@adhdev/daemon-core 0.9.82-rc.45 → 0.9.82-rc.451

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 (429) 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 +25 -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 +64 -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 +152 -0
  54. package/dist/commands/mesh-coordinator.d.ts +85 -1
  55. package/dist/commands/router.d.ts +279 -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 +129 -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 +12 -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 +66 -14
  74. package/dist/index.js +49753 -18414
  75. package/dist/index.js.map +1 -1
  76. package/dist/index.mjs +49614 -18438
  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 +115 -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 +306 -0
  108. package/dist/mesh/mesh-queue-assignment.d.ts +113 -0
  109. package/dist/mesh/mesh-reconcile-loop.d.ts +79 -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 +32 -1
  128. package/dist/providers/cli-provider-instance.d.ts +254 -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 +126 -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 +98 -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 +444 -0
  166. package/dist/providers/spec/fsm-evaluator.d.ts +93 -0
  167. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  168. package/dist/providers/spec/fsm-types.d.ts +202 -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 +519 -13
  178. package/dist/runtime-defaults.d.ts +2 -0
  179. package/dist/session-host/managed-host.d.ts +64 -0
  180. package/dist/session-host/runtime-surface.d.ts +10 -16
  181. package/dist/sessions/registry.d.ts +6 -0
  182. package/dist/shared-types-extra.d.ts +2 -4
  183. package/dist/shared-types.d.ts +86 -55
  184. package/dist/status/normalize.d.ts +1 -1
  185. package/dist/status/normalize.js +1 -0
  186. package/dist/status/normalize.js.map +1 -1
  187. package/dist/status/normalize.mjs +1 -0
  188. package/dist/status/normalize.mjs.map +1 -1
  189. package/dist/status/reporter.d.ts +2 -0
  190. package/dist/status/snapshot.d.ts +26 -0
  191. package/dist/system/hash.d.ts +8 -0
  192. package/dist/system/load-better-sqlite3.d.ts +21 -0
  193. package/dist/types.d.ts +5 -0
  194. package/package.json +7 -3
  195. package/src/agent-stream/poller.ts +2 -3
  196. package/src/agent-stream/provider-adapter.ts +1 -1
  197. package/src/boot/daemon-lifecycle.ts +63 -12
  198. package/src/boot/process-hardening.ts +89 -0
  199. package/src/build-info.ts +73 -0
  200. package/src/chat/source-machine.ts +534 -0
  201. package/src/chat/source-resolver.ts +0 -0
  202. package/src/chat/subscription-updates.ts +20 -1
  203. package/src/cli-adapter-types.d.ts +3 -1
  204. package/src/cli-adapter-types.ts +68 -2
  205. package/src/cli-adapters/cli-script-runner.ts +421 -0
  206. package/src/cli-adapters/cli-state-engine.ts +1246 -0
  207. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  208. package/src/cli-adapters/provider-cli-adapter.ts +914 -1144
  209. package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
  210. package/src/cli-adapters/provider-cli-parse.ts +19 -0
  211. package/src/cli-adapters/provider-cli-runtime.ts +56 -7
  212. package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
  213. package/src/cli-adapters/provider-cli-shared.ts +121 -11
  214. package/src/cli-adapters/pty-transport.ts +2 -1
  215. package/src/cli-adapters/pty-write-chunking.ts +106 -0
  216. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  217. package/src/cli-adapters/resolve-executable.ts +204 -0
  218. package/src/cli-adapters/session-host-transport.ts +2 -1
  219. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
  220. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  221. package/src/cli-adapters/terminal-screen.ts +16 -81
  222. package/src/commands/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
  223. package/src/commands/chat-commands-debug-bundle.ts +398 -0
  224. package/src/commands/chat-commands-read.ts +2488 -0
  225. package/src/commands/chat-commands-scope.ts +54 -0
  226. package/src/commands/chat-commands-shared.ts +114 -0
  227. package/src/commands/chat-commands-write.ts +891 -0
  228. package/src/commands/chat-commands.ts +19 -1841
  229. package/src/commands/cli-manager.ts +596 -27
  230. package/src/commands/handler.ts +841 -2
  231. package/src/commands/high-family/index.ts +28 -0
  232. package/src/commands/high-family/mesh-coordinator-launch.ts +680 -0
  233. package/src/commands/high-family/mesh-events.ts +89 -0
  234. package/src/commands/high-family/mesh-status.ts +822 -0
  235. package/src/commands/high-family/types.ts +80 -0
  236. package/src/commands/low-family/coordinator-prompt.ts +72 -0
  237. package/src/commands/low-family/daemon-lifecycle.ts +107 -0
  238. package/src/commands/low-family/diagnostics.ts +57 -0
  239. package/src/commands/low-family/index.ts +37 -0
  240. package/src/commands/low-family/mesh-ledger.ts +62 -0
  241. package/src/commands/low-family/mesh-node-logs.ts +87 -0
  242. package/src/commands/low-family/notification.ts +116 -0
  243. package/src/commands/low-family/refine-config.ts +106 -0
  244. package/src/commands/low-family/session-host.ts +274 -0
  245. package/src/commands/low-family/spec-providerdev.ts +217 -0
  246. package/src/commands/low-family/status-meta.ts +112 -0
  247. package/src/commands/low-family/types.ts +39 -0
  248. package/src/commands/med-family/cli-agent.ts +238 -0
  249. package/src/commands/med-family/fast-forward.ts +230 -0
  250. package/src/commands/med-family/ide.ts +163 -0
  251. package/src/commands/med-family/index.ts +37 -0
  252. package/src/commands/med-family/mesh-crud.ts +1253 -0
  253. package/src/commands/med-family/mesh-host-pairing.ts +234 -0
  254. package/src/commands/med-family/mesh-queue.ts +167 -0
  255. package/src/commands/med-family/mesh-restart.ts +92 -0
  256. package/src/commands/med-family/types.ts +153 -0
  257. package/src/commands/mesh-coordinator.ts +334 -124
  258. package/src/commands/router.ts +2893 -3536
  259. package/src/commands/stream-commands.ts +8 -0
  260. package/src/commands/upgrade-helper.ts +310 -45
  261. package/src/config/chat-history.ts +493 -24
  262. package/src/config/config.ts +12 -0
  263. package/src/config/mesh-config.ts +619 -23
  264. package/src/config/mesh-json-config.ts +376 -0
  265. package/src/config/recent-activity.ts +8 -2
  266. package/src/config/repo-settings.ts +111 -0
  267. package/src/daemon/dev-auto-implement.ts +3 -2
  268. package/src/daemon/dev-cli-debug.ts +10 -1
  269. package/src/daemon/dev-server.ts +0 -541
  270. package/src/detection/cli-detector.ts +28 -9
  271. package/src/detection/ide-detector.ts +55 -16
  272. package/src/detection/win32-ide-version.ts +106 -0
  273. package/src/git/change-impact-config.ts +354 -0
  274. package/src/git/git-commands.ts +78 -15
  275. package/src/git/git-diff.ts +81 -11
  276. package/src/git/git-executor.ts +12 -0
  277. package/src/git/git-status.ts +767 -48
  278. package/src/git/git-types.ts +14 -62
  279. package/src/git/git-worktree.ts +261 -4
  280. package/src/git/index.ts +17 -0
  281. package/src/index.ts +198 -12
  282. package/src/installer.d.ts +1 -1
  283. package/src/installer.ts +8 -6
  284. package/src/ipc/local-ipc-server.ts +278 -0
  285. package/src/launch.d.ts +1 -1
  286. package/src/launch.ts +37 -28
  287. package/src/logging/async-batch-writer.ts +55 -0
  288. package/src/logging/command-log.ts +7 -5
  289. package/src/logging/log-redactor.ts +100 -0
  290. package/src/logging/log-tail-reader.ts +341 -0
  291. package/src/logging/logger.ts +14 -7
  292. package/src/mesh/contracts.ts +338 -0
  293. package/src/mesh/coordinator-prompt.ts +416 -34
  294. package/src/mesh/coordinator-registry.ts +121 -0
  295. package/src/mesh/mesh-active-work.ts +645 -0
  296. package/src/mesh/mesh-clone-grace.ts +68 -0
  297. package/src/mesh/mesh-coordinator-config.ts +97 -0
  298. package/src/mesh/mesh-delivery-policy.ts +315 -0
  299. package/src/mesh/mesh-event-classify.ts +51 -0
  300. package/src/mesh/mesh-event-forwarding.ts +1897 -0
  301. package/src/mesh/mesh-event-trace.ts +67 -0
  302. package/src/mesh/mesh-events-coordinator.ts +32 -0
  303. package/src/mesh/mesh-events-pending.ts +656 -0
  304. package/src/mesh/mesh-events-stale.ts +389 -0
  305. package/src/mesh/mesh-events-utils.ts +443 -0
  306. package/src/mesh/mesh-events.ts +33 -1035
  307. package/src/mesh/mesh-fast-forward.ts +843 -0
  308. package/src/mesh/mesh-host-ownership.ts +111 -0
  309. package/src/mesh/mesh-init.ts +350 -0
  310. package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
  311. package/src/mesh/mesh-ledger.ts +841 -102
  312. package/src/mesh/mesh-magi-status.ts +223 -0
  313. package/src/mesh/mesh-missions.ts +449 -0
  314. package/src/mesh/mesh-node-identity.ts +1985 -0
  315. package/src/mesh/mesh-queue-assignment.ts +1924 -0
  316. package/src/mesh/mesh-reconcile-loop.ts +2018 -0
  317. package/src/mesh/mesh-refine-batch.ts +205 -0
  318. package/src/mesh/mesh-refine-gates.ts +1673 -0
  319. package/src/mesh/mesh-refine-status.ts +231 -0
  320. package/src/mesh/mesh-review-inbox.ts +307 -0
  321. package/src/mesh/mesh-routing.ts +291 -0
  322. package/src/mesh/mesh-runtime-store.ts +1853 -0
  323. package/src/mesh/mesh-scheduling-runtime.ts +198 -0
  324. package/src/mesh/mesh-task-inflight.ts +70 -0
  325. package/src/mesh/mesh-task-stats.ts +161 -0
  326. package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
  327. package/src/mesh/mesh-warmup-deadline.ts +152 -0
  328. package/src/mesh/mesh-work-queue.ts +1254 -141
  329. package/src/mesh/preview-freshness.ts +118 -0
  330. package/src/mesh/refine-config.ts +423 -0
  331. package/src/mesh/worktree-bootstrap-config.ts +450 -0
  332. package/src/providers/acp-provider-instance.ts +43 -10
  333. package/src/providers/approval-utils.d.ts +5 -0
  334. package/src/providers/approval-utils.ts +57 -5
  335. package/src/providers/chat-message-normalization.ts +92 -4
  336. package/src/providers/cli-provider-instance.ts +2177 -107
  337. package/src/providers/contracts.d.ts +55 -0
  338. package/src/providers/contracts.ts +160 -6
  339. package/src/providers/extension-provider-instance.ts +12 -7
  340. package/src/providers/external-sources.ts +218 -0
  341. package/src/providers/ide-provider-instance.ts +35 -12
  342. package/src/providers/manual-attendance.ts +85 -0
  343. package/src/providers/native-history/antigravity-cli-transcript.ts +1043 -0
  344. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  345. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  346. package/src/providers/native-history/constants.ts +19 -0
  347. package/src/providers/native-history/dispatcher.ts +373 -0
  348. package/src/providers/native-history/hermes-cli-transcript.ts +260 -0
  349. package/src/providers/native-history/index.ts +30 -0
  350. package/src/providers/provider-instance-manager.ts +71 -0
  351. package/src/providers/provider-instance.ts +19 -1
  352. package/src/providers/provider-loader.ts +668 -50
  353. package/src/providers/provider-schema.ts +87 -14
  354. package/src/providers/provider-trust.ts +114 -0
  355. package/src/providers/read-chat-contract.ts +76 -16
  356. package/src/providers/sdk/README.md +49 -0
  357. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  358. package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
  359. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  360. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  361. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  362. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  363. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  364. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  365. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  366. package/src/providers/sdk/v1/index.ts +152 -0
  367. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  368. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  369. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  370. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +509 -0
  371. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  372. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  373. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  374. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  375. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  376. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  377. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  378. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  379. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  380. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  381. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  382. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  383. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  384. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  385. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  386. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  387. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  388. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  389. package/src/providers/sdk/v1/validators/index.ts +19 -0
  390. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  391. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  392. package/src/providers/spec/adapter.ts +246 -0
  393. package/src/providers/spec/cli-adapter.ts +1064 -0
  394. package/src/providers/spec/evaluator.ts +407 -0
  395. package/src/providers/spec/fsm-driver.ts +1481 -0
  396. package/src/providers/spec/fsm-evaluator.ts +290 -0
  397. package/src/providers/spec/fsm-loader.ts +128 -0
  398. package/src/providers/spec/fsm-types.ts +301 -0
  399. package/src/providers/spec/native-history-executor.ts +1174 -0
  400. package/src/providers/spec/pre-launch-trust.ts +104 -0
  401. package/src/providers/spec/route.ts +51 -0
  402. package/src/providers/spec/types.ts +262 -0
  403. package/src/providers/status-monitor.d.ts +7 -7
  404. package/src/providers/status-monitor.ts +37 -22
  405. package/src/providers/transcript-v2.ts +567 -0
  406. package/src/providers/types/interactive-prompt.ts +536 -0
  407. package/src/providers/version-archive.ts +64 -24
  408. package/src/providers/working-dir.ts +23 -0
  409. package/src/repo-mesh-types.ts +758 -14
  410. package/src/runtime-defaults.ts +39 -0
  411. package/src/session-host/managed-host.ts +218 -0
  412. package/src/session-host/runtime-surface.ts +20 -80
  413. package/src/sessions/registry.ts +6 -0
  414. package/src/shared-types-extra.ts +2 -4
  415. package/src/shared-types.d.ts +8 -0
  416. package/src/shared-types.ts +124 -55
  417. package/src/status/builders.ts +26 -6
  418. package/src/status/normalize.ts +2 -0
  419. package/src/status/reporter.ts +19 -1
  420. package/src/status/snapshot.ts +95 -26
  421. package/src/system/hash.ts +23 -0
  422. package/src/system/host-memory.ts +29 -12
  423. package/src/system/load-better-sqlite3.ts +68 -0
  424. package/src/types.ts +5 -0
  425. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  426. package/dist/mesh/mesh-sync.d.ts +0 -53
  427. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  428. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  429. package/src/mesh/mesh-sync.ts +0 -111
