@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
@@ -31,66 +31,66 @@ export interface ProcessLoggingConfig {
31
31
  */
32
32
  /**
33
33
  * Client-side programmatic tool calling: a synthesized `code_execution` tool
34
- * that runs model-authored Python on the host, with every framework tool
35
- * injected as an async function. Mirrors the trained surface of Anthropic's
36
- * server-side PTC; inner tool results never enter the model context.
34
+ * that runs model-authored JavaScript in QuickJS compiled to WebAssembly, in a
35
+ * child process of its own per script, with the agent's tools as async
36
+ * functions. Mirrors the trained surface of Anthropic's server-side PTC;
37
+ * inner tool results never enter the model context.
37
38
  *
38
- * Robustness boundary, not a security sandbox (same doctrine as gate.js —
39
- * the agent already has broader host access through its tools).
39
+ * A script adds nothing to what its agent's tools allow, provided the host
40
+ * runtime's WebAssembly engine and the glue around it are right. It claims no
41
+ * containment beyond that: the child runs as the host's user, with an empty
42
+ * environment and no operating-system sandbox around it.
40
43
  */
41
44
  export interface CodeExecutionConfig {
42
45
  /** Master switch — only `true` synthesizes the tool. `create()` refuses a
43
46
  * value that isn't a boolean, a quoted "false" included; `null` or leaving
44
47
  * it out counts as off. */
45
48
  enabled: boolean;
46
- /** Python interpreter to spawn (default: 'python3' from PATH). */
47
- pythonPath?: string;
48
- /**
49
- * Per-inner-tool-call timeout; exceeding it raises TimeoutError inside the
50
- * script (default 270_000 ms, mirroring the managed runtime's message).
51
- */
49
+ /** How long a run or a wait waits for its script before it yields, unless
50
+ * the agent asks otherwise with `yield_time_ms` (default 30_000 ms). */
51
+ yieldMs?: number;
52
+ /** The most an agent may ask a run or a wait to wait (default 600_000 ms).
53
+ * At least `yieldMs`. */
54
+ maxYieldMs?: number;
55
+ /** A script's limit: a script still running this long after it started is
56
+ * stopped, as "stopped at its limit" (default 86_400_000 ms, a day). */
57
+ scriptLifetimeMs?: number;
58
+ /** Scripts one agent may have running at once, yielded ones included
59
+ * (default 3). */
60
+ maxRunningScripts?: number;
61
+ /** Script processes the host runs at once, every agent's together
62
+ * (default 16). A run past it is refused at once, and nothing runs. */
63
+ maxScriptChildren?: number;
64
+ /** How long one of a script's tool calls may go unanswered before the
65
+ * script is told it timed out; the tool may still take effect
66
+ * (default 270_000 ms). */
52
67
  toolCallTimeoutMs?: number;
53
- /** Whole-script deadline: cancel → grace → SIGKILL (default 600_000 ms). */
54
- scriptTimeoutMs?: number;
55
- /**
56
- * Longest deadline an agent may ask for on one call with `time_limit_ms`
57
- * (default: `scriptTimeoutMs`, so agents can only shorten it until this is
58
- * raised). Longer requests are capped, and the result says so.
59
- */
60
- maxScriptTimeoutMs?: number;
61
- /**
62
- * Idle interpreter reclaim — script globals are lost after this much
63
- * inactivity (default 300_000 ms, mirroring ~5-minute container reclaim).
64
- * 0 disables reclaim.
65
- */
66
- idleReclaimMs?: number;
67
- /** Max concurrent background (daemon) scripts per agent (default 3). */
68
- maxBackgroundScripts?: number;
69
- /** Background script lifetime ceiling, ms (default 86_400_000 = 24h). */
70
- backgroundMaxLifetimeMs?: number;
71
68
  /** Minimum interval between wake_agent() deliveries, ms (default 60_000).
72
- * Early wakes are delayed, not dropped (backpressure inside the script). */
69
+ * Early wakes are delayed, not dropped. */
73
70
  wakeMinIntervalMs?: number;
74
- /** Max wake_agent() calls per background script (default 100); further
75
- * calls raise RuntimeError inside the script. */
71
+ /** Max wake_agent() calls per script (default 100); further calls are
72
+ * refused in the script. */
76
73
  maxWakesPerScript?: number;
77
- /** Variables for the python interpreter beyond the operating allowlist it
78
- * inherits (see CHILD_ENV_ALLOWLIST), such as PYTHONPATH. A recipe can
79
- * `${VAR}`-substitute them from .env. Other host variables aren't
80
- * inherited, which limits what model-authored code inherits, not what a
81
- * process running as the same user can read. The runner sets
82
- * PYTHONUNBUFFERED and PYTHONIOENCODING last, over any value given here,
83
- * since its protocol needs both. The interpreter's working directory is
84
- * its own runtime directory, so a relative path given here, as in
85
- * PYTHONPATH, resolves there: give absolute paths. */
86
- env?: Record<string, string>;
87
- /** The interpreter inherits the host's whole environment instead of the
88
- * allowlist: every host variable, provider keys included, reaches
89
- * model-authored code and every subprocess a script starts. Listing what
90
- * scripts need in `env` is the safer route. With code execution enabled,
91
- * `create()` refuses any value but true, false or null, which counts as
92
- * not set. */
93
- inheritEnv?: boolean;
74
+ /**
75
+ * The WebAssembly memory's maximum for each script, its budget: a whole
76
+ * number of 64 KiB pages from 4 MiB to 2 GiB (default 128 MiB). A script's
77
+ * process stays within about its runtime's base plus 2.7 times this, plus
78
+ * what its calls take as they go out: up to about 200 MiB under Node and
79
+ * 410 MiB under Bun. The host holds at most about 6 times this, plus 653 MiB,
80
+ * plus 128 KiB for each wake maxWakesPerScript allows, for a script: about
81
+ * 1.4 GiB at the defaults.
82
+ * That's its 16 calls out at once, each with at most 4 MiB of JSON
83
+ * arguments, timed-out ones whose tools still run included, up to 16 more
84
+ * waiting as their text for those to end, up to 16 answers until the child
85
+ * takes them, each at most a third of this, the frame from the child being
86
+ * read, and its waiting wakes. A tool's
87
+ * own result, and the one serialization the bridge makes of it to check its
88
+ * size, are the tool's, beside this. Size a host by both. A call past the 16
89
+ * the script waits on waits in the script, in this memory. A tool result too large for
90
+ * it reaches the script as ResultTooLarge; how much fits depends on the
91
+ * result's shape (see `IsolateSettings.memoryMaxBytes`).
92
+ */
93
+ memoryMaxBytes?: number;
94
94
  }
95
95
 
96
96
  /** See `FrameworkConfig.providerHold`. */
@@ -117,9 +117,10 @@ export interface FrameworkConfig {
117
117
  subconscious?: import('../tune-out/tools.js').SubconsciousConfig;
118
118
 
119
119
  /**
120
- * IANA zone used only when rendering wall-clock times for the agent.
121
- * Stored/protocol timestamps remain epoch/UTC. Defaults to AGENT_TIMEZONE,
122
- * then the process zone.
120
+ * IANA zone of the agent's wall clock: it renders wall-clock times for the
121
+ * agent, and it sets where clock rows' boundaries fall (AgentConfig.clock,
122
+ * counted from local midnight here). Stored/protocol timestamps remain
123
+ * epoch/UTC. Defaults to AGENT_TIMEZONE, then the process zone.
123
124
  */
124
125
  timeZone?: string;
125
126
 
@@ -127,9 +128,10 @@ export interface FrameworkConfig {
127
128
  storePath?: string;
128
129
 
129
130
  /**
130
- * Branch-independent Discord awareness-marker outbox. Defaults to
131
+ * Branch-independent Discord awareness ledger. Defaults to
131
132
  * `<storePath>/recovery/discord-awareness-outbox.json`. Set explicitly when
132
- * providing an app-owned `store` without `storePath`; omit to disable.
133
+ * providing an app-owned `store` without `storePath`; with neither, the
134
+ * framework has no ledger and refuses a marks choice.
133
135
  */
134
136
  discordAwarenessOutboxPath?: string;
135
137
 
@@ -227,7 +229,7 @@ export interface FrameworkConfig {
227
229
 
228
230
  /**
229
231
  * Client-side programmatic tool calling (`code_execution` tool). Omitted or
230
- * `enabled: false` → tool absent, no python is ever spawned. At runtime,
232
+ * `enabled: false` → tool absent, and no script's process is ever started. At runtime,
231
233
  * untyped configs may also use `null` or `false` to omit this setting.
232
234
  * Other values that aren't objects are refused at `create()`.
233
235
  */
@@ -235,18 +237,20 @@ export interface FrameworkConfig {
235
237
 
236
238
  /**
237
239
  * Durable inline cap (chars) for tool results — successes AND errors — and
238
- * background-script wake payloads. Content over the cap is written to a
240
+ * script wake payloads (wake_agent()). Content over the cap is written to a
239
241
  * workspace file under `tool-results/` (deterministic `<date>-<callId>.txt`
240
242
  * name, overwritten on collision, retained until the workspace owner
241
243
  * deletes it — never auto-GC'd) and replaced inline by a bounded preview
242
- * plus the file reference; with no writable workspace the fallback is
243
- * explicit plain truncation. Default 24000 (house-safe; issue #89). Must be
244
+ * plus the file reference; with no writable mount without an include, the
245
+ * fallback is explicit plain truncation. Default 24000 (house-safe; issue #89). Must be
244
246
  * >= 1000. A resident's own agent_settings value
245
247
  * `tool_result_inline_max_chars` (durable, persisted in framework state)
246
248
  * takes precedence over this for that agent; the EFFECTIVE cap for every
247
249
  * source is min(desired, strategy bound) — desired values above the
248
250
  * strategy-derived bound (maxMessageTokens * 4) are hard-clamped to it,
249
- * with the clamp reported via agent_settings get.
251
+ * with the clamp reported via agent_settings get. For an ordinary resident
252
+ * the bound is the smallest among the agents that read the shared slot,
253
+ * reported as clamped by `reader-bound` when another reader's sets it.
250
254
  */
251
255
  toolResultInlineMaxChars?: number;
252
256
 
@@ -460,13 +464,16 @@ export interface InferenceLogEntry {
460
464
  }
461
465
 
462
466
  /**
463
- * Entry in the process log - records a processed event with all module responses.
467
+ * Entry in the process log - records a processed event with the module
468
+ * responses that applied.
464
469
  */
465
470
  export interface ProcessLogEntry {
466
471
  timestamp: number;
467
472
  /** The process event that was handled */
468
473
  processEvent: ProcessEvent;
469
- /** Responses from all modules, or blob ID if large */
474
+ /** The modules' responses that applied, or blob ID if large. A response
475
+ * refused for content context-manager won't store is left out; its stderr
476
+ * line and process:response-refused trace name it. */
470
477
  responses: ModuleProcessResponse[] | { blobId: string };
471
478
  }
472
479
 
@@ -476,7 +483,7 @@ export interface ProcessLogEntry {
476
483
  export interface ProcessLogQuery {
477
484
  /** Filter by process event type */
478
485
  eventType?: string;
479
- /** Filter by module name (modules that responded) */
486
+ /** Filter by module name (modules whose responses applied) */
480
487
  moduleName?: string;
481
488
  /** Max number of logs to return */
482
489
  limit?: number;
@@ -27,7 +27,8 @@ export interface MessageQuery {
27
27
 
28
28
  /**
29
29
  * A message as a module context's reads answer it: a stored row, or a row
30
- * for a write the framework holds (`held`).
30
+ * for a write the framework holds (`held`). Either is marked
31
+ * `heldFromResidents` when a tune-out holds it from the residents.
31
32
  */
32
33
  export type ModuleMessage = StoredMessage & {
33
34
  /**
@@ -39,9 +40,31 @@ export type ModuleMessage = StoredMessage & {
39
40
  * and `timestamp` are provisional: the sequence comes after every stored
40
41
  * row's, the timestamp is when the framework held the write (for a write
41
42
  * an older release held, when its queue was read back), and both change
42
- * when it lands. Absent on a stored row.
43
+ * when it lands. A held write whose earlier write may already be stored
44
+ * is looked up first, and answered as the stored row it is when the store
45
+ * holds it. Absent on a stored row.
43
46
  */
44
47
  held?: true;
48
+ /**
49
+ * True on a message a tune-out holds from the residents: one that arrived
50
+ * in a tuned-out channel, stamped `metadata.tuneOut` as it came in. The
51
+ * store keeps it, but no resident is shown the row itself: no resident's
52
+ * compiled view includes it, during the tune-out or after it, and a tool
53
+ * boundary of a turn alive when it arrived stores it without injecting it
54
+ * into the live turn. The subconscious reads it. Its text can still reach
55
+ * a resident in rows of their own, which aren't marked, such as the
56
+ * cancel's `<tuned-out-backlog>` row, with the text of the tune-out's newest
57
+ * messages, up to `backlogCap` of them and as many as fit in one of the
58
+ * residents' messages, the stored ones first and then those still held;
59
+ * what the subconscious says of it, in its report or its note; and the
60
+ * result of a tool that reads history on request, such as a
61
+ * channel's `fetch_history` or the history module's `extract`. A module
62
+ * that builds on what the residents see, such as one choosing from the
63
+ * recent conversation, leaves a marked row out, and one that matches
64
+ * what's stored, such as a sync's dedupe, keeps it. A held write (`held`)
65
+ * is marked too when it carries the stamp. Absent on every other row.
66
+ */
67
+ heldFromResidents?: true;
45
68
  };
46
69
 
47
70
  /**
@@ -290,13 +313,17 @@ export interface ModuleContext {
290
313
 
291
314
  /**
292
315
  * Edit a message, by its id or a held write's handle. A held write is
293
- * stored with the new content.
316
+ * stored with the new content. One whose earlier write may already be
317
+ * stored, where the store can't be searched to tell, throws with nothing
318
+ * changed.
294
319
  */
295
320
  editMessage(id: MessageId, content: ContentBlock[]): void;
296
321
 
297
322
  /**
298
323
  * Remove a message, by its id or a held write's handle. A held write is
299
- * dropped, so the agent never reads it.
324
+ * dropped, so the agent never reads it. One whose earlier write may
325
+ * already be stored, where the store can't be searched to tell, throws
326
+ * with nothing changed.
300
327
  */
301
328
  removeMessage(id: MessageId): void;
302
329
 
@@ -312,7 +339,9 @@ export interface ModuleContext {
312
339
  findMessageByExternalId(source: string, externalId: string): MessageId | null;
313
340
 
314
341
  /**
315
- * Get a message by its id or a held write's handle.
342
+ * Get a message by its id or a held write's handle, marked
343
+ * `heldFromResidents` when a tune-out holds it from the residents
344
+ * (ModuleMessage).
316
345
  */
317
346
  getMessage(id: MessageId): ModuleMessage | null;
318
347
 
@@ -322,7 +351,9 @@ export interface ModuleContext {
322
351
  * The rows of writes the framework holds come after the stored rows, as
323
352
  * the newest, or before them in a reversed query, marked `held`
324
353
  * (ModuleMessage). Those the last process held show once create() has
325
- * restored them, after every module's start() (addMessage).
354
+ * restored them, after every module's start() (addMessage). A message a
355
+ * tune-out holds from the residents is among the rows, marked
356
+ * `heldFromResidents` (ModuleMessage).
326
357
  */
327
358
  queryMessages(filter: MessageQuery): MessageQueryResult;
328
359
 
@@ -571,8 +602,9 @@ export interface SpeechContext {
571
602
 
572
603
  /**
573
604
  * The turn this speech ends: the same id as `ToolCall.callerTurnId` on the
574
- * calls made in it (its model's calls and its foreground scripts' inner
575
- * calls), kept across the turn's streams (a context-budget restart or a
605
+ * calls made in it (its model's calls, and a script's calls that reach the
606
+ * host while a code_execution call of the turn watches the script), kept across the
607
+ * turn's streams (a context-budget restart or a
576
608
  * retry), and larger for the agent's next turn. Unique only within one run
577
609
  * of the process.
578
610
  */
@@ -33,9 +33,23 @@ export type TraceEvent =
33
33
  | (TraceEventBase & {
34
34
  type: 'process:completed';
35
35
  processEvent: ProcessEvent;
36
+ /** The modules' responses that applied: one refused for malformed
37
+ * content is left out, and named by process:response-refused. */
36
38
  responses: ModuleProcessResponse[];
37
39
  durationMs: number;
38
40
  })
41
+ /** A module's process response held content context-manager won't store,
42
+ * in a message it adds or an edit it makes, and was refused whole before
43
+ * any response to the event applied. `where` names the first such message
44
+ * or edit in the response, such as `addMessages[1]`, and `places` is
45
+ * malformedContentPlaces' answer for it. */
46
+ | (TraceEventBase & {
47
+ type: 'process:response-refused';
48
+ moduleName: string;
49
+ eventType: string;
50
+ where: string;
51
+ places: string[];
52
+ })
39
53
 
40
54
  // Inference lifecycle
41
55
  | (TraceEventBase & {
@@ -124,9 +138,15 @@ export type TraceEvent =
124
138
  blockType: 'text' | 'thinking' | 'tool_call' | 'tool_result';
125
139
  /** 0-indexed block position in the current assistant turn. */
126
140
  blockIndex: number;
127
- /** The channel this stream shows typing in: the turn's locus as the
128
- * stream started (see inference:started), or in explicit mode the
129
- * channel the start's wake came from. */
141
+ /** The channel this stream shows typing in, the conversation the turn
142
+ * is attending. Locus and hybrid mode: the turn's locus, which an
143
+ * addressed re-pin or the agent's own `channel_open` can move between
144
+ * rounds, so it can change within one stream; the indicator and these
145
+ * traces follow it from the next round on, at the model's first
146
+ * content in it or its retry after a refusal, and a tool result the
147
+ * boundary reports carries the channel of the round it answers. In
148
+ * hybrid mode a `>>>` envelope can send the text itself elsewhere.
149
+ * Explicit mode: the channel the start's wake came from. */
130
150
  channelId?: string;
131
151
  })
132
152
  | (TraceEventBase & {
@@ -141,9 +161,15 @@ export type TraceEvent =
141
161
  phase: 'block_start' | 'block_complete';
142
162
  blockType: 'text' | 'thinking' | 'tool_call' | 'tool_result';
143
163
  blockIndex: number;
144
- /** The channel this stream shows typing in: the turn's locus as the
145
- * stream started (see inference:started), or in explicit mode the
146
- * channel the start's wake came from. */
164
+ /** The channel this stream shows typing in, the conversation the turn
165
+ * is attending. Locus and hybrid mode: the turn's locus, which an
166
+ * addressed re-pin or the agent's own `channel_open` can move between
167
+ * rounds, so it can change within one stream; the indicator and these
168
+ * traces follow it from the next round on, at the model's first
169
+ * content in it or its retry after a refusal, and a tool result the
170
+ * boundary reports carries the channel of the round it answers. In
171
+ * hybrid mode a `>>>` envelope can send the text itself elsewhere.
172
+ * Explicit mode: the channel the start's wake came from. */
147
173
  channelId?: string;
148
174
  })
149
175
  | (TraceEventBase & {
@@ -173,6 +199,66 @@ export type TraceEvent =
173
199
  type: 'inference:turn_ended';
174
200
  agentName: string;
175
201
  })
202
+ | (TraceEventBase & {
203
+ /**
204
+ * Prose that delivery published, sent once the publish succeeds: the
205
+ * outgoing stream's chunk (MCPL Spec 14.3 `channels/outgoing/chunk`),
206
+ * emitted whether or not the channel's server takes the stream. It
207
+ * carries only what was published, so a consumer that speaks or shows
208
+ * it, such as a voice relay, never gets text that delivery withholds (a
209
+ * `skip_reply`, a silencing send, a private `think`, a hold, a bounce,
210
+ * a draft) or a publish the server didn't confirm (`delivered: true`):
211
+ * one refused before sending, one that threw, timed out or got an
212
+ * error answer, one the server reported undelivered
213
+ * (`delivered: false`), and one whose reply leaves `delivered` out.
214
+ * `inference:tokens` stays the model's text as it is written (held, as
215
+ * before, while a tool-result guard's batch is pending). A later
216
+ * publish to the same destination, a server and its channel, by the
217
+ * same stream opens with a paragraph break (`\n\n`), so a
218
+ * destination's chunks joined in `index` order are its text, its
219
+ * messages kept apart.
220
+ * `mcpl:speech-routed` also reports speech publishes, with no stream
221
+ * id, index or end, each once delivered: deliverSpeech's, the `sleep`
222
+ * tool's announcement among them, and a subconscious's
223
+ * `speak_in_channel`'s. A relay that voices the agent's prose takes
224
+ * this trace, with `inference:published_complete`, and not
225
+ * `mcpl:speech-routed` as well, and takes each message's id from its
226
+ * `messageId` to edit what it voiced.
227
+ */
228
+ type: 'inference:published';
229
+ agentName: string;
230
+ /** The server the prose is published to, and its channel there: two
231
+ * servers' channels with the same id are two destinations. */
232
+ serverId: string;
233
+ channelId: string;
234
+ /** The stream's id, shared with its `channels/outgoing/*` notifications. */
235
+ inferenceId: string;
236
+ /** Increases by one per chunk of the stream, across its channels. */
237
+ index: number;
238
+ text: string;
239
+ /** The id the channel's server returned for this chunk's publish
240
+ * (`ChannelsPublishResult.messageId`); absent when it returned none.
241
+ * Each chunk is one publish, so each carries its own. */
242
+ messageId?: string;
243
+ })
244
+ | (TraceEventBase & {
245
+ /**
246
+ * A stream's end for one destination it published to, a server and
247
+ * its channel, emitted on every exit path once the stream has ended
248
+ * and its deliveries have run, or, when the host stops, before its
249
+ * connections close: `text` is everything its `inference:published`
250
+ * chunks carried there by then, and none follows it. Like those
251
+ * chunks, it's emitted whether or not that server takes the stream,
252
+ * or registers the channel still; the MCPL
253
+ * `channels/outgoing/complete` goes to the server only when it does.
254
+ */
255
+ type: 'inference:published_complete';
256
+ agentName: string;
257
+ serverId: string;
258
+ channelId: string;
259
+ inferenceId: string;
260
+ text: string;
261
+ })
176
262
 
177
263
  // Tool lifecycle
178
264
  | (TraceEventBase & {
@@ -216,10 +302,11 @@ export type TraceEvent =
216
302
  })
217
303
  | (TraceEventBase & {
218
304
  /**
219
- * A writable workspace existed but the oversized-result spill write
220
- * failed (size cap, storeBlob failure, …) — the over-cap tail was NOT
305
+ * The workspace had a writable mount without an include, where spills
306
+ * go, but the oversized-result spill write failed (size cap, storeBlob failure, …) — the over-cap tail was NOT
221
307
  * retained. Distinct from the no-workspace fallback, which is silent
222
- * by design (nothing unexpected happened).
308
+ * by design (nothing unexpected happened), whether the setup has no
309
+ * writable mount or every writable mount has an include, as configured.
223
310
  */
224
311
  type: 'tool:spill_failed';
225
312
  label: string;
@@ -302,6 +389,18 @@ export type TraceEvent =
302
389
  field?: string;
303
390
  detail?: string;
304
391
  })
392
+ /** MCPL content that context-manager won't store, because it doesn't
393
+ * match ContentBlock, reached the store/wake site and was refused there:
394
+ * no row, no wake. `places` is malformedContentPlaces' answer for it. */
395
+ | (TraceEventBase & {
396
+ type: 'mcpl:malformed-content-refused';
397
+ lane: 'push' | 'channel';
398
+ serverId: string;
399
+ places: string[];
400
+ eventId?: string;
401
+ channelId?: string;
402
+ messageId?: string;
403
+ })
305
404
  /** MCPL content with nothing model-visible reached the store/wake site
306
405
  * (module-emitted or coalescer-delivered) and was dropped: no row, no wake. */
307
406
  | (TraceEventBase & {
@@ -442,13 +541,16 @@ export type TraceEvent =
442
541
  })
443
542
 
444
543
  // Host-owned speech routing (ChannelRegistry.routeSpeech). One trace per
445
- // delivered prose segment. `text` is the segment verbatim — the same content
544
+ // delivered prose segment, and one per publish the subconscious's
545
+ // speak_in_channel delivers (ChannelRegistry.publishForAgent): that one's
546
+ // conversationId is the speaking agent's name, and it carries no
547
+ // messageId. `text` is the segment verbatim — the same content
446
548
  // already on the bus chunk-by-chunk via inference:tokens, and mcpl:* traces
447
549
  // are 'ops'-scoped on the webui wire — and `messageId` is the surface's id
448
- // for the posted message (when the MCPL server reports one). Together they
449
- // give external taps the (channelId, messageId, text) tuple needed to edit
450
- // a just-posted message, e.g. a TTS interruption truncating a reply to the
451
- // words actually voiced.
550
+ // for the posted message (on routeSpeech's traces, when the MCPL server
551
+ // reports one). Together they give external taps the (channelId,
552
+ // messageId, text) tuple needed to edit a just-posted message, e.g. a TTS
553
+ // interruption truncating a reply to the words actually voiced.
452
554
  | (TraceEventBase & {
453
555
  type: 'mcpl:speech-routed';
454
556
  /** Agent / conversation whose speech was routed. */
@@ -459,7 +561,8 @@ export type TraceEvent =
459
561
  textLen: number;
460
562
  /** The routed prose segment, verbatim. */
461
563
  text: string;
462
- /** Surface message id (e.g. Discord message id), when reported. */
564
+ /** Surface message id (e.g. Discord message id), when reported, on
565
+ * routeSpeech's traces. speak_in_channel's carry none. */
463
566
  messageId?: string;
464
567
  })
465
568
  | (TraceEventBase & {
@@ -473,6 +576,9 @@ export type TraceEvent =
473
576
  /** `failed`: nothing was posted; `unknown`: the request was dispatched
474
577
  * and no valid receipt came back, so it may have been. */
475
578
  outcome?: 'failed' | 'unknown';
579
+ /** The connector error's structured data, bounded (connectorText),
580
+ * when it sent some: it may say what a multi-part send posted. */
581
+ detail?: string;
476
582
  })
477
583
 
478
584
  // Admin puppet: an operator executed a tool AS an agent and stored the
@@ -3,13 +3,29 @@ export interface SessionUsage {
3
3
  outputTokens: number;
4
4
  cacheCreationTokens: number;
5
5
  cacheReadTokens: number;
6
+ /** The summed estimated cost of the inferences counted here that membrane
7
+ * priced, in one currency. An inference it couldn't price adds nothing, so
8
+ * this is a lower bound when any were unpriced. Absent when none was
9
+ * priced, and from the moment costs in two currencies meet here, since the
10
+ * two can't be summed, which `mixedCurrencies` records. */
6
11
  estimatedCost?: { total: number; currency: string };
12
+ /** Set once inferences priced in two currencies have been counted here:
13
+ * `estimatedCost` stays absent from then on, since the two can't be
14
+ * summed and a later cost alone isn't this tally's. Stored and restored
15
+ * with it, and carried into the shared ephemeral entry when stored
16
+ * entries fold into it. */
17
+ mixedCurrencies?: true;
7
18
  }
8
19
 
9
20
  export interface AgentUsage {
10
21
  agentName: string;
11
22
  usage: SessionUsage;
12
23
  inferenceCount: number;
24
+ /** Set on the one entry that holds every ephemeral agent's usage together
25
+ * (agentName EPHEMERAL_USAGE_NAME), apart from any agent of that name. Each
26
+ * ephemeral agent runs under a new name, so an entry per name would grow
27
+ * the record by one for every run, for good. */
28
+ ephemeral?: true;
13
29
  }
14
30
 
15
31
  export interface SessionUsageSnapshot {