@adhdev/daemon-core 0.9.82-rc.22 → 0.9.82-rc.220

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 (277) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +1 -0
  2. package/dist/boot/process-hardening.d.ts +50 -0
  3. package/dist/chat/source-machine.d.ts +166 -0
  4. package/dist/chat/source-resolver.d.ts +104 -0
  5. package/dist/chat/subscription-updates.d.ts +1 -0
  6. package/dist/cli-adapter-types.d.ts +23 -2
  7. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  8. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  9. package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
  10. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  11. package/dist/cli-adapters/provider-cli-shared.d.ts +29 -0
  12. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  13. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +3 -3
  14. package/dist/cli-adapters/terminal-backends/types.d.ts +1 -2
  15. package/dist/cli-adapters/terminal-screen.d.ts +2 -11
  16. package/dist/commands/cli-manager.d.ts +2 -1
  17. package/dist/commands/handler.d.ts +110 -0
  18. package/dist/commands/mesh-coordinator.d.ts +85 -1
  19. package/dist/commands/router.d.ts +32 -1
  20. package/dist/config/chat-history.d.ts +9 -0
  21. package/dist/config/config.d.ts +5 -0
  22. package/dist/config/mesh-config.d.ts +72 -1
  23. package/dist/git/git-commands.d.ts +9 -1
  24. package/dist/git/git-diff.d.ts +6 -0
  25. package/dist/git/git-types.d.ts +2 -0
  26. package/dist/index.d.ts +46 -11
  27. package/dist/index.js +36322 -15614
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +36182 -15568
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/installer.d.ts +1 -4
  32. package/dist/ipc/local-ipc-server.d.ts +91 -0
  33. package/dist/launch.d.ts +1 -1
  34. package/dist/logging/async-batch-writer.d.ts +10 -0
  35. package/dist/mesh/contracts.d.ts +164 -0
  36. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  37. package/dist/mesh/coordinator-registry.d.ts +59 -0
  38. package/dist/mesh/mesh-active-work.d.ts +90 -0
  39. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  40. package/dist/mesh/mesh-events-coordinator.d.ts +151 -0
  41. package/dist/mesh/mesh-events-pending.d.ts +33 -0
  42. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  43. package/dist/mesh/mesh-events-utils.d.ts +14 -0
  44. package/dist/mesh/mesh-events.d.ts +5 -40
  45. package/dist/mesh/mesh-fast-forward.d.ts +41 -0
  46. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  47. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  48. package/dist/mesh/mesh-ledger.d.ts +77 -1
  49. package/dist/mesh/mesh-missions.d.ts +58 -0
  50. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  51. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  52. package/dist/mesh/mesh-runtime-store.d.ts +324 -0
  53. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  54. package/dist/mesh/mesh-work-queue.d.ts +137 -6
  55. package/dist/mesh/preview-freshness.d.ts +18 -0
  56. package/dist/mesh/refine-config.d.ts +215 -0
  57. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  58. package/dist/providers/acp-provider-instance.d.ts +2 -0
  59. package/dist/providers/approval-utils.d.ts +13 -0
  60. package/dist/providers/cli-provider-instance.d.ts +39 -3
  61. package/dist/providers/contracts.d.ts +130 -6
  62. package/dist/providers/external-sources.d.ts +71 -0
  63. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  64. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  65. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  66. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  67. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  68. package/dist/providers/native-history/index.d.ts +13 -0
  69. package/dist/providers/provider-instance-manager.d.ts +12 -0
  70. package/dist/providers/provider-instance.d.ts +13 -1
  71. package/dist/providers/provider-loader.d.ts +26 -4
  72. package/dist/providers/provider-trust.d.ts +31 -0
  73. package/dist/providers/read-chat-contract.d.ts +29 -0
  74. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  75. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  76. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  77. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  78. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  79. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  80. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  81. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  82. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  83. package/dist/providers/sdk/v1/index.d.ts +30 -0
  84. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  85. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  86. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  87. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  88. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  89. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  90. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  91. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  92. package/dist/providers/spec/adapter.d.ts +52 -0
  93. package/dist/providers/spec/cli-adapter.d.ts +102 -0
  94. package/dist/providers/spec/driver.d.ts +287 -0
  95. package/dist/providers/spec/evaluator.d.ts +70 -0
  96. package/dist/providers/spec/fsm-driver.d.ts +110 -0
  97. package/dist/providers/spec/fsm-evaluator.d.ts +72 -0
  98. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  99. package/dist/providers/spec/fsm-types.d.ts +91 -0
  100. package/dist/providers/spec/loader.d.ts +15 -0
  101. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  102. package/dist/providers/spec/route.d.ts +4 -0
  103. package/dist/providers/spec/schema.gen.d.ts +2039 -0
  104. package/dist/providers/spec/types.d.ts +311 -0
  105. package/dist/providers/transcript-v2.d.ts +176 -0
  106. package/dist/providers/types/interactive-prompt.d.ts +48 -0
  107. package/dist/repo-mesh-types.d.ts +126 -1
  108. package/dist/sessions/registry.d.ts +3 -0
  109. package/dist/shared-types-extra.d.ts +2 -4
  110. package/dist/shared-types.d.ts +42 -1
  111. package/dist/status/normalize.d.ts +1 -1
  112. package/dist/status/normalize.js +1 -0
  113. package/dist/status/normalize.js.map +1 -1
  114. package/dist/status/normalize.mjs +1 -0
  115. package/dist/status/normalize.mjs.map +1 -1
  116. package/dist/status/reporter.d.ts +2 -0
  117. package/dist/status/snapshot.d.ts +1 -0
  118. package/dist/types.d.ts +5 -0
  119. package/package.json +6 -3
  120. package/src/agent-stream/poller.ts +2 -3
  121. package/src/boot/daemon-lifecycle.ts +22 -10
  122. package/src/boot/process-hardening.ts +89 -0
  123. package/src/chat/source-machine.ts +534 -0
  124. package/src/chat/source-resolver.ts +0 -0
  125. package/src/chat/subscription-updates.ts +20 -1
  126. package/src/cli-adapter-types.d.ts +1 -0
  127. package/src/cli-adapter-types.ts +22 -2
  128. package/src/cli-adapters/cli-script-runner.ts +421 -0
  129. package/src/cli-adapters/cli-state-engine.ts +1162 -0
  130. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  131. package/src/cli-adapters/provider-cli-adapter.ts +673 -1139
  132. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  133. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  134. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  135. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  136. package/src/cli-adapters/provider-cli-shared.ts +59 -11
  137. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  138. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +35 -29
  139. package/src/cli-adapters/terminal-backends/types.ts +1 -3
  140. package/src/cli-adapters/terminal-screen.ts +11 -81
  141. package/src/commands/chat-commands.ts +1787 -60
  142. package/src/commands/cli-manager.ts +283 -14
  143. package/src/commands/handler.ts +809 -2
  144. package/src/commands/mesh-coordinator.ts +332 -122
  145. package/src/commands/router.ts +4369 -558
  146. package/src/config/chat-history.ts +95 -24
  147. package/src/config/config.ts +12 -0
  148. package/src/config/mesh-config.ts +303 -3
  149. package/src/config/recent-activity.ts +8 -2
  150. package/src/daemon/dev-auto-implement.ts +3 -2
  151. package/src/daemon/dev-cli-debug.ts +10 -1
  152. package/src/detection/ide-detector.ts +26 -16
  153. package/src/git/git-commands.ts +42 -12
  154. package/src/git/git-diff.ts +53 -0
  155. package/src/git/git-status.ts +35 -6
  156. package/src/git/git-types.ts +2 -0
  157. package/src/git/git-worktree.ts +8 -1
  158. package/src/index.ts +126 -10
  159. package/src/installer.d.ts +1 -1
  160. package/src/installer.ts +8 -6
  161. package/src/ipc/local-ipc-server.ts +278 -0
  162. package/src/launch.d.ts +1 -1
  163. package/src/launch.ts +37 -28
  164. package/src/logging/async-batch-writer.ts +55 -0
  165. package/src/logging/logger.ts +2 -1
  166. package/src/mesh/contracts.ts +329 -0
  167. package/src/mesh/coordinator-prompt.ts +218 -31
  168. package/src/mesh/coordinator-registry.ts +121 -0
  169. package/src/mesh/mesh-active-work.ts +437 -0
  170. package/src/mesh/mesh-delivery-policy.ts +315 -0
  171. package/src/mesh/mesh-events-coordinator.ts +1447 -0
  172. package/src/mesh/mesh-events-pending.ts +371 -0
  173. package/src/mesh/mesh-events-stale.ts +283 -0
  174. package/src/mesh/mesh-events-utils.ts +166 -0
  175. package/src/mesh/mesh-events.ts +24 -908
  176. package/src/mesh/mesh-fast-forward.ts +438 -0
  177. package/src/mesh/mesh-host-ownership.ts +73 -0
  178. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  179. package/src/mesh/mesh-ledger.ts +587 -102
  180. package/src/mesh/mesh-missions.ts +151 -0
  181. package/src/mesh/mesh-refine-status.ts +144 -0
  182. package/src/mesh/mesh-review-inbox.ts +307 -0
  183. package/src/mesh/mesh-runtime-store.ts +1305 -0
  184. package/src/mesh/mesh-task-stats.ts +154 -0
  185. package/src/mesh/mesh-work-queue.ts +490 -166
  186. package/src/mesh/preview-freshness.ts +118 -0
  187. package/src/mesh/refine-config.ts +403 -0
  188. package/src/mesh/worktree-bootstrap-config.ts +326 -0
  189. package/src/providers/acp-provider-instance.ts +15 -1
  190. package/src/providers/approval-utils.d.ts +4 -0
  191. package/src/providers/approval-utils.ts +47 -5
  192. package/src/providers/chat-message-normalization.ts +4 -11
  193. package/src/providers/cli-provider-instance.ts +834 -64
  194. package/src/providers/contracts.d.ts +55 -0
  195. package/src/providers/contracts.ts +141 -6
  196. package/src/providers/external-sources.ts +218 -0
  197. package/src/providers/ide-provider-instance.ts +19 -5
  198. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  199. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  200. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  201. package/src/providers/native-history/dispatcher.ts +340 -0
  202. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  203. package/src/providers/native-history/index.ts +30 -0
  204. package/src/providers/provider-instance-manager.ts +30 -0
  205. package/src/providers/provider-instance.ts +10 -1
  206. package/src/providers/provider-loader.ts +592 -50
  207. package/src/providers/provider-schema.ts +87 -14
  208. package/src/providers/provider-trust.ts +114 -0
  209. package/src/providers/read-chat-contract.ts +76 -16
  210. package/src/providers/sdk/README.md +49 -0
  211. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  212. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  213. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  214. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  215. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  216. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  217. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  218. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  219. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  220. package/src/providers/sdk/v1/index.ts +152 -0
  221. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  222. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  223. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  224. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  225. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  226. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  227. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  228. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  229. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  230. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  231. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  232. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  233. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  234. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  235. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  236. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  237. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  238. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  239. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  240. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  241. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  242. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  243. package/src/providers/sdk/v1/validators/index.ts +19 -0
  244. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  245. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  246. package/src/providers/spec/adapter.ts +138 -0
  247. package/src/providers/spec/cli-adapter.ts +674 -0
  248. package/src/providers/spec/driver.ts +1082 -0
  249. package/src/providers/spec/evaluator.ts +604 -0
  250. package/src/providers/spec/fsm-driver.ts +663 -0
  251. package/src/providers/spec/fsm-evaluator.ts +255 -0
  252. package/src/providers/spec/fsm-loader.ts +102 -0
  253. package/src/providers/spec/fsm-types.ts +184 -0
  254. package/src/providers/spec/loader.ts +325 -0
  255. package/src/providers/spec/native-history-executor.ts +939 -0
  256. package/src/providers/spec/route.ts +51 -0
  257. package/src/providers/spec/schema.gen.ts +693 -0
  258. package/src/providers/spec/schema.json +342 -0
  259. package/src/providers/spec/types.ts +365 -0
  260. package/src/providers/transcript-v2.ts +567 -0
  261. package/src/providers/types/interactive-prompt.ts +425 -0
  262. package/src/providers/version-archive.ts +38 -20
  263. package/src/repo-mesh-types.ts +138 -1
  264. package/src/sessions/registry.ts +3 -0
  265. package/src/shared-types-extra.ts +2 -4
  266. package/src/shared-types.ts +45 -1
  267. package/src/status/builders.ts +24 -6
  268. package/src/status/normalize.ts +2 -0
  269. package/src/status/reporter.ts +15 -0
  270. package/src/status/snapshot.ts +84 -25
  271. package/src/system/host-memory.ts +29 -12
  272. package/src/types.ts +5 -0
  273. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  274. package/dist/mesh/mesh-sync.d.ts +0 -53
  275. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  276. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  277. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,693 @@
