@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,19 +1,25 @@
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
  /**
8
14
  * Base for all trace events.
9
15
  * TraceEvents are observability-only — they NEVER drive logic.
10
16
  */
11
- export interface TraceEventBase {
17
+ export type TraceEventBase = {
12
18
  /** When this trace was emitted */
13
19
  timestamp: number;
14
20
  /** Optional correlation ID for distributed tracing */
15
21
  traceId?: string;
16
- }
22
+ };
17
23
 
18
24
  /**
19
25
  * Observability events emitted by the framework.
@@ -136,6 +142,14 @@ export type TraceEvent =
136
142
  agentName: string;
137
143
  /** The failure's message, bounded as every trace event's `error` is (2,000 characters). */
138
144
  error: string;
145
+ /**
146
+ * The reason the agent's `[inference-failed]` note may give, before the
147
+ * note's own 600-character cut, and bounded as `error` is. Present only
148
+ * when the failure's message holds no provider's text: a progress
149
+ * bound's cut, a stream's abort, or context-manager's refusal of a
150
+ * compile. Absent otherwise, and a note then gives no reason.
151
+ */
152
+ shownReason?: string;
139
153
  /** Whether membrane classified the failure as retryable (observability). */
140
154
  retryable?: boolean;
141
155
  /**
@@ -150,6 +164,55 @@ export type TraceEvent =
150
164
  /** The provider's own error code, when it sent one (at most 128 characters). */
151
165
  providerErrorCode?: string;
152
166
  })
167
+ | (TraceEventBase & {
168
+ /**
169
+ * A start whose compile was refused for budget while compression was
170
+ * pending waits in the agent's budget hold, idle, instead of failing
171
+ * (#304). It follows the refused attempt's `inference:failed`. Once
172
+ * something the refused compile depends on has changed (compression's
173
+ * progress, nothing left pending, a surgery or an undo, the agent's
174
+ * budget or live context settings, or a quiesce's end), the hold ends,
175
+ * the held requests are queued, and its note is stored as the agent's
176
+ * own row, entering its window at once or, while a turn of the agent's
177
+ * is alive, at its next presentation point; a failed write stores
178
+ * none. Their start's own compile is the check: refused again while
179
+ * compression is pending, it waits in a new hold, with a new
180
+ * `inference:held`. `inference:hold_ended` follows each, once. An
181
+ * ephemeral run's start, and one before the framework's `start()`,
182
+ * never waits.
183
+ */
184
+ type: 'inference:held';
185
+ agentName: string;
186
+ /** 'over_budget', or 'context_refusal' when no summary covers a span the compile would drop. */
187
+ errorType: 'over_budget' | 'context_refusal';
188
+ /** The refusal's message, bounded as a trace event's `error` is (2,000 characters). */
189
+ error: string;
190
+ /** The refused compile's budget and size in tokens, when context-manager gave them. */
191
+ budget?: number;
192
+ actual?: number;
193
+ /** When this hold started (epoch ms). A wait held again after its
194
+ * release starts a new hold; its `context-refusal` alert and the note
195
+ * count from the wait's first hold. */
196
+ since: number;
197
+ /** Requests the hold holds as it starts: the refused start's own. */
198
+ heldRequests: number;
199
+ })
200
+ | (TraceEventBase & {
201
+ type: 'inference:hold_ended';
202
+ agentName: string;
203
+ /**
204
+ * 'released': something the refused compile depends on changed, so the
205
+ * held requests were queued and their start's compile is the check.
206
+ * 'stopped': the held turn was ended by `abortInference()`, `stop()` or
207
+ * its agent's end, reported after its `inference:aborted`. 'removed': a
208
+ * surgery or an undo removed what the held turn stood on, reported after
209
+ * its `inference:aborted`, and the wakes that joined it go back to the
210
+ * queue.
211
+ */
212
+ outcome: 'released' | 'stopped' | 'removed';
213
+ /** Since the hold started (`inference:held`'s `since`). */
214
+ waitedMs: number;
215
+ })
153
216
 
154
217
  // Streaming inference lifecycle
155
218
  | (TraceEventBase & {
@@ -174,7 +237,9 @@ export type TraceEvent =
174
237
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
175
238
  * Explicit mode: the channel its typing shows, where the start's wake
176
239
  * came from, or, at a start whose wake names none, such as a budget
177
- * restart, the one the turn already shows. */
240
+ * restart, the one the turn already shows. Disabled mode, and a silent
241
+ * turn in any mode: none, though the turn may show typing, since its
242
+ * text is never sent to a channel. */
178
243
  channelId?: string;
179
244
  })
