@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,9 +1,11 @@
1
1
  import type { ContentBlock } from '@animalabs/membrane';
2
2
  import type {
3
+ ContextManager,
3
4
  MessageId,
4
5
  MessageMetadata,
5
6
  StoredMessage,
6
7
  ContextInjection,
8
+ WindowStatus,
7
9
  } from '@animalabs/context-manager';
8
10
  import type { ProcessEvent, ToolDefinition, ToolCall, ToolResult } from './events.js';
9
11
  import type { TraceEventListener } from './trace.js';
@@ -49,44 +51,54 @@ export interface MessageQuery {
49
51
  export type ModuleContextInjection = ContextInjection & { placedEachCompile?: true };
50
52
 
51
53
  /**
52
- * A message as a module context's reads answer it: a stored row, or a row
53
- * for a write the framework holds (`held`). Either is marked
54
- * `heldFromResidents` when a tune-out holds it from the residents.
54
+ * A message as a module context's reads answer it: a stored row, marked
55
+ * `held` when it isn't in the window of the agent the read is for, and
56
+ * `heldFromResidents` when a tune-out or a suppress rule holds it from the
57
+ * residents.
55
58
  */
56
59
  export type ModuleMessage = StoredMessage & {
57
60
  /**
58
- * True while the framework holds the message's write, as it does while
59
- * the write's agent has a turn alive or the host is quiesced, until a
60
- * later boundary stores it. The row's `id` is then a handle, which
61
- * getMessage, editMessage and removeMessage take as they take a stored
62
- * id, and which names the stored row once the write lands. Its `sequence`
63
- * and `timestamp` are provisional: the sequence comes after every stored
64
- * row's, the timestamp is when the framework held the write (for a write
65
- * an older release held, when its queue was read back), and both change
66
- * when it lands. A held write whose earlier write may already be stored
67
- * is looked up first, and answered as the stored row it is when the store
68
- * holds it. Absent on a stored row.
61
+ * True on a row stored and not in the window of the agent the read is for
62
+ * (#291's presentation index): it arrived while that agent's turn was
63
+ * alive, or while the host was quiesced, and enters the window at the
64
+ * agent's next presentation point (a turn's start, a tool boundary that
65
+ * can carry it, a turn's end, or at once while no turn of it is alive);
66
+ * or it was taken out of the window as an undone turn's; or it is never
67
+ * presented to that agent, as a held message is to a resident. Set only
68
+ * once that agent's window is written down (presented mode); a held
69
+ * message an earlier release stored is in a resident's window written
70
+ * down from the record, so it reads without `held`, and
71
+ * `heldFromResidents` is what marks it. Its `id`,
72
+ * `sequence` and `timestamp` are the store's, as for any row: since #291
73
+ * every write is stored at once, so no row is a handle and nothing
74
+ * changes when it enters the window. Before #291 the same name marked a
75
+ * write the framework still held, under a `held:` handle; see the
76
+ * changelog. Absent on a row the window holds.
69
77
  */
70
78
  held?: true;
71
79
  /**
72
80
  * True on a message a tune-out holds from the residents: one that arrived
73
81
  * in a tuned-out channel, stamped `metadata.tuneOut` as it came in. The
74
82
  * store keeps it, but no resident is shown the row itself: no resident's
75
- * compiled view includes it, during the tune-out or after it, and a
76
- * resident's tool boundary of a turn alive when it arrived stores it
77
- * without injecting it into the live turn. The subconscious reads it. Its
83
+ * compiled view includes it, during the tune-out or after it. It is
84
+ * stored as any write is, and a resident's tool boundary of a turn alive
85
+ * when it arrived doesn't inject it into the live turn. The subconscious
86
+ * reads it. Its
78
87
  * text can still reach a resident in rows of their own, which aren't
79
88
  * marked, such as the
80
89
  * cancel's `<tuned-out-backlog>` row, with the text of the tune-out's newest
81
90
  * messages, up to `backlogCap` of them and as many as fit in one of the
82
- * residents' messages, the stored ones first and then those still held;
83
- * what the subconscious says of it, in its report or its note; and the
91
+ * residents' messages; what the subconscious says of it, in its report or
92
+ * its note; and the
84
93
  * result of a tool that reads history on request, such as a
85
94
  * channel's `fetch_history` or the history module's `extract`. A module
86
95
  * that builds on what the residents see, such as one choosing from the
87
96
  * recent conversation, leaves a marked row out, and one that matches
88
- * what's stored, such as a sync's dedupe, keeps it. A held write (`held`)
89
- * is marked too when it carries the stamp. Absent on every other row.
97
+ * what's stored, such as a sync's dedupe, keeps it. A row a suppress rule
98
+ * hid (`metadata.suppressed`) is marked too: no view shows it, the
99
+ * subconscious's included, and no window presents it, so once the
100
+ * agent's window is written down it reads `held` too. Absent on every
101
+ * other row.
90
102
  */
91
103
  heldFromResidents?: true;
92
104
  };
@@ -95,9 +107,8 @@ export type ModuleMessage = StoredMessage & {
95
107
  * Result of a message query.
96
108
  */
97
109
  export interface MessageQueryResult {
98
- /** The matching stored rows, then, as the newest, the matching rows of
99
- * writes the framework holds (ModuleMessage.held): before the stored rows
100
- * in a reversed query */
110
+ /** The matching stored rows, in store order (newest first in a reversed
111
+ * query), each marked as ModuleMessage says. */
101
112
  messages: ModuleMessage[];
102
113
  totalCount: number;
103
114
  }
@@ -281,9 +292,10 @@ export interface AgentSettingsExtension {
281
292
  * nothing.
282
293
  *
283
294
  * Its reads (`getState`, `getLog`, `getLogLength`, `getMessage`,
284
- * `queryMessages`, `getAgents`, `getActiveTools`, `findMessageByExternalId`)
285
- * answer, and fail, as before; one that meets a held write may record that
286
- * the write has landed, as any reader's does. The framework calls none of the
295
+ * `queryMessages`, `getAgents`, `getActiveTools`, `findMessageByExternalId`,
296
+ * and the window lookups `windowStatusOf`, `observes`, `viewKeeps` and
297
+ * `agentNameOf` where the framework offers them) answer, and fail, as
298
+ * before. The framework calls none of the
287
299
  * module's `onProcess`, `onAgentSpeech` and `onToolBatchComplete` again; it
288
300
  * drops whole a response of its that hadn't been applied by then, with a line
289
301
  * naming what the response asked for if it asked for anything; and it leaves
@@ -381,20 +393,44 @@ export interface ModuleContext {
381
393
  getModule<T extends Module>(name: string): T | null;
382
394
 
383
395
  /**
384
- * Add a message to the conversation, and answer its id. While the
385
- * framework holds the write (the agent's turn is alive, or the host is
386
- * quiesced), the id is a handle, `held:` and the write's id, which
387
- * getMessage, editMessage and removeMessage take as they take a stored
388
- * id, and which names the stored row once the write lands
389
- * (ModuleMessage.held). The writes a process held, and keeps across a
390
- * restart, show to the next process's modules once create() has restored
391
- * them, which is after every module's start().
396
+ * Add a message to the conversation, and answer its stored id. The write
397
+ * is stored at once, whatever the agent's turn (#291): it enters the
398
+ * agent's window at the agent's next presentation point, or at once while
399
+ * no turn of it is alive, and until then reads mark it `held`
400
+ * (ModuleMessage.held). Only while the write is kept in memory is the id
401
+ * '': while an operator's surgery holds the store, stored at the
402
+ * surgery's end, and while the agent's context manager refuses its work
403
+ * after a failed re-initialization, stored when a switchBranch()
404
+ * re-initializes it (a restart loses it; if the agent ends first, it goes
405
+ * to the primary when it is a write the primary takes in its place).
406
+ * Until it lands, such a write can't be read, edited or removed through
407
+ * this context: it has no id, getMessage, editMessage and removeMessage
408
+ * take none for it, and queryMessages and findMessageByExternalId read
409
+ * the store, which doesn't hold it yet. Its release stores it as it was
410
+ * given here. A module that must change it keeps the change and applies
411
+ * it to the row once the row is stored, which the release traces
412
+ * synchronously as `message:added` with source `surgery-release` and the
413
+ * stored id, as the Discord module does for an edit or a delete of a
414
+ * message whose create was kept.
415
+ * Writes a release before #291 held and kept across a restart are
416
+ * stored once create() imports them, which is after every module's
417
+ * start().
418
+ * A write whose store throws after rows of it landed is answered by the
419
+ * first of them, as stored (context-manager's WriteLandedError names
420
+ * them). One whose store throws where the store can't be read to tell
421
+ * what of it landed throws context-manager's WriteOutcomeUnknownError,
422
+ * which names the rows it knows are stored (`landed`, presented as a
423
+ * stored write's rows are) and counts those it can't (`unknown`,
424
+ * `unnamed`): the write may be stored, in part or whole, or not at all,
425
+ * and isn't answered as stored. A read of the store tells, once the store
426
+ * reads: queryMessages, or findMessageByExternalId for a write that
427
+ * carried `metadata.external`. Any other error means none of it is stored.
392
428
  *
393
429
  * With `opts.forAgent`, it's added to the named agent's window instead: a
394
430
  * conversation fork's or a running sub-agent's own store, or, for an
395
- * ordinary resident, the residents' shared slot. It's held while that
396
- * agent's turn is alive, as a write for the primary is while the
397
- * primary's is. A name that isn't a registered agent when the write is
431
+ * ordinary resident, the residents' shared slot. It enters that agent's
432
+ * window at that agent's points, as a write for the primary does at the
433
+ * primary's. A name that isn't a registered agent when the write is
398
434
  * made, or the empty name, throws, naming the registered ones, so a write
399
435
  * for a launcher that has gone is heard. For an ephemeral run (a
400
436
  * sub-agent's run) or a conversation fork, whose window nothing reads
@@ -413,12 +449,17 @@ export interface ModuleContext {
413
449
  * failed reply, or a channel notice its reader could act on). getMessage,
414
450
  * editMessage and removeMessage read the delivery agent's window (the
415
451
  * primary's, or the first agent's when none is primary): they don't take
416
- * an id or handle for a row in a fork's or a sub-agent's window, and don't
452
+ * an id for a row in a fork's or a sub-agent's window, and don't
417
453
  * find it (read it with queryMessages and the same forAgent). The
418
454
  * residents' shared slot is the primary's window too, for a primary
419
455
  * that's an ordinary resident, so there they do.
420
456
  * `metadata.external` with a target throws: its id map is read in the
421
- * primary's window.
457
+ * primary's window. The row is stamped (`metadata.audience`, #291) for
458
+ * the agent named, or, with no agent named, for the agents that take
459
+ * untargeted inbound in the slot it lands in: every resident on a
460
+ * residents' host. A row a suppress rule took is stamped for nobody, and
461
+ * one carrying a tune-out's hold for nobody but a named agent whose view
462
+ * keeps held traffic (the persistent subconscious).
422
463
  */
423
464
  addMessage(
424
465
  participant: string,
@@ -428,48 +469,53 @@ export interface ModuleContext {
428
469
  ): MessageId;
429
470
 
430
471
  /**
431
- * Edit a message, by its id or a held write's handle. A held write is
432
- * stored with the new content. One whose earlier write may already be
433
- * stored, where the store can't be searched to tell, throws with nothing
434
- * changed.
472
+ * Edit a stored message, by its id. An edit of a row an agent's window
473
+ * holds changes what that agent's next compile sends, as for any stored
474
+ * row. For one release it also takes the `held:` handle a release before
475
+ * #291 answered for a write it held, and edits the row that write landed
476
+ * as.
435
477
  */
436
478
  editMessage(id: MessageId, content: ContentBlock[]): void;
437
479
 
438
480
  /**
439
- * Remove a message, by its id or a held write's handle. A held write is
440
- * dropped, so the agent never reads it. One whose earlier write may
441
- * already be stored, where the store can't be searched to tell, throws
442
- * with nothing changed.
481
+ * Remove a stored message, by its id. For one release it also takes the
482
+ * `held:` handle a release before #291 answered for a write it held, and
483
+ * removes the row that write landed as.
443
484
  */
444
485
  removeMessage(id: MessageId): void;
445
486
 
446
487
  /**
447
488
  * Find the message for an external ID this context added a message under:
448
- * the row it added, while the store holds it. For a write the framework
449
- * held, whose id this context doesn't keep, the first row the store shows
450
- * under that external ID, held rows included, a held row by its handle.
451
- * Null when this context added none under it, when the row it added is
452
- * gone, or when the store shows none for a held write, such as one the
453
- * last process held, looked up in start().
489
+ * the row it added, while the store holds it. For a write whose id this
490
+ * context doesn't keep (one kept in memory, by an operator's surgery or
491
+ * for its agent's recovery, one whose store threw where context-manager
492
+ * couldn't tell whether it landed (WriteOutcomeUnknownError), or one a
493
+ * release before #291 held, whose map it kept as ''), the first row the
494
+ * store shows under that external ID. Null when this context added none under
495
+ * it, when the row it added is gone, or when the store shows none for
496
+ * such a write, as for one an earlier release left queued, looked up in
497
+ * start() before create() imports it.
454
498
  */
455
499
  findMessageByExternalId(source: string, externalId: string): MessageId | null;
456
500
 
457
501
  /**
458
- * Get a message by its id or a held write's handle, marked
459
- * `heldFromResidents` when a tune-out holds it from the residents
460
- * (ModuleMessage).
502
+ * Get a stored message by its id, marked as ModuleMessage says: `held`
503
+ * when it isn't in the delivery agent's window, `heldFromResidents` when a
504
+ * tune-out or a suppress rule holds it from the residents. For one release
505
+ * it also takes the `held:` handle a release before #291 answered, and
506
+ * gives the row that write landed as.
461
507
  */
462
508
  getMessage(id: MessageId): ModuleMessage | null;
463
509
 
464
510
  /**
465
511
  * Query messages by filter criteria.
466
512
  * Useful for finding messages from external sources, by participant, etc.
467
- * The rows of writes the framework holds come after the stored rows, as
468
- * the newest, or before them in a reversed query, marked `held`
469
- * (ModuleMessage). Those the last process held show once create() has
470
- * restored them, after every module's start() (addMessage). A message a
471
- * tune-out holds from the residents is among the rows, marked
472
- * `heldFromResidents` (ModuleMessage).
513
+ * The rows come in store order, each marked as ModuleMessage says: `held`
514
+ * when it isn't in the window of the agent the read is for (stored and not
515
+ * yet presented to it, or undone), and `heldFromResidents` when a tune-out
516
+ * or a suppress rule holds it from the residents. Writes a release before
517
+ * #291 left queued show once create() has imported them, after every
518
+ * module's start() (addMessage).
473
519
  *
474
520
  * It reads the primary's window (the first registered agent's when none
475
521
  * is primary), or with `opts.forAgent`, the named agent's: a conversation
@@ -482,6 +528,67 @@ export interface ModuleContext {
482
528
  */
483
529
  queryMessages(filter: MessageQuery, opts?: { forAgent?: string }): MessageQueryResult;
484
530
 
531
+ /**
532
+ * Where a stored row stands with an agent's window (#291), the rows its
533
+ * requests are given, before its view's filter (context-manager's
534
+ * `windowStatusOf`): `'in'` when the window holds it, which is every row
535
+ * its record holds while the window is still the record; `'undone'` when
536
+ * it was taken out as an undone turn's, or shed after a refusal; `'out'`
537
+ * when it is stored and not in the window (not presented to the agent
538
+ * yet, or taken back to arrived); `'absent'` when the agent's record
539
+ * doesn't hold it (removed, never stored on its branch, or in a slot it
540
+ * doesn't read). For the delivery agent (the primary's, or the first
541
+ * agent's when none is primary), or with `opts.forAgent`, the named
542
+ * agent, which must be registered, as for queryMessages: a name that
543
+ * isn't throws. A tool that reads the record for an agent, such as the
544
+ * history module's, says with it, and with viewKeeps, which of the rows it
545
+ * returns the agent isn't being shown.
546
+ *
547
+ * Optional: a framework from before the presentation index, or a host's
548
+ * own context, doesn't offer it. Call as `ctx.windowStatusOf?.(...)`.
549
+ */
550
+ windowStatusOf?(id: MessageId, opts?: { forAgent?: string }): WindowStatus;
551
+
552
+ /**
553
+ * Whether `observer` reads `observed`'s own rows through an observe edge
554
+ * (dendrite's relationships): one of its edges reads another slot
555
+ * `observed` owns, or names `observed` and reads the observer's own slot
556
+ * (a resident's `AgentConfig.observes`). Seeing another agent's rounds is
557
+ * a declared relationship (#291, decision 1): an observe edge, which a
558
+ * resident's configuration declares with `observes`, so a tool that reads
559
+ * the record for an agent leaves out another agent's own rows it isn't
560
+ * shown unless this is true.
561
+ * False for a name the registry doesn't know. Optional, as
562
+ * windowStatusOf is, and offered with it.
563
+ */
564
+ observes?(observer: string, observed: string): boolean;
565
+
566
+ /**
567
+ * Whether an agent's view keeps a stored row (#291): whether its requests
568
+ * carry the row, as its strategy renders it (a row it has folded, as that
569
+ * summary), while its window holds it. windowStatusOf answers before
570
+ * the view's filter, and a window written down from the record the
571
+ * residents share can hold rows the view never sends: another agent's
572
+ * stored context injection, and, for an agent whose view leaves held
573
+ * traffic out (a resident), a row a tune-out holds from the residents. A
574
+ * row the agent is shown is one windowStatusOf reads `'in'` and this
575
+ * keeps. It reads the view the agent's context was opened with
576
+ * (context-options.ts), for the delivery agent, or with `opts.forAgent`
577
+ * the named agent, which must be registered, as for windowStatusOf: a name
578
+ * that isn't throws. Optional, as windowStatusOf is, and offered with it.
579
+ */
580
+ viewKeeps?(row: StoredMessage, opts?: { forAgent?: string }): boolean;
581
+
582
+ /**
583
+ * The live agent whose context `contextManager` is (the one its
584
+ * `getContextManager()` returns), or undefined when it is no live
585
+ * agent's (#291). A module a host binds to an agent's context, as it binds
586
+ * the history module, reads that context's record and summaries; this
587
+ * says whose they are, so another agent's call can be told from that
588
+ * agent's own. Optional, as windowStatusOf is, and offered with it.
589
+ */
590
+ agentNameOf?(contextManager: ContextManager): string | undefined;
591
+
485
592
  /**
486
593
  * Get info about all agents.
487
594
  */
@@ -649,19 +756,25 @@ export type AgentStatus = 'idle' | 'inferring' | 'streaming' | 'waiting_for_tool
649
756
  */
650
757
  export interface EventResponse {
651
758
  /**
652
- * Messages to add to the conversation.
759
+ * Messages to add to the conversation. Each row says who it is for in
760
+ * `metadata.audience` (#291): the agents a `requestInference` list names
761
+ * that are registered and read the slot the row lands in (the agent the
762
+ * row is delivered to, when none of them is registered); for `true`, no
763
+ * request, or a list whose registered agents don't read that slot (an
764
+ * isolated job, a conversation fork), as for any write that names no
765
+ * agent, the agents that take untargeted inbound in the slot it lands in
766
+ * (every resident on a residents' host). A message that carries a
767
+ * tune-out's hold is for nobody.
653
768
  */
654
769
  addMessages?: NewMessage[];
655
770
 
656
771
  /**
657
- * Messages to edit, each by its id or a held write's handle
658
- * (ModuleContext.editMessage).
772
+ * Messages to edit, each by its stored id (ModuleContext.editMessage).
659
773
  */
660
774
  editMessages?: MessageEdit[];
661
775
 
662
776
  /**
663
- * Messages to remove, each by its id or a held write's handle
664
- * (ModuleContext.removeMessage).
777
+ * Messages to remove, each by its stored id (ModuleContext.removeMessage).
665
778
  */
666
779
  removeMessages?: MessageId[];
667
780