bridge-agent 0.1.0-beta.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -341,7 +341,7 @@ Summarize: todos completed, failed, any blockers. List what workers did.
341
341
 
342
342
  ${qo("bridge_get_project","bridge_get_plan","bridge_get_todos","bridge_add_todo","bridge_cancel_run","bridge_get_project_history","bridge_get_execution_status","bridge_list_agents","bridge_get_agent_status","bridge_spawn_worker","bridge_assign_task","bridge_get_todo_context","bridge_get_agent_output","bridge_kill_agent")}`};function Vo(r,e,t){if(!e)return[];let n=rs[e];if(!n)return[];if(r==="claude")try{let s=L.default.join(ve.default.tmpdir(),`bridge-role-${t}.md`),i=n.replaceAll("{{PANEL_ID}}",t);return Z.default.writeFileSync(s,i+`
343
343
  `,"utf-8"),console.log("[daemon] role.prompt.written",{agentId:t,role:e,tmpPath:s}),["--append-system-prompt-file",s]}catch(s){return console.warn("[daemon] role.prompt.write.failed",{agentId:t,role:e,error:String(s)}),[]}return r==="qwen"?["--append-system-prompt",n]:[]}function xe(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ho(r){try{let e=process.env.BRIDGE_MCP_URL,t=e?{mcpServers:{bridge:{type:"http",url:`${e}/mcp/${r.workspaceId}/${r.projectId}`,headers:{Authorization:`Bearer ${r.token}`,"x-panel-id":r.agentId??""}}}}:{mcpServers:{bridge:{command:Ze(),args:[],env:{BRIDGE_SERVER_URL:r.serverUrl,BRIDGE_TOKEN:r.token,BRIDGE_WORKSPACE_ID:r.workspaceId,BRIDGE_PROJECT_ID:r.projectId,BRIDGE_PANEL_ID:r.agentId??"",HTTP_MODE:"false"}}}},n=L.default.join(ve.default.tmpdir(),`bridge-mcp-kimi-${r.agentId??r.projectId}.json`);return Z.default.writeFileSync(n,JSON.stringify(t,null,2)+`
