openpond 0.2.25 → 0.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/app-server.js +1 -1
  2. package/dist/chunks/{actions-command-S27YU6NW.js → actions-command-NOCBOF5S.js} +1 -1
  3. package/dist/chunks/{app-layer-57323XKJ.js → app-layer-GLXYIT4B.js} +1 -1
  4. package/dist/chunks/app-server-runtime-7BJV3LRA.js +2 -0
  5. package/dist/chunks/{apps-U3TXSPU6.js → apps-YSWZT656.js} +1 -1
  6. package/dist/chunks/chunk-2LSP2AAN.js +166 -0
  7. package/dist/chunks/{chunk-RBQZVQQM.js → chunk-3RHPYXUN.js} +1 -1
  8. package/dist/chunks/{chunk-YNH6AUGE.js → chunk-6ZK5EZGN.js} +2 -2
  9. package/dist/chunks/{chunk-TR37PJIQ.js → chunk-ETH4SZO6.js} +11 -28
  10. package/dist/chunks/{chunk-UBHTZJEV.js → chunk-H5WLJNQB.js} +1 -1
  11. package/dist/chunks/{chunk-KLSLHUTO.js → chunk-I7XD5OBR.js} +1 -1
  12. package/dist/chunks/{chunk-F3VURV3Q.js → chunk-JKMPJFMN.js} +2 -2
  13. package/dist/chunks/{chunk-4KDHMGKI.js → chunk-JPCPNW6T.js} +1 -1
  14. package/dist/chunks/chunk-L3KS6MOV.js +2 -0
  15. package/dist/chunks/chunk-MAMUNDBZ.js +26 -0
  16. package/dist/chunks/{chunk-WK5HTGXV.js → chunk-P57W2CB2.js} +1 -1
  17. package/dist/chunks/{chunk-JTX6QZEP.js → chunk-Q6HXXKSB.js} +1 -1
  18. package/dist/chunks/{chunk-5WFXFKLA.js → chunk-SZDIGKZT.js} +333 -333
  19. package/dist/chunks/chunk-TOIG2PMH.js +19 -0
  20. package/dist/chunks/{chunk-AC2M2HO3.js → chunk-WVUPFGU7.js} +1 -1
  21. package/dist/chunks/chunk-XLF7VRKY.js +2 -0
  22. package/dist/chunks/{chunk-M4VGRNP6.js → chunk-Y2KDWP74.js} +1 -1
  23. package/dist/chunks/cli-A7DVODK2.js +2 -0
  24. package/dist/chunks/{configuration-command-BASDSNVK.js → configuration-command-VGYAJAKN.js} +1 -1
  25. package/dist/chunks/{core-commands-YQTVPPLJ.js → core-commands-QQNCA4WQ.js} +1 -1
  26. package/dist/chunks/{desktop-test-JITAYXCK.js → desktop-test-BMDAEN6Z.js} +1 -1
  27. package/dist/chunks/{extension-ZKWQ3ZPJ.js → extension-IQW2KDT6.js} +5 -5
  28. package/dist/chunks/{help-SDEZHWZL.js → help-DZBHIKVE.js} +1 -1
  29. package/dist/chunks/{opchat-IOP37GN3.js → opchat-BSTDLB7O.js} +1 -1
  30. package/dist/chunks/organizations-LAUKUPDF.js +2 -0
  31. package/dist/chunks/profile-ESJFHPYC.js +3 -0
  32. package/dist/chunks/{project-agent-DALYNEZ4.js → project-agent-CPQP4ZY6.js} +1 -1
  33. package/dist/chunks/{sandbox-command-VHCKLKN5.js → sandbox-command-W6NWHFAR.js} +1 -1
  34. package/dist/chunks/{sandbox-template-WY7XIMDK.js → sandbox-template-SM62NUMJ.js} +1 -1
  35. package/dist/chunks/{src-22KEI2VU.js → src-4L62URN6.js} +1 -1
  36. package/dist/chunks/{src-R3FALV6F.js → src-7AFR2KXE.js} +113 -109
  37. package/dist/chunks/{teams-bot-47H7LRFD.js → teams-bot-6LEMA4OH.js} +1 -1
  38. package/dist/chunks/{workspaces-RAHQXYWB.js → workspaces-2ROP4VXW.js} +1 -1
  39. package/dist/cli.js +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/web/assets/App-eRfSvxdE.js +226 -0
  42. package/dist/web/assets/{AppDialog-C3H3HARP.js → AppDialog-FvWvdWfk.js} +1 -1
  43. package/dist/web/assets/{AppTerminalPanel-DIXARKfe.js → AppTerminalPanel-Dfo_tXAE.js} +2 -2
  44. package/dist/web/assets/{AppsView-D0xPDTPJ.js → AppsView-CKg2_SXF.js} +1 -1
  45. package/dist/web/assets/{BrowserSidebar-D5eE9O30.js → BrowserSidebar-CBRz9dVj.js} +1 -1
  46. package/dist/web/assets/{CartesianChart-KMVbiMJX.js → CartesianChart-iXtVfIXm.js} +1 -1
  47. package/dist/web/assets/{CollaborationTabs-C1LTvUbK.js → CollaborationTabs-BFuRwsEy.js} +1 -1
  48. package/dist/web/assets/{CommandMenu-C9elnZaI.js → CommandMenu-Coahy7-K.js} +1 -1
  49. package/dist/web/assets/{CommunityView-BvXxVHmL.js → CommunityView-C0B6EVIp.js} +1 -1
  50. package/dist/web/assets/{ComposerCreateImproveStrip-Cwu8EaCb.js → ComposerCreateImproveStrip-C0MkRhov.js} +1 -1
  51. package/dist/web/assets/{GetStartedView-BI1j30-I.js → GetStartedView-f90pfPRp.js} +1 -1
  52. package/dist/web/assets/HostedModelLearningReview-DdZnSPKb.js +1 -0
  53. package/dist/web/assets/{HostedModelLearningSettings-DhaT1bxX.js → HostedModelLearningSettings-p9RdBxGd.js} +1 -1
  54. package/dist/web/assets/{LabModelVersionDetailPage-CeSm-sAq.js → LabModelVersionDetailPage-DLqT1fMT.js} +1 -1
  55. package/dist/web/assets/{LabSkillSidebar-BzGs7EC8.js → LabSkillSidebar-C7BuAuNK.js} +1 -1
  56. package/dist/web/assets/{LabsRoute-BQi8W0-2.js → LabsRoute-CUVbklNy.js} +4 -4
  57. package/dist/web/assets/{MainChatThread-D3KXQ4Te.js → MainChatThread-Crjs_iFv.js} +2 -2
  58. package/dist/web/assets/{MainPane-J15DRf-n.js → MainPane-Bl91XbhC.js} +7 -7
  59. package/dist/web/assets/{MarkdownText-BWIVACAt.js → MarkdownText-DV3sDJG3.js} +1 -1
  60. package/dist/web/assets/{Messages-BPbo8ih9.js → Messages-Bxo_ATcK.js} +1 -1
  61. package/dist/web/assets/{NativeSkillSidebar-BeqI4dXF.js → NativeSkillSidebar-B3wc0iGh.js} +1 -1
  62. package/dist/web/assets/{NewExperienceSwitcher-BggrQVIi.js → NewExperienceSwitcher-DBdsaysM.js} +1 -1
  63. package/dist/web/assets/{NewProjectDialog-B4PTFf78.js → NewProjectDialog-CtJJ6u5l.js} +1 -1
  64. package/dist/web/assets/{OutputsPage-DChjcyaP.js → OutputsPage-CV9rYjbQ.js} +1 -1
  65. package/dist/web/assets/{ProjectsPage-BdUkyg6I.js → ProjectsPage-O162K_Yb.js} +1 -1
  66. package/dist/web/assets/{RightChatPanelStack-CLCOzLVJ.js → RightChatPanelStack-CXzHpD5V.js} +1 -1
  67. package/dist/web/assets/{RightSidebarHomePanel-qs2Fa4JQ.js → RightSidebarHomePanel-DweT04nf.js} +1 -1
  68. package/dist/web/assets/ScheduledWorkPage-DFvjzhvz.js +1 -0
  69. package/dist/web/assets/SettingsView-B-O30p4h.js +9 -0
  70. package/dist/web/assets/{TeamChatView-uGwanVsA.js → TeamChatView-BoQYnywK.js} +1 -1
  71. package/dist/web/assets/{TerminalOverlay-DJNdErEp.js → TerminalOverlay-oLOOTbdP.js} +1 -1
  72. package/dist/web/assets/{TrainingCreationPanel-CwyKMNwt.js → TrainingCreationPanel-aCFYDuYZ.js} +1 -1
  73. package/dist/web/assets/{TrainingDraftPanel-Rdusv4s_.js → TrainingDraftPanel-CFa1YRTU.js} +1 -1
  74. package/dist/web/assets/{UsageSettingsSection-BkRalGcP.js → UsageSettingsSection-CakaMl6_.js} +1 -1
  75. package/dist/web/assets/{WorkSidebarPanel-d8PB-XNy.js → WorkSidebarPanel-XFwuIBFa.js} +1 -1
  76. package/dist/web/assets/{WorkspaceDiffPanel-DfpyLroX.js → WorkspaceDiffPanel-CL-lAcvW.js} +3 -3
  77. package/dist/web/assets/{WorkspaceEnvironmentMenu-DhUUB-lq.js → WorkspaceEnvironmentMenu-DcFKeae1.js} +1 -1
  78. package/dist/web/assets/{WorkspaceGitDialogs-0juVLtVy.js → WorkspaceGitDialogs-CE6uwWBo.js} +1 -1
  79. package/dist/web/assets/{WorkspaceMonacoEditor-Blo5esSN.js → WorkspaceMonacoEditor-Dd1yWxIF.js} +3 -3
  80. package/dist/web/assets/{arrow-up-right-BXeo-8KJ.js → arrow-up-right-DrBHDOjJ.js} +1 -1
  81. package/dist/web/assets/{chat-file-links-BEbA_E33.js → chat-file-links-DKYaOINv.js} +1 -1
  82. package/dist/web/assets/chevron-up-CT-jxFh0.js +1 -0
  83. package/dist/web/assets/{clipboard-17OIp5F-.js → clipboard-BwxTBPCP.js} +1 -1
  84. package/dist/web/assets/{cloud-upload-D28o8URw.js → cloud-upload-Ce9uYXcQ.js} +1 -1
  85. package/dist/web/assets/{cssMode-DDPYV_bh.js → cssMode-DDD1HmKz.js} +1 -1
  86. package/dist/web/assets/{folder-open-CqBlANkk.js → folder-open-BmWqQp0P.js} +1 -1
  87. package/dist/web/assets/{folder-plus-DkUnvZhx.js → folder-plus-B402AJf4.js} +1 -1
  88. package/dist/web/assets/{git-commit-horizontal-BEIomQj0.js → git-commit-horizontal-C1uAivqm.js} +1 -1
  89. package/dist/web/assets/{htmlMode-gF-t3JxJ.js → htmlMode-1MNILRvh.js} +1 -1
  90. package/dist/web/assets/{index-C5EoPZr0.css → index-BZ4iTv8E.css} +1 -1
  91. package/dist/web/assets/{index-Dg_FWrRZ.js → index-CPTsOhRN.js} +2 -2
  92. package/dist/web/assets/{info-n9PKmODI.js → info-BNROwjpD.js} +1 -1
  93. package/dist/web/assets/{jsonMode-B5DVQ7wE.js → jsonMode-mGxJ8u70.js} +1 -1
  94. package/dist/web/assets/{lspLanguageFeatures-FK4QlUnB.js → lspLanguageFeatures-DnwAgCyz.js} +1 -1
  95. package/dist/web/assets/{minimize-2--J7-Zqg1.js → minimize-2-DFgldo5D.js} +1 -1
  96. package/dist/web/assets/{monaco.contribution-DCmsluF_.js → monaco.contribution-BlgPPKyd.js} +2 -2
  97. package/dist/web/assets/{monaco.contribution-DEkLSjvo.js → monaco.contribution-CBuz55_x.js} +2 -2
  98. package/dist/web/assets/{monaco.contribution-CV2W_Ydj.js → monaco.contribution-CGYtN1vj.js} +2 -2
  99. package/dist/web/assets/{monaco.contribution-CM_Srh4F.js → monaco.contribution-qZ9QzQ68.js} +2 -2
  100. package/dist/web/assets/{play-CT6lFZDI.js → play-BQFyTfNz.js} +1 -1
  101. package/dist/web/assets/{python-DQHHAEpa.js → python-CpsWHcA8.js} +1 -1
  102. package/dist/web/assets/{refresh-cw-Cm-4hHSn.js → refresh-cw-DfFBmfXv.js} +1 -1
  103. package/dist/web/assets/{save-CwgR_oyc.js → save-8XYI0E0Y.js} +1 -1
  104. package/dist/web/assets/{square-DPrPBeHW.js → square-FQ0GLxuE.js} +1 -1
  105. package/dist/web/assets/{toggleHighContrast-C1QZjrPj.js → toggleHighContrast-CX2hgvvU.js} +1 -1
  106. package/dist/web/assets/{tsMode-DY4Ji1ac.js → tsMode-D9XBNmxG.js} +1 -1
  107. package/dist/web/assets/{upload-DABGNAIq.js → upload-BNXILcvp.js} +1 -1
  108. package/dist/web/assets/{useLocalAgentSchedules-D5P28Jej.js → useLocalAgentSchedules-Ccst1Wnz.js} +1 -1
  109. package/dist/web/assets/{wifi-off-CJOdJJRb.js → wifi-off-BoQdtnnN.js} +1 -1
  110. package/dist/web/assets/{workers-BLjr7D_D.js → workers-DpMJzLwE.js} +1 -1
  111. package/dist/web/assets/{yaml-eXk00scV.js → yaml-BqS3gPsN.js} +1 -1
  112. package/dist/web/index.html +2 -2
  113. package/package.json +1 -1
  114. package/dist/chunks/app-server-runtime-QIIJ3KQJ.js +0 -2
  115. package/dist/chunks/chunk-D6BBQHZM.js +0 -28
  116. package/dist/chunks/chunk-M4CJXPMH.js +0 -26
  117. package/dist/chunks/cli-GGYPZNZC.js +0 -2
  118. package/dist/chunks/organizations-4LQEILYG.js +0 -2
  119. package/dist/chunks/profile-MVLYUDLU.js +0 -3
  120. package/dist/web/assets/App-BzNZ7ycx.js +0 -176
  121. package/dist/web/assets/HostedModelLearningReview-Bwkg3lyV.js +0 -1
  122. package/dist/web/assets/ScheduledWorkPage-DzehKDhk.js +0 -1
  123. package/dist/web/assets/SettingsView-DJiJKYWW.js +0 -9
  124. package/dist/web/assets/chevron-up-Dx5rir4H.js +0 -1
