@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
@@ -16,6 +16,57 @@ import type { AgentConfig, ToolDefinition } from '../types/index.js';
16
16
  export declare const SUBCONSCIOUS_TOOL_NAMES: readonly ['deliver_summary', 'cancel_tuneout', 'note_disposition', 'speak_in_channel'];
17
17
  export type SubconsciousToolName = (typeof SUBCONSCIOUS_TOOL_NAMES)[number];
18
18
  export declare const SUBCONSCIOUS_TOOLS: ToolDefinition[];
19
+ /**
20
+ * Who reads a tuned-out channel's traffic, as the text a resident reads
21
+ * says it: the persistent subconscious by the name it runs under, or reader
22
+ * forks. There is no hold without a reader (0.33.0) but one whose release
23
+ * failed after the persistent reader ended, or at a start with none
24
+ * configured: none runs then (`running: false`), the reader named as
25
+ * configured, or by its default name, for tune_out's own text, and what a
26
+ * held channel's messages are says that none reads them (tuneOutHeldWords,
27
+ * tunedOutTrafficWords). A persistent reader's name is a value the host
28
+ * supplied, marked as such (suppliedValue).
29
+ */
30
+ export type TuneOutReader = {
31
+ readonly kind: 'persistent';
32
+ readonly name: string;
33
+ readonly running?: false;
34
+ } | {
35
+ readonly kind: 'forks';
36
+ };
37
+ /**
38
+ * What a tuned-out channel's messages are, as the words after "its
39
+ * messages" in a refusal a resident reads (a channel tool's on a tuned-out
40
+ * channel): held from it and read by `reader`, by the name it runs under or
41
+ * as forks of the resident's context.
42
+ */
43
+ export declare function tuneOutHeldWords(reader: TuneOutReader): string;
44
+ /**
45
+ * What a tuned-out channel's traffic is, as the words after "its traffic"
46
+ * in the [tuned out] note to a send there: held from the resident and read
47
+ * by `reader` until the tune-out ends, or, where none runs, held until its
48
+ * release is tried again (TuneOutReader).
49
+ */
50
+ export declare function tunedOutTrafficWords(reader: TuneOutReader): string;
51
+ /**
52
+ * Whether a tuned-out channel's messages get to its reader, as the words
53
+ * after "its messages" in tune_out's answers about the channel's transport,
54
+ * in the sentence's `form`: they reach `reader`, by the name it runs under
55
+ * or as "the reader" (forks, as tuneOutTool says it). Where no reader runs,
56
+ * those answers aren't given: tuneOutNoReaderAnswer is, in their place.
57
+ */
58
+ export declare function tuneOutReachWords(reader: TuneOutReader, form: 'reach' | 'may not reach' | "don't reach"): string;
59
+ /**
60
+ * tune_out's answer about a tuned-out channel's transport where no reader
61
+ * runs (`running: false`, a hold left on record by a failed release): a
62
+ * sentence of its own, given alone in place of each answer that says
63
+ * whether the messages reach the reader and when (tuneOutReachWords), since
64
+ * opening the channel doesn't change that none reads them. Undefined where
65
+ * a reader runs. tune_out is refused with no reader, repeated for a channel
66
+ * already tuned out too, so this answers a tune_out whose reader ended
67
+ * while its channel's open was out.
68
+ */
69
+ export declare function tuneOutNoReaderAnswer(reader: TuneOutReader): string | undefined;
19
70
  /**
20
71
  * Configuration for the subconscious (FrameworkConfig.subconscious). Two
21
72
  * shapes, by `reader`:
@@ -60,12 +111,21 @@ interface SubconsciousConfigBase {
60
111
  * a reader none. */
61
112
  thinkingBinding?: AgentConfig['thinkingBinding'];
62
113
  }