180
245
  | (TraceEventBase & {
@@ -199,7 +264,9 @@ export type TraceEvent =
199
264
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
200
265
  * Explicit mode: the channel its typing shows, where the start's wake
201
266
  * came from, or, at a start whose wake names none, such as a budget
202
- * restart, the one the turn already shows. */
267
+ * restart, the one the turn already shows. Disabled mode, and a silent
268
+ * turn in any mode: none, though the turn may show typing, since its
269
+ * text is never sent to a channel. */
203
270
  channelId?: string;
204
271
  })
205
272
  | (TraceEventBase & {
@@ -324,6 +391,7 @@ export type TraceEvent =
324
391
  module: string;
325
392
  tool: string;
326
393
  callId: string;
394
+ durationMs?: number;
327
395
  error: string;
328
396
  stack?: string;
329
397
  })
@@ -380,6 +448,10 @@ export type TraceEvent =
380
448
  })
381
449
 
382
450
  // Message lifecycle
451
+ /** A message stored, with its stored id. A write kept in memory first (a
452
+ * live surgery's hold, or the wait for its agent's context manager to be
453
+ * re-initialized) is traced once, as a release stores it, with source
454
+ * `surgery-release`; its arrival isn't traced. */
383
455
  | (TraceEventBase & {
384
456
  type: 'message:added';
385
457
  messageId: string;
@@ -391,6 +463,22 @@ export type TraceEvent =
391
463
  messageId: string;
392
464
  source: string;
393
465
  })
466
+ /** A write kept in memory until a live surgery's release (source
467
+ * `surgery-release`) whose store threw there: none of it was stored, or,
468
+ * with `mayBeStored`, context-manager couldn't tell what of it landed (the
469
+ * first row it names as stored is traced as `message:added`, as a stored
470
+ * write is). `external` is the address the write's metadata gave it, for
471
+ * the module that wrote it
472
+ * (the Discord module ends its record of a create with no row). The
473
+ * agent's writes lost at a release are told of once besides, by an ops
474
+ * alert of kind `store-held-lost`. */
475
+ | (TraceEventBase & {
476
+ type: 'message:lost';
477
+ source: string;
478
+ agentName: string;
479
+ external?: { source: string; id: string };
480
+ mayBeStored?: true;
481
+ })
394
482
  /** A push/event refused at the MCPL boundary: visibly-empty content
395
483
  * (`empty-content`, answered -32602, with no `field` or `detail`), or a
396
484
  * coalesced occurrence the host refused. A refused occurrence's reason
@@ -414,6 +502,13 @@ export type TraceEvent =
414
502
  channelId?: string;
415
503
  detail?: string;
416
504
  })
505
+ | (TraceEventBase & {
506
+ type: 'mcpl:push_event';
507
+ serverId: string;
508
+ eventId: string;
509
+ featureSet: string;
510
+ coalesce?: PushEventResult['coalesce'];
511
+ })
417
512
  /** A channels/incoming message refused at the MCPL boundary: an
418
513
  * unregistered channel (`unknown-channel`, §14.5), visibly-empty content
419
514
  * (`empty-content`), or a coalesced item the host refused
@@ -433,6 +528,71 @@ export type TraceEvent =
433
528
  field?: string;
434
529
  detail?: string;
435
530
  })
531
+ | (TraceEventBase & {
532
+ type: 'mcpl:channels-register';
533
+ serverId: string;
534
+ channelIds: string[];
535
+ count: number;
536
+ })
537
+ | (TraceEventBase & {
538
+ type: 'mcpl:channels-changed';
539
+ serverId: string;
540
+ /** 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. */
541
+ added: string[];
542
+ /** The notification's `removed`, as the server sent it: not validated, so a channel the server names by a number arrives as that number. */
543
+ removed: string[];
544
+ /** As `added`, for the notification's `updated`. */
545
+ updated: string[];
546
+ })
547
+ | (TraceEventBase & {
548
+ type: 'mcpl:channels-incoming';
549
+ serverId: string;
550
+ messageCount: number;
551
+ /** 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. */
552
+ channelIds: string[];
553
+ })
554
+ | (TraceEventBase & {
555
+ type: 'mcpl:channel-descriptor-rejected';
556
+ serverId: string;
557
+ channelId?: string;
558
+ reason: string;
559
+ })
560
+ | (TraceEventBase & {
561
+ type: 'mcpl:channel-lazy-registered';
562
+ serverId: string;
563
+ channelId: string;
564
+ label: string;
565
+ })
566
+ | (TraceEventBase & {
567
+ type: 'mcpl:channel-opened-by-send';
568
+ serverId: string;
569
+ channelId: string;
570
+ })
571
+ | (TraceEventBase & {
572
+ type: 'mcpl:channel-open-failed';
573
+ serverId: string;
574
+ channelId: string;
575
+ error: string;
576
+ })
577
+ | (TraceEventBase & {
578
+ type: 'mcpl:channel-open-substituted';
579
+ serverId: string;
580
+ channelId: string;
581
+ answeredFor: string;
582
+ })
583
+ | (TraceEventBase & {
584
+ type: 'mcpl:channel-reconcile-failed';
585
+ serverId: string;
586
+ channelId: string;
587
+ desired?: DesiredChannelState;
588
+ attempts?: number;
589
+ error: string;
590
+ })
591
+ | (TraceEventBase & {
592
+ type: 'mcpl:channel-reconcile-skipped';
593
+ serverId: string;
594
+ reason: string;
595
+ })
436
596
  /** MCPL content that context-manager won't store, because it doesn't
437
597
  * match ContentBlock, reached the store/wake site and was refused there:
438
598
  * no row, no wake. `places` is malformedContentPlaces' answer for it. */
