@vibecontrols/agent 2026.602.2 → 2026.602.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-config-85pskv43.js → agent-config-4ppenhqp.js} +1 -1
- package/dist/{agent-ready-tracker-zp6p8e6f.js → agent-ready-tracker-kgs7td6t.js} +1 -1
- package/dist/app-8qe1gw9z.js +2 -0
- package/dist/bootstrap-workspace-qgs6d5f0.js +2 -0
- package/dist/bootstrap.service-vg72w8pa.js +2 -0
- package/dist/{bridge-client-341r9rry.js → bridge-client-1fxza4p7.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/daemon-profile-gwdcqx0q.js +2 -0
- package/dist/esm-6f3dfn6v.js +2 -0
- package/dist/{finalize-retry-handle-registry-vv241fsq.js → finalize-retry-handle-registry-xnm9kxry.js} +1 -1
- package/dist/{finalize-retry-worker-xp1nhv3c.js → finalize-retry-worker-dvykrzed.js} +1 -1
- package/dist/gateway-client-9kwnmk89.js +2 -0
- package/dist/{getMachineId-bsd-a56s0v8c.js → getMachineId-bsd-753751sw.js} +1 -1
- package/dist/{getMachineId-darwin-w9k0yw9r.js → getMachineId-darwin-na1pranq.js} +1 -1
- package/dist/{getMachineId-linux-anh31jbf.js → getMachineId-linux-dmn0ncdm.js} +1 -1
- package/dist/{getMachineId-unsupported-5hv3pwca.js → getMachineId-unsupported-yv77j894.js} +1 -1
- package/dist/{getMachineId-win-njb8tery.js → getMachineId-win-9hmyqmm0.js} +1 -1
- package/dist/highlights-00fcgwwq.js +2 -0
- package/dist/highlights-23bc8zge.js +2 -0
- package/dist/highlights-4mhb2pb0.js +2 -0
- package/dist/highlights-q7w64nwb.js +2 -0
- package/dist/highlights-xwdw5xay.js +2 -0
- package/dist/{index-678rwfc0.js → index-0924jp9m.js} +1 -1
- package/dist/{index-z5a4yxzz.js → index-1mppacnx.js} +3 -3
- package/dist/{index-g8zv1gta.js → index-1zf3r23y.js} +1 -1
- package/dist/{index-jw1k4vbk.js → index-4qq083yd.js} +1 -1
- package/dist/index-5amvpjqx.js +11 -0
- package/dist/{index-d5ysy1yn.js → index-5dysvvjv.js} +1 -1
- package/dist/{index-n7qyrdr1.js → index-5wpck4aw.js} +1 -1
- package/dist/{index-5mw3eshk.js → index-8nqp3a4d.js} +1 -1
- package/dist/{index-2xs9cvjn.js → index-8sdrhr3q.js} +2 -2
- package/dist/{index-6mprnf7p.js → index-97mq40rr.js} +1 -1
- package/dist/{index-0cn9bv8z.js → index-a4854mwz.js} +1 -1
- package/dist/{index-tp4y9jde.js → index-a9ejdv22.js} +1 -1
- package/dist/{index-fzzwprvk.js → index-aq81xmn0.js} +5 -5
- package/dist/{index-xjzmb1pn.js → index-b6x6a4xp.js} +2 -2
- package/dist/{index-yy1mm8zs.js → index-c7554sg7.js} +1 -1
- package/dist/{index-mtm8cfyt.js → index-ca5c245v.js} +2 -2
- package/dist/{index-2gsarrbn.js → index-d1xjj001.js} +1 -1
- package/dist/{index-h8a8s8sn.js → index-ebwwtwwc.js} +1 -1
- package/dist/{index-8sm0nkh8.js → index-ep3zb271.js} +1 -1
- package/dist/{index-g2raeeh4.js → index-h74va4wd.js} +2 -2
- package/dist/{index-v9fx5wab.js → index-hvjqgb97.js} +1 -1
- package/dist/{index-9bqd8veb.js → index-js1xn4sq.js} +3 -3
- package/dist/{index-x1h8r7pr.js → index-kt5zxp42.js} +1 -1
- package/dist/{index-ssjmzqcz.js → index-nmk7cbj5.js} +1 -1
- package/dist/{index-rdp5xq4r.js → index-nrsqzcfc.js} +1 -1
- package/dist/index-p23tet7a.js +2 -0
- package/dist/{index-04n4qgvd.js → index-pgew6sge.js} +3 -3
- package/dist/{index-1zw3kea7.js → index-qwtspxw8.js} +1 -1
- package/dist/index-qzwphe3q.js +26 -0
- package/dist/index-rqq0k5fc.js +16 -0
- package/dist/{index-6jq17k9s.js → index-rv6h14n8.js} +1 -1
- package/dist/{index-qfz9fy56.js → index-rw9x93zb.js} +1 -1
- package/dist/{index-dm6yjmgq.js → index-rzpaqrhx.js} +2 -2
- package/dist/{index-g3ap3xpr.js → index-s2xpdnsj.js} +4 -4
- package/dist/{index-vdahdt49.js → index-tgrt61qr.js} +1 -1
- package/dist/{index-ef95xr4z.js → index-thammzct.js} +2 -2
- package/dist/{index-scsjyj4m.js → index-x649afed.js} +2 -2
- package/dist/{index-8kvc8ttn.js → index-xrs52f2c.js} +1 -1
- package/dist/{index-yrgm89r8.js → index-ydc0tk17.js} +1 -1
- package/dist/{index-1hnw0rhc.js → index-ytgmhxsj.js} +31 -31
- package/dist/{index-0248afsn.js → index-z5s398n0.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/injections-x3xya90r.js +2 -0
- package/dist/interactive-qc1j66mq.js +2 -0
- package/dist/key.cmd-972133dv.js +2 -0
- package/dist/log-shipper-hjnn1d5p.js +2 -0
- package/dist/{path-utils-35re7qf9.js → path-utils-hxdyv2zn.js} +1 -1
- package/dist/{plugin-system-c916v9an.js → plugin-system-cwznxqx5.js} +1 -1
- package/dist/prereqs-runner-27x3j1md.js +2 -0
- package/dist/profile-mount-8dc9jwt5.js +2 -0
- package/dist/prune-stale-shims-23y0stm8.js +2 -0
- package/dist/register-core-0d4adnqp.js +2 -0
- package/dist/secondary-profile-attach-qk5tde9n.js +2 -0
- package/dist/subprocess-1nna3d3x.js +2 -0
- package/dist/telemetry-8jfdyt51.js +2 -0
- package/dist/tree-sitter-javascript-q22gvtms.js +2 -0
- package/dist/tree-sitter-markdown-pntsjzm3.js +2 -0
- package/dist/tree-sitter-markdown_inline-g1wzqf7k.js +2 -0
- package/dist/tree-sitter-typescript-m9yfes10.js +2 -0
- package/dist/tree-sitter-zig-jmh62j90.js +2 -0
- package/dist/tunnel-bootstrap-5wgt9a1h.js +2 -0
- package/package.json +1 -1
- package/dist/app-y4yzq7yw.js +0 -2
- package/dist/bootstrap-workspace-zpm20zez.js +0 -2
- package/dist/bootstrap.service-pjmnpxha.js +0 -2
- package/dist/daemon-profile-vas1vf2t.js +0 -2
- package/dist/esm-9fpye77x.js +0 -2
- package/dist/gateway-client-43gzvj5s.js +0 -2
- package/dist/highlights-8d9mgr01.js +0 -2
- package/dist/highlights-jwvdxm9x.js +0 -2
- package/dist/highlights-qbx2vnme.js +0 -2
- package/dist/highlights-r3m83kn9.js +0 -2
- package/dist/highlights-s7mqapt6.js +0 -2
- package/dist/index-01qzsnwd.js +0 -16
- package/dist/index-hrdamx5j.js +0 -2
- package/dist/index-tmrbs96r.js +0 -11
- package/dist/index-z2yjbq9a.js +0 -26
- package/dist/injections-srewsjcz.js +0 -2
- package/dist/interactive-22ta89hc.js +0 -2
- package/dist/key.cmd-wgcq6kt8.js +0 -2
- package/dist/log-shipper-k24m8yw5.js +0 -2
- package/dist/prereqs-runner-ca4kt803.js +0 -2
- package/dist/profile-mount-npcknw6v.js +0 -2
- package/dist/prune-stale-shims-nkx9vq5m.js +0 -2
- package/dist/register-core-xhrk6ay5.js +0 -2
- package/dist/secondary-profile-attach-db5cr3e1.js +0 -2
- package/dist/subprocess-g9sk1ep9.js +0 -2
- package/dist/telemetry-tnq47dcs.js +0 -2
- package/dist/tree-sitter-javascript-3h25c6bs.js +0 -2
- package/dist/tree-sitter-markdown-3nemcjhe.js +0 -2
- package/dist/tree-sitter-markdown_inline-16ftwa53.js +0 -2
- package/dist/tree-sitter-typescript-f6mq6ze6.js +0 -2
- package/dist/tree-sitter-zig-s2trkm2d.js +0 -2
- package/dist/tunnel-bootstrap-2kg79ng8.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$c as
|
|
2
|
+
import{$c as f,Wc as a,Xc as b,Yc as c,Zc as d,_c as e,ad as g,bd as h,cd as i,dd as j,ed as k,fd as l,gd as m,hd as n,id as o,jd as p,kd as q,ld as r,md as s,nd as t,od as u,pd as v,qd as w,rd as x,sd as y,td as z,ud as A,vd as B}from"./index-h74va4wd.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";export{m as writeProfile,x as writeAgentConfigAwaitSecrets,w as writeAgentConfig,j as writeActiveProfileName,l as readProfile,y as readAgentConfigWithSecrets,u as readAgentConfig,i as readActiveProfileName,z as readActiveProfile,k as listProfileNames,f as getProfilesDir,h as getProfilePath,q as getProductionGatewayUrls,v as getOrCreateAgentInstanceId,t as getAgentConfigSeed,r as getAgentConfigPath,s as getAgentConfigDefaults,g as getActiveProfilePointerPath,p as ensureProfilesInitialized,n as deleteProfile,o as buildProfileSeed,e as assertValidProfileName,B as applyAgentSecretsToEnv,A as applyAgentConfigToEnv,c as NAMED_ENV_PRESETS,d as DEFAULT_PROFILE_NAME,a as CURRENT_CONFIG_SCHEMA_VERSION,b as BUILTIN_PROFILE_SEEDS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{oc as G,vc as f,wc as y,xc as V}from"./index-1mppacnx.js";import"./index-c7554sg7.js";var N={pending:()=>G.gray("\u25CF"),active:()=>G.cyan("\u25B6"),ok:()=>G.green("\u2713"),warn:()=>G.yellow("\u26A0"),fail:()=>G.red("\u2717")};function L(E,A){if(A)console.log(" "+E)}async function O(E,A=2000){let W=new AbortController,j=setTimeout(()=>W.abort(),A);try{let q=await fetch(`${E}/health/ready`,{signal:W.signal});if(q.status!==200&&q.status!==503)return null;return await q.json()}catch{return null}finally{clearTimeout(j)}}function P(E){if(!E?.message)return null;let A=E.message.match(/provider:\s*(\S+)/);return A?A[1]:null}async function M(E,A={}){let W=A.timeoutMs??60000,j=A.pollIntervalMs??500,q=A.verbose!==!1;if(q)f("Waiting for agent to become ready");let C={daemon:!1,awaiting:!1,initializing:!1,db:!1,session:!1,tunnel:!1},z=Date.now(),X="",H=0,D=null;while(Date.now()-z<W){let Q=await O(E);if(!Q){await T(j);continue}if(!C.daemon)L(`${N.ok()} Daemon listening on ${E}`,q),C.daemon=!0;let F=Q.bootState??"unknown",Y=Q.components??{};if(F!==X){if(X=F,F==="awaiting-config"&&!C.awaiting)L(`${N.warn()} Workspace config: ${G.yellow("awaiting OAuth credentials \u2014 register this agent in the VibeControls UI")}`,q),C.awaiting=!0;else if(F==="initializing"&&!C.initializing)L(`${N.active()} Finalizing: fetching encryption key, opening storage, loading plugins\u2026`,q),C.initializing=!0}if(F==="awaiting-config"){if(H++,H>=2)return{outcome:"awaiting-config",bootState:F,degradedReasons:[],summary:"Agent is awaiting workspace registration. Open the VibeControls UI \u2192 Agents \u2192 Add Agent, paste the API Key and Tunnel URL printed above."}}else H=0;if(Y.db?.ok&&!C.db)L(`${N.ok()} Storage encryption key loaded, DB opened`,q),C.db=!0;if(Y.session?.ok&&!C.session){let x=Y.session.message??"";L(`${N.ok()} Plugins started \u2014 ${x}`,q),C.session=!0}let Z=P(Y.tunnel);if(Z&&Z!=="bootstrap"&&Z!==D){if(D=Z,!C.tunnel)L(`${N.ok()} Tunnel ready (provider: ${Z})`,q),C.tunnel=!0}let I=Q.status==="degraded";if(F==="ready"&&!I){if(q)V(),y("Status",G.green("ready"));return{outcome:"ready",bootState:F,degradedReasons:[],summary:"Agent ready."}}if(F==="degraded"||F==="ready"&&I){let x=Q.degradedReasons??[],_=x;if(x.length===0){let J=[];for(let[$,K]of Object.entries(Y)){if($==="boot"||$==="lifecycle")continue;if(K&&!K.ok&&K.message)J.push({plugin:$,message:K.message})}for(let[$,K]of Object.entries(Q.plugins??{}))if(K&&!K.ok&&K.message)J.push({plugin:`plugin:${$}`,message:K.message});_=J}if(q){V(),L(`${N.fail()} Agent boot ${G.red("degraded")} \u2014 investigate before retrying`,q);for(let J of _)L(` ${G.gray("\xB7")} [${J.plugin}] ${J.message}`,q);V()}return{outcome:"degraded",bootState:F,degradedReasons:_,summary:_.length?`Agent degraded: ${_.map((J)=>`[${J.plugin}] ${J.message}`).join("; ")}`:"Agent degraded with no reported reason \u2014 check vibe logs."}}await T(j)}if(q)V(),L(`${N.warn()} Timed out after ${Math.round(W/1000)}s; last bootState=${X||"unknown"}. Check ${G.bold("vibe logs")} for details.`,q),V();return{outcome:"timeout",bootState:X||"unknown",degradedReasons:[],summary:`Timed out waiting for ready. Last bootState=${X||"unknown"}.`}}function T(E){return new Promise((A)=>setTimeout(A,E))}export{M as trackAgentReady};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{n as a}from"./index-qzwphe3q.js";import"./index-5wpck4aw.js";import"./index-ytgmhxsj.js";import"./index-6jzsthh9.js";import"./index-1zf3r23y.js";import"./index-rw9x93zb.js";import"./index-nmk7cbj5.js";import"./index-a9ejdv22.js";import"./index-4wgjx8bf.js";import"./index-s2xpdnsj.js";import"./index-0ckffygp.js";import"./index-rc79x8fw.js";import"./index-ydc0tk17.js";import"./index-52cp759f.js";import"./index-hvjqgb97.js";import"./index-rqq0k5fc.js";import"./index-5dysvvjv.js";import"./index-pgew6sge.js";import"./index-b6x6a4xp.js";import"./index-h74va4wd.js";import"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";export{a as createApp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Id as K,Od as D}from"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";var b="bridge-client",U=2000,G=30000,N=30000,O=6,z={ws:null,pingTimer:null,reconnectTimer:null,reconnectAttempt:0,connected:!1,stopped:!1,agentId:null,profile:"default",pendingEvents:[]};function Z(J,Q,$){D().logger[J](b,Q,$)}function C(J){try{let Q=new URL(J);Q.protocol=Q.protocol==="https:"?"wss:":"ws:",Q.pathname="/agent-bridge",Q.search="",Q.hash="";let $=process.env.VIBE_BRIDGE_URL;if($)return $;return Q.toString()}catch{return process.env.VIBE_BRIDGE_URL??""}}async function x(){if(z.stopped||z.ws)return;if(!K.isConfigured()){Z("debug","Gateway client not configured yet; deferring bridge connect");return}if(!z.agentId){Z("debug","No agentId set yet; deferring bridge connect");return}let J,Q,$;try{let Y=await K.getAccessToken();J=Y.token,Q=Y.workspaceGatewayUrl,$=Y.workspaceId}catch(Y){Z("warn","Failed to fetch access token for bridge",{error:Y instanceof Error?Y.message:String(Y)}),W();return}if(!J||!Q){W();return}let q=C(Q);if(!q){Z("warn","Cannot resolve bridge URL from workspaceGatewayUrl",{workspaceGatewayUrl:Q}),W();return}Z("info","Connecting to agent-bridge",{url:q,agentId:z.agentId});let H;try{H=new WebSocket(q,{headers:{Authorization:`Bearer ${J}`,...$?{"x-workspace-id":$}:{}}})}catch(Y){Z("warn","Bridge connect threw",{error:Y instanceof Error?Y.message:String(Y)}),W();return}z.ws=H,H.addEventListener("open",()=>{z.reconnectAttempt=0,Z("info","Bridge socket open \u2014 sending hello"),X({type:"hello",agentId:z.agentId,profile:z.profile,version:process.env.npm_package_version??"unknown"})}),H.addEventListener("message",(Y)=>{let B=typeof Y.data==="string"?Y.data:Y.data instanceof Blob?"":new TextDecoder().decode(Y.data);if(!B)return;let V;try{V=JSON.parse(B)}catch{return}if(V.type==="welcome")z.connected=!0,Z("info","Bridge welcome received \u2014 connection ready",{workspaceId:typeof V.workspaceId==="string"?V.workspaceId:void 0}),L(),P();else if(V.type==="error")Z("warn","Bridge error frame",{error:V})}),H.addEventListener("close",(Y)=>{if(Z("info","Bridge socket closed",{code:Y.code,reason:Y.reason}),M(),!z.stopped)W()}),H.addEventListener("error",(Y)=>{Z("warn","Bridge socket error",{message:Y.message})})}function X(J){if(!z.ws||z.ws.readyState!==1)return!1;try{return z.ws.send(JSON.stringify(J)),!0}catch(Q){return Z("debug","safeSend failed",{error:Q instanceof Error?Q.message:String(Q)}),!1}}function L(){F(),z.pingTimer=setInterval(()=>{X({type:"ping"})},N),z.pingTimer.unref?.()}function F(){if(z.pingTimer)clearInterval(z.pingTimer),z.pingTimer=null}function M(){z.connected=!1,F(),z.ws=null}function W(){if(z.stopped||z.reconnectTimer)return;let J=z.reconnectAttempt+1,Q=Math.min(U*2**Math.min(J-1,5),G);if(z.reconnectAttempt=J,J===O)Z("warn",`Bridge unavailable after ${J} attempts \u2014 falling back to existing HTTP polling for heartbeat/tunnel sync. Will keep retrying in the background.`);z.reconnectTimer=setTimeout(()=>{z.reconnectTimer=null,x()},Q),z.reconnectTimer.unref?.()}function P(){if(!z.connected)return;while(z.pendingEvents.length>0){let J=z.pendingEvents.shift();if(!X({type:J.type,...J.payload})){z.pendingEvents.unshift(J);return}}}var R=500;function j(J){if(z.connected&&X({type:J.type,...J.payload}))return;if(z.pendingEvents.length>=R)z.pendingEvents.shift();z.pendingEvents.push(J)}var I={start(J,Q){if(z.stopped=!1,z.agentId===J&&z.connected)return;z.agentId=J,z.profile=Q||"default",x()},stop(){if(z.stopped=!0,z.reconnectTimer)clearTimeout(z.reconnectTimer),z.reconnectTimer=null;let J=z.ws;try{J?.close(1000,"agent shutdown")}catch{}M()},publishEvent(J){j({type:"event",payload:{topic:J.topic,payload:J.payload}})},publishLog(J){j({type:"log",payload:{payload:J}})},isConnected(){return z.connected},isFallbackEngaged(){return z.reconnectAttempt>=O&&!z.connected}};export{I as bridgeClient};
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{H as O}from"./index-mxc61yr1.js";import{I as Q,J as w}from"./index-
|
|
3
|
+
import{H as O}from"./index-mxc61yr1.js";import{I as Q,J as w}from"./index-aq81xmn0.js";import"./index-d1xjj001.js";import"./index-b5dhmybd.js";import"./index-e1bw1bwr.js";import"./index-1zf3r23y.js";import"./index-rw9x93zb.js";import"./index-nmk7cbj5.js";import{wa as Z,za as I}from"./index-a9ejdv22.js";import{Aa as G,Ba as H}from"./index-4wgjx8bf.js";import{Wa as J}from"./index-s2xpdnsj.js";import{Xa as U}from"./index-0ckffygp.js";import"./index-rc79x8fw.js";import{bb as K}from"./index-ydc0tk17.js";import"./index-52cp759f.js";import"./index-rqq0k5fc.js";import"./index-5dysvvjv.js";import"./index-pgew6sge.js";import{dc as $}from"./index-8sdrhr3q.js";import"./index-8nqp3a4d.js";import{nc as E}from"./index-1mppacnx.js";import"./index-thammzct.js";import"./index-b6x6a4xp.js";import"./index-h74va4wd.js";import{Od as Y}from"./index-js1xn4sq.js";import{$d as W,de as X}from"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";import{join as B}from"path";if(typeof Bun>"u")console.error(`\x1B[31mError:\x1B[0m VibeControls Agent requires the Bun runtime.
|
|
4
4
|
Install Bun: https://bun.sh
|
|
5
5
|
Then run: bun run vibe ...`),process.exit(1);var T=process.argv.slice(2),_=T.includes("--plain")||T.includes("--json")||process.env.NO_COLOR==="1"||!process.stdout.isTTY;E(!_);try{O()}catch{}var N="1.0.0";try{let q=B(import.meta.dir,"..","package.json");N=(await Bun.file(q).json()).version}catch{}var x=new $;x.name("vibe").description("VibeControls Agent CLI \u2014 Remote development environment management").version(N,"-v, --version").option("--provider <name>","Override the default provider for tunnel/session operations").option("-p, --profile <name>","Target a specific profile (one-off; doesn't change the persisted default). See `vibe profile`.").option("--json","Emit machine-readable JSON instead of human output.").option("--plain","Force plain-text output (no interactive UI).").hook("preAction",(q,z)=>{let F=q.opts().profile;if(F)process.env.VIBECONTROLS_PROFILE=F;try{K.init(),K.emit("command.executed",{command_name:z.name()})}catch{}});w(x);async function M(){let q=new J;try{await q.loadCorePlugins()}catch{}try{await q.loadAll()}catch{}let z=new Z,F={storage:{async get(){return null},async set(){},async delete(){return!1},async list(){return[]},async deleteAll(){return 0}},logger:Y().logger,serviceRegistry:z,getProvider:(L)=>z.getProvider(L),getAgentBaseUrl:()=>process.env.AGENT_URL||"http://localhost:3005",getAgentVersion:()=>N,broadcast:()=>{},workspaceQuery:async()=>({data:void 0,errors:[{message:"workspaceQuery is not available in CLI mode"}]}),isGatewayConfigured:()=>!1,getAgentRecordId:async()=>null,getWorkspaceId:async()=>null,getConfig:async()=>{return},getPluginRegistry:()=>X(),getDataDir:()=>W(),cliContributors:new G,telemetry:{emit:(L,D)=>{try{K.emit(L,D??{})}catch{}}},os:U(),iframeBridge:I()};H(F.cliContributors);try{await q.dispatchCliSetup(x,F)}catch{}x.configureHelp({formatHelp:()=>Q(x,!0)}),await x.parseAsync()}M().then(()=>{process.exit(process.exitCode??0)}).catch((q)=>{console.error(`\x1B[31mFatal:\x1B[0m ${q instanceof Error?q.message:q}`),process.exit(1)});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Md as a,Nd as b,Od as c,Pd as d,Qd as e}from"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";export{a as profileRegistry,d as getOrCreateProfile,c as getDaemonProfile,b as ensureDaemonProfile,e as __resetDaemonProfileForTests};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$b as d,Yb as a,Zb as b,_b as c,ac as e,bc as f,cc as g,dc as h,ec as i,fc as j,gc as k}from"./index-8sdrhr3q.js";import"./index-c7554sg7.js";export{a as program,d as createOption,b as createCommand,c as createArgument,j as Option,g as InvalidOptionArgumentError,f as InvalidArgumentError,k as Help,e as CommanderError,h as Command,i as Argument};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./index-
|
|
2
|
+
import"./index-c7554sg7.js";var e=null;function n(t){e=t}function r(){return e}export{n as setFinalizeRetryHandle,r as getFinalizeRetryHandle};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Od as Y}from"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";var Z=[300000,600000,900000,1800000];function j(R){let W=R.backoffsMs??Z,w=0,z=!1,G=null,J=null,I=null,q=Y();if(q.getBootState()==="ready")return{cancel(){},async forceRetryNow(){return{ok:!0}},getState(){return{attempt:0,cancelled:!0,nextAttemptAt:null}}};function Q(){if(G!==null)clearTimeout(G),G=null,J=null}function X(){if(z)return Promise.resolve({ok:!1,error:"retry worker cancelled"});if(q.getBootState()==="ready")return z=!0,Q(),Promise.resolve({ok:!0});if(I)return I;return w+=1,R.onAttempt?.(w),q.logger.info("finalize-retry",`Background finalize retry attempt ${w}`),I=(async()=>{try{let v=await R.trigger();if(v.ok)q.logger.info("finalize-retry",`Background finalize succeeded on attempt ${w} \u2014 agent recovered`),z=!0,Q();else q.recordFinalizeError(v.error,w),q.logger.warn("finalize-retry",`Background finalize attempt ${w} failed`,{error:v.error});return v}catch(v){let H=v instanceof Error?v.message:String(v);return q.recordFinalizeError(H,w),q.logger.error("finalize-retry",`Background finalize attempt ${w} threw`,{error:H}),{ok:!1,error:H}}finally{I=null}})(),I}function V(){if(z)return;if(q.getBootState()==="ready"){z=!0;return}if(G!==null)return;let v=Math.min(w,W.length-1),H=W[v];J=Date.now()+H,G=setTimeout(async()=>{if(G=null,await X(),!z&&q.getBootState()!=="ready")V()},H)}return V(),{cancel(){z=!0,Q()},async forceRetryNow(){if(q.getBootState()==="ready")return{ok:!0};if(z)return{ok:!1,error:"retry worker cancelled"};Q();let v=await X();if(!z&&q.getBootState()!=="ready")V();return v},getState(){return{attempt:w,cancelled:z,nextAttemptAt:J?new Date(J).toISOString():null}}}}export{j as startFinalizeRetryWorker};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{f as D}from"./index-
|
|
2
|
+
import{f as D}from"./index-ep3zb271.js";import{g as C}from"./index-kt5zxp42.js";import{ge as z,ie as B}from"./index-c7554sg7.js";var H=z((v)=>{Object.defineProperty(v,"__esModule",{value:!0});v.getMachineId=void 0;var E=B("fs"),F=D(),q=C();async function G(){try{return(await E.promises.readFile("/etc/hostid",{encoding:"utf8"})).trim()}catch(k){q.diag.debug(`error reading machine id: ${k}`)}try{return(await(0,F.execAsync)("kenv -q smbios.system.uuid")).stdout.trim()}catch(k){q.diag.debug(`error reading machine id: ${k}`)}return}v.getMachineId=G});export default H();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{f as D}from"./index-
|
|
2
|
+
import{f as D}from"./index-ep3zb271.js";import{g as C}from"./index-kt5zxp42.js";import{ge as B}from"./index-c7554sg7.js";var H=B((q)=>{Object.defineProperty(q,"__esModule",{value:!0});q.getMachineId=void 0;var E=D(),F=C();async function G(){try{let f=(await(0,E.execAsync)('ioreg -rd1 -c "IOPlatformExpertDevice"')).stdout.split(`
|
|
3
3
|
`).find((z)=>z.includes("IOPlatformUUID"));if(!f)return;let k=f.split('" = "');if(k.length===2)return k[1].slice(0,-1)}catch(b){F.diag.debug(`error reading machine id: ${b}`)}return}q.getMachineId=G});export default H();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g as B}from"./index-
|
|
2
|
+
import{g as B}from"./index-kt5zxp42.js";import{ge as z,ie as A}from"./index-c7554sg7.js";var F=z((k)=>{Object.defineProperty(k,"__esModule",{value:!0});k.getMachineId=void 0;var C=A("fs"),D=B();async function E(){let v=["/etc/machine-id","/var/lib/dbus/machine-id"];for(let w of v)try{return(await C.promises.readFile(w,{encoding:"utf8"})).trim()}catch(b){D.diag.debug(`error reading machine id: ${b}`)}return}k.getMachineId=E});export default F();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g as q}from"./index-
|
|
2
|
+
import{g as q}from"./index-kt5zxp42.js";import{ge as k}from"./index-c7554sg7.js";var z=k((b)=>{Object.defineProperty(b,"__esModule",{value:!0});b.getMachineId=void 0;var v=q();async function w(){v.diag.debug("could not read machine-id: unsupported platform");return}b.getMachineId=w});export default z();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{f as E}from"./index-
|
|
2
|
+
import{f as E}from"./index-ep3zb271.js";import{g as D}from"./index-kt5zxp42.js";import{ge as B,ie as C}from"./index-c7554sg7.js";var J=B((v)=>{Object.defineProperty(v,"__esModule",{value:!0});v.getMachineId=void 0;var q=C("process"),F=E(),G=D();async function H(){let b="%windir%\\System32\\REG.exe";if(q.arch==="ia32"&&"PROCESSOR_ARCHITEW6432"in q.env)b="%windir%\\sysnative\\cmd.exe /c "+b;try{let k=(await(0,F.execAsync)(`${b} QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`)).stdout.split("REG_SZ");if(k.length===2)return k[1].trim()}catch(f){G.diag.debug(`error reading machine id: ${f}`)}return}v.getMachineId=H});export default J();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{i as L}from"./index-cs78wq6y.js";import{C as N,D as M,E as D,F as m,G as k}from"./index-6jzsthh9.js";import{Xa as v}from"./index-0ckffygp.js";import{
|
|
2
|
+
import{i as L}from"./index-cs78wq6y.js";import{C as N,D as M,E as D,F as m,G as k}from"./index-6jzsthh9.js";import{Xa as v}from"./index-0ckffygp.js";import{Ub as I,Vb as h}from"./index-pgew6sge.js";import{jc as p,kc as d,lc as w}from"./index-8nqp3a4d.js";import{Cc as f,Dc as x,qc as O,rc as q,sc as B,uc as A,vc as S,yc as i,zc as E}from"./index-1mppacnx.js";import{Gc as r}from"./index-thammzct.js";import{Kc as n,Lc as C,Nc as y,Oc as l,Pc as T}from"./index-b6x6a4xp.js";import"./index-h74va4wd.js";import{Fd as b,Id as g}from"./index-js1xn4sq.js";import"./index-a4854mwz.js";import"./index-4qq083yd.js";import"./index-c7554sg7.js";import{promises as J}from"fs";import H2 from"path";import V2 from"os";function u(j,H){let Q=Number.parseInt(process.env[j]??"",10);return Number.isInteger(Q)&&Q>0?Q:H}var j2=u("VIBECONTROLS_MAX_CONCURRENT_TASKS",4),Q2=u("VIBECONTROLS_MAX_TASK_OUTPUT_BYTES",1048576),Z2=new Set(["bash","sh","zsh","python","python3","node","bun","powershell","pwsh","cmd"]);async function $2(j,H){if(!j.command)throw Error("Command is required");let Q=j.cwd?(await D(j.cwd,{mustExist:!0})).path:process.cwd(),V=Bun.spawn(v().shellArgv(j.command),{cwd:Q,env:{...process.env,...j.env},stdout:"pipe",stderr:"pipe"}),Z=!1,z;if(H&&H>0)z=setTimeout(()=>{Z=!0,V.kill()},H);let[K,$]=await Promise.all([R(V.stdout,()=>V.kill()),R(V.stderr,()=>V.kill())]),Y=await V.exited;if(z)clearTimeout(z);if(Z)throw Error(`Command timed out after ${H}ms`);return{stdout:K,stderr:$,exitCode:Y}}async function z2(j,H){if(!j.script)throw Error("Script is required");let Q=v().platform==="win32",V=j.interpreter||(Q?"powershell":"bash");if(!Z2.has(V)||V.includes("/"))throw Error(`Interpreter '${V}' is not allowed`);let Z=j.cwd?(await D(j.cwd,{mustExist:!0})).path:process.cwd(),z=V2.tmpdir(),K=V==="powershell"||V==="pwsh"?"ps1":V==="cmd"?"cmd":"sh",$=H2.join(z,`vibecontrols-script-${globalThis.crypto.randomUUID()}.${K}`);await J.writeFile($,j.script,{mode:448});try{let Y=j.env?{...process.env,...j.env}:process.env,W=V==="powershell"||V==="pwsh"?[V,"-NoProfile","-ExecutionPolicy","Bypass","-File",$]:V==="cmd"?["cmd","/c",$]:[V,$],X=Bun.spawn(W,{cwd:Z,env:Y,stdout:"pipe",stderr:"pipe"}),G=!1,_;if(H&&H>0)_=setTimeout(()=>{G=!0,X.kill()},H);let[a,e]=await Promise.all([R(X.stdout,()=>X.kill()),R(X.stderr,()=>X.kill())]),t=await X.exited;if(_)clearTimeout(_);if(G)throw Error(`Script timed out after ${H}ms`);return{stdout:a,stderr:e,exitCode:t}}finally{await J.unlink($).catch(()=>{})}}async function R(j,H){let Q=new TextDecoder,V="",Z=0,z=!1;for await(let K of j){if(Z+=K.byteLength,Z>Q2){if(!z)z=!0,H(),V+=`
|
|
3
3
|
[output truncated: task output limit exceeded]
|
|
4
4
|
`;continue}V+=Q.decode(K,{stream:!0})}return V+=Q.decode(),V}async function Y2(j){if(!j.path)throw Error("Path is required");switch(j.operation){case"read":{let H=(await D(j.path,{mustExist:!0})).path;if(N(H))throw Error("Access to sensitive files not allowed");return await m(H),{content:await J.readFile(H,"utf-8"),path:H}}case"write":{if(!j.content)throw Error("Content is required for write operation");let H=(await D(j.path,{forWrite:!0})).path;if(M(H)||N(H))throw Error("Write access to sensitive files not allowed");return await J.writeFile(H,j.content),{success:!0,path:H}}case"delete":{let H=(await D(j.path,{mustExist:!0})).path;if(M(H)||N(H))throw Error("Delete access to this path is not allowed");return await J.unlink(H),{success:!0,path:H}}case"exists":try{let H=(await D(j.path)).path;return await J.access(H),{exists:!0,path:H}}catch{return{exists:!1}}case"list":{let H=(await D(j.path,{mustExist:!0})).path;return{files:(await k(H)).map((V)=>V.name),path:H}}default:throw Error(`Unknown file operation: ${j.operation}`)}}async function K2(j,H,Q,V){try{let Z=await j.getTask(H.id);if(Z&&Z.status!=="pending")return;await j.updateTask(H.id,{status:"running"});let z=JSON.parse(H.payload),K,$;switch(H.type){case"command":{let X=await $2(z,V?.timeout);K=X,$=X.exitCode;break}case"script":{let X=await z2(z,V?.timeout);K=X,$=X.exitCode;break}case"file_operation":K=await Y2(z);break;default:throw Error(`Unknown task type: ${H.type}`)}let Y=$!==void 0&&$!==0,W=Y?"failed":"completed";if(await j.updateTask(H.id,{status:W,result:JSON.stringify(K),...$!==void 0&&{exitCode:$},...Y&&{error:`Process exited with code ${$}`}}),V?.callbackUrl)P(V.callbackUrl,{agentTaskId:H.id,status:W,result:K,exitCode:$,...Y&&{error:`Process exited with code ${$}`}})}catch(Z){let z=Z instanceof Error?Z.message:String(Z);try{await j.updateTask(H.id,{status:"failed",error:z})}catch(K){console.warn(`[task] failed to mark task ${H.id} as failed: ${K instanceof Error?K.message:String(K)}`)}if(V?.callbackUrl)P(V.callbackUrl,{agentTaskId:H.id,status:"failed",error:z})}finally{Q.active=Math.max(0,Q.active-1)}}function P(j,H){fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H),signal:AbortSignal.timeout(1e4)}).catch(()=>{})}function c(j){let{db:H}=j,Q={active:0};return new h().get("/",async({query:V})=>{if(V.status==="pending")return{tasks:await H.getPendingTasks()};return{tasks:await H.getAllTasks()}}).get("/:id",async({params:V,set:Z})=>{let z=await H.getTask(V.id);if(!z)return Z.status=404,{error:"Task not found"};return{task:z}}).post("/legacy",async({body:V,set:Z})=>{try{return{task:await H.createTask({id:globalThis.crypto.randomUUID(),type:"file_operation",status:"completed",payload:JSON.stringify({operation:"exists",path:process.cwd(),meta:V}),result:JSON.stringify({legacy:!0,note:"Legacy doctor-script task accepted (no-op)."})})}}catch(z){return Z.status=500,{error:"Failed to create task",details:String(z)}}},{body:I.Any()}).post("/",async({body:V,request:Z,server:z,set:K})=>{let $=V;if($&&typeof $==="object"&&!$.type&&!$.payload&&($.title||$.description||$.command))try{return{task:await H.createTask({id:globalThis.crypto.randomUUID(),type:"file_operation",status:"completed",payload:JSON.stringify({operation:"exists",path:process.cwd(),meta:$}),result:JSON.stringify({legacy:!0,note:"Legacy doctor-script task accepted (no-op)."})})}}catch(W){return K.status=500,{error:"Failed to create task",details:String(W)}}let Y=V;try{if(Y.type==="command"||Y.type==="script"){let X=await L(Z,"VIBECONTROLS_ALLOW_REMOTE_SHELL_TASK",z,{getConfig:(G)=>H.getConfig(G)});if(X)return K.status=403,{error:"Forbidden",message:X}}else if(Y.type==="file_operation"&&["write","delete"].includes(String(Y.payload?.operation??""))){let X=await L(Z,"VIBECONTROLS_ALLOW_REMOTE_FILE_TASK",z,{getConfig:(G)=>H.getConfig(G)});if(X)return K.status=403,{error:"Forbidden",message:X}}if(Q.active>=j2)return K.status=429,{error:"Too many tasks are already running"};if(Q.active+=1,Y.callbackUrl&&!b(Y.callbackUrl,(()=>{let X=g.getConfig();return[X?.globalGatewayUrl,X?.workspaceGatewayUrl]})()))return Q.active=Math.max(0,Q.active-1),K.status=400,{error:"callbackUrl is not allowed"};let W=await H.createTask({id:globalThis.crypto.randomUUID(),type:Y.type,status:"pending",payload:JSON.stringify(Y.payload),...Y.calendarTaskId&&{calendarTaskId:Y.calendarTaskId},...Y.timeout&&{timeout:Y.timeout}});return K2(H,W,Q,{timeout:Y.timeout,callbackUrl:Y.callbackUrl}),{task:W}}catch(W){return Q.active=Math.max(0,Q.active-1),K.status=500,{error:"Failed to create task",details:String(W)}}},{body:I.Any()}).post("/:id/cancel",async({params:V,set:Z})=>{let z=await H.getTask(V.id);if(!z)return Z.status=404,{error:"Task not found"};if(z.status!=="pending")return Z.status=400,{error:"Only pending tasks can be cancelled"};return await H.updateTask(V.id,{status:"failed",error:"Task cancelled by user"}),{success:!0}}).delete("/:id",async({params:V,set:Z})=>{let z=await H.getTask(V.id);if(!z)return Z.status=404,{error:"Task not found"};if(z.status==="pending")await H.updateTask(V.id,{status:"failed",error:"Task cancelled via DELETE"});return{success:!0,status:z.status}})}var U="http://localhost:3005";function F(j){return`/api/profiles/${encodeURIComponent(y(j))}/tasks`}function o(j){let H=j.command("task").description("Manage background tasks");H.command("list").description("List tasks").option("--status <status>","Filter by status").option("--profile <name>","Profile name (overrides default resolution)").option("--agent-url <url>","Agent URL",U).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(Q){let V={...j.opts(),...Q};try{let Z=C(Q),z=F(V),K=Q.status?`${z}/?status=${encodeURIComponent(Q.status)}`:`${z}/`;await d({mode:p(V),fetchData:async()=>{return(await l(Z,K)).tasks||[]},plain:($)=>{if(!$||$.length===0){A("No tasks found.");return}S("Tasks"),i($.map((Y)=>({ID:x(Y.id),Type:Y.type||"-",Status:f(Y.status),Created:Y.createdAt?E(Y.createdAt):"-"})))},interactive:async($)=>{if(!$||$.length===0){S("Tasks"),A("No tasks found.");return}let Y=$.map((W)=>({id:String(W.id),label:W.type||x(W.id),hint:W.status||"",detail:[`ID: ${W.id}`,`Type: ${W.type??"-"}`,`Status: ${f(W.status)}`,`Created: ${W.createdAt?E(W.createdAt):"-"}`].join(`
|
|
5
5
|
`)}));await r({title:`vibe task list \u2014 ${$.length} task(s)`,rows:Y})},json:($)=>$.map((Y)=>({id:Y.id,type:Y.type??null,status:Y.status??null,createdAt:Y.createdAt??null}))})}catch(Z){O(q(Z))}}),H.command("run").description("Run a new task").requiredOption("-c, --command <cmd>","Command to run").option("--cwd <dir>","Working directory").option("--profile <name>","Profile name (overrides default resolution)").option("--agent-url <url>","Agent URL",U).option("--json","Emit JSON").action(async function(Q){let V={...j.opts(),...Q};try{let Z=C(Q);if(!n(Z)&&process.env.VIBECONTROLS_ALLOW_REMOTE_SHELL_TASK!=="1"){if(V.json){w(V,{ok:!1,error:"Remote shell task refused without env override"});return}O("Refusing to create a shell task on a remote agent URL. Set VIBECONTROLS_ALLOW_REMOTE_SHELL_TASK=1 only if you trust the target.");return}let z={command:Q.command};if(Q.cwd)z.cwd=Q.cwd;let K=F(V),$=await T(Z,`${K}/`,{type:"command",payload:z}),Y=$?.task?.id||$?.id||$?.taskId;if(w(V,{ok:!0,id:Y}))return;if(!Y){O("Task created but no ID returned by the agent");return}B(`Task created: ${x(Y)}`)}catch(Z){if(V.json){w(V,{ok:!1,error:q(Z)});return}O(q(Z))}}),H.command("cancel").description("Cancel a running task").requiredOption("-i, --id <id>","Task ID").option("--profile <name>","Profile name (overrides default resolution)").option("--agent-url <url>","Agent URL",U).option("--json","Emit JSON").action(async function(Q){let V={...j.opts(),...Q};try{let Z=C(Q),z=F(V);if(await T(Z,`${z}/${Q.id}/cancel`,{}),w(V,{ok:!0,id:Q.id}))return;B(`Task ${x(Q.id)} cancelled.`)}catch(Z){if(V.json){w(V,{ok:!1,error:q(Z)});return}O(q(Z))}})}function s(j,H){o(j)}function U2(j){return{name:"task",version:"2.2.0",description:"Background task execution \u2014 commands, scripts, file operations",capabilities:{storage:"rw",subprocess:!0,audit:!0,telemetry:!0},tags:["backend","cli"],cliCommand:"task",apiPrefix:"/api/tasks",createRoutes:(H)=>c(H),onCliSetup:async(H,Q)=>{s(H,Q)}}}export{U2 as createPlugin};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ie as A}from"./index-c7554sg7.js";var j=!process.env.NO_COLOR&&!!process.stdout.isTTY;function L(q){j=q}var C=(q,B)=>(F)=>j?`${q}${F}${B}`:F,z={bold:C("\x1B[1m","\x1B[22m"),dim:C("\x1B[2m","\x1B[22m"),italic:C("\x1B[3m","\x1B[23m"),underline:C("\x1B[4m","\x1B[24m"),red:C("\x1B[31m","\x1B[39m"),green:C("\x1B[32m","\x1B[39m"),yellow:C("\x1B[33m","\x1B[39m"),blue:C("\x1B[34m","\x1B[39m"),magenta:C("\x1B[35m","\x1B[39m"),cyan:C("\x1B[36m","\x1B[39m"),white:C("\x1B[37m","\x1B[39m"),gray:C("\x1B[90m","\x1B[39m"),brightRed:C("\x1B[91m","\x1B[39m"),brightGreen:C("\x1B[92m","\x1B[39m"),brightYellow:C("\x1B[93m","\x1B[39m"),brightBlue:C("\x1B[94m","\x1B[39m"),reset:"\x1B[0m"},Q={get success(){return z.green("\u2713")},get error(){return z.red("\u2717")},get warning(){return z.yellow("\u26A0")},get info(){return z.blue("\u25CF")},get running(){return z.green("\u25CF")},get stopped(){return z.red("\u25CB")},get pending(){return z.yellow("\u25CC")},get arrow(){return z.gray("\u2192")},get bullet(){return z.gray("\u2022")},get check(){return z.green("\u2714")}};function T(q){console.error(`${z.red("Error:")} ${q}`),process.exit(1)}function H(q){if(q instanceof Error)return q.message;if(typeof q==="string")return q;try{return JSON.stringify(q)}catch{return String(q)}}function M(q){console.log(` ${Q.success} ${q}`)}function f(q){console.log(` ${Q.warning} ${q}`)}function E(q){console.log(` ${Q.info} ${q}`)}function D(q){console.log(`
|
|
3
3
|
${z.bold(`\u2500\u2500 ${q} \u2500\u2500`)}
|
|
4
4
|
`)}function X(q,B){let F=B===null||B===void 0?z.gray("(none)"):String(B);console.log(` ${z.bold(q.padEnd(14))} ${F}`)}function $(){console.log()}function S(q){if(q.length===0){console.log(" (none)");return}console.table(q)}function W(q){let B=Date.now()-new Date(q).getTime(),F=Math.floor(B/1000);if(F<0)return"just now";if(F<60)return`${F}s ago`;let J=Math.floor(F/60);if(J<60)return`${J}m ago`;let N=Math.floor(J/60);if(N<24)return`${N}h ago`;let P=Math.floor(N/24);if(P<30)return`${P}d ago`;return`${Math.floor(P/30)}mo ago`}function x(q){if(q<60)return`${Math.floor(q)}s`;let B=Math.floor(q/60),F=Math.floor(q%60);if(B<60)return`${B}m ${F}s`;let J=Math.floor(B/60),N=B%60;return`${J}h ${N}m`}function K(q){if(q<1024)return`${q} B`;if(q<1048576)return`${(q/1024).toFixed(1)} KB`;if(q<1073741824)return`${(q/1048576).toFixed(1)} MB`;return`${(q/1073741824).toFixed(1)} GB`}function h(q){switch(q){case"running":case"active":case"healthy":case"success":case"completed":return z.green(q);case"stopped":case"inactive":case"terminated":case"failed":return z.red(q);case"starting":case"stopping":case"pending":case"warning":return z.yellow(q);case"error":return z.red(q);default:return q}}function k(q,B=10){if(q.length<=B)return q;return q.substring(0,B)+"..."}async function v(q,B=15000){let F=Date.now(),J=!1;while(Date.now()-F<B){try{if((await fetch(`${q}/health`)).ok){J=!0;break}}catch{}await new Promise((G)=>setTimeout(G,500))}if(!J){console.log(`
|
|
5
5
|
${Q.warning} Agent not yet responding at ${q}. Check ${z.bold("vibe logs")} for details.
|
|
6
|
-
`);return}let N=process.env.VIBECONTROLS_PROFILE||"default",P=`${q}/api/profiles/${encodeURIComponent(N)}/agent/tunnel`,R="(unavailable)";try{let{resolveDefaultApiKey:G}=await import("./key.cmd-
|
|
6
|
+
`);return}let N=process.env.VIBECONTROLS_PROFILE||"default",P=`${q}/api/profiles/${encodeURIComponent(N)}/agent/tunnel`,R="(unavailable)";try{let{resolveDefaultApiKey:G}=await import("./key.cmd-972133dv.js"),I=await G();if(I)R=I}catch{}let Y=R&&R!=="(unavailable)"?{"x-agent-api-key":R}:{},O="(not running)",Z=!1;try{let G=await fetch(P,{headers:Y});if(G.ok){let I=await G.json();if(I.tunnelUrl)O=I.tunnelUrl;else if(I.status!=="inactive")Z=!0}}catch{}if(Z||O==="(not running)"){process.stdout.write(` ${Q.info} Provisioning tunnel (first run downloads the tunnel binary)\u2026`);let G=150000,I=Date.now();while(Date.now()-I<G){try{let V=await fetch(P,{headers:Y});if(V.ok){let _=await V.json();if(_.tunnelUrl){O=_.tunnelUrl;break}}}catch{}await new Promise((V)=>setTimeout(V,1500)),process.stdout.write(`\r ${Q.info} Provisioning tunnel (first run downloads the tunnel binary)\u2026 ${Math.round((Date.now()-I)/1000)}s`)}process.stdout.write(`
|
|
7
7
|
`)}if(D("Agent Connection Details"),X("Agent URL:",q),X("API Key:",R),X("Tunnel URL:",O==="(not running)"?z.yellow(O):z.green(O)),$(),console.log(" Copy the API Key and Tunnel URL into the VibeControls UI agent configuration."),O==="(not running)")console.log(` ${z.yellow("Tunnel still provisioning")} \u2014 the cloudflared download may still be running in the daemon.`),console.log(` Re-check shortly: ${z.bold("vibe url")}`),console.log(` Start it manually: ${z.bold(`vibe tunnel agent --start --agent-url ${q}`)}`),console.log(` If it never appears: ${z.bold("vibe logs --tail 80")} (look for 'tunnel-bootstrap' / 'install')`);$()}
|
|
8
|
-
export{L as
|
|
8
|
+
export{L as nc,z as oc,Q as pc,T as qc,H as rc,M as sc,f as tc,E as uc,D as vc,X as wc,$ as xc,S as yc,W as zc,x as Ac,K as Bc,h as Cc,k as Dc,v as Ec};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{va as D}from"./index-
|
|
2
|
+
import{va as D}from"./index-nmk7cbj5.js";import{Fa as U,Ha as M,Pa as R}from"./index-s2xpdnsj.js";import{Xa as I}from"./index-0ckffygp.js";import{Mc as b}from"./index-b6x6a4xp.js";import{Id as x,Od as u}from"./index-js1xn4sq.js";import{$d as V,de as C}from"./index-a4854mwz.js";import{ie as L}from"./index-c7554sg7.js";import{existsSync as g,readFileSync as E,unlinkSync as Wz,writeFileSync as A}from"fs";import{join as c}from"path";var l=".consent.json";function Oz(z){try{let J=E(q(z),"utf8"),G=JSON.parse(J);if(Array.isArray(G.abilities)&&G.abilities.length>0)return new Set(G.abilities)}catch{}return null}function Uz(z){try{let J=E(q(z),"utf8"),G=JSON.parse(J);if(Array.isArray(G.providers))return G.providers.filter((X)=>typeof X==="string")}catch{}return[]}function _z(z){let J=new Set;for(let G of z.split(",").map((X)=>X.trim()).filter(Boolean)){let X=R(G);if(X)J.add(X)}return[...J]}function q(z){return c(z,l)}function Nz(z,J){let G=J??new Set(U.filter((Q)=>Q.defaultSelected||Q.mandatory).map((Q)=>Q.key)),X=z.skipPluginInstall?[]:M(process.platform,G).filter((Q)=>!z.skipPlugins.includes(Q.packageName)&&!z.skipPlugins.includes(Q.pluginName)).map((Q)=>({packageName:Q.packageName,pluginName:Q.pluginName,reason:Q.description}));return{tools:[],plugins:X}}async function Fz(){let z=new Set(U.filter((G)=>G.defaultSelected||G.mandatory).map((G)=>G.key));for(let G of U)if(G.mandatory)z.add(G.key);if(!(Boolean(process.stdin.isTTY)&&process.env.VIBE_AUTO_ACCEPT!=="1"))return z;try{let{interactiveCheckboxes:G}=await import("./interactive-qc1j66mq.js"),X=await G("Select the agent abilities to install",U.map((Q)=>({key:Q.key,label:Q.label,description:Q.description,mandatory:Q.mandatory})),z);if(X){for(let Q of U)if(Q.mandatory)X.add(Q.key);return X}return z}catch(G){process.stdout.write(`
|
|
3
3
|
[vibe] Falling back to plain prompt \u2014 ${G instanceof Error?G.message:String(G)}
|
|
4
4
|
|
|
5
5
|
`);let X=await d("Select the agent abilities to install",U.map((Q)=>({key:Q.key,label:Q.label,description:Q.description,mandatory:Q.mandatory})),z);if(X){for(let Q of U)if(Q.mandatory)X.add(Q.key);return X}return z}}async function d(z,J,G){let X=new Set(G);for(let Y of J)if(Y.mandatory)X.add(Y.key);let Q=()=>{process.stdout.write(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function z(){let j=process.env.VIBECONTROLS_LOG_SHIP_URL;if(!j)return null;return{url:j,apiKey:process.env.VIBECONTROLS_LOG_SHIP_API_KEY,batchSize:Number.parseInt(process.env.VIBECONTROLS_LOG_SHIP_BATCH??"",10)||100,intervalMs:Number.parseInt(process.env.VIBECONTROLS_LOG_SHIP_INTERVAL_MS??"",10)||1e4,sampleRate:Number.parseFloat(process.env.VIBECONTROLS_LOG_SHIP_SAMPLE??"1")}}var k=1000;class s{config=null;queue=[];timer=null;inFlight=!1;dropped=0;init(){if(this.config)return;if(this.config=z(),!this.config)return;if(this.timer=setInterval(()=>{this.flush()},this.config.intervalMs),this.timer&&typeof this.timer.unref==="function")this.timer.unref()}enqueue(j){if(!this.config)return;if(j.level==="debug"&&this.config.sampleRate<1&&Math.random()>this.config.sampleRate)return;if(this.queue.length>=k)this.dropped+=1,this.queue.shift();this.queue.push(j)}async flush(){if(!this.config||this.inFlight||this.queue.length===0)return;this.inFlight=!0;let j=this.queue.splice(0,this.config.batchSize);try{await fetch(this.config.url,{method:"POST",headers:{"Content-Type":"application/json",...this.config.apiKey?{Authorization:`Bearer ${this.config.apiKey}`}:{}},body:JSON.stringify({entries:j,dropped:this.dropped}),signal:AbortSignal.timeout(5000)}),this.dropped=0}catch{this.queue=[...j,...this.queue].slice(0,k)}finally{this.inFlight=!1}}stop(){if(this.timer)clearInterval(this.timer),this.timer=null;this.flush()}}var B=new s;
|
|
3
|
-
export{B as
|
|
3
|
+
export{B as ee};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{h as y,i as c}from"./index-cs78wq6y.js";import{A as p$,B as i$,y as l$}from"./index-ytgmhxsj.js";import{N as j$}from"./index-b5dhmybd.js";import{O as H$,P as K$}from"./index-e1bw1bwr.js";import{va as g}from"./index-nmk7cbj5.js";import"./index-a9ejdv22.js";import{Ca as k$}from"./index-4wgjx8bf.js";import"./index-s2xpdnsj.js";import"./index-0ckffygp.js";import{ab as v}from"./index-rc79x8fw.js";import{db as Y$}from"./index-52cp759f.js";import"./index-hvjqgb97.js";import{Jb as C$,Kb as D$,tb as X$,vb as L$}from"./index-rqq0k5fc.js";import"./index-5dysvvjv.js";import{Ub as F,Vb as p}from"./index-pgew6sge.js";import{Xb as g$}from"./index-rzpaqrhx.js";import"./index-8sdrhr3q.js";import{jc as x,kc as _,lc as c$}from"./index-8nqp3a4d.js";import{Ac as s,Bc as N,Cc as u,oc as V,pc as Z,qc as Y,rc as H,sc as A,uc as z,vc as X,wc as J,xc as Q,yc as h$,zc as k}from"./index-1mppacnx.js";import{Hc as K}from"./index-thammzct.js";import{Lc as T,Nc as b,Oc as M,Pc as y$}from"./index-b6x6a4xp.js";import{qd as T$}from"./index-h74va4wd.js";import{Id as z$,Ld as q$,Od as q}from"./index-js1xn4sq.js";import{$d as $$,Yd as J$,_d as a,ae as U$}from"./index-a4854mwz.js";import"./index-4qq083yd.js";import{ie as d}from"./index-c7554sg7.js";function t(f){let{name:W,onInit:w,onShutdown:U,onNuke:R,telemetryEventName:$,skipPlatforms:G}=f;return{onServerStart:async(I,O)=>{if(G&&G.includes(process.platform)){process.stderr.write(`[${W}] skipping init on unsupported platform '${process.platform}'
|
|
3
|
+
`);return}if(w)await w(O);if($)O.telemetry?.emit($,{plugin:W})},onServerStop:async(I)=>{if(U)await U(I)},onNuke:async(I,O)=>{if(R)return R(I,O)}}}var e=class{constructor(f,W){this.logger=f,this.source=W}logger;source;info(f,W){this.logger?.info?.(this.source,f,W)}warn(f,W){this.logger?.warn?.(this.source,f,W)}error(f,W){this.logger?.error?.(this.source,f,W)}debug(f,W){this.logger?.debug?.(this.source,f,W)}};import{existsSync as t$,rmSync as e$,statSync as a$}from"fs";import{resolve as $U}from"path";function R$(f=$$()){let W=[],w=$U(f),U=U$();if(!a(U,w))throw Error("Refusing to reset a path outside the agents directory");if(t$(w)&&a$(w).isDirectory())e$(w,{recursive:!0,force:!0}),W.push(w);return{removed:W,agentDir:w}}var S="alias",G$=/^[a-zA-Z0-9_-]{1,64}$/,w$=16384,f$=256,W$=1024,UU=new Set(["help","start","stop","restart","kill","list","status","setup","update","completion","autostart","export","import","diagnostics","nuke","doctor","log-level","gc","deploy","network","profile","peer-bootstrap","gateway-auth","info","key","system","url","health","notify","tunnel","session","git","config","log","plugin","ai","audit","alias","run"]);class D extends Error{code;constructor(f,W){super(W);this.code=f,this.name="AliasValidationError"}}class E extends Error{constructor(f){super(`alias '${f}' already exists`);this.name="AliasConflictError"}}class P extends Error{constructor(f){super(`alias '${f}' not found`);this.name="AliasNotFoundError"}}function RU(f){if(typeof f!=="string"||!G$.test(f))throw new D("invalid_name",`alias name must match ${G$} (got '${f}')`);if(UU.has(f))throw new D("reserved_name",`alias name '${f}' is reserved`)}function I$(f){if(typeof f!=="string"||f.length===0)throw new D("invalid_command","alias command must be a non-empty string");if(f.length>w$)throw new D("command_too_long",`alias command exceeds ${w$} bytes`)}function O$(f){if(f===void 0)return;if(typeof f!=="string")throw new D("invalid_description","alias description must be a string");if(f.length>f$)throw new D("description_too_long",`alias description exceeds ${f$} chars`)}function F$(f){if(f===void 0||f===null||f==="")return;if(typeof f!=="string")throw new D("invalid_cwd","alias cwd must be a string");if(f.length>W$)throw new D("cwd_too_long",`alias cwd exceeds ${W$} chars`);if(f.includes("\x00"))throw new D("invalid_cwd","alias cwd must not contain NUL bytes")}function GU(f){if(!f)return;try{return JSON.parse(f)}catch{return}}async function i(f){let W=await f.getAllPluginState(S),w=[];for(let U of W){let R=GU(U.value);if(R)w.push(R)}return w.sort((U,R)=>U.name.localeCompare(R.name)),w}async function n(f,W){return(await i(f)).find((U)=>U.name===W)}function V$(f){if(f===void 0||f===null)return null;let W=f.trim();return W===""?null:W}async function Q$(f,W){if(RU(W.name),I$(W.command),O$(W.description),F$(W.cwd),await n(f,W.name))throw new E(W.name);let U=new Date().toISOString(),R={id:crypto.randomUUID(),name:W.name,command:W.command,description:W.description,cwd:V$(W.cwd),profile:J$(),createdAt:U,updatedAt:U};return await f.setPluginState(S,R.id,JSON.stringify(R)),R}async function Z$(f,W,w){let U=await n(f,W);if(!U)throw new P(W);if(w.command!==void 0)I$(w.command);if(w.description!==void 0)O$(w.description);if(w.cwd!==void 0)F$(w.cwd);let R={...U,command:w.command??U.command,description:w.description!==void 0?w.description:U.description,cwd:w.cwd!==void 0?V$(w.cwd):U.cwd,updatedAt:new Date().toISOString()};return await f.setPluginState(S,R.id,JSON.stringify(R)),R}async function B$(f,W){let w=await n(f,W);if(!w)throw new P(W);await f.deletePluginState(S,w.id)}function m(){let f=q$()??q();return{dir:f.dataDir,scope:f.name}}function M$(f){let{serviceRegistry:W,db:w}=f;return new p().get("/api-key",()=>({apiKey:C$()})).post("/reset-key",async({body:U,set:R})=>{let $=U.apiKey;if(!$||typeof $!=="string")return R.status=400,{error:"Missing required field: apiKey"};try{return await D$($),await q().keyVault.bindApiKey($),q().logger.info("auth","Adopted backend-rotated agent API key via /reset-key"),{success:!0}}catch(G){return R.status=400,{error:"reset-key failed",message:G instanceof Error?G.message:String(G)}}},{body:F.Object({apiKey:F.String()})}).get("/audit",({query:U})=>{let R=U,$=R.limit?Math.min(5000,Math.max(1,Number.parseInt(R.limit,10)||100)):100,G=q().audit.listEvents({since:R.since,limit:$,event:R.event});return{events:G,count:G.length}},{query:F.Object({since:F.Optional(F.String()),limit:F.Optional(F.String()),event:F.Optional(F.String())})}).get("/setup/check",()=>{let U=H$();return{ready:U.filter(($)=>$.required).every(($)=>$.installed),dependencies:U}}).post("/setup/install",async({request:U,server:R,set:$})=>{let G=await c(U,"VIBECONTROLS_ALLOW_REMOTE_SETUP_INSTALL",R);if(G)return $.status=403,{error:"Forbidden",message:G};return await K$()}).get("/url",async()=>{let U=W.getProvider("tunnel"),R=U&&U.getActiveTunnelUrl?await U.getActiveTunnelUrl():null,$=`http://localhost:${process.env.PORT||3005}`;return{url:R||$,tunnelUrl:R,localUrl:$,source:R?"tunnel":"local"}}).get("/lifecycle/state",()=>{return{state:W.getService("agent","lifecycle")?.getState()??"running"}}).post("/lifecycle/stop",async({set:U})=>{let R=W.getService("agent","lifecycle");if(!R)return U.status=500,{error:"Lifecycle manager not initialized"};return await R.stop(),{state:"stopped"}}).post("/lifecycle/start",async({set:U})=>{let R=W.getService("agent","lifecycle");if(!R)return U.status=500,{error:"Lifecycle manager not initialized"};return await R.start(),{state:"running"}}).post("/lifecycle/kill",async({set:U})=>{let R=W.getService("agent","lifecycle");if(!R)return U.status=500,{error:"Lifecycle manager not initialized"};return setTimeout(()=>R.kill(),100),{state:"killing"}}).post("/log-level",async({body:U,request:R,server:$,set:G})=>{let I=await c(R,"VIBECONTROLS_ALLOW_REMOTE_LOG_LEVEL",$);if(I)return G.status=403,{error:"Forbidden",message:I};let O=String(U.level??"").toLowerCase();if(!["debug","info","warn","error"].includes(O))return G.status=400,{error:"Invalid level",message:"level must be debug | info | warn | error"};return q().logger.setLevel(O),q().logger.info("agent",`Log level set to ${O} via API`),{ok:!0,level:O}},{body:F.Object({level:F.String()})}).post("/reset",async({body:U,request:R,server:$,set:G})=>{if(!U.confirm)return G.status=400,{error:"Reset confirmation required",message:"Send { confirm: true } to reset local agent state."};let I=await c(R,"VIBECONTROLS_ALLOW_REMOTE_RESET",$);if(I)return G.status=403,{error:"Forbidden",message:I};let O=W.getService("agent","lifecycle");try{if(O)await O.prepareForReset()}catch(h){q().logger.warn("agent","prepareForReset failed during reset \u2014 proceeding to wipe anyway",{error:String(h)})}try{z$.configure({globalGatewayUrl:"",workspaceGatewayUrl:void 0,clientId:"",clientSecret:"",workspaceId:void 0})}catch{}await w.close();let{removed:B,agentDir:L}=R$();q().logger.info("agent","Reset wiped local agent state",{agentDir:L,removed:B});let C=new Uint8Array(32);crypto.getRandomValues(C);let j=`vcak_${Buffer.from(C).toString("base64url")}`;return T$({"static-api-key":j},m()),q().setBootState("awaiting-config"),G.status=200,{success:!0,state:"awaiting-config",...y(R,$)||process.env.VIBECONTROLS_RETURN_RESET_API_KEY==="1"?{newApiKey:j}:{},agentDir:L,removed:B}},{body:F.Object({confirm:F.Boolean()})}).post("/sessions/:sessionId/share",async({params:U,body:R,server:$,request:G,set:I})=>{if(!y(G,$)&&process.env.VIBECONTROLS_ALLOW_REMOTE_SESSION_SHARE!=="1")return I.status=403,{error:"Forbidden",message:"Session-share mint must come from a local request unless VIBECONTROLS_ALLOW_REMOTE_SESSION_SHARE=1."};if(!X$(U.sessionId))return I.status=400,{error:"BadRequest",message:"invalid sessionId"};let O=wU(R?.expiresIn)??1800000,B=crypto.randomUUID(),L=new Uint8Array(32);crypto.getRandomValues(L);let C=`vcak_${Buffer.from(L).toString("base64url")}`,j=new Date(Date.now()+O).toISOString(),r=[...(await import("./agent-config-4ppenhqp.js")).readAgentConfig({dir:m().dir}).apiKeys??[],{id:B,name:`session-share:${U.sessionId}:${R?.label??"viewer"}`,key:C,scopes:["read"],expiresAt:j,createdAt:new Date().toISOString()}];(await import("./agent-config-4ppenhqp.js")).writeAgentConfig({apiKeys:r},m());let h=W.getProvider("tunnel"),d$=(h&&h.getActiveTunnelUrl?await h.getActiveTunnelUrl():null)??`http://localhost:${process.env.PORT||3005}`,s$=L$({pathPrefixes:[`/terminal/${U.sessionId}`],methods:["GET"]},Math.min(600,Math.floor(O/1000))),r$=`${d$.replace(/\/$/,"")}/terminal/${encodeURIComponent(U.sessionId)}/#vt=${encodeURIComponent(s$.token)}`;return q().logger.info("session-share","Minted share credential",{sessionId:U.sessionId,keyId:B,expiresAt:j}),{ok:!0,keyId:B,apiKey:C,joinUrl:r$,sessionId:U.sessionId,expiresAt:j}},{params:F.Object({sessionId:F.String()}),body:F.Optional(F.Object({permissions:F.Optional(F.Array(F.String())),expiresIn:F.Optional(F.String()),label:F.Optional(F.String())}))}).get("/aliases",async()=>{return{aliases:await i(w)}}).get("/aliases/:name",async({params:U,set:R})=>{let $=await n(w,U.name);if(!$)return R.status=404,{error:"Alias not found"};return $},{params:F.Object({name:F.String()})}).post("/aliases",async({body:U,set:R})=>{try{let $=await Q$(w,U);return R.status=201,$}catch($){if($ instanceof E)return R.status=409,{error:"Alias already exists",message:$.message};if($ instanceof D)return R.status=400,{error:$.code,message:$.message};throw $}},{body:F.Object({name:F.String(),command:F.String(),description:F.Optional(F.String()),cwd:F.Optional(F.Union([F.String(),F.Null()]))})}).put("/aliases/:name",async({params:U,body:R,set:$})=>{try{return await Z$(w,U.name,R)}catch(G){if(G instanceof P)return $.status=404,{error:"Alias not found"};if(G instanceof D)return $.status=400,{error:G.code,message:G.message};throw G}},{params:F.Object({name:F.String()}),body:F.Object({command:F.Optional(F.String()),description:F.Optional(F.String()),cwd:F.Optional(F.Union([F.String(),F.Null()]))})}).delete("/aliases/:name",async({params:U,set:R})=>{try{return await B$(w,U.name),R.status=204,null}catch($){if($ instanceof P)return R.status=404,{error:"Alias not found"};throw $}},{params:F.Object({name:F.String()})}).post("/aliases/:name/execute",async({params:U,body:R,set:$})=>{let G=await n(w,U.name);if(!G)return $.status=404,{error:"Alias not found"};let I=R?.args??[],O=await j$(G,I);q().audit.emit("agent","alias.executed",{exit_code:O.exit_code});let B=Y$("alias.executed",{exit_code:O.exit_code});if(!B.ok)q().logger.debug("alias",`telemetry validate failed: ${B.reason}`);if(O.timed_out)$.status=408;return{exit_code:O.exit_code,stdout:O.stdout,stderr:O.stderr,duration_ms:O.duration_ms,truncated:O.truncated,cwd:O.cwd}},{params:F.Object({name:F.String()}),body:F.Optional(F.Object({args:F.Optional(F.Array(F.String()))}))}).post("/sessions/share/:keyId/revoke",async({params:U,server:R,request:$,set:G})=>{if(!y($,R)&&process.env.VIBECONTROLS_ALLOW_REMOTE_SESSION_SHARE!=="1")return G.status=403,{error:"Forbidden"};let I=await import("./agent-config-4ppenhqp.js"),O=m(),B=I.readAgentConfig({dir:O.dir}),L=(B.apiKeys??[]).length,C=(B.apiKeys??[]).filter((j)=>j.id!==U.keyId);if(C.length===L)return G.status=404,{error:"No such share key"};return I.writeAgentConfig({apiKeys:C},O),{ok:!0,revoked:U.keyId}},{params:F.Object({keyId:F.String()})})}function wU(f){if(!f)return null;let W=/^(\d+)([smhdw]?)$/.exec(f.trim());if(!W)return null;let w=Number(W[1]),U=W[2]||"m";return U==="s"?w*1000:U==="m"?w*60000:U==="h"?w*3600000:U==="d"?w*86400000:w*7*86400000}var fU="http://localhost:3005";function x$(f){f.command("health").description("Check health of a VibeControls agent instance").option("-n, --name <name>","Agent instance name").option("--agent-url <url>","Agent URL",fU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let w={...f.opts(),...W};await _({mode:x(w),fetchData:async()=>{if(w.name){let $=await new g().checkHealth(w.name);return{mode:"named",agentUrl:T(w),name:w.name,healthy:$.healthy,details:$.details??{}}}let U=T(w);try{let R=await M(U,"/health");return{mode:"url",agentUrl:U,healthy:!0,details:R}}catch(R){return{mode:"url",agentUrl:U,healthy:!1,details:{status:"unhealthy",...R instanceof Error?{error:H(R)}:{}}}}},plain:(U)=>{if(X("Agent Health"),Q(),U.mode==="named"){if(!U.healthy){Y(`Agent instance ${V.bold(U.name??"")} is not responding.`);return}let R=U.details;if(J("Instance",U.name??""),J("Status",u(R.status??"healthy")),R.uptime!==void 0)J("Uptime",`${R.uptime}s`);if(R.checks){Q(),z(`${Z.info} Health checks:`);for(let[$,G]of Object.entries(R.checks)){let I=G.status==="healthy"?Z.success:Z.error;J(` ${I} ${$}`,u(G.status))}}}else{if(J("URL",U.agentUrl),J("Status",u(U.details.status??"unhealthy")),U.details.version)J("Version",U.details.version);if(U.details.uptime!==void 0)J("Uptime",`${U.details.uptime}s`);if(U.details.timestamp)J("Timestamp",U.details.timestamp);if(U.details.checks){Q(),z(`${Z.info} Health checks:`);for(let[R,$]of Object.entries(U.details.checks)){let G=$.status==="healthy"?Z.success:Z.error;J(` ${G} ${R}`,u($.status))}}}if(Q(),U.healthy)A(`${Z.success} Agent is healthy.`)},interactive:async(U)=>{let R=[];if(U.mode==="named")R.push(`Instance: ${U.name??""}`);else R.push(`URL: ${U.agentUrl}`);if(R.push(`Status: ${u(U.details.status??(U.healthy?"healthy":"unhealthy"))}`),U.details.version)R.push(`Version: ${U.details.version}`);if(U.details.uptime!==void 0)R.push(`Uptime: ${U.details.uptime}s`);if(U.details.timestamp)R.push(`Time: ${U.details.timestamp}`);if(U.details.checks){R.push(""),R.push("Checks:");for(let[$,G]of Object.entries(U.details.checks))R.push(` ${$}: ${G.status}`)}await K({title:"Agent Health",body:R.join(`
|
|
4
|
+
`),footer:"press q to exit"})},json:(U)=>({mode:U.mode,agentUrl:U.agentUrl,name:U.name??null,healthy:U.healthy,details:U.details})})}catch(w){Y(`Health check failed: ${H(w)}`)}})}import{platform as WU,arch as JU,release as IU,hostname as OU,cpus as FU,totalmem as VU}from"os";var QU="http://localhost:3005";function _$(f){f.command("info").description("Show local and remote VibeControls agent information").option("--agent-url <url>","Agent URL",QU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let w={...f.opts(),...W},U=T(w),R=encodeURIComponent(b(w));await _({mode:x(w),fetchData:async()=>{let $={hostname:OU(),platform:WU(),arch:JU(),release:IU(),cpus:FU().length,totalMemory:VU(),nodeVersion:process.version,bunVersion:process.versions.bun};try{let G=await M(U,`/api/profiles/${R}/agent/version`);return{local:$,agentUrl:U,remote:G}}catch(G){return{local:$,agentUrl:U,remote:null,remoteError:G instanceof Error?H(G):String(G)}}},plain:($)=>{if(X("VibeControls Agent Info"),Q(),z(`${Z.info} Local System`),J("Hostname",$.local.hostname),J("Platform",`${$.local.platform} ${$.local.arch}`),J("OS Release",$.local.release),J("CPUs",String($.local.cpus)),J("Total Memory",N($.local.totalMemory)),J("Node.js",$.local.nodeVersion),$.local.bunVersion)J("Bun",$.local.bunVersion);if(Q(),z(`${Z.info} Remote Agent`),J("URL",$.agentUrl),$.remote){if(J("Version",V.bold($.remote.version)),$.remote.build)J("Build",$.remote.build);if($.remote.commit)J("Commit",$.remote.commit);if($.remote.nodeVersion)J("Node.js (remote)",$.remote.nodeVersion);if($.remote.bunVersion)J("Bun (remote)",$.remote.bunVersion)}else J("Status",V.dim("not reachable"));Q()},interactive:async($)=>{let G=[];if(G.push("Local System"),G.push(` Hostname: ${$.local.hostname}`),G.push(` Platform: ${$.local.platform} ${$.local.arch}`),G.push(` OS Release: ${$.local.release}`),G.push(` CPUs: ${$.local.cpus}`),G.push(` Total Memory: ${N($.local.totalMemory)}`),G.push(` Node.js: ${$.local.nodeVersion}`),$.local.bunVersion)G.push(` Bun: ${$.local.bunVersion}`);if(G.push(""),G.push("Remote Agent"),G.push(` URL: ${$.agentUrl}`),$.remote){if(G.push(` Version: ${$.remote.version}`),$.remote.build)G.push(` Build: ${$.remote.build}`);if($.remote.commit)G.push(` Commit: ${$.remote.commit}`);if($.remote.nodeVersion)G.push(` Node.js: ${$.remote.nodeVersion} (remote)`);if($.remote.bunVersion)G.push(` Bun: ${$.remote.bunVersion} (remote)`)}else G.push(" Status: not reachable");await K({title:"VibeControls Agent Info",body:G.join(`
|
|
5
|
+
`),footer:"press q to exit"})},json:($)=>({local:$.local,agentUrl:$.agentUrl,remote:$.remote,remoteError:$.remoteError??null})})}catch(w){Y(`Failed to get info: ${H(w)}`)}})}var ZU="http://localhost:3005";function b$(f){f.command("system").description("Show system information for a running VibeControls agent").option("--agent-url <url>","Agent URL",ZU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let w={...f.opts(),...W},U=T(w),R=encodeURIComponent(b(w));await _({mode:x(w),fetchData:()=>M(U,`/api/profiles/${R}/agent/system`),plain:($)=>{if(X("Agent System Information"),Q(),z(`${Z.info} Agent`),J("Version",V.bold($.agentVersion)),$.bunVersion)J("Bun",$.bunVersion);if($.environment)J("Environment",$.environment);J("Uptime",s($.uptime)),Q(),z(`${Z.info} Platform`),J("OS",`${$.platform} ${$.arch}`),J("Hostname",$.hostname),J("Release",$.release),Q(),z(`${Z.info} Resources`),J("CPUs",String($.cpus)),J("Total Memory",N($.totalMemory)),J("Free Memory",N($.freeMemory)),Q(),z(`${Z.info} Paths`),J("Home",$.homeDir),J("CWD",$.cwd),Q()},interactive:async($)=>{let G=["Agent",` Version: ${$.agentVersion}`,...$.bunVersion?[` Bun: ${$.bunVersion}`]:[],...$.environment?[` Environment: ${$.environment}`]:[],` Uptime: ${s($.uptime)}`,"","Platform",` OS: ${$.platform} ${$.arch}`,` Hostname: ${$.hostname}`,` Release: ${$.release}`,"","Resources",` CPUs: ${$.cpus}`,` Total Mem: ${N($.totalMemory)}`,` Free Mem: ${N($.freeMemory)}`,"","Paths",` Home: ${$.homeDir}`,` CWD: ${$.cwd}`];await K({title:"Agent System Information",body:G.join(`
|
|
6
|
+
`),footer:"press q to exit"})}})}catch(w){Y(`Failed to get system info: ${H(w)}`)}})}var BU="http://localhost:3005";async function u$(f){try{let W=await fetch(`${f}/health/ready`);if(W.status===200||W.status===503)return await W.json();return{healthy:!1,status:W.status}}catch{return{healthy:!1,error:"unreachable"}}}async function N$(f,W){try{let w=await fetch(`${f}/api/profiles/${W}/agent/api-key`);if(!w.ok)return null;return(await w.json()).apiKey??null}catch{return null}}async function zU(f,W){try{return await M(f,`/api/profiles/${W}/plugins`)}catch{return null}}function o(f){let W=f??{};if(W.error==="unreachable")return V.red("unreachable");if(typeof W.status==="number"&&W.status>=400)return V.red(`http ${W.status}`);let w=typeof W.status==="string"?W.status:"",U=typeof W.bootState==="string"?W.bootState:"";if(w==="ok"&&U==="ready")return V.green("ready");if(U==="awaiting-config")return V.yellow("awaiting-config");if(U==="initializing")return V.yellow("initializing");if(U==="degraded"||w==="degraded")return V.red(`degraded${U?` (${U})`:""}`);if(W.healthy===!1)return V.red("unhealthy");return V.green("healthy")}function YU(f){let w=(f??{}).lastFinalizeError;if(!w||typeof w!=="object")return null;let U=w;if(typeof U.message!=="string"||typeof U.at!=="string")return null;return{message:U.message,at:U.at,attempt:typeof U.attempt==="number"?U.attempt:void 0}}function P$(f){let W=f??{},w=typeof W.bootState==="string"?W.bootState:"";if(w!=="awaiting-config"&&w!=="degraded")return null;let U=[],R=YU(f);if(R)if(U.push(`${V.gray("\xB7")} Last error: ${V.red(R.message)}`),R.attempt!==void 0)U.push(`${V.gray("\xB7")} Background retry: attempt ${R.attempt}`);else U.push(`${V.gray("\xB7")} Last seen: ${R.at}`);if(w==="awaiting-config")U.push(`${V.gray("\xB7")} Force retry now: ${V.bold("vibe retry-config")}`);return U.push(`${V.gray("\xB7")} Full trace: ${V.bold("vibe logs --since 10m")}`),U.join(`
|
|
7
|
+
`)}async function TU(f,W){let w={agentUrl:W},U=f.jsonKey??f.title.toLowerCase(),R;try{R=await f.render(w)}catch(G){R=V.red(`error (${G.message})`)}let $=null;if(f.json)try{$=await f.json(w)}catch{$=null}return{title:f.title,jsonKey:U,text:R,json:$}}async function n$(f){let w=k$().getStatusSections();return Promise.all(w.map((U)=>TU(U,f)))}function S$(f){f.command("status").description("Show comprehensive status of VibeControls agent instance(s)").option("-n, --name <name>","Agent instance name").option("--agent-url <url>","Agent URL",BU).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(W){try{let w={...f.opts(),...W},U=new g;await _({mode:x(w),fetchData:async()=>{if(w.name){let I=await U.getStatus(w.name);if(!I)return{kind:"instance",agentUrl:T(w),instance:null,contributed:[]};let O=I.status==="running"&&I.port?`http://localhost:${I.port}`:T(w);if(I.status!=="running")return{kind:"instance",agentUrl:O,instance:I,contributed:[]};let B=encodeURIComponent(b({profile:I.name})),[L,C,j,l]=await Promise.all([u$(O),N$(O,B),zU(O,B),n$(O)]);return{kind:"instance",agentUrl:O,instance:I,health:L,apiKey:C,plugins:j,contributed:l}}let R=await U.listInstances(),$=R.filter((I)=>I.status==="running"),G=await Promise.all($.map(async(I)=>{let O=`http://localhost:${I.port}`,B=encodeURIComponent(b({profile:I.name})),[L,C,j]=await Promise.all([u$(O),N$(O,B),n$(O)]);return{name:I.name,agentUrl:O,health:L,apiKey:C,contributed:j}}));return{kind:"overview",instances:R,perRunning:G}},plain:(R)=>{if(R.kind==="instance"){if(!R.instance){Y(`Agent instance ${V.bold(w.name??"")} not found.`);return}let G=R.instance;if(X(`Agent Status: ${G.name}`),J("Name",G.name),J("Status",u(G.status)),J("PID",G.pid?String(G.pid):V.dim("n/a")),J("Port",G.port?String(G.port):V.dim("n/a")),J("Host",G.config?.host||V.dim("n/a")),J("Database",G.config?.dbPath||V.dim("n/a")),G.startTime)J("Started",k(G.startTime));if(G.status==="running"){Q(),J("Health",o(R.health));let I=P$(R.health);if(I)Q(),console.log(I),Q();let O=R.health?.uptime;if(O)J("Uptime",String(O));if(J("API Key",R.apiKey??V.dim("(unavailable)")),R.plugins){let B=R.plugins.plugins??[],L=B.filter((C)=>C.isCore).length;J("Plugins",`${B.length} total (${L} core, ${B.length-L} external)`)}else J("Plugins",V.dim("(unable to fetch)"));for(let B of R.contributed){if(B.text===null)continue;J(B.title,B.text)}}Q();return}if(X("Agent Instances"),Q(),!R.instances||R.instances.length===0){z(`${Z.info} No agent instances found.`),z(`Run ${V.bold("vibe start")} to start an agent.`);return}let $=R.instances.map((G)=>({Name:G.name,Status:u(G.status),PID:G.pid||"-",Port:G.port||"-",Started:G.startTime?k(G.startTime):"-"}));h$($),Q();for(let G of R.perRunning){Q(),X(`Quick Status: ${G.name}`),J("Health",o(G.health));let I=P$(G.health);if(I)Q(),console.log(I),Q();J("API Key",G.apiKey??V.dim("(unavailable)"));for(let O of G.contributed){if(O.text===null)continue;J(O.title,O.text)}}Q(),z(`${Z.info} ${R.instances.length} instance(s) found. Use ${V.bold("vibe status -n <name>")} for full details.`)},interactive:async(R)=>{let $=[];if(R.kind==="instance"){if(!R.instance)$.push(`Agent instance "${w.name??""}" not found.`);else{let G=R.instance;if($.push(`Name: ${G.name}`),$.push(`Status: ${u(G.status)}`),$.push(`PID: ${G.pid??"n/a"}`),$.push(`Port: ${G.port??"n/a"}`),$.push(`Host: ${G.config?.host??"n/a"}`),$.push(`Database: ${G.config?.dbPath??"n/a"}`),G.startTime)$.push(`Started: ${k(G.startTime)}`);if(G.status==="running"){if($.push(""),$.push(`Health: ${o(R.health)}`),$.push(`API Key: ${R.apiKey??"(unavailable)"}`),R.plugins){let I=R.plugins.plugins??[],O=I.filter((B)=>B.isCore).length;$.push(`Plugins: ${I.length} (${O} core, ${I.length-O} external)`)}for(let I of R.contributed){if(I.text===null)continue;$.push(`${I.title.padEnd(9)} ${I.text}`)}}}await K({title:`vibe status${w.name?` \u2014 ${w.name}`:""}`,body:$.join(`
|
|
8
|
+
`),footer:"press q to exit"});return}if(!R.instances||R.instances.length===0)$.push("No agent instances found."),$.push("Run `vibe start` to start an agent.");else for(let G of R.instances){$.push(`${V.bold(G.name)} ${u(G.status)}`),$.push(` PID: ${G.pid??"-"}`),$.push(` Port: ${G.port??"-"}`),$.push(` Started: ${G.startTime?k(G.startTime):"-"}`);let I=R.perRunning.find((O)=>O.name===G.name);if(I){$.push(` Health: ${o(I.health)}`);for(let O of I.contributed){if(O.text===null)continue;$.push(` ${O.title.padEnd(9)} ${O.text}`)}}$.push("")}await K({title:`vibe status \u2014 ${R.instances.length} instance(s)`,body:$.join(`
|
|
9
|
+
`),footer:"press q to exit"})},json:(R)=>{let $=(G)=>Object.fromEntries(G.map((I)=>[I.jsonKey,I.json]));if(R.kind==="instance"){if(!R.instance)return{instance:null};let G={instance:{name:R.instance.name,status:R.instance.status,pid:R.instance.pid,port:R.instance.port,host:R.instance.config?.host,dbPath:R.instance.config?.dbPath,startTime:R.instance.startTime}};if(R.instance.status==="running")G.health=R.health??null,G.plugins=R.plugins??null,Object.assign(G,$(R.contributed));return G}return{instances:R.instances.map((G)=>({name:G.name,status:G.status,pid:G.pid,port:G.port,startTime:G.startTime})),perRunning:R.perRunning.map((G)=>({name:G.name,health:G.health??null,...$(G.contributed)}))}}})}catch(w){let U=w instanceof Error?H(w):String(w);Y(`Failed to get status: ${U}`)}})}var XU="http://localhost:3005";function E$(f){f.command("url").description("Show the active URL for a running VibeControls agent").option("--agent-url <url>","Agent URL",XU).option("--json","Emit JSON").option("--plain","Force plain text output").action(async(W)=>{try{let w={...f.opts(),...W},U=T(W),R=encodeURIComponent(b(w));await _({mode:x(w),fetchData:()=>M(U,`/api/profiles/${R}/agent/url`),plain:($)=>{if(X("Agent URL"),Q(),J("Active URL",V.bold($.url)),J("Local URL",$.localUrl),$.tunnelUrl)J("Tunnel URL",V.cyan($.tunnelUrl));if(J("Mode",$.isTunnel?`${Z.running} Tunnel active`:`${Z.info} Local only`),Q(),$.isTunnel)z(`${Z.info} Agent is accessible via tunnel at ${V.bold($.tunnelUrl)}`);else z(`${Z.info} Agent is running locally at ${V.bold($.localUrl)}`)},interactive:async($)=>{let G=[` Active URL: ${$.url}`,` Local URL: ${$.localUrl}`,` Tunnel URL: ${$.tunnelUrl??"-"}`,` Mode: ${$.isTunnel?"Tunnel active":"Local only"}`];await K({title:"Agent URL",body:G.join(`
|
|
10
|
+
`)})},json:($)=>v($)})}catch(w){Y(`Failed to get URL: ${w.message}`)}})}var m$="http://localhost:3005";function A$(f){let W=f.command("gateway-auth").description("Manage gateway authentication for VibeControls agent");W.command("configure").description("Configure gateway authentication credentials").requiredOption("--global-url <url>","Global gateway URL").requiredOption("--workspace-url <url>","Workspace gateway URL").requiredOption("--client-id <id>","OAuth client ID").requiredOption("--client-secret <secret>","OAuth client secret").option("--workspace-id <id>","Workspace ID for auto-report").option("--agent-record-id <id>","Existing backend agent record ID").option("--agent-url <url>","Agent URL",m$).option("--json","Emit JSON result").action(async(w)=>{try{let U={...f.opts(),...w},R=T(w),$=encodeURIComponent(b(U)),G=await y$(R,`/api/profiles/${$}/agent/gateway-auth`,{globalGatewayUrl:w.globalUrl,workspaceGatewayUrl:w.workspaceUrl,clientId:w.clientId,clientSecret:w.clientSecret,workspaceId:w.workspaceId,agentRecordId:w.agentRecordId});if(c$(U,{ok:!!G.success,message:G.message??null,globalGatewayUrl:w.globalUrl,workspaceGatewayUrl:w.workspaceUrl,clientId:w.clientId,workspaceId:w.workspaceId??null,agentRecordId:w.agentRecordId??null}))return;if(X("Configure Gateway Authentication"),Q(),z(`${Z.info} Sending gateway auth configuration...`),Q(),G.success){if(A(`${Z.success} Gateway authentication configured successfully.`),Q(),J("Global URL",w.globalUrl),J("Workspace URL",w.workspaceUrl),J("Client ID",w.clientId),J("Client Secret",V.dim("********")),w.workspaceId)J("Workspace ID",w.workspaceId);if(w.agentRecordId)J("Agent Record ID",w.agentRecordId)}else Y(G.message||"Failed to configure gateway authentication.");Q()}catch(U){Y(`Failed to configure gateway auth: ${U instanceof Error?H(U):String(U)}`)}}),W.command("status").description("Check gateway authentication status").option("--agent-url <url>","Agent URL",m$).option("--json","Emit JSON").option("--plain","Force plain text output").action(async(w)=>{try{let U={...f.opts(),...w},R=T(w),$=encodeURIComponent(b(U));await _({mode:x(U),fetchData:()=>M(R,`/api/profiles/${$}/agent/gateway-auth`),plain:(G)=>{if(X("Gateway Authentication Status"),Q(),J("Configured",G.configured?`${Z.success} ${V.green("Yes")}`:`${Z.error} ${V.red("No")}`),G.configured){if(J("Global URL",G.config?.globalGatewayUrl||V.dim("n/a")),J("Workspace URL",G.config?.workspaceGatewayUrl||V.dim("n/a")),J("Client ID",G.config?.clientId||V.dim("n/a")),G.config?.workspaceId)J("Workspace ID",G.config.workspaceId)}else Q(),z(`${Z.info} Run ${V.bold("vibe gateway-auth configure")} to set up gateway authentication.`);Q()},interactive:async(G)=>{let I=G.configured?[" Configured: yes",` Global URL: ${G.config?.globalGatewayUrl??"n/a"}`,` Workspace URL: ${G.config?.workspaceGatewayUrl??"n/a"}`,` Client ID: ${G.config?.clientId??"n/a"}`,` Workspace ID: ${G.config?.workspaceId??"-"}`]:[" Configured: no",""," Run `vibe gateway-auth configure` to set up."];await K({title:"Gateway Authentication Status",body:I.join(`
|
|
11
|
+
`)})},json:(G)=>v(G)})}catch(U){Y(`Failed to get gateway auth status: ${U instanceof Error?H(U):String(U)}`)}})}function o$(f,W){x$(f),_$(f),g$(f),b$(f),S$(f),E$(f),A$(f)}var v$="agent";function CR(f){let W=null,w=t({name:v$,onShutdown:()=>{p$(),l$()}});return{name:v$,version:"2.3.0",description:"Core agent identity, system info, setup, gateway authentication, and auto-report",capabilities:{storage:"rw",secrets:"rw",gateway:!0,broadcast:!0,audit:!0,telemetry:!0},tags:["backend","cli"],cliCommand:"agent",apiPrefix:"/api/agent",publicPaths:["/identity","/tunnel"],createRoutes:(U)=>{return W=U.db,M$(U)},onCliSetup:async(U,R)=>{o$(U,R)},onServerReady:async(U,R)=>{if(W){let $=U,G=(typeof $.decorator?.apiKey==="string"?$.decorator.apiKey:void 0)??(typeof $.store?.apiKey==="string"?$.store.apiKey:void 0)??"unknown",I=new e(R.logger,"agent-plugin");i$(W,R.serviceRegistry,G).catch((O)=>{I.warn(`Auto-report background task failed: ${O}`)})}},onServerStop:()=>w.onServerStop({})}}export{CR as createPlugin};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{randomBytes as G,timingSafeEqual as J}from"crypto";var M="x-vc-internal-auth",z=G(32).toString("hex");function U(){return z}function V(F){let j=F.get(M);if(!j)return!1;let w=Buffer.from(j),x=Buffer.from(z);return w.length===x.length&&J(w,x)}
|
|
3
|
-
export{M as
|
|
3
|
+
export{M as Rb,U as Sb,V as Tb};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Xa as N}from"./index-0ckffygp.js";import{
|
|
2
|
+
import{Xa as N}from"./index-0ckffygp.js";import{Od as Q}from"./index-js1xn4sq.js";var V=5000,H=new Map,X=1;function Y(b){return`${b}#${X++}`}function u(b){let z=Bun.spawn(b.cmd,{env:b.env,cwd:b.cwd,stdout:b.stdout??"pipe",stderr:b.stderr??"pipe",stdin:b.stdin??"pipe",...N().processGroupSpawnOpts()}),B={id:Y(b.owner),owner:b.owner,pid:z.pid??null,startedAt:new Date().toISOString(),proc:z,meta:b.meta};return H.set(B.id,B),z.exited.finally(()=>{H.delete(B.id)}),B}function v(){return[...H.values()]}function C(b){return[...H.values()].filter((z)=>z.owner===b)}async function Z(b,z){let B=N(),J=Date.now()+z;while(Date.now()<J){if(!B.isProcessAlive(b))return!0;await new Promise((U)=>setTimeout(U,100))}return!B.isProcessAlive(b)}async function T(b,z="SIGTERM"){let B=b.pid;if(B==null)return;let J=N();if(J.killProcessTree(B,z),await Z(B,V))return;J.killProcessTree(B,"SIGKILL")}async function D(b){let z=H.get(b);if(!z)return!1;return await T(z),H.delete(b),!0}async function F(){let b=[...H.values()];if(b.length===0)return{reaped:0};return Q().logger.info("subprocess",`Reaping ${b.length} tracked child process(es)`,{owners:[...new Set(b.map((z)=>z.owner))]}),await Promise.all(b.map((z)=>T(z))),H.clear(),{reaped:b.length}}
|
|
3
3
|
export{u as o,v as p,C as q,D as r,F as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function O(){return!!process.stdout.isTTY&&!!process.stdin.isTTY}async function E(x,A=!1){if(!O())return A;let D=A?"[Y/n]":"[y/N]";return process.stdout.write(` ${x} ${D} `),new Promise((B)=>{let b=process.stdin;b.setRawMode?.(!0),b.resume(),b.setEncoding("utf8");let K=(N)=>{b.removeListener("data",K),b.setRawMode?.(!1),b.pause();let U=N.trim().toLowerCase();if(console.log(U||(A?"y":"n")),U==="")B(A);else B(U==="y")};b.on("data",K)})}function L(x){if(x.json)return"json";if(x.plain)return"plain";if(x.interactive)return"interactive";return"auto"}function P(){return!!process.env.CI||!!process.env.NO_COLOR||process.env.TERM==="dumb"}async function M(x){let A=await x.fetchData(),D=x.mode??"auto";if(D==="json"){let b=x.json?x.json(A):A;process.stdout.write(`${JSON.stringify(b,null,2)}
|
|
3
3
|
`);return}if(D==="plain"){await x.plain(A);return}if((D==="interactive"||O()&&!P())&&!!x.interactive&&x.interactive)try{await x.interactive(A);return}catch{}await x.plain(A)}function S(x,A){if(!x.json)return!1;return process.stdout.write(`${JSON.stringify(A,null,2)}
|
|
4
|
-
`),!0}async function y(x,A,D=!1){if(x.yes===!0||x.json===!0||!O())return!0;return E(A,D)}export{O as
|
|
4
|
+
`),!0}async function y(x,A,D=!1){if(x.yes===!0||x.json===!0||!O())return!0;return E(A,D)}export{O as hc,E as ic,L as jc,M as kc,S as lc,y as mc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{fe as bq,ge as M,ie as S}from"./index-c7554sg7.js";var K=M((s)=>{class P extends Error{constructor(q,z,J){super(J);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=z,this.exitCode=q,this.nestedError=void 0}}class A extends P{constructor(q){super(1,"commander.invalidArgument",q);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}s.CommanderError=P;s.InvalidArgumentError=A});var W=M((a)=>{var{InvalidArgumentError:t}=K();class w{constructor(q,z){switch(this.description=z||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,q[0]){case"<":this.required=!0,this._name=q.slice(1,-1);break;case"[":this.required=!1,this._name=q.slice(1,-1);break;default:this.required=!0,this._name=q;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(q,z){if(z===this.defaultValue||!Array.isArray(z))return[q];return z.push(q),z}default(q,z){return this.defaultValue=q,this.defaultValueDescription=z,this}argParser(q){return this.parseArg=q,this}choices(q){return this.argChoices=q.slice(),this.parseArg=(z,J)=>{if(!this.argChoices.includes(z))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(z,J);return z},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function n(q){let z=q.name()+(q.variadic===!0?"...":"");return q.required?"<"+z+">":"["+z+"]"}a.Argument=w;a.humanReadableArgName=n});var I=M((zq)=>{var{humanReadableArgName:qq}=W();class k{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(q){this.helpWidth=this.helpWidth??q.helpWidth??80}visibleCommands(q){let z=q.commands.filter((Q)=>!Q._hidden),J=q._getHelpCommand();if(J&&!J._hidden)z.push(J);if(this.sortSubcommands)z.sort((Q,X)=>{return Q.name().localeCompare(X.name())});return z}compareOptions(q,z){let J=(Q)=>{return Q.short?Q.short.replace(/^-/,""):Q.long.replace(/^--/,"")};return J(q).localeCompare(J(z))}visibleOptions(q){let z=q.options.filter((Q)=>!Q.hidden),J=q._getHelpOption();if(J&&!J.hidden){let Q=J.short&&q._findOption(J.short),X=J.long&&q._findOption(J.long);if(!Q&&!X)z.push(J);else if(J.long&&!X)z.push(q.createOption(J.long,J.description));else if(J.short&&!Q)z.push(q.createOption(J.short,J.description))}if(this.sortOptions)z.sort(this.compareOptions);return z}visibleGlobalOptions(q){if(!this.showGlobalOptions)return[];let z=[];for(let J=q.parent;J;J=J.parent){let Q=J.options.filter((X)=>!X.hidden);z.push(...Q)}if(this.sortOptions)z.sort(this.compareOptions);return z}visibleArguments(q){if(q._argsDescription)q.registeredArguments.forEach((z)=>{z.description=z.description||q._argsDescription[z.name()]||""});if(q.registeredArguments.find((z)=>z.description))return q.registeredArguments;return[]}subcommandTerm(q){let z=q.registeredArguments.map((J)=>qq(J)).join(" ");return q._name+(q._aliases[0]?"|"+q._aliases[0]:"")+(q.options.length?" [options]":"")+(z?" "+z:"")}optionTerm(q){return q.flags}argumentTerm(q){return q.name()}longestSubcommandTermLength(q,z){return z.visibleCommands(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleSubcommandTerm(z.subcommandTerm(Q))))},0)}longestOptionTermLength(q,z){return z.visibleOptions(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleOptionTerm(z.optionTerm(Q))))},0)}longestGlobalOptionTermLength(q,z){return z.visibleGlobalOptions(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleOptionTerm(z.optionTerm(Q))))},0)}longestArgumentTermLength(q,z){return z.visibleArguments(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleArgumentTerm(z.argumentTerm(Q))))},0)}commandUsage(q){let z=q._name;if(q._aliases[0])z=z+"|"+q._aliases[0];let J="";for(let Q=q.parent;Q;Q=Q.parent)J=Q.name()+" "+J;return J+z+" "+q.usage()}commandDescription(q){return q.description()}subcommandDescription(q){return q.summary()||q.description()}optionDescription(q){let z=[];if(q.argChoices)z.push(`choices: ${q.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(q.defaultValue!==void 0){if(q.required||q.optional||q.isBoolean()&&typeof q.defaultValue==="boolean")z.push(`default: ${q.defaultValueDescription||JSON.stringify(q.defaultValue)}`)}if(q.presetArg!==void 0&&q.optional)z.push(`preset: ${JSON.stringify(q.presetArg)}`);if(q.envVar!==void 0)z.push(`env: ${q.envVar}`);if(z.length>0){let J=`(${z.join(", ")})`;if(q.description)return`${q.description} ${J}`;return J}return q.description}argumentDescription(q){let z=[];if(q.argChoices)z.push(`choices: ${q.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(q.defaultValue!==void 0)z.push(`default: ${q.defaultValueDescription||JSON.stringify(q.defaultValue)}`);if(z.length>0){let J=`(${z.join(", ")})`;if(q.description)return`${q.description} ${J}`;return J}return q.description}formatItemList(q,z,J){if(z.length===0)return[];return[J.styleTitle(q),...z,""]}groupItems(q,z,J){let Q=new Map;return q.forEach((X)=>{let Y=J(X);if(!Q.has(Y))Q.set(Y,[])}),z.forEach((X)=>{let Y=J(X);if(!Q.has(Y))Q.set(Y,[]);Q.get(Y).push(X)}),Q}formatHelp(q,z){let J=z.padWidth(q,z),Q=z.helpWidth??80;function X(R,B){return z.formatItem(R,J,B,z)}let Y=[`${z.styleTitle("Usage:")} ${z.styleUsage(z.commandUsage(q))}`,""],Z=z.commandDescription(q);if(Z.length>0)Y=Y.concat([z.boxWrap(z.styleCommandDescription(Z),Q),""]);let _=z.visibleArguments(q).map((R)=>{return X(z.styleArgumentTerm(z.argumentTerm(R)),z.styleArgumentDescription(z.argumentDescription(R)))});if(Y=Y.concat(this.formatItemList("Arguments:",_,z)),this.groupItems(q.options,z.visibleOptions(q),(R)=>R.helpGroupHeading??"Options:").forEach((R,B)=>{let H=R.map((L)=>{return X(z.styleOptionTerm(z.optionTerm(L)),z.styleOptionDescription(z.optionDescription(L)))});Y=Y.concat(this.formatItemList(B,H,z))}),z.showGlobalOptions){let R=z.visibleGlobalOptions(q).map((B)=>{return X(z.styleOptionTerm(z.optionTerm(B)),z.styleOptionDescription(z.optionDescription(B)))});Y=Y.concat(this.formatItemList("Global Options:",R,z))}return this.groupItems(q.commands,z.visibleCommands(q),(R)=>R.helpGroup()||"Commands:").forEach((R,B)=>{let H=R.map((L)=>{return X(z.styleSubcommandTerm(z.subcommandTerm(L)),z.styleSubcommandDescription(z.subcommandDescription(L)))});Y=Y.concat(this.formatItemList(B,H,z))}),Y.join(`
|
|
3
3
|
`)}displayWidth(q){return C(q).length}styleTitle(q){return q}styleUsage(q){return q.split(" ").map((z)=>{if(z==="[options]")return this.styleOptionText(z);if(z==="[command]")return this.styleSubcommandText(z);if(z[0]==="["||z[0]==="<")return this.styleArgumentText(z);return this.styleCommandText(z)}).join(" ")}styleCommandDescription(q){return this.styleDescriptionText(q)}styleOptionDescription(q){return this.styleDescriptionText(q)}styleSubcommandDescription(q){return this.styleDescriptionText(q)}styleArgumentDescription(q){return this.styleDescriptionText(q)}styleDescriptionText(q){return q}styleOptionTerm(q){return this.styleOptionText(q)}styleSubcommandTerm(q){return q.split(" ").map((z)=>{if(z==="[options]")return this.styleOptionText(z);if(z[0]==="["||z[0]==="<")return this.styleArgumentText(z);return this.styleSubcommandText(z)}).join(" ")}styleArgumentTerm(q){return this.styleArgumentText(q)}styleOptionText(q){return q}styleArgumentText(q){return q}styleSubcommandText(q){return q}styleCommandText(q){return q}padWidth(q,z){return Math.max(z.longestOptionTermLength(q,z),z.longestGlobalOptionTermLength(q,z),z.longestSubcommandTermLength(q,z),z.longestArgumentTermLength(q,z))}preformatted(q){return/\n[^\S\r\n]/.test(q)}formatItem(q,z,J,Q){let Y=" ".repeat(2);if(!J)return Y+q;let Z=q.padEnd(z+q.length-Q.displayWidth(q)),_=2,$=(this.helpWidth??80)-z-_-2,R;if($<this.minWidthToWrap||Q.preformatted(J))R=J;else R=Q.boxWrap(J,$).replace(/\n/g,`
|
|
4
4
|
`+" ".repeat(z+_));return Y+Z+" ".repeat(_)+R.replace(/\n/g,`
|
|
5
5
|
${Y}`)}boxWrap(q,z){if(z<this.minWidthToWrap)return q;let J=q.split(/\r\n|\n/),Q=/[\s]*[^\s]+/g,X=[];return J.forEach((Y)=>{let Z=Y.match(Q);if(Z===null){X.push("");return}let _=[Z.shift()],T=this.displayWidth(_[0]);Z.forEach(($)=>{let R=this.displayWidth($);if(T+R<=z){_.push($),T+=R;return}X.push(_.join(""));let B=$.trimStart();_=[B],T=this.displayWidth(B)}),X.push(_.join(""))}),X.join(`
|
|
@@ -25,4 +25,4 @@ Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[q])this._lifeCycl
|
|
|
25
25
|
`),this._exit(0,"commander.version",q)}),this}description(q,z){if(q===void 0&&z===void 0)return this._description;if(this._description=q,z)this._argsDescription=z;return this}summary(q){if(q===void 0)return this._summary;return this._summary=q,this}alias(q){if(q===void 0)return this._aliases[0];let z=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)z=this.commands[this.commands.length-1];if(q===z._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand(q);if(J){let Q=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${q}' to command '${this.name()}' as already have command '${Q}'`)}return z._aliases.push(q),this}aliases(q){if(q===void 0)return this._aliases;return q.forEach((z)=>this.alias(z)),this}usage(q){if(q===void 0){if(this._usage)return this._usage;let z=this.registeredArguments.map((J)=>{return Mq(J)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?z:[]).join(" ")}return this._usage=q,this}name(q){if(q===void 0)return this._name;return this._name=q,this}helpGroup(q){if(q===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=q,this}commandsGroup(q){if(q===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=q,this}optionsGroup(q){if(q===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=q,this}_initOptionGroup(q){if(this._defaultOptionGroup&&!q.helpGroupHeading)q.helpGroup(this._defaultOptionGroup)}_initCommandGroup(q){if(this._defaultCommandGroup&&!q.helpGroup())q.helpGroup(this._defaultCommandGroup)}nameFromFilename(q){return this._name=U.basename(q,U.extname(q)),this}executableDir(q){if(q===void 0)return this._executableDir;return this._executableDir=q,this}helpInformation(q){let z=this.createHelp(),J=this._getOutputContext(q);z.prepareContext({error:J.error,helpWidth:J.helpWidth,outputHasColors:J.hasColors});let Q=z.formatHelp(this,z);if(J.hasColors)return Q;return this._outputConfiguration.stripColor(Q)}_getOutputContext(q){q=q||{};let z=!!q.error,J,Q,X;if(z)J=(Z)=>this._outputConfiguration.writeErr(Z),Q=this._outputConfiguration.getErrHasColors(),X=this._outputConfiguration.getErrHelpWidth();else J=(Z)=>this._outputConfiguration.writeOut(Z),Q=this._outputConfiguration.getOutHasColors(),X=this._outputConfiguration.getOutHelpWidth();return{error:z,write:(Z)=>{if(!Q)Z=this._outputConfiguration.stripColor(Z);return J(Z)},hasColors:Q,helpWidth:X}}outputHelp(q){let z;if(typeof q==="function")z=q,q=void 0;let J=this._getOutputContext(q),Q={error:J.error,write:J.write,command:this};this._getCommandAndAncestors().reverse().forEach((Y)=>Y.emit("beforeAllHelp",Q)),this.emit("beforeHelp",Q);let X=this.helpInformation({error:J.error});if(z){if(X=z(X),typeof X!=="string"&&!Buffer.isBuffer(X))throw Error("outputHelp callback must return a string or a Buffer")}if(J.write(X),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",Q),this._getCommandAndAncestors().forEach((Y)=>Y.emit("afterAllHelp",Q))}helpOption(q,z){if(typeof q==="boolean"){if(q){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(q??"-h, --help",z??"display help for command"),q||z)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(q){return this._helpOption=q,this._initOptionGroup(q),this}help(q){this.outputHelp(q);let z=Number(G.exitCode??0);if(z===0&&q&&typeof q!=="function"&&q.error)z=1;this._exit(z,"commander.help","(outputHelp)")}addHelpText(q,z){let J=["beforeAll","before","after","afterAll"];if(!J.includes(q))throw Error(`Unexpected value for position to addHelpText.
|
|
26
26
|
Expecting one of '${J.join("', '")}'`);let Q=`${q}Help`;return this.on(Q,(X)=>{let Y;if(typeof z==="function")Y=z({error:X.error,command:X.command});else Y=z;if(Y)X.write(`${Y}
|
|
27
27
|
`)}),this}_outputHelpIfRequested(q){let z=this._getHelpOption();if(z&&q.find((Q)=>z.is(Q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function u(q){return q.map((z)=>{if(!z.startsWith("--inspect"))return z;let J,Q="127.0.0.1",X="9229",Y;if((Y=z.match(/^(--inspect(-brk)?)$/))!==null)J=Y[1];else if((Y=z.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=Y[1],/^\d+$/.test(Y[3]))X=Y[3];else Q=Y[3];else if((Y=z.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=Y[1],Q=Y[3],X=Y[4];if(J&&X!=="0")return`${J}=${Q}:${parseInt(X)+1}`;return z})}function N(){if(G.env.NO_COLOR||G.env.FORCE_COLOR==="0"||G.env.FORCE_COLOR==="false")return!1;if(G.env.FORCE_COLOR||G.env.CLICOLOR_FORCE!==void 0)return!0;return}Wq.Command=F;Wq.useColor=N});var d=M((Vq)=>{var{Argument:c}=W(),{Command:y}=g(),{CommanderError:Iq,InvalidArgumentError:l}=K(),{Help:Eq}=I(),{Option:m}=E();Vq.program=new y;Vq.createCommand=(q)=>new y(q);Vq.createOption=(q,z)=>new m(q,z);Vq.createArgument=(q,z)=>new c(q,z);Vq.Command=y;Vq.Option=m;Vq.Argument=c;Vq.Help=Eq;Vq.CommanderError=Iq;Vq.InvalidArgumentError=l;Vq.InvalidOptionArgumentError=l});var p=bq(d(),1),{program:dq,createCommand:pq,createArgument:sq,createOption:iq,CommanderError:rq,InvalidArgumentError:tq,InvalidOptionArgumentError:nq,Command:aq,Argument:oq,Option:eq,Help:qz}=p.default;
|
|
28
|
-
export{dq as
|
|
28
|
+
export{dq as Yb,pq as Zb,sq as _b,iq as $b,rq as ac,tq as bc,nq as cc,aq as dc,oq as ec,eq as fc,qz as gc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{fe as NG,ge as i,ie as I1}from"./index-c7554sg7.js";var k1=i((tY,g1)=>{var d=1000,u=d*60,f=u*60,g=f*24,c0=g*7,b0=g*365.25;g1.exports=function(G,Y){Y=Y||{};var $=typeof G;if($==="string"&&G.length>0)return y0(G);else if($==="number"&&isFinite(G))return Y.long?p0(G):m0(G);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(G))};function y0(G){if(G=String(G),G.length>100)return;var Y=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(G);if(!Y)return;var $=parseFloat(Y[1]),J=(Y[2]||"ms").toLowerCase();switch(J){case"years":case"year":case"yrs":case"yr":case"y":return $*b0;case"weeks":case"week":case"w":return $*c0;case"days":case"day":case"d":return $*g;case"hours":case"hour":case"hrs":case"hr":case"h":return $*f;case"minutes":case"minute":case"mins":case"min":case"m":return $*u;case"seconds":case"second":case"secs":case"sec":case"s":return $*d;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return $;default:return}}function m0(G){var Y=Math.abs(G);if(Y>=g)return Math.round(G/g)+"d";if(Y>=f)return Math.round(G/f)+"h";if(Y>=u)return Math.round(G/u)+"m";if(Y>=d)return Math.round(G/d)+"s";return G+"ms"}function p0(G){var Y=Math.abs(G);if(Y>=g)return J1(G,Y,g,"day");if(Y>=f)return J1(G,Y,f,"hour");if(Y>=u)return J1(G,Y,u,"minute");if(Y>=d)return J1(G,Y,d,"second");return G+" ms"}function J1(G,Y,$,J){var Q=Y>=$*1.5;return Math.round(G/$)+" "+J+(Q?"s":"")}});var R1=i((rY,c1)=>{function l0(G){$.debug=$,$.default=$,$.coerce=V,$.disable=q,$.enable=Q,$.enabled=M,$.humanize=k1(),$.destroy=W,Object.keys(G).forEach((K)=>{$[K]=G[K]}),$.names=[],$.skips=[],$.formatters={};function Y(K){let j=0;for(let _=0;_<K.length;_++)j=(j<<5)-j+K.charCodeAt(_),j|=0;return $.colors[Math.abs(j)%$.colors.length]}$.selectColor=Y;function $(K){let j,_=null,O,y;function I(...A){if(!I.enabled)return;let h=I,r=Number(new Date),D0=r-(j||r);if(h.diff=D0,h.prev=j,h.curr=r,j=r,A[0]=$.coerce(A[0]),typeof A[0]!=="string")A.unshift("%O");let e=0;A[0]=A[0].replace(/%([a-zA-Z%])/g,(j1,A0)=>{if(j1==="%%")return"%";e++;let H1=$.formatters[A0];if(typeof H1==="function"){let C0=A[e];j1=H1.call(h,C0),A.splice(e,1),e--}return j1}),$.formatArgs.call(h,A),(h.log||$.log).apply(h,A)}if(I.namespace=K,I.useColors=$.useColors(),I.color=$.selectColor(K),I.extend=J,I.destroy=$.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(_!==null)return _;if(O!==$.namespaces)O=$.namespaces,y=$.enabled(K);return y},set:(A)=>{_=A}}),typeof $.init==="function")$.init(I);return I}function J(K,j){let _=$(this.namespace+(typeof j>"u"?":":j)+K);return _.log=this.log,_}function Q(K){$.save(K),$.namespaces=K,$.names=[],$.skips=[];let j=(typeof K==="string"?K:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let _ of j)if(_[0]==="-")$.skips.push(_.slice(1));else $.names.push(_)}function Z(K,j){let _=0,O=0,y=-1,I=0;while(_<K.length)if(O<j.length&&(j[O]===K[_]||j[O]==="*"))if(j[O]==="*")y=O,I=_,O++;else _++,O++;else if(y!==-1)O=y+1,I++,_=I;else return!1;while(O<j.length&&j[O]==="*")O++;return O===j.length}function q(){let K=[...$.names,...$.skips.map((j)=>"-"+j)].join(",");return $.enable(""),K}function M(K){for(let j of $.skips)if(Z(K,j))return!1;for(let j of $.names)if(Z(K,j))return!0;return!1}function V(K){if(K instanceof Error)return K.stack||K.message;return K}function W(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return $.enable($.load()),$}c1.exports=l0});var y1=i((b1,Q1)=>{b1.formatArgs=u0;b1.save=f0;b1.load=s0;b1.useColors=d0;b1.storage=o0();b1.destroy=(()=>{let G=!1;return()=>{if(!G)G=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();b1.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function d0(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let G;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(G=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(G[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function u0(G){if(G[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+G[0]+(this.useColors?"%c ":" ")+"+"+Q1.exports.humanize(this.diff),!this.useColors)return;let Y="color: "+this.color;G.splice(1,0,Y,"color: inherit");let $=0,J=0;G[0].replace(/%[a-zA-Z%]/g,(Q)=>{if(Q==="%%")return;if($++,Q==="%c")J=$}),G.splice(J,0,Y)}b1.log=console.debug||console.log||(()=>{});function f0(G){try{if(G)b1.storage.setItem("debug",G);else b1.storage.removeItem("debug")}catch(Y){}}function s0(){let G;try{G=b1.storage.getItem("debug")||b1.storage.getItem("DEBUG")}catch(Y){}if(!G&&typeof process<"u"&&"env"in process)G=process.env.DEBUG;return G}function o0(){try{return localStorage}catch(G){}}Q1.exports=R1()(b1);var{formatters:i0}=Q1.exports;i0.j=function(G){try{return JSON.stringify(G)}catch(Y){return"[UnexpectedJSONParseError]: "+Y.message}}});var d1=i((p1,K1)=>{var $G=I1("tty"),Z1=I1("util");p1.init=VG;p1.log=KG;p1.formatArgs=QG;p1.save=qG;p1.load=MG;p1.useColors=JG;p1.destroy=Z1.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");p1.colors=[6,2,3,4,5,1];try{let G=(()=>{throw new Error("Cannot require module "+"supports-color");})();if(G&&(G.stderr||G).level>=2)p1.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(G){}p1.inspectOpts=Object.keys(process.env).filter((G)=>{return/^debug_/i.test(G)}).reduce((G,Y)=>{let $=Y.substring(6).toLowerCase().replace(/_([a-z])/g,(Q,Z)=>{return Z.toUpperCase()}),J=process.env[Y];if(/^(yes|on|true|enabled)$/i.test(J))J=!0;else if(/^(no|off|false|disabled)$/i.test(J))J=!1;else if(J==="null")J=null;else J=Number(J);return G[$]=J,G},{});function JG(){return"colors"in p1.inspectOpts?Boolean(p1.inspectOpts.colors):$G.isatty(process.stderr.fd)}function QG(G){let{namespace:Y,useColors:$}=this;if($){let J=this.color,Q="\x1B[3"+(J<8?J:"8;5;"+J),Z=` ${Q};1m${Y} \x1B[0m`;G[0]=Z+G[0].split(`
|
|
3
3
|
`).join(`
|
|
4
4
|
`+Z),G.push(Q+"m+"+K1.exports.humanize(this.diff)+"\x1B[0m")}else G[0]=ZG()+Y+" "+G[0]}function ZG(){if(p1.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function KG(...G){return process.stderr.write(Z1.formatWithOptions(p1.inspectOpts,...G)+`
|
|
5
5
|
`)}function qG(G){if(G)process.env.DEBUG=G;else delete process.env.DEBUG}function MG(){return process.env.DEBUG}function VG(G){G.inspectOpts={};let Y=Object.keys(p1.inspectOpts);for(let $=0;$<Y.length;$++)G.inspectOpts[Y[$]]=p1.inspectOpts[Y[$]]}K1.exports=R1()(p1);var{formatters:m1}=K1.exports;m1.o=function(G){return this.inspectOpts.colors=this.useColors,Z1.inspect(G,this.inspectOpts).split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{isAbsolute as S,join as Z,relative as v,resolve as H}from"path";import{existsSync as E,readFileSync as m}from"fs";import{homedir as u}from"os";import{existsSync as F,mkdirSync as P,readFileSync as V,renameSync as j,writeFileSync as w}from"fs";import{homedir as I}from"os";import{dirname as N,join as U,resolve as b}from"path";var Q=new Map;async function B(q,z){let J=Q.get(q)??Promise.resolve(),$,K=new Promise((W)=>{$=W});Q.set(q,J.then(()=>K));try{return await J,await z()}finally{if($(),Q.get(q)===J.then(()=>K));queueMicrotask(()=>{let W=Q.get(q);if(!W)return;Promise.race([W,new Promise((D)=>{D(void 0)})]).then(()=>{if(Q.get(q)===W)Q.delete(q)})})}}var A="agents-registry";async function s(q){return B(A,q)}function T(){return b(process.env.VIBECONTROLS_HOME??U(I(),".boff","vibecontrols"))}var C=2,k="default";function M(){return U(T(),"agents.json")}function _(){let q=M();if(!F(q))return null;try{let z=JSON.parse(V(q,"utf8"));if(z&&typeof z==="object"&&!Array.isArray(z)&&"instances"in z)return z;return null}catch{return null}}function X(){let q=_();if(!q)return{schemaVersion:C,instances:[]};return q}function Y(q){let z=M();P(N(z),{recursive:!0});let J=`${z}.${process.pid}.tmp`,$={...q,schemaVersion:C};w(J,`${JSON.stringify($,null,2)}
|
|
3
3
|
`,{encoding:"utf8",mode:384}),j(J,z)}function o(){return X().instances}function a(q){let z=X();Y({...z,instances:q})}function O(){try{let z=X().defaultProfile;if(z&&typeof z==="string"&&z.length>0)return z}catch{}return k}function n(q){if(!q||typeof q!=="string")throw Error("setDefaultProfile: name is required");let z=X();Y({...z,defaultProfile:q})}var R=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,p=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function G(q){if(!R.test(q))throw Error("Invalid VIBECONTROLS_PROFILE. Use 1-128 characters: letters, numbers, dot, underscore, or dash.");return q}function h(){let q=process.env.VIBECONTROLS_PROFILE;if(q)return G(q);let z=O();return G(z)}function zq(q){if(!p.test(q))throw Error("Agent name must use 1-64 characters: letters, numbers, dot, underscore, or dash.");return q}function Jq(q,z){let J=v(H(q),H(z));return J===""||!!J&&!J.startsWith("..")&&!S(J)}function L(){let q=x(),z=h();return Z(q,"agents",z)}function Qq(){return Z(x(),"agents")}function Wq(){return Z(L(),"agent-db")}function x(){return H(process.env.VIBECONTROLS_HOME??Z(u(),".boff","vibecontrols"))}var y="https://registry.npmjs.org/";function Zq(){if(process.env.VIBECONTROLS_REGISTRY)return process.env.VIBECONTROLS_REGISTRY;try{let q=Z(L(),"config.json");if(E(q)){let z=JSON.parse(m(q,"utf8"));if(z.registry)return z.registry}}catch{}return y}
|
|
4
|
-
export{B as
|
|
4
|
+
export{B as Rd,s as Sd,o as Td,a as Ud,O as Vd,n as Wd,G as Xd,h as Yd,zq as Zd,Jq as _d,L as $d,Qq as ae,Wq as be,x as ce,Zq as de};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Sa as k}from"./index-
|
|
2
|
+
import{Sa as k}from"./index-s2xpdnsj.js";import{Eb as F,Fb as h,Gb as S,Hb as q,Jb as N,wb as f,zb as c}from"./index-rqq0k5fc.js";import{Vb as P}from"./index-pgew6sge.js";import{Od as V}from"./index-js1xn4sq.js";var U=["tunnel","session","ai","plan","gitops","security"];class m{providers=new Map;providerOrder=new Map;defaults=new Map;services=new Map;db;constructor(z){this.db=z}getDb(){return this.db}setProviderDefault(z,J){this.defaults.set(z,J)}clearProviderDefault(z,J){if(!J||this.defaults.get(z)===J)this.defaults.delete(z)}async hydrateDefaultsFromDb(){if(!this.db)return;for(let z of U)try{let J=await this.db.getConfig(`provider:default:${z}`);if(J)this.defaults.set(z,J)}catch{}}registerProvider(z,J,Q){if(!this.providers.has(z))this.providers.set(z,new Map),this.providerOrder.set(z,[]);let W=this.providers.get(z),Z=this.providerOrder.get(z);if(W.has(Q))V().logger.info("service-registry",`Updating ${z} provider from plugin '${Q}'`);else V().logger.info("service-registry",`Registered ${z} provider from plugin '${Q}'`);if(W.set(Q,{provider:J,pluginName:Q,registeredAt:new Date}),!Z.includes(Q))Z.push(Q)}getProvider(z){let J=this.providers.get(z);if(!J||J.size===0)return;let Q=this.defaults.get(z);if(Q&&J.has(Q))return J.get(Q).provider;let W=this.providerOrder.get(z);if(W&&W.length>0){let Z=W[0];return J.get(Z)?.provider}return}getProviderByName(z,J){let Q=this.providers.get(z);if(!Q)return;return Q.get(J)?.provider}hasProvider(z){let J=this.providers.get(z);return!!J&&J.size>0}unregisterProvider(z,J){let Q=this.providers.get(z);if(!Q)return!1;let W=Q.delete(J);if(W){let Z=this.providerOrder.get(z);if(Z){let X=Z.indexOf(J);if(X!==-1)Z.splice(X,1)}this.clearProviderDefault(z,J),V().logger.info("service-registry",`Unregistered ${z} provider from plugin '${J}'`)}return W}unregisterPlugin(z){for(let J of U)this.unregisterProvider(J,z);this.unregisterServices(z)}listProvidersForType(z){let J=this.providers.get(z);if(!J)return[];let Q=this.defaults.get(z);if(!Q||!J.has(Q)){let W=this.providerOrder.get(z);Q=W&&W.length>0?W[0]:void 0}return Array.from(J.keys()).map((W)=>({pluginName:W,isDefault:W===Q}))}registerService(z,J,Q){let W=`${z}:${J}`;this.services.set(W,{service:Q,pluginName:z}),V().logger.debug("service-registry",`Registered service '${W}'`)}getService(z,J){let Q=`${z}:${J}`;return this.services.get(Q)?.service}unregisterServices(z){let J=[];for(let[Q,W]of this.services)if(W.pluginName===z)J.push(Q);for(let Q of J)this.services.delete(Q);if(J.length>0)V().logger.info("service-registry",`Unregistered ${J.length} services from ${z}`)}listProviders(){let z=[];for(let[J,Q]of this.providers)for(let[W,Z]of Q)z.push({type:J,name:W,pluginName:Z.pluginName});return z}listServices(){return Array.from(this.services.entries()).map(([z,J])=>({pluginName:J.pluginName,serviceName:z.split(":").slice(1).join(":")}))}clear(){this.providers.clear(),this.providerOrder.clear(),this.defaults.clear(),this.services.clear()}}import{extname as g,relative as o,resolve as u}from"path";import{realpath as E}from"fs/promises";var n=["'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"],D=!1;function w(){let z=process.env.VIBE_UI_FRAME_ANCESTORS?.trim(),J=z?z.split(/[\s,]+/).filter(Boolean):n;if(z&&!D&&(J.includes("*")||!J.includes("'self'")))D=!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: ${z}`);return`frame-ancestors ${J.join(" ")}`}var l={".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 s(z){return l[g(z).toLowerCase()]||"application/octet-stream"}var b=`<script>
|
|
3
3
|
window.__VIBE_AUTH__={apiKey:null};
|
|
4
4
|
(function(){
|
|
5
5
|
var p=new URLSearchParams(window.location.search);
|