@adhdev/daemon-core 0.9.82-rc.46 → 0.9.82-rc.461
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 +25 -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-refine.d.ts +137 -0
- package/dist/commands/router-worktree-cleanup.d.ts +133 -0
- package/dist/commands/router.d.ts +241 -12
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +19 -0
- package/dist/config/mesh-config.d.ts +136 -1
- 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/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 +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 +67 -15
- package/dist/index.js +58583 -25541
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58207 -25332
- 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 +230 -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 +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 +7 -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 +155 -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 +29 -0
- 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 +133 -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 +310 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +158 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +80 -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 +493 -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 +318 -5
- package/dist/mesh/preview-freshness.d.ts +28 -0
- package/dist/mesh/refine-config.d.ts +216 -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 +45 -0
- package/dist/providers/chat-message-normalization.d.ts +58 -1
- package/dist/providers/cli-provider-instance.d.ts +290 -3
- package/dist/providers/contracts.d.ts +149 -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 +28 -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 +31 -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 +30 -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 +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 +598 -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 +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +86 -55
- 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 +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 +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/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2488 -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 +596 -27
- package/src/commands/handler.ts +845 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +680 -0
- package/src/commands/high-family/mesh-events.ts +89 -0
- package/src/commands/high-family/mesh-status.ts +832 -0
- package/src/commands/high-family/types.ts +80 -0
- package/src/commands/low-family/coordinator-prompt.ts +72 -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 +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 +241 -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 +1287 -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-refine.ts +1711 -0
- package/src/commands/router-worktree-cleanup.ts +870 -0
- package/src/commands/router.ts +1025 -4070
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +493 -24
- package/src/config/config.ts +30 -0
- package/src/config/mesh-config.ts +632 -23
- 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/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 +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 +200 -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/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 +469 -0
- package/src/mesh/coordinator-prompt.ts +554 -34
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +656 -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 +73 -0
- package/src/mesh/mesh-event-forwarding.ts +1950 -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 +1132 -0
- package/src/mesh/mesh-events-stale.ts +440 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +35 -1035
- package/src/mesh/mesh-fast-forward.ts +856 -0
- package/src/mesh/mesh-host-ownership.ts +111 -0
- package/src/mesh/mesh-init.ts +350 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +873 -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 +2065 -0
- package/src/mesh/mesh-queue-assignment.ts +2233 -0
- package/src/mesh/mesh-reconcile-loop.ts +2397 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1686 -0
- package/src/mesh/mesh-refine-status.ts +231 -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 +2056 -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 +1281 -141
- package/src/mesh/preview-freshness.ts +163 -0
- package/src/mesh/refine-config.ts +423 -0
- 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 +99 -5
- package/src/providers/chat-message-normalization.ts +126 -4
- package/src/providers/cli-provider-instance.ts +2456 -107
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +160 -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 +131 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +1193 -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 +503 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +260 -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 +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 +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 +509 -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 +1174 -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 +836 -13
- 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 +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +124 -55
- 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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — status/metadata + user-name commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Each handler
|
|
5
|
+
* reads only ctx.deps (+ process-global config/status builders) and returns the
|
|
6
|
+
* same CommandRouterResult the inlined case did. get_session_info aggregates the
|
|
7
|
+
* session/coordinator registries the router already holds via deps; none of these
|
|
8
|
+
* touch the router's inline-mesh cache or other instance state.
|
|
9
|
+
*/
|
|
10
|
+
import { loadConfig, updateConfig } from '../../config/config.js';
|
|
11
|
+
import { buildMachineInfo, buildStatusSnapshot } from '../../status/snapshot.js';
|
|
12
|
+
import { getDaemonBuildInfo } from '../../build-info.js';
|
|
13
|
+
import { getCoordinatorForSession } from '../../mesh/coordinator-registry.js';
|
|
14
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
15
|
+
|
|
16
|
+
export const statusMetaHandlers: Record<string, LowFamilyHandler> = {
|
|
17
|
+
set_user_name: async (_ctx: LowFamilyContext, args: any) => {
|
|
18
|
+
const name = args?.userName;
|
|
19
|
+
if (!name || typeof name !== 'string') throw new Error('userName required');
|
|
20
|
+
updateConfig({ userName: name });
|
|
21
|
+
return { success: true, userName: name };
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
get_status_metadata: async (ctx: LowFamilyContext, _args: any) => {
|
|
25
|
+
const snapshot = buildStatusSnapshot({
|
|
26
|
+
allStates: ctx.deps.instanceManager.collectAllStates(),
|
|
27
|
+
cdpManagers: ctx.deps.cdpManagers,
|
|
28
|
+
providerLoader: ctx.deps.providerLoader,
|
|
29
|
+
detectedIdes: ctx.deps.detectedIdes.value,
|
|
30
|
+
instanceId: ctx.deps.statusInstanceId || loadConfig().machineId || 'daemon',
|
|
31
|
+
version: ctx.deps.statusVersion || 'unknown',
|
|
32
|
+
profile: 'metadata',
|
|
33
|
+
});
|
|
34
|
+
// Surface the daemon's build stamp so coordinators (mesh_status)
|
|
35
|
+
// can detect a running daemon that predates a just-merged fix and
|
|
36
|
+
// is awaiting deploy/restart. Sibling of `status` to avoid
|
|
37
|
+
// perturbing the dashboard status snapshot shape.
|
|
38
|
+
return { success: true, status: snapshot, daemonBuild: getDaemonBuildInfo() };
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
get_machine_runtime_stats: async (_ctx: LowFamilyContext, _args: any) => {
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
machine: buildMachineInfo('full'),
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
// Session-info popup data. Aggregates whatever the daemon knows
|
|
50
|
+
// about a single live session into one envelope so the dashboard
|
|
51
|
+
// doesn't need to stitch together status + coordinator registry +
|
|
52
|
+
// session registry on the client. Includes the actual system
|
|
53
|
+
// prompt that was injected at launch when the session is a mesh
|
|
54
|
+
// coordinator — that's the "what prompt did the agent see?"
|
|
55
|
+
// question the info-icon dialog is meant to answer.
|
|
56
|
+
get_session_info: async (ctx: LowFamilyContext, args: any) => {
|
|
57
|
+
const sessionId = typeof args?.targetSessionId === 'string' ? args.targetSessionId.trim()
|
|
58
|
+
: typeof args?.sessionId === 'string' ? args.sessionId.trim() : '';
|
|
59
|
+
if (!sessionId) return { success: false, error: 'targetSessionId required' };
|
|
60
|
+
// Fetch both lookups up front. We used to bail with "Session not
|
|
61
|
+
// found" when sessionRegistry forgot the SID (auto-cleanup,
|
|
62
|
+
// daemon restart with the session not yet restored, etc), which
|
|
63
|
+
// hid the coordinator-side metadata even though the
|
|
64
|
+
// coordinator-registry still has it. Now we return whichever
|
|
65
|
+
// side we have. The dashboard renders "no coordinator-specific
|
|
66
|
+
// prompt" only when *neither* side knows the session.
|
|
67
|
+
const target = ctx.deps.sessionRegistry.get(sessionId);
|
|
68
|
+
const coord = getCoordinatorForSession(sessionId);
|
|
69
|
+
if (!target && !coord) return { success: false, error: 'Session not found', sessionId };
|
|
70
|
+
const adapter = target
|
|
71
|
+
? ctx.deps.cliManager.findAdapter(target.providerType, { instanceKey: sessionId })?.adapter
|
|
72
|
+
: undefined;
|
|
73
|
+
const runtimeMeta = (adapter && typeof (adapter as any).getRuntimeMetadata === 'function')
|
|
74
|
+
? (adapter as any).getRuntimeMetadata()
|
|
75
|
+
: undefined;
|
|
76
|
+
// Launch metadata (args / cwd / extra-env keys / providerSessionId) is
|
|
77
|
+
// derived from the live adapter's spawn plan; only available while the
|
|
78
|
+
// adapter is alive (resumed-from-history sessions report nothing here).
|
|
79
|
+
const launchInfo = (adapter && typeof (adapter as any).getLaunchInfo === 'function')
|
|
80
|
+
? (adapter as any).getLaunchInfo()
|
|
81
|
+
: undefined;
|
|
82
|
+
const providerType = target?.providerType || coord?.cliType || '';
|
|
83
|
+
const providerMetaForSession = providerType
|
|
84
|
+
? ctx.deps.providerLoader.resolve?.(providerType) || ctx.deps.providerLoader.getMeta(providerType)
|
|
85
|
+
: undefined;
|
|
86
|
+
return {
|
|
87
|
+
success: true,
|
|
88
|
+
session: {
|
|
89
|
+
sessionId,
|
|
90
|
+
providerType,
|
|
91
|
+
providerName: providerMetaForSession?.name,
|
|
92
|
+
transport: target?.transport,
|
|
93
|
+
workspace: (target as any)?.workspace || coord?.workspace,
|
|
94
|
+
spawnedAtMs: (target as any)?.spawnedAtMs || coord?.startedAt,
|
|
95
|
+
// providerSessionId now comes from the live adapter's launch info
|
|
96
|
+
// (the registry target never carried it — it was always undefined).
|
|
97
|
+
providerSessionId: launchInfo?.providerSessionId || (target as any)?.providerSessionId,
|
|
98
|
+
runtimeMetadata: runtimeMeta,
|
|
99
|
+
launch: launchInfo,
|
|
100
|
+
},
|
|
101
|
+
coordinator: coord ? {
|
|
102
|
+
meshId: coord.meshId,
|
|
103
|
+
startedAt: coord.startedAt,
|
|
104
|
+
cliType: coord.cliType,
|
|
105
|
+
systemPrompt: coord.systemPrompt,
|
|
106
|
+
extraSystemPrompt: coord.extraSystemPrompt,
|
|
107
|
+
injection: coord.injection,
|
|
108
|
+
mcpConfigPath: coord.mcpConfigPath,
|
|
109
|
+
} : null,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — shared types for the extracted low-coupling command
|
|
3
|
+
* handlers. Each handler is a pure function of (context, args): it reads only the
|
|
4
|
+
* router deps it needs and returns the exact CommandRouterResult the original
|
|
5
|
+
* `executeDaemonCommand` switch case returned, so the router facade is unchanged.
|
|
6
|
+
*
|
|
7
|
+
* Registry dispatch: DaemonCommandRouter.executeDaemonCommand looks up the cmd in
|
|
8
|
+
* lowFamilyRegistry BEFORE its switch; a hit returns the handler result, a miss
|
|
9
|
+
* falls through to the remaining switch (and ultimately CommandHandler delegation).
|
|
10
|
+
*/
|
|
11
|
+
import type { CommandRouterDeps, CommandRouterResult } from '../router.js';
|
|
12
|
+
|
|
13
|
+
/** Mesh record resolved from the router's inline-mesh cache + local config. */
|
|
14
|
+
export type ResolvedMeshForCommand = {
|
|
15
|
+
mesh: any;
|
|
16
|
+
inline: boolean;
|
|
17
|
+
source: 'inline_cache' | 'inline_bootstrap' | 'local_config';
|
|
18
|
+
} | null;
|
|
19
|
+
|
|
20
|
+
export interface LowFamilyContext {
|
|
21
|
+
deps: CommandRouterDeps;
|
|
22
|
+
/**
|
|
23
|
+
* Bound `DaemonCommandRouter.getMeshForCommand`. A handful of LOW handlers
|
|
24
|
+
* (mesh-node-logs) must resolve a mesh node's owning daemonId from the
|
|
25
|
+
* router's inline-mesh cache, which is router instance state not present in
|
|
26
|
+
* `deps`. The router injects it at dispatch; handlers that don't need it
|
|
27
|
+
* ignore it. Optional so unit tests can omit it (and assert the guarded
|
|
28
|
+
* fallback) without constructing a full router.
|
|
29
|
+
*/
|
|
30
|
+
getMeshForCommand?: (
|
|
31
|
+
meshId: string,
|
|
32
|
+
inlineMesh?: unknown,
|
|
33
|
+
options?: { preferInline?: boolean },
|
|
34
|
+
) => Promise<ResolvedMeshForCommand>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type LowFamilyHandler = (ctx: LowFamilyContext, args: any) => Promise<CommandRouterResult>;
|
|
38
|
+
|
|
39
|
+
export type LowFamilyRegistry = Map<string, LowFamilyHandler>;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER MED family — CLI/ACP agent + saved-session + restart commands.
|
|
3
|
+
*
|
|
4
|
+
* launch_cli, stop_cli / set_cli_view_mode / record_provider_pty, agent_command,
|
|
5
|
+
* list_saved_sessions and restart_session. launch_cli and agent_command stamp
|
|
6
|
+
* mesh-worker relay metadata and surface worktree-bootstrap-pending hints around a
|
|
7
|
+
* delegation to cliManager. restart_session dispatches IDE restarts (via ctx.stopIde
|
|
8
|
+
* + ctx.launchIde — no executeDaemonCommand recursion) or CLI/ACP restarts.
|
|
9
|
+
* Extracted verbatim from executeDaemonCommand.
|
|
10
|
+
*/
|
|
11
|
+
import { meshNodeIdMatches } from '@adhdev/mesh-shared';
|
|
12
|
+
import { supportsExplicitSessionResume } from '../cli-manager.js';
|
|
13
|
+
import { loadState } from '../../config/state-store.js';
|
|
14
|
+
import { getRecentActivity } from '../../config/recent-activity.js';
|
|
15
|
+
import { getSavedProviderSessions } from '../../config/saved-sessions.js';
|
|
16
|
+
import { listProviderHistorySessions } from '../../config/chat-history.js';
|
|
17
|
+
import { buildMeshWorkerRelayStamp } from '../../mesh/mesh-events-utils.js';
|
|
18
|
+
import { readStringValue } from '../router.js';
|
|
19
|
+
import type { MedFamilyContext, MedFamilyHandler } from './types.js';
|
|
20
|
+
|
|
21
|
+
export const cliAgentHandlers: Record<string, MedFamilyHandler> = {
|
|
22
|
+
launch_cli: async (ctx: MedFamilyContext, args: any) => {
|
|
23
|
+
// The coordinator routing anchor (meshCoordinatorDaemonId) is stamped
|
|
24
|
+
// upstream by mesh_launch_session, which resolves
|
|
25
|
+
// coordinatorNode.daemonId || ctx.localDaemonId || ctx.localMachineId and
|
|
26
|
+
// fail-closes for a remote node when none resolve. We deliberately do NOT
|
|
27
|
+
// self-stamp this daemon's own id when the field is missing: for a
|
|
28
|
+
// P2P-relayed remote worker launch, stamping the worker's own id would make
|
|
29
|
+
// the self-forward gate (mesh-events-coordinator: daemonIdsEquivalent) treat the
|
|
30
|
+
// worker as its own coordinator, suppressing the spontaneous completion-event
|
|
31
|
+
// forward and leaving the event in the pending inbox until a read_chat
|
|
32
|
+
// reconcile drains it. If the anchor is genuinely absent here, leave it
|
|
33
|
+
// absent rather than poison the routing.
|
|
34
|
+
const launchResult = await ctx.deps.cliManager.handleCliCommand('launch_cli', args);
|
|
35
|
+
// Bug C fix (part 1): when launching a mesh node worker session, surface
|
|
36
|
+
// bootstrapPending:true if the node's worktree bootstrap is still running.
|
|
37
|
+
// This is informational — the launch is NOT blocked here (blocking is done
|
|
38
|
+
// upstream by getWorktreeBootstrapLaunchBlock in the MCP layer).
|
|
39
|
+
const meshNodeId = readStringValue((args?.settings as any)?.meshNodeId);
|
|
40
|
+
const meshId = readStringValue((args?.settings as any)?.meshNodeFor);
|
|
41
|
+
if (meshNodeId && meshId && launchResult?.success !== false) {
|
|
42
|
+
try {
|
|
43
|
+
const { getMesh } = await import('../../config/mesh-config.js');
|
|
44
|
+
const meshObj = getMesh(meshId) ?? ctx.getCachedInlineMesh(meshId);
|
|
45
|
+
const nodeObj = Array.isArray(meshObj?.nodes)
|
|
46
|
+
? meshObj.nodes.find((n: any) => meshNodeIdMatches(n, meshNodeId))
|
|
47
|
+
: undefined;
|
|
48
|
+
const bootstrapStatus = readStringValue(nodeObj?.worktreeBootstrap?.status);
|
|
49
|
+
if (bootstrapStatus === 'running') {
|
|
50
|
+
return { success: true, ...launchResult, bootstrapPending: true };
|
|
51
|
+
}
|
|
52
|
+
} catch { /* best-effort — do not fail launch for bootstrap probe errors */ }
|
|
53
|
+
}
|
|
54
|
+
return launchResult;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
stop_cli: async (ctx: MedFamilyContext, args: any) => {
|
|
58
|
+
return ctx.deps.cliManager.handleCliCommand('stop_cli', args);
|
|
59
|
+
},
|
|
60
|
+
set_cli_view_mode: async (ctx: MedFamilyContext, args: any) => {
|
|
61
|
+
return ctx.deps.cliManager.handleCliCommand('set_cli_view_mode', args);
|
|
62
|
+
},
|
|
63
|
+
record_provider_pty: async (ctx: MedFamilyContext, args: any) => {
|
|
64
|
+
return ctx.deps.cliManager.handleCliCommand('record_provider_pty', args);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
agent_command: async (ctx: MedFamilyContext, args: any) => {
|
|
68
|
+
// Relay-safety stamp: a dispatch carrying meshContext.coordinatorDaemonId
|
|
69
|
+
// (mesh_send_task / queue assignment over P2P) is the worker daemon's chance
|
|
70
|
+
// to persist the coordinator routing anchor onto the target session BEFORE the
|
|
71
|
+
// turn runs. Without meshCoordinatorDaemonId on the session, the core forwarder
|
|
72
|
+
// (injectMeshSystemMessage) cannot resolve a remote coordinator target, so the
|
|
73
|
+
// completion event sits in the pending queue until a read_chat reconcile drains
|
|
74
|
+
// it. Stamping here makes a reused/relaunched remote session relay-safe at
|
|
75
|
+
// dispatch time even when it was not launched via mesh_launch_session.
|
|
76
|
+
{
|
|
77
|
+
const dispatchSessionId = readStringValue(args?.targetSessionId, (args as any)?.sessionId, (args as any)?.instanceId);
|
|
78
|
+
const dispatchMeshContext = args?.meshContext as Record<string, unknown> | undefined;
|
|
79
|
+
if (dispatchSessionId && dispatchMeshContext) {
|
|
80
|
+
try {
|
|
81
|
+
const inst = ctx.deps.instanceManager.getInstance(dispatchSessionId);
|
|
82
|
+
if (inst && typeof inst.updateSettings === 'function') {
|
|
83
|
+
const stamp = buildMeshWorkerRelayStamp(
|
|
84
|
+
inst.getState?.()?.settings as Record<string, unknown> | undefined,
|
|
85
|
+
{
|
|
86
|
+
meshId: dispatchMeshContext.meshId,
|
|
87
|
+
nodeId: dispatchMeshContext.nodeId,
|
|
88
|
+
coordinatorDaemonId: dispatchMeshContext.coordinatorDaemonId,
|
|
89
|
+
// Session-level anchor: preserved across the P2P dispatch to a
|
|
90
|
+
// remote worker so its completion echoes back to the right session.
|
|
91
|
+
coordinatorSessionId: dispatchMeshContext.coordinatorSessionId,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
if (stamp) inst.updateSettings(stamp);
|
|
95
|
+
}
|
|
96
|
+
} catch { /* best-effort — dispatch still proceeds without the stamp */ }
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Bug C fix / bootstrapPending dispatch gap: a task dispatched to a mesh node
|
|
100
|
+
// whose worktree bootstrap is STILL running must NOT be injected yet. Before this
|
|
101
|
+
// gate the dispatch proceeded and the prompt landed in the session's input buffer
|
|
102
|
+
// while the provider (e.g. claude CLI) was not yet ready to consume it — the inject
|
|
103
|
+
// was silently swallowed (the chat bubble showed the text but the session never
|
|
104
|
+
// transitioned to generating and never claimed the task). The prior code only
|
|
105
|
+
// ANNOTATED the already-completed dispatch with 'bootstrap_still_running' after the
|
|
106
|
+
// fact, which did not close the gap. Defer instead: refuse the inject with a
|
|
107
|
+
// recoverable signal so the coordinator re-sends once the node is ready (the
|
|
108
|
+
// confirmed "re-send to a ready session works" path), mirroring the queued-delivery
|
|
109
|
+
// contract for busy sessions. send_chat only — non-task actions still pass through.
|
|
110
|
+
const meshCtx = args?.meshContext as Record<string, unknown> | undefined;
|
|
111
|
+
const dispatchNodeId = readStringValue(meshCtx?.nodeId);
|
|
112
|
+
const dispatchMeshId = readStringValue(meshCtx?.meshId);
|
|
113
|
+
const isSendChat = args?.action === 'send_chat';
|
|
114
|
+
if (isSendChat && dispatchNodeId && dispatchMeshId) {
|
|
115
|
+
try {
|
|
116
|
+
const { getMesh } = await import('../../config/mesh-config.js');
|
|
117
|
+
// COMPLETION-PROPAGATION F6 (C1 SSOT): read the router's synchronous inline mesh
|
|
118
|
+
// cache FIRST, falling back to getMesh only when the inline view has nothing. The
|
|
119
|
+
// inline cache is the authoritative bootstrap-status source — markWorktreeBootstrapTerminalState
|
|
120
|
+
// stamps 'complete'/'failed' into it SYNCHRONOUSLY, then persists to local config
|
|
121
|
+
// (what getMesh reads) via a DETACHED async import chain that lags. Reading getMesh
|
|
122
|
+
// first therefore observed a stale 'running' and deferred a dispatch whose worktree
|
|
123
|
+
// was already bootstrapped — the stale-'running' defer this eliminates. Inline-first
|
|
124
|
+
// makes the freshest single source of truth win for both the running and terminal states.
|
|
125
|
+
const meshObj = ctx.getCachedInlineMesh(dispatchMeshId) ?? getMesh(dispatchMeshId);
|
|
126
|
+
const nodeObj = Array.isArray(meshObj?.nodes)
|
|
127
|
+
? meshObj.nodes.find((n: any) => meshNodeIdMatches(n, dispatchNodeId))
|
|
128
|
+
: undefined;
|
|
129
|
+
// COMPLETION-PROPAGATION F7 (C2): the single shared consume-ready/bootstrap-pending
|
|
130
|
+
// defer predicate (honors the stale-'running' git-clean backstop internally), reused
|
|
131
|
+
// by the local queue-claim gate too so remote and local dispatch agree on when to defer.
|
|
132
|
+
const { shouldDeferDispatchForBootstrap } = await import('../../mesh/worktree-bootstrap-config.js');
|
|
133
|
+
if (shouldDeferDispatchForBootstrap(nodeObj as any)) {
|
|
134
|
+
return {
|
|
135
|
+
success: false,
|
|
136
|
+
recoverable: true,
|
|
137
|
+
dispatched: false,
|
|
138
|
+
code: 'mesh_node_bootstrap_pending',
|
|
139
|
+
reason: 'bootstrap_still_running',
|
|
140
|
+
nodeId: dispatchNodeId,
|
|
141
|
+
meshId: dispatchMeshId,
|
|
142
|
+
...(readStringValue(meshCtx?.taskId) ? { taskId: readStringValue(meshCtx?.taskId) } : {}),
|
|
143
|
+
error: `Node '${dispatchNodeId}' worktree bootstrap is still running; a task injected now would land in the session input buffer before the provider is ready to consume it and be silently lost. Dispatch deferred.`,
|
|
144
|
+
nextAction: 'Wait for the worktree_bootstrap_complete event (or poll mesh_status until the node session is ready), then re-send the task with mesh_send_task. Alternatively use mesh_enqueue_task so the queue auto-assigns it once a ready session is available.',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
} catch { /* best-effort — if the bootstrap probe fails, fall through and dispatch */ }
|
|
148
|
+
}
|
|
149
|
+
return ctx.deps.cliManager.handleCliCommand('agent_command', args);
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
// ─── Logs ───
|
|
153
|
+
list_saved_sessions: async (ctx: MedFamilyContext, args: any) => {
|
|
154
|
+
const providerType = typeof args?.providerType === 'string'
|
|
155
|
+
? args.providerType.trim()
|
|
156
|
+
: typeof args?.agentType === 'string'
|
|
157
|
+
? args.agentType.trim()
|
|
158
|
+
: '';
|
|
159
|
+
const kind = args?.kind === 'acp' ? 'acp' : 'cli';
|
|
160
|
+
if (!providerType) {
|
|
161
|
+
return { success: false, error: 'providerType required' };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const wantsAll = args?.all === true;
|
|
165
|
+
const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
|
|
166
|
+
const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
|
|
167
|
+
const requestedWorkspace = typeof args?.workspace === 'string' ? args.workspace.trim() : '';
|
|
168
|
+
const requestedProviderSessionId = typeof args?.providerSessionId === 'string'
|
|
169
|
+
? args.providerSessionId.trim()
|
|
170
|
+
: typeof args?.activeProviderSessionId === 'string'
|
|
171
|
+
? args.activeProviderSessionId.trim()
|
|
172
|
+
: '';
|
|
173
|
+
const providerMeta = ctx.deps.providerLoader.resolve?.(providerType) || ctx.deps.providerLoader.getMeta(providerType);
|
|
174
|
+
const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
|
|
175
|
+
canonicalHistory: providerMeta?.nativeHistory,
|
|
176
|
+
offset,
|
|
177
|
+
limit,
|
|
178
|
+
historyBehavior: providerMeta?.historyBehavior,
|
|
179
|
+
scripts: providerMeta?.scripts as any,
|
|
180
|
+
});
|
|
181
|
+
const state = loadState();
|
|
182
|
+
const savedSessions = getSavedProviderSessions(state, { providerType, kind });
|
|
183
|
+
const recentSessions = getRecentActivity(state, 200)
|
|
184
|
+
.filter(entry => entry.providerType === providerType && entry.kind === kind && entry.providerSessionId);
|
|
185
|
+
const savedSessionById = new Map(savedSessions.map(entry => [entry.providerSessionId, entry]));
|
|
186
|
+
const recentSessionById = new Map(recentSessions.map(entry => [entry.providerSessionId!, entry]));
|
|
187
|
+
const canResumeById = supportsExplicitSessionResume(providerMeta?.resume);
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
success: true,
|
|
191
|
+
sessions: historySessions.map(session => {
|
|
192
|
+
const saved = savedSessionById.get(session.historySessionId);
|
|
193
|
+
const recent = recentSessionById.get(session.historySessionId);
|
|
194
|
+
const workspace = saved?.workspace
|
|
195
|
+
|| recent?.workspace
|
|
196
|
+
|| session.workspace
|
|
197
|
+
|| (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : undefined);
|
|
198
|
+
return {
|
|
199
|
+
id: session.historySessionId,
|
|
200
|
+
providerSessionId: session.historySessionId,
|
|
201
|
+
providerType,
|
|
202
|
+
providerName: saved?.providerName || recent?.providerName || providerType,
|
|
203
|
+
kind: saved?.kind || recent?.kind || kind,
|
|
204
|
+
title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
|
|
205
|
+
workspace,
|
|
206
|
+
summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
|
|
207
|
+
preview: session.preview,
|
|
208
|
+
messageCount: session.messageCount,
|
|
209
|
+
firstMessageAt: session.firstMessageAt,
|
|
210
|
+
lastMessageAt: session.lastMessageAt,
|
|
211
|
+
canResume: !!workspace && canResumeById,
|
|
212
|
+
historySource: session.source,
|
|
213
|
+
sourcePath: session.sourcePath,
|
|
214
|
+
sourceMtimeMs: session.sourceMtimeMs,
|
|
215
|
+
};
|
|
216
|
+
}),
|
|
217
|
+
hasMore,
|
|
218
|
+
source,
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
// ─── restart_session: IDE / CLI / ACP unified ───
|
|
223
|
+
restart_session: async (ctx: MedFamilyContext, args: any) => {
|
|
224
|
+
const targetType = args?.cliType || args?.agentType || args?.ideType;
|
|
225
|
+
if (!targetType) throw new Error('cliType or ideType required');
|
|
226
|
+
|
|
227
|
+
// Check if IDE (in cdpManagers or provider category is ide)
|
|
228
|
+
const isIde = ctx.deps.cdpManagers.has(targetType) ||
|
|
229
|
+
ctx.deps.providerLoader.getMeta(targetType)?.category === 'ide';
|
|
230
|
+
|
|
231
|
+
if (isIde) {
|
|
232
|
+
// IDE restart: stop (with process kill) → launch
|
|
233
|
+
await ctx.stopIde(targetType, true);
|
|
234
|
+
const launchResult = await ctx.launchIde({ ideType: targetType, enableCdp: true, workspace: args?.workspace });
|
|
235
|
+
return { success: true, restarted: true, ideType: targetType, launch: launchResult };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// CLI/ACP restart: delegate to CliManager
|
|
239
|
+
return ctx.deps.cliManager.handleCliCommand('restart_session', args);
|
|
240
|
+
},
|
|
241
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER MED family — fast-forward / refine convergence commands.
|
|
3
|
+
*
|
|
4
|
+
* mesh_init, plan_mesh_refine_node, fast_forward_mesh_node, refine_mesh_node and
|
|
5
|
+
* batch_refine_mesh_nodes. These resolve the target node, forward to the owning
|
|
6
|
+
* daemon when the node is remote, and run (or plan) the fast-forward / refine
|
|
7
|
+
* convergence. Extracted verbatim from executeDaemonCommand; the async execute
|
|
8
|
+
* paths delegate back to the router's refine-job starters via ctx.
|
|
9
|
+
*/
|
|
10
|
+
import { daemonIdsEquivalent, meshNodeIdMatches } from '@adhdev/mesh-shared';
|
|
11
|
+
import { fastForwardMeshNode } from '../../mesh/mesh-fast-forward.js';
|
|
12
|
+
import { runMeshInit } from '../../mesh/mesh-init.js';
|
|
13
|
+
import { detectCLIs } from '../../detection/cli-detector.js';
|
|
14
|
+
import { buildMeshRefineValidationPlan } from '../router.js';
|
|
15
|
+
import type { CommandRouterResult } from '../router.js';
|
|
16
|
+
import type { MedFamilyContext, MedFamilyHandler } from './types.js';
|
|
17
|
+
|
|
18
|
+
export const fastForwardHandlers: Record<string, MedFamilyHandler> = {
|
|
19
|
+
mesh_init: async (ctx: MedFamilyContext, args: any) => {
|
|
20
|
+
const workspace = typeof args?.workspace === 'string' && args.workspace.trim() ? args.workspace.trim() : process.cwd();
|
|
21
|
+
const mesh = args?.inlineMesh || {};
|
|
22
|
+
try {
|
|
23
|
+
const detected = await detectCLIs(ctx.deps.providerLoader, { includeVersion: true });
|
|
24
|
+
return { ...runMeshInit(mesh, workspace, detected, {
|
|
25
|
+
write: args?.write === true,
|
|
26
|
+
overwrite: args?.overwrite === true,
|
|
27
|
+
}) };
|
|
28
|
+
} catch (e: any) {
|
|
29
|
+
return { success: false, error: e?.message || String(e) };
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
plan_mesh_refine_node: async (ctx: MedFamilyContext, args: any) => {
|
|
34
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
35
|
+
const nodeId = typeof args?.nodeId === 'string' ? args.nodeId.trim() : '';
|
|
36
|
+
if (!meshId || !nodeId) return { success: false, error: 'meshId and nodeId required' };
|
|
37
|
+
// preferInline: plan is the dry-run sibling of refine — clone nodes must resolve.
|
|
38
|
+
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
39
|
+
const mesh = meshRecord?.mesh;
|
|
40
|
+
const node = mesh?.nodes?.find((n: any) => meshNodeIdMatches(n, nodeId));
|
|
41
|
+
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
dryRun: true,
|
|
45
|
+
nodeId,
|
|
46
|
+
workspace: node.workspace,
|
|
47
|
+
validationPlan: buildMeshRefineValidationPlan(mesh, node.workspace),
|
|
48
|
+
mergeWillRun: false,
|
|
49
|
+
cleanupWillRun: false,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
fast_forward_mesh_node: async (ctx: MedFamilyContext, args: any) => {
|
|
54
|
+
// The whole handler is wrapped: the safety-gate evaluation (mesh resolution,
|
|
55
|
+
// git status/stash/submodule fan-out) can throw on some platforms — notably a
|
|
56
|
+
// win32 daemon whose git invocation parsing or slow submodule probe raises
|
|
57
|
+
// before fastForwardMeshNode's own guarded body runs. router.execute re-throws,
|
|
58
|
+
// so an escaping throw surfaces to the coordinator as an opaque
|
|
59
|
+
// "Daemon IPC command failed" instead of the structured blockingReasons result
|
|
60
|
+
// a mac node returns cleanly. Catch it and return the same blocked shape so the
|
|
61
|
+
// coordinator can read the reason and route, never an IPC crash. Mirrors the
|
|
62
|
+
// mesh_init handler's try-catch contract.
|
|
63
|
+
const workspaceForError = typeof args?.workspace === 'string' ? args.workspace.trim() : '';
|
|
64
|
+
const meshIdForError = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
65
|
+
const nodeIdForError = typeof args?.nodeId === 'string' ? args.nodeId.trim() : '';
|
|
66
|
+
try {
|
|
67
|
+
const meshId = meshIdForError;
|
|
68
|
+
const nodeId = nodeIdForError;
|
|
69
|
+
let workspace = workspaceForError;
|
|
70
|
+
let submoduleIgnorePaths = Array.isArray(args?.submoduleIgnorePaths)
|
|
71
|
+
? args.submoduleIgnorePaths.filter((value: unknown): value is string => typeof value === 'string')
|
|
72
|
+
: undefined;
|
|
73
|
+
let nodeDaemonId: string | undefined;
|
|
74
|
+
let allowAutoPublishSubmoduleMainCommits = false;
|
|
75
|
+
if (meshId && nodeId) {
|
|
76
|
+
// preferInline so fast-forward can resolve inline-cache-only clone worktree nodes.
|
|
77
|
+
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
78
|
+
const mesh = meshRecord?.mesh;
|
|
79
|
+
const node = mesh?.nodes?.find((n: any) => meshNodeIdMatches(n, nodeId));
|
|
80
|
+
if (!workspace) {
|
|
81
|
+
workspace = typeof node?.workspace === 'string' ? node.workspace.trim() : '';
|
|
82
|
+
}
|
|
83
|
+
if (!submoduleIgnorePaths && Array.isArray(node?.policy?.submoduleIgnorePaths)) {
|
|
84
|
+
submoduleIgnorePaths = node.policy.submoduleIgnorePaths.filter((value: unknown): value is string => typeof value === 'string');
|
|
85
|
+
}
|
|
86
|
+
allowAutoPublishSubmoduleMainCommits = mesh?.policy?.allowAutoPublishSubmoduleMainCommits === true;
|
|
87
|
+
nodeDaemonId = typeof node?.daemonId === 'string' ? node.daemonId.trim() : undefined;
|
|
88
|
+
}
|
|
89
|
+
// If the target node belongs to a remote daemon, forward the command there.
|
|
90
|
+
// _meshDirectDispatch prevents re-forwarding (and P2P self-dial) when the stored
|
|
91
|
+
// daemonId uses a legacy format that doesn't match the receiving daemon's identity.
|
|
92
|
+
const selfDaemonId = ctx.deps.statusInstanceId;
|
|
93
|
+
// daemonIdsEquivalent: a legacy-form stored daemonId that resolves to THIS
|
|
94
|
+
// machine's core must be treated as local (not remote) so it is not forwarded /
|
|
95
|
+
// P2P self-dialed. Equivalent → local.
|
|
96
|
+
const isRemote = nodeDaemonId && selfDaemonId && !daemonIdsEquivalent(nodeDaemonId, selfDaemonId);
|
|
97
|
+
if (isRemote && ctx.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
|
|
98
|
+
const forwarded = await ctx.deps.dispatchMeshCommand(nodeDaemonId!, 'fast_forward_mesh_node', {
|
|
99
|
+
...(typeof args === 'object' && args !== null ? args as Record<string, unknown> : {}),
|
|
100
|
+
workspace,
|
|
101
|
+
_meshDirectDispatch: true,
|
|
102
|
+
});
|
|
103
|
+
return (forwarded ?? { success: false, error: 'no response from remote node' }) as CommandRouterResult;
|
|
104
|
+
}
|
|
105
|
+
const result = await (fastForwardMeshNode({
|
|
106
|
+
meshId: meshId || undefined,
|
|
107
|
+
nodeId: nodeId || undefined,
|
|
108
|
+
workspace,
|
|
109
|
+
branch: typeof args?.branch === 'string' ? args.branch : undefined,
|
|
110
|
+
execute: args?.execute === true,
|
|
111
|
+
dryRun: args?.dryRun === true,
|
|
112
|
+
updateSubmodules: args?.updateSubmodules === true,
|
|
113
|
+
submoduleIgnorePaths,
|
|
114
|
+
mode: args?.mode === 'push' ? 'push' : 'merge',
|
|
115
|
+
pushSubmodules: args?.pushSubmodules === true,
|
|
116
|
+
allowAutoPublishSubmoduleMainCommits,
|
|
117
|
+
}) as Promise<unknown>);
|
|
118
|
+
return result as CommandRouterResult;
|
|
119
|
+
} catch (e: any) {
|
|
120
|
+
const errorMessage = e?.message || String(e);
|
|
121
|
+
return {
|
|
122
|
+
success: false,
|
|
123
|
+
code: 'fast_forward_safety_gate_error',
|
|
124
|
+
...(meshIdForError ? { meshId: meshIdForError } : {}),
|
|
125
|
+
...(nodeIdForError ? { nodeId: nodeIdForError } : {}),
|
|
126
|
+
workspace: workspaceForError,
|
|
127
|
+
mode: args?.mode === 'push' ? 'push' : 'merge',
|
|
128
|
+
allowed: false,
|
|
129
|
+
willRun: false,
|
|
130
|
+
executed: false,
|
|
131
|
+
// Surface the throw as a blocking reason instead of an opaque IPC crash
|
|
132
|
+
// so the coordinator gets the same structured shape a clean node returns.
|
|
133
|
+
blockingReasons: ['fast_forward_safety_gate_error'],
|
|
134
|
+
operationError: errorMessage,
|
|
135
|
+
error: errorMessage,
|
|
136
|
+
} as CommandRouterResult;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
refine_mesh_node: async (ctx: MedFamilyContext, args: any) => {
|
|
141
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
142
|
+
const nodeId = typeof args?.nodeId === 'string' ? args.nodeId.trim() : '';
|
|
143
|
+
if (!meshId || !nodeId) return { success: false, error: 'meshId and nodeId required' };
|
|
144
|
+
|
|
145
|
+
// Remote forward: a worktree node lives on its OWN daemon's machine, so the
|
|
146
|
+
// refine (cd into node.workspace, merge → push → cleanup) must run on THAT
|
|
147
|
+
// daemon — not the coordinator, whose filesystem has no such path. The sibling
|
|
148
|
+
// fast_forward_mesh_node / clone_mesh_node handlers already forward to the
|
|
149
|
+
// node's daemon; refine_mesh_node was the gap (the coordinator would cd into a
|
|
150
|
+
// non-existent local path and fail), so remote-machine worktrees could not be
|
|
151
|
+
// converged at all. Forward both dry-run (plan reads the worktree git state)
|
|
152
|
+
// and execute (async merge job) so the same machine that owns the worktree
|
|
153
|
+
// resolves it.
|
|
154
|
+
//
|
|
155
|
+
// coordinatorDaemonId: refine is ASYNC — the completed/failed event is queued
|
|
156
|
+
// on the executing daemon's pending-events queue scoped to a coordinator id and
|
|
157
|
+
// recovered by the coordinator's reconcile loop (pullRemoteNodeQueues →
|
|
158
|
+
// get_pending_mesh_events). Without stamping our own status id, the remote
|
|
159
|
+
// daemon would fall back to ITS OWN statusInstanceId as the coordinator
|
|
160
|
+
// (startMeshRefineJob), scoping the terminal event to the wrong inbox where the
|
|
161
|
+
// real coordinator never pulls it. Stamp the canonical status id (which is in
|
|
162
|
+
// the coordinator's self-identity set used to scope the remote drain) so the
|
|
163
|
+
// event routes back here. Preserve any caller-supplied coordinatorDaemonId.
|
|
164
|
+
//
|
|
165
|
+
// _meshDirectDispatch prevents re-forwarding (and P2P self-dial) once the call
|
|
166
|
+
// has landed on the owning daemon — that daemon then executes locally even if
|
|
167
|
+
// the stored daemonId uses a legacy form that doesn't match its own identity.
|
|
168
|
+
{
|
|
169
|
+
const meshRecordForForward = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
170
|
+
const forwardNode = meshRecordForForward?.mesh?.nodes?.find((n: any) => meshNodeIdMatches(n, nodeId));
|
|
171
|
+
const nodeDaemonId = typeof forwardNode?.daemonId === 'string' ? forwardNode.daemonId.trim() : undefined;
|
|
172
|
+
const selfDaemonId = ctx.deps.statusInstanceId;
|
|
173
|
+
// daemonIdsEquivalent: a legacy-form daemonId resolving to this machine's core
|
|
174
|
+
// is local — execute locally instead of forwarding. Equivalent → local.
|
|
175
|
+
const isRemote = nodeDaemonId && selfDaemonId && !daemonIdsEquivalent(nodeDaemonId, selfDaemonId);
|
|
176
|
+
if (isRemote && ctx.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
|
|
177
|
+
const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === 'string' && args.coordinatorDaemonId.trim()
|
|
178
|
+
? args.coordinatorDaemonId.trim()
|
|
179
|
+
: undefined;
|
|
180
|
+
const forwarded = await ctx.deps.dispatchMeshCommand(nodeDaemonId!, 'refine_mesh_node', {
|
|
181
|
+
...(typeof args === 'object' && args !== null ? args as Record<string, unknown> : {}),
|
|
182
|
+
coordinatorDaemonId: callerCoordinatorDaemonId || selfDaemonId,
|
|
183
|
+
_meshDirectDispatch: true,
|
|
184
|
+
});
|
|
185
|
+
return (forwarded ?? { success: false, error: 'no response from remote node' }) as CommandRouterResult;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Dry-run (plan-only) is the default and stays synchronous: it does no
|
|
190
|
+
// validation/merge/push and returns the plan instantly. Only execute=true
|
|
191
|
+
// (and not dry_run) goes through the async refine job that actually
|
|
192
|
+
// validates → merges → pushes → cleans up. Mirrors the
|
|
193
|
+
// batch_refine_mesh_nodes / fast_forward_mesh_node dry_run/execute contract.
|
|
194
|
+
const isDryRun = args?.dryRun !== false && args?.execute !== true;
|
|
195
|
+
if (isDryRun) {
|
|
196
|
+
// preferInline: plan is the dry-run sibling of refine — clone nodes must resolve.
|
|
197
|
+
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
198
|
+
const mesh = meshRecord?.mesh;
|
|
199
|
+
const node = mesh?.nodes?.find((n: any) => meshNodeIdMatches(n, nodeId));
|
|
200
|
+
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
201
|
+
return {
|
|
202
|
+
success: true,
|
|
203
|
+
dryRun: true,
|
|
204
|
+
nodeId,
|
|
205
|
+
workspace: node.workspace,
|
|
206
|
+
validationPlan: buildMeshRefineValidationPlan(mesh, node.workspace),
|
|
207
|
+
mergeWillRun: false,
|
|
208
|
+
cleanupWillRun: false,
|
|
209
|
+
hint: 'Dry-run only — no merge/push/cleanup performed. Re-invoke with execute:true to converge this node.',
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
return ctx.startMeshRefineJob(meshId, nodeId, args);
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
batch_refine_mesh_nodes: async (ctx: MedFamilyContext, args: any) => {
|
|
216
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
217
|
+
if (!meshId) return { success: false, error: 'meshId required' };
|
|
218
|
+
const requestedNodeIds = Array.isArray(args?.nodeIds)
|
|
219
|
+
? (args.nodeIds as unknown[]).filter((v): v is string => typeof v === 'string' && v.trim().length > 0).map(v => v.trim())
|
|
220
|
+
: undefined;
|
|
221
|
+
// Dry-run (plan-only) stays synchronous: it does no validation/merge and
|
|
222
|
+
// returns instantly. Execute goes through the async batch job — immediate
|
|
223
|
+
// {async:true, status:'accepted'} + background convergence + terminal event,
|
|
224
|
+
// matching the single-node refine_mesh_node contract so long validation
|
|
225
|
+
// suites can't time out the IPC and strand the coordinator.
|
|
226
|
+
const isDryRun = args?.dryRun !== false && args?.execute !== true;
|
|
227
|
+
if (isDryRun) return ctx.batchRefineMeshNodes(meshId, requestedNodeIds, args);
|
|
228
|
+
return ctx.startMeshRefineBatchJob(meshId, requestedNodeIds, args);
|
|
229
|
+
},
|
|
230
|
+
};
|