@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
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '../../core/context.js';
2
+ import type { Usage } from '../../types/provider.js';
2
3
  export interface AgentEventMap {
3
4
  /**
4
5
  * Fired around a single Agent.run() call. Status trackers use these to
@@ -344,9 +345,15 @@ export interface AgentEventMap {
344
345
  reason?: string | undefined;
345
346
  };
346
347
  /**
347
- * Fired by the delegate tool when a subagent finishes. The agent's run
348
- * loop listens for this to collect `delegateSummaries` for the RunResult,
349
- * so the CLI/TUI can render flashy completion banners.
348
+ * Fired by the delegate tool when a subagent finishes raised from
349
+ * `emitDelegateCompleted` in `coordination/delegate-tool.ts`, alongside the
350
+ * richer `delegate.completed`. That helper is the ONLY emitter; keep any new
351
+ * completion branch routed through it rather than emitting
352
+ * `delegate.completed` directly, or these subscribers go silent again:
353
+ * - `core/agent-loop.ts` collects `delegateSummaries` for the RunResult
354
+ * (the CLI renderer's completion banner reads that array),
355
+ * - the bundled `agent-handoff` plugin posts its mailbox handoff note,
356
+ * - `webui-server` collab mirror forwards it to connected observers.
350
357
  */
351
358
  'subagent.done': {
352
359
  sessionId?: string | undefined;
@@ -370,5 +377,72 @@ export interface AgentEventMap {
370
377
  tokens: number;
371
378
  maxContext: number;
372
379
  };
380
+ /**
381
+ * A subagent's token spend, re-emitted onto the host EventBus with agent
382
+ * attribution attached.
383
+ *
384
+ * Deliberately NOT a replay of `token.accounted` under its own name. Every
385
+ * subagent runs on a private EventBus, so its `token.accounted` never
386
+ * reaches the host — but the host's subscribers for that event (statusline,
387
+ * `hq/cost-bridge`, `provider-cache-ledger`) all read it as LEADER spend.
388
+ * Re-emitting verbatim would fix subagent attribution by corrupting the
389
+ * leader's. Chronicle's domain adapter consumes this name through the
390
+ * `subagent.` prefix, mapping `subagentId` to `scope.agentId` and
391
+ * `provider`/`model` to `runtime`.
392
+ */
393
+ 'subagent.token_accounted': {
394
+ /** Parent/host session id — a subagent's spend rolls up to it. */
395
+ sessionId?: string | undefined;
396
+ subagentId: string;
397
+ agentName?: string | undefined;
398
+ /** Routed provider, falling back to the spawn-time selection. */
399
+ provider?: string | undefined;
400
+ /** Routed model, falling back to the spawn-time selection. */
401
+ model?: string | undefined;
402
+ /** This subagent's cumulative usage — never the leader's. */
403
+ usage: Usage;
404
+ /** Usage contributed by this one accounting call (not cumulative). */
405
+ deltaUsage?: Usage | undefined;
406
+ cost: {
407
+ input: number;
408
+ output: number;
409
+ total: number;
410
+ };
411
+ };
412
+ /**
413
+ * A subagent's provider attempt, re-emitted onto the host EventBus with
414
+ * agent attribution. Same rationale as {@link subagent.token_accounted}: the
415
+ * host's `provider.attempt.*` subscribers (fallback management, the shared
416
+ * `ProviderModelStatusTracker`, the leader's status surfaces) treat those
417
+ * events as leader activity, so subagent attempts get their own name. The
418
+ * three lifecycle phases collapse into one event keyed by `outcome` because
419
+ * every consumer of the subagent variant wants them on one timeline.
420
+ */
421
+ 'subagent.provider_attempt': {
422
+ /** Parent/host session id. */
423
+ sessionId?: string | undefined;
424
+ subagentId: string;
425
+ agentName?: string | undefined;
426
+ outcome: 'started' | 'completed' | 'failed';
427
+ provider?: string | undefined;
428
+ model?: string | undefined;
429
+ /** 0-based retry index within one logical request. */
430
+ attempt?: number | undefined;
431
+ durationMs?: number | undefined;
432
+ stopReason?: string | undefined;
433
+ /** Full Usage, cache buckets included — the point of bridging this at all. */
434
+ usage?: Usage | undefined;
435
+ /** Failure description; present on `outcome: 'failed'`. */
436
+ description?: string | undefined;
437
+ /** HTTP status; present on `outcome: 'failed'`. */
438
+ status?: number | undefined;
439
+ /** Retry classification; present on `outcome: 'failed'`. */
440
+ failureKind?: string | undefined;
441
+ retryable?: boolean | undefined;
442
+ traceId?: string | undefined;
443
+ logicalRequestId?: string | undefined;
444
+ promptManifestId?: string | undefined;
445
+ attemptId?: string | undefined;
446
+ };
373
447
  }
374
448
  //# sourceMappingURL=agent-events.d.ts.map
@@ -198,6 +198,18 @@ export interface BrainEventMap {
198
198
  */
199
199
  'token.accounted': {
200
200
  sessionId?: string | undefined;
201
+ /**
202
+ * Agent that burned these tokens. Absent means the leader.
203
+ *
204
+ * Every subagent runs on its own `DefaultTokenCounter` but reports the
205
+ * LEADER's session id (its counter is constructed with the host session so
206
+ * live cost UIs stay on one row). Without this field, a subagent's usage is
207
+ * indistinguishable from the leader's in every downstream consumer —
208
+ * Chronicle's domain adapter keys `scope.agentId` off it, and 2,402
209
+ * measured `token.accounted` rows landed with a null agent because nothing
210
+ * ever set it.
211
+ */
212
+ agentId?: string | undefined;
201
213
  usage: Usage;
202
214
  /** Usage contributed by this one accounting call (not cumulative). */
203
215
  deltaUsage?: Usage | undefined;
@@ -1,7 +1,7 @@
1
1
  import type { ChroniclePromptManifest } from '../../chronicle/prompt-manifest.js';
2
2
  import type { ContentBlock } from '../../types/blocks.js';
3
3
  import type { AgentContext } from '../../types/context.js';
4
- import type { ProviderErrorBody, Usage } from '../../types/provider.js';
4
+ import type { ProviderErrorBody, ProviderErrorKind, Usage } from '../../types/provider.js';
5
5
  export interface ProviderEventMap {
6
6
  /** Fired before every physical provider/model attempt, including attempt zero. */
7
7
  'provider.attempt.started': {
@@ -223,6 +223,12 @@ export interface ProviderEventMap {
223
223
  reason: string;
224
224
  timestamp: number;
225
225
  stateExpiresAt?: number | undefined;
226
+ /** Last-error context for durable audit logs; absent on clean transitions. */
227
+ lastErrorKind?: ProviderErrorKind | undefined;
228
+ lastErrorStatus?: number | null | undefined;
229
+ lastErrorMessage?: string | null | undefined;
230
+ lastSessionId?: string | null | undefined;
231
+ lastAgentId?: string | null | undefined;
226
232
  };
227
233
  /**
228
234
  * Fired by the UI when the user manually picks a model from the
@@ -33,6 +33,20 @@ export interface SessionEventMap {
33
33
  sessionId?: string | undefined;
34
34
  agents: readonly TrackedAgentSnapshot[];
35
35
  };
36
+ /**
37
+ * Same-session, in-process note from one agent to another (or the leader).
38
+ * Ephemeral: folded into the recipient's next iteration. Not mailbox —
39
+ * mailbox is the durable cross-session channel.
40
+ */
41
+ 'session.note': {
42
+ sessionId: string;
43
+ from: string;
44
+ to: string;
45
+ kind: 'note' | 'result' | 'ask' | 'steer';
46
+ body: string;
47
+ subject?: string | undefined;
48
+ ts: number;
49
+ };
36
50
  'iteration.started': {
37
51
  sessionId?: string | undefined;
38
52
  ctx: AgentContext;
@@ -270,5 +270,18 @@ export interface ToolEventMap {
270
270
  name: string;
271
271
  reason: string;
272
272
  };
273
+ /**
274
+ * Fired by `ToolRegistry.thinUnderused()` after auto-thinning disables
275
+ * one or more tools. The names are the tools that actually flipped
276
+ * (registered + not already disabled). `reason` is the human-readable
277
+ * caller label (e.g. `'boot-time auto-thin'`, `'manual apply'`); the
278
+ * audit-trail reason `'auto-thinned'` is also written to
279
+ * `disabledToolMeta` so the decision survives restarts.
280
+ */
281
+ 'tool.thinned': {
282
+ names: string[];
283
+ reason: string;
284
+ at: number;
285
+ };
273
286
  }
274
287
  //# sourceMappingURL=tool-events.d.ts.map
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Container
3
- } from "../chunk-O74MJHXU.js";
3
+ } from "../chunk-KZMSZV32.js";
4
4
  import {
5
5
  EventBus,
6
6
  ScopedEventBus
7
- } from "../chunk-4LJJYBAU.js";
7
+ } from "../chunk-FHZVFYSL.js";
8
8
  import {
9
9
  Pipeline,
10
10
  RunController,
11
11
  TOKENS
12
- } from "../chunk-Y2GE5TSI.js";
13
- import "../chunk-WOEZV3Q4.js";
12
+ } from "../chunk-NS52ISWS.js";
13
+ import "../chunk-25LSLC3G.js";
14
14
  import "../chunk-TBRL2RCC.js";
15
15
  export {
16
16
  Container,
@@ -16,8 +16,8 @@
16
16
  * @module mailbox-attach
17
17
  */
18
18
  import type { MailboxMessage } from './coordination/mailbox-types.js';
19
- import type { FleetConfig } from './types/config.js';
20
19
  import type { AgentInternals } from './core/agent-internals.js';
20
+ import type { FleetConfig } from './types/config.js';
21
21
  export declare function attachMailboxChecker(a: AgentInternals, source?: 'cli' | 'webui'): () => Promise<MailboxMessage[]>;
22
22
  /**
23
23
  * Fleet-pulse provider: returns a fresh "[FLEET PULSE]" digest block when
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  LLMSelector
3
- } from "../chunk-2FQL4PDC.js";
3
+ } from "../chunk-I7DALG7J.js";
4
4
  import {
5
5
  noOpLogger
6
6
  } from "../chunk-WBPVKEEE.js";
7
- import {
8
- DEFAULT_MODES
9
- } from "../chunk-2FK4WTFF.js";
10
7
  import {
11
8
  mergeModelsPayload
12
9
  } from "../chunk-EODDVJBM.js";
13
10
  import {
14
11
  FORBIDDEN_PROTO_KEYS
15
- } from "../chunk-DEIQMBD2.js";
12
+ } from "../chunk-B7F4WVP4.js";
16
13
  import "../chunk-5S437PRC.js";
17
14
  import "../chunk-4VWO3ZXL.js";
18
- import "../chunk-FSWCWSTS.js";
15
+ import "../chunk-HMLIGAU7.js";
19
16
  import {
20
17
  atomicWrite
21
- } from "../chunk-7ZHZE5EO.js";
18
+ } from "../chunk-OSGLYW5J.js";
19
+ import {
20
+ DEFAULT_MODES
21
+ } from "../chunk-2FK4WTFF.js";
22
+ import "../chunk-PFZO3C6H.js";
22
23
  import "../chunk-O37BQ65S.js";
23
24
  import {
24
25
  FetchError
25
- } from "../chunk-WOEZV3Q4.js";
26
+ } from "../chunk-25LSLC3G.js";
26
27
  import {
27
28
  toErrorMessage
28
29
  } from "../chunk-TBRL2RCC.js";
29
- import "../chunk-PFZO3C6H.js";
30
30
 
31
31
  // src/models/models-registry.ts
32
32
  import * as fs from "node:fs/promises";
@@ -749,6 +749,7 @@ function alibabaTokenPlanModelMeta(id) {
749
749
 
750
750
  // src/models/models-dev-schema.ts
751
751
  import { z } from "zod";
752
+ if ("document" in globalThis) z.config({ jitless: true });
752
753
  var MODELS_DEV_MODALITY_VALUES = ["text", "image", "audio", "video", "pdf"];
753
754
  var REASONING_EFFORT_LITERALS = [
754
755
  "none",
@@ -1,10 +1,30 @@
1
1
  import type { EventBus } from '../kernel/events.js';
2
2
  import type { MetricsSink } from '../types/observability.js';
3
+ /** Per-tool usage record maintained by the event-bridge for the auto-thinning
4
+ * pipeline's in-process fallback. The Chronicle rollup is the cross-session
5
+ * source of truth; this Map only fills the gap when Chronicle is unavailable
6
+ * (no node:sqlite at runtime) or hasn't refreshed yet. */
7
+ export interface ToolUsageRecord {
8
+ invocations: number;
9
+ failures: number;
10
+ durationMsTotal: number;
11
+ lastInvokedAt: number;
12
+ firstInvokedAt: number;
13
+ }
14
+ export type ToolUsageSnapshot = ReadonlyMap<string, ToolUsageRecord>;
15
+ /** The wireMetricsToEvents return value: the metrics sink plus the in-process
16
+ * tool-usage Map (read-only snapshot, updated in place by the listener), plus
17
+ * a `dispose()` that detaches every listener. */
18
+ export interface WiredMetricsHandle {
19
+ sink: MetricsSink;
20
+ getToolUsage(): ToolUsageSnapshot;
21
+ dispose(): void;
22
+ }
3
23
  /**
4
- * Subscribes a MetricsSink to the EventBus. Returns an unsubscribe function
5
- * that detaches all listeners. This is the single integration point between
6
- * the agent's event stream and the observability layer — no metric calls
7
- * leak into core call sites.
24
+ * Subscribes a MetricsSink to the EventBus. Returns a handle with the sink
25
+ * and a `getToolUsage()` accessor for the in-process per-tool usage Map.
26
+ * This is the single integration point between the agent's event stream
27
+ * and the observability layer — no metric calls leak into core call sites.
8
28
  */
9
- export declare function wireMetricsToEvents(events: EventBus, sink: MetricsSink): () => void;
29
+ export declare function wireMetricsToEvents(events: EventBus, sink: MetricsSink): WiredMetricsHandle;
10
30
  //# sourceMappingURL=event-bridge.d.ts.map
@@ -1,12 +1,13 @@
1
- export { InMemoryMetricsSink, type InMemoryMetricsSinkOptions, NoopMetricsSink, } from './metrics.js';
1
+ export { type ToolUsageRecord, type ToolUsageSnapshot, type WiredMetricsHandle, wireMetricsToEvents, } from './event-bridge.js';
2
2
  export { DefaultHealthRegistry } from './health.js';
3
- export { NoopTracer } from './tracer.js';
3
+ export { InMemoryMetricsSink, type InMemoryMetricsSinkOptions, NoopMetricsSink, } from './metrics.js';
4
+ export { type NetworkTelemetryContext, runWithNetworkTelemetry, startNetworkTelemetryMonitor, } from './network-telemetry.js';
4
5
  export { OTelTracer } from './otel-tracer.js';
5
- export { wireMetricsToEvents } from './event-bridge.js';
6
- export { emitProcessCompleted, emitProcessOutput, emitProcessStarted, runWithProcessTelemetry, type ProcessTelemetryContext, } from './process-telemetry.js';
6
+ export { buildOtlpMetricsRequest, type OtlpMetricsExporterHandle, type OtlpMetricsExporterOptions, startOtlpMetricsExporter, } from './otlp-metrics.js';
7
+ export { buildOtlpTracesRequest, type OtlpTraceExporterHandle, type OtlpTraceExporterOptions, startOtlpTraceExporter, } from './otlp-traces.js';
8
+ export { emitProcessCompleted, emitProcessOutput, emitProcessStarted, type ProcessTelemetryContext, runWithProcessTelemetry, } from './process-telemetry.js';
9
+ export { type MetricsServerHandle, type MetricsServerOptions, type MetricsTlsOptions, PROMETHEUS_CONTENT_TYPE, renderPrometheus, startMetricsServer, } from './prometheus.js';
7
10
  export { redactCommand, redactCommandArgs } from './redact-command.js';
8
- export { runWithNetworkTelemetry, startNetworkTelemetryMonitor, type NetworkTelemetryContext } from './network-telemetry.js';
9
- export { renderPrometheus, startMetricsServer, PROMETHEUS_CONTENT_TYPE, type MetricsServerOptions, type MetricsServerHandle, type MetricsTlsOptions, } from './prometheus.js';
10
- export { buildOtlpMetricsRequest, startOtlpMetricsExporter, type OtlpMetricsExporterOptions, type OtlpMetricsExporterHandle, } from './otlp-metrics.js';
11
- export { buildOtlpTracesRequest, startOtlpTraceExporter, type OtlpTraceExporterOptions, type OtlpTraceExporterHandle, } from './otlp-traces.js';
11
+ export { type CreateToolUsageSourceDeps, createToolUsageSource, filterUnderused, type ToolUsageSource, type UnderusedQueryOptions, type UnderusedToolCandidate, } from './tool-usage-source.js';
12
+ export { NoopTracer } from './tracer.js';
12
13
  //# sourceMappingURL=index.d.ts.map