@adhdev/daemon-core 0.9.82-rc.37 → 0.9.82-rc.371

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 (384) 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 +55 -2
  8. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  9. package/dist/cli-adapters/cli-state-engine.d.ts +198 -0
  10. package/dist/cli-adapters/provider-cli-adapter.d.ts +116 -64
  11. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  12. package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
  13. package/dist/cli-adapters/provider-cli-shared.d.ts +63 -0
  14. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  15. package/dist/cli-adapters/resolve-executable.d.ts +14 -0
  16. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
  17. package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
  18. package/dist/cli-adapters/terminal-screen.d.ts +4 -11
  19. package/dist/commands/chat-commands.d.ts +27 -0
  20. package/dist/commands/cli-manager.d.ts +15 -1
  21. package/dist/commands/handler.d.ts +125 -0
  22. package/dist/commands/high-family/index.d.ts +3 -0
  23. package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
  24. package/dist/commands/high-family/mesh-events.d.ts +2 -0
  25. package/dist/commands/high-family/mesh-status.d.ts +2 -0
  26. package/dist/commands/high-family/types.d.ts +60 -0
  27. package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
  28. package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
  29. package/dist/commands/low-family/diagnostics.d.ts +2 -0
  30. package/dist/commands/low-family/index.d.ts +3 -0
  31. package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
  32. package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
  33. package/dist/commands/low-family/notification.d.ts +2 -0
  34. package/dist/commands/low-family/refine-config.d.ts +2 -0
  35. package/dist/commands/low-family/session-host.d.ts +2 -0
  36. package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
  37. package/dist/commands/low-family/status-meta.d.ts +2 -0
  38. package/dist/commands/low-family/types.d.ts +33 -0
  39. package/dist/commands/med-family/cli-agent.d.ts +2 -0
  40. package/dist/commands/med-family/fast-forward.d.ts +2 -0
  41. package/dist/commands/med-family/ide.d.ts +10 -0
  42. package/dist/commands/med-family/index.d.ts +3 -0
  43. package/dist/commands/med-family/mesh-crud.d.ts +2 -0
  44. package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
  45. package/dist/commands/med-family/mesh-queue.d.ts +2 -0
  46. package/dist/commands/med-family/mesh-restart.d.ts +2 -0
  47. package/dist/commands/med-family/types.d.ts +116 -0
  48. package/dist/commands/mesh-coordinator.d.ts +85 -1
  49. package/dist/commands/router.d.ts +666 -2
  50. package/dist/commands/upgrade-helper.d.ts +41 -1
  51. package/dist/config/chat-history.d.ts +9 -0
  52. package/dist/config/config.d.ts +5 -0
  53. package/dist/config/mesh-config.d.ts +77 -1
  54. package/dist/daemon/dev-server.d.ts +0 -2
  55. package/dist/detection/ide-detector.d.ts +13 -0
  56. package/dist/detection/win32-ide-version.d.ts +37 -0
  57. package/dist/git/change-impact-config.d.ts +159 -0
  58. package/dist/git/git-commands.d.ts +11 -1
  59. package/dist/git/git-diff.d.ts +6 -0
  60. package/dist/git/git-executor.d.ts +11 -0
  61. package/dist/git/git-status.d.ts +23 -0
  62. package/dist/git/git-types.d.ts +2 -50
  63. package/dist/git/index.d.ts +2 -0
  64. package/dist/index.d.ts +55 -13
  65. package/dist/index.js +46565 -19737
  66. package/dist/index.js.map +1 -1
  67. package/dist/index.mjs +43563 -16868
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/installer.d.ts +1 -4
  70. package/dist/ipc/local-ipc-server.d.ts +91 -0
  71. package/dist/launch.d.ts +1 -1
  72. package/dist/logging/async-batch-writer.d.ts +10 -0
  73. package/dist/logging/log-redactor.d.ts +24 -0
  74. package/dist/logging/log-tail-reader.d.ts +46 -0
  75. package/dist/logging/logger.d.ts +1 -1
  76. package/dist/mesh/contracts.d.ts +164 -0
  77. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  78. package/dist/mesh/coordinator-registry.d.ts +59 -0
  79. package/dist/mesh/mesh-active-work.d.ts +174 -0
  80. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  81. package/dist/mesh/mesh-event-trace.d.ts +21 -0
  82. package/dist/mesh/mesh-events-coordinator.d.ts +91 -0
  83. package/dist/mesh/mesh-events-pending.d.ts +55 -0
  84. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  85. package/dist/mesh/mesh-events-utils.d.ts +61 -0
  86. package/dist/mesh/mesh-events.d.ts +6 -49
  87. package/dist/mesh/mesh-fast-forward.d.ts +81 -0
  88. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  89. package/dist/mesh/mesh-init.d.ts +86 -0
  90. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  91. package/dist/mesh/mesh-ledger.d.ts +77 -1
  92. package/dist/mesh/mesh-missions.d.ts +164 -0
  93. package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
  94. package/dist/mesh/mesh-refine-batch.d.ts +68 -0
  95. package/dist/mesh/mesh-refine-status.d.ts +62 -0
  96. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  97. package/dist/mesh/mesh-routing.d.ts +70 -0
  98. package/dist/mesh/mesh-runtime-store.d.ts +429 -0
  99. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  100. package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
  101. package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
  102. package/dist/mesh/mesh-work-queue.d.ts +246 -5
  103. package/dist/mesh/preview-freshness.d.ts +18 -0
  104. package/dist/mesh/refine-config.d.ts +216 -0
  105. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  106. package/dist/providers/acp-provider-instance.d.ts +5 -0
  107. package/dist/providers/approval-utils.d.ts +20 -0
  108. package/dist/providers/chat-message-normalization.d.ts +12 -0
  109. package/dist/providers/cli-provider-instance.d.ts +108 -3
  110. package/dist/providers/contracts.d.ts +139 -6
  111. package/dist/providers/external-sources.d.ts +71 -0
  112. package/dist/providers/manual-attendance.d.ts +63 -0
  113. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  114. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  115. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  116. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  117. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  118. package/dist/providers/native-history/index.d.ts +13 -0
  119. package/dist/providers/provider-instance-manager.d.ts +14 -0
  120. package/dist/providers/provider-instance.d.ts +23 -1
  121. package/dist/providers/provider-loader.d.ts +26 -4
  122. package/dist/providers/provider-trust.d.ts +31 -0
  123. package/dist/providers/read-chat-contract.d.ts +29 -0
  124. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  125. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
  126. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  127. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  128. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  129. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  130. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  131. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  132. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  133. package/dist/providers/sdk/v1/index.d.ts +30 -0
  134. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  135. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  136. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  137. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  138. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  139. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  140. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  141. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  142. package/dist/providers/spec/adapter.d.ts +91 -0
  143. package/dist/providers/spec/cli-adapter.d.ts +223 -0
  144. package/dist/providers/spec/evaluator.d.ts +45 -0
  145. package/dist/providers/spec/fsm-driver.d.ts +395 -0
  146. package/dist/providers/spec/fsm-evaluator.d.ts +76 -0
  147. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  148. package/dist/providers/spec/fsm-types.d.ts +174 -0
  149. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  150. package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
  151. package/dist/providers/spec/route.d.ts +4 -0
  152. package/dist/providers/spec/types.d.ts +222 -0
  153. package/dist/providers/status-monitor.d.ts +7 -7
  154. package/dist/providers/transcript-v2.d.ts +176 -0
  155. package/dist/providers/types/interactive-prompt.d.ts +84 -0
  156. package/dist/providers/working-dir.d.ts +17 -0
  157. package/dist/repo-mesh-types.d.ts +295 -13
  158. package/dist/sessions/registry.d.ts +6 -0
  159. package/dist/shared-types-extra.d.ts +2 -4
  160. package/dist/shared-types.d.ts +59 -2
  161. package/dist/status/normalize.d.ts +1 -1
  162. package/dist/status/normalize.js +1 -0
  163. package/dist/status/normalize.js.map +1 -1
  164. package/dist/status/normalize.mjs +1 -0
  165. package/dist/status/normalize.mjs.map +1 -1
  166. package/dist/status/reporter.d.ts +2 -0
  167. package/dist/status/snapshot.d.ts +26 -0
  168. package/dist/system/hash.d.ts +8 -0
  169. package/dist/system/load-better-sqlite3.d.ts +21 -0
  170. package/dist/types.d.ts +5 -0
  171. package/package.json +7 -3
  172. package/src/agent-stream/poller.ts +2 -3
  173. package/src/agent-stream/provider-adapter.ts +1 -1
  174. package/src/boot/daemon-lifecycle.ts +63 -12
  175. package/src/boot/process-hardening.ts +89 -0
  176. package/src/build-info.ts +73 -0
  177. package/src/chat/source-machine.ts +534 -0
  178. package/src/chat/source-resolver.ts +0 -0
  179. package/src/chat/subscription-updates.ts +20 -1
  180. package/src/cli-adapter-types.d.ts +1 -0
  181. package/src/cli-adapter-types.ts +56 -2
  182. package/src/cli-adapters/cli-script-runner.ts +421 -0
  183. package/src/cli-adapters/cli-state-engine.ts +1221 -0
  184. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  185. package/src/cli-adapters/provider-cli-adapter.ts +775 -1141
  186. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  187. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  188. package/src/cli-adapters/provider-cli-runtime.ts +56 -7
  189. package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
  190. package/src/cli-adapters/provider-cli-shared.ts +110 -11
  191. package/src/cli-adapters/pty-transport.ts +2 -1
  192. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  193. package/src/cli-adapters/resolve-executable.ts +90 -0
  194. package/src/cli-adapters/session-host-transport.ts +2 -1
  195. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -29
  196. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  197. package/src/cli-adapters/terminal-screen.ts +16 -81
  198. package/src/commands/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
  199. package/src/commands/chat-commands.ts +1917 -62
  200. package/src/commands/cli-manager.ts +502 -24
  201. package/src/commands/handler.ts +841 -2
  202. package/src/commands/high-family/index.ts +28 -0
  203. package/src/commands/high-family/mesh-coordinator-launch.ts +592 -0
  204. package/src/commands/high-family/mesh-events.ts +47 -0
  205. package/src/commands/high-family/mesh-status.ts +642 -0
  206. package/src/commands/high-family/types.ts +76 -0
  207. package/src/commands/low-family/coordinator-prompt.ts +72 -0
  208. package/src/commands/low-family/daemon-lifecycle.ts +107 -0
  209. package/src/commands/low-family/diagnostics.ts +57 -0
  210. package/src/commands/low-family/index.ts +37 -0
  211. package/src/commands/low-family/mesh-ledger.ts +62 -0
  212. package/src/commands/low-family/mesh-node-logs.ts +81 -0
  213. package/src/commands/low-family/notification.ts +116 -0
  214. package/src/commands/low-family/refine-config.ts +106 -0
  215. package/src/commands/low-family/session-host.ts +274 -0
  216. package/src/commands/low-family/spec-providerdev.ts +217 -0
  217. package/src/commands/low-family/status-meta.ts +112 -0
  218. package/src/commands/low-family/types.ts +39 -0
  219. package/src/commands/med-family/cli-agent.ts +218 -0
  220. package/src/commands/med-family/fast-forward.ts +198 -0
  221. package/src/commands/med-family/ide.ts +163 -0
  222. package/src/commands/med-family/index.ts +37 -0
  223. package/src/commands/med-family/mesh-crud.ts +788 -0
  224. package/src/commands/med-family/mesh-host-pairing.ts +234 -0
  225. package/src/commands/med-family/mesh-queue.ts +131 -0
  226. package/src/commands/med-family/mesh-restart.ts +92 -0
  227. package/src/commands/med-family/types.ts +120 -0
  228. package/src/commands/mesh-coordinator.ts +334 -124
  229. package/src/commands/router.ts +5121 -2369
  230. package/src/commands/stream-commands.ts +8 -0
  231. package/src/commands/upgrade-helper.ts +310 -45
  232. package/src/config/chat-history.ts +483 -24
  233. package/src/config/config.ts +12 -0
  234. package/src/config/mesh-config.ts +389 -6
  235. package/src/config/recent-activity.ts +8 -2
  236. package/src/daemon/dev-auto-implement.ts +3 -2
  237. package/src/daemon/dev-cli-debug.ts +10 -1
  238. package/src/daemon/dev-server.ts +0 -541
  239. package/src/detection/cli-detector.ts +28 -9
  240. package/src/detection/ide-detector.ts +55 -16
  241. package/src/detection/win32-ide-version.ts +106 -0
  242. package/src/git/change-impact-config.ts +354 -0
  243. package/src/git/git-commands.ts +55 -14
  244. package/src/git/git-diff.ts +81 -11
  245. package/src/git/git-executor.ts +12 -0
  246. package/src/git/git-status.ts +574 -43
  247. package/src/git/git-types.ts +14 -62
  248. package/src/git/git-worktree.ts +8 -1
  249. package/src/git/index.ts +16 -0
  250. package/src/index.ts +158 -12
  251. package/src/installer.d.ts +1 -1
  252. package/src/installer.ts +8 -6
  253. package/src/ipc/local-ipc-server.ts +278 -0
  254. package/src/launch.d.ts +1 -1
  255. package/src/launch.ts +37 -28
  256. package/src/logging/async-batch-writer.ts +55 -0
  257. package/src/logging/command-log.ts +7 -5
  258. package/src/logging/log-redactor.ts +100 -0
  259. package/src/logging/log-tail-reader.ts +220 -0
  260. package/src/logging/logger.ts +14 -7
  261. package/src/mesh/contracts.ts +338 -0
  262. package/src/mesh/coordinator-prompt.ts +234 -31
  263. package/src/mesh/coordinator-registry.ts +121 -0
  264. package/src/mesh/mesh-active-work.ts +645 -0
  265. package/src/mesh/mesh-delivery-policy.ts +315 -0
  266. package/src/mesh/mesh-event-trace.ts +67 -0
  267. package/src/mesh/mesh-events-coordinator.ts +2866 -0
  268. package/src/mesh/mesh-events-pending.ts +599 -0
  269. package/src/mesh/mesh-events-stale.ts +309 -0
  270. package/src/mesh/mesh-events-utils.ts +387 -0
  271. package/src/mesh/mesh-events.ts +30 -1035
  272. package/src/mesh/mesh-fast-forward.ts +839 -0
  273. package/src/mesh/mesh-host-ownership.ts +73 -0
  274. package/src/mesh/mesh-init.ts +260 -0
  275. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  276. package/src/mesh/mesh-ledger.ts +591 -102
  277. package/src/mesh/mesh-missions.ts +322 -0
  278. package/src/mesh/mesh-reconcile-loop.ts +1134 -0
  279. package/src/mesh/mesh-refine-batch.ts +197 -0
  280. package/src/mesh/mesh-refine-status.ts +231 -0
  281. package/src/mesh/mesh-review-inbox.ts +307 -0
  282. package/src/mesh/mesh-routing.ts +291 -0
  283. package/src/mesh/mesh-runtime-store.ts +1697 -0
  284. package/src/mesh/mesh-task-stats.ts +161 -0
  285. package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
  286. package/src/mesh/mesh-warmup-deadline.ts +152 -0
  287. package/src/mesh/mesh-work-queue.ts +997 -141
  288. package/src/mesh/preview-freshness.ts +118 -0
  289. package/src/mesh/refine-config.ts +423 -0
  290. package/src/mesh/worktree-bootstrap-config.ts +331 -0
  291. package/src/providers/acp-provider-instance.ts +43 -10
  292. package/src/providers/approval-utils.d.ts +5 -0
  293. package/src/providers/approval-utils.ts +57 -5
  294. package/src/providers/chat-message-normalization.ts +45 -5
  295. package/src/providers/cli-provider-instance.ts +1310 -101
  296. package/src/providers/contracts.d.ts +55 -0
  297. package/src/providers/contracts.ts +150 -6
  298. package/src/providers/extension-provider-instance.ts +12 -7
  299. package/src/providers/external-sources.ts +218 -0
  300. package/src/providers/ide-provider-instance.ts +35 -12
  301. package/src/providers/manual-attendance.ts +85 -0
  302. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  303. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  304. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  305. package/src/providers/native-history/dispatcher.ts +340 -0
  306. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  307. package/src/providers/native-history/index.ts +30 -0
  308. package/src/providers/provider-instance-manager.ts +30 -0
  309. package/src/providers/provider-instance.ts +19 -1
  310. package/src/providers/provider-loader.ts +668 -50
  311. package/src/providers/provider-schema.ts +87 -14
  312. package/src/providers/provider-trust.ts +114 -0
  313. package/src/providers/read-chat-contract.ts +76 -16
  314. package/src/providers/sdk/README.md +49 -0
  315. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  316. package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
  317. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  318. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  319. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  320. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  321. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  322. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  323. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  324. package/src/providers/sdk/v1/index.ts +152 -0
  325. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  326. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  327. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  328. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  329. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  330. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  331. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  332. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  333. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  334. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  335. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  336. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  337. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  338. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  339. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  340. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  341. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  342. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  343. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  344. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  345. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  346. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  347. package/src/providers/sdk/v1/validators/index.ts +19 -0
  348. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  349. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  350. package/src/providers/spec/adapter.ts +235 -0
  351. package/src/providers/spec/cli-adapter.ts +1051 -0
  352. package/src/providers/spec/evaluator.ts +407 -0
  353. package/src/providers/spec/fsm-driver.ts +1305 -0
  354. package/src/providers/spec/fsm-evaluator.ts +272 -0
  355. package/src/providers/spec/fsm-loader.ts +120 -0
  356. package/src/providers/spec/fsm-types.ts +273 -0
  357. package/src/providers/spec/native-history-executor.ts +1136 -0
  358. package/src/providers/spec/pre-launch-trust.ts +104 -0
  359. package/src/providers/spec/route.ts +51 -0
  360. package/src/providers/spec/types.ts +262 -0
  361. package/src/providers/status-monitor.d.ts +7 -7
  362. package/src/providers/status-monitor.ts +37 -22
  363. package/src/providers/transcript-v2.ts +567 -0
  364. package/src/providers/types/interactive-prompt.ts +536 -0
  365. package/src/providers/version-archive.ts +64 -24
  366. package/src/providers/working-dir.ts +23 -0
  367. package/src/repo-mesh-types.ts +378 -14
  368. package/src/sessions/registry.ts +6 -0
  369. package/src/shared-types-extra.ts +2 -4
  370. package/src/shared-types.d.ts +8 -0
  371. package/src/shared-types.ts +64 -1
  372. package/src/status/builders.ts +26 -6
  373. package/src/status/normalize.ts +2 -0
  374. package/src/status/reporter.ts +19 -1
  375. package/src/status/snapshot.ts +95 -26
  376. package/src/system/hash.ts +23 -0
  377. package/src/system/host-memory.ts +29 -12
  378. package/src/system/load-better-sqlite3.ts +68 -0
  379. package/src/types.ts +5 -0
  380. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  381. package/dist/mesh/mesh-sync.d.ts +0 -53
  382. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  383. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  384. package/src/mesh/mesh-sync.ts +0 -111
