@animalabs/agent-framework 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (368) hide show
  1. package/README.md +340 -22
  2. package/dist/src/admission/admit.d.ts +18 -0
  3. package/dist/src/admission/admit.d.ts.map +1 -1
  4. package/dist/src/admission/admit.js +16 -3
  5. package/dist/src/admission/admit.js.map +1 -1
  6. package/dist/src/agent.d.ts +208 -80
  7. package/dist/src/agent.d.ts.map +1 -1
  8. package/dist/src/agent.js +345 -113
  9. package/dist/src/agent.js.map +1 -1
  10. package/dist/src/api/mcp-server-core.d.ts.map +1 -1
  11. package/dist/src/api/mcp-server-core.js +50 -12
  12. package/dist/src/api/mcp-server-core.js.map +1 -1
  13. package/dist/src/api/server.d.ts.map +1 -1
  14. package/dist/src/api/server.js +4 -20
  15. package/dist/src/api/server.js.map +1 -1
  16. package/dist/src/append-all.d.ts +5 -0
  17. package/dist/src/append-all.d.ts.map +1 -0
  18. package/dist/src/append-all.js +8 -0
  19. package/dist/src/append-all.js.map +1 -0
  20. package/dist/src/code-execution/isolate/scripts.d.ts +12 -8
  21. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
  22. package/dist/src/code-execution/isolate/scripts.js +24 -0
  23. package/dist/src/code-execution/isolate/scripts.js.map +1 -1
  24. package/dist/src/config-checks.d.ts +7 -0
  25. package/dist/src/config-checks.d.ts.map +1 -1
  26. package/dist/src/config-checks.js +14 -0
  27. package/dist/src/config-checks.js.map +1 -1
  28. package/dist/src/context-manager-errors.d.ts +25 -0
  29. package/dist/src/context-manager-errors.d.ts.map +1 -0
  30. package/dist/src/context-manager-errors.js +31 -0
  31. package/dist/src/context-manager-errors.js.map +1 -0
  32. package/dist/src/context-options.d.ts +70 -0
  33. package/dist/src/context-options.d.ts.map +1 -0
  34. package/dist/src/context-options.js +90 -0
  35. package/dist/src/context-options.js.map +1 -0
  36. package/dist/src/cut-off-round.js +4 -4
  37. package/dist/src/deferred-import.d.ts +93 -0
  38. package/dist/src/deferred-import.d.ts.map +1 -0
  39. package/dist/src/deferred-import.js +177 -0
  40. package/dist/src/deferred-import.js.map +1 -0
  41. package/dist/src/dendrite/audience.d.ts +223 -0
  42. package/dist/src/dendrite/audience.d.ts.map +1 -0
  43. package/dist/src/dendrite/audience.js +202 -0
  44. package/dist/src/dendrite/audience.js.map +1 -0
  45. package/dist/src/dendrite/index.d.ts +5 -3
  46. package/dist/src/dendrite/index.d.ts.map +1 -1
  47. package/dist/src/dendrite/index.js +2 -1
  48. package/dist/src/dendrite/index.js.map +1 -1
  49. package/dist/src/dendrite/presets.d.ts +10 -5
  50. package/dist/src/dendrite/presets.d.ts.map +1 -1
  51. package/dist/src/dendrite/presets.js +17 -5
  52. package/dist/src/dendrite/presets.js.map +1 -1
  53. package/dist/src/dendrite/registry.d.ts +62 -7
  54. package/dist/src/dendrite/registry.d.ts.map +1 -1
  55. package/dist/src/dendrite/registry.js +183 -12
  56. package/dist/src/dendrite/registry.js.map +1 -1
  57. package/dist/src/dendrite/types.d.ts +91 -8
  58. package/dist/src/dendrite/types.d.ts.map +1 -1
  59. package/dist/src/failure-text.d.ts +36 -0
  60. package/dist/src/failure-text.d.ts.map +1 -0
  61. package/dist/src/failure-text.js +89 -0
  62. package/dist/src/failure-text.js.map +1 -0
  63. package/dist/src/foreign-rounds.d.ts +69 -0
  64. package/dist/src/foreign-rounds.d.ts.map +1 -0
  65. package/dist/src/foreign-rounds.js +152 -0
  66. package/dist/src/foreign-rounds.js.map +1 -0
  67. package/dist/src/framework.d.ts +2064 -842
  68. package/dist/src/framework.d.ts.map +1 -1
  69. package/dist/src/framework.js +8586 -3739
  70. package/dist/src/framework.js.map +1 -1
  71. package/dist/src/gate/event-gate.d.ts +125 -21
  72. package/dist/src/gate/event-gate.d.ts.map +1 -1
  73. package/dist/src/gate/event-gate.js +487 -72
  74. package/dist/src/gate/event-gate.js.map +1 -1
  75. package/dist/src/gate/index.d.ts +1 -1
  76. package/dist/src/gate/index.d.ts.map +1 -1
  77. package/dist/src/gate/index.js.map +1 -1
  78. package/dist/src/gate/reply-judge.d.ts +4 -0
  79. package/dist/src/gate/reply-judge.d.ts.map +1 -1
  80. package/dist/src/gate/reply-judge.js +12 -3
  81. package/dist/src/gate/reply-judge.js.map +1 -1
  82. package/dist/src/gate/rule-scope.d.ts +30 -0
  83. package/dist/src/gate/rule-scope.d.ts.map +1 -0
  84. package/dist/src/gate/rule-scope.js +41 -0
  85. package/dist/src/gate/rule-scope.js.map +1 -0
  86. package/dist/src/gate/suppress-script-worker.d.ts +2 -0
  87. package/dist/src/gate/suppress-script-worker.d.ts.map +1 -0
  88. package/dist/src/gate/suppress-script-worker.js +103 -0
  89. package/dist/src/gate/suppress-script-worker.js.map +1 -0
  90. package/dist/src/gate/suppress-scripts.d.ts +105 -0
  91. package/dist/src/gate/suppress-scripts.d.ts.map +1 -0
  92. package/dist/src/gate/suppress-scripts.js +403 -0
  93. package/dist/src/gate/suppress-scripts.js.map +1 -0
  94. package/dist/src/gate/suppression-review.d.ts +143 -0
  95. package/dist/src/gate/suppression-review.d.ts.map +1 -0
  96. package/dist/src/gate/suppression-review.js +463 -0
  97. package/dist/src/gate/suppression-review.js.map +1 -0
  98. package/dist/src/gate/suppression-stats.d.ts +125 -0
  99. package/dist/src/gate/suppression-stats.d.ts.map +1 -0
  100. package/dist/src/gate/suppression-stats.js +214 -0
  101. package/dist/src/gate/suppression-stats.js.map +1 -0
  102. package/dist/src/gate/types.d.ts +142 -7
  103. package/dist/src/gate/types.d.ts.map +1 -1
  104. package/dist/src/gate/wake-onboarding.d.ts +119 -0
  105. package/dist/src/gate/wake-onboarding.d.ts.map +1 -0
  106. package/dist/src/gate/wake-onboarding.js +277 -0
  107. package/dist/src/gate/wake-onboarding.js.map +1 -0
  108. package/dist/src/heartbeat/heartbeat.js +1 -1
  109. package/dist/src/heartbeat/heartbeat.js.map +1 -1
  110. package/dist/src/held-writes.d.ts +31 -23
  111. package/dist/src/held-writes.d.ts.map +1 -1
  112. package/dist/src/held-writes.js +44 -59
  113. package/dist/src/held-writes.js.map +1 -1
  114. package/dist/src/index.d.ts +6 -2
  115. package/dist/src/index.d.ts.map +1 -1
  116. package/dist/src/index.js +4 -0
  117. package/dist/src/index.js.map +1 -1
  118. package/dist/src/inference-bounds.d.ts +2 -1
  119. package/dist/src/inference-bounds.d.ts.map +1 -1
  120. package/dist/src/inference-bounds.js +9 -6
  121. package/dist/src/inference-bounds.js.map +1 -1
  122. package/dist/src/jsonrpc-envelope.d.ts +69 -0
  123. package/dist/src/jsonrpc-envelope.d.ts.map +1 -0
  124. package/dist/src/jsonrpc-envelope.js +66 -0
  125. package/dist/src/jsonrpc-envelope.js.map +1 -0
  126. package/dist/src/mcpl/channel-registry.d.ts +188 -28
  127. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  128. package/dist/src/mcpl/channel-registry.js +426 -70
  129. package/dist/src/mcpl/channel-registry.js.map +1 -1
  130. package/dist/src/mcpl/checkpoint-manager.d.ts +2 -4
  131. package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -1
  132. package/dist/src/mcpl/checkpoint-manager.js.map +1 -1
  133. package/dist/src/mcpl/feature-set-manager.d.ts +2 -4
  134. package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
  135. package/dist/src/mcpl/feature-set-manager.js.map +1 -1
  136. package/dist/src/mcpl/inbound-source.d.ts +2 -1
  137. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  138. package/dist/src/mcpl/inbound-source.js +2 -1
  139. package/dist/src/mcpl/inbound-source.js.map +1 -1
  140. package/dist/src/mcpl/inference-router.d.ts +6 -6
  141. package/dist/src/mcpl/inference-router.d.ts.map +1 -1
  142. package/dist/src/mcpl/inference-router.js.map +1 -1
  143. package/dist/src/mcpl/modern-connection.d.ts +109 -15
  144. package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
  145. package/dist/src/mcpl/modern-connection.js +593 -86
  146. package/dist/src/mcpl/modern-connection.js.map +1 -1
  147. package/dist/src/mcpl/protocol-family.d.ts +3 -1
  148. package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
  149. package/dist/src/mcpl/protocol-family.js +15 -9
  150. package/dist/src/mcpl/protocol-family.js.map +1 -1
  151. package/dist/src/mcpl/push-coalescer.d.ts +132 -22
  152. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  153. package/dist/src/mcpl/push-coalescer.js +105 -15
  154. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  155. package/dist/src/mcpl/push-handler.d.ts +9 -7
  156. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  157. package/dist/src/mcpl/push-handler.js.map +1 -1
  158. package/dist/src/mcpl/server-connection.d.ts +50 -28
  159. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  160. package/dist/src/mcpl/server-connection.js +165 -72
  161. package/dist/src/mcpl/server-connection.js.map +1 -1
  162. package/dist/src/mcpl/tool-classes.d.ts.map +1 -1
  163. package/dist/src/mcpl/tool-classes.js +3 -0
  164. package/dist/src/mcpl/tool-classes.js.map +1 -1
  165. package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
  166. package/dist/src/mcpl/tool-presence.js +10 -6
  167. package/dist/src/mcpl/tool-presence.js.map +1 -1
  168. package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
  169. package/dist/src/mcpl/toolset-host.js +7 -6
  170. package/dist/src/mcpl/toolset-host.js.map +1 -1
  171. package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
  172. package/dist/src/mcpl/toolsets-module.js +2 -1
  173. package/dist/src/mcpl/toolsets-module.js.map +1 -1
  174. package/dist/src/mcpl/types.d.ts +33 -6
  175. package/dist/src/mcpl/types.d.ts.map +1 -1
  176. package/dist/src/mcpl/types.js.map +1 -1
  177. package/dist/src/module-registry.d.ts +24 -1
  178. package/dist/src/module-registry.d.ts.map +1 -1
  179. package/dist/src/module-registry.js +68 -18
  180. package/dist/src/module-registry.js.map +1 -1
  181. package/dist/src/modules/discord/index.d.ts +45 -8
  182. package/dist/src/modules/discord/index.d.ts.map +1 -1
  183. package/dist/src/modules/discord/index.js +238 -87
  184. package/dist/src/modules/discord/index.js.map +1 -1
  185. package/dist/src/modules/health/index.js +2 -2
  186. package/dist/src/modules/health/index.js.map +1 -1
  187. package/dist/src/modules/history/index.d.ts +59 -0
  188. package/dist/src/modules/history/index.d.ts.map +1 -1
  189. package/dist/src/modules/history/index.js +432 -67
  190. package/dist/src/modules/history/index.js.map +1 -1
  191. package/dist/src/modules/history/semantic.d.ts +6 -5
  192. package/dist/src/modules/history/semantic.d.ts.map +1 -1
  193. package/dist/src/modules/history/semantic.js +18 -25
  194. package/dist/src/modules/history/semantic.js.map +1 -1
  195. package/dist/src/modules/workspace/disk-agreement.d.ts +1 -1
  196. package/dist/src/modules/workspace/disk-agreement.js +1 -1
  197. package/dist/src/modules/workspace/index.d.ts +28 -7
  198. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  199. package/dist/src/modules/workspace/index.js +80 -25
  200. package/dist/src/modules/workspace/index.js.map +1 -1
  201. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  202. package/dist/src/modules/workspace/observe.js +2 -1
  203. package/dist/src/modules/workspace/observe.js.map +1 -1
  204. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  205. package/dist/src/modules/workspace/reconcile.js +3 -2
  206. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  207. package/dist/src/notice-tags.d.ts +20 -9
  208. package/dist/src/notice-tags.d.ts.map +1 -1
  209. package/dist/src/notice-tags.js +20 -9
  210. package/dist/src/notice-tags.js.map +1 -1
  211. package/dist/src/operator-log.d.ts +36 -3
  212. package/dist/src/operator-log.d.ts.map +1 -1
  213. package/dist/src/operator-log.js +2 -2
  214. package/dist/src/operator-log.js.map +1 -1
  215. package/dist/src/presentation.d.ts +747 -0
  216. package/dist/src/presentation.d.ts.map +1 -0
  217. package/dist/src/presentation.js +1437 -0
  218. package/dist/src/presentation.js.map +1 -0
  219. package/dist/src/prose-drafts.d.ts +15 -11
  220. package/dist/src/prose-drafts.d.ts.map +1 -1
  221. package/dist/src/prose-drafts.js +16 -12
  222. package/dist/src/prose-drafts.js.map +1 -1
  223. package/dist/src/read-marks.d.ts +192 -0
  224. package/dist/src/read-marks.d.ts.map +1 -0
  225. package/dist/src/read-marks.js +242 -0
  226. package/dist/src/read-marks.js.map +1 -0
  227. package/dist/src/reasoning-loss.d.ts +5 -0
  228. package/dist/src/reasoning-loss.d.ts.map +1 -0
  229. package/dist/src/reasoning-loss.js +8 -0
  230. package/dist/src/reasoning-loss.js.map +1 -0
  231. package/dist/src/recovery/offline-branch.d.ts +91 -6
  232. package/dist/src/recovery/offline-branch.d.ts.map +1 -1
  233. package/dist/src/recovery/offline-branch.js +277 -32
  234. package/dist/src/recovery/offline-branch.js.map +1 -1
  235. package/dist/src/recovery/recover-cli.js +24 -4
  236. package/dist/src/recovery/recover-cli.js.map +1 -1
  237. package/dist/src/send-tools.d.ts +5 -9
  238. package/dist/src/send-tools.d.ts.map +1 -1
  239. package/dist/src/send-tools.js +40 -7
  240. package/dist/src/send-tools.js.map +1 -1
  241. package/dist/src/sent-rows.js +1 -1
  242. package/dist/src/stored-injections.d.ts +2 -2
  243. package/dist/src/stored-injections.js +2 -2
  244. package/dist/src/stored-removal.d.ts +17 -4
  245. package/dist/src/stored-removal.d.ts.map +1 -1
  246. package/dist/src/stored-removal.js +29 -5
  247. package/dist/src/stored-removal.js.map +1 -1
  248. package/dist/src/supplied-text.d.ts +1 -1
  249. package/dist/src/supplied-text.js +3 -3
  250. package/dist/src/supplied-text.js.map +1 -1
  251. package/dist/src/thinking-drops.d.ts +2 -0
  252. package/dist/src/thinking-drops.d.ts.map +1 -1
  253. package/dist/src/thinking-drops.js.map +1 -1
  254. package/dist/src/tool-presentation.d.ts.map +1 -1
  255. package/dist/src/tool-presentation.js +38 -9
  256. package/dist/src/tool-presentation.js.map +1 -1
  257. package/dist/src/tool-result-guard.d.ts +12 -1
  258. package/dist/src/tool-result-guard.d.ts.map +1 -1
  259. package/dist/src/tool-result-guard.js +42 -8
  260. package/dist/src/tool-result-guard.js.map +1 -1
  261. package/dist/src/tune-out/coordinator.d.ts +1170 -81
  262. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  263. package/dist/src/tune-out/coordinator.js +3732 -369
  264. package/dist/src/tune-out/coordinator.js.map +1 -1
  265. package/dist/src/tune-out/tools.d.ts +114 -17
  266. package/dist/src/tune-out/tools.d.ts.map +1 -1
  267. package/dist/src/tune-out/tools.js +89 -28
  268. package/dist/src/tune-out/tools.js.map +1 -1
  269. package/dist/src/tune-out/window-anchor.d.ts +143 -0
  270. package/dist/src/tune-out/window-anchor.d.ts.map +1 -0
  271. package/dist/src/tune-out/window-anchor.js +202 -0
  272. package/dist/src/tune-out/window-anchor.js.map +1 -0
  273. package/dist/src/types/agent.d.ts +121 -25
  274. package/dist/src/types/agent.d.ts.map +1 -1
  275. package/dist/src/types/events.d.ts +2 -0
  276. package/dist/src/types/events.d.ts.map +1 -1
  277. package/dist/src/types/framework.d.ts +72 -17
  278. package/dist/src/types/framework.d.ts.map +1 -1
  279. package/dist/src/types/inference-log.d.ts +1 -0
  280. package/dist/src/types/inference-log.d.ts.map +1 -1
  281. package/dist/src/types/module.d.ts +180 -69
  282. package/dist/src/types/module.d.ts.map +1 -1
  283. package/dist/src/types/trace.d.ts +573 -39
  284. package/dist/src/types/trace.d.ts.map +1 -1
  285. package/package.json +4 -4
  286. package/src/admission/admit.ts +32 -3
  287. package/src/agent.ts +392 -132
  288. package/src/api/mcp-server-core.ts +54 -17
  289. package/src/api/server.ts +4 -23
  290. package/src/append-all.ts +6 -0
  291. package/src/code-execution/isolate/scripts.ts +28 -3
  292. package/src/config-checks.ts +14 -0
  293. package/src/context-manager-errors.ts +37 -0
  294. package/src/context-options.ts +106 -0
  295. package/src/cut-off-round.ts +4 -4
  296. package/src/deferred-import.ts +239 -0
  297. package/src/dendrite/audience.ts +315 -0
  298. package/src/dendrite/index.ts +14 -2
  299. package/src/dendrite/presets.ts +18 -6
  300. package/src/dendrite/registry.ts +213 -14
  301. package/src/dendrite/types.ts +92 -8
  302. package/src/failure-text.ts +88 -0
  303. package/src/foreign-rounds.ts +199 -0
  304. package/src/framework.ts +8796 -3813
  305. package/src/gate/event-gate.ts +518 -91
  306. package/src/gate/index.ts +3 -0
  307. package/src/gate/reply-judge.ts +12 -3
  308. package/src/gate/rule-scope.ts +45 -0
  309. package/src/gate/suppress-script-worker.ts +89 -0
  310. package/src/gate/suppress-scripts.ts +414 -0
  311. package/src/gate/suppression-review.ts +517 -0
  312. package/src/gate/suppression-stats.ts +314 -0
  313. package/src/gate/types.ts +148 -7
  314. package/src/gate/wake-onboarding.ts +309 -0
  315. package/src/heartbeat/heartbeat.ts +1 -1
  316. package/src/held-writes.ts +49 -60
  317. package/src/index.ts +10 -2
  318. package/src/inference-bounds.ts +11 -6
  319. package/src/jsonrpc-envelope.ts +81 -0
  320. package/src/mcpl/channel-registry.ts +513 -116
  321. package/src/mcpl/checkpoint-manager.ts +3 -2
  322. package/src/mcpl/feature-set-manager.ts +2 -1
  323. package/src/mcpl/inbound-source.ts +2 -1
  324. package/src/mcpl/inference-router.ts +7 -4
  325. package/src/mcpl/modern-connection.ts +629 -91
  326. package/src/mcpl/protocol-family.ts +15 -9
  327. package/src/mcpl/push-coalescer.ts +193 -34
  328. package/src/mcpl/push-handler.ts +10 -5
  329. package/src/mcpl/server-connection.ts +169 -75
  330. package/src/mcpl/tool-classes.ts +3 -0
  331. package/src/mcpl/tool-presence.ts +10 -5
  332. package/src/mcpl/toolset-host.ts +7 -6
  333. package/src/mcpl/toolsets-module.ts +2 -1
  334. package/src/mcpl/types.ts +33 -6
  335. package/src/module-registry.ts +73 -17
  336. package/src/modules/discord/index.ts +230 -82
  337. package/src/modules/health/index.ts +2 -2
  338. package/src/modules/history/index.ts +439 -70
  339. package/src/modules/history/semantic.ts +18 -24
  340. package/src/modules/workspace/disk-agreement.ts +1 -1
  341. package/src/modules/workspace/index.ts +89 -26
  342. package/src/modules/workspace/observe.ts +2 -1
  343. package/src/modules/workspace/reconcile.ts +3 -2
  344. package/src/notice-tags.ts +21 -9
  345. package/src/operator-log.ts +36 -3
  346. package/src/presentation.ts +1678 -0
  347. package/src/prose-drafts.ts +16 -12
  348. package/src/read-marks.ts +328 -0
  349. package/src/reasoning-loss.ts +7 -0
  350. package/src/recovery/offline-branch.ts +350 -35
  351. package/src/recovery/recover-cli.ts +23 -4
  352. package/src/send-tools.ts +40 -7
  353. package/src/sent-rows.ts +1 -1
  354. package/src/stored-injections.ts +2 -2
  355. package/src/stored-removal.ts +31 -7
  356. package/src/supplied-text.ts +3 -3
  357. package/src/thinking-drops.ts +2 -0
  358. package/src/tool-presentation.ts +34 -9
  359. package/src/tool-result-guard.ts +41 -7
  360. package/src/tune-out/coordinator.ts +4121 -472
  361. package/src/tune-out/tools.ts +162 -44
  362. package/src/tune-out/window-anchor.ts +277 -0
  363. package/src/types/agent.ts +122 -25
  364. package/src/types/events.ts +2 -0
  365. package/src/types/framework.ts +73 -17
  366. package/src/types/inference-log.ts +1 -0
  367. package/src/types/module.ts +181 -68
  368. package/src/types/trace.ts +607 -43
@@ -1,8 +1,10 @@
1
+ export { residentViewFilter, subconsciousViewFilter } from './context-options.js';
1
2
  import { type PresentationSnapshot } from "./tool-presentation.js";
2
3
  import { JsStore } from '@animalabs/chronicle';
3
4
  import type { Membrane, ContentBlock, NormalizedRequest } from '@animalabs/membrane';
4
5
  import { type RetrySettings } from '@animalabs/membrane/retry';
5
6
  import { ContextManager } from '@animalabs/context-manager';
7
+ import { type TuneOutReader } from './tune-out/tools.js';
6
8
  import type { MessageMetadata, TokenBudget } from '@animalabs/context-manager';
7
9
  import type { FrameworkConfig, ErrorPolicy, ErrorAction, TraceEventListener, InferenceLogQuery, InferenceLogQueryResult, InferenceLogEntryWithId, ProcessLogQuery, ProcessLogQueryResult, ProcessLogEntryWithId, ProcessEvent, ToolCall, ToolResult, AgentConfig, InferenceRequest, Module, ContextMaintenanceSnapshot, AgentRuntimeSettingsPatch, AgentRuntimeSettingsSnapshot, SameRoundThinkTextPolicy } from './types/index.js';
8
10
  import { Agent, type RenderStats } from './agent.js';
