@animalabs/agent-framework 0.32.0 → 0.33.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 (288) hide show
  1. package/README.md +204 -14
  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 +185 -78
  7. package/dist/src/agent.d.ts.map +1 -1
  8. package/dist/src/agent.js +279 -102
  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/code-execution/isolate/scripts.d.ts +12 -8
  17. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
  18. package/dist/src/code-execution/isolate/scripts.js +24 -0
  19. package/dist/src/code-execution/isolate/scripts.js.map +1 -1
  20. package/dist/src/config-checks.d.ts +7 -0
  21. package/dist/src/config-checks.d.ts.map +1 -1
  22. package/dist/src/config-checks.js +14 -0
  23. package/dist/src/config-checks.js.map +1 -1
  24. package/dist/src/context-manager-errors.d.ts +25 -0
  25. package/dist/src/context-manager-errors.d.ts.map +1 -0
  26. package/dist/src/context-manager-errors.js +31 -0
  27. package/dist/src/context-manager-errors.js.map +1 -0
  28. package/dist/src/context-options.d.ts +67 -0
  29. package/dist/src/context-options.d.ts.map +1 -0
  30. package/dist/src/context-options.js +85 -0
  31. package/dist/src/context-options.js.map +1 -0
  32. package/dist/src/deferred-import.d.ts +93 -0
  33. package/dist/src/deferred-import.d.ts.map +1 -0
  34. package/dist/src/deferred-import.js +177 -0
  35. package/dist/src/deferred-import.js.map +1 -0
  36. package/dist/src/dendrite/audience.d.ts +223 -0
  37. package/dist/src/dendrite/audience.d.ts.map +1 -0
  38. package/dist/src/dendrite/audience.js +202 -0
  39. package/dist/src/dendrite/audience.js.map +1 -0
  40. package/dist/src/dendrite/index.d.ts +5 -3
  41. package/dist/src/dendrite/index.d.ts.map +1 -1
  42. package/dist/src/dendrite/index.js +2 -1
  43. package/dist/src/dendrite/index.js.map +1 -1
  44. package/dist/src/dendrite/presets.d.ts +10 -5
  45. package/dist/src/dendrite/presets.d.ts.map +1 -1
  46. package/dist/src/dendrite/presets.js +17 -5
  47. package/dist/src/dendrite/presets.js.map +1 -1
  48. package/dist/src/dendrite/registry.d.ts +62 -7
  49. package/dist/src/dendrite/registry.d.ts.map +1 -1
  50. package/dist/src/dendrite/registry.js +179 -10
  51. package/dist/src/dendrite/registry.js.map +1 -1
  52. package/dist/src/dendrite/types.d.ts +91 -8
  53. package/dist/src/dendrite/types.d.ts.map +1 -1
  54. package/dist/src/foreign-rounds.d.ts +69 -0
  55. package/dist/src/foreign-rounds.d.ts.map +1 -0
  56. package/dist/src/foreign-rounds.js +152 -0
  57. package/dist/src/foreign-rounds.js.map +1 -0
  58. package/dist/src/framework.d.ts +1976 -818
  59. package/dist/src/framework.d.ts.map +1 -1
  60. package/dist/src/framework.js +7566 -3422
  61. package/dist/src/framework.js.map +1 -1
  62. package/dist/src/gate/event-gate.d.ts +85 -15
  63. package/dist/src/gate/event-gate.d.ts.map +1 -1
  64. package/dist/src/gate/event-gate.js +421 -47
  65. package/dist/src/gate/event-gate.js.map +1 -1
  66. package/dist/src/gate/index.d.ts +1 -1
  67. package/dist/src/gate/index.d.ts.map +1 -1
  68. package/dist/src/gate/index.js.map +1 -1
  69. package/dist/src/gate/rule-scope.d.ts +30 -0
  70. package/dist/src/gate/rule-scope.d.ts.map +1 -0
  71. package/dist/src/gate/rule-scope.js +41 -0
  72. package/dist/src/gate/rule-scope.js.map +1 -0
  73. package/dist/src/gate/suppress-script-worker.d.ts +2 -0
  74. package/dist/src/gate/suppress-script-worker.d.ts.map +1 -0
  75. package/dist/src/gate/suppress-script-worker.js +103 -0
  76. package/dist/src/gate/suppress-script-worker.js.map +1 -0
  77. package/dist/src/gate/suppress-scripts.d.ts +105 -0
  78. package/dist/src/gate/suppress-scripts.d.ts.map +1 -0
  79. package/dist/src/gate/suppress-scripts.js +403 -0
  80. package/dist/src/gate/suppress-scripts.js.map +1 -0
  81. package/dist/src/gate/suppression-review.d.ts +143 -0
  82. package/dist/src/gate/suppression-review.d.ts.map +1 -0
  83. package/dist/src/gate/suppression-review.js +463 -0
  84. package/dist/src/gate/suppression-review.js.map +1 -0
  85. package/dist/src/gate/suppression-stats.d.ts +125 -0
  86. package/dist/src/gate/suppression-stats.d.ts.map +1 -0
  87. package/dist/src/gate/suppression-stats.js +214 -0
  88. package/dist/src/gate/suppression-stats.js.map +1 -0
  89. package/dist/src/gate/types.d.ts +135 -7
  90. package/dist/src/gate/types.d.ts.map +1 -1
  91. package/dist/src/gate/wake-onboarding.d.ts +119 -0
  92. package/dist/src/gate/wake-onboarding.d.ts.map +1 -0
  93. package/dist/src/gate/wake-onboarding.js +277 -0
  94. package/dist/src/gate/wake-onboarding.js.map +1 -0
  95. package/dist/src/held-writes.d.ts +31 -23
  96. package/dist/src/held-writes.d.ts.map +1 -1
  97. package/dist/src/held-writes.js +44 -59
  98. package/dist/src/held-writes.js.map +1 -1
  99. package/dist/src/index.d.ts +5 -2
  100. package/dist/src/index.d.ts.map +1 -1
  101. package/dist/src/index.js +3 -0
  102. package/dist/src/index.js.map +1 -1
  103. package/dist/src/jsonrpc-envelope.d.ts +69 -0
  104. package/dist/src/jsonrpc-envelope.d.ts.map +1 -0
  105. package/dist/src/jsonrpc-envelope.js +66 -0
  106. package/dist/src/jsonrpc-envelope.js.map +1 -0
  107. package/dist/src/mcpl/channel-registry.d.ts +131 -15
  108. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  109. package/dist/src/mcpl/channel-registry.js +290 -46
  110. package/dist/src/mcpl/channel-registry.js.map +1 -1
  111. package/dist/src/mcpl/checkpoint-manager.d.ts +2 -4
  112. package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -1
  113. package/dist/src/mcpl/checkpoint-manager.js.map +1 -1
  114. package/dist/src/mcpl/feature-set-manager.d.ts +2 -4
  115. package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
  116. package/dist/src/mcpl/feature-set-manager.js.map +1 -1
  117. package/dist/src/mcpl/inbound-source.d.ts +2 -1
  118. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  119. package/dist/src/mcpl/inbound-source.js +2 -1
  120. package/dist/src/mcpl/inbound-source.js.map +1 -1
  121. package/dist/src/mcpl/inference-router.d.ts +6 -6
  122. package/dist/src/mcpl/inference-router.d.ts.map +1 -1
  123. package/dist/src/mcpl/inference-router.js.map +1 -1
  124. package/dist/src/mcpl/push-coalescer.d.ts +132 -22
  125. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  126. package/dist/src/mcpl/push-coalescer.js +105 -15
  127. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  128. package/dist/src/mcpl/push-handler.d.ts +9 -7
  129. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  130. package/dist/src/mcpl/push-handler.js.map +1 -1
  131. package/dist/src/mcpl/server-connection.d.ts +13 -10
  132. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  133. package/dist/src/mcpl/server-connection.js +134 -56
  134. package/dist/src/mcpl/server-connection.js.map +1 -1
  135. package/dist/src/mcpl/tool-classes.d.ts.map +1 -1
  136. package/dist/src/mcpl/tool-classes.js +3 -0
  137. package/dist/src/mcpl/tool-classes.js.map +1 -1
  138. package/dist/src/mcpl/types.d.ts +8 -2
  139. package/dist/src/mcpl/types.d.ts.map +1 -1
  140. package/dist/src/mcpl/types.js.map +1 -1
  141. package/dist/src/module-registry.d.ts +24 -1
  142. package/dist/src/module-registry.d.ts.map +1 -1
  143. package/dist/src/module-registry.js +68 -18
  144. package/dist/src/module-registry.js.map +1 -1
  145. package/dist/src/modules/discord/index.d.ts +45 -8
  146. package/dist/src/modules/discord/index.d.ts.map +1 -1
  147. package/dist/src/modules/discord/index.js +237 -86
  148. package/dist/src/modules/discord/index.js.map +1 -1
  149. package/dist/src/modules/history/index.d.ts +59 -0
  150. package/dist/src/modules/history/index.d.ts.map +1 -1
  151. package/dist/src/modules/history/index.js +432 -67
  152. package/dist/src/modules/history/index.js.map +1 -1
  153. package/dist/src/modules/history/semantic.d.ts +6 -5
  154. package/dist/src/modules/history/semantic.d.ts.map +1 -1
  155. package/dist/src/modules/history/semantic.js +15 -22
  156. package/dist/src/modules/history/semantic.js.map +1 -1
  157. package/dist/src/modules/workspace/disk-agreement.d.ts +1 -1
  158. package/dist/src/modules/workspace/disk-agreement.js +1 -1
  159. package/dist/src/modules/workspace/index.d.ts +28 -7
  160. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  161. package/dist/src/modules/workspace/index.js +76 -22
  162. package/dist/src/modules/workspace/index.js.map +1 -1
  163. package/dist/src/notice-tags.d.ts +10 -1
  164. package/dist/src/notice-tags.d.ts.map +1 -1
  165. package/dist/src/notice-tags.js +10 -1
  166. package/dist/src/notice-tags.js.map +1 -1
  167. package/dist/src/operator-log.d.ts +36 -3
  168. package/dist/src/operator-log.d.ts.map +1 -1
  169. package/dist/src/operator-log.js +2 -2
  170. package/dist/src/operator-log.js.map +1 -1
  171. package/dist/src/presentation.d.ts +746 -0
  172. package/dist/src/presentation.d.ts.map +1 -0
  173. package/dist/src/presentation.js +1435 -0
  174. package/dist/src/presentation.js.map +1 -0
  175. package/dist/src/prose-drafts.d.ts +15 -11
  176. package/dist/src/prose-drafts.d.ts.map +1 -1
  177. package/dist/src/prose-drafts.js +16 -12
  178. package/dist/src/prose-drafts.js.map +1 -1
  179. package/dist/src/read-marks.d.ts +192 -0
  180. package/dist/src/read-marks.d.ts.map +1 -0
  181. package/dist/src/read-marks.js +242 -0
  182. package/dist/src/read-marks.js.map +1 -0
  183. package/dist/src/recovery/offline-branch.d.ts +91 -6
  184. package/dist/src/recovery/offline-branch.d.ts.map +1 -1
  185. package/dist/src/recovery/offline-branch.js +273 -29
  186. package/dist/src/recovery/offline-branch.js.map +1 -1
  187. package/dist/src/recovery/recover-cli.js +22 -3
  188. package/dist/src/recovery/recover-cli.js.map +1 -1
  189. package/dist/src/send-tools.d.ts +5 -9
  190. package/dist/src/send-tools.d.ts.map +1 -1
  191. package/dist/src/send-tools.js +40 -7
  192. package/dist/src/send-tools.js.map +1 -1
  193. package/dist/src/stored-injections.d.ts +2 -2
  194. package/dist/src/stored-injections.js +2 -2
  195. package/dist/src/stored-removal.d.ts +17 -4
  196. package/dist/src/stored-removal.d.ts.map +1 -1
  197. package/dist/src/stored-removal.js +29 -5
  198. package/dist/src/stored-removal.js.map +1 -1
  199. package/dist/src/tool-result-guard.d.ts +12 -1
  200. package/dist/src/tool-result-guard.d.ts.map +1 -1
  201. package/dist/src/tool-result-guard.js +42 -8
  202. package/dist/src/tool-result-guard.js.map +1 -1
  203. package/dist/src/tune-out/coordinator.d.ts +1159 -79
  204. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  205. package/dist/src/tune-out/coordinator.js +3709 -363
  206. package/dist/src/tune-out/coordinator.js.map +1 -1
  207. package/dist/src/tune-out/tools.d.ts +114 -17
  208. package/dist/src/tune-out/tools.d.ts.map +1 -1
  209. package/dist/src/tune-out/tools.js +87 -27
  210. package/dist/src/tune-out/tools.js.map +1 -1
  211. package/dist/src/tune-out/window-anchor.d.ts +143 -0
  212. package/dist/src/tune-out/window-anchor.d.ts.map +1 -0
  213. package/dist/src/tune-out/window-anchor.js +202 -0
  214. package/dist/src/tune-out/window-anchor.js.map +1 -0
  215. package/dist/src/types/agent.d.ts +82 -20
  216. package/dist/src/types/agent.d.ts.map +1 -1
  217. package/dist/src/types/events.d.ts +2 -0
  218. package/dist/src/types/events.d.ts.map +1 -1
  219. package/dist/src/types/framework.d.ts +32 -12
  220. package/dist/src/types/framework.d.ts.map +1 -1
  221. package/dist/src/types/module.d.ts +180 -69
  222. package/dist/src/types/module.d.ts.map +1 -1
  223. package/dist/src/types/trace.d.ts +510 -36
  224. package/dist/src/types/trace.d.ts.map +1 -1
  225. package/package.json +3 -3
  226. package/src/admission/admit.ts +32 -3
  227. package/src/agent.ts +323 -120
  228. package/src/api/mcp-server-core.ts +54 -17
  229. package/src/api/server.ts +4 -23
  230. package/src/code-execution/isolate/scripts.ts +28 -3
  231. package/src/config-checks.ts +14 -0
  232. package/src/context-manager-errors.ts +37 -0
  233. package/src/context-options.ts +96 -0
  234. package/src/deferred-import.ts +239 -0
  235. package/src/dendrite/audience.ts +315 -0
  236. package/src/dendrite/index.ts +14 -2
  237. package/src/dendrite/presets.ts +18 -6
  238. package/src/dendrite/registry.ts +209 -12
  239. package/src/dendrite/types.ts +92 -8
  240. package/src/foreign-rounds.ts +199 -0
  241. package/src/framework.ts +7804 -3546
  242. package/src/gate/event-gate.ts +428 -65
  243. package/src/gate/index.ts +3 -0
  244. package/src/gate/rule-scope.ts +45 -0
  245. package/src/gate/suppress-script-worker.ts +89 -0
  246. package/src/gate/suppress-scripts.ts +414 -0
  247. package/src/gate/suppression-review.ts +517 -0
  248. package/src/gate/suppression-stats.ts +314 -0
  249. package/src/gate/types.ts +141 -7
  250. package/src/gate/wake-onboarding.ts +309 -0
  251. package/src/held-writes.ts +49 -60
  252. package/src/index.ts +9 -2
  253. package/src/jsonrpc-envelope.ts +81 -0
  254. package/src/mcpl/channel-registry.ts +353 -85
  255. package/src/mcpl/checkpoint-manager.ts +3 -2
  256. package/src/mcpl/feature-set-manager.ts +2 -1
  257. package/src/mcpl/inbound-source.ts +2 -1
  258. package/src/mcpl/inference-router.ts +7 -4
  259. package/src/mcpl/push-coalescer.ts +193 -34
  260. package/src/mcpl/push-handler.ts +10 -5
  261. package/src/mcpl/server-connection.ts +141 -60
  262. package/src/mcpl/tool-classes.ts +3 -0
  263. package/src/mcpl/types.ts +8 -2
  264. package/src/module-registry.ts +73 -17
  265. package/src/modules/discord/index.ts +229 -81
  266. package/src/modules/history/index.ts +439 -70
  267. package/src/modules/history/semantic.ts +15 -21
  268. package/src/modules/workspace/disk-agreement.ts +1 -1
  269. package/src/modules/workspace/index.ts +85 -23
  270. package/src/notice-tags.ts +10 -1
  271. package/src/operator-log.ts +36 -3
  272. package/src/presentation.ts +1676 -0
  273. package/src/prose-drafts.ts +16 -12
  274. package/src/read-marks.ts +328 -0
  275. package/src/recovery/offline-branch.ts +346 -32
  276. package/src/recovery/recover-cli.ts +21 -3
  277. package/src/send-tools.ts +40 -7
  278. package/src/stored-injections.ts +2 -2
  279. package/src/stored-removal.ts +31 -7
  280. package/src/tool-result-guard.ts +41 -7
  281. package/src/tune-out/coordinator.ts +4089 -457
  282. package/src/tune-out/tools.ts +160 -43
  283. package/src/tune-out/window-anchor.ts +277 -0
  284. package/src/types/agent.ts +86 -20
  285. package/src/types/events.ts +2 -0
  286. package/src/types/framework.ts +32 -12
  287. package/src/types/module.ts +181 -68
  288. package/src/types/trace.ts +542 -40
