@adhdev/daemon-core 0.9.82-rc.18 → 0.9.82-rc.180

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 (223) hide show
  1. package/dist/boot/process-hardening.d.ts +50 -0
  2. package/dist/chat/source-machine.d.ts +166 -0
  3. package/dist/chat/source-resolver.d.ts +104 -0
  4. package/dist/chat/subscription-updates.d.ts +1 -0
  5. package/dist/cli-adapter-types.d.ts +22 -2
  6. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  7. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  8. package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
  9. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  10. package/dist/cli-adapters/provider-cli-shared.d.ts +29 -0
  11. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  12. package/dist/commands/handler.d.ts +110 -0
  13. package/dist/commands/mesh-coordinator.d.ts +72 -1
  14. package/dist/commands/router.d.ts +22 -0
  15. package/dist/config/chat-history.d.ts +8 -0
  16. package/dist/config/config.d.ts +5 -0
  17. package/dist/config/mesh-config.d.ts +72 -1
  18. package/dist/git/git-commands.d.ts +5 -1
  19. package/dist/index.d.ts +35 -8
  20. package/dist/index.js +19937 -4800
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +20357 -5290
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/installer.d.ts +1 -4
  25. package/dist/ipc/local-ipc-server.d.ts +91 -0
  26. package/dist/launch.d.ts +1 -1
  27. package/dist/logging/async-batch-writer.d.ts +10 -0
  28. package/dist/mesh/beads-db.d.ts +72 -0
  29. package/dist/mesh/contracts.d.ts +164 -0
  30. package/dist/mesh/coordinator-prompt.d.ts +30 -0
  31. package/dist/mesh/coordinator-registry.d.ts +59 -0
  32. package/dist/mesh/mesh-active-work.d.ts +90 -0
  33. package/dist/mesh/mesh-events.d.ts +97 -5
  34. package/dist/mesh/mesh-fast-forward.d.ts +41 -0
  35. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  36. package/dist/mesh/mesh-ledger.d.ts +58 -1
  37. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  38. package/dist/mesh/mesh-work-queue.d.ts +54 -6
  39. package/dist/mesh/preview-freshness.d.ts +18 -0
  40. package/dist/mesh/refine-config.d.ts +193 -0
  41. package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
  42. package/dist/providers/approval-utils.d.ts +13 -0
  43. package/dist/providers/cli-provider-instance.d.ts +15 -3
  44. package/dist/providers/contracts.d.ts +98 -5
  45. package/dist/providers/external-sources.d.ts +71 -0
  46. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  47. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  48. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  49. package/dist/providers/native-history/dispatcher.d.ts +25 -0
  50. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  51. package/dist/providers/native-history/index.d.ts +13 -0
  52. package/dist/providers/provider-instance.d.ts +3 -0
  53. package/dist/providers/provider-loader.d.ts +26 -4
  54. package/dist/providers/provider-trust.d.ts +31 -0
  55. package/dist/providers/read-chat-contract.d.ts +29 -0
  56. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  57. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  58. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  59. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  60. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  61. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  62. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  63. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  64. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  65. package/dist/providers/sdk/v1/index.d.ts +30 -0
  66. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  67. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  68. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  69. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  70. package/dist/providers/sdk/v1/types/common/index.d.ts +169 -0
  71. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  72. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  73. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  74. package/dist/providers/spec/adapter.d.ts +56 -0
  75. package/dist/providers/spec/cli-adapter.d.ts +95 -0
  76. package/dist/providers/spec/driver.d.ts +159 -0
  77. package/dist/providers/spec/evaluator.d.ts +47 -0
  78. package/dist/providers/spec/loader.d.ts +14 -0
  79. package/dist/providers/spec/native-history-executor.d.ts +39 -0
  80. package/dist/providers/spec/route.d.ts +4 -0
  81. package/dist/providers/spec/schema.gen.d.ts +511 -0
  82. package/dist/providers/spec/types.d.ts +212 -0
  83. package/dist/providers/transcript-v2.d.ts +176 -0
  84. package/dist/providers/types/interactive-prompt.d.ts +48 -0
  85. package/dist/repo-mesh-types.d.ts +102 -1
  86. package/dist/sessions/registry.d.ts +3 -0
  87. package/dist/shared-types.d.ts +42 -1
  88. package/dist/status/reporter.d.ts +2 -0
  89. package/dist/status/snapshot.d.ts +1 -0
  90. package/dist/types.d.ts +5 -0
  91. package/package.json +7 -2
  92. package/src/agent-stream/poller.ts +2 -3
  93. package/src/boot/daemon-lifecycle.ts +17 -10
  94. package/src/boot/process-hardening.ts +89 -0
  95. package/src/chat/source-machine.ts +534 -0
  96. package/src/chat/source-resolver.ts +0 -0
  97. package/src/chat/subscription-updates.ts +14 -1
  98. package/src/cli-adapter-types.d.ts +1 -0
  99. package/src/cli-adapter-types.ts +21 -2
  100. package/src/cli-adapters/cli-script-runner.ts +421 -0
  101. package/src/cli-adapters/cli-state-engine.ts +1086 -0
  102. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  103. package/src/cli-adapters/provider-cli-adapter.ts +670 -1137
  104. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  105. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  106. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  107. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  108. package/src/cli-adapters/provider-cli-shared.ts +59 -11
  109. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  110. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
  111. package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
  112. package/src/commands/chat-commands.ts +1597 -60
  113. package/src/commands/cli-manager.ts +214 -3
  114. package/src/commands/handler.ts +809 -2
  115. package/src/commands/mesh-coordinator.ts +231 -127
  116. package/src/commands/router.ts +3495 -502
  117. package/src/config/chat-history.ts +91 -24
  118. package/src/config/config.ts +12 -0
  119. package/src/config/mesh-config.ts +280 -2
  120. package/src/config/recent-activity.ts +8 -2
  121. package/src/daemon/dev-cli-debug.ts +10 -1
  122. package/src/detection/ide-detector.ts +26 -16
  123. package/src/git/git-commands.ts +17 -5
  124. package/src/git/git-worktree.ts +8 -1
  125. package/src/index.ts +113 -7
  126. package/src/installer.d.ts +1 -1
  127. package/src/installer.ts +8 -6
  128. package/src/ipc/local-ipc-server.ts +278 -0
  129. package/src/launch.d.ts +1 -1
  130. package/src/launch.ts +37 -28
  131. package/src/logging/async-batch-writer.ts +55 -0
  132. package/src/logging/logger.ts +2 -1
  133. package/src/mesh/beads-db.ts +486 -0
  134. package/src/mesh/contracts.ts +329 -0
  135. package/src/mesh/coordinator-prompt.ts +204 -30
  136. package/src/mesh/coordinator-registry.ts +121 -0
  137. package/src/mesh/mesh-active-work.ts +437 -0
  138. package/src/mesh/mesh-events.ts +982 -67
  139. package/src/mesh/mesh-fast-forward.ts +438 -0
  140. package/src/mesh/mesh-host-ownership.ts +73 -0
  141. package/src/mesh/mesh-ledger.ts +457 -104
  142. package/src/mesh/mesh-refine-status.ts +144 -0
  143. package/src/mesh/mesh-work-queue.ts +263 -159
  144. package/src/mesh/preview-freshness.ts +118 -0
  145. package/src/mesh/refine-config.ts +366 -0
  146. package/src/mesh/worktree-bootstrap-config.ts +247 -0
  147. package/src/providers/approval-utils.d.ts +4 -0
  148. package/src/providers/approval-utils.ts +47 -5
  149. package/src/providers/chat-message-normalization.ts +4 -11
  150. package/src/providers/cli-provider-instance.ts +598 -55
  151. package/src/providers/contracts.ts +105 -5
  152. package/src/providers/external-sources.ts +218 -0
  153. package/src/providers/ide-provider-instance.ts +19 -5
  154. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  155. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  156. package/src/providers/native-history/codex-cli-transcript.ts +419 -0
  157. package/src/providers/native-history/dispatcher.ts +231 -0
  158. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  159. package/src/providers/native-history/index.ts +30 -0
  160. package/src/providers/provider-instance.ts +3 -0
  161. package/src/providers/provider-loader.ts +585 -50
  162. package/src/providers/provider-schema.ts +31 -13
  163. package/src/providers/provider-trust.ts +114 -0
  164. package/src/providers/read-chat-contract.ts +76 -16
  165. package/src/providers/sdk/README.md +49 -0
  166. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  167. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  168. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  169. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  170. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  171. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  172. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  173. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  174. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  175. package/src/providers/sdk/v1/index.ts +152 -0
  176. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  177. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  178. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  179. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +458 -0
  180. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  181. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  182. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  183. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  184. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  185. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  186. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  187. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  188. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  189. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  190. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  191. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  192. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  193. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  194. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  195. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  196. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  197. package/src/providers/sdk/v1/types/common/index.ts +210 -0
  198. package/src/providers/sdk/v1/validators/index.ts +19 -0
  199. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  200. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  201. package/src/providers/spec/adapter.ts +168 -0
  202. package/src/providers/spec/cli-adapter.ts +453 -0
  203. package/src/providers/spec/driver.ts +540 -0
  204. package/src/providers/spec/evaluator.ts +298 -0
  205. package/src/providers/spec/loader.ts +130 -0
  206. package/src/providers/spec/native-history-executor.ts +706 -0
  207. package/src/providers/spec/route.ts +51 -0
  208. package/src/providers/spec/schema.gen.ts +511 -0
  209. package/src/providers/spec/schema.json +211 -0
  210. package/src/providers/spec/types.ts +231 -0
  211. package/src/providers/transcript-v2.ts +567 -0
  212. package/src/providers/types/interactive-prompt.ts +297 -0
  213. package/src/providers/version-archive.ts +38 -20
  214. package/src/repo-mesh-types.ts +112 -1
  215. package/src/sessions/registry.ts +3 -0
  216. package/src/shared-types.ts +45 -1
  217. package/src/status/builders.ts +24 -6
  218. package/src/status/reporter.ts +15 -0
  219. package/src/status/snapshot.ts +84 -25
  220. package/src/system/host-memory.ts +29 -12
  221. package/src/types.ts +5 -0
  222. package/dist/mesh/mesh-sync.d.ts +0 -53
  223. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,211 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "adhdev:cli/spec@1",
