@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,51 @@
1
+ /**
2
+ * Routing — given a CLI provider definition, decide whether to drive
3
+ * it via the legacy ProviderCliAdapter (scripts/v1/*.js parsers +
4
+ * cli-state-engine) or via SpecCliAdapter (single spec.json +
5
+ * SpecDriver). The gate is the presence of spec.json in the resolved
6
+ * provider directory.
7
+ *
8
+ * This is the only place in the daemon that knows which path a given
9
+ * provider takes. Providers can be migrated one at a time by adding
10
+ * a spec.json next to their scripts/v1/, then deleting scripts/v1/.
11
+ */
12
+ 'use strict';
13
+
14
+ import * as fs from 'node:fs';
15
+ import * as path from 'node:path';
16
+ import { ProviderCliAdapter } from '../../cli-adapters/provider-cli-adapter.js';
17
+ import type { CliProviderModule } from '../../cli-adapters/provider-cli-adapter.js';
18
+ import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
19
+ import type { CliAdapter } from '../../cli-adapter-types.js';
20
+ import { SpecCliAdapter } from './cli-adapter.js';
21
+ import { LOG } from '../../logging/logger.js';
22
+
23
+ export function createCliAdapter(
24
+ provider: CliProviderModule,
25
+ workingDir: string,
26
+ cliArgs: string[],
27
+ extraEnv: Record<string, string>,
28
+ transportFactory?: PtyTransportFactory,
29
+ ): CliAdapter {
30
+ // Prefer the path provider-loader already resolved (it walks the
31
+ // compatibility[i].spec → specs/default.json → spec.json chain).
32
+ // Fall back to the legacy spec.json-in-provider-dir lookup if the
33
+ // loader didn't attach one — keeps out-of-tree providers that still
34
+ // use the original layout working.
35
+ const resolvedSpecPath = (provider as unknown as { _resolvedSpecPath?: string })._resolvedSpecPath;
36
+ const dir = (provider as unknown as { _resolvedProviderDir?: string })._resolvedProviderDir;
37
+ let specPath: string | undefined = resolvedSpecPath && fs.existsSync(resolvedSpecPath) ? resolvedSpecPath : undefined;
38
+ if (!specPath && dir) {
39
+ const legacy = path.join(dir, 'spec.json');
40
+ if (fs.existsSync(legacy)) specPath = legacy;
41
+ }
42
+ if (specPath) {
43
+ try {
44
+ LOG.info('spec-route', `[${provider.type}] routing through SpecCliAdapter (${path.relative(dir || '', specPath) || specPath})`);
45
+ return new SpecCliAdapter(specPath, workingDir, cliArgs, extraEnv, transportFactory);
46
+ } catch (err) {
47
+ LOG.warn('spec-route', `[${provider.type}] spec invalid, falling back to ProviderCliAdapter: ${(err as Error).message}`);
48
+ }
49
+ }
50
+ return new ProviderCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory) as unknown as CliAdapter;
51
+ }
@@ -0,0 +1,559 @@
1
+ /**
2
+ * Auto-generated. Mirrors schema.json — regenerate after editing.
3
+ */
4
+ export const SCHEMA = {
5
+ "$schema": "http://json-schema.org/draft-07/schema#",
6
+ "$id": "adhdev:cli/spec@1",
7
+ "title": "ADHDev CLI provider spec",
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "required": [
11
+ "$schema",
12
+ "id",
13
+ "name",
14
+ "binary",
15
+ "send_message",
16
+ "layout",
17
+ "states",
18
+ "default_state"
19
+ ],
20
+ "properties": {
21
+ "$schema": {
22
+ "type": "string",
23
+ "const": "adhdev:cli/spec@1"
24
+ },
25
+ "id": {
26
+ "type": "string",
27
+ "minLength": 1,
28
+ "pattern": "^[a-z][a-z0-9-]*$"
29
+ },
30
+ "name": {
31
+ "type": "string",
32
+ "minLength": 1
33
+ },
34
+ "binary": {
35
+ "type": "string",
36
+ "minLength": 1
37
+ },
38
+ "spawn_args": {
39
+ "type": "array",
40
+ "items": {
41
+ "type": "string"
42
+ },
43
+ "default": []
44
+ },
45
+ "env": {
46
+ "type": "object",
47
+ "additionalProperties": {
48
+ "type": "string"
49
+ },
50
+ "default": {}
51
+ },
52
+ "send_message": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": [
56
+ "submit_key"
57
+ ],
58
+ "properties": {
59
+ "submit_key": {
60
+ "type": "string",
61
+ "minLength": 1
62
+ },
63
+ "delay_ms_before_submit": {
64
+ "type": "integer",
65
+ "minimum": 0
66
+ },
67
+ "delay_ms_per_char": {
68
+ "type": "integer",
69
+ "minimum": 0
70
+ }
71
+ }
72
+ },
73
+ "layout": {
74
+ "type": "object",
75
+ "additionalProperties": false,
76
+ "required": [
77
+ "sections"
78
+ ],
79
+ "properties": {
80
+ "sections": {
81
+ "type": "array",
82
+ "minItems": 1,
83
+ "items": {
84
+ "$ref": "#/definitions/section"
85
+ }
86
+ }
87
+ }
88
+ },
89
+ "states": {
90
+ "type": "array",
91
+ "minItems": 1,
92
+ "items": {
93
+ "$ref": "#/definitions/state"
94
+ }
95
+ },
96
+ "default_state": {
97
+ "type": "string",
98
+ "minLength": 1
99
+ },
100
+ "control_bar": {
101
+ "type": "array",
102
+ "default": [],
103
+ "items": {
104
+ "$ref": "#/definitions/control"
105
+ }
106
+ },
107
+ "notifications": {
108
+ "type": "array",
109
+ "default": [],
110
+ "items": {
111
+ "$ref": "#/definitions/notification"
112
+ }
113
+ },
114
+ "delegate": {
115
+ "type": "array",
116
+ "default": [],
117
+ "items": {
118
+ "$ref": "#/definitions/delegateTrigger"
119
+ }
120
+ },
121
+ "native_history": {
122
+ "$ref": "#/definitions/nativeHistory"
123
+ },
124
+ "cli_version_range": {
125
+ "type": "string",
126
+ "minLength": 1
127
+ },
128
+ "requiresFinalAssistantBeforeIdle": {
129
+ "type": "boolean"
130
+ },
131
+ "debounce": {
132
+ "type": "object",
133
+ "additionalProperties": false,
134
+ "properties": {
135
+ "busy_hold_ms": { "type": "integer", "minimum": 0 },
136
+ "idle_hold_ms": { "type": "integer", "minimum": 0 },
137
+ "startup_grace_ms": { "type": "integer", "minimum": 0 },
138
+ "completion_idle_after": {
139
+ "type": "object",
140
+ "additionalProperties": false,
141
+ "required": ["regex", "hold_ms"],
142
+ "properties": {
143
+ "section": { "type": "string", "minLength": 1 },
144
+ "regex": { "type": "string", "minLength": 1 },
145
+ "flags": { "type": "string" },
146
+ "hold_ms": { "type": "integer", "minimum": 0 },
147
+ "force_after_ms": { "type": "integer", "minimum": 0 }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ },
153
+ "definitions": {
154
+ "size": {
155
+ "oneOf": [
156
+ {
157
+ "type": "integer",
158
+ "minimum": 0
159
+ },
160
+ {
161
+ "type": "string",
162
+ "pattern": "^\\d+(\\.\\d+)?%$"
163
+ }
164
+ ]
165
+ },
166
+ "section": {
167
+ "type": "object",
168
+ "additionalProperties": false,
169
+ "required": [
170
+ "id"
171
+ ],
172
+ "properties": {
173
+ "id": {
174
+ "type": "string",
175
+ "minLength": 1,
176
+ "pattern": "^[a-z][a-z0-9_]*$"
177
+ },
178
+ "from_top": {
179
+ "$ref": "#/definitions/size"
180
+ },
181
+ "from_bottom": {
182
+ "$ref": "#/definitions/size"
183
+ },
184
+ "until": {
185
+ "type": "object",
186
+ "additionalProperties": false,
187
+ "required": [
188
+ "section"
189
+ ],
190
+ "properties": {
191
+ "section": {
192
+ "type": "string"
193
+ }
194
+ }
195
+ },
196
+ "anchor_regex": { "type": "string", "minLength": 1 },
197
+ "anchor_flags": { "type": "string" },
198
+ "anchor_last": { "type": "boolean" },
199
+ "anchor_context": {
200
+ "type": "object",
201
+ "additionalProperties": false,
202
+ "properties": {
203
+ "prev": { "type": "string" },
204
+ "prev_flags": { "type": "string" },
205
+ "next": { "type": "string" },
206
+ "next_flags": { "type": "string" }
207
+ }
208
+ },
209
+ "lines": { "type": "integer", "minimum": 1 },
210
+ "until_regex": { "type": "string", "minLength": 1 },
211
+ "until_regex_flags": { "type": "string" }
212
+ }
213
+ },
214
+ "sectionRegex": {
215
+ "type": "object",
216
+ "additionalProperties": false,
217
+ "required": [
218
+ "regex"
219
+ ],
220
+ "properties": {
221
+ "section": {
222
+ "type": "string"
223
+ },
224
+ "regex": {
225
+ "type": "string",
226
+ "minLength": 1
227
+ },
228
+ "flags": {
229
+ "type": "string",
230
+ "default": "i"
231
+ },
232
+ "cursor_row_min": {
233
+ "type": "integer",
234
+ "minimum": 0
235
+ },
236
+ "cursor_row_max": {
237
+ "type": "integer",
238
+ "minimum": 0
239
+ },
240
+ "cursor_col_min": {
241
+ "type": "integer",
242
+ "minimum": 0
243
+ },
244
+ "cursor_col_max": {
245
+ "type": "integer",
246
+ "minimum": 0
247
+ }
248
+ }
249
+ },
250
+ "sectionPattern": {
251
+ "type": "object",
252
+ "additionalProperties": false,
253
+ "required": [
254
+ "pattern"
255
+ ],
256
+ "properties": {
257
+ "section": {
258
+ "type": "string"
259
+ },
260
+ "pattern": {
261
+ "type": "string",
262
+ "minLength": 1
263
+ },
264
+ "flags": {
265
+ "type": "string",
266
+ "default": ""
267
+ }
268
+ }
269
+ },
270
+ "state": {
271
+ "type": "object",
272
+ "additionalProperties": false,
273
+ "required": [
274
+ "id",
275
+ "label",
276
+ "when"
277
+ ],
278
+ "properties": {
279
+ "id": {
280
+ "type": "string",
281
+ "minLength": 1,
282
+ "pattern": "^[a-z][a-z0-9_]*$"
283
+ },
284
+ "label": {
285
+ "type": "string",
286
+ "minLength": 1
287
+ },
288
+ "when": {
289
+ "$ref": "#/definitions/sectionRegex"
290
+ },
291
+ "extract_title": {
292
+ "$ref": "#/definitions/sectionRegex"
293
+ },
294
+ "modal_buttons": {
295
+ "type": "object",
296
+ "additionalProperties": false,
297
+ "required": [
298
+ "pattern",
299
+ "key_for_index"
300
+ ],
301
+ "properties": {
302
+ "section": {
303
+ "type": "string"
304
+ },
305
+ "pattern": {
306
+ "type": "string",
307
+ "minLength": 1
308
+ },
309
+ "flags": {
310
+ "type": "string"
311
+ },
312
+ "key_for_index": {
313
+ "type": "string",
314
+ "minLength": 1
315
+ },
316
+ "min_count": {
317
+ "type": "integer",
318
+ "minimum": 1,
319
+ "default": 2
320
+ },
321
+ "continuation_lines": {
322
+ "type": "boolean",
323
+ "default": false
324
+ }
325
+ }
326
+ }
327
+ }
328
+ },
329
+ "control": {
330
+ "type": "object",
331
+ "additionalProperties": false,
332
+ "required": [
333
+ "id",
334
+ "label",
335
+ "action"
336
+ ],
337
+ "properties": {
338
+ "id": {
339
+ "type": "string",
340
+ "minLength": 1,
341
+ "pattern": "^[a-z][a-z0-9_]*$"
342
+ },
343
+ "label": {
344
+ "type": "string",
345
+ "minLength": 1
346
+ },
347
+ "visible_when_state": {
348
+ "type": "array",
349
+ "items": {
350
+ "type": "string"
351
+ }
352
+ },
353
+ "action": {
354
+ "$ref": "#/definitions/controlAction"
355
+ }
356
+ }
357
+ },
358
+ "controlAction": {
359
+ "oneOf": [
360
+ {
361
+ "type": "object",
362
+ "additionalProperties": false,
363
+ "required": [
364
+ "type",
365
+ "keys"
366
+ ],
367
+ "properties": {
368
+ "type": {
369
+ "const": "send_keys"
370
+ },
371
+ "keys": {
372
+ "type": "string",
373
+ "minLength": 1
374
+ }
375
+ }
376
+ },
377
+ {
378
+ "type": "object",
379
+ "additionalProperties": false,
380
+ "required": [
381
+ "type",
382
+ "trigger_keys",
383
+ "wait_for",
384
+ "extract_choices",
385
+ "submit_key"
386
+ ],
387
+ "properties": {
388
+ "type": {
389
+ "const": "open_picker"
390
+ },
391
+ "trigger_keys": {
392
+ "type": "string",
393
+ "minLength": 1
394
+ },
395
+ "wait_for": {
396
+ "$ref": "#/definitions/sectionRegex"
397
+ },
398
+ "extract_choices": {
399
+ "$ref": "#/definitions/sectionPattern"
400
+ },
401
+ "submit_key": {
402
+ "type": "string",
403
+ "minLength": 1
404
+ }
405
+ }
406
+ },
407
+ {
408
+ "type": "object",
409
+ "additionalProperties": false,
410
+ "required": [
411
+ "type",
412
+ "method",
413
+ "keys_template"
414
+ ],
415
+ "properties": {
416
+ "type": {
417
+ "const": "attach_image"
418
+ },
419
+ "method": {
420
+ "const": "tempfile_then_keys"
421
+ },
422
+ "keys_template": {
423
+ "type": "string",
424
+ "minLength": 1
425
+ }
426
+ }
427
+ }
428
+ ]
429
+ },
430
+ "notification": {
431
+ "type": "object",
432
+ "additionalProperties": false,
433
+ "required": [
434
+ "id",
435
+ "when_state",
436
+ "title"
437
+ ],
438
+ "properties": {
439
+ "id": {
440
+ "type": "string",
441
+ "minLength": 1,
442
+ "pattern": "^[a-z][a-z0-9_]*$"
443
+ },
444
+ "when_state": {
445
+ "type": "string",
446
+ "minLength": 1
447
+ },
448
+ "title": {
449
+ "type": "string",
450
+ "minLength": 1
451
+ },
452
+ "body": {
453
+ "type": "string"
454
+ }
455
+ }
456
+ },
457
+ "nativeHistory": {
458
+ "type": "object",
459
+ "additionalProperties": false,
460
+ "properties": {
461
+ "reader": {
462
+ "type": "string",
463
+ "enum": [
464
+ "claude-cli",
465
+ "codex-cli",
466
+ "antigravity-cli",
467
+ "hermes-cli"
468
+ ]
469
+ },
470
+ "source": {
471
+ "oneOf": [
472
+ { "$ref": "#/definitions/nativeHistoryJsonlSource" },
473
+ { "$ref": "#/definitions/nativeHistorySqliteSource" }
474
+ ]
475
+ },
476
+ "override_path": { "type": "string", "minLength": 1 }
477
+ }
478
+ },
479
+ "nativeHistoryMessageMap": {
480
+ "type": "object",
481
+ "additionalProperties": false,
482
+ "required": ["role", "content"],
483
+ "properties": {
484
+ "role": { "type": "string", "minLength": 1 },
485
+ "content": { "type": "string", "minLength": 1 },
486
+ "content_strip": {
487
+ "type": "array",
488
+ "items": { "type": "string", "minLength": 1 }
489
+ },
490
+ "content_unwrap": {
491
+ "type": "array",
492
+ "items": { "type": "string", "minLength": 1 }
493
+ },
494
+ "timestamp_ms": { "type": "string", "minLength": 1 },
495
+ "kind": { "type": "string", "minLength": 1 }
496
+ }
497
+ },
498
+ "nativeHistoryJsonlSource": {
499
+ "type": "object",
500
+ "additionalProperties": false,
501
+ "required": ["kind", "path", "message_map"],
502
+ "properties": {
503
+ "kind": { "const": "jsonl" },
504
+ "path": { "type": "string", "minLength": 1 },
505
+ "file_pattern": { "type": "string", "minLength": 1 },
506
+ "recent_window_ms": { "type": "integer", "minimum": 0 },
507
+ "session_id_from": { "type": "string", "enum": ["filename_uuid", "first_record"] },
508
+ "session_id_path": { "type": "string", "minLength": 1 },
509
+ "message_filter": {
510
+ "type": "object",
511
+ "additionalProperties": false,
512
+ "required": ["where"],
513
+ "properties": { "where": { "type": "string", "minLength": 1 } }
514
+ },
515
+ "message_map": { "$ref": "#/definitions/nativeHistoryMessageMap" }
516
+ }
517
+ },
518
+ "nativeHistorySqliteSource": {
519
+ "type": "object",
520
+ "additionalProperties": false,
521
+ "required": ["kind", "path", "session_query", "message_query", "message_map"],
522
+ "properties": {
523
+ "kind": { "const": "sqlite" },
524
+ "path": { "type": "string", "minLength": 1 },
525
+ "session_query": { "type": "string", "minLength": 1 },
526
+ "message_query": { "type": "string", "minLength": 1 },
527
+ "message_map": { "$ref": "#/definitions/nativeHistoryMessageMap" }
528
+ }
529
+ },
530
+ "delegateTrigger": {
531
+ "type": "object",
532
+ "additionalProperties": false,
533
+ "required": [
534
+ "id",
535
+ "when_state",
536
+ "task_template"
537
+ ],
538
+ "properties": {
539
+ "id": {
540
+ "type": "string",
541
+ "minLength": 1,
542
+ "pattern": "^[a-z][a-z0-9_]*$"
543
+ },
544
+ "when_state": {
545
+ "type": "string",
546
+ "minLength": 1
547
+ },
548
+ "after_duration_ms": {
549
+ "type": "integer",
550
+ "minimum": 0
551
+ },
552
+ "task_template": {
553
+ "type": "string",
554
+ "minLength": 1
555
+ }
556
+ }
557
+ }
558
+ }
559
+ } as const;