@animalabs/agent-framework 0.32.0 → 0.34.0

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