114
+ /**
115
+ * The name a persistent reader runs under: its configuration's `name`, or,
116
+ * where the host gave none, `'Subconscious'` (PersistentReaderConfig.name).
117
+ * The one place the framework names a reader the host didn't: everything
118
+ * that needs the name of an unnamed reader asks this.
119
+ */
120
+ export declare function persistentReaderName(config: {
121
+ name?: string;
122
+ }): string;
63
123
  export interface PersistentReaderConfig extends SubconsciousConfigBase {
64
124
  reader?: 'persistent';
65
125
  /**
66
126
  * Registry + participant name. Default 'Subconscious' — following the
67
127
  * Context Manager precedent: a title-case functional voice, not an
68
- * agent-prefixed identifier.
128
+ * agent-prefixed identifier. persistentReaderName applies the default.
69
129
  */
70
130
  name?: string;
71
131
  /** Model id; defaults to the primary agent's (same-model side-process).
@@ -75,28 +135,52 @@ export interface PersistentReaderConfig extends SubconsciousConfigBase {
75
135
  * `thinkingBinding` set its own. */
76
136
  model?: string;
77
137
  /**
78
- * The voice/criteria mode block — recipe-side and co-authored with the
79
- * resident (it is an aspect of their attention). Report-shaped, second
80
- * person toward the resident. Canary before fleet use (issue #77).
138
+ * The persistent reader's system prompt (its AgentConfig.systemPrompt).
139
+ * Who writes it and what it says, a policy for the reader tools
140
+ * included, are the host's choice. Canary before fleet use (issue #77).
81
141
  */
82
142
  systemPrompt: string;
83
143
  /** WindowedPassthroughStrategy re-anchor fraction (default 0.5). */
84
144
  reAnchorFraction?: number;
145
+ /**
146
+ * How a resident's rounds go out in the subconscious's requests once its
147
+ * window follows the presentation index (#291, answer 13). Its own rounds go
148
+ * as stored either way.
149
+ *
150
+ * - `'transcript'` (the default): a line per tool call (the tool's name and
151
+ * its input in brief) and per result (its outcome in brief), the text as
152
+ * stored, and none of the resident's thinking (foreign-rounds.ts).
153
+ * - `'raw'`: as stored, as 0.30.0 sent them: the resident's thinking
154
+ * blocks, its tool calls and their results, in the subconscious's
155
+ * requests under the resident's name. A provider pairs tool blocks only
156
+ * in the turns of the agent that made the call, so it may refuse them, or
157
+ * the formatter may move them into the subconscious's own turns, where
158
+ * they read as calls it made.
159
+ *
160
+ * A thinking block's signature binds the block to the prefix the resident
161
+ * was sent, so the block can't be sent as part of another agent's prefix;
162
+ * its text could be. Leaving the text out is the transcript's choice, not
163
+ * the provider's.
164
+ */
165
+ foreignRounds?: 'transcript' | 'raw';
85
166
  }
86
167
  export interface ForkReaderConfig extends SubconsciousConfigBase {
87
168
  reader: 'forks';
88
169
  /**
89
170
  * Whose weights run the fork. Required, never defaulted: a fork holds the
90
- * resident's whole prefix, and which model reads it is the one fact the
91
- * resident's consent names. The resident's own model is the copy; another
92
- * model is allowed when stated here. `create` refuses the omission.
171
+ * resident's whole prefix, and which model reads it is recorded on each
172
+ * fork's `dendrite:agent-created` trace and is what a host's
173
+ * `dendrite.beforeDerive` can decide on. The resident's own model, or
174
+ * another model stated here. `create` refuses the omission.
93
175
  */
94
176
  model: string;
95
177
  /**
96
- * The reader's voice block — report-shaped, second person toward the
97
- * resident, co-authored with them. Delivered as the first message after
98
- * the fork point, with the notice, the standing dispositions and the held
99
- * traffic; never a system prompt.
178
+ * The reader's voice block: text the host supplies, handed to `framing`.
179
+ * The default framing (defaultReaderFraming) puts it in the one message a
180
+ * fork receives after the fork point, with the notice, the standing
181
+ * dispositions and the held traffic; it is never a system prompt. Who
182
+ * writes it and what it says, a policy for the reader tools included,
183
+ * are the host's choice.
100
184
  */
101
185
  voice: string;
102
186
  /**
@@ -114,7 +198,13 @@ export interface ForkReaderConfig extends SubconsciousConfigBase {
114
198
  * framework stores whatever this returns as a user message with
115
199
  * `metadata.kind = 'tune-out-reader-framing'`; the notice, voice,
116
200
  * dispositions and held traffic are in the context, and nothing else
117
- * about the fork's prompt is fixed by the path.
201
+ * about the fork's prompt is fixed by the path. note_disposition tells a
202
+ * reader that a disposition it records is shown to the reader each time
203
+ * it runs, and a fork is shown them only as its framing puts them
204
+ * (`dispositions`), so a framing that leaves them out makes that untrue.
205
+ * Likewise the held traffic reaches the fork only as its framing puts it
206
+ * (`backlog`): the fork's view, the residents', leaves the raw rows out,
207
+ * as it leaves out all held traffic (the default framing shows them).
118
208
  */
119
209
  framing?: (context: ReaderFramingContext) => ContentBlock[];
120
210
  }
