openpond 0.2.42 → 0.2.44

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 (181) hide show
  1. package/dist/app-server.d.ts +4473 -653
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/actions-command-5IEZEP6W.js +2 -0
  4. package/dist/chunks/{app-layer-ETI5QXQ3.js → app-layer-7SPLENWD.js} +1 -1
  5. package/dist/chunks/app-server-runtime-NQ2BYPGK.js +2 -0
  6. package/dist/chunks/apps-XQ7PHJTD.js +2 -0
  7. package/dist/chunks/{chunk-NT2UKDF7.js → chunk-2CXJK2M3.js} +1 -1
  8. package/dist/chunks/{chunk-MOMDY22U.js → chunk-36RCXSEJ.js} +1 -1
  9. package/dist/chunks/chunk-3QC2DDQ5.js +2 -0
  10. package/dist/chunks/chunk-3XDFNA7W.js +2 -0
  11. package/dist/chunks/chunk-4S4WH65X.js +3 -0
  12. package/dist/chunks/chunk-4TMC5F2P.js +5 -0
  13. package/dist/chunks/{chunk-Z7VAZVC5.js → chunk-65QCNUGE.js} +283 -202
  14. package/dist/chunks/{chunk-JYM3O4G7.js → chunk-ANVOHBUV.js} +1 -1
  15. package/dist/chunks/chunk-ARJUNUH6.js +5 -0
  16. package/dist/chunks/{chunk-LRGLV6JX.js → chunk-B3O2GAQH.js} +1 -1
  17. package/dist/chunks/{chunk-BJSXEGWG.js → chunk-CEEZ7Y2J.js} +1 -1
  18. package/dist/chunks/{chunk-ZG7QX66E.js → chunk-CR6CDOKS.js} +8 -8
  19. package/dist/chunks/{chunk-AANEPCEZ.js → chunk-DZVVGU6K.js} +1 -1
  20. package/dist/chunks/chunk-HY2Q7EDK.js +4 -0
  21. package/dist/chunks/chunk-IT4AT6LB.js +42 -0
  22. package/dist/chunks/{chunk-VQG25QBJ.js → chunk-KPDWQCF6.js} +1 -1
  23. package/dist/chunks/chunk-KRC2S5QF.js +5 -0
  24. package/dist/chunks/{chunk-AT6XYNQ5.js → chunk-L6HCBIAU.js} +1 -1
  25. package/dist/chunks/chunk-LNEOLOK2.js +13 -0
  26. package/dist/chunks/chunk-NM2GYDPA.js +19 -0
  27. package/dist/chunks/{chunk-QZ4KTU65.js → chunk-OI2N2636.js} +1 -1
  28. package/dist/chunks/{chunk-6UGTLC7Z.js → chunk-OJVIH7J6.js} +1 -1
  29. package/dist/chunks/{chunk-TPMXLA5Y.js → chunk-OMM4ZO7E.js} +7 -7
  30. package/dist/chunks/{chunk-S2MLTFZF.js → chunk-OQPFFKU6.js} +1 -1
  31. package/dist/chunks/{chunk-VTWY3U4M.js → chunk-PEYA2Q7Q.js} +1 -1
  32. package/dist/chunks/{chunk-2VTXKZNK.js → chunk-QID62K65.js} +5 -5
  33. package/dist/chunks/{chunk-76YP4FDQ.js → chunk-RAWEO7SJ.js} +2 -2
  34. package/dist/chunks/{chunk-BAQ3DWH2.js → chunk-W5NQ2DI7.js} +12 -12
  35. package/dist/chunks/{chunk-ZLQQUZH7.js → chunk-X2B4MN6W.js} +1 -1
  36. package/dist/chunks/{chunk-EEJ3HL6O.js → chunk-YF6IDYTS.js} +1 -1
  37. package/dist/chunks/{chunk-R6YJY7F2.js → chunk-YOOPTMQK.js} +1 -1
  38. package/dist/chunks/{chunk-MJC26GOX.js → chunk-Z3D4C7BG.js} +6 -6
  39. package/dist/chunks/{chunk-QUNRWDVO.js → chunk-Z6ZR5O3J.js} +3 -3
  40. package/dist/chunks/{chunk-SUAT5DR4.js → chunk-ZEVARU6J.js} +5 -5
  41. package/dist/chunks/cli-OJU6NQSA.js +2 -0
  42. package/dist/chunks/{configuration-command-N2FD7DWB.js → configuration-command-LDPUCHVH.js} +1 -1
  43. package/dist/chunks/core-commands-UZL5RF2M.js +2 -0
  44. package/dist/chunks/datasets-42AZHVSV.js +13 -0
  45. package/dist/chunks/desktop-test-DI76HKS7.js +3 -0
  46. package/dist/chunks/dist-6YP37XI5.js +2 -0
  47. package/dist/chunks/experiments-Z3S35BYN.js +2 -0
  48. package/dist/chunks/{extension-7GYFAHRP.js → extension-JEUZZJ5X.js} +1 -1
  49. package/dist/chunks/{help-MD7Z72QS.js → help-4F4QGL4C.js} +1 -1
  50. package/dist/chunks/hosted-harness-runtime-VZNYNQ6T.js +2 -0
  51. package/dist/chunks/hosted-profile-compiler-JXLPR7SX.js +2 -0
  52. package/dist/chunks/{hosted-profile-evaluation-control-VV2NXFBE.js → hosted-profile-evaluation-control-Q54YXXIM.js} +1 -1
  53. package/dist/chunks/{hosted-profile-evaluation-inspection-XMPRKON6.js → hosted-profile-evaluation-inspection-7WESM3ZH.js} +1 -1
  54. package/dist/chunks/hosted-profile-evaluation-preparation-QP24PYBL.js +3 -0
  55. package/dist/chunks/opchat-UFWWVJL6.js +3 -0
  56. package/dist/chunks/organizations-SBBIOF6O.js +2 -0
  57. package/dist/chunks/{profile-BZDCYKGL.js → profile-ESULTWDN.js} +1 -1
  58. package/dist/chunks/project-agent-IBHUQ3JX.js +2 -0
  59. package/dist/chunks/sandbox-command-PAJAIMWM.js +2 -0
  60. package/dist/chunks/{sandbox-template-ZYXK4QCI.js → sandbox-template-7WHGNVM6.js} +1 -1
  61. package/dist/chunks/src-5MJSO3UD.js +326 -0
  62. package/dist/chunks/{src-5Z35O6L7.js → src-A3OVZOSV.js} +1 -1
  63. package/dist/chunks/{teams-bot-WXGP3PA6.js → teams-bot-YMCDLBGT.js} +1 -1
  64. package/dist/chunks/{workspaces-7WY3ZVQW.js → workspaces-ZZ7R5BUL.js} +1 -1
  65. package/dist/cli.js +1 -1
  66. package/dist/index.js +1 -1
  67. package/dist/profile/local-profile.d.ts +2 -0
  68. package/dist/web/assets/App-6AQXN2SM.js +226 -0
  69. package/dist/web/assets/{AppDialog-DMymIOcU.js → AppDialog-CV3ddujB.js} +1 -1
  70. package/dist/web/assets/AppTerminalPanel-dhbGOO_K.js +2 -0
  71. package/dist/web/assets/{AppsView-CUrRKOiz.js → AppsView-Bxa-9BF2.js} +1 -1
  72. package/dist/web/assets/{BrowserSidebar-C5psWtoF.js → BrowserSidebar-BLwL2FOG.js} +1 -1
  73. package/dist/web/assets/{CartesianChart-DVGs4fGn.js → CartesianChart-BOxN-Su1.js} +1 -1
  74. package/dist/web/assets/{CollaborationTabs-D6eqNw88.js → CollaborationTabs-DTmJvNJx.js} +1 -1
  75. package/dist/web/assets/{CommandMenu--GRjuf3j.js → CommandMenu-DggN2ygj.js} +1 -1
  76. package/dist/web/assets/{CommunityView-CHGceVA_.js → CommunityView-CuDrYOIf.js} +1 -1
  77. package/dist/web/assets/{ComposerCreateImproveStrip-D08PAaxI.js → ComposerCreateImproveStrip-BrduENlL.js} +1 -1
  78. package/dist/web/assets/{GetStartedView-BPZcWzsG.js → GetStartedView-Db1IEWzv.js} +1 -1
  79. package/dist/web/assets/HostedModelLearningReview-kofNdPAe.js +1 -0
  80. package/dist/web/assets/{HostedModelLearningSettings-BmEMKcoy.js → HostedModelLearningSettings-6ij3nwWD.js} +1 -1
  81. package/dist/web/assets/{LabModelVersionDetailPage-CX5pOLl2.js → LabModelVersionDetailPage-C7Maqcit.js} +1 -1
  82. package/dist/web/assets/{LabSkillSidebar-C4vAz_0b.js → LabSkillSidebar-Bz0U-Nmw.js} +1 -1
  83. package/dist/web/assets/LabsRoute-Ch1N-e2S.js +52 -0
  84. package/dist/web/assets/LabsRoute-Dw6-12kt.css +1 -0
  85. package/dist/web/assets/MainChatThread-BJbhZOvs.js +2 -0
  86. package/dist/web/assets/{MainPane-EwtIf5_E.js → MainPane-Cs2Kng_k.js} +4 -4
  87. package/dist/web/assets/{MarkdownText-Bj9uRWtM.js → MarkdownText-BhzHRq1J.js} +1 -1
  88. package/dist/web/assets/{NativeSkillSidebar-U7PHw5DO.js → NativeSkillSidebar-LU-PhEhW.js} +1 -1
  89. package/dist/web/assets/{NewExperienceSwitcher-DneuamYK.js → NewExperienceSwitcher-Bi_gpHLG.js} +1 -1
  90. package/dist/web/assets/{NewProjectDialog-CrpXYCYV.js → NewProjectDialog-B8pWvSkq.js} +1 -1
  91. package/dist/web/assets/{OutputsPage-C1SPqz45.js → OutputsPage-BkGI0kHp.js} +1 -1
  92. package/dist/web/assets/{ProjectsPage-CCW3mGQb.js → ProjectsPage-Ca8_iEWu.js} +1 -1
  93. package/dist/web/assets/{RightChatPanelStack-D7ECzLfp.js → RightChatPanelStack-DjEdxsq8.js} +1 -1
  94. package/dist/web/assets/{RightSidebarHomePanel-B-4r-yLc.js → RightSidebarHomePanel-6pygznxX.js} +1 -1
  95. package/dist/web/assets/{ScheduledWorkPage-XjmcT64Z.js → ScheduledWorkPage-BSiOxxAH.js} +1 -1
  96. package/dist/web/assets/{SettingsView-BEBpD7W0.js → SettingsView-1XN7KLBl.js} +3 -3
  97. package/dist/web/assets/{TeamChatView-n9GnPY4F.js → TeamChatView-BGLCPTen.js} +2 -2
  98. package/dist/web/assets/{TerminalOverlay-CNaaMo7W.js → TerminalOverlay-DHkS2cVJ.js} +1 -1
  99. package/dist/web/assets/{TrainingCreationPanel-CEEXMmC5.js → TrainingCreationPanel-Dneamjzh.js} +1 -1
  100. package/dist/web/assets/{TrainingDraftPanel-CwyoL_Dy.js → TrainingDraftPanel-Cfh59jLZ.js} +1 -1
  101. package/dist/web/assets/{UsageSettingsSection-BNjgosYd.js → UsageSettingsSection-C9l1KY-O.js} +1 -1
  102. package/dist/web/assets/{WorkSidebarPanel-BatJltaq.js → WorkSidebarPanel-CEnO-Txp.js} +1 -1
  103. package/dist/web/assets/{WorkspaceDiffPanel-Cbr7qcqm.js → WorkspaceDiffPanel-BiuQBflC.js} +3 -3
  104. package/dist/web/assets/{WorkspaceEnvironmentMenu-DYu-PXRv.js → WorkspaceEnvironmentMenu-Dr-E0c1j.js} +1 -1
  105. package/dist/web/assets/{WorkspaceGitDialogs-BoamHtgk.js → WorkspaceGitDialogs-mE3Og6Zo.js} +1 -1
  106. package/dist/web/assets/{WorkspaceMonacoEditor-yg83VXk5.js → WorkspaceMonacoEditor-DPZ0n0G9.js} +60 -60
  107. package/dist/web/assets/{arrow-up-right-CN9lcbsD.js → arrow-up-right-DU2KsZD-.js} +1 -1
  108. package/dist/web/assets/{clipboard-DfLDGpSz.js → clipboard-g2b4_k81.js} +1 -1
  109. package/dist/web/assets/{cloud-upload-hk4EBTu-.js → cloud-upload-P2bDOPsQ.js} +1 -1
  110. package/dist/web/assets/cssMode-CPbPVAUt.js +1 -0
  111. package/dist/web/assets/{folder-open-BmhusYOx.js → folder-open-BmsONNsr.js} +1 -1
  112. package/dist/web/assets/{folder-plus-Bedc_RqV.js → folder-plus-B18NgUxy.js} +1 -1
  113. package/dist/web/assets/{git-commit-horizontal-D2Zvz4i7.js → git-commit-horizontal-enxGCV_e.js} +1 -1
  114. package/dist/web/assets/htmlMode-DiV88uQv.js +1 -0
  115. package/dist/web/assets/index-B9VSiz_z.css +1 -0
  116. package/dist/web/assets/{index-CpTHPmvd.js → index-vfpCN9zy.js} +6 -6
  117. package/dist/web/assets/{info-CayXQYUk.js → info-DmuSBIYe.js} +1 -1
  118. package/dist/web/assets/{jsonMode-_Ywm0ZC4.js → jsonMode-BaeOjuKU.js} +4 -4
  119. package/dist/web/assets/{lspLanguageFeatures-Caw_TPYu.js → lspLanguageFeatures-D8To0CQA.js} +1 -1
  120. package/dist/web/assets/{minimize-2-sPQtjkx8.js → minimize-2-C2xnEzCe.js} +1 -1
  121. package/dist/web/assets/monaco.contribution-DbrACt99.js +2 -0
  122. package/dist/web/assets/{monaco.contribution-CngZuH1Z.js → monaco.contribution-DgTFvG2Q.js} +2 -2
  123. package/dist/web/assets/{monaco.contribution-DmEqb8O2.js → monaco.contribution-JW3MxX6k.js} +2 -2
  124. package/dist/web/assets/{monaco.contribution-Bqi-s2-g.js → monaco.contribution-bytkwn0O.js} +2 -2
  125. package/dist/web/assets/{monitor-BuaCDSIZ.js → monitor-mtHVW7gU.js} +1 -1
  126. package/dist/web/assets/{python-D6SoZF70.js → python-DAPe0Urm.js} +1 -1
  127. package/dist/web/assets/{refresh-cw-DmpWkVF6.js → refresh-cw-Dvm_Pq3U.js} +1 -1
  128. package/dist/web/assets/{save-Di43Sc13.js → save-B2eVAjW6.js} +1 -1
  129. package/dist/web/assets/{square-Cui64whj.js → square-16bX2k2i.js} +1 -1
  130. package/dist/web/assets/toggleHighContrast-BgpFWRpS.css +1 -0
  131. package/dist/web/assets/{toggleHighContrast-e8XiQRTr.js → toggleHighContrast-Ce0YhEQg.js} +1 -1
  132. package/dist/web/assets/{tsMode-Cvh0MpFm.js → tsMode-CnvMmHz6.js} +1 -1
  133. package/dist/web/assets/{upload-Dphgk6dy.js → upload-COPbAaD-.js} +1 -1
  134. package/dist/web/assets/{useLocalAgentSchedules-CDN8WQld.js → useLocalAgentSchedules-C-Wjm5HK.js} +1 -1
  135. package/dist/web/assets/{useSessionTurnCache-Bvcc_al6.js → useSessionTurnCache-BfVbncMB.js} +1 -1
  136. package/dist/web/assets/{wifi-off-CIWXrn3o.js → wifi-off-C9iLbCC-.js} +1 -1
  137. package/dist/web/assets/{workers-XU4YZxHD.js → workers-BXh_u8Fr.js} +1 -1
  138. package/dist/web/assets/{yaml-BZ0UGaZH.js → yaml-CRSr9x6_.js} +1 -1
  139. package/dist/web/index.html +5 -5
  140. package/docs/command-reference.md +8 -1
  141. package/package.json +4 -2
  142. package/dist/chunks/actions-command-6EMO4BIK.js +0 -2
  143. package/dist/chunks/app-server-runtime-CJ7SJTTF.js +0 -2
  144. package/dist/chunks/apps-LH5AJCUI.js +0 -2
  145. package/dist/chunks/chunk-2Z6H32OC.js +0 -2
  146. package/dist/chunks/chunk-3CKJETWW.js +0 -2
  147. package/dist/chunks/chunk-4F2Q4CFS.js +0 -4
  148. package/dist/chunks/chunk-ANCZVBMI.js +0 -42
  149. package/dist/chunks/chunk-AUOMUBLE.js +0 -3
  150. package/dist/chunks/chunk-GC4OCTP6.js +0 -2
  151. package/dist/chunks/chunk-KCENW4ME.js +0 -2
  152. package/dist/chunks/chunk-OUN6VQDO.js +0 -5
  153. package/dist/chunks/chunk-TPOW52DO.js +0 -13
  154. package/dist/chunks/chunk-VI3ZF54E.js +0 -5
  155. package/dist/chunks/chunk-XJAK6DDB.js +0 -5
  156. package/dist/chunks/chunk-ZQWXPDCB.js +0 -19
  157. package/dist/chunks/cli-FM3DESGO.js +0 -2
  158. package/dist/chunks/core-commands-D2MJ7QFZ.js +0 -2
  159. package/dist/chunks/datasets-UYIZCMNZ.js +0 -13
  160. package/dist/chunks/desktop-test-IWDHFDSZ.js +0 -3
  161. package/dist/chunks/dist-JPRXSUXC.js +0 -2
  162. package/dist/chunks/experiments-Q6TAHJV3.js +0 -2
  163. package/dist/chunks/hosted-harness-runtime-LMYM7PYZ.js +0 -2
  164. package/dist/chunks/hosted-profile-compiler-H2J5HFT3.js +0 -2
  165. package/dist/chunks/hosted-profile-evaluation-preparation-ZZ3MZJDR.js +0 -3
  166. package/dist/chunks/opchat-URWW53CK.js +0 -3
  167. package/dist/chunks/organizations-BPBJV7LZ.js +0 -2
  168. package/dist/chunks/project-agent-U6YNYPHS.js +0 -2
  169. package/dist/chunks/sandbox-command-TTLFWUXV.js +0 -2
  170. package/dist/chunks/src-NABQMSR3.js +0 -325
  171. package/dist/web/assets/App-BpYDvJ6x.js +0 -226
  172. package/dist/web/assets/AppTerminalPanel-CFsUD-di.js +0 -2
  173. package/dist/web/assets/HostedModelLearningReview-DiS-n3XW.js +0 -1
  174. package/dist/web/assets/LabsRoute-BL04wKhE.js +0 -52
  175. package/dist/web/assets/LabsRoute-Cq9XLVDP.css +0 -1
  176. package/dist/web/assets/MainChatThread-BSwHDALr.js +0 -2
  177. package/dist/web/assets/cssMode-DkhTpCaH.js +0 -1
  178. package/dist/web/assets/htmlMode-Bf3_KJ2b.js +0 -1
  179. package/dist/web/assets/index-DUIWDN8o.css +0 -1
  180. package/dist/web/assets/monaco.contribution-DKY5M77J.js +0 -2
  181. package/dist/web/assets/toggleHighContrast-B7NOMXDY.css +0 -1
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as n}from"./chunk-FTQLQJQV.js";var s="127.0.0.1";var f="0.2.42",m="You are OpenPond Chat. Respond in the user's language. If the user's latest message is language-neutral, ambiguous, or only a short test, respond in English. Be concise and directly answer the latest request. Do not use emojis. Use Markdown when it improves scanability. If you emit reasoning or thinking content, keep it sparse and user-readable: at most one short sentence for major progress, decisions, or blockers. Omit reasoning for routine searches, reads, tool calls, and obvious next steps. Do not restate the user request, narrate every action, or include code blocks, code excerpts, diffs, raw tool payloads, or markdown examples in reasoning. Put necessary code or exact snippets only in the final assistant answer. When the user asks to show or preview an image that is available as a workspace path or signed image URL, use Markdown image syntax like ![description](path-or-url) instead of a bare path or raw HTML. For workspace-backed answers, use a Codex-style shape: brief outcome first, then Changed Files if files changed, then Verification if checks ran. End with a concise final answer that summarizes the result and verification when relevant. Do not mention raw tool JSON, internal repo paths, or origin/remote URLs unless the user explicitly asks for them or they are necessary to explain a git/deploy failure.";import{randomUUID as p}from"node:crypto";import i from"node:path";import{fileURLToPath as c}from"node:url";function u(){return new Date().toISOString()}n(u,"now");function l(e){if(typeof e=="string")return e;if(e instanceof Error)return e.message||e.name;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}n(l,"textFromUnknown");function w(e){if(!e||typeof e!="object")return"";let t=e;for(let r of["delta","text","output","chunk","message"])if(typeof t[r]=="string")return t[r];return t.delta&&typeof t.delta=="object"?l(t.delta):""}n(w,"extractDelta");function x(e){return{id:p(),timestamp:u(),...e}}n(x,"event");function k(e){let t=e.replace(/^https?:\/\//,""),[r,o]=t.split(":");return{host:r||s,port:o?Number.parseInt(o,10):17874}}n(k,"parseListen");function b(e){return(process.argv[1]?i.resolve(process.argv[1]):"")===i.resolve(c(e))}n(b,"isCliEntrypoint");export{s as a,f as b,m as c,u as d,l as e,w as f,x as g,k as h,b as i};
2
+ import{a as n}from"./chunk-FTQLQJQV.js";var s="127.0.0.1";var f="0.2.44",m="You are OpenPond Chat. Respond in the user's language. If the user's latest message is language-neutral, ambiguous, or only a short test, respond in English. Be concise and directly answer the latest request. Do not use emojis. Use Markdown when it improves scanability. If you emit reasoning or thinking content, keep it sparse and user-readable: at most one short sentence for major progress, decisions, or blockers. Omit reasoning for routine searches, reads, tool calls, and obvious next steps. Do not restate the user request, narrate every action, or include code blocks, code excerpts, diffs, raw tool payloads, or markdown examples in reasoning. Put necessary code or exact snippets only in the final assistant answer. When the user asks to show or preview an image that is available as a workspace path or signed image URL, use Markdown image syntax like ![description](path-or-url) instead of a bare path or raw HTML. For workspace-backed answers, use a Codex-style shape: brief outcome first, then Changed Files if files changed, then Verification if checks ran. End with a concise final answer that summarizes the result and verification when relevant. Do not mention raw tool JSON, internal repo paths, or origin/remote URLs unless the user explicitly asks for them or they are necessary to explain a git/deploy failure.";import{randomUUID as p}from"node:crypto";import i from"node:path";import{fileURLToPath as c}from"node:url";function u(){return new Date().toISOString()}n(u,"now");function l(e){if(typeof e=="string")return e;if(e instanceof Error)return e.message||e.name;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}n(l,"textFromUnknown");function w(e){if(!e||typeof e!="object")return"";let t=e;for(let r of["delta","text","output","chunk","message"])if(typeof t[r]=="string")return t[r];return t.delta&&typeof t.delta=="object"?l(t.delta):""}n(w,"extractDelta");function x(e){return{id:p(),timestamp:u(),...e}}n(x,"event");function k(e){let t=e.replace(/^https?:\/\//,""),[r,o]=t.split(":");return{host:r||s,port:o?Number.parseInt(o,10):17874}}n(k,"parseListen");function b(e){return(process.argv[1]?i.resolve(process.argv[1]):"")===i.resolve(c(e))}n(b,"isCliEntrypoint");export{s as a,f as b,m as c,u as d,l as e,w as f,x as g,k as h,b as i};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{b as E}from"./chunk-MOMDY22U.js";import{a as u,b as v,c as R,e as P,l as m}from"./chunk-HZP5U2AA.js";import{b as n}from"./chunk-ES2ISFJC.js";import{a as f}from"./chunk-FTQLQJQV.js";var C=n.object({profileId:u,sourceRevision:n.string().trim().min(1).max(240),harnessRelease:P}).strict(),I=n.object({kind:n.enum(["run","suite","comparison"]),id:u,contentHash:v}).strict(),g=n.object({schemaVersion:n.literal("openpond.profileEvaluationReport.v1"),id:u,createdAt:R,testedSources:n.array(C).min(1).max(100),tasksetReleases:n.array(P).min(1).max(100),metricPolicyHashes:n.array(v).min(1).max(100),modelConfigurationHashes:n.array(v).min(1).max(100),evidence:n.array(I).min(1).max(100),summary:n.object({totalChecks:n.number().int().nonnegative(),passedChecks:n.number().int().nonnegative(),failedChecks:n.number().int().nonnegative(),unscoredChecks:n.number().int().nonnegative(),meanScore:n.number().min(0).max(1).nullable()}).strict()}).strict().superRefine((e,i)=>{let{summary:t}=e;t.passedChecks+t.failedChecks+t.unscoredChecks!==t.totalChecks&&i.addIssue({code:"custom",path:["summary"],message:"Report check counts must add up."}),new Set(e.evidence.map(({kind:l,id:a})=>`${l}:${a}`)).size!==e.evidence.length&&i.addIssue({code:"custom",path:["evidence"],message:"Report evidence must be unique."})}),w=g.safeExtend({contentHash:v});function S(e){let i=g.parse(e);return w.parse({...i,contentHash:m(i)})}f(S,"createProfileEvaluationReport");function y(e){let i=w.parse(e),{contentHash:t,...l}=i;if(m(l)!==t)throw new Error("Profile evaluation report content hash differs from its source bytes.");return i}f(y,"assertProfileEvaluationReport");var x=n.object({id:u,runIds:n.array(u).min(2).max(100)}).strict();function z(e){return async i=>{let t=x.parse(i),l=await e.selectedProfile();if(!l)throw new Error("Select a Profile before comparing its evaluation runs.");let a=[];for(let r of t.runIds){let s=await e.store.getProfileEvaluationRun(r);if(!s||m(s.profileRef)!==m(l.ref))throw new Error(`Profile evaluation run ${r} is unavailable in the selected Profile.`);a.push({manifest:s.manifest,result:s.metric})}let o=await e.store.getProfileEvaluationComparison(t.id),c=E({id:t.id,members:a,createdAt:o?.createdAt??new Date().toISOString()});return e.store.saveProfileEvaluationComparison(l.ref,c)}}f(z,"createProfileEvaluationComparisonService");import{promises as d}from"node:fs";import h from"node:path";var j=n.object({id:u,evidenceKind:n.enum(["run","suite","comparison"]),evidenceId:u}).strict();function k(e){return h.join(e,"evals","reports")}f(k,"reportDirectory");async function b(e){let i=await d.lstat(e).catch(t=>{if(t.code==="ENOENT")return null;throw t});if(i&&(!i.isDirectory()||i.isSymbolicLink()))throw new Error("Profile evaluation report directory must be a regular directory.");i||await d.mkdir(e)}f(b,"ensureRegularDirectory");async function K(e){let i,t;if(e.evidenceKind==="run")i=[e.evidenceId],t="";else if(e.evidenceKind==="suite"){let o=await e.store.getProfileEvaluationSuiteRun(e.evidenceId);if(!o||o.profileId!==e.profileRef.profileId)throw new Error("Profile evaluation suite is unavailable.");i=o.members.map(c=>c.runManifest.id),t=o.contentHash}else{let o=await e.store.getProfileEvaluationComparison(e.evidenceId);if(!o)throw new Error("Profile evaluation comparison is unavailable.");i=o.members.map(c=>c.runManifest.id),t=o.contentHash}let l=await Promise.all(i.map(o=>e.store.getProfileEvaluationRun(o)));if(l.some(o=>!o||m(o.profileRef)!==m(e.profileRef)))throw new Error("Profile evaluation report is missing authorized run evidence.");let a=l;if(e.evidenceKind==="run"&&(t=a[0].contentHash),e.evidenceKind!=="run"){let o=e.evidenceKind==="suite"?(await e.store.getProfileEvaluationSuiteRun(e.evidenceId)).members.map(c=>c.runHash):(await e.store.getProfileEvaluationComparison(e.evidenceId)).members.map(c=>c.metricResultHash);for(let[c,r]of a.entries())if(e.evidenceKind==="suite"&&o[c]!==r.contentHash||e.evidenceKind==="comparison"&&o[c]!==r.metric.contentHash)throw new Error("Profile evaluation report evidence differs from retained member runs.")}return{runs:a,primary:{kind:e.evidenceKind,id:e.evidenceId,contentHash:t}}}f(K,"loadRuns");async function O(e){let i=j.parse(e.request),{runs:t,primary:l}=await K({store:e.store,profileRef:e.profileRef,evidenceKind:i.evidenceKind,evidenceId:i.evidenceId}),a=f(r=>[...new Map(r.map(s=>[m(s),s])).values()],"unique"),o=a(t.map(r=>m(r.manifest.metricPolicy))),c=t.map(r=>r.metric.value).filter(r=>r!==null);return S({schemaVersion:"openpond.profileEvaluationReport.v1",id:i.id,createdAt:new Date().toISOString(),testedSources:a(t.map(r=>({profileId:r.manifest.profileEvaluation.profileId,sourceRevision:r.manifest.profileEvaluation.sourceRevision,harnessRelease:r.manifest.profileEvaluation.harnessRelease}))),tasksetReleases:a(t.map(r=>r.manifest.tasksetRelease)),metricPolicyHashes:o,modelConfigurationHashes:a(t.map(r=>r.manifest.policy.kind==="model"?r.manifest.policy.configurationHash:m(r.manifest.policy))),evidence:[l,...t.filter(r=>l.kind!=="run"||r.manifest.id!==l.id).map(r=>({kind:"run",id:r.manifest.id,contentHash:r.contentHash}))],summary:{totalChecks:t.length,passedChecks:t.filter(r=>r.passed).length,failedChecks:t.filter(r=>!r.passed&&r.metric.value!==null).length,unscoredChecks:t.filter(r=>!r.passed&&r.metric.value===null).length,meanScore:o.length===1&&c.length===t.length?c.reduce((r,s)=>r+s,0)/c.length:null}})}f(O,"buildProfileEvaluationReport");function Q(e){return{list:f(async()=>{let l=await e.selectedProfile();if(!l)return[];let a=k(l.sourcePath),o=await d.lstat(a).catch(s=>{if(s.code==="ENOENT")return null;throw s});if(!o)return[];if(!o.isDirectory()||o.isSymbolicLink())throw new Error("Profile evaluation report directory is unsafe.");let c=await d.readdir(a,{withFileTypes:!0});return(await Promise.all(c.filter(s=>s.name.endsWith(".json")).map(async s=>{if(!s.isFile()||s.isSymbolicLink())throw new Error("Profile evaluation report must be a regular file.");let p=y(JSON.parse(await d.readFile(h.join(a,s.name),"utf8")));if(`${p.id}.json`!==s.name||p.testedSources.some(H=>H.profileId!==l.ref.profileId))throw new Error("Profile evaluation report differs from its source location.");return p}))).sort((s,p)=>p.createdAt.localeCompare(s.createdAt))},"list"),save:f(async l=>{let a=await e.selectedProfile();if(!a?.gitBacked)throw new Error("Select a Git-backed Profile before saving an evaluation report.");let o=await O({store:e.store,profileRef:a.ref,request:l}),c=h.join(a.sourcePath,"evals");await b(c);let r=k(a.sourcePath);return await b(r),await d.writeFile(h.join(r,`${o.id}.json`),`${JSON.stringify(o,null,2)}
2
+ import{b as E}from"./chunk-36RCXSEJ.js";import{a as u,b as v,c as R,e as P,l as m}from"./chunk-HZP5U2AA.js";import{b as n}from"./chunk-ES2ISFJC.js";import{a as f}from"./chunk-FTQLQJQV.js";var C=n.object({profileId:u,sourceRevision:n.string().trim().min(1).max(240),harnessRelease:P}).strict(),I=n.object({kind:n.enum(["run","suite","comparison"]),id:u,contentHash:v}).strict(),g=n.object({schemaVersion:n.literal("openpond.profileEvaluationReport.v1"),id:u,createdAt:R,testedSources:n.array(C).min(1).max(100),tasksetReleases:n.array(P).min(1).max(100),metricPolicyHashes:n.array(v).min(1).max(100),modelConfigurationHashes:n.array(v).min(1).max(100),evidence:n.array(I).min(1).max(100),summary:n.object({totalChecks:n.number().int().nonnegative(),passedChecks:n.number().int().nonnegative(),failedChecks:n.number().int().nonnegative(),unscoredChecks:n.number().int().nonnegative(),meanScore:n.number().min(0).max(1).nullable()}).strict()}).strict().superRefine((e,i)=>{let{summary:t}=e;t.passedChecks+t.failedChecks+t.unscoredChecks!==t.totalChecks&&i.addIssue({code:"custom",path:["summary"],message:"Report check counts must add up."}),new Set(e.evidence.map(({kind:l,id:a})=>`${l}:${a}`)).size!==e.evidence.length&&i.addIssue({code:"custom",path:["evidence"],message:"Report evidence must be unique."})}),w=g.safeExtend({contentHash:v});function S(e){let i=g.parse(e);return w.parse({...i,contentHash:m(i)})}f(S,"createProfileEvaluationReport");function y(e){let i=w.parse(e),{contentHash:t,...l}=i;if(m(l)!==t)throw new Error("Profile evaluation report content hash differs from its source bytes.");return i}f(y,"assertProfileEvaluationReport");var x=n.object({id:u,runIds:n.array(u).min(2).max(100)}).strict();function z(e){return async i=>{let t=x.parse(i),l=await e.selectedProfile();if(!l)throw new Error("Select a Profile before comparing its evaluation runs.");let a=[];for(let r of t.runIds){let s=await e.store.getProfileEvaluationRun(r);if(!s||m(s.profileRef)!==m(l.ref))throw new Error(`Profile evaluation run ${r} is unavailable in the selected Profile.`);a.push({manifest:s.manifest,result:s.metric})}let o=await e.store.getProfileEvaluationComparison(t.id),c=E({id:t.id,members:a,createdAt:o?.createdAt??new Date().toISOString()});return e.store.saveProfileEvaluationComparison(l.ref,c)}}f(z,"createProfileEvaluationComparisonService");import{promises as d}from"node:fs";import h from"node:path";var j=n.object({id:u,evidenceKind:n.enum(["run","suite","comparison"]),evidenceId:u}).strict();function k(e){return h.join(e,"evals","reports")}f(k,"reportDirectory");async function b(e){let i=await d.lstat(e).catch(t=>{if(t.code==="ENOENT")return null;throw t});if(i&&(!i.isDirectory()||i.isSymbolicLink()))throw new Error("Profile evaluation report directory must be a regular directory.");i||await d.mkdir(e)}f(b,"ensureRegularDirectory");async function K(e){let i,t;if(e.evidenceKind==="run")i=[e.evidenceId],t="";else if(e.evidenceKind==="suite"){let o=await e.store.getProfileEvaluationSuiteRun(e.evidenceId);if(!o||o.profileId!==e.profileRef.profileId)throw new Error("Profile evaluation suite is unavailable.");i=o.members.map(c=>c.runManifest.id),t=o.contentHash}else{let o=await e.store.getProfileEvaluationComparison(e.evidenceId);if(!o)throw new Error("Profile evaluation comparison is unavailable.");i=o.members.map(c=>c.runManifest.id),t=o.contentHash}let l=await Promise.all(i.map(o=>e.store.getProfileEvaluationRun(o)));if(l.some(o=>!o||m(o.profileRef)!==m(e.profileRef)))throw new Error("Profile evaluation report is missing authorized run evidence.");let a=l;if(e.evidenceKind==="run"&&(t=a[0].contentHash),e.evidenceKind!=="run"){let o=e.evidenceKind==="suite"?(await e.store.getProfileEvaluationSuiteRun(e.evidenceId)).members.map(c=>c.runHash):(await e.store.getProfileEvaluationComparison(e.evidenceId)).members.map(c=>c.metricResultHash);for(let[c,r]of a.entries())if(e.evidenceKind==="suite"&&o[c]!==r.contentHash||e.evidenceKind==="comparison"&&o[c]!==r.metric.contentHash)throw new Error("Profile evaluation report evidence differs from retained member runs.")}return{runs:a,primary:{kind:e.evidenceKind,id:e.evidenceId,contentHash:t}}}f(K,"loadRuns");async function O(e){let i=j.parse(e.request),{runs:t,primary:l}=await K({store:e.store,profileRef:e.profileRef,evidenceKind:i.evidenceKind,evidenceId:i.evidenceId}),a=f(r=>[...new Map(r.map(s=>[m(s),s])).values()],"unique"),o=a(t.map(r=>m(r.manifest.metricPolicy))),c=t.map(r=>r.metric.value).filter(r=>r!==null);return S({schemaVersion:"openpond.profileEvaluationReport.v1",id:i.id,createdAt:new Date().toISOString(),testedSources:a(t.map(r=>({profileId:r.manifest.profileEvaluation.profileId,sourceRevision:r.manifest.profileEvaluation.sourceRevision,harnessRelease:r.manifest.profileEvaluation.harnessRelease}))),tasksetReleases:a(t.map(r=>r.manifest.tasksetRelease)),metricPolicyHashes:o,modelConfigurationHashes:a(t.map(r=>r.manifest.policy.kind==="model"?r.manifest.policy.configurationHash:m(r.manifest.policy))),evidence:[l,...t.filter(r=>l.kind!=="run"||r.manifest.id!==l.id).map(r=>({kind:"run",id:r.manifest.id,contentHash:r.contentHash}))],summary:{totalChecks:t.length,passedChecks:t.filter(r=>r.passed).length,failedChecks:t.filter(r=>!r.passed&&r.metric.value!==null).length,unscoredChecks:t.filter(r=>!r.passed&&r.metric.value===null).length,meanScore:o.length===1&&c.length===t.length?c.reduce((r,s)=>r+s,0)/c.length:null}})}f(O,"buildProfileEvaluationReport");function Q(e){return{list:f(async()=>{let l=await e.selectedProfile();if(!l)return[];let a=k(l.sourcePath),o=await d.lstat(a).catch(s=>{if(s.code==="ENOENT")return null;throw s});if(!o)return[];if(!o.isDirectory()||o.isSymbolicLink())throw new Error("Profile evaluation report directory is unsafe.");let c=await d.readdir(a,{withFileTypes:!0});return(await Promise.all(c.filter(s=>s.name.endsWith(".json")).map(async s=>{if(!s.isFile()||s.isSymbolicLink())throw new Error("Profile evaluation report must be a regular file.");let p=y(JSON.parse(await d.readFile(h.join(a,s.name),"utf8")));if(`${p.id}.json`!==s.name||p.testedSources.some(H=>H.profileId!==l.ref.profileId))throw new Error("Profile evaluation report differs from its source location.");return p}))).sort((s,p)=>p.createdAt.localeCompare(s.createdAt))},"list"),save:f(async l=>{let a=await e.selectedProfile();if(!a?.gitBacked)throw new Error("Select a Git-backed Profile before saving an evaluation report.");let o=await O({store:e.store,profileRef:a.ref,request:l}),c=h.join(a.sourcePath,"evals");await b(c);let r=k(a.sourcePath);return await b(r),await d.writeFile(h.join(r,`${o.id}.json`),`${JSON.stringify(o,null,2)}
3
3
  `,{flag:"wx"}),o},"save")}}f(Q,"createProfileEvaluationReportService");export{z as a,O as b,Q as c};
@@ -1,12 +1,12 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as n}from"./chunk-FTQLQJQV.js";var k="https://openpond.ai",U="https://api.openpond.ai",N="https://api.openpond.ai/opchat/v1";function C(o){let e=o.trim().replace(/\/$/,"");if(!e)throw new Error("sandbox API URL must be non-empty");let t=new URL(e),r=t.pathname.replace(/\/$/,"");return r.endsWith("/v1/sandboxes")||r.endsWith("/api/sandboxes")?`${t.origin}${r}`:r.endsWith("/v1")?`${t.origin}${r}/sandboxes`:Q(t.hostname)?`${t.origin}${r}/v1/sandboxes`:t.origin===k?`${U}/v1/sandboxes`:`${t.origin}${r}/api/sandboxes`}n(C,"normalizeSandboxApiUrl");function L(o){let e="/sandboxes";if(!o.endsWith(e))throw new Error("sandbox API URL must end with /sandboxes");return o.slice(0,-e.length)}n(L,"apiRootUrlFromSandboxApiUrl");function Q(o){return o==="api.openpond.ai"||o==="staging-api.openpond.ai"||o.startsWith("api")&&o.endsWith(".openpond.ai")}n(Q,"isOpenPondHostedApiHost");function B(o){return{list:n((e={})=>o.listSandboxRuntimes(e),"list"),create:n(e=>o.createSandboxRuntime(e),"create"),handle:n((e,t=null)=>o.sandboxRuntime(e,t),"handle"),get:n(e=>o.getSandboxRuntime(e),"get"),createSandbox:n((e,t={},r={})=>o.createSandboxRuntimeSandbox(e,t,r),"createSandbox"),updateStatus:n((e,t)=>o.updateSandboxRuntimeStatus(e,t),"updateStatus"),events:n(e=>o.listSandboxRuntimeEvents(e),"events"),event:n((e,t)=>o.emitSandboxRuntimeEvent(e,t),"event"),checkpoint:n((e,t={})=>o.checkpointSandboxRuntime(e,t),"checkpoint"),promote:n((e,t,r={})=>o.promoteSandboxRuntime(e,t,r),"promote"),preserveSource:n((e,t={},r={})=>o.preserveSandboxRuntimeSource(e,t,r),"preserveSource")}}n(B,"createSandboxRuntimeNamespace");function z(o){return{list:n((e={})=>o.list(e),"list"),create:n(e=>o.create(e),"create"),get:n(e=>o.get(e),"get"),pricing:n(()=>o.pricing(),"pricing"),costs:n((e={})=>o.costs(e),"costs")}}n(z,"createSandboxNamespace");function D(o){return{list:n(e=>o.listProjects(e),"list"),upsert:n(e=>o.upsertProject(e),"upsert"),upsertGitRemote:n(e=>o.upsertProjectGitRemote(e),"upsertGitRemote"),get:n((e,t)=>o.getProject(e,t),"get"),update:n((e,t)=>o.updateProject(e,t),"update"),sync:n((e,t)=>o.syncProject(e,t),"sync"),ensureGitRemote:n((e,t)=>o.ensureProjectGitRemote(e,t),"ensureGitRemote"),getGitRemote:n((e,t)=>o.ensureProjectGitRemote(e,t),"getGitRemote"),git:n((e,t)=>o.ensureProjectGitRemote(e,t),"git"),uploadSource:n((e,t)=>o.uploadProjectSource(e,t),"uploadSource"),archive:n((e,t)=>o.archiveProject(e,t),"archive")}}n(D,"createSandboxProjectNamespace");function J(o){return{get:n(e=>o.getHostedProfile(e),"get"),status:n(e=>o.getHostedProfile(e),"status"),ensureHosted:n(e=>o.ensureHostedProfile(e),"ensureHosted"),push:n(e=>o.pushHostedProfile(e),"push")}}n(J,"createSandboxProfileNamespace");function M(o){return{list:n(e=>o.listAgents(e),"list"),upsert:n(e=>o.upsertAgent(e),"upsert"),get:n((e,t)=>o.getAgent(e,t),"get"),update:n((e,t)=>o.updateAgent(e,t),"update"),archive:n((e,t)=>o.archiveAgent(e,t),"archive"),run:n((e,t)=>o.runAgent(e,t),"run"),sourceDeployPlan:n((e,t)=>o.getAgentSourceDeployPlan(e,t),"sourceDeployPlan"),manifestSnapshots:n((e,t)=>o.listAgentManifestSnapshots(e,t),"manifestSnapshots"),requestSourceChecks:n((e,t)=>o.requestAgentSourceChecks(e,t),"requestSourceChecks"),configureSourceSetup:n((e,t)=>o.configureAgentSourceSetup(e,t),"configureSourceSetup"),publishSource:n((e,t)=>o.publishAgentSource(e,t),"publishSource")}}n(M,"createSandboxAgentNamespace");function F(o,e,t=null){let r=n(async(a={},d={})=>{let l=await o.getSandboxRuntime(e);return l.sandboxId?o.get(l.sandboxId):o.createSandboxRuntimeSandbox(e,a,d).then(u=>u.sandbox)},"currentSandbox"),s=n(async(a={},d={})=>{let l=await o.getSandboxRuntime(e);if(!l.sandboxId)return o.createSandboxRuntimeSandbox(e,a,d).then(p=>p.sandbox);let u=await o.get(l.sandboxId);return u.state==="stopped"?o.start(u.id,d).then(p=>p.sandbox):u.state==="archived"?o.restore(u.id).then(p=>p.sandbox):u.state==="deleted"||u.state==="error"?o.createSandboxRuntimeSandbox(e,a,d).then(p=>p.sandbox):u},"resume");return{id:e,initial:t,get:n(()=>o.getSandboxRuntime(e),"get"),sandbox:r,resume:s,createSandbox:n((a={},d={})=>o.createSandboxRuntimeSandbox(e,a,d),"createSandbox"),status:n(async a=>{if(typeof a!="string")return o.updateSandboxRuntimeStatus(e,a);let d=await o.getSandboxRuntime(e);return o.updateSandboxRuntimeStatus(e,{status:a,expectedVersion:d.version})},"status"),events:n(()=>o.listSandboxRuntimeEvents(e),"events"),event:n(a=>o.emitSandboxRuntimeEvent(e,a),"event"),recordCommit:n((a,d={})=>o.emitSandboxRuntimeEvent(e,{...d,type:d.type??"git.commit",commitSha:a}),"recordCommit"),checkpointHint:n((a={})=>o.emitSandboxRuntimeEvent(e,{type:"workflow.checkpoint_hint",summary:a.summary??a.reason??"Workflow checkpoint hint",payload:{...a.payload,reason:a.reason??null},artifactRefs:a.artifactRefs,lifecycleHint:{kind:"checkpoint",reason:a.reason??null}}),"checkpointHint"),waitForUser:n(async(a={})=>{await o.emitSandboxRuntimeEvent(e,{type:"workflow.waiting_for_user",summary:a.summary??a.reason??"Waiting for user",payload:{...a.payload,reason:a.reason??null},lifecycleHint:{kind:"waiting_for_user",reason:a.reason??null}});let d=await o.getSandboxRuntime(e);return d.status==="waiting_for_user"?d:o.updateSandboxRuntimeStatus(e,{status:"waiting_for_user",expectedVersion:d.version,summary:a.summary??a.reason,metadata:{workflowWaitForUserReason:a.reason??null}})},"waitForUser"),keepAlive:n((a={})=>{let d=Z(a);return o.emitSandboxRuntimeEvent(e,{type:"workflow.keepalive",summary:a.summary??a.reason??"Workflow keepalive",payload:{...a.payload,reason:a.reason??null,keepaliveUntil:d},lifecycleHint:{kind:"keepalive",reason:a.reason??null,keepaliveUntil:d}})},"keepAlive"),checkpoint:n(a=>o.checkpointSandboxRuntime(e,a),"checkpoint"),files:{write:n(async(a,d)=>o.uploadFile((await s()).id,a,d),"write"),read:n(async a=>o.downloadFile((await s()).id,a),"read"),readResponse:n(async a=>o.downloadFileResponse((await s()).id,a),"readResponse"),list:n(async(a={})=>o.listFiles((await s()).id,a),"list"),delete:n(async(a,d={})=>o.deleteFile((await s()).id,a,d),"delete"),search:n(async a=>o.searchFiles((await s()).id,a),"search"),stat:n(async a=>o.statFile((await s()).id,a),"stat"),mkdir:n(async a=>o.mkdir((await s()).id,a),"mkdir"),move:n(async a=>o.moveFile((await s()).id,a),"move")},commands:{run:n(async a=>o.exec((await s()).id,typeof a=="string"?{command:a}:a),"run")},ports:{expose:n(async a=>o.openPort((await s()).id,typeof a=="number"?{port:a}:a),"expose")},promote:n((a,d={})=>o.promoteSandboxRuntime(e,a,d),"promote"),preserveSource:n((a={},d={})=>o.preserveSandboxRuntimeSource(e,a,d),"preserveSource"),archive:n(async a=>{let d=a??(await o.getSandboxRuntime(e)).version;return o.updateSandboxRuntimeStatus(e,{status:"archived",expectedVersion:d})},"archive")}}n(F,"createSandboxRuntimeHandle");function Z(o){if(o?.until instanceof Date)return o.until.toISOString();if(typeof o?.until=="string"&&o.until.trim())return new Date(o.until).toISOString();let e=typeof o?.seconds=="number"&&Number.isFinite(o.seconds)?Math.max(1,Math.trunc(o.seconds)):60;return new Date(Date.now()+e*1e3).toISOString()}n(Z,"runtimeKeepaliveUntilIso");async function W(o,e={}){let t=`openpond-code-smoke-${Date.now()}`,r=`openpond-code-exec-ok:${t}`,s=`openpond-code-preview-ok:${t}`,i=`openpond-code-file-ok:${t}`,c=4173,m=null,a=null,d=!1,l=!1;try{let u=await G(o,await o.create({repo:e.repo??"https://github.com/octocat/Hello-World",resources:{cpu:e.cpu??1,memoryGb:e.memoryGb??1,diskGb:e.diskGb??8},budget:{maxUsd:e.budgetUsd??"0.05"},quotas:{maxSpendUsd:e.budgetUsd??"0.05",maxDurationSeconds:600,idleTimeoutSeconds:600,maxOpenPorts:2},metadata:{runId:t,source:"openpond-code-sandbox-smoke"}},{async:!0}));m=u.id;let p=e.expectedMppMode;if(p&&u.reservation.mpp?.mode!==p)throw new Error(`expected ${p} reservation, got ${u.reservation.mpp?.mode??"none"}`);if(!p&&!u.reservation.mpp?.mode)throw new Error("expected sandbox reservation MPP metadata");let y=await o.exec(u.id,{command:[`printf '${r}\\n'`,"test -f README && printf 'repo-clone-ok\\n'","cat > server.cjs <<'EOF'","const { createServer } = require('node:http');",`createServer((_request, response) => response.end('${s}')).listen(${c}, '0.0.0.0');`,"EOF","nohup node server.cjs > server.log 2>&1 & sleep 1"].join(`
3
- `),timeoutSeconds:120});if(y.command.status!=="succeeded")throw new Error(`expected command success, got ${y.command.status}`);if(!y.command.output.includes(r))throw new Error("expected exec marker");if(await o.uploadFile(u.id,"openpond-code-smoke.txt",i),await o.downloadFile(u.id,"openpond-code-smoke.txt")!==i)throw new Error("expected file roundtrip marker");let S=null;if(e.snapshot||e.fork){let h=await o.createSnapshot(u.id,{async:!0,name:`openpond-code-smoke-${t}`,replay:{entrypoints:[{command:"cat openpond-code-smoke.txt",name:"default"}],retention:{class:"pinned"},safety:{cleanup:"delete",idleTimeoutSeconds:600,internetEgress:"block",maxDurationSeconds:600,maxSpendUsd:e.budgetUsd??"0.05",publicPreview:!1},validation:{commands:[{command:"test -f openpond-code-smoke.txt"}]}}}),f=h.snapshot??(await re(o,u.id,h.snapshotJob?.snapshotId)).snapshot;if(S=f.id,f.state!=="ready")throw new Error(`expected ready snapshot, got ${f.state}`)}if(e.fork){if(!S)throw new Error("expected snapshot id before fork");let h=await G(o,(await o.forkSnapshot(S,{budget:{maxUsd:e.budgetUsd??"0.05"},metadata:{source:"openpond-code-sandbox-smoke-fork",templateSnapshotId:S}},{async:!0})).sandbox);a=h.id;let f=await o.exec(h.id,{command:"cat openpond-code-smoke.txt",timeoutSeconds:120});if(f.command.status!=="succeeded")throw new Error(`expected fork command success, got ${f.command.status}`);if(!f.command.output.includes(i))throw new Error("expected fork snapshot marker");e.keep||(await v(o,h.id),l=!0)}let I=null;if(e.preview!==!1){let h=await o.openPort(u.id,{label:"openpond-code-smoke",port:c}),f=await fetch(h.preview.url);I=f.status;let X=await f.text();if(f.status!==200)throw new Error(`expected preview HTTP 200, got ${f.status}`);if(!X.includes(s))throw new Error("expected preview marker")}let{sandbox:A,receipts:P}=await ee(o,u.id);return e.keep||(await v(o,u.id),d=!0),{deleted:d,execOutput:y.command.output.trim(),fileRoundtrip:!0,forkSandboxId:a,previewStatus:I,receiptRefs:P.map(h=>h.mpp.receiptRef??null),reservationRef:u.reservation.mpp?.reservationRef??null,runId:t,sandboxId:u.id,snapshotId:S,state:A.state}}finally{a&&!e.keep&&!l&&await H(o,a),m&&!e.keep&&!d&&await H(o,m)}}n(W,"runSandboxSmoke");async function ee(o,e){try{await o.stop(e)}catch{await o.stop(e,{async:!0})}let t=await K(o,e,new Set(["stopped","deleted"]),"stop"),r=await te(o,e);if(r.length===0)throw new Error("expected receipt readback");return{sandbox:t,receipts:r}}n(ee,"stopSandboxForSmoke");async function v(o,e){try{let t=await o.delete(e);if(t.state==="deleted")return t;await o.delete(e,{async:!0})}catch{await o.delete(e,{async:!0})}return K(o,e,new Set(["deleted"]),"delete")}n(v,"deleteSandboxForSmoke");async function H(o,e){try{await v(o,e)}catch{await o.delete(e,{async:!0}).catch(()=>{})}}n(H,"cleanupSandboxBestEffort");async function K(o,e,t,r){let c=Date.now()+3e5,m=await o.get(e);for(;Date.now()<c;){if(t.has(m.state))return m;if(m.state==="error")throw new Error(`sandbox ${r} failed: ${e}`);await $(3e3),m=await o.get(e)}throw new Error(`sandbox ${r} did not reach ${[...t].join("/")} before timeout: ${e} (${m.state})`)}n(K,"waitForSandboxState");async function te(o,e){let s=Date.now()+12e4,i=await o.receipts(e);for(;Date.now()<s;){if(i.length>0)return i;await $(3e3),i=await o.receipts(e)}return i}n(te,"waitForReceipts");async function G(o,e){if(e.state==="running"||e.state==="stopped")return e;if(e.state==="error")throw new Error(`sandbox create failed: ${e.id}
2
+ import{a as n}from"./chunk-FTQLQJQV.js";var k="https://openpond.ai",U="https://api.openpond.ai",N="https://api.openpond.ai/opchat/v1";function C(o){let e=o.trim().replace(/\/$/,"");if(!e)throw new Error("sandbox API URL must be non-empty");let t=new URL(e),r=t.pathname.replace(/\/$/,"");return r.endsWith("/v1/sandboxes")||r.endsWith("/api/sandboxes")?`${t.origin}${r}`:r.endsWith("/v1")?`${t.origin}${r}/sandboxes`:te(t.hostname)?`${t.origin}${r}/v1/sandboxes`:t.origin===k?`${U}/v1/sandboxes`:`${t.origin}${r}/api/sandboxes`}n(C,"normalizeSandboxApiUrl");function L(o){let e="/sandboxes";if(!o.endsWith(e))throw new Error("sandbox API URL must end with /sandboxes");return o.slice(0,-e.length)}n(L,"apiRootUrlFromSandboxApiUrl");function te(o){return o==="api.openpond.ai"||o==="staging-api.openpond.ai"||o.startsWith("api")&&o.endsWith(".openpond.ai")}n(te,"isOpenPondHostedApiHost");function B(o){return{list:n((e={})=>o.listSandboxRuntimes(e),"list"),create:n(e=>o.createSandboxRuntime(e),"create"),handle:n((e,t=null)=>o.sandboxRuntime(e,t),"handle"),get:n(e=>o.getSandboxRuntime(e),"get"),createSandbox:n((e,t={},r={})=>o.createSandboxRuntimeSandbox(e,t,r),"createSandbox"),updateStatus:n((e,t)=>o.updateSandboxRuntimeStatus(e,t),"updateStatus"),events:n(e=>o.listSandboxRuntimeEvents(e),"events"),event:n((e,t)=>o.emitSandboxRuntimeEvent(e,t),"event"),checkpoint:n((e,t={})=>o.checkpointSandboxRuntime(e,t),"checkpoint"),promote:n((e,t,r={})=>o.promoteSandboxRuntime(e,t,r),"promote"),preserveSource:n((e,t={},r={})=>o.preserveSandboxRuntimeSource(e,t,r),"preserveSource")}}n(B,"createSandboxRuntimeNamespace");function z(o){return{list:n((e={})=>o.list(e),"list"),create:n(e=>o.create(e),"create"),get:n(e=>o.get(e),"get"),pricing:n(()=>o.pricing(),"pricing"),costs:n((e={})=>o.costs(e),"costs")}}n(z,"createSandboxNamespace");function D(o){return{list:n(e=>o.listProjects(e),"list"),upsert:n(e=>o.upsertProject(e),"upsert"),upsertGitRemote:n(e=>o.upsertProjectGitRemote(e),"upsertGitRemote"),get:n((e,t)=>o.getProject(e,t),"get"),update:n((e,t)=>o.updateProject(e,t),"update"),sync:n((e,t)=>o.syncProject(e,t),"sync"),ensureGitRemote:n((e,t)=>o.ensureProjectGitRemote(e,t),"ensureGitRemote"),getGitRemote:n((e,t)=>o.ensureProjectGitRemote(e,t),"getGitRemote"),git:n((e,t)=>o.ensureProjectGitRemote(e,t),"git"),uploadSource:n((e,t)=>o.uploadProjectSource(e,t),"uploadSource"),archive:n((e,t)=>o.archiveProject(e,t),"archive")}}n(D,"createSandboxProjectNamespace");function J(o){return{get:n(e=>o.getHostedProfile(e),"get"),status:n(e=>o.getHostedProfile(e),"status"),ensureHosted:n(e=>o.ensureHostedProfile(e),"ensureHosted"),push:n(e=>o.pushHostedProfile(e),"push")}}n(J,"createSandboxProfileNamespace");function M(o){return{list:n(e=>o.listAgents(e),"list"),upsert:n(e=>o.upsertAgent(e),"upsert"),get:n((e,t)=>o.getAgent(e,t),"get"),update:n((e,t)=>o.updateAgent(e,t),"update"),archive:n((e,t)=>o.archiveAgent(e,t),"archive"),run:n((e,t)=>o.runAgent(e,t),"run"),sourceDeployPlan:n((e,t)=>o.getAgentSourceDeployPlan(e,t),"sourceDeployPlan"),manifestSnapshots:n((e,t)=>o.listAgentManifestSnapshots(e,t),"manifestSnapshots"),requestSourceChecks:n((e,t)=>o.requestAgentSourceChecks(e,t),"requestSourceChecks"),configureSourceSetup:n((e,t)=>o.configureAgentSourceSetup(e,t),"configureSourceSetup"),publishSource:n((e,t)=>o.publishAgentSource(e,t),"publishSource")}}n(M,"createSandboxAgentNamespace");function F(o,e,t=null){let r=n(async(a={},d={})=>{let l=await o.getSandboxRuntime(e);return l.sandboxId?o.get(l.sandboxId):o.createSandboxRuntimeSandbox(e,a,d).then(u=>u.sandbox)},"currentSandbox"),s=n(async(a={},d={})=>{let l=await o.getSandboxRuntime(e);if(!l.sandboxId)return o.createSandboxRuntimeSandbox(e,a,d).then(p=>p.sandbox);let u=await o.get(l.sandboxId);return u.state==="stopped"?o.start(u.id,d).then(p=>p.sandbox):u.state==="archived"?o.restore(u.id).then(p=>p.sandbox):u.state==="deleted"||u.state==="error"?o.createSandboxRuntimeSandbox(e,a,d).then(p=>p.sandbox):u},"resume");return{id:e,initial:t,get:n(()=>o.getSandboxRuntime(e),"get"),sandbox:r,resume:s,createSandbox:n((a={},d={})=>o.createSandboxRuntimeSandbox(e,a,d),"createSandbox"),status:n(async a=>{if(typeof a!="string")return o.updateSandboxRuntimeStatus(e,a);let d=await o.getSandboxRuntime(e);return o.updateSandboxRuntimeStatus(e,{status:a,expectedVersion:d.version})},"status"),events:n(()=>o.listSandboxRuntimeEvents(e),"events"),event:n(a=>o.emitSandboxRuntimeEvent(e,a),"event"),recordCommit:n((a,d={})=>o.emitSandboxRuntimeEvent(e,{...d,type:d.type??"git.commit",commitSha:a}),"recordCommit"),checkpointHint:n((a={})=>o.emitSandboxRuntimeEvent(e,{type:"workflow.checkpoint_hint",summary:a.summary??a.reason??"Workflow checkpoint hint",payload:{...a.payload,reason:a.reason??null},artifactRefs:a.artifactRefs,lifecycleHint:{kind:"checkpoint",reason:a.reason??null}}),"checkpointHint"),waitForUser:n(async(a={})=>{await o.emitSandboxRuntimeEvent(e,{type:"workflow.waiting_for_user",summary:a.summary??a.reason??"Waiting for user",payload:{...a.payload,reason:a.reason??null},lifecycleHint:{kind:"waiting_for_user",reason:a.reason??null}});let d=await o.getSandboxRuntime(e);return d.status==="waiting_for_user"?d:o.updateSandboxRuntimeStatus(e,{status:"waiting_for_user",expectedVersion:d.version,summary:a.summary??a.reason,metadata:{workflowWaitForUserReason:a.reason??null}})},"waitForUser"),keepAlive:n((a={})=>{let d=re(a);return o.emitSandboxRuntimeEvent(e,{type:"workflow.keepalive",summary:a.summary??a.reason??"Workflow keepalive",payload:{...a.payload,reason:a.reason??null,keepaliveUntil:d},lifecycleHint:{kind:"keepalive",reason:a.reason??null,keepaliveUntil:d}})},"keepAlive"),checkpoint:n(a=>o.checkpointSandboxRuntime(e,a),"checkpoint"),files:{write:n(async(a,d)=>o.uploadFile((await s()).id,a,d),"write"),read:n(async a=>o.downloadFile((await s()).id,a),"read"),readResponse:n(async a=>o.downloadFileResponse((await s()).id,a),"readResponse"),list:n(async(a={})=>o.listFiles((await s()).id,a),"list"),delete:n(async(a,d={})=>o.deleteFile((await s()).id,a,d),"delete"),search:n(async a=>o.searchFiles((await s()).id,a),"search"),stat:n(async a=>o.statFile((await s()).id,a),"stat"),mkdir:n(async a=>o.mkdir((await s()).id,a),"mkdir"),move:n(async a=>o.moveFile((await s()).id,a),"move")},commands:{run:n(async a=>o.exec((await s()).id,typeof a=="string"?{command:a}:a),"run")},ports:{expose:n(async a=>o.openPort((await s()).id,typeof a=="number"?{port:a}:a),"expose")},promote:n((a,d={})=>o.promoteSandboxRuntime(e,a,d),"promote"),preserveSource:n((a={},d={})=>o.preserveSandboxRuntimeSource(e,a,d),"preserveSource"),archive:n(async a=>{let d=a??(await o.getSandboxRuntime(e)).version;return o.updateSandboxRuntimeStatus(e,{status:"archived",expectedVersion:d})},"archive")}}n(F,"createSandboxRuntimeHandle");function re(o){if(o?.until instanceof Date)return o.until.toISOString();if(typeof o?.until=="string"&&o.until.trim())return new Date(o.until).toISOString();let e=typeof o?.seconds=="number"&&Number.isFinite(o.seconds)?Math.max(1,Math.trunc(o.seconds)):60;return new Date(Date.now()+e*1e3).toISOString()}n(re,"runtimeKeepaliveUntilIso");async function W(o,e={}){let t=`openpond-code-smoke-${Date.now()}`,r=`openpond-code-exec-ok:${t}`,s=`openpond-code-preview-ok:${t}`,i=`openpond-code-file-ok:${t}`,c=4173,m=null,a=null,d=!1,l=!1;try{let u=await G(o,await o.create({repo:e.repo??"https://github.com/octocat/Hello-World",resources:{cpu:e.cpu??1,memoryGb:e.memoryGb??1,diskGb:e.diskGb??8},budget:{maxUsd:e.budgetUsd??"0.05"},quotas:{maxSpendUsd:e.budgetUsd??"0.05",maxDurationSeconds:600,idleTimeoutSeconds:600,maxOpenPorts:2},metadata:{runId:t,source:"openpond-code-sandbox-smoke"}},{async:!0}));m=u.id;let p=e.expectedMppMode;if(p&&u.reservation.mpp?.mode!==p)throw new Error(`expected ${p} reservation, got ${u.reservation.mpp?.mode??"none"}`);if(!p&&!u.reservation.mpp?.mode)throw new Error("expected sandbox reservation MPP metadata");let y=await o.exec(u.id,{command:[`printf '${r}\\n'`,"test -f README && printf 'repo-clone-ok\\n'","cat > server.cjs <<'EOF'","const { createServer } = require('node:http');",`createServer((_request, response) => response.end('${s}')).listen(${c}, '0.0.0.0');`,"EOF","nohup node server.cjs > server.log 2>&1 & sleep 1"].join(`
3
+ `),timeoutSeconds:120});if(y.command.status!=="succeeded")throw new Error(`expected command success, got ${y.command.status}`);if(!y.command.output.includes(r))throw new Error("expected exec marker");if(await o.uploadFile(u.id,"openpond-code-smoke.txt",i),await o.downloadFile(u.id,"openpond-code-smoke.txt")!==i)throw new Error("expected file roundtrip marker");let S=null;if(e.snapshot||e.fork){let h=await o.createSnapshot(u.id,{async:!0,name:`openpond-code-smoke-${t}`,replay:{entrypoints:[{command:"cat openpond-code-smoke.txt",name:"default"}],retention:{class:"pinned"},safety:{cleanup:"delete",idleTimeoutSeconds:600,internetEgress:"block",maxDurationSeconds:600,maxSpendUsd:e.budgetUsd??"0.05",publicPreview:!1},validation:{commands:[{command:"test -f openpond-code-smoke.txt"}]}}}),f=h.snapshot??(await ne(o,u.id,h.snapshotJob?.snapshotId)).snapshot;if(S=f.id,f.state!=="ready")throw new Error(`expected ready snapshot, got ${f.state}`)}if(e.fork){if(!S)throw new Error("expected snapshot id before fork");let h=await G(o,(await o.forkSnapshot(S,{budget:{maxUsd:e.budgetUsd??"0.05"},metadata:{source:"openpond-code-sandbox-smoke-fork",templateSnapshotId:S}},{async:!0})).sandbox);a=h.id;let f=await o.exec(h.id,{command:"cat openpond-code-smoke.txt",timeoutSeconds:120});if(f.command.status!=="succeeded")throw new Error(`expected fork command success, got ${f.command.status}`);if(!f.command.output.includes(i))throw new Error("expected fork snapshot marker");e.keep||(await v(o,h.id),l=!0)}let I=null;if(e.preview!==!1){let h=await o.openPort(u.id,{label:"openpond-code-smoke",port:c}),f=await fetch(h.preview.url);I=f.status;let ee=await f.text();if(f.status!==200)throw new Error(`expected preview HTTP 200, got ${f.status}`);if(!ee.includes(s))throw new Error("expected preview marker")}let{sandbox:A,receipts:P}=await oe(o,u.id);return e.keep||(await v(o,u.id),d=!0),{deleted:d,execOutput:y.command.output.trim(),fileRoundtrip:!0,forkSandboxId:a,previewStatus:I,receiptRefs:P.map(h=>h.mpp.receiptRef??null),reservationRef:u.reservation.mpp?.reservationRef??null,runId:t,sandboxId:u.id,snapshotId:S,state:A.state}}finally{a&&!e.keep&&!l&&await H(o,a),m&&!e.keep&&!d&&await H(o,m)}}n(W,"runSandboxSmoke");async function oe(o,e){try{await o.stop(e)}catch{await o.stop(e,{async:!0})}let t=await K(o,e,new Set(["stopped","deleted"]),"stop"),r=await se(o,e);if(r.length===0)throw new Error("expected receipt readback");return{sandbox:t,receipts:r}}n(oe,"stopSandboxForSmoke");async function v(o,e){try{let t=await o.delete(e);if(t.state==="deleted")return t;await o.delete(e,{async:!0})}catch{await o.delete(e,{async:!0})}return K(o,e,new Set(["deleted"]),"delete")}n(v,"deleteSandboxForSmoke");async function H(o,e){try{await v(o,e)}catch{await o.delete(e,{async:!0}).catch(()=>{})}}n(H,"cleanupSandboxBestEffort");async function K(o,e,t,r){let c=Date.now()+3e5,m=await o.get(e);for(;Date.now()<c;){if(t.has(m.state))return m;if(m.state==="error")throw new Error(`sandbox ${r} failed: ${e}`);await $(3e3),m=await o.get(e)}throw new Error(`sandbox ${r} did not reach ${[...t].join("/")} before timeout: ${e} (${m.state})`)}n(K,"waitForSandboxState");async function se(o,e){let s=Date.now()+12e4,i=await o.receipts(e);for(;Date.now()<s;){if(i.length>0)return i;await $(3e3),i=await o.receipts(e)}return i}n(se,"waitForReceipts");async function G(o,e){if(e.state==="running"||e.state==="stopped")return e;if(e.state==="error")throw new Error(`sandbox create failed: ${e.id}
4
4
  ${e.logs.join(`
5
5
  `)}`);let t=12*6e4,r=3e3,s=Date.now()+t,i=e;for(;Date.now()<s;){if(await $(r),i=await o.get(e.id),i.state==="running"||i.state==="stopped")return i;if(i.state==="error")throw new Error(`sandbox create failed: ${i.id}
6
6
  ${i.logs.join(`
7
- `)}`)}throw new Error(`sandbox create did not reach running state before timeout: ${i.id} (${i.state})`)}n(G,"waitForCreateReady");async function re(o,e,t){if(!t)throw new Error("snapshot job did not return snapshot id");let r=12*6e4,s=3e3,i=Date.now()+r,c=await o.get(e);for(;Date.now()<i;){let m=c.snapshots?.find(d=>d.id===t);if(m?.state==="ready")return{sandbox:c,snapshot:m};let a=c.snapshotJobs?.find(d=>d.snapshotId===t);if(a?.status==="failed")throw new Error(`snapshot job failed: ${a.error??t}`);await $(s),c=await o.get(e)}throw new Error(`snapshot did not reach ready state before timeout: ${t}`)}n(re,"waitForSnapshotReady");function $(o){return new Promise(e=>setTimeout(e,o))}n($,"sleep");function R(o={}){return o.async||o.respondAsync?{Prefer:"respond-async"}:void 0}n(R,"asyncRequestHeaders");var q=class extends Error{static{n(this,"ApiTimeoutError")}timeoutMs;requestUrl;code="OPENPOND_API_TIMEOUT";constructor(e,t){super(`API request timed out after ${e}ms: ${t}`),this.timeoutMs=e,this.requestUrl=t,this.name="ApiTimeoutError"}},w=class extends Error{static{n(this,"ApiResponseTooLargeError")}maximumBytes;requestUrl;code="OPENPOND_API_RESPONSE_TOO_LARGE";constructor(e,t){super(`API response exceeded ${e} bytes: ${t}`),this.maximumBytes=e,this.requestUrl=t,this.name="ApiResponseTooLargeError"}},E=class extends Error{static{n(this,"OpenPondApiError")}status;apiMessage;code;constructor(e,t,r,s=null){let i=s||t;super(`${r} failed: ${e}${i?` ${i}`:""}`),this.status=e,this.apiMessage=s,this.name="OpenPondApiError",this.code=t||"OPENPOND_API_ERROR"}};async function x(o,e,t,r={}){let{timeoutMs:s=3e4,maxResponseBytes:i=8388608,explicitBearerAuth:c=!1,...m}=r,a=`${o}${t}`,d=new Headers(m.headers);d.set("Content-Type","application/json");let l=c?void 0:process.env.OPENPOND_API_KEY,u=e?.trim()||"",p=!c&&u.startsWith("opk_"),y=l||(p?u:null);y&&!d.has("openpond-api-key")&&d.set("openpond-api-key",y),e?d.set("Authorization",p?`ApiKey ${u}`:`Bearer ${e}`):l&&!d.has("Authorization")&&d.set("Authorization",`ApiKey ${l}`);let b=new AbortController,S=new q(s,a),I=s>0?setTimeout(()=>b.abort(S),s):null;I?.unref?.();let A=se(m.signal,b.signal,s),P=n(()=>{I&&clearTimeout(I)},"cleanup");try{let h=await fetch(a,{...m,headers:d,signal:A});return oe(h,{cleanup:P,maximumBytes:i,requestUrl:a,timeoutController:b,timeoutError:S})}catch(h){throw P(),b.signal.aborted?S:h}}n(x,"apiFetch");async function T(o,e){let t;try{let r=await o.text();t=r?JSON.parse(r):{}}catch(r){if(r instanceof q||r instanceof w)throw r;t={}}if(!o.ok){let r=typeof t.error=="string"?t.error:null,s=typeof t.message=="string"?t.message:null;throw new E(o.status,r,e,s)}return t}n(T,"readApiJson");function oe(o,e){if(!o.body)return e.cleanup(),o;let t=Number(o.headers.get("content-length"));if(e.maximumBytes>0&&Number.isFinite(t)&&t>e.maximumBytes)throw e.cleanup(),o.body.cancel(),new w(e.maximumBytes,e.requestUrl);let r=o.body.getReader(),s=0,i=new ReadableStream({async pull(c){try{let m=await r.read();if(m.done){e.cleanup(),c.close();return}if(s+=m.value.byteLength,e.maximumBytes>0&&s>e.maximumBytes){e.cleanup(),await r.cancel(),c.error(new w(e.maximumBytes,e.requestUrl));return}c.enqueue(m.value)}catch(m){e.cleanup(),c.error(e.timeoutController.signal.aborted?e.timeoutError:m)}},async cancel(c){e.cleanup(),await r.cancel(c)}});return new Response(i,{headers:o.headers,status:o.status,statusText:o.statusText})}n(oe,"boundedResponse");function se(o,e,t){return t<=0?o??void 0:o?AbortSignal.any([o,e]):e}n(se,"composedSignal");async function _(o){let e=await x(o.sandboxApiUrl,o.apiKey,o.path,{timeoutMs:0,maxResponseBytes:0});if(!e.body)return;let t=e.body.getReader(),r=new TextDecoder,s="";try{for(;;){let{done:i,value:c}=await t.read();if(i)break;s+=r.decode(c,{stream:!0});let m=s.indexOf(`
7
+ `)}`)}throw new Error(`sandbox create did not reach running state before timeout: ${i.id} (${i.state})`)}n(G,"waitForCreateReady");async function ne(o,e,t){if(!t)throw new Error("snapshot job did not return snapshot id");let r=12*6e4,s=3e3,i=Date.now()+r,c=await o.get(e);for(;Date.now()<i;){let m=c.snapshots?.find(d=>d.id===t);if(m?.state==="ready")return{sandbox:c,snapshot:m};let a=c.snapshotJobs?.find(d=>d.snapshotId===t);if(a?.status==="failed")throw new Error(`snapshot job failed: ${a.error??t}`);await $(s),c=await o.get(e)}throw new Error(`snapshot did not reach ready state before timeout: ${t}`)}n(ne,"waitForSnapshotReady");function $(o){return new Promise(e=>setTimeout(e,o))}n($,"sleep");function R(o={}){return o.async||o.respondAsync?{Prefer:"respond-async"}:void 0}n(R,"asyncRequestHeaders");var q=class extends Error{static{n(this,"ApiTimeoutError")}timeoutMs;requestUrl;code="OPENPOND_API_TIMEOUT";constructor(e,t){super(`API request timed out after ${e}ms: ${t}`),this.timeoutMs=e,this.requestUrl=t,this.name="ApiTimeoutError"}},w=class extends Error{static{n(this,"ApiResponseTooLargeError")}maximumBytes;requestUrl;code="OPENPOND_API_RESPONSE_TOO_LARGE";constructor(e,t){super(`API response exceeded ${e} bytes: ${t}`),this.maximumBytes=e,this.requestUrl=t,this.name="ApiResponseTooLargeError"}},E=class extends Error{static{n(this,"OpenPondApiError")}status;apiMessage;code;constructor(e,t,r,s=null){let i=s||t;super(`${r} failed: ${e}${i?` ${i}`:""}`),this.status=e,this.apiMessage=s,this.name="OpenPondApiError",this.code=t||"OPENPOND_API_ERROR"}};async function x(o,e,t,r={}){let{timeoutMs:s=3e4,maxResponseBytes:i=8388608,explicitBearerAuth:c=!1,...m}=r,a=`${o}${t}`,d=new Headers(m.headers);d.set("Content-Type","application/json");let l=c?void 0:process.env.OPENPOND_API_KEY,u=e?.trim()||"",p=!c&&u.startsWith("opk_"),y=l||(p?u:null);y&&!d.has("openpond-api-key")&&d.set("openpond-api-key",y),e?d.set("Authorization",p?`ApiKey ${u}`:`Bearer ${e}`):l&&!d.has("Authorization")&&d.set("Authorization",`ApiKey ${l}`);let b=new AbortController,S=new q(s,a),I=s>0?setTimeout(()=>b.abort(S),s):null;I?.unref?.();let A=ie(m.signal,b.signal,s),P=n(()=>{I&&clearTimeout(I)},"cleanup");try{let h=await fetch(a,{...m,headers:d,signal:A});return ae(h,{cleanup:P,maximumBytes:i,requestUrl:a,timeoutController:b,timeoutError:S})}catch(h){throw P(),b.signal.aborted?S:h}}n(x,"apiFetch");async function T(o,e){let t;try{let r=await o.text();t=r?JSON.parse(r):{}}catch(r){if(r instanceof q||r instanceof w)throw r;t={}}if(!o.ok){let r=typeof t.error=="string"?t.error:null,s=typeof t.message=="string"?t.message:null;throw new E(o.status,r,e,s)}return t}n(T,"readApiJson");function ae(o,e){if(!o.body)return e.cleanup(),o;let t=Number(o.headers.get("content-length"));if(e.maximumBytes>0&&Number.isFinite(t)&&t>e.maximumBytes)throw e.cleanup(),o.body.cancel(),new w(e.maximumBytes,e.requestUrl);let r=o.body.getReader(),s=0,i=new ReadableStream({async pull(c){try{let m=await r.read();if(m.done){e.cleanup(),c.close();return}if(s+=m.value.byteLength,e.maximumBytes>0&&s>e.maximumBytes){e.cleanup(),await r.cancel(),c.error(new w(e.maximumBytes,e.requestUrl));return}c.enqueue(m.value)}catch(m){e.cleanup(),c.error(e.timeoutController.signal.aborted?e.timeoutError:m)}},async cancel(c){e.cleanup(),await r.cancel(c)}});return new Response(i,{headers:o.headers,status:o.status,statusText:o.statusText})}n(ae,"boundedResponse");function ie(o,e,t){return t<=0?o??void 0:o?AbortSignal.any([o,e]):e}n(ie,"composedSignal");async function _(o){let e=await x(o.sandboxApiUrl,o.apiKey,o.path,{timeoutMs:0,maxResponseBytes:0});if(!e.body)return;let t=e.body.getReader(),r=new TextDecoder,s="";try{for(;;){let{done:i,value:c}=await t.read();if(i)break;s+=r.decode(c,{stream:!0});let m=s.indexOf(`
8
8
 
9
- `);for(;m!==-1;){let a=s.slice(0,m);s=s.slice(m+2);let d=ne(a);d&&process.stdout.write(d),m=s.indexOf(`
9
+ `);for(;m!==-1;){let a=s.slice(0,m);s=s.slice(m+2);let d=de(a);d&&process.stdout.write(d),m=s.indexOf(`
10
10
 
11
- `)}}}finally{t.releaseLock()}}n(_,"streamSandboxEventOutput");function Y(o){return typeof o=="string"?{dataBase64:Buffer.from(o,"utf-8").toString("base64")}:o instanceof Uint8Array?{dataBase64:Buffer.from(o).toString("base64")}:o}n(Y,"normalizePtyInput");function ne(o){if(!o.includes("event: output"))return null;let e=o.split(/\r?\n/).filter(t=>t.startsWith("data: ")).map(t=>t.slice(6));if(e.length===0)return null;try{let t=JSON.parse(e.join(`
12
- `));return typeof t.output=="string"?t.output:null}catch{return null}}n(ne,"parseProcessOutputEvent");var O=class{static{n(this,"OpenPondSandboxInstanceClient")}apiKey;apiRootUrl;sandboxApiUrl;customEndpoint;constructor(e){this.apiKey=e.apiKey,this.customEndpoint=e.customEndpoint??!1,this.sandboxApiUrl=C(e.sandboxApiUrl??e.baseUrl??U),this.apiRootUrl=L(this.sandboxApiUrl)}create(e,t={}){return this.request("",{method:"POST",...this.customEndpoint?{timeoutMs:18e4}:{},headers:R(t),body:JSON.stringify(e)}).then(r=>r.sandbox)}get(e){return this.request(`/${encodeURIComponent(e)}`).then(t=>t.sandbox)}exec(e,t){return this.request(`/${encodeURIComponent(e)}/exec`,{method:"POST",body:JSON.stringify(t)})}startProcess(e,t){return this.request(`/${encodeURIComponent(e)}/processes`,{method:"POST",body:JSON.stringify(t)})}listProcesses(e){return this.request(`/${encodeURIComponent(e)}/processes`)}getProcess(e,t,r={}){let s=new URLSearchParams;return r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),this.request(`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}${s.size>0?`?${s.toString()}`:""}`)}stopProcess(e,t){return this.request(`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}`,{method:"DELETE"})}async streamProcessOutput(e,t,r={}){let s=new URLSearchParams;r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),await _({sandboxApiUrl:this.sandboxApiUrl,apiKey:this.apiKey,path:`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/stream${s.size>0?`?${s.toString()}`:""}`})}startPty(e,t={}){return this.request(`/${encodeURIComponent(e)}/pty`,{method:"POST",body:JSON.stringify(t)})}listPtys(e){return this.request(`/${encodeURIComponent(e)}/pty`)}getPty(e,t,r={}){let s=new URLSearchParams;return r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}${s.size>0?`?${s.toString()}`:""}`)}writePtyInput(e,t,r){return this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}/input`,{method:"POST",body:JSON.stringify(Y(r))})}stopPty(e,t){return this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}`,{method:"DELETE"})}async streamPtyOutput(e,t,r={}){let s=new URLSearchParams;r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),await _({sandboxApiUrl:this.sandboxApiUrl,apiKey:this.apiKey,path:`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}/stream${s.size>0?`?${s.toString()}`:""}`})}uploadFile(e,t,r){return this.uploadFileBase64(e,t,Buffer.from(r,"utf-8").toString("base64"))}uploadFileBase64(e,t,r){return this.request(`/${encodeURIComponent(e)}/files`,{method:"POST",body:JSON.stringify({path:t,contentsBase64:r})})}async downloadFile(e,t){let r=await this.downloadFileResponse(e,t);return Buffer.from(r.file.contentsBase64,"base64").toString("utf-8")}downloadFileResponse(e,t){let r=typeof t=="string"?{path:t}:t,s=new URLSearchParams({path:r.path});return r.offsetBytes!==void 0&&s.set("offsetBytes",String(r.offsetBytes)),r.maxBytes!==void 0&&s.set("maxBytes",String(r.maxBytes)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`)}listFiles(e,t={}){let r=new URLSearchParams({list:"1"});return t.path&&r.set("path",t.path),t.recursive!==void 0&&r.set("recursive",String(t.recursive)),t.maxEntries!==void 0&&r.set("maxEntries",String(t.maxEntries)),this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`)}deleteFile(e,t,r={}){let s=new URLSearchParams({path:t});return r.recursive!==void 0&&s.set("recursive",String(r.recursive)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`,{method:"DELETE"})}statFile(e,t){let r=new URLSearchParams({stat:"1",path:t});return this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`)}mkdir(e,t){let r=typeof t=="string"?{path:t}:t,s=new URLSearchParams({path:r.path});return r.recursive!==void 0&&s.set("recursive",String(r.recursive)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`,{method:"PUT"})}moveFile(e,t){let r=new URLSearchParams({fromPath:t.fromPath,toPath:t.toPath});return t.overwrite!==void 0&&r.set("overwrite",String(t.overwrite)),this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`,{method:"PATCH"})}searchFiles(e,t){let r=new URLSearchParams({search:"1",query:t.query});return t.path&&r.set("path",t.path),t.maxResults!==void 0&&r.set("maxResults",String(t.maxResults)),this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`)}openPort(e,t){return this.request(`/${encodeURIComponent(e)}/ports`,{method:"POST",body:JSON.stringify(t)})}createSnapshot(e,t){return this.request(`/${encodeURIComponent(e)}/snapshots`,{method:"POST",body:JSON.stringify(t)})}updateSnapshot(e,t,r){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}validateSnapshot(e,t,r={}){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}/validate`,{method:"POST",body:JSON.stringify(r)})}publishSnapshot(e,t){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}/publish`,{method:"POST"})}fork(e,t={}){return this.request(`/${encodeURIComponent(e)}/fork`,{method:"POST",body:JSON.stringify(t)})}stop(e,t={}){let r=new URLSearchParams;return t.failOnUnpreservedChanges&&r.set("failOnUnpreservedChanges","true"),this.request(`/${encodeURIComponent(e)}/stop${r.size>0?`?${r.toString()}`:""}`,{method:"POST",headers:R(t)})}start(e,t={}){return this.request(`/${encodeURIComponent(e)}/start`,{method:"POST",headers:R(t)})}restore(e){return this.request(`/${encodeURIComponent(e)}/restore`,{method:"POST"})}delete(e,t={}){let r=new URLSearchParams;return t.failOnUnpreservedChanges&&r.set("failOnUnpreservedChanges","true"),this.request(`/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`,{method:"DELETE",headers:R(t)}).then(s=>s.sandbox)}receipts(e){return this.request(`/${encodeURIComponent(e)}/receipts`).then(t=>t.receipts)}logs(e){return this.request(`/${encodeURIComponent(e)}/logs`).then(t=>t.logs)}gitStatus(e){return this.request(`/${encodeURIComponent(e)}/git/status`)}gitDiff(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/diff`,{method:"POST",body:JSON.stringify(t)})}gitExportPatch(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/export-patch`,{method:"POST",body:JSON.stringify(t)})}gitBranch(e,t){return this.request(`/${encodeURIComponent(e)}/git/branch`,{method:"POST",body:JSON.stringify(t)})}gitCommit(e,t){return this.request(`/${encodeURIComponent(e)}/git/commit`,{method:"POST",body:JSON.stringify(t)})}gitPull(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/pull`,{method:"POST",body:JSON.stringify(t)})}gitPush(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/push`,{method:"POST",body:JSON.stringify(t)})}billing(e){return this.request(`/${encodeURIComponent(e)}/billing`)}pricing(){return this.request("/pricing")}costs(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.request(`/costs${t.size>0?`?${t.toString()}`:""}`)}integrationLeases(e){return this.request(`/${encodeURIComponent(e)}/integrations`)}attachIntegrationConnection(e,t){return this.request(`/${encodeURIComponent(e)}/integrations`,{method:"POST",body:JSON.stringify(t)})}removeIntegrationLease(e,t){return this.request(`/${encodeURIComponent(e)}/integrations`,{method:"DELETE",body:JSON.stringify({leaseId:t})})}async request(e,t={}){let r=await x(this.sandboxApiUrl,this.apiKey,e,this.customEndpoint?{...t,explicitBearerAuth:!0,redirect:"error"}:t);return T(r,"Sandbox request")}async requestApiRoot(e,t={}){let r=await x(this.apiRootUrl,this.apiKey,e,this.customEndpoint?{...t,explicitBearerAuth:!0,redirect:"error"}:t);return T(r,"OpenPond API request")}};var j=class extends O{static{n(this,"OpenPondSandboxClient")}runtimes=B(this);sandboxes=z(this);profile=J(this);projects=D(this);agents=M(this);list(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.request(t.size>0?`?${t.toString()}`:"").then(r=>r.sandboxes)}listSecrets(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),this.requestApiRoot(`/sandbox-secrets${t.size>0?`?${t.toString()}`:""}`).then(r=>r.secrets)}getSecret(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`).then(s=>s.secret)}createSecret(e){return this.requestApiRoot("/sandbox-secrets",{method:"POST",body:JSON.stringify(e)}).then(t=>t.secret)}rotateSecret(e,t){let r=new URLSearchParams;t.teamId&&r.set("teamId",t.teamId);let{teamId:s,...i}=t;return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/rotate${r.size>0?`?${r.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(c=>c.secret)}attachSecret(e,t){let r=new URLSearchParams;t.teamId&&r.set("teamId",t.teamId);let{teamId:s,...i}=t;return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/attach${r.size>0?`?${r.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(c=>c.secret)}revokeSecret(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/revoke${r.size>0?`?${r.toString()}`:""}`,{method:"POST"}).then(s=>s.secret)}deleteSecret(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`,{method:"DELETE"}).then(s=>s.secret)}snapshotCatalog(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),e.q&&t.set("q",e.q),e.kind&&t.set("kind",e.kind),e.replayState&&t.set("replayState",e.replayState),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/catalog/snapshots${t.size>0?`?${t.toString()}`:""}`)}listSandboxRuntimes(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.requestApiRoot(`/runtimes${t.size>0?`?${t.toString()}`:""}`).then(r=>r.runtimes)}listProjects(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/projects?${t.toString()}`).then(r=>r.projects)}upsertProject(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/projects?${t.toString()}`,{method:"POST",body:JSON.stringify(e)}).then(r=>r.project)}getHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/profile?${t.toString()}`).then(r=>r.profile)}ensureHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/profile/ensure?${t.toString()}`,{method:"POST"}).then(r=>{if(!r.profile)throw new Error("hosted_profile_missing");return r.profile})}pushHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId}),{teamId:r,...s}=e;return this.requestApiRoot(`/profile/push?${t.toString()}`,{method:"POST",body:JSON.stringify(s)})}async upsertProjectGitRemote(e){let t=await this.upsertProject(e);return this.ensureProjectGitRemote(t.id,{teamId:e.teamId})}getProject(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${r.toString()}`).then(s=>s.project)}syncProject(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/sync?${r.toString()}`,{method:"POST"}).then(s=>s.project)}ensureProjectGitRemote(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/git?${r.toString()}`,{method:"POST"})}uploadProjectSource(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/source?${r.toString()}`,{method:"POST",body:JSON.stringify(i)}).then(c=>c.project)}updateProject(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${r.toString()}`,{method:"PATCH",body:JSON.stringify(i)}).then(c=>c.project)}archiveProject(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${r.toString()}`,{method:"DELETE"}).then(s=>s.project)}listAgents(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/agents?${t.toString()}`).then(r=>r.agents)}upsertAgent(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/agents?${t.toString()}`,{method:"POST",body:JSON.stringify(e)}).then(r=>r.agent)}getAgent(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${r.toString()}`).then(s=>s.agent)}archiveAgent(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${r.toString()}`,{method:"DELETE"}).then(s=>s.agent)}updateAgent(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${r.toString()}`,{method:"PATCH",body:JSON.stringify(i)}).then(c=>c.agent)}runAgent(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/run?${r.toString()}`,{method:"POST",headers:{Prefer:"respond-async"},body:JSON.stringify(i)})}getAgentSourceDeployPlan(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/deploy-plan?${r.toString()}`).then(s=>s.deployPlan)}listAgentManifestSnapshots(e,t){let r=new URLSearchParams({teamId:t.teamId});return t.limit!==void 0&&r.set("limit",String(t.limit)),this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/manifest-snapshots?${r.toString()}`).then(s=>s.manifestSnapshots)}requestAgentSourceChecks(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/checks?${r.toString()}`,{method:"POST",body:JSON.stringify(i),timeoutMs:900*1e3})}configureAgentSourceSetup(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/setup?${r.toString()}`,{method:"POST",body:JSON.stringify(i)})}publishAgentSource(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/publish?${r.toString()}`,{method:"POST",body:JSON.stringify(i)})}getMicrosoftTeamsBotOverview(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/teams/bot/overview?${t.toString()}`)}bindMicrosoftTeamsBotConversation(e){return this.requestApiRoot("/teams/bot/bindings",{method:"POST",body:JSON.stringify(e)})}rebindMicrosoftTeamsBotConversation(e,t){return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}unlinkMicrosoftTeamsBotConversation(e){return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(e.bindingId)}`,{method:"DELETE",body:JSON.stringify({teamId:e.teamId})})}sendMicrosoftTeamsBotDiagnostic(e){return this.requestApiRoot("/teams/bot/diagnostics",{method:"POST",body:JSON.stringify(e)})}sendMicrosoftTeamsBotDiagnosticRun(e){return this.requestApiRoot("/teams/bot/diagnostics/run",{method:"POST",body:JSON.stringify(e)})}createSandboxRuntime(e){return this.requestApiRoot("/runtimes",{method:"POST",body:JSON.stringify(e)}).then(t=>t.runtime)}sandboxRuntime(e,t=null){return F(this,e,t)}getSandboxRuntime(e){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}`).then(t=>t.runtime)}createSandboxRuntimeSandbox(e,t={},r={}){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/sandbox`,{method:"POST",headers:R(r),body:JSON.stringify(t)})}updateSandboxRuntimeStatus(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/status`,{method:"PATCH",body:JSON.stringify(t)}).then(r=>r.runtime)}listSandboxRuntimeEvents(e){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/events`)}emitSandboxRuntimeEvent(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/events`,{method:"POST",body:JSON.stringify(t)})}checkpointSandboxRuntime(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/checkpoints`,{method:"POST",body:JSON.stringify(t)}).then(r=>r.runtime)}promoteSandboxRuntime(e,t,r={}){let s=new URLSearchParams;return r.teamId&&s.set("teamId",r.teamId),this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/promote${s.size>0?`?${s.toString()}`:""}`,{method:"POST",body:JSON.stringify(t)})}preserveSandboxRuntimeSource(e,t={},r={}){let s=new URLSearchParams;return r.teamId&&s.set("teamId",r.teamId),this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/preserve-source${s.size>0?`?${s.toString()}`:""}`,{method:"POST",body:JSON.stringify(t)})}forkSnapshot(e,t={},r={}){let s=new URLSearchParams;t.teamId&&s.set("teamId",t.teamId),t.projectId&&s.set("projectId",t.projectId),r.async&&s.set("async","1");let{teamId:i,projectId:c,...m}=t;return this.request(`/catalog/snapshots/${encodeURIComponent(e)}/fork${s.size>0?`?${s.toString()}`:""}`,{method:"POST",headers:r.async?{Prefer:"respond-async"}:void 0,body:JSON.stringify({...m,snapshotId:e})})}templates(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.q&&t.set("q",e.q),e.name&&t.set("name",e.name),e.version&&t.set("version",e.version),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/templates${t.size>0?`?${t.toString()}`:""}`)}publishedSnapshots(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.q&&t.set("q",e.q),e.name&&t.set("name",e.name),e.version&&t.set("version",e.version),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/published-snapshots${t.size>0?`?${t.toString()}`:""}`).then(r=>{let s=r.publishedSnapshots??r.templates;return{...r,templates:s,publishedSnapshots:s}})}launchTemplate(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:r,projectId:s,...i}=e;return this.request(`/templates/launch${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)})}runPublishedSnapshot(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:r,projectId:s,...i}=e;return this.request(`/published-snapshots/launch${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(c=>{let m=c.publishedSnapshot??c.template;return{...c,template:m,publishedSnapshot:m}})}listSchedules(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.sourceSandboxId&&t.set("sourceSandboxId",e.sourceSandboxId),this.request(`/schedules${t.size>0?`?${t.toString()}`:""}`)}createSchedule(e){let t=new URLSearchParams;e.projectId&&t.set("projectId",e.projectId);let{projectId:r,...s}=e;return this.request(`/schedules${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(s)})}getSchedule(e){return this.request(`/schedules/${encodeURIComponent(e)}`)}updateSchedule(e,t){return this.request(`/schedules/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}deleteSchedule(e){return this.request(`/schedules/${encodeURIComponent(e)}`,{method:"DELETE"})}listScheduleRuns(e,t={}){let r=new URLSearchParams;return t.limit!==void 0&&r.set("limit",String(t.limit)),this.request(`/schedules/${encodeURIComponent(e)}/runs${r.size>0?`?${r.toString()}`:""}`)}runScheduleNow(e,t={}){return this.request(`/schedules/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t)})}listTemplateBuilds(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/sandbox-template-builds?${t.toString()}`).then(r=>r.builds)}createTemplateBuild(e){return this.requestApiRoot("/sandbox-template-builds",{method:"POST",body:JSON.stringify(e)}).then(t=>t.build)}getTemplateBuild(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}`).then(t=>t.build)}getTemplateBuildLogs(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}/logs`)}cancelTemplateBuild(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}/cancel`,{method:"POST"}).then(t=>t.build)}listPublishedSnapshotBuilds(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/published-snapshot-builds?${t.toString()}`).then(r=>r.builds)}createPublishedSnapshotBuild(e){return this.requestApiRoot("/published-snapshot-builds",{method:"POST",body:JSON.stringify(e)}).then(t=>t.build)}getPublishedSnapshotBuild(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}`).then(t=>t.build)}getPublishedSnapshotBuildLogs(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}/logs`)}cancelPublishedSnapshotBuild(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}/cancel`,{method:"POST"}).then(t=>t.build)}listOrganizations(){return this.requestApiRoot("/organizations").then(e=>e.organizations??e.teams??[])}createOrganization(e){return this.requestApiRoot("/organizations",{method:"POST",body:JSON.stringify(e)}).then(t=>t.organization)}getOrganization(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}`).then(t=>t.organization)}updateOrganization(e,t){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}).then(r=>r.organization)}listOrganizationMembers(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/members`).then(t=>t.members)}upsertOrganizationMember(e,t){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)}).then(r=>r.member)}getOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server`).then(t=>t.mcpServer)}generateOrganizationMcpServer(e,t={}){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server`,{method:"POST",body:JSON.stringify(t)}).then(r=>r.mcpServer)}rotateOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/rotate`,{method:"POST"}).then(t=>t.mcpServer)}disableOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/disable`,{method:"POST"}).then(t=>t.mcpServer)}enableOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/enable`,{method:"POST"}).then(t=>t.mcpServer)}startReplay(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:r,projectId:s,...i}=e;return this.requestApiRoot(`/sandbox-replays${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)})}listReplays(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),this.requestApiRoot(`/sandbox-replays${t.size>0?`?${t.toString()}`:""}`)}getReplay(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`)}getReplayLogs(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/logs${r.size>0?`?${r.toString()}`:""}`)}getReplayArtifacts(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/artifacts${r.size>0?`?${r.toString()}`:""}`)}cancelReplay(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/cancel${r.size>0?`?${r.toString()}`:""}`,{method:"POST"})}integrationConnections(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),e.status&&t.set("status",e.status),this.requestApiRoot(`/integrations/connections${t.size>0?`?${t.toString()}`:""}`)}mcpServerConfig(){return{name:"openpond-sandboxes",transport:"streamable-http",url:`${this.sandboxApiUrl}/mcp`,headers:{"openpond-api-key":this.apiKey}}}smoke(e={}){return W(this,e)}};function De(o){return new j(o)}n(De,"createOpenPondSandboxClient");import{randomUUID as ae}from"node:crypto";function ie(o){let e=g(o);if(!e)throw new Error("apiBaseUrl is required");return e}n(ie,"normalizeApiBaseUrl");function V(o){return o.replace(/\/+$/,"")}n(V,"trimTrailingSlashes");function g(o){let e=V(o?.trim()??"");return e?(e=e.replace(/\/chat\/completions$/i,"").replace(/\/models(?:\/[^/]+)?$/i,""),e.endsWith("/opchat/v1")?e:e.endsWith("/opchat")?`${e}/v1`:(e.endsWith("/v1")&&(e=e.slice(0,-3)),`${V(e)}/opchat/v1`)):null}n(g,"normalizeOptionalOpChatApiBaseUrl");function We(o={}){let e=o.env??(typeof process<"u"?process.env:{}),t=g(o.opChatApiBaseUrl)??g(e.OPENPOND_OPCHAT_API_URL);if(t)return t;let r=g(o.chatApiBaseUrl)??g(e.OPENPOND_CHAT_API_URL)??g(e.OPENPOND_GATEWAY_URL);return r||(g(o.apiBaseUrl)??g(e.OPENPOND_API_URL)??N)}n(We,"resolveOpChatApiBaseUrl");function de(o){let e=o.trim();if(!e)throw new Error("OpenPond API key is required");return e}n(de,"requireToken");function ce(o,e,t){let r=new Headers;return r.set("Authorization",`Bearer ${de(o)}`),r.set("Content-Type","application/json"),r.set("Accept",e),r.set("x-openpond-client","openpond-code"),r.set("x-openpond-request-id",t||ae()),r}n(ce,"hostedHeaders");async function me(o){let e=await o.text().catch(()=>"");if(!e)return o.statusText||`HTTP ${o.status}`;try{let t=JSON.parse(e),r=typeof t.error=="string"||t.error&&typeof t.error=="object"&&!Array.isArray(t.error)?t.error:null,s=typeof t.code=="string"?t.code:r&&typeof r!="string"&&typeof r.code=="string"?r.code:null,i=typeof t.message=="string"?t.message:r&&typeof r!="string"&&typeof r.message=="string"?r.message:null,c=typeof r=="string"?r:r&&typeof r.type=="string"?r.type:null;return[s,c,i].filter(Boolean).join(": ")||e}catch{return e}}n(me,"readError");function ue(o,e){let t={model:o.model,messages:o.messages,stream:e};typeof o.temperature=="number"&&(t.temperature=o.temperature),typeof o.maxTokens=="number"&&(t.max_tokens=o.maxTokens),o.reasoningEffort==="off"?t.thinking={type:"disabled"}:o.reasoningEffort&&(t.reasoning_effort=o.reasoningEffort),o.tools&&(t.tools=o.tools);let r=o.toolChoice??o.tool_choice;return r!==void 0&&(t.tool_choice=r),o.metadata&&(t.metadata=o.metadata),t}n(ue,"buildHostedChatBody");async function Ke(o){let t=`${ie(o.apiBaseUrl)}/chat/completions`,r=await fetch(t,{method:"POST",headers:ce(o.token,"application/json",o.requestId),body:JSON.stringify(ue(o,!1)),signal:o.signal});if(!r.ok)throw new Error(`Hosted chat failed: ${r.status} ${await me(r)}`);return await r.json()}n(Ke,"sendHostedChatTurn");export{E as a,x as b,T as c,k as d,U as e,C as f,j as g,De as h,We as i,Ke as j};
11
+ `)}}}finally{t.releaseLock()}}n(_,"streamSandboxEventOutput");function Y(o){return typeof o=="string"?{dataBase64:Buffer.from(o,"utf-8").toString("base64")}:o instanceof Uint8Array?{dataBase64:Buffer.from(o).toString("base64")}:o}n(Y,"normalizePtyInput");function de(o){if(!o.includes("event: output"))return null;let e=o.split(/\r?\n/).filter(t=>t.startsWith("data: ")).map(t=>t.slice(6));if(e.length===0)return null;try{let t=JSON.parse(e.join(`
12
+ `));return typeof t.output=="string"?t.output:null}catch{return null}}n(de,"parseProcessOutputEvent");var O=class{static{n(this,"OpenPondSandboxInstanceClient")}apiKey;apiRootUrl;sandboxApiUrl;customEndpoint;constructor(e){this.apiKey=e.apiKey,this.customEndpoint=e.customEndpoint??!1,this.sandboxApiUrl=C(e.sandboxApiUrl??e.baseUrl??U),this.apiRootUrl=L(this.sandboxApiUrl)}create(e,t={}){return this.request("",{method:"POST",...this.customEndpoint?{timeoutMs:18e4}:{},headers:R(t),body:JSON.stringify(e)}).then(r=>r.sandbox)}get(e){return this.request(`/${encodeURIComponent(e)}`).then(t=>t.sandbox)}exec(e,t){return this.request(`/${encodeURIComponent(e)}/exec`,{method:"POST",body:JSON.stringify(t)})}startProcess(e,t){return this.request(`/${encodeURIComponent(e)}/processes`,{method:"POST",body:JSON.stringify(t)})}listProcesses(e){return this.request(`/${encodeURIComponent(e)}/processes`)}getProcess(e,t,r={}){let s=new URLSearchParams;return r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),this.request(`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}${s.size>0?`?${s.toString()}`:""}`)}stopProcess(e,t){return this.request(`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}`,{method:"DELETE"})}async streamProcessOutput(e,t,r={}){let s=new URLSearchParams;r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),await _({sandboxApiUrl:this.sandboxApiUrl,apiKey:this.apiKey,path:`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/stream${s.size>0?`?${s.toString()}`:""}`})}startPty(e,t={}){return this.request(`/${encodeURIComponent(e)}/pty`,{method:"POST",body:JSON.stringify(t)})}listPtys(e){return this.request(`/${encodeURIComponent(e)}/pty`)}getPty(e,t,r={}){let s=new URLSearchParams;return r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}${s.size>0?`?${s.toString()}`:""}`)}writePtyInput(e,t,r){return this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}/input`,{method:"POST",body:JSON.stringify(Y(r))})}stopPty(e,t){return this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}`,{method:"DELETE"})}async streamPtyOutput(e,t,r={}){let s=new URLSearchParams;r.since!==void 0&&s.set("since",String(Math.max(0,r.since))),await _({sandboxApiUrl:this.sandboxApiUrl,apiKey:this.apiKey,path:`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}/stream${s.size>0?`?${s.toString()}`:""}`})}uploadFile(e,t,r){return this.uploadFileBase64(e,t,Buffer.from(r,"utf-8").toString("base64"))}uploadFileBase64(e,t,r){return this.request(`/${encodeURIComponent(e)}/files`,{method:"POST",body:JSON.stringify({path:t,contentsBase64:r})})}async downloadFile(e,t){let r=await this.downloadFileResponse(e,t);return Buffer.from(r.file.contentsBase64,"base64").toString("utf-8")}downloadFileResponse(e,t){let r=typeof t=="string"?{path:t}:t,s=new URLSearchParams({path:r.path});return r.offsetBytes!==void 0&&s.set("offsetBytes",String(r.offsetBytes)),r.maxBytes!==void 0&&s.set("maxBytes",String(r.maxBytes)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`)}listFiles(e,t={}){let r=new URLSearchParams({list:"1"});return t.path&&r.set("path",t.path),t.recursive!==void 0&&r.set("recursive",String(t.recursive)),t.maxEntries!==void 0&&r.set("maxEntries",String(t.maxEntries)),this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`)}deleteFile(e,t,r={}){let s=new URLSearchParams({path:t});return r.recursive!==void 0&&s.set("recursive",String(r.recursive)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`,{method:"DELETE"})}statFile(e,t){let r=new URLSearchParams({stat:"1",path:t});return this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`)}mkdir(e,t){let r=typeof t=="string"?{path:t}:t,s=new URLSearchParams({path:r.path});return r.recursive!==void 0&&s.set("recursive",String(r.recursive)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`,{method:"PUT"})}moveFile(e,t){let r=new URLSearchParams({fromPath:t.fromPath,toPath:t.toPath});return t.overwrite!==void 0&&r.set("overwrite",String(t.overwrite)),this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`,{method:"PATCH"})}searchFiles(e,t){let r=new URLSearchParams({search:"1",query:t.query});return t.path&&r.set("path",t.path),t.maxResults!==void 0&&r.set("maxResults",String(t.maxResults)),this.request(`/${encodeURIComponent(e)}/files?${r.toString()}`)}openPort(e,t){return this.request(`/${encodeURIComponent(e)}/ports`,{method:"POST",body:JSON.stringify(t)})}createSnapshot(e,t){return this.request(`/${encodeURIComponent(e)}/snapshots`,{method:"POST",body:JSON.stringify(t)})}updateSnapshot(e,t,r){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}validateSnapshot(e,t,r={}){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}/validate`,{method:"POST",body:JSON.stringify(r)})}publishSnapshot(e,t){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}/publish`,{method:"POST"})}fork(e,t={}){return this.request(`/${encodeURIComponent(e)}/fork`,{method:"POST",body:JSON.stringify(t)})}stop(e,t={}){let r=new URLSearchParams;return t.failOnUnpreservedChanges&&r.set("failOnUnpreservedChanges","true"),this.request(`/${encodeURIComponent(e)}/stop${r.size>0?`?${r.toString()}`:""}`,{method:"POST",headers:R(t)})}start(e,t={}){return this.request(`/${encodeURIComponent(e)}/start`,{method:"POST",headers:R(t)})}restore(e){return this.request(`/${encodeURIComponent(e)}/restore`,{method:"POST"})}delete(e,t={}){let r=new URLSearchParams;return t.failOnUnpreservedChanges&&r.set("failOnUnpreservedChanges","true"),this.request(`/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`,{method:"DELETE",headers:R(t)}).then(s=>s.sandbox)}receipts(e){return this.request(`/${encodeURIComponent(e)}/receipts`).then(t=>t.receipts)}logs(e){return this.request(`/${encodeURIComponent(e)}/logs`).then(t=>t.logs)}gitStatus(e){return this.request(`/${encodeURIComponent(e)}/git/status`)}gitDiff(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/diff`,{method:"POST",body:JSON.stringify(t)})}gitExportPatch(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/export-patch`,{method:"POST",body:JSON.stringify(t)})}gitBranch(e,t){return this.request(`/${encodeURIComponent(e)}/git/branch`,{method:"POST",body:JSON.stringify(t)})}gitCommit(e,t){return this.request(`/${encodeURIComponent(e)}/git/commit`,{method:"POST",body:JSON.stringify(t)})}gitPull(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/pull`,{method:"POST",body:JSON.stringify(t)})}gitPush(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/push`,{method:"POST",body:JSON.stringify(t)})}billing(e){return this.request(`/${encodeURIComponent(e)}/billing`)}pricing(){return this.request("/pricing")}costs(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.request(`/costs${t.size>0?`?${t.toString()}`:""}`)}integrationLeases(e){return this.request(`/${encodeURIComponent(e)}/integrations`)}attachIntegrationConnection(e,t){return this.request(`/${encodeURIComponent(e)}/integrations`,{method:"POST",body:JSON.stringify(t)})}removeIntegrationLease(e,t){return this.request(`/${encodeURIComponent(e)}/integrations`,{method:"DELETE",body:JSON.stringify({leaseId:t})})}async request(e,t={}){let r=await x(this.sandboxApiUrl,this.apiKey,e,this.customEndpoint?{...t,explicitBearerAuth:!0,redirect:"error"}:t);return T(r,"Sandbox request")}async requestApiRoot(e,t={}){let r=await x(this.apiRootUrl,this.apiKey,e,this.customEndpoint?{...t,explicitBearerAuth:!0,redirect:"error"}:t);return T(r,"OpenPond API request")}};var j=class extends O{static{n(this,"OpenPondSandboxClient")}runtimes=B(this);sandboxes=z(this);profile=J(this);projects=D(this);agents=M(this);list(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.request(t.size>0?`?${t.toString()}`:"").then(r=>r.sandboxes)}listSecrets(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),this.requestApiRoot(`/sandbox-secrets${t.size>0?`?${t.toString()}`:""}`).then(r=>r.secrets)}getSecret(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`).then(s=>s.secret)}createSecret(e){return this.requestApiRoot("/sandbox-secrets",{method:"POST",body:JSON.stringify(e)}).then(t=>t.secret)}rotateSecret(e,t){let r=new URLSearchParams;t.teamId&&r.set("teamId",t.teamId);let{teamId:s,...i}=t;return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/rotate${r.size>0?`?${r.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(c=>c.secret)}attachSecret(e,t){let r=new URLSearchParams;t.teamId&&r.set("teamId",t.teamId);let{teamId:s,...i}=t;return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/attach${r.size>0?`?${r.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(c=>c.secret)}revokeSecret(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/revoke${r.size>0?`?${r.toString()}`:""}`,{method:"POST"}).then(s=>s.secret)}deleteSecret(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`,{method:"DELETE"}).then(s=>s.secret)}snapshotCatalog(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),e.q&&t.set("q",e.q),e.kind&&t.set("kind",e.kind),e.replayState&&t.set("replayState",e.replayState),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/catalog/snapshots${t.size>0?`?${t.toString()}`:""}`)}listSandboxRuntimes(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.requestApiRoot(`/runtimes${t.size>0?`?${t.toString()}`:""}`).then(r=>r.runtimes)}listProjects(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/projects?${t.toString()}`).then(r=>r.projects)}upsertProject(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/projects?${t.toString()}`,{method:"POST",body:JSON.stringify(e)}).then(r=>r.project)}getHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/profile?${t.toString()}`).then(r=>r.profile)}ensureHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/profile/ensure?${t.toString()}`,{method:"POST"}).then(r=>{if(!r.profile)throw new Error("hosted_profile_missing");return r.profile})}pushHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId}),{teamId:r,...s}=e;return this.requestApiRoot(`/profile/push?${t.toString()}`,{method:"POST",body:JSON.stringify(s)})}async upsertProjectGitRemote(e){let t=await this.upsertProject(e);return this.ensureProjectGitRemote(t.id,{teamId:e.teamId})}getProject(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${r.toString()}`).then(s=>s.project)}syncProject(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/sync?${r.toString()}`,{method:"POST"}).then(s=>s.project)}ensureProjectGitRemote(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/git?${r.toString()}`,{method:"POST"})}uploadProjectSource(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/source?${r.toString()}`,{method:"POST",body:JSON.stringify(i)}).then(c=>c.project)}updateProject(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${r.toString()}`,{method:"PATCH",body:JSON.stringify(i)}).then(c=>c.project)}archiveProject(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${r.toString()}`,{method:"DELETE"}).then(s=>s.project)}listAgents(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/agents?${t.toString()}`).then(r=>r.agents)}upsertAgent(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/agents?${t.toString()}`,{method:"POST",body:JSON.stringify(e)}).then(r=>r.agent)}getAgent(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${r.toString()}`).then(s=>s.agent)}archiveAgent(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${r.toString()}`,{method:"DELETE"}).then(s=>s.agent)}updateAgent(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${r.toString()}`,{method:"PATCH",body:JSON.stringify(i)}).then(c=>c.agent)}runAgent(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/run?${r.toString()}`,{method:"POST",headers:{Prefer:"respond-async"},body:JSON.stringify(i)})}getAgentSourceDeployPlan(e,t){let r=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/deploy-plan?${r.toString()}`).then(s=>s.deployPlan)}listAgentManifestSnapshots(e,t){let r=new URLSearchParams({teamId:t.teamId});return t.limit!==void 0&&r.set("limit",String(t.limit)),this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/manifest-snapshots?${r.toString()}`).then(s=>s.manifestSnapshots)}requestAgentSourceChecks(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/checks?${r.toString()}`,{method:"POST",body:JSON.stringify(i),timeoutMs:900*1e3})}configureAgentSourceSetup(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/setup?${r.toString()}`,{method:"POST",body:JSON.stringify(i)})}publishAgentSource(e,t){let r=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/publish?${r.toString()}`,{method:"POST",body:JSON.stringify(i)})}getMicrosoftTeamsBotOverview(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/teams/bot/overview?${t.toString()}`)}bindMicrosoftTeamsBotConversation(e){return this.requestApiRoot("/teams/bot/bindings",{method:"POST",body:JSON.stringify(e)})}rebindMicrosoftTeamsBotConversation(e,t){return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}unlinkMicrosoftTeamsBotConversation(e){return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(e.bindingId)}`,{method:"DELETE",body:JSON.stringify({teamId:e.teamId})})}sendMicrosoftTeamsBotDiagnostic(e){return this.requestApiRoot("/teams/bot/diagnostics",{method:"POST",body:JSON.stringify(e)})}sendMicrosoftTeamsBotDiagnosticRun(e){return this.requestApiRoot("/teams/bot/diagnostics/run",{method:"POST",body:JSON.stringify(e)})}createSandboxRuntime(e){return this.requestApiRoot("/runtimes",{method:"POST",body:JSON.stringify(e)}).then(t=>t.runtime)}sandboxRuntime(e,t=null){return F(this,e,t)}getSandboxRuntime(e){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}`).then(t=>t.runtime)}createSandboxRuntimeSandbox(e,t={},r={}){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/sandbox`,{method:"POST",headers:R(r),body:JSON.stringify(t)})}updateSandboxRuntimeStatus(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/status`,{method:"PATCH",body:JSON.stringify(t)}).then(r=>r.runtime)}listSandboxRuntimeEvents(e){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/events`)}emitSandboxRuntimeEvent(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/events`,{method:"POST",body:JSON.stringify(t)})}checkpointSandboxRuntime(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/checkpoints`,{method:"POST",body:JSON.stringify(t)}).then(r=>r.runtime)}promoteSandboxRuntime(e,t,r={}){let s=new URLSearchParams;return r.teamId&&s.set("teamId",r.teamId),this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/promote${s.size>0?`?${s.toString()}`:""}`,{method:"POST",body:JSON.stringify(t)})}preserveSandboxRuntimeSource(e,t={},r={}){let s=new URLSearchParams;return r.teamId&&s.set("teamId",r.teamId),this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/preserve-source${s.size>0?`?${s.toString()}`:""}`,{method:"POST",body:JSON.stringify(t)})}forkSnapshot(e,t={},r={}){let s=new URLSearchParams;t.teamId&&s.set("teamId",t.teamId),t.projectId&&s.set("projectId",t.projectId),r.async&&s.set("async","1");let{teamId:i,projectId:c,...m}=t;return this.request(`/catalog/snapshots/${encodeURIComponent(e)}/fork${s.size>0?`?${s.toString()}`:""}`,{method:"POST",headers:r.async?{Prefer:"respond-async"}:void 0,body:JSON.stringify({...m,snapshotId:e})})}templates(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.q&&t.set("q",e.q),e.name&&t.set("name",e.name),e.version&&t.set("version",e.version),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/templates${t.size>0?`?${t.toString()}`:""}`)}publishedSnapshots(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.q&&t.set("q",e.q),e.name&&t.set("name",e.name),e.version&&t.set("version",e.version),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/published-snapshots${t.size>0?`?${t.toString()}`:""}`).then(r=>{let s=r.publishedSnapshots??r.templates;return{...r,templates:s,publishedSnapshots:s}})}launchTemplate(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:r,projectId:s,...i}=e;return this.request(`/templates/launch${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)})}runPublishedSnapshot(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:r,projectId:s,...i}=e;return this.request(`/published-snapshots/launch${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(c=>{let m=c.publishedSnapshot??c.template;return{...c,template:m,publishedSnapshot:m}})}listSchedules(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.sourceSandboxId&&t.set("sourceSandboxId",e.sourceSandboxId),this.request(`/schedules${t.size>0?`?${t.toString()}`:""}`)}createSchedule(e){let t=new URLSearchParams;e.projectId&&t.set("projectId",e.projectId);let{projectId:r,...s}=e;return this.request(`/schedules${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(s)})}getSchedule(e){return this.request(`/schedules/${encodeURIComponent(e)}`)}updateSchedule(e,t){return this.request(`/schedules/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}deleteSchedule(e){return this.request(`/schedules/${encodeURIComponent(e)}`,{method:"DELETE"})}listScheduleRuns(e,t={}){let r=new URLSearchParams;return t.limit!==void 0&&r.set("limit",String(t.limit)),this.request(`/schedules/${encodeURIComponent(e)}/runs${r.size>0?`?${r.toString()}`:""}`)}runScheduleNow(e,t={}){return this.request(`/schedules/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t)})}listTemplateBuilds(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/sandbox-template-builds?${t.toString()}`).then(r=>r.builds)}createTemplateBuild(e){return this.requestApiRoot("/sandbox-template-builds",{method:"POST",body:JSON.stringify(e)}).then(t=>t.build)}getTemplateBuild(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}`).then(t=>t.build)}getTemplateBuildLogs(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}/logs`)}cancelTemplateBuild(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}/cancel`,{method:"POST"}).then(t=>t.build)}listPublishedSnapshotBuilds(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/published-snapshot-builds?${t.toString()}`).then(r=>r.builds)}createPublishedSnapshotBuild(e){return this.requestApiRoot("/published-snapshot-builds",{method:"POST",body:JSON.stringify(e)}).then(t=>t.build)}getPublishedSnapshotBuild(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}`).then(t=>t.build)}getPublishedSnapshotBuildLogs(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}/logs`)}cancelPublishedSnapshotBuild(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}/cancel`,{method:"POST"}).then(t=>t.build)}listOrganizations(){return this.requestApiRoot("/organizations").then(e=>e.organizations??e.teams??[])}createOrganization(e){return this.requestApiRoot("/organizations",{method:"POST",body:JSON.stringify(e)}).then(t=>t.organization)}getOrganization(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}`).then(t=>t.organization)}updateOrganization(e,t){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}).then(r=>r.organization)}listOrganizationMembers(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/members`).then(t=>t.members)}upsertOrganizationMember(e,t){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)}).then(r=>r.member)}getOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server`).then(t=>t.mcpServer)}generateOrganizationMcpServer(e,t={}){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server`,{method:"POST",body:JSON.stringify(t)}).then(r=>r.mcpServer)}rotateOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/rotate`,{method:"POST"}).then(t=>t.mcpServer)}disableOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/disable`,{method:"POST"}).then(t=>t.mcpServer)}enableOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/enable`,{method:"POST"}).then(t=>t.mcpServer)}startReplay(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:r,projectId:s,...i}=e;return this.requestApiRoot(`/sandbox-replays${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)})}listReplays(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),this.requestApiRoot(`/sandbox-replays${t.size>0?`?${t.toString()}`:""}`)}getReplay(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}${r.size>0?`?${r.toString()}`:""}`)}getReplayLogs(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/logs${r.size>0?`?${r.toString()}`:""}`)}getReplayArtifacts(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/artifacts${r.size>0?`?${r.toString()}`:""}`)}cancelReplay(e,t={}){let r=new URLSearchParams;return t.teamId&&r.set("teamId",t.teamId),t.projectId&&r.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/cancel${r.size>0?`?${r.toString()}`:""}`,{method:"POST"})}integrationConnections(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),e.status&&t.set("status",e.status),this.requestApiRoot(`/integrations/connections${t.size>0?`?${t.toString()}`:""}`)}mcpServerConfig(){return{name:"openpond-sandboxes",transport:"streamable-http",url:`${this.sandboxApiUrl}/mcp`,headers:{"openpond-api-key":this.apiKey}}}smoke(e={}){return W(this,e)}};function De(o){return new j(o)}n(De,"createOpenPondSandboxClient");import{randomUUID as ce}from"node:crypto";function X(o){let e=g(o);if(!e)throw new Error("apiBaseUrl is required");return e}n(X,"normalizeApiBaseUrl");function V(o){return o.replace(/\/+$/,"")}n(V,"trimTrailingSlashes");function g(o){let e=V(o?.trim()??"");return e?(e=e.replace(/\/chat\/completions$/i,"").replace(/\/models(?:\/[^/]+)?$/i,""),e.endsWith("/opchat/v1")?e:e.endsWith("/opchat")?`${e}/v1`:(e.endsWith("/v1")&&(e=e.slice(0,-3)),`${V(e)}/opchat/v1`)):null}n(g,"normalizeOptionalOpChatApiBaseUrl");function We(o={}){let e=o.env??(typeof process<"u"?process.env:{}),t=g(o.opChatApiBaseUrl)??g(e.OPENPOND_OPCHAT_API_URL);if(t)return t;let r=g(o.chatApiBaseUrl)??g(e.OPENPOND_CHAT_API_URL)??g(e.OPENPOND_GATEWAY_URL);return r||(g(o.apiBaseUrl)??g(e.OPENPOND_API_URL)??N)}n(We,"resolveOpChatApiBaseUrl");function me(o){let e=o.trim();if(!e)throw new Error("OpenPond API key is required");return e}n(me,"requireToken");function Q(o,e,t){let r=new Headers;return r.set("Authorization",`Bearer ${me(o)}`),r.set("Content-Type","application/json"),r.set("Accept",e),r.set("x-openpond-client","openpond-code"),r.set("x-openpond-request-id",t||ce()),r}n(Q,"hostedHeaders");async function Z(o){let e=await o.text().catch(()=>"");if(!e)return o.statusText||`HTTP ${o.status}`;try{let t=JSON.parse(e),r=typeof t.error=="string"||t.error&&typeof t.error=="object"&&!Array.isArray(t.error)?t.error:null,s=typeof t.code=="string"?t.code:r&&typeof r!="string"&&typeof r.code=="string"?r.code:null,i=typeof t.message=="string"?t.message:r&&typeof r!="string"&&typeof r.message=="string"?r.message:null,c=typeof r=="string"?r:r&&typeof r.type=="string"?r.type:null;return[s,c,i].filter(Boolean).join(": ")||e}catch{return e}}n(Z,"readError");function ue(o,e){let t={model:o.model,messages:o.messages,stream:e};typeof o.temperature=="number"&&(t.temperature=o.temperature),typeof o.maxTokens=="number"&&(t.max_tokens=o.maxTokens),o.reasoningEffort==="off"?t.thinking={type:"disabled"}:o.reasoningEffort&&(t.reasoning_effort=o.reasoningEffort),o.tools&&(t.tools=o.tools);let r=o.toolChoice??o.tool_choice;return r!==void 0&&(t.tool_choice=r),o.metadata&&(t.metadata=o.metadata),t}n(ue,"buildHostedChatBody");async function Ke(o){let t=`${X(o.apiBaseUrl)}/models`,r=await fetch(t,{method:"GET",headers:Q(o.token,"application/json"),signal:o.signal});if(!r.ok)throw new Error(`Hosted model list failed: ${r.status} ${await Z(r)}`);return await r.json()}n(Ke,"listOpChatModels");async function Ye(o){let t=`${X(o.apiBaseUrl)}/chat/completions`,r=await fetch(t,{method:"POST",headers:Q(o.token,"application/json",o.requestId),body:JSON.stringify(ue(o,!1)),signal:o.signal});if(!r.ok)throw new Error(`Hosted chat failed: ${r.status} ${await Z(r)}`);return await r.json()}n(Ye,"sendHostedChatTurn");export{E as a,x as b,T as c,k as d,U as e,C as f,j as g,De as h,We as i,Ke as j,Ye as k};