@adhdev/daemon-core 0.9.82-rc.44 → 0.9.82-rc.441

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 (425) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +9 -0
  2. package/dist/boot/process-hardening.d.ts +50 -0
  3. package/dist/build-info.d.ts +37 -0
  4. package/dist/chat/source-machine.d.ts +166 -0
  5. package/dist/chat/source-resolver.d.ts +104 -0
  6. package/dist/chat/subscription-updates.d.ts +1 -0
  7. package/dist/cli-adapter-types.d.ts +68 -2
  8. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  9. package/dist/cli-adapters/cli-state-engine.d.ts +200 -0
  10. package/dist/cli-adapters/provider-cli-adapter.d.ts +126 -64
  11. package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
  12. package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
  13. package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
  14. package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
  15. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  16. package/dist/cli-adapters/resolve-executable.d.ts +69 -0
  17. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
  18. package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
  19. package/dist/cli-adapters/terminal-screen.d.ts +4 -11
  20. package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
  21. package/dist/commands/chat-commands-read.d.ts +7 -0
  22. package/dist/commands/chat-commands-scope.d.ts +39 -0
  23. package/dist/commands/chat-commands-shared.d.ts +33 -0
  24. package/dist/commands/chat-commands-write.d.ts +14 -0
  25. package/dist/commands/chat-commands.d.ts +10 -23
  26. package/dist/commands/cli-manager.d.ts +15 -1
  27. package/dist/commands/handler.d.ts +125 -0
  28. package/dist/commands/high-family/index.d.ts +3 -0
  29. package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
  30. package/dist/commands/high-family/mesh-events.d.ts +2 -0
  31. package/dist/commands/high-family/mesh-status.d.ts +2 -0
  32. package/dist/commands/high-family/types.d.ts +60 -0
  33. package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
  34. package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
  35. package/dist/commands/low-family/diagnostics.d.ts +2 -0
  36. package/dist/commands/low-family/index.d.ts +3 -0
  37. package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
  38. package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
  39. package/dist/commands/low-family/notification.d.ts +2 -0
  40. package/dist/commands/low-family/refine-config.d.ts +2 -0
  41. package/dist/commands/low-family/session-host.d.ts +2 -0
  42. package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
  43. package/dist/commands/low-family/status-meta.d.ts +2 -0
  44. package/dist/commands/low-family/types.d.ts +33 -0
  45. package/dist/commands/med-family/cli-agent.d.ts +2 -0
  46. package/dist/commands/med-family/fast-forward.d.ts +2 -0
  47. package/dist/commands/med-family/ide.d.ts +10 -0
  48. package/dist/commands/med-family/index.d.ts +3 -0
  49. package/dist/commands/med-family/mesh-crud.d.ts +29 -0
  50. package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
  51. package/dist/commands/med-family/mesh-queue.d.ts +2 -0
  52. package/dist/commands/med-family/mesh-restart.d.ts +2 -0
  53. package/dist/commands/med-family/types.d.ts +142 -0
  54. package/dist/commands/mesh-coordinator.d.ts +85 -1
  55. package/dist/commands/router.d.ts +276 -2
  56. package/dist/commands/upgrade-helper.d.ts +41 -1
  57. package/dist/config/chat-history.d.ts +9 -0
  58. package/dist/config/config.d.ts +5 -0
  59. package/dist/config/mesh-config.d.ts +120 -1
  60. package/dist/config/mesh-json-config.d.ts +199 -0
  61. package/dist/config/repo-settings.d.ts +77 -0
  62. package/dist/daemon/dev-server.d.ts +0 -2
  63. package/dist/detection/ide-detector.d.ts +13 -0
  64. package/dist/detection/win32-ide-version.d.ts +37 -0
  65. package/dist/git/change-impact-config.d.ts +159 -0
  66. package/dist/git/git-commands.d.ts +11 -1
  67. package/dist/git/git-diff.d.ts +6 -0
  68. package/dist/git/git-executor.d.ts +11 -0
  69. package/dist/git/git-status.d.ts +57 -0
  70. package/dist/git/git-types.d.ts +2 -50
  71. package/dist/git/git-worktree.d.ts +71 -1
  72. package/dist/git/index.d.ts +3 -1
  73. package/dist/index.d.ts +64 -14
  74. package/dist/index.js +50719 -20120
  75. package/dist/index.js.map +1 -1
  76. package/dist/index.mjs +50317 -19882
  77. package/dist/index.mjs.map +1 -1
  78. package/dist/installer.d.ts +1 -4
  79. package/dist/ipc/local-ipc-server.d.ts +91 -0
  80. package/dist/launch.d.ts +1 -1
  81. package/dist/logging/async-batch-writer.d.ts +10 -0
  82. package/dist/logging/log-redactor.d.ts +24 -0
  83. package/dist/logging/log-tail-reader.d.ts +81 -0
  84. package/dist/logging/logger.d.ts +1 -1
  85. package/dist/mesh/contracts.d.ts +164 -0
  86. package/dist/mesh/coordinator-prompt.d.ts +89 -0
  87. package/dist/mesh/coordinator-registry.d.ts +59 -0
  88. package/dist/mesh/mesh-active-work.d.ts +174 -0
  89. package/dist/mesh/mesh-clone-grace.d.ts +8 -0
  90. package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
  91. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  92. package/dist/mesh/mesh-event-classify.d.ts +5 -0
  93. package/dist/mesh/mesh-event-forwarding.d.ts +41 -0
  94. package/dist/mesh/mesh-event-trace.d.ts +21 -0
  95. package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
  96. package/dist/mesh/mesh-events-pending.d.ts +69 -0
  97. package/dist/mesh/mesh-events-stale.d.ts +61 -0
  98. package/dist/mesh/mesh-events-utils.d.ts +75 -0
  99. package/dist/mesh/mesh-events.d.ts +6 -49
  100. package/dist/mesh/mesh-fast-forward.d.ts +81 -0
  101. package/dist/mesh/mesh-host-ownership.d.ts +29 -0
  102. package/dist/mesh/mesh-init.d.ts +128 -0
  103. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
  104. package/dist/mesh/mesh-ledger.d.ts +77 -1
  105. package/dist/mesh/mesh-magi-status.d.ts +63 -0
  106. package/dist/mesh/mesh-missions.d.ts +189 -0
  107. package/dist/mesh/mesh-node-identity.d.ts +289 -0
  108. package/dist/mesh/mesh-queue-assignment.d.ts +113 -0
  109. package/dist/mesh/mesh-reconcile-loop.d.ts +65 -0
  110. package/dist/mesh/mesh-refine-batch.d.ts +68 -0
  111. package/dist/mesh/mesh-refine-gates.d.ts +428 -0
  112. package/dist/mesh/mesh-refine-status.d.ts +62 -0
  113. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  114. package/dist/mesh/mesh-routing.d.ts +70 -0
  115. package/dist/mesh/mesh-runtime-store.d.ts +450 -0
  116. package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
  117. package/dist/mesh/mesh-task-inflight.d.ts +46 -0
  118. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  119. package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
  120. package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
  121. package/dist/mesh/mesh-work-queue.d.ts +300 -5
  122. package/dist/mesh/preview-freshness.d.ts +18 -0
  123. package/dist/mesh/refine-config.d.ts +216 -0
  124. package/dist/mesh/worktree-bootstrap-config.d.ts +145 -0
  125. package/dist/providers/acp-provider-instance.d.ts +5 -0
  126. package/dist/providers/approval-utils.d.ts +20 -0
  127. package/dist/providers/chat-message-normalization.d.ts +31 -1
  128. package/dist/providers/cli-provider-instance.d.ts +252 -3
  129. package/dist/providers/contracts.d.ts +149 -6
  130. package/dist/providers/external-sources.d.ts +71 -0
  131. package/dist/providers/manual-attendance.d.ts +63 -0
  132. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  133. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  134. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  135. package/dist/providers/native-history/constants.d.ts +12 -0
  136. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  137. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  138. package/dist/providers/native-history/index.d.ts +13 -0
  139. package/dist/providers/provider-instance-manager.d.ts +29 -0
  140. package/dist/providers/provider-instance.d.ts +23 -1
  141. package/dist/providers/provider-loader.d.ts +26 -4
  142. package/dist/providers/provider-trust.d.ts +31 -0
  143. package/dist/providers/read-chat-contract.d.ts +29 -0
  144. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  145. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
  146. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  147. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  148. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  149. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  150. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  151. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  152. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  153. package/dist/providers/sdk/v1/index.d.ts +30 -0
  154. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  155. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  156. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  157. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  158. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  159. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  160. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  161. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  162. package/dist/providers/spec/adapter.d.ts +91 -0
  163. package/dist/providers/spec/cli-adapter.d.ts +223 -0
  164. package/dist/providers/spec/evaluator.d.ts +45 -0
  165. package/dist/providers/spec/fsm-driver.d.ts +422 -0
  166. package/dist/providers/spec/fsm-evaluator.d.ts +76 -0
  167. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  168. package/dist/providers/spec/fsm-types.d.ts +174 -0
  169. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  170. package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
  171. package/dist/providers/spec/route.d.ts +4 -0
  172. package/dist/providers/spec/types.d.ts +222 -0
  173. package/dist/providers/status-monitor.d.ts +7 -7
  174. package/dist/providers/transcript-v2.d.ts +176 -0
  175. package/dist/providers/types/interactive-prompt.d.ts +84 -0
  176. package/dist/providers/working-dir.d.ts +17 -0
  177. package/dist/repo-mesh-types.d.ts +509 -13
  178. package/dist/runtime-defaults.d.ts +2 -0
  179. package/dist/sessions/registry.d.ts +6 -0
  180. package/dist/shared-types-extra.d.ts +2 -4
  181. package/dist/shared-types.d.ts +59 -2
  182. package/dist/status/normalize.d.ts +1 -1
  183. package/dist/status/normalize.js +1 -0
  184. package/dist/status/normalize.js.map +1 -1
  185. package/dist/status/normalize.mjs +1 -0
  186. package/dist/status/normalize.mjs.map +1 -1
  187. package/dist/status/reporter.d.ts +2 -0
  188. package/dist/status/snapshot.d.ts +26 -0
  189. package/dist/system/hash.d.ts +8 -0
  190. package/dist/system/load-better-sqlite3.d.ts +21 -0
  191. package/dist/types.d.ts +5 -0
  192. package/package.json +7 -3
  193. package/src/agent-stream/poller.ts +2 -3
  194. package/src/agent-stream/provider-adapter.ts +1 -1
  195. package/src/boot/daemon-lifecycle.ts +63 -12
  196. package/src/boot/process-hardening.ts +89 -0
  197. package/src/build-info.ts +73 -0
  198. package/src/chat/source-machine.ts +534 -0
  199. package/src/chat/source-resolver.ts +0 -0
  200. package/src/chat/subscription-updates.ts +20 -1
  201. package/src/cli-adapter-types.d.ts +3 -1
  202. package/src/cli-adapter-types.ts +68 -2
  203. package/src/cli-adapters/cli-script-runner.ts +421 -0
  204. package/src/cli-adapters/cli-state-engine.ts +1246 -0
  205. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  206. package/src/cli-adapters/provider-cli-adapter.ts +914 -1144
  207. package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
  208. package/src/cli-adapters/provider-cli-parse.ts +19 -0
  209. package/src/cli-adapters/provider-cli-runtime.ts +56 -7
  210. package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
  211. package/src/cli-adapters/provider-cli-shared.ts +121 -11
  212. package/src/cli-adapters/pty-transport.ts +2 -1
  213. package/src/cli-adapters/pty-write-chunking.ts +106 -0
  214. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  215. package/src/cli-adapters/resolve-executable.ts +204 -0
  216. package/src/cli-adapters/session-host-transport.ts +2 -1
  217. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
  218. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  219. package/src/cli-adapters/terminal-screen.ts +16 -81
  220. package/src/commands/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
  221. package/src/commands/chat-commands-debug-bundle.ts +398 -0
  222. package/src/commands/chat-commands-read.ts +2447 -0
  223. package/src/commands/chat-commands-scope.ts +54 -0
  224. package/src/commands/chat-commands-shared.ts +114 -0
  225. package/src/commands/chat-commands-write.ts +891 -0
  226. package/src/commands/chat-commands.ts +19 -1841
  227. package/src/commands/cli-manager.ts +572 -27
  228. package/src/commands/handler.ts +841 -2
  229. package/src/commands/high-family/index.ts +28 -0
  230. package/src/commands/high-family/mesh-coordinator-launch.ts +678 -0
  231. package/src/commands/high-family/mesh-events.ts +80 -0
  232. package/src/commands/high-family/mesh-status.ts +714 -0
  233. package/src/commands/high-family/types.ts +76 -0
  234. package/src/commands/low-family/coordinator-prompt.ts +72 -0
  235. package/src/commands/low-family/daemon-lifecycle.ts +107 -0
  236. package/src/commands/low-family/diagnostics.ts +57 -0
  237. package/src/commands/low-family/index.ts +37 -0
  238. package/src/commands/low-family/mesh-ledger.ts +62 -0
  239. package/src/commands/low-family/mesh-node-logs.ts +87 -0
  240. package/src/commands/low-family/notification.ts +116 -0
  241. package/src/commands/low-family/refine-config.ts +106 -0
  242. package/src/commands/low-family/session-host.ts +274 -0
  243. package/src/commands/low-family/spec-providerdev.ts +217 -0
  244. package/src/commands/low-family/status-meta.ts +112 -0
  245. package/src/commands/low-family/types.ts +39 -0
  246. package/src/commands/med-family/cli-agent.ts +238 -0
  247. package/src/commands/med-family/fast-forward.ts +230 -0
  248. package/src/commands/med-family/ide.ts +163 -0
  249. package/src/commands/med-family/index.ts +37 -0
  250. package/src/commands/med-family/mesh-crud.ts +1242 -0
  251. package/src/commands/med-family/mesh-host-pairing.ts +234 -0
  252. package/src/commands/med-family/mesh-queue.ts +167 -0
  253. package/src/commands/med-family/mesh-restart.ts +92 -0
  254. package/src/commands/med-family/types.ts +143 -0
  255. package/src/commands/mesh-coordinator.ts +334 -124
  256. package/src/commands/router.ts +2846 -3484
  257. package/src/commands/stream-commands.ts +8 -0
  258. package/src/commands/upgrade-helper.ts +310 -45
  259. package/src/config/chat-history.ts +493 -24
  260. package/src/config/config.ts +12 -0
  261. package/src/config/mesh-config.ts +593 -22
  262. package/src/config/mesh-json-config.ts +376 -0
  263. package/src/config/recent-activity.ts +8 -2
  264. package/src/config/repo-settings.ts +111 -0
  265. package/src/daemon/dev-auto-implement.ts +3 -2
  266. package/src/daemon/dev-cli-debug.ts +10 -1
  267. package/src/daemon/dev-server.ts +0 -541
  268. package/src/detection/cli-detector.ts +28 -9
  269. package/src/detection/ide-detector.ts +55 -16
  270. package/src/detection/win32-ide-version.ts +106 -0
  271. package/src/git/change-impact-config.ts +354 -0
  272. package/src/git/git-commands.ts +59 -15
  273. package/src/git/git-diff.ts +81 -11
  274. package/src/git/git-executor.ts +12 -0
  275. package/src/git/git-status.ts +767 -48
  276. package/src/git/git-types.ts +14 -62
  277. package/src/git/git-worktree.ts +261 -4
  278. package/src/git/index.ts +17 -0
  279. package/src/index.ts +196 -12
  280. package/src/installer.d.ts +1 -1
  281. package/src/installer.ts +8 -6
  282. package/src/ipc/local-ipc-server.ts +278 -0
  283. package/src/launch.d.ts +1 -1
  284. package/src/launch.ts +37 -28
  285. package/src/logging/async-batch-writer.ts +55 -0
  286. package/src/logging/command-log.ts +7 -5
  287. package/src/logging/log-redactor.ts +100 -0
  288. package/src/logging/log-tail-reader.ts +341 -0
  289. package/src/logging/logger.ts +14 -7
  290. package/src/mesh/contracts.ts +338 -0
  291. package/src/mesh/coordinator-prompt.ts +415 -34
  292. package/src/mesh/coordinator-registry.ts +121 -0
  293. package/src/mesh/mesh-active-work.ts +645 -0
  294. package/src/mesh/mesh-clone-grace.ts +68 -0
  295. package/src/mesh/mesh-coordinator-config.ts +97 -0
  296. package/src/mesh/mesh-delivery-policy.ts +315 -0
  297. package/src/mesh/mesh-event-classify.ts +51 -0
  298. package/src/mesh/mesh-event-forwarding.ts +1897 -0
  299. package/src/mesh/mesh-event-trace.ts +67 -0
  300. package/src/mesh/mesh-events-coordinator.ts +32 -0
  301. package/src/mesh/mesh-events-pending.ts +656 -0
  302. package/src/mesh/mesh-events-stale.ts +389 -0
  303. package/src/mesh/mesh-events-utils.ts +443 -0
  304. package/src/mesh/mesh-events.ts +33 -1035
  305. package/src/mesh/mesh-fast-forward.ts +843 -0
  306. package/src/mesh/mesh-host-ownership.ts +111 -0
  307. package/src/mesh/mesh-init.ts +350 -0
  308. package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
  309. package/src/mesh/mesh-ledger.ts +656 -102
  310. package/src/mesh/mesh-magi-status.ts +223 -0
  311. package/src/mesh/mesh-missions.ts +449 -0
  312. package/src/mesh/mesh-node-identity.ts +1887 -0
  313. package/src/mesh/mesh-queue-assignment.ts +1924 -0
  314. package/src/mesh/mesh-reconcile-loop.ts +1997 -0
  315. package/src/mesh/mesh-refine-batch.ts +205 -0
  316. package/src/mesh/mesh-refine-gates.ts +1673 -0
  317. package/src/mesh/mesh-refine-status.ts +231 -0
  318. package/src/mesh/mesh-review-inbox.ts +307 -0
  319. package/src/mesh/mesh-routing.ts +291 -0
  320. package/src/mesh/mesh-runtime-store.ts +1853 -0
  321. package/src/mesh/mesh-scheduling-runtime.ts +198 -0
  322. package/src/mesh/mesh-task-inflight.ts +70 -0
  323. package/src/mesh/mesh-task-stats.ts +161 -0
  324. package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
  325. package/src/mesh/mesh-warmup-deadline.ts +152 -0
  326. package/src/mesh/mesh-work-queue.ts +1254 -141
  327. package/src/mesh/preview-freshness.ts +118 -0
  328. package/src/mesh/refine-config.ts +423 -0
  329. package/src/mesh/worktree-bootstrap-config.ts +450 -0
  330. package/src/providers/acp-provider-instance.ts +43 -10
  331. package/src/providers/approval-utils.d.ts +5 -0
  332. package/src/providers/approval-utils.ts +57 -5
  333. package/src/providers/chat-message-normalization.ts +92 -4
  334. package/src/providers/cli-provider-instance.ts +2001 -106
  335. package/src/providers/contracts.d.ts +55 -0
  336. package/src/providers/contracts.ts +160 -6
  337. package/src/providers/extension-provider-instance.ts +12 -7
  338. package/src/providers/external-sources.ts +218 -0
  339. package/src/providers/ide-provider-instance.ts +35 -12
  340. package/src/providers/manual-attendance.ts +85 -0
  341. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  342. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  343. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  344. package/src/providers/native-history/constants.ts +19 -0
  345. package/src/providers/native-history/dispatcher.ts +345 -0
  346. package/src/providers/native-history/hermes-cli-transcript.ts +260 -0
  347. package/src/providers/native-history/index.ts +30 -0
  348. package/src/providers/provider-instance-manager.ts +71 -0
  349. package/src/providers/provider-instance.ts +19 -1
  350. package/src/providers/provider-loader.ts +668 -50
  351. package/src/providers/provider-schema.ts +87 -14
  352. package/src/providers/provider-trust.ts +114 -0
  353. package/src/providers/read-chat-contract.ts +76 -16
  354. package/src/providers/sdk/README.md +49 -0
  355. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  356. package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
  357. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  358. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  359. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  360. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  361. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  362. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  363. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  364. package/src/providers/sdk/v1/index.ts +152 -0
  365. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  366. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  367. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  368. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +509 -0
  369. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  370. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  371. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  372. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  373. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  374. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  375. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  376. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  377. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  378. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  379. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  380. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  381. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  382. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  383. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  384. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  385. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  386. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  387. package/src/providers/sdk/v1/validators/index.ts +19 -0
  388. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  389. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  390. package/src/providers/spec/adapter.ts +235 -0
  391. package/src/providers/spec/cli-adapter.ts +1056 -0
  392. package/src/providers/spec/evaluator.ts +407 -0
  393. package/src/providers/spec/fsm-driver.ts +1410 -0
  394. package/src/providers/spec/fsm-evaluator.ts +272 -0
  395. package/src/providers/spec/fsm-loader.ts +120 -0
  396. package/src/providers/spec/fsm-types.ts +273 -0
  397. package/src/providers/spec/native-history-executor.ts +1143 -0
  398. package/src/providers/spec/pre-launch-trust.ts +104 -0
  399. package/src/providers/spec/route.ts +51 -0
  400. package/src/providers/spec/types.ts +262 -0
  401. package/src/providers/status-monitor.d.ts +7 -7
  402. package/src/providers/status-monitor.ts +37 -22
  403. package/src/providers/transcript-v2.ts +567 -0
  404. package/src/providers/types/interactive-prompt.ts +536 -0
  405. package/src/providers/version-archive.ts +64 -24
  406. package/src/providers/working-dir.ts +23 -0
  407. package/src/repo-mesh-types.ts +748 -14
  408. package/src/runtime-defaults.ts +39 -0
  409. package/src/sessions/registry.ts +6 -0
  410. package/src/shared-types-extra.ts +2 -4
  411. package/src/shared-types.d.ts +8 -0
  412. package/src/shared-types.ts +64 -1
  413. package/src/status/builders.ts +26 -6
  414. package/src/status/normalize.ts +2 -0
  415. package/src/status/reporter.ts +19 -1
  416. package/src/status/snapshot.ts +95 -26
  417. package/src/system/hash.ts +23 -0
  418. package/src/system/host-memory.ts +29 -12
  419. package/src/system/load-better-sqlite3.ts +68 -0
  420. package/src/types.ts +5 -0
  421. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  422. package/dist/mesh/mesh-sync.d.ts +0 -53
  423. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  424. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  425. package/src/mesh/mesh-sync.ts +0 -111
