openpond 0.2.30 → 0.2.31

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 (168) hide show
  1. package/dist/api/types.d.ts +8 -0
  2. package/dist/app-server.d.ts +27797 -513
  3. package/dist/app-server.js +1 -1
  4. package/dist/chunks/{actions-command-NOCBOF5S.js → actions-command-6LFZFTLA.js} +1 -1
  5. package/dist/chunks/{app-layer-GLXYIT4B.js → app-layer-ZZHTHTJU.js} +1 -1
  6. package/dist/chunks/app-server-runtime-256UCS6N.js +2 -0
  7. package/dist/chunks/{apps-YSWZT656.js → apps-C2BMJ7DO.js} +1 -1
  8. package/dist/chunks/{chunk-GOQDMRUV.js → chunk-34URWDE7.js} +1 -1
  9. package/dist/chunks/chunk-4476RDBS.js +41 -0
  10. package/dist/chunks/{chunk-J3ZRHNGL.js → chunk-4QX2I2DX.js} +1 -1
  11. package/dist/chunks/{chunk-TOIG2PMH.js → chunk-55UCBRIX.js} +1 -1
  12. package/dist/chunks/{chunk-2LSP2AAN.js → chunk-5BFWDFPX.js} +1 -1
  13. package/dist/chunks/{chunk-JPCPNW6T.js → chunk-B5LKUQGM.js} +1 -1
  14. package/dist/chunks/{chunk-I7XD5OBR.js → chunk-BAKCGJ5D.js} +1 -1
  15. package/dist/chunks/{chunk-HMADUZ5P.js → chunk-CE27WEHK.js} +1 -1
  16. package/dist/chunks/{chunk-7TV2VBSD.js → chunk-DR3XPQRZ.js} +1 -1
  17. package/dist/chunks/{chunk-C5OV4XWF.js → chunk-EFTLCT7C.js} +1 -1
  18. package/dist/chunks/{chunk-GHGVF2KG.js → chunk-GCU66EAF.js} +1 -1
  19. package/dist/chunks/{chunk-F4WS5QIT.js → chunk-IFP6W4OW.js} +22 -22
  20. package/dist/chunks/{chunk-I5K74TOH.js → chunk-JEVA7YQL.js} +2 -2
  21. package/dist/chunks/{chunk-JKMPJFMN.js → chunk-JFR34MIK.js} +2 -2
  22. package/dist/chunks/chunk-JVIHGSOV.js +6 -0
  23. package/dist/chunks/{chunk-6ZK5EZGN.js → chunk-K6EGNB2A.js} +1 -1
  24. package/dist/chunks/chunk-L2UT3YIF.js +5 -0
  25. package/dist/chunks/{chunk-XLF7VRKY.js → chunk-L54LZUGH.js} +1 -1
  26. package/dist/chunks/{chunk-J2S7BOZU.js → chunk-MJC26GOX.js} +4 -4
  27. package/dist/chunks/{chunk-MAMUNDBZ.js → chunk-MVAJMRCW.js} +3 -3
  28. package/dist/chunks/{chunk-Y2NQXJ2Q.js → chunk-MXLB6MEW.js} +1 -1
  29. package/dist/chunks/chunk-PSZKG3E3.js +4 -0
  30. package/dist/chunks/{chunk-N6HBB2EA.js → chunk-PZ6KPMEZ.js} +342 -335
  31. package/dist/chunks/{chunk-XRV4WLI7.js → chunk-QPZNN5Q3.js} +1 -1
  32. package/dist/chunks/{chunk-ETH4SZO6.js → chunk-QTEYV4TW.js} +1 -1
  33. package/dist/chunks/{chunk-Y2KDWP74.js → chunk-T22TCCWW.js} +1 -1
  34. package/dist/chunks/{chunk-WVUPFGU7.js → chunk-UU7RXSJS.js} +1 -1
  35. package/dist/chunks/{chunk-TJNIYJUH.js → chunk-XCTFXXVY.js} +1 -1
  36. package/dist/chunks/{chunk-6LY7GYNK.js → chunk-Z6F6PYF4.js} +1 -1
  37. package/dist/chunks/cli-DSFTE4KT.js +2 -0
  38. package/dist/chunks/{configuration-command-VGYAJAKN.js → configuration-command-IHUB6BBM.js} +1 -1
  39. package/dist/chunks/{core-commands-QQNCA4WQ.js → core-commands-F2HIN7V4.js} +1 -1
  40. package/dist/chunks/{desktop-test-BMDAEN6Z.js → desktop-test-BFFUGVRS.js} +1 -1
  41. package/dist/chunks/{dist-5C6RYTQQ.js → dist-XCT2G25K.js} +1 -1
  42. package/dist/chunks/extension-D7IYZW7H.js +4 -0
  43. package/dist/chunks/{help-DZBHIKVE.js → help-5MKQV36D.js} +1 -1
  44. package/dist/chunks/opchat-XO7EDHY7.js +3 -0
  45. package/dist/chunks/{organizations-LAUKUPDF.js → organizations-DIRGTVK5.js} +1 -1
  46. package/dist/chunks/{profile-ESJFHPYC.js → profile-EMVJ5DJQ.js} +1 -1
  47. package/dist/chunks/{project-agent-CPQP4ZY6.js → project-agent-4QC7N3MB.js} +1 -1
  48. package/dist/chunks/{sandbox-command-W6NWHFAR.js → sandbox-command-L263BBOL.js} +1 -1
  49. package/dist/chunks/{sandbox-template-SM62NUMJ.js → sandbox-template-RYKWTBW7.js} +1 -1
  50. package/dist/chunks/{src-4L62URN6.js → src-RINMQ7IQ.js} +1 -1
  51. package/dist/chunks/src-RM2LIZGT.js +325 -0
  52. package/dist/chunks/{teams-bot-6LEMA4OH.js → teams-bot-NIZB6DOY.js} +1 -1
  53. package/dist/chunks/{workspaces-5PQMYPBV.js → workspaces-GPYDSN4C.js} +1 -1
  54. package/dist/cli.js +1 -1
  55. package/dist/hosted-chat.d.ts +1 -0
  56. package/dist/index.js +1 -1
  57. package/dist/web/assets/App-BcbjzSeU.js +226 -0
  58. package/dist/web/assets/{AppDialog-FvWvdWfk.js → AppDialog-C1cvE0gH.js} +1 -1
  59. package/dist/web/assets/{AppTerminalPanel-Dfo_tXAE.js → AppTerminalPanel-BFJNR2ik.js} +2 -2
  60. package/dist/web/assets/{AppsView-CKg2_SXF.js → AppsView-CReOofAf.js} +1 -1
  61. package/dist/web/assets/BrowserSidebar-CPxAck2O.js +1 -0
  62. package/dist/web/assets/{CartesianChart-iXtVfIXm.js → CartesianChart-SlZ8Qfkg.js} +1 -1
  63. package/dist/web/assets/{CollaborationTabs-BFuRwsEy.js → CollaborationTabs-DgFEunqQ.js} +1 -1
  64. package/dist/web/assets/{CommandMenu-Coahy7-K.js → CommandMenu-BiROlSdv.js} +1 -1
  65. package/dist/web/assets/CommunityView-DVST_ZxO.js +1 -0
  66. package/dist/web/assets/ComposerCreateImproveStrip-jRBhdiFB.js +1 -0
  67. package/dist/web/assets/GetStartedView-Ck4EW1_s.js +1 -0
  68. package/dist/web/assets/HostedModelLearningReview-DYFjp-96.js +1 -0
  69. package/dist/web/assets/HostedModelLearningSettings-BD7quEFA.js +1 -0
  70. package/dist/web/assets/LabModelVersionDetailPage-8-Gb5AAH.js +1 -0
  71. package/dist/web/assets/{LabSkillSidebar-C7BuAuNK.js → LabSkillSidebar-DO-kFl9Z.js} +1 -1
  72. package/dist/web/assets/{LabsRoute-CUVbklNy.js → LabsRoute-Dc9RQKdA.js} +6 -6
  73. package/dist/web/assets/MainChatThread-DZXcFgmJ.js +2 -0
  74. package/dist/web/assets/MainPane-BYrnuI30.js +19 -0
  75. package/dist/web/assets/{MarkdownText-DV3sDJG3.js → MarkdownText-ueZFkEyk.js} +21 -21
  76. package/dist/web/assets/{NativeSkillSidebar-B3wc0iGh.js → NativeSkillSidebar-DlAX2-dH.js} +1 -1
  77. package/dist/web/assets/NewExperienceSwitcher-BHYLG0IZ.js +1 -0
  78. package/dist/web/assets/NewProjectDialog-BwN6SnxR.js +1 -0
  79. package/dist/web/assets/OutputsPage-Q0kpdfq_.js +1 -0
  80. package/dist/web/assets/ProjectsPage-TnlBYfFy.js +1 -0
  81. package/dist/web/assets/{ProjectsPage-DdG-U9ZW.css → ProjectsPage-kun3Ron2.css} +1 -1
  82. package/dist/web/assets/RightChatPanelStack-D2qZ-1nK.js +1 -0
  83. package/dist/web/assets/{RightSidebarHomePanel-DweT04nf.js → RightSidebarHomePanel-q6FF-DR9.js} +1 -1
  84. package/dist/web/assets/ScheduledWorkPage-BTX3Sjoa.js +1 -0
  85. package/dist/web/assets/SettingsView-C7av3zwv.css +1 -0
  86. package/dist/web/assets/SettingsView-gAhNO4Rg.js +9 -0
  87. package/dist/web/assets/{TeamChatView-BoQYnywK.js → TeamChatView-DZtfZ12z.js} +2 -2
  88. package/dist/web/assets/{TerminalOverlay-oLOOTbdP.js → TerminalOverlay-MJqx0xg6.js} +1 -1
  89. package/dist/web/assets/{TrainingCreationPanel-aCFYDuYZ.js → TrainingCreationPanel-ORoKcc3m.js} +1 -1
  90. package/dist/web/assets/{TrainingDraftPanel-CFa1YRTU.js → TrainingDraftPanel-oolNVDIx.js} +1 -1
  91. package/dist/web/assets/{UsageSettingsSection-CakaMl6_.js → UsageSettingsSection-Lh_fLOcC.js} +1 -1
  92. package/dist/web/assets/WorkSidebarPanel-BIqP9SXr.js +1 -0
  93. package/dist/web/assets/WorkspaceDiffPanel-B0Zwyx9a.js +14 -0
  94. package/dist/web/assets/WorkspaceEnvironmentMenu-BpgvG43X.js +32 -0
  95. package/dist/web/assets/{WorkspaceGitDialogs-CE6uwWBo.js → WorkspaceGitDialogs-Bw5ADFuc.js} +1 -1
  96. package/dist/web/assets/{WorkspaceMonacoEditor-Dd1yWxIF.js → WorkspaceMonacoEditor-BpivuGzo.js} +3 -3
  97. package/dist/web/assets/{arrow-up-right-DrBHDOjJ.js → arrow-up-right-BjC4ygxR.js} +1 -1
  98. package/dist/web/assets/{clipboard-BwxTBPCP.js → clipboard-BOJ-sNJz.js} +1 -1
  99. package/dist/web/assets/{cloud-upload-Ce9uYXcQ.js → cloud-upload-D-_3UWhI.js} +1 -1
  100. package/dist/web/assets/{cssMode-DDD1HmKz.js → cssMode-CnHRib-_.js} +1 -1
  101. package/dist/web/assets/{folder-open-BmWqQp0P.js → folder-open-CO3Vz0rT.js} +1 -1
  102. package/dist/web/assets/{folder-plus-B402AJf4.js → folder-plus-CL6B10XJ.js} +1 -1
  103. package/dist/web/assets/{git-commit-horizontal-C1uAivqm.js → git-commit-horizontal-C_SNHoOD.js} +1 -1
  104. package/dist/web/assets/git-dialogs-C-F47S10.css +1 -0
  105. package/dist/web/assets/{htmlMode-1MNILRvh.js → htmlMode-DBpIV7Gx.js} +1 -1
  106. package/dist/web/assets/{index-CPTsOhRN.js → index-Dx0lr1R3.js} +2 -2
  107. package/dist/web/assets/index-lqk3IxE0.css +1 -0
  108. package/dist/web/assets/{info-BNROwjpD.js → info-C1C3X2vW.js} +1 -1
  109. package/dist/web/assets/{jsonMode-mGxJ8u70.js → jsonMode-B9puI-La.js} +1 -1
  110. package/dist/web/assets/{lspLanguageFeatures-DnwAgCyz.js → lspLanguageFeatures-DwPRvLkn.js} +1 -1
  111. package/dist/web/assets/{minimize-2-DFgldo5D.js → minimize-2-Cr76Lc_J.js} +1 -1
  112. package/dist/web/assets/{monaco.contribution-BlgPPKyd.js → monaco.contribution-CnlZLXhW.js} +2 -2
  113. package/dist/web/assets/{monaco.contribution-CBuz55_x.js → monaco.contribution-DKa3PSXH.js} +2 -2
  114. package/dist/web/assets/{monaco.contribution-qZ9QzQ68.js → monaco.contribution-DQxsY08y.js} +2 -2
  115. package/dist/web/assets/{monaco.contribution-CGYtN1vj.js → monaco.contribution-OemObo_b.js} +2 -2
  116. package/dist/web/assets/monitor-CktBkAZk.js +1 -0
  117. package/dist/web/assets/{python-CpsWHcA8.js → python-CVC74_7Q.js} +1 -1
  118. package/dist/web/assets/refresh-cw-JaxiGpHD.js +1 -0
  119. package/dist/web/assets/{save-8XYI0E0Y.js → save-DFm1K29k.js} +1 -1
  120. package/dist/web/assets/{square-FQ0GLxuE.js → square-D5fFhDFt.js} +1 -1
  121. package/dist/web/assets/{toggleHighContrast-CX2hgvvU.js → toggleHighContrast-D_EkCruq.js} +1 -1
  122. package/dist/web/assets/{tsMode-D9XBNmxG.js → tsMode-BczIS4rA.js} +1 -1
  123. package/dist/web/assets/{upload-BNXILcvp.js → upload-DvED7nbd.js} +1 -1
  124. package/dist/web/assets/{useLocalAgentSchedules-Ccst1Wnz.js → useLocalAgentSchedules-DWd5OvYb.js} +1 -1
  125. package/dist/web/assets/useSessionTurnCache-oMoxBcGj.js +1 -0
  126. package/dist/web/assets/{wifi-off-BoQdtnnN.js → wifi-off-BZL-Op_B.js} +1 -1
  127. package/dist/web/assets/{workers-DpMJzLwE.js → workers-DapCJCaQ.js} +1 -1
  128. package/dist/web/assets/{yaml-BqS3gPsN.js → yaml-DB9KLqu1.js} +1 -1
  129. package/dist/web/index.html +2 -2
  130. package/docs/command-reference.md +1 -0
  131. package/package.json +1 -1
  132. package/dist/chunks/app-server-runtime-SNSNFJW7.js +0 -2
  133. package/dist/chunks/chunk-3YSCXFE6.js +0 -5
  134. package/dist/chunks/chunk-DDRIX3EP.js +0 -40
  135. package/dist/chunks/chunk-P57W2CB2.js +0 -6
  136. package/dist/chunks/cli-DCFZ4GT6.js +0 -2
  137. package/dist/chunks/extension-IQW2KDT6.js +0 -6
  138. package/dist/chunks/opchat-BSTDLB7O.js +0 -3
  139. package/dist/chunks/src-G3GYZMCL.js +0 -323
  140. package/dist/web/assets/App-eRfSvxdE.js +0 -226
  141. package/dist/web/assets/BrowserSidebar-CBRz9dVj.js +0 -1
  142. package/dist/web/assets/CommunityView-C0B6EVIp.js +0 -1
  143. package/dist/web/assets/ComposerCreateImproveStrip-C0MkRhov.js +0 -1
  144. package/dist/web/assets/GetStartedView-f90pfPRp.js +0 -1
  145. package/dist/web/assets/HostedModelLearningReview-DdZnSPKb.js +0 -1
  146. package/dist/web/assets/HostedModelLearningSettings-p9RdBxGd.js +0 -1
  147. package/dist/web/assets/LabModelVersionDetailPage-DLqT1fMT.js +0 -1
  148. package/dist/web/assets/MainChatThread-Crjs_iFv.js +0 -2
  149. package/dist/web/assets/MainPane-Bl91XbhC.js +0 -10
  150. package/dist/web/assets/Messages-Bxo_ATcK.js +0 -10
  151. package/dist/web/assets/NewExperienceSwitcher-DBdsaysM.js +0 -1
  152. package/dist/web/assets/NewProjectDialog-CtJJ6u5l.js +0 -1
  153. package/dist/web/assets/OutputsPage-CV9rYjbQ.js +0 -1
  154. package/dist/web/assets/ProjectsPage-O162K_Yb.js +0 -1
  155. package/dist/web/assets/RightChatPanelStack-CXzHpD5V.js +0 -1
  156. package/dist/web/assets/ScheduledWorkPage-DFvjzhvz.js +0 -1
  157. package/dist/web/assets/SettingsView-B-O30p4h.js +0 -9
  158. package/dist/web/assets/SettingsView-BaWWvIJW.css +0 -1
  159. package/dist/web/assets/WorkSidebarPanel-XFwuIBFa.js +0 -1
  160. package/dist/web/assets/WorkspaceDiffPanel-CL-lAcvW.js +0 -14
  161. package/dist/web/assets/WorkspaceEnvironmentMenu-DcFKeae1.js +0 -32
  162. package/dist/web/assets/chat-file-links-DKYaOINv.js +0 -1
  163. package/dist/web/assets/chevron-up-CT-jxFh0.js +0 -1
  164. package/dist/web/assets/desktop-files-BQj1J-ob.js +0 -1
  165. package/dist/web/assets/git-dialogs-BZDqS1eT.css +0 -1
  166. package/dist/web/assets/index-BZ4iTv8E.css +0 -1
  167. package/dist/web/assets/play-BQFyTfNz.js +0 -1
  168. package/dist/web/assets/refresh-cw-DfFBmfXv.js +0 -1
@@ -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 N="https://openpond.ai",U="https://api.openpond.ai",k="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===N?`${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(`
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
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}
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 j(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 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(`
8
8
 
9
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(`
10
10
 
11
- `)}}}finally{t.releaseLock()}}n(j,"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 j({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 j({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 _=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 _(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)??k)}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.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,N as d,U as e,C as f,_ 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 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};