openpond 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/dist/chunks/actions-command-F55CBR2K.js +2 -0
  2. package/dist/chunks/app-layer-GNYLOBCX.js +3 -0
  3. package/dist/chunks/app-server-runtime-VAGY4LQS.js +2 -0
  4. package/dist/chunks/apps-HZ5JGBDR.js +2 -0
  5. package/dist/chunks/chunk-22UARBPW.js +3 -0
  6. package/dist/chunks/chunk-3A7HZJNE.js +1 -0
  7. package/dist/chunks/chunk-3M53YXEI.js +2 -0
  8. package/dist/chunks/chunk-3NDRIQTI.js +2 -0
  9. package/dist/chunks/chunk-6FA3GG5B.js +33 -0
  10. package/dist/chunks/chunk-6MI4KKWF.js +2 -0
  11. package/dist/chunks/chunk-7D2LMRP7.js +2 -0
  12. package/dist/chunks/chunk-A42DFLOR.js +16 -0
  13. package/dist/chunks/chunk-AF57BF75.js +24 -0
  14. package/dist/chunks/chunk-BX4J2VDU.js +2 -0
  15. package/dist/chunks/chunk-BZMVB3GS.js +2 -0
  16. package/dist/chunks/chunk-CCJG7GLE.js +5 -0
  17. package/dist/chunks/chunk-CWQWV2T3.js +2 -0
  18. package/dist/chunks/chunk-DUA3QP6Y.js +19 -0
  19. package/dist/chunks/chunk-EAPFMACH.js +10 -0
  20. package/dist/chunks/chunk-EG3XB6M6.js +5 -0
  21. package/dist/chunks/chunk-ES2ISFJC.js +66 -0
  22. package/dist/chunks/chunk-FTQLQJQV.js +2 -0
  23. package/dist/chunks/chunk-FYCJSUFV.js +53 -0
  24. package/dist/chunks/chunk-GEANXBLX.js +2 -0
  25. package/dist/chunks/chunk-GLUWATL5.js +2 -0
  26. package/dist/chunks/chunk-GPZYIVFV.js +2199 -0
  27. package/dist/chunks/chunk-H7IWJN7L.js +17 -0
  28. package/dist/chunks/chunk-HZP5U2AA.js +3 -0
  29. package/dist/chunks/chunk-I5K74TOH.js +3 -0
  30. package/dist/chunks/chunk-I7G35U7K.js +2 -0
  31. package/dist/chunks/chunk-IR3YJWPW.js +7 -0
  32. package/dist/chunks/chunk-J7WZSLHS.js +18 -0
  33. package/dist/chunks/chunk-K35OOAW2.js +6 -0
  34. package/dist/chunks/chunk-KDXLNQNF.js +12 -0
  35. package/dist/chunks/chunk-KJYNLFWD.js +2872 -0
  36. package/dist/chunks/chunk-KV2IXO2T.js +6 -0
  37. package/dist/chunks/chunk-NVGMZ2IN.js +2 -0
  38. package/dist/chunks/chunk-OGPHXXCD.js +1 -0
  39. package/dist/chunks/chunk-RAKJWIYO.js +36 -0
  40. package/dist/chunks/chunk-RWSAGQTP.js +2 -0
  41. package/dist/chunks/chunk-SDO4FC4Q.js +2 -0
  42. package/dist/chunks/chunk-T5XCPX4P.js +3 -0
  43. package/dist/chunks/chunk-VYUMTRB3.js +5 -0
  44. package/dist/chunks/chunk-X37KMV27.js +1 -0
  45. package/dist/chunks/chunk-XAYIETBO.js +28 -0
  46. package/dist/chunks/chunk-XEOEKFG6.js +71 -0
  47. package/dist/chunks/chunk-ZVOO7FKM.js +2 -0
  48. package/dist/chunks/cli-UYTSZB4Y.js +2 -0
  49. package/dist/chunks/configuration-command-HAPIYG25.js +2 -0
  50. package/dist/chunks/continual-D75WA7E7.js +7 -0
  51. package/dist/chunks/core-commands-N37UZEVE.js +2 -0
  52. package/dist/chunks/database-X2CUV732.js +2 -0
  53. package/dist/chunks/desktop-test-V7FBEG7U.js +3 -0
  54. package/dist/chunks/dist-NKLXFA37.js +2 -0
  55. package/dist/chunks/extension-NEPOQ44P.js +5 -0
  56. package/dist/chunks/help-HC4N5ZQC.js +8 -0
  57. package/dist/chunks/module-ES6BEMUI-ZVL3F6NW.js +2 -0
  58. package/dist/chunks/module-asyncify-2EFITU5U-R7TVXNAE.js +2 -0
  59. package/dist/chunks/opchat-C7XRN4ZW.js +3 -0
  60. package/dist/chunks/organizations-LQGRZJ2V.js +2 -0
  61. package/dist/chunks/profile-UWM24A7R.js +3 -0
  62. package/dist/chunks/project-agent-2ME52ZJW.js +2 -0
  63. package/dist/chunks/sandbox-command-53L3ZICT.js +2 -0
  64. package/dist/chunks/sandbox-template-55HUM5H7.js +10 -0
  65. package/dist/chunks/src-EYJF2LWV.js +319 -0
  66. package/dist/chunks/src-VGW2UEMV.js +82 -0
  67. package/dist/chunks/taskset-PISBOILQ.js +2 -0
  68. package/dist/chunks/teams-bot-FHD2HCHN.js +3 -0
  69. package/dist/chunks/training-2NDOWH5S.js +2 -0
  70. package/dist/chunks/workspaces-CQFVCR7T.js +2 -0
  71. package/dist/cli.js +3 -109
  72. package/dist/index.js +1 -31230
  73. package/dist/sandbox-template/manifest.js +1 -18380
  74. package/dist/web/assets/App-BoJQRfeu.js +176 -0
  75. package/dist/web/assets/AppDialog-rdfmJsGF.js +1 -0
  76. package/dist/web/assets/AppTerminalPanel-CLW0kxtg.js +2 -0
  77. package/dist/web/assets/{AppsView-B1NUuAIf.js → AppsView-DxMXadnp.js} +1 -1
  78. package/dist/web/assets/{BrowserSidebar-DOvYxXeP.js → BrowserSidebar-BH_jl0JS.js} +1 -1
  79. package/dist/web/assets/{CartesianChart-pOrYpzBr.js → CartesianChart-oT_rMYpf.js} +1 -1
  80. package/dist/web/assets/{CollaborationTabs-CgbR-MBJ.js → CollaborationTabs-CukgFGE0.js} +1 -1
  81. package/dist/web/assets/{CommandMenu-CrIr4qUX.js → CommandMenu-2btBTgOF.js} +1 -1
  82. package/dist/web/assets/{CommunityView-CvAVQ_HZ.js → CommunityView-DMTREmN5.js} +1 -1
  83. package/dist/web/assets/{ComposerCreateImproveStrip-DybcKwwd.js → ComposerCreateImproveStrip-3tN55cg9.js} +1 -1
  84. package/dist/web/assets/GetStartedView-CMHL24_w.js +1 -0
  85. package/dist/web/assets/HostedModelLearningReview-CqkSelkC.js +1 -0
  86. package/dist/web/assets/HostedModelLearningSettings-xqd2lSW3.js +1 -0
  87. package/dist/web/assets/LabModelVersionDetailPage-Bpnya5DM.js +1 -0
  88. package/dist/web/assets/{LabSkillSidebar-CuaYrtiu.js → LabSkillSidebar-BKZjScr8.js} +1 -1
  89. package/dist/web/assets/LabsRoute-BhPFmA_Z.js +32 -0
  90. package/dist/web/assets/LabsRoute-C1FWCoYb.css +1 -0
  91. package/dist/web/assets/MainChatThread-Bosxokt-.js +2 -0
  92. package/dist/web/assets/MainPane-Di-Rwe7x.js +8 -0
  93. package/dist/web/assets/{MarkdownText-DOlVQR8a.js → MarkdownText-dK4SBPp_.js} +1 -1
  94. package/dist/web/assets/{Messages-DMubppta.js → Messages-ftYRMKYa.js} +6 -6
  95. package/dist/web/assets/{NativeSkillSidebar-DSFwZ-od.js → NativeSkillSidebar-Cwo7JdB2.js} +1 -1
  96. package/dist/web/assets/{NewExperienceSwitcher-Dj0ePIJ-.js → NewExperienceSwitcher-C1_JzTq2.js} +1 -1
  97. package/dist/web/assets/{NewProjectDialog-B8NQV-Ji.js → NewProjectDialog-CxP6v6YW.js} +1 -1
  98. package/dist/web/assets/{OutputsPage-D_LDYTgV.js → OutputsPage-DL21_Alp.js} +1 -1
  99. package/dist/web/assets/{ProjectsPage-xjDYPc_W.js → ProjectsPage-BO9VyvMA.js} +1 -1
  100. package/dist/web/assets/RightChatPanelStack-DaqAnzdR.js +1 -0
  101. package/dist/web/assets/{RightSidebarHomePanel-j0VckZUu.js → RightSidebarHomePanel-PbUG12AO.js} +1 -1
  102. package/dist/web/assets/{ScheduledWorkPage-1aT4bBY-.js → ScheduledWorkPage-BhL-cXML.js} +1 -1
  103. package/dist/web/assets/{SettingsView-BSpuMDpv.js → SettingsView-D6-s7G88.js} +7 -7
  104. package/dist/web/assets/TeamChatView-DbS1N-fo.js +3 -0
  105. package/dist/web/assets/{TerminalOverlay-CrSwUk2d.js → TerminalOverlay-CphyBXJR.js} +3 -3
  106. package/dist/web/assets/{TrainingCreationPanel-B4HMRwUg.js → TrainingCreationPanel-Czsdraix.js} +1 -1
  107. package/dist/web/assets/{TrainingDraftPanel-D4r1tN3I.js → TrainingDraftPanel-Bq3B5pUk.js} +1 -1
  108. package/dist/web/assets/{UsageSettingsSection-2aymqwIM.js → UsageSettingsSection-B74FNwaP.js} +5 -5
  109. package/dist/web/assets/{WorkSidebarPanel-B0X0OiR6.js → WorkSidebarPanel-BgaK4XSg.js} +1 -1
  110. package/dist/web/assets/WorkspaceDiffPanel-C3seHnVY.js +14 -0
  111. package/dist/web/assets/{WorkspaceEnvironmentMenu-OAfMEt7L.js → WorkspaceEnvironmentMenu-DPghQUdv.js} +3 -3
  112. package/dist/web/assets/{WorkspaceGitDialogs-YxcPH2Rq.js → WorkspaceGitDialogs-D8c6Okb_.js} +1 -1
  113. package/dist/web/assets/{WorkspaceMonacoEditor-COKTiQZl.js → WorkspaceMonacoEditor-2kjRFf4l.js} +36 -36
  114. package/dist/web/assets/{arrow-up-right-_TX-awvK.js → arrow-up-right-C5X-29oa.js} +1 -1
  115. package/dist/web/assets/chat-file-links-Bmz9kVct.js +1 -0
  116. package/dist/web/assets/chevron-up-NbP9vY4E.js +1 -0
  117. package/dist/web/assets/{clipboard-CyRSS8Sy.js → clipboard-fvHMXPWa.js} +1 -1
  118. package/dist/web/assets/{cloud-upload-uBJBUYTy.js → cloud-upload-BAycsdHL.js} +1 -1
  119. package/dist/web/assets/{cssMode-BrXSsZYs.js → cssMode-Yis679a5.js} +1 -1
  120. package/dist/web/assets/{folder-open-DktdZNW7.js → folder-open-bii4KUCv.js} +1 -1
  121. package/dist/web/assets/{folder-plus-DO06i9Vo.js → folder-plus-B0B7mUCx.js} +1 -1
  122. package/dist/web/assets/{git-commit-horizontal-zFSIkPs7.js → git-commit-horizontal-B6yTdtnB.js} +1 -1
  123. package/dist/web/assets/{htmlMode-X9UMFkjt.js → htmlMode-DHeBSKVF.js} +1 -1
  124. package/dist/web/assets/{index-UOGdfLzi.js → index-667pXXsu.js} +1 -1
  125. package/dist/web/assets/{index-ByQIHpc9.css → index-BGMzUaup.css} +1 -1
  126. package/dist/web/assets/{info-BEJXUqCD.js → info-NCOESX3I.js} +1 -1
  127. package/dist/web/assets/{jsonMode-DIsB-j2E.js → jsonMode-C4oxy1cU.js} +1 -1
  128. package/dist/web/assets/{lspLanguageFeatures-CmZ17KpA.js → lspLanguageFeatures-CLj3WGZW.js} +1 -1
  129. package/dist/web/assets/{minimize-2-DumTpFtE.js → minimize-2-DtI1vgd7.js} +1 -1
  130. package/dist/web/assets/{monaco.contribution-D6w5PJji.js → monaco.contribution-DZPgekIQ.js} +2 -2
  131. package/dist/web/assets/{monaco.contribution-DJ_NmcHu.js → monaco.contribution-Ddw-TznO.js} +2 -2
  132. package/dist/web/assets/{monaco.contribution-YVDfJcG4.js → monaco.contribution-DhVPJ-oY.js} +2 -2
  133. package/dist/web/assets/{monaco.contribution-LZEujgny.js → monaco.contribution-DrW6DjWP.js} +2 -2
  134. package/dist/web/assets/{play-CLFeH7CU.js → play-DB3XFAnG.js} +1 -1
  135. package/dist/web/assets/{python-Djbda_qZ.js → python-DLyUeEeL.js} +1 -1
  136. package/dist/web/assets/{refresh-cw-B4IpQ_7Q.js → refresh-cw-0zSLZtfp.js} +1 -1
  137. package/dist/web/assets/{save-BbTHztnA.js → save-BCZlshOA.js} +1 -1
  138. package/dist/web/assets/{square-BJrVbmz6.js → square-CRytZWR_.js} +1 -1
  139. package/dist/web/assets/{toggleHighContrast-BopU5W9S.js → toggleHighContrast-TXg0rI_R.js} +1 -1
  140. package/dist/web/assets/{tsMode-CH_0_YDX.js → tsMode-Bj1019AY.js} +1 -1
  141. package/dist/web/assets/{upload-UumVeufu.js → upload-CnE9u7GB.js} +1 -1
  142. package/dist/web/assets/{useLocalAgentSchedules-BRa23U7O.js → useLocalAgentSchedules-qI87RHVI.js} +1 -1
  143. package/dist/web/assets/{wifi-off-BWJWivn6.js → wifi-off-CfuwRBx7.js} +1 -1
  144. package/dist/web/assets/{workers-pTe8RvSI.js → workers-CXdUI7wU.js} +1 -1
  145. package/dist/web/assets/{yaml-DNLASORn.js → yaml-AP8aiwLm.js} +1 -1
  146. package/dist/web/index.html +2 -2
  147. package/package.json +4 -3
  148. package/dist/chunks/actions-command-6N5XWMR6.js +0 -185
  149. package/dist/chunks/app-layer-F3CGXB33.js +0 -216
  150. package/dist/chunks/app-server-runtime-RHO5TFUC.js +0 -23
  151. package/dist/chunks/apps-L5XCL7QY.js +0 -429
  152. package/dist/chunks/chunk-26AMV5ZI.js +0 -634
  153. package/dist/chunks/chunk-3EB7I67T.js +0 -630
  154. package/dist/chunks/chunk-3ELF4FXY.js +0 -96
  155. package/dist/chunks/chunk-3VEYNDHN.js +0 -669
  156. package/dist/chunks/chunk-4KA25HUP.js +0 -5648
  157. package/dist/chunks/chunk-4L3ZJS2T.js +0 -1207
  158. package/dist/chunks/chunk-6SMNG6YA.js +0 -1303
  159. package/dist/chunks/chunk-7RIGZB7N.js +0 -1148
  160. package/dist/chunks/chunk-A6G3PFA5.js +0 -2164
  161. package/dist/chunks/chunk-BVY5JYM6.js +0 -512
  162. package/dist/chunks/chunk-DLQQIWN2.js +0 -648
  163. package/dist/chunks/chunk-FJ2JGB2N.js +0 -1373
  164. package/dist/chunks/chunk-FQS2QL5F.js +0 -14522
  165. package/dist/chunks/chunk-G65WAOJV.js +0 -1643
  166. package/dist/chunks/chunk-JTHL5XJ2.js +0 -1838
  167. package/dist/chunks/chunk-K4TZEHAW.js +0 -602
  168. package/dist/chunks/chunk-KCRCIQPD.js +0 -66
  169. package/dist/chunks/chunk-KSRWKXRB.js +0 -12
  170. package/dist/chunks/chunk-MUMPWI4O.js +0 -92
  171. package/dist/chunks/chunk-NTK22KJD.js +0 -10707
  172. package/dist/chunks/chunk-OCBRPU2K.js +0 -629
  173. package/dist/chunks/chunk-PS37DB5F.js +0 -183
  174. package/dist/chunks/chunk-R3C3MNSI.js +0 -140
  175. package/dist/chunks/chunk-SMNFI2FU.js +0 -113
  176. package/dist/chunks/chunk-UACZUFIA.js +0 -47
  177. package/dist/chunks/chunk-UZMVNKXM.js +0 -1275
  178. package/dist/chunks/chunk-VT6BLHMB.js +0 -67198
  179. package/dist/chunks/chunk-W5GKHH77.js +0 -168
  180. package/dist/chunks/chunk-X6F4LBTQ.js +0 -832
  181. package/dist/chunks/chunk-X7ZG4TSW.js +0 -3063
  182. package/dist/chunks/chunk-XA4KBDMY.js +0 -13723
  183. package/dist/chunks/chunk-YVCYVDNP.js +0 -746
  184. package/dist/chunks/chunk-ZNQEROWP.js +0 -254
  185. package/dist/chunks/cli-D2MUUBEX.js +0 -23
  186. package/dist/chunks/configuration-command-NR6JYIUD.js +0 -187
  187. package/dist/chunks/continual-37CE4LLJ.js +0 -803
  188. package/dist/chunks/core-commands-SWGIOZLW.js +0 -50
  189. package/dist/chunks/database-DEYUZDIM.js +0 -20
  190. package/dist/chunks/desktop-test-QOS7G5NE.js +0 -148
  191. package/dist/chunks/dist-AKYCQNNF.js +0 -187
  192. package/dist/chunks/extension-HJUJBQAD.js +0 -9378
  193. package/dist/chunks/help-J6PZ23IC.js +0 -67
  194. package/dist/chunks/opchat-ABX5YBAT.js +0 -169
  195. package/dist/chunks/organizations-CPNC47DO.js +0 -806
  196. package/dist/chunks/profile-Q3HB5MIO.js +0 -1136
  197. package/dist/chunks/project-agent-YHUBX4OR.js +0 -516
  198. package/dist/chunks/sandbox-command-YFL5QTWX.js +0 -1661
  199. package/dist/chunks/sandbox-template-Z6P7NTNF.js +0 -1655
  200. package/dist/chunks/src-7XEENEBI.js +0 -3628
  201. package/dist/chunks/src-KBBIV4NT.js +0 -56125
  202. package/dist/chunks/taskset-2TRZBRRT.js +0 -66
  203. package/dist/chunks/teams-bot-WD33NLH5.js +0 -146
  204. package/dist/chunks/training-4XH37UZB.js +0 -17
  205. package/dist/chunks/workspaces-WG2MH2WE.js +0 -99
  206. package/dist/web/assets/App-C9aGkxVg.js +0 -173
  207. package/dist/web/assets/AppDialog-CK6_lg8c.js +0 -1
  208. package/dist/web/assets/AppTerminalPanel-BKqgX4sd.js +0 -2
  209. package/dist/web/assets/GetStartedView-DVInkexN.js +0 -1
  210. package/dist/web/assets/LabModelVersionDetailPage-NaaPElmM.js +0 -1
  211. package/dist/web/assets/LabsRoute-BRR6x3SX.js +0 -2
  212. package/dist/web/assets/LabsRoute-CGFgymTX.css +0 -1
  213. package/dist/web/assets/MainChatThread-BfkjCZB9.js +0 -2
  214. package/dist/web/assets/MainPane-Gw-YK38n.js +0 -8
  215. package/dist/web/assets/RightChatPanelStack-BktRQ9wg.js +0 -1
  216. package/dist/web/assets/TeamChatView-BPWJbDf1.js +0 -3
  217. package/dist/web/assets/WorkspaceDiffPanel-Pg7GL0br.js +0 -14
  218. package/dist/web/assets/chat-file-links-CWLsRYvW.js +0 -1
  219. package/dist/web/assets/chevron-up--mNnEqha.js +0 -1
  220. package/dist/web/assets/index-BEPmTPIA.js +0 -1
