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

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 +50679 -20122
  75. package/dist/index.js.map +1 -1
  76. package/dist/index.mjs +47546 -17153
  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 +2327 -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
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Change-area analysis for one worktree node, used to order sibling nodes for
3
+ * batch refinement so that nodes least likely to conflict merge first.
4
+ *
5
+ * The heuristic is deliberately git-only and side-effect-free: it inspects the
6
+ * commits the node's branch adds on top of the base (`base..branch`) and records
7
+ * - whether any submodule gitlink path is touched (high-conflict signal: the
8
+ * batch must rebase later siblings onto the advanced submodule main), and
9
+ * - the set of changed top-level paths (so siblings touching disjoint trees can
10
+ * be ordered ahead of ones that overlap).
11
+ */
12
+ export interface MeshRefineBatchNodeChangeArea {
13
+ nodeId: string;
14
+ workspace: string;
15
+ branch: string;
16
+ /** Top-level path segments changed by the branch vs. base (e.g. 'oss', 'packages'). */
17
+ changedTopLevelPaths: string[];
18
+ /** Full changed file list (bounded) for overlap detection. */
19
+ changedFiles: string[];
20
+ /** Submodule gitlink paths touched by the branch (subset of changedTopLevelPaths). */
21
+ touchedSubmodulePaths: string[];
22
+ /** True when the branch touches at least one submodule gitlink. */
23
+ touchesSubmodule: boolean;
24
+ /** Number of commits the branch is ahead of base; 0 means nothing to merge. */
25
+ aheadCount: number;
26
+ /** Non-fatal analysis error (e.g. base/branch unresolved); ordering falls back to neutral. */
27
+ error?: string;
28
+ }
29
+ export interface MeshRefineBatchOrderingResult {
30
+ /** Node IDs in the order they should be refined. */
31
+ order: string[];
32
+ /** Per-node change areas, keyed by node id, for plan transparency. */
33
+ changeAreas: Record<string, MeshRefineBatchNodeChangeArea>;
34
+ /** Human-readable explanation of why the order was chosen. */
35
+ rationale: string[];
36
+ }
37
+ /**
38
+ * Analyze one worktree node's change area against its merge base.
39
+ *
40
+ * @param baseRef ref that the node will merge into (e.g. 'origin/main' or a SHA)
41
+ * @param branchRef the node's branch tip
42
+ * @param diffCwd repo to run the diff in (the worktree itself is authoritative for
43
+ * `branch` resolution, but the diff `base..branch` is symmetric, so
44
+ * the worktree cwd works for both refs once base is a reachable SHA).
45
+ */
46
+ export declare function analyzeMeshRefineNodeChangeArea(args: {
47
+ nodeId: string;
48
+ workspace: string;
49
+ branch: string;
50
+ baseRef: string;
51
+ branchRef: string;
52
+ diffCwd: string;
53
+ submodulePaths: Set<string>;
54
+ }): Promise<MeshRefineBatchNodeChangeArea>;
55
+ /**
56
+ * Order nodes for batch refinement to minimize cross-sibling conflicts.
57
+ *
58
+ * Heuristic (deterministic, stable):
59
+ * 1. Nodes that do NOT touch any submodule come first — they cannot advance the
60
+ * submodule main, so they never force a later submodule rebase.
61
+ * 2. Within each group, fewer touched top-level paths first (smaller blast radius).
62
+ * 3. Tie-break by node id for determinism.
63
+ *
64
+ * Submodule-touching siblings are intrinsically serial: each one that merges
65
+ * advances oss main, so the next must rebase. Ordering them last keeps the
66
+ * non-submodule merges (which never need a submodule rebase) clean and up front.
67
+ */
68
+ export declare function orderMeshRefineBatchNodes(changeAreas: MeshRefineBatchNodeChangeArea[]): MeshRefineBatchOrderingResult;
@@ -0,0 +1,428 @@
1
+ /**
2
+ * Mesh refine validation gates & gitlink fast-forward evaluation
3
+ *
4
+ * Extracted from commands/router.ts (behavior-preserving move). Contains:
5
+ * - the MeshCoordinator config-format type
6
+ * - refine validation / patch-equivalence / effective-diff / submodule
7
+ * reachability gates and their summary types + job handles
8
+ * - gitlink trivial-fast-forward evaluation and submodule alignment helpers
9
+ *
10
+ * router.ts re-exports every public symbol from here so existing import paths
11
+ * keep working. `CommandRouterResult` is imported type-only from router.ts
12
+ * (erased at compile time — no runtime import cycle).
13
+ */
14
+ import type { WorktreeBootstrapState } from '../mesh/worktree-bootstrap-config.js';
15
+ import type { CommandRouterResult } from '../commands/router.js';
16
+ export type MeshCoordinatorConfigFormat = 'claude_mcp_json' | 'hermes_config_yaml';
17
+ type MeshRefineValidationStatus = 'passed' | 'failed' | 'skipped';
18
+ type MeshRefineValidationSummary = {
19
+ status: MeshRefineValidationStatus;
20
+ required: true;
21
+ commandsRun: Array<Record<string, unknown>>;
22
+ bootstrapCommandsRun: Array<Record<string, unknown>>;
23
+ rejectedCommands: Array<Record<string, unknown>>;
24
+ skippedReason?: string;
25
+ failureKind?: string;
26
+ failureCode?: string;
27
+ /** Human-readable cause when failureKind === 'spawn_resolution_failed' (win32 .cmd shim, etc). */
28
+ spawnResolutionError?: string;
29
+ timeoutMs: number;
30
+ outputLimitBytes: number;
31
+ configSource?: string;
32
+ configSourceType?: string;
33
+ suggestions?: unknown[];
34
+ suggestedConfig?: unknown;
35
+ /**
36
+ * M2-3: the bootstrap stage recorded separately from validation so review
37
+ * surfaces can distinguish environment failures from validation failures.
38
+ * cached — worktree_bootstrap was 'ready' (staleInputs unchanged), skipped
39
+ * ran — worktree_bootstrap was stale/never-ran and re-ran successfully
40
+ * failed — bootstrap run failed (refine stops before validation)
41
+ * skipped — refine config validation.bootstrap === 'skip'
42
+ * legacy — deprecated validation.bootstrapCommands path was used
43
+ * not_configured — no bootstrap definition anywhere
44
+ */
45
+ bootstrap?: {
46
+ stage: 'cached' | 'ran' | 'failed' | 'skipped' | 'legacy' | 'not_configured';
47
+ status?: string;
48
+ skipped?: boolean;
49
+ configSource?: string;
50
+ staleReason?: string;
51
+ error?: string;
52
+ commandsRun?: Array<Record<string, unknown>>;
53
+ };
54
+ /** M2-2: deprecation notices from the refine config (e.g. bootstrapCommands). */
55
+ deprecationWarnings?: string[];
56
+ };
57
+ type MeshRefineStageStatus = 'passed' | 'failed' | 'skipped';
58
+ type MeshRefinePatchEquivalenceSummary = {
59
+ status: MeshRefineStageStatus;
60
+ equivalent: boolean;
61
+ baseHead: string;
62
+ branchHead: string;
63
+ mergeBase?: string;
64
+ mergedTree?: string;
65
+ expectedPatchId?: string;
66
+ actualPatchId?: string;
67
+ durationMs: number;
68
+ error?: string;
69
+ stdout?: string;
70
+ stderr?: string;
71
+ actionableHint?: MeshRefineSubmoduleConflictHint;
72
+ /**
73
+ * Set when a `merge-tree` submodule conflict was reclassified as a trivial
74
+ * gitlink fast-forward and the gate passed via a synthesized merge tree.
75
+ */
76
+ gitlinkTrivialFastForward?: {
77
+ resolved: boolean;
78
+ gitlinks: Array<{
79
+ path: string;
80
+ baseCommit?: string;
81
+ branchCommit?: string;
82
+ fastForward: boolean;
83
+ }>;
84
+ reason?: string;
85
+ };
86
+ };
87
+ type MeshRefineEffectiveDiffSummary = {
88
+ status: MeshRefineStageStatus;
89
+ /** True when there is at least one root-tree change between base and branch (incl. gitlink bumps). */
90
+ hasEffectiveDiff: boolean;
91
+ baseHead: string;
92
+ branchHead: string;
93
+ /** Root-level paths that differ between base and branch (capped). */
94
+ changedPaths?: string[];
95
+ /** Submodule paths with uncommitted/divergent commits but NO committed gitlink bump in the root tree. */
96
+ submoduleHints?: Array<{
97
+ path: string;
98
+ reason: string;
99
+ }>;
100
+ durationMs: number;
101
+ error?: string;
102
+ stdout?: string;
103
+ stderr?: string;
104
+ };
105
+ type MeshRefineSubmoduleConflictHint = {
106
+ kind: 'submodule_conflict';
107
+ message: string;
108
+ conflicts: Array<{
109
+ path: string;
110
+ baseCommit?: string;
111
+ branchCommit?: string;
112
+ }>;
113
+ nextSteps: string[];
114
+ };
115
+ type MeshRefineSubmoduleAlignmentSummary = {
116
+ status: 'passed' | 'failed' | 'skipped';
117
+ changedGitlinkPaths: string[];
118
+ outOfSyncPaths: string[];
119
+ updatedPaths: string[];
120
+ verifiedPaths: string[];
121
+ durationMs: number;
122
+ reason?: string;
123
+ command?: string;
124
+ error?: string;
125
+ stdout?: string;
126
+ stderr?: string;
127
+ };
128
+ type MeshRefineSubmoduleReachabilityEntry = {
129
+ path: string;
130
+ commit: string;
131
+ reachable: boolean;
132
+ publishRequired?: boolean;
133
+ autoPublishAllowed?: boolean;
134
+ autoPublishAttempted?: boolean;
135
+ autoPublishSucceeded?: boolean;
136
+ autoPublishVerified?: boolean;
137
+ autoPublishRefspec?: string;
138
+ autoPublishSkippedReason?: string;
139
+ importedFromWorktree?: boolean;
140
+ checkedLocal?: boolean;
141
+ localReachable?: boolean;
142
+ remote?: string;
143
+ remoteUrl?: string;
144
+ remoteReachable?: boolean;
145
+ remoteMainBranch?: string;
146
+ remoteMainReachable?: boolean;
147
+ fetchedFromOrigin?: boolean;
148
+ error?: string;
149
+ publishStdout?: string;
150
+ publishStderr?: string;
151
+ };
152
+ type MeshRefineSubmoduleReachabilitySummary = {
153
+ status: MeshRefineStageStatus;
154
+ checked: number;
155
+ unreachable: MeshRefineSubmoduleReachabilityEntry[];
156
+ entries: MeshRefineSubmoduleReachabilityEntry[];
157
+ durationMs: number;
158
+ autoPublishAllowed?: boolean;
159
+ autoPublishPolicySource?: string;
160
+ error?: string;
161
+ };
162
+ export type MeshRefineAsyncJobStatus = 'accepted' | 'completed' | 'failed';
163
+ export type MeshRefineJobHandle = {
164
+ success: true;
165
+ async: true;
166
+ status: MeshRefineAsyncJobStatus;
167
+ jobId: string;
168
+ interactionId: string;
169
+ meshId: string;
170
+ nodeId: string;
171
+ targetNodeId: string;
172
+ targetDaemonId?: string;
173
+ workspace?: string;
174
+ startedAt: string;
175
+ completedAt?: string;
176
+ duplicate?: boolean;
177
+ retryOfJobId?: string;
178
+ /**
179
+ * The coordinator daemon ID that initiated this refine job.
180
+ * When set, events for this job are scoped to that coordinator's
181
+ * pending-events queue instead of the shared broadcast queue.
182
+ */
183
+ targetCoordinatorDaemonId?: string;
184
+ eventDelivery: {
185
+ pendingEvents: true;
186
+ ledger: true;
187
+ };
188
+ evidence: {
189
+ pendingEventsCommand: 'get_pending_mesh_events';
190
+ ledgerCommand: 'get_mesh_ledger_slice';
191
+ taskHistoryKind: 'task_dispatched' | 'task_completed' | 'task_failed';
192
+ };
193
+ };
194
+ export type MeshRefineTerminalJob = MeshRefineJobHandle & {
195
+ result?: Record<string, unknown>;
196
+ };
197
+ export type MeshRefineBatchJobStatus = 'accepted' | 'completed' | 'failed';
198
+ /**
199
+ * Async handle returned by the batch Refinery the instant a convergence run is
200
+ * accepted. Mirrors {@link MeshRefineJobHandle} (async:true / status:'accepted' +
201
+ * terminal pending-event + ledger delivery) but scopes a whole batch of sibling
202
+ * nodes rather than a single node. The synthetic `batchLabel` is used as the
203
+ * `nodeLabel` for the shared refine event/message renderer.
204
+ */
205
+ export type MeshRefineBatchJobHandle = {
206
+ success: true;
207
+ async: true;
208
+ batch: true;
209
+ status: MeshRefineBatchJobStatus;
210
+ jobId: string;
211
+ interactionId: string;
212
+ meshId: string;
213
+ batchLabel: string;
214
+ nodeIds: string[];
215
+ nodeCount: number;
216
+ order: string[];
217
+ startedAt: string;
218
+ completedAt?: string;
219
+ duplicate?: boolean;
220
+ targetCoordinatorDaemonId?: string;
221
+ eventDelivery: {
222
+ pendingEvents: true;
223
+ ledger: true;
224
+ };
225
+ evidence: {
226
+ pendingEventsCommand: 'get_pending_mesh_events';
227
+ ledgerCommand: 'get_mesh_ledger_slice';
228
+ taskHistoryKind: 'task_dispatched' | 'task_completed' | 'task_failed';
229
+ };
230
+ };
231
+ export type MeshRefineBatchTerminalJob = MeshRefineBatchJobHandle & {
232
+ result?: Record<string, unknown>;
233
+ };
234
+ export declare function truncateValidationOutput(value: unknown): string;
235
+ /**
236
+ * A spawn-resolution failure is when the executable itself could not be found by
237
+ * the OS spawn boundary — `spawn <cmd> ENOENT` — as opposed to the command
238
+ * running and exiting non-zero. On win32 this is the .cmd-shim case: libuv's
239
+ * spawn search appends only .com/.exe, so a bare `npm`/`npx`/`tsc` (which are
240
+ * .cmd shims) ENOENTs even though it is installed. It carries no stderr, so it
241
+ * must be detected by error.code/syscall, not by string-matching output.
242
+ */
243
+ export declare function isSpawnResolutionError(error: any): boolean;
244
+ export declare function describeSpawnError(error: any, command: string, spawnResolutionFailed: boolean): string;
245
+ export declare function recordMeshRefineStage(stages: Array<Record<string, unknown>>, stage: string, status: MeshRefineStageStatus, startedAt: number, details?: Record<string, unknown>): void;
246
+ export declare function buildSubmodulePublishRequiredNextStep(entries: MeshRefineSubmoduleReachabilityEntry[]): string;
247
+ /**
248
+ * Async git exec helper used across the synchronous-refine stage pipeline. Bound
249
+ * once in the orchestrator and threaded through RefineContext so every stage runs
250
+ * git the same way (execFile + promisify, utf8). Returns the child's stdout/stderr.
251
+ */
252
+ export type RefineExecFileAsync = (file: string, args: string[], options: {
253
+ cwd: string;
254
+ encoding: 'utf8';
255
+ }) => Promise<{
256
+ stdout: string;
257
+ stderr: string;
258
+ }>;
259
+ /**
260
+ * Accumulated state shared by the synchronous-refine stages. The orchestrator
261
+ * (executeMeshRefineNodeSynchronously) seeds this in the resolve_refs stage and
262
+ * each later stage reads / extends it. `branchHead` and `patchEquivalence` are the
263
+ * only fields a stage mutates after creation (auto-rebase updates both), so they
264
+ * are carried on the mutable context rather than re-threaded through return types.
265
+ */
266
+ export interface RefineContext {
267
+ meshId: string;
268
+ nodeId: string;
269
+ args: any;
270
+ refineStages: Array<Record<string, unknown>>;
271
+ execFileAsync: RefineExecFileAsync;
272
+ mesh: any;
273
+ node: any;
274
+ sourceNode: any;
275
+ repoRoot: string;
276
+ branch: string;
277
+ baseBranch: string;
278
+ baseHead: string;
279
+ branchHead: string;
280
+ validationSummary: Awaited<ReturnType<typeof runMeshRefineValidationGate>>;
281
+ patchEquivalence: Awaited<ReturnType<typeof runMeshRefinePatchEquivalenceGate>>;
282
+ submoduleReachability: Awaited<ReturnType<typeof runMeshRefineSubmoduleReachabilityGate>>;
283
+ }
284
+ /**
285
+ * Stage outcome for the synchronous-refine pipeline. A stage either produces a
286
+ * terminal CommandRouterResult (an early-exit gate failure, or a successful
287
+ * already-merged short-circuit), in which case the orchestrator returns it
288
+ * immediately, or it returns `continue` with the (possibly extended) context for
289
+ * the next stage. This makes the orchestrator a flat sequence of stage calls
290
+ * while preserving the original body's exact early-return control flow.
291
+ */
292
+ export type RefineStageOutcome = {
293
+ kind: 'terminal';
294
+ result: CommandRouterResult;
295
+ } | {
296
+ kind: 'continue';
297
+ ctx: RefineContext;
298
+ };
299
+ export declare function resolveRefineryAutoPublishSubmoduleMainCommits(mesh: any, workspace: string): {
300
+ enabled: boolean;
301
+ source?: string;
302
+ };
303
+ export declare function runMeshRefinePatchEquivalenceGate(repoRoot: string, baseHead: string, branchHead: string): Promise<MeshRefinePatchEquivalenceSummary>;
304
+ export type MeshWorktreePatchContainmentSummary = {
305
+ /** True only when merging worktreeHead into ref introduces no new patch. */
306
+ contained: boolean;
307
+ ref: string;
308
+ worktreeHead: string;
309
+ mergeBase?: string;
310
+ mergedTree?: string;
311
+ /** patch-id of (ref -> synthesized merge tree); empty string when nothing new is added. */
312
+ residualPatchId?: string;
313
+ durationMs: number;
314
+ /** Set when the check could not run (treated conservatively as NOT contained). */
315
+ error?: string;
316
+ };
317
+ /**
318
+ * Patch-equivalence containment check for the worktree force-cleanup convergence
319
+ * guard. Answers a narrower question than {@link runMeshRefinePatchEquivalenceGate}:
320
+ * "are the worktree branch's changes ALREADY present in `ref` (e.g. origin/main),
321
+ * even though the worktree HEAD's commit SHA is not an ancestor of ref?"
322
+ *
323
+ * This is the cherry-pick / squash / rebase case: the same content landed on the
324
+ * default ref under a different commit SHA, so `merge-base --is-ancestor` (the
325
+ * primary cleanup guard) reports the worktree as un-converged and refuses to
326
+ * remove it. Refinery already accepts patch-equivalent landings via merge-tree +
327
+ * patch-id; this brings the same notion of "convergence" to the cleanup guard.
328
+ *
329
+ * Mechanism: synthesize the merge of `worktreeHead` into `ref` (reusing the same
330
+ * trivial-gitlink-fast-forward handling as the refine gate) and compute the
331
+ * patch-id of (ref -> mergedTree). If that residual diff is EMPTY, merging the
332
+ * worktree adds nothing new on top of ref — its changes are already present there
333
+ * and the worktree is safe to remove. A non-empty residual means the worktree
334
+ * still carries content not in ref, so it is NOT contained and must stay blocked.
335
+ *
336
+ * Conservative by construction: any merge-tree / patch-id failure, a genuine
337
+ * (non-trivial) submodule conflict, or any thrown error yields `contained: false`
338
+ * so an exception can never widen the cleanup allow-list.
339
+ */
340
+ export declare function checkWorktreeChangesPatchEquivalentInRef(repoRoot: string, ref: string, worktreeHead: string): Promise<MeshWorktreePatchContainmentSummary>;
341
+ /**
342
+ * No-op guard: detect a "silent no-op" merge before the Refinery merge runs.
343
+ *
344
+ * A silent no-op occurs when the refine target branch's ROOT tree is byte-identical
345
+ * to the merge base (origin/main). This is the trap where a submodule (e.g. oss) has
346
+ * real commits but the root branch never committed the gitlink (oss-pointer) bump, so
347
+ * the root diff Refinery would merge is empty. Merging that produces a merge commit with
348
+ * no content change — reported as "success" while the actual work never reaches main.
349
+ *
350
+ * A committed gitlink bump (the legitimate oss-pointer bump) DOES show up in the root
351
+ * tree diff (as a 160000-mode entry), so this guard does NOT block legitimate refines —
352
+ * it only fires when the root tree diff vs base is COMPLETELY empty.
353
+ *
354
+ * Runs after the patch-equivalence gate; the "already merged via other path" case
355
+ * (branch has real changes already present in base) is handled upstream and never
356
+ * reaches here, so an empty root diff at this point is genuinely a no-op.
357
+ */
358
+ export declare function runMeshRefineEffectiveDiffGate(repoRoot: string, baseHead: string, branchHead: string): Promise<MeshRefineEffectiveDiffSummary>;
359
+ /**
360
+ * Result of evaluating whether a `git merge-tree --write-tree` submodule
361
+ * conflict is in fact a trivial gitlink fast-forward that should pass the
362
+ * patch-equivalence gate.
363
+ *
364
+ * `git merge-tree` (and `git merge` with the default recursive strategy)
365
+ * refuses to 3-way merge gitlinks unless the case is "trivial" — and it
366
+ * treats *any* gitlink that differs across merge-base/base/branch as
367
+ * non-trivial, even when the branch-side commit is a strict descendant of the
368
+ * base-side commit (i.e. a real fast-forward). Refinery only ever wants to
369
+ * accept the branch's recorded gitlink, so a fast-forwardable bump is safe to
370
+ * resolve to the branch side without any conflict.
371
+ */
372
+ type GitlinkTrivialFastForwardEvaluation = {
373
+ /** True only when the merge-tree conflict is *fully* explained by trivial-ff gitlinks. */
374
+ trivial: boolean;
375
+ /** Why the evaluation declined to treat the conflict as trivial (set when trivial=false). */
376
+ reason?: string;
377
+ /** Per-path detail for the changed gitlinks that were inspected. */
378
+ gitlinks: Array<{
379
+ path: string;
380
+ baseCommit?: string;
381
+ branchCommit?: string;
382
+ fastForward: boolean;
383
+ }>;
384
+ };
385
+ /**
386
+ * Return the changed gitlink paths between base and branch whose advance is a
387
+ * strict fast-forward (the base-side commit is an ancestor of the branch-side
388
+ * commit inside that submodule's repo). These are the paths whose patch-id hunk
389
+ * may legitimately differ when base has advanced the same submodule, so they
390
+ * are safe to exclude from the patch-equivalence comparison. A non-ff (genuinely
391
+ * diverged) gitlink is deliberately excluded from this set so it still fails the
392
+ * gate.
393
+ */
394
+ export declare function collectFastForwardGitlinkPaths(repoRoot: string, baseHead: string, branchHead: string): string[];
395
+ /**
396
+ * Decide whether a merge-tree submodule conflict between base and branch is a
397
+ * trivial gitlink fast-forward (and nothing else).
398
+ *
399
+ * The conflict is treated as trivial ONLY when:
400
+ * 1. at least one changed gitlink exists,
401
+ * 2. every changed gitlink fast-forwards (base-commit is an ancestor of the
402
+ * branch-commit inside that submodule's repo), and
403
+ * 3. the *only* paths that changed on both sides of the merge (i.e. the paths
404
+ * that could possibly produce a 3-way conflict — the intersection of
405
+ * mergeBase→base and mergeBase→branch changes) are gitlinks. Any
406
+ * overlapping non-gitlink path means a genuine content conflict could be
407
+ * hiding behind the submodule failure, so we keep the block.
408
+ *
409
+ * If any of these fail, the conflict is left as a genuine block. This never
410
+ * passes a regular-file conflict or a diverged (non-ff) gitlink.
411
+ */
412
+ export declare function evaluateGitlinkTrivialFastForward(repoRoot: string, baseHead: string, branchHead: string): GitlinkTrivialFastForwardEvaluation;
413
+ export declare function alignRefinerySubmodulesAfterMerge(repoRoot: string, previousBaseHead: string, currentHead: string, options?: {
414
+ submoduleIgnorePaths?: string[];
415
+ }): Promise<MeshRefineSubmoduleAlignmentSummary>;
416
+ export declare function runMeshRefineSubmoduleReachabilityGate(repoRoot: string, mergedTree: string, options?: {
417
+ allowAutoPublishSubmoduleMainCommits?: boolean;
418
+ autoPublishPolicySource?: string;
419
+ worktreeRoot?: string;
420
+ }): Promise<MeshRefineSubmoduleReachabilitySummary>;
421
+ export declare function buildMeshRefineValidationPlan(mesh: any, workspace: string): Record<string, unknown>;
422
+ export declare function runMeshRefineValidationGate(mesh: any, workspace: string, opts?: {
423
+ /** M2-2: persisted node bootstrap state for staleness evaluation. */
424
+ persistedBootstrapState?: WorktreeBootstrapState | null;
425
+ /** M2-2: called after an inherit-mode bootstrap run so the caller can persist the new state. */
426
+ onBootstrapStateChange?: (state: WorktreeBootstrapState) => void;
427
+ }): Promise<MeshRefineValidationSummary>;
428
+ export {};
@@ -0,0 +1,62 @@
1
+ import type { MeshLedgerEntry } from './mesh-ledger.js';
2
+ import type { PendingMeshCoordinatorEvent } from './mesh-events.js';
3
+ import type { MeshAsyncJobLifecycle } from '../repo-mesh-types.js';
4
+ export type MeshAsyncRefineJobStatus = 'accepted' | 'running' | 'completed' | 'failed';
5
+ export interface MeshAsyncRefineJobSummary extends MeshAsyncJobLifecycle {
6
+ jobId: string;
7
+ interactionId?: string;
8
+ status: MeshAsyncRefineJobStatus;
9
+ meshId?: string;
10
+ nodeId?: string;
11
+ targetNodeId?: string;
12
+ targetDaemonId?: string;
13
+ workspace?: string;
14
+ branch?: string;
15
+ into?: string;
16
+ retryOfJobId?: string;
17
+ lastEvent?: string;
18
+ lastLedgerKind?: string;
19
+ lastUpdatedAt?: string;
20
+ instruction: string;
21
+ }
22
+ export declare function buildMeshAsyncRefineJobs(args: {
23
+ meshId?: string;
24
+ ledgerEntries?: MeshLedgerEntry[];
25
+ pendingEvents?: PendingMeshCoordinatorEvent[];
26
+ }): MeshAsyncRefineJobSummary[];
27
+ /** Terminal refine jobs older than this (relative to the newest job in the set) are
28
+ * "stale" — already-resolved historical refinery rejections/successes that should not
29
+ * keep inflating the status counts in mesh_status. 6h covers a long working session
30
+ * while still folding multi-day-old residue. */
31
+ export declare const STALE_TERMINAL_REFINE_WINDOW_MS: number;
32
+ /** Cap on how many recent terminal jobs are counted even if all fall inside the freshness
33
+ * window — prevents a burst of refines from dominating the summary. */
34
+ export declare const RECENT_TERMINAL_REFINE_CAP = 8;
35
+ export interface MeshAsyncRefineJobsSummary {
36
+ /** Count of jobs reflected in `byStatus` (active jobs + recent terminal jobs). */
37
+ total: number;
38
+ byStatus: Record<string, number>;
39
+ /** Terminal jobs dropped from the counts because they are stale residue. */
40
+ staleTerminal: number;
41
+ /** Non-terminal (accepted/running) jobs still in flight. */
42
+ activeJobs: MeshAsyncRefineJobSummary[];
43
+ }
44
+ /**
45
+ * Build a compact summary of refine jobs that folds stale terminal jobs.
46
+ *
47
+ * The full job list (from `buildMeshAsyncRefineJobs`) is derived from a recent ledger
48
+ * window and deduped by jobId, but it still includes every terminal (completed/failed)
49
+ * job that happens to fall in that window — including multi-day-old refinery rejections
50
+ * that have long since been resolved. Those stale terminals inflate `byStatus.failed`
51
+ * and read as "current breakage" when they are historical noise.
52
+ *
53
+ * Active (accepted/running) jobs are always counted. Terminal jobs are counted only when
54
+ * they are recent: within `STALE_TERMINAL_REFINE_WINDOW_MS` of the newest job's activity
55
+ * time AND among the `RECENT_TERMINAL_REFINE_CAP` most-recent terminals. Everything else
56
+ * is folded into `staleTerminal` and excluded from `byStatus`.
57
+ *
58
+ * Freshness is measured relative to the newest job in the set (not wall-clock), so the
59
+ * result is deterministic for a given input — important for tests and for stale-clock
60
+ * environments.
61
+ */
62
+ export declare function summarizeMeshAsyncRefineJobs(jobs: MeshAsyncRefineJobSummary[]): MeshAsyncRefineJobsSummary;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * M4.0: Review inbox — derive review items from existing truth.
3
+ *
4
+ * No new store: review items are a query-time projection of
5
+ * - mesh_status node statuses (daemon-owned branchConvergence), and
6
+ * - the task ledger (completion evidence envelopes + refine job results).
7
+ *
8
+ * Scope (M4.0): host-daemon-local nodes only. Remote nodes are excluded and
9
+ * surfaced via remoteNodesExcluded/excludedRemoteNodeIds until the
10
+ * daemon↔daemon P2P relay path is live-verified (M4.2).
11
+ */
12
+ import type { MeshLedgerEntry } from './mesh-ledger.js';
13
+ export type MeshReviewInboxReason = 'merge_candidate' | 'refine_blocked_review';
14
+ export interface MeshReviewInboxConvergence {
15
+ status: string;
16
+ reason: string | null;
17
+ nextStep: string | null;
18
+ needsConvergence: boolean;
19
+ }
20
+ export interface MeshReviewInboxEvidence {
21
+ available: boolean;
22
+ /** Ledger kind of the entry the evidence came from. */
23
+ kind?: 'task_completed' | 'task_failed';
24
+ /** 'task_completion' = ordinary worker completion envelope; 'refine_job' = Refinery result. */
25
+ source?: 'task_completion' | 'refine_job';
26
+ timestamp?: string;
27
+ taskId?: string;
28
+ sessionId?: string;
29
+ /** M2-3 bootstrap stage from the refine validation gate: cached|ran|failed|skipped|legacy|not_configured. */
30
+ bootstrap?: Record<string, unknown> | null;
31
+ validation?: Record<string, unknown> | null;
32
+ checkpoint?: Record<string, unknown> | null;
33
+ worker?: {
34
+ status: string;
35
+ classification?: string;
36
+ changedFiles: string[];
37
+ changedFilesTruncated?: true;
38
+ validationResults: Array<Record<string, unknown>>;
39
+ errors: string[];
40
+ requiresUserAction: boolean;
41
+ } | null;
42
+ finalBranchConvergenceState?: Record<string, unknown>;
43
+ refineJob?: Record<string, unknown>;
44
+ }
45
+ export interface MeshReviewInboxDiffFile {
46
+ path: string;
47
+ status?: string;
48
+ insertions?: number;
49
+ deletions?: number;
50
+ binary?: boolean;
51
+ oldPath?: string;
52
+ }
53
+ export interface MeshReviewInboxDiffSummary {
54
+ baseRef: string;
55
+ files: MeshReviewInboxDiffFile[];
56
+ totalFiles: number;
57
+ totalInsertions: number;
58
+ totalDeletions: number;
59
+ truncated: boolean;
60
+ error?: string;
61
+ }
62
+ export interface MeshReviewInboxItem {
63
+ nodeId: string;
64
+ workspace: string | null;
65
+ branch: string | null;
66
+ defaultBranch: string | null;
67
+ isLocalWorktree: boolean;
68
+ reviewReason: MeshReviewInboxReason;
69
+ convergence: MeshReviewInboxConvergence;
70
+ evidence: MeshReviewInboxEvidence;
71
+ transcriptHandle: Record<string, unknown> | null;
72
+ /** Latest non-terminal Refinery job for this node (accepted/running), if any. */
73
+ activeRefineJob: Record<string, unknown> | null;
74
+ lastActivityAt: string | null;
75
+ /** Filled by the daemon command with a bounded base-branch diff probe; null when the workspace is not locally readable. */
76
+ diffSummary?: MeshReviewInboxDiffSummary | null;
77
+ }
78
+ export interface MeshReviewInboxDerivation {
79
+ items: MeshReviewInboxItem[];
80
+ remoteNodesExcluded: boolean;
81
+ excludedRemoteNodeIds: string[];
82
+ }
83
+ /**
84
+ * Derive review inbox items from mesh_status node statuses and a bounded
85
+ * ledger tail. Pure and read-only; the caller attaches diffSummary separately.
86
+ */
87
+ export declare function deriveMeshReviewInboxItems(args: {
88
+ nodes: Array<Record<string, unknown>>;
89
+ ledgerEntries: MeshLedgerEntry[];
90
+ }): MeshReviewInboxDerivation;