@@ -455,20 +615,30 @@ export type TraceEvent =
455
615
  channelId?: string;
456
616
  messageId?: string;
457
617
  })
458
- /** RFC-006 coalescing decision record (received / displaced / removed /
459
- * rendered / revoked / render-cancelled / late-render / render-failed).
618
+ /** RFC-006 coalescing decision record, by `kind`.
460
619
  * A late-render whose push/render had already timed out, its fallback
461
620
  * materialized, is recorded by the connection's wiring rather than the
462
621
  * coalescer: it names `serverId`, `featureSet`, `key` and, for a
463
622
  * channel-scoped subject, `channelId` instead of `subject`, carries a late
464
623
  * JSON-RPC error as `error` (`[code] message`, bounded), and its `eventId`
465
624
  * links it to the batch's render-failed. */
625
+ | (TraceEventBase & { type: 'mcpl:coalescing' } & CoalescingAudit)
466
626
  | (TraceEventBase & {
467
627
  type: 'mcpl:coalescing';
468
- kind: string;
469
- subject?: string;
628
+ kind: 'late-render';
629
+ serverId: string;
470
630
  eventId?: string;
471
- [key: string]: unknown;
631
+ featureSet?: string;
632
+ key?: string;
633
+ channelId?: string;
634
+ discarded: true;
635
+ error?: string;
636
+ })
637
+ | (TraceEventBase & {
638
+ type: 'mcpl:coalescing';
639
+ kind: 'turn-withdrawn';
640
+ agentName: string;
641
+ subjects: string[];
472
642
  })
473
643
 
474
644
  // EventGate lifecycle
@@ -512,9 +682,8 @@ export type TraceEvent =
512
682
  * gate hands the line to the wake when its message is the newest at
513
683
  * the fire, EventGate isNewestEntry, and the turn's start decides).
514
684
  * `reason`: `newest`, on the delivery agent's start the message was
515
- * still the newest entry in the window; `held`, the host was quiesced
516
- * or another reader of the residents' shared slot had a turn alive,
517
- * so no line could be written then. */
685
+ * still the newest entry in the window; `held`, the host was
686
+ * quiesced, so no line could be written then. */
518
687
  type: 'gate:wake-line-omitted';
519
688
  reason: 'newest' | 'held';
520
689
  policyNames: string[];
@@ -525,6 +694,8 @@ export type TraceEvent =
525
694
  type: 'gate:config-reloaded';
526
695
  configPath: string;
527
696
  policyCount: number;
697
+ removedPolicies?: string[];
698
+ stateClearedPolicies?: string[];
528
699
  })
529
700
  | (TraceEventBase & {
530
701
  type: 'gate:decision';
@@ -534,30 +705,69 @@ export type TraceEvent =
534
705
  matchedPolicy: string | null;
535
706
  trigger: boolean;
536
707
  behavior: string;
708
+ observed?: string[];
537
709
  })
538
-
539
- // Usage lifecycle
710
+ /** A periodic review of what suppress rules hid ran (gate/suppression-review.ts); `delivered` when the agent was told. */
540
711
  | (TraceEventBase & {
541
- type: 'usage:updated';
542
- totals: SessionUsage;
712
+ type: 'gate:suppression-review';
543
713
  agentName: string;
544
- inferenceCount: number;
714
+ fromMs: number;
715
+ toMs: number;
716
+ total: number;
717
+ flagged: number;
718
+ delivered: boolean;
719
+ rules: Array<{ rule: string; suppressed: number; read: number; verdict: 'fits' | 'flagged' | 'error' | 'unjudged'; flagged: number }>;
545
720
  })
546
-
547
- // Undo/redo lifecycle
721
+ /** A suppress rule took an event: its row is stored and never rendered (EventGate.noteSuppressed). */
548
722
  | (TraceEventBase & {
549
- type: 'undo:completed';
550
- agentName: string;
551
- turnIndex: number;
552
- fromBranch: string;
553
- toBranch: string;
723
+ type: 'gate:suppressed';
724
+ policyName: string;
725
+ eventType: string;
726
+ serverId?: string;
727
+ channelId?: string;
728
+ })
729
+ | (TraceEventBase & Fields<RecipeChanges> & {
730
+ type: 'gate:config-reconciled';
731
+ configPath: string;
732
+ addedPolicies: string[];
554
733
  })
