@adhdev/daemon-core 0.9.82-rc.49 → 0.9.82-rc.490
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boot/daemon-lifecycle.d.ts +9 -0
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/build-info.d.ts +37 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +68 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +220 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +137 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
- package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +69 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
- package/dist/commands/chat-commands-read.d.ts +23 -0
- package/dist/commands/chat-commands-scope.d.ts +39 -0
- package/dist/commands/chat-commands-shared.d.ts +33 -0
- package/dist/commands/chat-commands-write.d.ts +14 -0
- package/dist/commands/chat-commands.d.ts +10 -23
- package/dist/commands/cli-manager.d.ts +71 -1
- package/dist/commands/handler.d.ts +125 -0
- package/dist/commands/high-family/index.d.ts +3 -0
- package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
- package/dist/commands/high-family/mesh-events.d.ts +2 -0
- package/dist/commands/high-family/mesh-status.d.ts +2 -0
- package/dist/commands/high-family/types.d.ts +64 -0
- package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
- package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
- package/dist/commands/low-family/diagnostics.d.ts +2 -0
- package/dist/commands/low-family/index.d.ts +3 -0
- package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
- package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
- package/dist/commands/low-family/notification.d.ts +2 -0
- package/dist/commands/low-family/refine-config.d.ts +2 -0
- package/dist/commands/low-family/session-host.d.ts +2 -0
- package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
- package/dist/commands/low-family/status-meta.d.ts +2 -0
- package/dist/commands/low-family/types.d.ts +33 -0
- package/dist/commands/med-family/cli-agent.d.ts +2 -0
- package/dist/commands/med-family/fast-forward.d.ts +2 -0
- package/dist/commands/med-family/ide.d.ts +10 -0
- package/dist/commands/med-family/index.d.ts +3 -0
- package/dist/commands/med-family/mesh-crud.d.ts +48 -0
- package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
- package/dist/commands/med-family/mesh-queue.d.ts +2 -0
- package/dist/commands/med-family/mesh-restart.d.ts +2 -0
- package/dist/commands/med-family/types.d.ts +152 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router-aggregate-status.d.ts +24 -0
- package/dist/commands/router-mesh-session-owner.d.ts +59 -0
- package/dist/commands/router-refine.d.ts +151 -0
- package/dist/commands/router-worktree-cleanup.d.ts +133 -0
- package/dist/commands/router.d.ts +203 -15
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +11 -0
- package/dist/config/config.d.ts +19 -0
- package/dist/config/mesh-config.d.ts +65 -0
- package/dist/config/mesh-json-config.d.ts +199 -0
- package/dist/config/registry-resolver.d.ts +54 -0
- package/dist/config/repo-settings.d.ts +77 -0
- package/dist/config/state-store.d.ts +30 -0
- package/dist/daemon/dev-server.d.ts +0 -2
- package/dist/detection/cli-detector.d.ts +17 -0
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/change-impact-config.d.ts +159 -0
- package/dist/git/git-commands.d.ts +26 -2
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +80 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/git-worktree.d.ts +71 -1
- package/dist/git/index.d.ts +3 -1
- package/dist/index.d.ts +70 -17
- package/dist/index.js +53532 -19073
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53283 -18989
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/logging/debug-config.d.ts +16 -0
- package/dist/logging/log-redactor.d.ts +24 -0
- package/dist/logging/log-tail-reader.d.ts +81 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/mesh/contracts.d.ts +256 -0
- package/dist/mesh/coordinator-prompt.d.ts +76 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +203 -0
- package/dist/mesh/mesh-clone-grace.d.ts +8 -0
- package/dist/mesh/mesh-completion-synthesis.d.ts +4 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +104 -0
- package/dist/mesh/mesh-event-classify.d.ts +7 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +58 -0
- package/dist/mesh/mesh-event-trace.d.ts +21 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
- package/dist/mesh/mesh-events-pending.d.ts +258 -0
- package/dist/mesh/mesh-events-stale.d.ts +61 -0
- package/dist/mesh/mesh-events-utils.d.ts +75 -0
- package/dist/mesh/mesh-events.d.ts +6 -49
- package/dist/mesh/mesh-fast-forward.d.ts +81 -0
- package/dist/mesh/mesh-host-ownership.d.ts +21 -1
- package/dist/mesh/mesh-init.d.ts +128 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
- package/dist/mesh/mesh-ledger.d.ts +139 -1
- package/dist/mesh/mesh-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +281 -0
- package/dist/mesh/mesh-node-identity.d.ts +310 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +162 -0
- package/dist/mesh/mesh-reconcile-acked-hold.d.ts +17 -0
- package/dist/mesh/mesh-reconcile-config.d.ts +6 -0
- package/dist/mesh/mesh-reconcile-identity.d.ts +6 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +84 -0
- package/dist/mesh/mesh-reconcile-v2-backstop.d.ts +16 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +457 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-remote-event-pull.d.ts +15 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +567 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/mesh/mesh-task-inflight.d.ts +46 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +34 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +392 -1
- package/dist/mesh/preview-freshness.d.ts +28 -0
- package/dist/mesh/refine-config.d.ts +97 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +219 -0
- package/dist/providers/acp-provider-instance.d.ts +5 -0
- package/dist/providers/approval-utils.d.ts +46 -0
- package/dist/providers/chat-message-normalization.d.ts +58 -1
- package/dist/providers/cli-provider-effect-format.d.ts +30 -0
- package/dist/providers/cli-provider-history-dedup.d.ts +17 -0
- package/dist/providers/cli-provider-input-prompt.d.ts +12 -0
- package/dist/providers/cli-provider-instance-types.d.ts +45 -0
- package/dist/providers/cli-provider-instance.d.ts +426 -30
- package/dist/providers/cli-provider-status-helpers.d.ts +46 -0
- package/dist/providers/cli-provider-transcript-merge.d.ts +7 -0
- package/dist/providers/contracts.d.ts +196 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/manual-attendance.d.ts +79 -0
- package/dist/providers/native-history/antigravity-claim-registry.d.ts +39 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +137 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/constants.d.ts +12 -0
- package/dist/providers/native-history/dispatcher.d.ts +44 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +30 -0
- package/dist/providers/provider-instance.d.ts +31 -1
- package/dist/providers/provider-loader.d.ts +42 -5
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/spec/adapter.d.ts +98 -0
- package/dist/providers/spec/cli-adapter.d.ts +223 -0
- package/dist/providers/spec/evaluator.d.ts +45 -0
- package/dist/providers/spec/fsm-driver.d.ts +449 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +93 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +202 -0
- package/dist/providers/spec/native-history-executor.d.ts +41 -0
- package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/types.d.ts +244 -0
- package/dist/providers/status-monitor.d.ts +7 -7
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +84 -0
- package/dist/providers/working-dir.d.ts +17 -0
- package/dist/repo-mesh-types.d.ts +616 -12
- package/dist/runtime-defaults.d.ts +2 -0
- package/dist/session-host/managed-host.d.ts +64 -0
- package/dist/session-host/runtime-surface.d.ts +10 -16
- package/dist/sessions/registry.d.ts +26 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +110 -55
- package/dist/status/chat-tail-hot-sessions.d.ts +40 -0
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +27 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +20 -6
- package/package.json +11 -4
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +80 -14
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +3 -1
- package/src/cli-adapter-types.ts +68 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1282 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +1048 -1143
- package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
- package/src/cli-adapters/provider-cli-parse.ts +19 -0
- package/src/cli-adapters/provider-cli-runtime.ts +56 -7
- package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
- package/src/cli-adapters/provider-cli-shared.ts +121 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/pty-write-chunking.ts +106 -0
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +204 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
- package/src/cli-adapters/terminal-backends/types.ts +10 -3
- package/src/cli-adapters/terminal-screen.ts +16 -81
- package/src/commands/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2788 -0
- package/src/commands/chat-commands-scope.ts +54 -0
- package/src/commands/chat-commands-shared.ts +114 -0
- package/src/commands/chat-commands-write.ts +891 -0
- package/src/commands/chat-commands.ts +19 -1841
- package/src/commands/cli-manager.d.ts +2 -0
- package/src/commands/cli-manager.ts +724 -27
- package/src/commands/handler.ts +865 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +696 -0
- package/src/commands/high-family/mesh-events.ts +102 -0
- package/src/commands/high-family/mesh-status.ts +857 -0
- package/src/commands/high-family/types.ts +80 -0
- package/src/commands/low-family/coordinator-prompt.ts +125 -0
- package/src/commands/low-family/daemon-lifecycle.ts +120 -0
- package/src/commands/low-family/diagnostics.ts +57 -0
- package/src/commands/low-family/index.ts +37 -0
- package/src/commands/low-family/mesh-ledger.ts +62 -0
- package/src/commands/low-family/mesh-node-logs.ts +87 -0
- package/src/commands/low-family/notification.ts +116 -0
- package/src/commands/low-family/refine-config.ts +106 -0
- package/src/commands/low-family/session-host.ts +282 -0
- package/src/commands/low-family/spec-providerdev.ts +217 -0
- package/src/commands/low-family/status-meta.ts +112 -0
- package/src/commands/low-family/types.ts +39 -0
- package/src/commands/med-family/cli-agent.ts +270 -0
- package/src/commands/med-family/fast-forward.ts +230 -0
- package/src/commands/med-family/ide.ts +163 -0
- package/src/commands/med-family/index.ts +37 -0
- package/src/commands/med-family/mesh-crud.ts +1268 -0
- package/src/commands/med-family/mesh-host-pairing.ts +234 -0
- package/src/commands/med-family/mesh-queue.ts +167 -0
- package/src/commands/med-family/mesh-restart.ts +92 -0
- package/src/commands/med-family/types.ts +153 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router-aggregate-status.ts +209 -0
- package/src/commands/router-mesh-session-owner.ts +114 -0
- package/src/commands/router-refine.ts +1794 -0
- package/src/commands/router-worktree-cleanup.ts +870 -0
- package/src/commands/router.ts +567 -4149
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +517 -24
- package/src/config/config.ts +30 -0
- package/src/config/mesh-config.ts +300 -24
- package/src/config/mesh-json-config.ts +376 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/config/registry-resolver.ts +100 -0
- package/src/config/repo-settings.ts +111 -0
- package/src/config/state-store.ts +55 -0
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/daemon/dev-server.ts +0 -541
- package/src/detection/cli-detector.ts +94 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +112 -16
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +822 -48
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +261 -4
- package/src/git/index.ts +17 -0
- package/src/index.ts +190 -13
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/command-log.ts +7 -5
- package/src/logging/debug-config.ts +25 -0
- package/src/logging/debug-trace.ts +7 -2
- package/src/logging/log-redactor.ts +100 -0
- package/src/logging/log-tail-reader.ts +341 -0
- package/src/logging/logger.ts +14 -7
- package/src/mesh/contracts.ts +510 -0
- package/src/mesh/coordinator-prompt.ts +627 -34
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +706 -0
- package/src/mesh/mesh-clone-grace.ts +68 -0
- package/src/mesh/mesh-completion-synthesis.ts +416 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +284 -0
- package/src/mesh/mesh-event-classify.ts +78 -0
- package/src/mesh/mesh-event-forwarding.ts +2030 -0
- package/src/mesh/mesh-event-trace.ts +67 -0
- package/src/mesh/mesh-events-coordinator.ts +32 -0
- package/src/mesh/mesh-events-pending.ts +1548 -0
- package/src/mesh/mesh-events-stale.ts +452 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +43 -1035
- package/src/mesh/mesh-fast-forward.ts +856 -0
- package/src/mesh/mesh-host-ownership.ts +41 -3
- package/src/mesh/mesh-init.ts +350 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +897 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +695 -0
- package/src/mesh/mesh-node-identity.ts +2065 -0
- package/src/mesh/mesh-queue-assignment.ts +2498 -0
- package/src/mesh/mesh-reconcile-acked-hold.ts +230 -0
- package/src/mesh/mesh-reconcile-config.ts +66 -0
- package/src/mesh/mesh-reconcile-identity.ts +103 -0
- package/src/mesh/mesh-reconcile-loop.ts +1696 -0
- package/src/mesh/mesh-reconcile-v2-backstop.ts +62 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1792 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-remote-event-pull.ts +279 -0
- package/src/mesh/mesh-review-inbox.ts +308 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +2292 -0
- package/src/mesh/mesh-scheduling-runtime.ts +198 -0
- package/src/mesh/mesh-task-inflight.ts +70 -0
- package/src/mesh/mesh-task-stats.ts +161 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +215 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1489 -145
- package/src/mesh/preview-freshness.ts +163 -0
- package/src/mesh/refine-config.ts +129 -12
- package/src/mesh/worktree-bootstrap-config.ts +599 -0
- package/src/providers/acp-provider-instance.ts +43 -10
- package/src/providers/approval-utils.d.ts +5 -0
- package/src/providers/approval-utils.ts +100 -6
- package/src/providers/chat-message-normalization.ts +126 -4
- package/src/providers/cli-provider-effect-format.ts +53 -0
- package/src/providers/cli-provider-history-dedup.ts +75 -0
- package/src/providers/cli-provider-input-prompt.ts +133 -0
- package/src/providers/cli-provider-instance-types.ts +131 -0
- package/src/providers/cli-provider-instance.ts +2771 -499
- package/src/providers/cli-provider-status-helpers.ts +123 -0
- package/src/providers/cli-provider-transcript-merge.ts +114 -0
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +207 -6
- package/src/providers/extension-provider-instance.ts +12 -7
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +35 -12
- package/src/providers/manual-attendance.ts +105 -0
- package/src/providers/native-history/antigravity-claim-registry.ts +138 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +1275 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +479 -0
- package/src/providers/native-history/constants.ts +19 -0
- package/src/providers/native-history/dispatcher.ts +617 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +312 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +71 -0
- package/src/providers/provider-instance.ts +24 -1
- package/src/providers/provider-loader.ts +700 -55
- package/src/providers/provider-schema.ts +93 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +261 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +538 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +246 -0
- package/src/providers/spec/cli-adapter.ts +1064 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1528 -0
- package/src/providers/spec/fsm-evaluator.ts +290 -0
- package/src/providers/spec/fsm-loader.ts +128 -0
- package/src/providers/spec/fsm-types.ts +301 -0
- package/src/providers/spec/native-history-executor.ts +1241 -0
- package/src/providers/spec/pre-launch-trust.ts +104 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/types.ts +284 -0
- package/src/providers/status-monitor.d.ts +7 -7
- package/src/providers/status-monitor.ts +37 -22
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +536 -0
- package/src/providers/version-archive.ts +64 -24
- package/src/providers/working-dir.ts +23 -0
- package/src/repo-mesh-types.ts +861 -14
- package/src/runtime-defaults.ts +39 -0
- package/src/session-host/managed-host.ts +218 -0
- package/src/session-host/runtime-surface.ts +20 -80
- package/src/sessions/registry.ts +44 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +148 -55
- package/src/status/builders.ts +69 -6
- package/src/status/chat-tail-hot-sessions.ts +117 -2
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +100 -27
- package/src/system/hash.ts +23 -0
- package/src/system/host-memory.ts +29 -12
- package/src/system/load-better-sqlite3.ts +68 -0
- package/src/types.ts +26 -6
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — provider-dev / spec debug commands.
|
|
3
|
+
*
|
|
4
|
+
* Powers the dev console's spec editor: read/write a session's spec.json, validate
|
|
5
|
+
* an in-progress spec, and preview condition/section resolution against a live
|
|
6
|
+
* session's screen. Extracted verbatim from executeDaemonCommand; reads only
|
|
7
|
+
* ctx.deps.sessionRegistry + ctx.deps.cliManager. resolveSpecPathInProviders (a
|
|
8
|
+
* `this`-free module helper) is relocated here unchanged.
|
|
9
|
+
*/
|
|
10
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
11
|
+
|
|
12
|
+
function resolveSpecPathInProviders(
|
|
13
|
+
specPath: string,
|
|
14
|
+
fsm: typeof import('node:fs'),
|
|
15
|
+
pathm: typeof import('node:path'),
|
|
16
|
+
osm: typeof import('node:os'),
|
|
17
|
+
): { ok: true; path: string } | { ok: false; error: string } {
|
|
18
|
+
let rootReal: string;
|
|
19
|
+
try {
|
|
20
|
+
rootReal = fsm.realpathSync(pathm.join(osm.homedir(), '.adhdev', 'providers'));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return { ok: false, error: `providers root unavailable: ${(e as Error).message}` };
|
|
23
|
+
}
|
|
24
|
+
const resolved = pathm.resolve(specPath);
|
|
25
|
+
const base = pathm.basename(resolved);
|
|
26
|
+
if (!/^[\w.-]+\.json$/.test(base)) {
|
|
27
|
+
return { ok: false, error: 'refused: spec file must be a *.json basename' };
|
|
28
|
+
}
|
|
29
|
+
let parentReal: string;
|
|
30
|
+
try {
|
|
31
|
+
parentReal = fsm.realpathSync(pathm.dirname(resolved));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return { ok: false, error: `spec directory not found: ${(e as Error).message}` };
|
|
34
|
+
}
|
|
35
|
+
if (parentReal !== rootReal && !parentReal.startsWith(rootReal + pathm.sep)) {
|
|
36
|
+
return { ok: false, error: 'refused: spec path must be under the providers root' };
|
|
37
|
+
}
|
|
38
|
+
const safe = pathm.join(parentReal, base);
|
|
39
|
+
// Reject if the final file itself is a symlink pointing elsewhere.
|
|
40
|
+
try {
|
|
41
|
+
const st = fsm.lstatSync(safe);
|
|
42
|
+
if (st.isSymbolicLink()) return { ok: false, error: 'refused: spec path is a symlink' };
|
|
43
|
+
} catch { /* file may not exist yet (write case) — fine */ }
|
|
44
|
+
return { ok: true, path: safe };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const specProviderDevHandlers: Record<string, LowFamilyHandler> = {
|
|
48
|
+
get_spec_debug: async (ctx: LowFamilyContext, args: any) => {
|
|
49
|
+
const sessionId = typeof args?.targetSessionId === 'string' ? args.targetSessionId.trim()
|
|
50
|
+
: typeof args?.sessionId === 'string' ? args.sessionId.trim() : '';
|
|
51
|
+
if (!sessionId) return { success: false, error: 'targetSessionId required' };
|
|
52
|
+
const target = ctx.deps.sessionRegistry.get(sessionId);
|
|
53
|
+
if (!target) return { success: false, error: 'Session not found', sessionId };
|
|
54
|
+
const adapterObj = ctx.deps.cliManager.findAdapter(target.providerType, { instanceKey: sessionId })?.adapter;
|
|
55
|
+
const snapshot = adapterObj
|
|
56
|
+
? (typeof (adapterObj as any).getDebugSnapshot === 'function'
|
|
57
|
+
? (adapterObj as any).getDebugSnapshot()
|
|
58
|
+
: typeof (adapterObj as any).getDebugState === 'function'
|
|
59
|
+
? (adapterObj as any).getDebugState()
|
|
60
|
+
: null)
|
|
61
|
+
: null;
|
|
62
|
+
return {
|
|
63
|
+
success: true,
|
|
64
|
+
sessionId,
|
|
65
|
+
providerType: target.providerType,
|
|
66
|
+
isSpecProvider: snapshot !== null,
|
|
67
|
+
snapshot,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
// ── Spec source read/write for the debug panel's live editor.
|
|
72
|
+
// Lets the dashboard load a session's spec.json, edit it, and save it back —
|
|
73
|
+
// the driver's fs.watch picks up the change and hot-reloads the FSM with no
|
|
74
|
+
// restart. Writes are confined to files under ~/.adhdev/providers.
|
|
75
|
+
get_spec_source: async (ctx: LowFamilyContext, args: any) => {
|
|
76
|
+
const fsm = await import('node:fs');
|
|
77
|
+
const pathm = await import('node:path');
|
|
78
|
+
const osm = await import('node:os');
|
|
79
|
+
const sessionId = typeof args?.targetSessionId === 'string' ? args.targetSessionId.trim()
|
|
80
|
+
: typeof args?.sessionId === 'string' ? args.sessionId.trim() : '';
|
|
81
|
+
let specPath = typeof args?.specPath === 'string' ? args.specPath : '';
|
|
82
|
+
if (!specPath && sessionId) {
|
|
83
|
+
const target = ctx.deps.sessionRegistry.get(sessionId);
|
|
84
|
+
const adapterObj = target ? ctx.deps.cliManager.findAdapter(target.providerType, { instanceKey: sessionId })?.adapter : null;
|
|
85
|
+
const snap = adapterObj && typeof (adapterObj as any).getDebugSnapshot === 'function' ? (adapterObj as any).getDebugSnapshot() : null;
|
|
86
|
+
specPath = snap?.specPath ?? '';
|
|
87
|
+
}
|
|
88
|
+
if (!specPath) return { success: false, error: 'specPath or resolvable targetSessionId required' };
|
|
89
|
+
// Confine reads to the providers tree, resolving symlinks so a crafted path
|
|
90
|
+
// can't escape via a symlinked spec file.
|
|
91
|
+
const safe = resolveSpecPathInProviders(specPath, fsm, pathm, osm);
|
|
92
|
+
if (!safe.ok) return { success: false, error: safe.error, specPath };
|
|
93
|
+
try {
|
|
94
|
+
const content = fsm.readFileSync(safe.path, 'utf8');
|
|
95
|
+
return { success: true, specPath: safe.path, content };
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return { success: false, error: `read failed: ${(e as Error).message}`, specPath };
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
write_spec_source: async (_ctx: LowFamilyContext, args: any) => {
|
|
102
|
+
const fsm = await import('node:fs');
|
|
103
|
+
const pathm = await import('node:path');
|
|
104
|
+
const osm = await import('node:os');
|
|
105
|
+
const specPath = typeof args?.specPath === 'string' ? args.specPath : '';
|
|
106
|
+
const content = typeof args?.content === 'string' ? args.content : '';
|
|
107
|
+
if (!specPath) return { success: false, error: 'specPath required' };
|
|
108
|
+
if (!content) return { success: false, error: 'content required' };
|
|
109
|
+
// Confine writes to the providers tree (symlink-safe — see helper).
|
|
110
|
+
const safe = resolveSpecPathInProviders(specPath, fsm, pathm, osm);
|
|
111
|
+
if (!safe.ok) return { success: false, error: safe.error };
|
|
112
|
+
// Validate JSON + (if v4) FSM structure before writing so a bad edit can't
|
|
113
|
+
// break the live session — return precise errors.
|
|
114
|
+
let parsed: unknown;
|
|
115
|
+
try { parsed = JSON.parse(content); }
|
|
116
|
+
catch (e) { return { success: false, error: `invalid JSON: ${(e as Error).message}` }; }
|
|
117
|
+
if ((parsed as any)?.$schema === 'adhdev:cli/spec@4') {
|
|
118
|
+
const { validateFsmSpec } = await import('../../providers/spec/fsm-loader.js');
|
|
119
|
+
const errs = validateFsmSpec(parsed);
|
|
120
|
+
if (errs.length) return { success: false, error: 'spec invalid', validationErrors: errs };
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
fsm.writeFileSync(safe.path, content, 'utf8');
|
|
124
|
+
return { success: true, specPath: safe.path };
|
|
125
|
+
} catch (e) {
|
|
126
|
+
return { success: false, error: `write failed: ${(e as Error).message}` };
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
// ── Validate an in-progress spec (string or object) without writing. The form
|
|
131
|
+
// builder calls this on every change so Save can stay disabled while there
|
|
132
|
+
// are structural / reference / regex errors.
|
|
133
|
+
validate_spec: async (_ctx: LowFamilyContext, args: any) => {
|
|
134
|
+
let parsed: unknown = args?.spec;
|
|
135
|
+
if (typeof args?.content === 'string') {
|
|
136
|
+
try { parsed = JSON.parse(args.content); }
|
|
137
|
+
catch (e) { return { success: true, valid: false, errors: [`invalid JSON: ${(e as Error).message}`] }; }
|
|
138
|
+
}
|
|
139
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
140
|
+
return { success: true, valid: false, errors: ['spec must be an object or content string'] };
|
|
141
|
+
}
|
|
142
|
+
const schema = (parsed as any).$schema;
|
|
143
|
+
if (schema === 'adhdev:cli/spec@4') {
|
|
144
|
+
const { validateFsmSpec } = await import('../../providers/spec/fsm-loader.js');
|
|
145
|
+
const errors = validateFsmSpec(parsed);
|
|
146
|
+
return { success: true, valid: errors.length === 0, errors };
|
|
147
|
+
}
|
|
148
|
+
// v1/v3 left to the legacy loader path; the builder is v4-only.
|
|
149
|
+
return { success: true, valid: false, errors: [`unsupported $schema "${schema}" — form builder is v4-only`] };
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
// ── Evaluate a single condition against a live session's current screen —
|
|
153
|
+
// powers the editor's "does this match right now?" preview. Returns the
|
|
154
|
+
// recursive match tree.
|
|
155
|
+
eval_condition_preview: async (ctx: LowFamilyContext, args: any) => {
|
|
156
|
+
const sessionId = typeof args?.targetSessionId === 'string' ? args.targetSessionId.trim()
|
|
157
|
+
: typeof args?.sessionId === 'string' ? args.sessionId.trim() : '';
|
|
158
|
+
if (!sessionId) return { success: false, error: 'targetSessionId required' };
|
|
159
|
+
if (!args?.condition || typeof args.condition !== 'object') return { success: false, error: 'condition required' };
|
|
160
|
+
const target = ctx.deps.sessionRegistry.get(sessionId);
|
|
161
|
+
if (!target) return { success: false, error: 'Session not found', sessionId };
|
|
162
|
+
const adapterObj = ctx.deps.cliManager.findAdapter(target.providerType, { instanceKey: sessionId })?.adapter as any;
|
|
163
|
+
const snap = adapterObj && typeof adapterObj.getDebugSnapshot === 'function' ? adapterObj.getDebugSnapshot() : null;
|
|
164
|
+
if (!snap?.screen) return { success: false, error: 'no live screen for session' };
|
|
165
|
+
// Reconstruct the sections map the spec would resolve. We pass the spec's
|
|
166
|
+
// sections so section-scoped regexes resolve the same way they do at
|
|
167
|
+
// runtime; fall back to the on-disk spec.
|
|
168
|
+
let sectionsDef: Record<string, unknown> | undefined;
|
|
169
|
+
try {
|
|
170
|
+
const fsm2 = await import('node:fs');
|
|
171
|
+
if (snap.specPath) {
|
|
172
|
+
const raw = JSON.parse(fsm2.readFileSync(snap.specPath, 'utf8'));
|
|
173
|
+
sectionsDef = raw?.sections;
|
|
174
|
+
}
|
|
175
|
+
} catch { /* fall back to whole-screen matching */ }
|
|
176
|
+
const { evaluateConditionPreview } = await import('../../providers/spec/fsm-evaluator.js');
|
|
177
|
+
try {
|
|
178
|
+
const result = evaluateConditionPreview(
|
|
179
|
+
args.condition,
|
|
180
|
+
sectionsDef as any,
|
|
181
|
+
snap.screen,
|
|
182
|
+
snap.cursorPosition ?? undefined,
|
|
183
|
+
);
|
|
184
|
+
return { success: true, result, sections: snap.sections ?? null };
|
|
185
|
+
} catch (e) {
|
|
186
|
+
return { success: false, error: `eval failed: ${(e as Error).message}` };
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
// ── Resolve a sections map against a live session's screen — the section
|
|
191
|
+
// editor's "test" button. Returns, for each section id, the line range + the
|
|
192
|
+
// text it captures. Accepts an in-progress sections map so it previews
|
|
193
|
+
// unsaved edits.
|
|
194
|
+
resolve_section_preview: async (ctx: LowFamilyContext, args: any) => {
|
|
195
|
+
const sessionId = typeof args?.targetSessionId === 'string' ? args.targetSessionId.trim()
|
|
196
|
+
: typeof args?.sessionId === 'string' ? args.sessionId.trim() : '';
|
|
197
|
+
if (!sessionId) return { success: false, error: 'targetSessionId required' };
|
|
198
|
+
if (!args?.sections || typeof args.sections !== 'object') return { success: false, error: 'sections map required' };
|
|
199
|
+
const target = ctx.deps.sessionRegistry.get(sessionId);
|
|
200
|
+
if (!target) return { success: false, error: 'Session not found', sessionId };
|
|
201
|
+
const adapterObj = ctx.deps.cliManager.findAdapter(target.providerType, { instanceKey: sessionId })?.adapter as any;
|
|
202
|
+
const snap = adapterObj && typeof adapterObj.getDebugSnapshot === 'function' ? adapterObj.getDebugSnapshot() : null;
|
|
203
|
+
if (!snap?.screen) return { success: false, error: 'no live screen for session' };
|
|
204
|
+
const { resolveSections } = await import('../../providers/spec/evaluator.js');
|
|
205
|
+
try {
|
|
206
|
+
const lines = String(snap.screen).split('\n').map((l: string) => l.endsWith('\r') ? l.slice(0, -1) : l);
|
|
207
|
+
const resolved = resolveSections(args.sections as any, lines);
|
|
208
|
+
return {
|
|
209
|
+
success: true,
|
|
210
|
+
screenLineCount: lines.length,
|
|
211
|
+
sections: resolved.map(s => ({ id: s.id, fromLine: s.fromLine, toLine: s.toLine, text: s.text })),
|
|
212
|
+
};
|
|
213
|
+
} catch (e) {
|
|
214
|
+
return { success: false, error: `resolve failed: ${(e as Error).message}` };
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
};
|
|
@@ -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,270 @@
|
|
|
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
|
+
// Daemon-owned per-session user Mute/Hide. Replaces the old browser-local
|
|
68
|
+
// localStorage layer: the user's manual hide/mute for a conversation is stored
|
|
69
|
+
// in-memory on the live session's settings (userHidden / userMuted) and rides
|
|
70
|
+
// the SAME status snapshot pipeline as the coordinator-policy surfaceHidden
|
|
71
|
+
// flag, so every client of this daemon sees the same state. In-memory only —
|
|
72
|
+
// resets on daemon restart (coordinator-spawned sessions re-derive their hidden
|
|
73
|
+
// default from mesh policy on relaunch). Passing null/undefined for a field
|
|
74
|
+
// leaves it unchanged; pass an explicit boolean to set, or false to clear an
|
|
75
|
+
// earlier hide/mute (e.g. unmute a coordinator-spawned worker overrides the
|
|
76
|
+
// policy default until restart).
|
|
77
|
+
set_conversation_prefs: async (ctx: MedFamilyContext, args: any) => {
|
|
78
|
+
const sessionId = readStringValue(args?.sessionId, (args as any)?.targetSessionId, (args as any)?.instanceId);
|
|
79
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
80
|
+
const inst = ctx.deps.instanceManager.getInstance(sessionId);
|
|
81
|
+
if (!inst || typeof inst.updateSettings !== 'function') {
|
|
82
|
+
return { success: false, error: 'Session not found or does not support preferences' };
|
|
83
|
+
}
|
|
84
|
+
const patch: Record<string, unknown> = {};
|
|
85
|
+
if (typeof args?.hidden === 'boolean') patch.userHidden = args.hidden;
|
|
86
|
+
if (typeof args?.muted === 'boolean') patch.userMuted = args.muted;
|
|
87
|
+
if (!Object.keys(patch).length) return { success: false, error: 'Nothing to update (hidden and/or muted required)' };
|
|
88
|
+
inst.updateSettings(patch);
|
|
89
|
+
// Push a fresh status snapshot so all clients see the updated
|
|
90
|
+
// surfaceHidden/muted immediately (cloud path). The standalone server has a
|
|
91
|
+
// parallel broadcast gate keyed on the command name (see daemon-standalone).
|
|
92
|
+
ctx.deps.onStatusChange?.();
|
|
93
|
+
return { success: true, sessionId, ...patch };
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
agent_command: async (ctx: MedFamilyContext, args: any) => {
|
|
97
|
+
// Relay-safety stamp: a dispatch carrying meshContext.coordinatorDaemonId
|
|
98
|
+
// (mesh_send_task / queue assignment over P2P) is the worker daemon's chance
|
|
99
|
+
// to persist the coordinator routing anchor onto the target session BEFORE the
|
|
100
|
+
// turn runs. Without meshCoordinatorDaemonId on the session, the core forwarder
|
|
101
|
+
// (injectMeshSystemMessage) cannot resolve a remote coordinator target, so the
|
|
102
|
+
// completion event sits in the pending queue until a read_chat reconcile drains
|
|
103
|
+
// it. Stamping here makes a reused/relaunched remote session relay-safe at
|
|
104
|
+
// dispatch time even when it was not launched via mesh_launch_session.
|
|
105
|
+
{
|
|
106
|
+
const dispatchSessionId = readStringValue(args?.targetSessionId, (args as any)?.sessionId, (args as any)?.instanceId);
|
|
107
|
+
const dispatchMeshContext = args?.meshContext as Record<string, unknown> | undefined;
|
|
108
|
+
if (dispatchSessionId && dispatchMeshContext) {
|
|
109
|
+
try {
|
|
110
|
+
const inst = ctx.deps.instanceManager.getInstance(dispatchSessionId);
|
|
111
|
+
if (inst && typeof inst.updateSettings === 'function') {
|
|
112
|
+
const stamp = buildMeshWorkerRelayStamp(
|
|
113
|
+
inst.getState?.()?.settings as Record<string, unknown> | undefined,
|
|
114
|
+
{
|
|
115
|
+
meshId: dispatchMeshContext.meshId,
|
|
116
|
+
nodeId: dispatchMeshContext.nodeId,
|
|
117
|
+
coordinatorDaemonId: dispatchMeshContext.coordinatorDaemonId,
|
|
118
|
+
// Session-level anchor: preserved across the P2P dispatch to a
|
|
119
|
+
// remote worker so its completion echoes back to the right session.
|
|
120
|
+
coordinatorSessionId: dispatchMeshContext.coordinatorSessionId,
|
|
121
|
+
},
|
|
122
|
+
);
|
|
123
|
+
if (stamp) inst.updateSettings(stamp);
|
|
124
|
+
}
|
|
125
|
+
} catch { /* best-effort — dispatch still proceeds without the stamp */ }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Bug C fix / bootstrapPending dispatch gap: a task dispatched to a mesh node
|
|
129
|
+
// whose worktree bootstrap is STILL running must NOT be injected yet. Before this
|
|
130
|
+
// gate the dispatch proceeded and the prompt landed in the session's input buffer
|
|
131
|
+
// while the provider (e.g. claude CLI) was not yet ready to consume it — the inject
|
|
132
|
+
// was silently swallowed (the chat bubble showed the text but the session never
|
|
133
|
+
// transitioned to generating and never claimed the task). The prior code only
|
|
134
|
+
// ANNOTATED the already-completed dispatch with 'bootstrap_still_running' after the
|
|
135
|
+
// fact, which did not close the gap. Defer instead: refuse the inject with a
|
|
136
|
+
// recoverable signal so the coordinator re-sends once the node is ready (the
|
|
137
|
+
// confirmed "re-send to a ready session works" path), mirroring the queued-delivery
|
|
138
|
+
// contract for busy sessions. send_chat only — non-task actions still pass through.
|
|
139
|
+
const meshCtx = args?.meshContext as Record<string, unknown> | undefined;
|
|
140
|
+
const dispatchNodeId = readStringValue(meshCtx?.nodeId);
|
|
141
|
+
const dispatchMeshId = readStringValue(meshCtx?.meshId);
|
|
142
|
+
const isSendChat = args?.action === 'send_chat';
|
|
143
|
+
if (isSendChat && dispatchNodeId && dispatchMeshId) {
|
|
144
|
+
try {
|
|
145
|
+
const { getMesh } = await import('../../config/mesh-config.js');
|
|
146
|
+
// COMPLETION-PROPAGATION F6 (C1 SSOT): read the router's synchronous inline mesh
|
|
147
|
+
// cache FIRST, falling back to getMesh only when the inline view has nothing. The
|
|
148
|
+
// inline cache is the authoritative bootstrap-status source — markWorktreeBootstrapTerminalState
|
|
149
|
+
// stamps 'complete'/'failed' into it SYNCHRONOUSLY, then persists to local config
|
|
150
|
+
// (what getMesh reads) via a DETACHED async import chain that lags. Reading getMesh
|
|
151
|
+
// first therefore observed a stale 'running' and deferred a dispatch whose worktree
|
|
152
|
+
// was already bootstrapped — the stale-'running' defer this eliminates. Inline-first
|
|
153
|
+
// makes the freshest single source of truth win for both the running and terminal states.
|
|
154
|
+
const meshObj = ctx.getCachedInlineMesh(dispatchMeshId) ?? getMesh(dispatchMeshId);
|
|
155
|
+
const nodeObj = Array.isArray(meshObj?.nodes)
|
|
156
|
+
? meshObj.nodes.find((n: any) => meshNodeIdMatches(n, dispatchNodeId))
|
|
157
|
+
: undefined;
|
|
158
|
+
// COMPLETION-PROPAGATION F7 (C2): the single shared consume-ready/bootstrap-pending
|
|
159
|
+
// defer predicate (honors the stale-'running' git-clean backstop internally), reused
|
|
160
|
+
// by the local queue-claim gate too so remote and local dispatch agree on when to defer.
|
|
161
|
+
const { shouldDeferDispatchForBootstrap } = await import('../../mesh/worktree-bootstrap-config.js');
|
|
162
|
+
if (shouldDeferDispatchForBootstrap(nodeObj as any)) {
|
|
163
|
+
return {
|
|
164
|
+
success: false,
|
|
165
|
+
recoverable: true,
|
|
166
|
+
dispatched: false,
|
|
167
|
+
code: 'mesh_node_bootstrap_pending',
|
|
168
|
+
reason: 'bootstrap_still_running',
|
|
169
|
+
nodeId: dispatchNodeId,
|
|
170
|
+
meshId: dispatchMeshId,
|
|
171
|
+
...(readStringValue(meshCtx?.taskId) ? { taskId: readStringValue(meshCtx?.taskId) } : {}),
|
|
172
|
+
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.`,
|
|
173
|
+
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.',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
} catch { /* best-effort — if the bootstrap probe fails, fall through and dispatch */ }
|
|
177
|
+
}
|
|
178
|
+
return ctx.deps.cliManager.handleCliCommand('agent_command', args);
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
// ─── Logs ───
|
|
182
|
+
list_saved_sessions: async (ctx: MedFamilyContext, args: any) => {
|
|
183
|
+
const providerType = typeof args?.providerType === 'string'
|
|
184
|
+
? args.providerType.trim()
|
|
185
|
+
: typeof args?.agentType === 'string'
|
|
186
|
+
? args.agentType.trim()
|
|
187
|
+
: '';
|
|
188
|
+
const kind = args?.kind === 'acp' ? 'acp' : 'cli';
|
|
189
|
+
if (!providerType) {
|
|
190
|
+
return { success: false, error: 'providerType required' };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const wantsAll = args?.all === true;
|
|
194
|
+
const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
|
|
195
|
+
const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
|
|
196
|
+
const requestedWorkspace = typeof args?.workspace === 'string' ? args.workspace.trim() : '';
|
|
197
|
+
const requestedProviderSessionId = typeof args?.providerSessionId === 'string'
|
|
198
|
+
? args.providerSessionId.trim()
|
|
199
|
+
: typeof args?.activeProviderSessionId === 'string'
|
|
200
|
+
? args.activeProviderSessionId.trim()
|
|
201
|
+
: '';
|
|
202
|
+
const providerMeta = ctx.deps.providerLoader.resolve?.(providerType) || ctx.deps.providerLoader.getMeta(providerType);
|
|
203
|
+
const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
|
|
204
|
+
canonicalHistory: providerMeta?.nativeHistory,
|
|
205
|
+
offset,
|
|
206
|
+
limit,
|
|
207
|
+
historyBehavior: providerMeta?.historyBehavior,
|
|
208
|
+
scripts: providerMeta?.scripts as any,
|
|
209
|
+
});
|
|
210
|
+
const state = loadState();
|
|
211
|
+
const savedSessions = getSavedProviderSessions(state, { providerType, kind });
|
|
212
|
+
const recentSessions = getRecentActivity(state, 200)
|
|
213
|
+
.filter(entry => entry.providerType === providerType && entry.kind === kind && entry.providerSessionId);
|
|
214
|
+
const savedSessionById = new Map(savedSessions.map(entry => [entry.providerSessionId, entry]));
|
|
215
|
+
const recentSessionById = new Map(recentSessions.map(entry => [entry.providerSessionId!, entry]));
|
|
216
|
+
const canResumeById = supportsExplicitSessionResume(providerMeta?.resume);
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
success: true,
|
|
220
|
+
sessions: historySessions.map(session => {
|
|
221
|
+
const saved = savedSessionById.get(session.historySessionId);
|
|
222
|
+
const recent = recentSessionById.get(session.historySessionId);
|
|
223
|
+
const workspace = saved?.workspace
|
|
224
|
+
|| recent?.workspace
|
|
225
|
+
|| session.workspace
|
|
226
|
+
|| (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : undefined);
|
|
227
|
+
return {
|
|
228
|
+
id: session.historySessionId,
|
|
229
|
+
providerSessionId: session.historySessionId,
|
|
230
|
+
providerType,
|
|
231
|
+
providerName: saved?.providerName || recent?.providerName || providerType,
|
|
232
|
+
kind: saved?.kind || recent?.kind || kind,
|
|
233
|
+
title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
|
|
234
|
+
workspace,
|
|
235
|
+
summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
|
|
236
|
+
preview: session.preview,
|
|
237
|
+
messageCount: session.messageCount,
|
|
238
|
+
firstMessageAt: session.firstMessageAt,
|
|
239
|
+
lastMessageAt: session.lastMessageAt,
|
|
240
|
+
canResume: !!workspace && canResumeById,
|
|
241
|
+
historySource: session.source,
|
|
242
|
+
sourcePath: session.sourcePath,
|
|
243
|
+
sourceMtimeMs: session.sourceMtimeMs,
|
|
244
|
+
};
|
|
245
|
+
}),
|
|
246
|
+
hasMore,
|
|
247
|
+
source,
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// ─── restart_session: IDE / CLI / ACP unified ───
|
|
252
|
+
restart_session: async (ctx: MedFamilyContext, args: any) => {
|
|
253
|
+
const targetType = args?.cliType || args?.agentType || args?.ideType;
|
|
254
|
+
if (!targetType) throw new Error('cliType or ideType required');
|
|
255
|
+
|
|
256
|
+
// Check if IDE (in cdpManagers or provider category is ide)
|
|
257
|
+
const isIde = ctx.deps.cdpManagers.has(targetType) ||
|
|
258
|
+
ctx.deps.providerLoader.getMeta(targetType)?.category === 'ide';
|
|
259
|
+
|
|
260
|
+
if (isIde) {
|
|
261
|
+
// IDE restart: stop (with process kill) → launch
|
|
262
|
+
await ctx.stopIde(targetType, true);
|
|
263
|
+
const launchResult = await ctx.launchIde({ ideType: targetType, enableCdp: true, workspace: args?.workspace });
|
|
264
|
+
return { success: true, restarted: true, ideType: targetType, launch: launchResult };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// CLI/ACP restart: delegate to CliManager
|
|
268
|
+
return ctx.deps.cliManager.handleCliCommand('restart_session', args);
|
|
269
|
+
},
|
|
270
|
+
};
|