@adhdev/daemon-core 0.9.82-rc.21 → 0.9.82-rc.211

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 (269) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +1 -0
  2. package/dist/boot/process-hardening.d.ts +50 -0
  3. package/dist/chat/source-machine.d.ts +166 -0
  4. package/dist/chat/source-resolver.d.ts +104 -0
  5. package/dist/chat/subscription-updates.d.ts +1 -0
  6. package/dist/cli-adapter-types.d.ts +23 -2
  7. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  8. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  9. package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
  10. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  11. package/dist/cli-adapters/provider-cli-shared.d.ts +29 -0
  12. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  13. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +3 -3
  14. package/dist/cli-adapters/terminal-backends/types.d.ts +1 -2
  15. package/dist/cli-adapters/terminal-screen.d.ts +2 -11
  16. package/dist/commands/cli-manager.d.ts +2 -1
  17. package/dist/commands/handler.d.ts +110 -0
  18. package/dist/commands/mesh-coordinator.d.ts +85 -1
  19. package/dist/commands/router.d.ts +32 -1
  20. package/dist/config/chat-history.d.ts +9 -0
  21. package/dist/config/config.d.ts +5 -0
  22. package/dist/config/mesh-config.d.ts +72 -1
  23. package/dist/git/git-commands.d.ts +9 -1
  24. package/dist/git/git-diff.d.ts +6 -0
  25. package/dist/git/git-types.d.ts +2 -0
  26. package/dist/index.d.ts +46 -11
  27. package/dist/index.js +35173 -15756
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +34880 -15556
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/installer.d.ts +1 -4
  32. package/dist/ipc/local-ipc-server.d.ts +91 -0
  33. package/dist/launch.d.ts +1 -1
  34. package/dist/logging/async-batch-writer.d.ts +10 -0
  35. package/dist/mesh/contracts.d.ts +164 -0
  36. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  37. package/dist/mesh/coordinator-registry.d.ts +59 -0
  38. package/dist/mesh/mesh-active-work.d.ts +90 -0
  39. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  40. package/dist/mesh/mesh-events-coordinator.d.ts +151 -0
  41. package/dist/mesh/mesh-events-pending.d.ts +33 -0
  42. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  43. package/dist/mesh/mesh-events-utils.d.ts +14 -0
  44. package/dist/mesh/mesh-events.d.ts +5 -40
  45. package/dist/mesh/mesh-fast-forward.d.ts +41 -0
  46. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  47. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  48. package/dist/mesh/mesh-ledger.d.ts +77 -1
  49. package/dist/mesh/mesh-missions.d.ts +58 -0
  50. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  51. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  52. package/dist/mesh/mesh-runtime-store.d.ts +324 -0
  53. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  54. package/dist/mesh/mesh-work-queue.d.ts +137 -6
  55. package/dist/mesh/preview-freshness.d.ts +18 -0
  56. package/dist/mesh/refine-config.d.ts +215 -0
  57. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  58. package/dist/providers/acp-provider-instance.d.ts +2 -0
  59. package/dist/providers/approval-utils.d.ts +13 -0
  60. package/dist/providers/cli-provider-instance.d.ts +39 -3
  61. package/dist/providers/contracts.d.ts +130 -6
  62. package/dist/providers/external-sources.d.ts +71 -0
  63. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  64. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  65. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  66. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  67. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  68. package/dist/providers/native-history/index.d.ts +13 -0
  69. package/dist/providers/provider-instance-manager.d.ts +12 -0
  70. package/dist/providers/provider-instance.d.ts +13 -1
  71. package/dist/providers/provider-loader.d.ts +26 -4
  72. package/dist/providers/provider-trust.d.ts +31 -0
  73. package/dist/providers/read-chat-contract.d.ts +29 -0
  74. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  75. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  76. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  77. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  78. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  79. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  80. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  81. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  82. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  83. package/dist/providers/sdk/v1/index.d.ts +30 -0
  84. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  85. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  86. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  87. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  88. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  89. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  90. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  91. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  92. package/dist/providers/spec/adapter.d.ts +52 -0
  93. package/dist/providers/spec/cli-adapter.d.ts +101 -0
  94. package/dist/providers/spec/driver.d.ts +225 -0
  95. package/dist/providers/spec/evaluator.d.ts +54 -0
  96. package/dist/providers/spec/loader.d.ts +15 -0
  97. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  98. package/dist/providers/spec/route.d.ts +4 -0
  99. package/dist/providers/spec/schema.gen.d.ts +2025 -0
  100. package/dist/providers/spec/types.d.ts +302 -0
  101. package/dist/providers/transcript-v2.d.ts +176 -0
  102. package/dist/providers/types/interactive-prompt.d.ts +48 -0
  103. package/dist/repo-mesh-types.d.ts +109 -1
  104. package/dist/sessions/registry.d.ts +3 -0
  105. package/dist/shared-types-extra.d.ts +2 -4
  106. package/dist/shared-types.d.ts +42 -1
  107. package/dist/status/normalize.d.ts +1 -1
  108. package/dist/status/normalize.js +1 -0
  109. package/dist/status/normalize.js.map +1 -1
  110. package/dist/status/normalize.mjs +1 -0
  111. package/dist/status/normalize.mjs.map +1 -1
  112. package/dist/status/reporter.d.ts +2 -0
  113. package/dist/status/snapshot.d.ts +1 -0
  114. package/dist/types.d.ts +5 -0
  115. package/package.json +6 -3
  116. package/src/agent-stream/poller.ts +2 -3
  117. package/src/boot/daemon-lifecycle.ts +22 -10
  118. package/src/boot/process-hardening.ts +89 -0
  119. package/src/chat/source-machine.ts +534 -0
  120. package/src/chat/source-resolver.ts +0 -0
  121. package/src/chat/subscription-updates.ts +20 -1
  122. package/src/cli-adapter-types.d.ts +1 -0
  123. package/src/cli-adapter-types.ts +22 -2
  124. package/src/cli-adapters/cli-script-runner.ts +421 -0
  125. package/src/cli-adapters/cli-state-engine.ts +1138 -0
  126. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  127. package/src/cli-adapters/provider-cli-adapter.ts +673 -1139
  128. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  129. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  130. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  131. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  132. package/src/cli-adapters/provider-cli-shared.ts +59 -11
  133. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  134. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +35 -29
  135. package/src/cli-adapters/terminal-backends/types.ts +1 -3
  136. package/src/cli-adapters/terminal-screen.ts +11 -81
  137. package/src/commands/chat-commands.ts +1787 -60
  138. package/src/commands/cli-manager.ts +283 -14
  139. package/src/commands/handler.ts +809 -2
  140. package/src/commands/mesh-coordinator.ts +332 -122
  141. package/src/commands/router.ts +4198 -557
  142. package/src/config/chat-history.ts +95 -24
  143. package/src/config/config.ts +12 -0
  144. package/src/config/mesh-config.ts +280 -2
  145. package/src/config/recent-activity.ts +8 -2
  146. package/src/daemon/dev-auto-implement.ts +3 -2
  147. package/src/daemon/dev-cli-debug.ts +10 -1
  148. package/src/detection/ide-detector.ts +26 -16
  149. package/src/git/git-commands.ts +42 -12
  150. package/src/git/git-diff.ts +53 -0
  151. package/src/git/git-status.ts +35 -6
  152. package/src/git/git-types.ts +2 -0
  153. package/src/git/git-worktree.ts +8 -1
  154. package/src/index.ts +126 -10
  155. package/src/installer.d.ts +1 -1
  156. package/src/installer.ts +8 -6
  157. package/src/ipc/local-ipc-server.ts +278 -0
  158. package/src/launch.d.ts +1 -1
  159. package/src/launch.ts +37 -28
  160. package/src/logging/async-batch-writer.ts +55 -0
  161. package/src/logging/logger.ts +2 -1
  162. package/src/mesh/contracts.ts +329 -0
  163. package/src/mesh/coordinator-prompt.ts +218 -31
  164. package/src/mesh/coordinator-registry.ts +121 -0
  165. package/src/mesh/mesh-active-work.ts +437 -0
  166. package/src/mesh/mesh-delivery-policy.ts +315 -0
  167. package/src/mesh/mesh-events-coordinator.ts +1404 -0
  168. package/src/mesh/mesh-events-pending.ts +371 -0
  169. package/src/mesh/mesh-events-stale.ts +283 -0
  170. package/src/mesh/mesh-events-utils.ts +161 -0
  171. package/src/mesh/mesh-events.ts +24 -908
  172. package/src/mesh/mesh-fast-forward.ts +438 -0
  173. package/src/mesh/mesh-host-ownership.ts +73 -0
  174. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  175. package/src/mesh/mesh-ledger.ts +587 -102
  176. package/src/mesh/mesh-missions.ts +151 -0
  177. package/src/mesh/mesh-refine-status.ts +144 -0
  178. package/src/mesh/mesh-review-inbox.ts +307 -0
  179. package/src/mesh/mesh-runtime-store.ts +1305 -0
  180. package/src/mesh/mesh-task-stats.ts +154 -0
  181. package/src/mesh/mesh-work-queue.ts +490 -166
  182. package/src/mesh/preview-freshness.ts +118 -0
  183. package/src/mesh/refine-config.ts +403 -0
  184. package/src/mesh/worktree-bootstrap-config.ts +326 -0
  185. package/src/providers/acp-provider-instance.ts +15 -1
  186. package/src/providers/approval-utils.d.ts +4 -0
  187. package/src/providers/approval-utils.ts +47 -5
  188. package/src/providers/chat-message-normalization.ts +4 -11
  189. package/src/providers/cli-provider-instance.ts +833 -64
  190. package/src/providers/contracts.d.ts +55 -0
  191. package/src/providers/contracts.ts +141 -6
  192. package/src/providers/external-sources.ts +218 -0
  193. package/src/providers/ide-provider-instance.ts +19 -5
  194. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  195. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  196. package/src/providers/native-history/codex-cli-transcript.ts +419 -0
  197. package/src/providers/native-history/dispatcher.ts +340 -0
  198. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  199. package/src/providers/native-history/index.ts +30 -0
  200. package/src/providers/provider-instance-manager.ts +30 -0
  201. package/src/providers/provider-instance.ts +10 -1
  202. package/src/providers/provider-loader.ts +582 -50
  203. package/src/providers/provider-schema.ts +87 -14
  204. package/src/providers/provider-trust.ts +114 -0
  205. package/src/providers/read-chat-contract.ts +76 -16
  206. package/src/providers/sdk/README.md +49 -0
  207. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  208. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  209. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  210. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  211. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  212. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  213. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  214. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  215. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  216. package/src/providers/sdk/v1/index.ts +152 -0
  217. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  218. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  219. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  220. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  221. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  222. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  223. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  224. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  225. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  226. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  227. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  228. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  229. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  230. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  231. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  232. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  233. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  234. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  235. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  236. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  237. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  238. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  239. package/src/providers/sdk/v1/validators/index.ts +19 -0
  240. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  241. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  242. package/src/providers/spec/adapter.ts +138 -0
  243. package/src/providers/spec/cli-adapter.ts +626 -0
  244. package/src/providers/spec/driver.ts +922 -0
  245. package/src/providers/spec/evaluator.ts +597 -0
  246. package/src/providers/spec/loader.ts +324 -0
  247. package/src/providers/spec/native-history-executor.ts +939 -0
  248. package/src/providers/spec/route.ts +51 -0
  249. package/src/providers/spec/schema.gen.ts +691 -0
  250. package/src/providers/spec/schema.json +341 -0
  251. package/src/providers/spec/types.ts +356 -0
  252. package/src/providers/transcript-v2.ts +567 -0
  253. package/src/providers/types/interactive-prompt.ts +425 -0
  254. package/src/providers/version-archive.ts +38 -20
  255. package/src/repo-mesh-types.ts +119 -1
  256. package/src/sessions/registry.ts +3 -0
  257. package/src/shared-types-extra.ts +2 -4
  258. package/src/shared-types.ts +45 -1
  259. package/src/status/builders.ts +24 -6
  260. package/src/status/normalize.ts +2 -0
  261. package/src/status/reporter.ts +15 -0
  262. package/src/status/snapshot.ts +84 -25
  263. package/src/system/host-memory.ts +29 -12
  264. package/src/types.ts +5 -0
  265. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  266. package/dist/mesh/mesh-sync.d.ts +0 -53
  267. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  268. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  269. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,302 @@
