@animalabs/agent-framework 0.23.3 → 0.24.1

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 (355) hide show
  1. package/README.md +212 -42
  2. package/dist/src/agent.d.ts +65 -9
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +98 -12
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/api/server.d.ts.map +1 -1
  7. package/dist/src/api/server.js +14 -12
  8. package/dist/src/api/server.js.map +1 -1
  9. package/dist/src/clock-rows.d.ts +115 -0
  10. package/dist/src/clock-rows.d.ts.map +1 -0
  11. package/dist/src/clock-rows.js +222 -0
  12. package/dist/src/clock-rows.js.map +1 -0
  13. package/dist/src/code-execution/engine.d.ts +177 -0
  14. package/dist/src/code-execution/engine.d.ts.map +1 -0
  15. package/dist/src/code-execution/engine.js +494 -0
  16. package/dist/src/code-execution/engine.js.map +1 -0
  17. package/dist/src/code-execution/index.d.ts +5 -10
  18. package/dist/src/code-execution/index.d.ts.map +1 -1
  19. package/dist/src/code-execution/index.js +5 -9
  20. package/dist/src/code-execution/index.js.map +1 -1
  21. package/dist/src/code-execution/isolate/calls.d.ts +114 -0
  22. package/dist/src/code-execution/isolate/calls.d.ts.map +1 -0
  23. package/dist/src/code-execution/isolate/calls.js +145 -0
  24. package/dist/src/code-execution/isolate/calls.js.map +1 -0
  25. package/dist/src/code-execution/isolate/child-entry.d.ts +2 -0
  26. package/dist/src/code-execution/isolate/child-entry.d.ts.map +1 -0
  27. package/dist/src/code-execution/isolate/child-entry.js +5 -0
  28. package/dist/src/code-execution/isolate/child-entry.js.map +1 -0
  29. package/dist/src/code-execution/isolate/child-main.d.ts +26 -0
  30. package/dist/src/code-execution/isolate/child-main.d.ts.map +1 -0
  31. package/dist/src/code-execution/isolate/child-main.js +132 -0
  32. package/dist/src/code-execution/isolate/child-main.js.map +1 -0
  33. package/dist/src/code-execution/isolate/child.d.ts +44 -0
  34. package/dist/src/code-execution/isolate/child.d.ts.map +1 -0
  35. package/dist/src/code-execution/isolate/child.js +315 -0
  36. package/dist/src/code-execution/isolate/child.js.map +1 -0
  37. package/dist/src/code-execution/isolate/frames.d.ts +80 -0
  38. package/dist/src/code-execution/isolate/frames.d.ts.map +1 -0
  39. package/dist/src/code-execution/isolate/frames.js +210 -0
  40. package/dist/src/code-execution/isolate/frames.js.map +1 -0
  41. package/dist/src/code-execution/isolate/output.d.ts +68 -0
  42. package/dist/src/code-execution/isolate/output.d.ts.map +1 -0
  43. package/dist/src/code-execution/isolate/output.js +143 -0
  44. package/dist/src/code-execution/isolate/output.js.map +1 -0
  45. package/dist/src/code-execution/isolate/prelude.d.ts +109 -0
  46. package/dist/src/code-execution/isolate/prelude.d.ts.map +1 -0
  47. package/dist/src/code-execution/isolate/prelude.js +401 -0
  48. package/dist/src/code-execution/isolate/prelude.js.map +1 -0
  49. package/dist/src/code-execution/isolate/protocol.d.ts +151 -0
  50. package/dist/src/code-execution/isolate/protocol.d.ts.map +1 -0
  51. package/dist/src/code-execution/isolate/protocol.js +150 -0
  52. package/dist/src/code-execution/isolate/protocol.js.map +1 -0
  53. package/dist/src/code-execution/isolate/render.d.ts +57 -0
  54. package/dist/src/code-execution/isolate/render.d.ts.map +1 -0
  55. package/dist/src/code-execution/isolate/render.js +214 -0
  56. package/dist/src/code-execution/isolate/render.js.map +1 -0
  57. package/dist/src/code-execution/isolate/runner.d.ts +250 -0
  58. package/dist/src/code-execution/isolate/runner.d.ts.map +1 -0
  59. package/dist/src/code-execution/isolate/runner.js +854 -0
  60. package/dist/src/code-execution/isolate/runner.js.map +1 -0
  61. package/dist/src/code-execution/isolate/scripts.d.ts +175 -0
  62. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -0
  63. package/dist/src/code-execution/isolate/scripts.js +357 -0
  64. package/dist/src/code-execution/isolate/scripts.js.map +1 -0
  65. package/dist/src/code-execution/quickjs.wasm +0 -0
  66. package/dist/src/code-execution/tool-definition.d.ts +93 -43
  67. package/dist/src/code-execution/tool-definition.d.ts.map +1 -1
  68. package/dist/src/code-execution/tool-definition.js +176 -142
  69. package/dist/src/code-execution/tool-definition.js.map +1 -1
  70. package/dist/src/deadline-timer.d.ts +3 -0
  71. package/dist/src/deadline-timer.d.ts.map +1 -1
  72. package/dist/src/deadline-timer.js +1 -1
  73. package/dist/src/deadline-timer.js.map +1 -1
  74. package/dist/src/framework.d.ts +1120 -457
  75. package/dist/src/framework.d.ts.map +1 -1
  76. package/dist/src/framework.js +4635 -2505
  77. package/dist/src/framework.js.map +1 -1
  78. package/dist/src/gate/event-gate.d.ts +28 -4
  79. package/dist/src/gate/event-gate.d.ts.map +1 -1
  80. package/dist/src/gate/event-gate.js +89 -13
  81. package/dist/src/gate/event-gate.js.map +1 -1
  82. package/dist/src/held-writes.d.ts +16 -3
  83. package/dist/src/held-writes.d.ts.map +1 -1
  84. package/dist/src/held-writes.js +16 -3
  85. package/dist/src/held-writes.js.map +1 -1
  86. package/dist/src/index.d.ts +8 -6
  87. package/dist/src/index.d.ts.map +1 -1
  88. package/dist/src/index.js +10 -8
  89. package/dist/src/index.js.map +1 -1
  90. package/dist/src/mcpl/channel-registry.d.ts +483 -115
  91. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  92. package/dist/src/mcpl/channel-registry.js +1735 -425
  93. package/dist/src/mcpl/channel-registry.js.map +1 -1
  94. package/dist/src/mcpl/conversation-router.d.ts +19 -39
  95. package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
  96. package/dist/src/mcpl/conversation-router.js +27 -59
  97. package/dist/src/mcpl/conversation-router.js.map +1 -1
  98. package/dist/src/mcpl/convert-block.d.ts.map +1 -1
  99. package/dist/src/mcpl/convert-block.js +9 -5
  100. package/dist/src/mcpl/convert-block.js.map +1 -1
  101. package/dist/src/mcpl/inbound-source.d.ts +50 -0
  102. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  103. package/dist/src/mcpl/inbound-source.js +130 -0
  104. package/dist/src/mcpl/inbound-source.js.map +1 -1
  105. package/dist/src/mcpl/index.d.ts +2 -1
  106. package/dist/src/mcpl/index.d.ts.map +1 -1
  107. package/dist/src/mcpl/index.js +3 -2
  108. package/dist/src/mcpl/index.js.map +1 -1
  109. package/dist/src/mcpl/log-value.d.ts +6 -0
  110. package/dist/src/mcpl/log-value.d.ts.map +1 -1
  111. package/dist/src/mcpl/log-value.js +8 -0
  112. package/dist/src/mcpl/log-value.js.map +1 -1
  113. package/dist/src/mcpl/modern-connection.d.ts +15 -6
  114. package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
  115. package/dist/src/mcpl/modern-connection.js +168 -53
  116. package/dist/src/mcpl/modern-connection.js.map +1 -1
  117. package/dist/src/mcpl/prose-grammar.d.ts +4 -5
  118. package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
  119. package/dist/src/mcpl/prose-grammar.js +4 -5
  120. package/dist/src/mcpl/prose-grammar.js.map +1 -1
  121. package/dist/src/mcpl/protocol-family.d.ts +97 -10
  122. package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
  123. package/dist/src/mcpl/protocol-family.js +174 -17
  124. package/dist/src/mcpl/protocol-family.js.map +1 -1
  125. package/dist/src/mcpl/push-coalescer.d.ts +132 -14
  126. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  127. package/dist/src/mcpl/push-coalescer.js +227 -50
  128. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  129. package/dist/src/mcpl/push-handler.d.ts +9 -20
  130. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  131. package/dist/src/mcpl/push-handler.js +7 -49
  132. package/dist/src/mcpl/push-handler.js.map +1 -1
  133. package/dist/src/mcpl/reference-fetcher.d.ts +2 -2
  134. package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
  135. package/dist/src/mcpl/reference-fetcher.js +4 -4
  136. package/dist/src/mcpl/reference-fetcher.js.map +1 -1
  137. package/dist/src/mcpl/server-connection.d.ts +50 -21
  138. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  139. package/dist/src/mcpl/server-connection.js +158 -74
  140. package/dist/src/mcpl/server-connection.js.map +1 -1
  141. package/dist/src/mcpl/tags.d.ts +24 -0
  142. package/dist/src/mcpl/tags.d.ts.map +1 -1
  143. package/dist/src/mcpl/tags.js +33 -0
  144. package/dist/src/mcpl/tags.js.map +1 -1
  145. package/dist/src/mcpl/tool-result-normalize.d.ts +2 -1
  146. package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
  147. package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
  148. package/dist/src/mcpl/transport.d.ts +55 -7
  149. package/dist/src/mcpl/transport.d.ts.map +1 -1
  150. package/dist/src/mcpl/transport.js +163 -34
  151. package/dist/src/mcpl/transport.js.map +1 -1
  152. package/dist/src/mcpl/types.d.ts +22 -6
  153. package/dist/src/mcpl/types.d.ts.map +1 -1
  154. package/dist/src/mcpl/types.js.map +1 -1
  155. package/dist/src/module-registry.d.ts +4 -2
  156. package/dist/src/module-registry.d.ts.map +1 -1
  157. package/dist/src/module-registry.js +100 -13
  158. package/dist/src/module-registry.js.map +1 -1
  159. package/dist/src/modules/discord/index.d.ts.map +1 -1
  160. package/dist/src/modules/discord/index.js +8 -13
  161. package/dist/src/modules/discord/index.js.map +1 -1
  162. package/dist/src/modules/history/index.d.ts.map +1 -1
  163. package/dist/src/modules/history/index.js +27 -4
  164. package/dist/src/modules/history/index.js.map +1 -1
  165. package/dist/src/modules/history/semantic.d.ts +15 -3
  166. package/dist/src/modules/history/semantic.d.ts.map +1 -1
  167. package/dist/src/modules/history/semantic.js +27 -5
  168. package/dist/src/modules/history/semantic.js.map +1 -1
  169. package/dist/src/modules/index.d.ts +1 -1
  170. package/dist/src/modules/index.d.ts.map +1 -1
  171. package/dist/src/modules/index.js.map +1 -1
  172. package/dist/src/modules/unknown-tool.d.ts +4 -1
  173. package/dist/src/modules/unknown-tool.d.ts.map +1 -1
  174. package/dist/src/modules/unknown-tool.js +4 -1
  175. package/dist/src/modules/unknown-tool.js.map +1 -1
  176. package/dist/src/modules/workspace/branch-intent.d.ts +3 -1
  177. package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
  178. package/dist/src/modules/workspace/branch-intent.js +3 -1
  179. package/dist/src/modules/workspace/branch-intent.js.map +1 -1
  180. package/dist/src/modules/workspace/edit-plan.d.ts +265 -0
  181. package/dist/src/modules/workspace/edit-plan.d.ts.map +1 -0
  182. package/dist/src/modules/workspace/edit-plan.js +794 -0
  183. package/dist/src/modules/workspace/edit-plan.js.map +1 -0
  184. package/dist/src/modules/workspace/edit-text.d.ts +117 -0
  185. package/dist/src/modules/workspace/edit-text.d.ts.map +1 -0
  186. package/dist/src/modules/workspace/edit-text.js +584 -0
  187. package/dist/src/modules/workspace/edit-text.js.map +1 -0
  188. package/dist/src/modules/workspace/effects.d.ts +5 -4
  189. package/dist/src/modules/workspace/effects.d.ts.map +1 -1
  190. package/dist/src/modules/workspace/effects.js +78 -25
  191. package/dist/src/modules/workspace/effects.js.map +1 -1
  192. package/dist/src/modules/workspace/index.d.ts +493 -62
  193. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  194. package/dist/src/modules/workspace/index.js +2216 -652
  195. package/dist/src/modules/workspace/index.js.map +1 -1
  196. package/dist/src/modules/workspace/observe.d.ts +213 -38
  197. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  198. package/dist/src/modules/workspace/observe.js +416 -36
  199. package/dist/src/modules/workspace/observe.js.map +1 -1
  200. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  201. package/dist/src/modules/workspace/reconcile.js +15 -8
  202. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  203. package/dist/src/modules/workspace/text.d.ts +32 -0
  204. package/dist/src/modules/workspace/text.d.ts.map +1 -0
  205. package/dist/src/modules/workspace/text.js +67 -0
  206. package/dist/src/modules/workspace/text.js.map +1 -0
  207. package/dist/src/modules/workspace/types.d.ts +210 -6
  208. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  209. package/dist/src/modules/workspace/types.js.map +1 -1
  210. package/dist/src/modules/workspace/watcher.d.ts +3 -2
  211. package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
  212. package/dist/src/modules/workspace/watcher.js.map +1 -1
  213. package/dist/src/operator-log.d.ts +52 -24
  214. package/dist/src/operator-log.d.ts.map +1 -1
  215. package/dist/src/operator-log.js.map +1 -1
  216. package/dist/src/recovery/discord-awareness-outbox.d.ts +496 -72
  217. package/dist/src/recovery/discord-awareness-outbox.d.ts.map +1 -1
  218. package/dist/src/recovery/discord-awareness-outbox.js +1196 -289
  219. package/dist/src/recovery/discord-awareness-outbox.js.map +1 -1
  220. package/dist/src/recovery/offline-branch.d.ts +26 -1
  221. package/dist/src/recovery/offline-branch.d.ts.map +1 -1
  222. package/dist/src/recovery/offline-branch.js +164 -39
  223. package/dist/src/recovery/offline-branch.js.map +1 -1
  224. package/dist/src/recovery/recover-cli.js +23 -4
  225. package/dist/src/recovery/recover-cli.js.map +1 -1
  226. package/dist/src/send-tools.d.ts +11 -0
  227. package/dist/src/send-tools.d.ts.map +1 -0
  228. package/dist/src/send-tools.js +11 -0
  229. package/dist/src/send-tools.js.map +1 -0
  230. package/dist/src/timezone.d.ts +4 -2
  231. package/dist/src/timezone.d.ts.map +1 -1
  232. package/dist/src/timezone.js +4 -2
  233. package/dist/src/timezone.js.map +1 -1
  234. package/dist/src/tool-image-ledger.d.ts +46 -7
  235. package/dist/src/tool-image-ledger.d.ts.map +1 -1
  236. package/dist/src/tool-image-ledger.js +60 -7
  237. package/dist/src/tool-image-ledger.js.map +1 -1
  238. package/dist/src/tool-result-guard.d.ts +14 -11
  239. package/dist/src/tool-result-guard.d.ts.map +1 -1
  240. package/dist/src/tool-result-guard.js +17 -14
  241. package/dist/src/tool-result-guard.js.map +1 -1
  242. package/dist/src/tool-result-history.d.ts +3 -2
  243. package/dist/src/tool-result-history.d.ts.map +1 -1
  244. package/dist/src/tool-result-history.js +3 -2
  245. package/dist/src/tool-result-history.js.map +1 -1
  246. package/dist/src/tune-out/coordinator.d.ts +21 -0
  247. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  248. package/dist/src/tune-out/coordinator.js +142 -40
  249. package/dist/src/tune-out/coordinator.js.map +1 -1
  250. package/dist/src/types/agent.d.ts +31 -6
  251. package/dist/src/types/agent.d.ts.map +1 -1
  252. package/dist/src/types/events.d.ts +66 -9
  253. package/dist/src/types/events.d.ts.map +1 -1
  254. package/dist/src/types/framework.d.ts +69 -62
  255. package/dist/src/types/framework.d.ts.map +1 -1
  256. package/dist/src/types/module.d.ts +40 -8
  257. package/dist/src/types/module.d.ts.map +1 -1
  258. package/dist/src/types/trace.d.ts +111 -10
  259. package/dist/src/types/trace.d.ts.map +1 -1
  260. package/dist/src/usage/types.d.ts +16 -0
  261. package/dist/src/usage/types.d.ts.map +1 -1
  262. package/dist/src/usage/usage-tracker.d.ts +14 -1
  263. package/dist/src/usage/usage-tracker.d.ts.map +1 -1
  264. package/dist/src/usage/usage-tracker.js +81 -41
  265. package/dist/src/usage/usage-tracker.js.map +1 -1
  266. package/package.json +6 -8
  267. package/src/agent.ts +99 -12
  268. package/src/api/server.ts +14 -12
  269. package/src/clock-rows.ts +302 -0
  270. package/src/code-execution/engine.ts +595 -0
  271. package/src/code-execution/index.ts +5 -17
  272. package/src/code-execution/isolate/calls.ts +199 -0
  273. package/src/code-execution/isolate/child-entry.ts +5 -0
  274. package/src/code-execution/isolate/child-main.ts +132 -0
  275. package/src/code-execution/isolate/child.ts +327 -0
  276. package/src/code-execution/isolate/frames.ts +209 -0
  277. package/src/code-execution/isolate/output.ts +161 -0
  278. package/src/code-execution/isolate/prelude.ts +409 -0
  279. package/src/code-execution/isolate/protocol.ts +240 -0
  280. package/src/code-execution/isolate/render.ts +230 -0
  281. package/src/code-execution/isolate/runner.ts +911 -0
  282. package/src/code-execution/isolate/scripts.ts +479 -0
  283. package/src/code-execution/quickjs.wasm +0 -0
  284. package/src/code-execution/quickjs.wasm.LICENSES +149 -0
  285. package/src/code-execution/tool-definition.ts +236 -167
  286. package/src/deadline-timer.ts +1 -1
  287. package/src/framework.ts +4978 -2671
  288. package/src/gate/event-gate.ts +79 -17
  289. package/src/held-writes.ts +17 -3
  290. package/src/index.ts +32 -22
  291. package/src/mcpl/channel-registry.ts +1892 -471
  292. package/src/mcpl/conversation-router.ts +26 -72
  293. package/src/mcpl/convert-block.ts +9 -5
  294. package/src/mcpl/inbound-source.ts +131 -0
  295. package/src/mcpl/index.ts +4 -2
  296. package/src/mcpl/log-value.ts +9 -0
  297. package/src/mcpl/modern-connection.ts +162 -53
  298. package/src/mcpl/prose-grammar.ts +4 -5
  299. package/src/mcpl/protocol-family.ts +200 -22
  300. package/src/mcpl/push-coalescer.ts +306 -62
  301. package/src/mcpl/push-handler.ts +12 -54
  302. package/src/mcpl/reference-fetcher.ts +4 -4
  303. package/src/mcpl/server-connection.ts +180 -79
  304. package/src/mcpl/tags.ts +36 -0
  305. package/src/mcpl/tool-result-normalize.ts +2 -1
  306. package/src/mcpl/transport.ts +162 -33
  307. package/src/mcpl/types.ts +23 -6
  308. package/src/module-registry.ts +92 -13
  309. package/src/modules/discord/index.ts +8 -13
  310. package/src/modules/history/index.ts +25 -3
  311. package/src/modules/history/semantic.ts +29 -6
  312. package/src/modules/index.ts +1 -0
  313. package/src/modules/unknown-tool.ts +4 -1
  314. package/src/modules/workspace/branch-intent.ts +3 -1
  315. package/src/modules/workspace/edit-plan.ts +954 -0
  316. package/src/modules/workspace/edit-text.ts +618 -0
  317. package/src/modules/workspace/effects.ts +70 -19
  318. package/src/modules/workspace/index.ts +2293 -650
  319. package/src/modules/workspace/observe.ts +465 -56
  320. package/src/modules/workspace/reconcile.ts +14 -7
  321. package/src/modules/workspace/text.ts +68 -0
  322. package/src/modules/workspace/types.ts +211 -6
  323. package/src/modules/workspace/watcher.ts +3 -2
  324. package/src/operator-log.ts +47 -19
  325. package/src/recovery/discord-awareness-outbox.ts +1500 -356
  326. package/src/recovery/offline-branch.ts +189 -55
  327. package/src/recovery/recover-cli.ts +25 -4
  328. package/src/send-tools.ts +11 -0
  329. package/src/timezone.ts +4 -2
  330. package/src/tool-image-ledger.ts +62 -8
  331. package/src/tool-result-guard.ts +18 -15
  332. package/src/tool-result-history.ts +3 -2
  333. package/src/tune-out/coordinator.ts +166 -45
  334. package/src/types/agent.ts +32 -6
  335. package/src/types/events.ts +66 -9
  336. package/src/types/framework.ts +69 -62
  337. package/src/types/module.ts +40 -8
  338. package/src/types/trace.ts +121 -15
  339. package/src/usage/types.ts +16 -0
  340. package/src/usage/usage-tracker.ts +86 -43
  341. package/dist/src/code-execution/py-runner.d.ts +0 -191
  342. package/dist/src/code-execution/py-runner.d.ts.map +0 -1
  343. package/dist/src/code-execution/py-runner.js +0 -655
  344. package/dist/src/code-execution/py-runner.js.map +0 -1
  345. package/dist/src/code-execution/runtime-py.d.ts +0 -50
  346. package/dist/src/code-execution/runtime-py.d.ts.map +0 -1
  347. package/dist/src/code-execution/runtime-py.js +0 -677
  348. package/dist/src/code-execution/runtime-py.js.map +0 -1
  349. package/dist/src/mcpl/prose-stream-router.d.ts +0 -88
  350. package/dist/src/mcpl/prose-stream-router.d.ts.map +0 -1
  351. package/dist/src/mcpl/prose-stream-router.js +0 -291
  352. package/dist/src/mcpl/prose-stream-router.js.map +0 -1
  353. package/src/code-execution/py-runner.ts +0 -791
  354. package/src/code-execution/runtime-py.ts +0 -677
  355. package/src/mcpl/prose-stream-router.ts +0 -268