@@ -134,13 +224,20 @@ export interface ReaderFramingContext {
134
224
  /** Standing dispositions recorded on the epoch, or null. */
135
225
  dispositions: string | null;
136
226
  /**
137
- * The traffic held since the last look, oldest first; empty when nothing
138
- * arrived. It includes the messages still queued behind the resident's
139
- * turn (admitted, not yet stored), last: their ids are held handles and
140
- * their sequences provisional, as a module's held rows are.
227
+ * The traffic held since the last look, oldest first, as stored; empty
228
+ * when nothing arrived. A held message is stored as it arrives, the
229
+ * resident's turn alive or not (#291), so the stored rows are all of it,
230
+ * but for one a surgery's hold or a manager awaiting recovery keeps in
231
+ * memory: it isn't stored yet, and is in the first backlog after it is.
141
232
  */
142
233
  backlog: StoredMessage[];
143
- /** How many of `backlog`'s last entries are still queued behind the resident's turn. Absent is none. */
234
+ /**
235
+ * Was how many of `backlog`'s last entries were still queued behind the
236
+ * resident's turn. Since #291 nothing is queued, so the framework never
237
+ * sets it.
238
+ *
239
+ * @deprecated Never set since #291; removed in a later release.
240
+ */
144
241
  queuedCount?: number;
145
242
  }
146
243
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tune-out/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAErE,eAAO,MAAM,uBAAuB,YAClC,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,CACV,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,C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;;;;;;;;;;;;OAmBG;IACH,aAAa,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC;CACtC;AAED,MAAM,WAAW,gBAAiB,SAAQ,sBAAsB;IAC9D,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,OAAO,4BAA4B,EAAE,eAAe,CAAC;IAC7E,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,YAAY,EAAE,CAAC;CAC7D;AAED,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACnC,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IACvC,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;;;OAMG;IACH,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,GAAG,YAAY,EAAE,CA8B9E"}
@@ -1,4 +1,5 @@
1
1
  import { authorLine } from '../author-presentation.js';
