@adhdev/daemon-core 0.9.82-rc.43 → 0.9.82-rc.430
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 +200 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +126 -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 +7 -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 +15 -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 +60 -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 +29 -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 +142 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +276 -2
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +100 -1
- package/dist/config/mesh-json-config.d.ts +199 -0
- package/dist/config/repo-settings.d.ts +77 -0
- package/dist/daemon/dev-server.d.ts +0 -2
- 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 +11 -1
- 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 +57 -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 +64 -14
- package/dist/index.js +49391 -19228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48574 -18570
- 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/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 +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +89 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +174 -0
- package/dist/mesh/mesh-clone-grace.d.ts +8 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-event-classify.d.ts +5 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +41 -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 +69 -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 +9 -0
- package/dist/mesh/mesh-init.d.ts +86 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +189 -0
- package/dist/mesh/mesh-node-identity.d.ts +289 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +113 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +65 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +428 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -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 +450 -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 +30 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +290 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +216 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +145 -0
- package/dist/providers/acp-provider-instance.d.ts +5 -0
- package/dist/providers/approval-utils.d.ts +20 -0
- package/dist/providers/chat-message-normalization.d.ts +31 -1
- package/dist/providers/cli-provider-instance.d.ts +221 -3
- package/dist/providers/contracts.d.ts +139 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/manual-attendance.d.ts +63 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -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 +27 -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 +29 -0
- package/dist/providers/provider-instance.d.ts +23 -1
- package/dist/providers/provider-loader.d.ts +26 -4
- 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 +91 -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 +422 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +76 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +174 -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 +222 -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 +501 -13
- package/dist/runtime-defaults.d.ts +2 -0
- package/dist/sessions/registry.d.ts +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +59 -2
- 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 +26 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -3
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +63 -12
- 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 +1246 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +914 -1144
- 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/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
- package/src/commands/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2327 -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.ts +544 -26
- package/src/commands/handler.ts +841 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +678 -0
- package/src/commands/high-family/mesh-events.ts +80 -0
- package/src/commands/high-family/mesh-status.ts +710 -0
- package/src/commands/high-family/types.ts +76 -0
- package/src/commands/low-family/coordinator-prompt.ts +72 -0
- package/src/commands/low-family/daemon-lifecycle.ts +107 -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 +274 -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 +238 -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 +1066 -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 +143 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router.ts +2711 -3254
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +483 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +495 -22
- package/src/config/mesh-json-config.ts +376 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/config/repo-settings.ts +111 -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 +28 -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 +59 -15
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +767 -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 +194 -12
- 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/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 +338 -0
- package/src/mesh/coordinator-prompt.ts +381 -33
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +645 -0
- package/src/mesh/mesh-clone-grace.ts +68 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-event-classify.ts +51 -0
- package/src/mesh/mesh-event-forwarding.ts +1888 -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 +656 -0
- package/src/mesh/mesh-events-stale.ts +389 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +33 -1035
- package/src/mesh/mesh-fast-forward.ts +843 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-init.ts +260 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +656 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +449 -0
- package/src/mesh/mesh-node-identity.ts +1887 -0
- package/src/mesh/mesh-queue-assignment.ts +1918 -0
- package/src/mesh/mesh-reconcile-loop.ts +1780 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1673 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-review-inbox.ts +307 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +1853 -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 +185 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1243 -141
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +423 -0
- package/src/mesh/worktree-bootstrap-config.ts +450 -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 +57 -5
- package/src/providers/chat-message-normalization.ts +92 -4
- package/src/providers/cli-provider-instance.ts +1933 -104
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +150 -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 +85 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +643 -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 +339 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +230 -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 +19 -1
- package/src/providers/provider-loader.ts +668 -50
- package/src/providers/provider-schema.ts +87 -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 +250 -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 +504 -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 +235 -0
- package/src/providers/spec/cli-adapter.ts +1056 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1410 -0
- package/src/providers/spec/fsm-evaluator.ts +272 -0
- package/src/providers/spec/fsm-loader.ts +120 -0
- package/src/providers/spec/fsm-types.ts +273 -0
- package/src/providers/spec/native-history-executor.ts +1128 -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 +262 -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 +740 -14
- package/src/runtime-defaults.ts +39 -0
- package/src/sessions/registry.ts +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +64 -1
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +95 -26
- 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 +5 -0
- 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
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createHash } from 'node:crypto'
|
|
3
|
-
import { existsSync, readdirSync, realpathSync } from 'node:fs'
|
|
4
|
-
import { createRequire } from 'node:module'
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
2
|
import * as os from 'node:os'
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
3
|
+
import { DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS } from '@adhdev/session-host-core'
|
|
4
|
+
import { basename, isAbsolute, join, resolve } from 'node:path'
|
|
5
|
+
import { LOG } from '../logging/logger.js'
|
|
6
|
+
import { shortHash } from '../system/hash.js'
|
|
7
|
+
import type {
|
|
8
|
+
MeshCoordinatorMcpConfigFormat,
|
|
9
|
+
MeshCoordinatorSystemPromptInjection,
|
|
10
|
+
ProviderModule,
|
|
11
|
+
} from '../providers/contracts.js'
|
|
8
12
|
|
|
9
13
|
export interface MeshCoordinatorMcpServerLaunch {
|
|
10
14
|
command: string
|
|
@@ -36,6 +40,7 @@ export type MeshCoordinatorSetup =
|
|
|
36
40
|
command: string
|
|
37
41
|
requiresRestart: boolean
|
|
38
42
|
instructions: string
|
|
43
|
+
mcpServer: MeshCoordinatorMcpServerLaunch
|
|
39
44
|
}
|
|
40
45
|
| {
|
|
41
46
|
kind: 'unsupported'
|
|
@@ -55,7 +60,7 @@ export interface ResolveMeshCoordinatorSetupOptions {
|
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
const DEFAULT_SERVER_NAME = 'adhdev-mesh'
|
|
58
|
-
const DEFAULT_ADHDEV_MCP_COMMAND = 'adhdev
|
|
63
|
+
const DEFAULT_ADHDEV_MCP_COMMAND = 'adhdev'
|
|
59
64
|
const HERMES_CLI_TYPE = 'hermes-cli'
|
|
60
65
|
const HERMES_MCP_CONFIG_PATH = '~/.hermes/config.yaml'
|
|
61
66
|
|
|
@@ -67,8 +72,9 @@ function isHermesProvider(provider: ProviderModule | null | undefined, cliType?:
|
|
|
67
72
|
function resolveHermesMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetupOptions): MeshCoordinatorSetup {
|
|
68
73
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
69
74
|
meshId: options.meshId,
|
|
70
|
-
|
|
75
|
+
adhdevMcpCommand: options.adhdevMcpCommand,
|
|
71
76
|
adhdevMcpEntryPath: options.adhdevMcpEntryPath,
|
|
77
|
+
nodeExecutable: options.nodeExecutable,
|
|
72
78
|
adhdevMcpTransport: options.adhdevMcpTransport,
|
|
73
79
|
adhdevMcpPort: options.adhdevMcpPort,
|
|
74
80
|
})
|
|
@@ -100,7 +106,7 @@ export function createHermesManualMeshCoordinatorSetup(meshId: string, workspace
|
|
|
100
106
|
requiresRestart: true,
|
|
101
107
|
instructions: 'Hermes CLI does not auto-import repo-local .mcp.json. Add this MCP server to Hermes config under mcp_servers, then start a fresh Hermes session.',
|
|
102
108
|
template: renderMeshCoordinatorTemplate(
|
|
103
|
-
'mcp_servers:\n {{serverName}}:\n command: {{adhdevMcpCommand}}\n args:\n - --repo-mesh\n - {{meshId}}\n enabled: true\n',
|
|
109
|
+
'mcp_servers:\n {{serverName}}:\n command: {{adhdevMcpCommand}}\n args:\n - mcp\n - --mode\n - ipc\n - --repo-mesh\n - {{meshId}}\n enabled: true\n',
|
|
104
110
|
{
|
|
105
111
|
meshId,
|
|
106
112
|
workspace,
|
|
@@ -141,8 +147,9 @@ export function resolveMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetup
|
|
|
141
147
|
}
|
|
142
148
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
143
149
|
meshId,
|
|
144
|
-
|
|
150
|
+
adhdevMcpCommand: options.adhdevMcpCommand,
|
|
145
151
|
adhdevMcpEntryPath: options.adhdevMcpEntryPath,
|
|
152
|
+
nodeExecutable: options.nodeExecutable,
|
|
146
153
|
adhdevMcpTransport: options.adhdevMcpTransport,
|
|
147
154
|
adhdevMcpPort: options.adhdevMcpPort,
|
|
148
155
|
})
|
|
@@ -167,22 +174,41 @@ export function resolveMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetup
|
|
|
167
174
|
if (!instructions || !template?.trim()) {
|
|
168
175
|
return { kind: 'unsupported', reason: 'Provider manual MCP setup is missing instructions or template' }
|
|
169
176
|
}
|
|
170
|
-
const
|
|
177
|
+
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
178
|
+
meshId,
|
|
179
|
+
adhdevMcpCommand: options.adhdevMcpCommand,
|
|
180
|
+
adhdevMcpEntryPath: options.adhdevMcpEntryPath,
|
|
181
|
+
nodeExecutable: options.nodeExecutable,
|
|
182
|
+
adhdevMcpTransport: options.adhdevMcpTransport,
|
|
183
|
+
adhdevMcpPort: options.adhdevMcpPort,
|
|
184
|
+
})
|
|
185
|
+
if (!mcpServer) {
|
|
186
|
+
return {
|
|
187
|
+
kind: 'unsupported',
|
|
188
|
+
reason: 'Could not resolve the ADHDev MCP server entrypoint and transport arguments',
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
let renderedTemplate = renderMeshCoordinatorTemplate(template, {
|
|
171
192
|
meshId,
|
|
172
193
|
workspace,
|
|
173
194
|
serverName,
|
|
174
|
-
adhdevMcpCommand:
|
|
195
|
+
adhdevMcpCommand: mcpServer.command,
|
|
196
|
+
adhdevMcpArgs: mcpServer.args.join(' '),
|
|
175
197
|
})
|
|
176
198
|
// Detect if the template is a runnable CLI command (single line, no YAML/JSON structure).
|
|
177
199
|
// If so, use cli_command kind so the daemon can execute it automatically.
|
|
178
200
|
const isCliCommand = !renderedTemplate.trim().includes('\n') && !renderedTemplate.trim().startsWith('{')
|
|
179
201
|
if (isCliCommand) {
|
|
202
|
+
if (!/\{\{\s*adhdevMcpArgs\s*\}\}/.test(template)) {
|
|
203
|
+
renderedTemplate = replaceLegacyCliCommandMcpArgs(renderedTemplate, mcpServer.args)
|
|
204
|
+
}
|
|
180
205
|
return {
|
|
181
206
|
kind: 'cli_command',
|
|
182
207
|
serverName,
|
|
183
208
|
command: renderedTemplate.trim(),
|
|
184
209
|
requiresRestart: mcpConfig.requiresRestart === true,
|
|
185
210
|
instructions: instructions,
|
|
211
|
+
mcpServer,
|
|
186
212
|
}
|
|
187
213
|
}
|
|
188
214
|
return {
|
|
@@ -203,12 +229,19 @@ export function resolveMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetup
|
|
|
203
229
|
}
|
|
204
230
|
|
|
205
231
|
function renderMeshCoordinatorTemplate(template: string, values: Record<string, string>): string {
|
|
206
|
-
return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key: string) => values[key] || '')
|
|
232
|
+
return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand|adhdevMcpArgs)\s*\}\}/g, (_, key: string) => values[key] || '')
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function replaceLegacyCliCommandMcpArgs(command: string, args: string[]): string {
|
|
236
|
+
return command.replace(
|
|
237
|
+
/\bmcp\s+--mode\s+(?:ipc|local)\s+--repo-mesh\s+\S+(?:\s+--port\s+\d+)?\s*$/,
|
|
238
|
+
args.join(' '),
|
|
239
|
+
)
|
|
207
240
|
}
|
|
208
241
|
|
|
209
242
|
function resolveHermesCoordinatorHome(meshId: string, workspace: string): string {
|
|
210
243
|
const key = `${meshId || 'mesh'}\n${resolve(workspace || os.tmpdir())}`
|
|
211
|
-
const hash =
|
|
244
|
+
const hash = shortHash(key)
|
|
212
245
|
return join(os.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash}`)
|
|
213
246
|
}
|
|
214
247
|
|
|
@@ -222,25 +255,53 @@ function resolveMcpConfigPath(configPath: string, workspace: string): string {
|
|
|
222
255
|
|
|
223
256
|
function resolveAdhdevMcpServerLaunch(options: {
|
|
224
257
|
meshId: string
|
|
225
|
-
|
|
258
|
+
adhdevMcpCommand?: string
|
|
226
259
|
adhdevMcpEntryPath?: string
|
|
260
|
+
nodeExecutable?: string
|
|
227
261
|
adhdevMcpTransport?: 'local' | 'ipc'
|
|
228
262
|
adhdevMcpPort?: number
|
|
229
263
|
}): MeshCoordinatorMcpServerLaunch | null {
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
264
|
+
const directEntryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath)
|
|
265
|
+
if (directEntryPath) {
|
|
266
|
+
const transport = resolveMcpTransport(options.adhdevMcpTransport)
|
|
267
|
+
const args = [directEntryPath, '--mode', transport, '--repo-mesh', options.meshId]
|
|
268
|
+
const port = resolveMcpPort(options.adhdevMcpPort)
|
|
269
|
+
if (port !== undefined) args.push('--port', String(port))
|
|
270
|
+
return {
|
|
271
|
+
command: resolveNodeExecutable(options.nodeExecutable),
|
|
272
|
+
args,
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const command = resolveAdhdevCommand(options.adhdevMcpCommand)
|
|
234
277
|
const transport = resolveMcpTransport(options.adhdevMcpTransport)
|
|
235
|
-
const
|
|
278
|
+
const directMcpEntrypoint = basename(command).startsWith('adhdev-mcp')
|
|
279
|
+
|| command.includes('/vendor/mcp-server/')
|
|
280
|
+
|| command.includes('\\vendor\\mcp-server\\')
|
|
281
|
+
const args = [...(directMcpEntrypoint ? [] : ['mcp']), '--mode', transport, '--repo-mesh', options.meshId]
|
|
236
282
|
const port = resolveMcpPort(options.adhdevMcpPort)
|
|
237
283
|
if (port !== undefined) args.push('--port', String(port))
|
|
238
284
|
return {
|
|
239
|
-
command
|
|
285
|
+
command,
|
|
240
286
|
args,
|
|
241
287
|
}
|
|
242
288
|
}
|
|
243
289
|
|
|
290
|
+
function resolveAdhdevCommand(explicitCommand?: string): string {
|
|
291
|
+
return explicitCommand?.trim() || process.env.ADHDEV_COORDINATOR_MCP_COMMAND?.trim() || DEFAULT_ADHDEV_MCP_COMMAND
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function resolveAdhdevMcpEntryPath(explicitEntryPath?: string): string | null {
|
|
295
|
+
const entryPath = explicitEntryPath?.trim() || process.env.ADHDEV_COORDINATOR_MCP_ENTRY_PATH?.trim()
|
|
296
|
+
return entryPath || null
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function resolveNodeExecutable(explicitNodeExecutable?: string): string {
|
|
300
|
+
return explicitNodeExecutable?.trim()
|
|
301
|
+
|| process.env.ADHDEV_COORDINATOR_NODE_EXECUTABLE?.trim()
|
|
302
|
+
|| process.execPath
|
|
303
|
+
}
|
|
304
|
+
|
|
244
305
|
function resolveMcpTransport(explicitTransport?: 'local' | 'ipc'): 'local' | 'ipc' {
|
|
245
306
|
if (explicitTransport === 'local' || explicitTransport === 'ipc') return explicitTransport
|
|
246
307
|
const envTransport = process.env.ADHDEV_COORDINATOR_MCP_TRANSPORT?.trim()
|
|
@@ -255,127 +316,276 @@ function resolveMcpPort(explicitPort?: number): number | undefined {
|
|
|
255
316
|
return Number.isInteger(parsed) && parsed > 0 ? parsed : undefined
|
|
256
317
|
}
|
|
257
318
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Apply a provider's declared system-prompt injection rule, mutating `cliArgs`
|
|
321
|
+
* and `launchEnv` in place and writing any required workspace context file.
|
|
322
|
+
*
|
|
323
|
+
* Replaces the previous hard-coded `if (cliType === 'claude-cli') ... else if
|
|
324
|
+
* (cliType === 'hermes-cli') ...` branches in router.ts. Adding a new CLI is
|
|
325
|
+
* now provider.v1.json data, not a router edit.
|
|
326
|
+
*
|
|
327
|
+
* Failures are non-fatal: log and continue with whatever was applied so the
|
|
328
|
+
* coordinator session still launches, just without the prompt for that
|
|
329
|
+
* provider. A missing/unknown rule means "skip injection" — safe by default
|
|
330
|
+
* (the previous fallback unconditionally pushed --append-system-prompt onto
|
|
331
|
+
* every non-Claude CLI, which crashed agy on launch).
|
|
332
|
+
*/
|
|
333
|
+
export interface CoordinatorInjectionEffect {
|
|
334
|
+
/** Absolute path the daemon wrote a wrapper-blocked file to. Only set for
|
|
335
|
+
* context_file injection. R48 schedules a strip after launch so workers
|
|
336
|
+
* don't see the wrapper on disk; R47's unregister cleanup uses it as a
|
|
337
|
+
* fallback if the timer never fires (process crash, etc). */
|
|
338
|
+
contextFilePath?: string
|
|
339
|
+
}
|
|
269
340
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
addCandidate('/usr/bin/node')
|
|
278
|
-
addCandidate(process.execPath)
|
|
279
|
-
|
|
280
|
-
for (const candidate of candidates) {
|
|
281
|
-
if (nodeRuntimeSupportsWebSocket(candidate)) return candidate
|
|
282
|
-
}
|
|
283
|
-
return null
|
|
341
|
+
export function applyMeshCoordinatorSystemPromptInjection(
|
|
342
|
+
systemPrompt: string,
|
|
343
|
+
injection: MeshCoordinatorSystemPromptInjection | undefined,
|
|
344
|
+
ctx: { cliArgs: string[]; launchEnv: Record<string, string>; workspace: string; cliType: string },
|
|
345
|
+
): CoordinatorInjectionEffect {
|
|
346
|
+
if (!systemPrompt || !injection) return {}
|
|
347
|
+
return applyInjectionRule(systemPrompt, injection, ctx)
|
|
284
348
|
}
|
|
285
349
|
|
|
286
|
-
function
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
350
|
+
function applyInjectionRule(
|
|
351
|
+
systemPrompt: string,
|
|
352
|
+
injection: MeshCoordinatorSystemPromptInjection,
|
|
353
|
+
ctx: { cliArgs: string[]; launchEnv: Record<string, string>; workspace: string; cliType: string },
|
|
354
|
+
): CoordinatorInjectionEffect {
|
|
355
|
+
switch (injection.mode) {
|
|
356
|
+
case 'cli_arg': {
|
|
357
|
+
if (!injection.flag) return {}
|
|
358
|
+
ctx.cliArgs.push(injection.flag, systemPrompt)
|
|
359
|
+
return {}
|
|
360
|
+
}
|
|
361
|
+
case 'config_override': {
|
|
362
|
+
if (!injection.flag || !injection.template) return {}
|
|
363
|
+
const rendered = injection.template
|
|
364
|
+
.replace(/\{prompt_json\}/g, JSON.stringify(systemPrompt))
|
|
365
|
+
.replace(/\{prompt\}/g, systemPrompt)
|
|
366
|
+
ctx.cliArgs.push(injection.flag, rendered)
|
|
367
|
+
return {}
|
|
368
|
+
}
|
|
369
|
+
case 'env_var': {
|
|
370
|
+
if (!injection.name) return {}
|
|
371
|
+
ctx.launchEnv[injection.name] = systemPrompt
|
|
372
|
+
return {}
|
|
373
|
+
}
|
|
374
|
+
case 'context_file': {
|
|
375
|
+
if (!injection.path) return {}
|
|
376
|
+
const target = isAbsolute(injection.path)
|
|
377
|
+
? injection.path
|
|
378
|
+
: join(ctx.workspace, injection.path)
|
|
379
|
+
const wrapper = injection.wrapper && injection.wrapper.includes('{prompt}')
|
|
380
|
+
? injection.wrapper
|
|
381
|
+
: '{prompt}'
|
|
382
|
+
// Prepend a short managed-by hint inside the wrapper block so a user
|
|
383
|
+
// opening AGENTS.md / GEMINI.md immediately understands the block is
|
|
384
|
+
// auto-regenerated by the daemon on every coordinator launch. The hint
|
|
385
|
+
// sits between the opening sentinel and the prompt body, so the stable
|
|
386
|
+
// sentinels declared in provider.v1.json are untouched and the
|
|
387
|
+
// idempotent replace regex above still matches on relaunches.
|
|
388
|
+
const managedNote =
|
|
389
|
+
'> _Managed by adhdev mesh coordinator — do not hand-edit this block. ' +
|
|
390
|
+
'Changes inside the sentinels are overwritten on next coordinator launch._'
|
|
391
|
+
const promptWithNote = `${managedNote}\n\n${systemPrompt}`
|
|
392
|
+
const rendered = wrapper.replace(/\{prompt\}/g, promptWithNote)
|
|
393
|
+
// If the wrapper has a stable opening sentinel, treat everything up to
|
|
394
|
+
// the matching closing sentinel as our previously-written block and
|
|
395
|
+
// replace it. Otherwise just append. The marker is the first non-
|
|
396
|
+
// placeholder line of the wrapper; this keeps relaunches idempotent
|
|
397
|
+
// without forcing spec authors to declare an explicit marker.
|
|
398
|
+
const sentinel = wrapper.split('{prompt}')[0].trim()
|
|
399
|
+
try {
|
|
400
|
+
if (existsSync(target)) {
|
|
401
|
+
const existing = readFileSync(target, 'utf-8')
|
|
402
|
+
if (sentinel && existing.includes(sentinel)) {
|
|
403
|
+
const closing = wrapper.split('{prompt}')[1]?.trim()
|
|
404
|
+
const safeOpen = sentinel.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
405
|
+
const safeClose = closing
|
|
406
|
+
? closing.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
407
|
+
: ''
|
|
408
|
+
const re = closing
|
|
409
|
+
? new RegExp(`${safeOpen}[\\s\\S]*?${safeClose}`, 'g')
|
|
410
|
+
: new RegExp(`${safeOpen}[\\s\\S]*$`, 'g')
|
|
411
|
+
writeFileSync(target, existing.replace(re, rendered), 'utf-8')
|
|
412
|
+
} else {
|
|
413
|
+
writeFileSync(target, `${existing}\n\n${rendered}`, 'utf-8')
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
writeFileSync(target, rendered, 'utf-8')
|
|
417
|
+
}
|
|
418
|
+
LOG.info('MeshCoordinator', `Wrote coordinator prompt to ${target} (${ctx.cliType})`)
|
|
419
|
+
return { contextFilePath: target }
|
|
420
|
+
} catch (error: any) {
|
|
421
|
+
LOG.warn('MeshCoordinator', `Could not write ${target}: ${error?.message || error}`)
|
|
422
|
+
return {}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
default:
|
|
426
|
+
// Unknown future mode — skip silently. Adding the new mode is a spec-
|
|
427
|
+
// language extension, not a runtime crash.
|
|
428
|
+
return {}
|
|
291
429
|
}
|
|
292
430
|
}
|
|
293
431
|
|
|
294
|
-
|
|
295
|
-
|
|
432
|
+
/**
|
|
433
|
+
* Strip the daemon's wrapper block from a context_file we previously wrote.
|
|
434
|
+
*
|
|
435
|
+
* Used in two places:
|
|
436
|
+
* 1. R48 inject-then-remove: ~5s after spawn, after agy/gemini have read
|
|
437
|
+
* the file into their in-memory system-prompt cache. Removing it from
|
|
438
|
+
* disk at that point doesn't affect the running coordinator but keeps
|
|
439
|
+
* worker sessions (or fresh non-coordinator launches) in the same
|
|
440
|
+
* workspace from picking up our wrapper.
|
|
441
|
+
* 2. R47 unregister fallback: if the timer never fires (process crash,
|
|
442
|
+
* kill -9), coordinator-registry.unregisterMeshCoordinator runs the
|
|
443
|
+
* same logic when its entry is dropped.
|
|
444
|
+
*
|
|
445
|
+
* Idempotent: missing file is fine, missing sentinels are fine, returns
|
|
446
|
+
* silently. Leaves user-authored content outside the sentinels intact.
|
|
447
|
+
* Deletes the file outright if our wrapper was the only content.
|
|
448
|
+
*/
|
|
449
|
+
export function stripCoordinatorWrapperFile(filePath: string): void {
|
|
450
|
+
const OPEN = '<!-- adhdev-mesh-coordinator-prompt -->'
|
|
451
|
+
const CLOSE = '<!-- /adhdev-mesh-coordinator-prompt -->'
|
|
296
452
|
try {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
453
|
+
if (!existsSync(filePath)) return
|
|
454
|
+
const existing = readFileSync(filePath, 'utf-8')
|
|
455
|
+
const openIdx = existing.indexOf(OPEN)
|
|
456
|
+
if (openIdx < 0) return
|
|
457
|
+
const closeIdx = existing.indexOf(CLOSE, openIdx)
|
|
458
|
+
if (closeIdx < 0) return
|
|
459
|
+
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length))
|
|
460
|
+
.replace(/^\s*\n+/, '')
|
|
461
|
+
.replace(/\n+\s*$/, '')
|
|
462
|
+
if (!remaining.trim()) {
|
|
463
|
+
try {
|
|
464
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
465
|
+
const fs = require('node:fs')
|
|
466
|
+
fs.unlinkSync(filePath)
|
|
467
|
+
} catch { /* best-effort */ }
|
|
468
|
+
} else {
|
|
469
|
+
writeFileSync(filePath, remaining + '\n', 'utf-8')
|
|
303
470
|
}
|
|
304
|
-
} catch {
|
|
305
|
-
// nvm is optional; PATH and process.execPath candidates still cover normal installs.
|
|
306
|
-
}
|
|
471
|
+
} catch { /* best-effort */ }
|
|
307
472
|
}
|
|
308
473
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const diff = (right[i] || 0) - (left[i] || 0)
|
|
315
|
-
if (diff !== 0) return diff
|
|
316
|
-
}
|
|
317
|
-
return b.localeCompare(a)
|
|
474
|
+
export interface PtyExecResult {
|
|
475
|
+
exitCode: number | null
|
|
476
|
+
signal: number | null
|
|
477
|
+
output: string
|
|
478
|
+
timedOut: boolean
|
|
318
479
|
}
|
|
319
480
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
})
|
|
326
|
-
return true
|
|
327
|
-
} catch {
|
|
328
|
-
return false
|
|
329
|
-
}
|
|
481
|
+
export interface MeshCoordinatorRegistrationStep {
|
|
482
|
+
command: string
|
|
483
|
+
args: string[]
|
|
484
|
+
required: boolean
|
|
485
|
+
label: 'remove_existing' | 'register'
|
|
330
486
|
}
|
|
331
487
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
// Resolve the sibling workspace build directly so Repo Mesh auto-import still
|
|
352
|
-
// writes an absolute Node entrypoint instead of falling back to a PATH bin shim.
|
|
353
|
-
addCandidate(resolve(dir, '../../mcp-server/dist/index.js'))
|
|
354
|
-
addCandidate(resolve(dir, '../../../mcp-server/dist/index.js'))
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
addPackagedCandidates(process.argv[1])
|
|
358
|
-
|
|
359
|
-
for (const candidate of candidates) {
|
|
360
|
-
const normalized = normalizeExistingPath(candidate)
|
|
361
|
-
if (normalized) return normalized
|
|
488
|
+
/**
|
|
489
|
+
* Codex rejects `mcp add` when a server with the same name already exists.
|
|
490
|
+
* Replace that entry before registering so transport/mesh changes do not leave
|
|
491
|
+
* a fresh coordinator attached to stale MCP launch arguments.
|
|
492
|
+
*/
|
|
493
|
+
export function buildMeshCoordinatorRegistrationPlan(
|
|
494
|
+
cliType: string,
|
|
495
|
+
serverName: string,
|
|
496
|
+
registrationCommand: string,
|
|
497
|
+
): MeshCoordinatorRegistrationStep[] {
|
|
498
|
+
const commandParts = registrationCommand.trim().split(/\s+/).filter(Boolean)
|
|
499
|
+
const [command, ...args] = commandParts
|
|
500
|
+
if (!command) return []
|
|
501
|
+
|
|
502
|
+
const register: MeshCoordinatorRegistrationStep = {
|
|
503
|
+
command,
|
|
504
|
+
args,
|
|
505
|
+
required: true,
|
|
506
|
+
label: 'register',
|
|
362
507
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
508
|
+
if (
|
|
509
|
+
cliType === 'codex-cli'
|
|
510
|
+
&& basename(command) === 'codex'
|
|
511
|
+
&& args[0] === 'mcp'
|
|
512
|
+
&& args[1] === 'add'
|
|
513
|
+
) {
|
|
514
|
+
return [
|
|
515
|
+
{
|
|
516
|
+
command,
|
|
517
|
+
args: ['mcp', 'remove', serverName],
|
|
518
|
+
required: false,
|
|
519
|
+
label: 'remove_existing',
|
|
520
|
+
},
|
|
521
|
+
register,
|
|
522
|
+
]
|
|
371
523
|
}
|
|
524
|
+
return [register]
|
|
372
525
|
}
|
|
373
526
|
|
|
374
|
-
|
|
527
|
+
/**
|
|
528
|
+
* Run a one-shot CLI command under a real PTY and collect its output.
|
|
529
|
+
*
|
|
530
|
+
* Some provider mcp-registration commands (`agy mcp add`, future bubbletea
|
|
531
|
+
* TUIs) refuse to run without `/dev/tty`. Daemon-side `execFileSync` runs
|
|
532
|
+
* pipe-only, so those commands fail with errors like
|
|
533
|
+
* `bubbletea: error opening TTY: open /dev/tty: device not configured`
|
|
534
|
+
* and silently skip the registration, leaving the launched session
|
|
535
|
+
* without the adhdev-mesh MCP tools — which is exactly what we saw with
|
|
536
|
+
* agy coordinators.
|
|
537
|
+
*
|
|
538
|
+
* Wrapping the registration through node-pty gives the child a real PTY,
|
|
539
|
+
* so the bubbletea check passes. We close stdin immediately and just
|
|
540
|
+
* collect stdout until the process exits or the timeout fires.
|
|
541
|
+
*/
|
|
542
|
+
export async function execUnderPty(
|
|
543
|
+
command: string,
|
|
544
|
+
args: string[],
|
|
545
|
+
options: { cwd?: string; env?: Record<string, string>; timeoutMs?: number } = {},
|
|
546
|
+
): Promise<PtyExecResult> {
|
|
547
|
+
let ptyLib: any
|
|
375
548
|
try {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
} catch {
|
|
379
|
-
|
|
549
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
550
|
+
ptyLib = require('node-pty')
|
|
551
|
+
} catch (error: any) {
|
|
552
|
+
throw new Error(`node-pty is not available: ${error?.message || error}`)
|
|
380
553
|
}
|
|
554
|
+
const env = { ...(options.env ?? (process.env as Record<string, string>)), TERM: 'xterm-256color' }
|
|
555
|
+
const timeoutMs = typeof options.timeoutMs === 'number' && options.timeoutMs > 0 ? options.timeoutMs : 20_000
|
|
556
|
+
return new Promise<PtyExecResult>((resolveResult) => {
|
|
557
|
+
let child: any
|
|
558
|
+
try {
|
|
559
|
+
child = ptyLib.spawn(command, args, {
|
|
560
|
+
name: 'xterm-256color',
|
|
561
|
+
cols: DEFAULT_SESSION_HOST_COLS,
|
|
562
|
+
rows: DEFAULT_SESSION_HOST_ROWS,
|
|
563
|
+
cwd: options.cwd ?? process.cwd(),
|
|
564
|
+
env,
|
|
565
|
+
})
|
|
566
|
+
} catch (error: any) {
|
|
567
|
+
resolveResult({ exitCode: null, signal: null, output: String(error?.message || error), timedOut: false })
|
|
568
|
+
return
|
|
569
|
+
}
|
|
570
|
+
let buffer = ''
|
|
571
|
+
let settled = false
|
|
572
|
+
const timer = setTimeout(() => {
|
|
573
|
+
if (settled) return
|
|
574
|
+
settled = true
|
|
575
|
+
try { child.kill() } catch { /* ignore */ }
|
|
576
|
+
resolveResult({ exitCode: null, signal: null, output: buffer, timedOut: true })
|
|
577
|
+
}, timeoutMs)
|
|
578
|
+
child.onData((chunk: string) => {
|
|
579
|
+
buffer += chunk
|
|
580
|
+
if (buffer.length > 256 * 1024) {
|
|
581
|
+
buffer = buffer.slice(-128 * 1024)
|
|
582
|
+
}
|
|
583
|
+
})
|
|
584
|
+
child.onExit(({ exitCode, signal }: { exitCode: number; signal?: number }) => {
|
|
585
|
+
if (settled) return
|
|
586
|
+
settled = true
|
|
587
|
+
clearTimeout(timer)
|
|
588
|
+
resolveResult({ exitCode, signal: signal ?? null, output: buffer, timedOut: false })
|
|
589
|
+
})
|
|
590
|
+
})
|
|
381
591
|
}
|