zidane 7.2.4 → 8.0.4

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 (376) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -6
  3. package/dist/{acp-D-tVyUjw.js → acp-DQDhi2dj.js} +230 -77
  4. package/dist/acp-DQDhi2dj.js.map +1 -0
  5. package/dist/acp-cli.d.ts +1 -1
  6. package/dist/acp-cli.js +9 -66
  7. package/dist/acp-cli.js.map +1 -1
  8. package/dist/acp.d.ts +10 -590
  9. package/dist/acp.d.ts.map +1 -1
  10. package/dist/acp.js +3 -3
  11. package/dist/{agent-D0zZnGbt.js → agent-DSLNmBp0.js} +14401 -13214
  12. package/dist/agent-DSLNmBp0.js.map +1 -0
  13. package/dist/agent.d.ts +1 -1
  14. package/dist/agent.js +3 -2
  15. package/dist/aliasing-lVFbm81n.js +217 -0
  16. package/dist/aliasing-lVFbm81n.js.map +1 -0
  17. package/dist/{anthropic-C2aole0G.js → anthropic-CD00LhUP.js} +1442 -1264
  18. package/dist/anthropic-CD00LhUP.js.map +1 -0
  19. package/dist/artifacts-CV2hUKnL.js.map +1 -1
  20. package/dist/{atomic-write-B7zr1ddF.js → atomic-write-Ijgf2Mhc.js} +13 -3
  21. package/dist/atomic-write-Ijgf2Mhc.js.map +1 -0
  22. package/dist/call-tool-dHlbGOIY.js +70 -0
  23. package/dist/call-tool-dHlbGOIY.js.map +1 -0
  24. package/dist/chat/pure.d.ts +372 -6
  25. package/dist/chat/pure.d.ts.map +1 -1
  26. package/dist/chat/pure.js +35 -244
  27. package/dist/chat/pure.js.map +1 -1
  28. package/dist/{approvals-DKaJZYlm.js → chat-JPJJ8uu5.js} +15879 -14631
  29. package/dist/chat-JPJJ8uu5.js.map +1 -0
  30. package/dist/chat.d.ts +4 -6
  31. package/dist/chat.js +23 -12
  32. package/dist/cli-shared-C-YCaglL.js +159 -0
  33. package/dist/cli-shared-C-YCaglL.js.map +1 -0
  34. package/dist/client-core-BQSyDALT.d.ts +2115 -0
  35. package/dist/client-core-BQSyDALT.d.ts.map +1 -0
  36. package/dist/codemode-worker.d.ts +1 -0
  37. package/dist/codemode-worker.js +155 -0
  38. package/dist/codemode-worker.js.map +1 -0
  39. package/dist/codemode.d.ts +352 -0
  40. package/dist/codemode.d.ts.map +1 -0
  41. package/dist/codemode.js +5 -0
  42. package/dist/connection-Dr-Js4yZ.d.ts +28 -0
  43. package/dist/connection-Dr-Js4yZ.d.ts.map +1 -0
  44. package/dist/connection-loop-gdh22LTI.js +112 -0
  45. package/dist/connection-loop-gdh22LTI.js.map +1 -0
  46. package/dist/context-segments-BHKlagL6.js +1016 -0
  47. package/dist/context-segments-BHKlagL6.js.map +1 -0
  48. package/dist/{context-transport-T_6AYIvy.js → context-transport-DSMTUsK1.js} +3 -3
  49. package/dist/{context-transport-T_6AYIvy.js.map → context-transport-DSMTUsK1.js.map} +1 -1
  50. package/dist/contexts/daytona.d.ts +19 -8
  51. package/dist/contexts/daytona.d.ts.map +1 -1
  52. package/dist/contexts/daytona.js +1 -440
  53. package/dist/contexts/docker.d.ts +36 -7
  54. package/dist/contexts/docker.d.ts.map +1 -1
  55. package/dist/contexts/docker.js +1 -456
  56. package/dist/contexts/e2b.d.ts +68 -13
  57. package/dist/contexts/e2b.d.ts.map +1 -1
  58. package/dist/contexts/e2b.js +1 -382
  59. package/dist/contexts/sandbox.d.ts +1 -1
  60. package/dist/contexts/sandbox.js +5 -0
  61. package/dist/contexts/sandbox.js.map +1 -1
  62. package/dist/{contexts-CRE9pw07.js → contexts-d7UolYot.js} +1059 -524
  63. package/dist/contexts-d7UolYot.js.map +1 -0
  64. package/dist/contexts.d.ts +3 -3
  65. package/dist/contexts.js +1 -1
  66. package/dist/cred-keys-GpBg71cP.js +105 -0
  67. package/dist/cred-keys-GpBg71cP.js.map +1 -0
  68. package/dist/{auth-BG2rVKSt.js → credentials-JttEuRON.js} +55 -206
  69. package/dist/credentials-JttEuRON.js.map +1 -0
  70. package/dist/{cursor-iojRXHF9.js → cursor-CdjaQTBW.js} +3 -3
  71. package/dist/{cursor-iojRXHF9.js.map → cursor-CdjaQTBW.js.map} +1 -1
  72. package/dist/daemon-cli.d.ts +1 -1
  73. package/dist/daemon-cli.js +3 -2
  74. package/dist/daemon-cli.js.map +1 -1
  75. package/dist/daytona-DG3omipZ.js +513 -0
  76. package/dist/daytona-DG3omipZ.js.map +1 -0
  77. package/dist/defaults-Cx3zvDOV.js +23 -0
  78. package/dist/defaults-Cx3zvDOV.js.map +1 -0
  79. package/dist/dispatcher-BMlu2BmZ.js +4941 -0
  80. package/dist/dispatcher-BMlu2BmZ.js.map +1 -0
  81. package/dist/docker-BZhMMJUp.js +727 -0
  82. package/dist/docker-BZhMMJUp.js.map +1 -0
  83. package/dist/e2b-CEVOdRib.js +480 -0
  84. package/dist/e2b-CEVOdRib.js.map +1 -0
  85. package/dist/edit-utils-EGosADZq.js +234 -0
  86. package/dist/edit-utils-EGosADZq.js.map +1 -0
  87. package/dist/environment-8wsKE2Ln.js +214 -0
  88. package/dist/environment-8wsKE2Ln.js.map +1 -0
  89. package/dist/eval-BNcvle_J.js +1595 -0
  90. package/dist/eval-BNcvle_J.js.map +1 -0
  91. package/dist/eval.d.ts +2 -2
  92. package/dist/eval.js +1 -1489
  93. package/dist/executor-Cx5-8yqi.js +621 -0
  94. package/dist/executor-Cx5-8yqi.js.map +1 -0
  95. package/dist/extension-authoring-DyGGmq9V.js +385 -0
  96. package/dist/extension-authoring-DyGGmq9V.js.map +1 -0
  97. package/dist/extensions.d.ts +2 -2
  98. package/dist/extensions.js +3 -3
  99. package/dist/{fetch-url-DX75gpL0.js → fetch-url-Ct2TjDWt.js} +4 -4
  100. package/dist/{fetch-url-DX75gpL0.js.map → fetch-url-Ct2TjDWt.js.map} +1 -1
  101. package/dist/{format-BF745pLL.js → format-C2NQEVUH.js} +39 -2
  102. package/dist/format-C2NQEVUH.js.map +1 -0
  103. package/dist/format-bytes-C7tfc3Zm.js +55 -0
  104. package/dist/format-bytes-C7tfc3Zm.js.map +1 -0
  105. package/dist/headless-C_rNUuYC.js +960 -0
  106. package/dist/headless-C_rNUuYC.js.map +1 -0
  107. package/dist/headless.d.ts +1 -1
  108. package/dist/headless.js +1 -413
  109. package/dist/{history-search-C4bk1Wz_.js → history-search-CcYzF8-0.js} +7 -3
  110. package/dist/history-search-CcYzF8-0.js.map +1 -0
  111. package/dist/history-search-worker.d.ts +1 -1
  112. package/dist/history-search-worker.js +1 -1
  113. package/dist/host-D7NrI03V.js +378 -0
  114. package/dist/host-D7NrI03V.js.map +1 -0
  115. package/dist/host-signals-BcP5QKUD.js +118 -0
  116. package/dist/host-signals-BcP5QKUD.js.map +1 -0
  117. package/dist/identity-CwfO8K-t.js +26 -0
  118. package/dist/identity-CwfO8K-t.js.map +1 -0
  119. package/dist/{index-BgN1T3lk.d.ts → index-BGe1fQT7.d.ts} +10987 -9320
  120. package/dist/index-BGe1fQT7.d.ts.map +1 -0
  121. package/dist/index-BVQsIKGn.d.ts +448 -0
  122. package/dist/index-BVQsIKGn.d.ts.map +1 -0
  123. package/dist/{index-C6NEd5y_.d.ts → index-CHABJd-L.d.ts} +3386 -502
  124. package/dist/index-CHABJd-L.d.ts.map +1 -0
  125. package/dist/{index-C37_ppWv.d.ts → index-D6a7qXpg.d.ts} +2 -3
  126. package/dist/index-D6a7qXpg.d.ts.map +1 -0
  127. package/dist/index.d.ts +6 -6
  128. package/dist/index.js +27 -23
  129. package/dist/{completion-core-BRo86R_L.js → inline-ghost-BVRQeGoL.js} +50 -2
  130. package/dist/inline-ghost-BVRQeGoL.js.map +1 -0
  131. package/dist/ipc/remote.d.ts +313 -0
  132. package/dist/ipc/remote.d.ts.map +1 -0
  133. package/dist/ipc/remote.js +4 -0
  134. package/dist/ipc.d.ts +6 -964
  135. package/dist/ipc.js +403 -4
  136. package/dist/ipc.js.map +1 -0
  137. package/dist/{isolation-Kfoof0MM.d.ts → isolation-D9L650W5.d.ts} +100 -15
  138. package/dist/isolation-D9L650W5.d.ts.map +1 -0
  139. package/dist/json-rpc--HXQti1E.js +350 -0
  140. package/dist/json-rpc--HXQti1E.js.map +1 -0
  141. package/dist/links-j8rED1sR.js +603 -0
  142. package/dist/links-j8rED1sR.js.map +1 -0
  143. package/dist/local-terminal-D8QThwo_.js +252 -0
  144. package/dist/local-terminal-D8QThwo_.js.map +1 -0
  145. package/dist/{logger--C1VQjwJ.js → logger-Gtqlayx8.js} +199 -173
  146. package/dist/logger-Gtqlayx8.js.map +1 -0
  147. package/dist/logs-view-CWG8aUAG.js.map +1 -1
  148. package/dist/{mcp-CgNd-f3F.js → mcp-_wecH9Qe.js} +608 -562
  149. package/dist/mcp-_wecH9Qe.js.map +1 -0
  150. package/dist/mcp.d.ts +2 -2
  151. package/dist/mcp.js +2 -2
  152. package/dist/media-sniff-UKijEaiQ.js.map +1 -1
  153. package/dist/{messages-2jcOA_5R.js → messages-BqiwcD2Q.js} +1017 -1014
  154. package/dist/messages-BqiwcD2Q.js.map +1 -0
  155. package/dist/{oauth-DxHO17JE.js → oauth-Px_pBB9W.js} +5 -5
  156. package/dist/{oauth-DxHO17JE.js.map → oauth-Px_pBB9W.js.map} +1 -1
  157. package/dist/{openai-compat-Dy56weK8.js → openai-compat-CFrpH7uq.js} +432 -589
  158. package/dist/openai-compat-CFrpH7uq.js.map +1 -0
  159. package/dist/orchestration-BCGmB8Ps.js +511 -0
  160. package/dist/orchestration-BCGmB8Ps.js.map +1 -0
  161. package/dist/output/stream-json.d.ts +1 -2
  162. package/dist/output/stream-json.d.ts.map +1 -1
  163. package/dist/output/stream-json.js +1 -1
  164. package/dist/output/terminal.d.ts +1 -2
  165. package/dist/output/terminal.d.ts.map +1 -1
  166. package/dist/output/terminal.js +13 -7
  167. package/dist/output/terminal.js.map +1 -1
  168. package/dist/{plugins-gbI7SBA6.js → plugins-DS7mahzZ.js} +20 -101
  169. package/dist/plugins-DS7mahzZ.js.map +1 -0
  170. package/dist/plugins.d.ts +1 -1
  171. package/dist/plugins.js +1 -2
  172. package/dist/prelude-Cxo4t74B.js +517 -0
  173. package/dist/prelude-Cxo4t74B.js.map +1 -0
  174. package/dist/presets.d.ts +1 -1
  175. package/dist/presets.js +1 -2
  176. package/dist/project-root-B8zADr4o.js +167 -0
  177. package/dist/project-root-B8zADr4o.js.map +1 -0
  178. package/dist/project-user-paths-BSgtrRxl.js +58 -0
  179. package/dist/project-user-paths-BSgtrRxl.js.map +1 -0
  180. package/dist/{prompts-Pqc3JdW_.d.ts → prompts-DYcvqShf.d.ts} +14 -11
  181. package/dist/prompts-DYcvqShf.d.ts.map +1 -0
  182. package/dist/protocol-DnhqqSmE.js +13 -0
  183. package/dist/protocol-DnhqqSmE.js.map +1 -0
  184. package/dist/providers/anthropic.d.ts +2 -2
  185. package/dist/providers/anthropic.js +1 -2
  186. package/dist/providers/arcee.d.ts +1 -1
  187. package/dist/providers/arcee.js +1 -1
  188. package/dist/providers/baseten.d.ts +1 -1
  189. package/dist/providers/baseten.js +1 -1
  190. package/dist/providers/cerebras.d.ts +1 -1
  191. package/dist/providers/cerebras.js +3 -2
  192. package/dist/providers/cerebras.js.map +1 -1
  193. package/dist/providers/local.d.ts +1 -1
  194. package/dist/providers/local.js +1 -1
  195. package/dist/providers/openai-compat.d.ts +1 -1
  196. package/dist/providers/openai-compat.js +1 -2
  197. package/dist/providers/openai.d.ts +1 -1
  198. package/dist/providers/openai.js +15 -12
  199. package/dist/providers/openai.js.map +1 -1
  200. package/dist/providers/openrouter.d.ts +1 -1
  201. package/dist/providers/openrouter.js +3 -2
  202. package/dist/providers/openrouter.js.map +1 -1
  203. package/dist/providers/xai.d.ts +1 -1
  204. package/dist/providers/xai.js +3 -3
  205. package/dist/{providers-BVhnFyiY.js → providers-XUR7F4Hi.js} +4 -4
  206. package/dist/{providers-BVhnFyiY.js.map → providers-XUR7F4Hi.js.map} +1 -1
  207. package/dist/providers.d.ts +1 -1
  208. package/dist/providers.js +4 -4
  209. package/dist/registry-D6ShBWJU.js +5234 -0
  210. package/dist/registry-D6ShBWJU.js.map +1 -0
  211. package/dist/remote-hosts-BtA_9ZGp.js +97 -0
  212. package/dist/remote-hosts-BtA_9ZGp.js.map +1 -0
  213. package/dist/restate.d.ts +2 -3
  214. package/dist/restate.d.ts.map +1 -1
  215. package/dist/restate.js +631 -572
  216. package/dist/restate.js.map +1 -1
  217. package/dist/run-summary-CklLiZ4y.js +288 -0
  218. package/dist/run-summary-CklLiZ4y.js.map +1 -0
  219. package/dist/{sandbox-BH0WQkXn.d.ts → sandbox-C5dR5DwQ.d.ts} +6 -3
  220. package/dist/sandbox-C5dR5DwQ.d.ts.map +1 -0
  221. package/dist/session/sqlite.d.ts +1 -2
  222. package/dist/session/sqlite.d.ts.map +1 -1
  223. package/dist/session/sqlite.js +1 -616
  224. package/dist/session-factory-BUGY5P40.js +1576 -0
  225. package/dist/session-factory-BUGY5P40.js.map +1 -0
  226. package/dist/{session-BqRP1hS7.js → session-xh9JXu6i.js} +94 -52
  227. package/dist/session-xh9JXu6i.js.map +1 -0
  228. package/dist/session.d.ts +1 -1
  229. package/dist/session.js +2 -2
  230. package/dist/settings-keys-Ckf29NeM.js +677 -0
  231. package/dist/settings-keys-Ckf29NeM.js.map +1 -0
  232. package/dist/shell-path-Dqaoow2J.js +412 -0
  233. package/dist/shell-path-Dqaoow2J.js.map +1 -0
  234. package/dist/{skills-BC3dodWp.js → skills-DKqZJm4X.js} +430 -470
  235. package/dist/skills-DKqZJm4X.js.map +1 -0
  236. package/dist/skills.d.ts +2 -2
  237. package/dist/skills.js +1 -2
  238. package/dist/source-mPExaUm8.js +381 -0
  239. package/dist/source-mPExaUm8.js.map +1 -0
  240. package/dist/sqlite-DV1DQzN2.js +698 -0
  241. package/dist/sqlite-DV1DQzN2.js.map +1 -0
  242. package/dist/{src-CkNQKFKr.js → src-BRMYRJib.js} +903 -1121
  243. package/dist/src-BRMYRJib.js.map +1 -0
  244. package/dist/{stdio-DPpBDPx5.js → stdio-C6YyoW3I.js} +4 -4
  245. package/dist/{stdio-DPpBDPx5.js.map → stdio-C6YyoW3I.js.map} +1 -1
  246. package/dist/{stdio-loader-Bbx19dMZ.js → stdio-loader-C830Vg-Z.js} +4 -4
  247. package/dist/{stdio-loader-Bbx19dMZ.js.map → stdio-loader-C830Vg-Z.js.map} +1 -1
  248. package/dist/system-prompt-MNVHatSD.d.ts.map +1 -1
  249. package/dist/timeout-DEaqslLO.d.ts.map +1 -1
  250. package/dist/todo-edits-Dn251YUP.js +1790 -0
  251. package/dist/todo-edits-Dn251YUP.js.map +1 -0
  252. package/dist/{turn-operations-DrbJlpq9.js → tool-formatters-IQFDrdrs.js} +1456 -2120
  253. package/dist/tool-formatters-IQFDrdrs.js.map +1 -0
  254. package/dist/tool-state-Dku6YqAB.js +989 -0
  255. package/dist/tool-state-Dku6YqAB.js.map +1 -0
  256. package/dist/tools/fetch-url.d.ts +1 -2
  257. package/dist/tools/fetch-url.d.ts.map +1 -1
  258. package/dist/tools/fetch-url.js +1 -2
  259. package/dist/tools/prompts.d.ts +1 -1
  260. package/dist/tools/prompts.js +7 -7
  261. package/dist/tools/prompts.js.map +1 -1
  262. package/dist/tools/web-search.d.ts +1 -2
  263. package/dist/tools/web-search.d.ts.map +1 -1
  264. package/dist/tools/web-search.js +2 -2
  265. package/dist/tools/web-search.js.map +1 -1
  266. package/dist/tools-_DnT3AGM.js +578 -0
  267. package/dist/tools-_DnT3AGM.js.map +1 -0
  268. package/dist/tools.d.ts +3 -3
  269. package/dist/tools.js +4 -2
  270. package/dist/tui.d.ts +534 -517
  271. package/dist/tui.d.ts.map +1 -1
  272. package/dist/tui.js +34933 -27242
  273. package/dist/tui.js.map +1 -1
  274. package/dist/turn-operations-B8sokwi5.js +333 -0
  275. package/dist/turn-operations-B8sokwi5.js.map +1 -0
  276. package/dist/turn-operations-DQX5ZZni.d.ts +3089 -0
  277. package/dist/turn-operations-DQX5ZZni.d.ts.map +1 -0
  278. package/dist/types-C7ZFOztE.d.ts +132 -0
  279. package/dist/types-C7ZFOztE.d.ts.map +1 -0
  280. package/dist/types-CH5XpIHw.js +114 -0
  281. package/dist/types-CH5XpIHw.js.map +1 -0
  282. package/dist/{types-CWgENVLY.js → types-Cu0ZGDu9.js} +10 -6
  283. package/dist/types-Cu0ZGDu9.js.map +1 -0
  284. package/dist/types-IqegbJEE.d.ts +624 -0
  285. package/dist/types-IqegbJEE.d.ts.map +1 -0
  286. package/dist/types.d.ts +4 -4
  287. package/dist/types.js +1 -1
  288. package/dist/url-D8HCl65b.js +1259 -0
  289. package/dist/url-D8HCl65b.js.map +1 -0
  290. package/dist/wasm-BVT-j5cl.js +33 -0
  291. package/dist/wasm-BVT-j5cl.js.map +1 -0
  292. package/dist/workspace-exec-stream-SV2R9d5S.js +355 -0
  293. package/dist/workspace-exec-stream-SV2R9d5S.js.map +1 -0
  294. package/dist/ws-CIHMvlSh.js +952 -0
  295. package/dist/ws-CIHMvlSh.js.map +1 -0
  296. package/dist/ws-client-N7NxzvQp.js +230 -0
  297. package/dist/ws-client-N7NxzvQp.js.map +1 -0
  298. package/dist/{xai-CazjStOK.js → xai-CvJTeLrI.js} +165 -5
  299. package/dist/xai-CvJTeLrI.js.map +1 -0
  300. package/dist/xdg-zweed0-t.js +117 -0
  301. package/dist/xdg-zweed0-t.js.map +1 -0
  302. package/docs/ACP.md +52 -0
  303. package/docs/ARCHITECTURE.md +103 -6
  304. package/docs/ARTIFACTS.md +8 -4
  305. package/docs/CHAT.md +165 -14
  306. package/docs/EXECUTION_CONTEXT.md +8 -0
  307. package/docs/EXTENSIONS.md +123 -2
  308. package/docs/HEADLESS.md +2 -0
  309. package/docs/IPC.md +775 -64
  310. package/docs/MACHINES.md +456 -0
  311. package/docs/PANELS.md +3 -0
  312. package/docs/README.md +4 -0
  313. package/docs/RESTATE.md +3 -2
  314. package/docs/RUN_IN_BACKGROUND.md +10 -2
  315. package/docs/SERVER.md +1085 -0
  316. package/docs/SKILL.md +6 -1
  317. package/docs/TERMINAL.md +75 -0
  318. package/docs/TUI.md +65 -14
  319. package/package.json +58 -26
  320. package/scripts/eval.ts +4 -0
  321. package/dist/acp-D-tVyUjw.js.map +0 -1
  322. package/dist/agent-D0zZnGbt.js.map +0 -1
  323. package/dist/anthropic-C2aole0G.js.map +0 -1
  324. package/dist/approvals-DKaJZYlm.js.map +0 -1
  325. package/dist/atomic-write-B7zr1ddF.js.map +0 -1
  326. package/dist/auth-BG2rVKSt.js.map +0 -1
  327. package/dist/completion-core-BRo86R_L.js.map +0 -1
  328. package/dist/contexts/daytona.js.map +0 -1
  329. package/dist/contexts/docker.js.map +0 -1
  330. package/dist/contexts/e2b.js.map +0 -1
  331. package/dist/contexts-CRE9pw07.js.map +0 -1
  332. package/dist/eval.js.map +0 -1
  333. package/dist/format-BF745pLL.js.map +0 -1
  334. package/dist/glob-DluQFSw1.js +0 -270
  335. package/dist/glob-DluQFSw1.js.map +0 -1
  336. package/dist/headless.js.map +0 -1
  337. package/dist/history-search-C4bk1Wz_.js.map +0 -1
  338. package/dist/index-BgN1T3lk.d.ts.map +0 -1
  339. package/dist/index-C37_ppWv.d.ts.map +0 -1
  340. package/dist/index-C6NEd5y_.d.ts.map +0 -1
  341. package/dist/ipc-zVSyo6K1.js +0 -331
  342. package/dist/ipc-zVSyo6K1.js.map +0 -1
  343. package/dist/ipc.d.ts.map +0 -1
  344. package/dist/isolation-Kfoof0MM.d.ts.map +0 -1
  345. package/dist/json-rpc-rSWMUh9b.js +0 -192
  346. package/dist/json-rpc-rSWMUh9b.js.map +0 -1
  347. package/dist/logger--C1VQjwJ.js.map +0 -1
  348. package/dist/mcp-CgNd-f3F.js.map +0 -1
  349. package/dist/messages-2jcOA_5R.js.map +0 -1
  350. package/dist/openai-compat-Dy56weK8.js.map +0 -1
  351. package/dist/output-cap-C9zukcCj.js +0 -100
  352. package/dist/output-cap-C9zukcCj.js.map +0 -1
  353. package/dist/panels-B6gRk4bf.js +0 -789
  354. package/dist/panels-B6gRk4bf.js.map +0 -1
  355. package/dist/plugins-gbI7SBA6.js.map +0 -1
  356. package/dist/prompts-Pqc3JdW_.d.ts.map +0 -1
  357. package/dist/run-summary-BU_NgwUT.js +0 -269
  358. package/dist/run-summary-BU_NgwUT.js.map +0 -1
  359. package/dist/sandbox-BH0WQkXn.d.ts.map +0 -1
  360. package/dist/session/sqlite.js.map +0 -1
  361. package/dist/session-BqRP1hS7.js.map +0 -1
  362. package/dist/shell-path-h5czzllR.js +0 -1549
  363. package/dist/shell-path-h5czzllR.js.map +0 -1
  364. package/dist/skills-BC3dodWp.js.map +0 -1
  365. package/dist/src-CkNQKFKr.js.map +0 -1
  366. package/dist/todo-edits-UOwgxGKu.js +0 -528
  367. package/dist/todo-edits-UOwgxGKu.js.map +0 -1
  368. package/dist/tool-formatters-DoRLnfuD.d.ts +0 -759
  369. package/dist/tool-formatters-DoRLnfuD.d.ts.map +0 -1
  370. package/dist/transcript-anchors-BeudMbXx.d.ts +0 -1762
  371. package/dist/transcript-anchors-BeudMbXx.d.ts.map +0 -1
  372. package/dist/turn-operations-C8bMBDl_.d.ts +0 -1258
  373. package/dist/turn-operations-C8bMBDl_.d.ts.map +0 -1
  374. package/dist/turn-operations-DrbJlpq9.js.map +0 -1
  375. package/dist/types-CWgENVLY.js.map +0 -1
  376. package/dist/xai-CazjStOK.js.map +0 -1