555
734
  | (TraceEventBase & {
556
- type: 'redo:completed';
557
- agentName: string;
558
- fromBranch: string;
559
- toBranch: string;
735
+ type: 'gate:policy-added';
736
+ configPath: string;
737
+ policyName: string;
738
+ replaced: boolean;
739
+ })
740
+ | (TraceEventBase & {
741
+ type: 'gate:policy-removed';
742
+ configPath: string;
743
+ policyName: string;
744
+ })
745
+ | (TraceEventBase & {
746
+ type: 'gate:shadow-warnings';
747
+ reason: string;
748
+ warnings: string[];
560
749
  })
750
+ /** Wake onboarding offered a server's suggestions after an undecided event
751
+ * (gate/wake-onboarding.ts): `policy` let it go by (null: the default). */
752
+ | (TraceEventBase & {
753
+ type: 'gate:onboarding-offered';
754
+ serverId: string;
755
+ digest: string;
756
+ policy: string | null;
757
+ rules: number;
758
+ wake: boolean;
759
+ })
760
+ /** The agent answered an offer: rules accepted (the names written), or declined. */
761
+ | (TraceEventBase & {
762
+ type: 'gate:onboarding-decided';
763
+ serverId: string;
764
+ digest: string;
765
+ state: 'accepted' | 'declined';
766
+ rules: string[];
767
+ })
768
+
769
+ // Usage lifecycle
770
+ | (TraceEventBase & Fields<UsageUpdatedEvent>)
561
771
 
562
772
  // Operator-initiated mutation (rollback/suppress/undo/hide/settings/quiesce…).
563
773
  // Mirrors the durable operator-actions.jsonl record so live UIs see the
@@ -683,10 +893,6 @@ export type TraceEvent =
683
893
  toolUseId: string;
684
894
  isError: boolean;
685
895
  durationMs: number;
686
- /** The pair was queued behind a turn that replaced the puppet's
687
- * reservation (provider-admission re-entry) instead of stored
688
- * directly; it lands at that turn's end flush. */
689
- deferred?: boolean;
690
896
  })
691
897
 
692
898
  // MCPL server connection lifecycle (spawn / handshake / reconnect health).
@@ -773,6 +979,51 @@ export type TraceEvent =
773
979
  /** missing_capabilities: the capability paths the grant lacks. */
774
980
  missing?: string[];
775
981
  })
982
+ | (TraceEventBase & {
983
+ type: 'mcpl:inference_start';
984
+ serverId: string;
985
+ featureSet: string;
986
+ model: string;
987
+ stream: boolean;
988
+ })
989
+ | (TraceEventBase & {
990
+ type: 'mcpl:inference_complete';
991
+ serverId: string;
992
+ model: string;
993
+ actualModel?: string;
994
+ inputTokens: number;
995
+ outputTokens: number;
996
+ streamed: boolean;
997
+ })
998
+ | (TraceEventBase & {
999
+ type: 'mcpl:inference_fail';
1000
+ serverId: string;
1001
+ model: string | null;
1002
+ error: string;
1003
+ streamed: boolean;
1004
+ })
1005
+ | (TraceEventBase & {
1006
+ type: 'mcpl:state_registered';
1007
+ serverId: string;
1008
+ featureSet: string;
1009
+ hostState: boolean;
1010
+ rollback: boolean;
1011
+ })
1012
+ | (TraceEventBase & {
1013
+ type: 'mcpl:checkpoint_recorded';
1014
+ serverId: string;
1015
+ featureSet: string;
1016
+ checkpoint: string;
1017
+ parent: string | null;
1018
+ hasData: boolean;
1019
+ hasPatch: boolean;
1020
+ })
1021
+ | (TraceEventBase & {
1022
+ type: 'mcpl:state_rollback';
1023
+ serverId: string;
1024
+ featureSet: string;
1025
+ checkpoint: string;
1026
+ })
776
1027
  | (TraceEventBase & {
777
1028
  /** An operator tool-name pattern matches no model-facing tool. Emitted
778
1029
  * once per pattern, after the servers it could name have listed. */
@@ -849,14 +1100,19 @@ export type TraceEvent =
849
1100
  // this stream, not a separate system. See connectome docs/observability.md.
850
1101
  | (TraceEventBase & {
851
1102
  type: 'ops:alert';
852
- /** Alert kind — open set: 'refusal' | 'hard-down' | 'mcpl-down' | … */
1103
+ /** Alert kind — open set: 'refusal' | 'hard-down' | 'mcpl-down' | …
1104
+ * A kind ending in `-clear` ends the alert of the kind before it:
1105
+ * 'context-refusal-clear' is raised when a budget hold whose wait
1106
+ * raised 'context-refusal' ends with its turn stopped or removed, so
1107
+ * the waiting start doesn't run. */
853
1108
  kind: string;
854
1109
  /** Agent name, or a server/component id for non-agent alerts (e.g. mcpl-down). */
855
1110
  agentName: string;
856
1111
  /** At most 2,000 characters. */
857
1112
  message: string;
858
- /** Kind-specific structured payload (mirrors the failures.log record),
859
- * bounded field by field as that record is. */
1113
+ /** Kind-specific structured payload (mirrors the failures.log record,
1114
+ * where the alert writes one: a budget hold's 'context-refusal' and its
1115
+ * clear write none), bounded field by field as that record is. */
860
1116
  data?: Record<string, unknown>;
861
1117
  })
862
1118
 
@@ -888,6 +1144,151 @@ export type TraceEvent =
888
1144
  since?: number;
889
1145
  })