344
- `,"utf-8"),console.log("[daemon] kimi.mcp.config.written",{tmpPath:n,transport:e?"http":"stdio"}),["--mcp-config-file",n]}catch(e){return console.warn("[daemon] kimi.mcp.config.build.failed",{error:String(e)}),[]}}function Go(r){try{let e=Ze(),t=`{BRIDGE_SERVER_URL=${xe(r.serverUrl)},BRIDGE_TOKEN=${xe(r.token)},BRIDGE_WORKSPACE_ID=${xe(r.workspaceId)},BRIDGE_PROJECT_ID=${xe(r.projectId)},HTTP_MODE="false"}`;return["-c",'mcp_servers.bridge.transport="stdio"',"-c",`mcp_servers.bridge.command=${xe(e)}`,"-c","mcp_servers.bridge.args=[]","-c",`mcp_servers.bridge.env=${t}`]}catch(e){return console.warn("[daemon] codex.mcp.config.build.failed",{error:String(e)}),[]}}function Ko(r){try{if(!r.cwd)return console.warn("[daemon] qwen.mcp.setup.skipped",{reason:"missing_cwd",projectId:r.projectId}),!1;let e=Ze(),t={cwd:r.cwd,encoding:"utf-8",timeout:5e3,stdio:"pipe"};(0,Jt.spawnSync)("qwen",["mcp","remove","--scope","project","bridge"],t);let n=(0,Jt.spawnSync)("qwen",["mcp","add","--scope","project","-t","stdio","-e",`BRIDGE_SERVER_URL=${r.serverUrl}`,"-e",`BRIDGE_TOKEN=${r.token}`,"-e",`BRIDGE_WORKSPACE_ID=${r.workspaceId}`,"-e",`BRIDGE_PROJECT_ID=${r.projectId}`,"-e",`BRIDGE_PANEL_ID=${r.agentId??""}`,"-e","HTTP_MODE=false","bridge",e],t);return n.status===0?(console.log("[daemon] qwen.mcp.setup.ok",{cwd:r.cwd,projectId:r.projectId}),!0):(console.warn("[daemon] qwen.mcp.setup.failed",{cwd:r.cwd,projectId:r.projectId,status:n.status,stderr:(n.stderr??"").toString().slice(0,300)}),!1)}catch(e){return console.warn("[daemon] qwen.mcp.setup.error",{error:String(e),projectId:r.projectId}),!1}}var Qe=[],Qt=!1,es=!1;function ns(){return Qt}function ss(r){if(es)throw new Error("[daemon] startDaemonConnection called twice \u2014 only one connection manager allowed");es=!0;let e=qt(),t=(0,ts.createHash)("sha256").update(e.token).digest("hex"),n=null,s=null,i=null,o=0;function c(){s&&(clearTimeout(s),s=null),n=new O(e.server,{headers:{Authorization:`Bearer ${e.token}`}});let l=n,d=null;l.on("open",()=>{Qt=!0,console.log("[daemon] ws.connected",{server:e.server}),i=setInterval(()=>{l.readyState===O.OPEN&&l.ping()},Lo),l.send(JSON.stringify({type:"ready",version:"1.1",name:e.name})),St().then(u=>{Qe=u,l.readyState===O.OPEN&&l.send(JSON.stringify({type:"agents",list:Qe}))}),d=Zn(u=>{l.readyState===O.OPEN&&l.send(JSON.stringify({type:"system_metrics",daemonId:t,...u}))})}),l.on("message",u=>{let h;try{h=JSON.parse(u.toString())}catch{console.warn("[daemon] Invalid JSON from server, ignoring");return}Yo(h,l,r,e)}),l.on("close",u=>{Qt=!1,i&&(clearInterval(i),i=null),d?.(),d=null,u===1008?(o++,o>=2&&(console.error("[daemon] ws.auth_failed \u2014 token invalid or expired (2 consecutive rejections), stopping. Re-run: bridge-agent auth"),process.exit(1)),console.warn("[daemon] ws.auth_rejected \u2014 transient 1008, will retry once",{attempt:o})):o=0,!s&&(console.log("[daemon] ws.reconnecting",{attempt:1}),s=setTimeout(c,3e3))}),l.on("error",u=>{console.error("[daemon] ws.error",{message:u.message})})}function a(){i&&(clearInterval(i),i=null),Ro();for(let l of Q.values())l();r.killAll(),n?.close()}process.on("SIGINT",()=>{a(),process.exit(0)}),process.on("SIGTERM",()=>{a(),process.exit(0)}),process.on("uncaughtException",l=>{console.error("[daemon] uncaughtException",{error:l.message}),r.killAll(),process.exit(1)}),c()}function Yo(r,e,t,n){switch(r.type){case"spawn":{console.log("[daemon] pty.spawn.start",{agentId:r.agentId,agentKey:r.agentKey,sessionId:r.sessionId,projectId:r.projectId,workspaceId:r.workspaceId,role:r.role});let s=Qe.find(b=>b.key===r.agentKey);if(!s){e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"AGENT_NOT_FOUND",message:`Agent '${r.agentKey}' is not installed on this machine`}));return}let i=re.find(b=>b.key===r.agentKey),o=[];if(r.sessionId&&i?.resumeArgs)o=i.resumeArgs(r.sessionId),console.log("[daemon] pty.spawn.resume",{agentId:r.agentId,sessionId:r.sessionId}),r.agentKey==="claude"&&(Q.get(r.agentId)?.(),Q.set(r.agentId,Kt(r.agentId,r.sessionId,(b,w,y)=>{e.readyState===O.OPEN&&e.send(JSON.stringify({type:"panel_token_usage",agentId:b,usedPct:w,usedTokens:y,...Xt}))})));else if(i?.assignSessionId){let b=crypto.randomUUID(),w=r.agentKey==="kimi"?"--session":"--session-id";o=[...i.spawnArgs??[],w,b],e.readyState===O.OPEN&&(e.send(JSON.stringify({type:"session_started",agentId:r.agentId,sessionId:b})),console.log("[daemon] session.assigned",{agentId:r.agentId,sessionId:b})),r.agentKey==="claude"&&(Q.get(r.agentId)?.(),Q.set(r.agentId,Kt(r.agentId,b,(y,D,G)=>{e.readyState===O.OPEN&&e.send(JSON.stringify({type:"panel_token_usage",agentId:y,usedPct:D,usedTokens:G,...Xt}))})))}else e.readyState===O.OPEN&&e.send(JSON.stringify({type:"session_started",agentId:r.agentId,sessionId:crypto.randomUUID()}));let c,a=!1,l;if(r.projectId&&r.workspaceId){let b=Uo(n.server),w=Ht(r.cwd);if(c={serverUrl:b,token:n.token,workspaceId:Fn(r.workspaceId),projectId:qn(r.projectId),agentId:r.agentId?Wn(r.agentId):void 0,cwd:r.cwd,projectEnv:w.env},r.agentKey==="claude"){let y=Wo(c);a=y.length>0,l=process.env.BRIDGE_MCP_URL?"http":"stdio",o=[...o,...y]}else if(r.agentKey==="codex"){let y=Go(c);a=y.length>0,l="stdio",o=[...o,...y]}else if(r.agentKey==="qwen")a=Ko(c),l=a?"stdio":void 0;else if(r.agentKey==="kimi"){let y=Ho(c);a=y.length>0,l=process.env.BRIDGE_MCP_URL?"http":"stdio",o=[...o,...y]}else a=!1,console.log("[daemon] mcp.config.skipped",{agentId:r.agentId,agentKey:r.agentKey,reason:"unsupported_agent_path"})}let d=Vo(r.agentKey,r.role,r.agentId);d.length>0&&(o=[...o,...d]);let u=Math.max(1,Math.min(500,r.cols)),h=Math.max(1,Math.min(500,r.rows)),g=Date.now(),f="",p=0,m=!1,v=!1;t.spawn(r.agentId,r.agentKey,s.binaryPath,o,u,h,b=>{p+=b.length;try{let w=Buffer.from(b,"base64").toString("utf-8");if(r.agentKey==="kimi"&&r.role&&!v&&Date.now()-g<3e4&&(/yolo agent/.test(w)||/●/.test(w)||/○/.test(w))){v=!0;let y=rs[r.role];if(y){let D=y.replaceAll("{{PANEL_ID}}",r.agentId),G=Do(D),Ce=Buffer.from(G).toString("base64");t.write(r.agentId,Ce,"orchestrator"),console.log("[daemon] kimi.role.injected",{agentId:r.agentId,role:r.role})}}}catch{}if(!f)try{let w=Buffer.from(b,"base64").toString("utf-8"),y=Bo(w).replace(/\x00/g,"").trim();if(y&&(f=$o(y)),r.agentKey==="codex"&&!m&&Date.now()-g<2e4&&/included in your plan for free|let[’']s build together/i.test(y)&&/yes|no|\[y\/n\]|\(y\/n\)|y\/n/i.test(y)){m=!0;let D=Buffer.from("y").toString("base64");t.write(r.agentId,D,"orchestrator"),console.log("[daemon] codex.onboarding.auto_ack",{agentId:r.agentId})}}catch{}e.readyState===O.OPEN&&e.send(JSON.stringify({type:"output",agentId:r.agentId,data:b}))},(b,w)=>{let y=Date.now()-g,D=y<=Mo;console.log("[daemon] pty.spawn.result",{agentId:r.agentId,agentKey:r.agentKey,daemonId:r.daemonId,exitCode:b,signal:w,uptimeMs:y,earlyExit:D,outputBytes:p,firstOutputSnippet:f||void 0}),D&&e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"SPAWN_FAILED",message:`Early exit: agent=${r.agentKey} code=${b??"null"} signal=${w??"null"} snippet="${f||"no output"}"`})),e.readyState===O.OPEN&&e.send(JSON.stringify({type:"exit",agentId:r.agentId,exitCode:b,signal:w}))},c)?e.readyState===O.OPEN&&e.send(JSON.stringify({type:"mcp_status",agentId:r.agentId,mcpConfigured:a,transport:a?l:void 0,projectId:c?.projectId})):e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"SPAWN_DUPLICATE",message:`Panel ${r.agentId} is already running`}));break}case"input":t.write(r.agentId,r.data,r.source);break;case"kill":Q.get(r.agentId)?.(),Q.delete(r.agentId),t.kill(r.agentId,r.force);break;case"resize":t.resize(r.agentId,r.cols,r.rows);break;case"detect_agents":St().then(s=>{Qe=s,e.readyState===O.OPEN&&e.send(JSON.stringify({type:"agents",list:s}))});break;case"dir_list":{let s=ve.default.homedir(),i=(r.path||"~").replace(/^~/,s),o=L.default.resolve(i);if(o!==s&&!o.startsWith(s+L.default.sep)){e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"INVALID_MSG",message:"Path outside home directory"}));return}try{let c=Z.default.readdirSync(o,{withFileTypes:!0}).filter(a=>a.isDirectory()&&!a.name.startsWith(".")).map(a=>({name:a.name,path:L.default.join(o,a.name)})).sort((a,l)=>a.name.localeCompare(l.name));e.readyState===O.OPEN&&e.send(JSON.stringify({type:"dir_list_result",requestId:r.requestId,path:o,entries:c}))}catch(c){e.readyState===O.OPEN&&e.send(JSON.stringify({type:"dir_list_result",requestId:r.requestId,path:o,entries:[],error:c instanceof Error?c.message:"Cannot read directory"}))}break}default:{let s=r}}}var zo="com.jerico.bridge-agent.plist",as=ee.default.join((0,Oe.homedir)(),"Library","LaunchAgents"),et=ee.default.join(as,zo),Zt=ee.default.join((0,Oe.homedir)(),"bridge-daemon.log"),er=ee.default.join((0,Oe.homedir)(),"bridge-daemon.err.log");function Jo(){let r=["/Users/alperduzgun/.nvm/versions/node/v20.20.1/lib/node_modules/bridge-agent/dist/index.js","/Users/alperduzgun/.nvm/versions/node/v20.20.1/bin/bridge-agent",...process.argv[1]?[process.argv[1]]:[]];for(let e of r)try{return require("node:fs").realpathSync(e)}catch{}return process.execPath}function Xo(r){try{(0,ke.execSync)(`mkdir -p "${as}"`,{stdio:"pipe"})}catch{}let e=(0,Oe.homedir)(),t=ee.default.join(e,".nvm","versions","node",process.versions.node,"bin"),n=ee.default.join(e,".local","bin"),s=[t,n,"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin"].join(":"),i=`<?xml version="1.0" encoding="UTF-8"?>
344
+ `,"utf-8"),console.log("[daemon] kimi.mcp.config.written",{tmpPath:n,transport:e?"http":"stdio"}),["--mcp-config-file",n]}catch(e){return console.warn("[daemon] kimi.mcp.config.build.failed",{error:String(e)}),[]}}function Go(r){try{let e=Ze(),t=`{BRIDGE_SERVER_URL=${xe(r.serverUrl)},BRIDGE_TOKEN=${xe(r.token)},BRIDGE_WORKSPACE_ID=${xe(r.workspaceId)},BRIDGE_PROJECT_ID=${xe(r.projectId)},HTTP_MODE="false"}`;return["-c",'mcp_servers.bridge.transport="stdio"',"-c",`mcp_servers.bridge.command=${xe(e)}`,"-c","mcp_servers.bridge.args=[]","-c",`mcp_servers.bridge.env=${t}`]}catch(e){return console.warn("[daemon] codex.mcp.config.build.failed",{error:String(e)}),[]}}function Ko(r){try{if(!r.cwd)return console.warn("[daemon] qwen.mcp.setup.skipped",{reason:"missing_cwd",projectId:r.projectId}),!1;let e=Ze(),t={cwd:r.cwd,encoding:"utf-8",timeout:5e3,stdio:"pipe"};(0,Jt.spawnSync)("qwen",["mcp","remove","--scope","project","bridge"],t);let n=(0,Jt.spawnSync)("qwen",["mcp","add","--scope","project","-t","stdio","-e",`BRIDGE_SERVER_URL=${r.serverUrl}`,"-e",`BRIDGE_TOKEN=${r.token}`,"-e",`BRIDGE_WORKSPACE_ID=${r.workspaceId}`,"-e",`BRIDGE_PROJECT_ID=${r.projectId}`,"-e",`BRIDGE_PANEL_ID=${r.agentId??""}`,"-e","HTTP_MODE=false","bridge",e],t);return n.status===0?(console.log("[daemon] qwen.mcp.setup.ok",{cwd:r.cwd,projectId:r.projectId}),!0):(console.warn("[daemon] qwen.mcp.setup.failed",{cwd:r.cwd,projectId:r.projectId,status:n.status,stderr:(n.stderr??"").toString().slice(0,300)}),!1)}catch(e){return console.warn("[daemon] qwen.mcp.setup.error",{error:String(e),projectId:r.projectId}),!1}}var Qe=[],Qt=!1,es=!1;function ns(){return Qt}function ss(r){if(es)throw new Error("[daemon] startDaemonConnection called twice \u2014 only one connection manager allowed");es=!0;let e=qt(),t=(0,ts.createHash)("sha256").update(e.token).digest("hex"),n=null,s=null,i=null,o=0;function c(){s&&(clearTimeout(s),s=null),n=new O(e.server,{headers:{Authorization:`Bearer ${e.token}`}});let l=n,d=null;l.on("open",()=>{Qt=!0,console.log("[daemon] ws.connected",{server:e.server}),i=setInterval(()=>{l.readyState===O.OPEN&&l.ping()},Lo),l.send(JSON.stringify({type:"ready",version:"1.1",name:e.name})),St().then(u=>{Qe=u,l.readyState===O.OPEN&&l.send(JSON.stringify({type:"agents",list:Qe}))}),d=Zn(u=>{l.readyState===O.OPEN&&l.send(JSON.stringify({type:"system_metrics",daemonId:t,...u}))})}),l.on("message",u=>{let h;try{h=JSON.parse(u.toString())}catch{console.warn("[daemon] Invalid JSON from server, ignoring");return}Yo(h,l,r,e)}),l.on("close",u=>{Qt=!1,i&&(clearInterval(i),i=null),d?.(),d=null,u===1008?(o++,o>=2&&(console.error("[daemon] ws.auth_failed \u2014 token invalid or expired (2 consecutive rejections), stopping. Re-run: bridge-agent auth"),process.exit(1)),console.warn("[daemon] ws.auth_rejected \u2014 transient 1008, will retry once",{attempt:o})):o=0,!s&&(console.log("[daemon] ws.reconnecting",{attempt:1}),s=setTimeout(c,3e3))}),l.on("error",u=>{console.error("[daemon] ws.error",{message:u.message})})}function a(){i&&(clearInterval(i),i=null),Ro();for(let l of Q.values())l();r.killAll(),n?.close()}process.on("SIGINT",()=>{a(),process.exit(0)}),process.on("SIGTERM",()=>{a(),process.exit(0)}),process.on("uncaughtException",l=>{console.error("[daemon] uncaughtException",{error:l.message}),r.killAll(),process.exit(1)}),c()}function Yo(r,e,t,n){switch(r.type){case"spawn":{console.log("[daemon] pty.spawn.start",{agentId:r.agentId,agentKey:r.agentKey,sessionId:r.sessionId,projectId:r.projectId,workspaceId:r.workspaceId,role:r.role});let s=Qe.find(b=>b.key===r.agentKey);if(!s){e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"AGENT_NOT_FOUND",message:`Agent '${r.agentKey}' is not installed on this machine`}));return}let i=re.find(b=>b.key===r.agentKey),o=[];if(r.sessionId&&i?.resumeArgs)o=i.resumeArgs(r.sessionId),console.log("[daemon] pty.spawn.resume",{agentId:r.agentId,sessionId:r.sessionId}),r.agentKey==="claude"&&(Q.get(r.agentId)?.(),Q.set(r.agentId,Kt(r.agentId,r.sessionId,(b,w,y)=>{e.readyState===O.OPEN&&e.send(JSON.stringify({type:"panel_token_usage",agentId:b,usedPct:w,usedTokens:y,...Xt}))})));else if(i?.assignSessionId){let b=crypto.randomUUID(),w=r.agentKey==="kimi"?"--session":"--session-id";o=[...i.spawnArgs??[],w,b],e.readyState===O.OPEN&&(e.send(JSON.stringify({type:"session_started",agentId:r.agentId,sessionId:b})),console.log("[daemon] session.assigned",{agentId:r.agentId,sessionId:b})),r.agentKey==="claude"&&(Q.get(r.agentId)?.(),Q.set(r.agentId,Kt(r.agentId,b,(y,D,G)=>{e.readyState===O.OPEN&&e.send(JSON.stringify({type:"panel_token_usage",agentId:y,usedPct:D,usedTokens:G,...Xt}))})))}else e.readyState===O.OPEN&&e.send(JSON.stringify({type:"session_started",agentId:r.agentId,sessionId:crypto.randomUUID()}));let c,a=!1,l;if(r.projectId&&r.workspaceId){let b=Uo(n.server),w=Ht(r.cwd);if(c={serverUrl:b,token:n.token,workspaceId:Fn(r.workspaceId),projectId:qn(r.projectId),agentId:r.agentId?Wn(r.agentId):void 0,cwd:r.cwd,projectEnv:w.env},r.agentKey==="claude"){let y=Wo(c);a=y.length>0,l=process.env.BRIDGE_MCP_URL?"http":"stdio",o=[...o,...y]}else if(r.agentKey==="codex"){let y=Go(c);a=y.length>0,l="stdio",o=[...o,...y]}else if(r.agentKey==="qwen")a=Ko(c),l=a?"stdio":void 0;else if(r.agentKey==="kimi"){let y=Ho(c);a=y.length>0,l=process.env.BRIDGE_MCP_URL?"http":"stdio",o=[...o,...y]}else a=!1,console.log("[daemon] mcp.config.skipped",{agentId:r.agentId,agentKey:r.agentKey,reason:"unsupported_agent_path"})}let d=Vo(r.agentKey,r.role,r.agentId);d.length>0&&(o=[...o,...d]);let u=Math.max(1,Math.min(500,r.cols)),h=Math.max(1,Math.min(500,r.rows)),g=Date.now(),f="",p=0,m=!1,v=!1;t.spawn(r.agentId,r.agentKey,s.binaryPath,o,u,h,b=>{p+=b.length;try{let w=Buffer.from(b,"base64").toString("utf-8");if(r.agentKey==="kimi"&&r.role&&!v&&Date.now()-g<3e4&&(/yolo agent/.test(w)||/●/.test(w)||/○/.test(w))){v=!0;let y=rs[r.role];if(y){let D=y.replaceAll("{{PANEL_ID}}",r.agentId),G=Do(D),Ce=Buffer.from(G).toString("base64");t.write(r.agentId,Ce,"orchestrator"),console.log("[daemon] kimi.role.injected",{agentId:r.agentId,role:r.role})}}}catch{}if(!f)try{let w=Buffer.from(b,"base64").toString("utf-8"),y=Bo(w).replace(/\x00/g,"").trim();if(y&&(f=$o(y)),r.agentKey==="codex"&&!m&&Date.now()-g<2e4&&/included in your plan for free|let[’']s build together/i.test(y)&&/yes|no|\[y\/n\]|\(y\/n\)|y\/n/i.test(y)){m=!0;let D=Buffer.from("y").toString("base64");t.write(r.agentId,D,"orchestrator"),console.log("[daemon] codex.onboarding.auto_ack",{agentId:r.agentId})}}catch{}e.readyState===O.OPEN&&e.send(JSON.stringify({type:"output",agentId:r.agentId,data:b}))},(b,w)=>{let y=Date.now()-g,D=y<=Mo;console.log("[daemon] pty.spawn.result",{agentId:r.agentId,agentKey:r.agentKey,daemonId:r.daemonId,exitCode:b,signal:w,uptimeMs:y,earlyExit:D,outputBytes:p,firstOutputSnippet:f||void 0}),D&&e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"SPAWN_FAILED",message:`Early exit: agent=${r.agentKey} code=${b??"null"} signal=${w??"null"} snippet="${f||"no output"}"`})),e.readyState===O.OPEN&&e.send(JSON.stringify({type:"exit",agentId:r.agentId,exitCode:b,signal:w}))},c)?e.readyState===O.OPEN&&e.send(JSON.stringify({type:"mcp_status",agentId:r.agentId,mcpConfigured:a,transport:a?l:void 0,projectId:c?.projectId})):e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"SPAWN_DUPLICATE",message:`Panel ${r.agentId} is already running`}));break}case"input":t.write(r.agentId,r.data,r.source);break;case"kill":Q.get(r.agentId)?.(),Q.delete(r.agentId),t.kill(r.agentId,r.force);break;case"resize":t.resize(r.agentId,r.cols,r.rows);break;case"detect_agents":St().then(s=>{Qe=s,e.readyState===O.OPEN&&e.send(JSON.stringify({type:"agents",list:s}))});break;case"dir_list":{let s=ve.default.homedir(),i=(r.path||"~").replace(/^~/,s),o=L.default.resolve(i);if(o!==s&&!o.startsWith(s+L.default.sep)){e.readyState===O.OPEN&&e.send(JSON.stringify({type:"error",code:"INVALID_MSG",message:"Path outside home directory"}));return}try{let c=Z.default.readdirSync(o,{withFileTypes:!0}).filter(a=>a.isDirectory()&&!a.name.startsWith(".")).map(a=>({name:a.name,path:L.default.join(o,a.name)})).sort((a,l)=>a.name.localeCompare(l.name));e.readyState===O.OPEN&&e.send(JSON.stringify({type:"dir_list_result",requestId:r.requestId,path:o,entries:c}))}catch(c){e.readyState===O.OPEN&&e.send(JSON.stringify({type:"dir_list_result",requestId:r.requestId,path:o,entries:[],error:c instanceof Error?c.message:"Cannot read directory"}))}break}default:{let s=r}}}var zo="com.jerico.bridge-agent.plist",as=ee.default.join((0,Oe.homedir)(),"Library","LaunchAgents"),et=ee.default.join(as,zo),Zt=ee.default.join((0,Oe.homedir)(),"bridge-daemon.log"),er=ee.default.join((0,Oe.homedir)(),"bridge-daemon.err.log");function Jo(){let r=["/Users/alperduzgun/.nvm/versions/node/v20.20.1/lib/node_modules/bridge-agent/dist/index.js","/Users/alperduzgun/.nvm/versions/node/v20.20.1/bin/bridge-agent",...process.argv[1]?[process.argv[1]]:[]];for(let e of r)try{return require("node:fs").realpathSync(e)}catch{}return process.execPath}function Xo(r){try{(0,ke.execSync)(`mkdir -p "${as}"`,{stdio:"pipe"})}catch{}let e=(0,Oe.homedir)(),t=ee.default.join(e,".nvm","versions","node",`v${process.versions.node}`,"bin"),n=ee.default.join(e,".local","bin"),s=[t,n,"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin"].join(":"),i=`<?xml version="1.0" encoding="UTF-8"?>
345
345
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
346
346
  <plist version="1.0">
347
347
  <dict>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bridge-agent",
3
- "version": "0.1.0-beta.8",
3
+ "version": "0.1.0",
4
4
  "description": "Bridge local agent — connects your AI tools to Jerico",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",