@@ -1,382 +1 @@
1
- import { r as capBufferedExecOutput } from "../output-cap-C9zukcCj.js";
2
- import { t as alwaysQuote } from "../shell-quote-BmnhZmdM.js";
3
- import { r as createLogger, t as consoleSink } from "../logger--C1VQjwJ.js";
4
- import { t as StreamQueue } from "../stream-queue-Cd9OJxl7.js";
5
- import { Buffer } from "node:buffer";
6
- //#region src/contexts/e2b.ts
7
- /**
8
- * "Effectively unlimited" command timeout for `execStream`. 2^31-1 ms
9
- * (~24.8 days — far beyond any sandbox lifetime) because both edges are
10
- * cliffs: `0` is treated by `@connectrpc/connect`'s deadline signal as
11
- * already expired (instant DeadlineExceeded), and anything above 2^31-1
12
- * overflows `setTimeout` and fires immediately.
13
- */
14
- const E2B_STREAM_TIMEOUT_MS = 2 ** 31 - 1;
15
- /** Per-probe timeout for the readiness `true` command. */
16
- const READINESS_PROBE_TIMEOUT_MS = 5e3;
17
- /** Pause between readiness probes while the sandbox is still warming up. */
18
- const READINESS_BACKOFF_MS = 250;
19
- /**
20
- * Command timeout for the pregame setup script. E2B's `commands.run` defaults
21
- * to 60s and offers no true "unlimited" — a `timeoutMs` of 0 is a 0ms deadline
22
- * (instant timeout), not "off". Setup scripts (`apt`/`pip` installs, builds)
23
- * routinely exceed 60s, so we pass a deliberately generous 30-minute ceiling.
24
- * The sandbox's own lifetime independently bounds anything longer.
25
- */
26
- const PREGAME_TIMEOUT_MS = 1800 * 1e3;
27
- /**
28
- * Upload a setup ("pregame") script into a ready sandbox and execute it.
29
- *
30
- * Writes the script to `/tmp/<name>`, then `chmod +x`'s and runs it directly
31
- * (so a `#!/bin/bash` / `#!/usr/bin/env python3` shebang chooses the
32
- * interpreter) in `cwd` with `envs` applied — the same env the sandbox was
33
- * created with, so the script sees the run's `--env` / `--pass-env`. A
34
- * generous {@link PREGAME_TIMEOUT_MS} ceiling is used so long `apt`/`pip`
35
- * installs aren't killed by E2B's 60s command default. A non-zero exit
36
- * (whether E2B returns it or raises on it) throws, so the caller can tear the
37
- * sandbox down rather than prompt against a broken environment.
38
- */
39
- async function runE2BPregame(sandbox, logger, opts) {
40
- const path = `/tmp/${opts.name}`;
41
- logger.info("running E2B pregame script", {
42
- sandboxId: sandbox.sandboxId,
43
- path
44
- });
45
- await sandbox.files.write(path, opts.content);
46
- const quoted = JSON.stringify(path);
47
- let result;
48
- try {
49
- result = await sandbox.commands.run(`chmod +x ${quoted} && ${quoted}`, {
50
- cwd: opts.cwd,
51
- envs: opts.envs,
52
- timeoutMs: PREGAME_TIMEOUT_MS
53
- });
54
- } catch (err) {
55
- const exitCode = typeof err?.exitCode === "number" ? err.exitCode : 124;
56
- logger.error("E2B pregame script failed", {
57
- sandboxId: sandbox.sandboxId,
58
- exitCode,
59
- stdout: err?.stdout ?? "",
60
- stderr: err?.stderr ?? err?.message ?? ""
61
- });
62
- throw new Error(`E2B pregame script ${opts.name} failed with exit code ${exitCode}`);
63
- }
64
- if (result.exitCode !== 0) {
65
- logger.error("E2B pregame script failed", {
66
- sandboxId: sandbox.sandboxId,
67
- exitCode: result.exitCode,
68
- stdout: result.stdout,
69
- stderr: result.stderr
70
- });
71
- throw new Error(`E2B pregame script ${opts.name} failed with exit code ${result.exitCode}`);
72
- }
73
- logger.info("E2B pregame ready", {
74
- sandboxId: sandbox.sandboxId,
75
- stdout: result.stdout,
76
- stderr: result.stderr
77
- });
78
- }
79
- /**
80
- * Block until an E2B sandbox is ready to run commands, or throw if it never
81
- * becomes ready within the deadline.
82
- *
83
- * The E2B control plane can hand back a sandbox id before the sandbox's `envd`
84
- * is accepting commands; the first real command then absorbs that cold start
85
- * and may time out. This polls a trivial `true` command on a short backoff,
86
- * logging a `waiting…` line up front and a `ready` line (with `elapsedMs`) on
87
- * success. On deadline exhaustion it best-effort kills the sandbox and throws.
88
- *
89
- * `now`/`sleep` are injectable purely for deterministic tests; in production
90
- * they default to `Date.now` and a real timer.
91
- */
92
- async function waitForE2BReady(sandbox, logger, opts) {
93
- if (opts.timeoutSeconds <= 0) return;
94
- const now = opts.now ?? Date.now;
95
- const sleep = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
96
- const start = now();
97
- const deadline = start + opts.timeoutSeconds * 1e3;
98
- logger.info("waiting for E2B sandbox to initialize", { sandboxId: sandbox.sandboxId });
99
- while (true) try {
100
- await sandbox.commands.run("true", { timeoutMs: READINESS_PROBE_TIMEOUT_MS });
101
- logger.info("E2B sandbox ready", {
102
- sandboxId: sandbox.sandboxId,
103
- elapsedMs: now() - start
104
- });
105
- return;
106
- } catch {
107
- if (now() >= deadline) {
108
- if (opts.killOnTimeout !== false) await sandbox.kill().catch(() => {});
109
- throw new Error(`E2B sandbox ${sandbox.sandboxId} did not become ready within ${opts.timeoutSeconds}s`);
110
- }
111
- await sleep(READINESS_BACKOFF_MS);
112
- }
113
- }
114
- /**
115
- * Resolve the effective E2B template, highest precedence first: the per-spawn
116
- * `SpawnConfig.sandbox.template`, then the factory `template` option, then the
117
- * `E2B_TEMPLATE` env var. Returns `undefined` (→ SDK's `base` default) when
118
- * none is set. The E2B SDK reads `E2B_API_KEY`/`E2B_DOMAIN` from the env but
119
- * NOT `E2B_TEMPLATE`, so this provider has to honor it itself.
120
- */
121
- function resolveE2BTemplate(perSpawnTemplate, optionTemplate, env = process.env) {
122
- return perSpawnTemplate || optionTemplate || env.E2B_TEMPLATE || void 0;
123
- }
124
- /**
125
- * Merge the factory-level {@link E2BProviderOptions.env} with the per-spawn
126
- * `SpawnConfig.env`, per-spawn winning on key conflicts. Returns `undefined`
127
- * when the merge is empty so callers can skip setting `envs` on the create
128
- * options entirely (rather than handing the SDK an empty object).
129
- */
130
- function resolveE2BEnv(optionEnv, perSpawnEnv) {
131
- const merged = {
132
- ...optionEnv,
133
- ...perSpawnEnv
134
- };
135
- return Object.keys(merged).length > 0 ? merged : void 0;
136
- }
137
- /**
138
- * Build a {@link SandboxProvider} backed by E2B.
139
- *
140
- * The provider owns a registry of live {@link E2BSandbox} instances keyed by
141
- * sandbox id, so the per-call `exec`/`readFile`/… hooks reuse the same warm
142
- * connection rather than reconnecting each time.
143
- */
144
- function createE2BProvider(options = {}) {
145
- const live = /* @__PURE__ */ new Map();
146
- const logger = options.logger ?? createLogger(consoleSink());
147
- const readinessTimeoutSeconds = options.readinessTimeoutSeconds ?? 60;
148
- async function loadSdk() {
149
- try {
150
- return (await import("e2b")).Sandbox;
151
- } catch {
152
- throw new Error("e2b is required for the E2B sandbox provider. Install it with: bun add e2b");
153
- }
154
- }
155
- function get(sandboxId) {
156
- const entry = live.get(sandboxId);
157
- if (!entry) throw new Error(`E2B sandbox ${sandboxId} is not tracked by this provider`);
158
- return entry;
159
- }
160
- async function killOwnedSandbox(sandbox) {
161
- try {
162
- await sandbox.kill();
163
- } catch {}
164
- }
165
- async function pauseOwnedSandbox(sandbox) {
166
- try {
167
- if (sandbox.pause) await sandbox.pause();
168
- else if (sandbox.betaPause) await sandbox.betaPause();
169
- else {
170
- logger.error("cannot pause E2B sandbox: this e2b SDK exposes neither pause() nor betaPause() (expected e2b@^2); leaving it to time out", { sandboxId: sandbox.sandboxId });
171
- return;
172
- }
173
- logger.info("paused E2B sandbox; reconnect later via the sandboxId option (CLI: --sandbox)", { sandboxId: sandbox.sandboxId });
174
- } catch (err) {
175
- logger.error("failed to pause E2B sandbox; it will run until its timeout", {
176
- sandboxId: sandbox.sandboxId,
177
- error: err instanceof Error ? err.message : String(err)
178
- });
179
- }
180
- }
181
- return {
182
- name: "e2b",
183
- async spawn(config) {
184
- const Sandbox = await loadSdk();
185
- const sb = config.sandbox ?? {};
186
- const apiKey = sb.apiKey ?? options.apiKey;
187
- const domain = sb.domain ?? options.domain;
188
- const template = resolveE2BTemplate(sb.template, options.template);
189
- const timeoutSeconds = config.limits?.timeout ?? options.timeoutSeconds;
190
- const connectId = sb.sandboxId ?? options.sandboxId;
191
- const envs = resolveE2BEnv(options.env, config.env);
192
- let sandbox;
193
- const owned = connectId === void 0;
194
- if (connectId !== void 0) {
195
- const connectOpts = {};
196
- if (apiKey !== void 0) connectOpts.apiKey = apiKey;
197
- if (domain !== void 0) connectOpts.domain = domain;
198
- if (timeoutSeconds !== void 0) connectOpts.timeoutMs = timeoutSeconds * 1e3;
199
- sandbox = await Sandbox.connect(connectId, connectOpts);
200
- } else {
201
- const createOpts = {};
202
- if (apiKey !== void 0) createOpts.apiKey = apiKey;
203
- if (domain !== void 0) createOpts.domain = domain;
204
- if (envs) createOpts.envs = envs;
205
- if (timeoutSeconds !== void 0) createOpts.timeoutMs = timeoutSeconds * 1e3;
206
- sandbox = template !== void 0 ? await Sandbox.create(template, createOpts) : await Sandbox.create(createOpts);
207
- }
208
- live.set(sandbox.sandboxId, {
209
- sandbox,
210
- env: envs,
211
- owned
212
- });
213
- try {
214
- await waitForE2BReady(sandbox, logger, {
215
- timeoutSeconds: readinessTimeoutSeconds,
216
- killOnTimeout: owned
217
- });
218
- } catch (err) {
219
- live.delete(sandbox.sandboxId);
220
- throw err;
221
- }
222
- const requestedCwd = config.cwd ?? options.cwd;
223
- let cwd;
224
- if (requestedCwd) {
225
- cwd = requestedCwd;
226
- await sandbox.commands.run(`mkdir -p ${JSON.stringify(cwd)}`).catch(() => {});
227
- } else cwd = await sandbox.commands.run("pwd").then((r) => r.stdout.trim()).catch(() => "") || "/home/user";
228
- if (options.pregame) try {
229
- await runE2BPregame(sandbox, logger, {
230
- name: options.pregame.name,
231
- content: options.pregame.content,
232
- cwd,
233
- envs
234
- });
235
- } catch (err) {
236
- if (owned) await sandbox.kill().catch(() => {});
237
- live.delete(sandbox.sandboxId);
238
- throw err;
239
- }
240
- return {
241
- id: sandbox.sandboxId,
242
- cwd
243
- };
244
- },
245
- /**
246
- * Live bidirectional stream — see `ExecutionContext.execStream`.
247
- *
248
- * Backed by E2B's pipe-based command API rather than `sandbox.pty`.
249
- * Both can carry stdin, but a PTY would force us to defeat terminal
250
- * semantics we never wanted (input echo, `\n`→`\r\n` rewriting, the
251
- * ~4096-byte canonical line cap, and stdout/stderr merged into one
252
- * stream). Pipes give split streams and byte-faithful framing for free.
253
- *
254
- * KNOWN RESIDUAL: `onStdout` / `onStderr` deliver `string`, already
255
- * decoded by the SDK. A chunk boundary that splits a multibyte
256
- * codepoint is therefore corrupted before it reaches us — we re-encode
257
- * to bytes to satisfy the seam, but cannot recover what the decoder
258
- * dropped. Newline framing and ASCII structure are unaffected, so
259
- * JSON-RPC still parses; the damage would be confined to non-ASCII
260
- * inside string values. If that ever bites, `sandbox.pty.create`
261
- * hands back raw `Uint8Array` and the Daytona PTY path in
262
- * `./daytona.ts` is the template for adopting it here.
263
- */
264
- async execStream(sandboxId, command, opts) {
265
- const { sandbox, env } = get(sandboxId);
266
- opts?.signal?.throwIfAborted();
267
- const warnBacklog = (which) => (bytes) => logger.warn("execStream consumer is not draining output", {
268
- sandboxId,
269
- stream: which,
270
- bufferedBytes: bytes
271
- });
272
- const stdout = new StreamQueue(warnBacklog("stdout"));
273
- const stderr = new StreamQueue(warnBacklog("stderr"));
274
- const pidFile = `/tmp/.zidane-stream-${Math.random().toString(36).slice(2, 10)}.pid`;
275
- const leader = `echo \$\$ > ${pidFile}; exec sh -c ${alwaysQuote(command)}`;
276
- const wrapped = `if setsid -w true 2>/dev/null; then exec setsid -w sh -c ${alwaysQuote(leader)}; else exec sh -c ${alwaysQuote(leader)}; fi`;
277
- const handle = await sandbox.commands.run(wrapped, {
278
- background: true,
279
- stdin: true,
280
- timeoutMs: E2B_STREAM_TIMEOUT_MS,
281
- ...opts?.cwd ? { cwd: opts.cwd } : {},
282
- envs: resolveE2BEnv(env, opts?.env),
283
- onStdout: (data) => stdout.push(new TextEncoder().encode(data)),
284
- onStderr: (data) => stderr.push(new TextEncoder().encode(data))
285
- });
286
- const pid = handle.pid;
287
- const exited = handle.wait().then((result) => result?.exitCode ?? 0).catch((err) => typeof err?.exitCode === "number" ? err.exitCode : 137).finally(() => {
288
- stdout.close();
289
- stderr.close();
290
- });
291
- let commandExited = false;
292
- exited.then(() => {
293
- commandExited = true;
294
- });
295
- const readLeaderPid = async () => {
296
- for (let attempt = 0; attempt < 20; attempt++) {
297
- const probe = await sandbox.commands.run(`cat ${pidFile} 2>/dev/null || true`).catch(() => null);
298
- const parsed = Number.parseInt(probe?.stdout?.trim() ?? "", 10);
299
- if (Number.isFinite(parsed) && parsed > 0) return parsed;
300
- if (commandExited) break;
301
- await new Promise((r) => setTimeout(r, 50));
302
- }
303
- return -1;
304
- };
305
- const leaderPid = await readLeaderPid();
306
- const kill = async () => {
307
- if (leaderPid > 0) await sandbox.commands.run(`kill -TERM -${leaderPid} 2>/dev/null || kill -TERM ${leaderPid} 2>/dev/null || true`).catch(() => {});
308
- await sandbox.commands.run(`rm -f ${pidFile}`).catch(() => {});
309
- await sandbox.commands.kill?.(pid).catch(() => {});
310
- };
311
- if (opts?.signal) if (opts.signal.aborted) kill();
312
- else {
313
- const onAbort = () => {
314
- kill();
315
- };
316
- const detach = () => opts.signal.removeEventListener("abort", onAbort);
317
- opts.signal.addEventListener("abort", onAbort, { once: true });
318
- exited.then(detach, detach);
319
- }
320
- return {
321
- pid,
322
- stdout,
323
- stderr,
324
- write: async (data) => {
325
- if (!sandbox.commands.sendStdin) throw new Error("E2B SDK is too old: `commands.sendStdin` is required for execStream");
326
- await sandbox.commands.sendStdin(pid, data);
327
- },
328
- kill,
329
- exited
330
- };
331
- },
332
- async exec(sandboxId, command, opts) {
333
- const { sandbox, env } = get(sandboxId);
334
- const timeoutMs = (opts?.timeout ?? 30) * 1e3;
335
- try {
336
- const result = await sandbox.commands.run(command, {
337
- cwd: opts?.cwd,
338
- envs: resolveE2BEnv(env, opts?.env),
339
- timeoutMs: timeoutMs > 0 ? timeoutMs : void 0
340
- });
341
- return {
342
- ...capBufferedExecOutput(result.stdout, result.stderr),
343
- exitCode: result.exitCode
344
- };
345
- } catch (err) {
346
- if (typeof err?.exitCode === "number") return {
347
- ...capBufferedExecOutput(err.stdout ?? "", err.stderr ?? err.message ?? ""),
348
- exitCode: err.exitCode
349
- };
350
- return {
351
- stdout: "",
352
- stderr: err?.message ?? String(err),
353
- exitCode: 124
354
- };
355
- }
356
- },
357
- async readFile(sandboxId, path) {
358
- return get(sandboxId).sandbox.files.read(path);
359
- },
360
- async writeFile(sandboxId, path, content, encoding = "utf-8") {
361
- const data = typeof content === "string" ? encoding === "utf-8" || encoding === "utf8" ? content : Buffer.from(content, encoding) : content;
362
- await get(sandboxId).sandbox.files.write(path, data);
363
- },
364
- async listFiles(sandboxId, path) {
365
- return (await get(sandboxId).sandbox.files.list(path)).map((e) => e.type === "dir" ? `${e.name}/` : e.name);
366
- },
367
- async destroy(sandboxId) {
368
- const entry = live.get(sandboxId);
369
- if (!entry) return;
370
- if (entry.owned) {
371
- const action = options.onDestroy ?? "kill";
372
- if (action === "pause") await pauseOwnedSandbox(entry.sandbox);
373
- else if (action === "kill") await killOwnedSandbox(entry.sandbox);
374
- }
375
- live.delete(sandboxId);
376
- }
377
- };
378
- }
379
- //#endregion
380
- export { createE2BProvider, resolveE2BEnv, resolveE2BTemplate, runE2BPregame, waitForE2BReady };
381
-
382
- //# sourceMappingURL=e2b.js.map
1
+ export { t as createE2BProvider, a as resolveE2BEnv, n as resolveE2BTemplate, r as runE2BPregame, i as waitForE2BReady } from "../e2b-CEVOdRib.js";
@@ -1,2 +1,2 @@
1
- import { n as createSandboxContext, t as SandboxProvider } from "../sandbox-BH0WQkXn.js";
1
+ import { n as createSandboxContext, t as SandboxProvider } from "../sandbox-C5dR5DwQ.js";
2
2
  export { SandboxProvider, createSandboxContext };
