@vibecontrols/agent 2026.1125.2 → 2026.1127.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 (106) hide show
  1. package/dist/agent-config-xwvsmn6b.js +2 -0
  2. package/dist/{agent-ready-tracker-mewxehg9.js → agent-ready-tracker-7ebr09d9.js} +1 -1
  3. package/dist/app-1dqn9qaw.js +2 -0
  4. package/dist/autostart.cmd-mdyv35dn.js +2 -0
  5. package/dist/bootstrap-workspace-1pt0bwy6.js +2 -0
  6. package/dist/bootstrap.service-gehm65tt.js +2 -0
  7. package/dist/bridge-client-9ax1cvj6.js +2 -0
  8. package/dist/bridge-commands-6dj7ewgx.js +2 -0
  9. package/dist/cli.js +2 -2
  10. package/dist/daemon-profile-fnhc7pcf.js +2 -0
  11. package/dist/{finalize-retry-worker-az74f2qv.js → finalize-retry-worker-c38km3mt.js} +1 -1
  12. package/dist/gateway-client-3zp6kkav.js +2 -0
  13. package/dist/{getMachineId-bsd-4w1wmcjv.js → getMachineId-bsd-qjqk66se.js} +1 -1
  14. package/dist/{getMachineId-darwin-kejwz8w5.js → getMachineId-darwin-tqhg8pqb.js} +1 -1
  15. package/dist/{getMachineId-linux-mpm53wat.js → getMachineId-linux-ygfapc26.js} +1 -1
  16. package/dist/{getMachineId-unsupported-54seyw5v.js → getMachineId-unsupported-87w3cred.js} +1 -1
  17. package/dist/{getMachineId-win-cva7ghz9.js → getMachineId-win-jrtkq63e.js} +1 -1
  18. package/dist/{index-0gmhd3hs.js → index-0rmmrrfh.js} +3 -3
  19. package/dist/{index-7f2k4g6q.js → index-12gb48hg.js} +4 -4
  20. package/dist/{index-7wben1jx.js → index-164mtd7z.js} +2 -2
  21. package/dist/{index-w0m3jm0s.js → index-1t74r13z.js} +2 -2
  22. package/dist/{index-thm1bzpj.js → index-2gj8zktr.js} +9 -9
  23. package/dist/{index-9xrhb68w.js → index-31ssvzw8.js} +2 -2
  24. package/dist/{index-652f9scs.js → index-4kf3nr14.js} +2 -2
  25. package/dist/{index-qe3xpt41.js → index-5s4mtrqb.js} +2 -2
  26. package/dist/{index-jmx5awkj.js → index-62vfxd90.js} +2 -2
  27. package/dist/{index-7gk1x74m.js → index-6nv5rdqh.js} +2 -2
  28. package/dist/{index-5ccmrpb5.js → index-6vsjepw2.js} +48 -48
  29. package/dist/{index-t6p4szqx.js → index-76vza24h.js} +3 -3
  30. package/dist/{index-76m37yd8.js → index-7bm1kptr.js} +3 -3
  31. package/dist/{index-0qjbnyg4.js → index-7wm4bqx5.js} +5 -5
  32. package/dist/{index-akk3rxnn.js → index-90gn0b6x.js} +3 -3
  33. package/dist/index-awj0w14r.js +11 -0
  34. package/dist/{index-2r6cmxxz.js → index-axkwyajz.js} +1 -1
  35. package/dist/index-bk17490n.js +3 -0
  36. package/dist/{index-fqz9n560.js → index-bp82hgag.js} +3 -3
  37. package/dist/{index-2vcxt38h.js → index-bpzk441p.js} +2 -2
  38. package/dist/{index-4z1y39jt.js → index-cn4p1ks0.js} +2 -2
  39. package/dist/{index-byerrz46.js → index-damc6cvc.js} +2 -2
  40. package/dist/{index-xtd0j8ve.js → index-dgbe8jm8.js} +2 -2
  41. package/dist/index-e5jdx9c1.js +3 -0
  42. package/dist/{index-tahaxp6n.js → index-ednz6yz2.js} +2 -2
  43. package/dist/{index-hsrt2v87.js → index-f5nmxa9e.js} +1 -1
  44. package/dist/{index-7s7ee1y9.js → index-he4hy261.js} +4 -4
  45. package/dist/{index-kwhx023z.js → index-j99tkngg.js} +10 -10
  46. package/dist/{index-4rasb3ph.js → index-k12bymz4.js} +9 -9
  47. package/dist/{index-qfxwk38p.js → index-p7fbnfwd.js} +2 -2
  48. package/dist/{index-jnxjjx2y.js → index-ppxayc0x.js} +2 -2
  49. package/dist/{index-er5k6qtr.js → index-qqnb0axh.js} +4 -4
  50. package/dist/index-qzwbctkv.js +16 -0
  51. package/dist/{index-a0vx2zyx.js → index-rae5bn1c.js} +2 -2
  52. package/dist/{index-8rbhm4g8.js → index-rhn7wy1p.js} +2 -2
  53. package/dist/index-sd5bt3g5.js +2 -0
  54. package/dist/{index-vtsd74g0.js → index-sq5j8bjn.js} +6 -6
  55. package/dist/{index-t5cfkz1e.js → index-v77bb0rm.js} +3 -3
  56. package/dist/{index-v16qz1fa.js → index-vhz1c474.js} +2 -2
  57. package/dist/{index-ywnfz6nm.js → index-wxb9dgwq.js} +1 -1
  58. package/dist/index-x4z055t8.js +3 -0
  59. package/dist/{index-haww9jpq.js → index-xetd52ad.js} +2 -2
  60. package/dist/index-xjnanwbf.js +116 -0
  61. package/dist/index-xp8g5akn.js +158 -0
  62. package/dist/{index-d59kp6zr.js → index-yfk0pb00.js} +2 -2
  63. package/dist/{index-cy97asyh.js → index-zcnfj1q4.js} +3 -3
  64. package/dist/{index-c4whjk5r.js → index-zn9snqbg.js} +2 -2
  65. package/dist/index.js +3 -3
  66. package/dist/interactive-52x9hv6c.js +2 -0
  67. package/dist/key.cmd-y415ngam.js +2 -0
  68. package/dist/log-shipper-02rqvtq8.js +2 -0
  69. package/dist/{path-utils-r4df8d3w.js → path-utils-qgkdkp5j.js} +1 -1
  70. package/dist/plugin-system-yxztgnyz.js +2 -0
  71. package/dist/prereqs-runner-w7z2dwa6.js +2 -0
  72. package/dist/profile-mount-ga5z1vx9.js +2 -0
  73. package/dist/prune-stale-shims-vejvb1rj.js +2 -0
  74. package/dist/register-core-pv4qe8zc.js +2 -0
  75. package/dist/secondary-profile-attach-h9kga6ss.js +2 -0
  76. package/dist/subprocess-p9bv9nqz.js +2 -0
  77. package/dist/telemetry-1d3t1mbf.js +2 -0
  78. package/dist/tunnel-bootstrap-esay39d5.js +2 -0
  79. package/package.json +1 -1
  80. package/dist/agent-config-v9d7gcz0.js +0 -2
  81. package/dist/app-xc9c1d71.js +0 -2
  82. package/dist/autostart.cmd-ahet7b1t.js +0 -2
  83. package/dist/bootstrap-workspace-3pb8qjsh.js +0 -2
  84. package/dist/bootstrap.service-9m7m1ksa.js +0 -2
  85. package/dist/bridge-client-xvqy3n15.js +0 -2
  86. package/dist/daemon-profile-sg8fp50z.js +0 -2
  87. package/dist/gateway-client-ermpz52n.js +0 -2
  88. package/dist/index-5021rk8n.js +0 -3
  89. package/dist/index-b3v08awy.js +0 -3
  90. package/dist/index-mmx2kp76.js +0 -16
  91. package/dist/index-ss5gez2p.js +0 -2
  92. package/dist/index-tts92sdm.js +0 -5
  93. package/dist/index-x83tcr8f.js +0 -158
  94. package/dist/index-zcmhy3jv.js +0 -116
  95. package/dist/interactive-vbz68zh5.js +0 -2
  96. package/dist/key.cmd-f6rjvjy8.js +0 -2
  97. package/dist/log-shipper-0erbwn0q.js +0 -2
  98. package/dist/plugin-system-byzwda4c.js +0 -2
  99. package/dist/prereqs-runner-gca0bytz.js +0 -2
  100. package/dist/profile-mount-s4mc1x18.js +0 -2
  101. package/dist/prune-stale-shims-4nqtv0xt.js +0 -2
  102. package/dist/register-core-ws2axmcf.js +0 -2
  103. package/dist/secondary-profile-attach-em1tq7vq.js +0 -2
  104. package/dist/subprocess-4gg77skg.js +0 -2
  105. package/dist/telemetry-nmtywcba.js +0 -2
  106. package/dist/tunnel-bootstrap-tjwz90pb.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{promises as u,closeSync as N,constants as k,fstatSync as D,lstatSync as W,openSync as B,readSync as Y,realpathSync as w,statSync as M}from"fs";import l from"os";import o from"path";function R(t,e){let r=parseInt(process.env[t]??"",10);return Number.isInteger(r)&&r>0?r:e}var E=R("VIBECONTROLS_MAX_FILE_READ_BYTES",10485760),g=R("VIBECONTROLS_MAX_DIRECTORY_ENTRIES",2000),_=[/(?:^|\/)\.env(?:\..*)?$/,/\.pem$/,/\.key$/,/(?:^|\/)id_rsa(?:$|\.)/,/(?:^|\/)\.ssh(?:\/|$)/,/(?:^|\/)\.git\/config$/,/(?:^|\/)\.npmrc$/],P=["/","/etc","/usr","/bin","/sbin","/var","/opt"],v=["C:\\Windows","C:\\Program Files","C:\\Program Files (x86)","C:\\ProgramData"];function x(){return process.platform==="win32"?v:P}function c(t){return process.platform==="win32"?t.toLowerCase():t}function I(){let t=process.env.VIBECONTROLS_ALLOWED_ROOTS;if(t)return t.split(o.delimiter).map((e)=>e.trim()).filter(Boolean);return[process.cwd(),l.homedir(),l.tmpdir()].filter(Boolean)}async function f(t){try{return await u.realpath(t)}catch{return null}}async function T(){let t=[];for(let e of I()){let r=o.resolve(e),s=await f(r)??r;if(!t.includes(s))t.push(s)}return t}function z(t,e){let r=o.relative(e,t);return r===""||!!r&&!r.startsWith("..")&&!o.isAbsolute(r)}async function h(t){if(!(await T()).some((r)=>z(t,r)))throw Error("Access denied: path is outside allowed directories")}async function A(t){let e=o.dirname(t);while(e&&e!==o.dirname(e)){let s=await f(e);if(s)return s;e=o.dirname(e)}let r=await f(e||o.parse(t).root);if(!r)throw Error("Path parent does not exist");return r}async function C(t){if((await u.lstat(o.resolve(t)).catch(()=>null))?.isSymbolicLink())throw Error("Access denied: symbolic links are not allowed")}function zt(t){return _.some((e)=>e.test(t))}function L(t){if(!t.startsWith("/"))return!1;let e=t.replace(/\\/g,"/").replace(/\/+/g,"/");return P.some((r)=>e===r||e.startsWith(r==="/"?"/":`${r}/`))}function Tr(t){let e=o.resolve(t),r=(()=>{try{return w(e)}catch{return null}})(),s=r?[e,r]:[e],n=l.tmpdir(),d=l.homedir(),S=(()=>{try{return w(n)}catch{return n}})(),b=(()=>{try{return w(d)}catch{return d}})(),y=o.sep,O=[n,S,d,b];for(let m of s){let i=c(m);if(O.some((p)=>{let a=c(p);return i===a||i.startsWith(a+y)}))return!1}if(s.some((m)=>{let i=c(m);return x().some((p)=>{let a=c(p);return i===a||i.startsWith(a+y)})}))return!0;return L(t)}async function oe(t,e={}){if(!t||t.includes("\x00"))throw Error("Invalid path");let r=o.resolve(t);await C(r);let s=await f(r);if(s)return await h(s),{path:r,realPath:s};if(e.mustExist)throw Error("Path not found");if(!e.forWrite)return await h(r),{path:r,realPath:r};let n=await A(r);return await h(n),{path:r,realPath:r}}async function di(t){let e=await u.stat(t);if(e.isFile()&&e.size>E)throw Error(`File is too large to read safely (${e.size} bytes, max ${E})`)}async function wt(t){let e=await u.opendir(t),r=[];try{for await(let s of e)if(r.push(s),r.length>g)throw Error(`Directory has too many entries (>${g})`)}finally{let s=e.close?.();if(s&&typeof s.catch==="function")await s.catch(()=>{return})}return r}
