@adhdev/daemon-core 0.9.82-rc.142 → 0.9.82-rc.144

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.
Files changed (91) hide show
  1. package/dist/boot/process-hardening.d.ts +50 -0
  2. package/dist/cli-adapters/cli-script-runner.d.ts +73 -1
  3. package/dist/cli-adapters/provider-cli-adapter.d.ts +17 -0
  4. package/dist/cli-adapters/provider-cli-shared.d.ts +6 -0
  5. package/dist/commands/handler.d.ts +66 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +2876 -403
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2890 -424
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/ipc/local-ipc-server.d.ts +91 -0
  12. package/dist/providers/contracts.d.ts +8 -0
  13. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  14. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  15. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  16. package/dist/providers/native-history/index.d.ts +11 -0
  17. package/dist/providers/provider-loader.d.ts +19 -1
  18. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  19. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  20. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  21. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +64 -0
  22. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +82 -0
  23. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  24. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  25. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  26. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  27. package/dist/providers/sdk/v1/index.d.ts +30 -0
  28. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  29. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  30. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  31. package/dist/providers/sdk/v1/types/cli/index.d.ts +268 -0
  32. package/dist/providers/sdk/v1/types/common/index.d.ts +169 -0
  33. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  34. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  35. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  36. package/package.json +4 -2
  37. package/src/boot/daemon-lifecycle.ts +14 -10
  38. package/src/boot/process-hardening.ts +89 -0
  39. package/src/cli-adapters/cli-script-runner.ts +289 -13
  40. package/src/cli-adapters/cli-state-engine.ts +8 -5
  41. package/src/cli-adapters/provider-cli-adapter.ts +36 -2
  42. package/src/cli-adapters/provider-cli-shared.ts +6 -0
  43. package/src/commands/chat-commands.ts +22 -1
  44. package/src/commands/cli-manager.ts +39 -0
  45. package/src/commands/handler.ts +539 -1
  46. package/src/commands/router.ts +1 -0
  47. package/src/index.ts +27 -0
  48. package/src/ipc/local-ipc-server.ts +278 -0
  49. package/src/providers/cli-provider-instance.ts +15 -0
  50. package/src/providers/contracts.ts +8 -0
  51. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  52. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  53. package/src/providers/native-history/codex-cli-transcript.ts +419 -0
  54. package/src/providers/native-history/index.ts +23 -0
  55. package/src/providers/provider-loader.ts +258 -17
  56. package/src/providers/provider-schema.ts +3 -0
  57. package/src/providers/sdk/README.md +49 -0
  58. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  59. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  60. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  61. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +245 -0
  62. package/src/providers/sdk/v1/builders/cli/parse-session.ts +247 -0
  63. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  64. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  65. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  66. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  67. package/src/providers/sdk/v1/index.ts +151 -0
  68. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  69. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  70. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  71. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +428 -0
  72. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  73. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  74. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  75. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  76. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  77. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  78. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  79. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  80. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +119 -0
  81. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  82. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  83. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  84. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  85. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  86. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  87. package/src/providers/sdk/v1/types/cli/index.ts +355 -0
  88. package/src/providers/sdk/v1/types/common/index.ts +210 -0
  89. package/src/providers/sdk/v1/validators/index.ts +19 -0
  90. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  91. package/src/providers/sdk/v1/validators/taint.ts +309 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * LocalIpcServer — generic HTTP + WebSocket IPC endpoint for daemon processes.
