@adhdev/daemon-core 0.9.82-rc.49 → 0.9.82-rc.490
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/boot/daemon-lifecycle.d.ts +9 -0
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/build-info.d.ts +37 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +68 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +220 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +137 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
- package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +69 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
- package/dist/commands/chat-commands-read.d.ts +23 -0
- package/dist/commands/chat-commands-scope.d.ts +39 -0
- package/dist/commands/chat-commands-shared.d.ts +33 -0
- package/dist/commands/chat-commands-write.d.ts +14 -0
- package/dist/commands/chat-commands.d.ts +10 -23
- package/dist/commands/cli-manager.d.ts +71 -1
- package/dist/commands/handler.d.ts +125 -0
- package/dist/commands/high-family/index.d.ts +3 -0
- package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
- package/dist/commands/high-family/mesh-events.d.ts +2 -0
- package/dist/commands/high-family/mesh-status.d.ts +2 -0
- package/dist/commands/high-family/types.d.ts +64 -0
- package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
- package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
- package/dist/commands/low-family/diagnostics.d.ts +2 -0
- package/dist/commands/low-family/index.d.ts +3 -0
- package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
- package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
- package/dist/commands/low-family/notification.d.ts +2 -0
- package/dist/commands/low-family/refine-config.d.ts +2 -0
- package/dist/commands/low-family/session-host.d.ts +2 -0
- package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
- package/dist/commands/low-family/status-meta.d.ts +2 -0
- package/dist/commands/low-family/types.d.ts +33 -0
- package/dist/commands/med-family/cli-agent.d.ts +2 -0
- package/dist/commands/med-family/fast-forward.d.ts +2 -0
- package/dist/commands/med-family/ide.d.ts +10 -0
- package/dist/commands/med-family/index.d.ts +3 -0
- package/dist/commands/med-family/mesh-crud.d.ts +48 -0
- package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
- package/dist/commands/med-family/mesh-queue.d.ts +2 -0
- package/dist/commands/med-family/mesh-restart.d.ts +2 -0
- package/dist/commands/med-family/types.d.ts +152 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router-aggregate-status.d.ts +24 -0
- package/dist/commands/router-mesh-session-owner.d.ts +59 -0
- package/dist/commands/router-refine.d.ts +151 -0
- package/dist/commands/router-worktree-cleanup.d.ts +133 -0
- package/dist/commands/router.d.ts +203 -15
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +11 -0
- package/dist/config/config.d.ts +19 -0
- package/dist/config/mesh-config.d.ts +65 -0
- package/dist/config/mesh-json-config.d.ts +199 -0
- package/dist/config/registry-resolver.d.ts +54 -0
- package/dist/config/repo-settings.d.ts +77 -0
- package/dist/config/state-store.d.ts +30 -0
- package/dist/daemon/dev-server.d.ts +0 -2
- package/dist/detection/cli-detector.d.ts +17 -0
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/change-impact-config.d.ts +159 -0
- package/dist/git/git-commands.d.ts +26 -2
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +80 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/git-worktree.d.ts +71 -1
- package/dist/git/index.d.ts +3 -1
- package/dist/index.d.ts +70 -17
- package/dist/index.js +53532 -19073
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53283 -18989
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/logging/debug-config.d.ts +16 -0
- package/dist/logging/log-redactor.d.ts +24 -0
- package/dist/logging/log-tail-reader.d.ts +81 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/mesh/contracts.d.ts +256 -0
- package/dist/mesh/coordinator-prompt.d.ts +76 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +203 -0
- package/dist/mesh/mesh-clone-grace.d.ts +8 -0
- package/dist/mesh/mesh-completion-synthesis.d.ts +4 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +104 -0
- package/dist/mesh/mesh-event-classify.d.ts +7 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +58 -0
- package/dist/mesh/mesh-event-trace.d.ts +21 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
- package/dist/mesh/mesh-events-pending.d.ts +258 -0
- package/dist/mesh/mesh-events-stale.d.ts +61 -0
- package/dist/mesh/mesh-events-utils.d.ts +75 -0
- package/dist/mesh/mesh-events.d.ts +6 -49
- package/dist/mesh/mesh-fast-forward.d.ts +81 -0
- package/dist/mesh/mesh-host-ownership.d.ts +21 -1
- package/dist/mesh/mesh-init.d.ts +128 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
- package/dist/mesh/mesh-ledger.d.ts +139 -1
- package/dist/mesh/mesh-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +281 -0
- package/dist/mesh/mesh-node-identity.d.ts +310 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +162 -0
- package/dist/mesh/mesh-reconcile-acked-hold.d.ts +17 -0
- package/dist/mesh/mesh-reconcile-config.d.ts +6 -0
- package/dist/mesh/mesh-reconcile-identity.d.ts +6 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +84 -0
- package/dist/mesh/mesh-reconcile-v2-backstop.d.ts +16 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +457 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-remote-event-pull.d.ts +15 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +567 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/mesh/mesh-task-inflight.d.ts +46 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +34 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +392 -1
- package/dist/mesh/preview-freshness.d.ts +28 -0
- package/dist/mesh/refine-config.d.ts +97 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +219 -0
- package/dist/providers/acp-provider-instance.d.ts +5 -0
- package/dist/providers/approval-utils.d.ts +46 -0
- package/dist/providers/chat-message-normalization.d.ts +58 -1
- package/dist/providers/cli-provider-effect-format.d.ts +30 -0
- package/dist/providers/cli-provider-history-dedup.d.ts +17 -0
- package/dist/providers/cli-provider-input-prompt.d.ts +12 -0
- package/dist/providers/cli-provider-instance-types.d.ts +45 -0
- package/dist/providers/cli-provider-instance.d.ts +426 -30
- package/dist/providers/cli-provider-status-helpers.d.ts +46 -0
- package/dist/providers/cli-provider-transcript-merge.d.ts +7 -0
- package/dist/providers/contracts.d.ts +196 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/manual-attendance.d.ts +79 -0
- package/dist/providers/native-history/antigravity-claim-registry.d.ts +39 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +137 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/constants.d.ts +12 -0
- package/dist/providers/native-history/dispatcher.d.ts +44 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +30 -0
- package/dist/providers/provider-instance.d.ts +31 -1
- package/dist/providers/provider-loader.d.ts +42 -5
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/spec/adapter.d.ts +98 -0
- package/dist/providers/spec/cli-adapter.d.ts +223 -0
- package/dist/providers/spec/evaluator.d.ts +45 -0
- package/dist/providers/spec/fsm-driver.d.ts +449 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +93 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +202 -0
- package/dist/providers/spec/native-history-executor.d.ts +41 -0
- package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/types.d.ts +244 -0
- package/dist/providers/status-monitor.d.ts +7 -7
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +84 -0
- package/dist/providers/working-dir.d.ts +17 -0
- package/dist/repo-mesh-types.d.ts +616 -12
- package/dist/runtime-defaults.d.ts +2 -0
- package/dist/session-host/managed-host.d.ts +64 -0
- package/dist/session-host/runtime-surface.d.ts +10 -16
- package/dist/sessions/registry.d.ts +26 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +110 -55
- package/dist/status/chat-tail-hot-sessions.d.ts +40 -0
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +27 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +20 -6
- package/package.json +11 -4
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +80 -14
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +3 -1
- package/src/cli-adapter-types.ts +68 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1282 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +1048 -1143
- package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
- package/src/cli-adapters/provider-cli-parse.ts +19 -0
- package/src/cli-adapters/provider-cli-runtime.ts +56 -7
- package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
- package/src/cli-adapters/provider-cli-shared.ts +121 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/pty-write-chunking.ts +106 -0
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +204 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
- package/src/cli-adapters/terminal-backends/types.ts +10 -3
- package/src/cli-adapters/terminal-screen.ts +16 -81
- package/src/commands/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2788 -0
- package/src/commands/chat-commands-scope.ts +54 -0
- package/src/commands/chat-commands-shared.ts +114 -0
- package/src/commands/chat-commands-write.ts +891 -0
- package/src/commands/chat-commands.ts +19 -1841
- package/src/commands/cli-manager.d.ts +2 -0
- package/src/commands/cli-manager.ts +724 -27
- package/src/commands/handler.ts +865 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +696 -0
- package/src/commands/high-family/mesh-events.ts +102 -0
- package/src/commands/high-family/mesh-status.ts +857 -0
- package/src/commands/high-family/types.ts +80 -0
- package/src/commands/low-family/coordinator-prompt.ts +125 -0
- package/src/commands/low-family/daemon-lifecycle.ts +120 -0
- package/src/commands/low-family/diagnostics.ts +57 -0
- package/src/commands/low-family/index.ts +37 -0
- package/src/commands/low-family/mesh-ledger.ts +62 -0
- package/src/commands/low-family/mesh-node-logs.ts +87 -0
- package/src/commands/low-family/notification.ts +116 -0
- package/src/commands/low-family/refine-config.ts +106 -0
- package/src/commands/low-family/session-host.ts +282 -0
- package/src/commands/low-family/spec-providerdev.ts +217 -0
- package/src/commands/low-family/status-meta.ts +112 -0
- package/src/commands/low-family/types.ts +39 -0
- package/src/commands/med-family/cli-agent.ts +270 -0
- package/src/commands/med-family/fast-forward.ts +230 -0
- package/src/commands/med-family/ide.ts +163 -0
- package/src/commands/med-family/index.ts +37 -0
- package/src/commands/med-family/mesh-crud.ts +1268 -0
- package/src/commands/med-family/mesh-host-pairing.ts +234 -0
- package/src/commands/med-family/mesh-queue.ts +167 -0
- package/src/commands/med-family/mesh-restart.ts +92 -0
- package/src/commands/med-family/types.ts +153 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router-aggregate-status.ts +209 -0
- package/src/commands/router-mesh-session-owner.ts +114 -0
- package/src/commands/router-refine.ts +1794 -0
- package/src/commands/router-worktree-cleanup.ts +870 -0
- package/src/commands/router.ts +567 -4149
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +517 -24
- package/src/config/config.ts +30 -0
- package/src/config/mesh-config.ts +300 -24
- package/src/config/mesh-json-config.ts +376 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/config/registry-resolver.ts +100 -0
- package/src/config/repo-settings.ts +111 -0
- package/src/config/state-store.ts +55 -0
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/daemon/dev-server.ts +0 -541
- package/src/detection/cli-detector.ts +94 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +112 -16
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +822 -48
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +261 -4
- package/src/git/index.ts +17 -0
- package/src/index.ts +190 -13
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/command-log.ts +7 -5
- package/src/logging/debug-config.ts +25 -0
- package/src/logging/debug-trace.ts +7 -2
- package/src/logging/log-redactor.ts +100 -0
- package/src/logging/log-tail-reader.ts +341 -0
- package/src/logging/logger.ts +14 -7
- package/src/mesh/contracts.ts +510 -0
- package/src/mesh/coordinator-prompt.ts +627 -34
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +706 -0
- package/src/mesh/mesh-clone-grace.ts +68 -0
- package/src/mesh/mesh-completion-synthesis.ts +416 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +284 -0
- package/src/mesh/mesh-event-classify.ts +78 -0
- package/src/mesh/mesh-event-forwarding.ts +2030 -0
- package/src/mesh/mesh-event-trace.ts +67 -0
- package/src/mesh/mesh-events-coordinator.ts +32 -0
- package/src/mesh/mesh-events-pending.ts +1548 -0
- package/src/mesh/mesh-events-stale.ts +452 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +43 -1035
- package/src/mesh/mesh-fast-forward.ts +856 -0
- package/src/mesh/mesh-host-ownership.ts +41 -3
- package/src/mesh/mesh-init.ts +350 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +897 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +695 -0
- package/src/mesh/mesh-node-identity.ts +2065 -0
- package/src/mesh/mesh-queue-assignment.ts +2498 -0
- package/src/mesh/mesh-reconcile-acked-hold.ts +230 -0
- package/src/mesh/mesh-reconcile-config.ts +66 -0
- package/src/mesh/mesh-reconcile-identity.ts +103 -0
- package/src/mesh/mesh-reconcile-loop.ts +1696 -0
- package/src/mesh/mesh-reconcile-v2-backstop.ts +62 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1792 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-remote-event-pull.ts +279 -0
- package/src/mesh/mesh-review-inbox.ts +308 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +2292 -0
- package/src/mesh/mesh-scheduling-runtime.ts +198 -0
- package/src/mesh/mesh-task-inflight.ts +70 -0
- package/src/mesh/mesh-task-stats.ts +161 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +215 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1489 -145
- package/src/mesh/preview-freshness.ts +163 -0
- package/src/mesh/refine-config.ts +129 -12
- package/src/mesh/worktree-bootstrap-config.ts +599 -0
- package/src/providers/acp-provider-instance.ts +43 -10
- package/src/providers/approval-utils.d.ts +5 -0
- package/src/providers/approval-utils.ts +100 -6
- package/src/providers/chat-message-normalization.ts +126 -4
- package/src/providers/cli-provider-effect-format.ts +53 -0
- package/src/providers/cli-provider-history-dedup.ts +75 -0
- package/src/providers/cli-provider-input-prompt.ts +133 -0
- package/src/providers/cli-provider-instance-types.ts +131 -0
- package/src/providers/cli-provider-instance.ts +2771 -499
- package/src/providers/cli-provider-status-helpers.ts +123 -0
- package/src/providers/cli-provider-transcript-merge.ts +114 -0
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +207 -6
- package/src/providers/extension-provider-instance.ts +12 -7
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +35 -12
- package/src/providers/manual-attendance.ts +105 -0
- package/src/providers/native-history/antigravity-claim-registry.ts +138 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +1275 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +479 -0
- package/src/providers/native-history/constants.ts +19 -0
- package/src/providers/native-history/dispatcher.ts +617 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +312 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +71 -0
- package/src/providers/provider-instance.ts +24 -1
- package/src/providers/provider-loader.ts +700 -55
- package/src/providers/provider-schema.ts +93 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +261 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +538 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +246 -0
- package/src/providers/spec/cli-adapter.ts +1064 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1528 -0
- package/src/providers/spec/fsm-evaluator.ts +290 -0
- package/src/providers/spec/fsm-loader.ts +128 -0
- package/src/providers/spec/fsm-types.ts +301 -0
- package/src/providers/spec/native-history-executor.ts +1241 -0
- package/src/providers/spec/pre-launch-trust.ts +104 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/types.ts +284 -0
- package/src/providers/status-monitor.d.ts +7 -7
- package/src/providers/status-monitor.ts +37 -22
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +536 -0
- package/src/providers/version-archive.ts +64 -24
- package/src/providers/working-dir.ts +23 -0
- package/src/repo-mesh-types.ts +861 -14
- package/src/runtime-defaults.ts +39 -0
- package/src/session-host/managed-host.ts +218 -0
- package/src/session-host/runtime-surface.ts +20 -80
- package/src/sessions/registry.ts +44 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +148 -55
- package/src/status/builders.ts +69 -6
- package/src/status/chat-tail-hot-sessions.ts +117 -2
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +100 -27
- package/src/system/hash.ts +23 -0
- package/src/system/host-memory.ts +29 -12
- package/src/system/load-better-sqlite3.ts +68 -0
- package/src/types.ts +26 -6
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER HIGH family — mesh coordinator launch.
|
|
3
|
+
*
|
|
4
|
+
* launch_mesh_coordinator: resolve the coordinator node + workspace, gate on Mesh
|
|
5
|
+
* Host ownership, resolve the provider's MCP coordinator setup (cli_command vs
|
|
6
|
+
* auto-import config), register the ADHDev mesh MCP server, build + inject the
|
|
7
|
+
* coordinator system prompt, launch the CLI session and record it in the
|
|
8
|
+
* coordinator registry + task ledger. Extracted verbatim from
|
|
9
|
+
* executeDaemonCommand — only `this.deps`/`this.inlineMeshCache` became
|
|
10
|
+
* `ctx.deps`/`ctx.inlineMeshCache`.
|
|
11
|
+
*/
|
|
12
|
+
import { join as pathJoin } from 'path';
|
|
13
|
+
import * as fs from 'fs';
|
|
14
|
+
import { LOG } from '../../logging/logger.js';
|
|
15
|
+
import { resolveMeshHostStatus, buildMeshHostRequiredFailure } from '../../mesh/mesh-host-ownership.js';
|
|
16
|
+
import { registerMeshCoordinator } from '../../mesh/coordinator-registry.js';
|
|
17
|
+
import { partitionSessionHostRecords } from '../../session-host/runtime-surface.js';
|
|
18
|
+
import { createHermesManualMeshCoordinatorSetup, resolveMeshCoordinatorSetup } from '../mesh-coordinator.js';
|
|
19
|
+
import { normalizeMeshNodeId } from '@adhdev/mesh-shared';
|
|
20
|
+
import {
|
|
21
|
+
readProviderPriorityFromPolicy,
|
|
22
|
+
resolveProviderTypeFromPriority,
|
|
23
|
+
readLiveMeshNodeWorkspace,
|
|
24
|
+
getMcpServersKey,
|
|
25
|
+
parseMeshCoordinatorMcpConfig,
|
|
26
|
+
serializeMeshCoordinatorMcpConfig,
|
|
27
|
+
loadHermesCoordinatorBaseConfig,
|
|
28
|
+
stripHermesCoordinatorTempModelProviderOverrides,
|
|
29
|
+
copyHermesCoordinatorCredentialFiles,
|
|
30
|
+
type MeshCoordinatorConfigFormat,
|
|
31
|
+
} from '../router.js';
|
|
32
|
+
import type { HighFamilyContext, HighFamilyHandler } from './types.js';
|
|
33
|
+
|
|
34
|
+
export const meshCoordinatorLaunchHandlers: Record<string, HighFamilyHandler> = {
|
|
35
|
+
launch_mesh_coordinator: async (ctx: HighFamilyContext, args: any) => {
|
|
36
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
37
|
+
let cliType = typeof args?.cliType === 'string' ? args.cliType.trim() : '';
|
|
38
|
+
// Optional per-launch system-prompt addition. Dashboard or API
|
|
39
|
+
// callers (e.g. when spawning a mesh-node-specific coordinator)
|
|
40
|
+
// can pass extra context that gets appended to the rendered
|
|
41
|
+
// default prompt under the "## Additional Context" section.
|
|
42
|
+
// Going through buildCoordinatorSystemPrompt's userInstruction
|
|
43
|
+
// means user-level override files (~/.adhdev/coordinator-prompts)
|
|
44
|
+
// and this per-launch addition compose cleanly: an override
|
|
45
|
+
// wins outright, but if there's no override, the default
|
|
46
|
+
// prompt + the optional append.md file + this extra context
|
|
47
|
+
// all stack in declared order.
|
|
48
|
+
const extraSystemPrompt = typeof args?.extraSystemPrompt === 'string'
|
|
49
|
+
? args.extraSystemPrompt.trim()
|
|
50
|
+
: '';
|
|
51
|
+
// Optional per-launch model / thinking-level override for the
|
|
52
|
+
// coordinator session. Passed straight through to launch_cli,
|
|
53
|
+
// which applies them best-effort for providers that support it
|
|
54
|
+
// (claude --effort, codex model_reasoning_effort). Blank / absent
|
|
55
|
+
// => provider default. This is a launch-time override only; it is
|
|
56
|
+
// NOT persisted to the mesh coordinator config.
|
|
57
|
+
const initialModel = typeof args?.initialModel === 'string' && args.initialModel.trim()
|
|
58
|
+
? args.initialModel.trim()
|
|
59
|
+
: null;
|
|
60
|
+
const initialThinkingLevel = typeof args?.initialThinkingLevel === 'string' && args.initialThinkingLevel.trim()
|
|
61
|
+
? args.initialThinkingLevel.trim()
|
|
62
|
+
: null;
|
|
63
|
+
if (!meshId) return { success: false, error: 'meshId required' };
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const { buildCoordinatorSystemPrompt } = await import('../../mesh/coordinator-prompt.js');
|
|
67
|
+
const { buildMissionPromptSection } = await import('../../mesh/mesh-missions.js');
|
|
68
|
+
// M3-3: inject the active mission summary into the coordinator prompt.
|
|
69
|
+
// Best-effort — a store failure must not block coordinator launch.
|
|
70
|
+
const buildMissionSectionBestEffort = (id: string): string => {
|
|
71
|
+
try { return buildMissionPromptSection(id); } catch { return ''; }
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Gap1: surface recent ledger/queue activity (recent failures +
|
|
75
|
+
// queue depth) so a freshly-launched coordinator sees them
|
|
76
|
+
// without first calling mesh_task_history. All cheap local reads
|
|
77
|
+
// — no remote peer probe. Best-effort: a read failure just omits
|
|
78
|
+
// the section, never blocks launch.
|
|
79
|
+
const buildRecentActivityBestEffort = async (id: string) => {
|
|
80
|
+
try {
|
|
81
|
+
const { getLedgerSummary, readLedgerEntries } = await import('../../mesh/mesh-ledger.js');
|
|
82
|
+
const { getMeshQueueStats } = await import('../../mesh/mesh-work-queue.js');
|
|
83
|
+
const summary = getLedgerSummary(id);
|
|
84
|
+
const queue = getMeshQueueStats(id);
|
|
85
|
+
const failureEntries = readLedgerEntries(id, { kind: ['task_failed'], tail: 5 });
|
|
86
|
+
const recentFailures = failureEntries.map((e) => {
|
|
87
|
+
const p = (e.payload || {}) as Record<string, unknown>;
|
|
88
|
+
const raw = typeof p.taskSummary === 'string' ? p.taskSummary
|
|
89
|
+
: typeof p.message === 'string' ? p.message
|
|
90
|
+
: typeof p.error === 'string' ? p.error
|
|
91
|
+
: '';
|
|
92
|
+
const summaryText = raw.length > 160 ? `${raw.slice(0, 160)}…` : raw;
|
|
93
|
+
return {
|
|
94
|
+
timestamp: e.timestamp,
|
|
95
|
+
nodeId: e.nodeId,
|
|
96
|
+
summary: summaryText,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
recentFailures,
|
|
101
|
+
recentFailureCount: summary.recentFailures,
|
|
102
|
+
pendingTasks: queue.pending,
|
|
103
|
+
assignedTasks: queue.assigned,
|
|
104
|
+
stalledTasks: summary.taskStalled,
|
|
105
|
+
lastActivityAt: summary.lastActivityAt,
|
|
106
|
+
};
|
|
107
|
+
} catch { return undefined; }
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Gap2-A: load accumulated operating notes (provider-neutral
|
|
111
|
+
// lessons) from the ledger so they ride into the prompt. Newest
|
|
112
|
+
// last; cap to the most recent 20 so the section stays lean.
|
|
113
|
+
// Best-effort: a read failure just omits the section.
|
|
114
|
+
const buildOperatingNotesBestEffort = async (id: string) => {
|
|
115
|
+
try {
|
|
116
|
+
const { readOperatingNotes } = await import('../../mesh/mesh-ledger.js');
|
|
117
|
+
// readOperatingNotes filters out tombstoned (forgotten) notes so a
|
|
118
|
+
// retracted lesson never rides into the prompt. Newest last; tail 20.
|
|
119
|
+
const noteEntries = readOperatingNotes(id, { tail: 20 });
|
|
120
|
+
const notes = noteEntries
|
|
121
|
+
.map((e) => {
|
|
122
|
+
const p = (e.payload || {}) as Record<string, unknown>;
|
|
123
|
+
const text = typeof p.text === 'string' ? p.text.trim() : '';
|
|
124
|
+
if (!text) return null;
|
|
125
|
+
const category: 'provider_quirk' | 'pattern_to_avoid' | 'recovery_lesson' | undefined =
|
|
126
|
+
p.category === 'provider_quirk' || p.category === 'pattern_to_avoid' || p.category === 'recovery_lesson'
|
|
127
|
+
? p.category
|
|
128
|
+
: undefined;
|
|
129
|
+
return {
|
|
130
|
+
text,
|
|
131
|
+
category,
|
|
132
|
+
createdAt: typeof p.createdAt === 'string' ? p.createdAt : e.timestamp,
|
|
133
|
+
sourceCoordinator: typeof p.sourceCoordinator === 'string' ? p.sourceCoordinator : undefined,
|
|
134
|
+
};
|
|
135
|
+
})
|
|
136
|
+
.filter((n): n is NonNullable<typeof n> => n !== null);
|
|
137
|
+
return notes.length ? notes : undefined;
|
|
138
|
+
} catch { return undefined; }
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Support inline mesh data from cloud (bypasses local meshes.json lookup)
|
|
142
|
+
let mesh: any;
|
|
143
|
+
if (args?.inlineMesh && typeof args.inlineMesh === 'object') {
|
|
144
|
+
mesh = args.inlineMesh;
|
|
145
|
+
// Cache cloud mesh so the MCP server can retrieve it via get_mesh
|
|
146
|
+
ctx.inlineMeshCache.set(meshId, mesh);
|
|
147
|
+
} else {
|
|
148
|
+
const { getMesh } = await import('../../config/mesh-config.js');
|
|
149
|
+
mesh = getMesh(meshId);
|
|
150
|
+
}
|
|
151
|
+
if (!mesh) return { success: false, error: 'Mesh not found' };
|
|
152
|
+
const meshHost = resolveMeshHostStatus(mesh);
|
|
153
|
+
if (!meshHost.canOwnCoordinator) {
|
|
154
|
+
return {
|
|
155
|
+
success: false,
|
|
156
|
+
...buildMeshHostRequiredFailure(mesh, 'coordinator launch'),
|
|
157
|
+
meshId,
|
|
158
|
+
cliType,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: 'No nodes in mesh' };
|
|
162
|
+
|
|
163
|
+
const requestedCoordinatorNodeId = typeof args?.coordinatorNodeId === 'string'
|
|
164
|
+
? args.coordinatorNodeId.trim()
|
|
165
|
+
: '';
|
|
166
|
+
const preferredCoordinatorNodeId = requestedCoordinatorNodeId
|
|
167
|
+
|| (typeof mesh.coordinator?.preferredNodeId === 'string' ? mesh.coordinator.preferredNodeId.trim() : '');
|
|
168
|
+
const coordinatorNode = preferredCoordinatorNodeId
|
|
169
|
+
? mesh.nodes.find((node: any) => node?.id === preferredCoordinatorNodeId || node?.nodeId === preferredCoordinatorNodeId)
|
|
170
|
+
: mesh.nodes[0];
|
|
171
|
+
if (!coordinatorNode) {
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
code: 'mesh_coordinator_node_not_found',
|
|
175
|
+
error: `Coordinator node ${preferredCoordinatorNodeId} was not found in mesh`,
|
|
176
|
+
meshId,
|
|
177
|
+
cliType,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const sessionHostRecords = ctx.deps.sessionHostControl?.listSessions
|
|
181
|
+
? await ctx.deps.sessionHostControl.listSessions().catch(() => [])
|
|
182
|
+
: [];
|
|
183
|
+
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
184
|
+
const workspace = readLiveMeshNodeWorkspace({
|
|
185
|
+
meshId,
|
|
186
|
+
nodeId: String(normalizeMeshNodeId(coordinatorNode) || preferredCoordinatorNodeId || ''),
|
|
187
|
+
liveSessionRecords: liveMeshSessions,
|
|
188
|
+
allowCoordinatorSession: true,
|
|
189
|
+
}) || (typeof coordinatorNode.workspace === 'string' ? coordinatorNode.workspace.trim() : '');
|
|
190
|
+
if (!workspace) return { success: false, error: 'Coordinator node workspace required', meshId, cliType };
|
|
191
|
+
|
|
192
|
+
// OPSRULES — layer the repo-shared declarative mesh config
|
|
193
|
+
// (.adhdev/mesh.json in the coordinator node workspace, else
|
|
194
|
+
// the calling cwd) UNDER the machine-local mesh entry. Only the
|
|
195
|
+
// COORDINATOR zone (prompt override/append) is merged — policy is
|
|
196
|
+
// machine-local and is never sourced from the repo file. The merge
|
|
197
|
+
// is in-memory only: meshes.json on disk is never mutated. Coordinator
|
|
198
|
+
// launch needs only the mesh.json zone (coordinator + operatingNotes),
|
|
199
|
+
// so it reads that dedicated loader directly rather than the unified
|
|
200
|
+
// loadRepoSettings (which would also touch refine/bootstrap via the
|
|
201
|
+
// machine-local inline seam). The effective mesh feeds prompt
|
|
202
|
+
// building; operating notes are merged with the runtime ledger below.
|
|
203
|
+
const { loadRepoMeshJsonConfig, applyRepoMeshConfig, mergeEffectiveOperatingNotes } =
|
|
204
|
+
await import('../../config/mesh-json-config.js');
|
|
205
|
+
const repoMeshConfigLoad = loadRepoMeshJsonConfig(workspace);
|
|
206
|
+
if (repoMeshConfigLoad.sourceType === 'invalid') {
|
|
207
|
+
LOG.warn('MeshCoordinator', `Ignoring invalid ${repoMeshConfigLoad.source} (${repoMeshConfigLoad.path || '?'}): ${repoMeshConfigLoad.error}`);
|
|
208
|
+
}
|
|
209
|
+
const effectiveMesh = applyRepoMeshConfig(mesh, repoMeshConfigLoad.config);
|
|
210
|
+
const buildEffectiveOperatingNotes = async (id: string) =>
|
|
211
|
+
mergeEffectiveOperatingNotes(repoMeshConfigLoad.config?.operatingNotes, await buildOperatingNotesBestEffort(id));
|
|
212
|
+
if (!cliType) {
|
|
213
|
+
const resolved = await resolveProviderTypeFromPriority({
|
|
214
|
+
nodeId: String(normalizeMeshNodeId(coordinatorNode) || preferredCoordinatorNodeId || 'coordinator'),
|
|
215
|
+
providerPriority: readProviderPriorityFromPolicy(coordinatorNode.policy),
|
|
216
|
+
providerLoader: ctx.deps.providerLoader,
|
|
217
|
+
onStatusChange: ctx.deps.onStatusChange,
|
|
218
|
+
});
|
|
219
|
+
if (!resolved.providerType) {
|
|
220
|
+
return {
|
|
221
|
+
success: false,
|
|
222
|
+
code: 'mesh_coordinator_provider_priority_unusable',
|
|
223
|
+
error: resolved.error || 'No usable provider found from node providerPriority',
|
|
224
|
+
meshId,
|
|
225
|
+
cliType,
|
|
226
|
+
workspace,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
cliType = resolved.providerType;
|
|
230
|
+
}
|
|
231
|
+
const providerMeta = ctx.deps.providerLoader.resolve?.(cliType) || ctx.deps.providerLoader.getMeta(cliType);
|
|
232
|
+
const coordinatorSetup = resolveMeshCoordinatorSetup({
|
|
233
|
+
provider: providerMeta,
|
|
234
|
+
cliType,
|
|
235
|
+
meshId,
|
|
236
|
+
workspace,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
if (coordinatorSetup.kind === 'unsupported') {
|
|
240
|
+
return {
|
|
241
|
+
success: false,
|
|
242
|
+
code: 'mesh_coordinator_unsupported',
|
|
243
|
+
error: coordinatorSetup.reason,
|
|
244
|
+
meshId,
|
|
245
|
+
cliType,
|
|
246
|
+
workspace,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (coordinatorSetup.kind === 'manual') {
|
|
251
|
+
return {
|
|
252
|
+
success: false,
|
|
253
|
+
code: 'mesh_coordinator_manual_mcp_setup_required',
|
|
254
|
+
error: coordinatorSetup.instructions,
|
|
255
|
+
meshId,
|
|
256
|
+
cliType,
|
|
257
|
+
workspace,
|
|
258
|
+
meshCoordinatorSetup: coordinatorSetup,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ─── CLI-command MCP registration (Codex, Gemini CLI) ───────────
|
|
263
|
+
if (coordinatorSetup.kind === 'cli_command') {
|
|
264
|
+
// Build coordinator prompt first — fail closed on errors.
|
|
265
|
+
let cliCmdSystemPrompt = '';
|
|
266
|
+
try {
|
|
267
|
+
cliCmdSystemPrompt = buildCoordinatorSystemPrompt({ mesh: effectiveMesh, coordinatorCliType: cliType, userInstruction: extraSystemPrompt || undefined, missionSection: buildMissionSectionBestEffort(mesh.id), recentActivity: await buildRecentActivityBestEffort(mesh.id), operatingNotes: await buildEffectiveOperatingNotes(mesh.id) });
|
|
268
|
+
} catch (error: any) {
|
|
269
|
+
const message = error?.message || String(error);
|
|
270
|
+
LOG.error('MeshCoordinator', `Failed to build coordinator prompt: ${message}`);
|
|
271
|
+
return {
|
|
272
|
+
success: false,
|
|
273
|
+
code: 'mesh_coordinator_prompt_failed',
|
|
274
|
+
error: `Failed to build Repo Mesh coordinator prompt: ${message}`,
|
|
275
|
+
meshId, cliType, workspace,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Run the provider's MCP registration command under a
|
|
280
|
+
// PTY. Some providers (agy, future bubbletea CLIs)
|
|
281
|
+
// refuse to run without /dev/tty, so pipe-only
|
|
282
|
+
// execFileSync silently no-ops the registration and
|
|
283
|
+
// the coordinator ends up without any mcp tools. With
|
|
284
|
+
// a real PTY the registration goes through and the
|
|
285
|
+
// exit code tells us whether it actually persisted.
|
|
286
|
+
let mcpRegistrationOk = false;
|
|
287
|
+
let mcpRegistrationFailure: {
|
|
288
|
+
command: string;
|
|
289
|
+
output: string;
|
|
290
|
+
exitCode: number | null;
|
|
291
|
+
signal: number | null;
|
|
292
|
+
timedOut: boolean;
|
|
293
|
+
} | null = null;
|
|
294
|
+
try {
|
|
295
|
+
const { buildMeshCoordinatorRegistrationPlan, execUnderPty } = await import('../mesh-coordinator.js');
|
|
296
|
+
const registrationPlan = buildMeshCoordinatorRegistrationPlan(
|
|
297
|
+
cliType,
|
|
298
|
+
coordinatorSetup.serverName,
|
|
299
|
+
coordinatorSetup.command,
|
|
300
|
+
);
|
|
301
|
+
for (const step of registrationPlan) {
|
|
302
|
+
const renderedCommand = [step.command, ...step.args].join(' ');
|
|
303
|
+
LOG.info('MeshCoordinator', `Running MCP ${step.label} (pty): ${renderedCommand}`);
|
|
304
|
+
const ptyResult = await execUnderPty(step.command, step.args, { cwd: workspace, timeoutMs: 20_000 });
|
|
305
|
+
if (ptyResult.exitCode === 0 && !ptyResult.timedOut) {
|
|
306
|
+
if (step.required) mcpRegistrationOk = true;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
LOG.warn('MeshCoordinator', `MCP ${step.label} failed exit=${ptyResult.exitCode} signal=${ptyResult.signal} timedOut=${ptyResult.timedOut} — output:\n${ptyResult.output.slice(-2000)}`);
|
|
310
|
+
if (step.required) {
|
|
311
|
+
mcpRegistrationFailure = {
|
|
312
|
+
command: renderedCommand,
|
|
313
|
+
output: ptyResult.output.slice(-2000),
|
|
314
|
+
exitCode: ptyResult.exitCode,
|
|
315
|
+
signal: ptyResult.signal,
|
|
316
|
+
timedOut: ptyResult.timedOut,
|
|
317
|
+
};
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} catch (error: any) {
|
|
322
|
+
LOG.warn('MeshCoordinator', `MCP registration command failed: ${error?.message || error}`);
|
|
323
|
+
mcpRegistrationFailure = {
|
|
324
|
+
command: coordinatorSetup.command,
|
|
325
|
+
output: error?.message || String(error),
|
|
326
|
+
exitCode: null,
|
|
327
|
+
signal: null,
|
|
328
|
+
timedOut: false,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (!mcpRegistrationOk) {
|
|
333
|
+
return {
|
|
334
|
+
success: false,
|
|
335
|
+
code: 'mesh_coordinator_mcp_registration_failed',
|
|
336
|
+
error: `Could not register ${coordinatorSetup.serverName}; coordinator session was not launched`,
|
|
337
|
+
meshId,
|
|
338
|
+
cliType,
|
|
339
|
+
workspace,
|
|
340
|
+
registration: mcpRegistrationFailure,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Codex gives repo-local .mcp.json precedence over its
|
|
345
|
+
// global `codex mcp add` registration. Refresh an
|
|
346
|
+
// existing ADHDev entry so a stale workspace command
|
|
347
|
+
// cannot shadow the registration we just verified.
|
|
348
|
+
if (cliType === 'codex-cli') {
|
|
349
|
+
const repoMcpConfigPath = pathJoin(workspace, '.mcp.json');
|
|
350
|
+
if (fs.existsSync(repoMcpConfigPath)) {
|
|
351
|
+
try {
|
|
352
|
+
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
353
|
+
fs.readFileSync(repoMcpConfigPath, 'utf-8'),
|
|
354
|
+
'claude_mcp_json',
|
|
355
|
+
);
|
|
356
|
+
const existingServers = repoMcpConfig.mcpServers;
|
|
357
|
+
if (
|
|
358
|
+
existingServers
|
|
359
|
+
&& typeof existingServers === 'object'
|
|
360
|
+
&& !Array.isArray(existingServers)
|
|
361
|
+
&& existingServers[coordinatorSetup.serverName]
|
|
362
|
+
) {
|
|
363
|
+
fs.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
364
|
+
...repoMcpConfig,
|
|
365
|
+
mcpServers: {
|
|
366
|
+
...existingServers,
|
|
367
|
+
[coordinatorSetup.serverName]: coordinatorSetup.mcpServer,
|
|
368
|
+
},
|
|
369
|
+
}, 'claude_mcp_json'), 'utf-8');
|
|
370
|
+
LOG.info('MeshCoordinator', `Refreshed repo-local ${repoMcpConfigPath} entry for ${coordinatorSetup.serverName}`);
|
|
371
|
+
}
|
|
372
|
+
} catch (error: any) {
|
|
373
|
+
return {
|
|
374
|
+
success: false,
|
|
375
|
+
code: 'mesh_coordinator_config_write_failed',
|
|
376
|
+
error: `Could not refresh repo-local MCP config: ${error?.message || error}`,
|
|
377
|
+
meshId,
|
|
378
|
+
cliType,
|
|
379
|
+
workspace,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Inject system prompt declaratively from provider.v1.json.
|
|
386
|
+
const cliCmdArgs: string[] = [];
|
|
387
|
+
const cliCmdEnv: Record<string, string> = {};
|
|
388
|
+
let cliCmdContextFilePath: string | undefined;
|
|
389
|
+
if (cliCmdSystemPrompt) {
|
|
390
|
+
const { applyMeshCoordinatorSystemPromptInjection } = await import('../mesh-coordinator.js');
|
|
391
|
+
const effect = applyMeshCoordinatorSystemPromptInjection(
|
|
392
|
+
cliCmdSystemPrompt,
|
|
393
|
+
providerMeta?.meshCoordinator?.systemPromptInjection,
|
|
394
|
+
{ cliArgs: cliCmdArgs, launchEnv: cliCmdEnv, workspace, cliType },
|
|
395
|
+
);
|
|
396
|
+
cliCmdContextFilePath = effect.contextFilePath;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const cliCmdLaunch: any = await ctx.deps.cliManager.handleCliCommand('launch_cli', {
|
|
400
|
+
cliType,
|
|
401
|
+
dir: workspace,
|
|
402
|
+
cliArgs: cliCmdArgs.length > 0 ? cliCmdArgs : undefined,
|
|
403
|
+
env: Object.keys(cliCmdEnv).length > 0 ? cliCmdEnv : undefined,
|
|
404
|
+
settings: { meshCoordinatorFor: meshId },
|
|
405
|
+
...(initialModel ? { initialModel } : {}),
|
|
406
|
+
...(initialThinkingLevel ? { initialThinkingLevel } : {}),
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// R48 inject-then-remove. Spawn was just kicked off above; agy and
|
|
410
|
+
// gemini-cli read AGENTS.md / GEMINI.md exactly once at startup and
|
|
411
|
+
// cache it for the rest of the session, so we can safely strip
|
|
412
|
+
// the wrapper from disk shortly after launch. That keeps any
|
|
413
|
+
// worker session launched into the same workspace later from
|
|
414
|
+
// picking up our wrapper block.
|
|
415
|
+
if (cliCmdLaunch?.success && cliCmdContextFilePath) {
|
|
416
|
+
const stripPath = cliCmdContextFilePath;
|
|
417
|
+
setTimeout(() => {
|
|
418
|
+
void import('../mesh-coordinator.js').then(({ stripCoordinatorWrapperFile }) => {
|
|
419
|
+
stripCoordinatorWrapperFile(stripPath);
|
|
420
|
+
LOG.info('MeshCoordinator', `Stripped wrapper from ${stripPath} after launch settle (cli_command)`);
|
|
421
|
+
}).catch(() => { /* best-effort */ });
|
|
422
|
+
}, 5000);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (!cliCmdLaunch?.success) {
|
|
426
|
+
return { success: false, error: cliCmdLaunch?.error || 'Failed to launch CLI session' };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
LOG.info('MeshCoordinator', `Launched ${cliType} coordinator (cli_command) for mesh ${meshId}`);
|
|
430
|
+
const cliCmdSessionId = cliCmdLaunch.sessionId || cliCmdLaunch.id;
|
|
431
|
+
if (cliCmdSessionId) {
|
|
432
|
+
const cliCmdInjectionDecl = providerMeta?.meshCoordinator?.systemPromptInjection;
|
|
433
|
+
registerMeshCoordinator({
|
|
434
|
+
meshId,
|
|
435
|
+
sessionId: cliCmdSessionId,
|
|
436
|
+
workspace,
|
|
437
|
+
startedAt: Date.now(),
|
|
438
|
+
cliType,
|
|
439
|
+
systemPrompt: cliCmdSystemPrompt || undefined,
|
|
440
|
+
extraSystemPrompt: extraSystemPrompt || undefined,
|
|
441
|
+
injection: cliCmdInjectionDecl ? {
|
|
442
|
+
mode: cliCmdInjectionDecl.mode,
|
|
443
|
+
target: 'flag' in cliCmdInjectionDecl ? cliCmdInjectionDecl.flag
|
|
444
|
+
: 'name' in cliCmdInjectionDecl ? cliCmdInjectionDecl.name
|
|
445
|
+
: 'path' in cliCmdInjectionDecl ? cliCmdInjectionDecl.path
|
|
446
|
+
: undefined,
|
|
447
|
+
} : undefined,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
const { appendLedgerEntry } = await import('../../mesh/mesh-ledger.js');
|
|
452
|
+
appendLedgerEntry(meshId, {
|
|
453
|
+
kind: 'coordinator_started',
|
|
454
|
+
sessionId: cliCmdSessionId,
|
|
455
|
+
providerType: cliType,
|
|
456
|
+
payload: { workspace },
|
|
457
|
+
});
|
|
458
|
+
} catch { /* best-effort */ }
|
|
459
|
+
|
|
460
|
+
return {
|
|
461
|
+
success: true,
|
|
462
|
+
meshId,
|
|
463
|
+
cliType,
|
|
464
|
+
workspace,
|
|
465
|
+
sessionId: cliCmdSessionId,
|
|
466
|
+
mcpRegistered: mcpRegistrationOk,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const configFormat = coordinatorSetup.configFormat as MeshCoordinatorConfigFormat;
|
|
471
|
+
if (configFormat !== 'claude_mcp_json' && configFormat !== 'hermes_config_yaml') {
|
|
472
|
+
return {
|
|
473
|
+
success: false,
|
|
474
|
+
code: 'mesh_coordinator_unsupported',
|
|
475
|
+
error: `Unsupported auto-import MCP config format: ${String(coordinatorSetup.configFormat)}`,
|
|
476
|
+
meshId,
|
|
477
|
+
cliType,
|
|
478
|
+
workspace,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Build the coordinator prompt before mutating workspace config or launching.
|
|
483
|
+
// Prompt generation failures are configuration/data-shape errors; fail closed so
|
|
484
|
+
// broken mesh state is visible instead of silently launching with weaker rules.
|
|
485
|
+
let systemPrompt = '';
|
|
486
|
+
try {
|
|
487
|
+
systemPrompt = buildCoordinatorSystemPrompt({ mesh: effectiveMesh, coordinatorCliType: cliType, userInstruction: extraSystemPrompt || undefined, missionSection: buildMissionSectionBestEffort(mesh.id), recentActivity: await buildRecentActivityBestEffort(mesh.id), operatingNotes: await buildEffectiveOperatingNotes(mesh.id) });
|
|
488
|
+
} catch (error: any) {
|
|
489
|
+
const message = error?.message || String(error);
|
|
490
|
+
LOG.error('MeshCoordinator', `Failed to build coordinator prompt: ${message}`);
|
|
491
|
+
return {
|
|
492
|
+
success: false,
|
|
493
|
+
code: 'mesh_coordinator_prompt_failed',
|
|
494
|
+
error: `Failed to build Repo Mesh coordinator prompt: ${message}`,
|
|
495
|
+
meshId,
|
|
496
|
+
cliType,
|
|
497
|
+
workspace,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// 1. Write provider-declared MCP config for CLIs that auto-import it.
|
|
502
|
+
const { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync } = await import('fs');
|
|
503
|
+
const { dirname } = await import('path');
|
|
504
|
+
const mcpConfigPath = coordinatorSetup.configPath;
|
|
505
|
+
const hermesManualFallback = cliType === 'hermes-cli' && configFormat === 'hermes_config_yaml'
|
|
506
|
+
? createHermesManualMeshCoordinatorSetup(meshId, workspace)
|
|
507
|
+
: null;
|
|
508
|
+
let hermesBaseConfig: { config: Record<string, any>; sourceHome: string; sourceConfigPath: string } | null = null;
|
|
509
|
+
if (hermesManualFallback) {
|
|
510
|
+
try {
|
|
511
|
+
hermesBaseConfig = loadHermesCoordinatorBaseConfig(mcpConfigPath);
|
|
512
|
+
} catch (error: any) {
|
|
513
|
+
const message = `Failed to parse Hermes base config for automatic coordinator setup: ${error?.message || error}`;
|
|
514
|
+
LOG.error('MeshCoordinator', message);
|
|
515
|
+
return { success: false, code: 'mesh_coordinator_config_parse_failed', error: message, meshId, cliType, workspace };
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const returnManualFallback = (message: string) => ({
|
|
519
|
+
success: false,
|
|
520
|
+
code: 'mesh_coordinator_manual_mcp_setup_required',
|
|
521
|
+
error: message,
|
|
522
|
+
meshId,
|
|
523
|
+
cliType,
|
|
524
|
+
workspace,
|
|
525
|
+
meshCoordinatorSetup: hermesManualFallback,
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// Merge ADHDev mesh server into existing config.
|
|
529
|
+
// Pass full mesh data as env var so the MCP server can bootstrap
|
|
530
|
+
// without depending on meshes.json or a running daemon.
|
|
531
|
+
const mcpServerEntry: Record<string, any> = {
|
|
532
|
+
command: coordinatorSetup.mcpServer.command,
|
|
533
|
+
args: coordinatorSetup.mcpServer.args,
|
|
534
|
+
};
|
|
535
|
+
if (args?.inlineMesh) {
|
|
536
|
+
const modeArgIndex = coordinatorSetup.mcpServer.args.findIndex((value: string) => value === '--mode');
|
|
537
|
+
const mcpTransport = modeArgIndex >= 0 ? coordinatorSetup.mcpServer.args[modeArgIndex + 1] : 'ipc';
|
|
538
|
+
mcpServerEntry.env = {
|
|
539
|
+
ADHDEV_INLINE_MESH: JSON.stringify(mesh),
|
|
540
|
+
ADHDEV_MCP_TRANSPORT: mcpTransport === 'local' ? 'local' : 'ipc',
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
try {
|
|
545
|
+
mkdirSync(dirname(mcpConfigPath), { recursive: true });
|
|
546
|
+
} catch (error: any) {
|
|
547
|
+
const message = `Could not prepare MCP config path for automatic setup: ${error?.message || error}`;
|
|
548
|
+
LOG.error('MeshCoordinator', message);
|
|
549
|
+
if (hermesManualFallback) return returnManualFallback(message);
|
|
550
|
+
return { success: false, code: 'mesh_coordinator_config_write_failed', error: message, meshId, cliType, workspace };
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// Backup existing MCP config if present.
|
|
554
|
+
const hadExistingMcpConfig = existsSync(mcpConfigPath);
|
|
555
|
+
let existingMcpConfig: Record<string, any> = hermesBaseConfig?.config || {};
|
|
556
|
+
if (hermesBaseConfig) {
|
|
557
|
+
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname(mcpConfigPath));
|
|
558
|
+
}
|
|
559
|
+
if (hadExistingMcpConfig) {
|
|
560
|
+
try {
|
|
561
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync(mcpConfigPath, 'utf-8'), configFormat);
|
|
562
|
+
const existingCoordinatorConfig = hermesManualFallback
|
|
563
|
+
? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig)
|
|
564
|
+
: parsedExistingMcpConfig;
|
|
565
|
+
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
566
|
+
copyFileSync(mcpConfigPath, mcpConfigPath + '.backup');
|
|
567
|
+
} catch (error: any) {
|
|
568
|
+
LOG.error('MeshCoordinator', `Failed to parse existing MCP config ${mcpConfigPath}: ${error?.message || error}`);
|
|
569
|
+
return {
|
|
570
|
+
success: false,
|
|
571
|
+
code: 'mesh_coordinator_config_parse_failed',
|
|
572
|
+
error: `Failed to parse existing MCP config at ${mcpConfigPath}`,
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const mcpServersKey = getMcpServersKey(configFormat);
|
|
578
|
+
const existingServers = existingMcpConfig[mcpServersKey];
|
|
579
|
+
const mcpConfig = {
|
|
580
|
+
...existingMcpConfig,
|
|
581
|
+
[mcpServersKey]: {
|
|
582
|
+
...(existingServers && typeof existingServers === 'object' && !Array.isArray(existingServers) ? existingServers : {}),
|
|
583
|
+
[coordinatorSetup.serverName]: mcpServerEntry,
|
|
584
|
+
},
|
|
585
|
+
};
|
|
586
|
+
try {
|
|
587
|
+
writeFileSync(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), 'utf-8');
|
|
588
|
+
} catch (error: any) {
|
|
589
|
+
const message = `Could not write MCP config for automatic setup: ${error?.message || error}`;
|
|
590
|
+
LOG.error('MeshCoordinator', message);
|
|
591
|
+
if (hermesManualFallback) return returnManualFallback(message);
|
|
592
|
+
return { success: false, code: 'mesh_coordinator_config_write_failed', error: message, meshId, cliType, workspace };
|
|
593
|
+
}
|
|
594
|
+
LOG.info('MeshCoordinator', `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
|
|
595
|
+
|
|
596
|
+
const cliArgs: string[] = [];
|
|
597
|
+
const launchEnv: Record<string, string> = {};
|
|
598
|
+
if (configFormat === 'hermes_config_yaml') {
|
|
599
|
+
launchEnv.HERMES_HOME = dirname(mcpConfigPath);
|
|
600
|
+
launchEnv.HERMES_IGNORE_USER_CONFIG = '';
|
|
601
|
+
}
|
|
602
|
+
let autoImportContextFilePath: string | undefined;
|
|
603
|
+
if (systemPrompt) {
|
|
604
|
+
const { applyMeshCoordinatorSystemPromptInjection } = await import('../mesh-coordinator.js');
|
|
605
|
+
const effect = applyMeshCoordinatorSystemPromptInjection(
|
|
606
|
+
systemPrompt,
|
|
607
|
+
providerMeta?.meshCoordinator?.systemPromptInjection,
|
|
608
|
+
{ cliArgs, launchEnv, workspace, cliType },
|
|
609
|
+
);
|
|
610
|
+
autoImportContextFilePath = effect.contextFilePath;
|
|
611
|
+
}
|
|
612
|
+
if (cliType === 'claude-cli') {
|
|
613
|
+
cliArgs.push('--mcp-config', coordinatorSetup.configPath);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// 3. Launch CLI session via existing cliManager.
|
|
617
|
+
// Provider-specific prompt injection remains fail-closed: Claude gets
|
|
618
|
+
// explicit CLI args, while Hermes reads HERMES_EPHEMERAL_SYSTEM_PROMPT.
|
|
619
|
+
const launchResult: any = await ctx.deps.cliManager.handleCliCommand('launch_cli', {
|
|
620
|
+
cliType,
|
|
621
|
+
dir: workspace,
|
|
622
|
+
cliArgs: cliArgs.length > 0 ? cliArgs : undefined,
|
|
623
|
+
env: Object.keys(launchEnv).length > 0 ? launchEnv : undefined,
|
|
624
|
+
settings: {
|
|
625
|
+
meshCoordinatorFor: meshId
|
|
626
|
+
},
|
|
627
|
+
...(initialModel ? { initialModel } : {}),
|
|
628
|
+
...(initialThinkingLevel ? { initialThinkingLevel } : {}),
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
// R48 inject-then-remove. See the cli_command branch for context;
|
|
632
|
+
// same idea: strip the wrapper from disk ~5s after launch so the
|
|
633
|
+
// user's AGENTS.md / GEMINI.md is untouched the moment any
|
|
634
|
+
// worker session opens up in the same workspace.
|
|
635
|
+
if (launchResult?.success && autoImportContextFilePath) {
|
|
636
|
+
const stripPath = autoImportContextFilePath;
|
|
637
|
+
setTimeout(() => {
|
|
638
|
+
void import('../mesh-coordinator.js').then(({ stripCoordinatorWrapperFile }) => {
|
|
639
|
+
stripCoordinatorWrapperFile(stripPath);
|
|
640
|
+
LOG.info('MeshCoordinator', `Stripped wrapper from ${stripPath} after launch settle (auto_import)`);
|
|
641
|
+
}).catch(() => { /* best-effort */ });
|
|
642
|
+
}, 5000);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (!launchResult?.success) {
|
|
646
|
+
return { success: false, error: launchResult?.error || 'Failed to launch CLI session' };
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
LOG.info('MeshCoordinator', `Launched ${cliType} coordinator for mesh ${meshId} in ${workspace}`);
|
|
650
|
+
const launchSessionId = launchResult.sessionId || launchResult.id;
|
|
651
|
+
if (launchSessionId) {
|
|
652
|
+
const autoImportInjectionDecl = providerMeta?.meshCoordinator?.systemPromptInjection;
|
|
653
|
+
registerMeshCoordinator({
|
|
654
|
+
meshId,
|
|
655
|
+
sessionId: launchSessionId,
|
|
656
|
+
workspace,
|
|
657
|
+
startedAt: Date.now(),
|
|
658
|
+
cliType,
|
|
659
|
+
systemPrompt: systemPrompt || undefined,
|
|
660
|
+
extraSystemPrompt: extraSystemPrompt || undefined,
|
|
661
|
+
mcpConfigPath,
|
|
662
|
+
injection: autoImportInjectionDecl ? {
|
|
663
|
+
mode: autoImportInjectionDecl.mode,
|
|
664
|
+
target: 'flag' in autoImportInjectionDecl ? autoImportInjectionDecl.flag
|
|
665
|
+
: 'name' in autoImportInjectionDecl ? autoImportInjectionDecl.name
|
|
666
|
+
: 'path' in autoImportInjectionDecl ? autoImportInjectionDecl.path
|
|
667
|
+
: undefined,
|
|
668
|
+
} : undefined,
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// Record coordinator launch in task ledger
|
|
673
|
+
try {
|
|
674
|
+
const { appendLedgerEntry } = await import('../../mesh/mesh-ledger.js');
|
|
675
|
+
appendLedgerEntry(meshId, {
|
|
676
|
+
kind: 'coordinator_started',
|
|
677
|
+
sessionId: launchSessionId,
|
|
678
|
+
providerType: cliType,
|
|
679
|
+
payload: { workspace },
|
|
680
|
+
});
|
|
681
|
+
} catch { /* ledger append is best-effort */ }
|
|
682
|
+
|
|
683
|
+
return {
|
|
684
|
+
success: true,
|
|
685
|
+
meshId,
|
|
686
|
+
cliType,
|
|
687
|
+
workspace,
|
|
688
|
+
sessionId: launchSessionId,
|
|
689
|
+
mcpConfigWritten: true,
|
|
690
|
+
};
|
|
691
|
+
} catch (e: any) {
|
|
692
|
+
LOG.error('MeshCoordinator', `Failed: ${e.message}`);
|
|
693
|
+
return { success: false, error: e.message };
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
};
|