2
+ import { appendAll } from '../append-all.js';
2
3
  export const SUBCONSCIOUS_TOOL_NAMES = [
3
4
  'deliver_summary',
4
5
  'cancel_tuneout',
@@ -8,10 +9,9 @@ export const SUBCONSCIOUS_TOOL_NAMES = [
8
9
  export const SUBCONSCIOUS_TOOLS = [
9
10
  {
10
11
  name: 'deliver_summary',
11
- description: 'Deliver a summary into the resident\'s context, in your own voice, ' +
12
- 'addressed to them (second person). Use at cadence when the diverted ' +
13
- 'traffic merits it; staying silent is always allowed — an empty ' +
14
- 'period needs no report.',
12
+ description: 'Deliver a summary into the resident\'s context: `text` arrives there ' +
13
+ 'verbatim (leading and trailing whitespace trimmed), under your own ' +
14
+ 'name.',
15
15
  inputSchema: {
16
16
  type: 'object',
17
17
  properties: {
@@ -29,11 +29,15 @@ export const SUBCONSCIOUS_TOOLS = [
29
29
  },
30
30
  {
31
31
  name: 'cancel_tuneout',
32
- description: 'End the tune-out on a channel now — use when something needs the ' +
33
- 'resident\'s full attention. The diverted backlog is delivered to ' +
34
- 'them (capped), and normal attention resumes. Add your own note in ' +
35
- '`text`; it arrives alongside the backlog, in your voice. If you were ' +
36
- 'started to read one hold, you can end only that hold.',
32
+ description: 'End the tune-out on a channel. The diverted backlog is delivered ' +
33
+ 'to the resident (capped), and the channel\'s traffic reaches them as ' +
34
+ 'it did before the tune-out, unless the all-except hold holds it too. ' +
35
+ 'A note in `text` arrives alongside the ' +
36
+ 'backlog, verbatim (leading and trailing whitespace trimmed), under ' +
37
+ 'your own name. Where the cancel has to wait (an operator\'s change to ' +
38
+ 'the store, say), its answer says so, and whether your note waits with ' +
39
+ 'it. If you were started to read ' +
40
+ 'one hold, you can end only that hold.',
37
41
  inputSchema: {
38
42
  type: 'object',
39
43
  properties: {
@@ -49,10 +53,10 @@ export const SUBCONSCIOUS_TOOLS = [
49
53
  },
50
54
  {
51
55
  name: 'note_disposition',
52
- description: 'Record a standing disposition for yourself — a durable note that ' +
53
- 'shapes how you treat future traffic ("antra\'s pings always ' +
54
- 'escalate", "ignore release-bot"). Replaces any previous note under ' +
55
- 'the same key.',
56
+ description: 'Record a standing disposition: a durable note, kept under `key` ' +
57
+ 'across invocations and shown to the reader each time it runs (e.g. ' +
58
+ 'key "<sender>", text "<a note on their messages>"). Replaces any ' +
59
+ 'previous note under the same key.',
56
60
  inputSchema: {
57
61
  type: 'object',
58
62
  properties: {
@@ -67,14 +71,14 @@ export const SUBCONSCIOUS_TOOLS = [
67
71
  },
68
72
  {
69
73
  name: 'speak_in_channel',
70
- description: 'Post a message into a tuned-out channel, in your own words and ' +
71
- 'clearly as yourself (not as the resident); it goes out through the ' +
72
- 'resident\'s publish path, so the channel sees it under their account. ' +
73
- 'Use sparingly — e.g. to tell someone the resident is tuned out and ' +
74
- 'when to expect them. If you were started to read one hold, you can ' +
75
- 'post only into a channel that hold still holds, and a post made once ' +
76
- 'it has ended is refused; your report can say it instead. Disabled unless ' +
77
- 'the resident\'s configuration allows it.',
74
+ description: 'Post `text` into a tuned-out channel, as written (leading and trailing ' +
75
+ 'whitespace trimmed). It goes out through ' +
76
+ 'the resident\'s publish path, so the channel sees it under the ' +
77
+ 'resident\'s account; nothing in the post names you. If you were ' +
78
+ 'started to read one hold, you can post only into a channel that hold ' +
79
+ 'still holds, and a post made once it has ended is refused; your report ' +
80
+ 'can say it instead. Disabled unless the resident\'s configuration ' +
81
+ 'allows it.',
78
82
  inputSchema: {
79
83
  type: 'object',
80
84
  properties: {
@@ -85,6 +89,68 @@ export const SUBCONSCIOUS_TOOLS = [
85
89
  },
86
90
  },
87
91
  ];
92
+ /**
93
+ * What a tuned-out channel's messages are, as the words after "its
94
+ * messages" in a refusal a resident reads (a channel tool's on a tuned-out
95
+ * channel): held from it and read by `reader`, by the name it runs under or
96
+ * as forks of the resident's context.
97
+ */
98
+ export function tuneOutHeldWords(reader) {
99
+ if (reader.kind === 'persistent' && reader.running === false) {
100
+ return "are held from you, with no reader running here to read them, until the tune-out's release, which failed, is tried again";
101
+ }
102
+ return reader.kind === 'persistent' ? `are held from you and read by ${reader.name}`
103
+ : 'are held from you and read by forks of your context';
104
+ }
105
+ /**
106
+ * What a tuned-out channel's traffic is, as the words after "its traffic"
107
+ * in the [tuned out] note to a send there: held from the resident and read
108
+ * by `reader` until the tune-out ends, or, where none runs, held until its
109
+ * release is tried again (TuneOutReader).
110
+ */
111
+ export function tunedOutTrafficWords(reader) {
112
+ if (reader.kind === 'persistent' && reader.running === false) {
113
+ return "is still held from you, with no reader running here to read it, until the tune-out's release, which failed, is tried again.";
114
+ }
115
+ return reader.kind === 'persistent'
116
+ ? `is still held from you, and read by ${reader.name}, until the tune-out ends.`
117
+ : 'is still held from you, and read by forks of your context, until the tune-out ends.';
118
+ }
119
+ /**
120
+ * Whether a tuned-out channel's messages get to its reader, as the words
121
+ * after "its messages" in tune_out's answers about the channel's transport,
122
+ * in the sentence's `form`: they reach `reader`, by the name it runs under
123
+ * or as "the reader" (forks, as tuneOutTool says it). Where no reader runs,
124
+ * those answers aren't given: tuneOutNoReaderAnswer is, in their place.
125
+ */
126
+ export function tuneOutReachWords(reader, form) {
127
+ return `${form} ${reader.kind === 'persistent' ? reader.name : 'the reader'}`;
128
+ }
129
+ /**
130
+ * tune_out's answer about a tuned-out channel's transport where no reader
131
+ * runs (`running: false`, a hold left on record by a failed release): a
132
+ * sentence of its own, given alone in place of each answer that says
133
+ * whether the messages reach the reader and when (tuneOutReachWords), since
134
+ * opening the channel doesn't change that none reads them. Undefined where
135
+ * a reader runs. tune_out is refused with no reader, repeated for a channel
136
+ * already tuned out too, so this answers a tune_out whose reader ended
137
+ * while its channel's open was out.
138
+ */
139
+ export function tuneOutNoReaderAnswer(reader) {
140
+ if (reader.kind !== 'persistent' || reader.running !== false)
141
+ return undefined;
142
+ return 'The tune-out is recorded, but its messages are held, with no reader running here to read them, until the '
143
+ + "tune-out's release, which failed, is tried again; opening its channel doesn't change that.";
144
+ }
145
+ /**
146
+ * The name a persistent reader runs under: its configuration's `name`, or,
147
+ * where the host gave none, `'Subconscious'` (PersistentReaderConfig.name).
148
+ * The one place the framework names a reader the host didn't: everything
149
+ * that needs the name of an unnamed reader asks this.
150
+ */
151
+ export function persistentReaderName(config) {
152
+ return config.name ?? 'Subconscious';
153
+ }
88
154
  /**
89
155
  * The default reader-fork framing: a header naming the channel, epoch and
90
156
  * trigger; the notice; the voice block; standing dispositions if any; then
@@ -101,17 +167,12 @@ export function defaultReaderFraming(ctx) {
101
167
  return content;
102
168
  }
103
169
  const n = ctx.backlog.length;
104
- const q = Math.min(Math.max(0, Math.floor(ctx.queuedCount ?? 0)), n);
105
170
  const lines = [`\n[Held in ${ctx.channelId} since your last look: ${n} message${n === 1 ? '' : 's'}]`];
106
171
  const flush = () => {
107
172
  if (lines.length > 0)
108
173
  content.push({ type: 'text', text: lines.splice(0).join('\n') });
109
174
  };
110
- const which = q === n ? (q === 1 ? 'It' : 'They') : (q === 1 ? 'The last one' : `The last ${q}`);
111
- const queuedNote = `[${which} arrived while ${ctx.resident}'s turn was running, so ${q === 1 ? 'it is' : 'they are'} still queued, not yet stored.]`;
112
- for (const [i, message] of ctx.backlog.entries()) {
113
- if (q > 0 && i === n - q)
114
- lines.push(queuedNote);
175
+ for (const message of ctx.backlog) {
115
176
  const author = message.metadata?.author?.name ?? message.participant;
116
177
  const text = message.content
117
178
  .filter((b) => b.type === 'text')
@@ -121,7 +182,7 @@ export function defaultReaderFraming(ctx) {
121
182
  const media = message.content.filter((b) => b.type !== 'text');
122
183
  if (media.length > 0) {
123
184
  flush();
124
- content.push(...media);
185
+ appendAll(content, media);
125
186
  }
126
187
  }
127
188
  flush();
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/tune-out/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAiBvD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;CACV,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAqB;IAClD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,qEAAqE;YACrE,sE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IAAI,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC,CAAC;IACF,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GAAI,OAAO,CAAC,QAAuD,EAAE,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;QACrH,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO;aACzB,MAAM,CAAC,CAAC,CAAC,EAAgD,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;aAC9E,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAClB,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;QACrC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QAC/D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,KAAK,EAAE,CAAC;YACR,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Where the persistent subconscious's window starts (#291, AF-5).
3
+ *
4
+ * The subconscious reads a tune-out's held traffic through a windowed
5
+ * passthrough strategy: everything from the anchor on, the anchor at the
6
+ * oldest active tune-out's start (the coordinator's anchorSubconscious), or
7
+ * at an earlier start kept in force: a cancelled tune-out's, kept while
8
+ * another stays active and across a restart, until the next enter sets the
9
+ * oldest active one's (below).
10
+ * While its window is the record, a start is a sequence, and the window is
11
+ * every row stored at it or after. Once its window follows the presentation
12
+ * index, the window is the rows in the order it was shown them, and a start
13
+ * is an index ordinal: the row at it and every row presented after it.
14
+ *
15
+ * A tune-out's start can't be turned into an ordinal once and for all at its
16
+ * enter. The subconscious's window grows only at its own points, so a row
17
+ * stored before the start can still be out of its window then (its turn
18
+ * alive, the host quiesced), and would be presented after the start, inside
19
+ * the window. Converting the sequence again later (a restart, another
20
+ * tune-out's enter) can give another ordinal, and so another window, once
21
+ * rows have been presented out of record order. So each tune-out's start is
22
+ * fixed once, at the first moment no row the subconscious is owed stored
23
+ * before the start is out of its window: the ordinal just past the last row
24
+ * in its window stored before the start, which leaves every such row out
25
+ * (0 when there is none). Others' rows enter a window in record order, so
26
+ * that is where the first row stored at the start or after entered, unless
27
+ * one of the subconscious's own rows was presented ahead of them, at its
28
+ * write, in the turn the tune-out began in; that row stays out too, the turn
29
+ * having been before the tune-out. The coordinator keeps the ordinal
30
+ * (subconsciousWindowFixed), and from then on the start is set by it,
31
+ * clamped to the window's length on a branch whose window is shorter (a
32
+ * rollback), the clamped ordinal then kept as the start, never converted
33
+ * again. A kept ordinal is kept as the start in force once it is set, not
34
+ * before, and one whose setting or keeping fails is tried again at the next
35
+ * presentation, as a fix is. One set while the window is the record (a
36
+ * branch move whose re-initialization of the subconscious failed) waits
37
+ * longer: it is set by sequence and fixed at the next enter or restart once
38
+ * the window presents. One whose setting or keeping failed before a branch
39
+ * move is fixed again on the branch moved to, from its window there, as one
40
+ * never fixed is: an ordinal is a place on the branch it was fixed on; one
41
+ * for tune-outs none of which is active then, and a cancelled tune-out's
42
+ * start set in force by its kept ordinal, are dropped at the move. A
43
+ * restart that finds a start in force kept sets that one, and fixes the
44
+ * oldest active tune-out's start, if it isn't kept, without moving the
45
+ * window to it; one that finds none in force kept sets the anchor the
46
+ * strategy persisted, as the start in force: where the oldest's start is
47
+ * kept, if it is earlier (a cancelled tune-out's start that was set but
48
+ * never kept), and where it isn't (its fix set, its keeping failed),
49
+ * wherever it is, rather than converting the oldest's sequence again, that
50
+ * start fixed without moving the window to it; where that anchor can't be
51
+ * read, it sets nothing, the window left where it was until the next enter
52
+ * or restart.
53
+ */
54
+ import type { ContextManager, StoredMessage } from '@animalabs/context-manager';
55
+ import type { SubconsciousWindowStart } from './coordinator.js';
56
+ import type { TraceEventInput } from '../types/trace.js';
57
+ /** The windowed strategy's anchor setters and read, as the anchor uses them. */
58
+ export interface AnchoredStrategy {
59
+ setAnchor(sequence: number): void;
60
+ setAnchorOrdinal(ordinal: number): void;
61
+ getAnchorOrdinal(): number | undefined;
62
+ }
63
+ /** What the anchor reads of the framework. */
64
+ export interface SubconsciousWindowAnchorHost {
65
+ /** The subconscious's name, for its traces. */
66
+ readonly agentName: string;
67
+ /** Its context manager while it is registered. */
68
+ cm(): Pick<ContextManager, 'indexLength' | 'getPresentedMessages' | 'ordinalOf'> | undefined;
69
+ /** Its windowed strategy. */
70
+ strategy(): AnchoredStrategy | null;
71
+ /** Whether its window follows the presentation index, so its places are ordinals. */
72
+ presents(): boolean;
73
+ /** The rows it is owed that its window doesn't hold yet, one per body (AgentPresentation.owedOf). */
74
+ owed(): readonly Pick<StoredMessage, 'sequence'>[];
75
+ /**
76
+ * Keep a start fixed for `epochIds` (TuneOutCoordinator.subconsciousWindowFixed), as the start in force when
77
+ * `inForce`; false when it couldn't be kept.
78
+ */
79
+ fixed(epochIds: readonly string[], ordinal: number, inForce: boolean): boolean;
80
+ emitTrace(event: Extract<TraceEventInput, {
81
+ type: 'tune-out:subconscious-window';
82
+ }>): void;
83
+ }
84
+ /** The subconscious's window start, set by sequence in legacy mode and by a fixed ordinal once its window is presented. */
85
+ export declare class SubconsciousWindowAnchor {
86
+ private readonly host;
87
+ /**
88
+ * The starts whose ordinal isn't set and kept yet, the one in force
89
+ * (`inForce`) first if it is among them: some row older than a start is
90
+ * still out of the window, or setting or keeping the ordinal it was fixed
91
+ * at (`ordinal`) failed, which the next presentation tries again. A start
92
+ * set by an ordinal already known (`known`) waits only for its setting and
93
+ * keeping: kept for `keep` (none for a start in force only) and as the
94
+ * start in force, traced when clamped (`clampedFrom`, the ordinal kept
95
+ * before).
96
+ */
97
+ private pending;
98
+ constructor(host: SubconsciousWindowAnchorHost);
99
+ /**
100
+ * Set the window start (the coordinator's setSubconsciousAnchor). In
101
+ * legacy mode by its sequence, as before the index. In presented mode by
102
+ * its ordinal when one was fixed, clamped to the window's index length
103
+ * and traced when past it, the clamped ordinal kept as the start; the
104
+ * strategy's persisted anchor where it is earlier, or, with no ordinal
105
+ * known, where it has one, at a resume that asks for it
106
+ * (keepEarlierAnchor); else by its sequence for now, converted as
107
+ * the strategy converts one, and the ordinal is fixed (see the module
108
+ * doc) as soon as no row the subconscious is owed stored before the start
109
+ * is out of its window, now or at a later presentation (presented). An
110
+ * ordinal set is kept as the start in force once it is set, and tried
111
+ * again at the next presentation until both succeed. The starts of
112
+ * `others`, the other active tune-outs' whose ordinal isn't kept yet, are
113
+ * fixed the same way, without moving the window to them. Never throws: a
114
+ * set that fails is logged, and the anchor stays where it was.
115
+ */
116
+ set(start: SubconsciousWindowStart, others?: readonly SubconsciousWindowStart[]): void;
117
+ /**
118
+ * The store's branch moved (the framework's followBranchMove, before the
119
+ * agents follow it): an ordinal is a place on the branch it was fixed on,
120
+ * so a start pending at one (its setting or keeping failed), or set by one
121
+ * kept there (`known`), waits again to be fixed, from the window it
122
+ * presents on now, as a start never fixed does (tryFix): one for a
123
+ * tune-out still active (`active`, the coordinator's, where the framework
124
+ * says). One fixed for tune-outs none of which is active any more, and
125
+ * the start in force only (a cancelled tune-out's, set by its kept
126
+ * ordinal: fixed again, it would be the active one's start), are dropped,
127
+ * as every start fixed at an ordinal was before (AF #844 review 3, #30
128
+ * and #44): the anchor the destination's strategy keeps stands until the
129
+ * next enter or restart sets one.
130
+ */
131
+ branchMoved(active?: readonly string[]): void;
132
+ /** Rows entered the subconscious's window (the presentation index's onPresented): a start waiting to be fixed may be fixable now. */
133
+ presented(): void;
134
+ /**
135
+ * Fix each pending start's ordinal, once no row owed and stored before it
136
+ * is out of the window, then set it (the start in force) and keep it;
137
+ * until both succeed a start stays pending at that ordinal. A start set by
138
+ * an ordinal known is set and kept the same way, and traced only when
139
+ * clamped.
140
+ */
141
+ private tryFix;
142
+ }
143
+ //# sourceMappingURL=window-anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-anchor.d.ts","sourceRoot":"","sources":["../../../src/tune-out/window-anchor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,gFAAgF;AAChF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,8CAA8C;AAC9C,MAAM,WAAW,4BAA4B;IAC3C,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,kDAAkD;IAClD,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,aAAa,GAAG,sBAAsB,GAAG,WAAW,CAAC,GAAG,SAAS,CAAC;IAC7F,6BAA6B;IAC7B,QAAQ,IAAI,gBAAgB,GAAG,IAAI,CAAC;IACpC,qFAAqF;IACrF,QAAQ,IAAI,OAAO,CAAC;IACpB,qGAAqG;IACrG,IAAI,IAAI,SAAS,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE,CAAC;IACnD;;;OAGG;IACH,KAAK,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC/E,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