@vibecontrols/agent 2026.602.2 → 2026.602.4

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 (116) hide show
  1. package/dist/{agent-config-85pskv43.js → agent-config-4ppenhqp.js} +1 -1
  2. package/dist/{agent-ready-tracker-zp6p8e6f.js → agent-ready-tracker-kgs7td6t.js} +1 -1
  3. package/dist/app-8qe1gw9z.js +2 -0
  4. package/dist/bootstrap-workspace-qgs6d5f0.js +2 -0
  5. package/dist/bootstrap.service-vg72w8pa.js +2 -0
  6. package/dist/{bridge-client-341r9rry.js → bridge-client-1fxza4p7.js} +1 -1
  7. package/dist/cli.js +1 -1
  8. package/dist/daemon-profile-gwdcqx0q.js +2 -0
  9. package/dist/esm-6f3dfn6v.js +2 -0
  10. package/dist/{finalize-retry-handle-registry-vv241fsq.js → finalize-retry-handle-registry-xnm9kxry.js} +1 -1
  11. package/dist/{finalize-retry-worker-xp1nhv3c.js → finalize-retry-worker-dvykrzed.js} +1 -1
  12. package/dist/gateway-client-9kwnmk89.js +2 -0
  13. package/dist/{getMachineId-bsd-a56s0v8c.js → getMachineId-bsd-753751sw.js} +1 -1
  14. package/dist/{getMachineId-darwin-w9k0yw9r.js → getMachineId-darwin-na1pranq.js} +1 -1
  15. package/dist/{getMachineId-linux-anh31jbf.js → getMachineId-linux-dmn0ncdm.js} +1 -1
  16. package/dist/{getMachineId-unsupported-5hv3pwca.js → getMachineId-unsupported-yv77j894.js} +1 -1
  17. package/dist/{getMachineId-win-njb8tery.js → getMachineId-win-9hmyqmm0.js} +1 -1
  18. package/dist/highlights-00fcgwwq.js +2 -0
  19. package/dist/highlights-23bc8zge.js +2 -0
  20. package/dist/highlights-4mhb2pb0.js +2 -0
  21. package/dist/highlights-q7w64nwb.js +2 -0
  22. package/dist/highlights-xwdw5xay.js +2 -0
  23. package/dist/{index-678rwfc0.js → index-0924jp9m.js} +1 -1
  24. package/dist/{index-z5a4yxzz.js → index-1mppacnx.js} +3 -3
  25. package/dist/{index-g8zv1gta.js → index-1zf3r23y.js} +1 -1
  26. package/dist/{index-jw1k4vbk.js → index-4qq083yd.js} +1 -1
  27. package/dist/index-5amvpjqx.js +11 -0
  28. package/dist/{index-d5ysy1yn.js → index-5dysvvjv.js} +1 -1
  29. package/dist/{index-n7qyrdr1.js → index-5wpck4aw.js} +1 -1
  30. package/dist/{index-5mw3eshk.js → index-8nqp3a4d.js} +1 -1
  31. package/dist/{index-2xs9cvjn.js → index-8sdrhr3q.js} +2 -2
  32. package/dist/{index-6mprnf7p.js → index-97mq40rr.js} +1 -1
  33. package/dist/{index-0cn9bv8z.js → index-a4854mwz.js} +1 -1
  34. package/dist/{index-tp4y9jde.js → index-a9ejdv22.js} +1 -1
  35. package/dist/{index-fzzwprvk.js → index-aq81xmn0.js} +5 -5
  36. package/dist/{index-xjzmb1pn.js → index-b6x6a4xp.js} +2 -2
  37. package/dist/{index-yy1mm8zs.js → index-c7554sg7.js} +1 -1
  38. package/dist/{index-mtm8cfyt.js → index-ca5c245v.js} +2 -2
  39. package/dist/{index-2gsarrbn.js → index-d1xjj001.js} +1 -1
  40. package/dist/{index-h8a8s8sn.js → index-ebwwtwwc.js} +1 -1
  41. package/dist/{index-8sm0nkh8.js → index-ep3zb271.js} +1 -1
  42. package/dist/{index-g2raeeh4.js → index-h74va4wd.js} +2 -2
  43. package/dist/{index-v9fx5wab.js → index-hvjqgb97.js} +1 -1
  44. package/dist/{index-9bqd8veb.js → index-js1xn4sq.js} +3 -3
  45. package/dist/{index-x1h8r7pr.js → index-kt5zxp42.js} +1 -1
  46. package/dist/{index-ssjmzqcz.js → index-nmk7cbj5.js} +1 -1
  47. package/dist/{index-rdp5xq4r.js → index-nrsqzcfc.js} +1 -1
  48. package/dist/index-p23tet7a.js +2 -0
  49. package/dist/{index-04n4qgvd.js → index-pgew6sge.js} +3 -3
  50. package/dist/{index-1zw3kea7.js → index-qwtspxw8.js} +1 -1
  51. package/dist/index-qzwphe3q.js +26 -0
  52. package/dist/index-rqq0k5fc.js +16 -0
  53. package/dist/{index-6jq17k9s.js → index-rv6h14n8.js} +1 -1
  54. package/dist/{index-qfz9fy56.js → index-rw9x93zb.js} +1 -1
  55. package/dist/{index-dm6yjmgq.js → index-rzpaqrhx.js} +2 -2
  56. package/dist/{index-g3ap3xpr.js → index-s2xpdnsj.js} +4 -4
  57. package/dist/{index-vdahdt49.js → index-tgrt61qr.js} +1 -1
  58. package/dist/{index-ef95xr4z.js → index-thammzct.js} +2 -2
  59. package/dist/{index-scsjyj4m.js → index-x649afed.js} +2 -2
  60. package/dist/{index-8kvc8ttn.js → index-xrs52f2c.js} +1 -1
  61. package/dist/{index-yrgm89r8.js → index-ydc0tk17.js} +1 -1
  62. package/dist/{index-1hnw0rhc.js → index-ytgmhxsj.js} +31 -31
  63. package/dist/{index-0248afsn.js → index-z5s398n0.js} +1 -1
  64. package/dist/index.js +2 -2
  65. package/dist/injections-x3xya90r.js +2 -0
  66. package/dist/interactive-qc1j66mq.js +2 -0
  67. package/dist/key.cmd-972133dv.js +2 -0
  68. package/dist/log-shipper-hjnn1d5p.js +2 -0
  69. package/dist/{path-utils-35re7qf9.js → path-utils-hxdyv2zn.js} +1 -1
  70. package/dist/{plugin-system-c916v9an.js → plugin-system-cwznxqx5.js} +1 -1
  71. package/dist/prereqs-runner-27x3j1md.js +2 -0
  72. package/dist/profile-mount-8dc9jwt5.js +2 -0
  73. package/dist/prune-stale-shims-23y0stm8.js +2 -0
  74. package/dist/register-core-0d4adnqp.js +2 -0
  75. package/dist/secondary-profile-attach-qk5tde9n.js +2 -0
  76. package/dist/subprocess-1nna3d3x.js +2 -0
  77. package/dist/telemetry-8jfdyt51.js +2 -0
  78. package/dist/tree-sitter-javascript-q22gvtms.js +2 -0
  79. package/dist/tree-sitter-markdown-pntsjzm3.js +2 -0
  80. package/dist/tree-sitter-markdown_inline-g1wzqf7k.js +2 -0
  81. package/dist/tree-sitter-typescript-m9yfes10.js +2 -0
  82. package/dist/tree-sitter-zig-jmh62j90.js +2 -0
  83. package/dist/tunnel-bootstrap-5wgt9a1h.js +2 -0
  84. package/package.json +1 -1
  85. package/dist/app-y4yzq7yw.js +0 -2
  86. package/dist/bootstrap-workspace-zpm20zez.js +0 -2
  87. package/dist/bootstrap.service-pjmnpxha.js +0 -2
  88. package/dist/daemon-profile-vas1vf2t.js +0 -2
  89. package/dist/esm-9fpye77x.js +0 -2
  90. package/dist/gateway-client-43gzvj5s.js +0 -2
  91. package/dist/highlights-8d9mgr01.js +0 -2
  92. package/dist/highlights-jwvdxm9x.js +0 -2
  93. package/dist/highlights-qbx2vnme.js +0 -2
  94. package/dist/highlights-r3m83kn9.js +0 -2
  95. package/dist/highlights-s7mqapt6.js +0 -2
  96. package/dist/index-01qzsnwd.js +0 -16
  97. package/dist/index-hrdamx5j.js +0 -2
  98. package/dist/index-tmrbs96r.js +0 -11
  99. package/dist/index-z2yjbq9a.js +0 -26
  100. package/dist/injections-srewsjcz.js +0 -2
  101. package/dist/interactive-22ta89hc.js +0 -2
  102. package/dist/key.cmd-wgcq6kt8.js +0 -2
  103. package/dist/log-shipper-k24m8yw5.js +0 -2
  104. package/dist/prereqs-runner-ca4kt803.js +0 -2
  105. package/dist/profile-mount-npcknw6v.js +0 -2
  106. package/dist/prune-stale-shims-nkx9vq5m.js +0 -2
  107. package/dist/register-core-xhrk6ay5.js +0 -2
  108. package/dist/secondary-profile-attach-db5cr3e1.js +0 -2
  109. package/dist/subprocess-g9sk1ep9.js +0 -2
  110. package/dist/telemetry-tnq47dcs.js +0 -2
  111. package/dist/tree-sitter-javascript-3h25c6bs.js +0 -2
  112. package/dist/tree-sitter-markdown-3nemcjhe.js +0 -2
  113. package/dist/tree-sitter-markdown_inline-16ftwa53.js +0 -2
  114. package/dist/tree-sitter-typescript-f6mq6ze6.js +0 -2
  115. package/dist/tree-sitter-zig-s2trkm2d.js +0 -2
  116. package/dist/tunnel-bootstrap-2kg79ng8.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{K as I}from"./index-2gsarrbn.js";import{Qb as G,Rb as D}from"./index-d5ysy1yn.js";import{Nd as H}from"./index-9bqd8veb.js";var j="prereqs-runner",q="plugin-mgr",v={status:null,install:null,satisfied:!0,pendingSudo:[],noProtocol:!0};function w(z,F){if(!z.apiPrefix)return null;return`${(z.apiPrefix.startsWith("/")?z.apiPrefix:`/${z.apiPrefix}`).replace(/\/+$/,"")}/prereqs${F}`}async function M(z,F,J){let Q=z.handle;if(typeof Q!=="function")return null;let Y=new Request(`http://agent.local${F}`,{method:J,headers:{"x-vc-profile-rewrite":"1",[G]:D()}}),K=await Q.call(z,Y);if(K.status===404)return null;if(!K.ok){let $=await K.text().catch(()=>"");throw Error(`prereqs ${J} ${F} \u2192 ${K.status} ${$}`)}return await K.json()}async function A(z,F,J,Q,Y={}){let K=w(z,"/status"),$=w(z,"/install");if(!K||!$)return v;let W=null;try{W=await M(J,K,"GET")}catch(V){H().logger.warn(j,`${z.name}: prereqs/status call failed`,{error:String(V)})}if(W===null)return v;if(W.satisfied||Y.skipInstall)return await x(Q,F,z.version,{status:W,install:null}),{status:W,install:null,satisfied:W.satisfied,pendingSudo:[],noProtocol:!1};let X=null;try{X=await M(J,$,"POST")}catch(V){H().logger.warn(j,`${z.name}: prereqs/install call failed`,{error:String(V)})}let B=W;try{let V=await M(J,K,"GET");if(V)B=V}catch{}if(await x(Q,F,z.version,{status:B,install:X}),X&&X.installed.length>0){let V=new Map;for(let Z of z.prerequisites??[])V.set(Z.name,Z.kind);I(F,X.installed.map((Z)=>({name:Z,kind:V.get(Z)??"binary"})))}return{status:B,install:X,satisfied:B.satisfied,pendingSudo:X?.pendingSudo??[],noProtocol:!1}}async function x(z,F,J,Q){if(!z)return;let Y=JSON.stringify({lastInstallAt:new Date().toISOString(),lastInstallVersion:J,satisfied:Q.status?.satisfied??!1,missing:Q.status?.missing??[],pendingSudo:Q.install?.pendingSudo??[]});try{await z.setPluginState(q,`prereqs:${F}`,Y)}catch(K){H().logger.warn(j,"Failed to persist prereq state",{packageName:F,error:String(K)})}}async function L(z,F){if(!z)return null;try{let J=await z.getPluginState(q,`prereqs:${F}`);return J?JSON.parse(J):null}catch{return null}}
