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

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 (382) 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/types.d.ts +116 -0
  47. package/dist/commands/mesh-coordinator.d.ts +85 -1
  48. package/dist/commands/router.d.ts +666 -2
  49. package/dist/commands/upgrade-helper.d.ts +41 -1
  50. package/dist/config/chat-history.d.ts +9 -0
  51. package/dist/config/config.d.ts +5 -0
  52. package/dist/config/mesh-config.d.ts +77 -1
  53. package/dist/daemon/dev-server.d.ts +0 -2
  54. package/dist/detection/ide-detector.d.ts +13 -0
  55. package/dist/detection/win32-ide-version.d.ts +37 -0
  56. package/dist/git/change-impact-config.d.ts +159 -0
  57. package/dist/git/git-commands.d.ts +11 -1
  58. package/dist/git/git-diff.d.ts +6 -0
  59. package/dist/git/git-executor.d.ts +11 -0
  60. package/dist/git/git-status.d.ts +23 -0
  61. package/dist/git/git-types.d.ts +2 -50
  62. package/dist/git/index.d.ts +2 -0
  63. package/dist/index.d.ts +55 -13
  64. package/dist/index.js +46516 -19739
  65. package/dist/index.js.map +1 -1
  66. package/dist/index.mjs +43516 -16870
  67. package/dist/index.mjs.map +1 -1
  68. package/dist/installer.d.ts +1 -4
  69. package/dist/ipc/local-ipc-server.d.ts +91 -0
  70. package/dist/launch.d.ts +1 -1
  71. package/dist/logging/async-batch-writer.d.ts +10 -0
  72. package/dist/logging/log-redactor.d.ts +24 -0
  73. package/dist/logging/log-tail-reader.d.ts +46 -0
  74. package/dist/logging/logger.d.ts +1 -1
  75. package/dist/mesh/contracts.d.ts +164 -0
  76. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  77. package/dist/mesh/coordinator-registry.d.ts +59 -0
  78. package/dist/mesh/mesh-active-work.d.ts +174 -0
  79. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  80. package/dist/mesh/mesh-event-trace.d.ts +21 -0
  81. package/dist/mesh/mesh-events-coordinator.d.ts +91 -0
  82. package/dist/mesh/mesh-events-pending.d.ts +55 -0
  83. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  84. package/dist/mesh/mesh-events-utils.d.ts +61 -0
  85. package/dist/mesh/mesh-events.d.ts +6 -49
  86. package/dist/mesh/mesh-fast-forward.d.ts +81 -0
  87. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  88. package/dist/mesh/mesh-init.d.ts +86 -0
  89. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  90. package/dist/mesh/mesh-ledger.d.ts +77 -1
  91. package/dist/mesh/mesh-missions.d.ts +164 -0
  92. package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
  93. package/dist/mesh/mesh-refine-batch.d.ts +68 -0
  94. package/dist/mesh/mesh-refine-status.d.ts +62 -0
  95. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  96. package/dist/mesh/mesh-routing.d.ts +70 -0
  97. package/dist/mesh/mesh-runtime-store.d.ts +429 -0
  98. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  99. package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
  100. package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
  101. package/dist/mesh/mesh-work-queue.d.ts +246 -5
  102. package/dist/mesh/preview-freshness.d.ts +18 -0
  103. package/dist/mesh/refine-config.d.ts +216 -0
  104. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  105. package/dist/providers/acp-provider-instance.d.ts +5 -0
  106. package/dist/providers/approval-utils.d.ts +20 -0
  107. package/dist/providers/chat-message-normalization.d.ts +12 -0
  108. package/dist/providers/cli-provider-instance.d.ts +108 -3
  109. package/dist/providers/contracts.d.ts +139 -6
  110. package/dist/providers/external-sources.d.ts +71 -0
  111. package/dist/providers/manual-attendance.d.ts +63 -0
  112. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  113. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  114. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  115. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  116. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  117. package/dist/providers/native-history/index.d.ts +13 -0
  118. package/dist/providers/provider-instance-manager.d.ts +14 -0
  119. package/dist/providers/provider-instance.d.ts +23 -1
  120. package/dist/providers/provider-loader.d.ts +26 -4
  121. package/dist/providers/provider-trust.d.ts +31 -0
  122. package/dist/providers/read-chat-contract.d.ts +29 -0
  123. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  124. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
  125. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  126. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  127. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  128. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  129. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  130. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  131. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  132. package/dist/providers/sdk/v1/index.d.ts +30 -0
  133. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  134. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  135. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  136. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  137. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  138. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  139. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  140. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  141. package/dist/providers/spec/adapter.d.ts +91 -0
  142. package/dist/providers/spec/cli-adapter.d.ts +223 -0
  143. package/dist/providers/spec/evaluator.d.ts +45 -0
  144. package/dist/providers/spec/fsm-driver.d.ts +395 -0
  145. package/dist/providers/spec/fsm-evaluator.d.ts +76 -0
  146. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  147. package/dist/providers/spec/fsm-types.d.ts +174 -0
  148. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  149. package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
  150. package/dist/providers/spec/route.d.ts +4 -0
  151. package/dist/providers/spec/types.d.ts +222 -0
  152. package/dist/providers/status-monitor.d.ts +7 -7
  153. package/dist/providers/transcript-v2.d.ts +176 -0
  154. package/dist/providers/types/interactive-prompt.d.ts +84 -0
  155. package/dist/providers/working-dir.d.ts +17 -0
  156. package/dist/repo-mesh-types.d.ts +295 -13
  157. package/dist/sessions/registry.d.ts +6 -0
  158. package/dist/shared-types-extra.d.ts +2 -4
  159. package/dist/shared-types.d.ts +59 -2
  160. package/dist/status/normalize.d.ts +1 -1
  161. package/dist/status/normalize.js +1 -0
  162. package/dist/status/normalize.js.map +1 -1
  163. package/dist/status/normalize.mjs +1 -0
  164. package/dist/status/normalize.mjs.map +1 -1
  165. package/dist/status/reporter.d.ts +2 -0
  166. package/dist/status/snapshot.d.ts +26 -0
  167. package/dist/system/hash.d.ts +8 -0
  168. package/dist/system/load-better-sqlite3.d.ts +21 -0
  169. package/dist/types.d.ts +5 -0
  170. package/package.json +7 -3
  171. package/src/agent-stream/poller.ts +2 -3
  172. package/src/agent-stream/provider-adapter.ts +1 -1
  173. package/src/boot/daemon-lifecycle.ts +63 -12
  174. package/src/boot/process-hardening.ts +89 -0
  175. package/src/build-info.ts +73 -0
  176. package/src/chat/source-machine.ts +534 -0
  177. package/src/chat/source-resolver.ts +0 -0
  178. package/src/chat/subscription-updates.ts +20 -1
  179. package/src/cli-adapter-types.d.ts +1 -0
  180. package/src/cli-adapter-types.ts +56 -2
  181. package/src/cli-adapters/cli-script-runner.ts +421 -0
  182. package/src/cli-adapters/cli-state-engine.ts +1221 -0
  183. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  184. package/src/cli-adapters/provider-cli-adapter.ts +775 -1141
  185. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  186. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  187. package/src/cli-adapters/provider-cli-runtime.ts +56 -7
  188. package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
  189. package/src/cli-adapters/provider-cli-shared.ts +110 -11
  190. package/src/cli-adapters/pty-transport.ts +2 -1
  191. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  192. package/src/cli-adapters/resolve-executable.ts +90 -0
  193. package/src/cli-adapters/session-host-transport.ts +2 -1
  194. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -29
  195. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  196. package/src/cli-adapters/terminal-screen.ts +16 -81
  197. package/src/commands/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
  198. package/src/commands/chat-commands.ts +1917 -62
  199. package/src/commands/cli-manager.ts +502 -24
  200. package/src/commands/handler.ts +841 -2
  201. package/src/commands/high-family/index.ts +28 -0
  202. package/src/commands/high-family/mesh-coordinator-launch.ts +592 -0
  203. package/src/commands/high-family/mesh-events.ts +47 -0
  204. package/src/commands/high-family/mesh-status.ts +642 -0
  205. package/src/commands/high-family/types.ts +76 -0
  206. package/src/commands/low-family/coordinator-prompt.ts +72 -0
  207. package/src/commands/low-family/daemon-lifecycle.ts +107 -0
  208. package/src/commands/low-family/diagnostics.ts +57 -0
  209. package/src/commands/low-family/index.ts +37 -0
  210. package/src/commands/low-family/mesh-ledger.ts +62 -0
  211. package/src/commands/low-family/mesh-node-logs.ts +81 -0
  212. package/src/commands/low-family/notification.ts +116 -0
  213. package/src/commands/low-family/refine-config.ts +106 -0
  214. package/src/commands/low-family/session-host.ts +274 -0
  215. package/src/commands/low-family/spec-providerdev.ts +217 -0
  216. package/src/commands/low-family/status-meta.ts +112 -0
  217. package/src/commands/low-family/types.ts +39 -0
  218. package/src/commands/med-family/cli-agent.ts +218 -0
  219. package/src/commands/med-family/fast-forward.ts +198 -0
  220. package/src/commands/med-family/ide.ts +163 -0
  221. package/src/commands/med-family/index.ts +35 -0
  222. package/src/commands/med-family/mesh-crud.ts +788 -0
  223. package/src/commands/med-family/mesh-host-pairing.ts +234 -0
  224. package/src/commands/med-family/mesh-queue.ts +131 -0
  225. package/src/commands/med-family/types.ts +120 -0
  226. package/src/commands/mesh-coordinator.ts +334 -124
  227. package/src/commands/router.ts +5121 -2369
  228. package/src/commands/stream-commands.ts +8 -0
  229. package/src/commands/upgrade-helper.ts +310 -45
  230. package/src/config/chat-history.ts +483 -24
  231. package/src/config/config.ts +12 -0
  232. package/src/config/mesh-config.ts +389 -6
  233. package/src/config/recent-activity.ts +8 -2
  234. package/src/daemon/dev-auto-implement.ts +3 -2
  235. package/src/daemon/dev-cli-debug.ts +10 -1
  236. package/src/daemon/dev-server.ts +0 -541
  237. package/src/detection/cli-detector.ts +28 -9
  238. package/src/detection/ide-detector.ts +55 -16
  239. package/src/detection/win32-ide-version.ts +106 -0
  240. package/src/git/change-impact-config.ts +354 -0
  241. package/src/git/git-commands.ts +55 -14
  242. package/src/git/git-diff.ts +81 -11
  243. package/src/git/git-executor.ts +12 -0
  244. package/src/git/git-status.ts +574 -43
  245. package/src/git/git-types.ts +14 -62
  246. package/src/git/git-worktree.ts +8 -1
  247. package/src/git/index.ts +16 -0
  248. package/src/index.ts +158 -12
  249. package/src/installer.d.ts +1 -1
  250. package/src/installer.ts +8 -6
  251. package/src/ipc/local-ipc-server.ts +278 -0
  252. package/src/launch.d.ts +1 -1
  253. package/src/launch.ts +37 -28
  254. package/src/logging/async-batch-writer.ts +55 -0
  255. package/src/logging/command-log.ts +7 -5
  256. package/src/logging/log-redactor.ts +100 -0
  257. package/src/logging/log-tail-reader.ts +220 -0
  258. package/src/logging/logger.ts +14 -7
  259. package/src/mesh/contracts.ts +338 -0
  260. package/src/mesh/coordinator-prompt.ts +234 -31
  261. package/src/mesh/coordinator-registry.ts +121 -0
  262. package/src/mesh/mesh-active-work.ts +645 -0
  263. package/src/mesh/mesh-delivery-policy.ts +315 -0
  264. package/src/mesh/mesh-event-trace.ts +67 -0
  265. package/src/mesh/mesh-events-coordinator.ts +2866 -0
  266. package/src/mesh/mesh-events-pending.ts +599 -0
  267. package/src/mesh/mesh-events-stale.ts +309 -0
  268. package/src/mesh/mesh-events-utils.ts +387 -0
  269. package/src/mesh/mesh-events.ts +30 -1035
  270. package/src/mesh/mesh-fast-forward.ts +839 -0
  271. package/src/mesh/mesh-host-ownership.ts +73 -0
  272. package/src/mesh/mesh-init.ts +260 -0
  273. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  274. package/src/mesh/mesh-ledger.ts +591 -102
  275. package/src/mesh/mesh-missions.ts +322 -0
  276. package/src/mesh/mesh-reconcile-loop.ts +1134 -0
  277. package/src/mesh/mesh-refine-batch.ts +197 -0
  278. package/src/mesh/mesh-refine-status.ts +231 -0
  279. package/src/mesh/mesh-review-inbox.ts +307 -0
  280. package/src/mesh/mesh-routing.ts +291 -0
  281. package/src/mesh/mesh-runtime-store.ts +1697 -0
  282. package/src/mesh/mesh-task-stats.ts +161 -0
  283. package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
  284. package/src/mesh/mesh-warmup-deadline.ts +152 -0
  285. package/src/mesh/mesh-work-queue.ts +997 -141
  286. package/src/mesh/preview-freshness.ts +118 -0
  287. package/src/mesh/refine-config.ts +423 -0
  288. package/src/mesh/worktree-bootstrap-config.ts +331 -0
  289. package/src/providers/acp-provider-instance.ts +43 -10
  290. package/src/providers/approval-utils.d.ts +5 -0
  291. package/src/providers/approval-utils.ts +57 -5
  292. package/src/providers/chat-message-normalization.ts +45 -5
  293. package/src/providers/cli-provider-instance.ts +1310 -101
  294. package/src/providers/contracts.d.ts +55 -0
  295. package/src/providers/contracts.ts +150 -6
  296. package/src/providers/extension-provider-instance.ts +12 -7
  297. package/src/providers/external-sources.ts +218 -0
  298. package/src/providers/ide-provider-instance.ts +35 -12
  299. package/src/providers/manual-attendance.ts +85 -0
  300. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  301. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  302. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  303. package/src/providers/native-history/dispatcher.ts +340 -0
  304. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  305. package/src/providers/native-history/index.ts +30 -0
  306. package/src/providers/provider-instance-manager.ts +30 -0
  307. package/src/providers/provider-instance.ts +19 -1
  308. package/src/providers/provider-loader.ts +668 -50
  309. package/src/providers/provider-schema.ts +87 -14
  310. package/src/providers/provider-trust.ts +114 -0
  311. package/src/providers/read-chat-contract.ts +76 -16
  312. package/src/providers/sdk/README.md +49 -0
  313. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  314. package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
  315. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  316. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  317. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  318. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  319. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  320. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  321. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  322. package/src/providers/sdk/v1/index.ts +152 -0
  323. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  324. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  325. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  326. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  327. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  328. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  329. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  330. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  331. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  332. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  333. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  334. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  335. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  336. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  337. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  338. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  339. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  340. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  341. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  342. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  343. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  344. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  345. package/src/providers/sdk/v1/validators/index.ts +19 -0
  346. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  347. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  348. package/src/providers/spec/adapter.ts +235 -0
  349. package/src/providers/spec/cli-adapter.ts +1051 -0
  350. package/src/providers/spec/evaluator.ts +407 -0
  351. package/src/providers/spec/fsm-driver.ts +1305 -0
  352. package/src/providers/spec/fsm-evaluator.ts +272 -0
  353. package/src/providers/spec/fsm-loader.ts +120 -0
  354. package/src/providers/spec/fsm-types.ts +273 -0
  355. package/src/providers/spec/native-history-executor.ts +1136 -0
  356. package/src/providers/spec/pre-launch-trust.ts +104 -0
  357. package/src/providers/spec/route.ts +51 -0
  358. package/src/providers/spec/types.ts +262 -0
  359. package/src/providers/status-monitor.d.ts +7 -7
  360. package/src/providers/status-monitor.ts +37 -22
  361. package/src/providers/transcript-v2.ts +567 -0
  362. package/src/providers/types/interactive-prompt.ts +536 -0
  363. package/src/providers/version-archive.ts +64 -24
  364. package/src/providers/working-dir.ts +23 -0
  365. package/src/repo-mesh-types.ts +378 -14
  366. package/src/sessions/registry.ts +6 -0
  367. package/src/shared-types-extra.ts +2 -4
  368. package/src/shared-types.d.ts +8 -0
  369. package/src/shared-types.ts +64 -1
  370. package/src/status/builders.ts +26 -6
  371. package/src/status/normalize.ts +2 -0
  372. package/src/status/reporter.ts +19 -1
  373. package/src/status/snapshot.ts +95 -26
  374. package/src/system/hash.ts +23 -0
  375. package/src/system/host-memory.ts +29 -12
  376. package/src/system/load-better-sqlite3.ts +68 -0
  377. package/src/types.ts +5 -0
  378. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  379. package/dist/mesh/mesh-sync.d.ts +0 -53
  380. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  381. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  382. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,234 @@