3
- export{zt,Tr,oe,di,wt};
2
+ import{promises as u,closeSync as N,constants as k,fstatSync as D,lstatSync as W,openSync as B,readSync as Y,realpathSync as w,statSync as M}from"fs";import l from"os";import o from"path";function R(t,e){let r=parseInt(process.env[t]??"",10);return Number.isInteger(r)&&r>0?r:e}var E=R("VIBECONTROLS_MAX_FILE_READ_BYTES",10485760),g=R("VIBECONTROLS_MAX_DIRECTORY_ENTRIES",2000),_=[/(?:^|\/)\.env(?:\..*)?$/,/\.pem$/,/\.key$/,/(?:^|\/)id_rsa(?:$|\.)/,/(?:^|\/)\.ssh(?:\/|$)/,/(?:^|\/)\.git\/config$/,/(?:^|\/)\.npmrc$/],P=["/","/etc","/usr","/bin","/sbin","/var","/opt"],v=["C:\\Windows","C:\\Program Files","C:\\Program Files (x86)","C:\\ProgramData"];function x(){return process.platform==="win32"?v:P}function c(t){return process.platform==="win32"?t.toLowerCase():t}function I(){let t=process.env.VIBECONTROLS_ALLOWED_ROOTS;if(t)return t.split(o.delimiter).map((e)=>e.trim()).filter(Boolean);return[process.cwd(),l.homedir(),l.tmpdir()].filter(Boolean)}async function f(t){try{return await u.realpath(t)}catch{return null}}async function T(){let t=[];for(let e of I()){let r=o.resolve(e),s=await f(r)??r;if(!t.includes(s))t.push(s)}return t}function z(t,e){let r=o.relative(e,t);return r===""||!!r&&!r.startsWith("..")&&!o.isAbsolute(r)}async function h(t){if(!(await T()).some((r)=>z(t,r)))throw Error("Access denied: path is outside allowed directories")}async function A(t){let e=o.dirname(t);while(e&&e!==o.dirname(e)){let s=await f(e);if(s)return s;e=o.dirname(e)}let r=await f(e||o.parse(t).root);if(!r)throw Error("Path parent does not exist");return r}async function C(t){if((await u.lstat(o.resolve(t)).catch(()=>null))?.isSymbolicLink())throw Error("Access denied: symbolic links are not allowed")}function ir(t){return _.some((e)=>e.test(t))}function L(t){if(!t.startsWith("/"))return!1;let e=t.replace(/\\/g,"/").replace(/\/+/g,"/");return P.some((r)=>e===r||e.startsWith(r==="/"?"/":`${r}/`))}function Fr(t){let e=o.resolve(t),r=(()=>{try{return w(e)}catch{return null}})(),s=r?[e,r]:[e],n=l.tmpdir(),d=l.homedir(),S=(()=>{try{return w(n)}catch{return n}})(),b=(()=>{try{return w(d)}catch{return d}})(),y=o.sep,O=[n,S,d,b];for(let m of s){let i=c(m);if(O.some((p)=>{let a=c(p);return i===a||i.startsWith(a+y)}))return!1}if(s.some((m)=>{let i=c(m);return x().some((p)=>{let a=c(p);return i===a||i.startsWith(a+y)})}))return!0;return L(t)}async function oe(t,e={}){if(!t||t.includes("\x00"))throw Error("Invalid path");let r=o.resolve(t);await C(r);let s=await f(r);if(s)return await h(s),{path:r,realPath:s};if(e.mustExist)throw Error("Path not found");if(!e.forWrite)return await h(r),{path:r,realPath:r};let n=await A(r);return await h(n),{path:r,realPath:r}}async function Ei(t){let e=await u.stat(t);if(e.isFile()&&e.size>E)throw Error(`File is too large to read safely (${e.size} bytes, max ${E})`)}async function Ft(t){let e=await u.opendir(t),r=[];try{for await(let s of e)if(r.push(s),r.length>g)throw Error(`Directory has too many entries (>${g})`)}finally{let s=e.close?.();if(s&&typeof s.catch==="function")await s.catch(()=>{return})}return r}
3
+ export{ir,Fr,oe,Ei,Ft};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{e}from"./index-0qjbnyg4.js";import{E}from"./index-w0m3jm0s.js";import{Mr}from"./index-tts92sdm.js";import{Ke,Lt,de,mt,Xe,ze,K}from"./index-mmx2kp76.js";var T=["tunnel","session","ai","plan","gitops","security","desk"];class Te{providers=new Map;providerOrder=new Map;defaults=new Map;services=new Map;db;constructor(t){this.db=t}getDb(){return this.db}setProviderDefault(t,r){this.defaults.set(t,r)}clearProviderDefault(t,r){if(!r||this.defaults.get(t)===r)this.defaults.delete(t)}async hydrateDefaultsFromDb(){if(!this.db)return;for(let t of T)try{let r=await this.db.getConfig(`provider:default:${t}`);if(r)this.defaults.set(t,r)}catch{}}registerProvider(t,r,i){if(!this.providers.has(t))this.providers.set(t,new Map),this.providerOrder.set(t,[]);let n=this.providers.get(t),o=this.providerOrder.get(t);if(n.has(i))e().logger.info("service-registry",`Updating ${t} provider from plugin '${i}'`);else e().logger.info("service-registry",`Registered ${t} provider from plugin '${i}'`);if(n.set(i,{provider:r,pluginName:i,registeredAt:new Date}),!o.includes(i))o.push(i)}getProvider(t){let r=this.providers.get(t);if(!r||r.size===0)return;let i=this.defaults.get(t);if(i&&r.has(i))return r.get(i).provider;let n=this.providerOrder.get(t);if(n&&n.length>0){let o=n[0];return r.get(o)?.provider}return}getProviderByName(t,r){let i=this.providers.get(t);if(!i)return;return i.get(r)?.provider}hasProvider(t){let r=this.providers.get(t);return!!r&&r.size>0}unregisterProvider(t,r){let i=this.providers.get(t);if(!i)return!1;let n=i.delete(r);if(n){let o=this.providerOrder.get(t);if(o){let s=o.indexOf(r);if(s!==-1)o.splice(s,1)}this.clearProviderDefault(t,r),e().logger.info("service-registry",`Unregistered ${t} provider from plugin '${r}'`)}return n}unregisterPlugin(t){for(let r of T)this.unregisterProvider(r,t);this.unregisterServices(t)}listProvidersForType(t){let r=this.providers.get(t);if(!r)return[];let i=this.defaults.get(t);if(!i||!r.has(i)){let n=this.providerOrder.get(t);i=n&&n.length>0?n[0]:void 0}return Array.from(r.keys()).map((n)=>({pluginName:n,isDefault:n===i}))}registerService(t,r,i){let n=`${t}:${r}`;this.services.set(n,{service:i,pluginName:t}),e().logger.debug("service-registry",`Registered service '${n}'`)}getService(t,r){let i=`${t}:${r}`;return this.services.get(i)?.service}unregisterServices(t){let r=[];for(let[i,n]of this.services)if(n.pluginName===t)r.push(i);for(let i of r)this.services.delete(i);if(r.length>0)e().logger.info("service-registry",`Unregistered ${r.length} services from ${t}`)}listProviders(){let t=[];for(let[r,i]of this.providers)for(let[n,o]of i)t.push({type:r,name:n,pluginName:o.pluginName});return t}listServices(){return Array.from(this.services.entries()).map(([t,r])=>({pluginName:r.pluginName,serviceName:t.split(":").slice(1).join(":")}))}clear(){this.providers.clear(),this.providerOrder.clear(),this.defaults.clear(),this.services.clear()}}class Ee{statusSections=[];doctorChecks=[];addStatusSection(t){this.statusSections.push(t)}addDoctorCheck(t){this.doctorChecks.push(t)}getStatusSections(){return this.statusSections}getDoctorChecks(){return this.doctorChecks}}var y=null;function Ti(t){y=t}function Pt(){if(!y)y=new Ee;return y}import{extname as N,relative as j,resolve as O}from"path";import{realpath as b}from"fs/promises";var B=["'self'","http://localhost:*","http://127.0.0.1:*","https://localhost:*","https://127.0.0.1:*","https://*.local.burdenoff.com","https://vibecontrols.com","https://*.vibecontrols.com","https://burdenoff.com","https://app.burdenoff.com","https://alphaapp.burdenoff.com"],R=!1;function f(){let t=process.env.VIBE_UI_FRAME_ANCESTORS?.trim(),r=t?t.split(/[\s,]+/).filter(Boolean):B;if(t&&!R&&(r.includes("*")||!r.includes("'self'")))R=!0,console.warn(`[ui-server] VIBE_UI_FRAME_ANCESTORS override does not include "'self'" or contains "*". This significantly weakens CSP frame-ancestors and is almost never intended. Override: ${t}`);return`frame-ancestors ${r.join(" ")}`}var M={".html":"text/html",".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".map":"application/json",".wasm":"application/wasm"};function F(t){return M[N(t).toLowerCase()]||"application/octet-stream"}var k=`<script>
2
+ import{e}from"./index-7wm4bqx5.js";import{E}from"./index-1t74r13z.js";import{lr}from"./index-awj0w14r.js";import{je,Kt,me,yt,rt,it,K}from"./index-qzwbctkv.js";var T=["tunnel","session","ai","plan","gitops","security","desk"];class xe{providers=new Map;providerOrder=new Map;defaults=new Map;services=new Map;db;constructor(t){this.db=t}getDb(){return this.db}setProviderDefault(t,r){this.defaults.set(t,r)}clearProviderDefault(t,r){if(!r||this.defaults.get(t)===r)this.defaults.delete(t)}async hydrateDefaultsFromDb(){if(!this.db)return;for(let t of T)try{let r=await this.db.getConfig(`provider:default:${t}`);if(r)this.defaults.set(t,r)}catch{}}registerProvider(t,r,i){if(!this.providers.has(t))this.providers.set(t,new Map),this.providerOrder.set(t,[]);let n=this.providers.get(t),o=this.providerOrder.get(t);if(n.has(i))e().logger.info("service-registry",`Updating ${t} provider from plugin '${i}'`);else e().logger.info("service-registry",`Registered ${t} provider from plugin '${i}'`);if(n.set(i,{provider:r,pluginName:i,registeredAt:new Date}),!o.includes(i))o.push(i)}getProvider(t){let r=this.providers.get(t);if(!r||r.size===0)return;let i=this.defaults.get(t);if(i&&r.has(i))return r.get(i).provider;let n=this.providerOrder.get(t);if(n&&n.length>0){let o=n[0];return r.get(o)?.provider}return}getProviderByName(t,r){let i=this.providers.get(t);if(!i)return;return i.get(r)?.provider}hasProvider(t){let r=this.providers.get(t);return!!r&&r.size>0}unregisterProvider(t,r){let i=this.providers.get(t);if(!i)return!1;let n=i.delete(r);if(n){let o=this.providerOrder.get(t);if(o){let s=o.indexOf(r);if(s!==-1)o.splice(s,1)}this.clearProviderDefault(t,r),e().logger.info("service-registry",`Unregistered ${t} provider from plugin '${r}'`)}return n}unregisterPlugin(t){for(let r of T)this.unregisterProvider(r,t);this.unregisterServices(t)}listProvidersForType(t){let r=this.providers.get(t);if(!r)return[];let i=this.defaults.get(t);if(!i||!r.has(i)){let n=this.providerOrder.get(t);i=n&&n.length>0?n[0]:void 0}return Array.from(r.keys()).map((n)=>({pluginName:n,isDefault:n===i}))}registerService(t,r,i){let n=`${t}:${r}`;this.services.set(n,{service:i,pluginName:t}),e().logger.debug("service-registry",`Registered service '${n}'`)}getService(t,r){let i=`${t}:${r}`;return this.services.get(i)?.service}unregisterServices(t){let r=[];for(let[i,n]of this.services)if(n.pluginName===t)r.push(i);for(let i of r)this.services.delete(i);if(r.length>0)e().logger.info("service-registry",`Unregistered ${r.length} services from ${t}`)}listProviders(){let t=[];for(let[r,i]of this.providers)for(let[n,o]of i)t.push({type:r,name:n,pluginName:o.pluginName});return t}listServices(){return Array.from(this.services.entries()).map(([t,r])=>({pluginName:r.pluginName,serviceName:t.split(":").slice(1).join(":")}))}clear(){this.providers.clear(),this.providerOrder.clear(),this.defaults.clear(),this.services.clear()}}class Ie{statusSections=[];doctorChecks=[];addStatusSection(t){this.statusSections.push(t)}addDoctorCheck(t){this.doctorChecks.push(t)}getStatusSections(){return this.statusSections}getDoctorChecks(){return this.doctorChecks}}var y=null;function Fi(t){y=t}function Nt(){if(!y)y=new Ie;return y}import{extname as N,relative as j,resolve as O}from"path";import{realpath as b}from"fs/promises";var B=["'self'","http://localhost:*","http://127.0.0.1:*","https://localhost:*","https://127.0.0.1:*","https://*.local.burdenoff.com","https://vibecontrols.com","https://*.vibecontrols.com","https://burdenoff.com","https://app.burdenoff.com","https://alphaapp.burdenoff.com"],R=!1;function f(){let t=process.env.VIBE_UI_FRAME_ANCESTORS?.trim(),r=t?t.split(/[\s,]+/).filter(Boolean):B;if(t&&!R&&(r.includes("*")||!r.includes("'self'")))R=!0,console.warn(`[ui-server] VIBE_UI_FRAME_ANCESTORS override does not include "'self'" or contains "*". This significantly weakens CSP frame-ancestors and is almost never intended. Override: ${t}`);return`frame-ancestors ${r.join(" ")}`}var M={".html":"text/html",".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".map":"application/json",".wasm":"application/wasm"};function F(t){return M[N(t).toLowerCase()]||"application/octet-stream"}var k=`<script>
3
3
  window.__VIBE_AUTH__={apiKey:null};
4
4
  (function(){
5
5
  var p=new URLSearchParams(window.location.search);
@@ -18,7 +18,7 @@ window.__VIBE_AUTH__={apiKey:null};
18
18
  }
19
19
  });
20
20
  })();
