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