@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
@@ -0,0 +1,746 @@
1
+ /**
2
+ * The presentation index (#291): which stored rows each agent's window
3
+ * holds, and when a row enters it.
4
+ *
5
+ * The store's record keeps every write in the order it arrived. An agent's
6
+ * window is another order over the same rows: the rows presented to it, in
7
+ * the order its requests carry them (context-manager's window index,
8
+ * `presentRows`; a row presented at rest is in the window before a request
9
+ * has carried it). While one agent writes one slot, and nothing else writes
10
+ * it during that agent's turns, the two orders are the same. Once others
11
+ * write it during a turn (another agent sharing the slot, a module), or one
12
+ * agent reads another's, they differ: a row
13
+ * another agent stored during my turn sits inside my turn in the record, but
14
+ * my requests carried it only at my next tool boundary or turn start, so a
15
+ * compile that sent it where the record has it would change my turn's prefix
16
+ * (the prompt cache misses, and a reply's signed thinking is sent under a
17
+ * prefix it wasn't minted under).
18
+ *
19
+ * This module decides who each stored row is presented to and when, through
20
+ * each live agent's own context manager. It reads the row's audience stamp
21
+ * (dendrite/audience.ts), the slot the row is stored in, and the registry's
22
+ * slots and observe edges (bearingOf), and presents:
23
+ *
24
+ * - an agent's own rows as they are written, through the own-row sink
25
+ * (storeOwnRow, Agent and ToolResultGuard call it once the row is stored),
26
+ * or at its next presentation point when a writer held one back;
27
+ * - another writer's rows meant for it (arrivals) at its turn start, at its
28
+ * tool boundary as a prefix the live stream can carry, at its turn's end,
29
+ * and at once while it has no turn alive (present at rest);
30
+ * - nothing of others' while the host is quiesced (frozen) or under a
31
+ * surgery hold, which freeze every window but for an agent's own rows (a
32
+ * hold by its own refusals: under it every agent is turn-alive and no
33
+ * turn starts);
34
+ * - the arrivals a rollback's cut took out of an agent's window only at its
35
+ * next turn start (holdUntilStart), so the cut holds until it speaks.
36
+ *
37
+ * Arrivals are read from the index itself (getUnpresentedMessages filtered
38
+ * by bearingOf), never from the store's head: a crashed turn's arrivals and
39
+ * rows imported at boot are arrivals by construction. A shared derivation's
40
+ * inheritance isn't an arrival: it reaches the child through the window it
41
+ * was derived with, and bearingOf reads an unstamped row at or before the
42
+ * derivation's checkpoint (derivedAt) as elsewhere. The one scalar kept is
43
+ * a memo of where a scan may start, reset whenever the branch, the index
44
+ * length or the reader's facts moved under it.
45
+ *
46
+ * The module presents only for an agent it has taken on (adopt) whose
47
+ * manager is in presented mode: it never calls presentRows on a manager in
48
+ * legacy mode but for the deliberate write-down at adopt, and again at a
49
+ * rebase after the store's branch moved to a branch whose window index for
50
+ * that manager was never written (one made before the write-down), since
51
+ * any presentRows there writes the whole record down and switches the mode.
52
+ * The rows of the record the write-down took in that carry an audience
53
+ * stamp and are elsewhere to the agent (another agent's own rows, mail
54
+ * stamped for others, a held row) are then taken out (retractForeign), so a
55
+ * window written down after other agents' windows holds only the rows an
56
+ * earlier release stored unstamped and the agent's own and its arrivals
57
+ * (decision 1).
58
+ * Nothing in it throws into a writer: a failed presentation is traced and
59
+ * its rows stay out of the window for the next point. A fresh turn start's
60
+ * also fails the start (presentAtStart).
61
+ *
62
+ * It never imports framework.ts, which imports it.
63
+ */
64
+ import type { ContentBlock } from '@animalabs/membrane';
65
+ import { type ContextManager, type MessageId, type MessageMetadata, type StoredMessage } from '@animalabs/context-manager';
66
+ import { type AgentRegistry } from './dendrite/registry.js';
67
+ import type { AgentName, MessageSlotRef, ObserveEdge } from './dendrite/types.js';
68
+ import type { WindowOrdinal } from './read-marks.js';
69
+ import type { PresentationRetractReason, TraceEventInput } from './types/trace.js';
70
+ export { heldFromResidents, suppressedRow } from './dendrite/audience.js';
71
+ /** Whether a stored row can join a live stream at a tool boundary: no tool
72
+ * blocks (the membrane's tool cycle) and not named as the agent itself (it
73
+ * would render as an assistant turn, a prefill). The #286 cut. */
74
+ export declare function isInjectableMidTurn(msg: {
75
+ participant: string;
76
+ content: ContentBlock[];
77
+ }, agent: {
78
+ isOwnParticipant(participant: string): boolean;
79
+ }): boolean;
80
+ /** What later compiles render from the store for the copies of one write
81
+ * that landed: one copy as it is, and two or more, the shards of a sharded
82
+ * body, as context-manager's autobiographical strategy (the one that
83
+ * shards on ingest) joins a body's consecutive shards: their non-text
84
+ * blocks, then one text block of their joined text. The join is that
85
+ * strategy's `mergeAdjacentBodyGroupRaw`, which context-manager doesn't
86
+ * export, so the rule is copied here. */
87
+ export declare function asCompiled(landed: ReadonlyArray<{
88
+ content: ContentBlock[];
89
+ }>): ContentBlock[];
90
+ /** A place in one agent's window on one branch: an index ordinal
91
+ * (ContextManager.ordinalOf, indexLength), never a store sequence. */
92
+ export type Position = WindowOrdinal;
93
+ /** Where an agent's window stood: its branch and its index length then. */
94
+ export interface WindowMark {
95
+ readonly branch: string;
96
+ readonly position: Position;
97
+ }
98
+ /** The row's place in `cm`'s window, or undefined for a row out of it (and every row in legacy mode). */
99
+ export declare function positionIn(cm: Pick<ContextManager, 'ordinalOf'>, id: MessageId): Position | undefined;
100
+ /** The place the next row presented in `cm`'s window will take (its index length, exclusive; 0 in legacy mode). */
101
+ export declare function windowEnd(cm: Pick<ContextManager, 'indexLength'>): Position;
102
+ /** Where `cm`'s window stands now, or null in legacy mode, where the window is the record and has no index. */
103
+ export declare function windowMarkOf(cm: Pick<ContextManager, 'windowMode' | 'indexLength' | 'currentBranch'>): WindowMark | null;
104
+ /**
105
+ * What a row in one agent's merged record is to that agent: its own row,
106
+ * an arrival (a row meant for it that another writer stored), or elsewhere
107
+ * (a row it is never presented: another agent's own round, mail for a
108
+ * co-resident, a held row for a resident, a row a suppress rule hid).
109
+ */
110
+ export type Bearing = 'own' | 'arrival' | 'elsewhere';
111
+ /** A slot an agent observes: the slot its edge reads, the edge, and the slot's owners. */
112
+ export interface ObservedSlot {
113
+ readonly slot: MessageSlotRef;
114
+ readonly edge: ObserveEdge;
115
+ readonly owners: readonly AgentName[];
116
+ }
117
+ /** What bearingOf needs to know of a reader, read from the registry (readerFacts). */
118
+ export interface ReaderFacts {
119
+ readonly name: AgentName;
120
+ /** The slot its own rows are stored in (registry.ownSlotOf). */
121
+ readonly ownSlot: MessageSlotRef | undefined;
122
+ /** The slots it observes, each through its edge. */
123
+ readonly observed: readonly ObservedSlot[];
124
+ /** Whether its window leaves held rows out: an agent whose own slot is the
125
+ * residents' slot, on the host's branch or a branch of its own (a shared
126
+ * fork, which carries the residents' view filter). */
127
+ readonly hidesHeld: boolean;
128
+ /** For a shared derivation, the parent's checkpoint: a row with no stamp
129
+ * at or before it is the parent's inheritance, not the child's arrival. */
130
+ readonly derivedAt?: number;
131
+ }
132
+ /** The registry queries readerFacts reads. */
133
+ export type ReaderRegistry = Pick<AgentRegistry, 'get' | 'ownSlotOf' | 'observedSlotOf' | 'slotOwners'>;
134
+ /** A reader's facts as the registry has them now. An agent it doesn't know has no slot and observes nothing. */
135
+ export declare function readerFacts(registry: ReaderRegistry, name: AgentName): ReaderFacts;
136
+ /**
137
+ * A reader's facts as the registry recorded them: its live record, else its
138
+ * newest ended one (registry.inspect). For a reader that has left, as a
139
+ * released fork or run has by the time its window is read for what it
140
+ * never read (AgentFramework.releasedWindow): readerFacts reads live
141
+ * records only, and would know nothing of it.
142
+ */
143
+ export declare function recordedReaderFacts(registry: Pick<AgentRegistry, 'inspect' | 'observedSlotOf' | 'slotOwners'>, name: AgentName): ReaderFacts;
144
+ /**
145
+ * Where a row bearingOf weighs is stored, as its caller read it: `'own'`,
146
+ * the reader's own slot (the own message store of its context, which
147
+ * getMessage and getAllMessages read), or another slot by its ref (an
148
+ * auxiliary view of its context, by namespace, or the own slot of the
149
+ * agent that wrote the row: slotOfRow, afterStore).
150
+ */
151
+ export type RowSlot = 'own' | MessageSlotRef;
152
+ /**
153
+ * What one row is to one reader, from the row's stamp, the reader's facts,
154
+ * and `slot`, the slot the row is stored in: the reader's own (`'own'`, or
155
+ * a ref sameSlot as its `ownSlot`), else a slot it may observe. undefined,
156
+ * a slot its caller couldn't name, is elsewhere.
157
+ *
158
+ * A row a suppress rule hid (suppressedRow) is elsewhere to every reader,
159
+ * in any slot: no view the framework sets renders it.
160
+ *
161
+ * In its own slot, with `stamp = audienceOf(metadata)`:
162
+ * - its own row (`ownRowOf` names it): own;
163
+ * - another agent's own row: an arrival when one of the reader's edges
164
+ * names that agent and reads this slot (observesOwnRows: a resident's
165
+ * `AgentConfig.observes`, the relationship decision 1 says another
166
+ * agent's rounds reach an agent only through), unless it is that agent's
167
+ * stored context injection, which the reader's view leaves out;
168
+ * elsewhere otherwise, as it is for every resident by default;
169
+ * - a row whose audience names it: an arrival, unless it is held and the
170
+ * reader leaves held rows out, or it is another agent's stored injection,
171
+ * which the reader's view leaves out too (what the reader's own view
172
+ * leaves out is never its arrival: main's #853 asks that view, agentSees,
173
+ * at a tool boundary);
174
+ * - a row stamped otherwise (mail for a co-resident, a held row): elsewhere;
175
+ * - a row with no stamp (stored by a host's writer that doesn't stamp): an
176
+ * arrival for the slot's owners, as it reads today, unless it is a shared
177
+ * derivation's inheritance (at or before `derivedAt`), held for a reader
178
+ * that leaves held rows out, or another agent's stored injection.
179
+ *
180
+ * In another slot: an arrival when an edge of the reader's that reads that
181
+ * slot shows it, by that edge's rules and that slot's owners
182
+ * (observedRowFor); elsewhere when none does, or the reader has no edge on
183
+ * the slot. A pure function of its arguments: it runs for a released agent,
184
+ * which has no live manager, too.
185
+ */
186
+ export declare function bearingOf(row: Pick<StoredMessage, 'sequence' | 'participant' | 'metadata'>, reader: ReaderFacts, slot: RowSlot | undefined): Bearing;
187
+ /**
188
+ * Whether a reader is shown `owner`'s own rows through an observe edge, as
189
+ * bearingOf reads its edges: an edge on another slot that `owner` owns, or
190
+ * an edge that names `owner` and reads the reader's own slot (a resident
191
+ * observing a co-resident, AgentConfig.observes). An edge on the reader's
192
+ * own slot shows only the agent it names, though every resident owns that
193
+ * slot.
194
+ */
195
+ export declare function observesOwnRows(reader: ReaderFacts, owner: AgentName): boolean;
196
+ /**
197
+ * Whether a row stamped for `audience` and stored in `slot` is meant only for
198
+ * agents that can't read it: its audience names someone, and none of them
199
+ * reads the slot, as an owner or through an observe edge (registry
200
+ * readersOf). Such a row is stored as named, never widened (no window
201
+ * presents it by its audience), and traced as a routing fault. A row whose
202
+ * audience names an observer of the slot is no fault: its edge shows it
203
+ * (observedRowFor), as one naming an owner is presented in that owner's
204
+ * window.
205
+ */
206
+ export declare function audienceFault(audience: readonly AgentName[], slot: MessageSlotRef | undefined, registry: Pick<AgentRegistry, 'readersOf'>): boolean;
207
+ /** Where one presentation into an agent's window happened. */
208
+ export type PresentationOccasion =
209
+ /** An agent's own row, presented as it was stored. */
210
+ 'write'
211
+ /** A turn's start, before its compile: its own rows and its arrivals. */
212
+ | 'turn-start'
213
+ /** A start's assembly of a wake's own rows, before its compile. */
214
+ | 'assembly'
215
+ /** The backstop before every compile: its own rows only. */
216
+ | 'compile'
217
+ /** A tool boundary: the round's rows, then a prefix of its arrivals. */
218
+ | 'tool-boundary'
219
+ /** The check before a boundary hands the stream its rows. */
220
+ | 'hand-off'
221
+ /** A turn's end. */
222
+ | 'turn-end'
223
+ /** An agent with no turn alive, presented a row at its write, or at boot. */
224
+ | 'at-rest'
225
+ /** Rows handed a reader fork as framing. */
226
+ | 'framing'
227
+ /** An agent taken on: its window written down and its own rows repaired. */
228
+ | 'adopt'
229
+ /** The store's branch moved under a live agent (rebase): its window on the
230
+ * new branch written down, where that branch had none, and its own rows
231
+ * repaired. */
232
+ | 'rebase';
233
+ /** A context manager as the module uses it. */
234
+ export type WindowManager = Pick<ContextManager, 'presentRows' | 'retractRows' | 'getUnpresentedMessages' | 'getPresentedMessages' | 'ordinalOf' | 'indexLength' | 'windowStatusOf' | 'windowMode' | 'getMessage' | 'currentBranch' | 'isClosed' | 'retractRemoved' | 'retractAbsentRows' | 'getStore'>;
235
+ /** An agent as the module presents to it. The framework's Agent is one. */
236
+ export interface PresentedAgent {
237
+ readonly name: AgentName;
238
+ getContextManager(): WindowManager;
239
+ isOwnParticipant(participant: string): boolean;
240
+ /** Where the agent tells of its own rows once they are stored (Agent.setOwnRowSink). */
241
+ setOwnRowSink?(sink: ((ids: readonly MessageId[]) => void) | undefined): void;
242
+ }
243
+ /** The traces the module emits, as a host passes them on. */
244
+ export type PresentationTrace = Extract<TraceEventInput, {
245
+ type: `presentation:${string}`;
246
+ }>;
247
+ /** What the module reads of its host (the framework). */
248
+ export interface PresentationHost {
249
+ /** Every agent registered now, a shared fork on its own branch included. */
250
+ liveAgents(): Iterable<PresentedAgent>;
251
+ readonly registry: Pick<AgentRegistry, 'get' | 'ownSlotOf' | 'observedSlotOf' | 'readersOf' | 'slotOwners'>;
252
+ /**
253
+ * Whether the agent's logical turn is alive: a turn token, a continuation
254
+ * or retry on its way, a live stream, or a tool cycle pending. Nothing but
255
+ * its own rows and its boundary's arrivals is presented to it then.
256
+ */
257
+ turnAlive(name: AgentName): boolean;
258
+ /**
259
+ * Whether others' rows are frozen out of every window: the host
260
+ * quiesced, or booting until create()'s pass over the windows. Own rows
261
+ * still present. A surgery's hold isn't asked here: its
262
+ * own refusals keep every point that reads this from being reached under
263
+ * it (the framework's `frozen`, where the host is built).
264
+ */
265
+ frozen(): boolean;
266
+ emitTrace(event: PresentationTrace): void;
267
+ }
268
+ /** A row a tool boundary presented for the live stream to carry: one per body, by the id that names it. */
269
+ export interface HeardRow {
270
+ readonly id: MessageId;
271
+ readonly participant: string;
272
+ /** The body as the store holds it, a sharded one's shards joined as compiles join them (asCompiled). */
273
+ readonly content: ContentBlock[];
274
+ readonly metadata?: MessageMetadata;
275
+ }
276
+ /** What a tool boundary presented beyond the round's own rows. */
277
+ export interface BoundaryPresentation {
278
+ /** The rows the stream carries next, in window order. */
279
+ readonly heard: readonly HeardRow[];
280
+ /** The first row the stream can't carry, where the rows presented stop. */
281
+ readonly cutAt?: MessageId;
282
+ }
283
+ /**
284
+ * An agent holding a row: in its window, at a place (`'window'`); in a
285
+ * window that is still the whole record (`'legacy'`), which holds every row
286
+ * its merged record does; or handed it as a reader fork's framing
287
+ * (`'framing'`).
288
+ */
289
+ export type Holder = {
290
+ readonly agent: AgentName;
291
+ readonly via: 'window';
292
+ readonly position: Position;
293
+ } | {
294
+ readonly agent: AgentName;
295
+ readonly via: 'legacy';
296
+ } | {
297
+ readonly agent: AgentName;
298
+ readonly via: 'framing';
299
+ };
300
+ /** What a presentation listener hears: the rows that entered one agent's window, in order, and where. */
301
+ export interface PresentedEvent {
302
+ readonly agentName: AgentName;
303
+ readonly occasion: PresentationOccasion;
304
+ readonly rows: readonly StoredMessage[];
305
+ }
306
+ /**
307
+ * The presentation index's decisions, over each live agent's context
308
+ * manager. The framework constructs it in create() and calls it at each
309
+ * presentation point.
310
+ */
311
+ export declare class AgentPresentation {
312
+ private readonly host;
313
+ private readonly adopted;
314
+ private readonly memos;
315
+ /** Bumped when a registration may have changed what a row is to someone: every memo is then stale. */
316
+ private generation;
317
+ /** Rows handed each reader fork as framing (noteFramed), in memory. */
318
+ private readonly framed;
319
+ /** Reader forks whose framing may not all be in their window yet: framed before they were taken on, or whose framing's presentation failed. */
320
+ private readonly framedPending;
321
+ private readonly listeners;
322
+ /** Own rows whose presentation at their write failed, per manager (presentOwn), until they enter its window. */
323
+ private readonly failedOwn;
324
+ /** Arrivals a rollback took out of each manager's window, kept out of it at rest until the agent's next turn start (holdUntilStart), on the branch the rollback left the store on. */
325
+ private readonly heldUntilStart;
326
+ /** Agents the boot's pass at rest left out (repairAndRest's `restExcept`): no point at rest presents their arrivals until their next turn start. */
327
+ private readonly restWithheld;
328
+ /** Read-only handles on the slots a manager merges, by namespace (slotOfRow): made only for a reader whose context merges more than one. */
329
+ private readonly slotReaders;
330
+ constructor(host: PresentationHost);
331
+ /** Take on every live agent (adopt), then present what each is owed at rest (repairAndRest). */
332
+ boot(): void;
333
+ /**
334
+ * Take an agent on. Once per manager object: a manager in legacy mode has
335
+ * its window written down (presentRows([]), which also finishes a
336
+ * write-down cut short), the stamped rows it took in that are elsewhere to
337
+ * the agent are taken out (retractForeign; where that fails, at the
338
+ * agent's next turn start or point at rest), and the agent's own rows
339
+ * stored and not in its window are presented to it, in record order (an
340
+ * undone turn's rows are not: getUnpresentedMessages leaves them out). A
341
+ * window that can't be
342
+ * written down (another version's index format, or a failed write; not a
343
+ * write-down that threw once its record was written, which reads as
344
+ * presented: writeDown) leaves the agent in legacy mode, traced once,
345
+ * until a move of the store's branch writes its window down on the new
346
+ * branch (rebase): its window is the whole record, as before the index.
347
+ * Then, every time, the agent's own-row sink is installed, one left in
348
+ * legacy mode's too, so the other readers of its slot hear of its rows
349
+ * (presentOwn), and every scan memo is dropped, since a registration can
350
+ * change who reads a slot.
351
+ */
352
+ adopt(agent: PresentedAgent): void;
353
+ /**
354
+ * The store's branch moved under an agent taken on (a host's switchBranch,
355
+ * a rollback's or a suppression's switch, a failed surgery's restore).
356
+ * Its manager's window index is the new branch's: on a branch made before
357
+ * the agent's write-down (every branch an earlier release's store holds,
358
+ * or a rollback into rows the write-down presented, which branchAt cuts
359
+ * at their own sequence) there is none, and the window would be the
360
+ * whole record for the rest of the process. So, as at adopt, such a
361
+ * window is written down (presentRows([]), traced as presented at
362
+ * `'rebase'`), the stamped rows it took in that are elsewhere to the
363
+ * agent, a co-resident's own rows presented on the old branch among them,
364
+ * are taken out (retractForeign), and the agent's own rows stored and not
365
+ * in its window are presented to it (the own-row sweep). A window that is presented on the
366
+ * new branch is presented again for an agent left in legacy mode by an
367
+ * earlier branch, its own-row sink installed. A window that can't be
368
+ * written down, or a manager whose strategy couldn't follow the move
369
+ * (`failure`, from its re-initialization by the framework, #353), leaves
370
+ * the agent in legacy mode until the next move, traced as
371
+ * presentation:failed at `'rebase'`. Arrivals aren't presented here: the
372
+ * framework's surgery release presents what each agent is owed. Never
373
+ * throws.
374
+ */
375
+ rebase(agent: PresentedAgent, failure?: unknown): void;
376
+ /**
377
+ * Write `agent`'s window down where its manager is in legacy mode
378
+ * (presentRows([]), which also finishes a write-down cut short), and say
379
+ * whether the window is presented after it. A write-down that fails, or
380
+ * leaves the manager in legacy mode, pins the agent in legacy mode
381
+ * (`state.pinnedLegacy`), traced as presentation:failed at `occasion`
382
+ * with `legacy`, which the host logs and alerts. A
383
+ * write-down that throws once its record is written (the store's own work
384
+ * after a write, such as a snapshot, failing) has written the window
385
+ * down: the manager reads its index again after any throw, so a window
386
+ * that reads as presented then is taken as one, and the agent is
387
+ * presented for, with a log line. A write-down at a rebase is traced as
388
+ * presented, with the bodies the window holds; a read for that trace
389
+ * which throws is logged and the trace skipped, the window presented.
390
+ */
391
+ private writeDown;
392
+ /**
393
+ * Take out of the agent's window the rows a write-down from the record
394
+ * took in that aren't its (decision 1): each row that carries an audience
395
+ * stamp and that bearingOf reads as elsewhere to the agent, such as
396
+ * another agent's own row, mail stamped for a co-resident, or a held row
397
+ * for a window that leaves held rows out. Each leaves its place as a plain
398
+ * retraction does, so it reads as arrived, and it stays elsewhere, so no
399
+ * later point presents it. Two kinds of row stay: an unstamped row, which
400
+ * a release before the stamp stored and the write-down migrates whole,
401
+ * and a shared derivation's inheritance (at or before its checkpoint),
402
+ * which is the child's history. Nothing is taken out for an agent the
403
+ * registry has no slot for. Run at every adopt and rebase, not only
404
+ * after a write-down this process made, so a window whose write-down
405
+ * landed and whose retraction didn't (a crash between the two records, a
406
+ * failed write) is repaired the next time it is taken on. Rows are
407
+ * weighed by the agent's relationships now, not by those they entered
408
+ * under, so a row the module presented is taken out too where it is
409
+ * elsewhere to the agent now: an observed agent's own row, presented
410
+ * through an observe edge the agent no longer has (a restart whose
411
+ * configuration dropped it). A reader fork's framing is passed over. Traced as
412
+ * presentation:retracted, reason `elsewhere`; a failure is traced as
413
+ * presentation:failed at `occasion`, and the rows stay in the window
414
+ * until the agent's next turn start or point at rest takes them out
415
+ * (`retractPending`, tried there until it succeeds), or the next adopt or
416
+ * rebase; a fresh turn start that can't take them out fails
417
+ * (presentAtStart). Never throws.
418
+ */
419
+ private retractForeign;
420
+ /** The rows of the agent's window retractForeign takes out, each body by its first shard; none for an agent the registry has no slot for. */
421
+ private foreignRows;
422
+ /** retractForeign again, where it failed before (`retractPending`). */
423
+ private retryRetraction;
424
+ /** Let an agent go: its sink off, and what the module kept for it (its memo, its framing, its held arrivals) dropped. */
425
+ forget(agent: PresentedAgent): void;
426
+ /**
427
+ * For every live agent the module presents to and whose turn isn't alive:
428
+ * its own rows stored and not in its window (the own-row sweep, traced as
429
+ * presentation:repaired), then whatever it is owed at rest (presentAtEnd).
430
+ * Boot runs it once every agent is taken on and the stored rows are in,
431
+ * whether or not an adopt repaired anything. An agent in `restExcept` has
432
+ * its own rows swept and nothing else: the boot couldn't read what it is
433
+ * owed to ask the wakes its rows owe, so they stay out of its window until
434
+ * its next turn start, which no wake was asked for. Until then no point at
435
+ * rest presents its arrivals (a row stored for it while it is idle, a
436
+ * turn's end), only its own rows, so a later boot finds them out of its
437
+ * window and reads them again.
438
+ */
439
+ repairAndRest(options?: {
440
+ restExcept?: ReadonlySet<AgentName>;
441
+ }): void;
442
+ /** Whether the module presents for this agent: taken on, its manager open and in presented mode. */
443
+ presenting(agent: PresentedAgent): boolean;
444
+ /**
445
+ * Present the agent's own rows now, in the order given, those not in its
446
+ * window yet, even while the host is frozen; then tell the other readers
447
+ * of its slot (afterStore), whatever became of that: a presentation that
448
+ * threw, or an agent the module doesn't present for (a failed rebase
449
+ * leaves its sink on). The own-row sink calls it. It is for a row the
450
+ * agent's stream carries (its round, its results, a notice injected at its
451
+ * boundary), one written before its next compile or after its stream's
452
+ * last request, or one written while it has no turn alive: any other row
453
+ * would enter a live window its requests don't carry, so its writer holds
454
+ * it back (storeOwnRow's `present: false`) for the next point's sweep.
455
+ *
456
+ * An own row whose presentation here failed (a transient store error) is
457
+ * kept, and presented ahead of the rows given at the agent's next call,
458
+ * in record order, while it is still out of the window: its window's
459
+ * ordinals never move, so a row written after it and presented first
460
+ * would stay ahead of it for good (a round's results ahead of its reply,
461
+ * which every later compile would send so). It is kept until the agent's
462
+ * next turn start or tool boundary, whose own-row sweep presents it by
463
+ * that point's rule, or leaves it for the next point when that fails
464
+ * too: a request compiled, or a stream handed its rows, without it
465
+ * mustn't find it in the window ahead of a reply it didn't come before.
466
+ * A row its writer held back is never kept: it waits for the next point's
467
+ * sweep. Never throws.
468
+ */
469
+ presentOwn(agent: PresentedAgent, ids: ReadonlyArray<MessageId | undefined>): void;
470
+ /**
471
+ * Rows `writer` just stored, in its own slot: each other reader of that
472
+ * slot (its owners and its observers) whose turn isn't alive, and the
473
+ * writer itself, is presented what it is owed at once, when one of the
474
+ * rows is its own or an arrival for it (present at rest). A reader with a
475
+ * turn alive takes them at its next point. Frozen, only own rows present.
476
+ * The module needn't present for the writer: one left in legacy mode
477
+ * tells the readers of its slot too. Each reader is weighed apart, so one
478
+ * whose window can't be read is traced and the others are still told.
479
+ * Never throws.
480
+ */
481
+ afterStore(writer: PresentedAgent, ids: ReadonlyArray<MessageId | undefined>): void;
482
+ /**
483
+ * A turn's start, before its compile. `'turn-start'` (a fresh start) and
484
+ * `'assembly'` (the rows a wake assembled for it) present, in one call and
485
+ * record order, the agent's own rows not in its window and its arrivals
486
+ * (none while frozen); `'compile'`, the backstop before every compile,
487
+ * fresh or resumed, its own rows only. Returns the arrivals presented, one
488
+ * per body, for the start to weigh. A fresh start ends a rollback's hold
489
+ * on the arrivals its cut returned (holdUntilStart): they enter with the
490
+ * rest, in record order, and the hold ends once they have, so a start
491
+ * that fails keeps it, and so does one while frozen, which presents no
492
+ * arrival; so does an agent the boot's pass at rest left out
493
+ * (repairAndRest's `restExcept`). A fresh start's presentation that fails (a read
494
+ * of the window or the record that throws, or a write of the window that
495
+ * leaves a row out) is traced, and then throws, so the start fails rather
496
+ * than compile without what it was started for, which waits outside the
497
+ * window for the next point. So does a fresh start where rows a
498
+ * write-down took in that aren't the agent's are still in its window
499
+ * (retractForeign failed again here), rather than compile with them. The
500
+ * backstop's is traced, and its compile goes on.
501
+ */
502
+ presentAtStart(agent: PresentedAgent, occasion: 'turn-start' | 'assembly' | 'compile'): StoredMessage[];
503
+ /**
504
+ * A tool boundary. First the round's own rows on the wire (`wire`: its
505
+ * reply, its results, a clock row due), those not in the window yet, in
506
+ * order; if that fails, nothing more. Then, unless the host is frozen or
507
+ * the stream can't carry injected rows (`injects` false), the agent's own
508
+ * rows not in its window and its arrivals, by bodies in record order, up
509
+ * to the first body the stream can't carry (isInjectableMidTurn: a tool
510
+ * block, or a row named as the agent), presented in one call: each body
511
+ * whole, named by its first shard not in the window. Those are what the
512
+ * stream carries next (`heard`); the cut body and those after it wait for
513
+ * the turn's end. A presentation cut short hears only the bodies wholly in
514
+ * the window. A read of the window or the record that throws is traced as
515
+ * presentation:failed, and the stream hears nothing: what wasn't presented
516
+ * waits for the next point, and the hand-off that follows checks the
517
+ * window as it then stands. Never throws, so the boundary goes on to hand
518
+ * the stream its results.
519
+ */
520
+ presentAtBoundary(agent: PresentedAgent, wire: ReadonlyArray<MessageId | undefined>, options: {
521
+ injects: boolean;
522
+ }): BoundaryPresentation;
523
+ /**
524
+ * A turn's end, and an agent at rest: when its logical turn isn't alive,
525
+ * its own rows not in its window and its arrivals (none while frozen), in
526
+ * one call and record order. Nothing while the turn is alive. Idempotent.
527
+ * Returns the arrivals presented, one per body.
528
+ */
529
+ presentAtEnd(agent: PresentedAgent): StoredMessage[];
530
+ /**
531
+ * The rows a rollback's branch cut took out of the agent's window and
532
+ * kept in the record (its `returnedToArrivals`, #291): they are arrivals
533
+ * again, and wait outside the window until the agent's next turn start
534
+ * (presentAtStart's `'turn-start'` or `'assembly'`), which presents them
535
+ * with whatever else it is owed, in record order (a start that fails
536
+ * keeps them held). Until then no point at
537
+ * rest presents them: not the surgery's release, a resume, a turn's end
538
+ * or a row stored for the agent while it is idle, so the cut the
539
+ * operator made is what the agent's window holds until it speaks again.
540
+ * A tool boundary isn't held back (a turn alive started since). An own
541
+ * row among them isn't held: own rows enter at every point, as ever. The
542
+ * hold is the branch's the store is on (the rollback's): on another
543
+ * branch the same stored rows are arrivals as any, so a later move of the
544
+ * store's branch, a suppression or rollback through another agent
545
+ * included, ends it there, and back on this one they are held again until
546
+ * the agent's next turn start. In memory: a restart presents them at its
547
+ * pass at rest, or, where it boots quiesced, at the resume (a frozen pass
548
+ * presents no arrival), and an agent let go (forget)
549
+ * drops them. Rows given again on the same branch add to those held, and
550
+ * on another replace them. Never throws.
551
+ */
552
+ holdUntilStart(agent: PresentedAgent, ids: readonly MessageId[]): void;
553
+ /**
554
+ * The check before a tool boundary hands the stream its rows: `sent` (the
555
+ * round's reply, its results and the injected rows, in the order the
556
+ * stream is given them) not yet in the window are presented, in order,
557
+ * and the window's newest bodies must then be exactly those rows. On a
558
+ * mismatch it traces presentation:hand-off-mismatch and the rows are not
559
+ * vouched for, so the stream's later thinking is left out at the next
560
+ * compile rather than sent under a prefix its window doesn't hold. An
561
+ * agent the module doesn't present for is vouched for as before. A read
562
+ * of the window that throws is traced as presentation:failed, and the
563
+ * rows are not vouched for: the check couldn't be made. Never throws.
564
+ */
565
+ handOff(agent: PresentedAgent, sent: ReadonlyArray<MessageId | undefined>): {
566
+ vouched: boolean;
567
+ };
568
+ /** A read of the agent's arrivals not yet presented, one per body, in record order (for previews and a release). */
569
+ arrivalsOf(agent: PresentedAgent): StoredMessage[];
570
+ /**
571
+ * A reader fork was handed held rows as framing (AF-5): those not in its
572
+ * window yet are presented there, when the module presents for it, and
573
+ * the fork counts as holding every one of them (holders, `'framing'`),
574
+ * however its window filters held rows, until it is let go (forget). A
575
+ * fork framed before it is taken on has them presented at its adopt. Its
576
+ * window's filter (the residents', which a reader fork inherits) keeps
577
+ * them out of its compiles, as it keeps all held traffic; its framing row
578
+ * shows them where the framing puts them (the default's does); nothing
579
+ * else of its window moves. Rows whose presentation fails enter at the
580
+ * fork's next turn start, or after a move of the store's branch (rebase).
581
+ */
582
+ noteFramed(agent: PresentedAgent, rowIds: readonly MessageId[]): void;
583
+ /**
584
+ * Drop the rows a reader fork was handed as framing (noteFramed) when the
585
+ * fork is never taken on, so never let go (forget): one its run refused
586
+ * before registering it (the host quiesced or stopping, a surgery holding
587
+ * the store). Nothing for a name handed none.
588
+ */
589
+ forgetFramed(agent: AgentName): void;
590
+ /**
591
+ * The rows the agent is owed and its window doesn't hold yet, one per
592
+ * body (its first shard not in the window), in record order: its own rows
593
+ * and its arrivals, frozen or not, whatever its turn. None for an agent the
594
+ * module doesn't present for. The subconscious's window start is fixed
595
+ * once no row it is owed stored before the start is among them.
596
+ */
597
+ owedOf(agent: PresentedAgent): StoredMessage[];
598
+ /**
599
+ * Whether a row just stored in the agent's own slot, and presented at
600
+ * rest by afterStore if at all, is out of its window though the agent is
601
+ * owed it (its own row, or an arrival): a presentation that failed, or
602
+ * the host's freeze, kept it out. A row that is nothing to the agent (held
603
+ * from a resident, stamped for another) isn't. Yes where the window can't
604
+ * be read to tell; no for an agent the module doesn't present for.
605
+ */
606
+ notPresented(agent: PresentedAgent, id: MessageId): boolean;
607
+ /**
608
+ * Every live agent holding a row: each whose window has it at a place,
609
+ * leaving out one whose window leaves held rows out when the row is held
610
+ * (a window written down from the record took in those an earlier release
611
+ * stored, before the audience stamp; retractForeign takes out the rest),
612
+ * and every one when a suppress rule hid the row, which no view renders;
613
+ * each whose window
614
+ * is still the whole record and whose record holds it; and each reader fork
615
+ * handed it as framing.
616
+ */
617
+ holders(rowId: MessageId): Holder[];
618
+ /**
619
+ * Rows removed from the record through `remover` (a context manager of a
620
+ * live agent's, or one opened apart from them), taken out of every other
621
+ * live agent's window that still holds them: context-manager tombstones a
622
+ * removal in the remover's own window only, and another window on the
623
+ * same slot, or merging it, keeps the row's place (CM-T) while its listing
624
+ * and its compile leave the row out. Each row leaves at its own place, so
625
+ * no other row's place moves, and a cursor or watermark kept by place
626
+ * stays good. A window on a branch whose record still holds the row (a
627
+ * fork, a derived agent's view made before the removal) keeps it, as does
628
+ * a window that is still the record, which is never written to here
629
+ * (context-manager's retractRemoved passes over both). Each window's rows
630
+ * taken out are traced (presentation:retracted, with `reason`), and a
631
+ * window that couldn't be repaired is logged and passed by: the removal
632
+ * stands. `ids` names every row removed, a body by each of its shards.
633
+ * Returns what left each window. Never throws.
634
+ */
635
+ retractRemoved(remover: WindowManager | undefined, ids: readonly MessageId[], reason: PresentationRetractReason): Array<{
636
+ agent: AgentName;
637
+ ids: MessageId[];
638
+ }>;
639
+ /**
640
+ * At boot, after every live agent is taken on: take out of each window
641
+ * the module presents for every row it holds that its record no longer
642
+ * does (context-manager's retractAbsentRows), as retractRemoved takes out
643
+ * the rows a live removal named. These are rows removed where no live
644
+ * context heard it: by an offline recovery's suppressions, with the host
645
+ * stopped, through the one context it opened, and removals whose own
646
+ * tombstone failed. Traced as presentation:retracted with `boot`; a
647
+ * window that couldn't be repaired is logged and passed by. Each agent's
648
+ * context is open with every slot it merges by then, so a row of a slot
649
+ * it merges isn't taken for removed. Never throws.
650
+ */
651
+ retractAbsentRows(): Array<{
652
+ agent: AgentName;
653
+ ids: MessageId[];
654
+ }>;
655
+ /** Whether a reader fork was handed the row as framing (noteFramed), and
656
+ * hasn't been let go since, whether or not its window holds the row. */
657
+ framedToAny(rowId: MessageId): boolean;
658
+ /** Whether any live agent but `except` holds the row in a window or as framing: a window that is still the record doesn't count. */
659
+ presentedToAnyone(rowId: MessageId, options?: {
660
+ except?: AgentName;
661
+ }): boolean;
662
+ /** The rows of the agent's window at or after `mark`, in window order; none in legacy mode. */
663
+ presentedSince(agent: PresentedAgent, mark: Position): StoredMessage[];
664
+ /** Hear each presentation into the named agent's window, after its rows entered. Returns the unsubscribe. */
665
+ onPresented(agentName: AgentName, listener: (event: PresentedEvent) => void): () => void;
666
+ /**
667
+ * A write's stamp, checked as it is stored through `deliveredTo`'s
668
+ * context: an audience none of whose agents reads that slot is traced
669
+ * (presentation:unreadable-audience), once for the write. The row is
670
+ * stored as named.
671
+ */
672
+ checkAudience(metadata: MessageMetadata | undefined, deliveredTo: AgentName): void;
673
+ /**
674
+ * The own rows whose presentation at their write failed (presentOwn) and
675
+ * that are still out of the agent's window, in record order. A row that
676
+ * entered by another point since, was undone, or left the record (a
677
+ * branch move, a removal) is dropped.
678
+ */
679
+ private failedOwnOf;
680
+ /**
681
+ * Keep, of the own rows presentOwn tried, those still out of the window,
682
+ * for its next call; forget the rest. Rows kept meanwhile that this call
683
+ * didn't try stay kept: a listener of its presentation, which runs
684
+ * inside it, may have stored an own row whose presentation failed, kept
685
+ * by that nested call.
686
+ */
687
+ private keepFailedOwn;
688
+ /** presentAtEnd under a named occasion; a rollback's held arrivals wait (holdUntilStart), and so do all of an agent's the boot left out (restWithheld). */
689
+ private presentAtRest;
690
+ /** The rows the agent was handed as framing (noteFramed) that its window doesn't hold yet, presented in the order handed. */
691
+ private presentFramed;
692
+ /** The own-row sweep: the agent's own rows not in its window, presented in record order, traced as a repair. */
693
+ private repair;
694
+ /**
695
+ * Present the agent's own pending rows, and its arrivals when `arrivals`
696
+ * (but those a rollback holds for its next start, with `atRest`), in one
697
+ * call; return the arrivals that entered whole, and the error when the
698
+ * presentation failed: a read that threw, or a write that left a row it
699
+ * named out. `next` is what the failure's log says becomes of its rows.
700
+ */
701
+ private presentPending;
702
+ /**
703
+ * The agent's pending bodies, in record order: its own rows not in its
704
+ * window, and its arrivals when `arrivals`, leaving out, with `atRest`,
705
+ * an arrival a rollback holds for the agent's next start (any shard of
706
+ * its body held). A body is its run of unpresented shards
707
+ * (continuesBody), weighed by its first.
708
+ */
709
+ private pending;
710
+ /**
711
+ * The slot of `cm`'s record a row is stored in, for bearingOf: its own
712
+ * (`'own'`, which getMessage reads), else the merged slot that holds it
713
+ * (mergedSlotsOf). The record holds the context's own slot and one
714
+ * auxiliary view per merged slot, so a row not in its own is in the one
715
+ * merged slot when there is one; when there are more, each is asked, by
716
+ * a read-only handle on it over the manager's store, which follows its
717
+ * branch and its writes as the manager's own views do. undefined for a
718
+ * row in none of them (a slot the reader has no edge on).
719
+ */
720
+ private slotOfRow;
721
+ /**
722
+ * One presentRows call for `ids` in the agent's window: every row named
723
+ * counts once it returns (it refuses a row already in the window, and
724
+ * returns one ordinal per row named); on a throw, the rows that entered
725
+ * before it count, as far as the window can be read then, and the
726
+ * failure is traced. Traces what entered and tells the listeners.
727
+ */
728
+ private present;
729
+ /**
730
+ * Tell the agent's listeners of the rows that entered its window, in
731
+ * order, each body as the window holds it. Where the window can't be
732
+ * read for that, they are told of each entered row by its first shard
733
+ * (a body's later shards left out), and that is logged: the rows are in
734
+ * the window whatever the read, so the listeners (noteArrival, the
735
+ * subconscious's anchor) still hear them.
736
+ */
737
+ private tell;
738
+ /**
739
+ * A presentation that failed, logged and traced (presentation:failed):
740
+ * `ids` are the rows it named that didn't enter the window (a body by
741
+ * the id that names it), where they are known, and `next` says what
742
+ * becomes of them.
743
+ */
744
+ private failed;
745
+ }
746
+ //# sourceMappingURL=presentation.d.ts.map