@adhdev/daemon-core 0.9.82-rc.16 → 0.9.82-rc.161

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