openpond 0.2.65 → 0.2.66
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.
- package/dist/app-server.js +1 -1
- package/dist/chunks/{acp-PHMBLRCV.js → acp-YYZ3ZO3Q.js} +1 -1
- package/dist/chunks/{acp-agent-A7GK2VSH.js → acp-agent-T26S7TU2.js} +1 -1
- package/dist/chunks/{app-layer-J66CQ2QN.js → app-layer-5XUMNHDO.js} +1 -1
- package/dist/chunks/{app-server-runtime-OMR2VE6L.js → app-server-runtime-TH56EG2Z.js} +1 -1
- package/dist/chunks/{apps-IHUFERZO.js → apps-MNT3KXIY.js} +1 -1
- package/dist/chunks/chunk-2ZNW6GUU.js +2 -0
- package/dist/chunks/{chunk-E2S2EMYQ.js → chunk-BQVB2SPF.js} +5 -5
- package/dist/chunks/{chunk-UM6EQOT2.js → chunk-JKI53ED7.js} +1 -1
- package/dist/chunks/{chunk-FGOTSCSE.js → chunk-NABPZ7AK.js} +1 -1
- package/dist/chunks/{chunk-KGUPAPGR.js → chunk-PLVWARB7.js} +1 -1
- package/dist/chunks/chunk-SBQ6KLXB.js +33 -0
- package/dist/chunks/{chunk-N2AV7PHV.js → chunk-UXPO3ZV7.js} +2 -2
- package/dist/chunks/{command-NDHFZAKA.js → command-NW6BGKOM.js} +3 -3
- package/dist/chunks/{configuration-command-465ODYTC.js → configuration-command-4WTS2MZS.js} +1 -1
- package/dist/chunks/{connected-evidence-XPAZQRFQ.js → connected-evidence-D7C45HYD.js} +1 -1
- package/dist/chunks/{connected-starting-assets-2YX3QVDB.js → connected-starting-assets-4LDXQVLN.js} +1 -1
- package/dist/chunks/{core-commands-PJOGRBHJ.js → core-commands-RXPXOYOP.js} +1 -1
- package/dist/chunks/{datasets-OTE2I4VT.js → datasets-LBLEKLCS.js} +1 -1
- package/dist/chunks/{desktop-test-Q6REQJ7K.js → desktop-test-INJPZ5VP.js} +1 -1
- package/dist/chunks/{evaluation-coordination-KRCY2H4C.js → evaluation-coordination-3ARLJAFH.js} +1 -1
- package/dist/chunks/{experiment-improvements-7MI2VYBR.js → experiment-improvements-UB4C5CSP.js} +1 -1
- package/dist/chunks/{experiments-CNUQKJZE.js → experiments-AHHKFJD6.js} +1 -1
- package/dist/chunks/{experiments-signal-4N344D4Y.js → experiments-signal-MTR475QV.js} +1 -1
- package/dist/chunks/{help-ZUKVY6RO.js → help-JQA3YMCX.js} +1 -1
- package/dist/chunks/{hosted-app-server-composition-DWSU6ASL.js → hosted-app-server-composition-GPXH3BOG.js} +1 -1
- package/dist/chunks/{human-review-HOBGC6RC.js → human-review-DVHVJXBA.js} +1 -1
- package/dist/chunks/{import-Q3YRFVY7.js → import-CLWTKDG6.js} +1 -1
- package/dist/chunks/{opchat-2LLDIWEJ.js → opchat-LMKH3OWR.js} +1 -1
- package/dist/chunks/{opchat-bounded-chat-FLDS36LU.js → opchat-bounded-chat-PPOWO7H4.js} +1 -1
- package/dist/chunks/{organizations-VIFSOY6P.js → organizations-T6ZUSHNJ.js} +1 -1
- package/dist/chunks/{profile-KIHMW2WB.js → profile-RIDNU2I5.js} +1 -1
- package/dist/chunks/{project-agent-TJLQNMLA.js → project-agent-GBMVDJY3.js} +1 -1
- package/dist/chunks/{sandbox-command-CQO6BEMQ.js → sandbox-command-L5VQ2T6C.js} +1 -1
- package/dist/chunks/{sandbox-template-MU33IILL.js → sandbox-template-NN3XQI7M.js} +1 -1
- package/dist/chunks/{setup-HSRCZ3WR.js → setup-TXEM2QSG.js} +1 -1
- package/dist/chunks/{src-CHQVWHV7.js → src-HJHIBDFX.js} +1 -1
- package/dist/chunks/{teams-bot-D3LWA4S5.js → teams-bot-FXMCOCPP.js} +1 -1
- package/dist/chunks/{tool-learning-NGO7QHYK.js → tool-learning-O7QTTEDB.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/skills/manifest.json +1 -1
- package/dist/web/assets/{App-BZuSv1XM.js → App-CNQi3RlI.js} +4 -4
- package/dist/web/assets/{AppDialog-BILEK4np.js → AppDialog-DuSd0wk6.js} +1 -1
- package/dist/web/assets/{AppTerminalPanel-BvxZ8bwD.js → AppTerminalPanel-DLz34eSs.js} +2 -2
- package/dist/web/assets/{AppToastContext-C-FsCKXW.js → AppToastContext-Dklk6CaG.js} +1 -1
- package/dist/web/assets/{AppsView-BMaq5oxx.js → AppsView-DkCMr67-.js} +1 -1
- package/dist/web/assets/{AttachmentTypeIcon-Bh7Ft_UL.js → AttachmentTypeIcon-DipNT6Tj.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-BG2MLJ9I.js → BrowserSidebar-BBaaanMS.js} +1 -1
- package/dist/web/assets/{CartesianChart-CS6ES_XT.js → CartesianChart-UU1sdoUO.js} +1 -1
- package/dist/web/assets/{ChatTimelineEntry-Dr5X_XyN.js → ChatTimelineEntry-Ct59FKw1.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-CPJ2w67F.js → CollaborationTabs-BWYRQ1PE.js} +1 -1
- package/dist/web/assets/{CommandMenu-Fe1V7NJd.js → CommandMenu-B08F9x5g.js} +1 -1
- package/dist/web/assets/{CommunityView-DHTcmOnI.js → CommunityView-BLTlSxyb.js} +1 -1
- package/dist/web/assets/{ComposerAttachments-Ck9VWD6o.js → ComposerAttachments-srWBKvCv.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-yiXO7cf8.js → ComposerCreateImproveStrip-DqTpU5cO.js} +1 -1
- package/dist/web/assets/{ConversationImportsSettings-_VLzUnHQ.js → ConversationImportsSettings-2KC-KQvu.js} +1 -1
- package/dist/web/assets/{FilePagePreview-BpcM1DfE.js → FilePagePreview-B-iUVPhh.js} +2 -2
- package/dist/web/assets/{GetStartedView-BH-WJ-rW.js → GetStartedView-5v0vBWXy.js} +1 -1
- package/dist/web/assets/{GettingStartedDialog-CdQfj7RA.js → GettingStartedDialog-Bn4072K-.js} +1 -1
- package/dist/web/assets/{HostedModelLearningReview-C3GsOlu9.js → HostedModelLearningReview-DWF6WPao.js} +1 -1
- package/dist/web/assets/{HostedModelLearningSettings-SSMst6dl.js → HostedModelLearningSettings-BYl-2j7B.js} +1 -1
- package/dist/web/assets/{HtmlVisual-CH0tb3fv.js → HtmlVisual-C2WsMj90.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-J2t9yILv.js → LabModelVersionDetailPage-CQz29DwD.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-DdDYvfj2.js → LabSkillSidebar-C50P74LI.js} +1 -1
- package/dist/web/assets/{LabsRoute-MJwIjSKg.js → LabsRoute-DJRgF1kQ.js} +6 -6
- package/dist/web/assets/{MainChatThread-BcwtaTDZ.js → MainChatThread-gwmhe1Nw.js} +2 -2
- package/dist/web/assets/{MainPane-DDO6diPt.js → MainPane-CqtgV9rU.js} +5 -5
- package/dist/web/assets/{NativeSetupTerminal-BPSUFpRm.js → NativeSetupTerminal-DrQldDsG.js} +2 -2
- package/dist/web/assets/{NativeSkillSidebar-DPYavzau.js → NativeSkillSidebar-Clv0IWyn.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-BtmvE9Sp.js → NewProjectDialog-Cw_F5Eaa.js} +1 -1
- package/dist/web/assets/{OutputsPage-BMRY7RK2.js → OutputsPage-Btyiie4B.js} +1 -1
- package/dist/web/assets/{PageChrome-5VRxH6Rp.js → PageChrome-BLLw_cEA.js} +1 -1
- package/dist/web/assets/{ProjectsPage-1LHqxOMo.js → ProjectsPage-BpSHWQgj.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-D_7KgExz.js → RightChatPanelStack-xW5rKbp0.js} +1 -1
- package/dist/web/assets/RightSidebarHomePanel-BDmIxvIm.js +1 -0
- package/dist/web/assets/{ScheduledWorkPage-Dtz4zJ0T.js → ScheduledWorkPage-WytWGQgw.js} +1 -1
- package/dist/web/assets/{SettingsView-BeDYNPcD.js → SettingsView-BJq5zNkv.js} +3 -3
- package/dist/web/assets/{TasksetDraftEditorPrimitives-CcvKO3YA.js → TasksetDraftEditorPrimitives-BxFEWI9W.js} +1 -1
- package/dist/web/assets/{TeamChatView-DaXxOkTe.js → TeamChatView-BisSMAXy.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-CF8uB4qA.js → TerminalOverlay-C7OM2F0-.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-DmMO7x5T.js → TrainingCreationPanel-KH5GFacT.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-DCHbXjSx.js → TrainingDraftPanel-DzOw13Md.js} +1 -1
- package/dist/web/assets/{TrainingRunLineage-CwisTWs_.js → TrainingRunLineage-B2WBOchk.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-Drt7gwRb.js → UsageSettingsSection-nZHno_4P.js} +1 -1
- package/dist/web/assets/WorkSidebarPanel-D3Ub_jVj.js +1 -0
- package/dist/web/assets/{WorkspaceDiffPanel-Dmbrg0-y.js → WorkspaceDiffPanel-CyTa8Cjs.js} +3 -3
- package/dist/web/assets/{WorkspaceEnvironmentMenu-KEZm1gdb.js → WorkspaceEnvironmentMenu-CtZzxQ1e.js} +1 -1
- package/dist/web/assets/{WorkspaceFileLocation-ChbOKrPO.js → WorkspaceFileLocation-1U8DDj1J.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-BS2JQKNQ.js → WorkspaceGitDialogs-BO1EUA3G.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-CN1hE_C4.js → WorkspaceMonacoEditor-Rqq_sKW_.js} +3 -3
- package/dist/web/assets/{WorkspacePdfPreview-Clb4m0le.js → WorkspacePdfPreview-zmmMp09R.js} +2 -2
- package/dist/web/assets/{WorkspacePresentationPreview-CwQsdvAR.js → WorkspacePresentationPreview-DNbhGjkE.js} +1 -1
- package/dist/web/assets/{bot-BNFltD5O.js → bot-D-eTQib6.js} +1 -1
- package/dist/web/assets/{chevron-down-BnnT0tnM.js → chevron-down-75im8nFF.js} +1 -1
- package/dist/web/assets/chevron-right-CpbCIUFo.js +1 -0
- package/dist/web/assets/{chevron-up-BAnwJJN3.js → chevron-up-BD8jg0bQ.js} +1 -1
- package/dist/web/assets/{client-choice-storage-Iuzoszas.js → client-choice-storage-CXlWJW5g.js} +1 -1
- package/dist/web/assets/{cloud-upload-CdSXJ7ms.js → cloud-upload-4lP-5zmp.js} +1 -1
- package/dist/web/assets/{copy-CBFg6m0d.js → copy-DRnATDDY.js} +1 -1
- package/dist/web/assets/{createLucideIcon-DF2VR6WA.js → createLucideIcon-CmkSm39S.js} +1 -1
- package/dist/web/assets/{cssMode-BSQUZhUO.js → cssMode-Cps-05f3.js} +1 -1
- package/dist/web/assets/{external-link-Cql9bKdv.js → external-link-D_nBEDFO.js} +1 -1
- package/dist/web/assets/{folder-open-BXdVB5J1.js → folder-open-tD5Lle1M.js} +1 -1
- package/dist/web/assets/{folder-plus-Cma2HulC.js → folder-plus-DlZ4hM48.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-eF--16ps.js → git-commit-horizontal-g8KBhvfr.js} +1 -1
- package/dist/web/assets/{htmlMode-aLPlQtyU.js → htmlMode-Do72TyNy.js} +1 -1
- package/dist/web/assets/icons-B8_Rkg-l.js +1 -0
- package/dist/web/assets/{image-CqKPwnBn.js → image-CUZMnZYi.js} +1 -1
- package/dist/web/assets/{index-CM0IRu1U.js → index-D7igQSAg.js} +2 -2
- package/dist/web/assets/{info-CqeYEqG0.js → info-SmuBZiE5.js} +1 -1
- package/dist/web/assets/{jsonMode-fu7bEcHB.js → jsonMode-B2N7W15Y.js} +1 -1
- package/dist/web/assets/loader-circle-D_KVxLLz.js +1 -0
- package/dist/web/assets/{lspLanguageFeatures-DraXQA4w.js → lspLanguageFeatures-DPmyOFVA.js} +1 -1
- package/dist/web/assets/{maximize-2-yMp8X9ts.js → maximize-2-B8HN3jsA.js} +1 -1
- package/dist/web/assets/{message-square-DbIMQqfj.js → message-square-CrDvzn66.js} +1 -1
- package/dist/web/assets/{monaco.contribution-Bd8EqYGR.js → monaco.contribution-BfOxF9PJ.js} +2 -2
- package/dist/web/assets/{monaco.contribution-BQhp1CJs.js → monaco.contribution-CRdTg0FH.js} +2 -2
- package/dist/web/assets/{monaco.contribution-CYWKnVxQ.js → monaco.contribution-DNONXznc.js} +2 -2
- package/dist/web/assets/{monaco.contribution-CmbWO0tB.js → monaco.contribution-DqqJBDzF.js} +2 -2
- package/dist/web/assets/{monitor-DFE2fTkT.js → monitor-CW-M_aaj.js} +1 -1
- package/dist/web/assets/{paperclip-D_qsKbVs.js → paperclip-DL449Io5.js} +1 -1
- package/dist/web/assets/{pdf-DkQRsi4n.js → pdf-BCq2Oosd.js} +1 -1
- package/dist/web/assets/play-DYLqBrwg.js +1 -0
- package/dist/web/assets/plus-DXZIpQuY.js +1 -0
- package/dist/web/assets/{presentation-BN_kIBPL.js → presentation-CupIXaYv.js} +1 -1
- package/dist/web/assets/{python-DB9pj5Hr.js → python-DuGMr666.js} +1 -1
- package/dist/web/assets/{refresh-cw-B27ohHfn.js → refresh-cw-CzVf5_oo.js} +1 -1
- package/dist/web/assets/{save-D-rwjKop.js → save-DatjrYPV.js} +1 -1
- package/dist/web/assets/{settings-lists-DgSaJQA4.js → settings-lists-D2ol3uNK.js} +1 -1
- package/dist/web/assets/square-BWB1nbZF.js +1 -0
- package/dist/web/assets/{square-terminal-CeoK51wH.js → square-terminal-Buj-s-fz.js} +1 -1
- package/dist/web/assets/{submit-issue-command-DZNW7Evj.js → submit-issue-command-wfngGS6Y.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-Bs8L1gx0.js → toggleHighContrast-cl0cw2QK.js} +1 -1
- package/dist/web/assets/{training-model-data-wHvE7xL1.js → training-model-data-CWnu1bz9.js} +1 -1
- package/dist/web/assets/{tsMode-C7EqshxC.js → tsMode-DLEc0PYL.js} +1 -1
- package/dist/web/assets/{upload-BWgjC2Jf.js → upload-DaFVH6R1.js} +1 -1
- package/dist/web/assets/{useAccountSettings-Dva1MpsJ.js → useAccountSettings-ByxjI9BG.js} +1 -1
- package/dist/web/assets/{useAgentInventory-CrjIOmvb.js → useAgentInventory-Df64T07n.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-P-UaUKMb.js → useLocalAgentSchedules-DNh_x9gQ.js} +1 -1
- package/dist/web/assets/{useQuery-Bn3KqR4r.js → useQuery-yUz7Ui8g.js} +1 -1
- package/dist/web/assets/{wifi-off--mKrSPFc.js → wifi-off-CtNwnIJc.js} +1 -1
- package/dist/web/assets/{workers-p0Kn2KMK.js → workers-CnqrOtic.js} +1 -1
- package/dist/web/assets/x-Bhl-4Zlt.js +1 -0
- package/dist/web/assets/{yaml-BeIdC4tu.js → yaml-C9vtYV4w.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-LOIYNRBC.js +0 -33
- package/dist/chunks/chunk-MMJU6PZV.js +0 -2
- package/dist/web/assets/RightSidebarHomePanel-iznJwDMf.js +0 -1
- package/dist/web/assets/WorkSidebarPanel-BrIIRtGW.js +0 -1
- package/dist/web/assets/chevron-right-C8K5PZj7.js +0 -1
- package/dist/web/assets/icons-c3vt7y6n.js +0 -1
- package/dist/web/assets/loader-circle-pxp89T5x.js +0 -1
- package/dist/web/assets/play-BtlX2stU.js +0 -1
- package/dist/web/assets/plus-DbASL_gy.js +0 -1
- package/dist/web/assets/square-C2caJ3NG.js +0 -1
- package/dist/web/assets/x-D9GTV9ke.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import"./chunk-T4QXKU5Y.js";import"./chunk-7P5SH3CI.js";import{c as h}from"./chunk-TGULVWPV.js";import"./chunk-
|
|
2
|
+
import"./chunk-T4QXKU5Y.js";import"./chunk-7P5SH3CI.js";import{c as h}from"./chunk-TGULVWPV.js";import"./chunk-NABPZ7AK.js";import"./chunk-BQVB2SPF.js";import"./chunk-XRKFTPHD.js";import{c as u,d as m,f as g}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{f as p}from"./chunk-3M53YXEI.js";import{a as k}from"./chunk-Q34IF4PW.js";import{a as d,c as w,d as B}from"./chunk-6XSSM4WT.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import{d as f}from"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as i}from"./chunk-FTQLQJQV.js";import{randomUUID as U}from"node:crypto";async function T(t,r){let e=r[0]||"smoke";if(e==="chat"){if(r.length!==1)throw new Error("opchat chat accepts options, not positional arguments.");await(await import("./opchat-bounded-chat-PPOWO7H4.js")).runBoundedOpChat(t);return}let o=await f(),s=await h(o,g(o)),l=C(o,t);if(e==="provider-catalog"||e==="providers-catalog"||e==="catalog"){let n=await y({apiBaseUrl:l,token:s});console.log(JSON.stringify(n,null,2));return}if(e==="models"||e==="model-list"){let n=await w({apiBaseUrl:l,token:s});console.log(JSON.stringify(n,null,2));return}if(e==="model"||e==="model-get"){let n=r[1]||a(t,"model");if(!n)throw new Error("usage: opchat model <model>");let c=await B({apiBaseUrl:l,token:s,model:n});console.log(JSON.stringify(c,null,2));return}if(e==="smoke"){let n=await k({apiBaseUrl:l,token:s,defaultModel:a(t,"model")||void 0,compatibilityModel:a(t,"compatibilityModel")||a(t,"compatModel")||void 0,skipStream:p(t.skipStream),skipTool:p(t.skipTool),log:i(c=>console.log(c),"log")});p(t.json)&&console.log(JSON.stringify(n,null,2));return}throw new Error(`usage: opchat <provider-catalog|models|model|smoke> [--opchat-api-base-url <url>]
|
|
3
3
|
opchat chat --model <id> --message <text> --team-id <id> --max-output-tokens <n> --request-id <id> --timeout-sec <1..600> --max-spend <usd> [--stream] (one bounded request; JSON receipt after completion)`)}i(T,"runOpChatCommand");async function y(t){let r=t.apiBaseUrl.trim().replace(/\/+$/,"");if(!r)throw new Error("OpChat API base URL is required.");let e=t.token.trim();if(!e)throw new Error("OpenPond API key is required.");let o=await fetch(`${r}/provider-catalog`,{method:"GET",headers:{Authorization:`Bearer ${e}`,Accept:"application/json","Content-Type":"application/json","x-openpond-client":"openpond-cli","x-openpond-request-id":U()}});if(!o.ok)throw new Error(`Hosted provider catalog failed: ${o.status} ${await A(o)}`);return o.json()}i(y,"getOpChatProviderCatalog");async function A(t){let r=await t.text().catch(()=>"");if(!r)return t.statusText||`HTTP ${t.status}`;try{let e=JSON.parse(r);if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;if(e.error&&typeof e.error=="object"&&!Array.isArray(e.error)){let o=e.error;return[o.code,o.message].filter(Boolean).join(": ")||r}return r}catch{return r}}i(A,"readResponseError");function C(t,r){let e=a(r,"opchatApiBaseUrl")||a(r,"opchatApiBaseurl")||a(r,"opChatApiBaseUrl")||a(r,"opChatApiBaseurl")||a(r,"opchatApiUrl")||a(r,"opChatApiUrl");return e?d({opChatApiBaseUrl:e}):d({apiBaseUrl:u(r)||t.apiBaseUrl,chatApiBaseUrl:m(r)||t.chatApiBaseUrl})}i(C,"resolveOpChatCliBaseUrl");function a(t,r){let e=t[r];return typeof e=="string"?e.trim():""}i(a,"optionString");export{T as runOpChatCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import"./chunk-T4QXKU5Y.js";import"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import{a as j}from"./chunk-V3KEG6MI.js";import{a as Z}from"./chunk-AZ7BL5FL.js";import"./chunk-
|
|
2
|
+
import"./chunk-T4QXKU5Y.js";import"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import{a as j}from"./chunk-V3KEG6MI.js";import{a as Z}from"./chunk-AZ7BL5FL.js";import"./chunk-NABPZ7AK.js";import"./chunk-BQVB2SPF.js";import"./chunk-XRKFTPHD.js";import{c as $,d as z}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as A,f as H}from"./chunk-3M53YXEI.js";import"./chunk-4N4EH3RJ.js";import"./chunk-ULJZ7NUF.js";import"./chunk-WJSJXK2N.js";import{a as D,d as X,i as J,j as Y}from"./chunk-6XSSM4WT.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-6FA3GG5B.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import{M as L}from"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import{A as s}from"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as p}from"./chunk-FTQLQJQV.js";import{createHash as ne}from"node:crypto";var ee=new Set(["Error","TypeError","SyntaxError","AbortError","TimeoutError","SocketError","HeadersTimeoutError","BodyTimeoutError","ConnectTimeoutError"]),te=new Set(["UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_ABORTED","UND_ERR_DESTROYED","UND_ERR_CLOSED","UND_ERR_RESPONSE_STATUS_CODE","ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","ENOTFOUND","EAI_AGAIN","ABORT_ERR"]);function K(n){let o=[],e=new Set,a=n;for(;a&&typeof a=="object"&&o.length<3&&!e.has(a);){e.add(a);let d=a;o.push({name:typeof d.name=="string"&&ee.has(d.name)?d.name:"unrecognized",code:d.code===void 0?null:typeof d.code=="string"&&te.has(d.code)?d.code:"unrecognized"}),a=d.cause}return o}p(K,"boundedTransportError");function V(){let n=null,o=null,e=null,a=null,d=null,M=null,l=0,y=0,m=0,S=0,c=0,i=0,E=null;return{observe:p(t=>{t.type==="request"&&(n=performance.now()-t.elapsedMs),t.type==="headers"&&(o=t),t.type==="bytes"&&(l=Math.max(l,t.elapsedMs-(a??o?.elapsedMs??0)),e??=t.elapsedMs,a=t.elapsedMs,y=Math.min(Number.MAX_SAFE_INTEGER,y+t.byteLength),m=Math.min(Number.MAX_SAFE_INTEGER,m+1)),t.type==="data"&&(S=Math.min(Number.MAX_SAFE_INTEGER,S+1),d=t.elapsedMs,t.errorFrame&&(i=Math.min(Number.MAX_SAFE_INTEGER,i+1))),t.type==="comment"&&(c=Math.min(Number.MAX_SAFE_INTEGER,c+1),M=t.elapsedMs),t.type==="done"&&(E=t.elapsedMs)},"observe"),snapshot:p(()=>{let t=n===null?null:Math.round(performance.now()-n);return{phase:n===null?"not_started":o?E!==null?"done":i>0?"error_frame":"response_body":"before_headers",elapsedMs:t,response:o===null?null:{status:o.status,headersAtMs:o.elapsedMs,eventStream:o.eventStream,noCache:o.noCache,noTransform:o.noTransform,bufferingDisabled:o.bufferingDisabled},bytes:y,readChunks:m,dataFrames:S,commentFrames:c,errorFrames:i,firstByteAtMs:e,lastByteAtMs:a,lastDataAtMs:d,lastCommentAtMs:M,doneAtMs:E,maxByteGapMs:l,silentForMs:t===null||o===null?null:Math.max(0,t-(a??o.elapsedMs))}},"snapshot")}}p(V,"createStreamDiagnostics");var O=s.coerce.number().int().positive().safe(),oe=s.object({model:s.string().trim().min(1).max(512),message:s.string().trim().min(1).max(131072),teamId:s.string().regex(/^[A-Za-z0-9_-]{3,191}$/),requestId:s.string().regex(/^[A-Za-z0-9._:-]{1,200}$/),maxOutputTokens:O,timeoutSec:O.max(600),maxSpend:s.coerce.number().finite().positive()}),q=s.number().finite().nonnegative(),re=s.object({id:s.string(),context_window:O,output_limit:O,metadata:s.object({billing:s.object({pricing:s.object({version:s.string().trim().min(1),source:s.string().trim().min(1),effectiveAt:s.string().refine(n=>Number.isFinite(Date.parse(n))),inputUsdPerMillionTokens:q,cachedInputUsdPerMillionTokens:q,outputUsdPerMillionTokens:q}).passthrough()})})});async function ge(n,o={}){let e=oe.parse({...n,message:A(n,"message")||A(n,"prompt")}),a=H(n.stream),d=n.effort===void 0?void 0:L.parse(n.effort),M=o.emit??(u=>console.log(JSON.stringify(u,null,2))),l=new AbortController,y=new Date().toISOString(),m=!1,S=null,c=null,i=null,E="",_=null,C=null,t=V(),x=null,B=p(u=>l.abort(new Error(`OpChat cancelled by ${u}.`)),"abort"),P=p(()=>B("SIGINT"),"interrupt"),v=p(()=>B("SIGTERM"),"terminate"),W=setTimeout(()=>l.abort(new DOMException("OpChat deadline reached.","TimeoutError")),e.timeoutSec*1e3);process.once("SIGINT",P),process.once("SIGTERM",v);let F=p((u,r)=>{let b=u==="completed"&&i&&i.estimated!==!0&&[i.prompt_tokens??i.input_tokens,i.completion_tokens??i.output_tokens].every(w=>typeof w=="number"&&Number.isSafeInteger(w)&&w>=0);return{schemaVersion:"openpond.boundedOpChatReceipt.v1",status:u,requestId:e.requestId,model:e.model,teamId:e.teamId,automaticRetry:!1,transport:a?"sse":"json",...a?{streamDiagnostics:t.snapshot()}:{},...x?{errorCauses:x}:{},startedAt:y,completedAt:new Date().toISOString(),apiOrigin:C,maxOutputTokens:e.maxOutputTokens,timeoutSec:e.timeoutSec,maximumSpendUsd:e.maxSpend,quote:S,dispatchAttempted:m,completion:c,usage:i,text:E,finishReason:_,accounting:{state:m?b?"usage_recorded":"unknown":"not_dispatched",chargedUsd:m?null:0,requiresLedgerReconciliation:m,cleanupConfirmed:!m},...r?{error:r}:{}}},"receipt");try{let u=await(o.account??j)(A(n,"account"));if(!u.token)throw new Error("Sign in to an OpenPond account before using OpChat.");let r=new URL(D({opChatApiBaseUrl:u.chatApiBaseUrl,env:{}})),b=[A(n,"opchatApiBaseUrl"),A(n,"opchatApiUrl"),z(n),$(n)].filter(g=>!!g);for(let g of b){let f=new URL(g);if(f.origin!==r.origin||f.username||f.password||f.search||f.hash)throw new Error("The OpChat API URL must match the signed-in account's chat origin.")}if(r.username||r.password||r.search||r.hash)throw new Error("The signed-in account has an invalid OpChat URL.");let w=D({opChatApiBaseUrl:b[0]??r.href,env:{}});C=r.origin,l.signal.throwIfAborted();let U=await X({apiBaseUrl:w,token:u.token,teamId:e.teamId,model:e.model,signal:AbortSignal.any([l.signal,AbortSignal.timeout(3e4)])}),Q=new Date().toISOString(),R=re.parse(U);if(R.id!==e.model)throw new Error("The catalog returned a different model identity.");if(e.maxOutputTokens>R.output_limit)throw new Error("The requested output limit exceeds the model's current limit.");let I=R.metadata.billing.pricing,N=Math.ceil(R.context_window*Math.max(I.inputUsdPerMillionTokens,I.cachedInputUsdPerMillionTokens)+e.maxOutputTokens*I.outputUsdPerMillionTokens);if(!Number.isSafeInteger(N)||N<=0)throw new Error("The model does not publish an enforceable positive request ceiling.");let k=N/1e6;if(S={kind:"worst_case_request_reservation",observedAt:Q,contextWindow:R.context_window,outputLimit:R.output_limit,pricing:I,maximumRequestCostUsd:k,predictedSpend:!1,catalog:U,catalogSha256:ne("sha256").update(JSON.stringify(U)).digest("hex")},k>e.maxSpend)throw new Error(`The current worst-case request reservation $${k} exceeds --max-spend $${e.maxSpend}.`);l.signal.throwIfAborted();let G={apiBaseUrl:w,token:u.token,teamId:e.teamId,model:e.model,requestId:e.requestId,reasoningEffort:d,maxTokens:e.maxOutputTokens,signal:l.signal,messages:[{role:"user",content:e.message}],...a?{onStreamDiagnostic:t.observe}:{}};if(m=!0,a){let g=null,f;for await(let h of Y(G)){l.signal.throwIfAborted();let T=h.raw&&typeof h.raw=="object"?h.raw:{};if(typeof T.id!="string"||!T.id||T.model!==e.model||T.request_id!==e.requestId||g!==null&&T.id!==g)throw new Error("The stream does not match the admitted completion, model and request identity.");if(g=T.id,typeof T.created=="number"&&(f=T.created),h.type==="text_delta"&&(E+=h.text),h.type==="usage"&&(i=h.usage),h.type==="finish"&&(_=h.finishReason),h.type==="tool_call_delta")throw new Error("The bounded OpChat request did not admit tool calls.")}if(!g||!_)throw new Error("The stream ended without a terminal completion receipt.");c={id:g,model:e.model,request_id:e.requestId,object:"chat.completion",assembledFromStream:!0,...f===void 0?{}:{created:f},choices:[{index:0,message:{role:"assistant",content:E},finish_reason:_}],...i===null?{}:{usage:i}}}else c=await J(G),i=c.usage??null,E=c.choices?.[0]?.message?.content??"",_=c.choices?.[0]?.finish_reason??null;if(!c.id||c.model!==e.model||c.request_id!==e.requestId)throw new Error("The completion does not match the admitted model and request identity.");if(l.signal.throwIfAborted(),!_)throw new Error("The response ended without a terminal completion receipt.");M(F("completed"))}catch(u){let r=l.signal.aborted?l.signal.reason:u;x=K(r);let b=r instanceof Error?r.message:String(r),w=l.signal.aborted?r instanceof Error&&r.name==="TimeoutError"?"timed_out":"cancelled":m?"failed":"rejected";throw M(F(w,b)),new Z(b)}finally{clearTimeout(W),process.removeListener("SIGINT",P),process.removeListener("SIGTERM",v)}}p(ge,"runBoundedOpChat");export{ge as runBoundedOpChat};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{m as M}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import{b as x}from"./chunk-V3KEG6MI.js";import"./chunk-FGOTSCSE.js";import"./chunk-E2S2EMYQ.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{a as _,f as O,h as k,i as S}from"./chunk-3M53YXEI.js";import"./chunk-4N4EH3RJ.js";import"./chunk-ULJZ7NUF.js";import"./chunk-WJSJXK2N.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-6FA3GG5B.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as i}from"./chunk-FTQLQJQV.js";import{createHash as j,randomBytes as L}from"node:crypto";import{createServer as B}from"node:http";function D(e){return[e.slug,`team=${e.teamId}`,`role=${e.role}`,`status=${e.status}`,e.displayName].join(" ")}i(D,"formatOrganizationLine");function H(e){return[e.email??e.userId,`user=${e.userId}`,`role=${e.role}`,e.createdAt].join(" ")}i(H,"formatOrganizationMemberLine");function W(e){return e?[e.slug,`team=${e.teamId}`,`status=${e.status}`,`tools=${e.toolset.join(",")||"-"}`,e.resourceUrl].join(" "):"no mcp server configured"}i(W,"formatOrganizationMcpServerLine");var F=["estimate.read","estimate.write","estimate.execute","artifacts.read","artifacts.write"];function b(e){let t=e.trim().replace(/\/$/,"");if(!t)throw new Error("MCP resource URL must be non-empty");return new URL(t).toString().replace(/\/$/,"")}i(b,"normalizeMcpResourceUrl");function R(e,t){let r=typeof t.resourceUrl=="string"&&t.resourceUrl.trim()?t.resourceUrl.trim():typeof t.url=="string"&&t.url.trim()?t.url.trim():"";if(r)return b(r);if(!e?.resourceUrl)throw new Error("organization does not have an MCP server; run organizations mcp-generate first");return b(e.resourceUrl)}i(R,"resolveMcpProbeResourceUrl");function v(e,t){let r=typeof t.origin=="string"&&t.origin.trim()?t.origin.trim():"";return r?b(r):new URL(e).origin}i(v,"resolveMcpProbeOrigin");function U(e=32){return L(e).toString("base64url")}i(U,"randomOauthToken");function G(e){return j("sha256").update(e).digest("base64url")}i(G,"buildMcpOauthPkceChallenge");function V(e){let t=typeof e.scope=="string"&&e.scope.trim()?e.scope:typeof e.scopes=="string"&&e.scopes.trim()?e.scopes:"";if(!t)return[...F];let r=t.split(/[,\s]+/g).map(o=>o.trim()).filter(Boolean);if(r.length===0)throw new Error("scope must include at least one OAuth scope");return r}i(V,"parseMcpOAuthScopes");function q(e){let t=typeof e.clientId=="string"&&e.clientId.trim()?e.clientId.trim():"openpond-code-mcp-proof";if(t==="true")throw new Error("client-id must be a non-empty value");return t}i(q,"resolveMcpOAuthClientId");function Y(e){let t=k(e.timeoutSeconds,"timeout-seconds")??k(e.timeout,"timeout")??180;if(t<=0)throw new Error("timeout must be greater than zero");return t*1e3}i(Y,"resolveMcpOAuthTimeoutMs");function Z(e){let t=k(e.callbackPort,"callback-port")??0;if(t<0||t>65535)throw new Error("callback-port must be between 0 and 65535");return t}i(Z,"resolveMcpOAuthCallbackPort");function E(e){return new Promise((t,r)=>{e.close(o=>{o?r(o):t()})})}i(E,"closeServer");async function K(e){let t=!1,r=null,o=null,s=null,n=new Promise((u,l)=>{o=u,s=l}),a=i((u,l,g,m,p)=>{if(t){u.writeHead(204).end();return}t=!0,u.writeHead(l,{"cache-control":"no-store","content-type":"text/html; charset=utf-8"}),u.end(g),r&&clearTimeout(r),m?o?.(m):s?.(p??new Error("oauth_callback_failed"))},"settle"),c=B((u,l)=>{let g=u.headers.host??"127.0.0.1",m=new URL(u.url??"/",`http://${g}`);if(m.pathname!=="/callback"){l.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),l.end("Not found");return}let p=m.searchParams.get("state")??"",f=m.searchParams.get("error")??"",w=m.searchParams.get("code")??"";if(p!==e.expectedState){a(l,400,"<!doctype html><title>OpenPond OAuth failed</title><p>State mismatch. Return to the terminal and retry.</p>",void 0,new Error("oauth_state_mismatch"));return}if(f){a(l,400,"<!doctype html><title>OpenPond OAuth denied</title><p>Authorization was not completed. Return to the terminal.</p>",void 0,new Error(`oauth_authorization_failed:${f}`));return}if(!w){a(l,400,"<!doctype html><title>OpenPond OAuth failed</title><p>Missing authorization code. Return to the terminal and retry.</p>",void 0,new Error("oauth_code_missing"));return}a(l,200,"<!doctype html><title>OpenPond OAuth complete</title><p>Authorization complete. You can return to the terminal.</p>",{code:w,state:p})});await new Promise((u,l)=>{let g=i(p=>{c.off("listening",m),l(p)},"onError"),m=i(()=>{c.off("error",g),u()},"onListening");c.once("error",g),c.once("listening",m),c.listen(e.port,"127.0.0.1")});let d=c.address();if(!d||typeof d.port!="number")throw await E(c),new Error("oauth_callback_listener_failed");return r=setTimeout(()=>{t||(t=!0,s?.(new Error("oauth_callback_timeout")))},e.timeoutMs),{close:i(async()=>{r&&clearTimeout(r),await E(c).catch(()=>{})},"close"),redirectUri:`http://127.0.0.1:${d.port}/callback`,waitForCallback:i(()=>n,"waitForCallback")}}i(K,"startMcpOAuthCallbackListener");function Q(e){x(e)}i(Q,"openUrlWithSystemBrowser");function X(e){let t=new URL(e.authorizationEndpoint);return t.searchParams.set("response_type","code"),t.searchParams.set("client_id",e.clientId),t.searchParams.set("redirect_uri",e.redirectUri),t.searchParams.set("code_challenge",e.codeChallenge),t.searchParams.set("code_challenge_method","S256"),t.searchParams.set("resource",e.resourceUrl),t.searchParams.set("scope",e.scopes.join(" ")),t.searchParams.set("state",e.state),t.toString()}i(X,"buildMcpOAuthAuthorizeUrl");async function ee(e){let t=new URLSearchParams;t.set("grant_type","authorization_code"),t.set("client_id",e.clientId),t.set("redirect_uri",e.redirectUri),t.set("code",e.code),t.set("code_verifier",e.codeVerifier);let r=await fetch(`${e.origin}/oauth/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:t}),o=await N(r);if(!r.ok)throw new Error(`oauth_token_exchange_failed:${r.status}:${JSON.stringify(o)}`);if(!o||typeof o!="object"||Array.isArray(o))throw new Error("oauth_token_exchange_invalid_response");let s=o;if(typeof s.access_token!="string"||!s.access_token.trim())throw new Error("oauth_token_exchange_missing_access_token");return{access_token:s.access_token,...typeof s.expires_in=="number"?{expires_in:s.expires_in}:{},...typeof s.refresh_token=="string"?{refresh_token:s.refresh_token}:{},...typeof s.scope=="string"?{scope:s.scope}:{},...typeof s.token_type=="string"?{token_type:s.token_type}:{}}}i(ee,"exchangeMcpOAuthAuthorizationCode");async function N(e){let t=await e.text().catch(()=>"");if(!t)return null;let r=t.trim();if((e.headers.get("content-type")??"").toLowerCase().includes("application/json")||r.startsWith("{")||r.startsWith("["))try{return JSON.parse(r)}catch{return t}return t}i(N,"readMcpProbeBody");async function P(e,t={}){let r=await fetch(e,t);return{url:e,status:r.status,ok:r.ok,headers:{contentType:r.headers.get("content-type"),location:r.headers.get("location"),wwwAuthenticate:r.headers.get("www-authenticate")},body:await N(r)}}i(P,"fetchMcpProbe");function te(e,t,r){return r?{jsonrpc:"2.0",id:e,method:t,params:r}:{jsonrpc:"2.0",id:e,method:t}}i(te,"buildMcpJsonRpcRequest");function T(e){let t=typeof e.arguments=="string"&&e.arguments.trim()?e.arguments:typeof e.args=="string"&&e.args.trim()?e.args:"";if(!t)return{};let r=_(t,"arguments");if(!r||typeof r!="object"||Array.isArray(r))throw new Error("arguments must be a JSON object");return r}i(T,"parseMcpToolArguments");async function z(e){let t={"content-type":"application/json"};return e.accessToken&&(t.authorization=`Bearer ${e.accessToken}`),P(e.resourceUrl,{method:"POST",headers:t,body:JSON.stringify(te(e.id,e.method,e.params))})}i(z,"postMcpJsonRpcProbe");async function A(e){let t=b(e.resourceUrl),r=b(e.origin),o=`${t}/.well-known/oauth-protected-resource`,s=`${r}/.well-known/oauth-authorization-server`,[n,a,c,d,u,l,g]=await Promise.all([P(o),P(s),P(t),z({resourceUrl:t,id:1,method:"initialize"}),z({resourceUrl:t,id:2,method:"tools/list"}),z({resourceUrl:t,id:3,method:"tools/call",params:{name:e.toolName,arguments:e.toolArguments}}),e.accessToken?z({resourceUrl:t,id:4,method:"tools/call",params:{name:e.toolName,arguments:e.toolArguments},accessToken:e.accessToken}):Promise.resolve(null)]);return{resourceUrl:t,origin:r,protectedResource:n,authorizationServer:a,directGetChallenge:c,initialize:d,toolsList:u,unauthenticatedToolCall:l,...g?{authenticatedToolCall:g}:{}}}i(A,"probeOrganizationMcp");function re(e){let t=typeof e=="string"?e.trim():"";if(t==="owner"||t==="admin"||t==="member")return t;throw new Error("role must be owner, admin, or member")}i(re,"parseOrganizationRole");function ne(e){let t=typeof e.displayName=="string"&&e.displayName.trim()?e.displayName.trim():typeof e.name=="string"&&e.name.trim()?e.name.trim():"";if(!t)throw new Error("usage: organizations create --name <name> [--slug <slug>]");return{displayName:t,...typeof e.slug=="string"&&e.slug.trim()?{slug:e.slug.trim()}:{},...typeof e.primaryContactEmail=="string"&&e.primaryContactEmail.trim()?{primaryContactEmail:e.primaryContactEmail.trim()}:{},...typeof e.customDomain=="string"&&e.customDomain.trim()?{customDomain:e.customDomain.trim()}:{}}}i(ne,"buildOrganizationCreateInput");function oe(e){let t={},r=typeof e.displayName=="string"&&e.displayName.trim()?e.displayName.trim():typeof e.name=="string"&&e.name.trim()?e.name.trim():"";if(r&&(t.displayName=r),typeof e.slug=="string"&&e.slug.trim()&&(t.slug=e.slug.trim()),typeof e.primaryContactEmail=="string"&&(t.primaryContactEmail=e.primaryContactEmail.trim()||null),typeof e.customDomain=="string"&&(t.customDomain=e.customDomain.trim()||null),typeof e.status=="string"&&e.status.trim()){let o=e.status.trim();if(o!=="active"&&o!=="disabled"&&o!=="archived")throw new Error("status must be active, disabled, or archived");t.status=o}if(Object.keys(t).length===0)throw new Error("organizations update requires at least one changed field");return t}i(oe,"buildOrganizationUpdateInput");function ie(e){let t=typeof e.email=="string"?e.email.trim():"";if(!t)throw new Error("usage: organizations member-upsert <slug> --email <email> --role <role>");return{email:t,role:re(e.role)}}i(ie,"buildOrganizationMemberInput");function ae(e){return{...typeof e.origin=="string"&&e.origin.trim()?{origin:e.origin.trim()}:{},...typeof e.toolset=="string"&&e.toolset.trim()?{toolset:S(e.toolset)}:{}}}i(ae,"buildOrganizationMcpGenerateInput");async function ge(e,t){let r=t[0]||"list",o=await M(e),s=O(e.json);if(r==="list"){let n=await o.listOrganizations();if(s){console.log(JSON.stringify({organizations:n},null,2));return}if(n.length===0){console.log("no organizations found");return}for(let a of n)console.log(D(a));return}if(r==="create"){let n=await o.createOrganization(ne(e));console.log(JSON.stringify({organization:n},null,2));return}if(r==="get"){let n=t[1];if(!n)throw new Error("usage: organizations get <slug>");let a=await o.getOrganization(n);console.log(JSON.stringify({organization:a},null,2));return}if(r==="update"){let n=t[1];if(!n)throw new Error("usage: organizations update <slug> [--name <name>]");let a=await o.updateOrganization(n,oe(e));console.log(JSON.stringify({organization:a},null,2));return}if(r==="members"||r==="member-list"){let n=t[1];if(!n)throw new Error("usage: organizations members <slug>");let a=await o.listOrganizationMembers(n);if(s){console.log(JSON.stringify({members:a},null,2));return}if(a.length===0){console.log("no organization members found");return}for(let c of a)console.log(H(c));return}if(r==="member-upsert"||r==="member-add"){let n=t[1];if(!n)throw new Error("usage: organizations member-upsert <slug> --email <email> --role <role>");let a=await o.upsertOrganizationMember(n,ie(e));console.log(JSON.stringify({member:a},null,2));return}if(r==="mcp-get"||r==="mcp-server"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-get <slug>");let a=await o.getOrganizationMcpServer(n);if(s){console.log(JSON.stringify({mcpServer:a},null,2));return}console.log(W(a));return}if(r==="mcp-generate"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-generate <slug> [--origin <url>]");let a=await o.generateOrganizationMcpServer(n,ae(e));console.log(JSON.stringify({mcpServer:a},null,2));return}if(r==="mcp-probe"||r==="mcp-inspect"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-probe <slug> [--origin <url>] [--tool <name>] [--arguments <json>] [--access-token <token>]");let a=await o.getOrganizationMcpServer(n),c=R(a,e),d=v(c,e),u=typeof e.tool=="string"&&e.tool.trim()?e.tool.trim():typeof e.toolName=="string"&&e.toolName.trim()?e.toolName.trim():"estimate_search_history",l=T(e),g=typeof e.accessToken=="string"&&e.accessToken.trim()?e.accessToken.trim():"",m=await A({resourceUrl:c,origin:d,toolName:u,toolArguments:l,...g?{accessToken:g}:{}});console.log(JSON.stringify({mcpServer:a,probe:m},null,2));return}if(r==="mcp-authorize"||r==="mcp-oauth"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-authorize <slug> [--origin <url>] [--scope <csv|space>] [--tool <name>] [--arguments <json>] [--open]");let a=await o.getOrganizationMcpServer(n),c=R(a,e),d=v(c,e),u=q(e),l=V(e),g=U(18),m=U(48),p=G(m),f=await K({expectedState:g,port:Z(e),timeoutMs:Y(e)}),w=X({authorizationEndpoint:`${d}/oauth/authorize`,clientId:u,codeChallenge:p,redirectUri:f.redirectUri,resourceUrl:c,scopes:l,state:g});if(console.error("Open this URL to authorize the organization MCP connection:"),console.error(w),console.error(`Waiting for OAuth callback on ${f.redirectUri}`),O(e.open))try{Q(w)}catch(y){console.error(`Unable to open a browser automatically: ${y instanceof Error?y.message:String(y)}`)}try{let y=await f.waitForCallback(),h=await ee({clientId:u,code:y.code,codeVerifier:m,origin:d,redirectUri:f.redirectUri}),C=typeof e.tool=="string"&&e.tool.trim()?e.tool.trim():typeof e.toolName=="string"&&e.toolName.trim()?e.toolName.trim():"estimate_search_history",I=T(e),$=await A({accessToken:h.access_token,origin:d,resourceUrl:c,toolArguments:I,toolName:C}),J=O(e.printToken);console.log(JSON.stringify({mcpServer:a,oauth:{accessTokenReceived:!0,clientId:u,expiresIn:h.expires_in??null,refreshTokenReceived:!!h.refresh_token,scope:h.scope??l.join(" "),tokenType:h.token_type??"Bearer",...J?{accessToken:h.access_token,refreshToken:h.refresh_token??null}:{}},probe:$},null,2))}finally{await f.close()}return}if(r==="mcp-rotate"||r==="mcp-disable"||r==="mcp-enable"){let n=t[1];if(!n)throw new Error(`usage: organizations ${r} <slug>`);let a=r==="mcp-rotate"?await o.rotateOrganizationMcpServer(n):r==="mcp-disable"?await o.disableOrganizationMcpServer(n):await o.enableOrganizationMcpServer(n);console.log(JSON.stringify({mcpServer:a},null,2));return}throw new Error("usage: organizations <list|create|get|update|members|member-upsert|mcp-get|mcp-generate|mcp-probe|mcp-authorize|mcp-rotate|mcp-disable|mcp-enable> [args]")}i(ge,"runOrganizationsCommand");export{F as DEFAULT_MCP_AUTHORIZE_SCOPES,te as buildMcpJsonRpcRequest,X as buildMcpOAuthAuthorizeUrl,G as buildMcpOauthPkceChallenge,ne as buildOrganizationCreateInput,ae as buildOrganizationMcpGenerateInput,ie as buildOrganizationMemberInput,oe as buildOrganizationUpdateInput,E as closeServer,ee as exchangeMcpOAuthAuthorizationCode,P as fetchMcpProbe,D as formatOrganizationLine,W as formatOrganizationMcpServerLine,H as formatOrganizationMemberLine,b as normalizeMcpResourceUrl,Q as openUrlWithSystemBrowser,V as parseMcpOAuthScopes,T as parseMcpToolArguments,re as parseOrganizationRole,z as postMcpJsonRpcProbe,A as probeOrganizationMcp,U as randomOauthToken,N as readMcpProbeBody,Z as resolveMcpOAuthCallbackPort,q as resolveMcpOAuthClientId,Y as resolveMcpOAuthTimeoutMs,v as resolveMcpProbeOrigin,R as resolveMcpProbeResourceUrl,ge as runOrganizationsCommand,K as startMcpOAuthCallbackListener};
|
|
2
|
+
import{m as M}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import{b as x}from"./chunk-V3KEG6MI.js";import"./chunk-NABPZ7AK.js";import"./chunk-BQVB2SPF.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{a as _,f as O,h as k,i as S}from"./chunk-3M53YXEI.js";import"./chunk-4N4EH3RJ.js";import"./chunk-ULJZ7NUF.js";import"./chunk-WJSJXK2N.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-6FA3GG5B.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as i}from"./chunk-FTQLQJQV.js";import{createHash as j,randomBytes as L}from"node:crypto";import{createServer as B}from"node:http";function D(e){return[e.slug,`team=${e.teamId}`,`role=${e.role}`,`status=${e.status}`,e.displayName].join(" ")}i(D,"formatOrganizationLine");function H(e){return[e.email??e.userId,`user=${e.userId}`,`role=${e.role}`,e.createdAt].join(" ")}i(H,"formatOrganizationMemberLine");function W(e){return e?[e.slug,`team=${e.teamId}`,`status=${e.status}`,`tools=${e.toolset.join(",")||"-"}`,e.resourceUrl].join(" "):"no mcp server configured"}i(W,"formatOrganizationMcpServerLine");var F=["estimate.read","estimate.write","estimate.execute","artifacts.read","artifacts.write"];function b(e){let t=e.trim().replace(/\/$/,"");if(!t)throw new Error("MCP resource URL must be non-empty");return new URL(t).toString().replace(/\/$/,"")}i(b,"normalizeMcpResourceUrl");function R(e,t){let r=typeof t.resourceUrl=="string"&&t.resourceUrl.trim()?t.resourceUrl.trim():typeof t.url=="string"&&t.url.trim()?t.url.trim():"";if(r)return b(r);if(!e?.resourceUrl)throw new Error("organization does not have an MCP server; run organizations mcp-generate first");return b(e.resourceUrl)}i(R,"resolveMcpProbeResourceUrl");function v(e,t){let r=typeof t.origin=="string"&&t.origin.trim()?t.origin.trim():"";return r?b(r):new URL(e).origin}i(v,"resolveMcpProbeOrigin");function U(e=32){return L(e).toString("base64url")}i(U,"randomOauthToken");function G(e){return j("sha256").update(e).digest("base64url")}i(G,"buildMcpOauthPkceChallenge");function V(e){let t=typeof e.scope=="string"&&e.scope.trim()?e.scope:typeof e.scopes=="string"&&e.scopes.trim()?e.scopes:"";if(!t)return[...F];let r=t.split(/[,\s]+/g).map(o=>o.trim()).filter(Boolean);if(r.length===0)throw new Error("scope must include at least one OAuth scope");return r}i(V,"parseMcpOAuthScopes");function q(e){let t=typeof e.clientId=="string"&&e.clientId.trim()?e.clientId.trim():"openpond-code-mcp-proof";if(t==="true")throw new Error("client-id must be a non-empty value");return t}i(q,"resolveMcpOAuthClientId");function Y(e){let t=k(e.timeoutSeconds,"timeout-seconds")??k(e.timeout,"timeout")??180;if(t<=0)throw new Error("timeout must be greater than zero");return t*1e3}i(Y,"resolveMcpOAuthTimeoutMs");function Z(e){let t=k(e.callbackPort,"callback-port")??0;if(t<0||t>65535)throw new Error("callback-port must be between 0 and 65535");return t}i(Z,"resolveMcpOAuthCallbackPort");function E(e){return new Promise((t,r)=>{e.close(o=>{o?r(o):t()})})}i(E,"closeServer");async function K(e){let t=!1,r=null,o=null,s=null,n=new Promise((u,l)=>{o=u,s=l}),a=i((u,l,g,m,p)=>{if(t){u.writeHead(204).end();return}t=!0,u.writeHead(l,{"cache-control":"no-store","content-type":"text/html; charset=utf-8"}),u.end(g),r&&clearTimeout(r),m?o?.(m):s?.(p??new Error("oauth_callback_failed"))},"settle"),c=B((u,l)=>{let g=u.headers.host??"127.0.0.1",m=new URL(u.url??"/",`http://${g}`);if(m.pathname!=="/callback"){l.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),l.end("Not found");return}let p=m.searchParams.get("state")??"",f=m.searchParams.get("error")??"",w=m.searchParams.get("code")??"";if(p!==e.expectedState){a(l,400,"<!doctype html><title>OpenPond OAuth failed</title><p>State mismatch. Return to the terminal and retry.</p>",void 0,new Error("oauth_state_mismatch"));return}if(f){a(l,400,"<!doctype html><title>OpenPond OAuth denied</title><p>Authorization was not completed. Return to the terminal.</p>",void 0,new Error(`oauth_authorization_failed:${f}`));return}if(!w){a(l,400,"<!doctype html><title>OpenPond OAuth failed</title><p>Missing authorization code. Return to the terminal and retry.</p>",void 0,new Error("oauth_code_missing"));return}a(l,200,"<!doctype html><title>OpenPond OAuth complete</title><p>Authorization complete. You can return to the terminal.</p>",{code:w,state:p})});await new Promise((u,l)=>{let g=i(p=>{c.off("listening",m),l(p)},"onError"),m=i(()=>{c.off("error",g),u()},"onListening");c.once("error",g),c.once("listening",m),c.listen(e.port,"127.0.0.1")});let d=c.address();if(!d||typeof d.port!="number")throw await E(c),new Error("oauth_callback_listener_failed");return r=setTimeout(()=>{t||(t=!0,s?.(new Error("oauth_callback_timeout")))},e.timeoutMs),{close:i(async()=>{r&&clearTimeout(r),await E(c).catch(()=>{})},"close"),redirectUri:`http://127.0.0.1:${d.port}/callback`,waitForCallback:i(()=>n,"waitForCallback")}}i(K,"startMcpOAuthCallbackListener");function Q(e){x(e)}i(Q,"openUrlWithSystemBrowser");function X(e){let t=new URL(e.authorizationEndpoint);return t.searchParams.set("response_type","code"),t.searchParams.set("client_id",e.clientId),t.searchParams.set("redirect_uri",e.redirectUri),t.searchParams.set("code_challenge",e.codeChallenge),t.searchParams.set("code_challenge_method","S256"),t.searchParams.set("resource",e.resourceUrl),t.searchParams.set("scope",e.scopes.join(" ")),t.searchParams.set("state",e.state),t.toString()}i(X,"buildMcpOAuthAuthorizeUrl");async function ee(e){let t=new URLSearchParams;t.set("grant_type","authorization_code"),t.set("client_id",e.clientId),t.set("redirect_uri",e.redirectUri),t.set("code",e.code),t.set("code_verifier",e.codeVerifier);let r=await fetch(`${e.origin}/oauth/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:t}),o=await N(r);if(!r.ok)throw new Error(`oauth_token_exchange_failed:${r.status}:${JSON.stringify(o)}`);if(!o||typeof o!="object"||Array.isArray(o))throw new Error("oauth_token_exchange_invalid_response");let s=o;if(typeof s.access_token!="string"||!s.access_token.trim())throw new Error("oauth_token_exchange_missing_access_token");return{access_token:s.access_token,...typeof s.expires_in=="number"?{expires_in:s.expires_in}:{},...typeof s.refresh_token=="string"?{refresh_token:s.refresh_token}:{},...typeof s.scope=="string"?{scope:s.scope}:{},...typeof s.token_type=="string"?{token_type:s.token_type}:{}}}i(ee,"exchangeMcpOAuthAuthorizationCode");async function N(e){let t=await e.text().catch(()=>"");if(!t)return null;let r=t.trim();if((e.headers.get("content-type")??"").toLowerCase().includes("application/json")||r.startsWith("{")||r.startsWith("["))try{return JSON.parse(r)}catch{return t}return t}i(N,"readMcpProbeBody");async function P(e,t={}){let r=await fetch(e,t);return{url:e,status:r.status,ok:r.ok,headers:{contentType:r.headers.get("content-type"),location:r.headers.get("location"),wwwAuthenticate:r.headers.get("www-authenticate")},body:await N(r)}}i(P,"fetchMcpProbe");function te(e,t,r){return r?{jsonrpc:"2.0",id:e,method:t,params:r}:{jsonrpc:"2.0",id:e,method:t}}i(te,"buildMcpJsonRpcRequest");function T(e){let t=typeof e.arguments=="string"&&e.arguments.trim()?e.arguments:typeof e.args=="string"&&e.args.trim()?e.args:"";if(!t)return{};let r=_(t,"arguments");if(!r||typeof r!="object"||Array.isArray(r))throw new Error("arguments must be a JSON object");return r}i(T,"parseMcpToolArguments");async function z(e){let t={"content-type":"application/json"};return e.accessToken&&(t.authorization=`Bearer ${e.accessToken}`),P(e.resourceUrl,{method:"POST",headers:t,body:JSON.stringify(te(e.id,e.method,e.params))})}i(z,"postMcpJsonRpcProbe");async function A(e){let t=b(e.resourceUrl),r=b(e.origin),o=`${t}/.well-known/oauth-protected-resource`,s=`${r}/.well-known/oauth-authorization-server`,[n,a,c,d,u,l,g]=await Promise.all([P(o),P(s),P(t),z({resourceUrl:t,id:1,method:"initialize"}),z({resourceUrl:t,id:2,method:"tools/list"}),z({resourceUrl:t,id:3,method:"tools/call",params:{name:e.toolName,arguments:e.toolArguments}}),e.accessToken?z({resourceUrl:t,id:4,method:"tools/call",params:{name:e.toolName,arguments:e.toolArguments},accessToken:e.accessToken}):Promise.resolve(null)]);return{resourceUrl:t,origin:r,protectedResource:n,authorizationServer:a,directGetChallenge:c,initialize:d,toolsList:u,unauthenticatedToolCall:l,...g?{authenticatedToolCall:g}:{}}}i(A,"probeOrganizationMcp");function re(e){let t=typeof e=="string"?e.trim():"";if(t==="owner"||t==="admin"||t==="member")return t;throw new Error("role must be owner, admin, or member")}i(re,"parseOrganizationRole");function ne(e){let t=typeof e.displayName=="string"&&e.displayName.trim()?e.displayName.trim():typeof e.name=="string"&&e.name.trim()?e.name.trim():"";if(!t)throw new Error("usage: organizations create --name <name> [--slug <slug>]");return{displayName:t,...typeof e.slug=="string"&&e.slug.trim()?{slug:e.slug.trim()}:{},...typeof e.primaryContactEmail=="string"&&e.primaryContactEmail.trim()?{primaryContactEmail:e.primaryContactEmail.trim()}:{},...typeof e.customDomain=="string"&&e.customDomain.trim()?{customDomain:e.customDomain.trim()}:{}}}i(ne,"buildOrganizationCreateInput");function oe(e){let t={},r=typeof e.displayName=="string"&&e.displayName.trim()?e.displayName.trim():typeof e.name=="string"&&e.name.trim()?e.name.trim():"";if(r&&(t.displayName=r),typeof e.slug=="string"&&e.slug.trim()&&(t.slug=e.slug.trim()),typeof e.primaryContactEmail=="string"&&(t.primaryContactEmail=e.primaryContactEmail.trim()||null),typeof e.customDomain=="string"&&(t.customDomain=e.customDomain.trim()||null),typeof e.status=="string"&&e.status.trim()){let o=e.status.trim();if(o!=="active"&&o!=="disabled"&&o!=="archived")throw new Error("status must be active, disabled, or archived");t.status=o}if(Object.keys(t).length===0)throw new Error("organizations update requires at least one changed field");return t}i(oe,"buildOrganizationUpdateInput");function ie(e){let t=typeof e.email=="string"?e.email.trim():"";if(!t)throw new Error("usage: organizations member-upsert <slug> --email <email> --role <role>");return{email:t,role:re(e.role)}}i(ie,"buildOrganizationMemberInput");function ae(e){return{...typeof e.origin=="string"&&e.origin.trim()?{origin:e.origin.trim()}:{},...typeof e.toolset=="string"&&e.toolset.trim()?{toolset:S(e.toolset)}:{}}}i(ae,"buildOrganizationMcpGenerateInput");async function ge(e,t){let r=t[0]||"list",o=await M(e),s=O(e.json);if(r==="list"){let n=await o.listOrganizations();if(s){console.log(JSON.stringify({organizations:n},null,2));return}if(n.length===0){console.log("no organizations found");return}for(let a of n)console.log(D(a));return}if(r==="create"){let n=await o.createOrganization(ne(e));console.log(JSON.stringify({organization:n},null,2));return}if(r==="get"){let n=t[1];if(!n)throw new Error("usage: organizations get <slug>");let a=await o.getOrganization(n);console.log(JSON.stringify({organization:a},null,2));return}if(r==="update"){let n=t[1];if(!n)throw new Error("usage: organizations update <slug> [--name <name>]");let a=await o.updateOrganization(n,oe(e));console.log(JSON.stringify({organization:a},null,2));return}if(r==="members"||r==="member-list"){let n=t[1];if(!n)throw new Error("usage: organizations members <slug>");let a=await o.listOrganizationMembers(n);if(s){console.log(JSON.stringify({members:a},null,2));return}if(a.length===0){console.log("no organization members found");return}for(let c of a)console.log(H(c));return}if(r==="member-upsert"||r==="member-add"){let n=t[1];if(!n)throw new Error("usage: organizations member-upsert <slug> --email <email> --role <role>");let a=await o.upsertOrganizationMember(n,ie(e));console.log(JSON.stringify({member:a},null,2));return}if(r==="mcp-get"||r==="mcp-server"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-get <slug>");let a=await o.getOrganizationMcpServer(n);if(s){console.log(JSON.stringify({mcpServer:a},null,2));return}console.log(W(a));return}if(r==="mcp-generate"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-generate <slug> [--origin <url>]");let a=await o.generateOrganizationMcpServer(n,ae(e));console.log(JSON.stringify({mcpServer:a},null,2));return}if(r==="mcp-probe"||r==="mcp-inspect"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-probe <slug> [--origin <url>] [--tool <name>] [--arguments <json>] [--access-token <token>]");let a=await o.getOrganizationMcpServer(n),c=R(a,e),d=v(c,e),u=typeof e.tool=="string"&&e.tool.trim()?e.tool.trim():typeof e.toolName=="string"&&e.toolName.trim()?e.toolName.trim():"estimate_search_history",l=T(e),g=typeof e.accessToken=="string"&&e.accessToken.trim()?e.accessToken.trim():"",m=await A({resourceUrl:c,origin:d,toolName:u,toolArguments:l,...g?{accessToken:g}:{}});console.log(JSON.stringify({mcpServer:a,probe:m},null,2));return}if(r==="mcp-authorize"||r==="mcp-oauth"){let n=t[1];if(!n)throw new Error("usage: organizations mcp-authorize <slug> [--origin <url>] [--scope <csv|space>] [--tool <name>] [--arguments <json>] [--open]");let a=await o.getOrganizationMcpServer(n),c=R(a,e),d=v(c,e),u=q(e),l=V(e),g=U(18),m=U(48),p=G(m),f=await K({expectedState:g,port:Z(e),timeoutMs:Y(e)}),w=X({authorizationEndpoint:`${d}/oauth/authorize`,clientId:u,codeChallenge:p,redirectUri:f.redirectUri,resourceUrl:c,scopes:l,state:g});if(console.error("Open this URL to authorize the organization MCP connection:"),console.error(w),console.error(`Waiting for OAuth callback on ${f.redirectUri}`),O(e.open))try{Q(w)}catch(y){console.error(`Unable to open a browser automatically: ${y instanceof Error?y.message:String(y)}`)}try{let y=await f.waitForCallback(),h=await ee({clientId:u,code:y.code,codeVerifier:m,origin:d,redirectUri:f.redirectUri}),C=typeof e.tool=="string"&&e.tool.trim()?e.tool.trim():typeof e.toolName=="string"&&e.toolName.trim()?e.toolName.trim():"estimate_search_history",I=T(e),$=await A({accessToken:h.access_token,origin:d,resourceUrl:c,toolArguments:I,toolName:C}),J=O(e.printToken);console.log(JSON.stringify({mcpServer:a,oauth:{accessTokenReceived:!0,clientId:u,expiresIn:h.expires_in??null,refreshTokenReceived:!!h.refresh_token,scope:h.scope??l.join(" "),tokenType:h.token_type??"Bearer",...J?{accessToken:h.access_token,refreshToken:h.refresh_token??null}:{}},probe:$},null,2))}finally{await f.close()}return}if(r==="mcp-rotate"||r==="mcp-disable"||r==="mcp-enable"){let n=t[1];if(!n)throw new Error(`usage: organizations ${r} <slug>`);let a=r==="mcp-rotate"?await o.rotateOrganizationMcpServer(n):r==="mcp-disable"?await o.disableOrganizationMcpServer(n):await o.enableOrganizationMcpServer(n);console.log(JSON.stringify({mcpServer:a},null,2));return}throw new Error("usage: organizations <list|create|get|update|members|member-upsert|mcp-get|mcp-generate|mcp-probe|mcp-authorize|mcp-rotate|mcp-disable|mcp-enable> [args]")}i(ge,"runOrganizationsCommand");export{F as DEFAULT_MCP_AUTHORIZE_SCOPES,te as buildMcpJsonRpcRequest,X as buildMcpOAuthAuthorizeUrl,G as buildMcpOauthPkceChallenge,ne as buildOrganizationCreateInput,ae as buildOrganizationMcpGenerateInput,ie as buildOrganizationMemberInput,oe as buildOrganizationUpdateInput,E as closeServer,ee as exchangeMcpOAuthAuthorizationCode,P as fetchMcpProbe,D as formatOrganizationLine,W as formatOrganizationMcpServerLine,H as formatOrganizationMemberLine,b as normalizeMcpResourceUrl,Q as openUrlWithSystemBrowser,V as parseMcpOAuthScopes,T as parseMcpToolArguments,re as parseOrganizationRole,z as postMcpJsonRpcProbe,A as probeOrganizationMcp,U as randomOauthToken,N as readMcpProbeBody,Z as resolveMcpOAuthCallbackPort,q as resolveMcpOAuthClientId,Y as resolveMcpOAuthTimeoutMs,v as resolveMcpProbeOrigin,R as resolveMcpProbeResourceUrl,ge as runOrganizationsCommand,K as startMcpOAuthCallbackListener};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{i as Ie,j as K,k as W,r as $e,s as Re}from"./chunk-36FNNR5N.js";import{m as G}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import"./chunk-FGOTSCSE.js";import"./chunk-E2S2EMYQ.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as f,d as B,f as S}from"./chunk-3M53YXEI.js";import{e as ie}from"./chunk-LZPCA6DH.js";import{a as ue}from"./chunk-L3KS6MOV.js";import"./chunk-SFR32TMJ.js";import"./chunk-5KJMFK65.js";import"./chunk-Y3B6ZUE6.js";import{ja as fe}from"./chunk-WLZJOCLA.js";import"./chunk-HIQPGYVH.js";import"./chunk-ZWW227M3.js";import"./chunk-DXA2UHBE.js";import"./chunk-MTP3B2SU.js";import"./chunk-X37KMV27.js";import{G as Pe,I as ke,J as ye,K as R,e as Q,f as he,g as X,h as ge,i as me,j as pe,q as ee,s as Se,t as we,x}from"./chunk-EBOTNBUS.js";import"./chunk-PWKJ5KLZ.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-JFZ6USNQ.js";import"./chunk-6FA3GG5B.js";import"./chunk-G4E3WGLM.js";import{c as ae,sa as le,ta as ce,wa as de}from"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as i}from"./chunk-FTQLQJQV.js";import{readFile as qe}from"node:fs/promises";import L from"node:path";import{promises as A}from"node:fs";import b from"node:path";async function oe(e,t){let o=b.join(e,t),n=await A.lstat(o).catch(l=>{if(l.code==="ENOENT")return null;throw l});if(!n)return[];if(!n.isDirectory()||n.isSymbolicLink())throw new Error(`Profile source directory is not a regular directory: ${t}`);let a=[];for(let l of await A.readdir(o,{withFileTypes:!0})){let h=b.join(o,l.name),d=b.relative(e,h).split(b.sep).join("/");if(l.isSymbolicLink())throw new Error(`Profile source contains a symlink: ${d}`);if(l.isDirectory())a.push(...await oe(e,d));else if(l.isFile())a.push(d);else throw new Error(`Profile source contains a non-regular file: ${d}`)}return a.sort()}i(oe,"sourceFiles");async function Ce(e,t=new Set){let{skills:o,skillCatalog:n}=await ue(e);if(n.error)throw new Error(`Profile Skills: ${n.error}`);for(let s of o)if(s.validationStatus!=="valid")throw new Error(`Profile Skill ${s.name}: ${s.validationMessages.join(" ")}`);let a=new Set(o.map(s=>s.path)),l=[...await oe(e,"workflows"),...await oe(e,"evals")].sort(),h=l.filter(s=>s.startsWith("workflows/")),d=h.some(s=>/^workflows\/[^/]+\/(PROMPT\.md|ACTION\.json)$/.test(s)),u=h.includes("workflows/catalog.json");if(d&&u)throw new Error("Workflow packages and legacy workflows/catalog.json cannot coexist.");let y=d?ie({files:new Map(await Promise.all(h.map(async s=>[s,await A.readFile(b.join(e,s),"utf8")]))),skillPaths:a,actionIds:t}).catalog:u?ae({catalog:JSON.parse(await A.readFile(b.join(e,"workflows/catalog.json"),"utf8")),sourcePaths:a,actionIds:t}):{workflows:[]},$=new Set(y.workflows.map(s=>s.id)),C=l.filter(s=>/^workflows\/[^/]+\/evals\/[^/]+\.json$/.test(s)||/^evals\/definitions\/[^/]+\.json$/.test(s)),w=l.filter(s=>/^evals\/suites\/[^/]+\.json$/.test(s));if(l.includes("evals/catalog.json")&&(C.length||w.length))throw new Error("Evaluation packages and legacy evals/catalog.json cannot coexist.");let j=await Promise.all(C.map(async s=>{let r=le.parse(JSON.parse(await A.readFile(b.join(e,s),"utf8"))),m=/^workflows\/([^/]+)\/evals\//.exec(s)?.[1];if(m&&(r.target.kind!=="workflow"||r.target.workflowId!==m))throw new Error(`Evaluation ${r.id} must target its containing Workflow ${m}.`);return r})),N=await Promise.all(w.map(async s=>ce.parse(JSON.parse(await A.readFile(b.join(e,s),"utf8"))))),_=l.includes("evals/catalog.json")?JSON.parse(await A.readFile(b.join(e,"evals/catalog.json"),"utf8")):{schemaVersion:"openpond.profileEvaluations.v1",definitions:j,suites:N},P=de({catalog:_,workflowIds:$,skillPaths:a,actionIds:t}).catalog,g=l.filter(s=>/^evals\/tasksets\/[^/]+\.json$/.test(s)),O=new Map;for(let s of g){let r=fe(JSON.parse(await A.readFile(b.join(e,s),"utf8"))).taskset;if(s!==`evals/tasksets/${r.contentHash}.json`)throw new Error(`Frozen Taskset file name differs from its content hash: ${s}.`);O.set(r.contentHash,r)}for(let s of P.definitions){let r=s.tasksetRelease.contentHash,m=`evals/tasksets/${r}.json`,H=O.get(r);if(!H)throw new Error(`Evaluation ${s.id} is missing Taskset ${m}.`);if(H.id!==s.tasksetRelease.id||H.contentHash!==r)throw new Error(`Evaluation ${s.id} references a different frozen Taskset.`);let E=new Set(H.tasks.filter(k=>k.split===s.split).map(k=>k.id));for(let k of s.taskIds)if(!E.has(k))throw new Error(`Evaluation ${s.id} references missing Taskset case ${k} in split ${s.split}.`)}return{workflows:y.workflows.length,skills:o.length,evaluations:P.definitions.length,tasksets:O.size}}i(Ce,"checkLocalProfileSource");import te from"node:path";async function Ae(e){if(!e.state.sourcePath)throw new Error("Active OpenPond profile is missing a source path.");let t=e.state.agents.find(s=>s.id===e.agentId);if(!t)throw new Error(`Profile agent not found for hosted materialization: ${e.agentId}`);if(!t.enabled)throw new Error(`Profile agent is disabled: ${e.agentId}`);let o=xe(e.state.sourcePath,t.path),n=await Ie(o),a=await K(o,n.entries),l=W(n,a.entries),h=await Me({client:e.client,teamId:e.teamId,projectId:e.projectId??null,profileProjectId:e.profileProjectId,profileName:e.profileName,agentId:e.agentId,localHead:e.localHead,hostedHead:e.hostedHead}),d=await e.client.projects.uploadSource(h.id,{teamId:e.teamId,entries:l.entries,branch:e.sourceRef,commitMessage:`Materialize OpenPond profile agent ${e.agentId}`}),u=await e.client.projects.sync(d.id,{teamId:e.teamId}),y=be(u)??be(d),$=je(u)??je(d)??e.sourceRef,C=`openpond-profile-agent:${e.profileProjectId}:${e.profileName}:${e.agentId}`,w=(await e.client.agents.list({teamId:e.teamId})).find(s=>s.externalId===C),j=await e.client.agents.upsert({teamId:e.teamId,projectId:u.id,name:t.name||e.agentId,slug:_e(e.profileName,e.agentId),selectedEntrypoint:Ne(e.state,e.agentId),triggerType:"manual",runtimeSource:{mode:"latest_source",...$?{sourceRef:$}:{},...y?{sourceCommitSha:y}:{}},metadata:{...w?.metadata??{},source:"openpond_profile_agent_materialization",profileProjectId:e.profileProjectId,profileName:e.profileName,profileAgentId:e.agentId,profileSourcePath:t.path,localHead:e.localHead,hostedHead:e.hostedHead},externalId:C}),N=v(a.uploadMetadata),_=v(N?.commands),P=v(N?.dependencySetup),g=Ue(P?.commands),O=[I(_?.validate),I(_?.eval)].filter(s=>!!s);return{status:"uploaded",agentId:e.agentId,runtimeAgentId:j.id,projectId:u.id,sourceRoot:o,sourceRef:$,sourceCommitSha:y??null,manifestHash:u.sandboxManifestHash??null,manifestPath:u.sandboxManifestPath??null,manifestSyncedAt:u.sandboxManifestSyncedAt??null,fileCount:l.fileCount,totalBytes:l.totalBytes,generatedManifestPath:a.generatedManifestPath,synthesizedOpenPondYaml:a.synthesizedOpenPondYaml,uploadMetadataPath:a.uploadMetadataPath,setupCommands:g,validationCommands:O,materializedAt:new Date().toISOString()}}i(Ae,"materializeHostedProfileAgentSource");async function Me(e){if(e.projectId)try{return await e.client.projects.get(e.projectId,{teamId:e.teamId})}catch{}return e.client.projects.upsert({teamId:e.teamId,name:`OpenPond profile ${e.profileName} ${e.agentId}`,sourceType:"manual",externalId:`openpond-profile:${e.profileProjectId}:${e.profileName}:${e.agentId}`,description:`Materialized OpenPond profile agent ${e.agentId} for hosted Team execution.`,metadata:{source:"openpond_profile_agent_materialization",profileProjectId:e.profileProjectId,profileName:e.profileName,profileAgentId:e.agentId,localHead:e.localHead,hostedHead:e.hostedHead}})}i(Me,"getOrCreateHostedSourceProject");function xe(e,t){let o=t.replace(/\\/g,"/"),n=te.resolve(e,o),a=te.relative(e,n);if(a.startsWith("..")||te.isAbsolute(a))throw new Error(`Profile agent path escapes profile source: ${t}`);return o==="agent/agent.ts"||o.endsWith("/agent.ts")?e:n}i(xe,"resolveProfileAgentSourceRoot");function Ne(e,t){let o=e.actionCatalog.find(n=>n.agentId===t&&(n.sourceActionId==="chat"||n.name==="chat"))??e.actionCatalog.find(n=>n.agentId===t);return{scope:"action",name:typeof o?.sourceActionId=="string"&&o.sourceActionId||typeof o?.name=="string"&&o.name||"chat"}}i(Ne,"hostedEntrypointForProfileAgent");function _e(e,t){return`openpond-profile-${e}-${t}`.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"openpond-profile-agent"}i(_e,"hostedRuntimeAgentSlug");function be(e){let t=v(e),o=v(t?.sourceConfig),n=v(t?.metadata);return I(o?.sourceCommitSha)??I(o?.commitSha)??I(o?.remoteSha)??I(n?.projectSourceUploadCommitSha)??I(n?.sourceCommitSha)??I(t?.templateRemoteSha)}i(be,"sandboxProjectSourceCommitSha");function je(e){let t=v(e),o=v(t?.sourceConfig);return I(o?.sourceRef)??I(o?.branch)??I(t?.gitBranch)??I(t?.defaultBranch)}i(je,"sandboxProjectSourceRef");function v(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}i(v,"record");function I(e){return typeof e=="string"&&e.trim()?e.trim():null}i(I,"text");function Ue(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}i(Ue,"stringArray");import{createHash as Fe,randomUUID as Le}from"node:crypto";function ve(e){let t=e.explicitKey?.trim();if(t)return t;let o=e.sourceHead?.trim()||"unknown-source",n=e.targetProjectId?.trim()||"no-target-project",a=Te(e.input).slice(0,16),l=`profile-push-run:${e.localHead}:${o}:${e.runtimeAgentId}:${n}:${a}`;return e.retry?`${l}:retry:${(e.randomId??Le)()}`:l}i(ve,"buildHostedRunIdempotencyKey");function Te(e){return Fe("sha256").update(ne(e)).digest("hex")}i(Te,"hashStableJson");function ne(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(t=>ne(t)).join(",")}]`:`{${Object.entries(e).sort(([t],[o])=>t.localeCompare(o)).map(([t,o])=>`${JSON.stringify(t)}:${ne(o)}`).join(",")}}`}i(ne,"stableJsonStringify");async function zo(e){let t=await Se({repoPath:f(e,"path")||ee(),profile:f(e,"profile")||"default",template:f(e,"template")||"blank-agent",force:S(e.force)});if(S(e.json)){console.log(JSON.stringify(t,null,2));return}console.log(`Initialized OpenPond profile ${t.activeProfile} at ${t.repoPath}`),console.log(`Profile source: ${t.sourcePath}`)}i(zo,"runOpenPondInitCommand");async function Mo(e,t){let o=t[0]??"current";if(o==="load"){let n=f(e,"path")||t[1];if(!n)throw new Error("usage: openpond profile load --path <dir> [--profile <name>]");let a=await we(n,f(e,"profile")||void 0);if(S(e.json)){console.log(JSON.stringify(a,null,2));return}console.log(`Loaded OpenPond profile ${a.activeProfile} from ${a.repoPath}`);return}if(o==="current"||o==="status"){let n=await x();if(S(e.json)){console.log(JSON.stringify(n,null,2));return}re(n);return}if(o==="diff"){let n=await x();if(S(e.json)){console.log(JSON.stringify({diff:n.diff,profile:n},null,2));return}to(n);return}if(o==="catalog"){let n=await x();if(S(e.json)){console.log(JSON.stringify({catalog:n.catalog,actions:n.actionCatalog,profile:n},null,2));return}no(n);return}if(o==="commit"){await Je(e,t.slice(1));return}if(o==="push"){await De(e);return}if(o==="check"){let n=f(e,"kind")||t[1]||"all";if(!["all","inspect","build","validate","eval"].includes(n))throw new Error("check kind must be one of inspect, build, validate, eval, all");if(n==="all"||n==="validate"){let a=await x();if(!a.sourcePath)throw new Error("No active Profile source to validate.");let l=await Ce(a.sourcePath,new Set(a.actionCatalog.map(h=>h.id)));console.log(`Profile source valid: ${l.workflows} Workflows, ${l.skills} Skills, ${l.evaluations} evaluations, ${l.tasksets} frozen Tasksets.`)}await ke(n);return}if(o==="ensure-hosted"){await He(e);return}if(o==="hosted"){let n=t[1]??"status";if(n==="ensure"){await He(e);return}if(n==="status"||n==="current"){await eo(e);return}throw new Error("usage: openpond profile hosted [status|ensure] --team-id <id> [--json]")}if(o==="agents"){if((t[1]??"list")!=="list")throw new Error("usage: openpond profile agents list [--json]");await oo(e,["list"]);return}throw new Error("usage: openpond profile <status|diff|catalog|commit|push|load|check|agents|hosted|ensure-hosted> [args]")}i(Mo,"runOpenPondProfileCommand");async function Je(e,t){let o=f(e,"message")||f(e,"commitMessage")||t.join(" ").trim()||void 0,n=await ye(o);if(S(e.json)){console.log(JSON.stringify(n,null,2));return}if(!n.committed){console.log("No profile changes to commit."),re(n.state);return}console.log("Committed OpenPond profile changes."),n.stdout.trim()&&console.log(n.stdout.trim()),re(n.state)}i(Je,"runProfileCommitCommand");async function De(e){let t=B(e,"usage: openpond profile push"),o=await x();if(o.error)throw new Error(o.error);if(!o.repoPath||!o.sourcePath||!o.manifestPath)throw new Error("No active OpenPond profile. Run `openpond init`.");if(!o.git?.isRepo)throw new Error("Active OpenPond profile source is not Git-backed. Run `openpond init` or reload a Git-backed profile.");if(!o.git.head)throw new Error("Profile source must have a committed Git head before push. Run `openpond profile commit` first.");if(o.git.dirty)throw new Error("Profile source has uncommitted changes. Run `openpond profile commit` before push.");let n=await G(e),a=S(e.ensureHosted)?await n.profile.ensureHosted({teamId:t}):await n.profile.get({teamId:t});if(!a)throw new Error("No hosted OpenPond profile repo found. Run `openpond profile ensure-hosted --team-id <id>` first, or pass `--ensure-hosted` to push.");let l=S(e.force),h=a.sourceUpload?.sourceCommitSha??null,d=o.hosted?.sourceCommitSha??null;if(d&&h!==d&&!l)throw new Error(["Hosted profile source changed since the last local push.",`Last pushed hosted head: ${d}`,`Current hosted head: ${h??"none"}`,"Inspect hosted changes before pushing, or rerun with --force to overwrite explicitly."].join(`
|
|
2
|
+
import{i as Ie,j as K,k as W,r as $e,s as Re}from"./chunk-36FNNR5N.js";import{m as G}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import"./chunk-NABPZ7AK.js";import"./chunk-BQVB2SPF.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as f,d as B,f as S}from"./chunk-3M53YXEI.js";import{e as ie}from"./chunk-LZPCA6DH.js";import{a as ue}from"./chunk-L3KS6MOV.js";import"./chunk-SFR32TMJ.js";import"./chunk-5KJMFK65.js";import"./chunk-Y3B6ZUE6.js";import{ja as fe}from"./chunk-WLZJOCLA.js";import"./chunk-HIQPGYVH.js";import"./chunk-ZWW227M3.js";import"./chunk-DXA2UHBE.js";import"./chunk-MTP3B2SU.js";import"./chunk-X37KMV27.js";import{G as Pe,I as ke,J as ye,K as R,e as Q,f as he,g as X,h as ge,i as me,j as pe,q as ee,s as Se,t as we,x}from"./chunk-EBOTNBUS.js";import"./chunk-PWKJ5KLZ.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-JFZ6USNQ.js";import"./chunk-6FA3GG5B.js";import"./chunk-G4E3WGLM.js";import{c as ae,sa as le,ta as ce,wa as de}from"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as i}from"./chunk-FTQLQJQV.js";import{readFile as qe}from"node:fs/promises";import L from"node:path";import{promises as A}from"node:fs";import b from"node:path";async function oe(e,t){let o=b.join(e,t),n=await A.lstat(o).catch(l=>{if(l.code==="ENOENT")return null;throw l});if(!n)return[];if(!n.isDirectory()||n.isSymbolicLink())throw new Error(`Profile source directory is not a regular directory: ${t}`);let a=[];for(let l of await A.readdir(o,{withFileTypes:!0})){let h=b.join(o,l.name),d=b.relative(e,h).split(b.sep).join("/");if(l.isSymbolicLink())throw new Error(`Profile source contains a symlink: ${d}`);if(l.isDirectory())a.push(...await oe(e,d));else if(l.isFile())a.push(d);else throw new Error(`Profile source contains a non-regular file: ${d}`)}return a.sort()}i(oe,"sourceFiles");async function Ce(e,t=new Set){let{skills:o,skillCatalog:n}=await ue(e);if(n.error)throw new Error(`Profile Skills: ${n.error}`);for(let s of o)if(s.validationStatus!=="valid")throw new Error(`Profile Skill ${s.name}: ${s.validationMessages.join(" ")}`);let a=new Set(o.map(s=>s.path)),l=[...await oe(e,"workflows"),...await oe(e,"evals")].sort(),h=l.filter(s=>s.startsWith("workflows/")),d=h.some(s=>/^workflows\/[^/]+\/(PROMPT\.md|ACTION\.json)$/.test(s)),u=h.includes("workflows/catalog.json");if(d&&u)throw new Error("Workflow packages and legacy workflows/catalog.json cannot coexist.");let y=d?ie({files:new Map(await Promise.all(h.map(async s=>[s,await A.readFile(b.join(e,s),"utf8")]))),skillPaths:a,actionIds:t}).catalog:u?ae({catalog:JSON.parse(await A.readFile(b.join(e,"workflows/catalog.json"),"utf8")),sourcePaths:a,actionIds:t}):{workflows:[]},$=new Set(y.workflows.map(s=>s.id)),C=l.filter(s=>/^workflows\/[^/]+\/evals\/[^/]+\.json$/.test(s)||/^evals\/definitions\/[^/]+\.json$/.test(s)),w=l.filter(s=>/^evals\/suites\/[^/]+\.json$/.test(s));if(l.includes("evals/catalog.json")&&(C.length||w.length))throw new Error("Evaluation packages and legacy evals/catalog.json cannot coexist.");let j=await Promise.all(C.map(async s=>{let r=le.parse(JSON.parse(await A.readFile(b.join(e,s),"utf8"))),m=/^workflows\/([^/]+)\/evals\//.exec(s)?.[1];if(m&&(r.target.kind!=="workflow"||r.target.workflowId!==m))throw new Error(`Evaluation ${r.id} must target its containing Workflow ${m}.`);return r})),N=await Promise.all(w.map(async s=>ce.parse(JSON.parse(await A.readFile(b.join(e,s),"utf8"))))),_=l.includes("evals/catalog.json")?JSON.parse(await A.readFile(b.join(e,"evals/catalog.json"),"utf8")):{schemaVersion:"openpond.profileEvaluations.v1",definitions:j,suites:N},P=de({catalog:_,workflowIds:$,skillPaths:a,actionIds:t}).catalog,g=l.filter(s=>/^evals\/tasksets\/[^/]+\.json$/.test(s)),O=new Map;for(let s of g){let r=fe(JSON.parse(await A.readFile(b.join(e,s),"utf8"))).taskset;if(s!==`evals/tasksets/${r.contentHash}.json`)throw new Error(`Frozen Taskset file name differs from its content hash: ${s}.`);O.set(r.contentHash,r)}for(let s of P.definitions){let r=s.tasksetRelease.contentHash,m=`evals/tasksets/${r}.json`,H=O.get(r);if(!H)throw new Error(`Evaluation ${s.id} is missing Taskset ${m}.`);if(H.id!==s.tasksetRelease.id||H.contentHash!==r)throw new Error(`Evaluation ${s.id} references a different frozen Taskset.`);let E=new Set(H.tasks.filter(k=>k.split===s.split).map(k=>k.id));for(let k of s.taskIds)if(!E.has(k))throw new Error(`Evaluation ${s.id} references missing Taskset case ${k} in split ${s.split}.`)}return{workflows:y.workflows.length,skills:o.length,evaluations:P.definitions.length,tasksets:O.size}}i(Ce,"checkLocalProfileSource");import te from"node:path";async function Ae(e){if(!e.state.sourcePath)throw new Error("Active OpenPond profile is missing a source path.");let t=e.state.agents.find(s=>s.id===e.agentId);if(!t)throw new Error(`Profile agent not found for hosted materialization: ${e.agentId}`);if(!t.enabled)throw new Error(`Profile agent is disabled: ${e.agentId}`);let o=xe(e.state.sourcePath,t.path),n=await Ie(o),a=await K(o,n.entries),l=W(n,a.entries),h=await Me({client:e.client,teamId:e.teamId,projectId:e.projectId??null,profileProjectId:e.profileProjectId,profileName:e.profileName,agentId:e.agentId,localHead:e.localHead,hostedHead:e.hostedHead}),d=await e.client.projects.uploadSource(h.id,{teamId:e.teamId,entries:l.entries,branch:e.sourceRef,commitMessage:`Materialize OpenPond profile agent ${e.agentId}`}),u=await e.client.projects.sync(d.id,{teamId:e.teamId}),y=be(u)??be(d),$=je(u)??je(d)??e.sourceRef,C=`openpond-profile-agent:${e.profileProjectId}:${e.profileName}:${e.agentId}`,w=(await e.client.agents.list({teamId:e.teamId})).find(s=>s.externalId===C),j=await e.client.agents.upsert({teamId:e.teamId,projectId:u.id,name:t.name||e.agentId,slug:_e(e.profileName,e.agentId),selectedEntrypoint:Ne(e.state,e.agentId),triggerType:"manual",runtimeSource:{mode:"latest_source",...$?{sourceRef:$}:{},...y?{sourceCommitSha:y}:{}},metadata:{...w?.metadata??{},source:"openpond_profile_agent_materialization",profileProjectId:e.profileProjectId,profileName:e.profileName,profileAgentId:e.agentId,profileSourcePath:t.path,localHead:e.localHead,hostedHead:e.hostedHead},externalId:C}),N=v(a.uploadMetadata),_=v(N?.commands),P=v(N?.dependencySetup),g=Ue(P?.commands),O=[I(_?.validate),I(_?.eval)].filter(s=>!!s);return{status:"uploaded",agentId:e.agentId,runtimeAgentId:j.id,projectId:u.id,sourceRoot:o,sourceRef:$,sourceCommitSha:y??null,manifestHash:u.sandboxManifestHash??null,manifestPath:u.sandboxManifestPath??null,manifestSyncedAt:u.sandboxManifestSyncedAt??null,fileCount:l.fileCount,totalBytes:l.totalBytes,generatedManifestPath:a.generatedManifestPath,synthesizedOpenPondYaml:a.synthesizedOpenPondYaml,uploadMetadataPath:a.uploadMetadataPath,setupCommands:g,validationCommands:O,materializedAt:new Date().toISOString()}}i(Ae,"materializeHostedProfileAgentSource");async function Me(e){if(e.projectId)try{return await e.client.projects.get(e.projectId,{teamId:e.teamId})}catch{}return e.client.projects.upsert({teamId:e.teamId,name:`OpenPond profile ${e.profileName} ${e.agentId}`,sourceType:"manual",externalId:`openpond-profile:${e.profileProjectId}:${e.profileName}:${e.agentId}`,description:`Materialized OpenPond profile agent ${e.agentId} for hosted Team execution.`,metadata:{source:"openpond_profile_agent_materialization",profileProjectId:e.profileProjectId,profileName:e.profileName,profileAgentId:e.agentId,localHead:e.localHead,hostedHead:e.hostedHead}})}i(Me,"getOrCreateHostedSourceProject");function xe(e,t){let o=t.replace(/\\/g,"/"),n=te.resolve(e,o),a=te.relative(e,n);if(a.startsWith("..")||te.isAbsolute(a))throw new Error(`Profile agent path escapes profile source: ${t}`);return o==="agent/agent.ts"||o.endsWith("/agent.ts")?e:n}i(xe,"resolveProfileAgentSourceRoot");function Ne(e,t){let o=e.actionCatalog.find(n=>n.agentId===t&&(n.sourceActionId==="chat"||n.name==="chat"))??e.actionCatalog.find(n=>n.agentId===t);return{scope:"action",name:typeof o?.sourceActionId=="string"&&o.sourceActionId||typeof o?.name=="string"&&o.name||"chat"}}i(Ne,"hostedEntrypointForProfileAgent");function _e(e,t){return`openpond-profile-${e}-${t}`.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"openpond-profile-agent"}i(_e,"hostedRuntimeAgentSlug");function be(e){let t=v(e),o=v(t?.sourceConfig),n=v(t?.metadata);return I(o?.sourceCommitSha)??I(o?.commitSha)??I(o?.remoteSha)??I(n?.projectSourceUploadCommitSha)??I(n?.sourceCommitSha)??I(t?.templateRemoteSha)}i(be,"sandboxProjectSourceCommitSha");function je(e){let t=v(e),o=v(t?.sourceConfig);return I(o?.sourceRef)??I(o?.branch)??I(t?.gitBranch)??I(t?.defaultBranch)}i(je,"sandboxProjectSourceRef");function v(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}i(v,"record");function I(e){return typeof e=="string"&&e.trim()?e.trim():null}i(I,"text");function Ue(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}i(Ue,"stringArray");import{createHash as Fe,randomUUID as Le}from"node:crypto";function ve(e){let t=e.explicitKey?.trim();if(t)return t;let o=e.sourceHead?.trim()||"unknown-source",n=e.targetProjectId?.trim()||"no-target-project",a=Te(e.input).slice(0,16),l=`profile-push-run:${e.localHead}:${o}:${e.runtimeAgentId}:${n}:${a}`;return e.retry?`${l}:retry:${(e.randomId??Le)()}`:l}i(ve,"buildHostedRunIdempotencyKey");function Te(e){return Fe("sha256").update(ne(e)).digest("hex")}i(Te,"hashStableJson");function ne(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(t=>ne(t)).join(",")}]`:`{${Object.entries(e).sort(([t],[o])=>t.localeCompare(o)).map(([t,o])=>`${JSON.stringify(t)}:${ne(o)}`).join(",")}}`}i(ne,"stableJsonStringify");async function zo(e){let t=await Se({repoPath:f(e,"path")||ee(),profile:f(e,"profile")||"default",template:f(e,"template")||"blank-agent",force:S(e.force)});if(S(e.json)){console.log(JSON.stringify(t,null,2));return}console.log(`Initialized OpenPond profile ${t.activeProfile} at ${t.repoPath}`),console.log(`Profile source: ${t.sourcePath}`)}i(zo,"runOpenPondInitCommand");async function Mo(e,t){let o=t[0]??"current";if(o==="load"){let n=f(e,"path")||t[1];if(!n)throw new Error("usage: openpond profile load --path <dir> [--profile <name>]");let a=await we(n,f(e,"profile")||void 0);if(S(e.json)){console.log(JSON.stringify(a,null,2));return}console.log(`Loaded OpenPond profile ${a.activeProfile} from ${a.repoPath}`);return}if(o==="current"||o==="status"){let n=await x();if(S(e.json)){console.log(JSON.stringify(n,null,2));return}re(n);return}if(o==="diff"){let n=await x();if(S(e.json)){console.log(JSON.stringify({diff:n.diff,profile:n},null,2));return}to(n);return}if(o==="catalog"){let n=await x();if(S(e.json)){console.log(JSON.stringify({catalog:n.catalog,actions:n.actionCatalog,profile:n},null,2));return}no(n);return}if(o==="commit"){await Je(e,t.slice(1));return}if(o==="push"){await De(e);return}if(o==="check"){let n=f(e,"kind")||t[1]||"all";if(!["all","inspect","build","validate","eval"].includes(n))throw new Error("check kind must be one of inspect, build, validate, eval, all");if(n==="all"||n==="validate"){let a=await x();if(!a.sourcePath)throw new Error("No active Profile source to validate.");let l=await Ce(a.sourcePath,new Set(a.actionCatalog.map(h=>h.id)));console.log(`Profile source valid: ${l.workflows} Workflows, ${l.skills} Skills, ${l.evaluations} evaluations, ${l.tasksets} frozen Tasksets.`)}await ke(n);return}if(o==="ensure-hosted"){await He(e);return}if(o==="hosted"){let n=t[1]??"status";if(n==="ensure"){await He(e);return}if(n==="status"||n==="current"){await eo(e);return}throw new Error("usage: openpond profile hosted [status|ensure] --team-id <id> [--json]")}if(o==="agents"){if((t[1]??"list")!=="list")throw new Error("usage: openpond profile agents list [--json]");await oo(e,["list"]);return}throw new Error("usage: openpond profile <status|diff|catalog|commit|push|load|check|agents|hosted|ensure-hosted> [args]")}i(Mo,"runOpenPondProfileCommand");async function Je(e,t){let o=f(e,"message")||f(e,"commitMessage")||t.join(" ").trim()||void 0,n=await ye(o);if(S(e.json)){console.log(JSON.stringify(n,null,2));return}if(!n.committed){console.log("No profile changes to commit."),re(n.state);return}console.log("Committed OpenPond profile changes."),n.stdout.trim()&&console.log(n.stdout.trim()),re(n.state)}i(Je,"runProfileCommitCommand");async function De(e){let t=B(e,"usage: openpond profile push"),o=await x();if(o.error)throw new Error(o.error);if(!o.repoPath||!o.sourcePath||!o.manifestPath)throw new Error("No active OpenPond profile. Run `openpond init`.");if(!o.git?.isRepo)throw new Error("Active OpenPond profile source is not Git-backed. Run `openpond init` or reload a Git-backed profile.");if(!o.git.head)throw new Error("Profile source must have a committed Git head before push. Run `openpond profile commit` first.");if(o.git.dirty)throw new Error("Profile source has uncommitted changes. Run `openpond profile commit` before push.");let n=await G(e),a=S(e.ensureHosted)?await n.profile.ensureHosted({teamId:t}):await n.profile.get({teamId:t});if(!a)throw new Error("No hosted OpenPond profile repo found. Run `openpond profile ensure-hosted --team-id <id>` first, or pass `--ensure-hosted` to push.");let l=S(e.force),h=a.sourceUpload?.sourceCommitSha??null,d=o.hosted?.sourceCommitSha??null;if(d&&h!==d&&!l)throw new Error(["Hosted profile source changed since the last local push.",`Last pushed hosted head: ${d}`,`Current hosted head: ${h??"none"}`,"Inspect hosted changes before pushing, or rerun with --force to overwrite explicitly."].join(`
|
|
3
3
|
`));let u=f(e,"hostedSourceAgentId"),y=S(e.hostedSourceChecks),$=S(e.publishHostedSource),C=f(e,"hostedRunAgentId"),w=u||(y||$?C:null),j=JSON.parse(await qe(o.manifestPath,"utf8")),N=Ge(j),_=j.profiles[o.activeProfile??j.defaultProfile]?.path??"profiles/default",P=await Ke({state:o,hostedSourceAgentId:w}),g=await n.profile.push({teamId:t,entries:P.entries,branch:o.git.branch??"main",commitMessage:f(e,"commitMessage")||f(e,"message")||`Push OpenPond profile ${o.activeProfile??"default"} at ${o.git.shortHead??o.git.head}`,expectedSourceCommitSha:h,localHeadSha:o.git.head,manifest:N,sourcePath:_,agents:o.agents.map(c=>({id:c.id,path:c.path,enabled:c.enabled}))}),O=new Date().toISOString(),s=o.hosted?.lastPushedLocalHead===o.git.head&&o.hosted?.sourceCommitSha===g.sourceUpload.sourceCommitSha,r={status:"pushed",promotionStatus:s?o.hosted?.promotionStatus??"uploaded":"uploaded",hostedRunStatus:s?o.hosted?.hostedRunStatus??"not_started":"not_started",pushedAt:O,teamId:t,projectId:g.profile.project.id,localHead:o.git.head,hostedHead:g.sourceUpload.sourceCommitSha,sourceRef:g.sourceUpload.sourceRef,hostedRunAgentId:s?o.hosted?.hostedRunAgentId??null:null,hostedRunId:s?o.hosted?.hostedRunId??null:null,hostedRunAt:s?o.hosted?.hostedRunAt??null:null,hostedSourceMaterialization:s?o.hosted?.hostedSourceMaterialization??null:null,hostedSourceCheck:s?o.hosted?.hostedSourceCheck??null:null,hostedPublish:s?o.hosted?.hostedPublish??null:null,hostedRun:s?o.hosted?.hostedRun??null:null};await R(r);let m=w??Ve(o,C),H=Re(e.hostedSourceDispatch,"hosted-source-dispatch")??"coding_core",E=null,k=null,Z=null;if(w&&(y||$||u))try{let c=await Ae({client:n,teamId:t,profileProjectId:g.profile.project.id,profileName:o.activeProfile??j.defaultProfile,state:o,agentId:w,sourceRef:g.sourceUpload.sourceRef??o.git.branch??"main",localHead:o.git.head,hostedHead:g.sourceUpload.sourceCommitSha,projectId:f(e,"hostedSourceProjectId")||(o.hosted?.hostedSourceMaterialization?.agentId===w?o.hosted.hostedSourceMaterialization.projectId:null)});r={...r,promotionStatus:"hosted_source_materialized",hostedSourceMaterialization:c},m=c.runtimeAgentId??w,await R(r)}catch(c){let p=c instanceof Error?c.message:String(c);throw r={...r,promotionStatus:"hosted_source_materialize_failed",hostedSourceMaterialization:{status:"failed",agentId:w,projectId:f(e,"hostedSourceProjectId")??null,error:p},error:p},await R(r),new Error(`Hosted source materialization failed after push: ${p}`)}if(y||$){if(!w)throw new Error("--hosted-source-agent-id or --hosted-run-agent-id is required for hosted source checks or publish.");if(!m)throw new Error("Unable to resolve the hosted runtime agent for source checks.");try{if(E=await n.agents.sourceDeployPlan(m,{teamId:t}),y){let c=r.hostedSourceMaterialization?.sourceRef??g.sourceUpload.sourceRef,p=r.hostedSourceMaterialization?.sourceCommitSha??g.sourceUpload.sourceCommitSha;if(k=await n.agents.requestSourceChecks(m,{teamId:t,...c?{sourceRef:c}:{},...p?{baseSha:p}:{},checkKind:$e(f(e,"hostedCheckKind")||f(e,"checkKind"))??"all",dispatch:H,metadata:{source:"openpond_profile_push_checks",localHead:o.git.head,hostedHead:g.sourceUpload.sourceCommitSha,materializedProjectId:r.hostedSourceMaterialization?.projectId??null,materializedSourceCommitSha:r.hostedSourceMaterialization?.sourceCommitSha??null,sourceRef:c,dispatch:H}}),k.dispatchResult?.status==="failed")throw new Error(k.dispatchResult.error??"hosted_source_check_dispatch_failed");if(k.dispatchResult?.status==="completed"){let J=Y(k.sourceCheckStatus);Ze(J)&&(await Ye({client:n,teamId:t,runtimeAgentId:m,sourceRef:c,sourceCommitSha:p,validatedAt:new Date().toISOString()}),E=await n.agents.sourceDeployPlan(m,{teamId:t}))}}r={...r,promotionStatus:y?"hosted_source_check_pending":r.promotionStatus,hostedSourceCheck:X({agentId:m,status:y?"requested":"deploy_plan_ready",deployPlan:E,checkResult:k})},await R(r)}catch(c){let p=c instanceof Error?c.message:String(c);throw r={...r,promotionStatus:"hosted_source_check_failed",hostedSourceCheck:X({agentId:m,status:"failed",deployPlan:E,checkedAt:new Date().toISOString(),error:p}),error:p},await R(r),new Error(`Hosted source check failed after push: ${p}`)}}if($){if(!w)throw new Error("--hosted-source-agent-id or --hosted-run-agent-id is required for hosted source publish.");if(!m)throw new Error("Unable to resolve the hosted runtime agent for source publish.");try{let c=f(e,"expectedManifestHash")||r.hostedSourceCheck?.manifestHash||E?.source.manifestHash||void 0;Z=await n.agents.publishSource(m,{teamId:t,...c?{expectedManifestHash:c}:{},...r.hostedSourceMaterialization?.sourceCommitSha??g.sourceUpload.sourceCommitSha?{expectedSourceCommitSha:r.hostedSourceMaterialization?.sourceCommitSha??g.sourceUpload.sourceCommitSha}:{}}),r={...r,promotionStatus:"hosted_source_published",hostedPublish:ge({agentId:m,publishResult:Z})},await R(r)}catch(c){let p=c instanceof Error?c.message:String(c);throw r={...r,promotionStatus:"hosted_source_publish_failed",hostedPublish:{status:"failed",agentId:m,error:p},error:p},await R(r),new Error(`Hosted source publish failed after push: ${p}`)}}let z=null;if(C){let c=m||C,p=new Date().toISOString(),J=so(e,"hostedRunInput")??{prompt:"hello",channel:"openpond_chat"},D=f(e,"hostedRunConversationId")||f(e,"conversationId"),U=f(e,"hostedRunTargetProjectId"),se=ve({explicitKey:f(e,"hostedRunIdempotencyKey"),retry:S(e.hostedRunRetry),localHead:o.git.head,sourceHead:r.hostedSourceMaterialization?.sourceCommitSha??g.sourceUpload.sourceCommitSha,runtimeAgentId:c,targetProjectId:U,input:J});await R({...r,promotionStatus:"hosted_run_pending",hostedRunStatus:"running",hostedRunAgentId:c,hostedRunAt:p});try{z=await n.agents.run(c,{teamId:t,...D?{conversationId:D}:{},...U?{targetProjectId:U}:{},...U?{targetProject:{id:U}}:{},idempotencyKey:se,input:J,metadata:{source:"openpond_profile_push_run",...D?{conversationId:D}:{},targetProjectId:U||null,localHead:o.git.head,hostedHead:g.sourceUpload.sourceCommitSha,hostedRunIdempotencyKey:se,hostedRunRetry:S(e.hostedRunRetry),materializedProjectId:r.hostedSourceMaterialization?.projectId??null,materializedSourceCommitSha:r.hostedSourceMaterialization?.sourceCommitSha??null,sourceRef:r.hostedSourceMaterialization?.sourceRef??g.sourceUpload.sourceRef,publishedSnapshotId:r.hostedPublish?.snapshotId??null,manifestHash:r.hostedPublish?.manifestHash??r.hostedSourceCheck?.manifestHash??null},runtimeSourcePolicy:$?{requirePublishedSnapshot:!0,source:"diagnostic"}:{allowLatestSource:!0,source:"diagnostic"}});let F=me({agentId:c,runResult:z}),M=pe(F);await R({...r,promotionStatus:M==="passed"?"hosted_run_passed":M==="failed"?"hosted_run_failed":"hosted_run_pending",hostedRunStatus:M,hostedRunAgentId:c,hostedRunId:z.run.id,hostedRunAt:z.run.createdAt??p,hostedRun:F})}catch(F){let M=F instanceof Error?F.message:String(F);throw await R({...r,promotionStatus:"hosted_run_failed",hostedRunStatus:"failed",hostedRunAgentId:c,hostedRunAt:new Date().toISOString(),hostedRun:{status:"failed",agentId:c,error:M},error:M}),new Error(`Hosted invocation failed to start after push: ${M}`)}}if(S(e.json)){console.log(JSON.stringify({...g,uploaded:Be(P),hostedSourceMaterialization:r.hostedSourceMaterialization??null,hostedSourceChecks:k,hostedSourcePublish:Z,hostedRun:z},null,2));return}console.log(`Pushed OpenPond profile ${o.activeProfile??"default"} to hosted profile repo.`),console.log(`Project id: ${g.profile.project.id}`),console.log(`Local head: ${o.git.head}`),console.log(`Hosted source commit: ${g.sourceUpload.sourceCommitSha??"unknown"}`),console.log(`Uploaded ${P.fileCount} file(s), ${P.totalBytes} byte(s) via ${P.transport.mode} (limits: ${P.limits.maxFiles} files, ${P.limits.maxFileBytes} bytes/file, ${P.limits.maxTotalBytes} bytes total).`),console.log(z?`Hosted invocation: running ${z.run.id}`:"Hosted invocation: not started"),r.hostedSourceMaterialization&&console.log(`Hosted materialized: ${r.hostedSourceMaterialization.status}`+(r.hostedSourceMaterialization.projectId?` ${r.hostedSourceMaterialization.projectId}`:"")+(r.hostedSourceMaterialization.sourceCommitSha?` ${r.hostedSourceMaterialization.sourceCommitSha}`:"")),r.hostedSourceCheck&&console.log(`Hosted source checks: ${r.hostedSourceCheck.status}`),r.hostedPublish&&console.log(`Hosted publish: ${r.hostedPublish.status}`+(r.hostedPublish.snapshotId?` ${r.hostedPublish.snapshotId}`:"")),console.log(`Uploaded files: ${P.fileCount}`)}i(De,"runProfilePushCommand");function Be(e){return{fileCount:e.fileCount,totalBytes:e.totalBytes,limits:e.limits,transport:e.transport}}i(Be,"summarizeProfileSourceUpload");function Ge(e){return{...e,profiles:Object.fromEntries(Object.entries(e.profiles).map(([t,o])=>[t,{path:o.path,defaultAgent:o.defaultAgent??"default",enabledAgents:o.enabledAgents??[]}]))}}i(Ge,"normalizeHostedProfileManifest");async function Ke(e){let t=e.state.repoPath;if(!t)throw new Error("Active OpenPond profile is missing a repository path.");let o=await he(t);if(!e.hostedSourceAgentId)return o;if(!e.state.sourcePath)throw new Error("Active OpenPond profile is missing a source path.");let n=e.state.agents.find(d=>d.id===e.hostedSourceAgentId);if(!n)throw new Error(`Profile agent not found for hosted source upload: ${e.hostedSourceAgentId}`);let a=We(e.state.sourcePath,n.path),l=L.relative(t,a).replace(/\\/g,"/");if(l.startsWith("..")||L.isAbsolute(l))throw new Error(`Profile agent path escapes profile repo: ${n.path}`);let h=await K(a,[]);return h.entries.length===0?o:W(o,h.entries.map(d=>({...d,path:l?`${l}/${d.path}`:d.path})))}i(Ke,"collectProfileSourceUploadForPush");function We(e,t){let o=t.replace(/\\/g,"/"),n=L.resolve(e,o),a=L.relative(e,n);if(a.startsWith("..")||L.isAbsolute(a))throw new Error(`Profile agent path escapes profile source: ${t}`);return o==="agent/agent.ts"||o.endsWith("/agent.ts")?e:n}i(We,"resolveProfileAgentSourceRoot");function Y(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}i(Y,"record");function T(e){return typeof e=="string"&&e.trim()?e.trim():null}i(T,"text");function Ve(e,t){if(!t)return null;let o=e.hosted?.hostedSourceMaterialization;return o?.agentId===t&&o.runtimeAgentId?o.runtimeAgentId:t}i(Ve,"resolveHostedRuntimeAgentIdForRun");async function Ye(e){!e.sourceRef||!e.sourceCommitSha||await e.client.agents.update(e.runtimeAgentId,{teamId:e.teamId,runtimeSource:{mode:"latest_source",sourceRef:e.sourceRef,sourceCommitSha:e.sourceCommitSha,buildStatus:"succeeded",validationStatus:"passed",validatedAt:e.validatedAt}})}i(Ye,"bindValidatedHostedRuntimeSource");function Ze(e){if(!e)return!1;let t=T(e.finalResultState)?.toLowerCase();if(t&&t!=="completed"&&!Ee(t))return!1;let o=Array.isArray(e.checkRuns)?e.checkRuns.map(Y).filter(u=>!!u):[];if(o.some(Qe))return!1;let n=o.some(u=>V(u).includes("build")&&q(u)),a=q(Y(e.validation))||o.some(u=>V(u).includes("validate")&&q(u)),l=Y(e.eval),d=!((T(e.requestedCheckKind)??"all")==="all"||(T(e.requestedCheckKind)??"")==="eval"||!!l||o.some(u=>V(u).includes("eval")))||q(l)||o.some(u=>V(u).includes("eval")&&q(u));return n&&a&&d}i(Ze,"sourceCheckStatusPassed");function V(e){return(T(e.command)??"").toLowerCase()}i(V,"checkRunCommand");function Qe(e){let t=e.passed;if(typeof t=="boolean")return!t;let o=e.exitCode;if(typeof o=="number"&&o!==0)return!0;let n=T(e.status)?.toLowerCase();return!!(n&&Xe(n))}i(Qe,"checkRunFailed");function q(e){if(!e)return!1;if(typeof e.passed=="boolean")return e.passed;let t=Oe(e.failed)??Oe(e.failedCount);if(t!==null&&t>0)return!1;let o=e.exitCode;if(typeof o=="number")return o===0;let n=T(e.status)?.toLowerCase();return!!(n&&Ee(n))}i(q,"checkEvidencePassed");function Oe(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:null}return null}i(Oe,"numericEvidence");function Ee(e){return e==="passed"||e==="succeeded"||e==="success"}i(Ee,"passingStatus");function Xe(e){return e==="failed"||e==="failure"||e==="cancelled"}i(Xe,"failingStatus");async function eo(e){let t=B(e,"usage: openpond profile hosted status"),n=await(await G(e)).profile.get({teamId:t});if(S(e.json)){console.log(JSON.stringify({profile:n},null,2));return}if(!n){console.log("No hosted OpenPond profile repo found."),console.log("Run `openpond profile ensure-hosted --team-id <id>` to create one.");return}ze(n)}i(eo,"runHostedProfileStatusCommand");async function He(e){let t=B(e,"usage: openpond profile ensure-hosted"),n=await(await G(e)).profile.ensureHosted({teamId:t});if(S(e.json)){console.log(JSON.stringify({profile:n},null,2));return}ze(n)}i(He,"runHostedProfileEnsureCommand");async function oo(e,t){if((t[0]??"list")!=="list")throw new Error("usage: openpond agents list [--json]");let n=await x();if(n.error)throw new Error(n.error);if(S(e.json)){console.log(JSON.stringify({agents:n.agents,profile:n},null,2));return}if(n.mode==="none"){console.log("No active OpenPond profile. Run `openpond init`.");return}if(n.agents.length===0){console.log(`No agents found in ${n.activeProfile}.`);return}for(let a of n.agents)console.log(`${a.id} ${a.enabled?"enabled":"disabled"} ${a.path}`)}i(oo,"runOpenPondAgentsCommand");async function xo(e,t,o){let n=f(t,"cwd"),a=[...o,...ro(t,new Set(["cwd","account","profile","handle","baseUrl"]))];await Pe({command:e,cwd:n?L.resolve(n):void 0,args:a,inherit:!0})}i(xo,"runOpenPondProfileSdkAlias");function re(e){if(e.mode==="none"){console.log("No active OpenPond profile."),console.log(`Default location: ${ee()}`);return}if(console.log(`Mode: ${e.mode}`),console.log(`Repo: ${e.repoPath}`),console.log(`Profile: ${e.activeProfile}`),console.log(`Source: ${e.sourcePath??"missing"}`),console.log(`State: ${e.summary.message}`),e.git&&(console.log(`Git: ${e.git.branch??"detached"} ${e.git.shortHead??"no-head"}${e.git.dirty?" dirty":" clean"}`),e.git.upstream&&console.log(`Upstream: ${e.git.upstream} ahead ${e.git.ahead??"?"} behind ${e.git.behind??"?"}`)),(e.hosted?.projectId||e.hosted?.sourceCommitSha)&&(console.log(`Hosted: ${e.hosted.projectId??"unbound"} ${e.hosted.sourceCommitSha??"no-source-head"}`),e.hosted.hostedSourceMaterialization&&console.log(`Hosted materialized: ${e.hosted.hostedSourceMaterialization.status}`+(e.hosted.hostedSourceMaterialization.agentId?` ${e.hosted.hostedSourceMaterialization.agentId}`:"")+(e.hosted.hostedSourceMaterialization.sourceCommitSha?` ${e.hosted.hostedSourceMaterialization.sourceCommitSha}`:"")),e.hosted.hostedSourceCheck&&console.log(`Hosted checks: ${e.hosted.hostedSourceCheck.status}`+(e.hosted.hostedSourceCheck.sandboxId?` sandbox ${e.hosted.hostedSourceCheck.sandboxId}`:"")),e.hosted.hostedPublish&&console.log(`Hosted publish: ${e.hosted.hostedPublish.status}`+(e.hosted.hostedPublish.snapshotId?` ${e.hosted.hostedPublish.snapshotId}`:"")),e.hosted.hostedRun&&console.log(`Hosted run: ${e.hosted.hostedRun.status}`+(e.hosted.hostedRun.runId?` ${e.hosted.hostedRun.runId}`:"")+(e.hosted.hostedRun.runtimeId?` runtime ${e.hosted.hostedRun.runtimeId}`:""))),console.log(`Catalog: ${e.catalog.actionCount} action(s)${e.catalog.stale?" stale":""}`),console.log(`Setup gate: ${e.setupGate.status} (${e.setupGate.blockingCount} blocking, ${e.setupGate.optionalMissingCount} optional missing)`),e.summary.defaultAction&&console.log(`Default action: ${e.summary.defaultAction}`),e.setupGate.blockingRequirements.length>0){console.log("Blocking setup:");for(let t of e.setupGate.blockingRequirements.slice(0,10))console.log(` ${Q(t)}`);e.setupGate.blockingRequirements.length>10&&console.log(` ... ${e.setupGate.blockingRequirements.length-10} more`)}if(!e.summary.checkFresh&&e.summary.checkStaleReason?console.log(`Checks: stale - ${e.summary.checkStaleReason}`):e.summary.checkFresh&&console.log("Checks: fresh"),e.lastCheck&&console.log(`Last check: ${e.lastCheck.command} ${e.lastCheck.status} at ${e.lastCheck.checkedAt}`),e.error&&console.log(`Error: ${e.error}`),e.agents.length>0){console.log("Agents:");for(let t of e.agents)console.log(` ${t.id} (${t.enabled?"enabled":"disabled"}) ${t.path}`)}if(e.skills.length>0){console.log("Skills:");for(let t of e.skills){let o=t.validationStatus==="valid"?"valid":t.validationStatus;console.log(` ${t.name} (${o}) ${t.path}`)}}}i(re,"printProfileState");function to(e){if(e.mode==="none"){console.log("No active OpenPond profile.");return}console.log(`Profile: ${e.activeProfile}`),console.log(`State: ${e.summary.message}`);let t=[["Changed agents",e.diff.changedAgents],["New agents",e.diff.newAgents],["Deleted agents",e.diff.deletedAgents],["Changed skills",e.diff.changedSkills],["Changed actions",e.diff.changedActions],["Changed extensions",e.diff.changedExtensions],["Setup changes",e.diff.setupChanges],["Env requirement changes",e.diff.envRequirementChanges]];for(let[o,n]of t)n.length!==0&&console.log(`${o}: ${n.join(", ")}`);if(e.diff.files.length===0){console.log("No source changes.");return}console.log("Files:");for(let o of e.diff.files)console.log(` ${o.status.padEnd(2)} ${o.path}`)}i(to,"printProfileDiff");function no(e){if(e.mode==="none"){console.log("No active OpenPond profile.");return}if(console.log(`Profile: ${e.activeProfile}`),console.log(`Catalog: ${e.catalog.actionCount} action(s)${e.catalog.stale?" stale":""}`),console.log(`Setup gate: ${e.setupGate.status} (${e.setupGate.blockingCount} blocking, ${e.setupGate.optionalMissingCount} optional missing)`),e.catalog.generatedAt&&console.log(`Generated at: ${e.catalog.generatedAt}`),e.catalog.error&&console.log(`Catalog error: ${e.catalog.error}`),e.actionCatalog.length===0){console.log("No catalog actions found. Run `openpond inspect` or `openpond build`.");return}for(let o of e.actionCatalog){let n=o.label??o.name??o.id,a=o.visibility??"default",l=e.setupGate.blockingRequirements.filter(d=>d.actionId===o.id),h=l.length?`setup_required:${l.map(d=>d.label).join(",")}`:"setup_ready";console.log(`${o.id} ${a} ${h} ${n}`)}let t=e.setupGate.blockingRequirements.filter(o=>o.actionId===null);if(t.length>0){console.log("Source setup blockers:");for(let o of t)console.log(` ${Q(o)}`)}}i(no,"printProfileCatalog");function ze(e){if(console.log(`Hosted profile repo: ${e.project.name}`),console.log(`Project id: ${e.project.id}`),console.log(`Role: ${e.project.role??"profile"}`),console.log(`Default profile: ${e.defaultProfile}`),console.log(`Source path: ${e.sourcePath}`),console.log(`Seed status: ${e.seedStatus}`),e.sourceUpload?.sourceRef&&console.log(`Source ref: ${e.sourceUpload.sourceRef}`),e.sourceUpload?.sourceCommitSha&&console.log(`Source commit: ${e.sourceUpload.sourceCommitSha}`),e.seededAt&&console.log(`Seeded at: ${e.seededAt}`),e.agents.length>0){console.log("Agents:");for(let t of e.agents)console.log(` ${t.id} (${t.enabled?"enabled":"disabled"}) ${t.path}`)}}i(ze,"printHostedProfileSummary");function ro(e,t){let o=[],n=new Set(["force","json"]);for(let[a,l]of Object.entries(e)){if(t.has(a))continue;let h=`--${a.replace(/[A-Z]/g,d=>`-${d.toLowerCase()}`)}`;if(l===!0||n.has(a)&&l==="true")o.push(h);else{if(n.has(a)&&l==="false")continue;typeof l=="string"&&o.push(h,l)}}return o}i(ro,"optionArgs");function so(e,t){let o=f(e,t);if(!o)return null;let n=JSON.parse(o);if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`--${t} must be a JSON object`);return n}i(so,"parseJsonObjectOption");export{Ke as collectProfileSourceUploadForPush,oo as runOpenPondAgentsCommand,zo as runOpenPondInitCommand,Mo as runOpenPondProfileCommand,xo as runOpenPondProfileSdkAlias};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as b,b as Y,c as F,d as H,e as W,f as z,g as X,h as E,i as y,j as v,k as C,l as Z,m as ee,n as A,o as te,p as _,q as j,r as re,s as ne,t as x,u as M,v as R,w as J,x as N,y as U,z as T}from"./chunk-36FNNR5N.js";import{m as h,n as I,v as P}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import"./chunk-FGOTSCSE.js";import"./chunk-E2S2EMYQ.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as u,d,e as w,f as S}from"./chunk-3M53YXEI.js";import"./chunk-PWKJ5KLZ.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-JFZ6USNQ.js";import"./chunk-6FA3GG5B.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as g}from"./chunk-FTQLQJQV.js";function k(e){let o=e.gitRepo?`${e.gitOwner??"_"}/${e.gitRepo}`:e.internalRepoPath??e.templateRepoUrl??e.normalizedSourceIdentity;return[e.id,e.status,e.sourceType,e.name,o].join(" ")}g(k,"formatProjectLine");function L(e){let o=e.selectedEntrypoint.name?`${e.selectedEntrypoint.scope}:${e.selectedEntrypoint.name}`:e.selectedEntrypoint.scope,i=e.runtimeSource?[e.runtimeSource.mode,e.runtimeSource.publishedSnapshotName??e.runtimeSource.publishedSnapshotId??e.runtimeSource.sourceRef].filter(a=>!!a).join(":"):"latest_source";return[e.id,e.status,e.triggerType,e.defaultWorkflowMode,i,o,e.name].join(" ")}g(L,"formatAgentLine");async function B(e,o,i){let a=i[1]?.trim(),t=i[2]?.trim(),n="usage: agent source <deploy-plan|checks|manifest-snapshots|setup|publish> <agent-id> --team-id <id>",r=d(o,n);if(!a||!t)throw new Error(n);if(a==="deploy-plan"){let s=await e.agents.sourceDeployPlan(t,{teamId:r});console.log(JSON.stringify({deployPlan:s},null,2));return}if(a==="manifest-snapshots"){let s=await e.agents.manifestSnapshots(t,{teamId:r,limit:x(o.limit)});console.log(JSON.stringify({manifestSnapshots:s},null,2));return}if(a==="checks"){let s=await e.agents.requestSourceChecks(t,M(r,o));console.log(JSON.stringify(s,null,2));return}if(a==="setup"){let s=typeof o.provider=="string"?o.provider.trim():"",l=typeof o.allowedActions=="string"?o.allowedActions.split(",").map(c=>c.trim()).filter(Boolean):[];if(!s||l.length===0)throw new Error(`${n}; setup requires --provider and --allowed-actions`);let p=await e.agents.configureSourceSetup(t,{teamId:r,integrationBindings:[{provider:s,mode:"connected",connectionMode:"member_connection",grantPolicy:"read_only",allowedActions:l,enabled:!0}]});console.log(JSON.stringify(p,null,2));return}if(a==="publish"){let s=await e.agents.publishSource(t,R(r,o));console.log(JSON.stringify(s,null,2));return}throw new Error(n)}g(B,"runAgentSourceWorkflow");import G from"node:path";var Q=new Set(["inspect","build","validate","eval","traces"]);function $(e,o){return Q.has(e)?!0:e==="run"&&!u(o,"teamId")}g($,"shouldDelegateLocalAgentSdkCommand");async function q(e,o){let i=o[0]||"inspect",a=G.resolve(u(e,"cwd")||u(e,"path")||"."),t=[i,...o.slice(1),"--cwd",a];S(e.json)&&t.push("--json"),D(t,e,"input","input"),D(t,e,"inputFile","input-file");let n=b(a),r=await P(n.command,[...n.args,...t],{cwd:a,inherit:!0});r.code!==0&&(process.exitCode=r.code??1)}g(q,"runLocalAgentSdkCommand");function D(e,o,i,a){let t=u(o,i);t&&e.push(`--${a}`,t)}g(D,"appendForwardedOption");async function Oe(e,o){let i=o[0]||"list";if($(i,e)){await q(e,o);return}let a=await h(e);if(i==="list"){let t=d(e,"usage: agent list"),n=await a.agents.list({teamId:t});if(S(e.json)){console.log(JSON.stringify({agents:n},null,2));return}if(n.length===0){console.log("no sandbox agents found");return}for(let r of n)console.log(L(r));return}if(i==="create"||i==="upsert"){let t=await a.agents.upsert(U(e));console.log(JSON.stringify({agent:t},null,2));return}if(i==="get"){let t=o[1]?.trim(),n=d(e,"usage: agent get <agentId>");if(!t)throw new Error("usage: agent get <agentId> --team-id <id>");let r=await a.agents.get(t,{teamId:n});console.log(JSON.stringify({agent:r},null,2));return}if(i==="run"){let t=o[1]?.trim(),n=d(e,"usage: agent run <agentId>");if(!t)throw new Error("usage: agent run <agentId> --team-id <id>");let r=u(e,"idempotencyKey"),s=u(e,"conversationId"),l=u(e,"targetProjectId"),p=A(e.triggerType),c=I(e.workflowMode),m=w(e,"input","input"),f=w(e,"metadata","metadata"),O=j(e),K=await a.agents.run(t,{teamId:n,...s?{conversationId:s}:{},...r?{idempotencyKey:r}:{},...l?{targetProjectId:l}:{},...l?{targetProject:{id:l}}:{},...p?{triggerType:p}:{},...c?{workflowMode:c}:{},...m?{input:m}:{},...f?{metadata:f}:{},...O?{runtimeSourcePolicy:O}:{}});console.log(JSON.stringify(K,null,2));return}if(i==="bind-runtime-source"||i==="bind-source"){let t=o[1]?.trim(),n=d(e,"usage: agent bind-source <agentId>");if(!t)throw new Error("usage: agent bind-source <agentId> --team-id <id> --source-mode latest_source|published_snapshot|auto");let r=_(e);if(!r?.mode)throw new Error("usage: agent bind-source <agentId> --team-id <id> --source-mode latest_source|published_snapshot|auto");let s=await a.agents.update(t,{teamId:n,runtimeSource:r});console.log(JSON.stringify({agent:s,agentSource:s.runtimeSource},null,2));return}if(i==="run-test"){let t=o[1]?.trim(),n=d(e,"usage: agent run-test <agentId>");if(!t)throw new Error("usage: agent run-test <agentId> --team-id <id>");let r=u(e,"idempotencyKey"),s=u(e,"conversationId"),l=u(e,"targetProjectId"),p=w(e,"input","input"),c=w(e,"metadata","metadata"),m=I(e.workflowMode),f=await a.agents.run(t,{teamId:n,...s?{conversationId:s}:{},...r?{idempotencyKey:r}:{},...l?{targetProjectId:l}:{},...l?{targetProject:{id:l}}:{},...m?{workflowMode:m}:{},...p?{input:p}:{},metadata:{...c??{},source:"agent_run_test"},runtimeSourcePolicy:j(e,"diagnostic")});console.log(JSON.stringify({resolvedRuntimeSource:f.run.runtimeSource,agent:f.agent,run:f.run,sandbox:f.sandbox??null},null,2));return}if(i==="source"){await B(a,e,o);return}if(i==="update"){let t=o[1]?.trim(),n=d(e,"usage: agent update <agentId>");if(!t)throw new Error("usage: agent update <agentId> --team-id <id>");let r=await a.agents.update(t,T(n,e));console.log(JSON.stringify({agent:r},null,2));return}if(i==="archive"){let t=o[1]?.trim(),n=d(e,"usage: agent archive <agentId>");if(!t)throw new Error("usage: agent archive <agentId> --team-id <id>");let r=await a.agents.archive(t,{teamId:n});console.log(JSON.stringify({agent:r},null,2));return}throw new Error("usage: agent <inspect|build|validate|eval|traces|list|create|upsert|get|update|run|run-test|bind-source|source|edit|archive> [--team-id <id>] [--project-id <id>] [--name <name>]")}g(Oe,"runAgentCommand");import V from"node:path";async function xe(e,o){let i=o[0]||"list",a=await h(e);if(i==="list"){let t=d(e,"usage: project list"),n=await a.projects.list({teamId:t});if(S(e.json)){console.log(JSON.stringify({projects:n},null,2));return}if(n.length===0){console.log("no sandbox projects found");return}for(let r of n)console.log(k(r));return}if(i==="create"||i==="upsert"){let t=await a.projects.upsert(J(e));console.log(JSON.stringify({project:t},null,2));return}if(i==="get"){let t=o[1]?.trim(),n=d(e,"usage: project get <projectId>");if(!t)throw new Error("usage: project get <projectId> --team-id <id>");let r=await a.projects.get(t,{teamId:n});console.log(JSON.stringify({project:r},null,2));return}if(i==="update"){let t=o[1]?.trim(),n=d(e,"usage: project update <projectId>");if(!t)throw new Error("usage: project update <projectId> --team-id <id>");let r=await a.projects.update(t,N(n,e));console.log(JSON.stringify({project:r},null,2));return}if(i==="sync"){let t=o[1]?.trim(),n=d(e,"usage: project sync <projectId>");if(!t)throw new Error("usage: project sync <projectId> --team-id <id>");let r=await a.projects.sync(t,{teamId:n});console.log(JSON.stringify({project:r},null,2));return}if(i==="source-upload"||i==="upload-source"){let t=o[1]?.trim(),n=d(e,"usage: project source-upload <projectId>");if(!t)throw new Error("usage: project source-upload <projectId> --team-id <id> [--path <dir>]");let r=V.resolve(u(e,"path")||"."),s=await E(r,e),l=u(e,"commitMessage")||u(e,"commit-message")||"Upload OpenPond project source",p=await y(r),c=await v(r,p.entries),m=C(p,c.entries),f=await a.projects.uploadSource(t,{teamId:n,entries:m.entries,...s?{branch:s}:{},commitMessage:l});console.log(JSON.stringify({project:f,uploaded:{path:r,branch:s,fileCount:m.fileCount,totalBytes:m.totalBytes,limits:m.limits,transport:m.transport,...c.generatedManifestPath?{agentSdk:{generatedManifestPath:c.generatedManifestPath,generatedEntryCount:c.entries.length,synthesizedOpenPondYaml:c.synthesizedOpenPondYaml,uploadMetadataPath:c.uploadMetadataPath,uploadMetadataHash:c.uploadMetadataHash,commands:c.uploadMetadata?.commands,dependencySetup:c.uploadMetadata?.dependencySetup,packageManager:c.uploadMetadata?.packageManager,sourceTreeMode:c.uploadMetadata?.sourceTreeMode,artifactHashes:c.uploadMetadata?.artifactHashes}}:{}}},null,2));return}if(i==="archive"){let t=o[1]?.trim(),n=d(e,"usage: project archive <projectId>");if(!t)throw new Error("usage: project archive <projectId> --team-id <id>");let r=await a.projects.archive(t,{teamId:n});console.log(JSON.stringify({project:r},null,2));return}throw new Error("usage: project <list|create|upsert|get|update|sync|source-upload|archive> [--team-id <id>] [--name <name>]")}g(xe,"runProjectCommand");export{W as PROJECT_SOURCE_UPLOAD_CONCURRENCY,z as PROJECT_SOURCE_UPLOAD_LIMITS,H as PROJECT_SOURCE_UPLOAD_MAX_BYTES,Y as PROJECT_SOURCE_UPLOAD_MAX_FILES,F as PROJECT_SOURCE_UPLOAD_MAX_FILE_BYTES,X as PROJECT_SOURCE_UPLOAD_TRANSPORT,M as buildAgentSourceChecksInput,_ as buildAgentSourceConfig,j as buildAgentSourcePolicy,R as buildAgentSourcePublishInput,T as buildAgentUpdateInput,U as buildAgentUpsertInput,N as buildProjectUpdateInput,J as buildProjectUpsertInput,y as collectProjectSourceUploadEntries,L as formatAgentLine,k as formatProjectLine,ee as parseAgentEntrypointScope,ne as parseAgentSourceCheckDispatch,re as parseAgentSourceCheckKind,te as parseAgentSourceMode,A as parseAgentTriggerType,x as parsePositiveLimit,Z as parseProjectSourceType,b as resolveLocalAgentSdkCommand,Oe as runAgentCommand,B as runAgentSourceWorkflow,xe as runProjectCommand};
|
|
2
|
+
import{a as b,b as Y,c as F,d as H,e as W,f as z,g as X,h as E,i as y,j as v,k as C,l as Z,m as ee,n as A,o as te,p as _,q as j,r as re,s as ne,t as x,u as M,v as R,w as J,x as N,y as U,z as T}from"./chunk-36FNNR5N.js";import{m as h,n as I,v as P}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import"./chunk-NABPZ7AK.js";import"./chunk-BQVB2SPF.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as u,d,e as w,f as S}from"./chunk-3M53YXEI.js";import"./chunk-PWKJ5KLZ.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-JFZ6USNQ.js";import"./chunk-6FA3GG5B.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as g}from"./chunk-FTQLQJQV.js";function k(e){let o=e.gitRepo?`${e.gitOwner??"_"}/${e.gitRepo}`:e.internalRepoPath??e.templateRepoUrl??e.normalizedSourceIdentity;return[e.id,e.status,e.sourceType,e.name,o].join(" ")}g(k,"formatProjectLine");function L(e){let o=e.selectedEntrypoint.name?`${e.selectedEntrypoint.scope}:${e.selectedEntrypoint.name}`:e.selectedEntrypoint.scope,i=e.runtimeSource?[e.runtimeSource.mode,e.runtimeSource.publishedSnapshotName??e.runtimeSource.publishedSnapshotId??e.runtimeSource.sourceRef].filter(a=>!!a).join(":"):"latest_source";return[e.id,e.status,e.triggerType,e.defaultWorkflowMode,i,o,e.name].join(" ")}g(L,"formatAgentLine");async function B(e,o,i){let a=i[1]?.trim(),t=i[2]?.trim(),n="usage: agent source <deploy-plan|checks|manifest-snapshots|setup|publish> <agent-id> --team-id <id>",r=d(o,n);if(!a||!t)throw new Error(n);if(a==="deploy-plan"){let s=await e.agents.sourceDeployPlan(t,{teamId:r});console.log(JSON.stringify({deployPlan:s},null,2));return}if(a==="manifest-snapshots"){let s=await e.agents.manifestSnapshots(t,{teamId:r,limit:x(o.limit)});console.log(JSON.stringify({manifestSnapshots:s},null,2));return}if(a==="checks"){let s=await e.agents.requestSourceChecks(t,M(r,o));console.log(JSON.stringify(s,null,2));return}if(a==="setup"){let s=typeof o.provider=="string"?o.provider.trim():"",l=typeof o.allowedActions=="string"?o.allowedActions.split(",").map(c=>c.trim()).filter(Boolean):[];if(!s||l.length===0)throw new Error(`${n}; setup requires --provider and --allowed-actions`);let p=await e.agents.configureSourceSetup(t,{teamId:r,integrationBindings:[{provider:s,mode:"connected",connectionMode:"member_connection",grantPolicy:"read_only",allowedActions:l,enabled:!0}]});console.log(JSON.stringify(p,null,2));return}if(a==="publish"){let s=await e.agents.publishSource(t,R(r,o));console.log(JSON.stringify(s,null,2));return}throw new Error(n)}g(B,"runAgentSourceWorkflow");import G from"node:path";var Q=new Set(["inspect","build","validate","eval","traces"]);function $(e,o){return Q.has(e)?!0:e==="run"&&!u(o,"teamId")}g($,"shouldDelegateLocalAgentSdkCommand");async function q(e,o){let i=o[0]||"inspect",a=G.resolve(u(e,"cwd")||u(e,"path")||"."),t=[i,...o.slice(1),"--cwd",a];S(e.json)&&t.push("--json"),D(t,e,"input","input"),D(t,e,"inputFile","input-file");let n=b(a),r=await P(n.command,[...n.args,...t],{cwd:a,inherit:!0});r.code!==0&&(process.exitCode=r.code??1)}g(q,"runLocalAgentSdkCommand");function D(e,o,i,a){let t=u(o,i);t&&e.push(`--${a}`,t)}g(D,"appendForwardedOption");async function Oe(e,o){let i=o[0]||"list";if($(i,e)){await q(e,o);return}let a=await h(e);if(i==="list"){let t=d(e,"usage: agent list"),n=await a.agents.list({teamId:t});if(S(e.json)){console.log(JSON.stringify({agents:n},null,2));return}if(n.length===0){console.log("no sandbox agents found");return}for(let r of n)console.log(L(r));return}if(i==="create"||i==="upsert"){let t=await a.agents.upsert(U(e));console.log(JSON.stringify({agent:t},null,2));return}if(i==="get"){let t=o[1]?.trim(),n=d(e,"usage: agent get <agentId>");if(!t)throw new Error("usage: agent get <agentId> --team-id <id>");let r=await a.agents.get(t,{teamId:n});console.log(JSON.stringify({agent:r},null,2));return}if(i==="run"){let t=o[1]?.trim(),n=d(e,"usage: agent run <agentId>");if(!t)throw new Error("usage: agent run <agentId> --team-id <id>");let r=u(e,"idempotencyKey"),s=u(e,"conversationId"),l=u(e,"targetProjectId"),p=A(e.triggerType),c=I(e.workflowMode),m=w(e,"input","input"),f=w(e,"metadata","metadata"),O=j(e),K=await a.agents.run(t,{teamId:n,...s?{conversationId:s}:{},...r?{idempotencyKey:r}:{},...l?{targetProjectId:l}:{},...l?{targetProject:{id:l}}:{},...p?{triggerType:p}:{},...c?{workflowMode:c}:{},...m?{input:m}:{},...f?{metadata:f}:{},...O?{runtimeSourcePolicy:O}:{}});console.log(JSON.stringify(K,null,2));return}if(i==="bind-runtime-source"||i==="bind-source"){let t=o[1]?.trim(),n=d(e,"usage: agent bind-source <agentId>");if(!t)throw new Error("usage: agent bind-source <agentId> --team-id <id> --source-mode latest_source|published_snapshot|auto");let r=_(e);if(!r?.mode)throw new Error("usage: agent bind-source <agentId> --team-id <id> --source-mode latest_source|published_snapshot|auto");let s=await a.agents.update(t,{teamId:n,runtimeSource:r});console.log(JSON.stringify({agent:s,agentSource:s.runtimeSource},null,2));return}if(i==="run-test"){let t=o[1]?.trim(),n=d(e,"usage: agent run-test <agentId>");if(!t)throw new Error("usage: agent run-test <agentId> --team-id <id>");let r=u(e,"idempotencyKey"),s=u(e,"conversationId"),l=u(e,"targetProjectId"),p=w(e,"input","input"),c=w(e,"metadata","metadata"),m=I(e.workflowMode),f=await a.agents.run(t,{teamId:n,...s?{conversationId:s}:{},...r?{idempotencyKey:r}:{},...l?{targetProjectId:l}:{},...l?{targetProject:{id:l}}:{},...m?{workflowMode:m}:{},...p?{input:p}:{},metadata:{...c??{},source:"agent_run_test"},runtimeSourcePolicy:j(e,"diagnostic")});console.log(JSON.stringify({resolvedRuntimeSource:f.run.runtimeSource,agent:f.agent,run:f.run,sandbox:f.sandbox??null},null,2));return}if(i==="source"){await B(a,e,o);return}if(i==="update"){let t=o[1]?.trim(),n=d(e,"usage: agent update <agentId>");if(!t)throw new Error("usage: agent update <agentId> --team-id <id>");let r=await a.agents.update(t,T(n,e));console.log(JSON.stringify({agent:r},null,2));return}if(i==="archive"){let t=o[1]?.trim(),n=d(e,"usage: agent archive <agentId>");if(!t)throw new Error("usage: agent archive <agentId> --team-id <id>");let r=await a.agents.archive(t,{teamId:n});console.log(JSON.stringify({agent:r},null,2));return}throw new Error("usage: agent <inspect|build|validate|eval|traces|list|create|upsert|get|update|run|run-test|bind-source|source|edit|archive> [--team-id <id>] [--project-id <id>] [--name <name>]")}g(Oe,"runAgentCommand");import V from"node:path";async function xe(e,o){let i=o[0]||"list",a=await h(e);if(i==="list"){let t=d(e,"usage: project list"),n=await a.projects.list({teamId:t});if(S(e.json)){console.log(JSON.stringify({projects:n},null,2));return}if(n.length===0){console.log("no sandbox projects found");return}for(let r of n)console.log(k(r));return}if(i==="create"||i==="upsert"){let t=await a.projects.upsert(J(e));console.log(JSON.stringify({project:t},null,2));return}if(i==="get"){let t=o[1]?.trim(),n=d(e,"usage: project get <projectId>");if(!t)throw new Error("usage: project get <projectId> --team-id <id>");let r=await a.projects.get(t,{teamId:n});console.log(JSON.stringify({project:r},null,2));return}if(i==="update"){let t=o[1]?.trim(),n=d(e,"usage: project update <projectId>");if(!t)throw new Error("usage: project update <projectId> --team-id <id>");let r=await a.projects.update(t,N(n,e));console.log(JSON.stringify({project:r},null,2));return}if(i==="sync"){let t=o[1]?.trim(),n=d(e,"usage: project sync <projectId>");if(!t)throw new Error("usage: project sync <projectId> --team-id <id>");let r=await a.projects.sync(t,{teamId:n});console.log(JSON.stringify({project:r},null,2));return}if(i==="source-upload"||i==="upload-source"){let t=o[1]?.trim(),n=d(e,"usage: project source-upload <projectId>");if(!t)throw new Error("usage: project source-upload <projectId> --team-id <id> [--path <dir>]");let r=V.resolve(u(e,"path")||"."),s=await E(r,e),l=u(e,"commitMessage")||u(e,"commit-message")||"Upload OpenPond project source",p=await y(r),c=await v(r,p.entries),m=C(p,c.entries),f=await a.projects.uploadSource(t,{teamId:n,entries:m.entries,...s?{branch:s}:{},commitMessage:l});console.log(JSON.stringify({project:f,uploaded:{path:r,branch:s,fileCount:m.fileCount,totalBytes:m.totalBytes,limits:m.limits,transport:m.transport,...c.generatedManifestPath?{agentSdk:{generatedManifestPath:c.generatedManifestPath,generatedEntryCount:c.entries.length,synthesizedOpenPondYaml:c.synthesizedOpenPondYaml,uploadMetadataPath:c.uploadMetadataPath,uploadMetadataHash:c.uploadMetadataHash,commands:c.uploadMetadata?.commands,dependencySetup:c.uploadMetadata?.dependencySetup,packageManager:c.uploadMetadata?.packageManager,sourceTreeMode:c.uploadMetadata?.sourceTreeMode,artifactHashes:c.uploadMetadata?.artifactHashes}}:{}}},null,2));return}if(i==="archive"){let t=o[1]?.trim(),n=d(e,"usage: project archive <projectId>");if(!t)throw new Error("usage: project archive <projectId> --team-id <id>");let r=await a.projects.archive(t,{teamId:n});console.log(JSON.stringify({project:r},null,2));return}throw new Error("usage: project <list|create|upsert|get|update|sync|source-upload|archive> [--team-id <id>] [--name <name>]")}g(xe,"runProjectCommand");export{W as PROJECT_SOURCE_UPLOAD_CONCURRENCY,z as PROJECT_SOURCE_UPLOAD_LIMITS,H as PROJECT_SOURCE_UPLOAD_MAX_BYTES,Y as PROJECT_SOURCE_UPLOAD_MAX_FILES,F as PROJECT_SOURCE_UPLOAD_MAX_FILE_BYTES,X as PROJECT_SOURCE_UPLOAD_TRANSPORT,M as buildAgentSourceChecksInput,_ as buildAgentSourceConfig,j as buildAgentSourcePolicy,R as buildAgentSourcePublishInput,T as buildAgentUpdateInput,U as buildAgentUpsertInput,N as buildProjectUpdateInput,J as buildProjectUpsertInput,y as collectProjectSourceUploadEntries,L as formatAgentLine,k as formatProjectLine,ee as parseAgentEntrypointScope,ne as parseAgentSourceCheckDispatch,re as parseAgentSourceCheckKind,te as parseAgentSourceMode,A as parseAgentTriggerType,x as parsePositiveLimit,Z as parseProjectSourceType,b as resolveLocalAgentSdkCommand,Oe as runAgentCommand,B as runAgentSourceWorkflow,xe as runProjectCommand};
|
|
@@ -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 L,n as M,o as c}from"./chunk-DAEUVT2I.js";import{m as v,s as w,t as y}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import"./chunk-FGOTSCSE.js";import"./chunk-E2S2EMYQ.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{b as I,f as g,g as h,h as m}from"./chunk-3M53YXEI.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as b}from"./chunk-FTQLQJQV.js";import{readFile as D,stat as _}from"node:fs/promises";async function U(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,a=h(e.maxEntries,"max-entries"),s=e.recursive!==void 0?g(e.recursive):void 0,d=await r.listFiles(t,{...n?{path:n}:{},...s!==void 0?{recursive:s}:{},...a!==void 0?{maxEntries:a}:{}});return console.log(JSON.stringify({sandbox:c(d.sandbox),files:d.files},null,2)),!0}if(o==="upload-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",a=typeof e.contents=="string"?e.contents:typeof e.content=="string"?e.content:"",s=typeof e.contentsBase64=="string"?e.contentsBase64.trim():typeof e.contentBase64=="string"?e.contentBase64.trim():"",d=typeof e.fromPath=="string"?e.fromPath.trim():"";if(!t||!n)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');if(d){if(a||s)throw new Error("Choose --from-path or inline contents for the upload.");let f=await _(d);if(!f.isFile()||f.size>10*1024*1024)throw new Error("Sandbox upload requires a file within 10 MiB.");let u=await D(d);if(u.byteLength>10*1024*1024)throw new Error("Sandbox upload file changed beyond 10 MiB.");s=u.toString("base64")}if(!a&&!s)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');let l=s?await r.uploadFileBase64(t,n,s):await r.uploadFile(t,n,a);return console.log(JSON.stringify({sandbox:c(l.sandbox),file:l.file},null,2)),!0}if(o==="download-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",a=m(e.offsetBytes,"offset-bytes"),s=m(e.maxBytes,"max-bytes");if(!t||!n)throw new Error("usage: sandbox download-file <sandboxId> --path <path>");let d=await r.downloadFileResponse(t,{path:n,...a!==void 0?{offsetBytes:a}:{},...s!==void 0?{maxBytes:s}:{}});return console.log(JSON.stringify({sandbox:c(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 a=typeof e.path=="string"?e.path.trim():void 0,s=h(e.maxResults,"max-results"),d=await r.searchFiles(t,{query:n,...a?{path:a}:{},...s!==void 0?{maxResults:s}:{}});return console.log(JSON.stringify({sandbox:c(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 a=await r.deleteFile(t,n,{recursive:g(e.recursive)});return console.log(JSON.stringify({sandbox:c(a.sandbox),deleted:a.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 a=await r.statFile(t,n);return console.log(JSON.stringify({sandbox:c(a.sandbox),file:a.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 a=await r.mkdir(t,{path:n,recursive:e.recursive!==void 0?g(e.recursive):void 0});return console.log(JSON.stringify({sandbox:c(a.sandbox),directory:a.directory},null,2)),!0}if(o==="move-file"){let t=i[1],n=typeof e.fromPath=="string"?e.fromPath.trim():"",a=typeof e.toPath=="string"?e.toPath.trim():"";if(!t||!n||!a)throw new Error("usage: sandbox move-file <sandboxId> --from-path <path> --to-path <path> [--overwrite]");let s=await r.moveFile(t,{fromPath:n,toPath:a,overwrite:g(e.overwrite)});return console.log(JSON.stringify({sandbox:c(s.sandbox),moved:s.moved,file:s.file},null,2)),!0}return!1}b(U,"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:c(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,a=await r.gitDiff(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:c(a.sandbox),diff:a.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,a=await r.gitExportPatch(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:c(a.sandbox),patch:a.patch},null,2)),!0}if(o==="git-branch"){let t=i[1],n=typeof e.branch=="string"?e.branch.trim():"",a=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 s=await r.gitBranch(t,{branch:n,create:g(e.create),...a?{startPoint:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),branch:s.branch},null,2)),!0}if(o==="git-commit"){let t=i[1],n=typeof e.message=="string"?e.message.trim():"",a=g(e.all),d=(typeof e.paths=="string"?e.paths:typeof e.path=="string"?e.path:"").split(",").map(f=>f.trim()).filter(Boolean);if(!t||!n||!a&&d.length===0)throw new Error('usage: sandbox git-commit <sandboxId> --message "..." [--all|--paths <csv>]');let l=await r.gitCommit(t,{message:n,...a?{all:!0}:{paths:d}});return console.log(JSON.stringify({sandbox:c(l.sandbox),commit:l.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,a=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,s=await r.gitPull(t,{...n?{remote:n}:{},...a?{branch:a}:{},...e.rebase!==void 0?{rebase:g(e.rebase)}:{},...e.ffOnly!==void 0?{ffOnly:g(e.ffOnly)}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),pull:s.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,a=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,s=await r.gitPush(t,{...n?{remote:n}:{},...a?{branch:a}:{},...e.setUpstream!==void 0?{setUpstream:g(e.setUpstream)}:{},...e.forceWithLease!==void 0?{forceWithLease:g(e.forceWithLease)}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),push:s.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 a=m(e.timeoutSeconds,"timeout-seconds"),s=await r.startProcess(t,{command:n.trim(),...a!==void 0?{timeoutSeconds:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),process:s.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:c(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 a=m(e.since,"since"),s=await r.getProcess(t,n,{...a!==void 0?{since:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),process:s.process,output:s.output,cursor:s.cursor,completed:s.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 a=await r.stopProcess(t,n);return console.log(JSON.stringify({sandbox:c(a.sandbox),process:a.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 a=m(e.since,"since");return await r.streamProcessOutput(t,n,{...a!==void 0?{since:a}:{}}),!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(" "),a=m(e.timeoutSeconds,"timeout-seconds"),s=m(e.rows,"rows"),d=m(e.cols,"cols"),l=await r.startPty(t,{...n.trim()?{command:n.trim()}:{},...a!==void 0?{timeoutSeconds:a}:{},...s!==void 0?{rows:s}:{},...d!==void 0?{cols:d}:{}});return console.log(JSON.stringify({sandbox:c(l.sandbox),pty:l.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:c(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 a=m(e.since,"since"),s=await r.getPty(t,n,{...a!==void 0?{since:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),pty:s.pty,output:s.output,cursor:s.cursor,completed:s.completed},null,2)),!0}if(o==="pty-write"){let t=i[1],n=i[2],a=typeof e.inputBase64=="string"?e.inputBase64.trim():"",s=(typeof e.input=="string"?e.input:null)||i.slice(3).join(" ");if(!t||!n||!a&&!s)throw new Error("usage: sandbox pty-write <sandboxId> <ptyId> --input <text>");let d=await r.writePtyInput(t,n,a?{dataBase64:a}:s);return console.log(JSON.stringify({sandbox:c(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 a=await r.stopPty(t,n);return console.log(JSON.stringify({sandbox:c(a.sandbox),pty:a.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 a=m(e.since,"since");return await r.streamPtyOutput(t,n,{...a!==void 0?{since:a}:{}}),!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():"",a=await r.listReplays({...t?{teamId:t}:{},...n?{projectId:n}:{}});if(g(e.json))return console.log(JSON.stringify(a,null,2)),!0;if(a.replays.length===0)return console.log("no sandbox replays found"),!0;for(let s of a.replays)console.log(O(s));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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.getReplay(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});return console.log(JSON.stringify(s,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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.getReplayLogs(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});for(let d of s.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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.getReplayArtifacts(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});return console.log(JSON.stringify({replayId:s.replayId,artifacts:s.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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.cancelReplay(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});return console.log(JSON.stringify(s,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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=m(e.intervalMs,"interval-ms")??5e3,d=m(e.timeoutMs,"timeout-ms")??900*1e3,l=Date.now(),f=new Set;for(;Date.now()-l<=d;){let u=await r.getReplay(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});for(let p of u.replay.logs)f.has(p)||(f.add(p),console.log(p));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(p=>setTimeout(p,s))}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():"",a=typeof e.agentId=="string"?e.agentId.trim():"",s=await r.listSandboxRuntimes({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{}});return console.log(JSON.stringify({runtimes:s},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():"",a=Number(e.expectedVersion),s=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0;if(!t||!n||!Number.isInteger(a))throw new Error("usage: sandbox runtime-status <runtimeId> --status <status> --expected-version <n>");let d=await r.updateSandboxRuntimeStatus(t,{status:n,expectedVersion:a,...s?{summary:s}:{}});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():"",a=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0,s=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,...a?{summary:a}:{},...s?{payload:s}:{},...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():"",a=typeof e.sandboxId=="string"&&e.sandboxId.trim()?e.sandboxId.trim():"",s=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,{...a?{sandboxId:a}:{},...s?{message:s}:{}},{...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(g(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 a of n)console.log(`${a.name} ${a.status} v${a.currentVersion??"current"} ${a.secretRef}`);return!0}if(o==="secret-create"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.name=="string"?e.name.trim():"",a=typeof e.description=="string"&&e.description.trim()?e.description.trim():void 0,s=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}`),l=await r.createSecret({...t?{teamId:t}:{},name:n,value:d,...a?{description:a}:{},...s?{scope:s}:{}});return console.log(JSON.stringify({secret:y(l)},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 a=await w(e,"New secret value"),s=await r.rotateSecret(t,{...n?{teamId:n}:{},value:a});return console.log(JSON.stringify({secret:y(s)},null,2)),!0}if(o==="secret-attach"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"",a=typeof e.envName=="string"?e.envName.trim():"",s=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||!a||!s||!d)throw new Error("usage: sandbox secret-attach <secretId> --env-name <ENV_NAME> --target-type sandbox|project|agent|template|replay --target-id <id>");let l=await r.attachSecret(t,{...n?{teamId:n}:{},envName:a,targetType:s,targetId:d});return console.log(JSON.stringify({secret:y(l)},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 a=o==="secret-revoke"?await r.revokeSecret(t,{...n?{teamId:n}:{}}):await r.deleteSecret(t,{...n?{teamId:n}:{}});return console.log(JSON.stringify({secret:y(a)},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(g(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 a of n)console.log(S(a));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(L(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(g(e.json))return console.log(JSON.stringify(n,null,2)),!0;for(let a of n.logs)console.log(a);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=m(e.intervalMs,"interval-ms")??5e3,a=m(e.timeoutMs,"timeout-ms")??900*1e3,s=Date.now(),d=new Set;for(;Date.now()-s<=a;){let[l,f]=await Promise.all([r.getPublishedSnapshotBuild(t),r.getPublishedSnapshotBuildLogs(t)]);for(let u of f.logs)d.has(u)||(d.add(u),console.log(u));if(l.status==="succeeded"||l.status==="failed"||l.status==="cancelled"){if(console.log(S(l)),l.status!=="succeeded")throw new Error(`published snapshot build ${l.status}: ${l.error??"no error"}`);return!0}await new Promise(u=>setTimeout(u,n))}throw new Error(`published snapshot build did not finish within ${a}ms`)}return!1}b(H,"handleSandboxTemplateBuildsCommand");function z(r){return g(r.async)||g(r.respondAsync)}b(z,"parseSandboxAsyncOption");async function Ce(r,o){let e=o[0]||"list",i=await v(r);if(e==="get"){let t=o[1];if(!t||o.length!==2)throw new Error("usage: sandbox get <sandboxId>");console.log(JSON.stringify({sandbox:await i.get(t)},null,2));return}if(e==="list"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=await i.list({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{}});if(s.length===0){console.log("no sandboxes found");return}for(let d of s)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():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=await i.costs({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{}});if(g(r.summary)){console.log(JSON.stringify({costs:{teamId:s.costs.teamId,ownerUserId:s.costs.ownerUserId,generatedAt:s.costs.generatedAt,summary:s.costs.summary,lineItems:s.costs.lineItems,tiers:s.costs.pricing.tiers.map(d=>({key:d.key,resources:d.resources,keepRunningEstimate:d.keepRunningEstimate}))}},null,2));return}console.log(JSON.stringify(s,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():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=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():"",l=typeof r.useCase=="string"?r.useCase.trim():"",f=typeof r.replayState=="string"?r.replayState.trim():"",u=await i.snapshotCatalog({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{},...s?{q:s}:{},...d?{tag:d}:{},...l?{useCase:l}:{},...f==="draft"||f==="validated"||f==="published"?{replayState:f}:{}});if(u.snapshots.length===0){console.log("no sandbox snapshots found");return}for(let p of u.snapshots)console.log(J(p));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():"",a=typeof r.query=="string"&&r.query.trim()?r.query.trim():typeof r.q=="string"&&r.q.trim()?r.q.trim():"",s=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():"",l=typeof r.tag=="string"?r.tag.trim():"",f=typeof r.useCase=="string"?r.useCase.trim():"",u=await i.publishedSnapshots({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{q:a}:{},...s?{name:s}:{},...d?{version:d}:{},...l?{tag:l}:{},...f?{useCase:f}:{}});if(u.publishedSnapshots.length===0){console.log("no published snapshots found");return}for(let p of u.publishedSnapshots)console.log(j(p));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():"",a=typeof r.snapshotId=="string"&&r.snapshotId.trim()?r.snapshotId.trim():typeof r.snapshot=="string"&&r.snapshot.trim()?r.snapshot.trim():"",s=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():"",l=typeof r.useCase=="string"?r.useCase.trim():"";if(!a&&!s&&!l)throw new Error("usage: sandbox run-published-snapshot [--snapshot-id <id>|--name <name>|--use-case <id>] [--version <v>]");let f=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}:{},...a?{snapshotId:a}:{},...s?{templateName:s}:{},...d?{version:d}:{},...l?{useCase:l}:{},...f?{budget:{maxUsd:f}}:{},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():"",a=typeof r.projectId=="string"?r.projectId.trim():"",s=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}:{},...a?{projectId:a}:{},...s?{budget:{maxUsd:s}}:{},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,M(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 a=R(r.cleanup),s=await i.validateSnapshot(t,n,{...a?{cleanup:a}:{}});console.log(JSON.stringify(s,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 a=await i.publishSnapshot(t,n);console.log(JSON.stringify(a,null,2));return}if(e==="integration-connections"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=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}:{},...a?{agentId:a}:{},...s?{status:s}:{}});console.log(JSON.stringify(d,null,2));return}if(e==="create"){let t=await N(i,B(r));console.log(JSON.stringify({sandbox:c(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 a=m(r.timeoutSeconds,"timeout-seconds"),s=await i.exec(t,{command:n.trim(),...a!==void 0?{timeoutSeconds:a}:{}});console.log(JSON.stringify({sandbox:c(s.sandbox),command:s.command},null,2));return}if(e==="port"||e==="preview"){let t=o[1],n=m(r.port,"port");if(!t||n===void 0)throw new Error("usage: sandbox port <sandboxId> --port <port>");let a=typeof r.label=="string"?r.label:void 0,s=typeof r.access=="string"?r.access.trim():"";if(s&&s!=="private"&&s!=="public")throw new Error("sandbox port --access must be private or public");let d=s==="public"?"public":"private",l=typeof r.domain=="string"?r.domain.trim():"",f=typeof r.authToken=="string"?r.authToken:"",u=typeof r.authHeader=="string"?r.authHeader.trim():"",p=typeof r.authHeaderValue=="string"?r.authHeaderValue:"";if(f&&(u||p))throw new Error("sandbox port auth options must use either --auth-token or --auth-header with --auth-header-value");if(u&&!p||!u&&p)throw new Error("sandbox port custom header auth requires both --auth-header and --auth-header-value");let x=await i.openPort(t,{port:n,...a?{label:a}:{},access:d,...r["auto-start"]||r.autoStart?{autoStart:!0}:{},...l?{customDomain:l}:{},...f?{authPolicy:{mode:"bearer",token:f}}:{},...u&&p?{authPolicy:{mode:"header",headerName:u,headerValue:p}}:{}});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:g(r.failOnUnpreservedChanges),async:z(r)});console.log(JSON.stringify({sandbox:c(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:g(r.failOnUnpreservedChanges),async:z(r)});console.log(JSON.stringify({sandbox:c(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 a of n)console.log(a);return}if(!(await F(i,e,r,o)||await U(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:c(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:c(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:c(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 a=await i.removeIntegrationLease(t,n);console.log(JSON.stringify({sandbox:c(a.sandbox),integrationLeases:a.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,a=g(r.keep),s=r.preview!==void 0?g(r.preview):!g(r.noPreview),d=g(r.snapshot),l=g(r.fork),f={...t?{repo:t}:{},...n?{budgetUsd:n}:{},keep:a,preview:s,snapshot:d,fork:l};typeof r.expectedMppMode=="string"&&r.expectedMppMode.trim()&&(f.expectedMppMode=r.expectedMppMode.trim());let u=h(r.cpu,"cpu"),p=h(r.memoryGb,"memory-gb"),x=h(r.diskGb,"disk-gb");u!==void 0&&(f.cpu=u),p!==void 0&&(f.memoryGb=p),x!==void 0&&(f.diskGb=x);let G=await i.smoke(f);console.log(JSON.stringify(G,null,2));return}throw new Error("usage: sandbox <list|get|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(Ce,"runSandboxCommand");export{Ce 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 L,n as M,o as c}from"./chunk-DAEUVT2I.js";import{m as v,s as w,t as y}from"./chunk-7P5SH3CI.js";import"./chunk-TGULVWPV.js";import"./chunk-NABPZ7AK.js";import"./chunk-BQVB2SPF.js";import"./chunk-XRKFTPHD.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{b as I,f as g,g as h,h as m}from"./chunk-3M53YXEI.js";import"./chunk-CRDKBFRN.js";import"./chunk-DMO3UIS7.js";import"./chunk-27JGS3KB.js";import"./chunk-BT5YNE5U.js";import"./chunk-3WJQ4IGK.js";import"./chunk-KTIBXRWQ.js";import"./chunk-L4EJ5R3B.js";import"./chunk-6ZTP6CUJ.js";import"./chunk-TBODQT4W.js";import"./chunk-YRDPVTEI.js";import"./chunk-JRGECNP3.js";import"./chunk-RRWL5BHZ.js";import"./chunk-NXN7GJOH.js";import"./chunk-5WPMI6QX.js";import"./chunk-W7NXFRHN.js";import"./chunk-5HPZGLOL.js";import"./chunk-GLUWATL5.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-JCLTFDVW.js";import"./chunk-I6VMRQF4.js";import"./chunk-QAFXQHHG.js";import"./chunk-OKKNDQJF.js";import"./chunk-AJXWJLZA.js";import"./chunk-G4E3WGLM.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-SH7POUVX.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import"./chunk-UGOK7VTC.js";import{a as b}from"./chunk-FTQLQJQV.js";import{readFile as D,stat as _}from"node:fs/promises";async function U(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,a=h(e.maxEntries,"max-entries"),s=e.recursive!==void 0?g(e.recursive):void 0,d=await r.listFiles(t,{...n?{path:n}:{},...s!==void 0?{recursive:s}:{},...a!==void 0?{maxEntries:a}:{}});return console.log(JSON.stringify({sandbox:c(d.sandbox),files:d.files},null,2)),!0}if(o==="upload-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",a=typeof e.contents=="string"?e.contents:typeof e.content=="string"?e.content:"",s=typeof e.contentsBase64=="string"?e.contentsBase64.trim():typeof e.contentBase64=="string"?e.contentBase64.trim():"",d=typeof e.fromPath=="string"?e.fromPath.trim():"";if(!t||!n)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');if(d){if(a||s)throw new Error("Choose --from-path or inline contents for the upload.");let f=await _(d);if(!f.isFile()||f.size>10*1024*1024)throw new Error("Sandbox upload requires a file within 10 MiB.");let u=await D(d);if(u.byteLength>10*1024*1024)throw new Error("Sandbox upload file changed beyond 10 MiB.");s=u.toString("base64")}if(!a&&!s)throw new Error('usage: sandbox upload-file <sandboxId> --path <path> --contents "text"');let l=s?await r.uploadFileBase64(t,n,s):await r.uploadFile(t,n,a);return console.log(JSON.stringify({sandbox:c(l.sandbox),file:l.file},null,2)),!0}if(o==="download-file"){let t=i[1],n=typeof e.path=="string"?e.path.trim():"",a=m(e.offsetBytes,"offset-bytes"),s=m(e.maxBytes,"max-bytes");if(!t||!n)throw new Error("usage: sandbox download-file <sandboxId> --path <path>");let d=await r.downloadFileResponse(t,{path:n,...a!==void 0?{offsetBytes:a}:{},...s!==void 0?{maxBytes:s}:{}});return console.log(JSON.stringify({sandbox:c(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 a=typeof e.path=="string"?e.path.trim():void 0,s=h(e.maxResults,"max-results"),d=await r.searchFiles(t,{query:n,...a?{path:a}:{},...s!==void 0?{maxResults:s}:{}});return console.log(JSON.stringify({sandbox:c(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 a=await r.deleteFile(t,n,{recursive:g(e.recursive)});return console.log(JSON.stringify({sandbox:c(a.sandbox),deleted:a.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 a=await r.statFile(t,n);return console.log(JSON.stringify({sandbox:c(a.sandbox),file:a.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 a=await r.mkdir(t,{path:n,recursive:e.recursive!==void 0?g(e.recursive):void 0});return console.log(JSON.stringify({sandbox:c(a.sandbox),directory:a.directory},null,2)),!0}if(o==="move-file"){let t=i[1],n=typeof e.fromPath=="string"?e.fromPath.trim():"",a=typeof e.toPath=="string"?e.toPath.trim():"";if(!t||!n||!a)throw new Error("usage: sandbox move-file <sandboxId> --from-path <path> --to-path <path> [--overwrite]");let s=await r.moveFile(t,{fromPath:n,toPath:a,overwrite:g(e.overwrite)});return console.log(JSON.stringify({sandbox:c(s.sandbox),moved:s.moved,file:s.file},null,2)),!0}return!1}b(U,"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:c(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,a=await r.gitDiff(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:c(a.sandbox),diff:a.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,a=await r.gitExportPatch(t,{...n?{baseRef:n}:{}});return console.log(JSON.stringify({sandbox:c(a.sandbox),patch:a.patch},null,2)),!0}if(o==="git-branch"){let t=i[1],n=typeof e.branch=="string"?e.branch.trim():"",a=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 s=await r.gitBranch(t,{branch:n,create:g(e.create),...a?{startPoint:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),branch:s.branch},null,2)),!0}if(o==="git-commit"){let t=i[1],n=typeof e.message=="string"?e.message.trim():"",a=g(e.all),d=(typeof e.paths=="string"?e.paths:typeof e.path=="string"?e.path:"").split(",").map(f=>f.trim()).filter(Boolean);if(!t||!n||!a&&d.length===0)throw new Error('usage: sandbox git-commit <sandboxId> --message "..." [--all|--paths <csv>]');let l=await r.gitCommit(t,{message:n,...a?{all:!0}:{paths:d}});return console.log(JSON.stringify({sandbox:c(l.sandbox),commit:l.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,a=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,s=await r.gitPull(t,{...n?{remote:n}:{},...a?{branch:a}:{},...e.rebase!==void 0?{rebase:g(e.rebase)}:{},...e.ffOnly!==void 0?{ffOnly:g(e.ffOnly)}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),pull:s.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,a=typeof e.branch=="string"&&e.branch.trim()?e.branch.trim():void 0,s=await r.gitPush(t,{...n?{remote:n}:{},...a?{branch:a}:{},...e.setUpstream!==void 0?{setUpstream:g(e.setUpstream)}:{},...e.forceWithLease!==void 0?{forceWithLease:g(e.forceWithLease)}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),push:s.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 a=m(e.timeoutSeconds,"timeout-seconds"),s=await r.startProcess(t,{command:n.trim(),...a!==void 0?{timeoutSeconds:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),process:s.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:c(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 a=m(e.since,"since"),s=await r.getProcess(t,n,{...a!==void 0?{since:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),process:s.process,output:s.output,cursor:s.cursor,completed:s.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 a=await r.stopProcess(t,n);return console.log(JSON.stringify({sandbox:c(a.sandbox),process:a.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 a=m(e.since,"since");return await r.streamProcessOutput(t,n,{...a!==void 0?{since:a}:{}}),!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(" "),a=m(e.timeoutSeconds,"timeout-seconds"),s=m(e.rows,"rows"),d=m(e.cols,"cols"),l=await r.startPty(t,{...n.trim()?{command:n.trim()}:{},...a!==void 0?{timeoutSeconds:a}:{},...s!==void 0?{rows:s}:{},...d!==void 0?{cols:d}:{}});return console.log(JSON.stringify({sandbox:c(l.sandbox),pty:l.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:c(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 a=m(e.since,"since"),s=await r.getPty(t,n,{...a!==void 0?{since:a}:{}});return console.log(JSON.stringify({sandbox:c(s.sandbox),pty:s.pty,output:s.output,cursor:s.cursor,completed:s.completed},null,2)),!0}if(o==="pty-write"){let t=i[1],n=i[2],a=typeof e.inputBase64=="string"?e.inputBase64.trim():"",s=(typeof e.input=="string"?e.input:null)||i.slice(3).join(" ");if(!t||!n||!a&&!s)throw new Error("usage: sandbox pty-write <sandboxId> <ptyId> --input <text>");let d=await r.writePtyInput(t,n,a?{dataBase64:a}:s);return console.log(JSON.stringify({sandbox:c(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 a=await r.stopPty(t,n);return console.log(JSON.stringify({sandbox:c(a.sandbox),pty:a.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 a=m(e.since,"since");return await r.streamPtyOutput(t,n,{...a!==void 0?{since:a}:{}}),!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():"",a=await r.listReplays({...t?{teamId:t}:{},...n?{projectId:n}:{}});if(g(e.json))return console.log(JSON.stringify(a,null,2)),!0;if(a.replays.length===0)return console.log("no sandbox replays found"),!0;for(let s of a.replays)console.log(O(s));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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.getReplay(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});return console.log(JSON.stringify(s,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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.getReplayLogs(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});for(let d of s.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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.getReplayArtifacts(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});return console.log(JSON.stringify({replayId:s.replayId,artifacts:s.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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=await r.cancelReplay(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});return console.log(JSON.stringify(s,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():"",a=typeof e.projectId=="string"?e.projectId.trim():"",s=m(e.intervalMs,"interval-ms")??5e3,d=m(e.timeoutMs,"timeout-ms")??900*1e3,l=Date.now(),f=new Set;for(;Date.now()-l<=d;){let u=await r.getReplay(t,{...n?{teamId:n}:{},...a?{projectId:a}:{}});for(let p of u.replay.logs)f.has(p)||(f.add(p),console.log(p));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(p=>setTimeout(p,s))}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():"",a=typeof e.agentId=="string"?e.agentId.trim():"",s=await r.listSandboxRuntimes({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{}});return console.log(JSON.stringify({runtimes:s},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():"",a=Number(e.expectedVersion),s=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0;if(!t||!n||!Number.isInteger(a))throw new Error("usage: sandbox runtime-status <runtimeId> --status <status> --expected-version <n>");let d=await r.updateSandboxRuntimeStatus(t,{status:n,expectedVersion:a,...s?{summary:s}:{}});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():"",a=typeof e.summary=="string"&&e.summary.trim()?e.summary.trim():void 0,s=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,...a?{summary:a}:{},...s?{payload:s}:{},...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():"",a=typeof e.sandboxId=="string"&&e.sandboxId.trim()?e.sandboxId.trim():"",s=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,{...a?{sandboxId:a}:{},...s?{message:s}:{}},{...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(g(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 a of n)console.log(`${a.name} ${a.status} v${a.currentVersion??"current"} ${a.secretRef}`);return!0}if(o==="secret-create"){let t=typeof e.teamId=="string"?e.teamId.trim():"",n=typeof e.name=="string"?e.name.trim():"",a=typeof e.description=="string"&&e.description.trim()?e.description.trim():void 0,s=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}`),l=await r.createSecret({...t?{teamId:t}:{},name:n,value:d,...a?{description:a}:{},...s?{scope:s}:{}});return console.log(JSON.stringify({secret:y(l)},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 a=await w(e,"New secret value"),s=await r.rotateSecret(t,{...n?{teamId:n}:{},value:a});return console.log(JSON.stringify({secret:y(s)},null,2)),!0}if(o==="secret-attach"){let t=i[1],n=typeof e.teamId=="string"?e.teamId.trim():"",a=typeof e.envName=="string"?e.envName.trim():"",s=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||!a||!s||!d)throw new Error("usage: sandbox secret-attach <secretId> --env-name <ENV_NAME> --target-type sandbox|project|agent|template|replay --target-id <id>");let l=await r.attachSecret(t,{...n?{teamId:n}:{},envName:a,targetType:s,targetId:d});return console.log(JSON.stringify({secret:y(l)},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 a=o==="secret-revoke"?await r.revokeSecret(t,{...n?{teamId:n}:{}}):await r.deleteSecret(t,{...n?{teamId:n}:{}});return console.log(JSON.stringify({secret:y(a)},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(g(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 a of n)console.log(S(a));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(L(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(g(e.json))return console.log(JSON.stringify(n,null,2)),!0;for(let a of n.logs)console.log(a);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=m(e.intervalMs,"interval-ms")??5e3,a=m(e.timeoutMs,"timeout-ms")??900*1e3,s=Date.now(),d=new Set;for(;Date.now()-s<=a;){let[l,f]=await Promise.all([r.getPublishedSnapshotBuild(t),r.getPublishedSnapshotBuildLogs(t)]);for(let u of f.logs)d.has(u)||(d.add(u),console.log(u));if(l.status==="succeeded"||l.status==="failed"||l.status==="cancelled"){if(console.log(S(l)),l.status!=="succeeded")throw new Error(`published snapshot build ${l.status}: ${l.error??"no error"}`);return!0}await new Promise(u=>setTimeout(u,n))}throw new Error(`published snapshot build did not finish within ${a}ms`)}return!1}b(H,"handleSandboxTemplateBuildsCommand");function z(r){return g(r.async)||g(r.respondAsync)}b(z,"parseSandboxAsyncOption");async function Ce(r,o){let e=o[0]||"list",i=await v(r);if(e==="get"){let t=o[1];if(!t||o.length!==2)throw new Error("usage: sandbox get <sandboxId>");console.log(JSON.stringify({sandbox:await i.get(t)},null,2));return}if(e==="list"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=await i.list({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{}});if(s.length===0){console.log("no sandboxes found");return}for(let d of s)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():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=await i.costs({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{}});if(g(r.summary)){console.log(JSON.stringify({costs:{teamId:s.costs.teamId,ownerUserId:s.costs.ownerUserId,generatedAt:s.costs.generatedAt,summary:s.costs.summary,lineItems:s.costs.lineItems,tiers:s.costs.pricing.tiers.map(d=>({key:d.key,resources:d.resources,keepRunningEstimate:d.keepRunningEstimate}))}},null,2));return}console.log(JSON.stringify(s,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():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=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():"",l=typeof r.useCase=="string"?r.useCase.trim():"",f=typeof r.replayState=="string"?r.replayState.trim():"",u=await i.snapshotCatalog({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{agentId:a}:{},...s?{q:s}:{},...d?{tag:d}:{},...l?{useCase:l}:{},...f==="draft"||f==="validated"||f==="published"?{replayState:f}:{}});if(u.snapshots.length===0){console.log("no sandbox snapshots found");return}for(let p of u.snapshots)console.log(J(p));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():"",a=typeof r.query=="string"&&r.query.trim()?r.query.trim():typeof r.q=="string"&&r.q.trim()?r.q.trim():"",s=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():"",l=typeof r.tag=="string"?r.tag.trim():"",f=typeof r.useCase=="string"?r.useCase.trim():"",u=await i.publishedSnapshots({...t?{teamId:t}:{},...n?{projectId:n}:{},...a?{q:a}:{},...s?{name:s}:{},...d?{version:d}:{},...l?{tag:l}:{},...f?{useCase:f}:{}});if(u.publishedSnapshots.length===0){console.log("no published snapshots found");return}for(let p of u.publishedSnapshots)console.log(j(p));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():"",a=typeof r.snapshotId=="string"&&r.snapshotId.trim()?r.snapshotId.trim():typeof r.snapshot=="string"&&r.snapshot.trim()?r.snapshot.trim():"",s=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():"",l=typeof r.useCase=="string"?r.useCase.trim():"";if(!a&&!s&&!l)throw new Error("usage: sandbox run-published-snapshot [--snapshot-id <id>|--name <name>|--use-case <id>] [--version <v>]");let f=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}:{},...a?{snapshotId:a}:{},...s?{templateName:s}:{},...d?{version:d}:{},...l?{useCase:l}:{},...f?{budget:{maxUsd:f}}:{},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():"",a=typeof r.projectId=="string"?r.projectId.trim():"",s=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}:{},...a?{projectId:a}:{},...s?{budget:{maxUsd:s}}:{},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,M(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 a=R(r.cleanup),s=await i.validateSnapshot(t,n,{...a?{cleanup:a}:{}});console.log(JSON.stringify(s,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 a=await i.publishSnapshot(t,n);console.log(JSON.stringify(a,null,2));return}if(e==="integration-connections"){let t=typeof r.teamId=="string"?r.teamId.trim():"",n=typeof r.projectId=="string"?r.projectId.trim():"",a=typeof r.agentId=="string"?r.agentId.trim():"",s=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}:{},...a?{agentId:a}:{},...s?{status:s}:{}});console.log(JSON.stringify(d,null,2));return}if(e==="create"){let t=await N(i,B(r));console.log(JSON.stringify({sandbox:c(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 a=m(r.timeoutSeconds,"timeout-seconds"),s=await i.exec(t,{command:n.trim(),...a!==void 0?{timeoutSeconds:a}:{}});console.log(JSON.stringify({sandbox:c(s.sandbox),command:s.command},null,2));return}if(e==="port"||e==="preview"){let t=o[1],n=m(r.port,"port");if(!t||n===void 0)throw new Error("usage: sandbox port <sandboxId> --port <port>");let a=typeof r.label=="string"?r.label:void 0,s=typeof r.access=="string"?r.access.trim():"";if(s&&s!=="private"&&s!=="public")throw new Error("sandbox port --access must be private or public");let d=s==="public"?"public":"private",l=typeof r.domain=="string"?r.domain.trim():"",f=typeof r.authToken=="string"?r.authToken:"",u=typeof r.authHeader=="string"?r.authHeader.trim():"",p=typeof r.authHeaderValue=="string"?r.authHeaderValue:"";if(f&&(u||p))throw new Error("sandbox port auth options must use either --auth-token or --auth-header with --auth-header-value");if(u&&!p||!u&&p)throw new Error("sandbox port custom header auth requires both --auth-header and --auth-header-value");let x=await i.openPort(t,{port:n,...a?{label:a}:{},access:d,...r["auto-start"]||r.autoStart?{autoStart:!0}:{},...l?{customDomain:l}:{},...f?{authPolicy:{mode:"bearer",token:f}}:{},...u&&p?{authPolicy:{mode:"header",headerName:u,headerValue:p}}:{}});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:g(r.failOnUnpreservedChanges),async:z(r)});console.log(JSON.stringify({sandbox:c(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:g(r.failOnUnpreservedChanges),async:z(r)});console.log(JSON.stringify({sandbox:c(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 a of n)console.log(a);return}if(!(await F(i,e,r,o)||await U(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:c(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:c(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:c(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 a=await i.removeIntegrationLease(t,n);console.log(JSON.stringify({sandbox:c(a.sandbox),integrationLeases:a.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,a=g(r.keep),s=r.preview!==void 0?g(r.preview):!g(r.noPreview),d=g(r.snapshot),l=g(r.fork),f={...t?{repo:t}:{},...n?{budgetUsd:n}:{},keep:a,preview:s,snapshot:d,fork:l};typeof r.expectedMppMode=="string"&&r.expectedMppMode.trim()&&(f.expectedMppMode=r.expectedMppMode.trim());let u=h(r.cpu,"cpu"),p=h(r.memoryGb,"memory-gb"),x=h(r.diskGb,"disk-gb");u!==void 0&&(f.cpu=u),p!==void 0&&(f.memoryGb=p),x!==void 0&&(f.diskGb=x);let G=await i.smoke(f);console.log(JSON.stringify(G,null,2));return}throw new Error("usage: sandbox <list|get|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(Ce,"runSandboxCommand");export{Ce as runSandboxCommand};
|