21
- </script>`;function p(t){if(!t.headers.has("Content-Security-Policy"))t.headers.set("Content-Security-Policy",f());return t}function U(t){if(t.includes("</head>"))return t.replace("</head>",k+"</head>");if(t.includes("</body>"))return t.replace("</body>",k+"</body>");return t+k}function S(t){return t.replace(/[&<>"']/g,(r)=>{switch(r){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";case"'":return"&#39;";default:return r}})}function A(t,r){let i=j(t,r);return i===""||!!i&&!i.startsWith("..")&&!i.startsWith("/")}async function D(t,r,i){let n=Mr(t);if(!n)return null;let o=await b(n),s=await b(r);if(!A(o,s))return null;let a=O(s,i),w=await b(a).catch(()=>a);if(!A(s,w))return null;return a}function L(t){return!1}function Br(t,r="/api/profiles/default/agent/ui-exchange"){let i=t.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),n=r.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return`<!doctype html>
21
+ </script>`;function p(t){if(!t.headers.has("Content-Security-Policy"))t.headers.set("Content-Security-Policy",f());return t}function U(t){if(t.includes("</head>"))return t.replace("</head>",k+"</head>");if(t.includes("</body>"))return t.replace("</body>",k+"</body>");return t+k}function S(t){return t.replace(/[&<>"']/g,(r)=>{switch(r){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";case"'":return"&#39;";default:return r}})}function A(t,r){let i=j(t,r);return i===""||!!i&&!i.startsWith("..")&&!i.startsWith("/")}async function D(t,r,i){let n=lr(t);if(!n)return null;let o=await b(n),s=await b(r);if(!A(o,s))return null;let a=O(s,i),w=await b(a).catch(()=>a);if(!A(s,w))return null;return a}function L(t){return!1}function vr(t,r="/api/profiles/default/agent/ui-exchange"){let i=t.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),n=r.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return`<!doctype html>
22
22
  <html>
23
23
  <head>
24
24
  <meta charset="utf-8">
@@ -79,5 +79,5 @@ window.__VIBE_AUTH__={apiKey:null};
79
79
  <h1>VibeControls Plugin UIs</h1>
80
80
  ${t.length>0?`<ul>${r}</ul>`:'<p class="empty">No plugins with UIs installed.</p>'}
81
81
  </body>
