@vibecontrols/agent 2026.820.1 → 2026.902.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/agent-config-5b0avmy6.js +2 -0
  2. package/dist/{agent-ready-tracker-y9wbqt6y.js → agent-ready-tracker-ez6r9djg.js} +1 -1
  3. package/dist/app-mhms2gs0.js +2 -0
  4. package/dist/autostart.cmd-4zb9xhj0.js +2 -0
  5. package/dist/bootstrap-workspace-t5fyq07m.js +2 -0
  6. package/dist/bootstrap.service-nxhkrsf1.js +2 -0
  7. package/dist/{bridge-client-emc7mttx.js → bridge-client-bgkr7bcn.js} +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/daemon-profile-j2wt35x8.js +2 -0
  10. package/dist/{esm-br6epktf.js → esm-n9r8p5n2.js} +1 -1
  11. package/dist/{finalize-retry-handle-registry-ndbsa6a3.js → finalize-retry-handle-registry-fvm4gm8s.js} +1 -1
  12. package/dist/{finalize-retry-worker-mfj115ek.js → finalize-retry-worker-wb8wj1yw.js} +1 -1
  13. package/dist/gateway-client-6dqagbg4.js +2 -0
  14. package/dist/{getMachineId-bsd-gvxzt2gm.js → getMachineId-bsd-fgatzdd7.js} +1 -1
  15. package/dist/{getMachineId-darwin-g66tx8f2.js → getMachineId-darwin-gt8j2jw2.js} +1 -1
  16. package/dist/{getMachineId-linux-f0mt4jq9.js → getMachineId-linux-bcz4rr1x.js} +1 -1
  17. package/dist/{getMachineId-unsupported-bsmqnjcv.js → getMachineId-unsupported-079qwwb4.js} +1 -1
  18. package/dist/{getMachineId-win-172fq57c.js → getMachineId-win-2hk4e8bg.js} +1 -1
  19. package/dist/highlights-0gfz787m.js +2 -0
  20. package/dist/highlights-86sbx76f.js +2 -0
  21. package/dist/highlights-n55f5jnk.js +2 -0
  22. package/dist/highlights-tbmszdr7.js +2 -0
  23. package/dist/highlights-wm2cs773.js +2 -0
  24. package/dist/{index-m1bteh0j.js → index-06es0fmw.js} +1 -1
  25. package/dist/{index-4f3ac5nf.js → index-0d4wfjbt.js} +2 -2
  26. package/dist/{index-ff8acg43.js → index-29fmptfn.js} +1 -1
  27. package/dist/index-2q2jadag.js +11 -0
  28. package/dist/{index-1hfchgm5.js → index-2sn36kaj.js} +1 -1
  29. package/dist/{index-jnrqbhew.js → index-3p4n7nwg.js} +1 -1
  30. package/dist/{index-hym4bq94.js → index-3tf12pw3.js} +1 -1
  31. package/dist/{index-2244sbdx.js → index-7wejfjj9.js} +3 -3
  32. package/dist/{index-tcew34xr.js → index-8q19ryt2.js} +1 -1
  33. package/dist/{index-6nz3c1ys.js → index-8xh8m2z7.js} +2 -2
  34. package/dist/{index-vd3njzs5.js → index-98gr644s.js} +29 -29
  35. package/dist/index-a8n6s2ae.js +2 -0
  36. package/dist/{index-najxwhng.js → index-b16y8wyz.js} +1 -1
  37. package/dist/{index-1xw2wxyf.js → index-df19rrbe.js} +1 -1
  38. package/dist/{index-xyfcpfec.js → index-dx9hjdp4.js} +2 -2
  39. package/dist/{index-97r6ekww.js → index-evnbrmdf.js} +1 -1
  40. package/dist/index-f2asckf0.js +26 -0
  41. package/dist/{index-r1v6p7vc.js → index-ggxs7nwz.js} +1 -1
  42. package/dist/{index-c4zn91z3.js → index-gz5t0vvc.js} +1 -1
  43. package/dist/{index-426ddch6.js → index-hp8jrj6j.js} +1 -1
  44. package/dist/{index-ywv7amgf.js → index-hrfkzecw.js} +1 -1
  45. package/dist/{index-4beawmtx.js → index-hz5cy6vz.js} +2 -2
  46. package/dist/{index-e0jbxcn1.js → index-jbxh0ffn.js} +2 -2
  47. package/dist/{index-sj39bx7y.js → index-js2r0men.js} +1 -1
  48. package/dist/{index-paxfq5k4.js → index-k3jkzj3k.js} +1 -1
  49. package/dist/{index-svtmb9t1.js → index-kteawn2b.js} +1 -1
  50. package/dist/{index-73qwyf9q.js → index-mbhq916m.js} +1 -1
  51. package/dist/{index-34g3tenj.js → index-qdbxvcwr.js} +1 -1
  52. package/dist/{index-axgp7ryd.js → index-qqq9qyy6.js} +3 -3
  53. package/dist/{index-jq7vqe4a.js → index-sspydg85.js} +1 -1
  54. package/dist/{index-81gn264d.js → index-tk81f249.js} +1 -1
  55. package/dist/{index-sasygg1e.js → index-vjdg5qb2.js} +1 -1
  56. package/dist/{index-wqwzfy0e.js → index-vkrf8kzp.js} +2 -2
  57. package/dist/{index-d384edvr.js → index-vnxqna70.js} +1 -1
  58. package/dist/{index-rhcsaqc0.js → index-w7gctzhm.js} +1 -1
  59. package/dist/{index-at6z8tds.js → index-x4eaagvr.js} +1 -1
  60. package/dist/{index-149rjxa5.js → index-xjr60th0.js} +1 -1
  61. package/dist/{index-a3mwtteb.js → index-xtbppqnv.js} +1 -1
  62. package/dist/index-y42xsgr6.js +133 -0
  63. package/dist/{index-gmwpaz2a.js → index-zr9rmjyp.js} +1 -1
  64. package/dist/index.js +2 -2
  65. package/dist/injections-2g0zh0bq.js +2 -0
  66. package/dist/interactive-08vyaapn.js +2 -0
  67. package/dist/key.cmd-642xcxb4.js +2 -0
  68. package/dist/log-shipper-9xfnjwr6.js +2 -0
  69. package/dist/{path-utils-rzsac4g6.js → path-utils-g449hqvm.js} +1 -1
  70. package/dist/{plugin-system-jww7bh2a.js → plugin-system-gpzcch00.js} +1 -1
  71. package/dist/prereqs-runner-re9f51fp.js +2 -0
  72. package/dist/profile-mount-txvgkaz8.js +2 -0
  73. package/dist/prune-stale-shims-vs6a07tb.js +2 -0
  74. package/dist/register-core-ma4kse87.js +2 -0
  75. package/dist/secondary-profile-attach-m9x9e7py.js +2 -0
  76. package/dist/subprocess-zcgpccp1.js +2 -0
  77. package/dist/telemetry-k6em3vy2.js +2 -0
  78. package/dist/tree-sitter-javascript-qh90w7td.js +2 -0
  79. package/dist/tree-sitter-markdown-favzteb6.js +2 -0
  80. package/dist/tree-sitter-markdown_inline-x2726t9j.js +2 -0
  81. package/dist/tree-sitter-typescript-m7ep8z1h.js +2 -0
  82. package/dist/tree-sitter-zig-3vsxg5wh.js +2 -0
  83. package/dist/tunnel-bootstrap-y8dczezc.js +2 -0
  84. package/package.json +1 -1
  85. package/dist/agent-config-t242qh84.js +0 -2
  86. package/dist/app-7rmybh7z.js +0 -2
  87. package/dist/autostart.cmd-arjjfy8k.js +0 -2
  88. package/dist/bootstrap-workspace-dvxqq79t.js +0 -2
  89. package/dist/bootstrap.service-3zpbgsg0.js +0 -2
  90. package/dist/daemon-profile-nbe3pww8.js +0 -2
  91. package/dist/gateway-client-dnjxwbnj.js +0 -2
  92. package/dist/highlights-3g7x1wxx.js +0 -2
  93. package/dist/highlights-66pe672g.js +0 -2
  94. package/dist/highlights-78tmcgkr.js +0 -2
  95. package/dist/highlights-dhv8z6p7.js +0 -2
  96. package/dist/highlights-j95xsvt4.js +0 -2
  97. package/dist/index-014sfc8c.js +0 -2
  98. package/dist/index-a9x5swye.js +0 -11
  99. package/dist/index-dpyv0pqb.js +0 -26
  100. package/dist/index-w893wd2g.js +0 -130
  101. package/dist/injections-2pt7wmtk.js +0 -2
  102. package/dist/interactive-svpgqn7v.js +0 -2
  103. package/dist/key.cmd-m0zst9pm.js +0 -2
  104. package/dist/log-shipper-m9h3jxem.js +0 -2
  105. package/dist/prereqs-runner-fhjjgzhw.js +0 -2
  106. package/dist/profile-mount-xchr4y5e.js +0 -2
  107. package/dist/prune-stale-shims-wttq2y0f.js +0 -2
  108. package/dist/register-core-n2kb3mhq.js +0 -2
  109. package/dist/secondary-profile-attach-yzwncw4f.js +0 -2
  110. package/dist/subprocess-chzm6zj2.js +0 -2
  111. package/dist/telemetry-h9pa43c9.js +0 -2
  112. package/dist/tree-sitter-javascript-jre8s337.js +0 -2
  113. package/dist/tree-sitter-markdown-3as64nwe.js +0 -2
  114. package/dist/tree-sitter-markdown_inline-rs74pnzp.js +0 -2
  115. package/dist/tree-sitter-typescript-dgsjhgb0.js +0 -2
  116. package/dist/tree-sitter-zig-p8cc70k0.js +0 -2
  117. package/dist/tunnel-bootstrap-6xm4w7dm.js +0 -2
