@wrongstack/core 0.284.0 → 0.285.0

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 (810) hide show
  1. package/dist/agent-status-tracker.d.ts +74 -0
  2. package/dist/agent-status-tracker.d.ts.map +1 -0
  3. package/dist/autophase/auto-phase-planner.d.ts +79 -0
  4. package/dist/autophase/auto-phase-planner.d.ts.map +1 -0
  5. package/dist/autophase/auto-phase-runner.d.ts +79 -0
  6. package/dist/autophase/auto-phase-runner.d.ts.map +1 -0
  7. package/dist/autophase/checkpoint.d.ts +49 -0
  8. package/dist/autophase/checkpoint.d.ts.map +1 -0
  9. package/dist/autophase/index.d.ts +9 -0
  10. package/dist/autophase/index.d.ts.map +1 -0
  11. package/dist/autophase/phase-graph-builder.d.ts +46 -0
  12. package/dist/autophase/phase-graph-builder.d.ts.map +1 -0
  13. package/dist/autophase/phase-orchestrator.d.ts +150 -0
  14. package/dist/autophase/phase-orchestrator.d.ts.map +1 -0
  15. package/dist/autophase/phase-store.d.ts +29 -0
  16. package/dist/autophase/phase-store.d.ts.map +1 -0
  17. package/dist/autophase/types.d.ts +329 -0
  18. package/dist/autophase/types.d.ts.map +1 -0
  19. package/dist/boot.d.ts +73 -0
  20. package/dist/boot.d.ts.map +1 -0
  21. package/dist/coordination/adaptive-concurrency.d.ts +63 -0
  22. package/dist/coordination/adaptive-concurrency.d.ts.map +1 -0
  23. package/dist/coordination/agent-bridge.d.ts +24 -0
  24. package/dist/coordination/agent-bridge.d.ts.map +1 -0
  25. package/dist/coordination/agent-monitor.d.ts +100 -0
  26. package/dist/coordination/agent-monitor.d.ts.map +1 -0
  27. package/dist/coordination/agent-subagent-runner.d.ts +74 -0
  28. package/dist/coordination/agent-subagent-runner.d.ts.map +1 -0
  29. package/dist/coordination/agents/agent-prompts.d.ts +2 -0
  30. package/dist/coordination/agents/agent-prompts.d.ts.map +1 -0
  31. package/dist/coordination/agents/index.d.ts +35 -0
  32. package/dist/coordination/agents/index.d.ts.map +1 -0
  33. package/dist/coordination/agents/phase1-discovery.d.ts +4 -0
  34. package/dist/coordination/agents/phase1-discovery.d.ts.map +1 -0
  35. package/dist/coordination/agents/phase2-planning.d.ts +4 -0
  36. package/dist/coordination/agents/phase2-planning.d.ts.map +1 -0
  37. package/dist/coordination/agents/phase3-build.d.ts +4 -0
  38. package/dist/coordination/agents/phase3-build.d.ts.map +1 -0
  39. package/dist/coordination/agents/phase3-techstack.d.ts +13 -0
  40. package/dist/coordination/agents/phase3-techstack.d.ts.map +1 -0
  41. package/dist/coordination/agents/phase4-verify.d.ts +4 -0
  42. package/dist/coordination/agents/phase4-verify.d.ts.map +1 -0
  43. package/dist/coordination/agents/phase5-review.d.ts +4 -0
  44. package/dist/coordination/agents/phase5-review.d.ts.map +1 -0
  45. package/dist/coordination/agents/phase6-domain.d.ts +4 -0
  46. package/dist/coordination/agents/phase6-domain.d.ts.map +1 -0
  47. package/dist/coordination/agents/phase7-knowledge.d.ts +4 -0
  48. package/dist/coordination/agents/phase7-knowledge.d.ts.map +1 -0
  49. package/dist/coordination/agents/phase8-delivery.d.ts +4 -0
  50. package/dist/coordination/agents/phase8-delivery.d.ts.map +1 -0
  51. package/dist/coordination/agents/phase9-meta.d.ts +4 -0
  52. package/dist/coordination/agents/phase9-meta.d.ts.map +1 -0
  53. package/dist/coordination/agents/types.d.ts +79 -0
  54. package/dist/coordination/agents/types.d.ts.map +1 -0
  55. package/dist/coordination/agents.d.ts +8 -0
  56. package/dist/coordination/agents.d.ts.map +1 -0
  57. package/dist/coordination/auto-extend.d.ts +46 -0
  58. package/dist/coordination/auto-extend.d.ts.map +1 -0
  59. package/dist/coordination/autonomous-brain.d.ts +154 -0
  60. package/dist/coordination/autonomous-brain.d.ts.map +1 -0
  61. package/dist/coordination/autonomous-coordinator.d.ts +239 -0
  62. package/dist/coordination/autonomous-coordinator.d.ts.map +1 -0
  63. package/dist/coordination/brain-monitor.d.ts +74 -0
  64. package/dist/coordination/brain-monitor.d.ts.map +1 -0
  65. package/dist/coordination/brain.d.ts +104 -0
  66. package/dist/coordination/brain.d.ts.map +1 -0
  67. package/dist/coordination/change-manager.d.ts +151 -0
  68. package/dist/coordination/change-manager.d.ts.map +1 -0
  69. package/dist/coordination/checkpoint-wiring.d.ts +61 -0
  70. package/dist/coordination/checkpoint-wiring.d.ts.map +1 -0
  71. package/dist/coordination/collab-bus.d.ts +132 -0
  72. package/dist/coordination/collab-bus.d.ts.map +1 -0
  73. package/dist/coordination/collab-debug.d.ts +302 -0
  74. package/dist/coordination/collab-debug.d.ts.map +1 -0
  75. package/dist/coordination/commit-safety.d.ts +72 -0
  76. package/dist/coordination/commit-safety.d.ts.map +1 -0
  77. package/dist/coordination/consensus-protocol.d.ts +106 -0
  78. package/dist/coordination/consensus-protocol.d.ts.map +1 -0
  79. package/dist/coordination/coordinator/error-classifier.d.ts +15 -0
  80. package/dist/coordination/coordinator/error-classifier.d.ts.map +1 -0
  81. package/dist/coordination/delegate-tool.d.ts +101 -0
  82. package/dist/coordination/delegate-tool.d.ts.map +1 -0
  83. package/dist/coordination/dep-watcher-bridge.d.ts +47 -0
  84. package/dist/coordination/dep-watcher-bridge.d.ts.map +1 -0
  85. package/dist/coordination/dep-watcher.d.ts +74 -0
  86. package/dist/coordination/dep-watcher.d.ts.map +1 -0
  87. package/dist/coordination/director/director-errors.d.ts +29 -0
  88. package/dist/coordination/director/director-errors.d.ts.map +1 -0
  89. package/dist/coordination/director-construction.d.ts +90 -0
  90. package/dist/coordination/director-construction.d.ts.map +1 -0
  91. package/dist/coordination/director-prompts.d.ts +119 -0
  92. package/dist/coordination/director-prompts.d.ts.map +1 -0
  93. package/dist/coordination/director-session.d.ts +68 -0
  94. package/dist/coordination/director-session.d.ts.map +1 -0
  95. package/dist/coordination/director-tools.d.ts +65 -0
  96. package/dist/coordination/director-tools.d.ts.map +1 -0
  97. package/dist/coordination/director.d.ts +802 -0
  98. package/dist/coordination/director.d.ts.map +1 -0
  99. package/dist/coordination/dispatcher.d.ts +82 -0
  100. package/dist/coordination/dispatcher.d.ts.map +1 -0
  101. package/dist/coordination/file-author-tracker.d.ts +76 -0
  102. package/dist/coordination/file-author-tracker.d.ts.map +1 -0
  103. package/dist/coordination/fleet-bus.d.ts +122 -0
  104. package/dist/coordination/fleet-bus.d.ts.map +1 -0
  105. package/dist/coordination/fleet-event-validation.d.ts +10 -0
  106. package/dist/coordination/fleet-event-validation.d.ts.map +1 -0
  107. package/dist/coordination/fleet-manager.d.ts +234 -0
  108. package/dist/coordination/fleet-manager.d.ts.map +1 -0
  109. package/dist/coordination/fleet-spawn.d.ts +102 -0
  110. package/dist/coordination/fleet-spawn.d.ts.map +1 -0
  111. package/dist/coordination/fleet-status-tool.d.ts +36 -0
  112. package/dist/coordination/fleet-status-tool.d.ts.map +1 -0
  113. package/dist/coordination/fleet-supervisor.d.ts +157 -0
  114. package/dist/coordination/fleet-supervisor.d.ts.map +1 -0
  115. package/dist/coordination/fleet.d.ts +96 -0
  116. package/dist/coordination/fleet.d.ts.map +1 -0
  117. package/dist/coordination/global-mailbox.d.ts +234 -0
  118. package/dist/coordination/global-mailbox.d.ts.map +1 -0
  119. package/dist/coordination/icoordinator.d.ts +97 -0
  120. package/dist/coordination/icoordinator.d.ts.map +1 -0
  121. package/dist/coordination/ifleet-manager.d.ts +177 -0
  122. package/dist/coordination/ifleet-manager.d.ts.map +1 -0
  123. package/dist/coordination/in-memory-transport.d.ts +12 -0
  124. package/dist/coordination/in-memory-transport.d.ts.map +1 -0
  125. package/dist/coordination/index.d.ts +78 -2587
  126. package/dist/coordination/index.d.ts.map +1 -0
  127. package/dist/coordination/index.js +739 -254
  128. package/dist/coordination/index.js.map +7 -1
  129. package/dist/coordination/knowledge-graph.d.ts +217 -0
  130. package/dist/coordination/knowledge-graph.d.ts.map +1 -0
  131. package/dist/coordination/large-answer-store.d.ts +61 -0
  132. package/dist/coordination/large-answer-store.d.ts.map +1 -0
  133. package/dist/coordination/mail-tools.d.ts +34 -0
  134. package/dist/coordination/mail-tools.d.ts.map +1 -0
  135. package/dist/coordination/mailbox-actions.d.ts +68 -0
  136. package/dist/coordination/mailbox-actions.d.ts.map +1 -0
  137. package/dist/coordination/mailbox-health.d.ts +131 -0
  138. package/dist/coordination/mailbox-health.d.ts.map +1 -0
  139. package/dist/coordination/mailbox-hooks.d.ts +55 -0
  140. package/dist/coordination/mailbox-hooks.d.ts.map +1 -0
  141. package/dist/coordination/mailbox-tool.d.ts +75 -0
  142. package/dist/coordination/mailbox-tool.d.ts.map +1 -0
  143. package/dist/{mailbox-types-BGZWrYTJ.d.ts → coordination/mailbox-types.d.ts} +37 -22
  144. package/dist/coordination/mailbox-types.d.ts.map +1 -0
  145. package/dist/coordination/mailbox.d.ts +69 -0
  146. package/dist/coordination/mailbox.d.ts.map +1 -0
  147. package/dist/coordination/model-matrix.d.ts +98 -0
  148. package/dist/coordination/model-matrix.d.ts.map +1 -0
  149. package/dist/coordination/multi-agent-coordinator.d.ts +202 -0
  150. package/dist/coordination/multi-agent-coordinator.d.ts.map +1 -0
  151. package/dist/coordination/null-fleet-bus.d.ts +10 -0
  152. package/dist/coordination/null-fleet-bus.d.ts.map +1 -0
  153. package/dist/coordination/package-author-tracker.d.ts +87 -0
  154. package/dist/coordination/package-author-tracker.d.ts.map +1 -0
  155. package/dist/coordination/package-outdated-watcher.d.ts +83 -0
  156. package/dist/coordination/package-outdated-watcher.d.ts.map +1 -0
  157. package/dist/coordination/single-instance-mailbox.d.ts +154 -0
  158. package/dist/coordination/single-instance-mailbox.d.ts.map +1 -0
  159. package/dist/coordination/spawn-budget.d.ts +6 -0
  160. package/dist/coordination/spawn-budget.d.ts.map +1 -0
  161. package/dist/coordination/subagent-budget.d.ts +323 -0
  162. package/dist/coordination/subagent-budget.d.ts.map +1 -0
  163. package/dist/coordination/subagent-nicknames.d.ts +42 -0
  164. package/dist/coordination/subagent-nicknames.d.ts.map +1 -0
  165. package/dist/coordination/subagent-result-tool.d.ts +20 -0
  166. package/dist/coordination/subagent-result-tool.d.ts.map +1 -0
  167. package/dist/coordination/task-auctioneer.d.ts +143 -0
  168. package/dist/coordination/task-auctioneer.d.ts.map +1 -0
  169. package/dist/coordination/task-dag.d.ts +147 -0
  170. package/dist/coordination/task-dag.d.ts.map +1 -0
  171. package/dist/coordination/techstack-mailbox-consumer.d.ts +50 -0
  172. package/dist/coordination/techstack-mailbox-consumer.d.ts.map +1 -0
  173. package/dist/coordination/transport.d.ts +2 -0
  174. package/dist/coordination/transport.d.ts.map +1 -0
  175. package/dist/coordination/worktree-task-runner.d.ts +45 -0
  176. package/dist/coordination/worktree-task-runner.d.ts.map +1 -0
  177. package/dist/core/agent-internals.d.ts +41 -0
  178. package/dist/core/agent-internals.d.ts.map +1 -0
  179. package/dist/core/agent-loop.d.ts +18 -0
  180. package/dist/core/agent-loop.d.ts.map +1 -0
  181. package/dist/core/agent-response.d.ts +21 -0
  182. package/dist/core/agent-response.d.ts.map +1 -0
  183. package/dist/core/agent-tools.d.ts +21 -0
  184. package/dist/core/agent-tools.d.ts.map +1 -0
  185. package/dist/core/agent-types.d.ts +95 -0
  186. package/dist/core/agent-types.d.ts.map +1 -0
  187. package/dist/core/agent.d.ts +54 -0
  188. package/dist/core/agent.d.ts.map +1 -0
  189. package/dist/core/btw.d.ts +40 -0
  190. package/dist/core/btw.d.ts.map +1 -0
  191. package/dist/core/context.d.ts +269 -0
  192. package/dist/core/context.d.ts.map +1 -0
  193. package/dist/core/continue-intent.d.ts +92 -0
  194. package/dist/core/continue-intent.d.ts.map +1 -0
  195. package/dist/core/continue-to-next-iteration.d.ts +96 -0
  196. package/dist/core/continue-to-next-iteration.d.ts.map +1 -0
  197. package/dist/core/conversation-state.d.ts +96 -0
  198. package/dist/core/conversation-state.d.ts.map +1 -0
  199. package/dist/core/fallback-model.d.ts +94 -0
  200. package/dist/core/fallback-model.d.ts.map +1 -0
  201. package/dist/core/fleet-pulse.d.ts +42 -0
  202. package/dist/core/fleet-pulse.d.ts.map +1 -0
  203. package/dist/core/input-builder.d.ts +95 -0
  204. package/dist/core/input-builder.d.ts.map +1 -0
  205. package/dist/core/instruction-bundle.d.ts +22 -0
  206. package/dist/core/instruction-bundle.d.ts.map +1 -0
  207. package/dist/core/iteration-limit.d.ts +35 -0
  208. package/dist/core/iteration-limit.d.ts.map +1 -0
  209. package/dist/core/mailbox-loop.d.ts +63 -0
  210. package/dist/core/mailbox-loop.d.ts.map +1 -0
  211. package/dist/core/modes/brief.d.ts +2 -0
  212. package/dist/core/modes/brief.d.ts.map +1 -0
  213. package/dist/core/modes/default.d.ts +8 -0
  214. package/dist/core/modes/default.d.ts.map +1 -0
  215. package/dist/core/modes/teach.d.ts +2 -0
  216. package/dist/core/modes/teach.d.ts.map +1 -0
  217. package/dist/core/provider-runner.d.ts +24 -0
  218. package/dist/core/provider-runner.d.ts.map +1 -0
  219. package/dist/core/queued-messages.d.ts +55 -0
  220. package/dist/core/queued-messages.d.ts.map +1 -0
  221. package/dist/core/run-env.d.ts +49 -0
  222. package/dist/core/run-env.d.ts.map +1 -0
  223. package/dist/core/streaming-response-builder.d.ts +78 -0
  224. package/dist/core/streaming-response-builder.d.ts.map +1 -0
  225. package/dist/core/system-prompt-builder.d.ts +213 -0
  226. package/dist/core/system-prompt-builder.d.ts.map +1 -0
  227. package/dist/defaults/index.d.ts +68 -158
  228. package/dist/defaults/index.d.ts.map +1 -0
  229. package/dist/defaults/index.js +1257 -819
  230. package/dist/defaults/index.js.map +7 -1
  231. package/dist/execution/auto-compaction-middleware.d.ts +123 -0
  232. package/dist/execution/auto-compaction-middleware.d.ts.map +1 -0
  233. package/dist/execution/autonomous-runner.d.ts +55 -0
  234. package/dist/execution/autonomous-runner.d.ts.map +1 -0
  235. package/dist/execution/autonomy-brain.d.ts +90 -0
  236. package/dist/execution/autonomy-brain.d.ts.map +1 -0
  237. package/dist/execution/autonomy-prompt-contributor.d.ts +39 -0
  238. package/dist/execution/autonomy-prompt-contributor.d.ts.map +1 -0
  239. package/dist/execution/compaction-core.d.ts +103 -0
  240. package/dist/execution/compaction-core.d.ts.map +1 -0
  241. package/dist/execution/compactor.d.ts +56 -0
  242. package/dist/execution/compactor.d.ts.map +1 -0
  243. package/dist/execution/design-color.d.ts +31 -0
  244. package/dist/execution/design-color.d.ts.map +1 -0
  245. package/dist/execution/design-detect.d.ts +96 -0
  246. package/dist/execution/design-detect.d.ts.map +1 -0
  247. package/dist/execution/design-kit-loader.d.ts +53 -0
  248. package/dist/execution/design-kit-loader.d.ts.map +1 -0
  249. package/dist/execution/design-materialize.d.ts +32 -0
  250. package/dist/execution/design-materialize.d.ts.map +1 -0
  251. package/dist/execution/design-project-store.d.ts +57 -0
  252. package/dist/execution/design-project-store.d.ts.map +1 -0
  253. package/dist/execution/design-verify.d.ts +44 -0
  254. package/dist/execution/design-verify.d.ts.map +1 -0
  255. package/dist/execution/error-handler.d.ts +34 -0
  256. package/dist/execution/error-handler.d.ts.map +1 -0
  257. package/dist/{parallel-eternal-engine-HUrtePLd.d.ts → execution/eternal-autonomy.d.ts} +10 -225
  258. package/dist/execution/eternal-autonomy.d.ts.map +1 -0
  259. package/dist/execution/goal-preamble.d.ts +2 -0
  260. package/dist/execution/goal-preamble.d.ts.map +1 -0
  261. package/dist/execution/index.d.ts +21 -180
  262. package/dist/execution/index.d.ts.map +1 -0
  263. package/dist/execution/index.js +465 -180
  264. package/dist/execution/index.js.map +7 -1
  265. package/dist/execution/intelligent-compactor.d.ts +85 -0
  266. package/dist/execution/intelligent-compactor.d.ts.map +1 -0
  267. package/dist/execution/model-runtime.d.ts +75 -0
  268. package/dist/execution/model-runtime.d.ts.map +1 -0
  269. package/dist/execution/parallel-eternal-engine.d.ts +130 -0
  270. package/dist/execution/parallel-eternal-engine.d.ts.map +1 -0
  271. package/dist/execution/prompt-enhancer.d.ts +12 -13
  272. package/dist/execution/prompt-enhancer.d.ts.map +1 -0
  273. package/dist/execution/prompt-enhancer.js +13 -7
  274. package/dist/execution/prompt-enhancer.js.map +7 -1
  275. package/dist/execution/prompt-loader.d.ts +52 -0
  276. package/dist/execution/prompt-loader.d.ts.map +1 -0
  277. package/dist/execution/provider-runner-impl.d.ts +14 -0
  278. package/dist/execution/provider-runner-impl.d.ts.map +1 -0
  279. package/dist/execution/regex-patterns.d.ts +7 -0
  280. package/dist/execution/regex-patterns.d.ts.map +1 -0
  281. package/dist/execution/retry-policy.d.ts +35 -0
  282. package/dist/execution/retry-policy.d.ts.map +1 -0
  283. package/dist/execution/selective-compactor.d.ts +94 -0
  284. package/dist/execution/selective-compactor.d.ts.map +1 -0
  285. package/dist/execution/skill-loader.d.ts +43 -0
  286. package/dist/execution/skill-loader.d.ts.map +1 -0
  287. package/dist/execution/strategy-compactor.d.ts +43 -0
  288. package/dist/execution/strategy-compactor.d.ts.map +1 -0
  289. package/dist/execution/tool-executor.d.ts +112 -0
  290. package/dist/execution/tool-executor.d.ts.map +1 -0
  291. package/dist/extension/extension-points.d.ts +121 -0
  292. package/dist/extension/extension-points.d.ts.map +1 -0
  293. package/dist/extension/index.d.ts +3 -10
  294. package/dist/extension/index.d.ts.map +1 -0
  295. package/dist/extension/index.js +59 -5
  296. package/dist/extension/index.js.map +7 -1
  297. package/dist/extension/registry.d.ts +86 -0
  298. package/dist/extension/registry.d.ts.map +1 -0
  299. package/dist/fleet-notifier.d.ts +28 -0
  300. package/dist/fleet-notifier.d.ts.map +1 -0
  301. package/dist/hooks/http-executor.d.ts +11 -0
  302. package/dist/hooks/http-executor.d.ts.map +1 -0
  303. package/dist/hooks/index.d.ts +10 -0
  304. package/dist/hooks/index.d.ts.map +1 -0
  305. package/dist/hooks/registry.d.ts +71 -0
  306. package/dist/hooks/registry.d.ts.map +1 -0
  307. package/dist/hooks/runner.d.ts +65 -0
  308. package/dist/hooks/runner.d.ts.map +1 -0
  309. package/dist/hooks/shell-executor.d.ts +33 -0
  310. package/dist/hooks/shell-executor.d.ts.map +1 -0
  311. package/dist/hooks/shell-hooks-equal.d.ts +15 -0
  312. package/dist/hooks/shell-hooks-equal.d.ts.map +1 -0
  313. package/dist/hq/agent-bridge.d.ts +27 -0
  314. package/dist/hq/agent-bridge.d.ts.map +1 -0
  315. package/dist/hq/alerts.d.ts +67 -0
  316. package/dist/hq/alerts.d.ts.map +1 -0
  317. package/dist/hq/auth-store.d.ts +161 -0
  318. package/dist/hq/auth-store.d.ts.map +1 -0
  319. package/dist/hq/brain-bridge.d.ts +37 -0
  320. package/dist/hq/brain-bridge.d.ts.map +1 -0
  321. package/dist/hq/commands.d.ts +122 -0
  322. package/dist/hq/commands.d.ts.map +1 -0
  323. package/dist/hq/cost-bridge.d.ts +36 -0
  324. package/dist/hq/cost-bridge.d.ts.map +1 -0
  325. package/dist/hq/factory.d.ts +66 -0
  326. package/dist/hq/factory.d.ts.map +1 -0
  327. package/dist/hq/fleet-bridge.d.ts +39 -0
  328. package/dist/hq/fleet-bridge.d.ts.map +1 -0
  329. package/dist/hq/index.d.ts +18 -816
  330. package/dist/hq/index.d.ts.map +1 -0
  331. package/dist/hq/index.js +417 -122
  332. package/dist/hq/index.js.map +7 -1
  333. package/dist/hq/mailbox-mapper.d.ts +27 -0
  334. package/dist/hq/mailbox-mapper.d.ts.map +1 -0
  335. package/dist/hq/persistence.d.ts +121 -0
  336. package/dist/hq/persistence.d.ts.map +1 -0
  337. package/dist/hq/protocol.d.ts +560 -0
  338. package/dist/hq/protocol.d.ts.map +1 -0
  339. package/dist/hq/publisher.d.ts +177 -0
  340. package/dist/hq/publisher.d.ts.map +1 -0
  341. package/dist/hq/redaction.d.ts +30 -0
  342. package/dist/hq/redaction.d.ts.map +1 -0
  343. package/dist/hq/session-bridge.d.ts +29 -0
  344. package/dist/hq/session-bridge.d.ts.map +1 -0
  345. package/dist/hq/tool-bridge.d.ts +41 -0
  346. package/dist/hq/tool-bridge.d.ts.map +1 -0
  347. package/dist/hq/transcript-mapper.d.ts +36 -0
  348. package/dist/hq/transcript-mapper.d.ts.map +1 -0
  349. package/dist/hq/worktree-bridge.d.ts +34 -0
  350. package/dist/hq/worktree-bridge.d.ts.map +1 -0
  351. package/dist/index.d.ts +108 -2872
  352. package/dist/index.d.ts.map +1 -0
  353. package/dist/index.js +2724 -1344
  354. package/dist/index.js.map +7 -1
  355. package/dist/infrastructure/context-manager.d.ts +92 -0
  356. package/dist/infrastructure/context-manager.d.ts.map +1 -0
  357. package/dist/infrastructure/index.d.ts +6 -64
  358. package/dist/infrastructure/index.d.ts.map +1 -0
  359. package/dist/infrastructure/index.js +39 -12
  360. package/dist/infrastructure/index.js.map +7 -1
  361. package/dist/infrastructure/logger.d.ts +99 -0
  362. package/dist/infrastructure/logger.d.ts.map +1 -0
  363. package/dist/infrastructure/mcp-servers.d.ts +83 -0
  364. package/dist/infrastructure/mcp-servers.d.ts.map +1 -0
  365. package/dist/{path-resolver-CMS5307d.d.ts → infrastructure/path-resolver.d.ts} +3 -5
  366. package/dist/infrastructure/path-resolver.d.ts.map +1 -0
  367. package/dist/infrastructure/token-counter.d.ts +57 -0
  368. package/dist/infrastructure/token-counter.d.ts.map +1 -0
  369. package/dist/kernel/container.d.ts +84 -0
  370. package/dist/kernel/container.d.ts.map +1 -0
  371. package/dist/{events-Bgnh43r9.d.ts → kernel/events.d.ts} +112 -206
  372. package/dist/kernel/events.d.ts.map +1 -0
  373. package/dist/kernel/index.d.ts +6 -107
  374. package/dist/kernel/index.d.ts.map +1 -0
  375. package/dist/kernel/index.js +56 -4
  376. package/dist/kernel/index.js.map +7 -1
  377. package/dist/kernel/pipeline.d.ts +105 -0
  378. package/dist/kernel/pipeline.d.ts.map +1 -0
  379. package/dist/kernel/run-controller.d.ts +55 -0
  380. package/dist/kernel/run-controller.d.ts.map +1 -0
  381. package/dist/kernel/tokens.d.ts +53 -0
  382. package/dist/kernel/tokens.d.ts.map +1 -0
  383. package/dist/mailbox-attach.d.ts +27 -0
  384. package/dist/mailbox-attach.d.ts.map +1 -0
  385. package/dist/middleware/collab-pause.d.ts +73 -0
  386. package/dist/middleware/collab-pause.d.ts.map +1 -0
  387. package/dist/models/codex-catalog.d.ts +41 -0
  388. package/dist/models/codex-catalog.d.ts.map +1 -0
  389. package/dist/models/index.d.ts +8 -163
  390. package/dist/models/index.d.ts.map +1 -0
  391. package/dist/models/index.js +150 -51
  392. package/dist/models/index.js.map +7 -1
  393. package/dist/models/llm-selector.d.ts +47 -0
  394. package/dist/models/llm-selector.d.ts.map +1 -0
  395. package/dist/models/mode-store.d.ts +22 -0
  396. package/dist/models/mode-store.d.ts.map +1 -0
  397. package/dist/models/model-intelligence.d.ts +56 -0
  398. package/dist/models/model-intelligence.d.ts.map +1 -0
  399. package/dist/models/model-router.d.ts +100 -0
  400. package/dist/models/model-router.d.ts.map +1 -0
  401. package/dist/models/models-registry.d.ts +106 -0
  402. package/dist/models/models-registry.d.ts.map +1 -0
  403. package/dist/models/provider-model-resolve.d.ts +69 -0
  404. package/dist/models/provider-model-resolve.d.ts.map +1 -0
  405. package/dist/observability/event-bridge.d.ts +10 -0
  406. package/dist/observability/event-bridge.d.ts.map +1 -0
  407. package/dist/observability/health.d.ts +18 -0
  408. package/dist/observability/health.d.ts.map +1 -0
  409. package/dist/observability/index.d.ts +9 -354
  410. package/dist/observability/index.d.ts.map +1 -0
  411. package/dist/observability/index.js +21 -8
  412. package/dist/observability/index.js.map +7 -1
  413. package/dist/observability/metrics.d.ts +26 -0
  414. package/dist/observability/metrics.d.ts.map +1 -0
  415. package/dist/observability/otel-tracer.d.ts +41 -0
  416. package/dist/observability/otel-tracer.d.ts.map +1 -0
  417. package/dist/observability/otlp-metrics.d.ts +111 -0
  418. package/dist/observability/otlp-metrics.d.ts.map +1 -0
  419. package/dist/observability/otlp-traces.d.ts +95 -0
  420. package/dist/observability/otlp-traces.d.ts.map +1 -0
  421. package/dist/observability/prometheus.d.ts +49 -0
  422. package/dist/observability/prometheus.d.ts.map +1 -0
  423. package/dist/observability/tracer.d.ts +9 -0
  424. package/dist/observability/tracer.d.ts.map +1 -0
  425. package/dist/plugin/api.d.ts +226 -0
  426. package/dist/plugin/api.d.ts.map +1 -0
  427. package/dist/plugin/loader.d.ts +73 -0
  428. package/dist/plugin/loader.d.ts.map +1 -0
  429. package/dist/plugins/chimera-plugin.d.ts +37 -0
  430. package/dist/plugins/chimera-plugin.d.ts.map +1 -0
  431. package/dist/plugins/git-plugin.d.ts +15 -0
  432. package/dist/plugins/git-plugin.d.ts.map +1 -0
  433. package/dist/plugins/observability-plugin.d.ts +19 -0
  434. package/dist/plugins/observability-plugin.d.ts.map +1 -0
  435. package/dist/plugins/plan-plugin.d.ts +16 -0
  436. package/dist/plugins/plan-plugin.d.ts.map +1 -0
  437. package/dist/plugins/prompts-plugin.d.ts +26 -0
  438. package/dist/plugins/prompts-plugin.d.ts.map +1 -0
  439. package/dist/plugins/security-plugin.d.ts +19 -0
  440. package/dist/plugins/security-plugin.d.ts.map +1 -0
  441. package/dist/plugins/skills-plugin.d.ts +42 -0
  442. package/dist/plugins/skills-plugin.d.ts.map +1 -0
  443. package/dist/plugins/sync-plugin.d.ts +22 -0
  444. package/dist/plugins/sync-plugin.d.ts.map +1 -0
  445. package/dist/prompts/index.d.ts +3 -0
  446. package/dist/prompts/index.d.ts.map +1 -0
  447. package/dist/prompts/prompt-installer.d.ts +50 -0
  448. package/dist/prompts/prompt-installer.d.ts.map +1 -0
  449. package/dist/prompts/prompt-manifest-store.d.ts +18 -0
  450. package/dist/prompts/prompt-manifest-store.d.ts.map +1 -0
  451. package/dist/registry/provider-registry.d.ts +51 -0
  452. package/dist/registry/provider-registry.d.ts.map +1 -0
  453. package/dist/registry/slash-command-registry.d.ts +61 -0
  454. package/dist/registry/slash-command-registry.d.ts.map +1 -0
  455. package/dist/registry/tool-registry.d.ts +154 -0
  456. package/dist/registry/tool-registry.d.ts.map +1 -0
  457. package/dist/replay/hash.d.ts +31 -0
  458. package/dist/replay/hash.d.ts.map +1 -0
  459. package/dist/replay/replay-provider-runner.d.ts +53 -0
  460. package/dist/replay/replay-provider-runner.d.ts.map +1 -0
  461. package/dist/{index-CbyuOE5y.d.ts → security/capabilities.d.ts} +31 -34
  462. package/dist/security/capabilities.d.ts.map +1 -0
  463. package/dist/security/config-secrets.d.ts +25 -0
  464. package/dist/security/config-secrets.d.ts.map +1 -0
  465. package/dist/security/index.d.ts +6 -8
  466. package/dist/security/index.d.ts.map +1 -0
  467. package/dist/security/index.js +102 -381
  468. package/dist/security/index.js.map +7 -1
  469. package/dist/security/permission-policy.d.ts +153 -0
  470. package/dist/security/permission-policy.d.ts.map +1 -0
  471. package/dist/security/secret-scrubber.d.ts +14 -0
  472. package/dist/security/secret-scrubber.d.ts.map +1 -0
  473. package/dist/security/secret-vault.d.ts +87 -0
  474. package/dist/security/secret-vault.d.ts.map +1 -0
  475. package/dist/security/yolo-risk.d.ts +11 -0
  476. package/dist/security/yolo-risk.d.ts.map +1 -0
  477. package/dist/{session-registry-Dvg7i_IA.d.ts → session-registry.d.ts} +8 -9
  478. package/dist/session-registry.d.ts.map +1 -0
  479. package/dist/skills/foreign-sources.d.ts +59 -0
  480. package/dist/skills/foreign-sources.d.ts.map +1 -0
  481. package/dist/skills/frontmatter.d.ts +44 -0
  482. package/dist/skills/frontmatter.d.ts.map +1 -0
  483. package/dist/skills/github-fetcher.d.ts +38 -0
  484. package/dist/skills/github-fetcher.d.ts.map +1 -0
  485. package/dist/skills/index.d.ts +11 -582
  486. package/dist/skills/index.d.ts.map +1 -0
  487. package/dist/skills/index.js +81 -43
  488. package/dist/skills/index.js.map +7 -1
  489. package/dist/skills/limits.d.ts +92 -0
  490. package/dist/skills/limits.d.ts.map +1 -0
  491. package/dist/skills/manifest-store.d.ts +42 -0
  492. package/dist/skills/manifest-store.d.ts.map +1 -0
  493. package/dist/skills/registry/github-direct-adapter.d.ts +17 -0
  494. package/dist/skills/registry/github-direct-adapter.d.ts.map +1 -0
  495. package/dist/skills/registry/registry-adapter.d.ts +84 -0
  496. package/dist/skills/registry/registry-adapter.d.ts.map +1 -0
  497. package/dist/skills/registry/skills-sh-adapter.d.ts +13 -0
  498. package/dist/skills/registry/skills-sh-adapter.d.ts.map +1 -0
  499. package/dist/skills/skill-generator.d.ts +82 -0
  500. package/dist/skills/skill-generator.d.ts.map +1 -0
  501. package/dist/skills/skill-installer.d.ts +124 -0
  502. package/dist/skills/skill-installer.d.ts.map +1 -0
  503. package/dist/storage/annotations-store.d.ts +118 -0
  504. package/dist/storage/annotations-store.d.ts.map +1 -0
  505. package/dist/storage/attachment-store.d.ts +31 -0
  506. package/dist/storage/attachment-store.d.ts.map +1 -0
  507. package/dist/storage/cloud-sync.d.ts +44 -0
  508. package/dist/storage/cloud-sync.d.ts.map +1 -0
  509. package/dist/storage/completed-work-checkpoint.d.ts +11 -0
  510. package/dist/storage/completed-work-checkpoint.d.ts.map +1 -0
  511. package/dist/storage/config-loader.d.ts +104 -0
  512. package/dist/storage/config-loader.d.ts.map +1 -0
  513. package/dist/storage/config-migration.d.ts +87 -0
  514. package/dist/storage/config-migration.d.ts.map +1 -0
  515. package/dist/storage/config-store.d.ts +22 -0
  516. package/dist/storage/config-store.d.ts.map +1 -0
  517. package/dist/{director-state-CMS_bMs4.d.ts → storage/director-state.d.ts} +28 -8
  518. package/dist/storage/director-state.d.ts.map +1 -0
  519. package/dist/storage/file-session-writer.d.ts +169 -0
  520. package/dist/storage/file-session-writer.d.ts.map +1 -0
  521. package/dist/{goal-store-Datpp-ar.d.ts → storage/goal-store.d.ts} +26 -19
  522. package/dist/storage/goal-store.d.ts.map +1 -0
  523. package/dist/storage/index.d.ts +39 -1031
  524. package/dist/storage/index.d.ts.map +1 -0
  525. package/dist/storage/index.js +655 -300
  526. package/dist/storage/index.js.map +7 -1
  527. package/dist/storage/input-history-store.d.ts +56 -0
  528. package/dist/storage/input-history-store.d.ts.map +1 -0
  529. package/dist/storage/memory-backend.d.ts +66 -0
  530. package/dist/storage/memory-backend.d.ts.map +1 -0
  531. package/dist/storage/memory-consolidator.d.ts +50 -0
  532. package/dist/storage/memory-consolidator.d.ts.map +1 -0
  533. package/dist/storage/memory-graph-backend.d.ts +117 -0
  534. package/dist/storage/memory-graph-backend.d.ts.map +1 -0
  535. package/dist/storage/memory-store.d.ts +119 -0
  536. package/dist/storage/memory-store.d.ts.map +1 -0
  537. package/dist/storage/plan-store.d.ts +78 -0
  538. package/dist/storage/plan-store.d.ts.map +1 -0
  539. package/dist/storage/plan-templates.d.ts +21 -0
  540. package/dist/storage/plan-templates.d.ts.map +1 -0
  541. package/dist/storage/prompt-store.d.ts +37 -0
  542. package/dist/storage/prompt-store.d.ts.map +1 -0
  543. package/dist/storage/prompt-usage-store.d.ts +29 -0
  544. package/dist/storage/prompt-usage-store.d.ts.map +1 -0
  545. package/dist/storage/provider-config-watcher.d.ts +34 -0
  546. package/dist/storage/provider-config-watcher.d.ts.map +1 -0
  547. package/dist/storage/queue-store.d.ts +37 -0
  548. package/dist/storage/queue-store.d.ts.map +1 -0
  549. package/dist/storage/recovery-lock.d.ts +79 -0
  550. package/dist/storage/recovery-lock.d.ts.map +1 -0
  551. package/dist/storage/replay-log-store.d.ts +97 -0
  552. package/dist/storage/replay-log-store.d.ts.map +1 -0
  553. package/dist/storage/session-analyzer.d.ts +48 -0
  554. package/dist/storage/session-analyzer.d.ts.map +1 -0
  555. package/dist/storage/session-checkpoint-cas.d.ts +37 -0
  556. package/dist/storage/session-checkpoint-cas.d.ts.map +1 -0
  557. package/dist/{session-event-bridge-D_z_mBwk.d.ts → storage/session-event-bridge.d.ts} +14 -15
  558. package/dist/storage/session-event-bridge.d.ts.map +1 -0
  559. package/dist/storage/session-helpers.d.ts +9 -0
  560. package/dist/storage/session-helpers.d.ts.map +1 -0
  561. package/dist/storage/session-id.d.ts +18 -0
  562. package/dist/storage/session-id.d.ts.map +1 -0
  563. package/dist/storage/session-reader.d.ts +21 -0
  564. package/dist/storage/session-reader.d.ts.map +1 -0
  565. package/dist/storage/session-recovery.d.ts +93 -0
  566. package/dist/storage/session-recovery.d.ts.map +1 -0
  567. package/dist/storage/session-resume-validation.d.ts +6 -0
  568. package/dist/storage/session-resume-validation.d.ts.map +1 -0
  569. package/dist/storage/session-rewinder.d.ts +21 -0
  570. package/dist/storage/session-rewinder.d.ts.map +1 -0
  571. package/dist/storage/session-store.d.ts +210 -0
  572. package/dist/storage/session-store.d.ts.map +1 -0
  573. package/dist/storage/session-summary.d.ts +12 -0
  574. package/dist/storage/session-summary.d.ts.map +1 -0
  575. package/dist/storage/session-tool-call-ends.d.ts +5 -0
  576. package/dist/storage/session-tool-call-ends.d.ts.map +1 -0
  577. package/dist/storage/storage-concurrency.d.ts +2 -0
  578. package/dist/storage/storage-concurrency.d.ts.map +1 -0
  579. package/dist/storage/task-store.d.ts +33 -0
  580. package/dist/storage/task-store.d.ts.map +1 -0
  581. package/dist/storage/todos-checkpoint.d.ts +39 -0
  582. package/dist/storage/todos-checkpoint.d.ts.map +1 -0
  583. package/dist/storage/tool-audit-log.d.ts +141 -0
  584. package/dist/storage/tool-audit-log.d.ts.map +1 -0
  585. package/dist/tasking/index.d.ts +3 -124
  586. package/dist/tasking/index.d.ts.map +1 -0
  587. package/dist/tasking/index.js +57 -4
  588. package/dist/tasking/index.js.map +7 -1
  589. package/dist/tasking/task-store.d.ts +22 -0
  590. package/dist/tasking/task-store.d.ts.map +1 -0
  591. package/dist/tasking/task-tracker.d.ts +102 -0
  592. package/dist/tasking/task-tracker.d.ts.map +1 -0
  593. package/dist/tools/index.d.ts +2 -59
  594. package/dist/tools/index.d.ts.map +1 -0
  595. package/dist/tools/index.js +93 -14
  596. package/dist/tools/index.js.map +7 -1
  597. package/dist/tools/mcp-control.d.ts +53 -0
  598. package/dist/tools/mcp-control.d.ts.map +1 -0
  599. package/dist/tools/mcp-use.d.ts +24 -0
  600. package/dist/tools/mcp-use.d.ts.map +1 -0
  601. package/dist/types/agent-bridge.d.ts +42 -0
  602. package/dist/types/agent-bridge.d.ts.map +1 -0
  603. package/dist/types/attachment.d.ts +54 -0
  604. package/dist/types/attachment.d.ts.map +1 -0
  605. package/dist/types/autonomy.d.ts +5 -0
  606. package/dist/types/autonomy.d.ts.map +1 -0
  607. package/dist/types/blocks.d.ts +76 -0
  608. package/dist/types/blocks.d.ts.map +1 -0
  609. package/dist/{compactor-DQLL4HTo.d.ts → types/compactor.d.ts} +5 -7
  610. package/dist/types/compactor.d.ts.map +1 -0
  611. package/dist/{config-MRqn1V-u.d.ts → types/config.d.ts} +135 -354
  612. package/dist/types/config.d.ts.map +1 -0
  613. package/dist/types/context-evidence.d.ts +68 -0
  614. package/dist/types/context-evidence.d.ts.map +1 -0
  615. package/dist/types/context-window.d.ts +35 -0
  616. package/dist/types/context-window.d.ts.map +1 -0
  617. package/dist/{default-config-B79_gJYv.d.ts → types/default-config.d.ts} +10 -11
  618. package/dist/types/default-config.d.ts.map +1 -0
  619. package/dist/types/design-kit.d.ts +91 -0
  620. package/dist/types/design-kit.d.ts.map +1 -0
  621. package/dist/{retry-policy-CQ7KwXJa.d.ts → types/error-handler.d.ts} +5 -12
  622. package/dist/types/error-handler.d.ts.map +1 -0
  623. package/dist/types/errors.d.ts +277 -0
  624. package/dist/types/errors.d.ts.map +1 -0
  625. package/dist/types/hooks.d.ts +167 -0
  626. package/dist/types/hooks.d.ts.map +1 -0
  627. package/dist/types/index.d.ts +40 -244
  628. package/dist/types/index.d.ts.map +1 -0
  629. package/dist/types/index.js +90 -12
  630. package/dist/types/index.js.map +7 -1
  631. package/dist/{input-reader-E-ffP2ee.d.ts → types/input-reader.d.ts} +3 -4
  632. package/dist/types/input-reader.d.ts.map +1 -0
  633. package/dist/{logger-B63L5bTg.d.ts → types/logger.d.ts} +3 -4
  634. package/dist/types/logger.d.ts.map +1 -0
  635. package/dist/types/memory.d.ts +89 -0
  636. package/dist/types/memory.d.ts.map +1 -0
  637. package/dist/types/messages.d.ts +24 -0
  638. package/dist/types/messages.d.ts.map +1 -0
  639. package/dist/types/mode-prompts.d.ts +2 -0
  640. package/dist/types/mode-prompts.d.ts.map +1 -0
  641. package/dist/{mode-CZlO9iU1.d.ts → types/mode.d.ts} +6 -7
  642. package/dist/types/mode.d.ts.map +1 -0
  643. package/dist/types/models-registry.d.ts +105 -0
  644. package/dist/types/models-registry.d.ts.map +1 -0
  645. package/dist/types/multi-agent.d.ts +435 -0
  646. package/dist/types/multi-agent.d.ts.map +1 -0
  647. package/dist/{observability-D-HZN_mF.d.ts → types/observability.d.ts} +12 -13
  648. package/dist/types/observability.d.ts.map +1 -0
  649. package/dist/{path-resolver-CPRj4bFY.d.ts → types/path-resolver.d.ts} +2 -3
  650. package/dist/types/path-resolver.d.ts.map +1 -0
  651. package/dist/{permission-ByDKXEcG.d.ts → types/permission.d.ts} +8 -9
  652. package/dist/types/permission.d.ts.map +1 -0
  653. package/dist/types/plugin.d.ts +385 -0
  654. package/dist/types/plugin.d.ts.map +1 -0
  655. package/dist/types/prompt-registry.d.ts +81 -0
  656. package/dist/types/prompt-registry.d.ts.map +1 -0
  657. package/dist/{prompt-DLd35n4Q.d.ts → types/prompt.d.ts} +14 -15
  658. package/dist/types/prompt.d.ts.map +1 -0
  659. package/dist/{provider-runner-ChL-kVg6.d.ts → types/provider-runner.d.ts} +9 -10
  660. package/dist/types/provider-runner.d.ts.map +1 -0
  661. package/dist/types/provider.d.ts +387 -0
  662. package/dist/types/provider.d.ts.map +1 -0
  663. package/dist/types/renderer.d.ts +23 -0
  664. package/dist/types/renderer.d.ts.map +1 -0
  665. package/dist/types/retry-policy.d.ts +7 -0
  666. package/dist/types/retry-policy.d.ts.map +1 -0
  667. package/dist/types/secret-scrubber.d.ts +5 -0
  668. package/dist/types/secret-scrubber.d.ts.map +1 -0
  669. package/dist/{secret-vault-BAKpgFw_.d.ts → types/secret-vault.d.ts} +13 -7
  670. package/dist/types/secret-vault.d.ts.map +1 -0
  671. package/dist/{selector-D8O6B_Rm.d.ts → types/selector.d.ts} +4 -6
  672. package/dist/types/selector.d.ts.map +1 -0
  673. package/dist/types/session-reader.d.ts +81 -0
  674. package/dist/types/session-reader.d.ts.map +1 -0
  675. package/dist/{session-rewinder-C9HnMkhP.d.ts → types/session-rewinder.d.ts} +5 -6
  676. package/dist/types/session-rewinder.d.ts.map +1 -0
  677. package/dist/types/session.d.ts +650 -0
  678. package/dist/types/session.d.ts.map +1 -0
  679. package/dist/types/side-effect.d.ts +34 -0
  680. package/dist/types/side-effect.d.ts.map +1 -0
  681. package/dist/{skill-DHniprNl.d.ts → types/skill.d.ts} +4 -5
  682. package/dist/types/skill.d.ts.map +1 -0
  683. package/dist/types/slash-command.d.ts +59 -0
  684. package/dist/types/slash-command.d.ts.map +1 -0
  685. package/dist/types/spec.d.ts +77 -0
  686. package/dist/types/spec.d.ts.map +1 -0
  687. package/dist/types/system-prompt-contributor.d.ts +20 -0
  688. package/dist/types/system-prompt-contributor.d.ts.map +1 -0
  689. package/dist/types/system-prompt.d.ts +51 -0
  690. package/dist/types/system-prompt.d.ts.map +1 -0
  691. package/dist/{task-graph-CH3acNQ7.d.ts → types/task-graph.d.ts} +21 -22
  692. package/dist/types/task-graph.d.ts.map +1 -0
  693. package/dist/types/token-counter.d.ts +42 -0
  694. package/dist/types/token-counter.d.ts.map +1 -0
  695. package/dist/types/tool-executor.d.ts +133 -0
  696. package/dist/types/tool-executor.d.ts.map +1 -0
  697. package/dist/types/tool-markers.d.ts +23 -0
  698. package/dist/types/tool-markers.d.ts.map +1 -0
  699. package/dist/types/tool.d.ts +245 -0
  700. package/dist/types/tool.d.ts.map +1 -0
  701. package/dist/types/utility-types.d.ts +31 -0
  702. package/dist/types/utility-types.d.ts.map +1 -0
  703. package/dist/utils/assert-never.d.ts +14 -0
  704. package/dist/utils/assert-never.d.ts.map +1 -0
  705. package/dist/utils/atomic-write.d.ts +12 -0
  706. package/dist/utils/atomic-write.d.ts.map +1 -0
  707. package/dist/utils/child-env.d.ts +67 -0
  708. package/dist/utils/child-env.d.ts.map +1 -0
  709. package/dist/utils/color.d.ts +20 -0
  710. package/dist/utils/color.d.ts.map +1 -0
  711. package/dist/utils/config-json.d.ts +14 -0
  712. package/dist/utils/config-json.d.ts.map +1 -0
  713. package/dist/utils/context-evidence.d.ts +47 -0
  714. package/dist/utils/context-evidence.d.ts.map +1 -0
  715. package/dist/utils/deep-merge.d.ts +64 -0
  716. package/dist/utils/deep-merge.d.ts.map +1 -0
  717. package/dist/utils/diff.d.ts +11 -0
  718. package/dist/utils/diff.d.ts.map +1 -0
  719. package/dist/utils/error.d.ts +2 -3
  720. package/dist/utils/error.d.ts.map +1 -0
  721. package/dist/utils/error.js +3 -3
  722. package/dist/utils/error.js.map +7 -1
  723. package/dist/utils/expect-defined.d.ts +2 -3
  724. package/dist/utils/expect-defined.d.ts.map +1 -0
  725. package/dist/utils/expect-defined.js +3 -3
  726. package/dist/utils/expect-defined.js.map +7 -1
  727. package/dist/utils/glob-expand.d.ts +10 -0
  728. package/dist/utils/glob-expand.d.ts.map +1 -0
  729. package/dist/utils/glob-match.d.ts +4 -0
  730. package/dist/utils/glob-match.d.ts.map +1 -0
  731. package/dist/utils/index.d.ts +37 -920
  732. package/dist/utils/index.d.ts.map +1 -0
  733. package/dist/utils/index.js +242 -33
  734. package/dist/utils/index.js.map +7 -1
  735. package/dist/utils/instruction-file.d.ts +3 -0
  736. package/dist/utils/instruction-file.d.ts.map +1 -0
  737. package/dist/utils/ip-guard.d.ts +34 -0
  738. package/dist/utils/ip-guard.d.ts.map +1 -0
  739. package/dist/utils/json-repair.d.ts +23 -0
  740. package/dist/utils/json-repair.d.ts.map +1 -0
  741. package/dist/utils/json-schema-validate.d.ts +42 -0
  742. package/dist/utils/json-schema-validate.d.ts.map +1 -0
  743. package/dist/utils/lru-cache.d.ts +29 -0
  744. package/dist/utils/lru-cache.d.ts.map +1 -0
  745. package/dist/utils/merge-custom-models.d.ts +12 -0
  746. package/dist/utils/merge-custom-models.d.ts.map +1 -0
  747. package/dist/utils/merge-models-payload.d.ts +20 -0
  748. package/dist/utils/merge-models-payload.d.ts.map +1 -0
  749. package/dist/utils/message-invariants.d.ts +22 -0
  750. package/dist/utils/message-invariants.d.ts.map +1 -0
  751. package/dist/utils/newline-normalize.d.ts +5 -0
  752. package/dist/utils/newline-normalize.d.ts.map +1 -0
  753. package/dist/utils/regex-guard.d.ts +21 -0
  754. package/dist/utils/regex-guard.d.ts.map +1 -0
  755. package/dist/utils/safe-json.d.ts +31 -0
  756. package/dist/utils/safe-json.d.ts.map +1 -0
  757. package/dist/utils/session-scoped-path.d.ts +13 -0
  758. package/dist/utils/session-scoped-path.d.ts.map +1 -0
  759. package/dist/utils/sleep.d.ts +5 -0
  760. package/dist/utils/sleep.d.ts.map +1 -0
  761. package/dist/utils/slug.d.ts +13 -0
  762. package/dist/utils/slug.d.ts.map +1 -0
  763. package/dist/utils/string.d.ts +9 -0
  764. package/dist/utils/string.d.ts.map +1 -0
  765. package/dist/utils/task-format.d.ts +22 -0
  766. package/dist/utils/task-format.d.ts.map +1 -0
  767. package/dist/utils/term.d.ts +133 -0
  768. package/dist/utils/term.d.ts.map +1 -0
  769. package/dist/utils/todos-format.d.ts +30 -0
  770. package/dist/utils/todos-format.d.ts.map +1 -0
  771. package/dist/utils/token-estimate.d.ts +112 -0
  772. package/dist/utils/token-estimate.d.ts.map +1 -0
  773. package/dist/utils/tool-description-mode.d.ts +28 -0
  774. package/dist/utils/tool-description-mode.d.ts.map +1 -0
  775. package/dist/utils/tool-output-serializer.d.ts +40 -0
  776. package/dist/utils/tool-output-serializer.d.ts.map +1 -0
  777. package/dist/utils/tool-result-render-mode.d.ts +55 -0
  778. package/dist/utils/tool-result-render-mode.d.ts.map +1 -0
  779. package/dist/utils/tool-subject.d.ts +5 -0
  780. package/dist/utils/tool-subject.d.ts.map +1 -0
  781. package/dist/utils/tool-wire-compact.d.ts +28 -0
  782. package/dist/utils/tool-wire-compact.d.ts.map +1 -0
  783. package/dist/utils/ulid.d.ts +11 -0
  784. package/dist/utils/ulid.d.ts.map +1 -0
  785. package/dist/{wstack-paths-C3K40Qst.d.ts → utils/wstack-paths.d.ts} +7 -8
  786. package/dist/utils/wstack-paths.d.ts.map +1 -0
  787. package/dist/worktree/index.d.ts +2 -0
  788. package/dist/worktree/index.d.ts.map +1 -0
  789. package/dist/{worktree-manager-DzwxKE35.d.ts → worktree/worktree-manager.d.ts} +19 -13
  790. package/dist/worktree/worktree-manager.d.ts.map +1 -0
  791. package/instructions/autonomy/active-mission.md +2 -4
  792. package/instructions/sections/tool/delegation-full.md +1 -1
  793. package/package.json +4 -5
  794. package/skills/node-modern/SKILL.md +2 -2
  795. package/skills/plugin-author/SKILL.md +9 -16
  796. package/dist/dispatcher-types.d-BBeXBQgS.d.ts +0 -66
  797. package/dist/global-mailbox-sZwyI6CS.d.ts +0 -959
  798. package/dist/index--Gm41aBJ.d.ts +0 -671
  799. package/dist/mcp-servers-DEV4s6Ks.d.ts +0 -259
  800. package/dist/multi-agent-coordinator-4RCRZKjN.d.ts +0 -1770
  801. package/dist/null-fleet-bus-CFoNVQEK.d.ts +0 -2127
  802. package/dist/pipeline-DGDyIohT.d.ts +0 -331
  803. package/dist/provider-model-resolve-o2hHLs79.d.ts +0 -263
  804. package/dist/secret-scrubber-3MHDDAtm.d.ts +0 -6
  805. package/dist/secret-vault-DxohkUBc.d.ts +0 -272
  806. package/dist/session-reader-7Esxrkpw.d.ts +0 -155
  807. package/dist/task-format-GX0B1mMC.d.ts +0 -23
  808. package/dist/todos-checkpoint-FY7PjmMx.d.ts +0 -850
  809. package/dist/tool-BNlnIJvo.d.ts +0 -2190
  810. package/dist/tool-executor-CckSCM5E.d.ts +0 -906