890
1146
 
1147
+ | (TraceEventBase & {
1148
+ type: 'tune-out:entered';
1149
+ serverId: string;
1150
+ channelId: string;
1151
+ epochId: string;
1152
+ scope?: 'all-except';
1153
+ reader: boolean;
1154
+ expiresAtMs?: number;
1155
+ })
1156
+ | (TraceEventBase & {
1157
+ type: 'tune-out:cancelled';
1158
+ serverId: string;
1159
+ channelId: string;
1160
+ epochId: string;
1161
+ scope?: 'all-except';
1162
+ reason: string;
1163
+ wakeCount: number;
1164
+ })
1165
+ | (TraceEventBase & {
1166
+ type: 'tune-out:announced';
1167
+ serverId: string;
1168
+ channelId: string;
1169
+ epochId: string;
1170
+ kind: 'entered' | 'released';
1171
+ })
1172
+ | (TraceEventBase & {
1173
+ type: 'tune-out:announce-failed';
1174
+ serverId: string;
1175
+ channelId: string;
1176
+ epochId: string;
1177
+ kind: 'entered' | 'released';
1178
+ error: string;
1179
+ })
1180
+ | (TraceEventBase & {
1181
+ type: 'tune-out:ack-failed';
1182
+ serverId: string;
1183
+ channelId: string;
1184
+ error: string;
1185
+ })
1186
+ | (TraceEventBase & {
1187
+ type: 'tune-out:timer-failed';
1188
+ timer: 'wake' | 'cadence' | 'expiry';
1189
+ serverId: string;
1190
+ channelId: string;
1191
+ error: string;
1192
+ })
1193
+ | (TraceEventBase & {
1194
+ type: 'tune-out:wake-budget-paused';
1195
+ serverId: string;
1196
+ channelId: string;
1197
+ epochId: string;
1198
+ scope: 'all-except';
1199
+ wakeCount: number;
1200
+ maxWakes: number;
1201
+ })
1202
+ /**
1203
+ * A tune-out's cancel asked for while writes were held in memory, queued
1204
+ * for the release and its retry, taken off the queue with what it was for
1205
+ * left undone. `hold-ended`: the hold of the epoch it was asked for
1206
+ * (`epochId`) ended without it, so it ends nothing, and no later hold
1207
+ * there (`currentEpochId`, the one in force when it was dropped, if one
1208
+ * was). `note-undelivered`: its hold ended, by another cancel or by its
1209
+ * own run, and delivering the note it carried failed (`error`).
1210
+ * `stopped`: the host stopped while it waited, its hold still in force,
1211
+ * which the next boot resumes without running it. `superseded`: it was
1212
+ * asked for while an earlier cancel of the same hold ran, and joined that
1213
+ * one when it was queued again, whose note stands.
1214
+ * `noteLost`: it carried a reader's note, which is not delivered, or,
1215
+ * with `noteMayBeStored`, may be stored after all: the store couldn't tell
1216
+ * whether its write landed (`error` says what it couldn't read), as the
1217
+ * author's notice then says it may be lost. Its
1218
+ * author is told so in its own context where the author still exists,
1219
+ * and a reader fork that has ended is not, the loss reaching no one
1220
+ * (`tune-out:note-loss-untold`, `author-gone`). The persistent
1221
+ * subconscious is told by the next boot where the host stopped, and,
1222
+ * where another cancel ended the hold, in that cancel's release, which
1223
+ * its window holds, rather than in a notice of its own. `noteAuthor`, whose note
1224
+ * it was, the name it would have been delivered under (the persistent
1225
+ * subconscious's, or the reader fork's that left it), where one is known.
1226
+ * For the all-except hold (`scope`), the channel is its excepted one.
1227
+ */
1228
+ | (TraceEventBase & {
1229
+ type: 'tune-out:deferred-cancel-dropped';
1230
+ serverId: string;
1231
+ channelId: string;
1232
+ epochId: string;
1233
+ scope?: 'all-except';
1234
+ reason: 'hold-ended' | 'note-undelivered' | 'stopped' | 'superseded';
1235
+ currentEpochId?: string;
1236
+ noteLost: boolean;
1237
+ noteMayBeStored?: true;
1238
+ noteAuthor?: string;
1239
+ error?: string;
1240
+ })
1241
+ /**
1242
+ * At boot, a hold on record (`epochId`; the all-except hold with `scope`,
1243
+ * its channel the excepted one) that the last stop's stamp
1244
+ * (`tune-out/<primary>/stop-stamp`) doesn't cover: the host crashed, or
1245
+ * the store refused the stop's writes. `found`, from that run's rows:
1246
+ * `ran`, a release of that epoch was stored after the cancel was asked,
1247
+ * its end not recorded; `delivered`, a waiting cancel's note was written
1248
+ * to the resident, with no release since; `asked`, the subconscious's
1249
+ * own call of that cancel, answered as waiting, is in its window;
1250
+ * `unknown`, nothing says whether a cancel waited. The persistent
1251
+ * subconscious (`noteAuthor`) is told which, by a loss notice kept and
1252
+ * tried again as the others are (`tune-out:note-loss-untold` where its
1253
+ * write fails). Not traced: a hold no stamp covers because none was ever
1254
+ * written (a first start on a version that stamps its stops), one whose
1255
+ * release already told a waiting note's loss, one whose loss the stop
1256
+ * kept, and one already told as much.
1257
+ */
1258
+ | (TraceEventBase & {
1259
+ type: 'tune-out:stop-unrecorded';
1260
+ serverId: string;
1261
+ channelId: string;
1262
+ epochId: string;
1263
+ scope?: 'all-except';
1264
+ noteAuthor: string;
1265
+ found: 'delivered' | 'ran' | 'asked' | 'unknown';
1266
+ })
1267
+ /**
1268
+ * The notice telling a lost note's author (`noteAuthor`) of the loss (a
1269
+ * `tune-out:deferred-cancel-dropped` with `noteLost`) was not written.
1270
+ * `write-failed`: writing it threw (`error`). It is kept, and tried again
1271
+ * whenever held writes are stored and every 60 s while none are, until it
1272
+ * is written. One for the persistent subconscious is kept in the store
1273
+ * too, so a stop leaves it there and the next boot tries it again; a
1274
+ * reader fork's is dropped at a stop. This traces its first failure only,
1275
+ * a later boot's included, and each later one is logged. `author-gone`:
1276
+ * the framework wrote nothing, as no agent of that name is registered (a
1277
+ * reader fork whose run has ended): the loss reaches no one, and the
1278
+ * notice is not kept. For the all-except hold (`scope`), the channel is
1279
+ * its excepted one.
1280
+ */
1281
+ | (TraceEventBase & {
1282
+ type: 'tune-out:note-loss-untold';
1283
+ serverId: string;
1284
+ channelId: string;
1285
+ epochId: string;
1286
+ scope?: 'all-except';
1287
+ noteAuthor: string;
1288
+ reason: 'write-failed' | 'author-gone';
1289
+ error?: string;
1290
+ })
1291
+
891
1292
  /** A reader fork ended in prose without `deliver_summary`; its final prose was delivered as its report. */