1
+ /**
2
+ * RF-ROUTER MED family — Mesh Host manual-pairing commands.
3
+ *
4
+ * get_mesh_host_pairing, configure_mesh_host_pairing,
5
+ * create_mesh_host_pairing_token, apply_mesh_host_join and
6
+ * join_mesh_host_pairing. These read/mutate the mesh host pairing metadata and,
7
+ * for join, apply the request to the host over mesh-command dispatch or a
8
+ * standalone HTTP command. Extracted verbatim from executeDaemonCommand; pairing
9
+ * helpers are imported from router.js, identical to the original references.
10
+ */
11
+ import { resolveMeshHostStatus } from '../../mesh/mesh-host-ownership.js';
12
+ import { buildMemberJoinNode, normalizeStandaloneHostCommandUrl } from '../router.js';
13
+ import type { MedFamilyContext, MedFamilyHandler } from './types.js';
14
+
15
+ export const meshHostPairingHandlers: Record<string, MedFamilyHandler> = {
16
+ get_mesh_host_pairing: async (ctx: MedFamilyContext, args: any) => {
17
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
18
+ if (!meshId) return { success: false, error: 'meshId required' };
19
+ const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
20
+ const mesh = meshRecord?.mesh;
21
+ if (!mesh) return { success: false, error: 'Mesh not found' };
22
+ const meshHost = resolveMeshHostStatus(mesh);
23
+ const pairingStatus = meshHost.pairing?.status || 'not_configured';
24
+ return {
25
+ success: true,
26
+ code: pairingStatus === 'not_configured' ? 'mesh_host_pairing_not_configured' : 'mesh_host_pairing_pending',
27
+ meshId,
28
+ hostAddress: meshHost.hostAddress,
29
+ meshHost,
30
+ manualPairing: {
31
+ status: pairingStatus,
32
+ joinImplemented: true,
33
+ protocol: 'standalone_command_direct_v1',
34
+ description: 'Standalone manual pairing can save address/token metadata, apply a host join over direct standalone command HTTP or injected mesh command dispatch, and check persisted status. P2P signaling remains outside this slice.',
35
+ },
36
+ };
37
+ },
38
+
39
+ configure_mesh_host_pairing: async (ctx: MedFamilyContext, args: any) => {
40
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
41
+ const hostAddress = typeof args?.hostAddress === 'string' ? args.hostAddress.trim() : '';
42
+ const token = typeof args?.token === 'string' ? args.token.trim() : '';
43
+ if (!meshId) return { success: false, error: 'meshId required' };
44
+ if (!hostAddress || !token) return { success: false, error: 'hostAddress and token required' };
45
+ try {
46
+ const { configureMeshHostPairing } = await import('../../config/mesh-config.js');
47
+ const configured = configureMeshHostPairing(meshId, { hostAddress, token });
48
+ if (!configured) return { success: false, error: 'Mesh not found' };
49
+ ctx.inlineMeshCache.set(meshId, configured.mesh);
50
+ const meshHost = resolveMeshHostStatus(configured.mesh);
51
+ return {
52
+ success: true,
53
+ code: 'mesh_host_pairing_pending',
54
+ meshId,
55
+ hostAddress: configured.hostAddress,
56
+ meshHost,
57
+ manualPairing: {
58
+ status: meshHost.pairing?.status || 'pairing',
59
+ joinImplemented: true,
60
+ protocol: 'standalone_command_direct_v1',
61
+ description: 'Manual Mesh Host pairing config was saved locally. Use join_mesh_host_pairing to apply it to the host. Raw token was not persisted.',
62
+ },
63
+ };
64
+ } catch (e: any) {
65
+ return { success: false, code: 'mesh_host_pairing_invalid', meshId, hostAddress, error: e.message };
66
+ }
67
+ },
68
+
69
+ create_mesh_host_pairing_token: async (ctx: MedFamilyContext, args: any) => {
70
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
71
+ if (!meshId) return { success: false, error: 'meshId required' };
72
+ try {
73
+ const { createMeshHostPairingToken } = await import('../../config/mesh-config.js');
74
+ const created = createMeshHostPairingToken(meshId, {
75
+ token: typeof args?.token === 'string' ? args.token : undefined,
76
+ expiresAt: typeof args?.expiresAt === 'string' ? args.expiresAt : undefined,
77
+ });
78
+ if (!created) return { success: false, error: 'Mesh not found' };
79
+ ctx.inlineMeshCache.set(meshId, created.mesh);
80
+ ctx.invalidateAggregateMeshStatus(meshId);
81
+ return {
82
+ success: true,
83
+ code: 'mesh_host_pairing_token_created',
84
+ meshId,
85
+ token: created.token,
86
+ tokenId: created.tokenId,
87
+ expiresAt: created.expiresAt,
88
+ meshHost: resolveMeshHostStatus(created.mesh),
89
+ warning: 'Raw token is returned once and is not persisted; share it with member daemons over a trusted channel.',
90
+ };
91
+ } catch (e: any) {
92
+ return { success: false, code: 'mesh_host_pairing_token_invalid', meshId, error: e.message };
93
+ }
94
+ },
95
+
96
+ apply_mesh_host_join: async (ctx: MedFamilyContext, args: any) => {
97
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
98
+ const token = typeof args?.token === 'string' ? args.token.trim() : '';
99
+ const memberNode = args?.memberNode && typeof args.memberNode === 'object' && !Array.isArray(args.memberNode)
100
+ ? args.memberNode
101
+ : null;
102
+ if (!meshId) return { success: false, error: 'meshId required' };
103
+ if (!token || !memberNode) return { success: false, error: 'token and memberNode required' };
104
+ try {
105
+ const { applyMeshHostJoinRequest } = await import('../../config/mesh-config.js');
106
+ const applied = applyMeshHostJoinRequest(meshId, {
107
+ token,
108
+ memberNode: memberNode as any,
109
+ memberMeshId: typeof args?.memberMeshId === 'string' ? args.memberMeshId : undefined,
110
+ });
111
+ if (!applied) return { success: false, error: 'Mesh not found' };
112
+ if (!applied.accepted) {
113
+ return {
114
+ success: false,
115
+ code: 'mesh_host_join_rejected',
116
+ meshId,
117
+ tokenId: applied.tokenId,
118
+ meshHost: applied.meshHost ? resolveMeshHostStatus({ meshHost: applied.meshHost }) : undefined,
119
+ error: applied.reason,
120
+ };
121
+ }
122
+ ctx.inlineMeshCache.set(meshId, applied.mesh);
123
+ ctx.invalidateAggregateMeshStatus(meshId);
124
+ try {
125
+ const { appendLedgerEntry } = await import('../../mesh/mesh-ledger.js');
126
+ appendLedgerEntry(meshId, {
127
+ kind: 'node_joined',
128
+ nodeId: applied.node.id,
129
+ payload: { role: 'member', tokenId: applied.tokenId, workspace: applied.node.workspace },
130
+ });
131
+ } catch { /* ledger append is best-effort */ }
132
+ return {
133
+ success: true,
134
+ code: 'mesh_host_join_accepted',
135
+ meshId,
136
+ node: applied.node,
137
+ tokenId: applied.tokenId,
138
+ meshHost: resolveMeshHostStatus(applied.mesh),
139
+ };
140
+ } catch (e: any) {
141
+ return { success: false, code: 'mesh_host_join_failed', meshId, error: e.message };
142
+ }
143
+ },
144
+
145
+ join_mesh_host_pairing: async (ctx: MedFamilyContext, args: any) => {
146
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
147
+ const token = typeof args?.token === 'string' ? args.token.trim() : '';
148
+ if (!meshId) return { success: false, error: 'meshId required' };
149
+ if (!token) return { success: false, error: 'token required because raw pairing tokens are not persisted' };
150
+ const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
151
+ const mesh = meshRecord?.mesh;
152
+ if (!mesh) return { success: false, error: 'Mesh not found' };
153
+ const meshHost = resolveMeshHostStatus(mesh);
154
+ if (meshHost.role !== 'member') {
155
+ return { success: false, code: 'mesh_host_join_not_member', meshId, meshHost, error: 'join_mesh_host_pairing must run from a member daemon configured with a Mesh Host address/token.' };
156
+ }
157
+ try {
158
+ const { tokenIdForManualPairing, markMeshHostPairingJoined } = await import('../../config/mesh-config.js');
159
+ const tokenId = tokenIdForManualPairing(token);
160
+ if (meshHost.pairing?.tokenId && meshHost.pairing.tokenId !== tokenId) {
161
+ return { success: false, code: 'mesh_host_join_rejected', meshId, tokenId, meshHost, error: 'invalid pairing token' };
162
+ }
163
+ const memberNode = buildMemberJoinNode(mesh, args, ctx.deps.statusInstanceId);
164
+ if (!memberNode) return { success: false, error: 'member node metadata unavailable' };
165
+ const hostMeshId = typeof args?.hostMeshId === 'string' && args.hostMeshId.trim() ? args.hostMeshId.trim() : meshId;
166
+ const hostDaemonId = typeof args?.hostDaemonId === 'string' && args.hostDaemonId.trim()
167
+ ? args.hostDaemonId.trim()
168
+ : meshHost.hostDaemonId;
169
+ let hostResult: any;
170
+ let transport: string;
171
+ if (hostDaemonId && ctx.deps.dispatchMeshCommand) {
172
+ transport = 'mesh_command_dispatch';
173
+ hostResult = await ctx.deps.dispatchMeshCommand(hostDaemonId, 'apply_mesh_host_join', {
174
+ meshId: hostMeshId,
175
+ token,
176
+ memberMeshId: meshId,
177
+ memberNode,
178
+ });
179
+ } else if (meshHost.hostAddress) {
180
+ transport = 'standalone_http_command';
181
+ const commandUrl = normalizeStandaloneHostCommandUrl(meshHost.hostAddress);
182
+ const response = await fetch(commandUrl, {
183
+ method: 'POST',
184
+ headers: { 'Content-Type': 'application/json' },
185
+ body: JSON.stringify({ type: 'apply_mesh_host_join', payload: { meshId: hostMeshId, token, memberMeshId: meshId, memberNode } }),
186
+ });
187
+ hostResult = await response.json().catch(() => ({ success: false, error: `Host returned HTTP ${response.status}` }));
188
+ if (!response.ok && hostResult?.success !== false) hostResult = { success: false, error: `Host returned HTTP ${response.status}` };
189
+ } else {
190
+ return {
191
+ success: false,
192
+ code: 'mesh_host_join_transport_unavailable',
193
+ meshId,
194
+ meshHost,
195
+ error: 'No hostDaemonId dispatch path or hostAddress HTTP command path is available. P2P signaling join is not implemented in this slice.',
196
+ };
197
+ }
198
+ if (!hostResult?.success) {
199
+ return { success: false, code: hostResult?.code || 'mesh_host_join_rejected', meshId, meshHost, transport, error: hostResult?.error || 'Mesh Host rejected join request', hostResult };
200
+ }
201
+ const joined = meshRecord.inline
202
+ ? null
203
+ : markMeshHostPairingJoined(meshId, {
204
+ tokenId: hostResult.tokenId || tokenId,
205
+ hostDaemonId: hostResult.meshHost?.hostDaemonId || hostDaemonId,
206
+ hostNodeId: hostResult.meshHost?.hostNodeId,
207
+ joinedAt: hostResult.meshHost?.pairing?.joinedAt,
208
+ });
209
+ if (joined) {
210
+ ctx.inlineMeshCache.set(meshId, joined.mesh);
211
+ ctx.invalidateAggregateMeshStatus(meshId);
212
+ }
213
+ return {
214
+ success: true,
215
+ code: 'mesh_host_join_applied',
216
+ meshId,
217
+ hostMeshId,
218
+ transport,
219
+ node: hostResult.node,
220
+ tokenId: hostResult.tokenId || tokenId,
221
+ meshHost: joined ? resolveMeshHostStatus(joined.mesh) : { ...meshHost, pairing: { ...(meshHost.pairing || {}), status: 'paired', tokenId: hostResult.tokenId || tokenId } },
222
+ hostResult,
223
+ manualPairing: {
224
+ status: 'paired',
225
+ joinImplemented: true,
226
+ protocol: 'standalone_command_direct_v1',
227
+ description: 'Mesh Host accepted the join and local member pairing status was marked paired. P2P runtime signaling remains outside this slice.',
228
+ },
229
+ };
230
+ } catch (e: any) {
231
+ return { success: false, code: 'mesh_host_join_failed', meshId, meshHost, error: e.message };
232
+ }
233
+ },
234
+ };
@@ -0,0 +1,131 @@
1
+ /**
2
+ * RF-ROUTER MED family — mesh work-queue commands.
3
+ *
4
+ * get_mesh_queue (view with dependency annotation), cancel_mesh_queue_task,
5
+ * requeue_mesh_queue_task and trigger_mesh_queue. The mutating commands gate on
6
+ * the Mesh Host owner check (ctx.requireMeshHostMutationOwner). trigger preflights
7
+ * a preferred-node claim before the round-robin trigger. Extracted verbatim from
8
+ * executeDaemonCommand.
9
+ */
10
+ import { readStringValue } from '../router.js';
11
+ import type { MedFamilyContext, MedFamilyHandler } from './types.js';
12
+
13
+ export const meshQueueHandlers: Record<string, MedFamilyHandler> = {
14
+ get_mesh_queue: async (_ctx: MedFamilyContext, args: any) => {
15
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
16
+ if (!meshId) return { success: false, error: 'meshId required' };
17
+ try {
18
+ const { getMeshQueueStats, getQueue, describeTaskDependencyState } = await import('../../mesh/mesh-work-queue.js');
19
+ const status = Array.isArray(args?.status)
20
+ ? args.status.map((s: any) => typeof s === 'string' ? s.trim() : '').filter(Boolean)
21
+ : undefined;
22
+ const rawQueue = getQueue(meshId, { status: status as any });
23
+ // M1: annotate dependency state at view time (waitingOn / dependenciesSatisfied).
24
+ const statusById = new Map(getQueue(meshId).map(task => [task.id, task.status]));
25
+ const queue = rawQueue.map(task =>
26
+ Array.isArray(task.dependsOn) && task.dependsOn.length > 0
27
+ ? { ...task, ...describeTaskDependencyState(task, statusById) }
28
+ : task);
29
+ const summary = getMeshQueueStats(meshId);
30
+ return {
31
+ success: true,
32
+ queue,
33
+ summary,
34
+ sourceOfTruth: {
35
+ kind: 'mesh_work_queue_file',
36
+ activeStatuses: ['pending', 'assigned'],
37
+ historicalStatuses: ['completed', 'failed', 'cancelled'],
38
+ notes: 'pending/assigned are active work; completed/failed/cancelled are historical records.',
39
+ },
40
+ };
41
+ } catch (e: any) {
42
+ return { success: false, error: e.message };
43
+ }
44
+ },
45
+
46
+ cancel_mesh_queue_task: async (ctx: MedFamilyContext, args: any) => {
47
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
48
+ const taskId = typeof args?.taskId === 'string' ? args.taskId.trim() : '';
49
+ if (!meshId || !taskId) return { success: false, error: 'meshId and taskId required' };
50
+ const ownerFailure = await ctx.requireMeshHostMutationOwner(meshId, args?.inlineMesh, 'queue cancellation');
51
+ if (ownerFailure) return ownerFailure;
52
+ try {
53
+ const { cancelTask } = await import('../../mesh/mesh-work-queue.js');
54
+ const reason = typeof args?.reason === 'string' ? args.reason : undefined;
55
+ const task = cancelTask(meshId, taskId, { reason });
56
+ if (!task) return { success: false, error: `Queue task '${taskId}' not found` };
57
+ return { success: true, task };
58
+ } catch (e: any) {
59
+ return { success: false, error: e.message };
60
+ }
61
+ },
62
+
63
+ requeue_mesh_queue_task: async (ctx: MedFamilyContext, args: any) => {
64
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
65
+ const taskId = typeof args?.taskId === 'string' ? args.taskId.trim() : '';
66
+ if (!meshId || !taskId) return { success: false, error: 'meshId and taskId required' };
67
+ const ownerFailure = await ctx.requireMeshHostMutationOwner(meshId, args?.inlineMesh, 'queue requeue');
68
+ if (ownerFailure) return ownerFailure;
69
+ try {
70
+ const { requeueTask } = await import('../../mesh/mesh-work-queue.js');
71
+ const task = requeueTask(meshId, taskId, {
72
+ reason: typeof args?.reason === 'string' ? args.reason : undefined,
73
+ targetNodeId: typeof args?.targetNodeId === 'string' ? args.targetNodeId.trim() : undefined,
74
+ targetSessionId: typeof args?.targetSessionId === 'string' ? args.targetSessionId.trim() : undefined,
75
+ clearTargetNode: args?.clearTargetNode === true,
76
+ clearTargetSession: args?.clearTargetSession !== false,
77
+ });
78
+ if (!task) return { success: false, error: `Queue task '${taskId}' not found` };
79
+ return { success: true, task };
80
+ } catch (e: any) {
81
+ return { success: false, error: e.message };
82
+ }
83
+ },
84
+
85
+ trigger_mesh_queue: async (ctx: MedFamilyContext, args: any) => {
86
+ const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
87
+ if (!meshId) return { success: false, error: 'meshId required' };
88
+ const ownerFailure = await ctx.requireMeshHostMutationOwner(meshId, args?.inlineMesh, 'queue trigger');
89
+ if (ownerFailure) return ownerFailure;
90
+ try {
91
+ const { triggerMeshQueue, tryAssignQueueTask } = await import('../../mesh/mesh-events.js');
92
+
93
+ // Bug A fix: when preferredNodeId is provided, attempt to claim a pending
94
+ // task for the preferred node's idle session first, before the general
95
+ // round-robin trigger picks a different node.
96
+ const preferredNodeId = typeof args?.preferredNodeId === 'string' ? args.preferredNodeId.trim() : '';
97
+ if (preferredNodeId) {
98
+ const cliInstances = ctx.deps.instanceManager.getByCategory('cli');
99
+ // Sort: preferred node's sessions first, others after
100
+ const sorted = [...cliInstances].sort((a, b) => {
101
+ const aSettings = a.getState().settings as Record<string, unknown> || {};
102
+ const bSettings = b.getState().settings as Record<string, unknown> || {};
103
+ const aNode = readStringValue(aSettings.meshNodeId, aSettings.nodeId);
104
+ const bNode = readStringValue(bSettings.meshNodeId, bSettings.nodeId);
105
+ return (aNode === preferredNodeId ? -1 : 0) - (bNode === preferredNodeId ? -1 : 0);
106
+ });
107
+ for (const inst of sorted) {
108
+ const state = inst.getState();
109
+ const settings = state.settings as Record<string, unknown> || {};
110
+ const nodeId = readStringValue(settings.meshNodeId, settings.nodeId);
111
+ if (!nodeId || nodeId !== preferredNodeId) continue;
112
+ const meshNodeFor = readStringValue(settings.meshNodeFor);
113
+ if (meshNodeFor !== meshId) continue;
114
+ const status = (readStringValue(state.status) || '').toLowerCase();
115
+ if (status !== 'idle') continue;
116
+ const sessionId = typeof state.instanceId === 'string' ? state.instanceId : '';
117
+ const providerType = readStringValue(state.type, settings.providerType) || '';
118
+ if (sessionId && providerType) {
119
+ tryAssignQueueTask(ctx.deps as any, meshId, nodeId, sessionId, providerType);
120
+ break;
121
+ }
122
+ }
123
+ }
124
+
125
+ const trigger = await triggerMeshQueue(ctx.deps as any, meshId);
126
+ return { success: true, trigger };
127
+ } catch (e: any) {
128
+ return { success: false, error: e.message };
129
+ }
130
+ },
131
+ };
@@ -0,0 +1,120 @@
1
+ /**
2
+ * RF-ROUTER MED family — shared types for the extracted medium-coupling command
3
+ * handlers. Like the LOW family, each handler is a function of (context, args)
4
+ * that returns the exact CommandRouterResult the original `executeDaemonCommand`
5
+ * switch case returned, so the router facade is unchanged.
6
+ *
7
+ * Unlike the LOW family, MED handlers need a handful of router-private
8
+ * collaborators (mesh resolution, owner gating, inline-cache mutation, worktree /
9
+ * session cleanup, refine job starters, IDE launch). The router binds these onto
10
+ * MedFamilyContext at dispatch; they are NOT reachable from `deps`. The IDE family
11
+ * also needs `launchIde` to break the original `launch_ide`/`restart_*`
12
+ * self-recursion through executeDaemonCommand.
13
+ *
14
+ * Registry dispatch: DaemonCommandRouter.executeDaemonCommand looks up the cmd in
15
+ * medFamilyRegistry BEFORE its switch; a hit returns the handler result, a miss
16
+ * falls through to the remaining switch (and ultimately CommandHandler delegation).
17
+ */
18
+ import type { CommandRouterDeps, CommandRouterResult, MeshGitProbeCache } from '../router.js';
19
+ import type { RepoMeshSessionCleanupMode } from '../../repo-mesh-types.js';
20
+ import type { WorktreeBootstrapState } from '../../mesh/worktree-bootstrap-config.js';
21
+
22
+ /** Mesh record resolved from the router's inline-mesh cache + local config. */
23
+ export type ResolvedMeshForCommand = {
24
+ mesh: any;
25
+ inline: boolean;
26
+ source: 'inline_cache' | 'inline_bootstrap' | 'local_config';
27
+ } | null;
28
+
29
+ /** Result of the router's local worktree-node cleanup. */
30
+ export type CleanupLocalWorktreeNodeResult =
31
+ | { success: true; skipped?: boolean; removedPath?: string; repoRoot?: string; reason?: string; fallback?: string; forced?: boolean; convergence?: Record<string, unknown>; recovered?: boolean; residue?: boolean; residueWarning?: string; residueError?: string }
32
+ | { success: false; code: string; error: string; recoveryHint: string; convergence?: Record<string, unknown> };
33
+
34
+ /**
35
+ * Router-private collaborators injected at dispatch. Each is a bound method or
36
+ * field of DaemonCommandRouter; handlers that don't need a given collaborator
37
+ * simply ignore it. The router owns this instance state (inline-mesh cache,
38
+ * aggregate-status cache, session/worktree cleanup, refine jobs), so it cannot be
39
+ * read from `deps` — the registry receives bound references instead.
40
+ */
41
+ export interface MedFamilyContext {
42
+ deps: CommandRouterDeps;
43
+
44
+ /** Bound `DaemonCommandRouter.getMeshForCommand`. */
45
+ getMeshForCommand: (
46
+ meshId: string,
47
+ inlineMesh?: unknown,
48
+ options?: { preferInline?: boolean },
49
+ ) => Promise<ResolvedMeshForCommand>;
50
+
51
+ /** Bound `DaemonCommandRouter.getCachedInlineMesh`. */
52
+ getCachedInlineMesh: (meshId: string, inlineMesh?: unknown) => any | undefined;
53
+
54
+ /** Bound `DaemonCommandRouter.requireMeshHostMutationOwner` (owner gate). */
55
+ requireMeshHostMutationOwner: (meshId: string, inlineMesh: unknown, operation: string) => Promise<CommandRouterResult | null>;
56
+
57
+ /** Bound `DaemonCommandRouter.invalidateAggregateMeshStatus`. */
58
+ invalidateAggregateMeshStatus: (meshId: string) => void;
59
+
60
+ /** Bound `DaemonCommandRouter.updateInlineMeshNode`. */
61
+ updateInlineMeshNode: (meshId: string, mesh: any, node: any) => void;
62
+
63
+ /** Bound `DaemonCommandRouter.removeInlineMeshNode`. */
64
+ removeInlineMeshNode: (meshId: string, mesh: any, nodeId: string) => boolean;
65
+
66
+ /** Bound `DaemonCommandRouter.normalizeMeshSessionCleanupMode`. */
67
+ normalizeMeshSessionCleanupMode: (value: unknown) => RepoMeshSessionCleanupMode;
68
+
69
+ /** Bound `DaemonCommandRouter.cleanupMeshSessions`. */
70
+ cleanupMeshSessions: (args: {
71
+ meshId: string;
72
+ nodeId: string;
73
+ node: any;
74
+ mode: RepoMeshSessionCleanupMode;
75
+ sessionIds?: string[];
76
+ dryRun?: boolean;
77
+ source?: 'mesh_cleanup_sessions' | 'mesh_remove_node';
78
+ }) => Promise<{ success: boolean; [key: string]: unknown }>;
79
+
80
+ /** Bound `DaemonCommandRouter.cleanupLocalWorktreeNode`. */
81
+ cleanupLocalWorktreeNode: (args: {
82
+ mesh: any;
83
+ node: any;
84
+ nodeId: string;
85
+ force?: boolean;
86
+ }) => Promise<CleanupLocalWorktreeNodeResult>;
87
+
88
+ /** Bound `DaemonCommandRouter.startMeshRefineJob` (async execute path). */
89
+ startMeshRefineJob: (meshId: string, nodeId: string, args: any) => Promise<CommandRouterResult>;
90
+
91
+ /** Bound `DaemonCommandRouter.batchRefineMeshNodes` (dry-run batch plan). */
92
+ batchRefineMeshNodes: (meshId: string, requestedNodeIds: string[] | undefined, args: any) => Promise<CommandRouterResult>;
93
+
94
+ /** Bound `DaemonCommandRouter.startMeshRefineBatchJob` (async batch execute). */
95
+ startMeshRefineBatchJob: (meshId: string, requestedNodeIds: string[] | undefined, args: any) => Promise<CommandRouterResult>;
96
+
97
+ /** Bound `DaemonCommandRouter.stopIde` (CDP disconnect + cleanup + optional kill). */
98
+ stopIde: (ideType: string, killProcess?: boolean) => Promise<void>;
99
+
100
+ /**
101
+ * Module-level `launchIde` helper bound to this context. The original
102
+ * `launch_ide` case body, lifted into a free function so `restart_session` /
103
+ * `restart_ide` can invoke the IDE launch directly instead of recursing
104
+ * through `executeDaemonCommand('launch_ide')` (which would re-enter the
105
+ * registry). Byte-identical to the original case body.
106
+ */
107
+ launchIde: (args: any) => Promise<CommandRouterResult>;
108
+
109
+ /** Router's inline-mesh cache (read/write of resolved mesh records). */
110
+ inlineMeshCache: Map<string, any>;
111
+
112
+ /** Router's mesh git-probe cache (reused direct-truth probes for get_mesh). */
113
+ meshGitProbeCache: MeshGitProbeCache;
114
+ }
115
+
116
+ export type MedFamilyHandler = (ctx: MedFamilyContext, args: any) => Promise<CommandRouterResult | null>;
117
+
118
+ export type MedFamilyRegistry = Map<string, MedFamilyHandler>;
119
+
120
+ export type { WorktreeBootstrapState };