4
+ "title": "ADHDev CLI provider spec",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["$schema", "id", "name", "binary", "send_message", "layout", "states", "default_state"],
8
+ "properties": {
9
+ "$schema": { "type": "string", "const": "adhdev:cli/spec@1" },
10
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9-]*$" },
11
+ "name": { "type": "string", "minLength": 1 },
12
+ "binary": { "type": "string", "minLength": 1 },
13
+ "spawn_args": { "type": "array", "items": { "type": "string" }, "default": [] },
14
+ "env": {
15
+ "type": "object",
16
+ "additionalProperties": { "type": "string" },
17
+ "default": {}
18
+ },
19
+ "send_message": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "required": ["submit_key"],
23
+ "properties": {
24
+ "submit_key": { "type": "string", "minLength": 1 },
25
+ "delay_ms_before_submit": { "type": "integer", "minimum": 0 },
26
+ "delay_ms_per_char": { "type": "integer", "minimum": 0 }
27
+ }
28
+ },
29
+ "layout": {
30
+ "type": "object",
31
+ "additionalProperties": false,
32
+ "required": ["sections"],
33
+ "properties": {
34
+ "sections": {
35
+ "type": "array",
36
+ "minItems": 1,
37
+ "items": { "$ref": "#/definitions/section" }
38
+ }
39
+ }
40
+ },
41
+ "states": {
42
+ "type": "array",
43
+ "minItems": 1,
44
+ "items": { "$ref": "#/definitions/state" }
45
+ },
46
+ "default_state": { "type": "string", "minLength": 1 },
47
+ "control_bar": {
48
+ "type": "array",
49
+ "default": [],
50
+ "items": { "$ref": "#/definitions/control" }
51
+ },
52
+ "notifications": {
53
+ "type": "array",
54
+ "default": [],
55
+ "items": { "$ref": "#/definitions/notification" }
56
+ },
57
+ "delegate": {
58
+ "type": "array",
59
+ "default": [],
60
+ "items": { "$ref": "#/definitions/delegateTrigger" }
61
+ },
62
+ "native_history": { "$ref": "#/definitions/nativeHistory" }
63
+ },
64
+ "definitions": {
65
+ "size": {
66
+ "oneOf": [
67
+ { "type": "integer", "minimum": 0 },
68
+ { "type": "string", "pattern": "^\\d+(\\.\\d+)?%$" }
69
+ ]
70
+ },
71
+ "section": {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": ["id"],
75
+ "properties": {
76
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
77
+ "from_top": { "$ref": "#/definitions/size" },
78
+ "from_bottom": { "$ref": "#/definitions/size" },
79
+ "until": {
80
+ "type": "object",
81
+ "additionalProperties": false,
82
+ "required": ["section"],
83
+ "properties": { "section": { "type": "string" } }
84
+ }
85
+ }
86
+ },
87
+ "sectionRegex": {
88
+ "type": "object",
89
+ "additionalProperties": false,
90
+ "required": ["regex"],
91
+ "properties": {
92
+ "section": { "type": "string" },
93
+ "regex": { "type": "string", "minLength": 1 },
94
+ "flags": { "type": "string", "default": "i" }
95
+ }
96
+ },
97
+ "sectionPattern": {
98
+ "type": "object",
99
+ "additionalProperties": false,
100
+ "required": ["pattern"],
101
+ "properties": {
102
+ "section": { "type": "string" },
103
+ "pattern": { "type": "string", "minLength": 1 },
104
+ "flags": { "type": "string", "default": "" }
105
+ }
106
+ },
107
+ "state": {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "required": ["id", "label", "when"],
111
+ "properties": {
112
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
113
+ "label": { "type": "string", "minLength": 1 },
114
+ "when": { "$ref": "#/definitions/sectionRegex" },
115
+ "extract_title": { "$ref": "#/definitions/sectionRegex" },
116
+ "modal_buttons": {
117
+ "type": "object",
118
+ "additionalProperties": false,
119
+ "required": ["pattern", "key_for_index"],
120
+ "properties": {
121
+ "section": { "type": "string" },
122
+ "pattern": { "type": "string", "minLength": 1 },
123
+ "flags": { "type": "string" },
124
+ "key_for_index": { "type": "string", "minLength": 1 },
125
+ "min_count": { "type": "integer", "minimum": 1, "default": 2 },
126
+ "continuation_lines": { "type": "boolean", "default": false }
127
+ }
128
+ }
129
+ }
130
+ },
131
+ "control": {
132
+ "type": "object",
133
+ "additionalProperties": false,
134
+ "required": ["id", "label", "action"],
135
+ "properties": {
136
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
137
+ "label": { "type": "string", "minLength": 1 },
138
+ "visible_when_state": { "type": "array", "items": { "type": "string" } },
139
+ "action": { "$ref": "#/definitions/controlAction" }
140
+ }
141
+ },
142
+ "controlAction": {
143
+ "oneOf": [
144
+ {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "required": ["type", "keys"],
148
+ "properties": {
149
+ "type": { "const": "send_keys" },
150
+ "keys": { "type": "string", "minLength": 1 }
151
+ }
152
+ },
153
+ {
154
+ "type": "object",
155
+ "additionalProperties": false,
156
+ "required": ["type", "trigger_keys", "wait_for", "extract_choices", "submit_key"],
157
+ "properties": {
158
+ "type": { "const": "open_picker" },
159
+ "trigger_keys": { "type": "string", "minLength": 1 },
160
+ "wait_for": { "$ref": "#/definitions/sectionRegex" },
161
+ "extract_choices": { "$ref": "#/definitions/sectionPattern" },
162
+ "submit_key": { "type": "string", "minLength": 1 }
163
+ }
164
+ },
165
+ {
166
+ "type": "object",
167
+ "additionalProperties": false,
168
+ "required": ["type", "method", "keys_template"],
169
+ "properties": {
170
+ "type": { "const": "attach_image" },
171
+ "method": { "const": "tempfile_then_keys" },
172
+ "keys_template": { "type": "string", "minLength": 1 }
173
+ }
174
+ }
175
+ ]
176
+ },
177
+ "notification": {
178
+ "type": "object",
179
+ "additionalProperties": false,
180
+ "required": ["id", "when_state", "title"],
181
+ "properties": {
182
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
183
+ "when_state": { "type": "string", "minLength": 1 },
184
+ "title": { "type": "string", "minLength": 1 },
185
+ "body": { "type": "string" }
186
+ }
187
+ },
188
+ "nativeHistory": {
189
+ "type": "object",
190
+ "additionalProperties": false,
191
+ "required": ["reader"],
192
+ "properties": {
193
+ "reader": {
194
+ "type": "string",
195
+ "enum": ["claude-cli", "codex-cli", "antigravity-cli", "hermes-cli"]
196
+ }
197
+ }
198
+ },
199
+ "delegateTrigger": {
200
+ "type": "object",
201
+ "additionalProperties": false,
202
+ "required": ["id", "when_state", "task_template"],
203
+ "properties": {
204
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
205
+ "when_state": { "type": "string", "minLength": 1 },
206
+ "after_duration_ms": { "type": "integer", "minimum": 0 },
207
+ "task_template": { "type": "string", "minLength": 1 }
208
+ }
209
+ }
210
+ }
211
+ }
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Type mirror of adhdev:cli/spec@1. Keep in sync with schema.json.
3
+ * Adding a field here without also adding it to schema.json (or vice
4
+ * versa) is a bug — the loader rejects specs that don't match the
5
+ * schema, so a missing field would fail at load time.
6
+ */
7
+ 'use strict';
8
+
9
+ export type Size = number | string;
10
+
11
+ export interface Section {
12
+ id: string;
13
+ from_top?: Size;
14
+ from_bottom?: Size;
15
+ until?: { section: string };
16
+ }
17
+
18
+ export interface SectionRegex {
19
+ section?: string;
20
+ regex: string;
21
+ flags?: string;
22
+ }
23
+
24
+ export interface SectionPattern {
25
+ section?: string;
26
+ pattern: string;
27
+ flags?: string;
28
+ }
29
+
30
+ export interface ModalButtonsRule {
31
+ section?: string;
32
+ pattern: string;
33
+ flags?: string;
34
+ key_for_index: string;
35
+ min_count?: number;
36
+ continuation_lines?: boolean;
37
+ }
38
+
39
+ export interface SpecState {
40
+ id: string;
41
+ label: string;
42
+ when: SectionRegex;
43
+ extract_title?: SectionRegex;
44
+ modal_buttons?: ModalButtonsRule;
45
+ }
46
+
47
+ export type ControlAction =
48
+ | { type: 'send_keys'; keys: string }
49
+ | {
50
+ type: 'open_picker';
51
+ trigger_keys: string;
52
+ wait_for: SectionRegex;
53
+ extract_choices: SectionPattern;
54
+ submit_key: string;
55
+ }
56
+ | {
57
+ type: 'attach_image';
58
+ method: 'tempfile_then_keys';
59
+ keys_template: string;
60
+ };
61
+
62
+ export interface Control {
63
+ id: string;
64
+ label: string;
65
+ visible_when_state?: string[];
66
+ action: ControlAction;
67
+ }
68
+
69
+ export interface NotificationRule {
70
+ id: string;
71
+ when_state: string;
72
+ title: string;
73
+ body?: string;
74
+ }
75
+
76
+ export interface DelegateTrigger {
77
+ id: string;
78
+ when_state: string;
79
+ after_duration_ms?: number;
80
+ task_template: string;
81
+ }
82
+
83
+ /**
84
+ * Native history config — three modes, picked by which fields are present:
85
+ *
86
+ * 1. `reader`: built-in reader id (claude-cli / codex-cli / antigravity-cli / hermes-cli).
87
+ * Backwards-compatible path used by the four shipped providers.
88
+ *
89
+ * 2. `source`: declarative source descriptor. The daemon's spec native-history
90
+ * executor reads the on-disk store (jsonl file / sqlite db) directly using
91
+ * paths + jsonpath maps from this block. New providers should prefer this
92
+ * mode — no daemon changes required.
93
+ *
94
+ * 3. `override_path`: relative path to a provider-supplied reader module
95
+ * (e.g. "./native_history/index.js"). Escape hatch for formats too
96
+ * exotic for the declarative executor. The module must default-export
97
+ * a function with the signature
98
+ * (input: NativeHistoryInput) => NativeHistoryResult | null
99
+ * and runs under provider-script-root sandboxing (same gate as
100
+ * scripts.js).
101
+ *
102
+ * The three modes are mutually exclusive — set exactly one. Loader rejects
103
+ * specs that set zero or more than one.
104
+ */
105
+ export interface NativeHistoryConfig {
106
+ reader?: 'claude-cli' | 'codex-cli' | 'antigravity-cli' | 'hermes-cli';
107
+ source?: NativeHistorySource;
108
+ override_path?: string;
109
+ }
110
+
111
+ export type NativeHistorySource =
112
+ | NativeHistoryJsonlSource
113
+ | NativeHistorySqliteSource;
114
+
115
+ /**
116
+ * JSONL source — each line in the resolved file is one record.
117
+ *
118
+ * `path` accepts ~/, environment variables (${HOME}), and a small set of
119
+ * runtime variables:
120
+ * {cwd} — the session's working directory, raw
121
+ * {cwd_dashed} — cwd with `/` replaced by `-` (claude's per-project key)
122
+ * {session_id} — providerSessionId, when known
123
+ * {yyyy} {mm} {dd} — UTC date components
124
+ *
125
+ * When `path` resolves to a directory, the daemon picks the newest file
126
+ * matching `file_pattern` whose mtime is inside `recent_window_ms` (default
127
+ * 5min) — prevents the wrong session's transcript from leaking through.
128
+ */
129
+ export interface NativeHistoryJsonlSource {
130
+ kind: 'jsonl';
131
+ path: string;
132
+ file_pattern?: string;
133
+ recent_window_ms?: number;
134
+ session_id_from?: 'filename_uuid' | 'first_record';
135
+ session_id_path?: string; // jsonpath into the first record when session_id_from='first_record'
136
+ message_filter?: { where: string }; // tiny expression: field op value joined by && / ||
137
+ message_map: NativeHistoryMessageMap;
138
+ }
139
+
140
+ /**
141
+ * SQLite source — provider runs two queries on a read-only handle: one to
142
+ * pick the session row (`session_query` — first row's first column is the
143
+ * sessionId), then one to fetch messages (`message_query` — `?` is bound
144
+ * to the sessionId). Output rows are projected through `message_map`.
145
+ */
146
+ export interface NativeHistorySqliteSource {
147
+ kind: 'sqlite';
148
+ path: string;
149
+ session_query: string;
150
+ message_query: string;
151
+ message_map: NativeHistoryMessageMap;
152
+ }
153
+
154
+ /**
155
+ * Maps a source record (jsonl line object / sqlite row) to a daemon
156
+ * native-history message. Values are jsonpath-lite strings: `$.foo.bar`
157
+ * or `$.items[0].text`. Literal strings (no leading `$`) pass through.
158
+ *
159
+ * `content_strip` lets a spec drop wrapper tags that the agent injects
160
+ * into its own transcript (claude's `<local-command-caveat>`, agy's
161
+ * `<USER_REQUEST>` / `<ADDITIONAL_METADATA>` / `<USER_SETTINGS_CHANGE>`).
162
+ * Each entry is a tag name; the executor removes `<tag>…</tag>` segments
163
+ * non-greedily before the value is handed to the dashboard. After all
164
+ * strips, leading/trailing whitespace is trimmed. If the result is empty
165
+ * the message is dropped.
166
+ */
167
+ export interface NativeHistoryMessageMap {
168
+ role: string; // → 'user' | 'assistant' | 'system' after normalize
169
+ content: string;
170
+ /**
171
+ * Tags whose entire `<tag>…</tag>` segment is removed from content.
172
+ * Use for noise wrappers the agent ships alongside the real message
173
+ * (claude's `<local-command-caveat>`, agy's `<ADDITIONAL_METADATA>`).
174
+ */
175
+ content_strip?: string[];
176
+ /**
177
+ * Tags whose open/close markers are removed but inner content is kept.
178
+ * Use when the *real* user/assistant message is wrapped in a tag
179
+ * the agent uses for routing (agy wraps user input in `<USER_REQUEST>`).
180
+ */
181
+ content_unwrap?: string[];
182
+ timestamp_ms?: string; // optional; falls back to receivedAt = now
183
+ kind?: string; // optional; defaults to 'standard'
184
+ }
185
+
186
+ export interface CliSpec {
187
+ $schema: 'adhdev:cli/spec@1';
188
+ id: string;
189
+ name: string;
190
+ binary: string;
191
+ spawn_args?: string[];
192
+ env?: Record<string, string>;
193
+ /**
194
+ * Optional version constraint this spec is authored for, e.g. ">=2.1.0".
195
+ * Pure metadata used by tooling/UI — the actual version-to-spec match
196
+ * happens in provider-loader via the manifest's compatibility array.
197
+ * Spec authors include this so a misrouted spec is easy to spot.
198
+ */
199
+ cli_version_range?: string;
200
+ send_message: {
201
+ submit_key: string;
202
+ delay_ms_before_submit?: number;
203
+ delay_ms_per_char?: number;
204
+ };
205
+ layout: { sections: Section[] };
206
+ states: SpecState[];
207
+ default_state: string;
208
+ control_bar?: Control[];
209
+ notifications?: NotificationRule[];
210
+ delegate?: DelegateTrigger[];
211
+ native_history?: NativeHistoryConfig;
212
+ /**
213
+ * Per-spec debounce knobs. Defaults are conservative (busy_hold_ms
214
+ * 6000) and live in SpecDriver. Spec authors override here when a
215
+ * particular CLI flickers slower/faster than the default.
216
+ */
217
+ debounce?: {
218
+ /** Min time to stay in busy after the evaluator last reported it.
219
+ * Absorbs per-frame flicker in TUIs that stream output through
220
+ * the same region as the spinner. */
221
+ busy_hold_ms?: number;
222
+ /** Min time after start() before a send_message is allowed to
223
+ * reach the PTY. Banner paints + auth flows + skill listings
224
+ * can keep the agent unable to accept input for several seconds
225
+ * even though the idle regex matches a transient empty prompt.
226
+ * Send_messages issued before this window are queued and drained
227
+ * once the window passes and an idle state has actually been
228
+ * observed. */
229
+ startup_grace_ms?: number;
230
+ };
231
+ }