@wrongstack/core 0.313.1 → 0.316.2

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 (290) hide show
  1. package/dist/chronicle/index.js +31 -31
  2. package/dist/chronicle/legacy-journal-import.d.ts +0 -6
  3. package/dist/chronicle/metrics-ingest.d.ts +14 -0
  4. package/dist/chronicle/metrics-schema.d.ts +10 -1
  5. package/dist/chronicle/metrics-store.d.ts +20 -2
  6. package/dist/chronicle/project-server.js +39 -31
  7. package/dist/chronicle/sink.d.ts +13 -0
  8. package/dist/chronicle/sqlite-journal.d.ts +20 -2
  9. package/dist/{chunk-WOEZV3Q4.js → chunk-25LSLC3G.js} +2 -1
  10. package/dist/{chunk-AI4LLQ2U.js → chunk-27QIURLN.js} +229 -12
  11. package/dist/{chunk-I45KAW2N.js → chunk-3AGWVSS7.js} +38 -450
  12. package/dist/chunk-3BDV7RL3.js +211 -0
  13. package/dist/{chunk-NFAYHPRH.js → chunk-3ECENVHL.js} +10 -8
  14. package/dist/{chunk-FW5LDDMJ.js → chunk-45WI72ZB.js} +1576 -1156
  15. package/dist/{chunk-AT4V4XGI.js → chunk-4BMVPOHO.js} +539 -313
  16. package/dist/{chunk-YBUJCZ57.js → chunk-4I7HGVVA.js} +17 -5
  17. package/dist/{chunk-JVGPR3TS.js → chunk-4LCZVJVF.js} +7 -55
  18. package/dist/{chunk-4ZHTKJHM.js → chunk-4SJNS7OB.js} +36 -2
  19. package/dist/{chunk-AD7ZFZCS.js → chunk-5BMIE7QG.js} +3 -3
  20. package/dist/{chunk-IQ35HMQL.js → chunk-5YPSXQXM.js} +71 -24
  21. package/dist/chunk-6FHWXLPT.js +10 -0
  22. package/dist/{chunk-FIV4IJL7.js → chunk-6H5GEOET.js} +163 -20
  23. package/dist/{chunk-VB3H5WWB.js → chunk-6NWEVFEL.js} +2 -2
  24. package/dist/{chunk-E6I5RXVK.js → chunk-AYW5YINX.js} +2 -2
  25. package/dist/{chunk-DEIQMBD2.js → chunk-B7F4WVP4.js} +2 -2
  26. package/dist/{chunk-XQ2XGIBF.js → chunk-BPBKKBUK.js} +6 -7
  27. package/dist/{chunk-K4YUNKU7.js → chunk-BYD345OX.js} +2 -2
  28. package/dist/{chunk-LZDDLNCZ.js → chunk-C27KDLOX.js} +4 -4
  29. package/dist/{chunk-6AKOTGLM.js → chunk-CU546ESW.js} +7 -7
  30. package/dist/{chunk-ZZ4V3WIZ.js → chunk-DLHHXUAM.js} +10 -1
  31. package/dist/{chunk-BAKVJLEV.js → chunk-DOTHQSJ2.js} +28 -16
  32. package/dist/{chunk-KBZGE6LN.js → chunk-DYLPMV4Q.js} +4 -3
  33. package/dist/{chunk-52RTVH4M.js → chunk-F3JWNST7.js} +2 -2
  34. package/dist/{chunk-WEBMSQP2.js → chunk-FC2ZGRF3.js} +21 -4
  35. package/dist/{chunk-FHAMQS7Q.js → chunk-FCBTO76Z.js} +76 -146
  36. package/dist/{chunk-4LJJYBAU.js → chunk-FHZVFYSL.js} +9 -1
  37. package/dist/{chunk-W4A6QA3D.js → chunk-FWNLEZYG.js} +4 -3
  38. package/dist/{chunk-OJZEX73F.js → chunk-GDQ7CZRQ.js} +5 -1
  39. package/dist/{chunk-QVOVMXJR.js → chunk-GJJGJB2R.js} +32 -9
  40. package/dist/{chunk-4XV6IR37.js → chunk-HI3JGZR2.js} +7 -6
  41. package/dist/{chunk-FSWCWSTS.js → chunk-HMLIGAU7.js} +26 -26
  42. package/dist/{chunk-PFXFQQRT.js → chunk-HXKZ7OBQ.js} +7 -43
  43. package/dist/{chunk-2FQL4PDC.js → chunk-I7DALG7J.js} +5 -5
  44. package/dist/{chunk-GM54GJBU.js → chunk-IRUTEHCE.js} +3 -3
  45. package/dist/{chunk-TYW2GI5I.js → chunk-J2WRWR37.js} +40 -13
  46. package/dist/{chunk-ZEHUCJHY.js → chunk-JFPJ6LLQ.js} +2 -2
  47. package/dist/chunk-JMULFFLN.js +9 -0
  48. package/dist/{chunk-RD6DEE36.js → chunk-JO4MGB6Z.js} +94 -8
  49. package/dist/{chunk-5DSMEVA4.js → chunk-K6BXGITA.js} +7 -7
  50. package/dist/{chunk-O74MJHXU.js → chunk-KZMSZV32.js} +2 -2
  51. package/dist/{chunk-GFJOMSHG.js → chunk-LA7CLDRW.js} +6 -2
  52. package/dist/{chunk-M2WF6AXG.js → chunk-LSMMOS2Z.js} +7 -3
  53. package/dist/{chunk-ASX6AW36.js → chunk-LXWCMQNJ.js} +3 -3
  54. package/dist/{chunk-WZO23AWO.js → chunk-M27LIEKV.js} +72 -22
  55. package/dist/{chunk-JTHKOYWU.js → chunk-MJPHJRAL.js} +15 -15
  56. package/dist/{chunk-G5AAKEEZ.js → chunk-MTL4O5YR.js} +5 -5
  57. package/dist/chunk-NHJ75HXY.js +1 -0
  58. package/dist/{chunk-ZYU2YOJ6.js → chunk-NIOAGFPB.js} +29 -15
  59. package/dist/{chunk-Y2GE5TSI.js → chunk-NS52ISWS.js} +2 -2
  60. package/dist/{chunk-UIWONWVG.js → chunk-NSOFPKGT.js} +541 -148
  61. package/dist/{chunk-RCQYT2I4.js → chunk-NVIZG63R.js} +2 -2
  62. package/dist/{chunk-EPC3GZD4.js → chunk-OOYZPOXM.js} +2 -2
  63. package/dist/{chunk-7ZHZE5EO.js → chunk-OSGLYW5J.js} +2 -2
  64. package/dist/{chunk-CE4ZOCOI.js → chunk-PFCMSSUF.js} +9 -9
  65. package/dist/{chunk-GFXZTHNI.js → chunk-PGRVXIMY.js} +5 -5
  66. package/dist/{chunk-JJPMWPB6.js → chunk-PISBFBJN.js} +6 -6
  67. package/dist/chunk-POOOIWE5.js +9 -0
  68. package/dist/{chunk-5RP3QTRL.js → chunk-PQNS3U7Z.js} +20 -3
  69. package/dist/{chunk-3E244UDA.js → chunk-QSTSJOCK.js} +52 -6
  70. package/dist/{chunk-YUPMXOGP.js → chunk-RFQMOKWK.js} +3 -3
  71. package/dist/chunk-RTOTNK3P.js +484 -0
  72. package/dist/{chunk-SN2DQRL6.js → chunk-RXKSDUAU.js} +7 -7
  73. package/dist/{chunk-T3KGZBU5.js → chunk-S45JPKQN.js} +189 -43
  74. package/dist/{chunk-YNCVSFGF.js → chunk-SAFHACFA.js} +4 -1
  75. package/dist/{chunk-KI4L2DUL.js → chunk-TCCHINEF.js} +114 -19
  76. package/dist/{chunk-AWNQ6ED6.js → chunk-THEGTRAG.js} +7 -2
  77. package/dist/{chunk-2KKODIQU.js → chunk-TR4LQE7L.js} +15 -15
  78. package/dist/{chunk-GPQ3NJPR.js → chunk-TWJMGXCI.js} +3 -3
  79. package/dist/{chunk-H72H4XDU.js → chunk-U45AXT5D.js} +9 -9
  80. package/dist/{chunk-62V2AFVG.js → chunk-U4FWBSO3.js} +160 -73
  81. package/dist/{chunk-A455ATZB.js → chunk-UBGDX6FI.js} +8 -1
  82. package/dist/chunk-UJILKYES.js +75 -0
  83. package/dist/{chunk-KSJ5UTP7.js → chunk-ULMAQV3T.js} +84 -4
  84. package/dist/{chunk-CB2HFKTP.js → chunk-VVBP6KGT.js} +1 -1
  85. package/dist/{chunk-RPOA7IAE.js → chunk-W5VITDM2.js} +43 -25
  86. package/dist/{chunk-QRTG4XTI.js → chunk-WAHQVNWT.js} +7 -1
  87. package/dist/{chunk-SQP64RCS.js → chunk-WGGYRBXH.js} +3019 -2976
  88. package/dist/{chunk-K3G6JBUC.js → chunk-WLYKU45P.js} +679 -141
  89. package/dist/chunk-WP7BVANJ.js +53 -0
  90. package/dist/{chunk-GAZEWQEZ.js → chunk-XF4VUMKW.js} +2 -2
  91. package/dist/{chunk-PAAWLLZX.js → chunk-Y5YXDM7D.js} +2 -2
  92. package/dist/{chunk-65RDIOR2.js → chunk-YOPAUVU4.js} +162 -44
  93. package/dist/{chunk-FFSX2QDQ.js → chunk-YPT4A46F.js} +3 -3
  94. package/dist/chunk-YWXT3JNM.js +425 -0
  95. package/dist/{chunk-EFEHDQGY.js → chunk-ZHZ2Y2DH.js} +64 -10
  96. package/dist/{chunk-CQQL4ZOQ.js → chunk-ZT7JNIGX.js} +4 -3
  97. package/dist/coordination/agent-monitor.d.ts +9 -1
  98. package/dist/coordination/agent-subagent-runner.d.ts +1 -1
  99. package/dist/coordination/agents/agent-prompts.d.ts +8 -0
  100. package/dist/coordination/agents/index.d.ts +33 -1
  101. package/dist/coordination/agents/index.js +52 -22
  102. package/dist/coordination/agents/phase3-wave1-platform.d.ts +1 -3
  103. package/dist/coordination/agents/phase3-wave2-meta.d.ts +1 -3
  104. package/dist/coordination/agents/phase8-wave3-products.d.ts +1 -3
  105. package/dist/coordination/agents/phase9-wave4-platform-meta.d.ts +1 -3
  106. package/dist/coordination/agents/project-agent-identity.d.ts +11 -11
  107. package/dist/coordination/agents/types.d.ts +13 -2
  108. package/dist/coordination/brain-monitor.d.ts +30 -7
  109. package/dist/coordination/collab-debug.d.ts +1 -1
  110. package/dist/coordination/collab-pause.d.ts +1 -1
  111. package/dist/coordination/delegate-tool.d.ts +7 -5
  112. package/dist/coordination/director-kanban-queue-helpers.d.ts +1 -0
  113. package/dist/coordination/director-options.d.ts +7 -0
  114. package/dist/coordination/director-spawn-model.d.ts +17 -0
  115. package/dist/coordination/director-tools.d.ts +2 -2
  116. package/dist/coordination/director.d.ts +12 -0
  117. package/dist/coordination/dispatcher.d.ts +8 -0
  118. package/dist/coordination/fleet-bus.d.ts +35 -4
  119. package/dist/coordination/fleet-supervisor.d.ts +10 -2
  120. package/dist/coordination/fleet.d.ts +16 -7
  121. package/dist/coordination/index.d.ts +4 -0
  122. package/dist/coordination/index.js +86 -49
  123. package/dist/coordination/kanban-dispatch-port.d.ts +2 -2
  124. package/dist/coordination/mailbox-http-router.d.ts +4 -3
  125. package/dist/coordination/mailbox-http-validation.d.ts +1 -1
  126. package/dist/coordination/mailbox-project-server.js +15 -15
  127. package/dist/coordination/mailbox-types.d.ts +24 -6
  128. package/dist/coordination/model-tier-leader.d.ts +122 -0
  129. package/dist/coordination/model-tier.d.ts +122 -0
  130. package/dist/coordination/multi-agent-coordinator.d.ts +24 -0
  131. package/dist/coordination/origin-session.d.ts +16 -0
  132. package/dist/coordination/provider-status-tracker.d.ts +37 -5
  133. package/dist/coordination/session-note-hub.d.ts +44 -0
  134. package/dist/coordination/session-note-tool.d.ts +10 -0
  135. package/dist/core/agent.d.ts +1 -1
  136. package/dist/core/context.d.ts +22 -3
  137. package/dist/core/index.d.ts +2 -0
  138. package/dist/core/index.js +130 -38
  139. package/dist/core/request-conversation-binding.d.ts +37 -0
  140. package/dist/core/session-notes.d.ts +25 -0
  141. package/dist/core/system-prompt-builder.d.ts +11 -2
  142. package/dist/core/system-prompt-variants.d.ts +78 -0
  143. package/dist/design/index.js +3 -3
  144. package/dist/execution/auto-compaction-middleware.d.ts +11 -0
  145. package/dist/execution/autonomy-brain.d.ts +2 -1
  146. package/dist/execution/autonomy-prompt-contributor.d.ts +7 -2
  147. package/dist/execution/compaction-core.d.ts +4 -4
  148. package/dist/execution/eternal-autonomy.d.ts +1 -1
  149. package/dist/execution/index.js +138 -129
  150. package/dist/execution/model-runtime.d.ts +0 -7
  151. package/dist/execution/parallel-eternal-engine.d.ts +7 -7
  152. package/dist/extension/index.js +3 -3
  153. package/dist/goal/index.js +6 -6
  154. package/dist/hooks/index.js +3 -3
  155. package/dist/hq/index.js +14 -12
  156. package/dist/hq/persistence/event-log.d.ts +0 -1
  157. package/dist/hq/persistence.d.ts +4 -4
  158. package/dist/hq/publisher.d.ts +2 -0
  159. package/dist/index.d.ts +14 -11
  160. package/dist/index.js +728 -635
  161. package/dist/infrastructure/index.d.ts +4 -4
  162. package/dist/infrastructure/index.js +281 -260
  163. package/dist/infrastructure/token-counter.d.ts +9 -0
  164. package/dist/kernel/events/agent-events.d.ts +77 -3
  165. package/dist/kernel/events/brain-events.d.ts +12 -0
  166. package/dist/kernel/events/provider-events.d.ts +7 -1
  167. package/dist/kernel/events/session-events.d.ts +14 -0
  168. package/dist/kernel/events/tool-events.d.ts +13 -0
  169. package/dist/kernel/index.js +4 -4
  170. package/dist/mailbox-attach.d.ts +1 -1
  171. package/dist/models/index.js +10 -9
  172. package/dist/observability/event-bridge.d.ts +25 -5
  173. package/dist/observability/index.d.ts +9 -8
  174. package/dist/observability/index.js +459 -351
  175. package/dist/observability/tool-usage-source.d.ts +65 -0
  176. package/dist/plugin/index.d.ts +5 -0
  177. package/dist/plugin/index.js +66 -50
  178. package/dist/plugins/auto-review-plugin.d.ts +3 -2
  179. package/dist/plugins/review-finding-commands.d.ts +0 -8
  180. package/dist/{review-finding-store-DKAV3AS6.js → plugins/review-finding-store.js} +7 -6
  181. package/dist/plugins/review-finding-types.js +19 -0
  182. package/dist/plugins/review-report-integration.js +21 -0
  183. package/dist/{review-report-store-OWY3EC3N.js → plugins/review-report-store.js} +7 -6
  184. package/dist/plugins/review-report-types.js +13 -0
  185. package/dist/prompts/index.js +5 -5
  186. package/dist/registry/index.js +3 -3
  187. package/dist/registry/tool-registry.d.ts +59 -9
  188. package/dist/{registry-R23UBE7H.js → registry-7N4O3E7W.js} +5 -5
  189. package/dist/security/capabilities.d.ts +6 -0
  190. package/dist/security/file-permissions.d.ts +1 -1
  191. package/dist/security/index.js +47 -33
  192. package/dist/security/permission-policy.d.ts +12 -1
  193. package/dist/security/secret-scrubber.d.ts +15 -0
  194. package/dist/session-catalog/index.d.ts +1 -0
  195. package/dist/session-catalog/index.js +19 -14
  196. package/dist/session-catalog/project-server.js +30 -13
  197. package/dist/session-catalog/protocol.d.ts +32 -1
  198. package/dist/session-catalog/registry.d.ts +17 -1
  199. package/dist/session-catalog/session-agents.d.ts +56 -0
  200. package/dist/session-catalog/store-rebuild.d.ts +14 -0
  201. package/dist/session-catalog/store-schema.d.ts +26 -0
  202. package/dist/session-catalog/store.d.ts +27 -1
  203. package/dist/session-note-attach.d.ts +9 -0
  204. package/dist/skills/index.js +5 -5
  205. package/dist/statusline/index.d.ts +43 -0
  206. package/dist/statusline/index.js +102 -0
  207. package/dist/storage/board-store-port.d.ts +2 -2
  208. package/dist/storage/config-loader/in-project-policy.d.ts +29 -0
  209. package/dist/storage/config-loader.d.ts +3 -2
  210. package/dist/storage/file-session-writer.d.ts +4 -2
  211. package/dist/storage/goal-coordination.d.ts +6 -1
  212. package/dist/storage/goal-kanban.d.ts +4 -1
  213. package/dist/storage/index.d.ts +12 -4
  214. package/dist/storage/index.js +76 -61
  215. package/dist/storage/input-history-store.d.ts +2 -4
  216. package/dist/storage/memory-curator.d.ts +133 -0
  217. package/dist/storage/session-agent-attribution.d.ts +39 -0
  218. package/dist/storage/session-doctor.d.ts +109 -0
  219. package/dist/storage/session-event-bridge.d.ts +5 -7
  220. package/dist/storage/session-outcome.d.ts +42 -0
  221. package/dist/storage/session-recovery.d.ts +55 -0
  222. package/dist/storage/session-store/load-session-data.d.ts +11 -0
  223. package/dist/storage/session-store/prune-helpers.d.ts +1 -1
  224. package/dist/storage/session-store/resume-session.d.ts +0 -2
  225. package/dist/storage/session-store/types.d.ts +8 -0
  226. package/dist/storage/session-store.d.ts +3 -3
  227. package/dist/storage/session-summary-tracker.d.ts +8 -1
  228. package/dist/storage/session-write-buffer.d.ts +18 -0
  229. package/dist/storage/session-writer-truncate.d.ts +2 -0
  230. package/dist/tasking/index.js +2 -2
  231. package/dist/tools/fallback-manage-tools.d.ts +6 -4
  232. package/dist/tools/index.js +21 -21
  233. package/dist/tools/model-tier-set-tool.d.ts +66 -0
  234. package/dist/types/agent-bridge.d.ts +2 -1
  235. package/dist/types/config/mcp-features.d.ts +7 -0
  236. package/dist/types/config/model-tiers.d.ts +148 -0
  237. package/dist/types/config/root.d.ts +9 -0
  238. package/dist/types/config/tools.d.ts +73 -0
  239. package/dist/types/config.d.ts +1 -0
  240. package/dist/types/context.d.ts +2 -0
  241. package/dist/types/default-config.d.ts +6 -0
  242. package/dist/types/errors.d.ts +2 -1
  243. package/dist/types/index.d.ts +11 -9
  244. package/dist/types/index.js +25 -15
  245. package/dist/types/multi-agent.d.ts +43 -0
  246. package/dist/types/plugin.d.ts +1 -1
  247. package/dist/types/provider.d.ts +15 -0
  248. package/dist/types/runtime-capability-manifest.d.ts +1 -1
  249. package/dist/types/secret-scrubber.d.ts +15 -0
  250. package/dist/types/session-markers.d.ts +37 -10
  251. package/dist/types/session-markers.js +1 -1
  252. package/dist/types/session-timeline.d.ts +197 -0
  253. package/dist/types/session-timeline.js +12 -0
  254. package/dist/types/session.d.ts +172 -11
  255. package/dist/types/system-prompt.d.ts +27 -0
  256. package/dist/utils/config-backup.d.ts +9 -1
  257. package/dist/utils/heap-watchdog.js +2 -2
  258. package/dist/utils/index.js +50 -48
  259. package/dist/utils/message-invariants.d.ts +4 -1
  260. package/dist/utils/regex-guard.d.ts +1 -1
  261. package/dist/utils/socket-path.d.ts +1 -1
  262. package/dist/utils/token-estimate.d.ts +6 -2
  263. package/dist/utils/wstack-paths.d.ts +2 -0
  264. package/dist/wiring/proxy-rewrite.d.ts +28 -0
  265. package/dist/wiring/proxy-rewrite.js +7 -1
  266. package/dist/worktree/index.js +2 -2
  267. package/instructions/agents/explore-companion.md +45 -18
  268. package/instructions/agents/memory-curator.md +34 -22
  269. package/instructions/coordination/director-preamble.md +12 -7
  270. package/instructions/coordination/subagent-baseline.md +26 -5
  271. package/instructions/leader-after-task.md +4 -1
  272. package/instructions/llm/chimera-review.md +30 -9
  273. package/instructions/llm/memory-curator.md +31 -0
  274. package/instructions/sections/tool/delegation-compact.md +2 -0
  275. package/instructions/sections/tool/delegation-full.md +5 -1
  276. package/instructions/sections/tool/mailbox-compact.md +5 -1
  277. package/instructions/sections/tool/mailbox-full.md +3 -0
  278. package/instructions/sections/tool/session-note-compact.md +3 -0
  279. package/instructions/sections/tool/session-note-full.md +15 -0
  280. package/instructions/system-lite.md +9 -4
  281. package/instructions/system-pro.md +66 -143
  282. package/instructions/system.md +73 -175
  283. package/package.json +33 -5
  284. package/dist/chunk-2BUUIMQB.js +0 -225
  285. package/dist/chunk-FAYRX2AD.js +0 -13
  286. package/dist/chunk-H5E77KUJ.js +0 -15
  287. package/dist/chunk-M7BS2K6U.js +0 -1
  288. package/dist/coordination/agents.d.ts +0 -8
  289. package/dist/coordination/transport.d.ts +0 -2
  290. package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +0 -28
