openpond 0.2.52 → 0.2.54

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 (137) hide show
  1. package/dist/app-server.d.ts +2 -1
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/{app-layer-RRFI27N4.js → app-layer-I7MZYVLL.js} +1 -1
  4. package/dist/chunks/{app-server-runtime-NITNSHYS.js → app-server-runtime-7AXV6JZI.js} +1 -1
  5. package/dist/chunks/{apps-NELJL377.js → apps-TM74FFQB.js} +1 -1
  6. package/dist/chunks/{chunk-XC7AHL57.js → chunk-37DXASQL.js} +115 -115
  7. package/dist/chunks/chunk-4EEH7MEC.js +2 -0
  8. package/dist/chunks/{chunk-7YR6CBNU.js → chunk-4SHKI3BH.js} +1 -1
  9. package/dist/chunks/{chunk-7MXZJQS7.js → chunk-4TZHH5FC.js} +1 -1
  10. package/dist/chunks/{chunk-T5T7NCHJ.js → chunk-5TNDPNS3.js} +1 -1
  11. package/dist/chunks/{chunk-AV3WI7JZ.js → chunk-6JAN4RMN.js} +1 -1
  12. package/dist/chunks/{chunk-OE2VF6KU.js → chunk-6VF3Q6QJ.js} +1 -1
  13. package/dist/chunks/{chunk-PVSUQGWK.js → chunk-7ZG3IT7C.js} +1 -1
  14. package/dist/chunks/{chunk-Q4H3NUVW.js → chunk-AH22RHPS.js} +2 -2
  15. package/dist/chunks/{chunk-DLZP22WV.js → chunk-FPUUZQUP.js} +1 -1
  16. package/dist/chunks/{chunk-ZBZBV5TB.js → chunk-GCOUYYHG.js} +1 -1
  17. package/dist/chunks/{chunk-MASJQWA2.js → chunk-GXSTZBM6.js} +1 -1
  18. package/dist/chunks/{chunk-IOQUF34U.js → chunk-H2VT22JK.js} +1 -1
  19. package/dist/chunks/{chunk-L3V4QKRV.js → chunk-NHFGEVVH.js} +1 -1
  20. package/dist/chunks/{chunk-HJEY5LBD.js → chunk-PQHTZ5CP.js} +1 -1
  21. package/dist/chunks/{chunk-CFLMKFOE.js → chunk-UE3DMPGM.js} +2 -2
  22. package/dist/chunks/{chunk-QJRXTIOC.js → chunk-USKE34VR.js} +1 -1
  23. package/dist/chunks/{chunk-FQZFLNLY.js → chunk-YD55Z5H3.js} +1 -1
  24. package/dist/chunks/{chunk-RLZPX4YP.js → chunk-YJ4PNAST.js} +1 -1
  25. package/dist/chunks/{cli-ZYFSCHZK.js → cli-JVB345H2.js} +1 -1
  26. package/dist/chunks/{configuration-command-SA56RV5B.js → configuration-command-MATM4XR5.js} +1 -1
  27. package/dist/chunks/{connected-evidence-IVSQZYIB.js → connected-evidence-YDPGNHLP.js} +1 -1
  28. package/dist/chunks/{core-commands-W5IGIITV.js → core-commands-MTV4EKXY.js} +1 -1
  29. package/dist/chunks/{datasets-KSO2UG6R.js → datasets-CP3IT47T.js} +1 -1
  30. package/dist/chunks/{desktop-test-6HXFM7PO.js → desktop-test-IAZC5MAH.js} +1 -1
  31. package/dist/chunks/{dist-5VFPYEIV.js → dist-SAABJU5F.js} +1 -1
  32. package/dist/chunks/{evaluation-coordination-MOFBXRXN.js → evaluation-coordination-EPHLZXYM.js} +1 -1
  33. package/dist/chunks/{experiment-improvements-TDHM6NEA.js → experiment-improvements-6JTOPA74.js} +1 -1
  34. package/dist/chunks/{experiments-HFPDFD4I.js → experiments-XHPFGECH.js} +1 -1
  35. package/dist/chunks/{extension-R373LYIB.js → extension-GX7DLW2X.js} +1 -1
  36. package/dist/chunks/{help-PEFQDDTA.js → help-WLKSACLZ.js} +1 -1
  37. package/dist/chunks/{hosted-experiment-improvement-MGBPXXW2.js → hosted-experiment-improvement-HAB3UE6A.js} +1 -1
  38. package/dist/chunks/{hosted-harness-runtime-WOLADXXP.js → hosted-harness-runtime-YM23QNDK.js} +1 -1
  39. package/dist/chunks/{hosted-profile-candidate-LVNKOTKJ.js → hosted-profile-candidate-EOBGKQAS.js} +1 -1
  40. package/dist/chunks/{hosted-profile-compiler-NBMUCZVS.js → hosted-profile-compiler-SCVJI2CP.js} +1 -1
  41. package/dist/chunks/{hosted-profile-evaluation-control-7B3RAZU2.js → hosted-profile-evaluation-control-RJ6XJZCS.js} +1 -1
  42. package/dist/chunks/{hosted-profile-evaluation-inspection-FPCV42DD.js → hosted-profile-evaluation-inspection-OC4XNGL2.js} +1 -1
  43. package/dist/chunks/{hosted-profile-evaluation-preparation-I6H6RFT6.js → hosted-profile-evaluation-preparation-ZD4FM3FD.js} +1 -1
  44. package/dist/chunks/{human-review-HRGGACEM.js → human-review-AAVMISBF.js} +1 -1
  45. package/dist/chunks/{import-RSAQ44GG.js → import-V3HUGRHR.js} +1 -1
  46. package/dist/chunks/{opchat-I7ZWJ5XK.js → opchat-QK43DXTY.js} +1 -1
  47. package/dist/chunks/{organizations-LFCZIH7E.js → organizations-SRPAWKC7.js} +1 -1
  48. package/dist/chunks/{profile-EPIX5QVK.js → profile-C6CQNVYE.js} +1 -1
  49. package/dist/chunks/{project-agent-DGOPMECP.js → project-agent-GZV5HNYI.js} +1 -1
  50. package/dist/chunks/{sandbox-command-Q5F6VUOS.js → sandbox-command-4TJXQTKT.js} +1 -1
  51. package/dist/chunks/{sandbox-template-7GICPIKJ.js → sandbox-template-BBGGPJMI.js} +1 -1
  52. package/dist/chunks/{src-DH5AQ4Z7.js → src-CR6UZYTX.js} +1 -1
  53. package/dist/chunks/{src-MGP3OYHL.js → src-NE6R4XC6.js} +109 -109
  54. package/dist/chunks/{teams-bot-Z6RJGHME.js → teams-bot-7I4BAUVO.js} +1 -1
  55. package/dist/cli.js +1 -1
  56. package/dist/web/assets/App-CO2F717V.css +1 -0
  57. package/dist/web/assets/{App-Dg6mZIQk.js → App-CuhaCsfb.js} +65 -64
  58. package/dist/web/assets/{AppDialog-gcj3rrTZ.js → AppDialog-BdusXgU0.js} +1 -1
  59. package/dist/web/assets/{AppTerminalPanel-Be-E4qZF.js → AppTerminalPanel-C4uRpnBz.js} +2 -2
  60. package/dist/web/assets/{AppsView-BdyPNSpT.js → AppsView-BS1czXUP.js} +1 -1
  61. package/dist/web/assets/{BrowserSidebar-CcQxU0uO.js → BrowserSidebar-Bl7V6YO2.js} +1 -1
  62. package/dist/web/assets/{CartesianChart-CN5hB6rV.js → CartesianChart-BstFbsdn.js} +1 -1
  63. package/dist/web/assets/{CollaborationTabs-BiDPHgXG.js → CollaborationTabs-B8YAf0c1.js} +1 -1
  64. package/dist/web/assets/{CommandMenu-B2qJCgWH.js → CommandMenu-DZct7zUJ.js} +1 -1
  65. package/dist/web/assets/{CommunityView-D1aOQKfS.js → CommunityView-CR0-W-uG.js} +1 -1
  66. package/dist/web/assets/{ComposerCreateImproveStrip-f1tdD0QS.js → ComposerCreateImproveStrip-DR-Qo7b4.js} +1 -1
  67. package/dist/web/assets/{GetStartedView-CPYs0fYN.js → GetStartedView-xqQoMMei.js} +1 -1
  68. package/dist/web/assets/HostedModelLearningReview-CHxxf_Lu.js +1 -0
  69. package/dist/web/assets/{HostedModelLearningSettings-IEKRXOkG.js → HostedModelLearningSettings-De3i9wF4.js} +1 -1
  70. package/dist/web/assets/{LabModelVersionDetailPage-DkIa0oG_.js → LabModelVersionDetailPage-DAY1MmqP.js} +1 -1
  71. package/dist/web/assets/{LabSkillSidebar-BUlU1Ti-.js → LabSkillSidebar-DLnIgnry.js} +1 -1
  72. package/dist/web/assets/{LabsRoute-8cKFNq19.js → LabsRoute-CXJRJMhr.js} +4 -4
  73. package/dist/web/assets/{MainChatThread-C5GwaIl_.js → MainChatThread-BwAla81W.js} +2 -2
  74. package/dist/web/assets/{MainPane-SMqq5YAM.js → MainPane-CakOBCHw.js} +4 -4
  75. package/dist/web/assets/{MarkdownText-CLnvdLVg.js → MarkdownText-gJMuefaJ.js} +1 -1
  76. package/dist/web/assets/{NativeSkillSidebar-B9bVb00x.js → NativeSkillSidebar-Dlxb8iOC.js} +1 -1
  77. package/dist/web/assets/{NewExperienceSwitcher-CelgG7Ua.js → NewExperienceSwitcher-DM-cqJ-K.js} +1 -1
  78. package/dist/web/assets/{NewProjectDialog-eEnsg9s2.js → NewProjectDialog-Cu1q75gq.js} +1 -1
  79. package/dist/web/assets/{OutputsPage-ByvsTUW-.js → OutputsPage-DiXMkasl.js} +1 -1
  80. package/dist/web/assets/{ProjectsPage-Cl2zFh8X.js → ProjectsPage-DqiBHiCB.js} +1 -1
  81. package/dist/web/assets/{RightChatPanelStack-MnGscF87.js → RightChatPanelStack-VaOOmxwd.js} +1 -1
  82. package/dist/web/assets/{RightSidebarHomePanel-C6NXMYuy.js → RightSidebarHomePanel-CeSFJM5s.js} +1 -1
  83. package/dist/web/assets/{ScheduledWorkPage-DCb6d7Lg.js → ScheduledWorkPage-D1jRQxFs.js} +1 -1
  84. package/dist/web/assets/{SettingsView-BMFfrxmo.js → SettingsView-RA9OXgcu.js} +3 -3
  85. package/dist/web/assets/{TeamChatView-DW_v2B9E.js → TeamChatView-DM0adMtj.js} +1 -1
  86. package/dist/web/assets/{TerminalOverlay-BJ7qsr9F.js → TerminalOverlay-CFlH51DD.js} +1 -1
  87. package/dist/web/assets/{TrainingCreationPanel-GSIwP6f1.js → TrainingCreationPanel-CgIBVGha.js} +1 -1
  88. package/dist/web/assets/{TrainingDraftPanel-DorY6I29.js → TrainingDraftPanel-Bbo3RRie.js} +1 -1
  89. package/dist/web/assets/{UsageSettingsSection-DmzStI9q.js → UsageSettingsSection-CSRjJUSa.js} +1 -1
  90. package/dist/web/assets/{WorkSidebarPanel-zsJrGaaL.js → WorkSidebarPanel-DwlEMEoG.js} +1 -1
  91. package/dist/web/assets/WorkspaceDiffPanel-pGVezNMw.js +14 -0
  92. package/dist/web/assets/{WorkspaceEnvironmentMenu-vJw9hE0y.js → WorkspaceEnvironmentMenu-Byjngd9V.js} +1 -1
  93. package/dist/web/assets/{WorkspaceGitDialogs-BpL-xtRX.js → WorkspaceGitDialogs-Dgmg-6XG.js} +1 -1
  94. package/dist/web/assets/{WorkspaceMonacoEditor-CJ3x0GHH.js → WorkspaceMonacoEditor-BR4qxMgU.js} +3 -3
  95. package/dist/web/assets/{arrow-up-right-C60QSULo.js → arrow-up-right-H0pvnH2s.js} +1 -1
  96. package/dist/web/assets/{chunk-UHVJOMWN-BxgPi0yP.js → chunk-UHVJOMWN-BqXRe639.js} +1 -1
  97. package/dist/web/assets/{clipboard-QIy0Jd_K.js → clipboard-BZzZ82Bk.js} +1 -1
  98. package/dist/web/assets/{cloud-upload-B9L-_gy0.js → cloud-upload-CJPYPVl8.js} +1 -1
  99. package/dist/web/assets/{cssMode-ffPyPUW9.js → cssMode-WC4Rg1l-.js} +1 -1
  100. package/dist/web/assets/{folder-open-BFy7KXWm.js → folder-open-sLZJxLQy.js} +1 -1
  101. package/dist/web/assets/{folder-plus-C3iGtUOI.js → folder-plus-C84wrpt_.js} +1 -1
  102. package/dist/web/assets/{git-commit-horizontal-DsTniKvi.js → git-commit-horizontal-Cotm7KEC.js} +1 -1
  103. package/dist/web/assets/{htmlMode-7ytlsiyK.js → htmlMode-C6oZGeaB.js} +1 -1
  104. package/dist/web/assets/{index-BK8GmZmB.js → index-BxWTVKtn.js} +2 -2
  105. package/dist/web/assets/index-dSmk3FLJ.css +1 -0
  106. package/dist/web/assets/{info-C8mwoaIJ.js → info-Dc81lEfw.js} +1 -1
  107. package/dist/web/assets/{jsonMode-BT35NJi4.js → jsonMode-BET4LQIn.js} +1 -1
  108. package/dist/web/assets/{lspLanguageFeatures-BKAwIewO.js → lspLanguageFeatures-BPxA_-Kg.js} +1 -1
  109. package/dist/web/assets/{minimize-2-34MApatV.js → minimize-2-Bs7MVN3C.js} +1 -1
  110. package/dist/web/assets/{monaco.contribution-CxtX0z-m.js → monaco.contribution-7AUuf2NS.js} +2 -2
  111. package/dist/web/assets/{monaco.contribution-9diduNNi.js → monaco.contribution-BH6kkO4b.js} +2 -2
  112. package/dist/web/assets/{monaco.contribution-DVnPUDsR.js → monaco.contribution-DFzEyaHi.js} +2 -2
  113. package/dist/web/assets/{monaco.contribution-Dj4R5U8Z.js → monaco.contribution-DXzyQfVi.js} +2 -2
  114. package/dist/web/assets/{monitor-4JxqJ7wz.js → monitor-DXL019Wf.js} +1 -1
  115. package/dist/web/assets/{play-C4PtpamL.js → play-CXkxUZeU.js} +1 -1
  116. package/dist/web/assets/{python-0GVncePC.js → python-PzBkTjWx.js} +1 -1
  117. package/dist/web/assets/{save-DjB16eou.js → save-DpezrtH2.js} +1 -1
  118. package/dist/web/assets/{square-Coz7UQqd.js → square-oy7f5Ce6.js} +1 -1
  119. package/dist/web/assets/{toggleHighContrast-D-3108_3.js → toggleHighContrast-Cto-fOXm.js} +1 -1
  120. package/dist/web/assets/{tsMode-CV4ktqqR.js → tsMode-BYA4LNc6.js} +1 -1
  121. package/dist/web/assets/{upload-D007T9Hm.js → upload-C5YFNgtS.js} +1 -1
  122. package/dist/web/assets/{useLocalAgentSchedules-BXjFbAVS.js → useLocalAgentSchedules-CnyTsqlf.js} +1 -1
  123. package/dist/web/assets/useProviderSettings-B_KeQjE5.js +5 -0
  124. package/dist/web/assets/{useSessionTurnCache-Bee6zbC_.js → useSessionTurnCache-DICuJSJW.js} +1 -1
  125. package/dist/web/assets/{wifi-off-BbNZc0za.js → wifi-off-nzHj7JXp.js} +1 -1
  126. package/dist/web/assets/{workers-DNQ5ne3z.js → workers-Dboaw6f_.js} +1 -1
  127. package/dist/web/assets/{yaml-BfAho-gB.js → yaml-uuY5JmO8.js} +1 -1
  128. package/dist/web/index.html +2 -2
  129. package/package.json +1 -1
  130. package/dist/chunks/chunk-EPY7M5XS.js +0 -2
  131. package/dist/web/assets/App-DkH8CeoI.css +0 -1
  132. package/dist/web/assets/HostedModelLearningReview-DVfJyUW_.js +0 -1
  133. package/dist/web/assets/WorkspaceDiffPanel-CiFsZjMm.js +0 -14
  134. package/dist/web/assets/index-C0H85uUI.css +0 -1
  135. package/dist/web/assets/useProviderSettings-SY7mp-5B.js +0 -5
  136. /package/dist/chunks/{chunk-XDMUD4FW.js → chunk-2JO2KWT3.js} +0 -0
  137. /package/dist/chunks/{chunk-XBCIBAXD.js → chunk-GS2NKNKG.js} +0 -0
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as N,b as E,c as P,d as J,e as j,f as S,g as O,h as C,i as R,j as k,k as B,l as q,m as U,n as L,o as l}from"./chunk-WITSXYEW.js";import{m as v,s as w,t as y}from"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-RLZPX4YP.js";import"./chunk-Q4H3NUVW.js";import{b as I,f,g as h,h as p}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as b}from"./chunk-FTQLQJQV.js";async function M(r,o,e,i){if(o==="list-files"){let t=i[1];if(!t)throw new Error("usage: sandbox list-files <sandboxId> [--path <path>]");let n=typeof e.path=="string"?e.path.trim():void 0,s=h(e.maxEntries,"max-entries"),a=e.recursive!==void 0?f(e.recursive):void 0,d=await r.listFiles(t,{...n?{path:n}:{},...a!==void 0?{recursive:a}:{},...s!==void 0?{maxEntries:s}:{}});return console.log(JSON.stringify({sandbox:l(d.sandbox),files:d.files},null,2)),!0}if(o==="upload-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",s=typeof e.contents=="string"?e.contents:typeof e.content=="string"?e.content:"",a=typeof e.contentsBase64=="string"?e.contentsBase64.trim():typeof e.contentBase64=="string"?e.contentBase64.trim():"";if(!t||!n)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');if(!s&&!a)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');let d=a?await r.uploadFileBase64(t,n,a):await r.uploadFile(t,n,s);return console.log(JSON.stringify({sandbox:l(d.sandbox),file:d.file},null,2)),!0}if(o==="download-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",s=Number(e["offset-bytes"]),a=Number(e["max-bytes"]);if(!t||!n)throw new Error("usage: sandbox download-file <sandboxId> --path <path>");let d=await r.downloadFileResponse(t,{path:n,...Number.isFinite(s)?{offsetBytes:s}:{},...Number.isFinite(a)?{maxBytes:a}:{}});return console.log(JSON.stringify({sandbox:l(d.sandbox),file:d.file,contents:Buffer.from(d.file.contentsBase64,"base64").toString("utf-8")},null,2)),!0}if(o==="search-files"){let t=i[1],n=typeof e.query=="string"?e.query.trim():"";if(!t||!n)throw new Error("usage: sandbox search-files <sandboxId> --query <text> [--path <path>]");let s=typeof e.path=="string"?e.path.trim():void 0,a=h(e.maxResults,"max-results"),d=await r.searchFiles(t,{query:n,...s?{path:s}:{},...a!==void 0?{maxResults:a}:{}});return console.log(JSON.stringify({sandbox:l(d.sandbox),matches:d.matches},null,2)),!0}if(o==="delete-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"";if(!t||!n)throw new Error("usage: sandbox delete-file <sandboxId> --path <path> [--recursive]");let s=await r.deleteFile(t,n,{recursive:f(e.recursive)});return console.log(JSON.stringify({sandbox:l(s.sandbox),deleted:s.deleted},null,2)),!0}if(o==="stat-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"";if(!t||!n)throw new Error("usage: sandbox stat-file <sandboxId> --path <path>");let s=await r.statFile(t,n);return console.log(JSON.stringify({sandbox:l(s.sandbox),file:s.file},null,2)),!0}if(o==="mkdir"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"";if(!t||!n)throw new Error("usage: sandbox mkdir <sandboxId> --path <path> [--recursive false]");let s=await r.mkdir(t,{path:n,recursive:e.recursive!==void 0?f(e.recursive):void 0});return console.log(JSON.stringify({sandbox:l(s.sandbox),directory:s.directory},null,2)),!0}if(o==="move-file"){let t=i[1],n=typeof e.fromPath=="string"?e.fromPath.trim():"",s=typeof e.toPath=="string"?e.toPath.trim():"";if(!t||!n||!s)throw new Error("usage: sandbox move-file <sandboxId> --from-path <path> --to-path <path> [--overwrite]");let a=await r.moveFile(t,{fromPath:n,toPath:s,overwrite:f(e.overwrite)});return console.log(JSON.stringify({sandbox:l(a.sandbox),moved:a.moved,file:a.file},null,2)),!0}return!1}b(M,"handleSandboxFilesCommand");async function T(r,o,e,i){if(o==="git-status"){let t=i[1];if(!t)throw new Error("usage: sandbox git-status <sandboxId>");let n=await r.gitStatus(t);return console.log(JSON.stringify({sandbox:l(n.sandbox),status:n.status},null,2)),!0}if(o==="git-diff"){let t=i[1];if(!t)throw new Error("usage: sandbox git-diff <sandboxId> [--base-ref <ref>]");let n=typeof e.baseRef=="string"&&e.baseRef.trim()?e.baseRef.trim():void 0,s=await r.gitDiff(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:l(s.sandbox),diff:s.diff},null,2)),!0}if(o==="git-export-patch"){let t=i[1];if(!t)throw new Error("usage: sandbox git-export-patch <sandboxId> [--base-ref <ref>]");let n=typeof e.baseRef=="string"&&e.baseRef.trim()?e.baseRef.trim():void 0,s=await r.gitExportPatch(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:l(s.sandbox),patch:s.patch},null,2)),!0}if(o==="git-branch"){let t=i[1],n=typeof e.branch=="string"?e.branch.trim():"",s=typeof e.startPoint=="string"&&e.startPoint.trim()?e.startPoint.trim():void 0;if(!t||!n)throw new Error("usage: sandbox git-branch <sandboxId> --branch <name> [--create] [--start-point <ref>]");let a=await r.gitBranch(t,{branch:n,create:f(e.create),...s?{startPoint:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),branch:a.branch},null,2)),!0}if(o==="git-commit"){let t=i[1],n=typeof e.message=="string"?e.message.trim():"",s=f(e.all),d=(typeof e.paths=="string"?e.paths:typeof e.path=="string"?e.path:"").split(",").map(g=>g.trim()).filter(Boolean);if(!t||!n||!s&&d.length===0)throw new Error('usage: sandbox git-commit <sandboxId> --message "..." [--all|--paths <csv>]');let c=await r.gitCommit(t,{message:n,...s?{all:!0}:{paths:d}});return console.log(JSON.stringify({sandbox:l(c.sandbox),commit:c.commit},null,2)),!0}if(o==="git-pull"){let t=i[1];if(!t)throw new Error("usage: sandbox git-pull <sandboxId> [--remote origin] [--branch main] [--rebase|--ff-only false]");let n=typeof e.remote=="string"&&e.remote.trim()?e.remote.trim():void 0,s=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,a=await r.gitPull(t,{...n?{remote:n}:{},...s?{branch:s}:{},...e.rebase!==void 0?{rebase:f(e.rebase)}:{},...e.ffOnly!==void 0?{ffOnly:f(e.ffOnly)}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),pull:a.pull},null,2)),!0}if(o==="git-push"){let t=i[1];if(!t)throw new Error("usage: sandbox git-push <sandboxId> [--remote origin] [--branch main] [--set-upstream] [--force-with-lease]");let n=typeof e.remote=="string"&&e.remote.trim()?e.remote.trim():void 0,s=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,a=await r.gitPush(t,{...n?{remote:n}:{},...s?{branch:s}:{},...e.setUpstream!==void 0?{setUpstream:f(e.setUpstream)}:{},...e.forceWithLease!==void 0?{forceWithLease:f(e.forceWithLease)}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),push:a.push},null,2)),!0}return!1}b(T,"handleSandboxGitCommand");async function F(r,o,e,i){if(o==="process-start"){let t=i[1],n=(typeof e.command=="string"?e.command:null)||i.slice(2).join(" ");if(!t||!n.trim())throw new Error("usage: sandbox process-start <sandboxId> --command <command>");let s=p(e.timeoutSeconds,"timeout-seconds"),a=await r.startProcess(t,{command:n.trim(),...s!==void 0?{timeoutSeconds:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),process:a.process},null,2)),!0}if(o==="process-list"){let t=i[1];if(!t)throw new Error("usage: sandbox process-list <sandboxId>");let n=await r.listProcesses(t);return console.log(JSON.stringify({sandbox:l(n.sandbox),processes:n.processes},null,2)),!0}if(o==="process-get"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox process-get <sandboxId> <processId> [--since <cursor>]");let s=p(e.since,"since"),a=await r.getProcess(t,n,{...s!==void 0?{since:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),process:a.process,output:a.output,cursor:a.cursor,completed:a.completed},null,2)),!0}if(o==="process-stop"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox process-stop <sandboxId> <processId>");let s=await r.stopProcess(t,n);return console.log(JSON.stringify({sandbox:l(s.sandbox),process:s.process},null,2)),!0}if(o==="process-stream"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox process-stream <sandboxId> <processId> [--since <cursor>]");let s=p(e.since,"since");return await r.streamProcessOutput(t,n,{...s!==void 0?{since:s}:{}}),!0}if(o==="pty-start"){let t=i[1];if(!t)throw new Error("usage: sandbox pty-start <sandboxId> [--command <command>]");let n=(typeof e.command=="string"?e.command:null)||i.slice(2).join(" "),s=p(e.timeoutSeconds,"timeout-seconds"),a=p(e.rows,"rows"),d=p(e.cols,"cols"),c=await r.startPty(t,{...n.trim()?{command:n.trim()}:{},...s!==void 0?{timeoutSeconds:s}:{},...a!==void 0?{rows:a}:{},...d!==void 0?{cols:d}:{}});return console.log(JSON.stringify({sandbox:l(c.sandbox),pty:c.pty},null,2)),!0}if(o==="pty-list"){let t=i[1];if(!t)throw new Error("usage: sandbox pty-list <sandboxId>");let n=await r.listPtys(t);return console.log(JSON.stringify({sandbox:l(n.sandbox),ptys:n.ptys},null,2)),!0}if(o==="pty-get"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox pty-get <sandboxId> <ptyId> [--since <cursor>]");let s=p(e.since,"since"),a=await r.getPty(t,n,{...s!==void 0?{since:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),pty:a.pty,output:a.output,cursor:a.cursor,completed:a.completed},null,2)),!0}if(o==="pty-write"){let t=i[1],n=i[2],s=typeof e.inputBase64=="string"?e.inputBase64.trim():"",a=(typeof e.input=="string"?e.input:null)||i.slice(3).join(" ");if(!t||!n||!s&&!a)throw new Error("usage: sandbox pty-write <sandboxId> <ptyId> --input <text>");let d=await r.writePtyInput(t,n,s?{dataBase64:s}:a);return console.log(JSON.stringify({sandbox:l(d.sandbox),pty:d.pty},null,2)),!0}if(o==="pty-stop"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox pty-stop <sandboxId> <ptyId>");let s=await r.stopPty(t,n);return console.log(JSON.stringify({sandbox:l(s.sandbox),pty:s.pty},null,2)),!0}if(o==="pty-stream"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox pty-stream <sandboxId> <ptyId> [--since <cursor>]");let s=p(e.since,"since");return await r.streamPtyOutput(t,n,{...s!==void 0?{since:s}:{}}),!0}return!1}b(F,"handleSandboxProcessCommand");async function A(r,o,e,i){if(o==="replays"||o==="replay-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.listReplays({...t?{teamId:t}:{},...n?{projectId:n}:{}});if(f(e.json))return console.log(JSON.stringify(s,null,2)),!0;if(s.replays.length===0)return console.log("no sandbox replays found"),!0;for(let a of s.replays)console.log(O(a));return!0}if(o==="replay-start"||o==="start-replay"){let t=await r.startReplay(k(e));return console.log(JSON.stringify(t,null,2)),!0}if(o==="replay-get"||o==="get-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-get <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.getReplay(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});return console.log(JSON.stringify(a,null,2)),!0}if(o==="replay-logs"||o==="logs-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-logs <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.getReplayLogs(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});for(let d of a.logs)console.log(d);return!0}if(o==="replay-artifacts"||o==="artifacts-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-artifacts <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.getReplayArtifacts(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});return console.log(JSON.stringify({replayId:a.replayId,artifacts:a.artifacts.map(C)},null,2)),!0}if(o==="replay-cancel"||o==="cancel-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-cancel <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.cancelReplay(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});return console.log(JSON.stringify(a,null,2)),!0}if(o==="replay-watch"||o==="watch-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-watch <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=p(e.intervalMs,"interval-ms")??5e3,d=p(e.timeoutMs,"timeout-ms")??900*1e3,c=Date.now(),g=new Set;for(;Date.now()-c<=d;){let u=await r.getReplay(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});for(let m of u.replay.logs)g.has(m)||(g.add(m),console.log(m));if(u.replay.state==="succeeded"||u.replay.state==="failed"||u.replay.state==="canceled"){if(console.log(O(u.replay)),u.replay.state!=="succeeded")throw new Error(`sandbox replay ${u.replay.state}: ${u.replay.error??"no error"}`);return!0}await new Promise(m=>setTimeout(m,a))}throw new Error(`sandbox replay did not finish within ${d}ms`)}return!1}b(A,"handleSandboxReplayCommand");async function V(r,o,e,i){if(o==="runtime-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.projectId=="string"?e.projectId.trim():"",s=typeof e.agentId=="string"?e.agentId.trim():"",a=await r.listSandboxRuntimes({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{}});return console.log(JSON.stringify({runtimes:a},null,2)),!0}if(o==="runtime-get"){let t=i[1]?.trim();if(!t)throw new Error("usage: sandbox runtime-get <runtimeId>");let n=await r.getSandboxRuntime(t);return console.log(JSON.stringify({runtime:n},null,2)),!0}if(o==="runtime-events"){let t=i[1]?.trim();if(!t)throw new Error("usage: sandbox runtime-events <runtimeId>");return console.log(JSON.stringify(await r.listSandboxRuntimeEvents(t),null,2)),!0}if(o==="runtime-status"){let t=i[1]?.trim(),n=typeof e.status=="string"&&e.status.trim()?e.status.trim():"",s=Number(e.expectedVersion),a=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0;if(!t||!n||!Number.isInteger(s))throw new Error("usage: sandbox runtime-status <runtimeId> --status <status> --expected-version <n>");let d=await r.updateSandboxRuntimeStatus(t,{status:n,expectedVersion:s,...a?{summary:a}:{}});return console.log(JSON.stringify({runtime:d},null,2)),!0}if(o==="runtime-event"){let t=i[1]?.trim(),n=typeof e.type=="string"&&e.type.trim()?e.type.trim():"",s=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0,a=typeof e.payload=="string"&&e.payload.trim()?I(e.payload,"payload"):void 0,d=typeof e.lifecycleHint=="string"&&e.lifecycleHint.trim()?I(e.lifecycleHint,"lifecycle-hint"):void 0;if(!t||!n)throw new Error("usage: sandbox runtime-event <runtimeId> --type <eventType> [--summary <text>] [--payload <json>] [--lifecycle-hint <json>]");return console.log(JSON.stringify(await r.emitSandboxRuntimeEvent(t,{type:n,...s?{summary:s}:{},...a?{payload:a}:{},...d?{lifecycleHint:d}:{}}),null,2)),!0}if(o==="runtime-preserve-source"||o==="runtime-preserve"){let t=i[1]?.trim(),n=typeof e.teamId=="string"&&e.teamId.trim()?e.teamId.trim():"",s=typeof e.sandboxId=="string"&&e.sandboxId.trim()?e.sandboxId.trim():"",a=typeof e.message=="string"&&e.message.trim()?e.message.trim():"";if(!t)throw new Error("usage: sandbox runtime-preserve-source <runtimeId> [--team-id <id>] [--sandbox-id <id>] [--message <text>]");return console.log(JSON.stringify(await r.runtimes.preserveSource(t,{...s?{sandboxId:s}:{},...a?{message:a}:{}},{...n?{teamId:n}:{}}),null,2)),!0}return!1}b(V,"handleSandboxRuntimeCommand");async function $(r,o,e,i){if(o==="secrets"||o==="secret-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=await r.listSecrets({...t?{teamId:t}:{}});if(f(e.json))return console.log(JSON.stringify({secrets:n.map(y)},null,2)),!0;if(n.length===0)return console.log("no sandbox secrets found"),!0;for(let s of n)console.log(`${s.name} ${s.status} v${s.currentVersion??"current"} ${s.secretRef}`);return!0}if(o==="secret-create"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.name=="string"?e.name.trim():"",s=typeof e.description=="string"&&e.description.trim()?e.description.trim():void 0,a=e.scope==="project"||e.scope==="template"||e.scope==="team"?e.scope:void 0;if(!n)throw new Error("usage: sandbox secret-create --name <ENV_NAME> [--team-id <id>] [--stdin]");let d=await w(e,`Value for ${n}`),c=await r.createSecret({...t?{teamId:t}:{},name:n,value:d,...s?{description:s}:{},...a?{scope:a}:{}});return console.log(JSON.stringify({secret:y(c)},null,2)),!0}if(o==="secret-rotate"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"";if(!t)throw new Error("usage: sandbox secret-rotate <secretId> [--team-id <id>] [--stdin]");let s=await w(e,"New secret value"),a=await r.rotateSecret(t,{...n?{teamId:n}:{},value:s});return console.log(JSON.stringify({secret:y(a)},null,2)),!0}if(o==="secret-attach"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.envName=="string"?e.envName.trim():"",a=e.targetType==="sandbox"||e.targetType==="template"||e.targetType==="project"||e.targetType==="agent"||e.targetType==="replay"?e.targetType:void 0,d=typeof e.targetId=="string"?e.targetId.trim():"";if(!t||!s||!a||!d)throw new Error("usage: sandbox secret-attach <secretId> --env-name <ENV_NAME> --target-type sandbox|project|agent|template|replay --target-id <id>");let c=await r.attachSecret(t,{...n?{teamId:n}:{},envName:s,targetType:a,targetId:d});return console.log(JSON.stringify({secret:y(c)},null,2)),!0}if(o==="secret-revoke"||o==="secret-delete"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"";if(!t)throw new Error(`usage: sandbox ${o} <secretId> [--team-id <id>]`);let s=o==="secret-revoke"?await r.revokeSecret(t,{...n?{teamId:n}:{}}):await r.deleteSecret(t,{...n?{teamId:n}:{}});return console.log(JSON.stringify({secret:y(s)},null,2)),!0}return!1}b($,"handleSandboxSecretsCommand");async function H(r,o,e,i){if(o==="published-snapshot-builds"||o==="published-snapshot-build-list"||o==="template-builds"||o==="template-build-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"";if(!t)throw new Error("usage: sandbox published-snapshot-builds --team-id <id>");let n=await r.listPublishedSnapshotBuilds({teamId:t});if(f(e.json))return console.log(JSON.stringify({builds:n},null,2)),!0;if(n.length===0)return console.log("no published snapshot builds found"),!0;for(let s of n)console.log(S(s));return!0}if(o==="published-snapshot-build-create"||o==="create-published-snapshot-build"||o==="template-build-create"||o==="create-template-build"){let t=await r.createPublishedSnapshotBuild(U(e));return console.log(JSON.stringify({build:t},null,2)),!0}if(o==="published-snapshot-build-get"||o==="get-published-snapshot-build"||o==="template-build-get"||o==="get-template-build"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-get <buildId>");let n=await r.getPublishedSnapshotBuild(t);return console.log(JSON.stringify({build:n},null,2)),!0}if(o==="published-snapshot-build-logs"||o==="published-snapshot-build-log"||o==="template-build-logs"||o==="template-build-log"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-logs <buildId>");let n=await r.getPublishedSnapshotBuildLogs(t);if(f(e.json))return console.log(JSON.stringify(n,null,2)),!0;for(let s of n.logs)console.log(s);return!0}if(o==="published-snapshot-build-cancel"||o==="cancel-published-snapshot-build"||o==="template-build-cancel"||o==="cancel-template-build"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-cancel <buildId>");let n=await r.cancelPublishedSnapshotBuild(t);return console.log(JSON.stringify({build:n},null,2)),!0}if(o==="published-snapshot-build-watch"||o==="watch-published-snapshot-build"||o==="template-build-watch"||o==="watch-template-build"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-watch <buildId>");let n=p(e.intervalMs,"interval-ms")??5e3,s=p(e.timeoutMs,"timeout-ms")??900*1e3,a=Date.now(),d=new Set;for(;Date.now()-a<=s;){let[c,g]=await Promise.all([r.getPublishedSnapshotBuild(t),r.getPublishedSnapshotBuildLogs(t)]);for(let u of g.logs)d.has(u)||(d.add(u),console.log(u));if(c.status==="succeeded"||c.status==="failed"||c.status==="cancelled"){if(console.log(S(c)),c.status!=="succeeded")throw new Error(`published snapshot build ${c.status}: ${c.error??"no error"}`);return!0}await new Promise(u=>setTimeout(u,n))}throw new Error(`published snapshot build did not finish within ${s}ms`)}return!1}b(H,"handleSandboxTemplateBuildsCommand");function G(r){return f(r.async)||f(r.respondAsync)}b(G,"parseSandboxAsyncOption");async function Pe(r,o){let e=o[0]||"list",i=await v(r);if(e==="list"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=await i.list({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{}});if(a.length===0){console.log("no sandboxes found");return}for(let d of a)console.log(P(d));return}if(e==="mcp-config"||e==="mcp-url"){let t=i.mcpServerConfig();console.log(JSON.stringify({...t,headers:{"openpond-api-key":"set OPENPOND_API_KEY or use your saved openpond profile"}},null,2));return}if(!await V(i,e,r,o)){if(e==="pricing"){let t=await i.pricing();console.log(JSON.stringify(t,null,2));return}if(e==="costs"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=await i.costs({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{}});if(f(r.summary)){console.log(JSON.stringify({costs:{teamId:a.costs.teamId,ownerUserId:a.costs.ownerUserId,generatedAt:a.costs.generatedAt,summary:a.costs.summary,lineItems:a.costs.lineItems,tiers:a.costs.pricing.tiers.map(d=>({key:d.key,resources:d.resources,keepRunningEstimate:d.keepRunningEstimate}))}},null,2));return}console.log(JSON.stringify(a,null,2));return}if(!await $(i,e,r,o)){if(e==="snapshots"||e==="snapshot-catalog"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=typeof r.query=="string"&&r.query.trim()?r.query.trim():typeof r.q=="string"&&r.q.trim()?r.q.trim():"",d=typeof r.tag=="string"?r.tag.trim():"",c=typeof r.useCase=="string"?r.useCase.trim():"",g=typeof r.replayState=="string"?r.replayState.trim():"",u=await i.snapshotCatalog({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{},...a?{q:a}:{},...d?{tag:d}:{},...c?{useCase:c}:{},...g==="draft"||g==="validated"||g==="published"?{replayState:g}:{}});if(u.snapshots.length===0){console.log("no sandbox snapshots found");return}for(let m of u.snapshots)console.log(J(m));return}if(e==="published-snapshots"||e==="published-snapshot-catalog"||e==="templates"||e==="template-catalog"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.query=="string"&&r.query.trim()?r.query.trim():typeof r.q=="string"&&r.q.trim()?r.q.trim():"",a=typeof r.name=="string"&&r.name.trim()?r.name.trim():typeof r.templateName=="string"&&r.templateName.trim()?r.templateName.trim():"",d=typeof r.version=="string"?r.version.trim():"",c=typeof r.tag=="string"?r.tag.trim():"",g=typeof r.useCase=="string"?r.useCase.trim():"",u=await i.publishedSnapshots({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{q:s}:{},...a?{name:a}:{},...d?{version:d}:{},...c?{tag:c}:{},...g?{useCase:g}:{}});if(u.publishedSnapshots.length===0){console.log("no published snapshots found");return}for(let m of u.publishedSnapshots)console.log(j(m));return}if(!(await H(i,e,r,o)||await A(i,e,r,o))){if(e==="run-published-snapshot"||e==="published-snapshot-run"||e==="template-launch"||e==="launch-template"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.snapshotId=="string"&&r.snapshotId.trim()?r.snapshotId.trim():typeof r.snapshot=="string"&&r.snapshot.trim()?r.snapshot.trim():"",a=typeof r.templateName=="string"&&r.templateName.trim()?r.templateName.trim():typeof r.name=="string"&&r.name.trim()?r.name.trim():typeof o[1]=="string"&&o[1].trim()?o[1].trim():"",d=typeof r.version=="string"?r.version.trim():"",c=typeof r.useCase=="string"?r.useCase.trim():"";if(!s&&!a&&!c)throw new Error("usage: sandbox run-published-snapshot [--snapshot-id <id>|--name <name>|--use-case <id>] [--version <v>]");let g=typeof r.budgetUsd=="string"&&r.budgetUsd.trim()?r.budgetUsd.trim():typeof r.budget=="string"&&r.budget.trim()?r.budget.trim():"",u=await i.runPublishedSnapshot({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{snapshotId:s}:{},...a?{templateName:a}:{},...d?{version:d}:{},...c?{useCase:c}:{},...g?{budget:{maxUsd:g}}:{},metadata:{source:"openpond-code-published-snapshot-run"}});console.log(JSON.stringify(u,null,2));return}if(e==="snapshot-fork"||e==="fork-snapshot"){let t=o[1];if(!t)throw new Error("snapshot-fork requires <snapshotId>");let n=typeof r.teamId=="string"?r.teamId.trim():"",s=typeof r.projectId=="string"?r.projectId.trim():"",a=typeof r.budgetUsd=="string"&&r.budgetUsd.trim()?r.budgetUsd.trim():typeof r.budget=="string"&&r.budget.trim()?r.budget.trim():"",d=await i.forkSnapshot(t,{...n?{teamId:n}:{},...s?{projectId:s}:{},...a?{budget:{maxUsd:a}}:{},metadata:{source:"openpond-code-snapshot-fork",templateSnapshotId:t}});console.log(JSON.stringify(d,null,2));return}if(e==="snapshot-create"||e==="create-snapshot"){let t=o[1];if(!t)throw new Error("usage: sandbox snapshot-create <sandboxId> --name <name>");let n=await i.createSnapshot(t,L(r));console.log(JSON.stringify(n,null,2));return}if(e==="snapshot-validate"||e==="validate-snapshot"){let t=o[1],n=o[2];if(!t||!n)throw new Error("snapshot-validate requires <sandboxId> <snapshotId>");let s=R(r.cleanup),a=await i.validateSnapshot(t,n,{...s?{cleanup:s}:{}});console.log(JSON.stringify(a,null,2));return}if(e==="snapshot-publish"||e==="publish-snapshot"){let t=o[1],n=o[2];if(!t||!n)throw new Error("snapshot-publish requires <sandboxId> <snapshotId>");let s=await i.publishSnapshot(t,n);console.log(JSON.stringify(s,null,2));return}if(e==="integration-connections"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=r.status==="active"||r.status==="revoked"||r.status==="error"||r.status==="all"?r.status:void 0,d=await i.integrationConnections({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{},...a?{status:a}:{}});console.log(JSON.stringify(d,null,2));return}if(e==="create"){let t=await N(i,B(r));console.log(JSON.stringify({sandbox:l(t.sandbox),...t.runtime?{runtime:t.runtime}:{}},null,2));return}if(e==="exec"){let t=o[1],n=(typeof r.command=="string"?r.command:null)||o.slice(2).join(" ");if(!t||!n.trim())throw new Error("usage: sandbox exec <sandboxId> --command <command>");let s=p(r.timeoutSeconds,"timeout-seconds"),a=await i.exec(t,{command:n.trim(),...s!==void 0?{timeoutSeconds:s}:{}});console.log(JSON.stringify({sandbox:l(a.sandbox),command:a.command},null,2));return}if(e==="port"||e==="preview"){let t=o[1],n=p(r.port,"port");if(!t||n===void 0)throw new Error("usage: sandbox port <sandboxId> --port <port>");let s=typeof r.label=="string"?r.label:void 0,a=typeof r.access=="string"?r.access.trim():"";if(a&&a!=="private"&&a!=="public")throw new Error("sandbox port --access must be private or public");let d=a==="public"?"public":"private",c=typeof r.domain=="string"?r.domain.trim():"",g=typeof r.authToken=="string"?r.authToken:"",u=typeof r.authHeader=="string"?r.authHeader.trim():"",m=typeof r.authHeaderValue=="string"?r.authHeaderValue:"";if(g&&(u||m))throw new Error("sandbox port auth options must use either --auth-token or --auth-header with --auth-header-value");if(u&&!m||!u&&m)throw new Error("sandbox port custom header auth requires both --auth-header and --auth-header-value");let x=await i.openPort(t,{port:n,...s?{label:s}:{},access:d,...r["auto-start"]||r.autoStart?{autoStart:!0}:{},...c?{customDomain:c}:{},...g?{authPolicy:{mode:"bearer",token:g}}:{},...u&&m?{authPolicy:{mode:"header",headerName:u,headerValue:m}}:{}});console.log(JSON.stringify(x.preview,null,2));return}if(e==="stop"){let t=o[1];if(!t)throw new Error("usage: sandbox stop <sandboxId> [--fail-on-unpreserved-changes] [--async]");let n=await i.stop(t,{failOnUnpreservedChanges:f(r.failOnUnpreservedChanges),async:G(r)});console.log(JSON.stringify({sandbox:l(n.sandbox),receipt:n.receipt},null,2));return}if(e==="start"){let t=o[1];if(!t)throw new Error("usage: sandbox start <sandboxId>");let n=await i.start(t);console.log(JSON.stringify({sandbox:await E(i,n.sandbox),receipt:n.receipt},null,2));return}if(e==="delete"){let t=o[1];if(!t)throw new Error("usage: sandbox delete <sandboxId> [--fail-on-unpreserved-changes] [--async]");let n=await i.delete(t,{failOnUnpreservedChanges:f(r.failOnUnpreservedChanges),async:G(r)});console.log(JSON.stringify({sandbox:l(n)},null,2));return}if(e==="receipts"){let t=o[1];if(!t)throw new Error("usage: sandbox receipts <sandboxId>");let n=await i.receipts(t);console.log(JSON.stringify({receipts:n},null,2));return}if(e==="logs"){let t=o[1];if(!t)throw new Error("usage: sandbox logs <sandboxId>");let n=await i.logs(t);for(let s of n)console.log(s);return}if(!(await F(i,e,r,o)||await M(i,e,r,o)||await T(i,e,r,o))){if(e==="billing"){let t=o[1];if(!t)throw new Error("usage: sandbox billing <sandboxId>");let n=await i.billing(t);console.log(JSON.stringify({sandbox:l(n.sandbox),billing:n.billing},null,2));return}if(e==="integration-leases"){let t=o[1];if(!t)throw new Error("usage: sandbox integration-leases <sandboxId>");let n=await i.integrationLeases(t);console.log(JSON.stringify({sandbox:l(n.sandbox),integrationLeases:n.integrationLeases},null,2));return}if(e==="integration-attach"){let t=o[1];if(!t)throw new Error("usage: sandbox integration-attach <sandboxId> --integration-connection <id> --integration-capabilities <csv>");let n=await i.attachIntegrationConnection(t,q(r));console.log(JSON.stringify({sandbox:l(n.sandbox),integrationLeases:n.integrationLeases},null,2));return}if(e==="integration-remove"){let t=o[1],n=typeof r.leaseId=="string"?r.leaseId.trim():"";if(!t||!n)throw new Error("usage: sandbox integration-remove <sandboxId> --lease-id <id>");let s=await i.removeIntegrationLease(t,n);console.log(JSON.stringify({sandbox:l(s.sandbox),integrationLeases:s.integrationLeases},null,2));return}if(e==="smoke"){let t=typeof r.repo=="string"?r.repo.trim():void 0,n=typeof r.budgetUsd=="string"?r.budgetUsd.trim():typeof r.budget=="string"?r.budget.trim():void 0,s=f(r.keep),a=r.preview!==void 0?f(r.preview):!f(r.noPreview),d=f(r.snapshot),c=f(r.fork),g={...t?{repo:t}:{},...n?{budgetUsd:n}:{},keep:s,preview:a,snapshot:d,fork:c};typeof r.expectedMppMode=="string"&&r.expectedMppMode.trim()&&(g.expectedMppMode=r.expectedMppMode.trim());let u=h(r.cpu,"cpu"),m=h(r.memoryGb,"memory-gb"),x=h(r.diskGb,"disk-gb");u!==void 0&&(g.cpu=u),m!==void 0&&(g.memoryGb=m),x!==void 0&&(g.diskGb=x);let z=await i.smoke(g);console.log(JSON.stringify(z,null,2));return}throw new Error("usage: sandbox <list|mcp-config|runtime-list|runtime-get|runtime-events|runtime-status|runtime-event|runtime-preserve-source|pricing|costs|secrets|secret-create|secret-rotate|secret-attach|secret-revoke|secret-delete|snapshots|published-snapshots|run-published-snapshot|snapshot-fork|snapshot-validate|snapshot-publish|create|exec|port|preview|stop|start|delete|receipts|logs|billing|process-start|process-list|process-get|process-stop|process-stream|pty-start|pty-list|pty-get|pty-write|pty-stop|pty-stream|upload-file|download-file|list-files|search-files|delete-file|stat-file|mkdir|move-file|git-status|git-diff|git-export-patch|git-branch|git-commit|git-pull|git-push|smoke> [args]")}}}}}b(Pe,"runSandboxCommand");export{Pe as runSandboxCommand};
2
+ import{a as N,b as E,c as P,d as J,e as j,f as S,g as O,h as C,i as R,j as k,k as B,l as q,m as U,n as L,o as l}from"./chunk-WITSXYEW.js";import{m as v,s as w,t as y}from"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{b as I,f,g as h,h as p}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as b}from"./chunk-FTQLQJQV.js";async function M(r,o,e,i){if(o==="list-files"){let t=i[1];if(!t)throw new Error("usage: sandbox list-files <sandboxId> [--path <path>]");let n=typeof e.path=="string"?e.path.trim():void 0,s=h(e.maxEntries,"max-entries"),a=e.recursive!==void 0?f(e.recursive):void 0,d=await r.listFiles(t,{...n?{path:n}:{},...a!==void 0?{recursive:a}:{},...s!==void 0?{maxEntries:s}:{}});return console.log(JSON.stringify({sandbox:l(d.sandbox),files:d.files},null,2)),!0}if(o==="upload-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",s=typeof e.contents=="string"?e.contents:typeof e.content=="string"?e.content:"",a=typeof e.contentsBase64=="string"?e.contentsBase64.trim():typeof e.contentBase64=="string"?e.contentBase64.trim():"";if(!t||!n)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');if(!s&&!a)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');let d=a?await r.uploadFileBase64(t,n,a):await r.uploadFile(t,n,s);return console.log(JSON.stringify({sandbox:l(d.sandbox),file:d.file},null,2)),!0}if(o==="download-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",s=Number(e["offset-bytes"]),a=Number(e["max-bytes"]);if(!t||!n)throw new Error("usage: sandbox download-file <sandboxId> --path <path>");let d=await r.downloadFileResponse(t,{path:n,...Number.isFinite(s)?{offsetBytes:s}:{},...Number.isFinite(a)?{maxBytes:a}:{}});return console.log(JSON.stringify({sandbox:l(d.sandbox),file:d.file,contents:Buffer.from(d.file.contentsBase64,"base64").toString("utf-8")},null,2)),!0}if(o==="search-files"){let t=i[1],n=typeof e.query=="string"?e.query.trim():"";if(!t||!n)throw new Error("usage: sandbox search-files <sandboxId> --query <text> [--path <path>]");let s=typeof e.path=="string"?e.path.trim():void 0,a=h(e.maxResults,"max-results"),d=await r.searchFiles(t,{query:n,...s?{path:s}:{},...a!==void 0?{maxResults:a}:{}});return console.log(JSON.stringify({sandbox:l(d.sandbox),matches:d.matches},null,2)),!0}if(o==="delete-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"";if(!t||!n)throw new Error("usage: sandbox delete-file <sandboxId> --path <path> [--recursive]");let s=await r.deleteFile(t,n,{recursive:f(e.recursive)});return console.log(JSON.stringify({sandbox:l(s.sandbox),deleted:s.deleted},null,2)),!0}if(o==="stat-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"";if(!t||!n)throw new Error("usage: sandbox stat-file <sandboxId> --path <path>");let s=await r.statFile(t,n);return console.log(JSON.stringify({sandbox:l(s.sandbox),file:s.file},null,2)),!0}if(o==="mkdir"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"";if(!t||!n)throw new Error("usage: sandbox mkdir <sandboxId> --path <path> [--recursive false]");let s=await r.mkdir(t,{path:n,recursive:e.recursive!==void 0?f(e.recursive):void 0});return console.log(JSON.stringify({sandbox:l(s.sandbox),directory:s.directory},null,2)),!0}if(o==="move-file"){let t=i[1],n=typeof e.fromPath=="string"?e.fromPath.trim():"",s=typeof e.toPath=="string"?e.toPath.trim():"";if(!t||!n||!s)throw new Error("usage: sandbox move-file <sandboxId> --from-path <path> --to-path <path> [--overwrite]");let a=await r.moveFile(t,{fromPath:n,toPath:s,overwrite:f(e.overwrite)});return console.log(JSON.stringify({sandbox:l(a.sandbox),moved:a.moved,file:a.file},null,2)),!0}return!1}b(M,"handleSandboxFilesCommand");async function T(r,o,e,i){if(o==="git-status"){let t=i[1];if(!t)throw new Error("usage: sandbox git-status <sandboxId>");let n=await r.gitStatus(t);return console.log(JSON.stringify({sandbox:l(n.sandbox),status:n.status},null,2)),!0}if(o==="git-diff"){let t=i[1];if(!t)throw new Error("usage: sandbox git-diff <sandboxId> [--base-ref <ref>]");let n=typeof e.baseRef=="string"&&e.baseRef.trim()?e.baseRef.trim():void 0,s=await r.gitDiff(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:l(s.sandbox),diff:s.diff},null,2)),!0}if(o==="git-export-patch"){let t=i[1];if(!t)throw new Error("usage: sandbox git-export-patch <sandboxId> [--base-ref <ref>]");let n=typeof e.baseRef=="string"&&e.baseRef.trim()?e.baseRef.trim():void 0,s=await r.gitExportPatch(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:l(s.sandbox),patch:s.patch},null,2)),!0}if(o==="git-branch"){let t=i[1],n=typeof e.branch=="string"?e.branch.trim():"",s=typeof e.startPoint=="string"&&e.startPoint.trim()?e.startPoint.trim():void 0;if(!t||!n)throw new Error("usage: sandbox git-branch <sandboxId> --branch <name> [--create] [--start-point <ref>]");let a=await r.gitBranch(t,{branch:n,create:f(e.create),...s?{startPoint:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),branch:a.branch},null,2)),!0}if(o==="git-commit"){let t=i[1],n=typeof e.message=="string"?e.message.trim():"",s=f(e.all),d=(typeof e.paths=="string"?e.paths:typeof e.path=="string"?e.path:"").split(",").map(g=>g.trim()).filter(Boolean);if(!t||!n||!s&&d.length===0)throw new Error('usage: sandbox git-commit <sandboxId> --message "..." [--all|--paths <csv>]');let c=await r.gitCommit(t,{message:n,...s?{all:!0}:{paths:d}});return console.log(JSON.stringify({sandbox:l(c.sandbox),commit:c.commit},null,2)),!0}if(o==="git-pull"){let t=i[1];if(!t)throw new Error("usage: sandbox git-pull <sandboxId> [--remote origin] [--branch main] [--rebase|--ff-only false]");let n=typeof e.remote=="string"&&e.remote.trim()?e.remote.trim():void 0,s=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,a=await r.gitPull(t,{...n?{remote:n}:{},...s?{branch:s}:{},...e.rebase!==void 0?{rebase:f(e.rebase)}:{},...e.ffOnly!==void 0?{ffOnly:f(e.ffOnly)}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),pull:a.pull},null,2)),!0}if(o==="git-push"){let t=i[1];if(!t)throw new Error("usage: sandbox git-push <sandboxId> [--remote origin] [--branch main] [--set-upstream] [--force-with-lease]");let n=typeof e.remote=="string"&&e.remote.trim()?e.remote.trim():void 0,s=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,a=await r.gitPush(t,{...n?{remote:n}:{},...s?{branch:s}:{},...e.setUpstream!==void 0?{setUpstream:f(e.setUpstream)}:{},...e.forceWithLease!==void 0?{forceWithLease:f(e.forceWithLease)}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),push:a.push},null,2)),!0}return!1}b(T,"handleSandboxGitCommand");async function F(r,o,e,i){if(o==="process-start"){let t=i[1],n=(typeof e.command=="string"?e.command:null)||i.slice(2).join(" ");if(!t||!n.trim())throw new Error("usage: sandbox process-start <sandboxId> --command <command>");let s=p(e.timeoutSeconds,"timeout-seconds"),a=await r.startProcess(t,{command:n.trim(),...s!==void 0?{timeoutSeconds:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),process:a.process},null,2)),!0}if(o==="process-list"){let t=i[1];if(!t)throw new Error("usage: sandbox process-list <sandboxId>");let n=await r.listProcesses(t);return console.log(JSON.stringify({sandbox:l(n.sandbox),processes:n.processes},null,2)),!0}if(o==="process-get"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox process-get <sandboxId> <processId> [--since <cursor>]");let s=p(e.since,"since"),a=await r.getProcess(t,n,{...s!==void 0?{since:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),process:a.process,output:a.output,cursor:a.cursor,completed:a.completed},null,2)),!0}if(o==="process-stop"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox process-stop <sandboxId> <processId>");let s=await r.stopProcess(t,n);return console.log(JSON.stringify({sandbox:l(s.sandbox),process:s.process},null,2)),!0}if(o==="process-stream"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox process-stream <sandboxId> <processId> [--since <cursor>]");let s=p(e.since,"since");return await r.streamProcessOutput(t,n,{...s!==void 0?{since:s}:{}}),!0}if(o==="pty-start"){let t=i[1];if(!t)throw new Error("usage: sandbox pty-start <sandboxId> [--command <command>]");let n=(typeof e.command=="string"?e.command:null)||i.slice(2).join(" "),s=p(e.timeoutSeconds,"timeout-seconds"),a=p(e.rows,"rows"),d=p(e.cols,"cols"),c=await r.startPty(t,{...n.trim()?{command:n.trim()}:{},...s!==void 0?{timeoutSeconds:s}:{},...a!==void 0?{rows:a}:{},...d!==void 0?{cols:d}:{}});return console.log(JSON.stringify({sandbox:l(c.sandbox),pty:c.pty},null,2)),!0}if(o==="pty-list"){let t=i[1];if(!t)throw new Error("usage: sandbox pty-list <sandboxId>");let n=await r.listPtys(t);return console.log(JSON.stringify({sandbox:l(n.sandbox),ptys:n.ptys},null,2)),!0}if(o==="pty-get"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox pty-get <sandboxId> <ptyId> [--since <cursor>]");let s=p(e.since,"since"),a=await r.getPty(t,n,{...s!==void 0?{since:s}:{}});return console.log(JSON.stringify({sandbox:l(a.sandbox),pty:a.pty,output:a.output,cursor:a.cursor,completed:a.completed},null,2)),!0}if(o==="pty-write"){let t=i[1],n=i[2],s=typeof e.inputBase64=="string"?e.inputBase64.trim():"",a=(typeof e.input=="string"?e.input:null)||i.slice(3).join(" ");if(!t||!n||!s&&!a)throw new Error("usage: sandbox pty-write <sandboxId> <ptyId> --input <text>");let d=await r.writePtyInput(t,n,s?{dataBase64:s}:a);return console.log(JSON.stringify({sandbox:l(d.sandbox),pty:d.pty},null,2)),!0}if(o==="pty-stop"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox pty-stop <sandboxId> <ptyId>");let s=await r.stopPty(t,n);return console.log(JSON.stringify({sandbox:l(s.sandbox),pty:s.pty},null,2)),!0}if(o==="pty-stream"){let t=i[1],n=i[2];if(!t||!n)throw new Error("usage: sandbox pty-stream <sandboxId> <ptyId> [--since <cursor>]");let s=p(e.since,"since");return await r.streamPtyOutput(t,n,{...s!==void 0?{since:s}:{}}),!0}return!1}b(F,"handleSandboxProcessCommand");async function A(r,o,e,i){if(o==="replays"||o==="replay-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.listReplays({...t?{teamId:t}:{},...n?{projectId:n}:{}});if(f(e.json))return console.log(JSON.stringify(s,null,2)),!0;if(s.replays.length===0)return console.log("no sandbox replays found"),!0;for(let a of s.replays)console.log(O(a));return!0}if(o==="replay-start"||o==="start-replay"){let t=await r.startReplay(k(e));return console.log(JSON.stringify(t,null,2)),!0}if(o==="replay-get"||o==="get-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-get <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.getReplay(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});return console.log(JSON.stringify(a,null,2)),!0}if(o==="replay-logs"||o==="logs-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-logs <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.getReplayLogs(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});for(let d of a.logs)console.log(d);return!0}if(o==="replay-artifacts"||o==="artifacts-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-artifacts <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.getReplayArtifacts(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});return console.log(JSON.stringify({replayId:a.replayId,artifacts:a.artifacts.map(C)},null,2)),!0}if(o==="replay-cancel"||o==="cancel-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-cancel <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=await r.cancelReplay(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});return console.log(JSON.stringify(a,null,2)),!0}if(o==="replay-watch"||o==="watch-replay"){let t=i[1];if(!t)throw new Error("usage: sandbox replay-watch <replayId> [--team-id <id>]");let n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.projectId=="string"?e.projectId.trim():"",a=p(e.intervalMs,"interval-ms")??5e3,d=p(e.timeoutMs,"timeout-ms")??900*1e3,c=Date.now(),g=new Set;for(;Date.now()-c<=d;){let u=await r.getReplay(t,{...n?{teamId:n}:{},...s?{projectId:s}:{}});for(let m of u.replay.logs)g.has(m)||(g.add(m),console.log(m));if(u.replay.state==="succeeded"||u.replay.state==="failed"||u.replay.state==="canceled"){if(console.log(O(u.replay)),u.replay.state!=="succeeded")throw new Error(`sandbox replay ${u.replay.state}: ${u.replay.error??"no error"}`);return!0}await new Promise(m=>setTimeout(m,a))}throw new Error(`sandbox replay did not finish within ${d}ms`)}return!1}b(A,"handleSandboxReplayCommand");async function V(r,o,e,i){if(o==="runtime-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.projectId=="string"?e.projectId.trim():"",s=typeof e.agentId=="string"?e.agentId.trim():"",a=await r.listSandboxRuntimes({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{}});return console.log(JSON.stringify({runtimes:a},null,2)),!0}if(o==="runtime-get"){let t=i[1]?.trim();if(!t)throw new Error("usage: sandbox runtime-get <runtimeId>");let n=await r.getSandboxRuntime(t);return console.log(JSON.stringify({runtime:n},null,2)),!0}if(o==="runtime-events"){let t=i[1]?.trim();if(!t)throw new Error("usage: sandbox runtime-events <runtimeId>");return console.log(JSON.stringify(await r.listSandboxRuntimeEvents(t),null,2)),!0}if(o==="runtime-status"){let t=i[1]?.trim(),n=typeof e.status=="string"&&e.status.trim()?e.status.trim():"",s=Number(e.expectedVersion),a=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0;if(!t||!n||!Number.isInteger(s))throw new Error("usage: sandbox runtime-status <runtimeId> --status <status> --expected-version <n>");let d=await r.updateSandboxRuntimeStatus(t,{status:n,expectedVersion:s,...a?{summary:a}:{}});return console.log(JSON.stringify({runtime:d},null,2)),!0}if(o==="runtime-event"){let t=i[1]?.trim(),n=typeof e.type=="string"&&e.type.trim()?e.type.trim():"",s=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0,a=typeof e.payload=="string"&&e.payload.trim()?I(e.payload,"payload"):void 0,d=typeof e.lifecycleHint=="string"&&e.lifecycleHint.trim()?I(e.lifecycleHint,"lifecycle-hint"):void 0;if(!t||!n)throw new Error("usage: sandbox runtime-event <runtimeId> --type <eventType> [--summary <text>] [--payload <json>] [--lifecycle-hint <json>]");return console.log(JSON.stringify(await r.emitSandboxRuntimeEvent(t,{type:n,...s?{summary:s}:{},...a?{payload:a}:{},...d?{lifecycleHint:d}:{}}),null,2)),!0}if(o==="runtime-preserve-source"||o==="runtime-preserve"){let t=i[1]?.trim(),n=typeof e.teamId=="string"&&e.teamId.trim()?e.teamId.trim():"",s=typeof e.sandboxId=="string"&&e.sandboxId.trim()?e.sandboxId.trim():"",a=typeof e.message=="string"&&e.message.trim()?e.message.trim():"";if(!t)throw new Error("usage: sandbox runtime-preserve-source <runtimeId> [--team-id <id>] [--sandbox-id <id>] [--message <text>]");return console.log(JSON.stringify(await r.runtimes.preserveSource(t,{...s?{sandboxId:s}:{},...a?{message:a}:{}},{...n?{teamId:n}:{}}),null,2)),!0}return!1}b(V,"handleSandboxRuntimeCommand");async function $(r,o,e,i){if(o==="secrets"||o==="secret-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=await r.listSecrets({...t?{teamId:t}:{}});if(f(e.json))return console.log(JSON.stringify({secrets:n.map(y)},null,2)),!0;if(n.length===0)return console.log("no sandbox secrets found"),!0;for(let s of n)console.log(`${s.name} ${s.status} v${s.currentVersion??"current"} ${s.secretRef}`);return!0}if(o==="secret-create"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.name=="string"?e.name.trim():"",s=typeof e.description=="string"&&e.description.trim()?e.description.trim():void 0,a=e.scope==="project"||e.scope==="template"||e.scope==="team"?e.scope:void 0;if(!n)throw new Error("usage: sandbox secret-create --name <ENV_NAME> [--team-id <id>] [--stdin]");let d=await w(e,`Value for ${n}`),c=await r.createSecret({...t?{teamId:t}:{},name:n,value:d,...s?{description:s}:{},...a?{scope:a}:{}});return console.log(JSON.stringify({secret:y(c)},null,2)),!0}if(o==="secret-rotate"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"";if(!t)throw new Error("usage: sandbox secret-rotate <secretId> [--team-id <id>] [--stdin]");let s=await w(e,"New secret value"),a=await r.rotateSecret(t,{...n?{teamId:n}:{},value:s});return console.log(JSON.stringify({secret:y(a)},null,2)),!0}if(o==="secret-attach"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"",s=typeof e.envName=="string"?e.envName.trim():"",a=e.targetType==="sandbox"||e.targetType==="template"||e.targetType==="project"||e.targetType==="agent"||e.targetType==="replay"?e.targetType:void 0,d=typeof e.targetId=="string"?e.targetId.trim():"";if(!t||!s||!a||!d)throw new Error("usage: sandbox secret-attach <secretId> --env-name <ENV_NAME> --target-type sandbox|project|agent|template|replay --target-id <id>");let c=await r.attachSecret(t,{...n?{teamId:n}:{},envName:s,targetType:a,targetId:d});return console.log(JSON.stringify({secret:y(c)},null,2)),!0}if(o==="secret-revoke"||o==="secret-delete"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"";if(!t)throw new Error(`usage: sandbox ${o} <secretId> [--team-id <id>]`);let s=o==="secret-revoke"?await r.revokeSecret(t,{...n?{teamId:n}:{}}):await r.deleteSecret(t,{...n?{teamId:n}:{}});return console.log(JSON.stringify({secret:y(s)},null,2)),!0}return!1}b($,"handleSandboxSecretsCommand");async function H(r,o,e,i){if(o==="published-snapshot-builds"||o==="published-snapshot-build-list"||o==="template-builds"||o==="template-build-list"){let t=typeof e.teamId=="string"?e.teamId.trim():"";if(!t)throw new Error("usage: sandbox published-snapshot-builds --team-id <id>");let n=await r.listPublishedSnapshotBuilds({teamId:t});if(f(e.json))return console.log(JSON.stringify({builds:n},null,2)),!0;if(n.length===0)return console.log("no published snapshot builds found"),!0;for(let s of n)console.log(S(s));return!0}if(o==="published-snapshot-build-create"||o==="create-published-snapshot-build"||o==="template-build-create"||o==="create-template-build"){let t=await r.createPublishedSnapshotBuild(U(e));return console.log(JSON.stringify({build:t},null,2)),!0}if(o==="published-snapshot-build-get"||o==="get-published-snapshot-build"||o==="template-build-get"||o==="get-template-build"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-get <buildId>");let n=await r.getPublishedSnapshotBuild(t);return console.log(JSON.stringify({build:n},null,2)),!0}if(o==="published-snapshot-build-logs"||o==="published-snapshot-build-log"||o==="template-build-logs"||o==="template-build-log"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-logs <buildId>");let n=await r.getPublishedSnapshotBuildLogs(t);if(f(e.json))return console.log(JSON.stringify(n,null,2)),!0;for(let s of n.logs)console.log(s);return!0}if(o==="published-snapshot-build-cancel"||o==="cancel-published-snapshot-build"||o==="template-build-cancel"||o==="cancel-template-build"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-cancel <buildId>");let n=await r.cancelPublishedSnapshotBuild(t);return console.log(JSON.stringify({build:n},null,2)),!0}if(o==="published-snapshot-build-watch"||o==="watch-published-snapshot-build"||o==="template-build-watch"||o==="watch-template-build"){let t=i[1];if(!t)throw new Error("usage: sandbox published-snapshot-build-watch <buildId>");let n=p(e.intervalMs,"interval-ms")??5e3,s=p(e.timeoutMs,"timeout-ms")??900*1e3,a=Date.now(),d=new Set;for(;Date.now()-a<=s;){let[c,g]=await Promise.all([r.getPublishedSnapshotBuild(t),r.getPublishedSnapshotBuildLogs(t)]);for(let u of g.logs)d.has(u)||(d.add(u),console.log(u));if(c.status==="succeeded"||c.status==="failed"||c.status==="cancelled"){if(console.log(S(c)),c.status!=="succeeded")throw new Error(`published snapshot build ${c.status}: ${c.error??"no error"}`);return!0}await new Promise(u=>setTimeout(u,n))}throw new Error(`published snapshot build did not finish within ${s}ms`)}return!1}b(H,"handleSandboxTemplateBuildsCommand");function G(r){return f(r.async)||f(r.respondAsync)}b(G,"parseSandboxAsyncOption");async function Pe(r,o){let e=o[0]||"list",i=await v(r);if(e==="list"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=await i.list({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{}});if(a.length===0){console.log("no sandboxes found");return}for(let d of a)console.log(P(d));return}if(e==="mcp-config"||e==="mcp-url"){let t=i.mcpServerConfig();console.log(JSON.stringify({...t,headers:{"openpond-api-key":"set OPENPOND_API_KEY or use your saved openpond profile"}},null,2));return}if(!await V(i,e,r,o)){if(e==="pricing"){let t=await i.pricing();console.log(JSON.stringify(t,null,2));return}if(e==="costs"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=await i.costs({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{}});if(f(r.summary)){console.log(JSON.stringify({costs:{teamId:a.costs.teamId,ownerUserId:a.costs.ownerUserId,generatedAt:a.costs.generatedAt,summary:a.costs.summary,lineItems:a.costs.lineItems,tiers:a.costs.pricing.tiers.map(d=>({key:d.key,resources:d.resources,keepRunningEstimate:d.keepRunningEstimate}))}},null,2));return}console.log(JSON.stringify(a,null,2));return}if(!await $(i,e,r,o)){if(e==="snapshots"||e==="snapshot-catalog"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=typeof r.query=="string"&&r.query.trim()?r.query.trim():typeof r.q=="string"&&r.q.trim()?r.q.trim():"",d=typeof r.tag=="string"?r.tag.trim():"",c=typeof r.useCase=="string"?r.useCase.trim():"",g=typeof r.replayState=="string"?r.replayState.trim():"",u=await i.snapshotCatalog({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{},...a?{q:a}:{},...d?{tag:d}:{},...c?{useCase:c}:{},...g==="draft"||g==="validated"||g==="published"?{replayState:g}:{}});if(u.snapshots.length===0){console.log("no sandbox snapshots found");return}for(let m of u.snapshots)console.log(J(m));return}if(e==="published-snapshots"||e==="published-snapshot-catalog"||e==="templates"||e==="template-catalog"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.query=="string"&&r.query.trim()?r.query.trim():typeof r.q=="string"&&r.q.trim()?r.q.trim():"",a=typeof r.name=="string"&&r.name.trim()?r.name.trim():typeof r.templateName=="string"&&r.templateName.trim()?r.templateName.trim():"",d=typeof r.version=="string"?r.version.trim():"",c=typeof r.tag=="string"?r.tag.trim():"",g=typeof r.useCase=="string"?r.useCase.trim():"",u=await i.publishedSnapshots({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{q:s}:{},...a?{name:a}:{},...d?{version:d}:{},...c?{tag:c}:{},...g?{useCase:g}:{}});if(u.publishedSnapshots.length===0){console.log("no published snapshots found");return}for(let m of u.publishedSnapshots)console.log(j(m));return}if(!(await H(i,e,r,o)||await A(i,e,r,o))){if(e==="run-published-snapshot"||e==="published-snapshot-run"||e==="template-launch"||e==="launch-template"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.snapshotId=="string"&&r.snapshotId.trim()?r.snapshotId.trim():typeof r.snapshot=="string"&&r.snapshot.trim()?r.snapshot.trim():"",a=typeof r.templateName=="string"&&r.templateName.trim()?r.templateName.trim():typeof r.name=="string"&&r.name.trim()?r.name.trim():typeof o[1]=="string"&&o[1].trim()?o[1].trim():"",d=typeof r.version=="string"?r.version.trim():"",c=typeof r.useCase=="string"?r.useCase.trim():"";if(!s&&!a&&!c)throw new Error("usage: sandbox run-published-snapshot [--snapshot-id <id>|--name <name>|--use-case <id>] [--version <v>]");let g=typeof r.budgetUsd=="string"&&r.budgetUsd.trim()?r.budgetUsd.trim():typeof r.budget=="string"&&r.budget.trim()?r.budget.trim():"",u=await i.runPublishedSnapshot({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{snapshotId:s}:{},...a?{templateName:a}:{},...d?{version:d}:{},...c?{useCase:c}:{},...g?{budget:{maxUsd:g}}:{},metadata:{source:"openpond-code-published-snapshot-run"}});console.log(JSON.stringify(u,null,2));return}if(e==="snapshot-fork"||e==="fork-snapshot"){let t=o[1];if(!t)throw new Error("snapshot-fork requires <snapshotId>");let n=typeof r.teamId=="string"?r.teamId.trim():"",s=typeof r.projectId=="string"?r.projectId.trim():"",a=typeof r.budgetUsd=="string"&&r.budgetUsd.trim()?r.budgetUsd.trim():typeof r.budget=="string"&&r.budget.trim()?r.budget.trim():"",d=await i.forkSnapshot(t,{...n?{teamId:n}:{},...s?{projectId:s}:{},...a?{budget:{maxUsd:a}}:{},metadata:{source:"openpond-code-snapshot-fork",templateSnapshotId:t}});console.log(JSON.stringify(d,null,2));return}if(e==="snapshot-create"||e==="create-snapshot"){let t=o[1];if(!t)throw new Error("usage: sandbox snapshot-create <sandboxId> --name <name>");let n=await i.createSnapshot(t,L(r));console.log(JSON.stringify(n,null,2));return}if(e==="snapshot-validate"||e==="validate-snapshot"){let t=o[1],n=o[2];if(!t||!n)throw new Error("snapshot-validate requires <sandboxId> <snapshotId>");let s=R(r.cleanup),a=await i.validateSnapshot(t,n,{...s?{cleanup:s}:{}});console.log(JSON.stringify(a,null,2));return}if(e==="snapshot-publish"||e==="publish-snapshot"){let t=o[1],n=o[2];if(!t||!n)throw new Error("snapshot-publish requires <sandboxId> <snapshotId>");let s=await i.publishSnapshot(t,n);console.log(JSON.stringify(s,null,2));return}if(e==="integration-connections"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",s=typeof r.agentId=="string"?r.agentId.trim():"",a=r.status==="active"||r.status==="revoked"||r.status==="error"||r.status==="all"?r.status:void 0,d=await i.integrationConnections({...t?{teamId:t}:{},...n?{projectId:n}:{},...s?{agentId:s}:{},...a?{status:a}:{}});console.log(JSON.stringify(d,null,2));return}if(e==="create"){let t=await N(i,B(r));console.log(JSON.stringify({sandbox:l(t.sandbox),...t.runtime?{runtime:t.runtime}:{}},null,2));return}if(e==="exec"){let t=o[1],n=(typeof r.command=="string"?r.command:null)||o.slice(2).join(" ");if(!t||!n.trim())throw new Error("usage: sandbox exec <sandboxId> --command <command>");let s=p(r.timeoutSeconds,"timeout-seconds"),a=await i.exec(t,{command:n.trim(),...s!==void 0?{timeoutSeconds:s}:{}});console.log(JSON.stringify({sandbox:l(a.sandbox),command:a.command},null,2));return}if(e==="port"||e==="preview"){let t=o[1],n=p(r.port,"port");if(!t||n===void 0)throw new Error("usage: sandbox port <sandboxId> --port <port>");let s=typeof r.label=="string"?r.label:void 0,a=typeof r.access=="string"?r.access.trim():"";if(a&&a!=="private"&&a!=="public")throw new Error("sandbox port --access must be private or public");let d=a==="public"?"public":"private",c=typeof r.domain=="string"?r.domain.trim():"",g=typeof r.authToken=="string"?r.authToken:"",u=typeof r.authHeader=="string"?r.authHeader.trim():"",m=typeof r.authHeaderValue=="string"?r.authHeaderValue:"";if(g&&(u||m))throw new Error("sandbox port auth options must use either --auth-token or --auth-header with --auth-header-value");if(u&&!m||!u&&m)throw new Error("sandbox port custom header auth requires both --auth-header and --auth-header-value");let x=await i.openPort(t,{port:n,...s?{label:s}:{},access:d,...r["auto-start"]||r.autoStart?{autoStart:!0}:{},...c?{customDomain:c}:{},...g?{authPolicy:{mode:"bearer",token:g}}:{},...u&&m?{authPolicy:{mode:"header",headerName:u,headerValue:m}}:{}});console.log(JSON.stringify(x.preview,null,2));return}if(e==="stop"){let t=o[1];if(!t)throw new Error("usage: sandbox stop <sandboxId> [--fail-on-unpreserved-changes] [--async]");let n=await i.stop(t,{failOnUnpreservedChanges:f(r.failOnUnpreservedChanges),async:G(r)});console.log(JSON.stringify({sandbox:l(n.sandbox),receipt:n.receipt},null,2));return}if(e==="start"){let t=o[1];if(!t)throw new Error("usage: sandbox start <sandboxId>");let n=await i.start(t);console.log(JSON.stringify({sandbox:await E(i,n.sandbox),receipt:n.receipt},null,2));return}if(e==="delete"){let t=o[1];if(!t)throw new Error("usage: sandbox delete <sandboxId> [--fail-on-unpreserved-changes] [--async]");let n=await i.delete(t,{failOnUnpreservedChanges:f(r.failOnUnpreservedChanges),async:G(r)});console.log(JSON.stringify({sandbox:l(n)},null,2));return}if(e==="receipts"){let t=o[1];if(!t)throw new Error("usage: sandbox receipts <sandboxId>");let n=await i.receipts(t);console.log(JSON.stringify({receipts:n},null,2));return}if(e==="logs"){let t=o[1];if(!t)throw new Error("usage: sandbox logs <sandboxId>");let n=await i.logs(t);for(let s of n)console.log(s);return}if(!(await F(i,e,r,o)||await M(i,e,r,o)||await T(i,e,r,o))){if(e==="billing"){let t=o[1];if(!t)throw new Error("usage: sandbox billing <sandboxId>");let n=await i.billing(t);console.log(JSON.stringify({sandbox:l(n.sandbox),billing:n.billing},null,2));return}if(e==="integration-leases"){let t=o[1];if(!t)throw new Error("usage: sandbox integration-leases <sandboxId>");let n=await i.integrationLeases(t);console.log(JSON.stringify({sandbox:l(n.sandbox),integrationLeases:n.integrationLeases},null,2));return}if(e==="integration-attach"){let t=o[1];if(!t)throw new Error("usage: sandbox integration-attach <sandboxId> --integration-connection <id> --integration-capabilities <csv>");let n=await i.attachIntegrationConnection(t,q(r));console.log(JSON.stringify({sandbox:l(n.sandbox),integrationLeases:n.integrationLeases},null,2));return}if(e==="integration-remove"){let t=o[1],n=typeof r.leaseId=="string"?r.leaseId.trim():"";if(!t||!n)throw new Error("usage: sandbox integration-remove <sandboxId> --lease-id <id>");let s=await i.removeIntegrationLease(t,n);console.log(JSON.stringify({sandbox:l(s.sandbox),integrationLeases:s.integrationLeases},null,2));return}if(e==="smoke"){let t=typeof r.repo=="string"?r.repo.trim():void 0,n=typeof r.budgetUsd=="string"?r.budgetUsd.trim():typeof r.budget=="string"?r.budget.trim():void 0,s=f(r.keep),a=r.preview!==void 0?f(r.preview):!f(r.noPreview),d=f(r.snapshot),c=f(r.fork),g={...t?{repo:t}:{},...n?{budgetUsd:n}:{},keep:s,preview:a,snapshot:d,fork:c};typeof r.expectedMppMode=="string"&&r.expectedMppMode.trim()&&(g.expectedMppMode=r.expectedMppMode.trim());let u=h(r.cpu,"cpu"),m=h(r.memoryGb,"memory-gb"),x=h(r.diskGb,"disk-gb");u!==void 0&&(g.cpu=u),m!==void 0&&(g.memoryGb=m),x!==void 0&&(g.diskGb=x);let z=await i.smoke(g);console.log(JSON.stringify(z,null,2));return}throw new Error("usage: sandbox <list|mcp-config|runtime-list|runtime-get|runtime-events|runtime-status|runtime-event|runtime-preserve-source|pricing|costs|secrets|secret-create|secret-rotate|secret-attach|secret-revoke|secret-delete|snapshots|published-snapshots|run-published-snapshot|snapshot-fork|snapshot-validate|snapshot-publish|create|exec|port|preview|stop|start|delete|receipts|logs|billing|process-start|process-list|process-get|process-stop|process-stream|pty-start|pty-list|pty-get|pty-write|pty-stop|pty-stream|upload-file|download-file|list-files|search-files|delete-file|stat-file|mkdir|move-file|git-status|git-diff|git-export-patch|git-branch|git-commit|git-pull|git-push|smoke> [args]")}}}}}b(Pe,"runSandboxCommand");export{Pe as runSandboxCommand};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as Ee,o as Re}from"./chunk-WITSXYEW.js";import{m as he}from"./chunk-MASJQWA2.js";import"./chunk-3A7HZJNE.js";import{c as f,d as we,e as Te,h as O,k as C,q as v,r as ye,s as U,t as Pe,u as ve}from"./chunk-EAPFMACH.js";import"./chunk-6FA3GG5B.js";import{a as ie,b as de,d as ce,e as le,k as me,m as N,n as fe,o as be,r as xe,v as g,w as ge,x as Se}from"./chunk-N3DEA6PG.js";import{c as oe}from"./chunk-PA7XP42P.js";import{f as ue,h as pe}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-RLZPX4YP.js";import"./chunk-Q4H3NUVW.js";import{a as M,f as h,h as R}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import"./chunk-2SPZYBDN.js";import{l as se}from"./chunk-QXVIIM4T.js";import{d as ae}from"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{promises as P,existsSync as kt}from"node:fs";import b from"node:path";import{Buffer as ht}from"node:buffer";import{promises as y}from"node:fs";import w from"node:path";import{Buffer as Ve}from"node:buffer";import{promises as j}from"node:fs";import S from"node:path";async function q(e,t,n,r){let a=Ie(n,r);if(!a)return[];let o=Oe(n,r),s=typeof r.projectId=="string"&&r.projectId.trim()?r.projectId.trim():typeof r.runtimeProjectId=="string"?r.runtimeProjectId.trim():"",d=typeof r.teamId=="string"?r.teamId.trim():"",c=[];for(let l of a.schedules){let u=Ce({manifest:n,schedule:l,override:o.get(l.name),mode:a.mode,sourceSandboxId:t,teamId:d,projectId:s}),m=await e.createSchedule(u);c.push({id:m.schedule.id,name:m.schedule.name,enabled:m.schedule.enabled,scheduleType:m.schedule.scheduleType,scheduleExpression:m.schedule.scheduleExpression,syncStatus:m.schedule.syncStatus,awsScheduleArn:m.schedule.awsScheduleArn??null,target:m.schedule.target})}return c}i(q,"createSandboxTemplateStartSchedules");function Ie(e,t){let n=t.enableSchedules??t.enableSchedule,r=t.disableSchedules??t.disableSchedule;if(n!==void 0&&r!==void 0)throw new Error("pass only one of --enable-schedules or --disable-schedules");let a=null,o;if(n!==void 0)a="enabled",o=n;else if(r!==void 0)a="disabled",o=r;else if(t.schedules!==void 0){o=t.schedules;let c=typeof t.scheduleMode=="string"?t.scheduleMode.trim().toLowerCase():"disabled";if(c==="none")return null;if(c!=="enabled"&&c!=="disabled")throw new Error("--schedule-mode must be enabled, disabled, or none");a=c}if(!a)return null;if(e.schedules.length===0)return{mode:a,schedules:[]};let s=ke(o,e),d=s===null?e.schedules:e.schedules.filter(c=>s.has(c.name));return{mode:a,schedules:d}}i(Ie,"resolveSandboxTemplateStartScheduleSelection");function ke(e,t){if(e===void 0||e===!0)return null;let n=String(e).trim();if(!n||n==="true"||n.toLowerCase()==="all")return null;if(n.toLowerCase()==="none")return new Set;let r=new Set(t.schedules.map(o=>o.name)),a=new Set(n.split(",").map(o=>o.trim()).filter(Boolean));for(let o of a)if(!r.has(o))throw new Error(`manifest schedule not found: ${o}`);return a}i(ke,"parseSandboxTemplateScheduleNameSelection");function Oe(e,t){let n=typeof t.scheduleOverrides=="string"?t.scheduleOverrides:typeof t.scheduleOverride=="string"?t.scheduleOverride:"";if(!n.trim())return new Map;let r=M(n,"schedule-overrides");if(!r||typeof r!="object"||Array.isArray(r))throw new Error("schedule-overrides must be a JSON object keyed by schedule name");let a=new Set(e.schedules.map(s=>s.name)),o=new Map;for(let[s,d]of Object.entries(r)){if(!a.has(s))throw new Error(`schedule override target does not exist: ${s}`);if(!d||typeof d!="object"||Array.isArray(d))throw new Error(`schedule override for ${s} must be an object`);o.set(s,d)}return o}i(Oe,"parseSandboxTemplateScheduleOverrides");function Ce(e){let t=Me(e.schedule,e.override),n=Ne(t);return{sourceSandboxId:e.sourceSandboxId,...e.teamId?{teamId:e.teamId}:{},...e.projectId?{projectId:e.projectId}:{},name:t.name,...t.description?{description:t.description}:{},...n,...t.timezone?{timezone:t.timezone}:{},enabled:typeof e.override?.enabled=="boolean"?e.override.enabled:e.mode==="enabled",...t.startAt?{startAt:t.startAt}:{},...t.endAt?{endAt:t.endAt}:{},...t.maxRuns!==void 0?{maxRuns:t.maxRuns}:{},runtimePolicy:t.runtimePolicy,target:Ae(e.manifest,t),...t.budget?{budget:t.budget}:{},...t.resources?{resources:t.resources}:{},...t.quotas?{quotas:t.quotas}:{},...t.lifecycle?{lifecycle:t.lifecycle}:{},...t.retentionPolicy?{retentionPolicy:t.retentionPolicy}:{},...t.env?{env:t.env}:{},...t.integrationLeases?{integrationLeases:t.integrationLeases}:{},metadata:{...t.metadata??{},manifestScheduleName:t.name,source:"openpond-code-sandbox-template-start"},managementSource:"openpond.yaml",manifestPath:f}}i(Ce,"buildSandboxTemplateStartScheduleInput");function Me(e,t){return t?{...e,...t,target:e.target||t.target?{...e.target??{},...t.target??{}}:void 0,metadata:e.metadata||t.metadata?{...e.metadata??{},...t.metadata??{}}:void 0}:e}i(Me,"mergeSandboxTemplateScheduleOverride");function Ne(e){return e.scheduleExpression?{scheduleType:e.scheduleType??"cron",scheduleExpression:e.scheduleExpression}:e.rate?{scheduleType:"rate",scheduleExpression:/^rate\(/i.test(e.rate)?e.rate:`rate(${e.rate})`}:e.once?{scheduleType:"once",scheduleExpression:/^at\(/i.test(e.once)?e.once:`at(${e.once})`}:{scheduleType:"cron",scheduleExpression:e.cron??""}}i(Ne,"sandboxTemplateScheduleExpression");function Ae(e,t){let n=t.command??t.target?.command??null;if(n)return{kind:"command",command:n,requiresStart:t.requiresStart??t.target?.requiresStart??!1};let r=t.target?.kind??"action";if(r==="start")return{kind:"command",command:e.start.command,requiresStart:t.requiresStart??t.target?.requiresStart??e.start.requiresStart??!1};if(r==="service"){let s=t.target?.name??"",d=e.services.find(c=>c.name===s);if(!d)throw new Error(`schedule service target does not exist: ${s}`);return{kind:"command",command:d.command,requiresStart:t.requiresStart??t.target?.requiresStart??d.requiresStart??!1}}let a=t.actionName??t.action??t.target?.actionName??(t.target?.kind==="action"?t.target?.name:void 0),o=e.actions.find(s=>s.name===a);if(!o)throw new Error(`schedule action target does not exist: ${a??""}`);return{kind:"command",command:o.command,requiresStart:t.requiresStart??t.target?.requiresStart??o.requiresStart??!1}}i(Ae,"sandboxTemplateScheduleCommandTarget");import{existsSync as Ge}from"node:fs";import We from"node:path";import{stdin as Ke}from"node:process";async function D(e,t,n){let r=typeof t.repo=="string"?t.repo.trim():"";if(r)return A(r);await $e(n);let a=await ae(),o=ue(a),s=pe(a),d=await oe(a,o),c=await Se(n,"origin");if(!c){let l=typeof t.teamId=="string"?t.teamId.trim():"",u=await se(s,d,{name:e.name,description:e.description,repoInit:"empty",...l?{teamId:l}:{}});c=ie(u);let m=await g("git",["remote","add","origin",c],{cwd:n});if(m.code!==0)throw new Error(`git remote add failed: ${m.stderr.trim()||m.stdout.trim()||"unknown error"}`)}if(le(c),await Fe(n,t),!h(t.noPush)){let l=await je(n,t);await Be(n,c,l,d,t)}return A(c)}i(D,"resolveSandboxTemplateStartRepo");async function $e(e){let t=We.join(e,".git");if(Ge(t))return;let n=await g("git",["init"],{cwd:e});if(n.code!==0)throw new Error(`git init failed: ${n.stderr.trim()||n.stdout.trim()||"unknown error"}`)}i($e,"ensureGitRepository");async function Fe(e,t){let n=await g("git",["status","--porcelain"],{cwd:e});if(n.code!==0)throw new Error(`git status failed: ${n.stderr.trim()||n.stdout.trim()||"unknown error"}`);let a=(await g("git",["rev-parse","--verify","HEAD"],{cwd:e})).code===0,o=n.stdout.trim().length>0;if(!o&&a)return;if(!(h(t.commit)||h(t.yes)||(Ke.isTTY?await me(a?"Commit local changes before starting the sandbox?":"Create the initial git commit before starting the sandbox?",!a):!1))){if(!a)throw new Error("local repository has no commits; pass --commit or commit before starting");o&&console.warn("warning: uncommitted local changes will not be included in the sandbox");return}let d=await g("git",["add","-A"],{cwd:e});if(d.code!==0)throw new Error(`git add failed: ${d.stderr.trim()||d.stdout.trim()||"unknown error"}`);let c=typeof t.commitMessage=="string"&&t.commitMessage.trim()?t.commitMessage.trim():`start ${f} sandbox`,l=await g("git",["commit","-m",c],{cwd:e});if(l.code!==0){let u=l.stderr.trim()||l.stdout.trim();if(u.includes("nothing to commit")&&a)return;throw new Error(`git commit failed: ${u||"unknown error"}`)}}i(Fe,"ensureGitCommitForSandboxTemplateStart");async function je(e,t){let r=(typeof t.branch=="string"?t.branch.trim():"")||await he(e);if(!r)throw new Error("unable to resolve git branch; pass --branch");return r}i(je,"resolveSandboxTemplateStartBranch");async function Be(e,t,n,r,a){let o;try{o=de(t,r)}catch{throw new Error("origin remote must be https for tokenized pushes")}let s=h(a.keepTokenRemote)||h(a.token)||h(a.setRemoteToken),d=t.includes("x-access-token:"),c=!s&&!d?t:null,l=process.env.GIT_TERMINAL_PROMPT;process.env.GIT_TERMINAL_PROMPT="0";try{if(!d){let m=await g("git",["remote","set-url","origin",o],{cwd:e});if(m.code!==0)throw new Error(`git remote set-url failed: ${ce(m.stderr.trim()||m.stdout.trim()||"unknown error")}`)}if((await g("git",["push","-u","origin",n],{cwd:e,inherit:!0})).code!==0)throw new Error("git push failed")}finally{c&&await g("git",["remote","set-url","origin",c],{cwd:e}).catch(()=>null),l===void 0?delete process.env.GIT_TERMINAL_PROMPT:process.env.GIT_TERMINAL_PROMPT=l}}i(Be,"pushGitBranchForSandboxTemplateStart");function $(e){return A(e).replace(/\.git$/,"")}i($,"normalizeSandboxTemplateRepoIdentity");function A(e){let t=new URL(e);t.username="",t.password="";let n=t.toString();return n.endsWith(".git")?n:`${n.replace(/\/$/,"")}.git`}i(A,"normalizeSandboxTemplateRepoUrl");async function _e(e){let t=L(e),n=S.dirname(t),r=await j.readFile(t,"utf8"),a=O(r);if(!a.ok){console.error(C(a.diagnostics)),process.exitCode=1;return}let o=a.manifest,s=G(o,e),d=await B(o,e,n),c=await D(o,e,n),l=await N(e),u=Ye(o,e,c),m=await Qe(l,u,c);await tt(l,m.id);let p=await ut(l,m.id,o,e),x=await V(l,m.id,d.uploadRequests),T={...d.scalars,..._(x,d.uploadRequests)},I=await X(l,m.id,s,T,bt(m)),k=await St(l,m.id,s.ports),E=await q(l,m.id,o,e);console.log(JSON.stringify({ok:!0,file:t,repo:c,executable:{kind:s.kind,name:s.name,command:s.command},sandbox:Re(m),setupCommands:p,uploadedFiles:x,input:T,execution:I,previews:k,schedules:E,expectedArtifacts:s.artifactPaths},null,2))}i(_e,"runSandboxTemplateStart");function G(e,t){let n=v(e),r=typeof t.action=="string"?t.action.trim():"",a=typeof t.service=="string"?t.service.trim():"",o=typeof t.target=="string"?t.target.trim():"",s=typeof t.entrypoint=="string"?t.entrypoint.trim():"",d=r||a||o||s||"start",c=r?"action":a?"service":"",l=n.find(u=>u.name===d&&(!c||u.kind===c));if(!l)throw new Error(`manifest executable not found: ${d}. Available: ${n.map(u=>`${u.kind}:${u.name}`).join(", ")}`);return l}i(G,"resolveSandboxTemplateStartExecutable");function Ye(e,t,n){let r=typeof t.budgetUsd=="string"&&t.budgetUsd.trim()?t.budgetUsd.trim():typeof t.budget=="string"&&t.budget.trim()?t.budget.trim():"0.05",a=R(t.maxDurationSeconds,"max-duration-seconds"),o=R(t.idleTimeoutSeconds,"idle-timeout-seconds"),s=typeof t.teamId=="string"?t.teamId.trim():"",d=typeof t.projectId=="string"?t.projectId.trim():"",c=typeof t.runtimeProjectId=="string"?t.runtimeProjectId.trim():"";if(d&&c&&d!==c)throw new Error("project-id and runtime-project-id must match when both are set");let l=d||c,u=typeof t.agentId=="string"?t.agentId.trim():"",m=typeof t.runtimeAgentId=="string"?t.runtimeAgentId.trim():"";if(u&&m&&u!==m)throw new Error("agent-id and runtime-agent-id must match when both are set");let p=u||m,x=fe(t.workflowMode),T=be(t.runtimePromotionPolicy),I=typeof t.runtimeBaseBranch=="string"&&t.runtimeBaseBranch.trim()?t.runtimeBaseBranch.trim():"",k=typeof t.runtimeBaseSha=="string"&&t.runtimeBaseSha.trim()?t.runtimeBaseSha.trim():"",E=typeof t.runtimeId=="string"&&t.runtimeId.trim()?t.runtimeId.trim():"",te=!!(x||T||I||k||E||c||m),ne=xe(e,t),re=Xe(e);return{sandbox:{repo:n,...s?{teamId:s}:{},...l?{projectId:l}:{},...p?{agentId:p}:{},resources:e.resources??{},networkPolicy:{internetEgress:He(e.network.egress)},budget:{maxUsd:r},quotas:{maxSpendUsd:r,...a!==void 0?{maxDurationSeconds:a}:{},...o!==void 0?{idleTimeoutSeconds:o}:{}},...ne.length>0?{env:ne}:{},...re?{workloadSource:re}:{},volumes:e.volumes,metadata:{source:"openpond-code-sandbox-template-start",manifestFile:f,template:{name:e.name,version:e.version,useCase:e.useCase}}},...te&&E?{runtimeId:E}:{},...te&&!E?{sandboxRuntime:{...s?{teamId:s}:{},...x?{workflowMode:x}:{},...l?{projectId:l}:{},...p?{agentId:p}:{},baseBranch:I||"master",...k?{baseSha:k}:{},...T?{promotionPolicy:T}:{}}}:{}}}i(Ye,"buildSandboxTemplateStartCreateInput");function Xe(e){if(e.runtime.image)return{image:e.runtime.image};if(e.runtime.dockerfile)return{dockerfile:e.runtime.dockerfile}}i(Xe,"sandboxWorkloadSourceFromManifest");function He(e){return e==="allow"?"allow":"block"}i(He,"sandboxTemplateInternetEgressPolicy");async function Qe(e,t,n){let r=Date.now();try{return(await Ee(e,t)).sandbox}catch(a){if(!Ze(a))throw a;return console.warn("warning: sandbox create timed out; checking for the created sandbox record"),et(e,t.sandbox,n,r)}}i(Qe,"createSandboxTemplateStartSandbox");function Ze(e){return e instanceof Error&&/\b(504|timed out|timeout)\b/i.test(e.message)}i(Ze,"isLikelySandboxCreateTimeout");async function et(e,t,n,r){let s=Date.now()+72e4,d=$(n),c=t.metadata??{};for(;Date.now()<s;){let u=(await e.list({...t.teamId?{teamId:t.teamId}:{},...t.projectId?{projectId:t.projectId}:{},...t.agentId?{agentId:t.agentId}:{}})).filter(m=>{if(!m.repo||$(m.repo)!==d)return!1;let p=Date.parse(m.createdAt);return!(Number.isFinite(p)&&p<r-3e4||c.source&&m.metadata?.source!==c.source)}).sort((m,p)=>Date.parse(p.createdAt)-Date.parse(m.createdAt))[0];if(u?.state==="running"||u?.state==="stopped")return u;if(u?.state==="error")throw new Error(`sandbox create failed after timeout: ${u.id}
2
+ import{a as Ee,o as Re}from"./chunk-WITSXYEW.js";import{m as he}from"./chunk-GXSTZBM6.js";import"./chunk-3A7HZJNE.js";import{c as f,d as we,e as Te,h as O,k as C,q as v,r as ye,s as U,t as Pe,u as ve}from"./chunk-EAPFMACH.js";import"./chunk-6FA3GG5B.js";import{a as ie,b as de,d as ce,e as le,k as me,m as N,n as fe,o as be,r as xe,v as g,w as ge,x as Se}from"./chunk-N3DEA6PG.js";import{c as oe}from"./chunk-PA7XP42P.js";import{f as ue,h as pe}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{a as M,f as h,h as R}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import"./chunk-2SPZYBDN.js";import{l as se}from"./chunk-QXVIIM4T.js";import{d as ae}from"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{promises as P,existsSync as kt}from"node:fs";import b from"node:path";import{Buffer as ht}from"node:buffer";import{promises as y}from"node:fs";import w from"node:path";import{Buffer as Ve}from"node:buffer";import{promises as j}from"node:fs";import S from"node:path";async function q(e,t,n,r){let a=Ie(n,r);if(!a)return[];let o=Oe(n,r),s=typeof r.projectId=="string"&&r.projectId.trim()?r.projectId.trim():typeof r.runtimeProjectId=="string"?r.runtimeProjectId.trim():"",d=typeof r.teamId=="string"?r.teamId.trim():"",c=[];for(let l of a.schedules){let u=Ce({manifest:n,schedule:l,override:o.get(l.name),mode:a.mode,sourceSandboxId:t,teamId:d,projectId:s}),m=await e.createSchedule(u);c.push({id:m.schedule.id,name:m.schedule.name,enabled:m.schedule.enabled,scheduleType:m.schedule.scheduleType,scheduleExpression:m.schedule.scheduleExpression,syncStatus:m.schedule.syncStatus,awsScheduleArn:m.schedule.awsScheduleArn??null,target:m.schedule.target})}return c}i(q,"createSandboxTemplateStartSchedules");function Ie(e,t){let n=t.enableSchedules??t.enableSchedule,r=t.disableSchedules??t.disableSchedule;if(n!==void 0&&r!==void 0)throw new Error("pass only one of --enable-schedules or --disable-schedules");let a=null,o;if(n!==void 0)a="enabled",o=n;else if(r!==void 0)a="disabled",o=r;else if(t.schedules!==void 0){o=t.schedules;let c=typeof t.scheduleMode=="string"?t.scheduleMode.trim().toLowerCase():"disabled";if(c==="none")return null;if(c!=="enabled"&&c!=="disabled")throw new Error("--schedule-mode must be enabled, disabled, or none");a=c}if(!a)return null;if(e.schedules.length===0)return{mode:a,schedules:[]};let s=ke(o,e),d=s===null?e.schedules:e.schedules.filter(c=>s.has(c.name));return{mode:a,schedules:d}}i(Ie,"resolveSandboxTemplateStartScheduleSelection");function ke(e,t){if(e===void 0||e===!0)return null;let n=String(e).trim();if(!n||n==="true"||n.toLowerCase()==="all")return null;if(n.toLowerCase()==="none")return new Set;let r=new Set(t.schedules.map(o=>o.name)),a=new Set(n.split(",").map(o=>o.trim()).filter(Boolean));for(let o of a)if(!r.has(o))throw new Error(`manifest schedule not found: ${o}`);return a}i(ke,"parseSandboxTemplateScheduleNameSelection");function Oe(e,t){let n=typeof t.scheduleOverrides=="string"?t.scheduleOverrides:typeof t.scheduleOverride=="string"?t.scheduleOverride:"";if(!n.trim())return new Map;let r=M(n,"schedule-overrides");if(!r||typeof r!="object"||Array.isArray(r))throw new Error("schedule-overrides must be a JSON object keyed by schedule name");let a=new Set(e.schedules.map(s=>s.name)),o=new Map;for(let[s,d]of Object.entries(r)){if(!a.has(s))throw new Error(`schedule override target does not exist: ${s}`);if(!d||typeof d!="object"||Array.isArray(d))throw new Error(`schedule override for ${s} must be an object`);o.set(s,d)}return o}i(Oe,"parseSandboxTemplateScheduleOverrides");function Ce(e){let t=Me(e.schedule,e.override),n=Ne(t);return{sourceSandboxId:e.sourceSandboxId,...e.teamId?{teamId:e.teamId}:{},...e.projectId?{projectId:e.projectId}:{},name:t.name,...t.description?{description:t.description}:{},...n,...t.timezone?{timezone:t.timezone}:{},enabled:typeof e.override?.enabled=="boolean"?e.override.enabled:e.mode==="enabled",...t.startAt?{startAt:t.startAt}:{},...t.endAt?{endAt:t.endAt}:{},...t.maxRuns!==void 0?{maxRuns:t.maxRuns}:{},runtimePolicy:t.runtimePolicy,target:Ae(e.manifest,t),...t.budget?{budget:t.budget}:{},...t.resources?{resources:t.resources}:{},...t.quotas?{quotas:t.quotas}:{},...t.lifecycle?{lifecycle:t.lifecycle}:{},...t.retentionPolicy?{retentionPolicy:t.retentionPolicy}:{},...t.env?{env:t.env}:{},...t.integrationLeases?{integrationLeases:t.integrationLeases}:{},metadata:{...t.metadata??{},manifestScheduleName:t.name,source:"openpond-code-sandbox-template-start"},managementSource:"openpond.yaml",manifestPath:f}}i(Ce,"buildSandboxTemplateStartScheduleInput");function Me(e,t){return t?{...e,...t,target:e.target||t.target?{...e.target??{},...t.target??{}}:void 0,metadata:e.metadata||t.metadata?{...e.metadata??{},...t.metadata??{}}:void 0}:e}i(Me,"mergeSandboxTemplateScheduleOverride");function Ne(e){return e.scheduleExpression?{scheduleType:e.scheduleType??"cron",scheduleExpression:e.scheduleExpression}:e.rate?{scheduleType:"rate",scheduleExpression:/^rate\(/i.test(e.rate)?e.rate:`rate(${e.rate})`}:e.once?{scheduleType:"once",scheduleExpression:/^at\(/i.test(e.once)?e.once:`at(${e.once})`}:{scheduleType:"cron",scheduleExpression:e.cron??""}}i(Ne,"sandboxTemplateScheduleExpression");function Ae(e,t){let n=t.command??t.target?.command??null;if(n)return{kind:"command",command:n,requiresStart:t.requiresStart??t.target?.requiresStart??!1};let r=t.target?.kind??"action";if(r==="start")return{kind:"command",command:e.start.command,requiresStart:t.requiresStart??t.target?.requiresStart??e.start.requiresStart??!1};if(r==="service"){let s=t.target?.name??"",d=e.services.find(c=>c.name===s);if(!d)throw new Error(`schedule service target does not exist: ${s}`);return{kind:"command",command:d.command,requiresStart:t.requiresStart??t.target?.requiresStart??d.requiresStart??!1}}let a=t.actionName??t.action??t.target?.actionName??(t.target?.kind==="action"?t.target?.name:void 0),o=e.actions.find(s=>s.name===a);if(!o)throw new Error(`schedule action target does not exist: ${a??""}`);return{kind:"command",command:o.command,requiresStart:t.requiresStart??t.target?.requiresStart??o.requiresStart??!1}}i(Ae,"sandboxTemplateScheduleCommandTarget");import{existsSync as Ge}from"node:fs";import We from"node:path";import{stdin as Ke}from"node:process";async function D(e,t,n){let r=typeof t.repo=="string"?t.repo.trim():"";if(r)return A(r);await $e(n);let a=await ae(),o=ue(a),s=pe(a),d=await oe(a,o),c=await Se(n,"origin");if(!c){let l=typeof t.teamId=="string"?t.teamId.trim():"",u=await se(s,d,{name:e.name,description:e.description,repoInit:"empty",...l?{teamId:l}:{}});c=ie(u);let m=await g("git",["remote","add","origin",c],{cwd:n});if(m.code!==0)throw new Error(`git remote add failed: ${m.stderr.trim()||m.stdout.trim()||"unknown error"}`)}if(le(c),await Fe(n,t),!h(t.noPush)){let l=await je(n,t);await Be(n,c,l,d,t)}return A(c)}i(D,"resolveSandboxTemplateStartRepo");async function $e(e){let t=We.join(e,".git");if(Ge(t))return;let n=await g("git",["init"],{cwd:e});if(n.code!==0)throw new Error(`git init failed: ${n.stderr.trim()||n.stdout.trim()||"unknown error"}`)}i($e,"ensureGitRepository");async function Fe(e,t){let n=await g("git",["status","--porcelain"],{cwd:e});if(n.code!==0)throw new Error(`git status failed: ${n.stderr.trim()||n.stdout.trim()||"unknown error"}`);let a=(await g("git",["rev-parse","--verify","HEAD"],{cwd:e})).code===0,o=n.stdout.trim().length>0;if(!o&&a)return;if(!(h(t.commit)||h(t.yes)||(Ke.isTTY?await me(a?"Commit local changes before starting the sandbox?":"Create the initial git commit before starting the sandbox?",!a):!1))){if(!a)throw new Error("local repository has no commits; pass --commit or commit before starting");o&&console.warn("warning: uncommitted local changes will not be included in the sandbox");return}let d=await g("git",["add","-A"],{cwd:e});if(d.code!==0)throw new Error(`git add failed: ${d.stderr.trim()||d.stdout.trim()||"unknown error"}`);let c=typeof t.commitMessage=="string"&&t.commitMessage.trim()?t.commitMessage.trim():`start ${f} sandbox`,l=await g("git",["commit","-m",c],{cwd:e});if(l.code!==0){let u=l.stderr.trim()||l.stdout.trim();if(u.includes("nothing to commit")&&a)return;throw new Error(`git commit failed: ${u||"unknown error"}`)}}i(Fe,"ensureGitCommitForSandboxTemplateStart");async function je(e,t){let r=(typeof t.branch=="string"?t.branch.trim():"")||await he(e);if(!r)throw new Error("unable to resolve git branch; pass --branch");return r}i(je,"resolveSandboxTemplateStartBranch");async function Be(e,t,n,r,a){let o;try{o=de(t,r)}catch{throw new Error("origin remote must be https for tokenized pushes")}let s=h(a.keepTokenRemote)||h(a.token)||h(a.setRemoteToken),d=t.includes("x-access-token:"),c=!s&&!d?t:null,l=process.env.GIT_TERMINAL_PROMPT;process.env.GIT_TERMINAL_PROMPT="0";try{if(!d){let m=await g("git",["remote","set-url","origin",o],{cwd:e});if(m.code!==0)throw new Error(`git remote set-url failed: ${ce(m.stderr.trim()||m.stdout.trim()||"unknown error")}`)}if((await g("git",["push","-u","origin",n],{cwd:e,inherit:!0})).code!==0)throw new Error("git push failed")}finally{c&&await g("git",["remote","set-url","origin",c],{cwd:e}).catch(()=>null),l===void 0?delete process.env.GIT_TERMINAL_PROMPT:process.env.GIT_TERMINAL_PROMPT=l}}i(Be,"pushGitBranchForSandboxTemplateStart");function $(e){return A(e).replace(/\.git$/,"")}i($,"normalizeSandboxTemplateRepoIdentity");function A(e){let t=new URL(e);t.username="",t.password="";let n=t.toString();return n.endsWith(".git")?n:`${n.replace(/\/$/,"")}.git`}i(A,"normalizeSandboxTemplateRepoUrl");async function _e(e){let t=L(e),n=S.dirname(t),r=await j.readFile(t,"utf8"),a=O(r);if(!a.ok){console.error(C(a.diagnostics)),process.exitCode=1;return}let o=a.manifest,s=G(o,e),d=await B(o,e,n),c=await D(o,e,n),l=await N(e),u=Ye(o,e,c),m=await Qe(l,u,c);await tt(l,m.id);let p=await ut(l,m.id,o,e),x=await V(l,m.id,d.uploadRequests),T={...d.scalars,..._(x,d.uploadRequests)},I=await X(l,m.id,s,T,bt(m)),k=await St(l,m.id,s.ports),E=await q(l,m.id,o,e);console.log(JSON.stringify({ok:!0,file:t,repo:c,executable:{kind:s.kind,name:s.name,command:s.command},sandbox:Re(m),setupCommands:p,uploadedFiles:x,input:T,execution:I,previews:k,schedules:E,expectedArtifacts:s.artifactPaths},null,2))}i(_e,"runSandboxTemplateStart");function G(e,t){let n=v(e),r=typeof t.action=="string"?t.action.trim():"",a=typeof t.service=="string"?t.service.trim():"",o=typeof t.target=="string"?t.target.trim():"",s=typeof t.entrypoint=="string"?t.entrypoint.trim():"",d=r||a||o||s||"start",c=r?"action":a?"service":"",l=n.find(u=>u.name===d&&(!c||u.kind===c));if(!l)throw new Error(`manifest executable not found: ${d}. Available: ${n.map(u=>`${u.kind}:${u.name}`).join(", ")}`);return l}i(G,"resolveSandboxTemplateStartExecutable");function Ye(e,t,n){let r=typeof t.budgetUsd=="string"&&t.budgetUsd.trim()?t.budgetUsd.trim():typeof t.budget=="string"&&t.budget.trim()?t.budget.trim():"0.05",a=R(t.maxDurationSeconds,"max-duration-seconds"),o=R(t.idleTimeoutSeconds,"idle-timeout-seconds"),s=typeof t.teamId=="string"?t.teamId.trim():"",d=typeof t.projectId=="string"?t.projectId.trim():"",c=typeof t.runtimeProjectId=="string"?t.runtimeProjectId.trim():"";if(d&&c&&d!==c)throw new Error("project-id and runtime-project-id must match when both are set");let l=d||c,u=typeof t.agentId=="string"?t.agentId.trim():"",m=typeof t.runtimeAgentId=="string"?t.runtimeAgentId.trim():"";if(u&&m&&u!==m)throw new Error("agent-id and runtime-agent-id must match when both are set");let p=u||m,x=fe(t.workflowMode),T=be(t.runtimePromotionPolicy),I=typeof t.runtimeBaseBranch=="string"&&t.runtimeBaseBranch.trim()?t.runtimeBaseBranch.trim():"",k=typeof t.runtimeBaseSha=="string"&&t.runtimeBaseSha.trim()?t.runtimeBaseSha.trim():"",E=typeof t.runtimeId=="string"&&t.runtimeId.trim()?t.runtimeId.trim():"",te=!!(x||T||I||k||E||c||m),ne=xe(e,t),re=Xe(e);return{sandbox:{repo:n,...s?{teamId:s}:{},...l?{projectId:l}:{},...p?{agentId:p}:{},resources:e.resources??{},networkPolicy:{internetEgress:He(e.network.egress)},budget:{maxUsd:r},quotas:{maxSpendUsd:r,...a!==void 0?{maxDurationSeconds:a}:{},...o!==void 0?{idleTimeoutSeconds:o}:{}},...ne.length>0?{env:ne}:{},...re?{workloadSource:re}:{},volumes:e.volumes,metadata:{source:"openpond-code-sandbox-template-start",manifestFile:f,template:{name:e.name,version:e.version,useCase:e.useCase}}},...te&&E?{runtimeId:E}:{},...te&&!E?{sandboxRuntime:{...s?{teamId:s}:{},...x?{workflowMode:x}:{},...l?{projectId:l}:{},...p?{agentId:p}:{},baseBranch:I||"master",...k?{baseSha:k}:{},...T?{promotionPolicy:T}:{}}}:{}}}i(Ye,"buildSandboxTemplateStartCreateInput");function Xe(e){if(e.runtime.image)return{image:e.runtime.image};if(e.runtime.dockerfile)return{dockerfile:e.runtime.dockerfile}}i(Xe,"sandboxWorkloadSourceFromManifest");function He(e){return e==="allow"?"allow":"block"}i(He,"sandboxTemplateInternetEgressPolicy");async function Qe(e,t,n){let r=Date.now();try{return(await Ee(e,t)).sandbox}catch(a){if(!Ze(a))throw a;return console.warn("warning: sandbox create timed out; checking for the created sandbox record"),et(e,t.sandbox,n,r)}}i(Qe,"createSandboxTemplateStartSandbox");function Ze(e){return e instanceof Error&&/\b(504|timed out|timeout)\b/i.test(e.message)}i(Ze,"isLikelySandboxCreateTimeout");async function et(e,t,n,r){let s=Date.now()+72e4,d=$(n),c=t.metadata??{};for(;Date.now()<s;){let u=(await e.list({...t.teamId?{teamId:t.teamId}:{},...t.projectId?{projectId:t.projectId}:{},...t.agentId?{agentId:t.agentId}:{}})).filter(m=>{if(!m.repo||$(m.repo)!==d)return!1;let p=Date.parse(m.createdAt);return!(Number.isFinite(p)&&p<r-3e4||c.source&&m.metadata?.source!==c.source)}).sort((m,p)=>Date.parse(p.createdAt)-Date.parse(m.createdAt))[0];if(u?.state==="running"||u?.state==="stopped")return u;if(u?.state==="error")throw new Error(`sandbox create failed after timeout: ${u.id}
3
3
  ${u.logs.join(`
4
4
  `)}`);await W(3e3)}throw new Error("sandbox create timed out and no matching created sandbox reached running state")}i(et,"recoverTimedOutSandboxCreate");async function tt(e,t){let a=Date.now()+12e4,o=null;for(;Date.now()<a;){try{let s=await e.exec(t,{command:"true",timeoutSeconds:30});if(s.command.status==="succeeded"&&s.command.exitCode===0)return;o=new Error(`readiness command ${s.command.status} with exit code ${String(s.command.exitCode)}`)}catch(s){if(o=s,!nt(s))throw s}await W(3e3)}throw new Error(`sandbox runner was not ready after create: ${rt(o)}`)}i(tt,"waitForSandboxTemplateRunnerReady");function nt(e){return e instanceof Error&&/\b(502|503|504|timed out|timeout|sandbox_not_found|sandbox_not_ready|sandbox_runner_failed)\b/i.test(e.message)}i(nt,"isRetryableSandboxRunnerReadyError");function rt(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown error"}i(rt,"formatUnknownError");function W(e){return new Promise(t=>setTimeout(t,e))}i(W,"sleep");async function B(e,t,n){let r=at(t),a=st(e),o=[],s=ot(t);for(let[c,l]of Object.entries(s)){let u=a.get(c);if(!u)throw new Error(`${c} is not declared as a file upload input in ${f}`);let m=await dt(l,n);if(!u.multiple&&m.length>1)throw new Error(`${c} accepts one file, got ${m.length}`);o.push({inputName:c,localPaths:m,spec:u})}let d=Array.isArray(e.inputs.schema.required)?e.inputs.schema.required.filter(c=>typeof c=="string"):[];for(let c of d)if(a.has(c)&&!o.some(l=>l.inputName===c))throw new Error(`${c} is required; pass --input-file ${c}=<path> or --input-files ${c}=<glob>`);return{scalars:r,uploadRequests:o}}i(B,"resolveSandboxTemplateStartInput");function at(e){let t=typeof e.inputs=="string"?e.inputs:typeof e.inputJson=="string"?e.inputJson:typeof e.params=="string"?e.params:"",n=t?M(t,"inputs"):{};if(!n||typeof n!="object"||Array.isArray(n))throw new Error("inputs must be a JSON object");let r=typeof e.input=="string"?e.input.trim():"";if(r){let[a,o]=J(r,"input");n[a]=o}return n}i(at,"parseSandboxTemplateScalarInputs");function ot(e){let t={},n=typeof e.inputFile=="string"?e.inputFile.trim():"";if(n){let[a,o]=J(n,"input-file");t[a]=o}let r=typeof e.inputFiles=="string"?e.inputFiles.trim():"";if(r){let[a,o]=J(r,"input-files");t[a]=o}return t}i(ot,"parseSandboxTemplateFileInputOptions");function J(e,t){let n=e.indexOf("=");if(n<=0)throw new Error(`${t} must be formatted as name=value`);let r=e.slice(0,n).trim(),a=e.slice(n+1).trim();if(!r||!a)throw new Error(`${t} must be formatted as name=value`);return[r,a]}i(J,"parseKeyValueOption");function st(e){let t=F(e.inputs.schema.properties)??{},n=new Map;for(let[r,a]of Object.entries(t)){let o=F(a);if(!o)continue;let s=F(o["x-openpond-upload"]??o.xOpenPondUpload);if(!s)continue;let d=typeof s.targetPath=="string"&&s.targetPath.trim()?it(s.targetPath):"";if(!d)throw new Error(`${r} upload metadata is missing targetPath`);let c=s.multiple===!0||o.type==="array"||F(o.items)?.format==="file";n.set(r,{inputName:r,multiple:c,targetPath:d})}return n}i(st,"collectSandboxTemplateUploadSpecs");function F(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}i(F,"asPlainRecord");function it(e){let t=e.trim().replace(/\\/g,"/").replace(/^\/workspace\//,"").replace(/^\.\//,"").replace(/^\/+/,"");if(!t||t.split("/").some(n=>n===".."||n===""))throw new Error(`invalid upload target path: ${e}`);if(t.split("/").some(K))throw new Error("sandbox template uploads cannot target .env* files; create sandbox secrets and pass refs with --env-ref");return t}i(it,"normalizeSandboxUploadTargetPath");async function dt(e,t){let n=e.split(",").map(a=>a.trim()).filter(Boolean),r=(await Promise.all(n.map(a=>ct(a,t)))).flat();if(r.length===0)throw new Error(`no files matched ${e}`);return r}i(dt,"expandSandboxTemplateUploadPaths");async function ct(e,t){let n=S.resolve(t,e);if(!e.includes("*")){if(lt(n),!(await j.stat(n)).isFile())throw new Error(`upload path is not a file: ${n}`);return[n]}let r=S.dirname(n),a=S.basename(n),o=mt(a),d=(await j.readdir(r,{withFileTypes:!0})).filter(l=>l.isFile()&&o.test(l.name)).sort((l,u)=>l.name.localeCompare(u.name));if(d.find(l=>K(l.name)))throw new Error("sandbox template uploads cannot include .env* files; create sandbox secrets and pass refs with --env-ref");return d.map(l=>S.join(r,l.name)).sort((l,u)=>l.localeCompare(u))}i(ct,"expandSandboxTemplateUploadPath");function lt(e){if(K(S.basename(e)))throw new Error("sandbox template uploads cannot include .env* files; create sandbox secrets and pass refs with --env-ref")}i(lt,"assertSandboxTemplateUploadPathAllowed");function K(e){return e===".env"||e.startsWith(".env.")}i(K,"isSandboxEnvFileName");function mt(e){let t=e.split("*").map(n=>n.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`)}i(mt,"globBasenameToRegExp");async function ut(e,t,n,r){let a=R(r.setupTimeoutSeconds,"setup-timeout-seconds")??900,o=[];for(let s of n.setup.commands){let d=await pt(e,t,s,a);if(o.push({command:s,status:d.status,exitCode:d.exitCode}),d.status!=="succeeded"||d.exitCode!==0)throw new Error(`setup command failed: ${s}
5
5
  ${d.output}`)}return o}i(ut,"runSandboxTemplateSetupCommands");async function V(e,t,n){let r=[];for(let a of n)for(let o of a.localPaths){let s=await j.readFile(o),d=Y(a.spec.targetPath,S.basename(o));await e.uploadFileBase64(t,d,s.toString("base64")),r.push({inputName:a.inputName,localPath:o,sandboxPath:d,sizeBytes:s.byteLength})}return r}i(V,"uploadSandboxTemplateStartFiles");function Y(e,t){return`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`}i(Y,"joinSandboxUploadPath");function _(e,t){let n={};for(let r of t){let a=e.filter(o=>o.inputName===r.inputName).map(o=>o.sandboxPath);n[r.inputName]=r.spec.multiple?a:a[0]??""}return n}i(_,"formatUploadedFileParams");async function X(e,t,n,r,a={}){await ft(e,t,r);let o=xt(n,a),s=n.timeoutSeconds;if(n.kind==="service")return{kind:"service",process:(await e.startProcess(t,{command:o,...s!==void 0?{timeoutSeconds:s}:{}})).process};let d=await Le(e,t,o,s??900);if(d.status!=="succeeded"||d.exitCode!==0)throw new Error(`template command failed: ${n.name}
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
3
- import{p as vt,q as St}from"./chunk-DLZP22WV.js";import"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import{O as yt}from"./chunk-XDMUD4FW.js";import{D as pe,E as ht,G as me}from"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import{C as He,D as ee,F as pt,H as mt,K as ft,N as gt}from"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import{f as dt,h as ct}from"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{createInterface as oo}from"node:readline/promises";import{stdin as Fe,stdout as k}from"node:process";import{pathToFileURL as io}from"node:url";function ge(){return{text:"",cursor:0,history:[],historyIndex:null}}i(ge,"createComposer");function wt(e,t){let r=e.text.slice(0,e.cursor),n=e.text.slice(e.cursor);return{...e,text:`${r}${t}${n}`,cursor:e.cursor+t.length,historyIndex:null}}i(wt,"insertText");function fe(e,t){return{...e,text:t,cursor:t.length}}i(fe,"replaceComposerText");function Rr(e){let t=e.text.trim();return t?{state:{text:"",cursor:0,history:[...e.history.filter(r=>r!==t),t].slice(-100),historyIndex:null},action:{type:"submit",text:t}}:{state:{...e,text:"",cursor:0,historyIndex:null},action:{type:"none"}}}i(Rr,"submitComposer");function Tt(e,t){if(t==="ctrl+c")return{state:e,action:{type:"cancel-or-exit"}};if(t==="ctrl+d")return{state:e,action:e.text?{type:"none"}:{type:"exit"}};if(t==="ctrl+l")return{state:e,action:{type:"rerender"}};if(t==="enter")return Rr(e);if(t==="alt+enter")return{state:wt(e,`
3
+ import{p as vt,q as St}from"./chunk-FPUUZQUP.js";import"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import{O as yt}from"./chunk-2JO2KWT3.js";import{D as pe,E as ht,G as me}from"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import{C as He,D as ee,F as pt,H as mt,K as ft,N as gt}from"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import{f as dt,h as ct}from"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{createInterface as oo}from"node:readline/promises";import{stdin as Fe,stdout as k}from"node:process";import{pathToFileURL as io}from"node:url";function ge(){return{text:"",cursor:0,history:[],historyIndex:null}}i(ge,"createComposer");function wt(e,t){let r=e.text.slice(0,e.cursor),n=e.text.slice(e.cursor);return{...e,text:`${r}${t}${n}`,cursor:e.cursor+t.length,historyIndex:null}}i(wt,"insertText");function fe(e,t){return{...e,text:t,cursor:t.length}}i(fe,"replaceComposerText");function Rr(e){let t=e.text.trim();return t?{state:{text:"",cursor:0,history:[...e.history.filter(r=>r!==t),t].slice(-100),historyIndex:null},action:{type:"submit",text:t}}:{state:{...e,text:"",cursor:0,historyIndex:null},action:{type:"none"}}}i(Rr,"submitComposer");function Tt(e,t){if(t==="ctrl+c")return{state:e,action:{type:"cancel-or-exit"}};if(t==="ctrl+d")return{state:e,action:e.text?{type:"none"}:{type:"exit"}};if(t==="ctrl+l")return{state:e,action:{type:"rerender"}};if(t==="enter")return Rr(e);if(t==="alt+enter")return{state:wt(e,`
4
4
  `),action:{type:"none"}};if(t==="backspace")return e.cursor<=0?{state:e,action:{type:"none"}}:{state:{...e,text:`${e.text.slice(0,e.cursor-1)}${e.text.slice(e.cursor)}`,cursor:e.cursor-1},action:{type:"none"}};if(t==="delete")return e.cursor>=e.text.length?{state:e,action:{type:"none"}}:{state:{...e,text:`${e.text.slice(0,e.cursor)}${e.text.slice(e.cursor+1)}`},action:{type:"none"}};if(t==="left")return{state:{...e,cursor:Math.max(0,e.cursor-1)},action:{type:"none"}};if(t==="right")return{state:{...e,cursor:Math.min(e.text.length,e.cursor+1)},action:{type:"none"}};if(t==="home"||t==="ctrl+a")return{state:{...e,cursor:0},action:{type:"none"}};if(t==="end"||t==="ctrl+e")return{state:{...e,cursor:e.text.length},action:{type:"none"}};if(t==="ctrl+u")return{state:{...e,text:e.text.slice(e.cursor),cursor:0},action:{type:"none"}};if(t==="ctrl+k")return{state:{...e,text:e.text.slice(0,e.cursor)},action:{type:"none"}};if(t==="up"){if(e.history.length===0)return{state:e,action:{type:"none"}};let r=e.historyIndex===null?e.history.length-1:Math.max(0,e.historyIndex-1);return{state:fe({...e,historyIndex:r},e.history[r]??""),action:{type:"none"}}}if(t==="down"){if(e.historyIndex===null)return{state:e,action:{type:"none"}};let r=e.historyIndex+1;return r>=e.history.length?{state:{...e,text:"",cursor:0,historyIndex:null},action:{type:"none"}}:{state:fe({...e,historyIndex:r},e.history[r]??""),action:{type:"none"}}}return t.length>0?{state:wt(e,t),action:{type:"none"}}:{state:e,action:{type:"none"}}}i(Tt,"handleComposerKey");var bt="A turn is already running. Wait for it to finish before sending another line.";function Mr(){let e=!1;return{isRunning(){return e},tryStartSubmission(){return e?!1:(e=!0,!0)},failSubmission(){e=!1},applyRuntimeEvent(t){t.name==="turn.started"&&(e=!0),(t.name==="turn.completed"||t.name==="turn.failed"||t.name==="turn.interrupted")&&(e=!1)}}}i(Mr,"createTerminalTurnSubmissionGuard");function Pt(){return Mr()}i(Pt,"createLineModeTurnGuard");var he=[{name:"help",usage:"/help",description:"show this help"},{name:"providers",usage:"/providers",description:"list providers"},{name:"provider",usage:"/provider [id]",description:"switch provider",requiresArgument:!0},{name:"model",usage:"/model [id]",description:"list or switch model"},{name:"apps",usage:"/apps",description:"list connectable apps"},{name:"install",usage:"/install <app>",description:"open app details",requiresArgument:!0},{name:"projects",usage:"/projects",description:"list projects"},{name:"project",usage:"/project <id>",description:"switch project",requiresArgument:!0},{name:"permissions",usage:"/permissions [ask|full-access]",description:"show or change command access"},{name:"profile",usage:"/profile [status|diff|catalog|check|push]",description:"show or sync profile"},{name:"agents",usage:"/agents",description:"list agents"},{name:"agent",usage:"/agent <id>",description:"select agent",requiresArgument:!0},{name:"run",usage:"/run <action> [json]",description:"run profile action",requiresArgument:!0},{name:"settings",usage:"/settings",description:"show settings"},{name:"logs",usage:"/logs",description:"show recent events"},{name:"compact",usage:"/compact",description:"compact current session"},{name:"clear",usage:"/clear",description:"clear terminal transcript"},{name:"exit",usage:"/exit",description:"exit"},{name:"hooks",usage:"/hooks",description:"show hook status"},{name:"start",usage:"/start",description:"start a new session"}];function ze(e){if(!e.startsWith("/"))return null;let[t="",...r]=e.slice(1).trim().split(/\s+/),n=t.toLowerCase();if(!n)return null;if(n==="exit"||n==="quit")return{type:"exit"};if(n==="help")return{type:"help"};if(n==="clear")return{type:"clear"};if(n==="agents")return{type:"agents"};if(n==="apps")return{type:"apps"};if(n==="agent")return{type:"agent",id:r.join(" ").trim()};if(n==="install")return{type:"install",id:r.join(" ").trim()};if(n==="projects")return{type:"projects"};if(n==="project")return{type:"project",id:r.join(" ").trim()};if(n==="model")return{type:"model",id:r.join(" ").trim()||null};if(n==="permissions")return{type:"permissions",args:r};if(n==="profile")return{type:"profile",args:r};if(n==="logs")return{type:"logs"};if(n==="providers")return{type:"providers"};if(n==="provider")return{type:"provider",id:r.join(" ").trim()||null};if(n==="compact")return{type:"compact"};if(n==="hooks")return{type:"hooks"};if(n==="start")return{type:"start"};if(n==="run"){let o=r[0]??"",s=r.slice(1).join(" ").trim();return s?{type:"run",action:o,input:JSON.parse(s)}:{type:"run",action:o,input:void 0}}return n==="settings"?{type:"settings",args:r}:{type:"unknown",command:n}}i(ze,"parseSlashCommand");function xt(e){let t=e.trim();if(!t.startsWith("!"))return null;let r=t.slice(1).trim();return r?{command:r}:null}i(xt,"parseDirectCommandPrompt");function Ct(){let e=Math.max(...he.map(t=>t.usage.length));return["Commands:",...he.map(t=>`${t.usage.padEnd(e+2)}${t.description}`)].join(`
5
5
  `)}i(Ct,"helpText");var ye=class{static{i(this,"RawInput")}input;onKey;previousRawMode=!1;dataHandler=null;constructor(t,r){this.input=t,this.onKey=r}start(){this.previousRawMode=this.input.isRaw??!1,this.input.setRawMode(!0),this.input.resume(),this.dataHandler=t=>{for(let r of Or(t))this.onKey(r)},this.input.on("data",this.dataHandler)}stop(){this.dataHandler&&this.input.off("data",this.dataHandler),this.dataHandler=null,this.input.setRawMode(this.previousRawMode),this.input.pause()}};function Or(e){let t=e.toString("utf8"),r=[];for(let n=0;n<t.length;n+=1){let o=t[n],s=t[n+1];if(o==="\x1B"){let a=jr(t,n);r.push(a.key),n=a.end;continue}o===""?r.push("ctrl+c"):o===""?r.push("ctrl+d"):o==="\f"?r.push("ctrl+l"):o===""?r.push("ctrl+a"):o===""?r.push("ctrl+e"):o==="\v"?r.push("ctrl+k"):o===""?r.push("ctrl+u"):o==="\x7F"||o==="\b"?r.push("backspace"):o==="\r"||o===`
6
6
  `?r.push("enter"):(o>=" "||o&&s)&&r.push(o)}return r}i(Or,"decodeKeys");function jr(e,t){let r=e.slice(t);return r.startsWith("\x1B\r")||r.startsWith(`\x1B