@adhdev/daemon-core 0.9.82-rc.18 → 0.9.82-rc.181
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/process-hardening.d.ts +50 -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 +22 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
- package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +29 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/commands/handler.d.ts +110 -0
- package/dist/commands/mesh-coordinator.d.ts +72 -1
- package/dist/commands/router.d.ts +22 -0
- package/dist/config/chat-history.d.ts +8 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +72 -1
- package/dist/git/git-commands.d.ts +5 -1
- package/dist/index.d.ts +35 -8
- package/dist/index.js +20754 -5387
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20567 -5270
- 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/mesh/beads-db.d.ts +72 -0
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +30 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +90 -0
- package/dist/mesh/mesh-events.d.ts +97 -5
- package/dist/mesh/mesh-fast-forward.d.ts +41 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-ledger.d.ts +58 -1
- package/dist/mesh/mesh-refine-status.d.ts +26 -0
- package/dist/mesh/mesh-work-queue.d.ts +54 -6
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +193 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
- package/dist/providers/approval-utils.d.ts +13 -0
- package/dist/providers/cli-provider-instance.d.ts +35 -3
- package/dist/providers/contracts.d.ts +98 -5
- 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 +25 -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 +12 -0
- package/dist/providers/provider-instance.d.ts +12 -0
- 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 +169 -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 +56 -0
- package/dist/providers/spec/cli-adapter.d.ts +97 -0
- package/dist/providers/spec/driver.d.ts +159 -0
- package/dist/providers/spec/evaluator.d.ts +47 -0
- package/dist/providers/spec/loader.d.ts +14 -0
- package/dist/providers/spec/native-history-executor.d.ts +39 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/schema.gen.d.ts +511 -0
- package/dist/providers/spec/types.d.ts +212 -0
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +48 -0
- package/dist/repo-mesh-types.d.ts +102 -1
- package/dist/sessions/registry.d.ts +3 -0
- package/dist/shared-types.d.ts +42 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -2
- package/src/agent-stream/poller.ts +2 -3
- package/src/boot/daemon-lifecycle.ts +17 -10
- package/src/boot/process-hardening.ts +89 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +14 -1
- package/src/cli-adapter-types.d.ts +1 -0
- package/src/cli-adapter-types.ts +21 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1086 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +670 -1137
- 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 +3 -1
- package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.ts +59 -11
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
- package/src/commands/chat-commands.ts +1597 -60
- package/src/commands/cli-manager.ts +230 -3
- package/src/commands/handler.ts +809 -2
- package/src/commands/mesh-coordinator.ts +231 -127
- package/src/commands/router.ts +3495 -502
- package/src/config/chat-history.ts +91 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +280 -2
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/detection/ide-detector.ts +26 -16
- package/src/git/git-commands.ts +17 -5
- package/src/git/git-worktree.ts +8 -1
- package/src/index.ts +113 -7
- 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/logger.ts +2 -1
- package/src/mesh/beads-db.ts +486 -0
- package/src/mesh/contracts.ts +329 -0
- package/src/mesh/coordinator-prompt.ts +204 -30
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +437 -0
- package/src/mesh/mesh-events.ts +963 -67
- package/src/mesh/mesh-fast-forward.ts +438 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-ledger.ts +457 -104
- package/src/mesh/mesh-refine-status.ts +144 -0
- package/src/mesh/mesh-work-queue.ts +263 -159
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +366 -0
- package/src/mesh/worktree-bootstrap-config.ts +247 -0
- package/src/providers/approval-utils.d.ts +4 -0
- package/src/providers/approval-utils.ts +47 -5
- package/src/providers/chat-message-normalization.ts +4 -11
- package/src/providers/cli-provider-instance.ts +651 -57
- package/src/providers/contracts.ts +105 -5
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +19 -5
- 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 +419 -0
- package/src/providers/native-history/dispatcher.ts +231 -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 +9 -0
- package/src/providers/provider-loader.ts +585 -50
- package/src/providers/provider-schema.ts +31 -13
- 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 +458 -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 +210 -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 +507 -0
- package/src/providers/spec/driver.ts +540 -0
- package/src/providers/spec/evaluator.ts +298 -0
- package/src/providers/spec/loader.ts +130 -0
- package/src/providers/spec/native-history-executor.ts +706 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/schema.gen.ts +511 -0
- package/src/providers/spec/schema.json +211 -0
- package/src/providers/spec/types.ts +231 -0
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +396 -0
- package/src/providers/version-archive.ts +38 -20
- package/src/repo-mesh-types.ts +112 -1
- package/src/sessions/registry.ts +3 -0
- package/src/shared-types.ts +45 -1
- package/src/status/builders.ts +24 -6
- package/src/status/reporter.ts +15 -0
- package/src/status/snapshot.ts +84 -25
- package/src/system/host-memory.ts +29 -12
- package/src/types.ts +5 -0
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
private spec;
|
|
19
|
+
private lastEvent;
|
|
20
|
+
private latestState;
|
|
21
|
+
private latestModal;
|
|
22
|
+
private statusCallback;
|
|
23
|
+
private ptyDataCallback;
|
|
24
|
+
private partialResponse;
|
|
25
|
+
private activeInteractivePrompt;
|
|
26
|
+
private interactivePromptTransport;
|
|
27
|
+
private claudeTuiPromptCaptureInFlight;
|
|
28
|
+
private jsonLineTail;
|
|
29
|
+
private exited;
|
|
30
|
+
private spawned;
|
|
31
|
+
private providerSessionId;
|
|
32
|
+
/** Wall clock at the moment spawn() ran. Used as the cutoff for
|
|
33
|
+
* native-history file selection so a prior session's transcript
|
|
34
|
+
* can't leak into this session before the agent has written its
|
|
35
|
+
* own records. */
|
|
36
|
+
private spawnedAtMs;
|
|
37
|
+
/** Env vars the daemon set on the spawned child. Mesh coordinator
|
|
38
|
+
* points hermes at a per-coordinator HERMES_HOME so the dashboard's
|
|
39
|
+
* native-history reader needs that override to find the right
|
|
40
|
+
* state.db; without it the reader sees ~/.hermes/state.db which
|
|
41
|
+
* the coordinator-launched hermes never writes to. The choice to
|
|
42
|
+
* redirect HERMES_HOME is a workaround for an unresolved hermes
|
|
43
|
+
* upstream feature gap (see hermes-agent#23130 — runtime-supplied
|
|
44
|
+
* MCP config), so this routing keeps the dashboard honest until
|
|
45
|
+
* hermes ships a runtime MCP override. */
|
|
46
|
+
private spawnedEnv;
|
|
47
|
+
constructor(specPath: string, workingDir: string, cliArgs: string[], extraEnv: Record<string, string>, transportFactory?: PtyTransportFactory);
|
|
48
|
+
spawn(): Promise<void>;
|
|
49
|
+
sendMessage(text: string): Promise<void>;
|
|
50
|
+
getStatus(): CliAdapterStatus;
|
|
51
|
+
private maybeRefreshNativeHistory;
|
|
52
|
+
getScriptParsedStatus(): unknown;
|
|
53
|
+
getPartialResponse(): string;
|
|
54
|
+
shutdown(): void;
|
|
55
|
+
cancel(): void;
|
|
56
|
+
isProcessing(): boolean;
|
|
57
|
+
isReady(): boolean;
|
|
58
|
+
setOnStatusChange(cb: () => void): void;
|
|
59
|
+
setOnPtyData(cb: (data: string) => void): void;
|
|
60
|
+
writeRaw(data: string): void;
|
|
61
|
+
resize(cols: number, rows: number): void;
|
|
62
|
+
resolveModal(buttonIndex: number): void;
|
|
63
|
+
resolveAction(data: unknown): Promise<void>;
|
|
64
|
+
setInteractivePromptResponse(response: InteractivePromptResponse): Promise<void>;
|
|
65
|
+
isApprovalRecentlyResolved(): boolean;
|
|
66
|
+
clearHistory(): void;
|
|
67
|
+
updateRuntimeSettings(): void;
|
|
68
|
+
setServerConn(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Map an invokeScript(name, args) call onto a control_bar entry.
|
|
71
|
+
*
|
|
72
|
+
* scriptName is matched against control.id. The control's action.type
|
|
73
|
+
* drives the dispatch:
|
|
74
|
+
*
|
|
75
|
+
* send_keys → click_control (e.g. stop)
|
|
76
|
+
* open_picker → click_control then resolve when extract_choices
|
|
77
|
+
* surface; choice index comes from args.choiceIndex
|
|
78
|
+
* or args.choice (string label match), defaulting to 0
|
|
79
|
+
* attach_image → attach_image dispatch; expects args.blob (data url
|
|
80
|
+
* or base64) and args.mime
|
|
81
|
+
*
|
|
82
|
+
* Callers that pass an unknown control id get a { not_found } response.
|
|
83
|
+
* No control matched, no driver call — keeps the surface honest.
|
|
84
|
+
*/
|
|
85
|
+
invokeScript(scriptName: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
86
|
+
getDebugSnapshot(): unknown;
|
|
87
|
+
getRuntimeMetadata(): unknown;
|
|
88
|
+
updateRuntimeMeta(meta?: Record<string, unknown>): void;
|
|
89
|
+
refreshProviderDefinition(): void;
|
|
90
|
+
private handleEvent;
|
|
91
|
+
private detectInteractivePromptFromPtyChunk;
|
|
92
|
+
private readCurrentScreenSections;
|
|
93
|
+
private readClaudeScreenAssistantMessages;
|
|
94
|
+
private maybeCaptureClaudeTuiPrompt;
|
|
95
|
+
private readClaudeTuiHeaders;
|
|
96
|
+
private captureClaudeTuiPrompt;
|
|
97
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
|
|
2
|
+
import { type TraceEntry } from './evaluator.js';
|
|
3
|
+
export type DashboardEvent = {
|
|
4
|
+
kind: 'pty_data';
|
|
5
|
+
chunk: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'state_changed';
|
|
8
|
+
state: {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
title: string | null;
|
|
12
|
+
};
|
|
13
|
+
modal: {
|
|
14
|
+
title: string | null;
|
|
15
|
+
buttons: {
|
|
16
|
+
index: number;
|
|
17
|
+
label: string;
|
|
18
|
+
}[];
|
|
19
|
+
} | null;
|
|
20
|
+
controls: {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
action_type: string;
|
|
24
|
+
}[];
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'notification';
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
body: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'delegate';
|
|
32
|
+
id: string;
|
|
33
|
+
task: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'spec_trace';
|
|
36
|
+
entries: TraceEntry[];
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'exit';
|
|
39
|
+
exit_code: number;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'spec_error';
|
|
42
|
+
errors: string[];
|
|
43
|
+
};
|
|
44
|
+
export type DashboardCommand = {
|
|
45
|
+
kind: 'send_message';
|
|
46
|
+
text: string;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'pty_write';
|
|
49
|
+
data: string;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'click_control';
|
|
52
|
+
control_id: string;
|
|
53
|
+
payload?: unknown;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'click_modal_button';
|
|
56
|
+
index: number;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'attach_image';
|
|
59
|
+
blob: string;
|
|
60
|
+
mime: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: 'resize';
|
|
63
|
+
cols: number;
|
|
64
|
+
rows: number;
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'cancel';
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'shutdown';
|
|
69
|
+
};
|
|
70
|
+
export interface SpecDriverOpts {
|
|
71
|
+
specPath: string;
|
|
72
|
+
workingDir: string;
|
|
73
|
+
extraEnv?: Record<string, string>;
|
|
74
|
+
cols?: number;
|
|
75
|
+
rows?: number;
|
|
76
|
+
/** Set false to skip the spec.json fs.watch. */
|
|
77
|
+
hotReload?: boolean;
|
|
78
|
+
/** Set true to forward trace entries on every state_changed. */
|
|
79
|
+
emitTrace?: boolean;
|
|
80
|
+
/** Inject the daemon's PTY transport (typically SessionHostPtyTransportFactory). */
|
|
81
|
+
transportFactory?: PtyTransportFactory;
|
|
82
|
+
/**
|
|
83
|
+
* Extra CLI args appended to spec.spawn_args. Used by the daemon to
|
|
84
|
+
* pass per-launch arguments like `--session-id <uuid>` so the agent
|
|
85
|
+
* uses the daemon's providerSessionId instead of generating its own.
|
|
86
|
+
*/
|
|
87
|
+
extraCliArgs?: string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Pick the effective delay (ms) to wait between writing the prompt body and
|
|
91
|
+
* writing the submit_key. Exported for tests; production callers go through
|
|
92
|
+
* actuallySendMessage. Floors to SUBMIT_DELAY_FLOOR_MS so specs that omit
|
|
93
|
+
* delay_ms_before_submit (e.g. claude, antigravity) still get baseline
|
|
94
|
+
* protection against the paste→submit race. Adds line-count bonus so
|
|
95
|
+
* multi-line prompts get more settling time on TUIs that re-render per
|
|
96
|
+
* embedded `\n`.
|
|
97
|
+
*/
|
|
98
|
+
export declare function resolveSubmitDelayMs(specBeforeSubmit: number | undefined, text: string): number;
|
|
99
|
+
export declare class SpecDriver {
|
|
100
|
+
private readonly opts;
|
|
101
|
+
private spec;
|
|
102
|
+
private adapter;
|
|
103
|
+
private listeners;
|
|
104
|
+
private currentStateId;
|
|
105
|
+
/** Have we ever seen the spec's idle state *after* the startup grace
|
|
106
|
+
* window? Until we do, the agent's startup banner may still be
|
|
107
|
+
* painting and any send_message we forward to the PTY will be wiped
|
|
108
|
+
* when the banner clears the screen. Queue + drain on first valid
|
|
109
|
+
* idle. */
|
|
110
|
+
private idleSeenOnce;
|
|
111
|
+
private startedAtMs;
|
|
112
|
+
private pendingSends;
|
|
113
|
+
private currentEval;
|
|
114
|
+
private pickerInProgress;
|
|
115
|
+
private delegateTimers;
|
|
116
|
+
/** Timestamp of the last time the evaluator returned busy. Used to debounce
|
|
117
|
+
* the busy → idle transition (see reevaluate). */
|
|
118
|
+
private lastBusyAt;
|
|
119
|
+
/** The exact busy state object we last saw — held alongside lastBusyAt so
|
|
120
|
+
* the hold can re-emit the same { id: 'busy', label, title } payload the
|
|
121
|
+
* dashboard already learned about. currentEval can't fill this role
|
|
122
|
+
* because the evaluator already moved past busy by the time the hold
|
|
123
|
+
* kicks in. */
|
|
124
|
+
private lastBusyState;
|
|
125
|
+
/** Timer that re-runs evaluate() once the hold window expires. Needed
|
|
126
|
+
* because the PTY stops emitting once the agent finishes; without an
|
|
127
|
+
* explicit wake-up there's nothing to trigger the busy → idle
|
|
128
|
+
* downshift. */
|
|
129
|
+
private busyExpiryTimer;
|
|
130
|
+
private specWatcher;
|
|
131
|
+
constructor(opts: SpecDriverOpts);
|
|
132
|
+
/** Subscribe to outbound events. Returns an unsubscribe fn. */
|
|
133
|
+
subscribe(listener: (ev: DashboardEvent) => void): () => void;
|
|
134
|
+
start(): void;
|
|
135
|
+
dispatch(cmd: DashboardCommand): void;
|
|
136
|
+
snapshot(): string;
|
|
137
|
+
shutdown(): void;
|
|
138
|
+
private loadSpecOrThrow;
|
|
139
|
+
private buildAdapterOpts;
|
|
140
|
+
private armSpecWatcher;
|
|
141
|
+
private emitInitialState;
|
|
142
|
+
/** Re-arm the timer that wakes the driver up after BUSY_HOLD_MS so it
|
|
143
|
+
* can decide whether to downshift to idle. Always uses the most recent
|
|
144
|
+
* hold value so a spec hot-reload that shortens the hold takes effect
|
|
145
|
+
* on the next busy entry. Safe to call repeatedly; only the last call
|
|
146
|
+
* fires. */
|
|
147
|
+
private scheduleBusyExpiry;
|
|
148
|
+
private reevaluate;
|
|
149
|
+
private armOrCancelDelegateTimers;
|
|
150
|
+
private fireDelegate;
|
|
151
|
+
private handleSendMessage;
|
|
152
|
+
private actuallySendMessage;
|
|
153
|
+
private handleClickControl;
|
|
154
|
+
private handleClickModalButton;
|
|
155
|
+
private handleAttachImage;
|
|
156
|
+
private tryAdvancePicker;
|
|
157
|
+
private handleExit;
|
|
158
|
+
private emit;
|
|
159
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CliSpec } from './types.js';
|
|
2
|
+
export interface ResolvedSection {
|
|
3
|
+
id: string;
|
|
4
|
+
fromLine: number;
|
|
5
|
+
toLine: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ModalSnapshot {
|
|
9
|
+
title: string | null;
|
|
10
|
+
buttons: {
|
|
11
|
+
index: number;
|
|
12
|
+
label: string;
|
|
13
|
+
key: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
export interface VisibleControl {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
actionType: 'send_keys' | 'open_picker' | 'attach_image';
|
|
20
|
+
}
|
|
21
|
+
export interface FiredNotification {
|
|
22
|
+
id: string;
|
|
23
|
+
title: string;
|
|
24
|
+
body: string;
|
|
25
|
+
}
|
|
26
|
+
export interface FiredDelegate {
|
|
27
|
+
id: string;
|
|
28
|
+
task: string;
|
|
29
|
+
}
|
|
30
|
+
export interface TraceEntry {
|
|
31
|
+
kind: 'section' | 'state_match' | 'state_skip' | 'modal' | 'control' | 'notification' | 'delegate';
|
|
32
|
+
text: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SpecEvaluation {
|
|
35
|
+
state: {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
title: string | null;
|
|
39
|
+
};
|
|
40
|
+
modal: ModalSnapshot | null;
|
|
41
|
+
controls: VisibleControl[];
|
|
42
|
+
notifications: FiredNotification[];
|
|
43
|
+
delegates: FiredDelegate[];
|
|
44
|
+
sections: ResolvedSection[];
|
|
45
|
+
trace: TraceEntry[];
|
|
46
|
+
}
|
|
47
|
+
export declare function evaluate(spec: CliSpec, screenText: string): SpecEvaluation;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CliSpec } from './types.js';
|
|
2
|
+
export interface SpecLoadResult {
|
|
3
|
+
ok: true;
|
|
4
|
+
spec: CliSpec;
|
|
5
|
+
sourcePath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SpecLoadError {
|
|
8
|
+
ok: false;
|
|
9
|
+
errors: string[];
|
|
10
|
+
sourcePath: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function loadSpec(sourcePath: string): SpecLoadResult | SpecLoadError;
|
|
13
|
+
/** Convenience: look up a provider's spec.json next to its provider dir. */
|
|
14
|
+
export declare function resolveSpecPath(providerDir: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NativeHistoryConfig } from './types.js';
|
|
2
|
+
export interface NativeHistoryInput {
|
|
3
|
+
agentType?: string;
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
providerSessionId?: string;
|
|
6
|
+
historySessionId?: string;
|
|
7
|
+
workspace?: string;
|
|
8
|
+
/** Daemon-side wall clock at the moment the session was registered.
|
|
9
|
+
* Native-history file lookups use this as the lower bound: any file
|
|
10
|
+
* whose mtime is before the current session started can't be from
|
|
11
|
+
* this session, so it's excluded from newest-recent matching. The
|
|
12
|
+
* caller (chat-history pipeline) populates this from the session
|
|
13
|
+
* registry; specs/executor never need to know how it's sourced. */
|
|
14
|
+
sessionStartedAtMs?: number;
|
|
15
|
+
/** Env overrides the daemon set on the spawned CLI. The mesh
|
|
16
|
+
* coordinator points hermes at a per-coordinator HERMES_HOME so
|
|
17
|
+
* the hermes process writes its state.db into a tmp directory
|
|
18
|
+
* instead of ~/.hermes. expandPath consults this map before
|
|
19
|
+
* process.env so the native-history reader follows the spawned
|
|
20
|
+
* child's view of HERMES_HOME / similar overrides; without it
|
|
21
|
+
* the reader would always look at ~/.hermes and miss every
|
|
22
|
+
* coordinator-session transcript. */
|
|
23
|
+
envOverrides?: Record<string, string>;
|
|
24
|
+
args?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface NativeHistoryMessage {
|
|
27
|
+
role: 'user' | 'assistant' | 'system';
|
|
28
|
+
content: string;
|
|
29
|
+
receivedAt: number;
|
|
30
|
+
kind?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface NativeHistoryResult {
|
|
33
|
+
messages: NativeHistoryMessage[];
|
|
34
|
+
providerSessionId?: string;
|
|
35
|
+
sourcePath: string;
|
|
36
|
+
sourceMtimeMs: number;
|
|
37
|
+
nativeHistoryCoverage?: 'full' | 'partial' | 'best-effort';
|
|
38
|
+
}
|
|
39
|
+
export declare function executeNativeHistory(cfg: NativeHistoryConfig, input: NativeHistoryInput): NativeHistoryResult | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CliProviderModule } from '../../cli-adapters/provider-cli-adapter.js';
|
|
2
|
+
import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
|
|
3
|
+
import type { CliAdapter } from '../../cli-adapter-types.js';
|
|
4
|
+
export declare function createCliAdapter(provider: CliProviderModule, workingDir: string, cliArgs: string[], extraEnv: Record<string, string>, transportFactory?: PtyTransportFactory): CliAdapter;
|