@animalabs/agent-framework 0.32.0 → 0.34.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 (368) hide show
  1. package/README.md +340 -22
  2. package/dist/src/admission/admit.d.ts +18 -0
  3. package/dist/src/admission/admit.d.ts.map +1 -1
  4. package/dist/src/admission/admit.js +16 -3
  5. package/dist/src/admission/admit.js.map +1 -1
  6. package/dist/src/agent.d.ts +208 -80
  7. package/dist/src/agent.d.ts.map +1 -1
  8. package/dist/src/agent.js +345 -113
  9. package/dist/src/agent.js.map +1 -1
  10. package/dist/src/api/mcp-server-core.d.ts.map +1 -1
  11. package/dist/src/api/mcp-server-core.js +50 -12
  12. package/dist/src/api/mcp-server-core.js.map +1 -1
  13. package/dist/src/api/server.d.ts.map +1 -1
  14. package/dist/src/api/server.js +4 -20
  15. package/dist/src/api/server.js.map +1 -1
  16. package/dist/src/append-all.d.ts +5 -0
  17. package/dist/src/append-all.d.ts.map +1 -0
  18. package/dist/src/append-all.js +8 -0
  19. package/dist/src/append-all.js.map +1 -0
  20. package/dist/src/code-execution/isolate/scripts.d.ts +12 -8
  21. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
  22. package/dist/src/code-execution/isolate/scripts.js +24 -0
  23. package/dist/src/code-execution/isolate/scripts.js.map +1 -1
  24. package/dist/src/config-checks.d.ts +7 -0
  25. package/dist/src/config-checks.d.ts.map +1 -1
  26. package/dist/src/config-checks.js +14 -0
  27. package/dist/src/config-checks.js.map +1 -1
  28. package/dist/src/context-manager-errors.d.ts +25 -0
  29. package/dist/src/context-manager-errors.d.ts.map +1 -0
  30. package/dist/src/context-manager-errors.js +31 -0
  31. package/dist/src/context-manager-errors.js.map +1 -0
  32. package/dist/src/context-options.d.ts +70 -0
  33. package/dist/src/context-options.d.ts.map +1 -0
  34. package/dist/src/context-options.js +90 -0
  35. package/dist/src/context-options.js.map +1 -0
  36. package/dist/src/cut-off-round.js +4 -4
  37. package/dist/src/deferred-import.d.ts +93 -0
  38. package/dist/src/deferred-import.d.ts.map +1 -0
  39. package/dist/src/deferred-import.js +177 -0
  40. package/dist/src/deferred-import.js.map +1 -0
  41. package/dist/src/dendrite/audience.d.ts +223 -0
  42. package/dist/src/dendrite/audience.d.ts.map +1 -0
  43. package/dist/src/dendrite/audience.js +202 -0
  44. package/dist/src/dendrite/audience.js.map +1 -0
  45. package/dist/src/dendrite/index.d.ts +5 -3
  46. package/dist/src/dendrite/index.d.ts.map +1 -1
  47. package/dist/src/dendrite/index.js +2 -1
  48. package/dist/src/dendrite/index.js.map +1 -1
  49. package/dist/src/dendrite/presets.d.ts +10 -5
  50. package/dist/src/dendrite/presets.d.ts.map +1 -1
  51. package/dist/src/dendrite/presets.js +17 -5
  52. package/dist/src/dendrite/presets.js.map +1 -1
  53. package/dist/src/dendrite/registry.d.ts +62 -7
  54. package/dist/src/dendrite/registry.d.ts.map +1 -1
  55. package/dist/src/dendrite/registry.js +183 -12
  56. package/dist/src/dendrite/registry.js.map +1 -1
  57. package/dist/src/dendrite/types.d.ts +91 -8
  58. package/dist/src/dendrite/types.d.ts.map +1 -1
  59. package/dist/src/failure-text.d.ts +36 -0
  60. package/dist/src/failure-text.d.ts.map +1 -0
  61. package/dist/src/failure-text.js +89 -0
  62. package/dist/src/failure-text.js.map +1 -0
  63. package/dist/src/foreign-rounds.d.ts +69 -0
  64. package/dist/src/foreign-rounds.d.ts.map +1 -0
  65. package/dist/src/foreign-rounds.js +152 -0
  66. package/dist/src/foreign-rounds.js.map +1 -0
  67. package/dist/src/framework.d.ts +2064 -842
  68. package/dist/src/framework.d.ts.map +1 -1
  69. package/dist/src/framework.js +8586 -3739
  70. package/dist/src/framework.js.map +1 -1
  71. package/dist/src/gate/event-gate.d.ts +125 -21
  72. package/dist/src/gate/event-gate.d.ts.map +1 -1
  73. package/dist/src/gate/event-gate.js +487 -72
  74. package/dist/src/gate/event-gate.js.map +1 -1
  75. package/dist/src/gate/index.d.ts +1 -1
  76. package/dist/src/gate/index.d.ts.map +1 -1
  77. package/dist/src/gate/index.js.map +1 -1
  78. package/dist/src/gate/reply-judge.d.ts +4 -0
  79. package/dist/src/gate/reply-judge.d.ts.map +1 -1
  80. package/dist/src/gate/reply-judge.js +12 -3
  81. package/dist/src/gate/reply-judge.js.map +1 -1
  82. package/dist/src/gate/rule-scope.d.ts +30 -0
  83. package/dist/src/gate/rule-scope.d.ts.map +1 -0
  84. package/dist/src/gate/rule-scope.js +41 -0
  85. package/dist/src/gate/rule-scope.js.map +1 -0
  86. package/dist/src/gate/suppress-script-worker.d.ts +2 -0
  87. package/dist/src/gate/suppress-script-worker.d.ts.map +1 -0
  88. package/dist/src/gate/suppress-script-worker.js +103 -0
  89. package/dist/src/gate/suppress-script-worker.js.map +1 -0
  90. package/dist/src/gate/suppress-scripts.d.ts +105 -0
  91. package/dist/src/gate/suppress-scripts.d.ts.map +1 -0
  92. package/dist/src/gate/suppress-scripts.js +403 -0
  93. package/dist/src/gate/suppress-scripts.js.map +1 -0
  94. package/dist/src/gate/suppression-review.d.ts +143 -0
  95. package/dist/src/gate/suppression-review.d.ts.map +1 -0
  96. package/dist/src/gate/suppression-review.js +463 -0
  97. package/dist/src/gate/suppression-review.js.map +1 -0
  98. package/dist/src/gate/suppression-stats.d.ts +125 -0
  99. package/dist/src/gate/suppression-stats.d.ts.map +1 -0
  100. package/dist/src/gate/suppression-stats.js +214 -0
  101. package/dist/src/gate/suppression-stats.js.map +1 -0
  102. package/dist/src/gate/types.d.ts +142 -7
  103. package/dist/src/gate/types.d.ts.map +1 -1
  104. package/dist/src/gate/wake-onboarding.d.ts +119 -0
  105. package/dist/src/gate/wake-onboarding.d.ts.map +1 -0
  106. package/dist/src/gate/wake-onboarding.js +277 -0
  107. package/dist/src/gate/wake-onboarding.js.map +1 -0
  108. package/dist/src/heartbeat/heartbeat.js +1 -1
  109. package/dist/src/heartbeat/heartbeat.js.map +1 -1
  110. package/dist/src/held-writes.d.ts +31 -23
  111. package/dist/src/held-writes.d.ts.map +1 -1
  112. package/dist/src/held-writes.js +44 -59
  113. package/dist/src/held-writes.js.map +1 -1
  114. package/dist/src/index.d.ts +6 -2
  115. package/dist/src/index.d.ts.map +1 -1
  116. package/dist/src/index.js +4 -0
  117. package/dist/src/index.js.map +1 -1
  118. package/dist/src/inference-bounds.d.ts +2 -1
  119. package/dist/src/inference-bounds.d.ts.map +1 -1
  120. package/dist/src/inference-bounds.js +9 -6
  121. package/dist/src/inference-bounds.js.map +1 -1
  122. package/dist/src/jsonrpc-envelope.d.ts +69 -0
  123. package/dist/src/jsonrpc-envelope.d.ts.map +1 -0
  124. package/dist/src/jsonrpc-envelope.js +66 -0
  125. package/dist/src/jsonrpc-envelope.js.map +1 -0
  126. package/dist/src/mcpl/channel-registry.d.ts +188 -28
  127. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  128. package/dist/src/mcpl/channel-registry.js +426 -70
  129. package/dist/src/mcpl/channel-registry.js.map +1 -1
  130. package/dist/src/mcpl/checkpoint-manager.d.ts +2 -4
  131. package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -1
  132. package/dist/src/mcpl/checkpoint-manager.js.map +1 -1
  133. package/dist/src/mcpl/feature-set-manager.d.ts +2 -4
  134. package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
  135. package/dist/src/mcpl/feature-set-manager.js.map +1 -1
  136. package/dist/src/mcpl/inbound-source.d.ts +2 -1
  137. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  138. package/dist/src/mcpl/inbound-source.js +2 -1
  139. package/dist/src/mcpl/inbound-source.js.map +1 -1
  140. package/dist/src/mcpl/inference-router.d.ts +6 -6
  141. package/dist/src/mcpl/inference-router.d.ts.map +1 -1
  142. package/dist/src/mcpl/inference-router.js.map +1 -1
  143. package/dist/src/mcpl/modern-connection.d.ts +109 -15
  144. package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
  145. package/dist/src/mcpl/modern-connection.js +593 -86
  146. package/dist/src/mcpl/modern-connection.js.map +1 -1
  147. package/dist/src/mcpl/protocol-family.d.ts +3 -1
  148. package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
  149. package/dist/src/mcpl/protocol-family.js +15 -9
  150. package/dist/src/mcpl/protocol-family.js.map +1 -1
  151. package/dist/src/mcpl/push-coalescer.d.ts +132 -22
  152. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  153. package/dist/src/mcpl/push-coalescer.js +105 -15
  154. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  155. package/dist/src/mcpl/push-handler.d.ts +9 -7
  156. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  157. package/dist/src/mcpl/push-handler.js.map +1 -1
  158. package/dist/src/mcpl/server-connection.d.ts +50 -28
  159. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  160. package/dist/src/mcpl/server-connection.js +165 -72
  161. package/dist/src/mcpl/server-connection.js.map +1 -1
  162. package/dist/src/mcpl/tool-classes.d.ts.map +1 -1
  163. package/dist/src/mcpl/tool-classes.js +3 -0
  164. package/dist/src/mcpl/tool-classes.js.map +1 -1
  165. package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
  166. package/dist/src/mcpl/tool-presence.js +10 -6
  167. package/dist/src/mcpl/tool-presence.js.map +1 -1
  168. package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
  169. package/dist/src/mcpl/toolset-host.js +7 -6
  170. package/dist/src/mcpl/toolset-host.js.map +1 -1
  171. package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
  172. package/dist/src/mcpl/toolsets-module.js +2 -1
  173. package/dist/src/mcpl/toolsets-module.js.map +1 -1
  174. package/dist/src/mcpl/types.d.ts +33 -6
  175. package/dist/src/mcpl/types.d.ts.map +1 -1
  176. package/dist/src/mcpl/types.js.map +1 -1
  177. package/dist/src/module-registry.d.ts +24 -1
  178. package/dist/src/module-registry.d.ts.map +1 -1
  179. package/dist/src/module-registry.js +68 -18
  180. package/dist/src/module-registry.js.map +1 -1
  181. package/dist/src/modules/discord/index.d.ts +45 -8
  182. package/dist/src/modules/discord/index.d.ts.map +1 -1
  183. package/dist/src/modules/discord/index.js +238 -87
  184. package/dist/src/modules/discord/index.js.map +1 -1
  185. package/dist/src/modules/health/index.js +2 -2
  186. package/dist/src/modules/health/index.js.map +1 -1
  187. package/dist/src/modules/history/index.d.ts +59 -0
  188. package/dist/src/modules/history/index.d.ts.map +1 -1
  189. package/dist/src/modules/history/index.js +432 -67
  190. package/dist/src/modules/history/index.js.map +1 -1
  191. package/dist/src/modules/history/semantic.d.ts +6 -5
  192. package/dist/src/modules/history/semantic.d.ts.map +1 -1
  193. package/dist/src/modules/history/semantic.js +18 -25
  194. package/dist/src/modules/history/semantic.js.map +1 -1
  195. package/dist/src/modules/workspace/disk-agreement.d.ts +1 -1
  196. package/dist/src/modules/workspace/disk-agreement.js +1 -1
  197. package/dist/src/modules/workspace/index.d.ts +28 -7
  198. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  199. package/dist/src/modules/workspace/index.js +80 -25
  200. package/dist/src/modules/workspace/index.js.map +1 -1
  201. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  202. package/dist/src/modules/workspace/observe.js +2 -1
  203. package/dist/src/modules/workspace/observe.js.map +1 -1
  204. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  205. package/dist/src/modules/workspace/reconcile.js +3 -2
  206. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  207. package/dist/src/notice-tags.d.ts +20 -9
  208. package/dist/src/notice-tags.d.ts.map +1 -1
  209. package/dist/src/notice-tags.js +20 -9
  210. package/dist/src/notice-tags.js.map +1 -1
  211. package/dist/src/operator-log.d.ts +36 -3
  212. package/dist/src/operator-log.d.ts.map +1 -1
  213. package/dist/src/operator-log.js +2 -2
  214. package/dist/src/operator-log.js.map +1 -1
  215. package/dist/src/presentation.d.ts +747 -0
  216. package/dist/src/presentation.d.ts.map +1 -0
  217. package/dist/src/presentation.js +1437 -0
  218. package/dist/src/presentation.js.map +1 -0
  219. package/dist/src/prose-drafts.d.ts +15 -11
  220. package/dist/src/prose-drafts.d.ts.map +1 -1
  221. package/dist/src/prose-drafts.js +16 -12
  222. package/dist/src/prose-drafts.js.map +1 -1
  223. package/dist/src/read-marks.d.ts +192 -0
  224. package/dist/src/read-marks.d.ts.map +1 -0
  225. package/dist/src/read-marks.js +242 -0
  226. package/dist/src/read-marks.js.map +1 -0
  227. package/dist/src/reasoning-loss.d.ts +5 -0
  228. package/dist/src/reasoning-loss.d.ts.map +1 -0
  229. package/dist/src/reasoning-loss.js +8 -0
  230. package/dist/src/reasoning-loss.js.map +1 -0
  231. package/dist/src/recovery/offline-branch.d.ts +91 -6
  232. package/dist/src/recovery/offline-branch.d.ts.map +1 -1
  233. package/dist/src/recovery/offline-branch.js +277 -32
  234. package/dist/src/recovery/offline-branch.js.map +1 -1
  235. package/dist/src/recovery/recover-cli.js +24 -4
  236. package/dist/src/recovery/recover-cli.js.map +1 -1
  237. package/dist/src/send-tools.d.ts +5 -9
  238. package/dist/src/send-tools.d.ts.map +1 -1
  239. package/dist/src/send-tools.js +40 -7
  240. package/dist/src/send-tools.js.map +1 -1
  241. package/dist/src/sent-rows.js +1 -1
  242. package/dist/src/stored-injections.d.ts +2 -2
  243. package/dist/src/stored-injections.js +2 -2
  244. package/dist/src/stored-removal.d.ts +17 -4
  245. package/dist/src/stored-removal.d.ts.map +1 -1
  246. package/dist/src/stored-removal.js +29 -5
  247. package/dist/src/stored-removal.js.map +1 -1
  248. package/dist/src/supplied-text.d.ts +1 -1
  249. package/dist/src/supplied-text.js +3 -3
  250. package/dist/src/supplied-text.js.map +1 -1
  251. package/dist/src/thinking-drops.d.ts +2 -0
  252. package/dist/src/thinking-drops.d.ts.map +1 -1
  253. package/dist/src/thinking-drops.js.map +1 -1
  254. package/dist/src/tool-presentation.d.ts.map +1 -1
  255. package/dist/src/tool-presentation.js +38 -9
  256. package/dist/src/tool-presentation.js.map +1 -1
  257. package/dist/src/tool-result-guard.d.ts +12 -1
  258. package/dist/src/tool-result-guard.d.ts.map +1 -1
  259. package/dist/src/tool-result-guard.js +42 -8
  260. package/dist/src/tool-result-guard.js.map +1 -1
  261. package/dist/src/tune-out/coordinator.d.ts +1170 -81
  262. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  263. package/dist/src/tune-out/coordinator.js +3732 -369
  264. package/dist/src/tune-out/coordinator.js.map +1 -1
  265. package/dist/src/tune-out/tools.d.ts +114 -17
  266. package/dist/src/tune-out/tools.d.ts.map +1 -1
  267. package/dist/src/tune-out/tools.js +89 -28
  268. package/dist/src/tune-out/tools.js.map +1 -1
  269. package/dist/src/tune-out/window-anchor.d.ts +143 -0
  270. package/dist/src/tune-out/window-anchor.d.ts.map +1 -0
  271. package/dist/src/tune-out/window-anchor.js +202 -0
  272. package/dist/src/tune-out/window-anchor.js.map +1 -0
  273. package/dist/src/types/agent.d.ts +121 -25
  274. package/dist/src/types/agent.d.ts.map +1 -1
  275. package/dist/src/types/events.d.ts +2 -0
  276. package/dist/src/types/events.d.ts.map +1 -1
  277. package/dist/src/types/framework.d.ts +72 -17
  278. package/dist/src/types/framework.d.ts.map +1 -1
  279. package/dist/src/types/inference-log.d.ts +1 -0
  280. package/dist/src/types/inference-log.d.ts.map +1 -1
  281. package/dist/src/types/module.d.ts +180 -69
  282. package/dist/src/types/module.d.ts.map +1 -1
  283. package/dist/src/types/trace.d.ts +573 -39
  284. package/dist/src/types/trace.d.ts.map +1 -1
  285. package/package.json +4 -4
  286. package/src/admission/admit.ts +32 -3
  287. package/src/agent.ts +392 -132
  288. package/src/api/mcp-server-core.ts +54 -17
  289. package/src/api/server.ts +4 -23
  290. package/src/append-all.ts +6 -0
  291. package/src/code-execution/isolate/scripts.ts +28 -3
  292. package/src/config-checks.ts +14 -0
  293. package/src/context-manager-errors.ts +37 -0
  294. package/src/context-options.ts +106 -0
  295. package/src/cut-off-round.ts +4 -4
  296. package/src/deferred-import.ts +239 -0
  297. package/src/dendrite/audience.ts +315 -0
  298. package/src/dendrite/index.ts +14 -2
  299. package/src/dendrite/presets.ts +18 -6
  300. package/src/dendrite/registry.ts +213 -14
  301. package/src/dendrite/types.ts +92 -8
  302. package/src/failure-text.ts +88 -0
  303. package/src/foreign-rounds.ts +199 -0
  304. package/src/framework.ts +8796 -3813
  305. package/src/gate/event-gate.ts +518 -91
  306. package/src/gate/index.ts +3 -0
  307. package/src/gate/reply-judge.ts +12 -3
  308. package/src/gate/rule-scope.ts +45 -0
  309. package/src/gate/suppress-script-worker.ts +89 -0
  310. package/src/gate/suppress-scripts.ts +414 -0
  311. package/src/gate/suppression-review.ts +517 -0
  312. package/src/gate/suppression-stats.ts +314 -0
  313. package/src/gate/types.ts +148 -7
  314. package/src/gate/wake-onboarding.ts +309 -0
  315. package/src/heartbeat/heartbeat.ts +1 -1
  316. package/src/held-writes.ts +49 -60
  317. package/src/index.ts +10 -2
  318. package/src/inference-bounds.ts +11 -6
  319. package/src/jsonrpc-envelope.ts +81 -0
  320. package/src/mcpl/channel-registry.ts +513 -116
  321. package/src/mcpl/checkpoint-manager.ts +3 -2
  322. package/src/mcpl/feature-set-manager.ts +2 -1
  323. package/src/mcpl/inbound-source.ts +2 -1
  324. package/src/mcpl/inference-router.ts +7 -4
  325. package/src/mcpl/modern-connection.ts +629 -91
  326. package/src/mcpl/protocol-family.ts +15 -9
  327. package/src/mcpl/push-coalescer.ts +193 -34
  328. package/src/mcpl/push-handler.ts +10 -5
  329. package/src/mcpl/server-connection.ts +169 -75
  330. package/src/mcpl/tool-classes.ts +3 -0
  331. package/src/mcpl/tool-presence.ts +10 -5
  332. package/src/mcpl/toolset-host.ts +7 -6
  333. package/src/mcpl/toolsets-module.ts +2 -1
  334. package/src/mcpl/types.ts +33 -6
  335. package/src/module-registry.ts +73 -17
  336. package/src/modules/discord/index.ts +230 -82
  337. package/src/modules/health/index.ts +2 -2
  338. package/src/modules/history/index.ts +439 -70
  339. package/src/modules/history/semantic.ts +18 -24
  340. package/src/modules/workspace/disk-agreement.ts +1 -1
  341. package/src/modules/workspace/index.ts +89 -26
  342. package/src/modules/workspace/observe.ts +2 -1
  343. package/src/modules/workspace/reconcile.ts +3 -2
  344. package/src/notice-tags.ts +21 -9
  345. package/src/operator-log.ts +36 -3
  346. package/src/presentation.ts +1678 -0
  347. package/src/prose-drafts.ts +16 -12
  348. package/src/read-marks.ts +328 -0
  349. package/src/reasoning-loss.ts +7 -0
  350. package/src/recovery/offline-branch.ts +350 -35
  351. package/src/recovery/recover-cli.ts +23 -4
  352. package/src/send-tools.ts +40 -7
  353. package/src/sent-rows.ts +1 -1
  354. package/src/stored-injections.ts +2 -2
  355. package/src/stored-removal.ts +31 -7
  356. package/src/supplied-text.ts +3 -3
  357. package/src/thinking-drops.ts +2 -0
  358. package/src/tool-presentation.ts +34 -9
  359. package/src/tool-result-guard.ts +41 -7
  360. package/src/tune-out/coordinator.ts +4121 -472
  361. package/src/tune-out/tools.ts +162 -44
  362. package/src/tune-out/window-anchor.ts +277 -0
  363. package/src/types/agent.ts +122 -25
  364. package/src/types/events.ts +2 -0
  365. package/src/types/framework.ts +73 -17
  366. package/src/types/inference-log.ts +1 -0
  367. package/src/types/module.ts +181 -68
  368. package/src/types/trace.ts +607 -43