@@ -3,6 +3,7 @@ import {
3
3
  AGENT_CATALOG,
4
4
  ALL_AGENT_DEFINITIONS,
5
5
  BUILD_AGENTS,
6
+ BUILT_IN_KNOWLEDGE_MANIFESTS,
6
7
  BUNDLED_AGENT_SKILLS,
7
8
  CAPTURE_COOLDOWN_MS,
8
9
  CAPTURE_MAX_PER_SESSION,
@@ -20,14 +21,18 @@ import {
20
21
  KNOWLEDGE_AGENTS,
21
22
  LEARNED_ENTRY_MAX_CHARS,
22
23
  LEARNED_HARD_LIMIT,
24
+ LEARNED_SKILL_TAG,
23
25
  LEARNED_SOFT_LIMIT,
24
26
  LIGHT_BUDGET,
25
27
  LearningOptimizationScheduler,
26
28
  MAX_EAGER_ROSTER_SKILLS,
27
29
  MEDIUM_BUDGET,
28
30
  META_AGENTS,
31
+ MIN_INSTRUCTIVE_LENGTH,
29
32
  PLANNING_AGENTS,
33
+ QUARANTINE_MAX_BYTES,
30
34
  REVIEW_AGENTS,
35
+ ROLE_DISPATCH_RATIONALE,
31
36
  ROLE_SKILL_SETS,
32
37
  SHADOW_AGENT_SKILLS,
33
38
  SKILL_AUGMENTATION_MAX_BYTES,
@@ -36,19 +41,14 @@ import {
36
41
  TOOLS,
37
42
  VERIFY_AGENTS,
38
43
  WAVE1_AGENTS,
39
- WAVE1_ROLES,
40
- WAVE1_ROLE_METAS,
41
44
  WAVE2_AGENTS,
42
- WAVE2_ROLES,
43
- WAVE2_ROLE_METAS,
44
45
  WAVE3_AGENTS,
45
- WAVE3_ROLES,
46
- WAVE3_ROLE_METAS,
47
46
  WAVE4_AGENTS,
48
- WAVE4_ROLES,
49
- WAVE4_ROLE_METAS,
47
+ agentsDir,
48
+ appendQuarantine,
50
49
  applyProjectAgentConfig,
51
50
  assertProjectAgentRole,
51
+ assertProjectSkillName,
52
52
  assignSkillsToAgents,
53
53
  buildConsolidationInstruction,
54
54
  buildProjectContextualizedPrompt,
@@ -56,6 +56,7 @@ import {
56
56
  canCaptureNewLearned,
57
57
  captureLearnedFromAgentOutput,
58
58
  captureLearnedFromAgentOutputDetailed,
59
+ captureWindowState,
59
60
  classifyLearnedEntry,
60
61
  clearProjectAgentConsolidated,
61
62
  clearProjectSkillAugmentation,
@@ -72,9 +73,13 @@ import {
72
73
  existsSync,
73
74
  getAgentDefinition,
74
75
  getProjectAgentLearnStats,
76
+ hasDirectiveContent,
75
77
  hintLearnedNeedsSummarization,
76
78
  isConsolidated,
79
+ isProjectAgentRoleName,
80
+ isProjectSkillName,
77
81
  isProvenDirective,
82
+ learningPolicyPath,
78
83
  listProjectAgentLearnedEntries,
79
84
  listProjectAgentRoles,
80
85
  listProjectSkillAugmentations,
@@ -89,17 +94,24 @@ import {
89
94
  loadRoleKnowledgeManifest,
90
95
  loadSkillAffinity,
91
96
  mergeStructuredEntries,
97
+ normalizeForComparison,
92
98
  normalizeLearnedEntry,
93
99
  optimizeProjectAgentLearning,
94
100
  parseLearnedEntryStamp,
95
101
  parseStructuredLearnedEntries,
96
102
  parseStructuredLearnedEntriesFromContent,
103
+ projectAgentProfilePath,
104
+ projectSkillAffinityPath,
105
+ projectSkillAugmentationPath,
106
+ projectSkillsDir,
97
107
  quarantinePath,
98
108
  rankRoleSkills,
99
109
  readQuarantinedDirectives,
100
110
  readRawLearnedEntries,
111
+ recordCaptureAttempt,
101
112
  recordDirectiveOutcomes,
102
113
  recordProjectAgentOptimizePass,
114
+ recordSkillLearned,
103
115
  recordSkillLoad,
104
116
  recordSkillOutcome,
105
117
  refreshProjectAgentIdentity,
@@ -109,8 +121,10 @@ import {
109
121
  resetCaptureWindows,
110
122
  resetProjectAgentIdentity,
111
123
  resolveAutoOptimizePolicy,
124
+ resolveCaptureKey,
112
125
  resolveRoleSkillCandidates,
113
126
  retiredDirectivesToWarnAbout,
127
+ roleDir,
114
128
  routeDirectiveToSkill,
115
129
  saveProjectAgentConsolidated,
116
130
  saveProjectSkillAugmentation,
@@ -126,9 +140,10 @@ import {
126
140
  updateProjectAgentKnowledge,
127
141
  updateProjectAgentLearned,
128
142
  updateProjectAgentLearningPolicy,
129
- validateProjectAgentConfig
130
- } from "../../chunk-FHAMQS7Q.js";
131
- import "../../chunk-A455ATZB.js";
143
+ validateProjectAgentConfig,
144
+ writeTextAtomically
145
+ } from "../../chunk-FCBTO76Z.js";
146
+ import "../../chunk-UBGDX6FI.js";
132
147
  import {
133
148
  RUNTIME_CAPABILITY_MANIFEST,
134
149
  inferRuntimeCapabilities,
@@ -140,14 +155,15 @@ import {
140
155
  runtimeCapabilityForTool,
141
156
  runtimeToolReferencesFromText,
142
157
  toolsForRuntimeCapabilities
143
- } from "../../chunk-AWNQ6ED6.js";
144
- import "../../chunk-YNCVSFGF.js";
158
+ } from "../../chunk-THEGTRAG.js";
159
+ import "../../chunk-SAFHACFA.js";
145
160
  import "../../chunk-O37BQ65S.js";
146
161
  export {
147
162
  AGENTS_BY_PHASE,
148
163
  AGENT_CATALOG,
149
164
  ALL_AGENT_DEFINITIONS,
150
165
  BUILD_AGENTS,
166
+ BUILT_IN_KNOWLEDGE_MANIFESTS,
151
167
  BUNDLED_AGENT_SKILLS,
152
168
  CAPTURE_COOLDOWN_MS,
153
169
  CAPTURE_MAX_PER_SESSION,
@@ -165,14 +181,18 @@ export {
165
181
  KNOWLEDGE_AGENTS,
166
182
  LEARNED_ENTRY_MAX_CHARS,
167
183
  LEARNED_HARD_LIMIT,
184
+ LEARNED_SKILL_TAG,
168
185
  LEARNED_SOFT_LIMIT,
169
186
  LIGHT_BUDGET,
170
187
  LearningOptimizationScheduler,
171
188
  MAX_EAGER_ROSTER_SKILLS,
172
189
  MEDIUM_BUDGET,
173
190
  META_AGENTS,
191
+ MIN_INSTRUCTIVE_LENGTH,
174
192
  PLANNING_AGENTS,
193
+ QUARANTINE_MAX_BYTES,
175
194
  REVIEW_AGENTS,
195
+ ROLE_DISPATCH_RATIONALE,
176
196
  ROLE_SKILL_SETS,
177
197
  RUNTIME_CAPABILITY_MANIFEST,
178
198
  SHADOW_AGENT_SKILLS,
@@ -182,19 +202,14 @@ export {
182
202
  TOOLS,
183
203
  VERIFY_AGENTS,
184
204
  WAVE1_AGENTS,
185
- WAVE1_ROLES,
186
- WAVE1_ROLE_METAS,
187
205
  WAVE2_AGENTS,
188
- WAVE2_ROLES,
189
- WAVE2_ROLE_METAS,
190
206
  WAVE3_AGENTS,
191
- WAVE3_ROLES,
192
- WAVE3_ROLE_METAS,
193
207
  WAVE4_AGENTS,
194
- WAVE4_ROLES,
195
- WAVE4_ROLE_METAS,
208
+ agentsDir,
209
+ appendQuarantine,
196
210
  applyProjectAgentConfig,
197
211
  assertProjectAgentRole,
212
+ assertProjectSkillName,
198
213
  assignSkillsToAgents,
199
214
  buildConsolidationInstruction,
200
215
  buildProjectContextualizedPrompt,
@@ -202,6 +217,7 @@ export {
202
217
  canCaptureNewLearned,
203
218
  captureLearnedFromAgentOutput,
204
219
  captureLearnedFromAgentOutputDetailed,
220
+ captureWindowState,
205
221
  classifyLearnedEntry,
206
222
  clearProjectAgentConsolidated,
207
223
  clearProjectSkillAugmentation,
@@ -218,12 +234,16 @@ export {
218
234
  existsSync,
219
235
  getAgentDefinition,
220
236
  getProjectAgentLearnStats,
237
+ hasDirectiveContent,
221
238
  hintLearnedNeedsSummarization,
222
239
  inferRuntimeCapabilities,
223
240
  isConsolidated,
224
241
  isDeprecatedRuntimeToolAlias,
225
242
  isKnownRuntimeCapability,
243
+ isProjectAgentRoleName,
244
+ isProjectSkillName,
226
245
  isProvenDirective,
246
+ learningPolicyPath,
227
247
  listProjectAgentLearnedEntries,
228
248
  listProjectAgentRoles,
229
249
  listProjectSkillAugmentations,
@@ -240,18 +260,25 @@ export {
240
260
  mergeStructuredEntries,
241
261
  missingRequiredRuntimeTools,
242
262
  missingRuntimeCapabilities,
263
+ normalizeForComparison,
243
264
  normalizeLearnedEntry,
244
265
  normalizeRuntimeToolName,
245
266
  optimizeProjectAgentLearning,
246
267
  parseLearnedEntryStamp,
247
268
  parseStructuredLearnedEntries,
248
269
  parseStructuredLearnedEntriesFromContent,
270
+ projectAgentProfilePath,
271
+ projectSkillAffinityPath,
272
+ projectSkillAugmentationPath,
273
+ projectSkillsDir,
249
274
  quarantinePath,
250
275
  rankRoleSkills,
251
276
  readQuarantinedDirectives,
252
277
  readRawLearnedEntries,
278
+ recordCaptureAttempt,
253
279
  recordDirectiveOutcomes,
254
280
  recordProjectAgentOptimizePass,
281
+ recordSkillLearned,
255
282
  recordSkillLoad,
256
283
  recordSkillOutcome,
257
284
  refreshProjectAgentIdentity,
@@ -261,8 +288,10 @@ export {
261
288
  resetCaptureWindows,
262
289
  resetProjectAgentIdentity,
263
290
  resolveAutoOptimizePolicy,
291
+ resolveCaptureKey,
264
292
  resolveRoleSkillCandidates,
265
293
  retiredDirectivesToWarnAbout,
294
+ roleDir,
266
295
  routeDirectiveToSkill,
267
296
  runtimeCapabilityForTool,
268
297
  runtimeToolReferencesFromText,
@@ -281,6 +310,7 @@ export {
281
310
  updateProjectAgentKnowledge,
282
311
  updateProjectAgentLearned,
283
312
  updateProjectAgentLearningPolicy,
284
- validateProjectAgentConfig
313
+ validateProjectAgentConfig,
314
+ writeTextAtomically
285
315
  };
286
316
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,3 @@
1
- import { type AgentDefinition, type RoleDispatcherSignal } from './types.js';
1
+ import { type AgentDefinition } from './types.js';
2
2
  export declare const WAVE1_AGENTS: AgentDefinition[];
3
- export declare const WAVE1_ROLE_METAS: Record<string, RoleDispatcherSignal>;
4
- export declare const WAVE1_ROLES: Set<string>;
5
3
  //# sourceMappingURL=phase3-wave1-platform.d.ts.map
@@ -1,5 +1,3 @@
1
- import { type AgentDefinition, type RoleDispatcherSignal } from './types.js';
1
+ import { type AgentDefinition } from './types.js';
2
2
  export declare const WAVE2_AGENTS: AgentDefinition[];
3
- export declare const WAVE2_ROLE_METAS: Record<string, RoleDispatcherSignal>;
4
- export declare const WAVE2_ROLES: Set<string>;
5
3
  //# sourceMappingURL=phase3-wave2-meta.d.ts.map
@@ -1,5 +1,3 @@
1
- import { type AgentDefinition, type RoleDispatcherSignal } from './types.js';
1
+ import { type AgentDefinition } from './types.js';
2
2
  export declare const WAVE3_AGENTS: AgentDefinition[];
3
- export declare const WAVE3_ROLE_METAS: Record<string, RoleDispatcherSignal>;
4
- export declare const WAVE3_ROLES: Set<string>;
5
3
  //# sourceMappingURL=phase8-wave3-products.d.ts.map
@@ -1,5 +1,3 @@
1
- import { type AgentDefinition, type RoleDispatcherSignal } from './types.js';
1
+ import { type AgentDefinition } from './types.js';
2
2
  export declare const WAVE4_AGENTS: AgentDefinition[];
3
- export declare const WAVE4_ROLE_METAS: Record<string, RoleDispatcherSignal>;
4
- export declare const WAVE4_ROLES: Set<string>;
5
3
  //# sourceMappingURL=phase9-wave4-platform-meta.d.ts.map
@@ -20,26 +20,26 @@
20
20
  import { existsSync } from 'node:fs';
21
21
  import { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION } from './project-agent-capture-window.js';
22
22
  import type { RoleKnowledgeManifest } from './project-agent-identity-types.js';
23
- export { type AutoOptimizeDecision, type AutoOptimizeEvent, type AutoOptimizePolicy, type AutoOptimizePolicyOverrides, DEFAULT_AUTO_OPTIMIZE_POLICY, evaluateAutoOptimize, LearningOptimizationScheduler, type LearningOptimizationSchedulerOptions, resolveAutoOptimizePolicy, } from './project-agent-auto-optimize.js';
24
- export { CAPTURE_SESSION_WINDOW_MS, resetCaptureWindow, resetCaptureWindows, } from './project-agent-capture-window.js';
23
+ export { DEFAULT_AUTO_OPTIMIZE_POLICY, evaluateAutoOptimize, LearningOptimizationScheduler, resolveAutoOptimizePolicy } from './project-agent-auto-optimize.js';
24
+ export { CAPTURE_SESSION_WINDOW_MS, resetCaptureWindow, resetCaptureWindows } from './project-agent-capture-window.js';
25
25
  export { loadProjectAgentConfig } from './project-agent-config-io.js';
26
26
  export { validateProjectAgentConfig } from './project-agent-config-validation.js';
27
- export { buildConsolidationInstruction, type ConsolidationMetadata, clearProjectAgentConsolidated, consolidatedDocumentPath, isConsolidated, loadConsolidationMetadata, loadProjectAgentConsolidated, readRawLearnedEntries, type SaveConsolidationOptions, saveProjectAgentConsolidated, } from './project-agent-consolidation.js';
28
- export { DIRECTIVE_QUARANTINE_MAX_UTILITY, DIRECTIVE_QUARANTINE_MIN_APPLIED, type DirectiveOutcomeResult, directiveWasApplied, recordDirectiveOutcomes, } from './project-agent-directive-outcome.js';
27
+ export { buildConsolidationInstruction, clearProjectAgentConsolidated, consolidatedDocumentPath, isConsolidated, loadConsolidationMetadata, loadProjectAgentConsolidated, readRawLearnedEntries, saveProjectAgentConsolidated } from './project-agent-consolidation.js';
28
+ export { DIRECTIVE_QUARANTINE_MAX_UTILITY, DIRECTIVE_QUARANTINE_MIN_APPLIED, directiveWasApplied, recordDirectiveOutcomes } from './project-agent-directive-outcome.js';
29
29
  export type { CreateProjectAgentInput, LearnedCaptureResult, ProjectAgentConfig, ProjectAgentProfile, RoleKnowledgeManifest, } from './project-agent-identity-types.js';
30
30
  export { splitLearnedEntries, tokenOverlap } from './project-agent-learning-entries.js';
31
- export { classifyLearnedEntry, LEARNED_ENTRY_MAX_CHARS, LEARNED_HARD_LIMIT, LEARNED_SOFT_LIMIT, type LearnedEntryCategory, normalizeLearnedEntry, } from './project-agent-learning-normalize.js';
32
- export { loadProjectAgentLearningPolicy, type ProjectAgentLearningPolicy, recordProjectAgentOptimizePass, updateProjectAgentLearningPolicy, } from './project-agent-learning-policy.js';
33
- export { DIRECTIVE_PROVEN_MIN_APPLIED, DIRECTIVE_PROVEN_MIN_UTILITY, decomposeLearnedEntry, directiveTrials, directiveUtility, enforceLearnedBudget, isProvenDirective, mergeStructuredEntries, parseLearnedEntryStamp, parseStructuredLearnedEntriesFromContent, renderLearnedInstructions, type StructuredLearnedEntry, } from './project-agent-learning-structured.js';
34
- export { type LearningOptimizerLlm, type OptimizeLearningOptions, type OptimizeLearningResult, optimizeProjectAgentLearning, unwrapWholeDocumentFence, } from './project-agent-optimizer.js';
31
+ export { classifyLearnedEntry, LEARNED_ENTRY_MAX_CHARS, LEARNED_HARD_LIMIT, LEARNED_SOFT_LIMIT, normalizeLearnedEntry } from './project-agent-learning-normalize.js';
32
+ export { loadProjectAgentLearningPolicy, recordProjectAgentOptimizePass, updateProjectAgentLearningPolicy } from './project-agent-learning-policy.js';
33
+ export { DIRECTIVE_PROVEN_MIN_APPLIED, DIRECTIVE_PROVEN_MIN_UTILITY, decomposeLearnedEntry, directiveTrials, directiveUtility, enforceLearnedBudget, isProvenDirective, mergeStructuredEntries, parseLearnedEntryStamp, parseStructuredLearnedEntriesFromContent, renderLearnedInstructions } from './project-agent-learning-structured.js';
34
+ export { optimizeProjectAgentLearning, unwrapWholeDocumentFence } from './project-agent-optimizer.js';
35
35
  export { assertProjectAgentRole } from './project-agent-paths.js';
36
- export { type QuarantinedDirective, quarantinePath, readQuarantinedDirectives, retiredDirectivesToWarnAbout, scrubRetiredLines, } from './project-agent-quarantine.js';
37
- export { buildSkillDistillInstruction, clearProjectSkillAugmentation, DEFAULT_EAGER_SKILL_LIMIT, listProjectSkillAugmentations, loadProjectSkillAugmentation, loadSkillAffinity, rankRoleSkills, recordSkillLoad, recordSkillOutcome, renderSkillAugmentation, resolveRoleSkillCandidates, routeDirectiveToSkill, SKILL_AUGMENTATION_MAX_BYTES, SKILL_EVIDENCE_HALF_LIFE_DAYS, type SkillAffinity, type SkillAffinityEntry, saveProjectSkillAugmentation, scoreSkillAffinity, setSkillPinned, } from './project-agent-skill-layer.js';
36
+ export { quarantinePath, readQuarantinedDirectives, retiredDirectivesToWarnAbout, scrubRetiredLines } from './project-agent-quarantine.js';
37
+ export { buildSkillDistillInstruction, clearProjectSkillAugmentation, DEFAULT_EAGER_SKILL_LIMIT, listProjectSkillAugmentations, loadProjectSkillAugmentation, loadSkillAffinity, rankRoleSkills, recordSkillLoad, recordSkillOutcome, renderSkillAugmentation, resolveRoleSkillCandidates, routeDirectiveToSkill, SKILL_AUGMENTATION_MAX_BYTES, SKILL_EVIDENCE_HALF_LIFE_DAYS, saveProjectSkillAugmentation, scoreSkillAffinity, setSkillPinned } from './project-agent-skill-layer.js';
38
38
  export { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION };
39
39
  export { listProjectAgentRoles, refreshProjectAgentIdentity, resetProjectAgentIdentity, updateProjectAgentConfig, updateProjectAgentIdentity, updateProjectAgentKnowledge, updateProjectAgentLearned, } from './project-agent-files.js';
40
40
  export { createProjectAgent, loadProjectAgentProfile, slugifyProjectAgentRole, } from './project-agent-profile.js';
41
41
  export { applyProjectAgentConfig, createProjectAgentRoster, } from './project-agent-roster.js';
42
- export { canCaptureNewLearned, captureLearnedFromAgentOutput, captureLearnedFromAgentOutputDetailed, detectLearnedConflicts, getProjectAgentLearnStats, hintLearnedNeedsSummarization, listProjectAgentLearnedEntries, loadProjectAgentLearned, parseStructuredLearnedEntries, type ProjectAgentLearnStats, } from './project-agent-capture.js';
42
+ export { canCaptureNewLearned, captureLearnedFromAgentOutput, captureLearnedFromAgentOutputDetailed, detectLearnedConflicts, getProjectAgentLearnStats, hintLearnedNeedsSummarization, listProjectAgentLearnedEntries, loadProjectAgentLearned, parseStructuredLearnedEntries } from './project-agent-capture.js';
43
43
  /**
44
44
  * Load the project-level identity appendix for a given role.
45
45
  * Appended to the subagent prompt after the base role prompt and policy.
@@ -41,6 +41,12 @@ export interface AgentCapability {
41
41
  * Optional `RoleDispatcherSignal` attached to the role. Wave-1/2/3/4 roles
42
42
  * carry this to make the "why this role wins" rationale auditable; legacy
43
43
  * roles omit it and the dispatcher falls back to `summary` + `keywords`.
44
+ *
45
+ * Set it on the definition itself — `ROLE_DISPATCH_RATIONALE` in
46
+ * `agents/index.ts` is derived from the catalog, and the LLM classifier
47
+ * reads `differentiatesFrom` from here. For a long stretch the wave files
48
+ * declared these blocks but only spread `.signals` into `keywords`, so the
49
+ * rationale and contrast text were authored and then dropped on the floor.
44
50
  */
45
51
  rationale?: RoleDispatcherSignal | undefined;
46
52
  }
@@ -57,8 +63,13 @@ export interface RoleDispatcherSignal {
57
63
  signals: readonly string[];
58
64
  /**
59
65
  * One-line description of how this role differs from its closest sibling
60
- * ("X finds defects; Y designs threats before code exists"). Used by tests
61
- * to assert distinct boundaries and by docs to explain routing.
66
+ * ("X finds defects; Y designs threats before code exists").
67
+ *
68
+ * Handed to the LLM dispatch classifier as a `vs. siblings:` line beside the
69
+ * candidate's summary (see `makeLLMClassifier`), which is the moment it
70
+ * matters: the classifier only runs when the heuristic could not separate
71
+ * roles that share vocabulary. Also asserted by
72
+ * `tests/coordination/role-dispatch-rationale.test.ts`.
62
73
  */
63
74
  differentiatesFrom: string;
64
75
  }
@@ -41,6 +41,16 @@ export type { BrainInterventionKind };
41
41
  export interface BrainInterventionInput {
42
42
  subject: string;
43
43
  body: string;
44
+ /**
45
+ * The session whose distress triggered this intervention.
46
+ *
47
+ * The steer has to reach THAT leader. A host that resolves the target from
48
+ * its own "current session" instead delivers the correction to whichever
49
+ * session is in front — with several sessions live under one host, the tab
50
+ * that is struggling gets nothing and an unrelated one is told to change
51
+ * approach. Undefined only when the signal itself carried no session.
52
+ */
53
+ sessionId?: string | undefined;
44
54
  }
45
55
  /**
46
56
  * How a detected distress signal is resolved.
@@ -132,14 +142,8 @@ export type BrainMonitorTunables = Partial<Pick<BrainMonitorOptions, 'enabled' |
132
142
  export declare const DEFAULT_FILE_EDIT_TOOLS: readonly string[];
133
143
  export declare class BrainMonitor {
134
144
  private readonly opts;
135
- private readonly failStreaks;
136
- private errorTimestamps;
137
- private readonly editTimestamps;
138
- private readonly lastEngagedAt;
145
+ private readonly bySession;
139
146
  private readonly unsubscribers;
140
- private engaging;
141
- private activeRuns;
142
- private lastProgressAt;
143
147
  private stallTimer;
144
148
  private toolFailureStreak;
145
149
  private errorStormCount;
@@ -164,6 +168,25 @@ export declare class BrainMonitor {
164
168
  private hostStarted;
165
169
  /** Resolve the leader's own session id for event filtering. */
166
170
  private resolveLeaderSessionId;
171
+ /**
172
+ * The signal state for one session, created on first sight.
173
+ *
174
+ * A host that pins `leaderSessionId` (the CLI, one session per process) only
175
+ * ever reaches one bucket. A host that does not (the WebUI, four tabs on one
176
+ * runtime) gets one bucket per tab, which is the point.
177
+ */
178
+ private stateFor;
179
+ /**
180
+ * Drop buckets for sessions that have been quiet longer than any signal
181
+ * window. Without this a long-lived host accumulates one bucket per session
182
+ * it has ever seen — cheap individually, unbounded in aggregate.
183
+ *
184
+ * Cooldowns are the one thing worth losing sleep over here: pruning a bucket
185
+ * resets its rate limit. That is acceptable only because the prune horizon is
186
+ * strictly longer than the cooldown, so a pruned session could have engaged
187
+ * again anyway.
188
+ */
189
+ private pruneIdleSessions;
167
190
  constructor(opts: BrainMonitorOptions);
168
191
  /** Resolve the live-tunable subset onto the instance. Shared by the constructor and `reconfigure`. */
169
192
  private applyTunables;
@@ -40,7 +40,7 @@ export declare const DEFAULT_MAX_TARGET_FILES = 30;
40
40
  * These flow through the FleetBus so the host can display them in the UI.
41
41
  */
42
42
  export { DirectorAlertLevel } from './collab-debug-types.js';
43
- export type { BugFinding, CollabBudgetConfig, BugFoundPayload, CollabBudgetOverrides, CollabBudgetWarningPayload, CollabDebugReport, CollabSessionOptions, CriticConcern, CriticEvaluation, CriticEvaluationPayload, DirectorAlert, DirectorCancelCollabPayload, RefactorPlan, RefactorPlanPayload, RefactorPhase, SharedFileEntry, SharedFileSnapshot, } from './collab-debug-types.js';
43
+ export type { BugFinding, CollabBudgetConfig, CollabBudgetOverrides, CollabBudgetWarningPayload, CollabDebugReport, CollabSessionOptions, CriticConcern, CriticEvaluation, DirectorAlert, DirectorCancelCollabPayload, RefactorPlan, RefactorPhase, SharedFileEntry, SharedFileSnapshot } from './collab-debug-types.js';
44
44
  import type { CollabDebugReport, CollabSessionOptions, DirectorAlert, SharedFileSnapshot } from './collab-debug-types.js';
45
45
  export declare class CollabSession extends EventEmitter {
46
46
  readonly sessionId: string;
@@ -1,5 +1,5 @@
1
1
  import type { CollaborationBus, InjectedToolResult } from './collab-bus.js';
2
- import type { ToolCallPipelinePayload } from '../core/agent.js';
2
+ import type { ToolCallPipelinePayload } from '../core/agent-types.js';
3
3
  import type { Middleware } from '../kernel/pipeline.js';
4
4
  /**
5
5
  * collabPauseMiddleware — gates the agent's `toolCall` pipeline on
@@ -62,11 +62,13 @@ export interface CreateDelegateToolOptions {
62
62
  subagentTimeoutBufferMs?: number | undefined;
63
63
  /**
64
64
  * Host EventBus. When supplied, `delegate` emits `delegate.started`
65
- * (before it blocks on the subagent) and `delegate.completed` (once the
66
- * subagent settles) so UIs / the Telegram bridge can render readable
67
- * start/finish lines instead of inferring them from the truncated
68
- * `tool.executed` JSON preview. Optional emits are best-effort and a
69
- * missing bus never affects delegation behaviour.
65
+ * (before it blocks on the subagent) and, once the subagent settles, both
66
+ * `delegate.completed` and `subagent.done` see `emitDelegateCompleted`
67
+ * below for why the outcome goes out on two names. UIs / the Telegram
68
+ * bridge render readable start/finish lines from these instead of
69
+ * inferring them from the truncated `tool.executed` JSON preview.
70
+ * Optional — emits are best-effort and a missing bus never affects
71
+ * delegation behaviour.
70
72
  */
71
73
  events?: EventBus | undefined;
72
74
  }
@@ -14,6 +14,7 @@ export interface KanbanQueueInput {
14
14
  role?: string | undefined;
15
15
  provider?: string | undefined;
16
16
  model?: string | undefined;
17
+ tier?: string | undefined;
17
18
  fallbackModels?: string[] | undefined;
18
19
  tools?: string[] | undefined;
19
20
  allowedCapabilities?: string[] | undefined;
@@ -1,3 +1,4 @@
1
+ import type { Config } from '../types/config.js';
1
2
  import type { Logger } from '../types/logger.js';
2
3
  import type { MultiAgentConfig, SubagentConfig, SubagentRunner, TaskResult, TaskSpec } from '../types/multi-agent.js';
3
4
  import type { SessionWriter } from '../types/session.js';
@@ -93,6 +94,12 @@ export interface DirectorOptions {
93
94
  maxLeaderContextLoad?: number | undefined;
94
95
  /** Provider's max context window in tokens. */
95
96
  maxContext?: number | (() => number | undefined) | undefined;
97
+ /**
98
+ * Live app config source for the deterministic model-tier layer. A getter is
99
+ * preferred so tier edits (WebUI / TUI / `/tier`) take effect on the next
100
+ * spawn without a restart, exactly like `modelMatrix`.
101
+ */
102
+ appConfig?: Config | (() => Config | undefined) | undefined;
96
103
  /** Per-task model matrix. */
97
104
  modelMatrix?: ModelMatrixSource | undefined;
98
105
  /** Optional git-worktree manager for Director fleet isolation. */
@@ -1,9 +1,26 @@
1
+ import type { Config } from '../types/config.js';
1
2
  import type { Logger } from '../types/logger.js';
2
3
  import type { SubagentConfig } from '../types/multi-agent.js';
3
4
  import type { ModelMatrixSource } from './model-matrix.js';
5
+ import type { ResolvedTierTarget } from './model-tier.js';
4
6
  import type { ProviderModelStatusTracker } from './provider-status-tracker.js';
5
7
  export interface ResolveDirectorSpawnModelOptions {
6
8
  modelMatrix?: ModelMatrixSource | undefined;
9
+ /**
10
+ * Live config, used to resolve the deterministic model-tier layer. Optional:
11
+ * when omitted (or when `modelTiers.enabled` is not true) the tier step is
12
+ * skipped entirely and resolution behaves exactly as it did before tiers
13
+ * existed.
14
+ */
15
+ config?: Config | undefined;
16
+ /**
17
+ * Tier named explicitly by the caller — the `tier` argument on `delegate` /
18
+ * `spawn_subagent`, or a Kanban task's persisted route. Outranks the routing
19
+ * table but still loses to an explicit provider/model.
20
+ */
21
+ tier?: string | undefined;
22
+ /** Observability hook: fired when a tier actually contributed a decision. */
23
+ onTierResolved?: ((resolved: ResolvedTierTarget) => void) | undefined;
7
24
  sessionProvider?: string | undefined;
8
25
  sessionModel?: string | undefined;
9
26
  statusTracker?: ProviderModelStatusTracker | undefined;
@@ -3,9 +3,9 @@ import type { Tool } from '../types/tool.js';
3
3
  import type * as Host from './director-host-contracts.js';
4
4
  export { makeAskResultTool, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeFleetTool, makeRollUpTool, makeTerminateAllTool, makeTerminateTool, } from './director-basic-tools.js';
5
5
  export { makeCollabDebugTool, makeFleetEmitTool, makeWorkCompleteTool, } from './director-collab-tools.js';
6
- export { makeQualityGateTool } from './director-quality-gate-tool.js';
7
6
  export { makeMutationTestTool } from './director-mutation-test-tool.js';
8
- export { applyMutation, type MutationKind, type MutationPlanItem, parseMutationReport, planMutations, } from './mutation-engine.js';
7
+ export { makeQualityGateTool } from './director-quality-gate-tool.js';
8
+ export { applyMutation, parseMutationReport, planMutations } from './mutation-engine.js';
9
9
  export declare function makeSpawnTool(director: Host.DirectorAdmissionPort, roster?: Record<string, SubagentConfig>): Tool;
10
10
  export declare function makeKanbanQueueTool(director: Host.DirectorLeaseRecoveryPort, roster?: Record<string, SubagentConfig>): Tool;
11
11
  //# sourceMappingURL=director-tools.d.ts.map
@@ -86,6 +86,7 @@ export declare class Director implements DirectorFleetHost, ICoordinator {
86
86
  leaderContextPressure: number;
87
87
  readonly maxLeaderContextLoad: number;
88
88
  private readonly maxContext;
89
+ private readonly appConfig?;
89
90
  readonly modelMatrix?: ModelMatrixSource | undefined;
90
91
  workCompleteFlag: boolean;
91
92
  private readonly btwNotes;
@@ -142,6 +143,17 @@ export declare class Director implements DirectorFleetHost, ICoordinator {
142
143
  retargetPendingTask(taskId: string, subagentId: string | undefined): boolean;
143
144
  terminate(subagentId: string): Promise<void>;
144
145
  terminateAll(): Promise<void>;
146
+ /**
147
+ * Terminate every subagent spawned by ONE session.
148
+ *
149
+ * What a tab's Stop button needs. `terminateAll()` is the wrong tool once
150
+ * several sessions share a director: it would kill three other tabs' fleets
151
+ * along with this one's. Aborting the leader's run only unwinds workers the
152
+ * leader is BLOCKED on (the delegate tool terminates those itself); anything
153
+ * started with `spawn_subagent` + `assign_task` keeps running because nobody
154
+ * asked it to stop. This is that ask, scoped to the session that owns them.
155
+ */
156
+ terminateSession(sessionId: string): Promise<void>;
145
157
  remove(subagentId: string): Promise<void>;
146
158
  private clearSubagentIdleRetirement;
147
159
  private armSubagentIdleRetirement;
@@ -43,11 +43,19 @@ export interface DispatchResult {
43
43
  * Provider-agnostic classifier seam. Given the task and the candidate agents
44
44
  * (role + summary), return the chosen role (and optional reason), or null to
45
45
  * decline. Wire via `makeLLMClassifier`.
46
+ *
47
+ * `differentiatesFrom` is present for roles that declare a
48
+ * `capability.rationale`. The classifier only ever runs on an ambiguous task —
49
+ * that is exactly when two siblings share vocabulary and a summary alone
50
+ * cannot separate them — so the contrast line is the most useful thing to hand
51
+ * it. Optional: legacy roles omit the rationale and the classifier falls back
52
+ * to `summary` for those.
46
53
  */
47
54
  export type DispatchClassifier = (task: string, candidates: {
48
55
  role: string;
49
56
  name: string;
50
57
  summary: string;
58
+ differentiatesFrom?: string | undefined;
51
59
  }[]) => Promise<{
52
60
  role: string;
53
61
  reason?: string | undefined;
@@ -58,6 +58,17 @@ export declare class FleetBus {
58
58
  * lean on summaries for the next task").
59
59
  */
60
60
  export interface FleetUsage {
61
+ /**
62
+ * Cumulative spend for the WHOLE run, retired subagents included.
63
+ *
64
+ * This used to be decremented when a subagent was retired, which made the
65
+ * figure mean "currently-live subagents" while every reader — the director's
66
+ * budget reasoning, `fleet.json`, `director-state.json` — treated it as the
67
+ * run total. A long orchestration that retires workers as it goes therefore
68
+ * under-reported its own spend, and the number could only ever fall.
69
+ * Retirement now moves a subagent's contribution into {@link retired}
70
+ * instead of erasing it.
71
+ */
61
72
  total: {
62
73
  input: number;
63
74
  output: number;
@@ -65,7 +76,22 @@ export interface FleetUsage {
65
76
  cacheWrite: number;
66
77
  cost: number;
67
78
  };
79
+ /** Live subagents only — retirement drops the entry to bound memory. */
68
80
  perSubagent: Record<string, SubagentUsageSnapshot>;
81
+ /**
82
+ * The share of {@link total} contributed by subagents no longer in
83
+ * `perSubagent`. `total` minus `retired` is the live-only figure the old
84
+ * decrementing behavior produced, so any consumer that genuinely wants
85
+ * "currently live" can still compute it.
86
+ */
87
+ retired: {
88
+ subagents: number;
89
+ input: number;
90
+ output: number;
91
+ cacheRead: number;
92
+ cacheWrite: number;
93
+ cost: number;
94
+ };
69
95
  }
70
96
  export interface SubagentUsageSnapshot {
71
97
  subagentId: string;
@@ -93,6 +119,7 @@ export declare class FleetUsageAggregator {
93
119
  private readonly metaLookup?;
94
120
  private readonly perSubagent;
95
121
  private readonly total;
122
+ private readonly retired;
96
123
  private readonly unsub;
97
124
  constructor(bus: FleetBus, priceLookup?: ((subagentId: string, provider?: string | undefined, model?: string | undefined) => {
98
125
  input?: number | undefined;
@@ -104,10 +131,14 @@ export declare class FleetUsageAggregator {
104
131
  model?: string | undefined;
105
132
  } | undefined) | undefined);
106
133
  /**
107
- * Remove a terminated subagent's data from the aggregator and subtract its
108
- * contribution from the running totals. Call this when a subagent is removed
109
- * from the fleet so the aggregator doesn't accumulate unbounded data for
110
- * entities that will never emit events again.
134
+ * Drop a terminated subagent's per-agent entry, folding its spend into
135
+ * {@link FleetUsage.retired} so the run total stays whole.
136
+ *
137
+ * The per-agent map is what needed bounding — one entry per spawn, for
138
+ * entities that will never emit again. Deducting from `total` as well (the
139
+ * original behavior) also un-spent real tokens: a run that retires each
140
+ * worker on completion reported a total that shrank as it made progress, and
141
+ * the director budgets against that number.
111
142
  */
112
143
  removeSubagent(subagentId: string): void;
113
144
  /** Disposes all fleet-bus subscriptions. Call when the aggregator is no longer needed. */
@@ -60,8 +60,16 @@ export interface FleetSupervisorActions {
60
60
  }>;
61
61
  /** High-priority steer mail to one agent. */
62
62
  steerAgent(subagentId: string, subject: string, body: string): Promise<void>;
63
- /** Status/steer mail to the session leader. */
64
- notifyLeader(subject: string, body: string): Promise<void>;
63
+ /**
64
+ * Status note to the session leader.
65
+ *
66
+ * `subagentId` names the worker the note is ABOUT, when there is one. The
67
+ * host resolves the conversation from it: with several tabs sharing this
68
+ * fleet, "the session leader" is not one address, and a note about tab 3's
69
+ * worker sent to the boot tab's leader reaches nobody who can act on it.
70
+ * Omitted for fleet-wide observations, which fall back to the host session.
71
+ */
72
+ notifyLeader(subject: string, body: string, subagentId?: string): Promise<void>;
65
73
  /** Abort a subagent (only used when config.allowTerminate). */
66
74
  terminate(subagentId: string): Promise<void>;
67
75
  }