@@ -1,2 +0,0 @@
1
- import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{i as a,j as b,k as c}from"./chunk-UBHTZJEV.js";import"./chunk-3YSCXFE6.js";import"./chunk-RBQZVQQM.js";import"./chunk-WK5HTGXV.js";import"./chunk-M4CJXPMH.js";import"./chunk-TR37PJIQ.js";import"./chunk-6MI4KKWF.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-J2S7BOZU.js";import"./chunk-D6BBQHZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-F4WS5QIT.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as resolveWebLaunchMessages,c as runOpenPondAppServerCli,b as runOpenPondServerCli};
@@ -1,2 +0,0 @@
1
- import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{m as B}from"./chunk-Y2NQXJ2Q.js";import"./chunk-TJNIYJUH.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-M4CJXPMH.js";import"./chunk-TR37PJIQ.js";import"./chunk-6MI4KKWF.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-OGPHXXCD.js";import"./chunk-KLSLHUTO.js";import"./chunk-6LY7GYNK.js";import"./chunk-XRV4WLI7.js";import"./chunk-GLUWATL5.js";import"./chunk-4KDHMGKI.js";import{d as x,e as C}from"./chunk-J2S7BOZU.js";import"./chunk-D6BBQHZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-AC2M2HO3.js";import"./chunk-F4WS5QIT.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-F3VURV3Q.js";import{a as _,f as b,h as k,i as E}from"./chunk-3M53YXEI.js";import{a as o}from"./chunk-FTQLQJQV.js";import{createHash as ie,randomBytes as ae}from"node:crypto";import{createServer as le}from"node:http";var Se=new URL(C).hostname,_e=new URL(x).hostname,Ee=`${C}/opchat/v1`;import{spawn as se}from"node:child_process";function L(e,t=process.platform){return t==="darwin"?{command:"open",args:[e]}:t==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",e]}:{command:"xdg-open",args:[e]}}o(L,"resolveSystemBrowserCommand");async function S(e,t={}){let n=t.command??L(e),s=t.handoffTimeoutMs??1500;return new Promise(u=>{let r=!1,i=null,c=o(a=>{r||(r=!0,i&&clearTimeout(i),u(a))},"finish"),p=se(n.command,n.args,{detached:!1,shell:!1,stdio:"ignore",windowsHide:!0});p.once("error",a=>{let l=a.code;c({opened:!1,error:l?`browser launcher ${n.command} failed (${l})`:`browser launcher ${n.command} failed`})}),p.once("close",(a,l)=>{if(a===0){c({opened:!0});return}let d=l?`signal ${l}`:`code ${a??"unknown"}`;c({opened:!1,error:`browser launcher ${n.command} exited with ${d}`})}),i=setTimeout(()=>{p.unref(),c({opened:!0})},s),i.unref()})}o(S,"openUrlWithSystemBrowser");function ce(e){return[e.slug,`team=${e.teamId}`,`role=${e.role}`,`status=${e.status}`,e.displayName].join(" ")}o(ce,"formatOrganizationLine");function ue(e){return[e.email??e.userId,`user=${e.userId}`,`role=${e.role}`,e.createdAt].join(" ")}o(ue,"formatOrganizationMemberLine");function de(e){return e?[e.slug,`team=${e.teamId}`,`status=${e.status}`,`tools=${e.toolset.join(",")||"-"}`,e.resourceUrl].join(" "):"no mcp server configured"}o(de,"formatOrganizationMcpServerLine");var pe=["estimate.read","estimate.write","estimate.execute","artifacts.read","artifacts.write"];function O(e){let t=e.trim().replace(/\/$/,"");if(!t)throw new Error("MCP resource URL must be non-empty");return new URL(t).toString().replace(/\/$/,"")}o(O,"normalizeMcpResourceUrl");function z(e,t){let n=typeof t.resourceUrl=="string"&&t.resourceUrl.trim()?t.resourceUrl.trim():typeof t.url=="string"&&t.url.trim()?t.url.trim():"";if(n)return O(n);if(!e?.resourceUrl)throw new Error("organization does not have an MCP server; run organizations mcp-generate first");return O(e.resourceUrl)}o(z,"resolveMcpProbeResourceUrl");function H(e,t){let n=typeof t.origin=="string"&&t.origin.trim()?t.origin.trim():"";return n?O(n):new URL(e).origin}o(H,"resolveMcpProbeOrigin");function M(e=32){return ae(e).toString("base64url")}o(M,"randomOauthToken");function me(e){return ie("sha256").update(e).digest("base64url")}o(me,"buildMcpOauthPkceChallenge");function fe(e){let t=typeof e.scope=="string"&&e.scope.trim()?e.scope:typeof e.scopes=="string"&&e.scopes.trim()?e.scopes:"";if(!t)return[...pe];let n=t.split(/[,\s]+/g).map(s=>s.trim()).filter(Boolean);if(n.length===0)throw new Error("scope must include at least one OAuth scope");return n}o(fe,"parseMcpOAuthScopes");function ge(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}o(ge,"resolveMcpOAuthClientId");function he(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}o(he,"resolveMcpOAuthTimeoutMs");function ye(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}o(ye,"resolveMcpOAuthCallbackPort");function N(e){return new Promise((t,n)=>{e.close(s=>{s?n(s):t()})})}o(N,"closeServer");async function Pe(e){let t=!1,n=null,s=null,u=null,r=new Promise((a,l)=>{s=a,u=l}),i=o((a,l,d,m,f)=>{if(t){a.writeHead(204).end();return}t=!0,a.writeHead(l,{"cache-control":"no-store","content-type":"text/html; charset=utf-8"}),a.end(d),n&&clearTimeout(n),m?s?.(m):u?.(f??new Error("oauth_callback_failed"))},"settle"),c=le((a,l)=>{let d=a.headers.host??"127.0.0.1",m=new URL(a.url??"/",`http://${d}`);if(m.pathname!=="/callback"){l.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),l.end("Not found");return}let f=m.searchParams.get("state")??"",g=m.searchParams.get("error")??"",P=m.searchParams.get("code")??"";if(f!==e.expectedState){i(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(g){i(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:${g}`));return}if(!P){i(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}i(l,200,"<!doctype html><title>OpenPond OAuth complete</title><p>Authorization complete. You can return to the terminal.</p>",{code:P,state:f})});await new Promise((a,l)=>{let d=o(f=>{c.off("listening",m),l(f)},"onError"),m=o(()=>{c.off("error",d),a()},"onListening");c.once("error",d),c.once("listening",m),c.listen(e.port,"127.0.0.1")});let p=c.address();if(!p||typeof p.port!="number")throw await N(c),new Error("oauth_callback_listener_failed");return n=setTimeout(()=>{t||(t=!0,u?.(new Error("oauth_callback_timeout")))},e.timeoutMs),{close:o(async()=>{n&&clearTimeout(n),await N(c).catch(()=>{})},"close"),redirectUri:`http://127.0.0.1:${p.port}/callback`,waitForCallback:o(()=>r,"waitForCallback")}}o(Pe,"startMcpOAuthCallbackListener");function we(e){S(e)}o(we,"openUrlWithSystemBrowser");function Ae(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()}o(Ae,"buildMcpOAuthAuthorizeUrl");async function Oe(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 n=await fetch(`${e.origin}/oauth/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:t}),s=await j(n);if(!n.ok)throw new Error(`oauth_token_exchange_failed:${n.status}:${JSON.stringify(s)}`);if(!s||typeof s!="object"||Array.isArray(s))throw new Error("oauth_token_exchange_invalid_response");let u=s;if(typeof u.access_token!="string"||!u.access_token.trim())throw new Error("oauth_token_exchange_missing_access_token");return{access_token:u.access_token,...typeof u.expires_in=="number"?{expires_in:u.expires_in}:{},...typeof u.refresh_token=="string"?{refresh_token:u.refresh_token}:{},...typeof u.scope=="string"?{scope:u.scope}:{},...typeof u.token_type=="string"?{token_type:u.token_type}:{}}}o(Oe,"exchangeMcpOAuthAuthorizationCode");async function j(e){let t=await e.text().catch(()=>"");if(!t)return null;let n=t.trim();if((e.headers.get("content-type")??"").toLowerCase().includes("application/json")||n.startsWith("{")||n.startsWith("["))try{return JSON.parse(n)}catch{return t}return t}o(j,"readMcpProbeBody");async function U(e,t={}){let n=await fetch(e,t);return{url:e,status:n.status,ok:n.ok,headers:{contentType:n.headers.get("content-type"),location:n.headers.get("location"),wwwAuthenticate:n.headers.get("www-authenticate")},body:await j(n)}}o(U,"fetchMcpProbe");function be(e,t,n){return n?{jsonrpc:"2.0",id:e,method:t,params:n}:{jsonrpc:"2.0",id:e,method:t}}o(be,"buildMcpJsonRpcRequest");function D(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 n=_(t,"arguments");if(!n||typeof n!="object"||Array.isArray(n))throw new Error("arguments must be a JSON object");return n}o(D,"parseMcpToolArguments");async function R(e){let t={"content-type":"application/json"};return e.accessToken&&(t.authorization=`Bearer ${e.accessToken}`),U(e.resourceUrl,{method:"POST",headers:t,body:JSON.stringify(be(e.id,e.method,e.params))})}o(R,"postMcpJsonRpcProbe");async function $(e){let t=O(e.resourceUrl),n=O(e.origin),s=`${t}/.well-known/oauth-protected-resource`,u=`${n}/.well-known/oauth-authorization-server`,[r,i,c,p,a,l,d]=await Promise.all([U(s),U(u),U(t),R({resourceUrl:t,id:1,method:"initialize"}),R({resourceUrl:t,id:2,method:"tools/list"}),R({resourceUrl:t,id:3,method:"tools/call",params:{name:e.toolName,arguments:e.toolArguments}}),e.accessToken?R({resourceUrl:t,id:4,method:"tools/call",params:{name:e.toolName,arguments:e.toolArguments},accessToken:e.accessToken}):Promise.resolve(null)]);return{resourceUrl:t,origin:n,protectedResource:r,authorizationServer:i,directGetChallenge:c,initialize:p,toolsList:a,unauthenticatedToolCall:l,...d?{authenticatedToolCall:d}:{}}}o($,"probeOrganizationMcp");function ke(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")}o(ke,"parseOrganizationRole");function xe(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()}:{}}}o(xe,"buildOrganizationCreateInput");function Ce(e){let t={},n=typeof e.displayName=="string"&&e.displayName.trim()?e.displayName.trim():typeof e.name=="string"&&e.name.trim()?e.name.trim():"";if(n&&(t.displayName=n),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 s=e.status.trim();if(s!=="active"&&s!=="disabled"&&s!=="archived")throw new Error("status must be active, disabled, or archived");t.status=s}if(Object.keys(t).length===0)throw new Error("organizations update requires at least one changed field");return t}o(Ce,"buildOrganizationUpdateInput");function Re(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:ke(e.role)}}o(Re,"buildOrganizationMemberInput");function Ue(e){return{...typeof e.origin=="string"&&e.origin.trim()?{origin:e.origin.trim()}:{},...typeof e.toolset=="string"&&e.toolset.trim()?{toolset:E(e.toolset)}:{}}}o(Ue,"buildOrganizationMcpGenerateInput");async function go(e,t){let n=t[0]||"list",s=await B(e),u=b(e.json);if(n==="list"){let r=await s.listOrganizations();if(u){console.log(JSON.stringify({organizations:r},null,2));return}if(r.length===0){console.log("no organizations found");return}for(let i of r)console.log(ce(i));return}if(n==="create"){let r=await s.createOrganization(xe(e));console.log(JSON.stringify({organization:r},null,2));return}if(n==="get"){let r=t[1];if(!r)throw new Error("usage: organizations get <slug>");let i=await s.getOrganization(r);console.log(JSON.stringify({organization:i},null,2));return}if(n==="update"){let r=t[1];if(!r)throw new Error("usage: organizations update <slug> [--name <name>]");let i=await s.updateOrganization(r,Ce(e));console.log(JSON.stringify({organization:i},null,2));return}if(n==="members"||n==="member-list"){let r=t[1];if(!r)throw new Error("usage: organizations members <slug>");let i=await s.listOrganizationMembers(r);if(u){console.log(JSON.stringify({members:i},null,2));return}if(i.length===0){console.log("no organization members found");return}for(let c of i)console.log(ue(c));return}if(n==="member-upsert"||n==="member-add"){let r=t[1];if(!r)throw new Error("usage: organizations member-upsert <slug> --email <email> --role <role>");let i=await s.upsertOrganizationMember(r,Re(e));console.log(JSON.stringify({member:i},null,2));return}if(n==="mcp-get"||n==="mcp-server"){let r=t[1];if(!r)throw new Error("usage: organizations mcp-get <slug>");let i=await s.getOrganizationMcpServer(r);if(u){console.log(JSON.stringify({mcpServer:i},null,2));return}console.log(de(i));return}if(n==="mcp-generate"){let r=t[1];if(!r)throw new Error("usage: organizations mcp-generate <slug> [--origin <url>]");let i=await s.generateOrganizationMcpServer(r,Ue(e));console.log(JSON.stringify({mcpServer:i},null,2));return}if(n==="mcp-probe"||n==="mcp-inspect"){let r=t[1];if(!r)throw new Error("usage: organizations mcp-probe <slug> [--origin <url>] [--tool <name>] [--arguments <json>] [--access-token <token>]");let i=await s.getOrganizationMcpServer(r),c=z(i,e),p=H(c,e),a=typeof e.tool=="string"&&e.tool.trim()?e.tool.trim():typeof e.toolName=="string"&&e.toolName.trim()?e.toolName.trim():"estimate_search_history",l=D(e),d=typeof e.accessToken=="string"&&e.accessToken.trim()?e.accessToken.trim():"",m=await $({resourceUrl:c,origin:p,toolName:a,toolArguments:l,...d?{accessToken:d}:{}});console.log(JSON.stringify({mcpServer:i,probe:m},null,2));return}if(n==="mcp-authorize"||n==="mcp-oauth"){let r=t[1];if(!r)throw new Error("usage: organizations mcp-authorize <slug> [--origin <url>] [--scope <csv|space>] [--tool <name>] [--arguments <json>] [--open]");let i=await s.getOrganizationMcpServer(r),c=z(i,e),p=H(c,e),a=ge(e),l=fe(e),d=M(18),m=M(48),f=me(m),g=await Pe({expectedState:d,port:ye(e),timeoutMs:he(e)}),P=Ae({authorizationEndpoint:`${p}/oauth/authorize`,clientId:a,codeChallenge:f,redirectUri:g.redirectUri,resourceUrl:c,scopes:l,state:d});if(console.error("Open this URL to authorize the organization MCP connection:"),console.error(P),console.error(`Waiting for OAuth callback on ${g.redirectUri}`),b(e.open))try{we(P)}catch(w){console.error(`Unable to open a browser automatically: ${w instanceof Error?w.message:String(w)}`)}try{let w=await g.waitForCallback(),h=await Oe({clientId:a,code:w.code,codeVerifier:m,origin:p,redirectUri:g.redirectUri}),F=typeof e.tool=="string"&&e.tool.trim()?e.tool.trim():typeof e.toolName=="string"&&e.toolName.trim()?e.toolName.trim():"estimate_search_history",J=D(e),q=await $({accessToken:h.access_token,origin:p,resourceUrl:c,toolArguments:J,toolName:F}),K=b(e.printToken);console.log(JSON.stringify({mcpServer:i,oauth:{accessTokenReceived:!0,clientId:a,expiresIn:h.expires_in??null,refreshTokenReceived:!!h.refresh_token,scope:h.scope??l.join(" "),tokenType:h.token_type??"Bearer",...K?{accessToken:h.access_token,refreshToken:h.refresh_token??null}:{}},probe:q},null,2))}finally{await g.close()}return}if(n==="mcp-rotate"||n==="mcp-disable"||n==="mcp-enable"){let r=t[1];if(!r)throw new Error(`usage: organizations ${n} <slug>`);let i=n==="mcp-rotate"?await s.rotateOrganizationMcpServer(r):n==="mcp-disable"?await s.disableOrganizationMcpServer(r):await s.enableOrganizationMcpServer(r);console.log(JSON.stringify({mcpServer:i},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]")}o(go,"runOrganizationsCommand");export{pe as DEFAULT_MCP_AUTHORIZE_SCOPES,be as buildMcpJsonRpcRequest,Ae as buildMcpOAuthAuthorizeUrl,me as buildMcpOauthPkceChallenge,xe as buildOrganizationCreateInput,Ue as buildOrganizationMcpGenerateInput,Re as buildOrganizationMemberInput,Ce as buildOrganizationUpdateInput,N as closeServer,Oe as exchangeMcpOAuthAuthorizationCode,U as fetchMcpProbe,ce as formatOrganizationLine,de as formatOrganizationMcpServerLine,ue as formatOrganizationMemberLine,O as normalizeMcpResourceUrl,we as openUrlWithSystemBrowser,fe as parseMcpOAuthScopes,D as parseMcpToolArguments,ke as parseOrganizationRole,R as postMcpJsonRpcProbe,$ as probeOrganizationMcp,M as randomOauthToken,j as readMcpProbeBody,ye as resolveMcpOAuthCallbackPort,ge as resolveMcpOAuthClientId,he as resolveMcpOAuthTimeoutMs,H as resolveMcpProbeOrigin,z as resolveMcpProbeResourceUrl,go as runOrganizationsCommand,Pe as startMcpOAuthCallbackListener};
@@ -1,3 +0,0 @@
1
- import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{i as ue,j as D,k as F,r as fe,s as ge}from"./chunk-C5OV4XWF.js";import{a as he}from"./chunk-BX4J2VDU.js";import{m as B}from"./chunk-Y2NQXJ2Q.js";import"./chunk-TJNIYJUH.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-X37KMV27.js";import{F as le,H as de,I as ce,J as y,e as Y,f as te,g as V,h as ne,i as re,j as se,q as Z,s as ae,t as ie,x as z}from"./chunk-YNH6AUGE.js";import"./chunk-7TV2VBSD.js";import"./chunk-OGPHXXCD.js";import"./chunk-KLSLHUTO.js";import"./chunk-6LY7GYNK.js";import"./chunk-XRV4WLI7.js";import"./chunk-GLUWATL5.js";import"./chunk-4KDHMGKI.js";import"./chunk-J2S7BOZU.js";import"./chunk-D6BBQHZM.js";import"./chunk-EAPFMACH.js";import"./chunk-6FA3GG5B.js";import"./chunk-AC2M2HO3.js";import"./chunk-F4WS5QIT.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-F3VURV3Q.js";import{c as l,d as T,f as g}from"./chunk-3M53YXEI.js";import{a as s}from"./chunk-FTQLQJQV.js";import{readFile as Ae}from"node:fs/promises";import M from"node:path";import Q from"node:path";async function Se(e){if(!e.state.sourcePath)throw new Error("Active OpenPond profile is missing a source path.");let t=e.state.agents.find(m=>m.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=Ce(e.state.sourcePath,t.path),n=await ue(o),a=await D(o,n.entries),c=F(n,a.entries),p=await Re({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}),u=await e.client.projects.uploadSource(p.id,{teamId:e.teamId,entries:c.entries,branch:e.sourceRef,commitMessage:`Materialize OpenPond profile agent ${e.agentId}`}),d=await e.client.projects.sync(u.id,{teamId:e.teamId}),R=me(d)??me(u),C=pe(d)??pe(u)??e.sourceRef,$=`openpond-profile-agent:${e.profileProjectId}:${e.profileName}:${e.agentId}`,w=(await e.client.agents.list({teamId:e.teamId})).find(m=>m.externalId===$),O=await e.client.agents.upsert({teamId:e.teamId,projectId:d.id,name:t.name||e.agentId,slug:$e(e.profileName,e.agentId),selectedEntrypoint:be(e.state,e.agentId),triggerType:"manual",runtimeSource:{mode:"latest_source",...C?{sourceRef:C}:{},...R?{sourceCommitSha:R}:{}},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:$}),N=b(a.uploadMetadata),U=b(N?.commands),I=b(N?.dependencySetup),h=ke(I?.commands),K=[P(U?.validate),P(U?.eval)].filter(m=>!!m);return{status:"uploaded",agentId:e.agentId,runtimeAgentId:O.id,projectId:d.id,sourceRoot:o,sourceRef:C,sourceCommitSha:R??null,manifestHash:d.sandboxManifestHash??null,manifestPath:d.sandboxManifestPath??null,manifestSyncedAt:d.sandboxManifestSyncedAt??null,fileCount:c.fileCount,totalBytes:c.totalBytes,generatedManifestPath:a.generatedManifestPath,synthesizedOpenPondYaml:a.synthesizedOpenPondYaml,uploadMetadataPath:a.uploadMetadataPath,setupCommands:h,validationCommands:K,materializedAt:new Date().toISOString()}}s(Se,"materializeHostedProfileAgentSource");async function Re(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}})}s(Re,"getOrCreateHostedSourceProject");function Ce(e,t){let o=t.replace(/\\/g,"/"),n=Q.resolve(e,o),a=Q.relative(e,n);if(a.startsWith("..")||Q.isAbsolute(a))throw new Error(`Profile agent path escapes profile source: ${t}`);return o==="agent/agent.ts"||o.endsWith("/agent.ts")?e:n}s(Ce,"resolveProfileAgentSourceRoot");function be(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"}}s(be,"hostedEntrypointForProfileAgent");function $e(e,t){return`openpond-profile-${e}-${t}`.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"openpond-profile-agent"}s($e,"hostedRuntimeAgentSlug");function me(e){let t=b(e),o=b(t?.sourceConfig),n=b(t?.metadata);return P(o?.sourceCommitSha)??P(o?.commitSha)??P(o?.remoteSha)??P(n?.projectSourceUploadCommitSha)??P(n?.sourceCommitSha)??P(t?.templateRemoteSha)}s(me,"sandboxProjectSourceCommitSha");function pe(e){let t=b(e),o=b(t?.sourceConfig);return P(o?.sourceRef)??P(o?.branch)??P(t?.gitBranch)??P(t?.defaultBranch)}s(pe,"sandboxProjectSourceRef");function b(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}s(b,"record");function P(e){return typeof e=="string"&&e.trim()?e.trim():null}s(P,"text");function ke(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(ke,"stringArray");async function so(e){let t=await ae({repoPath:l(e,"path")||Z(),profile:l(e,"profile")||"default",template:l(e,"template")||"blank-agent",force:g(e.force)});if(g(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}`)}s(so,"runOpenPondInitCommand");async function ao(e,t){let o=t[0]??"current";if(o==="load"){let n=l(e,"path")||t[1];if(!n)throw new Error("usage: openpond profile load --path <dir> [--profile <name>]");let a=await ie(n,l(e,"profile")||void 0);if(g(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 z();if(g(e.json)){console.log(JSON.stringify(n,null,2));return}X(n);return}if(o==="diff"){let n=await z();if(g(e.json)){console.log(JSON.stringify({diff:n.diff,profile:n},null,2));return}Te(n);return}if(o==="catalog"){let n=await z();if(g(e.json)){console.log(JSON.stringify({catalog:n.catalog,actions:n.actionCatalog,profile:n},null,2));return}Be(n);return}if(o==="commit"){await je(e,t.slice(1));return}if(o==="push"){await Oe(e);return}if(o==="check"){await de(l(e,"kind")||t[1]||"all");return}if(o==="ensure-hosted"){await we(e);return}if(o==="hosted"){let n=t[1]??"status";if(n==="ensure"){await we(e);return}if(n==="status"||n==="current"){await Le(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 qe(e,["list"]);return}throw new Error("usage: openpond profile <status|diff|catalog|commit|push|load|check|agents|hosted|ensure-hosted> [args]")}s(ao,"runOpenPondProfileCommand");async function je(e,t){let o=l(e,"message")||l(e,"commitMessage")||t.join(" ").trim()||void 0,n=await ce(o);if(g(e.json)){console.log(JSON.stringify(n,null,2));return}if(!n.committed){console.log("No profile changes to commit."),X(n.state);return}console.log("Committed OpenPond profile changes."),n.stdout.trim()&&console.log(n.stdout.trim()),X(n.state)}s(je,"runProfileCommitCommand");async function Oe(e){let t=T(e,"usage: openpond profile push"),o=await z();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 B(e),a=g(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 c=g(e.force),p=a.sourceUpload?.sourceCommitSha??null,u=o.hosted?.sourceCommitSha??null;if(u&&p!==u&&!c)throw new Error(["Hosted profile source changed since the last local push.",`Last pushed hosted head: ${u}`,`Current hosted head: ${p??"none"}`,"Inspect hosted changes before pushing, or rerun with --force to overwrite explicitly."].join(`
3
- `));let d=l(e,"hostedSourceAgentId"),R=g(e.hostedSourceChecks),C=g(e.publishHostedSource),$=l(e,"hostedRunAgentId"),w=d||(R||C?$:null),O=JSON.parse(await Ae(o.manifestPath,"utf8")),N=ve(O),U=O.profiles[o.activeProfile??O.defaultProfile]?.path??"profiles/default",I=await ze({state:o,hostedSourceAgentId:w}),h=await n.profile.push({teamId:t,entries:I.entries,branch:o.git.branch??"main",commitMessage:l(e,"commitMessage")||l(e,"message")||`Push OpenPond profile ${o.activeProfile??"default"} at ${o.git.shortHead??o.git.head}`,expectedSourceCommitSha:p,localHeadSha:o.git.head,manifest:N,sourcePath:U,agents:o.agents.map(i=>({id:i.id,path:i.path,enabled:i.enabled}))}),K=new Date().toISOString(),m=o.hosted?.lastPushedLocalHead===o.git.head&&o.hosted?.sourceCommitSha===h.sourceUpload.sourceCommitSha,r={status:"pushed",promotionStatus:m?o.hosted?.promotionStatus??"uploaded":"uploaded",hostedRunStatus:m?o.hosted?.hostedRunStatus??"not_started":"not_started",pushedAt:K,teamId:t,projectId:h.profile.project.id,localHead:o.git.head,hostedHead:h.sourceUpload.sourceCommitSha,sourceRef:h.sourceUpload.sourceRef,hostedRunAgentId:m?o.hosted?.hostedRunAgentId??null:null,hostedRunId:m?o.hosted?.hostedRunId??null:null,hostedRunAt:m?o.hosted?.hostedRunAt??null:null,hostedSourceMaterialization:m?o.hosted?.hostedSourceMaterialization??null:null,hostedSourceCheck:m?o.hosted?.hostedSourceCheck??null:null,hostedPublish:m?o.hosted?.hostedPublish??null:null,hostedRun:m?o.hosted?.hostedRun??null:null};await y(r);let S=w??Ee(o,$),ee=ge(e.hostedSourceDispatch,"hosted-source-dispatch")??"coding_core",_=null,k=null,W=null;if(w&&(R||C||d))try{let i=await Se({client:n,teamId:t,profileProjectId:h.profile.project.id,profileName:o.activeProfile??O.defaultProfile,state:o,agentId:w,sourceRef:h.sourceUpload.sourceRef??o.git.branch??"main",localHead:o.git.head,hostedHead:h.sourceUpload.sourceCommitSha,projectId:l(e,"hostedSourceProjectId")||(o.hosted?.hostedSourceMaterialization?.agentId===w?o.hosted.hostedSourceMaterialization.projectId:null)});r={...r,promotionStatus:"hosted_source_materialized",hostedSourceMaterialization:i},S=i.runtimeAgentId??w,await y(r)}catch(i){let f=i instanceof Error?i.message:String(i);throw r={...r,promotionStatus:"hosted_source_materialize_failed",hostedSourceMaterialization:{status:"failed",agentId:w,projectId:l(e,"hostedSourceProjectId")??null,error:f},error:f},await y(r),new Error(`Hosted source materialization failed after push: ${f}`)}if(R||C){if(!w)throw new Error("--hosted-source-agent-id or --hosted-run-agent-id is required for hosted source checks or publish.");if(!S)throw new Error("Unable to resolve the hosted runtime agent for source checks.");try{if(_=await n.agents.sourceDeployPlan(S,{teamId:t}),R){let i=r.hostedSourceMaterialization?.sourceRef??h.sourceUpload.sourceRef,f=r.hostedSourceMaterialization?.sourceCommitSha??h.sourceUpload.sourceCommitSha;if(k=await n.agents.requestSourceChecks(S,{teamId:t,...i?{sourceRef:i}:{},...f?{baseSha:f}:{},checkKind:fe(l(e,"hostedCheckKind")||l(e,"checkKind"))??"all",dispatch:ee,metadata:{source:"openpond_profile_push_checks",localHead:o.git.head,hostedHead:h.sourceUpload.sourceCommitSha,materializedProjectId:r.hostedSourceMaterialization?.projectId??null,materializedSourceCommitSha:r.hostedSourceMaterialization?.sourceCommitSha??null,sourceRef:i,dispatch:ee}}),k.dispatchResult?.status==="failed")throw new Error(k.dispatchResult.error??"hosted_source_check_dispatch_failed");if(k.dispatchResult?.status==="completed"){let L=J(k.sourceCheckStatus);xe(L)&&(await _e({client:n,teamId:t,runtimeAgentId:S,sourceRef:i,sourceCommitSha:f,validatedAt:new Date().toISOString()}),_=await n.agents.sourceDeployPlan(S,{teamId:t}))}}r={...r,promotionStatus:R?"hosted_source_check_pending":r.promotionStatus,hostedSourceCheck:V({agentId:S,status:R?"requested":"deploy_plan_ready",deployPlan:_,checkResult:k})},await y(r)}catch(i){let f=i instanceof Error?i.message:String(i);throw r={...r,promotionStatus:"hosted_source_check_failed",hostedSourceCheck:V({agentId:S,status:"failed",deployPlan:_,checkedAt:new Date().toISOString(),error:f}),error:f},await y(r),new Error(`Hosted source check failed after push: ${f}`)}}if(C){if(!w)throw new Error("--hosted-source-agent-id or --hosted-run-agent-id is required for hosted source publish.");if(!S)throw new Error("Unable to resolve the hosted runtime agent for source publish.");try{let i=l(e,"expectedManifestHash")||r.hostedSourceCheck?.manifestHash||_?.source.manifestHash||void 0;W=await n.agents.publishSource(S,{teamId:t,...i?{expectedManifestHash:i}:{},...r.hostedSourceMaterialization?.sourceCommitSha??h.sourceUpload.sourceCommitSha?{expectedSourceCommitSha:r.hostedSourceMaterialization?.sourceCommitSha??h.sourceUpload.sourceCommitSha}:{}}),r={...r,promotionStatus:"hosted_source_published",hostedPublish:ne({agentId:S,publishResult:W})},await y(r)}catch(i){let f=i instanceof Error?i.message:String(i);throw r={...r,promotionStatus:"hosted_source_publish_failed",hostedPublish:{status:"failed",agentId:S,error:f},error:f},await y(r),new Error(`Hosted source publish failed after push: ${f}`)}}let A=null;if($){let i=S||$,f=new Date().toISOString(),L=Fe(e,"hostedRunInput")??{prompt:"hello",channel:"openpond_chat"},q=l(e,"hostedRunConversationId")||l(e,"conversationId"),H=l(e,"hostedRunTargetProjectId"),oe=he({explicitKey:l(e,"hostedRunIdempotencyKey"),retry:g(e.hostedRunRetry),localHead:o.git.head,sourceHead:r.hostedSourceMaterialization?.sourceCommitSha??h.sourceUpload.sourceCommitSha,runtimeAgentId:i,targetProjectId:H,input:L});await y({...r,promotionStatus:"hosted_run_pending",hostedRunStatus:"running",hostedRunAgentId:i,hostedRunAt:f});try{A=await n.agents.run(i,{teamId:t,...q?{conversationId:q}:{},...H?{targetProjectId:H}:{},...H?{targetProject:{id:H}}:{},idempotencyKey:oe,input:L,metadata:{source:"openpond_profile_push_run",...q?{conversationId:q}:{},targetProjectId:H||null,localHead:o.git.head,hostedHead:h.sourceUpload.sourceCommitSha,hostedRunIdempotencyKey:oe,hostedRunRetry:g(e.hostedRunRetry),materializedProjectId:r.hostedSourceMaterialization?.projectId??null,materializedSourceCommitSha:r.hostedSourceMaterialization?.sourceCommitSha??null,sourceRef:r.hostedSourceMaterialization?.sourceRef??h.sourceUpload.sourceRef,publishedSnapshotId:r.hostedPublish?.snapshotId??null,manifestHash:r.hostedPublish?.manifestHash??r.hostedSourceCheck?.manifestHash??null},runtimeSourcePolicy:C?{requirePublishedSnapshot:!0,source:"diagnostic"}:{allowLatestSource:!0,source:"diagnostic"}});let v=re({agentId:i,runResult:A}),j=se(v);await y({...r,promotionStatus:j==="passed"?"hosted_run_passed":j==="failed"?"hosted_run_failed":"hosted_run_pending",hostedRunStatus:j,hostedRunAgentId:i,hostedRunId:A.run.id,hostedRunAt:A.run.createdAt??f,hostedRun:v})}catch(v){let j=v instanceof Error?v.message:String(v);throw await y({...r,promotionStatus:"hosted_run_failed",hostedRunStatus:"failed",hostedRunAgentId:i,hostedRunAt:new Date().toISOString(),hostedRun:{status:"failed",agentId:i,error:j},error:j}),new Error(`Hosted invocation failed to start after push: ${j}`)}}if(g(e.json)){console.log(JSON.stringify({...h,uploaded:He(I),hostedSourceMaterialization:r.hostedSourceMaterialization??null,hostedSourceChecks:k,hostedSourcePublish:W,hostedRun:A},null,2));return}console.log(`Pushed OpenPond profile ${o.activeProfile??"default"} to hosted profile repo.`),console.log(`Project id: ${h.profile.project.id}`),console.log(`Local head: ${o.git.head}`),console.log(`Hosted source commit: ${h.sourceUpload.sourceCommitSha??"unknown"}`),console.log(`Uploaded ${I.fileCount} file(s), ${I.totalBytes} byte(s) via ${I.transport.mode} (limits: ${I.limits.maxFiles} files, ${I.limits.maxFileBytes} bytes/file, ${I.limits.maxTotalBytes} bytes total).`),console.log(A?`Hosted invocation: running ${A.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: ${I.fileCount}`)}s(Oe,"runProfilePushCommand");function He(e){return{fileCount:e.fileCount,totalBytes:e.totalBytes,limits:e.limits,transport:e.transport}}s(He,"summarizeProfileSourceUpload");function ve(e){return{...e,profiles:Object.fromEntries(Object.entries(e.profiles).map(([t,o])=>[t,{path:o.path,defaultAgent:o.defaultAgent??"default",enabledAgents:o.enabledAgents??[]}]))}}s(ve,"normalizeHostedProfileManifest");async function ze(e){let t=e.state.repoPath;if(!t)throw new Error("Active OpenPond profile is missing a repository path.");let o=await te(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(u=>u.id===e.hostedSourceAgentId);if(!n)throw new Error(`Profile agent not found for hosted source upload: ${e.hostedSourceAgentId}`);let a=Me(e.state.sourcePath,n.path),c=M.relative(t,a).replace(/\\/g,"/");if(c.startsWith("..")||M.isAbsolute(c))throw new Error(`Profile agent path escapes profile repo: ${n.path}`);let p=await D(a,[]);return p.entries.length===0?o:F(o,p.entries.map(u=>({...u,path:c?`${c}/${u.path}`:u.path})))}s(ze,"collectProfileSourceUploadForPush");function Me(e,t){let o=t.replace(/\\/g,"/"),n=M.resolve(e,o),a=M.relative(e,n);if(a.startsWith("..")||M.isAbsolute(a))throw new Error(`Profile agent path escapes profile source: ${t}`);return o==="agent/agent.ts"||o.endsWith("/agent.ts")?e:n}s(Me,"resolveProfileAgentSourceRoot");function J(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}s(J,"record");function E(e){return typeof e=="string"&&e.trim()?e.trim():null}s(E,"text");function Ee(e,t){if(!t)return null;let o=e.hosted?.hostedSourceMaterialization;return o?.agentId===t&&o.runtimeAgentId?o.runtimeAgentId:t}s(Ee,"resolveHostedRuntimeAgentIdForRun");async function _e(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}})}s(_e,"bindValidatedHostedRuntimeSource");function xe(e){if(!e)return!1;let t=E(e.finalResultState)?.toLowerCase();if(t&&t!=="completed"&&!Ie(t))return!1;let o=Array.isArray(e.checkRuns)?e.checkRuns.map(J).filter(d=>!!d):[];if(o.some(Ne))return!1;let n=o.some(d=>G(d).includes("build")&&x(d)),a=x(J(e.validation))||o.some(d=>G(d).includes("validate")&&x(d)),c=J(e.eval),u=!((E(e.requestedCheckKind)??"all")==="all"||(E(e.requestedCheckKind)??"")==="eval"||!!c||o.some(d=>G(d).includes("eval")))||x(c)||o.some(d=>G(d).includes("eval")&&x(d));return n&&a&&u}s(xe,"sourceCheckStatusPassed");function G(e){return(E(e.command)??"").toLowerCase()}s(G,"checkRunCommand");function Ne(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=E(e.status)?.toLowerCase();return!!(n&&Ue(n))}s(Ne,"checkRunFailed");function x(e){if(!e)return!1;if(typeof e.passed=="boolean")return e.passed;let t=Pe(e.failed)??Pe(e.failedCount);if(t!==null&&t>0)return!1;let o=e.exitCode;if(typeof o=="number")return o===0;let n=E(e.status)?.toLowerCase();return!!(n&&Ie(n))}s(x,"checkEvidencePassed");function Pe(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}s(Pe,"numericEvidence");function Ie(e){return e==="passed"||e==="succeeded"||e==="success"}s(Ie,"passingStatus");function Ue(e){return e==="failed"||e==="failure"||e==="cancelled"}s(Ue,"failingStatus");async function Le(e){let t=T(e,"usage: openpond profile hosted status"),n=await(await B(e)).profile.get({teamId:t});if(g(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}ye(n)}s(Le,"runHostedProfileStatusCommand");async function we(e){let t=T(e,"usage: openpond profile ensure-hosted"),n=await(await B(e)).profile.ensureHosted({teamId:t});if(g(e.json)){console.log(JSON.stringify({profile:n},null,2));return}ye(n)}s(we,"runHostedProfileEnsureCommand");async function qe(e,t){if((t[0]??"list")!=="list")throw new Error("usage: openpond agents list [--json]");let n=await z();if(n.error)throw new Error(n.error);if(g(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}`)}s(qe,"runOpenPondAgentsCommand");async function io(e,t,o){let n=l(t,"cwd"),a=[...o,...De(t,new Set(["cwd","account","profile","handle","baseUrl"]))];await le({command:e,cwd:n?M.resolve(n):void 0,args:a,inherit:!0})}s(io,"runOpenPondProfileSdkAlias");function X(e){if(e.mode==="none"){console.log("No active OpenPond profile."),console.log(`Default location: ${Z()}`);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(` ${Y(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}`)}}}s(X,"printProfileState");function Te(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}`)}s(Te,"printProfileDiff");function Be(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",c=e.setupGate.blockingRequirements.filter(u=>u.actionId===o.id),p=c.length?`setup_required:${c.map(u=>u.label).join(",")}`:"setup_ready";console.log(`${o.id} ${a} ${p} ${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(` ${Y(o)}`)}}s(Be,"printProfileCatalog");function ye(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}`)}}s(ye,"printHostedProfileSummary");function De(e,t){let o=[],n=new Set(["force","json"]);for(let[a,c]of Object.entries(e)){if(t.has(a))continue;let p=`--${a.replace(/[A-Z]/g,u=>`-${u.toLowerCase()}`)}`;if(c===!0||n.has(a)&&c==="true")o.push(p);else{if(n.has(a)&&c==="false")continue;typeof c=="string"&&o.push(p,c)}}return o}s(De,"optionArgs");function Fe(e,t){let o=l(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}s(Fe,"parseJsonObjectOption");export{ze as collectProfileSourceUploadForPush,qe as runOpenPondAgentsCommand,so as runOpenPondInitCommand,ao as runOpenPondProfileCommand,io as runOpenPondProfileSdkAlias};