3
+ *
4
+ * Both daemon-cloud and daemon-standalone need a local IPC surface so
5
+ * external tools — the `adhdev mcp --mode ipc` MCP server and anything
6
+ * else that wants to issue commands without going through the cloud
7
+ * Worker — can connect over `ws://127.0.0.1:<port>/ipc`.
8
+ *
9
+ * Until now the implementation lived only in daemon-cloud. Standalone
10
+ * sessions therefore couldn't host MCP mesh tools — codex/claude config
11
+ * pointing at `--mode ipc` got `Cannot reach ipc daemon`. This module
12
+ * moves the transport into daemon-core so both daemons can mount it.
13
+ *
14
+ * The transport itself is daemon-agnostic. Cloud-specific behaviors
15
+ * (mesh relay, mandatory update gates) are injected via the caller's
16
+ * `handleCommand` hook; the IPC layer just frames/unframes JSON and
17
+ * routes messages.
18
+ */
19
+ import { WebSocket } from 'ws';
20
+ /** Parameters passed to `handleCommand` for each incoming ext:command frame. */
21
+ export interface IpcCommandContext {
22
+ /** The raw `command` field from the message — caller decides routing. */
23
+ command: string;
24
+ /** Args provided by the client; may have been normalized by the caller. */
25
+ args: Record<string, unknown>;
26
+ /** Stable id correlating the request and the eventual ext:command_result. */
27
+ requestId: string;
28
+ /** The connected WebSocket — only needed if the caller wants to send extra events. */
29
+ ws: WebSocket;
30
+ }
31
+ /** Result reported back to the client. `result` is optional context for success. */
32
+ export interface IpcCommandResult {
33
+ success: boolean;
34
+ result?: unknown;
35
+ error?: string;
36
+ /**
37
+ * Additional fields the caller wants merged into the response payload
38
+ * (e.g. the cloud daemon's mandatory-update-block fields). Reserved.
39
+ */
40
+ extra?: Record<string, unknown>;
41
+ }
42
+ /** Status payload returned from GET / on the IPC HTTP port. */
43
+ export interface IpcStatusPayload {
44
+ ok: true;
45
+ pid: number;
46
+ wsPath: string;
47
+ port: number;
48
+ /** Arbitrary daemon-specific summary. Cloud daemon includes mesh state, etc. */
49
+ status: Record<string, unknown> | null;
50
+ }
51
+ export interface LocalIpcServerOptions {
52
+ /** TCP port to listen on. 19222 is the conventional default. */
53
+ port: number;
54
+ /** Build the GET / status payload. Called on every health probe. */
55
+ buildStatusPayload: () => Record<string, unknown> | null;
56
+ /** Build the welcome message sent to a freshly-connected client. */
57
+ buildWelcomePayload: () => Record<string, unknown>;
58
+ /** Handle a single ext:command frame. Caller decides routing and returns the result. */
59
+ handleCommand: (ctx: IpcCommandContext) => Promise<IpcCommandResult>;
60
+ /** Optional notification when a new client connects (lets daemon track them for broadcasts). */
61
+ onClientConnected?: (ws: WebSocket) => void;
62
+ /** Optional notification when a client disconnects. */
63
+ onClientDisconnected?: (ws: WebSocket) => void;
64
+ /** Optional logger label (defaults to "IPC"). */
65
+ logCategory?: string;
66
+ }
67
+ /**
68
+ * Returned controller for stopping the server and broadcasting to clients.
69
+ * Stored by the daemon and torn down at shutdown.
70
+ */
71
+ export interface LocalIpcServerHandle {
72
+ /** True once `listen()` succeeded. */
73
+ isListening(): boolean;
74
+ /** Push a message to every connected client. */
75
+ broadcast(type: string, payload: unknown): void;
76
+ /** Close all client sockets + the HTTP server. */
77
+ close(): Promise<void>;
78
+ }
79
+ /**
80
+ * Build a JSON HTTP response describing the IPC endpoint. Exposed so caller
81
+ * code (and tests) can build the same shape without spinning a real server.
82
+ */
83
+ export declare function buildIpcStatusHttpResponse(method: string | undefined, url: string | undefined, payload: IpcStatusPayload): {
84
+ statusCode: number;
85
+ body: Record<string, unknown>;
86
+ };
87
+ /**
88
+ * Start the local IPC server. Returns a handle the caller can use to broadcast
89
+ * events and tear down at shutdown.
90
+ */
91
+ export declare function startLocalIpcServer(opts: LocalIpcServerOptions): Promise<LocalIpcServerHandle>;
@@ -386,6 +386,14 @@ export interface ProviderModule {
386
386
  extensionIdPattern_flags?: string;
387
387
  compatibility?: ProviderCompatibilityEntry[];
388
388
  defaultScriptDir?: string;
389
+ /**
390
+ * v1 declarative tui block (spinner/settledPrompt/modal/dispatchOrder/etc).
391
+ * When present, the daemon's CliScriptRunner builds canonical
392
+ * (input → verdict) functions from this and injects them into provider
393
+ * scripts as `sdk.declarativeDetectStatus` and `sdk.declarativeParseApproval`.
394
+ * v0 / verified-tier providers can omit this entirely.
395
+ */
396
+ tui?: Record<string, unknown>;
389
397
  /**
390
398
  * Scripts that can run at the IDE main-page level (not just inside the extension webview session frame).
391
399
  * Default: ['listModes', 'setMode', 'listModels', 'setModel'].
@@ -0,0 +1,100 @@
1
+ /**
2
+ * antigravity-cli-transcript — Daemon-side built-in native history adapter for antigravity-cli.
3
+ *
4
+ * Antigravity CLI stores conversations in multiple complementary locations:
5
+ *
6
+ * 1. ~/.gemini/antigravity-cli/history.jsonl
7
+ * Lightweight index of user prompts, one row per turn:
8
+ * { conversationId: string, display: string, workspace: string, timestamp: number }
9
+ *
10
+ * 2. ~/.gemini/antigravity-cli/brain/<uuid>/.system_generated/logs/transcript*.jsonl
11
+ * Per-session full transcript, one row per agent step:
12
+ * { source: 'USER_EXPLICIT'|'MODEL', type: string, content: string, status: 'DONE'|..., created_at: number }
13
+ *
14
+ * 3. ~/.gemini/antigravity-cli/conversations/<uuid>.pb
15
+ * Protobuf binary — schema not publicly documented. Adapter extracts
16
+ * printable UTF-8 text runs as best-effort content (no proto library needed).
17
+ *
18
+ * This adapter provides:
19
+ * - Full coverage when a brain transcript exists (authoritative source).
20
+ * - Partial coverage (user prompts only) from history.jsonl as fallback.
21
+ * - Best-effort raw-string extraction from .pb files when no other source exists.
22
+ *
23
+ * watchPath (from provider.v1.json):
24
+ * ~/.gemini/antigravity-cli/history.jsonl
25
+ * ~/.gemini/antigravity-cli/brain/{uuid}/.system_generated/logs/transcript*.jsonl
26
+ * ~/.gemini/antigravity-cli/conversations/{uuid}.pb
27
+ *
28
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
29
+ */
30
+ export type NativeHistoryRole = 'user' | 'assistant' | 'system';
31
+ export type NativeHistoryKind = 'standard' | 'tool' | 'session_start';
32
+ export interface NativeHistoryMessage {
33
+ ts: string;
34
+ receivedAt: number;
35
+ role: NativeHistoryRole;
36
+ content: string;
37
+ kind: NativeHistoryKind;
38
+ senderName?: string;
39
+ agent: 'antigravity-cli';
40
+ historySessionId: string;
41
+ workspace?: string;
42
+ /** Stable per-message identity (v2 contract). */
43
+ providerUnitKey?: string;
44
+ }
45
+ export interface NativeHistorySession {
46
+ messages: NativeHistoryMessage[];
47
+ providerSessionId: string;
48
+ source: 'provider-native';
49
+ sourcePath: string;
50
+ sourceMtimeMs: number;
51
+ /**
52
+ * 'full' — brain transcript was available and parsed.
53
+ * 'partial' — only history.jsonl user-prompts are available.
54
+ * 'best-effort' — .pb file bytes were used for raw text extraction.
55
+ */
56
+ nativeHistoryCoverage: 'full' | 'partial' | 'best-effort';
57
+ workspace?: string;
58
+ partialReason?: string;
59
+ }
60
+ export interface NativeHistorySessionMeta {
61
+ historySessionId: string;
62
+ sessionId: string;
63
+ sourcePath: string;
64
+ sourceMtimeMs: number;
65
+ messageCount: number;
66
+ firstMessageAt: number;
67
+ lastMessageAt: number;
68
+ sessionTitle?: string;
69
+ preview?: string;
70
+ workspace?: string;
71
+ agent: 'antigravity-cli';
72
+ source: 'provider-native';
73
+ nativeHistoryCoverage: 'full' | 'partial' | 'best-effort';
74
+ partialReason?: string;
75
+ }
76
+ /**
77
+ * Read a single Antigravity CLI session by its source file path.
78
+ *
79
+ * `sessionPath` is the absolute path to one of:
80
+ * - A brain transcript JSONL: ~/.gemini/antigravity-cli/brain/<uuid>/.system_generated/logs/transcript*.jsonl
81
+ * - The shared history.jsonl: ~/.gemini/antigravity-cli/history.jsonl
82
+ * - A conversation protobuf: ~/.gemini/antigravity-cli/conversations/<uuid>.pb
83
+ *
84
+ * The session UUID is inferred from the directory name (brain), filename (pb), or
85
+ * must be provided explicitly via `sessionId` for history.jsonl paths.
86
+ *
87
+ * Returns `null` when the file is missing, empty, or yields no parseable messages.
88
+ */
89
+ export declare function readSession(sessionPath: string, sessionId?: string, workspace?: string): Promise<NativeHistorySession | null>;
90
+ /**
91
+ * List all Antigravity CLI sessions found across all watchPath locations.
92
+ *
93
+ * Priority:
94
+ * 1. Brain transcript sessions (full coverage) — preferred source.
95
+ * 2. History JSONL entries without a brain transcript (partial coverage).
96
+ * 3. .pb conversation files without any other source (best-effort).
97
+ *
98
+ * Returns summary metadata sorted by most recently updated first.
99
+ */
100
+ export declare function listSessions(_watchPath: string): Promise<NativeHistorySessionMeta[]>;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * claude-cli-transcript — Daemon-side built-in native history adapter for claude-cli.
3
+ *
4
+ * Reads Claude Code JSONL transcript files directly without shelling out to a JS override.
5
+ * The transcript format is one JSON object per line, where each line has:
6
+ * - type: 'user' | 'assistant'
7
+ * - message: { content: string | ContentBlock[] }
8
+ * - timestamp: number (ms epoch) | string (ISO)
9
+ * - sessionId?: string
10
+ * - cwd?: string
11
+ *
12
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
13
+ */
14
+ export type NativeHistoryRole = 'user' | 'assistant' | 'system';
15
+ export type NativeHistoryKind = 'standard' | 'tool' | 'session_start';
16
+ export interface NativeHistoryMessage {
17
+ ts: string;
18
+ receivedAt: number;
19
+ role: NativeHistoryRole;
20
+ content: string;
21
+ kind: NativeHistoryKind;
22
+ senderName?: string;
23
+ agent: 'claude-cli';
24
+ historySessionId: string;
25
+ workspace?: string;
26
+ /** Stable per-message identity (v2 contract). */
27
+ providerUnitKey?: string;
28
+ }
29
+ export interface NativeHistorySession {
30
+ messages: NativeHistoryMessage[];
31
+ providerSessionId: string;
32
+ source: 'provider-native';
33
+ sourcePath: string;
34
+ sourceMtimeMs: number;
35
+ nativeHistoryCoverage: 'full';
36
+ workspace?: string;
37
+ }
38
+ export interface NativeHistorySessionMeta {
39
+ historySessionId: string;
40
+ sessionId: string;
41
+ sourcePath: string;
42
+ sourceMtimeMs: number;
43
+ messageCount: number;
44
+ firstMessageAt: number;
45
+ lastMessageAt: number;
46
+ sessionTitle?: string;
47
+ preview?: string;
48
+ workspace?: string;
49
+ agent: 'claude-cli';
50
+ source: 'provider-native';
51
+ nativeHistoryCoverage: 'full';
52
+ }
53
+ /**
54
+ * Read a single Claude Code session by its transcript file path.
55
+ *
56
+ * `sessionPath` is the absolute path to a `<uuid>.jsonl` file.
57
+ * Returns `null` when the file is missing, empty, or yields no parseable messages.
58
+ */
59
+ export declare function readSession(sessionPath: string): Promise<NativeHistorySession | null>;
60
+ /**
61
+ * List all Claude Code sessions under the given glob-style watchPath base dir.
62
+ *
63
+ * `watchPath` is the pattern from provider.v1.json (`~/.claude/projects/**\/*.jsonl`).
64
+ * This implementation expands the home directory and scans `~/.claude/projects/`
65
+ * recursively, collecting all `.jsonl` files.
66
+ *
67
+ * Returns summary metadata for each session (no full message reads on this hot path;
68
+ * each file is opened only for lightweight scanning).
69
+ */
70
+ export declare function listSessions(watchPath: string): Promise<NativeHistorySessionMeta[]>;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * codex-cli-transcript — Daemon-side built-in native history adapter for codex-cli.
3
+ *
4
+ * Reads Codex CLI rollout JSONL session files directly without shelling out to a JS override.
5
+ * Files are stored at ~/.codex/sessions/<uuid>[-<slug>].jsonl.
6
+ *
7
+ * Format — each line is a JSON object of one of these types:
8
+ * { type: 'session_meta', timestamp: number, payload: { id: string, cwd: string, ... } }
9
+ * { type: 'response_item', timestamp: number, payload: { type: 'message', role: 'user'|'assistant', content: ... } }
10
+ * { type: 'response_item', timestamp: number, payload: { type: 'function_call' | 'custom_tool_call', name?: string, arguments?: string, input?: unknown } }
11
+ * { type: 'response_item', timestamp: number, payload: { type: 'function_call_output' | 'custom_tool_call_output', output?: string, result?: string } }
12
+ *
13
+ * watchPath (from provider.v1.json): ~/.codex/sessions
14
+ *
15
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
16
+ */
17
+ export type NativeHistoryRole = 'user' | 'assistant' | 'system';
18
+ export type NativeHistoryKind = 'standard' | 'tool' | 'session_start';
19
+ export interface NativeHistoryMessage {
20
+ ts: string;
21
+ receivedAt: number;
22
+ role: NativeHistoryRole;
23
+ content: string;
24
+ kind: NativeHistoryKind;
25
+ senderName?: string;
26
+ agent: 'codex-cli';
27
+ historySessionId: string;
28
+ workspace?: string;
29
+ /** Stable per-message identity (v2 contract). */
30
+ providerUnitKey?: string;
31
+ }
32
+ export interface NativeHistorySession {
33
+ messages: NativeHistoryMessage[];
34
+ providerSessionId: string;
35
+ source: 'provider-native';
36
+ sourcePath: string;
37
+ sourceMtimeMs: number;
38
+ nativeHistoryCoverage: 'full';
39
+ workspace?: string;
40
+ }
41
+ export interface NativeHistorySessionMeta {
42
+ historySessionId: string;
43
+ sessionId: string;
44
+ sourcePath: string;
45
+ sourceMtimeMs: number;
46
+ messageCount: number;
47
+ firstMessageAt: number;
48
+ lastMessageAt: number;
49
+ sessionTitle?: string;
50
+ preview?: string;
51
+ workspace?: string;
52
+ agent: 'codex-cli';
53
+ source: 'provider-native';
54
+ nativeHistoryCoverage: 'full';
55
+ }
56
+ /**
57
+ * Read a single Codex CLI session by its JSONL file path.
58
+ *
59
+ * `sessionPath` is the absolute path to a `<uuid>[-<slug>].jsonl` file
60
+ * under ~/.codex/sessions/.
61
+ * Returns `null` when the file is missing, empty, or yields no parseable messages.
62
+ */
63
+ export declare function readSession(sessionPath: string): Promise<NativeHistorySession | null>;
64
+ /**
65
+ * List all Codex CLI sessions under the given watchPath base dir.
66
+ *
67
+ * `watchPath` is the value from provider.v1.json (`~/.codex/sessions`).
68
+ * Expands the home directory and scans the directory recursively,
69
+ * collecting all `.jsonl` files.
70
+ *
71
+ * Returns summary metadata for each session, sorted by most recently updated first.
72
+ */
73
+ export declare function listSessions(watchPath: string): Promise<NativeHistorySessionMeta[]>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * native-history — Daemon-side built-in adapters for CLI provider native history.
3
+ *
4
+ * Each adapter reads conversation history directly from the CLI tool's on-disk
5
+ * storage without shelling out to a provider JS override script.
6
+ *
7
+ * OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
8
+ */
9
+ export { readSession as readClaudeCliSession, listSessions as listClaudeCliSessions, } from './claude-cli-transcript.js';
10
+ export { readSession as readCodexCliSession, listSessions as listCodexCliSessions, } from './codex-cli-transcript.js';
11
+ export { readSession as readAntigravityCliSession, listSessions as listAntigravityCliSessions, } from './antigravity-cli-transcript.js';
@@ -58,7 +58,9 @@ export declare class ProviderLoader {
58
58
  /** Inject VersionArchive so resolve() can auto-detect installed versions */
59
59
  setVersionArchive(archive: VersionArchive): void;
60
60
  private static readonly GITHUB_TARBALL_URL;
61
+ private static readonly REGISTRY_BASE_URL;
61
62
  private static readonly META_FILE;
63
+ private static readonly REGISTRY_META_FILE;
62
64
  private static readonly REPO_PROVIDER_DIRNAME;
63
65
  private static readonly SIBLING_MARKER_FILE;
64
66
  private static readonly SIBLING_ENV_VAR;
@@ -295,6 +297,22 @@ export declare class ProviderLoader {
295
297
  *
296
298
  * @returns Whether an update occurred
297
299
  */
300
+ /**
301
+ * Sync providers from the ADHDev registry (registry.adhf.dev).
302
+ *
303
+ * Downloads only providers whose server checksum differs from the locally
304
+ * cached checksum. Falls back gracefully to the GitHub tarball path if the
305
+ * registry is unreachable or returns an unexpected response.
306
+ *
307
+ * Returns `{ updated: true }` when at least one provider file changed on disk,
308
+ * `{ updated: false }` when everything is already current, or
309
+ * `{ updated: false, error }` when the registry couldn't be reached and we
310
+ * should proceed to the GitHub tarball fallback.
311
+ */
312
+ fetchFromRegistry(): Promise<{
313
+ updated: boolean;
314
+ error?: string;
315
+ }>;
298
316
  fetchLatest(): Promise<{
299
317
  updated: boolean;
300
318
  error?: string;
@@ -305,7 +323,7 @@ export declare class ProviderLoader {
305
323
  private copyDirRecursive;
306
324
  /** .meta.json save */
307
325
  private writeMeta;
308
- /** Count provider files (provider.js or provider.json) */
326
+ /** Count provider files (provider.v1.json or provider.json — at most one per dir). */
309
327
  private countProviders;
310
328
  /**
311
329
  * Get public settings schema for a provider (for dashboard UI rendering)
@@ -0,0 +1,68 @@
1
+ /**
2
+ * buildDetectStatusFromAcp
3
+ *
4
+ * Turns a declarative `acp/session-protocol@1` block into a runtime
5
+ * `(input: AcpStatusInput) => 'idle' | 'generating' | 'waiting_approval' | null`
6
+ * function.
7
+ *
8
+ * Dispatch order:
9
+ * 1. Not connected → null (no information available).
10
+ * 2. Error patterns — checked first; first match returns the declared verdict.
11
+ * 3. Generating pattern — `generating`.
12
+ * 4. Idle pattern — `idle`.
13
+ * 5. Default: `null` (no change — caller preserves last known status).
14
+ *
15
+ * All regex patterns are compiled once at builder time so the returned
16
+ * detector function is allocation-free on the hot path.
17
+ */
18
+ interface AcpRegexPatternSpec {
19
+ regex: string;
20
+ flags?: string;
21
+ description?: string;
22
+ }
23
+ interface AcpErrorPatternSpec extends AcpRegexPatternSpec {
24
+ verdict: 'idle' | 'generating' | 'waiting_approval';
25
+ }
26
+ export interface AcpSessionSpec {
27
+ $schema?: 'adhdev:acp/session-protocol@1';
28
+ /** Pattern that matches a line emitted when the agent is idle/ready. */
29
+ idlePattern?: AcpRegexPatternSpec;
30
+ /** Pattern that matches a line emitted while the agent is actively working. */
31
+ generatingPattern?: AcpRegexPatternSpec;
32
+ /**
33
+ * Error/edge-case patterns. Checked in order; first match returns the
34
+ * declared verdict. Useful for approval prompts, fatal errors, etc.
35
+ */
36
+ errorPatterns?: AcpErrorPatternSpec[];
37
+ /** Wire format; informational only at the builder level — regex matching
38
+ * is identical regardless of promptStyle. */
39
+ promptStyle?: 'json-rpc' | 'plain-text' | 'mcp';
40
+ /** Message delimiter used to split incoming bytes (default: newline). */
41
+ messageDelimiter?: string;
42
+ }
43
+ export interface AcpStatusInput {
44
+ /** The most recently received line from the stdio stream. */
45
+ lastLine: string;
46
+ /**
47
+ * A sliding window of recent output lines (newest last).
48
+ * Builders may check these when a single line is not enough for context.
49
+ */
50
+ recentLines: string[];
51
+ /** Whether the ACP process is currently connected and running. */
52
+ isConnected: boolean;
53
+ }
54
+ export type AcpDetectedStatus = 'idle' | 'generating' | 'waiting_approval' | null;
55
+ interface CompiledAcpSpec {
56
+ idle: RegExp | null;
57
+ generating: RegExp | null;
58
+ errors: Array<{
59
+ re: RegExp;
60
+ verdict: AcpDetectedStatus;
61
+ }>;
62
+ }
63
+ declare function compileSpec(spec: AcpSessionSpec): CompiledAcpSpec;
64
+ export declare function buildDetectStatusFromAcp(spec: AcpSessionSpec): (input: AcpStatusInput) => AcpDetectedStatus;
65
+ export declare const __internal: {
66
+ compileSpec: typeof compileSpec;
67
+ };
68
+ export {};
@@ -0,0 +1,85 @@
1
+ /**
2
+ * buildDetectStatusFromTui
3
+ *
4
+ * Turns a manifest's declarative TUI block into a runtime
5
+ * `(input: CliStatusInput) => CliStatus | null` function.
6
+ *
7
+ * Inputs handled (all optional except spinner):
8
+ * - tui/spinner@1 → contributes `generating`
9
+ * - tui/settled-prompt@1 → contributes `idle`
10
+ * - tui/modal@1 → contributes `waiting_approval`
11
+ *
12
+ * Dispatch order (sprint-2026-06 contract):
13
+ * 1. Active generation cues win over idle prompt — checked first.
14
+ * Reason: codex/claude keep model footer visible during `Working` and
15
+ * `hasReadyPrompt` falsely fired idle. Audit §4.2 introduces
16
+ * `tui/cue-ordering` as the named primitive for this rule.
17
+ * 2. Modal cue (if present) is checked next — `waiting_approval`.
18
+ * 3. Settled-prompt cue — `idle`.
19
+ * 4. Default: `null` (no change).
20
+ */
21
+ import type { CliStatusInput, CliDetectStatusFn } from '../../types/cli/index.js';
22
+ import { type VisibleRegionSpec } from './visible-region.js';
23
+ interface RegexLikeSpec {
24
+ regex: string;
25
+ flags?: string;
26
+ }
27
+ interface SpinnerPatternSpec extends RegexLikeSpec {
28
+ description?: string;
29
+ }
30
+ interface SpinnerSpec {
31
+ $schema: 'adhdev:tui/spinner@1';
32
+ patterns: SpinnerPatternSpec[];
33
+ scope?: 'live-frame-tail' | 'whole-screen' | 'recent-buffer';
34
+ scopeWindowLines?: number;
35
+ }
36
+ interface SettledPromptFooterSpec {
37
+ pattern: string;
38
+ kind?: 'substring' | 'regex';
39
+ flags?: string;
40
+ }
41
+ interface SettledPromptSpec {
42
+ $schema: 'adhdev:tui/settled-prompt@1';
43
+ regex: string;
44
+ flags?: string;
45
+ withFooter?: SettledPromptFooterSpec[];
46
+ scope?: 'last-n-lines' | 'whole-screen';
47
+ scopeWindowLines?: number;
48
+ }
49
+ interface ModalSpec {
50
+ $schema: 'adhdev:tui/modal@1';
51
+ questionPattern: string;
52
+ questionFlags?: string;
53
+ questionVariants?: Array<{
54
+ regex: string;
55
+ flags?: string;
56
+ label?: string;
57
+ }>;
58
+ buttonPattern: string;
59
+ buttonFlags?: string;
60
+ }
61
+ export type DispatchGroup = 'spinner' | 'modal' | 'settled-prompt' | 'cue-ordering' | 'error-detection' | 'approval-stitching';
62
+ export interface DispatchOrderSpec {
63
+ $schema: 'adhdev:tui/dispatch-order@1';
64
+ order: DispatchGroup[];
65
+ onNoMatch?: 'idle' | 'unknown' | 'preserve-last';
66
+ }
67
+ export interface DetectStatusTuiSpec {
68
+ spinner?: SpinnerSpec;
69
+ settledPrompt?: SettledPromptSpec;
70
+ modal?: ModalSpec;
71
+ dispatchOrder?: DispatchOrderSpec;
72
+ visibleRegion?: VisibleRegionSpec;
73
+ }
74
+ declare function scopeText(input: CliStatusInput, scope: SpinnerSpec['scope'] | SettledPromptSpec['scope'], windowLines: number | undefined): string;
75
+ declare function spinnerMatches(spec: SpinnerSpec, input: CliStatusInput): boolean;
76
+ declare function settledPromptMatches(spec: SettledPromptSpec, input: CliStatusInput): boolean;
77
+ declare function modalMatches(spec: ModalSpec, input: CliStatusInput): boolean;
78
+ export declare function buildDetectStatusFromTui(spec: DetectStatusTuiSpec): CliDetectStatusFn;
79
+ export declare const __internal: {
80
+ scopeText: typeof scopeText;
81
+ spinnerMatches: typeof spinnerMatches;
82
+ settledPromptMatches: typeof settledPromptMatches;
83
+ modalMatches: typeof modalMatches;
84
+ };
85
+ export {};
@@ -0,0 +1,59 @@
1
+ /**
2
+ * buildParseApprovalFromSquash
3
+ *
4
+ * Companion to buildParseApprovalFromTui. Handles the squashed-modal case:
5
+ * the terminal has re-flowed the approval frame so the rendered text is a
6
+ * single run of lowercase-alnum bytes (e.g. `doyoutrustthecontentsofthisdirectory…1yescontinue2noquit`).
7
+ *
8
+ * Author declares:
9
+ * - `cues` — compact substrings/regexes that identify the modal
10
+ * - `footers` — optional compact substrings that must also be present
11
+ * - `buttonRules` — compact→labels mappings used to recover button labels
12
+ *
13
+ * Returns the same shape as buildParseApprovalFromTui — a CliApprovalModal
14
+ * (message + buttons) or null when no rule matches. Caller composes the two
15
+ * builders: try the regular modal first, then fall back to squash. Codex
16
+ * needs both because at narrow widths the terminal renders the squash form,
17
+ * and at wider widths it renders the regular framed form.
18
+ */
19
+ import type { CliApprovalInput, CliParseApprovalFn } from '../../types/cli/index.js';
20
+ interface SquashCueSpec {
21
+ compact: string;
22
+ kind?: 'substring' | 'regex';
23
+ label?: string;
24
+ messageWhenMatched?: string;
25
+ }
26
+ interface SquashFooterSpec {
27
+ compact: string;
28
+ kind?: 'substring' | 'regex';
29
+ }
30
+ interface SquashButtonRuleSpec {
31
+ compact: string;
32
+ kind?: 'substring' | 'regex';
33
+ labels: string[];
34
+ }
35
+ export interface ApprovalSquashSpec {
36
+ $schema: 'adhdev:tui/approval-squash@1';
37
+ cues: SquashCueSpec[];
38
+ footers?: SquashFooterSpec[];
39
+ buttonRules: SquashButtonRuleSpec[];
40
+ scope?: 'tail-window' | 'whole-screen';
41
+ tailWindowLines?: number;
42
+ }
43
+ /**
44
+ * The canonical normalisation. Identical to codex-cli's `compactText`:
45
+ * lowercase, then strip everything that is not a-z or 0-9.
46
+ *
47
+ * Exported for tests and for the (rare) provider that wants to compose this
48
+ * with extra normalisation steps.
49
+ */
50
+ export declare function compactText(value: string): string;
51
+ declare function matchSubstringOrRegex(needle: string, kind: 'substring' | 'regex' | undefined, haystack: string): boolean;
52
+ declare function scopeText(spec: ApprovalSquashSpec, input: CliApprovalInput): string;
53
+ export declare function buildParseApprovalFromSquash(spec: ApprovalSquashSpec): CliParseApprovalFn;
54
+ export declare const __internal: {
55
+ compactText: typeof compactText;
56
+ matchSubstringOrRegex: typeof matchSubstringOrRegex;
57
+ scopeText: typeof scopeText;
58
+ };
59
+ export {};