@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
package/dist/index-ss5gez2p.js
DELETED
package/dist/index-tts92sdm.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ht,I,se,N,e}from"./index-0qjbnyg4.js";import{b}from"./index-w4jqdhc2.js";import{existsSync as y,mkdirSync as F,readdirSync as ve,readFileSync as x,renameSync as Pe,realpathSync as B,rmSync as h,statSync as we,writeFileSync as M}from"fs";import{homedir as Se}from"os";import{dirname as S,isAbsolute as be,join as p,relative as ke,sep as j}from"path";import{fileURLToPath as L}from"url";import{existsSync as X,readFileSync as ee}from"fs";import{dirname as E,join as te}from"path";import{fileURLToPath as re}from"url";var ne="@vibecontrols/agent",P;function _e(){if(P)return P;try{let t=E(re(import.meta.url));for(let r=0;r<10&&t&&t!==E(t);r++){let i=te(t,"package.json");if(X(i))try{let n=JSON.parse(ee(i,"utf8"));if(n.name===ne&&typeof n.version==="string")return P=n.version,P}catch{}t=E(t)}}catch{}return P??"0.0.0"}function _(){let t=process.env.VIBECONTROLS_PLUGIN_CONTRACT_V2_ENFORCE;return t==="1"||t==="true"||t==="on"}var D={storage:"rw",secrets:"rw",gateway:!0,broadcast:!0,subprocess:!0,audit:!0,telemetry:!0,singletonOnly:!1,requiresIsolation:!1},O={storage:"none",secrets:"none",gateway:!1,broadcast:!1,subprocess:!1,audit:!1,telemetry:!1,singletonOnly:!1,requiresIsolation:!1};function V(){let t=process.env.VIBECONTROLS_STRICT_PLUGIN_CAPS;return t==="1"||t==="true"||t==="on"}function H(t,r,i,n,s=!1){return new Proxy(t,{get(a,o,l){if(o==="plugins"){if(!s)return;return Reflect.get(a,o,l)}if(o==="storage")return oe(a.storage,i.storage??"none",r,n);if(o==="broadcast"&&!i.broadcast)return w(r,"broadcast",n);if(o==="workspaceQuery"&&!i.gateway)return w(r,"workspaceQuery",n);if(o==="getAgentRecordId"&&!i.gateway)return w(r,"getAgentRecordId",n);if(o==="getWorkspaceId"&&!i.gateway)return w(r,"getWorkspaceId",n);if(o==="iframeBridge"&&!s){let g=Reflect.get(a,o,l);if(!g)return g;return{...g,getAgentApiKey:w(r,"iframeBridge.getAgentApiKey",n)}}if(o==="telemetry"){if(!i.telemetry)return;return Reflect.get(a,o,l)}return Reflect.get(a,o,l)}})}function oe(t,r,i,n){if(r==="rw")return t;return new Proxy(t,{get(s,a,o){let l=String(a),g=l==="set"||l==="delete"||l==="deleteAll";if(r==="none"||r==="read"&&g)return(...d)=>{throw n("plugin.capability.denied",{pluginName:i,surface:"storage",op:l,mode:r}),Error(`plugin '${i}' lacks storage:${g?"rw":"read"} capability (op=${l})`)};return Reflect.get(s,a,o)}})}function w(t,r,i){return(...n)=>{throw i("plugin.capability.denied",{pluginName:t,op:r}),Error(`plugin '${t}' lacks capability for ${r}`)}}import{Worker as ae}from"worker_threads";import{fileURLToPath as ge}from"url";import{randomUUID as ue}from"crypto";function ce(){let t=ge(import.meta.url),r=t.lastIndexOf("/"),i=r>=0?t.slice(0,r):t,n=`${i}/plugin-worker-runtime.ts`,s=`${i}/plugin-worker-runtime.js`;if(t.endsWith(".ts"))return n;return s}class R{worker;pending=new Map;spec;initPromise;terminated=!1;constructor(t){this.spec=t}async start(){if(this.initPromise)return this.initPromise;return this.initPromise=this.spawn(),this.initPromise}async spawn(){let t=this.spec.runtimeEntry??ce(),r=["PATH","HOME","USERPROFILE","TMPDIR","TMP","TEMP","LANG","LC_ALL","LC_CTYPE","TZ","SystemRoot","SystemDrive","ComSpec","PATHEXT","windir"],i={};for(let s of r){let a=process.env[s];if(typeof a==="string")i[s]=a}let n=new ae(t,{env:i});this.worker=n,n.on("message",(s)=>this.onMessage(s)),n.on("error",(s)=>this.onWorkerError(s instanceof Error?s:Error(String(s)))),n.on("exit",(s)=>this.onWorkerExit(s)),await this.call("init",{modulePath:this.spec.modulePath,ctxStub:{name:this.spec.ctx.name,dataDir:this.spec.ctx.dataDir}})}async dispatch(t,r=[]){if(this.terminated)throw Error("PluginWorkerHost terminated");if(!this.worker)await this.start();return this.call("dispatch",{method:t,params:r})}call(t,r){if(!this.worker)return Promise.reject(Error("worker not spawned"));let i=ue();return new Promise((n,s)=>{this.pending.set(i,{resolve:n,reject:s});try{this.worker?.postMessage({id:i,op:t,args:r})}catch(a){this.pending.delete(i),s(a instanceof Error?a:Error(String(a)))}})}onMessage(t){let r=this.pending.get(t.id);if(!r)return;if(this.pending.delete(t.id),t.ok)r.resolve(t.result);else{let i=Error(t.error?.message??"worker error");if(t.error?.stack)i.stack=t.error.stack;r.reject(i)}}onWorkerError(t){for(let[,r]of this.pending)r.reject(t);this.pending.clear()}onWorkerExit(t){if(this.pending.size>0){let r=Error(`worker exited (code=${t}) with pending calls`);for(let[,i]of this.pending)i.reject(r);this.pending.clear()}this.terminated=!0}async terminate(){if(this.terminated=!0,!this.worker)return;try{await this.worker.terminate()}catch{}this.worker=void 0}}var de=[{packageName:"@vibecontrols/vibe-plugin-storage",pluginName:"storage",label:"Storage facade",description:"Storage provider registry \u2014 owns AgentDatabase contract. Bundled with the agent; the storage meta lazy-loads the configured provider by name.",category:"storage",trusted:!0,isCore:!0,isDefault:!0,isCritical:!0,removable:!1,integrity:"sha512-E0agrBuSwO7R5z7dBA6Jb0Mq5zibhkFzvEh0lcb4N+byt25yStrDcsJqJ3bJpVdavw/OkAjB+MAC06zkTtHraQ=="},...["agent","task","config","git","plugin-mgr","log"].map((t)=>({packageName:`@vibecontrols/vibe-plugin-${t}`,pluginName:t,label:`${t} (built-in)`,description:`Built-in ${t} plugin bundled with the agent.`,category:"core",trusted:!0,isCore:!0,removable:!1}))],pe=[{packageName:"@vibecontrols/vibe-plugin-tunnel",pluginName:"tunnel",label:"Tunnel manager",description:"Owns TunnelProvider interface. Routes to a registered tunnel provider.",category:"tunnel",trusted:!0,isDefault:!0,isCritical:!0,cliCommand:"tunnel",apiPrefix:"/api/tunnel",integrity:"sha512-FFqJjvPNCAYZwMjOKt1vHiBuzd+6W9sYI6vZqls7kr3Za+m++tIueT9OV2DlpAJT8XU+fidrgsWgQi8AcjPHWQ=="},{packageName:"@vibecontrols/vibe-plugin-session-manager",pluginName:"session-manager",label:"Session manager",description:"Owns SessionProvider interface. Routes to a registered session backend.",category:"session",trusted:!0,isCore:!0,isDefault:!0,isCritical:!0,cliCommand:"session",apiPrefix:"/api/sessions",integrity:"sha512-1841STCBKRDc0h0BFgcZ3ZJydThKUkHKtDdnC2YMZOiSYVB4N/+7fJQhyMSq3bc6zj/FO7jBne9Gmg+PLoXiQA=="},{packageName:"@vibecontrols/vibe-plugin-ai",pluginName:"ai",label:"AI orchestration",description:"Owns AIAgentProvider interface. Prompts, contexts, sessions, dispatch, logs.",category:"ai",trusted:!0,isDefault:!0,isCritical:!0,cliCommand:"ai",apiPrefix:"/api/ai",integrity:"sha512-mIkzkzMDU38ILFa2lRsjeaJqAidtlUBWoQ3KaFxkpG88AHWUtcA6Vha/wZQ5Ns16h0g4vRKxtbOLfFSTEgRerA=="},{packageName:"@vibecontrols/vibe-plugin-plan",pluginName:"plan",label:"Plan orchestration",description:"Owns PlanProvider interface. Routes plan sessions to a registered provider.",category:"plan",trusted:!0,isDefault:!1,cliCommand:"plan",apiPrefix:"/api/plan",integrity:"sha512-SSCFLFkmAhHesLYgETeEyAZs2Gu8tDEaMMuJtMMKG5eKGQIXYJaJZnQBuXP/vKOAlLd//l8es5hPqhmiNSi4Gw=="},{packageName:"@vibecontrols/vibe-plugin-gitops",pluginName:"gitops",label:"GitOps orchestrator",description:"Owns GitOpsProvider interface. Routes repo / PR / CI / security queries to a registered provider.",category:"gitops",trusted:!0,isDefault:!1,cliCommand:"gitops",apiPrefix:"/api/gitops",integrity:"sha512-KzoSmBDgQ5mbSFxAuIyIBnC/HKwYhtXluGp06DvzQmwqOQ4vEC72PuSiVx3doWrt+Z6fZ6i6gxNzmYNpdhPLXA=="},{packageName:"@vibecontrols/vibe-plugin-security",pluginName:"security",label:"Security lifecycle",description:"Security lifecycle orchestrator \u2014 owns /api/security and dispatches to per-stage providers.",category:"security",trusted:!0,isDefault:!1,cliCommand:"security",apiPrefix:"/api/security",integrity:"sha512-K6w3tC7qnCotvnNWWdmHnjqGgCNJoPNMs8gCwWFbcNI5MmbIrUQfFQdcjwGudwryvN2+TrX12MhfhWz4p1qcMA=="},{packageName:"@vibecontrols/vibe-plugin-desk",pluginName:"desk",label:"Steward desk",description:"Owns the desk provider routing. Lets a BotManor Steward use this machine's browser or desktop, with remote control off until the owner turns it on.",category:"desk",trusted:!1,isDefault:!1,apiPrefix:"/api/desk",integrity:"sha512-5LHgI8OzBOZxFIE1PgL05sf2QYdd0qCA5fSu4Km9rt41sMjDvqcNQaWDo7hyYalqE/vY6LCJzrQ6xs47Vlx2Xw=="}],fe=[{packageName:"@vibecontrols/vibe-plugin-tool-code-server",pluginName:"code-server",label:"Browser code editor",description:"Browser-based VS Code via code-server \u2014 open any Vibe in an in-browser editor.",category:"tool",trusted:!0,isDefault:!1,cliCommand:"code-server",apiPrefix:"/api/code-server"}],me=[{packageName:"@vibecontrols/vibe-plugin-agent-backup",pluginName:"agent-backup",label:"Agent backup",description:"Backup and restore agent state.",category:"agent",trusted:!0,isDefault:!0,integrity:"sha512-KhN2Vaahtnl4IKRbaHKtlEbsuvW9dbgC2l4kkIXcme55DaSmLy5kYkiysnwyZdC4PRQu4NKM4GQLoW9hD86dRw=="}],ie=[...de,...pe,...fe,...me],Y=[{key:"storage",label:"Storage",description:"Encrypted local state for the agent.",categories:["storage"],mandatory:!0,defaultSelected:!0},{key:"tunnel",label:"Tunnels",description:"Expose the agent for remote access + share links.",categories:["tunnel"],mandatory:!0,defaultSelected:!0},{key:"backup",label:"Backup",description:"Backup + restore agent state.",categories:["agent"],mandatory:!0,defaultSelected:!0},{key:"session",label:"Terminal sessions",description:"Long-lived terminal / AI agent sessions.",categories:["session"],mandatory:!1,defaultSelected:!0},{key:"editor",label:"Browser code editor",description:"Open any Vibe in an in-browser VS Code editor (code-server).",categories:["tool"],mandatory:!1,defaultSelected:!0},{key:"ai",label:"AI orchestration",description:"AI agent harnesses, prompts + dispatch.",categories:["ai"],mandatory:!1,defaultSelected:!0},{key:"plan",label:"Plan review",description:"Review / approve AI-proposed plans.",categories:["plan"],mandatory:!1,defaultSelected:!1},{key:"gitops",label:"GitOps",description:"Repo / PR / CI / security integration.",categories:["gitops"],mandatory:!1,defaultSelected:!1},{key:"security",label:"Security",description:"Security scanning lifecycle.",categories:["security"],mandatory:!1,defaultSelected:!1}],C=ie.filter((t)=>t.isCore&&t.category==="core").map((t)=>t.pluginName),U=ie.filter((t)=>t.isDefault===!0);function A(t){return U}function ye(t,r){let i=r instanceof Set?r:new Set(r),n=new Set;for(let s of Y)if(s.mandatory||i.has(s.key))for(let a of s.categories)n.add(a);return ie.filter((s)=>n.has(s.category))}var G=new Set(ie.filter((t)=>t.trusted).map((t)=>t.packageName));function he(){let t=ie.filter((i)=>i.isCritical).flatMap((i)=>[i.packageName,i.pluginName]),r=process.env.VIBECONTROLS_CRITICAL_PLUGINS;if(r){let i=r.split(",").map((n)=>n.trim()).filter(Boolean);return new Set([...t,...i])}return new Set(t)}function ht(t){return he().has(t)}var bi=ie.filter((t)=>!t.isCore||t.category!=="core");function wi(t){return ie.find((r)=>r.packageName===t)}function qi(t){return new Set}function ft(t){return t.startsWith("@vibecontrols/vibe-plugin-")||G.has(t)}function Pr(t){let r=t.trim();if(!r)return;if(r.startsWith("@vibecontrols/"))return ie.find((n)=>n.packageName===r);if(r.startsWith("vibe-plugin-"))return ie.find((n)=>n.packageName===`@vibecontrols/${r}`);let i=ie.find((n)=>n.pluginName===r);if(i)return i;return ie.find((n)=>n.packageName===`@vibecontrols/vibe-plugin-${r}`)}function Mt(t){let r=t.trim();if(!r)return;let i=Pr(r);if(i)return i.packageName;if(r.startsWith("@vibecontrols/"))return r;if(r.startsWith("vibe-plugin-"))return`@vibecontrols/${r}`;return`@vibecontrols/vibe-plugin-${r}`}function q(t){return ie.find((r)=>r.pluginName===t)}function Ee(t){return ie.find((r)=>r.packageName===t)}function Re(t,r){if(t.length!==r.length)return!1;let i=0;for(let n=0;n<t.length;n++)i|=t.charCodeAt(n)^r.charCodeAt(n);return i===0}async function Ce(t,r,i){let n=Ee(t),s=process.env.VIBECONTROLS_REQUIRE_PLUGIN_INTEGRITY==="1";if(!n?.integrity){if(s)throw Error(`Refusing to install ${t}: catalog has no pinned integrity and VIBECONTROLS_REQUIRE_PLUGIN_INTEGRITY=1`);return}let a=i,o;try{let g=`${r.replace(/\/+$/,"")}/${t.replace("/","%2F")}`,u=await fetch(g,{headers:{accept:"application/json"},signal:AbortSignal.timeout(20000)});if(!u.ok)throw Error(`registry packument fetch failed (HTTP ${u.status})`);let d=await u.json();if(a=a??d["dist-tags"]?.latest,!a)throw Error("could not resolve version from registry");if(o=d.versions?.[a]?.dist?.integrity,typeof o!=="string"||o.length===0)throw Error(`registry did not return dist.integrity for ${t}@${a}`)}catch(l){let g=l instanceof Error?l.message:String(l);throw Error(`Pre-install integrity gate refused ${t}: ${g}`,{cause:l})}if(!Re(n.integrity,o)){let l=process.env.VIBECONTROLS_STRICT_PLUGIN_INTEGRITY==="1";if(ft(t)&&!l){e().logger.warn("plugin-manager",`Integrity pin for ${t} is stale \u2014 catalog expects ${n.integrity}, the allowlisted registry has ${o} for ${a}. Proceeding (first-party package, registry allowlisted). Re-pin plugins.config.ts to silence this.`);return}throw Error(`Pre-install integrity gate refused ${t}: integrity mismatch for ${a}: expected ${n.integrity}, got ${o}`)}}var $e=["https://registry.npmjs.org/","https://registry.npmjs.org"];function Ae(){let t=process.env.VIBECONTROLS_REGISTRY_ALLOWLIST,r=[...$e];if(typeof t==="string"&&t.length>0)for(let i of t.split(",").map((n)=>n.trim()).filter(Boolean))r.push(i);return r}function Ie(t){let r=Ae(),i;try{i=new URL(t).origin}catch{throw Error(`Invalid plugin registry URL: ${t}`)}for(let n of r)try{if(new URL(n).origin===i)return}catch{}throw Error(`Plugin registry '${t}' is not in the allow-list. Add it to VIBECONTROLS_REGISTRY_ALLOWLIST at daemon start.`)}var K="plugins.json",xe=/^@vibecontrols\/vibe-plugin-[a-z0-9][a-z0-9-]{0,80}$/,z=/^[a-z0-9][a-z0-9-]{0,63}$/,Le=/^\/api\/[A-Za-z0-9][A-Za-z0-9/_-]{0,127}$/,Te=/^\/[A-Za-z0-9][A-Za-z0-9/_-]{0,159}$/,Q=Symbol.for("vibecontrols.pluginPackageRoot");function Mr(t){return t[Q]}function le(t){let r=t.trim();if(!xe.test(r))throw Error("Plugin package must be a @vibecontrols/vibe-plugin-* package name.");if(!ft(r)&&process.env.VIBECONTROLS_ALLOW_UNTRUSTED_PLUGINS!=="1")throw Error("Plugin package is not in the trusted VibeControls catalog.");return r}function Ne(t,r){let i=ke(t,r);return i===""||!!i&&!i.startsWith("..")&&!be(i)}function Z(){return p(I(),"agent-plugins","node_modules")}function De(){try{let t=Z();return y(t)&&ve(t).length>0}catch{return!1}}function T(){let t=(process.env.VIBECONTROLS_PLUGIN_INSTALL_SCOPE??process.env.VIBECONTROLS_PLUGIN_INSTALL_MODE??"").toLowerCase();if(t==="local")return"local";if(t==="global")return"global";return De()?"local":"global"}var J="provider:default:";function Oe(t){if(!t||typeof t!=="object")return!1;let r=t;return typeof r.packageName==="string"&&typeof r.version==="string"&&typeof r.pluginName==="string"&&typeof r.installedAt==="string"}class W{registry=[];loaded=new Map;corePlugins=new Map;db;forcedIsolation=new Set;workerHosts=new Map;lifecycleChain=Promise.resolve();withLifecycleLock(t){let i=this.lifecycleChain.then(t,t);return this.lifecycleChain=i.then(()=>{return},()=>{return}),i}async terminateWorkerHost(t){let r=this.workerHosts.get(t);if(!r)return;try{await r.terminate()}catch(i){e().logger.warn("plugin-manager",`Failed to terminate worker for '${t}': ${i instanceof Error?i.message:String(i)}`)}finally{this.workerHosts.delete(t)}}async terminateAllWorkerHosts(){let t=Array.from(this.workerHosts.keys());await Promise.all(t.map((r)=>this.terminateWorkerHost(r)))}constructor(t){this.db=t,this.ensureDir(),this.loadRegistry();let r=process.env.VIBE_ISOLATE_PLUGINS;if(typeof r==="string"&&r.length>0)this.setForcedIsolation(r.split(",").map((i)=>i.trim()).filter((i)=>i.length>0))}setForcedIsolation(t){this.forcedIsolation=new Set(t.filter((r)=>r.length>0))}shouldIsolate(t){if(this.forcedIsolation.has(t.name))return!0;return t.capabilities?.requiresIsolation===!0}getWorkerHost(t){return this.workerHosts.get(t)}registerWorkerHost(t,r){this.workerHosts.set(t,r)}auditSink=(t,r)=>{e().logger.warn("plugin-capability",t,r)};static resolveEffectiveCapabilities(t,r){if(t.capabilities)return t.capabilities;return r?D:O}hostServicesFor(t,r){return this.wrapHostServices(t,r)}wrapHostServices(t,r){let i=this.corePlugins.has(t.name),n=W.resolveEffectiveCapabilities(t,i),s=i||this.isTrustedLoadedPlugin(t);return H(r,t.name,n,this.auditSink,s)}routeDepsFor(t,r){if(this.corePlugins.has(t.name)||this.isTrustedLoadedPlugin(t))return r;let n=W.resolveEffectiveCapabilities(t,!1),s=r.hostServices?this.wrapHostServices(t,r.hostServices):void 0,a=this.auditSink,o=(l)=>{throw a("plugin.capability.denied",{plugin:t.name,capability:`routeDeps.${l}`}),Error(`Plugin '${t.name}' may not use routeDeps.${l}: untrusted plugins receive only capability-scoped host services`)};return new Proxy({},{get(l,g){if(g==="hostServices")return s;if(g==="broadcast")return n.broadcast?r.broadcast:()=>o("broadcast");if(typeof g==="string")return o(g);return}})}isTrustedLoadedPlugin(t){for(let[r,i]of this.loaded)if(i===t)return ft(r);return!1}acceptCapabilities(t,r){if(t.capabilities?.singletonOnly===!0&&N.size()>1)return e().logger.error("plugin-manager",`[plugin] '${t.name}' refused to load: singletonOnly capability incompatible with multi-profile daemon (profiles=${N.size()}, source=${r})`),!1;if(t.capabilities)return!0;if(V())return e().logger.error("plugin-manager",`[plugin] '${t.name}' refused to load: missing required capabilities declaration (source=${r})`),!1;if(r.startsWith("core:"))e().logger.warn("plugin-manager",`[plugin] '${t.name}' loaded without a capabilities declaration \u2014 granting full trust (core plugin). Declare capabilities explicitly. (source=${r})`);else e().logger.warn("plugin-manager",`[plugin] '${t.name}' loaded without a capabilities declaration \u2014 defaulting to EMPTY capability set (deny by default). External plugins MUST declare capabilities explicitly to access host services. (source=${r})`);return!0}ensureDir(){let t=I();if(!y(t))F(t,{recursive:!0})}loadRegistry(){let t=p(I(),K);try{if(y(t)){let r=x(t,"utf-8"),i=JSON.parse(r);if(Array.isArray(i)&&i.every(Oe))this.registry=i.filter((n)=>{try{return le(n.packageName),!0}catch(s){return e().logger.warn("plugin-manager","Ignoring invalid plugin entry",{packageName:n.packageName,error:String(s)}),!1}});else throw Error("plugins.json has an invalid schema")}}catch(r){e().logger.warn("plugin-manager","Failed to load plugin registry",{path:t,error:String(r)}),this.registry=[]}}saveRegistry(){this.ensureDir();let t=p(I(),K),r=`${t}.${process.pid}.tmp`;M(r,`${JSON.stringify(this.registry,null,2)}
|
|
3
|
-
`,{encoding:"utf-8",mode:384}),Pe(r,t)}async loadCorePlugins(){let t=await Promise.allSettled([import("./index-thm1bzpj.js"),import("./index-t6p4szqx.js"),import("./index-hsrt2v87.js"),import("./index-xtd0j8ve.js"),import("./index-x83tcr8f.js"),import("./index-7gk1x74m.js")]),r=e();for(let i=0;i<t.length;i++){let n=t[i],s=C[i];if(n.status==="fulfilled"){let a=n.value,o;try{o=this.extractPlugin(a,`core:${s}`,r)}catch(l){e().logger.error("plugin-manager",`Core plugin '${s}' refused to load: ${l instanceof Error?l.message:String(l)}`);continue}if(o?.name){if(!this.acceptCapabilities(o,`core:${s}`))continue;this.corePlugins.set(o.name,o),e().logger.info("plugin-manager",`Core plugin loaded: ${o.name} v${o.version}`)}else e().logger.warn("plugin-manager",`Core plugin '${s}' did not export a valid createPlugin(ctx) factory`)}else e().logger.warn("plugin-manager",`Failed to load core plugin '${s}': ${n.reason}`)}e().logger.info("plugin-manager",`Core plugins loaded: ${this.corePlugins.size}/${C.length}`)}async resolveConcreteLatest(t,r){try{let n=`${r.replace(/\/+$/,"")}/${t.replace("/","%2F")}`,s=await fetch(n,{headers:{accept:"application/json"},signal:AbortSignal.timeout(20000)});if(!s.ok)return;let o=(await s.json())["dist-tags"]?.latest;if(typeof o==="string"&&/^\d+\.\d+\.\d+/.test(o))return o}catch{}return}async install(t,r={}){return this.withLifecycleLock(()=>this.installLocked(t,r))}async installLocked(t,r={}){t=le(t);let i=r.version?.trim()||void 0,n=r.refreshLatest===!0||!!i;e().logger.info("plugin-manager",`Installing ${t}${n?"@latest (refresh)":""}...`);let s=se();if(Ie(s),await Ce(t,s,void 0),!n)try{await import(t),e().logger.info("plugin-manager",`${t} already resolvable \u2014 skipping global install`);let c=await this.importPlugin(t),f={packageName:t,version:c.version,pluginName:c.name,installedAt:new Date().toISOString()};return this.registry=this.registry.filter((v)=>v.packageName!==t),this.registry.push(f),this.saveRegistry(),f}catch{}let a=se(),o=T(),l=i?i:n?await this.resolveConcreteLatest(t,a):void 0,g=n?`${t}@${l??"latest"}`:t;try{if(o==="local"){let c=p(I(),"agent-plugins");if(!y(c))F(c,{recursive:!0});let f=p(c,"package.json");if(!y(f))M(f,JSON.stringify({name:"vibecontrols-agent-plugins",private:!0,version:"0.0.0",dependencies:{}},null,2)+`
|
|
4
|
-
`);if(n&&l){let m=this.readInstalledVersion(p(c,"node_modules"),t);if(m&&m!==l){e().logger.info("plugin-manager",`Pre-clean ${t}: on-disk v${m} != target v${l} \u2014 removing stale copy + lockfile to force fresh resolve`);try{h(p(c,"node_modules",t),{recursive:!0,force:!0})}catch{}try{h(p(c,"bun.lock"),{force:!0}),h(p(c,"bun.lockb"),{force:!0})}catch{}}try{h(p(c,"bun.lock"),{force:!0}),h(p(c,"bun.lockb"),{force:!0})}catch{}}if(Bun.spawnSync(["bun","add",g,"--registry",a],{cwd:c,timeout:120000,stdout:"pipe",stderr:"pipe"}).exitCode!==0){let m=Bun.spawnSync(["npm","install",g,"--registry",a],{cwd:c,timeout:120000,stdout:"pipe",stderr:"pipe"});if(m.exitCode!==0)throw Error(m.stderr.toString().trim())}if(n&&l){let m=this.readInstalledVersion(p(c,"node_modules"),t);if(m!==l){e().logger.warn("plugin-manager",`bun kept ${t}@${m??"missing"} after requesting ${l}; retrying with npm after removing stale local copy`);try{h(p(c,"node_modules",t),{recursive:!0,force:!0}),h(p(c,"bun.lock"),{force:!0}),h(p(c,"bun.lockb"),{force:!0}),h(p(c,"package-lock.json"),{force:!0})}catch{}let k=Bun.spawnSync(["npm","install",g,"--registry",a,"--save-exact"],{cwd:c,timeout:120000,stdout:"pipe",stderr:"pipe"});if(k.exitCode!==0)throw Error(k.stderr.toString().trim())}}}else if(Bun.spawnSync(["bun","install","-g",g,"--registry",a],{timeout:120000,stdout:"pipe",stderr:"pipe"}).exitCode!==0){let f=Bun.spawnSync(["npm","install","-g",g,"--registry",a],{timeout:120000,stdout:"pipe",stderr:"pipe"});if(f.exitCode!==0)throw Error(f.stderr.toString().trim())}this.pluginRoots=void 0}catch(c){let f=c instanceof Error?c.message:String(c);if(n)try{await import(t),e().logger.warn("plugin-manager",`Could not refresh ${t} to @latest (${f}); using the already-installed copy`),this.pluginRoots=void 0;let v=await this.importPlugin(t),m={packageName:t,version:v.version,pluginName:v.name,installedAt:new Date().toISOString()};return this.registry=this.registry.filter((k)=>k.packageName!==t),this.registry.push(m),this.saveRegistry(),m}catch{}throw Error(`Failed to install ${t}: ${f}`,{cause:c})}let u=await this.importPlugin(t);if(n&&l&&u.version!==l)e().logger.warn("plugin-manager",`${t} refreshed to ${u.version} but registry latest is ${l} \u2014 a stale resolver/cache may still be in play`);if(this.corePlugins.has(u.name))e().logger.info("plugin-manager",`External plugin '${t}' overrides core plugin '${u.name}'`);let d={packageName:t,version:u.version,pluginName:u.name,installedAt:new Date().toISOString()};return this.registry=this.registry.filter((c)=>c.packageName!==t),this.registry.push(d),this.saveRegistry(),e().logger.info("plugin-manager",`Installed ${t}@${u.version} (${u.name})`),d}async ensureDefaultPlugins(t,r=[],i){let n=[],s=new Set(r),a=i?ye(process.platform,i):A(process.platform);for(let o of a){if(s.has(o.packageName)||s.has(o.pluginName)){e().logger.info("plugin-manager",`${o.packageName} skipped by --skip-plugin`);continue}if(o.isCore&&o.category==="core"){e().logger.info("plugin-manager",`${o.packageName} is bundled with the agent \u2014 skipping auto-install`);continue}if(this.registry.some((g)=>g.packageName===o.packageName)){e().logger.info("plugin-manager",`${o.packageName} already installed, skipping auto-install`);continue}t?.(`Installing ${o.label} (${o.packageName})...`);try{await this.install(o.packageName,{refreshLatest:!0}),n.push(o),t?.(`Installed ${o.label} (${o.packageName})`)}catch(g){let u=g instanceof Error?g.message:String(g);e().logger.error("plugin-manager",`Failed to auto-install ${o.packageName}: ${u}`),t?.(`Failed to install ${o.label}: ${u}`)}}if(n.length>0)this.loadRegistry();return n}async installAndLoad(t,r,i){let n=await this.install(t),s=this.loaded.get(n.packageName);if(s){this.registerPluginProviders(s,i);let a=this.wrapHostServices(s,i);if(s.onServerStart)await s.onServerStart(r,a);if(s.onServerReady)await s.onServerReady(r,a)}return n}async update(t,r){return this.withLifecycleLock(()=>this.updateLocked(t,r))}async updateLocked(t,r){if(t=le(t),e().logger.info("plugin-manager",`Updating ${t}${r?`@${r}`:""}...`),!this.registry.find((a)=>a.packageName===t))throw Error(`Plugin ${t} is not installed. Use 'install' first.`);let n=this.loaded.get(t);if(n)await this.terminateWorkerHost(n.name);this.loaded.delete(t);let s=await this.installLocked(t,{refreshLatest:!0,version:r});return e().logger.info("plugin-manager",`Updated ${t} to v${s.version}`),s}async updateAll(){let t=[];for(let r of[...this.registry])try{let i=await this.update(r.packageName);t.push({packageName:r.packageName,success:!0,version:i.version})}catch(i){t.push({packageName:r.packageName,success:!1,error:i instanceof Error?i.message:String(i)})}return t}async removeAll(t){let r=[],i=[...this.registry];for(let n of i)try{await this.remove(n.packageName,t),r.push({packageName:n.packageName,success:!0})}catch(s){r.push({packageName:n.packageName,success:!1,error:s instanceof Error?s.message:String(s)})}return r}async remove(t,r){return this.withLifecycleLock(()=>this.removeLocked(t,r))}async removeLocked(t,r){t=le(t),e().logger.info("plugin-manager",`Removing ${t}...`);let i=this.loaded.get(t);if(i?.onServerStop)try{await i.onServerStop()}catch(a){e().logger.warn("plugin-manager",`Error stopping ${t}: ${a}`)}if(i)await this.terminateWorkerHost(i.name),r?.serviceRegistry.unregisterPlugin(i.name),this.loaded.delete(t);let n=this.registry.find((a)=>a.packageName===t);if(!i&&n)r?.serviceRegistry.unregisterPlugin(n.pluginName);let s=p(I(),"agent-plugins");try{if(y(p(s,"package.json")))Bun.spawnSync(["bun","remove",t],{cwd:s,timeout:60000,stdout:"pipe",stderr:"pipe"})}catch{}try{Bun.spawnSync(["bun","remove","-g",t],{timeout:60000,stdout:"pipe",stderr:"pipe"})}catch{try{Bun.spawnSync(["npm","uninstall","-g",t],{timeout:60000,stdout:"pipe",stderr:"pipe"})}catch{}}this.pluginRoots=void 0,this.registry=this.registry.filter((a)=>a.packageName!==t),this.saveRegistry(),e().logger.info("plugin-manager",`Removed ${t}`)}async loadAll(){this.loaded.clear();let t=[];for(let r of this.registry)try{le(r.packageName),await this.importPlugin(r.packageName),e().logger.info("plugin-manager",`Loaded ${r.packageName} (${r.pluginName})`)}catch(i){let n=i.code;if(n==="ENOENT_PLUGIN")e().logger.info("plugin-manager",`${r.packageName} not present on disk \u2014 dropping from registry`),t.push(r.packageName);else if(n==="EPLUGIN_LEGACY_SINGLETON")e().logger.warn("plugin-manager",`Skipping ${r.packageName}: ${i instanceof Error?i.message:String(i)}`);else e().logger.warn("plugin-manager",`Failed to load ${r.packageName} \u2014 dropping from registry: ${i}`),t.push(r.packageName)}if(t.length>0){this.registry=this.registry.filter((r)=>!t.includes(r.packageName));try{this.saveRegistry()}catch(r){e().logger.warn("plugin-manager",`Failed to persist pruned registry: ${r}`)}}}async importPlugin(t){t=le(t);let r={},i;{let s=this.getGlobalRoots(),a=!1,o=[],l=!0;for(let g of s){let u=p(g,t);if(!y(u)){o.push({path:u,error:"directory missing"});continue}l=!1;try{i=u,r=await import(u),a=!0;break}catch(d){o.push({path:u,error:d instanceof Error?d.message:String(d)})}try{let d=p(u,"package.json");if(!y(d)){o.push({path:d,error:"package.json missing"});continue}let c=JSON.parse(x(d,"utf8")),f=c.module??c.main??"./index.js",v=p(u,f);i=u,r=await import(v),a=!0;break}catch(d){o.push({path:u,error:d instanceof Error?d.message:String(d)})}}if(!a)try{i=this.resolvePackageRoot(t)??i,r=await import(t),a=!0}catch(g){o.push({path:`bare:${t}`,error:g instanceof Error?g.message:String(g)})}if(!a){let g=o.map((d)=>`${d.path} (${d.error})`).join("; "),u=Error(`Cannot find module '${t}': explicit root attempts and bare import failed: ${g||"(no roots probed)"}`);if(l&&s.length>0)u.code="ENOENT_PLUGIN";throw u}}let n=this.extractPlugin(r,`external:${t}`,e());if(!n){if(this.hasLegacySingleton(r)){let s=Error(`${t} uses removed singleton contract; upgrade to createPlugin(ctx) factory (set VIBECONTROLS_PLUGIN_CONTRACT_V2_ENFORCE=1 to refuse strictly)`);throw s.code="EPLUGIN_LEGACY_SINGLETON",s}throw Error(`${t} does not export a valid createPlugin(ctx) factory`)}if(this.validatePluginExport(n,t,i),!this.acceptCapabilities(n,`external:${t}`))throw Error(`${t} refused to load: missing required capabilities declaration`);if(i)Object.defineProperty(n,Q,{value:i,enumerable:!1,configurable:!1});if(this.logResolvedPlugin(t,n.version,i),this.loaded.set(t,n),this.shouldIsolate(n)){let s=e(),a=new R({modulePath:t,pluginName:n.name,ctx:{name:s.name,dataDir:s.dataDir}});try{await a.start(),this.workerHosts.set(n.name,a),s.logger.info("plugin-manager",`Isolated plugin '${n.name}' running in worker_threads`)}catch(o){try{await a.terminate()}catch{}this.loaded.delete(t);let l=o instanceof Error?o.message:String(o);throw s.logger.error("plugin-manager",`Isolation required for '${n.name}' but worker failed to start (${l}); refusing to load in host process`),Error(`Plugin '${n.name}' requires isolation but the worker failed to start: ${l}`,{cause:o})}}return n}resolvePackageRoot(t){let r=import.meta;if(typeof r.resolve!=="function")return;try{let i=r.resolve(t);if(!i.startsWith("file:"))return;let n=S(L(i));while(n&&n!==S(n)){if(y(p(n,"package.json")))return n;n=S(n)}}catch{return}return}validatePluginExport(t,r,i){if(!z.test(t.name))throw Error(`${r} exports an invalid plugin name`);if(!t.version||t.version.length>64)throw Error(`${r} exports an invalid plugin version`);if(t.description&&t.description.length>500)throw Error(`${r} description is too long`);if(t.cliCommand&&!z.test(t.cliCommand))throw Error(`${r} exports an invalid CLI command`);if(t.apiPrefix){if(!Le.test(t.apiPrefix)||t.apiPrefix.includes("..")||t.apiPrefix.includes("//"))throw Error(`${r} exports an invalid API prefix`)}if(t.publicPaths){if(t.publicPaths.length>20)throw Error(`${r} exports too many public paths`);for(let n of t.publicPaths)if(!Te.test(n)||n.includes("..")||n.includes("//"))throw Error(`${r} exports an invalid public path`)}if(t.dependencies&&t.dependencies.length>20)throw Error(`${r} exports too many dependencies`);if(t.tags){let n=new Set(["backend","frontend","cli","provider","adapter","integration"]);if(t.tags.length>n.size)throw Error(`${r} exports too many tags`);for(let s of t.tags)if(!n.has(s))throw Error(`${r} exports an invalid tag`)}if(t.ui){if(t.ui.title&&t.ui.title.length>120)throw Error(`${r} UI title is too long`);if(t.ui.staticDir){if(!i)throw Error(`${r} UI staticDir requires a package root`);let n=B(i),s=B(t.ui.staticDir);if(!we(s).isDirectory()||!Ne(n,s))throw Error(`${r} UI staticDir must be inside the plugin package`)}}}pluginRoots;getPluginRoots(){if(this.pluginRoots!==void 0)return this.pluginRoots;let t=b(),r=[],i=new Set,n=(a)=>{if(!a||i.has(a)||!y(a))return;i.add(a),r.push(a)},s=process.env.VIBECONTROLS_PLUGIN_ROOTS;if(s)for(let a of s.split(t.pathSep).map((o)=>o.trim()).filter(Boolean))n(a);if(T()==="local")n(Z());else n(p(Se(),".bun","install","global","node_modules")),n(t.npmGlobalRoot());if(this.isRunningFromSource())n(this.agentOwnNodeModules());return this.pluginRoots=r,r}isRunningFromSource(){try{let t=L(import.meta.url);return t.includes(`${j}src${j}`)||t.includes("/src/")}catch{return!1}}agentOwnNodeModules(){try{let t=S(L(import.meta.url)),r="";while(t&&t!==r){if(y(p(t,"package.json")))return p(t,"node_modules");r=t,t=S(t)}}catch{}return null}getGlobalRoots(){return this.getPluginRoots()}readInstalledVersion(t,r){try{let i=p(t,r,"package.json");if(!y(i))return;let n=JSON.parse(x(i,"utf8"));return typeof n.version==="string"?n.version:void 0}catch{return}}logResolvedPlugin(t,r,i){let n=e().logger;n.debug("plugin-manager",`Resolved ${t}@${r}`,{from:i??"(bare import)"});try{let s=[];for(let a of this.getPluginRoots()){let o=p(a,t);if(i&&o===i)continue;let l=this.readInstalledVersion(a,t);if(l&&l!==r)s.push(`${o} (v${l})`)}if(s.length>0)n.warn("plugin-manager",`${t}: loaded v${r} but stale duplicate copy(ies) exist at a different version \u2014 these shadow the active copy across reinstalls. Run \`vibe nuke --all\` to purge them.`,{loadedVersion:r,loadedFrom:i??"(bare import)",shadows:s})}catch{}}extractPlugin(t,r,i){let n=this.findFactory(t);if(n){let s=n(i);if(!this.isVibePlugin(s))throw Error(`plugin '${r}' createPlugin(ctx) factory returned an invalid VibePlugin`);return s}if(this.hasLegacySingleton(t)){let s=`plugin '${r}' uses removed singleton contract; upgrade to createPlugin(ctx) factory`;if(_())throw Error(s);e().logger.warn("plugin-manager",s);return}return}findFactory(t){if(typeof t.createPlugin==="function")return t.createPlugin;let r=t.default;if(r&&typeof r.createPlugin==="function")return r.createPlugin;return}hasLegacySingleton(t){if(this.isVibePlugin(t.vibePlugin))return!0;let r=t.default;if(r&&this.isVibePlugin(r.vibePlugin))return!0;if(this.isVibePlugin(r))return!0;return!1}isVibePlugin(t){if(!t||typeof t!=="object")return!1;let r=t;return typeof r.name==="string"&&typeof r.version==="string"}registerProviders(t,r){this.registerPluginProviders(t,r)}registerPluginProviders(t,r){let n=q(t.name)?.isDefault===!0,s=(a)=>{if(!n)return;r.serviceRegistry.setProviderDefault(a,t.name)};if(t.providers?.tunnel){if(r.serviceRegistry.registerProvider("tunnel",t.providers.tunnel,t.name),s("tunnel"),t.tunnelDomainSuffixes)for(let a of t.tunnelDomainSuffixes)Ht(a)}if(t.providers?.session)r.serviceRegistry.registerProvider("session",t.providers.session,t.name),s("session");if(t.providers?.ai)r.serviceRegistry.registerProvider("ai",t.providers.ai,t.name),s("ai")}async dispatchCliSetup(t,r){for(let i of this.getAllPlugins())if(i.onCliSetup)try{await i.onCliSetup(t,this.wrapHostServices(i,r))}catch(n){e().logger.warn("plugin-manager",`onCliSetup failed for ${i.name}: ${n}`)}}async dispatchServerStart(t,r){let i=this.sortAllByDependencies(),n=[];for(let s of i){if(this.registerPluginProviders(s,r),s.onServerStart){let a=Date.now();try{await s.onServerStart(t,this.wrapHostServices(s,r)),(async()=>{try{let{telemetryService:o}=await import("./telemetry-nmtywcba.js");o.emit("plugin.activated",{plugin_name:s.name,version:s.version,duration_ms:Date.now()-a})}catch{}})()}catch(o){let l=o instanceof Error?o.message:String(o);e().logger.error("plugin-manager",`onServerStart failed for ${s.name}: ${l}`),(async()=>{try{let{telemetryService:u}=await import("./telemetry-nmtywcba.js");u.emit("plugin.failed",{plugin_name:s.name,error_class:o instanceof Error?o.constructor.name:"Error"})}catch{}})();let g=this.registry.find((u)=>u.pluginName===s.name);n.push({plugin:s.name,packageName:g?.packageName,error:l})}}this.registerPluginProviders(s,r)}return{failures:n}}async dispatchServerReady(t,r){for(let i of this.getAllPlugins())if(i.onServerReady)try{await i.onServerReady(t,this.wrapHostServices(i,r))}catch(n){e().logger.warn("plugin-manager",`onServerReady failed for ${i.name}: ${n}`)}}async provisionDefaultPrereqs(t,r,i,n){let s=process.env.VIBE_SKIP_PREREQ_INSTALL==="1",a=process.platform;e().logger.info("plugin-manager",`Provisioning default providers \u2014 agent build v${_e()}, platform=${a}, pluginInstallScope=${T()}, skipInstall=${s}`);let o=(n?ye(process.platform,n):A(process.platform)).map((u)=>u.packageName);if(!s)for(let u of o){if(this.loaded.has(u))continue;try{e().logger.info("plugin-manager",`Installing default meta ${u}`),await this.install(u,{refreshLatest:!0})}catch(d){e().logger.warn("plugin-manager",`Failed to install default meta ${u}: ${d}`)}}let l=this.buildHostPluginsFacade(t,r,i),g=this.attachPluginsFacade(r,l);for(let[u,d]of this.getAllLoaded()){if(!d.provisionProviders)continue;try{await d.provisionProviders(this.wrapHostServices(d,g)),e().logger.info("plugin-manager",`${u}: providers provisioned`)}catch(c){e().logger.warn("plugin-manager",`${u}: provisionProviders failed: ${c}`)}}}buildHostPluginsFacade(t,r,i){return{install:async(n,s)=>{await this.install(n,s??{})},loadProvider:async(n)=>{await this.loadAndStartProvider(n,t,r,i)},runPrereqs:async(n,s)=>{let{runPluginPrereqs:a}=await import("./prereqs-runner-gca0bytz.js"),o=this.loaded.get(n);if(!o)return{satisfied:!1};let l=await a(o,n,t,this.db??null,{skipInstall:s?.skipInstall===!0});return{satisfied:l.noProtocol?!0:l.satisfied}},electDefault:async(n,s)=>{await this.electProviderDefault(n,s,r)},isProviderRegistered:(n,s)=>r.serviceRegistry.listProvidersForType(n).some((a)=>a.pluginName===s),skipInstall:()=>process.env.VIBE_SKIP_PREREQ_INSTALL==="1"}}attachPluginsFacade(t,r){return new Proxy(t,{get(i,n,s){if(n==="plugins")return r;return Reflect.get(i,n,s)}})}async loadAndStartProvider(t,r,i,n){let s=this.loaded.get(t);if(!s)s=await this.importPlugin(t);if(s.createRoutes&&n?.(s))e().logger.info("plugin-manager",`${t}: mounted routes after provisioning`);this.registerPluginProviders(s,i);let a=this.wrapHostServices(s,i);if(s.onServerStart)await s.onServerStart(r,a);if(s.onServerReady)await s.onServerReady(r,a)}async electProviderDefault(t,r,i){if(!i.serviceRegistry.listProvidersForType(t).some((s)=>s.pluginName===r))return;try{let s=await this.getDefaultProvider(t);if(s&&s!==r)return;if(i.serviceRegistry.setProviderDefault(t,r),!s)await this.setDefaultProvider(t,r).catch(()=>{});e().logger.info("plugin-manager",`Elected platform-default '${t}' provider '${r}'`)}catch(s){e().logger.warn("plugin-manager",`Failed to elect default '${t}' provider '${r}': ${s}`)}}async dispatchServerStop(t){for(let r of this.getAllPlugins())if(r.onServerStop)try{await r.onServerStop(t)}catch(i){e().logger.warn("plugin-manager",`onServerStop failed for ${r.name}: ${i}`)}if(t?.reason==="shutdown")await this.terminateAllWorkerHosts()}async runPluginNuke(t,r,i){let n=t?this.loaded.has(t)?[[t,this.loaded.get(t)]]:[]:Array.from(this.loaded.entries()),s=[];for(let[a,o]of n){if(!o.onNuke)continue;try{let l=this.wrapHostServices(o,r),g=await o.onNuke(l,i);s.push({plugin:a,ok:!0,reaped:g?.reaped??[],notes:g?.notes??[]}),e().logger.info("plugin-manager",`onNuke ${i.dryRun?"(dry-run) ":""}completed for ${a}`,{reaped:g?.reaped??[]})}catch(l){let g=l instanceof Error?l.message:String(l);s.push({plugin:a,ok:!1,reaped:[],notes:[],error:g}),e().logger.warn("plugin-manager",`onNuke failed for ${a}: ${g}`)}}return{results:s}}async reloadAll(t,r){await this.dispatchServerStop({reason:"reload"}),await this.terminateAllWorkerHosts();for(let i of this.loaded.values())r.serviceRegistry.unregisterPlugin(i.name);this.loaded.clear(),this.corePlugins.clear(),this.loadRegistry(),await this.loadCorePlugins(),await this.loadAll(),await this.dispatchServerStart(t,r),await this.dispatchServerReady(t,r)}sortAllByDependencies(){let t=this.getAllPlugins(),r=new Map;for(let o of t)r.set(o.name,o);let i=new Set,n=new Set,s=[],a=(o)=>{if(i.has(o))return;if(n.has(o))throw Error(`Plugin dependency cycle detected at '${o}'`);let l=r.get(o);if(!l)return;if(n.add(o),l.dependencies)for(let g of l.dependencies){if(!r.has(g)){e().logger.warn("plugin-manager",`Plugin '${l.name}' depends on missing plugin '${g}'`);continue}a(g)}n.delete(o),i.add(o),s.push(l)};for(let o of t)a(o.name);return s}sortByDependencies(){let t=Array.from(this.loaded.entries()),r=new Map;for(let[a,o]of t)r.set(o.name,a);let i=new Set,n=[],s=(a)=>{if(i.has(a))return;i.add(a);let o=this.loaded.get(a);if(o?.dependencies)for(let g of o.dependencies){let u=r.get(g);if(u&&this.loaded.has(u))s(u)}let l=this.loaded.get(a);if(l)n.push([a,l])};for(let[a]of t)s(a);return n}getPluginByKey(t){for(let[,r]of this.loaded)if(r.name===t)return r;return this.corePlugins.get(t)}getAllPlugins(){let t=new Map;for(let[r,i]of this.corePlugins)t.set(r,i);for(let[,r]of this.loaded)t.set(r.name,r);return Array.from(t.values())}getAllPluginsByTag(t){return this.getAllPlugins().filter((r)=>r.tags?.includes(t)??!1)}resolvePluginChain(t){let r=new Set;for(let s of this.getAllPlugins())r.add(s.name);let i=[],n=-1;for(let s=0;s<t.length;s++){if(t[s].startsWith("-")){n=s;break}if(r.has(t[s]))i.push(t[s]);else{n=s;break}}if(n===-1)return{chain:i,command:"",args:[]};return{chain:i,command:t[n],args:t.slice(n+1)}}async getDefaultProvider(t){if(!this.db)return null;return await this.db.getConfig(`${J}${t}`)??null}async setDefaultProvider(t,r){if(!this.db)throw Error("Cannot set default provider: PluginManager was constructed without a database reference");if(!this.getPluginByKey(r))throw Error(`Plugin '${r}' not found`);await this.db.setConfig(`${J}${t}`,r),e().logger.info("plugin-manager",`Set default '${t}' provider to '${r}'`)}getPluginDetails(){let t=this.getCorePluginDetails(),r=this.getExternalPluginDetails(),i=new Map;for(let n of t)i.set(n.pluginName,n);for(let n of r)i.set(n.pluginName,n);return Array.from(i.values())}getCorePluginDetails(){let t=[];for(let[r,i]of this.corePlugins)t.push({packageName:`@vibecontrols/plugin-${r}`,pluginName:r,version:i.version,description:i.description,tags:i.tags,cliCommand:i.cliCommand,apiPrefix:i.apiPrefix,dependencies:i.dependencies,installedAt:"",loaded:!0,isCore:!0,hasUI:!!i.ui,uiUrl:i.ui?`/ui/${r}`:void 0,hasCliSetup:!!i.onCliSetup,hasServerStart:!!i.onServerStart,hasServerStop:!!i.onServerStop,hasServerReady:!!i.onServerReady,hasProviders:!!(i.providers?.tunnel||i.providers?.session||i.providers?.ai)});return t}getExternalPluginDetails(){return this.registry.map((t)=>{let r=this.loaded.get(t.packageName),i=q(t.pluginName);return{packageName:t.packageName,pluginName:t.pluginName,version:r?.version??t.version,description:r?.description,tags:r?.tags,cliCommand:r?.cliCommand,apiPrefix:r?.apiPrefix,dependencies:r?.dependencies,installedAt:t.installedAt,loaded:!!r,isCore:i?.isCore===!0,hasUI:!!r?.ui,uiUrl:r?.ui?`/ui/${t.pluginName}`:void 0,hasCliSetup:!!r?.onCliSetup,hasServerStart:!!r?.onServerStart,hasServerStop:!!r?.onServerStop,hasServerReady:!!r?.onServerReady,hasProviders:!!(r?.providers?.tunnel||r?.providers?.session||r?.providers?.ai)}})}getRegistry(){return[...this.registry]}getLoaded(t){return this.loaded.get(t)}getAllLoaded(){return new Map(this.loaded)}isInstalled(t){return this.registry.some((r)=>r.packageName===t)}isLoaded(t){return this.loaded.has(t)}}
|
|
5
|
-
export{_e,ie,Y,ye,ht,bi,wi,qi,ft,Pr,Mt,Mr,le,W};
|
package/dist/index-x83tcr8f.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{r,E}from"./index-w0m3jm0s.js";import{e}from"./index-0qjbnyg4.js";import{ht,bi,wi,ft,le}from"./index-tts92sdm.js";import{Et,kt}from"./index-5021rk8n.js";import"./index-kwhx023z.js";import{Xt}from"./index-5ccmrpb5.js";import"./index-mmx2kp76.js";import"./index-qfxwk38p.js";import{xt,pr}from"./index-v16qz1fa.js";import{i,s,A,l,p,o,g,n,F}from"./index-7f2k4g6q.js";import{Q,U}from"./index-vtsd74g0.js";import"./index-0gmhd3hs.js";import"./index-er5k6qtr.js";import{_,y,u}from"./index-t5cfkz1e.js";import{f,m,S,q}from"./index-byerrz46.js";import{timingSafeEqual as me}from"crypto";function fe(){return(process.env.NPM_CONFIG_REGISTRY||process.env.npm_config_registry||"https://registry.npmjs.org").replace(/\/+$/,"")}async function Y(c,k){try{let P=await fetch(`${fe()}/${c}/${k}`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(1e4)});if(P.ok){let a=(await P.json()).dist?.integrity;if(typeof a==="string"&&a.startsWith("sha"))return a}}catch{}try{let P=Bun.spawn({cmd:["npm","view",`${c}@${k}`,"dist.integrity","--json"],stdout:"pipe",stderr:"pipe"});if(await P.exited!==0)return null;let d=(await new Response(P.stdout).text()).trim();if(!d)return null;if(d.startsWith('"'))try{let b=JSON.parse(d);return typeof b==="string"?b:null}catch{return null}return d}catch{return null}}function Z(c,k){let P=Buffer.from(c),t=Buffer.from(k);if(P.length!==t.length)return!1;try{return me(P,t)}catch{return!1}}var ve=bi.map((c)=>({packageName:c.packageName,name:c.pluginName,description:c.description,cliCommand:c.cliCommand,apiPrefix:c.apiPrefix,installed:!1,category:c.category})),H=new Map;function O(c,k){let t=(H.get(c)??Promise.resolve()).then(k,k),a=t.then(()=>{return},()=>{return});return H.set(c,a),a.finally(()=>{if(H.get(c)===a)H.delete(c)}),t}function X(c){return H.has(c)}function ee(c){let k=c.getPluginDetails(),P=new Set(k.map((t)=>t.packageName));return{plugins:ve.map((t)=>({...t,installed:P.has(t.packageName)}))}}function te(c){let{pluginManager:k}=c;return new E().get("/",()=>{let P=k.getPluginDetails();return{plugins:P,count:P.length}}).get("/available",()=>ee(k)).get("/catalog",()=>ee(k)).get("/contributions",({query:P})=>{let t=typeof P?.mountPoint==="string"&&P.mountPoint?P.mountPoint:null,a=[],d=new Map;for(let b of k.getPluginDetails())d.set(b.pluginName,b.packageName);for(let b of k.getAllPlugins()){let N=b.ui;if(!N||!N.contributions||N.contributions.length===0)continue;let v=N.capabilities??{restPaths:[],wsTopics:[],rpcMethods:[]};for(let w of N.contributions){if(t&&w.mountPoint!==t)continue;let h=w.meta,R=h&&typeof h.url==="string"?h.url:null,I=R&&R.startsWith("/")&&!R.startsWith("//")&&!R.includes("\x00")&&!R.includes("..")?R:null;a.push({pluginKey:b.name,pluginPackageName:d.get(b.name),contribution:w,capabilities:w.capabilities??v,url:I??`/ui/${encodeURIComponent(b.name)}`})}}return{contributions:a,count:a.length}}).post("/install",async({body:P,set:t})=>{if(!P.packageName||typeof P.packageName!=="string")return t.status=400,{error:"Missing required field: packageName"};if(P.packageName.startsWith("@burdenoff/"))P.packageName=P.packageName.replace(/^@burdenoff\//,"@vibecontrols/");if(!ft(P.packageName))return t.status=403,{error:"Plugin package is not in the trusted VibeControls catalog"};try{let a=le(P.packageName);if(X(a)){let d=a.split("/").pop()?.replace("vibe-plugin-","");if(k.getAllPlugins().some((N)=>N.name===d))return{success:!0,message:`Plugin ${a} is already installed`,packageName:a,alreadyInstalled:!0};return t.status=409,{error:"Install for this package is already in progress. Wait for it to finish.",packageName:a}}return await O(a,async()=>{let d=a.split("/").pop()?.replace("vibe-plugin-",""),b=d?.startsWith("ai-")?d.slice(3):void 0,N=k.getAllPlugins().find((C)=>C.name===d||C.name===b),v=!!N,w=await k.install(a),h=wi(a);if(h?.integrity){let C=await Y(a,w.version);if(C&&!Z(h.integrity,C)){try{await k.remove(a,c.hostServices)}catch(x){console.warn(`[plugin-mgr] integrity rollback uninstall failed for ${a}:`,x)}return e().audit.emit("agent","plugin.install.rejected",{packageName:a,version:w.version,reason:"integrity_mismatch",expected:h.integrity,actual:C}),t.status=400,{error:"integrity mismatch",expected:h.integrity,actual:C}}if(!C)console.warn(`[plugin-mgr] could not fetch registry integrity for ${a}@${w.version}; accepting the package-manager-verified tarball (pin present but unverifiable)`),e().audit.emit("agent","plugin.install.integrity_unverified",{packageName:a,version:w.version,expected:h.integrity})}else console.warn(`[plugin-mgr] plugin ${a} has no pinned integrity \u2014 accepting npm registry's hash`);let R=k.getAllPlugins().find((C)=>C.name===w.pluginName);if(R){let C=[];if(c.mountPlugin)c.mountPlugin(R);if(c.hostServices){if(v&&N?.onServerStop)try{await N.onServerStop()}catch(L){C.push(`onServerStop failed: ${L instanceof Error?L.message:String(L)}`)}k.registerProviders(R,c.hostServices);let x=k.hostServicesFor(R,c.hostServices);if(R.onServerStart&&c.app)try{await R.onServerStart(c.app,x),k.registerProviders(R,c.hostServices)}catch(L){C.push(`onServerStart failed: ${L instanceof Error?L.message:String(L)}`)}if(R.onServerReady&&c.app)try{await R.onServerReady(c.app,x)}catch(L){C.push(`onServerReady failed: ${L instanceof Error?L.message:String(L)}`)}}if(c.rebuildPluginSurfaces?.(),C.length>0)return t.status=500,{success:!1,message:`Plugin ${a} installed but failed to start`,lifecycleErrors:C,restartRequired:!0}}let I;if(R&&c.app)try{I=await xt(R,a,c.app,c.db,{skipInstall:!!P.skipPrereqs})}catch(C){I=void 0,console.warn(`[plugin-mgr] prereq run failed for ${a}:`,C)}return Xt(c.db),e().audit.emit("agent","plugin.installed",{packageName:a,version:w.version,pluginName:w.pluginName,wasRunning:v}),{success:!0,message:`Plugin ${a} installed and loaded successfully`,prereqs:I?{satisfied:I.satisfied,missing:I.status?.missing??[],pendingSudo:I.pendingSudo,skipped:!!P.skipPrereqs}:void 0}})}catch(a){return t.status=500,{error:"Failed to install plugin",details:String(a)}}},{body:r.Object({packageName:r.String(),skipPrereqs:r.Optional(r.Boolean())})}).post("/prereqs/status",async({body:P,set:t})=>{if(!P.packageName)return t.status=400,{error:"Missing packageName"};let a=P.packageName,d=k.getAllPlugins().find((b)=>b.name===a||k.getLoaded(a)?.name===b.name);if(!d||!c.app)return await pr(c.db,a)??{satisfied:!0,missing:[]};try{let b=await xt(d,a,c.app,c.db,{skipInstall:!0});return{satisfied:b.satisfied,missing:b.status?.missing??[],noProtocol:b.noProtocol}}catch(b){return t.status=500,{error:String(b)}}},{body:r.Object({packageName:r.String()})}).post("/prereqs/install",async({body:P,set:t})=>{if(!P.packageName)return t.status=400,{error:"Missing packageName"};let a=P.packageName,d=k.getAllPlugins().find((b)=>b.name===a||k.getLoaded(a)?.name===b.name);if(!d||!c.app)return t.status=404,{error:"Plugin not loaded"};try{let b=await xt(d,a,c.app,c.db,{skipInstall:!1});return{satisfied:b.satisfied,installed:b.install?.installed??[],pendingSudo:b.pendingSudo,errors:b.install?.errors??[],noProtocol:b.noProtocol}}catch(b){return t.status=500,{error:String(b)}}},{body:r.Object({packageName:r.String(),approveSudo:r.Optional(r.Boolean())})}).post("/prereqs/uninstall",async({body:P,set:t})=>{if(!P.packageName)return t.status=400,{error:"Missing packageName"};let a=P.packageName,d=k.getAllPlugins().find((w)=>w.name===a);if(!d||!d.apiPrefix||!c.app)return t.status=404,{error:"Plugin not loaded"};let b=c.app.handle;if(typeof b!=="function")return t.status=500,{error:"App handle unavailable"};let N=`${d.apiPrefix.replace(/\/+$/,"")}/prereqs/uninstall`,v=await b.call(c.app,new Request(`http://agent.local${N}`,{method:"POST",headers:{"x-vc-profile-rewrite":"1",[Et]:kt()}}));if(v.status===404)return t.status=404,{error:"Plugin has no prereqs/uninstall endpoint"};return v.json()},{body:r.Object({packageName:r.String()})}).post("/nuke",async({body:P,set:t})=>{if(!c.hostServices)return t.status=503,{error:"hostServices unavailable"};let a=c.hostServices.getDataDir?.();return{ok:!0,...await k.runPluginNuke(P.packageName,c.hostServices,{agentDir:a,dryRun:!!P.dryRun})}},{body:r.Object({packageName:r.Optional(r.String()),dryRun:r.Optional(r.Boolean())})}).post("/remove",async({body:P,set:t})=>{if(!P.packageName||typeof P.packageName!=="string")return t.status=400,{error:"Missing required field: packageName"};if(P.packageName.startsWith("@burdenoff/"))P.packageName=P.packageName.replace(/^@burdenoff\//,"@vibecontrols/");if(ht(P.packageName))return{success:!0,message:`Plugin ${P.packageName} is critical and cannot be removed; treating remove as a no-op.`,skipped:!0};try{let a=le(P.packageName);return await O(a,async()=>(await k.remove(a,c.hostServices),c.rebuildPluginSurfaces?.(),Xt(c.db),e().audit.emit("agent","plugin.removed",{packageName:a}),{success:!0,message:`Plugin ${a} removed successfully`}))}catch(a){return t.status=500,{error:"Failed to remove plugin",details:String(a)}}},{body:r.Object({packageName:r.String()})}).post("/update",async({body:P,set:t})=>{if(!P.packageName||typeof P.packageName!=="string")return t.status=400,{error:"Missing required field: packageName"};let a=typeof P.version==="string"&&P.version.trim()?P.version.trim():void 0;if(a&&!/^[0-9][0-9A-Za-z.+-]{0,63}$/.test(a))return t.status=400,{error:`Invalid version "${a}"`};try{let d=le(P.packageName);return await O(d,async()=>{let b=k.getLoaded(d);if(b?.onServerStop)await b.onServerStop({reason:"reload"});if(b&&c.hostServices)c.hostServices.serviceRegistry.unregisterPlugin(b.name);let N=await k.update(d,a),v=k.getLoaded(d);if(v&&c.hostServices){k.registerProviders(v,c.hostServices);let w=k.hostServicesFor(v,c.hostServices);if(v.onServerStart&&c.app)await v.onServerStart(c.app,w),k.registerProviders(v,c.hostServices);if(v.onServerReady&&c.app)await v.onServerReady(c.app,w)}return c.rebuildPluginSurfaces?.(),Xt(c.db),{success:!0,message:`Plugin ${d} updated to v${N.version}`,version:N.version}})}catch(d){return t.status=500,{error:"Failed to update plugin",details:String(d)}}},{body:r.Object({packageName:r.String(),version:r.Optional(r.String())})}).post("/update-all",async({set:P})=>{try{let t=await O("*",()=>k.updateAll());return{success:!0,results:t,message:`Updated ${t.filter((a)=>a.success).length}/${t.length} plugin(s)`}}catch(t){return P.status=500,{error:"Failed to update all plugins",details:String(t)}}}).post("/remove-all",async({set:P})=>{try{let t=await O("*",async()=>{let a=await k.removeAll(c.hostServices);return c.rebuildPluginSurfaces?.(),a});return{success:!0,results:t,message:`Removed ${t.filter((a)=>a.success).length}/${t.length} plugin(s)`}}catch(t){return P.status=500,{error:"Failed to remove all plugins",details:String(t)}}}).post("/reload",async({set:P})=>{try{if(!c.app||!c.hostServices)return P.status=503,{error:"Plugin lifecycle services are not ready"};let t=await O("*",async()=>(await k.reloadAll(c.app,c.hostServices),c.rebuildPluginSurfaces?.(),k.getPluginDetails()));return{success:!0,plugins:t,message:`Reloaded ${t.length} plugin(s)`}}catch(t){return P.status=500,{error:"Failed to reload plugins",details:String(t)}}}).post("/:name/reload",async({params:P,set:t})=>{if(!c.app||!c.hostServices)return t.status=503,{error:"Plugin lifecycle services are not ready"};let a=P.name,d=k.getAllPlugins().find((v)=>v.name===a);if(!d)return t.status=404,{error:`Plugin "${a}" not found`};let N=k.getPluginDetails().find((v)=>v.pluginName===a)?.packageName??`core:${a}`;if(X(N))return t.status=409,{error:"Plugin lifecycle in progress; try again shortly",packageName:N};try{return await O(N,async()=>{if(d.onServerStop)try{await d.onServerStop({reason:"reload"})}catch(w){console.warn(`[plugin-mgr] onServerStop during reload of ${a}:`,w)}if(c.hostServices)c.hostServices.serviceRegistry.unregisterPlugin(d.name);k.registerProviders(d,c.hostServices);let v=k.hostServicesFor(d,c.hostServices);if(d.onServerStart)await d.onServerStart(c.app,v),k.registerProviders(d,c.hostServices);if(d.onServerReady)await d.onServerReady(c.app,v);return c.rebuildPluginSurfaces?.(),{success:!0,message:`Plugin ${a} reloaded`,version:d.version}})}catch(v){return t.status=500,{error:"Failed to reload plugin",details:String(v)}}},{params:r.Object({name:r.String()})})}import{mkdirSync as W,writeFileSync as M,existsSync as ne}from"fs";import{isAbsolute as ye,join as j,relative as he,resolve as G}from"path";var D="http://localhost:3005",be=/^[a-z0-9][a-z0-9-]{0,63}$/,Se=new Set(["backend","frontend","cli","provider","adapter","integration"]);function ie(c,k){let P=he(c,k);if(P.startsWith("..")||ye(P))throw Error("Plugin scaffold path escapes the selected directory.")}function T(c){return JSON.stringify(c)}function re(c){let k=c.command("plugin").description("Manage plugins");k.command("list").description("List installed plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(t)=>{try{let a={...c.opts(),...t},d=f(t),b=encodeURIComponent(m(a)),N=async()=>{try{return(await S(d,`/api/profiles/${b}/plugins`)).plugins||[]}catch{p("Agent not reachable. Attempting local plugin registry...");let{PluginManager:h}=await import("./plugin-system-byzwda4c.js");return new h().getPluginDetails()||[]}},v=(h)=>h.status??(h.loaded===!0||h.enabled===!0?"enabled":"disabled"),w=(h)=>h.pluginName||h.name||h.packageName||h.package||"-";await y({mode:_(a),fetchData:N,plain:(h)=>{if(!h.length){o("No plugins installed.");return}g("Installed Plugins"),F(h.map((R)=>({Name:w(R),Version:R.version||"-",Status:v(R),Description:R.description||"-"})))},interactive:async(h)=>{if(!h.length){g("Installed Plugins"),o("No plugins installed.");return}let R=h.map((I)=>{let C=w(I),x=v(I),L=[`${i.bold(C)} ${x==="enabled"?i.green(x):i.dim(x)}`,"",` Version: ${I.version||"-"}`,` Description: ${I.description||"-"}`];if(I.tags&&Array.isArray(I.tags))L.push(` Tags: ${I.tags.join(", ")}`);if(I.cliCommand)L.push(` CLI command: vibe ${I.cliCommand}`);return{id:C,label:C,hint:x,detail:L.join(`
|
|
3
|
-
`)}});await Q({title:`vibe plugin \u2014 ${h.length} installed`,rows:R,footer:"\u2191/\u2193 navigate \xB7 q to quit"})},json:(h)=>h.map((R)=>({name:w(R),version:R.version??null,status:v(R),description:R.description??null,tags:R.tags??null,cliCommand:R.cliCommand??null}))})}catch(a){s(A(a))}}),k.command("install").description("Install a plugin").argument("<package>","NPM package name to install").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--skip-prereqs","Skip running the plugin's prereqs/install",!1).option("--json","Emit JSON result").action(async(t,a)=>{try{let d={...c.opts(),...a},b=f(a),N=encodeURIComponent(m(d));try{let v=await q(b,`/api/profiles/${N}/plugins/install`,{packageName:t,skipPrereqs:!!a.skipPrereqs});if(u(d,{ok:!0,action:"install",package:t,version:v?.version??null,prereqs:v?.prereqs??null}))return;if(l(`Plugin "${t}" installed.`),v?.version)n("Version",v.version);if(v?.prereqs){let w=v.prereqs;if(w.skipped)p(`Prerequisite install skipped. Run \`vibe plugin prereqs ${t} install\` later.`);else if(!w.satisfied)p(`Prerequisites not yet satisfied: ${(w.missing||[]).map((h)=>h.name).join(", ")||"(unknown)"}`);if((w.pendingSudo||[]).length>0){p(`${w.pendingSudo.length} command(s) need sudo. Run them and re-check with \`vibe plugin prereqs ${t} status\`:`);for(let h of w.pendingSudo)n(` ${h.name}`,h.command)}}}catch{p("Agent not reachable. Attempting local install...");try{let{PluginManager:v}=await import("./plugin-system-byzwda4c.js");if(await new v().install(t),u(d,{ok:!0,action:"install",package:t,local:!0}))return;l(`Plugin "${t}" installed locally.`)}catch(v){s(`Could not install plugin via agent or locally: ${A(v)}`)}}}catch(d){s(A(d))}}),k.command("remove").description("Remove a plugin").argument("<package>","NPM package name to remove").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(t,a)=>{try{let d={...c.opts(),...a},b=f(a),N=encodeURIComponent(m(d));try{if(await q(b,`/api/profiles/${N}/plugins/remove`,{packageName:t}),u(d,{ok:!0,action:"remove",package:t}))return;l(`Plugin "${t}" removed.`)}catch{p("Agent not reachable. Attempting local removal...");try{let{PluginManager:v}=await import("./plugin-system-byzwda4c.js");if(await new v().remove(t),u(d,{ok:!0,action:"remove",package:t,local:!0}))return;l(`Plugin "${t}" removed locally.`)}catch(v){s(`Could not remove plugin via agent or locally: ${A(v)}`)}}}catch(d){s(A(d))}}),k.command("update").description("Update a plugin (or all plugins with --all)").argument("[package]","NPM package name to update").option("--all","Update all installed plugins",!1).option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(t,a)=>{try{let d={...c.opts(),...a},b=f(a),N=encodeURIComponent(m(d));if(a.all){o("Updating all plugins...");try{let v=await q(b,`/api/profiles/${N}/plugins/update-all`,{}),w=v?.results||[];if(u(d,{ok:!0,action:"update-all",results:w}))return;for(let h of w)if(h.success)l(`Updated ${h.packageName}${h.version?` to v${h.version}`:""}`);else p(`Failed to update ${h.packageName}: ${h.error}`);l(v?.message||"Done.")}catch{p("Agent not reachable. Attempting local update...");try{let{PluginManager:v}=await import("./plugin-system-byzwda4c.js"),h=await new v().updateAll();if(u(d,{ok:!0,action:"update-all",results:h,local:!0}))return;for(let R of h)if(R.success)l(`Updated ${R.packageName}${R.version?` to v${R.version}`:""}`);else p(`Failed to update ${R.packageName}: ${R.error}`)}catch(v){s(`Could not update plugins: ${A(v)}`)}}}else if(t){o(`Updating ${t}...`);try{let v=await q(b,`/api/profiles/${N}/plugins/update`,{packageName:t});if(u(d,{ok:!0,action:"update",package:t,version:v?.version??null,message:v?.message??null}))return;l(v?.message||`Plugin "${t}" updated.`)}catch{p("Agent not reachable. Attempting local update...");try{let{PluginManager:v}=await import("./plugin-system-byzwda4c.js"),h=await new v().update(t);if(u(d,{ok:!0,action:"update",package:t,version:h.version,local:!0}))return;l(`Plugin "${t}" updated to v${h.version}.`)}catch(v){s(`Could not update plugin: ${A(v)}`)}}}else s("Provide a package name to update, or use --all to update all plugins.")}catch(d){s(A(d))}}),k.command("uninstall").description("Uninstall a plugin (or all plugins with --all)").argument("[package]","NPM package name to uninstall").option("--all","Uninstall all external plugins",!1).option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(t,a)=>{try{let d={...c.opts(),...a},b=f(a),N=encodeURIComponent(m(d));if(a.all){o("Uninstalling all plugins...");try{let v=await q(b,`/api/profiles/${N}/plugins/remove-all`,{}),w=v?.results||[];if(u(d,{ok:!0,action:"uninstall-all",results:w}))return;for(let h of w)if(h.success)l(`Removed ${h.packageName}`);else p(`Failed to remove ${h.packageName}: ${h.error}`);l(v?.message||"Done.")}catch{p("Agent not reachable. Attempting local removal...");try{let{PluginManager:v}=await import("./plugin-system-byzwda4c.js"),h=await new v().removeAll();if(u(d,{ok:!0,action:"uninstall-all",results:h,local:!0}))return;for(let R of h)if(R.success)l(`Removed ${R.packageName}`);else p(`Failed to remove ${R.packageName}: ${R.error}`)}catch(v){s(`Could not uninstall plugins: ${A(v)}`)}}}else if(t)try{if(await q(b,`/api/profiles/${N}/plugins/remove`,{packageName:t}),u(d,{ok:!0,action:"uninstall",package:t}))return;l(`Plugin "${t}" uninstalled.`)}catch{p("Agent not reachable. Attempting local removal...");try{let{PluginManager:v}=await import("./plugin-system-byzwda4c.js");if(await new v().remove(t),u(d,{ok:!0,action:"uninstall",package:t,local:!0}))return;l(`Plugin "${t}" uninstalled locally.`)}catch(v){s(`Could not uninstall plugin: ${A(v)}`)}}else s("Provide a package name to uninstall, or use --all to uninstall all plugins.")}catch(d){s(A(d))}}),k.command("reload").description("Reload all plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(t)=>{try{let a={...c.opts(),...t},d=f(t),b=encodeURIComponent(m(a));if(await q(d,`/api/profiles/${b}/plugins/reload`,{}),u(a,{ok:!0,action:"reload"}))return;l("Plugins reloaded.")}catch(a){s(A(a))}}),k.command("available").description("Show available plugins").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(t)=>{try{let a={...c.opts(),...t},d=f(t),b=encodeURIComponent(m(a)),N=async()=>(await S(d,`/api/profiles/${b}/plugins/available`)).plugins||[],v=(h)=>h.name||h.package||"-",w=(h)=>h.version||h.latestVersion||"-";await y({mode:_(a),fetchData:N,plain:(h)=>{if(!h||h.length===0){o("No available plugins found.");return}g("Available Plugins"),F(h.map((R)=>({Name:v(R),Version:w(R),Description:R.description||"-"})))},interactive:async(h)=>{if(!h||h.length===0){g("Available Plugins"),o("No available plugins found.");return}let R=h.map((I)=>{let C=v(I),x=[i.bold(C),"",` Version: ${w(I)}`,` Description: ${I.description||"-"}`];return{id:C,label:C,hint:w(I),detail:x.join(`
|
|
4
|
-
`)}});await Q({title:`vibe plugin available \u2014 ${h.length} plugin(s)`,rows:R,footer:"\u2191/\u2193 navigate \xB7 q to quit"})},json:(h)=>h.map((R)=>({name:v(R),version:w(R),description:R.description??null}))})}catch(a){s(A(a))}});let P=k.command("prereqs").description("Inspect or run a plugin's prerequisite-install protocol").argument("<package>","NPM package name (or short plugin name)");P.command("status",{isDefault:!0}).description("Show the plugin's prereq status").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON").option("--plain","Force plain text output").action(async(t,a)=>{let d=a.parent?.args?.[0];if(!d){s("Missing plugin package argument.");return}try{let b={...c.opts(),...t},N=f(t),v=async()=>q(N,"/api/plugins/prereqs/status",{packageName:d});await y({mode:_(b),fetchData:v,plain:(w)=>{if(n("Plugin",d),n("Satisfied",w?.satisfied?"yes":"no"),Array.isArray(w?.missing)&&w.missing.length>0)n("Missing",w.missing.map((h)=>h.name).join(", "))},interactive:async(w)=>{let h=[`Plugin: ${d}`,`Satisfied: ${w?.satisfied?"yes":"no"}`];if(Array.isArray(w?.missing)&&w.missing.length>0)h.push(`Missing: ${w.missing.map((R)=>R.name).join(", ")}`);await U({title:`Prereqs: ${d}`,body:h.join(`
|
|
5
|
-
`),footer:"q / Esc to quit"})},json:(w)=>({plugin:d,satisfied:!!w?.satisfied,missing:Array.isArray(w?.missing)?w.missing:[],pendingSudo:Array.isArray(w?.pendingSudo)?w.pendingSudo:[]})})}catch(b){s(`Could not read prereq status: ${A(b)}`)}}),P.command("install").description("Run the plugin's prerequisite install endpoint").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--approve-sudo","Auto-approve sudo commands the plugin returns",!1).option("--json","Emit JSON result").action(async(t,a)=>{let d=a.parent?.args?.[0];if(!d){s("Missing plugin package argument.");return}try{let b={...c.opts(),...t},N=f(t),v=await q(N,"/api/plugins/prereqs/install",{packageName:d,approveSudo:!!t.approveSudo});if(u(b,{ok:!0,action:"prereqs-install",plugin:d,satisfied:!!v?.satisfied,pendingSudo:v?.pendingSudo??[]}))return;if(v?.satisfied)l(`Prerequisites satisfied for ${d}.`);else p(`Prerequisites still missing for ${d}.`);if(Array.isArray(v?.pendingSudo)&&v.pendingSudo.length>0){p(`${v.pendingSudo.length} command(s) require sudo:`);for(let w of v.pendingSudo)n(` ${w.name}`,w.command)}}catch(b){s(`Prereq install failed: ${A(b)}`)}}),P.command("uninstall").description("Run the plugin's prerequisite uninstall endpoint (if supported)").option("--agent-url <url>","Agent URL",D).option("--profile <name>","Target a specific profile by name").option("--json","Emit JSON result").action(async(t,a)=>{let d=a.parent?.args?.[0];if(!d){s("Missing plugin package argument.");return}try{let b={...c.opts(),...t},N=f(t);if(await q(N,"/api/plugins/prereqs/uninstall",{packageName:d}),u(b,{ok:!0,action:"prereqs-uninstall",plugin:d}))return;l(`Prereq uninstall completed for ${d}.`)}catch(b){p(`Prereq uninstall not supported or failed: ${A(b)}`)}}),k.command("create").description("Scaffold a new plugin project").argument("<name>",'Plugin name (e.g. "docker" \u2192 vibe-plugin-docker)').option("-d, --dir <directory>","Parent directory",".").option("--tag <tag>","Plugin tag (backend, frontend, cli, provider, adapter, integration)","backend").option("--with-ui","Include a companion UI plugin scaffold",!1).option("--json","Emit JSON result").action(async(t,a)=>{try{let d={...c.opts(),...a},b=t.startsWith("vibe-plugin-")?t.slice(12):t;if(!be.test(b)){s("Plugin name must use lowercase letters, numbers, and dashes only.");return}let N=a.tag;if(!Se.has(N)){s("Invalid plugin tag.");return}let v=`vibe-plugin-${b}`,w=G(a.dir),h=G(w,v);if(ie(w,h),ne(h)){s(`Directory "${h}" already exists.`);return}o(`Scaffolding ${v}...`),W(j(h,"src"),{recursive:!0}),W(j(h,"dist"),{recursive:!0});let R=`VibeControls plugin: ${b}`,I={name:`@vibecontrols/${v}`,version:"0.1.0",main:"./dist/index.js",type:"module",engines:{bun:">=1.3.0"},scripts:{build:"bun build ./src/index.ts --outdir ./dist --target bun",lint:"eslint ./src",format:"bunx prettier . --write","format:check":"bunx prettier . --check","type:check":"tsc --noEmit",clean:"rimraf dist",prebuild:"bun run clean",prepublishOnly:"bun run build",sanity:"bun run format:check && bun run lint && bun run type:check && bun run build"},keywords:["vibecontrols","vibe","vibe-plugin",b,"bun"],author:{name:"Your Name",email:"you@example.com"},license:"SEE LICENSE IN LICENSE",description:R,devDependencies:{"@types/bun":"^1.2.16","bun-types":"^1.3.9",commander:"^14.0.3",eslint:"^9.30.1",prettier:"^3.6.2",rimraf:"^6.0.1",typescript:"^5.8.3","typescript-eslint":"^8.56.0"},peerDependencies:{"@vibecontrols/agent":">=2.0.0"},peerDependenciesMeta:{"@vibecontrols/agent":{optional:!0}},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},files:["dist/**/*","README.md","LICENSE"]};M(j(h,"package.json"),JSON.stringify(I,null,2)+`
|
|
6
|
-
`);let C={compilerOptions:{target:"ES2022",module:"ES2022",moduleResolution:"bundler",types:["bun-types"],strict:!0,esModuleInterop:!0,skipLibCheck:!0,outDir:"./dist",rootDir:"./src",declaration:!0,sourceMap:!0},include:["src/**/*.ts"],exclude:["node_modules","dist"]};M(j(h,"tsconfig.json"),JSON.stringify(C,null,2)+`
|
|
7
|
-
`),M(j(h,".gitignore"),["node_modules/","dist/","bun.lock",".env",".env.local","*.tgz"].join(`
|
|
8
|
-
`)+`
|
|
9
|
-
`);let x=b,L=T(v),K=T(R),se=T(N),z=T(x),oe=`import type { Command } from "commander";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @vibecontrols/${v}
|
|
13
|
-
*
|
|
14
|
-
* ${R}
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// \u2500\u2500 Plugin Interfaces \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
18
|
-
|
|
19
|
-
export interface HostServices {
|
|
20
|
-
logger?: {
|
|
21
|
-
info: (msg: string) => void;
|
|
22
|
-
warn: (msg: string) => void;
|
|
23
|
-
error: (msg: string) => void;
|
|
24
|
-
debug: (msg: string) => void;
|
|
25
|
-
};
|
|
26
|
-
config?: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface VibePlugin {
|
|
30
|
-
name: string;
|
|
31
|
-
version: string;
|
|
32
|
-
description: string;
|
|
33
|
-
tags?: Array<
|
|
34
|
-
"backend" | "frontend" | "cli" | "provider" | "adapter" | "integration"
|
|
35
|
-
>;
|
|
36
|
-
cliCommand: string;
|
|
37
|
-
onCliSetup: (program: Command, hostServices?: HostServices) => void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// \u2500\u2500 Plugin Implementation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
41
|
-
|
|
42
|
-
const plugin: VibePlugin = {
|
|
43
|
-
name: ${L},
|
|
44
|
-
version: "0.1.0",
|
|
45
|
-
description: ${K},
|
|
46
|
-
tags: [${se}],
|
|
47
|
-
cliCommand: ${z},
|
|
48
|
-
|
|
49
|
-
onCliSetup(program: Command, _hostServices?: HostServices): void {
|
|
50
|
-
const cmd = program
|
|
51
|
-
.command(${z})
|
|
52
|
-
.description(${K});
|
|
53
|
-
|
|
54
|
-
cmd
|
|
55
|
-
.command("status")
|
|
56
|
-
.description(`+T(`Show ${b} status`)+`)
|
|
57
|
-
.action(() => {
|
|
58
|
-
console.log(`+T(`${v} is ready.`)+`);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
cmd
|
|
62
|
-
.command("info")
|
|
63
|
-
.description("Show plugin info")
|
|
64
|
-
.action(() => {
|
|
65
|
-
console.log(JSON.stringify({
|
|
66
|
-
name: plugin.name,
|
|
67
|
-
version: plugin.version,
|
|
68
|
-
description: plugin.description,
|
|
69
|
-
tags: plugin.tags,
|
|
70
|
-
}, null, 2));
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default plugin;
|
|
76
|
-
`;M(j(h,"src","index.ts"),oe);let ce=`# ${v}
|
|
77
|
-
|
|
78
|
-
${R}
|
|
79
|
-
|
|
80
|
-
## Installation
|
|
81
|
-
|
|
82
|
-
\`\`\`bash
|
|
83
|
-
vibe plugin install @vibecontrols/${v}
|
|
84
|
-
\`\`\`
|
|
85
|
-
|
|
86
|
-
## Usage
|
|
87
|
-
|
|
88
|
-
\`\`\`bash
|
|
89
|
-
vibe ${x} status
|
|
90
|
-
vibe ${x} info
|
|
91
|
-
\`\`\`
|
|
92
|
-
|
|
93
|
-
## Development
|
|
94
|
-
|
|
95
|
-
\`\`\`bash
|
|
96
|
-
bun install
|
|
97
|
-
bun run build
|
|
98
|
-
bun run sanity
|
|
99
|
-
\`\`\`
|
|
100
|
-
|
|
101
|
-
## Publishing
|
|
102
|
-
|
|
103
|
-
\`\`\`bash
|
|
104
|
-
bun run build
|
|
105
|
-
npm publish
|
|
106
|
-
\`\`\`
|
|
107
|
-
`;M(j(h,"README.md"),ce);let V={ok:!0,action:"create",plugin:v,packageName:`@vibecontrols/${v}`,cliCommand:x,tag:N,dir:h,withUi:a.withUi===!0};if(!d.json)l(`Created ${v} at ${h}`),n("Plugin Name",`@vibecontrols/${v}`),n("CLI Command",`vibe ${x}`),n("Tag",N),o(`
|
|
108
|
-
Next steps:`),o(` cd ${v}`),o(" bun install"),o(" bun run build"),o(` publish @vibecontrols/${v}, then install from catalog`);if(a.withUi){let B=`${v.replace("vibe-plugin-","vibe-plugin-ui-")}`,J=G(w,B);if(ie(w,J),ne(J)){if(!d.json)p(`UI directory "${J}" already exists, skipping.`);V.uiSkipped=!0,V.uiDir=J}else{W(j(J,"src"),{recursive:!0}),W(j(J,"public"),{recursive:!0});let ue={name:`@vibecontrols/${B}`,version:"0.1.0",private:!1,type:"module",scripts:{dev:"vite --port 5180",build:"tsc && vite build",preview:"vite preview",lint:"eslint ./src",format:"bunx prettier . --write","format:check":"bunx prettier . --check","type:check":"tsc --noEmit",sanity:"bun run format:check && bun run lint && bun run type:check && bun run build"},keywords:["vibecontrols","vibe-plugin","ui",b],author:{name:"Your Name",email:"you@example.com"},license:"SEE LICENSE IN LICENSE",description:`UI for ${v}`,dependencies:{react:"^19.0.0","react-dom":"^19.0.0"},devDependencies:{"@types/react":"^19.0.0","@types/react-dom":"^19.0.0","@vitejs/plugin-react":"^4.5.2",typescript:"^5.8.3",vite:"^7.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},files:["dist/**/*","README.md"]};M(j(J,"package.json"),JSON.stringify(ue,null,2)+`
|
|
109
|
-
`);let ge=`import React from "react";
|
|
110
|
-
import ReactDOM from "react-dom/client";
|
|
111
|
-
import App from "./App";
|
|
112
|
-
|
|
113
|
-
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
114
|
-
<React.StrictMode>
|
|
115
|
-
<App />
|
|
116
|
-
</React.StrictMode>
|
|
117
|
-
);
|
|
118
|
-
`;M(j(J,"src","main.tsx"),ge);let pe=`import { useState, useEffect } from "react";
|
|
119
|
-
|
|
120
|
-
const TITLE = ${T(`${b} UI`)};
|
|
121
|
-
|
|
122
|
-
export default function App() {
|
|
123
|
-
const [apiKey, setApiKey] = useState<string | null>(null);
|
|
124
|
-
const [status, setStatus] = useState("loading...");
|
|
125
|
-
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
// Auth via postMessage (iframe) or URL param (new tab)
|
|
128
|
-
const params = new URLSearchParams(window.location.search);
|
|
129
|
-
const key = params.get("apiKey");
|
|
130
|
-
if (key) {
|
|
131
|
-
setApiKey(key);
|
|
132
|
-
setStatus("connected");
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const handler = (e: MessageEvent) => {
|
|
137
|
-
if (e.data?.type === "vibe-auth" && e.data.apiKey) {
|
|
138
|
-
setApiKey(e.data.apiKey);
|
|
139
|
-
setStatus("connected");
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
window.addEventListener("message", handler);
|
|
143
|
-
return () => window.removeEventListener("message", handler);
|
|
144
|
-
}, []);
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<div style={{ background: "var(--vibe-surface, Canvas)", color: "var(--vibe-text, CanvasText)", minHeight: "100vh", padding: 24, fontFamily: "system-ui" }}>
|
|
148
|
-
<h1>{TITLE}</h1>
|
|
149
|
-
<p>Status: {status}</p>
|
|
150
|
-
{apiKey && <p style={{ color: "var(--vibe-success, CanvasText)" }}>Authenticated</p>}
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
`;M(j(J,"src","App.tsx"),pe);let de=`<!DOCTYPE html>
|
|
155
|
-
<html lang="en">
|
|
156
|
-
<head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>${b} UI</title></head>
|
|
157
|
-
<body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body>
|
|
158
|
-
</html>`;if(M(j(J,"index.html"),de),!d.json)l(`Created UI plugin ${B} at ${J}`);V.uiPluginName=B,V.uiPackageName=`@vibecontrols/${B}`,V.uiDir=J}}u(d,V)}catch(d){s(A(d))}})}function ae(c,k){re(c)}function Fe(c){return{name:"plugin-mgr",version:"2.2.0",description:"Plugin lifecycle management \u2014 install, remove, reload, catalog",capabilities:{storage:"rw",subprocess:!0,gateway:!0,audit:!0,telemetry:!0},tags:["backend","cli"],cliCommand:"plugin",apiPrefix:"/api/plugins",createRoutes:(k)=>te(k),onCliSetup:async(k,P)=>{ae(k,P)}}}export{Fe as createPlugin};
|