1
+ /**
2
+ * Auto-generated. Mirrors schema.json — regenerate after editing.
3
+ *
4
+ * SCHEMA_V1: validates adhdev:cli/spec@1 (legacy). Used for migration.
5
+ * SCHEMA_V3: validates adhdev:cli/spec@3 (current). Used after migration.
6
+ * SCHEMA: alias for SCHEMA_V3 (default export for loader.ts).
7
+ */
8
+
9
+ export const SCHEMA_V1 = {
10
+ "$schema": "http://json-schema.org/draft-07/schema#",
11
+ "$id": "adhdev:cli/spec@1",
12
+ "title": "ADHDev CLI provider spec v1",
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": [
16
+ "$schema",
17
+ "id",
18
+ "name",
19
+ "binary",
20
+ "send_message",
21
+ "layout",
22
+ "states",
23
+ "default_state"
24
+ ],
25
+ "properties": {
26
+ "$schema": {
27
+ "type": "string",
28
+ "const": "adhdev:cli/spec@1"
29
+ },
30
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9-]*$" },
31
+ "name": { "type": "string", "minLength": 1 },
32
+ "binary": { "type": "string", "minLength": 1 },
33
+ "spawn_args": { "type": "array", "items": { "type": "string" }, "default": [] },
34
+ "env": { "type": "object", "additionalProperties": { "type": "string" }, "default": {} },
35
+ "send_message": {
36
+ "type": "object",
37
+ "additionalProperties": false,
38
+ "required": ["submit_key"],
39
+ "properties": {
40
+ "submit_key": { "type": "string", "minLength": 1 },
41
+ "delay_ms_before_submit": { "type": "integer", "minimum": 0 },
42
+ "delay_ms_per_char": { "type": "integer", "minimum": 0 }
43
+ }
44
+ },
45
+ "layout": {
46
+ "type": "object",
47
+ "additionalProperties": false,
48
+ "required": ["sections"],
49
+ "properties": {
50
+ "sections": {
51
+ "type": "array",
52
+ "minItems": 1,
53
+ "items": { "$ref": "#/definitions/sectionV1" }
54
+ }
55
+ }
56
+ },
57
+ "states": {
58
+ "type": "array",
59
+ "minItems": 1,
60
+ "items": { "$ref": "#/definitions/stateV1" }
61
+ },
62
+ "default_state": { "type": "string", "minLength": 1 },
63
+ "control_bar": { "type": "array", "default": [], "items": { "$ref": "#/definitions/control" } },
64
+ "notifications": { "type": "array", "default": [], "items": { "$ref": "#/definitions/notification" } },
65
+ "delegate": { "type": "array", "default": [], "items": { "$ref": "#/definitions/delegateTrigger" } },
66
+ "native_history": { "$ref": "#/definitions/nativeHistory" },
67
+ "cli_version_range": { "type": "string", "minLength": 1 },
68
+ "requiresFinalAssistantBeforeIdle": { "type": "boolean" },
69
+ "debounce": {
70
+ "type": "object",
71
+ "additionalProperties": false,
72
+ "properties": {
73
+ "busy_hold_ms": { "type": "integer", "minimum": 0 },
74
+ "idle_hold_ms": { "type": "integer", "minimum": 0 },
75
+ "startup_grace_ms": { "type": "integer", "minimum": 0 },
76
+ "completion_idle_after": {
77
+ "type": "object",
78
+ "additionalProperties": false,
79
+ "required": ["regex", "hold_ms"],
80
+ "properties": {
81
+ "section": { "type": "string", "minLength": 1 },
82
+ "regex": { "type": "string", "minLength": 1 },
83
+ "flags": { "type": "string" },
84
+ "hold_ms": { "type": "integer", "minimum": 0 },
85
+ "force_after_ms": { "type": "integer", "minimum": 0 }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ },
91
+ "definitions": {
92
+ "size": {
93
+ "oneOf": [
94
+ { "type": "integer", "minimum": 0 },
95
+ { "type": "string", "pattern": "^\\d+(\\.\\d+)?%$" }
96
+ ]
97
+ },
98
+ "sectionV1": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "required": ["id"],
102
+ "properties": {
103
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
104
+ "from_top": { "$ref": "#/definitions/size" },
105
+ "from_bottom": { "$ref": "#/definitions/size" },
106
+ "until": {
107
+ "type": "object",
108
+ "additionalProperties": false,
109
+ "required": ["section"],
110
+ "properties": { "section": { "type": "string" } }
111
+ },
112
+ "anchor_regex": { "type": "string", "minLength": 1 },
113
+ "anchor_flags": { "type": "string" },
114
+ "anchor_last": { "type": "boolean" },
115
+ "anchor_context": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "properties": {
119
+ "prev": { "type": "string" },
120
+ "prev_flags": { "type": "string" },
121
+ "next": { "type": "string" },
122
+ "next_flags": { "type": "string" }
123
+ }
124
+ },
125
+ "lines": { "type": "integer", "minimum": 1 },
126
+ "until_regex": { "type": "string", "minLength": 1 },
127
+ "until_regex_flags": { "type": "string" }
128
+ }
129
+ },
130
+ "sectionRegex": {
131
+ "type": "object",
132
+ "additionalProperties": false,
133
+ "required": ["regex"],
134
+ "properties": {
135
+ "section": { "type": "string" },
136
+ "regex": { "type": "string", "minLength": 1 },
137
+ "flags": { "type": "string", "default": "i" },
138
+ "cursor_row_min": { "type": "integer", "minimum": 0 },
139
+ "cursor_row_max": { "type": "integer", "minimum": 0 },
140
+ "cursor_col_min": { "type": "integer", "minimum": 0 },
141
+ "cursor_col_max": { "type": "integer", "minimum": 0 },
142
+ "cursor_above_lines": { "type": "integer", "minimum": 1 },
143
+ "changed": { "type": "boolean", "const": true }
144
+ }
145
+ },
146
+ "sectionPattern": {
147
+ "type": "object",
148
+ "additionalProperties": false,
149
+ "required": ["pattern"],
150
+ "properties": {
151
+ "section": { "type": "string" },
152
+ "pattern": { "type": "string", "minLength": 1 },
153
+ "flags": { "type": "string", "default": "" }
154
+ }
155
+ },
156
+ "stateV1": {
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": ["id", "label", "when"],
160
+ "properties": {
161
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
162
+ "label": { "type": "string", "minLength": 1 },
163
+ "when": { "$ref": "#/definitions/sectionRegex" },
164
+ "extract_title": { "$ref": "#/definitions/sectionRegex" },
165
+ "modal_buttons": {
166
+ "type": "object",
167
+ "additionalProperties": false,
168
+ "required": ["key_for_index"],
169
+ "oneOf": [
170
+ { "required": ["pattern"] },
171
+ { "required": ["patterns"] }
172
+ ],
173
+ "properties": {
174
+ "section": { "type": "string" },
175
+ "pattern": { "type": "string", "minLength": 1 },
176
+ "flags": { "type": "string" },
177
+ "patterns": {
178
+ "type": "array",
179
+ "minItems": 1,
180
+ "items": {
181
+ "type": "object",
182
+ "additionalProperties": false,
183
+ "required": ["pattern"],
184
+ "properties": {
185
+ "pattern": { "type": "string", "minLength": 1 },
186
+ "flags": { "type": "string" }
187
+ }
188
+ }
189
+ },
190
+ "key_for_index": { "type": "string", "minLength": 1 },
191
+ "min_count": { "type": "integer", "minimum": 1, "default": 2 },
192
+ "continuation_lines": { "type": "boolean", "default": false }
193
+ }
194
+ }
195
+ }
196
+ },
197
+ "control": {
198
+ "type": "object",
199
+ "additionalProperties": false,
200
+ "required": ["id", "label", "action"],
201
+ "properties": {
202
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
203
+ "label": { "type": "string", "minLength": 1 },
204
+ "visible_when_state": { "type": "array", "items": { "type": "string" } },
205
+ "action": { "$ref": "#/definitions/controlAction" }
206
+ }
207
+ },
208
+ "controlAction": {
209
+ "oneOf": [
210
+ {
211
+ "type": "object",
212
+ "additionalProperties": false,
213
+ "required": ["type", "keys"],
214
+ "properties": {
215
+ "type": { "const": "send_keys" },
216
+ "keys": { "type": "string", "minLength": 1 }
217
+ }
218
+ },
219
+ {
220
+ "type": "object",
221
+ "additionalProperties": false,
222
+ "required": ["type", "trigger_keys", "wait_for", "extract_choices", "submit_key"],
223
+ "properties": {
224
+ "type": { "const": "open_picker" },
225
+ "trigger_keys": { "type": "string", "minLength": 1 },
226
+ "wait_for": { "$ref": "#/definitions/sectionRegex" },
227
+ "extract_choices": { "$ref": "#/definitions/sectionPattern" },
228
+ "submit_key": { "type": "string", "minLength": 1 }
229
+ }
230
+ },
231
+ {
232
+ "type": "object",
233
+ "additionalProperties": false,
234
+ "required": ["type", "method", "keys_template"],
235
+ "properties": {
236
+ "type": { "const": "attach_image" },
237
+ "method": { "const": "tempfile_then_keys" },
238
+ "keys_template": { "type": "string", "minLength": 1 }
239
+ }
240
+ }
241
+ ]
242
+ },
243
+ "notification": {
244
+ "type": "object",
245
+ "additionalProperties": false,
246
+ "required": ["id", "when_state", "title"],
247
+ "properties": {
248
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
249
+ "when_state": { "type": "string", "minLength": 1 },
250
+ "title": { "type": "string", "minLength": 1 },
251
+ "body": { "type": "string" }
252
+ }
253
+ },
254
+ "nativeHistory": {
255
+ "type": "object",
256
+ "additionalProperties": false,
257
+ "properties": {
258
+ "reader": {
259
+ "type": "string",
260
+ "enum": ["claude-cli", "codex-cli", "antigravity-cli", "hermes-cli"]
261
+ },
262
+ "source": {
263
+ "oneOf": [
264
+ { "$ref": "#/definitions/nativeHistoryJsonlSource" },
265
+ { "$ref": "#/definitions/nativeHistorySqliteSource" }
266
+ ]
267
+ },
268
+ "override_path": { "type": "string", "minLength": 1 }
269
+ }
270
+ },
271
+ "nativeHistoryMessageMap": {
272
+ "type": "object",
273
+ "additionalProperties": false,
274
+ "required": ["role", "content"],
275
+ "properties": {
276
+ "role": { "type": "string", "minLength": 1 },
277
+ "content": { "type": "string", "minLength": 1 },
278
+ "content_strip": { "type": "array", "items": { "type": "string", "minLength": 1 } },
279
+ "content_unwrap": { "type": "array", "items": { "type": "string", "minLength": 1 } },
280
+ "timestamp_ms": { "type": "string", "minLength": 1 },
281
+ "kind": { "type": "string", "minLength": 1 }
282
+ }
283
+ },
284
+ "nativeHistoryJsonlSource": {
285
+ "type": "object",
286
+ "additionalProperties": false,
287
+ "required": ["kind", "path", "message_map"],
288
+ "properties": {
289
+ "kind": { "const": "jsonl" },
290
+ "path": { "type": "string", "minLength": 1 },
291
+ "file_pattern": { "type": "string", "minLength": 1 },
292
+ "recent_window_ms": { "type": "integer", "minimum": 0 },
293
+ "session_id_from": { "type": "string", "enum": ["filename_uuid", "first_record"] },
294
+ "session_id_path": { "type": "string", "minLength": 1 },
295
+ "message_filter": {
296
+ "type": "object",
297
+ "additionalProperties": false,
298
+ "required": ["where"],
299
+ "properties": { "where": { "type": "string", "minLength": 1 } }
300
+ },
301
+ "message_map": { "$ref": "#/definitions/nativeHistoryMessageMap" }
302
+ }
303
+ },
304
+ "nativeHistorySqliteSource": {
305
+ "type": "object",
306
+ "additionalProperties": false,
307
+ "required": ["kind", "path", "session_query", "message_query", "message_map"],
308
+ "properties": {
309
+ "kind": { "const": "sqlite" },
310
+ "path": { "type": "string", "minLength": 1 },
311
+ "session_query": { "type": "string", "minLength": 1 },
312
+ "message_query": { "type": "string", "minLength": 1 },
313
+ "message_map": { "$ref": "#/definitions/nativeHistoryMessageMap" }
314
+ }
315
+ },
316
+ "delegateTrigger": {
317
+ "type": "object",
318
+ "additionalProperties": false,
319
+ "required": ["id", "when_state", "task_template"],
320
+ "properties": {
321
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
322
+ "when_state": { "type": "string", "minLength": 1 },
323
+ "after_duration_ms": { "type": "integer", "minimum": 0 },
324
+ "task_template": { "type": "string", "minLength": 1 }
325
+ }
326
+ }
327
+ }
328
+ } as const;
329
+
330
+ export const SCHEMA_V3 = {
331
+ "$schema": "http://json-schema.org/draft-07/schema#",
332
+ "$id": "adhdev:cli/spec@3",
333
+ "title": "ADHDev CLI provider spec v3",
334
+ "type": "object",
335
+ "additionalProperties": false,
336
+ "required": [
337
+ "$schema",
338
+ "id",
339
+ "name",
340
+ "binary",
341
+ "send_message",
342
+ "sections",
343
+ "states",
344
+ "default_state"
345
+ ],
346
+ "properties": {
347
+ "$schema": { "type": "string", "const": "adhdev:cli/spec@3" },
348
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9-]*$" },
349
+ "name": { "type": "string", "minLength": 1 },
350
+ "binary": { "type": "string", "minLength": 1 },
351
+ "spawn_args": { "type": "array", "items": { "type": "string" }, "default": [] },
352
+ "env": { "type": "object", "additionalProperties": { "type": "string" }, "default": {} },
353
+ "cli_version_range": { "type": "string", "minLength": 1 },
354
+ "send_message": {
355
+ "type": "object",
356
+ "additionalProperties": false,
357
+ "required": ["submit_key"],
358
+ "properties": {
359
+ "submit_key": { "type": "string", "minLength": 1 },
360
+ "delay_ms_before_submit": { "type": "integer", "minimum": 0 },
361
+ "delay_ms_per_char": { "type": "integer", "minimum": 0 }
362
+ }
363
+ },
364
+ "sections": {
365
+ "type": "object",
366
+ "minProperties": 1,
367
+ "additionalProperties": { "$ref": "#/definitions/sectionDef" }
368
+ },
369
+ "states": {
370
+ "type": "array",
371
+ "minItems": 1,
372
+ "items": { "$ref": "#/definitions/stateV3" }
373
+ },
374
+ "default_state": { "type": "string", "minLength": 1 },
375
+ "control_bar": { "type": "array", "default": [], "items": { "$ref": "#/definitions/control" } },
376
+ "notifications": { "type": "array", "default": [], "items": { "$ref": "#/definitions/notification" } },
377
+ "delegate": { "type": "array", "default": [], "items": { "$ref": "#/definitions/delegateTrigger" } },
378
+ "native_history": { "$ref": "#/definitions/nativeHistory" },
379
+ "requiresFinalAssistantBeforeIdle": { "type": "boolean" },
380
+ "timing": {
381
+ "type": "object",
382
+ "additionalProperties": false,
383
+ "properties": {
384
+ "busy_hold_ms": { "type": "integer", "minimum": 0 },
385
+ "idle_hold_ms": { "type": "integer", "minimum": 0 },
386
+ "startup_grace_ms": { "type": "integer", "minimum": 0 },
387
+ "screen_active_hold_ms": { "type": "integer", "minimum": 0 },
388
+ "completion_marker": {
389
+ "type": "object",
390
+ "additionalProperties": false,
391
+ "required": ["matches", "hold_ms"],
392
+ "properties": {
393
+ "section": { "type": "string", "minLength": 1 },
394
+ "matches": { "type": "string", "minLength": 1 },
395
+ "flags": { "type": "string" },
396
+ "hold_ms": { "type": "integer", "minimum": 0 },
397
+ "force_after_ms": { "type": "integer", "minimum": 0 }
398
+ }
399
+ }
400
+ }
401
+ }
402
+ },
403
+ "definitions": {
404
+ "size": {
405
+ "oneOf": [
406
+ { "type": "integer", "minimum": 0 },
407
+ { "type": "string", "pattern": "^\\d+(\\.\\d+)?%$" }
408
+ ]
409
+ },
410
+ "sectionDef": {
411
+ "type": "object",
412
+ "additionalProperties": false,
413
+ "properties": {
414
+ "from_top": { "$ref": "#/definitions/size" },
415
+ "from_bottom": { "$ref": "#/definitions/size" },
416
+ "until": { "type": "string", "minLength": 1 },
417
+ "anchor": { "type": "string", "minLength": 1 },
418
+ "anchor_flags": { "type": "string" },
419
+ "anchor_last": { "type": "boolean" },
420
+ "anchor_context": {
421
+ "type": "object",
422
+ "additionalProperties": false,
423
+ "properties": {
424
+ "prev": { "type": "string" },
425
+ "prev_flags": { "type": "string" },
426
+ "next": { "type": "string" },
427
+ "next_flags": { "type": "string" }
428
+ }
429
+ },
430
+ "lines": { "type": "integer", "minimum": 1 },
431
+ "until_regex": { "type": "string", "minLength": 1 },
432
+ "until_regex_flags": { "type": "string" }
433
+ }
434
+ },
435
+ "condition": {
436
+ "oneOf": [
437
+ { "$ref": "#/definitions/regexCondition" },
438
+ { "$ref": "#/definitions/changedCondition" },
439
+ { "$ref": "#/definitions/allCondition" },
440
+ { "$ref": "#/definitions/anyCondition" }
441
+ ]
442
+ },
443
+ "regexCondition": {
444
+ "type": "object",
445
+ "additionalProperties": false,
446
+ "required": ["matches"],
447
+ "properties": {
448
+ "section": { "type": "string" },
449
+ "matches": { "type": "string", "minLength": 1 },
450
+ "flags": { "type": "string" },
451
+ "cursor_row_min": { "type": "integer", "minimum": 0 },
452
+ "cursor_row_max": { "type": "integer", "minimum": 0 },
453
+ "cursor_col_min": { "type": "integer", "minimum": 0 },
454
+ "cursor_col_max": { "type": "integer", "minimum": 0 }
455
+ }
456
+ },
457
+ "changedCondition": {
458
+ "type": "object",
459
+ "additionalProperties": false,
460
+ "required": ["cursor_above", "changed"],
461
+ "properties": {
462
+ "cursor_above": { "type": "integer", "minimum": 1 },
463
+ "changed": { "type": "boolean" },
464
+ "stable_ms": { "type": "integer", "minimum": 0 }
465
+ }
466
+ },
467
+ "allCondition": {
468
+ "type": "object",
469
+ "additionalProperties": false,
470
+ "required": ["all"],
471
+ "properties": {
472
+ "all": {
473
+ "type": "array",
474
+ "items": { "$ref": "#/definitions/condition" }
475
+ }
476
+ }
477
+ },
478
+ "anyCondition": {
479
+ "type": "object",
480
+ "additionalProperties": false,
481
+ "required": ["any"],
482
+ "properties": {
483
+ "any": {
484
+ "type": "array",
485
+ "items": { "$ref": "#/definitions/condition" }
486
+ }
487
+ }
488
+ },
489
+ "extractTitle": {
490
+ "type": "object",
491
+ "additionalProperties": false,
492
+ "properties": {
493
+ "section": { "type": "string" },
494
+ "regex": { "type": "string", "minLength": 1 },
495
+ "flags": { "type": "string" },
496
+ "first_line": { "type": "boolean", "const": true }
497
+ }
498
+ },
499
+ "extractButtons": {
500
+ "type": "object",
501
+ "additionalProperties": false,
502
+ "required": ["pattern", "key_for_index"],
503
+ "properties": {
504
+ "section": { "type": "string" },
505
+ "pattern": { "type": "string", "minLength": 1 },
506
+ "flags": { "type": "string" },
507
+ "key_for_index": { "type": "string", "minLength": 1 },
508
+ "min_count": { "type": "integer", "minimum": 1, "default": 2 },
509
+ "continuation_lines": { "type": "boolean", "default": false }
510
+ }
511
+ },
512
+ "stateV3": {
513
+ "type": "object",
514
+ "additionalProperties": false,
515
+ "required": ["id", "label", "when"],
516
+ "properties": {
517
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
518
+ "label": { "type": "string", "minLength": 1 },
519
+ "when": {
520
+ "oneOf": [
521
+ { "$ref": "#/definitions/allCondition" },
522
+ { "$ref": "#/definitions/anyCondition" }
523
+ ]
524
+ },
525
+ "extract": {
526
+ "type": "object",
527
+ "additionalProperties": false,
528
+ "properties": {
529
+ "title": { "$ref": "#/definitions/extractTitle" },
530
+ "buttons": { "$ref": "#/definitions/extractButtons" }
531
+ }
532
+ }
533
+ }
534
+ },
535
+ "sectionRegex": {
536
+ "type": "object",
537
+ "additionalProperties": false,
538
+ "required": ["regex"],
539
+ "properties": {
540
+ "section": { "type": "string" },
541
+ "regex": { "type": "string", "minLength": 1 },
542
+ "flags": { "type": "string", "default": "i" },
543
+ "cursor_row_min": { "type": "integer", "minimum": 0 },
544
+ "cursor_row_max": { "type": "integer", "minimum": 0 },
545
+ "cursor_col_min": { "type": "integer", "minimum": 0 },
546
+ "cursor_col_max": { "type": "integer", "minimum": 0 }
547
+ }
548
+ },
549
+ "sectionPattern": {
550
+ "type": "object",
551
+ "additionalProperties": false,
552
+ "required": ["pattern"],
553
+ "properties": {
554
+ "section": { "type": "string" },
555
+ "pattern": { "type": "string", "minLength": 1 },
556
+ "flags": { "type": "string", "default": "" }
557
+ }
558
+ },
559
+ "control": {
560
+ "type": "object",
561
+ "additionalProperties": false,
562
+ "required": ["id", "label", "action"],
563
+ "properties": {
564
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
565
+ "label": { "type": "string", "minLength": 1 },
566
+ "visible_when_state": { "type": "array", "items": { "type": "string" } },
567
+ "action": { "$ref": "#/definitions/controlAction" }
568
+ }
569
+ },
570
+ "controlAction": {
571
+ "oneOf": [
572
+ {
573
+ "type": "object",
574
+ "additionalProperties": false,
575
+ "required": ["type", "keys"],
576
+ "properties": {
577
+ "type": { "const": "send_keys" },
578
+ "keys": { "type": "string", "minLength": 1 }
579
+ }
580
+ },
581
+ {
582
+ "type": "object",
583
+ "additionalProperties": false,
584
+ "required": ["type", "trigger_keys", "wait_for", "extract_choices", "submit_key"],
585
+ "properties": {
586
+ "type": { "const": "open_picker" },
587
+ "trigger_keys": { "type": "string", "minLength": 1 },
588
+ "wait_for": { "$ref": "#/definitions/sectionRegex" },
589
+ "extract_choices": { "$ref": "#/definitions/sectionPattern" },
590
+ "submit_key": { "type": "string", "minLength": 1 }
591
+ }
592
+ },
593
+ {
594
+ "type": "object",
595
+ "additionalProperties": false,
596
+ "required": ["type", "method", "keys_template"],
597
+ "properties": {
598
+ "type": { "const": "attach_image" },
599
+ "method": { "const": "tempfile_then_keys" },
600
+ "keys_template": { "type": "string", "minLength": 1 }
601
+ }
602
+ }
603
+ ]
604
+ },
605
+ "notification": {
606
+ "type": "object",
607
+ "additionalProperties": false,
608
+ "required": ["id", "when_state", "title"],
609
+ "properties": {
610
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
611
+ "when_state": { "type": "string", "minLength": 1 },
612
+ "title": { "type": "string", "minLength": 1 },
613
+ "body": { "type": "string" }
614
+ }
615
+ },
616
+ "nativeHistory": {
617
+ "type": "object",
618
+ "additionalProperties": false,
619
+ "properties": {
620
+ "reader": {
621
+ "type": "string",
622
+ "enum": ["claude-cli", "codex-cli", "antigravity-cli", "hermes-cli"]
623
+ },
624
+ "source": {
625
+ "oneOf": [
626
+ { "$ref": "#/definitions/nativeHistoryJsonlSource" },
627
+ { "$ref": "#/definitions/nativeHistorySqliteSource" }
628
+ ]
629
+ },
630
+ "override_path": { "type": "string", "minLength": 1 }
631
+ }
632
+ },
633
+ "nativeHistoryMessageMap": {
634
+ "type": "object",
635
+ "additionalProperties": false,
636
+ "required": ["role", "content"],
637
+ "properties": {
638
+ "role": { "type": "string", "minLength": 1 },
639
+ "content": { "type": "string", "minLength": 1 },
640
+ "content_strip": { "type": "array", "items": { "type": "string", "minLength": 1 } },
641
+ "content_unwrap": { "type": "array", "items": { "type": "string", "minLength": 1 } },
642
+ "timestamp_ms": { "type": "string", "minLength": 1 },
643
+ "kind": { "type": "string", "minLength": 1 }
644
+ }
645
+ },
646
+ "nativeHistoryJsonlSource": {
647
+ "type": "object",
648
+ "additionalProperties": false,
649
+ "required": ["kind", "path", "message_map"],
650
+ "properties": {
651
+ "kind": { "const": "jsonl" },
652
+ "path": { "type": "string", "minLength": 1 },
653
+ "file_pattern": { "type": "string", "minLength": 1 },
654
+ "recent_window_ms": { "type": "integer", "minimum": 0 },
655
+ "session_id_from": { "type": "string", "enum": ["filename_uuid", "first_record"] },
656
+ "session_id_path": { "type": "string", "minLength": 1 },
657
+ "message_filter": {
658
+ "type": "object",
659
+ "additionalProperties": false,
660
+ "required": ["where"],
661
+ "properties": { "where": { "type": "string", "minLength": 1 } }
662
+ },
663
+ "message_map": { "$ref": "#/definitions/nativeHistoryMessageMap" }
664
+ }
665
+ },
666
+ "nativeHistorySqliteSource": {
667
+ "type": "object",
668
+ "additionalProperties": false,
669
+ "required": ["kind", "path", "session_query", "message_query", "message_map"],
670
+ "properties": {
671
+ "kind": { "const": "sqlite" },
672
+ "path": { "type": "string", "minLength": 1 },
673
+ "session_query": { "type": "string", "minLength": 1 },
674
+ "message_query": { "type": "string", "minLength": 1 },
675
+ "message_map": { "$ref": "#/definitions/nativeHistoryMessageMap" }
676
+ }
677
+ },
678
+ "delegateTrigger": {
679
+ "type": "object",
680
+ "additionalProperties": false,
681
+ "required": ["id", "when_state", "task_template"],
682
+ "properties": {
683
+ "id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
684
+ "when_state": { "type": "string", "minLength": 1 },
685
+ "after_duration_ms": { "type": "integer", "minimum": 0 },
686
+ "task_template": { "type": "string", "minLength": 1 }
687
+ }
688
+ }
689
+ }
690
+ } as const;
691
+
692
+ /** Default schema export — v3 (current). */
693
+ export const SCHEMA = SCHEMA_V3;