@@ -31,6 +31,11 @@ function createSandboxContext(provider) {
31
31
  return provider.exec(getSandboxId(handle), command, options);
32
32
  },
33
33
  ...provider.execStream ? { execStream: async (handle, command, options) => provider.execStream(getSandboxId(handle), command, options) } : {},
34
+ ...provider.openTerminal ? { openTerminal: async (handle, options) => provider.openTerminal(getSandboxId(handle), {
35
+ ...options,
36
+ cwd: options.cwd ?? handle.cwd
37
+ }) } : {},
38
+ ...provider.reconnectTerminal ? { reconnectTerminal: async (handle, id, options) => provider.reconnectTerminal(getSandboxId(handle), id, options) } : {},
34
39
  async readFile(handle, path) {
35
40
  return provider.readFile(getSandboxId(handle), path);
36
41
  },
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox.js","names":[],"sources":["../../src/contexts/sandbox.ts"],"sourcesContent":["/**\n * Remote sandbox execution context.\n *\n * Offloads execution to a remote sandbox API (e.g. Rivet, E2B).\n * Specific providers implement the SandboxProvider interface.\n */\n\nimport type { Buffer } from 'node:buffer'\nimport type { ContextCapabilities, ExecResult, ExecutionContext, ExecutionHandle, ListFilesOptions, SpawnConfig, StreamHandle } from './types'\nimport { fileSizeViaExec } from './exec-file-size'\nimport { globFilesViaShell } from './glob-shell'\n\n// ---------------------------------------------------------------------------\n// Sandbox provider interface\n// ---------------------------------------------------------------------------\n\nexport interface SandboxProvider {\n name: string\n spawn: (config: SpawnConfig) => Promise<{ id: string, cwd: string }>\n exec: (sandboxId: string, command: string, options?: { cwd?: string, env?: Record<string, string>, timeout?: number }) => Promise<ExecResult>\n readFile: (sandboxId: string, path: string) => Promise<string>\n writeFile: (sandboxId: string, path: string, content: string | Buffer, encoding?: BufferEncoding) => Promise<void>\n listFiles: (sandboxId: string, path: string, options?: ListFilesOptions) => Promise<string[]>\n destroy: (sandboxId: string) => Promise<void>\n /**\n * Optional live bidirectional stream — see {@link ExecutionContext.execStream}\n * for the implementor contract. Providers whose backing API has no stdin\n * channel omit it; `createSandboxContext` then leaves `execStream` off the\n * context entirely so `capabilities.stream` stays false and callers get a\n * clear \"unsupported\" error instead of a silent host spawn.\n */\n execStream?: (\n sandboxId: string,\n command: string,\n options?: { cwd?: string, env?: Record<string, string>, signal?: AbortSignal },\n ) => Promise<StreamHandle>\n}\n\n// ---------------------------------------------------------------------------\n// Sandbox execution context\n// ---------------------------------------------------------------------------\n\nexport function createSandboxContext(provider: SandboxProvider): ExecutionContext {\n const sandboxes = new Map<string, string>()\n const destroyed = new Set<string>()\n\n // The handle id IS the sandbox id (set in `spawn` below), so the map is an\n // identity record of sandboxes this context instance spawned. A handle this\n // instance never spawned falls back to `handle.id` — the re-attach path for\n // durable hosts that journal the handle and hand it back via\n // `AgentOptions.handle` on a replay where `spawn` never re-ran. An\n // EXPLICITLY-destroyed handle still throws (a use-after-free guard, distinct\n // from never-spawned).\n function getSandboxId(handle: ExecutionHandle): string {\n if (destroyed.has(handle.id))\n throw new Error(`Sandbox ${handle.id} not found`)\n return sandboxes.get(handle.id) ?? handle.id\n }\n\n return {\n type: 'sandbox',\n\n capabilities: {\n shell: true,\n filesystem: true,\n glob: true,\n network: true,\n gpu: false,\n stream: provider.execStream !== undefined,\n } satisfies ContextCapabilities,\n\n async spawn(config?: SpawnConfig): Promise<ExecutionHandle> {\n const result = await provider.spawn(config ?? {})\n const handle: ExecutionHandle = { id: result.id, type: 'sandbox', cwd: result.cwd }\n sandboxes.set(handle.id, result.id)\n return handle\n },\n\n async exec(handle: ExecutionHandle, command: string, options?): Promise<ExecResult> {\n return provider.exec(getSandboxId(handle), command, options)\n },\n\n // Conditionally present: `capabilities.stream` is derived from the\n // provider, so the method must disappear too when the provider has no\n // stdin channel. A stub that always throws would make the two disagree.\n ...(provider.execStream\n ? {\n execStream: async (\n handle: ExecutionHandle,\n command: string,\n options?: { cwd?: string, env?: Record<string, string>, signal?: AbortSignal },\n ): Promise<StreamHandle> => provider.execStream!(getSandboxId(handle), command, options),\n }\n : {}),\n\n async readFile(handle: ExecutionHandle, path: string): Promise<string> {\n return provider.readFile(getSandboxId(handle), path)\n },\n\n async fileSize(handle: ExecutionHandle, path: string): Promise<number | null> {\n // Shared exec-probed capability (see exec-file-size.ts). Probe\n // through the sandbox's shell rather than the provider's file API:\n // `readFile` buffers the WHOLE file into host memory, so the\n // whole-read guard needs the size BEFORE any transfer happens. One\n // exec round-trip per whole-read tool call (read_file / edit) — the\n // price of not ballooning the host on a multi-GB sandbox file.\n return fileSizeViaExec(command => provider.exec(getSandboxId(handle), command), path)\n },\n\n async writeFile(handle: ExecutionHandle, path: string, content: string | Buffer, encoding?: BufferEncoding): Promise<void> {\n return provider.writeFile(getSandboxId(handle), path, content, encoding)\n },\n\n async listFiles(handle: ExecutionHandle, path: string, options?: ListFilesOptions): Promise<string[]> {\n const sandboxId = getSandboxId(handle)\n if (options?.glob) {\n return globFilesViaShell(\n path,\n command => provider.exec(sandboxId, command, { cwd: handle.cwd }),\n options?.limit ?? 1000,\n )\n }\n return provider.listFiles(sandboxId, path, options)\n },\n\n async destroy(handle: ExecutionHandle): Promise<void> {\n const id = sandboxes.get(handle.id)\n if (!id)\n return\n await provider.destroy(id)\n sandboxes.delete(handle.id)\n // Mark as torn down so a later op on this exact handle fails loudly\n // (use-after-free) instead of silently re-attaching by id.\n destroyed.add(handle.id)\n },\n }\n}\n"],"mappings":";;AA0CA,SAAgB,qBAAqB,UAA6C;CAChF,MAAM,4BAAY,IAAI,IAAoB;CAC1C,MAAM,4BAAY,IAAI,IAAY;CASlC,SAAS,aAAa,QAAiC;EACrD,IAAI,UAAU,IAAI,OAAO,EAAE,GACzB,MAAM,IAAI,MAAM,WAAW,OAAO,GAAG,WAAW;EAClD,OAAO,UAAU,IAAI,OAAO,EAAE,KAAK,OAAO;CAC5C;CAEA,OAAO;EACL,MAAM;EAEN,cAAc;GACZ,OAAO;GACP,YAAY;GACZ,MAAM;GACN,SAAS;GACT,KAAK;GACL,QAAQ,SAAS,eAAe,KAAA;EAClC;EAEA,MAAM,MAAM,QAAgD;GAC1D,MAAM,SAAS,MAAM,SAAS,MAAM,UAAU,CAAC,CAAC;GAChD,MAAM,SAA0B;IAAE,IAAI,OAAO;IAAI,MAAM;IAAW,KAAK,OAAO;GAAI;GAClF,UAAU,IAAI,OAAO,IAAI,OAAO,EAAE;GAClC,OAAO;EACT;EAEA,MAAM,KAAK,QAAyB,SAAiB,SAA+B;GAClF,OAAO,SAAS,KAAK,aAAa,MAAM,GAAG,SAAS,OAAO;EAC7D;EAKA,GAAI,SAAS,aACT,EACE,YAAY,OACV,QACA,SACA,YAC0B,SAAS,WAAY,aAAa,MAAM,GAAG,SAAS,OAAO,EACzF,IACA,CAAC;EAEL,MAAM,SAAS,QAAyB,MAA+B;GACrE,OAAO,SAAS,SAAS,aAAa,MAAM,GAAG,IAAI;EACrD;EAEA,MAAM,SAAS,QAAyB,MAAsC;GAO5E,OAAO,iBAAgB,YAAW,SAAS,KAAK,aAAa,MAAM,GAAG,OAAO,GAAG,IAAI;EACtF;EAEA,MAAM,UAAU,QAAyB,MAAc,SAA0B,UAA0C;GACzH,OAAO,SAAS,UAAU,aAAa,MAAM,GAAG,MAAM,SAAS,QAAQ;EACzE;EAEA,MAAM,UAAU,QAAyB,MAAc,SAA+C;GACpG,MAAM,YAAY,aAAa,MAAM;GACrC,IAAI,SAAS,MACX,OAAO,kBACL,OACA,YAAW,SAAS,KAAK,WAAW,SAAS,EAAE,KAAK,OAAO,IAAI,CAAC,GAChE,SAAS,SAAS,GACpB;GAEF,OAAO,SAAS,UAAU,WAAW,MAAM,OAAO;EACpD;EAEA,MAAM,QAAQ,QAAwC;GACpD,MAAM,KAAK,UAAU,IAAI,OAAO,EAAE;GAClC,IAAI,CAAC,IACH;GACF,MAAM,SAAS,QAAQ,EAAE;GACzB,UAAU,OAAO,OAAO,EAAE;GAG1B,UAAU,IAAI,OAAO,EAAE;EACzB;CACF;AACF"}
1
+ {"version":3,"file":"sandbox.js","names":[],"sources":["../../src/contexts/sandbox.ts"],"sourcesContent":["/**\n * Remote sandbox execution context.\n *\n * Offloads execution to a remote sandbox API (e.g. Rivet, E2B).\n * Specific providers implement the SandboxProvider interface.\n */\n\nimport type { Buffer } from 'node:buffer'\nimport type { ContextCapabilities, ExecResult, ExecutionContext, ExecutionHandle, ListFilesOptions, SpawnConfig, StreamHandle, TerminalOptions, TerminalProcess } from './types'\nimport { fileSizeViaExec } from './exec-file-size'\nimport { globFilesViaShell } from './glob-shell'\n\n// ---------------------------------------------------------------------------\n// Sandbox provider interface\n// ---------------------------------------------------------------------------\n\nexport interface SandboxProvider {\n name: string\n spawn: (config: SpawnConfig) => Promise<{ id: string, cwd: string }>\n exec: (sandboxId: string, command: string, options?: { cwd?: string, env?: Record<string, string>, timeout?: number }) => Promise<ExecResult>\n readFile: (sandboxId: string, path: string) => Promise<string>\n writeFile: (sandboxId: string, path: string, content: string | Buffer, encoding?: BufferEncoding) => Promise<void>\n listFiles: (sandboxId: string, path: string, options?: ListFilesOptions) => Promise<string[]>\n destroy: (sandboxId: string) => Promise<void>\n /**\n * Optional live bidirectional stream — see {@link ExecutionContext.execStream}\n * for the implementor contract. Providers whose backing API has no stdin\n * channel omit it; `createSandboxContext` then leaves `execStream` off the\n * context entirely so `capabilities.stream` stays false and callers get a\n * clear \"unsupported\" error instead of a silent host spawn.\n */\n execStream?: (\n sandboxId: string,\n command: string,\n options?: { cwd?: string, env?: Record<string, string>, signal?: AbortSignal },\n ) => Promise<StreamHandle>\n /** Optional interactive terminal — see {@link ExecutionContext.openTerminal}. */\n openTerminal?: (sandboxId: string, options: TerminalOptions) => Promise<TerminalProcess>\n /** Re-attach to a terminal by id — see {@link ExecutionContext.reconnectTerminal}. */\n reconnectTerminal?: (sandboxId: string, id: string, options: TerminalOptions) => Promise<TerminalProcess | null>\n}\n\n// ---------------------------------------------------------------------------\n// Sandbox execution context\n// ---------------------------------------------------------------------------\n\nexport function createSandboxContext(provider: SandboxProvider): ExecutionContext {\n const sandboxes = new Map<string, string>()\n const destroyed = new Set<string>()\n\n // The handle id IS the sandbox id (set in `spawn` below), so the map is an\n // identity record of sandboxes this context instance spawned. A handle this\n // instance never spawned falls back to `handle.id` — the re-attach path for\n // durable hosts that journal the handle and hand it back via\n // `AgentOptions.handle` on a replay where `spawn` never re-ran. An\n // EXPLICITLY-destroyed handle still throws (a use-after-free guard, distinct\n // from never-spawned).\n function getSandboxId(handle: ExecutionHandle): string {\n if (destroyed.has(handle.id))\n throw new Error(`Sandbox ${handle.id} not found`)\n return sandboxes.get(handle.id) ?? handle.id\n }\n\n return {\n type: 'sandbox',\n\n capabilities: {\n shell: true,\n filesystem: true,\n glob: true,\n network: true,\n gpu: false,\n stream: provider.execStream !== undefined,\n } satisfies ContextCapabilities,\n\n async spawn(config?: SpawnConfig): Promise<ExecutionHandle> {\n const result = await provider.spawn(config ?? {})\n const handle: ExecutionHandle = { id: result.id, type: 'sandbox', cwd: result.cwd }\n sandboxes.set(handle.id, result.id)\n return handle\n },\n\n async exec(handle: ExecutionHandle, command: string, options?): Promise<ExecResult> {\n return provider.exec(getSandboxId(handle), command, options)\n },\n\n // Conditionally present: `capabilities.stream` is derived from the\n // provider, so the method must disappear too when the provider has no\n // stdin channel. A stub that always throws would make the two disagree.\n ...(provider.execStream\n ? {\n execStream: async (\n handle: ExecutionHandle,\n command: string,\n options?: { cwd?: string, env?: Record<string, string>, signal?: AbortSignal },\n ): Promise<StreamHandle> => provider.execStream!(getSandboxId(handle), command, options),\n }\n : {}),\n\n ...(provider.openTerminal\n ? {\n openTerminal: async (handle: ExecutionHandle, options: TerminalOptions): Promise<TerminalProcess> =>\n provider.openTerminal!(getSandboxId(handle), { ...options, cwd: options.cwd ?? handle.cwd }),\n }\n : {}),\n ...(provider.reconnectTerminal\n ? {\n reconnectTerminal: async (handle: ExecutionHandle, id: string, options: TerminalOptions): Promise<TerminalProcess | null> =>\n provider.reconnectTerminal!(getSandboxId(handle), id, options),\n }\n : {}),\n\n async readFile(handle: ExecutionHandle, path: string): Promise<string> {\n return provider.readFile(getSandboxId(handle), path)\n },\n\n async fileSize(handle: ExecutionHandle, path: string): Promise<number | null> {\n // Shared exec-probed capability (see exec-file-size.ts). Probe\n // through the sandbox's shell rather than the provider's file API:\n // `readFile` buffers the WHOLE file into host memory, so the\n // whole-read guard needs the size BEFORE any transfer happens. One\n // exec round-trip per whole-read tool call (read_file / edit) — the\n // price of not ballooning the host on a multi-GB sandbox file.\n return fileSizeViaExec(command => provider.exec(getSandboxId(handle), command), path)\n },\n\n async writeFile(handle: ExecutionHandle, path: string, content: string | Buffer, encoding?: BufferEncoding): Promise<void> {\n return provider.writeFile(getSandboxId(handle), path, content, encoding)\n },\n\n async listFiles(handle: ExecutionHandle, path: string, options?: ListFilesOptions): Promise<string[]> {\n const sandboxId = getSandboxId(handle)\n if (options?.glob) {\n return globFilesViaShell(\n path,\n command => provider.exec(sandboxId, command, { cwd: handle.cwd }),\n options?.limit ?? 1000,\n )\n }\n return provider.listFiles(sandboxId, path, options)\n },\n\n async destroy(handle: ExecutionHandle): Promise<void> {\n const id = sandboxes.get(handle.id)\n if (!id)\n return\n await provider.destroy(id)\n sandboxes.delete(handle.id)\n // Mark as torn down so a later op on this exact handle fails loudly\n // (use-after-free) instead of silently re-attaching by id.\n destroyed.add(handle.id)\n },\n }\n}\n"],"mappings":";;AA8CA,SAAgB,qBAAqB,UAA6C;CAChF,MAAM,4BAAY,IAAI,IAAoB;CAC1C,MAAM,4BAAY,IAAI,IAAY;CASlC,SAAS,aAAa,QAAiC;EACrD,IAAI,UAAU,IAAI,OAAO,EAAE,GACzB,MAAM,IAAI,MAAM,WAAW,OAAO,GAAG,WAAW;EAClD,OAAO,UAAU,IAAI,OAAO,EAAE,KAAK,OAAO;CAC5C;CAEA,OAAO;EACL,MAAM;EAEN,cAAc;GACZ,OAAO;GACP,YAAY;GACZ,MAAM;GACN,SAAS;GACT,KAAK;GACL,QAAQ,SAAS,eAAe,KAAA;EAClC;EAEA,MAAM,MAAM,QAAgD;GAC1D,MAAM,SAAS,MAAM,SAAS,MAAM,UAAU,CAAC,CAAC;GAChD,MAAM,SAA0B;IAAE,IAAI,OAAO;IAAI,MAAM;IAAW,KAAK,OAAO;GAAI;GAClF,UAAU,IAAI,OAAO,IAAI,OAAO,EAAE;GAClC,OAAO;EACT;EAEA,MAAM,KAAK,QAAyB,SAAiB,SAA+B;GAClF,OAAO,SAAS,KAAK,aAAa,MAAM,GAAG,SAAS,OAAO;EAC7D;EAKA,GAAI,SAAS,aACT,EACE,YAAY,OACV,QACA,SACA,YAC0B,SAAS,WAAY,aAAa,MAAM,GAAG,SAAS,OAAO,EACzF,IACA,CAAC;EAEL,GAAI,SAAS,eACT,EACE,cAAc,OAAO,QAAyB,YAC5C,SAAS,aAAc,aAAa,MAAM,GAAG;GAAE,GAAG;GAAS,KAAK,QAAQ,OAAO,OAAO;EAAI,CAAC,EAC/F,IACA,CAAC;EACL,GAAI,SAAS,oBACT,EACE,mBAAmB,OAAO,QAAyB,IAAY,YAC7D,SAAS,kBAAmB,aAAa,MAAM,GAAG,IAAI,OAAO,EACjE,IACA,CAAC;EAEL,MAAM,SAAS,QAAyB,MAA+B;GACrE,OAAO,SAAS,SAAS,aAAa,MAAM,GAAG,IAAI;EACrD;EAEA,MAAM,SAAS,QAAyB,MAAsC;GAO5E,OAAO,iBAAgB,YAAW,SAAS,KAAK,aAAa,MAAM,GAAG,OAAO,GAAG,IAAI;EACtF;EAEA,MAAM,UAAU,QAAyB,MAAc,SAA0B,UAA0C;GACzH,OAAO,SAAS,UAAU,aAAa,MAAM,GAAG,MAAM,SAAS,QAAQ;EACzE;EAEA,MAAM,UAAU,QAAyB,MAAc,SAA+C;GACpG,MAAM,YAAY,aAAa,MAAM;GACrC,IAAI,SAAS,MACX,OAAO,kBACL,OACA,YAAW,SAAS,KAAK,WAAW,SAAS,EAAE,KAAK,OAAO,IAAI,CAAC,GAChE,SAAS,SAAS,GACpB;GAEF,OAAO,SAAS,UAAU,WAAW,MAAM,OAAO;EACpD;EAEA,MAAM,QAAQ,QAAwC;GACpD,MAAM,KAAK,UAAU,IAAI,OAAO,EAAE;GAClC,IAAI,CAAC,IACH;GACF,MAAM,SAAS,QAAQ,EAAE;GACzB,UAAU,OAAO,OAAO,EAAE;GAG1B,UAAU,IAAI,OAAO,EAAE;EACzB;CACF;AACF"}