@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
package/src/mcpl/types.ts CHANGED
@@ -22,7 +22,8 @@
22
22
  export interface JsonRpcRequest {
23
23
  jsonrpc: '2.0';
24
24
  method: string;
25
- id?: string | number;
25
+ /** A request's id; null is allowed, though JSON-RPC 2.0 discourages it. */
26
+ id?: string | number | null;
26
27
  params?: Record<string, unknown>;
27
28
  }
28
29
 
@@ -31,7 +32,8 @@ export interface JsonRpcRequest {
31
32
  */
32
33
  export interface JsonRpcResponse {
33
34
  jsonrpc: '2.0';
34
- id: string | number;
35
+ /** The request's id, or null when the request's own couldn't be read. */
36
+ id: string | number | null;
35
37
  result?: unknown;
36
38
  error?: JsonRpcError;
37
39
  }
@@ -265,8 +267,9 @@ export interface McplServerConfig {
265
267
  * - `ws://` or `wss://` is a legacy MCPL server over MCPL's WebSocket
266
268
  * binding. The host dials it and runs the same newline-delimited JSON-RPC
267
269
  * as over stdio.
268
- * - `http://` or `https://` is a modern MCP (2026-07-28) server over
269
- * Streamable HTTP.
270
+ * - `http://` or `https://` is a modern MCP server over Streamable HTTP.
271
+ * Its revision is negotiated at each connect: 2026-07-28 when the server
272
+ * offers it, and otherwise 2025-11-25, 2025-06-18 or 2025-03-26.
270
273
  */
271
274
  url?: string;
272
275
 
@@ -426,14 +429,34 @@ export interface McplServerConfig {
426
429
  * Only `true` turns it on, and null counts as not set. `create()`,
427
430
  * `connectMcplServer` and `restartMcplServer` refuse any other value, such
428
431
  * as a quoted "false".
432
+ *
433
+ * A modern server reached over HTTP at a 2025 revision can hold a session
434
+ * for this client. When the server ends it (HTTP 404), or stops serving its
435
+ * revision or its streams as a server upgraded to 2026-07-28 does, after it
436
+ * has answered a request, a new session starts at once whether or not this
437
+ * is set: the connection emits 'close' while its `willReconnect` reads
438
+ * true, then 'reconnect'. If that new session can't start, this setting
439
+ * decides, as for any lost connection, and a revision verdict stops it for
440
+ * good, as on any reconnect; without this setting, a second 'close', while
441
+ * `willReconnect` reads false, says the server is gone. An answered session
442
+ * that ends less than `reconnectIntervalMs` after it started gets a new
443
+ * one at once only if the last session restarted that way had lived that
444
+ * long, or there was none. A second such young end in a row, and a session
445
+ * that ends before it has answered, count as a failed connect, and follow
446
+ * this setting.
429
447
  */
430
448
  reconnect?: boolean;
431
449
 
432
450
  /**
433
451
  * Base interval between reconnection attempts in milliseconds.
434
452
  * The actual delay doubles with each consecutive failure (with ±25% jitter)
435
- * up to `reconnectMaxIntervalMs`, and resets after a successful handshake.
436
- * Default: 5000 (5 seconds).
453
+ * up to `reconnectMaxIntervalMs`, and resets after a successful handshake
454
+ * (for a modern server's 2025 session over HTTP, once that session's end
455
+ * starts a new one at once). Over HTTP the same backoff paces a modern
456
+ * server's streams: a dropped stream's first try waits the server's
457
+ * `retry` hint when it sent one above 0, and the backoff's first step
458
+ * otherwise, and a try after a failed one waits the longer of the hint
459
+ * and the doubling backoff. Default: 5000 (5 seconds).
437
460
  */
438
461
  reconnectIntervalMs?: number;
439
462
 
@@ -596,6 +619,10 @@ export interface FeatureSetDeclaration {
596
619
  coreTags?: string[];
597
620
  tags?: Record<string, unknown>;
598
621
  keyed?: Record<string, unknown>;
622
+ /** Ordered suggested rules (RFC-001 §5.1). Advisory: applied only on
623
+ * acceptance (§5.2), which wake onboarding asks the agent for. */
624
+ suggestedTreatment?: unknown[];
625
+ /** @deprecated RFC-001 revision 1's name for suggestedTreatment; still read. */
599
626
  defaultTreatment?: unknown[];
600
627
  open?: boolean;
601
628
  };
@@ -1,11 +1,15 @@
1
1
  import type { JsStateRegistration, JsStore } from '@animalabs/chronicle';
2
2
  import type { ContentBlock } from '@animalabs/membrane';
3
3
  import type {
4
+ ContextManager,
4
5
  MessageId,
5
6
  MessageMetadata,
6
7
  MessageQuery,
7
8
  ContextInjection,
9
+ StoredMessage,
10
+ WindowStatus,
8
11
  } from '@animalabs/context-manager';
12
+ import { WriteOutcomeUnknownError } from './context-manager-errors.js';
9
13
  import type {
10
14
  Module,
11
15
  ModuleContext,
@@ -25,7 +29,6 @@ import type {
25
29
  ModuleContextInjection,
26
30
  MessageQueryResult,
27
31
  } from './types/index.js';
28
- import { heldWriteId } from './held-writes.js';
29
32
  import { boundedErrorMessage } from './error-message.js';
30
33
  import type { Agent } from './agent.js';
31
34
  import { DEFAULT_SHUTDOWN_TIMEOUT_MS, validateShutdownTimeout, waitForShutdown } from './shutdown.js';
@@ -150,6 +153,13 @@ export class ModuleRegistry {
150
153
  message: string,
151
154
  data?: Record<string, unknown>,
152
155
  ) => void;
156
+ /** The window lookups ModuleContext.windowStatusOf, observes, viewKeeps
157
+ * and agentNameOf give modules (#291), when the framework offers them.
158
+ * Readonly-public, as notifyOpsFn is. */
159
+ readonly windowStatusOfFn?: (id: MessageId, opts?: { forAgent?: string }) => WindowStatus;
160
+ readonly observesFn?: (observer: string, observed: string) => boolean;
161
+ readonly viewKeepsFn?: (row: StoredMessage, opts?: { forAgent?: string }) => boolean;
162
+ readonly agentNameOfFn?: (contextManager: ContextManager) => string | undefined;
153
163
 
154
164
  constructor(
155
165
  store: JsStore,
@@ -170,6 +180,14 @@ export class ModuleRegistry {
170
180
  onTrace: (listener: TraceEventListener) => () => void;
171
181
  callTool: (call: ToolCall) => Promise<ToolResult>;
172
182
  notifyOps?: (kind: string, agentName: string, message: string, data?: Record<string, unknown>) => void;
183
+ /** Where a row stands with an agent's window (ModuleContext.windowStatusOf). */
184
+ windowStatusOf?: (id: MessageId, opts?: { forAgent?: string }) => WindowStatus;
185
+ /** Whether one agent observes another's own rows (ModuleContext.observes). */
186
+ observes?: (observer: string, observed: string) => boolean;
187
+ /** Whether an agent's view keeps a stored row (ModuleContext.viewKeeps). */
188
+ viewKeeps?: (row: StoredMessage, opts?: { forAgent?: string }) => boolean;
189
+ /** The live agent whose context a context manager is (ModuleContext.agentNameOf). */
190
+ agentNameOf?: (contextManager: ContextManager) => string | undefined;
173
191
  }
174
192
  ) {
175
193
  this.store = store;
@@ -184,6 +202,10 @@ export class ModuleRegistry {
184
202
  this.onTraceFn = options.onTrace;
185
203
  this.callToolFn = options.callTool;
186
204
  this.notifyOpsFn = options.notifyOps;
205
+ this.windowStatusOfFn = options.windowStatusOf;
206
+ this.observesFn = options.observes;
207
+ this.viewKeepsFn = options.viewKeeps;
208
+ this.agentNameOfFn = options.agentNameOf;
187
209
  this.dropRetiredPushFn = options.dropRetiredPush;
188
210
  }
189
211
 
@@ -748,6 +770,12 @@ class ModuleContextImpl implements ModuleContext {
748
770
  private pushEventFn: (event: ProcessEvent, moduleName?: string) => void;
749
771
  private onTraceFn: (listener: TraceEventListener) => () => void;
750
772
  private callToolFn: (call: ToolCall) => Promise<ToolResult>;
773
+ /** Offered only when the registry was given the framework's lookups, so
774
+ * a module can tell a framework that has them from one that hasn't. */
775
+ readonly windowStatusOf?: (id: MessageId, opts?: { forAgent?: string }) => WindowStatus;
776
+ readonly observes?: (observer: string, observed: string) => boolean;
777
+ readonly viewKeeps?: (row: StoredMessage, opts?: { forAgent?: string }) => boolean;
778
+ readonly agentNameOf?: (contextManager: ContextManager) => string | undefined;
751
779
 
752
780
  // External ID mapping stored in module state
753
781
  private externalIdMap: Map<string, MessageId> = new Map();
@@ -794,6 +822,14 @@ class ModuleContextImpl implements ModuleContext {
794
822
  this.pushEventFn = pushEvent;
795
823
  this.onTraceFn = onTrace;
796
824
  this.callToolFn = callTool;
825
+ const windowStatusOf = registry.windowStatusOfFn;
826
+ if (windowStatusOf) this.windowStatusOf = (id, opts) => windowStatusOf(id, opts);
827
+ const observes = registry.observesFn;
828
+ if (observes) this.observes = (observer, observed) => observes(observer, observed);
829
+ const viewKeeps = registry.viewKeepsFn;
830
+ if (viewKeeps) this.viewKeeps = (row, opts) => viewKeeps(row, opts);
831
+ const agentNameOf = registry.agentNameOfFn;
832
+ if (agentNameOf) this.agentNameOf = (contextManager) => agentNameOf(contextManager);
797
833
 
798
834
  // Load external ID map from state if exists
799
835
  const state = this.getState<{ externalIdMap?: Record<string, string> }>();
@@ -951,15 +987,35 @@ class ModuleContextImpl implements ModuleContext {
951
987
  throw new Error(`A message for agent ${JSON.stringify(opts.forAgent)} can't carry metadata.external: `
952
988
  + "its external id would be looked up in the primary's window. Leave forAgent out, or the external id.");
953
989
  }
954
- const id = this.addMessageFn(participant, content, metadata, opts);
990
+ let id: MessageId;
991
+ try {
992
+ id = this.addMessageFn(participant, content, metadata, opts);
993
+ } catch (error) {
994
+ // A write whose store threw where context-manager can't tell whether
995
+ // it landed (WriteOutcomeUnknownError, which the write is answered by)
996
+ // may be stored: its external id maps to '', as a write kept in memory
997
+ // does, so findMessageByExternalId looks it up in the store. A mapping
998
+ // that can't be persisted is logged, and the write's own error thrown.
999
+ if (metadata?.external && error instanceof WriteOutcomeUnknownError) {
1000
+ this.externalIdMap.set(`${metadata.external.source}:${metadata.external.id}`, '');
1001
+ try {
1002
+ this.persistExternalIdMap();
1003
+ } catch (persist) {
1004
+ console.error(`[module:${this.moduleName}] the external id of a write that may be stored could not be persisted:`, persist);
1005
+ }
1006
+ }
1007
+ throw error;
1008
+ }
955
1009
 
956
- // Track external ID if provided. A write the framework holds keeps '',
957
- // as it did before held writes had handles: the map is module state an
958
- // earlier release reads back, and a handle is no id to it.
959
- // findMessageByExternalId finds the held write by its external id.
1010
+ // Track external ID if provided: the stored id the write was given
1011
+ // (#291 stores every write at once), or '' for one kept in memory (a
1012
+ // surgery's hold, or the wait for its agent's recovery), as earlier
1013
+ // releases kept '' for a write they held.
1014
+ // findMessageByExternalId finds such a write by its external id once it
1015
+ // is stored.
960
1016
  if (metadata?.external) {
961
1017
  const key = `${metadata.external.source}:${metadata.external.id}`;
962
- this.externalIdMap.set(key, heldWriteId(id) === undefined ? id : '');
1018
+ this.externalIdMap.set(key, id);
963
1019
  // Persist the mapping
964
1020
  this.persistExternalIdMap();
965
1021
  }
@@ -991,15 +1047,16 @@ class ModuleContextImpl implements ModuleContext {
991
1047
  if (entry === undefined) return null;
992
1048
  // A stored id answers while the store holds its row, and once the row is
993
1049
  // gone the entry goes, as removeMessage drops it, except from a context
994
- // whose module has stopped, which keeps its mapping as it was. The '' a held
995
- // write keeps here (addMessage) names no row, so the message is looked up in
996
- // the store by its external id, held rows included, and the first row found
997
- // is taken, as context-manager's findByExternalId takes it: a held row
998
- // answers by its handle and leaves the entry as it is, and a stored row's id
999
- // becomes the entry. With nothing found, '' stays, as earlier releases kept
1000
- // it: in a module's start(), the writes the last process held don't show
1001
- // yet, since create() restores them after the modules start, and a write
1002
- // that shows later finds its entry.
1050
+ // whose module has stopped, which keeps its mapping as it was. A '' here
1051
+ // names no row: a write kept in memory (a surgery's hold, or the wait for
1052
+ // its agent's recovery), or one an earlier release held, whose map it
1053
+ // persisted with ''. So the message is looked up in the store by its
1054
+ // external id, and the first row found is taken, as context-manager's
1055
+ // findByExternalId takes it, and its id becomes the entry (but in a
1056
+ // stopped module's context). With nothing found, '' stays: in a module's
1057
+ // start(), a write an earlier release left queued isn't stored yet, since
1058
+ // create() imports those after the modules start, and a write that shows
1059
+ // later finds its entry.
1003
1060
  if (entry !== '') {
1004
1061
  if (this.getMessageFn(entry)) return entry;
1005
1062
  if (!this.retired) {
@@ -1009,7 +1066,6 @@ class ModuleContextImpl implements ModuleContext {
1009
1066
  return null;
1010
1067
  }
1011
1068
  const row = this.queryMessagesFn({ source, externalIds: [externalId] }).messages[0];
1012
- if (row?.held) return row.id;
1013
1069
  if (!row) return null;
1014
1070
  if (!this.retired) {
1015
1071
  this.externalIdMap.set(key, row.id);