@adhdev/daemon-core 0.9.82-rc.19 → 0.9.82-rc.190

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