@@ -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.
@@ -166,7 +172,9 @@ export type TraceEvent = (TraceEventBase & {
166
172
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
167
173
  * Explicit mode: the channel its typing shows, where the start's wake
168
174
  * came from, or, at a start whose wake names none, such as a budget
169
- * restart, the one the turn already shows. */
175
+ * restart, the one the turn already shows. Disabled mode, and a silent
176
+ * turn in any mode: none, though the turn may show typing, since its
177
+ * text is never sent to a channel. */
170
178
  channelId?: string;
171
179
  }) | (TraceEventBase & {
172
180
  /**
@@ -190,7 +198,9 @@ export type TraceEvent = (TraceEventBase & {
190
198
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
191
199
  * Explicit mode: the channel its typing shows, where the start's wake
192
200
  * came from, or, at a start whose wake names none, such as a budget
193
- * restart, the one the turn already shows. */
201
+ * restart, the one the turn already shows. Disabled mode, and a silent
202
+ * turn in any mode: none, though the turn may show typing, since its
203
+ * text is never sent to a channel. */
194
204
  channelId?: string;
195
205
  }) | (TraceEventBase & {
196
206
  type: 'inference:tool_calls_yielded';
@@ -312,6 +322,7 @@ export type TraceEvent = (TraceEventBase & {
312
322
  module: string;
313
323
  tool: string;
314
324
  callId: string;
325
+ durationMs?: number;
315
326
  error: string;
316
327
  stack?: string;
317
328
  }) | (TraceEventBase & {
@@ -360,7 +371,12 @@ export type TraceEvent = (TraceEventBase & {
360
371
  agentStatus: string;
361
372
  requestCount: number;
362
373
  oldestRequestAge: number;
363
- }) | (TraceEventBase & {
374
+ })
375
+ /** A message stored, with its stored id. A write kept in memory first (a
376
+ * live surgery's hold, or the wait for its agent's context manager to be
377
+ * re-initialized) is traced once, as a release stores it, with source
378
+ * `surgery-release`; its arrival isn't traced. */
379
+ | (TraceEventBase & {
364
380
  type: 'message:added';
365
381
  messageId: string;
366
382
  source: string;
@@ -371,6 +387,25 @@ export type TraceEvent = (TraceEventBase & {
371
387
  messageId: string;
372
388
  source: string;
373
389
  })
390
+ /** A write kept in memory until a live surgery's release (source
391
+ * `surgery-release`) whose store threw there: none of it was stored, or,
392
+ * with `mayBeStored`, context-manager couldn't tell what of it landed (the
393
+ * first row it names as stored is traced as `message:added`, as a stored
394
+ * write is). `external` is the address the write's metadata gave it, for
395
+ * the module that wrote it
396
+ * (the Discord module ends its record of a create with no row). The
397
+ * agent's writes lost at a release are told of once besides, by an ops
398
+ * alert of kind `store-held-lost`. */
399
+ | (TraceEventBase & {
400
+ type: 'message:lost';
401
+ source: string;
402
+ agentName: string;
403
+ external?: {
404
+ source: string;
405
+ id: string;
406
+ };
407
+ mayBeStored?: true;
408
+ })
374
409
  /** A push/event refused at the MCPL boundary: visibly-empty content
375
410
  * (`empty-content`, answered -32602, with no `field` or `detail`), or a
376
411
  * coalesced occurrence the host refused. A refused occurrence's reason
@@ -393,6 +428,12 @@ export type TraceEvent = (TraceEventBase & {
393
428
  field?: string;
394
429
  channelId?: string;
395
430
  detail?: string;
431
+ }) | (TraceEventBase & {
432
+ type: 'mcpl:push_event';
433
+ serverId: string;
434
+ eventId: string;
435
+ featureSet: string;
436
+ coalesce?: PushEventResult['coalesce'];
396
437
  })
397
438
  /** A channels/incoming message refused at the MCPL boundary: an
398
439
  * unregistered channel (`unknown-channel`, §14.5), visibly-empty content
@@ -412,6 +453,61 @@ export type TraceEvent = (TraceEventBase & {
412
453
  reason: string;
413
454
  field?: string;
414
455
  detail?: string;
456
+ }) | (TraceEventBase & {
457
+ type: 'mcpl:channels-register';
458
+ serverId: string;
459
+ channelIds: string[];
460
+ count: number;
461
+ }) | (TraceEventBase & {
462
+ type: 'mcpl:channels-changed';
463
+ serverId: string;
464
+ /** 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. */
465
+ added: string[];
466
+ /** The notification's `removed`, as the server sent it: not validated, so a channel the server names by a number arrives as that number. */
467
+ removed: string[];
468
+ /** As `added`, for the notification's `updated`. */
469
+ updated: string[];
470
+ }) | (TraceEventBase & {
471
+ type: 'mcpl:channels-incoming';
472
+ serverId: string;
473
+ messageCount: number;
474
+ /** 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. */
475
+ channelIds: string[];
476
+ }) | (TraceEventBase & {
477
+ type: 'mcpl:channel-descriptor-rejected';
478
+ serverId: string;
479
+ channelId?: string;
480
+ reason: string;
481
+ }) | (TraceEventBase & {
482
+ type: 'mcpl:channel-lazy-registered';
483
+ serverId: string;
484
+ channelId: string;
485
+ label: string;
486
+ }) | (TraceEventBase & {
487
+ type: 'mcpl:channel-opened-by-send';
488
+ serverId: string;
489
+ channelId: string;
490
+ }) | (TraceEventBase & {
491
+ type: 'mcpl:channel-open-failed';
492
+ serverId: string;
493
+ channelId: string;
494
+ error: string;
495
+ }) | (TraceEventBase & {
496
+ type: 'mcpl:channel-open-substituted';
497
+ serverId: string;
498
+ channelId: string;
499
+ answeredFor: string;
500
+ }) | (TraceEventBase & {
501
+ type: 'mcpl:channel-reconcile-failed';
502
+ serverId: string;
503
+ channelId: string;
504
+ desired?: DesiredChannelState;
505
+ attempts?: number;
506
+ error: string;
507
+ }) | (TraceEventBase & {
508
+ type: 'mcpl:channel-reconcile-skipped';
509
+ serverId: string;
510
+ reason: string;
415
511
  })
416
512
  /** MCPL content that context-manager won't store, because it doesn't
417
513
  * match ContentBlock, reached the store/wake site and was refused there:
@@ -435,8 +531,7 @@ export type TraceEvent = (TraceEventBase & {
435
531
  channelId?: string;
436
532
  messageId?: string;
437
533
  })
438
- /** RFC-006 coalescing decision record (received / displaced / removed /
439
- * rendered / revoked / render-cancelled / late-render / render-failed).
534
+ /** RFC-006 coalescing decision record, by `kind`.
440
535
  * A late-render whose push/render had already timed out, its fallback
441
536
  * materialized, is recorded by the connection's wiring rather than the
442
537
  * coalescer: it names `serverId`, `featureSet`, `key` and, for a
@@ -445,10 +540,21 @@ export type TraceEvent = (TraceEventBase & {
445
540
  * links it to the batch's render-failed. */
446
541
  | (TraceEventBase & {
447
542
  type: 'mcpl:coalescing';
448
- kind: string;
449
- subject?: string;
543
+ } & CoalescingAudit) | (TraceEventBase & {
544
+ type: 'mcpl:coalescing';
545
+ kind: 'late-render';
546
+ serverId: string;
450
547
  eventId?: string;
451
- [key: string]: unknown;
548
+ featureSet?: string;
549
+ key?: string;
550
+ channelId?: string;
551
+ discarded: true;
552
+ error?: string;
553
+ }) | (TraceEventBase & {
554
+ type: 'mcpl:coalescing';
555
+ kind: 'turn-withdrawn';
556
+ agentName: string;
557
+ subjects: string[];
452
558
  }) | (TraceEventBase & {
453
559
  type: 'gate:policy-matched';
454
560
  policyName: string;
@@ -485,9 +591,8 @@ export type TraceEvent = (TraceEventBase & {
485
591
  * gate hands the line to the wake when its message is the newest at
486
592
  * the fire, EventGate isNewestEntry, and the turn's start decides).
487
593
  * `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. */
594
+ * still the newest entry in the window; `held`, the host was
595
+ * quiesced, so no line could be written then. */
491
596
  type: 'gate:wake-line-omitted';
492
597
  reason: 'newest' | 'held';
493
598
  policyNames: string[];
@@ -497,6 +602,8 @@ export type TraceEvent = (TraceEventBase & {
497
602
  type: 'gate:config-reloaded';
498
603
  configPath: string;
499
604
  policyCount: number;
605
+ removedPolicies?: string[];
606
+ stateClearedPolicies?: string[];
500
607
  }) | (TraceEventBase & {
501
608
  type: 'gate:decision';
502
609
  eventType: string;
@@ -505,23 +612,68 @@ export type TraceEvent = (TraceEventBase & {
505
612
  matchedPolicy: string | null;
506
613
  trigger: boolean;
507
614
  behavior: string;
508
- }) | (TraceEventBase & {
509
- type: 'usage:updated';
510
- totals: SessionUsage;
615
+ observed?: string[];
616
+ })
617
+ /** A periodic review of what suppress rules hid ran (gate/suppression-review.ts); `delivered` when the agent was told. */
618
+ | (TraceEventBase & {
619
+ type: 'gate:suppression-review';
511
620
  agentName: string;
512
- inferenceCount: number;
621
+ fromMs: number;
622
+ toMs: number;
623
+ total: number;
624
+ flagged: number;
625
+ delivered: boolean;
626
+ rules: Array<{
627
+ rule: string;
628
+ suppressed: number;
629
+ read: number;
630
+ verdict: 'fits' | 'flagged' | 'error' | 'unjudged';
631
+ flagged: number;
632
+ }>;
633
+ })
634
+ /** A suppress rule took an event: its row is stored and never rendered (EventGate.noteSuppressed). */
635
+ | (TraceEventBase & {
636
+ type: 'gate:suppressed';
637
+ policyName: string;
638
+ eventType: string;
639
+ serverId?: string;
640
+ channelId?: string;
641
+ }) | (TraceEventBase & Fields<RecipeChanges> & {
642
+ type: 'gate:config-reconciled';
643
+ configPath: string;
644
+ addedPolicies: string[];
513
645
  }) | (TraceEventBase & {
514
- type: 'undo:completed';
515
- agentName: string;
516
- turnIndex: number;
517
- fromBranch: string;
518
- toBranch: string;
646
+ type: 'gate:policy-added';
647
+ configPath: string;
648
+ policyName: string;
649
+ replaced: boolean;
519
650
  }) | (TraceEventBase & {
520
- type: 'redo:completed';
521
- agentName: string;
522
- fromBranch: string;
523
- toBranch: string;
651
+ type: 'gate:policy-removed';
652
+ configPath: string;
653
+ policyName: string;
524
654
  }) | (TraceEventBase & {
655
+ type: 'gate:shadow-warnings';
656
+ reason: string;
657
+ warnings: string[];
658
+ })
659
+ /** Wake onboarding offered a server's suggestions after an undecided event
660
+ * (gate/wake-onboarding.ts): `policy` let it go by (null: the default). */
661
+ | (TraceEventBase & {
662
+ type: 'gate:onboarding-offered';
663
+ serverId: string;
664
+ digest: string;
665
+ policy: string | null;
666
+ rules: number;
667
+ wake: boolean;
668
+ })
669
+ /** The agent answered an offer: rules accepted (the names written), or declined. */
670
+ | (TraceEventBase & {
671
+ type: 'gate:onboarding-decided';
672
+ serverId: string;
673
+ digest: string;
674
+ state: 'accepted' | 'declined';
675
+ rules: string[];
676
+ }) | (TraceEventBase & Fields<UsageUpdatedEvent>) | (TraceEventBase & {
525
677
  type: 'operator:action';
526
678
  agentName?: string;
527
679
  kind: string;
@@ -615,10 +767,6 @@ export type TraceEvent = (TraceEventBase & {
615
767
  toolUseId: string;
616
768
  isError: boolean;
617
769
  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
770
  }) | (TraceEventBase & {
623
771
  type: 'mcpl:server-connect-failed';
624
772
  serverId: string;
@@ -694,6 +842,45 @@ export type TraceEvent = (TraceEventBase & {
694
842
  unrecognized?: string[];
695
843
  /** missing_capabilities: the capability paths the grant lacks. */
696
844
  missing?: string[];
845
+ }) | (TraceEventBase & {
846
+ type: 'mcpl:inference_start';
847
+ serverId: string;
848
+ featureSet: string;
849
+ model: string;
850
+ stream: boolean;
851
+ }) | (TraceEventBase & {
852
+ type: 'mcpl:inference_complete';
853
+ serverId: string;
854
+ model: string;
855
+ actualModel?: string;
856
+ inputTokens: number;
857
+ outputTokens: number;
858
+ streamed: boolean;
859
+ }) | (TraceEventBase & {
860
+ type: 'mcpl:inference_fail';
861
+ serverId: string;
862
+ model: string | null;
863
+ error: string;
864
+ streamed: boolean;
865
+ }) | (TraceEventBase & {
866
+ type: 'mcpl:state_registered';
867
+ serverId: string;
868
+ featureSet: string;
869
+ hostState: boolean;
870
+ rollback: boolean;
871
+ }) | (TraceEventBase & {
872
+ type: 'mcpl:checkpoint_recorded';
873
+ serverId: string;
874
+ featureSet: string;
875
+ checkpoint: string;
876
+ parent: string | null;
877
+ hasData: boolean;
878
+ hasPatch: boolean;
879
+ }) | (TraceEventBase & {
880
+ type: 'mcpl:state_rollback';
881
+ serverId: string;
882
+ featureSet: string;
883
+ checkpoint: string;
697
884
  }) | (TraceEventBase & {
698
885
  /** An operator tool-name pattern matches no model-facing tool. Emitted
699
886
  * once per pattern, after the servers it could name have listed. */
@@ -799,6 +986,143 @@ export type TraceEvent = (TraceEventBase & {
799
986
  type: 'host:quiesced_boot';
800
987
  reason?: string;
801
988
  since?: number;
989
+ }) | (TraceEventBase & {
990
+ type: 'tune-out:entered';
991
+ serverId: string;
992
+ channelId: string;
993
+ epochId: string;
994
+ scope?: 'all-except';
995
+ reader: boolean;
996
+ expiresAtMs?: number;
997
+ }) | (TraceEventBase & {
998
+ type: 'tune-out:cancelled';
999
+ serverId: string;
1000
+ channelId: string;
1001
+ epochId: string;
1002
+ scope?: 'all-except';
1003
+ reason: string;
1004
+ wakeCount: number;
1005
+ }) | (TraceEventBase & {
1006
+ type: 'tune-out:announced';
1007
+ serverId: string;
1008
+ channelId: string;
1009
+ epochId: string;
1010
+ kind: 'entered' | 'released';
1011
+ }) | (TraceEventBase & {
1012
+ type: 'tune-out:announce-failed';
1013
+ serverId: string;
1014
+ channelId: string;
1015
+ epochId: string;
1016
+ kind: 'entered' | 'released';
1017
+ error: string;
1018
+ }) | (TraceEventBase & {
1019
+ type: 'tune-out:ack-failed';
1020
+ serverId: string;
1021
+ channelId: string;
1022
+ error: string;
1023
+ }) | (TraceEventBase & {
1024
+ type: 'tune-out:timer-failed';
1025
+ timer: 'wake' | 'cadence' | 'expiry';
1026
+ serverId: string;
1027
+ channelId: string;
1028
+ error: string;
1029
+ }) | (TraceEventBase & {
1030
+ type: 'tune-out:wake-budget-paused';
1031
+ serverId: string;
1032
+ channelId: string;
1033
+ epochId: string;
1034
+ scope: 'all-except';
1035
+ wakeCount: number;
1036
+ maxWakes: number;
1037
+ })
1038
+ /**
1039
+ * A tune-out's cancel asked for while writes were held in memory, queued
1040
+ * for the release and its retry, taken off the queue with what it was for
1041
+ * left undone. `hold-ended`: the hold of the epoch it was asked for
1042
+ * (`epochId`) ended without it, so it ends nothing, and no later hold
1043
+ * there (`currentEpochId`, the one in force when it was dropped, if one
1044
+ * was). `note-undelivered`: its hold ended, by another cancel or by its
1045
+ * own run, and delivering the note it carried failed (`error`).
1046
+ * `stopped`: the host stopped while it waited, its hold still in force,
1047
+ * which the next boot resumes without running it. `superseded`: it was
1048
+ * asked for while an earlier cancel of the same hold ran, and joined that
1049
+ * one when it was queued again, whose note stands.
1050
+ * `noteLost`: it carried a reader's note, which is not delivered, or,
1051
+ * with `noteMayBeStored`, may be stored after all: the store couldn't tell
1052
+ * whether its write landed (`error` says what it couldn't read), as the
1053
+ * author's notice then says it may be lost. Its
1054
+ * author is told so in its own context where the author still exists,
1055
+ * and a reader fork that has ended is not, the loss reaching no one
1056
+ * (`tune-out:note-loss-untold`, `author-gone`). The persistent
1057
+ * subconscious is told by the next boot where the host stopped, and,
1058
+ * where another cancel ended the hold, in that cancel's release, which
1059
+ * its window holds, rather than in a notice of its own. `noteAuthor`, whose note
1060
+ * it was, the name it would have been delivered under (the persistent
1061
+ * subconscious's, or the reader fork's that left it), where one is known.
1062
+ * For the all-except hold (`scope`), the channel is its excepted one.
1063
+ */
1064
+ | (TraceEventBase & {
1065
+ type: 'tune-out:deferred-cancel-dropped';
1066
+ serverId: string;
1067
+ channelId: string;
1068
+ epochId: string;
1069
+ scope?: 'all-except';
1070
+ reason: 'hold-ended' | 'note-undelivered' | 'stopped' | 'superseded';
1071
+ currentEpochId?: string;
1072
+ noteLost: boolean;
1073
+ noteMayBeStored?: true;
1074
+ noteAuthor?: string;
1075
+ error?: string;
1076
+ })
1077
+ /**
1078
+ * At boot, a hold on record (`epochId`; the all-except hold with `scope`,
1079
+ * its channel the excepted one) that the last stop's stamp
1080
+ * (`tune-out/<primary>/stop-stamp`) doesn't cover: the host crashed, or
1081
+ * the store refused the stop's writes. `found`, from that run's rows:
1082
+ * `ran`, a release of that epoch was stored after the cancel was asked,
1083
+ * its end not recorded; `delivered`, a waiting cancel's note was written
1084
+ * to the resident, with no release since; `asked`, the subconscious's
1085
+ * own call of that cancel, answered as waiting, is in its window;
1086
+ * `unknown`, nothing says whether a cancel waited. The persistent
1087
+ * subconscious (`noteAuthor`) is told which, by a loss notice kept and
1088
+ * tried again as the others are (`tune-out:note-loss-untold` where its
1089
+ * write fails). Not traced: a hold no stamp covers because none was ever
1090
+ * written (a first start on a version that stamps its stops), one whose
1091
+ * release already told a waiting note's loss, one whose loss the stop
1092
+ * kept, and one already told as much.
1093
+ */
1094
+ | (TraceEventBase & {
1095
+ type: 'tune-out:stop-unrecorded';
1096
+ serverId: string;
1097
+ channelId: string;
1098
+ epochId: string;
1099
+ scope?: 'all-except';
1100
+ noteAuthor: string;
1101
+ found: 'delivered' | 'ran' | 'asked' | 'unknown';
1102
+ })
1103
+ /**
1104
+ * The notice telling a lost note's author (`noteAuthor`) of the loss (a
1105
+ * `tune-out:deferred-cancel-dropped` with `noteLost`) was not written.
1106
+ * `write-failed`: writing it threw (`error`). It is kept, and tried again
1107
+ * whenever held writes are stored and every 60 s while none are, until it
1108
+ * is written. One for the persistent subconscious is kept in the store
1109
+ * too, so a stop leaves it there and the next boot tries it again; a
1110
+ * reader fork's is dropped at a stop. This traces its first failure only,
1111
+ * a later boot's included, and each later one is logged. `author-gone`:
1112
+ * the framework wrote nothing, as no agent of that name is registered (a
1113
+ * reader fork whose run has ended): the loss reaches no one, and the
1114
+ * notice is not kept. For the all-except hold (`scope`), the channel is
1115
+ * its excepted one.
1116
+ */
1117
+ | (TraceEventBase & {
1118
+ type: 'tune-out:note-loss-untold';
1119
+ serverId: string;
1120
+ channelId: string;
1121
+ epochId: string;
1122
+ scope?: 'all-except';
1123
+ noteAuthor: string;
1124
+ reason: 'write-failed' | 'author-gone';
1125
+ error?: string;
802
1126
  })
803
1127
  /** A reader fork ended in prose without `deliver_summary`; its final prose was delivered as its report. */
804
1128
  | (TraceEventBase & {
@@ -825,10 +1149,8 @@ export type TraceEvent = (TraceEventBase & {
825
1149
  channelId: string;
826
1150
  epochId: string;
827
1151
  trigger: 'cadence' | 'wake' | 'cancel';
828
- /** Held messages the fork was handed, stored and queued. */
1152
+ /** Held messages the fork was handed. */
829
1153
  held: number;
830
- /** Of those, the ones still queued behind the resident's turn. */
831
- queued: number;
832
1154
  })
833
1155
  /**
834
1156
  * A tune-out reader fork threw: its framing, its derive or its run. One
@@ -847,6 +1169,25 @@ export type TraceEvent = (TraceEventBase & {
847
1169
  /** Whether the fork had reported through `deliver_summary` before it failed. */
848
1170
  reported: boolean;
849
1171
  returned: number;
1172
+ })
1173
+ /**
1174
+ * The persistent subconscious's window start was set by index ordinal
1175
+ * (#291): `fixed`, a tune-out's start fixed once no row the subconscious
1176
+ * is owed stored before the start was out of its window, and kept for its
1177
+ * epochs; `clamped`, a kept start (`kept`) past its window's index length
1178
+ * on the store's branch now (one a rollback made shorter), set at the
1179
+ * length instead.
1180
+ */
1181
+ | (TraceEventBase & {
1182
+ type: 'tune-out:subconscious-window';
1183
+ agentName: string;
1184
+ /** The tune-outs that start there. */
1185
+ epochIds: string[];
1186
+ how: 'fixed' | 'clamped';
1187
+ /** The ordinal the window starts at now. */
1188
+ ordinal: number;
1189
+ /** For `clamped`, the ordinal kept for them. */
1190
+ kept?: number;
850
1191
  }) | (TraceEventBase & {
851
1192
  type: 'dendrite:agent-created';
852
1193
  agentName: string;
@@ -891,7 +1232,7 @@ export type TraceEvent = (TraceEventBase & {
891
1232
  by?: string;
892
1233
  reason?: string;
893
1234
  })
894
- /** The message entered the recipient's store (not merely queued for it). */
1235
+ /** The message entered the recipient's store (not merely held for it). */
895
1236
  | (TraceEventBase & {
896
1237
  type: 'dendrite:mail-delivered';
897
1238
  mailId: string;
@@ -899,7 +1240,10 @@ export type TraceEvent = (TraceEventBase & {
899
1240
  from: string;
900
1241
  to: string;
901
1242
  })
902
- /** Queued for the recipient's next boundary; `mail-delivered` follows when it lands. */
1243
+ /** Held in memory behind a live surgery (the operator's switch awaited),
1244
+ * or kept for a recipient whose context manager refuses its work after a
1245
+ * failed re-initialization; `mail-delivered` follows when a release
1246
+ * stores it. */
903
1247
  | (TraceEventBase & {
904
1248
  type: 'dendrite:mail-deferred';
905
1249
  mailId: string;
@@ -927,6 +1271,8 @@ export type TraceEvent = (TraceEventBase & {
927
1271
  messageId: string;
928
1272
  recipients: string[];
929
1273
  held: string | null;
1274
+ /** The suppress rule that took the event, when one did. */
1275
+ suppressed?: string;
930
1276
  wake: boolean;
931
1277
  gatePass: boolean;
932
1278
  })
@@ -940,6 +1286,120 @@ export type TraceEvent = (TraceEventBase & {
940
1286
  /** Envelope kind of the acceptance the observer failed on. */
941
1287
  kind: 'channel' | 'unscoped' | 'surface';
942
1288
  error: string;
1289
+ }) | (TraceEventBase & {
1290
+ /**
1291
+ * Rows entered an agent's window (context-manager's presentRows), at
1292
+ * one of its presentation points (`occasion`): `count` bodies, a
1293
+ * sharded one counted once. At `rebase`, the store's branch moved to a
1294
+ * branch with no window for the agent, and its window there was
1295
+ * written down: `count` is the bodies it holds.
1296
+ */
1297
+ type: 'presentation:presented';
1298
+ agentName: string;
1299
+ occasion: PresentationOccasion;
1300
+ count: number;
1301
+ /** At a tool boundary: the first row that couldn't join the live
1302
+ * stream (a tool block, or a row named as the agent), where the rows
1303
+ * presented there stop. It and the rows after it wait for the turn's
1304
+ * end. */
1305
+ cutAt?: string;
1306
+ /** How many of them carry no audience stamp (stored by a host's
1307
+ * writer that doesn't stamp), presented to the slot's owners and
1308
+ * its observers. */
1309
+ unstamped?: number;
1310
+ }) | (TraceEventBase & {
1311
+ /** An agent's own rows that were stored and not in its window, found
1312
+ * when the agent was taken on or at boot, were presented to it. */
1313
+ type: 'presentation:repaired';
1314
+ agentName: string;
1315
+ count: number;
1316
+ }) | (TraceEventBase & {
1317
+ /**
1318
+ * A row was stamped for agents of which none reads the slot it is
1319
+ * stored in (`deliveredTo`'s), so no window presents it by its
1320
+ * audience. It is stored as named, never widened: observers of the
1321
+ * slot see it only as their edge shows it.
1322
+ */
1323
+ type: 'presentation:unreadable-audience';
1324
+ messageId?: string;
1325
+ audience: string[];
1326
+ slot: MessageSlotRef;
1327
+ deliveredTo: string;
1328
+ }) | (TraceEventBase & {
1329
+ /** A presentation failed; the rows it didn't present stay out of the
1330
+ * agent's window for its next presentation point. At a fresh turn's
1331
+ * start (`turn-start`, `assembly`), the start fails too. With
1332
+ * `legacy`, the agent was left unpresented (legacy mode) until a
1333
+ * later move of the store's branch: its window the whole record as
1334
+ * before the index, or, where its strategy couldn't follow a move to
1335
+ * a branch that holds a window, that window, writes for it waiting in
1336
+ * memory: at `adopt`, its window couldn't be
1337
+ * written down (another version's index format, or a failed write);
1338
+ * at `rebase`, after the store's branch moved, its window couldn't be
1339
+ * written down on the new branch, or its context's strategy couldn't
1340
+ * follow the move (`error` says which). The framework logs that and
1341
+ * raises an ops alert (`presentation-legacy`). Without it, at
1342
+ * `adopt` or `rebase`, presenting the agent's own rows failed, or
1343
+ * taking out the rows the write-down took in that aren't the
1344
+ * agent's did, which is tried again at its next turn start or point
1345
+ * at rest. */
1346
+ type: 'presentation:failed';
1347
+ agentName: string;
1348
+ occasion: PresentationOccasion;
1349
+ error: string;
1350
+ /** The rows the presentation named that didn't enter the window,
1351
+ * each body by the id that names it, where they are known (a write
1352
+ * of the window that failed). Absent where a read failed before the
1353
+ * rows could be named. */
1354
+ messageIds?: string[];
1355
+ /** Set where the failure left the agent in legacy mode. */
1356
+ legacy?: true;
1357
+ }) | (TraceEventBase & {
1358
+ /** At a tool boundary's hand-off, the newest rows of the agent's
1359
+ * window weren't the rows the stream was about to be given, in that
1360
+ * order. The stream's later rounds are noted as unvouched, so their
1361
+ * thinking is left out at the next compile rather than refused. */
1362
+ type: 'presentation:hand-off-mismatch';
1363
+ agentName: string;
1364
+ expected: string[];
1365
+ tail: string[];
1366
+ }) | (TraceEventBase & {
1367
+ /**
1368
+ * Rows were taken out of an agent's window. Every reason but `shed`
1369
+ * and `elsewhere` is a removal from the record made through another
1370
+ * agent's context, which context-manager tombstones in that context's
1371
+ * window only: the rows it removed leave this agent's window too, each
1372
+ * at its own place, so no other row's place moves (`hide`, `suppress` on its
1373
+ * fork, a coalescer's `coalescer`, a module's `module`, a suppression
1374
+ * a start finished, `resume`, and a refusal rewind's shed from a
1375
+ * window that is still the record, `rewind`), or that no live context
1376
+ * heard, found at boot (`boot`). `shed` is a refusal rewind's or an
1377
+ * inference failure's shed on a presented window: the rows leave the
1378
+ * agent's own window as an undone turn's do, and stay in the record.
1379
+ * `elsewhere` is a window written down from the shared record when the
1380
+ * agent was taken on, or after a branch move: the rows it took in that
1381
+ * carry an audience stamp and aren't the agent's (another agent's own
1382
+ * rows, mail stamped for others, a held row) leave it, and stay in the
1383
+ * record (decision 1).
1384
+ */
1385
+ type: 'presentation:retracted';
1386
+ agentName: string;
1387
+ messageIds: string[];
1388
+ reason: PresentationRetractReason;
1389
+ }) | (TraceEventBase & {
1390
+ /** An undo or a redo on the presentation index, counted in bodies.
1391
+ * An undo's `retracted` is the bodies from the turn's checkpoint on
1392
+ * that left the agent's window, the turn's own and what arrived
1393
+ * after it, and it carries no `represented`. A redo's
1394
+ * `retracted` is the rows that entered the window after the undo, and
1395
+ * any of the undo's own still in it after an undo cut short, which
1396
+ * left so the redone rows come back after their prefix; its
1397
+ * `represented` is the undone rows presented again. No branch
1398
+ * moved. */
1399
+ type: 'window:undone';
1400
+ agentName: string;
1401
+ retracted: number;
1402
+ represented?: number;
943
1403
  }) | (TraceEventBase & {
944
1404
  type: 'prose:drafts-held';
945
1405
  agentName: string;
@@ -959,8 +1419,22 @@ export type TraceEvent = (TraceEventBase & {
959
1419
  agentName: string;
960
1420
  draftIds: string[];
961
1421
  });
1422
+ /** Why rows left an agent's window (`presentation:retracted`). */
1423
+ export type PresentationRetractReason = 'hide' | 'suppress' | 'coalescer' | 'module' | 'resume' | 'rewind' | 'shed' | 'boot' | 'elsewhere';
962
1424
  /**
963
1425
  * Listener for trace events.
964
1426
  */
965
1427
  export type TraceEventListener = (event: TraceEvent) => void;
1428
+ /**
1429
+ * A trace as raised, before `emitTrace` stamps its `timestamp`: one of the
1430
+ * union's members without that field.
1431
+ */
1432
+ export type TraceEventInput = WithoutTimestamp<TraceEvent>;
1433
+ type Fields<Shape> = {
1434
+ [Key in keyof Shape]: Shape[Key];
1435
+ };
1436
+ type WithoutTimestamp<Event> = Event extends unknown ? {
1437
+ [Key in keyof Event as Key extends 'timestamp' ? never : Key]: Event[Key];
1438
+ } : never;
1439
+ export {};
966
1440
  //# sourceMappingURL=trace.d.ts.map