@@ -37,6 +37,12 @@ const KNOWN_PROVIDER_FIELDS = new Set<string>([
37
37
  'approvalPositiveHints',
38
38
  'sessionIdPattern',
39
39
  'historyBehavior',
40
+ // v1 canonical field name. The loader fills this in for legacy v0
41
+ // manifests that ship the old `canonicalHistory` spelling.
42
+ 'nativeHistory',
43
+ // Deprecated v0 alias for `nativeHistory`. Kept in the allowed-keys
44
+ // list so legacy provider.json manifests don't trip the unknown-key
45
+ // warning during the one-release deprecation window.
40
46
  'canonicalHistory',
41
47
  'autoFixProfile',
42
48
  'ideLevelScripts',
@@ -64,6 +70,8 @@ const KNOWN_PROVIDER_FIELDS = new Set<string>([
64
70
  'sendKey',
65
71
  'submitStrategy',
66
72
  'requirePromptEchoBeforeSubmit',
73
+ 'requiresFinalAssistantBeforeIdle',
74
+ 'augmentStaleSnapshot',
67
75
  'timeouts',
68
76
  'disableUpstream',
69
77
  ])
@@ -128,7 +136,7 @@ export function validateProviderDefinition(raw: unknown): ProviderValidationResu
128
136
  }
129
137
 
130
138
  validateCapabilities(provider as unknown as ProviderModule, controls, errors)
131
- validateCanonicalHistory(provider.canonicalHistory, errors)
139
+ validateNativeHistory(provider.nativeHistory, errors)
132
140
  validateMeshCoordinator(provider.meshCoordinator, errors)
133
141
 
134
142
  for (const control of controls) {
@@ -228,33 +236,43 @@ function validateCapabilities(provider: ProviderModule, controls: ProviderContro
228
236
  }
229
237
  }
230
238
 
231
- function validateCanonicalHistory(raw: unknown, errors: string[]): void {
239
+ function validateNativeHistory(raw: unknown, errors: string[]): void {
232
240
  if (raw === undefined) return
233
241
  if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
234
- errors.push('canonicalHistory must be an object')
242
+ errors.push('nativeHistory must be an object')
235
243
  return
236
244
  }
237
245
 
238
- const canonicalHistory = raw as Record<string, unknown>
239
- const format = canonicalHistory.format
246
+ const nativeHistory = raw as Record<string, unknown>
247
+ const format = nativeHistory.format
240
248
  if (format !== undefined && (typeof format !== 'string' || !format.trim())) {
241
- errors.push('canonicalHistory.format must be a non-empty string when provided')
249
+ errors.push('nativeHistory.format must be a non-empty string when provided')
242
250
  }
243
251
 
244
- const watchPath = canonicalHistory.watchPath
252
+ const watchPath = nativeHistory.watchPath
245
253
  if (watchPath !== undefined && (typeof watchPath !== 'string' || !watchPath.trim())) {
246
- errors.push('canonicalHistory.watchPath must be a non-empty string when provided')
254
+ errors.push('nativeHistory.watchPath must be a non-empty string when provided')
247
255
  }
248
256
 
249
- const mode = canonicalHistory.mode
257
+ const mode = nativeHistory.mode
250
258
  if (mode !== undefined && !['native-source', 'materialized-mirror', 'disabled'].includes(String(mode))) {
251
- errors.push('canonicalHistory.mode must be one of: native-source, materialized-mirror, disabled')
259
+ errors.push('nativeHistory.mode must be one of: native-source, materialized-mirror, disabled')
252
260
  }
253
261
 
254
- const scripts = canonicalHistory.scripts
262
+ // Chat transcript contract version (transcript-v2.ts). Absent → treated as
263
+ // v1 by readDeclaredChatContractVersion(). A2 will reject unrecognised
264
+ // values at load time; A1 only validates the field shape.
265
+ const chatContractVersion = nativeHistory.contractVersion
266
+ if (chatContractVersion !== undefined
267
+ && chatContractVersion !== '1.0'
268
+ && chatContractVersion !== '2.0') {
269
+ errors.push(`nativeHistory.contractVersion must be '1.0' or '2.0' when provided (got ${JSON.stringify(chatContractVersion)})`)
270
+ }
271
+
272
+ const scripts = nativeHistory.scripts
255
273
  if (scripts === undefined) return
256
274
  if (!scripts || typeof scripts !== 'object' || Array.isArray(scripts)) {
257
- errors.push('canonicalHistory.scripts must be an object')
275
+ errors.push('nativeHistory.scripts must be an object')
258
276
  return
259
277
  }
260
278
 
@@ -262,7 +280,7 @@ function validateCanonicalHistory(raw: unknown, errors: string[]): void {
262
280
  for (const key of ['readSession', 'listSessions']) {
263
281
  const value = scriptConfig[key]
264
282
  if (typeof value !== 'string' || !value.trim()) {
265
- errors.push(`canonicalHistory.scripts.${key} must be a non-empty string`)
283
+ errors.push(`nativeHistory.scripts.${key} must be a non-empty string`)
266
284
  }
267
285
  }
268
286
  }
@@ -282,7 +300,11 @@ function validateMeshCoordinator(raw: unknown, errors: string[]): void {
282
300
  errors.push('meshCoordinator.reason must be a non-empty string when provided')
283
301
  }
284
302
 
285
- const mcpConfig = meshCoordinator.mcpConfig
303
+ validateMeshCoordinatorMcpConfig(meshCoordinator.mcpConfig, errors)
304
+ validateMeshCoordinatorDelegatedWorkerIsolation(meshCoordinator.delegatedWorkerIsolation, errors)
305
+ }
306
+
307
+ function validateMeshCoordinatorMcpConfig(mcpConfig: unknown, errors: string[]): void {
286
308
  if (mcpConfig === undefined) return
287
309
  if (!mcpConfig || typeof mcpConfig !== 'object' || Array.isArray(mcpConfig)) {
288
310
  errors.push('meshCoordinator.mcpConfig must be an object')
@@ -330,6 +352,57 @@ function validateMeshCoordinator(raw: unknown, errors: string[]): void {
330
352
  }
331
353
  }
332
354
 
355
+ function validateMeshCoordinatorDelegatedWorkerIsolation(raw: unknown, errors: string[]): void {
356
+ if (raw === undefined) return
357
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
358
+ errors.push('meshCoordinator.delegatedWorkerIsolation must be an object')
359
+ return
360
+ }
361
+ const isolation = raw as Record<string, unknown>
362
+ const env = isolation.env
363
+ if (env !== undefined) {
364
+ if (!env || typeof env !== 'object' || Array.isArray(env)) {
365
+ errors.push('meshCoordinator.delegatedWorkerIsolation.env must be an object')
366
+ } else {
367
+ const unset = (env as Record<string, unknown>).unset
368
+ if (unset !== undefined && (!Array.isArray(unset) || unset.some((key) => typeof key !== 'string' || !key.trim()))) {
369
+ errors.push('meshCoordinator.delegatedWorkerIsolation.env.unset must be an array of non-empty strings')
370
+ }
371
+ }
372
+ }
373
+ const args = isolation.args
374
+ if (args === undefined) return
375
+ if (!Array.isArray(args)) {
376
+ errors.push('meshCoordinator.delegatedWorkerIsolation.args must be an array')
377
+ return
378
+ }
379
+ for (const [index, rule] of args.entries()) {
380
+ const prefix = `meshCoordinator.delegatedWorkerIsolation.args[${index}]`
381
+ if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {
382
+ errors.push(`${prefix} must be an object`)
383
+ continue
384
+ }
385
+ const item = rule as Record<string, unknown>
386
+ const mode = item.mode
387
+ if (mode !== 'empty_mcp_config' && mode !== 'config_override') {
388
+ errors.push(`${prefix}.mode must be one of: empty_mcp_config, config_override`)
389
+ continue
390
+ }
391
+ for (const key of mode === 'empty_mcp_config' ? ['flag'] : ['flag', 'key', 'value']) {
392
+ const value = item[key]
393
+ if (typeof value !== 'string' || !value.trim()) {
394
+ errors.push(`${prefix}.${key} must be a non-empty string`)
395
+ }
396
+ }
397
+ for (const key of ['strictFlag', 'dedupeKey']) {
398
+ const value = item[key]
399
+ if (value !== undefined && (typeof value !== 'string' || !value.trim())) {
400
+ errors.push(`${prefix}.${key} must be a non-empty string when provided`)
401
+ }
402
+ }
403
+ }
404
+ }
405
+
333
406
  function validateControl(control: ProviderControlDef, errors: string[]): void {
334
407
  if (!control || typeof control !== 'object') {
335
408
  errors.push('controls: each control must be an object')
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Provider trust classification.
3
+ *
4
+ * Each loaded provider gets a `trust` tag that the daemon and dashboard
5
+ * use to decide what to surface and what to gate behind a confirmation
6
+ * prompt. Trust is a function of *where* the provider came from
7
+ * (upstream / external / userDir) and the *shape of the manifest*
8
+ * (spec-only vs. carries JavaScript hooks).
9
+ *
10
+ * Rationale:
11
+ * - Spec-only manifests are static declarative configuration; the
12
+ * daemon's spec adapter walks the spec but never executes code
13
+ * authored by the provider.
14
+ * - Non-spec manifests ship JavaScript (tui-block builders consumed
15
+ * by the SDK, scriptDir overrides, or explicit `overrides.* .path`
16
+ * bindings). That code runs inside the daemon process with the
17
+ * same privileges as adhdev itself.
18
+ *
19
+ * Source × shape decides the trust label:
20
+ *
21
+ * layer | spec-only | non-spec
22
+ * ---------|---------------------|-----------------------
23
+ * user | user-custom | user-custom
24
+ * upstream | trusted | trusted-with-scripts
25
+ * external | external-safe | external-untrusted
26
+ *
27
+ * Dashboards should always show a badge for `trusted-with-scripts`
28
+ * (info — runs official JS), `external-safe` (info — declarative only,
29
+ * but 3rd-party), and `external-untrusted` (warning — runs JS from a
30
+ * 3rd-party). Activation of `external-untrusted` should require an
31
+ * explicit confirmation step that names the source URL.
32
+ */
33
+ 'use strict';
34
+
35
+ export type ProviderTrust =
36
+ | 'user-custom'
37
+ | 'trusted'
38
+ | 'trusted-with-scripts'
39
+ | 'external-safe'
40
+ | 'external-untrusted';
41
+
42
+ export type ProviderLayer = 'user' | 'upstream' | 'external';
43
+
44
+ export interface ProviderManifestShape {
45
+ /** Has a `tui` block — SDK builders consume it as code paths. */
46
+ hasTui: boolean;
47
+ /** Has a non-empty `overrides` object — JS override paths. */
48
+ hasOverrides: boolean;
49
+ /** compatibility[].scriptDir or defaultScriptDir is set — JS scripts dir. */
50
+ hasScriptDir: boolean;
51
+ }
52
+
53
+ /**
54
+ * Inspect a manifest to decide whether it ships JavaScript hooks.
55
+ * Cheap; pure; safe to call on every provider load.
56
+ */
57
+ export function inspectManifestShape(manifest: Record<string, unknown>): ProviderManifestShape {
58
+ const hasTui = !!manifest.tui && typeof manifest.tui === 'object'
59
+ && Object.keys(manifest.tui as Record<string, unknown>).length > 0;
60
+ const hasOverrides = !!manifest.overrides && typeof manifest.overrides === 'object'
61
+ && !Array.isArray(manifest.overrides)
62
+ && Object.keys(manifest.overrides as Record<string, unknown>).length > 0;
63
+ const compat = Array.isArray(manifest.compatibility) ? manifest.compatibility : [];
64
+ const compatHasScriptDir = compat.some((entry: any) => typeof entry?.scriptDir === 'string');
65
+ const hasScriptDir = compatHasScriptDir || typeof manifest.defaultScriptDir === 'string';
66
+ return { hasTui, hasOverrides, hasScriptDir };
67
+ }
68
+
69
+ /**
70
+ * Classify trust given the layer the provider was loaded from + the
71
+ * manifest's JS-hook footprint.
72
+ */
73
+ export function classifyTrust(
74
+ layer: ProviderLayer,
75
+ shape: ProviderManifestShape,
76
+ ): ProviderTrust {
77
+ const isSpecOnly = !shape.hasTui && !shape.hasOverrides && !shape.hasScriptDir;
78
+ switch (layer) {
79
+ case 'user':
80
+ return 'user-custom';
81
+ case 'upstream':
82
+ return isSpecOnly ? 'trusted' : 'trusted-with-scripts';
83
+ case 'external':
84
+ return isSpecOnly ? 'external-safe' : 'external-untrusted';
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Returns true when activation should require an explicit user confirm.
90
+ * Today only `external-untrusted` qualifies; future trust levels may
91
+ * fold in here.
92
+ */
93
+ export function requiresConfirmation(trust: ProviderTrust): boolean {
94
+ return trust === 'external-untrusted';
95
+ }
96
+
97
+ /**
98
+ * Render a short human-readable rationale for the trust tag. Used by
99
+ * the dashboard's confirmation modal and the provider catalog tooltip.
100
+ */
101
+ export function describeTrust(trust: ProviderTrust): string {
102
+ switch (trust) {
103
+ case 'user-custom':
104
+ return 'Hand-authored in ~/.adhdev/providers/. Runs your own code.';
105
+ case 'trusted':
106
+ return 'Official, declarative-only manifest from the ADHDev registry.';
107
+ case 'trusted-with-scripts':
108
+ return 'Official manifest from the ADHDev registry. Ships JavaScript hooks executed by the daemon.';
109
+ case 'external-safe':
110
+ return 'Manifest from a 3rd-party git source you added. Declarative-only — the daemon never runs JS from this source.';
111
+ case 'external-untrusted':
112
+ return 'Manifest from a 3rd-party git source you added. Ships JavaScript that the daemon will execute. Treat as untrusted code — review the source before enabling.';
113
+ }
114
+ }
@@ -1,8 +1,16 @@
1
1
  import type { MessagePart, ModalInfo, ReadChatResult } from './contracts.js'
2
2
  import { normalizeMessageParts } from './contracts.js'
3
3
  import type { ChatBubbleState, ChatMessage } from '../types.js'
4
-
5
- const VALID_STATUSES = ['idle', 'generating', 'waiting_approval', 'error', 'panel_hidden', 'streaming', 'long_generating'] as const
4
+ import {
5
+ CHAT_CONTRACT_VERSION_V1,
6
+ CHAT_CONTRACT_VERSION_V2,
7
+ assertReadChatResultV2Payload,
8
+ isSupportedChatContractVersion,
9
+ type ChatContractVersion,
10
+ type ReadChatResultV2,
11
+ } from './transcript-v2.js'
12
+
13
+ const VALID_STATUSES = ['idle', 'generating', 'waiting_approval', 'error', 'panel_hidden', 'starting', 'streaming', 'no_progress', 'long_generating'] as const
6
14
  const VALID_ROLES = ['user', 'assistant', 'system', 'human'] as const
7
15
  const VALID_BUBBLE_STATES = ['draft', 'streaming', 'final', 'removed'] as const
8
16
  const VALID_TURN_STATUSES = ['open', 'waiting_approval', 'complete', 'error'] as const
@@ -63,7 +71,7 @@ function validateMessage(message: unknown, source: string, index: number): ChatM
63
71
  content: validateMessageContent(message.content, source, index),
64
72
  }
65
73
 
66
- if (typeof message.kind === 'string') normalized.kind = message.kind as any
74
+ if (typeof message.kind === 'string') normalized.kind = message.kind as ChatMessage['kind']
67
75
  if (typeof message.id === 'string') normalized.id = message.id
68
76
  if (typeof message.bubbleId === 'string') normalized.bubbleId = message.bubbleId
69
77
  if (typeof message.providerUnitKey === 'string') normalized.providerUnitKey = message.providerUnitKey
@@ -71,20 +79,23 @@ function validateMessage(message: unknown, source: string, index: number): ChatM
71
79
  if (isFiniteNumber(message.index)) normalized.index = message.index
72
80
  if (isFiniteNumber(message.timestamp)) normalized.timestamp = message.timestamp
73
81
  if (isFiniteNumber(message.receivedAt)) normalized.receivedAt = message.receivedAt
74
- if (typeof (message as any)._turnKey === 'string') normalized._turnKey = (message as any)._turnKey
75
- if (Array.isArray(message.toolCalls)) normalized.toolCalls = message.toolCalls as any
76
- if (isPlainObject(message.meta)) normalized.meta = message.meta as any
82
+ // (A2.3) sequence is the monotonic ordering key consumed by ChatSourceMachine.
83
+ // v1 producers omit it; the daemon derives it in normalizeNativeHistoryMessages.
84
+ if (isFiniteNumber(message.sequence)) normalized.sequence = message.sequence
85
+ if (typeof message._turnKey === 'string') normalized._turnKey = message._turnKey
86
+ if (Array.isArray(message.toolCalls)) normalized.toolCalls = message.toolCalls as ChatMessage['toolCalls']
87
+ if (isPlainObject(message.meta)) normalized.meta = message.meta as ChatMessage['meta']
77
88
  if (typeof message.senderName === 'string') normalized.senderName = message.senderName
78
- if (typeof (message as any)._type === 'string') normalized._type = (message as any)._type
79
- if (typeof (message as any)._sub === 'string') normalized._sub = (message as any)._sub
80
- if (typeof (message as any).visibility === 'string') normalized.visibility = (message as any).visibility
81
- if (typeof (message as any).transcriptVisibility === 'string') normalized.transcriptVisibility = (message as any).transcriptVisibility
82
- if (typeof (message as any).audience === 'string') normalized.audience = (message as any).audience
83
- if (typeof (message as any).source === 'string') normalized.source = (message as any).source
84
- if (typeof (message as any).userFacing === 'boolean') normalized.userFacing = (message as any).userFacing
85
- if (typeof (message as any).internal === 'boolean') normalized.internal = (message as any).internal
86
- if (typeof (message as any).isInternal === 'boolean') normalized.isInternal = (message as any).isInternal
87
- if (typeof (message as any).debug === 'boolean') normalized.debug = (message as any).debug
89
+ if (typeof message._type === 'string') normalized._type = message._type
90
+ if (typeof message._sub === 'string') normalized._sub = message._sub
91
+ if (typeof message.visibility === 'string') normalized.visibility = message.visibility
92
+ if (typeof message.transcriptVisibility === 'string') normalized.transcriptVisibility = message.transcriptVisibility
93
+ if (typeof message.audience === 'string') normalized.audience = message.audience
94
+ if (typeof message.source === 'string') normalized.source = message.source
95
+ if (typeof message.userFacing === 'boolean') normalized.userFacing = message.userFacing
96
+ if (typeof message.internal === 'boolean') normalized.internal = message.internal
97
+ if (typeof message.isInternal === 'boolean') normalized.isInternal = message.isInternal
98
+ if (typeof message.debug === 'boolean') normalized.debug = message.debug
88
99
 
89
100
  return normalized
90
101
  }
@@ -129,6 +140,55 @@ function validateControlValues(controlValues: unknown, source: string): Record<s
129
140
  return normalized
130
141
  }
131
142
 
143
+ /**
144
+ * Read the producer-declared contract version from a raw read_chat payload.
145
+ * Returns v1 when absent or unrecognised, so legacy producers keep working
146
+ * through A1. A2 will tighten this to throw when an unsupported version is
147
+ * declared.
148
+ */
149
+ export function readPayloadContractVersion(raw: unknown): ChatContractVersion {
150
+ if (!isPlainObject(raw)) return CHAT_CONTRACT_VERSION_V1
151
+ const declared = (raw as Record<string, unknown>).contractVersion
152
+ if (isSupportedChatContractVersion(declared)) return declared
153
+ return CHAT_CONTRACT_VERSION_V1
154
+ }
155
+
156
+ /**
157
+ * Validate a v2 payload. Thin wrapper around assertReadChatResultV2Payload
158
+ * that prefixes the contract violation with the caller's source label.
159
+ */
160
+ export function validateReadChatResultV2Payload(raw: unknown, source = 'read_chat'): ReadChatResultV2 {
161
+ try {
162
+ return assertReadChatResultV2Payload(raw)
163
+ } catch (err) {
164
+ if (err instanceof Error) {
165
+ err.message = `${source}: ${err.message}`
166
+ }
167
+ throw err
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Versioned entry point. Routes on the producer-declared contractVersion:
173
+ * - v2 → strict v2 validation (transcript-v2.ts invariants)
174
+ * - v1 (or absent) → legacy permissive validation
175
+ *
176
+ * Callers that have not yet been audited to handle v2 outputs should use
177
+ * validateReadChatResultPayload directly; that path stays bound to v1 shape
178
+ * during the A1 transition.
179
+ */
180
+ export function validateReadChatResultPayloadVersioned(
181
+ raw: unknown,
182
+ source = 'read_chat',
183
+ ): { version: typeof CHAT_CONTRACT_VERSION_V1; payload: ReadChatResult & Record<string, unknown> }
184
+ | { version: typeof CHAT_CONTRACT_VERSION_V2; payload: ReadChatResultV2 } {
185
+ const version = readPayloadContractVersion(raw)
186
+ if (version === CHAT_CONTRACT_VERSION_V2) {
187
+ return { version, payload: validateReadChatResultV2Payload(raw, source) }
188
+ }
189
+ return { version: CHAT_CONTRACT_VERSION_V1, payload: validateReadChatResultPayload(raw, source) }
190
+ }
191
+
132
192
  export function validateReadChatResultPayload(raw: unknown, source = 'read_chat'): ReadChatResult & Record<string, unknown> {
133
193
  if (!isPlainObject(raw)) {
134
194
  throw new Error(`${source}: payload must be an object`)
@@ -0,0 +1,49 @@
1
+ # Provider SDK
2
+
3
+ > Status: Phase 1 in progress · License of this directory: AGPL-3.0 (part of `oss/`) · See [marketplace plan](../../../../../../docs/design/v1.0.0-marketplace-plan.md).
4
+
5
+ This directory is the **Provider SDK** — the framework that lets external developers author CLI providers (and later IDE, Extension, ACP) against a versioned, typed contract.
6
+
7
+ It lives **inside daemon-core**, not as a separate package, by design:
8
+
9
+ - the contract definitions live next to the runtime that consumes them, eliminating version drift
10
+ - `adhdev provider *` CLI commands call straight into these modules
11
+ - two npm packages are extracted from this source at build time:
12
+ - `@adhdev/provider-types` (Apache 2.0) — TypeScript types for external authors
13
+ - `@adhdev/provider-schemas` (Apache 2.0) — JSON Schemas for editor support
14
+
15
+ ## Layout
16
+
17
+ ```
18
+ sdk/
19
+ v1/ ← contract version 1 (current)
20
+ types/ ← TypeScript types — extracted to @adhdev/provider-types
21
+ cli/ ← CLI category types
22
+ common/ ← shared types (settings, capabilities, auth, spawn)
23
+ schemas/ ← JSON Schemas — extracted to @adhdev/provider-schemas
24
+ cli/
25
+ provider.schema.json ← top-level provider.json (mirrors adhdev-providers/schemas/v1/cli/)
26
+ primitives/ ← per-primitive schemas, namespaced by category
27
+ common/
28
+ primitives/ ← daemon-side primitive implementations
29
+ cli/ ← TUI primitives, native-history adapters, capability handlers
30
+ builders/ ← functions that turn manifest blocks into runtime handlers
31
+ validators/ ← schema check, AST taint analysis, fixture replay
32
+ scaffolders/ ← `adhdev provider init` templates
33
+ fixture-tooling/ ← PTY capture + replay utilities
34
+ v2/ ← reserved for next contract major
35
+ ```
36
+
37
+ ## Primitive identifiers
38
+
39
+ Primitives are referenced by `$schema: adhdev:<category>/<id>@<version>` in provider manifests. See the audit-derived v1 catalog of 50 primitives at [`audit-cli-v1.md §5`](../../../../../../../adhdev-providers/docs/provider-contract/cli/audit-cli-v1.md#5-proposed-v1-primitive-set).
40
+
41
+ ## Stability
42
+
43
+ `v1/` is unstable until SDK `1.0.0` is published. Breaking changes between SDK `0.x` releases are permitted during Phase 1-2 migration. After SDK `1.0.0`, breaking changes require an `engines.adhdev` major bump.
44
+
45
+ ## Out of scope
46
+
47
+ - This SDK does not provide IDE, Extension, or ACP primitives in v1.0.0. They follow in v1.1+.
48
+ - This SDK does not include the registry server code — that lives in [`oss/packages/registry/`](../../../../../registry/) (not yet created).
49
+ - This SDK does not include the marketplace web UI — that lives separately.
@@ -0,0 +1,144 @@
1
+ /**
2
+ * buildDetectStatusFromAcp
3
+ *
4
+ * Turns a declarative `acp/session-protocol@1` block into a runtime
5
+ * `(input: AcpStatusInput) => 'idle' | 'generating' | 'waiting_approval' | null`
6
+ * function.
7
+ *
8
+ * Dispatch order:
9
+ * 1. Not connected → null (no information available).
10
+ * 2. Error patterns — checked first; first match returns the declared verdict.
11
+ * 3. Generating pattern — `generating`.
12
+ * 4. Idle pattern — `idle`.
13
+ * 5. Default: `null` (no change — caller preserves last known status).
14
+ *
15
+ * All regex patterns are compiled once at builder time so the returned
16
+ * detector function is allocation-free on the hot path.
17
+ */
18
+
19
+ // ─── Spec shapes (mirror the JSON schema) ──────────────────────────────
20
+
21
+ interface AcpRegexPatternSpec {
22
+ regex: string;
23
+ flags?: string;
24
+ description?: string;
25
+ }
26
+
27
+ interface AcpErrorPatternSpec extends AcpRegexPatternSpec {
28
+ verdict: 'idle' | 'generating' | 'waiting_approval';
29
+ }
30
+
31
+ export interface AcpSessionSpec {
32
+ $schema?: 'adhdev:acp/session-protocol@1';
33
+ /** Pattern that matches a line emitted when the agent is idle/ready. */
34
+ idlePattern?: AcpRegexPatternSpec;
35
+ /** Pattern that matches a line emitted while the agent is actively working. */
36
+ generatingPattern?: AcpRegexPatternSpec;
37
+ /**
38
+ * Error/edge-case patterns. Checked in order; first match returns the
39
+ * declared verdict. Useful for approval prompts, fatal errors, etc.
40
+ */
41
+ errorPatterns?: AcpErrorPatternSpec[];
42
+ /** Wire format; informational only at the builder level — regex matching
43
+ * is identical regardless of promptStyle. */
44
+ promptStyle?: 'json-rpc' | 'plain-text' | 'mcp';
45
+ /** Message delimiter used to split incoming bytes (default: newline). */
46
+ messageDelimiter?: string;
47
+ }
48
+
49
+ // ─── Input shape ────────────────────────────────────────────────────────
50
+
51
+ export interface AcpStatusInput {
52
+ /** The most recently received line from the stdio stream. */
53
+ lastLine: string;
54
+ /**
55
+ * A sliding window of recent output lines (newest last).
56
+ * Builders may check these when a single line is not enough for context.
57
+ */
58
+ recentLines: string[];
59
+ /** Whether the ACP process is currently connected and running. */
60
+ isConnected: boolean;
61
+ }
62
+
63
+ // ─── Output type ────────────────────────────────────────────────────────
64
+
65
+ export type AcpDetectedStatus = 'idle' | 'generating' | 'waiting_approval' | null;
66
+
67
+ // ─── Helpers ────────────────────────────────────────────────────────────
68
+
69
+ function compile(re: string, flags?: string): RegExp {
70
+ try {
71
+ return new RegExp(re, flags ?? 'i');
72
+ } catch (e) {
73
+ throw new Error(`Invalid regex /${re}/${flags ?? 'i'}: ${(e as Error).message}`);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Safe `.test()` wrapper: resets `lastIndex` before each call so that
79
+ * regexes compiled with the `g` or `y` flag remain stateless across
80
+ * multiple detect invocations.
81
+ */
82
+ function testRe(re: RegExp, text: string): boolean {
83
+ re.lastIndex = 0;
84
+ return re.test(text);
85
+ }
86
+
87
+ // ─── Compiled internal representation ───────────────────────────────────
88
+
89
+ interface CompiledAcpSpec {
90
+ idle: RegExp | null;
91
+ generating: RegExp | null;
92
+ errors: Array<{ re: RegExp; verdict: AcpDetectedStatus }>;
93
+ }
94
+
95
+ function compileSpec(spec: AcpSessionSpec): CompiledAcpSpec {
96
+ const idle = spec.idlePattern
97
+ ? compile(spec.idlePattern.regex, spec.idlePattern.flags)
98
+ : null;
99
+
100
+ const generating = spec.generatingPattern
101
+ ? compile(spec.generatingPattern.regex, spec.generatingPattern.flags)
102
+ : null;
103
+
104
+ const errors = (spec.errorPatterns ?? []).map((ep) => ({
105
+ re: compile(ep.regex, ep.flags),
106
+ verdict: ep.verdict as AcpDetectedStatus,
107
+ }));
108
+
109
+ return { idle, generating, errors };
110
+ }
111
+
112
+ // ─── Public builder ─────────────────────────────────────────────────────
113
+
114
+ export function buildDetectStatusFromAcp(
115
+ spec: AcpSessionSpec,
116
+ ): (input: AcpStatusInput) => AcpDetectedStatus {
117
+ const compiled = compileSpec(spec);
118
+
119
+ return function detectAcpStatus(input: AcpStatusInput): AcpDetectedStatus {
120
+ // 1. No connection → no information.
121
+ if (!input.isConnected) return null;
122
+
123
+ const line = input.lastLine;
124
+
125
+ // 2. Error/edge-case patterns take priority.
126
+ for (const { re, verdict } of compiled.errors) {
127
+ if (testRe(re, line)) return verdict;
128
+ }
129
+
130
+ // 3. Generating pattern.
131
+ if (compiled.generating && testRe(compiled.generating, line)) return 'generating';
132
+
133
+ // 4. Idle pattern.
134
+ if (compiled.idle && testRe(compiled.idle, line)) return 'idle';
135
+
136
+ // 5. Nothing matched.
137
+ return null;
138
+ };
139
+ }
140
+
141
+ // Internal exports for builder reuse + tests.
142
+ export const __internal = {
143
+ compileSpec,
144
+ };