@adhdev/daemon-core 0.9.82-rc.35 → 0.9.82-rc.350
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 +8 -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 +46 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +198 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +116 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +53 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +14 -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/cli-manager.d.ts +2 -1
- package/dist/commands/handler.d.ts +110 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +324 -1
- package/dist/commands/upgrade-helper.d.ts +12 -0
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +77 -1
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/change-impact-config.d.ts +159 -0
- package/dist/git/git-commands.d.ts +11 -1
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +23 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/index.d.ts +2 -0
- package/dist/index.d.ts +52 -13
- package/dist/index.js +39739 -14302
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41369 -16055
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/logging/log-redactor.d.ts +24 -0
- package/dist/logging/log-tail-reader.d.ts +46 -0
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +36 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +174 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +169 -0
- package/dist/mesh/mesh-events-pending.d.ts +55 -0
- package/dist/mesh/mesh-events-stale.d.ts +40 -0
- package/dist/mesh/mesh-events-utils.d.ts +62 -0
- package/dist/mesh/mesh-events.d.ts +6 -49
- package/dist/mesh/mesh-fast-forward.d.ts +81 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-init.d.ts +86 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-missions.d.ts +164 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +419 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
- package/dist/mesh/mesh-work-queue.d.ts +218 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +216 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
- package/dist/providers/acp-provider-instance.d.ts +2 -0
- package/dist/providers/approval-utils.d.ts +13 -0
- package/dist/providers/chat-message-normalization.d.ts +12 -0
- package/dist/providers/cli-provider-instance.d.ts +77 -3
- package/dist/providers/contracts.d.ts +139 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/dispatcher.d.ts +27 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +14 -0
- package/dist/providers/provider-instance.d.ts +15 -1
- package/dist/providers/provider-loader.d.ts +26 -4
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -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 +69 -0
- package/dist/providers/spec/cli-adapter.d.ts +217 -0
- package/dist/providers/spec/evaluator.d.ts +23 -0
- package/dist/providers/spec/fsm-driver.d.ts +322 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +72 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +144 -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 +180 -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 +295 -13
- package/dist/sessions/registry.d.ts +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +59 -2
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +26 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -3
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +55 -12
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +1 -0
- package/src/cli-adapter-types.ts +47 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1215 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +774 -1141
- package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
- package/src/cli-adapters/provider-cli-parse.ts +13 -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 +100 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +90 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -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.ts +1823 -62
- package/src/commands/cli-manager.ts +304 -14
- package/src/commands/handler.ts +809 -2
- package/src/commands/mesh-coordinator.ts +332 -122
- package/src/commands/router.ts +7505 -1311
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +81 -30
- package/src/config/chat-history.ts +483 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +388 -6
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/detection/cli-detector.ts +28 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +55 -14
- package/src/git/git-diff.ts +53 -0
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +574 -43
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +8 -1
- package/src/git/index.ts +16 -0
- package/src/index.ts +146 -12
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/log-redactor.ts +100 -0
- package/src/logging/log-tail-reader.ts +220 -0
- package/src/logging/logger.ts +2 -1
- package/src/mesh/contracts.ts +329 -0
- package/src/mesh/coordinator-prompt.ts +234 -31
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +623 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-events-coordinator.ts +2224 -0
- package/src/mesh/mesh-events-pending.ts +558 -0
- package/src/mesh/mesh-events-stale.ts +290 -0
- package/src/mesh/mesh-events-utils.ts +381 -0
- package/src/mesh/mesh-events.ts +30 -1035
- package/src/mesh/mesh-fast-forward.ts +839 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-init.ts +260 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
- package/src/mesh/mesh-ledger.ts +590 -102
- package/src/mesh/mesh-missions.ts +322 -0
- package/src/mesh/mesh-reconcile-loop.ts +989 -0
- package/src/mesh/mesh-refine-batch.ts +197 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-review-inbox.ts +307 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +1660 -0
- package/src/mesh/mesh-task-stats.ts +154 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
- package/src/mesh/mesh-work-queue.ts +901 -141
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +423 -0
- package/src/mesh/worktree-bootstrap-config.ts +331 -0
- package/src/providers/acp-provider-instance.ts +25 -9
- package/src/providers/approval-utils.d.ts +4 -0
- package/src/providers/approval-utils.ts +47 -5
- package/src/providers/chat-message-normalization.ts +45 -5
- package/src/providers/cli-provider-instance.ts +1041 -99
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +150 -6
- package/src/providers/extension-provider-instance.ts +12 -7
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +35 -12
- package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +479 -0
- package/src/providers/native-history/dispatcher.ts +340 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +30 -0
- package/src/providers/provider-instance.ts +10 -1
- package/src/providers/provider-loader.ts +670 -50
- package/src/providers/provider-schema.ts +87 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +168 -0
- package/src/providers/spec/cli-adapter.ts +986 -0
- package/src/providers/spec/evaluator.ts +345 -0
- package/src/providers/spec/fsm-driver.ts +1065 -0
- package/src/providers/spec/fsm-evaluator.ts +255 -0
- package/src/providers/spec/fsm-loader.ts +120 -0
- package/src/providers/spec/fsm-types.ts +238 -0
- package/src/providers/spec/native-history-executor.ts +1136 -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 +226 -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 +378 -14
- package/src/sessions/registry.ts +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +64 -1
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +95 -26
- package/src/system/host-memory.ts +29 -12
- package/src/system/load-better-sqlite3.ts +68 -0
- package/src/types.ts +5 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
|
|
2
|
+
export type { PtyTransportFactory };
|
|
3
|
+
export interface TerminalAdapterOpts {
|
|
4
|
+
binary: string;
|
|
5
|
+
args?: string[];
|
|
6
|
+
cwd?: string;
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* When true, `env` is already a COMPLETE, sanitized environment (the spawn
|
|
10
|
+
* planner merged + stripped process.env already) and must be passed to the
|
|
11
|
+
* PTY verbatim — NOT overlaid on top of process.env. Overlaying would
|
|
12
|
+
* re-introduce the npm_/PNPM_/parent-session keys the planner explicitly
|
|
13
|
+
* stripped, so the spec path's spawn env would diverge from the legacy
|
|
14
|
+
* path's. Defaults to false (legacy overlay behaviour) for any caller that
|
|
15
|
+
* still passes a partial env.
|
|
16
|
+
*/
|
|
17
|
+
envIsComplete?: boolean;
|
|
18
|
+
cols?: number;
|
|
19
|
+
rows?: number;
|
|
20
|
+
/** Coalesce screen snapshots: emit on_screen_changed at most this often. */
|
|
21
|
+
screenChangeDebounceMs?: number;
|
|
22
|
+
tickIntervalMs?: number;
|
|
23
|
+
transportFactory?: PtyTransportFactory;
|
|
24
|
+
}
|
|
25
|
+
export interface TerminalAdapterHandlers {
|
|
26
|
+
init?(info: {
|
|
27
|
+
pid: number;
|
|
28
|
+
}): void;
|
|
29
|
+
on_pty_data?(chunk: string): void;
|
|
30
|
+
on_screen_changed?(snapshot: string): void;
|
|
31
|
+
on_exit?(info: {
|
|
32
|
+
exitCode: number;
|
|
33
|
+
}): void;
|
|
34
|
+
tick?(): void;
|
|
35
|
+
}
|
|
36
|
+
export declare class TerminalAdapter {
|
|
37
|
+
private readonly opts;
|
|
38
|
+
private readonly handlers;
|
|
39
|
+
private rows;
|
|
40
|
+
private cols;
|
|
41
|
+
private readonly screenDebounceMs;
|
|
42
|
+
private readonly tickIntervalMs;
|
|
43
|
+
private readonly factory;
|
|
44
|
+
private screen;
|
|
45
|
+
private pty;
|
|
46
|
+
private screenTimer;
|
|
47
|
+
private tickTimer;
|
|
48
|
+
private lastScreen;
|
|
49
|
+
constructor(opts: TerminalAdapterOpts, handlers: TerminalAdapterHandlers);
|
|
50
|
+
start(): void;
|
|
51
|
+
resize(cols: number, rows: number): void;
|
|
52
|
+
snapshot(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Full-buffer snapshot including scrollback history. Unlike snapshot()
|
|
55
|
+
* (visible viewport only), this survives a tall prompt whose top has
|
|
56
|
+
* scrolled off-screen — used for content-pattern extraction (modal
|
|
57
|
+
* buttons / approval anchors), NOT for cursor-relative conditions.
|
|
58
|
+
*/
|
|
59
|
+
snapshotWithScrollback(): string;
|
|
60
|
+
getCursorPosition(): {
|
|
61
|
+
row: number;
|
|
62
|
+
col: number;
|
|
63
|
+
};
|
|
64
|
+
send_keys(text: string): void;
|
|
65
|
+
kill(): void;
|
|
66
|
+
private onChunk;
|
|
67
|
+
private computeScreen;
|
|
68
|
+
private stopTimers;
|
|
69
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { CliAdapter, CliAdapterStatus } from '../../cli-adapter-types.js';
|
|
2
|
+
import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
|
|
3
|
+
import { type InteractivePromptResponse } from '../types/interactive-prompt.js';
|
|
4
|
+
export declare class SpecCliAdapter implements CliAdapter {
|
|
5
|
+
readonly cliType: string;
|
|
6
|
+
readonly cliName: string;
|
|
7
|
+
readonly workingDir: string;
|
|
8
|
+
/**
|
|
9
|
+
* Marker the daemon's finalization gate checks: `getStatus()` returns
|
|
10
|
+
* `messages: []` by design here (chat history lives in the daemon's
|
|
11
|
+
* native-history pipeline, not the adapter). Without this flag,
|
|
12
|
+
* cli-provider-instance's `missing_final_assistant` gate would stall
|
|
13
|
+
* every turn until the 30s safety timeout because it expects the
|
|
14
|
+
* adapter to surface the final assistant message.
|
|
15
|
+
*/
|
|
16
|
+
readonly chatMessagesOwnedExternally: true;
|
|
17
|
+
private driver;
|
|
18
|
+
/** Common spec fields the adapter reads, present in both v3 and v4. */
|
|
19
|
+
private spec;
|
|
20
|
+
private lastEvent;
|
|
21
|
+
private latestState;
|
|
22
|
+
private latestModal;
|
|
23
|
+
private statusCallback;
|
|
24
|
+
private ptyDataCallback;
|
|
25
|
+
private partialResponse;
|
|
26
|
+
private activeInteractivePrompt;
|
|
27
|
+
private interactivePromptTransport;
|
|
28
|
+
private claudeTuiPromptCaptureInFlight;
|
|
29
|
+
/**
|
|
30
|
+
* Wall clock of the first frame on which a held interactive prompt was
|
|
31
|
+
* observed to have left the screen. Mirrors the approval FSM's
|
|
32
|
+
* `modalLostAt` hysteresis (see cli-state-engine.ts): claude-cli's TUI
|
|
33
|
+
* repaints the choice picker as several PTY chunks, so a single frame
|
|
34
|
+
* with no "Enter to select" footer is not proof the prompt is gone — it
|
|
35
|
+
* may just be mid-repaint. We only clear the held prompt once it has
|
|
36
|
+
* been absent across a short grace window. Reset to null the moment the
|
|
37
|
+
* prompt footer reappears.
|
|
38
|
+
*
|
|
39
|
+
* Without this, a choice prompt resolved *directly in the terminal* (the
|
|
40
|
+
* user picked an option without going through ADHDev's
|
|
41
|
+
* setInteractivePromptResponse) was never cleared from
|
|
42
|
+
* `activeInteractivePrompt`, so getStatus() re-emitted the same prompt
|
|
43
|
+
* forever — the choice-resolve-stuck bug.
|
|
44
|
+
*/
|
|
45
|
+
private interactivePromptLostAt;
|
|
46
|
+
private jsonLineTail;
|
|
47
|
+
private exited;
|
|
48
|
+
private spawned;
|
|
49
|
+
private providerSessionId;
|
|
50
|
+
/** Wall clock at the moment spawn() ran. Used as the cutoff for
|
|
51
|
+
* native-history file selection so a prior session's transcript
|
|
52
|
+
* can't leak into this session before the agent has written its
|
|
53
|
+
* own records. */
|
|
54
|
+
private spawnedAtMs;
|
|
55
|
+
/** Env vars the daemon set on the spawned child. Mesh coordinator
|
|
56
|
+
* points hermes at a per-coordinator HERMES_HOME so the dashboard's
|
|
57
|
+
* native-history reader needs that override to find the right
|
|
58
|
+
* state.db; without it the reader sees ~/.hermes/state.db which
|
|
59
|
+
* the coordinator-launched hermes never writes to. The choice to
|
|
60
|
+
* redirect HERMES_HOME is a workaround for an unresolved hermes
|
|
61
|
+
* upstream feature gap (see hermes-agent#23130 — runtime-supplied
|
|
62
|
+
* MCP config), so this routing keeps the dashboard honest until
|
|
63
|
+
* hermes ships a runtime MCP override. */
|
|
64
|
+
private spawnedEnv;
|
|
65
|
+
constructor(specPath: string, workingDir: string, cliArgs: string[], extraEnv: Record<string, string>, transportFactory?: PtyTransportFactory);
|
|
66
|
+
spawn(): Promise<void>;
|
|
67
|
+
sendMessage(text: string): Promise<void>;
|
|
68
|
+
getStatus(): CliAdapterStatus;
|
|
69
|
+
private maybeRefreshNativeHistory;
|
|
70
|
+
getScriptParsedStatus(): unknown;
|
|
71
|
+
getPartialResponse(): string;
|
|
72
|
+
shutdown(): void;
|
|
73
|
+
cancel(): void;
|
|
74
|
+
isProcessing(): boolean;
|
|
75
|
+
isReady(): boolean;
|
|
76
|
+
setOnStatusChange(cb: () => void): void;
|
|
77
|
+
setOnPtyData(cb: (data: string) => void): void;
|
|
78
|
+
writeRaw(data: string): void;
|
|
79
|
+
resize(cols: number, rows: number): void;
|
|
80
|
+
resolveModal(buttonIndex: number): void;
|
|
81
|
+
resolveAction(data: unknown): Promise<void>;
|
|
82
|
+
setInteractivePromptResponse(response: InteractivePromptResponse): Promise<void>;
|
|
83
|
+
isApprovalRecentlyResolved(): boolean;
|
|
84
|
+
clearHistory(): void;
|
|
85
|
+
updateRuntimeSettings(): void;
|
|
86
|
+
setServerConn(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Map an invokeScript(name, args) call onto a control_bar entry.
|
|
89
|
+
*
|
|
90
|
+
* scriptName is matched against control.id. The control's action.type
|
|
91
|
+
* drives the dispatch:
|
|
92
|
+
*
|
|
93
|
+
* send_keys → click_control (e.g. stop)
|
|
94
|
+
* open_picker → two roles, driven by the screen, not a hardcoded list:
|
|
95
|
+
* - LIST (no choice arg): open the picker, wait for it
|
|
96
|
+
* to render, parse the on-screen options via
|
|
97
|
+
* `extract_choices`, and return them as
|
|
98
|
+
* `controlResult.options` (+ `currentValue`). This is
|
|
99
|
+
* how the dashboard's Model/Mode controls learn what is
|
|
100
|
+
* actually selectable in this CLI right now.
|
|
101
|
+
* - SELECT (args.choiceIndex / args.choiceLabel): drive
|
|
102
|
+
* the picker to that option using `submit_key`.
|
|
103
|
+
* attach_image → attach_image dispatch; expects args.blob (data url
|
|
104
|
+
* or base64) and args.mime
|
|
105
|
+
*
|
|
106
|
+
* Callers that pass an unknown control id get a { not_found } response.
|
|
107
|
+
* No control matched, no driver call — keeps the surface honest.
|
|
108
|
+
*/
|
|
109
|
+
invokeScript(scriptName: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* Open an `open_picker` control and return the options the CLI is showing,
|
|
112
|
+
* parsed live from the screen via `extract_choices`. Nothing is selected —
|
|
113
|
+
* the picker is left open so a follow-up SELECT invoke can commit a choice.
|
|
114
|
+
*/
|
|
115
|
+
private openPickerAndListChoices;
|
|
116
|
+
/**
|
|
117
|
+
* Drive an already-listable picker to a specific option. The option can be
|
|
118
|
+
* named (choiceLabel — matched against the parsed on-screen labels) or
|
|
119
|
+
* positional (choiceIndex — the on-screen number). The actual keystrokes
|
|
120
|
+
* come from the spec's `submit_key` with `{index}` substituted, so the spec
|
|
121
|
+
* — not this code — decides how a selection is keyed for each CLI.
|
|
122
|
+
*/
|
|
123
|
+
private selectPickerChoice;
|
|
124
|
+
/** Poll the live screen until the picker's `wait_for` condition matches,
|
|
125
|
+
* up to a short budget. Returns true if it rendered, false on timeout. */
|
|
126
|
+
private waitForPickerRendered;
|
|
127
|
+
/** Parse the picker's `extract_choices` pattern against the live screen.
|
|
128
|
+
* Each match yields { index, label, current }. `current` is true for the
|
|
129
|
+
* line the CLI marks with its cursor glyph (❯ ›). Purely screen-driven —
|
|
130
|
+
* no model/mode names are baked in. */
|
|
131
|
+
private extractPickerChoices;
|
|
132
|
+
/** Live text of a named screen section (or the whole screen when no
|
|
133
|
+
* section is named), resolved from the driver's current sections. */
|
|
134
|
+
private readScreenSectionText;
|
|
135
|
+
getDebugSnapshot(): unknown;
|
|
136
|
+
getRuntimeMetadata(): unknown;
|
|
137
|
+
updateRuntimeMeta(meta?: Record<string, unknown>): void;
|
|
138
|
+
refreshProviderDefinition(): void;
|
|
139
|
+
private handleEvent;
|
|
140
|
+
private detectInteractivePromptFromPtyChunk;
|
|
141
|
+
private readCurrentScreenSections;
|
|
142
|
+
private extractProviderSessionIdFromScreen;
|
|
143
|
+
private readClaudeScreenAssistantMessages;
|
|
144
|
+
/**
|
|
145
|
+
* Grace window a held interactive prompt must be absent from the screen
|
|
146
|
+
* before we treat it as resolved-in-terminal and clear it. claude-cli
|
|
147
|
+
* repaints the picker across multiple PTY chunks, so a single
|
|
148
|
+
* footer-less frame is not proof the prompt is gone. Sized in the same
|
|
149
|
+
* spirit as the approval FSM's `approvalCooldown` modal-lost hysteresis.
|
|
150
|
+
*/
|
|
151
|
+
private static readonly INTERACTIVE_PROMPT_LOST_GRACE_MS;
|
|
152
|
+
/**
|
|
153
|
+
* Multi-question TUI capture: after Tabbing to a page, re-snapshot at this
|
|
154
|
+
* interval until its checkbox glyph column has settled, up to the timeout.
|
|
155
|
+
* The interval matches the legacy single fixed wait (120ms); the timeout
|
|
156
|
+
* bounds total capture time so a single-select page (which never shows
|
|
157
|
+
* glyphs) doesn't stall the capture indefinitely.
|
|
158
|
+
*/
|
|
159
|
+
private static readonly CLAUDE_TUI_PAGE_POLL_INTERVAL_MS;
|
|
160
|
+
private static readonly CLAUDE_TUI_PAGE_SETTLE_TIMEOUT_MS;
|
|
161
|
+
/**
|
|
162
|
+
* Clear a held interactive prompt once the user has resolved it directly
|
|
163
|
+
* in the terminal (the choice picker leaves the screen without going
|
|
164
|
+
* through setInteractivePromptResponse). The approval path already does
|
|
165
|
+
* this via the FSM's modal-lost hysteresis; the interactive-prompt path
|
|
166
|
+
* had no equivalent, so a terminal-side answer left activeInteractivePrompt
|
|
167
|
+
* set and getStatus() re-emitted the same choice modal forever.
|
|
168
|
+
*
|
|
169
|
+
* Detection mirrors capture: the claude TUI picker is on-screen exactly
|
|
170
|
+
* while its "Enter to select" footer is rendered. When the footer is gone
|
|
171
|
+
* for INTERACTIVE_PROMPT_LOST_GRACE_MS the prompt is genuinely resolved.
|
|
172
|
+
*/
|
|
173
|
+
private maybeClearResolvedClaudeTuiPrompt;
|
|
174
|
+
private maybeCaptureClaudeTuiPrompt;
|
|
175
|
+
/**
|
|
176
|
+
* The TUI prompt is captured on the FIRST frame that renders the
|
|
177
|
+
* "Enter to select" footer. At that instant the option rows' checkbox
|
|
178
|
+
* column may not have drawn yet, so `detectClaudeTuiMultiSelect` returns
|
|
179
|
+
* false and the prompt is frozen as single-select — the dashboard then
|
|
180
|
+
* renders radio buttons even though the picker is multi-select.
|
|
181
|
+
*
|
|
182
|
+
* While the same TUI prompt is still on screen, re-check the live snapshot:
|
|
183
|
+
* if checkbox glyphs have since appeared, promote any single-select
|
|
184
|
+
* question to multi-select and re-emit status. Promotion is one-way
|
|
185
|
+
* (false→true only) — once a question is known multi-select we never demote
|
|
186
|
+
* it, since the glyph column can scroll out of view on later frames.
|
|
187
|
+
*
|
|
188
|
+
* For MULTI-question prompts the per-page Tab capture is the actual source
|
|
189
|
+
* of the bug: pages 2..N are snapshotted ~120ms after the Tab keypress,
|
|
190
|
+
* before their option-row glyph column has redrawn, so those questions
|
|
191
|
+
* freeze as single-select while page 1 (already settled) is correct. We
|
|
192
|
+
* cannot upgrade blindly — the live snapshot shows only ONE focused page —
|
|
193
|
+
* but we CAN read that page's question text/header and upgrade the matching
|
|
194
|
+
* question. As the user navigates the picker (or it settles), each page is
|
|
195
|
+
* eventually re-read and repaired.
|
|
196
|
+
*/
|
|
197
|
+
private maybeUpgradeClaudeTuiMultiSelect;
|
|
198
|
+
private readClaudeTuiHeaders;
|
|
199
|
+
/**
|
|
200
|
+
* Snapshot the currently-focused claude TUI page, polling until its
|
|
201
|
+
* option-row checkbox glyph column has settled (or a bounded timeout).
|
|
202
|
+
*
|
|
203
|
+
* Why poll: right after a Tab keypress the newly-focused page's glyph
|
|
204
|
+
* column has not redrawn yet, so an immediate snapshot shows the question +
|
|
205
|
+
* option labels but NO per-option checkbox markers — freezing that page as
|
|
206
|
+
* single-select. A fixed delay either races (too short) or is wasteful (too
|
|
207
|
+
* long). Instead we re-snapshot at a fixed interval and stop as soon as the
|
|
208
|
+
* frame shows multi-select glyphs, falling back to the last frame at the
|
|
209
|
+
* timeout. Single-select pages never show glyphs, so they always poll to the
|
|
210
|
+
* timeout — bounded small to keep capture snappy.
|
|
211
|
+
*/
|
|
212
|
+
private snapshotSettledClaudeTuiPage;
|
|
213
|
+
private captureClaudeTuiPrompt;
|
|
214
|
+
getDebugState(): Record<string, any>;
|
|
215
|
+
getTraceState(limit?: number): Record<string, any>;
|
|
216
|
+
getProviderResolutionMeta(): Record<string, any>;
|
|
217
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SectionDef, Condition, ExtractTitle, ExtractButtons } from './types.js';
|
|
2
|
+
export interface ResolvedSection {
|
|
3
|
+
id: string;
|
|
4
|
+
fromLine: number;
|
|
5
|
+
toLine: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TraceEntry {
|
|
9
|
+
kind: 'section' | 'state_match' | 'state_skip' | 'modal' | 'control' | 'notification' | 'delegate';
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function resolveSections(sectionsObj: Record<string, SectionDef>, lines: string[]): ResolvedSection[];
|
|
13
|
+
export declare function sectionText(sections: ResolvedSection[], sectionId: string | undefined, fullScreen: string): string;
|
|
14
|
+
export declare function evaluateCondition(cond: Condition, sections: ResolvedSection[], fullScreen: string, cursor: {
|
|
15
|
+
row: number;
|
|
16
|
+
col: number;
|
|
17
|
+
} | undefined, prevLines: string[] | undefined, trace: TraceEntry[], stateId: string): boolean;
|
|
18
|
+
export declare function extractTitle(rule: ExtractTitle, sections: ResolvedSection[], fullScreen: string): string | null;
|
|
19
|
+
export declare function extractButtonsFromRule(rule: ExtractButtons, hay: string): {
|
|
20
|
+
index: number;
|
|
21
|
+
label: string;
|
|
22
|
+
key: string;
|
|
23
|
+
}[];
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
|
|
2
|
+
import { type TraceEntry } from './evaluator.js';
|
|
3
|
+
import { type TransitionEval } from './fsm-evaluator.js';
|
|
4
|
+
export type DashboardEvent = {
|
|
5
|
+
kind: 'pty_data';
|
|
6
|
+
chunk: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'state_changed';
|
|
9
|
+
state: {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
title: string | null;
|
|
13
|
+
status: 'idle' | 'generating' | 'approval';
|
|
14
|
+
};
|
|
15
|
+
modal: {
|
|
16
|
+
title: string | null;
|
|
17
|
+
buttons: {
|
|
18
|
+
index: number;
|
|
19
|
+
label: string;
|
|
20
|
+
}[];
|
|
21
|
+
} | null;
|
|
22
|
+
controls: {
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
action_type: string;
|
|
26
|
+
}[];
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'notification';
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
body: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'delegate';
|
|
34
|
+
id: string;
|
|
35
|
+
task: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'spec_trace';
|
|
38
|
+
entries: TraceEntry[];
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'exit';
|
|
41
|
+
exit_code: number;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'spec_error';
|
|
44
|
+
errors: string[];
|
|
45
|
+
};
|
|
46
|
+
export type DashboardCommand = {
|
|
47
|
+
kind: 'send_message';
|
|
48
|
+
text: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'pty_write';
|
|
51
|
+
data: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'click_control';
|
|
54
|
+
control_id: string;
|
|
55
|
+
payload?: unknown;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'click_modal_button';
|
|
58
|
+
index: number;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'attach_image';
|
|
61
|
+
blob: string;
|
|
62
|
+
mime: string;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'resize';
|
|
65
|
+
cols: number;
|
|
66
|
+
rows: number;
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'cancel';
|
|
69
|
+
} | {
|
|
70
|
+
kind: 'shutdown';
|
|
71
|
+
};
|
|
72
|
+
export interface DriverHistoryEntry {
|
|
73
|
+
stateId: string;
|
|
74
|
+
label: string;
|
|
75
|
+
at: number;
|
|
76
|
+
durationMs: number;
|
|
77
|
+
reason: string;
|
|
78
|
+
matchedStateId?: string;
|
|
79
|
+
matchedRules?: string[];
|
|
80
|
+
debounceKind?: string;
|
|
81
|
+
idleHoldMs?: number;
|
|
82
|
+
busyHoldMs?: number;
|
|
83
|
+
via?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A frozen snapshot of the FULL FSM evaluation captured at the instant a
|
|
87
|
+
* transition fired — the rich `transitions[]` table (per-transition eligible /
|
|
88
|
+
* hold countdown / per-condition CondResult + remainingMs) that `getFsmDebug()`
|
|
89
|
+
* otherwise only computes live for the current instant. Kept in a separate ring
|
|
90
|
+
* buffer from `stateHistory` (which stays intentionally lightweight) so the
|
|
91
|
+
* "why did this rule fire just before the transition" question is answerable
|
|
92
|
+
* after the fact. before-only: this is the evaluation that PRODUCED the
|
|
93
|
+
* transition, not the post-transition state.
|
|
94
|
+
*/
|
|
95
|
+
export interface FsmSnapshotEntry {
|
|
96
|
+
/** State we transitioned out of. */
|
|
97
|
+
stateFrom: string;
|
|
98
|
+
/** State we transitioned into (the fired transition's destination). */
|
|
99
|
+
stateTo: string;
|
|
100
|
+
/** Wall-clock time the transition committed (ms). */
|
|
101
|
+
at: number;
|
|
102
|
+
/** The fired transition's destination state id (== stateTo; kept explicit
|
|
103
|
+
* to mirror the rule that fired). */
|
|
104
|
+
firedTo: string;
|
|
105
|
+
/** Human label of the fired transition (e.g. "approval→busy"). */
|
|
106
|
+
firedLabel: string;
|
|
107
|
+
/** Why-it-fired summary, same shape produced for stateHistory.matchedRules. */
|
|
108
|
+
reason: string[];
|
|
109
|
+
/** Every outgoing transition from `stateFrom` as evaluated at `at`, each
|
|
110
|
+
* with its eligible / hold / per-condition CondResult + remainingMs. This
|
|
111
|
+
* is the full pre-transition evaluation table — the whole point of the
|
|
112
|
+
* snapshot. */
|
|
113
|
+
transitions: TransitionEval[];
|
|
114
|
+
}
|
|
115
|
+
export interface ISpecDriver {
|
|
116
|
+
subscribe(listener: (ev: DashboardEvent) => void): () => void;
|
|
117
|
+
start(): void;
|
|
118
|
+
dispatch(cmd: DashboardCommand): void;
|
|
119
|
+
snapshot(): string;
|
|
120
|
+
getCursorPosition(): {
|
|
121
|
+
row: number;
|
|
122
|
+
col: number;
|
|
123
|
+
};
|
|
124
|
+
getScreen(): string;
|
|
125
|
+
getSpecPath(): string;
|
|
126
|
+
shutdown(): void;
|
|
127
|
+
getStateHistory(): ReadonlyArray<DriverHistoryEntry>;
|
|
128
|
+
getSections(): Array<{
|
|
129
|
+
id: string;
|
|
130
|
+
text: string;
|
|
131
|
+
}> | null;
|
|
132
|
+
getLastBusyAt(): number;
|
|
133
|
+
hasIdleHoldPending(): boolean;
|
|
134
|
+
getCompletionIdleDebounceState(): {
|
|
135
|
+
active: boolean;
|
|
136
|
+
ageMs: number;
|
|
137
|
+
holdMs: number;
|
|
138
|
+
forceAfterMs: number;
|
|
139
|
+
} | null;
|
|
140
|
+
getFsmDebug?(): unknown;
|
|
141
|
+
getFsmSnapshotHistory?(): ReadonlyArray<FsmSnapshotEntry>;
|
|
142
|
+
}
|
|
143
|
+
export interface SpecDriverOpts {
|
|
144
|
+
specPath: string;
|
|
145
|
+
workingDir: string;
|
|
146
|
+
extraEnv?: Record<string, string>;
|
|
147
|
+
cols?: number;
|
|
148
|
+
rows?: number;
|
|
149
|
+
hotReload?: boolean;
|
|
150
|
+
emitTrace?: boolean;
|
|
151
|
+
transportFactory?: PtyTransportFactory;
|
|
152
|
+
extraCliArgs?: string[];
|
|
153
|
+
}
|
|
154
|
+
export declare function resolveSubmitDelayMs(specBeforeSubmit: number | undefined, text: string): number;
|
|
155
|
+
export declare function guessExt(mime: string): string;
|
|
156
|
+
type HistoryEntry = DriverHistoryEntry;
|
|
157
|
+
export declare class FsmDriver implements ISpecDriver {
|
|
158
|
+
private readonly opts;
|
|
159
|
+
private spec;
|
|
160
|
+
private adapter;
|
|
161
|
+
private listeners;
|
|
162
|
+
private currentStateId;
|
|
163
|
+
private stateEnteredAt;
|
|
164
|
+
private startedAtMs;
|
|
165
|
+
private prevScreenLines;
|
|
166
|
+
/** Per cursor_above region (key: cursor_above, -1 = whole screen) → last
|
|
167
|
+
* time that region's content changed. Drives stable_ms conditions. */
|
|
168
|
+
private regionLastChangedAt;
|
|
169
|
+
/** Timer that re-runs evaluate() when a time-condition would flip true
|
|
170
|
+
* with no PTY frame to trigger it. */
|
|
171
|
+
private wakeTimer;
|
|
172
|
+
/** Timer driving the focus-gated stall watchdog (refocus_when_stalled_ms).
|
|
173
|
+
* Re-arms itself while the machine is generating so a re-prime can fire
|
|
174
|
+
* even when the PTY has gone completely quiet. */
|
|
175
|
+
private stallTimer;
|
|
176
|
+
/** Wall-clock time the last stall re-prime was injected. The cooldown gate:
|
|
177
|
+
* after a re-prime we don't re-inject until the screen changes (which
|
|
178
|
+
* resets the stall reference) or another full stall window lapses. */
|
|
179
|
+
private lastRefocusAt;
|
|
180
|
+
/** Timer driving the win32 verification-based submit resend loop (see
|
|
181
|
+
* WIN32_SUBMIT_* and scheduleWin32Submit). Re-arms itself until the FSM
|
|
182
|
+
* leaves idle (submitted) or the resend budget is spent. */
|
|
183
|
+
private win32SubmitTimer;
|
|
184
|
+
private currentEval;
|
|
185
|
+
private stateHistory;
|
|
186
|
+
private prevStateAt;
|
|
187
|
+
private readySeenOnce;
|
|
188
|
+
private pendingSends;
|
|
189
|
+
private pickerInProgress;
|
|
190
|
+
private delegateTimers;
|
|
191
|
+
private specWatcher;
|
|
192
|
+
/** Last full FSM evaluation, kept for the debugger. */
|
|
193
|
+
private lastFsmEval;
|
|
194
|
+
/** Ring buffer (max 20) of the full FSM evaluation captured at each
|
|
195
|
+
* transition — the rich pre-transition table that lastFsmEval only keeps
|
|
196
|
+
* for the single most recent evaluation. Separate from stateHistory. */
|
|
197
|
+
private fsmSnapshotHistory;
|
|
198
|
+
constructor(opts: SpecDriverOpts);
|
|
199
|
+
subscribe(listener: (ev: DashboardEvent) => void): () => void;
|
|
200
|
+
start(): void;
|
|
201
|
+
private scheduleSpawnPrime;
|
|
202
|
+
/** Write the declared `send_on_spawn` sequences to the PTY once. Used both
|
|
203
|
+
* at spawn (scheduleSpawnPrime) and, for focus-gated TUIs, by the stall
|
|
204
|
+
* watchdog to re-inject the focus-in wake mid-turn. No-op when the spec
|
|
205
|
+
* declares no prime, so non-focus-gated CLIs are never poked. */
|
|
206
|
+
private sendSpawnPrime;
|
|
207
|
+
dispatch(cmd: DashboardCommand): void;
|
|
208
|
+
snapshot(): string;
|
|
209
|
+
getCursorPosition(): {
|
|
210
|
+
row: number;
|
|
211
|
+
col: number;
|
|
212
|
+
};
|
|
213
|
+
getScreen(): string;
|
|
214
|
+
/** Scrollback-inclusive screen as line array — used only for modal/button
|
|
215
|
+
* content extraction so a tall prompt's off-screen anchors stay matchable.
|
|
216
|
+
* Falls back to the viewport snapshot if scrollback read is unavailable. */
|
|
217
|
+
private scrollbackLines;
|
|
218
|
+
getSpecPath(): string;
|
|
219
|
+
shutdown(): void;
|
|
220
|
+
getFsmDebug(): {
|
|
221
|
+
currentState: string;
|
|
222
|
+
label: string;
|
|
223
|
+
stateAgeMs: number;
|
|
224
|
+
status: string;
|
|
225
|
+
cursor: {
|
|
226
|
+
row: number;
|
|
227
|
+
col: number;
|
|
228
|
+
};
|
|
229
|
+
transitions: TransitionEval[];
|
|
230
|
+
};
|
|
231
|
+
getStateHistory(): ReadonlyArray<HistoryEntry>;
|
|
232
|
+
getFsmSnapshotHistory(): ReadonlyArray<FsmSnapshotEntry>;
|
|
233
|
+
getSections(): Array<{
|
|
234
|
+
id: string;
|
|
235
|
+
text: string;
|
|
236
|
+
}> | null;
|
|
237
|
+
/** v3-compat shims so the cli-adapter's existing debug snapshot keeps
|
|
238
|
+
* working without branching on driver type. */
|
|
239
|
+
getLastBusyAt(): number;
|
|
240
|
+
hasIdleHoldPending(): boolean;
|
|
241
|
+
getCompletionIdleDebounceState(): {
|
|
242
|
+
active: boolean;
|
|
243
|
+
ageMs: number;
|
|
244
|
+
holdMs: number;
|
|
245
|
+
forceAfterMs: number;
|
|
246
|
+
} | null;
|
|
247
|
+
private loadSpecOrThrow;
|
|
248
|
+
private buildAdapterOpts;
|
|
249
|
+
private armSpecWatcher;
|
|
250
|
+
private emitInitialState;
|
|
251
|
+
private buildClock;
|
|
252
|
+
private evalFsmNow;
|
|
253
|
+
private reevaluate;
|
|
254
|
+
private commitTransition;
|
|
255
|
+
/** Snapshot the full FSM evaluation that produced a transition into the
|
|
256
|
+
* separate fsmSnapshotHistory ring buffer (max 20). The transitions[]
|
|
257
|
+
* table is captured by reference — it is freshly built per evaluation in
|
|
258
|
+
* evaluateFsm and never mutated after, so no clone is needed. */
|
|
259
|
+
private pushFsmSnapshot;
|
|
260
|
+
/** Re-derive the visible modal + controls for the current state and emit a
|
|
261
|
+
* state_changed if anything differs from the last emit. */
|
|
262
|
+
private emitStateChanged;
|
|
263
|
+
private deriveModal;
|
|
264
|
+
private deriveTitle;
|
|
265
|
+
private deriveControls;
|
|
266
|
+
/** Track which cursor_above regions changed since the previous frame so
|
|
267
|
+
* stable_ms conditions can measure quiet time. We record every region
|
|
268
|
+
* size referenced by a stable_ms condition in the spec, plus the whole
|
|
269
|
+
* screen (-1). */
|
|
270
|
+
private trackRegionChanges;
|
|
271
|
+
/** All cursor_above region sizes referenced by stable_ms conditions in the
|
|
272
|
+
* current state's outgoing transitions, plus whole-screen. Cached lazily
|
|
273
|
+
* per spec load would be nicer but the set is tiny. */
|
|
274
|
+
private stableRegionSizes;
|
|
275
|
+
/** Schedule a re-evaluation for the soonest pending time-condition on any
|
|
276
|
+
* outgoing transition (elapsed_ms / stable_ms / min_hold_ms). Without
|
|
277
|
+
* this, a state whose only exit is time-based would never leave once the
|
|
278
|
+
* PTY goes quiet. */
|
|
279
|
+
private scheduleWakeForState;
|
|
280
|
+
/** True when this spec opts into stall recovery (declares a positive
|
|
281
|
+
* refocus window AND a wake sequence to re-inject). */
|
|
282
|
+
private stallRecoveryEnabled;
|
|
283
|
+
/** Wall-clock time the screen last changed in the current state, falling
|
|
284
|
+
* back to state entry when it has not changed since (i.e. fully stalled
|
|
285
|
+
* from the start of the state). */
|
|
286
|
+
private lastScreenChangeAt;
|
|
287
|
+
/** Arm a timer to re-inject the focus-in prime if the screen stays frozen
|
|
288
|
+
* through a `generating` state. Only active for opted-in focus-gated specs;
|
|
289
|
+
* a no-op (and cleared) for every other CLI and every non-generating state.
|
|
290
|
+
* Re-arms itself so it keeps watching while the PTY is quiet. */
|
|
291
|
+
private scheduleStallWatchdog;
|
|
292
|
+
/** Fire when the stall window elapses: if the screen is still frozen and we
|
|
293
|
+
* are still generating, re-inject the focus-in wake once, then re-arm. */
|
|
294
|
+
private onStallTick;
|
|
295
|
+
private maybeMarkReady;
|
|
296
|
+
private fireNotifications;
|
|
297
|
+
private armOrCancelDelegateTimers;
|
|
298
|
+
private fireDelegate;
|
|
299
|
+
private handleSendMessage;
|
|
300
|
+
private actuallySendMessage;
|
|
301
|
+
/** The agent's current coarse status, derived from the FSM node we're in. */
|
|
302
|
+
private currentStatus;
|
|
303
|
+
/**
|
|
304
|
+
* win32 verification-based submit. Sends the submit key, waits a gap, and if
|
|
305
|
+
* the FSM is still 'idle' (the prompt did not submit — the CR was absorbed as
|
|
306
|
+
* a multiline-paste newline) resends, up to WIN32_SUBMIT_MAX_RESENDS. The
|
|
307
|
+
* first CR always fires (so a stale/edge status never suppresses the submit);
|
|
308
|
+
* subsequent resends are gated on still being idle, and stop the instant the
|
|
309
|
+
* agent leaves idle (submitted → generating / approval). This converges the
|
|
310
|
+
* nondeterministic multiline window without spamming Enter into the next turn.
|
|
311
|
+
*/
|
|
312
|
+
private scheduleWin32Submit;
|
|
313
|
+
private handleClickControl;
|
|
314
|
+
private handleClickModalButton;
|
|
315
|
+
private handleAttachImage;
|
|
316
|
+
private tryAdvancePicker;
|
|
317
|
+
private handleExit;
|
|
318
|
+
private pushHistory;
|
|
319
|
+
private specTag;
|
|
320
|
+
private emit;
|
|
321
|
+
}
|
|
322
|
+
export {};
|