@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,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.
@@ -174,7 +180,9 @@ export type TraceEvent =
174
180
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
175
181
  * Explicit mode: the channel its typing shows, where the start's wake
176
182
  * came from, or, at a start whose wake names none, such as a budget
177
- * restart, the one the turn already shows. */
183
+ * restart, the one the turn already shows. Disabled mode, and a silent
184
+ * turn in any mode: none, though the turn may show typing, since its
185
+ * text is never sent to a channel. */
178
186
  channelId?: string;
179
187
  })
180
188
  | (TraceEventBase & {
@@ -199,7 +207,9 @@ export type TraceEvent =
199
207
  * hybrid mode a `>>>` envelope can send the text itself elsewhere.
200
208
  * Explicit mode: the channel its typing shows, where the start's wake
201
209
  * came from, or, at a start whose wake names none, such as a budget
202
- * restart, the one the turn already shows. */
210
+ * restart, the one the turn already shows. Disabled mode, and a silent
211
+ * turn in any mode: none, though the turn may show typing, since its
212
+ * text is never sent to a channel. */
203
213
  channelId?: string;
204
214
  })
205
215
  | (TraceEventBase & {
@@ -324,6 +334,7 @@ export type TraceEvent =
324
334
  module: string;
325
335
  tool: string;
326
336
  callId: string;
337
+ durationMs?: number;
327
338
  error: string;
328
339
  stack?: string;
329
340
  })
@@ -380,6 +391,10 @@ export type TraceEvent =
380
391
  })
381
392
 
382
393
  // Message lifecycle
394
+ /** A message stored, with its stored id. A write kept in memory first (a
395
+ * live surgery's hold, or the wait for its agent's context manager to be
396
+ * re-initialized) is traced once, as a release stores it, with source
397
+ * `surgery-release`; its arrival isn't traced. */
383
398
  | (TraceEventBase & {
384
399
  type: 'message:added';
385
400
  messageId: string;
@@ -391,6 +406,22 @@ export type TraceEvent =
391
406
  messageId: string;
392
407
  source: string;
393
408
  })