892
1293
  | (TraceEventBase & {
893
1294
  type: 'tune-out:reader-prose-delivered';
@@ -915,10 +1316,8 @@ export type TraceEvent =
915
1316
  channelId: string;
916
1317
  epochId: string;
917
1318
  trigger: 'cadence' | 'wake' | 'cancel';
918
- /** Held messages the fork was handed, stored and queued. */
1319
+ /** Held messages the fork was handed. */
919
1320
  held: number;
920
- /** Of those, the ones still queued behind the resident's turn. */
921
- queued: number;
922
1321
  })
923
1322
 
924
1323
  /**
@@ -940,9 +1339,30 @@ export type TraceEvent =
940
1339
  returned: number;
941
1340
  })
942
1341
 
1342
+ /**
1343
+ * The persistent subconscious's window start was set by index ordinal
1344
+ * (#291): `fixed`, a tune-out's start fixed once no row the subconscious
1345
+ * is owed stored before the start was out of its window, and kept for its
1346
+ * epochs; `clamped`, a kept start (`kept`) past its window's index length
1347
+ * on the store's branch now (one a rollback made shorter), set at the
1348
+ * length instead.
1349
+ */
1350
+ | (TraceEventBase & {
1351
+ type: 'tune-out:subconscious-window';
1352
+ agentName: string;
1353
+ /** The tune-outs that start there. */
1354
+ epochIds: string[];
1355
+ how: 'fixed' | 'clamped';
1356
+ /** The ordinal the window starts at now. */
1357
+ ordinal: number;
1358
+ /** For `clamped`, the ordinal kept for them. */
1359
+ kept?: number;
1360
+ })
1361
+
943
1362
  // Dendrite: agent registry and lifecycle.
