borgmcp 1.1.14 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +15 -0
- package/LICENSE +201 -33
- package/NOTICE +2 -0
- package/README.md +86 -37
- package/SECURITY.md +7 -0
- package/dist/agent-runtime.d.ts.map +1 -0
- package/dist/agent-runtime.js +63 -1
- package/dist/agent-runtime.js.map +1 -0
- package/dist/assimilate-cmd.d.ts +96 -17
- package/dist/assimilate-cmd.d.ts.map +1 -0
- package/dist/assimilate-cmd.js +1396 -48
- package/dist/assimilate-cmd.js.map +1 -0
- package/dist/assimilate-deps.d.ts.map +1 -0
- package/dist/assimilate-deps.js +384 -3
- package/dist/assimilate-deps.js.map +1 -0
- package/dist/assimilate-guard.d.ts +5 -7
- package/dist/assimilate-guard.d.ts.map +1 -0
- package/dist/assimilate-guard.js +60 -2
- package/dist/assimilate-guard.js.map +1 -0
- package/dist/assimilate-welcome.d.ts +1 -1
- package/dist/assimilate-welcome.d.ts.map +1 -0
- package/dist/assimilate-welcome.js +32 -2
- package/dist/assimilate-welcome.js.map +1 -0
- package/dist/auth-env.d.ts +7 -50
- package/dist/auth-env.d.ts.map +1 -0
- package/dist/auth-env.js +22 -1
- package/dist/auth-env.js.map +1 -0
- package/dist/backends/launch-all-pastelist.d.ts.map +1 -0
- package/dist/backends/launch-all-pastelist.js +11 -4
- package/dist/backends/launch-all-pastelist.js.map +1 -0
- package/dist/backends/launch-all-tmux.d.ts.map +1 -0
- package/dist/backends/launch-all-tmux.js +49 -1
- package/dist/backends/launch-all-tmux.js.map +1 -0
- package/dist/backends/launch-all-windows.d.ts.map +1 -0
- package/dist/backends/launch-all-windows.js +86 -12
- package/dist/backends/launch-all-windows.js.map +1 -0
- package/dist/bare-launch-menu.d.ts.map +1 -0
- package/dist/bare-launch-menu.js +83 -6
- package/dist/bare-launch-menu.js.map +1 -0
- package/dist/claude-launch-args.d.ts.map +1 -0
- package/dist/claude-launch-args.js +34 -1
- package/dist/claude-launch-args.js.map +1 -0
- package/dist/claude.d.ts.map +1 -0
- package/dist/claude.js +486 -14
- package/dist/claude.js.map +1 -0
- package/dist/cleanup-cmd.d.ts +5 -5
- package/dist/cleanup-cmd.d.ts.map +1 -0
- package/dist/cleanup-cmd.js +453 -14
- package/dist/cleanup-cmd.js.map +1 -0
- package/dist/clear-rewake-core.d.ts.map +1 -0
- package/dist/clear-rewake-core.js +23 -2
- package/dist/clear-rewake-core.js.map +1 -0
- package/dist/clear-rewake.d.ts.map +1 -0
- package/dist/clear-rewake.js +19 -1
- package/dist/clear-rewake.js.map +1 -0
- package/dist/cli-help.d.ts +5 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +104 -56
- package/dist/cli-help.js.map +1 -0
- package/dist/cli-platform.d.ts.map +1 -0
- package/dist/cli-platform.js +106 -4
- package/dist/cli-platform.js.map +1 -0
- package/dist/cli-tool-approval.d.ts +84 -0
- package/dist/cli-tool-approval.d.ts.map +1 -0
- package/dist/cli-tool-approval.js +583 -0
- package/dist/cli-tool-approval.js.map +1 -0
- package/dist/codex-app-server.d.ts.map +1 -0
- package/dist/codex-app-server.js +228 -4
- package/dist/codex-app-server.js.map +1 -0
- package/dist/codex-app-wake.d.ts.map +1 -0
- package/dist/codex-app-wake.js +432 -2
- package/dist/codex-app-wake.js.map +1 -0
- package/dist/codex-launch.d.ts.map +1 -0
- package/dist/codex-launch.js +102 -2
- package/dist/codex-launch.js.map +1 -0
- package/dist/codex-remote.d.ts +6 -1
- package/dist/codex-remote.d.ts.map +1 -0
- package/dist/codex-remote.js +394 -1
- package/dist/codex-remote.js.map +1 -0
- package/dist/codex-wake-resolve.d.ts.map +1 -0
- package/dist/codex-wake-resolve.js +127 -1
- package/dist/codex-wake-resolve.js.map +1 -0
- package/dist/config-utils.d.ts +2 -2
- package/dist/config-utils.d.ts.map +1 -0
- package/dist/config-utils.js +766 -3
- package/dist/config-utils.js.map +1 -0
- package/dist/config.d.ts +98 -61
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +426 -1
- package/dist/config.js.map +1 -0
- package/dist/console-prefix.d.ts.map +1 -0
- package/dist/console-prefix.js +96 -1
- package/dist/console-prefix.js.map +1 -0
- package/dist/cube-name.d.ts.map +1 -0
- package/dist/cube-name.js +67 -1
- package/dist/cube-name.js.map +1 -0
- package/dist/cubes.d.ts +126 -18
- package/dist/cubes.d.ts.map +1 -0
- package/dist/cubes.js +412 -4
- package/dist/cubes.js.map +1 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +71 -1
- package/dist/debug.js.map +1 -0
- package/dist/direct-log.d.ts.map +1 -0
- package/dist/direct-log.js +11 -1
- package/dist/direct-log.js.map +1 -0
- package/dist/docs-sections.d.ts +11 -10
- package/dist/docs-sections.d.ts.map +1 -0
- package/dist/docs-sections.js +113 -3
- package/dist/docs-sections.js.map +1 -0
- package/dist/drone-lifecycle.d.ts +5 -21
- package/dist/drone-lifecycle.d.ts.map +1 -0
- package/dist/drone-lifecycle.js +57 -8
- package/dist/drone-lifecycle.js.map +1 -0
- package/dist/drone-management.d.ts +29 -0
- package/dist/drone-management.d.ts.map +1 -0
- package/dist/drone-management.js +109 -0
- package/dist/drone-management.js.map +1 -0
- package/dist/ensure-mcp-config.d.ts.map +1 -0
- package/dist/ensure-mcp-config.js +36 -1
- package/dist/ensure-mcp-config.js.map +1 -0
- package/dist/evict-drone.d.ts +10 -2
- package/dist/evict-drone.d.ts.map +1 -0
- package/dist/evict-drone.js +60 -1
- package/dist/evict-drone.js.map +1 -0
- package/dist/gc-orphan-inboxes.d.ts.map +1 -0
- package/dist/gc-orphan-inboxes.js +177 -1
- package/dist/gc-orphan-inboxes.js.map +1 -0
- package/dist/inbox-monitor.d.ts +1 -1
- package/dist/inbox-monitor.d.ts.map +1 -0
- package/dist/inbox-monitor.js +856 -3
- package/dist/inbox-monitor.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1034 -37
- package/dist/index.js.map +1 -0
- package/dist/launch-all-cmd.d.ts.map +1 -0
- package/dist/launch-all-cmd.js +377 -37
- package/dist/launch-all-cmd.js.map +1 -0
- package/dist/launch-all-command.d.ts.map +1 -0
- package/dist/launch-all-command.js +24 -1
- package/dist/launch-all-command.js.map +1 -0
- package/dist/launch-all-deps.d.ts +3 -8
- package/dist/launch-all-deps.d.ts.map +1 -0
- package/dist/launch-all-deps.js +99 -1
- package/dist/launch-all-deps.js.map +1 -0
- package/dist/launch-all-discovery.d.ts +1 -0
- package/dist/launch-all-discovery.d.ts.map +1 -0
- package/dist/launch-all-discovery.js +90 -4
- package/dist/launch-all-discovery.js.map +1 -0
- package/dist/launch-all-locks.d.ts.map +1 -0
- package/dist/launch-all-locks.js +54 -1
- package/dist/launch-all-locks.js.map +1 -0
- package/dist/launch-gate.d.ts +2 -2
- package/dist/launch-gate.d.ts.map +1 -0
- package/dist/launch-gate.js +73 -1
- package/dist/launch-gate.js.map +1 -0
- package/dist/lifecycle-log-guard.d.ts.map +1 -0
- package/dist/lifecycle-log-guard.js +93 -2
- package/dist/lifecycle-log-guard.js.map +1 -0
- package/dist/list-roles-render.d.ts.map +1 -0
- package/dist/list-roles-render.js +40 -6
- package/dist/list-roles-render.js.map +1 -0
- package/dist/local-log-routing.d.ts +19 -0
- package/dist/local-log-routing.d.ts.map +1 -0
- package/dist/local-log-routing.js +67 -0
- package/dist/local-log-routing.js.map +1 -0
- package/dist/local-manage-tool-result.d.ts +8 -0
- package/dist/local-manage-tool-result.d.ts.map +1 -0
- package/dist/local-manage-tool-result.js +10 -0
- package/dist/local-manage-tool-result.js.map +1 -0
- package/dist/local-server-cursor.d.ts +34 -0
- package/dist/local-server-cursor.d.ts.map +1 -0
- package/dist/local-server-cursor.js +151 -0
- package/dist/local-server-cursor.js.map +1 -0
- package/dist/log-audit.d.ts.map +1 -0
- package/dist/log-audit.js +194 -3
- package/dist/log-audit.js.map +1 -0
- package/dist/log-stream.d.ts +31 -18
- package/dist/log-stream.d.ts.map +1 -0
- package/dist/log-stream.js +1214 -12
- package/dist/log-stream.js.map +1 -0
- package/dist/model-presets.d.ts.map +1 -0
- package/dist/model-presets.js +19 -1
- package/dist/model-presets.js.map +1 -0
- package/dist/name-validator.d.ts.map +1 -0
- package/dist/name-validator.js +22 -1
- package/dist/name-validator.js.map +1 -0
- package/dist/opencode-drone.d.ts.map +1 -0
- package/dist/opencode-drone.js +438 -4
- package/dist/opencode-drone.js.map +1 -0
- package/dist/opencode-plugin.d.ts +1 -1
- package/dist/opencode-plugin.d.ts.map +1 -0
- package/dist/opencode-plugin.js +29 -4
- package/dist/opencode-plugin.js.map +1 -0
- package/dist/parse-assimilate-args.d.ts +1 -1
- package/dist/parse-assimilate-args.d.ts.map +1 -0
- package/dist/parse-assimilate-args.js +125 -1
- package/dist/parse-assimilate-args.js.map +1 -0
- package/dist/parse-launch-all-args.d.ts.map +1 -0
- package/dist/parse-launch-all-args.js +70 -1
- package/dist/parse-launch-all-args.js.map +1 -0
- package/dist/postinstall-banner.d.ts.map +1 -0
- package/dist/postinstall-banner.js +27 -2
- package/dist/postinstall-banner.js.map +1 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +32 -5
- package/dist/postinstall.js.map +1 -0
- package/dist/readiness-probe.d.ts.map +1 -0
- package/dist/readiness-probe.js +9 -1
- package/dist/readiness-probe.js.map +1 -0
- package/dist/regen-format.d.ts.map +1 -0
- package/dist/regen-format.js +545 -13
- package/dist/regen-format.js.map +1 -0
- package/dist/regen.d.ts.map +1 -0
- package/dist/regen.js +141 -5
- package/dist/regen.js.map +1 -0
- package/dist/remote-client.d.ts +65 -175
- package/dist/remote-client.d.ts.map +1 -0
- package/dist/remote-client.js +942 -1
- package/dist/remote-client.js.map +1 -0
- package/dist/reset-local-seat-cmd.d.ts +50 -0
- package/dist/reset-local-seat-cmd.d.ts.map +1 -0
- package/dist/reset-local-seat-cmd.js +169 -0
- package/dist/reset-local-seat-cmd.js.map +1 -0
- package/dist/role-match.d.ts.map +1 -0
- package/dist/role-match.js +23 -1
- package/dist/role-match.js.map +1 -0
- package/dist/role-resolver.d.ts.map +1 -0
- package/dist/role-resolver.js +60 -1
- package/dist/role-resolver.js.map +1 -0
- package/dist/roster-render.d.ts.map +1 -0
- package/dist/roster-render.js +121 -3
- package/dist/roster-render.js.map +1 -0
- package/dist/seat-probe.d.ts +32 -13
- package/dist/seat-probe.d.ts.map +1 -0
- package/dist/seat-probe.js +78 -1
- package/dist/seat-probe.js.map +1 -0
- package/dist/seat-store.d.ts +76 -0
- package/dist/seat-store.d.ts.map +1 -0
- package/dist/seat-store.js +309 -0
- package/dist/seat-store.js.map +1 -0
- package/dist/seats.d.ts +303 -0
- package/dist/seats.d.ts.map +1 -0
- package/dist/seats.js +551 -0
- package/dist/seats.js.map +1 -0
- package/dist/self-path.d.ts +27 -0
- package/dist/self-path.d.ts.map +1 -0
- package/dist/self-path.js +43 -0
- package/dist/self-path.js.map +1 -0
- package/dist/server-endpoint.d.ts +9 -0
- package/dist/server-endpoint.d.ts.map +1 -0
- package/dist/server-endpoint.js +38 -0
- package/dist/server-endpoint.js.map +1 -0
- package/dist/server-errors.d.ts +50 -0
- package/dist/server-errors.d.ts.map +1 -0
- package/dist/server-errors.js +79 -0
- package/dist/server-errors.js.map +1 -0
- package/dist/server-handshake.d.ts +197 -0
- package/dist/server-handshake.d.ts.map +1 -0
- package/dist/server-handshake.js +505 -0
- package/dist/server-handshake.js.map +1 -0
- package/dist/server-response.d.ts +3 -0
- package/dist/server-response.d.ts.map +1 -0
- package/dist/server-response.js +67 -0
- package/dist/server-response.js.map +1 -0
- package/dist/server-trust.d.ts +14 -0
- package/dist/server-trust.d.ts.map +1 -0
- package/dist/server-trust.js +225 -0
- package/dist/server-trust.js.map +1 -0
- package/dist/setup-confirm.d.ts +3 -3
- package/dist/setup-confirm.d.ts.map +1 -0
- package/dist/setup-confirm.js +126 -2
- package/dist/setup-confirm.js.map +1 -0
- package/dist/setup.d.ts +5 -3
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +169 -46
- package/dist/setup.js.map +1 -0
- package/dist/shell-escape.d.ts.map +1 -0
- package/dist/shell-escape.js +22 -1
- package/dist/shell-escape.js.map +1 -0
- package/dist/spawn.d.ts +2 -2
- package/dist/spawn.d.ts.map +1 -0
- package/dist/spawn.js +29 -10
- package/dist/spawn.js.map +1 -0
- package/dist/startup-services.d.ts +0 -1
- package/dist/startup-services.d.ts.map +1 -0
- package/dist/startup-services.js +26 -1
- package/dist/startup-services.js.map +1 -0
- package/dist/stream-owner.d.ts +6 -2
- package/dist/stream-owner.d.ts.map +1 -0
- package/dist/stream-owner.js +547 -2
- package/dist/stream-owner.js.map +1 -0
- package/dist/stream-status.d.ts +1 -1
- package/dist/stream-status.d.ts.map +1 -0
- package/dist/stream-status.js +268 -3
- package/dist/stream-status.js.map +1 -0
- package/dist/sync-roles-render.d.ts.map +1 -0
- package/dist/sync-roles-render.js +118 -3
- package/dist/sync-roles-render.js.map +1 -0
- package/dist/sync.d.ts +1 -1
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +286 -22
- package/dist/sync.js.map +1 -0
- package/dist/terminal-title.d.ts.map +1 -0
- package/dist/terminal-title.js +68 -1
- package/dist/terminal-title.js.map +1 -0
- package/dist/token-store.d.ts +17 -111
- package/dist/token-store.d.ts.map +1 -0
- package/dist/token-store.js +81 -1
- package/dist/token-store.js.map +1 -0
- package/dist/tool-manifest.d.ts +4 -8
- package/dist/tool-manifest.d.ts.map +1 -0
- package/dist/tool-manifest.js +554 -1
- package/dist/tool-manifest.js.map +1 -0
- package/dist/tool-scope.d.ts +8 -12
- package/dist/tool-scope.d.ts.map +1 -0
- package/dist/tool-scope.js +97 -1
- package/dist/tool-scope.js.map +1 -0
- package/dist/types.d.ts +1 -5
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/unknown-subcommand.d.ts +1 -1
- package/dist/unknown-subcommand.d.ts.map +1 -0
- package/dist/unknown-subcommand.js +37 -1
- package/dist/unknown-subcommand.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +78 -2
- package/dist/version.js.map +1 -0
- package/dist/working-repo.d.ts.map +1 -0
- package/dist/working-repo.js +81 -1
- package/dist/working-repo.js.map +1 -0
- package/dist/worktree-lifecycle.d.ts.map +1 -0
- package/dist/worktree-lifecycle.js +205 -2
- package/dist/worktree-lifecycle.js.map +1 -0
- package/docs/EXTRACTION_PROVENANCE.md +40 -0
- package/docs/LOCAL_SERVER.md +103 -0
- package/docs/RELEASING.md +120 -0
- package/package.json +52 -34
- package/src/agent-runtime.ts +69 -0
- package/src/assimilate-cmd.ts +1864 -0
- package/src/assimilate-deps.ts +444 -0
- package/src/assimilate-guard.ts +84 -0
- package/src/assimilate-welcome.ts +39 -0
- package/src/auth-env.ts +21 -0
- package/src/backends/launch-all-pastelist.ts +18 -0
- package/src/backends/launch-all-tmux.ts +75 -0
- package/src/backends/launch-all-windows.ts +110 -0
- package/src/bare-launch-menu.ts +148 -0
- package/src/claude-launch-args.ts +35 -0
- package/src/claude.ts +561 -0
- package/src/cleanup-cmd.ts +581 -0
- package/src/clear-rewake-core.ts +34 -0
- package/src/clear-rewake.ts +18 -0
- package/src/cli-help.ts +116 -0
- package/src/cli-platform.ts +127 -0
- package/src/cli-tool-approval.ts +716 -0
- package/src/codex-app-server.ts +238 -0
- package/src/codex-app-wake.ts +512 -0
- package/src/codex-launch.ts +140 -0
- package/src/codex-remote.ts +500 -0
- package/src/codex-wake-resolve.ts +155 -0
- package/src/config-utils.ts +811 -0
- package/src/config.ts +595 -0
- package/src/console-prefix.ts +99 -0
- package/src/cube-name.ts +69 -0
- package/src/cubes.ts +583 -0
- package/src/debug.ts +73 -0
- package/src/direct-log.ts +9 -0
- package/src/docs-sections.ts +129 -0
- package/src/drone-lifecycle.ts +62 -0
- package/src/drone-management.ts +162 -0
- package/src/ensure-mcp-config.ts +54 -0
- package/src/evict-drone.ts +82 -0
- package/src/gc-orphan-inboxes.ts +229 -0
- package/src/inbox-monitor.ts +1005 -0
- package/src/index.ts +1201 -0
- package/src/launch-all-cmd.ts +450 -0
- package/src/launch-all-command.ts +30 -0
- package/src/launch-all-deps.ts +188 -0
- package/src/launch-all-discovery.ts +118 -0
- package/src/launch-all-locks.ts +74 -0
- package/src/launch-gate.ts +80 -0
- package/src/lifecycle-log-guard.ts +144 -0
- package/src/list-roles-render.ts +52 -0
- package/src/local-log-routing.ts +106 -0
- package/src/local-manage-tool-result.ts +10 -0
- package/src/local-server-cursor.ts +188 -0
- package/src/log-audit.ts +207 -0
- package/src/log-stream.ts +1505 -0
- package/src/model-presets.ts +22 -0
- package/src/name-validator.ts +23 -0
- package/src/opencode-drone.ts +528 -0
- package/src/opencode-plugin.ts +38 -0
- package/src/parse-assimilate-args.ts +125 -0
- package/src/parse-launch-all-args.ts +100 -0
- package/src/postinstall-banner.ts +37 -0
- package/src/postinstall.ts +36 -0
- package/src/readiness-probe.ts +12 -0
- package/src/regen-format.ts +651 -0
- package/src/regen.ts +150 -0
- package/src/remote-client.ts +1379 -0
- package/src/reset-local-seat-cmd.ts +227 -0
- package/src/role-match.ts +29 -0
- package/src/role-resolver.ts +93 -0
- package/src/roster-render.ts +196 -0
- package/src/seat-probe.ts +115 -0
- package/src/seat-store.ts +333 -0
- package/src/seats.ts +741 -0
- package/src/self-path.ts +51 -0
- package/src/server-endpoint.ts +38 -0
- package/src/server-errors.ts +93 -0
- package/src/server-handshake.ts +783 -0
- package/src/server-response.ts +76 -0
- package/src/server-trust.ts +245 -0
- package/src/setup-confirm.ts +171 -0
- package/src/setup.ts +186 -0
- package/src/shell-escape.ts +22 -0
- package/src/spawn.ts +31 -0
- package/src/startup-services.ts +36 -0
- package/src/stream-owner.ts +686 -0
- package/src/stream-status.ts +337 -0
- package/src/sync-roles-render.ts +163 -0
- package/src/sync.ts +363 -0
- package/src/terminal-title.ts +76 -0
- package/src/token-store.ts +102 -0
- package/src/tool-manifest.ts +610 -0
- package/src/tool-scope.ts +110 -0
- package/src/types.ts +5 -0
- package/src/unknown-subcommand.ts +35 -0
- package/src/version.ts +82 -0
- package/src/working-repo.ts +99 -0
- package/src/worktree-lifecycle.ts +254 -0
- package/dist/auth-recovery.d.ts +0 -33
- package/dist/auth-recovery.js +0 -1
- package/dist/auth.d.ts +0 -103
- package/dist/auth.js +0 -39
- package/dist/device-auth.d.ts +0 -75
- package/dist/device-auth.js +0 -1
- package/dist/drone-address.d.ts +0 -26
- package/dist/drone-address.js +0 -1
- package/dist/get-started.d.ts +0 -20
- package/dist/get-started.js +0 -2
- package/dist/health-beat.d.ts +0 -134
- package/dist/health-beat.js +0 -1
- package/dist/role-section.d.ts +0 -110
- package/dist/role-section.js +0 -8
- package/dist/setup-action.d.ts +0 -20
- package/dist/setup-action.js +0 -1
- package/dist/stale-version-check.d.ts +0 -40
- package/dist/stale-version-check.js +0 -1
- package/dist/subscription-retry.d.ts +0 -40
- package/dist/subscription-retry.js +0 -1
- package/dist/templates.d.ts +0 -107
- package/dist/templates.js +0 -359
- package/dist/token-crypto.d.ts +0 -50
- package/dist/token-crypto.js +0 -1
package/dist/cubes.js
CHANGED
|
@@ -1,4 +1,412 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Per-project active-cube persistence for Borg MCP client
|
|
3
|
+
*
|
|
4
|
+
* Stores the currently-assimilated cube identity + authority metadata PER
|
|
5
|
+
* PROJECT in ~/.config/borgmcp/cubes.json. The "project"
|
|
6
|
+
* is identified by walking up from cwd to find a .git directory; if none is
|
|
7
|
+
* found, cwd itself is used as the project key.
|
|
8
|
+
*
|
|
9
|
+
* Local-server session tokens never enter this file: only an opaque keychain
|
|
10
|
+
* reference is stored and hydrated at read time. An entry without verified
|
|
11
|
+
* local-server trust can no longer be hydrated.
|
|
12
|
+
*
|
|
13
|
+
* apiUrl is captured at assimilate time so subprocess invocations (e.g. the
|
|
14
|
+
* SessionStart hook firing borg-regen) don't need BORG_API_URL in their env
|
|
15
|
+
* to know which worker to talk to.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync } from 'node:fs';
|
|
18
|
+
import { mkdir, readFile, rename, unlink, writeFile } from 'node:fs/promises';
|
|
19
|
+
import { homedir } from 'node:os';
|
|
20
|
+
import { dirname, join, resolve } from 'node:path';
|
|
21
|
+
import { pruneDeadWakeTargets } from './codex-wake-resolve.js';
|
|
22
|
+
import { getActiveSeatCredential, getActiveSeatForWorktree, getSeatForWorktree, hasSeatForWorktree, observeSeat, readAllActiveSeats, refreshSeatMetadata, resetSeatForWorktree, seatRef, } from './seats.js';
|
|
23
|
+
const CUBES_DIR = join(homedir(), '.config', 'borgmcp');
|
|
24
|
+
const LAUNCH_FILE = join(CUBES_DIR, 'launch.json');
|
|
25
|
+
const CODEX_WAKE_TARGETS_FILE = join(CUBES_DIR, 'codex-wake-targets.json');
|
|
26
|
+
const INBOX_DIR = join(CUBES_DIR, 'inboxes');
|
|
27
|
+
/**
|
|
28
|
+
* Walk up from cwd looking for a .git directory. If found, return that
|
|
29
|
+
* directory. If not found by filesystem root, return the original cwd.
|
|
30
|
+
* The returned absolute path is the "project key" used to scope cube state.
|
|
31
|
+
*/
|
|
32
|
+
export function findProjectRoot(cwd = process.cwd()) {
|
|
33
|
+
let dir = resolve(cwd);
|
|
34
|
+
while (true) {
|
|
35
|
+
if (existsSync(join(dir, '.git')))
|
|
36
|
+
return dir;
|
|
37
|
+
const parent = dirname(dir);
|
|
38
|
+
if (parent === dir)
|
|
39
|
+
return resolve(cwd); // hit root, fall back to cwd
|
|
40
|
+
dir = parent;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Per-(cube, drone) inbox file path. Each drone gets its own file so that
|
|
45
|
+
* multiple drones in the same cube don't trample each other's writes when
|
|
46
|
+
* they each receive the same long-poll batch. The file lives under a
|
|
47
|
+
* per-cube subdir keyed by cube ID, then by drone ID (a UUID, globally
|
|
48
|
+
* unique).
|
|
49
|
+
*
|
|
50
|
+
* Validates cubeId/droneId as UUIDs before using them in a filesystem
|
|
51
|
+
* path. The values come from cubes.json (populated from server response),
|
|
52
|
+
* so the input is trusted in normal operation — but a regex guard is
|
|
53
|
+
* cheap defense against a corrupted file or future bug that would
|
|
54
|
+
* otherwise let `../` slip through into the inbox path.
|
|
55
|
+
*/
|
|
56
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
57
|
+
export function inboxPathForDrone(cubeId, droneId) {
|
|
58
|
+
if (!UUID_RE.test(cubeId))
|
|
59
|
+
throw new Error(`Invalid cubeId: ${cubeId}`);
|
|
60
|
+
if (!UUID_RE.test(droneId))
|
|
61
|
+
throw new Error(`Invalid droneId: ${droneId}`);
|
|
62
|
+
return join(INBOX_DIR, cubeId, `${droneId}.log`);
|
|
63
|
+
}
|
|
64
|
+
// gh#894: crash-safe write. A plain truncate-write (open-for-write then write)
|
|
65
|
+
// leaves a truncated/empty prefs file if the process dies mid-write — losing
|
|
66
|
+
// every stored cube preference. Instead write to a same-directory temp file
|
|
67
|
+
// and rename() it over the target: rename is atomic on POSIX, so a reader
|
|
68
|
+
// always sees either the old complete file or the new complete file, never a
|
|
69
|
+
// partial one. On any failure the original is untouched (we never opened it for
|
|
70
|
+
// write) and the temp is best-effort cleaned. `io` is injectable for tests.
|
|
71
|
+
let atomicTmpCounter = 0;
|
|
72
|
+
export async function atomicWriteFile(filePath, data, opts = {}) {
|
|
73
|
+
const io = opts.io ?? { writeFile, rename, unlink };
|
|
74
|
+
const mode = opts.mode ?? 0o600;
|
|
75
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
76
|
+
// Same-dir temp so rename() stays on one filesystem (atomicity requirement).
|
|
77
|
+
// pid + counter keeps concurrent same-process writes from colliding.
|
|
78
|
+
const tmp = `${filePath}.${process.pid}.${atomicTmpCounter++}.tmp`;
|
|
79
|
+
try {
|
|
80
|
+
await io.writeFile(tmp, data, { mode });
|
|
81
|
+
await io.rename(tmp, filePath);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
try {
|
|
85
|
+
await io.unlink(tmp);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
/* best-effort temp cleanup; never mask the original error */
|
|
89
|
+
}
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function isLaunchFile(data) {
|
|
94
|
+
return (data !== null &&
|
|
95
|
+
typeof data === 'object' &&
|
|
96
|
+
typeof data.projects === 'object' &&
|
|
97
|
+
data.projects !== null &&
|
|
98
|
+
!Array.isArray(data.projects));
|
|
99
|
+
}
|
|
100
|
+
async function readLaunchFile() {
|
|
101
|
+
let raw;
|
|
102
|
+
try {
|
|
103
|
+
raw = await readFile(LAUNCH_FILE, 'utf8');
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error?.code === 'ENOENT')
|
|
107
|
+
return null;
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const parsed = JSON.parse(raw);
|
|
112
|
+
return isLaunchFile(parsed) ? parsed : null;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function writeLaunchFile(data) {
|
|
119
|
+
// atomicWriteFile handles the mkdir + 0o600 mode, and the temp+rename keeps
|
|
120
|
+
// a concurrent reader from seeing a half-written launch file (gh#894, gh#901).
|
|
121
|
+
await atomicWriteFile(LAUNCH_FILE, JSON.stringify(data, null, 2) + '\n');
|
|
122
|
+
}
|
|
123
|
+
function codexWakeTargetKey(cubeId, droneId) {
|
|
124
|
+
if (!UUID_RE.test(cubeId))
|
|
125
|
+
throw new Error(`Invalid cubeId: ${cubeId}`);
|
|
126
|
+
if (!UUID_RE.test(droneId))
|
|
127
|
+
throw new Error(`Invalid droneId: ${droneId}`);
|
|
128
|
+
return `${cubeId}:${droneId}`;
|
|
129
|
+
}
|
|
130
|
+
function isCodexWakeTargetsFile(data) {
|
|
131
|
+
return (data !== null &&
|
|
132
|
+
typeof data === 'object' &&
|
|
133
|
+
typeof data.targets === 'object' &&
|
|
134
|
+
data.targets !== null &&
|
|
135
|
+
!Array.isArray(data.targets));
|
|
136
|
+
}
|
|
137
|
+
async function readCodexWakeTargetsFile() {
|
|
138
|
+
let raw;
|
|
139
|
+
try {
|
|
140
|
+
raw = await readFile(CODEX_WAKE_TARGETS_FILE, 'utf8');
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (error?.code === 'ENOENT')
|
|
144
|
+
return null;
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const parsed = JSON.parse(raw);
|
|
149
|
+
return isCodexWakeTargetsFile(parsed) ? parsed : null;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async function writeCodexWakeTargetsFile(data) {
|
|
156
|
+
// atomicWriteFile handles the mkdir + 0o600 mode, and the temp+rename keeps
|
|
157
|
+
// a concurrent reader from seeing a half-written file (gh#894, gh#901).
|
|
158
|
+
await atomicWriteFile(CODEX_WAKE_TARGETS_FILE, JSON.stringify(data, null, 2) + '\n');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the currently-active cube for the current project, or null if not
|
|
162
|
+
* assimilated in this project. Entries written by older client versions
|
|
163
|
+
* that lack the `cubeId` field are treated as absent — re-assimilate to
|
|
164
|
+
* refresh.
|
|
165
|
+
*/
|
|
166
|
+
export async function getActiveCube() {
|
|
167
|
+
const record = await getActiveSeatForWorktree(findProjectRoot());
|
|
168
|
+
if (!record || !record.cubeId || !record.droneId)
|
|
169
|
+
return null;
|
|
170
|
+
return hydrateActiveCube(record);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* True iff this worktree has an ACTIVE bound seat in seats.json. In the collapsed
|
|
174
|
+
* single-store model the credential and the worktree binding are one atomic unit,
|
|
175
|
+
* so there is no "binding present but credential lost" partial state to diagnose:
|
|
176
|
+
* an active bound seat always hydrates.
|
|
177
|
+
*/
|
|
178
|
+
export async function hasPersistedActiveCube() {
|
|
179
|
+
return hasSeatForWorktree(findProjectRoot());
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Compose an ActiveCube from an ACTIVE SeatRecord, hydrating the session bearer via
|
|
183
|
+
* the SOLE raw-bearer reader (getActiveSeatCredential). Returns null if the bearer
|
|
184
|
+
* can no longer be resolved (record concurrently reset/replaced).
|
|
185
|
+
*/
|
|
186
|
+
async function hydrateActiveCube(record) {
|
|
187
|
+
const ref = seatRef(record);
|
|
188
|
+
const sessionToken = await getActiveSeatCredential(ref, {
|
|
189
|
+
origin: record.origin,
|
|
190
|
+
trustIdentity: record.trustIdentity,
|
|
191
|
+
cubeId: record.cubeId,
|
|
192
|
+
});
|
|
193
|
+
if (!sessionToken)
|
|
194
|
+
return null;
|
|
195
|
+
return {
|
|
196
|
+
cubeId: record.cubeId,
|
|
197
|
+
droneId: record.droneId,
|
|
198
|
+
name: record.name ?? '',
|
|
199
|
+
droneLabel: record.droneLabel ?? '',
|
|
200
|
+
sessionToken,
|
|
201
|
+
apiUrl: record.origin,
|
|
202
|
+
serverTrustIdentity: record.trustIdentity,
|
|
203
|
+
localSessionCredentialRef: ref,
|
|
204
|
+
...(record.expiresAt !== undefined ? { localSessionExpiresAt: record.expiresAt } : {}),
|
|
205
|
+
...(record.roleName !== undefined ? { roleName: record.roleName } : {}),
|
|
206
|
+
...(record.roleClass !== undefined ? { roleClass: record.roleClass } : {}),
|
|
207
|
+
...(record.isHumanSeat !== undefined ? { isHumanSeat: record.isHumanSeat } : {}),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Legacy binding-only writer. In the collapsed single-store model an ACTIVE seat is
|
|
212
|
+
* created ONLY by the atomic mint→activate+bind path in seats.ts (driven by the
|
|
213
|
+
* attach FINALIZE); there is no standalone binding write. Retained solely as a
|
|
214
|
+
* fail-closed guard for incomplete session metadata.
|
|
215
|
+
*/
|
|
216
|
+
export async function setActiveCube(_active) {
|
|
217
|
+
throw new Error('local Borg server session metadata is incomplete');
|
|
218
|
+
}
|
|
219
|
+
export function activeCubeWithFreshRegenIdentity(active, result) {
|
|
220
|
+
const name = result.cube?.name ?? active.name;
|
|
221
|
+
const droneLabel = result.drone?.label ?? active.droneLabel;
|
|
222
|
+
const roleName = result.role?.name ?? active.roleName;
|
|
223
|
+
const roleClass = result.role?.role_class ?? active.roleClass;
|
|
224
|
+
const isHumanSeat = result.role?.is_human_seat ?? active.isHumanSeat;
|
|
225
|
+
if (name === active.name && droneLabel === active.droneLabel &&
|
|
226
|
+
roleName === active.roleName && roleClass === active.roleClass &&
|
|
227
|
+
isHumanSeat === active.isHumanSeat)
|
|
228
|
+
return active;
|
|
229
|
+
return { ...active, name, droneLabel, roleName, roleClass, isHumanSeat };
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Snapshot this worktree's exact FULL local-seat binding (incl drone id) plus a
|
|
233
|
+
* token-safe TYPED observation (active + digest | absent). Read-only. Returns null
|
|
234
|
+
* when this worktree has no ACTIVE bound seat to reset: an honest no-op.
|
|
235
|
+
*/
|
|
236
|
+
export async function snapshotLocalSeat() {
|
|
237
|
+
const worktree = findProjectRoot();
|
|
238
|
+
// CR#4: discover an ACTIVE seat OR a bound-PENDING record (a sibling whose
|
|
239
|
+
// activation failed, bound to THIS worktree by the attach bind-pending step).
|
|
240
|
+
// getActiveSeatForWorktree would MISS the bound-pending record (it requires
|
|
241
|
+
// state==='active' + a drone id), so `reset-local-seat` would FALSELY report
|
|
242
|
+
// "nothing to reset" (exit 0) while a resumable, server-digest-bound bearer
|
|
243
|
+
// persists at rest — a FALSE-SUCCESS revocation failure. getSeatForWorktree sees
|
|
244
|
+
// both, and the offline reset's exact re-check + delete cover the bound-pending
|
|
245
|
+
// record too.
|
|
246
|
+
const record = await getSeatForWorktree(worktree);
|
|
247
|
+
if (!record || !record.cubeId)
|
|
248
|
+
return null;
|
|
249
|
+
const ref = seatRef(record);
|
|
250
|
+
const observation = await observeSeat(ref, {
|
|
251
|
+
origin: record.origin,
|
|
252
|
+
trustIdentity: record.trustIdentity,
|
|
253
|
+
cubeId: record.cubeId,
|
|
254
|
+
});
|
|
255
|
+
return {
|
|
256
|
+
apiUrl: record.origin,
|
|
257
|
+
serverTrustIdentity: record.trustIdentity,
|
|
258
|
+
cubeId: record.cubeId,
|
|
259
|
+
...(record.droneId !== undefined ? { droneId: record.droneId } : {}),
|
|
260
|
+
credentialRef: ref,
|
|
261
|
+
worktree,
|
|
262
|
+
observation,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Read the RAW persisted local-server seat bound to the current worktree — ACTIVE
|
|
267
|
+
* or a bound-PENDING record — WITHOUT hydrating its credential. Used by the resume
|
|
268
|
+
* path to recover the seat identity, its stored `operation`, and its `state`.
|
|
269
|
+
*
|
|
270
|
+
* CR#2: a SIBLING attach whose activation failed leaves a PENDING record BOUND to
|
|
271
|
+
* the preserved worktree (via the attach path's bind-pending step). This surfaces it so the
|
|
272
|
+
* rerun-from-that-worktree re-derives the EXACT sibling ref and re-sends the
|
|
273
|
+
* identical bearer (ghost-free convergence). A crash-in-gap PENDING record that was
|
|
274
|
+
* NEVER bound to a worktree still returns null here (it carries no worktree locator)
|
|
275
|
+
* and is resumed by prepareSeat's idempotent mint-or-reuse; a genuine absence is
|
|
276
|
+
* likewise null and a fresh enroll mints correctly.
|
|
277
|
+
*/
|
|
278
|
+
export async function readPersistedLocalSeat() {
|
|
279
|
+
const record = await getSeatForWorktree(findProjectRoot());
|
|
280
|
+
if (!record || !record.cubeId)
|
|
281
|
+
return null;
|
|
282
|
+
return {
|
|
283
|
+
cubeId: record.cubeId,
|
|
284
|
+
...(record.droneId !== undefined ? { droneId: record.droneId } : {}),
|
|
285
|
+
name: record.name ?? '',
|
|
286
|
+
droneLabel: record.droneLabel ?? '',
|
|
287
|
+
apiUrl: record.origin,
|
|
288
|
+
serverTrustIdentity: record.trustIdentity,
|
|
289
|
+
localSessionCredentialRef: seatRef(record),
|
|
290
|
+
operation: record.operation,
|
|
291
|
+
state: record.state,
|
|
292
|
+
...(record.expiresAt !== undefined ? { localSessionExpiresAt: record.expiresAt } : {}),
|
|
293
|
+
...(record.roleName !== undefined ? { roleName: record.roleName } : {}),
|
|
294
|
+
...(record.roleClass !== undefined ? { roleClass: record.roleClass } : {}),
|
|
295
|
+
...(record.isHumanSeat !== undefined ? { isHumanSeat: record.isHumanSeat } : {}),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Reset this worktree's seat: delegate to the single-store resetSeatForWorktree,
|
|
300
|
+
* which under ONE flock re-checks the exact FULL binding (ref + drone id, CR #3)
|
|
301
|
+
* plus the token-safe observation and DELETES the whole record — credential AND
|
|
302
|
+
* binding vanish together in one commit. Any drift / missing / same-ref digest
|
|
303
|
+
* replacement is an honest no-op ('changed'); no cross-store 'partial' exists.
|
|
304
|
+
*/
|
|
305
|
+
export async function resetLocalSeatBinding(expected) {
|
|
306
|
+
const outcome = await resetSeatForWorktree({
|
|
307
|
+
worktree: expected.worktree,
|
|
308
|
+
ref: expected.credentialRef,
|
|
309
|
+
droneId: expected.droneId,
|
|
310
|
+
observation: expected.observation,
|
|
311
|
+
});
|
|
312
|
+
if (outcome.outcome === 'reset')
|
|
313
|
+
return { outcome: 'reset', credentialRef: outcome.ref };
|
|
314
|
+
if (outcome.outcome === 'no-binding')
|
|
315
|
+
return { outcome: 'no-binding' };
|
|
316
|
+
return { outcome: 'changed' };
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Metadata-only refresh (cube name / drone label / role display) of the CURRENT
|
|
320
|
+
* worktree's ACTIVE seat — delegates to seats.ts refreshSeatMetadata, which CANNOT
|
|
321
|
+
* alter the credential, ref, identity, or worktree binding. A no-op when this
|
|
322
|
+
* worktree has no active seat, so a stale regen identity can never resurrect or
|
|
323
|
+
* mutate a seat ref.
|
|
324
|
+
*/
|
|
325
|
+
export async function refreshActiveCubeMetadata(active) {
|
|
326
|
+
if (!active.localSessionCredentialRef)
|
|
327
|
+
return false;
|
|
328
|
+
return refreshSeatMetadata(findProjectRoot(), {
|
|
329
|
+
credentialRef: active.localSessionCredentialRef,
|
|
330
|
+
cubeId: active.cubeId,
|
|
331
|
+
droneId: active.droneId,
|
|
332
|
+
}, {
|
|
333
|
+
name: active.name,
|
|
334
|
+
droneLabel: active.droneLabel,
|
|
335
|
+
...(active.roleName !== undefined ? { roleName: active.roleName } : {}),
|
|
336
|
+
...(active.roleClass !== undefined ? { roleClass: active.roleClass } : {}),
|
|
337
|
+
...(active.isHumanSeat !== undefined ? { isHumanSeat: active.isHumanSeat } : {}),
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
export async function getProjectCliPreference() {
|
|
341
|
+
const data = await readLaunchFile();
|
|
342
|
+
if (!data)
|
|
343
|
+
return null;
|
|
344
|
+
const entry = data.projects[findProjectRoot()];
|
|
345
|
+
return entry?.cli === 'claude' || entry?.cli === 'codex' || entry?.cli === 'opencode' ? entry.cli : null;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* gh#556 Part 2 — like getProjectCliPreference, but keyed on an arbitrary
|
|
349
|
+
* worktree dir (launch-all reads the saved CLI preference for EACH discovered
|
|
350
|
+
* worktree, not just cwd). Returns null if no preference is saved for that path.
|
|
351
|
+
*/
|
|
352
|
+
export async function getProjectCliPreferenceForPath(dir) {
|
|
353
|
+
const data = await readLaunchFile();
|
|
354
|
+
if (!data)
|
|
355
|
+
return null;
|
|
356
|
+
const entry = data.projects[findProjectRoot(dir)];
|
|
357
|
+
return entry?.cli === 'claude' || entry?.cli === 'codex' || entry?.cli === 'opencode' ? entry.cli : null;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* gh#556 Part 2 — returns all persisted project identities from the seat store.
|
|
361
|
+
* Used by `borg launch-all` to enumerate drones across all known worktrees.
|
|
362
|
+
* Returns an empty array when no ACTIVE bound seats exist.
|
|
363
|
+
*/
|
|
364
|
+
export async function readAllProjectIdentities() {
|
|
365
|
+
const seats = await readAllActiveSeats();
|
|
366
|
+
const hydrated = await Promise.all(seats.map(async ({ worktree, record }) => ({
|
|
367
|
+
projectPath: worktree,
|
|
368
|
+
cube: await hydrateActiveCube(record),
|
|
369
|
+
})));
|
|
370
|
+
return hydrated.flatMap(({ projectPath, cube }) => cube === null ? [] : [{ projectPath, cube }]);
|
|
371
|
+
}
|
|
372
|
+
export async function setProjectCliPreference(cli) {
|
|
373
|
+
const existing = (await readLaunchFile()) ?? { projects: {} };
|
|
374
|
+
existing.projects[findProjectRoot()] = { cli };
|
|
375
|
+
await writeLaunchFile(existing);
|
|
376
|
+
}
|
|
377
|
+
export async function setCodexWakeTarget(cubeId, droneId, target) {
|
|
378
|
+
const existing = (await readCodexWakeTargetsFile()) ?? { targets: {} };
|
|
379
|
+
existing.targets[codexWakeTargetKey(cubeId, droneId)] = {
|
|
380
|
+
...target,
|
|
381
|
+
updatedAt: new Date().toISOString(),
|
|
382
|
+
};
|
|
383
|
+
await writeCodexWakeTargetsFile(existing);
|
|
384
|
+
}
|
|
385
|
+
export async function getCodexWakeTarget(cubeId, droneId) {
|
|
386
|
+
const existing = await readCodexWakeTargetsFile();
|
|
387
|
+
if (!existing)
|
|
388
|
+
return null;
|
|
389
|
+
const target = existing.targets[codexWakeTargetKey(cubeId, droneId)];
|
|
390
|
+
if (!target || typeof target.threadId !== 'string' || typeof target.socketPath !== 'string') {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
return target;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* gh#855: drop wake-target entries whose app-server socket is positively dead,
|
|
397
|
+
* so the file self-heals (stale dead-socket entries from crashed prior launches
|
|
398
|
+
* don't linger and mislead probeCodexBridgeArmed / health-beat). Pure prune
|
|
399
|
+
* decision lives in codex-wake-resolve.ts (false-deaf-avoidance: keeps alive +
|
|
400
|
+
* indeterminate); this is the thin read → prune → write-only-on-change glue.
|
|
401
|
+
* The liveness check is injected (claude.ts wires checkCodexBridgeHealthy) so
|
|
402
|
+
* cubes.ts stays free of the codex-remote dependency.
|
|
403
|
+
*/
|
|
404
|
+
export async function pruneDeadCodexWakeTargets(socketLiveness) {
|
|
405
|
+
const existing = await readCodexWakeTargetsFile();
|
|
406
|
+
if (!existing)
|
|
407
|
+
return;
|
|
408
|
+
const { targets, changed } = pruneDeadWakeTargets(existing.targets, socketLiveness);
|
|
409
|
+
if (changed)
|
|
410
|
+
await writeCodexWakeTargetsFile({ ...existing, targets });
|
|
411
|
+
}
|
|
412
|
+
//# sourceMappingURL=cubes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cubes.js","sourceRoot":"","sources":["../src/cubes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,OAAO,GAIR,MAAM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E,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE1C;AAED,kDAAkD;AAClD,wBAAgB,OAAO,IAAI,OAAO,CAEjC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAOjD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAUtD;AASD,+DAA+D;AAC/D,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
package/dist/debug.js
CHANGED
|
@@ -1 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in debug logging for the borg CLI (Queen observability ask — surface
|
|
3
|
+
* exactly what failed on errors like the cross-account assimilate 404).
|
|
4
|
+
*
|
|
5
|
+
* Enabled by `--debug` on the command line OR a truthy `BORG_DEBUG` env var,
|
|
6
|
+
* wired at the CLI entry points (top-level `borg` dispatcher + `borg setup`
|
|
7
|
+
* + `borg assimilate`). When on, `authedFetch` (remote-client.ts) emits one
|
|
8
|
+
* line per HTTP request + the server error body on failure.
|
|
9
|
+
*
|
|
10
|
+
* Output goes to STDERR with a `[borg:debug]` prefix so it never contaminates
|
|
11
|
+
* STDOUT (the MCP / tool output stream a drone session proxies).
|
|
12
|
+
*
|
|
13
|
+
* HARD INVARIANT: debug output must NEVER contain token material — no
|
|
14
|
+
* Authorization header, id_token, or refresh_token. Call sites log only
|
|
15
|
+
* method / path / status / server-error-body; the Bearer token is omitted.
|
|
16
|
+
*/
|
|
17
|
+
let debugEnabled = false;
|
|
18
|
+
/** Enable or disable debug logging for the lifetime of the process. */
|
|
19
|
+
export function setDebug(on) {
|
|
20
|
+
debugEnabled = on;
|
|
21
|
+
}
|
|
22
|
+
/** Whether debug logging is currently enabled. */
|
|
23
|
+
export function isDebug() {
|
|
24
|
+
return debugEnabled;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Emit a debug line to STDERR with the `[borg:debug]` prefix. No-op when
|
|
28
|
+
* debug is disabled, so call sites need not guard. STDOUT is left clean for
|
|
29
|
+
* MCP / tool output.
|
|
30
|
+
*/
|
|
31
|
+
export function debugLog(...args) {
|
|
32
|
+
if (!debugEnabled)
|
|
33
|
+
return;
|
|
34
|
+
if (args.length > 0 && typeof args[0] === 'string') {
|
|
35
|
+
console.error(`[borg:debug] ${args[0]}`, ...args.slice(1));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error('[borg:debug]', ...args);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolve debug state from a process argv array + `BORG_DEBUG` at a CLI entry
|
|
43
|
+
* point. Enables debug when `--debug` is present OR `BORG_DEBUG` is truthy,
|
|
44
|
+
* then STRIPS every `--debug` token from the array IN PLACE so downstream
|
|
45
|
+
* subcommand parsers (which reject unknown flags) never see it. Idempotent —
|
|
46
|
+
* safe to call from more than one entry point in the same process.
|
|
47
|
+
*/
|
|
48
|
+
export function initDebugFromArgv(argv) {
|
|
49
|
+
const hasFlag = argv.includes('--debug');
|
|
50
|
+
if (hasFlag || isTruthyEnv(process.env.BORG_DEBUG)) {
|
|
51
|
+
setDebug(true);
|
|
52
|
+
}
|
|
53
|
+
if (hasFlag) {
|
|
54
|
+
for (let i = argv.length - 1; i >= 0; i -= 1) {
|
|
55
|
+
if (argv[i] === '--debug')
|
|
56
|
+
argv.splice(i, 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** A non-empty env value other than the common falsy spellings is truthy. */
|
|
61
|
+
function isTruthyEnv(value) {
|
|
62
|
+
if (!value)
|
|
63
|
+
return false;
|
|
64
|
+
const v = value.trim().toLowerCase();
|
|
65
|
+
return v !== '' && v !== '0' && v !== 'false' && v !== 'no' && v !== 'off';
|
|
66
|
+
}
|
|
67
|
+
/** Test hook: reset module-level debug state between tests. */
|
|
68
|
+
export function _resetDebugForTests() {
|
|
69
|
+
debugEnabled = false;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,IAAI,YAAY,GAAG,KAAK,CAAC;AAEzB,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CAAC,EAAW;IAClC,YAAY,GAAG,EAAE,CAAC;AACpB,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,OAAO;IACrB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAe;IACzC,IAAI,CAAC,YAAY;QAAE,OAAO;IAC1B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnD,OAAO,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAc;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACzC,IAAI,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS;gBAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,SAAS,WAAW,CAAC,KAAyB;IAC5C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC;AAC7E,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,mBAAmB;IACjC,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direct-log.d.ts","sourceRoot":"","sources":["../src/direct-log.ts"],"names":[],"mappings":"AAAA,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAQrE"}
|
package/dist/direct-log.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
function
|
|
1
|
+
export function normalizeDirectLogRecipients(value) {
|
|
2
|
+
if (value == null)
|
|
3
|
+
return [];
|
|
4
|
+
const raw = Array.isArray(value) ? value : [value];
|
|
5
|
+
const recipients = raw
|
|
6
|
+
.filter((item) => typeof item === 'string')
|
|
7
|
+
.map((item) => item.trim())
|
|
8
|
+
.filter((item) => item.length > 0);
|
|
9
|
+
return [...new Set(recipients)];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=direct-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direct-log.js","sourceRoot":"","sources":["../src/direct-log.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,4BAA4B,CAAC,KAAc;IACzD,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,GAAG;SACnB,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;SAC1D,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/docs-sections.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The single source for the in-product docs index.
|
|
3
3
|
*
|
|
4
4
|
* `borg_docs` (index.ts) returns these sections so an agent can route a "how
|
|
5
|
-
* does borgmcp work /
|
|
6
|
-
* the URL for the content. Pure data +
|
|
7
|
-
* fetch, NO RAG/embeddings.
|
|
5
|
+
* does borgmcp work / setup / concept / tool" question to the right
|
|
6
|
+
* repository-local document, then WebFetch the URL for the content. Pure data +
|
|
7
|
+
* a lazy keyword match — NO server-side fetch, NO RAG/embeddings.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* This is a local-only client: every URL points at the public source repository
|
|
10
|
+
* (its README + `docs/`), never a hosted product site.
|
|
11
|
+
*
|
|
12
|
+
* `page` is the repository-local file each section maps to (anti-drift anchor).
|
|
12
13
|
*/
|
|
13
|
-
export declare const DOCS_BASE_URL = "https://
|
|
14
|
+
export declare const DOCS_BASE_URL = "https://github.com/Byte-Ventures/borg-mcp-client";
|
|
14
15
|
export interface DocsSection {
|
|
15
16
|
/** logical topic key */
|
|
16
17
|
slug: string;
|
|
17
18
|
title: string;
|
|
18
|
-
/**
|
|
19
|
+
/** repository-local document URL the agent should WebFetch */
|
|
19
20
|
url: string;
|
|
20
|
-
/** the
|
|
21
|
+
/** the repository file this section maps to (anti-drift anchor) */
|
|
21
22
|
page: string;
|
|
22
23
|
summary: string;
|
|
23
24
|
/** extra match terms for the topic lookup */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-sections.d.ts","sourceRoot":"","sources":["../src/docs-sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,aAAa,qDAAqD,CAAC;AAKhF,MAAM,WAAW,WAAW;IAC1B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,EAAE,WAAW,EAyEtC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAU9D;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAE/D"}
|