@@ -8,15 +8,73 @@
8
8
  * 3. How to orchestrate work across nodes
9
9
  *
10
10
  * The prompt is generated dynamically from the current mesh state.
11
+ *
12
+ * User customization:
13
+ * ~/.adhdev/coordinator-prompts/<cliType>.md — full override
14
+ * ~/.adhdev/coordinator-prompts/<cliType>.append.md — appended to default
15
+ * ~/.adhdev/coordinator-prompts/default.md — full override (any CLI)
16
+ * ~/.adhdev/coordinator-prompts/default.append.md — appended to default (any CLI)
17
+ *
18
+ * CLI-specific files take precedence over default.* files. The override file
19
+ * still gets the node/policy facts substituted via the same {{placeholders}}
20
+ * the daemon understands; an override that doesn't reference them just gets
21
+ * a static prompt, which is also fine.
11
22
  */
12
23
 
24
+ import * as fs from 'node:fs';
25
+ import * as os from 'node:os';
26
+ import * as path from 'node:path';
27
+
13
28
  import type {
14
29
  LocalMeshEntry,
15
30
  RepoMeshPolicy,
16
31
  RepoMeshStatus,
17
32
  RepoMeshNodeStatus,
18
33
  } from '../repo-mesh-types.js';
19
- import { DEFAULT_MESH_POLICY } from '../repo-mesh-types.js';
34
+ import { mergeAndNormalizePolicy } from '../repo-mesh-types.js';
35
+
36
+ /**
37
+ * Cheap, locally-derived "what just happened" snapshot for the coordinator
38
+ * prompt. Built at launch from the local ledger + work-queue stats — no remote
39
+ * peer probe. Surfaces the gap a fresh coordinator otherwise misses: it can't
40
+ * see recent failures / queue depth until it manually calls mesh_task_history.
41
+ *
42
+ * All fields are optional so callers that have nothing to report (or fail to
43
+ * read the ledger) simply omit the section — the prompt output stays identical
44
+ * to the pre-activity form in that case.
45
+ */
46
+ export interface CoordinatorRecentActivity {
47
+ /** task_failed entries from the recent window, newest last. */
48
+ recentFailures?: Array<{
49
+ timestamp?: string;
50
+ nodeId?: string;
51
+ /** Short task title/message, already truncated by the caller. */
52
+ summary?: string;
53
+ }>;
54
+ /** Count of task_failed entries inside the recent (30-min) window. */
55
+ recentFailureCount?: number;
56
+ /** Pending (unclaimed) tasks in the work queue. */
57
+ pendingTasks?: number;
58
+ /** Assigned-but-not-yet-terminal tasks in the work queue. */
59
+ assignedTasks?: number;
60
+ /** Stalled tasks recorded in the ledger. */
61
+ stalledTasks?: number;
62
+ /** ISO timestamp of the most recent ledger activity, if any. */
63
+ lastActivityAt?: string | null;
64
+ }
65
+
66
+ /**
67
+ * One coordinator operating note — a runtime-accumulated lesson (provider
68
+ * quirk, pattern to avoid, recovery lesson) persisted in the ledger so it
69
+ * survives coordinator restarts and is provider-neutral (visible to codex /
70
+ * hermes / antigravity coordinators, not just Claude's memory).
71
+ */
72
+ export interface CoordinatorOperatingNote {
73
+ text: string;
74
+ category?: 'provider_quirk' | 'pattern_to_avoid' | 'recovery_lesson';
75
+ createdAt?: string;
76
+ sourceCoordinator?: string;
77
+ }
20
78
 
