@adhdev/daemon-core 0.9.82-rc.20 → 0.9.82-rc.200

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