borgmcp 1.1.8 → 1.1.9
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-runtime.d.ts +37 -0
- package/dist/agent-runtime.js +1 -0
- package/dist/assimilate-cmd.js +22 -22
- package/dist/claude.js +11 -11
- package/dist/codex-app-wake.d.ts +9 -6
- package/dist/codex-app-wake.js +2 -2
- package/dist/codex-remote.js +1 -1
- package/dist/config-utils.d.ts +6 -4
- package/dist/config-utils.js +3 -3
- package/dist/health-beat.d.ts +3 -4
- package/dist/health-beat.js +1 -1
- package/dist/index.js +15 -15
- package/dist/roster-render.d.ts +5 -2
- package/dist/roster-render.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent CLI identity is independent from both the selected model and the
|
|
3
|
+
* Codex remote-wake transport. The child MCP process reports this value on its
|
|
4
|
+
* health beat so a relaunch of an existing seat can repair the server-side
|
|
5
|
+
* agent_kind without re-assimilating.
|
|
6
|
+
*/
|
|
7
|
+
export type AgentKind = 'claude' | 'codex' | 'opencode';
|
|
8
|
+
/** Pinned into MCP-child environments by Borg launch paths. */
|
|
9
|
+
export declare const BORG_AGENT_KIND_ENV = "BORG_AGENT_KIND";
|
|
10
|
+
/** Transport capability only — never use it as the primary CLI identity. */
|
|
11
|
+
export declare const BORG_CODEX_REMOTE_WAKE_ENV = "BORG_CODEX_REMOTE_WAKE";
|
|
12
|
+
/** Legacy OpenCode runtime marker, retained for installed-config compatibility. */
|
|
13
|
+
export declare const BORG_OPENCODE_ENV = "BORG_OPENCODE";
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the current MCP child's agent CLI. New Borg launches pin
|
|
16
|
+
* BORG_AGENT_KIND; the older wake-transport markers remain a fallback for
|
|
17
|
+
* already-installed clients.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveSessionAgentKind(env?: NodeJS.ProcessEnv): AgentKind;
|
|
20
|
+
/**
|
|
21
|
+
* Produce a clean agent-launch environment. Clearing stale transport markers
|
|
22
|
+
* is essential for a Codex → Claude relaunch: an inherited marker must not
|
|
23
|
+
* make the new Claude MCP child report Codex.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withAgentRuntimeEnv(env: NodeJS.ProcessEnv, agentKind: AgentKind): NodeJS.ProcessEnv;
|
|
26
|
+
/** Pin the selected Codex CLI identity into Codex's MCP-child env overlay. */
|
|
27
|
+
export declare function codexAgentKindConfigArgs(): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Pin the remote-wake transport capability separately from the CLI identity.
|
|
30
|
+
*
|
|
31
|
+
* Codex MCP children read their configured env rather than the wrapper's
|
|
32
|
+
* inherited process env. Explicitly pinning "0" on a no-socket launch is
|
|
33
|
+
* therefore necessary to override legacy static configs that used to persist
|
|
34
|
+
* BORG_CODEX_REMOTE_WAKE="1" as an identity marker.
|
|
35
|
+
*/
|
|
36
|
+
export declare function codexRemoteWakeConfigArgs(enabled?: boolean): string[];
|
|
37
|
+
//# sourceMappingURL=agent-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o="BORG_AGENT_KIND",t="BORG_CODEX_REMOTE_WAKE",r="BORG_OPENCODE";function E(e){return e==="claude"||e==="codex"||e==="opencode"}function i(e=process.env){return E(e[o])?e[o]:e[r]==="1"?"opencode":e[t]==="1"?"codex":"claude"}function _(e,c){const n={...e};return delete n[o],delete n[t],delete n[r],n[o]=c,c==="opencode"&&(n[r]="1"),n}function s(){return["-c",`mcp_servers.borg.env.${o}="codex"`]}function d(e=!0){return["-c",`mcp_servers.borg.env.${t}="${e?"1":"0"}"`]}export{o as BORG_AGENT_KIND_ENV,t as BORG_CODEX_REMOTE_WAKE_ENV,r as BORG_OPENCODE_ENV,s as codexAgentKindConfigArgs,d as codexRemoteWakeConfigArgs,i as resolveSessionAgentKind,_ as withAgentRuntimeEnv};
|
package/dist/assimilate-cmd.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import{dirname as J,basename as R}from"node:path";import{randomUUID as le}from"node:crypto";import{roleSlug as se,matchRoleByName as ce,pickDefaultRole as ue}from"./role-resolver.js";import{deriveCubeName as me,parseGitRemote as de,sanitizeRemoteUrl as fe}from"./cube-name.js";import{validateName as V}from"./name-validator.js";import{renderAssimilationWelcome as
|
|
1
|
+
import{dirname as J,basename as R}from"node:path";import{randomUUID as le}from"node:crypto";import{roleSlug as se,matchRoleByName as ce,pickDefaultRole as ue}from"./role-resolver.js";import{deriveCubeName as me,parseGitRemote as de,sanitizeRemoteUrl as fe}from"./cube-name.js";import{validateName as V}from"./name-validator.js";import{renderAssimilationWelcome as ge}from"./assimilate-welcome.js";import{shellEscape as he}from"./shell-escape.js";import{withCodexCwdArg as we}from"./codex-remote.js";import{buildAgentKickoffPrompt as be,buildKickoffWakePathClause as ke,recordCodexWakeTarget as ye,socketPathFromRemoteArgs as pe}from"./codex-launch.js";import{perWorktreeBranchName as F,adoptWorktree as ve,computeWorktreePath as X,localBranchExists as Q,isMerged as $e}from"./worktree-lifecycle.js";import{DroneEvictedError as xe}from"./drone-lifecycle.js";import{codexBorgSessionConfigArgs as Se}from"./launch-gate.js";import{codexAgentKindConfigArgs as Ce,codexRemoteWakeConfigArgs as Re,withAgentRuntimeEnv as _e}from"./agent-runtime.js";import{inboxPathForDrone as Ee}from"./cubes.js";import{monitorStateRootForWorktree as Ae}from"./inbox-monitor.js";import{resolveLaunchEnv as Ie,resolveOllamaBaseUrl as Ne,parseModel as Pe}from"./model-presets.js";import{unlinkSync as Le}from"node:fs";import{gcOrphanInboxesForCube as Te,defaultListInboxLogs as De,defaultInboxLivenessDeps as Ue,isInboxLive as Oe,ORPHAN_INBOX_STALE_MS as We}from"./gc-orphan-inboxes.js";import{installBorgPlugin as je}from"./opencode-plugin.js";import{computeOpenCodePort as Me,connectOpenCodeDrone as Be,injectInitialKickoff as He}from"./opencode-drone.js";async function wt(r,e){if(r.role!==void 0){const t=V(r.role);if(!t.ok)return e.stderr(t.error+`
|
|
2
2
|
`),1}if(r.flags.worktree!==void 0){const t=V(r.flags.worktree);if(!t.ok)return e.stderr(t.error+`
|
|
3
3
|
`),1}let a=await e.getCachedAuth();if(!a){if(!e.isTTY()&&!r.flags.yes)return e.stderr("borg setup required and stdin is non-interactive. Run `borg setup` first in an interactive terminal, then `borg assimilate`.\n"),1;a=await e.runSetup()}const o=e.findProjectRoot(e.cwd());let i;if(r.flags.cubeName)i=r.flags.cubeName;else{const t=e.runSync("git",["remote","get-url","origin"],o),n=t.status===0?t.stdout:null;if(i=me(o,n),n){const c=fe(n),f=c?de(c):null;c&&!f&&i&&e.stderr(`couldn't parse git remote '${c}' \u2014 using directory name '${i}' as cube name
|
|
4
4
|
`)}}let l=null;if(i&&i.includes("@")&&i.includes(":")){const t=i.lastIndexOf(":");l={ownerEmail:i.substring(0,t),cubeName:i.substring(t+1)},i=l.cubeName}const _=e.cwd();e.stderr(`Checking your cubes\u2026
|
|
5
5
|
`);let I;try{I=await e.listCubes(a.apiUrl,a.token)}catch(t){const n=t instanceof Error?t.message:String(t);if(n.includes("Authentication required")||n.includes("Authentication expired"))e.stderr(`Re-authenticating...
|
|
6
6
|
`),a=await e.runSetup(),I=await e.listCubes(a.apiUrl,a.token);else throw t}const N=I.find(t=>t.name===i);if(!N&&l)return e.stderr(`No cube named '${l.cubeName}' accessible to you owned by '${l.ownerEmail}'. Did you accept their invite? See borgmcp.ai/dashboard.
|
|
7
|
-
`),1;let u,
|
|
7
|
+
`),1;let u,P;if(N)u=await e.getCube(a.apiUrl,a.token,N.id),P=!1;else{let t;if(r.flags.template)t=r.flags.template;else if(r.flags.noTemplate)t=void 0;else if(e.isTTY())if(r.flags.yes)t="starter";else{const n=await e.listTemplates(a.apiUrl,a.token),c=["First drone joining a new cube. Apply a template?"];n.forEach((v,$)=>{const A=$===0?" (default)":"";c.push(` ${$+1}) ${v.name}${A} \u2014 ${v.description}`)}),c.push(` ${n.length+1}) skip \u2014 no template`);const f=(await e.prompt(c.join(`
|
|
8
8
|
`)+`
|
|
9
9
|
[1]: `)).trim(),y=f===""?1:parseInt(f,10);if(Number.isNaN(y)||y<1||y>n.length+1)return e.stderr(`invalid choice "${f}"
|
|
10
10
|
`),1;t=y<=n.length?n[y-1].name:void 0}else{if(!r.flags.yes)return e.stderr(`cube creation needs a template choice but stdin is non-interactive.
|
|
11
11
|
Pass --template <name>, --no-template, or --yes (defaults to starter).
|
|
12
12
|
`),1;t="starter"}e.stderr(i?`Creating cube '${i}'\u2026
|
|
13
13
|
`:`Creating your cube\u2026
|
|
14
|
-
`),u=await e.createCube(a.apiUrl,a.token,t?{name:i??void 0,template:t}:{name:i??void 0}),
|
|
14
|
+
`),u=await e.createCube(a.apiUrl,a.token,t?{name:i??void 0,template:t}:{name:i??void 0}),P=!0}let h;if(r.role!==void 0){if(h=ce(u.roles,r.role),!h){const t=u.roles.map(f=>f.name).join(", "),n=Ge(r.role,u.roles.map(f=>f.name)),c=n?` Did you mean "${n}"?`:"";return e.stderr(`no role matching "${r.role}" in cube "${u.name}". Available: ${t}.${c}
|
|
15
15
|
(Use --template <name> on first-drone setup or run \`borg_create-role\` from inside Claude.)
|
|
16
|
-
`),1}}else{const t=new Set((u.drones??[]).map(n=>n.role_id));if(
|
|
17
|
-
`),1}const
|
|
18
|
-
`),1;const K=r.flags.worktree!==void 0||
|
|
19
|
-
`),1}const m=await e.resolveCli(r.flags.cli);e.stderr(`Joining cube '${u.name}' as ${
|
|
20
|
-
`);let s;try{s=await e.assimilate(a.apiUrl,a.token,{cube_id:u.id,role_id:
|
|
16
|
+
`),1}}else{const t=new Set((u.drones??[]).map(n=>n.role_id));if(h=ue(u.roles,{isFirstDrone:P,occupiedRoleIds:t}),!h)return e.stderr(`cube "${u.name}" has no default or human-seat role; cannot infer a role. Either pass a role argument explicitly (e.g. \`borg assimilate builder\`) or run \`borg_create-role\` from inside Claude to set up roles.
|
|
17
|
+
`),1}const x=await e.getActiveCube();let S;if(x&&r.flags.here)if(x.cubeId===u.id)S=x.droneId;else return e.stderr(`this directory already hosts an active drone; remove --here or run from a fresh worktree
|
|
18
|
+
`),1;const K=r.flags.worktree!==void 0||x!==null&&!r.flags.here,ee=S??x?.droneId??null,L=K?null:await e.getLaunchModel(u.id,o,ee),b=r.flags.model??L?.model??h.default_model??null,T=Ne(process.env,b!=null&&b===L?.model?L?.ollamaBaseUrl:void 0);if(b){const t=await e.checkModelReachable(b,e.fetch,T);if(!t.ok)return e.stderr(`${t.message}
|
|
19
|
+
`),1}const m=await e.resolveCli(r.flags.cli);e.stderr(`Joining cube '${u.name}' as ${h.name}\u2026
|
|
20
|
+
`);let s;try{s=await e.assimilate(a.apiUrl,a.token,{cube_id:u.id,role_id:h.id,hostname:e.getHostname(),agent_kind:m,model:b,...S?{prior_drone_id:S}:{}})}catch(t){if(t instanceof xe&&S!=null)return e.stderr(`seat evicted \u2014 this worktree's saved seat was evicted from the cube. Re-assimilate fresh from a terminal, or remove this worktree.
|
|
21
21
|
`),1;const n=t instanceof Error?t.message:String(t);return e.stderr(`assimilate failed: ${n}
|
|
22
|
-
`),1}const k=u.roles.find(t=>t.id===s.role_id)??
|
|
23
|
-
`):k.id!==
|
|
22
|
+
`),1}const k=u.roles.find(t=>t.id===s.role_id)??h;s.reattached?e.stderr(`re-attached to existing seat ${s.drone_label} (session token rotated, no new drone minted)
|
|
23
|
+
`):k.id!==h.id&&e.stderr(`Note: your invite didn't grant the "${h.name}" role \u2014 assimilated as "${k.name}" instead.
|
|
24
24
|
`);const te=K;let w=null;if(te){const t=e.runSync("git",["rev-parse","--verify","HEAD"],o);if(t.status!==0)return e.stderr(`sibling worktree spawn requires HEAD pointing at a commit.
|
|
25
25
|
Fix: create at least one commit (\`git commit --allow-empty -m "initial"\`)
|
|
26
26
|
OR: pass --here to skip the sibling spawn and use the current directory
|
|
27
27
|
`),1;e.runSync("git",["fetch","origin"],o);let n="origin/main";e.runSync("git",["rev-parse","--verify","origin/main"],o).status!==0&&e.runSync("git",["rev-parse","--verify","origin/master"],o).status===0&&(n="origin/master");const f=t.stdout.trim(),y=e.runSync("git",["rev-parse",n],o).stdout.trim();f!==y&&e.stderr(`note: local HEAD (${f.slice(0,7)}) differs from ${n} (${y.slice(0,7)}); new worktree will start on ${n}
|
|
28
28
|
`);const v=R(o),$=r.flags.worktree??se(k.name);if($.length===0)return e.stderr(`cannot derive a worktree name from role "${k.name}"; pass an explicit --worktree <name>
|
|
29
|
-
`),1;const
|
|
30
|
-
`),1;e.stderr(`spawned sibling worktree at ${
|
|
31
|
-
`),e.chdir(
|
|
29
|
+
`),1;const A=e.homedir();let g=X(A,v,$),p=F(R(g),v),q=2;for(;e.pathExists(g)||Ye(e,o,g)||Q(e.runSync,o,p)&&!$e(e.runSync,o,p,n);)g=X(A,v,$,q),p=F(R(g),v),q++;e.mkdirp(J(g));const z=Q(e.runSync,o,p)?e.runSync("git",["worktree","add",g,p],o):e.runSync("git",["worktree","add","-b",p,g,n],o);if(z.status!==0)return e.stderr(`git worktree add failed: ${Z(z.stderr)}
|
|
30
|
+
`),1;e.stderr(`spawned sibling worktree at ${g} on branch ${p} (${n}); original dir is registered as active (edit ~/.config/borgmcp/cubes.json if stale).
|
|
31
|
+
`),e.chdir(g),e.stderr(Fe(g,p,o)),w=e.cwd()}try{await e.setActiveCube({cubeId:s.cube_id,droneId:s.drone_id,name:u.name,sessionToken:s.session_token,droneLabel:s.drone_label,apiUrl:a.apiUrl,roleName:k.name,isHumanSeat:k.is_human_seat,...k.role_class?{roleClass:k.role_class}:{}})}catch(t){const n=t instanceof Error?t.message:String(t);if(e.stderr(`setActiveCube failed: ${n}
|
|
32
32
|
`),w){const c=e.runSync("git",["worktree","remove","--force",w],o);c.status===0?e.stderr(`rolled back spawned worktree at ${w}
|
|
33
33
|
`):e.stderr(`manual cleanup needed: \`git worktree remove --force ${w}\` (rollback attempt failed: ${Z(c.stderr).trim()||"unknown"})
|
|
34
|
-
`)}return 1}const d=e.cwd(),
|
|
34
|
+
`)}return 1}const d=e.cwd(),D=e.findProjectRoot(d),U=Ae(D);try{const t=Ue(),n=J(Ee(s.cube_id,s.drone_id));Te({cubeInboxDir:n,selfDroneId:s.drone_id,deps:{listInboxLogs:De,isLive:c=>Oe(c,t,U),droneState:()=>"absent",unlink:c=>Le(c),now:t.now,staleMs:We},monitorStateRoot:U})}catch{}e.setTerminalTitle(s.drone_label,u.name);const re=e.isTTY()&&!process.env.NO_COLOR&&!process.env.CI;e.stdout(ge(k.name,u.name,re));try{e.installProjectSessionHook(d)}catch{e.stderr(`warning: could not install the project-local SessionStart hook in ${d}; it will be re-attempted on the next borg launch
|
|
35
35
|
`)}if(!w){e.runSync("git",["fetch","origin","--prune"],d);const t=F(R(d),R(o)),n=ve(e.runSync,d,t,"origin/main");n.action==="adopted"?(e.stderr(`worktree: adopted branch ${t} at origin/main
|
|
36
|
-
`),e.stderr(
|
|
36
|
+
`),e.stderr(Ke(d,t))):n.message&&e.stderr(`worktree sync: ${n.message}
|
|
37
37
|
`)}await e.probeMcpReady()||e.stderr(`warning: borg-mcp readiness probe did not complete within the timeout; launching ${m} anyway \u2014 the kickoff prompt's ToolSearch fallback will recover if the MCP server takes longer to start.
|
|
38
|
-
`);const ne=e.getInboxPath(s.cube_id,s.drone_id),
|
|
39
|
-
`),
|
|
38
|
+
`);const ne=e.getInboxPath(s.cube_id,s.drone_id),O=m==="codex"?`borg-wake-${le()}`:null,oe=ke(m,m==="claude"?ne:null,m==="claude"?U:null);let W,Y=[],C,E=null,j=null;b?await e.setLaunchModel(s.cube_id,D,{model:b,ollamaBaseUrl:Pe(b).kind==="ollama"?T:null}):await e.clearLaunchModel(s.cube_id,D);const G=Ie(b,T),M={..._e(process.env,m),...G.set,BORG_SESSION:"1"};for(const t of G.unset)delete M[t];if(m==="codex"){const t=await e.prepareCodexRemoteLaunch();t.warning?(e.stderr(`warning: ${t.warning}
|
|
39
|
+
`),W="\u26A0 Codex wake-path capability check failed: remote-control is unavailable for this session. Run borg_regen manually whenever you return, and expect only fallback wakeups until relaunch."):W="Codex wake-path capability check passed: remote-control socket established for this session.",Y=t.args,Object.keys(t.env).length>0&&Object.assign(M,t.env),E=pe(t.args),j=t.server?.cleanup??null}const B=be({cli:m,codexWakeNonce:O,monitorClause:oe,codexWakePathClause:W});let H;C=[B],m==="codex"?C=[...Se(),...Ce(),...Re(E!==null),...Y,...we(C,d)]:m==="opencode"&&(H=Me(s.drone_id),je(),C=[d,"--port",String(H),"--auto","--prompt",B]);const ie=e.exec(m,C,d,M);if(m==="codex"&&E&&O&&ye({deps:e,cubeId:s.cube_id,droneId:s.drone_id,socketPath:E,cwd:d,previewNeedle:O,launchedAtSeconds:Math.floor(Date.now()/1e3)}),m==="opencode"){const t=`http://127.0.0.1:${H}`;Be({serverUrl:t,directory:d,droneLabel:s.drone_label,cubeName:i??"borg"}).then(()=>He(B)).catch(()=>{})}const ae=await ie;if(j)try{j()}catch{}return w&&_!==w&&e.stderr(`
|
|
40
40
|
Agent exited. You were working in ${w}; your shell is back in ${_}.
|
|
41
41
|
To return:
|
|
42
|
-
cd ${
|
|
43
|
-
`),ae}function
|
|
42
|
+
cd ${he(w)}
|
|
43
|
+
`),ae}function Fe(r,e,a){return`
|
|
44
44
|
WORKTREE STEERING: You are in worktree ${r} on branch ${e}. Do ALL work HERE \u2014 cut your feature branch (fix/.../feat/...) off ${e} in THIS worktree, use relative paths / your cwd. NEVER \`git -C ${a}\` or operate on the primary checkout ${a}: the same branch can't be checked out in two worktrees, so work created in the primary won't reach your wt-branch without manual surgery (cherry-pick/merge).
|
|
45
|
-
`}function
|
|
45
|
+
`}function Ke(r,e){return`
|
|
46
46
|
WORKTREE STEERING: This checkout is now on branch ${e}. Do ALL work HERE in ${r} \u2014 cut your feature branch (fix/.../feat/...) off ${e}, use relative paths / your cwd.
|
|
47
|
-
`}function Z(r){return r.replace(/[\x00-\x1F\x7F]/g,"")}function
|
|
48
|
-
`).some(i=>i===`worktree ${a}`)}function
|
|
47
|
+
`}function Z(r){return r.replace(/[\x00-\x1F\x7F]/g,"")}function Ye(r,e,a){const o=r.runSync("git",["worktree","list","--porcelain"],e);return o.status!==0?!1:o.stdout.split(`
|
|
48
|
+
`).some(i=>i===`worktree ${a}`)}function Ge(r,e){if(e.length===0)return null;const a=r.toLowerCase();let o=null;for(const i of e){const l=qe(a,i.toLowerCase());l<=2&&(o===null||l<o.distance)&&(o={name:i,distance:l})}return o?o.name:null}function qe(r,e){if(r===e)return 0;if(r.length===0)return e.length;if(e.length===0)return r.length;const a=new Array(e.length+1),o=new Array(e.length+1);for(let i=0;i<=e.length;i++)a[i]=i;for(let i=1;i<=r.length;i++){o[0]=i;for(let l=1;l<=e.length;l++){const _=r[i-1]===e[l-1]?0:1;o[l]=Math.min(o[l-1]+1,a[l]+1,a[l-1]+_)}for(let l=0;l<=e.length;l++)a[l]=o[l]}return a[e.length]}export{wt as runAssimilate,Z as safeStderr,Ge as suggestRoleName};
|
package/dist/claude.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawn as
|
|
3
|
-
`)})();if((process.argv[2]==="--help"||process.argv[2]==="-h")&&(process.stdout.write(
|
|
4
|
-
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=
|
|
5
|
-
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=await
|
|
6
|
-
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=await ae({},e.options);process.exit(r)}if(process.argv[2]==="launch-all"){const e=
|
|
7
|
-
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=k(),
|
|
8
|
-
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1)),
|
|
9
|
-
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const
|
|
10
|
-
\u25FC Failed to launch ${
|
|
2
|
+
import{spawn as W}from"child_process";import{randomUUID as _}from"node:crypto";import{basename as G}from"node:path";import{createInterface as U}from"node:readline/promises";import i from"chalk";import{findProjectRoot as b,getActiveCube as Y,getLaunchModel as K,inboxPathForDrone as V,setCodexWakeTarget as j,pruneDeadCodexWakeTargets as q}from"./cubes.js";import{monitorStateRootForWorktree as X}from"./inbox-monitor.js";import{applyOllamaLaunchEnv as z,checkModelReachable as J}from"./model-presets.js";import{handleVersionFlag as Q,getPackageVersion as w}from"./version.js";import{isHelpFlag as L,setupHelpText as Z,topLevelHelpText as ee,assimilateHelpText as re}from"./cli-help.js";import{runSpawn as oe}from"./spawn.js";import{buildClaudeLaunchArgs as se}from"./claude-launch-args.js";import{parseSyncArgs as te,runSync as ie}from"./sync.js";import{parseCleanupArgs as ne,runCleanup as ae}from"./cleanup-cmd.js";import{parseAssimilateArgs as ce}from"./parse-assimilate-args.js";import{runAssimilate as le}from"./assimilate-cmd.js";import{buildDefaultAssimilateDeps as de}from"./assimilate-deps.js";import{parseLaunchAllArgs as O}from"./parse-launch-all-args.js";import{unknownSubcommand as pe}from"./unknown-subcommand.js";import{runLaunchAll as D}from"./launch-all-cmd.js";import{buildDefaultLaunchAllDeps as k}from"./launch-all-deps.js";import{discoverDroneCandidates as ue}from"./launch-all-discovery.js";import{explicitCliLaunchHint as me,runBareLaunchMenu as fe,shouldResolveExplicitCliLaunchHintTargets as ge,shouldShowLaunchMenu as he}from"./bare-launch-menu.js";import{setTerminalTitle as we}from"./terminal-title.js";import{initConsolePrefix as Ce,consolePrefix as t}from"./console-prefix.js";import{initDebugFromArgv as xe}from"./debug.js";import{fetchLatestBorgmcpVersion as ve,compareVersionsForStaleness as be}from"./stale-version-check.js";import{defaultCliChoiceDeps as ke,detectCliAvailability as $,installedCliNames as E,parseCliFlag as $e,resolveCliChoice as Se}from"./cli-platform.js";import{getRefreshToken as Ae,getIdToken as ye}from"./config.js";import{composeGetStarted as Te,shouldShowGetStarted as Pe}from"./get-started.js";import{prepareCodexRemoteLaunch as Ie,withCodexCwdArg as Re,defaultCodexRemoteDeps as Le,checkCodexBridgeHealthy as Oe}from"./codex-remote.js";import{BORG_CODEX_REMOTE_WAKE_ENV as De,codexAgentKindConfigArgs as Ee,codexRemoteWakeConfigArgs as Me,withAgentRuntimeEnv as S}from"./agent-runtime.js";import{findLoadedCodexThread as He}from"./codex-app-server.js";import{buildAgentKickoffPrompt as Ne,buildKickoffWakePathClause as Fe,recordCodexWakeTarget as Be,socketPathFromRemoteArgs as M}from"./codex-launch.js";import{codexBorgSessionConfigArgs as We}from"./launch-gate.js";import{addCodexMcpServer as _e,addCodexSessionStartHook as Ge,addCodexUserPromptSubmitHook as Ue,addMcpServer as Ye,addOpenCodeMcpServer as Ke,addProjectSessionStartHook as Ve,addUserPromptSubmitHook as je,isCodexMcpServerConfigured as qe,isMcpServerConfigured as Xe,isOpenCodeMcpServerConfigured as ze,removeSessionStartHook as Je}from"./config-utils.js";import{installBorgPlugin as Qe}from"./opencode-plugin.js";import{connectOpenCodeDrone as Ze,computeOpenCodePort as H,injectInitialKickoff as er}from"./opencode-drone.js";async function rr(){xe(process.argv),Q(),await Ce();const c=(async()=>{if(!process.stderr.isTTY)return;const e=w(),r=await ve();if(!r)return;const n=be(e,r);n.stale&&n.message&&process.stderr.write(`${t()}${n.message}
|
|
3
|
+
`)})();if((process.argv[2]==="--help"||process.argv[2]==="-h")&&(process.stdout.write(ee(w())),process.exit(0)),process.argv[2]==="setup"){L(process.argv[3])&&(process.stdout.write(Z(w())),process.exit(0)),await import("./setup.js");return}if(process.argv[2]==="assimilate"){process.argv.slice(3).some(L)&&(process.stdout.write(re(w())),process.exit(0));const e=ce(process.argv.slice(3));e.ok||(process.stderr.write(i.red(`${t()}\u25FC borg assimilate: ${e.error}
|
|
4
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=de(),n=await le({role:e.role,flags:e.flags},r);process.exit(n)}if(process.argv[2]==="spawn"){const e=await oe();process.exit(e)}if(process.argv[2]==="sync"){const e=te(process.argv.slice(3));e.ok||(process.stderr.write(i.red(`${t()}\u25FC borg sync: ${e.error}
|
|
5
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=await ie({},e.options);process.exit(r)}if(process.argv[2]==="cleanup"){const e=ne(process.argv.slice(3));e.ok||(process.stderr.write(i.red(`${t()}\u25FC borg cleanup: ${e.error}
|
|
6
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=await ae({},e.options);process.exit(r)}if(process.argv[2]==="launch-all"){const e=O(process.argv.slice(3));e.ok||(process.stderr.write(i.red(`${t()}\u25FC borg launch-all: ${e.error}
|
|
7
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=k(),n=await D(e.args,r);process.exit(n)}const a=pe(process.argv[2]);if(a!==null&&(process.stderr.write(i.red(`${t()}\u25FC unknown command: ${a}
|
|
8
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1)),Pe(await Ae()!==null,await ye()!==null)){const e=E($()).length>0;process.stdout.write(Te(e)),process.exit(0)}const d=$e(process.argv.slice(2));d.error&&(process.stderr.write(i.red(`${t()}\u25FC ${d.error}
|
|
9
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const A=async e=>{const r=U({input:process.stdin,output:process.stdout});try{return await r.question(e)}finally{r.close()}};let o=await Se(d.cli,ke(A,()=>process.stdin.isTTY===!0));or();const s=await Y();let C;const y=async()=>s?(C===void 0&&(C=(await ue({targetCubeId:s.cubeId},k())).length>0),C):!1,x=process.stdin.isTTY===!0,v=process.stdout.isTTY===!0,T=me({explicitCli:d.cli,stdinIsTTY:x,stdoutIsTTY:v,hasActiveCube:s!==null,hasLaunchAllTargets:ge({explicitCli:d.cli,stdinIsTTY:x,stdoutIsTTY:v,hasActiveCube:s!==null})?await y():!1});if(T&&process.stderr.write(T),he({extraArgs:process.argv.slice(2),stdinIsTTY:x,stdoutIsTTY:v})){const e=E($()).filter(n=>n!==o),r=await fe({defaultCli:o,otherInstalledClis:e,hasLaunchAllTargets:await y()},A);if(r.kind==="launch-all"){const n=O([]),B=n.ok?await D(n.args,k()):1;process.exit(B)}o=r.cli}const l=d.rest;we(s?{label:s.droneLabel,cubeName:s.name}:null,G(process.cwd()));const N=Fe(o,s&&o==="claude"?V(s.cubeId,s.droneId):null,s&&o==="claude"?X(b(process.cwd())):null);await Promise.race([c,new Promise(e=>setTimeout(e,2e3))]);const P=o==="codex"?`borg-wake-${_()}`:null;let g,I=[],u={...S(process.env,o),BORG_SESSION:"1"},p=null,m=null;if(o==="codex"&&!l.includes("--remote")){console.error(`${t()}${i.gray("\u25FC Starting Codex remote-wake app-server\u2026")}`);const e=await Ie(Le());e.warning?(console.error(`${t()}${i.yellow(`warning: ${e.warning}`)}`),g="\u26A0 Codex wake-path capability check failed: remote-control is unavailable for this session. Run borg_regen manually whenever you return, and expect only fallback wakeups until relaunch."):g="Codex wake-path capability check passed: remote-control socket established for this session.",I=e.args,u={...S(process.env,o),...e.env,BORG_SESSION:"1"},p=M(e.args),m=e.server?.cleanup??null}else o==="codex"&&l.includes("--remote")&&(g="Codex wake-path capability check: using caller-provided --remote socket; if no wake arrives, run borg_regen manually when returning to the session.",p=M(l),p&&(u={...S(process.env,o),[De]:"1",BORG_SESSION:"1"}));if(s){const e=await K(s.cubeId,b(),s.droneId),r=z(u,e,process.env);if(u=r.env,r.probe){const n=await J(r.probe.descriptor,fetch,r.probe.baseUrl);n.ok||console.error(`${t()}${i.yellow(`warning: ${n.message}`)}`)}}const f=Ne({cli:o,codexWakeNonce:P,monitorClause:N,codexWakePathClause:g});let h;if(o==="codex")h=[...We(),...Ee(),...Me(p!==null),...I,...Re([...l,f],process.cwd())];else if(o==="opencode"){const e=s?H(s.droneId):14096;Qe(),h=[process.cwd(),"--port",String(e),"--auto","--prompt",f,...l]}else h=se(l,f);const F=o==="claude"?"Claude Code":o==="codex"?"Codex":"OpenCode";console.error(`${t()}${i.blue(`\u25FC Launching ${F}\u2026`)}`);const R=W(o,h,{stdio:"inherit",shell:!1,env:u});if(o==="opencode"){const r=`http://127.0.0.1:${s?H(s.droneId):14096}`;Ze({serverUrl:r,directory:process.cwd(),droneLabel:s?.droneLabel??"opencode",cubeName:s?.name??"borg"}).then(()=>er(f)).catch(()=>{})}o==="codex"&&s&&p&&(Be({deps:{setCodexWakeTarget:j,findLoadedCodexThread:He},cubeId:s.cubeId,droneId:s.droneId,socketPath:p,passthroughArgs:l,previewNeedle:P??f.slice(0,120),cwd:process.cwd(),launchedAtSeconds:Math.floor(Date.now()/1e3)}),q(e=>Oe(e))),R.on("error",e=>{if(m)try{m()}catch{}if(e.code==="ENOENT"){console.error(`${t()}${i.red(`
|
|
10
|
+
\u25FC Failed to launch ${o}`)}`);const r=o==="opencode"?"opencode":o;console.error(`${t()}${i.gray(`Make sure ${r} is installed.
|
|
11
11
|
`)}`)}else console.error(`${t()}${i.red(`
|
|
12
|
-
\u25FC Failed to launch ${
|
|
13
|
-
`)}`);process.exit(1)}),
|
|
12
|
+
\u25FC Failed to launch ${o}: ${e.message}
|
|
13
|
+
`)}`);process.exit(1)}),R.on("exit",e=>{if(m)try{m()}catch{}process.exit(e??0)})}function or(){const c=$();if(c.claude)try{Xe()||Ye(),Ve(b(process.cwd())),Je(),je()}catch(a){console.error(`${t()}${i.yellow(`warning: Claude Code integration check failed: ${a?.message??a}`)}`)}if(c.codex)try{qe()||_e(),Ge(),Ue()}catch(a){console.error(`${t()}${i.yellow(`warning: Codex integration check failed: ${a?.message??a}`)}`)}if(c.opencode)try{ze()||Ke()}catch(a){console.error(`${t()}${i.yellow(`warning: OpenCode integration check failed: ${a?.message??a}`)}`)}}rr().catch(c=>{console.error(`${t()}${i.red(`
|
|
14
14
|
\u25FC Error: ${c.message}
|
|
15
15
|
`)}`),process.exit(1)});
|
package/dist/codex-app-wake.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const CODEX_WAKE_PROMPT = "New Borg cube-log activity arrived.";
|
|
|
5
5
|
export declare function formatCodexWakePrompt(inboxLine: string): string;
|
|
6
6
|
export declare const CODEX_CATCHUP_PROMPT = "Borg cube activity arrived while you were busy. Wake triage: run `borg_read-log unread_only=true` and DRAIN \u2014 repeat until the returned page is under the limit and behind_by is 0 \u2014 so no entries are skipped. Then handle actionable entries; if none, resume the prior interrupted work.";
|
|
7
7
|
export declare function isCodexRemoteWakeEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
8
|
-
export
|
|
8
|
+
export { resolveSessionAgentKind } from './agent-runtime.js';
|
|
9
9
|
export interface CodexWakeTarget {
|
|
10
10
|
enabled: boolean;
|
|
11
11
|
}
|
|
@@ -73,14 +73,17 @@ export declare function fireCodexHeartbeatTick(deps?: CodexWakeDeps, cadenceMs?:
|
|
|
73
73
|
* fireCodexHeartbeatTick every cadence. CODEX-ONLY: claude wakes via the tail-F
|
|
74
74
|
* inbox Monitor + /loop ScheduleWakeup and has NO app-server socket to inject
|
|
75
75
|
* into, so the heartbeat is intrinsically a codex mechanism. The gate reads
|
|
76
|
-
* agentKind LOCALLY from this child's own env
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
76
|
+
* agentKind and remote-wake capability LOCALLY from this child's own env,
|
|
77
|
+
* never a mutable/server-recorded field, so a mislabel can't silently defeat
|
|
78
|
+
* the backstop (gh#633 lesson). Agent CLI identity and remote transport are
|
|
79
|
+
* separate: a Codex CLI without a live remote transport has no app-server
|
|
80
|
+
* heartbeat to run. The timer is unref'd so it never keeps the process alive.
|
|
81
|
+
* Returns the timer, or null when this is not a remotely-wakeable Codex
|
|
82
|
+
* session. Injectable for tests.
|
|
81
83
|
*/
|
|
82
84
|
export declare function startCodexHeartbeat(opts?: {
|
|
83
85
|
agentKind?: 'claude' | 'codex' | 'opencode';
|
|
86
|
+
remoteWakeEnabled?: boolean;
|
|
84
87
|
intervalMs?: number;
|
|
85
88
|
tick?: () => void;
|
|
86
89
|
}): ReturnType<typeof setInterval> | null;
|
package/dist/codex-app-wake.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getActiveCube as
|
|
2
|
-
${e}`}const
|
|
1
|
+
import{getActiveCube as x,getCodexWakeTarget as C,setCodexWakeTarget as R}from"./cubes.js";import{CodexAppServerClient as S}from"./codex-app-server.js";import{checkCodexBridgeHealthy as K}from"./codex-remote.js";import{recordEventReceipt as W}from"./health-beat.js";import{BORG_CODEX_REMOTE_WAKE_ENV as O,resolveSessionAgentKind as M}from"./agent-runtime.js";import{codexAppServerSocketFromEnv as B,pickFreshThread as F,wakeTargetChanged as N,wakeRetryBackoffMs as H,wakeRetryExpired as j,WAKE_RETRY_MAX_ATTEMPTS as L,shouldFireHeartbeat as X}from"./codex-wake-resolve.js";const q="New Borg cube-log activity arrived.";function se(e){return`New Borg cube-log activity arrived:
|
|
2
|
+
${e}`}const _="Borg cube activity arrived while you were busy. Wake triage: run `borg_read-log unread_only=true` and DRAIN \u2014 repeat until the returned page is under the limit and behind_by is 0 \u2014 so no entries are skipped. Then handle actionable entries; if none, resume the prior interrupted work.";function D(e=process.env){return e[O]==="1"}import{resolveSessionAgentKind as ke}from"./agent-runtime.js";function V(e=process.env){return D(e)?{enabled:!0}:{enabled:!1}}async function le(e,t={}){try{const r=await(t.getCodexWakeTarget??C)(e.cubeId,e.droneId);return r?(t.checkBridge??K)(r.socketPath):!1}catch{return null}}let f=!1;const h=[],u=new Set,w=[],$=100;let g=!1,k=null;function ue(){return k}function T(e){k=(e.now??Date.now)()}let v=!1,y=!1;function p(){return y?!1:(y=!0,!0)}function A(){y=!1}function Y(e){return e?.code==="ENOENT"}function G(e){return new Promise(t=>setTimeout(t,e))}function m(e,t){return t.createClient?t.createClient(e):new S(e)}async function b(e,t){const n=B(t.env??process.env);if(n){const o=m(n,t);await o.connect();try{const a=await o.loadedThreadIds(),i=[];for(const l of a){const s=await o.readThread(l);s&&i.push({id:s.id,cwd:s.cwd,updatedAt:s.updatedAt})}const c=F(i,{cwd:(t.cwd??(()=>process.cwd()))()});return c?(await Q(e,{socketPath:n,threadId:c},t),{socketPath:n,threadId:c}):null}finally{o.close()}}const r=await(t.getCodexWakeTarget??C)(e.cubeId,e.droneId);return r?{socketPath:r.socketPath,threadId:r.threadId}:null}async function Q(e,t,n){try{const r=n.getCodexWakeTarget??C,o=n.setCodexWakeTarget??R,a=await r(e.cubeId,e.droneId),i=a?{socketPath:a.socketPath,threadId:a.threadId}:null;N(i,t)&&await o(e.cubeId,e.droneId,t)}catch{}}function de(e=q,t=process.env,n={}){V(t).enabled&&(h.push({reason:e,deps:n}),!f&&(f=!0,U().finally(()=>{f=!1})))}async function U(){for(;h.length>0;){const e=h.shift();await z(e.reason,e.deps)}}async function z(e,t){if(!p()){E(t);return}try{const n=await(t.getActiveCube??x)();if(!n)return;const r=await b(n,t);if(!r)return;const{socketPath:o,threadId:a}=r,i=`${a}\0${e}`;if(u.has(i))return;const c=m(o,t);await c.connect();try{if((await c.readThread(a))?.status?.type==="active"){E(t);return}await c.startTurn(a,e),W(),ee(i),T(t)}finally{c.close()}}catch{E(t)}finally{A()}}function E(e){g||(g=!0,J(e).finally(()=>{g=!1}))}async function J(e){const t=e.sleep??G,n=e.now??Date.now,r=e.jitter??(()=>Math.random()*500),o=e.maxAttempts??L,a=n();let i=0;for(;!j(a,n())&&i<o;)if(await t(H(i,r())),i++,!!p())try{const c=await(e.getActiveCube??x)();if(!c)continue;const l=await b(c,e);if(!l)continue;const{socketPath:s,threadId:I}=l,d=m(s,e);await d.connect();try{if((await d.readThread(I))?.status?.type==="active")continue;await d.startTurn(I,_),W(),T(e);return}finally{d.close()}}catch{}finally{A()}}const P=20*6e4;async function Z(e={},t=P){if(v)return;const n=(e.now??Date.now)();if(X(k,n,t)&&!(e.isStreamOwner&&!e.isStreamOwner())&&p()){v=!0;try{const r=await(e.getActiveCube??x)();if(!r)return;const o=await b(r,e);if(!o)return;const a=m(o.socketPath,e);await a.connect();try{if((await a.readThread(o.threadId))?.status?.type==="active")return;await a.startTurn(o.threadId,_),T(e)}finally{a.close()}}catch(r){Y(r)&&e.onAppServerSocketDead?.()}finally{v=!1,A()}}}function fe(e={}){const t=e.agentKind??M(),n=e.remoteWakeEnabled??D();if(t!=="codex"||!n)return null;const r=e.intervalMs??P,o=e.tick??(()=>{Z()}),a=setInterval(o,r);return a.unref?.(),a}function he(){f=!1,h.length=0,u.clear(),w.length=0,g=!1,k=null,v=!1,y=!1}function ee(e){if(!u.has(e))for(u.add(e),w.push(e);w.length>$;){const t=w.shift();t&&u.delete(t)}}export{_ as CODEX_CATCHUP_PROMPT,P as CODEX_HEARTBEAT_CADENCE_MS,q as CODEX_WAKE_PROMPT,Z as fireCodexHeartbeatTick,se as formatCodexWakePrompt,ue as getLastDeliveredAt,D as isCodexRemoteWakeEnabled,le as probeCodexBridgeArmed,he as resetCodexWakeForTests,V as resolveCodexWakeTarget,ke as resolveSessionAgentKind,fe as startCodexHeartbeat,de as wakeCodexViaAppServer};
|
package/dist/codex-remote.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdirSync as
|
|
1
|
+
import{mkdirSync as C,chmodSync as v,readdirSync as w,rmSync as k,writeFileSync as A,readFileSync as y}from"node:fs";import{homedir as S}from"node:os";import{join as u}from"node:path";import{randomBytes as b}from"node:crypto";import{spawn as E}from"node:child_process";import{CodexAppServerClient as _}from"./codex-app-server.js";import{codexBorgSessionConfigArgs as N,BORG_SESSION_ENV as R}from"./launch-gate.js";import{codexAppServerSocketConfigArgs as $}from"./codex-wake-resolve.js";import{BORG_AGENT_KIND_ENV as I,BORG_CODEX_REMOTE_WAKE_ENV as x,codexAgentKindConfigArgs as T,codexRemoteWakeConfigArgs as M}from"./agent-runtime.js";const O=u(S(),".config","borgmcp","codex-remote");function q(e,r){return P(e)?e:["--cd",r,...e]}function P(e){return e.some(r=>r==="--cd"||r.startsWith("--cd=")||r==="-C")}function g(e){try{return process.kill(e,0),!0}catch(r){return r?.code==="EPERM"}}function H(e,r={}){if(!e)return null;const a=r.isAlive??g,i=r.readPidFile??(o=>y(o,"utf-8")),c=e.replace(/\.sock$/,".pid");try{const o=Number.parseInt(i(c).trim(),10);return Number.isNaN(o)?null:a(o)}catch{return null}}function s(e){try{k(e,{force:!0})}catch{}}function B(e,r){let a;try{a=w(e)}catch{return}for(const i of a){if(!i.endsWith(".pid"))continue;const c=u(e,i),o=u(e,i.replace(/\.pid$/,".sock"));let t;try{t=Number.parseInt(y(c,"utf-8").trim(),10)}catch{s(c);continue}(Number.isNaN(t)||!r(t))&&(s(o),s(c))}}function p(e){return{args:[],env:{},warning:e}}async function U(e){const r=e.runtimeDir??O,a=e.isAlive??g,i=e.readyTimeoutMs??8e3,c=e.pollIntervalMs??250;try{C(r,{recursive:!0,mode:448}),v(r,448),B(r,a)}catch(n){return p(`Codex remote-wake disabled: could not prepare ${r} (${n?.message??n}); run borg_regen manually.`)}const o=(e.socketId??(()=>b(16).toString("hex")))(),t=u(r,`${o}.sock`),m=u(r,`${o}.pid`);let l;try{l=e.spawnAppServer(t)}catch(n){return s(t),p(`Codex remote-wake disabled: could not start \`codex app-server\` (${n?.message??n}) \u2014 is Codex installed + up to date? This session only wakes on the ~30min /loop fallback; run borg_regen manually.`)}if(l.pid!=null)try{A(m,String(l.pid))}catch{}const f=()=>{try{l.kill()}catch{}s(t),s(m)},h=Math.max(1,Math.ceil(i/c));let d=!1;for(let n=0;n<h&&!d;n++){try{d=await e.probeReady(t)}catch{d=!1}!d&&n<h-1&&await e.sleep(c)}return d?{args:["--remote",`unix://${t}`],env:{[x]:"1"},server:{pid:l.pid,socketPath:t,cleanup:f}}:(f(),p(`Codex remote-wake disabled: could not reach a Codex app-server at ${t} within ${i}ms (is Codex up to date? \`codex app-server --listen\` is required). This session only wakes on the ~30min /loop fallback \u2014 run borg_regen manually when you return.`))}function z(){return{spawnAppServer:e=>{const r=E("codex",["app-server",...N(),...T(),...M(),...$(e),"--listen",`unix://${e}`],{stdio:"ignore",shell:!1,env:{...process.env,[R]:"1",[I]:"codex",[x]:"1"}});return{pid:r.pid,kill:()=>{try{r.kill()}catch{}}}},probeReady:async e=>{const r=new _(e);try{return await r.connect(),await r.loadedThreadIds(),!0}catch{return!1}finally{try{r.close()}catch{}}},sleep:e=>new Promise(r=>setTimeout(r,e))}}export{O as DEFAULT_CODEX_REMOTE_DIR,H as checkCodexBridgeHealthy,z as defaultCodexRemoteDeps,g as defaultIsAlive,U as prepareCodexRemoteLaunch,q as withCodexCwdArg};
|
package/dist/config-utils.d.ts
CHANGED
|
@@ -119,10 +119,12 @@ export declare function isCodexUserPromptSubmitHookRegistered(hooksPath?: string
|
|
|
119
119
|
export declare function isOpenCodeMcpServerConfigured(configPath?: string): boolean;
|
|
120
120
|
/**
|
|
121
121
|
* Add borg MCP server to OpenCode using `opencode mcp add` CLI.
|
|
122
|
-
* Pins BORG_SESSION=1,
|
|
123
|
-
* environment so the MCP child inherits the
|
|
124
|
-
* signal (same approach as
|
|
125
|
-
* only see pinned env, not parent process
|
|
122
|
+
* Pins BORG_SESSION=1, BORG_AGENT_KIND=opencode, the legacy BORG_OPENCODE=1,
|
|
123
|
+
* and BORG_API_URL in the server environment so the MCP child inherits the
|
|
124
|
+
* activation gate + explicit agent-kind signal (same approach as Codex's
|
|
125
|
+
* pinned env — OpenCode MCP children only see pinned env, not parent process
|
|
126
|
+
* env). Existing configs with BORG_OPENCODE remain supported by the runtime
|
|
127
|
+
* fallback.
|
|
126
128
|
*/
|
|
127
129
|
export declare function addOpenCodeMcpServer(): void;
|
|
128
130
|
//# sourceMappingURL=config-utils.d.ts.map
|
package/dist/config-utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{execSync as d}from"child_process";import n from"fs";import f from"os";import i from"path";import{fileURLToPath as
|
|
2
|
-
`,"utf-8")}function S(e){if(!n.existsSync(e))return{};const r=n.readFileSync(e,"utf-8");return r.trim()?JSON.parse(r):{}}function
|
|
3
|
-
`,"utf-8")}function
|
|
1
|
+
import{execSync as d}from"child_process";import n from"fs";import f from"os";import i from"path";import{fileURLToPath as v}from"url";import{dirname as R}from"path";import{BORG_AGENT_KIND_ENV as A,BORG_CODEX_REMOTE_WAKE_ENV as E,withAgentRuntimeEnv as U}from"./agent-runtime.js";const H=v(import.meta.url),j=R(H),a="borg-regen",m="borg-log-audit",N=i.join(f.homedir(),".claude.json"),w=i.join(f.homedir(),".codex","config.toml"),u=i.join(f.homedir(),".codex","hooks.json"),I=i.join(f.homedir(),".config","opencode","opencode.json"),G="borg";function h(){return i.join(f.homedir(),".claude","settings.json")}function p(){const e=h();if(!n.existsSync(e))return{};const r=n.readFileSync(e,"utf-8");return r.trim()?JSON.parse(r):{}}function y(e){const r=h();n.mkdirSync(i.dirname(r),{recursive:!0}),n.writeFileSync(r,JSON.stringify(e,null,2)+`
|
|
2
|
+
`,"utf-8")}function S(e){if(!n.existsSync(e))return{};const r=n.readFileSync(e,"utf-8");return r.trim()?JSON.parse(r):{}}function x(e,r){n.mkdirSync(i.dirname(e),{recursive:!0}),n.writeFileSync(e,JSON.stringify(r,null,2)+`
|
|
3
|
+
`,"utf-8")}function K(){return C(h())}function V(e){return C(P(e))}function X(e){return $(P(e))}function P(e){return i.join(e,".claude","settings.local.json")}function C(e){let r;try{r=S(e)}catch(t){return console.error(`\u26A0 Could not parse ${e}: ${t.message}. Skipping hook registration; you can add it manually.`),!1}return r.hooks??={},r.hooks.SessionStart??=[],r.hooks.SessionStart.some(t=>Array.isArray(t?.hooks)&&t.hooks.some(s=>s?.type==="command"&&s?.command===a))?!1:(r.hooks.SessionStart.push({matcher:"*",hooks:[{type:"command",command:a}]}),x(e,r),!0)}function $(e){let r;try{r=S(e)}catch{return!1}const o=r?.hooks?.SessionStart;return Array.isArray(o)?o.some(t=>Array.isArray(t?.hooks)&&t.hooks.some(s=>s?.type==="command"&&s?.command===a)):!1}function W(){let e;try{e=p()}catch{return!1}const r=e?.hooks?.SessionStart;return Array.isArray(r)?r.some(o=>Array.isArray(o?.hooks)&&o.hooks.some(t=>t?.type==="command"&&t?.command===a)):!1}function Q(){let e;try{e=p()}catch{return!1}const r=e?.hooks?.UserPromptSubmit;return Array.isArray(r)?r.some(o=>Array.isArray(o?.hooks)&&o.hooks.some(t=>t?.type==="command"&&t?.command===m)):!1}function q(){let e;try{e=p()}catch{return!1}if(!e?.hooks?.SessionStart)return!1;let r=!1;return e.hooks.SessionStart=e.hooks.SessionStart.map(o=>{if(!Array.isArray(o?.hooks))return o;const t=o.hooks.filter(s=>!(s?.type==="command"&&s?.command===a));return t.length!==o.hooks.length?(r=!0,{...o,hooks:t}):o}).filter(o=>Array.isArray(o?.hooks)&&o.hooks.length>0),e.hooks.SessionStart.length===0&&delete e.hooks.SessionStart,Object.keys(e.hooks).length===0&&delete e.hooks,r&&y(e),r}function z(){let e;try{e=p()}catch(o){return console.error(`\u26A0 Could not parse ${h()}: ${o.message}. Skipping audit hook registration.`),!1}return e.hooks??={},e.hooks.UserPromptSubmit??=[],e.hooks.UserPromptSubmit.some(o=>Array.isArray(o?.hooks)&&o.hooks.some(t=>t?.type==="command"&&t?.command===m))?!1:(e.hooks.UserPromptSubmit.push({matcher:"*",hooks:[{type:"command",command:m}]}),y(e),!0)}function Y(){let e;try{e=p()}catch{return!1}if(!e?.hooks?.UserPromptSubmit)return!1;let r=!1;return e.hooks.UserPromptSubmit=e.hooks.UserPromptSubmit.map(o=>{if(!Array.isArray(o?.hooks))return o;const t=o.hooks.filter(s=>!(s?.type==="command"&&s?.command===m));return t.length!==o.hooks.length?(r=!0,{...o,hooks:t}):o}).filter(o=>Array.isArray(o?.hooks)&&o.hooks.length>0),e.hooks.UserPromptSubmit.length===0&&delete e.hooks.UserPromptSubmit,Object.keys(e.hooks).length===0&&delete e.hooks,r&&y(e),r}function Z(e=N){try{if(!n.existsSync(e))return!1;const r=n.readFileSync(e,"utf-8");if(!r.trim())return!1;const o=JSON.parse(r);if(!o||typeof o!="object")return!1;const t=o.mcpServers;return!t||typeof t!="object"||Array.isArray(t)?!1:G in t}catch{return!1}}function ee(e=w){try{if(!n.existsSync(e))return!1;const r=n.readFileSync(e,"utf-8"),o=/^\s*\[mcp_servers\.borg\]\s*$/m.test(r),t=new RegExp(`^\\s*${A}\\s*=\\s*"codex"\\s*$`,"m").test(r),s=new RegExp(`^\\s*${E}\\s*=\\s*"1"\\s*$`,"m").test(r);return o&&(t||s)}catch{return!1}}function re(){return i.join(j,"index.js")}function oe(){try{try{d("claude mcp remove --scope user borg",{stdio:"ignore"})}catch{}d("claude mcp add --scope user borg borg-mcp",{stdio:"inherit",env:{...process.env,BORG_API_URL:process.env.BORG_API_URL||"https://api.borgmcp.ai"}})}catch(e){throw e.message?.includes("command not found")?new Error("Claude CLI not found. Please install Claude Code first."):new Error(`Failed to add MCP server: ${e.message}`)}}function te(){try{try{d("codex mcp remove borg",{stdio:"ignore"})}catch{}const e=process.env.BORG_API_URL||"https://api.borgmcp.ai",r=U(process.env,"codex");d("codex mcp add borg --env BORG_API_URL="+_(e)+` --env ${A}=codex -- borg-mcp`,{stdio:"inherit",env:{...r,BORG_API_URL:e}})}catch(e){throw e.message?.includes("command not found")?new Error("Codex CLI not found. Please install Codex first."):new Error(`Failed to add MCP server to Codex: ${e.message}`)}}function _(e){return`'${e.replace(/'/g,"'\\''")}'`}function O(e,r,o={}){let t;try{t=S(u)}catch(l){return console.error(`\u26A0 Could not parse ${u}: ${l.message}. Skipping Codex hook registration.`),!1}t.hooks??={},t.hooks[e]??=[];const s=t.hooks[e];if(!Array.isArray(s)||s.some(l=>Array.isArray(l?.hooks)&&l.hooks.some(g=>g?.type==="command"&&g?.command===r)))return!1;const c={hooks:[{type:"command",command:r}]};return o.matcher&&(c.matcher=o.matcher),typeof o.timeout=="number"&&(c.hooks[0].timeout=o.timeout),s.push(c),x(u,t),!0}function se(){return O("SessionStart",a,{matcher:"startup|resume",timeout:30})}function ne(){return O("UserPromptSubmit",m,{timeout:10})}function b(e,r,o=u){try{const s=S(o)?.hooks?.[e];return Array.isArray(s)?s.some(k=>Array.isArray(k?.hooks)&&k.hooks.some(c=>c?.type==="command"&&c?.command===r)):!1}catch{return!1}}function ie(e=u){return b("SessionStart",a,e)}function ae(e=u){return b("UserPromptSubmit",m,e)}function ce(e=I){try{if(!n.existsSync(e))return!1;const r=n.readFileSync(e,"utf-8");if(!r.trim())return!1;const o=JSON.parse(r);if(!o||typeof o!="object")return!1;const t=o.mcp?.borg;return!t||typeof t!="object"?!1:t.type==="local"}catch{return!1}}function me(){try{const e=process.env.BORG_API_URL||"https://api.borgmcp.ai";d(`opencode mcp add borg --env BORG_SESSION=1 --env BORG_AGENT_KIND=opencode --env BORG_OPENCODE=1 --env BORG_API_URL=${_(e)} -- borg-mcp`,{stdio:"inherit"})}catch(e){throw e.message?.includes("command not found")?new Error("opencode CLI not found. Please install opencode first."):new Error(`Failed to add MCP server to opencode: ${e.message}`)}}export{te as addCodexMcpServer,se as addCodexSessionStartHook,ne as addCodexUserPromptSubmitHook,oe as addMcpServer,me as addOpenCodeMcpServer,V as addProjectSessionStartHook,K as addSessionStartHook,z as addUserPromptSubmitHook,re as getBinaryPath,b as isCodexHookRegistered,ee as isCodexMcpServerConfigured,ie as isCodexSessionStartHookRegistered,ae as isCodexUserPromptSubmitHookRegistered,Z as isMcpServerConfigured,ce as isOpenCodeMcpServerConfigured,X as isProjectSessionStartHookRegistered,W as isSessionStartHookRegistered,Q as isUserPromptSubmitHookRegistered,q as removeSessionStartHook,Y as removeUserPromptSubmitHook};
|
package/dist/health-beat.d.ts
CHANGED
|
@@ -43,10 +43,9 @@ export interface HealthPayload {
|
|
|
43
43
|
wake_armed: boolean;
|
|
44
44
|
/**
|
|
45
45
|
* gh#634: the drone's agent_kind from LIVE runtime detection
|
|
46
|
-
* (resolveSessionAgentKind).
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* COALESCE — same always-running-child self-heal pattern as wake_armed.
|
|
46
|
+
* (resolveSessionAgentKind). Assimilation captures agent_kind only at join,
|
|
47
|
+
* so a relaunch of an existing seat needs this always-running child to
|
|
48
|
+
* refresh the recorded value through recordDroneHealth's COALESCE update.
|
|
50
49
|
*/
|
|
51
50
|
agent_kind: 'claude' | 'codex' | 'opencode';
|
|
52
51
|
/**
|
package/dist/health-beat.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let
|
|
1
|
+
let r=null,i=null,l=null;function g(e=new Date){r=e}function v(){return r}function y(){return i}function k(){return l}function A(){r=null,i=null,l=null}function d(e,t,n,o,a,c){return{sse_connected:e,inbox_monitor_armed:t!==!1,wake_armed:n!==!1,agent_kind:o,hostname:a,version:c,last_event_at:r?r.toISOString():null}}async function f(e,t,n){try{const o=await n.getToken();await n.fetchImpl(`${e.apiUrl}/api/drone/health`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"X-Drone-Session":e.sessionToken,"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}async function m(e,t){const n=d(t.sseConnected,t.inboxMonitorHealthy,t.wakeArmed,t.agentKind,t.hostname,t.version);await f(e,n,t)}async function h(e){try{const t=await e.getActiveCube();if(!t)return;const n=e.getStreamConnected(),o=e.checkMonitor(e.getInboxPath(t));i=o;const a=e.resolveAgentKind(),c=a==="opencode"?await e.probeOpenCodeDrone?.(t)??null:a==="codex"?e.isCodexRemoteWake()?await e.probeBridgeArmed(t):!1:o;l=c;const s=e.resolveHostname(),u=e.resolveVersion();await m(t,{sseConnected:n,inboxMonitorHealthy:o,wakeArmed:c,agentKind:a,hostname:s,version:u,fetchImpl:e.fetchImpl,getToken:e.getToken})}catch{}}const x=6e4;function H(e,t=x){h(e);const n=setInterval(()=>{h(e)},t);return n.unref?.(),n}export{x as HEALTH_BEAT_INTERVAL_MS,A as __resetHealthBeatStateForTest,d as buildHealthPayload,m as emitHealthBeat,y as getCachedMonitorHealthy,k as getCachedWakeArmed,v as getLastEventReceivedAt,f as postHealthBeat,g as recordEventReceipt,h as runHealthBeatOnce,H as startHealthBeatTick};
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Server as X}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Z}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as ee,ListToolsRequestSchema as te,ListPromptsRequestSchema as oe,GetPromptRequestSchema as re}from"@modelcontextprotocol/sdk/types.js";import{assertRoleMatches as ne}from"./role-match.js";import{getCubeInfo as se,getRoleInfo as A,getRoleInfoByName as ie,getRoster as ae,readLog as ce,appendLog as le,submitReport as de,fetchReports as ue,ackLogEntry as pe,recordDecision as me,listDecisions as be,regen as L,listCubes as fe,createCube as ge,updateCube as O,deleteCube as he,createRole as _e,updateRole as ye,patchRoleSection as
|
|
2
|
+
import{Server as X}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Z}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as ee,ListToolsRequestSchema as te,ListPromptsRequestSchema as oe,GetPromptRequestSchema as re}from"@modelcontextprotocol/sdk/types.js";import{assertRoleMatches as ne}from"./role-match.js";import{getCubeInfo as se,getRoleInfo as A,getRoleInfoByName as ie,getRoster as ae,readLog as ce,appendLog as le,submitReport as de,fetchReports as ue,ackLogEntry as pe,recordDecision as me,listDecisions as be,regen as L,listCubes as fe,createCube as ge,updateCube as O,deleteCube as he,createRole as _e,updateRole as ye,patchRoleSection as C,patchTaxonomyClass as B,deleteRole as we,reassignDrone as xe,evictDrone as $e,getCube as x,checkSubscriptionStatus as ve,createBillingPortalSession as ke,createSubscription as Ee,syncRoles as Ce,applyTemplate as Re,whoami as Se,roleRationale as Ie,getValidToken as Te}from"./remote-client.js";import{startHealthBeatTick as qe}from"./health-beat.js";import{getTemplate as R,listTemplateNames as S,resolveCubeDirectiveForCreate as De,resolveCubeDirectiveForApply as Pe,resolveMessageTaxonomyForCreate as Ue}from"./templates.js";import{activeCubeWithFreshRegenIdentity as F,getActiveCube as g,setActiveCube as H,findProjectRoot as I,inboxPathForDrone as T}from"./cubes.js";import{monitorStateRootForWorktree as q}from"./inbox-monitor.js";import{addSessionStartHook as je,addUserPromptSubmitHook as Ne}from"./config-utils.js";import{humanAgo as W,formatLogEntryMarkdown as Me,formatRegenMarkdown as V,getDronePlaybook as Ae,getDronePlaybookChapter as Le,nullTaxonomyTip as Oe,regenWakePathDroneLabel as Be}from"./regen-format.js";import{startLogStream as Fe,getStreamStatus as D}from"./log-stream.js";import{isMcpReadinessProbe as He}from"./readiness-probe.js";import{runMcpStartupServices as We}from"./startup-services.js";import{TOOL_MANIFEST as Ve}from"./tool-manifest.js";import{DOCS_SECTIONS as ze,matchDocsSections as Ke,formatDocsIndex as Je}from"./docs-sections.js";import{renderRoleList as Qe}from"./list-roles-render.js";import{filterToolsForRole as Ye}from"./tool-scope.js";import{getPackageVersion as $,getOnDiskVersion as Ge,handleVersionFlag as Xe}from"./version.js";import{renderStreamStatus as Ze,checkInboxMonitorHealthy as P,formatWakePathPrefix as et,shouldShowWakePathWarning as tt}from"./stream-status.js";import{formatRoleAgentLabel as ot,renderRoster as rt}from"./roster-render.js";import{resolveDroneIdByLabel as nt,isUuidShape as st}from"./evict-drone.js";import{authRecoveryMessage as it}from"./auth-recovery.js";import{DroneEvictedError as at,DroneFrozenError as ct,formatEvictedToolResult as lt,formatFrozenToolResult as dt}from"./drone-lifecycle.js";import{classifyInSessionAssimilate as ut,reattachOnlyRefusal as pt,reattachFailureMessage as mt}from"./assimilate-guard.js";import{gateAllowsActivation as bt,borgSessionToolNotice as ft}from"./launch-gate.js";import{renderSyncRolesResult as gt}from"./sync-roles-render.js";import{initConsolePrefix as ht,consolePrefix as v}from"./console-prefix.js";import{isCodexRemoteWakeEnabled as _t,resolveSessionAgentKind as U,probeCodexBridgeArmed as yt}from"./codex-app-wake.js";import{connectOpenCodeDrone as wt,injectOpenCodeEntry as xt,probeOpenCodeDroneArmed as $t,computeOpenCodePort as vt}from"./opencode-drone.js";import{installBorgPlugin as kt}from"./opencode-plugin.js";import{setModuleInjectOpenCode as Et}from"./log-stream.js";import{lifecycleSignalForMessage as Ct,recordLifecycleLog as z,shouldSuppressLifecycleLog as Rt}from"./lifecycle-log-guard.js";import{normalizeDirectLogRecipients as St}from"./direct-log.js";import K from"open";import It from"os";function Tt(){try{const m=It.hostname();return m&&m.trim()?m.trim().slice(0,255):null}catch{return null}}async function J(m,y){return await Re(m,y.name)}async function h(){const m=await g();if(!m)throw new Error("Not assimilated to a cube. Use borg_assimilate <cube-name> first.");return m}async function qt(){Xe();const m=He();await We(m,{sessionStartHook:()=>{je()},auditHook:()=>{Ne()},sseStream:()=>{Fe()},openCode:async()=>{kt();const l=await g();if(l&&process.env.BORG_OPENCODE==="1"){const o=`http://127.0.0.1:${vt(l.droneId)}`;await wt({serverUrl:o,directory:process.cwd(),droneLabel:l.droneLabel,cubeName:l.name}),Et(xt)}},healthBeat:()=>{qe({getActiveCube:g,getStreamConnected:()=>D().connected,getInboxPath:l=>T(l.cubeId,l.droneId),checkMonitor:l=>P(l,q(I())),isCodexRemoteWake:_t,probeBridgeArmed:l=>yt({cubeId:l.cubeId,droneId:l.droneId}),probeOpenCodeDrone:()=>$t(),resolveAgentKind:U,resolveHostname:Tt,resolveVersion:$,getToken:Te,fetchImpl:globalThis.fetch.bind(globalThis)})}});const y=new X({name:"borg-mcp-client",version:$()},{capabilities:{tools:{},prompts:{}}}),j=Ve;y.setRequestHandler(te,async()=>{let l=null;try{const p=await g();p&&(l={roleName:p.roleName,roleClass:p.roleClass,isHumanSeat:p.isHumanSeat})}catch{l=null}return{tools:Ye(j,l)}}),y.setRequestHandler(ee,async l=>{let{name:p,arguments:o}=l.params;if(p==="borg_describe-tool"){const e=typeof o?.name=="string"?o.name:"",t=j.find(r=>r.name===e);return t?{content:[{type:"text",text:JSON.stringify({name:t.name,description:t.description,inputSchema:t.inputSchema},null,2)}]}:{content:[{type:"text",text:`Unknown borg tool: ${e||"(none)"}. Pass { name: "<borg_tool>" }.`}],isError:!0}}if(p==="borg_tool"){const e=typeof o?.name=="string"?o.name:"";if(!e||e==="borg_tool"||e==="borg_describe-tool")return{content:[{type:"text",text:'borg_tool: pass { name: "<borg_tool>", arguments: {...} } naming a real borg tool (not the dispatcher itself).'}],isError:!0};o=o?.arguments&&typeof o.arguments=="object"?o.arguments:{},p=e}if(!bt(`tool ${p}`))return{content:[{type:"text",text:ft(p)}],isError:!0};try{switch(p){case"borg_regen":{const e=await g();if(!e)return{content:[{type:"text",text:'Not connected to a cube. Use `borg_assimilate cube_name="<name>"` to join one.'}]};const t=typeof o?.since=="string"?o.since:void 0,r=o?.mode==="lite"?"lite":"full",n=await L(e.sessionToken,e.apiUrl,{since:t}),s=F(e,n);s!==e&&await H(s);const i=D(),a=T(s.cubeId,s.droneId),c=q(I()),f=U()==="claude"?P(a,c):!0,_=tt(i,f)?et({inboxPath:a,monitorStateRoot:c,droneLabel:Be(n,s.droneLabel),cubeName:s.name}):"";let u="";try{const b=$(),w=Ge();if(b!=="unknown"&&w!=="unknown"&&w!==b){const[k,N,Y]=b.split(".").map(Number),[E,M,G]=w.split(".").map(Number);(E>k||E===k&&M>N||E===k&&M===N&&G>Y)&&(u=`## \u{1F504} borgmcp ${w} installed \u2014 run /mcp and reconnect (or restart Claude Code) to apply. Currently running ${b}.
|
|
3
3
|
|
|
4
|
-
`)}}catch{}return{content:[{type:"text",text:
|
|
5
|
-
`)+V(n,{mode:"full"})}]}}catch(n){const s=mt(n??{});if(!s)throw n;return{content:[{type:"text",text:s}],isError:!0}}}case"borg_version":return{content:[{type:"text",text:`borgmcp ${
|
|
4
|
+
`)}}catch{}return{content:[{type:"text",text:u+_+V(n,{mode:r})}]}}case"borg_subscribe":return{content:[{type:"text",text:`Complete your subscription at: ${await Ee()}`}]};case"borg_upgrade-subscription":{const e=await ke();try{await K(e)}catch{}return{content:[{type:"text",text:`Manage your Borg MCP subscription at: ${e}`}]}}case"borg_subscription_status":{const e=await ve();return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}case"borg_open_dashboard":{const e="https://borgmcp.ai/dashboard";return await K(e),{content:[{type:"text",text:`\u25FC Opened dashboard in browser: ${e}`}]}}case"borg_assimilate":{const e=o?.cube_name;if(!e)throw new Error("cube_name is required");const t=await g(),r=ut(t,e);if(r.kind!=="reattach")return{content:[{type:"text",text:pt(r,e)}],isError:!0};try{const n=await L(t.sessionToken,t.apiUrl,{}),s=F(t,n);return s!==t&&await H(s),{content:[{type:"text",text:[`# Re-attached to cube: ${s.name}`,"",`**Drone label:** ${s.droneLabel}`,"**Seat:** existing identity reused \u2014 no new drone minted (gh#780)","",""].join(`
|
|
5
|
+
`)+V(n,{mode:"full"})}]}}catch(n){const s=mt(n??{});if(!s)throw n;return{content:[{type:"text",text:s}],isError:!0}}}case"borg_version":return{content:[{type:"text",text:`borgmcp ${$()}`}]};case"borg_playbook":return{content:[{type:"text",text:Le()}]};case"borg_docs":{const e=typeof o?.topic=="string"?o.topic.trim():"",t=e?Ke(e):[],r=t.length>0?t:ze;return{content:[{type:"text",text:`${e&&t.length>0?`Best-matching docs section(s) for "${e}" \u2014 WebFetch the URL for the full page:`:e?`No exact match for "${e}". Full Borg MCP docs index \u2014 WebFetch the URL you need:`:"Borg MCP docs index \u2014 WebFetch the URL of the section you need:"}
|
|
6
6
|
|
|
7
|
-
${
|
|
8
|
-
`)}]}}case"borg_role":{const e=await
|
|
7
|
+
${Je(r)}`}]}}case"borg_whoami":{const e=await h(),t=await Se(e.sessionToken,e.apiUrl);return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}case"borg_cube":{const e=await h(),[{cube:t,roles:r}]=await Promise.all([se(e.sessionToken,e.apiUrl),A(e.sessionToken,e.apiUrl)]),n=[];n.push(`# Cube: ${t.name}`),n.push(""),n.push("## Cube directive"),n.push(t.cube_directive||"_(none)_"),n.push("");const s=Oe(t.message_taxonomy);if(s&&(n.push(s),n.push("")),n.push("## Roles in this cube"),!r.length)n.push("_(no roles defined)_");else{for(const i of r){const a=[i.role_class==="queen"?"Queen":null,i.is_human_seat?"human-seat":null,i.is_default?"default":null].filter(Boolean).join(", "),c=a?` (${a})`:"",d=i.short_description||"_(no description)_";n.push(`- **${i.name}**${c} \u2014 ${d}`)}n.push(""),n.push("_(Coordinator-class drones can fetch role IDs via `borg_list-roles` for use with `borg_reassign-drone`.)_")}return n.push(""),n.push(Ae()),{content:[{type:"text",text:n.join(`
|
|
8
|
+
`)}]}}case"borg_role":{const e=await h(),t=typeof o?.role=="string"?o.role.trim():"";if(t){const{role:s}=await ie(e.sessionToken,e.apiUrl,t);return ne(t,s),{content:[{type:"text",text:[`# Role: ${s.name}`,"",s.detailed_description||"_(no detailed description set)_"].join(`
|
|
9
9
|
`)}]}}const{role:r}=await A(e.sessionToken,e.apiUrl);return{content:[{type:"text",text:[`# Your role: ${r.name}`,"",r.detailed_description||"_(no detailed description set)_"].join(`
|
|
10
|
-
`)}]}}case"borg_role-rationale":{const e=await
|
|
11
|
-
`)}]}}case"borg_roster":{const e=await
|
|
10
|
+
`)}]}}case"borg_role-rationale":{const e=await h(),t=typeof o?.role=="string"?o.role:"",r=typeof o?.section=="string"?o.section:"",n=await Ie(e.sessionToken,e.apiUrl,t,r);return{content:[{type:"text",text:[`# Role rationale: ${n.role} \u2014 ${n.section}`,"",n.body||"_(empty)_"].join(`
|
|
11
|
+
`)}]}}case"borg_roster":{const e=await h(),t=typeof o?.since=="string"?o.since:void 0,{drones:r,roles:n,since:s}=await ae(e.sessionToken,e.apiUrl,t);return{content:[{type:"text",text:rt({cubeName:e.name,drones:r,roles:n,resolvedSince:s??null,humanAgo:W})}]}}case"borg_stream-status":{const e=D(),t=await g(),r=t?T(t.cubeId,t.droneId):null,n=t?q(I()):null,s=t&&U()!=="claude",i=t?s?!0:P(r,n):null;let a="";e.runLoopHealth==="silent-inert"&&(a=`## \u26A0 SSE stream loop silent-inert \u2014 run /mcp and reconnect to restart
|
|
12
12
|
|
|
13
13
|
The log-stream consumer started but never connected. This drone will not receive real-time cube events.
|
|
14
14
|
|
|
15
|
-
`);const c=Ze({status:e,inboxMonitorHealthy:i,inboxPath:r,monitorStateRoot:n,droneLabel:t?.droneLabel??null,cubeName:t?.name??null,humanAgo:W});return{content:[{type:"text",text:a+c}]}}case"borg_read-log":{const e=await
|
|
16
|
-
`)}]}}case"borg_log":{const e=o?.message;if(!e||typeof e!="string")throw new Error("message is required");const t=await
|
|
15
|
+
`);const c=Ze({status:e,inboxMonitorHealthy:i,inboxPath:r,monitorStateRoot:n,droneLabel:t?.droneLabel??null,cubeName:t?.name??null,humanAgo:W});return{content:[{type:"text",text:a+c}]}}case"borg_read-log":{const e=await h(),t=typeof o?.since=="string"?o.since:void 0,r=typeof o?.limit=="number"?o.limit:void 0,n=o?.unread_only===!0||o?.unread_only==="true",{entries:s,drones:i,roles:a,behind_by:c,has_more:d}=await ce(e.sessionToken,e.apiUrl,{since:t,limit:r,unreadOnly:n}),f=new Map;for(const b of i)f.set(b.id,b);const _=new Map;for(const b of a)_.set(b.id,b);const u=[];if(u.push(`# Activity log: ${e.name}`),u.push(""),!s.length)u.push("_(no entries)_");else for(const b of s)u.push(Me(b,f,_));return d===!0?(u.push(""),u.push("\u26A0 has_more: true \u2014 call `borg_read-log unread_only=true` again until has_more=false so you finish draining unread entries.")):typeof c=="number"&&c>0&&(u.push(""),u.push(`\u26A0 behind_by: ${c} more unread ${c===1?"entry":"entries"} addressed to you \u2014 call \`borg_read-log unread_only=true\` again until behind_by=0 so you don't skip messages.`)),{content:[{type:"text",text:u.join(`
|
|
16
|
+
`)}]}}case"borg_log":{const e=o?.message;if(!e||typeof e!="string")throw new Error("message is required");const t=await g();if(!t)throw new Error("Not assimilated to a cube. Use borg_assimilate <cube-name> first.");if(Ct(e)){const u=await Rt(t,e);if(u.suppress)return await z(t,e),{content:[{type:"text",text:`Suppressed duplicate ${u.signal?.toUpperCase()} lifecycle log for ${t.droneLabel}; recent cube log already contains this signal.`}]}}const r=Object.prototype.hasOwnProperty.call(o??{},"to"),n=r?St(o?.to):void 0,s=typeof o?.class=="string"?o.class:void 0,i=o?.visibility==="broadcast"||o?.visibility==="direct"?o.visibility:void 0,a={...s?{class:s}:{},...r?{to:n??[]}:{},...i?{visibility:i}:{}},c=await le(t.sessionToken,t.apiUrl,e,a);await z(t,e);const d=c.routing?.message?`
|
|
17
17
|
${c.routing.message}`:"",f=c.unreachableRecipients?.length?`
|
|
18
|
-
\u26A0 ${c.unreachableRecipients.length} directed recipient(s) currently unreachable (wake-path:deaf): ${c.unreachableRecipients.map(
|
|
18
|
+
\u26A0 ${c.unreachableRecipients.length} directed recipient(s) currently unreachable (wake-path:deaf): ${c.unreachableRecipients.map(u=>u.label).join(", ")}. Message delivered \u2014 they'll read it when they return.`:"";return{content:[{type:"text",text:`Logged to cube "${t.name}" as ${t.droneLabel}. (entry id: ${c.entry.id})${d}${f}`}]}}case"borg_report-friction":{const e=o?.message;if(!e||typeof e!="string")throw new Error("message is required");const t=await g();if(!t)throw new Error("Not assimilated to a cube. Use borg_assimilate <cube-name> first.");const r=o?.kind==="bug"?"bug":"friction",n=o?.metadata&&typeof o.metadata=="object"&&!Array.isArray(o.metadata)?o.metadata:void 0;return{content:[{type:"text",text:(await de(t.sessionToken,t.apiUrl,{kind:r,message:e,metadata:n})).ok?"Report submitted \u2014 thank you. The borgmcp team will see it. (Write-only: you cannot read reports back.)":"Report did not submit. Try again, or raise it in the cube log."}]}}case"borg_reports":{const e=await ue();if(e.forbidden)return{content:[{type:"text",text:"Reports triage is builder/dogfooder-tier only. Your account is not on the dogfooder (builder) tier, so the friction-reports store is not readable. (Server-enforced gate.)"}]};if(!e.reports.length)return{content:[{type:"text",text:"No reports yet. Submissions via borg_report-friction will appear here, newest first."}]};const t=e.reports.map(r=>{const n=r.metadata&&Object.keys(r.metadata).length?" \xB7 "+Object.entries(r.metadata).map(([i,a])=>`${i}=${a}`).join(", "):"",s=r.redacted?" \xB7 [secrets-scrubbed]":"";return`**[${r.kind}]** ${r.created_at} \xB7 ${r.reporter_email}${n}${s}
|
|
19
19
|
${r.message}`});return{content:[{type:"text",text:`Reports (${e.reports.length}, newest first):
|
|
20
20
|
|
|
21
21
|
${t.join(`
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
`)}`}]}}case"borg_ack":{const e=o?.entry_id;if(!e||typeof e!="string")throw new Error("entry_id is required");const t=o?.kind==="claim"?"claim":"ack",r=await
|
|
25
|
+
`)}`}]}}case"borg_ack":{const e=o?.entry_id;if(!e||typeof e!="string")throw new Error("entry_id is required");const t=o?.kind==="claim"?"claim":"ack",r=await h();return await pe(r.sessionToken,r.apiUrl,e,t),{content:[{type:"text",text:t==="claim"?`Claimed entry ${e} in cube "${r.name}" (advisory \u2014 merge stays keyed on REVIEW-APPROVED).`:`Acked entry ${e} in cube "${r.name}".`}]}}case"borg_decide":{const e=o?.topic,t=o?.decision;if(!e||typeof e!="string")throw new Error("topic is required");if(!t||typeof t!="string")throw new Error("decision is required");const r=typeof o?.rationale=="string"?o.rationale:void 0,n=await h(),{decision:s}=await me(n.sessionToken,n.apiUrl,{topic:e,decision:t,...r!==void 0?{rationale:r}:{}}),i=s?.supersedes?" (superseded the prior decision on this topic)":"";return{content:[{type:"text",text:`Recorded ratified decision on "${e}" in cube "${n.name}"${i}. Cite it via borg_decisions; it surfaces in borg_regen.`}]}}case"borg_decisions":{const e=typeof o?.topic=="string"?o.topic:void 0,t=await h(),{decisions:r}=await be(t.sessionToken,t.apiUrl,e);return{content:[{type:"text",text:r.length===0?e?`No active ratified decision on "${e}" in cube "${t.name}".`:`No active ratified decisions in cube "${t.name}".`:r.map(s=>`**${s.topic}:** ${s.decision}${s.rationale?` \u2014 ${s.rationale}`:""}`).join(`
|
|
26
26
|
`)}]}}case"borg_list-cubes":{const{cubes:e}=await fe();if(!e.length)return{content:[{type:"text",text:"No cubes yet. Use borg_create-cube to make your first one."}]};const t=e.map(r=>`- **${r.name}** (id: ${r.id})
|
|
27
27
|
${(r.cube_directive||"_(no directive set)_").split(`
|
|
28
28
|
`)[0].slice(0,120)}`);return{content:[{type:"text",text:`Your cubes (${e.length}):
|
|
29
29
|
|
|
30
30
|
${t.join(`
|
|
31
31
|
|
|
32
|
-
`)}`}]}}case"borg_create-cube":{const e=o?.name,t=o?.cube_directive,r=o?.template;if(!e)throw new Error("name is required");if(t===void 0)throw new Error("cube_directive is required (pass empty string if none)");let n=null;if(r&&(n=
|
|
32
|
+
`)}`}]}}case"borg_create-cube":{const e=o?.name,t=o?.cube_directive,r=o?.template;if(!e)throw new Error("name is required");if(t===void 0)throw new Error("cube_directive is required (pass empty string if none)");let n=null;if(r&&(n=R(r),!n))throw new Error(`Unknown template "${r}". Available: ${S().join(", ")}`);const s=De(t,n),i=Ue(void 0,n),a=await ge(e,s,{message_taxonomy:i});if(n){const d=await J(a.id,n),f=s!==t?" Template cube directive applied (operator passed empty).":"";return{content:[{type:"text",text:`Created cube **${a.name}** (id: ${a.id}) with template **${r}** applied \u2014 ${d.created} role(s) created, ${d.updated} updated.${f} Use borg_assimilate ${a.name} to join as a drone.`}]}}return{content:[{type:"text",text:`Created cube **${a.name}** (id: ${a.id}). A default "Drone" role was seeded \u2014 rename or replace it via borg_update-role / borg_create-role / borg_delete-role. Use borg_assimilate ${a.name} to join as a drone.`}]}}case"borg_update-cube":{const e=o?.cube_id;if(!e)throw new Error("cube_id is required");const t={};if(typeof o?.name=="string"&&(t.name=o.name),typeof o?.cube_directive=="string"&&(t.cube_directive=o.cube_directive),Array.isArray(o?.message_taxonomy)&&(t.message_taxonomy=o.message_taxonomy),Object.keys(t).length===0)throw new Error("Pass at least one of: name, cube_directive, message_taxonomy.");const{cube:r}=await O(e,t);return{content:[{type:"text",text:`Updated cube **${r.name}** (id: ${r.id}).`}]}}case"borg_patch-taxonomy-class":{const e=o?.cube_id;if(!e)throw new Error("cube_id is required");const t=o?.action;if(t!=="add"&&t!=="replace"&&t!=="remove")throw new Error("action must be one of: add, replace, remove.");let r,n;if(t==="remove"){const i=o?.class;if(!i)throw new Error("class is required for remove.");({cube:r}=await B(e,{action:t,class:i})),n=i}else{const i=o?.class_def;if(i==null||typeof i!="object"||Array.isArray(i))throw new Error("class_def (object) is required for add/replace.");({cube:r}=await B(e,{action:t,class_def:i})),n=String(i.class??"")}return{content:[{type:"text",text:`${t==="add"?"Added":t==="replace"?"Replaced":"Removed"} taxonomy class **${n}** in cube **${r.name}** (id: ${r.id}).`}]}}case"borg_delete-cube":{const e=o?.cube_id;if(!e)throw new Error("cube_id is required");return await he(e),{content:[{type:"text",text:`Deleted cube ${e} (and all its roles, drones, log entries).`}]}}case"borg_create-role":{const e=o?.cube_id,t=o?.name,r=o?.short_description,n=o?.detailed_description;if(!e)throw new Error("cube_id is required");if(!t)throw new Error("name is required");if(r===void 0)throw new Error("short_description is required (pass empty string if none)");if(n===void 0)throw new Error("detailed_description is required (pass empty string if none)");const s=o?.is_default===!0,i=o?.is_human_seat===!0,a=o?.can_broadcast===!0,c=o?.receives_all_direct===!0,{role:d}=await _e(e,{name:t,short_description:r,detailed_description:n,is_default:s,is_human_seat:i,can_broadcast:a,receives_all_direct:c,...typeof o?.default_model=="string"?{default_model:o.default_model}:{}}),f=[d.role_class==="queen"?"Queen":null,d.is_human_seat?"human-seat":null,d.is_default?"default":null].filter(Boolean).join(", "),_=f?` (${f})`:"";return{content:[{type:"text",text:`Created role **${d.name}**${_} (id: ${d.id}) in cube ${e}.`}]}}case"borg_update-role":{const e=o?.role_id;if(!e)throw new Error("role_id is required");const t={};if(typeof o?.name=="string"&&(t.name=o.name),typeof o?.short_description=="string"&&(t.short_description=o.short_description),typeof o?.detailed_description=="string"&&(t.detailed_description=o.detailed_description),typeof o?.is_default=="boolean"&&(t.is_default=o.is_default),typeof o?.is_human_seat=="boolean"&&(t.is_human_seat=o.is_human_seat),typeof o?.can_broadcast=="boolean"&&(t.can_broadcast=o.can_broadcast),typeof o?.receives_all_direct=="boolean"&&(t.receives_all_direct=o.receives_all_direct),typeof o?.default_model=="string"&&(t.default_model=o.default_model),Object.keys(t).length===0)throw new Error("Pass at least one of: name, short_description, detailed_description, is_default, is_human_seat, can_broadcast, receives_all_direct, default_model.");const{role:r}=await ye(e,t),n=[r.role_class==="queen"?"Queen":null,r.is_human_seat?"human-seat":null,r.is_default?"default":null].filter(Boolean).join(", "),s=n?` (${n})`:"";return{content:[{type:"text",text:`Updated role **${r.name}**${s} (id: ${r.id}).`}]}}case"borg_patch-role-section":{const e=o?.role_id;if(!e)throw new Error("role_id is required");const t=o?.action;if(t!=="replace"&&t!=="insert"&&t!=="delete")throw new Error("action must be one of: replace, insert, delete.");const r=o?.heading;if(!r)throw new Error("heading is required");let n;if(t==="delete")({role:n}=await C(e,{action:t,heading:r}));else{const i=o?.body;if(typeof i!="string")throw new Error("body is required for replace/insert (pass empty string for an empty section).");if(t==="insert"){const a=typeof o?.after=="string"?o.after:null;({role:n}=await C(e,{action:t,heading:r,body:i,after:a}))}else({role:n}=await C(e,{action:t,heading:r,body:i}))}return{content:[{type:"text",text:`${t==="replace"?"Replaced":t==="insert"?"Inserted":"Deleted"} section **${r}** in role **${n.name}** (id: ${n.id}).`}]}}case"borg_delete-role":{const e=o?.role_id;if(!e)throw new Error("role_id is required");return await we(e),{content:[{type:"text",text:`Deleted role ${e}.`}]}}case"borg_reassign-drone":{const e=o?.drone_id,t=o?.role_id;if(!e)throw new Error("drone_id is required");if(!t)throw new Error("role_id is required");const{drone:r}=await xe(e,t);return{content:[{type:"text",text:`Reassigned drone ${r.label} (${r.id}) to role ${r.role_id}.`}]}}case"borg_evict-drone":{const e=o?.drone_id?.trim(),t=o?.label?.trim(),r=o?.cube_id?.trim();let n,s;if(e){if(!st(e))throw new Error(`drone_id "${e}" is not a UUID \u2014 if that's a drone label, pass it as label + cube_id instead.`);n=e,s=e}else if(t){if(!r)throw new Error("cube_id is required when evicting by label");const{drones:i}=await x(r),a=nt(i,t);if(!a)throw new Error(`No active drone labelled "${t}" in cube ${r} (it may already be evicted; check borg_list-drones).`);n=a.id,s=a.label}else throw new Error("Provide drone_id, or label + cube_id, to identify the drone to evict");return await $e(n),{content:[{type:"text",text:`Evicted drone ${s} (${n}). Soft-deleted: removed from the roster and freed its seat; log history preserved with anonymized attribution.`}]}}case"borg_list-drones":{const e=o?.cube_id;if(!e)throw new Error("cube_id is required");const{drones:t,roles:r}=await x(e);if(!t.length)return{content:[{type:"text",text:"No drones in this cube yet."}]};const n=new Map(r.map(i=>[i.id,i])),s=t.map(i=>{const a=n.get(i.role_id),c=ot(a?.name??"?",i.agent_kind),d=i.wake_path_alert_class&&i.wake_path_alert_class!=="independent"?` \u2014 wake-path-class: ${i.wake_path_alert_class}`:"";return`- **${i.label}** (id: ${i.id}) \u2014 role: ${c} (${i.role_id}) \u2014 last seen ${i.last_seen}${d}`});return{content:[{type:"text",text:`Drones in cube ${e} (${t.length}):
|
|
33
33
|
|
|
34
34
|
${s.join(`
|
|
35
|
-
`)}`}]}}case"borg_list-roles":{const e=o?.cube_id;if(!e)throw new Error("cube_id is required");const{roles:t}=await
|
|
35
|
+
`)}`}]}}case"borg_list-roles":{const e=o?.cube_id;if(!e)throw new Error("cube_id is required");const{roles:t}=await x(e);return{content:[{type:"text",text:Qe(t,e)}]}}case"borg_list-templates":return{content:[{type:"text",text:`Available templates:
|
|
36
36
|
|
|
37
|
-
${
|
|
38
|
-
`)}`}]};case"borg_sync-roles":{const e=o?.cube_id,t=o?.template_name||"software-dev",r=o?.apply===!0,n=o?.decisions&&typeof o.decisions=="object"?o.decisions:void 0;if(!e)throw new Error("cube_id is required");const s=await Ce(e,t,r,n);return{content:[{type:"text",text:gt(s,t)}]}}case"borg_apply-template":{const e=o?.cube_id,t=o?.template_name;if(!e)throw new Error("cube_id is required");if(!t)throw new Error("template_name is required");const r=
|
|
37
|
+
${S().map(r=>{const n=R(r);return`- **${r}**: ${n.description}`}).join(`
|
|
38
|
+
`)}`}]};case"borg_sync-roles":{const e=o?.cube_id,t=o?.template_name||"software-dev",r=o?.apply===!0,n=o?.decisions&&typeof o.decisions=="object"?o.decisions:void 0;if(!e)throw new Error("cube_id is required");const s=await Ce(e,t,r,n);return{content:[{type:"text",text:gt(s,t)}]}}case"borg_apply-template":{const e=o?.cube_id,t=o?.template_name;if(!e)throw new Error("cube_id is required");if(!t)throw new Error("template_name is required");const r=R(t);if(!r)throw new Error(`Unknown template "${t}". Available: ${S().join(", ")}`);const n=await J(e,r);let s="";const i=await x(e),a=Pe(i.cube_directive,r);return a!==null&&(await O(e,{cube_directive:a}),s=" Template cube directive applied (cube directive was empty)."),{content:[{type:"text",text:`Applied template **${t}** to cube ${e} \u2014 ${n.created} role(s) created, ${n.updated} updated.${s}`}]}}default:throw new Error(`Unknown tool: ${p}`)}}catch(e){if(e instanceof at)return{content:[{type:"text",text:lt(e.message)}],isError:!0};if(e instanceof ct)return{content:[{type:"text",text:dt(e.message)}],isError:!0};const t=it(e??{});return t?{content:[{type:"text",text:t}],isError:!0}:{content:[{type:"text",text:`Error: ${e.message}`}],isError:!0}}}),y.setRequestHandler(oe,async()=>({prompts:[{name:"borg_subscribe",description:"Set up Borg MCP Cube tier subscription ($1/month per cube; each cube adds 8 pooled agent sessions + 1000 req/hr). Free tier is permanent (1 cube + 3 agent sessions + 100 req/hr); no trial."},{name:"dashboard",description:"Open Borg MCP dashboard to manage cubes"}]})),y.setRequestHandler(re,async l=>{const{name:p}=l.params;switch(p){case"borg_subscribe":return{description:"Set up Borg MCP Cube tier subscription ($1/month per cube; each cube adds 8 pooled agent sessions + 1000 req/hr). Free tier is permanent (1 cube + 3 agent sessions + 100 req/hr); no trial.",messages:[{role:"user",content:{type:"text",text:"Please help me set up a Borg MCP subscription using the subscribe tool."}}]};case"dashboard":return{description:"Open Borg MCP dashboard to manage cubes",messages:[{role:"user",content:{type:"text",text:"Please open the Borg MCP dashboard using the borg_open_dashboard tool."}}]};default:throw new Error(`Unknown prompt: ${p}`)}});const Q=new Z;await y.connect(Q),await ht(),console.error(`${v()}\u25FC Borg MCP Client started`),console.error(`${v()}\u25FC Use borg_assimilate <cube-name> to join a cube as a drone`),console.error(`${v()}\u25FC Manage your cubes at https://borgmcp.ai/dashboard`)}qt().catch(m=>{console.error(`${v()}Fatal error:`,m),process.exit(1)});
|
package/dist/roster-render.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface RosterDrone {
|
|
|
24
24
|
/**
|
|
25
25
|
* gh#370 — which AI agent is running this drone. Null for drones that
|
|
26
26
|
* joined before the column existed or via a launcher path that didn't
|
|
27
|
-
* forward the kind.
|
|
27
|
+
* forward the kind. This is the agent CLI, not a model descriptor.
|
|
28
28
|
*/
|
|
29
29
|
agent_kind?: 'claude' | 'codex' | 'opencode' | null;
|
|
30
30
|
regen_count?: number | null;
|
|
@@ -32,7 +32,10 @@ export interface RosterDrone {
|
|
|
32
32
|
wake_path_alert_class?: 'dead' | 'post-blocked' | 'presumed-dead' | 'systemic-post-block' | 'wake-path-deaf' | 'independent' | null;
|
|
33
33
|
/**
|
|
34
34
|
* Model descriptor (e.g., "claude:claude-opus-4-8" or "ollama:qwen3-coder-next:q4_K_M").
|
|
35
|
-
*
|
|
35
|
+
* This is the configured launch setting captured at assimilation, not a live
|
|
36
|
+
* runtime model observation. It may remain after a later CLI relaunch.
|
|
37
|
+
* Null is not enough information to distinguish an inherited default from
|
|
38
|
+
* a legacy/missing report, so renderers must not infer an agent CLI from it.
|
|
36
39
|
*/
|
|
37
40
|
model?: string | null;
|
|
38
41
|
}
|
package/dist/roster-render.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{formatDroneAddressToken as
|
|
2
|
-
`);for(const e of
|
|
3
|
-
`)}export{g as formatRoleAgentLabel,
|
|
1
|
+
import{formatDroneAddressToken as w}from"./drone-address.js";const m={degraded:"unverified",deaf:"unresponsive"};function g(a,o){return`Role: ${a} \xB7 Agent CLI: ${o==="claude"?"Claude Code":o==="codex"?"Codex":o==="opencode"?"OpenCode":"unknown"}`}function v(a){const{cubeName:o,drones:s,roles:k,resolvedSince:t,humanAgo:r}=a,l=new Map;for(const e of k)l.set(e.id,e);const n=[];if(n.push(`# Drones in cube: ${o}`),n.push(""),t&&(n.push(`_Liveness probe since ${t} (${r(t)}). \`awake\` = drone posted to the cube log after that point._`),n.push("")),!s.length)return n.push("_(no drones connected)_"),n.join(`
|
|
2
|
+
`);for(const e of s){const h=l.get(e.role_id)?.name??"unknown",c=g(h,e.agent_kind),d=e.id?` ${w(e.id)}`:"",u=r(e.last_seen),i=e.model?` \xB7 \`Configured model: ${e.model}\``:" \xB7 `Configured model: not reported`",p=e.wake_path&&e.wake_path!=="live"?` \xB7 \`wake-path:${m[e.wake_path]??e.wake_path}\``:"",$=e.wake_path_alert_class&&e.wake_path_alert_class!=="independent"?` \xB7 \`wake-path-class:${e.wake_path_alert_class}\``:"",_=typeof e.regen_count=="number"?` \xB7 \`regen-count:${e.regen_count}\``:"";if(t){const f=e.seen_since===!0?"`awake`":"`stale`";n.push(`- **${e.label}**${d} (${c}) \u2014 last seen ${u} \xB7 ${f}${_}${p}${$}${i}`)}else n.push(`- **${e.label}**${d} (${c}) \u2014 last seen ${u}${_}${p}${$}${i}`)}return n.join(`
|
|
3
|
+
`)}export{g as formatRoleAgentLabel,v as renderRoster};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "borgmcp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Coordinate AI coding agents in shared cubes. Works with Claude Code and Codex. Create projects, assign roles, and share a live activity log.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|