82
- </html>`}function xi(t){return new E({prefix:"/ui"}).onAfterHandle(({set:r})=>{r.headers["Content-Security-Policy"]=f()}).get("/",()=>{let r=t.getAllPlugins().filter((i)=>i.ui).map((i)=>({name:i.name,title:i.ui?.title??i.name,tags:i.tags}));return p(new Response(V(r),{headers:{"Content-Type":"text/html; charset=utf-8"}}))}).get("/*",async({params:r,request:i,set:n})=>{let s=(r["*"]||"").split("/").filter(Boolean);if(s.length===0)return n.status=404,{error:"Plugin not specified"};let a=s[0];if(!de(a))return n.status=404,{error:`Invalid plugin name '${a}'`};let w=s.length===1||s.length===2&&!s[1],C=i.headers.get("sec-fetch-mode"),I=w&&(C==="navigate"||C===null),x=ze(i,a);if(!(!!x&&Xe(x,a))){if(I)return n.status=200,n.headers["content-type"]="text/html; charset=utf-8",n.headers["Content-Security-Policy"]=f(),Br(a);return n.status=401,{error:"Unauthorized: UI plugin cookie required"}}let c=t.getPluginByKey(a),P=s.slice(1).join("/");if(c&&s.length>=2){let l=t.getPluginByKey(s[1]);if(l?.ui)c=l,P=s.slice(2).join("/")}if(!c?.ui)return n.status=404,{error:`No UI available for plugin '${a}'`};if(c.ui.devUrl){if(!L(c.ui.devUrl))return n.status=403,{error:"Plugin UI dev proxy is disabled for this URL"};try{let l=new URL(c.ui.devUrl);l.pathname=`/${P}`.replace(/\/+/g,"/");let h=await fetch(l,{redirect:"manual"}),u=await h.arrayBuffer(),d=new Headers;return h.headers.forEach((m,g)=>d.set(g,m)),p(new Response(u,{status:h.status,headers:d}))}catch{return n.status=502,{error:`Failed to proxy to dev server at ${c.ui.devUrl}`}}}if(c.ui.staticDir){let l=c.ui.staticDir,u=await D(c,l,P||"index.html");if(!u)return n.status=403,{error:"Access denied"};let d=Bun.file(u);if(await d.exists()){let v=F(u);if(v==="text/html"){let _=await d.text();return p(new Response(U(_),{headers:{"Content-Type":"text/html; charset=utf-8"}}))}return p(new Response(d,{headers:{"Content-Type":v}}))}let m=await D(c,l,"index.html"),g=m?Bun.file(m):null;if(g&&await g.exists()){let v=await g.text();return p(new Response(U(v),{headers:{"Content-Type":"text/html; charset=utf-8"}}))}return n.status=404,{error:"File not found"}}return n.status=404,{error:"No UI configuration (neither staticDir nor devUrl)"}})}function ke(){return{getAgentApiKey:()=>K(),verifyIframeToken:(t,r)=>Ke(t,r),verifyUiCookieToken:(t,r)=>Xe(t,r),issueUiCookieToken:(t,r)=>{let i=mt(t,r);return{token:i.token,expiresAt:Date.parse(i.expiresAt)}},getIframeTokenFromRequest:(t,r)=>Lt(t,r),getUiCookieFromRequest:(t,r)=>ze(t,r),isValidUiPluginName:(t)=>de(t),frameAncestorsCsp:()=>f()}}
83
- export{Te,Ee,Ti,Pt,Br,xi,ke};
82
+ </html>`}function Oi(t){return new E({prefix:"/ui"}).onAfterHandle(({set:r})=>{r.headers["Content-Security-Policy"]=f()}).get("/",()=>{let r=t.getAllPlugins().filter((i)=>i.ui).map((i)=>({name:i.name,title:i.ui?.title??i.name,tags:i.tags}));return p(new Response(V(r),{headers:{"Content-Type":"text/html; charset=utf-8"}}))}).get("/*",async({params:r,request:i,set:n})=>{let s=(r["*"]||"").split("/").filter(Boolean);if(s.length===0)return n.status=404,{error:"Plugin not specified"};let a=s[0];if(!me(a))return n.status=404,{error:`Invalid plugin name '${a}'`};let w=s.length===1||s.length===2&&!s[1],C=i.headers.get("sec-fetch-mode"),I=w&&(C==="navigate"||C===null),x=it(i,a);if(!(!!x&&rt(x,a))){if(I)return n.status=200,n.headers["content-type"]="text/html; charset=utf-8",n.headers["Content-Security-Policy"]=f(),vr(a);return n.status=401,{error:"Unauthorized: UI plugin cookie required"}}let c=t.getPluginByKey(a),P=s.slice(1).join("/");if(c&&s.length>=2){let l=t.getPluginByKey(s[1]);if(l?.ui)c=l,P=s.slice(2).join("/")}if(!c?.ui)return n.status=404,{error:`No UI available for plugin '${a}'`};if(c.ui.devUrl){if(!L(c.ui.devUrl))return n.status=403,{error:"Plugin UI dev proxy is disabled for this URL"};try{let l=new URL(c.ui.devUrl);l.pathname=`/${P}`.replace(/\/+/g,"/");let h=await fetch(l,{redirect:"manual"}),u=await h.arrayBuffer(),d=new Headers;return h.headers.forEach((m,g)=>d.set(g,m)),p(new Response(u,{status:h.status,headers:d}))}catch{return n.status=502,{error:`Failed to proxy to dev server at ${c.ui.devUrl}`}}}if(c.ui.staticDir){let l=c.ui.staticDir,u=await D(c,l,P||"index.html");if(!u)return n.status=403,{error:"Access denied"};let d=Bun.file(u);if(await d.exists()){let v=F(u);if(v==="text/html"){let _=await d.text();return p(new Response(U(_),{headers:{"Content-Type":"text/html; charset=utf-8"}}))}return p(new Response(d,{headers:{"Content-Type":v}}))}let m=await D(c,l,"index.html"),g=m?Bun.file(m):null;if(g&&await g.exists()){let v=await g.text();return p(new Response(U(v),{headers:{"Content-Type":"text/html; charset=utf-8"}}))}return n.status=404,{error:"File not found"}}return n.status=404,{error:"No UI configuration (neither staticDir nor devUrl)"}})}function ve(){return{getAgentApiKey:()=>K(),verifyIframeToken:(t,r)=>je(t,r),verifyUiCookieToken:(t,r)=>rt(t,r),issueUiCookieToken:(t,r)=>{let i=yt(t,r);return{token:i.token,expiresAt:Date.parse(i.expiresAt)}},getIframeTokenFromRequest:(t,r)=>Kt(t,r),getUiCookieFromRequest:(t,r)=>it(t,r),isValidUiPluginName:(t)=>me(t),frameAncestorsCsp:()=>f()}}
83
+ export{xe,Ie,Fi,Nt,vr,Oi,ve};
@@ -0,0 +1,16 @@
1
+ // @bun
2
+ import{E}from"./index-1t74r13z.js";import{R,B,N,e}from"./index-7wm4bqx5.js";import{J,de,w,M}from"./index-j99tkngg.js";import{ji}from"./index-x4z055t8.js";import{randomBytes as P,createHmac as X,timingSafeEqual as ke}from"crypto";var F=600,ie=600,H=P(32),x="p2.";function S(t){if(!t.startsWith("/"))return`/${t}`;return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}var Ee=/^\/terminal\/[A-Za-z0-9_-]{1,128}(?:\/.*)?$/,_e=/^\/ui\/[a-z0-9-]{1,64}(?:\/.*)?$/,Ie=/^\/plan\/[A-Za-z0-9_-]{1,128}(?:\/.*)?$/,xe=/^\/git(?:\/.*)?$/,Pe="/ws/logs",Se=/^\/code-server(?:\/.*)?$/,Te=/^\/api\/plugins\/[a-z0-9-]{1,64}\/ui(?:\/.*)?$/;function se(t){if(typeof t!=="string"||t.length===0)return!1;if(t.includes("\x00")||t.includes(`
3
+ `)||t.includes("|"))return!1;if(t.includes(".."))return!1;if(new Set(["/","/api","/api/agent","/api/plugins","/api/profiles","/health","/metrics","/ws","/api/ai","/api/logs"]).has(t))return!1;if(Ee.test(t))return!0;if(_e.test(t))return!0;if(Ie.test(t))return!0;if(xe.test(t))return!0;if(t===Pe)return!0;if(Se.test(t))return!0;if(Te.test(t))return!0;return!1}var be=new Set(["*","GET","HEAD","POST","PUT","PATCH","DELETE","OPTIONS"]);function ve(t){if(!t||t.length===0)return["*"];let n=new Set,r=[];for(let i of t){if(typeof i!=="string")continue;let s=i.toUpperCase();if(!be.has(s))throw Error(`invalid method: ${i}`);if(!n.has(s))n.add(s),r.push(s)}if(r.length===0)return["*"];return r.sort()}function oe(t,n){if(t.includes("*"))return!0;return t.includes(n.toUpperCase())}var $e=/^[A-Za-z0-9_-]{1,128}$/;function we(t){return typeof t==="string"&&$e.test(t)}function Z(t,n,r){return X("sha256",H).update(`${t}
4
+ ${n}
5
+ ${r}`).digest("hex")}var C=new Map;function Fe(t){for(let[n,r]of C)if(r<=t)C.delete(n)}function ae(t,n){let r=Date.parse(n);if(!Number.isFinite(r))return;C.set(t,r)}function ue(t){return Fe(Date.now()),C.has(t)}function j(t,n,r,i){return X("sha256",H).update(`v2
6
+ ${t}
7
+ ${n}
8
+ ${r}
9
+ ${i}`).digest("hex")}function O(t){return Buffer.from(t,"utf8").toString("base64").replace(/=+$/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function D(t){try{let n=t.replace(/-/g,"+").replace(/_/g,"/"),r=n.length%4===0?n:n+"=".repeat(4-n.length%4);return Buffer.from(r,"base64").toString("utf8")}catch{return null}}var re=16;function Ke(t){if(t.length>re)throw Error(`pathPrefixes exceeds maximum count (${t.length} > ${re})`);let n=new Set,r=[];for(let i of t){if(!i||typeof i!=="string")continue;if(i.includes("..")||i.includes("\x00"))throw Error("invalid pathPrefix");let s=S(i);if(!se(s))throw Error(`pathPrefix '${s}' is not an allowed iframe surface`);if(!n.has(s))n.add(s),r.push(s)}return r.sort()}function fr(t,n=F){if(!t||typeof t!=="string")throw Error("pathPrefix is required");if(t.includes("..")||t.includes("\x00"))throw Error("invalid pathPrefix");let r=Math.min(Math.max(1,Math.floor(n||F)),ie),i=S(t);if(!se(i))throw Error(`pathPrefix '${i}' is not an allowed iframe surface`);let s=new Date(Date.now()+r*1000).toISOString(),o=P(16).toString("hex"),a=Z(i,s,o);return{token:`${s}|${o}|${a}`,expiresAt:s}}function Ut(t,n=F){if(!t||!Array.isArray(t.pathPrefixes)||t.pathPrefixes.length===0)throw Error("pathPrefixes is required");let r=Ke(t.pathPrefixes);if(r.length===0)throw Error("pathPrefixes is required");let i=ve(t.methods),s=Math.min(Math.max(1,Math.floor(n||F)),ie),o=new Date(Date.now()+s*1000).toISOString(),a=P(16).toString("hex"),c=O(JSON.stringify(r)),u=O(JSON.stringify(i)),f=`${x}${c}.${u}`,l=j(c,u,o,a);return{token:`${o}|${a}|${f}|${l}`,expiresAt:o}}function k(t,n){if(t.length!==n.length)return!1;try{return ke(Buffer.from(t,"hex"),Buffer.from(n,"hex"))}catch{return!1}}function U(t,n){let r=S(n);return t===r||t.startsWith(`${r}/`)}function je(t,n,r="*"){return Hr(t,n,r).ok}function Hr(t,n,r="*"){if(!t||typeof t!=="string")return{ok:!1,reason:"missing"};let i=t.split("|");if(i.length===3)return Ne(i,n);if(i.length===4)return Ce(i,n,r);return{ok:!1,reason:"malformed"}}function Ne(t,n){let[r,i,s]=t;if(!r||!i||!s)return{ok:!1,reason:"malformed"};if(!_(r))return{ok:!1,reason:"expired"};let o=n.split("/").filter(Boolean),a=["/"],c="";for(let u of o)c+=`/${u}`,a.push(c);for(let u of a){let f=Z(S(u),r,i);if(k(f,s)){if(!U(n,u))return{ok:!1,reason:"path_mismatch"};if(ue(i))return{ok:!1,reason:"replayed"};return ae(i,r),{ok:!0}}}return{ok:!1,reason:"bad_signature"}}function Ce(t,n,r){let[i,s,o,a]=t;if(!i||!s||!o||!a)return{ok:!1,reason:"malformed"};if(!o.startsWith(x))return{ok:!1,reason:"malformed"};if(!_(i))return{ok:!1,reason:"expired"};let u=o.slice(x.length).split("."),f=u[0]??"",l=u[1]??O(JSON.stringify(["*"]));if(!f)return{ok:!1,reason:"malformed"};let h=j(f,l,i,s);if(!k(h,a))return{ok:!1,reason:"bad_signature"};let v=D(f);if(v===null)return{ok:!1,reason:"malformed"};let y;try{y=JSON.parse(v)}catch{return{ok:!1,reason:"malformed"}}if(!Array.isArray(y))return{ok:!1,reason:"malformed"};let A=D(l),I=["*"];if(A!==null)try{let g=JSON.parse(A);if(Array.isArray(g)&&g.every((d)=>typeof d==="string"))I=g}catch{return{ok:!1,reason:"malformed"}}if(r!=="*"&&!oe(I,r))return{ok:!1,reason:"method_mismatch"};for(let g of y){if(typeof g!=="string")continue;if(U(n,g)){if(ue(s))return{ok:!1,reason:"replayed"};return ae(s,i),{ok:!0}}}return{ok:!1,reason:"path_mismatch"}}function qe(t,n,r="*"){if(!t||typeof t!=="string")return!1;let i=t.split("|");if(i.length===3){let[s,o,a]=i;if(!s||!o||!a)return!1;if(!_(s))return!1;let c=n.split("/").filter(Boolean),u=["/"],f="";for(let l of c)f+=`/${l}`,u.push(f);for(let l of u){let h=Z(S(l),s,o);if(k(h,a))return U(n,l)}return!1}if(i.length===4){let[s,o,a,c]=i;if(!s||!o||!a||!c)return!1;if(!a.startsWith(x))return!1;if(!_(s))return!1;let f=a.slice(x.length).split("."),l=f[0]??"",h=f[1]??O(JSON.stringify(["*"]));if(!l)return!1;let v=j(l,h,s,o);if(!k(v,c))return!1;let y=D(l);if(y===null)return!1;let A;try{A=JSON.parse(y)}catch{return!1}if(!Array.isArray(A))return!1;let I=D(h),g=["*"];if(I!==null)try{let d=JSON.parse(I);if(Array.isArray(d)&&d.every((Ae)=>typeof Ae==="string"))g=d}catch{return!1}if(r!=="*"&&!oe(g,r))return!1;for(let d of A){if(typeof d!=="string")continue;if(U(n,d))return!0}return!1}return!1}function _(t){let n=Date.parse(t);return Number.isFinite(n)&&Date.now()<n}function Kt(t,n){let r=t.headers.get("x-vibe-iframe-token")??t.headers.get("X-Vibe-Iframe-Token");if(r)return r;try{let i=new URL(t.url).searchParams.get("vt");if(i)return i}catch{}return null}var q="tc1|",z=600,Oe=600;function ce(t,n,r){return X("sha256",H).update(`tc1
10
+ ${t}
11
+ ${n}
12
+ ${r}`).digest("hex")}function Li(t,n=z){if(!we(t))throw Error("invalid sid");let r=Math.min(Math.max(1,Math.floor(n||z)||z),Oe),i=new Date(Date.now()+r*1000).toISOString(),s=P(16).toString("hex"),o=ce(t,i,s);return{token:`${q}${i}|${t}|${s}|${o}`,expiresAt:i}}function pr(t,n){if(!t||typeof t!=="string")return!1;if(!t.startsWith(q))return!1;let i=t.slice(q.length).split("|");if(i.length!==4)return!1;let[s,o,a,c]=i;if(!s||!o||!a||!c)return!1;if(o!==n)return!1;if(!_(s))return!1;let u=ce(o,s,a);return k(u,c)}function Vr(t,n){let r;if(t instanceof Headers)r=t.get("cookie")??t.get("Cookie")??void 0;else r=t.cookie??t.Cookie??void 0;if(!r)return null;let i=`vt_term_${n}`;for(let s of r.split(";")){let o=s.indexOf("=");if(o===-1)continue;if(s.slice(0,o).trim()!==i)continue;return s.slice(o+1).trim()||null}return null}function Yr(t,n){return Vr(t.headers,n)}var Y="uc1|",W=600,De=600,Me=/^[a-z0-9-]{1,64}$/;function me(t){return typeof t==="string"&&Me.test(t)}function fe(t,n,r){return X("sha256",H).update(`uc1
13
+ ${t}
14
+ ${n}
15
+ ${r}`).digest("hex")}function yt(t,n=W){if(!me(t))throw Error("invalid plugin name");let r=Math.min(Math.max(1,Math.floor(n||W)||W),De),i=new Date(Date.now()+r*1000).toISOString(),s=P(16).toString("hex"),o=fe(t,i,s);return{token:`${Y}${i}|${t}|${s}|${o}`,expiresAt:i}}function rt(t,n){if(!t||typeof t!=="string")return!1;if(!t.startsWith(Y))return!1;let i=t.slice(Y.length).split("|");if(i.length!==4)return!1;let[s,o,a,c]=i;if(!s||!o||!a||!c)return!1;if(o!==n)return!1;if(!_(s))return!1;let u=fe(o,s,a);return k(u,c)}function Ue(t,n){let r;if(t instanceof Headers)r=t.get("cookie")??t.get("Cookie")??void 0;else r=t.cookie??t.Cookie??void 0;if(!r)return null;let i=`vt_ui_${n}`;for(let s of r.split(";")){let o=s.indexOf("=");if(o===-1)continue;if(s.slice(0,o).trim()!==i)continue;return s.slice(o+1).trim()||null}return null}function it(t,n){return Ue(t.headers,n)}import{timingSafeEqual as Ge}from"crypto";var Le=["/api/agent/api-key","/api/agent/reset-key","/api/agent/iframe-token","/api/agent/aliases","/api/agent/alias","/api/agent/commands","/api/agent/lifecycle","/api/agent/nuke","/api/agent/uninstall","/api/agent/gateway-auth","/api/agent/storage-key","/api/agent/sessions/share","/api/config","/api/security","/api/tasks","/api/editor","/api/code-server","/api/logs","/api/maintenance"],Xe=["/api/plugins/install","/api/plugins/prereqs"],Be=["/api/plugins/remove","/api/plugins/remove-all"],Ve=["/api/agent/update","/api/plugins/update","/api/plugins/update-all"];var Q=new Set(["GET","HEAD","OPTIONS"]);function ee(t,n){return t===n||t.startsWith(`${n}/`)}function G(t,n){return n.some((r)=>ee(t,r))}function He(t){let n=new URL(t,"http://agent.local").pathname,r=/^\/api\/profiles\/[^/]+\/(.+)$/.exec(n);if(r?.[1])return`/api/${r[1]}`;return n}function hr(t,n,r){if(t.has("admin"))return!0;let i=He(r),s=n.toUpperCase();if(i==="/api/profiles"||/^\/api\/profiles\/[^/]+$/.test(i))return Q.has(s)&&t.has("read");if(G(i,Le))return!1;if(G(i,Xe)&&t.has("plugin:install"))return!0;if(G(i,Be)&&t.has("plugin:remove"))return!0;if(G(i,Ve)&&t.has("update"))return!0;if(ee(i,"/api/mesh"))return!0;if(ee(i,"/api/plugins")&&!Q.has(s))return!1;if(Q.has(s))return t.has("read")||t.has("mutate");return t.has("mutate")}var ze=["/health","/ui","/code-server","/terminal","/plan","/git","/api/agent/status","/api/agent/version","/api/agent/identity","/api/agent/terminal-exchange","/api/agent/ui-exchange","/api/agent/ui-exchange-plugin","/metrics"];function le(t,n){if(!n||n==="/")return!1;let r=n.endsWith("/")?n.slice(0,-1):n;return t===r||t.startsWith(`${r}/`)}function We(t){let n=t.replace(/^\/api\/profiles\/[^/]+/,"/api");return n==="/api"?"/":n}function Je(t){let n=/^\/api\/profiles\/([^/]+)(?:\/|$)/.exec(t);if(!n)return null;let r=n[1];if(!r)return null;return r}function ge(t,n){let r=[t],i=We(t);if(i!==t)r.push(i);for(let s of r){if(ze.some((o)=>le(s,o)))return!0;if(n.some((o)=>le(s,o)))return!0}return!1}function ye(){let t=new Uint8Array(32);return crypto.getRandomValues(t),`vcak_${Buffer.from(t).toString("base64url")}`}var p=null;function ne(){return`${R()}:static-api-key`}async function Re(){let t=process.env.AGENT_API_KEY;if(t)return p=t,t;let n=ne(),r=await J(n);if(r)return p=r,r;let i=w({dir:e().dataDir})["static-api-key"];if(i){try{await de(n,i)}catch(o){e().logger.warn("auth","could not persist legacy api key into secrets backend",{error:String(o)})}return p=i,i}let s=ye();return await de(n,s),p=s,e().logger.info("auth","Generated and persisted new agent API key"),e().audit.emit("agent","apikey.minted",{profile:R(),via:"loadAgentApiKey"}),s}function K(){let t=process.env.AGENT_API_KEY;if(t)return t;if(p!==null)return p;let n=w()["static-api-key"];if(n)return p=n,n;let r=ye();p=r;try{M({"static-api-key":r},{dir:e().dataDir,scope:e().name})}catch{}return de(ne(),r).catch(()=>{}),r}async function vi(t){if(process.env.AGENT_API_KEY)throw Error("AGENT_API_KEY is pinned via the environment \u2014 cannot rotate the key at runtime. Update the env var and restart.");let n=(t??"").trim();if(!/^vcak_[A-Za-z0-9_-]{16,}$/.test(n))throw Error("Invalid agent API key format (expected vcak_<base64url>).");p=n,await de(ne(),n);try{M({"static-api-key":n},{dir:e().dataDir,scope:e().name})}catch{}e().audit.emit("agent","apikey.rotated",{profile:R(),via:"reset-key"})}function L(t){let n=t["x-agent-api-key"]??t["X-Agent-Api-Key"];if(n)return n;let r=t.authorization??t.Authorization;if(r?.startsWith("Bearer "))return r.slice(7);return null}function Ye(t){return!1}function Ze(t,n){let r=L(Object.fromEntries(t.headers.entries()));if(r)return r;if(!Ye(n))return null;try{let i=new URL(t.url).searchParams.get("apiKey");if(i)return i}catch{}return null}function b(t,n){let r=Buffer.from(t),i=Buffer.from(n);if(r.length!==i.length)return!1;try{return Ge(r,i)}catch{return!1}}function V(t){if(!t)return!1;return b(t,K())}var T={name:"default",scopes:new Set(["admin"])};async function Qe(t,n){if(!t)return null;let r=Je(n);if(r){let i=N.get(r);if(i){try{if(await i.keyVault.match(t))return T}catch{}if(r===e().name){try{if(await e().keyVault.match(t))return T}catch{}if(b(t,K()))return T;return pe(t)}return null}}try{if(await e().keyVault.match(t))return T}catch{}if(b(t,K()))return T;return pe(t)}function pe(t){let n=mr(t);return n?{name:n.name,scopes:n.scopes}:null}function mr(t){if(!t)return null;if(b(t,K()))return{name:"default",scopes:new Set(["admin"])};let n=B()??e(),r=w({dir:n.dataDir}),i=Date.now();for(let s of r.apiKeys??[]){if(!b(t,s.key))continue;if(s.notBefore){let o=Date.parse(s.notBefore);if(Number.isFinite(o)&&i<o)return null}if(s.expiresAt){let o=Date.parse(s.expiresAt);if(Number.isFinite(o)&&i>=o)return null}return{name:s.name,scopes:new Set(s.scopes)}}return null}function Ui(t,n){if(!t)return!1;if(t.scopes.has("admin"))return!0;return n.some((r)=>t.scopes.has(r))}var m=null;function te(t,n){try{e().audit.emit("auth",t,n)}catch{e().logger.warn("auth.audit",t,n)}}function et(t){let n=new Set(t());if(m===null)for(let r of n)te("plugin.public_path.declared",{path:r});else{for(let r of n)if(!m.has(r))te("plugin.public_path.added",{path:r});for(let r of m)if(!n.has(r))te("plugin.public_path.removed",{path:r})}return m=n,n}function Ki(){m=null}function he(t){if(!t)return[];if(m===null)return[...et(t)];return[...m]}function Qi(t){let n=K();return e().logger.info("auth",`Agent API key: ${n.substring(0,8)}****${n.substring(n.length-4)}`),new E({name:"plugin/auth"}).decorate("apiKey",n).derive(async({request:r,path:i})=>{let s=he(t),o;if(ge(i,s))o=!0;else if(ji(r.headers))o=!0;else{let a=Kt(r,i);if(a&&je(a,i,r.method))o=!0;else{let c=Ze(r,i),u=await Qe(c,i);if(o=u!==null,u&&!hr(u.scopes,r.method,i))return{isAuthenticated:o,scopeDenied:u.name}}}return{isAuthenticated:o,scopeDenied:null}}).onBeforeHandle(({isAuthenticated:r,scopeDenied:i,request:s,path:o,set:a})=>{if(i){try{e().audit.emit("auth","scoped_key.denied",{key:i,method:s.method,path:o})}catch{}return a.status=403,{error:"Forbidden",message:"This API key's scopes do not allow this operation"}}let c=he(t);if(!r&&!ge(o,c)){if(Kt(s,o))return a.status=401,{error:"invalid iframe token"};return a.status=401,{error:"Unauthorized",message:"Invalid or missing API key"}}}).as("global")}
16
+ export{hr,we,fr,Ut,je,Hr,qe,Kt,Li,pr,Vr,Yr,me,yt,rt,it,Re,K,vi,L,V,mr,Ui,Ki,Qi};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var m=Object.create;var{getPrototypeOf:n,defineProperty:g,getOwnPropertyNames:o}=Object;var l=Object.prototype.hasOwnProperty;function p(b){return this[b]}var q,r,P=(b,c,d)=>{var h=b!=null&&typeof b==="object";if(h){var i=c?q??=new WeakMap:r??=new WeakMap,k=i.get(b);if(k)return k}d=b!=null?m(n(b)):{};let e=c||!b||!b.__esModule||!l.call(b,"default")?g(d,"default",{value:b,enumerable:!0}):d;if(b&&typeof b==="object"||typeof b==="function"){for(let f of o(b))if(!l.call(e,f))g(e,f,{get:p.bind(b,f),enumerable:!0})}if(h)i.set(b,e);return e};var a=(b,c)=>()=>(c||b((c={exports:{}}).exports,c),c.exports);var s=(b)=>b;function t(b,c){this[b]=s.bind(null,c)}var Hi=(b,c)=>{for(var d in c)g(b,d,{get:c[d],enumerable:!0,configurable:!0,set:t.bind(c,d)})};var j=import.meta.require;
3
- export{P,a,Hi,j};
2
+ var m=Object.create;var{getPrototypeOf:n,defineProperty:g,getOwnPropertyNames:o}=Object;var l=Object.prototype.hasOwnProperty;function p(b){return this[b]}var q,r,P=(b,c,d)=>{var h=b!=null&&typeof b==="object";if(h){var i=c?q??=new WeakMap:r??=new WeakMap,k=i.get(b);if(k)return k}d=b!=null?m(n(b)):{};let e=c||!b||!b.__esModule||!l.call(b,"default")?g(d,"default",{value:b,enumerable:!0}):d;if(b&&typeof b==="object"||typeof b==="function"){for(let f of o(b))if(!l.call(e,f))g(e,f,{get:p.bind(b,f),enumerable:!0})}if(h)i.set(b,e);return e};var a=(b,c)=>()=>(c||b((c={exports:{}}).exports,c),c.exports);var s=(b)=>b;function t(b,c){this[b]=s.bind(null,c)}var Wi=(b,c)=>{for(var d in c)g(b,d,{get:c[d],enumerable:!0,configurable:!0,set:t.bind(c,d)})};var j=import.meta.require;
3
+ export{P,a,Wi,j};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{I,C,e}from"./index-0qjbnyg4.js";import{existsSync as l,mkdirSync as a,readFileSync as p,appendFileSync as m,writeFileSync as u}from"fs";import{join as b,relative as y,resolve as c,isAbsolute as h}from"path";var o=".boff/",S=new Set([".boff",".boff/","/.boff","/.boff/"]);function Sr(){a(I(),{recursive:!0}),w()}function w(){let f=c(C()),i=c(process.cwd()),s=y(i,f);if(s.startsWith("..")||h(s))return;let t=b(i,".gitignore");if(!l(t)){u(t,`${o}
2
+ import{I,C,e}from"./index-7wm4bqx5.js";import{existsSync as l,mkdirSync as a,readFileSync as p,appendFileSync as m,writeFileSync as u}from"fs";import{join as b,relative as y,resolve as c,isAbsolute as h}from"path";var o=".boff/",S=new Set([".boff",".boff/","/.boff","/.boff/"]);function Tr(){a(I(),{recursive:!0}),w()}function w(){let f=c(C()),i=c(process.cwd()),s=y(i,f);if(s.startsWith("..")||h(s))return;let t=b(i,".gitignore");if(!l(t)){u(t,`${o}
3
3
  `,{mode:420}),e().logger.info("bootstrap",`Created .gitignore with ${o}`);return}let r=p(t,"utf8");if(r.split(/\r?\n/).some((g)=>{let n=g.trim();if(!n||n.startsWith("#"))return!1;return S.has(n)}))return;let d=r.length>0&&!r.endsWith(`
4
4
  `);m(t,`${d?`
5
5
  `:""}${o}
6
6
  `),e().logger.info("bootstrap",`Appended ${o} to .gitignore`)}
7
- export{Sr};
7
+ export{Tr};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ye}from"./index-xetd52ad.js";export{Ye as Command};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- async function y(){return await import("./index-01fp85ft.js")}var T=/\x1b\[[0-9;]*m/g;function he(t){return t.replace(T,"")}async function Q(t){if(t.rows.length===0)return null;let i=await y(),{createCliRenderer:R,BoxRenderable:w,TextRenderable:u,SelectRenderable:g,SelectRenderableEvents:c}=i,n=await R({exitOnCtrlC:!0,targetFps:30}),o=n.root.ctx,r=new w(o,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),l=new u(o,{content:` ${t.title}`,fg:"#8be9fd",height:1}),d=new u(o,{content:` ${t.footer??"\u2191/\u2193 navigate \xB7 Enter select \xB7 q quit"}`,fg:"#6c7086",height:1}),m=new w(o,{width:"100%",flexGrow:1,flexDirection:"row"}),a=new g(o,{width:t.listWidth??28,height:"100%",options:t.rows.map((e)=>({name:he(e.label),description:he(e.hint??""),value:e.id})),selectedIndex:0,showDescription:!0,backgroundColor:"#0b0d12",textColor:"#cdd6f4",focusedBackgroundColor:"#0b0d12",focusedTextColor:"#cdd6f4",selectedBackgroundColor:"#1f2335",selectedTextColor:"#a6e3a1",descriptionColor:"#6c7086",selectedDescriptionColor:"#9399b2",showScrollIndicator:!0,wrapSelection:!0}),f=new w(o,{flexGrow:1,height:"100%",flexDirection:"column",paddingLeft:2,paddingRight:2,backgroundColor:"#11141c"}),b=new u(o,{content:"",fg:"#cdd6f4"});f.add(b),m.add(a),m.add(f),r.add(l),r.add(m),r.add(d),n.root.add(r),a.focus();let p=(e)=>{let x=t.rows[e];if(!x)return;b.content=`
3
- ${he(x.detail)}
2
+ async function y(){return await import("./index-01fp85ft.js")}var T=/\x1b\[[0-9;]*m/g;function Ee(t){return t.replace(T,"")}async function Q(t){if(t.rows.length===0)return null;let i=await y(),{createCliRenderer:R,BoxRenderable:w,TextRenderable:u,SelectRenderable:g,SelectRenderableEvents:c}=i,n=await R({exitOnCtrlC:!0,targetFps:30}),o=n.root.ctx,r=new w(o,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),l=new u(o,{content:` ${t.title}`,fg:"#8be9fd",height:1}),d=new u(o,{content:` ${t.footer??"\u2191/\u2193 navigate \xB7 Enter select \xB7 q quit"}`,fg:"#6c7086",height:1}),m=new w(o,{width:"100%",flexGrow:1,flexDirection:"row"}),a=new g(o,{width:t.listWidth??28,height:"100%",options:t.rows.map((e)=>({name:Ee(e.label),description:Ee(e.hint??""),value:e.id})),selectedIndex:0,showDescription:!0,backgroundColor:"#0b0d12",textColor:"#cdd6f4",focusedBackgroundColor:"#0b0d12",focusedTextColor:"#cdd6f4",selectedBackgroundColor:"#1f2335",selectedTextColor:"#a6e3a1",descriptionColor:"#6c7086",selectedDescriptionColor:"#9399b2",showScrollIndicator:!0,wrapSelection:!0}),f=new w(o,{flexGrow:1,height:"100%",flexDirection:"column",paddingLeft:2,paddingRight:2,backgroundColor:"#11141c"}),b=new u(o,{content:"",fg:"#cdd6f4"});f.add(b),m.add(a),m.add(f),r.add(l),r.add(m),r.add(d),n.root.add(r),a.focus();let p=(e)=>{let x=t.rows[e];if(!x)return;b.content=`
3
+ ${Ee(x.detail)}
4
4
  `};return p(0),a.on(c.SELECTION_CHANGED,(e)=>{p(e)}),await new Promise((e)=>{let x=(s)=>{try{n.destroy()}catch{}e(s)};a.on(c.ITEM_SELECTED,()=>{let s=t.rows[a.getSelectedIndex()];x(s??null)}),n.keyInput.on("keypress",(s)=>{if(s.name==="escape"||s.name==="q")x(null)})}).then(async(e)=>{if(e&&t.onSelect)await t.onSelect(e);return e})}async function U(t){let i=await y(),{createCliRenderer:R,BoxRenderable:w,TextRenderable:u}=i,g=await R({exitOnCtrlC:!0,targetFps:30}),c=g.root.ctx,n=new w(c,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),o=new u(c,{content:` ${t.title}`,fg:"#8be9fd",height:1}),r=new w(c,{width:"100%",flexGrow:1,paddingLeft:2,paddingRight:2,backgroundColor:"#11141c"}),l=new u(c,{content:`
5
- ${he(t.body)}
6
- `,fg:"#cdd6f4"}),d=new u(c,{content:` ${t.footer??"q to quit"}`,fg:"#6c7086",height:1});r.add(l),n.add(o),n.add(r),n.add(d),g.root.add(n),await new Promise((m)=>{let a=()=>{try{g.destroy()}catch{}m()};g.keyInput.on("keypress",(f)=>{if(f.name==="escape"||f.name==="q"||f.name==="return")a()})})}async function Xi(t,i,R=0){if(i.length===0)return null;let w=await y(),{createCliRenderer:u,BoxRenderable:g,TextRenderable:c,SelectRenderable:n,SelectRenderableEvents:o}=w,r=await u({exitOnCtrlC:!0,targetFps:30}),l=r.root.ctx,d=new g(l,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),m=new c(l,{content:` ${t}`,fg:"#8be9fd",height:1}),a=new n(l,{width:"100%",flexGrow:1,options:i.map((b)=>({name:he(b.label),description:he(b.hint??""),value:b.value})),selectedIndex:R,showDescription:!0,backgroundColor:"#0b0d12",textColor:"#cdd6f4",focusedBackgroundColor:"#0b0d12",focusedTextColor:"#cdd6f4",selectedBackgroundColor:"#1f2335",selectedTextColor:"#a6e3a1",descriptionColor:"#6c7086",selectedDescriptionColor:"#9399b2",showScrollIndicator:!0,wrapSelection:!0}),f=new c(l,{content:" \u2191/\u2193 move \xB7 Enter select \xB7 q cancel",fg:"#6c7086",height:1});return d.add(m),d.add(a),d.add(f),r.root.add(d),a.focus(),await new Promise((b)=>{let p=(e)=>{try{r.destroy()}catch{}b(e)};a.on(o.ITEM_SELECTED,()=>{let e=i[a.getSelectedIndex()];p(e?.value??null)}),r.keyInput.on("keypress",(e)=>{if(e.name==="escape"||e.name==="q")p(null)})})}async function zi(t,i,R){let w=await y(),{createCliRenderer:u,BoxRenderable:g,TextRenderable:c}=w,n=new Set(R);for(let e of i)if(e.mandatory)n.add(e.key);let o=0,r=await u({exitOnCtrlC:!0,targetFps:30}),l=r.root.ctx,d=new g(l,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),m=new c(l,{content:` ${t}`,fg:"#8be9fd",height:1}),a=new g(l,{width:"100%",flexGrow:1,paddingLeft:2,paddingTop:1,backgroundColor:"#0b0d12"}),f=new c(l,{content:"",fg:"#cdd6f4"}),b=new c(l,{content:" \u2191/\u2193 move \xB7 space toggle \xB7 Enter confirm \xB7 q cancel",fg:"#6c7086",height:1});a.add(f),d.add(m),d.add(a),d.add(b),r.root.add(d);let p=()=>{f.content=i.map((e,x)=>{let h=e.mandatory||n.has(e.key)?"[x]":"[ ]",C=x===o?"\u203A":" ",k=e.mandatory?" (required)":"";return` ${C} ${h} ${e.label}${k}
7
- ${he(e.description)}`}).join(`
5
+ ${Ee(t.body)}
6
+ `,fg:"#cdd6f4"}),d=new u(c,{content:` ${t.footer??"q to quit"}`,fg:"#6c7086",height:1});r.add(l),n.add(o),n.add(r),n.add(d),g.root.add(n),await new Promise((m)=>{let a=()=>{try{g.destroy()}catch{}m()};g.keyInput.on("keypress",(f)=>{if(f.name==="escape"||f.name==="q"||f.name==="return")a()})})}async function sn(t,i,R=0){if(i.length===0)return null;let w=await y(),{createCliRenderer:u,BoxRenderable:g,TextRenderable:c,SelectRenderable:n,SelectRenderableEvents:o}=w,r=await u({exitOnCtrlC:!0,targetFps:30}),l=r.root.ctx,d=new g(l,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),m=new c(l,{content:` ${t}`,fg:"#8be9fd",height:1}),a=new n(l,{width:"100%",flexGrow:1,options:i.map((b)=>({name:Ee(b.label),description:Ee(b.hint??""),value:b.value})),selectedIndex:R,showDescription:!0,backgroundColor:"#0b0d12",textColor:"#cdd6f4",focusedBackgroundColor:"#0b0d12",focusedTextColor:"#cdd6f4",selectedBackgroundColor:"#1f2335",selectedTextColor:"#a6e3a1",descriptionColor:"#6c7086",selectedDescriptionColor:"#9399b2",showScrollIndicator:!0,wrapSelection:!0}),f=new c(l,{content:" \u2191/\u2193 move \xB7 Enter select \xB7 q cancel",fg:"#6c7086",height:1});return d.add(m),d.add(a),d.add(f),r.root.add(d),a.focus(),await new Promise((b)=>{let p=(e)=>{try{r.destroy()}catch{}b(e)};a.on(o.ITEM_SELECTED,()=>{let e=i[a.getSelectedIndex()];p(e?.value??null)}),r.keyInput.on("keypress",(e)=>{if(e.name==="escape"||e.name==="q")p(null)})})}async function on(t,i,R){let w=await y(),{createCliRenderer:u,BoxRenderable:g,TextRenderable:c}=w,n=new Set(R);for(let e of i)if(e.mandatory)n.add(e.key);let o=0,r=await u({exitOnCtrlC:!0,targetFps:30}),l=r.root.ctx,d=new g(l,{width:"100%",height:"100%",flexDirection:"column",backgroundColor:"#0b0d12"}),m=new c(l,{content:` ${t}`,fg:"#8be9fd",height:1}),a=new g(l,{width:"100%",flexGrow:1,paddingLeft:2,paddingTop:1,backgroundColor:"#0b0d12"}),f=new c(l,{content:"",fg:"#cdd6f4"}),b=new c(l,{content:" \u2191/\u2193 move \xB7 space toggle \xB7 Enter confirm \xB7 q cancel",fg:"#6c7086",height:1});a.add(f),d.add(m),d.add(a),d.add(b),r.root.add(d);let p=()=>{f.content=i.map((e,x)=>{let h=e.mandatory||n.has(e.key)?"[x]":"[ ]",C=x===o?"\u203A":" ",k=e.mandatory?" (required)":"";return` ${C} ${h} ${e.label}${k}
7
+ ${Ee(e.description)}`}).join(`
8
8
  `)};return p(),await new Promise((e)=>{let x=(s)=>{try{r.destroy()}catch{}e(s)};r.keyInput.on("keypress",(s)=>{let h=s.name;if(h==="up"||h==="k")o=(o-1+i.length)%i.length,p();else if(h==="down"||h==="j")o=(o+1)%i.length,p();else if(h==="space"||s.sequence===" "){let C=i[o];if(C&&!C.mandatory){if(n.has(C.key))n.delete(C.key);else n.add(C.key);p()}}else if(h==="return"){for(let C of i)if(C.mandatory)n.add(C.key);x(n)}else if(h==="escape"||h==="q")x(null)})})}
9
- export{he,Q,U,Xi,zi};
9
+ export{Ee,Q,U,sn,on};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- function Se(){return!!process.stdout.isTTY&&!!process.stdin.isTTY}async function Ie(t,e=!1){if(!Se())return e;let n=e?"[Y/n]":"[y/N]";return process.stdout.write(` ${t} ${n} `),new Promise((r)=>{let o=process.stdin;o.setRawMode?.(!0),o.resume(),o.setEncoding("utf8");let a=(s)=>{o.removeListener("data",a),o.setRawMode?.(!1),o.pause();let i=s.trim().toLowerCase();if(console.log(i||(e?"y":"n")),i==="")r(e);else r(i==="y")};o.on("data",a)})}function _(t){if(t.json)return"json";if(t.plain)return"plain";if(t.interactive)return"interactive";return"auto"}function p(){return!!process.env.CI||!!process.env.NO_COLOR||process.env.TERM==="dumb"}async function y(t){let e=await t.fetchData(),n=t.mode??"auto";if(n==="json"){let o=t.json?t.json(e):e;process.stdout.write(`${JSON.stringify(o,null,2)}
3
- `);return}if(n==="plain"){await t.plain(e);return}if((n==="interactive"||Se()&&!p())&&!!t.interactive&&t.interactive)try{await t.interactive(e);return}catch{}await t.plain(e)}function u(t,e){if(!t.json)return!1;return process.stdout.write(`${JSON.stringify(e,null,2)}
4
- `),!0}async function vt(t,e,n=!1){if(t.yes===!0||t.json===!0||!Se())return!0;return Ie(e,n)}export{Se,Ie,_,y,u,vt};
2
+ function ue(){return!!process.stdout.isTTY&&!!process.stdin.isTTY}async function le(t,e=!1){if(!ue())return e;let n=e?"[Y/n]":"[y/N]";return process.stdout.write(` ${t} ${n} `),new Promise((r)=>{let o=process.stdin;o.setRawMode?.(!0),o.resume(),o.setEncoding("utf8");let a=(s)=>{o.removeListener("data",a),o.setRawMode?.(!1),o.pause();let i=s.trim().toLowerCase();if(console.log(i||(e?"y":"n")),i==="")r(e);else r(i==="y")};o.on("data",a)})}function _(t){if(t.json)return"json";if(t.plain)return"plain";if(t.interactive)return"interactive";return"auto"}function p(){return!!process.env.CI||!!process.env.NO_COLOR||process.env.TERM==="dumb"}async function y(t){let e=await t.fetchData(),n=t.mode??"auto";if(n==="json"){let o=t.json?t.json(e):e;process.stdout.write(`${JSON.stringify(o,null,2)}
3
+ `);return}if(n==="plain"){await t.plain(e);return}if((n==="interactive"||ue()&&!p())&&!!t.interactive&&t.interactive)try{await t.interactive(e);return}catch{}await t.plain(e)}function u(t,e){if(!t.json)return!1;return process.stdout.write(`${JSON.stringify(e,null,2)}
4
+ `),!0}async function jt(t,e,n=!1){if(t.yes===!0||t.json===!0||!ue())return!0;return le(e,n)}export{ue,le,_,y,u,jt};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{e}from"./index-0qjbnyg4.js";import{Et,kt}from"./index-5021rk8n.js";import{hi}from"./index-0gmhd3hs.js";var g="prereqs-runner",R="plugin-mgr",d={status:null,install:null,satisfied:!0,pendingSudo:[],noProtocol:!0};function q(t,r){if(!t.apiPrefix)return null;return`${(t.apiPrefix.startsWith("/")?t.apiPrefix:`/${t.apiPrefix}`).replace(/\/+$/,"")}/prereqs${r}`}async function c(t,r,s){let l=t.handle;if(typeof l!=="function")return null;let u=new Request(`http://agent.local${r}`,{method:s,headers:{"x-vc-profile-rewrite":"1",[Et]:kt()}}),n=await l.call(t,u);if(n.status===404)return null;if(!n.ok){let P=await n.text().catch(()=>"");throw Error(`prereqs ${s} ${r} \u2192 ${n.status} ${P}`)}return await n.json()}async function xt(t,r,s,l,u={}){let n=q(t,"/status"),P=q(t,"/install");if(!n||!P)return d;let a=null;try{a=await c(s,n,"GET")}catch(i){e().logger.warn(g,`${t.name}: prereqs/status call failed`,{error:String(i)})}if(a===null)return d;if(a.satisfied||u.skipInstall)return await S(l,r,t.version,{status:a,install:null}),{status:a,install:null,satisfied:a.satisfied,pendingSudo:[],noProtocol:!1};let o=null;try{o=await c(s,P,"POST")}catch(i){e().logger.warn(g,`${t.name}: prereqs/install call failed`,{error:String(i)})}let p=a;try{let i=await c(s,n,"GET");if(i)p=i}catch{}if(await S(l,r,t.version,{status:p,install:o}),o&&o.installed.length>0){let i=new Map;for(let f of t.prerequisites??[])i.set(f.name,f.kind);hi(r,o.installed.map((f)=>({name:f,kind:i.get(f)??"binary"})))}return{status:p,install:o,satisfied:p.satisfied,pendingSudo:o?.pendingSudo??[],noProtocol:!1}}async function S(t,r,s,l){if(!t)return;let u=JSON.stringify({lastInstallAt:new Date().toISOString(),lastInstallVersion:s,satisfied:l.status?.satisfied??!1,missing:l.status?.missing??[],pendingSudo:l.install?.pendingSudo??[]});try{await t.setPluginState(R,`prereqs:${r}`,u)}catch(n){e().logger.warn(g,"Failed to persist prereq state",{packageName:r,error:String(n)})}}async function pr(t,r){if(!t)return null;try{let s=await t.getPluginState(R,`prereqs:${r}`);return s?JSON.parse(s):null}catch{return null}}
3
- export{xt,pr};
2
+ import{e}from"./index-7wm4bqx5.js";import{St,Qt}from"./index-x4z055t8.js";import{yi}from"./index-0rmmrrfh.js";var g="prereqs-runner",R="plugin-mgr",d={status:null,install:null,satisfied:!0,pendingSudo:[],noProtocol:!0};function q(t,r){if(!t.apiPrefix)return null;return`${(t.apiPrefix.startsWith("/")?t.apiPrefix:`/${t.apiPrefix}`).replace(/\/+$/,"")}/prereqs${r}`}async function c(t,r,s){let l=t.handle;if(typeof l!=="function")return null;let u=new Request(`http://agent.local${r}`,{method:s,headers:{"x-vc-profile-rewrite":"1",[St]:Qt()}}),n=await l.call(t,u);if(n.status===404)return null;if(!n.ok){let P=await n.text().catch(()=>"");throw Error(`prereqs ${s} ${r} \u2192 ${n.status} ${P}`)}return await n.json()}async function qt(t,r,s,l,u={}){let n=q(t,"/status"),P=q(t,"/install");if(!n||!P)return d;let a=null;try{a=await c(s,n,"GET")}catch(i){e().logger.warn(g,`${t.name}: prereqs/status call failed`,{error:String(i)})}if(a===null)return d;if(a.satisfied||u.skipInstall)return await S(l,r,t.version,{status:a,install:null}),{status:a,install:null,satisfied:a.satisfied,pendingSudo:[],noProtocol:!1};let o=null;try{o=await c(s,P,"POST")}catch(i){e().logger.warn(g,`${t.name}: prereqs/install call failed`,{error:String(i)})}let p=a;try{let i=await c(s,n,"GET");if(i)p=i}catch{}if(await S(l,r,t.version,{status:p,install:o}),o&&o.installed.length>0){let i=new Map;for(let f of t.prerequisites??[])i.set(f.name,f.kind);yi(r,o.installed.map((f)=>({name:f,kind:i.get(f)??"binary"})))}return{status:p,install:o,satisfied:p.satisfied,pendingSudo:o?.pendingSudo??[],noProtocol:!1}}async function S(t,r,s,l){if(!t)return;let u=JSON.stringify({lastInstallAt:new Date().toISOString(),lastInstallVersion:s,satisfied:l.status?.satisfied??!1,missing:l.status?.missing??[],pendingSudo:l.install?.pendingSudo??[]});try{await t.setPluginState(R,`prereqs:${r}`,u)}catch(n){e().logger.warn(g,"Failed to persist prereq state",{packageName:r,error:String(n)})}}async function Cr(t,r){if(!t)return null;try{let s=await t.getPluginState(R,`prereqs:${r}`);return s?JSON.parse(s):null}catch{return null}}
3
+ export{qt,Cr};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{C,e}from"./index-0qjbnyg4.js";import{Dr,ve}from"./index-4z1y39jt.js";import{createHash as p,randomUUID as m}from"crypto";import{existsSync as l,mkdirSync as v,readFileSync as g,writeFileSync as b}from"fs";import{join as d}from"path";import*as o from"os";var y="https://analytics.burdenoff.com/api/track",T="cd7d5ccc3667",f=200,I=10,_=30000,E=5000;function u(t){if(process.env.DO_NOT_TRACK==="1")return!1;let i=process.env.VIBECONTROLS_TELEMETRY?.toLowerCase();if(i==="on"||i==="true"||i==="1")return!0;if(i==="off"||i==="false"||i==="0")return!1;return t}class h{enabled=!1;persisted=!1;buffer=[];flushTimer=null;cachedAnonymousId=null;overflowWarned=!1;postFailureWarned=!1;initialized=!1;init(t){if(t?.persisted!==void 0)this.persisted=t.persisted;if(this.enabled=u(this.persisted),!this.initialized)this.initialized=!0,this.startFlushTimer()}setEnabled(t){let i=this.enabled;if(this.persisted=t,this.enabled=u(this.persisted),i&&!this.enabled)this.buffer=[],this.enqueueRaw("telemetry.disabled",{reason:"user_opt_out"}),this.flush()}emit(t,i={}){if(!this.enabled)return;let r={},s=!1;for(let[a,c]of Object.entries(i)){if(Dr(a)){s=!0;continue}r[a]=c}let n=ve(t,r);if(!n.ok||!n.sanitized){e().logger.warn("telemetry",`dropping event '${t}': ${n.reason??"invalid"}`);return}this.enqueue(t,n.sanitized)}enqueueRaw(t,i){this.enqueue(t,i)}enqueue(t,i){let r={site_id:T,event_name:t,properties:i,anonymous_id:this.getAnonymousId(),timestamp:new Date().toISOString()};if(this.buffer.length>=f){if(this.buffer.shift(),!this.overflowWarned)this.overflowWarned=!0,e().logger.warn("telemetry",`buffer overflow (cap=${f}) \u2014 dropping oldest events`)}if(this.buffer.push(r),this.buffer.length>=I)this.flush()}async flush(){if(this.buffer.length===0)return;let t=this.buffer.splice(0,this.buffer.length),i=new AbortController,r=setTimeout(()=>i.abort(),E);try{await fetch(y,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:t}),signal:i.signal})}catch(s){if(!this.postFailureWarned)this.postFailureWarned=!0,e().logger.warn("telemetry","shipper POST failed; dropping batch",{error:String(s)})}finally{clearTimeout(r)}}stop(){if(this.flushTimer)clearInterval(this.flushTimer),this.flushTimer=null;this.initialized=!1}_resetForTest(){this.stop(),this.enabled=!1,this.persisted=!1,this.buffer=[],this.cachedAnonymousId=null,this.overflowWarned=!1,this.postFailureWarned=!1}_bufferLength(){return this.buffer.length}_isEnabled(){return this.enabled}startFlushTimer(){if(this.flushTimer)return;if(this.flushTimer=setInterval(()=>{this.flush()},_),typeof this.flushTimer.unref==="function")this.flushTimer.unref()}getAnonymousId(){if(this.cachedAnonymousId)return this.cachedAnonymousId;let t=`${o.hostname()}${o.platform()}`,i=this.readOrCreateInstallId(),r=p("sha256").update(t+i).digest("hex");return this.cachedAnonymousId=r.slice(0,16),this.cachedAnonymousId}readOrCreateInstallId(){let t;try{t=C()}catch{t=d(process.cwd(),".boff","vibecontrols")}if(!l(t))try{v(t,{recursive:!0,mode:448})}catch{}let i=d(t,".install-id");if(l(i))try{let s=g(i,"utf-8").trim();if(s)return s}catch{}let r=m();try{b(i,r,{mode:384})}catch{}return r}}var Z=new h;
2
+ import{C,e}from"./index-7wm4bqx5.js";import{Kr,Ke}from"./index-cn4p1ks0.js";import{createHash as p,randomUUID as m}from"crypto";import{existsSync as l,mkdirSync as v,readFileSync as g,writeFileSync as b}from"fs";import{join as d}from"path";import*as o from"os";var y="https://analytics.burdenoff.com/api/track",T="cd7d5ccc3667",f=200,I=10,_=30000,E=5000;function u(t){if(process.env.DO_NOT_TRACK==="1")return!1;let i=process.env.VIBECONTROLS_TELEMETRY?.toLowerCase();if(i==="on"||i==="true"||i==="1")return!0;if(i==="off"||i==="false"||i==="0")return!1;return t}class h{enabled=!1;persisted=!1;buffer=[];flushTimer=null;cachedAnonymousId=null;overflowWarned=!1;postFailureWarned=!1;initialized=!1;init(t){if(t?.persisted!==void 0)this.persisted=t.persisted;if(this.enabled=u(this.persisted),!this.initialized)this.initialized=!0,this.startFlushTimer()}setEnabled(t){let i=this.enabled;if(this.persisted=t,this.enabled=u(this.persisted),i&&!this.enabled)this.buffer=[],this.enqueueRaw("telemetry.disabled",{reason:"user_opt_out"}),this.flush()}emit(t,i={}){if(!this.enabled)return;let r={},s=!1;for(let[a,c]of Object.entries(i)){if(Kr(a)){s=!0;continue}r[a]=c}let n=Ke(t,r);if(!n.ok||!n.sanitized){e().logger.warn("telemetry",`dropping event '${t}': ${n.reason??"invalid"}`);return}this.enqueue(t,n.sanitized)}enqueueRaw(t,i){this.enqueue(t,i)}enqueue(t,i){let r={site_id:T,event_name:t,properties:i,anonymous_id:this.getAnonymousId(),timestamp:new Date().toISOString()};if(this.buffer.length>=f){if(this.buffer.shift(),!this.overflowWarned)this.overflowWarned=!0,e().logger.warn("telemetry",`buffer overflow (cap=${f}) \u2014 dropping oldest events`)}if(this.buffer.push(r),this.buffer.length>=I)this.flush()}async flush(){if(this.buffer.length===0)return;let t=this.buffer.splice(0,this.buffer.length),i=new AbortController,r=setTimeout(()=>i.abort(),E);try{await fetch(y,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:t}),signal:i.signal})}catch(s){if(!this.postFailureWarned)this.postFailureWarned=!0,e().logger.warn("telemetry","shipper POST failed; dropping batch",{error:String(s)})}finally{clearTimeout(r)}}stop(){if(this.flushTimer)clearInterval(this.flushTimer),this.flushTimer=null;this.initialized=!1}_resetForTest(){this.stop(),this.enabled=!1,this.persisted=!1,this.buffer=[],this.cachedAnonymousId=null,this.overflowWarned=!1,this.postFailureWarned=!1}_bufferLength(){return this.buffer.length}_isEnabled(){return this.enabled}startFlushTimer(){if(this.flushTimer)return;if(this.flushTimer=setInterval(()=>{this.flush()},_),typeof this.flushTimer.unref==="function")this.flushTimer.unref()}getAnonymousId(){if(this.cachedAnonymousId)return this.cachedAnonymousId;let t=`${o.hostname()}${o.platform()}`,i=this.readOrCreateInstallId(),r=p("sha256").update(t+i).digest("hex");return this.cachedAnonymousId=r.slice(0,16),this.cachedAnonymousId}readOrCreateInstallId(){let t;try{t=C()}catch{t=d(process.cwd(),".boff","vibecontrols")}if(!l(t))try{v(t,{recursive:!0,mode:448})}catch{}let i=d(t,".install-id");if(l(i))try{let s=g(i,"utf-8").trim();if(s)return s}catch{}let r=m();try{b(i,r,{mode:384})}catch{}return r}}var Z=new h;
3
3
  export{Z};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{randomBytes as a,timingSafeEqual as i}from"crypto";var St="x-vc-internal-auth",r=a(32).toString("hex");function Qt(){return r}function ji(o){let t=o.get(St);if(!t)return!1;let n=Buffer.from(t),e=Buffer.from(r);return n.length===e.length&&i(n,e)}