1
+ export type Size = number | string;
2
+ export interface SectionPattern {
3
+ section?: string;
4
+ pattern: string;
5
+ flags?: string;
6
+ }
7
+ export type ControlAction = {
8
+ type: 'send_keys';
9
+ keys: string;
10
+ } | {
11
+ type: 'open_picker';
12
+ trigger_keys: string;
13
+ wait_for: SectionRegex;
14
+ extract_choices: SectionPattern;
15
+ submit_key: string;
16
+ } | {
17
+ type: 'attach_image';
18
+ method: 'tempfile_then_keys';
19
+ keys_template: string;
20
+ };
21
+ export interface Control {
22
+ id: string;
23
+ label: string;
24
+ visible_when_state?: string[];
25
+ action: ControlAction;
26
+ }
27
+ export interface NotificationRule {
28
+ id: string;
29
+ when_state: string;
30
+ title: string;
31
+ body?: string;
32
+ }
33
+ export interface DelegateTrigger {
34
+ id: string;
35
+ when_state: string;
36
+ after_duration_ms?: number;
37
+ task_template: string;
38
+ }
39
+ /**
40
+ * Native history config — three modes, picked by which fields are present:
41
+ *
42
+ * 1. `reader`: built-in reader id (claude-cli / codex-cli / antigravity-cli / hermes-cli).
43
+ *
44
+ * 2. `source`: declarative source descriptor.
45
+ *
46
+ * 3. `override_path`: relative path to a provider-supplied reader module.
47
+ */
48
+ export interface NativeHistoryConfig {
49
+ reader?: 'claude-cli' | 'codex-cli' | 'antigravity-cli' | 'hermes-cli';
50
+ source?: NativeHistorySource;
51
+ override_path?: string;
52
+ }
53
+ export type NativeHistorySource = NativeHistoryJsonlSource | NativeHistorySqliteSource;
54
+ export interface NativeHistoryJsonlSource {
55
+ kind: 'jsonl';
56
+ path: string;
57
+ file_pattern?: string;
58
+ recent_window_ms?: number;
59
+ session_id_from?: 'filename_uuid' | 'first_record';
60
+ session_id_path?: string;
61
+ message_filter?: {
62
+ where: string;
63
+ };
64
+ message_map: NativeHistoryMessageMap;
65
+ }
66
+ export interface NativeHistorySqliteSource {
67
+ kind: 'sqlite';
68
+ path: string;
69
+ session_query: string;
70
+ message_query: string;
71
+ message_map: NativeHistoryMessageMap;
72
+ }
73
+ export interface NativeHistoryMessageMap {
74
+ role: string;
75
+ content: string;
76
+ content_strip?: string[];
77
+ content_unwrap?: string[];
78
+ timestamp_ms?: string;
79
+ kind?: string;
80
+ }
81
+ export interface Section {
82
+ id: string;
83
+ from_top?: Size;
84
+ from_bottom?: Size;
85
+ until?: {
86
+ section: string;
87
+ };
88
+ anchor_regex?: string;
89
+ anchor_flags?: string;
90
+ anchor_last?: boolean;
91
+ anchor_context?: {
92
+ prev?: string;
93
+ prev_flags?: string;
94
+ next?: string;
95
+ next_flags?: string;
96
+ };
97
+ lines?: number;
98
+ until_regex?: string;
99
+ until_regex_flags?: string;
100
+ }
101
+ /** v1 condition — flat SectionRegex object. Also used in control_bar.wait_for. */
102
+ export interface SectionRegex {
103
+ section?: string;
104
+ regex?: string;
105
+ flags?: string;
106
+ cursor_row_min?: number;
107
+ cursor_row_max?: number;
108
+ cursor_col_min?: number;
109
+ cursor_col_max?: number;
110
+ /** v1 delta detection (cursor_above_lines + changed). */
111
+ cursor_above_lines?: number;
112
+ /** Required when cursor_above_lines is set. */
113
+ changed?: true;
114
+ }
115
+ export interface ModalButtonsRule {
116
+ section?: string;
117
+ pattern?: string;
118
+ flags?: string;
119
+ patterns?: Array<{
120
+ pattern: string;
121
+ flags?: string;
122
+ }>;
123
+ key_for_index: string;
124
+ min_count?: number;
125
+ continuation_lines?: boolean;
126
+ }
127
+ /**
128
+ * v3 section definition — keyed by id in `sections{}` object.
129
+ * `until` is EITHER a section-id string (no `^` prefix) OR a regex string (starts with `^`).
130
+ */
131
+ export interface SectionDef {
132
+ from_top?: Size;
133
+ from_bottom?: Size;
134
+ until?: string;
135
+ anchor?: string;
136
+ anchor_flags?: string;
137
+ anchor_last?: boolean;
138
+ anchor_context?: {
139
+ prev?: string;
140
+ next?: string;
141
+ prev_flags?: string;
142
+ next_flags?: string;
143
+ };
144
+ lines?: number;
145
+ until_regex?: string;
146
+ until_regex_flags?: string;
147
+ }
148
+ /** v3 regex condition against a section (or full screen). */
149
+ export interface RegexCondition {
150
+ section?: string;
151
+ matches: string;
152
+ flags?: string;
153
+ cursor_row_min?: number;
154
+ cursor_row_max?: number;
155
+ cursor_col_min?: number;
156
+ cursor_col_max?: number;
157
+ }
158
+ /** v3 delta condition: N lines above cursor changed vs prevLines. */
159
+ export interface ChangedCondition {
160
+ cursor_above: number;
161
+ changed: true;
162
+ }
163
+ /** v3 AND composite. */
164
+ export interface AllCondition {
165
+ all: Condition[];
166
+ }
167
+ /** v3 OR composite. */
168
+ export interface AnyCondition {
169
+ any: Condition[];
170
+ }
171
+ export type Condition = RegexCondition | ChangedCondition | AllCondition | AnyCondition;
172
+ /** v3 extract_title config. */
173
+ export interface ExtractTitle {
174
+ section?: string;
175
+ regex?: string;
176
+ flags?: string;
177
+ first_line?: true;
178
+ }
179
+ /** v3 extract_buttons config. */
180
+ export interface ExtractButtons {
181
+ section?: string;
182
+ pattern: string;
183
+ flags?: string;
184
+ key_for_index: string;
185
+ min_count?: number;
186
+ continuation_lines?: boolean;
187
+ }
188
+ /** v3 state. */
189
+ export interface SpecStateV3 {
190
+ id: string;
191
+ label: string;
192
+ when: AllCondition | AnyCondition;
193
+ extract?: {
194
+ title?: ExtractTitle;
195
+ buttons?: ExtractButtons;
196
+ };
197
+ }
198
+ export interface CliSpec {
199
+ $schema: 'adhdev:cli/spec@3';
200
+ id: string;
201
+ name: string;
202
+ binary: string;
203
+ spawn_args?: string[];
204
+ env?: Record<string, string>;
205
+ cli_version_range?: string;
206
+ send_message: {
207
+ submit_key: string;
208
+ delay_ms_before_submit?: number;
209
+ delay_ms_per_char?: number;
210
+ };
211
+ sections: Record<string, SectionDef>;
212
+ states: SpecStateV3[];
213
+ default_state: string;
214
+ control_bar?: Control[];
215
+ notifications?: NotificationRule[];
216
+ delegate?: DelegateTrigger[];
217
+ native_history?: NativeHistoryConfig;
218
+ requiresFinalAssistantBeforeIdle?: boolean;
219
+ /**
220
+ * Per-spec timing knobs. Replaces v1 `debounce`.
221
+ * Also accessible via the legacy `debounce` alias in the driver for
222
+ * backward compat with older callers.
223
+ */
224
+ timing?: {
225
+ busy_hold_ms?: number;
226
+ idle_hold_ms?: number;
227
+ startup_grace_ms?: number;
228
+ completion_marker?: {
229
+ section?: string;
230
+ matches: string;
231
+ flags?: string;
232
+ hold_ms: number;
233
+ force_after_ms?: number;
234
+ };
235
+ };
236
+ /**
237
+ * Legacy alias: v1 callers (tests, tooling) may read `debounce`.
238
+ * The loader populates both `timing` and `debounce` pointing at the
239
+ * same object so callers that use either field see consistent values.
240
+ * @deprecated Use `timing` instead.
241
+ */
242
+ debounce?: {
243
+ busy_hold_ms?: number;
244
+ idle_hold_ms?: number;
245
+ startup_grace_ms?: number;
246
+ /**
247
+ * Legacy field name for completion_marker. Populated by the loader
248
+ * from `timing.completion_marker` for backward compat.
249
+ */
250
+ completion_idle_after?: {
251
+ section?: string;
252
+ regex: string;
253
+ flags?: string;
254
+ hold_ms: number;
255
+ force_after_ms?: number;
256
+ };
257
+ };
258
+ }
259
+ /** Raw v1 spec shape as loaded from JSON. Used only in migrateV1toV3. */
260
+ export interface RawCliSpecV1 {
261
+ $schema: 'adhdev:cli/spec@1';
262
+ id: string;
263
+ name: string;
264
+ binary: string;
265
+ spawn_args?: string[];
266
+ env?: Record<string, string>;
267
+ cli_version_range?: string;
268
+ send_message: {
269
+ submit_key: string;
270
+ delay_ms_before_submit?: number;
271
+ delay_ms_per_char?: number;
272
+ };
273
+ layout: {
274
+ sections: Section[];
275
+ };
276
+ states: Array<{
277
+ id: string;
278
+ label: string;
279
+ when: SectionRegex;
280
+ extract_title?: SectionRegex;
281
+ modal_buttons?: ModalButtonsRule;
282
+ }>;
283
+ default_state: string;
284
+ control_bar?: Control[];
285
+ notifications?: NotificationRule[];
286
+ delegate?: DelegateTrigger[];
287
+ native_history?: NativeHistoryConfig;
288
+ requiresFinalAssistantBeforeIdle?: boolean;
289
+ debounce?: {
290
+ busy_hold_ms?: number;
291
+ idle_hold_ms?: number;
292
+ startup_grace_ms?: number;
293
+ completion_idle_after?: {
294
+ section?: string;
295
+ regex: string;
296
+ flags?: string;
297
+ hold_ms: number;
298
+ force_after_ms?: number;
299
+ };
300
+ };
301
+ }
302
+ export type SpecState = SpecStateV3;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Chat Transcript Contract v2
3
+ *
4
+ * First-class message identity, monotonic sequence, strict enums. Designed to
5
+ * replace the v1 contract (contracts.ts ReadChatResult + types.ts ChatMessage)
6
+ * during the A2 big-bang. This module defines the contract; it does not yet
7
+ * change runtime behaviour. v1 keeps working until A2 flips the switch.
8
+ *
9
+ * Invariants v2 enforces (and v1 does not):
10
+ * 1. Every ChatMessageV2 has providerUnitKey, bubbleId, sequence — none optional.
11
+ * 2. sequence is a monotonic integer per (sessionId, source) tuple. Producers
12
+ * never reuse it; consumers MAY assume strict ordering.
13
+ * 3. providerUnitKey is stable across re-reads: the same logical message
14
+ * always yields the same key even if its index shifts or content is
15
+ * edited mid-stream. Producers derive it from provider-owned identifiers
16
+ * (turn id, native message id), not from content hashes or array index.
17
+ * 4. timestamp is producer-asserted wall-clock; orderingTimestamp is monotonic
18
+ * and used for snapshot diffs. 1ms fallback increments are forbidden — if
19
+ * a producer cannot supply a stable monotonic value, the daemon assigns
20
+ * sequence at ingest and orderingTimestamp = ingestedAt.
21
+ * 5. visibility / source / role / kind are strict unions. No `(string & {})`
22
+ * escape hatches.
23
+ * 6. Coverage is exactly one of full/tail/current-turn. Mixing it with
24
+ * partialReason or unavailableReason is a contract violation.
25
+ * 7. workspace / sessionId are explicit on every ReadChatResultV2; the daemon
26
+ * no longer infers them from message bodies.
27
+ */
28
+ import type { MessagePart, ToolCallInfo } from './contracts.js';
29
+ export declare const CHAT_CONTRACT_VERSION_V1: "1.0";
30
+ export declare const CHAT_CONTRACT_VERSION_V2: "2.0";
31
+ export type ChatContractVersion = typeof CHAT_CONTRACT_VERSION_V1 | typeof CHAT_CONTRACT_VERSION_V2;
32
+ export declare const SUPPORTED_CHAT_CONTRACT_VERSIONS: readonly ChatContractVersion[];
33
+ export declare const CHAT_ROLES_V2: readonly ["user", "assistant", "system"];
34
+ export type ChatRoleV2 = typeof CHAT_ROLES_V2[number];
35
+ export declare const CHAT_MESSAGE_KINDS_V2: readonly ["standard", "thought", "tool", "terminal", "system"];
36
+ export type ChatMessageKindV2 = typeof CHAT_MESSAGE_KINDS_V2[number];
37
+ export declare const CHAT_VISIBILITIES_V2: readonly ["user", "debug", "internal", "hidden"];
38
+ export type ChatVisibilityV2 = typeof CHAT_VISIBILITIES_V2[number];
39
+ export declare const CHAT_AUDIENCES_V2: readonly ["chat", "debug", "trace", "internal"];
40
+ export type ChatAudienceV2 = typeof CHAT_AUDIENCES_V2[number];
41
+ export declare const CHAT_SOURCES_V2: readonly ["assistant_text", "tool_call", "terminal_command", "runtime_activity", "runtime_status", "provider_chrome", "control"];
42
+ export type ChatSourceV2 = typeof CHAT_SOURCES_V2[number];
43
+ export declare const CHAT_BUBBLE_STATES_V2: readonly ["draft", "streaming", "final", "removed"];
44
+ export type ChatBubbleStateV2 = typeof CHAT_BUBBLE_STATES_V2[number];
45
+ /**
46
+ * Stable identity of a single chat message. All fields are required in v2.
47
+ *
48
+ * - providerUnitKey: provider-owned canonical id. Must be derivable from
49
+ * provider primitives (native message id, turn id, bubble id), NOT from
50
+ * array index or content hash. Stable across re-reads of the same logical
51
+ * message even if neighbours change.
52
+ * - bubbleId: dashboard-owned bubble identity. May equal providerUnitKey when
53
+ * the provider already exposes a bubble-grained id; otherwise daemon
54
+ * derives it deterministically from providerUnitKey (e.g. `bubble:${key}`).
55
+ * - sequence: monotonic integer per (sessionId, source). Strictly increasing
56
+ * over the lifetime of the session. Used for snapshot diffs and dedup.
57
+ * - turnKey: stable identifier for the conversation turn this message belongs
58
+ * to. Required so consumers can group messages without re-deriving turns.
59
+ */
60
+ export interface MessageIdentityV2 {
61
+ providerUnitKey: string;
62
+ bubbleId: string;
63
+ sequence: number;
64
+ turnKey: string;
65
+ }
66
+ /**
67
+ * Producer-asserted wall-clock time (ms since epoch). Forward jumps are
68
+ * permitted; consumers MUST NOT rely on this for ordering.
69
+ */
70
+ export type ChatTimestampMs = number;
71
+ /**
72
+ * Monotonic ordering value (ms since epoch, but assigned by the daemon at
73
+ * ingest to guarantee monotonicity even if the producer's wall clock skews).
74
+ * Used by snapshot diffs in place of timestamp.
75
+ */
76
+ export type ChatOrderingTimestampMs = number;
77
+ export interface ChatMessageV2 extends MessageIdentityV2 {
78
+ role: ChatRoleV2;
79
+ kind: ChatMessageKindV2;
80
+ content: string | MessagePart[];
81
+ bubbleState: ChatBubbleStateV2;
82
+ timestamp: ChatTimestampMs;
83
+ orderingTimestamp: ChatOrderingTimestampMs;
84
+ visibility: ChatVisibilityV2;
85
+ audience: ChatAudienceV2;
86
+ source: ChatSourceV2;
87
+ /** Sender display name (for shared sessions). Empty string when unused. */
88
+ senderName: string;
89
+ /** Tool calls associated with this message. Empty array when none. */
90
+ toolCalls: ToolCallInfo[];
91
+ /** Producer-defined metadata. Daemon never inspects this except for passthrough. */
92
+ meta: Readonly<Record<string, unknown>>;
93
+ }
94
+ export interface WorkspaceContextV2 {
95
+ /** Absolute realpath of the workspace the session is reading from. */
96
+ workspacePath: string;
97
+ /** Workspace the session was intended to operate on (may differ during cross-workspace ops). */
98
+ intendedWorkspacePath: string;
99
+ }
100
+ export interface SessionContextV2 {
101
+ /** Provider-owned session id (e.g. claude.jsonl uuid, codex session_meta.id). */
102
+ providerSessionId: string;
103
+ /** Optional daemon-side history alias used to disambiguate within a workspace. */
104
+ historySessionId?: string;
105
+ }
106
+ /**
107
+ * v1 allowed `coverage='full'` to coexist with `partialReason`/`unavailableReason`,
108
+ * which is a contract lie. v2 makes the three states mutually exclusive.
109
+ */
110
+ export type CoverageHintV2 = {
111
+ kind: 'full';
112
+ } | {
113
+ kind: 'tail';
114
+ tailMessageCount: number;
115
+ } | {
116
+ kind: 'current-turn';
117
+ turnKey: string;
118
+ } | {
119
+ kind: 'partial';
120
+ partialReason: string;
121
+ } | {
122
+ kind: 'unavailable';
123
+ unavailableReason: string;
124
+ };
125
+ export type CanonicalHistoryModeV2 = 'native-source' | 'disabled' | 'materialized-mirror';
126
+ export interface CanonicalHistoryDeclarationV2 {
127
+ contractVersion: ChatContractVersion;
128
+ format: string;
129
+ mode: CanonicalHistoryModeV2;
130
+ watchPath?: string;
131
+ scripts: {
132
+ readSession: string;
133
+ listSessions: string;
134
+ };
135
+ }
136
+ export type ReadChatStatusV2 = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'panel_hidden' | 'streaming';
137
+ export type ReadChatTurnStatusV2 = 'open' | 'waiting_approval' | 'complete' | 'error';
138
+ export interface ReadChatResultV2 {
139
+ contractVersion: typeof CHAT_CONTRACT_VERSION_V2;
140
+ workspace: WorkspaceContextV2;
141
+ session: SessionContextV2;
142
+ coverage: CoverageHintV2;
143
+ status: ReadChatStatusV2;
144
+ messages: ChatMessageV2[];
145
+ currentTurnId: string;
146
+ turnStatus: ReadChatTurnStatusV2;
147
+ transcriptAuthority: 'provider' | 'daemon';
148
+ }
149
+ export declare class ChatContractViolationError extends Error {
150
+ readonly violationPath: string;
151
+ readonly contractVersion: ChatContractVersion;
152
+ constructor(contractVersion: ChatContractVersion, violationPath: string, detail: string);
153
+ }
154
+ /**
155
+ * Validate a v2 read_chat payload. Throws ChatContractViolationError on the
156
+ * first violation. v2 invariants beyond per-field checks:
157
+ * - messages[*].sequence strictly increasing
158
+ * - messages[*].orderingTimestamp monotonic non-decreasing
159
+ * - coverage union is well-formed
160
+ */
161
+ export declare function assertReadChatResultV2Payload(raw: unknown): ReadChatResultV2;
162
+ export declare function isSupportedChatContractVersion(value: unknown): value is ChatContractVersion;
163
+ /**
164
+ * Read a provider's declared chat contract version from its parsed
165
+ * provider.json `canonicalHistory.contractVersion` field.
166
+ *
167
+ * - Absent or unrecognized → treated as v1 (legacy behaviour preserved during
168
+ * the A1 transition). A2 will tighten this to reject unsupported versions
169
+ * at provider load time.
170
+ * - Present and supported → returned as-is.
171
+ *
172
+ * The returned version drives which validator (assertReadChatResultV2Payload
173
+ * vs the legacy validateReadChatResultPayload) processes the provider's
174
+ * read_chat output.
175
+ */
176
+ export declare function readDeclaredChatContractVersion(canonicalHistory: unknown): ChatContractVersion;
@@ -0,0 +1,48 @@
1
+ export interface InteractivePrompt {
2
+ promptId: string;
3
+ origin: 'cli' | 'mcp' | 'agent';
4
+ providerType: string;
5
+ createdAt: number;
6
+ questions: InteractiveQuestion[];
7
+ }
8
+ export interface InteractiveQuestion {
9
+ questionId: string;
10
+ question: string;
11
+ header?: string;
12
+ multiSelect: boolean;
13
+ options: InteractiveOption[];
14
+ allowFreeform?: boolean;
15
+ }
16
+ export interface InteractiveOption {
17
+ label: string;
18
+ description?: string;
19
+ preview?: string;
20
+ }
21
+ export interface InteractivePromptResponse {
22
+ promptId: string;
23
+ answers: Record<string, InteractiveAnswer>;
24
+ }
25
+ export interface InteractiveAnswer {
26
+ selectedLabels: string[];
27
+ freeformText?: string;
28
+ }
29
+ export declare function normalizeInteractivePrompt(raw: unknown): InteractivePrompt | null;
30
+ export declare function normalizeInteractivePromptResponse(raw: unknown): InteractivePromptResponse;
31
+ export declare function buildClaudeInteractiveToolResult(response: InteractivePromptResponse): string;
32
+ export interface ClaudeInteractiveTuiPage {
33
+ screenText: string;
34
+ header?: string;
35
+ }
36
+ export declare function detectClaudeAskUserQuestionPromptFromTuiPages(pages: ClaudeInteractiveTuiPage[], options: {
37
+ promptId: string;
38
+ providerType?: string;
39
+ createdAt?: number;
40
+ }): InteractivePrompt | null;
41
+ export declare function buildClaudeInteractiveTuiAnswerSteps(prompt: InteractivePrompt, response: InteractivePromptResponse): string[];
42
+ export declare function interactivePromptFromClaudeAskUserQuestion(input: unknown, options: {
43
+ promptId: string;
44
+ providerType: string;
45
+ createdAt?: number;
46
+ origin?: InteractivePrompt['origin'];
47
+ }): InteractivePrompt | null;
48
+ export declare function detectClaudeAskUserQuestionPromptFromJson(value: unknown, providerType?: string): InteractivePrompt | null;