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,1838 +0,0 @@
1
- import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
-
3
- // ../../packages/cloud/dist/api/core.js
4
- var DEFAULT_API_TIMEOUT_MS = 3e4;
5
- var DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;
6
- var LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1e3, maxResponseBytes: 64 * 1024 * 1024 };
7
- var ApiTimeoutError = class extends Error {
8
- timeoutMs;
9
- requestUrl;
10
- code = "OPENPOND_API_TIMEOUT";
11
- constructor(timeoutMs, requestUrl) {
12
- super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);
13
- this.timeoutMs = timeoutMs;
14
- this.requestUrl = requestUrl;
15
- this.name = "ApiTimeoutError";
16
- }
17
- };
18
- var ApiResponseTooLargeError = class extends Error {
19
- maximumBytes;
20
- requestUrl;
21
- code = "OPENPOND_API_RESPONSE_TOO_LARGE";
22
- constructor(maximumBytes, requestUrl) {
23
- super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);
24
- this.maximumBytes = maximumBytes;
25
- this.requestUrl = requestUrl;
26
- this.name = "ApiResponseTooLargeError";
27
- }
28
- };
29
- var OpenPondApiError = class extends Error {
30
- status;
31
- apiMessage;
32
- code;
33
- constructor(status, errorCode, label, apiMessage = null) {
34
- const detail = apiMessage || errorCode;
35
- super(`${label} failed: ${status}${detail ? ` ${detail}` : ""}`);
36
- this.status = status;
37
- this.apiMessage = apiMessage;
38
- this.name = "OpenPondApiError";
39
- this.code = errorCode || "OPENPOND_API_ERROR";
40
- }
41
- };
42
- async function apiFetch(baseUrl, token, requestPath, options = {}) {
43
- const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;
44
- const requestUrl = `${baseUrl}${requestPath}`;
45
- const headers = new Headers(init.headers);
46
- headers.set("Content-Type", "application/json");
47
- const apiKey = process.env.OPENPOND_API_KEY;
48
- const trimmedToken = token?.trim() || "";
49
- const tokenIsApiKey = trimmedToken.startsWith("opk_");
50
- const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);
51
- if (effectiveApiKey && !headers.has("openpond-api-key"))
52
- headers.set("openpond-api-key", effectiveApiKey);
53
- if (token) {
54
- headers.set("Authorization", tokenIsApiKey ? `ApiKey ${trimmedToken}` : `Bearer ${token}`);
55
- } else if (apiKey && !headers.has("Authorization")) {
56
- headers.set("Authorization", `ApiKey ${apiKey}`);
57
- }
58
- const timeoutController = new AbortController();
59
- const timeoutError = new ApiTimeoutError(timeoutMs, requestUrl);
60
- const timer = timeoutMs > 0 ? setTimeout(() => timeoutController.abort(timeoutError), timeoutMs) : null;
61
- timer?.unref?.();
62
- const signal = composedSignal(init.signal, timeoutController.signal, timeoutMs);
63
- const cleanup = () => {
64
- if (timer)
65
- clearTimeout(timer);
66
- };
67
- try {
68
- const response = await fetch(requestUrl, { ...init, headers, signal });
69
- return boundedResponse(response, {
70
- cleanup,
71
- maximumBytes: maxResponseBytes,
72
- requestUrl,
73
- timeoutController,
74
- timeoutError
75
- });
76
- } catch (error) {
77
- cleanup();
78
- if (timeoutController.signal.aborted)
79
- throw timeoutError;
80
- throw error;
81
- }
82
- }
83
- async function readApiJson(response, label) {
84
- let payload;
85
- try {
86
- const text = await response.text();
87
- payload = text ? JSON.parse(text) : {};
88
- } catch (error) {
89
- if (error instanceof ApiTimeoutError || error instanceof ApiResponseTooLargeError)
90
- throw error;
91
- payload = {};
92
- }
93
- if (!response.ok) {
94
- const errorCode = typeof payload.error === "string" ? payload.error : null;
95
- const apiMessage = typeof payload.message === "string" ? payload.message : null;
96
- throw new OpenPondApiError(response.status, errorCode, label, apiMessage);
97
- }
98
- return payload;
99
- }
100
- function boundedResponse(response, input) {
101
- if (!response.body) {
102
- input.cleanup();
103
- return response;
104
- }
105
- const contentLength = Number(response.headers.get("content-length"));
106
- if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {
107
- input.cleanup();
108
- void response.body.cancel();
109
- throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);
110
- }
111
- const reader = response.body.getReader();
112
- let receivedBytes = 0;
113
- const body = new ReadableStream({
114
- async pull(controller) {
115
- try {
116
- const result = await reader.read();
117
- if (result.done) {
118
- input.cleanup();
119
- controller.close();
120
- return;
121
- }
122
- receivedBytes += result.value.byteLength;
123
- if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {
124
- input.cleanup();
125
- await reader.cancel();
126
- controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));
127
- return;
128
- }
129
- controller.enqueue(result.value);
130
- } catch (error) {
131
- input.cleanup();
132
- controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);
133
- }
134
- },
135
- async cancel(reason) {
136
- input.cleanup();
137
- await reader.cancel(reason);
138
- }
139
- });
140
- return new Response(body, {
141
- headers: response.headers,
142
- status: response.status,
143
- statusText: response.statusText
144
- });
145
- }
146
- function composedSignal(callerSignal, timeoutSignal, timeoutMs) {
147
- if (timeoutMs <= 0)
148
- return callerSignal ?? void 0;
149
- return callerSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : timeoutSignal;
150
- }
151
-
152
- // ../../packages/cloud/dist/urls.js
153
- var DEFAULT_OPENPOND_WEB_BASE_URL = "https://openpond.ai";
154
- var DEFAULT_OPENPOND_API_BASE_URL = "https://api.openpond.ai";
155
- var DEFAULT_OPENPOND_OPCHAT_API_BASE_URL = "https://api.openpond.ai/opchat/v1";
156
-
157
- // ../../packages/cloud/dist/sandbox/url.js
158
- function normalizeSandboxApiUrl(baseUrlOrApiUrl) {
159
- const trimmed = baseUrlOrApiUrl.trim().replace(/\/$/, "");
160
- if (!trimmed) {
161
- throw new Error("sandbox API URL must be non-empty");
162
- }
163
- const url = new URL(trimmed);
164
- const normalizedPath = url.pathname.replace(/\/$/, "");
165
- if (normalizedPath.endsWith("/v1/sandboxes") || normalizedPath.endsWith("/api/sandboxes")) {
166
- return `${url.origin}${normalizedPath}`;
167
- }
168
- if (normalizedPath.endsWith("/v1")) {
169
- return `${url.origin}${normalizedPath}/sandboxes`;
170
- }
171
- if (isOpenPondHostedApiHost(url.hostname)) {
172
- return `${url.origin}${normalizedPath}/v1/sandboxes`;
173
- }
174
- if (url.origin === DEFAULT_OPENPOND_WEB_BASE_URL) {
175
- return `${DEFAULT_OPENPOND_API_BASE_URL}/v1/sandboxes`;
176
- }
177
- return `${url.origin}${normalizedPath}/api/sandboxes`;
178
- }
179
- function apiRootUrlFromSandboxApiUrl(sandboxApiUrl) {
180
- const suffix = "/sandboxes";
181
- if (!sandboxApiUrl.endsWith(suffix)) {
182
- throw new Error("sandbox API URL must end with /sandboxes");
183
- }
184
- return sandboxApiUrl.slice(0, -suffix.length);
185
- }
186
- function isOpenPondHostedApiHost(hostname) {
187
- return hostname === "api.openpond.ai" || hostname.startsWith("api") && hostname.endsWith(".openpond.ai");
188
- }
189
-
190
- // ../../packages/cloud/dist/sandbox/client-handles.js
191
- function createSandboxRuntimeNamespace(client) {
192
- return {
193
- list: (input = {}) => client.listSandboxRuntimes(input),
194
- create: (input) => client.createSandboxRuntime(input),
195
- handle: (runtimeId, initial = null) => client.sandboxRuntime(runtimeId, initial),
196
- get: (runtimeId) => client.getSandboxRuntime(runtimeId),
197
- createSandbox: (runtimeId, input = {}, options = {}) => client.createSandboxRuntimeSandbox(runtimeId, input, options),
198
- updateStatus: (runtimeId, input) => client.updateSandboxRuntimeStatus(runtimeId, input),
199
- events: (runtimeId) => client.listSandboxRuntimeEvents(runtimeId),
200
- event: (runtimeId, input) => client.emitSandboxRuntimeEvent(runtimeId, input),
201
- checkpoint: (runtimeId, input = {}) => client.checkpointSandboxRuntime(runtimeId, input),
202
- promote: (runtimeId, input, options = {}) => client.promoteSandboxRuntime(runtimeId, input, options),
203
- preserveSource: (runtimeId, input = {}, options = {}) => client.preserveSandboxRuntimeSource(runtimeId, input, options)
204
- };
205
- }
206
- function createSandboxNamespace(client) {
207
- return {
208
- list: (input = {}) => client.list(input),
209
- create: (input) => client.create(input),
210
- get: (sandboxId) => client.get(sandboxId),
211
- pricing: () => client.pricing(),
212
- costs: (input = {}) => client.costs(input)
213
- };
214
- }
215
- function createSandboxProjectNamespace(client) {
216
- return {
217
- list: (input) => client.listProjects(input),
218
- upsert: (input) => client.upsertProject(input),
219
- upsertGitRemote: (input) => client.upsertProjectGitRemote(input),
220
- get: (projectId, input) => client.getProject(projectId, input),
221
- update: (projectId, input) => client.updateProject(projectId, input),
222
- sync: (projectId, input) => client.syncProject(projectId, input),
223
- ensureGitRemote: (projectId, input) => client.ensureProjectGitRemote(projectId, input),
224
- getGitRemote: (projectId, input) => client.ensureProjectGitRemote(projectId, input),
225
- git: (projectId, input) => client.ensureProjectGitRemote(projectId, input),
226
- uploadSource: (projectId, input) => client.uploadProjectSource(projectId, input),
227
- archive: (projectId, input) => client.archiveProject(projectId, input)
228
- };
229
- }
230
- function createSandboxProfileNamespace(client) {
231
- return {
232
- get: (input) => client.getHostedProfile(input),
233
- status: (input) => client.getHostedProfile(input),
234
- ensureHosted: (input) => client.ensureHostedProfile(input),
235
- push: (input) => client.pushHostedProfile(input)
236
- };
237
- }
238
- function createSandboxAgentNamespace(client) {
239
- return {
240
- list: (input) => client.listAgents(input),
241
- upsert: (input) => client.upsertAgent(input),
242
- get: (agentId, input) => client.getAgent(agentId, input),
243
- update: (agentId, input) => client.updateAgent(agentId, input),
244
- archive: (agentId, input) => client.archiveAgent(agentId, input),
245
- run: (agentId, input) => client.runAgent(agentId, input),
246
- sourceDeployPlan: (agentId, input) => client.getAgentSourceDeployPlan(agentId, input),
247
- manifestSnapshots: (agentId, input) => client.listAgentManifestSnapshots(agentId, input),
248
- requestSourceChecks: (agentId, input) => client.requestAgentSourceChecks(agentId, input),
249
- configureSourceSetup: (agentId, input) => client.configureAgentSourceSetup(agentId, input),
250
- publishSource: (agentId, input) => client.publishAgentSource(agentId, input)
251
- };
252
- }
253
-
254
- // ../../packages/cloud/dist/sandbox/runtime-handle.js
255
- function createSandboxRuntimeHandle(client, runtimeId, initial = null) {
256
- const currentSandbox = async (input = {}, options = {}) => {
257
- const runtime = await client.getSandboxRuntime(runtimeId);
258
- if (runtime.sandboxId) {
259
- return client.get(runtime.sandboxId);
260
- }
261
- return client.createSandboxRuntimeSandbox(runtimeId, input, options).then((payload) => payload.sandbox);
262
- };
263
- const resume = async (input = {}, options = {}) => {
264
- const runtime = await client.getSandboxRuntime(runtimeId);
265
- if (!runtime.sandboxId) {
266
- return client.createSandboxRuntimeSandbox(runtimeId, input, options).then((payload) => payload.sandbox);
267
- }
268
- const sandbox = await client.get(runtime.sandboxId);
269
- if (sandbox.state === "stopped") {
270
- return client.start(sandbox.id, options).then((payload) => payload.sandbox);
271
- }
272
- if (sandbox.state === "archived") {
273
- return client.restore(sandbox.id).then((payload) => payload.sandbox);
274
- }
275
- if (sandbox.state === "deleted" || sandbox.state === "error") {
276
- return client.createSandboxRuntimeSandbox(runtimeId, input, options).then((payload) => payload.sandbox);
277
- }
278
- return sandbox;
279
- };
280
- const checkpointHint = (input = {}) => client.emitSandboxRuntimeEvent(runtimeId, {
281
- type: "workflow.checkpoint_hint",
282
- summary: input.summary ?? input.reason ?? "Workflow checkpoint hint",
283
- payload: {
284
- ...input.payload,
285
- reason: input.reason ?? null
286
- },
287
- artifactRefs: input.artifactRefs,
288
- lifecycleHint: {
289
- kind: "checkpoint",
290
- reason: input.reason ?? null
291
- }
292
- });
293
- const waitForUser = async (input = {}) => {
294
- await client.emitSandboxRuntimeEvent(runtimeId, {
295
- type: "workflow.waiting_for_user",
296
- summary: input.summary ?? input.reason ?? "Waiting for user",
297
- payload: {
298
- ...input.payload,
299
- reason: input.reason ?? null
300
- },
301
- lifecycleHint: {
302
- kind: "waiting_for_user",
303
- reason: input.reason ?? null
304
- }
305
- });
306
- const current = await client.getSandboxRuntime(runtimeId);
307
- if (current.status === "waiting_for_user")
308
- return current;
309
- return client.updateSandboxRuntimeStatus(runtimeId, {
310
- status: "waiting_for_user",
311
- expectedVersion: current.version,
312
- summary: input.summary ?? input.reason,
313
- metadata: {
314
- workflowWaitForUserReason: input.reason ?? null
315
- }
316
- });
317
- };
318
- const keepAlive = (input = {}) => {
319
- const keepaliveUntil = runtimeKeepaliveUntilIso(input);
320
- return client.emitSandboxRuntimeEvent(runtimeId, {
321
- type: "workflow.keepalive",
322
- summary: input.summary ?? input.reason ?? "Workflow keepalive",
323
- payload: {
324
- ...input.payload,
325
- reason: input.reason ?? null,
326
- keepaliveUntil
327
- },
328
- lifecycleHint: {
329
- kind: "keepalive",
330
- reason: input.reason ?? null,
331
- keepaliveUntil
332
- }
333
- });
334
- };
335
- return {
336
- id: runtimeId,
337
- initial,
338
- get: () => client.getSandboxRuntime(runtimeId),
339
- sandbox: currentSandbox,
340
- resume,
341
- createSandbox: (input = {}, options = {}) => client.createSandboxRuntimeSandbox(runtimeId, input, options),
342
- status: async (input) => {
343
- if (typeof input !== "string") {
344
- return client.updateSandboxRuntimeStatus(runtimeId, input);
345
- }
346
- const current = await client.getSandboxRuntime(runtimeId);
347
- return client.updateSandboxRuntimeStatus(runtimeId, {
348
- status: input,
349
- expectedVersion: current.version
350
- });
351
- },
352
- events: () => client.listSandboxRuntimeEvents(runtimeId),
353
- event: (input) => client.emitSandboxRuntimeEvent(runtimeId, input),
354
- recordCommit: (commitSha, input = {}) => client.emitSandboxRuntimeEvent(runtimeId, {
355
- ...input,
356
- type: input.type ?? "git.commit",
357
- commitSha
358
- }),
359
- checkpointHint,
360
- waitForUser,
361
- keepAlive,
362
- checkpoint: (input) => client.checkpointSandboxRuntime(runtimeId, input),
363
- files: {
364
- write: async (path, contents) => client.uploadFile((await resume()).id, path, contents),
365
- read: async (path) => client.downloadFile((await resume()).id, path),
366
- readResponse: async (input) => client.downloadFileResponse((await resume()).id, input),
367
- list: async (input = {}) => client.listFiles((await resume()).id, input),
368
- delete: async (path, input = {}) => client.deleteFile((await resume()).id, path, input),
369
- search: async (input) => client.searchFiles((await resume()).id, input),
370
- stat: async (path) => client.statFile((await resume()).id, path),
371
- mkdir: async (input) => client.mkdir((await resume()).id, input),
372
- move: async (input) => client.moveFile((await resume()).id, input)
373
- },
374
- commands: {
375
- run: async (command) => client.exec((await resume()).id, typeof command === "string" ? { command } : command)
376
- },
377
- ports: {
378
- expose: async (port) => client.openPort((await resume()).id, typeof port === "number" ? { port } : port)
379
- },
380
- promote: (input, options = {}) => client.promoteSandboxRuntime(runtimeId, input, options),
381
- preserveSource: (input = {}, options = {}) => client.preserveSandboxRuntimeSource(runtimeId, input, options),
382
- archive: async (expectedVersion) => {
383
- const version = expectedVersion ?? (await client.getSandboxRuntime(runtimeId)).version;
384
- return client.updateSandboxRuntimeStatus(runtimeId, {
385
- status: "archived",
386
- expectedVersion: version
387
- });
388
- }
389
- };
390
- }
391
- function runtimeKeepaliveUntilIso(input) {
392
- if (input?.until instanceof Date) {
393
- return input.until.toISOString();
394
- }
395
- if (typeof input?.until === "string" && input.until.trim()) {
396
- return new Date(input.until).toISOString();
397
- }
398
- const seconds = typeof input?.seconds === "number" && Number.isFinite(input.seconds) ? Math.max(1, Math.trunc(input.seconds)) : 60;
399
- return new Date(Date.now() + seconds * 1e3).toISOString();
400
- }
401
-
402
- // ../../packages/cloud/dist/sandbox/smoke.js
403
- async function runSandboxSmoke(client, options = {}) {
404
- const runId = `openpond-code-smoke-${Date.now()}`;
405
- const expectedExec = `openpond-code-exec-ok:${runId}`;
406
- const expectedPreview = `openpond-code-preview-ok:${runId}`;
407
- const expectedFile = `openpond-code-file-ok:${runId}`;
408
- const previewPort = 4173;
409
- let sandboxId = null;
410
- let forkSandboxId = null;
411
- let deleted = false;
412
- let forkDeleted = false;
413
- try {
414
- const sandbox = await waitForCreateReady(client, await client.create({
415
- repo: options.repo ?? "https://github.com/octocat/Hello-World",
416
- resources: {
417
- cpu: options.cpu ?? 1,
418
- memoryGb: options.memoryGb ?? 1,
419
- diskGb: options.diskGb ?? 8
420
- },
421
- budget: { maxUsd: options.budgetUsd ?? "0.05" },
422
- quotas: {
423
- maxSpendUsd: options.budgetUsd ?? "0.05",
424
- maxDurationSeconds: 600,
425
- idleTimeoutSeconds: 600,
426
- maxOpenPorts: 2
427
- },
428
- metadata: {
429
- runId,
430
- source: "openpond-code-sandbox-smoke"
431
- }
432
- }, { async: true }));
433
- sandboxId = sandbox.id;
434
- const expectedMppMode = options.expectedMppMode;
435
- if (expectedMppMode && sandbox.reservation.mpp?.mode !== expectedMppMode) {
436
- throw new Error(`expected ${expectedMppMode} reservation, got ${sandbox.reservation.mpp?.mode ?? "none"}`);
437
- }
438
- if (!expectedMppMode && !sandbox.reservation.mpp?.mode) {
439
- throw new Error("expected sandbox reservation MPP metadata");
440
- }
441
- const exec = await client.exec(sandbox.id, {
442
- command: [
443
- `printf '${expectedExec}\\n'`,
444
- "test -f README && printf 'repo-clone-ok\\n'",
445
- "cat > server.cjs <<'EOF'",
446
- "const { createServer } = require('node:http');",
447
- `createServer((_request, response) => response.end('${expectedPreview}')).listen(${previewPort}, '0.0.0.0');`,
448
- "EOF",
449
- "nohup node server.cjs > server.log 2>&1 & sleep 1"
450
- ].join("\n"),
451
- timeoutSeconds: 120
452
- });
453
- if (exec.command.status !== "succeeded") {
454
- throw new Error(`expected command success, got ${exec.command.status}`);
455
- }
456
- if (!exec.command.output.includes(expectedExec)) {
457
- throw new Error("expected exec marker");
458
- }
459
- await client.uploadFile(sandbox.id, "openpond-code-smoke.txt", expectedFile);
460
- const downloaded = await client.downloadFile(sandbox.id, "openpond-code-smoke.txt");
461
- if (downloaded !== expectedFile) {
462
- throw new Error("expected file roundtrip marker");
463
- }
464
- let snapshotId = null;
465
- if (options.snapshot || options.fork) {
466
- const snapshotResponse = await client.createSnapshot(sandbox.id, {
467
- async: true,
468
- name: `openpond-code-smoke-${runId}`,
469
- replay: {
470
- entrypoints: [
471
- {
472
- command: "cat openpond-code-smoke.txt",
473
- name: "default"
474
- }
475
- ],
476
- retention: {
477
- class: "pinned"
478
- },
479
- safety: {
480
- cleanup: "delete",
481
- idleTimeoutSeconds: 600,
482
- internetEgress: "block",
483
- maxDurationSeconds: 600,
484
- maxSpendUsd: options.budgetUsd ?? "0.05",
485
- publicPreview: false
486
- },
487
- validation: {
488
- commands: [
489
- {
490
- command: "test -f openpond-code-smoke.txt"
491
- }
492
- ]
493
- }
494
- }
495
- });
496
- const snapshot = snapshotResponse.snapshot ?? (await waitForSnapshotReady(client, sandbox.id, snapshotResponse.snapshotJob?.snapshotId)).snapshot;
497
- snapshotId = snapshot.id;
498
- if (snapshot.state !== "ready") {
499
- throw new Error(`expected ready snapshot, got ${snapshot.state}`);
500
- }
501
- }
502
- if (options.fork) {
503
- if (!snapshotId) {
504
- throw new Error("expected snapshot id before fork");
505
- }
506
- const forked = await waitForCreateReady(client, (await client.forkSnapshot(snapshotId, {
507
- budget: { maxUsd: options.budgetUsd ?? "0.05" },
508
- metadata: {
509
- source: "openpond-code-sandbox-smoke-fork",
510
- templateSnapshotId: snapshotId
511
- }
512
- }, { async: true })).sandbox);
513
- forkSandboxId = forked.id;
514
- const forkExec = await client.exec(forked.id, {
515
- command: "cat openpond-code-smoke.txt",
516
- timeoutSeconds: 120
517
- });
518
- if (forkExec.command.status !== "succeeded") {
519
- throw new Error(`expected fork command success, got ${forkExec.command.status}`);
520
- }
521
- if (!forkExec.command.output.includes(expectedFile)) {
522
- throw new Error("expected fork snapshot marker");
523
- }
524
- if (!options.keep) {
525
- await deleteSandboxForSmoke(client, forked.id);
526
- forkDeleted = true;
527
- }
528
- }
529
- let previewStatus = null;
530
- if (options.preview !== false) {
531
- const opened = await client.openPort(sandbox.id, {
532
- label: "openpond-code-smoke",
533
- port: previewPort
534
- });
535
- const preview = await fetch(opened.preview.url);
536
- previewStatus = preview.status;
537
- const body = await preview.text();
538
- if (preview.status !== 200) {
539
- throw new Error(`expected preview HTTP 200, got ${preview.status}`);
540
- }
541
- if (!body.includes(expectedPreview)) {
542
- throw new Error("expected preview marker");
543
- }
544
- }
545
- const { sandbox: readback, receipts } = await stopSandboxForSmoke(client, sandbox.id);
546
- if (!options.keep) {
547
- await deleteSandboxForSmoke(client, sandbox.id);
548
- deleted = true;
549
- }
550
- return {
551
- deleted,
552
- execOutput: exec.command.output.trim(),
553
- fileRoundtrip: true,
554
- forkSandboxId,
555
- previewStatus,
556
- receiptRefs: receipts.map((receipt) => receipt.mpp.receiptRef ?? null),
557
- reservationRef: sandbox.reservation.mpp?.reservationRef ?? null,
558
- runId,
559
- sandboxId: sandbox.id,
560
- snapshotId,
561
- state: readback.state
562
- };
563
- } finally {
564
- if (forkSandboxId && !options.keep && !forkDeleted) {
565
- await cleanupSandboxBestEffort(client, forkSandboxId);
566
- }
567
- if (sandboxId && !options.keep && !deleted) {
568
- await cleanupSandboxBestEffort(client, sandboxId);
569
- }
570
- }
571
- }
572
- async function stopSandboxForSmoke(client, sandboxId) {
573
- try {
574
- await client.stop(sandboxId);
575
- } catch {
576
- await client.stop(sandboxId, { async: true });
577
- }
578
- const sandbox = await waitForSandboxState(client, sandboxId, /* @__PURE__ */ new Set(["stopped", "deleted"]), "stop");
579
- const receipts = await waitForReceipts(client, sandboxId);
580
- if (receipts.length === 0) {
581
- throw new Error("expected receipt readback");
582
- }
583
- return { sandbox, receipts };
584
- }
585
- async function deleteSandboxForSmoke(client, sandboxId) {
586
- try {
587
- const deleted = await client.delete(sandboxId);
588
- if (deleted.state === "deleted") {
589
- return deleted;
590
- }
591
- await client.delete(sandboxId, { async: true });
592
- } catch {
593
- await client.delete(sandboxId, { async: true });
594
- }
595
- return waitForSandboxState(client, sandboxId, /* @__PURE__ */ new Set(["deleted"]), "delete");
596
- }
597
- async function cleanupSandboxBestEffort(client, sandboxId) {
598
- try {
599
- await deleteSandboxForSmoke(client, sandboxId);
600
- } catch {
601
- await client.delete(sandboxId, { async: true }).catch(() => void 0);
602
- }
603
- }
604
- async function waitForSandboxState(client, sandboxId, targetStates, operation) {
605
- const timeoutMs = 5 * 6e4;
606
- const pollMs = 3e3;
607
- const deadline = Date.now() + timeoutMs;
608
- let latest = await client.get(sandboxId);
609
- while (Date.now() < deadline) {
610
- if (targetStates.has(latest.state)) {
611
- return latest;
612
- }
613
- if (latest.state === "error") {
614
- throw new Error(`sandbox ${operation} failed: ${sandboxId}`);
615
- }
616
- await sleep(pollMs);
617
- latest = await client.get(sandboxId);
618
- }
619
- throw new Error(`sandbox ${operation} did not reach ${[...targetStates].join("/")} before timeout: ${sandboxId} (${latest.state})`);
620
- }
621
- async function waitForReceipts(client, sandboxId) {
622
- const timeoutMs = 2 * 6e4;
623
- const pollMs = 3e3;
624
- const deadline = Date.now() + timeoutMs;
625
- let receipts = await client.receipts(sandboxId);
626
- while (Date.now() < deadline) {
627
- if (receipts.length > 0) {
628
- return receipts;
629
- }
630
- await sleep(pollMs);
631
- receipts = await client.receipts(sandboxId);
632
- }
633
- return receipts;
634
- }
635
- async function waitForCreateReady(client, sandbox) {
636
- if (sandbox.state === "running" || sandbox.state === "stopped") {
637
- return sandbox;
638
- }
639
- if (sandbox.state === "error") {
640
- throw new Error(`sandbox create failed: ${sandbox.id}
641
- ${sandbox.logs.join("\n")}`);
642
- }
643
- const timeoutMs = 12 * 6e4;
644
- const pollMs = 3e3;
645
- const deadline = Date.now() + timeoutMs;
646
- let latest = sandbox;
647
- while (Date.now() < deadline) {
648
- await sleep(pollMs);
649
- latest = await client.get(sandbox.id);
650
- if (latest.state === "running" || latest.state === "stopped") {
651
- return latest;
652
- }
653
- if (latest.state === "error") {
654
- throw new Error(`sandbox create failed: ${latest.id}
655
- ${latest.logs.join("\n")}`);
656
- }
657
- }
658
- throw new Error(`sandbox create did not reach running state before timeout: ${latest.id} (${latest.state})`);
659
- }
660
- async function waitForSnapshotReady(client, sandboxId, snapshotId) {
661
- if (!snapshotId) {
662
- throw new Error("snapshot job did not return snapshot id");
663
- }
664
- const timeoutMs = 12 * 6e4;
665
- const pollMs = 3e3;
666
- const deadline = Date.now() + timeoutMs;
667
- let latest = await client.get(sandboxId);
668
- while (Date.now() < deadline) {
669
- const snapshot = latest.snapshots?.find((item) => item.id === snapshotId);
670
- if (snapshot?.state === "ready") {
671
- return { sandbox: latest, snapshot };
672
- }
673
- const job = latest.snapshotJobs?.find((item) => item.snapshotId === snapshotId);
674
- if (job?.status === "failed") {
675
- throw new Error(`snapshot job failed: ${job.error ?? snapshotId}`);
676
- }
677
- await sleep(pollMs);
678
- latest = await client.get(sandboxId);
679
- }
680
- throw new Error(`snapshot did not reach ready state before timeout: ${snapshotId}`);
681
- }
682
- function sleep(ms) {
683
- return new Promise((resolve) => setTimeout(resolve, ms));
684
- }
685
-
686
- // ../../packages/cloud/dist/sandbox/async-request-options.js
687
- function asyncRequestHeaders(options = {}) {
688
- return options.async || options.respondAsync ? { Prefer: "respond-async" } : void 0;
689
- }
690
-
691
- // ../../packages/cloud/dist/sandbox/stream.js
692
- async function streamSandboxEventOutput(params) {
693
- const response = await apiFetch(params.sandboxApiUrl, params.apiKey, params.path, { timeoutMs: 0, maxResponseBytes: 0 });
694
- if (!response.body) {
695
- return;
696
- }
697
- const reader = response.body.getReader();
698
- const decoder = new TextDecoder();
699
- let buffered = "";
700
- try {
701
- while (true) {
702
- const { done, value } = await reader.read();
703
- if (done)
704
- break;
705
- buffered += decoder.decode(value, { stream: true });
706
- let separatorIndex = buffered.indexOf("\n\n");
707
- while (separatorIndex !== -1) {
708
- const event = buffered.slice(0, separatorIndex);
709
- buffered = buffered.slice(separatorIndex + 2);
710
- const output = parseProcessOutputEvent(event);
711
- if (output)
712
- process.stdout.write(output);
713
- separatorIndex = buffered.indexOf("\n\n");
714
- }
715
- }
716
- } finally {
717
- reader.releaseLock();
718
- }
719
- }
720
- function normalizePtyInput(input) {
721
- if (typeof input === "string") {
722
- return { dataBase64: Buffer.from(input, "utf-8").toString("base64") };
723
- }
724
- if (input instanceof Uint8Array) {
725
- return { dataBase64: Buffer.from(input).toString("base64") };
726
- }
727
- return input;
728
- }
729
- function parseProcessOutputEvent(event) {
730
- if (!event.includes("event: output")) {
731
- return null;
732
- }
733
- const dataLines = event.split(/\r?\n/).filter((line) => line.startsWith("data: ")).map((line) => line.slice("data: ".length));
734
- if (dataLines.length === 0) {
735
- return null;
736
- }
737
- try {
738
- const parsed = JSON.parse(dataLines.join("\n"));
739
- return typeof parsed.output === "string" ? parsed.output : null;
740
- } catch {
741
- return null;
742
- }
743
- }
744
-
745
- // ../../packages/cloud/dist/sandbox/sandbox-instance-client.js
746
- var OpenPondSandboxInstanceClient = class {
747
- apiKey;
748
- apiRootUrl;
749
- sandboxApiUrl;
750
- constructor(options) {
751
- this.apiKey = options.apiKey;
752
- this.sandboxApiUrl = normalizeSandboxApiUrl(options.sandboxApiUrl ?? options.baseUrl ?? DEFAULT_OPENPOND_API_BASE_URL);
753
- this.apiRootUrl = apiRootUrlFromSandboxApiUrl(this.sandboxApiUrl);
754
- }
755
- create(input, options = {}) {
756
- return this.request("", {
757
- method: "POST",
758
- headers: asyncRequestHeaders(options),
759
- body: JSON.stringify(input)
760
- }).then((payload) => payload.sandbox);
761
- }
762
- get(sandboxId) {
763
- return this.request(`/${encodeURIComponent(sandboxId)}`).then((payload) => payload.sandbox);
764
- }
765
- exec(sandboxId, input) {
766
- return this.request(`/${encodeURIComponent(sandboxId)}/exec`, {
767
- method: "POST",
768
- body: JSON.stringify(input)
769
- });
770
- }
771
- startProcess(sandboxId, input) {
772
- return this.request(`/${encodeURIComponent(sandboxId)}/processes`, {
773
- method: "POST",
774
- body: JSON.stringify(input)
775
- });
776
- }
777
- listProcesses(sandboxId) {
778
- return this.request(`/${encodeURIComponent(sandboxId)}/processes`);
779
- }
780
- getProcess(sandboxId, processId, input = {}) {
781
- const query = new URLSearchParams();
782
- if (input.since !== void 0)
783
- query.set("since", String(Math.max(0, input.since)));
784
- return this.request(`/${encodeURIComponent(sandboxId)}/processes/${encodeURIComponent(processId)}${query.size > 0 ? `?${query.toString()}` : ""}`);
785
- }
786
- stopProcess(sandboxId, processId) {
787
- return this.request(`/${encodeURIComponent(sandboxId)}/processes/${encodeURIComponent(processId)}`, {
788
- method: "DELETE"
789
- });
790
- }
791
- async streamProcessOutput(sandboxId, processId, input = {}) {
792
- const query = new URLSearchParams();
793
- if (input.since !== void 0)
794
- query.set("since", String(Math.max(0, input.since)));
795
- await streamSandboxEventOutput({
796
- sandboxApiUrl: this.sandboxApiUrl,
797
- apiKey: this.apiKey,
798
- path: `/${encodeURIComponent(sandboxId)}/processes/${encodeURIComponent(processId)}/stream${query.size > 0 ? `?${query.toString()}` : ""}`
799
- });
800
- }
801
- startPty(sandboxId, input = {}) {
802
- return this.request(`/${encodeURIComponent(sandboxId)}/pty`, {
803
- method: "POST",
804
- body: JSON.stringify(input)
805
- });
806
- }
807
- listPtys(sandboxId) {
808
- return this.request(`/${encodeURIComponent(sandboxId)}/pty`);
809
- }
810
- getPty(sandboxId, ptyId, input = {}) {
811
- const query = new URLSearchParams();
812
- if (input.since !== void 0)
813
- query.set("since", String(Math.max(0, input.since)));
814
- return this.request(`/${encodeURIComponent(sandboxId)}/pty/${encodeURIComponent(ptyId)}${query.size > 0 ? `?${query.toString()}` : ""}`);
815
- }
816
- writePtyInput(sandboxId, ptyId, input) {
817
- return this.request(`/${encodeURIComponent(sandboxId)}/pty/${encodeURIComponent(ptyId)}/input`, {
818
- method: "POST",
819
- body: JSON.stringify(normalizePtyInput(input))
820
- });
821
- }
822
- stopPty(sandboxId, ptyId) {
823
- return this.request(`/${encodeURIComponent(sandboxId)}/pty/${encodeURIComponent(ptyId)}`, {
824
- method: "DELETE"
825
- });
826
- }
827
- async streamPtyOutput(sandboxId, ptyId, input = {}) {
828
- const query = new URLSearchParams();
829
- if (input.since !== void 0)
830
- query.set("since", String(Math.max(0, input.since)));
831
- await streamSandboxEventOutput({
832
- sandboxApiUrl: this.sandboxApiUrl,
833
- apiKey: this.apiKey,
834
- path: `/${encodeURIComponent(sandboxId)}/pty/${encodeURIComponent(ptyId)}/stream${query.size > 0 ? `?${query.toString()}` : ""}`
835
- });
836
- }
837
- uploadFile(sandboxId, path, contents) {
838
- return this.uploadFileBase64(sandboxId, path, Buffer.from(contents, "utf-8").toString("base64"));
839
- }
840
- uploadFileBase64(sandboxId, path, contentsBase64) {
841
- return this.request(`/${encodeURIComponent(sandboxId)}/files`, {
842
- method: "POST",
843
- body: JSON.stringify({
844
- path,
845
- contentsBase64
846
- })
847
- });
848
- }
849
- async downloadFile(sandboxId, path) {
850
- const payload = await this.downloadFileResponse(sandboxId, path);
851
- return Buffer.from(payload.file.contentsBase64, "base64").toString("utf-8");
852
- }
853
- downloadFileResponse(sandboxId, input) {
854
- const normalized = typeof input === "string" ? { path: input } : input;
855
- const query = new URLSearchParams({ path: normalized.path });
856
- if (normalized.offsetBytes !== void 0) {
857
- query.set("offsetBytes", String(normalized.offsetBytes));
858
- }
859
- if (normalized.maxBytes !== void 0) {
860
- query.set("maxBytes", String(normalized.maxBytes));
861
- }
862
- return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`);
863
- }
864
- listFiles(sandboxId, input = {}) {
865
- const query = new URLSearchParams({ list: "1" });
866
- if (input.path)
867
- query.set("path", input.path);
868
- if (input.recursive !== void 0)
869
- query.set("recursive", String(input.recursive));
870
- if (input.maxEntries !== void 0)
871
- query.set("maxEntries", String(input.maxEntries));
872
- return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`);
873
- }
874
- deleteFile(sandboxId, path, input = {}) {
875
- const query = new URLSearchParams({ path });
876
- if (input.recursive !== void 0)
877
- query.set("recursive", String(input.recursive));
878
- return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`, {
879
- method: "DELETE"
880
- });
881
- }
882
- statFile(sandboxId, path) {
883
- const query = new URLSearchParams({ stat: "1", path });
884
- return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`);
885
- }
886
- mkdir(sandboxId, input) {
887
- const normalized = typeof input === "string" ? { path: input } : input;
888
- const query = new URLSearchParams({ path: normalized.path });
889
- if (normalized.recursive !== void 0)
890
- query.set("recursive", String(normalized.recursive));
891
- return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`, {
892
- method: "PUT"
893
- });
894
- }
895
- moveFile(sandboxId, input) {
896
- const query = new URLSearchParams({
897
- fromPath: input.fromPath,
898
- toPath: input.toPath
899
- });
900
- if (input.overwrite !== void 0)
901
- query.set("overwrite", String(input.overwrite));
902
- return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`, {
903
- method: "PATCH"
904
- });
905
- }
906
- searchFiles(sandboxId, input) {
907
- const query = new URLSearchParams({
908
- search: "1",
909
- query: input.query
910
- });
911
- if (input.path)
912
- query.set("path", input.path);
913
- if (input.maxResults !== void 0)
914
- query.set("maxResults", String(input.maxResults));
915
- return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`);
916
- }
917
- openPort(sandboxId, input) {
918
- return this.request(`/${encodeURIComponent(sandboxId)}/ports`, {
919
- method: "POST",
920
- body: JSON.stringify(input)
921
- });
922
- }
923
- createSnapshot(sandboxId, input) {
924
- return this.request(`/${encodeURIComponent(sandboxId)}/snapshots`, {
925
- method: "POST",
926
- body: JSON.stringify(input)
927
- });
928
- }
929
- updateSnapshot(sandboxId, snapshotId, input) {
930
- return this.request(`/${encodeURIComponent(sandboxId)}/snapshots/${encodeURIComponent(snapshotId)}`, {
931
- method: "PATCH",
932
- body: JSON.stringify(input)
933
- });
934
- }
935
- validateSnapshot(sandboxId, snapshotId, input = {}) {
936
- return this.request(`/${encodeURIComponent(sandboxId)}/snapshots/${encodeURIComponent(snapshotId)}/validate`, {
937
- method: "POST",
938
- body: JSON.stringify(input)
939
- });
940
- }
941
- publishSnapshot(sandboxId, snapshotId) {
942
- return this.request(`/${encodeURIComponent(sandboxId)}/snapshots/${encodeURIComponent(snapshotId)}/publish`, {
943
- method: "POST"
944
- });
945
- }
946
- fork(sandboxId, input = {}) {
947
- return this.request(`/${encodeURIComponent(sandboxId)}/fork`, {
948
- method: "POST",
949
- body: JSON.stringify(input)
950
- });
951
- }
952
- stop(sandboxId, options = {}) {
953
- const query = new URLSearchParams();
954
- if (options.failOnUnpreservedChanges) {
955
- query.set("failOnUnpreservedChanges", "true");
956
- }
957
- return this.request(`/${encodeURIComponent(sandboxId)}/stop${query.size > 0 ? `?${query.toString()}` : ""}`, {
958
- method: "POST",
959
- headers: asyncRequestHeaders(options)
960
- });
961
- }
962
- start(sandboxId, options = {}) {
963
- return this.request(`/${encodeURIComponent(sandboxId)}/start`, {
964
- method: "POST",
965
- headers: asyncRequestHeaders(options)
966
- });
967
- }
968
- restore(sandboxId) {
969
- return this.request(`/${encodeURIComponent(sandboxId)}/restore`, {
970
- method: "POST"
971
- });
972
- }
973
- delete(sandboxId, options = {}) {
974
- const query = new URLSearchParams();
975
- if (options.failOnUnpreservedChanges) {
976
- query.set("failOnUnpreservedChanges", "true");
977
- }
978
- return this.request(`/${encodeURIComponent(sandboxId)}${query.size > 0 ? `?${query.toString()}` : ""}`, {
979
- method: "DELETE",
980
- headers: asyncRequestHeaders(options)
981
- }).then((payload) => payload.sandbox);
982
- }
983
- receipts(sandboxId) {
984
- return this.request(`/${encodeURIComponent(sandboxId)}/receipts`).then((payload) => payload.receipts);
985
- }
986
- logs(sandboxId) {
987
- return this.request(`/${encodeURIComponent(sandboxId)}/logs`).then((payload) => payload.logs);
988
- }
989
- gitStatus(sandboxId) {
990
- return this.request(`/${encodeURIComponent(sandboxId)}/git/status`);
991
- }
992
- gitDiff(sandboxId, input = {}) {
993
- return this.request(`/${encodeURIComponent(sandboxId)}/git/diff`, {
994
- method: "POST",
995
- body: JSON.stringify(input)
996
- });
997
- }
998
- gitExportPatch(sandboxId, input = {}) {
999
- return this.request(`/${encodeURIComponent(sandboxId)}/git/export-patch`, {
1000
- method: "POST",
1001
- body: JSON.stringify(input)
1002
- });
1003
- }
1004
- gitBranch(sandboxId, input) {
1005
- return this.request(`/${encodeURIComponent(sandboxId)}/git/branch`, {
1006
- method: "POST",
1007
- body: JSON.stringify(input)
1008
- });
1009
- }
1010
- gitCommit(sandboxId, input) {
1011
- return this.request(`/${encodeURIComponent(sandboxId)}/git/commit`, {
1012
- method: "POST",
1013
- body: JSON.stringify(input)
1014
- });
1015
- }
1016
- gitPull(sandboxId, input = {}) {
1017
- return this.request(`/${encodeURIComponent(sandboxId)}/git/pull`, {
1018
- method: "POST",
1019
- body: JSON.stringify(input)
1020
- });
1021
- }
1022
- gitPush(sandboxId, input = {}) {
1023
- return this.request(`/${encodeURIComponent(sandboxId)}/git/push`, {
1024
- method: "POST",
1025
- body: JSON.stringify(input)
1026
- });
1027
- }
1028
- billing(sandboxId) {
1029
- return this.request(`/${encodeURIComponent(sandboxId)}/billing`);
1030
- }
1031
- pricing() {
1032
- return this.request("/pricing");
1033
- }
1034
- costs(input = {}) {
1035
- const query = new URLSearchParams();
1036
- if (input.teamId)
1037
- query.set("teamId", input.teamId);
1038
- if (input.projectId)
1039
- query.set("projectId", input.projectId);
1040
- if (input.agentId)
1041
- query.set("agentId", input.agentId);
1042
- return this.request(`/costs${query.size > 0 ? `?${query.toString()}` : ""}`);
1043
- }
1044
- integrationLeases(sandboxId) {
1045
- return this.request(`/${encodeURIComponent(sandboxId)}/integrations`);
1046
- }
1047
- attachIntegrationConnection(sandboxId, input) {
1048
- return this.request(`/${encodeURIComponent(sandboxId)}/integrations`, {
1049
- method: "POST",
1050
- body: JSON.stringify(input)
1051
- });
1052
- }
1053
- removeIntegrationLease(sandboxId, leaseId) {
1054
- return this.request(`/${encodeURIComponent(sandboxId)}/integrations`, {
1055
- method: "DELETE",
1056
- body: JSON.stringify({ leaseId })
1057
- });
1058
- }
1059
- async request(path, init = {}) {
1060
- const response = await apiFetch(this.sandboxApiUrl, this.apiKey, path, init);
1061
- return readApiJson(response, "Sandbox request");
1062
- }
1063
- async requestApiRoot(path, init = {}) {
1064
- const response = await apiFetch(this.apiRootUrl, this.apiKey, path, init);
1065
- return readApiJson(response, "OpenPond API request");
1066
- }
1067
- };
1068
-
1069
- // ../../packages/cloud/dist/sandbox/client.js
1070
- var OpenPondSandboxClient = class extends OpenPondSandboxInstanceClient {
1071
- runtimes = createSandboxRuntimeNamespace(this);
1072
- sandboxes = createSandboxNamespace(this);
1073
- profile = createSandboxProfileNamespace(this);
1074
- projects = createSandboxProjectNamespace(this);
1075
- agents = createSandboxAgentNamespace(this);
1076
- list(input = {}) {
1077
- const query = new URLSearchParams();
1078
- if (input.teamId)
1079
- query.set("teamId", input.teamId);
1080
- if (input.projectId)
1081
- query.set("projectId", input.projectId);
1082
- if (input.agentId)
1083
- query.set("agentId", input.agentId);
1084
- return this.request(query.size > 0 ? `?${query.toString()}` : "").then((payload) => payload.sandboxes);
1085
- }
1086
- listSecrets(input = {}) {
1087
- const query = new URLSearchParams();
1088
- if (input.teamId)
1089
- query.set("teamId", input.teamId);
1090
- return this.requestApiRoot(`/sandbox-secrets${query.size > 0 ? `?${query.toString()}` : ""}`).then((payload) => payload.secrets);
1091
- }
1092
- getSecret(secretId, input = {}) {
1093
- const query = new URLSearchParams();
1094
- if (input.teamId)
1095
- query.set("teamId", input.teamId);
1096
- return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(secretId)}${query.size > 0 ? `?${query.toString()}` : ""}`).then((payload) => payload.secret);
1097
- }
1098
- createSecret(input) {
1099
- return this.requestApiRoot("/sandbox-secrets", {
1100
- method: "POST",
1101
- body: JSON.stringify(input)
1102
- }).then((payload) => payload.secret);
1103
- }
1104
- rotateSecret(secretId, input) {
1105
- const query = new URLSearchParams();
1106
- if (input.teamId)
1107
- query.set("teamId", input.teamId);
1108
- const { teamId: _teamId, ...body } = input;
1109
- return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(secretId)}/rotate${query.size > 0 ? `?${query.toString()}` : ""}`, {
1110
- method: "POST",
1111
- body: JSON.stringify(body)
1112
- }).then((payload) => payload.secret);
1113
- }
1114
- attachSecret(secretId, input) {
1115
- const query = new URLSearchParams();
1116
- if (input.teamId)
1117
- query.set("teamId", input.teamId);
1118
- const { teamId: _teamId, ...body } = input;
1119
- return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(secretId)}/attach${query.size > 0 ? `?${query.toString()}` : ""}`, {
1120
- method: "POST",
1121
- body: JSON.stringify(body)
1122
- }).then((payload) => payload.secret);
1123
- }
1124
- revokeSecret(secretId, input = {}) {
1125
- const query = new URLSearchParams();
1126
- if (input.teamId)
1127
- query.set("teamId", input.teamId);
1128
- return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(secretId)}/revoke${query.size > 0 ? `?${query.toString()}` : ""}`, { method: "POST" }).then((payload) => payload.secret);
1129
- }
1130
- deleteSecret(secretId, input = {}) {
1131
- const query = new URLSearchParams();
1132
- if (input.teamId)
1133
- query.set("teamId", input.teamId);
1134
- return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(secretId)}${query.size > 0 ? `?${query.toString()}` : ""}`, { method: "DELETE" }).then((payload) => payload.secret);
1135
- }
1136
- snapshotCatalog(input = {}) {
1137
- const query = new URLSearchParams();
1138
- if (input.teamId)
1139
- query.set("teamId", input.teamId);
1140
- if (input.projectId)
1141
- query.set("projectId", input.projectId);
1142
- if (input.agentId)
1143
- query.set("agentId", input.agentId);
1144
- if (input.q)
1145
- query.set("q", input.q);
1146
- if (input.kind)
1147
- query.set("kind", input.kind);
1148
- if (input.replayState)
1149
- query.set("replayState", input.replayState);
1150
- if (input.visibility)
1151
- query.set("visibility", input.visibility);
1152
- if (input.tag)
1153
- query.set("tag", input.tag);
1154
- if (input.useCase)
1155
- query.set("useCase", input.useCase);
1156
- if (input.limit)
1157
- query.set("limit", String(input.limit));
1158
- return this.request(`/catalog/snapshots${query.size > 0 ? `?${query.toString()}` : ""}`);
1159
- }
1160
- listSandboxRuntimes(input = {}) {
1161
- const query = new URLSearchParams();
1162
- if (input.teamId)
1163
- query.set("teamId", input.teamId);
1164
- if (input.projectId)
1165
- query.set("projectId", input.projectId);
1166
- if (input.agentId)
1167
- query.set("agentId", input.agentId);
1168
- return this.requestApiRoot(`/runtimes${query.size > 0 ? `?${query.toString()}` : ""}`).then((payload) => payload.runtimes);
1169
- }
1170
- listProjects(input) {
1171
- const query = new URLSearchParams({ teamId: input.teamId });
1172
- return this.requestApiRoot(`/projects?${query.toString()}`).then((payload) => payload.projects);
1173
- }
1174
- upsertProject(input) {
1175
- const query = new URLSearchParams({ teamId: input.teamId });
1176
- return this.requestApiRoot(`/projects?${query.toString()}`, {
1177
- method: "POST",
1178
- body: JSON.stringify(input)
1179
- }).then((payload) => payload.project);
1180
- }
1181
- getHostedProfile(input) {
1182
- const query = new URLSearchParams({ teamId: input.teamId });
1183
- return this.requestApiRoot(`/profile?${query.toString()}`).then((payload) => payload.profile);
1184
- }
1185
- ensureHostedProfile(input) {
1186
- const query = new URLSearchParams({ teamId: input.teamId });
1187
- return this.requestApiRoot(`/profile/ensure?${query.toString()}`, { method: "POST" }).then((payload) => {
1188
- if (!payload.profile) {
1189
- throw new Error("hosted_profile_missing");
1190
- }
1191
- return payload.profile;
1192
- });
1193
- }
1194
- pushHostedProfile(input) {
1195
- const query = new URLSearchParams({ teamId: input.teamId });
1196
- const { teamId: _teamId, ...body } = input;
1197
- return this.requestApiRoot(`/profile/push?${query.toString()}`, {
1198
- method: "POST",
1199
- body: JSON.stringify(body)
1200
- });
1201
- }
1202
- async upsertProjectGitRemote(input) {
1203
- const project = await this.upsertProject(input);
1204
- return this.ensureProjectGitRemote(project.id, { teamId: input.teamId });
1205
- }
1206
- getProject(projectId, input) {
1207
- const query = new URLSearchParams({ teamId: input.teamId });
1208
- return this.requestApiRoot(`/projects/${encodeURIComponent(projectId)}?${query.toString()}`).then((payload) => payload.project);
1209
- }
1210
- syncProject(projectId, input) {
1211
- const query = new URLSearchParams({ teamId: input.teamId });
1212
- return this.requestApiRoot(`/projects/${encodeURIComponent(projectId)}/sync?${query.toString()}`, { method: "POST" }).then((payload) => payload.project);
1213
- }
1214
- ensureProjectGitRemote(projectId, input) {
1215
- const query = new URLSearchParams({ teamId: input.teamId });
1216
- return this.requestApiRoot(`/projects/${encodeURIComponent(projectId)}/git?${query.toString()}`, { method: "POST" });
1217
- }
1218
- uploadProjectSource(projectId, input) {
1219
- const query = new URLSearchParams({ teamId: input.teamId });
1220
- const { teamId: _teamId, ...body } = input;
1221
- return this.requestApiRoot(`/projects/${encodeURIComponent(projectId)}/source?${query.toString()}`, {
1222
- method: "POST",
1223
- body: JSON.stringify(body)
1224
- }).then((payload) => payload.project);
1225
- }
1226
- updateProject(projectId, input) {
1227
- const query = new URLSearchParams({ teamId: input.teamId });
1228
- const { teamId: _teamId, ...body } = input;
1229
- return this.requestApiRoot(`/projects/${encodeURIComponent(projectId)}?${query.toString()}`, {
1230
- method: "PATCH",
1231
- body: JSON.stringify(body)
1232
- }).then((payload) => payload.project);
1233
- }
1234
- archiveProject(projectId, input) {
1235
- const query = new URLSearchParams({ teamId: input.teamId });
1236
- return this.requestApiRoot(`/projects/${encodeURIComponent(projectId)}?${query.toString()}`, { method: "DELETE" }).then((payload) => payload.project);
1237
- }
1238
- listAgents(input) {
1239
- const query = new URLSearchParams({ teamId: input.teamId });
1240
- return this.requestApiRoot(`/agents?${query.toString()}`).then((payload) => payload.agents);
1241
- }
1242
- upsertAgent(input) {
1243
- const query = new URLSearchParams({ teamId: input.teamId });
1244
- return this.requestApiRoot(`/agents?${query.toString()}`, {
1245
- method: "POST",
1246
- body: JSON.stringify(input)
1247
- }).then((payload) => payload.agent);
1248
- }
1249
- getAgent(agentId, input) {
1250
- const query = new URLSearchParams({ teamId: input.teamId });
1251
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}?${query.toString()}`).then((payload) => payload.agent);
1252
- }
1253
- archiveAgent(agentId, input) {
1254
- const query = new URLSearchParams({ teamId: input.teamId });
1255
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}?${query.toString()}`, { method: "DELETE" }).then((payload) => payload.agent);
1256
- }
1257
- updateAgent(agentId, input) {
1258
- const query = new URLSearchParams({ teamId: input.teamId });
1259
- const { teamId: _teamId, ...body } = input;
1260
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}?${query.toString()}`, {
1261
- method: "PATCH",
1262
- body: JSON.stringify(body)
1263
- }).then((payload) => payload.agent);
1264
- }
1265
- runAgent(agentId, input) {
1266
- const query = new URLSearchParams({ teamId: input.teamId });
1267
- const { teamId: _teamId, ...body } = input;
1268
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}/run?${query.toString()}`, {
1269
- method: "POST",
1270
- headers: {
1271
- Prefer: "respond-async"
1272
- },
1273
- body: JSON.stringify(body)
1274
- });
1275
- }
1276
- getAgentSourceDeployPlan(agentId, input) {
1277
- const query = new URLSearchParams({ teamId: input.teamId });
1278
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}/source/deploy-plan?${query.toString()}`).then((payload) => payload.deployPlan);
1279
- }
1280
- listAgentManifestSnapshots(agentId, input) {
1281
- const query = new URLSearchParams({ teamId: input.teamId });
1282
- if (input.limit !== void 0)
1283
- query.set("limit", String(input.limit));
1284
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}/source/manifest-snapshots?${query.toString()}`).then((payload) => payload.manifestSnapshots);
1285
- }
1286
- requestAgentSourceChecks(agentId, input) {
1287
- const query = new URLSearchParams({ teamId: input.teamId });
1288
- const { teamId: _teamId, ...body } = input;
1289
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}/source/checks?${query.toString()}`, {
1290
- method: "POST",
1291
- body: JSON.stringify(body),
1292
- timeoutMs: 15 * 60 * 1e3
1293
- });
1294
- }
1295
- configureAgentSourceSetup(agentId, input) {
1296
- const query = new URLSearchParams({ teamId: input.teamId });
1297
- const { teamId: _teamId, ...body } = input;
1298
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}/source/setup?${query.toString()}`, { method: "POST", body: JSON.stringify(body) });
1299
- }
1300
- publishAgentSource(agentId, input) {
1301
- const query = new URLSearchParams({ teamId: input.teamId });
1302
- const { teamId: _teamId, ...body } = input;
1303
- return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}/source/publish?${query.toString()}`, {
1304
- method: "POST",
1305
- body: JSON.stringify(body)
1306
- });
1307
- }
1308
- getMicrosoftTeamsBotOverview(input) {
1309
- const query = new URLSearchParams({ teamId: input.teamId });
1310
- return this.requestApiRoot(`/teams/bot/overview?${query.toString()}`);
1311
- }
1312
- bindMicrosoftTeamsBotConversation(input) {
1313
- return this.requestApiRoot("/teams/bot/bindings", {
1314
- method: "POST",
1315
- body: JSON.stringify(input)
1316
- });
1317
- }
1318
- rebindMicrosoftTeamsBotConversation(bindingId, input) {
1319
- return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(bindingId)}`, {
1320
- method: "PATCH",
1321
- body: JSON.stringify(input)
1322
- });
1323
- }
1324
- unlinkMicrosoftTeamsBotConversation(input) {
1325
- return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(input.bindingId)}`, {
1326
- method: "DELETE",
1327
- body: JSON.stringify({ teamId: input.teamId })
1328
- });
1329
- }
1330
- sendMicrosoftTeamsBotDiagnostic(input) {
1331
- return this.requestApiRoot("/teams/bot/diagnostics", {
1332
- method: "POST",
1333
- body: JSON.stringify(input)
1334
- });
1335
- }
1336
- sendMicrosoftTeamsBotDiagnosticRun(input) {
1337
- return this.requestApiRoot("/teams/bot/diagnostics/run", {
1338
- method: "POST",
1339
- body: JSON.stringify(input)
1340
- });
1341
- }
1342
- createSandboxRuntime(input) {
1343
- return this.requestApiRoot("/runtimes", {
1344
- method: "POST",
1345
- body: JSON.stringify(input)
1346
- }).then((payload) => payload.runtime);
1347
- }
1348
- sandboxRuntime(runtimeId, initial = null) {
1349
- return createSandboxRuntimeHandle(this, runtimeId, initial);
1350
- }
1351
- getSandboxRuntime(runtimeId) {
1352
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}`).then((payload) => payload.runtime);
1353
- }
1354
- createSandboxRuntimeSandbox(runtimeId, input = {}, options = {}) {
1355
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}/sandbox`, {
1356
- method: "POST",
1357
- headers: asyncRequestHeaders(options),
1358
- body: JSON.stringify(input)
1359
- });
1360
- }
1361
- updateSandboxRuntimeStatus(runtimeId, input) {
1362
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}/status`, {
1363
- method: "PATCH",
1364
- body: JSON.stringify(input)
1365
- }).then((payload) => payload.runtime);
1366
- }
1367
- listSandboxRuntimeEvents(runtimeId) {
1368
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}/events`);
1369
- }
1370
- emitSandboxRuntimeEvent(runtimeId, input) {
1371
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}/events`, {
1372
- method: "POST",
1373
- body: JSON.stringify(input)
1374
- });
1375
- }
1376
- checkpointSandboxRuntime(runtimeId, input) {
1377
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}/checkpoints`, {
1378
- method: "POST",
1379
- body: JSON.stringify(input)
1380
- }).then((payload) => payload.runtime);
1381
- }
1382
- promoteSandboxRuntime(runtimeId, input, options = {}) {
1383
- const query = new URLSearchParams();
1384
- if (options.teamId)
1385
- query.set("teamId", options.teamId);
1386
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}/promote${query.size > 0 ? `?${query.toString()}` : ""}`, {
1387
- method: "POST",
1388
- body: JSON.stringify(input)
1389
- });
1390
- }
1391
- preserveSandboxRuntimeSource(runtimeId, input = {}, options = {}) {
1392
- const query = new URLSearchParams();
1393
- if (options.teamId)
1394
- query.set("teamId", options.teamId);
1395
- return this.requestApiRoot(`/runtimes/${encodeURIComponent(runtimeId)}/preserve-source${query.size > 0 ? `?${query.toString()}` : ""}`, {
1396
- method: "POST",
1397
- body: JSON.stringify(input)
1398
- });
1399
- }
1400
- forkSnapshot(snapshotId, input = {}, options = {}) {
1401
- const query = new URLSearchParams();
1402
- if (input.teamId)
1403
- query.set("teamId", input.teamId);
1404
- if (input.projectId)
1405
- query.set("projectId", input.projectId);
1406
- if (options.async)
1407
- query.set("async", "1");
1408
- const { teamId: _teamId, projectId: _projectId, ...body } = input;
1409
- return this.request(`/catalog/snapshots/${encodeURIComponent(snapshotId)}/fork${query.size > 0 ? `?${query.toString()}` : ""}`, {
1410
- method: "POST",
1411
- headers: options.async ? { Prefer: "respond-async" } : void 0,
1412
- body: JSON.stringify({
1413
- ...body,
1414
- snapshotId
1415
- })
1416
- });
1417
- }
1418
- templates(input = {}) {
1419
- const query = new URLSearchParams();
1420
- if (input.teamId)
1421
- query.set("teamId", input.teamId);
1422
- if (input.projectId)
1423
- query.set("projectId", input.projectId);
1424
- if (input.q)
1425
- query.set("q", input.q);
1426
- if (input.name)
1427
- query.set("name", input.name);
1428
- if (input.version)
1429
- query.set("version", input.version);
1430
- if (input.visibility)
1431
- query.set("visibility", input.visibility);
1432
- if (input.tag)
1433
- query.set("tag", input.tag);
1434
- if (input.useCase)
1435
- query.set("useCase", input.useCase);
1436
- if (input.limit)
1437
- query.set("limit", String(input.limit));
1438
- return this.request(`/templates${query.size > 0 ? `?${query.toString()}` : ""}`);
1439
- }
1440
- publishedSnapshots(input = {}) {
1441
- const query = new URLSearchParams();
1442
- if (input.teamId)
1443
- query.set("teamId", input.teamId);
1444
- if (input.projectId)
1445
- query.set("projectId", input.projectId);
1446
- if (input.q)
1447
- query.set("q", input.q);
1448
- if (input.name)
1449
- query.set("name", input.name);
1450
- if (input.version)
1451
- query.set("version", input.version);
1452
- if (input.visibility)
1453
- query.set("visibility", input.visibility);
1454
- if (input.tag)
1455
- query.set("tag", input.tag);
1456
- if (input.useCase)
1457
- query.set("useCase", input.useCase);
1458
- if (input.limit)
1459
- query.set("limit", String(input.limit));
1460
- return this.request(`/published-snapshots${query.size > 0 ? `?${query.toString()}` : ""}`).then((payload) => {
1461
- const publishedSnapshots = payload.publishedSnapshots ?? payload.templates;
1462
- return {
1463
- ...payload,
1464
- templates: publishedSnapshots,
1465
- publishedSnapshots
1466
- };
1467
- });
1468
- }
1469
- launchTemplate(input) {
1470
- const query = new URLSearchParams();
1471
- if (input.teamId)
1472
- query.set("teamId", input.teamId);
1473
- if (input.projectId)
1474
- query.set("projectId", input.projectId);
1475
- const { teamId: _teamId, projectId: _projectId, ...body } = input;
1476
- return this.request(`/templates/launch${query.size > 0 ? `?${query.toString()}` : ""}`, {
1477
- method: "POST",
1478
- body: JSON.stringify(body)
1479
- });
1480
- }
1481
- runPublishedSnapshot(input) {
1482
- const query = new URLSearchParams();
1483
- if (input.teamId)
1484
- query.set("teamId", input.teamId);
1485
- if (input.projectId)
1486
- query.set("projectId", input.projectId);
1487
- const { teamId: _teamId, projectId: _projectId, ...body } = input;
1488
- return this.request(`/published-snapshots/launch${query.size > 0 ? `?${query.toString()}` : ""}`, {
1489
- method: "POST",
1490
- body: JSON.stringify(body)
1491
- }).then((payload) => {
1492
- const publishedSnapshot = payload.publishedSnapshot ?? payload.template;
1493
- return {
1494
- ...payload,
1495
- template: publishedSnapshot,
1496
- publishedSnapshot
1497
- };
1498
- });
1499
- }
1500
- listSchedules(input = {}) {
1501
- const query = new URLSearchParams();
1502
- if (input.teamId)
1503
- query.set("teamId", input.teamId);
1504
- if (input.projectId)
1505
- query.set("projectId", input.projectId);
1506
- if (input.sourceSandboxId)
1507
- query.set("sourceSandboxId", input.sourceSandboxId);
1508
- return this.request(`/schedules${query.size > 0 ? `?${query.toString()}` : ""}`);
1509
- }
1510
- createSchedule(input) {
1511
- const query = new URLSearchParams();
1512
- if (input.projectId)
1513
- query.set("projectId", input.projectId);
1514
- const { projectId: _projectId, ...body } = input;
1515
- return this.request(`/schedules${query.size > 0 ? `?${query.toString()}` : ""}`, {
1516
- method: "POST",
1517
- body: JSON.stringify(body)
1518
- });
1519
- }
1520
- getSchedule(scheduleId) {
1521
- return this.request(`/schedules/${encodeURIComponent(scheduleId)}`);
1522
- }
1523
- updateSchedule(scheduleId, input) {
1524
- return this.request(`/schedules/${encodeURIComponent(scheduleId)}`, {
1525
- method: "PATCH",
1526
- body: JSON.stringify(input)
1527
- });
1528
- }
1529
- deleteSchedule(scheduleId) {
1530
- return this.request(`/schedules/${encodeURIComponent(scheduleId)}`, {
1531
- method: "DELETE"
1532
- });
1533
- }
1534
- listScheduleRuns(scheduleId, input = {}) {
1535
- const query = new URLSearchParams();
1536
- if (input.limit !== void 0)
1537
- query.set("limit", String(input.limit));
1538
- return this.request(`/schedules/${encodeURIComponent(scheduleId)}/runs${query.size > 0 ? `?${query.toString()}` : ""}`);
1539
- }
1540
- runScheduleNow(scheduleId, input = {}) {
1541
- return this.request(`/schedules/${encodeURIComponent(scheduleId)}/run`, {
1542
- method: "POST",
1543
- body: JSON.stringify(input)
1544
- });
1545
- }
1546
- listTemplateBuilds(input) {
1547
- const query = new URLSearchParams({ teamId: input.teamId });
1548
- return this.requestApiRoot(`/sandbox-template-builds?${query.toString()}`).then((payload) => payload.builds);
1549
- }
1550
- createTemplateBuild(input) {
1551
- return this.requestApiRoot("/sandbox-template-builds", {
1552
- method: "POST",
1553
- body: JSON.stringify(input)
1554
- }).then((payload) => payload.build);
1555
- }
1556
- getTemplateBuild(buildId) {
1557
- return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(buildId)}`).then((payload) => payload.build);
1558
- }
1559
- getTemplateBuildLogs(buildId) {
1560
- return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(buildId)}/logs`);
1561
- }
1562
- cancelTemplateBuild(buildId) {
1563
- return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(buildId)}/cancel`, {
1564
- method: "POST"
1565
- }).then((payload) => payload.build);
1566
- }
1567
- listPublishedSnapshotBuilds(input) {
1568
- const query = new URLSearchParams({ teamId: input.teamId });
1569
- return this.requestApiRoot(`/published-snapshot-builds?${query.toString()}`).then((payload) => payload.builds);
1570
- }
1571
- createPublishedSnapshotBuild(input) {
1572
- return this.requestApiRoot("/published-snapshot-builds", {
1573
- method: "POST",
1574
- body: JSON.stringify(input)
1575
- }).then((payload) => payload.build);
1576
- }
1577
- getPublishedSnapshotBuild(buildId) {
1578
- return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(buildId)}`).then((payload) => payload.build);
1579
- }
1580
- getPublishedSnapshotBuildLogs(buildId) {
1581
- return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(buildId)}/logs`);
1582
- }
1583
- cancelPublishedSnapshotBuild(buildId) {
1584
- return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(buildId)}/cancel`, {
1585
- method: "POST"
1586
- }).then((payload) => payload.build);
1587
- }
1588
- listOrganizations() {
1589
- return this.requestApiRoot("/organizations").then((payload) => payload.organizations ?? payload.teams ?? []);
1590
- }
1591
- createOrganization(input) {
1592
- return this.requestApiRoot("/organizations", {
1593
- method: "POST",
1594
- body: JSON.stringify(input)
1595
- }).then((payload) => payload.organization);
1596
- }
1597
- getOrganization(slug) {
1598
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}`).then((payload) => payload.organization);
1599
- }
1600
- updateOrganization(slug, input) {
1601
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}`, {
1602
- method: "PATCH",
1603
- body: JSON.stringify(input)
1604
- }).then((payload) => payload.organization);
1605
- }
1606
- listOrganizationMembers(slug) {
1607
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}/members`).then((payload) => payload.members);
1608
- }
1609
- upsertOrganizationMember(slug, input) {
1610
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}/members`, {
1611
- method: "POST",
1612
- body: JSON.stringify(input)
1613
- }).then((payload) => payload.member);
1614
- }
1615
- getOrganizationMcpServer(slug) {
1616
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}/mcp-server`).then((payload) => payload.mcpServer);
1617
- }
1618
- generateOrganizationMcpServer(slug, input = {}) {
1619
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}/mcp-server`, {
1620
- method: "POST",
1621
- body: JSON.stringify(input)
1622
- }).then((payload) => payload.mcpServer);
1623
- }
1624
- rotateOrganizationMcpServer(slug) {
1625
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}/mcp-server/rotate`, {
1626
- method: "POST"
1627
- }).then((payload) => payload.mcpServer);
1628
- }
1629
- disableOrganizationMcpServer(slug) {
1630
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}/mcp-server/disable`, {
1631
- method: "POST"
1632
- }).then((payload) => payload.mcpServer);
1633
- }
1634
- enableOrganizationMcpServer(slug) {
1635
- return this.requestApiRoot(`/organizations/${encodeURIComponent(slug)}/mcp-server/enable`, {
1636
- method: "POST"
1637
- }).then((payload) => payload.mcpServer);
1638
- }
1639
- startReplay(input) {
1640
- const query = new URLSearchParams();
1641
- if (input.teamId)
1642
- query.set("teamId", input.teamId);
1643
- if (input.projectId)
1644
- query.set("projectId", input.projectId);
1645
- const { teamId: _teamId, projectId: _projectId, ...body } = input;
1646
- return this.requestApiRoot(`/sandbox-replays${query.size > 0 ? `?${query.toString()}` : ""}`, {
1647
- method: "POST",
1648
- body: JSON.stringify(body)
1649
- });
1650
- }
1651
- listReplays(input = {}) {
1652
- const query = new URLSearchParams();
1653
- if (input.teamId)
1654
- query.set("teamId", input.teamId);
1655
- if (input.projectId)
1656
- query.set("projectId", input.projectId);
1657
- return this.requestApiRoot(`/sandbox-replays${query.size > 0 ? `?${query.toString()}` : ""}`);
1658
- }
1659
- getReplay(replayId, input = {}) {
1660
- const query = new URLSearchParams();
1661
- if (input.teamId)
1662
- query.set("teamId", input.teamId);
1663
- if (input.projectId)
1664
- query.set("projectId", input.projectId);
1665
- return this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(replayId)}${query.size > 0 ? `?${query.toString()}` : ""}`);
1666
- }
1667
- getReplayLogs(replayId, input = {}) {
1668
- const query = new URLSearchParams();
1669
- if (input.teamId)
1670
- query.set("teamId", input.teamId);
1671
- if (input.projectId)
1672
- query.set("projectId", input.projectId);
1673
- return this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(replayId)}/logs${query.size > 0 ? `?${query.toString()}` : ""}`);
1674
- }
1675
- getReplayArtifacts(replayId, input = {}) {
1676
- const query = new URLSearchParams();
1677
- if (input.teamId)
1678
- query.set("teamId", input.teamId);
1679
- if (input.projectId)
1680
- query.set("projectId", input.projectId);
1681
- return this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(replayId)}/artifacts${query.size > 0 ? `?${query.toString()}` : ""}`);
1682
- }
1683
- cancelReplay(replayId, input = {}) {
1684
- const query = new URLSearchParams();
1685
- if (input.teamId)
1686
- query.set("teamId", input.teamId);
1687
- if (input.projectId)
1688
- query.set("projectId", input.projectId);
1689
- return this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(replayId)}/cancel${query.size > 0 ? `?${query.toString()}` : ""}`, {
1690
- method: "POST"
1691
- });
1692
- }
1693
- integrationConnections(input = {}) {
1694
- const query = new URLSearchParams();
1695
- if (input.teamId)
1696
- query.set("teamId", input.teamId);
1697
- if (input.projectId)
1698
- query.set("projectId", input.projectId);
1699
- if (input.agentId)
1700
- query.set("agentId", input.agentId);
1701
- if (input.status)
1702
- query.set("status", input.status);
1703
- return this.requestApiRoot(`/integrations/connections${query.size > 0 ? `?${query.toString()}` : ""}`);
1704
- }
1705
- mcpServerConfig() {
1706
- return {
1707
- name: "openpond-sandboxes",
1708
- transport: "streamable-http",
1709
- url: `${this.sandboxApiUrl}/mcp`,
1710
- headers: {
1711
- "openpond-api-key": this.apiKey
1712
- }
1713
- };
1714
- }
1715
- smoke(options = {}) {
1716
- return runSandboxSmoke(this, options);
1717
- }
1718
- };
1719
- function createOpenPondSandboxClient(options) {
1720
- return new OpenPondSandboxClient(options);
1721
- }
1722
-
1723
- // ../../packages/cloud/dist/hosted-chat.js
1724
- import { randomUUID } from "node:crypto";
1725
- function normalizeApiBaseUrl(value) {
1726
- const trimmed = normalizeOptionalOpChatApiBaseUrl(value);
1727
- if (!trimmed)
1728
- throw new Error("apiBaseUrl is required");
1729
- return trimmed;
1730
- }
1731
- function trimTrailingSlashes(value) {
1732
- return value.replace(/\/+$/, "");
1733
- }
1734
- function normalizeOptionalOpChatApiBaseUrl(value) {
1735
- let trimmed = trimTrailingSlashes(value?.trim() ?? "");
1736
- if (!trimmed)
1737
- return null;
1738
- trimmed = trimmed.replace(/\/chat\/completions$/i, "").replace(/\/models(?:\/[^/]+)?$/i, "");
1739
- if (trimmed.endsWith("/opchat/v1"))
1740
- return trimmed;
1741
- if (trimmed.endsWith("/opchat"))
1742
- return `${trimmed}/v1`;
1743
- if (trimmed.endsWith("/v1")) {
1744
- trimmed = trimmed.slice(0, -"/v1".length);
1745
- }
1746
- return `${trimTrailingSlashes(trimmed)}/opchat/v1`;
1747
- }
1748
- function resolveOpChatApiBaseUrl(options = {}) {
1749
- const runtimeEnv = options.env ?? (typeof process !== "undefined" ? process.env : {});
1750
- const explicit = normalizeOptionalOpChatApiBaseUrl(options.opChatApiBaseUrl) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_OPCHAT_API_URL);
1751
- if (explicit)
1752
- return explicit;
1753
- const migrationInput = normalizeOptionalOpChatApiBaseUrl(options.chatApiBaseUrl) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_CHAT_API_URL) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_GATEWAY_URL);
1754
- if (migrationInput)
1755
- return migrationInput;
1756
- const apiBase = normalizeOptionalOpChatApiBaseUrl(options.apiBaseUrl) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_API_URL);
1757
- return apiBase ?? DEFAULT_OPENPOND_OPCHAT_API_BASE_URL;
1758
- }
1759
- function requireToken(value) {
1760
- const trimmed = value.trim();
1761
- if (!trimmed)
1762
- throw new Error("OpenPond API key is required");
1763
- return trimmed;
1764
- }
1765
- function hostedHeaders(token, accept, requestId) {
1766
- const headers = new Headers();
1767
- headers.set("Authorization", `Bearer ${requireToken(token)}`);
1768
- headers.set("Content-Type", "application/json");
1769
- headers.set("Accept", accept);
1770
- headers.set("x-openpond-client", "openpond-code");
1771
- headers.set("x-openpond-request-id", requestId || randomUUID());
1772
- return headers;
1773
- }
1774
- async function readError(response) {
1775
- const text = await response.text().catch(() => "");
1776
- if (!text)
1777
- return response.statusText || `HTTP ${response.status}`;
1778
- try {
1779
- const payload = JSON.parse(text);
1780
- const error = typeof payload.error === "string" ? payload.error : payload.error && typeof payload.error === "object" && !Array.isArray(payload.error) ? payload.error : null;
1781
- const code = typeof payload.code === "string" ? payload.code : error && typeof error !== "string" && typeof error.code === "string" ? error.code : null;
1782
- const message = typeof payload.message === "string" ? payload.message : error && typeof error !== "string" && typeof error.message === "string" ? error.message : null;
1783
- const label = typeof error === "string" ? error : error && typeof error.type === "string" ? error.type : null;
1784
- return [code, label, message].filter(Boolean).join(": ") || text;
1785
- } catch {
1786
- return text;
1787
- }
1788
- }
1789
- function buildHostedChatBody(options, stream) {
1790
- const body = {
1791
- model: options.model,
1792
- messages: options.messages,
1793
- stream
1794
- };
1795
- if (typeof options.temperature === "number") {
1796
- body.temperature = options.temperature;
1797
- }
1798
- if (typeof options.maxTokens === "number") {
1799
- body.max_tokens = options.maxTokens;
1800
- }
1801
- if (options.tools) {
1802
- body.tools = options.tools;
1803
- }
1804
- const toolChoice = options.toolChoice ?? options.tool_choice;
1805
- if (toolChoice !== void 0) {
1806
- body.tool_choice = toolChoice;
1807
- }
1808
- if (options.metadata) {
1809
- body.metadata = options.metadata;
1810
- }
1811
- return body;
1812
- }
1813
- async function sendHostedChatTurn(options) {
1814
- const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
1815
- const requestUrl = `${apiBaseUrl}/chat/completions`;
1816
- const response = await fetch(requestUrl, {
1817
- method: "POST",
1818
- headers: hostedHeaders(options.token, "application/json", options.requestId),
1819
- body: JSON.stringify(buildHostedChatBody(options, false)),
1820
- signal: options.signal
1821
- });
1822
- if (!response.ok) {
1823
- throw new Error(`Hosted chat failed: ${response.status} ${await readError(response)}`);
1824
- }
1825
- return await response.json();
1826
- }
1827
-
1828
- export {
1829
- OpenPondApiError,
1830
- apiFetch,
1831
- readApiJson,
1832
- DEFAULT_OPENPOND_WEB_BASE_URL,
1833
- DEFAULT_OPENPOND_API_BASE_URL,
1834
- normalizeSandboxApiUrl,
1835
- createOpenPondSandboxClient,
1836
- resolveOpChatApiBaseUrl,
1837
- sendHostedChatTurn
1838
- };