@@ -1,18 +1,24 @@
1
1
  import type { ThinkingBindingEntry } from '@animalabs/membrane';
2
2
  import type { ProcessEvent } from './events.js';
3
3
  import type { ModuleProcessResponse } from './framework.js';
4
- import type { SessionUsage } from '../usage/types.js';
4
+ import type { UsageUpdatedEvent } from '../usage/types.js';
5
5
  import type { DraftReason } from '../prose-drafts.js';
6
+ import type { MessageSlotRef } from '../dendrite/types.js';
7
+ import type { PresentationOccasion } from '../presentation.js';
8
+ import type { RecipeChanges } from '../gate/recipe-reconcile.js';
9
+ import type { DesiredChannelState } from '../mcpl/channel-registry.js';
10
+ import type { PushEventResult } from '../mcpl/types.js';
11
+ import type { CoalescingAudit } from '../mcpl/push-coalescer.js';
6
12
  /**
7
13
  * Base for all trace events.
8
14
  * TraceEvents are observability-only — they NEVER drive logic.
9
15
  */
10
- export interface TraceEventBase {
16
+ export type TraceEventBase = {
11
17
  /** When this trace was emitted */
12
18
  timestamp: number;
13
19
  /** Optional correlation ID for distributed tracing */
14
20
  traceId?: string;
15
- }
21
+ };
16
22
  /**
17
23
  * Observability events emitted by the framework.
18
24
  * Subscribe via framework.onTrace() to monitor system behavior.
@@ -131,6 +137,14 @@ export type TraceEvent = (TraceEventBase & {
131
137
  agentName: string;
132
138
  /** The failure's message, bounded as every trace event's `error` is (2,000 characters). */