944
- // `agent-created` is the consent event: it names the kind of agent, what
945
- // ends it, and what happens to it when its spawner ends.
1363
+ // `agent-created` is the creation event: it names the kind of agent, what
1364
+ // ends it, and what happens to it when its spawner ends, for whatever a
1365
+ // host records or decides on them.
946
1366
  | (TraceEventBase & {
947
1367
  type: 'dendrite:agent-created';
948
1368
  agentName: string;
@@ -992,7 +1412,7 @@ export type TraceEvent =
992
1412
  by?: string;
993
1413
  reason?: string;
994
1414
  })
995
- /** The message entered the recipient's store (not merely queued for it). */
1415
+ /** The message entered the recipient's store (not merely held for it). */
996
1416
  | (TraceEventBase & {
997
1417
  type: 'dendrite:mail-delivered';
998
1418
  mailId: string;
@@ -1000,7 +1420,10 @@ export type TraceEvent =
1000
1420
  from: string;
1001
1421
  to: string;
1002
1422
  })
1003
- /** Queued for the recipient's next boundary; `mail-delivered` follows when it lands. */
1423
+ /** Held in memory behind a live surgery (the operator's switch awaited),
1424
+ * or kept for a recipient whose context manager refuses its work after a
1425
+ * failed re-initialization; `mail-delivered` follows when a release
1426
+ * stores it. */
1004
1427
  | (TraceEventBase & {
1005
1428
  type: 'dendrite:mail-deferred';
1006
1429
  mailId: string;
@@ -1029,6 +1452,8 @@ export type TraceEvent =
1029
1452
  messageId: string;
1030
1453
  recipients: string[];
1031
1454
  held: string | null;
1455
+ /** The suppress rule that took the event, when one did. */
1456
+ suppressed?: string;
1032
1457
  wake: boolean;
1033
1458
  gatePass: boolean;
1034
1459
  })
@@ -1048,6 +1473,130 @@ export type TraceEvent =
1048
1473
  error: string;
1049
1474
  })
1050
1475
 