21
79
  // ─── Prompt Builder ─────────────────────────────
22
80
 
@@ -25,10 +83,88 @@ export interface CoordinatorPromptContext {
25
83
  status?: RepoMeshStatus;
26
84
  userInstruction?: string;
27
85
  coordinatorCliType?: string;
86
+ /**
87
+ * M3: pre-rendered active mission section (from buildMissionPromptSection).
88
+ * Empty/undefined when the mesh has no active mission — the prompt output
89
+ * stays identical to the pre-M3 form in that case.
90
+ */
91
+ missionSection?: string;
92
+ /**
93
+ * Gap1: recent ledger/queue activity surfaced so a freshly-launched
94
+ * coordinator sees recent failures + queue depth without first calling
95
+ * mesh_task_history. Omitted → no "## Recent Activity" section.
96
+ */
97
+ recentActivity?: CoordinatorRecentActivity;
98
+ /**
99
+ * Gap2-A: runtime-accumulated operating notes (provider-neutral lessons)
100
+ * read from the ledger at launch. Omitted/empty → no "## Operating Notes"
101
+ * section.
102
+ */
103
+ operatingNotes?: CoordinatorOperatingNote[];
28
104
  }
29
105
 
106
+ /**
107
+ * Compose the final coordinator prompt from four layers, in this precedence:
108
+ *
109
+ * 1. Per-launch `extraSystemPrompt` (always appended, as "## Additional
110
+ * Context"). Never wins as a base — it's launch-scope context.
111
+ * 2. Mesh-level append (`mesh.coordinator.systemPromptAppend` or the legacy
112
+ * `systemPromptSuffix`). Stacks after whichever base won.
113
+ * 3. User-file append (`~/.adhdev/coordinator-prompts/<cli>.append.md` or
114
+ * `default.append.md`). Also stacks; same placeholder expansion as the
115
+ * override path.
116
+ * 4. Base prompt, picked in this order:
117
+ * a. `mesh.coordinator.systemPromptOverride` (mesh-level override)
118
+ * b. user-file override (`~/.adhdev/coordinator-prompts/<cli>.md` or
119
+ * `default.md`)
120
+ * c. daemon default (assembled from identity/nodes/policy/tools/…)
121
+ *
122
+ * That layering lets a user customize prompts at three increasing scopes
123
+ * (machine, mesh, single launch) without losing the daemon's stock rules.
124
+ */
30
125
  export function buildCoordinatorSystemPrompt(ctx: CoordinatorPromptContext): string {
31
- const { mesh, status, userInstruction, coordinatorCliType } = ctx;
126
+ const { mesh, userInstruction, coordinatorCliType } = ctx;
127
+
128
+ // ── Pick the base prompt ──
129
+ const meshOverride = mesh.coordinator?.systemPromptOverride?.trim();
130
+ let base: string;
131
+ if (meshOverride) {
132
+ base = expandPromptPlaceholders(meshOverride, ctx);
133
+ } else {
134
+ const userOverride = readUserPromptFile(coordinatorCliType, 'md');
135
+ if (userOverride !== null) {
136
+ base = expandPromptPlaceholders(userOverride, ctx);
137
+ } else {
138
+ base = buildDefaultCoordinatorPrompt(ctx);
139
+ }
140
+ }
141
+
142
+ const sections: string[] = [base];
143
+
144
+ // ── User-level append runs after whichever base won ──
145
+ const userAppend = readUserPromptFile(coordinatorCliType, 'append.md');
146
+ if (userAppend !== null) {
147
+ sections.push(expandPromptPlaceholders(userAppend, ctx));
148
+ }
149
+
150
+ // ── Mesh-level append (prefer the new field, fall back to the legacy alias) ──
151
+ const meshAppend = (mesh.coordinator?.systemPromptAppend
152
+ ?? mesh.coordinator?.systemPromptSuffix)?.trim();
153
+ if (meshAppend) {
154
+ sections.push(expandPromptPlaceholders(meshAppend, ctx));
155
+ }
156
+
157
+ // ── Per-launch context lands last so it's the most recent thing the
158
+ // agent reads. Marked as Additional Context, not a rule update. ──
159
+ if (userInstruction) {
160
+ sections.push(`## Additional Context\n${userInstruction}`);
161
+ }
162
+
163
+ return sections.join('\n\n');
164
+ }
165
+
166
+ function buildDefaultCoordinatorPrompt(ctx: CoordinatorPromptContext): string {
167
+ const { mesh, status, coordinatorCliType } = ctx;
32
168
  const sections: string[] = [];
33
169
 
34
170
  // ── Identity ──
@@ -46,8 +182,21 @@ Repository: \`${mesh.repoIdentity}\`${mesh.defaultBranch ? `\nDefault branch: \`
46
182
  sections.push('## Nodes\nNo nodes configured yet. Ask the user to add nodes with `adhdev mesh add-node`.');
47
183
  }
48
184
 
185
+ // ── Active Mission (M3) — only present when one exists ──
186
+ if (ctx.missionSection?.trim()) {
187
+ sections.push(ctx.missionSection.trim());
188
+ }
189
+
190
+ // ── Recent Activity (Gap1) — only present when there's something to show ──
191
+ const recentActivity = buildRecentActivitySection(ctx.recentActivity);
192
+ if (recentActivity) sections.push(recentActivity);
193
+
194
+ // ── Operating Notes (Gap2-A) — only present when notes exist ──
195
+ const operatingNotes = buildOperatingNotesSection(ctx.operatingNotes);
196
+ if (operatingNotes) sections.push(operatingNotes);
197
+
49
198
  // ── Policy ──
50
- sections.push(buildPolicySection({ ...DEFAULT_MESH_POLICY, ...(mesh.policy || {}) }));
199
+ sections.push(buildPolicySection(mergeAndNormalizePolicy(undefined, mesh.policy)));
51
200
 
52
201
  // ── Tools ──
53
202
  sections.push(TOOLS_SECTION);
@@ -58,25 +207,102 @@ Repository: \`${mesh.repoIdentity}\`${mesh.defaultBranch ? `\nDefault branch: \`
58
207
  // ── Workflow ──
59
208
  sections.push(WORKFLOW_SECTION);
60
209
 
210
+ // ── Onboarding / Reinit ──
211
+ sections.push(ONBOARDING_SECTION);
212
+
61
213
  // ── Rules ──
62
214
  sections.push(buildRulesSection(coordinatorCliType));
63
215
 
64
- // ── User instruction ──
65
- if (userInstruction) {
66
- sections.push(`## Additional Context\n${userInstruction}`);
67
- }
216
+ return sections.join('\n\n');
217
+ }
68
218
 
