@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,449 @@
|
|
|
1
|
+
import { type SpecPtyEvent } from './adapter.js';
|
|
2
|
+
import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
|
|
3
|
+
import { type TraceEntry } from './evaluator.js';
|
|
4
|
+
import { type TransitionEval } from './fsm-evaluator.js';
|
|
5
|
+
import { chunkPreservingSurrogates as chunkPreservingSurrogatesShared } from '../../cli-adapters/pty-write-chunking.js';
|
|
6
|
+
export type DashboardEvent = {
|
|
7
|
+
kind: 'pty_data';
|
|
8
|
+
chunk: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'state_changed';
|
|
11
|
+
state: {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
title: string | null;
|
|
15
|
+
status: 'idle' | 'generating' | 'approval';
|
|
16
|
+
};
|
|
17
|
+
modal: {
|
|
18
|
+
title: string | null;
|
|
19
|
+
buttons: {
|
|
20
|
+
index: number;
|
|
21
|
+
label: string;
|
|
22
|
+
}[];
|
|
23
|
+
kind: 'approval' | 'picker' | 'confirm' | null;
|
|
24
|
+
} | null;
|
|
25
|
+
controls: {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
action_type: string;
|
|
29
|
+
}[];
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'notification';
|
|
32
|
+
id: string;
|
|
33
|
+
title: string;
|
|
34
|
+
body: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'delegate';
|
|
37
|
+
id: string;
|
|
38
|
+
task: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'spec_trace';
|
|
41
|
+
entries: TraceEntry[];
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'exit';
|
|
44
|
+
exit_code: number;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'spec_error';
|
|
47
|
+
errors: string[];
|
|
48
|
+
};
|
|
49
|
+
export type DashboardCommand = {
|
|
50
|
+
kind: 'send_message';
|
|
51
|
+
text: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'pty_write';
|
|
54
|
+
data: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'click_control';
|
|
57
|
+
control_id: string;
|
|
58
|
+
payload?: unknown;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'click_modal_button';
|
|
61
|
+
index: number;
|
|
62
|
+
} | {
|
|
63
|
+
kind: 'attach_image';
|
|
64
|
+
blob: string;
|
|
65
|
+
mime: string;
|
|
66
|
+
} | {
|
|
67
|
+
kind: 'resize';
|
|
68
|
+
cols: number;
|
|
69
|
+
rows: number;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'cancel';
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'shutdown';
|
|
74
|
+
};
|
|
75
|
+
export interface DriverHistoryEntry {
|
|
76
|
+
stateId: string;
|
|
77
|
+
label: string;
|
|
78
|
+
at: number;
|
|
79
|
+
durationMs: number;
|
|
80
|
+
reason: string;
|
|
81
|
+
matchedStateId?: string;
|
|
82
|
+
matchedRules?: string[];
|
|
83
|
+
debounceKind?: string;
|
|
84
|
+
idleHoldMs?: number;
|
|
85
|
+
busyHoldMs?: number;
|
|
86
|
+
via?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A frozen snapshot of the FULL FSM evaluation captured at the instant a
|
|
90
|
+
* transition fired — the rich `transitions[]` table (per-transition eligible /
|
|
91
|
+
* hold countdown / per-condition CondResult + remainingMs) that `getFsmDebug()`
|
|
92
|
+
* otherwise only computes live for the current instant. Kept in a separate ring
|
|
93
|
+
* buffer from `stateHistory` (which stays intentionally lightweight) so the
|
|
94
|
+
* "why did this rule fire just before the transition" question is answerable
|
|
95
|
+
* after the fact. before-only: this is the evaluation that PRODUCED the
|
|
96
|
+
* transition, not the post-transition state.
|
|
97
|
+
*/
|
|
98
|
+
export interface FsmSnapshotEntry {
|
|
99
|
+
/** State we transitioned out of. */
|
|
100
|
+
stateFrom: string;
|
|
101
|
+
/** State we transitioned into (the fired transition's destination). */
|
|
102
|
+
stateTo: string;
|
|
103
|
+
/** Wall-clock time the transition committed (ms). */
|
|
104
|
+
at: number;
|
|
105
|
+
/** The fired transition's destination state id (== stateTo; kept explicit
|
|
106
|
+
* to mirror the rule that fired). */
|
|
107
|
+
firedTo: string;
|
|
108
|
+
/** Human label of the fired transition (e.g. "approval→busy"). */
|
|
109
|
+
firedLabel: string;
|
|
110
|
+
/** Why-it-fired summary, same shape produced for stateHistory.matchedRules. */
|
|
111
|
+
reason: string[];
|
|
112
|
+
/** Every outgoing transition from `stateFrom` as evaluated at `at`, each
|
|
113
|
+
* with its eligible / hold / per-condition CondResult + remainingMs. This
|
|
114
|
+
* is the full pre-transition evaluation table — the whole point of the
|
|
115
|
+
* snapshot. */
|
|
116
|
+
transitions: TransitionEval[];
|
|
117
|
+
}
|
|
118
|
+
export interface ISpecDriver {
|
|
119
|
+
subscribe(listener: (ev: DashboardEvent) => void): () => void;
|
|
120
|
+
start(): void;
|
|
121
|
+
dispatch(cmd: DashboardCommand): void;
|
|
122
|
+
updateMeta(meta: Record<string, unknown>, replace?: boolean): void;
|
|
123
|
+
snapshot(): string;
|
|
124
|
+
getCursorPosition(): {
|
|
125
|
+
row: number;
|
|
126
|
+
col: number;
|
|
127
|
+
};
|
|
128
|
+
getScreen(): string;
|
|
129
|
+
getSpecPath(): string;
|
|
130
|
+
shutdown(): void;
|
|
131
|
+
getStateHistory(): ReadonlyArray<DriverHistoryEntry>;
|
|
132
|
+
getSections(): Array<{
|
|
133
|
+
id: string;
|
|
134
|
+
text: string;
|
|
135
|
+
}> | null;
|
|
136
|
+
getLastBusyAt(): number;
|
|
137
|
+
hasIdleHoldPending(): boolean;
|
|
138
|
+
hasSeenReady(): boolean;
|
|
139
|
+
getCompletionIdleDebounceState(): {
|
|
140
|
+
active: boolean;
|
|
141
|
+
ageMs: number;
|
|
142
|
+
holdMs: number;
|
|
143
|
+
forceAfterMs: number;
|
|
144
|
+
} | null;
|
|
145
|
+
getFsmDebug?(): unknown;
|
|
146
|
+
getFsmSnapshotHistory?(): ReadonlyArray<FsmSnapshotEntry>;
|
|
147
|
+
getEventTimeline?(limit?: number): ReadonlyArray<SpecPtyEvent>;
|
|
148
|
+
}
|
|
149
|
+
export interface SpecDriverOpts {
|
|
150
|
+
specPath: string;
|
|
151
|
+
workingDir: string;
|
|
152
|
+
extraEnv?: Record<string, string>;
|
|
153
|
+
cols?: number;
|
|
154
|
+
rows?: number;
|
|
155
|
+
hotReload?: boolean;
|
|
156
|
+
emitTrace?: boolean;
|
|
157
|
+
transportFactory?: PtyTransportFactory;
|
|
158
|
+
extraCliArgs?: string[];
|
|
159
|
+
}
|
|
160
|
+
export type Win32SubmitMode = 'paste' | 'soft_newline';
|
|
161
|
+
export declare function resolveWin32SubmitMode(env?: NodeJS.ProcessEnv): Win32SubmitMode;
|
|
162
|
+
export declare function resolveSubmitDelayMs(specBeforeSubmit: number | undefined, text: string): number;
|
|
163
|
+
/** Re-export of the shared surrogate-safe splitter so existing imports of
|
|
164
|
+
* `chunkPreservingSurrogates` from this module keep working. The implementation
|
|
165
|
+
* lives in ../../cli-adapters/pty-write-chunking so the spec driver and the
|
|
166
|
+
* legacy adapter share one definition. */
|
|
167
|
+
export declare const chunkPreservingSurrogates: typeof chunkPreservingSurrogatesShared;
|
|
168
|
+
export declare function guessExt(mime: string): string;
|
|
169
|
+
type HistoryEntry = DriverHistoryEntry;
|
|
170
|
+
export declare class FsmDriver implements ISpecDriver {
|
|
171
|
+
private readonly opts;
|
|
172
|
+
private spec;
|
|
173
|
+
private adapter;
|
|
174
|
+
private listeners;
|
|
175
|
+
private currentStateId;
|
|
176
|
+
private stateEnteredAt;
|
|
177
|
+
private startedAtMs;
|
|
178
|
+
private prevScreenLines;
|
|
179
|
+
/** Per stable region → last time that region's content changed. Drives
|
|
180
|
+
* stable_ms conditions. Key = stableRegionKey(cond): numeric cursor_above
|
|
181
|
+
* (−1 = whole screen), or a `section:<id>` / `<region>#ignore:<pat>` string
|
|
182
|
+
* when the clause scopes to a section or declares an ignore_lines filter. */
|
|
183
|
+
private regionLastChangedAt;
|
|
184
|
+
/** COMPLETION-EARLYNOTIFY stable-eval trace: last stable/not-stable verdict
|
|
185
|
+
* recorded per stable region, so the trace fires only when the verdict FLIPS
|
|
186
|
+
* (not every quiet frame). Cleared on every transition alongside
|
|
187
|
+
* regionLastChangedAt. Diagnostic-only — never consulted by the FSM. */
|
|
188
|
+
private stableVerdictCache;
|
|
189
|
+
/** Timer that re-runs evaluate() when a time-condition would flip true
|
|
190
|
+
* with no PTY frame to trigger it. */
|
|
191
|
+
private wakeTimer;
|
|
192
|
+
/** Timer driving the focus-gated stall watchdog (refocus_when_stalled_ms).
|
|
193
|
+
* Re-arms itself while the machine is generating so a re-prime can fire
|
|
194
|
+
* even when the PTY has gone completely quiet. */
|
|
195
|
+
private stallTimer;
|
|
196
|
+
/** Wall-clock time the last stall re-prime was injected. The cooldown gate:
|
|
197
|
+
* after a re-prime we don't re-inject until the screen changes (which
|
|
198
|
+
* resets the stall reference) or another full stall window lapses. */
|
|
199
|
+
private lastRefocusAt;
|
|
200
|
+
/** Timer driving the win32 verification-based submit resend loop (see
|
|
201
|
+
* WIN32_SUBMIT_* and scheduleWin32Submit). Re-arms itself until the FSM
|
|
202
|
+
* leaves idle (submitted) or the resend budget is spent. */
|
|
203
|
+
private win32SubmitTimer;
|
|
204
|
+
/** Wall-clock (ms) of the most recent raw PTY output chunk. Advances on every
|
|
205
|
+
* on_pty_data — including the echo of text written into the composer — so the
|
|
206
|
+
* win32 submit settle-gate can tell when input has finished landing. */
|
|
207
|
+
private lastPtyDataAt;
|
|
208
|
+
/** Wall-clock (ms) of the most recent win32 message-body input write. Bridges
|
|
209
|
+
* the gap between writing a chunk and its echo so the settle-gate does not
|
|
210
|
+
* declare "quiet" mid-write. */
|
|
211
|
+
private lastWin32WriteAt;
|
|
212
|
+
/** Pending paced chunk-write timer for a large win32 body (see writeWin32Body). */
|
|
213
|
+
private win32WriteTimer;
|
|
214
|
+
/** Timer driving the win32 verification-based modal-confirm CR resend loop (see
|
|
215
|
+
* scheduleWin32ModalConfirm). A lone CR that confirms an approval/picker choice
|
|
216
|
+
* is absorbed by ConPTY the same way a send_message submit CR is, so the confirm
|
|
217
|
+
* must be resent until the modal actually resolves (status leaves 'approval'). */
|
|
218
|
+
private win32ModalConfirmTimer;
|
|
219
|
+
private currentEval;
|
|
220
|
+
private stateHistory;
|
|
221
|
+
private prevStateAt;
|
|
222
|
+
private readySeenOnce;
|
|
223
|
+
private pendingSends;
|
|
224
|
+
private pickerInProgress;
|
|
225
|
+
private delegateTimers;
|
|
226
|
+
private specWatcher;
|
|
227
|
+
/** Last full FSM evaluation, kept for the debugger. */
|
|
228
|
+
private lastFsmEval;
|
|
229
|
+
/** Ring buffer (max 20) of the full FSM evaluation captured at each
|
|
230
|
+
* transition — the rich pre-transition table that lastFsmEval only keeps
|
|
231
|
+
* for the single most recent evaluation. Separate from stateHistory. */
|
|
232
|
+
private fsmSnapshotHistory;
|
|
233
|
+
constructor(opts: SpecDriverOpts);
|
|
234
|
+
subscribe(listener: (ev: DashboardEvent) => void): () => void;
|
|
235
|
+
start(): void;
|
|
236
|
+
private scheduleSpawnPrime;
|
|
237
|
+
/** Write the declared `send_on_spawn` sequences to the PTY once. Used both
|
|
238
|
+
* at spawn (scheduleSpawnPrime) and, for focus-gated TUIs, by the stall
|
|
239
|
+
* watchdog to re-inject the focus-in wake mid-turn. No-op when the spec
|
|
240
|
+
* declares no prime, so non-focus-gated CLIs are never poked. */
|
|
241
|
+
private sendSpawnPrime;
|
|
242
|
+
dispatch(cmd: DashboardCommand): void;
|
|
243
|
+
/** Forward runtime metadata to the terminal transport so mesh binding
|
|
244
|
+
* fields (meshNodeId / meshNodeFor / workspaceLabel / lifecycle) reach
|
|
245
|
+
* the session registry. Not a DashboardCommand — this is a control-plane
|
|
246
|
+
* update, not user input. */
|
|
247
|
+
updateMeta(meta: Record<string, unknown>, replace?: boolean): void;
|
|
248
|
+
snapshot(): string;
|
|
249
|
+
getCursorPosition(): {
|
|
250
|
+
row: number;
|
|
251
|
+
col: number;
|
|
252
|
+
};
|
|
253
|
+
getScreen(): string;
|
|
254
|
+
/** Scrollback-inclusive screen as line array — used only for modal/button
|
|
255
|
+
* content extraction so a tall prompt's off-screen anchors stay matchable.
|
|
256
|
+
* Falls back to the viewport snapshot if scrollback read is unavailable. */
|
|
257
|
+
private scrollbackLines;
|
|
258
|
+
getSpecPath(): string;
|
|
259
|
+
shutdown(): void;
|
|
260
|
+
getFsmDebug(): {
|
|
261
|
+
currentState: string;
|
|
262
|
+
label: string;
|
|
263
|
+
stateAgeMs: number;
|
|
264
|
+
status: string;
|
|
265
|
+
cursor: {
|
|
266
|
+
row: number;
|
|
267
|
+
col: number;
|
|
268
|
+
};
|
|
269
|
+
transitions: TransitionEval[];
|
|
270
|
+
};
|
|
271
|
+
getStateHistory(): ReadonlyArray<HistoryEntry>;
|
|
272
|
+
getFsmSnapshotHistory(): ReadonlyArray<FsmSnapshotEntry>;
|
|
273
|
+
/** Debug-only PTY input/output/resize/cursor timeline from the adapter. */
|
|
274
|
+
getEventTimeline(limit?: number): ReadonlyArray<SpecPtyEvent>;
|
|
275
|
+
getSections(): Array<{
|
|
276
|
+
id: string;
|
|
277
|
+
text: string;
|
|
278
|
+
}> | null;
|
|
279
|
+
/** v3-compat shims so the cli-adapter's existing debug snapshot keeps
|
|
280
|
+
* working without branching on driver type. */
|
|
281
|
+
getLastBusyAt(): number;
|
|
282
|
+
hasIdleHoldPending(): boolean;
|
|
283
|
+
/**
|
|
284
|
+
* True once the machine has reached its first non-initial idle state (the
|
|
285
|
+
* prompt is genuinely drawn — see maybeMarkReady). The cli-adapter surfaces
|
|
286
|
+
* this on its idle status so CliProviderInstance can re-arm the queue-claim
|
|
287
|
+
* agent:ready on the first genuine ready, independent of the boot-time
|
|
288
|
+
* starting→idle one-shot (which is consumed too early for specs whose
|
|
289
|
+
* initial state already reports idle).
|
|
290
|
+
*/
|
|
291
|
+
hasSeenReady(): boolean;
|
|
292
|
+
getCompletionIdleDebounceState(): {
|
|
293
|
+
active: boolean;
|
|
294
|
+
ageMs: number;
|
|
295
|
+
holdMs: number;
|
|
296
|
+
forceAfterMs: number;
|
|
297
|
+
} | null;
|
|
298
|
+
private loadSpecOrThrow;
|
|
299
|
+
private buildAdapterOpts;
|
|
300
|
+
private armSpecWatcher;
|
|
301
|
+
private emitInitialState;
|
|
302
|
+
private buildClock;
|
|
303
|
+
private evalFsmNow;
|
|
304
|
+
private reevaluate;
|
|
305
|
+
private commitTransition;
|
|
306
|
+
/** Snapshot the full FSM evaluation that produced a transition into the
|
|
307
|
+
* separate fsmSnapshotHistory ring buffer (max 20). The transitions[]
|
|
308
|
+
* table is captured by reference — it is freshly built per evaluation in
|
|
309
|
+
* evaluateFsm and never mutated after, so no clone is needed. */
|
|
310
|
+
private pushFsmSnapshot;
|
|
311
|
+
/** Re-derive the visible modal + controls for the current state and emit a
|
|
312
|
+
* state_changed if anything differs from the last emit. */
|
|
313
|
+
private emitStateChanged;
|
|
314
|
+
private deriveModal;
|
|
315
|
+
private deriveTitle;
|
|
316
|
+
private deriveControls;
|
|
317
|
+
/** Track which stable regions changed since the previous frame so
|
|
318
|
+
* stable_ms conditions can measure quiet time. We record every distinct
|
|
319
|
+
* stable region referenced in the current state (numeric cursor_above /
|
|
320
|
+
* whole-screen -1, and named `section:<id>` regions) plus, for each, the
|
|
321
|
+
* optional `ignore_lines` filter that folds into its key.
|
|
322
|
+
*
|
|
323
|
+
* `ignore_lines` is the content-aware fix for the busy→idle wedge: lines
|
|
324
|
+
* matching it are stripped from BOTH frames before the comparison, so a
|
|
325
|
+
* benign residual ticker (bare token counter / elapsed timer that repaints
|
|
326
|
+
* every frame post-generation) no longer resets the clock — while an active
|
|
327
|
+
* spinner line, which does NOT match the benign pattern, still does (the
|
|
328
|
+
* FALSEIDLE2 / FALSEBUSY-B whole-screen invariant is preserved). */
|
|
329
|
+
private trackRegionChanges;
|
|
330
|
+
/** Every distinct stable-region descriptor referenced by stable_ms
|
|
331
|
+
* conditions in the current state's outgoing transitions, plus the plain
|
|
332
|
+
* whole-screen key (-1) that other machinery (stall watchdog) reads.
|
|
333
|
+
* De-duplicated by key. Cached lazily per spec load would be nicer but the
|
|
334
|
+
* set is tiny. */
|
|
335
|
+
private stableRegionDescriptors;
|
|
336
|
+
/** Schedule a re-evaluation for the soonest pending time-condition on any
|
|
337
|
+
* outgoing transition (elapsed_ms / stable_ms / min_hold_ms). Without
|
|
338
|
+
* this, a state whose only exit is time-based would never leave once the
|
|
339
|
+
* PTY goes quiet. */
|
|
340
|
+
private scheduleWakeForState;
|
|
341
|
+
/** True when this spec opts into stall recovery (declares a positive
|
|
342
|
+
* refocus window AND a wake sequence to re-inject). */
|
|
343
|
+
private stallRecoveryEnabled;
|
|
344
|
+
/** Wall-clock time the screen last changed in the current state, falling
|
|
345
|
+
* back to state entry when it has not changed since (i.e. fully stalled
|
|
346
|
+
* from the start of the state). */
|
|
347
|
+
private lastScreenChangeAt;
|
|
348
|
+
/** Arm a timer to re-inject the focus-in prime if the screen stays frozen
|
|
349
|
+
* through a `generating` state. Only active for opted-in focus-gated specs;
|
|
350
|
+
* a no-op (and cleared) for every other CLI and every non-generating state.
|
|
351
|
+
* Re-arms itself so it keeps watching while the PTY is quiet. */
|
|
352
|
+
private scheduleStallWatchdog;
|
|
353
|
+
/** Fire when the stall window elapses: if the screen is still frozen and we
|
|
354
|
+
* are still generating, re-inject the focus-in wake once, then re-arm. */
|
|
355
|
+
private onStallTick;
|
|
356
|
+
private maybeMarkReady;
|
|
357
|
+
private fireNotifications;
|
|
358
|
+
private armOrCancelDelegateTimers;
|
|
359
|
+
private fireDelegate;
|
|
360
|
+
private handleSendMessage;
|
|
361
|
+
private actuallySendMessage;
|
|
362
|
+
/** The agent's current coarse status, derived from the FSM node we're in. */
|
|
363
|
+
private currentStatus;
|
|
364
|
+
/** Record a win32 body write so the settle-gate counts it as input activity
|
|
365
|
+
* even before the echo arrives. */
|
|
366
|
+
private markWin32Write;
|
|
367
|
+
/** Most recent win32 input activity — a write we issued OR a PTY output chunk
|
|
368
|
+
* (echo). The submit settle-gate waits for this to go quiet. */
|
|
369
|
+
private lastWin32InputActivityAt;
|
|
370
|
+
/**
|
|
371
|
+
* Write the message body to the PTY for win32, paced into bounded chunks. A
|
|
372
|
+
* single unbounded ConPTY write can overflow the input pipe and drop leading
|
|
373
|
+
* bytes; splitting it with a short inter-chunk gap keeps the console input
|
|
374
|
+
* buffer from overflowing. Small bodies still go out in a single write. Each
|
|
375
|
+
* write advances lastWin32WriteAt so the submit settle-gate keeps waiting until
|
|
376
|
+
* the final segment is out and echoed.
|
|
377
|
+
*
|
|
378
|
+
* FIX-B-v2: a body that contains an embedded newline cannot be written raw —
|
|
379
|
+
* on the real win32 Ink/ConPTY composer each '\n' SUBMITS the preceding line as
|
|
380
|
+
* its own entry, truncating the prompt to only the tail fragment. So a
|
|
381
|
+
* newline-bearing body is rewritten so its embedded newlines never submit:
|
|
382
|
+
* - 'paste' (default): wrap the body in a bracketed-paste (ESC[200~ … ESC[201~)
|
|
383
|
+
* — the composer takes the whole thing, newlines and all, as pasted text.
|
|
384
|
+
* - 'soft_newline': replace each embedded newline with a non-submitting
|
|
385
|
+
* Shift+Enter (CSI-u) so the body is typed as one multi-line entry.
|
|
386
|
+
* The trailing submit CR is NOT written here — it stays separate and is fired
|
|
387
|
+
* later by scheduleWin32Submit (concern (A)). The bracketed-paste markers are
|
|
388
|
+
* written as their own atomic segments (never chunked), so chunking can never
|
|
389
|
+
* split ESC[200~ / ESC[201~ mid-sequence regardless of body length.
|
|
390
|
+
*/
|
|
391
|
+
private writeWin32Body;
|
|
392
|
+
/**
|
|
393
|
+
* win32 submit. Two phases:
|
|
394
|
+
*
|
|
395
|
+
* Phase 1 (echo-gate): hold the first CR until the body text is CONFIRMED in the
|
|
396
|
+
* composer (its whitespace-collapsed tail appears in the rendered screen) AND the
|
|
397
|
+
* PTY output is then quiet for WIN32_SUBMIT_SETTLE_MS (the full, possibly multi-KB
|
|
398
|
+
* / multiline body has finished arriving). This replaces a bare output-quiet
|
|
399
|
+
* settle: an early write that races claude's boot is buffered, not dropped, so the
|
|
400
|
+
* screen can go quiet with the body NOT YET in the composer — a quiet-only gate
|
|
401
|
+
* would then fire a CR into an empty composer (no submit). Waiting on the echo
|
|
402
|
+
* closes that. Honors an initial minimum delay and a generous WIN32_ECHO_MAX_WAIT_MS
|
|
403
|
+
* last-resort blind fire so a body that truly never confirms still submits (carried
|
|
404
|
+
* by phase 2) rather than hanging. A settled session echoes immediately → no delay.
|
|
405
|
+
*
|
|
406
|
+
* Phase 2 (verified resend — unchanged): send the submit key, wait a gap, and
|
|
407
|
+
* if the FSM is still 'idle' (the CR was absorbed as a multiline-paste
|
|
408
|
+
* newline) resend, up to WIN32_SUBMIT_MAX_RESENDS. The first CR always fires
|
|
409
|
+
* (a stale/edge status never suppresses it); resends are gated on still being
|
|
410
|
+
* idle and stop the instant the agent leaves idle (submitted → generating /
|
|
411
|
+
* approval). This preserves the win32 lone-CR-swallow handling.
|
|
412
|
+
*/
|
|
413
|
+
private scheduleWin32Submit;
|
|
414
|
+
private handleClickControl;
|
|
415
|
+
private handleClickModalButton;
|
|
416
|
+
/**
|
|
417
|
+
* Submit a modal-confirm key sequence (the choice key + its trailing CR).
|
|
418
|
+
*
|
|
419
|
+
* On win32 the trailing CR is the SAME lone-CR-swallow case as a send_message
|
|
420
|
+
* submit: ConPTY can absorb a single CR as a literal newline instead of a
|
|
421
|
+
* confirm, so the approval/picker modal never resolves and the FSM flaps
|
|
422
|
+
* approval↔busy while auto-approve keeps firing into the void (APPROVESTUCK).
|
|
423
|
+
* So we split any non-CR prefix (e.g. the "1" of "1\r") off, write it once, and
|
|
424
|
+
* resend the CR on a fixed cadence until the modal actually resolves (status
|
|
425
|
+
* leaves 'approval'). Non-win32 keeps the single direct write — its CR submits
|
|
426
|
+
* on the first try.
|
|
427
|
+
*/
|
|
428
|
+
private submitModalConfirm;
|
|
429
|
+
/**
|
|
430
|
+
* win32 modal-confirm CR resend loop. Mirrors scheduleWin32Submit's phase-2
|
|
431
|
+
* verified resend, but gated on still being IN a modal (status 'approval')
|
|
432
|
+
* rather than still idle: the first CR fires immediately, then resends every
|
|
433
|
+
* WIN32_SUBMIT_RESEND_GAP_MS while the FSM is still showing the modal, up to
|
|
434
|
+
* WIN32_SUBMIT_MAX_RESENDS. The instant the modal resolves (status flips to
|
|
435
|
+
* generating/idle) we stop, so no stray CR leaks into the next turn's composer.
|
|
436
|
+
*/
|
|
437
|
+
private scheduleWin32ModalConfirm;
|
|
438
|
+
private handleAttachImage;
|
|
439
|
+
private tryAdvancePicker;
|
|
440
|
+
private handleExit;
|
|
441
|
+
private pushHistory;
|
|
442
|
+
private specTag;
|
|
443
|
+
private emit;
|
|
444
|
+
}
|
|
445
|
+
/** Drop lines matching `ignoreRe` so a per-frame repaint confined to them does
|
|
446
|
+
* not register as a region change. No filter → lines returned unchanged.
|
|
447
|
+
* Exported for unit tests of the stable_ms `ignore_lines` change-detection. */
|
|
448
|
+
export declare function filterIgnoredLines(lines: string[], ignoreRe: RegExp | undefined): string[];
|
|
449
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { SectionDef } from './types.js';
|
|
2
|
+
import { type ResolvedSection, type TraceEntry } from './evaluator.js';
|
|
3
|
+
import { type CliSpecV4, type FsmCondition } from './fsm-types.js';
|
|
4
|
+
export interface FsmClock {
|
|
5
|
+
/** Wall-clock now (ms). Passed in so the evaluator stays pure. */
|
|
6
|
+
now: number;
|
|
7
|
+
/** When the current state was entered (ms). */
|
|
8
|
+
stateEnteredAt: number;
|
|
9
|
+
/** Last-changed timestamp per stable region. Numeric key = cursor_above
|
|
10
|
+
* value (0 / undefined → whole-screen, keyed as -1). String key =
|
|
11
|
+
* `section:<id>` for a section-scoped stable region. Missing key means
|
|
12
|
+
* "never observed changing" → treated as stable since stateEnteredAt. */
|
|
13
|
+
regionLastChangedAt: Map<number | string, number>;
|
|
14
|
+
}
|
|
15
|
+
/** Per-condition evaluation detail — the debugging payload. */
|
|
16
|
+
export interface CondResult {
|
|
17
|
+
kind: 'regex' | 'changed' | 'elapsed' | 'stable' | 'all' | 'any' | 'not';
|
|
18
|
+
result: boolean;
|
|
19
|
+
detail: string;
|
|
20
|
+
/** Remaining ms until a time-based condition would flip to true. 0 if
|
|
21
|
+
* already true or not applicable. Lets the UI show a countdown. */
|
|
22
|
+
remainingMs?: number;
|
|
23
|
+
/** Debug-only: the actual substring a TRUE regex condition matched, so the
|
|
24
|
+
* snapshot shows WHAT text the rule fired on — not just which regex. Never
|
|
25
|
+
* read by the FSM; purely for the Spec Debug Snapshot. */
|
|
26
|
+
matchedText?: string;
|
|
27
|
+
children?: CondResult[];
|
|
28
|
+
}
|
|
29
|
+
/** One evaluated transition with its full reasoning. */
|
|
30
|
+
export interface TransitionEval {
|
|
31
|
+
to: string;
|
|
32
|
+
label: string;
|
|
33
|
+
/** Did the `from` clause include the current state? (Always true for the
|
|
34
|
+
* transitions we return — kept for completeness.) */
|
|
35
|
+
eligible: boolean;
|
|
36
|
+
/** min_hold_ms guard satisfied? */
|
|
37
|
+
holdSatisfied: boolean;
|
|
38
|
+
holdRemainingMs: number;
|
|
39
|
+
/** Guard condition result (true if no `when`). */
|
|
40
|
+
condResult: boolean;
|
|
41
|
+
cond?: CondResult;
|
|
42
|
+
/** Overall: would this transition fire? */
|
|
43
|
+
fires: boolean;
|
|
44
|
+
priority: number;
|
|
45
|
+
}
|
|
46
|
+
export interface FsmEvaluation {
|
|
47
|
+
/** Sections resolved from the screen (shared with v3 shape). */
|
|
48
|
+
sections: ResolvedSection[];
|
|
49
|
+
/** Every outgoing transition from the current state, priority-ordered,
|
|
50
|
+
* each annotated with why it fired or didn't. */
|
|
51
|
+
transitions: TransitionEval[];
|
|
52
|
+
/** The transition that fires (first in priority order with fires===true),
|
|
53
|
+
* or null to stay in the current state. */
|
|
54
|
+
fired: TransitionEval | null;
|
|
55
|
+
/** v3-compatible trace lines for the legacy inspector. */
|
|
56
|
+
trace: TraceEntry[];
|
|
57
|
+
}
|
|
58
|
+
/** The `regionLastChangedAt` key for a stable condition. The key must capture
|
|
59
|
+
* everything that makes two stable clauses watch a DIFFERENT change signal:
|
|
60
|
+
* the geometric region (`section` wins over `cursor_above`, else whole-screen)
|
|
61
|
+
* AND the `ignore_lines` filter (two clauses on the same region but different
|
|
62
|
+
* ignore patterns see different "did it change" answers). Kept in one place so
|
|
63
|
+
* the driver (which populates the map) and the evaluator (which reads it)
|
|
64
|
+
* agree on the key.
|
|
65
|
+
*
|
|
66
|
+
* Bare whole-screen with no ignore filter keeps its historical numeric key -1
|
|
67
|
+
* so existing callers/tests that seed `regionLastChangedAt` with [-1, ...]
|
|
68
|
+
* keep working unchanged. */
|
|
69
|
+
export declare function stableRegionKey(cond: {
|
|
70
|
+
section?: string;
|
|
71
|
+
cursor_above?: number;
|
|
72
|
+
ignore_lines?: string;
|
|
73
|
+
}): number | string;
|
|
74
|
+
/**
|
|
75
|
+
* Evaluate the FSM: given the current state id and screen, return every
|
|
76
|
+
* outgoing transition annotated with why it fires/doesn't, plus the one that
|
|
77
|
+
* fires (if any).
|
|
78
|
+
*/
|
|
79
|
+
export declare function evaluateFsm(spec: CliSpecV4, currentStateId: string, screenText: string, cursor: {
|
|
80
|
+
row: number;
|
|
81
|
+
col: number;
|
|
82
|
+
} | undefined, prevLines: string[] | undefined, clock: FsmClock): FsmEvaluation;
|
|
83
|
+
/**
|
|
84
|
+
* Evaluate a single condition against a screen + section map — for the spec
|
|
85
|
+
* editor's live preview ("does this regex match the current screen right
|
|
86
|
+
* now?"). Time leaves (elapsed_ms/stable_ms) are evaluated against a synthetic
|
|
87
|
+
* clock where the state was just entered, so they report their countdown
|
|
88
|
+
* rather than firing; the preview is about screen-content match, not timing.
|
|
89
|
+
*/
|
|
90
|
+
export declare function evaluateConditionPreview(cond: FsmCondition, sections: Record<string, SectionDef> | undefined, screenText: string, cursor?: {
|
|
91
|
+
row: number;
|
|
92
|
+
col: number;
|
|
93
|
+
}): CondResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CliSpecV4 } from './fsm-types.js';
|
|
2
|
+
export interface FsmLoadOk {
|
|
3
|
+
ok: true;
|
|
4
|
+
spec: CliSpecV4;
|
|
5
|
+
sourcePath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FsmLoadErr {
|
|
8
|
+
ok: false;
|
|
9
|
+
errors: string[];
|
|
10
|
+
sourcePath: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function loadFsmSpec(sourcePath: string): FsmLoadOk | FsmLoadErr;
|
|
13
|
+
/** Pure validator — usable from a "validate before save" API in the panel. */
|
|
14
|
+
export declare function validateFsmSpec(raw: unknown): string[];
|