openpond 0.2.0 → 0.2.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 (220) hide show
  1. package/dist/chunks/actions-command-QP3NMDK4.js +2 -0
  2. package/dist/chunks/app-layer-N7VFRVJ2.js +3 -0
  3. package/dist/chunks/app-server-runtime-OCLPUI7F.js +2 -0
  4. package/dist/chunks/apps-AMG75TI4.js +2 -0
  5. package/dist/chunks/chunk-22UARBPW.js +3 -0
  6. package/dist/chunks/chunk-3A7HZJNE.js +1 -0
  7. package/dist/chunks/chunk-3M53YXEI.js +2 -0
  8. package/dist/chunks/chunk-3NDRIQTI.js +2 -0
  9. package/dist/chunks/chunk-5BBVEWG3.js +2 -0
  10. package/dist/chunks/chunk-5O7ZVCMV.js +6 -0
  11. package/dist/chunks/chunk-6FA3GG5B.js +33 -0
  12. package/dist/chunks/chunk-6MI4KKWF.js +2 -0
  13. package/dist/chunks/chunk-BBG546O6.js +6 -0
  14. package/dist/chunks/chunk-BX4J2VDU.js +2 -0
  15. package/dist/chunks/chunk-BZMVB3GS.js +2 -0
  16. package/dist/chunks/chunk-C5LOZSVS.js +2 -0
  17. package/dist/chunks/chunk-CWQWV2T3.js +2 -0
  18. package/dist/chunks/chunk-DUA3QP6Y.js +19 -0
  19. package/dist/chunks/chunk-EAPFMACH.js +10 -0
  20. package/dist/chunks/chunk-ES2ISFJC.js +66 -0
  21. package/dist/chunks/chunk-F65NIZLM.js +2199 -0
  22. package/dist/chunks/chunk-FGJ5LFPL.js +5 -0
  23. package/dist/chunks/chunk-FTQLQJQV.js +2 -0
  24. package/dist/chunks/chunk-FY7OQ5RK.js +24 -0
  25. package/dist/chunks/chunk-FYCJSUFV.js +53 -0
  26. package/dist/chunks/chunk-GLUWATL5.js +2 -0
  27. package/dist/chunks/chunk-H7IWJN7L.js +17 -0
  28. package/dist/chunks/chunk-HZP5U2AA.js +3 -0
  29. package/dist/chunks/chunk-I5K74TOH.js +3 -0
  30. package/dist/chunks/chunk-IR3YJWPW.js +7 -0
  31. package/dist/chunks/chunk-KU7QOHFT.js +2872 -0
  32. package/dist/chunks/chunk-KV553EWX.js +16 -0
  33. package/dist/chunks/chunk-MGN6GLNZ.js +2 -0
  34. package/dist/chunks/chunk-OG5Q6NXK.js +28 -0
  35. package/dist/chunks/chunk-OGPHXXCD.js +1 -0
  36. package/dist/chunks/chunk-PI36UHRA.js +18 -0
  37. package/dist/chunks/chunk-RWSAGQTP.js +2 -0
  38. package/dist/chunks/chunk-SAE4OIPC.js +2 -0
  39. package/dist/chunks/chunk-SDO4FC4Q.js +2 -0
  40. package/dist/chunks/chunk-UKUVMXOW.js +12 -0
  41. package/dist/chunks/chunk-VCLCFK3O.js +36 -0
  42. package/dist/chunks/chunk-VYUMTRB3.js +5 -0
  43. package/dist/chunks/chunk-X37KMV27.js +1 -0
  44. package/dist/chunks/chunk-XDHAGACI.js +3 -0
  45. package/dist/chunks/chunk-XEOEKFG6.js +71 -0
  46. package/dist/chunks/chunk-ZF7TEGY5.js +5 -0
  47. package/dist/chunks/chunk-ZVOO7FKM.js +2 -0
  48. package/dist/chunks/cli-M2FG7SSI.js +2 -0
  49. package/dist/chunks/configuration-command-XBKBIZBO.js +2 -0
  50. package/dist/chunks/continual-D75WA7E7.js +7 -0
  51. package/dist/chunks/core-commands-LUZVWXQR.js +2 -0
  52. package/dist/chunks/database-X2CUV732.js +2 -0
  53. package/dist/chunks/desktop-test-KGC4JVJ7.js +3 -0
  54. package/dist/chunks/dist-NKLXFA37.js +2 -0
  55. package/dist/chunks/extension-NQ7N5LEY.js +5 -0
  56. package/dist/chunks/help-MWK66XZK.js +8 -0
  57. package/dist/chunks/module-ES6BEMUI-ZVL3F6NW.js +2 -0
  58. package/dist/chunks/module-asyncify-2EFITU5U-R7TVXNAE.js +2 -0
  59. package/dist/chunks/opchat-XJZA3QKZ.js +3 -0
  60. package/dist/chunks/organizations-UECDFEYE.js +2 -0
  61. package/dist/chunks/profile-KUMIZURM.js +3 -0
  62. package/dist/chunks/project-agent-NILMJHLV.js +2 -0
  63. package/dist/chunks/sandbox-command-QHH65OSE.js +2 -0
  64. package/dist/chunks/sandbox-template-N7I63PNU.js +10 -0
  65. package/dist/chunks/src-724HF43W.js +82 -0
  66. package/dist/chunks/src-VTKTTKQO.js +319 -0
  67. package/dist/chunks/taskset-PISBOILQ.js +2 -0
  68. package/dist/chunks/teams-bot-UV4RU53M.js +3 -0
  69. package/dist/chunks/training-2NDOWH5S.js +2 -0
  70. package/dist/chunks/workspaces-XXT4KUD3.js +2 -0
  71. package/dist/cli.js +3 -109
  72. package/dist/index.js +1 -31230
  73. package/dist/sandbox-template/manifest.js +1 -18380
  74. package/dist/web/assets/App-DxecRQUL.js +176 -0
  75. package/dist/web/assets/AppDialog-B65Eo3gp.js +1 -0
  76. package/dist/web/assets/AppTerminalPanel-B2EKQM7W.js +2 -0
  77. package/dist/web/assets/{AppsView-B1NUuAIf.js → AppsView-BBoVe7s2.js} +1 -1
  78. package/dist/web/assets/{BrowserSidebar-DOvYxXeP.js → BrowserSidebar-CSM1atSJ.js} +1 -1
  79. package/dist/web/assets/{CartesianChart-pOrYpzBr.js → CartesianChart-CJKfXiEG.js} +1 -1
  80. package/dist/web/assets/{CollaborationTabs-CgbR-MBJ.js → CollaborationTabs-BMZamWFC.js} +1 -1
  81. package/dist/web/assets/{CommandMenu-CrIr4qUX.js → CommandMenu-B3U1z2eo.js} +1 -1
  82. package/dist/web/assets/{CommunityView-CvAVQ_HZ.js → CommunityView-CTyRUcfy.js} +1 -1
  83. package/dist/web/assets/{ComposerCreateImproveStrip-DybcKwwd.js → ComposerCreateImproveStrip-D7usvRtK.js} +1 -1
  84. package/dist/web/assets/GetStartedView-Ibu7oKWJ.js +1 -0
  85. package/dist/web/assets/HostedModelLearningReview-qnzIkT70.js +1 -0
  86. package/dist/web/assets/HostedModelLearningSettings--PKjpYsy.js +1 -0
  87. package/dist/web/assets/LabModelVersionDetailPage-s9uUN6fV.js +1 -0
  88. package/dist/web/assets/{LabSkillSidebar-CuaYrtiu.js → LabSkillSidebar-BKYseMiJ.js} +1 -1
  89. package/dist/web/assets/LabsRoute-C1FWCoYb.css +1 -0
  90. package/dist/web/assets/LabsRoute-DoRs0K6v.js +32 -0
  91. package/dist/web/assets/MainChatThread-DvuyMcMB.js +2 -0
  92. package/dist/web/assets/MainPane-BWwcxgHD.js +8 -0
  93. package/dist/web/assets/{MarkdownText-DOlVQR8a.js → MarkdownText-D8XC5UT_.js} +1 -1
  94. package/dist/web/assets/{Messages-DMubppta.js → Messages-e4A8JUjD.js} +6 -6
  95. package/dist/web/assets/{NativeSkillSidebar-DSFwZ-od.js → NativeSkillSidebar-D2Joh8XB.js} +1 -1
  96. package/dist/web/assets/{NewExperienceSwitcher-Dj0ePIJ-.js → NewExperienceSwitcher-CzGebt2E.js} +1 -1
  97. package/dist/web/assets/{NewProjectDialog-B8NQV-Ji.js → NewProjectDialog-CdMTSxUE.js} +1 -1
  98. package/dist/web/assets/{OutputsPage-D_LDYTgV.js → OutputsPage-m7cSb8dW.js} +1 -1
  99. package/dist/web/assets/{ProjectsPage-xjDYPc_W.js → ProjectsPage-C9mz8W1g.js} +1 -1
  100. package/dist/web/assets/RightChatPanelStack-B4LEqKEj.js +1 -0
  101. package/dist/web/assets/{RightSidebarHomePanel-j0VckZUu.js → RightSidebarHomePanel-DOeUsH7h.js} +1 -1
  102. package/dist/web/assets/{ScheduledWorkPage-1aT4bBY-.js → ScheduledWorkPage-UXZSSWgA.js} +1 -1
  103. package/dist/web/assets/{SettingsView-BSpuMDpv.js → SettingsView-CQm1ai73.js} +7 -7
  104. package/dist/web/assets/TeamChatView-C4haojB7.js +3 -0
  105. package/dist/web/assets/{TerminalOverlay-CrSwUk2d.js → TerminalOverlay-p2GZsuyQ.js} +3 -3
  106. package/dist/web/assets/{TrainingCreationPanel-B4HMRwUg.js → TrainingCreationPanel-BYJSlO8X.js} +1 -1
  107. package/dist/web/assets/{TrainingDraftPanel-D4r1tN3I.js → TrainingDraftPanel-DR5KlayH.js} +1 -1
  108. package/dist/web/assets/{UsageSettingsSection-2aymqwIM.js → UsageSettingsSection-BQToNXE4.js} +5 -5
  109. package/dist/web/assets/{WorkSidebarPanel-B0X0OiR6.js → WorkSidebarPanel--EeytWeg.js} +1 -1
  110. package/dist/web/assets/WorkspaceDiffPanel-BrovSYhn.js +14 -0
  111. package/dist/web/assets/{WorkspaceEnvironmentMenu-OAfMEt7L.js → WorkspaceEnvironmentMenu-l-keRgvj.js} +3 -3
  112. package/dist/web/assets/{WorkspaceGitDialogs-YxcPH2Rq.js → WorkspaceGitDialogs-aicWzaZu.js} +1 -1
  113. package/dist/web/assets/{WorkspaceMonacoEditor-COKTiQZl.js → WorkspaceMonacoEditor-CO_E74jM.js} +36 -36
  114. package/dist/web/assets/{arrow-up-right-_TX-awvK.js → arrow-up-right-rwPXNfVn.js} +1 -1
  115. package/dist/web/assets/chat-file-links-B3jDstSC.js +1 -0
  116. package/dist/web/assets/chevron-up-D089nvYQ.js +1 -0
  117. package/dist/web/assets/{clipboard-CyRSS8Sy.js → clipboard-DwEExyU4.js} +1 -1
  118. package/dist/web/assets/{cloud-upload-uBJBUYTy.js → cloud-upload-D2he0-vQ.js} +1 -1
  119. package/dist/web/assets/{cssMode-BrXSsZYs.js → cssMode-DS4k0NcI.js} +1 -1
  120. package/dist/web/assets/{folder-open-DktdZNW7.js → folder-open-CAOLduKD.js} +1 -1
  121. package/dist/web/assets/{folder-plus-DO06i9Vo.js → folder-plus-D56MrxVT.js} +1 -1
  122. package/dist/web/assets/{git-commit-horizontal-zFSIkPs7.js → git-commit-horizontal-CeNM0oKJ.js} +1 -1
  123. package/dist/web/assets/{htmlMode-X9UMFkjt.js → htmlMode-Xkni5erh.js} +1 -1
  124. package/dist/web/assets/{index-ByQIHpc9.css → index-BGMzUaup.css} +1 -1
  125. package/dist/web/assets/{index-UOGdfLzi.js → index-KwyAyscP.js} +1 -1
  126. package/dist/web/assets/{info-BEJXUqCD.js → info-CcrBaEE_.js} +1 -1
  127. package/dist/web/assets/{jsonMode-DIsB-j2E.js → jsonMode-C4YPbQB7.js} +1 -1
  128. package/dist/web/assets/{lspLanguageFeatures-CmZ17KpA.js → lspLanguageFeatures-CF5oMTz6.js} +1 -1
  129. package/dist/web/assets/{minimize-2-DumTpFtE.js → minimize-2-DzHQnInk.js} +1 -1
  130. package/dist/web/assets/{monaco.contribution-DJ_NmcHu.js → monaco.contribution-0EN4mGCC.js} +2 -2
  131. package/dist/web/assets/{monaco.contribution-YVDfJcG4.js → monaco.contribution-B4qcTP0w.js} +2 -2
  132. package/dist/web/assets/{monaco.contribution-LZEujgny.js → monaco.contribution-CJK_NrBm.js} +2 -2
  133. package/dist/web/assets/{monaco.contribution-D6w5PJji.js → monaco.contribution-CkPGKNd-.js} +2 -2
  134. package/dist/web/assets/{play-CLFeH7CU.js → play-p3-AMTPL.js} +1 -1
  135. package/dist/web/assets/{python-Djbda_qZ.js → python-B0kpTxAZ.js} +1 -1
  136. package/dist/web/assets/{refresh-cw-B4IpQ_7Q.js → refresh-cw-_jbTIzzr.js} +1 -1
  137. package/dist/web/assets/{save-BbTHztnA.js → save-Cy6hEotx.js} +1 -1
  138. package/dist/web/assets/{square-BJrVbmz6.js → square-DKQkcrOH.js} +1 -1
  139. package/dist/web/assets/{toggleHighContrast-BopU5W9S.js → toggleHighContrast-Bnk1VVVq.js} +1 -1
  140. package/dist/web/assets/{tsMode-CH_0_YDX.js → tsMode-BDrSVy7V.js} +1 -1
  141. package/dist/web/assets/{upload-UumVeufu.js → upload-COn0my_O.js} +1 -1
  142. package/dist/web/assets/{useLocalAgentSchedules-BRa23U7O.js → useLocalAgentSchedules-iZNB4Oee.js} +1 -1
  143. package/dist/web/assets/{wifi-off-BWJWivn6.js → wifi-off-Cqt-ZLXY.js} +1 -1
  144. package/dist/web/assets/{workers-pTe8RvSI.js → workers-hu0Ym93h.js} +1 -1
  145. package/dist/web/assets/{yaml-DNLASORn.js → yaml-D-JLDGL6.js} +1 -1
  146. package/dist/web/index.html +2 -2
  147. package/package.json +4 -3
  148. package/dist/chunks/actions-command-6N5XWMR6.js +0 -185
  149. package/dist/chunks/app-layer-F3CGXB33.js +0 -216
  150. package/dist/chunks/app-server-runtime-RHO5TFUC.js +0 -23
  151. package/dist/chunks/apps-L5XCL7QY.js +0 -429
  152. package/dist/chunks/chunk-26AMV5ZI.js +0 -634
  153. package/dist/chunks/chunk-3EB7I67T.js +0 -630
  154. package/dist/chunks/chunk-3ELF4FXY.js +0 -96
  155. package/dist/chunks/chunk-3VEYNDHN.js +0 -669
  156. package/dist/chunks/chunk-4KA25HUP.js +0 -5648
  157. package/dist/chunks/chunk-4L3ZJS2T.js +0 -1207
  158. package/dist/chunks/chunk-6SMNG6YA.js +0 -1303
  159. package/dist/chunks/chunk-7RIGZB7N.js +0 -1148
  160. package/dist/chunks/chunk-A6G3PFA5.js +0 -2164
  161. package/dist/chunks/chunk-BVY5JYM6.js +0 -512
  162. package/dist/chunks/chunk-DLQQIWN2.js +0 -648
  163. package/dist/chunks/chunk-FJ2JGB2N.js +0 -1373
  164. package/dist/chunks/chunk-FQS2QL5F.js +0 -14522
  165. package/dist/chunks/chunk-G65WAOJV.js +0 -1643
  166. package/dist/chunks/chunk-JTHL5XJ2.js +0 -1838
  167. package/dist/chunks/chunk-K4TZEHAW.js +0 -602
  168. package/dist/chunks/chunk-KCRCIQPD.js +0 -66
  169. package/dist/chunks/chunk-KSRWKXRB.js +0 -12
  170. package/dist/chunks/chunk-MUMPWI4O.js +0 -92
  171. package/dist/chunks/chunk-NTK22KJD.js +0 -10707
  172. package/dist/chunks/chunk-OCBRPU2K.js +0 -629
  173. package/dist/chunks/chunk-PS37DB5F.js +0 -183
  174. package/dist/chunks/chunk-R3C3MNSI.js +0 -140
  175. package/dist/chunks/chunk-SMNFI2FU.js +0 -113
  176. package/dist/chunks/chunk-UACZUFIA.js +0 -47
  177. package/dist/chunks/chunk-UZMVNKXM.js +0 -1275
  178. package/dist/chunks/chunk-VT6BLHMB.js +0 -67198
  179. package/dist/chunks/chunk-W5GKHH77.js +0 -168
  180. package/dist/chunks/chunk-X6F4LBTQ.js +0 -832
  181. package/dist/chunks/chunk-X7ZG4TSW.js +0 -3063
  182. package/dist/chunks/chunk-XA4KBDMY.js +0 -13723
  183. package/dist/chunks/chunk-YVCYVDNP.js +0 -746
  184. package/dist/chunks/chunk-ZNQEROWP.js +0 -254
  185. package/dist/chunks/cli-D2MUUBEX.js +0 -23
  186. package/dist/chunks/configuration-command-NR6JYIUD.js +0 -187
  187. package/dist/chunks/continual-37CE4LLJ.js +0 -803
  188. package/dist/chunks/core-commands-SWGIOZLW.js +0 -50
  189. package/dist/chunks/database-DEYUZDIM.js +0 -20
  190. package/dist/chunks/desktop-test-QOS7G5NE.js +0 -148
  191. package/dist/chunks/dist-AKYCQNNF.js +0 -187
  192. package/dist/chunks/extension-HJUJBQAD.js +0 -9378
  193. package/dist/chunks/help-J6PZ23IC.js +0 -67
  194. package/dist/chunks/opchat-ABX5YBAT.js +0 -169
  195. package/dist/chunks/organizations-CPNC47DO.js +0 -806
  196. package/dist/chunks/profile-Q3HB5MIO.js +0 -1136
  197. package/dist/chunks/project-agent-YHUBX4OR.js +0 -516
  198. package/dist/chunks/sandbox-command-YFL5QTWX.js +0 -1661
  199. package/dist/chunks/sandbox-template-Z6P7NTNF.js +0 -1655
  200. package/dist/chunks/src-7XEENEBI.js +0 -3628
  201. package/dist/chunks/src-KBBIV4NT.js +0 -56125
  202. package/dist/chunks/taskset-2TRZBRRT.js +0 -66
  203. package/dist/chunks/teams-bot-WD33NLH5.js +0 -146
  204. package/dist/chunks/training-4XH37UZB.js +0 -17
  205. package/dist/chunks/workspaces-WG2MH2WE.js +0 -99
  206. package/dist/web/assets/App-C9aGkxVg.js +0 -173
  207. package/dist/web/assets/AppDialog-CK6_lg8c.js +0 -1
  208. package/dist/web/assets/AppTerminalPanel-BKqgX4sd.js +0 -2
  209. package/dist/web/assets/GetStartedView-DVInkexN.js +0 -1
  210. package/dist/web/assets/LabModelVersionDetailPage-NaaPElmM.js +0 -1
  211. package/dist/web/assets/LabsRoute-BRR6x3SX.js +0 -2
  212. package/dist/web/assets/LabsRoute-CGFgymTX.css +0 -1
  213. package/dist/web/assets/MainChatThread-BfkjCZB9.js +0 -2
  214. package/dist/web/assets/MainPane-Gw-YK38n.js +0 -8
  215. package/dist/web/assets/RightChatPanelStack-BktRQ9wg.js +0 -1
  216. package/dist/web/assets/TeamChatView-BPWJbDf1.js +0 -3
  217. package/dist/web/assets/WorkspaceDiffPanel-Pg7GL0br.js +0 -14
  218. package/dist/web/assets/chat-file-links-CWLsRYvW.js +0 -1
  219. package/dist/web/assets/chevron-up--mNnEqha.js +0 -1
  220. package/dist/web/assets/index-BEPmTPIA.js +0 -1
