@vibecontrols/agent 2026.814.1 → 2026.820.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 (126) hide show
  1. package/dist/agent-config-t242qh84.js +2 -0
  2. package/dist/{agent-ready-tracker-gx1yqwjk.js → agent-ready-tracker-y9wbqt6y.js} +1 -1
  3. package/dist/app-7rmybh7z.js +2 -0
  4. package/dist/autostart.cmd-arjjfy8k.js +2 -0
  5. package/dist/bootstrap-workspace-dvxqq79t.js +2 -0
  6. package/dist/bootstrap.service-3zpbgsg0.js +2 -0
  7. package/dist/{bridge-client-zye1vz1y.js → bridge-client-emc7mttx.js} +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/daemon-profile-nbe3pww8.js +2 -0
  10. package/dist/esm-br6epktf.js +2 -0
  11. package/dist/{finalize-retry-handle-registry-kzfqhvwv.js → finalize-retry-handle-registry-ndbsa6a3.js} +1 -1
  12. package/dist/{finalize-retry-worker-74wxbdsh.js → finalize-retry-worker-mfj115ek.js} +1 -1
  13. package/dist/gateway-client-dnjxwbnj.js +2 -0
  14. package/dist/{getMachineId-bsd-65jabrgp.js → getMachineId-bsd-gvxzt2gm.js} +1 -1
  15. package/dist/{getMachineId-darwin-yykv9khr.js → getMachineId-darwin-g66tx8f2.js} +1 -1
  16. package/dist/{getMachineId-linux-w09acg2n.js → getMachineId-linux-f0mt4jq9.js} +1 -1
  17. package/dist/{getMachineId-unsupported-dwr7bb60.js → getMachineId-unsupported-bsmqnjcv.js} +1 -1
  18. package/dist/{getMachineId-win-0wkw4jek.js → getMachineId-win-172fq57c.js} +1 -1
  19. package/dist/highlights-3g7x1wxx.js +2 -0
  20. package/dist/highlights-66pe672g.js +2 -0
  21. package/dist/highlights-78tmcgkr.js +2 -0
  22. package/dist/highlights-dhv8z6p7.js +2 -0
  23. package/dist/highlights-j95xsvt4.js +2 -0
  24. package/dist/index-014sfc8c.js +2 -0
  25. package/dist/{index-gb5bnx7a.js → index-149rjxa5.js} +1 -1
  26. package/dist/{index-16czz4df.js → index-1hfchgm5.js} +1 -1
  27. package/dist/{index-nj7bvgws.js → index-1xw2wxyf.js} +1 -1
  28. package/dist/{index-5wsfsj88.js → index-2244sbdx.js} +4 -4
  29. package/dist/{index-4gt22c81.js → index-34g3tenj.js} +2 -2
  30. package/dist/{index-1ptfacy9.js → index-426ddch6.js} +1 -1
  31. package/dist/{index-r49hb09r.js → index-4beawmtx.js} +2 -2
  32. package/dist/{index-wndzw5pk.js → index-4f3ac5nf.js} +2 -2
  33. package/dist/{index-e1bw1bwr.js → index-54mmh1eb.js} +1 -1
  34. package/dist/{index-c975k3pk.js → index-6nz3c1ys.js} +3 -3
  35. package/dist/{index-ntj6ymk8.js → index-73qwyf9q.js} +1 -1
  36. package/dist/{index-5s2zc91f.js → index-81gn264d.js} +1 -1
  37. package/dist/{index-13xxbf03.js → index-97r6ekww.js} +2 -2
  38. package/dist/{index-zb7nfmts.js → index-a3mwtteb.js} +2 -2
  39. package/dist/index-a9x5swye.js +11 -0
  40. package/dist/{index-53qthjhb.js → index-at6z8tds.js} +2 -2
  41. package/dist/{index-c4p1qcnn.js → index-axgp7ryd.js} +3 -3
  42. package/dist/{index-5dysvvjv.js → index-bv1z3fxw.js} +1 -1
  43. package/dist/{index-q9dp55wv.js → index-c4zn91z3.js} +1 -1
  44. package/dist/{index-9g3vxhby.js → index-d384edvr.js} +2 -2
  45. package/dist/index-dpyv0pqb.js +26 -0
  46. package/dist/{index-zaw78sxw.js → index-e0jbxcn1.js} +3 -3
  47. package/dist/{index-0ckffygp.js → index-ea42kfvk.js} +1 -1
  48. package/dist/{index-52cp759f.js → index-ekr40gvh.js} +1 -1
  49. package/dist/{index-2gwc485c.js → index-ff8acg43.js} +2 -2
  50. package/dist/{index-jqfsvf8f.js → index-gmwpaz2a.js} +2 -2
  51. package/dist/{index-4wgjx8bf.js → index-hey6w5m0.js} +1 -1
  52. package/dist/{index-b5dhmybd.js → index-hwpmdq5z.js} +1 -1
  53. package/dist/{index-qzhvhyvq.js → index-hym4bq94.js} +1 -1
  54. package/dist/{index-m2kkd6t6.js → index-jnrqbhew.js} +2 -2
  55. package/dist/{index-wd2ak0q4.js → index-jq7vqe4a.js} +1 -1
  56. package/dist/{index-gx53t38f.js → index-m1bteh0j.js} +1 -1
  57. package/dist/{index-2bjqvapr.js → index-najxwhng.js} +1 -1
  58. package/dist/{index-jb3v3b39.js → index-paxfq5k4.js} +1 -1
  59. package/dist/{index-7vwefvxd.js → index-r1v6p7vc.js} +1 -1
  60. package/dist/{index-pc05r6fd.js → index-rhcsaqc0.js} +2 -2
  61. package/dist/{index-rc79x8fw.js → index-rmh8pff5.js} +1 -1
  62. package/dist/{index-8k78bp4w.js → index-sasygg1e.js} +1 -1
  63. package/dist/{index-0s81cfpe.js → index-sj39bx7y.js} +2 -2
  64. package/dist/{index-e2dqz3tw.js → index-svtmb9t1.js} +2 -2
  65. package/dist/{index-g9fthh7a.js → index-tcew34xr.js} +2 -2
  66. package/dist/index-vd3njzs5.js +116 -0
  67. package/dist/index-w893wd2g.js +130 -0
  68. package/dist/{index-8nqp3a4d.js → index-wj5hx7gq.js} +1 -1
  69. package/dist/{index-c0fgge10.js → index-wqwzfy0e.js} +2 -2
  70. package/dist/{index-jrxbbb7p.js → index-xyfcpfec.js} +2 -2
  71. package/dist/{index-zabjc8f2.js → index-ywv7amgf.js} +1 -1
  72. package/dist/index.js +3 -3
  73. package/dist/injections-2pt7wmtk.js +2 -0
  74. package/dist/interactive-svpgqn7v.js +2 -0
  75. package/dist/key.cmd-m0zst9pm.js +2 -0
  76. package/dist/log-shipper-m9h3jxem.js +2 -0
  77. package/dist/{path-utils-cg1gsy4m.js → path-utils-rzsac4g6.js} +1 -1
  78. package/dist/plugin-system-jww7bh2a.js +2 -0
  79. package/dist/prereqs-runner-fhjjgzhw.js +2 -0
  80. package/dist/profile-mount-xchr4y5e.js +2 -0
  81. package/dist/prune-stale-shims-wttq2y0f.js +2 -0
  82. package/dist/register-core-n2kb3mhq.js +2 -0
  83. package/dist/secondary-profile-attach-yzwncw4f.js +2 -0
  84. package/dist/subprocess-chzm6zj2.js +2 -0
  85. package/dist/telemetry-h9pa43c9.js +2 -0
  86. package/dist/tree-sitter-javascript-jre8s337.js +2 -0
  87. package/dist/tree-sitter-markdown-3as64nwe.js +2 -0
  88. package/dist/tree-sitter-markdown_inline-rs74pnzp.js +2 -0
  89. package/dist/tree-sitter-typescript-dgsjhgb0.js +2 -0
  90. package/dist/tree-sitter-zig-p8cc70k0.js +2 -0
  91. package/dist/tunnel-bootstrap-6xm4w7dm.js +2 -0
  92. package/package.json +1 -1
  93. package/dist/agent-config-hzzh97dn.js +0 -2
  94. package/dist/app-k3dex7x4.js +0 -2
  95. package/dist/bootstrap-workspace-dg1e3fp6.js +0 -2
  96. package/dist/bootstrap.service-nbhhd4pa.js +0 -2
  97. package/dist/daemon-profile-ryakpcbx.js +0 -2
  98. package/dist/esm-cg5tnbkd.js +0 -2
  99. package/dist/gateway-client-8y9yd0ch.js +0 -2
  100. package/dist/highlights-5wfvq2xq.js +0 -2
  101. package/dist/highlights-fdyzf5xj.js +0 -2
  102. package/dist/highlights-g5bek66n.js +0 -2
  103. package/dist/highlights-scv26t06.js +0 -2
  104. package/dist/highlights-tx5ed845.js +0 -2
  105. package/dist/index-2jxqpj7r.js +0 -26
  106. package/dist/index-nwh7j7ap.js +0 -2
  107. package/dist/index-sv4rzv3f.js +0 -11
  108. package/dist/index-tcwmw7ed.js +0 -231
  109. package/dist/injections-agpjxatz.js +0 -2
  110. package/dist/interactive-ewe5szk5.js +0 -2
  111. package/dist/key.cmd-xefsd8p4.js +0 -2
  112. package/dist/log-shipper-4h1k4kp6.js +0 -2
  113. package/dist/plugin-system-ksatnqp4.js +0 -2
  114. package/dist/prereqs-runner-6yf1e5e3.js +0 -2
  115. package/dist/profile-mount-13qvjqbg.js +0 -2
  116. package/dist/prune-stale-shims-t6kdd2an.js +0 -2
  117. package/dist/register-core-9k4zxnsg.js +0 -2
  118. package/dist/secondary-profile-attach-42x68g0c.js +0 -2
  119. package/dist/subprocess-6m8bja6s.js +0 -2
  120. package/dist/telemetry-mq37zapd.js +0 -2
  121. package/dist/tree-sitter-javascript-emqv64wx.js +0 -2
  122. package/dist/tree-sitter-markdown-v98rp3y1.js +0 -2
  123. package/dist/tree-sitter-markdown_inline-5gq03gn2.js +0 -2
  124. package/dist/tree-sitter-typescript-gr7ymg9w.js +0 -2
  125. package/dist/tree-sitter-zig-59q80fch.js +0 -2
  126. package/dist/tunnel-bootstrap-50fm2wt8.js +0 -2
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{d as m,e as H2}from"./index-7vwefvxd.js";import{z as c}from"./index-jrxbbb7p.js";import"./index-13xxbf03.js";import"./index-pc05r6fd.js";import"./index-4wgjx8bf.js";import{Ja as Z2,Ka as $2,La as z2,Na as W2,Ta as d}from"./index-5wsfsj88.js";import"./index-0ckffygp.js";import"./index-m2kkd6t6.js";import"./index-9g3vxhby.js";import{Rb as X2,Sb as Y2}from"./index-5dysvvjv.js";import{Ub as J,Vb as V2}from"./index-zaw78sxw.js";import{jc as l,kc as t,lc as R}from"./index-8nqp3a4d.js";import{oc as k,qc as q,rc as O,sc as S,tc as I,uc as _,vc as u,wc as A,yc as i}from"./index-c975k3pk.js";import{Gc as s,Hc as G2}from"./index-0s81cfpe.js";import{Lc as U,Nc as E,Oc as n,Pc as h}from"./index-e2dqz3tw.js";import"./index-sv4rzv3f.js";import{Pd as y}from"./index-c4p1qcnn.js";import"./index-q9dp55wv.js";import"./index-ntj6ymk8.js";import{je as L}from"./index-gb5bnx7a.js";import{timingSafeEqual as j2}from"crypto";function U2(){return(process.env.NPM_CONFIG_REGISTRY||process.env.npm_config_registry||"https://registry.npmjs.org").replace(/\/+$/,"")}async function a(V,B){try{let z=await fetch(`${U2()}/${V}/${B}`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(1e4)});if(z.ok){let Q=(await z.json()).dist?.integrity;if(typeof Q==="string"&&Q.startsWith("sha"))return Q}}catch{}try{let z=Bun.spawn({cmd:["npm","view",`${V}@${B}`,"dist.integrity","--json"],stdout:"pipe",stderr:"pipe"});if(await z.exited!==0)return null;let X=(await new Response(z.stdout).text()).trim();if(!X)return null;if(X.startsWith('"'))try{let $=JSON.parse(X);return typeof $==="string"?$:null}catch{return null}return X}catch{return null}}function e(V,B){let z=Buffer.from(V),K=Buffer.from(B);if(z.length!==K.length)return!1;try{return j2(z,K)}catch{return!1}}var h2=$2.map((V)=>({packageName:V.packageName,name:V.pluginName,description:V.description,cliCommand:V.cliCommand,apiPrefix:V.apiPrefix,installed:!1,category:V.category})),N=new Map;function w(V,B){let K=(N.get(V)??Promise.resolve()).then(B,B),Q=K.then(()=>{return},()=>{return});return N.set(V,Q),Q.finally(()=>{if(N.get(V)===Q)N.delete(V)}),K}function K2(V){return N.has(V)}function Q2(V){let B=V.getPluginDetails(),z=new Set(B.map((K)=>K.packageName));return{plugins:h2.map((K)=>({...K,installed:z.has(K.packageName)}))}}function B2(V){let{pluginManager:B}=V;return new V2().get("/",()=>{let z=B.getPluginDetails();return{plugins:z,count:z.length}}).get("/available",()=>Q2(B)).get("/catalog",()=>Q2(B)).get("/contributions",({query:z})=>{let K=typeof z?.mountPoint==="string"&&z.mountPoint?z.mountPoint:null,Q=[],X=new Map;for(let $ of B.getPluginDetails())X.set($.pluginName,$.packageName);for(let $ of B.getAllPlugins()){let x=$.ui;if(!x||!x.contributions||x.contributions.length===0)continue;let Y=x.capabilities??{restPaths:[],wsTopics:[],rpcMethods:[]};for(let W of x.contributions){if(K&&W.mountPoint!==K)continue;let Z=W.meta,H=Z&&typeof Z.url==="string"?Z.url:null,F=H&&H.startsWith("/")&&!H.startsWith("//")&&!H.includes("\x00")&&!H.includes("..")?H:null;Q.push({pluginKey:$.name,pluginPackageName:X.get($.name),contribution:W,capabilities:W.capabilities??Y,url:F??`/ui/${encodeURIComponent($.name)}`})}}return{contributions:Q,count:Q.length}}).post("/install",async({body:z,set:K})=>{if(!z.packageName||typeof z.packageName!=="string")return K.status=400,{error:"Missing required field: packageName"};if(z.packageName.startsWith("@burdenoff/"))z.packageName=z.packageName.replace(/^@burdenoff\//,"@vibecontrols/");if(!W2(z.packageName))return K.status=403,{error:"Plugin package is not in the trusted VibeControls catalog"};try{let Q=d(z.packageName);if(K2(Q)){let X=Q.split("/").pop()?.replace("vibe-plugin-","");if(B.getAllPlugins().some((x)=>x.name===X))return{success:!0,message:`Plugin ${Q} is already installed`,packageName:Q,alreadyInstalled:!0};return K.status=409,{error:"Install for this package is already in progress. Wait for it to finish.",packageName:Q}}return await w(Q,async()=>{let X=Q.split("/").pop()?.replace("vibe-plugin-",""),$=X?.startsWith("ai-")?X.slice(3):void 0,x=B.getAllPlugins().find((C)=>C.name===X||C.name===$),Y=!!x,W=await B.install(Q),Z=z2(Q);if(Z?.integrity){let C=await a(Q,W.version);if(C&&!e(Z.integrity,C)){try{await B.remove(Q,V.hostServices)}catch(G){console.warn(`[plugin-mgr] integrity rollback uninstall failed for ${Q}:`,G)}return y().audit.emit("agent","plugin.install.rejected",{packageName:Q,version:W.version,reason:"integrity_mismatch",expected:Z.integrity,actual:C}),K.status=400,{error:"integrity mismatch",expected:Z.integrity,actual:C}}if(!C)console.warn(`[plugin-mgr] could not fetch registry integrity for ${Q}@${W.version}; accepting the package-manager-verified tarball (pin present but unverifiable)`),y().audit.emit("agent","plugin.install.integrity_unverified",{packageName:Q,version:W.version,expected:Z.integrity})}else console.warn(`[plugin-mgr] plugin ${Q} has no pinned integrity \u2014 accepting npm registry's hash`);let H=B.getAllPlugins().find((C)=>C.name===W.pluginName);if(H){let C=[];if(V.mountPlugin)V.mountPlugin(H);if(V.hostServices){if(Y&&x?.onServerStop)try{await x.onServerStop()}catch(G){C.push(`onServerStop failed: ${G instanceof Error?G.message:String(G)}`)}if(B.registerProviders(H,V.hostServices),H.onServerStart&&V.app)try{await H.onServerStart(V.app,V.hostServices),B.registerProviders(H,V.hostServices)}catch(G){C.push(`onServerStart failed: ${G instanceof Error?G.message:String(G)}`)}if(H.onServerReady&&V.app)try{await H.onServerReady(V.app,V.hostServices)}catch(G){C.push(`onServerReady failed: ${G instanceof Error?G.message:String(G)}`)}}if(V.rebuildPluginSurfaces?.(),C.length>0)return K.status=500,{success:!1,message:`Plugin ${Q} installed but failed to start`,lifecycleErrors:C,restartRequired:!0}}let F;if(H&&V.app)try{F=await m(H,Q,V.app,V.db,{skipInstall:!!z.skipPrereqs})}catch(C){F=void 0,console.warn(`[plugin-mgr] prereq run failed for ${Q}:`,C)}return c(V.db),y().audit.emit("agent","plugin.installed",{packageName:Q,version:W.version,pluginName:W.pluginName,wasRunning:Y}),{success:!0,message:`Plugin ${Q} installed and loaded successfully`,prereqs:F?{satisfied:F.satisfied,missing:F.status?.missing??[],pendingSudo:F.pendingSudo,skipped:!!z.skipPrereqs}:void 0}})}catch(Q){return K.status=500,{error:"Failed to install plugin",details:String(Q)}}},{body:J.Object({packageName:J.String(),skipPrereqs:J.Optional(J.Boolean())})}).post("/prereqs/status",async({body:z,set:K})=>{if(!z.packageName)return K.status=400,{error:"Missing packageName"};let Q=z.packageName,X=B.getAllPlugins().find(($)=>$.name===Q||B.getLoaded(Q)?.name===$.name);if(!X||!V.app)return await H2(V.db,Q)??{satisfied:!0,missing:[]};try{let $=await m(X,Q,V.app,V.db,{skipInstall:!0});return{satisfied:$.satisfied,missing:$.status?.missing??[],noProtocol:$.noProtocol}}catch($){return K.status=500,{error:String($)}}},{body:J.Object({packageName:J.String()})}).post("/prereqs/install",async({body:z,set:K})=>{if(!z.packageName)return K.status=400,{error:"Missing packageName"};let Q=z.packageName,X=B.getAllPlugins().find(($)=>$.name===Q||B.getLoaded(Q)?.name===$.name);if(!X||!V.app)return K.status=404,{error:"Plugin not loaded"};try{let $=await m(X,Q,V.app,V.db,{skipInstall:!1});return{satisfied:$.satisfied,installed:$.install?.installed??[],pendingSudo:$.pendingSudo,errors:$.install?.errors??[],noProtocol:$.noProtocol}}catch($){return K.status=500,{error:String($)}}},{body:J.Object({packageName:J.String(),approveSudo:J.Optional(J.Boolean())})}).post("/prereqs/uninstall",async({body:z,set:K})=>{if(!z.packageName)return K.status=400,{error:"Missing packageName"};let Q=z.packageName,X=B.getAllPlugins().find((W)=>W.name===Q);if(!X||!X.apiPrefix||!V.app)return K.status=404,{error:"Plugin not loaded"};let $=V.app.handle;if(typeof $!=="function")return K.status=500,{error:"App handle unavailable"};let x=`${X.apiPrefix.replace(/\/+$/,"")}/prereqs/uninstall`,Y=await $.call(V.app,new Request(`http://agent.local${x}`,{method:"POST",headers:{"x-vc-profile-rewrite":"1",[X2]:Y2()}}));if(Y.status===404)return K.status=404,{error:"Plugin has no prereqs/uninstall endpoint"};return Y.json()},{body:J.Object({packageName:J.String()})}).post("/nuke",async({body:z,set:K})=>{if(!V.hostServices)return K.status=503,{error:"hostServices unavailable"};let Q=V.hostServices.getDataDir?.();return{ok:!0,...await B.runPluginNuke(z.packageName,V.hostServices,{agentDir:Q,dryRun:!!z.dryRun})}},{body:J.Object({packageName:J.Optional(J.String()),dryRun:J.Optional(J.Boolean())})}).post("/remove",async({body:z,set:K})=>{if(!z.packageName||typeof z.packageName!=="string")return K.status=400,{error:"Missing required field: packageName"};if(z.packageName.startsWith("@burdenoff/"))z.packageName=z.packageName.replace(/^@burdenoff\//,"@vibecontrols/");if(Z2(z.packageName))return{success:!0,message:`Plugin ${z.packageName} is critical and cannot be removed; treating remove as a no-op.`,skipped:!0};try{let Q=d(z.packageName);return await w(Q,async()=>{return await B.remove(Q,V.hostServices),V.rebuildPluginSurfaces?.(),c(V.db),y().audit.emit("agent","plugin.removed",{packageName:Q}),{success:!0,message:`Plugin ${Q} removed successfully`}})}catch(Q){return K.status=500,{error:"Failed to remove plugin",details:String(Q)}}},{body:J.Object({packageName:J.String()})}).post("/update",async({body:z,set:K})=>{if(!z.packageName||typeof z.packageName!=="string")return K.status=400,{error:"Missing required field: packageName"};let Q=typeof z.version==="string"&&z.version.trim()?z.version.trim():void 0;if(Q&&!/^[0-9][0-9A-Za-z.+-]{0,63}$/.test(Q))return K.status=400,{error:`Invalid version "${Q}"`};try{let X=d(z.packageName);return await w(X,async()=>{let $=B.getLoaded(X);if($?.onServerStop)await $.onServerStop({reason:"reload"});if($&&V.hostServices)V.hostServices.serviceRegistry.unregisterPlugin($.name);let x=await B.update(X,Q),Y=B.getLoaded(X);if(Y&&V.hostServices){if(B.registerProviders(Y,V.hostServices),Y.onServerStart&&V.app)await Y.onServerStart(V.app,V.hostServices),B.registerProviders(Y,V.hostServices);if(Y.onServerReady&&V.app)await Y.onServerReady(V.app,V.hostServices)}return V.rebuildPluginSurfaces?.(),c(V.db),{success:!0,message:`Plugin ${X} updated to v${x.version}`,version:x.version}})}catch(X){return K.status=500,{error:"Failed to update plugin",details:String(X)}}},{body:J.Object({packageName:J.String(),version:J.Optional(J.String())})}).post("/update-all",async({set:z})=>{try{let K=await w("*",()=>B.updateAll());return{success:!0,results:K,message:`Updated ${K.filter((Q)=>Q.success).length}/${K.length} plugin(s)`}}catch(K){return z.status=500,{error:"Failed to update all plugins",details:String(K)}}}).post("/remove-all",async({set:z})=>{try{let K=await w("*",async()=>{let Q=await B.removeAll(V.hostServices);return V.rebuildPluginSurfaces?.(),Q});return{success:!0,results:K,message:`Removed ${K.filter((Q)=>Q.success).length}/${K.length} plugin(s)`}}catch(K){return z.status=500,{error:"Failed to remove all plugins",details:String(K)}}}).post("/reload",async({set:z})=>{try{if(!V.app||!V.hostServices)return z.status=503,{error:"Plugin lifecycle services are not ready"};let K=await w("*",async()=>{return await B.reloadAll(V.app,V.hostServices),V.rebuildPluginSurfaces?.(),B.getPluginDetails()});return{success:!0,plugins:K,message:`Reloaded ${K.length} plugin(s)`}}catch(K){return z.status=500,{error:"Failed to reload plugins",details:String(K)}}}).post("/:name/reload",async({params:z,set:K})=>{if(!V.app||!V.hostServices)return K.status=503,{error:"Plugin lifecycle services are not ready"};let Q=z.name,X=B.getAllPlugins().find((Y)=>Y.name===Q);if(!X)return K.status=404,{error:`Plugin "${Q}" not found`};let x=B.getPluginDetails().find((Y)=>Y.pluginName===Q)?.packageName??`core:${Q}`;if(K2(x))return K.status=409,{error:"Plugin lifecycle in progress; try again shortly",packageName:x};try{return await w(x,async()=>{if(X.onServerStop)try{await X.onServerStop({reason:"reload"})}catch(Y){console.warn(`[plugin-mgr] onServerStop during reload of ${Q}:`,Y)}if(V.hostServices)V.hostServices.serviceRegistry.unregisterPlugin(X.name);if(B.registerProviders(X,V.hostServices),X.onServerStart)await X.onServerStart(V.app,V.hostServices),B.registerProviders(X,V.hostServices);if(X.onServerReady)await X.onServerReady(V.app,V.hostServices);return V.rebuildPluginSurfaces?.(),{success:!0,message:`Plugin ${Q} reloaded`,version:X.version}})}catch(Y){return K.status=500,{error:"Failed to reload plugin",details:String(Y)}}},{params:J.Object({name:J.String()})})}import{mkdirSync as o,writeFileSync as v,existsSync as x2}from"fs";import{isAbsolute as D2,join as T,relative as A2,resolve as g}from"path";var D="http://localhost:3005",v2=/^[a-z0-9][a-z0-9-]{0,63}$/,E2=new Set(["backend","frontend","cli","provider","adapter","integration"]);function C2(V,B){let z=A2(V,B);if(z.startsWith("..")||D2(z))throw Error("Plugin scaffold path escapes the selected directory.")}function M(V){return JSON.stringify(V)}function J2(V){let B=V.command("plugin").description("Manage plugins");B.command("list").description("List installed plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(K)=>{try{let Q={...V.opts(),...K},X=U(K),$=encodeURIComponent(E(Q)),x=async()=>{try{return(await n(X,`/api/profiles/${$}/plugins`)).plugins||[]}catch{I("Agent not reachable. Attempting local plugin registry...");let{PluginManager:Z}=await import("./plugin-system-ksatnqp4.js");return new Z().getPluginDetails()||[]}},Y=(Z)=>Z.status??(Z.loaded===!0||Z.enabled===!0?"enabled":"disabled"),W=(Z)=>Z.pluginName||Z.name||Z.packageName||Z.package||"-";await t({mode:l(Q),fetchData:x,plain:(Z)=>{if(!Z.length){_("No plugins installed.");return}u("Installed Plugins"),i(Z.map((H)=>({Name:W(H),Version:H.version||"-",Status:Y(H),Description:H.description||"-"})))},interactive:async(Z)=>{if(!Z.length){u("Installed Plugins"),_("No plugins installed.");return}let H=Z.map((F)=>{let C=W(F),G=Y(F),b=[`${k.bold(C)} ${G==="enabled"?k.green(G):k.dim(G)}`,"",` Version: ${F.version||"-"}`,` Description: ${F.description||"-"}`];if(F.tags&&Array.isArray(F.tags))b.push(` Tags: ${F.tags.join(", ")}`);if(F.cliCommand)b.push(` CLI command: vibe ${F.cliCommand}`);return{id:C,label:C,hint:G,detail:b.join(`
3
- `)}});await s({title:`vibe plugin \u2014 ${Z.length} installed`,rows:H,footer:"\u2191/\u2193 navigate \xB7 q to quit"})},json:(Z)=>Z.map((H)=>({name:W(H),version:H.version??null,status:Y(H),description:H.description??null,tags:H.tags??null,cliCommand:H.cliCommand??null}))})}catch(Q){q(O(Q))}}),B.command("install").description("Install a plugin").argument("<package>","NPM package name to install").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--skip-prereqs","Skip running the plugin's prereqs/install",!1).option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));try{let Y=await h($,`/api/profiles/${x}/plugins/install`,{packageName:K,skipPrereqs:!!Q.skipPrereqs});if(R(X,{ok:!0,action:"install",package:K,version:Y?.version??null,prereqs:Y?.prereqs??null}))return;if(S(`Plugin "${K}" installed.`),Y?.version)A("Version",Y.version);if(Y?.prereqs){let W=Y.prereqs;if(W.skipped)I(`Prerequisite install skipped. Run \`vibe plugin prereqs ${K} install\` later.`);else if(!W.satisfied)I(`Prerequisites not yet satisfied: ${(W.missing||[]).map((Z)=>Z.name).join(", ")||"(unknown)"}`);if((W.pendingSudo||[]).length>0){I(`${W.pendingSudo.length} command(s) need sudo. Run them and re-check with \`vibe plugin prereqs ${K} status\`:`);for(let Z of W.pendingSudo)A(` ${Z.name}`,Z.command)}}}catch{I("Agent not reachable. Attempting local install...");try{let{PluginManager:Y}=await import("./plugin-system-ksatnqp4.js");if(await new Y().install(K),R(X,{ok:!0,action:"install",package:K,local:!0}))return;S(`Plugin "${K}" installed locally.`)}catch(Y){q(`Could not install plugin via agent or locally: ${O(Y)}`)}}}catch(X){q(O(X))}}),B.command("remove").description("Remove a plugin").argument("<package>","NPM package name to remove").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));try{if(await h($,`/api/profiles/${x}/plugins/remove`,{packageName:K}),R(X,{ok:!0,action:"remove",package:K}))return;S(`Plugin "${K}" removed.`)}catch{I("Agent not reachable. Attempting local removal...");try{let{PluginManager:Y}=await import("./plugin-system-ksatnqp4.js");if(await new Y().remove(K),R(X,{ok:!0,action:"remove",package:K,local:!0}))return;S(`Plugin "${K}" removed locally.`)}catch(Y){q(`Could not remove plugin via agent or locally: ${O(Y)}`)}}}catch(X){q(O(X))}}),B.command("update").description("Update a plugin (or all plugins with --all)").argument("[package]","NPM package name to update").option("--all","Update all installed plugins",!1).option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));if(Q.all){_("Updating all plugins...");try{let Y=await h($,`/api/profiles/${x}/plugins/update-all`,{}),W=Y?.results||[];if(R(X,{ok:!0,action:"update-all",results:W}))return;for(let Z of W)if(Z.success)S(`Updated ${Z.packageName}${Z.version?` to v${Z.version}`:""}`);else I(`Failed to update ${Z.packageName}: ${Z.error}`);S(Y?.message||"Done.")}catch{I("Agent not reachable. Attempting local update...");try{let{PluginManager:Y}=await import("./plugin-system-ksatnqp4.js"),Z=await new Y().updateAll();if(R(X,{ok:!0,action:"update-all",results:Z,local:!0}))return;for(let H of Z)if(H.success)S(`Updated ${H.packageName}${H.version?` to v${H.version}`:""}`);else I(`Failed to update ${H.packageName}: ${H.error}`)}catch(Y){q(`Could not update plugins: ${O(Y)}`)}}}else if(K){_(`Updating ${K}...`);try{let Y=await h($,`/api/profiles/${x}/plugins/update`,{packageName:K});if(R(X,{ok:!0,action:"update",package:K,version:Y?.version??null,message:Y?.message??null}))return;S(Y?.message||`Plugin "${K}" updated.`)}catch{I("Agent not reachable. Attempting local update...");try{let{PluginManager:Y}=await import("./plugin-system-ksatnqp4.js"),Z=await new Y().update(K);if(R(X,{ok:!0,action:"update",package:K,version:Z.version,local:!0}))return;S(`Plugin "${K}" updated to v${Z.version}.`)}catch(Y){q(`Could not update plugin: ${O(Y)}`)}}}else q("Provide a package name to update, or use --all to update all plugins.")}catch(X){q(O(X))}}),B.command("uninstall").description("Uninstall a plugin (or all plugins with --all)").argument("[package]","NPM package name to uninstall").option("--all","Uninstall all external plugins",!1).option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));if(Q.all){_("Uninstalling all plugins...");try{let Y=await h($,`/api/profiles/${x}/plugins/remove-all`,{}),W=Y?.results||[];if(R(X,{ok:!0,action:"uninstall-all",results:W}))return;for(let Z of W)if(Z.success)S(`Removed ${Z.packageName}`);else I(`Failed to remove ${Z.packageName}: ${Z.error}`);S(Y?.message||"Done.")}catch{I("Agent not reachable. Attempting local removal...");try{let{PluginManager:Y}=await import("./plugin-system-ksatnqp4.js"),Z=await new Y().removeAll();if(R(X,{ok:!0,action:"uninstall-all",results:Z,local:!0}))return;for(let H of Z)if(H.success)S(`Removed ${H.packageName}`);else I(`Failed to remove ${H.packageName}: ${H.error}`)}catch(Y){q(`Could not uninstall plugins: ${O(Y)}`)}}}else if(K)try{if(await h($,`/api/profiles/${x}/plugins/remove`,{packageName:K}),R(X,{ok:!0,action:"uninstall",package:K}))return;S(`Plugin "${K}" uninstalled.`)}catch{I("Agent not reachable. Attempting local removal...");try{let{PluginManager:Y}=await import("./plugin-system-ksatnqp4.js");if(await new Y().remove(K),R(X,{ok:!0,action:"uninstall",package:K,local:!0}))return;S(`Plugin "${K}" uninstalled locally.`)}catch(Y){q(`Could not uninstall plugin: ${O(Y)}`)}}else q("Provide a package name to uninstall, or use --all to uninstall all plugins.")}catch(X){q(O(X))}}),B.command("reload").description("Reload all plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K)=>{try{let Q={...V.opts(),...K},X=U(K),$=encodeURIComponent(E(Q));if(await h(X,`/api/profiles/${$}/plugins/reload`,{}),R(Q,{ok:!0,action:"reload"}))return;S("Plugins reloaded.")}catch(Q){q(O(Q))}}),B.command("available").description("Show available plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(K)=>{try{let Q={...V.opts(),...K},X=U(K),$=encodeURIComponent(E(Q)),x=async()=>{return(await n(X,`/api/profiles/${$}/plugins/available`)).plugins||[]},Y=(Z)=>Z.name||Z.package||"-",W=(Z)=>Z.version||Z.latestVersion||"-";await t({mode:l(Q),fetchData:x,plain:(Z)=>{if(!Z||Z.length===0){_("No available plugins found.");return}u("Available Plugins"),i(Z.map((H)=>({Name:Y(H),Version:W(H),Description:H.description||"-"})))},interactive:async(Z)=>{if(!Z||Z.length===0){u("Available Plugins"),_("No available plugins found.");return}let H=Z.map((F)=>{let C=Y(F),G=[k.bold(C),"",` Version: ${W(F)}`,` Description: ${F.description||"-"}`];return{id:C,label:C,hint:W(F),detail:G.join(`
2
+ import{d as m,e as H2}from"./index-r1v6p7vc.js";import{z as c}from"./index-xyfcpfec.js";import"./index-97r6ekww.js";import"./index-rhcsaqc0.js";import"./index-hey6w5m0.js";import{Na as Z2,Oa as $2,Pa as z2,Ra as W2,Xa as d}from"./index-2244sbdx.js";import"./index-ea42kfvk.js";import"./index-jnrqbhew.js";import"./index-d384edvr.js";import{Vb as X2,Wb as Y2}from"./index-bv1z3fxw.js";import{Yb as J,Zb as V2}from"./index-e0jbxcn1.js";import{nc as l,oc as t,pc as R}from"./index-wj5hx7gq.js";import{Ac as A,Cc as i,sc as k,uc as q,vc as O,wc as S,xc as I,yc as _,zc as u}from"./index-6nz3c1ys.js";import{Kc as s,Lc as G2}from"./index-sj39bx7y.js";import{Pc as U,Rc as E,Sc as n,Tc as h}from"./index-svtmb9t1.js";import"./index-a9x5swye.js";import{Wd as y}from"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import{qe as L}from"./index-149rjxa5.js";import{timingSafeEqual as j2}from"crypto";function U2(){return(process.env.NPM_CONFIG_REGISTRY||process.env.npm_config_registry||"https://registry.npmjs.org").replace(/\/+$/,"")}async function a(V,B){try{let z=await fetch(`${U2()}/${V}/${B}`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(1e4)});if(z.ok){let Q=(await z.json()).dist?.integrity;if(typeof Q==="string"&&Q.startsWith("sha"))return Q}}catch{}try{let z=Bun.spawn({cmd:["npm","view",`${V}@${B}`,"dist.integrity","--json"],stdout:"pipe",stderr:"pipe"});if(await z.exited!==0)return null;let X=(await new Response(z.stdout).text()).trim();if(!X)return null;if(X.startsWith('"'))try{let $=JSON.parse(X);return typeof $==="string"?$:null}catch{return null}return X}catch{return null}}function e(V,B){let z=Buffer.from(V),K=Buffer.from(B);if(z.length!==K.length)return!1;try{return j2(z,K)}catch{return!1}}var h2=$2.map((V)=>({packageName:V.packageName,name:V.pluginName,description:V.description,cliCommand:V.cliCommand,apiPrefix:V.apiPrefix,installed:!1,category:V.category})),N=new Map;function w(V,B){let K=(N.get(V)??Promise.resolve()).then(B,B),Q=K.then(()=>{return},()=>{return});return N.set(V,Q),Q.finally(()=>{if(N.get(V)===Q)N.delete(V)}),K}function K2(V){return N.has(V)}function Q2(V){let B=V.getPluginDetails(),z=new Set(B.map((K)=>K.packageName));return{plugins:h2.map((K)=>({...K,installed:z.has(K.packageName)}))}}function B2(V){let{pluginManager:B}=V;return new V2().get("/",()=>{let z=B.getPluginDetails();return{plugins:z,count:z.length}}).get("/available",()=>Q2(B)).get("/catalog",()=>Q2(B)).get("/contributions",({query:z})=>{let K=typeof z?.mountPoint==="string"&&z.mountPoint?z.mountPoint:null,Q=[],X=new Map;for(let $ of B.getPluginDetails())X.set($.pluginName,$.packageName);for(let $ of B.getAllPlugins()){let x=$.ui;if(!x||!x.contributions||x.contributions.length===0)continue;let Y=x.capabilities??{restPaths:[],wsTopics:[],rpcMethods:[]};for(let W of x.contributions){if(K&&W.mountPoint!==K)continue;let Z=W.meta,H=Z&&typeof Z.url==="string"?Z.url:null,F=H&&H.startsWith("/")&&!H.startsWith("//")&&!H.includes("\x00")&&!H.includes("..")?H:null;Q.push({pluginKey:$.name,pluginPackageName:X.get($.name),contribution:W,capabilities:W.capabilities??Y,url:F??`/ui/${encodeURIComponent($.name)}`})}}return{contributions:Q,count:Q.length}}).post("/install",async({body:z,set:K})=>{if(!z.packageName||typeof z.packageName!=="string")return K.status=400,{error:"Missing required field: packageName"};if(z.packageName.startsWith("@burdenoff/"))z.packageName=z.packageName.replace(/^@burdenoff\//,"@vibecontrols/");if(!W2(z.packageName))return K.status=403,{error:"Plugin package is not in the trusted VibeControls catalog"};try{let Q=d(z.packageName);if(K2(Q)){let X=Q.split("/").pop()?.replace("vibe-plugin-","");if(B.getAllPlugins().some((x)=>x.name===X))return{success:!0,message:`Plugin ${Q} is already installed`,packageName:Q,alreadyInstalled:!0};return K.status=409,{error:"Install for this package is already in progress. Wait for it to finish.",packageName:Q}}return await w(Q,async()=>{let X=Q.split("/").pop()?.replace("vibe-plugin-",""),$=X?.startsWith("ai-")?X.slice(3):void 0,x=B.getAllPlugins().find((C)=>C.name===X||C.name===$),Y=!!x,W=await B.install(Q),Z=z2(Q);if(Z?.integrity){let C=await a(Q,W.version);if(C&&!e(Z.integrity,C)){try{await B.remove(Q,V.hostServices)}catch(G){console.warn(`[plugin-mgr] integrity rollback uninstall failed for ${Q}:`,G)}return y().audit.emit("agent","plugin.install.rejected",{packageName:Q,version:W.version,reason:"integrity_mismatch",expected:Z.integrity,actual:C}),K.status=400,{error:"integrity mismatch",expected:Z.integrity,actual:C}}if(!C)console.warn(`[plugin-mgr] could not fetch registry integrity for ${Q}@${W.version}; accepting the package-manager-verified tarball (pin present but unverifiable)`),y().audit.emit("agent","plugin.install.integrity_unverified",{packageName:Q,version:W.version,expected:Z.integrity})}else console.warn(`[plugin-mgr] plugin ${Q} has no pinned integrity \u2014 accepting npm registry's hash`);let H=B.getAllPlugins().find((C)=>C.name===W.pluginName);if(H){let C=[];if(V.mountPlugin)V.mountPlugin(H);if(V.hostServices){if(Y&&x?.onServerStop)try{await x.onServerStop()}catch(G){C.push(`onServerStop failed: ${G instanceof Error?G.message:String(G)}`)}if(B.registerProviders(H,V.hostServices),H.onServerStart&&V.app)try{await H.onServerStart(V.app,V.hostServices),B.registerProviders(H,V.hostServices)}catch(G){C.push(`onServerStart failed: ${G instanceof Error?G.message:String(G)}`)}if(H.onServerReady&&V.app)try{await H.onServerReady(V.app,V.hostServices)}catch(G){C.push(`onServerReady failed: ${G instanceof Error?G.message:String(G)}`)}}if(V.rebuildPluginSurfaces?.(),C.length>0)return K.status=500,{success:!1,message:`Plugin ${Q} installed but failed to start`,lifecycleErrors:C,restartRequired:!0}}let F;if(H&&V.app)try{F=await m(H,Q,V.app,V.db,{skipInstall:!!z.skipPrereqs})}catch(C){F=void 0,console.warn(`[plugin-mgr] prereq run failed for ${Q}:`,C)}return c(V.db),y().audit.emit("agent","plugin.installed",{packageName:Q,version:W.version,pluginName:W.pluginName,wasRunning:Y}),{success:!0,message:`Plugin ${Q} installed and loaded successfully`,prereqs:F?{satisfied:F.satisfied,missing:F.status?.missing??[],pendingSudo:F.pendingSudo,skipped:!!z.skipPrereqs}:void 0}})}catch(Q){return K.status=500,{error:"Failed to install plugin",details:String(Q)}}},{body:J.Object({packageName:J.String(),skipPrereqs:J.Optional(J.Boolean())})}).post("/prereqs/status",async({body:z,set:K})=>{if(!z.packageName)return K.status=400,{error:"Missing packageName"};let Q=z.packageName,X=B.getAllPlugins().find(($)=>$.name===Q||B.getLoaded(Q)?.name===$.name);if(!X||!V.app)return await H2(V.db,Q)??{satisfied:!0,missing:[]};try{let $=await m(X,Q,V.app,V.db,{skipInstall:!0});return{satisfied:$.satisfied,missing:$.status?.missing??[],noProtocol:$.noProtocol}}catch($){return K.status=500,{error:String($)}}},{body:J.Object({packageName:J.String()})}).post("/prereqs/install",async({body:z,set:K})=>{if(!z.packageName)return K.status=400,{error:"Missing packageName"};let Q=z.packageName,X=B.getAllPlugins().find(($)=>$.name===Q||B.getLoaded(Q)?.name===$.name);if(!X||!V.app)return K.status=404,{error:"Plugin not loaded"};try{let $=await m(X,Q,V.app,V.db,{skipInstall:!1});return{satisfied:$.satisfied,installed:$.install?.installed??[],pendingSudo:$.pendingSudo,errors:$.install?.errors??[],noProtocol:$.noProtocol}}catch($){return K.status=500,{error:String($)}}},{body:J.Object({packageName:J.String(),approveSudo:J.Optional(J.Boolean())})}).post("/prereqs/uninstall",async({body:z,set:K})=>{if(!z.packageName)return K.status=400,{error:"Missing packageName"};let Q=z.packageName,X=B.getAllPlugins().find((W)=>W.name===Q);if(!X||!X.apiPrefix||!V.app)return K.status=404,{error:"Plugin not loaded"};let $=V.app.handle;if(typeof $!=="function")return K.status=500,{error:"App handle unavailable"};let x=`${X.apiPrefix.replace(/\/+$/,"")}/prereqs/uninstall`,Y=await $.call(V.app,new Request(`http://agent.local${x}`,{method:"POST",headers:{"x-vc-profile-rewrite":"1",[X2]:Y2()}}));if(Y.status===404)return K.status=404,{error:"Plugin has no prereqs/uninstall endpoint"};return Y.json()},{body:J.Object({packageName:J.String()})}).post("/nuke",async({body:z,set:K})=>{if(!V.hostServices)return K.status=503,{error:"hostServices unavailable"};let Q=V.hostServices.getDataDir?.();return{ok:!0,...await B.runPluginNuke(z.packageName,V.hostServices,{agentDir:Q,dryRun:!!z.dryRun})}},{body:J.Object({packageName:J.Optional(J.String()),dryRun:J.Optional(J.Boolean())})}).post("/remove",async({body:z,set:K})=>{if(!z.packageName||typeof z.packageName!=="string")return K.status=400,{error:"Missing required field: packageName"};if(z.packageName.startsWith("@burdenoff/"))z.packageName=z.packageName.replace(/^@burdenoff\//,"@vibecontrols/");if(Z2(z.packageName))return{success:!0,message:`Plugin ${z.packageName} is critical and cannot be removed; treating remove as a no-op.`,skipped:!0};try{let Q=d(z.packageName);return await w(Q,async()=>{return await B.remove(Q,V.hostServices),V.rebuildPluginSurfaces?.(),c(V.db),y().audit.emit("agent","plugin.removed",{packageName:Q}),{success:!0,message:`Plugin ${Q} removed successfully`}})}catch(Q){return K.status=500,{error:"Failed to remove plugin",details:String(Q)}}},{body:J.Object({packageName:J.String()})}).post("/update",async({body:z,set:K})=>{if(!z.packageName||typeof z.packageName!=="string")return K.status=400,{error:"Missing required field: packageName"};let Q=typeof z.version==="string"&&z.version.trim()?z.version.trim():void 0;if(Q&&!/^[0-9][0-9A-Za-z.+-]{0,63}$/.test(Q))return K.status=400,{error:`Invalid version "${Q}"`};try{let X=d(z.packageName);return await w(X,async()=>{let $=B.getLoaded(X);if($?.onServerStop)await $.onServerStop({reason:"reload"});if($&&V.hostServices)V.hostServices.serviceRegistry.unregisterPlugin($.name);let x=await B.update(X,Q),Y=B.getLoaded(X);if(Y&&V.hostServices){if(B.registerProviders(Y,V.hostServices),Y.onServerStart&&V.app)await Y.onServerStart(V.app,V.hostServices),B.registerProviders(Y,V.hostServices);if(Y.onServerReady&&V.app)await Y.onServerReady(V.app,V.hostServices)}return V.rebuildPluginSurfaces?.(),c(V.db),{success:!0,message:`Plugin ${X} updated to v${x.version}`,version:x.version}})}catch(X){return K.status=500,{error:"Failed to update plugin",details:String(X)}}},{body:J.Object({packageName:J.String(),version:J.Optional(J.String())})}).post("/update-all",async({set:z})=>{try{let K=await w("*",()=>B.updateAll());return{success:!0,results:K,message:`Updated ${K.filter((Q)=>Q.success).length}/${K.length} plugin(s)`}}catch(K){return z.status=500,{error:"Failed to update all plugins",details:String(K)}}}).post("/remove-all",async({set:z})=>{try{let K=await w("*",async()=>{let Q=await B.removeAll(V.hostServices);return V.rebuildPluginSurfaces?.(),Q});return{success:!0,results:K,message:`Removed ${K.filter((Q)=>Q.success).length}/${K.length} plugin(s)`}}catch(K){return z.status=500,{error:"Failed to remove all plugins",details:String(K)}}}).post("/reload",async({set:z})=>{try{if(!V.app||!V.hostServices)return z.status=503,{error:"Plugin lifecycle services are not ready"};let K=await w("*",async()=>{return await B.reloadAll(V.app,V.hostServices),V.rebuildPluginSurfaces?.(),B.getPluginDetails()});return{success:!0,plugins:K,message:`Reloaded ${K.length} plugin(s)`}}catch(K){return z.status=500,{error:"Failed to reload plugins",details:String(K)}}}).post("/:name/reload",async({params:z,set:K})=>{if(!V.app||!V.hostServices)return K.status=503,{error:"Plugin lifecycle services are not ready"};let Q=z.name,X=B.getAllPlugins().find((Y)=>Y.name===Q);if(!X)return K.status=404,{error:`Plugin "${Q}" not found`};let x=B.getPluginDetails().find((Y)=>Y.pluginName===Q)?.packageName??`core:${Q}`;if(K2(x))return K.status=409,{error:"Plugin lifecycle in progress; try again shortly",packageName:x};try{return await w(x,async()=>{if(X.onServerStop)try{await X.onServerStop({reason:"reload"})}catch(Y){console.warn(`[plugin-mgr] onServerStop during reload of ${Q}:`,Y)}if(V.hostServices)V.hostServices.serviceRegistry.unregisterPlugin(X.name);if(B.registerProviders(X,V.hostServices),X.onServerStart)await X.onServerStart(V.app,V.hostServices),B.registerProviders(X,V.hostServices);if(X.onServerReady)await X.onServerReady(V.app,V.hostServices);return V.rebuildPluginSurfaces?.(),{success:!0,message:`Plugin ${Q} reloaded`,version:X.version}})}catch(Y){return K.status=500,{error:"Failed to reload plugin",details:String(Y)}}},{params:J.Object({name:J.String()})})}import{mkdirSync as o,writeFileSync as v,existsSync as x2}from"fs";import{isAbsolute as D2,join as T,relative as A2,resolve as g}from"path";var D="http://localhost:3005",v2=/^[a-z0-9][a-z0-9-]{0,63}$/,E2=new Set(["backend","frontend","cli","provider","adapter","integration"]);function C2(V,B){let z=A2(V,B);if(z.startsWith("..")||D2(z))throw Error("Plugin scaffold path escapes the selected directory.")}function M(V){return JSON.stringify(V)}function J2(V){let B=V.command("plugin").description("Manage plugins");B.command("list").description("List installed plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(K)=>{try{let Q={...V.opts(),...K},X=U(K),$=encodeURIComponent(E(Q)),x=async()=>{try{return(await n(X,`/api/profiles/${$}/plugins`)).plugins||[]}catch{I("Agent not reachable. Attempting local plugin registry...");let{PluginManager:Z}=await import("./plugin-system-jww7bh2a.js");return new Z().getPluginDetails()||[]}},Y=(Z)=>Z.status??(Z.loaded===!0||Z.enabled===!0?"enabled":"disabled"),W=(Z)=>Z.pluginName||Z.name||Z.packageName||Z.package||"-";await t({mode:l(Q),fetchData:x,plain:(Z)=>{if(!Z.length){_("No plugins installed.");return}u("Installed Plugins"),i(Z.map((H)=>({Name:W(H),Version:H.version||"-",Status:Y(H),Description:H.description||"-"})))},interactive:async(Z)=>{if(!Z.length){u("Installed Plugins"),_("No plugins installed.");return}let H=Z.map((F)=>{let C=W(F),G=Y(F),b=[`${k.bold(C)} ${G==="enabled"?k.green(G):k.dim(G)}`,"",` Version: ${F.version||"-"}`,` Description: ${F.description||"-"}`];if(F.tags&&Array.isArray(F.tags))b.push(` Tags: ${F.tags.join(", ")}`);if(F.cliCommand)b.push(` CLI command: vibe ${F.cliCommand}`);return{id:C,label:C,hint:G,detail:b.join(`
3
+ `)}});await s({title:`vibe plugin \u2014 ${Z.length} installed`,rows:H,footer:"\u2191/\u2193 navigate \xB7 q to quit"})},json:(Z)=>Z.map((H)=>({name:W(H),version:H.version??null,status:Y(H),description:H.description??null,tags:H.tags??null,cliCommand:H.cliCommand??null}))})}catch(Q){q(O(Q))}}),B.command("install").description("Install a plugin").argument("<package>","NPM package name to install").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--skip-prereqs","Skip running the plugin's prereqs/install",!1).option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));try{let Y=await h($,`/api/profiles/${x}/plugins/install`,{packageName:K,skipPrereqs:!!Q.skipPrereqs});if(R(X,{ok:!0,action:"install",package:K,version:Y?.version??null,prereqs:Y?.prereqs??null}))return;if(S(`Plugin "${K}" installed.`),Y?.version)A("Version",Y.version);if(Y?.prereqs){let W=Y.prereqs;if(W.skipped)I(`Prerequisite install skipped. Run \`vibe plugin prereqs ${K} install\` later.`);else if(!W.satisfied)I(`Prerequisites not yet satisfied: ${(W.missing||[]).map((Z)=>Z.name).join(", ")||"(unknown)"}`);if((W.pendingSudo||[]).length>0){I(`${W.pendingSudo.length} command(s) need sudo. Run them and re-check with \`vibe plugin prereqs ${K} status\`:`);for(let Z of W.pendingSudo)A(` ${Z.name}`,Z.command)}}}catch{I("Agent not reachable. Attempting local install...");try{let{PluginManager:Y}=await import("./plugin-system-jww7bh2a.js");if(await new Y().install(K),R(X,{ok:!0,action:"install",package:K,local:!0}))return;S(`Plugin "${K}" installed locally.`)}catch(Y){q(`Could not install plugin via agent or locally: ${O(Y)}`)}}}catch(X){q(O(X))}}),B.command("remove").description("Remove a plugin").argument("<package>","NPM package name to remove").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));try{if(await h($,`/api/profiles/${x}/plugins/remove`,{packageName:K}),R(X,{ok:!0,action:"remove",package:K}))return;S(`Plugin "${K}" removed.`)}catch{I("Agent not reachable. Attempting local removal...");try{let{PluginManager:Y}=await import("./plugin-system-jww7bh2a.js");if(await new Y().remove(K),R(X,{ok:!0,action:"remove",package:K,local:!0}))return;S(`Plugin "${K}" removed locally.`)}catch(Y){q(`Could not remove plugin via agent or locally: ${O(Y)}`)}}}catch(X){q(O(X))}}),B.command("update").description("Update a plugin (or all plugins with --all)").argument("[package]","NPM package name to update").option("--all","Update all installed plugins",!1).option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));if(Q.all){_("Updating all plugins...");try{let Y=await h($,`/api/profiles/${x}/plugins/update-all`,{}),W=Y?.results||[];if(R(X,{ok:!0,action:"update-all",results:W}))return;for(let Z of W)if(Z.success)S(`Updated ${Z.packageName}${Z.version?` to v${Z.version}`:""}`);else I(`Failed to update ${Z.packageName}: ${Z.error}`);S(Y?.message||"Done.")}catch{I("Agent not reachable. Attempting local update...");try{let{PluginManager:Y}=await import("./plugin-system-jww7bh2a.js"),Z=await new Y().updateAll();if(R(X,{ok:!0,action:"update-all",results:Z,local:!0}))return;for(let H of Z)if(H.success)S(`Updated ${H.packageName}${H.version?` to v${H.version}`:""}`);else I(`Failed to update ${H.packageName}: ${H.error}`)}catch(Y){q(`Could not update plugins: ${O(Y)}`)}}}else if(K){_(`Updating ${K}...`);try{let Y=await h($,`/api/profiles/${x}/plugins/update`,{packageName:K});if(R(X,{ok:!0,action:"update",package:K,version:Y?.version??null,message:Y?.message??null}))return;S(Y?.message||`Plugin "${K}" updated.`)}catch{I("Agent not reachable. Attempting local update...");try{let{PluginManager:Y}=await import("./plugin-system-jww7bh2a.js"),Z=await new Y().update(K);if(R(X,{ok:!0,action:"update",package:K,version:Z.version,local:!0}))return;S(`Plugin "${K}" updated to v${Z.version}.`)}catch(Y){q(`Could not update plugin: ${O(Y)}`)}}}else q("Provide a package name to update, or use --all to update all plugins.")}catch(X){q(O(X))}}),B.command("uninstall").description("Uninstall a plugin (or all plugins with --all)").argument("[package]","NPM package name to uninstall").option("--all","Uninstall all external plugins",!1).option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=U(Q),x=encodeURIComponent(E(X));if(Q.all){_("Uninstalling all plugins...");try{let Y=await h($,`/api/profiles/${x}/plugins/remove-all`,{}),W=Y?.results||[];if(R(X,{ok:!0,action:"uninstall-all",results:W}))return;for(let Z of W)if(Z.success)S(`Removed ${Z.packageName}`);else I(`Failed to remove ${Z.packageName}: ${Z.error}`);S(Y?.message||"Done.")}catch{I("Agent not reachable. Attempting local removal...");try{let{PluginManager:Y}=await import("./plugin-system-jww7bh2a.js"),Z=await new Y().removeAll();if(R(X,{ok:!0,action:"uninstall-all",results:Z,local:!0}))return;for(let H of Z)if(H.success)S(`Removed ${H.packageName}`);else I(`Failed to remove ${H.packageName}: ${H.error}`)}catch(Y){q(`Could not uninstall plugins: ${O(Y)}`)}}}else if(K)try{if(await h($,`/api/profiles/${x}/plugins/remove`,{packageName:K}),R(X,{ok:!0,action:"uninstall",package:K}))return;S(`Plugin "${K}" uninstalled.`)}catch{I("Agent not reachable. Attempting local removal...");try{let{PluginManager:Y}=await import("./plugin-system-jww7bh2a.js");if(await new Y().remove(K),R(X,{ok:!0,action:"uninstall",package:K,local:!0}))return;S(`Plugin "${K}" uninstalled locally.`)}catch(Y){q(`Could not uninstall plugin: ${O(Y)}`)}}else q("Provide a package name to uninstall, or use --all to uninstall all plugins.")}catch(X){q(O(X))}}),B.command("reload").description("Reload all plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K)=>{try{let Q={...V.opts(),...K},X=U(K),$=encodeURIComponent(E(Q));if(await h(X,`/api/profiles/${$}/plugins/reload`,{}),R(Q,{ok:!0,action:"reload"}))return;S("Plugins reloaded.")}catch(Q){q(O(Q))}}),B.command("available").description("Show available plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(K)=>{try{let Q={...V.opts(),...K},X=U(K),$=encodeURIComponent(E(Q)),x=async()=>{return(await n(X,`/api/profiles/${$}/plugins/available`)).plugins||[]},Y=(Z)=>Z.name||Z.package||"-",W=(Z)=>Z.version||Z.latestVersion||"-";await t({mode:l(Q),fetchData:x,plain:(Z)=>{if(!Z||Z.length===0){_("No available plugins found.");return}u("Available Plugins"),i(Z.map((H)=>({Name:Y(H),Version:W(H),Description:H.description||"-"})))},interactive:async(Z)=>{if(!Z||Z.length===0){u("Available Plugins"),_("No available plugins found.");return}let H=Z.map((F)=>{let C=Y(F),G=[k.bold(C),"",` Version: ${W(F)}`,` Description: ${F.description||"-"}`];return{id:C,label:C,hint:W(F),detail:G.join(`
4
4
  `)}});await s({title:`vibe plugin available \u2014 ${Z.length} plugin(s)`,rows:H,footer:"\u2191/\u2193 navigate \xB7 q to quit"})},json:(Z)=>Z.map((H)=>({name:Y(H),version:W(H),description:H.description??null}))})}catch(Q){q(O(Q))}});let z=B.command("prereqs").description("Inspect or run a plugin's prerequisite-install protocol").argument("<package>","NPM package name (or short plugin name)");z.command("status",{isDefault:!0}).description("Show the plugin's prereq status").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(K,Q)=>{let X=Q.parent?.args?.[0];if(!X){q("Missing plugin package argument.");return}try{let $={...V.opts(),...K},x=U(K),Y=async()=>h(x,"/api/plugins/prereqs/status",{packageName:X});await t({mode:l($),fetchData:Y,plain:(W)=>{if(A("Plugin",X),A("Satisfied",W?.satisfied?"yes":"no"),Array.isArray(W?.missing)&&W.missing.length>0)A("Missing",W.missing.map((Z)=>Z.name).join(", "))},interactive:async(W)=>{let Z=[`Plugin: ${X}`,`Satisfied: ${W?.satisfied?"yes":"no"}`];if(Array.isArray(W?.missing)&&W.missing.length>0)Z.push(`Missing: ${W.missing.map((H)=>H.name).join(", ")}`);await G2({title:`Prereqs: ${X}`,body:Z.join(`
5
5
  `),footer:"q / Esc to quit"})},json:(W)=>({plugin:X,satisfied:!!W?.satisfied,missing:Array.isArray(W?.missing)?W.missing:[],pendingSudo:Array.isArray(W?.pendingSudo)?W.pendingSudo:[]})})}catch($){q(`Could not read prereq status: ${O($)}`)}}),z.command("install").description("Run the plugin's prerequisite install endpoint").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--approve-sudo","Auto-approve sudo commands the plugin returns",!1).option("--json","Emit JSON result").action(async(K,Q)=>{let X=Q.parent?.args?.[0];if(!X){q("Missing plugin package argument.");return}try{let $={...V.opts(),...K},x=U(K),Y=await h(x,"/api/plugins/prereqs/install",{packageName:X,approveSudo:!!K.approveSudo});if(R($,{ok:!0,action:"prereqs-install",plugin:X,satisfied:!!Y?.satisfied,pendingSudo:Y?.pendingSudo??[]}))return;if(Y?.satisfied)S(`Prerequisites satisfied for ${X}.`);else I(`Prerequisites still missing for ${X}.`);if(Array.isArray(Y?.pendingSudo)&&Y.pendingSudo.length>0){I(`${Y.pendingSudo.length} command(s) require sudo:`);for(let W of Y.pendingSudo)A(` ${W.name}`,W.command)}}catch($){q(`Prereq install failed: ${O($)}`)}}),z.command("uninstall").description("Run the plugin's prerequisite uninstall endpoint (if supported)").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(K,Q)=>{let X=Q.parent?.args?.[0];if(!X){q("Missing plugin package argument.");return}try{let $={...V.opts(),...K},x=U(K);if(await h(x,"/api/plugins/prereqs/uninstall",{packageName:X}),R($,{ok:!0,action:"prereqs-uninstall",plugin:X}))return;S(`Prereq uninstall completed for ${X}.`)}catch($){I(`Prereq uninstall not supported or failed: ${O($)}`)}}),B.command("create").description("Scaffold a new plugin project").argument("<name>",'Plugin name (e.g. "docker" \u2192 vibe-plugin-docker)').option("-d, --dir <directory>","Parent directory",".").option("--tag <tag>","Plugin tag (backend, frontend, cli, provider, adapter, integration)","backend").option("--with-ui","Include a companion UI plugin scaffold",!1).option("--json","Emit JSON result").action(async(K,Q)=>{try{let X={...V.opts(),...Q},$=K.startsWith("vibe-plugin-")?K.slice(12):K;if(!v2.test($)){q("Plugin name must use lowercase letters, numbers, and dashes only.");return}let x=Q.tag;if(!E2.has(x)){q("Invalid plugin tag.");return}let Y=`vibe-plugin-${$}`,W=g(Q.dir),Z=g(W,Y);if(C2(W,Z),x2(Z)){q(`Directory "${Z}" already exists.`);return}_(`Scaffolding ${Y}...`),o(T(Z,"src"),{recursive:!0}),o(T(Z,"dist"),{recursive:!0});let H=`VibeControls plugin: ${$}`,F={name:`@vibecontrols/${Y}`,version:"0.1.0",main:"./dist/index.js",type:"module",engines:{bun:">=1.3.0"},scripts:{build:"bun build ./src/index.ts --outdir ./dist --target bun",lint:"eslint ./src",format:"bunx prettier . --write","format:check":"bunx prettier . --check","type:check":"tsc --noEmit",clean:"rimraf dist",prebuild:"bun run clean",prepublishOnly:"bun run build",sanity:"bun run format:check && bun run lint && bun run type:check && bun run build"},keywords:["vibecontrols","vibe","vibe-plugin",$,"bun"],author:{name:"Your Name",email:"you@example.com"},license:"SEE LICENSE IN LICENSE",description:H,devDependencies:{"@types/bun":"^1.2.16","bun-types":"^1.3.9",commander:"^14.0.3",eslint:"^9.30.1",prettier:"^3.6.2",rimraf:"^6.0.1",typescript:"^5.8.3","typescript-eslint":"^8.56.0"},peerDependencies:{"@vibecontrols/agent":">=2.0.0"},peerDependenciesMeta:{"@vibecontrols/agent":{optional:!0}},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},files:["dist/**/*","README.md","LICENSE"]};v(T(Z,"package.json"),JSON.stringify(F,null,2)+`
