@vibecontrols/agent 2026.902.1 → 2026.1124.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-config-v9d7gcz0.js +2 -0
- package/dist/agent-ready-tracker-mewxehg9.js +2 -0
- package/dist/app-k7z7tjem.js +2 -0
- package/dist/autostart.cmd-ahet7b1t.js +2 -0
- package/dist/bootstrap-workspace-3pb8qjsh.js +2 -0
- package/dist/bootstrap.service-9m7m1ksa.js +2 -0
- package/dist/bridge-client-xvqy3n15.js +2 -0
- package/dist/cli.js +2 -2
- package/dist/daemon-profile-sg8fp50z.js +2 -0
- package/dist/finalize-retry-handle-registry-z9mbbjmj.js +2 -0
- package/dist/finalize-retry-worker-az74f2qv.js +2 -0
- package/dist/gateway-client-ermpz52n.js +2 -0
- package/dist/getMachineId-bsd-4w1wmcjv.js +2 -0
- package/dist/getMachineId-darwin-kejwz8w5.js +3 -0
- package/dist/getMachineId-linux-mpm53wat.js +2 -0
- package/dist/getMachineId-unsupported-54seyw5v.js +2 -0
- package/dist/getMachineId-win-cva7ghz9.js +2 -0
- package/dist/highlights-3nz7pbkh.js +2 -0
- package/dist/highlights-6dgztt5d.js +2 -0
- package/dist/highlights-jq0g1547.js +2 -0
- package/dist/highlights-yc7cwzcr.js +2 -0
- package/dist/highlights-z2sw1kpq.js +2 -0
- package/dist/index-01fp85ft.js +171 -0
- package/dist/index-06bmw4xf.js +83 -0
- package/dist/index-0gmhd3hs.js +4 -0
- package/dist/index-0qjbnyg4.js +21 -0
- package/dist/index-2r6cmxxz.js +9 -0
- package/dist/index-2vcxt38h.js +3 -0
- package/dist/index-3b5xejjs.js +5 -0
- package/dist/index-3cbesatx.js +178 -0
- package/dist/index-4q8y6k1e.js +26 -0
- package/dist/index-4z1y39jt.js +3 -0
- package/dist/index-5021rk8n.js +3 -0
- package/dist/index-652f9scs.js +4 -0
- package/dist/index-76m37yd8.js +22 -0
- package/dist/index-7f2k4g6q.js +8 -0
- package/dist/index-7gk1x74m.js +15 -0
- package/dist/index-7wben1jx.js +3 -0
- package/dist/index-8rbhm4g8.js +7 -0
- package/dist/index-9bj65n3s.js +13 -0
- package/dist/index-9xrhb68w.js +14 -0
- package/dist/index-a0vx2zyx.js +3 -0
- package/dist/index-aav1drxa.js +158 -0
- package/dist/index-akk3rxnn.js +4 -0
- package/dist/index-b3v08awy.js +3 -0
- package/dist/index-byerrz46.js +3 -0
- package/dist/index-c4whjk5r.js +3 -0
- package/dist/index-cy97asyh.js +133 -0
- package/dist/index-d59kp6zr.js +3 -0
- package/dist/index-haww9jpq.js +27 -0
- package/dist/index-hsrt2v87.js +2 -0
- package/dist/index-jmx5awkj.js +3 -0
- package/dist/index-jnxjjx2y.js +3 -0
- package/dist/index-kwhx023z.js +11 -0
- package/dist/index-m942hydk.js +116 -0
- package/dist/index-mmx2kp76.js +16 -0
- package/dist/index-p0bbp16g.js +11 -0
- package/dist/index-qe3xpt41.js +3 -0
- package/dist/index-qfxwk38p.js +82 -0
- package/dist/index-ss5gez2p.js +2 -0
- package/dist/index-t5cfkz1e.js +4 -0
- package/dist/index-t6p4szqx.js +5 -0
- package/dist/index-tahaxp6n.js +3 -0
- package/dist/index-v16qz1fa.js +3 -0
- package/dist/index-vtsd74g0.js +9 -0
- package/dist/index-w0m3jm0s.js +408 -0
- package/dist/index-w4jqdhc2.js +5 -0
- package/dist/index-wr888ydc.js +17 -0
- package/dist/index-xtd0j8ve.js +3 -0
- package/dist/index-ywnfz6nm.js +3 -0
- package/dist/index.js +3 -3
- package/dist/injections-h25c1fmk.js +2 -0
- package/dist/interactive-vbz68zh5.js +2 -0
- package/dist/key.cmd-f6rjvjy8.js +2 -0
- package/dist/log-shipper-0erbwn0q.js +2 -0
- package/dist/path-utils-r4df8d3w.js +2 -0
- package/dist/plugin-system-kvg955t3.js +2 -0
- package/dist/prereqs-runner-gca0bytz.js +2 -0
- package/dist/profile-mount-s4mc1x18.js +2 -0
- package/dist/prune-stale-shims-4nqtv0xt.js +2 -0
- package/dist/register-core-31wm1d8m.js +2 -0
- package/dist/secondary-profile-attach-95kmnrhf.js +2 -0
- package/dist/subprocess-4gg77skg.js +2 -0
- package/dist/telemetry-nmtywcba.js +2 -0
- package/dist/tree-sitter-javascript-rfadfcwb.js +2 -0
- package/dist/tree-sitter-markdown-gkyb2qez.js +2 -0
- package/dist/tree-sitter-markdown_inline-xzttqkvb.js +2 -0
- package/dist/tree-sitter-typescript-4z897028.js +2 -0
- package/dist/tree-sitter-zig-y6n7djp6.js +2 -0
- package/dist/tunnel-bootstrap-rym0b0x5.js +2 -0
- package/package.json +10 -9
- package/dist/agent-config-5b0avmy6.js +0 -2
- package/dist/agent-ready-tracker-ez6r9djg.js +0 -2
- package/dist/app-mhms2gs0.js +0 -2
- package/dist/autostart.cmd-4zb9xhj0.js +0 -2
- package/dist/bootstrap-workspace-t5fyq07m.js +0 -2
- package/dist/bootstrap.service-nxhkrsf1.js +0 -2
- package/dist/bridge-client-bgkr7bcn.js +0 -2
- package/dist/daemon-profile-j2wt35x8.js +0 -2
- package/dist/esm-n9r8p5n2.js +0 -2
- package/dist/finalize-retry-handle-registry-fvm4gm8s.js +0 -2
- package/dist/finalize-retry-worker-wb8wj1yw.js +0 -2
- package/dist/gateway-client-6dqagbg4.js +0 -2
- package/dist/getMachineId-bsd-fgatzdd7.js +0 -2
- package/dist/getMachineId-darwin-gt8j2jw2.js +0 -3
- package/dist/getMachineId-linux-bcz4rr1x.js +0 -2
- package/dist/getMachineId-unsupported-079qwwb4.js +0 -2
- package/dist/getMachineId-win-2hk4e8bg.js +0 -2
- package/dist/highlights-0gfz787m.js +0 -2
- package/dist/highlights-86sbx76f.js +0 -2
- package/dist/highlights-n55f5jnk.js +0 -2
- package/dist/highlights-tbmszdr7.js +0 -2
- package/dist/highlights-wm2cs773.js +0 -2
- package/dist/index-06es0fmw.js +0 -10
- package/dist/index-0d4wfjbt.js +0 -171
- package/dist/index-29fmptfn.js +0 -13
- package/dist/index-2q2jadag.js +0 -11
- package/dist/index-2sn36kaj.js +0 -7
- package/dist/index-3p4n7nwg.js +0 -83
- package/dist/index-3tf12pw3.js +0 -3
- package/dist/index-54mmh1eb.js +0 -4
- package/dist/index-6jzsthh9.js +0 -3
- package/dist/index-7wejfjj9.js +0 -5
- package/dist/index-8q19ryt2.js +0 -28
- package/dist/index-8xh8m2z7.js +0 -8
- package/dist/index-98gr644s.js +0 -116
- package/dist/index-a8n6s2ae.js +0 -2
- package/dist/index-b16y8wyz.js +0 -15
- package/dist/index-bv1z3fxw.js +0 -3
- package/dist/index-cs78wq6y.js +0 -3
- package/dist/index-df19rrbe.js +0 -5
- package/dist/index-dx9hjdp4.js +0 -178
- package/dist/index-ea42kfvk.js +0 -5
- package/dist/index-ekr40gvh.js +0 -3
- package/dist/index-evnbrmdf.js +0 -4
- package/dist/index-f2asckf0.js +0 -26
- package/dist/index-ggxs7nwz.js +0 -3
- package/dist/index-gz5t0vvc.js +0 -4
- package/dist/index-hey6w5m0.js +0 -3
- package/dist/index-hp8jrj6j.js +0 -3
- package/dist/index-hrfkzecw.js +0 -3
- package/dist/index-hwpmdq5z.js +0 -4
- package/dist/index-hz5cy6vz.js +0 -11
- package/dist/index-jbxh0ffn.js +0 -407
- package/dist/index-js2r0men.js +0 -9
- package/dist/index-k3jkzj3k.js +0 -9
- package/dist/index-kteawn2b.js +0 -3
- package/dist/index-mbhq916m.js +0 -3
- package/dist/index-mxc61yr1.js +0 -3
- package/dist/index-qdbxvcwr.js +0 -17
- package/dist/index-qqq9qyy6.js +0 -21
- package/dist/index-rmh8pff5.js +0 -3
- package/dist/index-sspydg85.js +0 -15
- package/dist/index-tk81f249.js +0 -3
- package/dist/index-vjdg5qb2.js +0 -2
- package/dist/index-vkrf8kzp.js +0 -158
- package/dist/index-vnxqna70.js +0 -16
- package/dist/index-w7gctzhm.js +0 -83
- package/dist/index-wj5hx7gq.js +0 -4
- package/dist/index-x4eaagvr.js +0 -3
- package/dist/index-xjr60th0.js +0 -3
- package/dist/index-xtbppqnv.js +0 -3
- package/dist/index-y42xsgr6.js +0 -133
- package/dist/index-zr9rmjyp.js +0 -3
- package/dist/injections-2g0zh0bq.js +0 -2
- package/dist/interactive-08vyaapn.js +0 -2
- package/dist/key.cmd-642xcxb4.js +0 -2
- package/dist/log-shipper-9xfnjwr6.js +0 -2
- package/dist/path-utils-g449hqvm.js +0 -2
- package/dist/plugin-system-gpzcch00.js +0 -2
- package/dist/prereqs-runner-re9f51fp.js +0 -2
- package/dist/profile-mount-txvgkaz8.js +0 -2
- package/dist/prune-stale-shims-vs6a07tb.js +0 -2
- package/dist/register-core-ma4kse87.js +0 -2
- package/dist/secondary-profile-attach-m9x9e7py.js +0 -2
- package/dist/subprocess-zcgpccp1.js +0 -2
- package/dist/telemetry-k6em3vy2.js +0 -2
- package/dist/tree-sitter-javascript-qh90w7td.js +0 -2
- package/dist/tree-sitter-markdown-favzteb6.js +0 -2
- package/dist/tree-sitter-markdown_inline-x2726t9j.js +0 -2
- package/dist/tree-sitter-typescript-m7ep8z1h.js +0 -2
- package/dist/tree-sitter-zig-3vsxg5wh.js +0 -2
- package/dist/tunnel-bootstrap-y8dczezc.js +0 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{homedir as s,platform as u,tmpdir as a}from"os";import{delimiter as c}from"path";import{existsSync as d,readFileSync as m}from"fs";function g(){if(u()!=="linux")return!1;try{if(process.env.WSL_DISTRO_NAME)return!0;let r="/proc/version";if(!d(r))return!1;let e=m(r,"utf8").toLowerCase();return e.includes("microsoft")||e.includes("wsl")}catch{return!1}}function t(r){try{let e=Bun.spawnSync(r,{stdout:"pipe",stderr:"pipe"});return{code:e.exitCode??1,out:e.stdout.toString().trim(),err:e.stderr.toString().trim()}}catch(e){return{code:127,out:"",err:e instanceof Error?e.message:String(e)}}}class l{platform;isWSL;homeDir=s();tmpDir=a();pathSep=c;eol=`
|
|
3
|
+
`;executableSuffix="";constructor(r){this.platform=r,this.isWSL=g()}which(r,e){return Bun.which(r,{PATH:process.env.PATH})??null}isProcessAlive(r){if(!Number.isInteger(r)||r<=0)return!1;try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}platformLabel(){if(this.platform==="darwin")return"macOS";return this.isWSL?"WSL":"Linux"}killProcessTree(r,e){try{return process.kill(-r,e),!0}catch{try{return process.kill(r,e),!0}catch{return!1}}}listChildPids(r){let e=t(["pgrep","-P",String(r)]);if(e.code!==0)return[];return e.out.split(/\s+/).map((n)=>Number(n)).filter((n)=>Number.isInteger(n)&&n>0)}npmGlobalBin(){let r=t(["npm","bin","-g"]);if(r.code===0&&r.out)return r.out;let e=t(["npm","root","-g"]);if(e.code===0&&e.out)return`${e.out}/.bin`;return null}npmGlobalRoot(){let r=t(["npm","root","-g"]);return r.code===0&&r.out?r.out:null}bunGlobalBin(){let r=t(["bun","pm","-g","bin"]);if(r.code===0&&r.out)return r.out;return`${s()}/.bun/bin`}shellQuote(r){if(/^[A-Za-z0-9._\-/=:]+$/.test(r))return r;return`'${r.replace(/'/g,"'\\''")}'`}shellInvocation(){return{cmd:"/bin/sh",flag:"-c"}}shellArgv(r){let{cmd:e,flag:n}=this.shellInvocation();return[e,n,r]}processGroupSpawnOpts(){return{processGroupId:0}}}class p{platform="win32";isWSL=!1;homeDir=s();tmpDir=a();pathSep=c;eol=`\r
|
|
4
|
+
`;executableSuffix=".exe";which(r,e){return Bun.which(r,{PATH:process.env.PATH})??null}platformLabel(){return"Windows"}isProcessAlive(r){if(!Number.isInteger(r)||r<=0)return!1;try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}killProcessTree(r,e){let n=e==="SIGKILL"||e==="SIGTERM",i=["taskkill.exe","/T","/PID",String(r)];if(n)i.push("/F");return t(i).code===0}listChildPids(r){let e=t(["wmic.exe","process","where",`(ParentProcessId=${r})`,"get","ProcessId"]);if(e.code!==0)return[];return e.out.split(/\r?\n/).map((n)=>Number(n.trim())).filter((n)=>Number.isInteger(n)&&n>0&&n!==r)}npmGlobalBin(){let r=t(["npm.cmd","bin","-g"]);if(r.code===0&&r.out)return r.out;return null}npmGlobalRoot(){let r=t(["npm.cmd","root","-g"]);return r.code===0&&r.out?r.out:null}bunGlobalBin(){let r=t(["bun.exe","pm","-g","bin"]);if(r.code===0&&r.out)return r.out;return null}shellQuote(r){return`'${r.replace(/'/g,"''")}'`}shellInvocation(){return{cmd:"cmd.exe",flag:"/c"}}shellArgv(r){let{cmd:e,flag:n}=this.shellInvocation();return[e,n,r]}processGroupSpawnOpts(){return{}}}var o=null;function b(){if(o)return o;let r=u();if(r==="win32")o=new p;else if(r==="darwin"||r==="linux")o=new l(r);else o=new l("linux");return o}
|
|
5
|
+
export{b};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Y,ye,Mt}from"./index-3b5xejjs.js";import{Ht,It,T,R,I,ne,se,B,e}from"./index-0qjbnyg4.js";import{Z}from"./index-ywnfz6nm.js";import{D}from"./index-9bj65n3s.js";import{b}from"./index-w4jqdhc2.js";import{Re}from"./index-byerrz46.js";import{existsSync as q,readFileSync as S,unlinkSync as ht,writeFileSync as U}from"fs";import{join as X}from"path";var Q=".consent.json";function He(t){try{let r=S(P(t),"utf8"),n=JSON.parse(r);if(Array.isArray(n.abilities)&&n.abilities.length>0)return new Set(n.abilities)}catch{}return null}function qt(t){try{let r=S(P(t),"utf8"),n=JSON.parse(r);if(Array.isArray(n.providers))return n.providers.filter((o)=>typeof o==="string")}catch{}return[]}function Ei(t){let r=new Set;for(let n of t.split(",").map((o)=>o.trim()).filter(Boolean)){let o=Mt(n);if(o)r.add(o)}return[...r]}function P(t){return X(t,Q)}function _i(t,r){let n=r??new Set(Y.filter((i)=>i.defaultSelected||i.mandatory).map((i)=>i.key)),o=t.skipPluginInstall?[]:ye(process.platform,n).filter((i)=>!t.skipPlugins.includes(i.packageName)&&!t.skipPlugins.includes(i.pluginName)).map((i)=>({packageName:i.packageName,pluginName:i.pluginName,reason:i.description}));return{tools:[],plugins:o}}async function er(){let t=new Set(Y.filter((n)=>n.defaultSelected||n.mandatory).map((n)=>n.key));for(let n of Y)if(n.mandatory)t.add(n.key);if(!(Boolean(process.stdin.isTTY)&&process.env.VIBE_AUTO_ACCEPT!=="1"))return t;try{let{interactiveCheckboxes:n}=await import("./interactive-vbz68zh5.js"),o=await n("Select the agent abilities to install",Y.map((i)=>({key:i.key,label:i.label,description:i.description,mandatory:i.mandatory})),t);if(o){for(let i of Y)if(i.mandatory)o.add(i.key);return o}return t}catch(n){process.stdout.write(`
|
|
3
|
+
[vibe] Falling back to plain prompt \u2014 ${n instanceof Error?n.message:String(n)}
|
|
4
|
+
|
|
5
|
+
`);let o=await ee("Select the agent abilities to install",Y.map((i)=>({key:i.key,label:i.label,description:i.description,mandatory:i.mandatory})),t);if(o){for(let i of Y)if(i.mandatory)o.add(i.key);return o}return t}}async function ee(t,r,n){let o=new Set(n);for(let s of r)if(s.mandatory)o.add(s.key);let i=()=>{process.stdout.write(`
|
|
6
|
+
${t}
|
|
7
|
+
`),r.forEach((s,l)=>{let d=s.mandatory||o.has(s.key)?"[x]":"[ ]",u=s.mandatory?" (required)":"";process.stdout.write(` ${(l+1).toString().padStart(2)}. ${d} ${s.label}${u}
|
|
8
|
+
${s.description}
|
|
9
|
+
`)}),process.stdout.write(`
|
|
10
|
+
Type numbers to toggle (e.g. '2 4'), 'a' = all, 'n' = none, '?' = help, Enter = confirm: `)},a=()=>new Promise((s)=>{let l=[],c=(d)=>{let u=d.toString("utf8");if(l.push(u),u.includes(`
|
|
11
|
+
`))process.stdin.off("data",c),s(l.join("").replace(/\r?\n$/u,""))};process.stdin.on("data",c)});process.stdin.resume();try{while(!0){i();let s=(await a()).trim();if(s==="")return o;if(s==="?"||s.toLowerCase()==="h"){process.stdout.write(`
|
|
12
|
+
\u2022 Type one or more row numbers (separated by spaces or commas) to flip those rows.
|
|
13
|
+
`+` \u2022 Type 'a' to select all, 'n' to deselect everything except required rows.
|
|
14
|
+
`+` \u2022 Press Enter on a blank line to confirm the current selection.
|
|
15
|
+
`+` \u2022 Press Ctrl-C to cancel and accept the safe defaults (everything on).
|
|
16
|
+
`);continue}if(s.toLowerCase()==="a"){for(let c of r)o.add(c.key);continue}if(s.toLowerCase()==="n"){o.clear();for(let c of r)if(c.mandatory)o.add(c.key);continue}let l=s.split(/[\s,]+/u).filter(Boolean);for(let c of l){let d=Number.parseInt(c,10);if(!Number.isFinite(d)||d<1||d>r.length)continue;let u=r[d-1];if(!u||u.mandatory)continue;if(o.has(u.key))o.delete(u.key);else o.add(u.key)}}}finally{process.stdin.pause()}}function yi(t){let r=new Set(Y.map((o)=>o.key)),n=new Set;for(let o of t.split(",").map((i)=>i.trim().toLowerCase()))if(r.has(o))n.add(o);for(let o of Y)if(o.mandatory)n.add(o.key);return n}function tr(){return new Set(Y.filter((t)=>t.defaultSelected||t.mandatory).map((t)=>t.key))}function Si(t,r,n,o,i){let a={acceptedAt:new Date().toISOString(),agentVersion:o,abilities:[...n],providers:i?[...i]:void 0,tools:r.tools.map((s)=>({name:s.name,reason:s.reason})),plugins:r.plugins.map((s)=>({packageName:s.packageName,reason:s.reason}))};U(P(t),JSON.stringify(a,null,2))}function ot(t,r){let n=oe(t),o={acceptedAt:n?.acceptedAt??new Date().toISOString(),agentVersion:r.agentVersion??n?.agentVersion,abilities:r.abilities?[...r.abilities]:n?.abilities,providers:r.providers?[...r.providers]:n?.providers,tools:n?.tools??[],plugins:n?.plugins??[]};U(P(t),JSON.stringify(o,null,2))}function oe(t){try{let r=P(t);if(!q(r))return null;return JSON.parse(S(r,"utf8"))}catch{return null}}import{createHash as ie}from"crypto";import{homedir as le,tmpdir as ce}from"os";import*as f from"path";import{spawn as E}from"child_process";import{createWriteStream as ue,existsSync as de,promises as h}from"fs";import{Readable as pe}from"stream";import{pipeline as ge}from"stream/promises";function fe(){let t=process.arch==="x64"?"x64":"arm64";return`${process.platform==="win32"?"win32":process.platform==="darwin"?"darwin":"linux"}-${t}`}function he(){return f.join(le(),".boff","vibecontrols","tools")}function O(t,r){let n=r??t;if(process.platform==="win32"&&!n.toLowerCase().endsWith(".exe"))return`${n}.exe`;return n}function we(t,r,n){return f.join(n??he(),t,O(t,r))}async function N(t,r){if(!r.versionMatcher)return!0;return new Promise((n)=>{let o=E(t,r.versionArgs??["--version"],{stdio:["ignore","pipe","pipe"]}),i="";o.stdout.on("data",(a)=>i+=a.toString()),o.stderr.on("data",(a)=>i+=a.toString()),o.on("close",()=>{try{n(new RegExp(r.versionMatcher).test(i))}catch{n(!1)}}),o.on("error",()=>n(!1))})}async function be(t){let r=t.platform??fe(),n=O(t.name,t.binaryName),o=we(t.name,t.binaryName,t.cacheRoot);if(de(o)&&await N(o,t))return o;try{let a=typeof Bun<"u"&&typeof Bun.which==="function"?Bun.which(t.binaryName??t.name,{PATH:process.env.PATH}):null;if(a&&await N(a,t))return t.log?.info?.(`[install] using PATH binary ${t.name} (${a})`),a}catch{}let i=t.downloads[r];if(!i)throw Error(`[install] no download manifest entry for ${t.name} on ${r}`);return t.log?.info?.(`[install] downloading ${t.name} for ${r}`),await h.mkdir(f.dirname(o),{recursive:!0}),await ke(i,o,n,t.name),t.log?.info?.(`[install] installed ${t.name} \u2192 ${o}`),o}async function ke(t,r,n,o){f.dirname(r);let i=f.join(ce(),`vibe-install-${o}-${process.pid}`);await h.mkdir(i,{recursive:!0});let a=f.join(i,"artifact");try{let s=await fetch(t.url,{redirect:"follow"});if(!s.ok)throw Error(`download failed (${s.status}) for ${t.url}`);if(!s.body)throw Error(`empty response body for ${t.url}`);if(await ge(pe.fromWeb(s.body),ue(a)),t.sha256){let c=ie("sha256").update(await h.readFile(a)).digest("hex");if(c!==t.sha256)throw Error(`sha256 mismatch for ${o}: expected ${t.sha256}, got ${c}`)}let l=t.archive??(t.url.endsWith(".tar.gz")||t.url.endsWith(".tgz")?"tar.gz":t.url.endsWith(".zip")?"zip":"raw");if(l==="raw")await h.copyFile(a,r);else{if(l==="tar.gz")await x("tar",["-xzf",a,"-C",i]);else await Pe(a,i);let c=t.binaryWithinArchive??n;await h.copyFile(f.join(i,c),r)}if(process.platform!=="win32")await h.chmod(r,493)}finally{await h.rm(i,{recursive:!0,force:!0})}}async function Pe(t,r){try{await x("unzip",["-q","-o",t,"-d",r]);return}catch(n){if(process.platform!=="win32")throw n;await x("tar",["-xf",t,"-C",r])}}async function x(t,r){return new Promise((n,o)=>{let i=E(t,r,{stdio:["ignore","ignore","pipe"]}),a="";i.stderr.on("data",(s)=>a+=s.toString()),i.on("close",(s)=>s===0?n():o(Error(`${t} exit ${s}: ${a}`))),i.on("error",o)})}var k="https://github.com/cloudflare/cloudflared/releases/latest/download",ve={"linux-x64":{url:`${k}/cloudflared-linux-amd64`,archive:"raw"},"linux-arm64":{url:`${k}/cloudflared-linux-arm64`,archive:"raw"},"darwin-x64":{url:`${k}/cloudflared-darwin-amd64.tgz`,archive:"tar.gz",binaryWithinArchive:"cloudflared"},"darwin-arm64":{url:`${k}/cloudflared-darwin-arm64.tgz`,archive:"tar.gz",binaryWithinArchive:"cloudflared"},"win32-x64":{url:`${k}/cloudflared-windows-amd64.exe`,archive:"raw"},"win32-arm64":{url:`${k}/cloudflared-windows-arm64.exe`,archive:"raw"}},Se=/(https:\/\/(?!api\.)[a-zA-Z0-9-]+\.trycloudflare\.com)/;async function L(t,r){let n=r?.log??{},o;try{o=await be({name:"cloudflared",downloads:ve,versionMatcher:"cloudflared version",log:n})}catch(s){return n.warn?.(`quick-tunnel: could not obtain cloudflared: ${String(s)}`),null}let i;try{i=E(o,["tunnel","--url",`http://127.0.0.1:${t}`,"--no-autoupdate"],{stdio:["ignore","pipe","pipe"]})}catch(s){return n.warn?.(`quick-tunnel: failed to spawn cloudflared: ${String(s)}`),null}let a=await new Promise((s)=>{let l=!1,c=(g)=>{if(l)return;l=!0,s(g)},d=setTimeout(()=>{n.warn?.("quick-tunnel: cloudflared did not advertise a URL in time"),c(null)},r?.timeoutMs??30000),u=(g)=>{let p=g.toString("utf8").match(Se);if(p)clearTimeout(d),c(p[0])};i.stdout?.on("data",u),i.stderr?.on("data",u),i.on("error",(g)=>{clearTimeout(d),n.warn?.(`quick-tunnel: cloudflared failed to spawn: ${String(g)}`),c(null)}),i.on("exit",(g)=>{clearTimeout(d),n.warn?.(`quick-tunnel: cloudflared exited (code=${g})`),c(null)})});if(!a)return null;return{url:a,child:i}}import{existsSync as M,mkdirSync as xe,readFileSync as $e,writeFileSync as Te,unlinkSync as Ee}from"fs";import{dirname as Ae,join as F}from"path";import{readdirSync as Ce}from"fs";function A(t){return F(t??I(),"tunnel.state.json")}function j(t,r){let n=A(r);try{xe(Ae(n),{recursive:!0}),Te(n,JSON.stringify(t,null,2),"utf8")}catch(o){e().logger.warn("tunnel-state","Failed to persist tunnel state",{error:String(o)})}}function te(t){let r=A(t);if(!M(r))return null;try{let n=$e(r,"utf8"),o=JSON.parse(n);if(typeof o.pid!=="number")return null;return o}catch(n){return e().logger.warn("tunnel-state","Failed to read tunnel state",{error:String(n)}),null}}function re(t){let r=A(t);if(!M(r))return;try{Ee(r)}catch{}}function ae(t){return b().isProcessAlive(t)}function Ii(t){let r=[];if(t?.allProfiles){let o;try{o=ne()}catch{return r}let i;try{i=Ce(o)}catch{return r}for(let a of i){let s=F(o,a),l=te(s);if(l)r.push({...l,alive:ae(l.pid),profileDir:s})}return r}let n=te();if(n)r.push({...n,alive:ae(n.pid),profileDir:I()});return r}function rr(t){return t.replace(/[^A-Za-z0-9_]/g,"_")}function v(){return(B()??e()).tunnel}async function Rr(t,r){let n=v();_e(t),Ie();let o=process.env.AGENT_TUNNEL_URL;if(o){let s=It(o);if(!s)return e().logger.warn("tunnel-bootstrap","Ignoring invalid AGENT_TUNNEL_URL"),null;n.url=s,n.externalUrl=!0,e().logger.info("tunnel-bootstrap",`Using AGENT_TUNNEL_URL=${s}`);try{Z.emit("tunnel.url_assigned",{provider:"external"})}catch{}return s}let i=r.port,a=await L(i,{log:{info:(s)=>e().logger.info("tunnel-bootstrap",s),warn:(s)=>e().logger.warn("tunnel-bootstrap",s)}});if(!a)return e().logger.warn("tunnel-bootstrap","No bootstrap tunnel \u2014 the agent will register once the tunnel provider starts post-config"),null;if(n.child=a.child,n.url=a.url,n.url){e().logger.info("tunnel-bootstrap",`Bootstrap tunnel ready: ${n.url}`);try{let c=new URL(n.url).hostname.split(".");if(c.length>=2)Ht("."+c.slice(-2).join("."))}catch{}try{Z.emit("tunnel.url_assigned",{provider:"bootstrap"})}catch{}let s=rr(R());if(process.env[`AGENT_TUNNEL_URL_${s}`]=n.url,n.child?.pid!==void 0)process.env[`AGENT_TUNNEL_PID_${s}`]=String(n.child.pid),j({pid:n.child.pid,url:n.url,startedAt:new Date().toISOString(),provider:"bootstrap",port:i,cmd:`cloudflared tunnel --url http://127.0.0.1:${i}`})}return n.url}function Ji(){let t=v();if(t.externalUrl)return!1;if(!t.child||t.child.killed)return!1;let r=t.child.pid;if(r===void 0)return!1;try{process.kill(r,0)}catch{return!1}return t.child=null,re(),e().logger.info("tunnel-bootstrap",`Handed over bootstrap tunnel (PID ${r}) to plugin \u2014 process kept alive`),!0}function ir(){let t=v();if(t.externalUrl){re();return}let r=t.child;if(t.child=null,re(),!r||r.killed)return;try{r.kill("SIGTERM"),e().logger.info("tunnel-bootstrap","Bootstrap tunnel stopped")}catch{}}function at(){return v().url}function Ie(){let t=te();if(!t)return;if(!ae(t.pid)){re();return}try{process.kill(t.pid,"SIGTERM"),e().logger.info("tunnel-bootstrap","Reaped orphan tunnel from prior run",{pid:t.pid,provider:t.provider})}catch{}let r=Date.now();while(Date.now()-r<2000&&ae(t.pid))Bun.sleepSync(50);if(ae(t.pid))try{process.kill(t.pid,"SIGKILL")}catch{}re()}function _e(t){let r={name:"bootstrap",async getActiveTunnelUrl(){return v().url}};t.registerProvider("tunnel",r,"bootstrap")}import{existsSync as Ue,mkdirSync as Oe,readFileSync as Be,renameSync as Me,writeFileSync as Fe}from"fs";import{dirname as je,join as ze}from"path";var De=["tunnel:read","session:list","session:share:read","session:share:write","plugin:list","plugin:install","plugin:remove","log:read","diagnostics:read","key:mint","mesh:forward","admin"];function z(t){return ze(t??I(),"agent-network.json")}function y(t){let r=z(t);if(!Ue(r))return{schemaVersion:1,peers:[]};let n=Be(r,"utf8");try{let o=JSON.parse(n);if(!o||!Array.isArray(o.peers))return{schemaVersion:1,peers:[]};return o}catch{return{schemaVersion:1,peers:[]}}}function C(t,r){let n=z(r);Oe(je(n),{recursive:!0});let o=`${n}.${process.pid}.tmp`;Fe(o,JSON.stringify(t,null,2),{mode:384}),Me(o,n)}function Ci(t){return y(t).peers}function Ve(t,r){return y(r).peers.find((n)=>n.id===t)??null}function H(t,r){if(r.workspaceId&&t.workspaceId&&t.workspaceId!==r.workspaceId)return!1;if(r.ownerUserId)return(t.ownerUserId??r.ownerUserId)===r.ownerUserId;return!0}function At(t,r){return y(r).peers.filter((n)=>H(n,t))}function Fr(t,r,n){return y(n).peers.find((o)=>o.agentRecordId===t&&H(o,r))??null}function Ye(t,r){let n=y(r),o=n.peers.findIndex((i)=>i.id===t.id);if(o>=0)n.peers[o]={...n.peers[o],...t};else n.peers.push(t);return C(n,r),t}function Ne(t,r,n){let o=y(n),i=o.peers.findIndex((a)=>a.id===t);if(i<0)return null;return o.peers[i]={...o.peers[i],...r},C(o,n),o.peers[i]}function Rt(t,r){let n=y(r),o=n.peers.length;if(n.peers=n.peers.filter((i)=>i.id!==t),n.peers.length===o)return!1;return C(n,r),!0}function Ze(t){let r=new Set(De);return[...t].filter((n)=>r.has(n)).map((n)=>n)}import{join as Ke}from"path";function w(t){let r=b();return r.which(t)??`${t}${r.executableSuffix}`}async function nr(){let t=["..","../..","../../.."];for(let r of t)try{let n=Ke(import.meta.dir,r,"package.json"),o=await Bun.file(n).json(),{name:i,version:a}=o;if(i&&a){let s=o.publishConfig;return{name:i,version:a,registry:s?.registry??se()}}}catch{}throw Error("package.json not found")}function Ge(t,r,n){try{let o=Bun.spawnSync([w("npm"),"view",`${t}@${r}`,"--json",`--registry=${n}`],{stdout:"pipe",stderr:"pipe"});if(o.exitCode!==0)return null;let i=JSON.parse(o.stdout.toString());return Array.isArray(i)?i[0]??null:i}catch{return null}}function V(t,r){let n=(a)=>a.replace(/^[\^~>=<v]+/,"").split(/[.+-]/).map((s)=>Number(s)||0),o=n(t),i=n(r);for(let a=0;a<Math.max(o.length,i.length);a++){let s=o[a]??0,l=i[a]??0;if(s!==l)return s-l}return 0}function qe(t,r){if(!t)return{ok:!0,message:""};let n=t.replace(/^[\^~]/,"").replace(/^>=?\s*/,"");if(V(r,n)>=0)return{ok:!0,message:`bun ${r} >= ${n}`};return{ok:!1,message:`requires bun ${t}, this process is bun ${r}`}}function Xe(t){try{let r=w("npm"),n=Bun.spawnSync([r,"root","-g"],{stdout:"pipe",stderr:"pipe"});if(n.exitCode!==0)return null;return`${n.stdout.toString().trim()}/${t}`}catch{return null}}function Qe(t){let r=Xe(t);if(!r)return{ok:!0,step:"(skipped, install root unknown)"};let n=`${r}/dist/cli.js`,o=(l,c,d)=>{try{let u=w("bun"),g=Bun.spawnSync([u,n,...l],{stdout:"pipe",stderr:"pipe",timeout:d});if(g.exitCode===0)return{ok:!0,step:c};return{ok:!1,step:c,detail:g.stderr.toString().slice(0,300)||`exit ${g.exitCode}`}}catch(u){return{ok:!1,step:c,detail:String(u)}}},i=o(["--version"],"vibe --version",1e4);if(!i.ok)return i;let a=o(["info"],"vibe info",15000);if(!a.ok)return a;let s=o(["plugin","list","--json"],"vibe plugin list",30000);if(!s.ok)return s;return{ok:!0,step:"all checks passed"}}async function et(t,r=60000){try{let n=new D,o=await n.getStatus(t);if(!o||o.status!=="running")return{kind:"not-running"};let i=`http://localhost:${o.port}`,a;try{a=await Re(i)}catch{}let s={};if(a)s["x-agent-api-key"]=a;let l=1000,c=Date.now();while(Date.now()-c<r){try{let d=await fetch(`${i}/api/profiles/${encodeURIComponent(t)}/stats/inflight`,{headers:s,signal:AbortSignal.timeout(2000)});if(d.ok){let u=await d.json();if(typeof u.inflight==="number"&&u.inflight===0){let g=o.config;return await n.restart(t,g),{kind:"restarted"}}}}catch{}await new Promise((d)=>setTimeout(d,l))}return{kind:"still-busy"}}catch(n){return{kind:"error",message:n instanceof Error?n.message:String(n)}}}async function Le(){let t;try{t=await nr()}catch(n){return{name:"@vibecontrols/agent",registry:se(),current:"unknown",latest:null,hasUpdate:!1,error:n instanceof Error?n.message:String(n)}}let r=null;try{let n=Bun.spawnSync([w("npm"),"view",t.name,"version",`--registry=${t.registry}`],{stdout:"pipe",stderr:"pipe"});if(n.exitCode===0)r=n.stdout.toString().trim()||null}catch{}if(!r)return{name:t.name,registry:t.registry,current:t.version,latest:null,hasUpdate:!1,error:"Could not reach the registry to check for updates"};return{name:t.name,registry:t.registry,current:t.version,latest:r,hasUpdate:V(r,t.version)>0}}async function Je(t={}){let r=t.onLog??(()=>{}),n=t.restart!==!1,o=t.name||"default",i;try{i=await nr()}catch(p){return{ok:!1,updated:!1,current:"unknown",previous:"unknown",latest:null,target:null,restart:"skipped",error:p instanceof Error?p.message:String(p)}}let a=i.version,s=t.targetVersion?.trim(),l=null;if(!s||s==="latest"){try{let p=Bun.spawnSync([w("npm"),"view",i.name,"version",`--registry=${i.registry}`],{stdout:"pipe",stderr:"pipe"});if(p.exitCode===0)l=p.stdout.toString().trim()||null}catch{}if(!l)return{ok:!1,updated:!1,current:a,previous:a,latest:null,target:null,restart:"skipped",error:"Could not check for updates (registry unreachable)"};s=l}if(s===a)return r(`Already on ${a}; nothing to do.`),{ok:!0,updated:!1,current:a,previous:a,latest:l??a,target:s,restart:"skipped"};let c,d=Ge(i.name,s,i.registry);if(d){let p=typeof Bun<"u"?Bun.version:"0.0.0",m=qe(d.engines?.bun,p);if(c=m.message,!m.ok&&!t.allowIncompatible)return{ok:!1,updated:!1,current:a,previous:a,latest:l,target:s,engineMessage:m.message,restart:"skipped",error:`Refusing to upgrade: ${m.message}. Pass allowIncompatible to override.`}}r(`Installing ${i.name}@${s}...`);try{let p=Bun.spawnSync([w("npm"),"install","-g",`${i.name}@${s}`,`--registry=${i.registry}`],{stdout:"pipe",stderr:"pipe"});if(p.exitCode!==0){let m=p.stderr.toString().slice(0,500);return{ok:!1,updated:!1,current:a,previous:a,latest:l,target:s,engineMessage:c,restart:"skipped",error:`npm install failed: ${m||`exit ${p.exitCode}`}`}}}catch(p){return{ok:!1,updated:!1,current:a,previous:a,latest:l,target:s,engineMessage:c,restart:"skipped",error:`npm install threw: ${p instanceof Error?p.message:String(p)}`}}let u=Qe(i.name);if(!u.ok){r(`Smoke test failed at "${u.step}" \u2014 rolling back to ${a}.`);let p=!1;try{p=Bun.spawnSync([w("npm"),"install","-g",`${i.name}@${a}`,`--registry=${i.registry}`],{stdout:"pipe",stderr:"pipe"}).exitCode===0}catch{}return{ok:!1,updated:!1,current:p?a:s,previous:a,latest:l,target:s,engineMessage:c,smoke:u,rolledBack:p,restart:"skipped",error:`Post-install smoke test failed at "${u.step}"${u.detail?`: ${u.detail}`:""}. ${p?"Rolled back.":"Rollback FAILED \u2014 reinstall manually."}`}}let g={kind:"skipped"};if(n)r(`Waiting for agent "${o}" to become idle before restart...`),g=await et(o,t.restartBudgetMs);return r(`Updated to ${s}.`),{ok:!0,updated:!0,current:s,previous:a,latest:l,target:s,engineMessage:c,smoke:u,rolledBack:!1,restart:g.kind,restartError:g.kind==="error"?g.message:void 0}}function tt(t){let r=/^(?:ssh:\/\/)?(?:([^@\s]+)@)?([^:/\s]+)(?::(\d+))?$/.exec(t.trim());if(!r)throw Error(`Could not parse SSH target: ${t}`);let n=Boolean(r[1]),o=Boolean(r[3]);if(!n&&!o&&!t.includes(":"))return{alias:r[2],host:r[2]};return{user:r[1],host:r[2],port:r[3]?Number(r[3]):void 0}}class K{mode="ssh";id;target;constructor(t){if(this.target=t,t.alias)this.id=`ssh://${t.alias}`;else{let r=t.user?`${t.user}@`:"",n=t.port?`:${t.port}`:"";this.id=`ssh://${r}${t.host}${n}`}}sshArgv(){let t=["ssh","-o","BatchMode=yes","-o","StrictHostKeyChecking=accept-new","-o","ServerAliveInterval=30"];if(this.target.identityFile)t.push("-i",this.target.identityFile);if(this.target.port)t.push("-p",String(this.target.port));return t.push(this.target.alias??(this.target.user?`${this.target.user}@${this.target.host}`:this.target.host)),t}async probe(){let t={},r=[["npm","command -v npm"],["node","command -v node"],["bun","command -v bun"],["vibe","command -v vibe"],["os","uname -s 2>/dev/null || echo unknown"],["arch","uname -m 2>/dev/null || echo unknown"]];for(let[n,o]of r){let i=await this.run(["sh","-c",o]),a=i.stdout.trim();if(i.code===0&&a)t[n]=a}return t}async run(t,r){let n=t.map(_).join(" "),o=[...this.sshArgv(),n],i=Bun.spawnSync(o,{stdout:"pipe",stderr:"pipe",timeout:r?.timeoutMs??600000});return{code:i.exitCode??1,stdout:i.stdout.toString(),stderr:i.stderr.toString()}}async upload(t,r,n){let o=[...this.sshArgv(),`cat > ${_(t)} && chmod ${(n??384).toString(8)} ${_(t)}`],i=Bun.spawn(o,{stdin:"pipe",stdout:"pipe",stderr:"pipe"}),a=i.stdin;a.write(typeof r==="string"?r:Buffer.from(r).toString("binary")),await a.end();let s=await i.exited;if(s!==0){let l=await new Response(i.stderr).text();throw Error(`upload to ${t} failed (exit ${s}): ${l}`)}}async close(){}}function _(t){if(/^[A-Za-z0-9._\-/=:]+$/.test(t))return t;return`'${t.replace(/'/g,"'\\''")}'`}class W{mode="local";id="local";async probe(){let t={},r=[["npm","command -v npm"],["node","command -v node"],["bun","command -v bun"],["vibe","command -v vibe"],["os","uname -s 2>/dev/null || echo unknown"],["arch","uname -m 2>/dev/null || echo unknown"]];for(let[n,o]of r){let i=await this.run(["sh","-c",o]),a=i.stdout.trim();if(i.code===0&&a)t[n]=a}return t}async run(t,r){let n=Bun.spawnSync(t,{stdout:"pipe",stderr:"pipe",timeout:r?.timeoutMs??600000});return{code:n.exitCode??1,stdout:n.stdout.toString(),stderr:n.stderr.toString()}}async upload(t,r,n){await Bun.write(t,r);try{let{chmodSync:o}=await import("fs");o(t,n??384)}catch{}}async close(){}}function We(t,r){let n=/^([a-z]+):\/\//.exec(t)?.[1];if(n==="local"||t.trim()==="local"||t.trim()==="localhost")return new W;if(!n||n==="ssh"){let o=tt(t);if(r?.identityFile)o.identityFile=r.identityFile;return new K(o)}throw Error(`Unsupported install transport scheme: ${n}://. Supported today: ssh:// (and bare host or ssh_config alias). Future: winrm://, ssm://, docker://, k8s://`)}var rt=/^[A-Za-z0-9._+-]+$/,nt=/^(?:@[a-z0-9][a-z0-9._-]{0,127}\/)?[a-z0-9][a-z0-9._-]{0,127}(?:@[A-Za-z0-9][A-Za-z0-9._+-]{0,127})?$/,it=/^\d+[smhdw]?$/,st=/^[a-z0-9:_-]{1,64}$/,pt=/[`$;&|<>'"\\]/,ft=/['"`$\s;|&<>()\\]/;function G(t){for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);if(n<=31||n===127)return!0}return!1}function ct(t){if(!t||t.length>128||t.startsWith("-")||!rt.test(t))throw Error(`Invalid agent version: ${t}`);return t}function ut(t){if(!t||t.length>2048||G(t)||ft.test(t))throw Error(`Invalid registry URL: ${t}`);let r;try{r=new URL(t)}catch{throw Error(`Invalid registry URL: ${t}`)}if(r.protocol!=="http:"&&r.protocol!=="https:"||!r.hostname)throw Error(`Invalid registry URL: ${t}`);return t}function lt(t){let r=t.trim();if(!r||r.includes("..")||!nt.test(r))throw Error(`Invalid plugin package name: ${t}`);return r}function gt(t){let r=t.trim();if(!r||r.length>16||!it.test(r))throw Error(`Invalid --expires-in value: ${t}`);return r}function Or(t){let r=t.split(",").map((n)=>n.trim()).filter(Boolean);if(r.length===0)throw Error(`Invalid --permissions value: ${t}`);for(let n of r)if(!st.test(n))throw Error(`Invalid --permissions value: ${t}`);return r.join(",")}function dt(t){let r=t.trim();if(!r||r.length>128||r.startsWith("-")||G(r)||pt.test(r))throw Error(`Invalid --label value: ${t}`);return r}function Ft(t,r){let n=ut(t),o=ct(r);return["sh","-c",'export PATH="$HOME/.bun/bin:$PATH"; npm_config_registry="$1" bun install -g @vibecontrols/agent@"$2" --no-cache',"_",n,o]}function Ot(t){return["sh","-c",'export PATH="$HOME/.bun/bin:$PATH"; vibe plugin install "$1"',"_",lt(t)]}function Bt(t){let r=dt(t.label),n=Or(t.scope),o=t.expiresIn?gt(t.expiresIn):void 0,i=[];if(t.json)i.push("--json");if(t.emitDefaultKey)i.push("--emit-default-key");let a=i.length>0?`${i.join(" ")} `:"";if(o)return["sh","-c",`export PATH="$HOME/.bun/bin:$PATH"; vibe peer-bootstrap ${a}--label "$1" --scope "$2" --expires-in "$3" 2>/dev/null`,"_",r,n,o];return["sh","-c",`export PATH="$HOME/.bun/bin:$PATH"; vibe peer-bootstrap ${a}--label "$1" --scope "$2" 2>/dev/null`,"_",r,n]}async function J(t,r,n){let o=`${t.tunnelUrl.replace(/\/$/,"")}${r}`;try{let i=await fetch(o,{method:n.method??"GET",headers:{"x-agent-api-key":t.apiKey,"content-type":n.body?"application/json":"application/octet-stream"},body:n.body?JSON.stringify(n.body):void 0,signal:AbortSignal.timeout(n.timeoutMs??30000)});if(i.status===200||i.status===201||i.status===204){let s=await i.json().catch(()=>{return});return{ok:!0,status:i.status,data:s}}let a=await i.text().catch(()=>"");return{ok:!1,status:i.status,error:a}}catch(i){return{ok:!1,status:0,error:i instanceof Error?i.message:String(i)}}}async function me(t,r,n={}){let o=Ve(t);if(!o)return{ok:!1,status:0,error:`No peer with id ${t}`};let i=await J(o,r,n);if(i.ok)return Ne(o.id,{lastReachable:new Date().toISOString()}),i;if(!(i.status===401||i.status===0||i.status===502||i.status===503||i.status===504))return i;if(!o.agentRecordId||!T.isConfigured())return i;let s=null;try{s=await T.lookupPeerAgent(o.agentRecordId,n.operation??"peer-call")}catch(d){e().logger.warn("peer-client","Backend rotation lookup failed",{peerId:t,error:d instanceof Error?d.message:String(d)})}if(!s)return i;Ne(o.id,{tunnelUrl:s.tunnelUrl,apiKey:s.apiKey});let l={...o,tunnelUrl:s.tunnelUrl,apiKey:s.apiKey};return{...await J(l,r,n),rotated:!0}}
|
|
17
|
+
export{He,qt,Ei,_i,er,yi,tr,Si,ot,te,re,ae,Ii,rr,Rr,Ji,ir,at,De,Ci,Ve,At,Fr,Ye,Ne,Rt,Ze,nr,Le,Je,We,ct,ut,lt,gt,Or,dt,Ft,Ot,Bt,me};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{r,E}from"./index-w0m3jm0s.js";import{oe,wt}from"./index-jnxjjx2y.js";import"./index-0qjbnyg4.js";import"./index-kwhx023z.js";import{s,A,l,o,g,n,F,v,H}from"./index-7f2k4g6q.js";import{Q}from"./index-vtsd74g0.js";import{_,y,u}from"./index-t5cfkz1e.js";import{f,m,S,q,Ce,Ae}from"./index-byerrz46.js";import{promises as b}from"fs";import P from"path";async function I(d){try{let i=await b.readdir(d);if(i.includes("package.json")){try{let t=JSON.parse(await b.readFile(P.join(d,"package.json"),"utf8")),e={...t.dependencies,...t.devDependencies};if(e.react||e["@types/react"])return"react";if(e.vue||e["@vue/cli"])return"vue";if(e.angular||e["@angular/core"])return"angular";if(e.next||e["@types/next"])return"nextjs";if(e.nuxt||e["@nuxt/core"])return"nuxtjs";if(e.svelte||e["@sveltejs/kit"])return"svelte";if(e.express||e.fastify||e.koa)return"nodejs-backend";if(e.electron)return"electron";if(e.vite)return"vite"}catch{}return"nodejs"}if(i.includes("setup.py")||i.includes("requirements.txt")||i.includes("pyproject.toml")||i.includes("Pipfile")){if(i.includes("manage.py"))return"django";if(i.includes("app.py"))return"flask";return"python"}if(i.includes("go.mod"))return"go";if(i.includes("Cargo.toml"))return"rust";if(i.includes("pom.xml"))return"maven";if(i.includes("build.gradle")||i.includes("build.gradle.kts"))return"gradle";if(i.includes("Gemfile"))return"ruby";if(i.includes("composer.json"))return"php";if(i.some((t)=>t.endsWith(".csproj")||t.endsWith(".sln")))return"dotnet";if(i.includes("CMakeLists.txt")||i.includes("Makefile"))return"cpp";if(i.includes("Package.swift"))return"swift";if(i.includes("pubspec.yaml"))return"flutter";if(i.some((t)=>t.endsWith(".tf")))return"terraform";if(i.includes("Dockerfile"))return"docker"}catch{}return}async function G(d){try{let i=["vite.config.ts","vite.config.js"];for(let t of i)try{let a=(await b.readFile(P.join(d,t),"utf-8")).match(/port:\s*(\d+)/);if(a)return parseInt(a[1],10)}catch{}}catch{}return}var O=new Set([".git","node_modules","__pycache__",".venv","venv","dist","build"]),N=parseInt(process.env.VIBECONTROLS_GIT_SCAN_MAX_DEPTH??"8",10),J=parseInt(process.env.VIBECONTROLS_GIT_SCAN_MAX_DIRECTORIES??"5000",10);async function C(d,i,t,e={visited:0},a=0){let R=[];if(a>N||e.visited>=J)return R;e.visited+=1;try{let c=await wt(d);if(c.some((p)=>p.name===".git"&&p.isDirectory())){if(R.push({path:d,name:P.basename(d),parentPath:t,isSubmodule:!!t,projectType:await I(d),vitePort:await G(d)}),!i)return R;t=d}for(let p of c)if(p.isDirectory()&&!p.isSymbolicLink()&&!O.has(p.name)&&!p.name.startsWith(".")){let j=P.join(d,p.name),x=await C(j,i,t,e,a+1);R.push(...x)}}catch{}return R}function T(d){let{db:i}=d;return new E().get("/",async()=>({repositories:await i.getAllGitRepositories()})).get("/:id",async({params:t,set:e})=>{let a=await i.getGitRepository(t.id);if(!a)return e.status=404,{error:"Repository not found"};return{repository:a}}).post("/scan",async({body:t,set:e})=>{try{let a=(await oe(t.directory,{mustExist:!0})).path;if(!(await b.stat(a)).isDirectory())return e.status=400,{error:"Path is not a directory"};let c=await C(a,t.includeSubmodules??!0),h=[];for(let p of c){let j=await i.getGitRepositoryByPath(p.path);if(j)await i.updateGitRepository(j.id,p),h.push({...j,...p});else{let x=await i.createGitRepository({id:globalThis.crypto.randomUUID(),...p});h.push(x)}}return{repositories:h,scannedPath:a,totalFound:h.length}}catch(a){return e.status=500,{error:"Failed to scan directory",details:String(a)}}},{body:r.Object({directory:r.String(),includeSubmodules:r.Optional(r.Boolean())})}).put("/:id",async({params:t,body:e,set:a})=>{if(!await i.getGitRepository(t.id))return a.status=404,{error:"Repository not found"};try{return await i.updateGitRepository(t.id,e),{success:!0}}catch(c){return a.status=500,{error:"Failed to update repository",details:String(c)}}},{body:r.Object({name:r.Optional(r.String()),projectType:r.Optional(r.String()),vitePort:r.Optional(r.Number())})}).delete("/:id",async({params:t,set:e})=>{if(!await i.getGitRepository(t.id))return e.status=404,{error:"Repository not found"};try{return await i.deleteGitRepository(t.id),{success:!0}}catch(R){return e.status=500,{error:"Failed to delete repository",details:String(R)}}}).post("/fix-hierarchy",async({set:t})=>{try{let e=await i.fixGitHierarchy(),a=await i.getAllGitRepositories();return{success:!0,fixed:e.fixed,total:a.length}}catch(e){return t.status=500,{error:"Failed to fix hierarchy",details:String(e)}}})}var w="http://localhost:3005";function k(d){let i=d.command("git").description("Manage git repositories");i.command("list").description("List discovered git repositories").option("--agent-url <url>","Agent URL",w).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(t){let e={...d.opts(),...t};try{let a=f(t),R=encodeURIComponent(m(e));await y({mode:_(e),fetchData:async()=>(await S(a,`/api/profiles/${R}/git`)).repositories||[],plain:(c)=>{if(!c||c.length===0){o("No git repositories found.");return}g("Git Repositories"),F(c.map((h)=>({ID:H(h.id),Name:h.name||"-",Path:h.path||"-",Type:h.type||h.projectType||"-",Submodule:h.isSubmodule?"Yes":"No",Scanned:h.scannedAt?v(h.scannedAt):"-"})))},interactive:async(c)=>{if(!c||c.length===0){g("Git Repositories"),o("No git repositories found.");return}let h=c.map((p)=>({id:String(p.id),label:p.name||H(p.id),hint:p.type||p.projectType||"",detail:[`ID: ${p.id}`,`Name: ${p.name??"-"}`,`Path: ${p.path??"-"}`,`Type: ${p.type??p.projectType??"-"}`,`Submodule: ${p.isSubmodule?"Yes":"No"}`,`Scanned: ${p.scannedAt?v(p.scannedAt):"-"}`].join(`
|
|
3
|
+
`)}));await Q({title:`vibe git list \u2014 ${c.length} repo(s)`,rows:h})},json:(c)=>c.map((h)=>({id:h.id,name:h.name??null,path:h.path??null,type:h.type??h.projectType??null,isSubmodule:!!h.isSubmodule,scannedAt:h.scannedAt??null}))})}catch(a){s(A(a))}}),i.command("scan").description("Scan a directory for git repositories").requiredOption("--dir <directory>","Directory to scan").option("--depth <depth>","Scan depth","3").option("--agent-url <url>","Agent URL",w).option("--json","Emit JSON").action(async function(t){let e={...d.opts(),...t};try{let a=f(t),R=encodeURIComponent(m(e)),c=await q(a,`/api/profiles/${R}/git/scan`,{directory:t.dir,depth:parseInt(t.depth,10)});if(u(e,{ok:!0,found:c?.found??c?.repositories?.length??0}))return;if(l("Git scan completed."),c?.found!==void 0)n("Repositories found",c.found);if(c?.repositories)n("Repositories found",c.repositories.length)}catch(a){if(e.json){u(e,{ok:!1,error:A(a)});return}s(A(a))}}),i.command("update").description("Update a git repository entry").requiredOption("-i, --id <id>","Repository ID").option("--vite-port <port>","Vite dev server port").option("--project-type <type>","Project type").option("--agent-url <url>","Agent URL",w).option("--json","Emit JSON").action(async function(t){let e={...d.opts(),...t};try{let a=f(t),R=encodeURIComponent(m(e)),c={};if(t.vitePort)c.vitePort=parseInt(t.vitePort,10);if(t.projectType)c.projectType=t.projectType;if(await Ce(a,`/api/profiles/${R}/git/${t.id}`,c),u(e,{ok:!0,id:t.id}))return;l(`Repository ${H(t.id)} updated.`)}catch(a){if(e.json){u(e,{ok:!1,error:A(a)});return}s(A(a))}}),i.command("delete").description("Delete a git repository entry").requiredOption("-i, --id <id>","Repository ID").option("--agent-url <url>","Agent URL",w).option("--json","Emit JSON").action(async function(t){let e={...d.opts(),...t};try{let a=f(t),R=encodeURIComponent(m(e));if(await Ae(a,`/api/profiles/${R}/git/${t.id}`),u(e,{ok:!0,id:t.id}))return;l(`Repository ${H(t.id)} deleted.`)}catch(a){if(e.json){u(e,{ok:!1,error:A(a)});return}s(A(a))}}),i.command("fix-hierarchy").description("Fix repository parent-child hierarchy").option("--agent-url <url>","Agent URL",w).option("--json","Emit JSON").action(async function(t){let e={...d.opts(),...t};try{let a=f(t),R=encodeURIComponent(m(e)),c=await q(a,`/api/profiles/${R}/git/fix-hierarchy`,{});if(u(e,{ok:!0,fixed:c?.fixed??null}))return;if(l("Hierarchy fix completed."),c?.fixed!==void 0)n("Fixed",c.fixed)}catch(a){if(e.json){u(e,{ok:!1,error:A(a)});return}s(A(a))}})}function D(d,i){k(d)}function te(d){return{name:"git",version:"2.2.0",description:"Git repository scanning, tracking, and hierarchy management",capabilities:{storage:"rw",subprocess:!0,audit:!0,telemetry:!0},tags:["backend","cli"],cliCommand:"git",apiPrefix:"/api/git",createRoutes:(i)=>T(i),onCliSetup:async(i,t)=>{D(i,t)}}}export{te as createPlugin};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{C,e}from"./index-0qjbnyg4.js";import{Dr,ve}from"./index-4z1y39jt.js";import{createHash as p,randomUUID as m}from"crypto";import{existsSync as l,mkdirSync as v,readFileSync as g,writeFileSync as b}from"fs";import{join as d}from"path";import*as o from"os";var y="https://analytics.burdenoff.com/api/track",T="cd7d5ccc3667",f=200,I=10,_=30000,E=5000;function u(t){if(process.env.DO_NOT_TRACK==="1")return!1;let i=process.env.VIBECONTROLS_TELEMETRY?.toLowerCase();if(i==="on"||i==="true"||i==="1")return!0;if(i==="off"||i==="false"||i==="0")return!1;return t}class h{enabled=!1;persisted=!1;buffer=[];flushTimer=null;cachedAnonymousId=null;overflowWarned=!1;postFailureWarned=!1;initialized=!1;init(t){if(t?.persisted!==void 0)this.persisted=t.persisted;if(this.enabled=u(this.persisted),!this.initialized)this.initialized=!0,this.startFlushTimer()}setEnabled(t){let i=this.enabled;if(this.persisted=t,this.enabled=u(this.persisted),i&&!this.enabled)this.buffer=[],this.enqueueRaw("telemetry.disabled",{reason:"user_opt_out"}),this.flush()}emit(t,i={}){if(!this.enabled)return;let r={},s=!1;for(let[a,c]of Object.entries(i)){if(Dr(a)){s=!0;continue}r[a]=c}let n=ve(t,r);if(!n.ok||!n.sanitized){e().logger.warn("telemetry",`dropping event '${t}': ${n.reason??"invalid"}`);return}this.enqueue(t,n.sanitized)}enqueueRaw(t,i){this.enqueue(t,i)}enqueue(t,i){let r={site_id:T,event_name:t,properties:i,anonymous_id:this.getAnonymousId(),timestamp:new Date().toISOString()};if(this.buffer.length>=f){if(this.buffer.shift(),!this.overflowWarned)this.overflowWarned=!0,e().logger.warn("telemetry",`buffer overflow (cap=${f}) \u2014 dropping oldest events`)}if(this.buffer.push(r),this.buffer.length>=I)this.flush()}async flush(){if(this.buffer.length===0)return;let t=this.buffer.splice(0,this.buffer.length),i=new AbortController,r=setTimeout(()=>i.abort(),E);try{await fetch(y,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:t}),signal:i.signal})}catch(s){if(!this.postFailureWarned)this.postFailureWarned=!0,e().logger.warn("telemetry","shipper POST failed; dropping batch",{error:String(s)})}finally{clearTimeout(r)}}stop(){if(this.flushTimer)clearInterval(this.flushTimer),this.flushTimer=null;this.initialized=!1}_resetForTest(){this.stop(),this.enabled=!1,this.persisted=!1,this.buffer=[],this.cachedAnonymousId=null,this.overflowWarned=!1,this.postFailureWarned=!1}_bufferLength(){return this.buffer.length}_isEnabled(){return this.enabled}startFlushTimer(){if(this.flushTimer)return;if(this.flushTimer=setInterval(()=>{this.flush()},_),typeof this.flushTimer.unref==="function")this.flushTimer.unref()}getAnonymousId(){if(this.cachedAnonymousId)return this.cachedAnonymousId;let t=`${o.hostname()}${o.platform()}`,i=this.readOrCreateInstallId(),r=p("sha256").update(t+i).digest("hex");return this.cachedAnonymousId=r.slice(0,16),this.cachedAnonymousId}readOrCreateInstallId(){let t;try{t=C()}catch{t=d(process.cwd(),".boff","vibecontrols")}if(!l(t))try{v(t,{recursive:!0,mode:448})}catch{}let i=d(t,".install-id");if(l(i))try{let s=g(i,"utf-8").trim();if(s)return s}catch{}let r=m();try{b(i,r,{mode:384})}catch{}return r}}var Z=new h;
|
|
3
|
+
export{Z};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import
|
|
4
|
-
`,{mode:384})}function
|
|
5
|
-
`,{mode:384}),
|
|
3
|
+
import"./index-w0m3jm0s.js";import{oi,Zt,mr,ai,Er}from"./index-4q8y6k1e.js";import"./index-3cbesatx.js";import{R,I,ee,C,e}from"./index-0qjbnyg4.js";import{_e}from"./index-3b5xejjs.js";import{qe,K}from"./index-mmx2kp76.js";import{J,ce,w,X,yt,ti}from"./index-kwhx023z.js";import"./index-5021rk8n.js";import"./index-qfxwk38p.js";import"./index-wr888ydc.js";import{Z}from"./index-ywnfz6nm.js";import"./index-tahaxp6n.js";import"./index-jnxjjx2y.js";import{Sr}from"./index-8rbhm4g8.js";import"./index-9bj65n3s.js";import"./index-06bmw4xf.js";import"./index-4z1y39jt.js";import"./index-byerrz46.js";async function G(t,i={}){let r=i.readConfig??(async()=>{let n=await X();return{clientId:n.clientId,clientSecret:n.clientSecret,workspaceId:n.workspaceId,organizationId:n.organizationId,globalGatewayUrl:n.globalGatewayUrl,workspaceGatewayUrl:n.workspaceGatewayUrl}});try{let n=i.pinned?.clientId&&i.pinned?.clientSecret?{clientId:i.pinned.clientId,clientSecret:i.pinned.clientSecret}:null,a=await r();if(!a.clientId||!a.clientSecret)return t;return{clientId:n?.clientId??a.clientId,clientSecret:n?.clientSecret??a.clientSecret,workspaceId:a.workspaceId??t.workspaceId,organizationId:a.organizationId??t.organizationId,globalGatewayUrl:a.globalGatewayUrl??t.globalGatewayUrl,workspaceGatewayUrl:a.workspaceGatewayUrl??t.workspaceGatewayUrl}}catch(n){let a=n instanceof Error?n.message:String(n);if(i.onReadError)i.onReadError(a);else e().logger.warn("finalize-retry","Could not re-read stored credentials; retrying with the boot-time pair",{error:a});return t}}import{isAbsolute as me}from"path";import{existsSync as y,mkdirSync as L,readFileSync as ne,readdirSync as B,renameSync as oe,unlinkSync as Re,writeFileSync as D}from"fs";import{dirname as V,join as v}from"path";var ie=".secrets-migrated-v1",se=["static-api-key","clientId","clientSecret"];function ae(t,i){return`${t}:${i}`}function z(){return v(C(),ie)}function le(){let t=z();L(V(t),{recursive:!0}),D(t,`${new Date().toISOString()}
|
|
4
|
+
`,{mode:384})}function ge(t){if(!y(t))return null;try{let i=ne(t,"utf8"),r=JSON.parse(i);if(r&&typeof r==="object"&&!Array.isArray(r))return r}catch{}return null}function pe(t,i){L(V(t),{recursive:!0});let r=`${t}.${process.pid}.tmp`;D(r,`${JSON.stringify(i,null,2)}
|
|
5
|
+
`,{mode:384}),oe(r,t)}function de(){let t=C(),i=v(t,"agents");if(!y(i))return[];let r=[],n;try{n=B(i)}catch{return[]}for(let a of n){let l=v(i,a,"config.json");if(!y(l))continue;r.push({path:l,scope:a})}return r}function ue(){let t=C(),i=v(t,"profiles");if(!y(i))return[];let r=[],n;try{n=B(i)}catch{return[]}for(let a of n){if(!a.endsWith(".json"))continue;r.push({path:v(i,a),scope:a.slice(0,-5)})}return r}async function fe(t,i){let r=ge(t);if(!r)return 0;let n=0;for(let a of se){let l=r[a];if(typeof l!=="string"||l.length===0)continue;let p=ae(i,a);try{await ce(p,l),delete r[a],n++,e().logger.info("secrets-migrator","migrated field",{path:t,scope:i,key:a})}catch(d){e().logger.warn("secrets-migrator","failed to migrate field",{path:t,scope:i,key:a,error:String(d)})}}if(n>0)pe(t,r);return n}async function F(){let t={alreadyMigrated:!1,fieldsMoved:0,filesUpdated:0};if(y(z()))return t.alreadyMigrated=!0,t;let i=[...de(),...ue()];for(let r of i){let n;try{n=await fe(r.path,r.scope)}catch(a){e().logger.warn("secrets-migrator","skipping target after error",{path:r.path,error:String(a)});continue}if(n>0)t.fieldsMoved+=n,t.filesUpdated++}try{le()}catch(r){e().logger.warn("secrets-migrator","failed to drop migration marker",{error:String(r)})}if(t.fieldsMoved>0)e().logger.info("secrets-migrator","migration complete",{fieldsMoved:t.fieldsMoved,filesUpdated:t.filesUpdated});return t}{let t=JSON.parse.bind(JSON);JSON.parse=(n,a)=>{try{return t(n,a)}catch(l){if(typeof n==="string"&&n.endsWith("}}"))try{return t(n.slice(0,-1),a)}catch{}throw l}};let r=globalThis.Request?.prototype;if(r&&typeof r.json==="function"){let n=r.json;r.json=async function(){let l=await this.text();if(!l)return;try{return t(l)}catch{if(l.endsWith("}}"))try{return t(l.slice(0,-1))}catch{}let p=new Request("http://shim/",{method:"POST",body:l});return n.call(p)}}}}Sr();yt();if(!process.env.VIBECONTROLS_DATA_DIR)process.env.VIBECONTROLS_DATA_DIR=I();if(typeof Bun>"u")console.error("ERROR: VibeControls Agent requires Bun runtime."),console.error("Install Bun: https://bun.sh"),process.exit(1);function ye(t){if(t==="default")return 3005;let i=2166136261;for(let r=0;r<t.length;r++)i=Math.imul(i^t.charCodeAt(r),16777619);return 3100+Math.abs(i)%300}var b=(()=>{try{return R()}catch{return"default"}})(),T=Number.parseInt(process.env.PORT||String(ye(b)),10),_=Number.isInteger(T)&&T>0?T:3005,A=process.env.HOST||"0.0.0.0",we=(()=>{let t=process.env.DB_PATH;if(!t)return;if(me(t))return t;console.warn(`[boot] Ignoring relative DB_PATH=${t} (cwd=${process.cwd()}). Use an absolute path or unset to fall back to ${ee()}.`);return})(),P=process.env.AGENT_API_KEY||void 0,ve=process.env.LOG_LEVEL||"info",he=process.env.CORS_ORIGIN||void 0;async function Se(){try{await F()}catch(s){e().logger.warn("server","secrets migration encountered an error",{error:String(s)})}let t=w()["static-api-key"],i=(()=>{try{return R()}catch{return"default"}})(),r=t??await J(`${i}:static-api-key`),n=!P&&!r;await qe();let a={clientId:process.env.VIBE_CLIENT_ID,clientSecret:process.env.VIBE_CLIENT_SECRET};await ti();let l=process.env.VIBE_CLIENT_ID,p=process.env.VIBE_CLIENT_SECRET,d=process.env.VIBE_GLOBAL_GATEWAY_URL,N=process.env.VIBE_WORKSPACE_GATEWAY_URL,M=process.env.VIBE_WORKSPACE_ID,x=!!l&&!!p&&!!d&&!!N&&!!M;e().logger.info("server","Starting VibeControls Agent...",{runtime:"bun",bunVersion:Bun.version,port:_,host:A,env:"production"});try{let s=w(),o=s["telemetry.enabled"]===!0||s["telemetry.enabled"]==="true";Z.init({persisted:o});let c=Date.now();Z.emit("agent.started",{version:process.env.npm_package_version??"unknown",profile:b,platform:process.platform}),process.__vibe_started_at=c}catch{}let h=Math.max(1,Number.parseInt(process.env.VIBECONTROLS_AGENT_BOOT_RETRIES??"10",10)||10),W=(s)=>{let o=String(s?.message??s).toLowerCase();return o.includes("syntax")||o.includes("cannot find module")||o.includes("module not found")||o.includes("typeerror")||o.includes("config schema")||o.includes("invalid config")||o.includes("corrupt")||o.includes("eaccess")||o.includes("eperm")},g=null,u=0;while(!g){u++;try{g=await Er({port:_,host:A,dbPath:we,apiKey:P,logLevel:ve,corsOrigin:he}),await g.start();try{let s=await import("fs"),o=`${I()}/runtime.json`;s.writeFileSync(o,JSON.stringify({pid:process.pid,port:_,host:A,profile:b,startedAt:new Date().toISOString(),version:_e()},null,2));let c=()=>{try{if(s.existsSync(o))s.unlinkSync(o)}catch{}};process.once("SIGTERM",c),process.once("SIGINT",c),process.once("exit",c)}catch(s){e().logger.warn("server","Could not write runtime.json",{error:String(s)})}}catch(s){let o=W(s);if(e().logger.error("server","Failed to start agent server",{attempt:u,maxBootAttempts:h,fatal:o,error:String(s)}),o||u>=h)console.error(`\u274C Failed to start VibeControls Agent (attempt ${u}/${h}, fatal=${o}):`,s),process.exit(1);let c=Math.min(30000,1000*2**Math.min(5,u-1)),m=Math.floor(Math.random()*500),S=c+m;console.warn(`\u26A0\uFE0F Agent boot attempt ${u}/${h} failed (transient), retrying in ${Math.round(S/1000)}s...`),await new Promise((k)=>setTimeout(k,S)),g=null}}let O=g.getServiceRegistry().getProvider("tunnel"),f=null;if(O?.getActiveTunnelUrl)for(let s=0;s<30;s++){if(f=await O.getActiveTunnelUrl(),f)break;await new Promise((o)=>setTimeout(o,1000))}if(!f){let{sanitizeEnvSuffix:s}=await import("./tunnel-bootstrap-rym0b0x5.js"),{getVibecontrolsProfile:o}=await import("./path-utils-r4df8d3w.js"),c=s(o());f=process.env[`AGENT_TUNNEL_URL_${c}`]??process.env.AGENT_TUNNEL_URL??null}let j=w(),q=P||K()||j["static-api-key"]||"",E=e().getBootState(),Y=E==="ready"?null:oi();if(E==="ready")Zt();Ie({port:_,host:A,tunnelUrl:f,apiKey:q,revealApiKey:n||process.env.AGENT_PRINT_API_KEY==="1",state:E,pairingToken:Y});try{mr({profile:b})}catch(s){e().logger.warn("server","Could not start autoupdate",{error:String(s)})}let{existsSync:H,unlinkSync:Q}=await import("fs"),{tmpdir:te}=await import("os"),{join:re}=await import("path"),U=async(s)=>{e().logger.info("server",`Received ${s}, shutting down...`),ai();try{let c=process.__vibe_started_at??Date.now();Z.emit("agent.stopped",{uptime_s:Math.round((Date.now()-c)/1000),reason:s}),await Z.flush(),Z.stop()}catch{}let o=g.getLifecycle();if(s==="SIGTERM"){let c=re(te(),`.boff-vibecontrols-kill-${process.pid}`);if(H(c)){try{Q(c)}catch{}if(e().logger.info("server","Kill-intent flag detected \u2014 full shutdown"),o)await o.kill();else await g.stop({reason:"shutdown"}),process.exit(0)}else if(e().logger.info("server","No kill flag \u2014 treating as hot-reload (soft stop)"),o)await o.softStop();else await g.stop({reason:"reload"})}else if(o)await o.kill();else await g.stop({reason:"shutdown"}),process.exit(0)};if(process.on("SIGINT",()=>U("SIGINT")),process.on("SIGTERM",()=>U("SIGTERM")),x){let s=(()=>{let o=process.env.VIBECONTROLS_FINALIZE_TIMEOUT_MS,c=o?Number.parseInt(o,10):NaN;return Number.isFinite(c)&&c>0?c:300000})();e().logger.info("server",`VIBE_* env vars detected \u2014 running inline finalize (timeout ${Math.round(s/1000)}s)`),(async()=>{let o={clientId:l,clientSecret:p,workspaceId:M,globalGatewayUrl:d,workspaceGatewayUrl:N};try{let c=await Promise.race([g.finalize(o),new Promise((m)=>setTimeout(()=>m({ok:!1,error:`inline finalize timed out after ${Math.round(s/1000)}s`}),s))]);if(!c.ok){e().logger.warn("server","Inline finalize failed \u2014 agent stays awaiting-config. Background retry worker will keep trying.",{error:c.error});let{startFinalizeRetryWorker:m}=await import("./finalize-retry-worker-az74f2qv.js"),{setFinalizeRetryHandle:S}=await import("./finalize-retry-handle-registry-z9mbbjmj.js"),k=m({trigger:async()=>g.finalize(await G(o,{pinned:a}))});S(k)}}catch(c){e().logger.error("server","Inline finalize threw",{error:String(c)})}})()}else e().logger.info("server","Agent is awaiting gateway credentials. Add it on the VibeControls platform using the tunnel URL and API key shown above.")}function Ie(t){let r=(d)=>("\u2551 "+d).padEnd(65)+"\u2551",n="\u2560"+"\u2550".repeat(64)+"\u2563",a="\u2554"+"\u2550".repeat(64)+"\u2557",l="\u255A"+"\u2550".repeat(64)+"\u255D",p=t.revealApiKey?t.apiKey:t.apiKey?`${t.apiKey.substring(0,8)}****${t.apiKey.substring(t.apiKey.length-4)}`:"(none)";if(console.log(""),console.log(a),console.log(r("VibeControls Agent")),console.log(n),console.log(r(`State: ${t.state}`)),console.log(r(`Agent URL: http://${t.host}:${t.port}`)),console.log(r(`API Key: ${p}`)),console.log(r(`Tunnel URL: ${t.tunnelUrl??"(none)"}`)),t.pairingToken)console.log(r(`Pairing: ${t.pairingToken}`)),console.log(r(" (send as x-pairing-token on bootstrap)"));if(console.log(n),console.log(r(`Health: http://localhost:${t.port}/health`)),console.log(r(`Status: http://localhost:${t.port}/api/agent/status`)),console.log(l),!t.revealApiKey)console.log(" (Set AGENT_PRINT_API_KEY=1 to print the API key in full.)");console.log("")}Se();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{pt,Wi,vr}from"./index-qfxwk38p.js";import"./index-mmx2kp76.js";import"./index-5021rk8n.js";import"./index-w0m3jm0s.js";import"./index-kwhx023z.js";import"./index-0qjbnyg4.js";export{vr as dispatchProfileRequest,pt as mountProfileRoutes,Wi as unmountProfileRoutes};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wr}from"./index-m942hydk.js";import"./index-cy97asyh.js";import"./index-0gmhd3hs.js";import"./index-652f9scs.js";import"./index-wr888ydc.js";import"./index-9bj65n3s.js";import"./index-3b5xejjs.js";import"./index-ywnfz6nm.js";import"./index-4z1y39jt.js";import"./index-mmx2kp76.js";import"./index-5021rk8n.js";import"./index-w0m3jm0s.js";import"./index-t5cfkz1e.js";import"./index-7f2k4g6q.js";import"./index-vtsd74g0.js";import"./index-byerrz46.js";import"./index-kwhx023z.js";import"./index-0qjbnyg4.js";export{wr as registerCoreCommands};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ai}from"./index-3cbesatx.js";import"./index-06bmw4xf.js";import"./index-3b5xejjs.js";import"./index-qfxwk38p.js";import"./index-mmx2kp76.js";import"./index-5021rk8n.js";import"./index-w0m3jm0s.js";import"./index-kwhx023z.js";import"./index-0qjbnyg4.js";export{Ai as attachSecondaryProfile};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{rr,Rr,Ji,ir,at}from"./index-wr888ydc.js";import"./index-ywnfz6nm.js";import"./index-4z1y39jt.js";import"./index-0qjbnyg4.js";export{at as getBootstrapTunnelUrl,rr as sanitizeEnvSuffix,Rr as startBootstrapTunnel,ir as stopBootstrapTunnel,Ji as tryHandoverBootstrapTunnel};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibecontrols/agent",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1124.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -50,39 +50,40 @@
|
|
|
50
50
|
},
|
|
51
51
|
"license": "SEE LICENSE IN LICENSE",
|
|
52
52
|
"description": "VibeControls Agent CLI - Remote development environment management with terminal multiplexing, tunnels, and extensible plugins. Powered by Bun + Elysia.",
|
|
53
|
+
"packageManager": "bun@1.4.4",
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"@elysiajs/cors": "^1.3.1",
|
|
55
56
|
"@opentelemetry/api": "^1.9.0",
|
|
56
57
|
"@opentelemetry/exporter-prometheus": "^0.217.0",
|
|
57
|
-
"@opentelemetry/sdk-metrics": "^
|
|
58
|
+
"@opentelemetry/sdk-metrics": "^3.0.0",
|
|
58
59
|
"@opentui/core": "0.2.8",
|
|
59
|
-
"@vibecontrols/plugin-sdk": "2026.
|
|
60
|
+
"@vibecontrols/plugin-sdk": "2026.1124.1",
|
|
60
61
|
"@vibecontrols/vibe-plugin-storage": "2026.601.1",
|
|
61
|
-
"commander": "^
|
|
62
|
+
"commander": "^15.0.0",
|
|
62
63
|
"elysia": "^1.3.2"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
|
-
"@eslint/js": "^
|
|
66
|
+
"@eslint/js": "^9.39.5",
|
|
66
67
|
"@playwright/test": "1.59.1",
|
|
67
68
|
"@types/bun": "^1.3.9",
|
|
68
69
|
"@vibecontrols/vibe-plugin-ai": "2026.601.1",
|
|
69
70
|
"@vibecontrols/vibe-plugin-session-manager": "2026.608.1",
|
|
70
71
|
"@vibecontrols/vibe-plugin-tunnel": "2026.601.1",
|
|
71
|
-
"eslint": "^
|
|
72
|
+
"eslint": "^9.39.5",
|
|
72
73
|
"globals": "^17.3.0",
|
|
73
74
|
"knip": "6.12.0",
|
|
74
75
|
"lefthook": "2.1.4",
|
|
75
76
|
"prettier": "^3.8.1",
|
|
76
77
|
"rimraf": "^6.1.3",
|
|
77
|
-
"typescript": "
|
|
78
|
+
"typescript": "6.0.3",
|
|
78
79
|
"typescript-eslint": "^8.56.0"
|
|
79
80
|
},
|
|
80
81
|
"repository": {
|
|
81
82
|
"type": "git",
|
|
82
|
-
"url": "git+https://github.com/
|
|
83
|
+
"url": "git+https://github.com/Algoshred/vibecontrols-agent.git"
|
|
83
84
|
},
|
|
84
85
|
"bugs": {
|
|
85
|
-
"url": "https://github.com/
|
|
86
|
+
"url": "https://github.com/Algoshred/vibecontrols-agent/issues"
|
|
86
87
|
},
|
|
87
88
|
"homepage": "https://vibecontrols.com",
|
|
88
89
|
"publishConfig": {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$c as b,Ad as C,Bd as D,Cd as E,Dd as F,Ed as G,Fd as H,Gd as I,Hd as J,Id as K,_c as a,ad as c,bd as d,cd as e,dd as f,ed as g,fd as h,gd as i,hd as j,id as k,jd as l,kd as m,ld as n,md as o,nd as p,od as q,pd as r,qd as s,rd as t,sd as u,td as v,ud as w,vd as x,wd as y,xd as z,yd as A,zd as B}from"./index-2q2jadag.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{n as writeProfile,y as writeAgentConfigAwaitSecrets,x as writeAgentConfig,j as writeActiveProfileName,D as resolvePriorIdentity,m as readProfileStrict,l as readProfile,z as readAgentConfigWithSecrets,v as readAgentConfig,i as readActiveProfileName,A as readActiveProfile,k as listProfileNames,f as getProfilesDir,h as getProfilePath,r as getProductionGatewayUrls,w as getOrCreateAgentInstanceId,H as getEnvPinnedGateways,u as getAgentConfigSeed,s as getAgentConfigPath,t as getAgentConfigDefaults,g as getActiveProfilePointerPath,B as gatewayOriginOf,q as ensureProfilesInitialized,F as describeProfileEnvironmentConflict,G as describeGatewayIdentityMismatch,E as describeGatewayIdentityConflict,o as deleteProfile,p as buildProfileSeed,C as buildPairedIdentity,e as assertValidProfileName,K as applyAgentSecretsToEnv,J as applyAgentConfigToEnv,I as __resetEnvPinnedGatewaysForTests,c as NAMED_ENV_PRESETS,d as DEFAULT_PROFILE_NAME,a as CURRENT_CONFIG_SCHEMA_VERSION,b as BUILTIN_PROFILE_SEEDS};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ac as y,Bc as V,sc as G,zc as f}from"./index-8xh8m2z7.js";import"./index-xjr60th0.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};
|
package/dist/app-mhms2gs0.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{n as a}from"./index-f2asckf0.js";import"./index-hrfkzecw.js";import"./index-dx9hjdp4.js";import"./index-6jzsthh9.js";import"./index-qdbxvcwr.js";import"./index-xtbppqnv.js";import"./index-29fmptfn.js";import"./index-w7gctzhm.js";import"./index-hey6w5m0.js";import"./index-7wejfjj9.js";import"./index-ea42kfvk.js";import"./index-rmh8pff5.js";import"./index-x4eaagvr.js";import"./index-ekr40gvh.js";import"./index-3p4n7nwg.js";import"./index-vnxqna70.js";import"./index-bv1z3fxw.js";import"./index-jbxh0ffn.js";import"./index-kteawn2b.js";import"./index-2q2jadag.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as createApp};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{K as a,L as b,M as c,N as d}from"./index-y42xsgr6.js";import"./index-ea42kfvk.js";import"./index-8q19ryt2.js";import"./index-wj5hx7gq.js";import"./index-8xh8m2z7.js";import"./index-js2r0men.js";import"./index-kteawn2b.js";import"./index-2q2jadag.js";import"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{d as register,a as generateSystemdUnit,b as generateLaunchdPlist,c as ensureAutostartConfigured};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Wd as K,ae as D}from"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.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 $(J,Q,Z){D().logger[J](b,Q,Z)}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 Z=process.env.VIBE_BRIDGE_URL;if(Z)return Z;return Q.toString()}catch{return process.env.VIBE_BRIDGE_URL??""}}async function x(){if(z.stopped||z.ws)return;if(!K.isConfigured()){$("debug","Gateway client not configured yet; deferring bridge connect");return}if(!z.agentId){$("debug","No agentId set yet; deferring bridge connect");return}let J,Q,Z;try{let Y=await K.getAccessToken();J=Y.token,Q=Y.workspaceGatewayUrl,Z=Y.workspaceId}catch(Y){$("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){$("warn","Cannot resolve bridge URL from workspaceGatewayUrl",{workspaceGatewayUrl:Q}),W();return}$("info","Connecting to agent-bridge",{url:q,agentId:z.agentId});let H;try{H=new WebSocket(q,{headers:{Authorization:`Bearer ${J}`,...Z?{"x-workspace-id":Z}:{}}})}catch(Y){$("warn","Bridge connect threw",{error:Y instanceof Error?Y.message:String(Y)}),W();return}z.ws=H,H.addEventListener("open",()=>{z.reconnectAttempt=0,$("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,$("info","Bridge welcome received \u2014 connection ready",{workspaceId:typeof V.workspaceId==="string"?V.workspaceId:void 0}),L(),P();else if(V.type==="error")$("warn","Bridge error frame",{error:V})}),H.addEventListener("close",(Y)=>{if($("info","Bridge socket closed",{code:Y.code,reason:Y.reason}),M(),!z.stopped)W()}),H.addEventListener("error",(Y)=>{$("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 $("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)$("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().catch((Z)=>{$("debug",`Bridge reconnect attempt failed: ${Z instanceof Error?Z.message:String(Z)}`)})},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().catch((Z)=>{$("debug",`Bridge connect failed: ${Z instanceof Error?Z.message:String(Z)}`)})},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};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$d as b,_d as a,ae as c,be as d,ce as e}from"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.js";export{a as profileRegistry,d as getOrCreateProfile,c as getDaemonProfile,b as ensureDaemonProfile,e as __resetDaemonProfileForTests};
|
package/dist/esm-n9r8p5n2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ac as a,bc as b,cc as c,dc as d,ec as e,fc as f,gc as g,hc as h,ic as i,jc as j,kc as k}from"./index-8q19ryt2.js";import"./index-xjr60th0.js";export{a as program,d as createOption,b as createCommand,c as createArgument,j as Option,g as InvalidOptionArgumentError,f as InvalidArgumentError,k as Help,e as CommanderError,h as Command,i as Argument};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ae as Y}from"./index-qqq9qyy6.js";import"./index-gz5t0vvc.js";import"./index-mbhq916m.js";import"./index-xjr60th0.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 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{f as D}from"./index-3tf12pw3.js";import{g as C}from"./index-hp8jrj6j.js";import{ue as z,we as B}from"./index-xjr60th0.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 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{f as D}from"./index-3tf12pw3.js";import{g as C}from"./index-hp8jrj6j.js";import{ue as B}from"./index-xjr60th0.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
|
-
`).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 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{g as B}from"./index-hp8jrj6j.js";import{ue as z,we as A}from"./index-xjr60th0.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 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{g as q}from"./index-hp8jrj6j.js";import{ue as k}from"./index-xjr60th0.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 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{f as E}from"./index-3tf12pw3.js";import{g as D}from"./index-hp8jrj6j.js";import{ue as B,we as C}from"./index-xjr60th0.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();
|
package/dist/index-06es0fmw.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{a as P,b as S,c as v}from"./index-b16y8wyz.js";import{g as M}from"./index-hp8jrj6j.js";import{ue as z,we as E}from"./index-xjr60th0.js";var I=z((_)=>{Object.defineProperty(_,"__esModule",{value:!0});_.PrometheusSerializer=void 0;var b=M(),H=v(),T=S(),y=P(),h="otel.scope.schema_url";function C(F){return F.replace(/\\/g,"\\\\").replace(/\n/g,"\\n")}function k(F=""){if(typeof F!=="string")F=JSON.stringify(F);return C(F).replace(/"/g,"\\\"")}var d=/[^a-z0-9_]/gi,l=/_{2,}/g;function w(F){return F.replace(d,"_").replace(l,"_")}function p(F,J){if(!F.endsWith("_total")&&J.dataPointType===H.DataPointType.SUM&&J.isMonotonic)F=F+"_total";return F}function u(F){if(F===1/0)return"+Inf";else if(F===-1/0)return"-Inf";else return`${F}`}function m(F){switch(F.dataPointType){case H.DataPointType.SUM:if(F.isMonotonic)return"counter";return"gauge";case H.DataPointType.GAUGE:return"gauge";case H.DataPointType.HISTOGRAM:return"histogram";default:return"untyped"}}function B(F,J,K,Q,V){let W=!1,X="";for(let[Y,$]of Object.entries(J)){let Z=w(Y);W=!0,X+=`${X.length>0?",":""}${Z}="${k($)}"`}if(V)for(let[Y,$]of Object.entries(V)){let Z=w(Y);W=!0,X+=`${X.length>0?",":""}${Z}="${k($)}"`}if(W)F+=`{${X}}`;return`${F} ${u(K)}${Q!==void 0?" "+String(Q):""}
|
|
3
|
-
`}var c="# no registered metrics";class A{_prefix;_appendTimestamp;_additionalAttributes;_withResourceConstantLabels;_withoutScopeInfo;_withoutTargetInfo;constructor(F,J=!1,K,Q,V){if(F)this._prefix=F+"_";this._appendTimestamp=J,this._withResourceConstantLabels=K,this._withoutScopeInfo=!!V,this._withoutTargetInfo=!!Q}serialize(F){let J="";this._additionalAttributes=this._filterResourceConstantLabels(F.resource.attributes,this._withResourceConstantLabels);for(let K of F.scopeMetrics)J+=this._serializeScopeMetrics(K);if(J==="")J+=c;return this._serializeResource(F.resource)+J}_filterResourceConstantLabels(F,J){if(J){let K={};for(let[Q,V]of Object.entries(F))if(Q.match(J))K[Q]=V;return K}return}_serializeScopeMetrics(F){let J="";for(let K of F.metrics)J+=this._serializeMetricData(K,F.scope)+`
|
|
4
|
-
`;return J}_serializeMetricData(F,J){let K=w(C(F.descriptor.name));if(this._prefix)K=`${this._prefix}${K}`;let Q=F.dataPointType;K=p(K,F);let V=`# HELP ${K} ${C(F.descriptor.description||"description missing")}`,W=F.descriptor.unit?`
|
|
5
|
-
# UNIT ${K} ${C(F.descriptor.unit)}`:"",X=`# TYPE ${K} ${m(F)}`,Y;if(this._withoutScopeInfo)Y=this._additionalAttributes;else{let Z={[y.ATTR_OTEL_SCOPE_NAME]:J.name};if(J.schemaUrl)Z[h]=J.schemaUrl;if(J.version)Z[y.ATTR_OTEL_SCOPE_VERSION]=J.version;Y=Object.assign(Z,this._additionalAttributes)}let $="";switch(Q){case H.DataPointType.SUM:case H.DataPointType.GAUGE:{$=F.dataPoints.map((Z)=>this._serializeSingularDataPoint(K,F,Z,Y)).join("");break}case H.DataPointType.HISTOGRAM:{$=F.dataPoints.map((Z)=>this._serializeHistogramDataPoint(K,F,Z,Y)).join("");break}default:b.diag.error(`Unrecognizable DataPointType: ${Q} for metric "${K}"`)}return`${V}${W}
|
|
6
|
-
${X}
|
|
7
|
-
${$}`.trim()}_serializeSingularDataPoint(F,J,K,Q){let V="",{value:W,attributes:X}=K,Y=(0,T.hrTimeToMilliseconds)(K.endTime);return V+=B(F,X,W,this._appendTimestamp?Y:void 0,Q),V}_serializeHistogramDataPoint(F,J,K,Q){let V="",W=K.attributes,X=K.value,Y=(0,T.hrTimeToMilliseconds)(K.endTime);for(let j of["count","sum"]){let q=X[j];if(q!=null)V+=B(F+"_"+j,W,q,this._appendTimestamp?Y:void 0,Q)}let $=0,Z=X.buckets.counts.entries(),R=!1;for(let[j,q]of Z){$+=q;let O=X.buckets.boundaries[j];if(O===void 0&&R)break;if(O===1/0)R=!0;V+=B(F+"_bucket",W,$,this._appendTimestamp?Y:void 0,Object.assign({},Q,{le:O===void 0||O===1/0?"+Inf":String(O)}))}return V}_serializeResource(F){if(this._withoutTargetInfo===!0)return"";let J="target_info",K=`# HELP ${J} Target metadata`,Q=`# TYPE ${J} gauge`,V=B(J,F.attributes,1).trim();return`${K}
|
|
8
|
-
${Q}
|
|
9
|
-
${V}
|
|
10
|
-
`}}_.PrometheusSerializer=A});var f=z((g)=>{Object.defineProperty(g,"__esModule",{value:!0});g.PrometheusExporter=void 0;var U=M(),n=S(),N=v(),o=E("http"),i=I(),s=E("url");class G extends N.MetricReader{static DEFAULT_OPTIONS={host:void 0,port:9464,endpoint:"/metrics",prefix:"",appendTimestamp:!1,withResourceConstantLabels:void 0,withoutScopeInfo:!1,withoutTargetInfo:!1};_host;_port;_baseUrl;_endpoint;_server;_prefix;_appendTimestamp;_serializer;_startServerPromise;constructor(F={},J=()=>{}){super({aggregationSelector:(W)=>{return{type:N.AggregationType.DEFAULT}},aggregationTemporalitySelector:(W)=>N.AggregationTemporality.CUMULATIVE,metricProducers:F.metricProducers});this._host=F.host||process.env.OTEL_EXPORTER_PROMETHEUS_HOST||G.DEFAULT_OPTIONS.host,this._port=F.port||Number(process.env.OTEL_EXPORTER_PROMETHEUS_PORT)||G.DEFAULT_OPTIONS.port,this._prefix=F.prefix||G.DEFAULT_OPTIONS.prefix,this._appendTimestamp=typeof F.appendTimestamp==="boolean"?F.appendTimestamp:G.DEFAULT_OPTIONS.appendTimestamp;let K=F.withResourceConstantLabels||G.DEFAULT_OPTIONS.withResourceConstantLabels,Q=F.withoutScopeInfo||G.DEFAULT_OPTIONS.withoutScopeInfo,V=F.withoutTargetInfo||G.DEFAULT_OPTIONS.withoutTargetInfo;if(this._server=(0,o.createServer)(this._requestHandler).unref(),this._serializer=new i.PrometheusSerializer(this._prefix,this._appendTimestamp,K,V,Q),this._baseUrl=`http://${this._host}:${this._port}/`,this._endpoint=(F.endpoint||G.DEFAULT_OPTIONS.endpoint).replace(/^([^/])/,"/$1"),F.preventServerStart!==!0)this.startServer().then(J,(W)=>{U.diag.error(W),J(W)});else if(J)queueMicrotask(J)}async onForceFlush(){}onShutdown(){return this.stopServer()}stopServer(){if(!this._server)return U.diag.debug("Prometheus stopServer() was called but server was never started."),Promise.resolve();else return new Promise((F)=>{this._server.close((J)=>{if(!J)U.diag.debug("Prometheus exporter was stopped");else if(J.code!=="ERR_SERVER_NOT_RUNNING")(0,n.globalErrorHandler)(J);F()})})}startServer(){return this._startServerPromise??=new Promise((F,J)=>{this._server.once("error",J),this._server.listen({port:this._port,host:this._host},()=>{U.diag.debug(`Prometheus exporter server started: ${this._host}:${this._port}/${this._endpoint}`),F()})}),this._startServerPromise}getMetricsRequestHandler(F,J){this._exportMetrics(J)}_requestHandler=(F,J)=>{let K;try{if(F.url!=null)K=new s.URL(F.url,this._baseUrl).pathname}catch{J.statusCode=400,J.end("Bad Request");return}if(K===this._endpoint)this._exportMetrics(J);else this._notFound(J)};_exportMetrics=(F)=>{F.statusCode=200,F.setHeader("content-type","text/plain"),this.collect().then((J)=>{let{resourceMetrics:K,errors:Q}=J;if(Q.length)U.diag.error("PrometheusExporter: metrics collection errors",...Q);F.end(this._serializer.serialize(K))},(J)=>{F.end(`# failed to export metrics: ${J}`)})};_notFound=(F)=>{F.statusCode=404,F.end()}}g.PrometheusExporter=G});var e=z((L)=>{Object.defineProperty(L,"__esModule",{value:!0});L.PrometheusSerializer=L.PrometheusExporter=void 0;var a=f();Object.defineProperty(L,"PrometheusExporter",{enumerable:!0,get:function(){return a.PrometheusExporter}});var r=I();Object.defineProperty(L,"PrometheusSerializer",{enumerable:!0,get:function(){return r.PrometheusSerializer}})});export default e();
|