@@ -16,10 +16,10 @@
16
16
  * - Everything else is left unrouted and dropped by the framework — the
17
17
  * trunk is a dormant template, not a listener.
18
18
  *
19
- * Bindings expire after an idle TTL. Expiry runs a final closure turn on the
20
- * fork (see framework wiring) and unbinds; the next qualifying message on
21
- * that channel spawns a *fresh* fork (generation + 1) from the current
22
- * trunk, so handbook/template updates propagate between engagements.
19
+ * Bindings expire after an idle TTL. Expiry unbinds the channel and runs a
20
+ * final closure turn on the fork (see framework wiring); the next qualifying
21
+ * message on that channel spawns a *fresh* fork (generation + 1) from the
22
+ * current trunk, so handbook/template updates propagate between engagements.
23
23
  *
24
24
  * The binding table is in-memory — bindings are re-established by the next
25
25
  * qualifying message after a restart. The generation counters, by contrast,
@@ -93,10 +93,6 @@ export interface ConversationRouterConfig {
93
93
  }
94
94
  export interface ConversationBinding {
95
95
  channelId: string;
96
- /** The channel's MCPL server, where the binding was made with one: channel
97
- * ids are unique only within one server's connection (MCPL §14.2), so each
98
- * server's channel has its own binding. */
99
- serverId?: string;
100
96
  agentName: string;
101
97
  /** Engagement counter per channel — fresh forks get a new generation. */
102
98
  generation: number;
@@ -143,14 +139,10 @@ export declare const DEFAULT_CLOSURE_PROMPT: string;
143
139
  */
144
140
  export declare class ConversationRouter {
145
141
  private config;
146
- /** Active bindings, keyed by the channel's server and id (bindingKey):
147
- * two servers' channels with one id are two conversations. */
142
+ /** Active bindings, keyed by channelId. */
148
143
  private bindings;
149
- /** Engagement counter per channel id — survives unbind, so a re-bound
150
- * channel gets a distinct fork agent name. Kept by bare id, as it's
151
- * persisted: two servers sharing an id share a counter, which still never
152
- * repeats a name, and their forks' names differ anyway, since each hashes
153
- * its server (forkAgentName). */
144
+ /** Engagement counter per channel — survives unbind, so a re-bound channel
145
+ * gets a distinct fork agent name. */
154
146
  private generations;
155
147
  constructor(config: ConversationRouterConfig);
156
148
  get templateAgent(): string;
@@ -168,26 +160,20 @@ export declare class ConversationRouter {
168
160
  * Record a binding after the framework successfully spawned the fork.
169
161
  * Returns the new binding.
170
162
  */
171
- bind(channel: string | ConversationChannel, agentName: string, generation: number, now?: number): ConversationBinding;
163
+ bind(channelId: string, agentName: string, generation: number, now?: number): ConversationBinding;
172
164
  /** Record delivered activity on an existing binding. Does not bind a
173
165
  * channel or advance its generation. Call after successful delivery, not
174
166
  * when previewing a route. The optional clock supports deterministic use. */
175
- touch(channel: string | ConversationChannel, now?: number): void;
176
- unbind(channel: string | ConversationChannel): void;
177
- getBinding(channel: string | ConversationChannel): ConversationBinding | undefined;
178
- /**
179
- * The binding a caller names, with its key. A channel given with its server
180
- * names that server's binding only. A bare id, as callers gave it before
181
- * bindings had servers, names the binding made with no server, else the one
182
- * binding for that id; where several servers' channels with that id are
183
- * bound, it names none.
184
- */
185
- private findBinding;
167
+ touch(channelId: string, now?: number): void;
168
+ unbind(channelId: string): void;
169
+ getBinding(channelId: string): ConversationBinding | undefined;
186
170
  /** Reverse lookup: the channel an agent is bound to, if any. */
187
171
  channelForAgent(agentName: string): string | undefined;
188
172
  getBindings(): ConversationBinding[];
189
- /** Bindings whose idle TTL has elapsed. Does not unbind — the framework
190
- * runs the closure turn first, then calls unbind(). */
173
+ /** Bindings whose idle TTL has elapsed. Does not unbind: the framework
174
+ * unbinds each one first, so the channel's next message goes to a newer
175
+ * fork, or nowhere, and then runs the old fork's closure turn
176
+ * (sweepExpiredConversations). */
191
177
  expired(now?: number): ConversationBinding[];
192
178
  /**
193
179
  * Classify a channel from its descriptor and/or message metadata. Slack
@@ -200,19 +186,13 @@ export declare class ConversationRouter {
200
186
  * survive restarts, or a re-engaged channel reuses generation 1's name and
201
187
  * reopens (and re-seeds) the previous engagement's Chronicle namespace. */
202
188
  exportGenerations(): Record<string, number>;
203
- /** Restore persisted engagement counters (see exportGenerations). */
189
+ /** Raise each channel's engagement counter to at least the given
190
+ * generation, never lowering one: the persisted counters at startup (see
191
+ * exportGenerations), or a spawn's generation whose fork ended before the
192
+ * spawn could bind it. */
204
193
  hydrateGenerations(generations: Record<string, number>): void;
205
194
  private shouldTrigger;
206
195
  }
207
- /**
208
- * A channel as the router's bindings take it: its id, with the MCPL server it
209
- * belongs to where the caller has one. A bare id, as callers gave it before,
210
- * is the channel with no server.
211
- */
212
- export interface ConversationChannel {
213
- channelId: string;
214
- serverId?: string;
215
- }
216
196
  /**
217
197
  * A fork's agent name: `<prefix>-<readable>-g<generation>-<hash>`, such as
218
198
  * `conversation-C123-g2-e08e564271867d16` for Slack's channel `C123` on the
@@ -1 +1 @@
1
- {"version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KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe,CA2BlD;IAED;;;OAGG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,mBAAmB,CAWpG;IAED;;iFAE6E;IAC7E,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,IAAI,CAG/C;IAED,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9B;IAED,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAE7D;IAED,gEAAgE;IAChE,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKrD;IAED,WAAW,IAAI,mBAAmB,EAAE,CAEnC;IAED;;;sCAGkC;IAClC,OAAO,CAAC,GAAG,SAAa,GAAG,mBAAmB,EAAE,CAG/C;IAMD;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CACpB,UAAU,CAAC,EAAE,iBAAiB,EAC9B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,WAAW,CAQb;IAED;;+EAE2E;IAC3E,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE1C;IAED;;;8BAG0B;IAC1B,kBAAkB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAM5D;IAED,OAAO,CAAC,aAAa;CAKtB;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAIzH"}
@@ -16,10 +16,10 @@
16
16
  * - Everything else is left unrouted and dropped by the framework — the
17
17
  * trunk is a dormant template, not a listener.
18
18
  *
19
- * Bindings expire after an idle TTL. Expiry runs a final closure turn on the
20
- * fork (see framework wiring) and unbinds; the next qualifying message on
21
- * that channel spawns a *fresh* fork (generation + 1) from the current
22
- * trunk, so handbook/template updates propagate between engagements.
19
+ * Bindings expire after an idle TTL. Expiry unbinds the channel and runs a
20
+ * final closure turn on the fork (see framework wiring); the next qualifying
21
+ * message on that channel spawns a *fresh* fork (generation + 1) from the
22
+ * current trunk, so handbook/template updates propagate between engagements.
23
23
  *
24
24
  * The binding table is in-memory — bindings are re-established by the next
25
25
  * qualifying message after a restart. The generation counters, by contrast,
@@ -55,14 +55,10 @@ export const DEFAULT_CLOSURE_PROMPT = '[system] This engagement is closing due t
55
55
  */
56
56
  export class ConversationRouter {
57
57
  config;
58
- /** Active bindings, keyed by the channel's server and id (bindingKey):
59
- * two servers' channels with one id are two conversations. */
58
+ /** Active bindings, keyed by channelId. */
60
59
  bindings = new Map();
61
- /** Engagement counter per channel id — survives unbind, so a re-bound
62
- * channel gets a distinct fork agent name. Kept by bare id, as it's
63
- * persisted: two servers sharing an id share a counter, which still never
64
- * repeats a name, and their forks' names differ anyway, since each hashes
65
- * its server (forkAgentName). */
60
+ /** Engagement counter per channel — survives unbind, so a re-bound channel
61
+ * gets a distinct fork agent name. */
66
62
  generations = new Map();
67
63
  constructor(config) {
68
64
  this.config = config;
@@ -86,7 +82,7 @@ export class ConversationRouter {
86
82
  * unchanged; a failed spawn doesn't leave a dangling route.
87
83
  */
88
84
  route(facts) {
89
- const existing = this.bindings.get(bindingKey(facts));
85
+ const existing = this.bindings.get(facts.channelId);
90
86
  if (existing) {
91
87
  return {
92
88
  kind: 'existing',
@@ -112,57 +108,31 @@ export class ConversationRouter {
112
108
  * Record a binding after the framework successfully spawned the fork.
113
109
  * Returns the new binding.
114
110
  */
115
- bind(channel, agentName, generation, now = Date.now()) {
116
- const { channelId, serverId } = asChannel(channel);
117
- // The counter is kept by bare id, and two servers' spawns on one id can
118
- // run beside each other, so a bind can finish after a later spawn's: the
119
- // counter keeps the higher, or the next spawn would propose a fork name
120
- // already used.
121
- this.generations.set(channelId, Math.max(this.generations.get(channelId) ?? 0, generation));
111
+ bind(channelId, agentName, generation, now = Date.now()) {
112
+ this.generations.set(channelId, generation);
122
113
  const binding = {
123
114
  channelId,
124
- ...(serverId !== undefined ? { serverId } : {}),
125
115
  agentName,
126
116
  generation,
127
117
  boundAt: now,
128
118
  lastActivity: now,
129
119
  };
130
- this.bindings.set(bindingKey({ channelId, serverId }), binding);
120
+ this.bindings.set(channelId, binding);
131
121
  return binding;
132
122
  }
133
123
  /** Record delivered activity on an existing binding. Does not bind a
134
124
  * channel or advance its generation. Call after successful delivery, not
135
125
  * when previewing a route. The optional clock supports deterministic use. */
136
- touch(channel, now = Date.now()) {
137
- const found = this.findBinding(channel);
138
- if (found)
139
- found[1].lastActivity = now;
126
+ touch(channelId, now = Date.now()) {
127
+ const binding = this.bindings.get(channelId);
128
+ if (binding)
129
+ binding.lastActivity = now;
140
130
  }
141
- unbind(channel) {
142
- const found = this.findBinding(channel);
143
- if (found)
144
- this.bindings.delete(found[0]);
131
+ unbind(channelId) {
132
+ this.bindings.delete(channelId);
145
133
  }
146
- getBinding(channel) {
147
- return this.findBinding(channel)?.[1];
148
- }
149
- /**
150
- * The binding a caller names, with its key. A channel given with its server
151
- * names that server's binding only. A bare id, as callers gave it before
152
- * bindings had servers, names the binding made with no server, else the one
153
- * binding for that id; where several servers' channels with that id are
154
- * bound, it names none.
155
- */
156
- findBinding(channel) {
157
- const named = asChannel(channel);
158
- const key = bindingKey(named);
159
- const exact = this.bindings.get(key);
160
- if (exact)
161
- return [key, exact];
162
- if (named.serverId !== undefined)
163
- return undefined;
164
- const matches = [...this.bindings.entries()].filter(([, b]) => b.channelId === named.channelId);
165
- return matches.length === 1 ? matches[0] : undefined;
134
+ getBinding(channelId) {
135
+ return this.bindings.get(channelId);
166
136
  }
167
137
  /** Reverse lookup: the channel an agent is bound to, if any. */
168
138
  channelForAgent(agentName) {
@@ -175,8 +145,10 @@ export class ConversationRouter {
175
145
  getBindings() {
176
146
  return Array.from(this.bindings.values());
177
147
  }
178
- /** Bindings whose idle TTL has elapsed. Does not unbind — the framework
179
- * runs the closure turn first, then calls unbind(). */
148
+ /** Bindings whose idle TTL has elapsed. Does not unbind: the framework
149
+ * unbinds each one first, so the channel's next message goes to a newer
150
+ * fork, or nowhere, and then runs the old fork's closure turn
151
+ * (sweepExpiredConversations). */
180
152
  expired(now = Date.now()) {
181
153
  const ttl = this.idleTtlMs;
182
154
  return this.getBindings().filter((b) => now - b.lastActivity >= ttl);
@@ -209,7 +181,10 @@ export class ConversationRouter {
209
181
  exportGenerations() {
210
182
  return Object.fromEntries(this.generations);
211
183
  }
212
- /** Restore persisted engagement counters (see exportGenerations). */
184
+ /** Raise each channel's engagement counter to at least the given
185
+ * generation, never lowering one: the persisted counters at startup (see
186
+ * exportGenerations), or a spawn's generation whose fork ended before the
187
+ * spawn could bind it. */
213
188
  hydrateGenerations(generations) {
214
189
  for (const [channelId, generation] of Object.entries(generations)) {
215
190
  if (typeof generation === 'number' && generation > (this.generations.get(channelId) ?? 0)) {
@@ -223,13 +198,6 @@ export class ConversationRouter {
223
198
  return rule === 'always' || facts.mentioned;
224
199
  }
225
200
  }
226
- function asChannel(channel) {
227
- return typeof channel === 'string' ? { channelId: channel } : channel;
228
- }
229
- /** A binding's key: its channel's server and id, unambiguous whatever either holds. */
230
- function bindingKey(channel) {
231
- return JSON.stringify([channel.serverId ?? null, channel.channelId]);
232
- }
233
201
  /** The readable part of a fork's name stops here: uniqueness rides on the hash. */
234
202
  const FORK_NAME_READABLE_MAX = 64;
235
203
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-router.js","sourceRoot":"","sources":["../../../src/mcpl/conversation-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqBzC,gFAAgF;AAChF,MAAM,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AC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3G,OAAO,GAAG,MAAM,IAAI,QAAQ,KAAK,UAAU,IAAI,IAAI,EAAE,CAAC;AACxD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"convert-block.d.ts","sourceRoot":"","sources":["../../../src/mcpl/convert-block.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAYxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAiExG"}
1
+ {"version":3,"file":"convert-block.d.ts","sourceRoot":"","sources":["../../../src/mcpl/convert-block.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAYxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAqExG"}
@@ -29,9 +29,12 @@ export function convertBlock(block, provenance, serverId) {
29
29
  // closed, withhold the data (checked BEFORE the data branch).
30
30
  return { type: 'text', text: INLINE_WITHHELD_TEXT };
31
31
  }
32
- if (isFilledString(block.uri) && block.disposition) {
32
+ if (isFilledString(block.uri) && block.disposition !== undefined) {
33
33
  // RFC-005 uri-form media with a disposition claim: stub, do not
34
- // hand the URI to the provider or inline it.
34
+ // hand the URI to the provider or inline it. Any disposition given
35
+ // is a claim, one the reference rejects included, as classifyBlock
36
+ // and isInlineContradiction read it: a falsy one such as 0, false
37
+ // or '' stubs too, rather than sending the URI as the image's source.
35
38
  return { type: 'text', text: referenceStubOrNull(block, provenance, serverId) ?? '[reference]' };
36
39
  }
37
40
  if (isFilledString(block.data) && isFilledString(block.mimeType)) {
@@ -53,9 +56,10 @@ export function convertBlock(block, provenance, serverId) {
53
56
  // closed, withhold the data (checked BEFORE the data branch).
54
57
  return { type: 'text', text: INLINE_WITHHELD_TEXT };
55
58
  }
56
- if (isFilledString(block.uri) && block.disposition) {
57
- // RFC-005 uri-form media with a disposition claim: stub, do not
58
- // hand the URI to the provider or inline it.
59
+ if (isFilledString(block.uri) && block.disposition !== undefined) {
60
+ // RFC-005 uri-form media with a disposition claim, a falsy one
61
+ // included, as for an image (above): stub, do not hand the URI to
62
+ // the provider or inline it.
59
63
  return { type: 'text', text: referenceStubOrNull(block, provenance, serverId) ?? '[reference]' };
60
64
  }
61
65
  if (isFilledString(block.data) && isFilledString(block.mimeType)) {
@@ -1 +1 @@
1
- {"version":3,"file":"convert-block.js","sourceRoot":"","sources":["../../../src/mcpl/convert-block.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAuB,EAAE,UAAkB,EAAE,QAAgB;IACxF,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,qEAAqE;YACrE,kEAAkE;YAClE,8DAA8D;YAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,2BAA2B,EAAE,CAAC;QAE3G,KAAK,OAAO;YACV,IAA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QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE;iBACxD,CAAC;YACpB,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;QAE5G,KAAK,UAAU;YACb,kEAAkE;YAClE,oEAAoE;YACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC;QAEnG,SAAS,CAAC;YACR,qEAAqE;YACrE,uEAAuE;YACvE,oEAAoE;YACpE,+BAA+B;YAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;4CAG4C;AAC5C,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC;AACnD,CAAC"}
@@ -111,4 +111,54 @@ export declare function readInboundSource(metadata: unknown): InboundSource | un
111
111
  * one of them could contain: two keys are equal only for the same parts.
112
112
  */
113
113
  export declare function conversationKey(source: InboundSource): string | undefined;
114
+ /**
115
+ * JSON with object keys sorted at every level, written as the store's append
116
+ * keeps a value (its native UTF-8 write, which the real-store digest table
117
+ * checks): an `undefined` object entry is dropped; a string is well-formed
118
+ * (each lone surrogate comes back as U+FFFD); and an entry whose key isn't
119
+ * well-formed is dropped (the store doesn't keep it). An `undefined` array
120
+ * element is written as `null`, as JSON writes it: the store's append
121
+ * refuses a body holding one, so no stored copy does. So a value
122
+ * hashes alike however its keys were ordered (content read back from the
123
+ * store has them in a different order than it was written), and alike
124
+ * before and after the store. editMessage writes JSON instead, so an edited
125
+ * copy can keep what an append wouldn't; it has changed anyway.
126
+ *
127
+ * It expects JSON-shaped values, as the MCPL lanes deliver them (parsed from
128
+ * JSON). Any other object is written by its own enumerable entries, unlike
129
+ * JSON.stringify: a Date becomes `{}`, as the store's own write keeps it, but
130
+ * a deferred write recovered from its JSON file brings it back as a string.
131
+ *
132
+ * sourceBodyDigest's serializer, kept out of the package API: serialization
133
+ * and framing both stay inside sourceBodyDigest, so consumers don't
134
+ * duplicate either (`canonicalJson(blocks)` alone hashes differently).
135
+ */
136
+ export declare function canonicalJson(value: unknown): string;
137
+ /**
138
+ * The version identity of a delivered body (agreed with the receipts lane,
139
+ * room-220 #46752–#47210): SHA-256 hex of `canonicalJson([blocks])` over the
140
+ * ContentBlock[] the framework stores for the body — after MCPL conversion,
141
+ * before any host decoration is added and before storage shards it — with
142
+ * each block as the store keeps it (storedBlock, canonicalJson). So a body
143
+ * hashes alike as delivered, as handed to storage, and as read back from
144
+ * the store. The one-element array keeps the framing an undecorated,
145
+ * unsharded stored copy has always hashed to, so a stamped copy and an
146
+ * older copy of the same body share a version.
147
+ *
148
+ * Ingestion stamps it as `metadata.sourceBodyDigest`, and the same function
149
+ * over exactly the blocks handed to storage (decorations included) as
150
+ * `metadata.storedBodyDigest`, on both MCPL lanes. Both live outside the
151
+ * frozen admission envelope: they describe the body actually delivered (a
152
+ * materialization, a correction), not the admission. Neither proves later
153
+ * presence or completeness; an unsharded stored copy that no longer hashes
154
+ * to its storedBodyDigest was changed after delivery (editMessage keeps
155
+ * metadata). A body the store shards carries the whole body's two digests
156
+ * on every shard, and no shard hashes to them. Check a copy read back with
157
+ * its blobs resolved (getAllMessages, getMessage, or getMessageWindow
158
+ * without `resolveBlobs: false`): a blob reference never matches.
159
+ *
160
+ * Exported from the package root, so a consumer checks a copy against either
161
+ * field with this same function rather than a copy of it.
162
+ */
163
+ export declare function sourceBodyDigest(blocks: readonly unknown[]): string;
114
164
  //# sourceMappingURL=inbound-source.d.ts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,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAwB9E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAMzE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUpD;AAmED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAEnE"}
@@ -20,6 +20,7 @@
20
20
  * `materialized` record what RFC-006 did with it. Nothing here is a version
21
21
  * key: `eventId` is present only when the producer supplied one.
22
22
  */
23
+ import { createHash } from 'node:crypto';
23
24
  /** Metadata key the framework stamps. */
24
25
  export const INBOUND_SOURCE_KEY = 'inboundSource';
25
26
  const isText = (v) => typeof v === 'string' && v.length > 0;
@@ -80,4 +81,133 @@ export function conversationKey(source) {
80
81
  return JSON.stringify(['surface', source.surface]);
81
82
  return undefined;
82
83
  }
84
+ /**
85
+ * JSON with object keys sorted at every level, written as the store's append
86
+ * keeps a value (its native UTF-8 write, which the real-store digest table
87
+ * checks): an `undefined` object entry is dropped; a string is well-formed
88
+ * (each lone surrogate comes back as U+FFFD); and an entry whose key isn't
89
+ * well-formed is dropped (the store doesn't keep it). An `undefined` array
90
+ * element is written as `null`, as JSON writes it: the store's append
91
+ * refuses a body holding one, so no stored copy does. So a value
92
+ * hashes alike however its keys were ordered (content read back from the
93
+ * store has them in a different order than it was written), and alike
94
+ * before and after the store. editMessage writes JSON instead, so an edited
95
+ * copy can keep what an append wouldn't; it has changed anyway.
96
+ *
97
+ * It expects JSON-shaped values, as the MCPL lanes deliver them (parsed from
98
+ * JSON). Any other object is written by its own enumerable entries, unlike
99
+ * JSON.stringify: a Date becomes `{}`, as the store's own write keeps it, but
100
+ * a deferred write recovered from its JSON file brings it back as a string.
101
+ *
102
+ * sourceBodyDigest's serializer, kept out of the package API: serialization
103
+ * and framing both stay inside sourceBodyDigest, so consumers don't
104
+ * duplicate either (`canonicalJson(blocks)` alone hashes differently).
105
+ */
106
+ export function canonicalJson(value) {
107
+ if (Array.isArray(value))
108
+ return `[${value.map(canonicalJson).join(',')}]`;
109
+ if (value && typeof value === 'object') {
110
+ const entries = Object.entries(value)
111
+ .filter(([k, v]) => v !== undefined && k.isWellFormed())
112
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
113
+ return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(',')}}`;
114
+ }
115
+ if (typeof value === 'string')
116
+ return JSON.stringify(value.toWellFormed());
117
+ return JSON.stringify(value) ?? 'null';
118
+ }
119
+ /**
120
+ * A block as the store hands it back. Context-manager keeps inline media as
121
+ * blobs (blob-manager.ts): an image whose source isn't a URL, and every
122
+ * document, audio or video block, comes back as `{ type, source: { type:
123
+ * 'base64', data, mediaType } }` and nothing else, its data re-encoded from
124
+ * the decoded bytes, and an image's media type taken from its bytes'
125
+ * signature where they have one. Any other block comes back as it was given,
126
+ * except a store-internal `blob_ref` from an unresolved read, which resolves
127
+ * to inline media by default. It is digested as given here, so an unresolved
128
+ * read and its resolved form differ. Context-manager refuses caller-supplied
129
+ * blob_ref writes; the MCPL lanes never store one.
130
+ */
131
+ function storedBlock(block) {
132
+ const media = block;
133
+ const blob = media?.type === 'image'
134
+ ? media.source?.type !== 'url'
135
+ : media?.type === 'document' || media?.type === 'audio' || media?.type === 'video';
136
+ const source = media?.source;
137
+ if (!blob || typeof source?.data !== 'string')
138
+ return block;
139
+ const data = canonicalBase64(source.data);
140
+ const mediaType = media.type === 'image'
141
+ ? sniffRasterImageMediaType(Buffer.from(data.slice(0, 32), 'base64')) ?? source.mediaType
142
+ : source.mediaType;
143
+ return { type: media.type, source: { type: 'base64', data, mediaType } };
144
+ }
145
+ /**
146
+ * Base64 as the store writes it back from the decoded bytes: padded, with no
147
+ * whitespace, the standard alphabet and zero unused bits. Data already in
148
+ * that form, as every stored copy's is, is returned without decoding it all.
149
+ */
150
+ function canonicalBase64(data) {
151
+ if (data.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(data)) {
152
+ const last = data.slice(-4);
153
+ if (Buffer.from(last, 'base64').toString('base64') === last)
154
+ return data;
155
+ }
156
+ return Buffer.from(data, 'base64').toString('base64');
157
+ }
158
+ /**
159
+ * The store's own test for raster image types with an unambiguous byte
160
+ * signature, copied from context-manager's blob-manager.ts (it isn't
161
+ * exported): the store relabels an image whose bytes match one of these.
162
+ */
163
+ function sniffRasterImageMediaType(bytes) {
164
+ if (bytes.length >= 8 &&
165
+ bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47 &&
166
+ bytes[4] === 0x0d && bytes[5] === 0x0a && bytes[6] === 0x1a && bytes[7] === 0x0a) {
167
+ return 'image/png';
168
+ }
169
+ if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) {
170
+ return 'image/jpeg';
171
+ }
172
+ if (bytes.length >= 6) {
173
+ const signature = Buffer.from(bytes.subarray(0, 6)).toString('ascii');
174
+ if (signature === 'GIF87a' || signature === 'GIF89a')
175
+ return 'image/gif';
176
+ }
177
+ if (bytes.length >= 12 &&
178
+ Buffer.from(bytes.subarray(0, 4)).toString('ascii') === 'RIFF' &&
179
+ Buffer.from(bytes.subarray(8, 12)).toString('ascii') === 'WEBP') {
180
+ return 'image/webp';
181
+ }
182
+ return null;
183
+ }
184
+ /**
185
+ * The version identity of a delivered body (agreed with the receipts lane,
186
+ * room-220 #46752–#47210): SHA-256 hex of `canonicalJson([blocks])` over the
187
+ * ContentBlock[] the framework stores for the body — after MCPL conversion,
188
+ * before any host decoration is added and before storage shards it — with
189
+ * each block as the store keeps it (storedBlock, canonicalJson). So a body
190
+ * hashes alike as delivered, as handed to storage, and as read back from
191
+ * the store. The one-element array keeps the framing an undecorated,
192
+ * unsharded stored copy has always hashed to, so a stamped copy and an
193
+ * older copy of the same body share a version.
194
+ *
195
+ * Ingestion stamps it as `metadata.sourceBodyDigest`, and the same function
196
+ * over exactly the blocks handed to storage (decorations included) as
197
+ * `metadata.storedBodyDigest`, on both MCPL lanes. Both live outside the
198
+ * frozen admission envelope: they describe the body actually delivered (a
199
+ * materialization, a correction), not the admission. Neither proves later
200
+ * presence or completeness; an unsharded stored copy that no longer hashes
201
+ * to its storedBodyDigest was changed after delivery (editMessage keeps
202
+ * metadata). A body the store shards carries the whole body's two digests
203
+ * on every shard, and no shard hashes to them. Check a copy read back with
204
+ * its blobs resolved (getAllMessages, getMessage, or getMessageWindow
205
+ * without `resolveBlobs: false`): a blob reference never matches.
206
+ *
207
+ * Exported from the package root, so a consumer checks a copy against either
208
+ * field with this same function rather than a copy of it.
209
+ */
210
+ export function sourceBodyDigest(blocks) {
211
+ return createHash('sha256').update(canonicalJson([blocks.map(storedBlock)])).digest('hex');
212
+ }
83
213
  //# sourceMappingURL=inbound-source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inbound-source.js","sourceRoot":"","sources":["../../../src/mcpl/inbound-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiFH,yCAAyC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD,MAAM,MAAM,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAClF,MAAM,YAAY,GAAG,CAAC,CAAU,EAAW,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;AAC3E,MAAM,YAAY,GAAG,CAAC,CAAU,EAAW,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAA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,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;QACpE,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA0B;IACzD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7F,CAAC"}
@@ -19,7 +19,8 @@ export { PushHandler } from './push-handler.js';
19
19
  export type { McplPushEvent } from './push-handler.js';
20
20
  export { InferenceRouter } from './inference-router.js';
21
21
  export { ChannelRegistry } from './channel-registry.js';
22
- export { INBOUND_SOURCE_KEY, readInboundSource, conversationKey } from './inbound-source.js';
22
+ export type { PublishRefusalReason } from './channel-registry.js';
23
+ export { INBOUND_SOURCE_KEY, readInboundSource, conversationKey, sourceBodyDigest } from './inbound-source.js';
23
24
  export type { InboundSource, InboundChannelSource, InboundUnscopedSource, InboundSurfaceSource, } from './inbound-source.js';
24
25
  /** @deprecated Per-channel conversation routing is deprecated and will be removed (anima-research/agent-framework#235). */
25
26
  export { ConversationRouter, DEFAULT_CLOSURE_PROMPT } from './conversation-router.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcpl/index.ts"],"names":[],"mappings":"AACA,YAAY,EAEV,cAAc,EACd,eAAe,EACf,YAAY,EAGZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EAGnB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EAGvB,gBAAgB,EAGhB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,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C7F,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,2HAA2H;AAC3H,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACtF,2HAA2H;AAC3H,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcpl/index.ts"],"names":[],"mappings":"AACA,YAAY,EAEV,cAAc,EACd,eAAe,EACf,YAAY,EAGZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EAGnB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EAGvB,gBAAgB,EAGhB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EAGxB,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAGlB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAGnB,eAAe,EACf,eAAe,EAGf,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EAGrB,WAAW,EACX,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,oBAAoB,EAGpB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAG5B,sBAAsB,EAGtB,cAA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AAmB,EACnB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/G,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,2HAA2H;AAC3H,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACtF,2HAA2H;AAC3H,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
@@ -21,8 +21,9 @@ export { PushHandler } from './push-handler.js';
21
21
  export { InferenceRouter } from './inference-router.js';
22
22
  // Channel registry (channel lifecycle, incoming messages, synthesized tools)
23
23
  export { ChannelRegistry } from './channel-registry.js';
24
- // Inbound source envelope: where each accepted item came from, stamped once
25
- export { INBOUND_SOURCE_KEY, readInboundSource, conversationKey } from './inbound-source.js';
24
+ // Inbound source envelope: where each accepted item came from, stamped once;
25
+ // and the digest of a delivered or stored body
26
+ export { INBOUND_SOURCE_KEY, readInboundSource, conversationKey, sourceBodyDigest } from './inbound-source.js';
26
27
  // Per-channel conversation routing (fork-per-channel agents)
27
28
  /** @deprecated Per-channel conversation routing is deprecated and will be removed (anima-research/agent-framework#235). */
28
29
  export { ConversationRouter, DEFAULT_CLOSURE_PROMPT } from './conversation-router.js';