2
+ import{K as I}from"./index-d1xjj001.js";import{Rb as G,Sb as D}from"./index-5dysvvjv.js";import{Od as H}from"./index-js1xn4sq.js";var j="prereqs-runner",q="plugin-mgr",v={status:null,install:null,satisfied:!0,pendingSudo:[],noProtocol:!0};function w(z,F){if(!z.apiPrefix)return null;return`${(z.apiPrefix.startsWith("/")?z.apiPrefix:`/${z.apiPrefix}`).replace(/\/+$/,"")}/prereqs${F}`}async function M(z,F,J){let Q=z.handle;if(typeof Q!=="function")return null;let Y=new Request(`http://agent.local${F}`,{method:J,headers:{"x-vc-profile-rewrite":"1",[G]:D()}}),K=await Q.call(z,Y);if(K.status===404)return null;if(!K.ok){let $=await K.text().catch(()=>"");throw Error(`prereqs ${J} ${F} \u2192 ${K.status} ${$}`)}return await K.json()}async function A(z,F,J,Q,Y={}){let K=w(z,"/status"),$=w(z,"/install");if(!K||!$)return v;let W=null;try{W=await M(J,K,"GET")}catch(V){H().logger.warn(j,`${z.name}: prereqs/status call failed`,{error:String(V)})}if(W===null)return v;if(W.satisfied||Y.skipInstall)return await x(Q,F,z.version,{status:W,install:null}),{status:W,install:null,satisfied:W.satisfied,pendingSudo:[],noProtocol:!1};let X=null;try{X=await M(J,$,"POST")}catch(V){H().logger.warn(j,`${z.name}: prereqs/install call failed`,{error:String(V)})}let B=W;try{let V=await M(J,K,"GET");if(V)B=V}catch{}if(await x(Q,F,z.version,{status:B,install:X}),X&&X.installed.length>0){let V=new Map;for(let Z of z.prerequisites??[])V.set(Z.name,Z.kind);I(F,X.installed.map((Z)=>({name:Z,kind:V.get(Z)??"binary"})))}return{status:B,install:X,satisfied:B.satisfied,pendingSudo:X?.pendingSudo??[],noProtocol:!1}}async function x(z,F,J,Q){if(!z)return;let Y=JSON.stringify({lastInstallAt:new Date().toISOString(),lastInstallVersion:J,satisfied:Q.status?.satisfied??!1,missing:Q.status?.missing??[],pendingSudo:Q.install?.pendingSudo??[]});try{await z.setPluginState(q,`prereqs:${F}`,Y)}catch(K){H().logger.warn(j,"Failed to persist prereq state",{packageName:F,error:String(K)})}}async function L(z,F){if(!z)return null;try{let J=await z.getPluginState(q,`prereqs:${F}`);return J?JSON.parse(J):null}catch{return null}}
3
3
  export{A as d,L as e};
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{j as o,k as r,l as t,m as e,n as XQ}from"./index-z2yjbq9a.js";import"./index-n7qyrdr1.js";import{t as QQ}from"./index-6jq17k9s.js";import"./index-1hnw0rhc.js";import"./index-6jzsthh9.js";import"./index-g8zv1gta.js";import"./index-qfz9fy56.js";import"./index-ssjmzqcz.js";import"./index-tp4y9jde.js";import"./index-4wgjx8bf.js";import{Da as a}from"./index-g3ap3xpr.js";import"./index-0ckffygp.js";import"./index-rc79x8fw.js";import{bb as W}from"./index-yrgm89r8.js";import"./index-52cp759f.js";import"./index-v9fx5wab.js";import{Ib as s,Jb as i}from"./index-01qzsnwd.js";import"./index-d5ysy1yn.js";import"./index-04n4qgvd.js";import"./index-xjzmb1pn.js";import{Rc as p,Sc as v,nd as C,td as l,ud as n}from"./index-g2raeeh4.js";import{Nd as q}from"./index-9bqd8veb.js";import{Xd as D,_d as S,ae as g,be as M}from"./index-0cn9bv8z.js";import"./index-jw1k4vbk.js";import{he as B}from"./index-yy1mm8zs.js";import{isAbsolute as MQ}from"path";import{existsSync as V,mkdirSync as y,readFileSync as _Q,readdirSync as P,renameSync as BQ,unlinkSync as DQ,writeFileSync as f}from"fs";import{dirname as d,join as F}from"path";var GQ=".secrets-migrated-v1",IQ=["static-api-key","clientId","clientSecret"];function WQ(Q,H){return`${Q}:${H}`}function c(){return F(M(),GQ)}function TQ(){let Q=c();y(d(Q),{recursive:!0}),f(Q,`${new Date().toISOString()}
3
+ import{j as o,k as r,l as t,m as e,n as XQ}from"./index-qzwphe3q.js";import"./index-5wpck4aw.js";import{t as QQ}from"./index-rv6h14n8.js";import"./index-ytgmhxsj.js";import"./index-6jzsthh9.js";import"./index-1zf3r23y.js";import"./index-rw9x93zb.js";import"./index-nmk7cbj5.js";import"./index-a9ejdv22.js";import"./index-4wgjx8bf.js";import{Da as a}from"./index-s2xpdnsj.js";import"./index-0ckffygp.js";import"./index-rc79x8fw.js";import{bb as W}from"./index-ydc0tk17.js";import"./index-52cp759f.js";import"./index-hvjqgb97.js";import{Ib as s,Jb as i}from"./index-rqq0k5fc.js";import"./index-5dysvvjv.js";import"./index-pgew6sge.js";import"./index-b6x6a4xp.js";import{Sc as p,Tc as v,od as C,ud as l,vd as n}from"./index-h74va4wd.js";import{Od as q}from"./index-js1xn4sq.js";import{$d as S,Yd as D,be as g,ce as M}from"./index-a4854mwz.js";import"./index-4qq083yd.js";import{ie as B}from"./index-c7554sg7.js";import{isAbsolute as MQ}from"path";import{existsSync as V,mkdirSync as y,readFileSync as _Q,readdirSync as P,renameSync as BQ,unlinkSync as DQ,writeFileSync as f}from"fs";import{dirname as d,join as F}from"path";var GQ=".secrets-migrated-v1",IQ=["static-api-key","clientId","clientSecret"];function WQ(Q,H){return`${Q}:${H}`}function c(){return F(M(),GQ)}function TQ(){let Q=c();y(d(Q),{recursive:!0}),f(Q,`${new Date().toISOString()}
4
4
  `,{mode:384})}function JQ(Q){if(!V(Q))return null;try{let H=_Q(Q,"utf8"),X=JSON.parse(H);if(X&&typeof X==="object"&&!Array.isArray(X))return X}catch{}return null}function VQ(Q,H){y(d(Q),{recursive:!0});let X=`${Q}.${process.pid}.tmp`;f(X,`${JSON.stringify(H,null,2)}
5
- `,{mode:384}),BQ(X,Q)}function FQ(){let Q=M(),H=F(Q,"agents");if(!V(H))return[];let X=[],L;try{L=P(H)}catch{return[]}for(let Y of L){let z=F(H,Y,"config.json");if(!V(z))continue;X.push({path:z,scope:Y})}return X}function jQ(){let Q=M(),H=F(Q,"profiles");if(!V(H))return[];let X=[],L;try{L=P(H)}catch{return[]}for(let Y of L){if(!Y.endsWith(".json"))continue;X.push({path:F(H,Y),scope:Y.slice(0,-5)})}return X}async function KQ(Q,H){let X=JQ(Q);if(!X)return 0;let L=0;for(let Y of IQ){let z=X[Y];if(typeof z!=="string"||z.length===0)continue;let _=WQ(H,Y);try{await v(_,z),delete X[Y],L++,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(L>0)VQ(Q,X);return L}async function m(){let Q={alreadyMigrated:!1,fieldsMoved:0,filesUpdated:0};if(V(c()))return Q.alreadyMigrated=!0,Q;let H=[...FQ(),...jQ()];for(let X of H){let L;try{L=await KQ(X.path,X.scope)}catch(Y){q().logger.warn("secrets-migrator","skipping target after error",{path:X.path,error:String(Y)});continue}if(L>0)Q.fieldsMoved+=L,Q.filesUpdated++}try{TQ()}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=(L,Y)=>{try{return Q(L,Y)}catch(z){if(typeof L==="string"&&L.endsWith("}}"))try{return Q(L.slice(0,-1),Y)}catch{}throw z}};let X=globalThis.Request?.prototype;if(X&&typeof X.json==="function"){let L=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 L.call(_)}}}}QQ();l();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 UQ(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 E=(()=>{try{return D()}catch{return"default"}})(),A=Number.parseInt(process.env.PORT||String(UQ(E)),10),U=Number.isInteger(A)&&A>0?A:3005,R=process.env.HOST||"0.0.0.0",RQ=(()=>{let Q=process.env.DB_PATH;if(!Q)return;if(MQ(Q))return Q;console.warn(`[boot] Ignoring relative DB_PATH=${Q} (cwd=${process.cwd()}). Use an absolute path or unset to fall back to ${g()}.`);return})(),x=process.env.AGENT_API_KEY||void 0,CQ=process.env.LOG_LEVEL||"info",EQ=process.env.CORS_ORIGIN||void 0;async function wQ(){try{await m()}catch($){q().logger.warn("server","secrets migration encountered an error",{error:String($)})}let Q=C()["static-api-key"],H=(()=>{try{return D()}catch{return"default"}})(),X=Q??await p(`${H}:static-api-key`),L=!x&&!X;await s(),await n();let Y=process.env.VIBE_CLIENT_ID,z=process.env.VIBE_CLIENT_SECRET,_=process.env.VIBE_GLOBAL_GATEWAY_URL,G=process.env.VIBE_WORKSPACE_GATEWAY_URL,b=process.env.VIBE_WORKSPACE_ID,ZQ=!!Y&&!!z&&!!_&&!!G&&!!b;q().logger.info("server","Starting VibeControls Agent...",{runtime:"bun",bunVersion:Bun.version,port:U,host:R,env:"production"});try{let $=C(),Z=$["telemetry.enabled"]===!0||$["telemetry.enabled"]==="true";W.init({persisted:Z});let N=Date.now();W.emit("agent.started",{version:process.env.npm_package_version??"unknown",profile:E,platform:process.platform}),process.__vibe_started_at=N}catch{}let j=Math.max(1,Number.parseInt(process.env.VIBECONTROLS_AGENT_BOOT_RETRIES??"10",10)||10),$Q=($)=>{let Z=String($?.message??$).toLowerCase();return Z.includes("syntax")||Z.includes("cannot find module")||Z.includes("module not found")||Z.includes("typeerror")||Z.includes("config schema")||Z.includes("invalid config")||Z.includes("corrupt")||Z.includes("eaccess")||Z.includes("eperm")},O=null,I=0;while(!O){I++;try{O=await XQ({port:U,host:R,dbPath:RQ,apiKey:x,logLevel:CQ,corsOrigin:EQ}),await O.start();try{let $=await import("fs"),Z=`${S()}/runtime.json`;$.writeFileSync(Z,JSON.stringify({pid:process.pid,port:U,host:R,profile:E,startedAt:new Date().toISOString(),version:a()},null,2));let N=()=>{try{if($.existsSync(Z))$.unlinkSync(Z)}catch{}};process.once("SIGTERM",N),process.once("SIGINT",N),process.once("exit",N)}catch($){q().logger.warn("server","Could not write runtime.json",{error:String($)})}}catch($){let Z=$Q($);if(q().logger.error("server","Failed to start agent server",{attempt:I,maxBootAttempts:j,fatal:Z,error:String($)}),Z||I>=j)console.error(`\u274C Failed to start VibeControls Agent (attempt ${I}/${j}, fatal=${Z}):`,$),process.exit(1);let N=Math.min(30000,1000*2**Math.min(5,I-1)),J=Math.floor(Math.random()*500),K=N+J;console.warn(`\u26A0\uFE0F Agent boot attempt ${I}/${j} failed (transient), retrying in ${Math.round(K/1000)}s...`),await new Promise((k)=>setTimeout(k,K)),O=null}}let h=O.getServiceRegistry().getProvider("tunnel"),T=null;if(h?.getActiveTunnelUrl)for(let $=0;$<30;$++){if(T=await h.getActiveTunnelUrl(),T)break;await new Promise((Z)=>setTimeout(Z,1000))}if(!T){let{sanitizeEnvSuffix:$}=await import("./tunnel-bootstrap-2kg79ng8.js"),{getVibecontrolsProfile:Z}=await import("./path-utils-35re7qf9.js"),N=$(Z());T=process.env[`AGENT_TUNNEL_URL_${N}`]??process.env.AGENT_TUNNEL_URL??null}let HQ=C(),LQ=x||i()||HQ["static-api-key"]||"",w=q().getBootState(),YQ=w==="ready"?null:o();if(w==="ready")r();kQ({port:U,host:R,tunnelUrl:T,apiKey:LQ,revealApiKey:L||process.env.AGENT_PRINT_API_KEY==="1",state:w,pairingToken:YQ});try{t({profile:E})}catch($){q().logger.warn("server","Could not start autoupdate",{error:String($)})}let{existsSync:NQ,unlinkSync:qQ}=await import("fs"),{tmpdir:zQ}=await import("os"),{join:OQ}=await import("path"),u=async($)=>{q().logger.info("server",`Received ${$}, shutting down...`),e();try{let N=process.__vibe_started_at??Date.now();W.emit("agent.stopped",{uptime_s:Math.round((Date.now()-N)/1000),reason:$}),await W.flush(),W.stop()}catch{}let Z=O.getLifecycle();if($==="SIGTERM"){let N=OQ(zQ(),`.boff-vibecontrols-kill-${process.pid}`);if(NQ(N)){try{qQ(N)}catch{}if(q().logger.info("server","Kill-intent flag detected \u2014 full shutdown"),Z)await Z.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)"),Z)await Z.softStop();else await O.stop({reason:"reload"})}else if(Z)await Z.kill();else await O.stop({reason:"shutdown"}),process.exit(0)};if(process.on("SIGINT",()=>u("SIGINT")),process.on("SIGTERM",()=>u("SIGTERM")),ZQ){let $=(()=>{let Z=process.env.VIBECONTROLS_FINALIZE_TIMEOUT_MS,N=Z?Number.parseInt(Z,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($/1000)}s)`),(async()=>{let Z={clientId:Y,clientSecret:z,workspaceId:b,globalGatewayUrl:_,workspaceGatewayUrl:G};try{let N=await Promise.race([O.finalize(Z),new Promise((J)=>setTimeout(()=>J({ok:!1,error:`inline finalize timed out after ${Math.round($/1000)}s`}),$))]);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-xp1nhv3c.js"),{setFinalizeRetryHandle:K}=await import("./finalize-retry-handle-registry-vv241fsq.js"),k=J({trigger:()=>O.finalize(Z)});K(k)}}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",L="\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(L),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(L),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("")}wQ();
5
+ `,{mode:384}),BQ(X,Q)}function FQ(){let Q=M(),H=F(Q,"agents");if(!V(H))return[];let X=[],L;try{L=P(H)}catch{return[]}for(let Y of L){let z=F(H,Y,"config.json");if(!V(z))continue;X.push({path:z,scope:Y})}return X}function jQ(){let Q=M(),H=F(Q,"profiles");if(!V(H))return[];let X=[],L;try{L=P(H)}catch{return[]}for(let Y of L){if(!Y.endsWith(".json"))continue;X.push({path:F(H,Y),scope:Y.slice(0,-5)})}return X}async function KQ(Q,H){let X=JQ(Q);if(!X)return 0;let L=0;for(let Y of IQ){let z=X[Y];if(typeof z!=="string"||z.length===0)continue;let _=WQ(H,Y);try{await v(_,z),delete X[Y],L++,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(L>0)VQ(Q,X);return L}async function m(){let Q={alreadyMigrated:!1,fieldsMoved:0,filesUpdated:0};if(V(c()))return Q.alreadyMigrated=!0,Q;let H=[...FQ(),...jQ()];for(let X of H){let L;try{L=await KQ(X.path,X.scope)}catch(Y){q().logger.warn("secrets-migrator","skipping target after error",{path:X.path,error:String(Y)});continue}if(L>0)Q.fieldsMoved+=L,Q.filesUpdated++}try{TQ()}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=(L,Y)=>{try{return Q(L,Y)}catch(z){if(typeof L==="string"&&L.endsWith("}}"))try{return Q(L.slice(0,-1),Y)}catch{}throw z}};let X=globalThis.Request?.prototype;if(X&&typeof X.json==="function"){let L=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 L.call(_)}}}}QQ();l();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 UQ(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 E=(()=>{try{return D()}catch{return"default"}})(),A=Number.parseInt(process.env.PORT||String(UQ(E)),10),U=Number.isInteger(A)&&A>0?A:3005,R=process.env.HOST||"0.0.0.0",RQ=(()=>{let Q=process.env.DB_PATH;if(!Q)return;if(MQ(Q))return Q;console.warn(`[boot] Ignoring relative DB_PATH=${Q} (cwd=${process.cwd()}). Use an absolute path or unset to fall back to ${g()}.`);return})(),x=process.env.AGENT_API_KEY||void 0,CQ=process.env.LOG_LEVEL||"info",EQ=process.env.CORS_ORIGIN||void 0;async function wQ(){try{await m()}catch($){q().logger.warn("server","secrets migration encountered an error",{error:String($)})}let Q=C()["static-api-key"],H=(()=>{try{return D()}catch{return"default"}})(),X=Q??await p(`${H}:static-api-key`),L=!x&&!X;await s(),await n();let Y=process.env.VIBE_CLIENT_ID,z=process.env.VIBE_CLIENT_SECRET,_=process.env.VIBE_GLOBAL_GATEWAY_URL,G=process.env.VIBE_WORKSPACE_GATEWAY_URL,b=process.env.VIBE_WORKSPACE_ID,ZQ=!!Y&&!!z&&!!_&&!!G&&!!b;q().logger.info("server","Starting VibeControls Agent...",{runtime:"bun",bunVersion:Bun.version,port:U,host:R,env:"production"});try{let $=C(),Z=$["telemetry.enabled"]===!0||$["telemetry.enabled"]==="true";W.init({persisted:Z});let N=Date.now();W.emit("agent.started",{version:process.env.npm_package_version??"unknown",profile:E,platform:process.platform}),process.__vibe_started_at=N}catch{}let j=Math.max(1,Number.parseInt(process.env.VIBECONTROLS_AGENT_BOOT_RETRIES??"10",10)||10),$Q=($)=>{let Z=String($?.message??$).toLowerCase();return Z.includes("syntax")||Z.includes("cannot find module")||Z.includes("module not found")||Z.includes("typeerror")||Z.includes("config schema")||Z.includes("invalid config")||Z.includes("corrupt")||Z.includes("eaccess")||Z.includes("eperm")},O=null,I=0;while(!O){I++;try{O=await XQ({port:U,host:R,dbPath:RQ,apiKey:x,logLevel:CQ,corsOrigin:EQ}),await O.start();try{let $=await import("fs"),Z=`${S()}/runtime.json`;$.writeFileSync(Z,JSON.stringify({pid:process.pid,port:U,host:R,profile:E,startedAt:new Date().toISOString(),version:a()},null,2));let N=()=>{try{if($.existsSync(Z))$.unlinkSync(Z)}catch{}};process.once("SIGTERM",N),process.once("SIGINT",N),process.once("exit",N)}catch($){q().logger.warn("server","Could not write runtime.json",{error:String($)})}}catch($){let Z=$Q($);if(q().logger.error("server","Failed to start agent server",{attempt:I,maxBootAttempts:j,fatal:Z,error:String($)}),Z||I>=j)console.error(`\u274C Failed to start VibeControls Agent (attempt ${I}/${j}, fatal=${Z}):`,$),process.exit(1);let N=Math.min(30000,1000*2**Math.min(5,I-1)),J=Math.floor(Math.random()*500),K=N+J;console.warn(`\u26A0\uFE0F Agent boot attempt ${I}/${j} failed (transient), retrying in ${Math.round(K/1000)}s...`),await new Promise((k)=>setTimeout(k,K)),O=null}}let h=O.getServiceRegistry().getProvider("tunnel"),T=null;if(h?.getActiveTunnelUrl)for(let $=0;$<30;$++){if(T=await h.getActiveTunnelUrl(),T)break;await new Promise((Z)=>setTimeout(Z,1000))}if(!T){let{sanitizeEnvSuffix:$}=await import("./tunnel-bootstrap-5wgt9a1h.js"),{getVibecontrolsProfile:Z}=await import("./path-utils-hxdyv2zn.js"),N=$(Z());T=process.env[`AGENT_TUNNEL_URL_${N}`]??process.env.AGENT_TUNNEL_URL??null}let HQ=C(),LQ=x||i()||HQ["static-api-key"]||"",w=q().getBootState(),YQ=w==="ready"?null:o();if(w==="ready")r();kQ({port:U,host:R,tunnelUrl:T,apiKey:LQ,revealApiKey:L||process.env.AGENT_PRINT_API_KEY==="1",state:w,pairingToken:YQ});try{t({profile:E})}catch($){q().logger.warn("server","Could not start autoupdate",{error:String($)})}let{existsSync:NQ,unlinkSync:qQ}=await import("fs"),{tmpdir:zQ}=await import("os"),{join:OQ}=await import("path"),u=async($)=>{q().logger.info("server",`Received ${$}, shutting down...`),e();try{let N=process.__vibe_started_at??Date.now();W.emit("agent.stopped",{uptime_s:Math.round((Date.now()-N)/1000),reason:$}),await W.flush(),W.stop()}catch{}let Z=O.getLifecycle();if($==="SIGTERM"){let N=OQ(zQ(),`.boff-vibecontrols-kill-${process.pid}`);if(NQ(N)){try{qQ(N)}catch{}if(q().logger.info("server","Kill-intent flag detected \u2014 full shutdown"),Z)await Z.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)"),Z)await Z.softStop();else await O.stop({reason:"reload"})}else if(Z)await Z.kill();else await O.stop({reason:"shutdown"}),process.exit(0)};if(process.on("SIGINT",()=>u("SIGINT")),process.on("SIGTERM",()=>u("SIGTERM")),ZQ){let $=(()=>{let Z=process.env.VIBECONTROLS_FINALIZE_TIMEOUT_MS,N=Z?Number.parseInt(Z,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($/1000)}s)`),(async()=>{let Z={clientId:Y,clientSecret:z,workspaceId:b,globalGatewayUrl:_,workspaceGatewayUrl:G};try{let N=await Promise.race([O.finalize(Z),new Promise((J)=>setTimeout(()=>J({ok:!1,error:`inline finalize timed out after ${Math.round($/1000)}s`}),$))]);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-dvykrzed.js"),{setFinalizeRetryHandle:K}=await import("./finalize-retry-handle-registry-xnm9kxry.js"),k=J({trigger:()=>O.finalize(Z)});K(k)}}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",L="\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(L),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(L),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("")}wQ();
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-c7554sg7.js";var t="./injections-73j83es3.scm";export{t as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Fc as a,Gc as b,Hc as c,Ic as d,Jc as e}from"./index-thammzct.js";import"./index-c7554sg7.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{Wb as a,Xb as b}from"./index-rzpaqrhx.js";import"./index-8sdrhr3q.js";import"./index-8nqp3a4d.js";import"./index-1mppacnx.js";import"./index-thammzct.js";import"./index-b6x6a4xp.js";import"./index-h74va4wd.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";export{a as resolveDefaultApiKey,b as register};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ee as a}from"./index-4qq083yd.js";import"./index-c7554sg7.js";export{a as logShipper};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$d as f,Wd as a,Xd as b,Yd as c,Zd as d,_d as e,ae as g,be as h,ce as i}from"./index-0cn9bv8z.js";import"./index-yy1mm8zs.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{$d as e,Xd as a,Yd as b,Zd as c,_d as d,ae as f,be as g,ce as h,de as i}from"./index-a4854mwz.js";import"./index-c7554sg7.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{Ga as a,Ia as b,Qa as c,Ra as d,Sa as e,Ta as f,Ua as g,Va as h,Wa as i}from"./index-g3ap3xpr.js";import"./index-0ckffygp.js";import"./index-9bqd8veb.js";import"./index-0cn9bv8z.js";import"./index-jw1k4vbk.js";import"./index-yy1mm8zs.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{Ga as a,Ia as b,Qa as c,Ra as d,Sa as e,Ta as f,Ua as g,Va as h,Wa as i}from"./index-s2xpdnsj.js";import"./index-0ckffygp.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.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-z5s398n0.js";import"./index-d1xjj001.js";import"./index-5dysvvjv.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";export{a as runPluginPrereqs,b as readPrereqState};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{nb as a,ob as b,pb as c,qb as d,rb as e,sb as f}from"./index-hvjqgb97.js";import"./index-rqq0k5fc.js";import"./index-5dysvvjv.js";import"./index-pgew6sge.js";import"./index-h74va4wd.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.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-c7554sg7.js";export{a as pruneStaleBunBinShims};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{J as a}from"./index-aq81xmn0.js";import"./index-d1xjj001.js";import"./index-b5dhmybd.js";import"./index-e1bw1bwr.js";import"./index-1zf3r23y.js";import"./index-rw9x93zb.js";import"./index-nmk7cbj5.js";import"./index-4wgjx8bf.js";import"./index-s2xpdnsj.js";import"./index-0ckffygp.js";import"./index-rc79x8fw.js";import"./index-ydc0tk17.js";import"./index-52cp759f.js";import"./index-rqq0k5fc.js";import"./index-5dysvvjv.js";import"./index-pgew6sge.js";import"./index-8nqp3a4d.js";import"./index-1mppacnx.js";import"./index-thammzct.js";import"./index-b6x6a4xp.js";import"./index-h74va4wd.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";export{a as registerCoreCommands};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{x as a}from"./index-ytgmhxsj.js";import"./index-a9ejdv22.js";import"./index-4wgjx8bf.js";import"./index-s2xpdnsj.js";import"./index-0ckffygp.js";import"./index-hvjqgb97.js";import"./index-rqq0k5fc.js";import"./index-5dysvvjv.js";import"./index-pgew6sge.js";import"./index-h74va4wd.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.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-5wpck4aw.js";import"./index-0ckffygp.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.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{bb as a}from"./index-ydc0tk17.js";import"./index-52cp759f.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";export{a as telemetryService};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-c7554sg7.js";var l="./tree-sitter-javascript-nd0q4pe9.wasm";export{l as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-c7554sg7.js";var F="./tree-sitter-markdown-411r6y9b.wasm";export{F as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-c7554sg7.js";var E="./tree-sitter-markdown_inline-j5349f42.wasm";export{E as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-c7554sg7.js";var h="./tree-sitter-typescript-zxjzwt75.wasm";export{h as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-c7554sg7.js";var A="./tree-sitter-zig-e78zbjpm.wasm";export{A as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{pa as a,qa as b,ra as c,sa as d,ta as e,ua as f}from"./index-rw9x93zb.js";import"./index-0ckffygp.js";import"./index-ydc0tk17.js";import"./index-52cp759f.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.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.602.2",
3
+ "version": "2026.602.4",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{n as a}from"./index-z2yjbq9a.js";import"./index-n7qyrdr1.js";import"./index-1hnw0rhc.js";import"./index-6jzsthh9.js";import"./index-g8zv1gta.js";import"./index-qfz9fy56.js";import"./index-ssjmzqcz.js";import"./index-tp4y9jde.js";import"./index-4wgjx8bf.js";import"./index-g3ap3xpr.js";import"./index-0ckffygp.js";import"./index-rc79x8fw.js";import"./index-yrgm89r8.js";import"./index-52cp759f.js";import"./index-v9fx5wab.js";import"./index-01qzsnwd.js";import"./index-d5ysy1yn.js";import"./index-04n4qgvd.js";import"./index-xjzmb1pn.js";import"./index-g2raeeh4.js";import"./index-9bqd8veb.js";import"./index-0cn9bv8z.js";import"./index-jw1k4vbk.js";import"./index-yy1mm8zs.js";export{a as createApp};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{t as a}from"./index-6jq17k9s.js";import"./index-9bqd8veb.js";import"./index-0cn9bv8z.js";import"./index-jw1k4vbk.js";import"./index-yy1mm8zs.js";export{a as bootstrapWorkspace};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{O as a,P as b}from"./index-e1bw1bwr.js";import"./index-yy1mm8zs.js";export{b as installDependencies,a as checkDependencies};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ld as a,Md as b,Nd as c,Od as d,Pd as e}from"./index-9bqd8veb.js";import"./index-0cn9bv8z.js";import"./index-jw1k4vbk.js";import"./index-yy1mm8zs.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{$b as e,Xb as a,Yb as b,Zb as c,_b as d,ac as f,bc as g,cc as h,dc as i,ec as j,fc as k}from"./index-2xs9cvjn.js";import"./index-yy1mm8zs.js";export{a as program,d as createOption,b as createCommand,c as createArgument,j as Option,g as InvalidOptionArgumentError,f as InvalidArgumentError,k as Help,e as CommanderError,h as Command,i as Argument};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Fd as a,Gd as b,Hd as c,Id as d}from"./index-9bqd8veb.js";import"./index-0cn9bv8z.js";import"./index-jw1k4vbk.js";import"./index-yy1mm8zs.js";export{a as normalizeGatewayUrl,c as gatewayClient,d as default,b as GatewayClient};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-yy1mm8zs.js";var a="./highlights-x6tmsnaa.scm";export{a as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-yy1mm8zs.js";var t="./highlights-r812a2qc.scm";export{t as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-yy1mm8zs.js";var r="./highlights-eq9cgrbb.scm";export{r as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-yy1mm8zs.js";var n="./highlights-hk7bwhj4.scm";export{n as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-yy1mm8zs.js";var t="./highlights-ghv9g403.scm";export{t as default};
@@ -1,16 +0,0 @@
1
- // @bun
2
- import{Sb as jY}from"./index-d5ysy1yn.js";import{Ub as WY}from"./index-04n4qgvd.js";import{Rc as zY,Sc as A,nd as P,pd as JY}from"./index-g2raeeh4.js";import{Kd as HY,Ld as wY,Nd as V}from"./index-9bqd8veb.js";import{Xd as p}from"./index-0cn9bv8z.js";import{randomBytes as M,createHmac as E,timingSafeEqual as vY}from"crypto";var R=600,n=600,g=M(32),K="p2.";function S(Y){if(!Y.startsWith("/"))return`/${Y}`;return Y.length>1&&Y.endsWith("/")?Y.slice(0,-1):Y}var UY=/^\/terminal\/[A-Za-z0-9_-]{1,128}(?:\/.*)?$/,XY=/^\/ui\/[a-z0-9-]{1,64}(?:\/.*)?$/,NY=/^\/plan\/[A-Za-z0-9_-]{1,128}(?:\/.*)?$/,bY=/^\/git(?:\/.*)?$/,OY="/ws/logs",LY=/^\/code-server(?:\/.*)?$/,CY=/^\/api\/plugins\/[a-z0-9-]{1,64}\/ui(?:\/.*)?$/;function s(Y){if(typeof Y!=="string"||Y.length===0)return!1;if(Y.includes("\x00")||Y.includes(`
3
- `)||Y.includes("|"))return!1;if(Y.includes(".."))return!1;if(new Set(["/","/api","/api/agent","/api/plugins","/api/profiles","/health","/metrics","/ws","/api/ai","/api/logs"]).has(Y))return!1;if(UY.test(Y))return!0;if(XY.test(Y))return!0;if(NY.test(Y))return!0;if(bY.test(Y))return!0;if(Y===OY)return!0;if(LY.test(Y))return!0;if(CY.test(Y))return!0;return!1}var DY=new Set(["*","GET","HEAD","POST","PUT","PATCH","DELETE","OPTIONS"]);function KY(Y){if(!Y||Y.length===0)return["*"];let Z=new Set,$=[];for(let Q of Y){if(typeof Q!=="string")continue;let W=Q.toUpperCase();if(!DY.has(W))throw Error(`invalid method: ${Q}`);if(!Z.has(W))Z.add(W),$.push(W)}if($.length===0)return["*"];return $.sort()}function r(Y,Z){if(Y.includes("*"))return!0;return Y.includes(Z.toUpperCase())}var MY=/^[A-Za-z0-9_-]{1,128}$/;function SY(Y){return typeof Y==="string"&&MY.test(Y)}function x(Y,Z,$){return E("sha256",g).update(`${Y}
4
- ${Z}
5
- ${$}`).digest("hex")}var y=new Map;function kY(Y){for(let[Z,$]of y)if($<=Y)y.delete(Z)}function a(Y,Z){let $=Date.parse(Z);if(!Number.isFinite($))return;y.set(Y,$)}function i(Y){return kY(Date.now()),y.has(Y)}function h(Y,Z,$,Q){return E("sha256",g).update(`v2
6
- ${Y}
7
- ${Z}
8
- ${$}
9
- ${Q}`).digest("hex")}function T(Y){return Buffer.from(Y,"utf8").toString("base64").replace(/=+$/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(Y){try{let Z=Y.replace(/-/g,"+").replace(/_/g,"/"),$=Z.length%4===0?Z:Z+"=".repeat(4-Z.length%4);return Buffer.from($,"base64").toString("utf8")}catch{return null}}var d=16;function qY(Y){if(Y.length>d)throw Error(`pathPrefixes exceeds maximum count (${Y.length} > ${d})`);let Z=new Set,$=[];for(let Q of Y){if(!Q||typeof Q!=="string")continue;if(Q.includes("..")||Q.includes("\x00"))throw Error("invalid pathPrefix");let W=S(Q);if(!s(W))throw Error(`pathPrefix '${W}' is not an allowed iframe surface`);if(!Z.has(W))Z.add(W),$.push(W)}return $.sort()}function nY(Y,Z=R){if(!Y||typeof Y!=="string")throw Error("pathPrefix is required");if(Y.includes("..")||Y.includes("\x00"))throw Error("invalid pathPrefix");let $=Math.min(Math.max(1,Math.floor(Z||R)),n),Q=S(Y);if(!s(Q))throw Error(`pathPrefix '${Q}' is not an allowed iframe surface`);let W=new Date(Date.now()+$*1000).toISOString(),z=M(16).toString("hex"),J=x(Q,W,z);return{token:`${W}|${z}|${J}`,expiresAt:W}}function sY(Y,Z=R){if(!Y||!Array.isArray(Y.pathPrefixes)||Y.pathPrefixes.length===0)throw Error("pathPrefixes is required");let $=qY(Y.pathPrefixes);if($.length===0)throw Error("pathPrefixes is required");let Q=KY(Y.methods),W=Math.min(Math.max(1,Math.floor(Z||R)),n),z=new Date(Date.now()+W*1000).toISOString(),J=M(16).toString("hex"),j=T(JSON.stringify($)),G=T(JSON.stringify(Q)),H=`${K}${j}.${G}`,w=h(j,G,z,J);return{token:`${z}|${J}|${H}|${w}`,expiresAt:z}}function L(Y,Z){if(Y.length!==Z.length)return!1;try{return vY(Buffer.from(Y,"hex"),Buffer.from(Z,"hex"))}catch{return!1}}function _(Y,Z){let $=S(Z);return Y===$||Y.startsWith(`${$}/`)}function t(Y,Z,$="*"){return FY(Y,Z,$).ok}function FY(Y,Z,$="*"){if(!Y||typeof Y!=="string")return{ok:!1,reason:"missing"};let Q=Y.split("|");if(Q.length===3)return RY(Q,Z);if(Q.length===4)return yY(Q,Z,$);return{ok:!1,reason:"malformed"}}function RY(Y,Z){let[$,Q,W]=Y;if(!$||!Q||!W)return{ok:!1,reason:"malformed"};if(!C($))return{ok:!1,reason:"expired"};let z=Z.split("/").filter(Boolean),J=["/"],j="";for(let G of z)j+=`/${G}`,J.push(j);for(let G of J){let H=x(S(G),$,Q);if(L(H,W)){if(!_(Z,G))return{ok:!1,reason:"path_mismatch"};if(i(Q))return{ok:!1,reason:"replayed"};return a(Q,$),{ok:!0}}}return{ok:!1,reason:"bad_signature"}}function yY(Y,Z,$){let[Q,W,z,J]=Y;if(!Q||!W||!z||!J)return{ok:!1,reason:"malformed"};if(!z.startsWith(K))return{ok:!1,reason:"malformed"};if(!C(Q))return{ok:!1,reason:"expired"};let G=z.slice(K.length).split("."),H=G[0]??"",w=G[1]??T(JSON.stringify(["*"]));if(!H)return{ok:!1,reason:"malformed"};let N=h(H,w,Q,W);if(!L(N,J))return{ok:!1,reason:"bad_signature"};let F=I(H);if(F===null)return{ok:!1,reason:"malformed"};let b;try{b=JSON.parse(F)}catch{return{ok:!1,reason:"malformed"}}if(!Array.isArray(b))return{ok:!1,reason:"malformed"};let O=I(w),D=["*"];if(O!==null)try{let B=JSON.parse(O);if(Array.isArray(B)&&B.every((v)=>typeof v==="string"))D=B}catch{return{ok:!1,reason:"malformed"}}if($!=="*"&&!r(D,$))return{ok:!1,reason:"method_mismatch"};for(let B of b){if(typeof B!=="string")continue;if(_(Z,B)){if(i(W))return{ok:!1,reason:"replayed"};return a(W,Q),{ok:!0}}}return{ok:!1,reason:"path_mismatch"}}function rY(Y,Z,$="*"){if(!Y||typeof Y!=="string")return!1;let Q=Y.split("|");if(Q.length===3){let[W,z,J]=Q;if(!W||!z||!J)return!1;if(!C(W))return!1;let j=Z.split("/").filter(Boolean),G=["/"],H="";for(let w of j)H+=`/${w}`,G.push(H);for(let w of G){let N=x(S(w),W,z);if(L(N,J))return _(Z,w)}return!1}if(Q.length===4){let[W,z,J,j]=Q;if(!W||!z||!J||!j)return!1;if(!J.startsWith(K))return!1;if(!C(W))return!1;let H=J.slice(K.length).split("."),w=H[0]??"",N=H[1]??T(JSON.stringify(["*"]));if(!w)return!1;let F=h(w,N,W,z);if(!L(F,j))return!1;let b=I(w);if(b===null)return!1;let O;try{O=JSON.parse(b)}catch{return!1}if(!Array.isArray(O))return!1;let D=I(N),B=["*"];if(D!==null)try{let v=JSON.parse(D);if(Array.isArray(v)&&v.every((BY)=>typeof BY==="string"))B=v}catch{return!1}if($!=="*"&&!r(B,$))return!1;for(let v of O){if(typeof v!=="string")continue;if(_(Z,v))return!0}return!1}return!1}function C(Y){let Z=Date.parse(Y);return Number.isFinite(Z)&&Date.now()<Z}function c(Y,Z){let $=Y.headers.get("x-vibe-iframe-token")??Y.headers.get("X-Vibe-Iframe-Token");if($)return $;try{let Q=new URL(Y.url).searchParams.get("vt");if(Q)return Q}catch{}return null}var u="tc1|",l=600,TY=600;function e(Y,Z,$){return E("sha256",g).update(`tc1
10
- ${Y}
11
- ${Z}
12
- ${$}`).digest("hex")}function aY(Y,Z=l){if(!SY(Y))throw Error("invalid sid");let $=Math.min(Math.max(1,Math.floor(Z||l)||l),TY),Q=new Date(Date.now()+$*1000).toISOString(),W=M(16).toString("hex"),z=e(Y,Q,W);return{token:`${u}${Q}|${Y}|${W}|${z}`,expiresAt:Q}}function iY(Y,Z){if(!Y||typeof Y!=="string")return!1;if(!Y.startsWith(u))return!1;let Q=Y.slice(u.length).split("|");if(Q.length!==4)return!1;let[W,z,J,j]=Q;if(!W||!z||!J||!j)return!1;if(z!==Z)return!1;if(!C(W))return!1;let G=e(z,W,J);return L(G,j)}function IY(Y,Z){let $;if(Y instanceof Headers)$=Y.get("cookie")??Y.get("Cookie")??void 0;else $=Y.cookie??Y.Cookie??void 0;if(!$)return null;let Q=`vt_term_${Z}`;for(let W of $.split(";")){let z=W.indexOf("=");if(z===-1)continue;if(W.slice(0,z).trim()!==Q)continue;return W.slice(z+1).trim()||null}return null}function tY(Y,Z){return IY(Y.headers,Z)}var f="uc1|",m=600,_Y=600,EY=/^[a-z0-9-]{1,64}$/;function gY(Y){return typeof Y==="string"&&EY.test(Y)}function YY(Y,Z,$){return E("sha256",g).update(`uc1
13
- ${Y}
14
- ${Z}
15
- ${$}`).digest("hex")}function eY(Y,Z=m){if(!gY(Y))throw Error("invalid plugin name");let $=Math.min(Math.max(1,Math.floor(Z||m)||m),_Y),Q=new Date(Date.now()+$*1000).toISOString(),W=M(16).toString("hex"),z=YY(Y,Q,W);return{token:`${f}${Q}|${Y}|${W}|${z}`,expiresAt:Q}}function YZ(Y,Z){if(!Y||typeof Y!=="string")return!1;if(!Y.startsWith(f))return!1;let Q=Y.slice(f.length).split("|");if(Q.length!==4)return!1;let[W,z,J,j]=Q;if(!W||!z||!J||!j)return!1;if(z!==Z)return!1;if(!C(W))return!1;let G=YY(z,W,J);return L(G,j)}function AY(Y,Z){let $;if(Y instanceof Headers)$=Y.get("cookie")??Y.get("Cookie")??void 0;else $=Y.cookie??Y.Cookie??void 0;if(!$)return null;let Q=`vt_ui_${Z}`;for(let W of $.split(";")){let z=W.indexOf("=");if(z===-1)continue;if(W.slice(0,z).trim()!==Q)continue;return W.slice(z+1).trim()||null}return null}function ZZ(Y,Z){return AY(Y.headers,Z)}import{timingSafeEqual as PY}from"crypto";var lY=["/health","/ui","/code-server","/terminal","/plan","/git","/api/agent/status","/api/agent/version","/api/agent/identity","/api/agent/terminal-exchange","/api/agent/ui-exchange","/api/agent/ui-exchange-plugin","/metrics"];function ZY(Y,Z){if(!Z||Z==="/")return!1;let $=Z.endsWith("/")?Z.slice(0,-1):Z;return Y===$||Y.startsWith(`${$}/`)}function mY(Y){let Z=Y.replace(/^\/api\/profiles\/[^/]+/,"/api");return Z==="/api"?"/":Z}function uY(Y){let Z=/^\/api\/profiles\/([^/]+)(?:\/|$)/.exec(Y);if(!Z)return null;let $=Z[1];if(!$)return null;return $}function $Y(Y,Z){let $=[Y],Q=mY(Y);if(Q!==Y)$.push(Q);for(let W of $){if(lY.some((z)=>ZY(W,z)))return!0;if(Z.some((z)=>ZY(W,z)))return!0}return!1}function GY(){let Y=new Uint8Array(32);return crypto.getRandomValues(Y),`vcak_${Buffer.from(Y).toString("base64url")}`}var U=null;function VY(){return`${p()}:static-api-key`}async function BZ(){let Y=process.env.AGENT_API_KEY;if(Y)return U=Y,Y;let Z=VY(),$=await zY(Z);if($)return U=$,$;let Q=P({dir:V().dataDir})["static-api-key"];if(Q){try{await A(Z,Q)}catch(z){V().logger.warn("auth","could not persist legacy api key into secrets backend",{error:String(z)})}return U=Q,Q}let W=GY();return await A(Z,W),U=W,V().logger.info("auth","Generated and persisted new agent API key"),V().audit.emit("agent","apikey.minted",{profile:p(),via:"loadAgentApiKey"}),W}function k(){let Y=process.env.AGENT_API_KEY;if(Y)return Y;if(U!==null)return U;let Z=P()["static-api-key"];if(Z)return U=Z,Z;let $=GY();U=$;try{JY({"static-api-key":$},{dir:V().dataDir,scope:V().name})}catch{}return A(VY(),$).catch(()=>{}),$}function fY(Y){let Z=Y["x-agent-api-key"]??Y["X-Agent-Api-Key"];if(Z)return Z;let $=Y.authorization??Y.Authorization;if($?.startsWith("Bearer "))return $.slice(7);return null}function xY(Y){return!1}function hY(Y,Z){let $=fY(Object.fromEntries(Y.headers.entries()));if($)return $;if(!xY(Z))return null;try{let Q=new URL(Y.url).searchParams.get("apiKey");if(Q)return Q}catch{}return null}function q(Y,Z){let $=Buffer.from(Y),Q=Buffer.from(Z);if($.length!==Q.length)return!1;try{return PY($,Q)}catch{return!1}}function vZ(Y){if(!Y)return!1;return q(Y,k())}async function cY(Y,Z){if(!Y)return!1;let $=uY(Z);if($){let Q=wY.get($);if(Q){try{if(await Q.keyVault.match(Y))return!0}catch{}if($===V().name){try{if(await V().keyVault.match(Y))return!0}catch{}return q(Y,k())}return!1}}try{if(await V().keyVault.match(Y))return!0}catch{}if(q(Y,k()))return!0;if(oY(Y)!==null)return!0;return!1}function oY(Y){if(!Y)return null;if(q(Y,k()))return{name:"default",scopes:new Set(["admin"])};let Z=HY()??V(),$=P({dir:Z.dataDir}),Q=Date.now();for(let W of $.apiKeys??[]){if(!q(Y,W.key))continue;if(W.notBefore){let z=Date.parse(W.notBefore);if(Number.isFinite(z)&&Q<z)return null}if(W.expiresAt){let z=Date.parse(W.expiresAt);if(Number.isFinite(z)&&Q>=z)return null}return{name:W.name,scopes:new Set(W.scopes)}}return null}function UZ(Y,Z){if(!Y)return!1;if(Y.scopes.has("admin"))return!0;return Z.some(($)=>Y.scopes.has($))}var X=null;function o(Y,Z){try{V().audit.emit("auth",Y,Z)}catch{V().logger.warn("auth.audit",Y,Z)}}function pY(Y){let Z=new Set(Y());if(X===null)for(let $ of Z)o("plugin.public_path.declared",{path:$});else{for(let $ of Z)if(!X.has($))o("plugin.public_path.added",{path:$});for(let $ of X)if(!Z.has($))o("plugin.public_path.removed",{path:$})}return X=Z,Z}function XZ(){X=null}function QY(Y){if(!Y)return[];if(X===null)return[...pY(Y)];return[...X]}function NZ(Y){let Z=k();return V().logger.info("auth",`Agent API key: ${Z.substring(0,8)}****${Z.substring(Z.length-4)}`),new WY({name:"plugin/auth"}).decorate("apiKey",Z).derive(async({request:$,path:Q})=>{let W=QY(Y),z;if($Y(Q,W))z=!0;else if(jY($.headers))z=!0;else{let J=c($,Q);if(J&&t(J,Q,$.method))z=!0;else{let j=hY($,Q);z=await cY(j,Q)}}return{isAuthenticated:z}}).onBeforeHandle(({isAuthenticated:$,request:Q,path:W,set:z})=>{let J=QY(Y);if(!$&&!$Y(W,J)){if(c(Q,W))return z.status=401,{error:"invalid iframe token"};return z.status=401,{error:"Unauthorized",message:"Invalid or missing API key"}}}).as("global")}
16
- export{SY as tb,nY as ub,sY as vb,t as wb,FY as xb,rY as yb,c as zb,aY as Ab,iY as Bb,IY as Cb,tY as Db,gY as Eb,eY as Fb,YZ as Gb,ZZ as Hb,BZ as Ib,k as Jb,fY as Kb,vZ as Lb,oY as Mb,UZ as Nb,XZ as Ob,NZ as Pb};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{c as a}from"./index-8kvc8ttn.js";import"./index-x1h8r7pr.js";import"./index-yy1mm8zs.js";export default a();
@@ -1,11 +0,0 @@
1
- // @bun
2
- import{h as y,i as A}from"./index-cs78wq6y.js";import{A as l$,B as p$,y as v$}from"./index-1hnw0rhc.js";import{N as H$}from"./index-b5dhmybd.js";import{O as K$,P as q$}from"./index-e1bw1bwr.js";import{va as g}from"./index-ssjmzqcz.js";import"./index-tp4y9jde.js";import{Ca as h$}from"./index-4wgjx8bf.js";import"./index-g3ap3xpr.js";import"./index-0ckffygp.js";import{ab as v}from"./index-rc79x8fw.js";import{db as Y$}from"./index-52cp759f.js";import"./index-v9fx5wab.js";import{Jb as C$,tb as X$,vb as L$}from"./index-01qzsnwd.js";import"./index-d5ysy1yn.js";import{Tb as F,Ub as p}from"./index-04n4qgvd.js";import{Wb as c$}from"./index-dm6yjmgq.js";import"./index-2xs9cvjn.js";import{ic as M,jc as x,kc as y$}from"./index-5mw3eshk.js";import{Ac as N,Bc as u,nc as V,oc as Z,pc as Y,qc as K,rc as c,tc as z,uc as X,vc as J,wc as Q,xc as P$,yc as k,zc as s}from"./index-z5a4yxzz.js";import{Gc as q}from"./index-ef95xr4z.js";import{Kc as T,Mc as _,Nc as j,Oc as m$}from"./index-xjzmb1pn.js";import{pd as T$}from"./index-g2raeeh4.js";import{Hd as z$,Kd as D$,Nd as b}from"./index-9bqd8veb.js";import{$d as U$,Xd as J$,Zd as a,_d as $$}from"./index-0cn9bv8z.js";import"./index-jw1k4vbk.js";import{he as d}from"./index-yy1mm8zs.js";function t(f){let{name:W,onInit:G,onShutdown:U,onNuke:R,telemetryEventName:$,skipPlatforms:w}=f;return{onServerStart:async(I,O)=>{if(w&&w.includes(process.platform)){process.stderr.write(`[${W}] skipping init on unsupported platform '${process.platform}'
3
- `);return}if(G)await G(O);if($)O.telemetry?.emit($,{plugin:W})},onServerStop:async(I)=>{if(U)await U(I)},onNuke:async(I,O)=>{if(R)return R(I,O)}}}var e=class{constructor(f,W){this.logger=f,this.source=W}logger;source;info(f,W){this.logger?.info?.(this.source,f,W)}warn(f,W){this.logger?.warn?.(this.source,f,W)}error(f,W){this.logger?.error?.(this.source,f,W)}debug(f,W){this.logger?.debug?.(this.source,f,W)}};import{existsSync as r$,rmSync as t$,statSync as e$}from"fs";import{resolve as a$}from"path";function R$(f=$$()){let W=[],G=a$(f),U=U$();if(!a(U,G))throw Error("Refusing to reset a path outside the agents directory");if(r$(G)&&e$(G).isDirectory())t$(G,{recursive:!0,force:!0}),W.push(G);return{removed:W,agentDir:G}}var S="alias",w$=/^[a-zA-Z0-9_-]{1,64}$/,G$=16384,f$=256,W$=1024,$U=new Set(["help","start","stop","restart","kill","list","status","setup","update","completion","autostart","export","import","diagnostics","nuke","doctor","log-level","gc","deploy","network","profile","peer-bootstrap","gateway-auth","info","key","system","url","health","notify","tunnel","session","git","config","log","plugin","ai","audit","alias","run"]);class D extends Error{code;constructor(f,W){super(W);this.code=f,this.name="AliasValidationError"}}class E extends Error{constructor(f){super(`alias '${f}' already exists`);this.name="AliasConflictError"}}class n extends Error{constructor(f){super(`alias '${f}' not found`);this.name="AliasNotFoundError"}}function UU(f){if(typeof f!=="string"||!w$.test(f))throw new D("invalid_name",`alias name must match ${w$} (got '${f}')`);if($U.has(f))throw new D("reserved_name",`alias name '${f}' is reserved`)}function I$(f){if(typeof f!=="string"||f.length===0)throw new D("invalid_command","alias command must be a non-empty string");if(f.length>G$)throw new D("command_too_long",`alias command exceeds ${G$} bytes`)}function O$(f){if(f===void 0)return;if(typeof f!=="string")throw new D("invalid_description","alias description must be a string");if(f.length>f$)throw new D("description_too_long",`alias description exceeds ${f$} chars`)}function F$(f){if(f===void 0||f===null||f==="")return;if(typeof f!=="string")throw new D("invalid_cwd","alias cwd must be a string");if(f.length>W$)throw new D("cwd_too_long",`alias cwd exceeds ${W$} chars`);if(f.includes("\x00"))throw new D("invalid_cwd","alias cwd must not contain NUL bytes")}function RU(f){if(!f)return;try{return JSON.parse(f)}catch{return}}async function i(f){let W=await f.getAllPluginState(S),G=[];for(let U of W){let R=RU(U.value);if(R)G.push(R)}return G.sort((U,R)=>U.name.localeCompare(R.name)),G}async function P(f,W){return(await i(f)).find((U)=>U.name===W)}function V$(f){if(f===void 0||f===null)return null;let W=f.trim();return W===""?null:W}async function Q$(f,W){if(UU(W.name),I$(W.command),O$(W.description),F$(W.cwd),await P(f,W.name))throw new E(W.name);let U=new Date().toISOString(),R={id:crypto.randomUUID(),name:W.name,command:W.command,description:W.description,cwd:V$(W.cwd),profile:J$(),createdAt:U,updatedAt:U};return await f.setPluginState(S,R.id,JSON.stringify(R)),R}async function Z$(f,W,G){let U=await P(f,W);if(!U)throw new n(W);if(G.command!==void 0)I$(G.command);if(G.description!==void 0)O$(G.description);if(G.cwd!==void 0)F$(G.cwd);let R={...U,command:G.command??U.command,description:G.description!==void 0?G.description:U.description,cwd:G.cwd!==void 0?V$(G.cwd):U.cwd,updatedAt:new Date().toISOString()};return await f.setPluginState(S,R.id,JSON.stringify(R)),R}async function B$(f,W){let G=await P(f,W);if(!G)throw new n(W);await f.deletePluginState(S,G.id)}function m(){let f=D$()??b();return{dir:f.dataDir,scope:f.name}}function j$(f){let{serviceRegistry:W,db:G}=f;return new p().get("/api-key",()=>({apiKey:C$()})).get("/audit",({query:U})=>{let R=U,$=R.limit?Math.min(5000,Math.max(1,Number.parseInt(R.limit,10)||100)):100,w=b().audit.listEvents({since:R.since,limit:$,event:R.event});return{events:w,count:w.length}},{query:F.Object({since:F.Optional(F.String()),limit:F.Optional(F.String()),event:F.Optional(F.String())})}).get("/setup/check",()=>{let U=K$();return{ready:U.filter(($)=>$.required).every(($)=>$.installed),dependencies:U}}).post("/setup/install",async({request:U,server:R,set:$})=>{let w=await A(U,"VIBECONTROLS_ALLOW_REMOTE_SETUP_INSTALL",R);if(w)return $.status=403,{error:"Forbidden",message:w};return await q$()}).get("/url",async()=>{let U=W.getProvider("tunnel"),R=U&&U.getActiveTunnelUrl?await U.getActiveTunnelUrl():null,$=`http://localhost:${process.env.PORT||3005}`;return{url:R||$,tunnelUrl:R,localUrl:$,source:R?"tunnel":"local"}}).get("/lifecycle/state",()=>{return{state:W.getService("agent","lifecycle")?.getState()??"running"}}).post("/lifecycle/stop",async({set:U})=>{let R=W.getService("agent","lifecycle");if(!R)return U.status=500,{error:"Lifecycle manager not initialized"};return await R.stop(),{state:"stopped"}}).post("/lifecycle/start",async({set:U})=>{let R=W.getService("agent","lifecycle");if(!R)return U.status=500,{error:"Lifecycle manager not initialized"};return await R.start(),{state:"running"}}).post("/lifecycle/kill",async({set:U})=>{let R=W.getService("agent","lifecycle");if(!R)return U.status=500,{error:"Lifecycle manager not initialized"};return setTimeout(()=>R.kill(),100),{state:"killing"}}).post("/log-level",async({body:U,request:R,server:$,set:w})=>{let I=await A(R,"VIBECONTROLS_ALLOW_REMOTE_LOG_LEVEL",$);if(I)return w.status=403,{error:"Forbidden",message:I};let O=String(U.level??"").toLowerCase();if(!["debug","info","warn","error"].includes(O))return w.status=400,{error:"Invalid level",message:"level must be debug | info | warn | error"};return b().logger.setLevel(O),b().logger.info("agent",`Log level set to ${O} via API`),{ok:!0,level:O}},{body:F.Object({level:F.String()})}).post("/reset",async({body:U,request:R,server:$,set:w})=>{if(!U.confirm)return w.status=400,{error:"Reset confirmation required",message:"Send { confirm: true } to reset local agent state."};let I=await A(R,"VIBECONTROLS_ALLOW_REMOTE_RESET",$);if(I)return w.status=403,{error:"Forbidden",message:I};let O=W.getService("agent","lifecycle");try{if(O)await O.prepareForReset()}catch(h){b().logger.warn("agent","prepareForReset failed during reset \u2014 proceeding to wipe anyway",{error:String(h)})}try{z$.configure({globalGatewayUrl:"",workspaceGatewayUrl:void 0,clientId:"",clientSecret:"",workspaceId:void 0})}catch{}await G.close();let{removed:B,agentDir:L}=R$();b().logger.info("agent","Reset wiped local agent state",{agentDir:L,removed:B});let C=new Uint8Array(32);crypto.getRandomValues(C);let H=`vcak_${Buffer.from(C).toString("base64url")}`;return T$({"static-api-key":H},m()),b().setBootState("awaiting-config"),w.status=200,{success:!0,state:"awaiting-config",...y(R,$)||process.env.VIBECONTROLS_RETURN_RESET_API_KEY==="1"?{newApiKey:H}:{},agentDir:L,removed:B}},{body:F.Object({confirm:F.Boolean()})}).post("/sessions/:sessionId/share",async({params:U,body:R,server:$,request:w,set:I})=>{if(!y(w,$)&&process.env.VIBECONTROLS_ALLOW_REMOTE_SESSION_SHARE!=="1")return I.status=403,{error:"Forbidden",message:"Session-share mint must come from a local request unless VIBECONTROLS_ALLOW_REMOTE_SESSION_SHARE=1."};if(!X$(U.sessionId))return I.status=400,{error:"BadRequest",message:"invalid sessionId"};let O=wU(R?.expiresIn)??1800000,B=crypto.randomUUID(),L=new Uint8Array(32);crypto.getRandomValues(L);let C=`vcak_${Buffer.from(L).toString("base64url")}`,H=new Date(Date.now()+O).toISOString(),r=[...(await import("./agent-config-85pskv43.js")).readAgentConfig({dir:m().dir}).apiKeys??[],{id:B,name:`session-share:${U.sessionId}:${R?.label??"viewer"}`,key:C,scopes:["read"],expiresAt:H,createdAt:new Date().toISOString()}];(await import("./agent-config-85pskv43.js")).writeAgentConfig({apiKeys:r},m());let h=W.getProvider("tunnel"),i$=(h&&h.getActiveTunnelUrl?await h.getActiveTunnelUrl():null)??`http://localhost:${process.env.PORT||3005}`,d$=L$({pathPrefixes:[`/terminal/${U.sessionId}`],methods:["GET"]},Math.min(600,Math.floor(O/1000))),s$=`${i$.replace(/\/$/,"")}/terminal/${encodeURIComponent(U.sessionId)}/#vt=${encodeURIComponent(d$.token)}`;return b().logger.info("session-share","Minted share credential",{sessionId:U.sessionId,keyId:B,expiresAt:H}),{ok:!0,keyId:B,apiKey:C,joinUrl:s$,sessionId:U.sessionId,expiresAt:H}},{params:F.Object({sessionId:F.String()}),body:F.Optional(F.Object({permissions:F.Optional(F.Array(F.String())),expiresIn:F.Optional(F.String()),label:F.Optional(F.String())}))}).get("/aliases",async()=>{return{aliases:await i(G)}}).get("/aliases/:name",async({params:U,set:R})=>{let $=await P(G,U.name);if(!$)return R.status=404,{error:"Alias not found"};return $},{params:F.Object({name:F.String()})}).post("/aliases",async({body:U,set:R})=>{try{let $=await Q$(G,U);return R.status=201,$}catch($){if($ instanceof E)return R.status=409,{error:"Alias already exists",message:$.message};if($ instanceof D)return R.status=400,{error:$.code,message:$.message};throw $}},{body:F.Object({name:F.String(),command:F.String(),description:F.Optional(F.String()),cwd:F.Optional(F.Union([F.String(),F.Null()]))})}).put("/aliases/:name",async({params:U,body:R,set:$})=>{try{return await Z$(G,U.name,R)}catch(w){if(w instanceof n)return $.status=404,{error:"Alias not found"};if(w instanceof D)return $.status=400,{error:w.code,message:w.message};throw w}},{params:F.Object({name:F.String()}),body:F.Object({command:F.Optional(F.String()),description:F.Optional(F.String()),cwd:F.Optional(F.Union([F.String(),F.Null()]))})}).delete("/aliases/:name",async({params:U,set:R})=>{try{return await B$(G,U.name),R.status=204,null}catch($){if($ instanceof n)return R.status=404,{error:"Alias not found"};throw $}},{params:F.Object({name:F.String()})}).post("/aliases/:name/execute",async({params:U,body:R,set:$})=>{let w=await P(G,U.name);if(!w)return $.status=404,{error:"Alias not found"};let I=R?.args??[],O=await H$(w,I);b().audit.emit("agent","alias.executed",{exit_code:O.exit_code});let B=Y$("alias.executed",{exit_code:O.exit_code});if(!B.ok)b().logger.debug("alias",`telemetry validate failed: ${B.reason}`);if(O.timed_out)$.status=408;return{exit_code:O.exit_code,stdout:O.stdout,stderr:O.stderr,duration_ms:O.duration_ms,truncated:O.truncated,cwd:O.cwd}},{params:F.Object({name:F.String()}),body:F.Optional(F.Object({args:F.Optional(F.Array(F.String()))}))}).post("/sessions/share/:keyId/revoke",async({params:U,server:R,request:$,set:w})=>{if(!y($,R)&&process.env.VIBECONTROLS_ALLOW_REMOTE_SESSION_SHARE!=="1")return w.status=403,{error:"Forbidden"};let I=await import("./agent-config-85pskv43.js"),O=m(),B=I.readAgentConfig({dir:O.dir}),L=(B.apiKeys??[]).length,C=(B.apiKeys??[]).filter((H)=>H.id!==U.keyId);if(C.length===L)return w.status=404,{error:"No such share key"};return I.writeAgentConfig({apiKeys:C},O),{ok:!0,revoked:U.keyId}},{params:F.Object({keyId:F.String()})})}function wU(f){if(!f)return null;let W=/^(\d+)([smhdw]?)$/.exec(f.trim());if(!W)return null;let G=Number(W[1]),U=W[2]||"m";return U==="s"?G*1000:U==="m"?G*60000:U==="h"?G*3600000:U==="d"?G*86400000:G*7*86400000}var GU="http://localhost:3005";function M$(f){f.command("health").description("Check health of a VibeControls agent instance").option("-n, --name <name>","Agent instance name").option("--agent-url <url>","Agent URL",GU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let G={...f.opts(),...W};await x({mode:M(G),fetchData:async()=>{if(G.name){let $=await new g().checkHealth(G.name);return{mode:"named",agentUrl:T(G),name:G.name,healthy:$.healthy,details:$.details??{}}}let U=T(G);try{let R=await j(U,"/health");return{mode:"url",agentUrl:U,healthy:!0,details:R}}catch(R){return{mode:"url",agentUrl:U,healthy:!1,details:{status:"unhealthy",...R instanceof Error?{error:K(R)}:{}}}}},plain:(U)=>{if(X("Agent Health"),Q(),U.mode==="named"){if(!U.healthy){Y(`Agent instance ${V.bold(U.name??"")} is not responding.`);return}let R=U.details;if(J("Instance",U.name??""),J("Status",u(R.status??"healthy")),R.uptime!==void 0)J("Uptime",`${R.uptime}s`);if(R.checks){Q(),z(`${Z.info} Health checks:`);for(let[$,w]of Object.entries(R.checks)){let I=w.status==="healthy"?Z.success:Z.error;J(` ${I} ${$}`,u(w.status))}}}else{if(J("URL",U.agentUrl),J("Status",u(U.details.status??"unhealthy")),U.details.version)J("Version",U.details.version);if(U.details.uptime!==void 0)J("Uptime",`${U.details.uptime}s`);if(U.details.timestamp)J("Timestamp",U.details.timestamp);if(U.details.checks){Q(),z(`${Z.info} Health checks:`);for(let[R,$]of Object.entries(U.details.checks)){let w=$.status==="healthy"?Z.success:Z.error;J(` ${w} ${R}`,u($.status))}}}if(Q(),U.healthy)c(`${Z.success} Agent is healthy.`)},interactive:async(U)=>{let R=[];if(U.mode==="named")R.push(`Instance: ${U.name??""}`);else R.push(`URL: ${U.agentUrl}`);if(R.push(`Status: ${u(U.details.status??(U.healthy?"healthy":"unhealthy"))}`),U.details.version)R.push(`Version: ${U.details.version}`);if(U.details.uptime!==void 0)R.push(`Uptime: ${U.details.uptime}s`);if(U.details.timestamp)R.push(`Time: ${U.details.timestamp}`);if(U.details.checks){R.push(""),R.push("Checks:");for(let[$,w]of Object.entries(U.details.checks))R.push(` ${$}: ${w.status}`)}await q({title:"Agent Health",body:R.join(`
4
- `),footer:"press q to exit"})},json:(U)=>({mode:U.mode,agentUrl:U.agentUrl,name:U.name??null,healthy:U.healthy,details:U.details})})}catch(G){Y(`Health check failed: ${K(G)}`)}})}import{platform as fU,arch as WU,release as JU,hostname as IU,cpus as OU,totalmem as FU}from"os";var VU="http://localhost:3005";function x$(f){f.command("info").description("Show local and remote VibeControls agent information").option("--agent-url <url>","Agent URL",VU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let G={...f.opts(),...W},U=T(G),R=encodeURIComponent(_(G));await x({mode:M(G),fetchData:async()=>{let $={hostname:IU(),platform:fU(),arch:WU(),release:JU(),cpus:OU().length,totalMemory:FU(),nodeVersion:process.version,bunVersion:process.versions.bun};try{let w=await j(U,`/api/profiles/${R}/agent/version`);return{local:$,agentUrl:U,remote:w}}catch(w){return{local:$,agentUrl:U,remote:null,remoteError:w instanceof Error?K(w):String(w)}}},plain:($)=>{if(X("VibeControls Agent Info"),Q(),z(`${Z.info} Local System`),J("Hostname",$.local.hostname),J("Platform",`${$.local.platform} ${$.local.arch}`),J("OS Release",$.local.release),J("CPUs",String($.local.cpus)),J("Total Memory",N($.local.totalMemory)),J("Node.js",$.local.nodeVersion),$.local.bunVersion)J("Bun",$.local.bunVersion);if(Q(),z(`${Z.info} Remote Agent`),J("URL",$.agentUrl),$.remote){if(J("Version",V.bold($.remote.version)),$.remote.build)J("Build",$.remote.build);if($.remote.commit)J("Commit",$.remote.commit);if($.remote.nodeVersion)J("Node.js (remote)",$.remote.nodeVersion);if($.remote.bunVersion)J("Bun (remote)",$.remote.bunVersion)}else J("Status",V.dim("not reachable"));Q()},interactive:async($)=>{let w=[];if(w.push("Local System"),w.push(` Hostname: ${$.local.hostname}`),w.push(` Platform: ${$.local.platform} ${$.local.arch}`),w.push(` OS Release: ${$.local.release}`),w.push(` CPUs: ${$.local.cpus}`),w.push(` Total Memory: ${N($.local.totalMemory)}`),w.push(` Node.js: ${$.local.nodeVersion}`),$.local.bunVersion)w.push(` Bun: ${$.local.bunVersion}`);if(w.push(""),w.push("Remote Agent"),w.push(` URL: ${$.agentUrl}`),$.remote){if(w.push(` Version: ${$.remote.version}`),$.remote.build)w.push(` Build: ${$.remote.build}`);if($.remote.commit)w.push(` Commit: ${$.remote.commit}`);if($.remote.nodeVersion)w.push(` Node.js: ${$.remote.nodeVersion} (remote)`);if($.remote.bunVersion)w.push(` Bun: ${$.remote.bunVersion} (remote)`)}else w.push(" Status: not reachable");await q({title:"VibeControls Agent Info",body:w.join(`
5
- `),footer:"press q to exit"})},json:($)=>({local:$.local,agentUrl:$.agentUrl,remote:$.remote,remoteError:$.remoteError??null})})}catch(G){Y(`Failed to get info: ${K(G)}`)}})}var QU="http://localhost:3005";function _$(f){f.command("system").description("Show system information for a running VibeControls agent").option("--agent-url <url>","Agent URL",QU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let G={...f.opts(),...W},U=T(G),R=encodeURIComponent(_(G));await x({mode:M(G),fetchData:()=>j(U,`/api/profiles/${R}/agent/system`),plain:($)=>{if(X("Agent System Information"),Q(),z(`${Z.info} Agent`),J("Version",V.bold($.agentVersion)),$.bunVersion)J("Bun",$.bunVersion);if($.environment)J("Environment",$.environment);J("Uptime",s($.uptime)),Q(),z(`${Z.info} Platform`),J("OS",`${$.platform} ${$.arch}`),J("Hostname",$.hostname),J("Release",$.release),Q(),z(`${Z.info} Resources`),J("CPUs",String($.cpus)),J("Total Memory",N($.totalMemory)),J("Free Memory",N($.freeMemory)),Q(),z(`${Z.info} Paths`),J("Home",$.homeDir),J("CWD",$.cwd),Q()},interactive:async($)=>{let w=["Agent",` Version: ${$.agentVersion}`,...$.bunVersion?[` Bun: ${$.bunVersion}`]:[],...$.environment?[` Environment: ${$.environment}`]:[],` Uptime: ${s($.uptime)}`,"","Platform",` OS: ${$.platform} ${$.arch}`,` Hostname: ${$.hostname}`,` Release: ${$.release}`,"","Resources",` CPUs: ${$.cpus}`,` Total Mem: ${N($.totalMemory)}`,` Free Mem: ${N($.freeMemory)}`,"","Paths",` Home: ${$.homeDir}`,` CWD: ${$.cwd}`];await q({title:"Agent System Information",body:w.join(`
6
- `),footer:"press q to exit"})}})}catch(G){Y(`Failed to get system info: ${K(G)}`)}})}var ZU="http://localhost:3005";async function b$(f){try{let W=await fetch(`${f}/health/ready`);if(W.status===200||W.status===503)return await W.json();return{healthy:!1,status:W.status}}catch{return{healthy:!1,error:"unreachable"}}}async function u$(f,W){try{let G=await fetch(`${f}/api/profiles/${W}/agent/api-key`);if(!G.ok)return null;return(await G.json()).apiKey??null}catch{return null}}async function BU(f,W){try{return await j(f,`/api/profiles/${W}/plugins`)}catch{return null}}function o(f){let W=f??{};if(W.error==="unreachable")return V.red("unreachable");if(typeof W.status==="number"&&W.status>=400)return V.red(`http ${W.status}`);let G=typeof W.status==="string"?W.status:"",U=typeof W.bootState==="string"?W.bootState:"";if(G==="ok"&&U==="ready")return V.green("ready");if(U==="awaiting-config")return V.yellow("awaiting-config");if(U==="initializing")return V.yellow("initializing");if(U==="degraded"||G==="degraded")return V.red(`degraded${U?` (${U})`:""}`);if(W.healthy===!1)return V.red("unhealthy");return V.green("healthy")}function zU(f){let G=(f??{}).lastFinalizeError;if(!G||typeof G!=="object")return null;let U=G;if(typeof U.message!=="string"||typeof U.at!=="string")return null;return{message:U.message,at:U.at,attempt:typeof U.attempt==="number"?U.attempt:void 0}}function N$(f){let W=f??{},G=typeof W.bootState==="string"?W.bootState:"";if(G!=="awaiting-config"&&G!=="degraded")return null;let U=[],R=zU(f);if(R)if(U.push(`${V.gray("\xB7")} Last error: ${V.red(R.message)}`),R.attempt!==void 0)U.push(`${V.gray("\xB7")} Background retry: attempt ${R.attempt}`);else U.push(`${V.gray("\xB7")} Last seen: ${R.at}`);if(G==="awaiting-config")U.push(`${V.gray("\xB7")} Force retry now: ${V.bold("vibe retry-config")}`);return U.push(`${V.gray("\xB7")} Full trace: ${V.bold("vibe logs --since 10m")}`),U.join(`
7
- `)}async function YU(f,W){let G={agentUrl:W},U=f.jsonKey??f.title.toLowerCase(),R;try{R=await f.render(G)}catch(w){R=V.red(`error (${w.message})`)}let $=null;if(f.json)try{$=await f.json(G)}catch{$=null}return{title:f.title,jsonKey:U,text:R,json:$}}async function n$(f){let G=h$().getStatusSections();return Promise.all(G.map((U)=>YU(U,f)))}function k$(f){f.command("status").description("Show comprehensive status of VibeControls agent instance(s)").option("-n, --name <name>","Agent instance name").option("--agent-url <url>","Agent URL",ZU).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let G={...f.opts(),...W},U=new g;await x({mode:M(G),fetchData:async()=>{if(G.name){let I=await U.getStatus(G.name);if(!I)return{kind:"instance",agentUrl:T(G),instance:null,contributed:[]};let O=I.status==="running"&&I.port?`http://localhost:${I.port}`:T(G);if(I.status!=="running")return{kind:"instance",agentUrl:O,instance:I,contributed:[]};let B=encodeURIComponent(_({profile:I.name})),[L,C,H,l]=await Promise.all([b$(O),u$(O,B),BU(O,B),n$(O)]);return{kind:"instance",agentUrl:O,instance:I,health:L,apiKey:C,plugins:H,contributed:l}}let R=await U.listInstances(),$=R.filter((I)=>I.status==="running"),w=await Promise.all($.map(async(I)=>{let O=`http://localhost:${I.port}`,B=encodeURIComponent(_({profile:I.name})),[L,C,H]=await Promise.all([b$(O),u$(O,B),n$(O)]);return{name:I.name,agentUrl:O,health:L,apiKey:C,contributed:H}}));return{kind:"overview",instances:R,perRunning:w}},plain:(R)=>{if(R.kind==="instance"){if(!R.instance){Y(`Agent instance ${V.bold(G.name??"")} not found.`);return}let w=R.instance;if(X(`Agent Status: ${w.name}`),J("Name",w.name),J("Status",u(w.status)),J("PID",w.pid?String(w.pid):V.dim("n/a")),J("Port",w.port?String(w.port):V.dim("n/a")),J("Host",w.config?.host||V.dim("n/a")),J("Database",w.config?.dbPath||V.dim("n/a")),w.startTime)J("Started",k(w.startTime));if(w.status==="running"){Q(),J("Health",o(R.health));let I=N$(R.health);if(I)Q(),console.log(I),Q();let O=R.health?.uptime;if(O)J("Uptime",String(O));if(J("API Key",R.apiKey??V.dim("(unavailable)")),R.plugins){let B=R.plugins.plugins??[],L=B.filter((C)=>C.isCore).length;J("Plugins",`${B.length} total (${L} core, ${B.length-L} external)`)}else J("Plugins",V.dim("(unable to fetch)"));for(let B of R.contributed){if(B.text===null)continue;J(B.title,B.text)}}Q();return}if(X("Agent Instances"),Q(),!R.instances||R.instances.length===0){z(`${Z.info} No agent instances found.`),z(`Run ${V.bold("vibe start")} to start an agent.`);return}let $=R.instances.map((w)=>({Name:w.name,Status:u(w.status),PID:w.pid||"-",Port:w.port||"-",Started:w.startTime?k(w.startTime):"-"}));P$($),Q();for(let w of R.perRunning){Q(),X(`Quick Status: ${w.name}`),J("Health",o(w.health));let I=N$(w.health);if(I)Q(),console.log(I),Q();J("API Key",w.apiKey??V.dim("(unavailable)"));for(let O of w.contributed){if(O.text===null)continue;J(O.title,O.text)}}Q(),z(`${Z.info} ${R.instances.length} instance(s) found. Use ${V.bold("vibe status -n <name>")} for full details.`)},interactive:async(R)=>{let $=[];if(R.kind==="instance"){if(!R.instance)$.push(`Agent instance "${G.name??""}" not found.`);else{let w=R.instance;if($.push(`Name: ${w.name}`),$.push(`Status: ${u(w.status)}`),$.push(`PID: ${w.pid??"n/a"}`),$.push(`Port: ${w.port??"n/a"}`),$.push(`Host: ${w.config?.host??"n/a"}`),$.push(`Database: ${w.config?.dbPath??"n/a"}`),w.startTime)$.push(`Started: ${k(w.startTime)}`);if(w.status==="running"){if($.push(""),$.push(`Health: ${o(R.health)}`),$.push(`API Key: ${R.apiKey??"(unavailable)"}`),R.plugins){let I=R.plugins.plugins??[],O=I.filter((B)=>B.isCore).length;$.push(`Plugins: ${I.length} (${O} core, ${I.length-O} external)`)}for(let I of R.contributed){if(I.text===null)continue;$.push(`${I.title.padEnd(9)} ${I.text}`)}}}await q({title:`vibe status${G.name?` \u2014 ${G.name}`:""}`,body:$.join(`
8
- `),footer:"press q to exit"});return}if(!R.instances||R.instances.length===0)$.push("No agent instances found."),$.push("Run `vibe start` to start an agent.");else for(let w of R.instances){$.push(`${V.bold(w.name)} ${u(w.status)}`),$.push(` PID: ${w.pid??"-"}`),$.push(` Port: ${w.port??"-"}`),$.push(` Started: ${w.startTime?k(w.startTime):"-"}`);let I=R.perRunning.find((O)=>O.name===w.name);if(I){$.push(` Health: ${o(I.health)}`);for(let O of I.contributed){if(O.text===null)continue;$.push(` ${O.title.padEnd(9)} ${O.text}`)}}$.push("")}await q({title:`vibe status \u2014 ${R.instances.length} instance(s)`,body:$.join(`
9
- `),footer:"press q to exit"})},json:(R)=>{let $=(w)=>Object.fromEntries(w.map((I)=>[I.jsonKey,I.json]));if(R.kind==="instance"){if(!R.instance)return{instance:null};let w={instance:{name:R.instance.name,status:R.instance.status,pid:R.instance.pid,port:R.instance.port,host:R.instance.config?.host,dbPath:R.instance.config?.dbPath,startTime:R.instance.startTime}};if(R.instance.status==="running")w.health=R.health??null,w.plugins=R.plugins??null,Object.assign(w,$(R.contributed));return w}return{instances:R.instances.map((w)=>({name:w.name,status:w.status,pid:w.pid,port:w.port,startTime:w.startTime})),perRunning:R.perRunning.map((w)=>({name:w.name,health:w.health??null,...$(w.contributed)}))}}})}catch(G){let U=G instanceof Error?K(G):String(G);Y(`Failed to get status: ${U}`)}})}var TU="http://localhost:3005";function S$(f){f.command("url").description("Show the active URL for a running VibeControls agent").option("--agent-url <url>","Agent URL",TU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async(W)=>{try{let G={...f.opts(),...W},U=T(W),R=encodeURIComponent(_(G));await x({mode:M(G),fetchData:()=>j(U,`/api/profiles/${R}/agent/url`),plain:($)=>{if(X("Agent URL"),Q(),J("Active URL",V.bold($.url)),J("Local URL",$.localUrl),$.tunnelUrl)J("Tunnel URL",V.cyan($.tunnelUrl));if(J("Mode",$.isTunnel?`${Z.running} Tunnel active`:`${Z.info} Local only`),Q(),$.isTunnel)z(`${Z.info} Agent is accessible via tunnel at ${V.bold($.tunnelUrl)}`);else z(`${Z.info} Agent is running locally at ${V.bold($.localUrl)}`)},interactive:async($)=>{let w=[` Active URL: ${$.url}`,` Local URL: ${$.localUrl}`,` Tunnel URL: ${$.tunnelUrl??"-"}`,` Mode: ${$.isTunnel?"Tunnel active":"Local only"}`];await q({title:"Agent URL",body:w.join(`
10
- `)})},json:($)=>v($)})}catch(G){Y(`Failed to get URL: ${G.message}`)}})}var E$="http://localhost:3005";function A$(f){let W=f.command("gateway-auth").description("Manage gateway authentication for VibeControls agent");W.command("configure").description("Configure gateway authentication credentials").requiredOption("--global-url <url>","Global gateway URL").requiredOption("--workspace-url <url>","Workspace gateway URL").requiredOption("--client-id <id>","OAuth client ID").requiredOption("--client-secret <secret>","OAuth client secret").option("--workspace-id <id>","Workspace ID for auto-report").option("--agent-record-id <id>","Existing backend agent record ID").option("--agent-url <url>","Agent URL",E$).option("--json","Emit JSON result").action(async(G)=>{try{let U={...f.opts(),...G},R=T(G),$=encodeURIComponent(_(U)),w=await m$(R,`/api/profiles/${$}/agent/gateway-auth`,{globalGatewayUrl:G.globalUrl,workspaceGatewayUrl:G.workspaceUrl,clientId:G.clientId,clientSecret:G.clientSecret,workspaceId:G.workspaceId,agentRecordId:G.agentRecordId});if(y$(U,{ok:!!w.success,message:w.message??null,globalGatewayUrl:G.globalUrl,workspaceGatewayUrl:G.workspaceUrl,clientId:G.clientId,workspaceId:G.workspaceId??null,agentRecordId:G.agentRecordId??null}))return;if(X("Configure Gateway Authentication"),Q(),z(`${Z.info} Sending gateway auth configuration...`),Q(),w.success){if(c(`${Z.success} Gateway authentication configured successfully.`),Q(),J("Global URL",G.globalUrl),J("Workspace URL",G.workspaceUrl),J("Client ID",G.clientId),J("Client Secret",V.dim("********")),G.workspaceId)J("Workspace ID",G.workspaceId);if(G.agentRecordId)J("Agent Record ID",G.agentRecordId)}else Y(w.message||"Failed to configure gateway authentication.");Q()}catch(U){Y(`Failed to configure gateway auth: ${U instanceof Error?K(U):String(U)}`)}}),W.command("status").description("Check gateway authentication status").option("--agent-url <url>","Agent URL",E$).option("--json","Emit JSON").option("--plain","Force plain text output").action(async(G)=>{try{let U={...f.opts(),...G},R=T(G),$=encodeURIComponent(_(U));await x({mode:M(U),fetchData:()=>j(R,`/api/profiles/${$}/agent/gateway-auth`),plain:(w)=>{if(X("Gateway Authentication Status"),Q(),J("Configured",w.configured?`${Z.success} ${V.green("Yes")}`:`${Z.error} ${V.red("No")}`),w.configured){if(J("Global URL",w.config?.globalGatewayUrl||V.dim("n/a")),J("Workspace URL",w.config?.workspaceGatewayUrl||V.dim("n/a")),J("Client ID",w.config?.clientId||V.dim("n/a")),w.config?.workspaceId)J("Workspace ID",w.config.workspaceId)}else Q(),z(`${Z.info} Run ${V.bold("vibe gateway-auth configure")} to set up gateway authentication.`);Q()},interactive:async(w)=>{let I=w.configured?[" Configured: yes",` Global URL: ${w.config?.globalGatewayUrl??"n/a"}`,` Workspace URL: ${w.config?.workspaceGatewayUrl??"n/a"}`,` Client ID: ${w.config?.clientId??"n/a"}`,` Workspace ID: ${w.config?.workspaceId??"-"}`]:[" Configured: no",""," Run `vibe gateway-auth configure` to set up."];await q({title:"Gateway Authentication Status",body:I.join(`
11
- `)})},json:(w)=>v(w)})}catch(U){Y(`Failed to get gateway auth status: ${U instanceof Error?K(U):String(U)}`)}})}function g$(f,W){M$(f),x$(f),c$(f),_$(f),k$(f),S$(f),A$(f)}var o$="agent";function LR(f){let W=null,G=t({name:o$,onShutdown:()=>{l$(),v$()}});return{name:o$,version:"2.3.0",description:"Core agent identity, system info, setup, gateway authentication, and auto-report",capabilities:{storage:"rw",secrets:"rw",gateway:!0,broadcast:!0,audit:!0,telemetry:!0},tags:["backend","cli"],cliCommand:"agent",apiPrefix:"/api/agent",publicPaths:["/identity","/tunnel"],createRoutes:(U)=>{return W=U.db,j$(U)},onCliSetup:async(U,R)=>{g$(U,R)},onServerReady:async(U,R)=>{if(W){let $=U,w=(typeof $.decorator?.apiKey==="string"?$.decorator.apiKey:void 0)??(typeof $.store?.apiKey==="string"?$.store.apiKey:void 0)??"unknown",I=new e(R.logger,"agent-plugin");p$(W,R.serviceRegistry,w).catch((O)=>{I.warn(`Auto-report background task failed: ${O}`)})}},onServerStop:()=>G.onServerStop({})}}export{LR as createPlugin};