@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
@@ -0,0 +1,150 @@
1
+ /**
2
+ * The messages between a script's parent and its child, and the checks that
3
+ * turn a decoded frame from the child into one of them. Every frame from a
4
+ * child is untrusted: the parent acts only on a
5
+ * message `decodeChildMessage` accepts, and any other ends the script as
6
+ * crashed.
7
+ */
8
+ import { countJsonValues } from './frames.js';
9
+ export { countJsonValues };
10
+ /**
11
+ * The most tool calls a script has out at once, from the call until the
12
+ * script has its answer. One past them waits in the script, in its own memory,
13
+ * until one is answered, and is never refused, so a `Promise.all` over many
14
+ * calls still works, only paced, and what waits is the script's to hold. A
15
+ * child that sends more crashes its run. `wake_agent()` takes no place: its
16
+ * answer holds nothing, and its own cap bounds it.
17
+ */
18
+ export const MAX_CALLS_IN_FLIGHT = 16;
19
+ /**
20
+ * The most JSON a tool call's arguments may be, in UTF-8 bytes: room for a
21
+ * generated file of a few MB of ordinary text as one string (escaping takes
22
+ * more room for quotes, backslashes and control characters). With MAX_ARGUMENT_VALUES it bounds
23
+ * what the host holds for a call while it runs: its arguments' text and their
24
+ * parsed value, at most about twice these bytes each (a string the runtime
25
+ * keeps in two bytes a character) and about 92 bytes a value, the most a
26
+ * value cost in a parse under Node 24 and Bun 1.4.
27
+ */
28
+ export const MAX_ARGUMENT_BYTES = 4 * 1024 * 1024;
29
+ /** The most values a tool call's arguments may hold: each object, array and element counts. */
30
+ export const MAX_ARGUMENT_VALUES = 100_000;
31
+ /** The most JSON a `wake_agent()` payload may be, in UTF-8 bytes: a wake says what happened, and a longer result is written with a tool. */
32
+ export const MAX_WAKE_PAYLOAD_BYTES = 64 * 1024;
33
+ /** A cap as the tool's text says it, such as 4 MiB. */
34
+ export const capText = (bytes) => (bytes % (1024 * 1024) === 0 ? `${bytes / (1024 * 1024)} MiB` : `${bytes / 1024} KiB`);
35
+ /** A `wake_agent()` payload the host won't take, said to the script: nothing was sent. Null when it may go out. */
36
+ export function wakeRefusal(payloadJson) {
37
+ const bytes = Buffer.byteLength(payloadJson, 'utf8');
38
+ if (bytes <= MAX_WAKE_PAYLOAD_BYTES)
39
+ return null;
40
+ return {
41
+ name: 'WakeRefused',
42
+ message: `wake_agent()'s payload is ${bytes} bytes of JSON, past the ${capText(MAX_WAKE_PAYLOAD_BYTES)} a wake can carry; nothing was sent. Write a longer result with a tool, and wake with where to find it.`,
43
+ bytes,
44
+ };
45
+ }
46
+ /**
47
+ * The longest frame a child sends: a call frame carries its arguments escaped,
48
+ * at most six bytes for each of the 4 MiB the script may send, with room for
49
+ * its name and the rest. The child encodes its frames against it, and the
50
+ * parent refuses a longer one before its body is kept, so one frame being
51
+ * read costs the host at most this much as bytes, and its text and its parse
52
+ * up to twice as much again each.
53
+ */
54
+ export const MAX_CHILD_FRAME_BYTES = 6 * MAX_ARGUMENT_BYTES + 1024 * 1024;
55
+ /** A wake past the script's cap, said to the script: nothing was sent. */
56
+ export function wakeLimitRefusal(maxWakes) {
57
+ // A cap of 0 turns wakes off for every script, so a new one can't either.
58
+ if (maxWakes === 0) {
59
+ return {
60
+ name: 'WakeRefused',
61
+ message: "wake_agent() is off on this host: its operator set maxWakesPerScript to 0, so nothing was sent, and no script here can wake its agent.",
62
+ };
63
+ }
64
+ return {
65
+ name: 'WakeRefused',
66
+ message: `wake limit reached: ${maxWakes} per script, set by the host's maxWakesPerScript; nothing was sent, and every later ` +
67
+ 'wake_agent() in this script is refused the same way. A new script can wake its agent again.',
68
+ };
69
+ }
70
+ /** A call's arguments the host won't take, said to the script: nothing was sent. Null when they may go out. */
71
+ export function argumentsRefusal(tool, argsJson) {
72
+ const bytes = Buffer.byteLength(argsJson, 'utf8');
73
+ if (bytes > MAX_ARGUMENT_BYTES) {
74
+ return {
75
+ name: 'ArgumentsTooLarge',
76
+ message: `${tool}'s arguments are ${bytes} bytes of JSON, past the ${capText(MAX_ARGUMENT_BYTES)} a call can take; nothing was sent. Send the data in parts, over several calls.`,
77
+ bytes,
78
+ };
79
+ }
80
+ if (countJsonValues(argsJson, MAX_ARGUMENT_VALUES) > MAX_ARGUMENT_VALUES) {
81
+ return {
82
+ name: 'ArgumentsTooLarge',
83
+ message: `${tool}'s arguments hold more than ${MAX_ARGUMENT_VALUES.toLocaleString('en-US')} values, the most a call can take; nothing was sent. Send the data in parts, or as one string.`,
84
+ bytes,
85
+ };
86
+ }
87
+ return null;
88
+ }
89
+ /** The error a script gets for a call whose result was too large for its memory: the call took effect. */
90
+ export const RESULT_TOO_LARGE = 'ResultTooLarge';
91
+ const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
92
+ /** A call's id: a result frame carries it as an unsigned 32-bit number, so a larger one couldn't name its call. */
93
+ const isCallId = (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0 && v <= 0xffffffff;
94
+ /** The longest tool name the parent takes from a child, in UTF-16 code units. Providers allow 64; this leaves room and bounds the error text. */
95
+ const MAX_NAME_CHARS = 256;
96
+ /**
97
+ * A frame from a child, as a message the parent may act on, or the reason it
98
+ * can't be one. Fields beyond those a message has are ignored.
99
+ */
100
+ export function decodeChildMessage(value) {
101
+ if (!isRecord(value))
102
+ return { invalid: 'a frame from the child was not an object' };
103
+ switch (value.t) {
104
+ case 'call': {
105
+ if (!isCallId(value.id))
106
+ return { invalid: "a call's id was not a whole number from 0 to 4294967295" };
107
+ if (typeof value.name !== 'string' || value.name.length === 0 || value.name.length > MAX_NAME_CHARS) {
108
+ return { invalid: "a call's name was not a string of 1 to 256 UTF-16 code units" };
109
+ }
110
+ if (typeof value.args !== 'string')
111
+ return { invalid: "a call's arguments were not text" };
112
+ return { t: 'call', id: value.id, name: value.name, args: value.args };
113
+ }
114
+ case 'seen': {
115
+ if (!isCallId(value.id))
116
+ return { invalid: "a seen frame's id was not a whole number from 0 to 4294967295" };
117
+ return value.unfit === true ? { t: 'seen', id: value.id, unfit: true } : { t: 'seen', id: value.id };
118
+ }
119
+ case 'out': {
120
+ if (typeof value.text !== 'string')
121
+ return { invalid: 'an output frame did not hold text' };
122
+ return { t: 'out', text: value.text };
123
+ }
124
+ case 'end': {
125
+ if (value.how === 'finished') {
126
+ if (value.value !== undefined && typeof value.value !== 'string')
127
+ return { invalid: "a finished script's value was not JSON text" };
128
+ return value.value === undefined ? { t: 'end', how: 'finished' } : { t: 'end', how: 'finished', value: value.value };
129
+ }
130
+ if (value.how === 'failed') {
131
+ const error = value.error;
132
+ if (!isRecord(error) || typeof error.name !== 'string' || typeof error.message !== 'string' || (error.stack !== undefined && typeof error.stack !== 'string')) {
133
+ return { invalid: "a failed script's error did not hold a name and a message" };
134
+ }
135
+ return {
136
+ t: 'end',
137
+ how: 'failed',
138
+ error: { name: error.name, message: error.message, ...(error.stack === undefined ? {} : { stack: error.stack }) },
139
+ ...(value.stalled === true ? { stalled: true } : {}),
140
+ };
141
+ }
142
+ if (value.how === 'stopped')
143
+ return { t: 'end', how: 'stopped' };
144
+ return { invalid: 'an end frame named no ending' };
145
+ }
146
+ default:
147
+ return { invalid: 'a frame from the child named no message' };
148
+ }
149
+ }
150
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../../src/code-execution/isolate/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAE3C,4IAA4I;AAC5I,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,uDAAuD;AACvD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC;AAEzI,mHAAmH;AACnH,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACrD,IAAI,KAAK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KAAK,CAAC;gBAC1B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;oBAC9J,OAAO,EAAE,OAAO,EAAE,2DAA2D,EAAE,CAAC;gBAClF,CAAC;gBACD,OAAO;oBACL,CAAC,EAAE,KAAK;oBACR,GAAG,EAAE,QAAQ;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;oBACjH,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACrD,CAAC;YACJ,CAAC;YACD,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;gBAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACjE,OAAO,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC;QACrD,CAAC;QACD;YACE,OAAO,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC;IAClE,CAAC;AACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * What the model reads for a return of `code_execution`: how the script ended
3
+ * or that it's still running, first, so no cut can drop it; then what became
4
+ * of its calls, naming each whose effect is uncertain with a count of the
5
+ * rest; then what it returned and what it wrote since the last return.
6
+ */
7
+ import type { ScriptListing, ScriptReturn } from './scripts.js';
8
+ /**
9
+ * The most of a script's return value, or of a failure's message or stack,
10
+ * that a return shows, as a head and a tail of half this each. The run keeps
11
+ * them cut to this, so an ended run kept for a later wait holds no more.
12
+ */
13
+ export declare const VALUE_CHARS = 8000;
14
+ /** The most of a failure's name a return shows: a name is a word, so the message and the stack keep the room. */
15
+ export declare const NAME_CHARS = 200;
16
+ /**
17
+ * The most a cut's marker adds to its text (bounded's, with a count of up to
18
+ * 16 digits). A text bounded again with this much room past its first bound
19
+ * keeps its first cut, and the count that cut gives, as they are.
20
+ */
21
+ export declare const CUT_MARK_CHARS = 64;
22
+ /**
23
+ * `text`, or its head and tail of about `max / 2` each with the count dropped
24
+ * between, as copies of their own. Neither cut parts a surrogate pair.
25
+ */
26
+ export declare function bounded(text: string, max: number): string;
27
+ /**
28
+ * bounded's cut of a text of `length` characters, past its bound, from its
29
+ * first and its last `max / 2` characters, rounded down: `head` and `tail`,
30
+ * of that one length. So a text that's never held whole, such as a stack's
31
+ * frames as the agent reads them (scriptFrames), is cut as bounded cuts it.
32
+ */
33
+ export declare function cutOf(head: string, tail: string, length: number): string;
34
+ /** A duration as the settings give it: exactly, a fraction of a second included. */
35
+ export declare function formatMs(ms: number): string;
36
+ /**
37
+ * The start of `text`, up to `max` characters and "…" when it goes on, never
38
+ * parting a surrogate pair: a glimpse of a text that may already have been cut,
39
+ * whose count a second cut would misstate.
40
+ */
41
+ export declare function glimpse(text: string, max: number): string;
42
+ export interface RenderOptions {
43
+ /** The bound the return was made at, for a yield's line. */
44
+ boundMs: number;
45
+ lifetimeMs: number;
46
+ /**
47
+ * The agent's inline cap for tool results, which the return is stored
48
+ * under: the output is cut to the room the rest of the return leaves in
49
+ * it. None when left out.
50
+ */
51
+ maxChars?: number;
52
+ }
53
+ /** The text a return gives the model. */
54
+ export declare function renderReturn(r: ScriptReturn, options: RenderOptions): string;
55
+ /** A `list` of an agent's scripts: each one's id and how it stands, with how to see more. */
56
+ export declare function renderList(scripts: ScriptListing[], now: number): string;
57
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/code-execution/isolate/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGhE;;;;GAIG;AACH,eAAO,MAAM,WAAW,OAAQ,CAAC;AAEjC,iHAAiH;AACjH,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQxE;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAK3C;AAuBD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAMzD;AAuDD,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,yCAAyC;AACzC,wBAAgB,YAAY,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CA+B5E;AA0BD,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQxE"}
@@ -0,0 +1,214 @@
1
+ /**
2
+ * What the model reads for a return of `code_execution`: how the script ended
3
+ * or that it's still running, first, so no cut can drop it; then what became
4
+ * of its calls, naming each whose effect is uncertain with a count of the
5
+ * rest; then what it returned and what it wrote since the last return.
6
+ */
7
+ import { fresh, toolRef } from './calls.js';
8
+ import { renderOutput } from './output.js';
9
+ /**
10
+ * The most of a script's return value, or of a failure's message or stack,
11
+ * that a return shows, as a head and a tail of half this each. The run keeps
12
+ * them cut to this, so an ended run kept for a later wait holds no more.
13
+ */
14
+ export const VALUE_CHARS = 8_000;
15
+ /** The most of a failure's name a return shows: a name is a word, so the message and the stack keep the room. */
16
+ export const NAME_CHARS = 200;
17
+ /**
18
+ * The most a cut's marker adds to its text (bounded's, with a count of up to
19
+ * 16 digits). A text bounded again with this much room past its first bound
20
+ * keeps its first cut, and the count that cut gives, as they are.
21
+ */
22
+ export const CUT_MARK_CHARS = 64;
23
+ /**
24
+ * `text`, or its head and tail of about `max / 2` each with the count dropped
25
+ * between, as copies of their own. Neither cut parts a surrogate pair.
26
+ */
27
+ export function bounded(text, max) {
28
+ if (text.length <= max)
29
+ return text;
30
+ const half = Math.floor(max / 2);
31
+ return cutOf(text.slice(0, half), text.slice(text.length - half), text.length);
32
+ }
33
+ /**
34
+ * bounded's cut of a text of `length` characters, past its bound, from its
35
+ * first and its last `max / 2` characters, rounded down: `head` and `tail`,
36
+ * of that one length. So a text that's never held whole, such as a stack's
37
+ * frames as the agent reads them (scriptFrames), is cut as bounded cuts it.
38
+ */
39
+ export function cutOf(head, tail, length) {
40
+ const half = head.length;
41
+ let kept = half;
42
+ const last = head.charCodeAt(kept - 1);
43
+ if (last >= 0xd800 && last <= 0xdbff)
44
+ kept -= 1;
45
+ const first = tail.charCodeAt(0);
46
+ const skipped = first >= 0xdc00 && first <= 0xdfff ? 1 : 0;
47
+ return `${fresh(head.slice(0, kept))}\n[… ${length - half + skipped - kept} characters dropped here …]\n${fresh(tail.slice(skipped))}`;
48
+ }
49
+ /** A duration as the settings give it: exactly, a fraction of a second included. */
50
+ export function formatMs(ms) {
51
+ if (ms < 1000)
52
+ return `${ms} ms`;
53
+ if (ms % 3_600_000 === 0)
54
+ return `${ms / 3_600_000} h`;
55
+ if (ms % 60_000 === 0)
56
+ return `${ms / 60_000} min`;
57
+ return `${ms / 1000} s`;
58
+ }
59
+ function endingLine(id, ending, lifetimeMs) {
60
+ switch (ending.how) {
61
+ case 'finished':
62
+ return `Script ${id} finished.`;
63
+ case 'failed':
64
+ // The run keeps the message cut to VALUE_CHARS, with room for the cut's marker.
65
+ return `Script ${id} failed: ${ending.error.name ? `${ending.error.name}: ` : ''}${ending.error.message}`;
66
+ case 'stopped': {
67
+ const why = ending.reason === 'agent'
68
+ ? `Script ${id} was stopped, as you asked.`
69
+ : ending.why
70
+ ? `Script ${id} was stopped: ${ending.why}.`
71
+ : `Script ${id} was stopped at its limit of ${formatMs(lifetimeMs)}.`;
72
+ return ending.short ? `${why} Its process didn't stop by itself and was ended, so its output may be short.` : why;
73
+ }
74
+ case 'crashed':
75
+ // The detail is the host's account; what it means for the agent follows.
76
+ return `Script ${id} crashed: ${ending.detail}. A crash is the script's process failing, not an error its code threw: a fault in the host or its runtime, or something the script's own data asked of the runtime that it couldn't do, such as reading values nested thousands deep, or code nested hundreds deep. Running it again may work; if the same script crashes again, change what it does with its data or its code.`;
77
+ }
78
+ }
79
+ /**
80
+ * The start of `text`, up to `max` characters and "…" when it goes on, never
81
+ * parting a surrogate pair: a glimpse of a text that may already have been cut,
82
+ * whose count a second cut would misstate.
83
+ */
84
+ export function glimpse(text, max) {
85
+ if (text.length <= max)
86
+ return text;
87
+ let cut = max;
88
+ const last = text.charCodeAt(cut - 1);
89
+ if (last >= 0xd800 && last <= 0xdbff)
90
+ cut -= 1;
91
+ return `${fresh(text.slice(0, cut))}…`;
92
+ }
93
+ /** A named call as the agent wrote it, with its arguments. */
94
+ function namedRef(call) {
95
+ return call.tool === 'wake_agent' ? `wake_agent(${call.args})` : `${toolRef(call.tool)}(${call.args})`;
96
+ }
97
+ function namedLine(call) {
98
+ switch (call.state) {
99
+ case 'uncertain':
100
+ return `- still running when the script ended, so it may or may not take effect: ${namedRef(call)}`;
101
+ case 'timed-out':
102
+ return `- timed out in the script, and still running when the script ended, so it may still take effect: ${namedRef(call)}`;
103
+ case 'timed-out-answered':
104
+ return `- timed out in the script, and its answer came later: ${namedRef(call)}, answer ${JSON.stringify(call.answer ?? '')}`;
105
+ case 'too-large':
106
+ return `- answered with a result the script couldn't receive, too large for its memory or nested too deep, so it got an error instead: ${namedRef(call)}`;
107
+ case 'unseen':
108
+ return `- answered, but the script ended before it read the answer: ${namedRef(call)}`;
109
+ }
110
+ }
111
+ /**
112
+ * What became of the calls. At a yield, counts. At the end, counts, and each
113
+ * call whose answer the script didn't see, named with its arguments, past
114
+ * CALLS_NAMED counted by tool.
115
+ */
116
+ function callsLines(calls, running) {
117
+ if (calls.made === 0)
118
+ return running ? 'It has made no tool calls yet.' : 'It made no tool calls.';
119
+ const unseen = calls.named.length + Object.values(calls.more).reduce((sum, n) => sum + n, 0);
120
+ const parts = [];
121
+ const add = (n, words) => {
122
+ if (n > 0)
123
+ parts.push(`${n} ${words}`);
124
+ };
125
+ add(calls.answered, 'answered');
126
+ add(calls.failed, 'answered with an error');
127
+ add(calls.refused, calls.refused === 1 ? 'refused before it ran, so nothing was done' : 'refused before they ran, so nothing was done');
128
+ add(calls.unsent, 'never sent, so nothing was done');
129
+ add(calls.running, 'still running');
130
+ add(calls.waiting, 'waiting their turn in the host');
131
+ // Timed out, answered with a result too large for the script's memory,
132
+ // still running when the script ended (uncertain), or answered after the
133
+ // script stopped reading (unseen): either way the script went on without
134
+ // the answer.
135
+ add(unseen, unseen === 1 ? "whose answer it didn't see" : "whose answers it didn't see");
136
+ const head = `${running ? 'Its calls so far' : 'Its calls'}: ${calls.made}${parts.length ? ` (${parts.join('; ')})` : ''}`;
137
+ if (running || unseen === 0)
138
+ return `${head}.`;
139
+ const lines = [`${head}:`, ...calls.named.map(namedLine)];
140
+ const more = Object.entries(calls.more);
141
+ if (more.length > 0) {
142
+ lines.push(`- and ${unseen - calls.named.length} more: ${more.map(([tool, n]) => `${toolRef(tool)} ×${n}`).join(', ')}`);
143
+ }
144
+ return lines.join('\n');
145
+ }
146
+ /** The text a return gives the model. */
147
+ export function renderReturn(r, options) {
148
+ const lines = [];
149
+ if (r.ending === null) {
150
+ lines.push(`Script ${r.scriptId} is still running after ${formatMs(options.boundMs)}.`);
151
+ lines.push(r.stopsAtTurnEnd
152
+ ? `It will be stopped when your turn ends if it's still running, since only the primary agent's scripts outlive a turn. ` +
153
+ `Wait for it with {"action": "wait", "script_id": "${r.scriptId}"} to see it finish, or stop it with {"action": "stop", "script_id": "${r.scriptId}"}.`
154
+ : `Wait for it with {"action": "wait", "script_id": "${r.scriptId}"}, stop it with {"action": "stop", "script_id": "${r.scriptId}"}, ` +
155
+ 'or leave it running: it can wake you with wake_agent(), and you are woken if it fails, crashes or reaches its limit.');
156
+ }
157
+ else {
158
+ lines.push(endingLine(r.scriptId, r.ending, options.lifetimeMs));
159
+ }
160
+ // The ending's line gave the name and message; the script's frames follow (GuestError.stack).
161
+ if (r.ending?.how === 'failed' && r.ending.error.stack)
162
+ lines.push(r.ending.error.stack);
163
+ lines.push(callsLines(r.calls, r.ending === null));
164
+ // The run keeps the value cut to VALUE_CHARS, with room for the cut's marker.
165
+ if (r.ending?.how === 'finished' && r.ending.value !== undefined)
166
+ lines.push(`It returned: ${r.ending.value}`);
167
+ const { head, tail, dropped } = r.output;
168
+ if (head.length + tail.length + dropped === 0) {
169
+ lines.push(r.first ? 'No output.' : 'No output since the last return.');
170
+ return lines.join('\n');
171
+ }
172
+ // The output comes last, and past the agent's inline cap the framework's
173
+ // cut would take its tail first: it gets the room the rest leaves, its head
174
+ // and tail cut alike.
175
+ const label = `${r.first ? 'Its output' : 'Its output since the last return'}:\n`;
176
+ const rest = lines.join('\n').length + 1 + label.length;
177
+ lines.push(label + renderOutput(r.output, (options.maxChars ?? Infinity) - rest));
178
+ return lines.join('\n');
179
+ }
180
+ function minutesAgo(ms) {
181
+ const minutes = Math.round(ms / 60_000);
182
+ return minutes < 1 ? 'under a minute' : `${minutes} min`;
183
+ }
184
+ /** How a listed script stands, in a few words. */
185
+ function listingState(s, now) {
186
+ if (s.running)
187
+ return `running for ${minutesAgo(now - s.startedAt)}`;
188
+ const when = s.endedAt === null ? '' : ` ${minutesAgo(now - s.endedAt)} ago`;
189
+ const e = s.ending;
190
+ switch (e?.how) {
191
+ case 'finished':
192
+ return `finished${when}`;
193
+ case 'failed':
194
+ return `failed${when}: ${e.error.name ? `${e.error.name}: ` : ''}${glimpse(e.error.message, 300)}`;
195
+ case 'crashed':
196
+ return `crashed${when}`;
197
+ case 'stopped':
198
+ return e.reason === 'agent' ? `stopped by you${when}` : e.why ? `stopped${when}: ${e.why}` : `stopped at its limit${when}`;
199
+ default:
200
+ return 'ended';
201
+ }
202
+ }
203
+ /** A `list` of an agent's scripts: each one's id and how it stands, with how to see more. */
204
+ export function renderList(scripts, now) {
205
+ if (scripts.length === 0)
206
+ return 'You have no scripts.';
207
+ const lines = scripts.map((s) => `- ${s.scriptId}: ${listingState(s, now)}${s.wakes > 0 ? ` (${s.wakes} wake${s.wakes === 1 ? '' : 's'} delivered)` : ''}`);
208
+ return [
209
+ 'Your scripts:',
210
+ ...lines,
211
+ '{"action": "wait", "script_id": ...} gives a script\'s output since its last return, or its result once it has ended.',
212
+ ].join('\n');
213
+ }
214
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../../src/code-execution/isolate/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAoC,MAAM,YAAY,CAAC;AAG9E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,iHAAiH;AACjH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAE9B;;;;GAIG;AACH,MAAM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