6
6
  `);let C={compilerOptions:{target:"ES2022",module:"ES2022",moduleResolution:"bundler",types:["bun-types"],strict:!0,esModuleInterop:!0,skipLibCheck:!0,outDir:"./dist",rootDir:"./src",declaration:!0,sourceMap:!0},include:["src/**/*.ts"],exclude:["node_modules","dist"]};v(T(Z,"tsconfig.json"),JSON.stringify(C,null,2)+`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{wa as Fa,za}from"./index-pc05r6fd.js";import{Aa as Ua}from"./index-4wgjx8bf.js";import{Da as Pa,Wa as Ba}from"./index-5wsfsj88.js";import{Xa as ja}from"./index-0ckffygp.js";import{nb as Ka}from"./index-m2kkd6t6.js";import{Jb as qa}from"./index-9g3vxhby.js";import{qd as ba,sd as wt}from"./index-sv4rzv3f.js";import{Ad as Zt,Cd as Ra,Dd as ka,Fd as La,Jd as x,Nd as Ta,Pd as g,Qd as Oa}from"./index-c4p1qcnn.js";import{_d as Vt,de as Ia}from"./index-q9dp55wv.js";import{je as Ae}from"./index-gb5bnx7a.js";var Gt=[0,5000,15000,30000,60000],Xa=2000,Ha=5000,Va=120000,cs=10,Ja=1048576;class ei extends Error{resetAt;resource;constructor(e,t,i){super(e);this.name="RateLimitError",this.resource=t,this.resetAt=i}}function ti(e,t){if(!e?.length)return null;let i=e.find((r)=>r.extensions?.code==="RATE_LIMITED");if(!i)return null;let s=i.extensions?.resetAt,n=null;if(s){let r=new Date(s);if(!Number.isNaN(r.getTime()))n=r}return new ei(`${t} rate limited${n?` until ${n.toISOString()}`:""}`,t,n)}function Ya(e){if(!e.resetAt)return 60000;let t=e.resetAt.getTime()-Date.now()+Xa;return Math.min(Math.max(t,Ha),Va)}async function Wa(e,t){let i=e.headers.get("content-length");if(i){let o=Number.parseInt(i,10);if(Number.isInteger(o)&&o>t)throw Error(`Gateway response is too large (${o} bytes)`)}if(!e.body)return"";let s=e.body.getReader(),n=[],r=0;try{while(!0){let{done:o,value:c}=await s.read();if(o)break;if(!c)continue;if(r+=c.byteLength,r>t)throw await s.cancel().catch(()=>{return}),Error(`Gateway response exceeds ${t} bytes`);n.push(c)}}finally{s.releaseLock()}let a=new Uint8Array(r),l=0;for(let o of n)a.set(o,l),l+=o.byteLength;return new TextDecoder().decode(a)}async function ii(e,t){let i=await Wa(e,Ja),s;try{s=i?JSON.parse(i):{}}catch(n){let r=i.slice(0,240).replace(/\s+/g," ");throw Error(`${t} returned non-JSON response (${e.status} ${e.statusText})${r?`: ${r}`:""}`,{cause:n})}if(!e.ok){let n=i.slice(0,240).replace(/\s+/g," ");throw Error(`${t} failed (${e.status} ${e.statusText})${n?`: ${n}`:""}`)}return s}function si(e){return e.endsWith("/graphql")?e:`${e}/graphql`}function Qa(e){let t;try{t=new URL(e).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{return!1}if(t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t==="host.docker.internal")return!0;return t.endsWith(".localhost")||t.endsWith(".local")||t.endsWith(".local.burdenoff.com")}function ni(e){if(!(process.env.VIBE_DEV_INSECURE_TLS==="1"||process.env.NODE_TLS_REJECT_UNAUTHORIZED==="0")&&!Qa(e))return{};return{tls:{rejectUnauthorized:!1}}}async function Ga(e,t,i){let s=await fetch(si(e),{method:"POST",...ni(e),headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`mutation AuthenticateApp($input: AuthenticateAppInput!) {
2
+ import{Aa as Fa,Da as za}from"./index-rhcsaqc0.js";import{Ea as Ua}from"./index-hey6w5m0.js";import{Ha as Pa,_a as Ba}from"./index-2244sbdx.js";import{$a as ja}from"./index-ea42kfvk.js";import{rb as Ka}from"./index-jnrqbhew.js";import{Nb as qa}from"./index-d384edvr.js";import{ud as ba,wd as wt}from"./index-a9x5swye.js";import{Hd as Zt,Jd as Ra,Kd as ka,Md as La,Qd as x,Ud as Ta,Wd as g,Xd as Oa}from"./index-axgp7ryd.js";import{fe as Vt,ke as Ia}from"./index-c4zn91z3.js";import{qe as Ae}from"./index-149rjxa5.js";var Gt=[0,5000,15000,30000,60000],Xa=2000,Ha=5000,Va=120000,cs=10,Ja=1048576;class ei extends Error{resetAt;resource;constructor(e,t,i){super(e);this.name="RateLimitError",this.resource=t,this.resetAt=i}}function ti(e,t){if(!e?.length)return null;let i=e.find((r)=>r.extensions?.code==="RATE_LIMITED");if(!i)return null;let s=i.extensions?.resetAt,n=null;if(s){let r=new Date(s);if(!Number.isNaN(r.getTime()))n=r}return new ei(`${t} rate limited${n?` until ${n.toISOString()}`:""}`,t,n)}function Ya(e){if(!e.resetAt)return 60000;let t=e.resetAt.getTime()-Date.now()+Xa;return Math.min(Math.max(t,Ha),Va)}async function Wa(e,t){let i=e.headers.get("content-length");if(i){let o=Number.parseInt(i,10);if(Number.isInteger(o)&&o>t)throw Error(`Gateway response is too large (${o} bytes)`)}if(!e.body)return"";let s=e.body.getReader(),n=[],r=0;try{while(!0){let{done:o,value:c}=await s.read();if(o)break;if(!c)continue;if(r+=c.byteLength,r>t)throw await s.cancel().catch(()=>{return}),Error(`Gateway response exceeds ${t} bytes`);n.push(c)}}finally{s.releaseLock()}let a=new Uint8Array(r),l=0;for(let o of n)a.set(o,l),l+=o.byteLength;return new TextDecoder().decode(a)}async function ii(e,t){let i=await Wa(e,Ja),s;try{s=i?JSON.parse(i):{}}catch(n){let r=i.slice(0,240).replace(/\s+/g," ");throw Error(`${t} returned non-JSON response (${e.status} ${e.statusText})${r?`: ${r}`:""}`,{cause:n})}if(!e.ok){let n=i.slice(0,240).replace(/\s+/g," ");throw Error(`${t} failed (${e.status} ${e.statusText})${n?`: ${n}`:""}`)}return s}function si(e){return e.endsWith("/graphql")?e:`${e}/graphql`}function Qa(e){let t;try{t=new URL(e).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{return!1}if(t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t==="host.docker.internal")return!0;return t.endsWith(".localhost")||t.endsWith(".local")||t.endsWith(".local.burdenoff.com")}function ni(e){if(!(process.env.VIBE_DEV_INSECURE_TLS==="1"||process.env.NODE_TLS_REJECT_UNAUTHORIZED==="0")&&!Qa(e))return{};return{tls:{rejectUnauthorized:!1}}}async function Ga(e,t,i){let s=await fetch(si(e),{method:"POST",...ni(e),headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`mutation AuthenticateApp($input: AuthenticateAppInput!) {
3
3
  authenticateApp(input: $input) { accessToken expiresIn }
4
4
  }`,variables:{input:{clientId:t,clientSecret:i,scopes:[]}}}),signal:AbortSignal.timeout(15000)}),n=await ii(s,"authenticateApp"),r=ti(n.errors,"authenticateApp");if(r)throw r;if(n.errors?.length){let l=n.errors.map((o)=>o.extensions?.code??"UNKNOWN").join(",");throw Error(`authenticateApp errors [${l}]: ${n.errors.map((o)=>o.message).join("; ")}`)}let a=n.data?.authenticateApp?.accessToken;if(!a)throw Error("authenticateApp returned no token");return a}async function Za(e,t,i,s){let n=await fetch(si(e),{method:"POST",...ni(e),headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({query:`mutation IssueAgentWorkspaceToken($input: IssueWorkspaceTokenInput!) {
5
5
  issueWorkspaceToken(input: $input) {
@@ -174,5 +174,5 @@ data: /message
174
174
  mutation NotifyVibecontrolsAgentPluginChange($agentId: ID!) {
175
175
  notifyVibecontrolsAgentPluginChange(agentId: $agentId)
176
176
  }
177
- `;async function kd(e){try{if(!x.isConfigured())return;let t=await e.getConfig("gateway-auth:agentRecordId");if(!t)return;let i=await x.workspaceQuery(Rh,{agentId:t});if(i.errors?.length)g().logger.debug(y,"Plugin-change notify returned errors",{errors:i.errors.map((s)=>s.message)})}catch(t){g().logger.debug(y,`Plugin-change notify failed: ${t instanceof Error?t.message:String(t)}`)}}var ft=null,tt=null,_t=!1;function At(e,t,i){if(ft)return;let s=Number(process.env.VIBE_TUNNEL_SYNC_MS),n=Number.isFinite(s)&&s>0?s:i??60000;ft=setInterval(async()=>{if(!x.isConfigured())return;try{let r=t.getProvider("tunnel");if(!r||!r.getActiveTunnelUrl)return;let a=ka(await r.getActiveTunnelUrl()),l=await e.getConfig("gateway-auth:agentRecordId");if(!l)return;if(await Yt(l),!a){if(!_t)_t=!(await x.workspaceQuery(xt,{id:l,input:{tunnelStatus:"DISCONNECTED"}})).errors?.length,g().logger.warn(y,"No active tunnel URL \u2014 reported tunnel as DISCONNECTED",{reported:_t});return}let o=_t,c=x.getConfig()?.workspaceId||"",h;if(c)h=(await x.workspaceQuery(Wt,{workspaceId:c})).data?.vibecontrolsAgents?.find((p)=>p.id===l)?.tunnelUrl??null;let u=a!==tt,d=h!==void 0&&h!==a;if(!u&&!d&&!o)return;g().logger.info(y,"Re-publishing tunnel URL",{reason:o?"tunnel-recovered":d?"backend-drift":"local-change",backend:h,local:a,lastReported:tt});let _=await x.workspaceQuery(xt,{id:l,input:{tunnelUrl:a,tunnelStatus:"CONNECTED"}});if(!_.errors?.length)tt=a,_t=!1,g().logger.info(y,"Tunnel URL synced to backend",{tunnelUrl:a});else g().logger.warn(y,"Tunnel URL sync returned errors",{errors:_.errors.map((f)=>f.message)})}catch(r){g().logger.debug(y,`Tunnel sync check failed: ${r instanceof Error?r.message:String(r)}`)}},n),ft.unref?.()}function Ld(){if(ft)clearInterval(ft),ft=null;_t=!1,tt=null}async function Pd(e,t,i){if(!x.isConfigured()){g().logger.debug(y,"Gateway auth not configured \u2014 skipping auto-report");return}let s=await e.getConfig("gateway-auth:workspaceId");if(!s){g().logger.warn(y,"No workspaceId configured \u2014 skipping auto-report. "+"Configure via POST /api/agent/gateway-auth with workspaceId.");return}g().logger.info(y,"Starting auto-report to backend...");try{let n=process.env.VIBE_AGENT_NAME||Jt.hostname(),r=Jt.platform(),a=Jt.arch(),l=Pa(),o=await Dh(t),c=await os(e,n);if(c){g().logger.info(y,`Updating agent record ${c} via workspace gateway`);let u=await x.workspaceQuery(xt,{id:c,input:{tunnelUrl:o||null,tunnelStatus:o?"CONNECTED":"DISCONNECTED",agentApiKey:i}});if(u.errors?.length){if(g().logger.warn(y,"Update mutation returned errors",{errors:u.errors.map((_)=>_.message)}),await Ch(s,c)){g().logger.warn(y,"Agent record still exists \u2014 treating update failure as transient; will retry on next sync (NOT registering a duplicate)",{agentRecordId:c}),await Ca(s,{hostname:n,platform:r,arch:a,tunnelUrl:o,apiKey:i}),await Yt(c),tt=o,At(e,t),ut(e);return}g().logger.info(y,"Cached agent record no longer exists \u2014 clearing cache and registering fresh",{agentRecordId:c}),await e.setConfig("gateway-auth:agentRecordId",""),c=null}else{g().logger.info(y,"Agent record updated successfully",{agentRecordId:c,tunnelUrl:o}),await Da(c,o,s),await Ca(s,{hostname:n,platform:r,arch:a,tunnelUrl:o,apiKey:i}),await Yt(c),tt=o,At(e,t),ut(e);return}}g().logger.info(y,`Registering installed agent via workspace gateway (hostname: ${n})`);for(let u=1;u<=Fe&&!c;u++){if(u>1){let p=await os(e,n);if(p){c=p,g().logger.info(y,"Adopted an agent record discovered after a retry (not registering a duplicate)",{agentRecordId:c});break}}let d=await x.workspaceQuery(Ma,{workspaceId:s,input:{name:n,hostname:n,platform:r,architecture:a,tunnelUrl:o||null,agentApiKey:i}}),_=d.errors?.length?void 0:d.data?.registerInstalledAgent?.id;if(_){await e.setConfig("gateway-auth:agentRecordId",_),c=_,g().logger.info(y,"Agent registered successfully",{agentRecordId:_,name:d.data?.registerInstalledAgent?.name,tunnelUrl:o,version:l,attempt:u});break}let f=d.errors?.length?d.errors.map((p)=>p.message):["registerInstalledAgent returned no id"];if(u<Fe){let p=Math.min(30000,as*2**(u-1));g().logger.warn(y,`Register installed agent failed (attempt ${u}/${Fe}) \u2014 retrying in ${Math.round(p/1000)}s`,{errors:f}),await new Promise((m)=>setTimeout(m,p));continue}g().logger.error(y,"Register installed agent failed after retries \u2014 agent is running but NOT registered with the workspace",{errors:f}),g().recordDegradedReason("agent-registration",`registerInstalledAgent failed after ${Fe} attempts: ${f.join("; ")}`)}if(!c){At(e,t),ut(e);return}let h=await x.workspaceQuery(xt,{id:c,input:{tunnelUrl:o||null,tunnelStatus:o?"CONNECTED":"DISCONNECTED"}});if(h.errors?.length)g().logger.warn(y,"Post-registration agent update returned errors",{errors:h.errors.map((u)=>u.message)});else g().logger.info(y,"Post-registration agent sync completed",{agentRecordId:c,tunnelUrl:o});if(await Da(c,o,s),await Yt(c),tt=o,At(e,t),ut(e),process.env.VIBE_BRIDGE_DISABLED!=="1")try{let{bridgeClient:u}=await import("./bridge-client-zye1vz1y.js"),d=process.env.VIBECONTROLS_PROFILE||"default";u.start(c,d)}catch(u){g().logger.warn(y,`bridge-client start failed: ${u instanceof Error?u.message:String(u)}`)}}catch(n){g().logger.error(y,`Auto-report failed: ${n instanceof Error?n.message:String(n)}`);try{At(e,t),ut(e)}catch{}}}var S="lifecycle";class ls{serviceRegistry;pluginManager;db;app;hostServices;appStopFn;state="running";transition=Promise.resolve();constructor(e,t,i,s,n,r){this.serviceRegistry=e;this.pluginManager=t;this.db=i;this.app=s;this.hostServices=n;this.appStopFn=r}getState(){return this.state}enqueueTransition(e,t){let i=this.transition.then(t,t);return this.transition=i.catch((s)=>{g().logger.warn(S,`Lifecycle transition '${e}' failed`,{error:String(s)})}),i}async stop(){return this.enqueueTransition("stop",async()=>{if(this.state==="stopped"){g().logger.warn(S,"Agent is already stopped");return}g().logger.info(S,"Stopping agent..."),this.state="stopped";let e=this.serviceRegistry.getProvider("session");if(e)try{let t=await e.list();for(let i of t)if(i.status==="active")try{await e.kill(i.id),g().logger.debug(S,`Killed session ${i.id}`)}catch(s){g().logger.warn(S,`Failed to kill session ${i.id}`,{error:String(s)})}}catch(t){g().logger.warn(S,"Failed to list/stop sessions",{error:String(t)})}try{await this.pluginManager.dispatchServerStop()}catch(t){g().logger.warn(S,"Error during plugin stop dispatch",{error:String(t)})}g().logger.info(S,"Agent stopped (tunnel + HTTP still alive)");try{await Qt(this.db,"stopped")}catch(t){g().logger.warn(S,"Failed to report stopped state to backend",{error:String(t)})}})}async start(){return this.enqueueTransition("start",async()=>{if(this.state==="running"){g().logger.warn(S,"Agent is already running");return}g().logger.info(S,"Starting agent..."),this.state="running";try{await this.pluginManager.dispatchServerStart(this.app,this.hostServices),await this.pluginManager.dispatchServerReady(this.app,this.hostServices)}catch(e){g().logger.warn(S,"Error during plugin start dispatch",{error:String(e)})}g().logger.info(S,"Agent started");try{await Qt(this.db,"running")}catch(e){g().logger.warn(S,"Failed to report running state to backend",{error:String(e)})}})}async softStop(){return this.enqueueTransition("softStop",async()=>{g().logger.info(S,"Soft-stopping agent (hot-reload)...");try{await this.pluginManager.dispatchServerStop({reason:"reload"})}catch(e){g().logger.warn(S,"Error during plugin soft-stop dispatch",{error:String(e)})}try{await this.appStopFn({reason:"reload"})}catch{}g().logger.info(S,"Agent soft-stopped \u2014 exiting for reload"),process.exit(0)})}async prepareForReset(){return this.enqueueTransition("prepareForReset",async()=>{g().logger.info(S,"Preparing agent for reset..."),this.state="stopped";try{await this.pluginManager.dispatchServerStop({reason:"shutdown"})}catch(e){g().logger.warn(S,"Error during reset stop dispatch",{error:String(e)})}})}async kill(){return this.enqueueTransition("kill",async()=>{g().logger.info(S,"Killing agent...");try{await Promise.race([Qt(this.db,"killed"),new Promise((t,i)=>setTimeout(()=>i(Error("Timeout")),5000))])}catch(t){g().logger.warn(S,"Failed to report killed state to backend",{error:String(t)})}let e=this.serviceRegistry.getProvider("tunnel");if(e)try{let t=await e.list();for(let i of t)try{await e.stop(i.id)}catch{}}catch(t){g().logger.warn(S,"Failed to stop tunnels",{error:String(t)})}try{await this.appStopFn()}catch{}g().logger.info(S,"Agent killed \u2014 exiting process"),process.exit(0)})}}async function kh(e){let t=await Lh(e);if(t)return t;return Ph(e.name)}async function Lh(e){let t;try{t=await wt({dir:e.dataDir,scope:e.name})}catch{return null}if(!t.clientId||!t.clientSecret||!t.globalGatewayUrl||!t.workspaceGatewayUrl||!t.workspaceId)return null;return{clientId:t.clientId,clientSecret:t.clientSecret,globalGatewayUrl:t.globalGatewayUrl,workspaceGatewayUrl:t.workspaceGatewayUrl,workspaceId:t.workspaceId,organizationId:t.organizationId}}function Ph(e){let t=e.replace(/[^A-Za-z0-9_]/g,"_").toUpperCase(),i=(o)=>process.env[`VIBE_${t}_${o}`],s=i("CLIENT_ID"),n=i("CLIENT_SECRET"),r=i("GLOBAL_GATEWAY_URL"),a=i("WORKSPACE_GATEWAY_URL"),l=i("WORKSPACE_ID");if(!s||!n||!r||!a||!l)return null;return{clientId:s,clientSecret:n,globalGatewayUrl:r,workspaceGatewayUrl:a,workspaceId:l,organizationId:i("ORGANIZATION_ID")}}async function Na(e){let t=await kh(e);if(!t)return{ok:!1,error:`no creds for profile '${e.name}' (run gateway-auth against this profile or set VIBE_${e.name.toUpperCase()}_* env vars)`};e.setBootState("initializing");let i;try{let l=await hs(t);i=await va({dbPath:e.dataDir,encryptionKey:l})}catch(l){return e.setBootState("awaiting-config"),{ok:!1,error:l instanceof Error?l.message:String(l)}}let s=new Fa(i);await s.hydrateDefaultsFromDb();let n=new Ba(i);await n.loadCorePlugins();try{await n.loadAll()}catch(l){e.logger.warn("secondary-profile-attach","failed to load some external plugins for secondary profile",{error:l instanceof Error?l.message:String(l)})}let r={storage:{async get(l,o){return await i.getPluginState(l,o)??null},async set(l,o,c){await i.setPluginState(l,o,c)},async delete(l,o){return i.deletePluginState(l,o)},async list(l){return await i.getAllPluginState(l)},async deleteAll(l){return i.deleteAllPluginState(l)}},logger:e.logger,serviceRegistry:s,getProvider:(l)=>s.getProvider(l),getAgentBaseUrl:()=>process.env.AGENT_URL||"http://localhost:0",getAgentVersion:()=>"0.0.0",broadcast:()=>{},workspaceQuery:async()=>({}),isGatewayConfigured:()=>!0,getAgentRecordId:async()=>await i.getConfig("gateway-auth:agentRecordId")??null,getWorkspaceId:async()=>await i.getConfig("gateway-auth:workspaceId")??null,getConfig:async(l)=>await i.getConfig(l)??void 0,getPluginRegistry:()=>"",getDataDir:()=>e.dataDir,cliContributors:new Ua,audit:{emit:(l,o)=>e.audit.emit("agent",l,o??{})},telemetry:{emit:()=>{}},os:ja(),iframeBridge:za()},a=new ls(s,n,i,{},r,async()=>{});s.registerService("agent","lifecycle",a),e.attachServices({db:i,serviceRegistry:s,pluginManager:n,lifecycle:a,hostServices:r});try{Ka(e)}catch(l){e.logger.warn("secondary-profile-attach","failed to mount per-profile plugin routes",{error:l instanceof Error?l.message:String(l)})}try{await e.keyVault.bindApiKey(qa())}catch{}return e.setBootState("ready"),{ok:!0}}
177
+ `;async function kd(e){try{if(!x.isConfigured())return;let t=await e.getConfig("gateway-auth:agentRecordId");if(!t)return;let i=await x.workspaceQuery(Rh,{agentId:t});if(i.errors?.length)g().logger.debug(y,"Plugin-change notify returned errors",{errors:i.errors.map((s)=>s.message)})}catch(t){g().logger.debug(y,`Plugin-change notify failed: ${t instanceof Error?t.message:String(t)}`)}}var ft=null,tt=null,_t=!1;function At(e,t,i){if(ft)return;let s=Number(process.env.VIBE_TUNNEL_SYNC_MS),n=Number.isFinite(s)&&s>0?s:i??60000;ft=setInterval(async()=>{if(!x.isConfigured())return;try{let r=t.getProvider("tunnel");if(!r||!r.getActiveTunnelUrl)return;let a=ka(await r.getActiveTunnelUrl()),l=await e.getConfig("gateway-auth:agentRecordId");if(!l)return;if(await Yt(l),!a){if(!_t)_t=!(await x.workspaceQuery(xt,{id:l,input:{tunnelStatus:"DISCONNECTED"}})).errors?.length,g().logger.warn(y,"No active tunnel URL \u2014 reported tunnel as DISCONNECTED",{reported:_t});return}let o=_t,c=x.getConfig()?.workspaceId||"",h;if(c)h=(await x.workspaceQuery(Wt,{workspaceId:c})).data?.vibecontrolsAgents?.find((p)=>p.id===l)?.tunnelUrl??null;let u=a!==tt,d=h!==void 0&&h!==a;if(!u&&!d&&!o)return;g().logger.info(y,"Re-publishing tunnel URL",{reason:o?"tunnel-recovered":d?"backend-drift":"local-change",backend:h,local:a,lastReported:tt});let _=await x.workspaceQuery(xt,{id:l,input:{tunnelUrl:a,tunnelStatus:"CONNECTED"}});if(!_.errors?.length)tt=a,_t=!1,g().logger.info(y,"Tunnel URL synced to backend",{tunnelUrl:a});else g().logger.warn(y,"Tunnel URL sync returned errors",{errors:_.errors.map((f)=>f.message)})}catch(r){g().logger.debug(y,`Tunnel sync check failed: ${r instanceof Error?r.message:String(r)}`)}},n),ft.unref?.()}function Ld(){if(ft)clearInterval(ft),ft=null;_t=!1,tt=null}async function Pd(e,t,i){if(!x.isConfigured()){g().logger.debug(y,"Gateway auth not configured \u2014 skipping auto-report");return}let s=await e.getConfig("gateway-auth:workspaceId");if(!s){g().logger.warn(y,"No workspaceId configured \u2014 skipping auto-report. "+"Configure via POST /api/agent/gateway-auth with workspaceId.");return}g().logger.info(y,"Starting auto-report to backend...");try{let n=process.env.VIBE_AGENT_NAME||Jt.hostname(),r=Jt.platform(),a=Jt.arch(),l=Pa(),o=await Dh(t),c=await os(e,n);if(c){g().logger.info(y,`Updating agent record ${c} via workspace gateway`);let u=await x.workspaceQuery(xt,{id:c,input:{tunnelUrl:o||null,tunnelStatus:o?"CONNECTED":"DISCONNECTED",agentApiKey:i}});if(u.errors?.length){if(g().logger.warn(y,"Update mutation returned errors",{errors:u.errors.map((_)=>_.message)}),await Ch(s,c)){g().logger.warn(y,"Agent record still exists \u2014 treating update failure as transient; will retry on next sync (NOT registering a duplicate)",{agentRecordId:c}),await Ca(s,{hostname:n,platform:r,arch:a,tunnelUrl:o,apiKey:i}),await Yt(c),tt=o,At(e,t),ut(e);return}g().logger.info(y,"Cached agent record no longer exists \u2014 clearing cache and registering fresh",{agentRecordId:c}),await e.setConfig("gateway-auth:agentRecordId",""),c=null}else{g().logger.info(y,"Agent record updated successfully",{agentRecordId:c,tunnelUrl:o}),await Da(c,o,s),await Ca(s,{hostname:n,platform:r,arch:a,tunnelUrl:o,apiKey:i}),await Yt(c),tt=o,At(e,t),ut(e);return}}g().logger.info(y,`Registering installed agent via workspace gateway (hostname: ${n})`);for(let u=1;u<=Fe&&!c;u++){if(u>1){let p=await os(e,n);if(p){c=p,g().logger.info(y,"Adopted an agent record discovered after a retry (not registering a duplicate)",{agentRecordId:c});break}}let d=await x.workspaceQuery(Ma,{workspaceId:s,input:{name:n,hostname:n,platform:r,architecture:a,tunnelUrl:o||null,agentApiKey:i}}),_=d.errors?.length?void 0:d.data?.registerInstalledAgent?.id;if(_){await e.setConfig("gateway-auth:agentRecordId",_),c=_,g().logger.info(y,"Agent registered successfully",{agentRecordId:_,name:d.data?.registerInstalledAgent?.name,tunnelUrl:o,version:l,attempt:u});break}let f=d.errors?.length?d.errors.map((p)=>p.message):["registerInstalledAgent returned no id"];if(u<Fe){let p=Math.min(30000,as*2**(u-1));g().logger.warn(y,`Register installed agent failed (attempt ${u}/${Fe}) \u2014 retrying in ${Math.round(p/1000)}s`,{errors:f}),await new Promise((m)=>setTimeout(m,p));continue}g().logger.error(y,"Register installed agent failed after retries \u2014 agent is running but NOT registered with the workspace",{errors:f}),g().recordDegradedReason("agent-registration",`registerInstalledAgent failed after ${Fe} attempts: ${f.join("; ")}`)}if(!c){At(e,t),ut(e);return}let h=await x.workspaceQuery(xt,{id:c,input:{tunnelUrl:o||null,tunnelStatus:o?"CONNECTED":"DISCONNECTED"}});if(h.errors?.length)g().logger.warn(y,"Post-registration agent update returned errors",{errors:h.errors.map((u)=>u.message)});else g().logger.info(y,"Post-registration agent sync completed",{agentRecordId:c,tunnelUrl:o});if(await Da(c,o,s),await Yt(c),tt=o,At(e,t),ut(e),process.env.VIBE_BRIDGE_DISABLED!=="1")try{let{bridgeClient:u}=await import("./bridge-client-emc7mttx.js"),d=process.env.VIBECONTROLS_PROFILE||"default";u.start(c,d)}catch(u){g().logger.warn(y,`bridge-client start failed: ${u instanceof Error?u.message:String(u)}`)}}catch(n){g().logger.error(y,`Auto-report failed: ${n instanceof Error?n.message:String(n)}`);try{At(e,t),ut(e)}catch{}}}var S="lifecycle";class ls{serviceRegistry;pluginManager;db;app;hostServices;appStopFn;state="running";transition=Promise.resolve();constructor(e,t,i,s,n,r){this.serviceRegistry=e;this.pluginManager=t;this.db=i;this.app=s;this.hostServices=n;this.appStopFn=r}getState(){return this.state}enqueueTransition(e,t){let i=this.transition.then(t,t);return this.transition=i.catch((s)=>{g().logger.warn(S,`Lifecycle transition '${e}' failed`,{error:String(s)})}),i}async stop(){return this.enqueueTransition("stop",async()=>{if(this.state==="stopped"){g().logger.warn(S,"Agent is already stopped");return}g().logger.info(S,"Stopping agent..."),this.state="stopped";let e=this.serviceRegistry.getProvider("session");if(e)try{let t=await e.list();for(let i of t)if(i.status==="active")try{await e.kill(i.id),g().logger.debug(S,`Killed session ${i.id}`)}catch(s){g().logger.warn(S,`Failed to kill session ${i.id}`,{error:String(s)})}}catch(t){g().logger.warn(S,"Failed to list/stop sessions",{error:String(t)})}try{await this.pluginManager.dispatchServerStop()}catch(t){g().logger.warn(S,"Error during plugin stop dispatch",{error:String(t)})}g().logger.info(S,"Agent stopped (tunnel + HTTP still alive)");try{await Qt(this.db,"stopped")}catch(t){g().logger.warn(S,"Failed to report stopped state to backend",{error:String(t)})}})}async start(){return this.enqueueTransition("start",async()=>{if(this.state==="running"){g().logger.warn(S,"Agent is already running");return}g().logger.info(S,"Starting agent..."),this.state="running";try{await this.pluginManager.dispatchServerStart(this.app,this.hostServices),await this.pluginManager.dispatchServerReady(this.app,this.hostServices)}catch(e){g().logger.warn(S,"Error during plugin start dispatch",{error:String(e)})}g().logger.info(S,"Agent started");try{await Qt(this.db,"running")}catch(e){g().logger.warn(S,"Failed to report running state to backend",{error:String(e)})}})}async softStop(){return this.enqueueTransition("softStop",async()=>{g().logger.info(S,"Soft-stopping agent (hot-reload)...");try{await this.pluginManager.dispatchServerStop({reason:"reload"})}catch(e){g().logger.warn(S,"Error during plugin soft-stop dispatch",{error:String(e)})}try{await this.appStopFn({reason:"reload"})}catch{}g().logger.info(S,"Agent soft-stopped \u2014 exiting for reload"),process.exit(0)})}async prepareForReset(){return this.enqueueTransition("prepareForReset",async()=>{g().logger.info(S,"Preparing agent for reset..."),this.state="stopped";try{await this.pluginManager.dispatchServerStop({reason:"shutdown"})}catch(e){g().logger.warn(S,"Error during reset stop dispatch",{error:String(e)})}})}async kill(){return this.enqueueTransition("kill",async()=>{g().logger.info(S,"Killing agent...");try{await Promise.race([Qt(this.db,"killed"),new Promise((t,i)=>setTimeout(()=>i(Error("Timeout")),5000))])}catch(t){g().logger.warn(S,"Failed to report killed state to backend",{error:String(t)})}let e=this.serviceRegistry.getProvider("tunnel");if(e)try{let t=await e.list();for(let i of t)try{await e.stop(i.id)}catch{}}catch(t){g().logger.warn(S,"Failed to stop tunnels",{error:String(t)})}try{await this.appStopFn()}catch{}g().logger.info(S,"Agent killed \u2014 exiting process"),process.exit(0)})}}async function kh(e){let t=await Lh(e);if(t)return t;return Ph(e.name)}async function Lh(e){let t;try{t=await wt({dir:e.dataDir,scope:e.name})}catch{return null}if(!t.clientId||!t.clientSecret||!t.globalGatewayUrl||!t.workspaceGatewayUrl||!t.workspaceId)return null;return{clientId:t.clientId,clientSecret:t.clientSecret,globalGatewayUrl:t.globalGatewayUrl,workspaceGatewayUrl:t.workspaceGatewayUrl,workspaceId:t.workspaceId,organizationId:t.organizationId}}function Ph(e){let t=e.replace(/[^A-Za-z0-9_]/g,"_").toUpperCase(),i=(o)=>process.env[`VIBE_${t}_${o}`],s=i("CLIENT_ID"),n=i("CLIENT_SECRET"),r=i("GLOBAL_GATEWAY_URL"),a=i("WORKSPACE_GATEWAY_URL"),l=i("WORKSPACE_ID");if(!s||!n||!r||!a||!l)return null;return{clientId:s,clientSecret:n,globalGatewayUrl:r,workspaceGatewayUrl:a,workspaceId:l,organizationId:i("ORGANIZATION_ID")}}async function Na(e){let t=await kh(e);if(!t)return{ok:!1,error:`no creds for profile '${e.name}' (run gateway-auth against this profile or set VIBE_${e.name.toUpperCase()}_* env vars)`};e.setBootState("initializing");let i;try{let l=await hs(t);i=await va({dbPath:e.dataDir,encryptionKey:l})}catch(l){return e.setBootState("awaiting-config"),{ok:!1,error:l instanceof Error?l.message:String(l)}}let s=new Fa(i);await s.hydrateDefaultsFromDb();let n=new Ba(i);await n.loadCorePlugins();try{await n.loadAll()}catch(l){e.logger.warn("secondary-profile-attach","failed to load some external plugins for secondary profile",{error:l instanceof Error?l.message:String(l)})}let r={storage:{async get(l,o){return await i.getPluginState(l,o)??null},async set(l,o,c){await i.setPluginState(l,o,c)},async delete(l,o){return i.deletePluginState(l,o)},async list(l){return await i.getAllPluginState(l)},async deleteAll(l){return i.deleteAllPluginState(l)}},logger:e.logger,serviceRegistry:s,getProvider:(l)=>s.getProvider(l),getAgentBaseUrl:()=>process.env.AGENT_URL||"http://localhost:0",getAgentVersion:()=>"0.0.0",broadcast:()=>{},workspaceQuery:async()=>({}),isGatewayConfigured:()=>!0,getAgentRecordId:async()=>await i.getConfig("gateway-auth:agentRecordId")??null,getWorkspaceId:async()=>await i.getConfig("gateway-auth:workspaceId")??null,getConfig:async(l)=>await i.getConfig(l)??void 0,getPluginRegistry:()=>"",getDataDir:()=>e.dataDir,cliContributors:new Ua,audit:{emit:(l,o)=>e.audit.emit("agent",l,o??{})},telemetry:{emit:()=>{}},os:ja(),iframeBridge:za()},a=new ls(s,n,i,{},r,async()=>{});s.registerService("agent","lifecycle",a),e.attachServices({db:i,serviceRegistry:s,pluginManager:n,lifecycle:a,hostServices:r});try{Ka(e)}catch(l){e.logger.warn("secondary-profile-attach","failed to mount per-profile plugin routes",{error:l instanceof Error?l.message:String(l)})}try{await e.keyVault.bindApiKey(qa())}catch{}return e.setBootState("ready"),{ok:!0}}
178
178
  export{va as u,hs as v,ls as w,Na as x,bd as y,kd as z,Ld as A,Pd as B};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Xa as N}from"./index-0ckffygp.js";import{Pd as Q}from"./index-c4p1qcnn.js";var V=5000,H=new Map,X=1;function Y(b){return`${b}#${X++}`}function u(b){let z=Bun.spawn(b.cmd,{env:b.env,cwd:b.cwd,stdout:b.stdout??"pipe",stderr:b.stderr??"pipe",stdin:b.stdin??"pipe",...N().processGroupSpawnOpts()}),B={id:Y(b.owner),owner:b.owner,pid:z.pid??null,startedAt:new Date().toISOString(),proc:z,meta:b.meta};return H.set(B.id,B),z.exited.finally(()=>{H.delete(B.id)}),B}function v(){return[...H.values()]}function C(b){return[...H.values()].filter((z)=>z.owner===b)}async function Z(b,z){let B=N(),J=Date.now()+z;while(Date.now()<J){if(!B.isProcessAlive(b))return!0;await new Promise((U)=>setTimeout(U,100))}return!B.isProcessAlive(b)}async function T(b,z="SIGTERM"){let B=b.pid;if(B==null)return;let J=N();if(J.killProcessTree(B,z),await Z(B,V))return;J.killProcessTree(B,"SIGKILL")}async function D(b){let z=H.get(b);if(!z)return!1;return await T(z),H.delete(b),!0}async function F(){let b=[...H.values()];if(b.length===0)return{reaped:0};return Q().logger.info("subprocess",`Reaping ${b.length} tracked child process(es)`,{owners:[...new Set(b.map((z)=>z.owner))]}),await Promise.all(b.map((z)=>T(z))),H.clear(),{reaped:b.length}}
2
+ import{$a as N}from"./index-ea42kfvk.js";import{Wd as Q}from"./index-axgp7ryd.js";var V=5000,H=new Map,X=1;function Y(b){return`${b}#${X++}`}function u(b){let z=Bun.spawn(b.cmd,{env:b.env,cwd:b.cwd,stdout:b.stdout??"pipe",stderr:b.stderr??"pipe",stdin:b.stdin??"pipe",...N().processGroupSpawnOpts()}),B={id:Y(b.owner),owner:b.owner,pid:z.pid??null,startedAt:new Date().toISOString(),proc:z,meta:b.meta};return H.set(B.id,B),z.exited.finally(()=>{H.delete(B.id)}),B}function v(){return[...H.values()]}function C(b){return[...H.values()].filter((z)=>z.owner===b)}async function Z(b,z){let B=N(),J=Date.now()+z;while(Date.now()<J){if(!B.isProcessAlive(b))return!0;await new Promise((U)=>setTimeout(U,100))}return!B.isProcessAlive(b)}async function T(b,z="SIGTERM"){let B=b.pid;if(B==null)return;let J=N();if(J.killProcessTree(B,z),await Z(B,V))return;J.killProcessTree(B,"SIGKILL")}async function D(b){let z=H.get(b);if(!z)return!1;return await T(z),H.delete(b),!0}async function F(){let b=[...H.values()];if(b.length===0)return{reaped:0};return Q().logger.info("subprocess",`Reaping ${b.length} tracked child process(es)`,{owners:[...new Set(b.map((z)=>z.owner))]}),await Promise.all(b.map((z)=>T(z))),H.clear(),{reaped:b.length}}
3
3
  export{u as o,v as p,C as q,D as r,F as s};
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-2jxqpj7r.js";import"./index-zabjc8f2.js";import{t as QQ}from"./index-16czz4df.js";import"./index-jrxbbb7p.js";import"./index-6jzsthh9.js";import"./index-4gt22c81.js";import"./index-zb7nfmts.js";import"./index-2gwc485c.js";import"./index-pc05r6fd.js";import"./index-4wgjx8bf.js";import{Da as a}from"./index-5wsfsj88.js";import"./index-0ckffygp.js";import"./index-rc79x8fw.js";import{bb as W}from"./index-53qthjhb.js";import"./index-52cp759f.js";import"./index-m2kkd6t6.js";import{Ib as s,Jb as i}from"./index-9g3vxhby.js";import"./index-5dysvvjv.js";import"./index-zaw78sxw.js";import"./index-e2dqz3tw.js";import{Sc as p,Tc as v,od as C,ud as l,vd as n}from"./index-sv4rzv3f.js";import{Pd as q}from"./index-c4p1qcnn.js";import{Zd as D,ae as S,ce as g,de as M}from"./index-q9dp55wv.js";import"./index-ntj6ymk8.js";import{je as B}from"./index-gb5bnx7a.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
- `,{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-50fm2wt8.js"),{getVibecontrolsProfile:Z}=await import("./path-utils-cg1gsy4m.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-74wxbdsh.js"),{setFinalizeRetryHandle:K}=await import("./finalize-retry-handle-registry-kzfqhvwv.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();
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()}
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();
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-149rjxa5.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-sj39bx7y.js";import"./index-149rjxa5.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-gmwpaz2a.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{a as resolveDefaultApiKey,b as register};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{me as a}from"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{a as logShipper};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$d as d,Yd as a,Zd as b,_d as c,ae as e,be as f,ce as g,de as h,ee as i}from"./index-q9dp55wv.js";import"./index-gb5bnx7a.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{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};
@@ -0,0 +1,2 @@
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};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{d as a,e as b}from"./index-r1v6p7vc.js";import"./index-97r6ekww.js";import"./index-bv1z3fxw.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.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-jnrqbhew.js";import"./index-d384edvr.js";import"./index-bv1z3fxw.js";import"./index-e0jbxcn1.js";import"./index-a9x5swye.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.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-149rjxa5.js";export{a as pruneStaleBunBinShims};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{J as a}from"./index-vd3njzs5.js";import"./index-w893wd2g.js";import"./index-97r6ekww.js";import"./index-hwpmdq5z.js";import"./index-54mmh1eb.js";import"./index-34g3tenj.js";import"./index-a3mwtteb.js";import"./index-ff8acg43.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-d384edvr.js";import"./index-bv1z3fxw.js";import"./index-e0jbxcn1.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{a as registerCoreCommands};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{x as a}from"./index-xyfcpfec.js";import"./index-rhcsaqc0.js";import"./index-hey6w5m0.js";import"./index-2244sbdx.js";import"./index-ea42kfvk.js";import"./index-jnrqbhew.js";import"./index-d384edvr.js";import"./index-bv1z3fxw.js";import"./index-e0jbxcn1.js";import"./index-a9x5swye.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.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-ywv7amgf.js";import"./index-ea42kfvk.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.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-at6z8tds.js";import"./index-ekr40gvh.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.js";export{a as telemetryService};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-149rjxa5.js";var l="./tree-sitter-javascript-nd0q4pe9.wasm";export{l as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-149rjxa5.js";var F="./tree-sitter-markdown-411r6y9b.wasm";export{F as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-149rjxa5.js";var E="./tree-sitter-markdown_inline-j5349f42.wasm";export{E as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-149rjxa5.js";var h="./tree-sitter-typescript-zxjzwt75.wasm";export{h as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./index-149rjxa5.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-a3mwtteb.js";import"./index-ea42kfvk.js";import"./index-at6z8tds.js";import"./index-ekr40gvh.js";import"./index-axgp7ryd.js";import"./index-c4zn91z3.js";import"./index-73qwyf9q.js";import"./index-149rjxa5.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.814.1",
3
+ "version": "2026.820.1",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$c as f,Wc as a,Xc as b,Yc as c,Zc as d,_c as e,ad as g,bd as h,cd as i,dd as j,ed as k,fd as l,gd as m,hd as n,id as o,jd as p,kd as q,ld as r,md as s,nd as t,od as u,pd as v,qd as w,rd as x,sd as y,td as z,ud as A,vd as B}from"./index-sv4rzv3f.js";import"./index-c4p1qcnn.js";import"./index-q9dp55wv.js";import"./index-ntj6ymk8.js";import"./index-gb5bnx7a.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,p as ensureProfilesInitialized,n as deleteProfile,o as buildProfileSeed,e as assertValidProfileName,B as applyAgentSecretsToEnv,A 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-2jxqpj7r.js";import"./index-zabjc8f2.js";import"./index-jrxbbb7p.js";import"./index-6jzsthh9.js";import"./index-4gt22c81.js";import"./index-zb7nfmts.js";import"./index-2gwc485c.js";import"./index-pc05r6fd.js";import"./index-4wgjx8bf.js";import"./index-5wsfsj88.js";import"./index-0ckffygp.js";import"./index-rc79x8fw.js";import"./index-53qthjhb.js";import"./index-52cp759f.js";import"./index-m2kkd6t6.js";import"./index-9g3vxhby.js";import"./index-5dysvvjv.js";import"./index-zaw78sxw.js";import"./index-e2dqz3tw.js";import"./index-sv4rzv3f.js";import"./index-c4p1qcnn.js";import"./index-q9dp55wv.js";import"./index-ntj6ymk8.js";import"./index-gb5bnx7a.js";export{a as createApp};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{t as a}from"./index-16czz4df.js";import"./index-c4p1qcnn.js";import"./index-q9dp55wv.js";import"./index-ntj6ymk8.js";import"./index-gb5bnx7a.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-gb5bnx7a.js";export{b as installDependencies,a as checkDependencies};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Nd as a,Od as b,Pd as c,Qd as d,Rd as e}from"./index-c4p1qcnn.js";import"./index-q9dp55wv.js";import"./index-ntj6ymk8.js";import"./index-gb5bnx7a.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 d,Yb as a,Zb as b,_b as c,ac as e,bc as f,cc as g,dc as h,ec as i,fc as j,gc as k}from"./index-g9fthh7a.js";import"./index-gb5bnx7a.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{Hd as a,Id as b,Jd as c,Kd as d}from"./index-c4p1qcnn.js";import"./index-q9dp55wv.js";import"./index-ntj6ymk8.js";import"./index-gb5bnx7a.js";export{a as normalizeGatewayUrl,c as gatewayClient,d as default,b as GatewayClient};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-gb5bnx7a.js";var n="./highlights-hk7bwhj4.scm";export{n as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-gb5bnx7a.js";var t="./highlights-r812a2qc.scm";export{t as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-gb5bnx7a.js";var t="./highlights-ghv9g403.scm";export{t as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-gb5bnx7a.js";var a="./highlights-x6tmsnaa.scm";export{a as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import"./index-gb5bnx7a.js";var r="./highlights-eq9cgrbb.scm";export{r as default};