409
+ /** A write kept in memory until a live surgery's release (source
410
+ * `surgery-release`) whose store threw there: none of it was stored, or,
411
+ * with `mayBeStored`, context-manager couldn't tell what of it landed (the
412
+ * first row it names as stored is traced as `message:added`, as a stored
413
+ * write is). `external` is the address the write's metadata gave it, for
414
+ * the module that wrote it
415
+ * (the Discord module ends its record of a create with no row). The
416
+ * agent's writes lost at a release are told of once besides, by an ops
417
+ * alert of kind `store-held-lost`. */
418
+ | (TraceEventBase & {
419
+ type: 'message:lost';
420
+ source: string;
421
+ agentName: string;
422
+ external?: { source: string; id: string };
423
+ mayBeStored?: true;
424
+ })
394
425
  /** A push/event refused at the MCPL boundary: visibly-empty content
395
426
  * (`empty-content`, answered -32602, with no `field` or `detail`), or a
396
427
  * coalesced occurrence the host refused. A refused occurrence's reason
@@ -414,6 +445,13 @@ export type TraceEvent =
414
445
  channelId?: string;
415
446
  detail?: string;
416
447
  })
448
+ | (TraceEventBase & {
449
+ type: 'mcpl:push_event';
450
+ serverId: string;
451
+ eventId: string;
452
+ featureSet: string;
453
+ coalesce?: PushEventResult['coalesce'];
454
+ })
417
455
  /** A channels/incoming message refused at the MCPL boundary: an
418
456
  * unregistered channel (`unknown-channel`, §14.5), visibly-empty content
419
457
  * (`empty-content`), or a coalesced item the host refused
@@ -433,6 +471,71 @@ export type TraceEvent =
433
471
  field?: string;
434
472
  detail?: string;
435
473
  })
474
+ | (TraceEventBase & {
475
+ type: 'mcpl:channels-register';
476
+ serverId: string;
477
+ channelIds: string[];
478
+ count: number;
479
+ })
480
+ | (TraceEventBase & {
481
+ type: 'mcpl:channels-changed';
482
+ serverId: string;
483
+ /** 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. */
484
+ added: string[];
485
+ /** The notification's `removed`, as the server sent it: not validated, so a channel the server names by a number arrives as that number. */
486
+ removed: string[];
487
+ /** As `added`, for the notification's `updated`. */
488
+ updated: string[];
489
+ })
490
+ | (TraceEventBase & {
491
+ type: 'mcpl:channels-incoming';
492
+ serverId: string;
493
+ messageCount: number;
494
+ /** 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. */
495
+ channelIds: string[];
496
+ })
497
+ | (TraceEventBase & {
498
+ type: 'mcpl:channel-descriptor-rejected';
499
+ serverId: string;
500
+ channelId?: string;
501
+ reason: string;
502
+ })
503
+ | (TraceEventBase & {
504
+ type: 'mcpl:channel-lazy-registered';
505
+ serverId: string;
506
+ channelId: string;
507
+ label: string;
508
+ })
509
+ | (TraceEventBase & {
510
+ type: 'mcpl:channel-opened-by-send';
511
+ serverId: string;
512
+ channelId: string;
513
+ })
514
+ | (TraceEventBase & {
515
+ type: 'mcpl:channel-open-failed';
516
+ serverId: string;
517
+ channelId: string;
518
+ error: string;
519
+ })
520
+ | (TraceEventBase & {
521
+ type: 'mcpl:channel-open-substituted';
522
+ serverId: string;
523
+ channelId: string;
524
+ answeredFor: string;
525
+ })
526
+ | (TraceEventBase & {
527
+ type: 'mcpl:channel-reconcile-failed';
528
+ serverId: string;
529
+ channelId: string;
530
+ desired?: DesiredChannelState;
531
+ attempts?: number;
532
+ error: string;
533
+ })
534
+ | (TraceEventBase & {
535
+ type: 'mcpl:channel-reconcile-skipped';
536
+ serverId: string;
537
+ reason: string;
538
+ })
436
539
  /** MCPL content that context-manager won't store, because it doesn't
437
540
  * match ContentBlock, reached the store/wake site and was refused there:
438
541
  * no row, no wake. `places` is malformedContentPlaces' answer for it. */
@@ -455,20 +558,30 @@ export type TraceEvent =
455
558
  channelId?: string;
456
559
  messageId?: string;
457
560
  })
458
- /** RFC-006 coalescing decision record (received / displaced / removed /
459
- * rendered / revoked / render-cancelled / late-render / render-failed).
561
+ /** RFC-006 coalescing decision record, by `kind`.
460
562
  * A late-render whose push/render had already timed out, its fallback
461
563
  * materialized, is recorded by the connection's wiring rather than the
462
564
  * coalescer: it names `serverId`, `featureSet`, `key` and, for a
463
565
  * channel-scoped subject, `channelId` instead of `subject`, carries a late
464
566
  * JSON-RPC error as `error` (`[code] message`, bounded), and its `eventId`
465
567
  * links it to the batch's render-failed. */
568
+ | (TraceEventBase & { type: 'mcpl:coalescing' } & CoalescingAudit)
466
569
  | (TraceEventBase & {
467
570
  type: 'mcpl:coalescing';
468
- kind: string;
469
- subject?: string;
571
+ kind: 'late-render';
572
+ serverId: string;
470
573
  eventId?: string;
471
- [key: string]: unknown;
574
+ featureSet?: string;
575
+ key?: string;
576
+ channelId?: string;
577
+ discarded: true;
578
+ error?: string;
579
+ })
580
+ | (TraceEventBase & {
581
+ type: 'mcpl:coalescing';
582
+ kind: 'turn-withdrawn';
583
+ agentName: string;
584
+ subjects: string[];
472
585
  })
473
586
 
474
587
  // EventGate lifecycle
@@ -512,9 +625,8 @@ export type TraceEvent =
512
625
  * gate hands the line to the wake when its message is the newest at
513
626
  * the fire, EventGate isNewestEntry, and the turn's start decides).