@@ -1,29 +1,22 @@
1
- import { randomUUID, createHash, randomBytes } from 'crypto';
2
- import * as fsp9 from 'fs/promises';
3
- import * as path9 from 'path';
4
- import { isAbsolute, resolve } from 'path';
5
- import * as os from 'os';
6
- import { hostname } from 'os';
7
- import { readFileSync, statSync, createReadStream, openSync, writeSync, fsyncSync, closeSync } from 'fs';
8
- import { fileURLToPath } from 'url';
9
- import { EventEmitter } from 'events';
10
- import { listReadyTasks, claimReadyTask, updateTaskAssignment } from '@wrongstack/kanban';
11
- import { createInterface } from 'readline';
12
- import { execFileSync, spawn } from 'child_process';
13
-
14
1
  // src/coordination/agent-bridge.ts
2
+ import { randomUUID } from "node:crypto";
3
+
4
+ // src/utils/atomic-write.ts
5
+ import { randomBytes } from "node:crypto";
6
+ import * as fs from "node:fs/promises";
7
+ import * as path from "node:path";
15
8
  async function atomicWrite(targetPath, content, opts = {}) {
16
- const dir = path9.dirname(targetPath);
17
- await fsp9.mkdir(dir, { recursive: true });
18
- const tmp = path9.join(dir, `.${path9.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
9
+ const dir = path.dirname(targetPath);
10
+ await fs.mkdir(dir, { recursive: true });
11
+ const tmp = path.join(dir, `.${path.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
19
12
  try {
20
13
  if (typeof content === "string") {
21
- await fsp9.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
14
+ await fs.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
22
15
  } else {
23
- await fsp9.writeFile(tmp, content, { flag: "wx" });
16
+ await fs.writeFile(tmp, content, { flag: "wx" });
24
17
  }
25
18
  try {
26
- const fh = await fsp9.open(tmp, "r+");
19
+ const fh = await fs.open(tmp, "r+");
27
20
  try {
28
21
  await fh.sync();
29
22
  } finally {
@@ -33,56 +26,56 @@ async function atomicWrite(targetPath, content, opts = {}) {
33
26
  }
34
27
  let mode;
35
28
  try {
36
- const stat9 = await fsp9.stat(targetPath);
29
+ const stat9 = await fs.stat(targetPath);
37
30
  mode = stat9.mode & 511;
38
31
  } catch {
39
32
  mode = opts.mode;
40
33
  }
41
34
  if (mode !== void 0) {
42
- await fsp9.chmod(tmp, mode);
35
+ await fs.chmod(tmp, mode);
43
36
  }
44
37
  await renameWithRetry(tmp, targetPath);
45
38
  if (mode !== void 0 && process.platform === "win32") {
46
39
  try {
47
- await fsp9.chmod(targetPath, mode);
40
+ await fs.chmod(targetPath, mode);
48
41
  } catch {
49
42
  }
50
43
  }
51
44
  } catch (err) {
52
45
  try {
53
- await fsp9.unlink(tmp);
46
+ await fs.unlink(tmp);
54
47
  } catch {
55
48
  }
56
49
  throw err;
57
50
  }
58
51
  }
59
52
  async function ensureDir(dir) {
60
- await fsp9.mkdir(dir, { recursive: true });
53
+ await fs.mkdir(dir, { recursive: true });
61
54
  }
62
55
  async function withFileLock(targetPath, fn, opts = {}) {
63
- const dir = path9.dirname(targetPath);
64
- await fsp9.mkdir(dir, { recursive: true });
65
- const lockPath = path9.join(dir, `.${path9.basename(targetPath)}.lock`);
56
+ const dir = path.dirname(targetPath);
57
+ await fs.mkdir(dir, { recursive: true });
58
+ const lockPath = path.join(dir, `.${path.basename(targetPath)}.lock`);
66
59
  const timeoutMs = opts.timeoutMs ?? 5e3;
67
60
  const staleMs = opts.staleMs ?? 3e4;
68
61
  const started = Date.now();
69
62
  let handle;
70
63
  for (; ; ) {
71
64
  try {
72
- handle = await fsp9.open(lockPath, "wx");
65
+ handle = await fs.open(lockPath, "wx");
73
66
  await handle.writeFile(`${process.pid}:${Date.now()}`);
74
67
  break;
75
68
  } catch (err) {
76
69
  const code = err.code;
77
70
  if (code === "ENOENT") {
78
- await fsp9.mkdir(dir, { recursive: true });
71
+ await fs.mkdir(dir, { recursive: true });
79
72
  continue;
80
73
  }
81
74
  if (code !== "EEXIST") throw err;
82
75
  try {
83
- const stat9 = await fsp9.stat(lockPath);
76
+ const stat9 = await fs.stat(lockPath);
84
77
  if (Date.now() - stat9.mtimeMs > staleMs) {
85
- await fsp9.unlink(lockPath);
78
+ await fs.unlink(lockPath);
86
79
  continue;
87
80
  }
88
81
  } catch {
@@ -107,7 +100,7 @@ async function withFileLock(targetPath, fn, opts = {}) {
107
100
  } catch {
108
101
  }
109
102
  try {
110
- await fsp9.unlink(lockPath);
103
+ await fs.unlink(lockPath);
111
104
  } catch {
112
105
  }
113
106
  }
@@ -115,14 +108,14 @@ async function withFileLock(targetPath, fn, opts = {}) {
115
108
  var TRANSIENT_RENAME_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES", "ENOTEMPTY"]);
116
109
  async function renameWithRetry(from, to) {
117
110
  if (process.platform !== "win32") {
118
- await fsp9.rename(from, to);
111
+ await fs.rename(from, to);
119
112
  return;
120
113
  }
121
114
  const delays = [10, 25, 60, 120, 250];
122
115
  let lastErr;
123
116
  for (let i = 0; i <= delays.length; i++) {
124
117
  try {
125
- await fsp9.rename(from, to);
118
+ await fs.rename(from, to);
126
119
  return;
127
120
  } catch (err) {
128
121
  lastErr = err;
@@ -210,8 +203,9 @@ function sanitizeNodeOptions(value) {
210
203
  }
211
204
  return kept.join(" ");
212
205
  }
206
+ var gitIdentity = null;
213
207
  function buildChildEnv(optsOrSessionId) {
214
- const opts = {};
208
+ const opts = typeof optsOrSessionId === "string" ? { sessionId: optsOrSessionId } : optsOrSessionId ?? {};
215
209
  const hasOwn = Object.hasOwn(process.env, "WRONGSTACK_CHILD_ENV_PASSTHROUGH");
216
210
  const legacyHasOwn = Object.hasOwn(process.env, "WRONGSTACK_BASH_ENV_PASSTHROUGH");
217
211
  const passthrough = hasOwn && process.env["WRONGSTACK_CHILD_ENV_PASSTHROUGH"] === "1" || legacyHasOwn && process.env["WRONGSTACK_BASH_ENV_PASSTHROUGH"] === "1";
@@ -249,6 +243,16 @@ function buildChildEnv(optsOrSessionId) {
249
243
  out[k] = v;
250
244
  }
251
245
  }
246
+ if (gitIdentity) {
247
+ if (gitIdentity.name) {
248
+ out["GIT_AUTHOR_NAME"] = gitIdentity.name;
249
+ out["GIT_COMMITTER_NAME"] = gitIdentity.name;
250
+ }
251
+ if (gitIdentity.email) {
252
+ out["GIT_AUTHOR_EMAIL"] = gitIdentity.email;
253
+ out["GIT_COMMITTER_EMAIL"] = gitIdentity.email;
254
+ }
255
+ }
252
256
  if (opts.extra) {
253
257
  Object.assign(out, opts.extra);
254
258
  }
@@ -264,12 +268,16 @@ function toErrorMessage(err) {
264
268
  // src/utils/expect-defined.ts
265
269
  function expectDefined(value, label) {
266
270
  if (value === null || value === void 0) {
267
- const err = new Error("Expected value to be defined");
271
+ const err = new Error(label ? `Expected ${label} to be defined` : "Expected value to be defined");
268
272
  err.name = "ExpectDefinedError";
269
273
  throw err;
270
274
  }
271
275
  return value;
272
276
  }
277
+
278
+ // src/utils/glob-expand.ts
279
+ import * as fsp from "node:fs/promises";
280
+ import { isAbsolute, resolve } from "node:path";
273
281
  var GLOB_CHARS = /* @__PURE__ */ new Set(["*", "?", "["]);
274
282
  var IS_WINDOWS = process.platform === "win32";
275
283
  var SEP = IS_WINDOWS ? "\\" : "/";
@@ -335,7 +343,7 @@ async function expandGlob(pattern) {
335
343
  async function walk(dir, pat) {
336
344
  let entries;
337
345
  try {
338
- entries = await fsp9.readdir(dir);
346
+ entries = await fsp.readdir(dir);
339
347
  } catch {
340
348
  return;
341
349
  }
@@ -357,7 +365,7 @@ async function expandGlob(pattern) {
357
365
  for (const e of entries) {
358
366
  const full = `${dir}${SEP}${e}`;
359
367
  try {
360
- const stat9 = await fsp9.stat(full);
368
+ const stat9 = await fsp.stat(full);
361
369
  if (stat9.isDirectory()) await walk(full, rest);
362
370
  } catch {
363
371
  }
@@ -375,7 +383,7 @@ async function expandGlob(pattern) {
375
383
  if (entries.includes(seg)) {
376
384
  const full = `${dir}${SEP}${seg}`;
377
385
  try {
378
- const stat9 = await fsp9.stat(full);
386
+ const stat9 = await fsp.stat(full);
379
387
  if (stat9.isDirectory()) await walk(full, rest);
380
388
  } catch {
381
389
  }
@@ -513,13 +521,16 @@ function safeStringify(value, pretty = false) {
513
521
  });
514
522
  }
515
523
  }
524
+
525
+ // src/utils/session-scoped-path.ts
526
+ import * as path2 from "node:path";
516
527
  function sessionScopedPath(dir, sessionId, suffix) {
517
528
  if (!sessionId || sessionId.includes("\\") || sessionId.includes("..")) {
518
529
  throw invalid(sessionId);
519
530
  }
520
- const resolved = path9.resolve(dir, `${sessionId}${suffix}`);
521
- const rel = path9.relative(path9.resolve(dir), resolved);
522
- if (rel.startsWith("..") || path9.isAbsolute(rel)) {
531
+ const resolved = path2.resolve(dir, `${sessionId}${suffix}`);
532
+ const rel = path2.relative(path2.resolve(dir), resolved);
533
+ if (rel.startsWith("..") || path2.isAbsolute(rel)) {
523
534
  throw invalid(sessionId);
524
535
  }
525
536
  return resolved;
@@ -532,6 +543,9 @@ function invalid(sessionId) {
532
543
  context: { reason: "path_traversal" }
533
544
  });
534
545
  }
546
+
547
+ // src/utils/ulid.ts
548
+ import { randomBytes as randomBytes2 } from "node:crypto";
535
549
  var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
536
550
  var ENCODING_LEN = ENCODING.length;
537
551
  var TIME_LEN = 10;
@@ -547,7 +561,7 @@ function encodeTime(now, len) {
547
561
  return str;
548
562
  }
549
563
  function encodeRandom(len) {
550
- const bytes = randomBytes(len);
564
+ const bytes = randomBytes2(len);
551
565
  let str = "";
552
566
  for (let i = 0; i < len; i++) {
553
567
  str += ENCODING[bytes[i] % ENCODING_LEN];
@@ -562,9 +576,14 @@ function ulid(seedTime = Date.now()) {
562
576
  function truncate(s, max) {
563
577
  return s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
564
578
  }
579
+
580
+ // src/utils/wstack-paths.ts
581
+ import { createHash } from "node:crypto";
582
+ import * as os from "node:os";
583
+ import * as path3 from "node:path";
565
584
  function projectSlug(absRoot) {
566
- const base = slugify(path9.basename(absRoot));
567
- const hash = createHash("sha256").update(path9.resolve(absRoot)).digest("hex").slice(0, 6);
585
+ const base = slugify(path3.basename(absRoot));
586
+ const hash = createHash("sha256").update(path3.resolve(absRoot)).digest("hex").slice(0, 6);
568
587
  return `${base}-${hash}`;
569
588
  }
570
589
  function slugify(name) {
@@ -572,8 +591,8 @@ function slugify(name) {
572
591
  }
573
592
  function wstackGlobalRoot() {
574
593
  const fromEnv = process.env["WRONGSTACK_HOME"];
575
- if (fromEnv && fromEnv.trim().length > 0) return path9.resolve(fromEnv);
576
- return path9.join(os.homedir(), ".wrongstack");
594
+ if (fromEnv && fromEnv.trim().length > 0) return path3.resolve(fromEnv);
595
+ return path3.join(os.homedir(), ".wrongstack");
577
596
  }
578
597
 
579
598
  // src/types/errors.ts
@@ -586,13 +605,53 @@ var ERROR_CODES = {
586
605
  PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
587
606
  PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
588
607
  PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW",
608
+ // Tool
609
+ TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
610
+ TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED",
611
+ TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED",
612
+ TOOL_TIMEOUT: "TOOL_TIMEOUT",
613
+ TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
614
+ // Config
615
+ CONFIG_INVALID: "CONFIG_INVALID",
616
+ CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
617
+ CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED",
618
+ CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED",
619
+ // Plugin
620
+ PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED",
621
+ PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH",
622
+ PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
589
623
  // Agent
590
624
  AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
625
+ AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW",
591
626
  AGENT_ABORTED: "AGENT_ABORTED",
592
627
  AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
628
+ // Session
629
+ SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
630
+ SESSION_CORRUPTED: "SESSION_CORRUPTED",
631
+ SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED",
632
+ // Container / Registry
633
+ CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
634
+ CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
635
+ CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY",
636
+ REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
637
+ REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
638
+ REGISTRY_INVALID: "REGISTRY_INVALID",
593
639
  // File system
594
640
  FS_READ_FAILED: "FS_READ_FAILED",
595
- FS_DELETE_FAILED: "FS_DELETE_FAILED"};
641
+ FS_WRITE_FAILED: "FS_WRITE_FAILED",
642
+ FS_MKDIR_FAILED: "FS_MKDIR_FAILED",
643
+ FS_DELETE_FAILED: "FS_DELETE_FAILED",
644
+ FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED",
645
+ // SDD (Spec-Driven Development)
646
+ SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED",
647
+ SDD_PARSE_FAILED: "SDD_PARSE_FAILED",
648
+ SDD_INVALID_STATE: "SDD_INVALID_STATE",
649
+ SDD_NOT_READY: "SDD_NOT_READY",
650
+ // General
651
+ VALIDATION_ERROR: "VALIDATION_ERROR",
652
+ PARSE_FAILED: "PARSE_FAILED",
653
+ UNKNOWN: "UNKNOWN"
654
+ };
596
655
  var WrongStackError = class extends Error {
597
656
  code;
598
657
  subsystem;
@@ -1271,10 +1330,30 @@ var ToolCapabilities = {
1271
1330
  SHELL_RESTRICTED: "shell.restricted",
1272
1331
  /** Can run a restricted project formatter/linter-style command. */
1273
1332
  SHELL_EXEC: "shell.exec",
1333
+ /** Can read files inside the project (and possibly outside via symlinks if not guarded). */
1334
+ FS_READ: "fs.read",
1274
1335
  /** Can write / modify / delete files inside the project. */
1275
1336
  FS_WRITE: "fs.write",
1276
1337
  /** Can write files outside the current project root (very high risk). */
1277
1338
  FS_WRITE_OUTSIDE_PROJECT: "fs.write.outside-project",
1339
+ /** Can perform outbound network requests. */
1340
+ NET_OUTBOUND: "net.outbound",
1341
+ /** Can mutate in-memory session todos only. */
1342
+ SESSION_TODO: "session.todo",
1343
+ /** Can mutate in-memory session mode only. */
1344
+ SESSION_MODE: "session.mode",
1345
+ /** Can inspect registered tool metadata. */
1346
+ TOOL_META: "tool.meta",
1347
+ /** Can invoke arbitrary registered tools through a meta-tool. */
1348
+ TOOL_MUTATE_ANY: "tool.mutate.any",
1349
+ /** Can read persistent memory. */
1350
+ MEMORY_READ: "memory.read",
1351
+ /** Can write persistent memory. */
1352
+ MEMORY_WRITE: "memory.write",
1353
+ /** Can delete persistent memory. */
1354
+ MEMORY_DELETE: "memory.delete",
1355
+ /** Proxies tools from external MCP servers (unknown capability). */
1356
+ MCP_PROXY: "mcp.proxy",
1278
1357
  /** Can spawn or manage subagents / multi-agent tasks. */
1279
1358
  SUBAGENT_SPAWN: "subagent.spawn",
1280
1359
  /** Can inspect fleet/subagent coordination state without mutating it. */
@@ -1285,9 +1364,43 @@ var ToolCapabilities = {
1285
1364
  COORDINATION_RESULT_SUBMIT: "coordination.result.submit",
1286
1365
  /** Can read or write inter-agent mailbox messages. */
1287
1366
  COORDINATION_MAIL: "coordination.mail",
1367
+ /** Can schedule, inspect, or cancel in-session cron jobs. */
1368
+ COORDINATION_CRON: "coordination.cron",
1369
+ /** Can mutate global or session configuration / trust state. */
1370
+ CONFIG_MUTATE: "config.mutate",
1288
1371
  /** Can install packages or run package managers with side effects. */
1289
1372
  PACKAGE_INSTALL: "package.install"
1290
1373
  };
1374
+ var DANGEROUS_FOR_SUBAGENTS = [
1375
+ ToolCapabilities.SHELL_ARBITRARY,
1376
+ ToolCapabilities.SHELL_RESTRICTED,
1377
+ ToolCapabilities.SHELL_EXEC,
1378
+ ToolCapabilities.FS_WRITE,
1379
+ ToolCapabilities.FS_WRITE_OUTSIDE_PROJECT,
1380
+ ToolCapabilities.TOOL_MUTATE_ANY,
1381
+ ToolCapabilities.MEMORY_WRITE,
1382
+ ToolCapabilities.MEMORY_DELETE,
1383
+ ToolCapabilities.MCP_PROXY,
1384
+ ToolCapabilities.SUBAGENT_SPAWN,
1385
+ ToolCapabilities.CONFIG_MUTATE,
1386
+ ToolCapabilities.PACKAGE_INSTALL
1387
+ ];
1388
+ var WIDE_SUBAGENT_CAPABILITIES = [
1389
+ ToolCapabilities.FS_READ,
1390
+ ToolCapabilities.FS_WRITE,
1391
+ ToolCapabilities.NET_OUTBOUND,
1392
+ ToolCapabilities.SESSION_TODO,
1393
+ ToolCapabilities.TOOL_META,
1394
+ ToolCapabilities.MEMORY_READ,
1395
+ ToolCapabilities.SHELL_ARBITRARY,
1396
+ ToolCapabilities.SHELL_RESTRICTED,
1397
+ ToolCapabilities.SHELL_EXEC,
1398
+ ToolCapabilities.PACKAGE_INSTALL,
1399
+ // Read-only fleet visibility (fleet_status) — peer awareness has no blast
1400
+ // radius and every fleet worker should coordinate around its peers.
1401
+ ToolCapabilities.COORDINATION_FLEET_READ,
1402
+ ToolCapabilities.COORDINATION_RESULT_SUBMIT
1403
+ ];
1291
1404
 
1292
1405
  // src/coordination/subagent-result-tool.ts
1293
1406
  var SUBAGENT_STRUCTURED_REPORT_META_KEY = "subagentStructuredReport";
@@ -1685,6 +1798,12 @@ var TOOLS = {
1685
1798
  /** Web research. */
1686
1799
  research: ["read", "grep", "glob", "search", "fetch", "mailbox"]
1687
1800
  };
1801
+
1802
+ // src/coordination/agents/agent-prompts.ts
1803
+ import { readFileSync, statSync } from "node:fs";
1804
+ import * as os2 from "node:os";
1805
+ import * as path4 from "node:path";
1806
+ import { fileURLToPath } from "node:url";
1688
1807
  var promptCache = /* @__PURE__ */ new Map();
1689
1808
  var candidateCache = /* @__PURE__ */ new Map();
1690
1809
  function agentPrompt(id) {
@@ -1696,7 +1815,7 @@ function agentPrompt(id) {
1696
1815
  let resolved = "";
1697
1816
  for (const dir of agentPromptDirCandidates(envDir)) {
1698
1817
  try {
1699
- resolved = readFileSync(path9.join(dir, fileName), "utf8").trimEnd();
1818
+ resolved = readFileSync(path4.join(dir, fileName), "utf8").trimEnd();
1700
1819
  break;
1701
1820
  } catch {
1702
1821
  }
@@ -1705,20 +1824,20 @@ function agentPrompt(id) {
1705
1824
  return resolved;
1706
1825
  }
1707
1826
  function agentPromptDirCandidates(envDir) {
1708
- const globalRoot = process.env["WRONGSTACK_HOME"] || path9.join(os.homedir(), ".wrongstack");
1827
+ const globalRoot = process.env["WRONGSTACK_HOME"] || path4.join(os2.homedir(), ".wrongstack");
1709
1828
  const candKey = `${envDir}\0${globalRoot}`;
1710
1829
  const cached = candidateCache.get(candKey);
1711
1830
  if (cached !== void 0) return cached;
1712
- const here = path9.dirname(fileURLToPath(import.meta.url));
1831
+ const here = path4.dirname(fileURLToPath(import.meta.url));
1713
1832
  const explicitDir = envDir || void 0;
1714
1833
  const candidates = [
1715
- ...explicitDir ? [path9.resolve(explicitDir)] : [],
1716
- path9.join(globalRoot, "instructions", "agents"),
1717
- path9.resolve(here, "../../../../instructions/agents"),
1718
- path9.resolve(here, "../../../instructions/agents"),
1719
- path9.resolve(here, "../../instructions/agents"),
1720
- path9.resolve(here, "../instructions/agents"),
1721
- path9.resolve(here, "instructions/agents")
1834
+ ...explicitDir ? [path4.resolve(explicitDir)] : [],
1835
+ path4.join(globalRoot, "instructions", "agents"),
1836
+ path4.resolve(here, "../../../../instructions/agents"),
1837
+ path4.resolve(here, "../../../instructions/agents"),
1838
+ path4.resolve(here, "../../instructions/agents"),
1839
+ path4.resolve(here, "../instructions/agents"),
1840
+ path4.resolve(here, "instructions/agents")
1722
1841
  ];
1723
1842
  const ordered = candidates.sort((a, b) => Number(!isDirectory(a)) - Number(!isDirectory(b)));
1724
1843
  candidateCache.set(candKey, ordered);
@@ -3430,6 +3549,9 @@ function formatHumanPrompt(request) {
3430
3549
  lines.push("", `Risk: ${request.risk}`);
3431
3550
  return lines.join("\n");
3432
3551
  }
3552
+
3553
+ // src/coordination/brain-monitor.ts
3554
+ import { randomUUID as randomUUID2 } from "node:crypto";
3433
3555
  var BrainMonitor = class {
3434
3556
  constructor(opts) {
3435
3557
  this.opts = opts;
@@ -3502,7 +3624,7 @@ var BrainMonitor = class {
3502
3624
  this.lastEngagedAt.set(kind, Date.now());
3503
3625
  try {
3504
3626
  const request = {
3505
- id: `brainmon-${randomUUID()}`,
3627
+ id: `brainmon-${randomUUID2()}`,
3506
3628
  sessionId: this.opts.sessionId?.(),
3507
3629
  source: "system",
3508
3630
  question: input.question,
@@ -3565,6 +3687,11 @@ var BrainMonitor = class {
3565
3687
  }
3566
3688
  };
3567
3689
 
3690
+ // src/coordination/collab-debug.ts
3691
+ import { EventEmitter } from "node:events";
3692
+ import * as fsp2 from "node:fs/promises";
3693
+ import { randomUUID as randomUUID3 } from "node:crypto";
3694
+
3568
3695
  // src/coordination/fleet-event-validation.ts
3569
3696
  var ROLE_BY_EVENT = {
3570
3697
  "bug.found": "bug-hunter",
@@ -3721,7 +3848,7 @@ var CollabSession = class extends EventEmitter {
3721
3848
  _timeoutTimer;
3722
3849
  constructor(director, fleetBus, options) {
3723
3850
  super();
3724
- this.sessionId = randomUUID();
3851
+ this.sessionId = randomUUID3();
3725
3852
  this.options = options;
3726
3853
  this.director = director;
3727
3854
  this.fleetBus = fleetBus;
@@ -3783,8 +3910,8 @@ var CollabSession = class extends EventEmitter {
3783
3910
  for (const filePath of allFiles) {
3784
3911
  try {
3785
3912
  const [content, stat9] = await Promise.all([
3786
- fsp9.readFile(filePath, "utf8"),
3787
- fsp9.stat(filePath)
3913
+ fsp2.readFile(filePath, "utf8"),
3914
+ fsp2.stat(filePath)
3788
3915
  ]);
3789
3916
  const ext = filePath.split(".").pop() ?? "";
3790
3917
  const language = ext === "ts" || ext === "tsx" ? "typescript" : ext === "js" || ext === "jsx" ? "javascript" : ext === "md" ? "markdown" : ext === "json" ? "json" : void 0;
@@ -3961,7 +4088,7 @@ var CollabSession = class extends EventEmitter {
3961
4088
  timeoutMs: budget.timeoutMs
3962
4089
  };
3963
4090
  const subagentId = await this.director.spawn(cfg);
3964
- await this.director.assign({ id: randomUUID(), subagentId, description: taskBrief });
4091
+ await this.director.assign({ id: randomUUID3(), subagentId, description: taskBrief });
3965
4092
  return subagentId;
3966
4093
  }
3967
4094
  buildBugHunterTask() {
@@ -4212,7 +4339,7 @@ Emit each evaluation immediately. Do not wait until you have read all reports.`;
4212
4339
  for (const file of this.snapshot.files) {
4213
4340
  if (file.snapshotMtimeMs === void 0 && file.snapshotSizeBytes === void 0) continue;
4214
4341
  try {
4215
- const stat9 = await fsp9.stat(file.path);
4342
+ const stat9 = await fsp2.stat(file.path);
4216
4343
  const mtimeChanged = file.snapshotMtimeMs !== void 0 && stat9.mtimeMs > file.snapshotMtimeMs + 1;
4217
4344
  const sizeChanged = file.snapshotSizeBytes !== void 0 && stat9.size !== file.snapshotSizeBytes;
4218
4345
  if (mtimeChanged || sizeChanged) {
@@ -4289,6 +4416,11 @@ Emit each evaluation immediately. Do not wait until you have read all reports.`;
4289
4416
  }
4290
4417
  };
4291
4418
 
4419
+ // src/coordination/delegate-tool.ts
4420
+ import * as fsp3 from "node:fs/promises";
4421
+ import * as path5 from "node:path";
4422
+ import { randomUUID as randomUUID4 } from "node:crypto";
4423
+
4292
4424
  // src/coordination/fleet.ts
4293
4425
  var AUDIT_LOG_AGENT = {
4294
4426
  id: "audit-log",
@@ -4510,17 +4642,25 @@ function createDelegateTool(opts) {
4510
4642
  return {
4511
4643
  name: "delegate",
4512
4644
  description: "Hand a discrete piece of work to a dedicated subagent and wait for its result. The subagent has its own context, its own LLM call, and its own budget \u2014 use this when a task is self-contained, would otherwise blow up your context, or benefits from a specialized role (bug-hunter, security-scanner, refactor-planner, audit-log). For free-form coding tasks (not tied to a pre-defined role), pass `name` + `task` \u2014 the subagent runs as a general-purpose coding agent with a large default budget. YOU decide how big the budget is: pass `timeoutMs`, `maxIterations`, and `maxToolCalls` sized to the actual work. There is no hidden cap forcing a 3-minute / 80-iteration limit \u2014 if a monorepo audit needs 2 hours and 500 tool calls, ask for that. Call multiple delegates in parallel through the provider's parallel-tool-call surface to fan work out across roles.",
4513
- usageHint: "Set `task` to a complete instruction. Either pick `role` from the roster (audit-log, bug-hunter, refactor-planner, security-scanner) or pass `name` to run a free-form coding agent. For non-trivial work, also pass `timeoutMs`, `maxIterations`, and `maxToolCalls`. Returns the subagent's `TaskResult` \u2014 including the textual `result`, iteration count, tool count, and duration. Auto-promotes the host into director mode on first call.",
4645
+ usageHint: "Set `task` to a complete instruction. Either pick `role` from the roster (audit-log, bug-hunter, refactor-planner, security-scanner) or pass `name` to run a free-form coding agent. For non-trivial work, also pass `timeoutMs`, `maxIterations`, and `maxToolCalls`. Returns the subagent's `TaskResult` \u2014 including the textual `result`, iteration count, tool count, and duration. Requires Director mode to be active in normal CLI sessions.",
4514
4646
  permission: "auto",
4515
4647
  mutating: false,
4516
4648
  capabilities: [ToolCapabilities.SUBAGENT_SPAWN],
4517
4649
  inputSchema,
4518
- async execute(input) {
4650
+ async execute(input, _ctx, execOpts) {
4519
4651
  const sessionId = opts.directorRunId;
4652
+ const abortSignal = execOpts?.signal;
4520
4653
  const i = input ?? {};
4521
4654
  if (typeof i.task !== "string" || !i.task.trim()) {
4522
4655
  return { ok: false, error: "`task` is required." };
4523
4656
  }
4657
+ if (abortSignal?.aborted) {
4658
+ return {
4659
+ ok: false,
4660
+ stopReason: "aborted",
4661
+ error: "Delegation cancelled before spawn \u2014 the run was interrupted."
4662
+ };
4663
+ }
4524
4664
  const target = i.role ?? i.name ?? "subagent";
4525
4665
  try {
4526
4666
  let director = await opts.host.ensureDirector();
@@ -4585,7 +4725,7 @@ function createDelegateTool(opts) {
4585
4725
  opts.events?.emit("delegate.started", { sessionId, target, task: i.task });
4586
4726
  const subagentId = await director.spawn(cfg);
4587
4727
  const taskId = await director.assign({
4588
- id: `${randomUUID()}`,
4728
+ id: `${randomUUID4()}`,
4589
4729
  description: i.task,
4590
4730
  subagentId
4591
4731
  });
@@ -4593,6 +4733,8 @@ function createDelegateTool(opts) {
4593
4733
  const result = await new Promise((resolve9) => {
4594
4734
  let settled = false;
4595
4735
  let timer;
4736
+ let offAbort = () => {
4737
+ };
4596
4738
  const finish = (value) => {
4597
4739
  if (settled) return;
4598
4740
  settled = true;
@@ -4600,6 +4742,7 @@ function createDelegateTool(opts) {
4600
4742
  offTool();
4601
4743
  offIter();
4602
4744
  offProgress();
4745
+ offAbort();
4603
4746
  resolve9(value);
4604
4747
  };
4605
4748
  const arm = () => {
@@ -4612,9 +4755,42 @@ function createDelegateTool(opts) {
4612
4755
  const offTool = dir.fleet.filter("tool.executed", bump);
4613
4756
  const offIter = dir.fleet.filter("iteration.started", bump);
4614
4757
  const offProgress = dir.fleet.filter("tool.progress", bump);
4758
+ if (abortSignal) {
4759
+ const onAbortSignal = () => finish({ __aborted: true });
4760
+ abortSignal.addEventListener("abort", onAbortSignal, { once: true });
4761
+ offAbort = () => abortSignal.removeEventListener("abort", onAbortSignal);
4762
+ if (abortSignal.aborted) onAbortSignal();
4763
+ }
4615
4764
  arm();
4616
4765
  dir.awaitTasks([taskId]).then((r) => finish(r[0] ?? { __emptyResult: true })).catch(() => finish({ __timeout: true }));
4617
4766
  });
4767
+ if ("__aborted" in result) {
4768
+ try {
4769
+ await dir.terminate(subagentId);
4770
+ } catch {
4771
+ }
4772
+ const partial2 = await readSubagentPartial(opts, subagentId);
4773
+ opts.events?.emit("delegate.completed", {
4774
+ sessionId,
4775
+ target,
4776
+ task: i.task,
4777
+ ok: false,
4778
+ status: "aborted",
4779
+ summary: `[${target}] aborted \u2014 the run was interrupted`,
4780
+ durationMs: 0,
4781
+ iterations: partial2?.events ?? 0,
4782
+ toolCalls: partial2?.toolUsesObserved ?? 0,
4783
+ subagentId
4784
+ });
4785
+ return {
4786
+ ok: false,
4787
+ stopReason: "aborted",
4788
+ error: "Delegated task aborted \u2014 the run was interrupted.",
4789
+ subagentId,
4790
+ taskId,
4791
+ partial: partial2
4792
+ };
4793
+ }
4618
4794
  if ("__timeout" in result) {
4619
4795
  const partial2 = await readSubagentPartial(opts, subagentId);
4620
4796
  opts.events?.emit("delegate.completed", {
@@ -4741,7 +4917,7 @@ function instantiateRosterConfig(role, base) {
4741
4917
  ...withBudget,
4742
4918
  // Give each spawn a fresh id so parallel or repeated delegates
4743
4919
  // can use the same role safely.
4744
- id: `${role}-${randomUUID().slice(0, 8)}`
4920
+ id: `${role}-${randomUUID4().slice(0, 8)}`
4745
4921
  };
4746
4922
  }
4747
4923
  function hintForKind(kind, retryable, backoffMs, partial) {
@@ -4816,13 +4992,13 @@ async function readSubagentPartial(opts, subagentId) {
4816
4992
  if (!opts.sessionsRoot) return void 0;
4817
4993
  const candidates = [];
4818
4994
  if (opts.directorRunId) {
4819
- candidates.push(path9.join(opts.sessionsRoot, opts.directorRunId, `${subagentId}.jsonl`));
4995
+ candidates.push(path5.join(opts.sessionsRoot, opts.directorRunId, `${subagentId}.jsonl`));
4820
4996
  } else {
4821
4997
  try {
4822
- const entries = await fsp9.readdir(opts.sessionsRoot, { withFileTypes: true });
4998
+ const entries = await fsp3.readdir(opts.sessionsRoot, { withFileTypes: true });
4823
4999
  for (const entry of entries) {
4824
5000
  if (entry.isDirectory()) {
4825
- candidates.push(path9.join(opts.sessionsRoot, entry.name, `${subagentId}.jsonl`));
5001
+ candidates.push(path5.join(opts.sessionsRoot, entry.name, `${subagentId}.jsonl`));
4826
5002
  }
4827
5003
  }
4828
5004
  } catch {
@@ -4832,7 +5008,7 @@ async function readSubagentPartial(opts, subagentId) {
4832
5008
  for (const file of candidates) {
4833
5009
  let raw;
4834
5010
  try {
4835
- raw = await fsp9.readFile(file, "utf8");
5011
+ raw = await fsp3.readFile(file, "utf8");
4836
5012
  } catch {
4837
5013
  continue;
4838
5014
  }
@@ -5013,10 +5189,19 @@ function attachDepWatcherBridge(opts) {
5013
5189
  unsub();
5014
5190
  };
5015
5191
  }
5192
+
5193
+ // src/coordination/director.ts
5194
+ import { randomUUID as randomUUID7 } from "node:crypto";
5195
+ import * as fsp5 from "node:fs/promises";
5196
+ import * as path7 from "node:path";
5197
+
5198
+ // src/storage/director-state.ts
5199
+ import * as fsp4 from "node:fs/promises";
5200
+ import { hostname } from "node:os";
5016
5201
  async function acquireDirectorStateLock(lockPath, processId = process.pid) {
5017
5202
  let existing;
5018
5203
  try {
5019
- existing = await fsp9.readFile(lockPath, "utf8");
5204
+ existing = await fsp4.readFile(lockPath, "utf8");
5020
5205
  } catch {
5021
5206
  }
5022
5207
  if (existing) {
@@ -5040,7 +5225,7 @@ async function acquireDirectorStateLock(lockPath, processId = process.pid) {
5040
5225
  }
5041
5226
  async function releaseDirectorStateLock(lockPath) {
5042
5227
  try {
5043
- await fsp9.unlink(lockPath);
5228
+ await fsp4.unlink(lockPath);
5044
5229
  } catch {
5045
5230
  }
5046
5231
  }
@@ -5260,6 +5445,11 @@ var FleetContextOverflowError = class extends Error {
5260
5445
  this.observed = observed;
5261
5446
  }
5262
5447
  };
5448
+
5449
+ // src/utils/instruction-file.ts
5450
+ import { readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
5451
+ import * as path6 from "node:path";
5452
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
5263
5453
  var textCache = /* @__PURE__ */ new Map();
5264
5454
  var rootCandidates;
5265
5455
  function readBundledInstructionText(relativePath) {
@@ -5268,7 +5458,7 @@ function readBundledInstructionText(relativePath) {
5268
5458
  let resolved = "";
5269
5459
  for (const root of instructionRootCandidates()) {
5270
5460
  try {
5271
- resolved = readFileSync(path9.join(root, relativePath), "utf8").trimEnd();
5461
+ resolved = readFileSync2(path6.join(root, relativePath), "utf8").trimEnd();
5272
5462
  break;
5273
5463
  } catch {
5274
5464
  }
@@ -5284,18 +5474,18 @@ function renderInstructionTemplate(template, values) {
5284
5474
  }
5285
5475
  function instructionRootCandidates() {
5286
5476
  if (rootCandidates !== void 0) return rootCandidates;
5287
- const here = path9.dirname(fileURLToPath(import.meta.url));
5477
+ const here = path6.dirname(fileURLToPath2(import.meta.url));
5288
5478
  const candidates = [
5289
- path9.resolve(here, "../../instructions"),
5290
- path9.resolve(here, "../instructions"),
5291
- path9.resolve(here, "instructions")
5479
+ path6.resolve(here, "../../instructions"),
5480
+ path6.resolve(here, "../instructions"),
5481
+ path6.resolve(here, "instructions")
5292
5482
  ];
5293
5483
  rootCandidates = candidates.sort((a, b) => Number(!isDirectory2(a)) - Number(!isDirectory2(b)));
5294
5484
  return rootCandidates;
5295
5485
  }
5296
5486
  function isDirectory2(candidate) {
5297
5487
  try {
5298
- return statSync(candidate).isDirectory();
5488
+ return statSync2(candidate).isDirectory();
5299
5489
  } catch {
5300
5490
  return false;
5301
5491
  }
@@ -5362,6 +5552,14 @@ function rosterSummaryFromConfigs(roster) {
5362
5552
  return lines.join("\n");
5363
5553
  }
5364
5554
 
5555
+ // src/coordination/director-tools.ts
5556
+ import { randomUUID as randomUUID5 } from "node:crypto";
5557
+ import {
5558
+ claimReadyTask,
5559
+ listReadyTasks,
5560
+ updateTaskAssignment
5561
+ } from "@wrongstack/kanban";
5562
+
5365
5563
  // src/coordination/dispatcher.ts
5366
5564
  var DEFAULT_DISPATCH_ROLE = "executor";
5367
5565
  var FALLBACK_DEFINITION = {
@@ -5621,7 +5819,7 @@ function instantiateRosterConfig2(role, base) {
5621
5819
  ...base,
5622
5820
  // Roster entries are templates. A director may spawn several
5623
5821
  // workers with the same role, so never reuse the template id.
5624
- id: `${role}-${randomUUID().slice(0, 8)}`
5822
+ id: `${role}-${randomUUID5().slice(0, 8)}`
5625
5823
  };
5626
5824
  }
5627
5825
  function makeQualityGateTool(director, roster) {
@@ -5720,7 +5918,7 @@ function makeQualityGateTool(director, roster) {
5720
5918
  makeQualityGateSubagentConfig("verifier", roster, i.verifierWorktree ?? "auto")
5721
5919
  );
5722
5920
  const taskId = await director.assign({
5723
- id: randomUUID(),
5921
+ id: randomUUID5(),
5724
5922
  subagentId,
5725
5923
  description: buildVerifierTask(i, {
5726
5924
  attempt,
@@ -5738,7 +5936,7 @@ function makeQualityGateTool(director, roster) {
5738
5936
  makeQualityGateSubagentConfig("reviewer", roster, i.reviewerWorktree ?? "off")
5739
5937
  );
5740
5938
  const taskId = await director.assign({
5741
- id: randomUUID(),
5939
+ id: randomUUID5(),
5742
5940
  subagentId,
5743
5941
  description: buildReviewerTask(i, {
5744
5942
  attempt,
@@ -5766,7 +5964,7 @@ function makeQualityGateTool(director, roster) {
5766
5964
  };
5767
5965
  }
5768
5966
  const repairTaskId = await director.assign({
5769
- id: randomUUID(),
5967
+ id: randomUUID5(),
5770
5968
  subagentId: i.repairSubagentId,
5771
5969
  description: buildRepairTask(i, attempts[attempts.length - 1], attempt),
5772
5970
  timeoutMs: i.timeoutMs
@@ -6034,7 +6232,7 @@ function makeAssignTool(director) {
6034
6232
  async execute(input) {
6035
6233
  const i = input;
6036
6234
  const task = {
6037
- id: randomUUID(),
6235
+ id: randomUUID5(),
6038
6236
  description: i.description,
6039
6237
  subagentId: i.subagentId,
6040
6238
  maxToolCalls: i.maxToolCalls,
@@ -6115,7 +6313,7 @@ function makeKanbanQueueTool(director, roster) {
6115
6313
  const leaseTtlMs = Math.max(1e3, Math.floor(i.leaseTtlMs ?? 5 * 60 * 1e3));
6116
6314
  const claimedAt = nowIso();
6117
6315
  const leaseSeeding = {
6118
- leaseId: randomUUID(),
6316
+ leaseId: randomUUID5(),
6119
6317
  claimedAt,
6120
6318
  heartbeatAt: claimedAt,
6121
6319
  leaseExpiresAt: new Date(Date.now() + leaseTtlMs).toISOString()
@@ -6169,7 +6367,7 @@ function makeKanbanQueueTool(director, roster) {
6169
6367
  const config = buildKanbanSubagentConfig(claim.task, i, roster);
6170
6368
  subagentId = await director.spawn(config);
6171
6369
  runTaskId = await director.assign({
6172
- id: randomUUID(),
6370
+ id: randomUUID5(),
6173
6371
  subagentId,
6174
6372
  description: buildKanbanFleetTaskPrompt(claim.board, claim.task, {
6175
6373
  heartbeatIntervalMs: i.heartbeatIntervalMs ?? 6e4,
@@ -7184,6 +7382,7 @@ function fallbackProfileChain(config, profileName) {
7184
7382
  const chain = config.fallbackProfiles?.[profileName];
7185
7383
  return Array.isArray(chain) ? chain.filter((ref) => parseModelRef(ref).model) : [];
7186
7384
  }
7385
+ var DEFAULT_PRIMARY_COOLDOWN_MAX_MS = 10 * 6e4;
7187
7386
 
7188
7387
  // src/coordination/model-matrix.ts
7189
7388
  var MATRIX_PHASE_KEYS = Object.keys(AGENTS_BY_PHASE);
@@ -7357,6 +7556,10 @@ function isValidMatrixKey(key) {
7357
7556
  return matrixKeyKind(key) !== "unknown";
7358
7557
  }
7359
7558
 
7559
+ // src/coordination/multi-agent-coordinator.ts
7560
+ import { randomUUID as randomUUID6 } from "node:crypto";
7561
+ import { EventEmitter as EventEmitter2 } from "node:events";
7562
+
7360
7563
  // src/coordination/coordinator/error-classifier.ts
7361
7564
  function classifySubagentError(err, hints = {}) {
7362
7565
  if (err instanceof AgentError && err.cause) {
@@ -7551,7 +7754,7 @@ function formatRole(role) {
7551
7754
  }
7552
7755
 
7553
7756
  // src/coordination/multi-agent-coordinator.ts
7554
- var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends EventEmitter {
7757
+ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends EventEmitter2 {
7555
7758
  coordinatorId;
7556
7759
  config;
7557
7760
  runner;
@@ -7644,7 +7847,7 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
7644
7847
  return { ...subagent, name: display };
7645
7848
  }
7646
7849
  async spawn(subagent) {
7647
- const id = subagent.id || randomUUID();
7850
+ const id = subagent.id || randomUUID6();
7648
7851
  const cfg = this.withNickname(subagent, id);
7649
7852
  if (this.subagents.has(id)) {
7650
7853
  throw new Error(`Subagent id "${id}" already exists \u2014 refusing to overwrite`);
@@ -8311,8 +8514,9 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
8311
8514
  }
8312
8515
  const subagent = this.subagents.get(result.subagentId);
8313
8516
  if (subagent && subagent.status !== "stopped") {
8314
- result.status === "failed" || result.status === "timeout";
8517
+ const failed = result.status === "failed" || result.status === "timeout";
8315
8518
  subagent.status = "idle";
8519
+ void failed;
8316
8520
  subagent.currentTask = void 0;
8317
8521
  if (subagent.abortController.signal.aborted) {
8318
8522
  subagent.abortController = new AbortController();
@@ -8701,6 +8905,9 @@ var Director = class _Director {
8701
8905
  subagentBaseline;
8702
8906
  /** See {@link DirectorOptions.taskResultNotifier}. */
8703
8907
  taskResultNotifier;
8908
+ subagentIdleTimeoutMs;
8909
+ retireSubagentOnTaskComplete;
8910
+ subagentIdleTimers = /* @__PURE__ */ new Map();
8704
8911
  /** Absolute path to the fleet's shared scratchpad directory, or null
8705
8912
  * when none was configured. Exposed as a readonly getter for callers
8706
8913
  * that need to surface the path to the user (e.g. the CLI logging
@@ -8796,13 +9003,15 @@ var Director = class _Director {
8796
9003
  /** Prevents large `ask_subagent` answers from bloating the leader's context window. */
8797
9004
  largeAnswerStore;
8798
9005
  constructor(opts) {
8799
- this.id = opts.config.coordinatorId || randomUUID();
9006
+ this.id = opts.config.coordinatorId || randomUUID7();
8800
9007
  this.brain = opts.brain;
8801
9008
  this.manifestPath = opts.manifestPath;
8802
9009
  this.roster = opts.roster;
8803
9010
  this.directorPreamble = opts.directorPreamble ?? DEFAULT_DIRECTOR_PREAMBLE;
8804
9011
  this.subagentBaseline = opts.subagentBaseline ?? DEFAULT_SUBAGENT_BASELINE;
8805
9012
  this.taskResultNotifier = opts.taskResultNotifier;
9013
+ this.subagentIdleTimeoutMs = typeof opts.subagentIdleTimeoutMs === "number" && Number.isFinite(opts.subagentIdleTimeoutMs) && opts.subagentIdleTimeoutMs >= 0 ? opts.subagentIdleTimeoutMs : void 0;
9014
+ this.retireSubagentOnTaskComplete = opts.retireSubagentOnTaskComplete ?? false;
8806
9015
  this.sharedScratchpadPath = opts.sharedScratchpadPath ?? null;
8807
9016
  this.maxSpawns = opts.maxSpawns ?? Number.POSITIVE_INFINITY;
8808
9017
  this.maxSpawnDepth = opts.fleetManager?.maxSpawnDepth ?? resolveMaxSpawnDepth(opts.maxSpawnDepth);
@@ -8833,7 +9042,7 @@ var Director = class _Director {
8833
9042
  this.fleetManager = opts.fleetManager;
8834
9043
  this.logger = opts.logger;
8835
9044
  if (this.sharedScratchpadPath) {
8836
- void fsp9.mkdir(this.sharedScratchpadPath, { recursive: true }).catch((err) => this.logShutdownError("shared_scratchpad_mkdir", err));
9045
+ void fsp5.mkdir(this.sharedScratchpadPath, { recursive: true }).catch((err) => this.logShutdownError("shared_scratchpad_mkdir", err));
8837
9046
  }
8838
9047
  this.transport = new InMemoryBridgeTransport();
8839
9048
  this.bridge = new InMemoryAgentBridge(
@@ -8947,6 +9156,10 @@ var Director = class _Director {
8947
9156
  } else {
8948
9157
  this.scheduleManifest();
8949
9158
  }
9159
+ this.armSubagentIdleRetirement(
9160
+ r.subagentId,
9161
+ this.retireSubagentOnTaskComplete ? 0 : this.subagentIdleTimeoutMs
9162
+ );
8950
9163
  };
8951
9164
  this.coordinator.on("task.completed", this.taskCompletedListener);
8952
9165
  const extendCounts = /* @__PURE__ */ new Map();
@@ -9419,6 +9632,7 @@ var Director = class _Director {
9419
9632
  });
9420
9633
  this.scheduleManifest();
9421
9634
  }
9635
+ this.armSubagentIdleRetirement(result.subagentId, this.subagentIdleTimeoutMs);
9422
9636
  return result.subagentId;
9423
9637
  }
9424
9638
  /**
@@ -9441,7 +9655,7 @@ var Director = class _Director {
9441
9655
  );
9442
9656
  }
9443
9657
  const msg = {
9444
- id: randomUUID(),
9658
+ id: randomUUID7(),
9445
9659
  type: "task",
9446
9660
  from: this.id,
9447
9661
  to: subagentId,
@@ -9540,7 +9754,7 @@ var Director = class _Director {
9540
9754
  })),
9541
9755
  usage: this.usage.snapshot()
9542
9756
  };
9543
- await fsp9.mkdir(path9.dirname(this.manifestPath), { recursive: true });
9757
+ await fsp5.mkdir(path7.dirname(this.manifestPath), { recursive: true });
9544
9758
  await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
9545
9759
  return this.manifestPath;
9546
9760
  }
@@ -9567,6 +9781,8 @@ var Director = class _Director {
9567
9781
  this.budgetFilter();
9568
9782
  this.budgetFilter = null;
9569
9783
  }
9784
+ for (const timer of this.subagentIdleTimers.values()) clearTimeout(timer);
9785
+ this.subagentIdleTimers.clear();
9570
9786
  await this.coordinator.stopAll();
9571
9787
  for (const b of this.subagentBridges.values()) {
9572
9788
  await b.stop().catch((err) => this.logShutdownError("subagent_bridge_stop", err));
@@ -9606,7 +9822,7 @@ var Director = class _Director {
9606
9822
  * concurrency limit applies — the task may queue before running.
9607
9823
  */
9608
9824
  async assign(task) {
9609
- const taskWithId = task.id ? task : { ...task, id: randomUUID() };
9825
+ const taskWithId = task.id ? task : { ...task, id: randomUUID7() };
9610
9826
  if (this.workCompleteFlag) {
9611
9827
  const synthetic = {
9612
9828
  subagentId: taskWithId.subagentId ?? "unassigned",
@@ -9670,7 +9886,7 @@ var Director = class _Director {
9670
9886
  * rollups and persisted fleet task history.
9671
9887
  */
9672
9888
  async assignInternal(task) {
9673
- const taskWithId = task.id ? task : { ...task, id: randomUUID() };
9889
+ const taskWithId = task.id ? task : { ...task, id: randomUUID7() };
9674
9890
  this.internalTaskIds.add(taskWithId.id);
9675
9891
  try {
9676
9892
  await this.coordinator.assign(taskWithId);
@@ -9789,6 +10005,7 @@ var Director = class _Director {
9789
10005
  await this.coordinator.stopAll();
9790
10006
  }
9791
10007
  async remove(subagentId) {
10008
+ this.clearSubagentIdleRetirement(subagentId);
9792
10009
  await this.coordinator.remove(subagentId);
9793
10010
  const bridge = this.subagentBridges.get(subagentId);
9794
10011
  if (bridge) {
@@ -9809,6 +10026,34 @@ var Director = class _Director {
9809
10026
  this.taskOwners.delete(subagentId);
9810
10027
  this.taskDescriptions.delete(subagentId);
9811
10028
  }
10029
+ clearSubagentIdleRetirement(subagentId) {
10030
+ const timer = this.subagentIdleTimers.get(subagentId);
10031
+ if (!timer) return;
10032
+ clearTimeout(timer);
10033
+ this.subagentIdleTimers.delete(subagentId);
10034
+ }
10035
+ /**
10036
+ * Arm one lifecycle timer per worker. The callback re-checks coordinator
10037
+ * state so a task assigned in the same turn always wins over retirement.
10038
+ */
10039
+ armSubagentIdleRetirement(subagentId, delayMs) {
10040
+ this.clearSubagentIdleRetirement(subagentId);
10041
+ if (delayMs === void 0) return;
10042
+ const timer = setTimeout(() => {
10043
+ this.subagentIdleTimers.delete(subagentId);
10044
+ const entry = this.coordinator.getStatus().subagents.find((a) => a.id === subagentId);
10045
+ if (!entry || entry.status !== "idle") return;
10046
+ if (this.coordinator.listPendingTasks().some((task) => task.subagentId === subagentId)) {
10047
+ this.armSubagentIdleRetirement(subagentId, this.subagentIdleTimeoutMs);
10048
+ return;
10049
+ }
10050
+ void this.remove(subagentId).catch(
10051
+ (err) => this.logShutdownError("subagent_idle_retirement", err)
10052
+ );
10053
+ }, delayMs);
10054
+ if (typeof timer.unref === "function") timer.unref();
10055
+ this.subagentIdleTimers.set(subagentId, timer);
10056
+ }
9812
10057
  status() {
9813
10058
  const base = this.coordinator.getStatus();
9814
10059
  return {
@@ -9860,10 +10105,10 @@ var Director = class _Director {
9860
10105
  */
9861
10106
  async readSession(subagentId, tail) {
9862
10107
  if (!this.sessionsRoot) return null;
9863
- const filePath = path9.join(this.sessionsRoot, this.directorRunId, `${subagentId}.jsonl`);
10108
+ const filePath = path7.join(this.sessionsRoot, this.directorRunId, `${subagentId}.jsonl`);
9864
10109
  let raw;
9865
10110
  try {
9866
- raw = await fsp9.readFile(filePath, "utf8");
10111
+ raw = await fsp5.readFile(filePath, "utf8");
9867
10112
  } catch {
9868
10113
  return null;
9869
10114
  }
@@ -10028,6 +10273,21 @@ var Director = class _Director {
10028
10273
  }
10029
10274
  };
10030
10275
 
10276
+ // src/coordination/director-session.ts
10277
+ import * as path12 from "node:path";
10278
+
10279
+ // src/storage/session-store.ts
10280
+ import { createHash as createHash4 } from "node:crypto";
10281
+ import { createReadStream } from "node:fs";
10282
+ import * as fsp9 from "node:fs/promises";
10283
+ import * as path11 from "node:path";
10284
+ import { createInterface } from "node:readline";
10285
+
10286
+ // src/storage/file-session-writer.ts
10287
+ import { closeSync, fsyncSync, openSync, writeSync } from "node:fs";
10288
+ import * as fsp6 from "node:fs/promises";
10289
+ import * as path8 from "node:path";
10290
+
10031
10291
  // src/storage/session-helpers.ts
10032
10292
  function userInputTitle(content) {
10033
10293
  const text = typeof content === "string" ? content : content.filter((b) => b.type === "text").map((b) => b.text).join(" ");
@@ -10043,7 +10303,7 @@ var FileSessionWriter = class _FileSessionWriter {
10043
10303
  this.meta = meta;
10044
10304
  this.events = events;
10045
10305
  this.resumed = opts.resumed ?? false;
10046
- this.manifestFile = opts.dir ? path9.join(opts.dir, `${path9.basename(id)}.summary.json`) : "";
10306
+ this.manifestFile = opts.dir ? path8.join(opts.dir, `${path8.basename(id)}.summary.json`) : "";
10047
10307
  this.filePath = opts.filePath ?? "";
10048
10308
  this.secretScrubber = opts.secretScrubber;
10049
10309
  this.checkpointCas = opts.checkpointCas;
@@ -10583,7 +10843,7 @@ var FileSessionWriter = class _FileSessionWriter {
10583
10843
  let removedCount = 0;
10584
10844
  let targetCheckpointSeen = false;
10585
10845
  try {
10586
- fd = await fsp9.open(this.filePath, "r", 384);
10846
+ fd = await fsp6.open(this.filePath, "r", 384);
10587
10847
  while (true) {
10588
10848
  const buf = Buffer.alloc(CHUNK_SIZE);
10589
10849
  const { bytesRead } = await fd.read(buf, 0, CHUNK_SIZE, fileOffset);
@@ -10638,7 +10898,7 @@ var FileSessionWriter = class _FileSessionWriter {
10638
10898
  await this.writeChain;
10639
10899
  await this.handle.close();
10640
10900
  const tmpPath = `${this.filePath}.rewind.tmp`;
10641
- const src = await fsp9.open(this.filePath, "r", 384);
10901
+ const src = await fsp6.open(this.filePath, "r", 384);
10642
10902
  try {
10643
10903
  const statResult = await src.stat();
10644
10904
  const totalSize = statResult.size;
@@ -10654,7 +10914,7 @@ var FileSessionWriter = class _FileSessionWriter {
10654
10914
  } else {
10655
10915
  newlineAfterCheckpoint = totalSize;
10656
10916
  }
10657
- const writeFd = await fsp9.open(tmpPath, "w", 384);
10917
+ const writeFd = await fsp6.open(tmpPath, "w", 384);
10658
10918
  try {
10659
10919
  let readOffset = 0;
10660
10920
  while (readOffset < newlineAfterCheckpoint) {
@@ -10702,11 +10962,11 @@ var FileSessionWriter = class _FileSessionWriter {
10702
10962
  await writeFd.close();
10703
10963
  }
10704
10964
  await src.close();
10705
- await fsp9.rename(tmpPath, this.filePath);
10706
- this.handle = await fsp9.open(this.filePath, "a", 384);
10965
+ await fsp6.rename(tmpPath, this.filePath);
10966
+ this.handle = await fsp6.open(this.filePath, "a", 384);
10707
10967
  } catch (err) {
10708
- await fsp9.unlink(tmpPath).catch(() => void 0);
10709
- this.handle = await fsp9.open(this.filePath, "a", 384).catch(() => this.handle);
10968
+ await fsp6.unlink(tmpPath).catch(() => void 0);
10969
+ this.handle = await fsp6.open(this.filePath, "a", 384).catch(() => this.handle);
10710
10970
  throw err;
10711
10971
  }
10712
10972
  await this.append({
@@ -10741,7 +11001,7 @@ var FileSessionWriter = class _FileSessionWriter {
10741
11001
  provider: this.meta.provider ?? "unknown"
10742
11002
  })}
10743
11003
  `;
10744
- await fsp9.writeFile(this.filePath, record, "utf8");
11004
+ await fsp6.writeFile(this.filePath, record, "utf8");
10745
11005
  this.activePromptIndex = null;
10746
11006
  this.pendingFileSnapshots = [];
10747
11007
  }
@@ -10786,6 +11046,12 @@ var FileSessionWriter = class _FileSessionWriter {
10786
11046
  }
10787
11047
  };
10788
11048
 
11049
+ // src/storage/session-checkpoint-cas.ts
11050
+ import { spawn } from "node:child_process";
11051
+ import { createHash as createHash2, randomUUID as randomUUID8 } from "node:crypto";
11052
+ import * as fsp7 from "node:fs/promises";
11053
+ import * as path9 from "node:path";
11054
+
10789
11055
  // src/storage/storage-concurrency.ts
10790
11056
  async function mapWithConcurrency(items, concurrency, mapper) {
10791
11057
  if (items.length === 0) return [];
@@ -10812,7 +11078,7 @@ var MAX_GIT_OUTPUT = 16 * 1024 * 1024;
10812
11078
  var MAX_BLOB_BYTES = 64 * 1024 * 1024;
10813
11079
  var MAX_CHECKPOINT_BYTES = 512 * 1024 * 1024;
10814
11080
  function sha256(content) {
10815
- return createHash("sha256").update(content).digest("hex");
11081
+ return createHash2("sha256").update(content).digest("hex");
10816
11082
  }
10817
11083
  function isInside(root, target) {
10818
11084
  const relative4 = path9.relative(root, target);
@@ -10868,9 +11134,9 @@ var SessionCheckpointCas = class {
10868
11134
  return null;
10869
11135
  }
10870
11136
  try {
10871
- const stat9 = await fsp9.lstat(absolute);
11137
+ const stat9 = await fsp7.lstat(absolute);
10872
11138
  if (stat9.isSymbolicLink()) {
10873
- const linkTarget = await fsp9.readlink(absolute);
11139
+ const linkTarget = await fsp7.readlink(absolute);
10874
11140
  const resolvedLink = path9.resolve(path9.dirname(absolute), linkTarget);
10875
11141
  if (path9.isAbsolute(linkTarget) || !isInside(this.projectRoot, resolvedLink)) {
10876
11142
  unresolved.push({
@@ -10900,7 +11166,7 @@ var SessionCheckpointCas = class {
10900
11166
  return null;
10901
11167
  }
10902
11168
  scheduledBytes += stat9.size;
10903
- const content = await fsp9.readFile(absolute);
11169
+ const content = await fsp7.readFile(absolute);
10904
11170
  const blobHash = sha256(content);
10905
11171
  await this.putBlob(blobHash, content);
10906
11172
  return { path: relative4, state: "file", blobHash, mode: stat9.mode & 511 };
@@ -10938,7 +11204,7 @@ var SessionCheckpointCas = class {
10938
11204
  if (target === this.projectRoot) {
10939
11205
  throw new Error("Refusing to materialize a workspace checkpoint over the parent project root");
10940
11206
  }
10941
- const targetStat = await fsp9.stat(target);
11207
+ const targetStat = await fsp7.stat(target);
10942
11208
  if (!targetStat.isDirectory()) throw new Error(`Checkpoint target is not a directory: ${target}`);
10943
11209
  const manifest = await this.loadManifest(checkpoint.manifestHash);
10944
11210
  if (manifest.baseHead !== checkpoint.baseHead.toLowerCase() || manifest.coverage !== checkpoint.coverage || manifest.entries.length !== checkpoint.entryCount || manifest.unresolved.length !== checkpoint.unresolvedCount) {
@@ -10965,7 +11231,7 @@ var SessionCheckpointCas = class {
10965
11231
  if (targetStatus.stdout.length > 0) {
10966
11232
  throw new Error("Checkpoint target must be a clean checkout before materialization");
10967
11233
  }
10968
- const realTarget = await fsp9.realpath(target);
11234
+ const realTarget = await fsp7.realpath(target);
10969
11235
  const writtenFiles = [];
10970
11236
  const deletedFiles = [];
10971
11237
  const errors = [];
@@ -10995,24 +11261,24 @@ var SessionCheckpointCas = class {
10995
11261
  for (const { entry, output, content } of prepared) {
10996
11262
  try {
10997
11263
  if (entry.state === "absent") {
10998
- await fsp9.unlink(output).catch((err) => {
11264
+ await fsp7.unlink(output).catch((err) => {
10999
11265
  if (err.code !== "ENOENT") throw err;
11000
11266
  });
11001
11267
  deletedFiles.push(entry.path);
11002
11268
  continue;
11003
11269
  }
11004
11270
  if (entry.state === "symlink") {
11005
- await fsp9.unlink(output).catch((err) => {
11271
+ await fsp7.unlink(output).catch((err) => {
11006
11272
  if (err.code !== "ENOENT") throw err;
11007
11273
  });
11008
- await fsp9.mkdir(path9.dirname(output), { recursive: true });
11009
- await fsp9.symlink(entry.linkTarget, output);
11274
+ await fsp7.mkdir(path9.dirname(output), { recursive: true });
11275
+ await fsp7.symlink(entry.linkTarget, output);
11010
11276
  writtenFiles.push(entry.path);
11011
11277
  continue;
11012
11278
  }
11013
11279
  if (!content) throw new Error("CAS blob was not prepared");
11014
11280
  await atomicWrite(output, content, { mode: entry.mode });
11015
- await fsp9.chmod(output, entry.mode).catch(() => void 0);
11281
+ await fsp7.chmod(output, entry.mode).catch(() => void 0);
11016
11282
  writtenFiles.push(entry.path);
11017
11283
  } catch (err) {
11018
11284
  errors.push(`${entry.path}: ${toErrorMessage(err)}`);
@@ -11030,9 +11296,9 @@ var SessionCheckpointCas = class {
11030
11296
  }
11031
11297
  async putBlob(hash, content) {
11032
11298
  const target = this.objectPath(hash);
11033
- await fsp9.mkdir(path9.dirname(target), { recursive: true });
11299
+ await fsp7.mkdir(path9.dirname(target), { recursive: true });
11034
11300
  try {
11035
- const existing = await fsp9.readFile(target);
11301
+ const existing = await fsp7.readFile(target);
11036
11302
  if (sha256(existing) !== hash) throw new Error(`Corrupt CAS object collision: ${hash}`);
11037
11303
  return;
11038
11304
  } catch (err) {
@@ -11040,30 +11306,30 @@ var SessionCheckpointCas = class {
11040
11306
  }
11041
11307
  const temp = path9.join(
11042
11308
  path9.dirname(target),
11043
- `.${path9.basename(target)}.${process.pid}.${randomUUID()}.tmp`
11309
+ `.${path9.basename(target)}.${process.pid}.${randomUUID8()}.tmp`
11044
11310
  );
11045
11311
  let handle;
11046
11312
  try {
11047
- handle = await fsp9.open(temp, "wx", 384);
11313
+ handle = await fsp7.open(temp, "wx", 384);
11048
11314
  await handle.writeFile(content);
11049
11315
  await handle.sync();
11050
11316
  await handle.close();
11051
11317
  handle = void 0;
11052
11318
  try {
11053
- await fsp9.link(temp, target);
11319
+ await fsp7.link(temp, target);
11054
11320
  } catch (err) {
11055
11321
  if (err.code !== "EEXIST") throw err;
11056
- const existing = await fsp9.readFile(target);
11322
+ const existing = await fsp7.readFile(target);
11057
11323
  if (sha256(existing) !== hash) throw new Error(`Corrupt CAS object collision: ${hash}`);
11058
11324
  }
11059
11325
  } finally {
11060
11326
  await handle?.close().catch(() => void 0);
11061
- await fsp9.unlink(temp).catch(() => void 0);
11327
+ await fsp7.unlink(temp).catch(() => void 0);
11062
11328
  }
11063
11329
  }
11064
11330
  async putManifest(hash, encoded) {
11065
11331
  const target = this.manifestPath(hash);
11066
- const existing = await fsp9.readFile(target).catch(() => null);
11332
+ const existing = await fsp7.readFile(target).catch(() => null);
11067
11333
  if (existing) {
11068
11334
  if (sha256(existing) !== hash) throw new Error(`Corrupt checkpoint manifest collision: ${hash}`);
11069
11335
  return;
@@ -11071,12 +11337,12 @@ var SessionCheckpointCas = class {
11071
11337
  await atomicWrite(target, encoded, { mode: 384 });
11072
11338
  }
11073
11339
  async readBlob(hash) {
11074
- const content = await fsp9.readFile(this.objectPath(hash));
11340
+ const content = await fsp7.readFile(this.objectPath(hash));
11075
11341
  if (sha256(content) !== hash) throw new Error(`CAS blob integrity check failed: ${hash}`);
11076
11342
  return content;
11077
11343
  }
11078
11344
  async loadManifest(hash) {
11079
- const raw = await fsp9.readFile(this.manifestPath(hash));
11345
+ const raw = await fsp7.readFile(this.manifestPath(hash));
11080
11346
  if (sha256(raw) !== hash) throw new Error(`Checkpoint manifest integrity check failed: ${hash}`);
11081
11347
  const parsed = JSON.parse(raw.toString("utf8"));
11082
11348
  if (parsed.version !== 1 || typeof parsed.baseHead !== "string" || parsed.coverage !== "git-head-plus-dirty" || !Array.isArray(parsed.entries) || !Array.isArray(parsed.unresolved)) {
@@ -11106,7 +11372,7 @@ var SessionCheckpointCas = class {
11106
11372
  let probe = output;
11107
11373
  for (; ; ) {
11108
11374
  try {
11109
- const real = await fsp9.realpath(probe);
11375
+ const real = await fsp7.realpath(probe);
11110
11376
  if (!isInside(realTarget, real)) throw new Error("path resolves through a symlink outside checkpoint target");
11111
11377
  return output;
11112
11378
  } catch (err) {
@@ -11166,12 +11432,17 @@ function defaultRunGit(args, cwd) {
11166
11432
  child.on("close", (code) => resolve9(result(code ?? 1)));
11167
11433
  });
11168
11434
  }
11435
+
11436
+ // src/storage/session-resume-validation.ts
11437
+ import { createHash as createHash3 } from "node:crypto";
11438
+ import * as fsp8 from "node:fs/promises";
11439
+ import * as path10 from "node:path";
11169
11440
  var MAX_REVALIDATE_BYTES = 5 * 1024 * 1024;
11170
11441
  var VALIDATION_CONCURRENCY = 8;
11171
11442
  var NOTICE_PATH_LIMIT = 20;
11172
11443
  function isInside2(root, target) {
11173
- const relative4 = path9.relative(root, target);
11174
- return relative4 === "" || !relative4.startsWith("..") && !path9.isAbsolute(relative4);
11444
+ const relative4 = path10.relative(root, target);
11445
+ return relative4 === "" || !relative4.startsWith("..") && !path10.isAbsolute(relative4);
11175
11446
  }
11176
11447
  function errno(err) {
11177
11448
  return err && typeof err === "object" && "code" in err ? String(err.code) : void 0;
@@ -11182,7 +11453,7 @@ function latestObservations(events, projectRoot) {
11182
11453
  if (event.type !== "file_observation" || typeof event.path !== "string" || event.path.length === 0 || typeof event.hash !== "string" || !/^[a-f\d]{64}$/i.test(event.hash)) {
11183
11454
  continue;
11184
11455
  }
11185
- const normalized = path9.resolve(projectRoot, event.path);
11456
+ const normalized = path10.resolve(projectRoot, event.path);
11186
11457
  latest.set(normalized, {
11187
11458
  path: normalized,
11188
11459
  hash: event.hash.toLowerCase(),
@@ -11206,7 +11477,7 @@ async function validateOne(observation, lexicalRoot, realRoot) {
11206
11477
  }
11207
11478
  let realFile;
11208
11479
  try {
11209
- realFile = await fsp9.realpath(observation.path);
11480
+ realFile = await fsp8.realpath(observation.path);
11210
11481
  } catch (err) {
11211
11482
  if (errno(err) === "ENOENT") return { ...base, status: "deleted" };
11212
11483
  return { ...base, status: "unreadable", detail: toErrorMessage(err) };
@@ -11219,7 +11490,7 @@ async function validateOne(observation, lexicalRoot, realRoot) {
11219
11490
  };
11220
11491
  }
11221
11492
  try {
11222
- const stat9 = await fsp9.stat(realFile);
11493
+ const stat9 = await fsp8.stat(realFile);
11223
11494
  if (!stat9.isFile()) {
11224
11495
  return { ...base, status: "unreadable", detail: "Path is no longer a regular file." };
11225
11496
  }
@@ -11230,8 +11501,8 @@ async function validateOne(observation, lexicalRoot, realRoot) {
11230
11501
  detail: `File now exceeds the ${MAX_REVALIDATE_BYTES}-byte validation limit.`
11231
11502
  };
11232
11503
  }
11233
- const content = await fsp9.readFile(realFile, "utf8");
11234
- const actualHash = createHash("sha256").update(content, "utf8").digest("hex");
11504
+ const content = await fsp8.readFile(realFile, "utf8");
11505
+ const actualHash = createHash3("sha256").update(content, "utf8").digest("hex");
11235
11506
  if (actualHash === observation.hash) return null;
11236
11507
  return { ...base, status: "modified", actualHash };
11237
11508
  } catch (err) {
@@ -11240,8 +11511,8 @@ async function validateOne(observation, lexicalRoot, realRoot) {
11240
11511
  }
11241
11512
  }
11242
11513
  async function validateResumeFileObservations(events, projectRoot) {
11243
- const lexicalRoot = path9.resolve(projectRoot);
11244
- const realRoot = await fsp9.realpath(lexicalRoot).catch(() => lexicalRoot);
11514
+ const lexicalRoot = path10.resolve(projectRoot);
11515
+ const realRoot = await fsp8.realpath(lexicalRoot).catch(() => lexicalRoot);
11245
11516
  const observations = latestObservations(events, lexicalRoot);
11246
11517
  const results = await mapWithConcurrency(
11247
11518
  observations,
@@ -11256,9 +11527,9 @@ async function validateResumeFileObservations(events, projectRoot) {
11256
11527
  }
11257
11528
  function formatResumeValidationNotice(validation, projectRoot) {
11258
11529
  if (validation.staleFiles.length === 0) return null;
11259
- const root = path9.resolve(projectRoot);
11530
+ const root = path10.resolve(projectRoot);
11260
11531
  const shown = validation.staleFiles.slice(0, NOTICE_PATH_LIMIT).map((entry) => {
11261
- const relative4 = path9.relative(root, entry.path);
11532
+ const relative4 = path10.relative(root, entry.path);
11262
11533
  const display = isInside2(root, entry.path) ? relative4 || "." : entry.path;
11263
11534
  return `- ${JSON.stringify(display)} [${entry.status}]`;
11264
11535
  });
@@ -11380,9 +11651,9 @@ var DefaultSessionStore = class _DefaultSessionStore {
11380
11651
  static LIST_SCAN_CONCURRENCY = 32;
11381
11652
  constructor(opts) {
11382
11653
  this.dir = opts.dir;
11383
- this.projectRoot = opts.projectRoot ? path9.resolve(opts.projectRoot) : void 0;
11654
+ this.projectRoot = opts.projectRoot ? path11.resolve(opts.projectRoot) : void 0;
11384
11655
  this.checkpointCas = this.projectRoot ? new SessionCheckpointCas({
11385
- rootDir: path9.join(this.dir, "_cas"),
11656
+ rootDir: path11.join(this.dir, "_cas"),
11386
11657
  projectRoot: this.projectRoot
11387
11658
  }) : void 0;
11388
11659
  this.events = opts.events;
@@ -11436,17 +11707,17 @@ var DefaultSessionStore = class _DefaultSessionStore {
11436
11707
  }
11437
11708
  /** Absolute path to the session index file. */
11438
11709
  get indexFile() {
11439
- return path9.join(this.dir, "_index.jsonl");
11710
+ return path11.join(this.dir, "_index.jsonl");
11440
11711
  }
11441
11712
  /** Join session ID to its absolute path within the store directory. */
11442
11713
  sessionPath(id, ext) {
11443
11714
  return sessionScopedPath(this.dir, id, ext);
11444
11715
  }
11445
11716
  shardManifestPath(shardKey) {
11446
- return shardKey ? path9.join(this.dir, shardKey, "_manifest.json") : path9.join(this.dir, "_manifest.json");
11717
+ return shardKey ? path11.join(this.dir, shardKey, "_manifest.json") : path11.join(this.dir, "_manifest.json");
11447
11718
  }
11448
11719
  shardKeyForSessionId(id) {
11449
- const dirName = path9.dirname(id);
11720
+ const dirName = path11.dirname(id);
11450
11721
  return dirName === "." ? "" : dirName;
11451
11722
  }
11452
11723
  invalidateShardManifestBySessionId(id) {
@@ -11458,7 +11729,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
11458
11729
  * subdirectory so sessions group naturally by day.
11459
11730
  */
11460
11731
  async ensureShardDir(id) {
11461
- const dirPath = path9.dirname(sessionScopedPath(this.dir, id, ""));
11732
+ const dirPath = path11.dirname(sessionScopedPath(this.dir, id, ""));
11462
11733
  await ensureDir(dirPath);
11463
11734
  return dirPath;
11464
11735
  }
@@ -11520,7 +11791,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
11520
11791
  }
11521
11792
  const parentPrefix = parent.events.slice(0, boundary + 1);
11522
11793
  const workspaceCheckpoint = targetCheckpoint?.workspaceCheckpoint;
11523
- const checkpointHash = createHash("sha256").update(parentPrefix.map((event) => JSON.stringify(event)).join("\n") + "\n", "utf8").digest("hex");
11794
+ const checkpointHash = createHash4("sha256").update(parentPrefix.map((event) => JSON.stringify(event)).join("\n") + "\n", "utf8").digest("hex");
11524
11795
  const inherited = parentPrefix.filter(inheritsIntoFork);
11525
11796
  const writer = await this.create({
11526
11797
  id: "",
@@ -11615,7 +11886,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
11615
11886
  // Shard directory (sessions/<date>/) — must match create() so the
11616
11887
  // .summary.json sidecar lands next to the JSONL instead of the
11617
11888
  // sessions root (where summaryFor() would never find it).
11618
- dir: path9.dirname(file),
11889
+ dir: path11.dirname(file),
11619
11890
  filePath: file,
11620
11891
  secretScrubber: this.secretScrubber,
11621
11892
  checkpointCas: this.checkpointCas,
@@ -12170,7 +12441,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
12170
12441
  return entry;
12171
12442
  }
12172
12443
  async collectSessionFilesInShard(shardKey) {
12173
- const dir = shardKey ? path9.join(this.dir, shardKey) : this.dir;
12444
+ const dir = shardKey ? path11.join(this.dir, shardKey) : this.dir;
12174
12445
  const entries = await this.collectSessionFiles(dir, shardKey);
12175
12446
  return shardKey ? entries.filter((entry) => entry.id.startsWith(`${shardKey}/`)) : entries.filter((entry) => !entry.id.includes("/"));
12176
12447
  }
@@ -12193,13 +12464,13 @@ var DefaultSessionStore = class _DefaultSessionStore {
12193
12464
  if (entry.name === "_index.jsonl") continue;
12194
12465
  const base = entry.name.replace(/\.jsonl$/, "");
12195
12466
  const id = prefix ? `${prefix}/${base}` : base;
12196
- files.push({ id, filePath: path9.join(dir, entry.name) });
12467
+ files.push({ id, filePath: path11.join(dir, entry.name) });
12197
12468
  }
12198
12469
  }
12199
12470
  const childFileArrays = await Promise.all(
12200
12471
  dirEntries.map((entry) => {
12201
12472
  const childPrefix = depth === 0 ? entry.name : `${prefix}/${entry.name}`;
12202
- return this.collectSessionFiles(path9.join(dir, entry.name), childPrefix, depth + 1);
12473
+ return this.collectSessionFiles(path11.join(dir, entry.name), childPrefix, depth + 1);
12203
12474
  })
12204
12475
  );
12205
12476
  return [...childFileArrays.flat(), ...files];
@@ -12232,7 +12503,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
12232
12503
  const childIdArrays = await Promise.all(
12233
12504
  dirEntries.map((entry) => {
12234
12505
  const childPrefix = depth === 0 ? entry.name : `${prefix}/${entry.name}`;
12235
- return this.collectSessionIds(path9.join(dir, entry.name), childPrefix, depth + 1);
12506
+ return this.collectSessionIds(path11.join(dir, entry.name), childPrefix, depth + 1);
12236
12507
  })
12237
12508
  );
12238
12509
  return [...childIdArrays.flat(), ...fileIds];
@@ -12349,9 +12620,9 @@ var DefaultSessionStore = class _DefaultSessionStore {
12349
12620
  async deleteSession(id) {
12350
12621
  const jsonlPath = this.sessionPath(id, ".jsonl");
12351
12622
  const summaryPath = this.sessionPath(id, ".summary.json");
12352
- const shardDir = path9.dirname(jsonlPath);
12353
- const base = path9.basename(id);
12354
- const sessDir = path9.join(shardDir, base);
12623
+ const shardDir = path11.dirname(jsonlPath);
12624
+ const base = path11.basename(id);
12625
+ const sessDir = path11.join(shardDir, base);
12355
12626
  const deletions = [
12356
12627
  fsp9.unlink(jsonlPath),
12357
12628
  fsp9.unlink(summaryPath),
@@ -12392,7 +12663,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
12392
12663
  */
12393
12664
  async readActiveSessionId() {
12394
12665
  try {
12395
- const raw = await fsp9.readFile(path9.join(this.dir, "active.json"), "utf8");
12666
+ const raw = await fsp9.readFile(path11.join(this.dir, "active.json"), "utf8");
12396
12667
  const active = JSON.parse(raw);
12397
12668
  return active.sessionId ?? null;
12398
12669
  } catch {
@@ -12455,7 +12726,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
12455
12726
  const activeSessionId = await this.readActiveSessionId();
12456
12727
  const isPrunableJsonl = (name) => name.endsWith(".jsonl") && name !== "_index.jsonl" && name !== "_mailbox.jsonl" && !name.endsWith(".replay.jsonl") && !name.endsWith(".audit.jsonl");
12457
12728
  const pruneFile = async (dir, name, prefix) => {
12458
- const jsonlPath = path9.join(dir, name);
12729
+ const jsonlPath = path11.join(dir, name);
12459
12730
  try {
12460
12731
  const stat9 = await fsp9.stat(jsonlPath);
12461
12732
  if (stat9.mtimeMs >= cutoff) return;
@@ -12475,7 +12746,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
12475
12746
  continue;
12476
12747
  }
12477
12748
  if (!entry.isDirectory()) continue;
12478
- const dateDir = path9.join(this.dir, entry.name);
12749
+ const dateDir = path11.join(this.dir, entry.name);
12479
12750
  const files = await fsp9.readdir(dateDir, { withFileTypes: true }).catch(() => []);
12480
12751
  for (const file of files) {
12481
12752
  if (!file.isFile() || !isPrunableJsonl(file.name)) continue;
@@ -12487,7 +12758,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
12487
12758
  }
12488
12759
  for (const entry of entries) {
12489
12760
  if (!entry.isDirectory()) continue;
12490
- const dateDir = path9.join(this.dir, entry.name);
12761
+ const dateDir = path11.join(this.dir, entry.name);
12491
12762
  try {
12492
12763
  const remaining = await fsp9.readdir(dateDir);
12493
12764
  if (remaining.length === 0) {
@@ -12618,9 +12889,9 @@ function makeDirectorSessionFactory(opts) {
12618
12889
  let dir;
12619
12890
  if (opts.store) {
12620
12891
  store = opts.store;
12621
- dir = opts.sessionsRoot ? path9.join(opts.sessionsRoot, runId) : "(caller-managed)";
12892
+ dir = opts.sessionsRoot ? path12.join(opts.sessionsRoot, runId) : "(caller-managed)";
12622
12893
  } else if (opts.sessionsRoot) {
12623
- dir = path9.join(opts.sessionsRoot, runId);
12894
+ dir = path12.join(opts.sessionsRoot, runId);
12624
12895
  store = new DefaultSessionStore({ dir });
12625
12896
  } else {
12626
12897
  throw new Error("makeDirectorSessionFactory requires either `store` or `sessionsRoot`");
@@ -12642,6 +12913,11 @@ function makeDirectorSessionFactory(opts) {
12642
12913
  }
12643
12914
  };
12644
12915
  }
12916
+
12917
+ // src/coordination/fleet-manager.ts
12918
+ import { randomUUID as randomUUID9 } from "node:crypto";
12919
+ import * as fsp10 from "node:fs/promises";
12920
+ import * as path13 from "node:path";
12645
12921
  var FleetManager = class {
12646
12922
  /** The fleet-wide event bus. */
12647
12923
  fleet;
@@ -12687,7 +12963,7 @@ var FleetManager = class {
12687
12963
  maxContext;
12688
12964
  constructor(opts = {}) {
12689
12965
  this.manifestPath = opts.manifestPath;
12690
- this.directorRunId = opts.directorRunId ?? randomUUID();
12966
+ this.directorRunId = opts.directorRunId ?? randomUUID9();
12691
12967
  this.maxSpawns = opts.maxSpawns ?? Number.POSITIVE_INFINITY;
12692
12968
  this.maxSpawnDepth = resolveMaxSpawnDepth(opts.maxSpawnDepth);
12693
12969
  this.spawnDepth = opts.spawnDepth ?? 0;
@@ -12902,7 +13178,7 @@ var FleetManager = class {
12902
13178
  })),
12903
13179
  usage: this.usage.snapshot()
12904
13180
  };
12905
- await fsp9.mkdir(path9.dirname(this.manifestPath), { recursive: true });
13181
+ await fsp10.mkdir(path13.dirname(this.manifestPath), { recursive: true });
12906
13182
  await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
12907
13183
  return this.manifestPath;
12908
13184
  }
@@ -13039,6 +13315,11 @@ var FleetManager = class {
13039
13315
  }
13040
13316
  };
13041
13317
 
13318
+ // src/coordination/global-mailbox.ts
13319
+ import { randomUUID as randomUUID10 } from "node:crypto";
13320
+ import * as fsp11 from "node:fs/promises";
13321
+ import * as path14 from "node:path";
13322
+
13042
13323
  // src/coordination/mailbox-types.ts
13043
13324
  function normalizeRecipient(to) {
13044
13325
  return to.trim().toLowerCase() === "all" ? "*" : to.trim();
@@ -13055,7 +13336,7 @@ var REGISTRY_CACHE_TTL_MS = 2e3;
13055
13336
  var LINE_SEPARATOR = "\n";
13056
13337
  var MESSAGE_CACHE_MAX_ENTRIES = 1e4;
13057
13338
  function resolveProjectDir(projectRoot, globalRoot) {
13058
- return path9.join(globalRoot, "projects", projectSlug(projectRoot));
13339
+ return path14.join(globalRoot, "projects", projectSlug(projectRoot));
13059
13340
  }
13060
13341
  var GlobalMailbox = class {
13061
13342
  /** Path to the JSONL message file. */
@@ -13119,14 +13400,14 @@ var GlobalMailbox = class {
13119
13400
  * @param hqPublisher — optional HQ publisher, or getter, for cross-project telemetry
13120
13401
  */
13121
13402
  constructor(projectDir, events, hqPublisher) {
13122
- this.messagePath = path9.join(projectDir, MAILBOX_FILE);
13123
- this.registryPath = path9.join(projectDir, "_mailbox.registry.json");
13124
- this.clientRegistryPath = path9.join(projectDir, CLIENT_REGISTRY_FILE);
13403
+ this.messagePath = path14.join(projectDir, MAILBOX_FILE);
13404
+ this.registryPath = path14.join(projectDir, "_mailbox.registry.json");
13405
+ this.clientRegistryPath = path14.join(projectDir, CLIENT_REGISTRY_FILE);
13125
13406
  this._events = events;
13126
13407
  this._hqPublisher = hqPublisher;
13127
13408
  }
13128
13409
  get hqMailboxId() {
13129
- return `${path9.basename(path9.dirname(this.messagePath))}:mailbox`;
13410
+ return `${path14.basename(path14.dirname(this.messagePath))}:mailbox`;
13130
13411
  }
13131
13412
  get hqPublisher() {
13132
13413
  return typeof this._hqPublisher === "function" ? this._hqPublisher() : this._hqPublisher;
@@ -13147,7 +13428,7 @@ var GlobalMailbox = class {
13147
13428
  async send(input) {
13148
13429
  const now = (/* @__PURE__ */ new Date()).toISOString();
13149
13430
  const msg = {
13150
- id: randomUUID(),
13431
+ id: randomUUID10(),
13151
13432
  from: input.from,
13152
13433
  // "all" is an accepted spelling of the broadcast address — canonical
13153
13434
  // form on disk is '*' so every query/checker matches it.
@@ -13163,9 +13444,9 @@ var GlobalMailbox = class {
13163
13444
  taskContext: input.taskContext
13164
13445
  };
13165
13446
  const line = JSON.stringify(msg) + LINE_SEPARATOR;
13166
- await fsp9.mkdir(path9.dirname(this.messagePath), { recursive: true });
13447
+ await fsp11.mkdir(path14.dirname(this.messagePath), { recursive: true });
13167
13448
  await withFileLock(this.messagePath, async () => {
13168
- await fsp9.appendFile(this.messagePath, line, "utf8");
13449
+ await fsp11.appendFile(this.messagePath, line, "utf8");
13169
13450
  const { mtimeMs, size } = await this._statMessageFile();
13170
13451
  this._pushToCache(msg, mtimeMs, size);
13171
13452
  });
@@ -13236,7 +13517,7 @@ var GlobalMailbox = class {
13236
13517
  }
13237
13518
  if (changed) {
13238
13519
  const serialized = all.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR) + LINE_SEPARATOR;
13239
- await fsp9.writeFile(this.messagePath, serialized, "utf8");
13520
+ await fsp11.writeFile(this.messagePath, serialized, "utf8");
13240
13521
  }
13241
13522
  const { mtimeMs, size } = await this._statMessageFile();
13242
13523
  this._setMessageCache(all, mtimeMs, size);
@@ -13278,7 +13559,7 @@ var GlobalMailbox = class {
13278
13559
  updated = m;
13279
13560
  }
13280
13561
  const serialized = all.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR) + LINE_SEPARATOR;
13281
- await fsp9.writeFile(this.messagePath, serialized, "utf8");
13562
+ await fsp11.writeFile(this.messagePath, serialized, "utf8");
13282
13563
  const { mtimeMs, size } = await this._statMessageFile();
13283
13564
  this._setMessageCache(all, mtimeMs, size);
13284
13565
  });
@@ -13303,7 +13584,7 @@ var GlobalMailbox = class {
13303
13584
  updated = m;
13304
13585
  }
13305
13586
  const serialized = all.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR) + LINE_SEPARATOR;
13306
- await fsp9.writeFile(this.messagePath, serialized, "utf8");
13587
+ await fsp11.writeFile(this.messagePath, serialized, "utf8");
13307
13588
  const { mtimeMs, size } = await this._statMessageFile();
13308
13589
  this._setMessageCache(all, mtimeMs, size);
13309
13590
  });
@@ -13550,7 +13831,7 @@ var GlobalMailbox = class {
13550
13831
  }
13551
13832
  async clearAll() {
13552
13833
  await withFileLock(this.messagePath, async () => {
13553
- await fsp9.writeFile(this.messagePath, "", "utf8");
13834
+ await fsp11.writeFile(this.messagePath, "", "utf8");
13554
13835
  const { mtimeMs, size } = await this._statMessageFile();
13555
13836
  this._setMessageCache([], mtimeMs, size);
13556
13837
  });
@@ -13583,7 +13864,7 @@ var GlobalMailbox = class {
13583
13864
  remaining = kept.length;
13584
13865
  if (kept.length < all.length) {
13585
13866
  const content = kept.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR) + LINE_SEPARATOR;
13586
- await fsp9.writeFile(this.messagePath, content, "utf8");
13867
+ await fsp11.writeFile(this.messagePath, content, "utf8");
13587
13868
  }
13588
13869
  const { mtimeMs, size } = await this._statMessageFile();
13589
13870
  this._setMessageCache(kept, mtimeMs, size);
@@ -13604,7 +13885,7 @@ var GlobalMailbox = class {
13604
13885
  */
13605
13886
  async _readMessages() {
13606
13887
  try {
13607
- const raw = await fsp9.readFile(this.messagePath, "utf8");
13888
+ const raw = await fsp11.readFile(this.messagePath, "utf8");
13608
13889
  return this._parseLines(raw);
13609
13890
  } catch (err) {
13610
13891
  if (err.code === "ENOENT") return [];
@@ -13697,7 +13978,7 @@ var GlobalMailbox = class {
13697
13978
  */
13698
13979
  async _statMessageFile() {
13699
13980
  try {
13700
- const st = await fsp9.stat(this.messagePath);
13981
+ const st = await fsp11.stat(this.messagePath);
13701
13982
  return { mtimeMs: st.mtimeMs, size: st.size };
13702
13983
  } catch (err) {
13703
13984
  if (err.code === "ENOENT") {
@@ -13743,12 +14024,12 @@ var GlobalMailbox = class {
13743
14024
  */
13744
14025
  async _readMessagesCachedWork() {
13745
14026
  try {
13746
- const st = await fsp9.stat(this.messagePath);
14027
+ const st = await fsp11.stat(this.messagePath);
13747
14028
  if (this._messageCache !== null && this._messageCacheMtime === st.mtimeMs && this._messageCacheSize === st.size) {
13748
14029
  return this._messageCache;
13749
14030
  }
13750
14031
  if (this._messageCache !== null && this._messageCacheSize >= 0 && st.size > this._messageCacheSize) {
13751
- const fd = await fsp9.open(this.messagePath, "r");
14032
+ const fd = await fsp11.open(this.messagePath, "r");
13752
14033
  try {
13753
14034
  const updated = await this._readNewMessagesOnly(fd, this._messageCacheSize, st.size);
13754
14035
  this._messageCacheMtime = st.mtimeMs;
@@ -13824,14 +14105,14 @@ var GlobalMailbox = class {
13824
14105
  this._messageCacheSize = size;
13825
14106
  }
13826
14107
  async _ensureRegistry() {
13827
- await fsp9.mkdir(path9.dirname(this.registryPath), { recursive: true });
14108
+ await fsp11.mkdir(path14.dirname(this.registryPath), { recursive: true });
13828
14109
  }
13829
14110
  async _readRegistry(opts) {
13830
14111
  if (!opts?.fresh && this._registryCache && Date.now() - this._registryCacheAt < REGISTRY_CACHE_TTL_MS) {
13831
14112
  return new Map(this._registryCache);
13832
14113
  }
13833
14114
  try {
13834
- const raw = await fsp9.readFile(this.registryPath, "utf8");
14115
+ const raw = await fsp11.readFile(this.registryPath, "utf8");
13835
14116
  const data = JSON.parse(raw);
13836
14117
  const map = /* @__PURE__ */ new Map();
13837
14118
  for (const [id, agent] of Object.entries(data)) {
@@ -13873,20 +14154,20 @@ var GlobalMailbox = class {
13873
14154
  for (const [id, agent] of registry) {
13874
14155
  obj[id] = agent;
13875
14156
  }
13876
- const tmp = `${this.registryPath}.${randomUUID().slice(0, 8)}.tmp`;
13877
- await fsp9.writeFile(tmp, JSON.stringify(obj), "utf8");
13878
- await fsp9.rename(tmp, this.registryPath);
14157
+ const tmp = `${this.registryPath}.${randomUUID10().slice(0, 8)}.tmp`;
14158
+ await fsp11.writeFile(tmp, JSON.stringify(obj), "utf8");
14159
+ await fsp11.rename(tmp, this.registryPath);
13879
14160
  }
13880
14161
  // ── Client registry internals ───────────────────────────────────────────
13881
14162
  async _ensureClientRegistry() {
13882
- await fsp9.mkdir(path9.dirname(this.clientRegistryPath), { recursive: true });
14163
+ await fsp11.mkdir(path14.dirname(this.clientRegistryPath), { recursive: true });
13883
14164
  }
13884
14165
  async _readClientRegistry(opts) {
13885
14166
  if (!opts?.fresh && this._clientRegistryCache && Date.now() - this._clientRegistryCacheAt < REGISTRY_CACHE_TTL_MS) {
13886
14167
  return new Map(this._clientRegistryCache);
13887
14168
  }
13888
14169
  try {
13889
- const raw = await fsp9.readFile(this.clientRegistryPath, "utf8");
14170
+ const raw = await fsp11.readFile(this.clientRegistryPath, "utf8");
13890
14171
  const data = JSON.parse(raw);
13891
14172
  const map = /* @__PURE__ */ new Map();
13892
14173
  for (const [id, client] of Object.entries(data)) {
@@ -13918,16 +14199,19 @@ var GlobalMailbox = class {
13918
14199
  for (const [id, client] of registry) {
13919
14200
  obj[id] = client;
13920
14201
  }
13921
- const tmp = `${this.clientRegistryPath}.${randomUUID().slice(0, 8)}.tmp`;
13922
- await fsp9.writeFile(tmp, JSON.stringify(obj), "utf8");
13923
- await fsp9.rename(tmp, this.clientRegistryPath);
14202
+ const tmp = `${this.clientRegistryPath}.${randomUUID10().slice(0, 8)}.tmp`;
14203
+ await fsp11.writeFile(tmp, JSON.stringify(obj), "utf8");
14204
+ await fsp11.rename(tmp, this.clientRegistryPath);
13924
14205
  }
13925
14206
  };
14207
+
14208
+ // src/coordination/mailbox-tool.ts
14209
+ import { createHash as createHash5 } from "node:crypto";
13926
14210
  function defaultResolveProjectDir(ctx) {
13927
14211
  return resolveProjectDir(ctx.projectRoot, wstackGlobalRoot());
13928
14212
  }
13929
14213
  function mailboxSessionTag(sessionId) {
13930
- return createHash("sha256").update(sessionId).digest("hex").slice(0, 8);
14214
+ return createHash5("sha256").update(sessionId).digest("hex").slice(0, 8);
13931
14215
  }
13932
14216
  function resolveMailboxIdentity(ctx, fallbackBase = "leader") {
13933
14217
  const fieldId = ctx.agentId && ctx.agentId !== "unknown" ? ctx.agentId : void 0;
@@ -14273,6 +14557,9 @@ function makeFleetStatusTool(opts = {}) {
14273
14557
  }
14274
14558
  };
14275
14559
  }
14560
+
14561
+ // src/coordination/fleet-supervisor.ts
14562
+ import { randomUUID as randomUUID11 } from "node:crypto";
14276
14563
  var COLLAB_ID_PREFIXES = ["bug-hunter-", "refactor-planner-", "critic-"];
14277
14564
  var DEFAULTS = {
14278
14565
  intervalMs: 2e4,
@@ -14514,7 +14801,7 @@ var FleetSupervisor = class {
14514
14801
  */
14515
14802
  async decide(question, context, options, risk) {
14516
14803
  const request = {
14517
- id: `fleetsup-${randomUUID()}`,
14804
+ id: `fleetsup-${randomUUID11()}`,
14518
14805
  sessionId: this.opts.sessionId?.(),
14519
14806
  source: "system",
14520
14807
  question,
@@ -15002,6 +15289,11 @@ function makeMailInboxTool(opts = {}) {
15002
15289
  }
15003
15290
  };
15004
15291
  }
15292
+
15293
+ // src/coordination/mailbox.ts
15294
+ import { randomUUID as randomUUID12 } from "node:crypto";
15295
+ import * as fsp12 from "node:fs/promises";
15296
+ import * as path15 from "node:path";
15005
15297
  var MAILBOX_FILE2 = "_mailbox.jsonl";
15006
15298
  var LINE_SEPARATOR2 = "\n";
15007
15299
  var MESSAGE_CACHE_MAX_ENTRIES2 = 1e4;
@@ -15017,7 +15309,7 @@ var DefaultMailbox = class {
15017
15309
  /** Counts malformed JSONL lines skipped during parsing for observability. */
15018
15310
  _corruptionCount = 0;
15019
15311
  constructor(sessionDir) {
15020
- this.filePath = path9.join(sessionDir, MAILBOX_FILE2);
15312
+ this.filePath = path15.join(sessionDir, MAILBOX_FILE2);
15021
15313
  }
15022
15314
  get mailboxPath() {
15023
15315
  return this.filePath;
@@ -15030,7 +15322,7 @@ var DefaultMailbox = class {
15030
15322
  async send(input) {
15031
15323
  const now = (/* @__PURE__ */ new Date()).toISOString();
15032
15324
  const msg = {
15033
- id: randomUUID(),
15325
+ id: randomUUID12(),
15034
15326
  from: input.from,
15035
15327
  // "all" is an accepted spelling of the broadcast address — canonical
15036
15328
  // form on disk is '*' so every query/checker matches it.
@@ -15046,9 +15338,9 @@ var DefaultMailbox = class {
15046
15338
  taskContext: input.taskContext
15047
15339
  };
15048
15340
  const line = JSON.stringify(msg) + LINE_SEPARATOR2;
15049
- await fsp9.mkdir(path9.dirname(this.filePath), { recursive: true });
15341
+ await fsp12.mkdir(path15.dirname(this.filePath), { recursive: true });
15050
15342
  await withFileLock(this.filePath, async () => {
15051
- await fsp9.appendFile(this.filePath, line, "utf8");
15343
+ await fsp12.appendFile(this.filePath, line, "utf8");
15052
15344
  this._pushToCache(msg);
15053
15345
  const { mtime, size } = await this._statUnderLockOrAbsent();
15054
15346
  this._messageCacheMtime = mtime;
@@ -15148,7 +15440,7 @@ var DefaultMailbox = class {
15148
15440
  }
15149
15441
  if (changed) {
15150
15442
  const serialized = all.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR2) + LINE_SEPARATOR2;
15151
- await fsp9.writeFile(this.filePath, serialized, "utf8");
15443
+ await fsp12.writeFile(this.filePath, serialized, "utf8");
15152
15444
  }
15153
15445
  const { mtime, size } = await this._statUnderLockOrAbsent();
15154
15446
  this._setMessageCache(all, mtime, size);
@@ -15209,7 +15501,7 @@ var DefaultMailbox = class {
15209
15501
  }
15210
15502
  async clearAll() {
15211
15503
  await withFileLock(this.filePath, async () => {
15212
- await fsp9.writeFile(this.filePath, "", "utf8");
15504
+ await fsp12.writeFile(this.filePath, "", "utf8");
15213
15505
  const { mtime, size } = await this._statUnderLockOrAbsent();
15214
15506
  this._setMessageCache([], mtime, size);
15215
15507
  });
@@ -15242,7 +15534,7 @@ var DefaultMailbox = class {
15242
15534
  remaining = kept.length;
15243
15535
  if (kept.length < all.length) {
15244
15536
  const content = kept.map((m) => JSON.stringify(m)).join(LINE_SEPARATOR2) + LINE_SEPARATOR2;
15245
- await fsp9.writeFile(this.filePath, content, "utf8");
15537
+ await fsp12.writeFile(this.filePath, content, "utf8");
15246
15538
  }
15247
15539
  const { mtime, size } = await this._statUnderLockOrAbsent();
15248
15540
  this._setMessageCache(kept, mtime, size);
@@ -15265,7 +15557,7 @@ var DefaultMailbox = class {
15265
15557
  // ── Internal ──────────────────────────────────────────────────────────
15266
15558
  async _readAll() {
15267
15559
  try {
15268
- const raw = await fsp9.readFile(this.filePath, "utf8");
15560
+ const raw = await fsp12.readFile(this.filePath, "utf8");
15269
15561
  return this._parseLines(raw);
15270
15562
  } catch (err) {
15271
15563
  if (err.code === "ENOENT") return [];
@@ -15340,7 +15632,7 @@ var DefaultMailbox = class {
15340
15632
  */
15341
15633
  async _statUnderLockOrAbsent() {
15342
15634
  try {
15343
- const st = await fsp9.stat(this.filePath);
15635
+ const st = await fsp12.stat(this.filePath);
15344
15636
  return { mtime: st.mtimeMs, size: st.size };
15345
15637
  } catch (err) {
15346
15638
  if (err.code === "ENOENT") {
@@ -15351,12 +15643,12 @@ var DefaultMailbox = class {
15351
15643
  }
15352
15644
  async _readAllCached() {
15353
15645
  try {
15354
- const st = await fsp9.stat(this.filePath);
15646
+ const st = await fsp12.stat(this.filePath);
15355
15647
  if (this._messageCache !== null && this._messageCacheMtime === st.mtimeMs && this._messageCacheSize === st.size) {
15356
15648
  return this._messageCache;
15357
15649
  }
15358
15650
  if (this._messageCache !== null && this._messageCacheSize >= 0 && st.size > this._messageCacheSize) {
15359
- const fd = await fsp9.open(this.filePath, "r");
15651
+ const fd = await fsp12.open(this.filePath, "r");
15360
15652
  try {
15361
15653
  const updated = await this._readNewMessagesOnly(fd, this._messageCacheSize, st.size);
15362
15654
  this._messageCacheMtime = st.mtimeMs;
@@ -15695,14 +15987,18 @@ function createMailboxHooks(opts) {
15695
15987
 
15696
15988
  // src/coordination/null-fleet-bus.ts
15697
15989
  var NULL_FLEET_BUS = new FleetBus();
15990
+
15991
+ // src/coordination/package-author-tracker.ts
15992
+ import * as fs2 from "node:fs/promises";
15993
+ import * as path16 from "node:path";
15698
15994
  var DEFAULT_MAX_ENTRIES = 1e4;
15699
15995
  var LOG_FILENAME = "package-authors.json";
15700
15996
  function logPath(storageDir) {
15701
- return path9.join(storageDir, LOG_FILENAME);
15997
+ return path16.join(storageDir, LOG_FILENAME);
15702
15998
  }
15703
15999
  async function loadLog(storageDir, projectRoot) {
15704
16000
  try {
15705
- const raw = await fsp9.readFile(logPath(storageDir), "utf-8");
16001
+ const raw = await fs2.readFile(logPath(storageDir), "utf-8");
15706
16002
  const parsed = JSON.parse(raw);
15707
16003
  if (!parsed.entries || !Array.isArray(parsed.entries)) {
15708
16004
  return { projectRoot, entries: [] };
@@ -15716,13 +16012,13 @@ async function loadLog(storageDir, projectRoot) {
15716
16012
  }
15717
16013
  }
15718
16014
  async function saveLog(storageDir, log) {
15719
- await fsp9.mkdir(storageDir, { recursive: true });
16015
+ await fs2.mkdir(storageDir, { recursive: true });
15720
16016
  const tmp = `${logPath(storageDir)}.tmp.${Date.now()}`;
15721
- await fsp9.writeFile(tmp, JSON.stringify(log, null, 2) + "\n", "utf-8");
15722
- await fsp9.rename(tmp, logPath(storageDir));
16017
+ await fs2.writeFile(tmp, JSON.stringify(log, null, 2) + "\n", "utf-8");
16018
+ await fs2.rename(tmp, logPath(storageDir));
15723
16019
  }
15724
16020
  function detectEcosystem(manifestPath) {
15725
- const name = path9.basename(manifestPath).toLowerCase();
16021
+ const name = path16.basename(manifestPath).toLowerCase();
15726
16022
  if (name === "package.json") return "npm";
15727
16023
  if (name === "go.mod") return "go";
15728
16024
  if (name === "cargo.toml") return "cargo";
@@ -15967,11 +16263,18 @@ mvn versions:use-latest-versions`;
15967
16263
  return `# Update ${entry.name} to ${entry.latestVersion} using your package manager`;
15968
16264
  }
15969
16265
  }
16266
+
16267
+ // src/coordination/single-instance-mailbox.ts
16268
+ import { randomBytes as randomBytes3 } from "node:crypto";
16269
+ import * as fsp13 from "node:fs/promises";
16270
+ import { execFileSync } from "node:child_process";
16271
+ import * as os3 from "node:os";
16272
+ import * as path17 from "node:path";
15970
16273
  var MAILBOX_BRIDGE_LOCK_FILENAME = ".mailbox-bridge.lock";
15971
16274
  var MAILBOX_BRIDGE_TOKEN_FILENAME = ".mailbox.token";
15972
16275
  async function acquireOrJoin(opts) {
15973
- const lockPath = path9.join(opts.projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
15974
- const tokenPath = path9.join(opts.projectDir, MAILBOX_BRIDGE_TOKEN_FILENAME);
16276
+ const lockPath = path17.join(opts.projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
16277
+ const tokenPath = path17.join(opts.projectDir, MAILBOX_BRIDGE_TOKEN_FILENAME);
15975
16278
  const inspected = await readLockForInspection(lockPath);
15976
16279
  if (inspected.kind === "live") {
15977
16280
  const existing = inspected.lock;
@@ -15981,10 +16284,10 @@ async function acquireOrJoin(opts) {
15981
16284
  return { kind: "joined", lock: existing, tokenPath };
15982
16285
  }
15983
16286
  if (inspected.kind === "stale") {
15984
- await fsp9.unlink(lockPath).catch(() => void 0);
16287
+ await fsp13.unlink(lockPath).catch(() => void 0);
15985
16288
  }
15986
16289
  const generation = inspected.kind === "stale" ? inspected.lock.generation + 1 : 1;
15987
- const token = randomBytes(32).toString("hex");
16290
+ const token = randomBytes3(32).toString("hex");
15988
16291
  const tentative = {
15989
16292
  pid: process.pid,
15990
16293
  host: opts.host,
@@ -15999,34 +16302,34 @@ async function acquireOrJoin(opts) {
15999
16302
  return { kind: "acquired", lock: tentative, tokenPath };
16000
16303
  }
16001
16304
  async function finalize(projectDir, tentative, boundPort) {
16002
- const lockPath = path9.join(projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
16003
- const tokenPath = path9.join(projectDir, MAILBOX_BRIDGE_TOKEN_FILENAME);
16305
+ const lockPath = path17.join(projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
16306
+ const tokenPath = path17.join(projectDir, MAILBOX_BRIDGE_TOKEN_FILENAME);
16004
16307
  const finalized = {
16005
16308
  ...tentative,
16006
16309
  port: boundPort,
16007
16310
  url: `http://${tentative.host}:${boundPort}`
16008
16311
  };
16009
16312
  await atomicWriteJson(lockPath, finalized);
16010
- await fsp9.writeFile(tokenPath, finalized.token, { mode: 384 });
16313
+ await fsp13.writeFile(tokenPath, finalized.token, { mode: 384 });
16011
16314
  return finalized;
16012
16315
  }
16013
16316
  async function release(projectDir, generation) {
16014
- const lockPath = path9.join(projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
16015
- const tokenPath = path9.join(projectDir, MAILBOX_BRIDGE_TOKEN_FILENAME);
16317
+ const lockPath = path17.join(projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
16318
+ const tokenPath = path17.join(projectDir, MAILBOX_BRIDGE_TOKEN_FILENAME);
16016
16319
  try {
16017
- const raw = await fsp9.readFile(lockPath, "utf-8");
16320
+ const raw = await fsp13.readFile(lockPath, "utf-8");
16018
16321
  const parsed = JSON.parse(raw);
16019
16322
  if (parsed.generation !== generation) return;
16020
16323
  if (parsed.pid !== process.pid) return;
16021
- await fsp9.unlink(lockPath).catch(() => void 0);
16022
- await fsp9.unlink(tokenPath).catch(() => void 0);
16324
+ await fsp13.unlink(lockPath).catch(() => void 0);
16325
+ await fsp13.unlink(tokenPath).catch(() => void 0);
16023
16326
  } catch {
16024
16327
  }
16025
16328
  }
16026
16329
  async function readLockForInspection(lockPath) {
16027
16330
  let raw;
16028
16331
  try {
16029
- raw = await fsp9.readFile(lockPath, "utf-8");
16332
+ raw = await fsp13.readFile(lockPath, "utf-8");
16030
16333
  } catch {
16031
16334
  return { kind: "absent" };
16032
16335
  }
@@ -16034,7 +16337,7 @@ async function readLockForInspection(lockPath) {
16034
16337
  try {
16035
16338
  parsed = JSON.parse(raw);
16036
16339
  } catch {
16037
- await fsp9.unlink(lockPath).catch(() => void 0);
16340
+ await fsp13.unlink(lockPath).catch(() => void 0);
16038
16341
  return { kind: "absent" };
16039
16342
  }
16040
16343
  if (!isProcessAlive(parsed.pid)) {
@@ -16046,7 +16349,7 @@ async function readLockForInspection(lockPath) {
16046
16349
  return { kind: "live", lock: parsed };
16047
16350
  }
16048
16351
  async function readLiveLock(projectDir) {
16049
- const lockPath = path9.join(projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
16352
+ const lockPath = path17.join(projectDir, MAILBOX_BRIDGE_LOCK_FILENAME);
16050
16353
  const result = await readLockForInspection(lockPath);
16051
16354
  if (result.kind === "live") {
16052
16355
  return { kind: "live", lock: result.lock };
@@ -16057,22 +16360,22 @@ async function readLiveLock(projectDir) {
16057
16360
  return { kind: "absent" };
16058
16361
  }
16059
16362
  async function atomicWriteJson(targetPath, value) {
16060
- const dir = path9.dirname(targetPath);
16061
- await fsp9.mkdir(dir, { recursive: true });
16062
- const tmp = `${targetPath}.tmp.${process.pid}.${randomBytes(4).toString("hex")}`;
16363
+ const dir = path17.dirname(targetPath);
16364
+ await fsp13.mkdir(dir, { recursive: true });
16365
+ const tmp = `${targetPath}.tmp.${process.pid}.${randomBytes3(4).toString("hex")}`;
16063
16366
  const body = JSON.stringify(value, null, 2) + "\n";
16064
- await fsp9.writeFile(tmp, body, { mode: 384 });
16367
+ await fsp13.writeFile(tmp, body, { mode: 384 });
16065
16368
  try {
16066
- await fsp9.rename(tmp, targetPath);
16369
+ await fsp13.rename(tmp, targetPath);
16067
16370
  } catch (err) {
16068
- await fsp9.unlink(tmp).catch(() => void 0);
16371
+ await fsp13.unlink(tmp).catch(() => void 0);
16069
16372
  throw err;
16070
16373
  }
16071
16374
  }
16072
16375
  function isProcessAlive(pid) {
16073
16376
  if (!Number.isInteger(pid) || pid <= 0) return false;
16074
16377
  if (pid === process.pid) return true;
16075
- if (os.platform() === "win32") {
16378
+ if (os3.platform() === "win32") {
16076
16379
  try {
16077
16380
  const out = execFileSync("tasklist", ["/FI", `PID eq ${pid}`, "/NH", "/FO", "CSV"], {
16078
16381
  encoding: "utf-8",
@@ -16279,6 +16582,10 @@ var AdaptiveConcurrencyController = class {
16279
16582
  };
16280
16583
  }
16281
16584
  };
16585
+
16586
+ // src/coordination/agent-monitor.ts
16587
+ import * as fs3 from "node:fs/promises";
16588
+ import * as path18 from "node:path";
16282
16589
  var AgentMonitorService = class {
16283
16590
  _fleetBus;
16284
16591
  _events;
@@ -16417,6 +16724,13 @@ var AgentMonitorService = class {
16417
16724
  task: session.task
16418
16725
  });
16419
16726
  }
16727
+ /** Drop a retired subagent from every live in-memory monitor surface. */
16728
+ removeSubagent(subagentId) {
16729
+ this._sessions.delete(subagentId);
16730
+ const dispose = this._subscriptions.get(subagentId);
16731
+ if (dispose) dispose();
16732
+ this._subscriptions.delete(subagentId);
16733
+ }
16420
16734
  // ── Internal ───────────────────────────────────────────────────────
16421
16735
  _routeEvent(subagentId, type, payload) {
16422
16736
  const session = this._sessions.get(subagentId);
@@ -16529,11 +16843,11 @@ var AgentMonitorService = class {
16529
16843
  this._onEntry?.(entry);
16530
16844
  }
16531
16845
  async _appendToFile(subagentId, entry) {
16532
- const dir = path9.join(this._transcriptsDir, subagentId);
16533
- await fsp9.mkdir(dir, { recursive: true });
16534
- const filePath = path9.join(dir, "transcript.jsonl");
16846
+ const dir = path18.join(this._transcriptsDir, subagentId);
16847
+ await fs3.mkdir(dir, { recursive: true });
16848
+ const filePath = path18.join(dir, "transcript.jsonl");
16535
16849
  const line = JSON.stringify(entry) + "\n";
16536
- await fsp9.appendFile(filePath, line, { encoding: "utf8" });
16850
+ await fs3.appendFile(filePath, line, { encoding: "utf8" });
16537
16851
  }
16538
16852
  _uid() {
16539
16853
  return `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
@@ -16568,6 +16882,9 @@ ${output}${suffix}`;
16568
16882
  function createAgentMonitorService(opts) {
16569
16883
  return new AgentMonitorService(opts);
16570
16884
  }
16885
+
16886
+ // src/coordination/autonomous-brain.ts
16887
+ import { randomUUID as randomUUID13 } from "node:crypto";
16571
16888
  var AutonomousBrain = class {
16572
16889
  graph;
16573
16890
  // Fleet bus for emitting decisions — null-safe, no-op if not provided
@@ -16675,7 +16992,7 @@ var AutonomousBrain = class {
16675
16992
  consequence: i === 0 ? `Spawn the most appropriate agent for: ${taskDescription.slice(0, 80)}` : `Spawn an alternative agent for the same task`
16676
16993
  }));
16677
16994
  return this.decideAuto({
16678
- id: randomUUID(),
16995
+ id: randomUUID13(),
16679
16996
  source,
16680
16997
  decisionType: "spawn",
16681
16998
  question: `Should we spawn a subagent for this task?`,
@@ -16718,7 +17035,7 @@ var AutonomousBrain = class {
16718
17035
  }
16719
17036
  ];
16720
17037
  return this.decideAuto({
16721
- id: randomUUID(),
17038
+ id: randomUUID13(),
16722
17039
  source,
16723
17040
  decisionType: "approve_change",
16724
17041
  question: `Should we approve the change "${change.title}"?`,
@@ -16777,7 +17094,7 @@ var AutonomousBrain = class {
16777
17094
  consequence: "Break the task into smaller sub-tasks"
16778
17095
  });
16779
17096
  return this.decideAuto({
16780
- id: randomUUID(),
17097
+ id: randomUUID13(),
16781
17098
  source,
16782
17099
  decisionType: "escalate_task",
16783
17100
  question: `Task failed: ${error.slice(0, 100)}. How should we proceed?`,
@@ -16910,6 +17227,14 @@ ${ctx.error}`);
16910
17227
  return "low";
16911
17228
  }
16912
17229
  };
17230
+
17231
+ // src/coordination/autonomous-coordinator.ts
17232
+ import { randomUUID as randomUUID16 } from "node:crypto";
17233
+
17234
+ // src/coordination/knowledge-graph.ts
17235
+ import { randomUUID as randomUUID14 } from "node:crypto";
17236
+ import * as fsp14 from "node:fs/promises";
17237
+ import * as path19 from "node:path";
16913
17238
  var KnowledgeGraph = class {
16914
17239
  nodes = /* @__PURE__ */ new Map();
16915
17240
  index = /* @__PURE__ */ new Map();
@@ -16937,8 +17262,8 @@ var KnowledgeGraph = class {
16937
17262
  return this.index;
16938
17263
  }
16939
17264
  constructor(sessionDir) {
16940
- this.filePath = path9.join(sessionDir, "_knowledge_graph");
16941
- this.graphFilePath = path9.join(this.filePath, "graph.jsonl");
17265
+ this.filePath = path19.join(sessionDir, "_knowledge_graph");
17266
+ this.graphFilePath = path19.join(this.filePath, "graph.jsonl");
16942
17267
  }
16943
17268
  // ── Write ──────────────────────────────────────────────────────────────
16944
17269
  /**
@@ -16946,7 +17271,7 @@ var KnowledgeGraph = class {
16946
17271
  * Returns the node with its assigned id.
16947
17272
  */
16948
17273
  async add(node) {
16949
- const full = { id: randomUUID(), ...node };
17274
+ const full = { id: randomUUID14(), ...node };
16950
17275
  this.nodes.set(full.id, full);
16951
17276
  this._trackSeq(full.id);
16952
17277
  this._addToIndex(full, this._indexKeys(full));
@@ -17029,8 +17354,8 @@ var KnowledgeGraph = class {
17029
17354
  * used to poll for new nodes since the last check.
17030
17355
  */
17031
17356
  subscribe(agentId, filter) {
17032
- const channel = randomUUID();
17033
- const sub = { id: randomUUID(), agentId, filter, channel };
17357
+ const channel = randomUUID14();
17358
+ const sub = { id: randomUUID14(), agentId, filter, channel };
17034
17359
  this.subs.set(channel, sub);
17035
17360
  this.pendingDeliveries.set(channel, []);
17036
17361
  return channel;
@@ -17120,7 +17445,8 @@ var KnowledgeGraph = class {
17120
17445
  const nodeTags = node.tags ?? node.tags ?? [];
17121
17446
  if (!f.tags.some((t) => nodeTags.includes(t))) return false;
17122
17447
  }
17123
- if (f.since && node.id > f.since) ;
17448
+ if (f.since && node.id > f.since) {
17449
+ }
17124
17450
  return true;
17125
17451
  }
17126
17452
  _deliver(node) {
@@ -17132,23 +17458,23 @@ var KnowledgeGraph = class {
17132
17458
  }
17133
17459
  }
17134
17460
  async _persist(node) {
17135
- await fsp9.mkdir(this.filePath, { recursive: true });
17461
+ await fsp14.mkdir(this.filePath, { recursive: true });
17136
17462
  const line = JSON.stringify(node) + "\n";
17137
17463
  await withFileLock(this.graphFilePath, async () => {
17138
- await fsp9.appendFile(this.graphFilePath, line, "utf8");
17464
+ await fsp14.appendFile(this.graphFilePath, line, "utf8");
17139
17465
  });
17140
17466
  }
17141
17467
  async _append(node) {
17142
- await fsp9.mkdir(this.filePath, { recursive: true });
17468
+ await fsp14.mkdir(this.filePath, { recursive: true });
17143
17469
  const line = JSON.stringify({ op: "update", node }) + "\n";
17144
17470
  await withFileLock(this.graphFilePath, async () => {
17145
- await fsp9.appendFile(this.graphFilePath, line, "utf8");
17471
+ await fsp14.appendFile(this.graphFilePath, line, "utf8");
17146
17472
  });
17147
17473
  }
17148
17474
  /** Rebuild in-memory state from the log file. Call on startup. */
17149
17475
  async load() {
17150
17476
  try {
17151
- const content = await fsp9.readFile(this.graphFilePath, "utf8");
17477
+ const content = await fsp14.readFile(this.graphFilePath, "utf8");
17152
17478
  const lines = content.split("\n").filter(Boolean);
17153
17479
  for (const line of lines) {
17154
17480
  try {
@@ -17470,6 +17796,9 @@ var TaskDAG = class {
17470
17796
  return false;
17471
17797
  }
17472
17798
  };
17799
+
17800
+ // src/coordination/task-auctioneer.ts
17801
+ import { randomUUID as randomUUID15 } from "node:crypto";
17473
17802
  var TaskAuctioneer = class {
17474
17803
  graph;
17475
17804
  fleet;
@@ -17589,7 +17918,7 @@ var TaskAuctioneer = class {
17589
17918
  const score = dispatchResult.confidence * (dispatchResult.role === agent.agentRole ? 1.2 : 1);
17590
17919
  if (score < this.minConfidence) return false;
17591
17920
  const bid = {
17592
- id: randomUUID(),
17921
+ id: randomUUID15(),
17593
17922
  taskId,
17594
17923
  agentId: agent.agentId,
17595
17924
  agentName: agent.agentName,
@@ -18515,7 +18844,7 @@ var AutonomousCoordinator = class _AutonomousCoordinator {
18515
18844
  break;
18516
18845
  }
18517
18846
  const decision = await this.brain.decideAuto({
18518
- id: randomUUID(),
18847
+ id: randomUUID16(),
18519
18848
  source: "system",
18520
18849
  decisionType: "prioritize_goals",
18521
18850
  question: `What should we work on next? Open goals: ${dispatchable.map((g) => g.title).join(", ")}`,
@@ -19010,7 +19339,163 @@ ${input.detail}`
19010
19339
  this.onCoordinatorEvent?.(event);
19011
19340
  }
19012
19341
  };
19013
-
19014
- export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, TOOLS as AGENT_TOOL_PRESETS, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AdaptiveConcurrencyController, AgentMonitorService, AutonomousBrain, AutonomousCoordinator, BUG_HUNTER_AGENT, BUILD_AGENTS, BrainDecisionQueue, BrainMonitor, BudgetExceededError, BudgetThresholdSignal, ChangeManager, CollabSession, ConsensusProtocol, DECISION_TIMEOUT_MS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_MAX_FLEET_SPAWNS, DEFAULT_QUALITY_CHECKS, DEFAULT_SUBAGENT_BASELINE, DELIVERY_AGENTS, DEPENDENCY_FILE_PATTERNS, DISCOVERY_AGENTS, DOMAIN_AGENTS, DefaultBrainArbiter, DefaultMailbox, DefaultMultiAgentCoordinator, Director, DirectorAlertLevel, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetSupervisor, FleetTokenCapError, FleetUsageAggregator, GlobalMailbox, HARD_MAX_SPAWN_DEPTH, HEAVY_BUDGET, HumanEscalatingBrainArbiter, InMemoryAgentBridge, InMemoryBridgeTransport, KNOWLEDGE_AGENTS, KnowledgeGraph, LIGHT_BUDGET, LargeAnswerStore, MAILBOX_BRIDGE_LOCK_FILENAME, MAILBOX_BRIDGE_TOKEN_FILENAME, MAILBOX_HEALTH_DEFAULT_FAILURE_THRESHOLD, MAILBOX_HEALTH_DEFAULT_FROM, MAILBOX_HEALTH_DEFAULT_INTERVAL_MS, MAILBOX_HEALTH_DEFAULT_TIMEOUT_MS, MATRIX_PHASE_KEYS, MAX_SUBAGENT_STRUCTURED_REPORT_CHARS, MEDIUM_BUDGET, META_AGENTS, MailboxHealthWatchdog, NULL_FLEET_BUS, ObservableBrainArbiter, PLANNING_AGENTS, REFACTOR_PLANNER_AGENT, REVIEW_AGENTS, SECURITY_SCANNER_AGENT, SUBAGENT_STRUCTURED_REPORT_META_KEY, SubagentBudget, TIMEOUT_PREEMPT_FRACTION, TaskAuctioneer, TaskDAG, VERIFY_AGENTS, WorktreeIntegrationError, acquireOrJoin, actionToAckInput, applyRosterBudget, attachAutoExtend, attachDepWatcherBridge, buildDownAlert, buildRecoveryAlert, composeDirectorPrompt, composeSubagentPrompt, createAgentMonitorService, createDelegateTool, createMailboxHooks, createMessage, detectEcosystem, dispatchAgent, finalize, formatHumanPrompt, formatSubagentStructuredReport, getAgentDefinition, getFullPackageLog, getManifestPackages, getPackageAuthor, getPackagesByAgent, isValidMatrixKey, mailboxSessionTag, makeAgentSubagentRunner, makeAskResultTool, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeCollabDebugTool, makeDependencyWatcherConfig, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetTool as makeFleetHealthTool, makeFleetTool as makeFleetSessionTool, makeFleetStatusTool, makeFleetTool, makeFleetTool as makeFleetUsageTool, makeKanbanQueueTool, makeLLMClassifier, makeMailInboxTool, makeMailSendTool, makeMailboxTool, makeQualityGateTool, makeRollUpTool, makeSpawnTool, makeSubagentResultTool, makeTerminateAllTool, makeTerminateTool, makeWorkCompleteTool, matrixKeyKind, normalizeRecipient, normalizeSubagentStructuredReport, phaseForRole, readLiveLock, readSubagentStructuredReport, recordPackageAction, release, resolveImplementationModelTarget, resolveMailboxIdentity, resolveMaxSpawnDepth, resolveModelMatrix, resolveModelMatrixResolution, resolveModelTargetFromEntry, resolveProjectDir, resolveSubagentModelTarget, resolveSubagentWorktreeDecision, roleNeedsIndependentReviewModel, rosterSummaryFromConfigs, sameModelReference, scoreAgents, startPackageOutdatedWatcher, subagentNeedsWorktree, updatePackageOutdatedStatus, validateWatchdogOptions, withDisabledToolFiltering, wrapSubagentRunnerWithWorktrees };
19342
+ export {
19343
+ ACP_AGENTS,
19344
+ AGENTS_BY_PHASE,
19345
+ AGENT_CATALOG,
19346
+ TOOLS as AGENT_TOOL_PRESETS,
19347
+ ALL_AGENT_DEFINITIONS,
19348
+ ALL_FLEET_AGENTS,
19349
+ AUDIT_LOG_AGENT,
19350
+ AdaptiveConcurrencyController,
19351
+ AgentMonitorService,
19352
+ AutonomousBrain,
19353
+ AutonomousCoordinator,
19354
+ BUG_HUNTER_AGENT,
19355
+ BUILD_AGENTS,
19356
+ BrainDecisionQueue,
19357
+ BrainMonitor,
19358
+ BudgetExceededError,
19359
+ BudgetThresholdSignal,
19360
+ ChangeManager,
19361
+ CollabSession,
19362
+ ConsensusProtocol,
19363
+ DECISION_TIMEOUT_MS,
19364
+ DEFAULT_DIRECTOR_PREAMBLE,
19365
+ DEFAULT_DISPATCH_ROLE,
19366
+ DEFAULT_MAX_FLEET_SPAWNS,
19367
+ DEFAULT_QUALITY_CHECKS,
19368
+ DEFAULT_SUBAGENT_BASELINE,
19369
+ DELIVERY_AGENTS,
19370
+ DEPENDENCY_FILE_PATTERNS,
19371
+ DISCOVERY_AGENTS,
19372
+ DOMAIN_AGENTS,
19373
+ DefaultBrainArbiter,
19374
+ DefaultMailbox,
19375
+ DefaultMultiAgentCoordinator,
19376
+ Director,
19377
+ DirectorAlertLevel,
19378
+ FLEET_ROSTER,
19379
+ FLEET_ROSTER_BUDGETS,
19380
+ FLEET_ROSTER_WITHACP,
19381
+ FleetBus,
19382
+ FleetCostCapError,
19383
+ FleetManager,
19384
+ FleetSpawnBudgetError,
19385
+ FleetSupervisor,
19386
+ FleetTokenCapError,
19387
+ FleetUsageAggregator,
19388
+ GlobalMailbox,
19389
+ HARD_MAX_SPAWN_DEPTH,
19390
+ HEAVY_BUDGET,
19391
+ HumanEscalatingBrainArbiter,
19392
+ InMemoryAgentBridge,
19393
+ InMemoryBridgeTransport,
19394
+ KNOWLEDGE_AGENTS,
19395
+ KnowledgeGraph,
19396
+ LIGHT_BUDGET,
19397
+ LargeAnswerStore,
19398
+ MAILBOX_BRIDGE_LOCK_FILENAME,
19399
+ MAILBOX_BRIDGE_TOKEN_FILENAME,
19400
+ MAILBOX_HEALTH_DEFAULT_FAILURE_THRESHOLD,
19401
+ MAILBOX_HEALTH_DEFAULT_FROM,
19402
+ MAILBOX_HEALTH_DEFAULT_INTERVAL_MS,
19403
+ MAILBOX_HEALTH_DEFAULT_TIMEOUT_MS,
19404
+ MATRIX_PHASE_KEYS,
19405
+ MAX_SUBAGENT_STRUCTURED_REPORT_CHARS,
19406
+ MEDIUM_BUDGET,
19407
+ META_AGENTS,
19408
+ MailboxHealthWatchdog,
19409
+ NULL_FLEET_BUS,
19410
+ ObservableBrainArbiter,
19411
+ PLANNING_AGENTS,
19412
+ REFACTOR_PLANNER_AGENT,
19413
+ REVIEW_AGENTS,
19414
+ SECURITY_SCANNER_AGENT,
19415
+ SUBAGENT_STRUCTURED_REPORT_META_KEY,
19416
+ SubagentBudget,
19417
+ TIMEOUT_PREEMPT_FRACTION,
19418
+ TaskAuctioneer,
19419
+ TaskDAG,
19420
+ VERIFY_AGENTS,
19421
+ WorktreeIntegrationError,
19422
+ acquireOrJoin,
19423
+ actionToAckInput,
19424
+ applyRosterBudget,
19425
+ attachAutoExtend,
19426
+ attachDepWatcherBridge,
19427
+ buildDownAlert,
19428
+ buildRecoveryAlert,
19429
+ composeDirectorPrompt,
19430
+ composeSubagentPrompt,
19431
+ createAgentMonitorService,
19432
+ createDelegateTool,
19433
+ createMailboxHooks,
19434
+ createMessage,
19435
+ detectEcosystem,
19436
+ dispatchAgent,
19437
+ finalize,
19438
+ formatHumanPrompt,
19439
+ formatSubagentStructuredReport,
19440
+ getAgentDefinition,
19441
+ getFullPackageLog,
19442
+ getManifestPackages,
19443
+ getPackageAuthor,
19444
+ getPackagesByAgent,
19445
+ isValidMatrixKey,
19446
+ mailboxSessionTag,
19447
+ makeAgentSubagentRunner,
19448
+ makeAskResultTool,
19449
+ makeAskTool,
19450
+ makeAssignTool,
19451
+ makeAwaitTasksTool,
19452
+ makeCollabDebugTool,
19453
+ makeDependencyWatcherConfig,
19454
+ makeDirectorSessionFactory,
19455
+ makeFleetEmitTool,
19456
+ makeFleetTool as makeFleetHealthTool,
19457
+ makeFleetTool as makeFleetSessionTool,
19458
+ makeFleetStatusTool,
19459
+ makeFleetTool,
19460
+ makeFleetTool as makeFleetUsageTool,
19461
+ makeKanbanQueueTool,
19462
+ makeLLMClassifier,
19463
+ makeMailInboxTool,
19464
+ makeMailSendTool,
19465
+ makeMailboxTool,
19466
+ makeQualityGateTool,
19467
+ makeRollUpTool,
19468
+ makeSpawnTool,
19469
+ makeSubagentResultTool,
19470
+ makeTerminateAllTool,
19471
+ makeTerminateTool,
19472
+ makeWorkCompleteTool,
19473
+ matrixKeyKind,
19474
+ normalizeRecipient,
19475
+ normalizeSubagentStructuredReport,
19476
+ phaseForRole,
19477
+ readLiveLock,
19478
+ readSubagentStructuredReport,
19479
+ recordPackageAction,
19480
+ release,
19481
+ resolveImplementationModelTarget,
19482
+ resolveMailboxIdentity,
19483
+ resolveMaxSpawnDepth,
19484
+ resolveModelMatrix,
19485
+ resolveModelMatrixResolution,
19486
+ resolveModelTargetFromEntry,
19487
+ resolveProjectDir,
19488
+ resolveSubagentModelTarget,
19489
+ resolveSubagentWorktreeDecision,
19490
+ roleNeedsIndependentReviewModel,
19491
+ rosterSummaryFromConfigs,
19492
+ sameModelReference,
19493
+ scoreAgents,
19494
+ startPackageOutdatedWatcher,
19495
+ subagentNeedsWorktree,
19496
+ updatePackageOutdatedStatus,
19497
+ validateWatchdogOptions,
19498
+ withDisabledToolFiltering,
19499
+ wrapSubagentRunnerWithWorktrees
19500
+ };
19015
19501
  //# sourceMappingURL=index.js.map
19016
- //# sourceMappingURL=index.js.map