69
- if (mesh.coordinator?.systemPromptSuffix) {
70
- sections.push(mesh.coordinator.systemPromptSuffix);
219
+ /**
220
+ * Look up a user-customization file under ~/.adhdev/coordinator-prompts/.
221
+ *
222
+ * Lookup order:
223
+ * 1. <cliType>.<suffix> — provider-specific
224
+ * 2. default.<suffix> — shared across providers
225
+ *
226
+ * Returns null when neither exists; an empty/whitespace-only file is also
227
+ * treated as "no override" so users can drop in a stub without affecting
228
+ * behavior. Read errors (permission, IO) are swallowed and logged-as-null
229
+ * intentionally: a broken override file should never block coordinator
230
+ * launch, it should just behave as if the file weren't there.
231
+ */
232
+ function readUserPromptFile(cliType: string | undefined, suffix: string): string | null {
233
+ const dir = path.join(os.homedir(), '.adhdev', 'coordinator-prompts');
234
+ const candidates: string[] = [];
235
+ if (cliType) candidates.push(path.join(dir, `${cliType}.${suffix}`));
236
+ candidates.push(path.join(dir, `default.${suffix}`));
237
+ for (const p of candidates) {
238
+ try {
239
+ const text = fs.readFileSync(p, 'utf8');
240
+ if (text.trim()) return text;
241
+ } catch { /* missing file is the common case — keep going */ }
71
242
  }
243
+ return null;
244
+ }
72
245
 
73
- return sections.join('\n\n');
246
+ /**
247
+ * Expand `{{placeholder}}` tokens against current mesh state.
248
+ *
249
+ * Tokens we support today:
250
+ * {{meshName}} — mesh.name
251
+ * {{repo}} — mesh.repoIdentity
252
+ * {{defaultBranch}} — mesh.defaultBranch or empty
253
+ * {{cliType}} — coordinator CLI type or empty
254
+ * {{nodes}} — full node section (status if known, otherwise config)
255
+ * {{mission}} — active mission summary section (empty when none)
256
+ * {{recentActivity}} — recent failures + queue depth section (empty when none)
257
+ * {{operatingNotes}} — accumulated operating notes section (empty when none)
258
+ * {{policy}} — full policy section
259
+ * {{tools}} — the canonical tools table
260
+ * {{workflow}} — the canonical orchestration workflow
261
+ * {{onboarding}} — the guided init/reinit onboarding section
262
+ * {{rules}} — the canonical rules section (with coordinatorNote)
263
+ * {{toolExposurePreflight}} — the MCP-missing preflight reminder
264
+ *
265
+ * Unknown tokens are left as-is — that way typos are obvious in the rendered
266
+ * prompt instead of silently disappearing. Tokens are not recursive: an
267
+ * expanded value's own {{...}} content stays literal.
268
+ */
269
+ function expandPromptPlaceholders(template: string, ctx: CoordinatorPromptContext): string {
270
+ const { mesh, status, coordinatorCliType } = ctx;
271
+ const nodesSection = status?.nodes?.length
272
+ ? buildNodeStatusSection(status.nodes)
273
+ : mesh.nodes.length
274
+ ? buildNodeConfigSection(mesh)
275
+ : '## Nodes\nNo nodes configured yet. Ask the user to add nodes with `adhdev mesh add-node`.';
276
+ const replacements: Record<string, string> = {
277
+ meshName: mesh.name,
278
+ repo: mesh.repoIdentity,
279
+ defaultBranch: mesh.defaultBranch || '',
280
+ cliType: coordinatorCliType || '',
281
+ nodes: nodesSection,
282
+ mission: ctx.missionSection?.trim() || '',
283
+ recentActivity: buildRecentActivitySection(ctx.recentActivity) || '',
284
+ operatingNotes: buildOperatingNotesSection(ctx.operatingNotes) || '',
285
+ policy: buildPolicySection(mergeAndNormalizePolicy(undefined, mesh.policy)),
286
+ tools: TOOLS_SECTION,
287
+ workflow: WORKFLOW_SECTION,
288
+ onboarding: ONBOARDING_SECTION,
289
+ rules: buildRulesSection(coordinatorCliType),
290
+ toolExposurePreflight: TOOL_EXPOSURE_PREFLIGHT_SECTION,
291
+ };
292
+ return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key) => {
293
+ return Object.prototype.hasOwnProperty.call(replacements, key) ? replacements[key] : m;
294
+ });
74
295
  }
75
296
 
76
297
  // ─── Section Builders ───────────────────────────
77
298
 
