@vibecontrols/agent 2026.1125.2 → 2026.1127.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-config-xwvsmn6b.js +2 -0
- package/dist/{agent-ready-tracker-mewxehg9.js → agent-ready-tracker-7ebr09d9.js} +1 -1
- package/dist/app-1dqn9qaw.js +2 -0
- package/dist/autostart.cmd-mdyv35dn.js +2 -0
- package/dist/bootstrap-workspace-1pt0bwy6.js +2 -0
- package/dist/bootstrap.service-gehm65tt.js +2 -0
- package/dist/bridge-client-9ax1cvj6.js +2 -0
- package/dist/bridge-commands-6dj7ewgx.js +2 -0
- package/dist/cli.js +2 -2
- package/dist/daemon-profile-fnhc7pcf.js +2 -0
- package/dist/{finalize-retry-worker-az74f2qv.js → finalize-retry-worker-c38km3mt.js} +1 -1
- package/dist/gateway-client-3zp6kkav.js +2 -0
- package/dist/{getMachineId-bsd-4w1wmcjv.js → getMachineId-bsd-qjqk66se.js} +1 -1
- package/dist/{getMachineId-darwin-kejwz8w5.js → getMachineId-darwin-tqhg8pqb.js} +1 -1
- package/dist/{getMachineId-linux-mpm53wat.js → getMachineId-linux-ygfapc26.js} +1 -1
- package/dist/{getMachineId-unsupported-54seyw5v.js → getMachineId-unsupported-87w3cred.js} +1 -1
- package/dist/{getMachineId-win-cva7ghz9.js → getMachineId-win-jrtkq63e.js} +1 -1
- package/dist/{index-0gmhd3hs.js → index-0rmmrrfh.js} +3 -3
- package/dist/{index-7f2k4g6q.js → index-12gb48hg.js} +4 -4
- package/dist/{index-7wben1jx.js → index-164mtd7z.js} +2 -2
- package/dist/{index-w0m3jm0s.js → index-1t74r13z.js} +2 -2
- package/dist/{index-thm1bzpj.js → index-2gj8zktr.js} +9 -9
- package/dist/{index-9xrhb68w.js → index-31ssvzw8.js} +2 -2
- package/dist/{index-652f9scs.js → index-4kf3nr14.js} +2 -2
- package/dist/{index-qe3xpt41.js → index-5s4mtrqb.js} +2 -2
- package/dist/{index-jmx5awkj.js → index-62vfxd90.js} +2 -2
- package/dist/{index-7gk1x74m.js → index-6nv5rdqh.js} +2 -2
- package/dist/{index-5ccmrpb5.js → index-6vsjepw2.js} +48 -48
- package/dist/{index-t6p4szqx.js → index-76vza24h.js} +3 -3
- package/dist/{index-76m37yd8.js → index-7bm1kptr.js} +3 -3
- package/dist/{index-0qjbnyg4.js → index-7wm4bqx5.js} +5 -5
- package/dist/{index-akk3rxnn.js → index-90gn0b6x.js} +3 -3
- package/dist/index-awj0w14r.js +11 -0
- package/dist/{index-2r6cmxxz.js → index-axkwyajz.js} +1 -1
- package/dist/index-bk17490n.js +3 -0
- package/dist/{index-fqz9n560.js → index-bp82hgag.js} +3 -3
- package/dist/{index-2vcxt38h.js → index-bpzk441p.js} +2 -2
- package/dist/{index-4z1y39jt.js → index-cn4p1ks0.js} +2 -2
- package/dist/{index-byerrz46.js → index-damc6cvc.js} +2 -2
- package/dist/{index-xtd0j8ve.js → index-dgbe8jm8.js} +2 -2
- package/dist/index-e5jdx9c1.js +3 -0
- package/dist/{index-tahaxp6n.js → index-ednz6yz2.js} +2 -2
- package/dist/{index-hsrt2v87.js → index-f5nmxa9e.js} +1 -1
- package/dist/{index-7s7ee1y9.js → index-he4hy261.js} +4 -4
- package/dist/{index-kwhx023z.js → index-j99tkngg.js} +10 -10
- package/dist/{index-4rasb3ph.js → index-k12bymz4.js} +9 -9
- package/dist/{index-qfxwk38p.js → index-p7fbnfwd.js} +2 -2
- package/dist/{index-jnxjjx2y.js → index-ppxayc0x.js} +2 -2
- package/dist/{index-er5k6qtr.js → index-qqnb0axh.js} +4 -4
- package/dist/index-qzwbctkv.js +16 -0
- package/dist/{index-a0vx2zyx.js → index-rae5bn1c.js} +2 -2
- package/dist/{index-8rbhm4g8.js → index-rhn7wy1p.js} +2 -2
- package/dist/index-sd5bt3g5.js +2 -0
- package/dist/{index-vtsd74g0.js → index-sq5j8bjn.js} +6 -6
- package/dist/{index-t5cfkz1e.js → index-v77bb0rm.js} +3 -3
- package/dist/{index-v16qz1fa.js → index-vhz1c474.js} +2 -2
- package/dist/{index-ywnfz6nm.js → index-wxb9dgwq.js} +1 -1
- package/dist/index-x4z055t8.js +3 -0
- package/dist/{index-haww9jpq.js → index-xetd52ad.js} +2 -2
- package/dist/index-xjnanwbf.js +116 -0
- package/dist/index-xp8g5akn.js +158 -0
- package/dist/{index-d59kp6zr.js → index-yfk0pb00.js} +2 -2
- package/dist/{index-cy97asyh.js → index-zcnfj1q4.js} +3 -3
- package/dist/{index-c4whjk5r.js → index-zn9snqbg.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/interactive-52x9hv6c.js +2 -0
- package/dist/key.cmd-y415ngam.js +2 -0
- package/dist/log-shipper-02rqvtq8.js +2 -0
- package/dist/{path-utils-r4df8d3w.js → path-utils-qgkdkp5j.js} +1 -1
- package/dist/plugin-system-yxztgnyz.js +2 -0
- package/dist/prereqs-runner-w7z2dwa6.js +2 -0
- package/dist/profile-mount-ga5z1vx9.js +2 -0
- package/dist/prune-stale-shims-vejvb1rj.js +2 -0
- package/dist/register-core-pv4qe8zc.js +2 -0
- package/dist/secondary-profile-attach-h9kga6ss.js +2 -0
- package/dist/subprocess-p9bv9nqz.js +2 -0
- package/dist/telemetry-1d3t1mbf.js +2 -0
- package/dist/tunnel-bootstrap-esay39d5.js +2 -0
- package/package.json +1 -1
- package/dist/agent-config-v9d7gcz0.js +0 -2
- package/dist/app-xc9c1d71.js +0 -2
- package/dist/autostart.cmd-ahet7b1t.js +0 -2
- package/dist/bootstrap-workspace-3pb8qjsh.js +0 -2
- package/dist/bootstrap.service-9m7m1ksa.js +0 -2
- package/dist/bridge-client-xvqy3n15.js +0 -2
- package/dist/daemon-profile-sg8fp50z.js +0 -2
- package/dist/gateway-client-ermpz52n.js +0 -2
- package/dist/index-5021rk8n.js +0 -3
- package/dist/index-b3v08awy.js +0 -3
- package/dist/index-mmx2kp76.js +0 -16
- package/dist/index-ss5gez2p.js +0 -2
- package/dist/index-tts92sdm.js +0 -5
- package/dist/index-x83tcr8f.js +0 -158
- package/dist/index-zcmhy3jv.js +0 -116
- package/dist/interactive-vbz68zh5.js +0 -2
- package/dist/key.cmd-f6rjvjy8.js +0 -2
- package/dist/log-shipper-0erbwn0q.js +0 -2
- package/dist/plugin-system-byzwda4c.js +0 -2
- package/dist/prereqs-runner-gca0bytz.js +0 -2
- package/dist/profile-mount-s4mc1x18.js +0 -2
- package/dist/prune-stale-shims-4nqtv0xt.js +0 -2
- package/dist/register-core-ws2axmcf.js +0 -2
- package/dist/secondary-profile-attach-em1tq7vq.js +0 -2
- package/dist/subprocess-4gg77skg.js +0 -2
- package/dist/telemetry-nmtywcba.js +0 -2
- package/dist/tunnel-bootstrap-tjwz90pb.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r,E}from"./index-
|
|
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
|
|
2
|
+
import{r,E}from"./index-1t74r13z.js";import{oe,Ft}from"./index-ppxayc0x.js";import"./index-7wm4bqx5.js";import"./index-j99tkngg.js";import{s,A,l,o,g,n,F,v,H}from"./index-12gb48hg.js";import{Q}from"./index-sq5j8bjn.js";import{_,y,u}from"./index-v77bb0rm.js";import{f,m,S,q,Te,ge}from"./index-damc6cvc.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 Ft(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 Te(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 ge(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
|
+
var i=new Set(["static-api-key","plugin-state:external-config"]),o=["gateway-auth:"],s=[/(^|[-_:])secret($|[-_:])/i,/(^|[-_:])token($|[-_:])/i,/(^|[-_:])password($|[-_:])/i,/(^|[-_:])api[-_]?key($|[-_:])/i,/^static-api-key$/i,/^gateway-auth:/i,/^clientSecret$/i,/^plugin-state:external-config$/i],Mi="[redacted]";function vt(t){return i.has(t)||o.some((n)=>t.startsWith(n))}function r(t){return s.some((n)=>n.test(t))}function be(t,n){return r(t)&&n!==void 0?"[redacted]":n}function Di(t){return Object.fromEntries(Object.entries(t).map(([n,e])=>[n,be(n,e)]))}function k(t){if(Array.isArray(t))return t.map((n)=>k(n));if(!t||typeof t!=="object")return t;return Object.fromEntries(Object.entries(t).map(([n,e])=>[n,r(n)?"[redacted]":k(e)]))}
|
|
3
|
+
export{Mi,vt,be,Di,k};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{e}from"./index-
|
|
3
|
-
export{
|
|
2
|
+
import{e}from"./index-7wm4bqx5.js";import{b}from"./index-w4jqdhc2.js";var a=5000,i=new Map,d=1;function c(r){return`${r}#${d++}`}function wr(r){let n=Bun.spawn(r.cmd,{env:r.env,cwd:r.cwd,stdout:r.stdout??"pipe",stderr:r.stderr??"pipe",stdin:r.stdin??"pipe",...b().processGroupSpawnOpts()}),t={id:c(r.owner),owner:r.owner,pid:n.pid??null,startedAt:new Date().toISOString(),proc:n,meta:r.meta};return i.set(t.id,t),n.exited.finally(()=>{i.delete(t.id)}),t}function qr(r){return[...i.values()].filter((n)=>n.owner===r)}async function l(r,n){let t=b(),s=Date.now()+n;while(Date.now()<s){if(!t.isProcessAlive(r))return!0;await new Promise((o)=>setTimeout(o,100))}return!t.isProcessAlive(r)}async function p(r,n="SIGTERM"){let t=r.pid;if(t==null)return;let s=b();if(s.killProcessTree(t,n),await l(t,a))return;s.killProcessTree(t,"SIGKILL")}async function en(){let r=[...i.values()];if(r.length===0)return{reaped:0};return e().logger.info("subprocess",`Reaping ${r.length} tracked child process(es)`,{owners:[...new Set(r.map((n)=>n.owner))]}),await Promise.all(r.map((n)=>p(n))),i.clear(),{reaped:r.length}}
|
|
3
|
+
export{wr,qr,en};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r,E}from"./index-
|
|
2
|
+
import{r,E}from"./index-1t74r13z.js";import"./index-7wm4bqx5.js";import{Z}from"./index-wxb9dgwq.js";import"./index-j99tkngg.js";import{i,d,s,A,l,o,g,n,c,F}from"./index-12gb48hg.js";import"./index-sq5j8bjn.js";import{vt,be,Di}from"./index-e5jdx9c1.js";import"./index-cn4p1ks0.js";import{_,y,u}from"./index-v77bb0rm.js";import{f,m,S,Te,ge}from"./index-damc6cvc.js";function R(C,t){if(C==="telemetry.enabled")Z.setEnabled(t==="true")}function P(C){return Object.entries(C).map(([t,e])=>({key:t,value:e}))}function j(C){let{db:t}=C;return new E().get("/",async()=>{let e=await t.getAllConfig(),p=Di(e);return{config:p,configs:P(p)}}).get("/status",async()=>await t.getConfigStatus()).get("/:key",async({params:e,set:p})=>{let k=await t.getConfig(e.key);if(k===void 0)return p.status=404,{error:"Configuration key not found"};return{key:e.key,value:be(e.key,k)}}).put("/:key",async({params:e,body:p,set:k})=>{if(vt(e.key))return k.status=403,{error:"Configuration key is managed by a dedicated endpoint"};try{return await t.setConfig(e.key,p.value),R(e.key,p.value),{success:!0}}catch(a){return k.status=500,{error:"Failed to set configuration",details:String(a)}}},{body:r.Object({value:r.String()})}).delete("/:key",async({params:e,set:p})=>{if(vt(e.key))return p.status=403,{error:"Configuration key is managed by a dedicated endpoint"};if(await t.getConfig(e.key)===void 0)return p.status=404,{error:"Configuration key not found"};try{return await t.deleteConfig(e.key),{success:!0}}catch(a){return p.status=500,{error:"Failed to delete configuration",details:String(a)}}}).post("/",async({body:e,set:p})=>{if(vt(e.key))return p.status=403,{error:"Configuration key is managed by a dedicated endpoint"};try{return await t.setConfig(e.key,e.value),R(e.key,e.value),{success:!0,key:e.key}}catch(k){return p.status=500,{error:"Failed to set configuration",details:String(k)}}},{body:r.Object({key:r.String(),value:r.String()})}).post("/bulk",async({body:e,set:p})=>{let k=Object.keys(e.configs).filter(vt);if(k.length>0)return p.status=403,{error:"One or more configuration keys are managed by dedicated endpoints",keys:k};try{await t.bulkSetConfig(e.configs);for(let[a,v]of Object.entries(e.configs))R(a,v);return{success:!0}}catch(a){return p.status=500,{error:"Failed to set configuration",details:String(a)}}},{body:r.Object({configs:r.Record(r.String(),r.String())})})}var x="http://localhost:3005";function h(C){C.command("config").description("Manage VibeControls agent configuration").option("--set <key=value>","Set a configuration value").option("--get <key>","Get a configuration value").option("--delete <key>","Delete a configuration value").option("--list","List all configuration values",!1).option("--value <value>","Value used with `--set <key>` (alternative to `--set key=value`)").option("--agent-url <url>","Agent URL",x).option("--json","Emit JSON").option("--plain","Force plain text output").action(async function(t){let e={...C.opts(),...t};try{let p=f(t),k=encodeURIComponent(m(e));if(t.set){let a=t.set.indexOf("="),v,b;if(a===-1){if(t.value===void 0){if(e.json){u(e,{ok:!1,error:"Invalid format: use key=value or --set key --value v"});return}s(`Invalid format. Use ${i.bold("--set key=value")} or ${i.bold("--set key --value value")}`);return}v=t.set.trim(),b=String(t.value).trim()}else v=t.set.slice(0,a).trim(),b=t.set.slice(a+1).trim();if(!v){if(e.json){u(e,{ok:!1,error:"Configuration key cannot be empty"});return}s("Configuration key cannot be empty.");return}if(await Te(p,`/api/profiles/${k}/config/${encodeURIComponent(v)}`,{value:b}),u(e,{ok:!0,key:v}))return;l(`${d.success} Set ${i.bold(v)} = ${i.cyan(String(be(v,b)))}`)}else if(t.get)await y({mode:_(e),fetchData:()=>S(p,`/api/profiles/${k}/config/${encodeURIComponent(t.get)}`),plain:(a)=>{g("Configuration"),c(),n(a.key,i.bold(String(be(a.key,a.value)))),c()},json:(a)=>({key:a.key,value:be(a.key,a.value)})});else if(t.delete){if(await ge(p,`/api/profiles/${k}/config/${encodeURIComponent(t.delete)}`),u(e,{ok:!0,key:t.delete}))return;l(`${d.success} Deleted configuration key: ${i.bold(t.delete)}`)}else if(t.list)await y({mode:_(e),fetchData:()=>S(p,`/api/profiles/${k}/config/`),plain:(a)=>{if(g("Agent Configuration"),c(),!a.configs||a.configs.length===0){o(`${d.info} No configuration entries found.`);return}let v=a.configs.map((b)=>({Key:b.key,Value:String(be(b.key,b.value))}));F(v),c(),o(`${d.info} ${a.configs.length} configuration(s) found.`)},json:(a)=>(a.configs??[]).map((v)=>({key:v.key,value:be(v.key,v.value)}))});else{if(e.json){u(e,{ok:!1,error:"No operation specified"});return}o(`${d.info} Usage:`),o(` ${i.bold("vibe config --list")} List all config values`),o(` ${i.bold("vibe config --get <key>")} Get a config value`),o(` ${i.bold("vibe config --set <key=value>")} Set a config value`),o(` ${i.bold("vibe config --delete <key>")} Delete a config value`)}}catch(p){if(e.json){u(e,{ok:!1,error:A(p)});return}s(`Config operation failed: ${A(p)}`)}})}function w(C,t){h(C)}function J(C){return{name:"config",version:"2.2.0",description:"Agent configuration key-value store",capabilities:{storage:"rw",audit:!0},tags:["backend","cli"],cliCommand:"config",apiPrefix:"/api/config",createRoutes:(t)=>j(t),onCliSetup:async(t,e)=>{w(t,e)}}}export{J as createPlugin};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ot,bt,Ji,Oe,Xt,O,I,C}from"./index-7wm4bqx5.js";import{Ae}from"./index-awj0w14r.js";import{b}from"./index-w4jqdhc2.js";import{existsSync as f,readdirSync as R,readFileSync as h,writeFileSync as m,mkdirSync as y,openSync as P,closeSync as w,unlinkSync as v}from"fs";import{join as l}from"path";import{tmpdir as k}from"os";import{spawn as A}from"child_process";class D{registryPath;logsDir;productDir;constructor(){let t=C();this.productDir=t,this.registryPath=l(t,"agents.json");let s=I();this.logsDir=l(s,"logs"),y(t,{recursive:!0}),y(s,{recursive:!0}),y(this.logsDir,{recursive:!0})}async startDaemon(t){return O(t.name),this.withInstanceLock(t.name,async()=>{let s=await this.findProcessByName(t.name);if(s&&s.status==="running"){let u=s.version,g=Ae();if(u===g){console.log(`\u26A0\uFE0F Agent '${t.name}' is already running on port ${s.port}`);return}console.log(`\uD83D\uDD04 Agent '${t.name}' is running an older build (${u??"unknown"} \u2192 ${g}) \u2014 restarting to apply the update`);try{await this.stopInternal(t.name)}catch(d){console.log(`\u26A0\uFE0F Could not cleanly stop the stale daemon (${d instanceof Error?d.message:String(d)}); proceeding to start the new build`)}}let e=l(this.logsDir,`${t.name}.log`),n=P(e,"a"),i=l(import.meta.dir,"index.js"),r=l(import.meta.dir,"..","index.ts"),c=f(i)?i:r,a=A(process.execPath,["run",c],{detached:!0,windowsHide:!0,stdio:["ignore",n,n],env:{...process.env,VIBECONTROLS_PROFILE:t.profile||"default",PORT:t.port.toString(),DB_PATH:t.dbPath,NODE_ENV:"production",AGENT_LOG_FILE:e}});a.on("error",()=>{}),w(n),await new Promise((u)=>setTimeout(u,2000));let o=a.pid;if(!(o!==void 0&&await this.isProcessRunning(o))){let u="";try{u=h(e,"utf8").split(/\r?\n/).filter((S)=>S.trim()).slice(-25).join(`
|
|
3
3
|
`)}catch{}let g=`See ${e}`;throw Error(u?`Failed to start agent '${t.name}'. ${g}
|
|
4
4
|
--- last log lines ---
|
|
5
|
-
${u}`:`Failed to start agent '${t.name}'. ${g}`)}a.unref(),await this.saveProcessInfo(t.name,o,t),console.log(`\uD83D\uDE80 Agent '${t.name}' started (PID: ${o}, Port: ${t.port})`)})}async stop(t){return O(t),this.withInstanceLock(t,()=>this.stopInternal(t))}async stopInternal(t){let s=await this.findProcessByName(t);if(!s||s.status!=="running"){console.log(`\u26A0\uFE0F Agent '${t}' is not running`);return}try{if(process.kill(s.pid,"SIGTERM"),await new Promise((n)=>setTimeout(n,3000)),await this.isProcessRunning(s.pid))process.kill(s.pid,"SIGKILL");await this.updateProcessStatus(t,"stopped"),console.log(`\u2705 Agent '${t}' stopped (tunnel + API key preserved)`)}catch(e){throw Error(`Failed to stop agent '${t}': ${e}`,{cause:e})}}async restart(t,s){O(t),O(s.name);let e=await this.findProcessByName(t);if(e&&e.status==="running")await this.stop(t);await this.startDaemon(s),console.log(`\uD83D\uDD04 Agent '${t}' restarted (tunnel + API key preserved)`)}async kill(t){return O(t),this.withInstanceLock(t,async()=>{let s=await this.findProcessByName(t);if(!s||s.status!=="running"){console.log(`\u26A0\uFE0F Agent '${t}' is not running`);return}let e=l(k(),`.boff-vibecontrols-kill-${s.pid}`);try{await Bun.write(e,"kill")}catch{}try{process.kill(s.pid,"SIGTERM"),await new Promise((i)=>setTimeout(i,5000))}catch{}if(await this.isProcessRunning(s.pid))await this.killProcessTree(s.pid);await this.updateProcessStatus(t,"stopped"),console.log(`\uD83D\uDC80 Agent '${t}' killed (tunnel + state torn down)`)})}async getStatus(t){return O(t),this.findProcessByName(t)}discoverRuntimeInstances(){let t=l(this.productDir,"agents");if(!f(t))return[];let s;try{s=R(t,{withFileTypes:!0}).filter((n)=>n.isDirectory()).map((n)=>n.name)}catch{return[]}let e=[];for(let n of s){let i=l(t,n,"runtime.json");if(!f(i))continue;try{let r=JSON.parse(h(i,"utf8"));if(typeof r.pid!=="number"||typeof r.port!=="number")continue;let c=r.profile||n;try{O(c)}catch{continue}e.push({name:c,pid:r.pid,port:r.port,config:{name:c,port:r.port,daemon:!0,dbPath:l(t,n,"agent-db"),host:r.host,profile:c},startTime:r.startedAt??new Date(0).toISOString(),status:"unknown",version:r.version})}catch{}}return e}async getStatusAll(){let t=this.loadRegistry(),s=new Set(t.map((r)=>r.name)),e=[...t];for(let r of this.discoverRuntimeInstances())if(!s.has(r.name))e.push(r);let n=[];for(let r of e){let c=await this.isManagedProcessRunning(r);if(!s.has(r.name)&&!c)continue;n.push({...r,status:c?"running":"stopped"})}let i=n.filter((r)=>r.status==="running"&&!s.has(r.name));if(i.length>0)try{await
|
|
5
|
+
${u}`:`Failed to start agent '${t.name}'. ${g}`)}a.unref(),await this.saveProcessInfo(t.name,o,t),console.log(`\uD83D\uDE80 Agent '${t.name}' started (PID: ${o}, Port: ${t.port})`)})}async stop(t){return O(t),this.withInstanceLock(t,()=>this.stopInternal(t))}async stopInternal(t){let s=await this.findProcessByName(t);if(!s||s.status!=="running"){console.log(`\u26A0\uFE0F Agent '${t}' is not running`);return}try{if(process.kill(s.pid,"SIGTERM"),await new Promise((n)=>setTimeout(n,3000)),await this.isProcessRunning(s.pid))process.kill(s.pid,"SIGKILL");await this.updateProcessStatus(t,"stopped"),console.log(`\u2705 Agent '${t}' stopped (tunnel + API key preserved)`)}catch(e){throw Error(`Failed to stop agent '${t}': ${e}`,{cause:e})}}async restart(t,s){O(t),O(s.name);let e=await this.findProcessByName(t);if(e&&e.status==="running")await this.stop(t);await this.startDaemon(s),console.log(`\uD83D\uDD04 Agent '${t}' restarted (tunnel + API key preserved)`)}async kill(t){return O(t),this.withInstanceLock(t,async()=>{let s=await this.findProcessByName(t);if(!s||s.status!=="running"){console.log(`\u26A0\uFE0F Agent '${t}' is not running`);return}let e=l(k(),`.boff-vibecontrols-kill-${s.pid}`);try{await Bun.write(e,"kill")}catch{}try{process.kill(s.pid,"SIGTERM"),await new Promise((i)=>setTimeout(i,5000))}catch{}if(await this.isProcessRunning(s.pid))await this.killProcessTree(s.pid);await this.updateProcessStatus(t,"stopped"),console.log(`\uD83D\uDC80 Agent '${t}' killed (tunnel + state torn down)`)})}async getStatus(t){return O(t),this.findProcessByName(t)}discoverRuntimeInstances(){let t=l(this.productDir,"agents");if(!f(t))return[];let s;try{s=R(t,{withFileTypes:!0}).filter((n)=>n.isDirectory()).map((n)=>n.name)}catch{return[]}let e=[];for(let n of s){let i=l(t,n,"runtime.json");if(!f(i))continue;try{let r=JSON.parse(h(i,"utf8"));if(typeof r.pid!=="number"||typeof r.port!=="number")continue;let c=r.profile||n;try{O(c)}catch{continue}e.push({name:c,pid:r.pid,port:r.port,config:{name:c,port:r.port,daemon:!0,dbPath:l(t,n,"agent-db"),host:r.host,profile:c},startTime:r.startedAt??new Date(0).toISOString(),status:"unknown",version:r.version})}catch{}}return e}async getStatusAll(){let t=this.loadRegistry(),s=new Set(t.map((r)=>r.name)),e=[...t];for(let r of this.discoverRuntimeInstances())if(!s.has(r.name))e.push(r);let n=[];for(let r of e){let c=await this.isManagedProcessRunning(r);if(!s.has(r.name)&&!c)continue;n.push({...r,status:c?"running":"stopped"})}let i=n.filter((r)=>r.status==="running"&&!s.has(r.name));if(i.length>0)try{await ot(()=>{let r=this.loadRegistry(),c=new Set(r.map((o)=>o.name)),a=i.filter((o)=>!c.has(o.name));if(a.length>0)this.saveRegistry([...r,...a.map((o)=>({...o,status:"running"}))])})}catch{}return n}async listInstances(){return this.getStatusAll()}getDefaultProfile(){return Oe()}setDefaultProfile(t){Xt(O(t))}async showLogs(t,s){O(t);let e=l(this.logsDir,`${t}.log`);if(!f(e)){console.log(`No logs found for agent '${t}'`);return}if(s.follow)try{let n=async(o)=>{let p=await Bun.file(e).text(),g=p.split(`
|
|
6
6
|
`).slice(-s.tail).join(`
|
|
7
7
|
`);if(process.stdout.write(o?g:g),o&&!g.endsWith(`
|
|
8
8
|
`))process.stdout.write(`
|
|
9
9
|
`);return p.length},i=await n(!0),r=!1,c=setInterval(async()=>{if(r)return;try{let o=await import("fs"),p=o.statSync(e);if(p.size>i){let u=o.openSync(e,"r"),g=p.size-i,d=Buffer.alloc(g);o.readSync(u,d,0,g,i),o.closeSync(u),process.stdout.write(d),i=p.size}else if(p.size<i)i=await n(!1)}catch{}},500),a=()=>{if(r)return;r=!0,clearInterval(c)};process.on("SIGINT",()=>{a(),process.exit(0)}),process.on("SIGTERM",()=>{a(),process.exit(0)}),process.on("SIGHUP",()=>{a(),process.exit(0)}),process.on("exit",a)}catch(n){console.error("Failed to follow logs:",n)}else try{let r=(await Bun.file(e).text()).split(`
|
|
10
10
|
`).slice(-s.tail).join(`
|
|
11
|
-
`);console.log(r)}catch(n){console.error("Failed to read logs:",n)}}async checkHealth(t){let s=await this.findProcessByName(t);if(!s||s.status!=="running")return{healthy:!1,details:{error:"Process not running"}};try{let e=await fetch(`http://localhost:${s.port}/health`),n=await e.json();return{healthy:e.ok,details:n}}catch(e){return{healthy:!1,details:{error:"Health check failed",message:e.message}}}}async setConfig(t,s){let e=l(C(),"config.json"),n={};if(f(e))n=JSON.parse(h(e,"utf8"));n[t]=s,m(e,JSON.stringify(n,null,2))}async getConfig(t){let s=l(C(),"config.json");if(!f(s))return t?void 0:{};let e=JSON.parse(h(s,"utf8"));return t?e[t]:e}loadRegistry(){return
|
|
12
|
-
`)}catch(r){if(r.code==="EEXIST"){let a=parseInt(h(n,"utf8"),10);if(!a||!await this.isProcessRunning(a)){try{v(n)}catch{}return this.withInstanceLock(t,s)}throw Error(`Agent '${t}' is already being modified`,{cause:r})}throw r}try{return await s()}finally{try{w(i)}catch{}try{v(n)}catch{}}}async saveProcessInfo(t,s,e){await
|
|
11
|
+
`);console.log(r)}catch(n){console.error("Failed to read logs:",n)}}async checkHealth(t){let s=await this.findProcessByName(t);if(!s||s.status!=="running")return{healthy:!1,details:{error:"Process not running"}};try{let e=await fetch(`http://localhost:${s.port}/health`),n=await e.json();return{healthy:e.ok,details:n}}catch(e){return{healthy:!1,details:{error:"Health check failed",message:e.message}}}}async setConfig(t,s){let e=l(C(),"config.json"),n={};if(f(e))n=JSON.parse(h(e,"utf8"));n[t]=s,m(e,JSON.stringify(n,null,2))}async getConfig(t){let s=l(C(),"config.json");if(!f(s))return t?void 0:{};let e=JSON.parse(h(s,"utf8"));return t?e[t]:e}loadRegistry(){return bt()}saveRegistry(t){Ji(t)}async withInstanceLock(t,s){let e=O(t),n=l(this.productDir,`.agent-${e}.lock`),i;try{i=P(n,"wx",384),m(i,`${process.pid}
|
|
12
|
+
`)}catch(r){if(r.code==="EEXIST"){let a=parseInt(h(n,"utf8"),10);if(!a||!await this.isProcessRunning(a)){try{v(n)}catch{}return this.withInstanceLock(t,s)}throw Error(`Agent '${t}' is already being modified`,{cause:r})}throw r}try{return await s()}finally{try{w(i)}catch{}try{v(n)}catch{}}}async saveProcessInfo(t,s,e){await ot(()=>{let i=this.loadRegistry().filter((r)=>r.name!==t);i.push({name:t,pid:s,port:e.port,config:e,startTime:new Date().toISOString(),status:"running"}),this.saveRegistry(i)})}async updateProcessStatus(t,s){await ot(()=>{let e=this.loadRegistry(),n=e.find((i)=>i.name===t);if(n)n.status=s,this.saveRegistry(e)})}async findProcessByName(t){O(t);let e=this.loadRegistry().find((i)=>i.name===t);if(!e)return null;let n=await this.isManagedProcessRunning(e);return e.status=n?"running":"stopped",e}async isManagedProcessRunning(t){if(!await this.isProcessRunning(t.pid))return!1;try{return(await fetch(`http://127.0.0.1:${t.port}/health/live`,{signal:AbortSignal.timeout(1000)})).ok}catch{return!1}}async isProcessRunning(t){try{return process.kill(t,0),!0}catch{return!1}}killProcessTree(t){try{b().killProcessTree(t,"SIGKILL")}catch{}}}
|
|
13
13
|
export{D};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`,{mode:384}),ut(n,this.path),!k(this.markerPath()))this.writeMarker()}markerPath(){return f(W(this.path),
|
|
4
|
-
`,{mode:384})}catch{}}}var
|
|
5
|
-
`,{mode:384}),ut(r,n)}async function
|
|
6
|
-
`,{mode:384})}catch{return{ok:!1,warning:"could not write install marker"}}let r=[{check:["sh","-c","command -v apt-get"],install:["sudo","-n","apt-get","install","-y","libsecret-1-0"]},{check:["sh","-c","command -v dnf"],install:["sudo","-n","dnf","install","-y","libsecret"]},{check:["sh","-c","command -v pacman"],install:["sudo","-n","pacman","-S","--noconfirm","libsecret"]}];for(let i of r){if(Q(i.check[0],i.check.slice(1),{stdio:["ignore","pipe","pipe"]}).status!==0)continue;let o=Q(i.install[0],i.install.slice(1),{stdio:["ignore","pipe","pipe"]});if(o.status===0)return{ok:!0};return{ok:!1,warning:`auto-install via '${i.install.join(" ")}' failed (exit ${o.status??"unknown"})`}}return{ok:!1,warning:"no supported package manager found"}}var D=null,F=null,ct=null;async function lt(t){try{return await t.get({service:v,name:"__probe__"}),!0}catch{return!1}}async function Xt(){if(ct)return ct;let t
|
|
7
|
-
`,{mode:384}),x(i,r)}function
|
|
8
|
-
`,{mode:384}),x(a,i),s}function
|
|
9
|
-
`,{mode:384}),x(g,r),s}async function
|
|
10
|
-
`,{mode:384}),x(c,r),s})}async function X(t){let n=w({dir:t?.dir,strict:t?.strict}),r=t?.scope??T();for(let i of E){if(n[i])continue;try{let s=await J(m(r,i));if(s)n[i]=s}catch(s){if(t?.strict)throw s}}return n}function ae(){return
|
|
11
|
-
export{J,
|
|
2
|
+
import{he,R,I,C,e}from"./index-7wm4bqx5.js";import{existsSync as d,mkdirSync as O,readdirSync as Qt,readFileSync as h,renameSync as x,rmSync as te,writeFileSync as S}from"fs";import{dirname as B,join as L}from"path";import{randomUUID as ee}from"crypto";import{existsSync as k,mkdirSync as K,readFileSync as gt,renameSync as ut,unlinkSync as Gt,writeFileSync as _}from"fs";import{dirname as W,join as f}from"path";import{spawnSync as Q}from"child_process";import{hostname as vt,networkInterfaces as _t,platform as dt,userInfo as Ut}from"os";import{createCipheriv as Rt,createDecipheriv as Ot,pbkdf2Sync as xt,randomBytes as Bt}from"crypto";var tt="secrets:fallback",ft="secrets:index",et=10,Lt=100,rt=new Map;function pt(t,n){let r=`${t}:${n}`,i=(rt.get(r)??0)+1;if(rt.set(r,i),i<=et)return!0;return(i-et)%Lt===0}var v="vibecontrols-agent",wt=".libsecret-install-attempted",yt="secrets.json";function $t(){return globalThis.Bun?.secrets??null}class j{api;kind="bun-secrets";constructor(t){this.api=t}async get(t){return this.api.get({service:v,name:t})}async set(t,n){await this.api.set({service:v,name:t,value:n}),await Kt(t)}async delete(t){let n=await this.api.delete({service:v,name:t});return await Jt(t),n}async list(t){return qt(t)}}var mt=".secrets-encrypted-v1",Tt=1e5,Nt=32,Dt="sha256",P=null,it=null;function Ft(){let t=_t();for(let n of Object.values(t)){if(!n)continue;for(let r of n){let i=r?.mac;if(i&&i!=="00:00:00:00:00:00")return i}}return"no-mac"}function ot(){if(it!==null)return it;let t;try{t=Ut().username||"unknown"}catch{t=process.env.USER||process.env.USERNAME||"unknown"}return`${vt()}|${t}|${Ft()}`}function ht(){if(P)return P;let t=`vibecontrols-agent::${ot()}`;return P=xt(t,ot(),Tt,Nt,Dt),P}function at(t){let n=Bt(12),r=Rt("aes-256-gcm",ht(),n),i=Buffer.concat([r.update(t,"utf8"),r.final()]),s=r.getAuthTag();return`${n.toString("hex")}:${s.toString("hex")}:${i.toString("hex")}`}function Mt(t){let n=t.split(":");if(n.length!==3)return!1;let[r,i,s]=n;return/^[0-9a-f]+$/i.test(r)&&r.length===24&&/^[0-9a-f]+$/i.test(i)&&i.length===32&&/^[0-9a-f]*$/i.test(s)}function Wt(t){if(!Mt(t))return null;try{let[n,r,i]=t.split(":"),s=Ot("aes-256-gcm",ht(),Buffer.from(n,"hex"));return s.setAuthTag(Buffer.from(r,"hex")),Buffer.concat([s.update(Buffer.from(i,"hex")),s.final()]).toString("utf8")}catch{return null}}class kt{kind="json-fallback";path;constructor(){this.path=f(C(),yt)}async get(t){let{plain:n}=this.readWithMigration(),r=n[t];return typeof r==="string"?r:null}async set(t,n){await he(tt,async()=>{let{encrypted:r}=this.readWithMigration();r[t]=at(n),this.writeEncrypted(r)})}async delete(t){return he(tt,async()=>{let{encrypted:n}=this.readWithMigration();if(!(t in n))return!1;return delete n[t],this.writeEncrypted(n),!0})}async list(t){let{encrypted:n}=this.readWithMigration(),r=Object.keys(n);return(t?r.filter((s)=>s.startsWith(t)):r).sort().map((s)=>({name:s}))}readWithMigration(){if(!k(this.path))return{encrypted:{},plain:{}};let t;try{t=gt(this.path,"utf8")}catch{return{encrypted:{},plain:{}}}let n;try{n=JSON.parse(t)}catch{return{encrypted:{},plain:{}}}if(!n||typeof n!=="object"||Array.isArray(n))return{encrypted:{},plain:{}};let r={},i={},s=!1;for(let[o,a]of Object.entries(n)){if(typeof a!=="string")continue;let g=Wt(a);if(g!==null){r[o]=a,i[o]=g;continue}r[o]=at(a),i[o]=a,s=!0}if(s)try{this.writeEncrypted(r),this.writeMarker()}catch{}return{encrypted:r,plain:i}}writeEncrypted(t){K(W(this.path),{recursive:!0});let n=`${this.path}.${process.pid}.tmp`;if(_(n,`${JSON.stringify(t,null,2)}
|
|
3
|
+
`,{mode:384}),ut(n,this.path),!k(this.markerPath()))this.writeMarker()}markerPath(){return f(W(this.path),mt)}writeMarker(){try{_(this.markerPath(),`${new Date().toISOString()}
|
|
4
|
+
`,{mode:384})}catch{}}}var jt=".secrets-index.json";function Y(){return f(C(),jt)}function q(){let t=Y();if(!k(t))return new Set;try{let n=gt(t,"utf8"),r=JSON.parse(n);if(Array.isArray(r))return new Set(r.filter((i)=>typeof i==="string"))}catch{}return new Set}function At(t){let n=Y();K(W(n),{recursive:!0});let r=`${n}.${process.pid}.tmp`;_(r,`${JSON.stringify([...t].sort(),null,2)}
|
|
5
|
+
`,{mode:384}),ut(r,n)}async function Kt(t){await he(ft,()=>{let n=q();if(n.has(t))return;n.add(t),At(n)})}async function Jt(t){await he(ft,()=>{let n=q();if(!n.delete(t))return;At(n)})}function qt(t){let r=[...q()];return(t?r.filter((s)=>s.startsWith(t)):r).sort().map((s)=>({name:s}))}function zt(){if(dt()!=="linux")return{ok:!1};if(process.env.CI==="true")return{ok:!1,warning:"CI/test environment detected; using JSON fallback"};if(process.env.VIBE_SKIP_LIBSECRET_INSTALL==="1")return{ok:!1,warning:"VIBE_SKIP_LIBSECRET_INSTALL=1 set; using JSON fallback"};let t=C(),n=f(t,wt);if(k(n))return{ok:!1,warning:"previous attempt failed; not retrying"};try{K(t,{recursive:!0}),_(n,`${new Date().toISOString()}
|
|
6
|
+
`,{mode:384})}catch{return{ok:!1,warning:"could not write install marker"}}let r=[{check:["sh","-c","command -v apt-get"],install:["sudo","-n","apt-get","install","-y","libsecret-1-0"]},{check:["sh","-c","command -v dnf"],install:["sudo","-n","dnf","install","-y","libsecret"]},{check:["sh","-c","command -v pacman"],install:["sudo","-n","pacman","-S","--noconfirm","libsecret"]}];for(let i of r){if(Q(i.check[0],i.check.slice(1),{stdio:["ignore","pipe","pipe"]}).status!==0)continue;let o=Q(i.install[0],i.install.slice(1),{stdio:["ignore","pipe","pipe"]});if(o.status===0)return{ok:!0};return{ok:!1,warning:`auto-install via '${i.install.join(" ")}' failed (exit ${o.status??"unknown"})`}}return{ok:!1,warning:"no supported package manager found"}}var D=null,F=null,ct=null;async function lt(t){try{return await t.get({service:v,name:"__probe__"}),!0}catch{return!1}}async function Xt(){if(ct)return ct;let t=$t();if(t&&await lt(t))return new j(t);if(dt()==="linux"&&t){let n=zt();if(n.ok&&await lt(t))return new j(t);if(n.warning)console.warn(`[secrets] libsecret unavailable (${n.warning}); using JSON fallback`);else console.warn("[secrets] Bun.secrets unavailable; using JSON fallback. Install libsecret-1-0 (apt) / libsecret (dnf/pacman) for OS keychain support.")}else if(!t)console.warn("[secrets] Bun.secrets API not present in this runtime; using JSON fallback.");return new kt}async function U(){if(D)return D;if(!F)F=Xt().then((t)=>(D=t,t));return F}async function J(t){let r=await(await U()).get(t);if(pt("read",t))e().audit.emit("agent","secret.read",{name:t,hit:r!==null});return r}async function de(t,n){if(await(await U()).set(t,n),pt("written",t))e().audit.emit("agent","secret.written",{name:t,valueLen:n.length})}async function Wr(){let t=await U(),n=(await t.list()).map((r)=>r.name);return{count:n.length,backend:n.length===0?"none":t.kind,names:n}}async function $i(){let t=await U(),r=(await t.list()).map((i)=>i.name);for(let i of r)try{await t.delete(i)}catch{}if(t.kind==="bun-secrets")G(Y()),G(f(C(),wt));else if(t.kind==="json-fallback"){let i=C();G(f(i,yt)),G(f(i,mt))}return{count:r.length,backend:r.length===0?"none":t.kind,names:r}}function G(t){try{if(k(t))Gt(t)}catch{}}function ne(t){return`agent-config:${t}`}var E=["clientId","clientSecret","gatewayClientId","gatewayClientSecret","static-api-key"];function bt(t){return E.includes(t)}function m(t,n){return`${t}:${n}`}function T(){try{return R()}catch{return"default"}}var y=1,re=[],N={globalGatewayUrl:"https://graphql.burdenoff.com/global/graphql",workspaceGatewayUrl:"https://graphqlworkspaces.burdenoff.com/workspaces/graphql"},ie={globalGatewayUrl:"https://alphagraphql.burdenoff.com/global/graphql",workspaceGatewayUrl:"https://alphagraphqlworkspaces.burdenoff.com/workspaces/graphql"},se={globalGatewayUrl:"http://localhost:4000/global/graphql",workspaceGatewayUrl:"http://localhost:4003/workspaces/graphql"},Ht={default:{...N}},Er={local:{...se},alpha:{...ie},prod:{...N}},A="default",St=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function _e(t){if(!St.test(t))throw Error("Profile name must use 1-64 characters: letters, numbers, dot, underscore, or dash.");return t}function Et(){return L(C(),"profiles")}function H(){return L(C(),"active")}function $e(t){return L(Et(),`${_e(t)}.json`)}function ye(){let t=H();if(!d(t))return A;try{let n=h(t,"utf8").trim();if(!n)return A;return _e(n)}catch{return A}}function Vt(t){let n=_e(t),r=H();O(B(r),{recursive:!0});let i=`${r}.${process.pid}.tmp`;S(i,`${n}
|
|
7
|
+
`,{mode:384}),x(i,r)}function Xr(){let t=Et();if(!d(t))return[];return Qt(t,{withFileTypes:!0}).filter((n)=>n.isFile()&&n.name.endsWith(".json")).map((n)=>n.name.slice(0,-5)).filter((n)=>St.test(n)).sort()}function It(t){let n=$e(t);if(!d(n))return{};try{return V(h(n,"utf8"))}catch{return{}}}function Pt(t,n){let r=JSON.parse(t);if(!r||typeof r!=="object"||Array.isArray(r))throw Error(`${n} is not a JSON object`);return r}function zr(t){let n=$e(t);if(!d(n))return{};return Pt(h(n,"utf8"),`Profile ${n}`)}function nt(t,n){let r=_e(t),i=$e(r);O(B(i),{recursive:!0});let s={schemaVersion:y,...n},o={...s};for(let g of E){let c=o[g];if(typeof c==="string"&&c.length>0)de(m(r,g),c).catch(()=>{});delete o[g]}let a=`${i}.${process.pid}.tmp`;return S(a,`${JSON.stringify(o,null,2)}
|
|
8
|
+
`,{mode:384}),x(a,i),s}function ei(t){let n=$e(t);if(!d(n))return!1;return te(n,{force:!0}),!0}function _r(t,n={}){let r=Ht[t];return{schemaVersion:y,globalGatewayUrl:r.globalGatewayUrl,workspaceGatewayUrl:r.workspaceGatewayUrl,...n}}function yr(){let t={created:[],activeWritten:null};for(let n of Object.keys(Ht))if(!d($e(n)))nt(n,_r(n)),t.created.push(n);if(!d(H()))Vt(A),t.activeWritten=A;return t}function oe(){return{...N}}function st(t){let n=t?.dir??I();return L(n,"config.json")}function Sr(){return{...N}}function ti(t={}){let n=oe();return{schemaVersion:y,globalGatewayUrl:n.globalGatewayUrl,workspaceGatewayUrl:n.workspaceGatewayUrl,...t}}function V(t){try{let n=JSON.parse(t);if(n&&typeof n==="object")return n}catch{}return{}}function w(t){let n=st(t);if(!d(n))return{};let r;try{let s=h(n,"utf8");r=t?.strict?Pt(s,`Agent config ${n}`):V(s)}catch(s){if(t?.strict)throw s;return{}}if((r.schemaVersion??0)>=y)return r;for(let s of re){if(s.from<(r.schemaVersion??0))continue;r=s.apply(r),r.schemaVersion=s.to}if(r.schemaVersion!==y)r.schemaVersion=y;if(!t?.strict)try{S(n,JSON.stringify(r,null,2),{mode:384})}catch{}return r}function ri(t){let n=w(t);if(n.agentInstanceId)return n.agentInstanceId;let r=ee();return M({agentInstanceId:r},t),r}function M(t,n){let r=st(n);O(B(r),{recursive:!0});let i=d(r)?V(h(r,"utf8")):{},s={...i},o={...i};for(let c of E)delete o[c];let a=n?.scope??T();for(let[c,l]of Object.entries(t)){if(l===void 0||l==="")continue;if(s[c]=l,bt(c)&&typeof l==="string"){de(m(a,c),l).catch(()=>{});continue}o[c]=l}let g=`${r}.${process.pid}.tmp`;return S(g,`${JSON.stringify(o,null,2)}
|
|
9
|
+
`,{mode:384}),x(g,r),s}async function Yt(t,n){let r=st(n);return he(ne(r),async()=>{O(B(r),{recursive:!0});let i=d(r)?V(h(r,"utf8")):{},s={...i},o={...i};for(let l of E)delete o[l];let a=n?.scope??T(),g=[];for(let[l,p]of Object.entries(t)){if(p===void 0||p==="")continue;if(s[l]=p,bt(l)&&typeof p==="string"){g.push(de(m(a,l),p));continue}o[l]=p}await Promise.all(g);let c=`${r}.${process.pid}.tmp`;return S(c,`${JSON.stringify(o,null,2)}
|
|
10
|
+
`,{mode:384}),x(c,r),s})}async function X(t){let n=w({dir:t?.dir,strict:t?.strict}),r=t?.scope??T();for(let i of E){if(n[i])continue;try{let s=await J(m(r,i));if(s)n[i]=s}catch(s){if(t?.strict)throw s}}return n}function ae(){return It(ye())}function u(t){if(!t)return null;try{return new URL(t).origin}catch{return null}}function Zt(t,n=new Date().toISOString()){let r={pairedAt:n},i=u(t.globalGatewayUrl);if(i)r.globalGatewayOrigin=i;let s=u(t.workspaceGatewayUrl);if(s)r.workspaceGatewayOrigin=s;if(t.workspaceId)r.workspaceId=t.workspaceId;if(t.agentRecordId)r.agentRecordId=t.agentRecordId;return r}function ce(t){if(!Boolean(t.clientId||t.pairedIdentity||t.workspaceId||t.agentRecordId))return null;let r=t.pairedIdentity,i={workspaceId:r?.workspaceId??t.workspaceId,globalGatewayUrl:u(r?.globalGatewayOrigin??t.globalGatewayUrl)??void 0,workspaceGatewayUrl:u(r?.workspaceGatewayOrigin??t.workspaceGatewayUrl)??void 0};if(Boolean(i.workspaceId||i.globalGatewayUrl||i.workspaceGatewayUrl))return i;return null}function ii(t,n){let r=ce(t);if(!r)return null;let i=Z(r,n);if(!i.length)return null;let s=b(r),o=t.pairedIdentity?.pairedAt;return`${t.clientId?`This agent is already paired with ${s}.`:`This agent holds no credential right now, but it is still bound to ${s}${o?` (paired ${o})`:""} \u2014 a cleared `+"secrets store is not an unpaired agent."} Refusing a credential push from ${b(n)} (${i.join("; ")}): it would overwrite the only credential slot and strand the existing pairing on 401. Re-send with "force": true to repair deliberately, or run the other environment under its own profile (VIBECONTROLS_PROFILE).`}function ni(t,n,r){let i=Z({globalGatewayUrl:t.globalGatewayUrl,workspaceGatewayUrl:t.workspaceGatewayUrl},{...n,workspaceId:void 0});if(!i.length)return null;let s=u(t.globalGatewayUrl)??u(t.workspaceGatewayUrl)??"its configured gateway";return`Profile "${r}" is configured for ${s}, but this credential push is for ${b(n)} (${i.join("; ")}). Accepting it would repoint the profile `+"without saying so \u2014 the agent would run against one environment while "+`"${r}" still describes another. Run that environment under its own profile (VIBECONTROLS_PROFILE=<name>, or \`vibe profile create <name>\`), or re-send with "force": true to repoint "${r}" deliberately.`}function b(t){return`${u(t.globalGatewayUrl)??"unknown gateway"} (workspace ${t.workspaceId??"unknown"})`}function Z(t,n){let r=[],i=u(t.globalGatewayUrl),s=u(n.globalGatewayUrl);if(i&&s&&i!==s)r.push(`global gateway ${i} -> ${s}`);let o=u(t.workspaceGatewayUrl),a=u(n.workspaceGatewayUrl);if(o&&a&&o!==a)r.push(`workspace gateway ${o} -> ${a}`);if(t.workspaceId&&n.workspaceId&&t.workspaceId!==n.workspaceId)r.push(`workspace ${t.workspaceId} -> ${n.workspaceId}`);return r}function si(t,n){if(!t.clientId)return null;let r=Z(t,n);if(!r.length)return null;return`Credentials were issued for ${b(t)} but this agent is configured for ${b(n)} (${r.join("; ")}). `+"They cannot authenticate there \u2014 re-pair the agent from the environment "+"it should belong to, or clear the conflicting environment override (VIBE_GLOBAL_GATEWAY_URL / VIBE_WORKSPACE_GATEWAY_URL / VIBE_WORKSPACE_ID)."}var z=null;function oi(){return{...z??{}}}function Ct(){try{yr()}catch{}let t=ae(),n=w(),r={...t,...n};if(z===null)z={globalGatewayUrl:process.env.VIBE_GLOBAL_GATEWAY_URL,workspaceGatewayUrl:process.env.VIBE_WORKSPACE_GATEWAY_URL};let i=(o,a)=>{if(!process.env[o]&&a)process.env[o]=a};i("VIBE_WORKSPACE_ID",r.workspaceId),i("VIBE_ORGANIZATION_ID",r.organizationId);let s=Sr();return i("VIBE_GLOBAL_GATEWAY_URL",r.globalGatewayUrl??s.globalGatewayUrl),i("VIBE_WORKSPACE_GATEWAY_URL",r.workspaceGatewayUrl??s.workspaceGatewayUrl),i("VIBE_STORAGE_ADAPTER",r.storageAdapter),i("VIBECONTROLS_PLUGIN_INSTALL_SCOPE",r.pluginInstallScope),r}async function ai(){let t=(r,i)=>{if(!process.env[r]&&i)process.env[r]=i},n=T();try{let r=await J(m(n,"clientId"));t("VIBE_CLIENT_ID",r??void 0)}catch{}try{let r=await J(m(n,"clientSecret"));t("VIBE_CLIENT_SECRET",r??void 0)}catch{}}
|
|
11
|
+
export{J,de,Wr,$i,Ht,Er,_e,$e,ye,Vt,Xr,It,zr,nt,ei,_r,yr,st,Sr,ti,w,ri,M,Yt,X,Zt,ii,ni,si,oi,Ct,ai};
|