3
+ export{St,Qt,ji};
@@ -11,7 +11,7 @@ ${r}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),n
11
11
  - too many long flags`);throw Error(`${h}
12
12
  - unrecognised flag format`)}if(e===void 0&&i===void 0)throw Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:i}}function k(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);let i=[];for(let n=0;n<=t.length;n++)i[n]=[n];for(let n=0;n<=e.length;n++)i[0][n]=n;for(let n=1;n<=e.length;n++)for(let s=1;s<=t.length;s++){let r;if(t[s-1]===e[n-1])r=0;else r=1;if(i[s][n]=Math.min(i[s-1][n]+1,i[s][n-1]+1,i[s-1][n-1]+r),s>1&&n>1&&t[s-1]===e[n-2]&&t[s-2]===e[n-1])i[s][n]=Math.min(i[s][n],i[s-2][n-2]+1)}return i[t.length][e.length]}function w(t,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let i=t.startsWith("--");if(i)t=t.slice(2),e=e.map((o)=>o.slice(2));let n=[],s=3,r=0.4;if(e.forEach((o)=>{if(o.length<=1)return;let h=k(t,o),l=Math.max(t.length,o.length);if((l-h)/l>r){if(h<s)s=h,n=[o];else if(h===s)n.push(o)}}),n.sort((o,h)=>o.localeCompare(h)),i)n=n.map((o)=>`--${o}`);if(n.length>1)return`