133
139
  error: string;
140
+ /**
141
+ * The reason the agent's `[inference-failed]` note may give, before the
142
+ * note's own 600-character cut, and bounded as `error` is. Present only
143
+ * when the failure's message holds no provider's text: a progress
144
+ * bound's cut, a stream's abort, or context-manager's refusal of a
145
+ * compile. Absent otherwise, and a note then gives no reason.
146
+ */
147
+ shownReason?: string;
134
148
  /** Whether membrane classified the failure as retryable (observability). */
135
149
  retryable?: boolean;
136
150
  /**
@@ -144,6 +158,53 @@ export type TraceEvent = (TraceEventBase & {
144
158
  httpStatus?: number;
145
159
  /** The provider's own error code, when it sent one (at most 128 characters). */
146
160
  providerErrorCode?: string;
161
+ }) | (TraceEventBase & {
162
+ /**
163
+ * A start whose compile was refused for budget while compression was
164
+ * pending waits in the agent's budget hold, idle, instead of failing
165
+ * (#304). It follows the refused attempt's `inference:failed`. Once
166
+ * something the refused compile depends on has changed (compression's
167
+ * progress, nothing left pending, a surgery or an undo, the agent's
168
+ * budget or live context settings, or a quiesce's end), the hold ends,
169
+ * the held requests are queued, and its note is stored as the agent's
170
+ * own row, entering its window at once or, while a turn of the agent's
171
+ * is alive, at its next presentation point; a failed write stores
172
+ * none. Their start's own compile is the check: refused again while
173
+ * compression is pending, it waits in a new hold, with a new
174
+ * `inference:held`. `inference:hold_ended` follows each, once. An
175
+ * ephemeral run's start, and one before the framework's `start()`,
176
+ * never waits.
177
+ */
178
+ type: 'inference:held';
179
+ agentName: string;
180
+ /** 'over_budget', or 'context_refusal' when no summary covers a span the compile would drop. */
181
+ errorType: 'over_budget' | 'context_refusal';
182
+ /** The refusal's message, bounded as a trace event's `error` is (2,000 characters). */
183
+ error: string;
184
+ /** The refused compile's budget and size in tokens, when context-manager gave them. */
185
+ budget?: number;
186
+ actual?: number;
187
+ /** When this hold started (epoch ms). A wait held again after its
188
+ * release starts a new hold; its `context-refusal` alert and the note
189
+ * count from the wait's first hold. */
190
+ since: number;
191
+ /** Requests the hold holds as it starts: the refused start's own. */
192
+ heldRequests: number;
193
+ }) | (TraceEventBase & {
194
+ type: 'inference:hold_ended';
195
+ agentName: string;
196
+ /**
197
+ * 'released': something the refused compile depends on changed, so the
198
+ * held requests were queued and their start's compile is the check.
199
+ * 'stopped': the held turn was ended by `abortInference()`, `stop()` or
200
+ * its agent's end, reported after its `inference:aborted`. 'removed': a
201
+ * surgery or an undo removed what the held turn stood on, reported after
202
+ * its `inference:aborted`, and the wakes that joined it go back to the
203
+ * queue.
204
+ */
205
+ outcome: 'released' | 'stopped' | 'removed';
206
+ /** Since the hold started (`inference:held`'s `since`). */
207
+ waitedMs: number;
147
208
  }) | (TraceEventBase & {
148
209
  type: 'inference:tokens';
149
210
  agentName: string;
@@ -166,7 +227,9 @@ export type TraceEvent = (TraceEventBase & {
166
227
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
167
228
  * Explicit mode: the channel its typing shows, where the start's wake
168
229
  * came from, or, at a start whose wake names none, such as a budget
169
- * restart, the one the turn already shows. */
230
+ * restart, the one the turn already shows. Disabled mode, and a silent
231
+ * turn in any mode: none, though the turn may show typing, since its
232
+ * text is never sent to a channel. */
170
233
  channelId?: string;
171
234
  }) | (TraceEventBase & {
172
235
  /**
@@ -190,7 +253,9 @@ export type TraceEvent = (TraceEventBase & {
190
253
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
191
254
  * Explicit mode: the channel its typing shows, where the start's wake
192
255
  * came from, or, at a start whose wake names none, such as a budget
193
- * restart, the one the turn already shows. */
256
+ * restart, the one the turn already shows. Disabled mode, and a silent
257
+ * turn in any mode: none, though the turn may show typing, since its
258
+ * text is never sent to a channel. */
194
259
  channelId?: string;
195
260
  }) | (TraceEventBase & {
196
261
  type: 'inference:tool_calls_yielded';
@@ -312,6 +377,7 @@ export type TraceEvent = (TraceEventBase & {
312
377
  module: string;
313
378
  tool: string;
314
379
  callId: string;
380
+ durationMs?: number;
315
381
  error: string;
316
382
  stack?: string;
317
383
  }) | (TraceEventBase & {
@@ -360,7 +426,12 @@ export type TraceEvent = (TraceEventBase & {
360
426
  agentStatus: string;
361
427
  requestCount: number;
362
428
  oldestRequestAge: number;
363
- }) | (TraceEventBase & {
429
+ })
430
+ /** A message stored, with its stored id. A write kept in memory first (a
431
+ * live surgery's hold, or the wait for its agent's context manager to be
432
+ * re-initialized) is traced once, as a release stores it, with source
433
+ * `surgery-release`; its arrival isn't traced. */
434
+ | (TraceEventBase & {
364
435
  type: 'message:added';
365
436
  messageId: string;
366
437
  source: string;
@@ -371,6 +442,25 @@ export type TraceEvent = (TraceEventBase & {
371
442
  messageId: string;
372
443
  source: string;
373
444
  })
445
+ /** A write kept in memory until a live surgery's release (source
446
+ * `surgery-release`) whose store threw there: none of it was stored, or,
447
+ * with `mayBeStored`, context-manager couldn't tell what of it landed (the
448
+ * first row it names as stored is traced as `message:added`, as a stored
449
+ * write is). `external` is the address the write's metadata gave it, for
450
+ * the module that wrote it
451
+ * (the Discord module ends its record of a create with no row). The
452
+ * agent's writes lost at a release are told of once besides, by an ops
453
+ * alert of kind `store-held-lost`. */
454
+ | (TraceEventBase & {
455
+ type: 'message:lost';
456
+ source: string;
457
+ agentName: string;
458
+ external?: {
459
+ source: string;
460
+ id: string;
461
+ };
462
+ mayBeStored?: true;
463
+ })
374
464
  /** A push/event refused at the MCPL boundary: visibly-empty content
375
465
  * (`empty-content`, answered -32602, with no `field` or `detail`), or a
376
466
  * coalesced occurrence the host refused. A refused occurrence's reason
@@ -393,6 +483,12 @@ export type TraceEvent = (TraceEventBase & {
393
483
  field?: string;
394
484
  channelId?: string;
395
485
  detail?: string;
486
+ }) | (TraceEventBase & {
487
+ type: 'mcpl:push_event';
488
+ serverId: string;
489
+ eventId: string;
490
+ featureSet: string;
491
+ coalesce?: PushEventResult['coalesce'];
396
492
  })
397
493
  /** A channels/incoming message refused at the MCPL boundary: an
398
494
  * unregistered channel (`unknown-channel`, §14.5), visibly-empty content
@@ -412,6 +508,61 @@ export type TraceEvent = (TraceEventBase & {
412
508
  reason: string;
413
509
  field?: string;
414
510
  detail?: string;
511
+ }) | (TraceEventBase & {
512
+ type: 'mcpl:channels-register';
513
+ serverId: string;
514
+ channelIds: string[];
515
+ count: number;
516
+ }) | (TraceEventBase & {
517
+ type: 'mcpl:channels-changed';
518
+ serverId: string;
519
+ /** The `id` of each descriptor in the notification's `added`, rejected ones included, as the server sent it: not validated, so a malformed descriptor's might not be a string. */
520
+ added: string[];
521
+ /** The notification's `removed`, as the server sent it: not validated, so a channel the server names by a number arrives as that number. */
522
+ removed: string[];
523
+ /** As `added`, for the notification's `updated`. */
524
+ updated: string[];
525
+ }) | (TraceEventBase & {
526
+ type: 'mcpl:channels-incoming';
527
+ serverId: string;
528
+ messageCount: number;
529
+ /** The distinct `channelId`s of the batch's messages, rejected ones included, as the server sent them: not validated, so a malformed message's might not be a string. */
530
+ channelIds: string[];
531
+ }) | (TraceEventBase & {
532
+ type: 'mcpl:channel-descriptor-rejected';
533
+ serverId: string;
534
+ channelId?: string;
535
+ reason: string;
536
+ }) | (TraceEventBase & {
537
+ type: 'mcpl:channel-lazy-registered';
538
+ serverId: string;
539
+ channelId: string;
540
+ label: string;
541
+ }) | (TraceEventBase & {
542
+ type: 'mcpl:channel-opened-by-send';
543
+ serverId: string;
544
+ channelId: string;
545
+ }) | (TraceEventBase & {
546
+ type: 'mcpl:channel-open-failed';
547
+ serverId: string;
548
+ channelId: string;
549
+ error: string;
550
+ }) | (TraceEventBase & {
551
+ type: 'mcpl:channel-open-substituted';
552
+ serverId: string;
553
+ channelId: string;
554
+ answeredFor: string;
555
+ }) | (TraceEventBase & {
556
+ type: 'mcpl:channel-reconcile-failed';
557
+ serverId: string;
558
+ channelId: string;
559
+ desired?: DesiredChannelState;
560
+ attempts?: number;
561
+ error: string;
562
+ }) | (TraceEventBase & {
563
+ type: 'mcpl:channel-reconcile-skipped';
564
+ serverId: string;
565
+ reason: string;
415
566
  })
416
567
  /** MCPL content that context-manager won't store, because it doesn't
417
568
  * match ContentBlock, reached the store/wake site and was refused there:
@@ -435,8 +586,7 @@ export type TraceEvent = (TraceEventBase & {
435
586
  channelId?: string;
436
587
  messageId?: string;
437
588
  })
438
- /** RFC-006 coalescing decision record (received / displaced / removed /
439
- * rendered / revoked / render-cancelled / late-render / render-failed).
589
+ /** RFC-006 coalescing decision record, by `kind`.
440
590
  * A late-render whose push/render had already timed out, its fallback
441
591
  * materialized, is recorded by the connection's wiring rather than the
442
592
  * coalescer: it names `serverId`, `featureSet`, `key` and, for a
@@ -445,10 +595,21 @@ export type TraceEvent = (TraceEventBase & {
445
595
  * links it to the batch's render-failed. */
446
596
  | (TraceEventBase & {
447
597
  type: 'mcpl:coalescing';
448
- kind: string;
449
- subject?: string;
598
+ } & CoalescingAudit) | (TraceEventBase & {
599
+ type: 'mcpl:coalescing';
600
+ kind: 'late-render';
601
+ serverId: string;
450
602
  eventId?: string;
451
- [key: string]: unknown;
603
+ featureSet?: string;
604
+ key?: string;
605
+ channelId?: string;
606
+ discarded: true;
607
+ error?: string;
608
+ }) | (TraceEventBase & {
609
+ type: 'mcpl:coalescing';
610
+ kind: 'turn-withdrawn';
611
+ agentName: string;
612
+ subjects: string[];
452
613
  }) | (TraceEventBase & {
453
614
  type: 'gate:policy-matched';
454
615
  policyName: string;
@@ -485,9 +646,8 @@ export type TraceEvent = (TraceEventBase & {
485
646
  * gate hands the line to the wake when its message is the newest at
486
647
  * the fire, EventGate isNewestEntry, and the turn's start decides).
487
648
  * `reason`: `newest`, on the delivery agent's start the message was
488
- * still the newest entry in the window; `held`, the host was quiesced
489
- * or another reader of the residents' shared slot had a turn alive,
490
- * so no line could be written then. */
649
+ * still the newest entry in the window; `held`, the host was
650
+ * quiesced, so no line could be written then. */
491
651
  type: 'gate:wake-line-omitted';
492
652
  reason: 'newest' | 'held';
493
653
  policyNames: string[];
@@ -497,6 +657,8 @@ export type TraceEvent = (TraceEventBase & {
497
657
  type: 'gate:config-reloaded';
498
658
  configPath: string;
499
659
  policyCount: number;
660
+ removedPolicies?: string[];
661
+ stateClearedPolicies?: string[];
500
662
  }) | (TraceEventBase & {
501
663
  type: 'gate:decision';
502
664
  eventType: string;
@@ -505,23 +667,68 @@ export type TraceEvent = (TraceEventBase & {
505
667
  matchedPolicy: string | null;
506
668
  trigger: boolean;
507
669
  behavior: string;
508
- }) | (TraceEventBase & {
509
- type: 'usage:updated';
510
- totals: SessionUsage;
670
+ observed?: string[];
671
+ })
672
+ /** A periodic review of what suppress rules hid ran (gate/suppression-review.ts); `delivered` when the agent was told. */
673
+ | (TraceEventBase & {
674
+ type: 'gate:suppression-review';
511
675
  agentName: string;
512
- inferenceCount: number;
676
+ fromMs: number;
677
+ toMs: number;
678
+ total: number;
679
+ flagged: number;
680
+ delivered: boolean;
681
+ rules: Array<{
682
+ rule: string;
683
+ suppressed: number;
684
+ read: number;
685
+ verdict: 'fits' | 'flagged' | 'error' | 'unjudged';
686
+ flagged: number;
687
+ }>;
688
+ })
689
+ /** A suppress rule took an event: its row is stored and never rendered (EventGate.noteSuppressed). */
690
+ | (TraceEventBase & {
691
+ type: 'gate:suppressed';
692
+ policyName: string;
693
+ eventType: string;
694
+ serverId?: string;
695
+ channelId?: string;
696
+ }) | (TraceEventBase & Fields<RecipeChanges> & {
697
+ type: 'gate:config-reconciled';
698
+ configPath: string;
699
+ addedPolicies: string[];
513
700
  }) | (TraceEventBase & {
514
- type: 'undo:completed';
515
- agentName: string;
516
- turnIndex: number;
517
- fromBranch: string;
518
- toBranch: string;
701
+ type: 'gate:policy-added';
702
+ configPath: string;
703
+ policyName: string;
704
+ replaced: boolean;
519
705
  }) | (TraceEventBase & {
520
- type: 'redo:completed';
521
- agentName: string;
522
- fromBranch: string;
523
- toBranch: string;
706
+ type: 'gate:policy-removed';
707
+ configPath: string;
708
+ policyName: string;
524
709
  }) | (TraceEventBase & {
710
+ type: 'gate:shadow-warnings';
711
+ reason: string;
712
+ warnings: string[];
713
+ })
714
+ /** Wake onboarding offered a server's suggestions after an undecided event
715
+ * (gate/wake-onboarding.ts): `policy` let it go by (null: the default). */
716
+ | (TraceEventBase & {
717
+ type: 'gate:onboarding-offered';
718
+ serverId: string;
719
+ digest: string;
720
+ policy: string | null;
721
+ rules: number;
722
+ wake: boolean;
723
+ })
724
+ /** The agent answered an offer: rules accepted (the names written), or declined. */
725
+ | (TraceEventBase & {
726
+ type: 'gate:onboarding-decided';
727
+ serverId: string;
728
+ digest: string;
729
+ state: 'accepted' | 'declined';
730
+ rules: string[];
731
+ }) | (TraceEventBase & Fields<UsageUpdatedEvent>) | (TraceEventBase & {
525
732
  type: 'operator:action';
526
733
  agentName?: string;
527
734
  kind: string;
@@ -615,10 +822,6 @@ export type TraceEvent = (TraceEventBase & {
615
822
  toolUseId: string;
616
823
  isError: boolean;
617
824
  durationMs: number;
618
- /** The pair was queued behind a turn that replaced the puppet's
619
- * reservation (provider-admission re-entry) instead of stored
620
- * directly; it lands at that turn's end flush. */
621
- deferred?: boolean;
622
825
  }) | (TraceEventBase & {
623
826
  type: 'mcpl:server-connect-failed';
624
827
  serverId: string;
@@ -694,6 +897,45 @@ export type TraceEvent = (TraceEventBase & {
694
897
  unrecognized?: string[];
695
898
  /** missing_capabilities: the capability paths the grant lacks. */
696
899
  missing?: string[];
900
+ }) | (TraceEventBase & {
901
+ type: 'mcpl:inference_start';
902
+ serverId: string;
903
+ featureSet: string;
904
+ model: string;
905
+ stream: boolean;
906
+ }) | (TraceEventBase & {
907
+ type: 'mcpl:inference_complete';
908
+ serverId: string;
909
+ model: string;
910
+ actualModel?: string;
911
+ inputTokens: number;
912
+ outputTokens: number;
913
+ streamed: boolean;
914
+ }) | (TraceEventBase & {
915
+ type: 'mcpl:inference_fail';
916
+ serverId: string;
917
+ model: string | null;
918
+ error: string;
919
+ streamed: boolean;
920
+ }) | (TraceEventBase & {
921
+ type: 'mcpl:state_registered';
922
+ serverId: string;
923
+ featureSet: string;
924
+ hostState: boolean;
925
+ rollback: boolean;
926
+ }) | (TraceEventBase & {
927
+ type: 'mcpl:checkpoint_recorded';
928
+ serverId: string;
929
+ featureSet: string;
930
+ checkpoint: string;
931
+ parent: string | null;
932
+ hasData: boolean;
933
+ hasPatch: boolean;
934
+ }) | (TraceEventBase & {
935
+ type: 'mcpl:state_rollback';
936
+ serverId: string;
937
+ featureSet: string;
938
+ checkpoint: string;
697
939
  }) | (TraceEventBase & {
698
940
  /** An operator tool-name pattern matches no model-facing tool. Emitted
699
941
  * once per pattern, after the servers it could name have listed. */
@@ -767,14 +1009,19 @@ export type TraceEvent = (TraceEventBase & {
767
1009
  error?: string;
768
1010
  }) | (TraceEventBase & {
769
1011
  type: 'ops:alert';
770
- /** Alert kind — open set: 'refusal' | 'hard-down' | 'mcpl-down' | … */
1012
+ /** Alert kind — open set: 'refusal' | 'hard-down' | 'mcpl-down' | …
1013
+ * A kind ending in `-clear` ends the alert of the kind before it:
1014
+ * 'context-refusal-clear' is raised when a budget hold whose wait
1015
+ * raised 'context-refusal' ends with its turn stopped or removed, so
1016
+ * the waiting start doesn't run. */
771
1017
  kind: string;
772
1018
  /** Agent name, or a server/component id for non-agent alerts (e.g. mcpl-down). */
773
1019
  agentName: string;
774
1020
  /** At most 2,000 characters. */
775
1021
  message: string;
776
- /** Kind-specific structured payload (mirrors the failures.log record),
777
- * bounded field by field as that record is. */
1022
+ /** Kind-specific structured payload (mirrors the failures.log record,
1023
+ * where the alert writes one: a budget hold's 'context-refusal' and its
1024
+ * clear write none), bounded field by field as that record is. */
778
1025
  data?: Record<string, unknown>;
779
1026
  }) | (TraceEventBase & {
780
1027
  type: 'host:quiesce';
@@ -799,6 +1046,143 @@ export type TraceEvent = (TraceEventBase & {
799
1046
  type: 'host:quiesced_boot';
800
1047
  reason?: string;
801
1048
  since?: number;
1049
+ }) | (TraceEventBase & {
1050
+ type: 'tune-out:entered';
1051
+ serverId: string;
1052
+ channelId: string;
1053
+ epochId: string;
1054
+ scope?: 'all-except';
1055
+ reader: boolean;
1056
+ expiresAtMs?: number;
1057
+ }) | (TraceEventBase & {
1058
+ type: 'tune-out:cancelled';
1059
+ serverId: string;
1060
+ channelId: string;
1061
+ epochId: string;
1062
+ scope?: 'all-except';
1063
+ reason: string;
1064
+ wakeCount: number;
1065
+ }) | (TraceEventBase & {
1066
+ type: 'tune-out:announced';
1067
+ serverId: string;
1068
+ channelId: string;
1069
+ epochId: string;
1070
+ kind: 'entered' | 'released';
1071
+ }) | (TraceEventBase & {
1072
+ type: 'tune-out:announce-failed';
1073
+ serverId: string;
1074
+ channelId: string;
1075
+ epochId: string;
1076
+ kind: 'entered' | 'released';
1077
+ error: string;
1078
+ }) | (TraceEventBase & {
1079
+ type: 'tune-out:ack-failed';
1080
+ serverId: string;
1081
+ channelId: string;
1082
+ error: string;
1083
+ }) | (TraceEventBase & {
1084
+ type: 'tune-out:timer-failed';
1085
+ timer: 'wake' | 'cadence' | 'expiry';
1086
+ serverId: string;
1087
+ channelId: string;
1088
+ error: string;
1089
+ }) | (TraceEventBase & {
1090
+ type: 'tune-out:wake-budget-paused';
1091
+ serverId: string;
1092
+ channelId: string;
1093
+ epochId: string;
1094
+ scope: 'all-except';
1095
+ wakeCount: number;
1096
+ maxWakes: number;
1097
+ })
1098
+ /**
1099
+ * A tune-out's cancel asked for while writes were held in memory, queued
1100
+ * for the release and its retry, taken off the queue with what it was for
1101
+ * left undone. `hold-ended`: the hold of the epoch it was asked for
1102
+ * (`epochId`) ended without it, so it ends nothing, and no later hold
1103
+ * there (`currentEpochId`, the one in force when it was dropped, if one
1104
+ * was). `note-undelivered`: its hold ended, by another cancel or by its
1105
+ * own run, and delivering the note it carried failed (`error`).
1106
+ * `stopped`: the host stopped while it waited, its hold still in force,
1107
+ * which the next boot resumes without running it. `superseded`: it was
1108
+ * asked for while an earlier cancel of the same hold ran, and joined that
1109
+ * one when it was queued again, whose note stands.
1110
+ * `noteLost`: it carried a reader's note, which is not delivered, or,
1111
+ * with `noteMayBeStored`, may be stored after all: the store couldn't tell
1112
+ * whether its write landed (`error` says what it couldn't read), as the
1113
+ * author's notice then says it may be lost. Its
1114
+ * author is told so in its own context where the author still exists,
1115
+ * and a reader fork that has ended is not, the loss reaching no one
1116
+ * (`tune-out:note-loss-untold`, `author-gone`). The persistent
1117
+ * subconscious is told by the next boot where the host stopped, and,
1118
+ * where another cancel ended the hold, in that cancel's release, which
1119
+ * its window holds, rather than in a notice of its own. `noteAuthor`, whose note
1120
+ * it was, the name it would have been delivered under (the persistent
1121
+ * subconscious's, or the reader fork's that left it), where one is known.
1122
+ * For the all-except hold (`scope`), the channel is its excepted one.
1123
+ */
1124
+ | (TraceEventBase & {
1125
+ type: 'tune-out:deferred-cancel-dropped';
1126
+ serverId: string;
1127
+ channelId: string;
1128
+ epochId: string;
1129
+ scope?: 'all-except';
1130
+ reason: 'hold-ended' | 'note-undelivered' | 'stopped' | 'superseded';
1131
+ currentEpochId?: string;
1132
+ noteLost: boolean;
1133
+ noteMayBeStored?: true;
1134
+ noteAuthor?: string;
1135
+ error?: string;
1136
+ })
1137
+ /**
1138
+ * At boot, a hold on record (`epochId`; the all-except hold with `scope`,
1139
+ * its channel the excepted one) that the last stop's stamp
1140
+ * (`tune-out/<primary>/stop-stamp`) doesn't cover: the host crashed, or
1141
+ * the store refused the stop's writes. `found`, from that run's rows:
1142
+ * `ran`, a release of that epoch was stored after the cancel was asked,
1143
+ * its end not recorded; `delivered`, a waiting cancel's note was written
1144
+ * to the resident, with no release since; `asked`, the subconscious's
1145
+ * own call of that cancel, answered as waiting, is in its window;
1146
+ * `unknown`, nothing says whether a cancel waited. The persistent
1147
+ * subconscious (`noteAuthor`) is told which, by a loss notice kept and
1148
+ * tried again as the others are (`tune-out:note-loss-untold` where its
1149
+ * write fails). Not traced: a hold no stamp covers because none was ever
1150
+ * written (a first start on a version that stamps its stops), one whose
1151
+ * release already told a waiting note's loss, one whose loss the stop
1152
+ * kept, and one already told as much.
1153
+ */
1154
+ | (TraceEventBase & {
1155
+ type: 'tune-out:stop-unrecorded';
1156
+ serverId: string;
1157
+ channelId: string;
1158
+ epochId: string;
1159
+ scope?: 'all-except';
1160
+ noteAuthor: string;
1161
+ found: 'delivered' | 'ran' | 'asked' | 'unknown';
1162
+ })
1163
+ /**
1164
+ * The notice telling a lost note's author (`noteAuthor`) of the loss (a
1165
+ * `tune-out:deferred-cancel-dropped` with `noteLost`) was not written.
1166
+ * `write-failed`: writing it threw (`error`). It is kept, and tried again
1167
+ * whenever held writes are stored and every 60 s while none are, until it
1168
+ * is written. One for the persistent subconscious is kept in the store
1169
+ * too, so a stop leaves it there and the next boot tries it again; a
1170
+ * reader fork's is dropped at a stop. This traces its first failure only,
1171
+ * a later boot's included, and each later one is logged. `author-gone`:
1172
+ * the framework wrote nothing, as no agent of that name is registered (a
1173
+ * reader fork whose run has ended): the loss reaches no one, and the
1174
+ * notice is not kept. For the all-except hold (`scope`), the channel is
1175
+ * its excepted one.
1176
+ */
1177
+ | (TraceEventBase & {
1178
+ type: 'tune-out:note-loss-untold';
1179
+ serverId: string;
1180
+ channelId: string;
1181
+ epochId: string;
1182
+ scope?: 'all-except';
1183
+ noteAuthor: string;
1184
+ reason: 'write-failed' | 'author-gone';
1185
+ error?: string;
802
1186
  })
803
1187
  /** A reader fork ended in prose without `deliver_summary`; its final prose was delivered as its report. */
804
1188
  | (TraceEventBase & {
@@ -825,10 +1209,8 @@ export type TraceEvent = (TraceEventBase & {
825
1209
  channelId: string;
826
1210
  epochId: string;
827
1211
  trigger: 'cadence' | 'wake' | 'cancel';
828
- /** Held messages the fork was handed, stored and queued. */
1212
+ /** Held messages the fork was handed. */
829
1213
  held: number;
830
- /** Of those, the ones still queued behind the resident's turn. */
831
- queued: number;
832
1214
  })
833
1215
  /**
834
1216
  * A tune-out reader fork threw: its framing, its derive or its run. One
@@ -847,6 +1229,25 @@ export type TraceEvent = (TraceEventBase & {
847
1229
  /** Whether the fork had reported through `deliver_summary` before it failed. */
848
1230
  reported: boolean;
849
1231
  returned: number;
1232
+ })
1233
+ /**
1234
+ * The persistent subconscious's window start was set by index ordinal
1235
+ * (#291): `fixed`, a tune-out's start fixed once no row the subconscious
1236
+ * is owed stored before the start was out of its window, and kept for its
1237
+ * epochs; `clamped`, a kept start (`kept`) past its window's index length
1238
+ * on the store's branch now (one a rollback made shorter), set at the
1239
+ * length instead.
1240
+ */
1241
+ | (TraceEventBase & {
1242
+ type: 'tune-out:subconscious-window';
1243
+ agentName: string;
1244
+ /** The tune-outs that start there. */
1245
+ epochIds: string[];
1246
+ how: 'fixed' | 'clamped';
1247
+ /** The ordinal the window starts at now. */
1248
+ ordinal: number;
1249
+ /** For `clamped`, the ordinal kept for them. */
1250
+ kept?: number;
850
1251
  }) | (TraceEventBase & {
851
1252
  type: 'dendrite:agent-created';
852
1253
  agentName: string;
@@ -891,7 +1292,7 @@ export type TraceEvent = (TraceEventBase & {
891
1292
  by?: string;
892
1293
  reason?: string;
893
1294
  })
894
- /** The message entered the recipient's store (not merely queued for it). */
1295
+ /** The message entered the recipient's store (not merely held for it). */
895
1296
  | (TraceEventBase & {
896
1297
  type: 'dendrite:mail-delivered';
897
1298
  mailId: string;
@@ -899,7 +1300,10 @@ export type TraceEvent = (TraceEventBase & {
899
1300
  from: string;
900
1301
  to: string;
901
1302
  })
902
- /** Queued for the recipient's next boundary; `mail-delivered` follows when it lands. */
1303
+ /** Held in memory behind a live surgery (the operator's switch awaited),
1304
+ * or kept for a recipient whose context manager refuses its work after a
1305
+ * failed re-initialization; `mail-delivered` follows when a release
1306
+ * stores it. */
903
1307
  | (TraceEventBase & {
904
1308
  type: 'dendrite:mail-deferred';
905
1309
  mailId: string;
@@ -927,6 +1331,8 @@ export type TraceEvent = (TraceEventBase & {
927
1331
  messageId: string;
928
1332
  recipients: string[];
929
1333
  held: string | null;
1334
+ /** The suppress rule that took the event, when one did. */
1335
+ suppressed?: string;
930
1336
  wake: boolean;
931
1337
  gatePass: boolean;
932
1338
  })
@@ -940,6 +1346,120 @@ export type TraceEvent = (TraceEventBase & {
940
1346
  /** Envelope kind of the acceptance the observer failed on. */
941
1347
  kind: 'channel' | 'unscoped' | 'surface';
942
1348
  error: string;
1349
+ }) | (TraceEventBase & {
1350
+ /**
1351
+ * Rows entered an agent's window (context-manager's presentRows), at
1352
+ * one of its presentation points (`occasion`): `count` bodies, a
1353
+ * sharded one counted once. At `rebase`, the store's branch moved to a
1354
+ * branch with no window for the agent, and its window there was
1355
+ * written down: `count` is the bodies it holds.
1356
+ */
1357
+ type: 'presentation:presented';
1358
+ agentName: string;
1359
+ occasion: PresentationOccasion;
1360
+ count: number;
1361
+ /** At a tool boundary: the first row that couldn't join the live
1362
+ * stream (a tool block, or a row named as the agent), where the rows
1363
+ * presented there stop. It and the rows after it wait for the turn's
1364
+ * end. */
1365
+ cutAt?: string;
1366
+ /** How many of them carry no audience stamp (stored by a host's
1367
+ * writer that doesn't stamp), presented to the slot's owners and
1368
+ * its observers. */
1369
+ unstamped?: number;
1370
+ }) | (TraceEventBase & {
1371
+ /** An agent's own rows that were stored and not in its window, found
1372
+ * when the agent was taken on or at boot, were presented to it. */
1373
+ type: 'presentation:repaired';
1374
+ agentName: string;
1375
+ count: number;
1376
+ }) | (TraceEventBase & {
1377
+ /**
1378
+ * A row was stamped for agents of which none reads the slot it is
1379
+ * stored in (`deliveredTo`'s), so no window presents it by its
1380
+ * audience. It is stored as named, never widened: observers of the
1381
+ * slot see it only as their edge shows it.
1382
+ */
1383
+ type: 'presentation:unreadable-audience';
1384
+ messageId?: string;
1385
+ audience: string[];
1386
+ slot: MessageSlotRef;
1387
+ deliveredTo: string;
1388
+ }) | (TraceEventBase & {
1389
+ /** A presentation failed; the rows it didn't present stay out of the
1390
+ * agent's window for its next presentation point. At a fresh turn's
1391
+ * start (`turn-start`, `assembly`), the start fails too. With
1392
+ * `legacy`, the agent was left unpresented (legacy mode) until a
1393
+ * later move of the store's branch: its window the whole record as
1394
+ * before the index, or, where its strategy couldn't follow a move to
1395
+ * a branch that holds a window, that window, writes for it waiting in
1396
+ * memory: at `adopt`, its window couldn't be
1397
+ * written down (another version's index format, or a failed write);
1398
+ * at `rebase`, after the store's branch moved, its window couldn't be
1399
+ * written down on the new branch, or its context's strategy couldn't
1400
+ * follow the move (`error` says which). The framework logs that and
1401
+ * raises an ops alert (`presentation-legacy`). Without it, at
1402
+ * `adopt` or `rebase`, presenting the agent's own rows failed, or
1403
+ * taking out the rows the write-down took in that aren't the
1404
+ * agent's did, which is tried again at its next turn start or point
1405
+ * at rest. */
1406
+ type: 'presentation:failed';
1407
+ agentName: string;
1408
+ occasion: PresentationOccasion;
1409
+ error: string;
1410
+ /** The rows the presentation named that didn't enter the window,
1411
+ * each body by the id that names it, where they are known (a write
1412
+ * of the window that failed). Absent where a read failed before the
1413
+ * rows could be named. */
1414
+ messageIds?: string[];
1415
+ /** Set where the failure left the agent in legacy mode. */
1416
+ legacy?: true;
1417
+ }) | (TraceEventBase & {
1418
+ /** At a tool boundary's hand-off, the newest rows of the agent's
1419
+ * window weren't the rows the stream was about to be given, in that
1420
+ * order. The stream's later rounds are noted as unvouched, so their
1421
+ * thinking is left out at the next compile rather than refused. */
1422
+ type: 'presentation:hand-off-mismatch';
1423
+ agentName: string;
1424
+ expected: string[];
1425
+ tail: string[];
1426
+ }) | (TraceEventBase & {
1427
+ /**
1428
+ * Rows were taken out of an agent's window. Every reason but `shed`
1429
+ * and `elsewhere` is a removal from the record made through another
1430
+ * agent's context, which context-manager tombstones in that context's
1431
+ * window only: the rows it removed leave this agent's window too, each
1432
+ * at its own place, so no other row's place moves (`hide`, `suppress` on its
1433
+ * fork, a coalescer's `coalescer`, a module's `module`, a suppression
1434
+ * a start finished, `resume`, and a refusal rewind's shed from a
1435
+ * window that is still the record, `rewind`), or that no live context
1436
+ * heard, found at boot (`boot`). `shed` is a refusal rewind's or an
1437
+ * inference failure's shed on a presented window: the rows leave the
1438
+ * agent's own window as an undone turn's do, and stay in the record.
1439
+ * `elsewhere` is a window written down from the shared record when the
1440
+ * agent was taken on, or after a branch move: the rows it took in that
1441
+ * carry an audience stamp and aren't the agent's (another agent's own
1442
+ * rows, mail stamped for others, a held row) leave it, and stay in the
1443
+ * record (decision 1).
1444
+ */
1445
+ type: 'presentation:retracted';
1446
+ agentName: string;
1447
+ messageIds: string[];
1448
+ reason: PresentationRetractReason;
1449
+ }) | (TraceEventBase & {
1450
+ /** An undo or a redo on the presentation index, counted in bodies.
1451
+ * An undo's `retracted` is the bodies from the turn's checkpoint on
1452
+ * that left the agent's window, the turn's own and what arrived
1453
+ * after it, and it carries no `represented`. A redo's
1454
+ * `retracted` is the rows that entered the window after the undo, and
1455
+ * any of the undo's own still in it after an undo cut short, which
1456
+ * left so the redone rows come back after their prefix; its
1457
+ * `represented` is the undone rows presented again. No branch
1458
+ * moved. */
1459
+ type: 'window:undone';
1460
+ agentName: string;
1461
+ retracted: number;
1462
+ represented?: number;
943
1463
  }) | (TraceEventBase & {
944
1464
  type: 'prose:drafts-held';
945
1465
  agentName: string;
@@ -959,8 +1479,22 @@ export type TraceEvent = (TraceEventBase & {
959
1479
  agentName: string;
960
1480
  draftIds: string[];
961
1481
  });
1482
+ /** Why rows left an agent's window (`presentation:retracted`). */
1483
+ export type PresentationRetractReason = 'hide' | 'suppress' | 'coalescer' | 'module' | 'resume' | 'rewind' | 'shed' | 'boot' | 'elsewhere' | 'unsent-injection';
962
1484
  /**
963
1485
  * Listener for trace events.
964
1486
  */
965
1487
  export type TraceEventListener = (event: TraceEvent) => void;
1488
+ /**
1489
+ * A trace as raised, before `emitTrace` stamps its `timestamp`: one of the
1490
+ * union's members without that field.
1491
+ */
1492
+ export type TraceEventInput = WithoutTimestamp<TraceEvent>;
1493
+ type Fields<Shape> = {
1494
+ [Key in keyof Shape]: Shape[Key];
1495
+ };
1496
+ type WithoutTimestamp<Event> = Event extends unknown ? {
1497
+ [Key in keyof Event as Key extends 'timestamp' ? never : Key]: Event[Key];
1498
+ } : never;
1499
+ export {};
966
1500
  //# sourceMappingURL=trace.d.ts.map