@@ -1,1373 +0,0 @@
1
- import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import {
3
- DEFAULT_OPENPOND_API_BASE_URL,
4
- DEFAULT_OPENPOND_WEB_BASE_URL
5
- } from "./chunk-KSRWKXRB.js";
6
- import {
7
- initializeHome,
8
- readAccountConfiguration,
9
- readCache,
10
- updateAccountConfiguration,
11
- writeCache
12
- } from "./chunk-4KA25HUP.js";
13
- import {
14
- resolveOpenPondHome
15
- } from "./chunk-ZNQEROWP.js";
16
-
17
- // ../../packages/cloud/src/api/core.ts
18
- var DEFAULT_API_TIMEOUT_MS = 3e4;
19
- var DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;
20
- var LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1e3, maxResponseBytes: 64 * 1024 * 1024 };
21
- var ApiTimeoutError = class extends Error {
22
- constructor(timeoutMs, requestUrl) {
23
- super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);
24
- this.timeoutMs = timeoutMs;
25
- this.requestUrl = requestUrl;
26
- this.name = "ApiTimeoutError";
27
- }
28
- timeoutMs;
29
- requestUrl;
30
- code = "OPENPOND_API_TIMEOUT";
31
- };
32
- var ApiResponseTooLargeError = class extends Error {
33
- constructor(maximumBytes, requestUrl) {
34
- super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);
35
- this.maximumBytes = maximumBytes;
36
- this.requestUrl = requestUrl;
37
- this.name = "ApiResponseTooLargeError";
38
- }
39
- maximumBytes;
40
- requestUrl;
41
- code = "OPENPOND_API_RESPONSE_TOO_LARGE";
42
- };
43
- async function apiFetch(baseUrl, token, requestPath, options = {}) {
44
- const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;
45
- const requestUrl = `${baseUrl}${requestPath}`;
46
- const headers = new Headers(init.headers);
47
- headers.set("Content-Type", "application/json");
48
- const apiKey = process.env.OPENPOND_API_KEY;
49
- const trimmedToken = token?.trim() || "";
50
- const tokenIsApiKey = trimmedToken.startsWith("opk_");
51
- const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);
52
- if (effectiveApiKey && !headers.has("openpond-api-key")) 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) clearTimeout(timer);
65
- };
66
- try {
67
- const response = await fetch(requestUrl, { ...init, headers, signal });
68
- return boundedResponse(response, {
69
- cleanup,
70
- maximumBytes: maxResponseBytes,
71
- requestUrl,
72
- timeoutController,
73
- timeoutError
74
- });
75
- } catch (error) {
76
- cleanup();
77
- if (timeoutController.signal.aborted) throw timeoutError;
78
- throw error;
79
- }
80
- }
81
- function boundedResponse(response, input) {
82
- if (!response.body) {
83
- input.cleanup();
84
- return response;
85
- }
86
- const contentLength = Number(response.headers.get("content-length"));
87
- if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {
88
- input.cleanup();
89
- void response.body.cancel();
90
- throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);
91
- }
92
- const reader = response.body.getReader();
93
- let receivedBytes = 0;
94
- const body = new ReadableStream({
95
- async pull(controller) {
96
- try {
97
- const result = await reader.read();
98
- if (result.done) {
99
- input.cleanup();
100
- controller.close();
101
- return;
102
- }
103
- receivedBytes += result.value.byteLength;
104
- if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {
105
- input.cleanup();
106
- await reader.cancel();
107
- controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));
108
- return;
109
- }
110
- controller.enqueue(result.value);
111
- } catch (error) {
112
- input.cleanup();
113
- controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);
114
- }
115
- },
116
- async cancel(reason) {
117
- input.cleanup();
118
- await reader.cancel(reason);
119
- }
120
- });
121
- return new Response(body, {
122
- headers: response.headers,
123
- status: response.status,
124
- statusText: response.statusText
125
- });
126
- }
127
- function composedSignal(callerSignal, timeoutSignal, timeoutMs) {
128
- if (timeoutMs <= 0) return callerSignal ?? void 0;
129
- return callerSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : timeoutSignal;
130
- }
131
-
132
- // ../../packages/cloud/src/api/deployments.ts
133
- async function deployApp(baseUrl, token, appId, input) {
134
- const environment = input?.environment ?? "production";
135
- const response = await apiFetch(
136
- baseUrl,
137
- token,
138
- `/v4/apps/${appId}/deployments`,
139
- {
140
- method: "POST",
141
- body: JSON.stringify({
142
- environment,
143
- ...input?.commitSha ? { commitSha: input.commitSha } : {},
144
- ...input?.branch ? { branch: input.branch } : {}
145
- })
146
- }
147
- );
148
- if (!response.ok) {
149
- const text = await response.text().catch(() => "");
150
- throw new Error(`Deploy failed: ${response.status} ${text}`);
151
- }
152
- return await response.json();
153
- }
154
- async function getDeploymentLogs(apiBase, token, deploymentId) {
155
- const response = await apiFetch(
156
- apiBase,
157
- token,
158
- `/apps/deployments/${deploymentId}/logs`,
159
- { method: "GET" }
160
- );
161
- if (!response.ok) {
162
- const text = await response.text().catch(() => "");
163
- throw new Error(`Deployment logs failed: ${response.status} ${text}`);
164
- }
165
- const payload = await response.json().catch(() => ({}));
166
- const logs = Array.isArray(payload.logs) ? payload.logs : [];
167
- return logs.map((log) => {
168
- const createdAt = typeof log.createdAt === "string" ? log.createdAt : log.createdAt instanceof Date ? log.createdAt.toISOString() : (/* @__PURE__ */ new Date()).toISOString();
169
- return {
170
- id: typeof log.id === "string" ? log.id : `${Math.random()}`,
171
- type: typeof log.type === "string" ? log.type : void 0,
172
- message: typeof log.message === "string" ? log.message : "",
173
- createdAt
174
- };
175
- });
176
- }
177
- async function getDeploymentStatus(apiBase, token, deploymentId) {
178
- const response = await apiFetch(
179
- apiBase,
180
- token,
181
- `/apps/deployments/${deploymentId}/status`,
182
- { method: "GET" }
183
- );
184
- if (!response.ok) {
185
- const text = await response.text().catch(() => "");
186
- throw new Error(`Deployment status failed: ${response.status} ${text}`);
187
- }
188
- const payload = await response.json().catch(() => ({}));
189
- return { status: payload.deployment?.status };
190
- }
191
- async function getLatestDeploymentForApp(apiBase, token, appId, options) {
192
- const params = new URLSearchParams();
193
- if (options?.status && options.status.length > 0) {
194
- params.set("status", options.status.join(","));
195
- }
196
- if (options?.createdAfter) {
197
- params.set("createdAfter", options.createdAfter);
198
- }
199
- if (options?.branch) {
200
- params.set("branch", options.branch);
201
- }
202
- const query = params.toString();
203
- const response = await apiFetch(
204
- apiBase,
205
- token,
206
- `/apps/${appId}/deployments/latest${query ? `?${query}` : ""}`,
207
- { method: "GET" }
208
- );
209
- if (!response.ok) {
210
- const text = await response.text().catch(() => "");
211
- throw new Error(
212
- `Latest deployment lookup failed: ${response.status} ${text}`
213
- );
214
- }
215
- const payload = await response.json().catch(() => ({}));
216
- if (!payload.deployment) return null;
217
- return {
218
- id: payload.deployment.id,
219
- status: payload.deployment.status
220
- };
221
- }
222
- async function getDeploymentDetail(apiBase, token, deploymentId) {
223
- const response = await apiFetch(
224
- apiBase,
225
- token,
226
- `/apps/deployments/${deploymentId}`,
227
- { method: "GET" }
228
- );
229
- if (!response.ok) {
230
- const text = await response.text().catch(() => "");
231
- throw new Error(`Deployment fetch failed: ${response.status} ${text}`);
232
- }
233
- const payload = await response.json().catch(() => ({}));
234
- return payload.deployment ?? null;
235
- }
236
-
237
- // ../../packages/cloud/src/api.ts
238
- var DEFAULT_OPENPOND_API_HOST = new URL(DEFAULT_OPENPOND_API_BASE_URL).hostname;
239
- var DEFAULT_OPENPOND_WEB_HOST = new URL(DEFAULT_OPENPOND_WEB_BASE_URL).hostname;
240
- async function listApps(apiBase, token, options) {
241
- const params = new URLSearchParams();
242
- if (options?.handle) {
243
- params.set("handle", options.handle);
244
- }
245
- if (typeof options?.limit === "number" && Number.isFinite(options.limit)) {
246
- params.set("limit", String(Math.max(1, Math.floor(options.limit))));
247
- }
248
- if (typeof options?.offset === "number" && Number.isFinite(options.offset)) {
249
- params.set("offset", String(Math.max(0, Math.floor(options.offset))));
250
- }
251
- if (typeof options?.includeScheduled === "boolean") {
252
- params.set("includeScheduled", options.includeScheduled ? "true" : "false");
253
- }
254
- const query = params.toString();
255
- const response = await apiFetch(
256
- apiBase,
257
- token,
258
- `/apps/list${query ? `?${query}` : ""}`,
259
- { method: "GET" }
260
- );
261
- if (!response.ok) {
262
- const text = await response.text().catch(() => "");
263
- throw new Error(`Apps list failed: ${response.status} ${text}`);
264
- }
265
- const payload = await response.json().catch(() => ({}));
266
- return Array.isArray(payload.apps) ? payload.apps : [];
267
- }
268
- async function createRepo(apiBase, apiKey, input) {
269
- const response = await apiFetch(apiBase, apiKey, "/apps/repo/create", {
270
- method: "POST",
271
- body: JSON.stringify(input)
272
- });
273
- if (!response.ok) {
274
- const text = await response.text().catch(() => "");
275
- throw new Error(`Repo create failed: ${response.status} ${text}`);
276
- }
277
- return await response.json();
278
- }
279
- async function updateAppCodeVisibility(apiBase, apiKey, appId, codeVisibility) {
280
- const response = await apiFetch(
281
- apiBase,
282
- apiKey,
283
- `/apps/${encodeURIComponent(appId)}/code-visibility`,
284
- {
285
- method: "PATCH",
286
- body: JSON.stringify({ codeVisibility })
287
- }
288
- );
289
- if (!response.ok) {
290
- const text = await response.text().catch(() => "");
291
- throw new Error(
292
- `Code visibility update failed: ${response.status} ${text}`
293
- );
294
- }
295
- return await response.json();
296
- }
297
- async function createHeadlessApps(baseUrl, token, items, teamId) {
298
- const response = await apiFetch(baseUrl, token, "/v4/apps/headless", {
299
- method: "POST",
300
- body: JSON.stringify({ items, ...teamId ? { teamId } : {} })
301
- });
302
- if (!response.ok) {
303
- const text = await response.text().catch(() => "");
304
- throw new Error(`Headless create failed: ${response.status} ${text}`);
305
- }
306
- return await response.json();
307
- }
308
- async function getTemplateStatus(apiBase, token, appId) {
309
- const response = await apiFetch(
310
- apiBase,
311
- token,
312
- `/v4/apps/${appId}/template/status`,
313
- { method: "GET" }
314
- );
315
- if (!response.ok) {
316
- const text = await response.text().catch(() => "");
317
- throw new Error(`Template status failed: ${response.status} ${text}`);
318
- }
319
- return await response.json();
320
- }
321
- async function listTemplateBranches(apiBase, token, appId) {
322
- const response = await apiFetch(
323
- apiBase,
324
- token,
325
- `/v4/apps/${appId}/template/branches`,
326
- { method: "GET" }
327
- );
328
- if (!response.ok) {
329
- const text = await response.text().catch(() => "");
330
- throw new Error(`Template branches failed: ${response.status} ${text}`);
331
- }
332
- return await response.json();
333
- }
334
- async function deployLatestTemplate(apiBase, token, appId, input) {
335
- const response = await apiFetch(
336
- apiBase,
337
- token,
338
- `/v4/apps/${appId}/template/deploy-latest`,
339
- {
340
- method: "POST",
341
- body: JSON.stringify(input)
342
- }
343
- );
344
- if (!response.ok) {
345
- const text = await response.text().catch(() => "");
346
- throw new Error(`Template deploy failed: ${response.status} ${text}`);
347
- }
348
- return await response.json();
349
- }
350
- async function updateAppEnvironment(apiBase, token, appId, input) {
351
- const response = await apiFetch(
352
- apiBase,
353
- token,
354
- `/v4/apps/${appId}/environment`,
355
- {
356
- method: "POST",
357
- body: JSON.stringify(input)
358
- }
359
- );
360
- if (!response.ok) {
361
- const text = await response.text().catch(() => "");
362
- throw new Error(`Environment update failed: ${response.status} ${text}`);
363
- }
364
- return await response.json();
365
- }
366
- async function getAppEnvironment(apiBase, token, appId) {
367
- const response = await apiFetch(
368
- apiBase,
369
- token,
370
- `/v4/apps/${appId}/environment`,
371
- {
372
- method: "GET"
373
- }
374
- );
375
- if (!response.ok) {
376
- const text = await response.text().catch(() => "");
377
- throw new Error(`Environment get failed: ${response.status} ${text}`);
378
- }
379
- return await response.json();
380
- }
381
- async function listUserTools(baseUrl, token) {
382
- const response = await apiFetch(baseUrl, token, "/apps/tools", {
383
- method: "GET"
384
- });
385
- if (!response.ok) {
386
- const text = await response.text().catch(() => "");
387
- throw new Error(`Tools lookup failed: ${response.status} ${text}`);
388
- }
389
- return await response.json();
390
- }
391
- async function createAgentFromPrompt(baseUrl, token, payload) {
392
- return apiFetch(baseUrl, token, "/apps/agent/create", {
393
- method: "POST",
394
- body: JSON.stringify(payload)
395
- });
396
- }
397
- async function getUserPerformance(baseUrl, token, options) {
398
- const params = new URLSearchParams();
399
- if (options?.appId) {
400
- params.set("appId", options.appId);
401
- }
402
- const qs = params.toString();
403
- const response = await apiFetch(
404
- baseUrl,
405
- token,
406
- `/apps/performance${qs ? `?${qs}` : ""}`,
407
- {
408
- method: "GET"
409
- }
410
- );
411
- if (!response.ok) {
412
- const text = await response.text().catch(() => "");
413
- throw new Error(`Performance lookup failed: ${response.status} ${text}`);
414
- }
415
- return await response.json();
416
- }
417
- async function getAppRuntimeSummary(baseUrl, token, appId) {
418
- const params = new URLSearchParams({ appId });
419
- const response = await apiFetch(
420
- baseUrl,
421
- token,
422
- `/apps/summary?${params.toString()}`,
423
- {
424
- method: "GET"
425
- }
426
- );
427
- if (!response.ok) {
428
- const text = await response.text().catch(() => "");
429
- throw new Error(`Summary lookup failed: ${response.status} ${text}`);
430
- }
431
- return await response.json();
432
- }
433
- async function getOpenPondAccount(baseUrl, token) {
434
- const response = await apiFetch(baseUrl, token, "/v1/account", {
435
- method: "GET"
436
- });
437
- if (!response.ok) {
438
- const text = await response.text().catch(() => "");
439
- throw new Error(`Account lookup failed: ${response.status} ${text}`);
440
- }
441
- return await response.json();
442
- }
443
- async function checkOpenPondApiHealth(baseUrl, token) {
444
- const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
445
- const started = Date.now();
446
- const normalizedBase = baseUrl.replace(/\/$/, "");
447
- try {
448
- const response = await apiFetch(normalizedBase, null, "/health", {
449
- method: "GET",
450
- headers: { Accept: "application/json" }
451
- });
452
- const latencyMs = Date.now() - started;
453
- const payload = await response.json().catch(() => ({}));
454
- let authenticated = null;
455
- let account = null;
456
- if (token?.trim()) {
457
- try {
458
- const accountPayload = await getOpenPondAccount(normalizedBase, token);
459
- authenticated = true;
460
- account = accountPayload.account;
461
- } catch {
462
- authenticated = false;
463
- }
464
- }
465
- return {
466
- reachable: response.ok,
467
- authenticated,
468
- apiBase: normalizedBase,
469
- latencyMs,
470
- status: response.status,
471
- service: typeof payload.service === "string" ? payload.service : null,
472
- checkedAt,
473
- account,
474
- ...response.ok ? {} : { error: response.statusText || `HTTP ${response.status}` }
475
- };
476
- } catch (error) {
477
- return {
478
- reachable: false,
479
- authenticated: token?.trim() ? false : null,
480
- apiBase: normalizedBase,
481
- latencyMs: Date.now() - started,
482
- status: null,
483
- service: null,
484
- checkedAt,
485
- error: error instanceof Error ? error.message : String(error)
486
- };
487
- }
488
- }
489
- async function runAssistantMode(baseUrl, token, payload) {
490
- const response = await apiFetch(baseUrl, token, "/apps/assistant/run", {
491
- method: "POST",
492
- body: JSON.stringify(payload)
493
- });
494
- if (!response.ok) {
495
- const text = await response.text().catch(() => "");
496
- throw new Error(`Assistant run failed: ${response.status} ${text}`);
497
- }
498
- return await response.json();
499
- }
500
- async function executeUserTool(baseUrl, token, body) {
501
- const response = await apiFetch(baseUrl, token, "/apps/tools/execute", {
502
- method: "POST",
503
- body: JSON.stringify(body)
504
- });
505
- const text = await response.text().catch(() => "");
506
- let payload = null;
507
- try {
508
- payload = text ? JSON.parse(text) : null;
509
- } catch {
510
- payload = text;
511
- }
512
- if (!response.ok) {
513
- return {
514
- ok: false,
515
- status: response.status,
516
- error: payload && typeof payload === "object" && "error" in payload ? String(payload.error) : text || response.statusText
517
- };
518
- }
519
- return {
520
- ok: true,
521
- status: response.status,
522
- data: payload
523
- };
524
- }
525
- async function submitBacktestRun(baseUrl, token, body) {
526
- const response = await apiFetch(baseUrl, token, "/apps/backtests/run", {
527
- method: "POST",
528
- body: JSON.stringify(body)
529
- });
530
- if (!response.ok) {
531
- const text = await response.text().catch(() => "");
532
- throw new Error(`Backtest run failed: ${response.status} ${text}`);
533
- }
534
- return await response.json();
535
- }
536
- async function submitBacktestTx(baseUrl, token, params) {
537
- const qs = params.query && Object.keys(params.query).length > 0 ? `?${new URLSearchParams(params.query).toString()}` : "";
538
- const response = await apiFetch(baseUrl, token, `/apps/backtests/tx${qs}`, {
539
- method: params.method,
540
- body: params.method === "POST" && params.body !== void 0 ? JSON.stringify(params.body) : void 0
541
- });
542
- if (!response.ok) {
543
- const text = await response.text().catch(() => "");
544
- throw new Error(`Backtests request failed: ${response.status} ${text}`);
545
- }
546
- return await response.json();
547
- }
548
- async function submitBacktestDetail(baseUrl, token, query) {
549
- const qs = new URLSearchParams(query).toString();
550
- const response = await apiFetch(
551
- baseUrl,
552
- token,
553
- `/apps/backtests/detail?${qs}`,
554
- {
555
- method: "GET"
556
- }
557
- );
558
- if (!response.ok) {
559
- const text = await response.text().catch(() => "");
560
- throw new Error(`Backtest detail failed: ${response.status} ${text}`);
561
- }
562
- return await response.json();
563
- }
564
- function normalizeToolPathSegment(toolName) {
565
- const trimmed = toolName.trim().replace(/^\/+/, "");
566
- return encodeURIComponent(trimmed || "tool");
567
- }
568
- function resolveWorkerBaseUrl(baseUrl) {
569
- const trimmed = baseUrl.replace(/\/$/, "");
570
- const workerEnv = process.env.OPENPOND_TOOL_URL;
571
- if (workerEnv) {
572
- return workerEnv.replace(/\/$/, "");
573
- }
574
- try {
575
- const url = new URL(trimmed);
576
- const host = url.hostname.toLowerCase();
577
- const mappedHost = (() => {
578
- if (host === "apps.openpond.live") {
579
- return null;
580
- }
581
- if (host === DEFAULT_OPENPOND_API_HOST || host === DEFAULT_OPENPOND_WEB_HOST || host === "openpond.live" || host === "www.openpond.live") {
582
- return "https://apps.openpond.live";
583
- }
584
- return null;
585
- })();
586
- if (mappedHost) {
587
- return mappedHost;
588
- }
589
- const isLocal = host === "localhost" || host === "127.0.0.1";
590
- const port = url.port || (url.protocol === "https:" ? "443" : "80");
591
- if (isLocal && port === "3000") {
592
- return trimmed;
593
- }
594
- } catch {
595
- }
596
- return trimmed;
597
- }
598
- async function executeHostedTool(baseUrl, token, payload) {
599
- const workerBase = resolveWorkerBaseUrl(baseUrl);
600
- const toolPath = normalizeToolPathSegment(payload.toolName);
601
- const deploymentPrefix = payload.deploymentId ? `/${payload.appId}/deployments/${payload.deploymentId}` : `/${payload.appId}`;
602
- const requestPath = `${deploymentPrefix}/${toolPath}`;
603
- const headers = new Headers(payload.headers || {});
604
- const method = payload.method ?? "POST";
605
- const body = payload.body === void 0 || method === "GET" ? void 0 : JSON.stringify(payload.body);
606
- const response = await apiFetch(workerBase, token, requestPath, {
607
- method,
608
- body,
609
- headers
610
- });
611
- const text = await response.text().catch(() => "");
612
- let data = null;
613
- try {
614
- data = text ? JSON.parse(text) : null;
615
- } catch {
616
- data = text;
617
- }
618
- const dataOk = data && typeof data === "object" && "ok" in data ? Boolean(data.ok) : true;
619
- const ok = response.ok && dataOk;
620
- const status = data && typeof data === "object" && "status" in data ? Number(data.status) || response.status : response.status;
621
- const error = data && typeof data === "object" && "error" in data ? String(data.error) : response.ok ? void 0 : text || response.statusText;
622
- const payloadData = data && typeof data === "object" && "data" in data ? data.data : data;
623
- return { ok, status, data: payloadData, error };
624
- }
625
-
626
- // ../../packages/cloud/src/config.ts
627
- import path from "node:path";
628
- var DEFAULT_ACCOUNT_HANDLE = "default";
629
- var ACCOUNT_SCOPED_KEYS = [
630
- "apiKey",
631
- "baseUrl",
632
- "apiBaseUrl",
633
- "chatApiBaseUrl",
634
- "token",
635
- "appId",
636
- "conversationId"
637
- ];
638
- function hasOwn(value, key) {
639
- return Object.prototype.hasOwnProperty.call(value, key);
640
- }
641
- function normalizeHandle(value) {
642
- if (typeof value !== "string") return null;
643
- const trimmed = value.trim();
644
- return trimmed.length > 0 ? trimmed : null;
645
- }
646
- function normalizeBaseUrl(value) {
647
- if (typeof value !== "string") return null;
648
- const trimmed = value.trim();
649
- if (!trimmed) return null;
650
- return trimmed.replace(/\/$/, "");
651
- }
652
- function requireHandle(value) {
653
- const handle = normalizeHandle(value);
654
- if (!handle) {
655
- throw new Error("profile handle must be non-empty");
656
- }
657
- return handle;
658
- }
659
- function requireApiKey(value) {
660
- if (typeof value !== "string") {
661
- throw new Error("apiKey must be a non-empty string");
662
- }
663
- const trimmed = value.trim();
664
- if (!trimmed) {
665
- throw new Error("apiKey must be a non-empty string");
666
- }
667
- return trimmed;
668
- }
669
- function handleEquals(left, right) {
670
- const normalizedLeft = normalizeHandle(left);
671
- const normalizedRight = normalizeHandle(right);
672
- return Boolean(
673
- normalizedLeft && normalizedRight && normalizedLeft.toLowerCase() === normalizedRight.toLowerCase()
674
- );
675
- }
676
- function findAccountIndex(accounts, handle, baseUrl) {
677
- const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
678
- return accounts.findIndex((candidate) => {
679
- if (!handleEquals(candidate.handle, handle)) return false;
680
- if (!normalizedBaseUrl) return true;
681
- return normalizeBaseUrl(candidate.baseUrl) === normalizedBaseUrl;
682
- });
683
- }
684
- function selectorFromAccount(account) {
685
- const handle = normalizeHandle(account.handle) ?? DEFAULT_ACCOUNT_HANDLE;
686
- const baseUrl = normalizeBaseUrl(account.baseUrl);
687
- return baseUrl ? { handle, baseUrl } : { handle };
688
- }
689
- function sanitizeActiveProfile(value) {
690
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
691
- const input = value;
692
- const handle = normalizeHandle(
693
- typeof input.handle === "string" ? input.handle : void 0
694
- );
695
- if (!handle) return null;
696
- const baseUrl = normalizeBaseUrl(
697
- typeof input.baseUrl === "string" ? input.baseUrl : void 0
698
- );
699
- return baseUrl ? { handle, baseUrl } : { handle };
700
- }
701
- function sanitizeLocalOpenPondProfile(value) {
702
- if (!value || typeof value !== "object" || Array.isArray(value)) {
703
- return void 0;
704
- }
705
- const input = value;
706
- const repoPath = typeof input.repoPath === "string" ? input.repoPath.trim() : "";
707
- const profile = typeof input.profile === "string" && input.profile.trim() ? input.profile.trim() : "default";
708
- if (!repoPath) return void 0;
709
- const out = {
710
- repoPath,
711
- profile,
712
- mode: "local"
713
- };
714
- if (input.lastCheck && typeof input.lastCheck === "object" && !Array.isArray(input.lastCheck)) {
715
- const check = input.lastCheck;
716
- const command = check.command;
717
- const status = check.status;
718
- const checkedAt = check.checkedAt;
719
- if ((command === "inspect" || command === "build" || command === "validate" || command === "eval" || command === "run") && (status === "passed" || status === "failed") && typeof checkedAt === "string") {
720
- out.lastCheck = {
721
- command,
722
- status,
723
- checkedAt,
724
- ...typeof check.exitCode === "number" || check.exitCode === null ? { exitCode: check.exitCode } : {},
725
- ...typeof check.sourceHead === "string" || check.sourceHead === null ? { sourceHead: check.sourceHead } : {}
726
- };
727
- }
728
- }
729
- if (input.lastPush && typeof input.lastPush === "object" && !Array.isArray(input.lastPush)) {
730
- const push = input.lastPush;
731
- const status = push.status;
732
- const pushedAt = push.pushedAt;
733
- if ((status === "pushed" || status === "failed") && typeof pushedAt === "string") {
734
- out.lastPush = {
735
- status,
736
- pushedAt,
737
- ...typeof push.teamId === "string" || push.teamId === null ? { teamId: push.teamId } : {},
738
- ...typeof push.projectId === "string" || push.projectId === null ? { projectId: push.projectId } : {},
739
- ...typeof push.localHead === "string" || push.localHead === null ? { localHead: push.localHead } : {},
740
- ...typeof push.hostedHead === "string" || push.hostedHead === null ? { hostedHead: push.hostedHead } : {},
741
- ...typeof push.sourceRef === "string" || push.sourceRef === null ? { sourceRef: push.sourceRef } : {},
742
- ...push.promotionStatus === "uploaded" || push.promotionStatus === "hosted_source_materialized" || push.promotionStatus === "hosted_source_materialize_failed" || push.promotionStatus === "hosted_source_check_pending" || push.promotionStatus === "hosted_source_check_failed" || push.promotionStatus === "hosted_source_published" || push.promotionStatus === "hosted_source_publish_failed" || push.promotionStatus === "hosted_run_pending" || push.promotionStatus === "hosted_run_passed" || push.promotionStatus === "hosted_run_failed" || push.promotionStatus === null ? { promotionStatus: push.promotionStatus } : {},
743
- ...push.hostedRunStatus === "not_started" || push.hostedRunStatus === "running" || push.hostedRunStatus === "passed" || push.hostedRunStatus === "failed" || push.hostedRunStatus === null ? { hostedRunStatus: push.hostedRunStatus } : {},
744
- ...typeof push.hostedRunAgentId === "string" || push.hostedRunAgentId === null ? { hostedRunAgentId: push.hostedRunAgentId } : {},
745
- ...typeof push.hostedRunId === "string" || push.hostedRunId === null ? { hostedRunId: push.hostedRunId } : {},
746
- ...typeof push.hostedRunAt === "string" || push.hostedRunAt === null ? { hostedRunAt: push.hostedRunAt } : {},
747
- ...sanitizeHostedMaterializationStatus(push.hostedSourceMaterialization) ? { hostedSourceMaterialization: sanitizeHostedMaterializationStatus(push.hostedSourceMaterialization) } : {},
748
- ...sanitizeHostedSourceCheckStatus(push.hostedSourceCheck) ? { hostedSourceCheck: sanitizeHostedSourceCheckStatus(push.hostedSourceCheck) } : {},
749
- ...sanitizeHostedPublishStatus(push.hostedPublish) ? { hostedPublish: sanitizeHostedPublishStatus(push.hostedPublish) } : {},
750
- ...sanitizeHostedRunSummary(push.hostedRun) ? { hostedRun: sanitizeHostedRunSummary(push.hostedRun) } : {},
751
- ...typeof push.error === "string" || push.error === null ? { error: push.error } : {}
752
- };
753
- }
754
- }
755
- if (Array.isArray(input.profiles)) {
756
- const profiles = input.profiles.flatMap((value2) => {
757
- const entry = sanitizeLocalOpenPondProfile(value2);
758
- if (!entry) return [];
759
- const rawEntry = value2;
760
- const source = rawEntry.source === "github" || rawEntry.source === "openpond_git" ? rawEntry.source : "local";
761
- const repositoryId = typeof rawEntry.repositoryId === "string" && rawEntry.repositoryId.trim() ? rawEntry.repositoryId.trim() : path.resolve(entry.repoPath);
762
- return [{
763
- source,
764
- repositoryId,
765
- repoPath: entry.repoPath,
766
- profile: entry.profile,
767
- ...entry.lastCheck ? { lastCheck: entry.lastCheck } : {},
768
- ...entry.lastPush ? { lastPush: entry.lastPush } : {}
769
- }];
770
- });
771
- if (profiles.length > 0) out.profiles = profiles;
772
- }
773
- return out;
774
- }
775
- function sanitizeHostedMaterializationStatus(value) {
776
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
777
- const input = value;
778
- const status = stringField(input.status);
779
- if (!status) return null;
780
- return {
781
- status,
782
- ...nullableStringProp(input, "agentId"),
783
- ...nullableStringProp(input, "runtimeAgentId"),
784
- ...nullableStringProp(input, "projectId"),
785
- ...nullableStringProp(input, "sourceRoot"),
786
- ...nullableStringProp(input, "sourceRef"),
787
- ...nullableStringProp(input, "sourceCommitSha"),
788
- ...nullableStringProp(input, "manifestHash"),
789
- ...nullableStringProp(input, "manifestPath"),
790
- ...nullableStringProp(input, "manifestSyncedAt"),
791
- ...nullableNumberProp(input, "fileCount"),
792
- ...nullableNumberProp(input, "totalBytes"),
793
- ...nullableStringProp(input, "generatedManifestPath"),
794
- ...nullableBooleanProp(input, "synthesizedOpenPondYaml"),
795
- ...nullableStringProp(input, "uploadMetadataPath"),
796
- ...stringArrayProp(input, "setupCommands"),
797
- ...stringArrayProp(input, "validationCommands"),
798
- ...nullableStringProp(input, "materializedAt"),
799
- ...nullableStringProp(input, "error")
800
- };
801
- }
802
- function sanitizeHostedSourceCheckStatus(value) {
803
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
804
- const input = value;
805
- const status = stringField(input.status);
806
- if (!status) return null;
807
- return {
808
- status,
809
- ...nullableStringProp(input, "agentId"),
810
- ...nullableStringProp(input, "deployPlanStatus"),
811
- ...nullableBooleanProp(input, "canRun"),
812
- ...nullableBooleanProp(input, "canDeploy"),
813
- ...nullableStringProp(input, "sourceRef"),
814
- ...nullableStringProp(input, "sourceCommitSha"),
815
- ...nullableStringProp(input, "manifestHash"),
816
- ...nullableStringProp(input, "manifestPath"),
817
- ...stringArrayProp(input, "setupCommands"),
818
- ...stringArrayProp(input, "validationCommands"),
819
- ...stringArrayProp(input, "requiredChecks"),
820
- ...stringArrayProp(input, "evalNames"),
821
- ...stringArrayProp(input, "blockedReasons"),
822
- ...stringArrayProp(input, "staleReasons"),
823
- ...nullableStringProp(input, "runtimeId"),
824
- ...nullableStringProp(input, "sandboxId"),
825
- ...stringArrayProp(input, "traceArtifactRefs"),
826
- ...stringArrayProp(input, "evalResultArtifactRefs"),
827
- ...stringArrayProp(input, "validatorArtifactRefs"),
828
- ...nullableStringProp(input, "checkedAt"),
829
- ...nullableStringProp(input, "error")
830
- };
831
- }
832
- function sanitizeHostedPublishStatus(value) {
833
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
834
- const input = value;
835
- const status = stringField(input.status);
836
- if (!status) return null;
837
- return {
838
- status,
839
- ...nullableStringProp(input, "agentId"),
840
- ...nullableStringProp(input, "snapshotId"),
841
- ...nullableStringProp(input, "sourceRef"),
842
- ...nullableStringProp(input, "sourceCommitSha"),
843
- ...nullableStringProp(input, "manifestHash"),
844
- ...nullableStringProp(input, "manifestPath"),
845
- ...nullableStringProp(input, "buildStatus"),
846
- ...nullableStringProp(input, "validationStatus"),
847
- ...nullableStringProp(input, "evalStatus"),
848
- ...nullableStringProp(input, "publishedAt"),
849
- ...nullableStringProp(input, "error")
850
- };
851
- }
852
- function sanitizeHostedRunSummary(value) {
853
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
854
- const input = value;
855
- const status = stringField(input.status);
856
- if (!status) return null;
857
- return {
858
- status,
859
- ...nullableStringProp(input, "agentId"),
860
- ...nullableStringProp(input, "runId"),
861
- ...nullableStringProp(input, "runtimeId"),
862
- ...nullableStringProp(input, "sandboxId"),
863
- ...nullableStringProp(input, "sourceRef"),
864
- ...nullableStringProp(input, "sourceCommitSha"),
865
- ...nullableStringProp(input, "manifestHash"),
866
- ...nullableStringProp(input, "setupGateStatus"),
867
- ...stringArrayProp(input, "setupRequirementRefs"),
868
- ...stringArrayProp(input, "artifactRefs"),
869
- ...stringArrayProp(input, "traceArtifactRefs"),
870
- ...stringArrayProp(input, "evalArtifactRefs"),
871
- ...nullableStringProp(input, "startedAt"),
872
- ...nullableStringProp(input, "completedAt"),
873
- ...nullableStringProp(input, "error")
874
- };
875
- }
876
- function nullableStringProp(input, key) {
877
- const value = input[key];
878
- return typeof value === "string" || value === null ? { [key]: value } : {};
879
- }
880
- function nullableBooleanProp(input, key) {
881
- const value = input[key];
882
- return typeof value === "boolean" || value === null ? { [key]: value } : {};
883
- }
884
- function nullableNumberProp(input, key) {
885
- const value = input[key];
886
- return typeof value === "number" || value === null ? { [key]: value } : {};
887
- }
888
- function stringArrayProp(input, key) {
889
- const value = input[key];
890
- if (!Array.isArray(value)) return {};
891
- const strings = value.filter((item) => typeof item === "string");
892
- return { [key]: strings };
893
- }
894
- function stringField(value) {
895
- return typeof value === "string" && value.trim() ? value.trim() : null;
896
- }
897
- function accountMatchesSelector(account, selector) {
898
- if (!handleEquals(account.handle, selector.handle)) return false;
899
- const selectorBaseUrl = normalizeBaseUrl(selector.baseUrl);
900
- if (selectorBaseUrl) {
901
- return normalizeBaseUrl(account.baseUrl) === selectorBaseUrl;
902
- }
903
- return !normalizeBaseUrl(account.baseUrl);
904
- }
905
- function findAccountIndexForSelector(accounts, selector, options = {}) {
906
- const normalizedBaseUrl = normalizeBaseUrl(selector.baseUrl);
907
- if (normalizedBaseUrl) {
908
- return findAccountIndex(accounts, selector.handle, normalizedBaseUrl);
909
- }
910
- const noBaseIdx = accounts.findIndex(
911
- (account) => accountMatchesSelector(account, selector)
912
- );
913
- if (noBaseIdx !== -1) return noBaseIdx;
914
- const matches = accounts.map((account, index) => ({ account, index })).filter(({ account }) => handleEquals(account.handle, selector.handle));
915
- if (matches.length > 1 && options.requireUnambiguous) {
916
- throw new Error(
917
- `multiple profiles found for ${selector.handle}; pass --base-url to select one`
918
- );
919
- }
920
- return matches[0]?.index ?? -1;
921
- }
922
- function sanitizeSession(value) {
923
- if (!value || typeof value !== "object" || Array.isArray(value)) {
924
- return void 0;
925
- }
926
- const input = value;
927
- const out = {};
928
- if (typeof input.token === "string") out.token = input.token;
929
- if (typeof input.appId === "string" || input.appId === null) {
930
- out.appId = input.appId;
931
- }
932
- if (typeof input.conversationId === "string" || input.conversationId === null) {
933
- out.conversationId = input.conversationId;
934
- }
935
- return Object.keys(out).length > 0 ? out : void 0;
936
- }
937
- function sanitizeAccount(value) {
938
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
939
- const input = value;
940
- const handle = normalizeHandle(
941
- typeof input.handle === "string" ? input.handle : void 0
942
- );
943
- if (!handle) return null;
944
- const out = { handle };
945
- if (typeof input.apiKey === "string") out.apiKey = input.apiKey;
946
- if (typeof input.baseUrl === "string") out.baseUrl = input.baseUrl;
947
- if (typeof input.apiBaseUrl === "string") out.apiBaseUrl = input.apiBaseUrl;
948
- if (typeof input.chatApiBaseUrl === "string") out.chatApiBaseUrl = input.chatApiBaseUrl;
949
- if (typeof input.environment === "string")
950
- out.environment = input.environment;
951
- const session = sanitizeSession(input.session);
952
- if (session) out.session = session;
953
- return out;
954
- }
955
- function extractLegacySession(raw) {
956
- const session = {};
957
- if (typeof raw.token === "string") session.token = raw.token;
958
- if (typeof raw.appId === "string" || raw.appId === null) {
959
- session.appId = raw.appId;
960
- }
961
- if (typeof raw.conversationId === "string" || raw.conversationId === null) {
962
- session.conversationId = raw.conversationId;
963
- }
964
- return Object.keys(session).length > 0 ? session : void 0;
965
- }
966
- function extractLegacyAccount(raw, handle) {
967
- const out = { handle };
968
- if (typeof raw.apiKey === "string") out.apiKey = raw.apiKey;
969
- if (typeof raw.baseUrl === "string") out.baseUrl = raw.baseUrl;
970
- if (typeof raw.apiBaseUrl === "string") out.apiBaseUrl = raw.apiBaseUrl;
971
- if (typeof raw.chatApiBaseUrl === "string") out.chatApiBaseUrl = raw.chatApiBaseUrl;
972
- const session = extractLegacySession(raw);
973
- if (session) out.session = session;
974
- return out;
975
- }
976
- function normalizeGlobalConfig(raw) {
977
- const normalized = {};
978
- if (typeof raw.lspEnabled === "boolean")
979
- normalized.lspEnabled = raw.lspEnabled;
980
- if (raw.executionMode === "local" || raw.executionMode === "hosted") {
981
- normalized.executionMode = raw.executionMode;
982
- }
983
- if (raw.mode === "general" || raw.mode === "builder") {
984
- normalized.mode = raw.mode;
985
- }
986
- const openpondProfile = sanitizeLocalOpenPondProfile(raw.openpondProfile);
987
- if (openpondProfile) {
988
- normalized.openpondProfile = openpondProfile;
989
- }
990
- const accounts = [];
991
- const sourceAccounts = Array.isArray(raw.accounts) ? raw.accounts : [];
992
- for (const candidate of sourceAccounts) {
993
- const account = sanitizeAccount(candidate);
994
- if (!account) continue;
995
- if (findAccountIndex(accounts, account.handle, account.baseUrl) !== -1)
996
- continue;
997
- accounts.push(account);
998
- }
999
- if (accounts.length === 0) {
1000
- const legacyHandle = sanitizeActiveProfile(raw.activeProfile)?.handle || DEFAULT_ACCOUNT_HANDLE;
1001
- accounts.push(extractLegacyAccount(raw, legacyHandle));
1002
- }
1003
- const requested = sanitizeActiveProfile(raw.activeProfile);
1004
- const activeIdx = requested ? findAccountIndexForSelector(accounts, requested) : -1;
1005
- const activeAccount = accounts[activeIdx === -1 ? 0 : activeIdx];
1006
- normalized.accounts = accounts;
1007
- normalized.activeProfile = selectorFromAccount(activeAccount);
1008
- return normalized;
1009
- }
1010
- function resolveRequestedProfile(global, explicitAccount, explicitBaseUrl) {
1011
- const accounts = global.accounts ?? [];
1012
- const requestedBaseUrl = normalizeBaseUrl(
1013
- explicitBaseUrl ?? process.env.OPENPOND_BASE_URL
1014
- );
1015
- const explicit = normalizeHandle(explicitAccount);
1016
- if (explicit) {
1017
- return requestedBaseUrl ? { handle: explicit, baseUrl: requestedBaseUrl } : { handle: explicit };
1018
- }
1019
- const envAccount = normalizeHandle(process.env.OPENPOND_ACCOUNT);
1020
- if (envAccount) {
1021
- return requestedBaseUrl ? { handle: envAccount, baseUrl: requestedBaseUrl } : { handle: envAccount };
1022
- }
1023
- const activeProfile = sanitizeActiveProfile(global.activeProfile);
1024
- if (activeProfile) {
1025
- return requestedBaseUrl ? { handle: activeProfile.handle, baseUrl: requestedBaseUrl } : activeProfile;
1026
- }
1027
- return accounts[0] ? selectorFromAccount(accounts[0]) : { handle: DEFAULT_ACCOUNT_HANDLE };
1028
- }
1029
- function ensureAccount(accounts, handle, baseUrl) {
1030
- const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
1031
- if (normalizedBaseUrl) {
1032
- const idx = findAccountIndex(accounts, handle, normalizedBaseUrl);
1033
- if (idx !== -1) {
1034
- return accounts[idx];
1035
- }
1036
- } else {
1037
- const matches = accounts.filter(
1038
- (account) => handleEquals(account.handle, handle)
1039
- );
1040
- if (matches.length > 1) {
1041
- throw new Error(
1042
- `multiple profiles found for ${handle}; pass --base-url to select one`
1043
- );
1044
- }
1045
- if (matches.length === 1) {
1046
- return matches[0];
1047
- }
1048
- }
1049
- const next = { handle };
1050
- if (normalizedBaseUrl) {
1051
- next.baseUrl = normalizedBaseUrl;
1052
- }
1053
- accounts.push(next);
1054
- return next;
1055
- }
1056
- function cleanupAccount(account) {
1057
- if (account.session && Object.keys(account.session).length === 0) {
1058
- delete account.session;
1059
- }
1060
- }
1061
- function applyScopedKey(account, key, value, options) {
1062
- const shouldDelete = value === null || value === void 0 && options.undefinedDeletes;
1063
- switch (key) {
1064
- case "apiKey": {
1065
- if (shouldDelete) {
1066
- delete account.apiKey;
1067
- return;
1068
- }
1069
- if (typeof value === "string") {
1070
- account.apiKey = value;
1071
- }
1072
- return;
1073
- }
1074
- case "baseUrl": {
1075
- if (shouldDelete) {
1076
- delete account.baseUrl;
1077
- return;
1078
- }
1079
- if (typeof value === "string") {
1080
- account.baseUrl = value;
1081
- }
1082
- return;
1083
- }
1084
- case "apiBaseUrl": {
1085
- if (shouldDelete) {
1086
- delete account.apiBaseUrl;
1087
- return;
1088
- }
1089
- if (typeof value === "string") {
1090
- account.apiBaseUrl = value;
1091
- }
1092
- return;
1093
- }
1094
- case "chatApiBaseUrl": {
1095
- if (shouldDelete) {
1096
- delete account.chatApiBaseUrl;
1097
- return;
1098
- }
1099
- if (typeof value === "string") {
1100
- account.chatApiBaseUrl = value;
1101
- }
1102
- return;
1103
- }
1104
- case "token":
1105
- case "appId":
1106
- case "conversationId": {
1107
- if (!account.session) account.session = {};
1108
- if (shouldDelete) {
1109
- delete account.session[key];
1110
- cleanupAccount(account);
1111
- return;
1112
- }
1113
- if (typeof value === "string" || value === null) {
1114
- account.session[key] = value;
1115
- }
1116
- cleanupAccount(account);
1117
- return;
1118
- }
1119
- }
1120
- }
1121
- function applyAccountPatch(global, source, options) {
1122
- const hasScopedPatch = ACCOUNT_SCOPED_KEYS.some((key) => hasOwn(source, key));
1123
- if (!hasScopedPatch) return false;
1124
- const accounts = global.accounts ?? [];
1125
- const selector = sanitizeActiveProfile(source.activeProfile) ?? resolveRequestedProfile(global);
1126
- const requestedBaseUrl = normalizeBaseUrl(
1127
- hasOwn(source, "baseUrl") ? source.baseUrl ?? null : selector.baseUrl ?? process.env.OPENPOND_BASE_URL
1128
- );
1129
- const account = ensureAccount(accounts, selector.handle, requestedBaseUrl);
1130
- for (const key of ACCOUNT_SCOPED_KEYS) {
1131
- if (!hasOwn(source, key)) continue;
1132
- applyScopedKey(
1133
- account,
1134
- key,
1135
- source[key],
1136
- options
1137
- );
1138
- }
1139
- global.accounts = accounts;
1140
- global.activeProfile = selectorFromAccount(account);
1141
- return true;
1142
- }
1143
- function applyTopLevelPatch(global, source) {
1144
- if (hasOwn(source, "lspEnabled")) {
1145
- if (typeof source.lspEnabled === "boolean") {
1146
- global.lspEnabled = source.lspEnabled;
1147
- } else if (source.lspEnabled === null) {
1148
- delete global.lspEnabled;
1149
- }
1150
- }
1151
- if (hasOwn(source, "executionMode")) {
1152
- if (source.executionMode === "local" || source.executionMode === "hosted") {
1153
- global.executionMode = source.executionMode;
1154
- } else if (source.executionMode === null) {
1155
- delete global.executionMode;
1156
- }
1157
- }
1158
- if (hasOwn(source, "mode")) {
1159
- if (source.mode === "general" || source.mode === "builder") {
1160
- global.mode = source.mode;
1161
- } else if (source.mode === null) {
1162
- delete global.mode;
1163
- }
1164
- }
1165
- if (hasOwn(source, "activeProfile")) {
1166
- const selector = sanitizeActiveProfile(source.activeProfile);
1167
- if (selector) {
1168
- const idx = findAccountIndexForSelector(global.accounts ?? [], selector);
1169
- global.activeProfile = idx === -1 ? selector : selectorFromAccount((global.accounts ?? [])[idx]);
1170
- } else if (source.activeProfile === null) {
1171
- delete global.activeProfile;
1172
- }
1173
- }
1174
- if (hasOwn(source, "openpondProfile")) {
1175
- const profile = sanitizeLocalOpenPondProfile(source.openpondProfile);
1176
- if (profile) {
1177
- global.openpondProfile = profile;
1178
- } else if (source.openpondProfile === null) {
1179
- delete global.openpondProfile;
1180
- }
1181
- }
1182
- }
1183
- async function updateGlobalConfig(update) {
1184
- const home = resolveOpenPondHome();
1185
- await initializeHome(home);
1186
- return await updateAccountConfiguration(home, (raw) => {
1187
- const current = normalizeGlobalConfig(raw);
1188
- update(current);
1189
- return current;
1190
- });
1191
- }
1192
- async function loadGlobalConfig() {
1193
- const home = resolveOpenPondHome();
1194
- await initializeHome(home);
1195
- return normalizeGlobalConfig(await readAccountConfiguration(home));
1196
- }
1197
- async function loadConfig(options = {}) {
1198
- const global = await loadGlobalConfig();
1199
- const accounts = global.accounts ?? [];
1200
- const requested = resolveRequestedProfile(
1201
- global,
1202
- options.account,
1203
- options.baseUrl
1204
- );
1205
- const idx = findAccountIndexForSelector(accounts, requested, {
1206
- requireUnambiguous: true
1207
- });
1208
- const account = idx === -1 ? null : accounts[idx];
1209
- const session = account?.session;
1210
- return {
1211
- ...global,
1212
- activeProfile: account ? selectorFromAccount(account) : requested,
1213
- apiKey: account?.apiKey,
1214
- baseUrl: account?.baseUrl,
1215
- apiBaseUrl: account?.apiBaseUrl,
1216
- chatApiBaseUrl: account?.chatApiBaseUrl,
1217
- token: session?.token,
1218
- appId: session?.appId,
1219
- conversationId: session?.conversationId
1220
- };
1221
- }
1222
- async function listConfiguredProfiles() {
1223
- const global = await loadGlobalConfig();
1224
- const activeProfile = sanitizeActiveProfile(global.activeProfile);
1225
- return (global.accounts ?? []).map((account) => {
1226
- const handle = normalizeHandle(account.handle) ?? DEFAULT_ACCOUNT_HANDLE;
1227
- return {
1228
- handle,
1229
- baseUrl: normalizeBaseUrl(account.baseUrl),
1230
- apiBaseUrl: normalizeBaseUrl(account.apiBaseUrl),
1231
- chatApiBaseUrl: normalizeBaseUrl(account.chatApiBaseUrl),
1232
- environment: account.environment?.trim() || null,
1233
- isActive: Boolean(
1234
- activeProfile && accountMatchesSelector({ ...account, handle }, activeProfile)
1235
- ),
1236
- hasApiKey: Boolean(account.apiKey?.trim()),
1237
- hasSessionToken: Boolean(account.session?.token?.trim()),
1238
- sessionAppId: account.session?.appId ?? null,
1239
- sessionConversationId: account.session?.conversationId ?? null
1240
- };
1241
- });
1242
- }
1243
- async function setActiveProfile(handle, options = {}) {
1244
- const requestedHandle = requireHandle(handle);
1245
- const requestedBaseUrl = normalizeBaseUrl(options.baseUrl);
1246
- let selectedIndex = -1;
1247
- await updateGlobalConfig((global) => {
1248
- const accounts = global.accounts ?? [];
1249
- selectedIndex = findAccountIndexForSelector(
1250
- accounts,
1251
- requestedBaseUrl ? { handle: requestedHandle, baseUrl: requestedBaseUrl } : { handle: requestedHandle },
1252
- { requireUnambiguous: true }
1253
- );
1254
- if (selectedIndex === -1) throw new Error(`profile not found: ${requestedHandle}`);
1255
- global.activeProfile = selectorFromAccount(accounts[selectedIndex]);
1256
- });
1257
- const profiles = await listConfiguredProfiles();
1258
- return profiles.find((profile) => profile.isActive) ?? profiles[selectedIndex];
1259
- }
1260
- async function saveProfileApiKey(input) {
1261
- const handle = requireHandle(input.handle);
1262
- const apiKey = requireApiKey(input.apiKey);
1263
- const baseUrl = normalizeBaseUrl(input.baseUrl);
1264
- const apiBaseUrl = normalizeBaseUrl(input.apiBaseUrl);
1265
- const chatApiBaseUrl = normalizeBaseUrl(input.chatApiBaseUrl);
1266
- let savedSelector = { handle };
1267
- await updateGlobalConfig((global) => {
1268
- const accounts = global.accounts ?? [];
1269
- const account = ensureAccount(accounts, handle, baseUrl);
1270
- account.apiKey = apiKey;
1271
- if (baseUrl) account.baseUrl = baseUrl;
1272
- if (apiBaseUrl) account.apiBaseUrl = apiBaseUrl;
1273
- else if (input.apiBaseUrl === null) delete account.apiBaseUrl;
1274
- if (chatApiBaseUrl) account.chatApiBaseUrl = chatApiBaseUrl;
1275
- else if (input.chatApiBaseUrl === null) delete account.chatApiBaseUrl;
1276
- if (input.environment === null) delete account.environment;
1277
- else if (typeof input.environment === "string" && input.environment.trim()) {
1278
- account.environment = input.environment.trim();
1279
- }
1280
- global.accounts = accounts;
1281
- savedSelector = selectorFromAccount(account);
1282
- if (input.setActive !== false) global.activeProfile = savedSelector;
1283
- });
1284
- const profiles = await listConfiguredProfiles();
1285
- const saved = profiles.find((profile) => {
1286
- if (!handleEquals(profile.handle, savedSelector.handle)) return false;
1287
- if (!baseUrl) return true;
1288
- return normalizeBaseUrl(profile.baseUrl) === baseUrl;
1289
- });
1290
- if (!saved) {
1291
- throw new Error(`failed to save profile: ${handle}`);
1292
- }
1293
- return saved;
1294
- }
1295
- async function saveGlobalConfig(next) {
1296
- await updateGlobalConfig((current) => {
1297
- applyTopLevelPatch(current, next);
1298
- applyAccountPatch(current, next, { undefinedDeletes: false });
1299
- });
1300
- }
1301
-
1302
- // ../../packages/cloud/src/cache.ts
1303
- import { createHash } from "node:crypto";
1304
- var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1e3;
1305
- function buildCacheKey(scope) {
1306
- return createHash("sha256").update(JSON.stringify([scope.apiBase.replace(/\/$/, ""), scope.apiKey.trim()])).digest("hex");
1307
- }
1308
- async function cached(namespace, params) {
1309
- const entry = await readCache(resolveOpenPondHome(), namespace, buildCacheKey(params), { allowStale: true });
1310
- if (!entry || Date.now() - Date.parse(entry.updatedAt) >= (params.ttlMs ?? DEFAULT_CACHE_TTL_MS)) return null;
1311
- return entry.payload;
1312
- }
1313
- async function getCachedApps(params) {
1314
- return cached("cloud.apps", params);
1315
- }
1316
- async function setCachedApps(params) {
1317
- await writeCache(resolveOpenPondHome(), "cloud.apps", buildCacheKey(params), params.apps);
1318
- }
1319
- async function getCachedTools(params) {
1320
- return cached("cloud.tools", params);
1321
- }
1322
- async function setCachedTools(params) {
1323
- await writeCache(resolveOpenPondHome(), "cloud.tools", buildCacheKey(params), params.tools);
1324
- }
1325
-
1326
- // ../../packages/cloud/src/sandbox/types/runtime-profiles.ts
1327
- var SANDBOX_RUNTIME_PROFILE_IDS = [
1328
- "openpond-generic-v1",
1329
- "openpond-work-v1",
1330
- "openpond-coding-core-v1",
1331
- "openpond-agent-harness-v1"
1332
- ];
1333
-
1334
- export {
1335
- deployApp,
1336
- getDeploymentLogs,
1337
- getDeploymentStatus,
1338
- getLatestDeploymentForApp,
1339
- getDeploymentDetail,
1340
- listApps,
1341
- createRepo,
1342
- updateAppCodeVisibility,
1343
- createHeadlessApps,
1344
- getTemplateStatus,
1345
- listTemplateBranches,
1346
- deployLatestTemplate,
1347
- updateAppEnvironment,
1348
- getAppEnvironment,
1349
- listUserTools,
1350
- createAgentFromPrompt,
1351
- getUserPerformance,
1352
- getAppRuntimeSummary,
1353
- getOpenPondAccount,
1354
- checkOpenPondApiHealth,
1355
- runAssistantMode,
1356
- executeUserTool,
1357
- submitBacktestRun,
1358
- submitBacktestTx,
1359
- submitBacktestDetail,
1360
- executeHostedTool,
1361
- loadGlobalConfig,
1362
- loadConfig,
1363
- listConfiguredProfiles,
1364
- setActiveProfile,
1365
- saveProfileApiKey,
1366
- saveGlobalConfig,
1367
- DEFAULT_CACHE_TTL_MS,
1368
- getCachedApps,
1369
- setCachedApps,
1370
- getCachedTools,
1371
- setCachedTools,
1372
- SANDBOX_RUNTIME_PROFILE_IDS
1373
- };