514
627
  * `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. */
628
+ * still the newest entry in the window; `held`, the host was
629
+ * quiesced, so no line could be written then. */
518
630
  type: 'gate:wake-line-omitted';
519
631
  reason: 'newest' | 'held';
520
632
  policyNames: string[];
@@ -525,6 +637,8 @@ export type TraceEvent =
525
637
  type: 'gate:config-reloaded';
526
638
  configPath: string;
527
639
  policyCount: number;
640
+ removedPolicies?: string[];
641
+ stateClearedPolicies?: string[];
528
642
  })
529
643
  | (TraceEventBase & {
530
644
  type: 'gate:decision';
@@ -534,31 +648,70 @@ export type TraceEvent =
534
648
  matchedPolicy: string | null;
535
649
  trigger: boolean;
536
650
  behavior: string;
651
+ observed?: string[];
537
652
  })
538
-
539
- // Usage lifecycle
653
+ /** A periodic review of what suppress rules hid ran (gate/suppression-review.ts); `delivered` when the agent was told. */
540
654
  | (TraceEventBase & {
541
- type: 'usage:updated';
542
- totals: SessionUsage;
655
+ type: 'gate:suppression-review';
543
656
  agentName: string;
544
- inferenceCount: number;
657
+ fromMs: number;
658
+ toMs: number;
659
+ total: number;
660
+ flagged: number;
661
+ delivered: boolean;
662
+ rules: Array<{ rule: string; suppressed: number; read: number; verdict: 'fits' | 'flagged' | 'error' | 'unjudged'; flagged: number }>;
545
663
  })
546
-
547
- // Undo/redo lifecycle
664
+ /** A suppress rule took an event: its row is stored and never rendered (EventGate.noteSuppressed). */
548
665
  | (TraceEventBase & {
549
- type: 'undo:completed';
550
- agentName: string;
551
- turnIndex: number;
552
- fromBranch: string;
553
- toBranch: string;
666
+ type: 'gate:suppressed';
667
+ policyName: string;
668
+ eventType: string;
669
+ serverId?: string;
670
+ channelId?: string;
671
+ })
672
+ | (TraceEventBase & Fields<RecipeChanges> & {
673
+ type: 'gate:config-reconciled';
674
+ configPath: string;
675
+ addedPolicies: string[];
554
676
  })
555
677
  | (TraceEventBase & {
556
- type: 'redo:completed';
557
- agentName: string;
558
- fromBranch: string;
559
- toBranch: string;
678
+ type: 'gate:policy-added';
679
+ configPath: string;
680
+ policyName: string;
681
+ replaced: boolean;
682
+ })
683
+ | (TraceEventBase & {
684
+ type: 'gate:policy-removed';
685
+ configPath: string;
686
+ policyName: string;
687
+ })
688
+ | (TraceEventBase & {
689
+ type: 'gate:shadow-warnings';
690
+ reason: string;
691
+ warnings: string[];
692
+ })
693
+ /** Wake onboarding offered a server's suggestions after an undecided event
694
+ * (gate/wake-onboarding.ts): `policy` let it go by (null: the default). */
695
+ | (TraceEventBase & {
696
+ type: 'gate:onboarding-offered';
697
+ serverId: string;
698
+ digest: string;
699
+ policy: string | null;
700
+ rules: number;
701
+ wake: boolean;
702
+ })
703
+ /** The agent answered an offer: rules accepted (the names written), or declined. */
704
+ | (TraceEventBase & {
705
+ type: 'gate:onboarding-decided';
706
+ serverId: string;
707
+ digest: string;
708
+ state: 'accepted' | 'declined';
709
+ rules: string[];
560
710
  })
561
711
 
712
+ // Usage lifecycle
713
+ | (TraceEventBase & Fields<UsageUpdatedEvent>)
714
+
562
715
  // Operator-initiated mutation (rollback/suppress/undo/hide/settings/quiesce…).
563
716
  // Mirrors the durable operator-actions.jsonl record so live UIs see the
564
717
  // same entry the file keeps.
@@ -683,10 +836,6 @@ export type TraceEvent =
683
836
  toolUseId: string;
684
837
  isError: boolean;
685
838
  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
839
  })
691
840
 
692
841
  // MCPL server connection lifecycle (spawn / handshake / reconnect health).
@@ -773,6 +922,51 @@ export type TraceEvent =
773
922
  /** missing_capabilities: the capability paths the grant lacks. */
774
923
  missing?: string[];
775
924
  })
925
+ | (TraceEventBase & {
926
+ type: 'mcpl:inference_start';
927
+ serverId: string;
928
+ featureSet: string;
929
+ model: string;
930
+ stream: boolean;
931
+ })
932
+ | (TraceEventBase & {
933
+ type: 'mcpl:inference_complete';
934
+ serverId: string;
935
+ model: string;
936
+ actualModel?: string;
937
+ inputTokens: number;
938
+ outputTokens: number;
939
+ streamed: boolean;
940
+ })
941
+ | (TraceEventBase & {
942
+ type: 'mcpl:inference_fail';
943
+ serverId: string;
944
+ model: string | null;
945
+ error: string;
946
+ streamed: boolean;
947
+ })
948
+ | (TraceEventBase & {
949
+ type: 'mcpl:state_registered';
950
+ serverId: string;
951
+ featureSet: string;
952
+ hostState: boolean;
953
+ rollback: boolean;
954
+ })
955
+ | (TraceEventBase & {
956
+ type: 'mcpl:checkpoint_recorded';
957
+ serverId: string;
958
+ featureSet: string;
959
+ checkpoint: string;
960
+ parent: string | null;
961
+ hasData: boolean;
962
+ hasPatch: boolean;
963
+ })
964
+ | (TraceEventBase & {
965
+ type: 'mcpl:state_rollback';
966
+ serverId: string;
967
+ featureSet: string;
968
+ checkpoint: string;
969
+ })
776
970
  | (TraceEventBase & {
777
971
  /** An operator tool-name pattern matches no model-facing tool. Emitted
778
972
  * once per pattern, after the servers it could name have listed. */
@@ -888,6 +1082,151 @@ export type TraceEvent =
888
1082
  since?: number;
889
1083
  })
890
1084
 
1085
+ | (TraceEventBase & {
1086
+ type: 'tune-out:entered';
1087
+ serverId: string;
1088
+ channelId: string;
1089
+ epochId: string;
1090
+ scope?: 'all-except';
1091
+ reader: boolean;
1092
+ expiresAtMs?: number;
1093
+ })
1094
+ | (TraceEventBase & {
1095
+ type: 'tune-out:cancelled';
1096
+ serverId: string;
1097
+ channelId: string;
1098
+ epochId: string;
1099
+ scope?: 'all-except';
1100
+ reason: string;
1101
+ wakeCount: number;
1102
+ })
1103
+ | (TraceEventBase & {
1104
+ type: 'tune-out:announced';
1105
+ serverId: string;
1106
+ channelId: string;
1107
+ epochId: string;
1108
+ kind: 'entered' | 'released';
1109
+ })
1110
+ | (TraceEventBase & {
1111
+ type: 'tune-out:announce-failed';
1112
+ serverId: string;
1113
+ channelId: string;
1114
+ epochId: string;
1115
+ kind: 'entered' | 'released';
1116
+ error: string;
1117
+ })
1118
+ | (TraceEventBase & {
1119
+ type: 'tune-out:ack-failed';
1120
+ serverId: string;
1121
+ channelId: string;
1122
+ error: string;
1123
+ })
1124
+ | (TraceEventBase & {
1125
+ type: 'tune-out:timer-failed';
1126
+ timer: 'wake' | 'cadence' | 'expiry';
1127
+ serverId: string;
1128
+ channelId: string;
1129
+ error: string;
1130
+ })
1131
+ | (TraceEventBase & {
1132
+ type: 'tune-out:wake-budget-paused';
1133
+ serverId: string;
1134
+ channelId: string;
1135
+ epochId: string;
1136
+ scope: 'all-except';
1137
+ wakeCount: number;
1138
+ maxWakes: number;
1139
+ })
1140
+ /**
1141
+ * A tune-out's cancel asked for while writes were held in memory, queued
1142
+ * for the release and its retry, taken off the queue with what it was for
1143
+ * left undone. `hold-ended`: the hold of the epoch it was asked for
1144
+ * (`epochId`) ended without it, so it ends nothing, and no later hold
1145
+ * there (`currentEpochId`, the one in force when it was dropped, if one
1146
+ * was). `note-undelivered`: its hold ended, by another cancel or by its
1147
+ * own run, and delivering the note it carried failed (`error`).
1148
+ * `stopped`: the host stopped while it waited, its hold still in force,
1149
+ * which the next boot resumes without running it. `superseded`: it was
1150
+ * asked for while an earlier cancel of the same hold ran, and joined that
1151
+ * one when it was queued again, whose note stands.
1152
+ * `noteLost`: it carried a reader's note, which is not delivered, or,
1153
+ * with `noteMayBeStored`, may be stored after all: the store couldn't tell
1154
+ * whether its write landed (`error` says what it couldn't read), as the
1155
+ * author's notice then says it may be lost. Its
1156
+ * author is told so in its own context where the author still exists,
1157
+ * and a reader fork that has ended is not, the loss reaching no one
1158
+ * (`tune-out:note-loss-untold`, `author-gone`). The persistent
1159
+ * subconscious is told by the next boot where the host stopped, and,
1160
+ * where another cancel ended the hold, in that cancel's release, which
1161
+ * its window holds, rather than in a notice of its own. `noteAuthor`, whose note
1162
+ * it was, the name it would have been delivered under (the persistent
1163
+ * subconscious's, or the reader fork's that left it), where one is known.
1164
+ * For the all-except hold (`scope`), the channel is its excepted one.
1165
+ */
1166
+ | (TraceEventBase & {
1167
+ type: 'tune-out:deferred-cancel-dropped';
1168
+ serverId: string;
1169
+ channelId: string;
1170
+ epochId: string;
1171
+ scope?: 'all-except';
1172
+ reason: 'hold-ended' | 'note-undelivered' | 'stopped' | 'superseded';
1173
+ currentEpochId?: string;
1174
+ noteLost: boolean;
1175
+ noteMayBeStored?: true;
1176
+ noteAuthor?: string;
1177
+ error?: string;
1178
+ })
1179
+ /**
1180
+ * At boot, a hold on record (`epochId`; the all-except hold with `scope`,
1181
+ * its channel the excepted one) that the last stop's stamp
1182
+ * (`tune-out/<primary>/stop-stamp`) doesn't cover: the host crashed, or
1183
+ * the store refused the stop's writes. `found`, from that run's rows:
1184
+ * `ran`, a release of that epoch was stored after the cancel was asked,
1185
+ * its end not recorded; `delivered`, a waiting cancel's note was written
1186
+ * to the resident, with no release since; `asked`, the subconscious's
1187
+ * own call of that cancel, answered as waiting, is in its window;
1188
+ * `unknown`, nothing says whether a cancel waited. The persistent
1189
+ * subconscious (`noteAuthor`) is told which, by a loss notice kept and
1190
+ * tried again as the others are (`tune-out:note-loss-untold` where its
1191
+ * write fails). Not traced: a hold no stamp covers because none was ever
1192
+ * written (a first start on a version that stamps its stops), one whose
1193
+ * release already told a waiting note's loss, one whose loss the stop
1194
+ * kept, and one already told as much.
1195
+ */
1196
+ | (TraceEventBase & {
1197
+ type: 'tune-out:stop-unrecorded';
1198
+ serverId: string;
1199
+ channelId: string;
1200
+ epochId: string;
1201
+ scope?: 'all-except';
1202
+ noteAuthor: string;
1203
+ found: 'delivered' | 'ran' | 'asked' | 'unknown';
1204
+ })
1205
+ /**
1206
+ * The notice telling a lost note's author (`noteAuthor`) of the loss (a
1207
+ * `tune-out:deferred-cancel-dropped` with `noteLost`) was not written.
1208
+ * `write-failed`: writing it threw (`error`). It is kept, and tried again
1209
+ * whenever held writes are stored and every 60 s while none are, until it
1210
+ * is written. One for the persistent subconscious is kept in the store
1211
+ * too, so a stop leaves it there and the next boot tries it again; a
1212
+ * reader fork's is dropped at a stop. This traces its first failure only,
1213
+ * a later boot's included, and each later one is logged. `author-gone`:
1214
+ * the framework wrote nothing, as no agent of that name is registered (a
1215
+ * reader fork whose run has ended): the loss reaches no one, and the
1216
+ * notice is not kept. For the all-except hold (`scope`), the channel is
1217
+ * its excepted one.
1218
+ */
1219
+ | (TraceEventBase & {
1220
+ type: 'tune-out:note-loss-untold';
1221
+ serverId: string;
1222
+ channelId: string;
1223
+ epochId: string;
1224
+ scope?: 'all-except';
1225
+ noteAuthor: string;
1226
+ reason: 'write-failed' | 'author-gone';
1227
+ error?: string;
1228
+ })
1229
+
891
1230
  /** A reader fork ended in prose without `deliver_summary`; its final prose was delivered as its report. */
892
1231
  | (TraceEventBase & {
893
1232
  type: 'tune-out:reader-prose-delivered';
@@ -915,10 +1254,8 @@ export type TraceEvent =
915
1254
  channelId: string;
916
1255
  epochId: string;
917
1256
  trigger: 'cadence' | 'wake' | 'cancel';
918
- /** Held messages the fork was handed, stored and queued. */
1257
+ /** Held messages the fork was handed. */
919
1258
  held: number;
920
- /** Of those, the ones still queued behind the resident's turn. */
921
- queued: number;
922
1259
  })
923
1260
 
924
1261
  /**
@@ -940,9 +1277,30 @@ export type TraceEvent =
940
1277
  returned: number;
941
1278
  })
942
1279
 
1280
+ /**
1281
+ * The persistent subconscious's window start was set by index ordinal
1282
+ * (#291): `fixed`, a tune-out's start fixed once no row the subconscious
1283
+ * is owed stored before the start was out of its window, and kept for its
1284
+ * epochs; `clamped`, a kept start (`kept`) past its window's index length
1285
+ * on the store's branch now (one a rollback made shorter), set at the
1286
+ * length instead.
1287
+ */
1288
+ | (TraceEventBase & {
1289
+ type: 'tune-out:subconscious-window';
1290
+ agentName: string;
1291
+ /** The tune-outs that start there. */
1292
+ epochIds: string[];
1293
+ how: 'fixed' | 'clamped';
1294
+ /** The ordinal the window starts at now. */
1295
+ ordinal: number;
1296
+ /** For `clamped`, the ordinal kept for them. */
1297
+ kept?: number;
1298
+ })
1299
+
943
1300
  // 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.
1301
+ // `agent-created` is the creation event: it names the kind of agent, what
1302
+ // ends it, and what happens to it when its spawner ends, for whatever a
1303
+ // host records or decides on them.
946
1304
  | (TraceEventBase & {
947
1305
  type: 'dendrite:agent-created';
948
1306
  agentName: string;
@@ -992,7 +1350,7 @@ export type TraceEvent =
992
1350
  by?: string;
993
1351
  reason?: string;
994
1352
  })
995
- /** The message entered the recipient's store (not merely queued for it). */
1353
+ /** The message entered the recipient's store (not merely held for it). */
996
1354
  | (TraceEventBase & {
997
1355
  type: 'dendrite:mail-delivered';
998
1356
  mailId: string;
@@ -1000,7 +1358,10 @@ export type TraceEvent =
1000
1358
  from: string;
1001
1359
  to: string;
1002
1360
  })
1003
- /** Queued for the recipient's next boundary; `mail-delivered` follows when it lands. */
1361
+ /** Held in memory behind a live surgery (the operator's switch awaited),
1362
+ * or kept for a recipient whose context manager refuses its work after a
1363
+ * failed re-initialization; `mail-delivered` follows when a release
1364
+ * stores it. */
1004
1365
  | (TraceEventBase & {
1005
1366
  type: 'dendrite:mail-deferred';
1006
1367
  mailId: string;
@@ -1029,6 +1390,8 @@ export type TraceEvent =
1029
1390
  messageId: string;
1030
1391
  recipients: string[];
1031
1392
  held: string | null;
1393
+ /** The suppress rule that took the event, when one did. */
1394
+ suppressed?: string;
1032
1395
  wake: boolean;
1033
1396
  gatePass: boolean;
1034
1397
  })
@@ -1048,6 +1411,130 @@ export type TraceEvent =
1048
1411
  error: string;
1049
1412
  })
1050
1413
 
1414
+ // The presentation index (#291, src/presentation.ts): which stored rows
1415
+ // each agent's window holds, in the order its requests carried them.
1416
+ | (TraceEventBase & {
1417
+ /**
1418
+ * Rows entered an agent's window (context-manager's presentRows), at
1419
+ * one of its presentation points (`occasion`): `count` bodies, a
1420
+ * sharded one counted once. At `rebase`, the store's branch moved to a
1421
+ * branch with no window for the agent, and its window there was
1422
+ * written down: `count` is the bodies it holds.
1423
+ */
1424
+ type: 'presentation:presented';
1425
+ agentName: string;
1426
+ occasion: PresentationOccasion;
1427
+ count: number;
1428
+ /** At a tool boundary: the first row that couldn't join the live
1429
+ * stream (a tool block, or a row named as the agent), where the rows
1430
+ * presented there stop. It and the rows after it wait for the turn's
1431
+ * end. */
1432
+ cutAt?: string;
1433
+ /** How many of them carry no audience stamp (stored by a host's
1434
+ * writer that doesn't stamp), presented to the slot's owners and
1435
+ * its observers. */
1436
+ unstamped?: number;
1437
+ })
1438
+ | (TraceEventBase & {
1439
+ /** An agent's own rows that were stored and not in its window, found
1440
+ * when the agent was taken on or at boot, were presented to it. */
1441
+ type: 'presentation:repaired';
1442
+ agentName: string;
1443
+ count: number;
1444
+ })
1445
+ | (TraceEventBase & {
1446
+ /**
1447
+ * A row was stamped for agents of which none reads the slot it is
1448
+ * stored in (`deliveredTo`'s), so no window presents it by its
1449
+ * audience. It is stored as named, never widened: observers of the
1450
+ * slot see it only as their edge shows it.
1451
+ */
1452
+ type: 'presentation:unreadable-audience';
1453
+ messageId?: string;
1454
+ audience: string[];
1455
+ slot: MessageSlotRef;
1456
+ deliveredTo: string;
1457
+ })
1458
+ | (TraceEventBase & {
1459
+ /** A presentation failed; the rows it didn't present stay out of the
1460
+ * agent's window for its next presentation point. At a fresh turn's
1461
+ * start (`turn-start`, `assembly`), the start fails too. With
1462
+ * `legacy`, the agent was left unpresented (legacy mode) until a
1463
+ * later move of the store's branch: its window the whole record as
1464
+ * before the index, or, where its strategy couldn't follow a move to
1465
+ * a branch that holds a window, that window, writes for it waiting in
1466
+ * memory: at `adopt`, its window couldn't be
1467
+ * written down (another version's index format, or a failed write);
1468
+ * at `rebase`, after the store's branch moved, its window couldn't be
1469
+ * written down on the new branch, or its context's strategy couldn't
1470
+ * follow the move (`error` says which). The framework logs that and
1471
+ * raises an ops alert (`presentation-legacy`). Without it, at
1472
+ * `adopt` or `rebase`, presenting the agent's own rows failed, or
1473
+ * taking out the rows the write-down took in that aren't the
1474
+ * agent's did, which is tried again at its next turn start or point
1475
+ * at rest. */
1476
+ type: 'presentation:failed';
1477
+ agentName: string;
1478
+ occasion: PresentationOccasion;
1479
+ error: string;
1480
+ /** The rows the presentation named that didn't enter the window,
1481
+ * each body by the id that names it, where they are known (a write
1482
+ * of the window that failed). Absent where a read failed before the
1483
+ * rows could be named. */
1484
+ messageIds?: string[];
1485
+ /** Set where the failure left the agent in legacy mode. */
1486
+ legacy?: true;
1487
+ })
1488
+ | (TraceEventBase & {
1489
+ /** At a tool boundary's hand-off, the newest rows of the agent's
1490
+ * window weren't the rows the stream was about to be given, in that
1491
+ * order. The stream's later rounds are noted as unvouched, so their
1492
+ * thinking is left out at the next compile rather than refused. */
1493
+ type: 'presentation:hand-off-mismatch';
1494
+ agentName: string;
1495
+ expected: string[];
1496
+ tail: string[];
1497
+ })
1498
+ | (TraceEventBase & {
1499
+ /**
1500
+ * Rows were taken out of an agent's window. Every reason but `shed`
1501
+ * and `elsewhere` is a removal from the record made through another
1502
+ * agent's context, which context-manager tombstones in that context's
1503
+ * window only: the rows it removed leave this agent's window too, each
1504
+ * at its own place, so no other row's place moves (`hide`, `suppress` on its
1505
+ * fork, a coalescer's `coalescer`, a module's `module`, a suppression
1506
+ * a start finished, `resume`, and a refusal rewind's shed from a
1507
+ * window that is still the record, `rewind`), or that no live context
1508
+ * heard, found at boot (`boot`). `shed` is a refusal rewind's or an
1509
+ * inference failure's shed on a presented window: the rows leave the
1510
+ * agent's own window as an undone turn's do, and stay in the record.
1511
+ * `elsewhere` is a window written down from the shared record when the
1512
+ * agent was taken on, or after a branch move: the rows it took in that
1513
+ * carry an audience stamp and aren't the agent's (another agent's own
1514
+ * rows, mail stamped for others, a held row) leave it, and stay in the
1515
+ * record (decision 1).
1516
+ */
1517
+ type: 'presentation:retracted';
1518
+ agentName: string;
1519
+ messageIds: string[];
1520
+ reason: PresentationRetractReason;
1521
+ })
1522
+ | (TraceEventBase & {
1523
+ /** An undo or a redo on the presentation index, counted in bodies.
1524
+ * An undo's `retracted` is the bodies from the turn's checkpoint on
1525
+ * that left the agent's window, the turn's own and what arrived
1526
+ * after it, and it carries no `represented`. A redo's
1527
+ * `retracted` is the rows that entered the window after the undo, and
1528
+ * any of the undo's own still in it after an undo cut short, which
1529
+ * left so the redone rows come back after their prefix; its
1530
+ * `represented` is the undone rows presented again. No branch
1531
+ * moved. */
1532
+ type: 'window:undone';
1533
+ agentName: string;
1534
+ retracted: number;
1535
+ represented?: number;
1536
+ })
1537
+
1051
1538
  // Held prose drafts (src/prose-drafts.ts): plain speech kept privately
1052
1539
  // instead of sent; a resident's explicit resend; a deliberate dismissal.
1053
1540
  | (TraceEventBase & {
@@ -1072,7 +1559,22 @@ export type TraceEvent =
1072
1559
  draftIds: string[];
1073
1560
  });
1074
1561
 
1562
+ /** Why rows left an agent's window (`presentation:retracted`). */
1563
+ export type PresentationRetractReason = 'hide' | 'suppress' | 'coalescer' | 'module' | 'resume' | 'rewind' | 'shed' | 'boot' | 'elsewhere';
1564
+
1075
1565
  /**
1076
1566
  * Listener for trace events.
1077
1567
  */
1078
1568
  export type TraceEventListener = (event: TraceEvent) => void;
1569
+
1570
+ /**
1571
+ * A trace as raised, before `emitTrace` stamps its `timestamp`: one of the
1572
+ * union's members without that field.
1573
+ */
1574
+ export type TraceEventInput = WithoutTimestamp<TraceEvent>;
1575
+
1576
+ type Fields<Shape> = { [Key in keyof Shape]: Shape[Key] };
1577
+
1578
+ type WithoutTimestamp<Event> = Event extends unknown
1579
+ ? { [Key in keyof Event as Key extends 'timestamp' ? never : Key]: Event[Key] }
1580
+ : never;