@@ -0,0 +1,133 @@
1
+ // @bun
2
+ import{$a as l}from"./index-ea42kfvk.js";import{pc as L}from"./index-wj5hx7gq.js";import{Ac as Z,Bc as U,uc as f,wc as O,xc as E,yc as V,zc as W}from"./index-8xh8m2z7.js";import{ne as i,pe as m}from"./index-gz5t0vvc.js";import{existsSync as C,mkdirSync as A,writeFileSync as v,unlinkSync as P,readFileSync as s}from"fs";import{join as J}from"path";import{homedir as Q,platform as D}from"os";import{isAbsolute as r,resolve as e}from"path";function h(){return i()}function w(){return J(h(),"logs")}function b(){if(process.execPath&&process.execPath.includes("bun"))return process.execPath;let q=l().which("bun");if(q)return q;throw Error("Could not find bun binary. Ensure bun is installed and in PATH.")}function x(){return import.meta.dir.endsWith("/dist")||import.meta.dir.includes("/dist/")?J(import.meta.dir,"index.js"):J(import.meta.dir,"..","..","index.ts")}function N(q,z){if(/[\0\r\n]/.test(q))throw Error(`${z} contains invalid control characters`)}function j(q){if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(q))throw Error("Agent name must use 1-64 characters: letters, numbers, dot, underscore, or dash.");return q}function t(q){let z=parseInt(q,10);if(!Number.isInteger(z)||z<1||z>65535)throw Error("Port must be an integer between 1 and 65535");return z}function X(q){return N(q,"systemd value"),`"${q.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}function qq(q){if(N(q,"systemd path"),!r(q))throw Error(`systemd path must be absolute, got: ${q}`);return q}function M(q){let z=String(q);return N(z,"plist value"),z.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function k(q){let z=J(Q(),".config","systemd","user");return A(z,{recursive:!0}),J(z,`vibecontrols-agent-${q}.service`)}function p(q){return`[Unit]
3
+ Description=VibeControls Agent (${q.name})
4
+ After=network.target
5
+
6
+ [Service]
7
+ Type=simple
8
+ ExecStart=${X(q.bunPath)} run ${X(q.entryPoint)}
9
+ Environment=${X(`PORT=${q.port}`)}
10
+ Environment=${X(`DB_PATH=${q.dbPath}`)}${q.host?`
11
+ Environment=${X(`HOST=${q.host}`)}`:""}
12
+ Environment=NODE_ENV=production${q.profile?`
13
+ Environment=${X(`VIBECONTROLS_PROFILE=${q.profile}`)}`:""}${q.profiles?`
14
+ Environment=${X(`VIBECONTROLS_PROFILES=${q.profiles}`)}`:""}${q.home?`
15
+ Environment=${X(`VIBECONTROLS_HOME=${q.home}`)}`:""}${q.isolatePlugins?`
16
+ Environment=${X(`VIBE_ISOLATE_PLUGINS=${q.isolatePlugins}`)}`:""}
17
+ Environment=${X(`AGENT_LOG_FILE=${q.logFile}`)}
18
+ Environment=${X(`HOME=${Q()}`)}
19
+ Environment=${X(`PATH=${process.env.PATH??""}`)}
20
+ WorkingDirectory=${qq(Q())}
21
+ Restart=always
22
+ RestartSec=5
23
+ StandardOutput=append:${q.logFile}
24
+ StandardError=append:${q.logFile}
25
+
26
+ [Install]
27
+ WantedBy=default.target
28
+ `}async function zq(q,z,G,H={}){j(q),N(G,"dbPath");let K=b(),Y=x(),$=J(w(),`${q}.log`),_=k(q),B=`vibecontrols-agent-${q}.service`;A(w(),{recursive:!0});let I=p({name:q,port:z,dbPath:G,bunPath:K,entryPoint:Y,logFile:$,host:H.host,profile:H.profile,profiles:H.profiles,home:H.home,isolatePlugins:H.isolatePlugins});v(_,I),V(`Wrote systemd unit: ${_}`);let R=[["systemctl","--user","daemon-reload"],["systemctl","--user","enable",B],...H.skipStart?[]:[["systemctl","--user","start",B]]];for(let T of R){let F=Bun.spawnSync(T);if(F.exitCode!==0){let c=F.stderr.toString().trim();throw Error(`${T.join(" ")} failed (exit ${F.exitCode})${c?` \u2014 ${c}`:""}`)}}if(Bun.spawnSync(["loginctl","enable-linger",process.env.USER||""]).exitCode===0)V("Enabled user linger (service survives logout)");O(`Autostart installed for agent '${q}' on port ${z}`),Z("Service",B),Z("Unit file",_),Z("Log file",$),U(),V(`Check status: systemctl --user status ${B}`)}async function Gq(q){let z=`vibecontrols-agent-${q}.service`,G=k(q),H=[["systemctl","--user","stop",z],["systemctl","--user","disable",z]];for(let K of H)Bun.spawnSync(K);if(C(G))P(G),V(`Removed unit file: ${G}`);Bun.spawnSync(["systemctl","--user","daemon-reload"]),O(`Autostart removed for agent '${q}'`)}async function Hq(q){let z=`vibecontrols-agent-${q}.service`,G=k(q);if(!C(G)){V(`Autostart is NOT configured for agent '${q}'`),Z("Expected unit",G);return}W(`Autostart Status \u2014 ${q}`),Z("Unit file",G),Z("Service",z),U();let K=Bun.spawnSync(["systemctl","--user","status",z]).stdout.toString().trim();if(K)console.log(K);else V("Service status unavailable")}function y(q){let z=J(Q(),"Library","LaunchAgents");return A(z,{recursive:!0}),J(z,`com.boff.vibecontrols.agent.${q}.plist`)}function n(q){return`<?xml version="1.0" encoding="UTF-8"?>
29
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
30
+ <plist version="1.0">
31
+ <dict>
32
+ <key>Label</key>
33
+ <string>com.boff.vibecontrols.agent.${M(q.name)}</string>
34
+ <key>ProgramArguments</key>
35
+ <array>
36
+ <string>${M(q.bunPath)}</string>
37
+ <string>run</string>
38
+ <string>${M(q.entryPoint)}</string>
39
+ </array>
40
+ <key>EnvironmentVariables</key>
41
+ <dict>
42
+ <key>PORT</key>
43
+ <string>${M(q.port)}</string>
44
+ <key>DB_PATH</key>
45
+ <string>${M(q.dbPath)}</string>${q.host?`
46
+ <key>HOST</key>
47
+ <string>${M(q.host)}</string>`:""}
48
+ <key>NODE_ENV</key>
49
+ <string>production</string>${q.profile?`
50
+ <key>VIBECONTROLS_PROFILE</key>
51
+ <string>${M(q.profile)}</string>`:""}${q.profiles?`
52
+ <key>VIBECONTROLS_PROFILES</key>
53
+ <string>${M(q.profiles)}</string>`:""}${q.home?`
54
+ <key>VIBECONTROLS_HOME</key>
55
+ <string>${M(q.home)}</string>`:""}${q.isolatePlugins?`
56
+ <key>VIBE_ISOLATE_PLUGINS</key>
57
+ <string>${M(q.isolatePlugins)}</string>`:""}
58
+ <key>AGENT_LOG_FILE</key>
59
+ <string>${M(q.logFile)}</string>
60
+ <key>HOME</key>
61
+ <string>${M(Q())}</string>
62
+ <key>PATH</key>
63
+ <string>${M(process.env.PATH??"")}</string>
64
+ </dict>
65
+ <key>WorkingDirectory</key>
66
+ <string>${M(Q())}</string>
67
+ <key>RunAtLoad</key>
68
+ <true/>
69
+ <key>KeepAlive</key>
70
+ <dict>
71
+ <key>SuccessfulExit</key>
72
+ <false/>
73
+ </dict>
74
+ <key>StandardOutPath</key>
75
+ <string>${M(q.logFile)}</string>
76
+ <key>StandardErrorPath</key>
77
+ <string>${M(q.logFile)}</string>
78
+ <key>ProcessType</key>
79
+ <string>Background</string>
80
+ </dict>
81
+ </plist>
82
+ `}async function Kq(q,z,G,H={}){j(q),N(G,"dbPath");let K=b(),Y=x(),$=J(w(),`${q}.log`),_=y(q);A(w(),{recursive:!0});let B=n({name:q,port:z,dbPath:G,bunPath:K,entryPoint:Y,logFile:$,host:H.host,profile:H.profile,profiles:H.profiles,home:H.home,isolatePlugins:H.isolatePlugins});if(v(_,B),V(`Wrote launchd plist: ${_}`),H.skipStart){O(`Autostart configured for agent '${q}' on port ${z}`),Z("Plist",_),Z("Log file",$);return}let I=Bun.spawnSync(["launchctl","load",_]);if(I.exitCode!==0){let R=I.stderr.toString().trim();E(`launchctl load failed: ${R}`),V("Trying bootstrap method...");let S=Bun.spawnSync(["id","-u"]).stdout.toString().trim(),T=Bun.spawnSync(["launchctl","bootstrap",`gui/${S}`,_]);if(T.exitCode!==0){let F=T.stderr.toString().trim();throw Error(`launchctl could not load ${_}: load failed${R?` \u2014 ${R}`:""}; bootstrap failed (exit ${T.exitCode})${F?` \u2014 ${F}`:""}`)}}O(`Autostart installed for agent '${q}' on port ${z}`),Z("Plist",_),Z("Log file",$)}async function Mq(q){let z=y(q),G=`com.boff.vibecontrols.agent.${q}`;Bun.spawnSync(["launchctl","unload",z]);let H=Bun.spawnSync(["id","-u"]).stdout.toString().trim();if(Bun.spawnSync(["launchctl","bootout",`gui/${H}/${G}`]),C(z))P(z),V(`Removed plist: ${z}`);O(`Autostart removed for agent '${q}'`)}async function Yq(q){let z=y(q),G=`com.boff.vibecontrols.agent.${q}`;if(!C(z)){V(`Autostart is NOT configured for agent '${q}'`),Z("Expected plist",z);return}W(`Autostart Status \u2014 ${q}`),Z("Plist",z),Z("Label",G),U();let Y=Bun.spawnSync(["launchctl","list"]).stdout.toString().split(`
83
+ `).filter(($)=>$.includes("vibecontrols"));if(Y.length>0)console.log(Y.join(`
84
+ `));else V("Service not currently loaded")}function u(q){return`VibeControlsAgent_${q}`}function a(q){return J(h(),`autostart-${q}.xml`)}function Zq(q){let z=[`<Variable><Name>VIBECONTROLS_PROFILE</Name><Value>${M(q.name)}</Value></Variable>`,`<Variable><Name>PORT</Name><Value>${M(q.port)}</Value></Variable>`,`<Variable><Name>VIBECONTROLS_HOME</Name><Value>${M(q.configDir)}</Value></Variable>`];if(q.dbPath)z.push(`<Variable><Name>DB_PATH</Name><Value>${M(q.dbPath)}</Value></Variable>`);let G=process.env.USERNAME??process.env.USER??"User";return`<?xml version="1.0" encoding="UTF-16"?>
85
+ <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
86
+ <RegistrationInfo>
87
+ <Description>VibeControls Agent (${M(q.name)}) \u2014 auto-start on logon, restart on crash</Description>
88
+ </RegistrationInfo>
89
+ <Triggers>
90
+ <LogonTrigger>
91
+ <Enabled>true</Enabled>
92
+ <UserId>${M(G)}</UserId>
93
+ </LogonTrigger>
94
+ </Triggers>
95
+ <Principals>
96
+ <Principal id="Author">
97
+ <UserId>${M(G)}</UserId>
98
+ <LogonType>InteractiveToken</LogonType>
99
+ <RunLevel>LeastPrivilege</RunLevel>
100
+ </Principal>
101
+ </Principals>
102
+ <Settings>
103
+ <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
104
+ <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
105
+ <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
106
+ <AllowHardTerminate>true</AllowHardTerminate>
107
+ <StartWhenAvailable>true</StartWhenAvailable>
108
+ <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
109
+ <IdleSettings>
110
+ <StopOnIdleEnd>false</StopOnIdleEnd>
111
+ <RestartOnIdle>false</RestartOnIdle>
112
+ </IdleSettings>
113
+ <AllowStartOnDemand>true</AllowStartOnDemand>
114
+ <Enabled>true</Enabled>
115
+ <Hidden>true</Hidden>
116
+ <RunOnlyIfIdle>false</RunOnlyIfIdle>
117
+ <WakeToRun>false</WakeToRun>
118
+ <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
119
+ <Priority>7</Priority>
120
+ <RestartOnFailure>
121
+ <Interval>PT1M</Interval>
122
+ <Count>3</Count>
123
+ </RestartOnFailure>
124
+ </Settings>
125
+ <Actions Context="Author">
126
+ <Exec>
127
+ <Command>${M(q.bunPath)}</Command>
128
+ <Arguments>${M(q.entryPoint)} start --foreground --port ${M(q.port)} --name ${M(q.name)}${q.host?` --host ${M(q.host)}`:""}</Arguments>
129
+ <WorkingDirectory>${M(q.configDir)}</WorkingDirectory>
130
+ </Exec>
131
+ </Actions>
132
+ </Task>`}async function _q(q,z,G,H={}){let K=u(q),Y=a(q),$=h(),_=w();A($,{recursive:!0}),A(_,{recursive:!0});let B=b(),I=x(),R=Zq({name:q,port:z,host:H.host,dbPath:G,bunPath:B,entryPoint:I,configDir:$,logsDir:_}),S=Buffer.concat([Buffer.from([255,254]),Buffer.from(R,"utf16le")]);if(v(Y,S),Z("Task XML",Y),Bun.spawnSync(["schtasks","/Create","/TN",K,"/XML",Y,"/F"],{stdout:"inherit",stderr:"inherit"}).exitCode!==0)throw Error("schtasks /Create failed. Run from an elevated shell if your user lacks scheduler permission.");U(),O(`Autostart installed for agent '${q}' (Task: ${K})`),V("To start now without rebooting:"),V(` schtasks /Run /TN ${K}`)}async function $q(q){let z=u(q),G=a(q),H=Bun.spawnSync(["schtasks","/Delete","/TN",z,"/F"],{stdout:"pipe",stderr:"pipe"});if(H.exitCode!==0)E(`schtasks /Delete returned non-zero (${H.exitCode}). Task may not have existed.`);else O(`Removed scheduled task ${z}`);if(C(G))try{P(G)}catch{}}async function Vq(q){let z=u(q),G=Bun.spawnSync(["schtasks","/Query","/TN",z,"/V","/FO","LIST"],{stdout:"pipe",stderr:"pipe"});if(G.exitCode!==0){V(`Autostart is NOT configured for agent '${q}'`),Z("Expected task",z);return}W(`Autostart Status \u2014 ${q}`),Z("Task",z),U(),console.log(G.stdout.toString())}function d(q,z,G){if(!C(z))return!1;try{let H=G({bunPath:b(),entryPoint:x(),logFile:J(w(),`${q.name}.log`)});return s(z,"utf8")===H}catch{return!0}}function Xq(q){try{let z=Bun.spawnSync(["systemctl","--user","is-enabled",`vibecontrols-agent-${q}.service`]);if(z.exitCode===0)return!0;let G=z.stdout.toString().trim();return!["disabled","masked","linked",""].includes(G)}catch{return!0}}var o={linux:{label:"systemd",install:(q,z,G,H)=>zq(q,z,G??"./agent-db",H),uninstall:Gq,status:Hq,isCurrent:(q)=>d(q,k(q.name),(z)=>p({...q,...z}))&&Xq(q.name),autoConfigurable:!0},darwin:{label:"launchd",install:(q,z,G,H)=>Kq(q,z,G??"./agent-db",H),uninstall:Mq,status:Yq,isCurrent:(q)=>d(q,y(q.name),(z)=>n({...q,...z})),autoConfigurable:!0},win32:{label:"Task Scheduler",install:_q,uninstall:$q,status:Vq,isCurrent:()=>!0,autoConfigurable:!1}};function g(){let q=o[D()];if(!q)throw Error(`Autostart is not supported on ${D()}. Supported: linux (systemd), darwin (launchd), win32 (Task Scheduler).`);return q}async function Fq(q){let z=process.env.VIBECONTROLS_PROFILES||void 0,G=process.env.VIBECONTROLS_HOME||void 0,H=process.env.VIBE_ISOLATE_PLUGINS||void 0;if(process.env.VIBE_NO_AUTOSTART==="1"||process.env.VIBE_AUTOSTART==="0")return{installed:!1,reason:"opted out via env"};let K=o[D()];if(!K)return{installed:!1,reason:`unsupported platform ${D()}`};if(!K.autoConfigurable)return{installed:!1,reason:`${K.label} must be configured manually \u2014 run \`vibe autostart install\``};try{let Y={name:q.name,port:q.port,dbPath:q.dbPath??"./agent-db",host:q.host,profile:q.profile,profiles:z,home:G,isolatePlugins:H};if(K.isCurrent(Y))return{installed:!1,reason:"already configured"};return await K.install(q.name,q.port,q.dbPath,{skipStart:!0,host:q.host,profile:q.profile,profiles:z,home:G,isolatePlugins:H}),{installed:!0,serviceLabel:K.label}}catch(Y){return{installed:!1,failed:!0,reason:Y instanceof Error?Y.message:String(Y)}}}function Wq(q){let z=q.command("autostart").description("Configure agent to auto-start on system boot");z.command("install").description("Generate and enable system service for auto-start on reboot").option("-n, --name <name>","Agent instance name","default").option("-p, --port <port>","Port to listen on","3005").option("--db-path <path>","Agent storage directory (absolute path; default: ~/.boff/vibecontrols/agents/<profile>/agent-db)").option("--json","Emit JSON").action(async function(G){let H={...q.opts(),...G};try{let K=g(),Y=j(G.name),$=t(G.port),_=G.dbPath??null,B=m(),I=(()=>{if(!_)return B;if(r(_))return _;let R=e(B,"..",_);return E(`--db-path is relative; resolved to ${R}. Pass an absolute path to silence this warning.`),R})();if(!H.json)W("Installing Autostart"),Z("Platform",`${D()} (${K.label})`),Z("Agent",Y),Z("Port",String($)),Z("Database",I),U();await K.install(Y,$,I),L(H,{ok:!0,enabled:!0,name:Y,port:$})}catch(K){if(H.json)L(H,{ok:!1,error:String(K)}),process.exit(1);f(`Failed to install autostart: ${K}`),process.exit(1)}}),z.command("uninstall").description("Stop and remove the system service").option("-n, --name <name>","Agent instance name","default").option("--json","Emit JSON").action(async function(G){let H={...q.opts(),...G};try{let K=g(),Y=j(G.name);if(!H.json)W("Removing Autostart");await K.uninstall(Y),L(H,{ok:!0,enabled:!1,name:Y})}catch(K){if(H.json)L(H,{ok:!1,error:String(K)}),process.exit(1);f(`Failed to uninstall autostart: ${K}`),process.exit(1)}}),z.command("status").description("Check if autostart is configured and running").option("-n, --name <name>","Agent instance name","default").action(async(G)=>{try{let H=g(),K=j(G.name);await H.status(K)}catch(H){f(`Failed to check autostart status: ${H}`),process.exit(1)}})}
133
+ export{p as K,n as L,Fq as M,Wq as N};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{nc as O,oc as L,pc as Y}from"./index-wj5hx7gq.js";import{Ac as X,Bc as I,Cc as K,sc as D,uc as R,vc as U,wc as W,yc as C,zc as E}from"./index-6nz3c1ys.js";import{Wc as J,sd as T,ud as V,wd as w}from"./index-a9x5swye.js";import{ee as h}from"./index-c4zn91z3.js";async function P(){if(process.env.AGENT_API_KEY)return process.env.AGENT_API_KEY;let F="default";try{F=h()}catch{}let H=await J(`${F}:static-api-key`);if(H)return H;return T()["static-api-key"]??null}var j=["read","mutate","plugin:install","plugin:remove","update","admin"];function _(F){if(F.length<=12)return"[redacted]";return`${F.slice(0,8)}...${F.slice(-4)}`}function x(){let F=new Uint8Array(32);return crypto.getRandomValues(F),`vcak_${Buffer.from(F).toString("base64url")}`}function b(){return crypto.randomUUID()}function A(F){if(!F)return;let H=/^(\d+)([smhdw]?)$/.exec(F.trim());if(!H)throw Error(`Invalid --expires-in: ${F} (use 30s, 12h, 7d, 4w; bare digits = days)`);let q=Number(H[1]),N=H[2]||"d",z=N==="s"?q*1000:N==="m"?q*60000:N==="h"?q*3600000:N==="w"?q*7*86400000:q*86400000;return new Date(Date.now()+z).toISOString()}function S(F){if(!F)return["read"];let H=F.split(",").map((q)=>q.trim()).filter(Boolean);for(let q of H)if(!j.includes(q))throw Error(`Unknown scope: ${q}. Allowed: ${j.join(", ")}`);return H}function f(F){let H=F.command("key").description("Show or manage VibeControls agent API keys");H.command("show",{isDefault:!0}).description("Show the default agent API key").option("--show-secret","Print the full API key",!1).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(q){let N={...F.opts(),...q};try{await L({mode:O(N),fetchData:async()=>{return{apiKey:await P()??null}},plain:(z)=>{if(E("Agent API Key"),I(),!z.apiKey){R("No API key found in AGENT_API_KEY or local agent config.");return}if(X("API Key",D.bold(q.showSecret?z.apiKey:_(z.apiKey))),!q.showSecret)X("Full key",D.dim("hidden; rerun with --show-secret"));I()},json:(z)=>({apiKey:z.apiKey?q.showSecret?z.apiKey:"[redacted]":null})})}catch(z){R(`Failed to get API key: ${U(z)}`)}}),H.command("list").description("List all scoped API keys (default + minted)").option("--json","Emit JSON").option("--plain","Force plain text output").option("--show-secret","Include full key values in JSON output",!1).action(async function(q){let N={...F.opts(),...q};try{await L({mode:O(N),fetchData:()=>w(),plain:(z)=>{let B=[],Q=z["static-api-key"];if(Q)B.push({ID:"default",Name:"default",Scopes:"admin",Expires:"never",Key:_(Q)});for(let G of z.apiKeys??[])B.push({ID:G.id??"(legacy)",Name:G.name,Scopes:G.scopes.join(","),Expires:G.expiresAt??"never",Key:_(G.key)});if(B.length===0){C("No keys configured.");return}E("Agent API Keys"),K(B)},json:(z)=>{let B=[],Q=z["static-api-key"];if(Q)B.push({id:"default",name:"default",scopes:["admin"],expiresAt:null,key:q.showSecret?Q:"[redacted]"});for(let G of z.apiKeys??[])B.push({id:G.id??"(legacy)",name:G.name,scopes:G.scopes,expiresAt:G.expiresAt??null,key:q.showSecret?G.key:"[redacted]"});return B}})}catch(z){R(U(z))}}),H.command("add").description("Mint a new scoped API key").requiredOption("--name <name>","Display name (logs only)").option("--scope <scope>",`Comma-separated scope list (default: read). Allowed: ${j.join(",")}`,"read").option("--expires-in <duration>","TTL (e.g. 7d, 12h, 30m). Omit for no expiry.").option("--not-before <iso>","ISO timestamp before which the key is rejected.").option("--json","Emit JSON").action(function(q){let N={...F.opts(),...q};try{let z=S(q.scope),B=A(q.expiresIn),Q=T(),G=b(),Z=x(),$={id:G,name:q.name,key:Z,scopes:z,expiresAt:B,notBefore:q.notBefore,createdAt:new Date().toISOString()},M=[...Q.apiKeys??[],$];if(V({apiKeys:M}),Y(N,{ok:!0,id:G,name:q.name,scopes:z,expiresAt:B??null,key:Z}))return;if(W(`Minted key ${G}`),X("Name",q.name),X("Scopes",z.join(",")),B)X("Expires",B);if(q.notBefore)X("Not before",q.notBefore);I(),X("Key (save now)",D.bold(Z))}catch(z){if(N.json){Y(N,{ok:!1,error:U(z)});return}R(U(z))}}),H.command("revoke <id>").description("Revoke a scoped key by ID").option("--json","Emit JSON").action(function(q,N){let z={...F.opts(),...N};try{let B=T(),Q=(B.apiKeys??[]).length,G=(B.apiKeys??[]).filter((Z)=>Z.id!==q);if(G.length===Q){if(z.json){Y(z,{ok:!1,error:`No key with id ${q}`});return}R(`No key with id ${q}`);return}if(V({apiKeys:G}),Y(z,{ok:!0,id:q}))return;W(`Revoked key ${q}`)}catch(B){if(z.json){Y(z,{ok:!1,error:U(B)});return}R(U(B))}}),H.command("rotate <id>").description("Rotate the secret of an existing scoped key (preserves scopes/expiry)").option("--json","Emit JSON").action(function(q,N){let z={...F.opts(),...N};try{let B=T();if(!(B.apiKeys??[]).find(($)=>$.id===q)){if(z.json){Y(z,{ok:!1,error:`No key with id ${q}`});return}R(`No key with id ${q}`);return}let G=x(),Z=(B.apiKeys??[]).map(($)=>$.id===q?{...$,key:G}:$);if(V({apiKeys:Z}),Y(z,{ok:!0,id:q,key:G}))return;W(`Rotated key ${q}`),X("New key (save now)",D.bold(G))}catch(B){if(z.json){Y(z,{ok:!1,error:U(B)});return}R(U(B))}})}
2
+ import{nc as O,oc as L,pc as Y}from"./index-wj5hx7gq.js";import{Ac as X,Bc as I,Cc as K,sc as D,uc as R,vc as U,wc as W,yc as C,zc as E}from"./index-8xh8m2z7.js";import{Wc as J,td as T,vd as V,xd as w}from"./index-2q2jadag.js";import{ke as h}from"./index-gz5t0vvc.js";async function P(){if(process.env.AGENT_API_KEY)return process.env.AGENT_API_KEY;let F="default";try{F=h()}catch{}let H=await J(`${F}:static-api-key`);if(H)return H;return T()["static-api-key"]??null}var j=["read","mutate","plugin:install","plugin:remove","update","admin"];function _(F){if(F.length<=12)return"[redacted]";return`${F.slice(0,8)}...${F.slice(-4)}`}function x(){let F=new Uint8Array(32);return crypto.getRandomValues(F),`vcak_${Buffer.from(F).toString("base64url")}`}function b(){return crypto.randomUUID()}function A(F){if(!F)return;let H=/^(\d+)([smhdw]?)$/.exec(F.trim());if(!H)throw Error(`Invalid --expires-in: ${F} (use 30s, 12h, 7d, 4w; bare digits = days)`);let q=Number(H[1]),N=H[2]||"d",z=N==="s"?q*1000:N==="m"?q*60000:N==="h"?q*3600000:N==="w"?q*7*86400000:q*86400000;return new Date(Date.now()+z).toISOString()}function S(F){if(!F)return["read"];let H=F.split(",").map((q)=>q.trim()).filter(Boolean);for(let q of H)if(!j.includes(q))throw Error(`Unknown scope: ${q}. Allowed: ${j.join(", ")}`);return H}function f(F){let H=F.command("key").description("Show or manage VibeControls agent API keys");H.command("show",{isDefault:!0}).description("Show the default agent API key").option("--show-secret","Print the full API key",!1).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(q){let N={...F.opts(),...q};try{await L({mode:O(N),fetchData:async()=>{return{apiKey:await P()??null}},plain:(z)=>{if(E("Agent API Key"),I(),!z.apiKey){R("No API key found in AGENT_API_KEY or local agent config.");return}if(X("API Key",D.bold(q.showSecret?z.apiKey:_(z.apiKey))),!q.showSecret)X("Full key",D.dim("hidden; rerun with --show-secret"));I()},json:(z)=>({apiKey:z.apiKey?q.showSecret?z.apiKey:"[redacted]":null})})}catch(z){R(`Failed to get API key: ${U(z)}`)}}),H.command("list").description("List all scoped API keys (default + minted)").option("--json","Emit JSON").option("--plain","Force plain text output").option("--show-secret","Include full key values in JSON output",!1).action(async function(q){let N={...F.opts(),...q};try{await L({mode:O(N),fetchData:()=>w(),plain:(z)=>{let B=[],Q=z["static-api-key"];if(Q)B.push({ID:"default",Name:"default",Scopes:"admin",Expires:"never",Key:_(Q)});for(let G of z.apiKeys??[])B.push({ID:G.id??"(legacy)",Name:G.name,Scopes:G.scopes.join(","),Expires:G.expiresAt??"never",Key:_(G.key)});if(B.length===0){C("No keys configured.");return}E("Agent API Keys"),K(B)},json:(z)=>{let B=[],Q=z["static-api-key"];if(Q)B.push({id:"default",name:"default",scopes:["admin"],expiresAt:null,key:q.showSecret?Q:"[redacted]"});for(let G of z.apiKeys??[])B.push({id:G.id??"(legacy)",name:G.name,scopes:G.scopes,expiresAt:G.expiresAt??null,key:q.showSecret?G.key:"[redacted]"});return B}})}catch(z){R(U(z))}}),H.command("add").description("Mint a new scoped API key").requiredOption("--name <name>","Display name (logs only)").option("--scope <scope>",`Comma-separated scope list (default: read). Allowed: ${j.join(",")}`,"read").option("--expires-in <duration>","TTL (e.g. 7d, 12h, 30m). Omit for no expiry.").option("--not-before <iso>","ISO timestamp before which the key is rejected.").option("--json","Emit JSON").action(function(q){let N={...F.opts(),...q};try{let z=S(q.scope),B=A(q.expiresIn),Q=T(),G=b(),Z=x(),$={id:G,name:q.name,key:Z,scopes:z,expiresAt:B,notBefore:q.notBefore,createdAt:new Date().toISOString()},M=[...Q.apiKeys??[],$];if(V({apiKeys:M}),Y(N,{ok:!0,id:G,name:q.name,scopes:z,expiresAt:B??null,key:Z}))return;if(W(`Minted key ${G}`),X("Name",q.name),X("Scopes",z.join(",")),B)X("Expires",B);if(q.notBefore)X("Not before",q.notBefore);I(),X("Key (save now)",D.bold(Z))}catch(z){if(N.json){Y(N,{ok:!1,error:U(z)});return}R(U(z))}}),H.command("revoke <id>").description("Revoke a scoped key by ID").option("--json","Emit JSON").action(function(q,N){let z={...F.opts(),...N};try{let B=T(),Q=(B.apiKeys??[]).length,G=(B.apiKeys??[]).filter((Z)=>Z.id!==q);if(G.length===Q){if(z.json){Y(z,{ok:!1,error:`No key with id ${q}`});return}R(`No key with id ${q}`);return}if(V({apiKeys:G}),Y(z,{ok:!0,id:q}))return;W(`Revoked key ${q}`)}catch(B){if(z.json){Y(z,{ok:!1,error:U(B)});return}R(U(B))}}),H.command("rotate <id>").description("Rotate the secret of an existing scoped key (preserves scopes/expiry)").option("--json","Emit JSON").action(function(q,N){let z={...F.opts(),...N};try{let B=T();if(!(B.apiKeys??[]).find(($)=>$.id===q)){if(z.json){Y(z,{ok:!1,error:`No key with id ${q}`});return}R(`No key with id ${q}`);return}let G=x(),Z=(B.apiKeys??[]).map(($)=>$.id===q?{...$,key:G}:$);if(V({apiKeys:Z}),Y(z,{ok:!0,id:q,key:G}))return;W(`Rotated key ${q}`),X("New key (save now)",D.bold(G))}catch(B){if(z.json){Y(z,{ok:!1,error:U(B)});return}R(U(B))}})}
3
3
  export{P as _b,f as $b};
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{j as e,k as QQ,l as XQ,m as ZQ,n as HQ}from"./index-dpyv0pqb.js";import"./index-ywv7amgf.js";import{t as $Q}from"./index-1hfchgm5.js";import"./index-xyfcpfec.js";import"./index-6jzsthh9.js";import"./index-34g3tenj.js";import"./index-a3mwtteb.js";import"./index-ff8acg43.js";import"./index-rhcsaqc0.js";import"./index-hey6w5m0.js";import{Ha as t}from"./index-2244sbdx.js";import"./index-ea42kfvk.js";import"./index-rmh8pff5.js";import{fb as T}from"./index-at6z8tds.js";import"./index-ekr40gvh.js";import"./index-jnrqbhew.js";import{Mb as o,Nb as r}from"./index-d384edvr.js";import"./index-bv1z3fxw.js";import"./index-e0jbxcn1.js";import"./index-svtmb9t1.js";import{Bd as s,Cd as a,Wc as i,Xc as m,sd as E,wd as y}from"./index-a9x5swye.js";import{Wd as q}from"./index-axgp7ryd.js";import{ee as k,he as S,je as n,ke as U}from"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import{qe as B}from"./index-149rjxa5.js";async function P(Q,H={}){let X=H.readConfig??(async()=>{let Z=await y();return{clientId:Z.clientId,clientSecret:Z.clientSecret,workspaceId:Z.workspaceId,organizationId:Z.organizationId,globalGatewayUrl:Z.globalGatewayUrl,workspaceGatewayUrl:Z.workspaceGatewayUrl}});try{let Z=H.pinned?.clientId&&H.pinned?.clientSecret?{clientId:H.pinned.clientId,clientSecret:H.pinned.clientSecret}:null,Y=await X();if(!Y.clientId||!Y.clientSecret)return Q;return{clientId:Z?.clientId??Y.clientId,clientSecret:Z?.clientSecret??Y.clientSecret,workspaceId:Y.workspaceId??Q.workspaceId,organizationId:Y.organizationId??Q.organizationId,globalGatewayUrl:Y.globalGatewayUrl??Q.globalGatewayUrl,workspaceGatewayUrl:Y.workspaceGatewayUrl??Q.workspaceGatewayUrl}}catch(Z){let Y=Z instanceof Error?Z.message:String(Z);if(H.onReadError)H.onReadError(Y);else q().logger.warn("finalize-retry","Could not re-read stored credentials; retrying with the boot-time pair",{error:Y});return Q}}import{isAbsolute as EQ}from"path";import{existsSync as V,mkdirSync as d,readFileSync as IQ,readdirSync as f,renameSync as TQ,unlinkSync as yQ,writeFileSync as g}from"fs";import{dirname as c,join as F}from"path";var WQ=".secrets-migrated-v1",JQ=["static-api-key","clientId","clientSecret"];function VQ(Q,H){return`${Q}:${H}`}function p(){return F(U(),WQ)}function FQ(){let Q=p();d(c(Q),{recursive:!0}),g(Q,`${new Date().toISOString()}
3
+ import{j as e,k as QQ,l as XQ,m as ZQ,n as HQ}from"./index-f2asckf0.js";import"./index-hrfkzecw.js";import{t as $Q}from"./index-2sn36kaj.js";import"./index-dx9hjdp4.js";import"./index-6jzsthh9.js";import"./index-qdbxvcwr.js";import"./index-xtbppqnv.js";import"./index-29fmptfn.js";import"./index-w7gctzhm.js";import"./index-hey6w5m0.js";import{Ha as t}from"./index-7wejfjj9.js";import"./index-ea42kfvk.js";import"./index-rmh8pff5.js";import{fb as T}from"./index-x4eaagvr.js";import"./index-ekr40gvh.js";import"./index-3p4n7nwg.js";import{Mb as o,Nb as r}from"./index-vnxqna70.js";import"./index-bv1z3fxw.js";import"./index-jbxh0ffn.js";import"./index-kteawn2b.js";import{Hd as s,Id as a,Wc as i,Xc as m,td as E,xd as y}from"./index-2q2jadag.js";import{ae as q}from"./index-qqq9qyy6.js";import{ke as k,ne as S,pe as n,qe as U}from"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import{we as B}from"./index-xjr60th0.js";async function P(Q,H={}){let X=H.readConfig??(async()=>{let Z=await y();return{clientId:Z.clientId,clientSecret:Z.clientSecret,workspaceId:Z.workspaceId,organizationId:Z.organizationId,globalGatewayUrl:Z.globalGatewayUrl,workspaceGatewayUrl:Z.workspaceGatewayUrl}});try{let Z=H.pinned?.clientId&&H.pinned?.clientSecret?{clientId:H.pinned.clientId,clientSecret:H.pinned.clientSecret}:null,Y=await X();if(!Y.clientId||!Y.clientSecret)return Q;return{clientId:Z?.clientId??Y.clientId,clientSecret:Z?.clientSecret??Y.clientSecret,workspaceId:Y.workspaceId??Q.workspaceId,organizationId:Y.organizationId??Q.organizationId,globalGatewayUrl:Y.globalGatewayUrl??Q.globalGatewayUrl,workspaceGatewayUrl:Y.workspaceGatewayUrl??Q.workspaceGatewayUrl}}catch(Z){let Y=Z instanceof Error?Z.message:String(Z);if(H.onReadError)H.onReadError(Y);else q().logger.warn("finalize-retry","Could not re-read stored credentials; retrying with the boot-time pair",{error:Y});return Q}}import{isAbsolute as EQ}from"path";import{existsSync as V,mkdirSync as d,readFileSync as IQ,readdirSync as f,renameSync as TQ,unlinkSync as yQ,writeFileSync as g}from"fs";import{dirname as c,join as F}from"path";var WQ=".secrets-migrated-v1",JQ=["static-api-key","clientId","clientSecret"];function VQ(Q,H){return`${Q}:${H}`}function p(){return F(U(),WQ)}function FQ(){let Q=p();d(c(Q),{recursive:!0}),g(Q,`${new Date().toISOString()}
4
4
  `,{mode:384})}function KQ(Q){if(!V(Q))return null;try{let H=IQ(Q,"utf8"),X=JSON.parse(H);if(X&&typeof X==="object"&&!Array.isArray(X))return X}catch{}return null}function MQ(Q,H){d(c(Q),{recursive:!0});let X=`${Q}.${process.pid}.tmp`;g(X,`${JSON.stringify(H,null,2)}