@@ -1,1661 +0,0 @@
1
- import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import {
3
- buildSandboxCreateInput,
4
- buildSandboxIntegrationAttachInput,
5
- buildSandboxReplayInput,
6
- buildSnapshotCreateInput,
7
- buildTemplateBuildCreateInput,
8
- createSandboxFromPlan,
9
- formatReplayLine,
10
- formatSandboxLine,
11
- formatSandboxTemplateLine,
12
- formatSnapshotCatalogLine,
13
- formatTemplateBuildLine,
14
- normalizeSnapshotValidationCleanup,
15
- summarizeReplayArtifact,
16
- summarizeSandbox,
17
- waitForSandboxCreateReady
18
- } from "./chunk-3EB7I67T.js";
19
- import {
20
- readSandboxSecretValue,
21
- resolveSandboxClient,
22
- summarizeSandboxSecret
23
- } from "./chunk-3VEYNDHN.js";
24
- import "./chunk-FJ2JGB2N.js";
25
- import "./chunk-SMNFI2FU.js";
26
- import "./chunk-KSRWKXRB.js";
27
- import "./chunk-PS37DB5F.js";
28
- import "./chunk-4KA25HUP.js";
29
- import "./chunk-ZNQEROWP.js";
30
- import "./chunk-7RIGZB7N.js";
31
- import "./chunk-4L3ZJS2T.js";
32
- import "./chunk-JTHL5XJ2.js";
33
- import "./chunk-FQS2QL5F.js";
34
- import {
35
- parseBooleanOption,
36
- parseIntegerOption,
37
- parseJsonObjectOption,
38
- parseNumberOption
39
- } from "./chunk-MUMPWI4O.js";
40
- import "./chunk-UACZUFIA.js";
41
-
42
- // src/cli/sandbox-files-command.ts
43
- async function handleSandboxFilesCommand(client, subcommand, options, rest) {
44
- if (subcommand === "list-files") {
45
- const sandboxId = rest[1];
46
- if (!sandboxId) {
47
- throw new Error("usage: sandbox list-files <sandboxId> [--path <path>]");
48
- }
49
- const path = typeof options.path === "string" ? options.path.trim() : void 0;
50
- const maxEntries = parseNumberOption(options.maxEntries, "max-entries");
51
- const recursive = options.recursive !== void 0 ? parseBooleanOption(options.recursive) : void 0;
52
- const result = await client.listFiles(sandboxId, {
53
- ...path ? { path } : {},
54
- ...recursive !== void 0 ? { recursive } : {},
55
- ...maxEntries !== void 0 ? { maxEntries } : {}
56
- });
57
- console.log(
58
- JSON.stringify(
59
- {
60
- sandbox: summarizeSandbox(result.sandbox),
61
- files: result.files
62
- },
63
- null,
64
- 2
65
- )
66
- );
67
- return true;
68
- }
69
- if (subcommand === "upload-file") {
70
- const sandboxId = rest[1];
71
- const path = typeof options.path === "string" ? options.path.trim() : "";
72
- const contents = typeof options.contents === "string" ? options.contents : typeof options.content === "string" ? options.content : "";
73
- const contentsBase64 = typeof options.contentsBase64 === "string" ? options.contentsBase64.trim() : typeof options.contentBase64 === "string" ? options.contentBase64.trim() : "";
74
- if (!sandboxId || !path) {
75
- throw new Error(
76
- 'usage: sandbox upload-file <sandboxId> --path <path> --contents "text"'
77
- );
78
- }
79
- if (!contents && !contentsBase64) {
80
- throw new Error(
81
- 'usage: sandbox upload-file <sandboxId> --path <path> --contents "text"'
82
- );
83
- }
84
- const result = contentsBase64 ? await client.uploadFileBase64(sandboxId, path, contentsBase64) : await client.uploadFile(sandboxId, path, contents);
85
- console.log(
86
- JSON.stringify(
87
- {
88
- sandbox: summarizeSandbox(result.sandbox),
89
- file: result.file
90
- },
91
- null,
92
- 2
93
- )
94
- );
95
- return true;
96
- }
97
- if (subcommand === "download-file") {
98
- const sandboxId = rest[1];
99
- const path = typeof options.path === "string" ? options.path.trim() : "";
100
- const offsetBytes = Number(options["offset-bytes"]);
101
- const maxBytes = Number(options["max-bytes"]);
102
- if (!sandboxId || !path) {
103
- throw new Error("usage: sandbox download-file <sandboxId> --path <path>");
104
- }
105
- const result = await client.downloadFileResponse(sandboxId, {
106
- path,
107
- ...Number.isFinite(offsetBytes) ? { offsetBytes } : {},
108
- ...Number.isFinite(maxBytes) ? { maxBytes } : {}
109
- });
110
- console.log(
111
- JSON.stringify(
112
- {
113
- sandbox: summarizeSandbox(result.sandbox),
114
- file: result.file,
115
- contents: Buffer.from(result.file.contentsBase64, "base64").toString(
116
- "utf-8"
117
- )
118
- },
119
- null,
120
- 2
121
- )
122
- );
123
- return true;
124
- }
125
- if (subcommand === "search-files") {
126
- const sandboxId = rest[1];
127
- const query = typeof options.query === "string" ? options.query.trim() : "";
128
- if (!sandboxId || !query) {
129
- throw new Error(
130
- "usage: sandbox search-files <sandboxId> --query <text> [--path <path>]"
131
- );
132
- }
133
- const path = typeof options.path === "string" ? options.path.trim() : void 0;
134
- const maxResults = parseNumberOption(options.maxResults, "max-results");
135
- const result = await client.searchFiles(sandboxId, {
136
- query,
137
- ...path ? { path } : {},
138
- ...maxResults !== void 0 ? { maxResults } : {}
139
- });
140
- console.log(
141
- JSON.stringify(
142
- {
143
- sandbox: summarizeSandbox(result.sandbox),
144
- matches: result.matches
145
- },
146
- null,
147
- 2
148
- )
149
- );
150
- return true;
151
- }
152
- if (subcommand === "delete-file") {
153
- const sandboxId = rest[1];
154
- const path = typeof options.path === "string" ? options.path.trim() : "";
155
- if (!sandboxId || !path) {
156
- throw new Error(
157
- "usage: sandbox delete-file <sandboxId> --path <path> [--recursive]"
158
- );
159
- }
160
- const result = await client.deleteFile(sandboxId, path, {
161
- recursive: parseBooleanOption(options.recursive)
162
- });
163
- console.log(
164
- JSON.stringify(
165
- {
166
- sandbox: summarizeSandbox(result.sandbox),
167
- deleted: result.deleted
168
- },
169
- null,
170
- 2
171
- )
172
- );
173
- return true;
174
- }
175
- if (subcommand === "stat-file") {
176
- const sandboxId = rest[1];
177
- const path = typeof options.path === "string" ? options.path.trim() : "";
178
- if (!sandboxId || !path) {
179
- throw new Error("usage: sandbox stat-file <sandboxId> --path <path>");
180
- }
181
- const result = await client.statFile(sandboxId, path);
182
- console.log(
183
- JSON.stringify(
184
- {
185
- sandbox: summarizeSandbox(result.sandbox),
186
- file: result.file
187
- },
188
- null,
189
- 2
190
- )
191
- );
192
- return true;
193
- }
194
- if (subcommand === "mkdir") {
195
- const sandboxId = rest[1];
196
- const path = typeof options.path === "string" ? options.path.trim() : "";
197
- if (!sandboxId || !path) {
198
- throw new Error(
199
- "usage: sandbox mkdir <sandboxId> --path <path> [--recursive false]"
200
- );
201
- }
202
- const result = await client.mkdir(sandboxId, {
203
- path,
204
- recursive: options.recursive !== void 0 ? parseBooleanOption(options.recursive) : void 0
205
- });
206
- console.log(
207
- JSON.stringify(
208
- {
209
- sandbox: summarizeSandbox(result.sandbox),
210
- directory: result.directory
211
- },
212
- null,
213
- 2
214
- )
215
- );
216
- return true;
217
- }
218
- if (subcommand === "move-file") {
219
- const sandboxId = rest[1];
220
- const fromPath = typeof options.fromPath === "string" ? options.fromPath.trim() : "";
221
- const toPath = typeof options.toPath === "string" ? options.toPath.trim() : "";
222
- if (!sandboxId || !fromPath || !toPath) {
223
- throw new Error(
224
- "usage: sandbox move-file <sandboxId> --from-path <path> --to-path <path> [--overwrite]"
225
- );
226
- }
227
- const result = await client.moveFile(sandboxId, {
228
- fromPath,
229
- toPath,
230
- overwrite: parseBooleanOption(options.overwrite)
231
- });
232
- console.log(
233
- JSON.stringify(
234
- {
235
- sandbox: summarizeSandbox(result.sandbox),
236
- moved: result.moved,
237
- file: result.file
238
- },
239
- null,
240
- 2
241
- )
242
- );
243
- return true;
244
- }
245
- return false;
246
- }
247
-
248
- // src/cli/sandbox-git-command.ts
249
- async function handleSandboxGitCommand(client, subcommand, options, rest) {
250
- if (subcommand === "git-status") {
251
- const sandboxId = rest[1];
252
- if (!sandboxId) {
253
- throw new Error("usage: sandbox git-status <sandboxId>");
254
- }
255
- const result = await client.gitStatus(sandboxId);
256
- console.log(
257
- JSON.stringify(
258
- {
259
- sandbox: summarizeSandbox(result.sandbox),
260
- status: result.status
261
- },
262
- null,
263
- 2
264
- )
265
- );
266
- return true;
267
- }
268
- if (subcommand === "git-diff") {
269
- const sandboxId = rest[1];
270
- if (!sandboxId) {
271
- throw new Error("usage: sandbox git-diff <sandboxId> [--base-ref <ref>]");
272
- }
273
- const baseRef = typeof options.baseRef === "string" && options.baseRef.trim() ? options.baseRef.trim() : void 0;
274
- const result = await client.gitDiff(sandboxId, {
275
- ...baseRef ? { baseRef } : {}
276
- });
277
- console.log(
278
- JSON.stringify(
279
- {
280
- sandbox: summarizeSandbox(result.sandbox),
281
- diff: result.diff
282
- },
283
- null,
284
- 2
285
- )
286
- );
287
- return true;
288
- }
289
- if (subcommand === "git-export-patch") {
290
- const sandboxId = rest[1];
291
- if (!sandboxId) {
292
- throw new Error(
293
- "usage: sandbox git-export-patch <sandboxId> [--base-ref <ref>]"
294
- );
295
- }
296
- const baseRef = typeof options.baseRef === "string" && options.baseRef.trim() ? options.baseRef.trim() : void 0;
297
- const result = await client.gitExportPatch(sandboxId, {
298
- ...baseRef ? { baseRef } : {}
299
- });
300
- console.log(
301
- JSON.stringify(
302
- {
303
- sandbox: summarizeSandbox(result.sandbox),
304
- patch: result.patch
305
- },
306
- null,
307
- 2
308
- )
309
- );
310
- return true;
311
- }
312
- if (subcommand === "git-branch") {
313
- const sandboxId = rest[1];
314
- const branch = typeof options.branch === "string" ? options.branch.trim() : "";
315
- const startPoint = typeof options.startPoint === "string" && options.startPoint.trim() ? options.startPoint.trim() : void 0;
316
- if (!sandboxId || !branch) {
317
- throw new Error(
318
- "usage: sandbox git-branch <sandboxId> --branch <name> [--create] [--start-point <ref>]"
319
- );
320
- }
321
- const result = await client.gitBranch(sandboxId, {
322
- branch,
323
- create: parseBooleanOption(options.create),
324
- ...startPoint ? { startPoint } : {}
325
- });
326
- console.log(
327
- JSON.stringify(
328
- {
329
- sandbox: summarizeSandbox(result.sandbox),
330
- branch: result.branch
331
- },
332
- null,
333
- 2
334
- )
335
- );
336
- return true;
337
- }
338
- if (subcommand === "git-commit") {
339
- const sandboxId = rest[1];
340
- const message = typeof options.message === "string" ? options.message.trim() : "";
341
- const all = parseBooleanOption(options.all);
342
- const rawPaths = typeof options.paths === "string" ? options.paths : typeof options.path === "string" ? options.path : "";
343
- const paths = rawPaths.split(",").map((path) => path.trim()).filter(Boolean);
344
- if (!sandboxId || !message || !all && paths.length === 0) {
345
- throw new Error(
346
- 'usage: sandbox git-commit <sandboxId> --message "..." [--all|--paths <csv>]'
347
- );
348
- }
349
- const result = await client.gitCommit(sandboxId, {
350
- message,
351
- ...all ? { all: true } : { paths }
352
- });
353
- console.log(
354
- JSON.stringify(
355
- {
356
- sandbox: summarizeSandbox(result.sandbox),
357
- commit: result.commit
358
- },
359
- null,
360
- 2
361
- )
362
- );
363
- return true;
364
- }
365
- if (subcommand === "git-pull") {
366
- const sandboxId = rest[1];
367
- if (!sandboxId) {
368
- throw new Error(
369
- "usage: sandbox git-pull <sandboxId> [--remote origin] [--branch main] [--rebase|--ff-only false]"
370
- );
371
- }
372
- const remote = typeof options.remote === "string" && options.remote.trim() ? options.remote.trim() : void 0;
373
- const branch = typeof options.branch === "string" && options.branch.trim() ? options.branch.trim() : void 0;
374
- const result = await client.gitPull(sandboxId, {
375
- ...remote ? { remote } : {},
376
- ...branch ? { branch } : {},
377
- ...options.rebase !== void 0 ? { rebase: parseBooleanOption(options.rebase) } : {},
378
- ...options.ffOnly !== void 0 ? { ffOnly: parseBooleanOption(options.ffOnly) } : {}
379
- });
380
- console.log(
381
- JSON.stringify(
382
- {
383
- sandbox: summarizeSandbox(result.sandbox),
384
- pull: result.pull
385
- },
386
- null,
387
- 2
388
- )
389
- );
390
- return true;
391
- }
392
- if (subcommand === "git-push") {
393
- const sandboxId = rest[1];
394
- if (!sandboxId) {
395
- throw new Error(
396
- "usage: sandbox git-push <sandboxId> [--remote origin] [--branch main] [--set-upstream] [--force-with-lease]"
397
- );
398
- }
399
- const remote = typeof options.remote === "string" && options.remote.trim() ? options.remote.trim() : void 0;
400
- const branch = typeof options.branch === "string" && options.branch.trim() ? options.branch.trim() : void 0;
401
- const result = await client.gitPush(sandboxId, {
402
- ...remote ? { remote } : {},
403
- ...branch ? { branch } : {},
404
- ...options.setUpstream !== void 0 ? { setUpstream: parseBooleanOption(options.setUpstream) } : {},
405
- ...options.forceWithLease !== void 0 ? { forceWithLease: parseBooleanOption(options.forceWithLease) } : {}
406
- });
407
- console.log(
408
- JSON.stringify(
409
- {
410
- sandbox: summarizeSandbox(result.sandbox),
411
- push: result.push
412
- },
413
- null,
414
- 2
415
- )
416
- );
417
- return true;
418
- }
419
- return false;
420
- }
421
-
422
- // src/cli/sandbox-process-command.ts
423
- async function handleSandboxProcessCommand(client, subcommand, options, rest) {
424
- if (subcommand === "process-start") {
425
- const sandboxId = rest[1];
426
- const command = (typeof options.command === "string" ? options.command : null) || rest.slice(2).join(" ");
427
- if (!sandboxId || !command.trim()) {
428
- throw new Error(
429
- "usage: sandbox process-start <sandboxId> --command <command>"
430
- );
431
- }
432
- const timeoutSeconds = parseIntegerOption(
433
- options.timeoutSeconds,
434
- "timeout-seconds"
435
- );
436
- const result = await client.startProcess(sandboxId, {
437
- command: command.trim(),
438
- ...timeoutSeconds !== void 0 ? { timeoutSeconds } : {}
439
- });
440
- console.log(
441
- JSON.stringify(
442
- {
443
- sandbox: summarizeSandbox(result.sandbox),
444
- process: result.process
445
- },
446
- null,
447
- 2
448
- )
449
- );
450
- return true;
451
- }
452
- if (subcommand === "process-list") {
453
- const sandboxId = rest[1];
454
- if (!sandboxId) {
455
- throw new Error("usage: sandbox process-list <sandboxId>");
456
- }
457
- const result = await client.listProcesses(sandboxId);
458
- console.log(
459
- JSON.stringify(
460
- {
461
- sandbox: summarizeSandbox(result.sandbox),
462
- processes: result.processes
463
- },
464
- null,
465
- 2
466
- )
467
- );
468
- return true;
469
- }
470
- if (subcommand === "process-get") {
471
- const sandboxId = rest[1];
472
- const processId = rest[2];
473
- if (!sandboxId || !processId) {
474
- throw new Error(
475
- "usage: sandbox process-get <sandboxId> <processId> [--since <cursor>]"
476
- );
477
- }
478
- const since = parseIntegerOption(options.since, "since");
479
- const result = await client.getProcess(sandboxId, processId, {
480
- ...since !== void 0 ? { since } : {}
481
- });
482
- console.log(
483
- JSON.stringify(
484
- {
485
- sandbox: summarizeSandbox(result.sandbox),
486
- process: result.process,
487
- output: result.output,
488
- cursor: result.cursor,
489
- completed: result.completed
490
- },
491
- null,
492
- 2
493
- )
494
- );
495
- return true;
496
- }
497
- if (subcommand === "process-stop") {
498
- const sandboxId = rest[1];
499
- const processId = rest[2];
500
- if (!sandboxId || !processId) {
501
- throw new Error("usage: sandbox process-stop <sandboxId> <processId>");
502
- }
503
- const result = await client.stopProcess(sandboxId, processId);
504
- console.log(
505
- JSON.stringify(
506
- {
507
- sandbox: summarizeSandbox(result.sandbox),
508
- process: result.process
509
- },
510
- null,
511
- 2
512
- )
513
- );
514
- return true;
515
- }
516
- if (subcommand === "process-stream") {
517
- const sandboxId = rest[1];
518
- const processId = rest[2];
519
- if (!sandboxId || !processId) {
520
- throw new Error(
521
- "usage: sandbox process-stream <sandboxId> <processId> [--since <cursor>]"
522
- );
523
- }
524
- const since = parseIntegerOption(options.since, "since");
525
- await client.streamProcessOutput(sandboxId, processId, {
526
- ...since !== void 0 ? { since } : {}
527
- });
528
- return true;
529
- }
530
- if (subcommand === "pty-start") {
531
- const sandboxId = rest[1];
532
- if (!sandboxId) {
533
- throw new Error(
534
- "usage: sandbox pty-start <sandboxId> [--command <command>]"
535
- );
536
- }
537
- const command = (typeof options.command === "string" ? options.command : null) || rest.slice(2).join(" ");
538
- const timeoutSeconds = parseIntegerOption(
539
- options.timeoutSeconds,
540
- "timeout-seconds"
541
- );
542
- const rows = parseIntegerOption(options.rows, "rows");
543
- const cols = parseIntegerOption(options.cols, "cols");
544
- const result = await client.startPty(sandboxId, {
545
- ...command.trim() ? { command: command.trim() } : {},
546
- ...timeoutSeconds !== void 0 ? { timeoutSeconds } : {},
547
- ...rows !== void 0 ? { rows } : {},
548
- ...cols !== void 0 ? { cols } : {}
549
- });
550
- console.log(
551
- JSON.stringify(
552
- {
553
- sandbox: summarizeSandbox(result.sandbox),
554
- pty: result.pty
555
- },
556
- null,
557
- 2
558
- )
559
- );
560
- return true;
561
- }
562
- if (subcommand === "pty-list") {
563
- const sandboxId = rest[1];
564
- if (!sandboxId) {
565
- throw new Error("usage: sandbox pty-list <sandboxId>");
566
- }
567
- const result = await client.listPtys(sandboxId);
568
- console.log(
569
- JSON.stringify(
570
- {
571
- sandbox: summarizeSandbox(result.sandbox),
572
- ptys: result.ptys
573
- },
574
- null,
575
- 2
576
- )
577
- );
578
- return true;
579
- }
580
- if (subcommand === "pty-get") {
581
- const sandboxId = rest[1];
582
- const ptyId = rest[2];
583
- if (!sandboxId || !ptyId) {
584
- throw new Error(
585
- "usage: sandbox pty-get <sandboxId> <ptyId> [--since <cursor>]"
586
- );
587
- }
588
- const since = parseIntegerOption(options.since, "since");
589
- const result = await client.getPty(sandboxId, ptyId, {
590
- ...since !== void 0 ? { since } : {}
591
- });
592
- console.log(
593
- JSON.stringify(
594
- {
595
- sandbox: summarizeSandbox(result.sandbox),
596
- pty: result.pty,
597
- output: result.output,
598
- cursor: result.cursor,
599
- completed: result.completed
600
- },
601
- null,
602
- 2
603
- )
604
- );
605
- return true;
606
- }
607
- if (subcommand === "pty-write") {
608
- const sandboxId = rest[1];
609
- const ptyId = rest[2];
610
- const inputBase64 = typeof options.inputBase64 === "string" ? options.inputBase64.trim() : "";
611
- const inputText = (typeof options.input === "string" ? options.input : null) || rest.slice(3).join(" ");
612
- if (!sandboxId || !ptyId || !inputBase64 && !inputText) {
613
- throw new Error(
614
- "usage: sandbox pty-write <sandboxId> <ptyId> --input <text>"
615
- );
616
- }
617
- const result = await client.writePtyInput(
618
- sandboxId,
619
- ptyId,
620
- inputBase64 ? { dataBase64: inputBase64 } : inputText
621
- );
622
- console.log(
623
- JSON.stringify(
624
- {
625
- sandbox: summarizeSandbox(result.sandbox),
626
- pty: result.pty
627
- },
628
- null,
629
- 2
630
- )
631
- );
632
- return true;
633
- }
634
- if (subcommand === "pty-stop") {
635
- const sandboxId = rest[1];
636
- const ptyId = rest[2];
637
- if (!sandboxId || !ptyId) {
638
- throw new Error("usage: sandbox pty-stop <sandboxId> <ptyId>");
639
- }
640
- const result = await client.stopPty(sandboxId, ptyId);
641
- console.log(
642
- JSON.stringify(
643
- {
644
- sandbox: summarizeSandbox(result.sandbox),
645
- pty: result.pty
646
- },
647
- null,
648
- 2
649
- )
650
- );
651
- return true;
652
- }
653
- if (subcommand === "pty-stream") {
654
- const sandboxId = rest[1];
655
- const ptyId = rest[2];
656
- if (!sandboxId || !ptyId) {
657
- throw new Error(
658
- "usage: sandbox pty-stream <sandboxId> <ptyId> [--since <cursor>]"
659
- );
660
- }
661
- const since = parseIntegerOption(options.since, "since");
662
- await client.streamPtyOutput(sandboxId, ptyId, {
663
- ...since !== void 0 ? { since } : {}
664
- });
665
- return true;
666
- }
667
- return false;
668
- }
669
-
670
- // src/cli/sandbox-replay-command.ts
671
- async function handleSandboxReplayCommand(client, subcommand, options, rest) {
672
- if (subcommand === "replays" || subcommand === "replay-list") {
673
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
674
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
675
- const result = await client.listReplays({
676
- ...teamId ? { teamId } : {},
677
- ...projectId ? { projectId } : {}
678
- });
679
- if (parseBooleanOption(options.json)) {
680
- console.log(JSON.stringify(result, null, 2));
681
- return true;
682
- }
683
- if (result.replays.length === 0) {
684
- console.log("no sandbox replays found");
685
- return true;
686
- }
687
- for (const replay of result.replays) {
688
- console.log(formatReplayLine(replay));
689
- }
690
- return true;
691
- }
692
- if (subcommand === "replay-start" || subcommand === "start-replay") {
693
- const result = await client.startReplay(buildSandboxReplayInput(options));
694
- console.log(JSON.stringify(result, null, 2));
695
- return true;
696
- }
697
- if (subcommand === "replay-get" || subcommand === "get-replay") {
698
- const replayId = rest[1];
699
- if (!replayId) {
700
- throw new Error("usage: sandbox replay-get <replayId> [--team-id <id>]");
701
- }
702
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
703
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
704
- const result = await client.getReplay(replayId, {
705
- ...teamId ? { teamId } : {},
706
- ...projectId ? { projectId } : {}
707
- });
708
- console.log(JSON.stringify(result, null, 2));
709
- return true;
710
- }
711
- if (subcommand === "replay-logs" || subcommand === "logs-replay") {
712
- const replayId = rest[1];
713
- if (!replayId) {
714
- throw new Error("usage: sandbox replay-logs <replayId> [--team-id <id>]");
715
- }
716
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
717
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
718
- const result = await client.getReplayLogs(replayId, {
719
- ...teamId ? { teamId } : {},
720
- ...projectId ? { projectId } : {}
721
- });
722
- for (const line of result.logs) {
723
- console.log(line);
724
- }
725
- return true;
726
- }
727
- if (subcommand === "replay-artifacts" || subcommand === "artifacts-replay") {
728
- const replayId = rest[1];
729
- if (!replayId) {
730
- throw new Error(
731
- "usage: sandbox replay-artifacts <replayId> [--team-id <id>]"
732
- );
733
- }
734
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
735
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
736
- const result = await client.getReplayArtifacts(replayId, {
737
- ...teamId ? { teamId } : {},
738
- ...projectId ? { projectId } : {}
739
- });
740
- console.log(
741
- JSON.stringify(
742
- {
743
- replayId: result.replayId,
744
- artifacts: result.artifacts.map(summarizeReplayArtifact)
745
- },
746
- null,
747
- 2
748
- )
749
- );
750
- return true;
751
- }
752
- if (subcommand === "replay-cancel" || subcommand === "cancel-replay") {
753
- const replayId = rest[1];
754
- if (!replayId) {
755
- throw new Error(
756
- "usage: sandbox replay-cancel <replayId> [--team-id <id>]"
757
- );
758
- }
759
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
760
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
761
- const result = await client.cancelReplay(replayId, {
762
- ...teamId ? { teamId } : {},
763
- ...projectId ? { projectId } : {}
764
- });
765
- console.log(JSON.stringify(result, null, 2));
766
- return true;
767
- }
768
- if (subcommand === "replay-watch" || subcommand === "watch-replay") {
769
- const replayId = rest[1];
770
- if (!replayId) {
771
- throw new Error(
772
- "usage: sandbox replay-watch <replayId> [--team-id <id>]"
773
- );
774
- }
775
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
776
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
777
- const intervalMs = parseIntegerOption(options.intervalMs, "interval-ms") ?? 5e3;
778
- const timeoutMs = parseIntegerOption(options.timeoutMs, "timeout-ms") ?? 15 * 60 * 1e3;
779
- const startedAt = Date.now();
780
- const seenLogs = /* @__PURE__ */ new Set();
781
- while (Date.now() - startedAt <= timeoutMs) {
782
- const result = await client.getReplay(replayId, {
783
- ...teamId ? { teamId } : {},
784
- ...projectId ? { projectId } : {}
785
- });
786
- for (const line of result.replay.logs) {
787
- if (!seenLogs.has(line)) {
788
- seenLogs.add(line);
789
- console.log(line);
790
- }
791
- }
792
- if (result.replay.state === "succeeded" || result.replay.state === "failed" || result.replay.state === "canceled") {
793
- console.log(formatReplayLine(result.replay));
794
- if (result.replay.state !== "succeeded") {
795
- throw new Error(
796
- `sandbox replay ${result.replay.state}: ${result.replay.error ?? "no error"}`
797
- );
798
- }
799
- return true;
800
- }
801
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
802
- }
803
- throw new Error(`sandbox replay did not finish within ${timeoutMs}ms`);
804
- }
805
- return false;
806
- }
807
-
808
- // src/cli/sandbox-runtime-command.ts
809
- async function handleSandboxRuntimeCommand(client, subcommand, options, rest) {
810
- if (subcommand === "runtime-list") {
811
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
812
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
813
- const agentId = typeof options.agentId === "string" ? options.agentId.trim() : "";
814
- const runtimes = await client.listSandboxRuntimes({
815
- ...teamId ? { teamId } : {},
816
- ...projectId ? { projectId } : {},
817
- ...agentId ? { agentId } : {}
818
- });
819
- console.log(JSON.stringify({ runtimes }, null, 2));
820
- return true;
821
- }
822
- if (subcommand === "runtime-get") {
823
- const runtimeId = rest[1]?.trim();
824
- if (!runtimeId) {
825
- throw new Error("usage: sandbox runtime-get <runtimeId>");
826
- }
827
- const runtime = await client.getSandboxRuntime(runtimeId);
828
- console.log(JSON.stringify({ runtime }, null, 2));
829
- return true;
830
- }
831
- if (subcommand === "runtime-events") {
832
- const runtimeId = rest[1]?.trim();
833
- if (!runtimeId) {
834
- throw new Error("usage: sandbox runtime-events <runtimeId>");
835
- }
836
- console.log(
837
- JSON.stringify(await client.listSandboxRuntimeEvents(runtimeId), null, 2)
838
- );
839
- return true;
840
- }
841
- if (subcommand === "runtime-status") {
842
- const runtimeId = rest[1]?.trim();
843
- const status = typeof options.status === "string" && options.status.trim() ? options.status.trim() : "";
844
- const expectedVersion = Number(options.expectedVersion);
845
- const summary = typeof options.summary === "string" && options.summary.trim() ? options.summary.trim() : void 0;
846
- if (!runtimeId || !status || !Number.isInteger(expectedVersion)) {
847
- throw new Error(
848
- "usage: sandbox runtime-status <runtimeId> --status <status> --expected-version <n>"
849
- );
850
- }
851
- const runtime = await client.updateSandboxRuntimeStatus(runtimeId, {
852
- status,
853
- expectedVersion,
854
- ...summary ? { summary } : {}
855
- });
856
- console.log(JSON.stringify({ runtime }, null, 2));
857
- return true;
858
- }
859
- if (subcommand === "runtime-event") {
860
- const runtimeId = rest[1]?.trim();
861
- const type = typeof options.type === "string" && options.type.trim() ? options.type.trim() : "";
862
- const summary = typeof options.summary === "string" && options.summary.trim() ? options.summary.trim() : void 0;
863
- const payload = typeof options.payload === "string" && options.payload.trim() ? parseJsonObjectOption(options.payload, "payload") : void 0;
864
- const lifecycleHint = typeof options.lifecycleHint === "string" && options.lifecycleHint.trim() ? parseJsonObjectOption(options.lifecycleHint, "lifecycle-hint") : void 0;
865
- if (!runtimeId || !type) {
866
- throw new Error(
867
- "usage: sandbox runtime-event <runtimeId> --type <eventType> [--summary <text>] [--payload <json>] [--lifecycle-hint <json>]"
868
- );
869
- }
870
- console.log(
871
- JSON.stringify(
872
- await client.emitSandboxRuntimeEvent(runtimeId, {
873
- type,
874
- ...summary ? { summary } : {},
875
- ...payload ? { payload } : {},
876
- ...lifecycleHint ? { lifecycleHint } : {}
877
- }),
878
- null,
879
- 2
880
- )
881
- );
882
- return true;
883
- }
884
- if (subcommand === "runtime-preserve-source" || subcommand === "runtime-preserve") {
885
- const runtimeId = rest[1]?.trim();
886
- const teamId = typeof options.teamId === "string" && options.teamId.trim() ? options.teamId.trim() : "";
887
- const sandboxId = typeof options.sandboxId === "string" && options.sandboxId.trim() ? options.sandboxId.trim() : "";
888
- const message = typeof options.message === "string" && options.message.trim() ? options.message.trim() : "";
889
- if (!runtimeId) {
890
- throw new Error(
891
- "usage: sandbox runtime-preserve-source <runtimeId> [--team-id <id>] [--sandbox-id <id>] [--message <text>]"
892
- );
893
- }
894
- console.log(
895
- JSON.stringify(
896
- await client.runtimes.preserveSource(
897
- runtimeId,
898
- {
899
- ...sandboxId ? { sandboxId } : {},
900
- ...message ? { message } : {}
901
- },
902
- {
903
- ...teamId ? { teamId } : {}
904
- }
905
- ),
906
- null,
907
- 2
908
- )
909
- );
910
- return true;
911
- }
912
- return false;
913
- }
914
-
915
- // src/cli/sandbox-secrets-command.ts
916
- async function handleSandboxSecretsCommand(client, subcommand, options, rest) {
917
- if (subcommand === "secrets" || subcommand === "secret-list") {
918
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
919
- const secrets = await client.listSecrets({
920
- ...teamId ? { teamId } : {}
921
- });
922
- if (parseBooleanOption(options.json)) {
923
- console.log(
924
- JSON.stringify(
925
- { secrets: secrets.map(summarizeSandboxSecret) },
926
- null,
927
- 2
928
- )
929
- );
930
- return true;
931
- }
932
- if (secrets.length === 0) {
933
- console.log("no sandbox secrets found");
934
- return true;
935
- }
936
- for (const secret of secrets) {
937
- console.log(
938
- `${secret.name} ${secret.status} v${secret.currentVersion ?? "current"} ${secret.secretRef}`
939
- );
940
- }
941
- return true;
942
- }
943
- if (subcommand === "secret-create") {
944
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
945
- const name = typeof options.name === "string" ? options.name.trim() : "";
946
- const description = typeof options.description === "string" && options.description.trim() ? options.description.trim() : void 0;
947
- const scope = options.scope === "project" || options.scope === "template" || options.scope === "team" ? options.scope : void 0;
948
- if (!name) {
949
- throw new Error(
950
- "usage: sandbox secret-create --name <ENV_NAME> [--team-id <id>] [--stdin]"
951
- );
952
- }
953
- const value = await readSandboxSecretValue(options, `Value for ${name}`);
954
- const secret = await client.createSecret({
955
- ...teamId ? { teamId } : {},
956
- name,
957
- value,
958
- ...description ? { description } : {},
959
- ...scope ? { scope } : {}
960
- });
961
- console.log(
962
- JSON.stringify({ secret: summarizeSandboxSecret(secret) }, null, 2)
963
- );
964
- return true;
965
- }
966
- if (subcommand === "secret-rotate") {
967
- const secretId = rest[1];
968
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
969
- if (!secretId) {
970
- throw new Error(
971
- "usage: sandbox secret-rotate <secretId> [--team-id <id>] [--stdin]"
972
- );
973
- }
974
- const value = await readSandboxSecretValue(options, "New secret value");
975
- const secret = await client.rotateSecret(secretId, {
976
- ...teamId ? { teamId } : {},
977
- value
978
- });
979
- console.log(
980
- JSON.stringify({ secret: summarizeSandboxSecret(secret) }, null, 2)
981
- );
982
- return true;
983
- }
984
- if (subcommand === "secret-attach") {
985
- const secretId = rest[1];
986
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
987
- const envName = typeof options.envName === "string" ? options.envName.trim() : "";
988
- const targetType = options.targetType === "sandbox" || options.targetType === "template" || options.targetType === "project" || options.targetType === "agent" || options.targetType === "replay" ? options.targetType : void 0;
989
- const targetId = typeof options.targetId === "string" ? options.targetId.trim() : "";
990
- if (!secretId || !envName || !targetType || !targetId) {
991
- throw new Error(
992
- "usage: sandbox secret-attach <secretId> --env-name <ENV_NAME> --target-type sandbox|project|agent|template|replay --target-id <id>"
993
- );
994
- }
995
- const secret = await client.attachSecret(secretId, {
996
- ...teamId ? { teamId } : {},
997
- envName,
998
- targetType,
999
- targetId
1000
- });
1001
- console.log(
1002
- JSON.stringify({ secret: summarizeSandboxSecret(secret) }, null, 2)
1003
- );
1004
- return true;
1005
- }
1006
- if (subcommand === "secret-revoke" || subcommand === "secret-delete") {
1007
- const secretId = rest[1];
1008
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1009
- if (!secretId) {
1010
- throw new Error(
1011
- `usage: sandbox ${subcommand} <secretId> [--team-id <id>]`
1012
- );
1013
- }
1014
- const secret = subcommand === "secret-revoke" ? await client.revokeSecret(secretId, {
1015
- ...teamId ? { teamId } : {}
1016
- }) : await client.deleteSecret(secretId, {
1017
- ...teamId ? { teamId } : {}
1018
- });
1019
- console.log(
1020
- JSON.stringify({ secret: summarizeSandboxSecret(secret) }, null, 2)
1021
- );
1022
- return true;
1023
- }
1024
- return false;
1025
- }
1026
-
1027
- // src/cli/sandbox-template-builds-command.ts
1028
- async function handleSandboxTemplateBuildsCommand(client, subcommand, options, rest) {
1029
- if (subcommand === "published-snapshot-builds" || subcommand === "published-snapshot-build-list" || subcommand === "template-builds" || subcommand === "template-build-list") {
1030
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1031
- if (!teamId) {
1032
- throw new Error(
1033
- "usage: sandbox published-snapshot-builds --team-id <id>"
1034
- );
1035
- }
1036
- const builds = await client.listPublishedSnapshotBuilds({ teamId });
1037
- if (parseBooleanOption(options.json)) {
1038
- console.log(JSON.stringify({ builds }, null, 2));
1039
- return true;
1040
- }
1041
- if (builds.length === 0) {
1042
- console.log("no published snapshot builds found");
1043
- return true;
1044
- }
1045
- for (const build of builds) {
1046
- console.log(formatTemplateBuildLine(build));
1047
- }
1048
- return true;
1049
- }
1050
- if (subcommand === "published-snapshot-build-create" || subcommand === "create-published-snapshot-build" || subcommand === "template-build-create" || subcommand === "create-template-build") {
1051
- const build = await client.createPublishedSnapshotBuild(
1052
- buildTemplateBuildCreateInput(options)
1053
- );
1054
- console.log(JSON.stringify({ build }, null, 2));
1055
- return true;
1056
- }
1057
- if (subcommand === "published-snapshot-build-get" || subcommand === "get-published-snapshot-build" || subcommand === "template-build-get" || subcommand === "get-template-build") {
1058
- const buildId = rest[1];
1059
- if (!buildId) {
1060
- throw new Error("usage: sandbox published-snapshot-build-get <buildId>");
1061
- }
1062
- const build = await client.getPublishedSnapshotBuild(buildId);
1063
- console.log(JSON.stringify({ build }, null, 2));
1064
- return true;
1065
- }
1066
- if (subcommand === "published-snapshot-build-logs" || subcommand === "published-snapshot-build-log" || subcommand === "template-build-logs" || subcommand === "template-build-log") {
1067
- const buildId = rest[1];
1068
- if (!buildId) {
1069
- throw new Error("usage: sandbox published-snapshot-build-logs <buildId>");
1070
- }
1071
- const logs = await client.getPublishedSnapshotBuildLogs(buildId);
1072
- if (parseBooleanOption(options.json)) {
1073
- console.log(JSON.stringify(logs, null, 2));
1074
- return true;
1075
- }
1076
- for (const line of logs.logs) {
1077
- console.log(line);
1078
- }
1079
- return true;
1080
- }
1081
- if (subcommand === "published-snapshot-build-cancel" || subcommand === "cancel-published-snapshot-build" || subcommand === "template-build-cancel" || subcommand === "cancel-template-build") {
1082
- const buildId = rest[1];
1083
- if (!buildId) {
1084
- throw new Error(
1085
- "usage: sandbox published-snapshot-build-cancel <buildId>"
1086
- );
1087
- }
1088
- const build = await client.cancelPublishedSnapshotBuild(buildId);
1089
- console.log(JSON.stringify({ build }, null, 2));
1090
- return true;
1091
- }
1092
- if (subcommand === "published-snapshot-build-watch" || subcommand === "watch-published-snapshot-build" || subcommand === "template-build-watch" || subcommand === "watch-template-build") {
1093
- const buildId = rest[1];
1094
- if (!buildId) {
1095
- throw new Error("usage: sandbox published-snapshot-build-watch <buildId>");
1096
- }
1097
- const intervalMs = parseIntegerOption(options.intervalMs, "interval-ms") ?? 5e3;
1098
- const timeoutMs = parseIntegerOption(options.timeoutMs, "timeout-ms") ?? 15 * 60 * 1e3;
1099
- const startedAt = Date.now();
1100
- const seenLogs = /* @__PURE__ */ new Set();
1101
- while (Date.now() - startedAt <= timeoutMs) {
1102
- const [build, logs] = await Promise.all([
1103
- client.getPublishedSnapshotBuild(buildId),
1104
- client.getPublishedSnapshotBuildLogs(buildId)
1105
- ]);
1106
- for (const line of logs.logs) {
1107
- if (!seenLogs.has(line)) {
1108
- seenLogs.add(line);
1109
- console.log(line);
1110
- }
1111
- }
1112
- if (build.status === "succeeded" || build.status === "failed" || build.status === "cancelled") {
1113
- console.log(formatTemplateBuildLine(build));
1114
- if (build.status !== "succeeded") {
1115
- throw new Error(
1116
- `published snapshot build ${build.status}: ${build.error ?? "no error"}`
1117
- );
1118
- }
1119
- return true;
1120
- }
1121
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
1122
- }
1123
- throw new Error(
1124
- `published snapshot build did not finish within ${timeoutMs}ms`
1125
- );
1126
- }
1127
- return false;
1128
- }
1129
-
1130
- // src/cli/sandbox-command.ts
1131
- function parseSandboxAsyncOption(options) {
1132
- return parseBooleanOption(options.async) || parseBooleanOption(options.respondAsync);
1133
- }
1134
- async function runSandboxCommand(options, rest) {
1135
- const subcommand = rest[0] || "list";
1136
- const client = await resolveSandboxClient(options);
1137
- if (subcommand === "list") {
1138
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1139
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
1140
- const agentId = typeof options.agentId === "string" ? options.agentId.trim() : "";
1141
- const sandboxes = await client.list({
1142
- ...teamId ? { teamId } : {},
1143
- ...projectId ? { projectId } : {},
1144
- ...agentId ? { agentId } : {}
1145
- });
1146
- if (sandboxes.length === 0) {
1147
- console.log("no sandboxes found");
1148
- return;
1149
- }
1150
- for (const sandbox of sandboxes) {
1151
- console.log(formatSandboxLine(sandbox));
1152
- }
1153
- return;
1154
- }
1155
- if (subcommand === "mcp-config" || subcommand === "mcp-url") {
1156
- const config = client.mcpServerConfig();
1157
- console.log(
1158
- JSON.stringify(
1159
- {
1160
- ...config,
1161
- headers: {
1162
- "openpond-api-key": "set OPENPOND_API_KEY or use your saved openpond profile"
1163
- }
1164
- },
1165
- null,
1166
- 2
1167
- )
1168
- );
1169
- return;
1170
- }
1171
- if (await handleSandboxRuntimeCommand(client, subcommand, options, rest)) {
1172
- return;
1173
- }
1174
- if (subcommand === "pricing") {
1175
- const pricing = await client.pricing();
1176
- console.log(JSON.stringify(pricing, null, 2));
1177
- return;
1178
- }
1179
- if (subcommand === "costs") {
1180
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1181
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
1182
- const agentId = typeof options.agentId === "string" ? options.agentId.trim() : "";
1183
- const costs = await client.costs({
1184
- ...teamId ? { teamId } : {},
1185
- ...projectId ? { projectId } : {},
1186
- ...agentId ? { agentId } : {}
1187
- });
1188
- if (parseBooleanOption(options.summary)) {
1189
- console.log(
1190
- JSON.stringify(
1191
- {
1192
- costs: {
1193
- teamId: costs.costs.teamId,
1194
- ownerUserId: costs.costs.ownerUserId,
1195
- generatedAt: costs.costs.generatedAt,
1196
- summary: costs.costs.summary,
1197
- lineItems: costs.costs.lineItems,
1198
- tiers: costs.costs.pricing.tiers.map((tier) => ({
1199
- key: tier.key,
1200
- resources: tier.resources,
1201
- keepRunningEstimate: tier.keepRunningEstimate
1202
- }))
1203
- }
1204
- },
1205
- null,
1206
- 2
1207
- )
1208
- );
1209
- return;
1210
- }
1211
- console.log(JSON.stringify(costs, null, 2));
1212
- return;
1213
- }
1214
- if (await handleSandboxSecretsCommand(client, subcommand, options, rest)) {
1215
- return;
1216
- }
1217
- if (subcommand === "snapshots" || subcommand === "snapshot-catalog") {
1218
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1219
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
1220
- const agentId = typeof options.agentId === "string" ? options.agentId.trim() : "";
1221
- const query = typeof options.query === "string" && options.query.trim() ? options.query.trim() : typeof options.q === "string" && options.q.trim() ? options.q.trim() : "";
1222
- const tag = typeof options.tag === "string" ? options.tag.trim() : "";
1223
- const useCase = typeof options.useCase === "string" ? options.useCase.trim() : "";
1224
- const replayState = typeof options.replayState === "string" ? options.replayState.trim() : "";
1225
- const catalog = await client.snapshotCatalog({
1226
- ...teamId ? { teamId } : {},
1227
- ...projectId ? { projectId } : {},
1228
- ...agentId ? { agentId } : {},
1229
- ...query ? { q: query } : {},
1230
- ...tag ? { tag } : {},
1231
- ...useCase ? { useCase } : {},
1232
- ...replayState === "draft" || replayState === "validated" || replayState === "published" ? { replayState } : {}
1233
- });
1234
- if (catalog.snapshots.length === 0) {
1235
- console.log("no sandbox snapshots found");
1236
- return;
1237
- }
1238
- for (const snapshot of catalog.snapshots) {
1239
- console.log(formatSnapshotCatalogLine(snapshot));
1240
- }
1241
- return;
1242
- }
1243
- if (subcommand === "published-snapshots" || subcommand === "published-snapshot-catalog" || subcommand === "templates" || subcommand === "template-catalog") {
1244
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1245
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
1246
- const query = typeof options.query === "string" && options.query.trim() ? options.query.trim() : typeof options.q === "string" && options.q.trim() ? options.q.trim() : "";
1247
- const name = typeof options.name === "string" && options.name.trim() ? options.name.trim() : typeof options.templateName === "string" && options.templateName.trim() ? options.templateName.trim() : "";
1248
- const version = typeof options.version === "string" ? options.version.trim() : "";
1249
- const tag = typeof options.tag === "string" ? options.tag.trim() : "";
1250
- const useCase = typeof options.useCase === "string" ? options.useCase.trim() : "";
1251
- const catalog = await client.publishedSnapshots({
1252
- ...teamId ? { teamId } : {},
1253
- ...projectId ? { projectId } : {},
1254
- ...query ? { q: query } : {},
1255
- ...name ? { name } : {},
1256
- ...version ? { version } : {},
1257
- ...tag ? { tag } : {},
1258
- ...useCase ? { useCase } : {}
1259
- });
1260
- if (catalog.publishedSnapshots.length === 0) {
1261
- console.log("no published snapshots found");
1262
- return;
1263
- }
1264
- for (const template of catalog.publishedSnapshots) {
1265
- console.log(formatSandboxTemplateLine(template));
1266
- }
1267
- return;
1268
- }
1269
- if (await handleSandboxTemplateBuildsCommand(
1270
- client,
1271
- subcommand,
1272
- options,
1273
- rest
1274
- ) || await handleSandboxReplayCommand(client, subcommand, options, rest)) {
1275
- return;
1276
- }
1277
- if (subcommand === "run-published-snapshot" || subcommand === "published-snapshot-run" || subcommand === "template-launch" || subcommand === "launch-template") {
1278
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1279
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
1280
- const snapshotId = typeof options.snapshotId === "string" && options.snapshotId.trim() ? options.snapshotId.trim() : typeof options.snapshot === "string" && options.snapshot.trim() ? options.snapshot.trim() : "";
1281
- const templateName = typeof options.templateName === "string" && options.templateName.trim() ? options.templateName.trim() : typeof options.name === "string" && options.name.trim() ? options.name.trim() : typeof rest[1] === "string" && rest[1].trim() ? rest[1].trim() : "";
1282
- const version = typeof options.version === "string" ? options.version.trim() : "";
1283
- const useCase = typeof options.useCase === "string" ? options.useCase.trim() : "";
1284
- if (!snapshotId && !templateName && !useCase) {
1285
- throw new Error(
1286
- "usage: sandbox run-published-snapshot [--snapshot-id <id>|--name <name>|--use-case <id>] [--version <v>]"
1287
- );
1288
- }
1289
- const budgetUsd = typeof options.budgetUsd === "string" && options.budgetUsd.trim() ? options.budgetUsd.trim() : typeof options.budget === "string" && options.budget.trim() ? options.budget.trim() : "";
1290
- const result = await client.runPublishedSnapshot({
1291
- ...teamId ? { teamId } : {},
1292
- ...projectId ? { projectId } : {},
1293
- ...snapshotId ? { snapshotId } : {},
1294
- ...templateName ? { templateName } : {},
1295
- ...version ? { version } : {},
1296
- ...useCase ? { useCase } : {},
1297
- ...budgetUsd ? { budget: { maxUsd: budgetUsd } } : {},
1298
- metadata: {
1299
- source: "openpond-code-published-snapshot-run"
1300
- }
1301
- });
1302
- console.log(JSON.stringify(result, null, 2));
1303
- return;
1304
- }
1305
- if (subcommand === "snapshot-fork" || subcommand === "fork-snapshot") {
1306
- const snapshotId = rest[1];
1307
- if (!snapshotId) {
1308
- throw new Error("snapshot-fork requires <snapshotId>");
1309
- }
1310
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1311
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
1312
- const budgetUsd = typeof options.budgetUsd === "string" && options.budgetUsd.trim() ? options.budgetUsd.trim() : typeof options.budget === "string" && options.budget.trim() ? options.budget.trim() : "";
1313
- const result = await client.forkSnapshot(snapshotId, {
1314
- ...teamId ? { teamId } : {},
1315
- ...projectId ? { projectId } : {},
1316
- ...budgetUsd ? { budget: { maxUsd: budgetUsd } } : {},
1317
- metadata: {
1318
- source: "openpond-code-snapshot-fork",
1319
- templateSnapshotId: snapshotId
1320
- }
1321
- });
1322
- console.log(JSON.stringify(result, null, 2));
1323
- return;
1324
- }
1325
- if (subcommand === "snapshot-create" || subcommand === "create-snapshot") {
1326
- const sandboxId = rest[1];
1327
- if (!sandboxId) {
1328
- throw new Error(
1329
- "usage: sandbox snapshot-create <sandboxId> --name <name>"
1330
- );
1331
- }
1332
- const result = await client.createSnapshot(
1333
- sandboxId,
1334
- buildSnapshotCreateInput(options)
1335
- );
1336
- console.log(JSON.stringify(result, null, 2));
1337
- return;
1338
- }
1339
- if (subcommand === "snapshot-validate" || subcommand === "validate-snapshot") {
1340
- const sandboxId = rest[1];
1341
- const snapshotId = rest[2];
1342
- if (!sandboxId || !snapshotId) {
1343
- throw new Error("snapshot-validate requires <sandboxId> <snapshotId>");
1344
- }
1345
- const cleanup = normalizeSnapshotValidationCleanup(options.cleanup);
1346
- const result = await client.validateSnapshot(sandboxId, snapshotId, {
1347
- ...cleanup ? { cleanup } : {}
1348
- });
1349
- console.log(JSON.stringify(result, null, 2));
1350
- return;
1351
- }
1352
- if (subcommand === "snapshot-publish" || subcommand === "publish-snapshot") {
1353
- const sandboxId = rest[1];
1354
- const snapshotId = rest[2];
1355
- if (!sandboxId || !snapshotId) {
1356
- throw new Error("snapshot-publish requires <sandboxId> <snapshotId>");
1357
- }
1358
- const result = await client.publishSnapshot(sandboxId, snapshotId);
1359
- console.log(JSON.stringify(result, null, 2));
1360
- return;
1361
- }
1362
- if (subcommand === "integration-connections") {
1363
- const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
1364
- const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
1365
- const agentId = typeof options.agentId === "string" ? options.agentId.trim() : "";
1366
- const status = options.status === "active" || options.status === "revoked" || options.status === "error" || options.status === "all" ? options.status : void 0;
1367
- const result = await client.integrationConnections({
1368
- ...teamId ? { teamId } : {},
1369
- ...projectId ? { projectId } : {},
1370
- ...agentId ? { agentId } : {},
1371
- ...status ? { status } : {}
1372
- });
1373
- console.log(JSON.stringify(result, null, 2));
1374
- return;
1375
- }
1376
- if (subcommand === "create") {
1377
- const result = await createSandboxFromPlan(
1378
- client,
1379
- buildSandboxCreateInput(options)
1380
- );
1381
- console.log(
1382
- JSON.stringify(
1383
- {
1384
- sandbox: summarizeSandbox(result.sandbox),
1385
- ...result.runtime ? { runtime: result.runtime } : {}
1386
- },
1387
- null,
1388
- 2
1389
- )
1390
- );
1391
- return;
1392
- }
1393
- if (subcommand === "exec") {
1394
- const sandboxId = rest[1];
1395
- const command = (typeof options.command === "string" ? options.command : null) || rest.slice(2).join(" ");
1396
- if (!sandboxId || !command.trim()) {
1397
- throw new Error("usage: sandbox exec <sandboxId> --command <command>");
1398
- }
1399
- const timeoutSeconds = parseIntegerOption(
1400
- options.timeoutSeconds,
1401
- "timeout-seconds"
1402
- );
1403
- const result = await client.exec(sandboxId, {
1404
- command: command.trim(),
1405
- ...timeoutSeconds !== void 0 ? { timeoutSeconds } : {}
1406
- });
1407
- console.log(
1408
- JSON.stringify(
1409
- {
1410
- sandbox: summarizeSandbox(result.sandbox),
1411
- command: result.command
1412
- },
1413
- null,
1414
- 2
1415
- )
1416
- );
1417
- return;
1418
- }
1419
- if (subcommand === "port" || subcommand === "preview") {
1420
- const sandboxId = rest[1];
1421
- const port = parseIntegerOption(options.port, "port");
1422
- if (!sandboxId || port === void 0) {
1423
- throw new Error("usage: sandbox port <sandboxId> --port <port>");
1424
- }
1425
- const label = typeof options.label === "string" ? options.label : void 0;
1426
- const rawAccess = typeof options.access === "string" ? options.access.trim() : "";
1427
- if (rawAccess && rawAccess !== "private" && rawAccess !== "public") {
1428
- throw new Error("sandbox port --access must be private or public");
1429
- }
1430
- const access = rawAccess === "public" ? "public" : "private";
1431
- const customDomain = typeof options.domain === "string" ? options.domain.trim() : "";
1432
- const authToken = typeof options.authToken === "string" ? options.authToken : "";
1433
- const authHeader = typeof options.authHeader === "string" ? options.authHeader.trim() : "";
1434
- const authHeaderValue = typeof options.authHeaderValue === "string" ? options.authHeaderValue : "";
1435
- if (authToken && (authHeader || authHeaderValue)) {
1436
- throw new Error(
1437
- "sandbox port auth options must use either --auth-token or --auth-header with --auth-header-value"
1438
- );
1439
- }
1440
- if (authHeader && !authHeaderValue || !authHeader && authHeaderValue) {
1441
- throw new Error(
1442
- "sandbox port custom header auth requires both --auth-header and --auth-header-value"
1443
- );
1444
- }
1445
- const result = await client.openPort(sandboxId, {
1446
- port,
1447
- ...label ? { label } : {},
1448
- access,
1449
- ...options["auto-start"] || options.autoStart ? { autoStart: true } : {},
1450
- ...customDomain ? { customDomain } : {},
1451
- ...authToken ? { authPolicy: { mode: "bearer", token: authToken } } : {},
1452
- ...authHeader && authHeaderValue ? {
1453
- authPolicy: {
1454
- mode: "header",
1455
- headerName: authHeader,
1456
- headerValue: authHeaderValue
1457
- }
1458
- } : {}
1459
- });
1460
- console.log(JSON.stringify(result.preview, null, 2));
1461
- return;
1462
- }
1463
- if (subcommand === "stop") {
1464
- const sandboxId = rest[1];
1465
- if (!sandboxId) {
1466
- throw new Error(
1467
- "usage: sandbox stop <sandboxId> [--fail-on-unpreserved-changes] [--async]"
1468
- );
1469
- }
1470
- const result = await client.stop(sandboxId, {
1471
- failOnUnpreservedChanges: parseBooleanOption(
1472
- options.failOnUnpreservedChanges
1473
- ),
1474
- async: parseSandboxAsyncOption(options)
1475
- });
1476
- console.log(
1477
- JSON.stringify(
1478
- {
1479
- sandbox: summarizeSandbox(result.sandbox),
1480
- receipt: result.receipt
1481
- },
1482
- null,
1483
- 2
1484
- )
1485
- );
1486
- return;
1487
- }
1488
- if (subcommand === "start") {
1489
- const sandboxId = rest[1];
1490
- if (!sandboxId) {
1491
- throw new Error("usage: sandbox start <sandboxId>");
1492
- }
1493
- const result = await client.start(sandboxId);
1494
- console.log(
1495
- JSON.stringify(
1496
- {
1497
- sandbox: await waitForSandboxCreateReady(client, result.sandbox),
1498
- receipt: result.receipt
1499
- },
1500
- null,
1501
- 2
1502
- )
1503
- );
1504
- return;
1505
- }
1506
- if (subcommand === "delete") {
1507
- const sandboxId = rest[1];
1508
- if (!sandboxId) {
1509
- throw new Error(
1510
- "usage: sandbox delete <sandboxId> [--fail-on-unpreserved-changes] [--async]"
1511
- );
1512
- }
1513
- const sandbox = await client.delete(sandboxId, {
1514
- failOnUnpreservedChanges: parseBooleanOption(
1515
- options.failOnUnpreservedChanges
1516
- ),
1517
- async: parseSandboxAsyncOption(options)
1518
- });
1519
- console.log(
1520
- JSON.stringify({ sandbox: summarizeSandbox(sandbox) }, null, 2)
1521
- );
1522
- return;
1523
- }
1524
- if (subcommand === "receipts") {
1525
- const sandboxId = rest[1];
1526
- if (!sandboxId) {
1527
- throw new Error("usage: sandbox receipts <sandboxId>");
1528
- }
1529
- const receipts = await client.receipts(sandboxId);
1530
- console.log(JSON.stringify({ receipts }, null, 2));
1531
- return;
1532
- }
1533
- if (subcommand === "logs") {
1534
- const sandboxId = rest[1];
1535
- if (!sandboxId) {
1536
- throw new Error("usage: sandbox logs <sandboxId>");
1537
- }
1538
- const logs = await client.logs(sandboxId);
1539
- for (const line of logs) {
1540
- console.log(line);
1541
- }
1542
- return;
1543
- }
1544
- if (await handleSandboxProcessCommand(client, subcommand, options, rest) || await handleSandboxFilesCommand(client, subcommand, options, rest) || await handleSandboxGitCommand(client, subcommand, options, rest)) {
1545
- return;
1546
- }
1547
- if (subcommand === "billing") {
1548
- const sandboxId = rest[1];
1549
- if (!sandboxId) {
1550
- throw new Error("usage: sandbox billing <sandboxId>");
1551
- }
1552
- const result = await client.billing(sandboxId);
1553
- console.log(
1554
- JSON.stringify(
1555
- {
1556
- sandbox: summarizeSandbox(result.sandbox),
1557
- billing: result.billing
1558
- },
1559
- null,
1560
- 2
1561
- )
1562
- );
1563
- return;
1564
- }
1565
- if (subcommand === "integration-leases") {
1566
- const sandboxId = rest[1];
1567
- if (!sandboxId) {
1568
- throw new Error("usage: sandbox integration-leases <sandboxId>");
1569
- }
1570
- const result = await client.integrationLeases(sandboxId);
1571
- console.log(
1572
- JSON.stringify(
1573
- {
1574
- sandbox: summarizeSandbox(result.sandbox),
1575
- integrationLeases: result.integrationLeases
1576
- },
1577
- null,
1578
- 2
1579
- )
1580
- );
1581
- return;
1582
- }
1583
- if (subcommand === "integration-attach") {
1584
- const sandboxId = rest[1];
1585
- if (!sandboxId) {
1586
- throw new Error(
1587
- "usage: sandbox integration-attach <sandboxId> --integration-connection <id> --integration-capabilities <csv>"
1588
- );
1589
- }
1590
- const result = await client.attachIntegrationConnection(
1591
- sandboxId,
1592
- buildSandboxIntegrationAttachInput(options)
1593
- );
1594
- console.log(
1595
- JSON.stringify(
1596
- {
1597
- sandbox: summarizeSandbox(result.sandbox),
1598
- integrationLeases: result.integrationLeases
1599
- },
1600
- null,
1601
- 2
1602
- )
1603
- );
1604
- return;
1605
- }
1606
- if (subcommand === "integration-remove") {
1607
- const sandboxId = rest[1];
1608
- const leaseId = typeof options.leaseId === "string" ? options.leaseId.trim() : "";
1609
- if (!sandboxId || !leaseId) {
1610
- throw new Error(
1611
- "usage: sandbox integration-remove <sandboxId> --lease-id <id>"
1612
- );
1613
- }
1614
- const result = await client.removeIntegrationLease(sandboxId, leaseId);
1615
- console.log(
1616
- JSON.stringify(
1617
- {
1618
- sandbox: summarizeSandbox(result.sandbox),
1619
- integrationLeases: result.integrationLeases
1620
- },
1621
- null,
1622
- 2
1623
- )
1624
- );
1625
- return;
1626
- }
1627
- if (subcommand === "smoke") {
1628
- const repo = typeof options.repo === "string" ? options.repo.trim() : void 0;
1629
- const budgetUsd = typeof options.budgetUsd === "string" ? options.budgetUsd.trim() : typeof options.budget === "string" ? options.budget.trim() : void 0;
1630
- const keep = parseBooleanOption(options.keep);
1631
- const preview = options.preview !== void 0 ? parseBooleanOption(options.preview) : !parseBooleanOption(options.noPreview);
1632
- const snapshot = parseBooleanOption(options.snapshot);
1633
- const fork = parseBooleanOption(options.fork);
1634
- const smokeOptions = {
1635
- ...repo ? { repo } : {},
1636
- ...budgetUsd ? { budgetUsd } : {},
1637
- keep,
1638
- preview,
1639
- snapshot,
1640
- fork
1641
- };
1642
- if (typeof options.expectedMppMode === "string" && options.expectedMppMode.trim()) {
1643
- smokeOptions.expectedMppMode = options.expectedMppMode.trim();
1644
- }
1645
- const cpu = parseNumberOption(options.cpu, "cpu");
1646
- const memoryGb = parseNumberOption(options.memoryGb, "memory-gb");
1647
- const diskGb = parseNumberOption(options.diskGb, "disk-gb");
1648
- if (cpu !== void 0) smokeOptions.cpu = cpu;
1649
- if (memoryGb !== void 0) smokeOptions.memoryGb = memoryGb;
1650
- if (diskGb !== void 0) smokeOptions.diskGb = diskGb;
1651
- const summary = await client.smoke(smokeOptions);
1652
- console.log(JSON.stringify(summary, null, 2));
1653
- return;
1654
- }
1655
- throw new Error(
1656
- "usage: sandbox <list|mcp-config|runtime-list|runtime-get|runtime-events|runtime-status|runtime-event|runtime-preserve-source|pricing|costs|secrets|secret-create|secret-rotate|secret-attach|secret-revoke|secret-delete|snapshots|published-snapshots|run-published-snapshot|snapshot-fork|snapshot-validate|snapshot-publish|create|exec|port|preview|stop|start|delete|receipts|logs|billing|process-start|process-list|process-get|process-stop|process-stream|pty-start|pty-list|pty-get|pty-write|pty-stop|pty-stream|upload-file|download-file|list-files|search-files|delete-file|stat-file|mkdir|move-file|git-status|git-diff|git-export-patch|git-branch|git-commit|git-pull|git-push|smoke> [args]"
1657
- );
1658
- }
1659
- export {
1660
- runSandboxCommand
1661
- };