78
299
  function buildNodeStatusSection(nodes: RepoMeshNodeStatus[]): string {
79
- const lines = ['## Current Node Status', ''];
300
+ const lines = [
301
+ '## Current Node Status',
302
+ '',
303
+ 'Node labels are display context, not aliases. Use exact `nodeId` values in mesh tool calls; do not invent shorthand names such as M1/M2 unless they are explicitly configured labels.',
304
+ '',
305
+ ];
80
306
  for (const n of nodes) {
81
307
  const healthIcon = n.health === 'online' ? '🟢' :
82
308
  n.health === 'dirty' ? '🟡' :
@@ -85,31 +311,155 @@ function buildNodeStatusSection(nodes: RepoMeshNodeStatus[]): string {
85
311
  ? `sessions: ${n.activeSessions.join(', ')}`
86
312
  : 'no active sessions';
87
313
  const branch = n.git?.branch ? `branch: \`${n.git.branch}\`` : '';
88
- lines.push(`- ${healthIcon} **${n.machineLabel}** (${n.nodeId})`);
89
- lines.push(` workspace: \`${n.workspace}\` | ${branch} | ${sessions}`);
314
+ const context = [
315
+ n.daemonId ? `daemon: \`${n.daemonId}\`` : '',
316
+ n.providers?.length ? `providers: ${n.providers.join(', ')}` : '',
317
+ ].filter(Boolean).join(' | ');
318
+ lines.push(`- ${healthIcon} **${n.machineLabel}** (nodeId: \`${n.nodeId}\`)`);
319
+ lines.push(` workspace: \`${n.workspace}\`${context ? ` | ${context}` : ''} | ${branch} | ${sessions}`);
90
320
  if (n.error) lines.push(` ⚠️ ${n.error}`);
321
+ const nodePrompt = typeof (n as any).systemPrompt === 'string' ? (n as any).systemPrompt.trim() : '';
322
+ if (nodePrompt) {
323
+ lines.push(` 📌 Node instruction: ${indentFollowing(nodePrompt, ' ')}`);
324
+ }
91
325
  }
92
326
  return lines.join('\n');
93
327
  }
94
328
 
95
329
  function buildNodeConfigSection(mesh: LocalMeshEntry): string {
96
- const lines = ['## Configured Nodes', ''];
330
+ const lines = [
331
+ '## Configured Nodes',
332
+ '',
333
+ 'Node labels are display context, not aliases. Use exact `nodeId` values in mesh tool calls; do not invent shorthand names such as M1/M2 unless they are explicitly configured labels.',
334
+ '',
335
+ ];
97
336
  for (const n of mesh.nodes) {
98
337
  const labels: string[] = [];
99
338
  if (n.isLocalWorktree) labels.push('worktree');
100
339
  if (n.policy?.readOnly) labels.push('read-only');
101
340
  const suffix = labels.length ? ` [${labels.join(', ')}]` : '';
102
- lines.push(`- **${n.workspace}** (${n.id})${suffix}`);
341
+ const explicitMachineLabel = typeof (n as any).machineLabel === 'string' ? (n as any).machineLabel : '';
342
+ const explicitLabel = explicitMachineLabel ? ` label: **${explicitMachineLabel}** |` : '';
343
+ const providerPriority = n.policy?.providerPriority?.length ? ` | providers: ${n.policy.providerPriority.join(', ')}` : '';
344
+ // Per-(node, provider) maxParallel cap. Only maxParallel is enforced by the
345
+ // queue; routing is governed by required_tags, not provider roles.
346
+ const providerRoles = Array.isArray(n.policy?.providerRoles)
347
+ ? (n.policy!.providerRoles as Array<{ providerType?: unknown; maxParallel?: unknown }>)
348
+ .map(r => {
349
+ const type = typeof r?.providerType === 'string' ? r.providerType.trim() : '';
350
+ if (!type) return '';
351
+ const cap = Number.isFinite(Number(r?.maxParallel)) ? ` (max ${Math.floor(Number(r.maxParallel))})` : '';
352
+ return `${type}${cap}`;
353
+ })
354
+ .filter(Boolean)
355
+ : [];
356
+ const providerRolesSuffix = providerRoles.length ? ` | caps: ${providerRoles.join(', ')}` : '';
357
+ lines.push(`- ${explicitLabel} nodeId: \`${n.id}\` | workspace: \`${n.workspace}\`${n.daemonId ? ` | daemon: \`${n.daemonId}\`` : ''}${providerPriority}${providerRolesSuffix}${suffix}`);
358
+ const nodePrompt = typeof (n as any).systemPrompt === 'string' ? (n as any).systemPrompt.trim() : '';
359
+ if (nodePrompt) {
360
+ lines.push(` 📌 Node instruction: ${indentFollowing(nodePrompt, ' ')}`);
361
+ }
103
362
  }
104
363
  lines.push('', '_Use `mesh_status` to probe live health before delegating work._');
105
364
  return lines.join('\n');
106
365
  }
107
366
 
367
+ /**
368
+ * Indent every line after the first by `pad`. Used so multi-line node
369
+ * instructions still visually nest under the node bullet without the
370
+ * second line dangling at column zero.
371
+ */
372
+ function indentFollowing(text: string, pad: string): string {
373
+ const lines = text.split('\n');
374
+ if (lines.length === 1) return lines[0];
375
+ return [lines[0], ...lines.slice(1).map(l => pad + l)].join('\n');
376
+ }
377
+
378
+ /**
379
+ * Gap1 — render the "## Recent Activity" section from the locally-derived
380
+ * activity snapshot. Returns '' (no section) when there's nothing worth
381
+ * surfacing: no recent failures, no queued work, no stalls. This keeps a quiet
382
+ * mesh's prompt identical to the pre-activity form.
383
+ */
384
+ function buildRecentActivitySection(activity?: CoordinatorRecentActivity): string {
385
+ if (!activity) return '';
386
+ const failures = Array.isArray(activity.recentFailures) ? activity.recentFailures : [];
387
+ const pending = Number.isFinite(activity.pendingTasks) ? Number(activity.pendingTasks) : 0;
388
+ const assigned = Number.isFinite(activity.assignedTasks) ? Number(activity.assignedTasks) : 0;
389
+ const stalled = Number.isFinite(activity.stalledTasks) ? Number(activity.stalledTasks) : 0;
390
+ const recentFailureCount = Number.isFinite(activity.recentFailureCount)
391
+ ? Number(activity.recentFailureCount)
392
+ : failures.length;
393
+
394
+ // Nothing actionable to show → omit the section entirely.
395
+ if (failures.length === 0 && pending === 0 && assigned === 0 && stalled === 0 && recentFailureCount === 0) {
396
+ return '';
397
+ }
398
+
399
+ const lines: string[] = ['## Recent Activity', ''];
400
+ lines.push('A snapshot of this mesh\'s recent ledger/queue state at launch. Use it to decide what needs attention first; call `mesh_task_history` / `mesh_view_queue` for full detail.');
401
+ lines.push('');
402
+
403
+ const counts: string[] = [];
404
+ if (pending > 0) counts.push(`**${pending}** pending`);
405
+ if (assigned > 0) counts.push(`**${assigned}** assigned`);
406
+ if (stalled > 0) counts.push(`**${stalled}** stalled`);
407
+ if (recentFailureCount > 0) counts.push(`**${recentFailureCount}** failed in the last 30 min`);
408
+ if (counts.length) lines.push(`- Queue/ledger: ${counts.join(', ')}.`);
409
+ if (activity.lastActivityAt) lines.push(`- Last ledger activity: ${activity.lastActivityAt}.`);
410
+
411
+ if (failures.length > 0) {
412
+ // Newest first, capped to the 5 most recent so the prompt stays lean.
413
+ const recent = failures.slice(-5).reverse();
414
+ lines.push('', 'Recent failures (newest first):');
415
+ for (const f of recent) {
416
+ const when = f.timestamp ? `${f.timestamp} ` : '';
417
+ const node = f.nodeId ? `node \`${f.nodeId}\`` : 'unknown node';
418
+ const summary = (f.summary || '').trim();
419
+ lines.push(`- ${when}${node}${summary ? ` — ${summary}` : ''}`);
420
+ }
421
+ lines.push('', '_Check `mesh_task_history` before retrying; repeated failures on the same node mean reassign or escalate, not retry._');
422
+ }
423
+
424
+ return lines.join('\n');
425
+ }
426
+
427
+ /**
428
+ * Gap2-A — render the "## Operating Notes" section from accumulated coordinator
429
+ * notes. Returns '' when there are none, so a mesh that has never recorded a
430
+ * note gets the unchanged prompt. Notes are runtime-accumulated lessons that
431
+ * persist across coordinator restarts and are provider-neutral.
432
+ */
433
+ function buildOperatingNotesSection(notes?: CoordinatorOperatingNote[]): string {
434
+ const valid = Array.isArray(notes)
435
+ ? notes.filter(n => n && typeof n.text === 'string' && n.text.trim())
436
+ : [];
437
+ if (valid.length === 0) return '';
438
+
439
+ const categoryLabel: Record<string, string> = {
440
+ provider_quirk: 'provider quirk',
441
+ pattern_to_avoid: 'pattern to avoid',
442
+ recovery_lesson: 'recovery lesson',
443
+ };
444
+
445
+ const lines: string[] = ['## Operating Notes', ''];
446
+ lines.push('Lessons earlier coordinators on this mesh recorded via `mesh_record_note`. Treat them as accumulated operating knowledge — apply them. When you learn a durable lesson (a provider quirk, a pattern to avoid, a recovery lesson), record it with `mesh_record_note` so future coordinators inherit it.');
447
+ lines.push('');
448
+ for (const n of valid) {
449
+ const cat = n.category && categoryLabel[n.category] ? `[${categoryLabel[n.category]}] ` : '';
450
+ lines.push(`- ${cat}${n.text.trim()}`);
451
+ }
452
+ return lines.join('\n');
453
+ }
454
+
108
455
  function buildPolicySection(policy: RepoMeshPolicy): string {
109
456
  const rules: string[] = [];
110
457
  if (policy.requirePreTaskCheckpoint) rules.push('- Create a git checkpoint **before** starting each task');
111
458
  if (policy.requirePostTaskCheckpoint) rules.push('- Create a git checkpoint **after** each task completes');
112
459
  if (policy.requireApprovalForPush) rules.push('- **Ask for user approval** before pushing to remote');
460
+ if (policy.allowAutoPublishSubmoduleMainCommits) {
461
+ rules.push('- Refinery may auto-publish unreachable submodule gitlink commits to submodule origin/main with non-force pushes after validation and patch-equivalence pass');
462
+ }
113
463
  if (policy.requireApprovalForDestructiveGit) rules.push('- **Ask for user approval** before destructive git operations (force push, reset, etc.)');
114
464
 
115
465
  const dirtyBehavior = {
@@ -139,13 +489,22 @@ const TOOLS_SECTION = `## Available Tools
139
489
  | \`mesh_read_chat\` | Read recent chat messages from a delegated agent session |
140
490
  | \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
141
491
  | \`mesh_task_history\` | Read the task ledger — dispatches, completions, failures. Use to understand what has been done before deciding next steps |
492
+ | \`mesh_record_note\` | Record a durable, provider-neutral operating note (provider quirk / pattern to avoid / recovery lesson). Future coordinators see it under "## Operating Notes" at launch |
493
+ | \`mesh_forget_note\` | Retract a stale/wrong operating note by note_id or exact text so it stops riding into future coordinators' prompts (append-only tombstone; history preserved) |
142
494
  | \`mesh_git_status\` | Check git status on a specific node |
495
+ | \`mesh_read_node_logs\` | Fetch a remote node's daemon log tail directly over P2P (grep/since/byte-bounded, secrets redacted) — no session/PowerShell needed to debug a node's daemon |
496
+ | \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
143
497
  | \`mesh_checkpoint\` | Create a git checkpoint on a node |
144
498
  | \`mesh_approve\` | Approve/reject a pending agent action |
145
499
  | \`mesh_clone_node\` | Create a worktree node for isolated parallel branch work |
146
500
  | \`mesh_refine_node\` | Validate and merge a completed worktree node back into its base branch |
147
501
  | \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |
148
- | \`mesh_cleanup_sessions\` | Manually clean up delegated session records for a node |`;
502
+ | \`mesh_cleanup_sessions\` | Manually clean up delegated session records for a node |
503
+ | \`mesh_init\` | Guided onboarding for a fresh repo: dry-run scan → suggest \`.adhdev/*\` configs (refine/bootstrap/change-impact) + providerPriority + current-config echo; gated write on approval |
504
+ | \`mesh_reinit\` | Re-onboard an already-configured repo: re-suggest with overwrite semantics + current-vs-suggested diff; dry-run preview first, per-section approval before write |
505
+ | \`mesh_write_mesh_json_config\` | Gated write of \`.adhdev/mesh.json\` (repo coordinator-prompt config) from the mesh entry — dry-run/overwrite like mesh_init |
506
+ | \`mesh_magi_kind_panel_set\` | Bind a task_kind → MAGI kind-panel slots (machine-local, wholesale replacement — approve current-vs-new first) |
507
+ | \`mesh_magi_kind_panel_list\` | List configured task_kind → MAGI kind-panel slot bindings (machine-local, read-only) |`;
149
508
 
150
509
  const TOOL_EXPOSURE_PREFLIGHT_SECTION = `## Tool Exposure Preflight
151
510
 
@@ -154,17 +513,17 @@ Before doing any coordinator work, confirm that the actual callable tool list in
154
513
  const WORKFLOW_SECTION = `## Orchestration Workflow
155
514
 
156
515
  1. **Assess** — Call \`mesh_status\` to see which nodes are healthy and available. Check \`mesh_task_history\` to understand what has already been done in this mesh — previous delegations, completions, and failures.
157
- 2. **Plan** — Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist. If \`mesh_task_history\` shows a recent failure for a task, decide whether to retry or reassign.
516
+ 2. **Plan** — Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist. If \`mesh_task_history\` shows a recent failure for a task, decide whether to retry or reassign. **For multi-task work, create a mission first**: call \`mesh_mission_upsert\` with a title and goal, then attach every enqueued task with \`mission_id\`. Express "B after A" ordering with \`depends_on\` on the queue task instead of waiting and polling — the system claims dependents automatically when their dependencies complete. When the mission's outcome is decided, update its status (\`completed\`/\`abandoned\`) via \`mesh_mission_upsert\`. If the prompt already shows an **Active Mission**, continue it from its current task state — do not re-enqueue tasks that already exist.
158
517
  3. **Queue / Delegate** — The Mesh uses an autonomous pull-based Work Queue:
159
518
  a. **General Tasks**: Enqueue tasks using \`mesh_enqueue_task\`. Idle node agents will automatically pull tasks from the queue and begin working.
160
519
  b. **Node Preparation**: Reuse an existing idle session on the correct node/provider before launching a new chat/session. Call \`mesh_launch_session\` only when no suitable session exists, when the user explicitly asks for a fresh provider/session, or when branch/worktree isolation requires it. If you need branch isolation for parallel work, call \`mesh_clone_node\` to create a worktree node first.
161
520
  c. **Targeted Tasks**: Use \`mesh_send_task\` only when you need to bypass the queue and force a specific node to execute a task immediately.
162
521
  d. For the first dispatch of a new task, provide a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
163
522
  e. For a continuation of the same issue in an existing session, send a concise **delta instruction**: current verified state, the exact failed/blocked step, the newly approved action, and final reporting requirements. Do not resend the full original task or open a new chat solely to continue the same work; that wastes coordinator and worker context.
164
- 4. **Monitor** — Prefer event-driven completion/status notifications. Do **not** poll \`mesh_read_chat\` repeatedly. Use \`mesh_view_queue\` to see the status of all pending, assigned, completed, and failed tasks. Do not call \`mesh_read_chat\` again within a few seconds for the same generating session. Use at most one compact \`mesh_read_chat\` check after a completion/approval signal. Handle approvals via \`mesh_approve\`.
523
+ 4. **Monitor** — Prefer event-driven completion/status notifications. Do **not** poll \`mesh_read_chat\` repeatedly. Do **not** repeatedly call \`mesh_status\` or \`mesh_view_queue\` just to wait for assigned/generating work. After dispatching a direct or queued task, send one progress update with the task/session handle, then stop. Wait for \`pendingCoordinatorEvents\` or another completion/approval/status signal, an explicit user status request, or a real timeout/stall signal before reading status/chat/queue again. Use at most one compact \`mesh_read_chat\` check after a terminal signal. Handle approvals via \`mesh_approve\`. **Proactively parallelize new work.** When the user reports a new bug or asks for new work, start it immediately if it is independent of in-flight tasks and there is headroom under \`maxParallelTasks\` — do not wait for a current task to finish or for the user to prompt you to parallelize. Read-only diagnosis (\`live_debug_readonly\`) has no isolation or merge cost, so dispatch it in parallel right away. The no-polling / concurrency-limit rules constrain *re-checking or duplicating already-dispatched work*; they are **not** a reason to defer starting a new, independent task.
165
524
  5. **Verify** — When a task reports completion or git work is visible, call \`mesh_git_status\` to verify changes were made.
166
525
  6. **Checkpoint** — Call \`mesh_checkpoint\` to save the work.
167
- 7. **Converge branches** — Before marking any task complete, classify every touched node/branch into exactly one final state: \`merged_to_main\`, \`pushed_feature_branch_needs_merge\`, \`blocked_review\`, \`cleanup_candidate\`, or \`not_mergeable\`. Use \`mesh_status\` branchConvergenceSummary and \`mesh_refine_node\` for clean worktree branches when safe. A task that remains on a non-main branch is not fully complete unless the final report names the follow-up state and next step.
526
+ 7. **Converge branches** — Before marking any task complete, classify every touched node/branch into exactly one final state: \`merged_to_main\`, \`pushed_feature_branch_needs_merge\`, \`blocked_review\`, \`cleanup_candidate\`, or \`not_mergeable\`. Use \`mesh_status\` branchConvergenceSummary. For obvious clean branch catch-up (ahead 0, behind > 0, upstream fresh, no dirty/stash/submodule issues), use \`mesh_fast_forward_node\` dry-run first and execute only when explicitly safe/approved; this avoids consuming an agent session. Use \`mesh_refine_node\` for clean worktree branches when safe. Before/refine merging root commits that contain submodule gitlink changes, require each submodule commit to be reachable from the configured submodule remote main branch, not merely present on a feature ref or local checkout. If \`mesh_refine_node\` returns \`submodule_reachability_failed\` or publish-required evidence, keep the public convergence bucket as \`blocked_review\`; unless \`allowAutoPublishSubmoduleMainCommits\` is explicitly enabled and Refinery reports successful non-force publish plus post-publish verification, ask the user for explicit approval to push/publish the unreachable submodule commit(s) to submodule main, then rerun \`mesh_refine_node\`. Do not merge the root branch until the submodule commit(s) are reachable from submodule origin/main. A task that remains on a non-main branch is not fully complete unless the final report names the follow-up state and next step.
168
527
  8. **Clean up** — Remove worktree nodes via \`mesh_remove_node\` after their work is merged or no longer needed.
169
528
  9. **Report** — Summarize what was done, what changed, any issues, and the branch convergence state.
170
529
 
@@ -181,6 +540,29 @@ Follow these recovery rules:
181
540
  3. **If no recovery context**: The stop may be intentional (normal completion). Use \`mesh_read_chat\` once to verify, then move on.
182
541
  4. **Always record what happened**: After handling a failure, briefly note the outcome in your report to the user.`;
183
542
 
543
+ const ONBOARDING_SECTION = `## Onboarding / Reinit
544
+
545
+ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (or to **re-init / reconfigure** an already-onboarded repo), run ONE guided, approval-gated conversation. You draft, the user approves, the daemon writes. Never auto-write a heuristic suggestion without an explicit user approval turn.
546
+
547
+ **Save scopes — label every draft with its scope before asking for approval:**
548
+ - **repo-file (commit target)** — \`.adhdev/refine.json\`, \`.adhdev/worktree_bootstrap.json\`, \`.adhdev/change-impact.json\`, \`.adhdev/mesh.json\`. These are committed to the repository and shared with every machine/contributor.
549
+ - **machine-local** — MAGI kind→panel bindings and named MAGI panels, node providerPriority (\`~/.adhdev/meshes.json\`). These stay on this machine and are NOT committed.
550
+
551
+ **Guided sequence:**
552
+ 1. **Scan (dry-run)** — Call \`mesh_init\` (write=false, the default). It returns per-domain suggested configs for refine / worktree_bootstrap / change-impact, a recommended providerPriority, AND \`currentConfig\` — the currently-saved config per domain (repo files + machine-local \`magiKindPanels\`). Nothing is written.
553
+ 2. **Present drafts** — For each domain, show the user the suggested config with its **save scope label** (repo-file vs machine-local). When \`currentConfig\` already has a saved value for a domain (init on a partially-onboarded repo, or any reinit), present a **current-vs-suggested diff**, not just the suggestion.
554
+ 3. **Approve → gated write** — Only after the user approves, call the matching gated-write tool:
555
+ - repo \`.adhdev/*\` config files → \`mesh_init\` with \`write=true\` (and \`overwrite=true\` ONLY for domains the user approved replacing).
556
+ - \`.adhdev/mesh.json\` (coordinator prompt / operating notes) → \`mesh_write_mesh_json_config\` (write=true, overwrite only if approved).
557
+ - machine-local MAGI kind→panel slots → \`mesh_magi_kind_panel_set\` (write=true). NOTE: a kind binding is a **wholesale replacement** of that kind's slot list — present the current-vs-new slots first.
558
+ - machine-local named MAGI panels → \`mesh_magi_panel_set\`. providerPriority → apply via node policy update.
559
+
560
+ **init vs reinit:**
561
+ - **\`mesh_init\`** — for a fresh, never-onboarded repo. Existing config files are kept (existing-wins) unless the user explicitly approves overwrite. Use for first-time setup.
562
+ - **\`mesh_reinit\`** — for a repo that is already onboarded and needs its config refreshed. It re-suggests with OVERWRITE semantics and returns the current-vs-suggested \`currentConfig\` echo. Its first call is a DRY-RUN preview: you MUST present the per-section current-vs-suggested diff and get EXPLICIT per-section approval before re-invoking with write=true. Overwrite is a wholesale replacement, so it silently drops operator hand-edits if you skip the diff — never do that.
563
+
564
+ `;
565
+
184
566
  function buildRulesSection(coordinatorCliType?: string): string {
185
567
  const coordinatorNote = coordinatorCliType
186
568
  ? `\n- **Coordinator runtime is not a delegation default.** This coordinator is running as \`${coordinatorCliType}\`, but delegated node sessions must follow the user's requested provider, not the coordinator's own runtime.`
@@ -188,19 +570,19 @@ function buildRulesSection(coordinatorCliType?: string): string {
188
570
 
189
571
  return `## Rules
190
572
 
191
- - **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly delegate all of that to node agents. Your context should stay lean.
192
- - **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to the queue or a node. Do not do it yourself.
193
- - **Respect explicit provider requests.** If the user names an agent/provider, pass the matching provider type to \`mesh_launch_session\`: Hermes \`hermes-cli\`, Claude Code/Claude \`claude-cli\`, Codex \`codex-cli\`, Gemini \`gemini-cli\`. Never substitute \`claude-cli\` just because the coordinator itself is Claude Code.
194
- - **Front-load new task messages.** When calling \`mesh_enqueue_task\` or \`mesh_send_task\` for a new task, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
195
- - **Avoid context-wasting restarts.** For follow-up, retry, commit/push, preview, or cleanup work on the same issue, prefer the existing idle session and send only the delta from its last verified state. Start a fresh chat/session only for genuinely independent work, explicit provider/user request, unsafe transcript contamination, or required branch/worktree isolation.
196
- - **Don't inspect code.** Treat delegated agent summaries as self-reports, not verification. Verify side effects via \`mesh_git_status\` (including related repo freshness when configured), not by reading source files.
197
- - **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed. Never launch a duplicate session or second worker solely because \`mesh_read_chat\` has no final assistant message while the delegated session is still showing tool/terminal activity.
198
- - **Handle failures with context.** If a task fails, check \`mesh_task_history\` first to see if this task was attempted before and how it failed. Read the chat to understand why, then decide: retry on the same node, reassign to a different node, or escalate to the user.
199
- - **Check history before starting.** At the beginning of a coordination session, call \`mesh_task_history\` to understand what was previously delegated and its outcomes. This prevents duplicate work and informs recovery decisions.
200
- - **Keep the user informed.** Report progress after each delegation round — one or two sentences, not a narration.
201
- - **Respect node capabilities.** Don't send build tasks to read-only nodes. Don't push from nodes that aren't allowed to.
202
- - **Never fabricate tool results.** Always call the actual tool; never pretend you did.
203
- - **Clean up worktree nodes.** After a worktree task completes and its changes are merged or checkpointed, call \`mesh_remove_node\` to free resources.
204
- - **Do not strand completed branches.** A checkpointed or clean feature/worktree branch is not done by itself. Merge/refine it to the mesh default branch, or explicitly report one of \`pushed_feature_branch_needs_merge\`, \`blocked_review\`, \`cleanup_candidate\`, or \`not_mergeable\` with the next action.
205
- - **Name worktree branches meaningfully.** Use descriptive names like \`feat/auth-refactor\` or \`fix/build-123\`.${coordinatorNote}`;
573
+ - **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinatorkeep context lean.
574
+ - **Front-load task messages.** Include everything the agent needs (files, problem, expected fix) in \`mesh_enqueue_task\` / \`mesh_send_task\`. Append a structured result request at the end: ask the worker to conclude with a JSON block containing \`status\`, \`changedFiles\`, \`gitStatus\`, \`validationResults\`, \`errors\`, \`nextAction\`. The daemon parses this automatically; you can read it from \`mesh_task_history\`.
575
+ - **Reuse idle sessions.** For follow-up, retry, commit/push, or cleanup on the same issue, send only the delta to the existing idle session. Start fresh only for independent work, provider mismatch, transcript contamination, or required worktree isolation.
576
+ - **Respect explicit provider requests.** Map: Hermes \`hermes-cli\`, Claude/Claude Code \`claude-cli\`, Codex \`codex-cli\`, Gemini \`gemini-cli\`, Antigravity \`antigravity-cli\`. Never substitute the coordinator's own runtime.
577
+ - **Verify via git, not source.** Use \`mesh_git_status\` to confirm side effects. Treat agent summaries as self-reports, not verification.
578
+ - **Limit parallelism.** Start with 1–2 tasks; scale only on success. Never duplicate a session because \`mesh_read_chat\` shows no final message while tool/terminal activity is ongoing. This caps *concurrent* load — it does not mean serialize independent work: when a new, independent request arrives and there is headroom under \`maxParallelTasks\`, dispatch it right away rather than waiting for an in-flight task or a user nudge (read-only diagnosis especially, since it has no merge cost).
579
+ - **Check history first.** Call \`mesh_task_history\` at session start to avoid duplicate work and inform recovery. On failure, read task history before retrying.
580
+ - **Sequence shared-base-moving merges.** Parallel dispatch is encouraged, but merging one worktree can advance another in-flight worktree's base especially the oss submodule pointer — turning a clean fast-forward into a diverged rebase (patch-equivalence correctly blocks this). Before merging an in-flight worktree while siblings are also in flight, land in an intentional order, re-clone long-running worktrees from the advanced base, or expect to manually rebase + ff-only the laggards; merging an independent fix mid-flight can strand siblings into a rebase.
581
+ - **Converge branches.** After worktree tasks: refine/fast-forward, or classify as \`pushed_feature_branch_needs_merge\` / \`blocked_review\` / \`cleanup_candidate\` / \`not_mergeable\`. Clean up with \`mesh_remove_node\`.
582
+ - **Refinery is config-driven.** \`mesh_refine_node\` must run validation from \`.adhdev/refine.{json,yaml,yml}\` or \`repo-mesh.refine.*\`. Heuristics are scaffolding only.
583
+ - **Submodule reachability = publish-needed.** \`submodule_reachability_failed\` classify as \`blocked_review\`, request user approval to push to submodule main, then rerun \`mesh_refine_node\`.
584
+ - **Honor per-node instructions.** When a node carries a 📌 Node instruction in the nodes section, include the relevant parts of that instruction in the task message you send to that node. Don't paraphrase the instruction into your own words — quote it verbatim so the worker agent sees exactly what the user wrote.
585
+ - **Mission status does not update itself.** When a mission's tasks are all done or the work is abandoned, explicitly call \`mesh_mission_upsert\` to set status \`completed\` or \`abandoned\`. Never leave a finished mission in \`active\`. All-cancelled tasks with no further work → \`abandoned\`.
586
+ - **Never fabricate tool results.** Always call the actual tool.
587
+ - **Keep the user informed.** One or two sentences after each delegation round.${coordinatorNote}`;
206
588
  }