1476
+ // The presentation index (#291, src/presentation.ts): which stored rows
1477
+ // each agent's window holds, in the order its requests carried them.
1478
+ | (TraceEventBase & {
1479
+ /**
1480
+ * Rows entered an agent's window (context-manager's presentRows), at
1481
+ * one of its presentation points (`occasion`): `count` bodies, a
1482
+ * sharded one counted once. At `rebase`, the store's branch moved to a
1483
+ * branch with no window for the agent, and its window there was
1484
+ * written down: `count` is the bodies it holds.
1485
+ */
1486
+ type: 'presentation:presented';
1487
+ agentName: string;
1488
+ occasion: PresentationOccasion;
1489
+ count: number;
1490
+ /** At a tool boundary: the first row that couldn't join the live
1491
+ * stream (a tool block, or a row named as the agent), where the rows
1492
+ * presented there stop. It and the rows after it wait for the turn's
1493
+ * end. */
1494
+ cutAt?: string;
1495
+ /** How many of them carry no audience stamp (stored by a host's
1496
+ * writer that doesn't stamp), presented to the slot's owners and
1497
+ * its observers. */
1498
+ unstamped?: number;
1499
+ })
1500
+ | (TraceEventBase & {
1501
+ /** An agent's own rows that were stored and not in its window, found
1502
+ * when the agent was taken on or at boot, were presented to it. */
1503
+ type: 'presentation:repaired';
1504
+ agentName: string;
1505
+ count: number;
1506
+ })
1507
+ | (TraceEventBase & {
1508
+ /**
1509
+ * A row was stamped for agents of which none reads the slot it is
1510
+ * stored in (`deliveredTo`'s), so no window presents it by its
1511
+ * audience. It is stored as named, never widened: observers of the
1512
+ * slot see it only as their edge shows it.
1513
+ */
1514
+ type: 'presentation:unreadable-audience';
1515
+ messageId?: string;
1516
+ audience: string[];
1517
+ slot: MessageSlotRef;
1518
+ deliveredTo: string;
1519
+ })
1520
+ | (TraceEventBase & {
1521
+ /** A presentation failed; the rows it didn't present stay out of the
1522
+ * agent's window for its next presentation point. At a fresh turn's
1523
+ * start (`turn-start`, `assembly`), the start fails too. With
1524
+ * `legacy`, the agent was left unpresented (legacy mode) until a
1525
+ * later move of the store's branch: its window the whole record as
1526
+ * before the index, or, where its strategy couldn't follow a move to
1527
+ * a branch that holds a window, that window, writes for it waiting in
1528
+ * memory: at `adopt`, its window couldn't be
1529
+ * written down (another version's index format, or a failed write);
1530
+ * at `rebase`, after the store's branch moved, its window couldn't be
1531
+ * written down on the new branch, or its context's strategy couldn't
1532
+ * follow the move (`error` says which). The framework logs that and
1533
+ * raises an ops alert (`presentation-legacy`). Without it, at
1534
+ * `adopt` or `rebase`, presenting the agent's own rows failed, or
1535
+ * taking out the rows the write-down took in that aren't the
1536
+ * agent's did, which is tried again at its next turn start or point
1537
+ * at rest. */
1538
+ type: 'presentation:failed';
1539
+ agentName: string;
1540
+ occasion: PresentationOccasion;
1541
+ error: string;
1542
+ /** The rows the presentation named that didn't enter the window,
1543
+ * each body by the id that names it, where they are known (a write
1544
+ * of the window that failed). Absent where a read failed before the
1545
+ * rows could be named. */
1546
+ messageIds?: string[];
1547
+ /** Set where the failure left the agent in legacy mode. */
1548
+ legacy?: true;
1549
+ })
1550
+ | (TraceEventBase & {
1551
+ /** At a tool boundary's hand-off, the newest rows of the agent's
1552
+ * window weren't the rows the stream was about to be given, in that
1553
+ * order. The stream's later rounds are noted as unvouched, so their
1554
+ * thinking is left out at the next compile rather than refused. */
1555
+ type: 'presentation:hand-off-mismatch';
1556
+ agentName: string;
1557
+ expected: string[];
1558
+ tail: string[];
1559
+ })
1560
+ | (TraceEventBase & {
1561
+ /**
1562
+ * Rows were taken out of an agent's window. Every reason but `shed`
1563
+ * and `elsewhere` is a removal from the record made through another
1564
+ * agent's context, which context-manager tombstones in that context's
1565
+ * window only: the rows it removed leave this agent's window too, each
1566
+ * at its own place, so no other row's place moves (`hide`, `suppress` on its
1567
+ * fork, a coalescer's `coalescer`, a module's `module`, a suppression
1568
+ * a start finished, `resume`, and a refusal rewind's shed from a
1569
+ * window that is still the record, `rewind`), or that no live context
1570
+ * heard, found at boot (`boot`). `shed` is a refusal rewind's or an
1571
+ * inference failure's shed on a presented window: the rows leave the
1572
+ * agent's own window as an undone turn's do, and stay in the record.
1573
+ * `elsewhere` is a window written down from the shared record when the
1574
+ * agent was taken on, or after a branch move: the rows it took in that
1575
+ * carry an audience stamp and aren't the agent's (another agent's own
1576
+ * rows, mail stamped for others, a held row) leave it, and stay in the
1577
+ * record (decision 1).
1578
+ */
1579
+ type: 'presentation:retracted';
1580
+ agentName: string;
1581
+ messageIds: string[];
1582
+ reason: PresentationRetractReason;
1583
+ })
1584
+ | (TraceEventBase & {
1585
+ /** An undo or a redo on the presentation index, counted in bodies.
1586
+ * An undo's `retracted` is the bodies from the turn's checkpoint on
1587
+ * that left the agent's window, the turn's own and what arrived
1588
+ * after it, and it carries no `represented`. A redo's
1589
+ * `retracted` is the rows that entered the window after the undo, and
1590
+ * any of the undo's own still in it after an undo cut short, which
1591
+ * left so the redone rows come back after their prefix; its
1592
+ * `represented` is the undone rows presented again. No branch
1593
+ * moved. */
1594
+ type: 'window:undone';
1595
+ agentName: string;
1596
+ retracted: number;
1597
+ represented?: number;
1598
+ })
1599
+
1051
1600
  // Held prose drafts (src/prose-drafts.ts): plain speech kept privately
1052
1601
  // instead of sent; a resident's explicit resend; a deliberate dismissal.
1053
1602
  | (TraceEventBase & {
@@ -1072,7 +1621,22 @@ export type TraceEvent =
1072
1621
  draftIds: string[];
1073
1622
  });
1074
1623
 
1624
+ /** Why rows left an agent's window (`presentation:retracted`). */
1625
+ export type PresentationRetractReason = 'hide' | 'suppress' | 'coalescer' | 'module' | 'resume' | 'rewind' | 'shed' | 'boot' | 'elsewhere' | 'unsent-injection';
1626
+
1075
1627
  /**
1076
1628
  * Listener for trace events.
1077
1629
  */
1078
1630
  export type TraceEventListener = (event: TraceEvent) => void;
1631
+
1632
+ /**
1633
+ * A trace as raised, before `emitTrace` stamps its `timestamp`: one of the
1634
+ * union's members without that field.
1635
+ */
1636
+ export type TraceEventInput = WithoutTimestamp<TraceEvent>;
1637
+
1638
+ type Fields<Shape> = { [Key in keyof Shape]: Shape[Key] };
1639
+
1640
+ type WithoutTimestamp<Event> = Event extends unknown
1641
+ ? { [Key in keyof Event as Key extends 'timestamp' ? never : Key]: Event[Key] }
1642
+ : never;