openpond 0.2.29 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/api/types.d.ts +8 -0
  2. package/dist/app-server.d.ts +27797 -513
  3. package/dist/app-server.js +1 -1
  4. package/dist/chunks/{actions-command-NOCBOF5S.js → actions-command-6LFZFTLA.js} +1 -1
  5. package/dist/chunks/{app-layer-GLXYIT4B.js → app-layer-ZZHTHTJU.js} +1 -1
  6. package/dist/chunks/app-server-runtime-256UCS6N.js +2 -0
  7. package/dist/chunks/{apps-YSWZT656.js → apps-C2BMJ7DO.js} +1 -1
  8. package/dist/chunks/{chunk-GOQDMRUV.js → chunk-34URWDE7.js} +1 -1
  9. package/dist/chunks/chunk-4476RDBS.js +41 -0
  10. package/dist/chunks/{chunk-J3ZRHNGL.js → chunk-4QX2I2DX.js} +1 -1
  11. package/dist/chunks/{chunk-TOIG2PMH.js → chunk-55UCBRIX.js} +1 -1
  12. package/dist/chunks/{chunk-2LSP2AAN.js → chunk-5BFWDFPX.js} +1 -1
  13. package/dist/chunks/{chunk-JPCPNW6T.js → chunk-B5LKUQGM.js} +1 -1
  14. package/dist/chunks/{chunk-I7XD5OBR.js → chunk-BAKCGJ5D.js} +1 -1
  15. package/dist/chunks/{chunk-7GN6B4NP.js → chunk-CE27WEHK.js} +1 -1
  16. package/dist/chunks/{chunk-7TV2VBSD.js → chunk-DR3XPQRZ.js} +1 -1
  17. package/dist/chunks/{chunk-C5OV4XWF.js → chunk-EFTLCT7C.js} +1 -1
  18. package/dist/chunks/{chunk-O2IWIXBH.js → chunk-GCU66EAF.js} +1 -1
  19. package/dist/chunks/{chunk-F4WS5QIT.js → chunk-IFP6W4OW.js} +22 -22
  20. package/dist/chunks/{chunk-I5K74TOH.js → chunk-JEVA7YQL.js} +2 -2
  21. package/dist/chunks/{chunk-JKMPJFMN.js → chunk-JFR34MIK.js} +2 -2
  22. package/dist/chunks/chunk-JVIHGSOV.js +6 -0
  23. package/dist/chunks/{chunk-6ZK5EZGN.js → chunk-K6EGNB2A.js} +1 -1
  24. package/dist/chunks/chunk-L2UT3YIF.js +5 -0
  25. package/dist/chunks/{chunk-XLF7VRKY.js → chunk-L54LZUGH.js} +1 -1
  26. package/dist/chunks/{chunk-J2S7BOZU.js → chunk-MJC26GOX.js} +4 -4
  27. package/dist/chunks/{chunk-MAMUNDBZ.js → chunk-MVAJMRCW.js} +3 -3
  28. package/dist/chunks/{chunk-Y2NQXJ2Q.js → chunk-MXLB6MEW.js} +1 -1
  29. package/dist/chunks/chunk-PSZKG3E3.js +4 -0
  30. package/dist/chunks/{chunk-LYCKR4HT.js → chunk-PZ6KPMEZ.js} +342 -335
  31. package/dist/chunks/{chunk-XRV4WLI7.js → chunk-QPZNN5Q3.js} +1 -1
  32. package/dist/chunks/{chunk-ETH4SZO6.js → chunk-QTEYV4TW.js} +1 -1
  33. package/dist/chunks/{chunk-Y2KDWP74.js → chunk-T22TCCWW.js} +1 -1
  34. package/dist/chunks/{chunk-WVUPFGU7.js → chunk-UU7RXSJS.js} +1 -1
  35. package/dist/chunks/{chunk-TJNIYJUH.js → chunk-XCTFXXVY.js} +1 -1
  36. package/dist/chunks/{chunk-6LY7GYNK.js → chunk-Z6F6PYF4.js} +1 -1
  37. package/dist/chunks/cli-DSFTE4KT.js +2 -0
  38. package/dist/chunks/{configuration-command-VGYAJAKN.js → configuration-command-IHUB6BBM.js} +1 -1
  39. package/dist/chunks/{core-commands-QQNCA4WQ.js → core-commands-F2HIN7V4.js} +1 -1
  40. package/dist/chunks/{desktop-test-BMDAEN6Z.js → desktop-test-BFFUGVRS.js} +1 -1
  41. package/dist/chunks/{dist-5C6RYTQQ.js → dist-XCT2G25K.js} +1 -1
  42. package/dist/chunks/extension-D7IYZW7H.js +4 -0
  43. package/dist/chunks/{help-DZBHIKVE.js → help-5MKQV36D.js} +1 -1
  44. package/dist/chunks/opchat-XO7EDHY7.js +3 -0
  45. package/dist/chunks/{organizations-LAUKUPDF.js → organizations-DIRGTVK5.js} +1 -1
  46. package/dist/chunks/{profile-ESJFHPYC.js → profile-EMVJ5DJQ.js} +1 -1
  47. package/dist/chunks/{project-agent-CPQP4ZY6.js → project-agent-4QC7N3MB.js} +1 -1
  48. package/dist/chunks/{sandbox-command-W6NWHFAR.js → sandbox-command-L263BBOL.js} +1 -1
  49. package/dist/chunks/{sandbox-template-SM62NUMJ.js → sandbox-template-RYKWTBW7.js} +1 -1
  50. package/dist/chunks/{src-4L62URN6.js → src-RINMQ7IQ.js} +1 -1
  51. package/dist/chunks/src-RM2LIZGT.js +325 -0
  52. package/dist/chunks/{teams-bot-6LEMA4OH.js → teams-bot-NIZB6DOY.js} +1 -1
  53. package/dist/chunks/{workspaces-ERYPHR26.js → workspaces-GPYDSN4C.js} +1 -1
  54. package/dist/cli.js +1 -1
  55. package/dist/hosted-chat.d.ts +1 -0
  56. package/dist/index.js +1 -1
  57. package/dist/web/assets/App-BcbjzSeU.js +226 -0
  58. package/dist/web/assets/{AppDialog-FvWvdWfk.js → AppDialog-C1cvE0gH.js} +1 -1
  59. package/dist/web/assets/{AppTerminalPanel-Dfo_tXAE.js → AppTerminalPanel-BFJNR2ik.js} +2 -2
  60. package/dist/web/assets/{AppsView-CKg2_SXF.js → AppsView-CReOofAf.js} +1 -1
  61. package/dist/web/assets/BrowserSidebar-CPxAck2O.js +1 -0
  62. package/dist/web/assets/{CartesianChart-iXtVfIXm.js → CartesianChart-SlZ8Qfkg.js} +1 -1
  63. package/dist/web/assets/{CollaborationTabs-BFuRwsEy.js → CollaborationTabs-DgFEunqQ.js} +1 -1
  64. package/dist/web/assets/{CommandMenu-Coahy7-K.js → CommandMenu-BiROlSdv.js} +1 -1
  65. package/dist/web/assets/CommunityView-DVST_ZxO.js +1 -0
  66. package/dist/web/assets/ComposerCreateImproveStrip-jRBhdiFB.js +1 -0
  67. package/dist/web/assets/GetStartedView-Ck4EW1_s.js +1 -0
  68. package/dist/web/assets/HostedModelLearningReview-DYFjp-96.js +1 -0
  69. package/dist/web/assets/HostedModelLearningSettings-BD7quEFA.js +1 -0
  70. package/dist/web/assets/LabModelVersionDetailPage-8-Gb5AAH.js +1 -0
  71. package/dist/web/assets/{LabSkillSidebar-C7BuAuNK.js → LabSkillSidebar-DO-kFl9Z.js} +1 -1
  72. package/dist/web/assets/{LabsRoute-CUVbklNy.js → LabsRoute-Dc9RQKdA.js} +6 -6
  73. package/dist/web/assets/MainChatThread-DZXcFgmJ.js +2 -0
  74. package/dist/web/assets/MainPane-BYrnuI30.js +19 -0
  75. package/dist/web/assets/{MarkdownText-DV3sDJG3.js → MarkdownText-ueZFkEyk.js} +21 -21
  76. package/dist/web/assets/{NativeSkillSidebar-B3wc0iGh.js → NativeSkillSidebar-DlAX2-dH.js} +1 -1
  77. package/dist/web/assets/NewExperienceSwitcher-BHYLG0IZ.js +1 -0
  78. package/dist/web/assets/NewProjectDialog-BwN6SnxR.js +1 -0
  79. package/dist/web/assets/OutputsPage-Q0kpdfq_.js +1 -0
  80. package/dist/web/assets/ProjectsPage-TnlBYfFy.js +1 -0
  81. package/dist/web/assets/{ProjectsPage-DdG-U9ZW.css → ProjectsPage-kun3Ron2.css} +1 -1
  82. package/dist/web/assets/RightChatPanelStack-D2qZ-1nK.js +1 -0
  83. package/dist/web/assets/{RightSidebarHomePanel-DweT04nf.js → RightSidebarHomePanel-q6FF-DR9.js} +1 -1
  84. package/dist/web/assets/ScheduledWorkPage-BTX3Sjoa.js +1 -0
  85. package/dist/web/assets/SettingsView-C7av3zwv.css +1 -0
  86. package/dist/web/assets/SettingsView-gAhNO4Rg.js +9 -0
  87. package/dist/web/assets/{TeamChatView-BoQYnywK.js → TeamChatView-DZtfZ12z.js} +2 -2
  88. package/dist/web/assets/{TerminalOverlay-oLOOTbdP.js → TerminalOverlay-MJqx0xg6.js} +1 -1
  89. package/dist/web/assets/{TrainingCreationPanel-aCFYDuYZ.js → TrainingCreationPanel-ORoKcc3m.js} +1 -1
  90. package/dist/web/assets/{TrainingDraftPanel-CFa1YRTU.js → TrainingDraftPanel-oolNVDIx.js} +1 -1
  91. package/dist/web/assets/{UsageSettingsSection-CakaMl6_.js → UsageSettingsSection-Lh_fLOcC.js} +1 -1
  92. package/dist/web/assets/WorkSidebarPanel-BIqP9SXr.js +1 -0
  93. package/dist/web/assets/WorkspaceDiffPanel-B0Zwyx9a.js +14 -0
  94. package/dist/web/assets/WorkspaceEnvironmentMenu-BpgvG43X.js +32 -0
  95. package/dist/web/assets/{WorkspaceGitDialogs-CE6uwWBo.js → WorkspaceGitDialogs-Bw5ADFuc.js} +1 -1
  96. package/dist/web/assets/{WorkspaceMonacoEditor-Dd1yWxIF.js → WorkspaceMonacoEditor-BpivuGzo.js} +3 -3
  97. package/dist/web/assets/{arrow-up-right-DrBHDOjJ.js → arrow-up-right-BjC4ygxR.js} +1 -1
  98. package/dist/web/assets/{clipboard-BwxTBPCP.js → clipboard-BOJ-sNJz.js} +1 -1
  99. package/dist/web/assets/{cloud-upload-Ce9uYXcQ.js → cloud-upload-D-_3UWhI.js} +1 -1
  100. package/dist/web/assets/{cssMode-DDD1HmKz.js → cssMode-CnHRib-_.js} +1 -1
  101. package/dist/web/assets/{folder-open-BmWqQp0P.js → folder-open-CO3Vz0rT.js} +1 -1
  102. package/dist/web/assets/{folder-plus-B402AJf4.js → folder-plus-CL6B10XJ.js} +1 -1
  103. package/dist/web/assets/{git-commit-horizontal-C1uAivqm.js → git-commit-horizontal-C_SNHoOD.js} +1 -1
  104. package/dist/web/assets/git-dialogs-C-F47S10.css +1 -0
  105. package/dist/web/assets/{htmlMode-1MNILRvh.js → htmlMode-DBpIV7Gx.js} +1 -1
  106. package/dist/web/assets/{index-CPTsOhRN.js → index-Dx0lr1R3.js} +2 -2
  107. package/dist/web/assets/index-lqk3IxE0.css +1 -0
  108. package/dist/web/assets/{info-BNROwjpD.js → info-C1C3X2vW.js} +1 -1
  109. package/dist/web/assets/{jsonMode-mGxJ8u70.js → jsonMode-B9puI-La.js} +1 -1
  110. package/dist/web/assets/{lspLanguageFeatures-DnwAgCyz.js → lspLanguageFeatures-DwPRvLkn.js} +1 -1
  111. package/dist/web/assets/{minimize-2-DFgldo5D.js → minimize-2-Cr76Lc_J.js} +1 -1
  112. package/dist/web/assets/{monaco.contribution-BlgPPKyd.js → monaco.contribution-CnlZLXhW.js} +2 -2
  113. package/dist/web/assets/{monaco.contribution-CBuz55_x.js → monaco.contribution-DKa3PSXH.js} +2 -2
  114. package/dist/web/assets/{monaco.contribution-qZ9QzQ68.js → monaco.contribution-DQxsY08y.js} +2 -2
  115. package/dist/web/assets/{monaco.contribution-CGYtN1vj.js → monaco.contribution-OemObo_b.js} +2 -2
  116. package/dist/web/assets/monitor-CktBkAZk.js +1 -0
  117. package/dist/web/assets/{python-CpsWHcA8.js → python-CVC74_7Q.js} +1 -1
  118. package/dist/web/assets/refresh-cw-JaxiGpHD.js +1 -0
  119. package/dist/web/assets/{save-8XYI0E0Y.js → save-DFm1K29k.js} +1 -1
  120. package/dist/web/assets/{square-FQ0GLxuE.js → square-D5fFhDFt.js} +1 -1
  121. package/dist/web/assets/{toggleHighContrast-CX2hgvvU.js → toggleHighContrast-D_EkCruq.js} +1 -1
  122. package/dist/web/assets/{tsMode-D9XBNmxG.js → tsMode-BczIS4rA.js} +1 -1
  123. package/dist/web/assets/{upload-BNXILcvp.js → upload-DvED7nbd.js} +1 -1
  124. package/dist/web/assets/{useLocalAgentSchedules-Ccst1Wnz.js → useLocalAgentSchedules-DWd5OvYb.js} +1 -1
  125. package/dist/web/assets/useSessionTurnCache-oMoxBcGj.js +1 -0
  126. package/dist/web/assets/{wifi-off-BoQdtnnN.js → wifi-off-BZL-Op_B.js} +1 -1
  127. package/dist/web/assets/{workers-DpMJzLwE.js → workers-DapCJCaQ.js} +1 -1
  128. package/dist/web/assets/{yaml-BqS3gPsN.js → yaml-DB9KLqu1.js} +1 -1
  129. package/dist/web/index.html +2 -2
  130. package/docs/command-reference.md +1 -0
  131. package/package.json +1 -1
  132. package/dist/chunks/app-server-runtime-SL7IFG2M.js +0 -2
  133. package/dist/chunks/chunk-3YSCXFE6.js +0 -5
  134. package/dist/chunks/chunk-JPERN6WI.js +0 -40
  135. package/dist/chunks/chunk-P57W2CB2.js +0 -6
  136. package/dist/chunks/cli-DBIRAAYU.js +0 -2
  137. package/dist/chunks/extension-IQW2KDT6.js +0 -6
  138. package/dist/chunks/opchat-BSTDLB7O.js +0 -3
  139. package/dist/chunks/src-MBP4EHYL.js +0 -323
  140. package/dist/web/assets/App-eRfSvxdE.js +0 -226
  141. package/dist/web/assets/BrowserSidebar-CBRz9dVj.js +0 -1
  142. package/dist/web/assets/CommunityView-C0B6EVIp.js +0 -1
  143. package/dist/web/assets/ComposerCreateImproveStrip-C0MkRhov.js +0 -1
  144. package/dist/web/assets/GetStartedView-f90pfPRp.js +0 -1
  145. package/dist/web/assets/HostedModelLearningReview-DdZnSPKb.js +0 -1
  146. package/dist/web/assets/HostedModelLearningSettings-p9RdBxGd.js +0 -1
  147. package/dist/web/assets/LabModelVersionDetailPage-DLqT1fMT.js +0 -1
  148. package/dist/web/assets/MainChatThread-Crjs_iFv.js +0 -2
  149. package/dist/web/assets/MainPane-Bl91XbhC.js +0 -10
  150. package/dist/web/assets/Messages-Bxo_ATcK.js +0 -10
  151. package/dist/web/assets/NewExperienceSwitcher-DBdsaysM.js +0 -1
  152. package/dist/web/assets/NewProjectDialog-CtJJ6u5l.js +0 -1
  153. package/dist/web/assets/OutputsPage-CV9rYjbQ.js +0 -1
  154. package/dist/web/assets/ProjectsPage-O162K_Yb.js +0 -1
  155. package/dist/web/assets/RightChatPanelStack-CXzHpD5V.js +0 -1
  156. package/dist/web/assets/ScheduledWorkPage-DFvjzhvz.js +0 -1
  157. package/dist/web/assets/SettingsView-B-O30p4h.js +0 -9
  158. package/dist/web/assets/SettingsView-BaWWvIJW.css +0 -1
  159. package/dist/web/assets/WorkSidebarPanel-XFwuIBFa.js +0 -1
  160. package/dist/web/assets/WorkspaceDiffPanel-CL-lAcvW.js +0 -14
  161. package/dist/web/assets/WorkspaceEnvironmentMenu-DcFKeae1.js +0 -32
  162. package/dist/web/assets/chat-file-links-DKYaOINv.js +0 -1
  163. package/dist/web/assets/chevron-up-CT-jxFh0.js +0 -1
  164. package/dist/web/assets/desktop-files-BQj1J-ob.js +0 -1
  165. package/dist/web/assets/git-dialogs-BZDqS1eT.css +0 -1
  166. package/dist/web/assets/index-BZ4iTv8E.css +0 -1
  167. package/dist/web/assets/play-BQFyTfNz.js +0 -1
  168. package/dist/web/assets/refresh-cw-DfFBmfXv.js +0 -1
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{$a as L,_a as H,jb as S}from"./chunk-F4WS5QIT.js";import{f as A,h as O}from"./chunk-H7IWJN7L.js";import{a as l}from"./chunk-FTQLQJQV.js";import Q from"node:path";var U="default",z=["apiKey","baseUrl","apiBaseUrl","chatApiBaseUrl","token","appId","conversationId"];function re(){return V()}l(re,"getConfigPath");function V(){return O(A()).config}l(V,"getGlobalConfigPath");function m(n,e){return Object.prototype.hasOwnProperty.call(n,e)}l(m,"hasOwn");function h(n){if(typeof n!="string")return null;let e=n.trim();return e.length>0?e:null}l(h,"normalizeHandle");function d(n){if(typeof n!="string")return null;let e=n.trim();return e?e.replace(/\/$/,""):null}l(d,"normalizeBaseUrl");function q(n){let e=h(n);if(!e)throw new Error("profile handle must be non-empty");return e}l(q,"requireHandle");function W(n){if(typeof n!="string")throw new Error("apiKey must be a non-empty string");let e=n.trim();if(!e)throw new Error("apiKey must be a non-empty string");return e}l(W,"requireApiKey");function b(n,e){let t=h(n),s=h(e);return!!(t&&s&&t.toLowerCase()===s.toLowerCase())}l(b,"handleEquals");function v(n,e,t){let s=d(t);return n.findIndex(i=>b(i.handle,e)?s?d(i.baseUrl)===s:!0:!1)}l(v,"findAccountIndex");function P(n){let e=h(n.handle)??U,t=d(n.baseUrl);return t?{handle:e,baseUrl:t}:{handle:e}}l(P,"selectorFromAccount");function y(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=h(typeof e.handle=="string"?e.handle:void 0);if(!t)return null;let s=d(typeof e.baseUrl=="string"?e.baseUrl:void 0);return s?{handle:t,baseUrl:s}:{handle:t}}l(y,"sanitizeActiveProfile");function B(n){if(!n||typeof n!="object"||Array.isArray(n))return;let e=n,t=typeof e.repoPath=="string"?e.repoPath.trim():"",s=typeof e.profile=="string"&&e.profile.trim()?e.profile.trim():"default";if(!t)return;let i={repoPath:t,profile:s,mode:"local"};if(e.lastCheck&&typeof e.lastCheck=="object"&&!Array.isArray(e.lastCheck)){let o=e.lastCheck,a=o.command,u=o.status,c=o.checkedAt;(a==="inspect"||a==="build"||a==="validate"||a==="eval"||a==="run")&&(u==="passed"||u==="failed")&&typeof c=="string"&&(i.lastCheck={command:a,status:u,checkedAt:c,...typeof o.exitCode=="number"||o.exitCode===null?{exitCode:o.exitCode}:{},...typeof o.sourceHead=="string"||o.sourceHead===null?{sourceHead:o.sourceHead}:{}})}if(e.lastPush&&typeof e.lastPush=="object"&&!Array.isArray(e.lastPush)){let o=e.lastPush,a=o.status,u=o.pushedAt;(a==="pushed"||a==="failed")&&typeof u=="string"&&(i.lastPush={status:a,pushedAt:u,...typeof o.teamId=="string"||o.teamId===null?{teamId:o.teamId}:{},...typeof o.projectId=="string"||o.projectId===null?{projectId:o.projectId}:{},...typeof o.localHead=="string"||o.localHead===null?{localHead:o.localHead}:{},...typeof o.hostedHead=="string"||o.hostedHead===null?{hostedHead:o.hostedHead}:{},...typeof o.sourceRef=="string"||o.sourceRef===null?{sourceRef:o.sourceRef}:{},...o.promotionStatus==="uploaded"||o.promotionStatus==="hosted_source_materialized"||o.promotionStatus==="hosted_source_materialize_failed"||o.promotionStatus==="hosted_source_check_pending"||o.promotionStatus==="hosted_source_check_failed"||o.promotionStatus==="hosted_source_published"||o.promotionStatus==="hosted_source_publish_failed"||o.promotionStatus==="hosted_run_pending"||o.promotionStatus==="hosted_run_passed"||o.promotionStatus==="hosted_run_failed"||o.promotionStatus===null?{promotionStatus:o.promotionStatus}:{},...o.hostedRunStatus==="not_started"||o.hostedRunStatus==="running"||o.hostedRunStatus==="passed"||o.hostedRunStatus==="failed"||o.hostedRunStatus===null?{hostedRunStatus:o.hostedRunStatus}:{},...typeof o.hostedRunAgentId=="string"||o.hostedRunAgentId===null?{hostedRunAgentId:o.hostedRunAgentId}:{},...typeof o.hostedRunId=="string"||o.hostedRunId===null?{hostedRunId:o.hostedRunId}:{},...typeof o.hostedRunAt=="string"||o.hostedRunAt===null?{hostedRunAt:o.hostedRunAt}:{},...w(o.hostedSourceMaterialization)?{hostedSourceMaterialization:w(o.hostedSourceMaterialization)}:{},...E(o.hostedSourceCheck)?{hostedSourceCheck:E(o.hostedSourceCheck)}:{},...K(o.hostedPublish)?{hostedPublish:K(o.hostedPublish)}:{},...M(o.hostedRun)?{hostedRun:M(o.hostedRun)}:{},...typeof o.error=="string"||o.error===null?{error:o.error}:{}})}if(Array.isArray(e.profiles)){let o=e.profiles.flatMap(a=>{let u=B(a);if(!u)return[];let c=a,p=c.source==="github"||c.source==="openpond_git"?c.source:"local",C=typeof c.repositoryId=="string"&&c.repositoryId.trim()?c.repositoryId.trim():Q.resolve(u.repoPath);return[{source:p,repositoryId:C,repoPath:u.repoPath,profile:u.profile,...u.lastCheck?{lastCheck:u.lastCheck}:{},...u.lastPush?{lastPush:u.lastPush}:{}}]});o.length>0&&(i.profiles=o)}return i}l(B,"sanitizeLocalOpenPondProfile");function w(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"runtimeAgentId"),...r(e,"projectId"),...r(e,"sourceRoot"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"manifestPath"),...r(e,"manifestSyncedAt"),...T(e,"fileCount"),...T(e,"totalBytes"),...r(e,"generatedManifestPath"),...k(e,"synthesizedOpenPondYaml"),...r(e,"uploadMetadataPath"),...f(e,"setupCommands"),...f(e,"validationCommands"),...r(e,"materializedAt"),...r(e,"error")}:null}l(w,"sanitizeHostedMaterializationStatus");function E(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"deployPlanStatus"),...k(e,"canRun"),...k(e,"canDeploy"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"manifestPath"),...f(e,"setupCommands"),...f(e,"validationCommands"),...f(e,"requiredChecks"),...f(e,"evalNames"),...f(e,"blockedReasons"),...f(e,"staleReasons"),...r(e,"runtimeId"),...r(e,"sandboxId"),...f(e,"traceArtifactRefs"),...f(e,"evalResultArtifactRefs"),...f(e,"validatorArtifactRefs"),...r(e,"checkedAt"),...r(e,"error")}:null}l(E,"sanitizeHostedSourceCheckStatus");function K(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"snapshotId"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"manifestPath"),...r(e,"buildStatus"),...r(e,"validationStatus"),...r(e,"evalStatus"),...r(e,"publishedAt"),...r(e,"error")}:null}l(K,"sanitizeHostedPublishStatus");function M(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"runId"),...r(e,"runtimeId"),...r(e,"sandboxId"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"setupGateStatus"),...f(e,"setupRequirementRefs"),...f(e,"artifactRefs"),...f(e,"traceArtifactRefs"),...f(e,"evalArtifactRefs"),...r(e,"startedAt"),...r(e,"completedAt"),...r(e,"error")}:null}l(M,"sanitizeHostedRunSummary");function r(n,e){let t=n[e];return typeof t=="string"||t===null?{[e]:t}:{}}l(r,"nullableStringProp");function k(n,e){let t=n[e];return typeof t=="boolean"||t===null?{[e]:t}:{}}l(k,"nullableBooleanProp");function T(n,e){let t=n[e];return typeof t=="number"||t===null?{[e]:t}:{}}l(T,"nullableNumberProp");function f(n,e){let t=n[e];if(!Array.isArray(t))return{};let s=t.filter(i=>typeof i=="string");return{[e]:s}}l(f,"stringArrayProp");function R(n){return typeof n=="string"&&n.trim()?n.trim():null}l(R,"stringField");function D(n,e){if(!b(n.handle,e.handle))return!1;let t=d(e.baseUrl);return t?d(n.baseUrl)===t:!d(n.baseUrl)}l(D,"accountMatchesSelector");function I(n,e,t={}){let s=d(e.baseUrl);if(s)return v(n,e.handle,s);let i=n.findIndex(a=>D(a,e));if(i!==-1)return i;let o=n.map((a,u)=>({account:a,index:u})).filter(({account:a})=>b(a.handle,e.handle));if(o.length>1&&t.requireUnambiguous)throw new Error(`multiple profiles found for ${e.handle}; pass --base-url to select one`);return o[0]?.index??-1}l(I,"findAccountIndexForSelector");function X(n){if(!n||typeof n!="object"||Array.isArray(n))return;let e=n,t={};return typeof e.token=="string"&&(t.token=e.token),(typeof e.appId=="string"||e.appId===null)&&(t.appId=e.appId),(typeof e.conversationId=="string"||e.conversationId===null)&&(t.conversationId=e.conversationId),Object.keys(t).length>0?t:void 0}l(X,"sanitizeSession");function Z(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=h(typeof e.handle=="string"?e.handle:void 0);if(!t)return null;let s={handle:t};typeof e.apiKey=="string"&&(s.apiKey=e.apiKey),typeof e.baseUrl=="string"&&(s.baseUrl=e.baseUrl),typeof e.apiBaseUrl=="string"&&(s.apiBaseUrl=e.apiBaseUrl),typeof e.chatApiBaseUrl=="string"&&(s.chatApiBaseUrl=e.chatApiBaseUrl),typeof e.environment=="string"&&(s.environment=e.environment);let i=X(e.session);return i&&(s.session=i),s}l(Z,"sanitizeAccount");function ee(n){let e={};return typeof n.token=="string"&&(e.token=n.token),(typeof n.appId=="string"||n.appId===null)&&(e.appId=n.appId),(typeof n.conversationId=="string"||n.conversationId===null)&&(e.conversationId=n.conversationId),Object.keys(e).length>0?e:void 0}l(ee,"extractLegacySession");function ne(n,e){let t={handle:e};typeof n.apiKey=="string"&&(t.apiKey=n.apiKey),typeof n.baseUrl=="string"&&(t.baseUrl=n.baseUrl),typeof n.apiBaseUrl=="string"&&(t.apiBaseUrl=n.apiBaseUrl),typeof n.chatApiBaseUrl=="string"&&(t.chatApiBaseUrl=n.chatApiBaseUrl);let s=ee(n);return s&&(t.session=s),t}l(ne,"extractLegacyAccount");function x(n){let e={};typeof n.lspEnabled=="boolean"&&(e.lspEnabled=n.lspEnabled),(n.executionMode==="local"||n.executionMode==="hosted")&&(e.executionMode=n.executionMode),(n.mode==="general"||n.mode==="builder")&&(e.mode=n.mode);let t=B(n.openpondProfile);t&&(e.openpondProfile=t);let s=[],i=Array.isArray(n.accounts)?n.accounts:[];for(let c of i){let p=Z(c);p&&v(s,p.handle,p.baseUrl)===-1&&s.push(p)}if(s.length===0){let c=y(n.activeProfile)?.handle||U;s.push(ne(n,c))}let o=y(n.activeProfile),a=o?I(s,o):-1,u=s[a===-1?0:a];return e.accounts=s,e.activeProfile=P(u),e}l(x,"normalizeGlobalConfig");function N(n,e,t){let s=n.accounts??[],i=d(t??process.env.OPENPOND_BASE_URL),o=h(e);if(o)return i?{handle:o,baseUrl:i}:{handle:o};let a=h(process.env.OPENPOND_ACCOUNT);if(a)return i?{handle:a,baseUrl:i}:{handle:a};let u=y(n.activeProfile);return u?i?{handle:u.handle,baseUrl:i}:u:s[0]?P(s[0]):{handle:U}}l(N,"resolveRequestedProfile");function G(n,e,t){let s=d(t);if(s){let o=v(n,e,s);if(o!==-1)return n[o]}else{let o=n.filter(a=>b(a.handle,e));if(o.length>1)throw new Error(`multiple profiles found for ${e}; pass --base-url to select one`);if(o.length===1)return o[0]}let i={handle:e};return s&&(i.baseUrl=s),n.push(i),i}l(G,"ensureAccount");function j(n){n.session&&Object.keys(n.session).length===0&&delete n.session}l(j,"cleanupAccount");function te(n,e,t,s){let i=t===null||t===void 0&&s.undefinedDeletes;switch(e){case"apiKey":{if(i){delete n.apiKey;return}typeof t=="string"&&(n.apiKey=t);return}case"baseUrl":{if(i){delete n.baseUrl;return}typeof t=="string"&&(n.baseUrl=t);return}case"apiBaseUrl":{if(i){delete n.apiBaseUrl;return}typeof t=="string"&&(n.apiBaseUrl=t);return}case"chatApiBaseUrl":{if(i){delete n.chatApiBaseUrl;return}typeof t=="string"&&(n.chatApiBaseUrl=t);return}case"token":case"appId":case"conversationId":{if(n.session||(n.session={}),i){delete n.session[e],j(n);return}(typeof t=="string"||t===null)&&(n.session[e]=t),j(n);return}}}l(te,"applyScopedKey");function $(n,e,t){if(!z.some(c=>m(e,c)))return!1;let i=n.accounts??[],o=y(e.activeProfile)??N(n),a=d(m(e,"baseUrl")?e.baseUrl??null:o.baseUrl??process.env.OPENPOND_BASE_URL),u=G(i,o.handle,a);for(let c of z)m(e,c)&&te(u,c,e[c],t);return n.accounts=i,n.activeProfile=P(u),!0}l($,"applyAccountPatch");function F(n,e){if(m(e,"lspEnabled")&&(typeof e.lspEnabled=="boolean"?n.lspEnabled=e.lspEnabled:e.lspEnabled===null&&delete n.lspEnabled),m(e,"executionMode")&&(e.executionMode==="local"||e.executionMode==="hosted"?n.executionMode=e.executionMode:e.executionMode===null&&delete n.executionMode),m(e,"mode")&&(e.mode==="general"||e.mode==="builder"?n.mode=e.mode:e.mode===null&&delete n.mode),m(e,"activeProfile")){let t=y(e.activeProfile);if(t){let s=I(n.accounts??[],t);n.activeProfile=s===-1?t:P((n.accounts??[])[s])}else e.activeProfile===null&&delete n.activeProfile}if(m(e,"openpondProfile")){let t=B(e.openpondProfile);t?n.openpondProfile=t:e.openpondProfile===null&&delete n.openpondProfile}}l(F,"applyTopLevelPatch");async function oe(n){let e=A();await S(e),await L(e,()=>n)}l(oe,"writeGlobalConfig");async function _(n){let e=A();return await S(e),await L(e,t=>{let s=x(t);return n(s),s})}l(_,"updateGlobalConfig");async function Y(){let n=A();return await S(n),x(await H(n))}l(Y,"loadGlobalConfig");async function le(n={}){let e=await Y(),t=e.accounts??[],s=N(e,n.account,n.baseUrl),i=I(t,s,{requireUnambiguous:!0}),o=i===-1?null:t[i],a=o?.session;return{...e,activeProfile:o?P(o):s,apiKey:o?.apiKey,baseUrl:o?.baseUrl,apiBaseUrl:o?.apiBaseUrl,chatApiBaseUrl:o?.chatApiBaseUrl,token:a?.token,appId:a?.appId,conversationId:a?.conversationId}}l(le,"loadConfig");async function J(){let n=await Y(),e=y(n.activeProfile);return(n.accounts??[]).map(t=>{let s=h(t.handle)??U;return{handle:s,baseUrl:d(t.baseUrl),apiBaseUrl:d(t.apiBaseUrl),chatApiBaseUrl:d(t.chatApiBaseUrl),environment:t.environment?.trim()||null,isActive:!!(e&&D({...t,handle:s},e)),hasApiKey:!!t.apiKey?.trim(),hasSessionToken:!!t.session?.token?.trim(),sessionAppId:t.session?.appId??null,sessionConversationId:t.session?.conversationId??null}})}l(J,"listConfiguredProfiles");async function ae(n,e={}){let t=q(n),s=d(e.baseUrl),i=-1;await _(a=>{let u=a.accounts??[];if(i=I(u,s?{handle:t,baseUrl:s}:{handle:t},{requireUnambiguous:!0}),i===-1)throw new Error(`profile not found: ${t}`);a.activeProfile=P(u[i])});let o=await J();return o.find(a=>a.isActive)??o[i]}l(ae,"setActiveProfile");async function ue(n){let e=q(n.handle),t=W(n.apiKey),s=d(n.baseUrl),i=d(n.apiBaseUrl),o=d(n.chatApiBaseUrl),a={handle:e};await _(p=>{let C=p.accounts??[],g=G(C,e,s);g.apiKey=t,s&&(g.baseUrl=s),i?g.apiBaseUrl=i:n.apiBaseUrl===null&&delete g.apiBaseUrl,o?g.chatApiBaseUrl=o:n.chatApiBaseUrl===null&&delete g.chatApiBaseUrl,n.environment===null?delete g.environment:typeof n.environment=="string"&&n.environment.trim()&&(g.environment=n.environment.trim()),p.accounts=C,a=P(g),n.setActive!==!1&&(p.activeProfile=a)});let c=(await J()).find(p=>b(p.handle,a.handle)?s?d(p.baseUrl)===s:!0:!1);if(!c)throw new Error(`failed to save profile: ${e}`);return c}l(ue,"saveProfileApiKey");async function ce(n){let e=x(n);F(e,n),$(e,n,{undefinedDeletes:!0}),await oe(e)}l(ce,"saveConfig");async function de(n){await _(e=>{F(e,n),$(e,n,{undefinedDeletes:!1})})}l(de,"saveGlobalConfig");export{re as a,_ as b,Y as c,le as d,J as e,ae as f,ue as g,ce as h,de as i};
2
+ import{$a as L,_a as H,jb as S}from"./chunk-IFP6W4OW.js";import{f as A,h as O}from"./chunk-H7IWJN7L.js";import{a as l}from"./chunk-FTQLQJQV.js";import Q from"node:path";var U="default",z=["apiKey","baseUrl","apiBaseUrl","chatApiBaseUrl","token","appId","conversationId"];function re(){return V()}l(re,"getConfigPath");function V(){return O(A()).config}l(V,"getGlobalConfigPath");function m(n,e){return Object.prototype.hasOwnProperty.call(n,e)}l(m,"hasOwn");function h(n){if(typeof n!="string")return null;let e=n.trim();return e.length>0?e:null}l(h,"normalizeHandle");function d(n){if(typeof n!="string")return null;let e=n.trim();return e?e.replace(/\/$/,""):null}l(d,"normalizeBaseUrl");function q(n){let e=h(n);if(!e)throw new Error("profile handle must be non-empty");return e}l(q,"requireHandle");function W(n){if(typeof n!="string")throw new Error("apiKey must be a non-empty string");let e=n.trim();if(!e)throw new Error("apiKey must be a non-empty string");return e}l(W,"requireApiKey");function b(n,e){let t=h(n),s=h(e);return!!(t&&s&&t.toLowerCase()===s.toLowerCase())}l(b,"handleEquals");function v(n,e,t){let s=d(t);return n.findIndex(i=>b(i.handle,e)?s?d(i.baseUrl)===s:!0:!1)}l(v,"findAccountIndex");function P(n){let e=h(n.handle)??U,t=d(n.baseUrl);return t?{handle:e,baseUrl:t}:{handle:e}}l(P,"selectorFromAccount");function y(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=h(typeof e.handle=="string"?e.handle:void 0);if(!t)return null;let s=d(typeof e.baseUrl=="string"?e.baseUrl:void 0);return s?{handle:t,baseUrl:s}:{handle:t}}l(y,"sanitizeActiveProfile");function B(n){if(!n||typeof n!="object"||Array.isArray(n))return;let e=n,t=typeof e.repoPath=="string"?e.repoPath.trim():"",s=typeof e.profile=="string"&&e.profile.trim()?e.profile.trim():"default";if(!t)return;let i={repoPath:t,profile:s,mode:"local"};if(e.lastCheck&&typeof e.lastCheck=="object"&&!Array.isArray(e.lastCheck)){let o=e.lastCheck,a=o.command,u=o.status,c=o.checkedAt;(a==="inspect"||a==="build"||a==="validate"||a==="eval"||a==="run")&&(u==="passed"||u==="failed")&&typeof c=="string"&&(i.lastCheck={command:a,status:u,checkedAt:c,...typeof o.exitCode=="number"||o.exitCode===null?{exitCode:o.exitCode}:{},...typeof o.sourceHead=="string"||o.sourceHead===null?{sourceHead:o.sourceHead}:{}})}if(e.lastPush&&typeof e.lastPush=="object"&&!Array.isArray(e.lastPush)){let o=e.lastPush,a=o.status,u=o.pushedAt;(a==="pushed"||a==="failed")&&typeof u=="string"&&(i.lastPush={status:a,pushedAt:u,...typeof o.teamId=="string"||o.teamId===null?{teamId:o.teamId}:{},...typeof o.projectId=="string"||o.projectId===null?{projectId:o.projectId}:{},...typeof o.localHead=="string"||o.localHead===null?{localHead:o.localHead}:{},...typeof o.hostedHead=="string"||o.hostedHead===null?{hostedHead:o.hostedHead}:{},...typeof o.sourceRef=="string"||o.sourceRef===null?{sourceRef:o.sourceRef}:{},...o.promotionStatus==="uploaded"||o.promotionStatus==="hosted_source_materialized"||o.promotionStatus==="hosted_source_materialize_failed"||o.promotionStatus==="hosted_source_check_pending"||o.promotionStatus==="hosted_source_check_failed"||o.promotionStatus==="hosted_source_published"||o.promotionStatus==="hosted_source_publish_failed"||o.promotionStatus==="hosted_run_pending"||o.promotionStatus==="hosted_run_passed"||o.promotionStatus==="hosted_run_failed"||o.promotionStatus===null?{promotionStatus:o.promotionStatus}:{},...o.hostedRunStatus==="not_started"||o.hostedRunStatus==="running"||o.hostedRunStatus==="passed"||o.hostedRunStatus==="failed"||o.hostedRunStatus===null?{hostedRunStatus:o.hostedRunStatus}:{},...typeof o.hostedRunAgentId=="string"||o.hostedRunAgentId===null?{hostedRunAgentId:o.hostedRunAgentId}:{},...typeof o.hostedRunId=="string"||o.hostedRunId===null?{hostedRunId:o.hostedRunId}:{},...typeof o.hostedRunAt=="string"||o.hostedRunAt===null?{hostedRunAt:o.hostedRunAt}:{},...w(o.hostedSourceMaterialization)?{hostedSourceMaterialization:w(o.hostedSourceMaterialization)}:{},...E(o.hostedSourceCheck)?{hostedSourceCheck:E(o.hostedSourceCheck)}:{},...K(o.hostedPublish)?{hostedPublish:K(o.hostedPublish)}:{},...M(o.hostedRun)?{hostedRun:M(o.hostedRun)}:{},...typeof o.error=="string"||o.error===null?{error:o.error}:{}})}if(Array.isArray(e.profiles)){let o=e.profiles.flatMap(a=>{let u=B(a);if(!u)return[];let c=a,p=c.source==="github"||c.source==="openpond_git"?c.source:"local",C=typeof c.repositoryId=="string"&&c.repositoryId.trim()?c.repositoryId.trim():Q.resolve(u.repoPath);return[{source:p,repositoryId:C,repoPath:u.repoPath,profile:u.profile,...u.lastCheck?{lastCheck:u.lastCheck}:{},...u.lastPush?{lastPush:u.lastPush}:{}}]});o.length>0&&(i.profiles=o)}return i}l(B,"sanitizeLocalOpenPondProfile");function w(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"runtimeAgentId"),...r(e,"projectId"),...r(e,"sourceRoot"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"manifestPath"),...r(e,"manifestSyncedAt"),...T(e,"fileCount"),...T(e,"totalBytes"),...r(e,"generatedManifestPath"),...k(e,"synthesizedOpenPondYaml"),...r(e,"uploadMetadataPath"),...f(e,"setupCommands"),...f(e,"validationCommands"),...r(e,"materializedAt"),...r(e,"error")}:null}l(w,"sanitizeHostedMaterializationStatus");function E(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"deployPlanStatus"),...k(e,"canRun"),...k(e,"canDeploy"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"manifestPath"),...f(e,"setupCommands"),...f(e,"validationCommands"),...f(e,"requiredChecks"),...f(e,"evalNames"),...f(e,"blockedReasons"),...f(e,"staleReasons"),...r(e,"runtimeId"),...r(e,"sandboxId"),...f(e,"traceArtifactRefs"),...f(e,"evalResultArtifactRefs"),...f(e,"validatorArtifactRefs"),...r(e,"checkedAt"),...r(e,"error")}:null}l(E,"sanitizeHostedSourceCheckStatus");function K(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"snapshotId"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"manifestPath"),...r(e,"buildStatus"),...r(e,"validationStatus"),...r(e,"evalStatus"),...r(e,"publishedAt"),...r(e,"error")}:null}l(K,"sanitizeHostedPublishStatus");function M(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=R(e.status);return t?{status:t,...r(e,"agentId"),...r(e,"runId"),...r(e,"runtimeId"),...r(e,"sandboxId"),...r(e,"sourceRef"),...r(e,"sourceCommitSha"),...r(e,"manifestHash"),...r(e,"setupGateStatus"),...f(e,"setupRequirementRefs"),...f(e,"artifactRefs"),...f(e,"traceArtifactRefs"),...f(e,"evalArtifactRefs"),...r(e,"startedAt"),...r(e,"completedAt"),...r(e,"error")}:null}l(M,"sanitizeHostedRunSummary");function r(n,e){let t=n[e];return typeof t=="string"||t===null?{[e]:t}:{}}l(r,"nullableStringProp");function k(n,e){let t=n[e];return typeof t=="boolean"||t===null?{[e]:t}:{}}l(k,"nullableBooleanProp");function T(n,e){let t=n[e];return typeof t=="number"||t===null?{[e]:t}:{}}l(T,"nullableNumberProp");function f(n,e){let t=n[e];if(!Array.isArray(t))return{};let s=t.filter(i=>typeof i=="string");return{[e]:s}}l(f,"stringArrayProp");function R(n){return typeof n=="string"&&n.trim()?n.trim():null}l(R,"stringField");function D(n,e){if(!b(n.handle,e.handle))return!1;let t=d(e.baseUrl);return t?d(n.baseUrl)===t:!d(n.baseUrl)}l(D,"accountMatchesSelector");function I(n,e,t={}){let s=d(e.baseUrl);if(s)return v(n,e.handle,s);let i=n.findIndex(a=>D(a,e));if(i!==-1)return i;let o=n.map((a,u)=>({account:a,index:u})).filter(({account:a})=>b(a.handle,e.handle));if(o.length>1&&t.requireUnambiguous)throw new Error(`multiple profiles found for ${e.handle}; pass --base-url to select one`);return o[0]?.index??-1}l(I,"findAccountIndexForSelector");function X(n){if(!n||typeof n!="object"||Array.isArray(n))return;let e=n,t={};return typeof e.token=="string"&&(t.token=e.token),(typeof e.appId=="string"||e.appId===null)&&(t.appId=e.appId),(typeof e.conversationId=="string"||e.conversationId===null)&&(t.conversationId=e.conversationId),Object.keys(t).length>0?t:void 0}l(X,"sanitizeSession");function Z(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n,t=h(typeof e.handle=="string"?e.handle:void 0);if(!t)return null;let s={handle:t};typeof e.apiKey=="string"&&(s.apiKey=e.apiKey),typeof e.baseUrl=="string"&&(s.baseUrl=e.baseUrl),typeof e.apiBaseUrl=="string"&&(s.apiBaseUrl=e.apiBaseUrl),typeof e.chatApiBaseUrl=="string"&&(s.chatApiBaseUrl=e.chatApiBaseUrl),typeof e.environment=="string"&&(s.environment=e.environment);let i=X(e.session);return i&&(s.session=i),s}l(Z,"sanitizeAccount");function ee(n){let e={};return typeof n.token=="string"&&(e.token=n.token),(typeof n.appId=="string"||n.appId===null)&&(e.appId=n.appId),(typeof n.conversationId=="string"||n.conversationId===null)&&(e.conversationId=n.conversationId),Object.keys(e).length>0?e:void 0}l(ee,"extractLegacySession");function ne(n,e){let t={handle:e};typeof n.apiKey=="string"&&(t.apiKey=n.apiKey),typeof n.baseUrl=="string"&&(t.baseUrl=n.baseUrl),typeof n.apiBaseUrl=="string"&&(t.apiBaseUrl=n.apiBaseUrl),typeof n.chatApiBaseUrl=="string"&&(t.chatApiBaseUrl=n.chatApiBaseUrl);let s=ee(n);return s&&(t.session=s),t}l(ne,"extractLegacyAccount");function x(n){let e={};typeof n.lspEnabled=="boolean"&&(e.lspEnabled=n.lspEnabled),(n.executionMode==="local"||n.executionMode==="hosted")&&(e.executionMode=n.executionMode),(n.mode==="general"||n.mode==="builder")&&(e.mode=n.mode);let t=B(n.openpondProfile);t&&(e.openpondProfile=t);let s=[],i=Array.isArray(n.accounts)?n.accounts:[];for(let c of i){let p=Z(c);p&&v(s,p.handle,p.baseUrl)===-1&&s.push(p)}if(s.length===0){let c=y(n.activeProfile)?.handle||U;s.push(ne(n,c))}let o=y(n.activeProfile),a=o?I(s,o):-1,u=s[a===-1?0:a];return e.accounts=s,e.activeProfile=P(u),e}l(x,"normalizeGlobalConfig");function N(n,e,t){let s=n.accounts??[],i=d(t??process.env.OPENPOND_BASE_URL),o=h(e);if(o)return i?{handle:o,baseUrl:i}:{handle:o};let a=h(process.env.OPENPOND_ACCOUNT);if(a)return i?{handle:a,baseUrl:i}:{handle:a};let u=y(n.activeProfile);return u?i?{handle:u.handle,baseUrl:i}:u:s[0]?P(s[0]):{handle:U}}l(N,"resolveRequestedProfile");function G(n,e,t){let s=d(t);if(s){let o=v(n,e,s);if(o!==-1)return n[o]}else{let o=n.filter(a=>b(a.handle,e));if(o.length>1)throw new Error(`multiple profiles found for ${e}; pass --base-url to select one`);if(o.length===1)return o[0]}let i={handle:e};return s&&(i.baseUrl=s),n.push(i),i}l(G,"ensureAccount");function j(n){n.session&&Object.keys(n.session).length===0&&delete n.session}l(j,"cleanupAccount");function te(n,e,t,s){let i=t===null||t===void 0&&s.undefinedDeletes;switch(e){case"apiKey":{if(i){delete n.apiKey;return}typeof t=="string"&&(n.apiKey=t);return}case"baseUrl":{if(i){delete n.baseUrl;return}typeof t=="string"&&(n.baseUrl=t);return}case"apiBaseUrl":{if(i){delete n.apiBaseUrl;return}typeof t=="string"&&(n.apiBaseUrl=t);return}case"chatApiBaseUrl":{if(i){delete n.chatApiBaseUrl;return}typeof t=="string"&&(n.chatApiBaseUrl=t);return}case"token":case"appId":case"conversationId":{if(n.session||(n.session={}),i){delete n.session[e],j(n);return}(typeof t=="string"||t===null)&&(n.session[e]=t),j(n);return}}}l(te,"applyScopedKey");function $(n,e,t){if(!z.some(c=>m(e,c)))return!1;let i=n.accounts??[],o=y(e.activeProfile)??N(n),a=d(m(e,"baseUrl")?e.baseUrl??null:o.baseUrl??process.env.OPENPOND_BASE_URL),u=G(i,o.handle,a);for(let c of z)m(e,c)&&te(u,c,e[c],t);return n.accounts=i,n.activeProfile=P(u),!0}l($,"applyAccountPatch");function F(n,e){if(m(e,"lspEnabled")&&(typeof e.lspEnabled=="boolean"?n.lspEnabled=e.lspEnabled:e.lspEnabled===null&&delete n.lspEnabled),m(e,"executionMode")&&(e.executionMode==="local"||e.executionMode==="hosted"?n.executionMode=e.executionMode:e.executionMode===null&&delete n.executionMode),m(e,"mode")&&(e.mode==="general"||e.mode==="builder"?n.mode=e.mode:e.mode===null&&delete n.mode),m(e,"activeProfile")){let t=y(e.activeProfile);if(t){let s=I(n.accounts??[],t);n.activeProfile=s===-1?t:P((n.accounts??[])[s])}else e.activeProfile===null&&delete n.activeProfile}if(m(e,"openpondProfile")){let t=B(e.openpondProfile);t?n.openpondProfile=t:e.openpondProfile===null&&delete n.openpondProfile}}l(F,"applyTopLevelPatch");async function oe(n){let e=A();await S(e),await L(e,()=>n)}l(oe,"writeGlobalConfig");async function _(n){let e=A();return await S(e),await L(e,t=>{let s=x(t);return n(s),s})}l(_,"updateGlobalConfig");async function Y(){let n=A();return await S(n),x(await H(n))}l(Y,"loadGlobalConfig");async function le(n={}){let e=await Y(),t=e.accounts??[],s=N(e,n.account,n.baseUrl),i=I(t,s,{requireUnambiguous:!0}),o=i===-1?null:t[i],a=o?.session;return{...e,activeProfile:o?P(o):s,apiKey:o?.apiKey,baseUrl:o?.baseUrl,apiBaseUrl:o?.apiBaseUrl,chatApiBaseUrl:o?.chatApiBaseUrl,token:a?.token,appId:a?.appId,conversationId:a?.conversationId}}l(le,"loadConfig");async function J(){let n=await Y(),e=y(n.activeProfile);return(n.accounts??[]).map(t=>{let s=h(t.handle)??U;return{handle:s,baseUrl:d(t.baseUrl),apiBaseUrl:d(t.apiBaseUrl),chatApiBaseUrl:d(t.chatApiBaseUrl),environment:t.environment?.trim()||null,isActive:!!(e&&D({...t,handle:s},e)),hasApiKey:!!t.apiKey?.trim(),hasSessionToken:!!t.session?.token?.trim(),sessionAppId:t.session?.appId??null,sessionConversationId:t.session?.conversationId??null}})}l(J,"listConfiguredProfiles");async function ae(n,e={}){let t=q(n),s=d(e.baseUrl),i=-1;await _(a=>{let u=a.accounts??[];if(i=I(u,s?{handle:t,baseUrl:s}:{handle:t},{requireUnambiguous:!0}),i===-1)throw new Error(`profile not found: ${t}`);a.activeProfile=P(u[i])});let o=await J();return o.find(a=>a.isActive)??o[i]}l(ae,"setActiveProfile");async function ue(n){let e=q(n.handle),t=W(n.apiKey),s=d(n.baseUrl),i=d(n.apiBaseUrl),o=d(n.chatApiBaseUrl),a={handle:e};await _(p=>{let C=p.accounts??[],g=G(C,e,s);g.apiKey=t,s&&(g.baseUrl=s),i?g.apiBaseUrl=i:n.apiBaseUrl===null&&delete g.apiBaseUrl,o?g.chatApiBaseUrl=o:n.chatApiBaseUrl===null&&delete g.chatApiBaseUrl,n.environment===null?delete g.environment:typeof n.environment=="string"&&n.environment.trim()&&(g.environment=n.environment.trim()),p.accounts=C,a=P(g),n.setActive!==!1&&(p.activeProfile=a)});let c=(await J()).find(p=>b(p.handle,a.handle)?s?d(p.baseUrl)===s:!0:!1);if(!c)throw new Error(`failed to save profile: ${e}`);return c}l(ue,"saveProfileApiKey");async function ce(n){let e=x(n);F(e,n),$(e,n,{undefinedDeletes:!0}),await oe(e)}l(ce,"saveConfig");async function de(n){await _(e=>{F(e,n),$(e,n,{undefinedDeletes:!1})})}l(de,"saveGlobalConfig");export{re as a,_ as b,Y as c,le as d,J as e,ae as f,ue as g,ce as h,de as i};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{c as eA}from"./chunk-IR3YJWPW.js";import{$a as o0,$b as AA,Ab as ke,Ba as ce,Da as tt,Eb as ge,Fb as Se,Ja as J,Ka as be,La as Gx,Lb as N,Mb as f0,Na as je,Nb as W,Ob as c8,Qb as ox,Ra as Q0,Rb as b8,Sa as le,Sb as Y,Ta as E8,Ua as de,Va as me,Wa as Ce,Xa as De,Ya as Ix,Za as Y8,_a as sx,ab as P0,ac as qe,bc as fx,cc as Re,db as X0,fb as W0,h as Ee,kb as ue,lb as u0,qb as pe,tb as Qx,vb as xA,xb as he}from"./chunk-2LSP2AAN.js";import{k as q,l as _,m as r0,n as Z,o as g,q as Bx,r as n0,s as o8,u as f8,v as D,w as z0,x as Hx}from"./chunk-F4WS5QIT.js";import{b as x}from"./chunk-ES2ISFJC.js";import{a as n,b as rt,c as Ft,e as fe}from"./chunk-FTQLQJQV.js";var BF=Ft((xf,iF)=>{"use strict";var In=Object.create,A8=Object.defineProperty,Qn=Object.getOwnPropertyDescriptor,VA=Object.getOwnPropertyNames,Pn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty,Nn=n((A,e,r)=>e in A?A8(A,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):A[e]=r,"__defNormalProp"),On=n((A,e)=>function(){return A&&(e=(0,A[VA(A)[0]])(A=0)),e},"__esm"),Ln=n((A,e)=>function(){return e||(0,A[VA(A)[0]])((e={exports:{}}).exports,e),e.exports},"__commonJS"),FF=n((A,e)=>{for(var r in e)A8(A,r,{get:e[r],enumerable:!0})},"__export"),tF=n((A,e,r,F)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of VA(e))!Mn.call(A,t)&&t!==r&&A8(A,t,{get:n(()=>e[t],"get"),enumerable:!(F=Qn(e,t))||F.enumerable});return A},"__copyProps"),Vn=n((A,e,r)=>(r=A!=null?In(Pn(A)):{},tF(e||!A||!A.__esModule?A8(r,"default",{value:A,enumerable:!0}):r,A)),"__toESM"),Jn=n(A=>tF(A8({},"__esModule",{value:!0}),A),"__toCommonJS"),Un=n((A,e,r)=>(Nn(A,typeof e!="symbol"?e+"":e,r),r),"__publicField"),aF={};FF(aF,{QuickJSFFI:n(()=>vF,"QuickJSFFI")});var vF,Zn=On({"src/ffi.ts"(){"use strict";vF=class{static{n(this,"QuickJSFFI")}constructor(A){this.module=A,this.DEBUG=!1,this.QTS_Throw=this.module.cwrap("QTS_Throw","number",["number","number"]),this.QTS_NewError=this.module.cwrap("QTS_NewError","number",["number"]),this.QTS_RuntimeSetMemoryLimit=this.module.cwrap("QTS_RuntimeSetMemoryLimit",null,["number","number"]),this.QTS_RuntimeComputeMemoryUsage=this.module.cwrap("QTS_RuntimeComputeMemoryUsage","number",["number","number"]),this.QTS_RuntimeDumpMemoryUsage=this.module.cwrap("QTS_RuntimeDumpMemoryUsage","number",["number"]),this.QTS_RecoverableLeakCheck=this.module.cwrap("QTS_RecoverableLeakCheck","number",[]),this.QTS_BuildIsSanitizeLeak=this.module.cwrap("QTS_BuildIsSanitizeLeak","number",[]),this.QTS_RuntimeSetMaxStackSize=this.module.cwrap("QTS_RuntimeSetMaxStackSize",null,["number","number"]),this.QTS_GetUndefined=this.module.cwrap("QTS_GetUndefined","number",[]),this.QTS_GetNull=this.module.cwrap("QTS_GetNull","number",[]),this.QTS_GetFalse=this.module.cwrap("QTS_GetFalse","number",[]),this.QTS_GetTrue=this.module.cwrap("QTS_GetTrue","number",[]),this.QTS_NewHostRef=this.module.cwrap("QTS_NewHostRef","number",["number","number"]),this.QTS_GetHostRefId=this.module.cwrap("QTS_GetHostRefId","number",["number"]),this.QTS_NewRuntime=this.module.cwrap("QTS_NewRuntime","number",[]),this.QTS_FreeRuntime=this.module.cwrap("QTS_FreeRuntime",null,["number"]),this.QTS_NewContext=this.module.cwrap("QTS_NewContext","number",["number","number"]),this.QTS_FreeContext=this.module.cwrap("QTS_FreeContext",null,["number"]),this.QTS_FreeValuePointer=this.module.cwrap("QTS_FreeValuePointer",null,["number","number"]),this.QTS_FreeValuePointerRuntime=this.module.cwrap("QTS_FreeValuePointerRuntime",null,["number","number"]),this.QTS_FreeVoidPointer=this.module.cwrap("QTS_FreeVoidPointer",null,["number","number"]),this.QTS_FreeCString=this.module.cwrap("QTS_FreeCString",null,["number","number"]),this.QTS_DupValuePointer=this.module.cwrap("QTS_DupValuePointer","number",["number","number"]),this.QTS_NewObject=this.module.cwrap("QTS_NewObject","number",["number"]),this.QTS_NewObjectProto=this.module.cwrap("QTS_NewObjectProto","number",["number","number"]),this.QTS_NewArray=this.module.cwrap("QTS_NewArray","number",["number"]),this.QTS_NewArrayBuffer=this.module.cwrap("QTS_NewArrayBuffer","number",["number","number","number"]),this.QTS_NewFloat64=this.module.cwrap("QTS_NewFloat64","number",["number","number"]),this.QTS_GetFloat64=this.module.cwrap("QTS_GetFloat64","number",["number","number"]),this.QTS_NewString=this.module.cwrap("QTS_NewString","number",["number","number"]),this.QTS_GetString=this.module.cwrap("QTS_GetString","number",["number","number"]),this.QTS_GetArrayBuffer=this.module.cwrap("QTS_GetArrayBuffer","number",["number","number"]),this.QTS_GetArrayBufferLength=this.module.cwrap("QTS_GetArrayBufferLength","number",["number","number"]),this.QTS_NewSymbol=this.module.cwrap("QTS_NewSymbol","number",["number","number","number"]),this.QTS_GetSymbolDescriptionOrKey=this.module.cwrap("QTS_GetSymbolDescriptionOrKey","number",["number","number"]),this.QTS_IsGlobalSymbol=this.module.cwrap("QTS_IsGlobalSymbol","number",["number","number"]),this.QTS_IsJobPending=this.module.cwrap("QTS_IsJobPending","number",["number"]),this.QTS_ExecutePendingJob=this.module.cwrap("QTS_ExecutePendingJob","number",["number","number","number"]),this.QTS_GetProp=this.module.cwrap("QTS_GetProp","number",["number","number","number"]),this.QTS_GetPropNumber=this.module.cwrap("QTS_GetPropNumber","number",["number","number","number"]),this.QTS_SetProp=this.module.cwrap("QTS_SetProp",null,["number","number","number","number"]),this.QTS_DefineProp=this.module.cwrap("QTS_DefineProp",null,["number","number","number","number","number","number","boolean","boolean","boolean"]),this.QTS_GetOwnPropertyNames=this.module.cwrap("QTS_GetOwnPropertyNames","number",["number","number","number","number","number"]),this.QTS_Call=this.module.cwrap("QTS_Call","number",["number","number","number","number","number"]),this.QTS_ResolveException=this.module.cwrap("QTS_ResolveException","number",["number","number"]),this.QTS_Dump=this.module.cwrap("QTS_Dump","number",["number","number"]),this.QTS_Eval=this.module.cwrap("QTS_Eval","number",["number","number","number","string","number","number"]),this.QTS_GetModuleNamespace=this.module.cwrap("QTS_GetModuleNamespace","number",["number","number"]),this.QTS_Typeof=this.module.cwrap("QTS_Typeof","number",["number","number"]),this.QTS_GetLength=this.module.cwrap("QTS_GetLength","number",["number","number","number"]),this.QTS_IsEqual=this.module.cwrap("QTS_IsEqual","number",["number","number","number","number"]),this.QTS_GetGlobalObject=this.module.cwrap("QTS_GetGlobalObject","number",["number"]),this.QTS_NewPromiseCapability=this.module.cwrap("QTS_NewPromiseCapability","number",["number","number"]),this.QTS_PromiseState=this.module.cwrap("QTS_PromiseState","number",["number","number"]),this.QTS_PromiseResult=this.module.cwrap("QTS_PromiseResult","number",["number","number"]),this.QTS_TestStringArg=this.module.cwrap("QTS_TestStringArg",null,["string"]),this.QTS_GetDebugLogEnabled=this.module.cwrap("QTS_GetDebugLogEnabled","number",["number"]),this.QTS_SetDebugLogEnabled=this.module.cwrap("QTS_SetDebugLogEnabled",null,["number","number"]),this.QTS_BuildIsDebug=this.module.cwrap("QTS_BuildIsDebug","number",[]),this.QTS_BuildIsAsyncify=this.module.cwrap("QTS_BuildIsAsyncify","number",[]),this.QTS_NewFunction=this.module.cwrap("QTS_NewFunction","number",["number","string","number","boolean","number"]),this.QTS_ArgvGetJSValueConstPointer=this.module.cwrap("QTS_ArgvGetJSValueConstPointer","number",["number","number"]),this.QTS_RuntimeEnableInterruptHandler=this.module.cwrap("QTS_RuntimeEnableInterruptHandler",null,["number"]),this.QTS_RuntimeDisableInterruptHandler=this.module.cwrap("QTS_RuntimeDisableInterruptHandler",null,["number"]),this.QTS_RuntimeEnableModuleLoader=this.module.cwrap("QTS_RuntimeEnableModuleLoader",null,["number","number"]),this.QTS_RuntimeDisableModuleLoader=this.module.cwrap("QTS_RuntimeDisableModuleLoader",null,["number"]),this.QTS_bjson_encode=this.module.cwrap("QTS_bjson_encode","number",["number","number"]),this.QTS_bjson_decode=this.module.cwrap("QTS_bjson_decode","number",["number","number"])}}}}),Kn=Ln({"dist/emscripten-module.cjs"(A,e){"use strict";var r=(()=>{var F=globalThis.document?.currentScript?.src;return async function(t={}){var v,a=t,B=!!globalThis.window,c=!!globalThis.WorkerGlobalScope,i=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";function s(E){E={log:E||function(){}};for(let b of s.Pa)b(E);return a.quickJSEmscriptenExtensions=E}n(s,"q"),s.Pa=[],a.quickjsEmscriptenInit=s,s.Pa.push(E=>{E.getWasmMemory=function(){return Z0}});var f="./this.program",j=n((E,b)=>{throw b},"u");if(typeof __filename<"u"?F=__filename:c&&(F=self.location.href),i){var l=rt("fs");1<process.argv.length&&(f=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),j=n((E,b)=>{throw process.exitCode=E,b},"u")}else if(B||c)try{new URL(".",F)}catch{}var u=console.log.bind(console),m=console.error.bind(console),R=!1,y;function T(E){for(var b=0,o=E.length,p=new Uint8Array(o),I;b<o;++b)I=E.charCodeAt(b),p[b]=~I>>8&I;return p}n(T,"ca");var k,A0,K,e0,P,z,l0=!1;function U0(){var E=Z0.buffer;a.HEAP8=K=new Int8Array(E),new Int16Array(E),a.HEAPU8=e0=new Uint8Array(E),new Uint16Array(E),P=new Int32Array(E),z=new Uint32Array(E),new Float32Array(E),new Float64Array(E),new BigInt64Array(E),new BigUint64Array(E)}n(U0,"H");function s0(E){throw a.onAbort?.(E),E="Aborted("+E+")",m(E),R=!0,E=new WebAssembly.RuntimeError(E+". Build with -sASSERTIONS for more info."),A0?.(E),E}n(s0,"I");var J8;async function UF(E){return E}n(UF,"da");async function ZF(E){var b=J8;try{var o=await UF(b);return await WebAssembly.instantiate(o,E)}catch(p){m(`failed to asynchronously prepare wasm: ${p}`),s0(p)}}n(ZF,"ea");async function KF(E){return ZF(E)}n(KF,"fa");class U8{static{n(this,"K")}constructor(b){Un(this,"name","ExitStatus"),this.message=`Program terminated with exit(${b})`,this.status=b}}for(var re=E=>{for(;0<E.length;)E.shift()(a)},Fe=[],te=[],zF=()=>{var E=a.preRun.shift();te.push(E)},B8=!0,Z0,ae=new TextDecoder,ve=(E,b,o,p)=>{if(o=b+o,p)return o;for(;E[b]&&!(b>=o);)++b;return b},G0=(E,b,o)=>E?ae.decode(e0.subarray(E,ve(e0,E,b,o))):"",Z8=0,XF=[0,31,60,91,121,152,182,213,244,274,305,335],WF=[0,31,59,90,120,151,181,212,243,273,304,334],$x={},ne=E=>{y=E,B8||0<Z8||(a.onExit?.(E),R=!0),j(E,new U8(E))},YF=E=>{if(!R)try{E()}catch(b){b instanceof U8||b=="unwind"||j(1,b)}finally{if(!(B8||0<Z8))try{y=E=y,ne(E)}catch(b){b instanceof U8||b=="unwind"||j(1,b)}}},K0=(E,b,o)=>{var p=e0;if(!(0<o))return 0;var I=b;o=b+o-1;for(var L=0;L<E.length;++L){var V=E.codePointAt(L);if(127>=V){if(b>=o)break;p[b++]=V}else if(2047>=V){if(b+1>=o)break;p[b++]=192|V>>6,p[b++]=128|V&63}else if(65535>=V){if(b+2>=o)break;p[b++]=224|V>>12,p[b++]=128|V>>6&63,p[b++]=128|V&63}else{if(b+3>=o)break;p[b++]=240|V>>18,p[b++]=128|V>>12&63,p[b++]=128|V>>6&63,p[b++]=128|V&63,L++}}return p[b]=0,b-I},K8={},ie=()=>{if(!z8){var E={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:f||"./this.program"},b;for(b in K8)K8[b]===void 0?delete E[b]:E[b]=K8[b];var o=[];for(b in E)o.push(`${b}=${E[b]}`);z8=o}return z8},z8,X8=E=>{for(var b=0,o=0;o<E.length;++o){var p=E.charCodeAt(o);127>=p?b++:2047>=p?b+=2:55296<=p&&57343>=p?(b+=4,++o):b+=3}return b},xt=[null,[],[]],At=(E,b,o,p)=>{var I={string:n(x0=>{var X=0;if(x0!=null&&x0!==0){X=X8(x0)+1;var R0=W8(X);K0(x0,R0,X),X=R0}return X},"string"),array:n(x0=>{var X=W8(x0.length);return K.set(x0,X),X},"array")};E=a["_"+E];var L=[],V=0;if(p)for(var v0=0;v0<p.length;v0++){var ix=I[o[v0]];ix?(V===0&&(V=oe()),L[v0]=ix(p[v0])):L[v0]=p[v0]}return o=E(...L),o=(function(x0){return V!==0&&se(V),b==="string"?G0(x0):b==="boolean"?!!x0:x0})(o)},Tx=new Uint8Array(123),I0=25;0<=I0;--I0)Tx[48+I0]=52+I0,Tx[65+I0]=I0,Tx[97+I0]=26+I0;if(Tx[43]=62,Tx[47]=63,a.wasmMemory?Z0=a.wasmMemory:Z0=new WebAssembly.Memory({initial:(a.INITIAL_MEMORY||16777216)/65536,maximum:32768}),U0(),a.noExitRuntime&&(B8=a.noExitRuntime),a.print&&(u=a.print),a.printErr&&(m=a.printErr),a.thisProgram&&(f=a.thisProgram),a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.shift()();a.cwrap=(E,b,o,p)=>{var I=!o||o.every(L=>L==="number"||L==="boolean");return b!=="string"&&I&&!p?a["_"+E]:(...L)=>At(E,b,o,L)},a.UTF8ToString=G0,a.stringToUTF8=(E,b,o)=>K0(E,b,o),a.lengthBytesUTF8=X8;var Be,se,W8,oe,et={b:n((E,b,o,p)=>s0(`Assertion failed: ${G0(E)}, at: `+[b?G0(b):"unknown filename",o,p?G0(p):"unknown function"]),"b"),q:n(()=>s0(""),"q"),l:n(()=>{B8=!1,Z8=0},"l"),m:n(function(E,b){E=-9007199254740992>E||9007199254740992<E?NaN:Number(E),E=new Date(1e3*E),P[b>>2]=E.getSeconds(),P[b+4>>2]=E.getMinutes(),P[b+8>>2]=E.getHours(),P[b+12>>2]=E.getDate(),P[b+16>>2]=E.getMonth(),P[b+20>>2]=E.getFullYear()-1900,P[b+24>>2]=E.getDay();var o=E.getFullYear();P[b+28>>2]=(o%4!==0||o%100===0&&o%400!==0?WF:XF)[E.getMonth()]+E.getDate()-1|0,P[b+36>>2]=-(60*E.getTimezoneOffset()),o=new Date(E.getFullYear(),6,1).getTimezoneOffset();var p=new Date(E.getFullYear(),0,1).getTimezoneOffset();P[b+32>>2]=(o!=p&&E.getTimezoneOffset()==Math.min(p,o))|0},"m"),j:n((E,b)=>{if($x[E]&&(clearTimeout($x[E].id),delete $x[E]),!b)return 0;var o=setTimeout(()=>{delete $x[E],YF(()=>Be(E,performance.now()))},b);return $x[E]={id:o,Qa:b},0},"j"),n:n((E,b,o,p)=>{var I=new Date().getFullYear(),L=new Date(I,0,1).getTimezoneOffset();I=new Date(I,6,1).getTimezoneOffset(),z[E>>2]=60*Math.max(L,I),P[b>>2]=+(L!=I),b=n(V=>{var v0=Math.abs(V);return`UTC${0<=V?"-":"+"}${String(Math.floor(v0/60)).padStart(2,"0")}${String(v0%60).padStart(2,"0")}`},"d"),E=b(L),b=b(I),I<L?(K0(E,o,17),K0(b,p,17)):(K0(E,p,17),K0(b,o,17))},"n"),p:n(()=>Date.now(),"p"),k:n(E=>{var b=e0.length;if(E>>>=0,2147483648<E)return!1;for(var o=1;4>=o;o*=2){var p=b*(1+.2/o);p=Math.min(p,E+100663296);x:{p=(Math.min(2147483648,65536*Math.ceil(Math.max(E,p)/65536))-Z0.buffer.byteLength+65535)/65536|0;try{Z0.grow(p),U0();var I=1;break x}catch{}I=void 0}if(I)return!0}return!1},"k"),e:n((E,b)=>{var o=0,p=0,I;for(I of ie()){var L=b+o;z[E+p>>2]=L,o+=K0(I,L,1/0)+1,p+=4}return 0},"e"),f:n((E,b)=>{var o=ie();z[E>>2]=o.length,E=0;for(var p of o)E+=X8(p)+1;return z[b>>2]=E,0},"f"),d:n(()=>52,"d"),o:n(function(){return 70},"o"),c:n((E,b,o,p)=>{for(var I=0,L=0;L<o;L++){var V=z[b>>2],v0=z[b+4>>2];b+=8;for(var ix=0;ix<v0;ix++){var x0=E,X=e0[V+ix],R0=xt[x0];X===0||X===10?(x0=x0===1?u:m,X=ve(R0,0),X=ae.decode(R0.buffer?R0.subarray(0,X):new Uint8Array(R0.slice(0,X))),x0(X),R0.length=0):R0.push(X)}I+=v0}return z[p>>2]=I,0},"c"),a:Z0,r:ne,s:n(function(E,b,o,p,I){return a.callbacks.callFunction(void 0,E,b,o,p,I)},"s"),i:n(function(E){return a.callbacks.shouldInterrupt(void 0,E)},"i"),h:n(function(E,b,o){return o=G0(o),a.callbacks.loadModuleSource(void 0,E,b,o)},"h"),g:n(function(E,b,o,p){return o=G0(o),p=G0(p),a.callbacks.normalizeModule(void 0,E,b,o,p)},"g"),t:n(function(E,b){a.callbacks.freeHostRef(void 0,E,b)},"t")},s8;return s8=await(async function(){function E(o){return o=s8=o.exports,a._malloc=o.v,a._QTS_Throw=o.w,a._QTS_NewError=o.x,a._QTS_RuntimeSetMemoryLimit=o.y,a._QTS_RuntimeComputeMemoryUsage=o.z,a._QTS_RuntimeDumpMemoryUsage=o.A,a._QTS_RecoverableLeakCheck=o.B,a._QTS_BuildIsSanitizeLeak=o.C,a._QTS_RuntimeSetMaxStackSize=o.D,a._QTS_GetUndefined=o.E,a._QTS_GetNull=o.F,a._QTS_GetFalse=o.G,a._QTS_GetTrue=o.H,a._QTS_NewHostRef=o.I,a._QTS_GetHostRefId=o.J,a._QTS_NewRuntime=o.K,a._QTS_FreeRuntime=o.L,a._free=o.M,a._QTS_NewContext=o.N,a._QTS_FreeContext=o.O,a._QTS_FreeValuePointer=o.P,a._QTS_FreeValuePointerRuntime=o.Q,a._QTS_FreeVoidPointer=o.R,a._QTS_FreeCString=o.S,a._QTS_DupValuePointer=o.T,a._QTS_NewObject=o.U,a._QTS_NewObjectProto=o.V,a._QTS_NewArray=o.W,a._QTS_NewArrayBuffer=o.X,a._QTS_NewFloat64=o.Y,a._QTS_GetFloat64=o.Z,a._QTS_NewString=o._,a._QTS_GetString=o.$,a._QTS_GetArrayBuffer=o.aa,a._QTS_GetArrayBufferLength=o.ba,a._QTS_NewSymbol=o.ca,a._QTS_GetSymbolDescriptionOrKey=o.da,a._QTS_IsGlobalSymbol=o.ea,a._QTS_IsJobPending=o.fa,a._QTS_ExecutePendingJob=o.ga,a._QTS_GetProp=o.ha,a._QTS_GetPropNumber=o.ia,a._QTS_SetProp=o.ja,a._QTS_DefineProp=o.ka,a._QTS_GetOwnPropertyNames=o.la,a._QTS_Call=o.ma,a._QTS_ResolveException=o.na,a._QTS_Dump=o.oa,a._QTS_Eval=o.pa,a._QTS_GetModuleNamespace=o.qa,a._QTS_Typeof=o.ra,a._QTS_GetLength=o.sa,a._QTS_IsEqual=o.ta,a._QTS_GetGlobalObject=o.ua,a._QTS_NewPromiseCapability=o.va,a._QTS_PromiseState=o.wa,a._QTS_PromiseResult=o.xa,a._QTS_TestStringArg=o.ya,a._QTS_GetDebugLogEnabled=o.za,a._QTS_SetDebugLogEnabled=o.Aa,a._QTS_BuildIsDebug=o.Ba,a._QTS_BuildIsAsyncify=o.Ca,a._QTS_NewFunction=o.Da,a._QTS_ArgvGetJSValueConstPointer=o.Ea,a._QTS_RuntimeEnableInterruptHandler=o.Fa,a._QTS_RuntimeDisableInterruptHandler=o.Ga,a._QTS_RuntimeEnableModuleLoader=o.Ha,a._QTS_RuntimeDisableModuleLoader=o.Ia,a._QTS_bjson_encode=o.Ja,a._QTS_bjson_decode=o.Ka,Be=o.La,se=o.Ma,W8=o.Na,oe=o.Oa,s8}n(E,"b");var b={a:et};return a.instantiateWasm?new Promise(o=>{a.instantiateWasm(b,(p,I)=>{o(E(p,I))})}):(J8??(J8=T(`\0asm\0\0\0\xBEi\`\x7F\x7F\0\`\x7F\x7F\x7F\x7F\`\x7F~\x7F\x7F~\`\x7F\x7F\x7F\`\x7F\x7F\`\x7F~\x7F\x7F\x7F~\`\x7F\x7F\x7F\0\`\x7F~~\`\x7F\x7F\x7F\x7F\x7F\`\x7F\0\`\x7F~\0\`\x7F~\x7F\`||\`\x7F\x7F~\`\x7F\x7F~\x7F\`\x7F~\x7F\x7F\x7F\x7F~\`\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F~\x7F~\`\x7F~\x7F\0\`\x7F\x7F\x7F\x7F\0\`\x7F~\x7F\x7F\`\x7F~~~\`\x7F\x7F\x7F~\`\x7F~~\x7F\x7F\x7F~\`\x7F\x7F~\x7F\x7F\`\x7F~~\x7F\`\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F~~\x7F\x7F~\`\x7F\x7F\x7F\x7F~\`|||\`\0\x7F\`\x7F~\x7F\x7F\x7F\`~\x7F\`\0\0\`\x7F~\`\x07\x7F~\x7F~~~\x7F\x7F\`\x7F~\x7F~\x7F\x7F\`\x7F~~\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F\0\`\x7F\x7F\x7F~\x7F\`\x7F~~~\x7F\x7F\`\x07\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`~~\`\x7F|\x7F\`\x7F~\x7F~~\`\x7F~\x7F~~\x7F\x7F\`~\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F~\`\x7F~\x7F\x7F\0\`\x7F\x7F|\`\x07\x7F~\x7F\x7F\x7F\x7F\x7F~\`~\x7F\0\`\x7F\x7F~\0\`\x7F~~\x7F~\`\x7F~\x7F~\x7F\`\x7F~\x7F~\0\`\x7F~~~\x7F\` \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F\x7F~\`~\x7F\x7F\x7F\`\b\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x07\x7F\x7F\x7F\x7F\x7F\x7F\x7F\0\`\x7F~\x7F\x7F\x7F\x7F\`\x7F\x7F~~\`|\x7F\`\x7F~~\x7F\x7F\0\`\x7F~~\x7F\0\`|\x7F|\`||\x7F|\`\x7F\x7F~\x7F\0\`\x7F~~~~\x7F\x7F\`\x7F\x7F~~\x7F\`\x7F~~\x7F\x7F\x7F\`\x7F|\x7F\x7F\x7F\x7F\x7F\`\0|\`\x7F~\x7F~\x7F~\`\r\x7F\x7F\x7F\x7F\x7F\x7F\x7F~\x7F\x7F\x7F\x7F\x7F~\`\x7F\x7F~\x7F\x7F\x7F\`\x7F\x7F~~~~\x7F\`\x7F\x7F~\x7F~\`\x07\x7F~~~\x7F\x7F\x7F~\`\x7F|\`\x7F|\x7F\x7F\x7F~\`\b\x7F~~\x7F\x7F\x7F\x7F\x7F~\`\x7F~\x7F\x7F\x7F\x7F\0\`\b\x7F\x7F\x7F\x7F\x7F\x7F~\x7F~\`\x7F~\x7F\x7F\x7F\x7F\x7F\`
2
+ import{c as eA}from"./chunk-IR3YJWPW.js";import{$a as o0,$b as AA,Ab as ke,Ba as ce,Da as tt,Eb as ge,Fb as Se,Ja as J,Ka as be,La as Gx,Lb as N,Mb as f0,Na as je,Nb as W,Ob as c8,Qb as ox,Ra as Q0,Rb as b8,Sa as le,Sb as Y,Ta as E8,Ua as de,Va as me,Wa as Ce,Xa as De,Ya as Ix,Za as Y8,_a as sx,ab as P0,ac as qe,bc as fx,cc as Re,db as X0,fb as W0,h as Ee,kb as ue,lb as u0,qb as pe,tb as Qx,vb as xA,xb as he}from"./chunk-5BFWDFPX.js";import{k as q,l as _,m as r0,n as Z,o as g,q as Bx,r as n0,s as o8,u as f8,v as D,w as z0,x as Hx}from"./chunk-IFP6W4OW.js";import{b as x}from"./chunk-ES2ISFJC.js";import{a as n,b as rt,c as Ft,e as fe}from"./chunk-FTQLQJQV.js";var BF=Ft((xf,iF)=>{"use strict";var In=Object.create,A8=Object.defineProperty,Qn=Object.getOwnPropertyDescriptor,VA=Object.getOwnPropertyNames,Pn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty,Nn=n((A,e,r)=>e in A?A8(A,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):A[e]=r,"__defNormalProp"),On=n((A,e)=>function(){return A&&(e=(0,A[VA(A)[0]])(A=0)),e},"__esm"),Ln=n((A,e)=>function(){return e||(0,A[VA(A)[0]])((e={exports:{}}).exports,e),e.exports},"__commonJS"),FF=n((A,e)=>{for(var r in e)A8(A,r,{get:e[r],enumerable:!0})},"__export"),tF=n((A,e,r,F)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of VA(e))!Mn.call(A,t)&&t!==r&&A8(A,t,{get:n(()=>e[t],"get"),enumerable:!(F=Qn(e,t))||F.enumerable});return A},"__copyProps"),Vn=n((A,e,r)=>(r=A!=null?In(Pn(A)):{},tF(e||!A||!A.__esModule?A8(r,"default",{value:A,enumerable:!0}):r,A)),"__toESM"),Jn=n(A=>tF(A8({},"__esModule",{value:!0}),A),"__toCommonJS"),Un=n((A,e,r)=>(Nn(A,typeof e!="symbol"?e+"":e,r),r),"__publicField"),aF={};FF(aF,{QuickJSFFI:n(()=>vF,"QuickJSFFI")});var vF,Zn=On({"src/ffi.ts"(){"use strict";vF=class{static{n(this,"QuickJSFFI")}constructor(A){this.module=A,this.DEBUG=!1,this.QTS_Throw=this.module.cwrap("QTS_Throw","number",["number","number"]),this.QTS_NewError=this.module.cwrap("QTS_NewError","number",["number"]),this.QTS_RuntimeSetMemoryLimit=this.module.cwrap("QTS_RuntimeSetMemoryLimit",null,["number","number"]),this.QTS_RuntimeComputeMemoryUsage=this.module.cwrap("QTS_RuntimeComputeMemoryUsage","number",["number","number"]),this.QTS_RuntimeDumpMemoryUsage=this.module.cwrap("QTS_RuntimeDumpMemoryUsage","number",["number"]),this.QTS_RecoverableLeakCheck=this.module.cwrap("QTS_RecoverableLeakCheck","number",[]),this.QTS_BuildIsSanitizeLeak=this.module.cwrap("QTS_BuildIsSanitizeLeak","number",[]),this.QTS_RuntimeSetMaxStackSize=this.module.cwrap("QTS_RuntimeSetMaxStackSize",null,["number","number"]),this.QTS_GetUndefined=this.module.cwrap("QTS_GetUndefined","number",[]),this.QTS_GetNull=this.module.cwrap("QTS_GetNull","number",[]),this.QTS_GetFalse=this.module.cwrap("QTS_GetFalse","number",[]),this.QTS_GetTrue=this.module.cwrap("QTS_GetTrue","number",[]),this.QTS_NewHostRef=this.module.cwrap("QTS_NewHostRef","number",["number","number"]),this.QTS_GetHostRefId=this.module.cwrap("QTS_GetHostRefId","number",["number"]),this.QTS_NewRuntime=this.module.cwrap("QTS_NewRuntime","number",[]),this.QTS_FreeRuntime=this.module.cwrap("QTS_FreeRuntime",null,["number"]),this.QTS_NewContext=this.module.cwrap("QTS_NewContext","number",["number","number"]),this.QTS_FreeContext=this.module.cwrap("QTS_FreeContext",null,["number"]),this.QTS_FreeValuePointer=this.module.cwrap("QTS_FreeValuePointer",null,["number","number"]),this.QTS_FreeValuePointerRuntime=this.module.cwrap("QTS_FreeValuePointerRuntime",null,["number","number"]),this.QTS_FreeVoidPointer=this.module.cwrap("QTS_FreeVoidPointer",null,["number","number"]),this.QTS_FreeCString=this.module.cwrap("QTS_FreeCString",null,["number","number"]),this.QTS_DupValuePointer=this.module.cwrap("QTS_DupValuePointer","number",["number","number"]),this.QTS_NewObject=this.module.cwrap("QTS_NewObject","number",["number"]),this.QTS_NewObjectProto=this.module.cwrap("QTS_NewObjectProto","number",["number","number"]),this.QTS_NewArray=this.module.cwrap("QTS_NewArray","number",["number"]),this.QTS_NewArrayBuffer=this.module.cwrap("QTS_NewArrayBuffer","number",["number","number","number"]),this.QTS_NewFloat64=this.module.cwrap("QTS_NewFloat64","number",["number","number"]),this.QTS_GetFloat64=this.module.cwrap("QTS_GetFloat64","number",["number","number"]),this.QTS_NewString=this.module.cwrap("QTS_NewString","number",["number","number"]),this.QTS_GetString=this.module.cwrap("QTS_GetString","number",["number","number"]),this.QTS_GetArrayBuffer=this.module.cwrap("QTS_GetArrayBuffer","number",["number","number"]),this.QTS_GetArrayBufferLength=this.module.cwrap("QTS_GetArrayBufferLength","number",["number","number"]),this.QTS_NewSymbol=this.module.cwrap("QTS_NewSymbol","number",["number","number","number"]),this.QTS_GetSymbolDescriptionOrKey=this.module.cwrap("QTS_GetSymbolDescriptionOrKey","number",["number","number"]),this.QTS_IsGlobalSymbol=this.module.cwrap("QTS_IsGlobalSymbol","number",["number","number"]),this.QTS_IsJobPending=this.module.cwrap("QTS_IsJobPending","number",["number"]),this.QTS_ExecutePendingJob=this.module.cwrap("QTS_ExecutePendingJob","number",["number","number","number"]),this.QTS_GetProp=this.module.cwrap("QTS_GetProp","number",["number","number","number"]),this.QTS_GetPropNumber=this.module.cwrap("QTS_GetPropNumber","number",["number","number","number"]),this.QTS_SetProp=this.module.cwrap("QTS_SetProp",null,["number","number","number","number"]),this.QTS_DefineProp=this.module.cwrap("QTS_DefineProp",null,["number","number","number","number","number","number","boolean","boolean","boolean"]),this.QTS_GetOwnPropertyNames=this.module.cwrap("QTS_GetOwnPropertyNames","number",["number","number","number","number","number"]),this.QTS_Call=this.module.cwrap("QTS_Call","number",["number","number","number","number","number"]),this.QTS_ResolveException=this.module.cwrap("QTS_ResolveException","number",["number","number"]),this.QTS_Dump=this.module.cwrap("QTS_Dump","number",["number","number"]),this.QTS_Eval=this.module.cwrap("QTS_Eval","number",["number","number","number","string","number","number"]),this.QTS_GetModuleNamespace=this.module.cwrap("QTS_GetModuleNamespace","number",["number","number"]),this.QTS_Typeof=this.module.cwrap("QTS_Typeof","number",["number","number"]),this.QTS_GetLength=this.module.cwrap("QTS_GetLength","number",["number","number","number"]),this.QTS_IsEqual=this.module.cwrap("QTS_IsEqual","number",["number","number","number","number"]),this.QTS_GetGlobalObject=this.module.cwrap("QTS_GetGlobalObject","number",["number"]),this.QTS_NewPromiseCapability=this.module.cwrap("QTS_NewPromiseCapability","number",["number","number"]),this.QTS_PromiseState=this.module.cwrap("QTS_PromiseState","number",["number","number"]),this.QTS_PromiseResult=this.module.cwrap("QTS_PromiseResult","number",["number","number"]),this.QTS_TestStringArg=this.module.cwrap("QTS_TestStringArg",null,["string"]),this.QTS_GetDebugLogEnabled=this.module.cwrap("QTS_GetDebugLogEnabled","number",["number"]),this.QTS_SetDebugLogEnabled=this.module.cwrap("QTS_SetDebugLogEnabled",null,["number","number"]),this.QTS_BuildIsDebug=this.module.cwrap("QTS_BuildIsDebug","number",[]),this.QTS_BuildIsAsyncify=this.module.cwrap("QTS_BuildIsAsyncify","number",[]),this.QTS_NewFunction=this.module.cwrap("QTS_NewFunction","number",["number","string","number","boolean","number"]),this.QTS_ArgvGetJSValueConstPointer=this.module.cwrap("QTS_ArgvGetJSValueConstPointer","number",["number","number"]),this.QTS_RuntimeEnableInterruptHandler=this.module.cwrap("QTS_RuntimeEnableInterruptHandler",null,["number"]),this.QTS_RuntimeDisableInterruptHandler=this.module.cwrap("QTS_RuntimeDisableInterruptHandler",null,["number"]),this.QTS_RuntimeEnableModuleLoader=this.module.cwrap("QTS_RuntimeEnableModuleLoader",null,["number","number"]),this.QTS_RuntimeDisableModuleLoader=this.module.cwrap("QTS_RuntimeDisableModuleLoader",null,["number"]),this.QTS_bjson_encode=this.module.cwrap("QTS_bjson_encode","number",["number","number"]),this.QTS_bjson_decode=this.module.cwrap("QTS_bjson_decode","number",["number","number"])}}}}),Kn=Ln({"dist/emscripten-module.cjs"(A,e){"use strict";var r=(()=>{var F=globalThis.document?.currentScript?.src;return async function(t={}){var v,a=t,B=!!globalThis.window,c=!!globalThis.WorkerGlobalScope,i=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";function s(E){E={log:E||function(){}};for(let b of s.Pa)b(E);return a.quickJSEmscriptenExtensions=E}n(s,"q"),s.Pa=[],a.quickjsEmscriptenInit=s,s.Pa.push(E=>{E.getWasmMemory=function(){return Z0}});var f="./this.program",j=n((E,b)=>{throw b},"u");if(typeof __filename<"u"?F=__filename:c&&(F=self.location.href),i){var l=rt("fs");1<process.argv.length&&(f=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),j=n((E,b)=>{throw process.exitCode=E,b},"u")}else if(B||c)try{new URL(".",F)}catch{}var u=console.log.bind(console),m=console.error.bind(console),R=!1,y;function T(E){for(var b=0,o=E.length,p=new Uint8Array(o),I;b<o;++b)I=E.charCodeAt(b),p[b]=~I>>8&I;return p}n(T,"ca");var k,A0,K,e0,P,z,l0=!1;function U0(){var E=Z0.buffer;a.HEAP8=K=new Int8Array(E),new Int16Array(E),a.HEAPU8=e0=new Uint8Array(E),new Uint16Array(E),P=new Int32Array(E),z=new Uint32Array(E),new Float32Array(E),new Float64Array(E),new BigInt64Array(E),new BigUint64Array(E)}n(U0,"H");function s0(E){throw a.onAbort?.(E),E="Aborted("+E+")",m(E),R=!0,E=new WebAssembly.RuntimeError(E+". Build with -sASSERTIONS for more info."),A0?.(E),E}n(s0,"I");var J8;async function UF(E){return E}n(UF,"da");async function ZF(E){var b=J8;try{var o=await UF(b);return await WebAssembly.instantiate(o,E)}catch(p){m(`failed to asynchronously prepare wasm: ${p}`),s0(p)}}n(ZF,"ea");async function KF(E){return ZF(E)}n(KF,"fa");class U8{static{n(this,"K")}constructor(b){Un(this,"name","ExitStatus"),this.message=`Program terminated with exit(${b})`,this.status=b}}for(var re=E=>{for(;0<E.length;)E.shift()(a)},Fe=[],te=[],zF=()=>{var E=a.preRun.shift();te.push(E)},B8=!0,Z0,ae=new TextDecoder,ve=(E,b,o,p)=>{if(o=b+o,p)return o;for(;E[b]&&!(b>=o);)++b;return b},G0=(E,b,o)=>E?ae.decode(e0.subarray(E,ve(e0,E,b,o))):"",Z8=0,XF=[0,31,60,91,121,152,182,213,244,274,305,335],WF=[0,31,59,90,120,151,181,212,243,273,304,334],$x={},ne=E=>{y=E,B8||0<Z8||(a.onExit?.(E),R=!0),j(E,new U8(E))},YF=E=>{if(!R)try{E()}catch(b){b instanceof U8||b=="unwind"||j(1,b)}finally{if(!(B8||0<Z8))try{y=E=y,ne(E)}catch(b){b instanceof U8||b=="unwind"||j(1,b)}}},K0=(E,b,o)=>{var p=e0;if(!(0<o))return 0;var I=b;o=b+o-1;for(var L=0;L<E.length;++L){var V=E.codePointAt(L);if(127>=V){if(b>=o)break;p[b++]=V}else if(2047>=V){if(b+1>=o)break;p[b++]=192|V>>6,p[b++]=128|V&63}else if(65535>=V){if(b+2>=o)break;p[b++]=224|V>>12,p[b++]=128|V>>6&63,p[b++]=128|V&63}else{if(b+3>=o)break;p[b++]=240|V>>18,p[b++]=128|V>>12&63,p[b++]=128|V>>6&63,p[b++]=128|V&63,L++}}return p[b]=0,b-I},K8={},ie=()=>{if(!z8){var E={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:f||"./this.program"},b;for(b in K8)K8[b]===void 0?delete E[b]:E[b]=K8[b];var o=[];for(b in E)o.push(`${b}=${E[b]}`);z8=o}return z8},z8,X8=E=>{for(var b=0,o=0;o<E.length;++o){var p=E.charCodeAt(o);127>=p?b++:2047>=p?b+=2:55296<=p&&57343>=p?(b+=4,++o):b+=3}return b},xt=[null,[],[]],At=(E,b,o,p)=>{var I={string:n(x0=>{var X=0;if(x0!=null&&x0!==0){X=X8(x0)+1;var R0=W8(X);K0(x0,R0,X),X=R0}return X},"string"),array:n(x0=>{var X=W8(x0.length);return K.set(x0,X),X},"array")};E=a["_"+E];var L=[],V=0;if(p)for(var v0=0;v0<p.length;v0++){var ix=I[o[v0]];ix?(V===0&&(V=oe()),L[v0]=ix(p[v0])):L[v0]=p[v0]}return o=E(...L),o=(function(x0){return V!==0&&se(V),b==="string"?G0(x0):b==="boolean"?!!x0:x0})(o)},Tx=new Uint8Array(123),I0=25;0<=I0;--I0)Tx[48+I0]=52+I0,Tx[65+I0]=I0,Tx[97+I0]=26+I0;if(Tx[43]=62,Tx[47]=63,a.wasmMemory?Z0=a.wasmMemory:Z0=new WebAssembly.Memory({initial:(a.INITIAL_MEMORY||16777216)/65536,maximum:32768}),U0(),a.noExitRuntime&&(B8=a.noExitRuntime),a.print&&(u=a.print),a.printErr&&(m=a.printErr),a.thisProgram&&(f=a.thisProgram),a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.shift()();a.cwrap=(E,b,o,p)=>{var I=!o||o.every(L=>L==="number"||L==="boolean");return b!=="string"&&I&&!p?a["_"+E]:(...L)=>At(E,b,o,L)},a.UTF8ToString=G0,a.stringToUTF8=(E,b,o)=>K0(E,b,o),a.lengthBytesUTF8=X8;var Be,se,W8,oe,et={b:n((E,b,o,p)=>s0(`Assertion failed: ${G0(E)}, at: `+[b?G0(b):"unknown filename",o,p?G0(p):"unknown function"]),"b"),q:n(()=>s0(""),"q"),l:n(()=>{B8=!1,Z8=0},"l"),m:n(function(E,b){E=-9007199254740992>E||9007199254740992<E?NaN:Number(E),E=new Date(1e3*E),P[b>>2]=E.getSeconds(),P[b+4>>2]=E.getMinutes(),P[b+8>>2]=E.getHours(),P[b+12>>2]=E.getDate(),P[b+16>>2]=E.getMonth(),P[b+20>>2]=E.getFullYear()-1900,P[b+24>>2]=E.getDay();var o=E.getFullYear();P[b+28>>2]=(o%4!==0||o%100===0&&o%400!==0?WF:XF)[E.getMonth()]+E.getDate()-1|0,P[b+36>>2]=-(60*E.getTimezoneOffset()),o=new Date(E.getFullYear(),6,1).getTimezoneOffset();var p=new Date(E.getFullYear(),0,1).getTimezoneOffset();P[b+32>>2]=(o!=p&&E.getTimezoneOffset()==Math.min(p,o))|0},"m"),j:n((E,b)=>{if($x[E]&&(clearTimeout($x[E].id),delete $x[E]),!b)return 0;var o=setTimeout(()=>{delete $x[E],YF(()=>Be(E,performance.now()))},b);return $x[E]={id:o,Qa:b},0},"j"),n:n((E,b,o,p)=>{var I=new Date().getFullYear(),L=new Date(I,0,1).getTimezoneOffset();I=new Date(I,6,1).getTimezoneOffset(),z[E>>2]=60*Math.max(L,I),P[b>>2]=+(L!=I),b=n(V=>{var v0=Math.abs(V);return`UTC${0<=V?"-":"+"}${String(Math.floor(v0/60)).padStart(2,"0")}${String(v0%60).padStart(2,"0")}`},"d"),E=b(L),b=b(I),I<L?(K0(E,o,17),K0(b,p,17)):(K0(E,p,17),K0(b,o,17))},"n"),p:n(()=>Date.now(),"p"),k:n(E=>{var b=e0.length;if(E>>>=0,2147483648<E)return!1;for(var o=1;4>=o;o*=2){var p=b*(1+.2/o);p=Math.min(p,E+100663296);x:{p=(Math.min(2147483648,65536*Math.ceil(Math.max(E,p)/65536))-Z0.buffer.byteLength+65535)/65536|0;try{Z0.grow(p),U0();var I=1;break x}catch{}I=void 0}if(I)return!0}return!1},"k"),e:n((E,b)=>{var o=0,p=0,I;for(I of ie()){var L=b+o;z[E+p>>2]=L,o+=K0(I,L,1/0)+1,p+=4}return 0},"e"),f:n((E,b)=>{var o=ie();z[E>>2]=o.length,E=0;for(var p of o)E+=X8(p)+1;return z[b>>2]=E,0},"f"),d:n(()=>52,"d"),o:n(function(){return 70},"o"),c:n((E,b,o,p)=>{for(var I=0,L=0;L<o;L++){var V=z[b>>2],v0=z[b+4>>2];b+=8;for(var ix=0;ix<v0;ix++){var x0=E,X=e0[V+ix],R0=xt[x0];X===0||X===10?(x0=x0===1?u:m,X=ve(R0,0),X=ae.decode(R0.buffer?R0.subarray(0,X):new Uint8Array(R0.slice(0,X))),x0(X),R0.length=0):R0.push(X)}I+=v0}return z[p>>2]=I,0},"c"),a:Z0,r:ne,s:n(function(E,b,o,p,I){return a.callbacks.callFunction(void 0,E,b,o,p,I)},"s"),i:n(function(E){return a.callbacks.shouldInterrupt(void 0,E)},"i"),h:n(function(E,b,o){return o=G0(o),a.callbacks.loadModuleSource(void 0,E,b,o)},"h"),g:n(function(E,b,o,p){return o=G0(o),p=G0(p),a.callbacks.normalizeModule(void 0,E,b,o,p)},"g"),t:n(function(E,b){a.callbacks.freeHostRef(void 0,E,b)},"t")},s8;return s8=await(async function(){function E(o){return o=s8=o.exports,a._malloc=o.v,a._QTS_Throw=o.w,a._QTS_NewError=o.x,a._QTS_RuntimeSetMemoryLimit=o.y,a._QTS_RuntimeComputeMemoryUsage=o.z,a._QTS_RuntimeDumpMemoryUsage=o.A,a._QTS_RecoverableLeakCheck=o.B,a._QTS_BuildIsSanitizeLeak=o.C,a._QTS_RuntimeSetMaxStackSize=o.D,a._QTS_GetUndefined=o.E,a._QTS_GetNull=o.F,a._QTS_GetFalse=o.G,a._QTS_GetTrue=o.H,a._QTS_NewHostRef=o.I,a._QTS_GetHostRefId=o.J,a._QTS_NewRuntime=o.K,a._QTS_FreeRuntime=o.L,a._free=o.M,a._QTS_NewContext=o.N,a._QTS_FreeContext=o.O,a._QTS_FreeValuePointer=o.P,a._QTS_FreeValuePointerRuntime=o.Q,a._QTS_FreeVoidPointer=o.R,a._QTS_FreeCString=o.S,a._QTS_DupValuePointer=o.T,a._QTS_NewObject=o.U,a._QTS_NewObjectProto=o.V,a._QTS_NewArray=o.W,a._QTS_NewArrayBuffer=o.X,a._QTS_NewFloat64=o.Y,a._QTS_GetFloat64=o.Z,a._QTS_NewString=o._,a._QTS_GetString=o.$,a._QTS_GetArrayBuffer=o.aa,a._QTS_GetArrayBufferLength=o.ba,a._QTS_NewSymbol=o.ca,a._QTS_GetSymbolDescriptionOrKey=o.da,a._QTS_IsGlobalSymbol=o.ea,a._QTS_IsJobPending=o.fa,a._QTS_ExecutePendingJob=o.ga,a._QTS_GetProp=o.ha,a._QTS_GetPropNumber=o.ia,a._QTS_SetProp=o.ja,a._QTS_DefineProp=o.ka,a._QTS_GetOwnPropertyNames=o.la,a._QTS_Call=o.ma,a._QTS_ResolveException=o.na,a._QTS_Dump=o.oa,a._QTS_Eval=o.pa,a._QTS_GetModuleNamespace=o.qa,a._QTS_Typeof=o.ra,a._QTS_GetLength=o.sa,a._QTS_IsEqual=o.ta,a._QTS_GetGlobalObject=o.ua,a._QTS_NewPromiseCapability=o.va,a._QTS_PromiseState=o.wa,a._QTS_PromiseResult=o.xa,a._QTS_TestStringArg=o.ya,a._QTS_GetDebugLogEnabled=o.za,a._QTS_SetDebugLogEnabled=o.Aa,a._QTS_BuildIsDebug=o.Ba,a._QTS_BuildIsAsyncify=o.Ca,a._QTS_NewFunction=o.Da,a._QTS_ArgvGetJSValueConstPointer=o.Ea,a._QTS_RuntimeEnableInterruptHandler=o.Fa,a._QTS_RuntimeDisableInterruptHandler=o.Ga,a._QTS_RuntimeEnableModuleLoader=o.Ha,a._QTS_RuntimeDisableModuleLoader=o.Ia,a._QTS_bjson_encode=o.Ja,a._QTS_bjson_decode=o.Ka,Be=o.La,se=o.Ma,W8=o.Na,oe=o.Oa,s8}n(E,"b");var b={a:et};return a.instantiateWasm?new Promise(o=>{a.instantiateWasm(b,(p,I)=>{o(E(p,I))})}):(J8??(J8=T(`\0asm\0\0\0\xBEi\`\x7F\x7F\0\`\x7F\x7F\x7F\x7F\`\x7F~\x7F\x7F~\`\x7F\x7F\x7F\`\x7F\x7F\`\x7F~\x7F\x7F\x7F~\`\x7F\x7F\x7F\0\`\x7F~~\`\x7F\x7F\x7F\x7F\x7F\`\x7F\0\`\x7F~\0\`\x7F~\x7F\`||\`\x7F\x7F~\`\x7F\x7F~\x7F\`\x7F~\x7F\x7F\x7F\x7F~\`\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F~\x7F~\`\x7F~\x7F\0\`\x7F\x7F\x7F\x7F\0\`\x7F~\x7F\x7F\`\x7F~~~\`\x7F\x7F\x7F~\`\x7F~~\x7F\x7F\x7F~\`\x7F\x7F~\x7F\x7F\`\x7F~~\x7F\`\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F~~\x7F\x7F~\`\x7F\x7F\x7F\x7F~\`|||\`\0\x7F\`\x7F~\x7F\x7F\x7F\`~\x7F\`\0\0\`\x7F~\`\x07\x7F~\x7F~~~\x7F\x7F\`\x7F~\x7F~\x7F\x7F\`\x7F~~\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F\0\`\x7F\x7F\x7F~\x7F\`\x7F~~~\x7F\x7F\`\x07\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`~~\`\x7F|\x7F\`\x7F~\x7F~~\`\x7F~\x7F~~\x7F\x7F\`~\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F~\`\x7F~\x7F\x7F\0\`\x7F\x7F|\`\x07\x7F~\x7F\x7F\x7F\x7F\x7F~\`~\x7F\0\`\x7F\x7F~\0\`\x7F~~\x7F~\`\x7F~\x7F~\x7F\`\x7F~\x7F~\0\`\x7F~~~\x7F\` \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F\x7F~\`~\x7F\x7F\x7F\`\b\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x07\x7F\x7F\x7F\x7F\x7F\x7F\x7F\0\`\x7F~\x7F\x7F\x7F\x7F\`\x7F\x7F~~\`|\x7F\`\x7F~~\x7F\x7F\0\`\x7F~~\x7F\0\`|\x7F|\`||\x7F|\`\x7F\x7F~\x7F\0\`\x7F~~~~\x7F\x7F\`\x7F\x7F~~\x7F\`\x7F~~\x7F\x7F\x7F\`\x7F|\x7F\x7F\x7F\x7F\x7F\`\0|\`\x7F~\x7F~\x7F~\`\r\x7F\x7F\x7F\x7F\x7F\x7F\x7F~\x7F\x7F\x7F\x7F\x7F~\`\x7F\x7F~\x7F\x7F\x7F\`\x7F\x7F~~~~\x7F\`\x7F\x7F~\x7F~\`\x07\x7F~~~\x7F\x7F\x7F~\`\x7F|\`\x7F|\x7F\x7F\x7F~\`\b\x7F~~\x7F\x7F\x7F\x7F\x7F~\`\x7F~\x7F\x7F\x7F\x7F\0\`\b\x7F\x7F\x7F\x7F\x7F\x7F~\x7F~\`\x7F~\x7F\x7F\x7F\x7F\x7F\`
3
3
  \x7F\x7F~\x7F\x7F~~~\x7F\x7F\x7F\`\x7F\x7F~~~~\`||\x7F\`\x7F\x7F\x7F\x7F\x7F|\`\x7F\x7F~~\x7F\x7F\`\x7F~~\0\`\x07\x7F~\x7F\x7F\x7F\x7F\x7F\0\`\x7F~~~~\`|\x7F\x7F\`\x7F\x7F~~~\`\b\x7F~~~~\x7F~~~\`~~\x7F\x7F\`\x07\x7F\x7F\x7F~~~\x7F\x7F\`\x7F\x7F|\0\`\x7F~|~\`\0~\`\x7F|\0\` \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\0~ab\0ac\0\bad\0ae\0af\0ag\0\bah\0ai\0aj\0+ak\0al\0!am\x003an\0ao\0ap\0Jaq\0!ar\0 as\0at\0\0aa\x80\x80\x80\xAB
4
4
  \xA9
5
5
 
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as me,b as D,c as G,d as j,e as z,g as ye,i as T,j as we,k as S,l as he,v as B,x as F}from"./chunk-Y2NQXJ2Q.js";import{a as fe,b as L,c as R}from"./chunk-TJNIYJUH.js";import{b as H,c as be,d as ve,f as w,h as P,i as Re}from"./chunk-BSHAIAXY.js";import{M as ce,N as le,R as de,V as pe,h as $,i as ne,l as oe,n as re,o as ie,p as ae,q as se}from"./chunk-6LY7GYNK.js";import{d as y,e as ue,f as ge,g as C}from"./chunk-XRV4WLI7.js";import{a as Z,b as ee,c as te}from"./chunk-JKMPJFMN.js";import{a as M,f as v,k as X}from"./chunk-3M53YXEI.js";import{a as g}from"./chunk-FTQLQJQV.js";import{promises as V,existsSync as W}from"node:fs";import U from"node:path";import{stdin as $e}from"node:process";async function Ge(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=await ie(n,i,a.id);console.log(JSON.stringify(s,null,2))}g(Ge,"runTemplateStatus");async function je(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=await ae(n,i,a.id);console.log(JSON.stringify(s,null,2))}g(je,"runTemplateBranches");async function ze(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=typeof e.env=="string"?e.env:typeof e.environment=="string"?e.environment:void 0,f=X(s),c=await se(n,i,a.id,{environment:f});console.log(JSON.stringify(c,null,2))}g(ze,"runTemplateUpdate");async function He(e){let o=await y(),t=w(o),r=typeof e.apiKey=="string"?e.apiKey:typeof e.key=="string"?e.key:null,n=r?r.trim():await L();if(!n)throw new Error("API key is required");n.startsWith("opk_")||console.log("warning: API keys usually start with opk_."),await C({handle:o.activeProfile?.handle||"default",apiKey:n,baseUrl:t,apiBaseUrl:o.apiBaseUrl,chatApiBaseUrl:o.chatApiBaseUrl,setActive:!0}),console.log("Saved account credentials to the encrypted OpenPond credential store.")}g(He,"runLogin");async function Fe(e,o){let t=o[0]||"list";if(t==="list"){let r=await ue();console.log(JSON.stringify({profiles:r},null,2));return}if(t==="use"){let r=o[1];if(!r)throw new Error("usage: profiles use <name> [--base-url <url>]");let n=await ge(r,{baseUrl:H(e)});console.log(JSON.stringify({profile:n},null,2));return}if(t==="save"){let r=o[1];if(!r)throw new Error("usage: profiles save <name> --api-key <key> [--base-url <url>] [--api-base-url <url>] [--chat-api-base-url <url>]");let n=typeof e.apiKey=="string"?e.apiKey:typeof e.key=="string"?e.key:null,i=n?n.trim():await L(),a=typeof e.environment=="string"?e.environment:typeof e.env=="string"?e.env:void 0,s=await C({handle:r,apiKey:i,baseUrl:H(e),apiBaseUrl:be(e),chatApiBaseUrl:ve(e),environment:a,setActive:!0});console.log(JSON.stringify({profile:s},null,2));return}throw new Error("usage: profiles <list|use|save> [args]")}g(Fe,"runProfiles");async function Ve(){let e=await y(),o=w(e),t=P(e),r=await R(e,o),n=await ce(t,r);console.log(JSON.stringify(n,null,2))}g(Ve,"runAccount");async function We(e){let o=await y(),t=P(o),r=fe(o),n=await le(t,r);console.log(JSON.stringify(n,null,2))}g(We,"runHealth");async function qe(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=typeof e.branch=="string"?String(e.branch):void 0,f=await $(n,i,a.id,{branch:s});if(!f?.id){console.log("no deployments found");return}let c=await ne(n,i,f.id),d=(c&&Array.isArray(c.toolsJson)?c.toolsJson:null)||(c&&typeof c.metadataJson=="object"&&c.metadataJson?c.metadataJson.tools:null),u=Array.isArray(d)?d:[];if(u.length===0){console.log("no tools found");return}for(let l of u){let m=l,h=m.profile||m.function,I=m.name||h?.name||"unknown",p=m.description||h?.description||"";console.log(p?`${I} - ${p}`:I)}}g(qe,"runToolList");async function Ye(e,o,t){let r=await y(),n=w(r),i=P(r),a=await R(r,n),{app:s}=await T(i,a,o),f=typeof e.branch=="string"?String(e.branch):void 0,c=await $(i,a,s.id,{branch:f});if(!c?.id)throw new Error("no deployments found");let d;if(typeof e.body=="string")try{d=JSON.parse(e.body)}catch{throw new Error("tool body must be valid JSON")}let u=typeof e.method=="string"?String(e.method).toUpperCase():"POST",l=await pe(n,a,{appId:s.id,deploymentId:c.id,toolName:t,method:u,body:d,headers:a?{"openpond-api-key":a}:void 0});if(!l.ok)throw new Error(l.error||`tool failed (${l.status})`);let m=l.data??{ok:!0};console.log(JSON.stringify(m,null,2))}g(Ye,"runToolRun");async function Qe(e,o,t){let r=await y(),n=w(r),i=P(r),a=await R(r,n),{app:s}=await T(i,a,o),f=typeof e.branch=="string"?String(e.branch):void 0,c=typeof e.deploymentId=="string"?String(e.deploymentId):void 0,d=c?{id:c}:await $(i,a,s.id,{branch:f});if(!d?.id)throw new Error("no deployments found");let u=typeof e.body=="string"?M(String(e.body),"body"):{};if(!u||typeof u!="object"||Array.isArray(u))throw new Error("body must be a JSON object");let l=typeof e.method=="string"?String(e.method).toUpperCase():"POST",m={...u,appId:s.id,deploymentId:d.id,toolName:t,method:l},h=await de(i,a,m);console.log(JSON.stringify(h,null,2))}g(Qe,"runBacktestRun");async function Xe(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a,handle:s,repo:f}=await T(n,i,o),c=typeof e.branch=="string"?String(e.branch):void 0,d=typeof e.deploymentId=="string"?String(e.deploymentId):void 0,u=d?{id:d}:await $(n,i,a.id,{branch:c});if(!u?.id){console.log("no deployments found");return}await we({baseUrl:n,apiKey:i,deploymentId:u.id,prefix:`[${s}/${f}] `,intervalMs:e.interval?Number(e.interval):void 0,timeoutMs:e.timeout?Number(e.timeout):void 0})}g(Xe,"runDeployWatch");async function Ze(e,o){let r=((typeof e.name=="string"?e.name:null)||o.join(" ")).trim();if(!r)throw new Error("usage: repo create --name <name> [--team-id <id>] [--path <dir>] [--template <owner/repo|url>] [--template-branch <branch>] [--empty|--opentool] [--sandbox] [--token] [--auto-schedule-migration <true|false>]");let n=await y(),i=w(n),a=await R(n,i),s=P(n),f=typeof e.teamId=="string"&&e.teamId.trim()?e.teamId.trim():void 0,c=typeof e.template=="string"?e.template.trim():"";if(c&&(e.empty==="true"||e.opentool==="true"))throw new Error("choose one: --template or --empty/--opentool");if(e.empty==="true"&&e.opentool==="true")throw new Error("choose one: --empty or --opentool");let d=typeof e.description=="string"?e.description.trim():void 0,u=typeof e.templateBranch=="string"&&e.templateBranch.trim().length>0?e.templateBranch.trim():void 0,l=typeof e.env=="string"?M(e.env,"env"):void 0;if(l){if(typeof l!="object"||Array.isArray(l))throw new Error("env must be a JSON object");for(let[b,A]of Object.entries(l))if(typeof A!="string")throw new Error(`env value for ${b} must be a string`)}if(c){e.deployOnPush!==void 0&&console.warn("deploy-on-push is not used for template create (auto deploys)");let b=Re(c,i),k=(await re(s,a,[{name:r,...d?{description:d}:{},templateRepoUrl:b,...u?{templateBranch:u}:{},...l?{envVars:l}:{}}],f)).items?.[0];if(!k||k.status!=="ok"||!k.appId)throw new Error(k?.error||"Template create failed");console.log(`app_id: ${k.appId}`),k.deploymentId&&console.log(`deployment_id: ${k.deploymentId}`),k.conversationId&&console.log(`conversation_id: ${k.conversationId}`);return}let m=process.cwd(),h=typeof e.path=="string"?e.path:typeof e.dir=="string"?e.dir:null,I=h&&h.trim().length>0?h.trim():$e.isTTY?await he(m):m,p=U.resolve(I);if(W(p)){if(!(await V.stat(p)).isDirectory())throw new Error(`path is not a directory: ${p}`)}else await V.mkdir(p,{recursive:!0});let Pe=(await V.readdir(p)).filter(b=>b!==".git").length===0,x=v(e.yes)||v(e.force);if(!Pe&&!x&&!await S(`Directory is not empty (${p}). Continue?`,!1)){console.log("aborted");return}let ke=U.join(p,".git");if(!W(ke)){if(!(x?!0:await S("Initialize git repository here?",!0))){console.log("aborted");return}let A=await B("git",["init"],{cwd:p});if(A.code!==0)throw new Error(`git init failed: ${A.stderr.trim()||A.stdout.trim()||"unknown error"}`)}let K=await F(p,"origin");if(K&&!x&&!await S(`Remote "origin" already set (${K}). Replace it?`,!1)){console.log("aborted");return}let q=e.opentool==="true"?"opentool":"empty",Te=v(e.sandbox),Be=v(e.deployOnPush),N=e.autoScheduleMigration,Y=typeof N=="string"||typeof N=="boolean",Ee=Y?v(N):void 0,E=await oe(s,a,{name:r,...f?{teamId:f}:{},...d?{description:d}:{},...q?{repoInit:q}:{},...Te?{sandbox:!0}:{},...l?{envVars:l}:{},...Be?{deployOnPush:!0}:{},...Y?{autoScheduleMigration:Ee}:{}}),O=me(E);z(O);let J=v(e.token)||v(e.setRemoteToken),Oe=D(O,a),Q=J?Oe:O,_=await B("git",K?["remote","set-url","origin",Q]:["remote","add","origin",Q],{cwd:p});if(_.code!==0)throw new Error(`git remote failed: ${j(_.stderr.trim()||_.stdout.trim()||"unknown error")}`);let Ae=J?G(O):O;console.log(`app_id: ${E.appId}`),E.gitOwner&&E.gitRepo&&console.log(`repo: ${E.gitOwner}/${E.gitRepo}`),console.log(`remote: ${Ae}`),console.log('next: git add . && git commit -m "init"');let Ie=E.defaultBranch||"master";console.log(`next: openpond repo push --path ${p} --branch ${Ie}`),J||console.log(`token-remote (non-interactive): git -C ${p} remote set-url origin ${G(O)}`);try{await ye({apiBase:s,apiKey:a,forceRefresh:!0})}catch(b){console.warn("cache refresh failed",b)}}g(Ze,"runRepoCreate");async function Se(e){let o=await B("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e});if(o.code!==0)return null;let t=o.stdout.trim();return t.length>0?t:null}g(Se,"resolveGitBranch");async function et(e){let o=await y(),t=w(o),r=await R(o,t),n=typeof e.path=="string"?e.path:typeof e.dir=="string"?e.dir:null,i=U.resolve(n&&n.trim().length>0?n.trim():"."),a=U.join(i,".git");if(!W(a))throw new Error(`git repo not found at ${i} (missing .git)`);let s=await F(i,"origin");if(!s)throw new Error("origin remote not set; run `openpond repo create` first");z(s);let c=(typeof e.branch=="string"?e.branch.trim():"")||await Se(i);if(!c)throw new Error("unable to resolve git branch; pass --branch");let d;try{d=D(s,r)}catch{throw new Error("origin remote must be https for tokenized pushes")}let u=v(e.keepTokenRemote)||v(e.token)||v(e.setRemoteToken),l=s.includes("x-access-token:"),m=!u&&!l?s:null,h=process.env.GIT_TERMINAL_PROMPT;process.env.GIT_TERMINAL_PROMPT="0";try{if(!l){let p=await B("git",["remote","set-url","origin",d],{cwd:i});if(p.code!==0)throw new Error(`git remote set-url failed: ${j(p.stderr.trim()||p.stdout.trim()||"unknown error")}`)}if((await B("git",["push","-u","origin",c],{cwd:i,inherit:!0})).code!==0)throw new Error("git push failed")}finally{m&&await B("git",["remote","set-url","origin",m],{cwd:i}).catch(()=>null),h===void 0?delete process.env.GIT_TERMINAL_PROMPT:process.env.GIT_TERMINAL_PROMPT=h}}g(et,"runRepoPush");async function tt(e){if(e.length===0)throw new Error("usage: opentool <init|validate|build> [args]");let o=process.platform==="win32"?"npx.cmd":"npx";if((await B(o,["opentool",...e],{inherit:!0})).code!==0)throw new Error("opentool command failed")}g(tt,"runOpentool");async function nt(){let e="openpond",o=Z(),t=await te(e),r=`npm i -g ${e}@${t}`,n=ee(o,t);if(n===0){console.log(`${e} is up to date (${o})`);return}if(n===-1){console.log(`Update available: ${o} -> ${t}`),console.log(`Run: ${r}`);return}if(n===1){console.log(`Installed version (${o}) is newer than npm latest (${t}).`);return}if(o===t){console.log(`${e} is up to date (${o})`);return}console.log(`Installed: ${o}`),console.log(`Latest: ${t}`),console.log(`Run: ${r}`)}g(nt,"runCheckUpdate");export{Ge as a,je as b,ze as c,He as d,Fe as e,Ve as f,We as g,qe as h,Ye as i,Qe as j,Xe as k,Ze as l,Se as m,et as n,tt as o,nt as p};
2
+ import{a as me,b as D,c as G,d as j,e as z,g as ye,i as T,j as we,k as S,l as he,v as B,x as F}from"./chunk-MXLB6MEW.js";import{a as fe,b as L,c as R}from"./chunk-XCTFXXVY.js";import{b as H,c as be,d as ve,f as w,h as P,i as Re}from"./chunk-BSHAIAXY.js";import{M as ce,N as le,R as de,V as pe,h as $,i as ne,l as oe,n as re,o as ie,p as ae,q as se}from"./chunk-Z6F6PYF4.js";import{d as y,e as ue,f as ge,g as C}from"./chunk-QPZNN5Q3.js";import{a as Z,b as ee,c as te}from"./chunk-JFR34MIK.js";import{a as M,f as v,k as X}from"./chunk-3M53YXEI.js";import{a as g}from"./chunk-FTQLQJQV.js";import{promises as V,existsSync as W}from"node:fs";import U from"node:path";import{stdin as $e}from"node:process";async function Ge(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=await ie(n,i,a.id);console.log(JSON.stringify(s,null,2))}g(Ge,"runTemplateStatus");async function je(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=await ae(n,i,a.id);console.log(JSON.stringify(s,null,2))}g(je,"runTemplateBranches");async function ze(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=typeof e.env=="string"?e.env:typeof e.environment=="string"?e.environment:void 0,f=X(s),c=await se(n,i,a.id,{environment:f});console.log(JSON.stringify(c,null,2))}g(ze,"runTemplateUpdate");async function He(e){let o=await y(),t=w(o),r=typeof e.apiKey=="string"?e.apiKey:typeof e.key=="string"?e.key:null,n=r?r.trim():await L();if(!n)throw new Error("API key is required");n.startsWith("opk_")||console.log("warning: API keys usually start with opk_."),await C({handle:o.activeProfile?.handle||"default",apiKey:n,baseUrl:t,apiBaseUrl:o.apiBaseUrl,chatApiBaseUrl:o.chatApiBaseUrl,setActive:!0}),console.log("Saved account credentials to the encrypted OpenPond credential store.")}g(He,"runLogin");async function Fe(e,o){let t=o[0]||"list";if(t==="list"){let r=await ue();console.log(JSON.stringify({profiles:r},null,2));return}if(t==="use"){let r=o[1];if(!r)throw new Error("usage: profiles use <name> [--base-url <url>]");let n=await ge(r,{baseUrl:H(e)});console.log(JSON.stringify({profile:n},null,2));return}if(t==="save"){let r=o[1];if(!r)throw new Error("usage: profiles save <name> --api-key <key> [--base-url <url>] [--api-base-url <url>] [--chat-api-base-url <url>]");let n=typeof e.apiKey=="string"?e.apiKey:typeof e.key=="string"?e.key:null,i=n?n.trim():await L(),a=typeof e.environment=="string"?e.environment:typeof e.env=="string"?e.env:void 0,s=await C({handle:r,apiKey:i,baseUrl:H(e),apiBaseUrl:be(e),chatApiBaseUrl:ve(e),environment:a,setActive:!0});console.log(JSON.stringify({profile:s},null,2));return}throw new Error("usage: profiles <list|use|save> [args]")}g(Fe,"runProfiles");async function Ve(){let e=await y(),o=w(e),t=P(e),r=await R(e,o),n=await ce(t,r);console.log(JSON.stringify(n,null,2))}g(Ve,"runAccount");async function We(e){let o=await y(),t=P(o),r=fe(o),n=await le(t,r);console.log(JSON.stringify(n,null,2))}g(We,"runHealth");async function qe(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a}=await T(n,i,o),s=typeof e.branch=="string"?String(e.branch):void 0,f=await $(n,i,a.id,{branch:s});if(!f?.id){console.log("no deployments found");return}let c=await ne(n,i,f.id),d=(c&&Array.isArray(c.toolsJson)?c.toolsJson:null)||(c&&typeof c.metadataJson=="object"&&c.metadataJson?c.metadataJson.tools:null),u=Array.isArray(d)?d:[];if(u.length===0){console.log("no tools found");return}for(let l of u){let m=l,h=m.profile||m.function,I=m.name||h?.name||"unknown",p=m.description||h?.description||"";console.log(p?`${I} - ${p}`:I)}}g(qe,"runToolList");async function Ye(e,o,t){let r=await y(),n=w(r),i=P(r),a=await R(r,n),{app:s}=await T(i,a,o),f=typeof e.branch=="string"?String(e.branch):void 0,c=await $(i,a,s.id,{branch:f});if(!c?.id)throw new Error("no deployments found");let d;if(typeof e.body=="string")try{d=JSON.parse(e.body)}catch{throw new Error("tool body must be valid JSON")}let u=typeof e.method=="string"?String(e.method).toUpperCase():"POST",l=await pe(n,a,{appId:s.id,deploymentId:c.id,toolName:t,method:u,body:d,headers:a?{"openpond-api-key":a}:void 0});if(!l.ok)throw new Error(l.error||`tool failed (${l.status})`);let m=l.data??{ok:!0};console.log(JSON.stringify(m,null,2))}g(Ye,"runToolRun");async function Qe(e,o,t){let r=await y(),n=w(r),i=P(r),a=await R(r,n),{app:s}=await T(i,a,o),f=typeof e.branch=="string"?String(e.branch):void 0,c=typeof e.deploymentId=="string"?String(e.deploymentId):void 0,d=c?{id:c}:await $(i,a,s.id,{branch:f});if(!d?.id)throw new Error("no deployments found");let u=typeof e.body=="string"?M(String(e.body),"body"):{};if(!u||typeof u!="object"||Array.isArray(u))throw new Error("body must be a JSON object");let l=typeof e.method=="string"?String(e.method).toUpperCase():"POST",m={...u,appId:s.id,deploymentId:d.id,toolName:t,method:l},h=await de(i,a,m);console.log(JSON.stringify(h,null,2))}g(Qe,"runBacktestRun");async function Xe(e,o){let t=await y(),r=w(t),n=P(t),i=await R(t,r),{app:a,handle:s,repo:f}=await T(n,i,o),c=typeof e.branch=="string"?String(e.branch):void 0,d=typeof e.deploymentId=="string"?String(e.deploymentId):void 0,u=d?{id:d}:await $(n,i,a.id,{branch:c});if(!u?.id){console.log("no deployments found");return}await we({baseUrl:n,apiKey:i,deploymentId:u.id,prefix:`[${s}/${f}] `,intervalMs:e.interval?Number(e.interval):void 0,timeoutMs:e.timeout?Number(e.timeout):void 0})}g(Xe,"runDeployWatch");async function Ze(e,o){let r=((typeof e.name=="string"?e.name:null)||o.join(" ")).trim();if(!r)throw new Error("usage: repo create --name <name> [--team-id <id>] [--path <dir>] [--template <owner/repo|url>] [--template-branch <branch>] [--empty|--opentool] [--sandbox] [--token] [--auto-schedule-migration <true|false>]");let n=await y(),i=w(n),a=await R(n,i),s=P(n),f=typeof e.teamId=="string"&&e.teamId.trim()?e.teamId.trim():void 0,c=typeof e.template=="string"?e.template.trim():"";if(c&&(e.empty==="true"||e.opentool==="true"))throw new Error("choose one: --template or --empty/--opentool");if(e.empty==="true"&&e.opentool==="true")throw new Error("choose one: --empty or --opentool");let d=typeof e.description=="string"?e.description.trim():void 0,u=typeof e.templateBranch=="string"&&e.templateBranch.trim().length>0?e.templateBranch.trim():void 0,l=typeof e.env=="string"?M(e.env,"env"):void 0;if(l){if(typeof l!="object"||Array.isArray(l))throw new Error("env must be a JSON object");for(let[b,A]of Object.entries(l))if(typeof A!="string")throw new Error(`env value for ${b} must be a string`)}if(c){e.deployOnPush!==void 0&&console.warn("deploy-on-push is not used for template create (auto deploys)");let b=Re(c,i),k=(await re(s,a,[{name:r,...d?{description:d}:{},templateRepoUrl:b,...u?{templateBranch:u}:{},...l?{envVars:l}:{}}],f)).items?.[0];if(!k||k.status!=="ok"||!k.appId)throw new Error(k?.error||"Template create failed");console.log(`app_id: ${k.appId}`),k.deploymentId&&console.log(`deployment_id: ${k.deploymentId}`),k.conversationId&&console.log(`conversation_id: ${k.conversationId}`);return}let m=process.cwd(),h=typeof e.path=="string"?e.path:typeof e.dir=="string"?e.dir:null,I=h&&h.trim().length>0?h.trim():$e.isTTY?await he(m):m,p=U.resolve(I);if(W(p)){if(!(await V.stat(p)).isDirectory())throw new Error(`path is not a directory: ${p}`)}else await V.mkdir(p,{recursive:!0});let Pe=(await V.readdir(p)).filter(b=>b!==".git").length===0,x=v(e.yes)||v(e.force);if(!Pe&&!x&&!await S(`Directory is not empty (${p}). Continue?`,!1)){console.log("aborted");return}let ke=U.join(p,".git");if(!W(ke)){if(!(x?!0:await S("Initialize git repository here?",!0))){console.log("aborted");return}let A=await B("git",["init"],{cwd:p});if(A.code!==0)throw new Error(`git init failed: ${A.stderr.trim()||A.stdout.trim()||"unknown error"}`)}let K=await F(p,"origin");if(K&&!x&&!await S(`Remote "origin" already set (${K}). Replace it?`,!1)){console.log("aborted");return}let q=e.opentool==="true"?"opentool":"empty",Te=v(e.sandbox),Be=v(e.deployOnPush),N=e.autoScheduleMigration,Y=typeof N=="string"||typeof N=="boolean",Ee=Y?v(N):void 0,E=await oe(s,a,{name:r,...f?{teamId:f}:{},...d?{description:d}:{},...q?{repoInit:q}:{},...Te?{sandbox:!0}:{},...l?{envVars:l}:{},...Be?{deployOnPush:!0}:{},...Y?{autoScheduleMigration:Ee}:{}}),O=me(E);z(O);let J=v(e.token)||v(e.setRemoteToken),Oe=D(O,a),Q=J?Oe:O,_=await B("git",K?["remote","set-url","origin",Q]:["remote","add","origin",Q],{cwd:p});if(_.code!==0)throw new Error(`git remote failed: ${j(_.stderr.trim()||_.stdout.trim()||"unknown error")}`);let Ae=J?G(O):O;console.log(`app_id: ${E.appId}`),E.gitOwner&&E.gitRepo&&console.log(`repo: ${E.gitOwner}/${E.gitRepo}`),console.log(`remote: ${Ae}`),console.log('next: git add . && git commit -m "init"');let Ie=E.defaultBranch||"master";console.log(`next: openpond repo push --path ${p} --branch ${Ie}`),J||console.log(`token-remote (non-interactive): git -C ${p} remote set-url origin ${G(O)}`);try{await ye({apiBase:s,apiKey:a,forceRefresh:!0})}catch(b){console.warn("cache refresh failed",b)}}g(Ze,"runRepoCreate");async function Se(e){let o=await B("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e});if(o.code!==0)return null;let t=o.stdout.trim();return t.length>0?t:null}g(Se,"resolveGitBranch");async function et(e){let o=await y(),t=w(o),r=await R(o,t),n=typeof e.path=="string"?e.path:typeof e.dir=="string"?e.dir:null,i=U.resolve(n&&n.trim().length>0?n.trim():"."),a=U.join(i,".git");if(!W(a))throw new Error(`git repo not found at ${i} (missing .git)`);let s=await F(i,"origin");if(!s)throw new Error("origin remote not set; run `openpond repo create` first");z(s);let c=(typeof e.branch=="string"?e.branch.trim():"")||await Se(i);if(!c)throw new Error("unable to resolve git branch; pass --branch");let d;try{d=D(s,r)}catch{throw new Error("origin remote must be https for tokenized pushes")}let u=v(e.keepTokenRemote)||v(e.token)||v(e.setRemoteToken),l=s.includes("x-access-token:"),m=!u&&!l?s:null,h=process.env.GIT_TERMINAL_PROMPT;process.env.GIT_TERMINAL_PROMPT="0";try{if(!l){let p=await B("git",["remote","set-url","origin",d],{cwd:i});if(p.code!==0)throw new Error(`git remote set-url failed: ${j(p.stderr.trim()||p.stdout.trim()||"unknown error")}`)}if((await B("git",["push","-u","origin",c],{cwd:i,inherit:!0})).code!==0)throw new Error("git push failed")}finally{m&&await B("git",["remote","set-url","origin",m],{cwd:i}).catch(()=>null),h===void 0?delete process.env.GIT_TERMINAL_PROMPT:process.env.GIT_TERMINAL_PROMPT=h}}g(et,"runRepoPush");async function tt(e){if(e.length===0)throw new Error("usage: opentool <init|validate|build> [args]");let o=process.platform==="win32"?"npx.cmd":"npx";if((await B(o,["opentool",...e],{inherit:!0})).code!==0)throw new Error("opentool command failed")}g(tt,"runOpentool");async function nt(){let e="openpond",o=Z(),t=await te(e),r=`npm i -g ${e}@${t}`,n=ee(o,t);if(n===0){console.log(`${e} is up to date (${o})`);return}if(n===-1){console.log(`Update available: ${o} -> ${t}`),console.log(`Run: ${r}`);return}if(n===1){console.log(`Installed version (${o}) is newer than npm latest (${t}).`);return}if(o===t){console.log(`${e} is up to date (${o})`);return}console.log(`Installed: ${o}`),console.log(`Latest: ${t}`),console.log(`Run: ${r}`)}g(nt,"runCheckUpdate");export{Ge as a,je as b,ze as c,He as d,Fe as e,Ve as f,We as g,qe as h,Ye as i,Qe as j,Xe as k,Ze as l,Se as m,et as n,tt as o,nt as p};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{e as g,g as $,h as O,i as C}from"./chunk-JKMPJFMN.js";import{a as w}from"./chunk-3M53YXEI.js";import{a as r}from"./chunk-FTQLQJQV.js";var L=Symbol("openpondCliOptionValues"),a=class extends Error{static{r(this,"CliUsageError")}exitCode=2;constructor(t){super(t),this.name="CliUsageError"}},K=new Set(["maxOutputBytes","timeoutSec"]);function k(n){let t=[...n],o="",i={},e={},u=[];for(;t.length>0;){let s=t.shift();if(s==="--"){u.push(...t);break}if(s.startsWith("--")){let f=s.indexOf("="),c=f>=0?s.slice(2,f):s.slice(2),p=N(c),d=f>=0?s.slice(f+1):P(t,p,o);h(i,e,p,d,o)}else _(s)?y(s,t,i,e):o?u.push(s):o=s}return Object.defineProperty(i,L,{value:e,enumerable:!1,configurable:!1,writable:!1}),V(o,i),{command:o,options:i,rest:u}}r(k,"parseArgs");function N(n){return n.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}r(N,"normalizeCliOptionKey");function _(n){return/^-[^-].*/.test(n)&&!S(n)}r(_,"isShortOptionToken");function y(n,t,o,i){let e=n.slice(1);if(!e)return;let u=e.indexOf("="),s=u>=0?e.slice(0,u):e,f=u>=0?e.slice(u+1):null;if(s.length!==1){for(let d of s){let m=g[d];if(!m)throw new a(`unknown short option -${d}`);if(C(m)!=="boolean")throw new a(`short option -${d} requires its own value`);h(o,i,m,"true")}return}let c=g[s];if(!c)throw new a(`unknown short option -${s}`);let p=f??P(t,c);h(o,i,c,p)}r(y,"parseShortOptionToken");function P(n,t,o){let i=I(t,o);if(i==="boolean")return n[0]&&x(n[0])?n.shift():"true";if(i){let e=n.shift();if(e===void 0||R(e)&&!S(e))throw e!==void 0&&n.unshift(e),new a(`${l(t)} must be ${b(i)}`);return e}return n[0]&&!n[0].startsWith("--")?n.shift():"true"}r(P,"readOptionValue");function h(n,t,o,i,e){T(o,i,e),n[o]=i,(t[o]??=[]).push(i)}r(h,"setParsedOption");function T(n,t,o){let i=I(n,o);if(i){if(i==="boolean"){if(!x(t))throw new a(`${l(n)} must be a boolean`);return}if(t.trim().length===0||t==="true")throw new a(`${l(n)} must be ${b(i)}`);if(i==="number"||i==="integer"){let e=Number(t);if(!Number.isFinite(e))throw new a(`${l(n)} must be ${b(i)}`);if(i==="integer"&&!Number.isInteger(e))throw new a(`${l(n)} must be an integer`);if(i==="integer"&&K.has(n)&&e<=0)throw new a(`${l(n)} must be a positive integer`);return}if(i==="json")try{w(t,l(n))}catch(e){throw new a(e instanceof Error?e.message:String(e))}}}r(T,"validateParsedOptionValue");function I(n,t){return t?O(t,n):C(n)}r(I,"typedOptionKind");function l(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}r(l,"cliOptionLabel");function E(n){return n==="json"?"JSON value":n}r(E,"optionKindLabel");function b(n){let t=E(n);return/^[aeiou]/i.test(t)?`an ${t}`:`a ${t}`}r(b,"optionKindPhrase");function x(n){return/^(true|false|1|0|yes|no)$/i.test(n)}r(x,"isBooleanLiteral");function R(n){return n.startsWith("-")&&n!=="-"}r(R,"isOptionLike");function S(n){return/^-\d+(?:\.\d+)?$/.test(n)}r(S,"isNegativeNumber");function V(n,t){let o=n?$(n):null;for(let i of Object.keys(t))if(!O(n,i)){let e=l(i),u=o?` for ${o.name}`:"";throw new a(`unknown option --${e}${u}`)}}r(V,"validateCommandOptions");export{a,k as b};
2
+ import{e as g,g as $,h as O,i as C}from"./chunk-JFR34MIK.js";import{a as w}from"./chunk-3M53YXEI.js";import{a as r}from"./chunk-FTQLQJQV.js";var L=Symbol("openpondCliOptionValues"),a=class extends Error{static{r(this,"CliUsageError")}exitCode=2;constructor(t){super(t),this.name="CliUsageError"}},K=new Set(["maxOutputBytes","timeoutSec"]);function k(n){let t=[...n],o="",i={},e={},u=[];for(;t.length>0;){let s=t.shift();if(s==="--"){u.push(...t);break}if(s.startsWith("--")){let f=s.indexOf("="),c=f>=0?s.slice(2,f):s.slice(2),p=N(c),d=f>=0?s.slice(f+1):P(t,p,o);h(i,e,p,d,o)}else _(s)?y(s,t,i,e):o?u.push(s):o=s}return Object.defineProperty(i,L,{value:e,enumerable:!1,configurable:!1,writable:!1}),V(o,i),{command:o,options:i,rest:u}}r(k,"parseArgs");function N(n){return n.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}r(N,"normalizeCliOptionKey");function _(n){return/^-[^-].*/.test(n)&&!S(n)}r(_,"isShortOptionToken");function y(n,t,o,i){let e=n.slice(1);if(!e)return;let u=e.indexOf("="),s=u>=0?e.slice(0,u):e,f=u>=0?e.slice(u+1):null;if(s.length!==1){for(let d of s){let m=g[d];if(!m)throw new a(`unknown short option -${d}`);if(C(m)!=="boolean")throw new a(`short option -${d} requires its own value`);h(o,i,m,"true")}return}let c=g[s];if(!c)throw new a(`unknown short option -${s}`);let p=f??P(t,c);h(o,i,c,p)}r(y,"parseShortOptionToken");function P(n,t,o){let i=I(t,o);if(i==="boolean")return n[0]&&x(n[0])?n.shift():"true";if(i){let e=n.shift();if(e===void 0||R(e)&&!S(e))throw e!==void 0&&n.unshift(e),new a(`${l(t)} must be ${b(i)}`);return e}return n[0]&&!n[0].startsWith("--")?n.shift():"true"}r(P,"readOptionValue");function h(n,t,o,i,e){T(o,i,e),n[o]=i,(t[o]??=[]).push(i)}r(h,"setParsedOption");function T(n,t,o){let i=I(n,o);if(i){if(i==="boolean"){if(!x(t))throw new a(`${l(n)} must be a boolean`);return}if(t.trim().length===0||t==="true")throw new a(`${l(n)} must be ${b(i)}`);if(i==="number"||i==="integer"){let e=Number(t);if(!Number.isFinite(e))throw new a(`${l(n)} must be ${b(i)}`);if(i==="integer"&&!Number.isInteger(e))throw new a(`${l(n)} must be an integer`);if(i==="integer"&&K.has(n)&&e<=0)throw new a(`${l(n)} must be a positive integer`);return}if(i==="json")try{w(t,l(n))}catch(e){throw new a(e instanceof Error?e.message:String(e))}}}r(T,"validateParsedOptionValue");function I(n,t){return t?O(t,n):C(n)}r(I,"typedOptionKind");function l(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}r(l,"cliOptionLabel");function E(n){return n==="json"?"JSON value":n}r(E,"optionKindLabel");function b(n){let t=E(n);return/^[aeiou]/i.test(t)?`an ${t}`:`a ${t}`}r(b,"optionKindPhrase");function x(n){return/^(true|false|1|0|yes|no)$/i.test(n)}r(x,"isBooleanLiteral");function R(n){return n.startsWith("-")&&n!=="-"}r(R,"isOptionLike");function S(n){return/^-\d+(?:\.\d+)?$/.test(n)}r(S,"isNegativeNumber");function V(n,t){let o=n?$(n):null;for(let i of Object.keys(t))if(!O(n,i)){let e=l(i),u=o?` for ${o.name}`:"";throw new a(`unknown option --${e}${u}`)}}r(V,"validateCommandOptions");export{a,k as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{i as s}from"./chunk-XRV4WLI7.js";import{a as i}from"./chunk-GLUWATL5.js";import{a as n}from"./chunk-FTQLQJQV.js";import{stdin as a,stdout as c}from"node:process";import{createInterface as l}from"node:readline/promises";var p=`${i}/settings/api-keys`;function u(e){let t=process.env.OPENPOND_API_KEY?.trim();if(t)return t;let r=e.apiKey?.trim();if(r)return r;let o=e.token?.trim();return o&&o.startsWith("opk_")?o:null}n(u,"resolveApiKey");async function P(){if(!a.isTTY||!c.isTTY)throw new Error("OpenPond API key is required in non-interactive mode. Set OPENPOND_API_KEY or run `openpond login` in a terminal.");console.log("Open the OpenPond UI to create an API key:"),console.log(p);let e=l({input:a,output:c});try{let t=(await e.question("Paste your OpenPond API key: ")).trim();if(!t)throw new Error("API key is required");return t.startsWith("opk_")||console.log("warning: API keys usually start with opk_."),t}finally{e.close()}}n(P,"promptForApiKey");async function A(e,t){let r=u(e);if(r)return r;let o=await P();return await s({apiKey:o,baseUrl:t,activeProfile:e.activeProfile}),console.log("Saved account credentials to the encrypted OpenPond credential store."),o}n(A,"ensureApiKey");export{u as a,P as b,A as c};
2
+ import{i as s}from"./chunk-QPZNN5Q3.js";import{a as i}from"./chunk-GLUWATL5.js";import{a as n}from"./chunk-FTQLQJQV.js";import{stdin as a,stdout as c}from"node:process";import{createInterface as l}from"node:readline/promises";var p=`${i}/settings/api-keys`;function u(e){let t=process.env.OPENPOND_API_KEY?.trim();if(t)return t;let r=e.apiKey?.trim();if(r)return r;let o=e.token?.trim();return o&&o.startsWith("opk_")?o:null}n(u,"resolveApiKey");async function P(){if(!a.isTTY||!c.isTTY)throw new Error("OpenPond API key is required in non-interactive mode. Set OPENPOND_API_KEY or run `openpond login` in a terminal.");console.log("Open the OpenPond UI to create an API key:"),console.log(p);let e=l({input:a,output:c});try{let t=(await e.question("Paste your OpenPond API key: ")).trim();if(!t)throw new Error("API key is required");return t.startsWith("opk_")||console.log("warning: API keys usually start with opk_."),t}finally{e.close()}}n(P,"promptForApiKey");async function A(e,t){let r=u(e);if(r)return r;let o=await P();return await s({apiKey:o,baseUrl:t,activeProfile:e.activeProfile}),console.log("Saved account credentials to the encrypted OpenPond credential store."),o}n(A,"ensureApiKey");export{u as a,P as b,A as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as v,b as I}from"./chunk-GLUWATL5.js";import{Pa as L,Qa as E}from"./chunk-F4WS5QIT.js";import{f as w}from"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";var T=class extends Error{constructor(t,e){super(`API request timed out after ${t}ms: ${e}`);this.timeoutMs=t;this.requestUrl=e;this.name="ApiTimeoutError"}timeoutMs;requestUrl;static{a(this,"ApiTimeoutError")}code="OPENPOND_API_TIMEOUT"},S=class extends Error{constructor(t,e){super(`API response exceeded ${t} bytes: ${e}`);this.maximumBytes=t;this.requestUrl=e;this.name="ApiResponseTooLargeError"}maximumBytes;requestUrl;static{a(this,"ApiResponseTooLargeError")}code="OPENPOND_API_RESPONSE_TOO_LARGE"},O=class extends Error{constructor(t,e,s,r=null){let c=r||e;super(`${s} failed: ${t}${c?` ${c}`:""}`);this.status=t;this.apiMessage=r;this.name="OpenPondApiError",this.code=e||"OPENPOND_API_ERROR"}status;apiMessage;static{a(this,"OpenPondApiError")}code};async function i(o,n,t,e={}){let{timeoutMs:s=3e4,maxResponseBytes:r=8388608,explicitBearerAuth:c=!1,...p}=e,d=`${o}${t}`,m=new Headers(p.headers);m.set("Content-Type","application/json");let g=c?void 0:process.env.OPENPOND_API_KEY,h=n?.trim()||"",u=!c&&h.startsWith("opk_"),x=g||(u?h:null);x&&!m.has("openpond-api-key")&&m.set("openpond-api-key",x),n?m.set("Authorization",u?`ApiKey ${h}`:`Bearer ${n}`):g&&!m.has("Authorization")&&m.set("Authorization",`ApiKey ${g}`);let y=new AbortController,f=new T(s,d),R=s>0?setTimeout(()=>y.abort(f),s):null;R?.unref?.();let P=C(p.signal,y.signal,s),k=a(()=>{R&&clearTimeout(R)},"cleanup");try{let A=await fetch(d,{...p,headers:m,signal:P});return q(A,{cleanup:k,maximumBytes:r,requestUrl:d,timeoutController:y,timeoutError:f})}catch(A){throw k(),y.signal.aborted?f:A}}a(i,"apiFetch");async function l(o,n){let t;try{let e=await o.text();t=e?JSON.parse(e):{}}catch(e){if(e instanceof T||e instanceof S)throw e;t={}}if(!o.ok){let e=typeof t.error=="string"?t.error:null,s=typeof t.message=="string"?t.message:null;throw new O(o.status,e,n,s)}return t}a(l,"readApiJson");function q(o,n){if(!o.body)return n.cleanup(),o;let t=Number(o.headers.get("content-length"));if(n.maximumBytes>0&&Number.isFinite(t)&&t>n.maximumBytes)throw n.cleanup(),o.body.cancel(),new S(n.maximumBytes,n.requestUrl);let e=o.body.getReader(),s=0,r=new ReadableStream({async pull(c){try{let p=await e.read();if(p.done){n.cleanup(),c.close();return}if(s+=p.value.byteLength,n.maximumBytes>0&&s>n.maximumBytes){n.cleanup(),await e.cancel(),c.error(new S(n.maximumBytes,n.requestUrl));return}c.enqueue(p.value)}catch(p){n.cleanup(),c.error(n.timeoutController.signal.aborted?n.timeoutError:p)}},async cancel(c){n.cleanup(),await e.cancel(c)}});return new Response(r,{headers:o.headers,status:o.status,statusText:o.statusText})}a(q,"boundedResponse");function C(o,n,t){return t<=0?o??void 0:o?AbortSignal.any([o,n]):n}a(C,"composedSignal");async function U(o,n,t,e,s){let r=await i(o,n,`/v4/apps/${t}/commits`,{method:"POST",body:JSON.stringify({files:e,message:s})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Commit failed: ${r.status} ${c}`)}return await r.json()}a(U,"commitFiles");async function _(o,n,t,e){let s=e?.environment??"production",r=await i(o,n,`/v4/apps/${t}/deployments`,{method:"POST",body:JSON.stringify({environment:s,...e?.commitSha?{commitSha:e.commitSha}:{},...e?.branch?{branch:e.branch}:{}})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Deploy failed: ${r.status} ${c}`)}return await r.json()}a(_,"deployApp");async function j(o,n,t,e){let s=await i(o,n,`/v4/apps/${encodeURIComponent(t)}/deployments/promote-preview`,{method:"POST",body:JSON.stringify(e)});return l(s,"Preview promotion")}a(j,"promotePreviewToProduction");async function B(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/lifecycle/start`,{method:"POST",body:JSON.stringify(e)});return l(s,"App lifecycle start")}a(B,"startAppLifecycle");async function G(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/logs`,{method:"GET"});if(!e.ok){let c=await e.text().catch(()=>"");throw new Error(`Deployment logs failed: ${e.status} ${c}`)}let s=await e.json().catch(()=>({}));return(Array.isArray(s.logs)?s.logs:[]).map(c=>{let p=typeof c.createdAt=="string"?c.createdAt:c.createdAt instanceof Date?c.createdAt.toISOString():new Date().toISOString();return{id:typeof c.id=="string"?c.id:`${Math.random()}`,type:typeof c.type=="string"?c.type:void 0,message:typeof c.message=="string"?c.message:"",createdAt:p}})}a(G,"getDeploymentLogs");async function J(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/status`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment status failed: ${e.status} ${r}`)}return{status:(await e.json().catch(()=>({}))).deployment?.status}}a(J,"getDeploymentStatus");async function M(o,n,t,e){let s=new URLSearchParams;e?.status&&e.status.length>0&&s.set("status",e.status.join(",")),e?.createdAfter&&s.set("createdAfter",e.createdAfter),e?.branch&&s.set("branch",e.branch);let r=s.toString(),c=await i(o,n,`/apps/${t}/deployments/latest${r?`?${r}`:""}`,{method:"GET"});if(!c.ok){let d=await c.text().catch(()=>"");throw new Error(`Latest deployment lookup failed: ${c.status} ${d}`)}let p=await c.json().catch(()=>({}));return p.deployment?{id:p.deployment.id,status:p.deployment.status}:null}a(M,"getLatestDeploymentForApp");async function F(o,n,t){let e=await i(o,n,`/apps/deployments/${t}`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment fetch failed: ${e.status} ${r}`)}return(await e.json().catch(()=>({}))).deployment??null}a(F,"getDeploymentDetail");var H=new URL(I).hostname,V=new URL(v).hostname;async function ae(o,n,t){let e=new URLSearchParams;t?.handle&&e.set("handle",t.handle),typeof t?.limit=="number"&&Number.isFinite(t.limit)&&e.set("limit",String(Math.max(1,Math.floor(t.limit)))),typeof t?.offset=="number"&&Number.isFinite(t.offset)&&e.set("offset",String(Math.max(0,Math.floor(t.offset)))),typeof t?.includeScheduled=="boolean"&&e.set("includeScheduled",t.includeScheduled?"true":"false");let s=e.toString(),r=await i(o,n,`/apps/list${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let p=await r.text().catch(()=>"");throw new Error(`Apps list failed: ${r.status} ${p}`)}let c=await r.json().catch(()=>({}));return Array.isArray(c.apps)?c.apps:[]}a(ae,"listApps");async function ie(o,n,t){let e=await i(o,n,"/api/projects/local",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Create project failed: ${e.status} ${s}`)}return await e.json()}a(ie,"createLocalProject");async function ce(o,n,t){let e=await i(o,n,"/apps/repo/create",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Repo create failed: ${e.status} ${s}`)}return await e.json()}a(ce,"createRepo");async function pe(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/code-visibility`,{method:"PATCH",body:JSON.stringify({codeVisibility:e})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Code visibility update failed: ${s.status} ${r}`)}return await s.json()}a(pe,"updateAppCodeVisibility");async function ue(o,n,t,e){let s=await i(o,n,"/v4/apps/headless",{method:"POST",body:JSON.stringify({items:t,...e?{teamId:e}:{}})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Headless create failed: ${s.status} ${r}`)}return await s.json()}a(ue,"createHeadlessApps");async function le(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/status`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template status failed: ${e.status} ${s}`)}return await e.json()}a(le,"getTemplateStatus");async function de(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/branches`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template branches failed: ${e.status} ${s}`)}return await e.json()}a(de,"listTemplateBranches");async function me(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/template/deploy-latest`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Template deploy failed: ${s.status} ${r}`)}return await s.json()}a(me,"deployLatestTemplate");async function ge(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/environment`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Environment update failed: ${s.status} ${r}`)}return await s.json()}a(ge,"updateAppEnvironment");async function he(o,n,t){let e=await i(o,n,`/v4/apps/${t}/environment`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Environment get failed: ${e.status} ${s}`)}return await e.json()}a(he,"getAppEnvironment");async function ye(o,n){let t=await i(o,n,"/api/tools/manifest",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Manifest fetch failed: ${t.status} ${e}`)}return await t.json()}a(ye,"fetchToolManifest");async function fe(o,n){let t=await i(o,n,"/apps/tools",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Tools lookup failed: ${t.status} ${e}`)}return await t.json()}a(fe,"listUserTools");async function Re(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Schedules lookup failed: ${e.status} ${r}`)}let s=await e.json().catch(()=>({}));return{schedules:Array.isArray(s.schedules)?s.schedules:[]}}a(Re,"listAppSchedules");async function we(o,n,t={}){let e=new URLSearchParams;t.domain&&e.set("domain",t.domain),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion),typeof t.limit=="number"&&e.set("limit",String(t.limit));for(let c of t.tags??[])e.append("tag",c);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe list")}a(we,"listOpenToolRecipes");async function Se(o,n,t){let e=await i(o,n,"/v1/opentool/recipes/search",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool recipe search")}a(Se,"searchOpenToolRecipes");async function xe(o,n,t){let e=new URLSearchParams;typeof t.includeExamples=="boolean"&&e.set("includeExamples",String(t.includeExamples)),typeof t.includeTests=="boolean"&&e.set("includeTests",String(t.includeTests)),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes/${encodeURIComponent(t.id)}${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe get")}a(xe,"getOpenToolRecipe");async function Te(o,n,t){let e=await i(o,n,"/v1/opentool/rules",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool rules get")}a(Te,"getOpenToolRules");function b(o){let n=new URLSearchParams;typeof o=="number"&&Number.isFinite(o)&&n.set("limit",String(Math.max(1,Math.floor(o))));let t=n.toString();return t?`?${t}`:""}a(b,"buildLimitQuery");function D(o){if(Array.isArray(o))return o;if(!o||typeof o!="object")return[];let n=o;return Array.isArray(n.logs)?n.logs:Array.isArray(n.runs)?n.runs:Array.isArray(n.scheduleRuns)?n.scheduleRuns:Array.isArray(n.items)?n.items:[]}a(D,"normalizeScheduleExecutionLogs");async function Pe(o,n,t,e){let s={...e?.preferredScheduleId?{preferredScheduleId:e.preferredScheduleId}:{},...e?.scheduleId?{scheduleId:e.scheduleId}:{},...e?.startAt?{startAt:e.startAt}:{},...e&&"endAt"in e?{endAt:e.endAt??null}:{}},r=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/start`,{method:"POST",body:JSON.stringify(s)});return l(r,"Schedule start")}a(Pe,"startAppSchedules");async function Ae(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/stop`,{method:"POST",body:JSON.stringify({})});return l(e,"Schedule stop")}a(Ae,"stopAppSchedules");async function Ee(o,n){let t=await i(o,n,"/apps/schedules/current/stop",{method:"POST",body:JSON.stringify({})});return l(t,"Current schedule stop")}a(Ee,"stopCurrentAppSchedules");async function Oe(o,n,t){let e=await i(o,n,"/v1/schedules/run",{method:"POST",body:JSON.stringify({scheduleId:t.scheduleId})});return l(e,"Schedule run")}a(Oe,"runScheduleNow");async function be(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/${encodeURIComponent(e)}`,{method:"DELETE"});return l(s,"Schedule delete")}a(be,"deleteOrArchiveSchedule");async function $e(o,n,t,e){let s=await i(o,n,`/v1/schedules/${encodeURIComponent(t)}/execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Schedule execution logs");return{logs:D(r)}}a($e,"listScheduleExecutionLogs");async function ke(o,n,t,e){let s=await i(o,n,`/v1/deployments/${encodeURIComponent(t)}/schedule-execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Deployment schedule execution logs");return{logs:D(r)}}a(ke,"listDeploymentScheduleExecutionLogs");async function Le(o,n,t){let e=await i(o,n,`/v1/schedule-execution-logs/${encodeURIComponent(t)}`,{method:"GET"});return l(e,"Schedule execution log")}a(Le,"getScheduleExecutionLog");async function ve(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/execution-timeline${b(e?.limit)}`,{method:"GET"});return l(s,"App execution timeline")}a(ve,"getAppExecutionTimeline");async function Ie(o,n,t){return i(o,n,"/apps/agent/create",{method:"POST",body:JSON.stringify(t)})}a(Ie,"createAgentFromPrompt");async function De(o,n,t){let e=new URLSearchParams;t?.appId&&e.set("appId",t.appId);let s=e.toString(),r=await i(o,n,`/apps/performance${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Performance lookup failed: ${r.status} ${c}`)}return await r.json()}a(De,"getUserPerformance");async function Ne(o,n,t){let e=new URLSearchParams({appId:t}),s=await i(o,n,`/apps/summary?${e.toString()}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Summary lookup failed: ${s.status} ${r}`)}return await s.json()}a(Ne,"getAppRuntimeSummary");async function z(o,n){let t=await i(o,n,"/v1/account",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Account lookup failed: ${t.status} ${e}`)}return await t.json()}a(z,"getOpenPondAccount");async function qe(o,n){let t=new Date().toISOString(),e=Date.now(),s=o.replace(/\/$/,"");try{let r=await i(s,null,"/health",{method:"GET",headers:{Accept:"application/json"}}),c=Date.now()-e,p=await r.json().catch(()=>({})),d=null,m=null;if(n?.trim())try{let g=await z(s,n);d=!0,m=g.account}catch{d=!1}return{reachable:r.ok,authenticated:d,apiBase:s,latencyMs:c,status:r.status,service:typeof p.service=="string"?p.service:null,checkedAt:t,account:m,...r.ok?{}:{error:r.statusText||`HTTP ${r.status}`}}}catch(r){return{reachable:!1,authenticated:n?.trim()?!1:null,apiBase:s,latencyMs:Date.now()-e,status:null,service:null,checkedAt:t,error:r instanceof Error?r.message:String(r)}}}a(qe,"checkOpenPondApiHealth");async function Ce(o,n,t){let e=await i(o,n,"/apps/assistant/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Assistant run failed: ${e.status} ${s}`)}return await e.json()}a(Ce,"runAssistantMode");async function Ue(o,n,t){let e=await i(o,n,"/apps/agent/digest",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Agent digest failed: ${e.status} ${s}`)}return await e.json()}a(Ue,"postAgentDigest");async function _e(o,n,t){let e=await i(o,n,"/apps/tools/execute",{method:"POST",body:JSON.stringify(t)}),s=await e.text().catch(()=>""),r=null;try{r=s?JSON.parse(s):null}catch{r=s}return e.ok?{ok:!0,status:e.status,data:r}:{ok:!1,status:e.status,error:r&&typeof r=="object"&&"error"in r?String(r.error):s||e.statusText}}a(_e,"executeUserTool");async function je(o,n,t){let e=await i(o,n,"/apps/backtests/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Backtest run failed: ${e.status} ${s}`)}return await e.json()}a(je,"submitBacktestRun");async function Be(o,n,t){let e=t.query&&Object.keys(t.query).length>0?`?${new URLSearchParams(t.query).toString()}`:"",s=await i(o,n,`/apps/backtests/tx${e}`,{method:t.method,body:t.method==="POST"&&t.body!==void 0?JSON.stringify(t.body):void 0});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtests request failed: ${s.status} ${r}`)}return await s.json()}a(Be,"submitBacktestTx");async function Ge(o,n,t){let e=new URLSearchParams(t).toString(),s=await i(o,n,`/apps/backtests/detail?${e}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtest detail failed: ${s.status} ${r}`)}return await s.json()}a(Ge,"submitBacktestDetail");function K(o){let n=o.trim().replace(/^\/+/,"");return encodeURIComponent(n||"tool")}a(K,"normalizeToolPathSegment");function W(o){let n=o.replace(/\/$/,""),t=process.env.OPENPOND_TOOL_URL;if(t)return t.replace(/\/$/,"");try{let e=new URL(n),s=e.hostname.toLowerCase(),r=s==="apps.openpond.live"?null:s===H||s===V||s==="openpond.live"||s==="www.openpond.live"?"https://apps.openpond.live":null;if(r)return r;let c=s==="localhost"||s==="127.0.0.1",p=e.port||(e.protocol==="https:"?"443":"80");if(c&&p==="3000")return n}catch{}return n}a(W,"resolveWorkerBaseUrl");async function Je(o,n,t){let e=W(o),s=K(t.toolName),c=`${t.deploymentId?`/${t.appId}/deployments/${t.deploymentId}`:`/${t.appId}`}/${s}`,p=new Headers(t.headers||{}),d=t.method??"POST",m=t.body===void 0||d==="GET"?void 0:JSON.stringify(t.body),g=await i(e,n,c,{method:d,body:m,headers:p}),h=await g.text().catch(()=>""),u=null;try{u=h?JSON.parse(h):null}catch{u=h}let x=u&&typeof u=="object"&&"ok"in u?!!u.ok:!0,y=g.ok&&x,f=u&&typeof u=="object"&&"status"in u&&Number(u.status)||g.status,R=u&&typeof u=="object"&&"error"in u?String(u.error):g.ok?void 0:h||g.statusText,P=u&&typeof u=="object"&&"data"in u?u.data:u;return{ok:y,status:f,data:P,error:R}}a(Je,"executeHostedTool");import{createHash as Y}from"node:crypto";var X=3600*1e3;function $(o){return Y("sha256").update(JSON.stringify([o.apiBase.replace(/\/$/,""),o.apiKey.trim()])).digest("hex")}a($,"buildCacheKey");async function N(o,n){let t=await L(w(),o,$(n),{allowStale:!0});return!t||Date.now()-Date.parse(t.updatedAt)>=(n.ttlMs??X)?null:t.payload}a(N,"cached");async function ot(o){return N("cloud.apps",o)}a(ot,"getCachedApps");async function st(o){await E(w(),"cloud.apps",$(o),o.apps)}a(st,"setCachedApps");async function rt(o){return N("cloud.tools",o)}a(rt,"getCachedTools");async function at(o){await E(w(),"cloud.tools",$(o),o.tools)}a(at,"setCachedTools");var pt=["openpond-generic-v1","openpond-work-v1","openpond-coding-core-v1","openpond-agent-harness-v1"];export{i as a,U as b,_ as c,j as d,B as e,G as f,J as g,M as h,F as i,ae as j,ie as k,ce as l,pe as m,ue as n,le as o,de as p,me as q,ge as r,he as s,ye as t,fe as u,Re as v,we as w,Se as x,xe as y,Te as z,Pe as A,Ae as B,Ee as C,Oe as D,be as E,$e as F,ke as G,Le as H,ve as I,Ie as J,De as K,Ne as L,z as M,qe as N,Ce as O,Ue as P,_e as Q,je as R,Be as S,Ge as T,W as U,Je as V,X as W,ot as X,st as Y,rt as Z,at as _,pt as $};
2
+ import{a as v,b as I}from"./chunk-GLUWATL5.js";import{Pa as L,Qa as E}from"./chunk-IFP6W4OW.js";import{f as w}from"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";var T=class extends Error{constructor(t,e){super(`API request timed out after ${t}ms: ${e}`);this.timeoutMs=t;this.requestUrl=e;this.name="ApiTimeoutError"}timeoutMs;requestUrl;static{a(this,"ApiTimeoutError")}code="OPENPOND_API_TIMEOUT"},S=class extends Error{constructor(t,e){super(`API response exceeded ${t} bytes: ${e}`);this.maximumBytes=t;this.requestUrl=e;this.name="ApiResponseTooLargeError"}maximumBytes;requestUrl;static{a(this,"ApiResponseTooLargeError")}code="OPENPOND_API_RESPONSE_TOO_LARGE"},O=class extends Error{constructor(t,e,s,r=null){let c=r||e;super(`${s} failed: ${t}${c?` ${c}`:""}`);this.status=t;this.apiMessage=r;this.name="OpenPondApiError",this.code=e||"OPENPOND_API_ERROR"}status;apiMessage;static{a(this,"OpenPondApiError")}code};async function i(o,n,t,e={}){let{timeoutMs:s=3e4,maxResponseBytes:r=8388608,explicitBearerAuth:c=!1,...p}=e,d=`${o}${t}`,m=new Headers(p.headers);m.set("Content-Type","application/json");let g=c?void 0:process.env.OPENPOND_API_KEY,h=n?.trim()||"",u=!c&&h.startsWith("opk_"),x=g||(u?h:null);x&&!m.has("openpond-api-key")&&m.set("openpond-api-key",x),n?m.set("Authorization",u?`ApiKey ${h}`:`Bearer ${n}`):g&&!m.has("Authorization")&&m.set("Authorization",`ApiKey ${g}`);let y=new AbortController,f=new T(s,d),R=s>0?setTimeout(()=>y.abort(f),s):null;R?.unref?.();let P=U(p.signal,y.signal,s),k=a(()=>{R&&clearTimeout(R)},"cleanup");try{let A=await fetch(d,{...p,headers:m,signal:P});return C(A,{cleanup:k,maximumBytes:r,requestUrl:d,timeoutController:y,timeoutError:f})}catch(A){throw k(),y.signal.aborted?f:A}}a(i,"apiFetch");async function l(o,n){let t;try{let e=await o.text();t=e?JSON.parse(e):{}}catch(e){if(e instanceof T||e instanceof S)throw e;t={}}if(!o.ok){let e=typeof t.error=="string"?t.error:null,s=typeof t.message=="string"?t.message:null;throw new O(o.status,e,n,s)}return t}a(l,"readApiJson");function C(o,n){if(!o.body)return n.cleanup(),o;let t=Number(o.headers.get("content-length"));if(n.maximumBytes>0&&Number.isFinite(t)&&t>n.maximumBytes)throw n.cleanup(),o.body.cancel(),new S(n.maximumBytes,n.requestUrl);let e=o.body.getReader(),s=0,r=new ReadableStream({async pull(c){try{let p=await e.read();if(p.done){n.cleanup(),c.close();return}if(s+=p.value.byteLength,n.maximumBytes>0&&s>n.maximumBytes){n.cleanup(),await e.cancel(),c.error(new S(n.maximumBytes,n.requestUrl));return}c.enqueue(p.value)}catch(p){n.cleanup(),c.error(n.timeoutController.signal.aborted?n.timeoutError:p)}},async cancel(c){n.cleanup(),await e.cancel(c)}});return new Response(r,{headers:o.headers,status:o.status,statusText:o.statusText})}a(C,"boundedResponse");function U(o,n,t){return t<=0?o??void 0:o?AbortSignal.any([o,n]):n}a(U,"composedSignal");async function _(o,n,t,e,s){let r=await i(o,n,`/v4/apps/${t}/commits`,{method:"POST",body:JSON.stringify({files:e,message:s})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Commit failed: ${r.status} ${c}`)}return await r.json()}a(_,"commitFiles");async function j(o,n,t,e){let s=e?.environment??"production",r=await i(o,n,`/v4/apps/${t}/deployments`,{method:"POST",body:JSON.stringify({environment:s,...e?.commitSha?{commitSha:e.commitSha}:{},...e?.branch?{branch:e.branch}:{}})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Deploy failed: ${r.status} ${c}`)}return await r.json()}a(j,"deployApp");async function B(o,n,t,e){let s=await i(o,n,`/v4/apps/${encodeURIComponent(t)}/deployments/promote-preview`,{method:"POST",body:JSON.stringify(e)});return l(s,"Preview promotion")}a(B,"promotePreviewToProduction");async function G(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/lifecycle/start`,{method:"POST",body:JSON.stringify(e)});return l(s,"App lifecycle start")}a(G,"startAppLifecycle");async function J(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/logs`,{method:"GET"});if(!e.ok){let c=await e.text().catch(()=>"");throw new Error(`Deployment logs failed: ${e.status} ${c}`)}let s=await e.json().catch(()=>({}));return(Array.isArray(s.logs)?s.logs:[]).map(c=>{let p=typeof c.createdAt=="string"?c.createdAt:c.createdAt instanceof Date?c.createdAt.toISOString():new Date().toISOString();return{id:typeof c.id=="string"?c.id:`${Math.random()}`,type:typeof c.type=="string"?c.type:void 0,message:typeof c.message=="string"?c.message:"",createdAt:p}})}a(J,"getDeploymentLogs");async function M(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/status`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment status failed: ${e.status} ${r}`)}return{status:(await e.json().catch(()=>({}))).deployment?.status}}a(M,"getDeploymentStatus");async function F(o,n,t,e){let s=new URLSearchParams;e?.status&&e.status.length>0&&s.set("status",e.status.join(",")),e?.createdAfter&&s.set("createdAfter",e.createdAfter),e?.branch&&s.set("branch",e.branch);let r=s.toString(),c=await i(o,n,`/apps/${t}/deployments/latest${r?`?${r}`:""}`,{method:"GET"});if(!c.ok){let d=await c.text().catch(()=>"");throw new Error(`Latest deployment lookup failed: ${c.status} ${d}`)}let p=await c.json().catch(()=>({}));return p.deployment?{id:p.deployment.id,status:p.deployment.status}:null}a(F,"getLatestDeploymentForApp");async function H(o,n,t){let e=await i(o,n,`/apps/deployments/${t}`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment fetch failed: ${e.status} ${r}`)}return(await e.json().catch(()=>({}))).deployment??null}a(H,"getDeploymentDetail");var V=new URL(I).hostname,D=new URL(v).hostname;async function ae(o,n,t){let e=new URLSearchParams;t?.handle&&e.set("handle",t.handle),typeof t?.limit=="number"&&Number.isFinite(t.limit)&&e.set("limit",String(Math.max(1,Math.floor(t.limit)))),typeof t?.offset=="number"&&Number.isFinite(t.offset)&&e.set("offset",String(Math.max(0,Math.floor(t.offset)))),typeof t?.includeScheduled=="boolean"&&e.set("includeScheduled",t.includeScheduled?"true":"false");let s=e.toString(),r=await i(o,n,`/apps/list${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let p=await r.text().catch(()=>"");throw new Error(`Apps list failed: ${r.status} ${p}`)}let c=await r.json().catch(()=>({}));return Array.isArray(c.apps)?c.apps:[]}a(ae,"listApps");async function ie(o,n,t){let e=await i(o,n,"/api/projects/local",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Create project failed: ${e.status} ${s}`)}return await e.json()}a(ie,"createLocalProject");async function ce(o,n,t){let e=await i(o,n,"/apps/repo/create",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Repo create failed: ${e.status} ${s}`)}return await e.json()}a(ce,"createRepo");async function pe(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/code-visibility`,{method:"PATCH",body:JSON.stringify({codeVisibility:e})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Code visibility update failed: ${s.status} ${r}`)}return await s.json()}a(pe,"updateAppCodeVisibility");async function ue(o,n,t,e){let s=await i(o,n,"/v4/apps/headless",{method:"POST",body:JSON.stringify({items:t,...e?{teamId:e}:{}})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Headless create failed: ${s.status} ${r}`)}return await s.json()}a(ue,"createHeadlessApps");async function le(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/status`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template status failed: ${e.status} ${s}`)}return await e.json()}a(le,"getTemplateStatus");async function de(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/branches`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template branches failed: ${e.status} ${s}`)}return await e.json()}a(de,"listTemplateBranches");async function me(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/template/deploy-latest`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Template deploy failed: ${s.status} ${r}`)}return await s.json()}a(me,"deployLatestTemplate");async function ge(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/environment`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Environment update failed: ${s.status} ${r}`)}return await s.json()}a(ge,"updateAppEnvironment");async function he(o,n,t){let e=await i(o,n,`/v4/apps/${t}/environment`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Environment get failed: ${e.status} ${s}`)}return await e.json()}a(he,"getAppEnvironment");async function ye(o,n){let t=await i(o,n,"/api/tools/manifest",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Manifest fetch failed: ${t.status} ${e}`)}return await t.json()}a(ye,"fetchToolManifest");async function fe(o,n){let t=await i(o,n,"/apps/tools",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Tools lookup failed: ${t.status} ${e}`)}return await t.json()}a(fe,"listUserTools");async function Re(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Schedules lookup failed: ${e.status} ${r}`)}let s=await e.json().catch(()=>({}));return{schedules:Array.isArray(s.schedules)?s.schedules:[]}}a(Re,"listAppSchedules");async function we(o,n,t={}){let e=new URLSearchParams;t.domain&&e.set("domain",t.domain),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion),typeof t.limit=="number"&&e.set("limit",String(t.limit));for(let c of t.tags??[])e.append("tag",c);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe list")}a(we,"listOpenToolRecipes");async function Se(o,n,t){let e=await i(o,n,"/v1/opentool/recipes/search",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool recipe search")}a(Se,"searchOpenToolRecipes");async function xe(o,n,t){let e=new URLSearchParams;typeof t.includeExamples=="boolean"&&e.set("includeExamples",String(t.includeExamples)),typeof t.includeTests=="boolean"&&e.set("includeTests",String(t.includeTests)),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes/${encodeURIComponent(t.id)}${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe get")}a(xe,"getOpenToolRecipe");async function Te(o,n,t){let e=await i(o,n,"/v1/opentool/rules",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool rules get")}a(Te,"getOpenToolRules");function b(o){let n=new URLSearchParams;typeof o=="number"&&Number.isFinite(o)&&n.set("limit",String(Math.max(1,Math.floor(o))));let t=n.toString();return t?`?${t}`:""}a(b,"buildLimitQuery");function N(o){if(Array.isArray(o))return o;if(!o||typeof o!="object")return[];let n=o;return Array.isArray(n.logs)?n.logs:Array.isArray(n.runs)?n.runs:Array.isArray(n.scheduleRuns)?n.scheduleRuns:Array.isArray(n.items)?n.items:[]}a(N,"normalizeScheduleExecutionLogs");async function Pe(o,n,t,e){let s={...e?.preferredScheduleId?{preferredScheduleId:e.preferredScheduleId}:{},...e?.scheduleId?{scheduleId:e.scheduleId}:{},...e?.startAt?{startAt:e.startAt}:{},...e&&"endAt"in e?{endAt:e.endAt??null}:{}},r=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/start`,{method:"POST",body:JSON.stringify(s)});return l(r,"Schedule start")}a(Pe,"startAppSchedules");async function Ae(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/stop`,{method:"POST",body:JSON.stringify({})});return l(e,"Schedule stop")}a(Ae,"stopAppSchedules");async function Ee(o,n){let t=await i(o,n,"/apps/schedules/current/stop",{method:"POST",body:JSON.stringify({})});return l(t,"Current schedule stop")}a(Ee,"stopCurrentAppSchedules");async function Oe(o,n,t){let e=await i(o,n,"/v1/schedules/run",{method:"POST",body:JSON.stringify({scheduleId:t.scheduleId})});return l(e,"Schedule run")}a(Oe,"runScheduleNow");async function be(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/${encodeURIComponent(e)}`,{method:"DELETE"});return l(s,"Schedule delete")}a(be,"deleteOrArchiveSchedule");async function $e(o,n,t,e){let s=await i(o,n,`/v1/schedules/${encodeURIComponent(t)}/execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Schedule execution logs");return{logs:N(r)}}a($e,"listScheduleExecutionLogs");async function ke(o,n,t,e){let s=await i(o,n,`/v1/deployments/${encodeURIComponent(t)}/schedule-execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Deployment schedule execution logs");return{logs:N(r)}}a(ke,"listDeploymentScheduleExecutionLogs");async function Le(o,n,t){let e=await i(o,n,`/v1/schedule-execution-logs/${encodeURIComponent(t)}`,{method:"GET"});return l(e,"Schedule execution log")}a(Le,"getScheduleExecutionLog");async function ve(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/execution-timeline${b(e?.limit)}`,{method:"GET"});return l(s,"App execution timeline")}a(ve,"getAppExecutionTimeline");async function Ie(o,n,t){return i(o,n,"/apps/agent/create",{method:"POST",body:JSON.stringify(t)})}a(Ie,"createAgentFromPrompt");async function De(o,n,t){let e=new URLSearchParams;t?.appId&&e.set("appId",t.appId);let s=e.toString(),r=await i(o,n,`/apps/performance${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Performance lookup failed: ${r.status} ${c}`)}return await r.json()}a(De,"getUserPerformance");async function Ne(o,n,t){let e=new URLSearchParams({appId:t}),s=await i(o,n,`/apps/summary?${e.toString()}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Summary lookup failed: ${s.status} ${r}`)}return await s.json()}a(Ne,"getAppRuntimeSummary");async function z(o,n){let t=await i(o,n,"/v1/account",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Account lookup failed: ${t.status} ${e}`)}return await t.json()}a(z,"getOpenPondAccount");async function qe(o,n){let t=new Date().toISOString(),e=Date.now(),s=o.replace(/\/$/,"");try{let r=await i(s,null,"/health",{method:"GET",headers:{Accept:"application/json"}}),c=Date.now()-e,p=await r.json().catch(()=>({})),d=null,m=null;if(n?.trim())try{let g=await z(s,n);d=!0,m=g.account}catch{d=!1}return{reachable:r.ok,authenticated:d,apiBase:s,latencyMs:c,status:r.status,service:typeof p.service=="string"?p.service:null,checkedAt:t,account:m,...r.ok?{}:{error:r.statusText||`HTTP ${r.status}`}}}catch(r){return{reachable:!1,authenticated:n?.trim()?!1:null,apiBase:s,latencyMs:Date.now()-e,status:null,service:null,checkedAt:t,error:r instanceof Error?r.message:String(r)}}}a(qe,"checkOpenPondApiHealth");async function Ce(o,n,t){let e=await i(o,n,"/apps/assistant/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Assistant run failed: ${e.status} ${s}`)}return await e.json()}a(Ce,"runAssistantMode");async function Ue(o,n,t){let e=await i(o,n,"/apps/agent/digest",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Agent digest failed: ${e.status} ${s}`)}return await e.json()}a(Ue,"postAgentDigest");async function _e(o,n,t){let e=await i(o,n,"/apps/tools/execute",{method:"POST",body:JSON.stringify(t)}),s=await e.text().catch(()=>""),r=null;try{r=s?JSON.parse(s):null}catch{r=s}return e.ok?{ok:!0,status:e.status,data:r}:{ok:!1,status:e.status,error:r&&typeof r=="object"&&"error"in r?String(r.error):s||e.statusText}}a(_e,"executeUserTool");async function je(o,n,t){let e=await i(o,n,"/apps/backtests/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Backtest run failed: ${e.status} ${s}`)}return await e.json()}a(je,"submitBacktestRun");async function Be(o,n,t){let e=t.query&&Object.keys(t.query).length>0?`?${new URLSearchParams(t.query).toString()}`:"",s=await i(o,n,`/apps/backtests/tx${e}`,{method:t.method,body:t.method==="POST"&&t.body!==void 0?JSON.stringify(t.body):void 0});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtests request failed: ${s.status} ${r}`)}return await s.json()}a(Be,"submitBacktestTx");async function Ge(o,n,t){let e=new URLSearchParams(t).toString(),s=await i(o,n,`/apps/backtests/detail?${e}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtest detail failed: ${s.status} ${r}`)}return await s.json()}a(Ge,"submitBacktestDetail");function K(o){let n=o.trim().replace(/^\/+/,"");return encodeURIComponent(n||"tool")}a(K,"normalizeToolPathSegment");function W(o){let n=o.replace(/\/$/,""),t=process.env.OPENPOND_TOOL_URL;if(t)return t.replace(/\/$/,"");try{let e=new URL(n),s=e.hostname.toLowerCase(),r=s==="apps.openpond.live"?null:s===V||s===D||s===`www.${D}`||s==="openpond.live"||s==="www.openpond.live"?"https://apps.openpond.live":null;if(r)return r;let c=s==="localhost"||s==="127.0.0.1",p=e.port||(e.protocol==="https:"?"443":"80");if(c&&p==="3000")return n}catch{}return n}a(W,"resolveWorkerBaseUrl");async function Je(o,n,t){let e=W(o),s=K(t.toolName),c=`${t.deploymentId?`/${t.appId}/deployments/${t.deploymentId}`:`/${t.appId}`}/${s}`,p=new Headers(t.headers||{}),d=t.method??"POST",m=t.body===void 0||d==="GET"?void 0:JSON.stringify(t.body),g=await i(e,n,c,{method:d,body:m,headers:p}),h=await g.text().catch(()=>""),u=null;try{u=h?JSON.parse(h):null}catch{u=h}let x=u&&typeof u=="object"&&"ok"in u?!!u.ok:!0,y=g.ok&&x,f=u&&typeof u=="object"&&"status"in u&&Number(u.status)||g.status,R=u&&typeof u=="object"&&"error"in u?String(u.error):g.ok?void 0:h||g.statusText,P=u&&typeof u=="object"&&"data"in u?u.data:u;return{ok:y,status:f,data:P,error:R}}a(Je,"executeHostedTool");import{createHash as Y}from"node:crypto";var X=3600*1e3;function $(o){return Y("sha256").update(JSON.stringify([o.apiBase.replace(/\/$/,""),o.apiKey.trim()])).digest("hex")}a($,"buildCacheKey");async function q(o,n){let t=await L(w(),o,$(n),{allowStale:!0});return!t||Date.now()-Date.parse(t.updatedAt)>=(n.ttlMs??X)?null:t.payload}a(q,"cached");async function ot(o){return q("cloud.apps",o)}a(ot,"getCachedApps");async function st(o){await E(w(),"cloud.apps",$(o),o.apps)}a(st,"setCachedApps");async function rt(o){return q("cloud.tools",o)}a(rt,"getCachedTools");async function at(o){await E(w(),"cloud.tools",$(o),o.tools)}a(at,"setCachedTools");var pt=["openpond-generic-v1","openpond-work-v1","openpond-coding-core-v1","openpond-agent-harness-v1"];export{i as a,_ as b,j as c,B as d,G as e,J as f,M as g,F as h,H as i,ae as j,ie as k,ce as l,pe as m,ue as n,le as o,de as p,me as q,ge as r,he as s,ye as t,fe as u,Re as v,we as w,Se as x,xe as y,Te as z,Pe as A,Ae as B,Ee as C,Oe as D,be as E,$e as F,ke as G,Le as H,ve as I,Ie as J,De as K,Ne as L,z as M,qe as N,Ce as O,Ue as P,_e as Q,je as R,Be as S,Ge as T,W as U,Je as V,X as W,ot as X,st as Y,rt as Z,at as _,pt as $};
@@ -0,0 +1,2 @@
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-4476RDBS.js";import"./chunk-L2UT3YIF.js";import"./chunk-CE27WEHK.js";import"./chunk-JVIHGSOV.js";import"./chunk-MVAJMRCW.js";import"./chunk-L3KS6MOV.js";import"./chunk-55UCBRIX.js";import"./chunk-6MI4KKWF.js";import"./chunk-QTEYV4TW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-MJC26GOX.js";import"./chunk-5BFWDFPX.js";import"./chunk-6FA3GG5B.js";import"./chunk-IFP6W4OW.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 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as f}from"./chunk-WVUPFGU7.js";import{Aa as C,Ab as T,Ca as m,Da as j,Ea as x,Fa as F,Ga as v,Ha as P,Sa as J,b as d,c as w,e as b,fb as N,gb as q,jb as k,lb as A,mb as B,pb as H,qb as I,yb as E,zb as M}from"./chunk-F4WS5QIT.js";import"./chunk-ES2ISFJC.js";import{d as O,f as S,h as g}from"./chunk-H7IWJN7L.js";import"./chunk-JKMPJFMN.js";import"./chunk-3M53YXEI.js";import{a as l}from"./chunk-FTQLQJQV.js";import R from"node:path";import{readFile as p}from"node:fs/promises";var n=l((t,s)=>typeof t[s]=="string"?t[s]:void 0,"stringOption");function a(t){console.log(JSON.stringify(t,null,2))}l(a,"print");function U(t,s){let i=n(t,"keyPath");if(i){let r=JSON.parse(i);if(Array.isArray(r)&&r.length&&r.every(c=>typeof c=="string"&&c.length))return r;throw new f("--key-path must be a JSON array of key segments.")}if(!s)throw new f("Specify a setting key, or --key-path for keys containing dots.");return s.split(".")}l(U,"keyPath");async function G(t,s){let i=S({home:n(t,"home")}),r=s[0]??"get",c=g(i).config;if(r==="path"){console.log(c);return}if(r==="export"){let e=await T(i),o=n(t,"file");o?(await b(R.resolve(o),JSON.stringify(e,null,2),{privateParent:!1}),a({path:R.resolve(o),requiresRebinding:e.requiresRebinding})):a(e);return}if(r==="backup"||r==="restore"){let e=n(t,"file"),o=n(t,"keyFile");if(!e||!o)throw new f(`config ${r} requires --file <encrypted-backup> and --key-file <separate-32-byte-key-file>.`);let u=await p(o),y=u.length===32?u:Buffer.from(u.toString("utf8").trim(),"base64");try{a(r==="backup"?await E(i,e,y):await M(e,i,y))}finally{y.fill(0),u.fill(0)}return}if(r==="collect-orphans"){a(await N(i));return}if(r==="schema"){a(F());return}if(r==="migrate"){let e=n(t,"resolutionFile"),o=e?q.parse(JSON.parse(await p(e,"utf8"))):void 0;a(await k(i,{resolutions:o,sourceAppHome:n(t,"sourceAppHome"),sourceConfig:n(t,"sourceConfig"),sourceBrowserState:n(t,"sourceBrowserState"),dryRun:t.dryRun===!0||t.dryRun==="true"}));return}if(r==="recover"){let e=n(t,"revision");a(e?await x(i,e,n(t,"expectedRevision")??d(await w(c))):await A(i));return}if(r==="restart-migration"){a(await B(i));return}if(r==="effective"){a(await I(i,{projectRoot:n(t,"projectRoot"),accountId:n(t,"accountId")}));return}if(r==="trust"||r==="untrust"){let e=n(t,"projectRoot")??s[1];if(!e)throw new f("Specify the canonical project root with --project-root.");await H(i,e,n(t,"accountId")??"local",r==="trust"),a({root:e,trusted:r==="trust"});return}if(r==="revisions"){a(await m(i));return}if(r==="validate"){let e=n(t,"file")??c;C(await p(e,"utf8"),e,t.project===!0||t.project==="true"?"project":"user"),a({valid:!0,path:e});return}if(r==="replace"){let e=n(t,"file");if(!e)throw new f("config replace requires --file <validated-toml-file>.");a(await j(i,n(t,"expectedRevision")??d(await w(c)),await p(e,"utf8")));return}if(r==="doctor"){let e=await w(c),o=null;try{await v(i)}catch(u){o=O(u,c)}a({home:i,path:c,rawRevision:d(e),issue:o,recoverableRevisions:await m(i),migration:await w(R.join(g(i).runtime,"migration.json"))!==null}),o&&(process.exitCode=1);return}if(await k(i),r==="clear-cache"){await J(i),a({cleared:!0,path:g(i).cache});return}let h=await v(i);if(r==="get"){if(!s[1]&&!t.keyPath){a(h);return}let e=h.document;for(let o of U(t,s[1]))e=e&&typeof e=="object"?e[o]:void 0;a(e??null);return}if(r==="set"||r==="unset"){let e=U(t,s[1]),o;if(r==="set"){let u=n(t,"value")??s[2];if(u===void 0)throw new f("config set requires a value. Use JSON for arrays, tables, numbers and booleans.");try{o=JSON.parse(u)}catch{o=u}}a(await P(i,n(t,"expectedRevision")??h.rawRevision,[r==="set"?{op:"set",path:e,value:o}:{op:"unset",path:e}]));return}throw new f(`Unknown config command: ${r}`)}l(G,"runConfigurationCommand");export{G as runConfigurationCommand};
2
+ import{a as f}from"./chunk-UU7RXSJS.js";import{Aa as C,Ab as T,Ca as m,Da as j,Ea as x,Fa as F,Ga as v,Ha as P,Sa as J,b as d,c as w,e as b,fb as N,gb as q,jb as k,lb as A,mb as B,pb as H,qb as I,yb as E,zb as M}from"./chunk-IFP6W4OW.js";import"./chunk-ES2ISFJC.js";import{d as O,f as S,h as g}from"./chunk-H7IWJN7L.js";import"./chunk-JFR34MIK.js";import"./chunk-3M53YXEI.js";import{a as l}from"./chunk-FTQLQJQV.js";import R from"node:path";import{readFile as p}from"node:fs/promises";var n=l((t,s)=>typeof t[s]=="string"?t[s]:void 0,"stringOption");function a(t){console.log(JSON.stringify(t,null,2))}l(a,"print");function U(t,s){let i=n(t,"keyPath");if(i){let r=JSON.parse(i);if(Array.isArray(r)&&r.length&&r.every(c=>typeof c=="string"&&c.length))return r;throw new f("--key-path must be a JSON array of key segments.")}if(!s)throw new f("Specify a setting key, or --key-path for keys containing dots.");return s.split(".")}l(U,"keyPath");async function G(t,s){let i=S({home:n(t,"home")}),r=s[0]??"get",c=g(i).config;if(r==="path"){console.log(c);return}if(r==="export"){let e=await T(i),o=n(t,"file");o?(await b(R.resolve(o),JSON.stringify(e,null,2),{privateParent:!1}),a({path:R.resolve(o),requiresRebinding:e.requiresRebinding})):a(e);return}if(r==="backup"||r==="restore"){let e=n(t,"file"),o=n(t,"keyFile");if(!e||!o)throw new f(`config ${r} requires --file <encrypted-backup> and --key-file <separate-32-byte-key-file>.`);let u=await p(o),y=u.length===32?u:Buffer.from(u.toString("utf8").trim(),"base64");try{a(r==="backup"?await E(i,e,y):await M(e,i,y))}finally{y.fill(0),u.fill(0)}return}if(r==="collect-orphans"){a(await N(i));return}if(r==="schema"){a(F());return}if(r==="migrate"){let e=n(t,"resolutionFile"),o=e?q.parse(JSON.parse(await p(e,"utf8"))):void 0;a(await k(i,{resolutions:o,sourceAppHome:n(t,"sourceAppHome"),sourceConfig:n(t,"sourceConfig"),sourceBrowserState:n(t,"sourceBrowserState"),dryRun:t.dryRun===!0||t.dryRun==="true"}));return}if(r==="recover"){let e=n(t,"revision");a(e?await x(i,e,n(t,"expectedRevision")??d(await w(c))):await A(i));return}if(r==="restart-migration"){a(await B(i));return}if(r==="effective"){a(await I(i,{projectRoot:n(t,"projectRoot"),accountId:n(t,"accountId")}));return}if(r==="trust"||r==="untrust"){let e=n(t,"projectRoot")??s[1];if(!e)throw new f("Specify the canonical project root with --project-root.");await H(i,e,n(t,"accountId")??"local",r==="trust"),a({root:e,trusted:r==="trust"});return}if(r==="revisions"){a(await m(i));return}if(r==="validate"){let e=n(t,"file")??c;C(await p(e,"utf8"),e,t.project===!0||t.project==="true"?"project":"user"),a({valid:!0,path:e});return}if(r==="replace"){let e=n(t,"file");if(!e)throw new f("config replace requires --file <validated-toml-file>.");a(await j(i,n(t,"expectedRevision")??d(await w(c)),await p(e,"utf8")));return}if(r==="doctor"){let e=await w(c),o=null;try{await v(i)}catch(u){o=O(u,c)}a({home:i,path:c,rawRevision:d(e),issue:o,recoverableRevisions:await m(i),migration:await w(R.join(g(i).runtime,"migration.json"))!==null}),o&&(process.exitCode=1);return}if(await k(i),r==="clear-cache"){await J(i),a({cleared:!0,path:g(i).cache});return}let h=await v(i);if(r==="get"){if(!s[1]&&!t.keyPath){a(h);return}let e=h.document;for(let o of U(t,s[1]))e=e&&typeof e=="object"?e[o]:void 0;a(e??null);return}if(r==="set"||r==="unset"){let e=U(t,s[1]),o;if(r==="set"){let u=n(t,"value")??s[2];if(u===void 0)throw new f("config set requires a value. Use JSON for arrays, tables, numbers and booleans.");try{o=JSON.parse(u)}catch{o=u}}a(await P(i,n(t,"expectedRevision")??h.rawRevision,[r==="set"?{op:"set",path:e,value:o}:{op:"unset",path:e}]));return}throw new f(`Unknown config command: ${r}`)}l(G,"runConfigurationCommand");export{G as runConfigurationCommand};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-Y2KDWP74.js";import"./chunk-Y2NQXJ2Q.js";import"./chunk-TJNIYJUH.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-OGPHXXCD.js";import"./chunk-I7XD5OBR.js";import"./chunk-6LY7GYNK.js";import"./chunk-XRV4WLI7.js";import"./chunk-GLUWATL5.js";import"./chunk-JPCPNW6T.js";import"./chunk-J2S7BOZU.js";import"./chunk-2LSP2AAN.js";import"./chunk-WVUPFGU7.js";import"./chunk-F4WS5QIT.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-JKMPJFMN.js";import"./chunk-3M53YXEI.js";import"./chunk-FTQLQJQV.js";export{m as resolveGitBranch,f as runAccount,j as runBacktestRun,p as runCheckUpdate,k as runDeployWatch,g as runHealth,d as runLogin,o as runOpentool,e as runProfiles,l as runRepoCreate,n as runRepoPush,b as runTemplateBranches,a as runTemplateStatus,c as runTemplateUpdate,h as runToolList,i as runToolRun};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-T22TCCWW.js";import"./chunk-MXLB6MEW.js";import"./chunk-XCTFXXVY.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-OGPHXXCD.js";import"./chunk-BAKCGJ5D.js";import"./chunk-Z6F6PYF4.js";import"./chunk-QPZNN5Q3.js";import"./chunk-GLUWATL5.js";import"./chunk-B5LKUQGM.js";import"./chunk-MJC26GOX.js";import"./chunk-5BFWDFPX.js";import"./chunk-UU7RXSJS.js";import"./chunk-IFP6W4OW.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-JFR34MIK.js";import"./chunk-3M53YXEI.js";import"./chunk-FTQLQJQV.js";export{m as resolveGitBranch,f as runAccount,j as runBacktestRun,p as runCheckUpdate,k as runDeployWatch,g as runHealth,d as runLogin,o as runOpentool,e as runProfiles,l as runRepoCreate,n as runRepoPush,b as runTemplateBranches,a as runTemplateStatus,c as runTemplateUpdate,h as runToolList,i as runToolRun};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{u as f}from"./chunk-Y2NQXJ2Q.js";import"./chunk-TJNIYJUH.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-OGPHXXCD.js";import"./chunk-I7XD5OBR.js";import"./chunk-6LY7GYNK.js";import"./chunk-XRV4WLI7.js";import"./chunk-GLUWATL5.js";import"./chunk-JPCPNW6T.js";import"./chunk-J2S7BOZU.js";import"./chunk-2LSP2AAN.js";import{a as c}from"./chunk-WVUPFGU7.js";import"./chunk-F4WS5QIT.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-JKMPJFMN.js";import{c as p,f as u}from"./chunk-3M53YXEI.js";import{a as r}from"./chunk-FTQLQJQV.js";import d from"node:path";import{access as v}from"node:fs/promises";import{constants as C}from"node:fs";import{createRequire as P}from"node:module";var l=d.join("scripts","desktop-harness.ts");async function $(n,t){let o=await j({options:n,rest:t}),e=await f(o.command,o.args,{cwd:o.cwd,inherit:!0,timeoutMs:0});if(e.code!==0)throw new m(e.code)}r($,"runDesktopTestCommand");async function j(n){let t=n.options,o=n.rest,e=o[0];if(e!=="run"&&e!=="attach")throw new c(D());let a=o.slice(1);if(a.length===0)throw new c("usage: openpond desktop-test run <scenario...> [options]");let g=p(t,"cwd")||n.cwd||process.cwd(),w=await O(g),k=(n.env??process.env).OPENPOND_NODE_BINARY?.trim()||process.execPath,s=[P(import.meta.url).resolve("tsx/cli"),l,"run",...a],h=x(t,e);return h&&s.push(`--${h}`),i(s,"--app",t,"app"),i(s,"--server",t,"server"),i(s,"--token",t,"token"),i(s,"--token-file",t,"tokenFile"),i(s,"--devtools-port",t,"devtoolsPort"),i(s,"--artifacts-dir",t,"artifactsDir"),H(s,t),i(s,"--grep",t,"grep"),i(s,"--timeout-ms",t,"timeoutMs"),u(t.keepHome)&&s.push("--keep-home"),{command:k,args:s,cwd:w}}r(j,"buildDesktopHarnessInvocation");async function O(n){let t=d.resolve(n);for(;;){let o=d.join(t,l);if(await R(o))return t;let e=d.dirname(t);if(e===t)throw new c(`Could not find ${l}. Run this command from the OpenPond source checkout or pass --cwd <repo>.`);t=e}}r(O,"resolveDesktopHarnessRepoRoot");function x(n,t){let o=t==="attach"?"attach":null;for(let e of["isolated","attach","packaged","none"])if(u(n[e])){if(o&&o!==e)throw new c("Choose only one desktop harness launch mode: --isolated, --attach, --packaged, or --none.");o=e}return o}r(x,"resolveLaunchMode");function i(n,t,o,e){let a=p(o,e);a&&n.push(t,a)}r(i,"appendStringFlag");function H(n,t){let o=p(t,"json"),e=p(t,"jsonPath");if(o&&y(o))throw new c("harness --json requires a report path. Use --json <path> or --json-path <path>.");if(o&&e&&o!==e)throw new c("Use only one JSON report path: --json <path> or --json-path <path>.");let a=o||e;a&&n.push("--json",a)}r(H,"appendJsonFlag");function y(n){return/^(true|false|1|0|yes|no)$/i.test(n)}r(y,"isBooleanLiteral");async function R(n){try{return await v(n,C.R_OK),!0}catch{return!1}}r(R,"fileExists");function D(){return["usage: openpond desktop-test run <scenario...> [options]"," openpond desktop-test attach <scenario...> [options]","","Options include --isolated, --attach, --packaged, --none, --app <path>,","--server <url>, --token <token>, --token-file <path>, --devtools-port <port>, --artifacts-dir <path>,","--json <path>, --json-path <path>, --grep <pattern>, --timeout-ms <ms>,","--keep-home, and --cwd <repo>."].join(`
2
+ import{u as f}from"./chunk-MXLB6MEW.js";import"./chunk-XCTFXXVY.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-OGPHXXCD.js";import"./chunk-BAKCGJ5D.js";import"./chunk-Z6F6PYF4.js";import"./chunk-QPZNN5Q3.js";import"./chunk-GLUWATL5.js";import"./chunk-B5LKUQGM.js";import"./chunk-MJC26GOX.js";import"./chunk-5BFWDFPX.js";import{a as c}from"./chunk-UU7RXSJS.js";import"./chunk-IFP6W4OW.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-JFR34MIK.js";import{c as p,f as u}from"./chunk-3M53YXEI.js";import{a as r}from"./chunk-FTQLQJQV.js";import d from"node:path";import{access as v}from"node:fs/promises";import{constants as C}from"node:fs";import{createRequire as P}from"node:module";var l=d.join("scripts","desktop-harness.ts");async function $(n,t){let o=await j({options:n,rest:t}),e=await f(o.command,o.args,{cwd:o.cwd,inherit:!0,timeoutMs:0});if(e.code!==0)throw new m(e.code)}r($,"runDesktopTestCommand");async function j(n){let t=n.options,o=n.rest,e=o[0];if(e!=="run"&&e!=="attach")throw new c(D());let a=o.slice(1);if(a.length===0)throw new c("usage: openpond desktop-test run <scenario...> [options]");let g=p(t,"cwd")||n.cwd||process.cwd(),w=await O(g),k=(n.env??process.env).OPENPOND_NODE_BINARY?.trim()||process.execPath,s=[P(import.meta.url).resolve("tsx/cli"),l,"run",...a],h=x(t,e);return h&&s.push(`--${h}`),i(s,"--app",t,"app"),i(s,"--server",t,"server"),i(s,"--token",t,"token"),i(s,"--token-file",t,"tokenFile"),i(s,"--devtools-port",t,"devtoolsPort"),i(s,"--artifacts-dir",t,"artifactsDir"),H(s,t),i(s,"--grep",t,"grep"),i(s,"--timeout-ms",t,"timeoutMs"),u(t.keepHome)&&s.push("--keep-home"),{command:k,args:s,cwd:w}}r(j,"buildDesktopHarnessInvocation");async function O(n){let t=d.resolve(n);for(;;){let o=d.join(t,l);if(await R(o))return t;let e=d.dirname(t);if(e===t)throw new c(`Could not find ${l}. Run this command from the OpenPond source checkout or pass --cwd <repo>.`);t=e}}r(O,"resolveDesktopHarnessRepoRoot");function x(n,t){let o=t==="attach"?"attach":null;for(let e of["isolated","attach","packaged","none"])if(u(n[e])){if(o&&o!==e)throw new c("Choose only one desktop harness launch mode: --isolated, --attach, --packaged, or --none.");o=e}return o}r(x,"resolveLaunchMode");function i(n,t,o,e){let a=p(o,e);a&&n.push(t,a)}r(i,"appendStringFlag");function H(n,t){let o=p(t,"json"),e=p(t,"jsonPath");if(o&&y(o))throw new c("harness --json requires a report path. Use --json <path> or --json-path <path>.");if(o&&e&&o!==e)throw new c("Use only one JSON report path: --json <path> or --json-path <path>.");let a=o||e;a&&n.push("--json",a)}r(H,"appendJsonFlag");function y(n){return/^(true|false|1|0|yes|no)$/i.test(n)}r(y,"isBooleanLiteral");async function R(n){try{return await v(n,C.R_OK),!0}catch{return!1}}r(R,"fileExists");function D(){return["usage: openpond desktop-test run <scenario...> [options]"," openpond desktop-test attach <scenario...> [options]","","Options include --isolated, --attach, --packaged, --none, --app <path>,","--server <url>, --token <token>, --token-file <path>, --devtools-port <port>, --artifacts-dir <path>,","--json <path>, --json-path <path>, --grep <pattern>, --timeout-ms <ms>,","--keep-home, and --cwd <repo>."].join(`
3
3
  `)}r(D,"desktopHarnessCliUsage");var m=class extends Error{static{r(this,"HarnessCommandFailedError")}exitCode;constructor(t){let o=typeof t=="number"&&t>0?t:1;super(`desktop harness failed with exit code ${o}`),this.name="HarnessCommandFailedError",this.exitCode=o}};export{j as buildDesktopHarnessInvocation,O as resolveDesktopHarnessRepoRoot,$ as runDesktopTestCommand};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{$a as ga,Aa as A,Ab as Ha,Ba as B,Bb as Ia,Ca as C,Da as D,Ea as E,Fa as F,Ga as G,Ha as H,Ia as I,Ja as J,Ka as K,La as L,Ma as M,Na as N,Oa as O,Pa as W,Qa as X,Ra as Y,Sa as Z,Ta as _,Ua as $,Va as aa,Wa as ba,Xa as ca,Ya as da,Za as ea,_a as fa,a as l,ab as ha,b as m,bb as ia,c as n,cb as ja,d as o,db as ka,e as p,eb as la,f as q,fb as ma,g as r,gb as na,h as s,hb as oa,i as t,ib as pa,j as u,jb as qa,kb as ra,lb as sa,mb as ta,nb as ua,ob as va,pb as wa,qb as xa,rb as ya,sb as za,tb as Aa,ub as Ba,va as v,vb as Ca,wa as w,wb as Da,xa as x,xb as Ea,ya as y,yb as Fa,za as z,zb as Ga}from"./chunk-F4WS5QIT.js";import"./chunk-ES2ISFJC.js";import{a,b,c,d,e,f,g,h,i,k as j,l as k,m as P,n as Q,o as R,p as S,q as T,r as U,s as V}from"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{Ca as CLIENT_CHOICE_KEYS,Ba as ClientChoicesSchema,w as ConfigSchema,v as CredentialReferenceSchema,L as LAYOUT_PREFERENCE_KEYS,l as MISSING_REVISION,na as MigrationResolutionsSchema,P as PERSISTENCE_TABLES_SQL,c as PersistenceError,ea as accountId,r as acquireFileLock,ja as artifactReference,za as assertConfigRunCurrent,Ia as assertHomeCompatible,k as assertStorageAncestors,p as atomicWriteFile,b as bindHomeCallbacks,ya as captureConfigRun,Z as clearCache,ma as collectArtifactOrphans,F as configEditorSchema,C as configRecoveryRevisions,N as configToPreferences,da as credentialVersions,ba as deleteCredential,V as deleteLocalRecord,y as diffConfig,Aa as effectivePreferences,g as expandHome,Fa as exportRecoveryBackup,Ha as exportSettings,m as fileRevision,S as getLocalRecord,qa as initializeHome,e as isMissing,O as layoutPreferences,Y as listCache,T as listLocalRecords,J as mergeConfig,ca as newCredentialId,Q as openStorageDatabase,H as patchConfig,d as persistenceIssue,M as preferencesToConfig,o as privateDirectory,s as processIsDead,j as protectPrivateDirectory,ia as publishManagedArtifact,U as putLocalRecord,fa as readAccountConfiguration,W as readCache,Da as readClientChoices,G as readConfig,_ as readCredential,$ as readCredentials,t as readJsonFile,oa as readMigrationJournal,n as readOptionalFile,ua as readPreferences,sa as recoverMigration,la as releaseArtifactReference,B as rememberValidConfig,D as replaceConfigText,i as resolveConfigPath,xa as resolveEffectiveConfig,f as resolveOpenPondHome,pa as resolveStoredPath,ta as restartMigration,E as restoreConfigRevision,Ga as restoreRecoveryBackup,z as serializeConfig,wa as setProjectTrust,h as storagePaths,ga as updateAccountConfiguration,Ea as updateClientChoices,I as updateConfig,u as updateJsonFile,va as updatePreferences,x as validateConfigDocument,A as validateConfigText,ha as validateManagedArtifacts,ra as validateMigratedHome,K as watchConfig,q as withFileLock,R as withLocalDatabase,ka as withManagedArtifact,a as withOpenPondHome,X as writeCache,aa as writeCredential};
2
+ import{$a as ga,Aa as A,Ab as Ha,Ba as B,Bb as Ia,Ca as C,Da as D,Ea as E,Fa as F,Ga as G,Ha as H,Ia as I,Ja as J,Ka as K,La as L,Ma as M,Na as N,Oa as O,Pa as W,Qa as X,Ra as Y,Sa as Z,Ta as _,Ua as $,Va as aa,Wa as ba,Xa as ca,Ya as da,Za as ea,_a as fa,a as l,ab as ha,b as m,bb as ia,c as n,cb as ja,d as o,db as ka,e as p,eb as la,f as q,fb as ma,g as r,gb as na,h as s,hb as oa,i as t,ib as pa,j as u,jb as qa,kb as ra,lb as sa,mb as ta,nb as ua,ob as va,pb as wa,qb as xa,rb as ya,sb as za,tb as Aa,ub as Ba,va as v,vb as Ca,wa as w,wb as Da,xa as x,xb as Ea,ya as y,yb as Fa,za as z,zb as Ga}from"./chunk-IFP6W4OW.js";import"./chunk-ES2ISFJC.js";import{a,b,c,d,e,f,g,h,i,k as j,l as k,m as P,n as Q,o as R,p as S,q as T,r as U,s as V}from"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{Ca as CLIENT_CHOICE_KEYS,Ba as ClientChoicesSchema,w as ConfigSchema,v as CredentialReferenceSchema,L as LAYOUT_PREFERENCE_KEYS,l as MISSING_REVISION,na as MigrationResolutionsSchema,P as PERSISTENCE_TABLES_SQL,c as PersistenceError,ea as accountId,r as acquireFileLock,ja as artifactReference,za as assertConfigRunCurrent,Ia as assertHomeCompatible,k as assertStorageAncestors,p as atomicWriteFile,b as bindHomeCallbacks,ya as captureConfigRun,Z as clearCache,ma as collectArtifactOrphans,F as configEditorSchema,C as configRecoveryRevisions,N as configToPreferences,da as credentialVersions,ba as deleteCredential,V as deleteLocalRecord,y as diffConfig,Aa as effectivePreferences,g as expandHome,Fa as exportRecoveryBackup,Ha as exportSettings,m as fileRevision,S as getLocalRecord,qa as initializeHome,e as isMissing,O as layoutPreferences,Y as listCache,T as listLocalRecords,J as mergeConfig,ca as newCredentialId,Q as openStorageDatabase,H as patchConfig,d as persistenceIssue,M as preferencesToConfig,o as privateDirectory,s as processIsDead,j as protectPrivateDirectory,ia as publishManagedArtifact,U as putLocalRecord,fa as readAccountConfiguration,W as readCache,Da as readClientChoices,G as readConfig,_ as readCredential,$ as readCredentials,t as readJsonFile,oa as readMigrationJournal,n as readOptionalFile,ua as readPreferences,sa as recoverMigration,la as releaseArtifactReference,B as rememberValidConfig,D as replaceConfigText,i as resolveConfigPath,xa as resolveEffectiveConfig,f as resolveOpenPondHome,pa as resolveStoredPath,ta as restartMigration,E as restoreConfigRevision,Ga as restoreRecoveryBackup,z as serializeConfig,wa as setProjectTrust,h as storagePaths,ga as updateAccountConfiguration,Ea as updateClientChoices,I as updateConfig,u as updateJsonFile,va as updatePreferences,x as validateConfigDocument,A as validateConfigText,ha as validateManagedArtifacts,ra as validateMigratedHome,K as watchConfig,q as withFileLock,R as withLocalDatabase,ka as withManagedArtifact,a as withOpenPondHome,X as writeCache,aa as writeCredential};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as se}from"./chunk-PSZKG3E3.js";import"./chunk-BX4J2VDU.js";import"./chunk-55UCBRIX.js";import"./chunk-6MI4KKWF.js";import"./chunk-QTEYV4TW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-4QX2I2DX.js";import"./chunk-22UARBPW.js";import"./chunk-JEVA7YQL.js";import{a as T,x as D}from"./chunk-K6EGNB2A.js";import"./chunk-DR3XPQRZ.js";import"./chunk-Z6F6PYF4.js";import"./chunk-QPZNN5Q3.js";import"./chunk-GLUWATL5.js";import"./chunk-5BFWDFPX.js";import"./chunk-EAPFMACH.js";import"./chunk-6FA3GG5B.js";import{f as N}from"./chunk-IFP6W4OW.js";import"./chunk-ES2ISFJC.js";import{f as ne,h as z,p as B,r as oe}from"./chunk-H7IWJN7L.js";import{f as G}from"./chunk-3M53YXEI.js";import{a as r}from"./chunk-FTQLQJQV.js";var u=class extends Error{static{r(this,"GithubExtensionError")}code;status;constructor(t,o){super(t),this.name="GithubExtensionError",this.code=o.code,this.status=o.status??400}};import{createHash as ce}from"node:crypto";import J from"node:path";var ie="HEAD",ae=64,de=512,le=20*1024*1024,K=5*1024*1024,me=8,Ue=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,pe=/^[A-Za-z0-9_.-]+$/,ue=new Set(["agents","assets","references","scripts"]);function Se(e={}){let t=e.fetch??fetch,o=e.githubToken?.trim()||process.env.GITHUB_TOKEN?.trim()||process.env.GH_TOKEN?.trim()||null;return{async resolve(n){let s=await qe(n,t,o);return{preview:await Te(s,t,o),files:ge(s)}},async download(n,s){await _e({resolution:n,fetchImpl:t,githubToken:o,writeFile:s})}}}r(Se,"createGithubSourceClient");function I(e){let t=e.trim(),o="",n="";if(/^(?:https?:\/\/)?github\.com\//i.test(t)){let d=new URL(t.startsWith("http")?t:`https://${t}`);if(d.hostname.toLowerCase()!=="github.com")throw j(e);let a=d.pathname.replace(/^\/+|\/+$/g,"").split("/");if(a.length!==2)throw j(e);[o="",n=""]=a}else{let a=t.replace(/^github:/i,"").replace(/^\/+|\/+$/g,"").split("/");if(a.length!==2)throw j(e);[o="",n=""]=a}if(n=n.replace(/\.git$/i,""),!pe.test(o)||!pe.test(n))throw j(e);let s=o.toLowerCase(),i=n.toLowerCase();return{id:`github:${s}/${i}`,owner:s,repo:i,repositoryUrl:`https://github.com/${s}/${i}`}}r(I,"parseGithubExtensionSource");async function qe(e,t,o){let n=I(e.source),s=e.ref?.trim()||ie,i=await H(t,o,`/repos/${n.owner}/${n.repo}`),d=s===ie?i.default_branch?.trim()||"main":s,a=await H(t,o,`/repos/${n.owner}/${n.repo}/commits/${encodeURIComponent(d)}`),b=a.sha?.trim(),f=a.commit?.tree?.sha?.trim();if(!b||!f)throw new u("GitHub returned an incomplete commit response.",{code:"github_invalid_commit",status:502});let y=await H(t,o,`/repos/${n.owner}/${n.repo}/git/trees/${f}?recursive=1`);if(y.truncated)throw new u("The GitHub repository tree is too large to install safely.",{code:"github_tree_truncated"});let w=(y.tree??[]).filter(ze),x=Le(w);if(x.length===0)throw new u("No skills found. Add SKILL.md at the repository root or use a standard agent skills directory.",{code:"extension_no_skills"});if(x.length>ae)throw new u(`Extension contains more than ${ae} skills.`,{code:"extension_too_many_skills"});Ge(x);let A=w.find(m=>m.type==="blob"&&/^readme(?:\.[^/]+)?$/i.test(m.path))??null;return{identity:n,requestedRef:s,resolvedCommit:b,tree:w,skillPackages:x,readme:A}}r(qe,"resolveSource");async function Te(e,t,o){let n=await xe(e.skillPackages,me,async a=>{let b=await Fe(e,a.entry,t,o);return je(a,b)}),s=De(n.map(a=>a.name));for(let a of n)s.has(a.name)&&(a.validationStatus="error",a.validationMessages=[...a.validationMessages,`Duplicate skill name: ${a.name}`]);let i=n.flatMap(a=>a.validationMessages.map(b=>`${a.relativePath}: ${b}`)),d=ge(e);return{...e.identity,source:"github",requestedRef:e.requestedRef,resolvedCommit:e.resolvedCommit,sourcePath:null,readmePath:e.readme?.path??null,packageHash:Ne(d),skills:n.sort((a,b)=>a.name.localeCompare(b.name)),validationStatus:i.length===0?"valid":"error",validationMessages:i}}r(Te,"buildPreview");function je(e,t){let o=T(t),n=e.root==="."?null:J.posix.basename(e.root),s=o.name??n??"invalid-skill",i=[...o.messages];Ue.test(s)||i.push("Skill name must be lowercase kebab-case."),n&&s!==n&&i.push(`Skill name must match its directory name (${n}).`);let d=e.files.filter(a=>a.path!==e.entry.path).map(a=>Be(e.root,a.path)).sort();return{name:s,description:o.description??"",relativePath:e.root==="."?"SKILL.md":`${e.root}/SKILL.md`,sourcePath:"",charCount:t.length,sourceHash:ce("sha256").update(t).digest("hex"),resourceFiles:d,validationStatus:i.length===0?"valid":"error",validationMessages:[...new Set(i)]}}r(je,"previewSkill");function Le(e){let t=[],o=e.find(a=>a.type==="blob"&&a.path==="SKILL.md");o&&t.push({root:".",entry:o});let n=e.filter(a=>a.type==="blob"&&a.path.endsWith("/SKILL.md")),s=n.filter(a=>Me(a.path)),i=s.length>0?s:n,d=new Set(i.map(a=>J.posix.dirname(a.path)));for(let a of i){let b=J.posix.dirname(a.path);[...d].some(f=>f!==b&&b.startsWith(`${f}/`))||t.push({root:b,entry:a})}return t.map(({root:a,entry:b})=>{let f=e.filter(x=>{if(x.type!=="blob")return!1;if(a!==".")return x.path.startsWith(`${a}/`);if(x.path==="SKILL.md")return!0;let A=x.path.split("/",1)[0]??"";return ue.has(A)}),y=e.find(x=>x.type!=="blob"&&x.type!=="tree"&&(a==="."?x.path==="SKILL.md"||ue.has(x.path.split("/",1)[0]??""):x.path.startsWith(`${a}/`))),w=f.find(x=>x.mode==="120000");if(y||w)throw new u(`Skill package ${a} contains a symlink or submodule.`,{code:"extension_unsafe_entry"});return{root:a,entry:b,files:f}})}r(Le,"discoverSkillPackages");function Me(e){let t=e.split("/");if(t.at(-1)!=="SKILL.md")return!1;let o=t.slice(0,-1);if(o.length<2)return!1;let n=o.lastIndexOf("skills");if(n<0||n>2)return!1;let s=o.slice(0,n),i=o.slice(n+1);if(i.length<1||i.length>2)return!1;if(n===0)return!0;let d=s[0]??"";return d.startsWith(".")||d==="agent"||d==="data"}r(Me,"isStandardAgentSkillsPath");function ge(e){let t=new Map;e.readme&&t.set(e.readme.path,e.readme);for(let o of e.skillPackages)for(let n of o.files)t.set(n.path,n);return[...t.values()].sort((o,n)=>o.path.localeCompare(n.path))}r(ge,"filesToDownload");async function _e(e){let t=0;await xe(e.resolution.files,me,async o=>{let n=await be({owner:e.resolution.preview.owner,repo:e.resolution.preview.repo,commit:e.resolution.preview.resolvedCommit,file:o,fetchImpl:e.fetchImpl,githubToken:e.githubToken});if(t+=n.byteLength,t>le)throw new u("Extension download exceeds the maximum allowed size.",{code:"extension_too_large"});await e.writeFile(o.path,n,o.mode==="100755")})}r(_e,"downloadFiles");async function Fe(e,t,o,n){let s=await be({owner:e.identity.owner,repo:e.identity.repo,commit:e.resolvedCommit,file:t,fetchImpl:o,githubToken:n});return new TextDecoder("utf-8",{fatal:!0}).decode(s)}r(Fe,"downloadText");async function be(e){let t=e.file.path.split("/").map(encodeURIComponent).join("/"),o=`https://raw.githubusercontent.com/${e.owner}/${e.repo}/${e.commit}/${t}`,n=await e.fetchImpl(o,{headers:he(e.githubToken,"application/vnd.github.raw"),redirect:"follow"});if(!n.ok)throw new u(`GitHub file download failed (${n.status}): ${e.file.path}`,{code:"github_download_failed",status:n.status});let s=Number(n.headers.get("content-length"));if(Number.isFinite(s)&&s>K)throw new u(`Extension file is too large: ${e.file.path}`,{code:"extension_file_too_large"});let i=new Uint8Array(await n.arrayBuffer());if(i.byteLength>K)throw new u(`Extension file is too large: ${e.file.path}`,{code:"extension_file_too_large"});return i}r(be,"downloadBytes");async function H(e,t,o){let n=await e(`https://api.github.com${o}`,{headers:he(t,"application/vnd.github+json")});if(!n.ok){let s=await n.json().catch(()=>null),i=typeof s?.message=="string"?`: ${s.message}`:"";throw new u(`GitHub request failed (${n.status})${i}`,{code:n.status===404?"github_repository_not_found":"github_request_failed",status:n.status})}return await n.json()}r(H,"githubJson");function he(e,t){let o=new Headers({Accept:t,"User-Agent":"openpond-extension-installer","X-GitHub-Api-Version":"2022-11-28"});return e&&o.set("Authorization",`Bearer ${e}`),o}r(he,"githubHeaders");function Ge(e){let t=new Map;for(let n of e)for(let s of n.files)t.set(s.path,s);if(t.size>de)throw new u(`Extension contains more than ${de} skill files.`,{code:"extension_too_many_files"});let o=0;for(let n of t.values()){if((n.size??0)>K)throw new u(`Extension file is too large: ${n.path}`,{code:"extension_file_too_large"});o+=n.size??0}if(o>le)throw new u("Extension exceeds the maximum allowed size.",{code:"extension_too_large"})}r(Ge,"validateDownloadLimits");function ze(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.path=="string"&&!t.path.startsWith("/")&&!t.path.split("/").includes("..")&&typeof t.mode=="string"&&(t.type==="blob"||t.type==="tree"||t.type==="commit")&&typeof t.sha=="string"}r(ze,"validTreeEntry");function Ne(e){let t=ce("sha256");for(let o of e)t.update(`${o.path}\0${o.sha}\0${o.size??""}
3
+ `);return t.digest("hex")}r(Ne,"hashTree");function Be(e,t){return e==="."?t:t.slice(e.length+1)}r(Be,"relativeSkillPath");function De(e){let t=new Set,o=new Set;for(let n of e)t.has(n)&&o.add(n),t.add(n);return o}r(De,"duplicateValues");async function xe(e,t,o){let n=new Array(e.length),s=0;async function i(){for(;s<e.length;){let d=s;s+=1,n[d]=await o(e[d])}}return r(i,"worker"),await Promise.all(Array.from({length:Math.min(t,e.length)},i)),n}r(xe,"mapConcurrent");function j(e){return new u(`Invalid GitHub extension source: ${e}. Use owner/repo or https://github.com/owner/repo.`,{code:"github_invalid_source"})}r(j,"invalidSource");import{createHash as He,randomUUID as we}from"node:crypto";import{existsSync as v}from"node:fs";import{mkdir as W,readFile as Je,rename as k,rm as E,stat as Ke,writeFile as Re}from"node:fs/promises";import g from"node:path";var M=1,We=15e3;function Oe(e={}){let t=g.resolve(e.home??e.rootPath??ne()),o=g.resolve(e.rootPath??g.join(t,"library","extensions")),n=z(t).database,s=Se({fetch:e.fetch,githubToken:e.githubToken}),i=e.now??(()=>new Date);async function d(){try{let m=await O(t),p=await Promise.all(m.extensions.map(S=>V(o,S)));return Ze(p,await C(e.reservedSkillNames)),{rootPath:o,registryPath:n,extensions:p.sort(Q),error:null}}catch(m){return{rootPath:o,registryPath:n,extensions:[],error:m instanceof Error?m.message:String(m)}}}r(d,"list");async function a(m){let p=await s.resolve(m),S=await O(t),c=S.extensions.find(l=>l.id===p.preview.id)??null;return U(p.preview,S.extensions.filter(l=>l.id!==c?.id),await C(e.reservedSkillNames)),p.preview}r(a,"preview");async function b(m){let p=I(m.source);return Y(o,p.id,async()=>{let S=await O(t);if(S.extensions.some(h=>h.id===p.id))throw new u(`${p.owner}/${p.repo} is already installed.`,{code:"extension_already_installed",status:409});let c=await s.resolve(m);Ie(c.preview),U(c.preview,S.extensions,await C(e.reservedSkillNames));let l=i().toISOString(),R=await fe({rootPath:o,resolution:c,installedAt:l,updatedAt:l,github:s});try{let h=await C(e.reservedSkillNames);return await X(t,i,P=>({...P,extensions:Xe(P,R,h)})),await Pe(o,R.id),R}catch(h){throw await ye(o,R.id),h}})}r(b,"add");async function f(m){let p=I(m.source);return Y(o,p.id,async()=>{let S=await O(t),c=L(S,p.id),l=await s.resolve({source:c.repositoryUrl,ref:m.ref?.trim()||c.requestedRef});if(Ie(l.preview),U(l.preview,S.extensions.filter(h=>h.id!==c.id),await C(e.reservedSkillNames)),c.resolvedCommit===l.preview.resolvedCommit&&c.packageHash===l.preview.packageHash&&c.requestedRef===l.preview.requestedRef)return V(o,c);let R=await fe({rootPath:o,resolution:l,installedAt:c.installedAt,updatedAt:i().toISOString(),github:s});try{let h=await C(e.reservedSkillNames);return await X(t,i,P=>({...P,extensions:Ye(P,R,h)})),await Pe(o,R.id),R}catch(h){throw await ye(o,R.id),h}})}r(f,"update");async function y(){let m=await d();if(m.error)throw new u(m.error,{code:"extension_registry_error"});let p={updated:[],unchanged:[],failed:[]};for(let S of m.extensions)try{let c=await f({source:S.repositoryUrl,ref:S.requestedRef});c.resolvedCommit===S.resolvedCommit&&c.packageHash===S.packageHash?p.unchanged.push(c):p.updated.push(c)}catch(c){p.failed.push({id:S.id,error:c instanceof Error?c.message:String(c)})}return p}r(y,"updateAll");async function w(m){let p=I(m),S=await O(t);return V(o,L(S,p.id))}r(w,"inspect");async function x(m){let p=I(m);return Y(o,p.id,async()=>{let S=await O(t),c=L(S,p.id),l=q(o,p.owner,p.repo),R=`${l}.${we()}.remove`;v(l)&&await k(l,R);try{return await X(t,i,h=>({...h,extensions:h.extensions.filter(P=>P.id!==c.id)})),await E(R,{recursive:!0,force:!0}),c}catch(h){throw v(R)&&!v(l)&&await k(R,l),h}})}r(x,"remove");async function A(m){let p=m.trim();if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(p))throw new u("Extension skill name must be lowercase kebab-case.",{code:"extension_skill_invalid_name"});let S=await d();if(S.error)throw new u(S.error,{code:"extension_registry_error"});let c=S.extensions.flatMap(te=>te.skills.filter(F=>F.name===p).map(F=>({extension:te,skill:F})));if(c.length===0)throw new u(`Extension skill not found: ${p}`,{code:"extension_skill_not_found",status:404});if(c.length>1)throw new u(`Extension skill name is ambiguous: ${p}`,{code:"extension_skill_conflict",status:409});let l=c[0];if(l.extension.validationStatus!=="valid"||l.skill.validationStatus!=="valid")throw new u(`Extension skill ${p} is not valid.`,{code:"extension_skill_invalid"});let R=$e(l.extension.sourcePath,l.skill.relativePath),h=await Je(R,"utf8"),P=He("sha256").update(h).digest("hex");if(P!==l.skill.sourceHash)throw new u(`Extension skill ${p} changed on disk. Update or reinstall its extension before using it.`,{code:"extension_skill_modified"});let $=T(h);if($.messages.length>0||$.name!==p||!$.description)throw new u(`Extension skill ${p} is not valid. ${$.messages.join(" ")}`.trim(),{code:"extension_skill_invalid"});return{name:p,description:$.description,body:$.body,path:l.skill.relativePath,sourcePath:l.extension.sourcePath,sourceHash:P,charCount:h.length,packagePath:g.dirname(R),resourceFiles:l.skill.resourceFiles}}return r(A,"readSkill"),{rootPath:o,registryPath:n,list:d,preview:a,add:b,update:f,updateAll:y,inspect:w,remove:x,readSkill:A}}r(Oe,"createGithubExtensionManager");async function fe(e){let t=e.resolution.preview,o=q(e.rootPath,t.owner,t.repo),n=`${o}.${we()}.install`,s=Z(e.rootPath,t.id),i=g.join(n,"current");await E(n,{recursive:!0,force:!0}),await E(s,{recursive:!0,force:!0}),await W(i,{recursive:!0,mode:448});try{await e.github.download(e.resolution,async(a,b,f)=>{let y=$e(i,a);await W(g.dirname(y),{recursive:!0,mode:448}),await Re(y,b,{mode:f?448:384})});let d=Ve(t,o,e.installedAt,e.updatedAt);return await Re(g.join(n,"extension.json"),`${JSON.stringify(d,null,2)}
4
+ `,{mode:384}),await W(g.dirname(o),{recursive:!0,mode:448}),v(o)&&await k(o,s),await k(n,o),d}catch(d){throw await E(n,{recursive:!0,force:!0}),v(s)&&!v(o)&&await k(s,o),d}}r(fe,"materializeExtension");function Ve(e,t,o,n){let s=g.join(t,"current");return{...e,sourcePath:s,readmePath:e.readmePath?g.join(s,e.readmePath):null,installedAt:o,updatedAt:n,skills:e.skills.map(i=>({...i,sourcePath:g.join(s,i.relativePath)}))}}r(Ve,"installedExtension");async function Pe(e,t){await E(Z(e,t),{recursive:!0,force:!0})}r(Pe,"finalizeMaterialization");async function ye(e,t){let o=I(t.replace(/^github:/,"")),n=q(e,o.owner,o.repo),s=Z(e,t);await E(n,{recursive:!0,force:!0}),v(s)&&await k(s,n)}r(ye,"rollbackMaterialization");async function V(e,t){let o=q(e,t.owner,t.repo),n=g.join(o,"current"),s=(await Ke(g.join(o,"extension.json")).catch(()=>null))?.isFile()??!1,i=t.validationMessages.filter(d=>d!=="Installed files are missing.");return s||i.push("Installed files are missing."),{...t,sourcePath:n,readmePath:t.readmePath?g.join(n,g.basename(t.readmePath)):null,skills:t.skills.map(d=>({...d,sourcePath:g.join(n,d.relativePath)})),validationStatus:i.length===0?"valid":"error",validationMessages:i}}r(V,"hydrateExtension");function Ie(e){if(e.validationStatus!=="valid")throw new u(`Extension contains invalid skills: ${e.validationMessages.join(" ")}`,{code:"extension_invalid"})}r(Ie,"assertInstallable");function U(e,t,o){let n=new Map;for(let i of o)n.set(i,"a shipped OpenPond skill");for(let i of t)for(let d of i.skills)n.set(d.name,i.id);let s=e.skills.map(i=>({name:i.name,owner:n.get(i.name)})).filter(i=>!!i.owner);if(s.length!==0)throw new u(`Skill name conflict: ${s.map(i=>`${i.name} (${i.owner})`).join(", ")}.`,{code:"extension_skill_conflict",status:409})}r(U,"assertSkillNamesAvailable");function Xe(e,t,o){if(e.extensions.some(n=>n.id===t.id))throw new u(`${t.owner}/${t.repo} is already installed.`,{code:"extension_already_installed",status:409});return U(t,e.extensions,o),[...e.extensions,t].sort(Q)}r(Xe,"appendInstalledExtension");function Ye(e,t,o){return L(e,t.id),U(t,e.extensions.filter(n=>n.id!==t.id),o),e.extensions.map(n=>n.id===t.id?t:n).sort(Q)}r(Ye,"replaceInstalledExtension");function Ze(e,t){let o=new Map;for(let n of t)o.set(n,"built-in");for(let n of e)for(let s of n.skills){let i=o.get(s.name);if(!i){o.set(s.name,n.id);continue}let d=`Skill name conflicts with ${i}: ${s.name}`;s.validationStatus="error",s.validationMessages=[...new Set([...s.validationMessages,d])],n.validationStatus="error",n.validationMessages=[...new Set([...n.validationMessages,d])]}}r(Ze,"markInstalledSkillConflicts");async function C(e){let t=typeof e=="function"?await e():e??[];return[...new Set(t.map(o=>o.trim()).filter(Boolean))]}r(C,"reservedSkillNames");function L(e,t){let o=e.extensions.find(n=>n.id===t);if(o)return o;throw new u(`${t.replace(/^github:/,"")} is not installed.`,{code:"extension_not_installed",status:404})}r(L,"requireInstalled");async function O(e){let t=B(e,"extension_installations","registry")?.value;if(!t)return et();if(t.schemaVersion!==M||!Array.isArray(t.extensions)||!t.extensions.every(ve))throw new Error("Extension registry has an unsupported format.");return Qe(t)}r(O,"readRegistry");async function X(e,t,o){await N(g.join(z(e).runtime,"extension-registry"),async()=>{let n=B(e,"extension_installations","registry"),s=o(await O(e));oe(e,"extension_installations","registry",{...s,schemaVersion:M,updatedAt:t().toISOString()},n?.revision??null)})}r(X,"writeRegistry");function Qe(e){return{schemaVersion:M,updatedAt:typeof e?.updatedAt=="string"?e.updatedAt:null,extensions:Array.isArray(e?.extensions)?e.extensions.filter(ve):[]}}r(Qe,"normalizeRegistry");function et(){return{schemaVersion:M,updatedAt:null,extensions:[]}}r(et,"emptyRegistry");function ve(e){if(!e||typeof e!="object")return!1;let t=e;return t.source==="github"&&typeof t.id=="string"&&typeof t.owner=="string"&&typeof t.repo=="string"&&typeof t.repositoryUrl=="string"&&typeof t.requestedRef=="string"&&typeof t.resolvedCommit=="string"&&Array.isArray(t.skills)}r(ve,"isStoredExtension");function $e(e,t){if(g.isAbsolute(t)||t.split(/[\\/]/).includes(".."))throw new u(`Unsafe extension path: ${t}`,{code:"extension_unsafe_path"});let o=g.resolve(e,...t.split("/")),n=`${g.resolve(e)}${g.sep}`;if(!o.startsWith(n))throw new u(`Unsafe extension path: ${t}`,{code:"extension_unsafe_path"});return o}r($e,"safeDestination");function q(e,t,o){return g.join(e,"github",t,o)}r(q,"extensionDirectory");function Z(e,t){let o=I(t.replace(/^github:/,""));return`${q(e,o.owner,o.repo)}.previous`}r(Z,"backupDirectory");async function Y(e,t,o){let n=t.replace(/[^a-z0-9.-]+/gi,"-");return N(g.join(e,".locks",n),o,We)}r(Y,"withExtensionLock");function Q(e,t){return e.id.localeCompare(t.id)}r(Q,"extensionSort");async function Ln(e,t,o=Oe({reservedSkillNames:r(async()=>{let n=await D();return[...se,...n.skills.map(s=>s.name)]},"reservedSkillNames")})){let n=t[0]?.toLowerCase()||"list",s=G(e.json);if(n==="list"){let i=await o.list();if(i.error)throw new Error(i.error);tt(i.extensions,s);return}if(n==="add"||n==="preview"){let d={source:_(t[1],n),ref:Ce(e.ref)},a=n==="preview"?await o.preview(d):await o.add(d);ee(a,s,n==="preview"?"Preview":"Installed");return}if(n==="inspect"){ee(await o.inspect(_(t[1],n)),s,"Installed");return}if(n==="update"){if(G(e.all)){let a=await o.updateAll();if(s)console.log(JSON.stringify(a,null,2));else{console.log(`Updated ${a.updated.length}; unchanged ${a.unchanged.length}; failed ${a.failed.length}.`);for(let b of a.failed)console.log(`- ${b.id}: ${b.error}`)}a.failed.length>0&&(process.exitCode=1);return}let i=_(t[1],n),d=await o.update({source:i,ref:Ce(e.ref)});ee(d,s,"Updated");return}if(n==="remove"){let i=await o.remove(_(t[1],n));console.log(s?JSON.stringify({removed:i},null,2):`Removed ${i.owner}/${i.repo} and ${i.skills.length} skill(s).`);return}throw new Error("usage: openpond extension <add|preview|list|inspect|update|remove> [owner/repo] [--ref <ref>] [--all] [--json]")}r(Ln,"runOpenPondExtensionCommand");function ee(e,t,o){if(t){console.log(JSON.stringify(e,null,2));return}console.log(`${o} ${e.owner}/${e.repo}@${e.resolvedCommit.slice(0,12)} (${e.requestedRef}).`);for(let n of e.skills){let s=n.resourceFiles.length>0?`, ${n.resourceFiles.length} resource(s)`:"";console.log(`- ${n.name}${s}: ${n.description}`)}}r(ee,"printExtension");function tt(e,t){if(t){console.log(JSON.stringify({extensions:e},null,2));return}if(e.length===0){console.log("No third-party extensions installed.");return}console.log(`Third-party extensions (${e.length}):`);for(let o of e)console.log(`- ${o.owner}/${o.repo}@${o.resolvedCommit.slice(0,12)} \xB7 ${o.skills.length} skill(s) \xB7 ${o.validationStatus}`)}r(tt,"printExtensionList");function _(e,t){let o=e?.trim();if(o)return o;throw new Error(`usage: openpond extension ${t} <owner/repo>`)}r(_,"requiredSource");function Ce(e){return typeof e=="string"&&e.trim()?e.trim():void 0}r(Ce,"optionText");export{Ln as runOpenPondExtensionCommand};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{d as r,f as i,k as p}from"./chunk-JKMPJFMN.js";import"./chunk-3M53YXEI.js";import{a as t}from"./chunk-FTQLQJQV.js";function d(){console.log(m())}t(d,"printHelp");function m(){let n=["OpenPond CLI","","Usage:"," openpond [--no-open] [--hostname HOST] [--port PORT]"," openpond <command> [options] [-- passthrough...]"," openpond --version","","Commands:"];for(let o of i()){let s=o.aliases?.length?` (aliases: ${o.aliases.join(", ")})`:"";n.push(` ${o.usage}${s}`);for(let e of o.usages??[])n.push(` ${e}`)}n.push("","Global options:");for(let[o,s]of Object.entries(r).sort(([e],[a])=>e.localeCompare(a))){let e=o.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);n.push(s==="boolean"?` --${e}`:` --${e} <${s}>`)}return n.push("","Run `openpond <command> --help` for the selected command schema.","Arguments after `--` are passed through without option parsing."),n.join(`
2
+ import{d as r,f as i,k as p}from"./chunk-JFR34MIK.js";import"./chunk-3M53YXEI.js";import{a as t}from"./chunk-FTQLQJQV.js";function d(){console.log(m())}t(d,"printHelp");function m(){let n=["OpenPond CLI","","Usage:"," openpond [--no-open] [--hostname HOST] [--port PORT]"," openpond <command> [options] [-- passthrough...]"," openpond --version","","Commands:"];for(let o of i()){let s=o.aliases?.length?` (aliases: ${o.aliases.join(", ")})`:"";n.push(` ${o.usage}${s}`);for(let e of o.usages??[])n.push(` ${e}`)}n.push("","Global options:");for(let[o,s]of Object.entries(r).sort(([e],[a])=>e.localeCompare(a))){let e=o.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);n.push(s==="boolean"?` --${e}`:` --${e} <${s}>`)}return n.push("","Run `openpond <command> --help` for the selected command schema.","Arguments after `--` are passed through without option parsing."),n.join(`
3
3
  `)}t(m,"formatCliHelp");function l(){return["# OpenPond CLI command reference","","<!-- Generated by `pnpm --dir apps/cli docs:commands`; do not edit by hand. -->","","Parsing, aliases, command help, and this reference use the same authoritative registry.","",...i().map(o=>`## ${o.name}
4
4
 
5
5
  \`\`\`text
@@ -0,0 +1,3 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import"./chunk-PSZKG3E3.js";import"./chunk-MXLB6MEW.js";import{c as B}from"./chunk-XCTFXXVY.js";import{c as U,d as C,f as O}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-55UCBRIX.js";import"./chunk-6MI4KKWF.js";import"./chunk-QTEYV4TW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{a as u,c as A,d as x,i as v,j as S,k as R}from"./chunk-JEVA7YQL.js";import"./chunk-OGPHXXCD.js";import"./chunk-BAKCGJ5D.js";import"./chunk-Z6F6PYF4.js";import{d as k}from"./chunk-QPZNN5Q3.js";import"./chunk-GLUWATL5.js";import"./chunk-B5LKUQGM.js";import"./chunk-MJC26GOX.js";import"./chunk-5BFWDFPX.js";import"./chunk-6FA3GG5B.js";import"./chunk-UU7RXSJS.js";import{ga as y}from"./chunk-IFP6W4OW.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-JFR34MIK.js";import{f as m}from"./chunk-3M53YXEI.js";import{a as i}from"./chunk-FTQLQJQV.js";import{randomUUID as b}from"node:crypto";async function G(r,t){let e=t[0]||"smoke",n=await k(),l=await B(n,O(n)),c=P(n,r);if(e==="provider-catalog"||e==="providers-catalog"||e==="catalog"){let a=await E({apiBaseUrl:c,token:l});console.log(JSON.stringify(a,null,2));return}if(e==="models"||e==="model-list"){let a=await A({apiBaseUrl:c,token:l});console.log(JSON.stringify(a,null,2));return}if(e==="model"||e==="model-get"){let a=t[1]||o(r,"model");if(!a)throw new Error("usage: opchat model <model>");let p=await x({apiBaseUrl:c,token:l,model:a});console.log(JSON.stringify(p,null,2));return}if(e==="chat"){let a=o(r,"model")||"openpond-chat",p=o(r,"effort"),f=p?y.parse(p):void 0,d=o(r,"message")||o(r,"prompt")||"Reply with a short confirmation from OpChat.";if(!m(r.stream)){let s=await v({apiBaseUrl:c,token:l,model:a,reasoningEffort:f,messages:[{role:"user",content:d}]});console.log(JSON.stringify(s,null,2));return}let g="",h=null,w=null;for await(let s of S({apiBaseUrl:c,token:l,model:a,reasoningEffort:f,messages:[{role:"user",content:d}]}))s.type==="text_delta"?(g+=s.text,process.stdout.write(s.text)):s.type==="finish"?h=s.finishReason:s.type==="usage"&&(w=s.usage);process.stdout.write(`
3
+ `),console.log(JSON.stringify({finishReason:h,usage:w,text:g},null,2));return}if(e==="smoke"){let a=await R({apiBaseUrl:c,token:l,defaultModel:o(r,"model")||void 0,compatibilityModel:o(r,"compatibilityModel")||o(r,"compatModel")||void 0,skipStream:m(r.skipStream),skipTool:m(r.skipTool),log:i(p=>console.log(p),"log")});m(r.json)&&console.log(JSON.stringify(a,null,2));return}throw new Error("usage: opchat <provider-catalog|models|model|chat|smoke> [--opchat-api-base-url <url>] [chat --model <id> --effort <off|low|medium|high|xhigh|max>]")}i(G,"runOpChatCommand");async function E(r){let t=r.apiBaseUrl.trim().replace(/\/+$/,"");if(!t)throw new Error("OpChat API base URL is required.");let e=r.token.trim();if(!e)throw new Error("OpenPond API key is required.");let n=await fetch(`${t}/provider-catalog`,{method:"GET",headers:{Authorization:`Bearer ${e}`,Accept:"application/json","Content-Type":"application/json","x-openpond-client":"openpond-cli","x-openpond-request-id":b()}});if(!n.ok)throw new Error(`Hosted provider catalog failed: ${n.status} ${await T(n)}`);return n.json()}i(E,"getOpChatProviderCatalog");async function T(r){let t=await r.text().catch(()=>"");if(!t)return r.statusText||`HTTP ${r.status}`;try{let e=JSON.parse(t);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 n=e.error;return[n.code,n.message].filter(Boolean).join(": ")||t}return t}catch{return t}}i(T,"readResponseError");function P(r,t){let e=o(t,"opchatApiBaseUrl")||o(t,"opchatApiBaseurl")||o(t,"opChatApiBaseUrl")||o(t,"opChatApiBaseurl")||o(t,"opchatApiUrl")||o(t,"opChatApiUrl");return e?u({opChatApiBaseUrl:e}):u({apiBaseUrl:U(t)||r.apiBaseUrl,chatApiBaseUrl:C(t)||r.chatApiBaseUrl})}i(P,"resolveOpChatCliBaseUrl");function o(r,t){let e=r[t];return typeof e=="string"?e.trim():""}i(o,"optionString");export{G as runOpChatCommand};