5
- `,{mode:384}),TQ(X,Q)}function UQ(){let Q=U(),H=F(Q,"agents");if(!V(H))return[];let X=[],Z;try{Z=f(H)}catch{return[]}for(let Y of Z){let z=F(H,Y,"config.json");if(!V(z))continue;X.push({path:z,scope:Y})}return X}function RQ(){let Q=U(),H=F(Q,"profiles");if(!V(H))return[];let X=[],Z;try{Z=f(H)}catch{return[]}for(let Y of Z){if(!Y.endsWith(".json"))continue;X.push({path:F(H,Y),scope:Y.slice(0,-5)})}return X}async function jQ(Q,H){let X=KQ(Q);if(!X)return 0;let Z=0;for(let Y of JQ){let z=X[Y];if(typeof z!=="string"||z.length===0)continue;let _=VQ(H,Y);try{await m(_,z),delete X[Y],Z++,q().logger.info("secrets-migrator","migrated field",{path:Q,scope:H,key:Y})}catch(G){q().logger.warn("secrets-migrator","failed to migrate field",{path:Q,scope:H,key:Y,error:String(G)})}}if(Z>0)MQ(Q,X);return Z}async function l(){let Q={alreadyMigrated:!1,fieldsMoved:0,filesUpdated:0};if(V(p()))return Q.alreadyMigrated=!0,Q;let H=[...UQ(),...RQ()];for(let X of H){let Z;try{Z=await jQ(X.path,X.scope)}catch(Y){q().logger.warn("secrets-migrator","skipping target after error",{path:X.path,error:String(Y)});continue}if(Z>0)Q.fieldsMoved+=Z,Q.filesUpdated++}try{FQ()}catch(X){q().logger.warn("secrets-migrator","failed to drop migration marker",{error:String(X)})}if(Q.fieldsMoved>0)q().logger.info("secrets-migrator","migration complete",{fieldsMoved:Q.fieldsMoved,filesUpdated:Q.filesUpdated});return Q}{let Q=JSON.parse.bind(JSON);JSON.parse=(Z,Y)=>{try{return Q(Z,Y)}catch(z){if(typeof Z==="string"&&Z.endsWith("}}"))try{return Q(Z.slice(0,-1),Y)}catch{}throw z}};let X=globalThis.Request?.prototype;if(X&&typeof X.json==="function"){let Z=X.json;X.json=async function(){let z=await this.text();if(!z)return;try{return Q(z)}catch{if(z.endsWith("}}"))try{return Q(z.slice(0,-1))}catch{}let _=new Request("http://shim/",{method:"POST",body:z});return Z.call(_)}}}}$Q();s();if(!process.env.VIBECONTROLS_DATA_DIR)process.env.VIBECONTROLS_DATA_DIR=S();if(typeof Bun>"u")console.error("ERROR: VibeControls Agent requires Bun runtime."),console.error("Install Bun: https://bun.sh"),process.exit(1);function wQ(Q){if(Q==="default")return 3005;let H=2166136261;for(let X=0;X<Q.length;X++)H=Math.imul(H^Q.charCodeAt(X),16777619);return 3100+Math.abs(H)%300}var w=(()=>{try{return k()}catch{return"default"}})(),x=Number.parseInt(process.env.PORT||String(wQ(w)),10),R=Number.isInteger(x)&&x>0?x:3005,j=process.env.HOST||"0.0.0.0",CQ=(()=>{let Q=process.env.DB_PATH;if(!Q)return;if(EQ(Q))return Q;console.warn(`[boot] Ignoring relative DB_PATH=${Q} (cwd=${process.cwd()}). Use an absolute path or unset to fall back to ${n()}.`);return})(),D=process.env.AGENT_API_KEY||void 0,AQ=process.env.LOG_LEVEL||"info",xQ=process.env.CORS_ORIGIN||void 0;async function DQ(){try{await l()}catch(L){q().logger.warn("server","secrets migration encountered an error",{error:String(L)})}let Q=E()["static-api-key"],H=(()=>{try{return k()}catch{return"default"}})(),X=Q??await i(`${H}:static-api-key`),Z=!D&&!X;await o();let Y={clientId:process.env.VIBE_CLIENT_ID,clientSecret:process.env.VIBE_CLIENT_SECRET};await a();let z=process.env.VIBE_CLIENT_ID,_=process.env.VIBE_CLIENT_SECRET,G=process.env.VIBE_GLOBAL_GATEWAY_URL,u=process.env.VIBE_WORKSPACE_GATEWAY_URL,h=process.env.VIBE_WORKSPACE_ID,YQ=!!z&&!!_&&!!G&&!!u&&!!h;q().logger.info("server","Starting VibeControls Agent...",{runtime:"bun",bunVersion:Bun.version,port:R,host:j,env:"production"});try{let L=E(),$=L["telemetry.enabled"]===!0||L["telemetry.enabled"]==="true";T.init({persisted:$});let N=Date.now();T.emit("agent.started",{version:process.env.npm_package_version??"unknown",profile:w,platform:process.platform}),process.__vibe_started_at=N}catch{}let K=Math.max(1,Number.parseInt(process.env.VIBECONTROLS_AGENT_BOOT_RETRIES??"10",10)||10),LQ=(L)=>{let $=String(L?.message??L).toLowerCase();return $.includes("syntax")||$.includes("cannot find module")||$.includes("module not found")||$.includes("typeerror")||$.includes("config schema")||$.includes("invalid config")||$.includes("corrupt")||$.includes("eaccess")||$.includes("eperm")},O=null,I=0;while(!O){I++;try{O=await HQ({port:R,host:j,dbPath:CQ,apiKey:D,logLevel:AQ,corsOrigin:xQ}),await O.start();try{let L=await import("fs"),$=`${S()}/runtime.json`;L.writeFileSync($,JSON.stringify({pid:process.pid,port:R,host:j,profile:w,startedAt:new Date().toISOString(),version:t()},null,2));let N=()=>{try{if(L.existsSync($))L.unlinkSync($)}catch{}};process.once("SIGTERM",N),process.once("SIGINT",N),process.once("exit",N)}catch(L){q().logger.warn("server","Could not write runtime.json",{error:String(L)})}}catch(L){let $=LQ(L);if(q().logger.error("server","Failed to start agent server",{attempt:I,maxBootAttempts:K,fatal:$,error:String(L)}),$||I>=K)console.error(`\u274C Failed to start VibeControls Agent (attempt ${I}/${K}, fatal=${$}):`,L),process.exit(1);let N=Math.min(30000,1000*2**Math.min(5,I-1)),J=Math.floor(Math.random()*500),M=N+J;console.warn(`\u26A0\uFE0F Agent boot attempt ${I}/${K} failed (transient), retrying in ${Math.round(M/1000)}s...`),await new Promise((A)=>setTimeout(A,M)),O=null}}let b=O.getServiceRegistry().getProvider("tunnel"),W=null;if(b?.getActiveTunnelUrl)for(let L=0;L<30;L++){if(W=await b.getActiveTunnelUrl(),W)break;await new Promise(($)=>setTimeout($,1000))}if(!W){let{sanitizeEnvSuffix:L}=await import("./tunnel-bootstrap-6xm4w7dm.js"),{getVibecontrolsProfile:$}=await import("./path-utils-rzsac4g6.js"),N=L($());W=process.env[`AGENT_TUNNEL_URL_${N}`]??process.env.AGENT_TUNNEL_URL??null}let NQ=E(),qQ=D||r()||NQ["static-api-key"]||"",C=q().getBootState(),zQ=C==="ready"?null:e();if(C==="ready")QQ();kQ({port:R,host:j,tunnelUrl:W,apiKey:qQ,revealApiKey:Z||process.env.AGENT_PRINT_API_KEY==="1",state:C,pairingToken:zQ});try{XQ({profile:w})}catch(L){q().logger.warn("server","Could not start autoupdate",{error:String(L)})}let{existsSync:OQ,unlinkSync:_Q}=await import("fs"),{tmpdir:BQ}=await import("os"),{join:GQ}=await import("path"),v=async(L)=>{q().logger.info("server",`Received ${L}, shutting down...`),ZQ();try{let N=process.__vibe_started_at??Date.now();T.emit("agent.stopped",{uptime_s:Math.round((Date.now()-N)/1000),reason:L}),await T.flush(),T.stop()}catch{}let $=O.getLifecycle();if(L==="SIGTERM"){let N=GQ(BQ(),`.boff-vibecontrols-kill-${process.pid}`);if(OQ(N)){try{_Q(N)}catch{}if(q().logger.info("server","Kill-intent flag detected \u2014 full shutdown"),$)await $.kill();else await O.stop({reason:"shutdown"}),process.exit(0)}else if(q().logger.info("server","No kill flag \u2014 treating as hot-reload (soft stop)"),$)await $.softStop();else await O.stop({reason:"reload"})}else if($)await $.kill();else await O.stop({reason:"shutdown"}),process.exit(0)};if(process.on("SIGINT",()=>v("SIGINT")),process.on("SIGTERM",()=>v("SIGTERM")),YQ){let L=(()=>{let $=process.env.VIBECONTROLS_FINALIZE_TIMEOUT_MS,N=$?Number.parseInt($,10):NaN;return Number.isFinite(N)&&N>0?N:300000})();q().logger.info("server",`VIBE_* env vars detected \u2014 running inline finalize (timeout ${Math.round(L/1000)}s)`),(async()=>{let $={clientId:z,clientSecret:_,workspaceId:h,globalGatewayUrl:G,workspaceGatewayUrl:u};try{let N=await Promise.race([O.finalize($),new Promise((J)=>setTimeout(()=>J({ok:!1,error:`inline finalize timed out after ${Math.round(L/1000)}s`}),L))]);if(!N.ok){q().logger.warn("server","Inline finalize failed \u2014 agent stays awaiting-config. Background retry worker will keep trying.",{error:N.error});let{startFinalizeRetryWorker:J}=await import("./finalize-retry-worker-mfj115ek.js"),{setFinalizeRetryHandle:M}=await import("./finalize-retry-handle-registry-ndbsa6a3.js"),A=J({trigger:async()=>O.finalize(await P($,{pinned:Y}))});M(A)}}catch(N){q().logger.error("server","Inline finalize threw",{error:String(N)})}})()}else q().logger.info("server","Agent is awaiting gateway credentials. Add it on the VibeControls platform using the tunnel URL and API key shown above.")}function kQ(Q){let X=(G)=>("\u2551 "+G).padEnd(65)+"\u2551",Z="\u2560"+"\u2550".repeat(64)+"\u2563",Y="\u2554"+"\u2550".repeat(64)+"\u2557",z="\u255A"+"\u2550".repeat(64)+"\u255D",_=Q.revealApiKey?Q.apiKey:Q.apiKey?`${Q.apiKey.substring(0,8)}****${Q.apiKey.substring(Q.apiKey.length-4)}`:"(none)";if(console.log(""),console.log(Y),console.log(X("VibeControls Agent")),console.log(Z),console.log(X(`State: ${Q.state}`)),console.log(X(`Agent URL: http://${Q.host}:${Q.port}`)),console.log(X(`API Key: ${_}`)),console.log(X(`Tunnel URL: ${Q.tunnelUrl??"(none)"}`)),Q.pairingToken)console.log(X(`Pairing: ${Q.pairingToken}`)),console.log(X(" (send as x-pairing-token on bootstrap)"));if(console.log(Z),console.log(X(`Health: http://localhost:${Q.port}/health`)),console.log(X(`Status: http://localhost:${Q.port}/api/agent/status`)),console.log(z),!Q.revealApiKey)console.log(" (Set AGENT_PRINT_API_KEY=1 to print the API key in full.)");console.log("")}DQ();
5
+ `,{mode:384}),TQ(X,Q)}function UQ(){let Q=U(),H=F(Q,"agents");if(!V(H))return[];let X=[],Z;try{Z=f(H)}catch{return[]}for(let Y of Z){let z=F(H,Y,"config.json");if(!V(z))continue;X.push({path:z,scope:Y})}return X}function RQ(){let Q=U(),H=F(Q,"profiles");if(!V(H))return[];let X=[],Z;try{Z=f(H)}catch{return[]}for(let Y of Z){if(!Y.endsWith(".json"))continue;X.push({path:F(H,Y),scope:Y.slice(0,-5)})}return X}async function jQ(Q,H){let X=KQ(Q);if(!X)return 0;let Z=0;for(let Y of JQ){let z=X[Y];if(typeof z!=="string"||z.length===0)continue;let _=VQ(H,Y);try{await m(_,z),delete X[Y],Z++,q().logger.info("secrets-migrator","migrated field",{path:Q,scope:H,key:Y})}catch(G){q().logger.warn("secrets-migrator","failed to migrate field",{path:Q,scope:H,key:Y,error:String(G)})}}if(Z>0)MQ(Q,X);return Z}async function l(){let Q={alreadyMigrated:!1,fieldsMoved:0,filesUpdated:0};if(V(p()))return Q.alreadyMigrated=!0,Q;let H=[...UQ(),...RQ()];for(let X of H){let Z;try{Z=await jQ(X.path,X.scope)}catch(Y){q().logger.warn("secrets-migrator","skipping target after error",{path:X.path,error:String(Y)});continue}if(Z>0)Q.fieldsMoved+=Z,Q.filesUpdated++}try{FQ()}catch(X){q().logger.warn("secrets-migrator","failed to drop migration marker",{error:String(X)})}if(Q.fieldsMoved>0)q().logger.info("secrets-migrator","migration complete",{fieldsMoved:Q.fieldsMoved,filesUpdated:Q.filesUpdated});return Q}{let Q=JSON.parse.bind(JSON);JSON.parse=(Z,Y)=>{try{return Q(Z,Y)}catch(z){if(typeof Z==="string"&&Z.endsWith("}}"))try{return Q(Z.slice(0,-1),Y)}catch{}throw z}};let X=globalThis.Request?.prototype;if(X&&typeof X.json==="function"){let Z=X.json;X.json=async function(){let z=await this.text();if(!z)return;try{return Q(z)}catch{if(z.endsWith("}}"))try{return Q(z.slice(0,-1))}catch{}let _=new Request("http://shim/",{method:"POST",body:z});return Z.call(_)}}}}$Q();s();if(!process.env.VIBECONTROLS_DATA_DIR)process.env.VIBECONTROLS_DATA_DIR=S();if(typeof Bun>"u")console.error("ERROR: VibeControls Agent requires Bun runtime."),console.error("Install Bun: https://bun.sh"),process.exit(1);function wQ(Q){if(Q==="default")return 3005;let H=2166136261;for(let X=0;X<Q.length;X++)H=Math.imul(H^Q.charCodeAt(X),16777619);return 3100+Math.abs(H)%300}var w=(()=>{try{return k()}catch{return"default"}})(),x=Number.parseInt(process.env.PORT||String(wQ(w)),10),R=Number.isInteger(x)&&x>0?x:3005,j=process.env.HOST||"0.0.0.0",CQ=(()=>{let Q=process.env.DB_PATH;if(!Q)return;if(EQ(Q))return Q;console.warn(`[boot] Ignoring relative DB_PATH=${Q} (cwd=${process.cwd()}). Use an absolute path or unset to fall back to ${n()}.`);return})(),D=process.env.AGENT_API_KEY||void 0,AQ=process.env.LOG_LEVEL||"info",xQ=process.env.CORS_ORIGIN||void 0;async function DQ(){try{await l()}catch(L){q().logger.warn("server","secrets migration encountered an error",{error:String(L)})}let Q=E()["static-api-key"],H=(()=>{try{return k()}catch{return"default"}})(),X=Q??await i(`${H}:static-api-key`),Z=!D&&!X;await o();let Y={clientId:process.env.VIBE_CLIENT_ID,clientSecret:process.env.VIBE_CLIENT_SECRET};await a();let z=process.env.VIBE_CLIENT_ID,_=process.env.VIBE_CLIENT_SECRET,G=process.env.VIBE_GLOBAL_GATEWAY_URL,u=process.env.VIBE_WORKSPACE_GATEWAY_URL,h=process.env.VIBE_WORKSPACE_ID,YQ=!!z&&!!_&&!!G&&!!u&&!!h;q().logger.info("server","Starting VibeControls Agent...",{runtime:"bun",bunVersion:Bun.version,port:R,host:j,env:"production"});try{let L=E(),$=L["telemetry.enabled"]===!0||L["telemetry.enabled"]==="true";T.init({persisted:$});let N=Date.now();T.emit("agent.started",{version:process.env.npm_package_version??"unknown",profile:w,platform:process.platform}),process.__vibe_started_at=N}catch{}let K=Math.max(1,Number.parseInt(process.env.VIBECONTROLS_AGENT_BOOT_RETRIES??"10",10)||10),LQ=(L)=>{let $=String(L?.message??L).toLowerCase();return $.includes("syntax")||$.includes("cannot find module")||$.includes("module not found")||$.includes("typeerror")||$.includes("config schema")||$.includes("invalid config")||$.includes("corrupt")||$.includes("eaccess")||$.includes("eperm")},O=null,I=0;while(!O){I++;try{O=await HQ({port:R,host:j,dbPath:CQ,apiKey:D,logLevel:AQ,corsOrigin:xQ}),await O.start();try{let L=await import("fs"),$=`${S()}/runtime.json`;L.writeFileSync($,JSON.stringify({pid:process.pid,port:R,host:j,profile:w,startedAt:new Date().toISOString(),version:t()},null,2));let N=()=>{try{if(L.existsSync($))L.unlinkSync($)}catch{}};process.once("SIGTERM",N),process.once("SIGINT",N),process.once("exit",N)}catch(L){q().logger.warn("server","Could not write runtime.json",{error:String(L)})}}catch(L){let $=LQ(L);if(q().logger.error("server","Failed to start agent server",{attempt:I,maxBootAttempts:K,fatal:$,error:String(L)}),$||I>=K)console.error(`\u274C Failed to start VibeControls Agent (attempt ${I}/${K}, fatal=${$}):`,L),process.exit(1);let N=Math.min(30000,1000*2**Math.min(5,I-1)),J=Math.floor(Math.random()*500),M=N+J;console.warn(`\u26A0\uFE0F Agent boot attempt ${I}/${K} failed (transient), retrying in ${Math.round(M/1000)}s...`),await new Promise((A)=>setTimeout(A,M)),O=null}}let b=O.getServiceRegistry().getProvider("tunnel"),W=null;if(b?.getActiveTunnelUrl)for(let L=0;L<30;L++){if(W=await b.getActiveTunnelUrl(),W)break;await new Promise(($)=>setTimeout($,1000))}if(!W){let{sanitizeEnvSuffix:L}=await import("./tunnel-bootstrap-y8dczezc.js"),{getVibecontrolsProfile:$}=await import("./path-utils-g449hqvm.js"),N=L($());W=process.env[`AGENT_TUNNEL_URL_${N}`]??process.env.AGENT_TUNNEL_URL??null}let NQ=E(),qQ=D||r()||NQ["static-api-key"]||"",C=q().getBootState(),zQ=C==="ready"?null:e();if(C==="ready")QQ();kQ({port:R,host:j,tunnelUrl:W,apiKey:qQ,revealApiKey:Z||process.env.AGENT_PRINT_API_KEY==="1",state:C,pairingToken:zQ});try{XQ({profile:w})}catch(L){q().logger.warn("server","Could not start autoupdate",{error:String(L)})}let{existsSync:OQ,unlinkSync:_Q}=await import("fs"),{tmpdir:BQ}=await import("os"),{join:GQ}=await import("path"),v=async(L)=>{q().logger.info("server",`Received ${L}, shutting down...`),ZQ();try{let N=process.__vibe_started_at??Date.now();T.emit("agent.stopped",{uptime_s:Math.round((Date.now()-N)/1000),reason:L}),await T.flush(),T.stop()}catch{}let $=O.getLifecycle();if(L==="SIGTERM"){let N=GQ(BQ(),`.boff-vibecontrols-kill-${process.pid}`);if(OQ(N)){try{_Q(N)}catch{}if(q().logger.info("server","Kill-intent flag detected \u2014 full shutdown"),$)await $.kill();else await O.stop({reason:"shutdown"}),process.exit(0)}else if(q().logger.info("server","No kill flag \u2014 treating as hot-reload (soft stop)"),$)await $.softStop();else await O.stop({reason:"reload"})}else if($)await $.kill();else await O.stop({reason:"shutdown"}),process.exit(0)};if(process.on("SIGINT",()=>v("SIGINT")),process.on("SIGTERM",()=>v("SIGTERM")),YQ){let L=(()=>{let $=process.env.VIBECONTROLS_FINALIZE_TIMEOUT_MS,N=$?Number.parseInt($,10):NaN;return Number.isFinite(N)&&N>0?N:300000})();q().logger.info("server",`VIBE_* env vars detected \u2014 running inline finalize (timeout ${Math.round(L/1000)}s)`),(async()=>{let $={clientId:z,clientSecret:_,workspaceId:h,globalGatewayUrl:G,workspaceGatewayUrl:u};try{let N=await Promise.race([O.finalize($),new Promise((J)=>setTimeout(()=>J({ok:!1,error:`inline finalize timed out after ${Math.round(L/1000)}s`}),L))]);if(!N.ok){q().logger.warn("server","Inline finalize failed \u2014 agent stays awaiting-config. Background retry worker will keep trying.",{error:N.error});let{startFinalizeRetryWorker:J}=await import("./finalize-retry-worker-wb8wj1yw.js"),{setFinalizeRetryHandle:M}=await import("./finalize-retry-handle-registry-fvm4gm8s.js"),A=J({trigger:async()=>O.finalize(await P($,{pinned:Y}))});M(A)}}catch(N){q().logger.error("server","Inline finalize threw",{error:String(N)})}})()}else q().logger.info("server","Agent is awaiting gateway credentials. Add it on the VibeControls platform using the tunnel URL and API key shown above.")}function kQ(Q){let X=(G)=>("\u2551 "+G).padEnd(65)+"\u2551",Z="\u2560"+"\u2550".repeat(64)+"\u2563",Y="\u2554"+"\u2550".repeat(64)+"\u2557",z="\u255A"+"\u2550".repeat(64)+"\u255D",_=Q.revealApiKey?Q.apiKey:Q.apiKey?`${Q.apiKey.substring(0,8)}****${Q.apiKey.substring(Q.apiKey.length-4)}`:"(none)";if(console.log(""),console.log(Y),console.log(X("VibeControls Agent")),console.log(Z),console.log(X(`State: ${Q.state}`)),console.log(X(`Agent URL: http://${Q.host}:${Q.port}`)),console.log(X(`API Key: ${_}`)),console.log(X(`Tunnel URL: ${Q.tunnelUrl??"(none)"}`)),Q.pairingToken)console.log(X(`Pairing: ${Q.pairingToken}`)),console.log(X(" (send as x-pairing-token on bootstrap)"));if(console.log(Z),console.log(X(`Health: http://localhost:${Q.port}/health`)),console.log(X(`Status: http://localhost:${Q.port}/api/agent/status`)),console.log(z),!Q.revealApiKey)console.log(" (Set AGENT_PRINT_API_KEY=1 to print the API key in full.)");console.log("")}DQ();
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-xjr60th0.js";var t="./injections-73j83es3.scm";export{t as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Jc as a,Kc as b,Lc as c,Mc as d,Nc as e}from"./index-js2r0men.js";import"./index-xjr60th0.js";export{a as stripAnsi,b as interactiveTable,d as interactiveSelect,c as interactiveDetail,e as interactiveCheckboxes};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$b as b,_b as a}from"./index-zr9rmjyp.js";import"./index-8q19ryt2.js";import"./index-wj5hx7gq.js";import"./index-8xh8m2z7.js";import"./index-js2r0men.js";import"./index-kteawn2b.js";import"./index-2q2jadag.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as resolveDefaultApiKey,b as register};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{se as a}from"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as logShipper};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{de as a,ee as b,fe as c,ge as d,he as e,ie as f,je as g,ke as h,le as i}from"./index-c4zn91z3.js";import"./index-149rjxa5.js";export{c as validateAgentName,d as isPathInside,f as getVibecontrolsProfilesDir,b as getVibecontrolsProfile,h as getVibecontrolsProductDir,e as getVibecontrolsDir,g as getProfileDataDir,i as getPluginRegistry,a as assertValidProfile};
2
+ import{je as a,ke as b,le as c,me as d,ne as e,oe as f,pe as g,qe as h,re as i}from"./index-gz5t0vvc.js";import"./index-xjr60th0.js";export{c as validateAgentName,d as isPathInside,f as getVibecontrolsProfilesDir,b as getVibecontrolsProfile,h as getVibecontrolsProductDir,e as getVibecontrolsDir,g as getProfileDataDir,i as getPluginRegistry,a as assertValidProfile};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ka as a,Ma as b,Ua as c,Va as d,Wa as e,Xa as f,Ya as g,Za as h,_a as i}from"./index-2244sbdx.js";import"./index-ea42kfvk.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{f as validatePluginPackageName,c as getRegistryAllowlist,e as getPluginPackageRoot,g as getInstallScope,d as assertRegistryAllowed,b as TRUSTED_PACKAGES,i as PluginManager,h as DEFAULT_PLUGINS,a as CORE_PLUGIN_NAMES};
2
+ import{Ka as a,Ma as b,Ua as c,Va as d,Wa as e,Xa as f,Ya as g,Za as h,_a as i}from"./index-7wejfjj9.js";import"./index-ea42kfvk.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{f as validatePluginPackageName,c as getRegistryAllowlist,e as getPluginPackageRoot,g as getInstallScope,d as assertRegistryAllowed,b as TRUSTED_PACKAGES,i as PluginManager,h as DEFAULT_PLUGINS,a as CORE_PLUGIN_NAMES};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{d as a,e as b}from"./index-ggxs7nwz.js";import"./index-evnbrmdf.js";import"./index-bv1z3fxw.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as runPluginPrereqs,b as readPrereqState};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{rb as a,sb as b,tb as c,ub as d,vb as e,wb as f}from"./index-3p4n7nwg.js";import"./index-vnxqna70.js";import"./index-bv1z3fxw.js";import"./index-jbxh0ffn.js";import"./index-2q2jadag.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{b as unmountProfileRoutes,a as mountProfileRoutes,c as dispatchProfileRequest,f as __setMountForTests,e as __resetProfileMountsForTests,d as __listMountedProfilesForTests};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{H as a}from"./index-mxc61yr1.js";import"./index-xjr60th0.js";export{a as pruneStaleBunBinShims};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{J as a}from"./index-98gr644s.js";import"./index-y42xsgr6.js";import"./index-evnbrmdf.js";import"./index-hwpmdq5z.js";import"./index-54mmh1eb.js";import"./index-qdbxvcwr.js";import"./index-xtbppqnv.js";import"./index-29fmptfn.js";import"./index-hey6w5m0.js";import"./index-7wejfjj9.js";import"./index-ea42kfvk.js";import"./index-rmh8pff5.js";import"./index-x4eaagvr.js";import"./index-ekr40gvh.js";import"./index-vnxqna70.js";import"./index-bv1z3fxw.js";import"./index-jbxh0ffn.js";import"./index-8q19ryt2.js";import"./index-wj5hx7gq.js";import"./index-8xh8m2z7.js";import"./index-js2r0men.js";import"./index-kteawn2b.js";import"./index-2q2jadag.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as registerCoreCommands};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{x as a}from"./index-dx9hjdp4.js";import"./index-w7gctzhm.js";import"./index-hey6w5m0.js";import"./index-7wejfjj9.js";import"./index-ea42kfvk.js";import"./index-3p4n7nwg.js";import"./index-vnxqna70.js";import"./index-bv1z3fxw.js";import"./index-jbxh0ffn.js";import"./index-2q2jadag.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as attachSecondaryProfile};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{o as a,p as b,q as c,r as d,s as e}from"./index-hrfkzecw.js";import"./index-ea42kfvk.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as spawnTracked,c as listTrackedByOwner,b as listTracked,d as killTracked,e as killAllTracked};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{fb as a}from"./index-x4eaagvr.js";import"./index-ekr40gvh.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as telemetryService};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-xjr60th0.js";var l="./tree-sitter-javascript-nd0q4pe9.wasm";export{l as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-xjr60th0.js";var F="./tree-sitter-markdown-411r6y9b.wasm";export{F as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-xjr60th0.js";var E="./tree-sitter-markdown_inline-j5349f42.wasm";export{E as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-xjr60th0.js";var h="./tree-sitter-typescript-zxjzwt75.wasm";export{h as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-xjr60th0.js";var A="./tree-sitter-zig-e78zbjpm.wasm";export{A as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ta as a,ua as b,va as c,wa as d,xa as e,ya as f}from"./index-xtbppqnv.js";import"./index-ea42kfvk.js";import"./index-x4eaagvr.js";import"./index-ekr40gvh.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{c as tryHandoverBootstrapTunnel,d as stopBootstrapTunnel,b as startBootstrapTunnel,a as sanitizeEnvSuffix,f as reapOrphanTunnelsForProfile,e as getBootstrapTunnelUrl};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecontrols/agent",
3
- "version": "2026.820.1",
3
+ "version": "2026.902.1",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$c as b,Ad as C,Bd as D,Cd as E,_c as a,ad as c,bd as d,cd as e,dd as f,ed as g,fd as h,gd as i,hd as j,id as k,jd as l,kd as m,ld as n,md as o,nd as p,od as q,pd as r,qd as s,rd as t,sd as u,td as v,ud as w,vd as x,wd as y,xd as z,yd as A,zd as B}from"./index-a9x5swye.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{m as writeProfile,x as writeAgentConfigAwaitSecrets,w as writeAgentConfig,j as writeActiveProfileName,l as readProfile,y as readAgentConfigWithSecrets,u as readAgentConfig,i as readActiveProfileName,z as readActiveProfile,k as listProfileNames,f as getProfilesDir,h as getProfilePath,q as getProductionGatewayUrls,v as getOrCreateAgentInstanceId,t as getAgentConfigSeed,r as getAgentConfigPath,s as getAgentConfigDefaults,g as getActiveProfilePointerPath,A as gatewayOriginOf,p as ensureProfilesInitialized,C as describeGatewayIdentityMismatch,B as describeGatewayIdentityConflict,n as deleteProfile,o as buildProfileSeed,e as assertValidProfileName,E as applyAgentSecretsToEnv,D as applyAgentConfigToEnv,c as NAMED_ENV_PRESETS,d as DEFAULT_PROFILE_NAME,a as CURRENT_CONFIG_SCHEMA_VERSION,b as BUILTIN_PROFILE_SEEDS};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{n as a}from"./index-dpyv0pqb.js";import"./index-ywv7amgf.js";import"./index-xyfcpfec.js";import"./index-6jzsthh9.js";import"./index-34g3tenj.js";import"./index-a3mwtteb.js";import"./index-ff8acg43.js";import"./index-rhcsaqc0.js";import"./index-hey6w5m0.js";import"./index-2244sbdx.js";import"./index-ea42kfvk.js";import"./index-rmh8pff5.js";import"./index-at6z8tds.js";import"./index-ekr40gvh.js";import"./index-jnrqbhew.js";import"./index-d384edvr.js";import"./index-bv1z3fxw.js";import"./index-e0jbxcn1.js";import"./index-svtmb9t1.js";import"./index-a9x5swye.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{a as createApp};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{K as a,L as b,M as c,N as d}from"./index-w893wd2g.js";import"./index-ea42kfvk.js";import"./index-tcew34xr.js";import"./index-wj5hx7gq.js";import"./index-6nz3c1ys.js";import"./index-sj39bx7y.js";import"./index-svtmb9t1.js";import"./index-a9x5swye.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{d as register,a as generateSystemdUnit,b as generateLaunchdPlist,c as ensureAutostartConfigured};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{t as a}from"./index-1hfchgm5.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{a as bootstrapWorkspace};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{S as a,T as b}from"./index-54mmh1eb.js";import"./index-149rjxa5.js";export{b as installDependencies,a as checkDependencies};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ud as a,Vd as b,Wd as c,Xd as d,Yd as e}from"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{a as profileRegistry,d as getOrCreateProfile,c as getDaemonProfile,b as ensureDaemonProfile,e as __resetDaemonProfileForTests};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Od as a,Pd as b,Qd as c,Rd as d}from"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{a as normalizeGatewayUrl,c as gatewayClient,d as default,b as GatewayClient};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-149rjxa5.js";var t="./highlights-ghv9g403.scm";export{t as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-149rjxa5.js";var r="./highlights-eq9cgrbb.scm";export{r as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-149rjxa5.js";var a="./highlights-x6tmsnaa.scm";export{a as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-149rjxa5.js";var n="./highlights-hk7bwhj4.scm";export{n as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-149rjxa5.js";var t="./highlights-r812a2qc.scm";export{t as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{c as a}from"./index-najxwhng.js";import"./index-426ddch6.js";import"./index-149rjxa5.js";export default a();
@@ -1,11 +0,0 @@
1
- // @bun
2
- import{Wd as s}from"./index-axgp7ryd.js";import{Zd as K,ee as wq,he as Oq,ke as j}from"./index-c4zn91z3.js";import{existsSync as G,mkdirSync as k,readdirSync as cq,readFileSync as b,renameSync as _,rmSync as sq,writeFileSync as D}from"fs";import{dirname as I,join as h}from"path";import{randomUUID as rq}from"crypto";import{existsSync as w,mkdirSync as o,readFileSync as Xq,renameSync as Hq,unlinkSync as Fq,writeFileSync as A}from"fs";import{dirname as m,join as V}from"path";import{spawnSync as a}from"child_process";import{hostname as Nq,networkInterfaces as Aq,platform as Yq,userInfo as Rq}from"os";import{createCipheriv as Pq,createDecipheriv as xq,pbkdf2Sync as uq,randomBytes as kq}from"crypto";var t="secrets:fallback",Wq="secrets:index",e=10,_q=100,qq=new Map;function jq(q,Q){let $=`${q}:${Q}`,z=(qq.get($)??0)+1;if(qq.set($,z),z<=e)return!0;return(z-e)%_q===0}var N="vibecontrols-agent",Gq=".libsecret-install-attempted",Vq="secrets.json";function Iq(){return globalThis.Bun?.secrets??null}class d{api;kind="bun-secrets";constructor(q){this.api=q}async get(q){return this.api.get({service:N,name:q})}async set(q,Q){await this.api.set({service:N,name:q,value:Q}),await gq(q)}async delete(q){let Q=await this.api.delete({service:N,name:q});return await mq(q),Q}async list(q){return dq(q)}}var Kq=".secrets-encrypted-v1",hq=1e5,vq=32,fq="sha256",C=null,Qq=null;function yq(){let q=Aq();for(let Q of Object.values(q)){if(!Q)continue;for(let $ of Q){let z=$?.mac;if(z&&z!=="00:00:00:00:00:00")return z}}return"no-mac"}function $q(){if(Qq!==null)return Qq;let q;try{q=Rq().username||"unknown"}catch{q=process.env.USER||process.env.USERNAME||"unknown"}return`${Nq()}|${q}|${yq()}`}function Uq(){if(C)return C;let q=`vibecontrols-agent::${$q()}`;return C=uq(q,$q(),hq,vq,fq),C}function zq(q){let Q=kq(12),$=Pq("aes-256-gcm",Uq(),Q),z=Buffer.concat([$.update(q,"utf8"),$.final()]),Z=$.getAuthTag();return`${Q.toString("hex")}:${Z.toString("hex")}:${z.toString("hex")}`}function Eq(q){let Q=q.split(":");if(Q.length!==3)return!1;let[$,z,Z]=Q;return/^[0-9a-f]+$/i.test($)&&$.length===24&&/^[0-9a-f]+$/i.test(z)&&z.length===32&&/^[0-9a-f]*$/i.test(Z)}function Sq(q){if(!Eq(q))return null;try{let[Q,$,z]=q.split(":"),Z=xq("aes-256-gcm",Uq(),Buffer.from(Q,"hex"));return Z.setAuthTag(Buffer.from($,"hex")),Buffer.concat([Z.update(Buffer.from(z,"hex")),Z.final()]).toString("utf8")}catch{return null}}class Mq{kind="json-fallback";path;constructor(){this.path=V(j(),Vq)}async get(q){let{plain:Q}=this.readWithMigration(),$=Q[q];return typeof $==="string"?$:null}async set(q,Q){await K(t,async()=>{let{encrypted:$}=this.readWithMigration();$[q]=zq(Q),this.writeEncrypted($)})}async delete(q){return K(t,async()=>{let{encrypted:Q}=this.readWithMigration();if(!(q in Q))return!1;return delete Q[q],this.writeEncrypted(Q),!0})}async list(q){let{encrypted:Q}=this.readWithMigration(),$=Object.keys(Q);return(q?$.filter((Z)=>Z.startsWith(q)):$).sort().map((Z)=>({name:Z}))}readWithMigration(){if(!w(this.path))return{encrypted:{},plain:{}};let q;try{q=Xq(this.path,"utf8")}catch{return{encrypted:{},plain:{}}}let Q;try{Q=JSON.parse(q)}catch{return{encrypted:{},plain:{}}}if(!Q||typeof Q!=="object"||Array.isArray(Q))return{encrypted:{},plain:{}};let $={},z={},Z=!1;for(let[J,X]of Object.entries(Q)){if(typeof X!=="string")continue;let W=Sq(X);if(W!==null){$[J]=X,z[J]=W;continue}$[J]=zq(X),z[J]=X,Z=!0}if(Z)try{this.writeEncrypted($),this.writeMarker()}catch{}return{encrypted:$,plain:z}}writeEncrypted(q){o(m(this.path),{recursive:!0});let Q=`${this.path}.${process.pid}.tmp`;if(A(Q,`${JSON.stringify(q,null,2)}
3
- `,{mode:384}),Hq(Q,this.path),!w(this.markerPath()))this.writeMarker()}markerPath(){return V(m(this.path),Kq)}writeMarker(){try{A(this.markerPath(),`${new Date().toISOString()}
4
- `,{mode:384})}catch{}}}var lq=".secrets-index.json";function p(){return V(j(),lq)}function c(){let q=p();if(!w(q))return new Set;try{let Q=Xq(q,"utf8"),$=JSON.parse(Q);if(Array.isArray($))return new Set($.filter((z)=>typeof z==="string"))}catch{}return new Set}function Bq(q){let Q=p();o(m(Q),{recursive:!0});let $=`${Q}.${process.pid}.tmp`;A($,`${JSON.stringify([...q].sort(),null,2)}
5
- `,{mode:384}),Hq($,Q)}async function gq(q){await K(Wq,()=>{let Q=c();if(Q.has(q))return;Q.add(q),Bq(Q)})}async function mq(q){await K(Wq,()=>{let Q=c();if(!Q.delete(q))return;Bq(Q)})}function dq(q){let $=[...c()];return(q?$.filter((Z)=>Z.startsWith(q)):$).sort().map((Z)=>({name:Z}))}function oq(){if(Yq()!=="linux")return{ok:!1};if(process.env.CI==="true")return{ok:!1,warning:"CI/test environment detected; using JSON fallback"};if(process.env.VIBE_SKIP_LIBSECRET_INSTALL==="1")return{ok:!1,warning:"VIBE_SKIP_LIBSECRET_INSTALL=1 set; using JSON fallback"};let q=j(),Q=V(q,Gq);if(w(Q))return{ok:!1,warning:"previous attempt failed; not retrying"};try{o(q,{recursive:!0}),A(Q,`${new Date().toISOString()}
6
- `,{mode:384})}catch{return{ok:!1,warning:"could not write install marker"}}let $=[{check:["sh","-c","command -v apt-get"],install:["sudo","-n","apt-get","install","-y","libsecret-1-0"]},{check:["sh","-c","command -v dnf"],install:["sudo","-n","dnf","install","-y","libsecret"]},{check:["sh","-c","command -v pacman"],install:["sudo","-n","pacman","-S","--noconfirm","libsecret"]}];for(let z of $){if(a(z.check[0],z.check.slice(1),{stdio:["ignore","pipe","pipe"]}).status!==0)continue;let J=a(z.install[0],z.install.slice(1),{stdio:["ignore","pipe","pipe"]});if(J.status===0)return{ok:!0};return{ok:!1,warning:`auto-install via '${z.install.join(" ")}' failed (exit ${J.status??"unknown"})`}}return{ok:!1,warning:"no supported package manager found"}}var l=null,g=null,Zq=null;async function Jq(q){try{return await q.get({service:N,name:"__probe__"}),!0}catch{return!1}}async function pq(){if(Zq)return Zq;let q=Iq();if(q&&await Jq(q))return new d(q);if(Yq()==="linux"&&q){let Q=oq();if(Q.ok&&await Jq(q))return new d(q);if(Q.warning)console.warn(`[secrets] libsecret unavailable (${Q.warning}); using JSON fallback`);else console.warn("[secrets] Bun.secrets unavailable; using JSON fallback. Install libsecret-1-0 (apt) / libsecret (dnf/pacman) for OS keychain support.")}else if(!q)console.warn("[secrets] Bun.secrets API not present in this runtime; using JSON fallback.");return new Mq}async function R(){if(l)return l;if(!g)g=pq().then((q)=>{return l=q,q});return g}async function P(q){let $=await(await R()).get(q);if(jq("read",q))s().audit.emit("agent","secret.read",{name:q,hit:$!==null});return $}async function x(q,Q){if(await(await R()).set(q,Q),jq("written",q))s().audit.emit("agent","secret.written",{name:q,valueLen:Q.length})}async function wQ(){let q=await R(),Q=(await q.list()).map(($)=>$.name);return{count:Q.length,backend:Q.length===0?"none":q.kind,names:Q}}async function OQ(){let q=await R(),$=(await q.list()).map((z)=>z.name);for(let z of $)try{await q.delete(z)}catch{}if(q.kind==="bun-secrets")F(p()),F(V(j(),Gq));else if(q.kind==="json-fallback"){let z=j();F(V(z,Vq)),F(V(z,Kq))}return{count:$.length,backend:$.length===0?"none":q.kind,names:$}}function F(q){try{if(w(q))Fq(q)}catch{}}function iq(q){return`agent-config:${q}`}var L=["clientId","clientSecret","gatewayClientId","gatewayClientSecret","static-api-key"];function Tq(q){return L.includes(q)}function B(q,Q){return`${q}:${Q}`}function v(){try{return wq()}catch{return"default"}}var M=1,nq=[],f={globalGatewayUrl:"https://graphql.burdenoff.com/global/graphql",workspaceGatewayUrl:"https://graphqlworkspaces.burdenoff.com/workspaces/graphql"},aq={globalGatewayUrl:"https://alphagraphql.burdenoff.com/global/graphql",workspaceGatewayUrl:"https://alphagraphqlworkspaces.burdenoff.com/workspaces/graphql"},tq={globalGatewayUrl:"http://localhost:4000/global/graphql",workspaceGatewayUrl:"http://localhost:4003/workspaces/graphql"},bq={default:{...f}},AQ={local:{...tq},alpha:{...aq},prod:{...f}},T="default",Dq=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function y(q){if(!Dq.test(q))throw Error("Profile name must use 1-64 characters: letters, numbers, dot, underscore, or dash.");return q}function Lq(){return h(j(),"profiles")}function r(){return h(j(),"active")}function E(q){return h(Lq(),`${y(q)}.json`)}function eq(){let q=r();if(!G(q))return T;try{let Q=b(q,"utf8").trim();if(!Q)return T;return y(Q)}catch{return T}}function qQ(q){let Q=y(q),$=r();k(I($),{recursive:!0});let z=`${$}.${process.pid}.tmp`;D(z,`${Q}
7
- `,{mode:384}),_(z,$)}function RQ(){let q=Lq();if(!G(q))return[];return cq(q,{withFileTypes:!0}).filter((Q)=>Q.isFile()&&Q.name.endsWith(".json")).map((Q)=>Q.name.slice(0,-5)).filter((Q)=>Dq.test(Q)).sort()}function QQ(q){let Q=E(q);if(!G(Q))return{};try{return S(b(Q,"utf8"))}catch{return{}}}function $Q(q,Q){let $=y(q),z=E($);k(I(z),{recursive:!0});let Z={schemaVersion:M,...Q},J={...Z};for(let W of L){let H=J[W];if(typeof H==="string"&&H.length>0)x(B($,W),H).catch(()=>{});delete J[W]}let X=`${z}.${process.pid}.tmp`;return D(X,`${JSON.stringify(J,null,2)}
8
- `,{mode:384}),_(X,z),Z}function PQ(q){let Q=E(q);if(!G(Q))return!1;return sq(Q,{force:!0}),!0}function zQ(q,Q={}){let $=bq[q];return{schemaVersion:M,globalGatewayUrl:$.globalGatewayUrl,workspaceGatewayUrl:$.workspaceGatewayUrl,...Q}}function ZQ(){let q={created:[],activeWritten:null};for(let Q of Object.keys(bq))if(!G(E(Q)))$Q(Q,zQ(Q)),q.created.push(Q);if(!G(r()))qQ(T),q.activeWritten=T;return q}function JQ(){return{...f}}function i(q){let Q=q?.dir??Oq();return h(Q,"config.json")}function XQ(){return{...f}}function xQ(q={}){let Q=JQ();return{schemaVersion:M,globalGatewayUrl:Q.globalGatewayUrl,workspaceGatewayUrl:Q.workspaceGatewayUrl,...q}}function S(q){try{let Q=JSON.parse(q);if(Q&&typeof Q==="object")return Q}catch{}return{}}function n(q){let Q=i(q);if(!G(Q))return{};let $;try{$=S(b(Q,"utf8"))}catch{return{}}if(($.schemaVersion??0)>=M)return $;for(let Z of nq){if(Z.from<($.schemaVersion??0))continue;$=Z.apply($),$.schemaVersion=Z.to}if($.schemaVersion!==M)$.schemaVersion=M;try{D(Q,JSON.stringify($,null,2),{mode:384})}catch{}return $}function uQ(q){let Q=n(q);if(Q.agentInstanceId)return Q.agentInstanceId;let $=rq();return HQ({agentInstanceId:$},q),$}function HQ(q,Q){let $=i(Q);k(I($),{recursive:!0});let z=G($)?S(b($,"utf8")):{},Z={...z},J={...z};for(let H of L)delete J[H];let X=Q?.scope??v();for(let[H,Y]of Object.entries(q)){if(Y===void 0||Y==="")continue;if(Z[H]=Y,Tq(H)&&typeof Y==="string"){x(B(X,H),Y).catch(()=>{});continue}J[H]=Y}let W=`${$}.${process.pid}.tmp`;return D(W,`${JSON.stringify(J,null,2)}
9
- `,{mode:384}),_(W,$),Z}async function kQ(q,Q){let $=i(Q);return K(iq($),async()=>{k(I($),{recursive:!0});let z=G($)?S(b($,"utf8")):{},Z={...z},J={...z};for(let Y of L)delete J[Y];let X=Q?.scope??v(),W=[];for(let[Y,U]of Object.entries(q)){if(U===void 0||U==="")continue;if(Z[Y]=U,Tq(Y)&&typeof U==="string"){W.push(x(B(X,Y),U));continue}J[Y]=U}await Promise.all(W);let H=`${$}.${process.pid}.tmp`;return D(H,`${JSON.stringify(J,null,2)}
10
- `,{mode:384}),_(H,$),Z})}async function _Q(q){let Q=n(q?{dir:q.dir}:void 0),$=q?.scope??v();for(let z of L){if(Q[z])continue;try{let Z=await P(B($,z));if(Z)Q[z]=Z}catch(Z){if(q?.strict)throw Z}}return Q}function YQ(){return QQ(eq())}function O(q){if(!q)return null;try{return new URL(q).origin}catch{return null}}function IQ(q,Q){if(!q.clientId)return null;let $=Cq(q,Q);if(!$.length)return null;return`This agent is already paired with ${u(q)}. Refusing a credential push from ${u(Q)} (${$.join("; ")}): it would overwrite the only credential slot and strand the existing pairing on 401. Re-send with "force": true to repair deliberately, or run the other environment under its own profile (VIBECONTROLS_PROFILE).`}function u(q){return`${O(q.globalGatewayUrl)??"unknown gateway"} (workspace ${q.workspaceId??"unknown"})`}function Cq(q,Q){let $=[],z=O(q.globalGatewayUrl),Z=O(Q.globalGatewayUrl);if(z&&Z&&z!==Z)$.push(`global gateway ${z} -> ${Z}`);let J=O(q.workspaceGatewayUrl),X=O(Q.workspaceGatewayUrl);if(J&&X&&J!==X)$.push(`workspace gateway ${J} -> ${X}`);if(q.workspaceId&&Q.workspaceId&&q.workspaceId!==Q.workspaceId)$.push(`workspace ${q.workspaceId} -> ${Q.workspaceId}`);return $}function hQ(q,Q){if(!q.clientId)return null;let $=Cq(q,Q);if(!$.length)return null;return`Credentials were issued for ${u(q)} but this agent is configured for ${u(Q)} (${$.join("; ")}). `+"They cannot authenticate there \u2014 re-pair the agent from the environment "+"it should belong to, or clear the conflicting environment override (VIBE_GLOBAL_GATEWAY_URL / VIBE_WORKSPACE_GATEWAY_URL / VIBE_WORKSPACE_ID)."}function vQ(){try{ZQ()}catch{}let q=YQ(),Q=n(),$={...q,...Q},z=(J,X)=>{if(!process.env[J]&&X)process.env[J]=X};z("VIBE_WORKSPACE_ID",$.workspaceId),z("VIBE_ORGANIZATION_ID",$.organizationId);let Z=XQ();return z("VIBE_GLOBAL_GATEWAY_URL",$.globalGatewayUrl??Z.globalGatewayUrl),z("VIBE_WORKSPACE_GATEWAY_URL",$.workspaceGatewayUrl??Z.workspaceGatewayUrl),z("VIBE_STORAGE_ADAPTER",$.storageAdapter),z("VIBECONTROLS_PLUGIN_INSTALL_SCOPE",$.pluginInstallScope),$}async function fQ(){let q=($,z)=>{if(!process.env[$]&&z)process.env[$]=z},Q=v();try{let $=await P(B(Q,"clientId"));q("VIBE_CLIENT_ID",$??void 0)}catch{}try{let $=await P(B(Q,"clientSecret"));q("VIBE_CLIENT_SECRET",$??void 0)}catch{}}
11
- export{P as Wc,x as Xc,wQ as Yc,OQ as Zc,M as _c,bq as $c,AQ as ad,T as bd,y as cd,Lq as dd,r as ed,E as fd,eq as gd,qQ as hd,RQ as id,QQ as jd,$Q as kd,PQ as ld,zQ as md,ZQ as nd,JQ as od,i as pd,XQ as qd,xQ as rd,n as sd,uQ as td,HQ as ud,kQ as vd,_Q as wd,YQ as xd,O as yd,IQ as zd,hQ as Ad,vQ as Bd,fQ as Cd};