borgmcp 1.0.48 → 1.0.49
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/claude-launch-args.d.ts +32 -0
- package/dist/claude-launch-args.js +1 -0
- package/dist/claude.js +9 -9
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gh#702 — borg-launched Claude Code drones auto-allow the borg MCP
|
|
3
|
+
* coordination tools so a drone never prompts on borg_regen / borg_log /
|
|
4
|
+
* borg_ack / etc. mid-loop.
|
|
5
|
+
*
|
|
6
|
+
* SCOPED, by deliberate design (Option A, per-launch — avoids the gh#844
|
|
7
|
+
* settings-mutation/consent class):
|
|
8
|
+
* - ONLY `mcp__borg__*` is auto-allowed. Bash, file edits (Read/Write/Edit),
|
|
9
|
+
* web (WebFetch/WebSearch), and everything else STILL prompt. This is an
|
|
10
|
+
* allowlist ADD, NOT `--dangerously-skip-permissions` and NOT a blanket
|
|
11
|
+
* allow.
|
|
12
|
+
* - Applied ONLY by the borg launcher (a per-invocation CLI flag) — there is
|
|
13
|
+
* NO persistent user-settings write, so no consent gate is involved.
|
|
14
|
+
* - claude only. Codex parity is a separate follow-up (different permission
|
|
15
|
+
* model) — intentionally not handled here.
|
|
16
|
+
*/
|
|
17
|
+
/** The allowlist pattern matching every tool from the `borg` MCP server. */
|
|
18
|
+
export declare const BORG_MCP_ALLOWED_TOOLS = "mcp__borg__*";
|
|
19
|
+
/**
|
|
20
|
+
* Build the argv for a borg-launched `claude` process: the user's passthrough
|
|
21
|
+
* args.
|
|
22
|
+
*
|
|
23
|
+
* ORDER IS LOAD-BEARING (CR blocker 0e5c697e): `--allowedTools` is a VARIADIC
|
|
24
|
+
* option (`<tools...>`, a space-separated list), so it greedily consumes every
|
|
25
|
+
* following non-flag argv element. If the kickoff prompt came AFTER it, claude
|
|
26
|
+
* would absorb the prompt as a 2nd "allowed tool" and launch with NO kickoff.
|
|
27
|
+
* So the kickoff positional goes FIRST and the variadic flag goes LAST, where
|
|
28
|
+
* it can only consume its own single value:
|
|
29
|
+
* [...passthrough, kickoff, '--allowedTools', 'mcp__borg__*']
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildClaudeLaunchArgs(passthroughArgs: string[], kickoff: string): string[];
|
|
32
|
+
//# sourceMappingURL=claude-launch-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r="mcp__borg__*";function e(o,_){return[...o,_,"--allowedTools",r]}export{r as BORG_MCP_ALLOWED_TOOLS,e as buildClaudeLaunchArgs};
|
package/dist/claude.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawn as E}from"child_process";import{randomUUID as M}from"node:crypto";import{basename as O}from"node:path";import{createInterface as H}from"node:readline/promises";import t from"chalk";import{findProjectRoot as y,getActiveCube as F,getLaunchModel as N,inboxPathForDrone as B,setCodexWakeTarget as _,pruneDeadCodexWakeTargets as W}from"./cubes.js";import{applyOllamaLaunchEnv as G,checkModelReachable as Y}from"./model-presets.js";import{handleVersionFlag as U,getPackageVersion as h}from"./version.js";import{isHelpFlag as T,setupHelpText as V,topLevelHelpText as K,assimilateHelpText as j}from"./cli-help.js";import{runSpawn as q}from"./spawn.js";import{parseSyncArgs as
|
|
3
|
-
`)})();if((process.argv[2]==="--help"||process.argv[2]==="-h")&&(process.stdout.write(K(h())),process.exit(0)),process.argv[2]==="setup"){T(process.argv[3])&&(process.stdout.write(V(h())),process.exit(0)),await import("./setup.js");return}if(process.argv[2]==="assimilate"){process.argv.slice(3).some(T)&&(process.stdout.write(j(h())),process.exit(0));const e=
|
|
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
|
|
7
|
-
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=
|
|
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
|
|
2
|
+
import{spawn as E}from"child_process";import{randomUUID as M}from"node:crypto";import{basename as O}from"node:path";import{createInterface as H}from"node:readline/promises";import t from"chalk";import{findProjectRoot as y,getActiveCube as F,getLaunchModel as N,inboxPathForDrone as B,setCodexWakeTarget as _,pruneDeadCodexWakeTargets as W}from"./cubes.js";import{applyOllamaLaunchEnv as G,checkModelReachable as Y}from"./model-presets.js";import{handleVersionFlag as U,getPackageVersion as h}from"./version.js";import{isHelpFlag as T,setupHelpText as V,topLevelHelpText as K,assimilateHelpText as j}from"./cli-help.js";import{runSpawn as q}from"./spawn.js";import{buildClaudeLaunchArgs as X}from"./claude-launch-args.js";import{parseSyncArgs as z,runSync as J}from"./sync.js";import{parseCleanupArgs as Q,runCleanup as Z}from"./cleanup-cmd.js";import{parseAssimilateArgs as ee}from"./parse-assimilate-args.js";import{runAssimilate as re}from"./assimilate-cmd.js";import{buildDefaultAssimilateDeps as oe}from"./assimilate-deps.js";import{parseLaunchAllArgs as A}from"./parse-launch-all-args.js";import{unknownSubcommand as se}from"./unknown-subcommand.js";import{runLaunchAll as I}from"./launch-all-cmd.js";import{buildDefaultLaunchAllDeps as C}from"./launch-all-deps.js";import{discoverDroneCandidates as te}from"./launch-all-discovery.js";import{runBareLaunchMenu as ae,shouldShowLaunchMenu as ie}from"./bare-launch-menu.js";import{setTerminalTitle as ce}from"./terminal-title.js";import{initConsolePrefix as ne,consolePrefix as o}from"./console-prefix.js";import{initDebugFromArgv as le}from"./debug.js";import{fetchLatestBorgmcpVersion as de,compareVersionsForStaleness as pe}from"./stale-version-check.js";import{defaultCliChoiceDeps as ue,detectCliAvailability as k,installedCliNames as P,parseCliFlag as me,resolveCliChoice as fe}from"./cli-platform.js";import{getRefreshToken as ge,getIdToken as he}from"./config.js";import{composeGetStarted as we,shouldShowGetStarted as xe}from"./get-started.js";import{prepareCodexRemoteLaunch as Ce,withCodexCwdArg as ke,defaultCodexRemoteDeps as ve,checkCodexBridgeHealthy as be}from"./codex-remote.js";import{findLoadedCodexThread as $e}from"./codex-app-server.js";import{buildAgentKickoffPrompt as Se,buildKickoffWakePathClause as ye,recordCodexWakeTarget as Te,socketPathFromRemoteArgs as R}from"./codex-launch.js";import{codexBorgSessionConfigArgs as Ae}from"./launch-gate.js";import{addCodexMcpServer as Ie,addCodexSessionStartHook as Pe,addCodexUserPromptSubmitHook as Re,addMcpServer as Le,addProjectSessionStartHook as De,addUserPromptSubmitHook as Ee,isCodexMcpServerConfigured as Me,isMcpServerConfigured as Oe,removeSessionStartHook as He}from"./config-utils.js";async function Fe(){le(process.argv),U(),await ne();const n=(async()=>{if(!process.stderr.isTTY)return;const e=h(),r=await de();if(!r)return;const i=pe(e,r);i.stale&&i.message&&process.stderr.write(`${o()}${i.message}
|
|
3
|
+
`)})();if((process.argv[2]==="--help"||process.argv[2]==="-h")&&(process.stdout.write(K(h())),process.exit(0)),process.argv[2]==="setup"){T(process.argv[3])&&(process.stdout.write(V(h())),process.exit(0)),await import("./setup.js");return}if(process.argv[2]==="assimilate"){process.argv.slice(3).some(T)&&(process.stdout.write(j(h())),process.exit(0));const e=ee(process.argv.slice(3));e.ok||(process.stderr.write(t.red(`${o()}\u25FC borg assimilate: ${e.error}
|
|
4
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=oe(),i=await re({role:e.role,flags:e.flags},r);process.exit(i)}if(process.argv[2]==="spawn"){const e=await q();process.exit(e)}if(process.argv[2]==="sync"){const e=z(process.argv.slice(3));e.ok||(process.stderr.write(t.red(`${o()}\u25FC borg sync: ${e.error}
|
|
5
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=await J({},e.options);process.exit(r)}if(process.argv[2]==="cleanup"){const e=Q(process.argv.slice(3));e.ok||(process.stderr.write(t.red(`${o()}\u25FC borg cleanup: ${e.error}
|
|
6
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=await Z({},e.options);process.exit(r)}if(process.argv[2]==="launch-all"){const e=A(process.argv.slice(3));e.ok||(process.stderr.write(t.red(`${o()}\u25FC borg launch-all: ${e.error}
|
|
7
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const r=C(),i=await I(e.args,r);process.exit(i)}const c=se(process.argv[2]);if(c!==null&&(process.stderr.write(t.red(`${o()}\u25FC unknown command: ${c}
|
|
8
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1)),xe(await ge()!==null,await he()!==null)){const e=P(k()).length>0;process.stdout.write(we(e)),process.exit(0)}const f=me(process.argv.slice(2));f.error&&(process.stderr.write(t.red(`${o()}\u25FC ${f.error}
|
|
9
|
+
`)),process.stderr.write("Run `borg --help` for usage.\n"),process.exit(1));const v=async e=>{const r=H({input:process.stdin,output:process.stdout});try{return await r.question(e)}finally{r.close()}};let s=await fe(f.cli,ue(v,()=>process.stdin.isTTY===!0));Ne();const a=await F();if(ie({extraArgs:process.argv.slice(2),stdinIsTTY:process.stdin.isTTY===!0,stdoutIsTTY:process.stdout.isTTY===!0})){const e=P(k()).find(m=>m!==s)??null;let r=!1;a&&(r=(await te({targetCubeId:a.cubeId},C())).length>0);const i=await ae({defaultCli:s,otherInstalledCli:e,hasLaunchAllTargets:r},v);if(i.kind==="launch-all"){const m=A([]),D=m.ok?await I(m.args,C()):1;process.exit(D)}s=i.cli}const l=f.rest;ce(a?{label:a.droneLabel,cubeName:a.name}:null,O(process.cwd()));const L=ye(s==="codex"?"codex":"claude",a&&s==="claude"?B(a.cubeId,a.droneId):null);await Promise.race([n,new Promise(e=>setTimeout(e,2e3))]);const b=s==="codex"?`borg-wake-${M()}`:null;let g,$=[],d={...process.env,BORG_SESSION:"1"},p=null,u=null;if(s==="codex"&&!l.includes("--remote")){console.error(`${o()}${t.gray("\u25FC Starting Codex remote-wake app-server\u2026")}`);const e=await Ce(ve());e.warning?(console.error(`${o()}${t.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.",$=e.args,d={...process.env,...e.env,BORG_SESSION:"1"},p=R(e.args),u=e.server?.cleanup??null}else s==="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=R(l),p&&(d={...process.env,BORG_CODEX_REMOTE_WAKE:"1",BORG_SESSION:"1"}));if(a){const e=await N(a.cubeId,y(),a.droneId),r=G(d,e,process.env);if(d=r.env,r.probe){const i=await Y(r.probe.descriptor,fetch,r.probe.baseUrl);i.ok||console.error(`${o()}${t.yellow(`warning: ${i.message}`)}`)}}const w=Se({cli:s,codexWakeNonce:b,monitorClause:L,codexWakePathClause:g});let x;s==="codex"?x=[...Ae(),...$,...ke([...l,w],process.cwd())]:x=X(l,w),console.error(`${o()}${t.blue(`\u25FC Launching ${s==="claude"?"Claude Code":"Codex"}\u2026`)}`);const S=E(s,x,{stdio:"inherit",shell:!1,env:d});s==="codex"&&a&&p&&(Te({deps:{setCodexWakeTarget:_,findLoadedCodexThread:$e},cubeId:a.cubeId,droneId:a.droneId,socketPath:p,passthroughArgs:l,previewNeedle:b??w.slice(0,120),cwd:process.cwd(),launchedAtSeconds:Math.floor(Date.now()/1e3)}),W(e=>be(e))),S.on("error",e=>{if(u)try{u()}catch{}e.code==="ENOENT"?(console.error(`${o()}${t.red(`
|
|
10
10
|
\u25FC Failed to launch ${s}`)}`),console.error(`${o()}${t.gray(`Make sure ${s} is installed.
|
|
11
11
|
`)}`)):console.error(`${o()}${t.red(`
|
|
12
12
|
\u25FC Failed to launch ${s}: ${e.message}
|
|
13
|
-
`)}`),process.exit(1)}),S.on("exit",e=>{if(u)try{u()}catch{}process.exit(e??0)})}function
|
|
13
|
+
`)}`),process.exit(1)}),S.on("exit",e=>{if(u)try{u()}catch{}process.exit(e??0)})}function Ne(){const n=k();if(n.claude)try{Oe()||Le(),De(y(process.cwd())),He(),Ee()}catch(c){console.error(`${o()}${t.yellow(`warning: Claude Code integration check failed: ${c?.message??c}`)}`)}if(n.codex)try{Me()||Ie(),Pe(),Re()}catch(c){console.error(`${o()}${t.yellow(`warning: Codex integration check failed: ${c?.message??c}`)}`)}}Fe().catch(n=>{console.error(`${o()}${t.red(`
|
|
14
14
|
\u25FC Error: ${n.message}
|
|
15
15
|
`)}`),process.exit(1)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "borgmcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
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",
|