@@ -14,6 +14,448 @@ import { DaemonCliManager } from './cli-manager.js';
14
14
  import type { ProviderLoader } from '../providers/provider-loader.js';
15
15
  import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
16
16
  import { SessionRegistry } from '../sessions/registry.js';
17
+ import { awaitWithWarmupDeadline } from '../mesh/mesh-warmup-deadline.js';
18
+ export declare function readProviderPriorityFromPolicy(policy: unknown): string[];
19
+ /**
20
+ * Normalize a providerRoles array (RepoMeshNodePolicy.providerRoles) from raw
21
+ * tool args. Each entry binds a providerType to an optional `maxParallel` cap.
22
+ * Entries without a usable providerType are dropped; the last entry wins on
23
+ * duplicate providerType. Returns [] when no valid entries — callers then omit
24
+ * the field entirely (full backward compat). Routing is governed by required_tags;
25
+ * any legacy `role` field on the input is ignored.
26
+ */
27
+ export declare function normalizeProviderRoles(value: unknown): Array<{
28
+ providerType: string;
29
+ maxParallel?: number;
30
+ }>;
31
+ export declare function readObjectRecord(value: unknown): Record<string, any>;
32
+ export declare function readStringValue(...values: unknown[]): string | undefined;
33
+ export declare function readBooleanValue(...values: unknown[]): boolean | undefined;
34
+ export declare function summarizeRepoMeshStatusDebug(status: any): Record<string, unknown>;
35
+ export declare function logRepoMeshStatusDebug(event: string, fields: Record<string, unknown>): void;
36
+ export declare function buildMeshNodeDisplayLabel(node: Record<string, unknown>, nodeId: string, providerPriority: string[]): string;
37
+ export declare function readMeshNodeMachineId(node: Record<string, unknown>): string | undefined;
38
+ export declare function readMeshNodeHostname(node: Record<string, unknown>): string | undefined;
39
+ export declare function buildMeshNodeMachineIdentity(node: Record<string, unknown>, opts: {
40
+ localMachineId?: string;
41
+ localDaemonId?: string;
42
+ coordinatorHostname?: string;
43
+ isSelfNode?: boolean;
44
+ }): Record<string, unknown>;
45
+ export declare function buildInlineMeshTransitGitStatus(node: any): Record<string, unknown> | undefined;
46
+ export declare function buildLivePeerGitConnection(connection: Record<string, unknown>, timestamp?: string): Record<string, unknown>;
47
+ export declare function recordInlineMeshDirectGitTruth(node: any, git: Record<string, unknown>, source: 'selected_coordinator_local_git' | 'selected_coordinator_mesh_p2p_git'): {
48
+ reporterPlatform: string | null;
49
+ reporterArch: string | null;
50
+ };
51
+ /**
52
+ * Persist the live self-reported platform/arch onto the local meshes.json node
53
+ * record so capability-tag os=/arch= self-heals across coordinator restarts.
54
+ *
55
+ * The in-memory stamp done by recordInlineMeshDirectGitTruth lives on the
56
+ * mesh_status assembly object and is discarded after the response; only a
57
+ * `local_config` mesh has a backing meshes.json node to write through to. Inline
58
+ * cache/bootstrap meshes have no local node to update, so we no-op for them.
59
+ * Fire-and-forget (same pattern as the worktreeBootstrap writer) — a persistence
60
+ * failure must never block the status response.
61
+ */
62
+ export declare function persistNodeReporterPlatform(meshSource: 'inline_cache' | 'inline_bootstrap' | 'local_config', mesh: any, nodeId: string | undefined, reporter: {
63
+ reporterPlatform: string | null;
64
+ reporterArch: string | null;
65
+ }): void;
66
+ export declare function deriveMeshNodeHealthFromGit(git: Record<string, unknown> | null | undefined): 'online' | 'dirty' | 'degraded';
67
+ export declare function applyInlineMeshBranchConvergence(mesh: any, node: any, status: Record<string, unknown>): void;
68
+ export declare function summarizeInlineMeshBranchConvergence(nodes: Array<Record<string, unknown>>): Record<string, unknown>;
69
+ /**
70
+ * Resolve the owning-node attribution for a mesh node record so a coordinator can
71
+ * stamp the TRUE owner onto a synthetic session entry instead of letting the
72
+ * dashboard fall back to the coordinator's own daemonId. Returns whichever of the
73
+ * owning node's `daemonId` / display machine name could be read from the node's
74
+ * (possibly multi-serialization-path) shape; both may be undefined for a node that
75
+ * never carried machine identity.
76
+ */
77
+ export declare function resolveMeshNodeAttribution(node: unknown): {
78
+ daemonId?: string;
79
+ machineName?: string;
80
+ };
81
+ export declare function readCachedInlineMeshActiveSessionDetails(node: any): Array<Record<string, unknown>>;
82
+ /**
83
+ * Transient per-node marker the mesh_status render loop stamps onto a node
84
+ * `status` at the two sites that obtain git truth from a FRESH probe this call
85
+ * (a successful local `getGitRepoStatus`, or a successful P2P `git_status`
86
+ * round-trip). finalizeMeshNodeStatus consumes and deletes it. Held/standing
87
+ * truth (node.lastGit / cachedStatus / inline transit) is deliberately NOT
88
+ * stamped — its absence is exactly how the freshness marker tells "live" apart
89
+ * from "cached". Internal only; never serialized in the response.
90
+ */
91
+ export declare const MESH_NODE_LIVE_TRUTH_MARKER = "__liveTruthProbed";
92
+ /**
93
+ * Build the additive per-node `dataFreshness` marker. This NEVER mutates any
94
+ * existing field — it only adds an explicit, machine-readable answer to the
95
+ * question the legacy fields blurred: is this node's data live (just probed),
96
+ * cached (held truth, maybe old), or absent because the peer was unreachable?
97
+ *
98
+ * The crucial separation: an UNREACHABLE peer (P2P probe failed / not connected)
99
+ * is no longer indistinguishable from an idle/EMPTY node. Both used to render as
100
+ * `health:'unknown'` with no sessions; now `dataFreshness.dataSource` and
101
+ * `reachable` tell them apart so a coordinator never reads a dead peer as "online
102
+ * but doing nothing".
103
+ */
104
+ export declare function buildMeshNodeDataFreshness(args: {
105
+ status: Record<string, unknown>;
106
+ node?: any;
107
+ isSelfNode: boolean;
108
+ daemonId?: string;
109
+ /** True when this node was stamped with a fresh live git probe this call. */
110
+ liveTruthProbed: boolean;
111
+ /** True when direct-peer-truth accounting classified this node unavailable. */
112
+ directTruthUnavailable?: boolean;
113
+ now?: () => number;
114
+ }): Record<string, unknown>;
115
+ export declare function finalizeMeshNodeStatus(args: {
116
+ status: Record<string, unknown>;
117
+ node: any;
118
+ daemonId?: string;
119
+ isSelfNode: boolean;
120
+ /** True when direct-peer-truth accounting classified this node unavailable. */
121
+ directTruthUnavailable?: boolean;
122
+ }): void;
123
+ export declare const MESH_DIRECT_PROBE_TIMEOUT_MS: number;
124
+ export declare const MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS: number;
125
+ export declare const MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS: number;
126
+ /**
127
+ * De-duplicates and rate-limits per-peer git_status probes so a single mesh
128
+ * refresh — or a burst of refreshes from the dashboard auto-retry loop — cannot
129
+ * launch a storm of concurrent/back-to-back `refreshUpstream:true` commands to
130
+ * the same slow peer.
131
+ *
132
+ * Two gates, both keyed by `daemonId::workspace`:
133
+ * - In-flight dedup: a second probe for a key with a probe already running
134
+ * shares (awaits) the in-flight promise instead of issuing a second command.
135
+ * - Recently-probed reuse: a successful probe younger than `reuseMs` is reused
136
+ * verbatim instead of issuing a fresh probe. Failures are NOT cached (so a
137
+ * transient timeout doesn't pin a peer to "no truth" for the whole window).
138
+ *
139
+ * Lives on the router instance so the gate spans separate mesh_status calls,
140
+ * which is exactly where the refresh storm happens.
141
+ */
142
+ export declare class MeshGitProbeCache {
143
+ private readonly reuseMs;
144
+ private readonly now;
145
+ private inflight;
146
+ private recent;
147
+ constructor(reuseMs: number, now?: () => number);
148
+ private key;
149
+ /**
150
+ * Run `probe` for this peer, but reuse a fresh recent result or an in-flight
151
+ * probe for the same key when one is available. `probe` is only invoked when
152
+ * neither gate is satisfied.
153
+ */
154
+ probe(daemonId: string, workspace: string, probe: () => Promise<Record<string, unknown> | null>): Promise<Record<string, unknown> | null>;
155
+ }
156
+ export { awaitWithWarmupDeadline };
157
+ /**
158
+ * Probe a remote peer's git_status with a bounded retry budget, but only while
159
+ * the peer is reported `connected`. A single slow (often TURN-relayed) peer can
160
+ * exceed one probe window; retrying — with the connection re-checked before each
161
+ * attempt so we abandon a peer that dropped — recovers it without blocking the
162
+ * mesh forever. Shared by the bootstrap hydrate path and the per-node render
163
+ * path so both treat a connected-but-slow peer identically.
164
+ *
165
+ * Returns the git status on success, or null if every attempt failed/timed out
166
+ * (caller decides how to classify). `getConnection` is consulted before each
167
+ * attempt; a non-`connected` state short-circuits the retry loop (the very first
168
+ * attempt always runs so a missing connection getter still gets one try).
169
+ */
170
+ export declare function probeRemoteMeshGitStatusWithRetry(args: {
171
+ dispatchMeshCommand?: (daemonId: string, cmd: string, args: Record<string, unknown>) => Promise<unknown>;
172
+ daemonId: string;
173
+ workspace: string;
174
+ timeoutMs: number;
175
+ /** Per-attempt timeout for retries (attempts > 0); defaults to timeoutMs. */
176
+ retryTimeoutMs?: number;
177
+ /** Cold-open warmup budget per attempt; defaults to MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS. */
178
+ connectTimeoutMs?: number;
179
+ getConnection?: (daemonId: string) => Record<string, unknown> | null;
180
+ onConnection?: (connection: Record<string, unknown>) => void;
181
+ }): Promise<Record<string, unknown> | null>;
182
+ export declare function hydrateInlineMeshDirectTruth(args: {
183
+ mesh: any;
184
+ meshSource: 'inline_cache' | 'inline_bootstrap' | 'local_config';
185
+ dispatchMeshCommand?: (daemonId: string, cmd: string, args: Record<string, unknown>) => Promise<unknown>;
186
+ getMeshPeerConnectionStatus?: (daemonId: string) => Record<string, unknown> | null;
187
+ statusInstanceId?: string;
188
+ localMachineId?: string;
189
+ probeRemotePeers: boolean;
190
+ probeCache?: MeshGitProbeCache;
191
+ }): Promise<{
192
+ directEvidenceCount: number;
193
+ localConfirmedCount: number;
194
+ peerAttemptedCount: number;
195
+ peerConfirmedCount: number;
196
+ standingEvidenceCount: number;
197
+ unavailableNodeIds: string[];
198
+ deadNodeIds: string[];
199
+ }>;
200
+ export declare function summarizeMeshSessionRecord(record: any): Record<string, unknown>;
201
+ export declare function readLiveMeshNodeWorkspace(args: {
202
+ meshId: string;
203
+ nodeId: string;
204
+ liveSessionRecords: any[];
205
+ allowCoordinatorSession?: boolean;
206
+ }): string;
207
+ export declare function collectLiveMeshSessionRecords(args: {
208
+ meshId: string;
209
+ node: any;
210
+ nodeId: string;
211
+ liveSessionRecords: any[];
212
+ allowCoordinatorSession?: boolean;
213
+ }): any[];
214
+ export declare function buildHistoricalMeshSessions(args: {
215
+ meshId: string;
216
+ nodes: any[];
217
+ liveSessionRecords: any[];
218
+ }): {
219
+ count: number;
220
+ sessions: Record<string, unknown>[];
221
+ instruction: string;
222
+ } | undefined;
223
+ export declare function applyCachedInlineMeshNodeStatus(status: Record<string, unknown>, node: any, options?: {
224
+ skipGit?: boolean;
225
+ skipError?: boolean;
226
+ skipHealth?: boolean;
227
+ }): boolean;
228
+ export declare function resolveProviderTypeFromPriority(args: {
229
+ nodeId: string;
230
+ providerPriority: string[];
231
+ providerLoader: ProviderLoader;
232
+ onStatusChange?: () => void;
233
+ }): Promise<{
234
+ providerType?: string;
235
+ error?: string;
236
+ }>;
237
+ export type MeshCoordinatorConfigFormat = 'claude_mcp_json' | 'hermes_config_yaml';
238
+ type MeshRefineStageStatus = 'passed' | 'failed' | 'skipped';
239
+ type MeshRefinePatchEquivalenceSummary = {
240
+ status: MeshRefineStageStatus;
241
+ equivalent: boolean;
242
+ baseHead: string;
243
+ branchHead: string;
244
+ mergeBase?: string;
245
+ mergedTree?: string;
246
+ expectedPatchId?: string;
247
+ actualPatchId?: string;
248
+ durationMs: number;
249
+ error?: string;
250
+ stdout?: string;
251
+ stderr?: string;
252
+ actionableHint?: MeshRefineSubmoduleConflictHint;
253
+ /**
254
+ * Set when a `merge-tree` submodule conflict was reclassified as a trivial
255
+ * gitlink fast-forward and the gate passed via a synthesized merge tree.
256
+ */
257
+ gitlinkTrivialFastForward?: {
258
+ resolved: boolean;
259
+ gitlinks: Array<{
260
+ path: string;
261
+ baseCommit?: string;
262
+ branchCommit?: string;
263
+ fastForward: boolean;
264
+ }>;
265
+ reason?: string;
266
+ };
267
+ };
268
+ type MeshRefineEffectiveDiffSummary = {
269
+ status: MeshRefineStageStatus;
270
+ /** True when there is at least one root-tree change between base and branch (incl. gitlink bumps). */
271
+ hasEffectiveDiff: boolean;
272
+ baseHead: string;
273
+ branchHead: string;
274
+ /** Root-level paths that differ between base and branch (capped). */
275
+ changedPaths?: string[];
276
+ /** Submodule paths with uncommitted/divergent commits but NO committed gitlink bump in the root tree. */
277
+ submoduleHints?: Array<{
278
+ path: string;
279
+ reason: string;
280
+ }>;
281
+ durationMs: number;
282
+ error?: string;
283
+ stdout?: string;
284
+ stderr?: string;
285
+ };
286
+ type MeshRefineSubmoduleConflictHint = {
287
+ kind: 'submodule_conflict';
288
+ message: string;
289
+ conflicts: Array<{
290
+ path: string;
291
+ baseCommit?: string;
292
+ branchCommit?: string;
293
+ }>;
294
+ nextSteps: string[];
295
+ };
296
+ type MeshRefineAsyncJobStatus = 'accepted' | 'completed' | 'failed';
297
+ export type MeshRefineJobHandle = {
298
+ success: true;
299
+ async: true;
300
+ status: MeshRefineAsyncJobStatus;
301
+ jobId: string;
302
+ interactionId: string;
303
+ meshId: string;
304
+ nodeId: string;
305
+ targetNodeId: string;
306
+ targetDaemonId?: string;
307
+ workspace?: string;
308
+ startedAt: string;
309
+ completedAt?: string;
310
+ duplicate?: boolean;
311
+ retryOfJobId?: string;
312
+ /**
313
+ * The coordinator daemon ID that initiated this refine job.
314
+ * When set, events for this job are scoped to that coordinator's
315
+ * pending-events queue instead of the shared broadcast queue.
316
+ */
317
+ targetCoordinatorDaemonId?: string;
318
+ eventDelivery: {
319
+ pendingEvents: true;
320
+ ledger: true;
321
+ };
322
+ evidence: {
323
+ pendingEventsCommand: 'get_pending_mesh_events';
324
+ ledgerCommand: 'get_mesh_ledger_slice';
325
+ taskHistoryKind: 'task_dispatched' | 'task_completed' | 'task_failed';
326
+ };
327
+ };
328
+ /**
329
+ * A spawn-resolution failure is when the executable itself could not be found by
330
+ * the OS spawn boundary — `spawn <cmd> ENOENT` — as opposed to the command
331
+ * running and exiting non-zero. On win32 this is the .cmd-shim case: libuv's
332
+ * spawn search appends only .com/.exe, so a bare `npm`/`npx`/`tsc` (which are
333
+ * .cmd shims) ENOENTs even though it is installed. It carries no stderr, so it
334
+ * must be detected by error.code/syscall, not by string-matching output.
335
+ */
336
+ export declare function isSpawnResolutionError(error: any): boolean;
337
+ export declare function describeSpawnError(error: any, command: string, spawnResolutionFailed: boolean): string;
338
+ export declare function runMeshRefinePatchEquivalenceGate(repoRoot: string, baseHead: string, branchHead: string): Promise<MeshRefinePatchEquivalenceSummary>;
339
+ export type MeshWorktreePatchContainmentSummary = {
340
+ /** True only when merging worktreeHead into ref introduces no new patch. */
341
+ contained: boolean;
342
+ ref: string;
343
+ worktreeHead: string;
344
+ mergeBase?: string;
345
+ mergedTree?: string;
346
+ /** patch-id of (ref -> synthesized merge tree); empty string when nothing new is added. */
347
+ residualPatchId?: string;
348
+ durationMs: number;
349
+ /** Set when the check could not run (treated conservatively as NOT contained). */
350
+ error?: string;
351
+ };
352
+ /**
353
+ * Patch-equivalence containment check for the worktree force-cleanup convergence
354
+ * guard. Answers a narrower question than {@link runMeshRefinePatchEquivalenceGate}:
355
+ * "are the worktree branch's changes ALREADY present in `ref` (e.g. origin/main),
356
+ * even though the worktree HEAD's commit SHA is not an ancestor of ref?"
357
+ *
358
+ * This is the cherry-pick / squash / rebase case: the same content landed on the
359
+ * default ref under a different commit SHA, so `merge-base --is-ancestor` (the
360
+ * primary cleanup guard) reports the worktree as un-converged and refuses to
361
+ * remove it. Refinery already accepts patch-equivalent landings via merge-tree +
362
+ * patch-id; this brings the same notion of "convergence" to the cleanup guard.
363
+ *
364
+ * Mechanism: synthesize the merge of `worktreeHead` into `ref` (reusing the same
365
+ * trivial-gitlink-fast-forward handling as the refine gate) and compute the
366
+ * patch-id of (ref -> mergedTree). If that residual diff is EMPTY, merging the
367
+ * worktree adds nothing new on top of ref — its changes are already present there
368
+ * and the worktree is safe to remove. A non-empty residual means the worktree
369
+ * still carries content not in ref, so it is NOT contained and must stay blocked.
370
+ *
371
+ * Conservative by construction: any merge-tree / patch-id failure, a genuine
372
+ * (non-trivial) submodule conflict, or any thrown error yields `contained: false`
373
+ * so an exception can never widen the cleanup allow-list.
374
+ */
375
+ export declare function checkWorktreeChangesPatchEquivalentInRef(repoRoot: string, ref: string, worktreeHead: string): Promise<MeshWorktreePatchContainmentSummary>;
376
+ /**
377
+ * No-op guard: detect a "silent no-op" merge before the Refinery merge runs.
378
+ *
379
+ * A silent no-op occurs when the refine target branch's ROOT tree is byte-identical
380
+ * to the merge base (origin/main). This is the trap where a submodule (e.g. oss) has
381
+ * real commits but the root branch never committed the gitlink (oss-pointer) bump, so
382
+ * the root diff Refinery would merge is empty. Merging that produces a merge commit with
383
+ * no content change — reported as "success" while the actual work never reaches main.
384
+ *
385
+ * A committed gitlink bump (the legitimate oss-pointer bump) DOES show up in the root
386
+ * tree diff (as a 160000-mode entry), so this guard does NOT block legitimate refines —
387
+ * it only fires when the root tree diff vs base is COMPLETELY empty.
388
+ *
389
+ * Runs after the patch-equivalence gate; the "already merged via other path" case
390
+ * (branch has real changes already present in base) is handled upstream and never
391
+ * reaches here, so an empty root diff at this point is genuinely a no-op.
392
+ */
393
+ export declare function runMeshRefineEffectiveDiffGate(repoRoot: string, baseHead: string, branchHead: string): Promise<MeshRefineEffectiveDiffSummary>;
394
+ /**
395
+ * Result of evaluating whether a `git merge-tree --write-tree` submodule
396
+ * conflict is in fact a trivial gitlink fast-forward that should pass the
397
+ * patch-equivalence gate.
398
+ *
399
+ * `git merge-tree` (and `git merge` with the default recursive strategy)
400
+ * refuses to 3-way merge gitlinks unless the case is "trivial" — and it
401
+ * treats *any* gitlink that differs across merge-base/base/branch as
402
+ * non-trivial, even when the branch-side commit is a strict descendant of the
403
+ * base-side commit (i.e. a real fast-forward). Refinery only ever wants to
404
+ * accept the branch's recorded gitlink, so a fast-forwardable bump is safe to
405
+ * resolve to the branch side without any conflict.
406
+ */
407
+ type GitlinkTrivialFastForwardEvaluation = {
408
+ /** True only when the merge-tree conflict is *fully* explained by trivial-ff gitlinks. */
409
+ trivial: boolean;
410
+ /** Why the evaluation declined to treat the conflict as trivial (set when trivial=false). */
411
+ reason?: string;
412
+ /** Per-path detail for the changed gitlinks that were inspected. */
413
+ gitlinks: Array<{
414
+ path: string;
415
+ baseCommit?: string;
416
+ branchCommit?: string;
417
+ fastForward: boolean;
418
+ }>;
419
+ };
420
+ /**
421
+ * Return the changed gitlink paths between base and branch whose advance is a
422
+ * strict fast-forward (the base-side commit is an ancestor of the branch-side
423
+ * commit inside that submodule's repo). These are the paths whose patch-id hunk
424
+ * may legitimately differ when base has advanced the same submodule, so they
425
+ * are safe to exclude from the patch-equivalence comparison. A non-ff (genuinely
426
+ * diverged) gitlink is deliberately excluded from this set so it still fails the
427
+ * gate.
428
+ */
429
+ export declare function collectFastForwardGitlinkPaths(repoRoot: string, baseHead: string, branchHead: string): string[];
430
+ /**
431
+ * Decide whether a merge-tree submodule conflict between base and branch is a
432
+ * trivial gitlink fast-forward (and nothing else).
433
+ *
434
+ * The conflict is treated as trivial ONLY when:
435
+ * 1. at least one changed gitlink exists,
436
+ * 2. every changed gitlink fast-forwards (base-commit is an ancestor of the
437
+ * branch-commit inside that submodule's repo), and
438
+ * 3. the *only* paths that changed on both sides of the merge (i.e. the paths
439
+ * that could possibly produce a 3-way conflict — the intersection of
440
+ * mergeBase→base and mergeBase→branch changes) are gitlinks. Any
441
+ * overlapping non-gitlink path means a genuine content conflict could be
442
+ * hiding behind the submodule failure, so we keep the block.
443
+ *
444
+ * If any of these fail, the conflict is left as a genuine block. This never
445
+ * passes a regular-file conflict or a diverged (non-ff) gitlink.
446
+ */
447
+ export declare function evaluateGitlinkTrivialFastForward(repoRoot: string, baseHead: string, branchHead: string): GitlinkTrivialFastForwardEvaluation;
448
+ export declare function buildMeshRefineValidationPlan(mesh: any, workspace: string): Record<string, unknown>;
449
+ export declare function getMcpServersKey(format: MeshCoordinatorConfigFormat): 'mcpServers' | 'mcp_servers';
450
+ export declare function parseMeshCoordinatorMcpConfig(text: string, format: MeshCoordinatorConfigFormat): Record<string, any>;
451
+ export declare function serializeMeshCoordinatorMcpConfig(config: Record<string, any>, format: MeshCoordinatorConfigFormat): string;
452
+ export declare function loadHermesCoordinatorBaseConfig(targetConfigPath: string): {
453
+ config: Record<string, any>;
454
+ sourceHome: string;
455
+ sourceConfigPath: string;
456
+ };
457
+ export declare function stripHermesCoordinatorTempModelProviderOverrides(config: Record<string, any>): Record<string, any>;
458
+ export declare function copyHermesCoordinatorCredentialFiles(sourceHome: string, targetHome: string): void;
17
459
  export interface SessionHostControlPlane {
18
460
  getDiagnostics(payload?: {
19
461
  includeSessions?: boolean;
@@ -55,12 +497,14 @@ export interface CommandRouterDeps {
55
497
  value: any[];
56
498
  };
57
499
  sessionRegistry: SessionRegistry;
58
- /** Callback for CDP manager creation after launch_ide */
500
+ /** Callback after CDP manager created (transport-specific extras) */
59
501
  onCdpManagerCreated?: (ideType: string, manager: DaemonCdpManager) => void;
60
502
  /** Callback after IDE connected (e.g., startAgentStreamPolling) */
61
503
  onIdeConnected?: () => void;
62
504
  /** Callback after status change (stop_ide, restart) */
63
505
  onStatusChange?: () => void;
506
+ /** Callback when a mesh state is invalidated */
507
+ onMeshStateChange?: (meshId: string) => void;
64
508
  /** Callback after chat-related commands */
65
509
  onPostChatCommand?: () => void;
66
510
  /** Get a connected CDP manager (for agent stream reset check) */
@@ -81,26 +525,138 @@ export interface CommandRouterResult {
81
525
  success: boolean;
82
526
  [key: string]: unknown;
83
527
  }
528
+ /**
529
+ * Confine a spec path to ~/.adhdev/providers, defeating both prefix-bypass
530
+ * (e.g. ".../providers-evil") and symlink escape. Resolves the real path of
531
+ * the *parent* directory (the file may not exist yet for writes), requires the
532
+ * basename to be a literal `*.json`, and re-joins under the verified parent so
533
+ * the returned path can't point outside the tree. Used by get/write_spec_source.
534
+ */
535
+ export declare function normalizeStandaloneHostCommandUrl(hostAddress: string): string;
536
+ export declare function buildMemberJoinNode(mesh: any, args: any, fallbackDaemonId?: string): Record<string, unknown> | null;
84
537
  export declare class DaemonCommandRouter {
85
538
  private deps;
86
539
  /** In-memory cache for cloud-originating meshes passed via inlineMesh.
87
540
  * Allows the MCP server to query mesh data via get_mesh even when
88
541
  * the mesh doesn't exist in the local meshes.json file. */
89
542
  private inlineMeshCache;
543
+ /** Tombstones for inline mesh nodes removed via remove_mesh_node, keyed by
544
+ * meshId → set of removed nodeIds. The dashboard keeps echoing the removed
545
+ * node in the inlineMesh it attaches to every command; without a tombstone,
546
+ * reconcileInlineMeshCache MERGEs it straight back (resurrection). A
547
+ * tombstoned node is skipped during reconcile only while its workspace is
548
+ * absent from disk — a genuine re-registration (same nodeId, workspace back
549
+ * on disk) clears the tombstone and merges normally, preserving clone
550
+ * worktree visibility and legitimate node re-creation. */
551
+ private removedInlineMeshNodeIds;
552
+ /** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default. */
553
+ private aggregateMeshStatusCache;
554
+ /** Shared per-peer git_status probe dedup + recently-probed reuse gate.
555
+ * Spans separate mesh_status/get_mesh calls so the dashboard auto-retry
556
+ * loop cannot storm a slow peer with back-to-back refreshUpstream probes. */
557
+ private meshGitProbeCache;
558
+ /** In-memory async Refinery jobs keyed by meshId:nodeId to reject/return duplicate in-flight requests. */
559
+ private runningRefineJobs;
560
+ /** Terminal async Refinery jobs preserve a clear answer after the worktree node has been removed. */
561
+ private terminalRefineJobs;
562
+ /** In-memory async batch Refinery jobs keyed by meshId (one batch convergence per mesh at a time). */
563
+ private runningRefineBatchJobs;
564
+ /** Terminal async batch Refinery jobs preserve the last batch outcome for late readers. */
565
+ private terminalRefineBatchJobs;
90
566
  constructor(deps: CommandRouterDeps);
567
+ private cloneJsonValue;
568
+ private hydrateCachedAggregateMeshStatusFromInline;
569
+ private getCachedAggregateMeshStatus;
570
+ private rememberAggregateMeshStatus;
571
+ getCachedInlineMeshNodes(): any[];
572
+ /**
573
+ * Resolve the REMOTE worker daemonId that owns a given session, when the session
574
+ * belongs to a mesh node hosted on a DIFFERENT daemon than this coordinator.
575
+ *
576
+ * The coordinator does not host remote-worker session instances in its own
577
+ * instanceManager/sessionRegistry — only their cached mesh-node metadata. A
578
+ * dashboard-issued session-scoped command (invoke_provider_script / resolve_action /
579
+ * set_mode / …) lands on the coordinator with a targetSessionId the coordinator can't
580
+ * find locally, and without forwarding it dies as "Live session not found". send_chat
581
+ * happens to survive (its target resolves to the worker by another route), but the
582
+ * controlbar commands do not — so the controlbar buttons appear to do nothing.
583
+ *
584
+ * Mirror the existing node-level remote-forward pattern (fast_forward_mesh_node etc.):
585
+ * scan the candidate mesh nodes for the one hosting the targetSessionId, and return its
586
+ * daemonId when that daemonId is a remote daemon (i.e. not this coordinator's own
587
+ * statusInstanceId). Returns undefined for a locally-hosted session (no forward — execute
588
+ * locally as before) or when ownership can't be resolved.
589
+ *
590
+ * The candidate set spans BOTH the cached inline-mesh nodes and the live aggregate
591
+ * mesh-status snapshots. The inline cache reliably carries only each node's single primary
592
+ * session (cachedStatus.activeSession), so a worker hosting more than one session exposes its
593
+ * non-primary sessions only on the aggregate snapshot nodes (status.activeSessions /
594
+ * activeSessionDetails, built from live session records). collectMeshNodeHostedSessionIds does
595
+ * the wider plural-shape scan so a controlbar/modal command targeting a non-primary remote
596
+ * session still resolves its owner — the singular readCachedInlineMeshActiveSessions semantics
597
+ * other consumers depend on stay untouched.
598
+ */
599
+ resolveRemoteMeshSessionOwnerDaemonId(sessionId: string): string | undefined;
600
+ /**
601
+ * Candidate nodes for remote-session owner resolution: the cached inline-mesh nodes (which
602
+ * carry each node's primary session) plus the nodes from every cached aggregate mesh-status
603
+ * snapshot (which carry each node's full live session list). getCachedInlineMeshNodes()
604
+ * returns a fresh array, so appending the aggregate nodes never mutates cached state.
605
+ */
606
+ private collectMeshSessionOwnerCandidateNodes;
91
607
  getCachedInlineMesh(meshId: string, inlineMesh?: unknown): any | undefined;
92
608
  private warmInlineMeshCache;
93
609
  private getMeshForCommand;
610
+ private invalidateAggregateMeshStatus;
611
+ /**
612
+ * Build the MedFamilyContext handed to RF-ROUTER MED family handlers. Binds the
613
+ * router-private collaborators those handlers need (mesh resolution, owner
614
+ * gating, inline-cache mutation, worktree / session cleanup, refine job
615
+ * starters, IDE stop/launch) plus the inline-mesh and git-probe caches. The
616
+ * `launchIde` field closes over the freshly-built context so restart_session /
617
+ * restart_ide invoke the IDE launch directly instead of recursing through
618
+ * executeDaemonCommand('launch_ide').
619
+ */
620
+ private buildMedFamilyContext;
621
+ /**
622
+ * Build the HighFamilyContext handed to RF-ROUTER HIGH family handlers. Binds
623
+ * the router-private collaborators those handlers need (mesh resolution, the
624
+ * aggregate-status memory cache + its bound read/write helpers, the
625
+ * running-refine-job table, inline-mesh + git-probe caches, and the router's
626
+ * own `execute` for the get_mesh_review_inbox mesh_status re-entry). HIGH
627
+ * handlers reach more router-owned state than MED, but the binding shape is
628
+ * the same: bound methods + direct field references, none reachable from
629
+ * `deps`.
630
+ */
631
+ private buildHighFamilyContext;
632
+ private requireMeshHostMutationOwner;
94
633
  private updateInlineMeshNode;
95
634
  private removeInlineMeshNode;
635
+ private tombstoneRemovedInlineMeshNode;
636
+ /** Filter an incoming inline mesh against this mesh's tombstones before it is
637
+ * reconciled into the cache. A tombstoned node is dropped only while its
638
+ * workspace is still absent from disk; if the workspace is back (genuine
639
+ * re-registration), the tombstone is cleared and the node merges normally. */
640
+ private applyInlineMeshNodeTombstones;
96
641
  private normalizeMeshSessionCleanupMode;
97
642
  private sessionMatchesMeshNode;
643
+ /**
644
+ * Best-effort recursive removal of a managed worktree directory.
645
+ *
646
+ * The git-registry de-registration is the safety-critical step of worktree
647
+ * teardown; a leftover directory must never gate dropping the node from the
648
+ * mesh. On Windows, `fs.rmSync` can throw EINVAL/EPERM/EBUSY on submodule
649
+ * gitlink (`.git`) files, long paths, junctions, or while a just-stopped
650
+ * delegate session is still releasing a handle/cwd on the directory. This
651
+ * helper absorbs those errors (never throws), with bounded retries + backoff
652
+ * to give handles time to release, and reports whether residue remains.
653
+ */
654
+ private bestEffortRemoveWorktreeDir;
98
655
  private cleanupLocalWorktreeNode;
99
656
  private getWorktreeForceCleanupConvergence;
100
657
  private isCompletedHostedSession;
101
658
  private recordIntentionalMeshSessionStop;
102
659
  private cleanupMeshSessions;
103
- private traceSessionHostAction;
104
660
  /**
105
661
  * Unified command routing.
106
662
  * Returns result for all commands:
@@ -113,6 +669,114 @@ export declare class DaemonCommandRouter {
113
669
  * @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
114
670
  */
115
671
  execute(cmd: string, args: any, source?: string): Promise<CommandRouterResult>;
672
+ private buildRefineJobKey;
673
+ private buildRefineJobHandle;
674
+ private queueRefineJobEvent;
675
+ private appendRefineJobLedger;
676
+ /**
677
+ * On daemon restart, scan all mesh ledgers for refine jobs that were dispatched
678
+ * but never completed/failed (i.e. the daemon died mid-job). Re-queue each one
679
+ * so the job runs to completion automatically without coordinator intervention.
680
+ */
681
+ resumePendingRefineJobsOnStartup(): Promise<void>;
682
+ /**
683
+ * Synchronous refinery for a single worktree node — the gate pipeline that
684
+ * validates, preflights (patch-equivalence / submodule-reachability /
685
+ * no-op), merges, aligns submodules, cleans up the worktree node and
686
+ * (optionally) pushes. The body is a flat sequence of stage methods; each
687
+ * stage either returns a terminal CommandRouterResult (gate failure or a
688
+ * successful already-merged short-circuit) or `continue` with the extended
689
+ * context. Behavior — stage order, every early-exit, and every result shape —
690
+ * is identical to the previous single inlined body.
691
+ */
692
+ private executeMeshRefineNodeSynchronously;
693
+ /**
694
+ * resolve_refs stage: resolve the mesh / worktree node / source node /
695
+ * repoRoot, then the worktree branch, base branch, fetched base head and
696
+ * branch head. Seeds the RefineContext consumed by every later stage.
697
+ */
698
+ private refineResolveRefsStage;
699
+ /**
700
+ * validation stage: run the refinery validation gate (typecheck / test /
701
+ * lint / build per node config) and block on failure or when no allowlisted
702
+ * command was available. On pass, stores the summary on the context.
703
+ */
704
+ private refineValidationStage;
705
+ /**
706
+ * patch_equivalence stage: preflight that the worktree branch's cumulative
707
+ * patch is equivalent to base+branch. On a "behind base" branch, auto-rebase
708
+ * once and re-check; on an empty merge-tree with real branch changes, treat as
709
+ * already-merged-via-another-path and short-circuit to cleanup. Mutates the
710
+ * context's branchHead (after rebase) and patchEquivalence (rebased gate).
711
+ */
712
+ private refinePatchEquivalenceStage;
713
+ /**
714
+ * submodule_reachability stage: verify every submodule gitlink commit that
715
+ * would land via the merge is reachable from its configured remote main
716
+ * branch (optionally auto-publishing when policy allows). Blocks the merge
717
+ * when any commit is unreachable. Stores the result on the context.
718
+ */
719
+ private refineSubmoduleReachabilityStage;
720
+ /**
721
+ * effective_diff stage (no-op guard): block a silent no-op merge where the
722
+ * branch produces no effective root-tree diff against base — typically a
723
+ * submodule that has commits but whose root-level gitlink (pointer) bump was
724
+ * never committed, so the merge would land nothing real on main.
725
+ */
726
+ private refineEffectiveDiffStage;
727
+ /**
728
+ * merge + finalize stage: perform the --no-ff merge, align submodule
729
+ * checkouts after merge, clean up (remove) the worktree node per policy,
730
+ * append the refinery ledger entry, and (unless approval is required) push the
731
+ * base branch. Always terminal — produces the final CommandRouterResult.
732
+ */
733
+ private refineMergeAndFinalizeStage;
734
+ /**
735
+ * Batch refinery: converge multiple sibling worktree nodes onto the base branch
736
+ * in one sequential pipeline, absorbing the rebase + patch-equivalence churn that
737
+ * arises when several siblings touch the same submodule.
738
+ *
739
+ * Reuses executeMeshRefineNodeSynchronously per node — every node goes through the
740
+ * exact same validation / patch-equivalence / submodule-reachability / merge / cleanup
741
+ * gates, including its built-in auto-rebase onto fresh origin/<base>. Because each
742
+ * node fetches origin/<base> at the start of its own refine, a node merged earlier in
743
+ * the batch advances the base, and the next node's refine auto-rebases onto it before
744
+ * re-running patch-equivalence. No force-push, no reset — conflicting nodes are
745
+ * isolated as blocked_review while the rest of the batch proceeds.
746
+ */
747
+ private batchRefineMeshNodes;
748
+ /**
749
+ * Convergence core shared by the synchronous batch entry and the async batch job.
750
+ * Refines each node in order: the per-node refine pipeline fetches origin/<base>
751
+ * fresh, so each merged sibling advances the base before the next node's auto-rebase
752
+ * + patch-equivalence re-check. A blocked/failed node is isolated; the batch
753
+ * continues with the remaining nodes. Does NOT touch the per-node merge logic — it
754
+ * only sequences calls to executeMeshRefineNodeSynchronously and aggregates outcomes.
755
+ */
756
+ private runMeshRefineBatchConvergence;
757
+ private buildRefineBatchJobKey;
758
+ private buildRefineBatchJobHandle;
759
+ /**
760
+ * Emit a batch Refinery terminal/accepted event through the SAME pending-event +
761
+ * forward mechanism single-node refine uses (queueRefineJobEvent), so the
762
+ * coordinator's existing refine:accepted/completed/failed handling and message
763
+ * renderer apply unchanged. The aggregate per-node results ride along in `result`.
764
+ */
765
+ private queueRefineBatchJobEvent;
766
+ private appendRefineBatchJobLedger;
767
+ private finishMeshRefineBatchJob;
768
+ /**
769
+ * Async entry for the batch Refinery execute path. Mirrors startMeshRefineJob:
770
+ * resolves the plan synchronously (so target/ordering errors and the dry-run shape
771
+ * stay synchronous), then for execute=true registers an in-flight batch job, returns
772
+ * {async:true, status:'accepted', batch:true, ...plan} immediately, and runs the
773
+ * convergence loop in the background — emitting the same terminal refine event.
774
+ * Idempotent: a batch already in flight for this mesh returns the running handle
775
+ * with duplicate:true rather than spawning a second background job.
776
+ */
777
+ private startMeshRefineBatchJob;
778
+ private finishMeshRefineJob;
779
+ private startMeshRefineJob;
116
780
  /**
117
781
  * Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
118
782
  * Returns null if not handled at this level → caller delegates to CommandHandler.