@@ -17,10 +19,21 @@ import type { ActivationRecord, AgentEndReason, AgentRecord, AgentSpec, EndOutco
17
19
  * and every module utility is there too.
18
20
  */
19
21
  export declare const BUILTIN_TOOLSET_TOOLS: ReadonlySet<string>;
22
+ import { type SuppressedEventRecord } from './gate/suppression-stats.js';
23
+ import { type SuppressionReviewSummary } from './gate/suppression-review.js';
20
24
  import type { SessionUsageSnapshot } from './usage/types.js';
21
25
  import type { ContextStrategy } from '@animalabs/context-manager';
22
26
  import { type DiscordAwarenessView, type DiscordAwarenessCancelReceipt, type DiscordAwarenessMarks, type DiscordAwarenessRetractReceipt } from './recovery/discord-awareness-outbox.js';
23
27
  import { type SurgeryMarkerReceipt, type SurgeryMarksPreview, type OperatorLogEntry, type OperatorLogInput, type OperatorRequester } from './operator-log.js';
28
+ export type { TuneOutReader };
29
+ /**
30
+ * The `tune_out` tool for a host with `reader`. The text says what happens
31
+ * to the channel's traffic and what the reader there can do, by the name
32
+ * the host gave it. It says nothing of what a reader decides or why: the
33
+ * voice doctrine's standard (coordinator.ts), which puts no words in a
34
+ * model's mouth, holds for what the resident is told about its reader too.
35
+ */
36
+ export declare function tuneOutTool(reader: TuneOutReader): import('./types/index.js').ToolDefinition;
24
37
  /**
25
38
  * Feasibility verdict for a runtime-settings patch, derived through the SAME
26
39
  * settings→config mapping the live apply path uses (`Agent.planRuntimeSettings`
@@ -102,19 +115,31 @@ export interface HostModeStatus {
102
115
  * gate while quiesced, or, while serving, until the scheduler's next pass
103
116
  * takes them), in a scheduler pass's hands, or held by a provider hold (an
104
117
  * acceleration or host hold, or a provider's stated wait). There, a start
105
- * merged from several requests counts as those it took in. A start parked
106
- * on provider admission behind an auxiliary call counts once in
107
- * `parkedAdmissions` instead, however many wakes are merged into it.
108
- * Continuations of a turn (budget restart, tool results) and a held turn's
109
- * retry, which a quiesce lets through, are never counted. */
118
+ * merged from several requests counts as those it took in. A start parked on
119
+ * provider admission behind an auxiliary call counts once in
120
+ * `parkedAdmissions` instead, however many wakes are merged into it. A turn
121
+ * a budget hold holds counts once, continuation or not. The wakes merged
122
+ * into its start are part of it. Wakes that joined it while it waited count
123
+ * as other gated requests do. Other continuations (budget restart, tool
124
+ * results, the tool-result guard's retry) and a held turn's retry, which a
125
+ * quiesce lets through, are never counted. */
110
126
  gatedRequests: number;
111
127
  /** code_execution scripts still running that no call is waiting on: left
112
128
  * running after a yield, outside any turn. Quiesce does NOT stop them —
113
129
  * they hold no turn token, so drain doesn't wait for them. Reported so the
114
130
  * operator sees what is still acting during the window. */
115
131
  backgroundScripts: number;
116
- /** Context writes (module events, api message.send) withheld because the
117
- * host is quiesced. Persisted while quiesced and flushed by resume(). */
132
+ /**
133
+ * Context writes kept in memory, to be stored later: those a live
134
+ * operator surgery's hold keeps until its release, and those kept for an
135
+ * agent whose context manager refuses its work after a failed
136
+ * re-initialization, until a branch move (switchBranch, a rollback or a
137
+ * suppression) re-initializes it; 0 otherwise. Before #291 it counted the writes held in the deferred queue,
138
+ * which this release no longer keeps: a write made while quiesced is
139
+ * stored at once, and no agent is shown another's until resume.
140
+ *
141
+ * @deprecated Kept for one release; removed in the next.
142
+ */
118
143
  deferredWrites: number;
119
144
  /** Agents whose turn `abandon` had not ended when its grace ran out: a
120
145
  * turn token held with no stream to cancel and no check ahead to stop it
@@ -145,12 +170,13 @@ export declare class ResumeBlockedError extends Error {
145
170
  }>);
146
171
  }
147
172
  /**
148
- * Thrown by `quiesce()` without `abandon` when the queue of deferred context
149
- * writes can't reach disk: it's over its cap, so its record can't hold it, or
150
- * its write failed, and that error is the `cause`. So the queue as it
151
- * stands isn't on disk. The host's mode is as it was, and the
152
- * message names the ways out, among them quiescing with `abandon: true`,
153
- * which goes on with the queue in memory.
173
+ * Was thrown by `quiesce()` when the queue of deferred context writes couldn't
174
+ * reach disk. Since #291 the framework keeps no such queue (a write is stored
175
+ * at once, and enters each agent's window at that agent's presentation
176
+ * points), so quiesce() never throws it.
177
+ *
178
+ * @deprecated Never thrown since #291; kept exported for one release so a
179
+ * host that tests for it still builds.
154
180
  */
155
181
  export declare class QuiesceBlockedError extends Error {
156
182
  constructor(message: string, options?: {
@@ -171,7 +197,7 @@ export declare class QuiesceBlockedError extends Error {
171
197
  */
172
198
  export declare class ProviderWaitNotSleptError extends Error {
173
199
  readonly retryAfterMs: number;
174
- constructor(message: string, retryAfterMs: number);
200
+ constructor(message: string, retryAfterMs: number, options?: ErrorOptions);
175
201
  }
176
202
  interface InferenceToolSnapshot {
177
203
  sameRoundThinkTextPolicy: SameRoundThinkTextPolicy;
@@ -227,13 +253,15 @@ export declare class DefaultErrorPolicy implements ErrorPolicy {
227
253
  * grace only brings the abandon's report sooner.
228
254
  */
229
255
  export declare function setAbandonGraceForTests(framework: AgentFramework, ms: number): void;
256
+ export { heldFromResidents } from './presentation.js';
257
+ export { suppressedRow } from './presentation.js';
230
258
  /**
231
- * The admission record on a stored message: it was held from the residents
232
- * by a policy epoch (`metadata.tuneOut = { epochId }`). ONE predicate for
233
- * "held from the resident", read by the compiled-view filter and by the
234
- * mid-turn injection alike (#232 H1), so the window and the wire agree.
259
+ * The event type an MCPL server's `[toolsets]` notice (a tool change with no
260
+ * result or event to ride on, RFC-014 §8.3) is gated as: from the server's
261
+ * id, with the notice's text as its content. Only suppress rules read it,
262
+ * since a notice never wakes the agent.
235
263
  */
236
- export declare const heldFromResidents: (metadata: Record<string, unknown> | undefined) => boolean;
264
+ export declare const TOOL_CHANGES_EVENT_TYPE = "mcpl:tool-changes";
237
265
  /** Options for {@link AgentFramework.deriveAgent}. */
238
266
  export interface DeriveAgentOptions {
239
267
  /** The new agent's name. Single-use within this framework's lifetime. */
@@ -327,7 +355,10 @@ export declare function restoreAlert(restore: {
327
355
  })): ReinitAlertText;
328
356
  export declare function disposalAlert(disposal: {
329
357
  move: ReinitMove;
358
+ /** The writes kept in memory for it, by the move's hold or while its manager refused its work, that it ended before storing. */
330
359
  heldWrites?: number;
360
+ /** How many of them went on to the primary, which takes them in its place (passesToPrimary); the rest were dropped. */
361
+ passedOn?: number;
331
362
  reinitFailed?: string;
332
363
  cleanupFailed?: string;
333
364
  }): ReinitAlertText;
@@ -356,8 +387,9 @@ export declare function opsWebhookText(message: string): string;
356
387
  * the shed doesn't help, and the breaker stops at its rewind cap. The 413 arm
357
388
  * takes both labels membranes have given a 413, invalid_request and
358
389
  * context_length (see the notes below). Other statuses keep the history,
359
- * since a shed takes the exchange out of the agent's context, which only an
360
- * operator's undo brings back, and the status gives no sign that a shed
390
+ * since a shed takes the exchange out of the agent's context for good (the
391
+ * record keeps it, and no later start, restart or redo of another turn
392
+ * presents it again), and the status gives no sign that a shed
361
393
  * would help: a 404 is a model or an endpoint that doesn't exist, and 405,
362
394
  * 409, 410 and 415 are about the HTTP request or the resource, as a rule,
363
395
  * rather than the conversation.
@@ -477,10 +509,6 @@ export declare class AgentFramework {
477
509
  * clear failed, or a quiesce whose write failed partway, memory can say
478
510
  * serving while the record says quiesced, until a resume() clears it. */
479
511
  private hostModeRecordMayBeQuiesced;
480
- /** Whether a resume() is between serving and clearing the record: it has
481
- * cleared `quiesced` and is flushing the deferred writes, then clearing the
482
- * record. A resume() on the serving host leaves the record to it. */
483
- private resumeInFlight;
484
512
  private quiesceReason?;
485
513
  private quiescedAt?;
486
514
  private traceListeners;
@@ -511,6 +539,9 @@ export declare class AgentFramework {
511
539
  private providerAccelerationCooldowns;
512
540
  private providerAccelerationRecoveries;
513
541
  private providerAccelerationLastRecovery;
542
+ private budgetHolds;
543
+ private overBudgetDrainAfter;
544
+ private budgetHoldRecheckMs;
514
545
  private providerAccelerationDefaultCooldownMs;
515
546
  private providerAccelerationJitterMs;
516
547
  private inferenceBounds;
@@ -704,11 +735,13 @@ export declare class AgentFramework {
704
735
  private subconsciousAgentName;
705
736
  /** Its windowed strategy — the coordinator moves the anchor on tune-out entry. */
706
737
  private subconsciousStrategy;
738
+ /** Where the persistent subconscious's window starts, by sequence or by a fixed ordinal (#291, AF-5). */
739
+ private subconsciousAnchor;
707
740
  /** Its config (speak_in_channel gate, voice block provenance). */
708
741
  private subconsciousConfig;
709
742
  /** Tune-out coordinator (issue #77); non-null iff a reader is configured + channels. */
710
743
  private tuneOutCoordinator;
711
- /** Residents are offered `tune_out` (a reader is configured, or `tuneOut.enabled`). */
744
+ /** Residents are offered `tune_out` (a reader is configured). */
712
745
  private tuneOutOffered;
713
746
  /**
714
747
  * The reply anchor a coalesced delivery would set, parked until the
@@ -728,20 +761,6 @@ export declare class AgentFramework {
728
761
  /** Agents an abandon could not cancel (token held, no stream) — surfaced
729
762
  * in HostModeStatus until the next quiesce/resume. */
730
763
  private lastUnabandonable;
731
- /** True while the deferred-write queue is mirrored to its record, so each
732
- * change of it writes it: from a write of it that reached or may reach
733
- * the record, one that failed or met the cap unless quiesce() rejected
734
- * for it (deferredWritesFellBehind), or a boot that restored it, until a
735
- * write clears the record once the queue drains. */
736
- private deferredWritesPersisted;
737
- /** True from a write of the queue that failed or met the cap, unless
738
- * quiesce() rejected for it, until one succeeds: a run of failures
739
- * (deferredWritesFellBehind). A quiesce({ abandon: true }) over the cap
740
- * goes on rather than rejecting, so its write begins a run too. */
741
- private deferredWritesBehind;
742
- /** True once the cap has been met in the current run, so its line is
743
- * logged once a run, whatever began the run. */
744
- private deferredWritesCapLogged;
745
764
  /** The agent registry and its ended log, as recovery files beside the store
746
765
  * (nissa's #546 finding 3): Chronicle state follows the store's branch, and
747
766
  * an undo or an operator's surgery must not erase a result held for
@@ -760,39 +779,19 @@ export declare class AgentFramework {
760
779
  private endedLogIndexed;
761
780
  /** The last indexed entry's mark, so a log that changed under the index is seen. */
762
781
  private endedLogTail;
763
- /** Branch-independent recovery files (see FrameworkConfig.hostModePath /
764
- * deferredWritesPath). Undefined → branch-local slot fallback. */
782
+ /** Branch-independent recovery file for the host's mode (see
783
+ * FrameworkConfig.hostModePath). Undefined → branch-local slot fallback. */
765
784
  private hostModePath;
785
+ /** Where a release before #291 mirrored its deferred-write queue (see
786
+ * FrameworkConfig.deferredWritesPath), read once at boot by the importer
787
+ * (importPersistedDeferredWrites), for one release. Undefined → the
788
+ * store's slot. */
766
789
  private deferredWritesPath;
790
+ /** The writes the importer left queued for the next boot, its agent's
791
+ * store having failed (importPersistedDeferredWrites): reconcile doesn't
792
+ * deliver again the mail one of them carries. One release. */
793
+ private importLeftQueued;
767
794
  private recoveryFallbackWarned;
768
- /**
769
- * Deferred writes that have been handed to a context manager but whose
770
- * chronicle state is NOT yet durably synced. They stay in the durable
771
- * recovery queue until `ackDeferredWrites()` syncs the store — chronicle
772
- * persists the slot-chain head only on sync(), so acknowledging on append
773
- * alone would let a hard exit forget an accepted message.
774
- */
775
- private unackedDeferredWrites;
776
- /** Monotonic order stamp for deferred writes: the durable queue is always
777
- * written, restored, drained and flushed in `seq` order, whatever the
778
- * pending/un-acked split — a re-deferred entry keeps its place. Boot
779
- * recovery numbers the restored queue 1..N in that order, and the stamp
780
- * goes on from N (restorePersistedDeferredWrites). */
781
- private deferredSeq;
782
- /**
783
- * Per target agent: the store's message count when the OLDEST currently
784
- * un-acked entry for it was handed off. Persisted with the queue so a boot
785
- * after an interrupted flush knows exactly which slot range the batch
786
- * could occupy and dedups against all of it — never a fixed tail.
787
- */
788
- private deferredScanFrom;
789
- private deferredMessages;
790
- /** The marked held writes whose store couldn't be searched, each with the
791
- * failure said, said once until a lookup of them succeeds and again when
792
- * the failure changes (landedCopiesById), and those a drain has said it
793
- * holds what's queued behind (writeDrainedInOrder). */
794
- private unsearchableSaid;
795
- private stillUnknownSaid;
796
795
  private activeTurnTokens;
797
796
  /** Each running scheduler pass's requests, which it took from
798
797
  * pendingRequests: it holds those of the agents it hasn't taken up yet
@@ -810,8 +809,10 @@ export declare class AgentFramework {
810
809
  * (beginAgentTurn). */
811
810
  private settledTurns;
812
811
  /** Agents whose fresh turn's coalescing assembly is running
813
- * (beginAgentTurn): the window in which addMessage honours a write's
814
- * bypassDeferralFor naming that agent. */
812
+ * (beginAgentTurn). What is stored for such an agent meanwhile is
813
+ * presented before its compile (presentAtStart's 'assembly'), so
814
+ * addMessage stores it with the event clock it is due, and doesn't
815
+ * mark its placement unpresented. */
815
816
  private readonly assembling;
816
817
  /**
817
818
  * The InferenceRequest that started each agent's turn in progress — set and
@@ -896,6 +897,75 @@ export declare class AgentFramework {
896
897
  * roles from here instead of excluding kinds by hand.
897
898
  */
898
899
  private readonly registry;
900
+ /**
901
+ * The presentation index (#291, presentation.ts). Set once, in create(),
902
+ * before any agent is created; null only on a framework built from its
903
+ * prototype, as some suites build one. Each agent is taken on as it is
904
+ * registered (adoptPresentation), and from then on, for an agent whose
905
+ * window is presented (presents), a write enters the window at the
906
+ * agent's presentation points: its own rows as they are written, others'
907
+ * at its turn's start, at its tool boundary as the stream can carry them,
908
+ * at its turn's end, and at once while no turn of it is alive. Every
909
+ * write is stored at once.
910
+ */
911
+ private presentation;
912
+ private bootFreeze;
913
+ /** The arrival listener adoptPresentation installed for each agent, by its unsubscribe. */
914
+ private readonly presentationListeners;
915
+ /**
916
+ * Writes a surgery's hold kept out of every store while the operator's
917
+ * switch was awaited (addMessage, and the writes into a fork's store), in
918
+ * arrival order. They are in memory only, so a crash during the surgery
919
+ * loses them: the release replays them through the ordinary write path
920
+ * (releaseSurgeryHeldWrites).
921
+ */
922
+ private readonly surgeryHeldWrites;
923
+ /**
924
+ * Set while releaseSurgeryHeldWrites replays what a hold kept: the writes
925
+ * still to replay stay in surgeryHeldWrites, a write made meanwhile (a
926
+ * listener of a replayed write's trace) is kept behind them, and the
927
+ * tune-out's writesHeld reads true, as during the hold.
928
+ */
929
+ private replayingHeld;
930
+ /**
931
+ * Set by addMessage and storeInFork where the write the release replays
932
+ * (`replayed`) meets a hold a listener of its own traces began: the write
933
+ * isn't stored, and stays at the head of the queue for that hold's
934
+ * release (releaseSurgeryHeldWrites reads and clears it).
935
+ */
936
+ private replayHeldAgain;
937
+ /** A release of the tune-outs on record with no reader (releaseTuneOutsWithoutReader) that met held writes, to run once they are stored. */
938
+ private releaseWithoutReaderWaits;
939
+ /** How many writes this process has kept in memory (SurgeryHeldWrite.heldOrder): their arrival order across agents. */
940
+ private heldWritesKept;
941
+ /**
942
+ * Writes for an agent whose context manager refuses its work, by the
943
+ * agent's name, each agent's in arrival order: its re-initialization after
944
+ * a branch move failed (reinitializeManagers), and context-manager's
945
+ * initialization fence refused a write for it (refusesUntilReinitialized),
946
+ * at its writer or at a hold's release. Every later write for the agent
947
+ * waits behind them. They are in memory only, so a restart loses them: the
948
+ * next move that re-initializes the agent stores them, at its release, as
949
+ * the hold's own writes (recoverHeldWrites), and an agent that ends first
950
+ * passes on the ones the primary takes in its place (passHeldWritesOn).
951
+ */
952
+ private readonly heldForRecovery;
953
+ /**
954
+ * The context managers that refuse their work until a re-initialization
955
+ * succeeds, each with what failed: a move's re-initialization of it
956
+ * (reinitializeManagers), or a failed surgery's restore that selected the
957
+ * branch and couldn't initialize it (restoreSourceBranch).
958
+ */
959
+ private readonly managersRefusingWork;
960
+ /**
961
+ * The agents whose foreignRounds the framework sets (applyForeignRounds),
962
+ * each with the mode its configuration names: a resident that observes
963
+ * another (AgentConfig.foreignRounds), and the persistent subconscious
964
+ * (its config's); and an agent that takes its context from one of those
965
+ * (a derived agent, a conversation fork), with that agent's. Recorded at
966
+ * registration (configureForeignRounds).
967
+ */
968
+ private readonly foreignRoundsConfigured;
899
969
  /** Tell the first adoption candidate when task work is orphaned (config.dendrite.announceOrphans). */
900
970
  private announceOrphans;
901
971
  /**
@@ -911,8 +981,10 @@ export declare class AgentFramework {
911
981
  /** Per source agent, per kind: how many derivations, since when, and at which count the last note went. */
912
982
  private derivationTallies;
913
983
  private readonly sharedSlotAgents;
914
- /** The batched-wake lines already written (placeWakeLines), so every agent a
915
- * wake was for, and every later start of it, writes each at most once. */
984
+ /** The batched-wake lines already written (placeWakeLines), and the agents
985
+ * each was written for, so every later start of a wake writes each at
986
+ * most once for its agent: the delivery agent alone, and with the
987
+ * presentation index each resident a wake was for. */
916
988
  private readonly placedWakeLines;
917
989
  /** Rounds of tool calls, by their results array, that a save_recent_image
918
990
  * in the round counted by their share of the bound: such a round is
@@ -921,10 +993,14 @@ export declare class AgentFramework {
921
993
  /** Group commit: one fsync per event-loop turn, shared by every waiter. */
922
994
  /** The windows of forks and runs deregistered while the host was quiesced,
923
995
  * by agent name (releaseWindowNowOrAfterResume); resume() releases them
924
- * (runReleasesAfterResume), or stop() passes on what they left, unread or
925
- * queued, and clears them. While a name is here, no other flush drains
926
- * its queue (drainDeferredFor). */
996
+ * (runReleasesAfterResume), or stop() passes on what they left unread,
997
+ * and clears them. */
927
998
  private readonly releasesAfterResume;
999
+ /** Each released agent's reader facts, as the registry recorded them when
1000
+ * its release was asked for (releaseWindowNowOrAfterResume), before a
1001
+ * later agent can take its name: what its release reads as meant for it
1002
+ * (releasedWindow). */
1003
+ private readonly releasedReaders;
928
1004
  private readonly managerReleases;
929
1005
  private readonly releasedByCleanup;
930
1006
  private readonly resumesPending;
@@ -958,6 +1034,12 @@ export declare class AgentFramework {
958
1034
  * publish the call makes is credited with (publishReadThrough). Kept only
959
1035
  * while the dispatch runs (dispatchScriptToolCall). */
960
1036
  private readonly scriptCallStarts;
1037
+ /** The marks of channel_publish calls still out (publishReadThrough's,
1038
+ * taken at the call), by agent, until their delivery settles: a redo
1039
+ * gives them again (heldMarksOf, retakeMarks), as it gives a running
1040
+ * script's, so a script's publish that settles after the redo is credited
1041
+ * with the rows put back (holdPublishMark). */
1042
+ private readonly publishMarksInFlight;
961
1043
  /** Per agent, the unexpected thinking drops its last operator alert counted (noteThinkingLoss). */
962
1044
  private readonly thinkingLossIncidents;
963
1045
  /** Per live stream that can be noted, its rows so far after the compiled messages (noteRoundSent). */
@@ -1006,6 +1088,7 @@ export declare class AgentFramework {
1006
1088
  private mcplToolServers;
1007
1089
  /** Servers whose tools/list answered in the latest refresh. */
1008
1090
  private mcplListedServers;
1091
+ private mcplPublishedConnections;
1009
1092
  /** refreshMcplTools' starts, and the start whose result was published
1010
1093
  * last: a refresh that a later-started one has overtaken publishes
1011
1094
  * nothing, since that one listed every server after it. */
@@ -1025,7 +1108,8 @@ export declare class AgentFramework {
1025
1108
  private toolPatternKnownPrefixes;
1026
1109
  /** Maps serverId → McplServerConfig for prefix lookup. */
1027
1110
  private mcplServerConfigs;
1028
- /** Modern-MCP (2026-07-28) servers, by id; read through modernServers().
1111
+ /** Modern-MCP servers (2026-07-28, or a 2025 revision over HTTP), by id;
1112
+ * read through modernServers().
1029
1113
  * They are kept apart from the MCPL registry on purpose: they have no
1030
1114
  * grant, planes or server→host traffic, so the MCPL machinery (quiesce's
1031
1115
  * plane pauses, policy) never sees them. They take part
@@ -1062,6 +1146,7 @@ export declare class AgentFramework {
1062
1146
  * subsystem can be lazily initialized by connectMcplServer when the
1063
1147
  * framework started with zero configured servers. */
1064
1148
  private mcplInferenceRoutingConfig;
1149
+ private mcplUnpromptedChannel;
1065
1150
  /** The awareness ledger; null for a framework with neither storePath nor
1066
1151
  * discordAwarenessOutboxPath, which refuses a marks choice. */
1067
1152
  private readonly discordAwarenessOutbox;
@@ -1078,7 +1163,6 @@ export declare class AgentFramework {
1078
1163
  */
1079
1164
  private surgeryHold;
1080
1165
  private readonly conversationSpawnsInFlight;
1081
- private syncMoveReinit;
1082
1166
  private holdAlertMs;
1083
1167
  /** Serialize per-server drains so reconnect and an online undo cannot race. */
1084
1168
  private discordAwarenessDrains;
@@ -1088,6 +1172,10 @@ export declare class AgentFramework {
1088
1172
  private discordAwarenessDrainsJoined;
1089
1173
  private eventGate;
1090
1174
  private judgeWired;
1175
+ /** Wake onboarding's record of the agent's decisions (null: onboarding off, or no gate). */
1176
+ private wakeDecisions;
1177
+ /** The periodic review of what suppress rules hid; null with no gate or with the review off. */
1178
+ private suppressionReview;
1091
1179
  /** The heartbeat (FrameworkConfig.heartbeat), when the host turns it on. */
1092
1180
  private heartbeat;
1093
1181
  private usageTracker;
@@ -1198,14 +1286,11 @@ export declare class AgentFramework {
1198
1286
  * stop() fails with the cancel's error: that stop() doesn't wait for it,
1199
1287
  * even with no budget, and a later stop() waits for it as for anything an
1200
1288
  * earlier one left running (the last point below). After either:
1201
- * - an agent still registered whose stream is still running keeps its
1202
- * deferred writes queued, since the stream may still write. The stream's
1203
- * own turn-end flush takes them when it settles, if the process lives on,
1204
- * and a later stop() takes what that leaves; a memory-only queue loses
1205
- * them if the process exits first.
1289
+ * - an agent still registered whose stream is still running may still
1290
+ * write; what it writes is stored as it is written, as every write is.
1206
1291
  * - every ephemeral run still registered is ended, as after any stop(), and
1207
- * its end stores what is queued for it, as at any run's end, whatever its
1208
- * stream is doing: once a run has left, its stream's late events are
1292
+ * its release passes on what it never read, as at any run's end, whatever
1293
+ * its stream is doing: once a run has left, its stream's late events are
1209
1294
  * dropped, though a write the stream already had under way can still
1210
1295
  * land in the run's namespace after them.
1211
1296
  * - an event loop still in a call, such as a module's onProcess, finishes
@@ -1216,8 +1301,7 @@ export declare class AgentFramework {
1216
1301
  * Each conversation fork still live ends, as a closing fork's end does,
1217
1302
  * whatever its stream is doing, as each run does: its channel unbinds, and
1218
1303
  * its window's release passes on to the primary the notices it left that
1219
- * the primary takes in its place, unread in its window, or still queued
1220
- * for it unless it read the copy that landed there. Its end settles a
1304
+ * the primary takes in its place, unread in its window. Its end settles a
1221
1305
  * tool-result batch its stream still held and removes the stream's
1222
1306
  * entries, and once it has left, its stream's late events are dropped.
1223
1307
  */
@@ -1299,6 +1383,18 @@ export declare class AgentFramework {
1299
1383
  * them beside the gate's own timers, so it can weigh what waiting costs.
1300
1384
  */
1301
1385
  private upcomingWakesFor;
1386
+ /**
1387
+ * What will wake `agentName` with no new event, as healthSnapshot reports
1388
+ * it: soonest first, the first HEALTH_UPCOMING_WAKES of them, each with its
1389
+ * time, kind and whether the rule table lets it wake the agent (a probe:
1390
+ * gate.js isn't asked). A wake's `what` stays out: it can quote a reminder or
1391
+ * a queue reason, and health goes to observers granted nothing else.
1392
+ *
1393
+ * The field is left out when this can't say, so that it isn't taken for an
1394
+ * agent with nothing due: when a read throws, and when the heartbeat is
1395
+ * heartbeat-mcpl, whose next tick only its own process knows.
1396
+ */
1397
+ private upcomingWakesHealth;
1302
1398
  /**
1303
1399
  * The heartbeat's ticks and reminders for `agentName`, soonest first, which
1304
1400
  * the agent's rules decide as they decide a heartbeat push: one the rules
@@ -1342,7 +1438,7 @@ export declare class AgentFramework {
1342
1438
  * tick stores no prompt: its turn, when the gate triggers one, is a silent
1343
1439
  * heartbeat (silent-heartbeat.ts), prose suppressed. As for a stored push,
1344
1440
  * the wake of the agent the text was delivered to is dropped once a
1345
- * request of its own has carried and answered the text (readsWriteFor);
1441
+ * request of its own has carried and answered the text (readsRowFor);
1346
1442
  * another resident's isn't tied to it.
1347
1443
  */
1348
1444
  private deliverHeartbeat;
@@ -1359,6 +1455,7 @@ export declare class AgentFramework {
1359
1455
  /** Run a heartbeat call, its throw an error result. */
1360
1456
  private runHeartbeatTool;
1361
1457
  private auxiliaryMembraneFor;
1458
+ private managerCallLanded;
1362
1459
  /**
1363
1460
  * The reply judge's calls. None waits: under the agent's holds a call is
1364
1461
  * refused without being made, and the agent's turn stops the judge. A call
@@ -1441,6 +1538,36 @@ export declare class AgentFramework {
1441
1538
  * for its caller: the text, and the wait itself, which its rejection
1442
1539
  * carries (ProviderWaitNotSleptError). */
1443
1540
  private statedWaitNotSlept;
1541
+ private holdForBudgetRefusal;
1542
+ private rowsTurnStandsOn;
1543
+ private compressionPending;
1544
+ private startBudgetHoldRecheck;
1545
+ private driveBudgetHoldSoon;
1546
+ private driveBudgetHold;
1547
+ private releaseBudgetHolds;
1548
+ private releaseBudgetHoldsOnEvidence;
1549
+ private releaseBudgetHoldOnEvidence;
1550
+ private budgetHoldMoved;
1551
+ private compressionProgressOf;
1552
+ private closureWaits;
1553
+ private releaseBudgetHold;
1554
+ private storeBudgetHoldNote;
1555
+ private finishBudgetHold;
1556
+ private budgetHoldOpenText;
1557
+ private retractUnsentInjections;
1558
+ private endHeldTurn;
1559
+ private dropBudgetHold;
1560
+ private heldContinuation;
1561
+ private dropHeldTurn;
1562
+ /** Take `hold` out of its agent's wait, with no trace yet. */
1563
+ private detachBudgetHold;
1564
+ /** End a turn detachBudgetHold took out of its wait: its wakes back in the queue, then its end traced. */
1565
+ private endDetachedHold;
1566
+ private rowGone;
1567
+ private rowLeftWindow;
1568
+ private budgetWaitEnded;
1569
+ private checkBudgetHoldsAfterWindowChange;
1570
+ private kickOverBudgetDrain;
1444
1571
  /** When a hold's timer next fires: at its deadline, stepped past what one
1445
1572
  * timer can hold. A hold with no deadline (a wait held until released, or
1446
1573
  * the stand-in for unreadable records) asks again as often as unreadable
@@ -1756,7 +1883,9 @@ export declare class AgentFramework {
1756
1883
  /** What an agent is told when a send tool's words go to a channel it tuned
1757
1884
  * out, or undefined where nothing needs saying. A send keeps the tune-out
1758
1885
  * (ChannelRegistry.openChannelNow), so the agent that sent there expecting
1759
- * answers learns they still go to its subconscious. A send tool's answer
1886
+ * answers learns they are still held from it, and who reads them
1887
+ * meanwhile: the reader by the name it runs under, or forks of its
1888
+ * context (tuneOutReader). A send tool's answer
1760
1889
  * carries this, send_dm's included, or for a code_execution script's send
1761
1890
  * a notice in the agent's window: a tune-out diverts a DM too. The same setting
1762
1891
  * turns it off, a conversation agent gets none, and a failure while
@@ -1923,17 +2052,16 @@ export declare class AgentFramework {
1923
2052
  static readonly QUIESCE_TIMEOUT_MAX_MS = 600000;
1924
2053
  static readonly QUIESCE_TIMEOUT_DEFAULT_MS = 120000;
1925
2054
  /**
1926
- * Enter quiesce mode: write the deferred-write queue, persist the flag,
1927
- * suppress gate deliveries, pause all MCPL data planes, and wait for
1928
- * in-flight turns to settle (turn-alive is a turn token, which spans
1929
- * dequeue → settled teardown, a continuation of the turn on its way to its
1930
- * start, or the turn's retry, which a provider hold keeps or which waits
1931
- * to start: turnHolders). Idempotent, but for the queue's write, which
1932
- * every call makes first: when the queue can't reach disk, because its
1933
- * write fails or it's over the cap, the call rejects with a
1934
- * QuiesceBlockedError and the host's mode as it was, unless it has
1935
- * `abandon`, which goes on with the queue in memory and an alert
1936
- * (writeDeferredWritesForQuiesce).
2055
+ * Enter quiesce mode: persist the flag, suppress gate deliveries, pause all
2056
+ * MCPL data planes, and wait for in-flight turns to settle (turn-alive is
2057
+ * a turn token, which spans dequeue → settled teardown, a continuation of
2058
+ * the turn on its way to its start, or the turn's retry, which a provider
2059
+ * hold keeps or which waits to start: turnHolders). Idempotent. While
2060
+ * quiesced a write is stored at once, as always, unless a surgery's hold
2061
+ * or a context manager refusing its work keeps it in memory, and the
2062
+ * presentation index presents no agent another's row until resume
2063
+ * (#291): every window is frozen but for each agent's own rows, a
2064
+ * draining turn's tool boundaries included.
1937
2065
  *
1938
2066
  * On drain timeout the host STAYS quiesced (`drained: false` in the
1939
2067
  * result); with `abandon: true` the undrained streams are cancelled via a
@@ -1968,49 +2096,15 @@ export declare class AgentFramework {
1968
2096
  }): Promise<HostModeStatus>;
1969
2097
  private runResume;
1970
2098
  /**
1971
- * Land every deferred write whose target has no turn alive, as one batch
1972
- * acknowledged once: the chronicle is synced, then the persisted queue is
1973
- * rewritten without the batch (ackDeferredWrites). Until then the batch
1974
- * stays in the durable queue, so a crash mid-flush replays it at the next
1975
- * boot, which skips each entry that already landed, by its deferredWriteId —
1976
- * no loss, no duplicates. The batch is stored in queue order, whatever its
1977
- * targets (writeDrainedInOrder). A write the store rejects stays queued,
1978
- * logged, with what is queued behind it for its target, so the flush never
1979
- * stores that target's later entries ahead of it, and other targets' entries
1980
- * go on. One the store refuses as malformed, which it would at every flush,
1981
- * is logged and dropped instead, and what is behind it goes on. (A write
1982
- * that isn't deferred can still land ahead of it, such as one for an idle
1983
- * agent once the host has resumed.) A boot that meets it again logs it and
1984
- * goes on.
1985
- *
1986
- * Per-target: an agent whose turn is still alive keeps ITS messages
1987
- * deferred for its own turn boundary; everyone else's flush now.
1988
- */
1989
- private flushDeferredWrites;
1990
- /**
1991
- * Acknowledge every deferred write that has been handed to a context
1992
- * manager: sync the chronicle so the appended slots are durable, and only
1993
- * then drop them from the recovery queue. If the sync fails they stay in
1994
- * the durable queue (the next ack, or stop(), retries); a reboot in that
1995
- * state replays them, deduplicated by `deferredWriteId` for any that did
1996
- * reach disk. Idempotent and cheap when nothing is un-acked.
1997
- */
1998
- private ackDeferredWrites;
1999
- /**
2000
- * Move drained entries into the un-acked set and record, per target
2001
- * agent, the store position they will be appended after — then persist
2002
- * that receipt BEFORE any of them is written. Boot recovery scans from the
2003
- * recorded position to the tail, so every member of an interrupted batch
2004
- * is visible to the dedup, however large the batch.
2005
- */
2006
- private handOffDeferredWrites;
2007
- /**
2008
- * Which of `ids` already exist in some agent's store as a landed deferred
2009
- * write (`metadata.deferredWriteId`). Scans each context manager's recent
2010
- * tail blob-free — an interrupted flush is always within the last few
2011
- * hundred slots — and tolerates facades without windowed reads. A context
2012
- * that can't be read throws, naming its agent: counted as holding none, a
2013
- * write that landed there before its ack would land a second time.
2099
+ * Which of `ids`, an earlier release's queued writes, already exist in
2100
+ * some agent's store as a landed write (`metadata.deferredWriteId`): one an
2101
+ * interrupted flush of that release stored before its ack, or one this
2102
+ * importer stored at a boot that ended before it cleared the record. Scans
2103
+ * each context manager from the record's per-agent position (the whole
2104
+ * store where it names none) to the tail, blob-free, and tolerates facades
2105
+ * without windowed reads. A context that can't be read throws, naming its
2106
+ * agent: counted as holding none, a write that landed there would land a
2107
+ * second time.
2014
2108
  */
2015
2109
  private landedDeferredWriteIds;
2016
2110
  /** Atomic, durable JSON write for the recovery files. The document goes to
@@ -2043,95 +2137,144 @@ export declare class AgentFramework {
2043
2137
  private readRecoveryFile;
2044
2138
  private warnRecoveryFallbackOnce;
2045
2139
  /**
2046
- * Mirror the deferred-write queue durably while quiesced (and until an
2047
- * already-persisted queue drains). The quiesce flag itself is persisted
2048
- * because a crash mid-surgery is an expected event; the messages withheld
2049
- * BECAUSE of that surgery would otherwise die with the process — and the
2050
- * window is operator-length, not turn-length. Lives in the
2051
- * branch-independent recovery file so a rollback cannot orphan it.
2052
- * Deferrals outside a quiesce window (turn-alive, mid-tool-cycle) are
2053
- * mirrored only while such a queue is still persisted; otherwise they are
2054
- * memory-only: they land within the turn, at a tool boundary or at its
2055
- * end, and a crash before then loses them. That window runs to the turn's
2056
- * end for a message held there and what is queued behind it, and, on a
2057
- * stream that doesn't declare it carries injected messages (membrane's XML
2058
- * prefill path declares it can't), for every message deferred during the
2059
- * turn.
2140
+ * Store, once, the context writes a release before #291 left queued
2141
+ * (src/deferred-import.ts reads its record), and clear the record. One
2142
+ * release only: the release after this one deletes it. A host boots this
2143
+ * release until its record is empty (the `deferred-import` alert says
2144
+ * when writes stay queued, such as those for an agent a move cut), and
2145
+ * doesn't upgrade past it from a release that kept a queue.
2146
+ *
2147
+ * Such a release held a write while its agent's turn was alive or the host
2148
+ * was quiesced, and mirrored the queue to its recovery file (or the
2149
+ * store's slot) while quiesced, or from a flush that might not have
2150
+ * reached disk, until the queue drained. This release keeps no queue, so
2151
+ * create() calls this once, after the quiesced flags are restored and
2152
+ * every agent's window was written down at its registration, and before
2153
+ * the boot's pass over the windows (repairAndRest) and the registry's
2154
+ * reconcile:
2155
+ *
2156
+ * - A record that can't be read, or that isn't a queue, fails create()
2157
+ * (deferredWritesRefusal), and so does a context that can't be checked
2158
+ * for writes that already landed: taken as empty, the writes would never
2159
+ * be stored, or would be stored twice.
2160
+ * - Each write is stored in the order it arrived, across agents, under
2161
+ * its own id (`metadata.deferredWriteId`, addMessage's `imported`), so a
2162
+ * later boot finds it. One that already landed is skipped by that id: an
2163
+ * interrupted flush of the earlier release stored it before its ack, or
2164
+ * a boot of this one stored it and ended before it cleared the record.
2165
+ * One whose earlier write may have landed (`landing: 'unknown'`) is
2166
+ * looked up across its agent's whole branch first: found, it isn't
2167
+ * stored again; where the branch can't be searched, that agent is cut
2168
+ * there.
2169
+ * - A write keeps the audience it was queued with. One queued with none,
2170
+ * by a release before the stamp, is stamped as addMessage stamps any
2171
+ * write, and a tool-block pair (the puppet's) as its agent's own row.
2172
+ * - A write for an agent no longer registered goes to the primary, as its
2173
+ * by-name notice under the write's own id, when it is a failed reply, a
2174
+ * channel notice its reader could act on, or a module's write for a run
2175
+ * or a fork (passesToPrimary); anything else is dropped, logged. The
2176
+ * notice is stamped for the primary alone, whatever stamp the write was
2177
+ * queued with: one for the gone agent would put it in no window.
2178
+ * - A write that can't be stored cuts its agent: it and that agent's later
2179
+ * writes stay in the record for the next boot, and the other agents' go
2180
+ * on. One context-manager refuses as malformed, which it would at every
2181
+ * boot, is dropped, logged.
2182
+ * - A tune-out's release (`kind: 'tune-out-cancel'`) stored here owes its
2183
+ * agent the wake its cancel requested (#232 gap 6).
2184
+ * - Mail an imported write carries is released as it is stored
2185
+ * (releaseLandedMail), so reconcile doesn't deliver it again; the
2186
+ * boot's pass after the import asks its recipient's wake
2187
+ * (wakeForUnpresentedMail), as the delivery did.
2060
2188
  *
2061
- * A write that fails, or a queue over the cap, which writes nothing,
2062
- * leaves the record as it last held it, except that store only, a write
2063
- * whose sync failed is in the store, where a later sync can still put it
2064
- * on disk (writeDeferredWritesSlot). The queue stays in memory and
2065
- * mirrored, so its next change writes it again. Until a write succeeds, a
2066
- * restart restores what the record holds, or doesn't start if it can't
2067
- * read the record: it loses writes queued since, and brings back an entry
2068
- * withdrawn since (removePlacement, RFC-006's removal of an unread
2069
- * deferred write) that it still lists. The callers go on: a
2070
- * deferral's caller has already answered its source, so failing it would
2071
- * lose a write that can still land at resume. The first such write after
2072
- * one that succeeded raises an ops alert, and a line says when a write
2073
- * succeeds again (deferredWritesFellBehind). quiesce() writes the queue
2074
- * itself before it changes the host's mode, and refuses instead, unless
2075
- * the call has `abandon` (writeDeferredWritesForQuiesce).
2076
- */
2077
- private persistDeferredWrites;
2078
- /**
2079
- * Write the queue to its record as it stands, when the host is quiesced
2080
- * (`quiesced`, which quiesce() passes before it sets the flag) or the
2081
- * queue is mirrored: the queue when it holds anything, and an empty one
2082
- * over a record that held one. What the write throws is thrown. A queue
2083
- * whose JSON is longer than the cap writes nothing.
2084
- */
2085
- private writeDeferredWrites;
2086
- /** Store only, the slot is the record, and a write isn't on disk until the
2087
- * store syncs, so a sync that fails is the write's failure, as in
2088
- * persistHostMode. The slot is set by then, and a later sync can still
2089
- * put it on disk, so writeDeferredWrites marks the queue mirrored before
2090
- * it writes; a boot that restores such a queue skips each entry that
2091
- * already landed. */
2092
- private writeDeferredWritesSlot;
2093
- /** The durable queue: every deferred write not yet acked, pending and
2094
- * un-acked, in deferral order. */
2095
- private durableDeferredWrites;
2096
- /** Where the queue is recorded, as an operator would look for it. */
2097
- private deferredWritesRecord;
2098
- /**
2099
- * quiesce()'s write of the queue, before it changes the host's mode, as a
2100
- * quiesced host keeps it: a write held only in memory, such as one
2101
- * deferred behind a turn still alive, is on disk before quiesce() goes on,
2102
- * as its record is. When the queue can't reach disk, because its write
2103
- * fails or it's over the cap, which writes nothing, a call with `abandon`
2104
- * goes on with the queue in memory and the failure's or the cap's alert.
2105
- * Any other throws a QuiesceBlockedError naming the ways out, so quiesce()
2106
- * rejects with the host's mode as it was (store only, the slot set before
2107
- * a sync that failed leaves the queue mirrored: writeDeferredWritesSlot).
2108
- * Writes a flush landed stay in the queue until a store sync acks them, so
2109
- * it first retries an ack whose sync failed: once a sync succeeds they're
2110
- * on disk, and they leave the queue rather than count against the cap.
2111
- */
2112
- private writeDeferredWritesForQuiesce;
2113
- /**
2114
- * A write of the queue failed, or met the cap, and quiesce() didn't reject
2115
- * for it. The queue stays mirrored, so its next change writes it again.
2116
- * The first such write since one that succeeded raises an ops alert naming
2117
- * the record, and the rest of the run raises none. A failed write's own
2118
- * line is logged each time (persistDeferredWrites), and the cap's line the
2119
- * first time the cap is met in a run, whatever began it. On a host that is
2120
- * or is about to be quiesced, both say to resume before any restart, since
2121
- * a quiesced host lands its deferred writes only at a resume.
2122
- */
2123
- private deferredWritesFellBehind;
2124
- /** A write of the queue succeeded after a run of failures: say that the
2125
- * record has caught up. */
2126
- private deferredWritesCaughtUp;
2127
- /**
2128
- * Restore the deferred-write queue a crash or a stop left durable. Nothing
2129
- * stored is an empty queue. A queue that can't be read, or that reads as
2130
- * anything but a queue, throws, since taken as empty the next deferral
2131
- * would replace the stored one; so does a context that can't be checked
2132
- * for writes that already landed (see landedDeferredWriteIds).
2133
- */
2134
- private restorePersistedDeferredWrites;
2189
+ * - A write with no id is given one as it is read (readPersistedDeferredWrites),
2190
+ * and the record is written with it before anything is stored, so the
2191
+ * next boot finds a copy that landed by it. Where that write fails,
2192
+ * such a write cuts its agent.
2193
+ *
2194
+ * What is stored is presented to no window here: the pass after the
2195
+ * import presents each agent its own rows and what it is owed at rest, and
2196
+ * a quiesced host's other rows wait for resume. Once every write is stored
2197
+ * the store is synced, and only then is the record cleared, or written
2198
+ * again with the writes cut for the next boot; a sync that fails leaves
2199
+ * the record as it was, and the next boot skips what landed.
2200
+ */
2201
+ private importPersistedDeferredWrites;
2202
+ /**
2203
+ * At boot, the wakes a tune-out's rows still owe their agents (#232 gap
2204
+ * 6). A tune-out's release for the resident (`kind: 'tune-out-cancel'`)
2205
+ * and its notices for the subconscious (`tune-out-wake`,
2206
+ * `tune-out-cadence`, `tune-out-cancel-report`,
2207
+ * `tune-out-note-undelivered`) are stored at once and
2208
+ * made durable (commitDeliveries), but the wake each asks for is in
2209
+ * memory. One stored while a turn of its agent's was alive stays out of
2210
+ * that agent's window until its next tool boundary or the turn's end,
2211
+ * and its wake runs after; a
2212
+ * process that ended before then lost the wake, and the row is still not
2213
+ * in the window at the next boot. So each such row owes its agent a wake,
2214
+ * asked for here, before the boot's pass presents what each agent is owed
2215
+ * (repairAndRest). Earlier releases kept such a row in the deferred queue,
2216
+ * whose restore asked for the same wake; the importer still asks for it
2217
+ * for a release it stores (importPersistedDeferredWrites), and is not
2218
+ * asked twice. A row in the window already was presented at rest or
2219
+ * injected at a tool boundary, its wake run or lost with the turn as
2220
+ * before #291. Nothing for an agent the index doesn't present for. A
2221
+ * window that can't be read is logged and asks for nothing, and its agent
2222
+ * is returned: the boot's pass leaves what it is owed out of its window
2223
+ * (repairAndRest's `restExcept`), so a later boot reads it again.
2224
+ */
2225
+ private wakeForUnpresentedTuneOutRows;
2226
+ /**
2227
+ * At boot, the wakes stored mail still owes its recipients (#291). A
2228
+ * result or a message is stored for its recipient as it is delivered,
2229
+ * whatever the recipient's turn, and its mail released once the store has
2230
+ * synced the row (releaseLandedMail); the wake the delivery asks for is in
2231
+ * memory. Mail stored while a turn of its recipient's was alive stays out
2232
+ * of that agent's window until the turn's next point (its tool boundary
2233
+ * or its end), and its wake runs after the turn, unless a request of
2234
+ * the turn carried the row and was answered (rowDone); a process that
2235
+ * ended before then lost the wake, and the next boot has nothing left to
2236
+ * deliver: the mail is no longer held (or is released there, its copy
2237
+ * found in the store), and an interrupted job's result, stored, needs no
2238
+ * "ended without a result" notice (resultStoredFor). So each agent the
2239
+ * index presents for is woken, once per sender and kind, for each row of
2240
+ * mail it is owed and its window doesn't hold, as the delivery's wake
2241
+ * (`agent-<kind>:<sender>`, source 'dendrite'), asked for here, before the
2242
+ * boot's pass presents what each agent is owed (repairAndRest). That
2243
+ * covers mail an earlier release left queued, which the importer stores
2244
+ * and releases. The row is the recipient's when it
2245
+ * names that agent as the one it is for (`dendrite.to`); one stored before
2246
+ * mail named its recipient counts for an agent its audience names, so a
2247
+ * slot's observer isn't woken for a resident's mail. Mail whose sender
2248
+ * asked for no wake (sendAgentMessage's `wake: false`, recorded on the row
2249
+ * as `dendrite.wake: false`) asks for none; reconcile's redelivery of held
2250
+ * mail doesn't ask, as the registry doesn't record it. Mail an earlier
2251
+ * release left queued records no such ask (that release didn't queue
2252
+ * it), so it is woken for whatever its sender asked, where main asked no
2253
+ * boot wake for any queued mail.
2254
+ * Mail in the window already was presented at rest, or sent in a request
2255
+ * of the turn's (at its tool boundary), its wake run or lost as before
2256
+ * #291, and asks for none; nor does a wake with the same reason already
2257
+ * pending. A window that can't be read is logged and asks for nothing, and
2258
+ * its agent is returned, as wakeForUnpresentedTuneOutRows returns one. The
2259
+ * wakes are asked in memory: once the pass has presented the rows, a
2260
+ * process that ends, or a create() that fails, before they run loses them,
2261
+ * and the next boot, which finds the rows in the window, asks for none.
2262
+ */
2263
+ private wakeForUnpresentedMail;
2264
+ /**
2265
+ * Write the deferred-write record the importer read once it is done:
2266
+ * empty, or holding the writes it left for the next boot, in their order.
2267
+ * The file where it was read from the file, else the store's slot. A
2268
+ * write that fails is logged and alerted: the next boot imports the
2269
+ * record again, and skips what landed by its id.
2270
+ */
2271
+ private writeImportedRecord;
2272
+ /**
2273
+ * Write the deferred-write record the importer reads: empty, or holding
2274
+ * `entries`, in their order. The file where it was read from the file,
2275
+ * else the store's slot, synced. Throws what the write threw.
2276
+ */
2277
+ private recordImportQueue;
2135
2278
  /**
2136
2279
  * Operator-driven maintenance: run (or join) one bounded compression pass —
2137
2280
  * the same runQueuedMaintenance the timer drives, so tool definitions are
@@ -2482,13 +2625,22 @@ export declare class AgentFramework {
2482
2625
  private discardEphemeralCandidate;
2483
2626
  /**
2484
2627
  * The default wording for the call that derived a child: who it is, what
2485
- * kind, and how long — the fields the consent event names, so the fork
2628
+ * kind, and how long — the fields the creation event names, so the fork
2486
2629
  * never has to infer its own lifetime from context (Linn, 10-09).
2487
2630
  */
2488
2631
  private derivedNote;
2489
2632
  /**
2490
2633
  * The parent's in-flight tool round, reproduced on the child's branch so
2491
2634
  * the child sees the call that made it (see `DeriveAgentOptions.pendingRound`).
2635
+ *
2636
+ * The results it carries are the ones the parent holds: while the round
2637
+ * waits for its tools, those `completed` so far; once every result is in,
2638
+ * the `ready` state's `toolResults`. A round stays pending while a boundary
2639
+ * builds its results for storing (the ordinary tool boundary, or a stream
2640
+ * that completed while its tools ran, which gave each call still running
2641
+ * an error result), and the state is `ready` then, so a derive landing in
2642
+ * that build frames the round with its results, never with a note that a
2643
+ * call whose result is in is still running.
2492
2644
  */
2493
2645
  private framePendingRound;
2494
2646
  /**
@@ -2530,10 +2682,21 @@ export declare class AgentFramework {
2530
2682
  * - A live agent: a snapshot derived from its context — at the head, or
2531
2683
  * at `atSequence` for an earlier state. The snapshot is its own branch;
2532
2684
  * the agent keeps running and is not affected by anything done to it.
2685
+ * `atSequence` is a sequence on the store's branch that follows a
2686
+ * presentation into the agent's window (#291), such as
2687
+ * `getStore().currentSequence()` read after one, not a row's own
2688
+ * sequence: a row enters the window at a write after its own, so a cut
2689
+ * at the row's own sequence holds it in the snapshot's record
2690
+ * (getAllMessages) and not in its window (getPresentedMessages), where
2691
+ * it reads as arrived (context-manager's derive).
2533
2692
  * - An ended agent: the context it left, reopened where it lives.
2534
2693
  *
2535
- * The returned manager uses a passthrough strategy: it shows what is
2536
- * stored, raw. An ended agent's context is the real one — treat it as
2694
+ * The returned manager uses a passthrough strategy, so nothing is
2695
+ * folded: its compile is the agent's window as the agent's view shows it
2696
+ * (the rows the window holds, through its view filter), and in legacy
2697
+ * mode, where the window is the record, the record so. These compiled
2698
+ * views omit legacy reasoning-loss notices. getAllMessages()
2699
+ * lists the record. An ended agent's context is the real one — treat it as
2537
2700
  * read-only unless you mean to change what a later resume starts from.
2538
2701
  */
2539
2702
  inspectAgentContext(name: string, options?: {
@@ -2541,6 +2704,31 @@ export declare class AgentFramework {
2541
2704
  }): Promise<ContextManager>;
2542
2705
  /** Open the context an ended agent left, wherever it lives. */
2543
2706
  private reopenAgentContext;
2707
+ /**
2708
+ * The view an agent's live context was opened with, by where its rows go
2709
+ * and what it observes (context-options.ts): a resident's, on the
2710
+ * residents' slot, or for an isolated agent that watches that slot, the
2711
+ * residents' view when its edge leaves held traffic out, and the
2712
+ * subconscious's when it shows it. For an isolated agent that
2713
+ * watches no residents' slot on its branch (a worker, a conversation
2714
+ * fork), whose view excludes only legacy reasoning-loss notices.
2715
+ */
2716
+ private liveViewFilterOf;
2717
+ /**
2718
+ * The agent a chain of shared derivations started from, whose view each
2719
+ * derived context in it inherited: `record` itself when it isn't one, and
2720
+ * the newest record the registry has of a parent otherwise, back to one
2721
+ * that isn't (or one the registry no longer knows, by its name).
2722
+ */
2723
+ private viewOwnerOf;
2724
+ /**
2725
+ * The view a context derived by shared inheritance was opened with
2726
+ * (deriveSharedContext): what the agent its chain of derivations started
2727
+ * from sees (liveViewFilterOf), and the stored injections of each agent in
2728
+ * the chain, which carry that agent's name and would otherwise read as
2729
+ * another's. Legacy notices remain excluded even for an own injection.
2730
+ */
2731
+ private derivedViewFilterOf;
2544
2732
  /** Open a derived agent's context on a branch of its own (see deriveAgent). */
2545
2733
  private deriveSharedContext;
2546
2734
  /** Flat list of registered agents with their roles, lifetime and relationships. */
@@ -2641,19 +2829,23 @@ export declare class AgentFramework {
2641
2829
  * else would surface it (reparentAgent delivers it).
2642
2830
  */
2643
2831
  private tellResultHeld;
2644
- /** A host-framed lifecycle fact in an agent's context. Never voiced as anyone. */
2832
+ /**
2833
+ * A host-framed lifecycle fact in an agent's context. Never voiced as
2834
+ * anyone. Its `dendrite` detail names the agent it is for (`to`), as mail's
2835
+ * does.
2836
+ */
2645
2837
  private lifecycleNotice;
2646
2838
  /**
2647
- * The creation ("consent") event: names what kind of agent this is, what
2648
- * ends it and what happens to it when its spawner ends. A derived agent's
2649
- * creation is told to the agent it was derived from only when the host
2650
- * asks for it with a derivationNotice and that returns text: one
2651
- * host-framed line in the source's context, with no wake, given the
2652
- * framework's line built from the same facts as the trace. Without one the
2653
- * source is told nothing; the trace is emitted either way. Both derivation
2654
- * paths announce after the fork's branch or copy exists, so a fork never
2655
- * inherits the notice about itself; a source that has ended is told
2656
- * nothing (lifecycleNotice).
2839
+ * The creation event: names what kind of agent this is, what ends it and
2840
+ * what happens to it when its spawner ends. A derived agent's creation is
2841
+ * told to the agent it was derived from only when the host asks for it
2842
+ * with a derivationNotice and that returns text: one host-framed line in
2843
+ * the source's context, with no wake, given the framework's line built
2844
+ * from the same facts as the trace. Without one the source is told
2845
+ * nothing; the trace is emitted either way. Both derivation paths announce
2846
+ * after the fork's branch or copy exists, so a fork never inherits the
2847
+ * notice about itself; a source that has ended is told nothing
2848
+ * (lifecycleNotice).
2657
2849
  */
2658
2850
  private announceAgentCreated;
2659
2851
  /** The derivation notice's text, addressed to the agent `from` the record was derived. */
@@ -2739,6 +2931,9 @@ export declare class AgentFramework {
2739
2931
  * ran would be overwritten by this boot's first registration.
2740
2932
  */
2741
2933
  private restoreAgentRegistry;
2934
+ private passOnInterruptedNotices;
2935
+ /** The rows of the interrupted record `from` (name#incarnation@createdAt) whose pass the primary's store holds (passOnInterruptedNotices). */
2936
+ private rowsPassedOn;
2742
2937
  /**
2743
2938
  * Boot reconciliation, once configuration has declared its agents.
2744
2939
  * Restart behaviour follows from lifetime: persistent agents were just
@@ -2750,11 +2945,54 @@ export declare class AgentFramework {
2750
2945
  /**
2751
2946
  * Deliver held mail that hasn't landed. Its copy may have reached the
2752
2947
  * recipient's store in the same sync that the release missed, and then it
2753
- * is released instead; and a write the deferred queue still holds for it
2754
- * lands at the next flush and releases it then (releaseLandedMail). Either
2755
- * way a second delivery would put it in the window twice under one mail id.
2948
+ * is released instead. In the residents' shared slot the recipient's
2949
+ * store holds every resident's mail, so a copy counts only where it was
2950
+ * for this recipient (dendrite.to); a row stored before mail carried `to`
2951
+ * counts by its mail id alone (isMailCopyFor).
2952
+ *
2953
+ * A write an earlier release queued for this mail, which the importer
2954
+ * stored, was released as it was stored (releaseLandedMail), and one
2955
+ * whose release missed its sync is found here. One the importer left
2956
+ * queued for the next boot (importLeftQueued) lands then and releases the
2957
+ * mail then; a second delivery here would put it in the window twice
2958
+ * under one mail id. A copy for another recipient is not that write, as a
2959
+ * stored one isn't.
2960
+ *
2961
+ * A copy found is released only once the store has synced, as
2962
+ * releaseLandedMail releases: the copy may be in memory only (an import
2963
+ * whose sync failed), and the release is written to the registry's own
2964
+ * recovery file at once. A sync that fails leaves the mail held and
2965
+ * undelivered, for the next boot's check.
2756
2966
  */
2757
2967
  private deliverHeldMail;
2968
+ /**
2969
+ * Whether `recipient`'s store holds a result the agent `record` names
2970
+ * delivered in this incarnation, for that recipient (dendrite.to, or none
2971
+ * on a row stored before mail named its recipient). Mail is released once
2972
+ * its row is stored, so after a restart that interrupted the agent, its
2973
+ * result is no longer held mail but is in the store: a recipient whose
2974
+ * turn was alive when it arrived has it stored at once, as an idle one
2975
+ * does (#291). It counts as handed over even while it is out of the
2976
+ * recipient's window, the turn it arrived in cut off by the restart: the
2977
+ * boot asked that recipient's wake for it again (wakeForUnpresentedMail),
2978
+ * and its pass presented it.
2979
+ *
2980
+ * A result counts only where it was produced (dendrite.producedAt, which
2981
+ * every delivered result carries) at or after the record was created: a
2982
+ * single-use name whose counter aged out of the registry starts again at
2983
+ * incarnation 1, so an earlier agent of that name and incarnation may have
2984
+ * delivered one to the same recipient. Both times are the registry's wall
2985
+ * clock (Date.now): the two agents are always on opposite sides of a
2986
+ * restart, so they don't share a millisecond, but a clock stepped back
2987
+ * between the record's creation and its result can misjudge the result
2988
+ * as an earlier agent's.
2989
+ *
2990
+ * Undefined where the store can't be read, which is logged: whether the
2991
+ * result was handed over is unknown, so the boot leaves the record out of
2992
+ * its notice and of its settling (settleInterrupted), and the next boot
2993
+ * asks again.
2994
+ */
2995
+ private resultStoredFor;
2758
2996
  private createDeferred;
2759
2997
  /** Liveness ping for an active ephemeral run (no-op otherwise). */
2760
2998
  private touchEphemeralRun;
@@ -2789,7 +3027,19 @@ export declare class AgentFramework {
2789
3027
  * Rejects with ProviderWaitNotSleptError when the run ends rather than sleep
2790
3028
  * a retryable failure's stated wait longer than the framework's ten-minute
2791
3029
  * cap, or one it can't represent, and with a plain Error for any other
2792
- * ending, a stated wait its error policy declines among them.
3030
+ * ending, a stated wait its error policy declines among them. A failed
3031
+ * turn's rejection never carries a provider's message: a provider's failure
3032
+ * is told by membrane's type and the HTTP status, a safety failure only as
3033
+ * a request that couldn't be completed, a progress bound's cut, a stream's
3034
+ * abort and context-manager's refusal of a compile in their own words, and
3035
+ * any other failure as the turn failing. Where an error ended the turn, the
3036
+ * rejection's `cause` is a bounded copy of it: a plain `Error` with its
3037
+ * `name`, its message and stack cut to 2,000 characters, and, from a
3038
+ * MembraneError, its `type`, `retryable`, `httpStatus`, `providerErrorCode`
3039
+ * and `retryAfterMs`, which a host reads by name. It carries no `rawError`
3040
+ * or `rawRequest`, and `instanceof MembraneError` doesn't hold on it. Its
3041
+ * message and stack are the failure's own, a provider's words included, for
3042
+ * classifying the failure and for logs, and aren't for showing to an agent.
2793
3043
  *
2794
3044
  * The caller provides a pre-created agent + contextManager (from createEphemeralAgent).
2795
3045
  * The task message should already be in the context manager.
@@ -2810,9 +3060,22 @@ export declare class AgentFramework {
2810
3060
  * Query inference logs.
2811
3061
  * Returns entries with summary info (doesn't resolve blobs).
2812
3062
  */
2813
- /** Tune-out (issue #77): divert a channel to your subconscious. Present
2814
- * only when the subconscious resident is configured. */
2815
- private static readonly TUNE_OUT_TOOL;
3063
+ /** Tune-out (issue #77): hold a channel. Offered when a reader is
3064
+ * configured (tuneOutOffered), its text naming the reader (tuneOutTool). */
3065
+ private tuneOutToolDefinition;
3066
+ /**
3067
+ * The reader of a tuned-out channel's traffic, as the text a resident
3068
+ * reads describes it (tuneOutTool, tunedOutSendNote, tune_out's answers
3069
+ * and the channel registry's refusals of a tuned-out channel): the persistent
3070
+ * subconscious by the name it runs under, which the host gives it, or
3071
+ * reader forks as forks of the resident's context. There is no hold
3072
+ * without a reader (0.33.0): a tune-out is on record with none running
3073
+ * only where its release failed, after the persistent reader ended or at
3074
+ * a start with none configured. The text names the persistent reader as
3075
+ * configured then, or by its default name (persistentReaderName), as one
3076
+ * not running (`running: false`), which what its messages are says.
3077
+ */
3078
+ private tuneOutReader;
2816
3079
  /** `focus`: the resident-facing alias for `tune_out` with scope "all-except" (#232 decision 2). */
2817
3080
  private static readonly FOCUS_TOOL;
2818
3081
  /** Synthesized sleep/wake tool definitions (present when a gate is wired). */
@@ -2823,7 +3086,15 @@ export declare class AgentFramework {
2823
3086
  * hot-reloaded gate.json (same validation as load), so a rule takes effect
2824
3087
  * immediately and survives restart. */
2825
3088
  private static readonly WAKE_RULE_TOOLS;
3089
+ /** Wake onboarding's answers (gate/wake-onboarding.ts): accept an MCPL
3090
+ * server's suggested treatment (MCPL RFC-001 §5), all of it or some, or
3091
+ * decline it. Present when a gate is wired and onboarding is on. */
3092
+ private static readonly WAKE_ONBOARDING_TOOLS;
2826
3093
  private static readonly JUDGED_WAKE_RULE_TOOLS;
3094
+ /** What the agent's suppress rules have kept out of its context, read from the stamped rows (gate/suppression-stats.ts). Present when a gate is wired. */
3095
+ private static readonly SUPPRESSION_STATS_TOOL;
3096
+ /** Writes the stamped rows to a workspace file (gate/suppression-stats.ts). Present when a gate and a workspace are. */
3097
+ private static readonly DUMP_SUPPRESSED_TOOL;
2827
3098
  /** Discoverability for event tags (MCPL RFC-001): the reserved chat:* core,
2828
3099
  * each connected server's declared tag ontology, and gate.js status. */
2829
3100
  private static readonly EVENT_TAGS_TOOL;
@@ -2864,6 +3135,35 @@ export declare class AgentFramework {
2864
3135
  * skipped.
2865
3136
  */
2866
3137
  private reactToRefusal;
3138
+ /**
3139
+ * Shed the newest turn: take the newest message that isn't a system
3140
+ * message, and that reached a request, out of what the agent is sent,
3141
+ * whoever wrote it, with the rest of its exchange (the tool_use turn
3142
+ * paired with a tool result, and the whole of a body stored in shards).
3143
+ * With `carried` (the stored bodies a refused request's compile carried,
3144
+ * by each body's first message id), only a message that request carried
3145
+ * counts, or the stored result of a call it carried, which goes with that
3146
+ * call as one exchange; a row that carries nothing a request sends
3147
+ * (asNextRequestCarries) is passed over and left in place. It adds no
3148
+ * marker; the caller keeps one consolidated marker for the episode
3149
+ * (updateRewindMarker). The returned record's descriptor says what was
3150
+ * set aside and its size, never the content. Returns null when nothing
3151
+ * that counts is left.
3152
+ *
3153
+ * On a presented window (#291) the shed is the window's: the newest rows
3154
+ * of the agent's own window, in its order, leave it as an undone turn's
3155
+ * do (retractRows with `undone`), so no presentation point brings them
3156
+ * back, and the record keeps them, as the marker says. No other agent's
3157
+ * window, nor its cache prefix or signed thinking, changes. A row the
3158
+ * agent is never sent is passed over: a system_change row, a row a
3159
+ * tune-out holds from residents (for an agent whose window leaves them
3160
+ * out), and another agent's stored context injection. On a window that is
3161
+ * still the record, the rows are removed from it, as before the index,
3162
+ * and leave every other window that held them.
3163
+ *
3164
+ * Shared by the refusal rewind, automatic or forced by `/unstick`, and by
3165
+ * the shed after inference exhaustion (quarantinePoisonedHistory).
3166
+ */
2867
3167
  private shedNewestTurn;
2868
3168
  /**
2869
3169
  * Maintain exactly ONE consolidated marker for the current rewind episode,
@@ -2910,8 +3210,9 @@ export declare class AgentFramework {
2910
3210
  /** Agent state at queue time — 'idle' means no turn holds the agent, so
2911
3211
  * the turn starts on the next scheduler pass unless a provider hold (a
2912
3212
  * provider's stated wait, or a capacity cooldown) holds it until the hold
2913
- * ends, or a start of the agent's that waits for an auxiliary call to
2914
- * finish goes first; anything else means it runs after the current turn. */
3213
+ * ends, or a budget hold keeps it until compression makes room, or a
3214
+ * start of the agent's that waits for an auxiliary call to finish goes
3215
+ * first; anything else means it runs after the current turn. */
2915
3216
  agentStatus?: string;
2916
3217
  /** True when the host is quiesced: the wake is PARKED, not running, until resume(). */
2917
3218
  quiesced?: boolean;
@@ -2920,8 +3221,11 @@ export declare class AgentFramework {
2920
3221
  * Handle a `host/command` request from an MCPL surface server (e.g. a
2921
3222
  * Discord slash command). Currently supports:
2922
3223
  *
2923
- * undo — revert the last N inference turns (branch-based, see
2924
- * `undoLastTurn`). The response includes the last message the agent
3224
+ * undo — revert the last N inference turns on the agent's window (see
3225
+ * `undoLastTurn`; no branch moves), or with `messages`, the last N rows
3226
+ * of its window that are in its own slot (the record's, on a window that
3227
+ * is still the record), by a rollback onto a new branch (see
3228
+ * `rollbackToMessage`). The response includes the last message the agent
2925
3229
  * would see in its context after the undo, obtained via the transparent
2926
3230
  * `previewActivation` render (no inference, no Chronicle writes).
2927
3231
  *
@@ -2987,73 +3291,261 @@ export declare class AgentFramework {
2987
3291
  * It moves the store once any maintenance already running has finished, so
2988
3292
  * the move can come after the call returns, and a refusal moves nothing.
2989
3293
  * An operator's operation: refused once stop() has begun, and waited for
2990
- * by stop() while it runs.
3294
+ * by stop() while it runs. It is written to the operator log as a
3295
+ * `checkout` (`requester` and `note` as the caller gives them), a refusal
3296
+ * or failure with its error, but for the refusal once stop() has begun,
3297
+ * which throws before anything is written.
2991
3298
  *
2992
3299
  * The branch moves under every agent sharing the store, so the switch
2993
3300
  * reserves the store as a surgery does: every agent must be idle with no
2994
3301
  * turn alive (no continuation or held retry of one on its way), or it is
2995
3302
  * refused (OperatorActionError 'agent-busy'), and no turn starts until the
2996
- * switch is done.
2997
- *
2998
- * Every agent's context manager is re-initialized for the branch before
2999
- * the store is released (reinitializeManagers). One whose
3000
- * re-initialization fails raises an ops alert naming its agent
3303
+ * switch is done. Before the reservation is released every live agent's
3304
+ * context follows the move (followBranchMove): its context manager is
3305
+ * re-initialized for the branch (reinitializeManagers), and its window is
3306
+ * written down there if the branch was made before its write-down. One
3307
+ * whose re-initialization fails raises an ops alert naming its agent
3001
3308
  * (`context-reinit-failed`), and the switch still resolves. A switch to the
3002
3309
  * branch the store is already on re-initializes them too, which is how a
3003
3310
  * manager left refusing by a failed re-initialization is recovered without
3004
3311
  * a restart.
3005
3312
  */
3006
- switchBranch(name: string): Promise<void>;
3007
- /**
3008
- * Undo the last inference turn for an agent.
3009
- *
3010
- * Creates a new branch at the Chronicle sequence recorded before that turn
3011
- * and switches to it, atomically rolling back all state (messages, context
3012
- * log, inference log, MCPL checkpoints).
3313
+ switchBranch(name: string, opts?: {
3314
+ requester?: OperatorRequester;
3315
+ note?: string;
3316
+ }): Promise<void>;
3317
+ /**
3318
+ * After the store's branch moved, under a store reservation (a host's
3319
+ * switchBranch, a rollback's switch, a suppression's fork, or a failed
3320
+ * surgery's restore): every live agent's context follows the move. Its
3321
+ * context manager is re-initialized for the branch the store is on
3322
+ * (reinitializeManagers, #353), every one but `except`'s, the agent the
3323
+ * move was made through, whose own switchBranch or fork initialized it,
3324
+ * or whose failed surgery's restore left it refusing its work, which
3325
+ * counts here as a failed re-initialization, reported by the restore and
3326
+ * not returned (a manager that didn't make the move keeps its strategy at the old
3327
+ * branch generation otherwise, and an AutobiographicalStrategy refuses
3328
+ * every compile until a re-initialization). Then the presentation index
3329
+ * rebases each agent on the new branch (#291): a window the branch has
3330
+ * none of (a branch made before the agent's write-down, a rollback into
3331
+ * rows the write-down presented) is written down, and the agent's own
3332
+ * rows not in its window are presented, so an agent that presented before
3333
+ * the move presents after it, and an agent whose configuration names how
3334
+ * other agents' rounds go out to it is sent them so where its window is
3335
+ * presented now, as stored where it isn't (applyForeignRounds). Arrivals
3336
+ * wait for the reservation's release, which presents what each agent is
3337
+ * owed. Redo entries are
3338
+ * dropped, every agent's: each was an undo on a window of the branch the
3339
+ * store left. A switch to the branch the store was on (`sameBranch`, a
3340
+ * refusing manager's recovery) moves no branch, so each agent whose
3341
+ * window is presented after the rebase keeps its redo entries: an undo is
3342
+ * a retraction on that window, and the rebase presents no undone row
3343
+ * (main kept redo across a switch too). Returns the managers whose re-initialization failed, for
3344
+ * the caller to report (reportReinitFailures) before it releases the
3345
+ * store.
3013
3346
  *
3014
- * The undone branch is saved so `redo()` can restore it.
3015
- * Returns the checkpoint that was undone, or null if nothing to undo.
3347
+ * Never throws: the move has happened. A manager whose re-initialization
3348
+ * fails stays fenced until a later one succeeds (switchBranch() to the
3349
+ * branch the store is on), and its agent's window stays the record until
3350
+ * the next move, traced as presentation:failed at `'rebase'`; so does an
3351
+ * agent whose window can't be written down. The writes for it meanwhile
3352
+ * wait in memory (heldForRecovery), and the move whose re-initialization
3353
+ * of it succeeds stores them at its release (recoverHeldWrites).
3354
+ */
3355
+ private followBranchMove;
3356
+ /**
3357
+ * Undo the last inference turn for an agent, on its window (#291,
3358
+ * decision 4): the rows the turn's checkpoint saw enter the window after
3359
+ * it leave it, the agent's own as undone and others' as arrived and not
3360
+ * yet presented, which its next start presents again. Nothing is written
3361
+ * to the record and no branch moves, so `fromBranch` and `toBranch` are
3362
+ * both the store's branch, `window` says how many rows left, and a
3363
+ * `window:undone` trace is emitted. The record, the workspace and
3364
+ * `_config` mounts, MCPL checkpoints and the inference log are left as
3365
+ * they are: rollbackToMessage is the record-level revert. `redo()` puts
3366
+ * the rows back. It is refused while a turn of the agent's is alive, and
3367
+ * allowed while another agent's is, and refused for an agent whose window
3368
+ * isn't presented (presents: a write-down that failed, at its
3369
+ * registration or after a branch move, or a context that couldn't follow
3370
+ * a branch move), which has no window of its own to undo on.
3016
3371
  *
3017
- * The branch moves under every agent sharing the store, so an undo
3018
- * reserves the store as a surgery does: every agent must be idle, or it is
3019
- * refused (OperatorActionError 'agent-busy'). It returns once the store has
3020
- * moved, and the store stays reserved until every agent's context manager
3021
- * is re-initialized for the new branch, so no turn starts before then. One
3022
- * whose re-initialization fails raises an ops alert naming its agent
3023
- * (`context-reinit-failed`). An undo or redo made before the managers are
3024
- * done moves the store again under the same reservation, and they are
3025
- * re-initialized for the branch the last one leaves.
3372
+ * Returns `{ undone: false }` when there is nothing to undo. A store error
3373
+ * before any row has left the window is thrown as it is, and the turn can
3374
+ * still be undone. An undo that fails after rows left (cut short, or its
3375
+ * checkpoint save failing) throws OperatorActionError 'failed', saying how
3376
+ * many rows left, and can be redone (undoOnWindow).
3026
3377
  *
3027
- * `settled`, present when the store moved, settles once that reservation
3028
- * is released, every manager re-initialized or its failure alerted, and
3029
- * never rejects. Await it before work that needs the store free: a
3030
- * compile on an agent's own context manager, or a write meant to land at
3031
- * once, which the reservation would defer. An undo or redo that moves the
3032
- * store again under the same reservation settles with it.
3378
+ * No branch moves, so nothing is reserved and no context manager is
3379
+ * re-initialized (#353's re-initialization follows a branch move, and an
3380
+ * undo on the window makes none): every other agent goes on compiling.
3381
+ * Its result carries no `settled`, which an undo gives only when it moved
3382
+ * the store.
3033
3383
  */
3034
3384
  undoLastTurn(agentName: string, requester?: OperatorRequester): {
3035
3385
  undone: boolean;
3036
3386
  turnIndex?: number;
3037
3387
  fromBranch?: string;
3038
3388
  toBranch?: string;
3389
+ window?: {
3390
+ retracted: number;
3391
+ represented: number;
3392
+ };
3393
+ /** Present only when the undo moved the store, which an undo on the
3394
+ * window never does: nothing waits to settle (#291, decision 4). */
3039
3395
  settled?: Promise<void>;
3040
3396
  };
3041
3397
  /** undoLastTurn's work, for a host/command undo already admitted: a stop()
3042
3398
  * begun by a trace of one of its turns doesn't refuse the next. */
3043
3399
  private runUndoLastTurn;
3044
3400
  /**
3045
- * Redo a previously undone turn for an agent.
3401
+ * An undo on the window (undoLastTurn): the
3402
+ * agent's newest checkpoint's tail of its window, the rows at the index
3403
+ * length it recorded and after (checkpointLength), leaves it. The agent's
3404
+ * own rows leave as undone, so no presentation point presents them again
3405
+ * until a redo; others' rows leave as arrived and not presented, and its
3406
+ * next presentation point presents them again, after what it holds then.
3407
+ * The rows are named body by body, by the shard that names each, in
3408
+ * window order, and kept for redo with the ordinal each held, the index
3409
+ * length the undo left, and which of them each of the agent's marks
3410
+ * covered (marksOverTail).
3046
3411
  *
3047
- * Switches back to the branch that was active before the last undo.
3048
- * Returns false if there's nothing to redo.
3412
+ * Own rows and others' leave in two calls, each whole or not at all on a
3413
+ * store that batches. The redo entry is kept before either, so an undo
3414
+ * cut short after rows left (between the calls, or partway through one
3415
+ * on a store without the batched form) is refused with
3416
+ * OperatorActionError 'failed' and can be redone: a redo puts back what
3417
+ * left, in its order, and its checkpoint stays for another undo to finish
3418
+ * it. So is an undo whose rows all left and whose checkpoint save then
3419
+ * failed: the checkpoint stays saved, and the next undo, which finds
3420
+ * nothing of its turn left in the window past it, saves the checkpoints
3421
+ * without it and keeps no redo of nothing (the entry kept puts the rows
3422
+ * back). An undo that took nothing out throws its error and keeps
3423
+ * nothing. Each refusal after rows left is traced (`window:undone`) and
3424
+ * recorded with its error.
3425
+ */
3426
+ private undoOnWindow;
3427
+ private undoTurnOnWindow;
3428
+ /**
3429
+ * Where a checkpoint's turn began in the agent's window: the index length
3430
+ * it recorded, on the branch it recorded it on. A checkpoint recorded
3431
+ * before the window was presented (an earlier version's, or one taken
3432
+ * while the context was in legacy mode), or on another branch, is
3433
+ * converted: the place of the first row in the window stored after the
3434
+ * checkpoint's sequence, or the window's end when there is none.
3435
+ */
3436
+ private checkpointLength;
3437
+ /**
3438
+ * The bodies of `cm`'s window at ordinal `from` and after, in window
3439
+ * order: each by the shard that names it, with its ordinal and sequence,
3440
+ * and whether it is `agent`'s own row. A stamped row is the agent's own
3441
+ * when its stamp says so (isOwnRowOf). A row stored before the audience
3442
+ * stamp (every turn an earlier release recorded, whose checkpoints an
3443
+ * undo still takes) carries none, and the presentation index reads it as
3444
+ * an arrival, so an undo that took it out as arrived would see it come
3445
+ * back at the agent's next point: it is the agent's own when it is stored
3446
+ * under the agent's voice (isOwnParticipant), holds only results of
3447
+ * calls an own row of the window made, which such a release stored under
3448
+ * `user`, or is a framework notice whose metadata names the agent as its
3449
+ * owner (legacyNoticeOwner: a drafts notice, an `[auto-continue]` row, a
3450
+ * stored injection), which such a release stored under `user` too.
3451
+ */
3452
+ private windowBodiesFrom;
3453
+ /**
3454
+ * The read marks held for `agent` (heldMarksOf's): its own
3455
+ * (Agent.heldReadMarks), the marks its running scripts started with
3456
+ * (AgentScripts.readMarksOf), which each script's sends are credited with
3457
+ * having read (publishReadThrough), and those of its channel_publish calls
3458
+ * still out (publishMarksInFlight). A redo gives them all again.
3459
+ */
3460
+ private heldMarksOf;
3461
+ /**
3462
+ * Hold a publish's mark (publishReadThrough's) while its call is out
3463
+ * (publishMarksInFlight), so a redo meanwhile gives it again. `release`
3464
+ * lets it go and returns the mark as it stands then, for notePublished.
3465
+ */
3466
+ private holdPublishMark;
3467
+ /**
3468
+ * The agent's marks (heldMarksOf: its own and its running scripts') that cover rows of `tail` by
3469
+ * their ordinals in its window, read before an undo takes them out, each
3470
+ * with the bodies it covers. A mark taken in legacy mode is one of them
3471
+ * where it covers such rows: the window is presented (undo refuses one
3472
+ * that isn't), and there it covers the rows the window held by its head
3473
+ * where they stand (coverTest), which a redo puts back at new ordinals
3474
+ * past it. One on another branch can't say, and isn't kept. A failure to
3475
+ * read them is logged and keeps none: the redone rows then read as unread
3476
+ * until the agent's next mark, as they did before redo gave marks again.
3477
+ */
3478
+ private marksOverTail;
3479
+ /**
3480
+ * A redo of an undo on the window. First the rows presented since the
3481
+ * undo leave the window as arrived and not presented (they enter again at
3482
+ * the agent's next point, after the redone rows), and with them any of
3483
+ * the undo's own rows still in it (an undo cut short), so the redone
3484
+ * rounds sit after the prefix their signed thinking was minted under.
3485
+ * Presented since means in the window past the index length the undo
3486
+ * left and not in it right after the undo: a body a later undo took out
3487
+ * and its redo put back (`kept`) stays where it is, so undos redone in
3488
+ * turn give back the window they took. Then the rows the undo took out
3489
+ * enter it again, in their window order, but for one the store no longer
3490
+ * holds. Each undo still to redo below this one (`below`, oldest first)
3491
+ * notes which of the rows put back were in its window right after it
3492
+ * (their ordinal before this undo was below the length it left), and the
3493
+ * marks that covered the rows at the undo cover them again
3494
+ * (retakeMarks). The checkpoint goes back, unless an undo cut short left
3495
+ * it in place.
3049
3496
  *
3050
- * It reserves the store and re-initializes every agent's context manager
3051
- * as undoLastTurn() does, and its result's `settled` is undoLastTurn()'s.
3497
+ * A step that fails once the window has changed (the retraction partway,
3498
+ * the rows' return, the checkpoint save) refuses the redo with
3499
+ * OperatorActionError 'failed', saying how many rows left and how many
3500
+ * returned, traced (`window:undone`) and recorded with its error; the
3501
+ * entry stays, and another redo finishes it, from the window as it then
3502
+ * is. One that changed nothing throws its error as it is. The caller,
3503
+ * redo(), takes the entry off the stack and traces and records a redo
3504
+ * that went through, after this returns.
3505
+ */
3506
+ private redoOnWindow;
3507
+ /**
3508
+ * After a redo put `back` (the undo's rows, in window order) into the
3509
+ * window again, at new ordinals past every mark: each mark the undo
3510
+ * recorded (RedoEntry.marks) that the agent still holds is given again,
3511
+ * covering the window as it stands up to the first row put back that the
3512
+ * mark didn't cover at the undo. So a row the undone turn had read, and
3513
+ * its reply answered, reads as read, shown and answered again, and one it
3514
+ * hadn't reads as before; a row presented since the undo, which the redo
3515
+ * took out and the agent's next point presents after, isn't covered. A
3516
+ * mark the agent no longer holds (a compile moved it since the undo) is
3517
+ * left as it is: what it covers is what the agent read later. Each undo
3518
+ * still to redo below records the new mark in place of the old, and so
3519
+ * does this one's entry, for a redo that finishes this one where it was
3520
+ * cut short after the rows came back (redoOnWindow). A failure
3521
+ * is logged and leaves the marks as they were: the rows put back then
3522
+ * read as unread until the agent's next mark.
3523
+ */
3524
+ private retakeMarks;
3525
+ /**
3526
+ * Redo a previously undone turn for an agent, on its window (undoLastTurn):
3527
+ * no branch moves, the rows presented since the undo leave the window,
3528
+ * and the rows it took out enter it again, in their order, with `window`
3529
+ * saying how many of each and a `window:undone` trace; the agent's marks
3530
+ * that covered them at the undo cover them again. Undos are redone newest
3531
+ * first, each giving back the window it took. Returns
3532
+ * `{ redone: false }` if there's nothing to redo. Refused
3533
+ * (OperatorActionError 'failed') when the store is on another branch
3534
+ * than the undo was: its rows' places are that branch's window's. A
3535
+ * branch move through the framework (switchBranch, a rollback, a
3536
+ * suppression, a failed surgery's restore) drops every redo entry
3537
+ * (followBranchMove), so this is a move made past it.
3052
3538
  */
3053
3539
  redo(agentName: string, requester?: OperatorRequester): {
3054
3540
  redone: boolean;
3055
3541
  fromBranch?: string;
3056
3542
  toBranch?: string;
3543
+ window?: {
3544
+ retracted: number;
3545
+ represented: number;
3546
+ };
3547
+ /** Present only when the redo moved the store, which a redo on the
3548
+ * window never does: nothing waits to settle (#291, decision 4). */
3057
3549
  settled?: Promise<void>;
3058
3550
  };
3059
3551
  /**
@@ -3089,18 +3581,111 @@ export declare class AgentFramework {
3089
3581
  * Passing the gate RESERVES the store for the caller: a turn token is
3090
3582
  * held for every agent until the returned release runs, so no wake — via
3091
3583
  * the scheduler or a parked provider admission, both of which re-test
3092
- * turn-alive — can start a turn while the switch is awaited. Release also
3093
- * flushes messages that deferred behind the reservation, as the puppet
3094
- * does. Always release in `finally`: a token nobody clears wedges the fleet.
3584
+ * turn-alive — can start a turn while the switch is awaited, and every
3585
+ * write made meanwhile is held in memory (surgeryHeldWrites). Release
3586
+ * stores what the hold kept, in arrival order, and presents each reserved
3587
+ * agent what it is owed, as at a turn's end, but for the arrivals a
3588
+ * rollback's cut returned, which wait for that agent's next turn start
3589
+ * (presentation.holdUntilStart). Always release in `finally`: a token
3590
+ * nobody clears wedges the fleet.
3095
3591
  */
3096
3592
  private reserveStoreForSurgery;
3097
3593
  private reinitializeManagers;
3594
+ /**
3595
+ * After a move's pass (reinitializeManagers): the writes kept in memory
3596
+ * for each agent whose context manager refused its work
3597
+ * (heldForRecovery), and whose re-initialization didn't fail this time,
3598
+ * go back to the move's hold ahead of the writes it keeps now, which came
3599
+ * after them, each agent's in arrival order. The release stores them
3600
+ * through the ordinary write path and traces each as it lands
3601
+ * (releaseSurgeryHeldWrites); one its manager still refuses there is kept
3602
+ * for it again, and the ones after it wait behind it. An agent gone
3603
+ * meanwhile passes them on (passHeldWritesOn). With no hold, which no
3604
+ * move makes, they are stored now.
3605
+ */
3606
+ private recoverHeldWrites;
3607
+ /**
3608
+ * Keep `write` in memory for `agentName`, whose context manager refuses
3609
+ * its work (heldForRecovery), behind the writes already kept for it. The
3610
+ * first one kept is logged with the refusal that began the wait.
3611
+ */
3612
+ private keepForRecovery;
3613
+ private refusesItsWork;
3614
+ /** Whether writes for `agentName` wait in memory for its context manager's recovery (heldForRecovery). */
3615
+ private waitsForRecovery;
3616
+ /**
3617
+ * At stop(), before its final sync: the writes still kept in memory, which
3618
+ * no queue persists (#291), told of once per agent they are for, by a log
3619
+ * line and an ops alert of kind `store-held-lost` naming how many and of
3620
+ * what kinds. Those kept for an agent whose context manager refuses its
3621
+ * work (heldForRecovery) are lost: no branch move follows a stop. Those
3622
+ * a surgery's hold still keeps (surgeryHeldWrites, a hold whose operation
3623
+ * outlived stop()'s wait for it) are stored only if it releases before the
3624
+ * process exits. Mail among them stays held in the registry, and the next
3625
+ * boot delivers it. Says nothing when none is kept. An alert's listeners
3626
+ * run as it is raised, and a write one makes is kept so too, after this
3627
+ * read of what is kept: each round tells the writes the rounds before it
3628
+ * didn't, until one finds none new (a few rounds at most, for a listener
3629
+ * that writes at every alert).
3630
+ */
3631
+ private reportHeldWritesAtStop;
3632
+ /** One round of reportHeldWritesAtStop: tells the writes kept in memory that aren't in `told`, adding them; whether any was. */
3633
+ private reportHeldWritesOnce;
3634
+ /**
3635
+ * The writes for `agentName` a surgery's release couldn't store, told of
3636
+ * once: a log line and an ops alert of kind `store-held-lost`. Each was
3637
+ * accepted with no id and kept in memory until the release, where its
3638
+ * store threw. One context-manager found none of stored is lost (one it
3639
+ * names rows of as stored, WriteLandedError, counts as stored and isn't
3640
+ * here). One whose store couldn't be read to tell what of it landed
3641
+ * (WriteOutcomeUnknownError: `unknown` holds one per such write) may be
3642
+ * lost: the alert names the rows the errors name as stored, which the
3643
+ * release presented and traced, and the rows the store may hold besides,
3644
+ * by id and by count, and its data counts them (`mayBeStored`). The writes
3645
+ * after them went on.
3646
+ */
3647
+ private tellHeldWritesLost;
3648
+ /** How many writes wait in memory for an agent's recovery (heldForRecovery), every agent's. */
3649
+ private writesHeldForRecovery;
3650
+ /**
3651
+ * Writes kept in memory for an agent that ended before they were stored
3652
+ * (a fork a move emptied and disposed, or a fork or a run that ended while
3653
+ * a hold kept them or while its context manager refused its work): each
3654
+ * one the primary takes in its place, as a release of the agent's window
3655
+ * passes it on (passesToPrimary: a failed reply, a channel notice its
3656
+ * reader could act on, or a module's write for a run or a fork, which goes
3657
+ * as the write itself), goes on to the primary by name
3658
+ * (passNoticeToPrimary), in arrival order, where a hold keeps it until its
3659
+ * release, as any write. The rest are dropped, which is logged and, unless
3660
+ * the caller's own alert counts them (`counted`: a move's disposal of the
3661
+ * fork), told of by an ops alert of kind `store-held-lost`: unlike a
3662
+ * released window's unread rows, they never reach the record. Each write
3663
+ * goes on by itself: one whose notice can't be built (passNoticeToPrimary
3664
+ * doesn't guard that, and a channel notice's words read the store) is
3665
+ * logged and counted among the dropped, and the rest still go on. Never
3666
+ * throws.
3667
+ */
3668
+ private passHeldWritesOn;
3669
+ /**
3670
+ * The name a kept write names whose agent has ended, else undefined: no
3671
+ * agent is registered under it, or another incarnation is, not the one
3672
+ * the write was kept for (SurgeryHeldWrite.heldFor). A write that names no
3673
+ * agent is the delivery agent's at its release, whichever that is then.
3674
+ * `named` is the name the write was kept under, where a caller keys it.
3675
+ */
3676
+ private heldWriteTargetGone;
3677
+ /**
3678
+ * Take out of memory the writes kept for `agent`, which is ending: those
3679
+ * kept while its context manager refused its work (heldForRecovery), then
3680
+ * those a surgery's hold keeps that name it, in arrival order, so that
3681
+ * neither a later move nor the hold's release meets them. Writes that
3682
+ * name no agent stay: they are the delivery agent's at the release.
3683
+ */
3684
+ private takeHeldWritesFor;
3098
3685
  private reportLongHold;
3099
3686
  private disposeEmptiedForks;
3100
3687
  private reportReinitFailures;
3101
3688
  private reportReinitFailure;
3102
- private beginSyncMove;
3103
- private reinitializeAfterSyncMove;
3104
3689
  /**
3105
3690
  * A surgery's marker batch, recorded before its body change. If it can't
3106
3691
  * be recorded, the surgery doesn't start, and the error says what the
@@ -3126,14 +3711,21 @@ export declare class AgentFramework {
3126
3711
  private retireAfterRestore;
3127
3712
  /**
3128
3713
  * After a failed switch or redaction: put the store back on `sourceBranch`
3129
- * if it moved, and return a sentence saying what actually happened. Never
3130
- * throws — the caller reports the original failure with this appended.
3714
+ * if it moved, and return a sentence saying what actually happened. The
3715
+ * caller's release has every other live agent's context follow the store
3716
+ * to where it ends (followBranchMove): its source, or the failed branch
3717
+ * when the restore failed too. Never throws — the caller reports the
3718
+ * original failure with this appended.
3131
3719
  */
3132
3720
  private restoreSourceBranch;
3133
3721
  /**
3134
3722
  * Roll the active branch back so `messageId` becomes its tail: fork the
3135
3723
  * chronicle at that message (origin-sequence time-travel branch) and switch
3136
- * to the fork. Everything after the message stays on the source branch.
3724
+ * to the fork. Everything after the message stays on the source branch
3725
+ * (on a presented window, but for the rows stored before the write that
3726
+ * presented it: those the window took after that write,
3727
+ * returnedToArrivals, and those it presented with the message,
3728
+ * keptInWindowAfterTarget).
3137
3729
  *
3138
3730
  * The rollback is local to the resident. Marking removed Discord messages
3139
3731
  * with an awareness reaction is a separate, explicit publication choice
@@ -3178,6 +3770,38 @@ export declare class AgentFramework {
3178
3770
  role?: string;
3179
3771
  preview?: string;
3180
3772
  } | null;
3773
+ /**
3774
+ * On a presented window (#291), the rows after the target in the
3775
+ * agent's window that the cut kept in the record: stored before the
3776
+ * write that presented the target, they left the window as arrived and
3777
+ * not presented. They wait outside it until the agent's next turn
3778
+ * start, which presents them after what its window holds then: the
3779
+ * surgery's release, a resume, the agent's turn ending or a row
3780
+ * stored for it while it is idle don't bring them back, so the cut
3781
+ * holds until the agent speaks again, on the rollback's branch: a later
3782
+ * move of the store's branch, a suppression or rollback through another
3783
+ * agent included, ends it. An own row of the agent's among
3784
+ * them is the exception: it re-enters at the surgery's release, as own
3785
+ * rows enter at every point. The hold is in memory: a restart before
3786
+ * then presents them at its pass over every agent at rest, or, where it
3787
+ * boots quiesced, at the resume. Not counted
3788
+ * in `messagesRemoved`, and not marked. Set only on a presented window.
3789
+ */
3790
+ returnedToArrivals?: number;
3791
+ /**
3792
+ * On a presented window (#291), the rows after the target in the
3793
+ * agent's window that one write presented together with the target (a
3794
+ * batch: two Discord messages that arrived while the agent was busy,
3795
+ * say, presented at its turn's end). The cut is at that write, so they
3796
+ * stay in the window after the target: a branch cut can't separate
3797
+ * them from it. Not removed, so not counted in `messagesRemoved` and
3798
+ * not marked; suppressMessages, or, for those with a Discord message
3799
+ * id, the host's hide by it, takes them out: a suppression through the
3800
+ * agent whose own slot holds each, this one, or for a row of a slot it observes (a
3801
+ * persistent subconscious's residents' rows), that slot's owner. Set
3802
+ * only on a presented window.
3803
+ */
3804
+ keptInWindowAfterTarget?: number;
3181
3805
  }>;
3182
3806
  /**
3183
3807
  * Suppress specific messages from the live context without touching the
@@ -3192,9 +3816,16 @@ export declare class AgentFramework {
3192
3816
  * a marker-scheduling receipt (`markers`); delivery continues without the
3193
3817
  * caller waiting on it.
3194
3818
  *
3195
- * Not retroactive over derived state: a message already folded into an
3196
- * autobiographical summary stays in that summary — roll back to before it
3197
- * entered if that matters.
3819
+ * On a presented window (#291) the removal reaches what every reader on
3820
+ * the store folded: every other agent's context follows the fork before
3821
+ * the removals (followBranchMove), so each one's strategy hears the rows
3822
+ * leave, drops each summary that folded one and folds the rows it keeps
3823
+ * again. Where a window can't be repaired, which is logged, its strategy
3824
+ * hears at the next boot (presentation's retractAbsentRows), since the
3825
+ * record no longer holds the rows. In legacy mode it is not retroactive
3826
+ * over derived state: a message already folded into an autobiographical
3827
+ * summary stays in that summary — roll back to before it entered if that
3828
+ * matters.
3198
3829
  */
3199
3830
  suppressMessages(agentName: string, opts: {
3200
3831
  messageIds: string[];
@@ -3228,8 +3859,76 @@ export declare class AgentFramework {
3228
3859
  * changing anything. Never bisects a body group: chronicle refuses that
3229
3860
  * for removals and branchAt has no such guard, so the target snaps to the
3230
3861
  * group's last shard.
3862
+ *
3863
+ * The rows removed are those the branch cut leaves behind: the slot's
3864
+ * rows after the target stored after the sequence branchAt cuts at
3865
+ * (branchSequenceOf). That is every row after the target, but on a
3866
+ * presented window (#291), where the cut is the write that presented the
3867
+ * target, rows stored after the target and before that write stay in the
3868
+ * record. Those of them the agent's window holds were presented after
3869
+ * the target: they leave the window (`returnedToArrivals`, named by
3870
+ * `returnedIds`); the agent's own rows among them enter it again at its
3871
+ * next presentation point (the surgery's release), and the rest, as
3872
+ * arrived and not presented, at the agent's next turn start on the
3873
+ * rollback's branch (a later move of the store's branch, a suppression or
3874
+ * rollback through another agent included, ends the hold; it is in
3875
+ * memory: a restart presents them at its pass at rest, or, where it boots
3876
+ * quiesced, at the resume). The rows of
3877
+ * the agent's window after the
3878
+ * target that the write presenting it presented too (`keptInWindow`, a
3879
+ * batch: one write, one presentation point) stay in the window, since no
3880
+ * branch cut separates them from the target. Both are set only on a
3881
+ * presented window. A rollback that neither removes a row nor returns
3882
+ * one is refused as a no-op, saying why: rows presented with the target
3883
+ * are named, with the removals that can take them out, and through which
3884
+ * agent a suppression does (suppressionThrough).
3231
3885
  */
3232
3886
  private planRollback;
3887
+ /**
3888
+ * Through which agent a suppression takes `rows` of `agentName`'s window
3889
+ * out, for a refusal's advice, each row named by its id, which
3890
+ * suppressMessages takes: a suppression looks for its ids in the agent's
3891
+ * own slot (planSuppression), so a row of a slot the agent observes,
3892
+ * merged into its window, is suppressed through an owner of that slot
3893
+ * whose own slot holds it (observedRowOwner). Plain `suppressMessages`
3894
+ * with the ids when every row is in the agent's own slot. Where an
3895
+ * owner's slot holds no row but those named for it, the advice says the
3896
+ * suppression there is refused, as planSuppression refuses one that
3897
+ * would leave no row.
3898
+ */
3899
+ private suppressionThrough;
3900
+ /**
3901
+ * On which agent the host's hide takes each of `rows` out, for a
3902
+ * refusal's advice, each row named by its Discord message id, which the
3903
+ * hide matches: the hide reads the own slot of the agent it is run on, so
3904
+ * a row of a slot `agentName` observes, merged into its window, is hidden
3905
+ * on an owner of that slot whose own slot holds it (observedRowOwner), as
3906
+ * suppressionThrough names one for a suppression. Grouped by agent, the
3907
+ * groups set apart by semicolons.
3908
+ */
3909
+ private hideThrough;
3910
+ /**
3911
+ * The live agent whose own slot holds `id`, a row of a slot `agentName`
3912
+ * observes: an owner of one of the slots its observe edges read
3913
+ * (readerFacts' observed slots), other than itself. Undefined when none
3914
+ * is found or the registry can't be read.
3915
+ */
3916
+ private observedRowOwner;
3917
+ /** Whether a slot `cm` merges beside its own holds the row, which its own slot doesn't. */
3918
+ private mergesObservedRow;
3919
+ /**
3920
+ * What a branch cut at `cut` does to the rows of `cm`'s window after the
3921
+ * target (`tailId`), in window order: those it keeps in the record and
3922
+ * out of the window (`returned`: stored at or before the cut, and
3923
+ * presented by a write after it), and those it keeps in the window
3924
+ * (`kept`: presented by the write the cut is at, the one that presented
3925
+ * the target, so after the target only when that write presented them
3926
+ * together, a batch). Read from the window's newest row back, to the
3927
+ * target or the first row presented before the cut: every row's cut
3928
+ * (branchSequenceOf, the write that presented it, or its own sequence
3929
+ * for a row the write-down presented) grows in window order.
3930
+ */
3931
+ private windowAfterCut;
3233
3932
  /**
3234
3933
  * The removal intervals a suppression of `requestedIds` would apply
3235
3934
  * (index-ordered, newest first), validated, without changing anything. A
@@ -3249,6 +3948,18 @@ export declare class AgentFramework {
3249
3948
  } | {
3250
3949
  suppress: string[];
3251
3950
  }): SurgeryMarksPreview;
3951
+ /**
3952
+ * The live agents whose window holds a row now (#291): each whose context
3953
+ * reads it `'in'` (windowStatusOf), every agent whose window is still the
3954
+ * record and whose record holds it among them (`names`). A row an agent's
3955
+ * view leaves out (agentSees) is held by no such agent, though its window
3956
+ * holds it: one a tune-out holds from residents, or another agent's stored
3957
+ * context injection, which a write-down from the record took in. A row a
3958
+ * suppress rule hid is held by no agent: no view shows it. An agent
3959
+ * whose lookup throws is in `unreadable`, with the error: whether its
3960
+ * window holds the row isn't known.
3961
+ */
3962
+ private holderNames;
3252
3963
  /** The awareness ledger's batches and retract requests, for operator surfaces. */
3253
3964
  listDiscordAwareness(): DiscordAwarenessView[];
3254
3965
  /**
@@ -3315,7 +4026,9 @@ export declare class AgentFramework {
3315
4026
  * reservation. The gate picks it up by mtime; stop() still waits for it. */
3316
4027
  private materializeConfigMountAfterBranchSwitch;
3317
4028
  /**
3318
- * Check if undo/redo is available for an agent.
4029
+ * Check if undo/redo is available for an agent. `canRedo` is false where
4030
+ * the newest undo was on another branch than the store's, which redo
4031
+ * refuses; `redoDepth` counts every undo kept all the same.
3319
4032
  */
3320
4033
  getUndoRedoState(agentName: string): {
3321
4034
  canUndo: boolean;
@@ -3324,6 +4037,7 @@ export declare class AgentFramework {
3324
4037
  redoDepth: number;
3325
4038
  };
3326
4039
  private recordTurnCheckpoint;
4040
+ private dropTurnCheckpoint;
3327
4041
  /**
3328
4042
  * Checkpoints live in one Tree state (TURN_CHECKPOINTS_TREE_ID) keyed by agent
3329
4043
  * name, each key pointing at a JSON blob of that agent's ≤MAX_TURN_CHECKPOINTS
@@ -3365,6 +4079,12 @@ export declare class AgentFramework {
3365
4079
  * Useful for testing.
3366
4080
  */
3367
4081
  runUntilIdle(): Promise<void>;
4082
+ /**
4083
+ * A configured agent (a resident). `configured` is every configured
4084
+ * agent's name: an agent its `observes` names may be registered after it,
4085
+ * in this same pass, so its edge on that agent is admitted before then
4086
+ * (AgentRegistry.register's `declaredWith`).
4087
+ */
3368
4088
  private createAgent;
3369
4089
  /**
3370
4090
  * Create and register the subconscious resident (issue #77): a persistent
@@ -3374,6 +4094,14 @@ export declare class AgentFramework {
3374
4094
  * excludes; the backlog is precisely what it exists to see. Windowed
3375
4095
  * passthrough, no memory pyramid: its durable output is what it delivers
3376
4096
  * into the resident's window, which accumulates there.
4097
+ *
4098
+ * With the presentation index (#291) the merge is the record its window is
4099
+ * presented from, not its compile: the residents' rows enter its window by
4100
+ * its observe edge's rule (observedRowFor) at its own points, as any
4101
+ * agent's arrivals do, so none lands inside its live turn; its window
4102
+ * starts at the oldest active tune-out's start, fixed as an ordinal
4103
+ * (SubconsciousWindowAnchor); and a resident's rounds go out to it as a
4104
+ * transcript (foreign-rounds.ts).
3377
4105
  */
3378
4106
  private createSubconsciousAgent;
3379
4107
  /**
@@ -3382,6 +4110,36 @@ export declare class AgentFramework {
3382
4110
  * kept for the voice block, the speech switch and the strategy factory.
3383
4111
  */
3384
4112
  private configureReaderForks;
4113
+ /**
4114
+ * How many of the residents' stored rows `keep` keeps the persistent
4115
+ * subconscious hasn't been shown (the coordinator's unseenBySubconscious),
4116
+ * one per body: with the presentation index, those its window doesn't
4117
+ * hold, which it takes at its next point; else those its consumed mark
4118
+ * doesn't cover, stored after its last compile. 0 with no subconscious,
4119
+ * and for a row its mark can't speak for.
4120
+ */
4121
+ private unseenBySubconscious;
4122
+ /**
4123
+ * The persistent subconscious's window as written down, its presented
4124
+ * rows (the coordinator's subconsciousWindow): what a boot reads for the
4125
+ * losses told to it, its own cancels, and what it was told of an
4126
+ * unrecorded stop, where the turn a row asked for, in memory, doesn't
4127
+ * outlast a stop, and its read marks, in memory too, don't either. Its
4128
+ * stored rows where its window isn't presented. None with no
4129
+ * subconscious.
4130
+ */
4131
+ private subconsciousWindow;
4132
+ /**
4133
+ * The persistent subconscious's tool results as its tool-result guard
4134
+ * archived them (the coordinator's subconsciousGuardedResults): each
4135
+ * `staged` record of its audit (TOOL_RESULT_GUARD_AUDIT_STATE, under the
4136
+ * subconscious's name) holds its batch's original content, inline or as a
4137
+ * blob, written and synced before the placeholder row's results went out,
4138
+ * by tool use id, the placeholders' own. A crash before the guard settles
4139
+ * the batch leaves the placeholder for the result in its record; the
4140
+ * original is here. None with no subconscious, or no audit.
4141
+ */
4142
+ private subconsciousGuardedResults;
3385
4143
  /**
3386
4144
  * One reader invocation: derive a fork of the resident at its head with
3387
4145
  * the resident's refusals, hand it the held traffic since the last look
@@ -3390,13 +4148,11 @@ export declare class AgentFramework {
3390
4148
  */
3391
4149
  private invokeReaderFork;
3392
4150
  /**
3393
- * Held messages still queued behind the resident's turn, as rows of a
3394
- * reader fork's backlog: each named by its held handle, as module rows name
3395
- * it until it lands (heldRows), at a provisional sequence past the
3396
- * resident's last stored message, and timed when it was first held.
4151
+ * A reader fork's own words to the resident: attributed mail when it has a
4152
+ * route, else under its name. Answers the row's id for the latter (empty
4153
+ * where the write was kept in memory), and nothing for mail, which the
4154
+ * registry keeps until it is delivered.
3397
4155
  */
3398
- private queuedReaderRows;
3399
- /** A reader fork's own words to the resident: attributed mail when it has a route, else under its name. */
3400
4156
  private deliverFromReader;
3401
4157
  private runLoop;
3402
4158
  private processNextEvent;
@@ -3410,6 +4166,34 @@ export declare class AgentFramework {
3410
4166
  */
3411
4167
  private dispatchProcessEventToModules;
3412
4168
  private applyProcessResponse;
4169
+ /**
4170
+ * Who a module's process response's messages are for when its inference
4171
+ * request names agents (#291's audience stamp): those of them registered
4172
+ * here that read the slot the messages land in (readersNamed), once each,
4173
+ * in the order named, whether or not the event gate then lets their wake
4174
+ * through; the delivery agent when it names none registered. The messages
4175
+ * are stored where a write that names no agent is, the delivery agent's
4176
+ * store, whoever these are: on a residents' host the shared slot every
4177
+ * resident reads. Undefined for a request for every agent (`true`), for
4178
+ * none, for an empty list, or for one whose registered agents don't read
4179
+ * that slot (an isolated job, a conversation fork), which leave the stamp
4180
+ * to addMessage (untargetedAudience): stamped for those agents alone, the
4181
+ * messages would be in no window.
4182
+ */
4183
+ private requestedAudience;
4184
+ /**
4185
+ * Of the agents a write that names no agent (no `forAgent`) is said to be
4186
+ * for (`named`, non-empty), those that read the slot it lands in, the
4187
+ * delivery agent's own: its owners and the agents that observe it (the
4188
+ * registry's readersOf), in the order named. Undefined when none of them
4189
+ * reads it, so the write takes addMessage's stamp for a write that names
4190
+ * no agent in that slot (defaultAudience): a stamp naming only agents
4191
+ * that can't read the slot puts the row in no window. Where the registry
4192
+ * places no slot for the delivery agent, `named` as given.
4193
+ */
4194
+ private readersNamed;
4195
+ /** Each event's suppression, decided once: by its MCPL lane at admission, or by the first module response that adds messages or asks for a wake (applyProcessResponse). */
4196
+ private readonly eventSuppression;
3413
4197
  /** The servers and keys whose drop withoutHostKeys has logged, each as
3414
4198
  * `${serverId}\u0000${key}`. */
3415
4199
  private readonly hostKeysDropped;
@@ -3439,6 +4223,21 @@ export declare class AgentFramework {
3439
4223
  * the template ("trunk") is a dormant warm checkpoint, not a listener.
3440
4224
  */
3441
4225
  private routeConversationIncoming;
4226
+ /**
4227
+ * A fork's channel message, routed or a correction for it, written into
4228
+ * the fork's store (storeInFork, #291: stored at once, stamped for the fork
4229
+ * alone, and presented at the fork's next point, at once when no turn of
4230
+ * its is alive), and where it went: the fork, with the stored id, and
4231
+ * `presented: false` where the row is out of the fork's window after its
4232
+ * write, as addMessage's placement says (placedUnpresented). While a
4233
+ * surgery holds the store, storeInFork keeps the write in memory
4234
+ * (surgeryHeldWrites) and the hold's release stores it, and while the
4235
+ * fork's context manager refuses its work it keeps it for the move that
4236
+ * re-initializes it (heldForRecovery), so the placement names the fork
4237
+ * alone, with no id yet, as not presented: no request reads it before it
4238
+ * is stored, and the fork is woken to read it, as addMessage places a
4239
+ * write it keeps. `mayBeStored`: storeInFork's.
4240
+ */
3442
4241
  private writeToFork;
3443
4242
  /**
3444
4243
  * Spawn a persistent per-channel conversation agent ("fork") from the
@@ -3624,6 +4423,14 @@ export declare class AgentFramework {
3624
4423
  * editMessage keeps metadata but not this hash.
3625
4424
  */
3626
4425
  private static withStoredDigest;
4426
+ /**
4427
+ * Who an admitted inbound message is for (#291's audience stamp): the
4428
+ * recipients admission delivered it to, in their view, and nobody when a
4429
+ * tune-out holds it, since then nothing may act for them (admit.ts), or
4430
+ * when a suppress rule took it, since then no view renders it. The
4431
+ * stored row lands in one store, the delivery agent's, whoever these are.
4432
+ */
4433
+ private static inboundAudience;
3627
4434
  /** Source envelope of a channels/incoming event (lane facts as given). */
3628
4435
  private channelEventSource;
3629
4436
  /** Source envelope of a push event: its derived channel, else unscoped. */
@@ -3669,38 +4476,68 @@ export declare class AgentFramework {
3669
4476
  private assertChannelScopedPush;
3670
4477
  private coalescedAuthorized;
3671
4478
  private coalescedAudience;
3672
- /** Deliver through the lane's ordinary path; report where it landed. */
4479
+ /** Deliver through the lane's ordinary path; report where it landed.
4480
+ * `options.mayBeStored` rides the event to its store, which looks for the
4481
+ * occurrence's rows first (FrameworkWriteOptions.mayBeStored). */
3673
4482
  private deliverCoalesced;
4483
+ private dispatchAfterDelivery;
3674
4484
  private wakeForCoalescedBatch;
3675
4485
  /** Queue a wake for each agent of the batch's audience, when its latest
3676
4486
  * occurrence triggers inference. `plain`: an ordinary push wake, without
3677
4487
  * the subject a withdrawal of the batch's wakes goes by, for a render
3678
- * placed in its agent's deferred queue (wakeToRead), at `readsDeferredWrite`,
3679
- * marked ambient when every notice the render folds was (`allAmbient`). */
4488
+ * its turn being assembled doesn't read (wakeToRead), reading `readsRow`
4489
+ * (readsRowFor), marked ambient when every notice the render folds was
4490
+ * (`allAmbient`). */
3680
4491
  private queueCoalescedWakes;
3681
4492
  /** Withdraw unstarted wakes whose sole cause is this subject (§4.2), and
3682
4493
  * a merged start whose every request is withdrawn. */
3683
4494
  private cancelCoalescedWakes;
3684
- /**
3685
- * A placement in the deferred queue is upgraded in place once the flush has
3686
- * stored it: the stored copy carries `metadata.deferredWriteId`, found by
3687
- * scanning the unread tail (above the watermark) — never below it.
3688
- */
3689
- private resolvePlacement;
3690
4495
  /** Unread (the coalescer's isUnread) by the consumed watermark, or, by the
3691
- * shown watermark, never possibly shown (its isUnshown). A placement still
3692
- * in the deferred queue is both, once settled (settleUnknownLandings): one
3693
- * whose write may already be stored, its store unsearchable, is a doubt,
3694
- * which counts as read and as shown. */
4496
+ * shown watermark, never possibly shown (its isUnshown). A placement with
4497
+ * no stored row, a write kept in memory (a surgery's hold, or the wait
4498
+ * for its agent's recovery), counts as read and as shown: it can't be
4499
+ * found again once it is stored. */
3695
4500
  private isUnreadPlacement;
3696
4501
  /**
3697
- * Unread = stored, above the agent's consumed watermark on the current
3698
- * branch, not a body-group shard (immutable), and not folded into any
3699
- * summary (compression is consumption, §3.3). Conservative on every doubt.
3700
- * By the shown watermark (Agent.getShownWatermark), the same test says the
3701
- * message may never have been shown.
4502
+ * Unread = stored, not covered by the consumed watermark of any agent that
4503
+ * reads it (Agent.getConsumedWatermark, read in that agent's own context:
4504
+ * in its window as of the mark once the context presents rows, else at or
4505
+ * below the mark on the branch), not a body-group shard (immutable), and
4506
+ * not folded into any reader's summary (compression is consumption,
4507
+ * §3.3). Conservative on every doubt: a reader whose mark can't say (none,
4508
+ * or one on another branch) counts it read. By the shown watermark
4509
+ * (Agent.getShownWatermark), the same test says the message may never
4510
+ * have been shown.
3702
4511
  */
3703
4512
  private isUnreadStoredMessage;
4513
+ /**
4514
+ * The live agents whose presented window holds a row (the presentation
4515
+ * index's holders, #291, leaving out a window that is still the whole
4516
+ * record): each one's own place for it, or a reader fork's framing.
4517
+ * None on a framework built without the index. Undefined when it can't be
4518
+ * read, which is logged: one window that can't be read fails the lookup
4519
+ * for every window, so which hold the row isn't known.
4520
+ */
4521
+ private windowHolders;
4522
+ /** Whether a reader fork was handed a row as framing (the presentation
4523
+ * index's noteFramed, #291, AF-5): its framing row carries the row's
4524
+ * text, so the row is read whatever its marks say. False on a framework
4525
+ * built without the index. */
4526
+ private framedToAReader;
4527
+ /**
4528
+ * Rows just removed from the record through `remover`, taken out of every
4529
+ * other live agent's window that still holds them (the presentation
4530
+ * index's retractRemoved, #291): context-manager tombstones a removal in
4531
+ * the remover's window only. Each row leaves at its own place, so no
4532
+ * other row's place moves; a window on a branch whose record still holds
4533
+ * the row, and one that is still the record, keep it. A window that can't
4534
+ * be repaired is logged and the removal stands. Called after every
4535
+ * removal in place: a hide, a suppression on its fork, a coalescer's or a
4536
+ * module's removal, a suppression a start finishes, and a shed from a
4537
+ * window that is still the record. A rollback needs none: it is a branch
4538
+ * cut, made at the same place in every window.
4539
+ */
4540
+ private retractRemovedElsewhere;
3704
4541
  private removePlacement;
3705
4542
  /**
3706
4543
  * Convert an MCPL push event to a context message.
@@ -3708,9 +4545,9 @@ export declare class AgentFramework {
3708
4545
  private handleMcplPushEvent;
3709
4546
  /**
3710
4547
  * Whether a batched gate wake's addressed route may become `agentName`'s
3711
- * speech locus. The gate broadcasts to every agent, conversation forks
3712
- * included. A fork speaks only in its home channel, and a channel bound to
3713
- * a fork is that fork's conversation, so no other agent takes it.
4548
+ * speech locus. A batch naming no agent wakes every resident and
4549
+ * conversation fork. A fork speaks only in its home channel, and a channel
4550
+ * bound to a fork is that fork's conversation, so no other agent takes it.
3714
4551
  */
3715
4552
  private mayTakeGateRoute;
3716
4553
  /**
@@ -3744,8 +4581,8 @@ export declare class AgentFramework {
3744
4581
  */
3745
4582
  private channelOfHome;
3746
4583
  /**
3747
- * Explicit mode's typing channel for one start of a turn, which has no
3748
- * locus, read once as the start opens (driveStream then shows what the
4584
+ * The typing channel for one start of a turn that has no locus, an
4585
+ * explicit or a disabled mode turn's, read once as the start opens (driveStream then shows what the
3749
4586
  * start showed, TurnRouting.typing): where that start's wake came from,
3750
4587
  * its trigger's channel with its server (channelNamed), so a start batched
3751
4588
  * with a new wake shows typing where that wake came from. Not the turn's
@@ -3759,9 +4596,11 @@ export declare class AgentFramework {
3759
4596
  * (TurnRouting.noChannel), a wake named without its server isn't read: a
3760
4597
  * retry's trigger names it again, and reading it then could take a
3761
4598
  * channel the turn never had. A wake that gives its server, as every one
3762
- * the framework makes for a channel does, names that pair.
4599
+ * the framework makes for a channel does, names that pair. A silent wake's
4600
+ * start (InferenceRequest.suppressProse), which runs as disabled mode in
4601
+ * every mode, shows none, though its wake names a channel.
3763
4602
  */
3764
- private explicitTypingChannel;
4603
+ private noLocusTypingChannel;
3765
4604
  /**
3766
4605
  * Derive the MCPL composite channel id (the outbound routing locus) for a
3767
4606
  * push event from its server-defined `origin`, if it carries one.
@@ -3804,8 +4643,8 @@ export declare class AgentFramework {
3804
4643
  * Stamps for the rows the agent's reply stores in its current turn: its
3805
4644
  * assistant responses, its tool_result rows (through `storeResults`), and
3806
4645
  * the contained-wrapper row that stands in for a response. The turn's other
3807
- * stores (a delivery receipt, a routing notice, a deferred flush) aren't the
3808
- * reply's, and carry none.
4646
+ * stores (a delivery receipt, a routing notice) aren't the reply's, and
4647
+ * carry none.
3809
4648
  * - A silent heartbeat tick stamps each of them for the whole turn, with the
3810
4649
  * separator text its request rendered. The stamps keep every row of the
3811
4650
  * tick identifiable after the turn, for a later retention policy to find
@@ -3848,8 +4687,11 @@ export declare class AgentFramework {
3848
4687
  * turn whose round it came from (opts.routing). `notice: 'now'` also
3849
4688
  * queues a private notice naming them, which
3850
4689
  * the resident hears at its next tool boundary — only when the live stream
3851
- * presents mid-turn injections. Otherwise the turn-end receipt names them
3852
- * (or, after a crash, the next turn's catch-up). Drafts the journal cannot
4690
+ * presents mid-turn injections. The notice is the agent's own row, about
4691
+ * its own speech (#291), so an undo of the turn takes it out of the window
4692
+ * with the turn's other rows, as it takes the receipt, and the next start
4693
+ * names the draft again (noticeUnnoticedDrafts). Otherwise the turn-end
4694
+ * receipt names them (or, after a crash, the next turn's catch-up). Drafts the journal cannot
3853
4695
  * hold are reported in the receipt: their words remain in history only.
3854
4696
  */
3855
4697
  private holdProseDrafts;
@@ -3880,17 +4722,18 @@ export declare class AgentFramework {
3880
4722
  * Turn start (or after a crash): name, privately and before the turn's
3881
4723
  * compile, any open drafts no notice on the current branch names: none
3882
4724
  * reached the history (a crash, an aborted turn), or a rollback or branch
3883
- * move took the notices away. Every draft it marks is named by id, newest
3884
- * first: the newest eight with their state and why each was held, the rest
3885
- * by id. Like every notice, it quotes none of their words; the drafts tool
3886
- * shows them. A draft a recent message already names is recorded as
3887
- * noticed rather than named again: its notice landed after its turn ended,
3888
- * as a bounce does when a delivery runs after a tool ends an explicit turn.
3889
- * It reads only the recent history (draftsNamedInHistory), so its notice
3890
- * claims no more than that. Left out are the open logical turn's own
3891
- * drafts, which its receipt names and its settlement records
3892
- * (settleTurnDrafts), and drafts a notice still waiting in the deferred
3893
- * queue names.
4725
+ * move took the notices away, or, once the agent's context presents rows
4726
+ * (#291), an undo took them out of its window as an undone turn's. Every
4727
+ * draft it marks is named by id, newest first: the newest eight with their
4728
+ * state and why each was held, the rest by id. Like every notice, it quotes
4729
+ * none of their words; the drafts tool shows them. A draft a recent message
4730
+ * already names is recorded as noticed rather than named again: its notice
4731
+ * landed after its turn ended, as a bounce does when a delivery runs after
4732
+ * a tool ends an explicit turn. It reads only the recent history
4733
+ * (draftsNamedInHistory), so its notice claims no more than that, a notice
4734
+ * stored and not yet presented to the agent among it, which its next start
4735
+ * presents. Left out are the open logical turn's own drafts, which its
4736
+ * receipt names and its settlement records (settleTurnDrafts).
3894
4737
  */
3895
4738
  private noticeUnnoticedDrafts;
3896
4739
  /**
@@ -3904,7 +4747,8 @@ export declare class AgentFramework {
3904
4747
  */
3905
4748
  private noticeHeadMoves;
3906
4749
  /**
3907
- * Logical turn end, after the turn's deferred notices are flushed: record
4750
+ * Logical turn end, the turn's notices stored (each at its write since
4751
+ * #291, with no queue to flush first): record
3908
4752
  * as noticed exactly the drafts a stored message names (the receipt, a
3909
4753
  * held-draft notice, a bounce notice), each with the message that names
3910
4754
  * it. One whose notice never reached the history stays unnoticed, for the
@@ -3920,8 +4764,13 @@ export declare class AgentFramework {
3920
4764
  /** Which of these drafts a stored notice or receipt OF THIS RESIDENT names
3921
4765
  * (draft ids are unique only per resident, and residents can share one
3922
4766
  * history), each with the newest message that names it, reading only the
3923
- * recent history, where this turn's notices are. */
4767
+ * recent history of the slot's record, where this turn's notices are. A
4768
+ * notice stored and not presented to the agent yet counts: its next start
4769
+ * presents it. Once the agent's context presents rows (#291), one taken
4770
+ * out of its window as an undone turn's (windowStatusOf 'undone') doesn't:
4771
+ * the record still holds it, and the agent's window doesn't. */
3924
4772
  private draftsNamedInHistory;
4773
+ private static undoneInWindow;
3925
4774
  /** Page size for drafts(action: "list"). */
3926
4775
  private static readonly DRAFTS_PAGE;
3927
4776
  /** Drafts with a delivery attempt in flight, `${agent}\u0000${id}`: a
@@ -3959,10 +4808,21 @@ export declare class AgentFramework {
3959
4808
  * for them, and the agent may send them where it chooses.
3960
4809
  */
3961
4810
  private routeLocusSpeech;
4811
+ private cameFrom;
4812
+ /**
4813
+ * Hold a locked turn's plain speech as drafts ('no-destination'): the agent
4814
+ * pointed its speech at drafts, or has no lock yet. Named in the turn's
4815
+ * receipt rather than a notice per round, since holding is what the agent
4816
+ * asked for.
4817
+ */
4818
+ private holdLockedProse;
3962
4819
  /** The mark a framework wake takes from a heartbeat's turn with no locus
3963
4820
  * of its own (InferenceRequest.heartbeatTurn), so the turn it opens is a
3964
4821
  * heartbeat's too; nothing for any other turn. */
3965
4822
  private heartbeatTurnMark;
4823
+ private unpromptedTurnMark;
4824
+ private wakeChannelsMark;
4825
+ private turnRetryOf;
3966
4826
  /** Hold a heartbeat turn's plain speech as drafts ('no-destination'), named by `round`'s notice. */
3967
4827
  private holdHeartbeatProse;
3968
4828
  /** Record a successful plain-prose delivery for this turn's receipt. */
@@ -3981,6 +4841,14 @@ export declare class AgentFramework {
3981
4841
  * ([discord-send-failed]); this is the success half.
3982
4842
  */
3983
4843
  private appendProseDeliveryReceipt;
4844
+ /**
4845
+ * main's [speech-not-posted] notice, the agent's own row (#291:
4846
+ * storeOwnRow, stamped and presented as it is stored), written by the frame
4847
+ * whose turn ends here, or by a start before its compile, each holding the
4848
+ * agent. A dropped start (endDroppedTurn) passes `present` false: its agent
4849
+ * may have been replaced, and a turn of the new one's may be alive, so the
4850
+ * row waits out of the window for the agent's next point.
4851
+ */
3984
4852
  private nameUnpostedSpeech;
3985
4853
  private noteFailedTurnEnd;
3986
4854
  /**
@@ -3989,9 +4857,9 @@ export declare class AgentFramework {
3989
4857
  * destination itself. A `>>` into a channel the agent closed or declined
3990
4858
  * leaves it closed, so the note goes wherever the turn's speech stayed in
3991
4859
  * such a channel, once per channel. It goes through addMessage, as the
3992
- * open notices do: held while the agent has a turn alive and written at
3993
- * that turn's next boundary, so it reaches the agent once and never
3994
- * mid-turn. No-op otherwise.
4860
+ * open notices do: stored at once, and presented at the agent's next
4861
+ * presentation point while a turn of its is alive, so it reaches the
4862
+ * agent once. No-op otherwise.
3995
4863
  */
3996
4864
  private appendClosedChannelNoteAlone;
3997
4865
  /**
@@ -4006,6 +4874,54 @@ export declare class AgentFramework {
4006
4874
  /** The stored baseline's entry for the agent set (rememberAnnouncedLocus),
4007
4875
  * or removed (undefined) when the agent ends without coming back. */
4008
4876
  private writeAnnouncedLocus;
4877
+ /**
4878
+ * Whether the agent's current turn has no channel of its own, so it is
4879
+ * answering no incoming message (ChannelRegistry.incomingFor): a
4880
+ * heartbeat's, or one woken for a channel that names none, which no re-pin
4881
+ * or channel_open has given a channel since. A locked turn's locus is where
4882
+ * it speaks, not a message it answers, so it never counts as one.
4883
+ */
4884
+ private channellessTurn;
4885
+ /**
4886
+ * The prose routing an agent's turns run under: its configured mode, except
4887
+ * for a locked agent's conversation fork and ephemeral run, which have no
4888
+ * lock of their own. A fork is bound to its home channel, so it routes as
4889
+ * locus mode does. A run's plain speech is its caller's result, and it
4890
+ * publishes none: run as locus mode, its narration between tool calls would
4891
+ * post to the channel inferred for its turn, which the lock exists to
4892
+ * prevent, so it runs disabled, as a disabled resident's run does.
4893
+ */
4894
+ private proseRoutingOf;
4895
+ /**
4896
+ * A locked agent's own choice of destination (prose_locus), as
4897
+ * framework/state keeps it: a channel, 'drafts', or undefined when it
4898
+ * hasn't chosen. Throws when the state can't be read.
4899
+ */
4900
+ private readProseLock;
4901
+ /** Record a locked agent's choice of destination. Throws when it isn't recorded. */
4902
+ private writeProseLock;
4903
+ /**
4904
+ * Where a locked agent's plain speech goes now: its own choice
4905
+ * (prose_locus), else its recipe's proseLock, resolved as a `>>` target
4906
+ * is, else nowhere (null: held as drafts). A stored choice that can't be
4907
+ * read holds the speech as drafts rather than fall back to the recipe's,
4908
+ * which the agent may have moved it away from.
4909
+ */
4910
+ private proseLockLocus;
4911
+ /** Where a locked turn's plain speech goes now: its locus, or nowhere (drafts) while a move holds the rest of the turn (heldForMove). */
4912
+ private turnSpeaksAt;
4913
+ /** " prose_locus moves it." where the agent may call prose_locus, else nothing: a notice names only a tool the agent has. */
4914
+ private proseLocusMoves;
4915
+ /** Where a locked agent's plain speech goes, as the agent is told it: a verb phrase after "your plain speech". */
4916
+ private proseLockShown;
4917
+ /**
4918
+ * prose_locus: read or move a locked agent's prose lock. A move is
4919
+ * recorded before it applies, so a failed write moves nothing. It applies
4920
+ * to the calling turn's later rounds while that turn is open (what the
4921
+ * calling round wrote was routed with the locus it had), and to every
4922
+ * later turn.
4923
+ */
4924
+ private proseLocusToolResult;
4009
4925
  /**
4010
4926
  * Announce-on-change locus notice (turn-frozen routing). Appends a durable
4011
4927
  * `[routing]` window message when the turn's effective outbound locus
@@ -4033,8 +4949,221 @@ export declare class AgentFramework {
4033
4949
  * (addressedElsewhereNotice).
4034
4950
  */
4035
4951
  private repinChannel;
4952
+ /**
4953
+ * Whether `agent`'s logical turn is alive: a turn token, or a continuation
4954
+ * of its turn or a retry on its way (hasTurn: a budget restart's queued
4955
+ * continuation, a provider hold's retry), or a live stream or a tool cycle
4956
+ * pending (turnAlive). The one test the presentation index (its host's
4957
+ * turnAlive) and the writes that weigh a turn share: a write stored then
4958
+ * is marked not presented (addMessage) and takes no clock row ahead of it,
4959
+ * and no undo or redo is made.
4960
+ */
4961
+ private logicalTurnAlive;
4036
4962
  /** Whether `agent` has a turn alive: starting, streaming or waiting on its tools. */
4037
4963
  private turnAlive;
4964
+ /**
4965
+ * Whether the presentation index presents for `agent` (#291): the agent
4966
+ * taken on, and its context in presented mode. Every registered agent is
4967
+ * taken on, its window written down at its registration, and again on the
4968
+ * new branch after every move of the store's branch where that branch has
4969
+ * none (followBranchMove: a branch made before the write-down, a rollback
4970
+ * into rows the write-down presented), so a branch move doesn't end it.
4971
+ * One whose window couldn't be written down (another version's index
4972
+ * format, or a failed write), or whose context couldn't follow a branch
4973
+ * move, stays unpresented until the next move (legacy mode: its window
4974
+ * the whole record where the branch has none, or as the new branch holds
4975
+ * it, writes for it then waiting in memory), traced as
4976
+ * presentation:failed; the paths that ask this pass it by: nothing is
4977
+ * presented for it, its tool boundaries hear nothing, and undo refuses
4978
+ * it.
4979
+ */
4980
+ private presents;
4981
+ /**
4982
+ * Record, at an agent's registration, the mode its requests send other
4983
+ * agents' rounds in (foreignRoundsConfigured). An agent that takes its
4984
+ * context from another (`from`: a derived agent's parent, a conversation
4985
+ * fork's template) is sent them in the mode configured for that agent,
4986
+ * the one its window uses when presented (a source left in legacy mode by
4987
+ * a failed write-down is sent them as stored meanwhile; a child it
4988
+ * derives, presented, isn't), its inheritance holding what that agent's
4989
+ * window held of them, a shared derivation's as a window and a copy's or
4990
+ * a fork's seed as its own rows. The source is live here: the registry
4991
+ * admits a derived agent only while its context source is, but for a
4992
+ * resumption, which takes its configuration's mode as below. Otherwise, an
4993
+ * agent that observes another is sent them as its configuration's
4994
+ * foreignRounds says, a transcript by default, as the persistent
4995
+ * subconscious is (foreign-rounds.ts). Any other agent reads no other
4996
+ * agent's rounds, and is left as stored.
4997
+ */
4998
+ private configureForeignRounds;
4999
+ /**
5000
+ * How another agent's rounds go out in `agent`'s requests
5001
+ * (Agent.setForeignRounds), for an agent whose configuration names a mode
5002
+ * (foreignRoundsConfigured): that mode while the presentation index
5003
+ * presents its window, and as stored (`'raw'`) while its window is the
5004
+ * record, as before the index. Set at its registration and again after
5005
+ * each branch move's rebase (followBranchMove), which can present a
5006
+ * window whose write-down failed at registration, or leave one in legacy
5007
+ * mode. Nothing for any other agent, which reads no other agent's rounds.
5008
+ */
5009
+ private applyForeignRounds;
5010
+ /**
5011
+ * Take a newly registered agent on (presentation.adopt: its window
5012
+ * written down, its own rows stored and not in it presented, its own-row
5013
+ * sink installed), and weigh each row of another writer that enters its
5014
+ * window at a start, at an end or at rest as its open turn's arrival
5015
+ * (noteArrival), as the flushes these points replace weighed what they
5016
+ * stored. A tool boundary weighs what it hears itself.
5017
+ */
5018
+ private adoptPresentation;
5019
+ /**
5020
+ * For the workspace's head-move notice (useWindow): whether `agentName`'s
5021
+ * window still holds the first of its own rows stored after
5022
+ * `afterSequence`, the store's head when it wrote a mount direct during a
5023
+ * turn of its, which is the round that made the write (one made outside
5024
+ * any turn isn't asked here). An undo on the window leaves the record
5025
+ * and the branch as they were and takes the turn's own rows out of the
5026
+ * window as undone, so this is where the agent's history no longer holds
5027
+ * the write. True for an agent the index doesn't present for, and where
5028
+ * no own row of its came after. A row is its own by the rule an undo
5029
+ * takes it out by (ownWindowRow), so a turn an earlier release stored,
5030
+ * with no stamp, counts by its voice. Reads the record back from its
5031
+ * newest row, 64 at a time, to that place, then weighs the rows after it
5032
+ * in store order.
5033
+ */
5034
+ private windowHoldsOwnRowsAfter;
5035
+ /** Let a deregistered agent go from the presentation index (forget), its arrival listener with it. */
5036
+ private forgetPresentation;
5037
+ /**
5038
+ * An agent's turn's end, or a moment its turn may have ended: what it is
5039
+ * owed is presented (presentation.presentAtEnd),
5040
+ * unless its logical turn is still alive (a token, a continuation or
5041
+ * retry on its way, a stream, a tool cycle), whose own points present
5042
+ * it. Idempotent; nothing for an agent the index doesn't present for.
5043
+ */
5044
+ private presentAtEndOf;
5045
+ /**
5046
+ * Whether a write stored for `agent` now waits outside its window for a
5047
+ * later point (#291), read before the write: while the host is quiesced,
5048
+ * or while a logical turn of the agent's is alive (`turnLive`,
5049
+ * logicalTurnAlive), but for a fresh tool_result (a draining turn's
5050
+ * continuation depends on it) and a write while the agent's start is
5051
+ * assembling, which that start presents before its compile.
5052
+ */
5053
+ private keptOutOfWindow;
5054
+ /**
5055
+ * Whether a write stored for `agent` as `id` is placed as not presented
5056
+ * to it (`presented: false`), which a coalesced render's delivery reads
5057
+ * to keep the render replaceable and wake its agent to read it: kept out
5058
+ * of the agent's window by its turn or a quiesced host (`keptOut`,
5059
+ * keptOutOfWindow), or stored while no logical turn of the agent's was
5060
+ * alive (`atRest`) and out of its window after its presentation at rest,
5061
+ * which failed (presentation.notPresented). Only for an agent the index
5062
+ * presents for.
5063
+ */
5064
+ private placedUnpresented;
5065
+ /**
5066
+ * A channel message stored straight into a fork's own store, past
5067
+ * addMessage, as the fork writes are (a correction
5068
+ * handleMcplChannelIncoming delivers, a message routeConversationIncoming
5069
+ * routes), stamped for the fork alone. While a surgery holds the store it
5070
+ * is held in memory instead (surgeryHeldWrites) and '' returned, and so
5071
+ * is it while a hold's release replays what the hold kept, but for the
5072
+ * write the replay stores (`replayed`, called as soon as its store
5073
+ * returns, as addMessage calls it), and while the fork's context
5074
+ * manager refuses its work after a failed re-initialization
5075
+ * (heldForRecovery, as addMessage keeps a write);
5076
+ * stored, it enters the fork's window at once when no turn of the fork's
5077
+ * is alive, else at the fork's next point (afterStore). One whose store
5078
+ * threw after its row landed is stored as that row, and one whose store
5079
+ * can't tell what of it landed throws that error, the rows it names
5080
+ * presented (landedThoughThrown), as addMessage's. `mayBeStored`: as
5081
+ * FrameworkWriteOptions.mayBeStored, read back in the fork's store.
5082
+ */
5083
+ private storeInFork;
5084
+ /**
5085
+ * The writes a surgery's hold kept (surgeryHeldWrites), replayed in the
5086
+ * order they arrived once the hold and its tokens are released, each by
5087
+ * the path it was held on: addMessage's, or a fork's store. Ahead of them
5088
+ * are the writes kept for an agent whose context manager the move
5089
+ * re-initialized after it refused its work (recoverHeldWrites). Each is
5090
+ * traced once, as it is stored (`message:added`, source
5091
+ * `surgery-release`, with its stored id): its arrival named none, and
5092
+ * wasn't traced. The trace is emitted synchronously, right after that
5093
+ * write's store and before the next write is stored, inside this call,
5094
+ * which no await interrupts: a listener that edits or removes the row
5095
+ * does so before any turn compiles a request with it in, though the row
5096
+ * may be in an idle reader's window by then (each reader takes it as it
5097
+ * is stored). The Discord module relies on that to apply the edits and
5098
+ * deletes it kept for a message whose create the hold kept, which no
5099
+ * module can reach before it lands (ModuleContext.addMessage). Keep it so,
5100
+ * or give such a module a callback the release calls in its place. The
5101
+ * writes are taken off the queue one at a time, each once it is stored or
5102
+ * lost, and while they replay (replayingHeld) the ones still waiting, the
5103
+ * one being stored included, stay listed (the tune-out's
5104
+ * getSurgeryHeldMessages, HostModeStatus.deferredWrites), a write such a
5105
+ * listener makes is kept behind them, and the tune-out's writesHeld reads
5106
+ * true, so a cancel a listener asks for waits for the replay's end, as it
5107
+ * does during the hold. A hold a listener begins meanwhile stops the
5108
+ * replay, and its own release stores the rest, in order: one begun by a
5109
+ * listener of the write being stored (its clock row's trace) leaves that
5110
+ * write unstored at their head. A
5111
+ * write for an agent whose context manager refuses its
5112
+ * work is kept in memory for it again (heldForRecovery), never dropped,
5113
+ * and is traced when a later move stores it. An agent that ends during
5114
+ * the hold takes its writes out of it as it ends, and passes them on
5115
+ * (releaseWindowNowOrAfterResume). One the release still meets for an
5116
+ * agent gone, or for a name another agent is registered under since
5117
+ * (heldWriteTargetGone), goes on to the primary if it is one the primary
5118
+ * takes in its place, and is dropped otherwise (passHeldWritesOn), told of
5119
+ * by an ops alert. A write whose store threw after its rows landed
5120
+ * (context-manager's WriteLandedError) is stored as those rows by
5121
+ * addMessage and storeInFork, presented and traced as any write stored
5122
+ * here. One whose store threw where context-manager can't tell what of it
5123
+ * landed (WriteOutcomeUnknownError) may be lost: the rows the error names
5124
+ * as stored are presented (by addMessage and storeInFork) and traced, the
5125
+ * first by its id, and the write is counted as one that may be lost, the
5126
+ * rows the store may hold besides named. Any other throw stored none of
5127
+ * the write: it is logged and lost. The rest go on either way. Each
5128
+ * agent's lost writes, and those that may be, are told of once, by a log
5129
+ * line and an ops alert of kind `store-held-lost`. Each is also given to
5130
+ * the tune-out coordinator, by its metadata (heldWriteLost), before the
5131
+ * deferred cancels run: a reader's note kept with a waiting cancel is
5132
+ * told lost to the reader when that cancel ends the hold, as the cancel's
5133
+ * waiting answer promised. So is each write stored (heldWriteStored),
5134
+ * before its trace: such a note counts as delivered then, and a stop
5135
+ * while its cancel still waits doesn't tell it lost.
5136
+ */
5137
+ private releaseSurgeryHeldWrites;
5138
+ /**
5139
+ * One write of releaseSurgeryHeldWrites's replay, the head of `queue`,
5140
+ * stored by the path it was held on; one that fails is noted in `lost`,
5141
+ * by agent, and given to the tune-out coordinator (heldWriteLost), which
5142
+ * knows its own writes by their metadata; one stored is given to it too
5143
+ * (heldWriteStored). It is taken off the queue once
5144
+ * it is stored, kept for its agent's recovery, passed on or lost, before
5145
+ * its trace; false where a
5146
+ * hold begun during its store (a listener of its clock row's trace)
5147
+ * keeps it at the head, unstored.
5148
+ */
5149
+ private replayHeldWrite;
5150
+ /**
5151
+ * Whether a round's turn was stopped while its results were built (a
5152
+ * spill's workspace write), which a tool boundary and a stream that
5153
+ * completed while its tools ran both await before they store anything:
5154
+ * the stop's name, or null when the round goes on. `before` is the state
5155
+ * the build began from and `stream` the round's stream.
5156
+ *
5157
+ * A host's cancelStream, stop() and abortInference, and an ephemeral run's
5158
+ * disposal, replace that state (the agent is left idle): `'state-changed'`.
5159
+ * A quiesce's abandon and stop() record their cancel of the stream and
5160
+ * leave the state to driveStream: the record's name, once the stream is no
5161
+ * longer waiting for these results. The stream's state is what makes the
5162
+ * record this stream's: one left under the same key by an earlier stream,
5163
+ * such as an earlier agent's of the same name, sits beside a stream still
5164
+ * waiting.
5165
+ */
5166
+ private roundStoppedDuringBuild;
4038
5167
  /**
4039
5168
  * Store the clock row due in `agent`'s window (clock-rows.ts), if the agent
4040
5169
  * has clock rows and a boundary has passed since the window's last clock,
@@ -4047,10 +5176,11 @@ export declare class AgentFramework {
4047
5176
  * the request that follows or before every request still to come, so the
4048
5177
  * window and the live stream keep matching.
4049
5178
  *
4050
- * None while the host is quiesced (the window is frozen for surgery), and
4051
- * none in the residents' shared slot while another of its readers (the
4052
- * subconscious among them, through its merged view) has a turn alive: the
4053
- * row would sit inside that turn without joining its stream. A clock that
5179
+ * None while the host is quiesced (the window is frozen for surgery). In
5180
+ * the residents' shared slot another reader's turn doesn't matter (#291):
5181
+ * the row is the agent's own, in no other resident's window unless that
5182
+ * resident observes the agent (AgentConfig.observes), which takes it at
5183
+ * its own points. A clock that
4054
5184
  * can't be planned or stored is logged and skipped: it never holds up what
4055
5185
  * it would have preceded. One whose write threw after it landed is the
4056
5186
  * window's all the same, so it's returned, and a tool boundary injects it.
@@ -4063,10 +5193,9 @@ export declare class AgentFramework {
4063
5193
  * that couldn't be stored (stored-injections.ts, #155 part 5). Which are
4064
5194
  * stored, and which skipped, is planInjectionStores'.
4065
5195
  *
4066
- * Nothing is stored while the window is held (slotHeldFrom: the host is
4067
- * quiesced, or another reader of the residents' shared slot has a turn
4068
- * alive, as for a clock row): `compile()` places what the plan would have
4069
- * stored, and what it skips, being in view already, isn't placed again.
5196
+ * Nothing is stored while the host is quiesced, as for a clock row:
5197
+ * `compile()` places what the plan would have stored, and what it skips,
5198
+ * being in view already, isn't placed again.
4070
5199
  * Rows are written in the order gathered. A row whose write throws is
4071
5200
  * placed by `compile()` instead, with every row after it, unless the
4072
5201
  * read-back shows it landed; where the read-back fails, a row whose write
@@ -4089,9 +5218,10 @@ export declare class AgentFramework {
4089
5218
  * since costs one request, as below. A part the strategy cut at its
4090
5219
  * per-message cap, or stripped an image from, counts as held, since a new
4091
5220
  * copy would meet the same. One a fold has summarized, a strategy's window
4092
- * has scrolled past, a throwing write left part-stored, or that no request
4093
- * since this agent started has held (and no failed start since has
4094
- * stored), is stored again at the next start,
5221
+ * has scrolled past, an undo has taken out of the agent's window (#291),
5222
+ * a throwing write left part-stored, or that no request since this agent
5223
+ * started has held (and no failed start since has stored), is stored
5224
+ * again at the next start,
4095
5225
  * so the agent has the current copy at the cost of one more row: a fold
4096
5226
  * between two starts leaves the request after it with the summary's word,
4097
5227
  * and the start after that stores it again. The rows to store come in the order gathered,
@@ -4104,27 +5234,37 @@ export declare class AgentFramework {
4104
5234
  * Undefined when there's nothing of the stored kind.
4105
5235
  */
4106
5236
  private planInjectionStores;
4107
- /**
4108
- * Whether a write the framework makes into `agent`'s window of its own
4109
- * accord (a clock row, a batched wake's line) waits: while the host is
4110
- * quiesced, or, for a reader of the residents' shared slot (the
4111
- * subconscious, which reads it through a merged view, included), while
4112
- * another reader of it has a turn alive, where it would land inside that
4113
- * turn.
4114
- */
4115
- private slotHeldFrom;
4116
5237
  /** Rows isNewestIn reads back past clock rows and stored injections. */
4117
5238
  private static readonly NEWEST_SCAN_ROWS;
4118
5239
  /** Rows a window's last-clock scan reads at a time. */
4119
5240
  private static readonly CLOCK_SCAN_ROWS;
4120
- /** What the next clock is planned from: the window's newest row's time and
4121
- * the time its last clock row reads, found by reading back from the
4122
- * newest row, CLOCK_SCAN_ROWS at a time, until a clock row comes, however
4123
- * far back it is. In the steady state the newest chunk holds it, unless
4124
- * more rows than that have come since the last clock; a window with no
4125
- * clock row is read whole once, and then takes one (planClock). */
5241
+ /** What the agent's next clock is planned from: its window's newest row's
5242
+ * time and the time its last clock row reads, found by reading back from
5243
+ * the newest row, CLOCK_SCAN_ROWS at a time, until a clock row comes,
5244
+ * however far back it is. In the steady state the newest chunk holds it,
5245
+ * unless more rows than that have come since the last clock; a window
5246
+ * with no clock row is read whole once, and then takes one (planClock).
5247
+ * While the agent's context is in legacy mode, its window is the slot's
5248
+ * record, a co-resident's rows and clock rows among them. Once it
5249
+ * presents rows (#291), the window is the rows presented to it, in their
5250
+ * order: a co-resident's clock row isn't in it unless the agent observes
5251
+ * that co-resident (AgentConfig.observes), and then the newest clock row
5252
+ * the window holds is read, whosever it is; a row stored and not
5253
+ * presented yet comes after the clock its start writes, so it isn't read. */
4126
5254
  private lastClockOf;
4127
5255
  private agentSees;
5256
+ /**
5257
+ * Record `view`, the filter `contextManager` was opened with
5258
+ * (context-options.ts: residentViewFilter, subconsciousViewFilter, or
5259
+ * liveViewFilterOf's choice for an agent's record), as what its agent sees
5260
+ * (storeSees), so main's checks of whether an agent sees a row (agentSees,
5261
+ * #853: a tool boundary's injection, an arrival, an unread message's
5262
+ * readers, the newest-row check, the recent-image scan) ask the predicate
5263
+ * its compiles read. Both views read a row's metadata alone. A manager
5264
+ * opened with no view keeps no record, and agentSees reads it as seeing
5265
+ * every row, as its compiles do. Returns the manager.
5266
+ */
5267
+ private recordView;
4128
5268
  /**
4129
5269
  * Weigh a message that no tool boundary of the agent's open logical turn
4130
5270
  * will weigh: one that would re-pin the locus becomes one of the turn's
@@ -4137,18 +5277,11 @@ export declare class AgentFramework {
4137
5277
  private noteArrival;
4138
5278
  /**
4139
5279
  * Whether `agent`'s store is the residents' one message slot, which every
4140
- * ordinary resident reads (`readsSharedSlot` in the registry). The subconscious reads that
4141
- * slot through a merged view, but its own store is isolated, as a fork's
4142
- * or an ephemeral agent's is.
5280
+ * ordinary resident reads: its own slot in the registry (`ownSlot`) is
5281
+ * that slot. The subconscious reads that slot through an observe edge, but
5282
+ * its own store is isolated, as a fork's or an ephemeral agent's is.
4143
5283
  */
4144
5284
  private isOrdinaryResident;
4145
- /**
4146
- * Weigh a message just stored in an ordinary resident's store for every
4147
- * other ordinary resident's open turn, running or not: residents read one
4148
- * message slot, and a tool boundary weighs only the messages drained for
4149
- * its own agent, so no boundary of another resident's turn weighs it.
4150
- */
4151
- private noteForOtherResidents;
4152
5285
  /**
4153
5286
  * Show the turn's typing indicator in `channel`, stopping the one it last
4154
5287
  * showed elsewhere: this stream's, or one an earlier stream of the turn
@@ -4179,18 +5312,20 @@ export declare class AgentFramework {
4179
5312
  */
4180
5313
  private repinTurnLocus;
4181
5314
  /**
4182
- * Under `speech.locus: 'delivery'`: tell the agent that someone addressed
4183
- * it from another channel while its turn was busy, since incoming traffic
4184
- * never moves the locus and a neutral message carries nothing that names
4185
- * its channel (first live run, 2026-10-12, finding C). Once per channel
5315
+ * Under `speech.locus: 'delivery'`, and in a locked turn under either rule:
5316
+ * tell the agent that someone addressed it from another channel while its
5317
+ * turn was busy, since incoming traffic never moves the locus and a neutral
5318
+ * message carries nothing that names its channel (first live run,
5319
+ * 2026-10-12, finding C). Once per channel
4186
5320
  * per turn (TurnRouting.addressedElsewhere); nothing for the turn's own
4187
- * locus. Stored durably; returned as stored for a live stream to inject
4188
- * with its boundary's other messages. Undefined when nothing was stored.
5321
+ * locus. Stored durably; returned as stored, with its id, for a live
5322
+ * stream to inject with its boundary's other messages, so the round's note
5323
+ * (noteRoundSent) names the stored row. Undefined when nothing was stored.
4189
5324
  */
4190
5325
  private addressedElsewhereNotice;
4191
5326
  /**
4192
5327
  * The arrivals a start of the turn consumes under `speech.locus:
4193
- * 'delivery'`: each one that addressed the agent, whose message is still
5328
+ * 'delivery'`, or in a locked turn: each one that addressed the agent, whose message is still
4194
5329
  * in the store, gets the addressed-elsewhere notice, oldest first. A
4195
5330
  * follow-up in an engaged channel addressed nobody and is not announced.
4196
5331
  */
@@ -4207,8 +5342,9 @@ export declare class AgentFramework {
4207
5342
  * ensureInitialDesiredState) only where the agent it's addressed to can
4208
5343
  * call it for every channel it names (canCloseChannels): a conversation
4209
5344
  * fork may close only its home channel, and an agent's allowedTools can leave
4210
- * channel_close out. The other residents can read it too, where several
4211
- * share one slot (#291); a fork's seed leaves it out (primaryNoticeTexts).
5345
+ * channel_close out. Where several residents share one slot it is stored
5346
+ * in the slot they share, but stamped for the agent it's addressed to
5347
+ * (#291); a fork's seed leaves it out (primaryNoticeTexts).
4212
5348
  * Where an
4213
5349
  * agent's own send opened a channel it can't close, the primary is told by
4214
5350
  * name too, if it's registered and can close it, and the agent is told
@@ -4224,14 +5360,17 @@ export declare class AgentFramework {
4224
5360
  * Write a builder's channel notices in order, each on its own: one that
4225
5361
  * can't be written is logged, and the rest are still written. A reader's
4226
5362
  * notice that says the primary was told comes after the primary's, and is
4227
- * written in its `untold` words where the primary's write failed, so it
4228
- * never says the primary was told of a notice that wasn't written. A write
4229
- * addMessage defers to the primary's next boundary, as it does any write
4230
- * to an agent mid-turn, counts as written: a memory-only queue loses it at
4231
- * exit, as it loses any deferred write. Through
4232
- * framework.addMessage for mid-turn safety (deferral + hear-while-acting
4233
- * injection): an open a delivery forces happens inside a live turn, and a
4234
- * direct context-manager append there would store the notice out of order.
5363
+ * written in its `untold` words where the primary's write threw, so it
5364
+ * never says the primary was told of a notice whose write threw. A write
5365
+ * a surgery's hold keeps in memory, or one kept for a manager that refuses
5366
+ * its work, counts as written (addMessage returns '' for it, without
5367
+ * throwing): if storing the primary's fails at the release, or a restart
5368
+ * loses it, the reader's notice, stored too, still says the primary was
5369
+ * told. A write is stored at once (#291), and one for an agent mid-turn enters its
5370
+ * window at its next point (its tool boundary hears it, or its turn's end
5371
+ * presents it). Through framework.addMessage, so a notice an open forces
5372
+ * inside a live turn is stored and presented as any write is, rather than
5373
+ * appended to the context manager straight.
4235
5374
  */
4236
5375
  private writeChannelNotices;
4237
5376
  /**
@@ -4321,8 +5460,10 @@ export declare class AgentFramework {
4321
5460
  * channel_open as the way to try again only where the agent it's addressed
4322
5461
  * to can call it: a conversation fork's channel_open is refused outright
4323
5462
  * (dispatchChannelToolCall), and an agent's allowedTools can leave it out.
4324
- * The other residents can read it too, where several share one slot
4325
- * (#291); a fork's seed leaves it out (primaryNoticeTexts).
5463
+ * Where several residents share one slot it is stored in the slot they
5464
+ * share, but stamped for the agent it's addressed to (#291), the primary
5465
+ * alone where it's told by name; a fork's seed leaves it out
5466
+ * (primaryNoticeTexts).
4326
5467
  * Where the channel is selected for opening, it says so and why, as
4327
5468
  * speech's failure does, and what that means: where the host couldn't
4328
5469
  * record putting the channel's decision back, a later delivery or
@@ -4391,9 +5532,6 @@ export declare class AgentFramework {
4391
5532
  * agent's cap. False when it couldn't be stored.
4392
5533
  */
4393
5534
  private writeAutoContinueNotice;
4394
- /** Whether another reader of the residents' shared slot has a turn alive,
4395
- * so no row may be written there now (as storeDueClock checks). */
4396
- private sharedSlotBusy;
4397
5535
  /** A continuation whose turn doesn't run: the run's count goes back to
4398
5536
  * what it was before it was queued. */
4399
5537
  private giveBackAutoContinue;
@@ -4529,8 +5667,8 @@ export declare class AgentFramework {
4529
5667
  * the gate released). Any other drop ends it as a start dropped before it
4530
5668
  * sends anything ends, and settles a registered ephemeral run's turn with
4531
5669
  * the drop's reason. That frame, if it hasn't let go of its token yet,
4532
- * ends on its own and settles nothing. What was deferred for the agent
4533
- * lands now, or at that frame's end.
5670
+ * ends on its own and settles nothing. What was stored for the agent
5671
+ * meanwhile is presented now (presentAtEndOf), or at that frame's end.
4534
5672
  */
4535
5673
  private endContinuedTurn;
4536
5674
  /**
@@ -4672,8 +5810,10 @@ export declare class AgentFramework {
4672
5810
  * - Refused unless the agent is idle with no turn alive: puppeting
4673
5811
  * mid-turn would corrupt the turn state machine and the live stream's
4674
5812
  * wire ordering. For its own duration the puppet HOLDS the turn-alive
4675
- * marker (wakes requeue, cross-turn writers defer), so a wake landing
4676
- * during the tool's execution cannot start a turn underneath the pair.
5813
+ * marker (wakes requeue, and a write meanwhile is stored at once and
5814
+ * kept out of the window until the agent's next presentation point, the
5815
+ * puppet's end), so a wake landing during the tool's execution cannot
5816
+ * start a turn underneath the pair.
4677
5817
  * - Refused for tools outside the agent's own surface (the tools it may
4678
5818
  * call, availableToolsForPresentation), and for skip_reply, by name or
4679
5819
  * through a toolsets--act that reaches it, which ends the turn it's
@@ -5111,15 +6251,16 @@ export declare class AgentFramework {
5111
6251
  private refusedResult;
5112
6252
  /**
5113
6253
  * Why this host refuses a skip_reply call, as the model will read it, or
5114
- * undefined when it doesn't (skipReplyWakeRefusal): without an EventGate,
5115
- * any wake_in_seconds; with one, a wake_in_seconds that isn't a number of
5116
- * seconds. Only when the channel registry handles skip_reply. The dispatch
5117
- * that refuses the call reads it here, and so does the turn's bookkeeping of
5118
- * a refused round (roundCallOf), for the model's calls and a script's calls
5119
- * that reach the host while a call of the round watches it: the silence
5120
- * before it, which comes back after its round, and in XML mode which round's
5121
- * prose stays private. A skip_reply round's own prose stays private by the
5122
- * tool's name, refused or not.
6254
+ * undefined when it doesn't: a reason that isn't a string
6255
+ * (ChannelRegistry.nonStringRefusal), or (skipReplyWakeRefusal) without an
6256
+ * EventGate, any wake_in_seconds, and with one, a wake_in_seconds that isn't
6257
+ * a number of seconds. Only when the channel registry handles skip_reply.
6258
+ * The dispatch that refuses the call reads it here, and so does the turn's
6259
+ * bookkeeping of a refused round (roundCallOf), for the model's calls and a
6260
+ * script's calls that reach the host while a call of the round watches it:
6261
+ * the silence before it, which comes back after its round, and in XML mode
6262
+ * which round's prose stays private. A skip_reply round's own prose stays
6263
+ * private by the tool's name, refused or not.
5123
6264
  */
5124
6265
  private skipReplyRefusal;
5125
6266
  private refusesSelfWake;
@@ -5127,8 +6268,8 @@ export declare class AgentFramework {
5127
6268
  * A call as its round's routing counts it, made directly, or by a script
5128
6269
  * and reaching the host while a run or wait call of the round watches it
5129
6270
  * (ScriptRound). A skip_reply refused, because the agent's allowedTools
5130
- * doesn't name it, because its arguments are refused (markedInputRefusal)
5131
- * or because this host can't set the wake it asks for, is
6271
+ * doesn't name it, because its arguments are refused (markedInputRefusal),
6272
+ * or because this host refuses its arguments (skipReplyRefusal), is
5132
6273
  * marked refused: it keeps its own round private and silences nothing after
5133
6274
  * it. A refusal withholds the call's effect, not the model's choice to keep
5134
6275
  * its words private. Any other call the list refuses posted nothing, so it
@@ -5149,48 +6290,64 @@ export declare class AgentFramework {
5149
6290
  private dispatchToolCall;
5150
6291
  private dispatchToolCallEvent;
5151
6292
  private addMessage;
6293
+ /**
6294
+ * The agents a write's placement may name (addMessage's out-param,
6295
+ * #291), never none: its delivery agent, or, for a write stored in that
6296
+ * agent's slot for other agents only (its stamp names them and not it,
6297
+ * as a coalesced render targeted to a co-resident is: inboundAudience),
6298
+ * those of them whose own slot it is. The placement names one agent,
6299
+ * whose store the coalescer reads the row in and removes it from
6300
+ * (isUnreadPlacement, removePlacement), whose wake reads it, and to whom
6301
+ * `presented` refers: the first of these the write wasn't presented to,
6302
+ * else the first. An agent that only observes the slot (the subconscious
6303
+ * over the residents' slot) has no copy of the row in its own store, so
6304
+ * a write for such agents alone is placed for the delivery agent, as
6305
+ * before.
6306
+ */
6307
+ private placementReaders;
5152
6308
  /**
5153
6309
  * Whether an MCPL event's own stored entry is the newest entry in the window
5154
- * a batched wake's line is written to (deliveryAgent(): the primary's), with
5155
- * no turn alive there (turnAlive: started, streaming, or waiting on its
5156
- * tools) and nothing waiting to be written (deferred). The gate then hands
5157
- * the line to the wake (WakeLine) instead of writing it, and the turn's
5158
- * start decides it (placeWakeLines). A channel message is found by its
5159
- * server, channel and message id, a push event by its server and event id.
5160
- * A message a tune-out holds from the residents is never "newest" here.
6310
+ * a batched wake's line is written to, with no turn alive there (turnAlive:
6311
+ * started, streaming, or waiting on its tools): the window of each agent a
6312
+ * targeted event was delivered to (`recipients`), else the delivery
6313
+ * agent's (deliveryAgent(): the primary's). The gate then hands the line to
6314
+ * the wake (WakeLine) instead of writing it, and the turn's start decides
6315
+ * it (placeWakeLines). A channel message is found by its server, channel
6316
+ * and message id, a push event by its server and event id. A message a
6317
+ * tune-out holds from the residents is never "newest" here.
5161
6318
  */
5162
6319
  private isNewestContextEntry;
5163
6320
  /**
5164
6321
  * Write the batched-wake lines the gate left to this turn's start (WakeLine)
5165
- * into the window they name, the delivery agent's (the residents' shared
5166
- * slot where it is one), on that agent's own start only. Called by a fresh
5167
- * start that doesn't resume a logical turn, after the turn's own inputs (a
5168
- * due clock row, the deferred-write and assembly flushes) and before its
5169
- * checkpoint, so a line lands after whatever arrived since the gate's
5170
- * decision, before the notices the turn's start writes itself (the locus
5171
- * notice among them), and before the agent's answer to the wake.
6322
+ * into the starting agent's own window, as its own rows (#291). Called by
6323
+ * a fresh start that doesn't resume a logical turn, after the turn's own
6324
+ * inputs (a due clock row, and the rows its start presents) and before its
6325
+ * checkpoint, so a line lands after whatever entered the window since the
6326
+ * gate's decision, before the notices the turn's start writes itself (the
6327
+ * locus notice among them), and before the agent's answer to the wake.
5172
6328
  *
5173
- * - A wake's one line whose event is still the newest entry is left out:
5174
- * no message follows the wake's, so it is the wake's whole cause, and the
5175
- * start's token defers an arrival into the window past its request. (The
5176
- * start's own notices, written after this, aren't messages a reply could
5177
- * be meant for.)
5178
- * - A co-resident's start places nothing. Every resident gets every
5179
- * batched wake, so a co-resident writing the line would put it under the
5180
- * message, the line #727 left out, or after the delivery agent's answer,
5181
- * a wake line for a message already answered. Its request shows what the
5182
- * slot holds, as on `main`: a reply after the message is in the message's
5183
- * own channel, but a message from another channel that lands between the
5184
- * gate's decision and its compile follows the message with no line.
6329
+ * - A wake's one line whose event is still the newest entry of the
6330
+ * agent's window is left out: no message follows the wake's, so it is
6331
+ * the wake's whole cause, and an arrival stored past the start enters
6332
+ * the window at a later point, after its request. (The start's own
6333
+ * notices, written after this, aren't messages a reply could be meant
6334
+ * for.)
6335
+ * - Each resident a batched wake is for (every resident, or a targeted
6336
+ * batch's recipients) gets it, and each one's start
6337
+ * decides and writes its own line: a co-resident's line, and her reply,
6338
+ * are her own rows and enter no other window but an observer's
6339
+ * (AgentConfig.observes), which takes them as it takes her rounds; in
6340
+ * no other can either land under the message or after another
6341
+ * resident's answer. For an agent whose
6342
+ * window isn't presented (its write-down failed, so its window is the
6343
+ * record), only the delivery agent's start writes the slot's one line,
6344
+ * and a co-resident's start places nothing.
5185
6345
  * - Two or more lines are all written, each naming its message, its age
5186
6346
  * counted to now.
5187
- * - None is written while the host is quiesced or another reader of the
5188
- * slot has a turn alive (slotHeldFrom, as for a clock row): written, a
5189
- * line would land inside that turn, and deferred, it would wait for the
5190
- * delivery agent's next boundary, never reaching this request
5191
- * (overlapping turns in the slot, #286). They stay undecided, and are
5192
- * written only if another fresh start of the wake comes (a provider
5193
- * hold's release, a requeue): this start's request goes without them.
6347
+ * - None is written while the host is quiesced, as for a clock row. They
6348
+ * stay undecided, and are written only if another fresh start of the
6349
+ * wake comes (a provider hold's release, a requeue): this start's
6350
+ * request goes without them.
5194
6351
  *
5195
6352
  * A line left out is traced. Each line is written once (placedWakeLines),
5196
6353
  * across the wake's retries and holds, whichever copy of its trigger a
@@ -5202,41 +6359,88 @@ export declare class AgentFramework {
5202
6359
  * clock rows, stored context injections and rows the agent's own view
5203
6360
  * leaves out after it aside: a channel message by its server, channel and
5204
6361
  * message id, a push event by its server and event id, and never one the
5205
- * agent's view leaves out, such as one a tune-out holds. Past
5206
- * NEWEST_SCAN_ROWS such rows, it answers no. */
6362
+ * agent's view leaves out (agentSees), such as one a tune-out holds. Past
6363
+ * NEWEST_SCAN_ROWS such rows, it answers no. While the agent's context
6364
+ * is in legacy mode, its window is the slot's record, read from its
6365
+ * newest row. Once it presents rows (#291), the window's own order
6366
+ * decides, as the agent's next request will hold it (windowTail): the
6367
+ * rows presented to it, then its own rows and its arrivals not presented
6368
+ * yet (bearingOf), an observed co-resident's rounds among them, which its
6369
+ * next start presents; a row stored in a shared slot for another agent,
6370
+ * such as the own round of a co-resident it doesn't observe, isn't in
6371
+ * it. */
5207
6372
  private isNewestIn;
6373
+ /**
6374
+ * The newest `limit` rows of a presented window as the agent's next
6375
+ * request will hold them, newest first: the rows it is owed and not
6376
+ * presented yet (its own rows and its arrivals, one per body, as the
6377
+ * presentation index reads them: owedOf, so an observed co-resident's
6378
+ * round is among them), after the rows its window holds. A row presented
6379
+ * later than a newer one comes after it here, as in the window.
6380
+ */
6381
+ private windowTail;
5208
6382
  /** Where addMessage delivers: the named agent, else the primary, else the
5209
6383
  * first registered agent. Undefined when there is no such agent. */
5210
6384
  private deliveryAgent;
6385
+ /**
6386
+ * The audience addMessage stamps a write with when its caller gives none
6387
+ * (#291): for one a suppress rule took (suppressedRow), nobody, as no view
6388
+ * renders it; for one that carries a tune-out's hold, nobody, since no
6389
+ * resident is shown it (inboundAudience), unless it names an agent whose
6390
+ * own view keeps it (agentSees, main's #853: the subconscious, whose view
6391
+ * keeps held traffic), which it is for; the agent a write names
6392
+ * (`forAgent`); and for a write that names no agent, untargetedAudience
6393
+ * of the agent it is delivered to. Undefined only for that last on a
6394
+ * host with no agent, where addMessage stores nothing. Restore stamps an
6395
+ * entry an earlier version queued by the same rule
6396
+ * (restorePersistedDeferredWrites).
6397
+ */
6398
+ private defaultAudience;
6399
+ /**
6400
+ * Who a write that names no agent is for (#291's audience stamp): the
6401
+ * agents whose role takes untargeted inbound (the registry's
6402
+ * untargetedRecipients) and whose own slot is the slot the write lands
6403
+ * in, its delivery agent's, in registration order. On a residents' host
6404
+ * that is every resident, as every resident reads the shared slot the
6405
+ * row is stored in; with one resident it is that resident, the stamp such
6406
+ * a write had before. The delivery agent alone when there is none: a host
6407
+ * whose only agent is an ephemeral run, or an agent the registry doesn't
6408
+ * place. This is the rule #291's presentation index presents an
6409
+ * untargeted row in the shared slot by, applied when the row is written,
6410
+ * so the record tells an untargeted write from one for the primary,
6411
+ * which is stamped with the primary alone. The slot's observers (the
6412
+ * subconscious) aren't in it: they are a relationship in the registry
6413
+ * (dendrite/audience.ts).
6414
+ */
6415
+ private untargetedAudience;
6416
+ /** A message was said to `agentName` (main's #846): the re-send count of
6417
+ * its exhausted turn starts again, unless its own view leaves the
6418
+ * message out (agentSees), it is the agent's own schedule write, or it
6419
+ * isn't conversation. */
5211
6420
  private noteSpokenTo;
5212
- /** The notes addMessage takes for a message it stored: an arrival for the
5213
- * agent when none of its turns is alive or the message was assembled for
5214
- * the start now beginning (no tool boundary will weigh it), and one for
5215
- * every other resident's open turn. */
6421
+ /** The notes addMessage takes for a message it stored. Each agent it is
6422
+ * for was spoken to (noteSpokenTo): the agents its audience stamp names
6423
+ * (#291), which for a write that names no agent are the residents that
6424
+ * take untargeted inbound in its slot, as main notes every other
6425
+ * resident (noteForOtherResidents there), and the agent it was delivered
6426
+ * to where it carries no stamp. And for an agent whose window isn't
6427
+ * presented (a write-down of it failed), whose window is the record: an
6428
+ * arrival for its open turn when none of its turns is alive or its start
6429
+ * is assembling (no tool boundary will weigh it). An agent the
6430
+ * presentation index presents for weighs the row as it enters its window
6431
+ * (adoptPresentation's listener), or at the tool boundary that hears it,
6432
+ * not here. */
5216
6433
  private noteStored;
5217
6434
  /**
5218
6435
  * Held agent mail is released only when its message has actually entered
5219
- * the recipient's store — never on a deferral. Called at every site that
5220
- * writes a message into a context: the direct path above and the two
5221
- * deferred-write flushes (turn start, tool boundary). Both writes reach
5222
- * disk in the same sync, so a crash keeps either both or neither.
6436
+ * the recipient's store, as a copy for that recipient — never while a
6437
+ * surgery's hold, or the wait for the recipient's recovery, keeps the
6438
+ * write in memory. Called where the framework stores a
6439
+ * message (addMessage, and the importer's lookup of a write that landed).
6440
+ * Both writes reach disk in the same sync, so a crash keeps either both or
6441
+ * neither.
5223
6442
  */
5224
6443
  private releaseLandedMail;
5225
- /**
5226
- * Splice out the deferred messages addressed to `agentName` (explicitly
5227
- * via forAgent, or implicitly when it is the primary), leaving other
5228
- * targets' messages queued for their own boundaries. With `stopAt`, the
5229
- * drain ends at the first of them (in queue order) that it matches: that
5230
- * message and every later one stay queued, so what is drained is always a
5231
- * prefix of the agent's queue.
5232
- */
5233
- private drainDeferredFor;
5234
- /**
5235
- * Put drained entries back into the queue under their ids and seq: out of
5236
- * the un-acked set, and persisted when the queue is. A memory-only queue
5237
- * keeps them while the framework runs.
5238
- */
5239
- private requeueDrained;
5240
6444
  /**
5241
6445
  * What the next compile sends for each of `ids`, messages a tool boundary
5242
6446
  * has just stored, as the agent's strategy renders them as the newest of
@@ -5250,110 +6454,9 @@ export declare class AgentFramework {
5250
6454
  * strategies could say.
5251
6455
  */
5252
6456
  private renderForInjection;
5253
- /**
5254
- * Write drained entries in queue (seq) order, whatever their targets:
5255
- * residents share one message slot, so the order entries arrived in is the
5256
- * order they're stored. Each target is cut at its own first entry that
5257
- * can't be stored: that entry and every later one for the same target go
5258
- * back into the queue under their ids and seq (requeueDrained) before
5259
- * anything is logged, and other targets' entries go on. Left in the
5260
- * un-acked set, the next ack would drop them from the durable queue.
5261
- *
5262
- * So none of a target's entries lands ahead of an earlier one, and a queued
5263
- * tool_use that can't be stored keeps the tool_result queued behind it from
5264
- * being stored alone, unless context-manager refused it as malformed
5265
- * (below). (A tool_use that is stored, followed by a tool_result that
5266
- * can't be, stays stored without it until the tool_result lands at a later
5267
- * flush, or for good when the store refuses the tool_result as malformed.
5268
- * The only queued pair is puppetToolCall's, queued only when its turn's
5269
- * token is no longer its own once the pair is built, which its comment
5270
- * calls defensive.) An entry that keeps failing is logged by id at each
5271
- * flush, and holds its target's later queued writes rather than letting
5272
- * them land out of order.
5273
- *
5274
- * An entry context-manager refuses as malformed (MalformedContentError) is
5275
- * the exception for the store's own validation: context-manager checks
5276
- * content and every shard before writing. A custom synchronous strategy
5277
- * hook can throw the same class after append (context-manager #288);
5278
- * unreadable landing in that callback escape remains a limitation until
5279
- * the CM follow-up lands. A copy actually found still counts first. Other
5280
- * ambiguous errors remain queued for ID reconciliation before retry. A
5281
- * malformed refusal would fail every flush and hold its target's later
5282
- * writes for good, so it's logged and dropped instead, and its
5283
- * target isn't cut: left in the un-acked set, the next ack drops it from
5284
- * the durable queue. A tool_use dropped this way leaves a tool_result
5285
- * queued behind it to be stored alone. context-manager mends a tool_use
5286
- * whose input isn't an object, so it refuses one only when that input has
5287
- * no JSON form or the block itself is malformed. addMessage refuses such
5288
- * content before it's queued, so an entry meets this here from a queue an
5289
- * earlier process persisted, as puppetToolCall's pair, which it queues
5290
- * itself, or when the strategy's chunking splits well-formed content into a
5291
- * shard the store refuses, which the store's error names.
5292
- *
5293
- * From a fresh turn's start to the end of its coalescing assembly, before
5294
- * its checkpoint, every write deferred for its agent lands in that
5295
- * request, in arrival order, up to one that can't be stored and unless the
5296
- * host is quiesced (flushForStart). The turn-start flush writes the queue;
5297
- * while the assembly runs, each write it makes into the agent's own window
5298
- * (addMessage's bypassDeferralFor) first writes what was deferred since;
5299
- * and what was deferred during the assembly is written once it ends. A
5300
- * write the assembly makes while an entry is held waits behind it in the
5301
- * queue, so the hold covers the assembly's writes too, and so does one
5302
- * made while the host is quiesced with anything queued for the agent: a
5303
- * quiesce that begins while an assembly awaits a render lets that turn
5304
- * drain, and what is queued waits for resume(). Outside that window the
5305
- * hold is the queue's alone: a write that isn't deferred is stored at once
5306
- * and can land ahead of a held entry, as a fresh tool_result does whatever
5307
- * its agent's state, and any write does while its agent's turn, stream and
5308
- * tool cycle are all idle and the host isn't quiesced. So an entry that
5309
- * keeps failing holds what is deferred behind it and the assembly's writes
5310
- * for its agent.
5311
- *
5312
- * A write can throw after its message is stored: a store listener, the
5313
- * strategy's handling of the add, or a later shard of a sharded body can
5314
- * throw once a record is written. Before an entry that threw is put back,
5315
- * its target's store is read from where it stood before the write, for
5316
- * messages carrying the entry's `deferredWriteId`. What it finds counts as
5317
- * written, at most once: the entry isn't requeued and stored a second
5318
- * time, and what landed, as later compiles render it (asCompiled), is what
5319
- * it returns as the entry's content. For a sharded body, that can be its
5320
- * first shards alone if rollback could not remove them; context-manager
5321
- * from 0.15 otherwise removes shards from a failed append. (Requeued, the
5322
- * landed shards would be stored twice, and only the rest could not be
5323
- * appended later without splitting the body.) Boot's scan for landed
5324
- * writes counts a landed shard the same way. When the store can't be read
5325
- * back (storedCopiesOf logs it), or couldn't say how many messages it held
5326
- * before the write, the store is searched for the entry's id at once
5327
- * (landedCopiesById): found, it counts as written, as above. When that
5328
- * can't be done either, whether the entry landed is unknown: it's put back
5329
- * marked so (`landing`), and before it's written again the store is
5330
- * searched for its id. Found then, it counts as written where it was
5331
- * stored, ahead of what was stored since without it, a known limit
5332
- * (context-manager #155, named at the tool boundary's drain); not found,
5333
- * it's written. While the store can't be searched, it stays queued,
5334
- * holding what's behind it.
5335
- *
5336
- * Returns what was written (stored, or deferred again by addMessage, whose
5337
- * id is then empty), in queue order: for one target, its entries up to the
5338
- * first that couldn't be stored, less entries refused as malformed and dropped. Each comes
5339
- * with its content: as given, unless the store took it as more than one
5340
- * message (a sharded body) and can be read back, when its copies are
5341
- * returned joined, as later compiles render them (asCompiled), or its write
5342
- * threw after storing it (above). `onLanded` hears an entry whose write
5343
- * threw after storing it, with the id it landed under, as soon as it's
5344
- * found: before the writes after it, so whatever it records keeps their
5345
- * order.
5346
- */
5347
- private writeDrainedInOrder;
5348
6457
  /** How many messages the agent's store holds: undefined when its store
5349
6458
  * can't say. */
5350
6459
  private storedCountOf;
5351
- /** The messages carrying `deferredWriteId` among those the agent's store
5352
- * gained from position `from` on, in store order, with their blobs
5353
- * resolved, as a request carries them. A sharded body's carry its
5354
- * `bodyGroupId`. Undefined when the store can't be read back, which is
5355
- * logged: not the same as nothing found. */
5356
- private storedCopiesOf;
5357
6460
  /** The messages `match` picks among those the agent's store gained from
5358
6461
  * position `from` on, in store order, with their blobs resolved. Undefined
5359
6462
  * when the store can't be read back, which is logged under `tag`, naming
@@ -5369,66 +6472,41 @@ export declare class AgentFramework {
5369
6472
  * is absent, and a write taken as absent is stored again.
5370
6473
  */
5371
6474
  private landedPositions;
6475
+ /** The rows on `cm`'s current branch whose metadata `match` picks, by
6476
+ * position and id, in store order, scanned as landedPositions says: in
6477
+ * blob-free windows, throwing where a window can't be read or comes back
6478
+ * short. */
6479
+ private rowsWhere;
6480
+ /**
6481
+ * The rows of the coalesced occurrence `metadata` is a delivery of (its
6482
+ * `coalescingSubject` and `eventId`, the delivery identity wasPublished
6483
+ * reads at a restore) that `agent`'s store holds on its current branch, in
6484
+ * store order: [] for none, or for a write that carries no such identity.
6485
+ * A delivery's recovery reads them before it stores the occurrence again
6486
+ * (FrameworkWriteOptions.mayBeStored), after a delivery whose store
6487
+ * couldn't tell whether it landed: context-manager gives the row of an
6488
+ * append that threw no id, so it is found by what it carries, as
6489
+ * findMessageByExternalId finds a module's write. Scanned blob-free
6490
+ * (rowsWhere), so a blob missing from some row can't hide them. Undefined
6491
+ * when the store can't be read to tell, which is logged, naming the
6492
+ * occurrence and the duplicate its store may then make: the one case the
6493
+ * recovery can't tell.
6494
+ */
6495
+ private storedOccurrenceRows;
5372
6496
  /**
5373
6497
  * The messages carrying `deferredWriteId` anywhere on the agent's current
5374
6498
  * branch, in store order with their blobs resolved, as a request carries
5375
- * them, so no position is needed. They're found with queryMessages, over
5376
- * context-manager's cached view, as landedRow finds a held write's row.
5377
- * Where that throws, as one blob missing anywhere on the branch makes it
5378
- * do, the branch is scanned blob-free instead (landedPositions), and only
5379
- * the rows that match are read with their blobs. Undefined when the store
5380
- * can be searched neither way, or the scan finds the write's rows but one
5381
- * of them can't be read. Each write whose lookup fails is said once until
5382
- * a lookup of it succeeds, since every path that reads held writes looks
5383
- * again.
6499
+ * them, so no position is needed: where an earlier release's queued write
6500
+ * whose landing it couldn't tell may have landed (the importer's lookup).
6501
+ * They're found with queryMessages, over context-manager's cached view,
6502
+ * as landedRow finds a held write's row. Where that throws, as one blob
6503
+ * missing anywhere on the branch makes it do, the branch is scanned
6504
+ * blob-free instead (landedPositions), and only the rows that match are
6505
+ * read with their blobs. Undefined when the store can be searched neither
6506
+ * way, or the scan finds the write's rows but one of them can't be read,
6507
+ * which is logged.
5384
6508
  */
5385
6509
  private landedCopiesById;
5386
- /** The line naming a drained write that threw: one that couldn't be stored,
5387
- * which is already back in the queue; with 'dropped', a malformed refusal
5388
- * from the store's pre-write validation (see the CM #288 caveat above);
5389
- * with a count, one stored before the
5390
- * throw (for a sharded body, how many of its shards), or, with
5391
- * `foundLater`, one an earlier write of which landed and was found by its
5392
- * id; with `'unknown'`, one whose store couldn't be read to tell
5393
- * whether it landed, back in the queue to be looked up first; and with
5394
- * `'still-unknown'`, one that still can't be looked up. Logging mustn't
5395
- * fail the flush that met it, so a thrown value that has no text is
5396
- * named as such. */
5397
- private logDeferredWriteError;
5398
- /**
5399
- * Write what is queued for `agent` into its window past its deferral, in
5400
- * queue order and cut at a write that fails, though one the store refuses
5401
- * as malformed is dropped and what follows goes on (writeDrainedInOrder),
5402
- * between a fresh turn's start and its checkpoint, where what is stored is
5403
- * the turn's input: at the start, before each write the coalescing
5404
- * assembly makes for the agent, and once the assembly ends, the last two
5405
- * not while the host is quiesced, when what is queued waits for resume().
5406
- * What is stored is weighed for the start now beginning and for every
5407
- * other resident's open turn. Returns whether anything is still queued for
5408
- * the agent.
5409
- */
5410
- private flushForStart;
5411
- /** Whether anything is queued for `agentName`, by drainDeferredFor's
5412
- * target rule. */
5413
- private queuedFor;
5414
- /** Re-add drained entries through addMessage, which stores each or defers
5415
- * it again, in queue order and cut per target (writeDrainedInOrder). With
5416
- * `bypassDeferral`, each is stored past its target's deferral (stop()). A
5417
- * write that threw after storing missed the notes addMessage takes after a
5418
- * store, so they're taken for what landed as soon as it's found, before
5419
- * the writes after it: an open turn's arrivals keep the order the writes
5420
- * landed in, and its newest stays the newest (remainingArrival).
5421
- *
5422
- * A target no longer registered (a fork or a run that has ended, here or
5423
- * before a crash) has no window to land in: a failed reply queued for it,
5424
- * or a channel notice it could have acted on, becomes the primary's
5425
- * by-name notice, and a module's write for a run or a fork goes to it as
5426
- * written, each under the entry's own id and place in the queue
5427
- * (passesToPrimary, queuedNoticeForPrimary), written with the rest; any
5428
- * other write is dropped, logged, by addMessage. Nothing here reads the gone agent's
5429
- * window, so such a notice an earlier write of which landed there, and
5430
- * which the agent read, goes on too. */
5431
- private readdDrained;
5432
6510
  /**
5433
6511
  * Where a notice about an agent's own action belongs: its failed reply, its
5434
6512
  * bounced prose (beside its `{{unsent}}` clipboard), its script's wake, the
@@ -5437,8 +6515,9 @@ export declare class AgentFramework {
5437
6515
  * waits on that agent's own turn, stream and tool cycle: a conversation
5438
6516
  * fork or an ephemeral run reads only its isolated slot, and a resident's
5439
6517
  * notice would otherwise wait on the primary's turn rather than its own.
5440
- * Residents share one message slot, so a resident's notice can land there
5441
- * while another resident's turn is alive; agent-framework #291 covers that.
6518
+ * Residents share one message slot, so a resident's notice can be stored
6519
+ * there while another resident's turn is alive; since #291 it is for its
6520
+ * agent alone, and enters no other resident's window.
5442
6521
  *
5443
6522
  * null when the agent is no longer registered (a fork or a run already
5444
6523
  * released): there is no window to write, so the caller writes nothing,
@@ -5452,81 +6531,65 @@ export declare class AgentFramework {
5452
6531
  /**
5453
6532
  * A conversation fork or an ephemeral run has been deregistered. A release
5454
6533
  * never runs while the host is quiesced: it waits for resume()
5455
- * (releaseWindowNowOrAfterResume), since a write could land mid-surgery.
6534
+ * (releaseWindowNowOrAfterResume), or, when stop() comes first, stop()
6535
+ * runs it.
5456
6536
  *
5457
6537
  * The agent never reads its window again, so every failed-reply notice it
5458
6538
  * never read, and every channel notice it could act on and never read, is
5459
6539
  * passed to the primary, by name, once, and so is every module write for
5460
6540
  * it that it never read, as the write itself (passesToPrimary,
5461
- * passOnFromReleasedWindow): each one stored in its window above its
5462
- * consumed watermark (flushed there at its turn's end, or stored while it
5463
- * was idle) and not heard at a tool boundary, and each one still queued
5464
- * for it, pending or un-acked. One with an entry still in the durable
5465
- * queue goes on only as that entry, under its own id and seq, so a crash
5466
- * before the ack below replays it once; a copy of it in the window decides
5467
- * only whether the agent read it. Writes still queued would wait for a
5468
- * boundary it never reaches, and a flush that finds it gone would drop all
5469
- * but the notices it passes on, so they land in its own window now, which
5470
- * Chronicle keeps for investigation. One whose earlier write may have
5471
- * landed (`landing` unknown) is looked up there by its id first, or, where
5472
- * the store can't be searched, in the window's own read: found, it isn't
5473
- * stored again; where neither can see the store, it's stored anyway, with
5474
- * a line saying it may now be stored twice, or, where storing it fails
5475
- * too, that it may be stored once, twice or not at all. Its stream is over
5476
- * or cancelled, or, when stop() ends it, may still run past its cancel, and
5477
- * then drops each event that comes after the agent has left (driveStream);
5478
- * a turn of its still assembling or compiling, as when stop() ends it,
5479
- * drops before it sends anything. One path still stores after these
5480
- * writes: a `complete` that arrived while the agent still waited for tools
5481
- * awaits the spill of its last tool results, and stores them once that
5482
- * resolves, even if a watchdog has ended the run meanwhile. A tool boundary
6541
+ * passNoticeToPrimary): each one stored in its store for it, not for its
6542
+ * parent or a co-resident whose record it shares, and not covered by its
6543
+ * consumed watermark (releasedWindow): presented at its turn's end and
6544
+ * never consumed, stored while it was idle, or never presented. A message
6545
+ * a tool boundary injected is covered once its stream says it carried it.
6546
+ * Its stream is over or cancelled, or, when stop() ends it, may still run
6547
+ * past its cancel, and then drops each event that comes after the agent
6548
+ * has left (driveStream); a turn of its still assembling or compiling, as
6549
+ * when stop() ends it, drops before it sends anything. One path can still
6550
+ * store after the release: a `complete` that arrived while the agent
6551
+ * still waited for tools awaits the spill of its last tool results, and
6552
+ * stores them once that resolves unless the agent's state was replaced
6553
+ * meanwhile, as a run's disposal by its watchdog or its caller replaces it,
6554
+ * or stop() or a quiesce's abandon cancelled its stream
6555
+ * (roundStoppedDuringBuild): then it stores nothing, as a tool boundary
5483
6556
  * stores nothing for a round whose turn was stopped while its results were
5484
- * prepared.
6557
+ * prepared. The agent's store stays in Chronicle for investigation.
5485
6558
  */
5486
6559
  private releaseWindow;
5487
6560
  /**
5488
- * The part of a released agent's pass to the primary that its release and
5489
- * stop() share (stop() runs it for a release the quiesce postponed). Each
5490
- * notice stored in its window that it never read and the primary takes in
5491
- * its place (passesToPrimary: a failed reply, a channel notice its reader
5492
- * could act on, or a module's write for a run or a fork, which goes as
5493
- * the write itself) goes on as stored, by name (passNoticeToPrimary),
5494
- * except a copy of an entry for it still in the durable queue, pending or
5495
- * un-acked: that entry is the notice's one identity until its ack, the one
5496
- * boot's check for landed writes knows, so it's the entry that goes on, as
5497
- * the primary's by-name notice under its own id and seq (`passOn`,
5498
- * queuedNoticeForPrimary), and a crash before the ack replays it once, not
5499
- * twice. A queued notice goes on unless the agent read a copy of it that
5500
- * landed in its window; where the window can't be read, it goes on, since
5501
- * telling the primary of a notice the agent may have read costs less than
5502
- * telling no one. Both callers run this before their drain, which hands
5503
- * pending entries to the un-acked set, so the un-acked entries for the
5504
- * agent here have all landed (their write went through, or a lookup found
5505
- * it: settleFound), and they go on here; the pending ones are the
5506
- * caller's. Returns the window's read, `passOn`, what it has queued so far
5507
- * for the primary, and how many un-acked entries the agent had.
5508
- */
5509
- private passOnFromReleasedWindow;
5510
- /**
5511
- * What a released agent's window holds that its pass to the primary reads
5512
- * (passOnFromReleasedWindow): `unread`, the notices stored there that it
5513
- * never read and the primary takes in its place (passesToPrimary: its
6561
+ * What a released agent's window holds that its release passes to the
6562
+ * primary (releaseWindow): `unread`, the notices stored there for it that
6563
+ * it never read and the primary takes in its place (passesToPrimary: its
5514
6564
  * failed replies, the channel notices it was told it could act on, and a
5515
6565
  * run's or a fork's module writes), each with its participant and
5516
6566
  * content, a sharded body's shards joined into one text, as the
5517
- * autobiographical strategy joins them (asCompiled), other than
5518
- * copies of the entries `held` names; and `held`, for each of
5519
- * those entries with a copy there, its copies and whether any of them is
5520
- * unread. A notice is read below the lower of its consumed watermark and
5521
- * the point where the watermark's branch and the current one part
5522
- * (branchesPartAt), and unread everywhere when it has no watermark. The
5523
- * watermark is set when the agent is created, and moves at a compile, and
5524
- * at a tool boundary whose stream declares it carries the messages
6567
+ * autobiographical strategy joins them (asCompiled). A notice is for it
6568
+ * when the audience rule doesn't put it elsewhere (bearingOf, with the
6569
+ * facts the registry recorded for it when its release was asked for:
6570
+ * releasedReaders): its own row, a row whose audience names it, or a row
6571
+ * with no stamp stored after a shared fork's derivation point. Its store
6572
+ * may be a record it shares: a shared fork reads its parent's slot on a
6573
+ * branch of its own, and a resident reads the slot every resident
6574
+ * writes. A notice there for its parent or a co-resident never entered
6575
+ * its window, and is that agent's to read, or to pass on at its own
6576
+ * release: passed on here, it would reach the primary again at each such
6577
+ * release, in this agent's name. A notice for it is read
6578
+ * when the agent's consumed watermark covers it (covers): once its context
6579
+ * presents rows (#291), when it was in the agent's window as of the mark,
6580
+ * so a notice never presented to it, or presented and never consumed, is
6581
+ * unread; for an agent whose window isn't presented, when it is at or
6582
+ * below the mark, or, for a mark on another branch, at or below the lower
6583
+ * of the mark and the point where the two branches part (branchesPartAt).
6584
+ * A mark taken in presented mode can't say on another branch, and there,
6585
+ * as everywhere for an agent with no watermark, every notice is unread.
6586
+ * The watermark is set when the agent is created, and moves at a compile,
6587
+ * and at a tool boundary whose stream declares it carries the messages
5525
6588
  * injected there (markContextConsumed). So a notice such a stream carried
5526
- * is under it. One a boundary stored without sending (a turn a tool ended,
5527
- * a budget restart, the direct API's boundary, which has no stream) is
5528
- * above it until a compile sends it, and counts as unread. null when the
5529
- * window can't be read, which is logged.
6589
+ * is under it. One a boundary presented without sending (a turn a tool
6590
+ * ended, a budget restart, the direct API's boundary, which has no stream)
6591
+ * is above it until a compile sends it, and counts as unread. null when
6592
+ * the window can't be read, which is logged.
5530
6593
  */
5531
6594
  private releasedWindow;
5532
6595
  /**
@@ -5540,15 +6603,16 @@ export declare class AgentFramework {
5540
6603
  private branchesPartAt;
5541
6604
  /**
5542
6605
  * Release a deregistered fork's or run's window (releaseWindow) now, or,
5543
- * while the host is quiesced, when it resumes. A release lands the agent's
5544
- * queued writes in its window, and while quiesced a write could land
5545
- * mid-surgery; dropping them instead would lose them from both the window
5546
- * and the recovery queue. Only the window waits: the agent is already
5547
- * deregistered, so its stream can't dispatch anything more and resume
5548
- * doesn't weigh its context, and a write addressed to it meanwhile is
5549
- * treated as for any agent no longer registered (dropped, or passed to the
5550
- * primary if it's a failed reply, a channel notice its reader could act
5551
- * on, or a module's write for a run or a fork: passesToPrimary).
6606
+ * while the host is quiesced, when it resumes: what the release passes to
6607
+ * the primary is judged on the window as the quiesce leaves it. Only the
6608
+ * window waits: the agent is already deregistered, so its stream can't
6609
+ * dispatch anything more and resume doesn't weigh its context, and a
6610
+ * write addressed to it meanwhile is treated as for any agent no longer
6611
+ * registered (dropped, or passed to the primary if it's a failed reply, a
6612
+ * channel notice its reader could act on, or a module's write for a run or
6613
+ * a fork: passesToPrimary). The writes kept in memory for it, while its
6614
+ * context manager refused its work or by a surgery's hold still up, which
6615
+ * no window holds, are judged so at once.
5552
6616
  */
5553
6617
  private releaseWindowNowOrAfterResume;
5554
6618
  /** resume(): the windows whose release the quiesce window postponed, each on its own. */
@@ -5557,28 +6621,27 @@ export declare class AgentFramework {
5557
6621
  * A fork or an ephemeral run ended before reading a notice the primary
5558
6622
  * takes in its place (passesToPrimary): it was released with the notice
5559
6623
  * stored in its window unread, or, for a failed reply, its delivery failed
5560
- * after release. (A notice still queued for it, at release or restored at
5561
- * boot, goes on as the queue entry itself: queuedNoticeForPrimary.) Tell
5562
- * the primary instead, naming the speaker, so an agent who can still act
5563
- * learns of it (noticeForPrimary). Never throws: it runs inside a release,
5564
- * which must complete whatever this write meets.
6624
+ * after release. (One an earlier release left queued for it goes on at
6625
+ * boot, under the queued write's own id: importPersistedDeferredWrites.)
6626
+ * Tell the primary instead, naming the speaker, so an agent who can still act
6627
+ * learns of it (noticeForPrimary). The notice is the primary's alone
6628
+ * (#291's audience stamp): a co-resident sharing the primary's slot isn't
6629
+ * the agent who takes the speaker's place. On a host with no primary it
6630
+ * goes where a write that names no agent goes, stamped as one. A failed
6631
+ * write is logged and returned, not thrown: it runs inside a release,
6632
+ * which must complete whatever this write meets. Building the notice isn't
6633
+ * guarded, so a throw there, as a store read for a channel notice's words
6634
+ * can make at boot, reaches the caller. Whether the primary was told:
6635
+ * `declined` when no one is, `failed` when the write failed, each logged;
6636
+ * `held` when the write was kept in memory, not stored (a surgery's hold,
6637
+ * or the receiving agent's manager refusing its work), which stores it at
6638
+ * the hold's release, and loses it to a stop or a crash before then: the
6639
+ * empty id addMessage answers for a write it keeps, and, for a write that
6640
+ * names no agent, as this one, for nothing else. `passedOn`, the record
6641
+ * and row a boot passes on (passOnInterruptedNotices), is stamped on the
6642
+ * notice, so a later boot finds it passed.
5565
6643
  */
5566
6644
  private passNoticeToPrimary;
5567
- /**
5568
- * A queued entry for `speaker`, who is gone, that the primary takes in its
5569
- * place, as the primary's by-name notice (noticeForPrimary): the same
5570
- * entry, under its own id and seq, now addressed to the primary. Written
5571
- * through the drain, it lands stamped with that id, or waits in the queue
5572
- * under it, so boot's exactly-once holds for it: a crash before the
5573
- * original's ack replays one entry, never the original and a separate
5574
- * notice. An entry marked as one whose earlier write may have landed
5575
- * (`landing`) keeps the mark, so before it's written it's looked up by its
5576
- * id in the primary's window, where it would land now
5577
- * (writeDrainedInOrder). A release has looked in the speaker's own window
5578
- * first (releaseWindow). null when no one is told (logged where it's
5579
- * decided).
5580
- */
5581
- private queuedNoticeForPrimary;
5582
6645
  /**
5583
6646
  * The primary's by-name notice in place of one `speaker` never read, and
5584
6647
  * what it's about, as a log line says it: a failed reply's
@@ -5634,111 +6697,84 @@ export declare class AgentFramework {
5634
6697
  private labelledChannel;
5635
6698
  /**
5636
6699
  * A module's write through its context (ModuleContext.addMessage):
5637
- * addMessage's, except that a write the framework holds is answered by its
5638
- * handle (heldHandle) rather than '', so the module can find, read, edit
5639
- * and remove what it wrote before the write lands, through getMessage,
5640
- * editMessage and removeMessage, which read the delivery agent's window: a
5641
- * handle for a write held for a fork or a sub-agent isn't found there. The
5642
- * framework's own callers keep the '' they've always had, which their
5643
- * traces and checks take as a write not stored yet.
6700
+ * addMessage's. The write is stored at once whatever its agent's turn
6701
+ * (#291), and its stored id returned; it enters the agent's window at the
6702
+ * agent's next presentation point, or at once while no turn of it is
6703
+ * alive. Only while the write is kept in memory is the id '': a
6704
+ * surgery's hold keeps it until its release stores it, and an agent whose
6705
+ * context manager refuses its work after a failed re-initialization has
6706
+ * it kept until a move re-initializes the agent and its release stores
6707
+ * it (heldForRecovery). A write whose store throws where context-manager
6708
+ * can't tell what of it landed throws its WriteOutcomeUnknownError, the
6709
+ * rows it names presented (addMessage): the write may be stored, and isn't
6710
+ * answered as stored.
5644
6711
  *
5645
6712
  * With `forAgent`, the write is for the named agent's window, which must
5646
6713
  * be registered when the write is made: a name that isn't, or the empty
5647
6714
  * one, which addMessage would read as none (deliveryAgent), throws, naming
5648
6715
  * the registered ones, as queryMessages does. The framework's own writes
5649
- * log and drop instead, as a held write does whose agent is gone by its
5650
- * flush. A write for an ephemeral run or a conversation fork, whose
5651
- * window nothing reads after its release, is marked (PRIMARY_IF_UNREAD_KEY),
5652
- * so the release passes it to the primary if its target never read it,
5653
- * as it passes a notice (passOnFromReleasedWindow).
6716
+ * log and drop instead. A write for an ephemeral run or a conversation
6717
+ * fork, whose window nothing reads after its release, is marked
6718
+ * (PRIMARY_IF_UNREAD_KEY), so the release passes it to the primary if its
6719
+ * target never read it, as it passes a notice (releaseWindow). A write
6720
+ * that names no agent is stamped for the agents that take untargeted
6721
+ * inbound in the slot it lands in (untargetedAudience, #291); one with
6722
+ * `forAgent` for that agent.
5654
6723
  */
5655
6724
  private addModuleMessage;
5656
- /**
5657
- * The writes the framework holds for the store `reader` reads, in queue
5658
- * order: those addressed to it and, when it's an ordinary resident, those
5659
- * addressed to any ordinary resident, since residents share one message
5660
- * slot (`readsSharedSlot` in the registry). A write whose target is gone isn't among them:
5661
- * no module reads that agent's store, and the write waits for its window's
5662
- * release (drainDeferredFor) or, at its flush, is dropped (addMessage), a
5663
- * failed reply, or a channel notice its reader could act on, passing to the
5664
- * primary as its notice, and a module's write for a run as written
5665
- * (passesToPrimary, queuedNoticeForPrimary).
5666
- */
5667
- private heldWritesFor;
5668
- /**
5669
- * The writes held for `reader`'s store (heldWritesFor) as the rows a
5670
- * module's context reads: each under its handle, marked `held`, and
5671
- * `heldFromResidents` too when its metadata carries a tune-out's stamp
5672
- * (asModuleRow), with the participant, content and metadata it was
5673
- * written with, the time it was first held as its timestamp, and a
5674
- * sequence after every row the store holds, in queue order. The sequence
5675
- * and timestamp are provisional: the stored row has the store's own.
5676
- */
5677
- private heldRows;
5678
- /** The row a held write landed as, found by the id it's stored with
5679
- * (`metadata.deferredWriteId`): the first, for a body stored in shards,
5680
- * as addMessage answers a stored write. Null when it hasn't landed, or is
5681
- * no longer in the store. */
6725
+ /** The row a write an earlier release held landed as, found by the id
6726
+ * it's stored with (`metadata.deferredWriteId`): the first, for a body
6727
+ * stored in shards, as addMessage answers a stored write. Null when it
6728
+ * hasn't landed, or is no longer in the store. A module that kept the
6729
+ * `held:` handle such a release gave it reaches the row through it, for
6730
+ * one release (heldWriteId). */
5682
6731
  private landedRow;
5683
6732
  /**
5684
- * Settle held writes whose landing is unknown (DeferredWrite.landing),
5685
- * among those `which` picks, before a path reads or changes held writes:
5686
- * each is looked up by its id in its target's store (landedCopiesById).
5687
- * Found, the write landed (settleFound), where its copy sits, a known
5688
- * limit (writeDrainedInOrder). Not found, the mark goes, and it's an
5689
- * ordinary held write, which is persisted as an edit is. Where the store
5690
- * can't be searched, it stays marked, a doubt each path reads by its own
5691
- * rule.
5692
- */
5693
- private settleUnknownLandings;
5694
- /**
5695
- * A marked held write found to have landed, as `stored`: it leaves the
5696
- * pending queue for the un-acked set, as a drained write does, so it stays
5697
- * in the durable queue until the next ack has synced the store that holds
5698
- * it, and it's a stored write from then on, so the paths for a landed
5699
- * write apply to it. It takes the notes a store takes (noteStored), which
5700
- * its first write missed when it threw, as a flush that finds such a write
5701
- * takes them (readdDrained), and is logged by its id. It isn't carried
5702
- * into a turn, as a flush that finds it carries it: the agent reads it at
5703
- * its next compile, where the store holds it.
5704
- */
5705
- private settleFound;
5706
- /**
5707
- * A stored row a module names by its id: where it carries the
5708
- * deferredWriteId of a marked held write the reader's store holds, it's
5709
- * that write's copy, so the write landed, and it's settled as found
5710
- * (settleFound) before the row is read or changed. A lookup by the id
5711
- * can't be needed then, so this holds where the store can't be searched
5712
- * too. One row of a sharded body says it's a shard, without a count,
5713
- * since one row doesn't tell how many landed.
5714
- */
5715
- private settleByCopy;
5716
- /** A held write whose landing stays unknown after settling, its store
5717
- * unsearchable, can't be edited or removed: it may already be stored, and
5718
- * changing only the queued entry could leave its stored copy as it was.
5719
- * Throws with nothing changed. */
5720
- private refuseUnsettled;
5721
- /** Whether a wake for a deferred write has nothing left for the agent to
5722
- * do, on evidence only. The write's row is at or below the newest
6733
+ * Whether a wake for a row it reads (InferenceRequest.readsRow) has
6734
+ * nothing left for the agent to do, on evidence only. The row is done once
6735
+ * it is gone from the agent's store on its current branch
6736
+ * (removed, or left on a branch the agent has switched from, where a turn
6737
+ * now would find nothing of it), or once an answered request's consumed
6738
+ * watermark covers it and the agent has spoken where the wake asks
6739
+ * (answeredCovers). A row stored and not yet presented to the agent isn't
6740
+ * covered, so its wake stays: its turn presents the row. Any doubt keeps
6741
+ * the wake, such as a store that can't be read.
6742
+ */
6743
+ private rowDone;
6744
+ /** Whether a request the agent had answered carried `row`: the newest
5723
6745
  * consumed watermark of an answered request (Agent.getAnsweredWatermark)
5724
- * on the agent's current branch, and for a wake that carries a channel
5725
- * and wasn't marked ambient (`to`, that channel on the wake's server), the
5726
- * agent has since published there having read the row
5727
- * (Agent.publishedAfterReading): hearing a message isn't answering it,
5728
- * and the wake's turn is the agent's chance to answer there. Or the
5729
- * write is in neither the queue (drained entries not yet stored
5730
- * included) nor the store's current branch: removed, or left on a
5731
- * branch the agent has switched from, where a turn now would find
5732
- * nothing of it (switching back brings it back unread, with no wake, as
5733
- * main's wake spent on this branch leaves it). Any doubt keeps the
5734
- * wake, such as a watermark that a branch switch or an undo left on
5735
- * another branch, or a store that can't be read: a turn that finds
5736
- * nothing new costs less than a write no wake brings the agent to read
5737
- * or answer. */
5738
- private deferredWriteDone;
5739
- private storedMessageDone;
5740
- private writeAnswered;
5741
- private readsWriteFor;
6746
+ * covers it, read in the agent's context (covers), and, for a wake that
6747
+ * carries a channel and wasn't marked ambient (`to`, that channel on the
6748
+ * wake's server), the agent has since published there having read the
6749
+ * row (Agent.publishedAfterReading): hearing a message isn't answering
6750
+ * it, and the wake's turn is the agent's chance to answer there. A mark
6751
+ * that can't say (none, or one a branch switch or an undo left on another
6752
+ * branch) says no. */
6753
+ private answeredCovers;
6754
+ /**
6755
+ * The mark a wake for `agentName` takes for the row it was queued with
6756
+ * (`placement`, addMessage's out-param), so the scheduler can drop the
6757
+ * wake once the row needs nothing more of the agent (rowDone): the row's
6758
+ * stored id, for every row stored for that agent, whether it was
6759
+ * presented to the agent at its write or not (`presented: false`, set
6760
+ * where the agent's turn was alive). #291 first marked only a row kept
6761
+ * out of a live turn's window; #814 marks a message stored as it arrived
6762
+ * too, and this carries that. The wider mark drops no wake wrongly:
6763
+ * rowDone drops one only once an answered request's mark covers the row,
6764
+ * by its place in the agent's window (covers), so a request that never
6765
+ * carried the row keeps its wake. A resumed turn (a context-budget
6766
+ * restart, or a tool-result guard's retry a provider held) presents
6767
+ * nothing that arrived meanwhile (the presentation's afterStore counts
6768
+ * its turn alive), so its request doesn't carry such a row, and the row's
6769
+ * wake still starts a turn after it. Another agent's wake stays plain, and
6770
+ * so does one for a write kept in memory (a surgery's hold, or
6771
+ * heldForRecovery), which has no id yet.
6772
+ */
6773
+ private readsRowFor;
6774
+ /** A module's id as the store knows it: a stored id as it is, and an
6775
+ * earlier release's `held:` handle as the row its write landed as, or
6776
+ * the handle itself, which the store doesn't hold, when it never landed. */
6777
+ private storedIdOf;
5742
6778
  private editMessage;
5743
6779
  private removeMessage;
5744
6780
  private getMessage;
@@ -5749,10 +6785,38 @@ export declare class AgentFramework {
5749
6785
  * so. */
5750
6786
  private unknownAgentError;
5751
6787
  /** A module's query (ModuleContext.queryMessages): the delivery agent's
5752
- * window (the primary's, or the first agent's when none is primary), or
6788
+ * store (the primary's, or the first agent's when none is primary), or
5753
6789
  * the named agent's, which must be registered: an unknown name, or the
5754
- * empty one, throws, naming the registered ones, as a write's does. */
6790
+ * empty one, throws, naming the registered ones, as a write's does. The
6791
+ * rows come in store order, each marked `held` where it isn't in that
6792
+ * agent's window (#291: stored and not yet presented to it, or taken out
6793
+ * of it as an undone turn's), and the count is the store's. */
5755
6794
  private queryMessages;
6795
+ /** A module's window lookup (ModuleContext.windowStatusOf, #291): where
6796
+ * a row stands with the delivery agent's window, or the named agent's,
6797
+ * which must be registered, as for a query: an unknown name, or the
6798
+ * empty one, throws, naming the registered ones. */
6799
+ private windowStatusFor;
6800
+ /** Whether `observer` reads `observed`'s own rows through an observe edge
6801
+ * (ModuleContext.observes, #291), as the presentation index reads its
6802
+ * edges (observesOwnRows). */
6803
+ private observesOwnRowsOf;
6804
+ /**
6805
+ * A module's view lookup (ModuleContext.viewKeeps, #291): whether the
6806
+ * delivery agent's view, or the named agent's, which must be registered,
6807
+ * as for windowStatusFor, keeps a row, so its requests carry it, as its
6808
+ * strategy renders it (a row it has folded, as that summary), while its
6809
+ * window holds it. The view is the one its context was opened with, as
6810
+ * recorded for it (agentSees, main's #853: liveViewFilterOf's choice,
6811
+ * through the agent a shared derivation's view came from): a resident's
6812
+ * leaves out held traffic, the other agents' stored context injections
6813
+ * and what a suppress rule hid, the subconscious's those injections and
6814
+ * suppressed rows, and an agent opened with no view keeps every row. An agent the registry has no
6815
+ * record of is read through a resident's view, the one that keeps least.
6816
+ */
6817
+ private viewKeepsFor;
6818
+ /** The live agent whose context a context manager is (ModuleContext.agentNameOf, #291), or undefined. */
6819
+ private agentNameOfContext;
5756
6820
  private createFrameworkState;
5757
6821
  private emitTrace;
5758
6822
  /**
@@ -5795,7 +6859,8 @@ export declare class AgentFramework {
5795
6859
  private logFailure;
5796
6860
  /**
5797
6861
  * Ops alert — the one escalation path for "a human should hear about this":
5798
- * (1) durable failures.log record (unless the caller already wrote one),
6862
+ * (1) durable failures.log record (unless the caller already wrote one, or
6863
+ * the alert keeps none, as a budget hold's open and clear don't),
5799
6864
  * (2) an `ops:alert` trace so authorized observers get it on the wire,
5800
6865
  * (3) if CONNECTOME_OPS_WEBHOOK is set, a Discord post throttled to one per
5801
6866
  * (agent, kind) per cooldown window — a persistent failure re-posts
@@ -5828,6 +6893,17 @@ export declare class AgentFramework {
5828
6893
  * `roundContent` to vouch for ends noting instead, as a round's does.
5829
6894
  */
5830
6895
  private noteStreamEnd;
6896
+ /**
6897
+ * A row an agent's window holds, by its id, from whichever slot its
6898
+ * manager merges: getMessage reads the manager's own slot alone, and the
6899
+ * subconscious hears the residents' rows at its tool boundary from the slot
6900
+ * it watches (#291). Null in legacy mode, where nothing is heard from
6901
+ * another slot, and for a row the window doesn't hold; null too where the
6902
+ * window can't be read, which is logged naming `agentName` and the row,
6903
+ * so a note that then records the row as not stored can be told from one
6904
+ * whose row is absent.
6905
+ */
6906
+ private windowRowOf;
5831
6907
  /**
5832
6908
  * Every row so far, judged as of now (roundRows), noted. A note the context manager writes nothing for (false)
5833
6909
  * ends the stream's notes, with a line saying so: where the stream's compile no longer wrote the branch's record, or
@@ -6391,8 +7467,9 @@ export declare class AgentFramework {
6391
7467
  closedTab: boolean;
6392
7468
  retrying: boolean;
6393
7469
  /** Which engine serves it: `legacy` (MCP 2024-11-05 + MCPL) or `modern`
6394
- * (MCP 2026-07-28), as its configuration selects; null when the
6395
- * configuration names no usable transport (see `refused`). */
7470
+ * (the SDK's client: MCP 2026-07-28, or over HTTP a 2025 revision), as
7471
+ * its configuration selects; null when the configuration names no
7472
+ * usable transport (see `refused`). */
6396
7473
  family: 'legacy' | 'modern' | null;
6397
7474
  /** The MCP revision its last handshake established; null until one has. */
6398
7475
  protocolVersion: string | null;
@@ -6475,10 +7552,7 @@ export declare class AgentFramework {
6475
7552
  * every other wake.
6476
7553
  */
6477
7554
  private wireModernEvents;
6478
- /** An MCP tool call's trace: a result the server marked an error (or one
6479
- * the reading takes as one, such as malformed content) is tool:failed, as
6480
- * on the other tool paths; anything else is tool:completed. */
6481
- private traceMcpToolOutcome;
7555
+ private traceToolOutcome;
6482
7556
  /**
6483
7557
  * Discover tools from all connected MCPL servers and cache them.
6484
7558
  * Tools are namespaced as `{toolPrefix}--{toolName}` per server config.
@@ -6565,6 +7639,35 @@ export declare class AgentFramework {
6565
7639
  * and what's nested in them at any depth (shownToScriptFromServer).
6566
7640
  */
6567
7641
  private mcpToolResult;
7642
+ /** Whether any tune-out is on record: a channel's, or the all-except scope. */
7643
+ private tuneOutOnRecord;
7644
+ /** The tune-out coordinator over this framework's channels, with the hooks it acts through. */
7645
+ private makeTuneOutCoordinator;
7646
+ /**
7647
+ * Whether a tune-out's release would be kept in memory now, not stored:
7648
+ * a release made while a surgery's hold keeps writes in memory, or while
7649
+ * the primary's or the subconscious's manager refuses its work, would be
7650
+ * kept there too, and lost to a crash before it is stored, while the
7651
+ * epoch's end is on disk at once. The coordinator's cancel waits for them
7652
+ * then (its writesHeld; releaseSurgeryHeldWrites runs it), and so does a
7653
+ * release of the holds on record with no reader
7654
+ * (releaseTuneOutsWithoutReader). With `forAgent` (a loss notice's
7655
+ * author), whether a write for that agent would be kept: a surgery's hold
7656
+ * or its replay, or that agent's own manager refusing its work or waiting
7657
+ * for its recovery; not the primary's or the subconscious's, which hold
7658
+ * their own agent's writes alone.
7659
+ */
7660
+ private tuneOutWritesHeld;
7661
+ /**
7662
+ * No reader is configured, so nothing can watch or end a hold: each hold
7663
+ * on record (one 0.32's `tuneOut.enabled` left, or one whose reader the
7664
+ * recipe no longer has) ends now, and its backlog goes to the resident,
7665
+ * the per-channel holds and the all-except scope alike, through a
7666
+ * coordinator made for that alone: at a start, or, where no MCPL server
7667
+ * was configured, when the first one connects. One whose release fails
7668
+ * stays on record for the next start.
7669
+ */
7670
+ private releaseTuneOutsWithoutReader;
6568
7671
  /**
6569
7672
  * A tune-out on record where this host has no tune-out coordinator: a
6570
7673
  * start with no subconscious makes none, and neither does a channel
@@ -6576,8 +7679,10 @@ export declare class AgentFramework {
6576
7679
  * open again as a cancel leaves it, under the tune-out's own source, so an
6577
7680
  * agent's tune-out keeps the agent's provenance (the housekeeping guard
6578
7681
  * reads it). A log line names the channel and says how many of the
6579
- * messages it diverted are held here, stored or still queued to be
6580
- * written, which nothing will now deliver as its backlog.
7682
+ * messages it diverted are stored here, which nothing will now deliver as
7683
+ * its backlog. Where no reader is configured, releaseTuneOutsWithoutReader
7684
+ * ends them instead, backlog delivered; this is only the late-connect path
7685
+ * of a host that has a reader.
6581
7686
  */
6582
7687
  private endTuneOutsWithoutCoordinator;
6583
7688
  /**
@@ -6587,6 +7692,15 @@ export declare class AgentFramework {
6587
7692
  * Dispatch a synthesized channel tool call.
6588
7693
  */
6589
7694
  private dispatchChannelToolCall;
7695
+ /**
7696
+ * `wake_accept_suggestions` / `wake_decline`: the agent's answer to a wake
7697
+ * onboarding offer. Accepting writes the chosen suggestions as
7698
+ * `suggested:<server>:<n>` rules (replacing any it accepted before) ahead of
7699
+ * the first catch-all; declining removes them. Either way the decision is
7700
+ * recorded against the server's declared ontology, so it isn't asked again
7701
+ * until that changes. Throws only what the gate throws on a write.
7702
+ */
7703
+ private answerWakeOnboarding;
6590
7704
  /**
6591
7705
  * Handle the synthesized `wake_add_rule` / `wake_remove_rule` tools: mutate
6592
7706
  * the hot-reloaded gate.json at runtime. Validation lives in the EventGate
@@ -6635,7 +7749,103 @@ export declare class AgentFramework {
6635
7749
  * framework's policy inputs (recipients, the hold in force, the wake
6636
7750
  * gate), traced. Callers apply it; nothing downstream re-asks.
6637
7751
  */
7752
+ /**
7753
+ * The suppressed rows stored in an agent's message slot (the primary's when
7754
+ * none is named), oldest first, whole: what dump_suppressed writes and the
7755
+ * suppression review reads, for a host to read too. Within `sinceMs` (at or
7756
+ * after) and `untilMs` (before), and of `rule`, when given. The slot is read
7757
+ * on the branch it's on; a write a surgery's hold, or the wait for its
7758
+ * agent's recovery, keeps in memory isn't in it until it is stored.
7759
+ */
7760
+ suppressedEvents(agentName?: string, opts?: {
7761
+ rule?: string;
7762
+ sinceMs?: number;
7763
+ untilMs?: number;
7764
+ }): SuppressedEventRecord[];
7765
+ /** Run the suppression review now, as its timer would: null when none is wired or one isn't run now (SuppressionReview.runOnce). */
7766
+ reviewSuppression(): Promise<SuppressionReviewSummary | null>;
7767
+ /** The suppress rules in force, as the suppression review knows them. */
7768
+ private suppressRulesInForce;
7769
+ /**
7770
+ * Tell the agent what the suppression review found: a notice of the
7771
+ * framework's own (never suppressed, as it's no event), and a wake when the
7772
+ * review flagged something. Throws when the notice can't be written, so the
7773
+ * review covers its period again next time.
7774
+ */
7775
+ private deliverSuppressionReview;
7776
+ /**
7777
+ * Whether `agent`'s view leaves suppressed rows out, asked of the view
7778
+ * itself (storeSees): every resident's, the subconscious's and a view
7779
+ * derived from one does. An isolated agent's own view excludes legacy
7780
+ * reasoning-loss notices, not suppressed rows, so a suppressed row stamped
7781
+ * there would render.
7782
+ */
7783
+ private viewHidesSuppressed;
7784
+ /**
7785
+ * The suppress rule that takes an event a lane is about to write with
7786
+ * addMessage, or null (EventGate.decideSuppression: asked once per event,
7787
+ * since a windowed rule opens its window for an event it lets by). Null
7788
+ * with no gate, and where the write would land in a view that doesn't hide
7789
+ * suppressed rows (viewHidesSuppressed), since the stamp would hide
7790
+ * nothing there.
7791
+ */
7792
+ private suppressionFor;
7793
+ /**
7794
+ * Count a write a suppress rule took, once addMessage has taken it (stored,
7795
+ * or kept in memory by a surgery's hold) (EventGate.noteSuppressed), and tell the review
7796
+ * the rule's description as it stands now, so the rows are judged against
7797
+ * it even when the rule is gone by the next review.
7798
+ */
7799
+ private noteSuppressedWrite;
6638
7800
  private admitInbound;
7801
+ /**
7802
+ * Wake onboarding, after an inbound event is stored: if the gate let it go
7803
+ * by without anyone having decided about its server (gate/wake-onboarding.ts
7804
+ * isUndecided), and the agent hasn't been offered or answered for this
7805
+ * server's declared ontology, offer the server's suggestions once — a notice
7806
+ * after the event, and a wake when the event is addressed to the agent or
7807
+ * waiting on it (ATTENTION_TAGS); otherwise the notice waits for the next
7808
+ * turn. Never throws: onboarding is advice, and an event's delivery must not
7809
+ * depend on it.
7810
+ *
7811
+ * The notice is for the agents the event was delivered to (#291's audience
7812
+ * stamp): the event's recipients, as its row's stamp names them
7813
+ * (inboundAudience), so it reads as following "the one above" only where
7814
+ * that one is, and a co-resident the event wasn't for is neither shown it
7815
+ * nor woken by it. It is stored where a write that names no agent is for
7816
+ * those of them that read that slot (readersNamed), stamped for them; a
7817
+ * recipient that doesn't read it (a conversation fork, on its own slot)
7818
+ * gets its own copy where it reads (`forAgent`), stamped for it, so a
7819
+ * recipient is woken to a notice it is shown and no one else is shown it
7820
+ * but an agent observing that slot (the persistent subconscious).
7821
+ * Mixed recipients get it in both places, once each. An event with no
7822
+ * recipients is for the residents that take untargeted messages, as
7823
+ * before. It goes through addMessage, which stores it at once and
7824
+ * presents it to each of them at rest or at their next point, as it does
7825
+ * the event. The wake of the agent its write's placement names reads the
7826
+ * row (readsRowFor): the delivery agent, or, where the stamp doesn't name
7827
+ * it, a recipient whose own slot that is (placementReaders); and so does
7828
+ * a fork's for its own copy. A co-resident's wake beside the delivery
7829
+ * agent stays plain, as the event's own does.
7830
+ */
7831
+ private considerWakeOnboarding;
7832
+ /** The last offer built per server, kept while its enabled declarations are the same objects. */
7833
+ private wakeOfferCache;
7834
+ /**
7835
+ * A server's offer from the feature sets this host enabled for it (events
7836
+ * of the others never arrive, and their ontology isn't the question).
7837
+ */
7838
+ private wakeOffer;
7839
+ /** The onboarding notice: what happened, what the server suggests, how to answer. Server-written text is quoted. */
7840
+ private wakeOnboardingText;
7841
+ private describeOfferedRule;
7842
+ /**
7843
+ * Make delivered messages durable now, and answer whether they are: a
7844
+ * tune-out's cancel stores its release and syncs it before it records the
7845
+ * epoch's end (#232 gap 6), and a sync that fails answers false, so the
7846
+ * cancel leaves the tune-out in force for its next try. A dump a surgery's
7847
+ * hold keeps is in memory until the hold's release.
7848
+ */
6639
7849
  private commitDeliveries;
6640
7850
  /** The history-reading tool the primary resident actually has, if any (#232 gap 11). */
6641
7851
  private residentHistoryTool;
@@ -6688,11 +7898,23 @@ export declare class AgentFramework {
6688
7898
  private buildEventTagsResult;
6689
7899
  private dispatchEventTagsToolCall;
6690
7900
  private dispatchGateToolCall;
7901
+ /**
7902
+ * suppression_stats: what the suppress rules have hidden, counted over the
7903
+ * rows stored in the caller's message slot (the residents' shared one, for
7904
+ * a resident), on the branch it's on. Every suppress rule in force is
7905
+ * listed, with what it suppressed since start (the gate's matchCount).
7906
+ */
7907
+ private dispatchSuppressionStatsToolCall;
7908
+ /**
7909
+ * dump_suppressed: the suppressed rows in the caller's message slot
7910
+ * (suppressedEvents), whole, written to a workspace file as the caller's own
7911
+ * write.
7912
+ */
7913
+ private dispatchDumpSuppressedToolCall;
6691
7914
  /** The channel context one server is told for an agent's inference
6692
7915
  * (context/beforeInference, §14.4): only that server's own channels
6693
7916
  * (ChannelRegistry.buildChannelContext). */
6694
7917
  private channelsForServer;
6695
7918
  private buildBeforeInferenceParams;
6696
7919
  }
6697
- export {};
6698
7920
  //# sourceMappingURL=framework.d.ts.map