@adhdev/daemon-core 0.9.82-rc.49 → 0.9.82-rc.491
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 +66 -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 +53556 -19074
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53380 -19063
- 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 +1309 -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,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — session notification / seen-state commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Each handler
|
|
5
|
+
* mutates only the persisted recent-activity state store (loadState/saveState) and
|
|
6
|
+
* fires ctx.deps.onStatusChange; session lookup is rebuilt from deps the router
|
|
7
|
+
* already holds. Returns the same CommandRouterResult the inlined cases did.
|
|
8
|
+
*/
|
|
9
|
+
import { loadState, saveState } from '../../config/state-store.js';
|
|
10
|
+
import { markSessionSeen, dismissSessionNotification, markSessionNotificationUnread } from '../../config/recent-activity.js';
|
|
11
|
+
import { buildSessionEntries } from '../../status/builders.js';
|
|
12
|
+
import { getSessionCompletionMarker } from '../../status/snapshot.js';
|
|
13
|
+
import { LOG } from '../../logging/logger.js';
|
|
14
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
15
|
+
|
|
16
|
+
const READ_DEBUG_ENABLED = process.argv.includes('--dev') || process.env.ADHDEV_READ_DEBUG === '1';
|
|
17
|
+
|
|
18
|
+
export const notificationHandlers: Record<string, LowFamilyHandler> = {
|
|
19
|
+
mark_session_seen: async (ctx: LowFamilyContext, args: any) => {
|
|
20
|
+
const sessionId = args?.sessionId;
|
|
21
|
+
if (!sessionId || typeof sessionId !== 'string') {
|
|
22
|
+
return { success: false, error: 'sessionId is required' };
|
|
23
|
+
}
|
|
24
|
+
const currentState = loadState();
|
|
25
|
+
const prevSeenAt = currentState.sessionReads?.[sessionId] || 0;
|
|
26
|
+
const sessionEntries = buildSessionEntries(
|
|
27
|
+
ctx.deps.instanceManager.collectAllStates(),
|
|
28
|
+
ctx.deps.cdpManagers,
|
|
29
|
+
);
|
|
30
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
31
|
+
const requestedCompletionMarker = typeof args?.completionMarker === 'string'
|
|
32
|
+
? args.completionMarker.trim()
|
|
33
|
+
: '';
|
|
34
|
+
const completionMarker = requestedCompletionMarker || (targetSession ? getSessionCompletionMarker(targetSession) : '');
|
|
35
|
+
const requestedProviderSessionId = typeof args?.providerSessionId === 'string'
|
|
36
|
+
? args.providerSessionId.trim()
|
|
37
|
+
: '';
|
|
38
|
+
const providerSessionId = requestedProviderSessionId || targetSession?.providerSessionId;
|
|
39
|
+
const next = markSessionSeen(
|
|
40
|
+
currentState,
|
|
41
|
+
sessionId,
|
|
42
|
+
typeof args?.seenAt === 'number' ? args.seenAt : Date.now(),
|
|
43
|
+
completionMarker,
|
|
44
|
+
providerSessionId,
|
|
45
|
+
);
|
|
46
|
+
if (READ_DEBUG_ENABLED) {
|
|
47
|
+
LOG.info('RecentRead', `mark_session_seen sessionId=${sessionId} seenAt=${String(args?.seenAt || '')} prevSeenAt=${String(prevSeenAt)} nextSeenAt=${String(next.sessionReads?.[sessionId] || 0)} marker=${completionMarker || '-'}`);
|
|
48
|
+
}
|
|
49
|
+
saveState(next);
|
|
50
|
+
ctx.deps.onStatusChange?.();
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
sessionId,
|
|
54
|
+
seenAt: next.sessionReads?.[sessionId] || Date.now(),
|
|
55
|
+
completionMarker,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
delete_notification: async (ctx: LowFamilyContext, args: any) => {
|
|
60
|
+
const sessionId = args?.sessionId;
|
|
61
|
+
const notificationId = typeof args?.notificationId === 'string' ? args.notificationId.trim() : '';
|
|
62
|
+
if (!sessionId || typeof sessionId !== 'string') {
|
|
63
|
+
return { success: false, error: 'sessionId is required' };
|
|
64
|
+
}
|
|
65
|
+
if (!notificationId) {
|
|
66
|
+
return { success: false, error: 'notificationId is required' };
|
|
67
|
+
}
|
|
68
|
+
const sessionEntries = buildSessionEntries(
|
|
69
|
+
ctx.deps.instanceManager.collectAllStates(),
|
|
70
|
+
ctx.deps.cdpManagers,
|
|
71
|
+
);
|
|
72
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
73
|
+
const next = dismissSessionNotification(
|
|
74
|
+
loadState(),
|
|
75
|
+
sessionId,
|
|
76
|
+
notificationId,
|
|
77
|
+
targetSession?.providerSessionId,
|
|
78
|
+
);
|
|
79
|
+
saveState(next);
|
|
80
|
+
ctx.deps.onStatusChange?.();
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
sessionId,
|
|
84
|
+
notificationId,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
mark_notification_unread: async (ctx: LowFamilyContext, args: any) => {
|
|
89
|
+
const sessionId = args?.sessionId;
|
|
90
|
+
const notificationId = typeof args?.notificationId === 'string' ? args.notificationId.trim() : '';
|
|
91
|
+
if (!sessionId || typeof sessionId !== 'string') {
|
|
92
|
+
return { success: false, error: 'sessionId is required' };
|
|
93
|
+
}
|
|
94
|
+
if (!notificationId) {
|
|
95
|
+
return { success: false, error: 'notificationId is required' };
|
|
96
|
+
}
|
|
97
|
+
const sessionEntries = buildSessionEntries(
|
|
98
|
+
ctx.deps.instanceManager.collectAllStates(),
|
|
99
|
+
ctx.deps.cdpManagers,
|
|
100
|
+
);
|
|
101
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
102
|
+
const next = markSessionNotificationUnread(
|
|
103
|
+
loadState(),
|
|
104
|
+
sessionId,
|
|
105
|
+
notificationId,
|
|
106
|
+
targetSession?.providerSessionId,
|
|
107
|
+
);
|
|
108
|
+
saveState(next);
|
|
109
|
+
ctx.deps.onStatusChange?.();
|
|
110
|
+
return {
|
|
111
|
+
success: true,
|
|
112
|
+
sessionId,
|
|
113
|
+
notificationId,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — mesh refine-config / change-impact config commands.
|
|
3
|
+
*
|
|
4
|
+
* Schema/validate/suggest endpoints for the repo mesh refine config and the
|
|
5
|
+
* change-impact config. Pure: every handler is a function of args only (it reads
|
|
6
|
+
* no router deps), so ctx is unused. Extracted verbatim from executeDaemonCommand;
|
|
7
|
+
* the config helpers are imported from their source modules, identical to router.ts.
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
CHANGE_IMPACT_CONFIG_LOCATIONS,
|
|
11
|
+
CHANGE_IMPACT_CONFIG_SCHEMA,
|
|
12
|
+
loadChangeImpactConfig,
|
|
13
|
+
suggestChangeImpactConfig,
|
|
14
|
+
validateChangeImpactConfig,
|
|
15
|
+
} from '../../git/change-impact-config.js';
|
|
16
|
+
import {
|
|
17
|
+
MESH_REFINE_CONFIG_LOCATIONS,
|
|
18
|
+
MESH_REFINE_CONFIG_SCHEMA,
|
|
19
|
+
loadMeshRefineConfig,
|
|
20
|
+
suggestMeshRefineConfig,
|
|
21
|
+
validateMeshRefineConfig,
|
|
22
|
+
} from '../../mesh/refine-config.js';
|
|
23
|
+
import {
|
|
24
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
|
|
25
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
|
|
26
|
+
} from '../../mesh/worktree-bootstrap-config.js';
|
|
27
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
28
|
+
|
|
29
|
+
export const refineConfigHandlers: Record<string, LowFamilyHandler> = {
|
|
30
|
+
get_mesh_refine_config_schema: async (_ctx: LowFamilyContext, _args: any) => {
|
|
31
|
+
return {
|
|
32
|
+
success: true,
|
|
33
|
+
schema: MESH_REFINE_CONFIG_SCHEMA,
|
|
34
|
+
locations: MESH_REFINE_CONFIG_LOCATIONS,
|
|
35
|
+
worktreeBootstrap: {
|
|
36
|
+
schema: MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
|
|
37
|
+
locations: MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
|
|
38
|
+
sourceOfTruth: 'repo worktree bootstrap config',
|
|
39
|
+
runBehavior: 'When present and enabled, clone_mesh_node runs commands after submodule initialization and records status on the worktree node.',
|
|
40
|
+
},
|
|
41
|
+
sourceOfTruth: 'repo mesh/refine config',
|
|
42
|
+
heuristicRole: 'suggestions_only_not_execution_path',
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
validate_mesh_refine_config: async (_ctx: LowFamilyContext, args: any) => {
|
|
47
|
+
const workspace = typeof args?.workspace === 'string' ? args.workspace : process.cwd();
|
|
48
|
+
const mesh = args?.inlineMesh || {};
|
|
49
|
+
const loaded = args?.config !== undefined
|
|
50
|
+
? { config: args.config, source: 'inline', sourceType: 'mesh_policy' as const }
|
|
51
|
+
: loadMeshRefineConfig(mesh, workspace);
|
|
52
|
+
const validation = loaded.config
|
|
53
|
+
? validateMeshRefineConfig(loaded.config, loaded.source)
|
|
54
|
+
: { valid: false, errors: [((loaded as { error?: string }).error) || 'repo mesh/refine config unavailable'], commands: [], rejectedCommands: [] };
|
|
55
|
+
return { success: validation.valid, ...loaded, ...validation };
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
suggest_mesh_refine_config: async (_ctx: LowFamilyContext, args: any) => {
|
|
59
|
+
const workspace = typeof args?.workspace === 'string' ? args.workspace : process.cwd();
|
|
60
|
+
const mesh = args?.inlineMesh || {};
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
...suggestMeshRefineConfig(mesh, workspace),
|
|
64
|
+
note: 'Suggestions are heuristic scaffold only; Refinery will not execute them until saved into repo mesh/refine config.',
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
get_mesh_change_impact_config_schema: async (_ctx: LowFamilyContext, _args: any) => {
|
|
69
|
+
return {
|
|
70
|
+
success: true,
|
|
71
|
+
schema: CHANGE_IMPACT_CONFIG_SCHEMA,
|
|
72
|
+
locations: CHANGE_IMPACT_CONFIG_LOCATIONS,
|
|
73
|
+
sourceOfTruth: 'repo change-impact config',
|
|
74
|
+
heuristicRole: 'suggestions_only_not_execution_path',
|
|
75
|
+
note: 'Declarative config only — JSON/YAML are parsed but never executed. Defines which package/file changes require a daemon rebuild/restart vs. a web-only redeploy vs. nothing.',
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
validate_mesh_change_impact_config: async (_ctx: LowFamilyContext, args: any) => {
|
|
80
|
+
const workspace = typeof args?.workspace === 'string' ? args.workspace : process.cwd();
|
|
81
|
+
if (args?.config !== undefined) {
|
|
82
|
+
const validation = validateChangeImpactConfig(args.config, 'inline');
|
|
83
|
+
return { success: validation.valid, source: 'inline', sourceType: 'mesh_policy', ...validation };
|
|
84
|
+
}
|
|
85
|
+
const loaded = loadChangeImpactConfig(workspace);
|
|
86
|
+
if (loaded.sourceType === 'repo_file') {
|
|
87
|
+
const validation = validateChangeImpactConfig(loaded.config, loaded.source);
|
|
88
|
+
return { success: validation.valid, ...loaded, ...validation };
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
...loaded,
|
|
93
|
+
valid: false,
|
|
94
|
+
errors: [loaded.error || 'repo change-impact config unavailable'],
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
suggest_mesh_change_impact_config: async (_ctx: LowFamilyContext, args: any) => {
|
|
99
|
+
const workspace = typeof args?.workspace === 'string' ? args.workspace : process.cwd();
|
|
100
|
+
return {
|
|
101
|
+
success: true,
|
|
102
|
+
...suggestChangeImpactConfig(workspace),
|
|
103
|
+
note: 'Suggestions are heuristic scaffold only; the draft must be reviewed and saved into repo change-impact config before it takes effect. Nothing is executed.',
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER LOW family — session-host control commands.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from DaemonCommandRouter.executeDaemonCommand. Each handler
|
|
5
|
+
* reads only ctx.deps.sessionHostControl (+ cliManager for the resume/restart
|
|
6
|
+
* hosted-session restore) and returns the same CommandRouterResult as before.
|
|
7
|
+
* The trace/summarize helpers were `this`-free module functions in router.ts and
|
|
8
|
+
* are relocated here unchanged.
|
|
9
|
+
*/
|
|
10
|
+
import type { HostedCliRuntimeDescriptor } from '../cli-manager.js';
|
|
11
|
+
import { recordDebugTrace } from '../../logging/debug-trace.js';
|
|
12
|
+
import { getSessionHostSurfaceKind, partitionSessionHostRecords } from '../../session-host/runtime-surface.js';
|
|
13
|
+
import type { LowFamilyContext, LowFamilyHandler } from './types.js';
|
|
14
|
+
|
|
15
|
+
function toHostedCliRuntimeDescriptor(record: any): HostedCliRuntimeDescriptor | null {
|
|
16
|
+
if (!record || typeof record !== 'object') return null;
|
|
17
|
+
const runtimeId = typeof record.sessionId === 'string' ? record.sessionId : '';
|
|
18
|
+
const cliType = typeof record.providerType === 'string' ? record.providerType : '';
|
|
19
|
+
const workspace = typeof record.workspace === 'string' ? record.workspace : '';
|
|
20
|
+
if (!runtimeId || !cliType || !workspace) return null;
|
|
21
|
+
return {
|
|
22
|
+
runtimeId,
|
|
23
|
+
runtimeKey: typeof record.runtimeKey === 'string' ? record.runtimeKey : undefined,
|
|
24
|
+
displayName: typeof record.displayName === 'string' ? record.displayName : undefined,
|
|
25
|
+
workspaceLabel: typeof record.workspaceLabel === 'string' ? record.workspaceLabel : undefined,
|
|
26
|
+
lifecycle: typeof record.lifecycle === 'string' ? record.lifecycle as HostedCliRuntimeDescriptor['lifecycle'] : undefined,
|
|
27
|
+
recoveryState: typeof record.meta?.runtimeRecoveryState === 'string'
|
|
28
|
+
? String(record.meta.runtimeRecoveryState)
|
|
29
|
+
: null,
|
|
30
|
+
cliType,
|
|
31
|
+
workspace,
|
|
32
|
+
cliArgs: Array.isArray(record.meta?.cliArgs) ? record.meta.cliArgs as string[] : [],
|
|
33
|
+
providerSessionId: typeof record.meta?.providerSessionId === 'string'
|
|
34
|
+
? String(record.meta.providerSessionId)
|
|
35
|
+
: undefined,
|
|
36
|
+
// Real spawn time (PAST timestamp) of the underlying runtime — startedAt is
|
|
37
|
+
// stamped on markStarted; fall back to createdAt (record creation). Threaded
|
|
38
|
+
// through so an attach restores the native-history session-floor to the
|
|
39
|
+
// runtime's actual birth instead of collapsing spawnedAtMs to 0 (which broke
|
|
40
|
+
// the antigravity per-session birth-floor for co-located MAGI runtimes).
|
|
41
|
+
startedAtMs: typeof record.startedAt === 'number' && record.startedAt > 0
|
|
42
|
+
? record.startedAt
|
|
43
|
+
: (typeof record.createdAt === 'number' && record.createdAt > 0 ? record.createdAt : undefined),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getWriteConflictOwnerClientId(error: unknown): string | undefined {
|
|
48
|
+
const message = typeof error === 'string'
|
|
49
|
+
? error
|
|
50
|
+
: error instanceof Error
|
|
51
|
+
? error.message
|
|
52
|
+
: '';
|
|
53
|
+
const match = /^Write owned by\s+(.+)$/.exec(message.trim());
|
|
54
|
+
return match?.[1]?.trim() || undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function summarizeSessionHostRecord(result: unknown): Record<string, unknown> {
|
|
58
|
+
if (!result || typeof result !== 'object') return {};
|
|
59
|
+
const record = result as Record<string, any>;
|
|
60
|
+
return {
|
|
61
|
+
runtimeKey: typeof record.runtimeKey === 'string' ? record.runtimeKey : undefined,
|
|
62
|
+
lifecycle: typeof record.lifecycle === 'string' ? record.lifecycle : undefined,
|
|
63
|
+
surfaceKind: getSessionHostSurfaceKind(record as any),
|
|
64
|
+
attachedClientCount: Array.isArray(record.attachedClients) ? record.attachedClients.length : undefined,
|
|
65
|
+
hasWriteOwner: !!record.writeOwner,
|
|
66
|
+
writeOwnerClientId: typeof record.writeOwner?.clientId === 'string' ? record.writeOwner.clientId : undefined,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function summarizeSessionHostRecords(result: unknown): Record<string, unknown> {
|
|
71
|
+
const records = Array.isArray(result) ? result : [];
|
|
72
|
+
const groups = partitionSessionHostRecords(records as any[]);
|
|
73
|
+
return {
|
|
74
|
+
sessionCount: records.length,
|
|
75
|
+
liveRuntimeCount: groups.liveRuntimes.length,
|
|
76
|
+
recoverySnapshotCount: groups.recoverySnapshots.length,
|
|
77
|
+
inactiveRecordCount: groups.inactiveRecords.length,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function summarizeSessionHostDiagnostics(result: unknown): Record<string, unknown> {
|
|
82
|
+
const diagnostics = result && typeof result === 'object' ? result as Record<string, any> : {};
|
|
83
|
+
const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
|
|
84
|
+
return {
|
|
85
|
+
runtimeCount: typeof diagnostics.runtimeCount === 'number' ? diagnostics.runtimeCount : undefined,
|
|
86
|
+
...summarizeSessionHostRecords(sessions),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function summarizeSessionHostPruneResult(result: unknown): Record<string, unknown> {
|
|
91
|
+
const value = result && typeof result === 'object' ? result as Record<string, any> : {};
|
|
92
|
+
return {
|
|
93
|
+
duplicateGroupCount: typeof value.duplicateGroupCount === 'number' ? value.duplicateGroupCount : undefined,
|
|
94
|
+
prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : undefined,
|
|
95
|
+
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : undefined,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function traceSessionHostAction<T>(
|
|
100
|
+
action: string,
|
|
101
|
+
args: any,
|
|
102
|
+
run: () => Promise<T>,
|
|
103
|
+
summarizeResult?: (result: T) => Record<string, unknown>,
|
|
104
|
+
): Promise<T> {
|
|
105
|
+
const interactionId = typeof args?._interactionId === 'string' ? args._interactionId : undefined;
|
|
106
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : undefined;
|
|
107
|
+
const requestedPayload: Record<string, unknown> = { action };
|
|
108
|
+
if (sessionId) requestedPayload.sessionId = sessionId;
|
|
109
|
+
if (typeof args?.clientId === 'string') requestedPayload.clientId = args.clientId;
|
|
110
|
+
if (typeof args?.signal === 'string') requestedPayload.signal = args.signal;
|
|
111
|
+
if (typeof args?.providerType === 'string') requestedPayload.providerType = args.providerType;
|
|
112
|
+
if (typeof args?.workspace === 'string') requestedPayload.workspace = args.workspace;
|
|
113
|
+
if (typeof args?.dryRun === 'boolean') requestedPayload.dryRun = args.dryRun;
|
|
114
|
+
|
|
115
|
+
recordDebugTrace({
|
|
116
|
+
interactionId,
|
|
117
|
+
category: 'session_host',
|
|
118
|
+
stage: 'action_requested',
|
|
119
|
+
level: 'info',
|
|
120
|
+
sessionId,
|
|
121
|
+
payload: requestedPayload,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
const result = await run();
|
|
126
|
+
recordDebugTrace({
|
|
127
|
+
interactionId,
|
|
128
|
+
category: 'session_host',
|
|
129
|
+
stage: 'action_result',
|
|
130
|
+
level: 'info',
|
|
131
|
+
sessionId,
|
|
132
|
+
payload: {
|
|
133
|
+
...requestedPayload,
|
|
134
|
+
success: true,
|
|
135
|
+
...(summarizeResult ? summarizeResult(result) : {}),
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
return result;
|
|
139
|
+
} catch (error: any) {
|
|
140
|
+
recordDebugTrace({
|
|
141
|
+
interactionId,
|
|
142
|
+
category: 'session_host',
|
|
143
|
+
stage: 'action_failed',
|
|
144
|
+
level: 'error',
|
|
145
|
+
sessionId,
|
|
146
|
+
payload: {
|
|
147
|
+
...requestedPayload,
|
|
148
|
+
error: error?.message || String(error),
|
|
149
|
+
failureKind: getWriteConflictOwnerClientId(error) ? 'write_conflict' : 'request_failed',
|
|
150
|
+
conflictOwnerClientId: getWriteConflictOwnerClientId(error),
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export const sessionHostHandlers: Record<string, LowFamilyHandler> = {
|
|
158
|
+
session_host_get_diagnostics: async (ctx: LowFamilyContext, args: any) => {
|
|
159
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
160
|
+
const diagnostics = await traceSessionHostAction('session_host_get_diagnostics', args, () => ctx.deps.sessionHostControl!.getDiagnostics({
|
|
161
|
+
includeSessions: args?.includeSessions !== false,
|
|
162
|
+
limit: Number(args?.limit) || undefined,
|
|
163
|
+
}), (result) => ({
|
|
164
|
+
includeSessions: args?.includeSessions !== false,
|
|
165
|
+
limit: Number(args?.limit) || undefined,
|
|
166
|
+
...summarizeSessionHostDiagnostics(result),
|
|
167
|
+
}));
|
|
168
|
+
return { success: true, diagnostics };
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
session_host_list_sessions: async (ctx: LowFamilyContext, args: any) => {
|
|
172
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
173
|
+
const sessions = await traceSessionHostAction('session_host_list_sessions', args, () => ctx.deps.sessionHostControl!.listSessions(), (records) => summarizeSessionHostRecords(records));
|
|
174
|
+
return { success: true, sessions };
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
session_host_stop_session: async (ctx: LowFamilyContext, args: any) => {
|
|
178
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
179
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : '';
|
|
180
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
181
|
+
const record = await traceSessionHostAction('session_host_stop_session', args, () => ctx.deps.sessionHostControl!.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
|
|
182
|
+
return { success: true, record };
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
session_host_resume_session: async (ctx: LowFamilyContext, args: any) => {
|
|
186
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
187
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : '';
|
|
188
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
189
|
+
const record = await traceSessionHostAction('session_host_resume_session', args, async () => {
|
|
190
|
+
const nextRecord = await ctx.deps.sessionHostControl!.resumeSession(sessionId);
|
|
191
|
+
const hosted = toHostedCliRuntimeDescriptor(nextRecord);
|
|
192
|
+
if (hosted) {
|
|
193
|
+
await ctx.deps.cliManager.restoreHostedSessions([hosted]);
|
|
194
|
+
}
|
|
195
|
+
return nextRecord;
|
|
196
|
+
}, (result) => ({
|
|
197
|
+
...summarizeSessionHostRecord(result),
|
|
198
|
+
restoredHostedSession: !!toHostedCliRuntimeDescriptor(result),
|
|
199
|
+
}));
|
|
200
|
+
return { success: true, record };
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
session_host_restart_session: async (ctx: LowFamilyContext, args: any) => {
|
|
204
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
205
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : '';
|
|
206
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
207
|
+
const record = await traceSessionHostAction('session_host_restart_session', args, async () => {
|
|
208
|
+
const nextRecord = await ctx.deps.sessionHostControl!.restartSession(sessionId);
|
|
209
|
+
const hosted = toHostedCliRuntimeDescriptor(nextRecord);
|
|
210
|
+
if (hosted) {
|
|
211
|
+
await ctx.deps.cliManager.restoreHostedSessions([hosted]);
|
|
212
|
+
}
|
|
213
|
+
return nextRecord;
|
|
214
|
+
}, (result) => ({
|
|
215
|
+
...summarizeSessionHostRecord(result),
|
|
216
|
+
restoredHostedSession: !!toHostedCliRuntimeDescriptor(result),
|
|
217
|
+
}));
|
|
218
|
+
return { success: true, record };
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
session_host_send_signal: async (ctx: LowFamilyContext, args: any) => {
|
|
222
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
223
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : '';
|
|
224
|
+
const signal = typeof args?.signal === 'string' ? args.signal : '';
|
|
225
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
226
|
+
if (!signal) return { success: false, error: 'signal required' };
|
|
227
|
+
const record = await traceSessionHostAction('session_host_send_signal', args, () => ctx.deps.sessionHostControl!.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
|
|
228
|
+
return { success: true, record };
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
session_host_force_detach_client: async (ctx: LowFamilyContext, args: any) => {
|
|
232
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
233
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : '';
|
|
234
|
+
const clientId = typeof args?.clientId === 'string' ? args.clientId : '';
|
|
235
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
236
|
+
if (!clientId) return { success: false, error: 'clientId required' };
|
|
237
|
+
const record = await traceSessionHostAction('session_host_force_detach_client', args, () => ctx.deps.sessionHostControl!.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
|
|
238
|
+
return { success: true, record };
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
session_host_prune_duplicate_sessions: async (ctx: LowFamilyContext, args: any) => {
|
|
242
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
243
|
+
const result = await traceSessionHostAction('session_host_prune_duplicate_sessions', args, () => ctx.deps.sessionHostControl!.pruneDuplicateSessions({
|
|
244
|
+
providerType: typeof args?.providerType === 'string' ? args.providerType : undefined,
|
|
245
|
+
workspace: typeof args?.workspace === 'string' ? args.workspace : undefined,
|
|
246
|
+
dryRun: args?.dryRun === true,
|
|
247
|
+
}), (value) => summarizeSessionHostPruneResult(value));
|
|
248
|
+
return { success: true, result };
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
session_host_acquire_write: async (ctx: LowFamilyContext, args: any) => {
|
|
252
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
253
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : '';
|
|
254
|
+
const clientId = typeof args?.clientId === 'string' ? args.clientId : '';
|
|
255
|
+
const ownerType = args?.ownerType === 'agent' ? 'agent' : 'user';
|
|
256
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
257
|
+
if (!clientId) return { success: false, error: 'clientId required' };
|
|
258
|
+
const record = await traceSessionHostAction('session_host_acquire_write', args, () => ctx.deps.sessionHostControl!.acquireWrite({
|
|
259
|
+
sessionId,
|
|
260
|
+
clientId,
|
|
261
|
+
ownerType,
|
|
262
|
+
force: args?.force !== false,
|
|
263
|
+
}), (result) => ({
|
|
264
|
+
...summarizeSessionHostRecord(result),
|
|
265
|
+
ownerType,
|
|
266
|
+
}));
|
|
267
|
+
return { success: true, record };
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
session_host_release_write: async (ctx: LowFamilyContext, args: any) => {
|
|
271
|
+
if (!ctx.deps.sessionHostControl) return { success: false, error: 'Session host control unavailable' };
|
|
272
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId : '';
|
|
273
|
+
const clientId = typeof args?.clientId === 'string' ? args.clientId : '';
|
|
274
|
+
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
275
|
+
if (!clientId) return { success: false, error: 'clientId required' };
|
|
276
|
+
const record = await traceSessionHostAction('session_host_release_write', args, () => ctx.deps.sessionHostControl!.releaseWrite({
|
|
277
|
+
sessionId,
|
|
278
|
+
clientId,
|
|
279
|
+
}), (result) => summarizeSessionHostRecord(result));
|
|
280
|
+
return { success: true, record };
|
|
281
|
+
},
|
|
282
|
+
};
|