13
13
  (Did you mean one of ${n.join(", ")}?)`;if(n.length===1)return`
14
- (Did you mean ${n[0]}?)`;return""}class $e extends P{constructor(t){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(e)=>p.stdout.write(e),writeErr:(e)=>p.stderr.write(e),outputError:(e,i)=>i(e),getOutHelpWidth:()=>p.stdout.isTTY?p.stdout.columns:void 0,getErrHelpWidth:()=>p.stderr.isTTY?p.stderr.columns:void 0,getOutHasColors:()=>V()??(p.stdout.isTTY&&p.stdout.hasColors?.()),getErrHasColors:()=>V()??(p.stderr.isTTY&&p.stderr.hasColors?.()),stripColor:(e)=>W(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let n=e,s=i;if(typeof n==="object"&&n!==null)s=n,n=null;s=s||{};let[,r,o]=t.match(/([^ ]+) *(.*)/),h=this.createCommand(r);if(n)h.description(n),h._executableHandler=!0;if(s.isDefault)this._defaultCommandName=h._name;if(h._hidden=!!(s.noHelp||s.hidden),h._executableFile=s.executableFile||null,o)h.arguments(o);if(this._registerCommand(h),h.parent=this,h.copyInheritedSettings(this),n)return this;return h}createCommand(t){return new $e(t)}createHelp(){return Object.assign(new A,this.configureHelp())}configureHelp(t){if(t===void 0)return this._helpConfiguration;return this._helpConfiguration=t,this}configureOutput(t){if(t===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...t},this}showHelpAfterError(t=!0){if(typeof t!=="string")t=!!t;return this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw Error(`Command passed to .addCommand() must have a name
14
+ (Did you mean ${n[0]}?)`;return""}class Ye extends P{constructor(t){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(e)=>p.stdout.write(e),writeErr:(e)=>p.stderr.write(e),outputError:(e,i)=>i(e),getOutHelpWidth:()=>p.stdout.isTTY?p.stdout.columns:void 0,getErrHelpWidth:()=>p.stderr.isTTY?p.stderr.columns:void 0,getOutHasColors:()=>V()??(p.stdout.isTTY&&p.stdout.hasColors?.()),getErrHasColors:()=>V()??(p.stderr.isTTY&&p.stderr.hasColors?.()),stripColor:(e)=>W(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let n=e,s=i;if(typeof n==="object"&&n!==null)s=n,n=null;s=s||{};let[,r,o]=t.match(/([^ ]+) *(.*)/),h=this.createCommand(r);if(n)h.description(n),h._executableHandler=!0;if(s.isDefault)this._defaultCommandName=h._name;if(h._hidden=!!(s.noHelp||s.hidden),h._executableFile=s.executableFile||null,o)h.arguments(o);if(this._registerCommand(h),h.parent=this,h.copyInheritedSettings(this),n)return this;return h}createCommand(t){return new Ye(t)}createHelp(){return Object.assign(new A,this.configureHelp())}configureHelp(t){if(t===void 0)return this._helpConfiguration;return this._helpConfiguration=t,this}configureOutput(t){if(t===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...t},this}showHelpAfterError(t=!0){if(typeof t!=="string")t=!!t;return this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw Error(`Command passed to .addCommand() must have a name
15
15
  - specify the name in Command constructor or using .name()`);if(e=e||{},e.isDefault)this._defaultCommandName=t._name;if(e.noHelp||e.hidden)t._hidden=!0;return this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new C(t,e)}argument(t,e,i,n){let s=this.createArgument(t,e);if(typeof i==="function")s.default(n).argParser(i);else s.default(i);return this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach((e)=>{this.argument(e)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if(typeof t==="boolean"){if(this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let i=t??"help [command]",[,n,s]=i.match(/([^ ]+) *(.*)/),r=e??"display help for command",o=this.createCommand(n);if(o.helpOption(!1),s)o.arguments(s);if(r)o.description(r);if(this._addImplicitHelpCommand=!0,this._helpCommand=o,t||e)this._initCommandGroup(o);return this}addHelpCommand(t,e){if(typeof t!=="object")return this.helpCommand(t,e),this;return this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(t,e){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw Error(`Unexpected value for event passed to hook : '${t}'.
16
16
  Expecting one of '${i.join("', '")}'`);if(this._lifeCycleHooks[t])this._lifeCycleHooks[t].push(e);else this._lifeCycleHooks[t]=[e];return this}exitOverride(t){if(t)this._exitCallback=t;else this._exitCallback=(e)=>{if(e.code!=="commander.executeSubCommandAsync")throw e};return this}_exit(t,e,i){if(this._exitCallback)this._exitCallback(new f(t,e,i));p.exit(t)}action(t){let e=(i)=>{let n=this.registeredArguments.length,s=i.slice(0,n);if(this._storeOptionsAsProperties)s[n]=this;else s[n]=this.opts();return s.push(this),t.apply(this,s)};return this._actionHandler=e,this}createOption(t,e){return new O(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(s){if(s.code==="commander.invalidArgument"){let r=`${n} ${s.message}`;this.error(r,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
17
17
  - already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let e=(n)=>[n.name()].concat(n.aliases()),i=e(t).find((n)=>this._findCommand(n));if(i){let n=e(this._findCommand(i)).join("|"),s=e(t).join("|");throw Error(`cannot add command '${s}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let e=t.name(),i=t.attributeName();if(t.defaultValue!==void 0)this.setOptionValueWithSource(i,t.defaultValue,"default");let n=(s,r,o)=>{if(s==null&&t.presetArg!==void 0)s=t.presetArg;let h=this.getOptionValue(i);if(s!==null&&t.parseArg)s=this._callParseArg(t,s,h,r);else if(s!==null&&t.variadic)s=t._collectValue(s,h);if(s==null)if(t.negate)s=!1;else if(t.isBoolean()||t.optional)s=!0;else s="";this.setOptionValueWithSource(i,s,o)};if(this.on("option:"+e,(s)=>{let r=`error: option '${t.flags}' argument '${s}' is invalid.`;n(s,r,"cli")}),t.envVar)this.on("optionEnv:"+e,(s)=>{let r=`error: option '${t.flags}' value '${s}' from env '${t.envVar}' is invalid.`;n(s,r,"env")});return this}_optionEx(t,e,i,n,s){if(typeof e==="object"&&e instanceof O)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(e,i);if(r.makeOptionMandatory(!!t.mandatory),typeof n==="function")r.default(s).argParser(n);else if(n instanceof RegExp){let o=n;n=(h,l)=>{let a=o.exec(h);return a?a[0]:l},r.default(s).argParser(n)}else r.default(n);return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:!0},t,e,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){if(this._storeOptionsAsProperties)return this[t];return this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){if(this._storeOptionsAsProperties)this[t]=e;else this._optionValues[t]=e;return this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach((i)=>{if(i.getOptionValueSource(t)!==void 0)e=i.getOptionValueSource(t)}),e}_prepareUserArgs(t,e){if(t!==void 0&&!Array.isArray(t))throw Error("first parameter to parse must be array or undefined");if(e=e||{},t===void 0&&e.from===void 0){if(p.versions?.electron)e.from="electron";let n=p.execArgv??[];if(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))e.from="eval"}if(t===void 0)t=p.argv;this.rawArgs=t.slice();let i;switch(e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":if(p.defaultApp)this._scriptPath=t[1],i=t.slice(2);else i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw Error(`unexpected parse option { from: '${e.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",i}parse(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_prepareForParse(){if(this._savedState===null)this.options.filter((t)=>t.negate&&t.defaultValue===void 0&&this.getOptionValue(t.attributeName())===void 0).forEach((t)=>{let e=t.long.replace(/^--no-/,"--");if(!this._findOption(e))this.setOptionValueWithSource(t.attributeName(),!0,"default")}),this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
@@ -24,4 +24,4 @@ Expecting one of '${i.join("', '")}'`);if(this._lifeCycleHooks[t])this._lifeCycl
24
24
  `),this.outputHelp({error:!0});let i=e||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach((t)=>{if(t.envVar&&t.envVar in p.env){let e=t.attributeName();if(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))if(t.required||t.optional)this.emit(`optionEnv:${t.name()}`,p.env[t.envVar]);else this.emit(`optionEnv:${t.name()}`)}})}_parseOptionsImplied(){let t=new y(this.options),e=(i)=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter((i)=>i.implied!==void 0&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach((i)=>{Object.keys(i.implied).filter((n)=>!e(n)).forEach((n)=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let i=(r)=>{let o=r.attributeName(),h=this.getOptionValue(o),l=this.options.find((u)=>u.negate&&o===u.attributeName()),a=this.options.find((u)=>!u.negate&&o===u.attributeName());if(l&&(l.presetArg===void 0&&h===!1||l.presetArg!==void 0&&h===l.presetArg))return l;return a||r},n=(r)=>{let o=i(r),h=o.attributeName();if(this.getOptionValueSource(h)==="env")return`environment variable '${o.envVar}'`;return`option '${o.flags}'`},s=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let r=s.createHelp().visibleOptions(s).filter((o)=>o.long).map((o)=>o.long);n=n.concat(r),s=s.parent}while(s&&!s._enablePositionalOptions);e=w(t,n)}let i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,i=e===1?"":"s",n=t.length,s=this.parent?` for '${this.name()}'`:"",r=t.join(", "),o=`error: too many arguments${s}. Expected ${e} argument${i} but got ${n}: ${r}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach((s)=>{if(n.push(s.name()),s.alias())n.push(s.alias())}),e=w(t,n)}let i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";let n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
25
  `),this._exit(0,"commander.version",t)}),this}description(t,e){if(t===void 0&&e===void 0)return this._description;if(this._description=t,e)this._argsDescription=e;return this}summary(t){if(t===void 0)return this._summary;return this._summary=t,this}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)e=this.commands[this.commands.length-1];if(t===e._name)throw Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return e._aliases.push(t),this}aliases(t){if(t===void 0)return this._aliases;return t.forEach((e)=>this.alias(e)),this}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map((i)=>b(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){if(t===void 0)return this._name;return this._name=t,this}helpGroup(t){if(t===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=t,this}commandsGroup(t){if(t===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=t,this}optionsGroup(t){if(t===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=t,this}_initOptionGroup(t){if(this._defaultOptionGroup&&!t.helpGroupHeading)t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){if(this._defaultCommandGroup&&!t.helpGroup())t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=m.basename(t,m.extname(t)),this}executableDir(t){if(t===void 0)return this._executableDir;return this._executableDir=t,this}helpInformation(t){let e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=e.formatHelp(this,e);if(i.hasColors)return n;return this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let e=!!t.error,i,n,s;if(e)i=(o)=>this._outputConfiguration.writeErr(o),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth();else i=(o)=>this._outputConfiguration.writeOut(o),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth();return{error:e,write:(o)=>{if(!n)o=this._outputConfiguration.stripColor(o);return i(o)},hasColors:n,helpWidth:s}}outputHelp(t){let e;if(typeof t==="function")e=t,t=void 0;let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach((r)=>r.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:i.error});if(e){if(s=e(s),typeof s!=="string"&&!Buffer.isBuffer(s))throw Error("outputHelp callback must return a string or a Buffer")}if(i.write(s),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",n),this._getCommandAndAncestors().forEach((r)=>r.emit("afterAllHelp",n))}helpOption(t,e){if(typeof t==="boolean"){if(t){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(t??"-h, --help",e??"display help for command"),t||e)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let e=Number(p.exitCode??0);if(e===0&&t&&typeof t!=="function"&&t.error)e=1;this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw Error(`Unexpected value for position to addHelpText.
26
26
  Expecting one of '${i.join("', '")}'`);let n=`${t}Help`;return this.on(n,(s)=>{let r;if(typeof e==="function")r=e({error:s.error,command:s.command});else r=e;if(r)s.write(`${r}
27
- `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();if(e&&t.find((n)=>e.is(n)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function v(t){return t.map((e)=>{if(!e.startsWith("--inspect"))return e;let i,n="127.0.0.1",s="9229",r;if((r=e.match(/^(--inspect(-brk)?)$/))!==null)i=r[1];else if((r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(i=r[1],/^\d+$/.test(r[3]))s=r[3];else n=r[3];else if((r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)i=r[1],n=r[3],s=r[4];if(i&&s!=="0")return`${i}=${n}:${parseInt(s)+1}`;return e})}function V(){if(p.env.NO_COLOR||p.env.FORCE_COLOR==="0"||p.env.FORCE_COLOR==="false")return!1;if(p.env.FORCE_COLOR||p.env.CLICOLOR_FORCE!==void 0)return!0;return}var at=new $e;export{$e};
27
+ `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();if(e&&t.find((n)=>e.is(n)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function v(t){return t.map((e)=>{if(!e.startsWith("--inspect"))return e;let i,n="127.0.0.1",s="9229",r;if((r=e.match(/^(--inspect(-brk)?)$/))!==null)i=r[1];else if((r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(i=r[1],/^\d+$/.test(r[3]))s=r[3];else n=r[3];else if((r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)i=r[1],n=r[3],s=r[4];if(i&&s!=="0")return`${i}=${n}:${parseInt(s)+1}`;return e})}function V(){if(p.env.NO_COLOR||p.env.FORCE_COLOR==="0"||p.env.FORCE_COLOR==="false")return!1;if(p.env.FORCE_COLOR||p.env.CLICOLOR_FORCE!==void 0)return!0;return}var at=new Ye;export{Ye};