openpond 0.2.54 → 0.2.55

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 (254) hide show
  1. package/dist/app-server.d.ts +1513 -99
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/actions-command-WTFZA7LF.js +2 -0
  4. package/dist/chunks/{app-layer-I7MZYVLL.js → app-layer-Y2UERCPY.js} +1 -1
  5. package/dist/chunks/app-server-runtime-2RM3N4I6.js +2 -0
  6. package/dist/chunks/apps-KDNWYO3G.js +2 -0
  7. package/dist/chunks/chunk-2DFR7PJ4.js +2460 -0
  8. package/dist/chunks/chunk-4CRM2ADK.js +2 -0
  9. package/dist/chunks/{chunk-7ZG3IT7C.js → chunk-4WEUCGJ3.js} +6 -6
  10. package/dist/chunks/chunk-55G6B54U.js +6 -0
  11. package/dist/chunks/chunk-73G5UYBB.js +12 -0
  12. package/dist/chunks/{chunk-DALJMSJG.js → chunk-ARQEJOEK.js} +24 -24
  13. package/dist/chunks/chunk-B7QDZPNX.js +2 -0
  14. package/dist/chunks/chunk-BFKYRQMA.js +2 -0
  15. package/dist/chunks/{chunk-AH22RHPS.js → chunk-BQAF5P7K.js} +2 -2
  16. package/dist/chunks/{chunk-YJ4PNAST.js → chunk-BTI4N7YO.js} +1 -1
  17. package/dist/chunks/chunk-C6D4WAYN.js +6 -0
  18. package/dist/chunks/chunk-CGBI2VYJ.js +2 -0
  19. package/dist/chunks/chunk-DLVPSCTB.js +2 -0
  20. package/dist/chunks/{chunk-UJ5EFSEC.js → chunk-G6JMQGX7.js} +1 -1
  21. package/dist/chunks/chunk-GGIG3XU7.js +3 -0
  22. package/dist/chunks/chunk-IODUCRBA.js +58 -0
  23. package/dist/chunks/chunk-JIMU3KDA.js +24 -0
  24. package/dist/chunks/chunk-JUJSA7KI.js +22 -0
  25. package/dist/chunks/chunk-K5SBVO3B.js +195 -0
  26. package/dist/chunks/chunk-KD3QVRIJ.js +21 -0
  27. package/dist/chunks/chunk-KGNCKIFP.js +3 -0
  28. package/dist/chunks/chunk-L4235TRQ.js +140 -0
  29. package/dist/chunks/{chunk-N5QNXMIS.js → chunk-MH3LHSGX.js} +1 -1
  30. package/dist/chunks/chunk-MVF3F5QS.js +2 -0
  31. package/dist/chunks/{chunk-N3DEA6PG.js → chunk-NNIRIUSY.js} +1 -1
  32. package/dist/chunks/{chunk-WITSXYEW.js → chunk-NOTXPD2T.js} +1 -1
  33. package/dist/chunks/{chunk-T5LE6R5S.js → chunk-OSIO7PLX.js} +1 -1
  34. package/dist/chunks/chunk-OULAKUIN.js +2 -0
  35. package/dist/chunks/chunk-OWNLDB2O.js +2 -0
  36. package/dist/chunks/{chunk-NAZ26IZL.js → chunk-Q7AXHFZV.js} +1 -1
  37. package/dist/chunks/chunk-QDHMP5FS.js +2 -0
  38. package/dist/chunks/chunk-QKD5OMDI.js +2 -0
  39. package/dist/chunks/{chunk-YD55Z5H3.js → chunk-QRAKXZOC.js} +10 -10
  40. package/dist/chunks/{chunk-JDLAHVAJ.js → chunk-R27YGT77.js} +1 -1
  41. package/dist/chunks/chunk-R2BSIRYL.js +3 -0
  42. package/dist/chunks/chunk-SHQOIROR.js +42 -0
  43. package/dist/chunks/chunk-STDMBJOQ.js +9 -0
  44. package/dist/chunks/chunk-T4QGDQHP.js +4 -0
  45. package/dist/chunks/{chunk-R3XFY7VL.js → chunk-TERVLCRG.js} +1 -1
  46. package/dist/chunks/{chunk-PA7XP42P.js → chunk-U2YMBCX7.js} +1 -1
  47. package/dist/chunks/{chunk-GXSTZBM6.js → chunk-UA5DA5I2.js} +1 -1
  48. package/dist/chunks/chunk-VJEZPDBS.js +5 -0
  49. package/dist/chunks/chunk-WDFLCNRC.js +8 -0
  50. package/dist/chunks/chunk-WZYRAR7X.js +16 -0
  51. package/dist/chunks/chunk-YDT7L3VZ.js +24 -0
  52. package/dist/chunks/chunk-YR5ID2SS.js +2 -0
  53. package/dist/chunks/chunk-YUPBAWBJ.js +554 -0
  54. package/dist/chunks/cli-465VC2WP.js +2 -0
  55. package/dist/chunks/{configuration-command-MATM4XR5.js → configuration-command-LAAP2EXT.js} +1 -1
  56. package/dist/chunks/connected-evidence-XM626247.js +2 -0
  57. package/dist/chunks/{continual-PKK2BOTB.js → continual-TTGJ6YTR.js} +1 -1
  58. package/dist/chunks/core-commands-W7EK552V.js +2 -0
  59. package/dist/chunks/datasets-QJWYTTQL.js +2 -0
  60. package/dist/chunks/desktop-test-3B2D34NF.js +3 -0
  61. package/dist/chunks/dist-FAJX2UBW.js +2 -0
  62. package/dist/chunks/{dist-4HV2W6V4.js → dist-HUAE2KFZ.js} +1 -1
  63. package/dist/chunks/{chunk-6VF3Q6QJ.js → dist-SKYG5LZO.js} +2 -4
  64. package/dist/chunks/evaluation-coordination-2MONR4AX.js +2 -0
  65. package/dist/chunks/experiment-improvements-WVQ5FK46.js +2 -0
  66. package/dist/chunks/experiments-S5UQ32QB.js +2 -0
  67. package/dist/chunks/extension-DWMY6D2R.js +4 -0
  68. package/dist/chunks/{help-WLKSACLZ.js → help-A72QDRNG.js} +1 -1
  69. package/dist/chunks/hosted-experiment-improvement-2OWOQLHC.js +3 -0
  70. package/dist/chunks/hosted-harness-runtime-TGFMAV7W.js +2 -0
  71. package/dist/chunks/hosted-profile-candidate-WQSI6HZO.js +3 -0
  72. package/dist/chunks/hosted-profile-compiler-Z2A4TEA6.js +2 -0
  73. package/dist/chunks/hosted-profile-evaluation-control-FKGARUEE.js +2 -0
  74. package/dist/chunks/hosted-profile-evaluation-inspection-QOY2JKV4.js +3 -0
  75. package/dist/chunks/hosted-profile-evaluation-preparation-WVP6CALP.js +3 -0
  76. package/dist/chunks/human-review-TGHQKXFZ.js +2 -0
  77. package/dist/chunks/{import-V3HUGRHR.js → import-4UE5XNSG.js} +1 -1
  78. package/dist/chunks/javascript-isolate-process-source-ZPQKKLR4.js +2 -0
  79. package/dist/chunks/javascript-verifier-worker-source-F3LSGPOY.js +2 -0
  80. package/dist/chunks/learning-R2XBMMEM.js +2 -0
  81. package/dist/chunks/opchat-WULL6CUP.js +3 -0
  82. package/dist/chunks/organizations-I37HISVX.js +2 -0
  83. package/dist/chunks/profile-NOZ6TVXL.js +3 -0
  84. package/dist/chunks/project-agent-T6XKC54C.js +2 -0
  85. package/dist/chunks/sandbox-command-STB47FRY.js +2 -0
  86. package/dist/chunks/{sandbox-template-BBGGPJMI.js → sandbox-template-LKGBDVJ4.js} +1 -1
  87. package/dist/chunks/sql-execution-process-source-B4HQM6ZV.js +2 -0
  88. package/dist/chunks/src-T3KWWCAH.js +322 -0
  89. package/dist/chunks/{src-CR6UZYTX.js → src-ZWJ5IO7A.js} +1 -1
  90. package/dist/chunks/{taskset-LUG3ZU6J.js → taskset-RNYDR4GS.js} +1 -1
  91. package/dist/chunks/{teams-bot-7I4BAUVO.js → teams-bot-H7XT23XB.js} +1 -1
  92. package/dist/chunks/{training-XHE6FVII.js → training-M6FAPRSJ.js} +1 -1
  93. package/dist/cli.js +1 -1
  94. package/dist/index.js +1 -1
  95. package/dist/web/assets/App-CLFfy_Av.js +154 -0
  96. package/dist/web/assets/App-CTlAPuCY.css +1 -0
  97. package/dist/web/assets/{AppDialog-BdusXgU0.js → AppDialog-CPHTPqrx.js} +1 -1
  98. package/dist/web/assets/{AppTerminalPanel-C4uRpnBz.js → AppTerminalPanel-BVj5Tj93.js} +2 -2
  99. package/dist/web/assets/AppsView-O69zEBY3.js +1 -0
  100. package/dist/web/assets/{BrowserSidebar-Bl7V6YO2.js → BrowserSidebar-Pr_Kpe8p.js} +1 -1
  101. package/dist/web/assets/{CartesianChart-BstFbsdn.js → CartesianChart-JPqo6YOf.js} +1 -1
  102. package/dist/web/assets/{CollaborationTabs-B8YAf0c1.js → CollaborationTabs-CAJcQFn2.js} +1 -1
  103. package/dist/web/assets/{CommandMenu-DZct7zUJ.js → CommandMenu-B-w53n9A.js} +1 -1
  104. package/dist/web/assets/{CommunityView-CR0-W-uG.js → CommunityView-DbZKK8_P.js} +1 -1
  105. package/dist/web/assets/{ComposerCreateImproveStrip-DR-Qo7b4.js → ComposerCreateImproveStrip-3_083PF4.js} +1 -1
  106. package/dist/web/assets/{GetStartedView-xqQoMMei.js → GetStartedView-D7JGm_6c.js} +1 -1
  107. package/dist/web/assets/HostedModelLearningReview-DwgMfZ7_.js +1 -0
  108. package/dist/web/assets/{HostedModelLearningSettings-De3i9wF4.js → HostedModelLearningSettings-JRfQadRl.js} +1 -1
  109. package/dist/web/assets/{LabModelVersionDetailPage-DAY1MmqP.js → LabModelVersionDetailPage-BUYflJY_.js} +1 -1
  110. package/dist/web/assets/{LabSkillSidebar-DLnIgnry.js → LabSkillSidebar-BBiqk7Rf.js} +1 -1
  111. package/dist/web/assets/LabsRoute-Ci6vUnSd.js +99 -0
  112. package/dist/web/assets/MainChatThread-BQK3oI2N.js +2 -0
  113. package/dist/web/assets/MainPane-D3ojiN-p.js +18 -0
  114. package/dist/web/assets/{MarkdownText-gJMuefaJ.js → MarkdownText-DOdOVFXL.js} +25 -25
  115. package/dist/web/assets/{NativeSkillSidebar-Dlxb8iOC.js → NativeSkillSidebar-CRI_ri8z.js} +1 -1
  116. package/dist/web/assets/{NewExperienceSwitcher-DM-cqJ-K.js → NewExperienceSwitcher-DhYtfE68.js} +1 -1
  117. package/dist/web/assets/{NewProjectDialog-Cu1q75gq.js → NewProjectDialog-D8sy1gOz.js} +1 -1
  118. package/dist/web/assets/{OutputsPage-DiXMkasl.js → OutputsPage-CbWgrhXA.js} +1 -1
  119. package/dist/web/assets/{ProjectsPage-DqiBHiCB.js → ProjectsPage-DLB67lyA.js} +1 -1
  120. package/dist/web/assets/RightChatPanelStack-ozSKnDyX.js +1 -0
  121. package/dist/web/assets/{RightSidebarHomePanel-CeSFJM5s.js → RightSidebarHomePanel-CKs3OwhD.js} +1 -1
  122. package/dist/web/assets/ScheduledWorkPage-Cafv_QnR.js +1 -0
  123. package/dist/web/assets/SettingsView-T1vYDPjh.js +5 -0
  124. package/dist/web/assets/{TeamChatView-DM0adMtj.js → TeamChatView-vIrmXOY_.js} +2 -2
  125. package/dist/web/assets/{TerminalOverlay-CFlH51DD.js → TerminalOverlay-CAmF__Dq.js} +1 -1
  126. package/dist/web/assets/{TrainingCreationPanel-CgIBVGha.js → TrainingCreationPanel-D75K0yk5.js} +1 -1
  127. package/dist/web/assets/{TrainingDraftPanel-Bbo3RRie.js → TrainingDraftPanel-D7XZePAk.js} +1 -1
  128. package/dist/web/assets/{UsageSettingsSection-CSRjJUSa.js → UsageSettingsSection-CYTmp7PG.js} +1 -1
  129. package/dist/web/assets/WorkSidebarPanel-CODMjVHY.js +1 -0
  130. package/dist/web/assets/WorkspaceDiffPanel-DQGoIjH9.js +14 -0
  131. package/dist/web/assets/WorkspaceEnvironmentMenu-c1pHDskn.js +63 -0
  132. package/dist/web/assets/{WorkspaceGitDialogs-Dgmg-6XG.js → WorkspaceGitDialogs-DrVtapQQ.js} +1 -1
  133. package/dist/web/assets/{WorkspaceMonacoEditor-BR4qxMgU.js → WorkspaceMonacoEditor-BCKzvSj2.js} +3 -3
  134. package/dist/web/assets/arrow-up-right-CP4hZdrJ.js +1 -0
  135. package/dist/web/assets/chunk-NOJECMB7-Bhcms-w5.js +1 -0
  136. package/dist/web/assets/{clipboard-BZzZ82Bk.js → clipboard-BgrXorn-.js} +1 -1
  137. package/dist/web/assets/{cloud-upload-CJPYPVl8.js → cloud-upload-B_zYztb6.js} +1 -1
  138. package/dist/web/assets/{cssMode-WC4Rg1l-.js → cssMode-DanjGgA8.js} +1 -1
  139. package/dist/web/assets/{folder-open-sLZJxLQy.js → folder-open-CdVKbtGq.js} +1 -1
  140. package/dist/web/assets/folder-plus-Cc5KElB6.js +1 -0
  141. package/dist/web/assets/{git-commit-horizontal-Cotm7KEC.js → git-commit-horizontal-CjGIIgRi.js} +1 -1
  142. package/dist/web/assets/{htmlMode-C6oZGeaB.js → htmlMode-DRGDF_UL.js} +1 -1
  143. package/dist/web/assets/index-B5re-RJy.css +1 -0
  144. package/dist/web/assets/{index-BxWTVKtn.js → index-BE-wXZ5R.js} +2 -2
  145. package/dist/web/assets/info-BLj0RvhA.js +1 -0
  146. package/dist/web/assets/{jsonMode-BET4LQIn.js → jsonMode-CCu0j2GD.js} +1 -1
  147. package/dist/web/assets/{lspLanguageFeatures-BPxA_-Kg.js → lspLanguageFeatures-s_Lhm7P6.js} +1 -1
  148. package/dist/web/assets/minimize-2-Cyg_zD9z.js +1 -0
  149. package/dist/web/assets/{monaco.contribution-DXzyQfVi.js → monaco.contribution-CAzXvYkn.js} +2 -2
  150. package/dist/web/assets/{monaco.contribution-DFzEyaHi.js → monaco.contribution-CY7mRgOB.js} +2 -2
  151. package/dist/web/assets/{monaco.contribution-7AUuf2NS.js → monaco.contribution-aUeLcBEg.js} +2 -2
  152. package/dist/web/assets/{monaco.contribution-BH6kkO4b.js → monaco.contribution-mUPNK9ra.js} +2 -2
  153. package/dist/web/assets/monitor-DZvOs_wC.js +1 -0
  154. package/dist/web/assets/play-BJPzemuY.js +1 -0
  155. package/dist/web/assets/{python-PzBkTjWx.js → python-B_qnnVaG.js} +1 -1
  156. package/dist/web/assets/{save-DpezrtH2.js → save-BDy9tA3E.js} +1 -1
  157. package/dist/web/assets/square-Cb2c5td4.js +1 -0
  158. package/dist/web/assets/{toggleHighContrast-Cto-fOXm.js → toggleHighContrast-MhO1JLyR.js} +1 -1
  159. package/dist/web/assets/{tsMode-BYA4LNc6.js → tsMode-DfBXJb9V.js} +1 -1
  160. package/dist/web/assets/{upload-C5YFNgtS.js → upload-D56kThRh.js} +1 -1
  161. package/dist/web/assets/{useLocalAgentSchedules-CnyTsqlf.js → useLocalAgentSchedules-DMnGfswi.js} +1 -1
  162. package/dist/web/assets/useProviderSettings-Bv5B9eNk.js +5 -0
  163. package/dist/web/assets/{useSessionTurnCache-DICuJSJW.js → useSessionTurnCache-ClAY8gze.js} +1 -1
  164. package/dist/web/assets/{wifi-off-nzHj7JXp.js → wifi-off-C9lWJmVm.js} +1 -1
  165. package/dist/web/assets/{workers-Dboaw6f_.js → workers-BYzrH8by.js} +1 -1
  166. package/dist/web/assets/{yaml-uuY5JmO8.js → yaml-D3T8UkT3.js} +1 -1
  167. package/dist/web/index.html +2 -2
  168. package/package.json +3 -3
  169. package/dist/chunks/actions-command-DSO6YOEE.js +0 -2
  170. package/dist/chunks/app-server-runtime-7AXV6JZI.js +0 -2
  171. package/dist/chunks/apps-TM74FFQB.js +0 -2
  172. package/dist/chunks/chunk-2JO2KWT3.js +0 -5
  173. package/dist/chunks/chunk-2SPZYBDN.js +0 -16
  174. package/dist/chunks/chunk-37DXASQL.js +0 -191
  175. package/dist/chunks/chunk-4EEH7MEC.js +0 -2
  176. package/dist/chunks/chunk-4SHKI3BH.js +0 -2
  177. package/dist/chunks/chunk-4TZHH5FC.js +0 -2409
  178. package/dist/chunks/chunk-5TNDPNS3.js +0 -2
  179. package/dist/chunks/chunk-6JAN4RMN.js +0 -42
  180. package/dist/chunks/chunk-7QEE4PBI.js +0 -8
  181. package/dist/chunks/chunk-BX4J2VDU.js +0 -2
  182. package/dist/chunks/chunk-EMKZVP7Z.js +0 -2
  183. package/dist/chunks/chunk-FPUUZQUP.js +0 -6
  184. package/dist/chunks/chunk-GCOUYYHG.js +0 -5
  185. package/dist/chunks/chunk-GS2NKNKG.js +0 -4
  186. package/dist/chunks/chunk-H2VT22JK.js +0 -2
  187. package/dist/chunks/chunk-HA7EFTPF.js +0 -23
  188. package/dist/chunks/chunk-IKWDL3RB.js +0 -17
  189. package/dist/chunks/chunk-L3KS6MOV.js +0 -2
  190. package/dist/chunks/chunk-NHFGEVVH.js +0 -518
  191. package/dist/chunks/chunk-NNF6KCHD.js +0 -3
  192. package/dist/chunks/chunk-PJM2G7SG.js +0 -21
  193. package/dist/chunks/chunk-PQHTZ5CP.js +0 -2
  194. package/dist/chunks/chunk-PYABBF53.js +0 -53
  195. package/dist/chunks/chunk-QRWPEW3Z.js +0 -24
  196. package/dist/chunks/chunk-QXVIIM4T.js +0 -2
  197. package/dist/chunks/chunk-SDEDAHV6.js +0 -160
  198. package/dist/chunks/chunk-TGIB24K4.js +0 -22
  199. package/dist/chunks/chunk-UE3DMPGM.js +0 -3
  200. package/dist/chunks/chunk-USKE34VR.js +0 -9
  201. package/dist/chunks/chunk-WV2APYWG.js +0 -2
  202. package/dist/chunks/chunk-XM26DGML.js +0 -3
  203. package/dist/chunks/chunk-YIB3J4RC.js +0 -2
  204. package/dist/chunks/chunk-YL6VFJ4P.js +0 -2
  205. package/dist/chunks/chunk-Z3D4C7BG.js +0 -12
  206. package/dist/chunks/cli-JVB345H2.js +0 -2
  207. package/dist/chunks/connected-evidence-YDPGNHLP.js +0 -2
  208. package/dist/chunks/core-commands-MTV4EKXY.js +0 -2
  209. package/dist/chunks/datasets-CP3IT47T.js +0 -2
  210. package/dist/chunks/desktop-test-IAZC5MAH.js +0 -3
  211. package/dist/chunks/dist-SAABJU5F.js +0 -2
  212. package/dist/chunks/evaluation-coordination-EPHLZXYM.js +0 -2
  213. package/dist/chunks/experiment-improvements-6JTOPA74.js +0 -2
  214. package/dist/chunks/experiments-XHPFGECH.js +0 -2
  215. package/dist/chunks/extension-GX7DLW2X.js +0 -4
  216. package/dist/chunks/hosted-experiment-improvement-HAB3UE6A.js +0 -3
  217. package/dist/chunks/hosted-harness-runtime-YM23QNDK.js +0 -2
  218. package/dist/chunks/hosted-profile-candidate-EOBGKQAS.js +0 -3
  219. package/dist/chunks/hosted-profile-compiler-SCVJI2CP.js +0 -2
  220. package/dist/chunks/hosted-profile-evaluation-control-RJ6XJZCS.js +0 -2
  221. package/dist/chunks/hosted-profile-evaluation-inspection-OC4XNGL2.js +0 -3
  222. package/dist/chunks/hosted-profile-evaluation-preparation-ZD4FM3FD.js +0 -3
  223. package/dist/chunks/human-review-AAVMISBF.js +0 -2
  224. package/dist/chunks/learning-FNBEIAY6.js +0 -2
  225. package/dist/chunks/opchat-QK43DXTY.js +0 -3
  226. package/dist/chunks/organizations-SRPAWKC7.js +0 -2
  227. package/dist/chunks/profile-C6CQNVYE.js +0 -3
  228. package/dist/chunks/project-agent-GZV5HNYI.js +0 -2
  229. package/dist/chunks/sandbox-command-4TJXQTKT.js +0 -2
  230. package/dist/chunks/src-NE6R4XC6.js +0 -329
  231. package/dist/web/assets/App-CO2F717V.css +0 -1
  232. package/dist/web/assets/App-CuhaCsfb.js +0 -235
  233. package/dist/web/assets/AppsView-BS1czXUP.js +0 -1
  234. package/dist/web/assets/HostedModelLearningReview-CHxxf_Lu.js +0 -1
  235. package/dist/web/assets/LabsRoute-CXJRJMhr.js +0 -99
  236. package/dist/web/assets/MainChatThread-BwAla81W.js +0 -2
  237. package/dist/web/assets/MainPane-CakOBCHw.js +0 -19
  238. package/dist/web/assets/RightChatPanelStack-VaOOmxwd.js +0 -1
  239. package/dist/web/assets/ScheduledWorkPage-D1jRQxFs.js +0 -1
  240. package/dist/web/assets/SettingsView-RA9OXgcu.js +0 -5
  241. package/dist/web/assets/WorkSidebarPanel-DwlEMEoG.js +0 -1
  242. package/dist/web/assets/WorkspaceDiffPanel-pGVezNMw.js +0 -14
  243. package/dist/web/assets/WorkspaceEnvironmentMenu-Byjngd9V.js +0 -32
  244. package/dist/web/assets/arrow-up-right-H0pvnH2s.js +0 -1
  245. package/dist/web/assets/chunk-UHVJOMWN-BqXRe639.js +0 -1
  246. package/dist/web/assets/folder-plus-C84wrpt_.js +0 -1
  247. package/dist/web/assets/index-dSmk3FLJ.css +0 -1
  248. package/dist/web/assets/info-Dc81lEfw.js +0 -1
  249. package/dist/web/assets/minimize-2-Bs7MVN3C.js +0 -1
  250. package/dist/web/assets/monitor-DXL019Wf.js +0 -1
  251. package/dist/web/assets/play-CXkxUZeU.js +0 -1
  252. package/dist/web/assets/square-oy7f5Ce6.js +0 -1
  253. package/dist/web/assets/useProviderSettings-B_KeQjE5.js +0 -5
  254. /package/dist/chunks/{chunk-OGPHXXCD.js → chunk-BT5YNE5U.js} +0 -0
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as p,b as v}from"./chunk-G6JMQGX7.js";import"./chunk-NPOHW5OU.js";import"./chunk-NNIRIUSY.js";import"./chunk-U2YMBCX7.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-BTI4N7YO.js";import"./chunk-BQAF5P7K.js";import{c as r}from"./chunk-3M53YXEI.js";import"./chunk-B7QDZPNX.js";import{v as d,w as s,x as h,y as w}from"./chunk-WZYRAR7X.js";import"./chunk-BT5YNE5U.js";import"./chunk-TERVLCRG.js";import"./chunk-GLUWATL5.js";import"./chunk-73G5UYBB.js";import"./chunk-YR5ID2SS.js";import"./chunk-55G6B54U.js";import"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as m}from"./chunk-FTQLQJQV.js";async function b(t,e,n){let[a,o]=n,i=r(e,"actor");if(!i||!a||n.length>2)throw new Error("Select --actor, --team and an evaluation command.");if(e.local!==!0&&e.local!=="true")throw new Error("These evaluation owners currently run through the authenticated native bridge. Select --local --server-url with its loopback origin.");let c={...await v(e),actorId:i,projectId:r(e,"project")||null},l=a==="request"?await p(e):a==="list"?t==="schedule"?{operation:a,...r(e,"cursor")?{cursor:r(e,"cursor")}:{},limit:Number(r(e,"limit")||50)}:{operation:a}:{operation:a,id:o};if((a==="request"||a==="list")&&o)throw new Error("This operation does not accept an additional resource id.");let u=AbortSignal.timeout(6e4),f=t==="schedule"?await new s(c).command(d.parse(l),u):await new w(c).command(h.parse(l),u);console.log(JSON.stringify(f,null,2))}m(b,"runEvaluationCoordinationCommand");export{b as runEvaluationCoordinationCommand};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as s,b as l}from"./chunk-G6JMQGX7.js";import"./chunk-NPOHW5OU.js";import"./chunk-NNIRIUSY.js";import"./chunk-U2YMBCX7.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-BTI4N7YO.js";import"./chunk-BQAF5P7K.js";import{c as e}from"./chunk-3M53YXEI.js";import"./chunk-B7QDZPNX.js";import{t as m,u as c}from"./chunk-WZYRAR7X.js";import"./chunk-BT5YNE5U.js";import"./chunk-TERVLCRG.js";import"./chunk-GLUWATL5.js";import"./chunk-73G5UYBB.js";import"./chunk-YR5ID2SS.js";import"./chunk-55G6B54U.js";import"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";async function f(t,i){let[r,o]=i,n=e(t,"actor");if(!n||!r||i.length>2)throw new Error("usage: improve <list|read|instructions|request> [id] --team <id> --actor <owner-id> [--input-file <path>] [--local --server-url <loopback-origin>]");let u=m.parse(r==="request"?await s(t):r==="list"?{operation:r,limit:Number(e(t,"limit")||30),...e(t,"cursor")?{cursor:e(t,"cursor")}:{}}:{operation:r,id:o});if(r==="request"&&o||r==="list"&&o)throw new Error("This operation does not accept a candidate id.");let d=new c({...await l(t),actorId:n});console.log(JSON.stringify(await d.command(u,AbortSignal.timeout(6e4)),null,2))}a(f,"runExperimentImprovementsCommand");export{f as runExperimentImprovementsCommand};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as ie,c as ae}from"./chunk-NPOHW5OU.js";import"./chunk-QDHMP5FS.js";import{Db as j,ib as te,jb as ne,ta as C,vb as U,wb as I,xb as re,yb as k}from"./chunk-YDT7L3VZ.js";import"./chunk-NNIRIUSY.js";import{c as X}from"./chunk-U2YMBCX7.js";import{c as Z,f as ee}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-BTI4N7YO.js";import"./chunk-BQAF5P7K.js";import{c as o}from"./chunk-3M53YXEI.js";import"./chunk-B7QDZPNX.js";import{b as K,c as M,d as P,q as W,r as Y}from"./chunk-WZYRAR7X.js";import"./chunk-BT5YNE5U.js";import{d as V}from"./chunk-TERVLCRG.js";import{b as Q}from"./chunk-GLUWATL5.js";import"./chunk-73G5UYBB.js";import"./chunk-YR5ID2SS.js";import"./chunk-55G6B54U.js";import{$a as T,Ra as F,db as D,eb as G,hb as B,ib as J}from"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import{m as H}from"./chunk-KGNCKIFP.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as x}from"./chunk-FTQLQJQV.js";import{readFile as N,stat as z}from"node:fs/promises";var w=e.string().trim().min(1).max(500),oe=e.string().regex(/^[a-f0-9]{64}$/),ue=e.object({schemaVersion:e.literal("openpond.experimentCaseInspection.v1"),teamId:w,executionId:w,manifestHash:oe,receiptId:w,taskId:w,seed:e.string().min(1),input:e.record(e.string(),e.unknown()).nullable(),output:e.unknown().nullable(),error:e.string().nullable(),events:e.array(e.record(e.string(),e.unknown())).max(25),nextEventCursor:w.nullable(),eventCount:e.number().int().nonnegative()}).strict(),fe=ue.extend({contentHash:oe}).strict(),v=class{constructor(s){this.options=s;let n=new URL(s.baseUrl);if(!["http:","https:"].includes(n.protocol)||n.username||n.password||n.search||n.hash||!s.apiKey.trim()||!s.teamId.trim())throw new Error("A clean API origin and workspace credentials are required.");this.baseUrl=n.toString().replace(/\/+$/,"")}options;static{x(this,"OpenPondExperimentInspectionClient")}baseUrl;async case(s,n,r={}){let b=new URLSearchParams(r.afterId?{afterId:w.parse(r.afterId)}:{}),h=await(this.options.fetch??fetch)(`${this.baseUrl}/v1/experiments/${encodeURIComponent(w.parse(s))}/cases/${encodeURIComponent(w.parse(n))}?${b}`,{signal:r.signal,redirect:"error",headers:{Authorization:`Bearer ${this.options.apiKey}`,"X-OpenPond-Team-Id":this.options.teamId,Accept:"application/json"}}),S=await h.json();if(!h.ok)throw new Error(e.object({message:e.string()}).parse(S).message);let a=fe.parse(S),{contentHash:l,...i}=a;if(H(i)!==l||a.teamId!==this.options.teamId||a.executionId!==s||a.receiptId!==n||r.manifestHash&&a.manifestHash!==r.manifestHash||a.events.length>a.eventCount)throw new Error("Case inspection differs from its requested workspace, execution or retained content.");return a}};import{readFile as Re,stat as He}from"node:fs/promises";var q=e.object({source:e.enum(["local","github","openpond_git"]),repositoryId:e.string().trim().min(1),profileId:e.string().trim().min(1)}),Ue=e.object({ref:q,revision:e.string().nullable(),sourceHash:e.string()});var m=e.string().trim().min(1).max(200),d=e.string().regex(/^[a-f0-9]{64}$/),ce=e.enum(["queued","running","cancelling","completed","failed","cancelled","interrupted"]),me=e.object({providerId:e.enum(["openpond","custom-openai-compatible","claude-code"]),modelId:e.string().trim().min(1).max(500),configurationHash:d,maxOutputTokens:e.number().int().positive().max(262144),temperature:e.number().min(0).max(2).optional(),topP:e.number().positive().max(1).optional(),messages:e.array(e.object({role:e.enum(["system","user","assistant"]),content:e.string().max(262144)}).strict()).max(200)}).strict(),Te=e.object({configuration:k,package:C}).strict(),De=e.object({configuration:k,expectedPackageHash:d.optional()}).strict(),Ge=e.object({schemaVersion:e.literal("openpond.localExperimentDefinition.v1"),location:e.literal("local"),id:m,teamId:m,ownerActorId:m,revision:e.number().int().positive(),configuration:k,model:me,packageHash:d,graders:e.array(I).min(1).max(100),availableGraders:e.array(I).min(1).max(1e3),createdAt:e.iso.datetime(),updatedAt:e.iso.datetime(),contentHash:d}).strict(),Be=e.object({operationId:m,definition:U}).strict(),Je=e.object({teamId:m,id:m}).strict(),Ke=e.object({teamId:m,projectId:m.optional(),status:ce.optional(),datasetHash:d.optional(),search:e.string().max(100).optional(),afterId:m.optional(),limit:e.number().int().min(1).max(100).default(30)}).strict(),O=e.object({schemaVersion:e.literal("openpond.localExperimentExecution.v1"),location:e.literal("local"),id:m,teamId:m,ownerActorId:m,operationId:m,definition:U,kind:e.enum(["target","scoring"]),executionHash:d,sourceExecution:e.object({id:m,executionHash:d}).strict().nullable(),packageHash:d,maximumCostUsd:e.number().finite().positive(),status:ce,createdAt:e.iso.datetime(),completedAt:e.iso.datetime().nullable(),counts:e.object({pending:e.number().int().nonnegative(),running:e.number().int().nonnegative(),completed:e.number().int().nonnegative(),failed:e.number().int().nonnegative(),cancelled:e.number().int().nonnegative(),unknown:e.number().int().nonnegative()}).strict(),usage:e.object({knownCostUsd:e.number().finite().nonnegative(),costUsd:e.number().finite().nonnegative().nullable(),heldUsd:e.number().finite().nonnegative(),uncertainRequests:e.number().int().nonnegative()}).strict(),cleanupComplete:e.boolean(),error:e.string().max(2e3).nullable()}).strict(),xe=O.omit({definition:!0});function _(t,s){t.kind==="scoring"!=(t.sourceExecution!==null)&&s.addIssue({code:"custom",message:"Only retained scoring passes name an original execution."}),["completed","failed","cancelled","interrupted"].includes(t.status)&&(!t.completedAt||t.counts.pending||t.counts.running)&&s.addIssue({code:"custom",message:"Terminal local execution requires complete population accounting."}),["completed","cancelled"].includes(t.status)&&!t.cleanupComplete&&s.addIssue({code:"custom",message:"Successful completion or cancellation requires confirmed local transport cleanup."}),t.usage.uncertainRequests>0&&t.usage.costUsd!==null&&s.addIssue({code:"custom",message:"Uncertain provider charges cannot claim a measured total."})}x(_,"validateLocalExecutionState");var Me=O.superRefine(_),y=xe.superRefine(_),he=e.object({configuration:j,package:C}).strict(),ge=e.object({configuration:j,expectedPackageHash:e.string().regex(/^[a-f0-9]{64}$/).optional()}).strict(),A=e.object({configuration:j,model:me,packageHash:e.string().regex(/^[a-f0-9]{64}$/),graders:e.array(I).min(1).max(100),availableGraders:e.array(I).min(1).max(1e3),retainedConfigurationHash:e.string().regex(/^[a-f0-9]{64}$/).optional(),configurationHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().superRefine((t,s)=>{let{configurationHash:n,...r}=t;H(r)!==n&&s.addIssue({code:"custom",message:"Local configuration snapshot bytes changed."})}),{definition:Ve,...Ee}=O.shape,L=e.object({...Ee,kind:e.literal("target"),...A.shape}).strict().superRefine((t,s)=>{let n={configuration:t.configuration,model:t.model,packageHash:t.packageHash,graders:t.graders,availableGraders:t.availableGraders,...t.retainedConfigurationHash?{retainedConfigurationHash:t.retainedConfigurationHash}:{},configurationHash:t.configurationHash};_(t,s),A.safeParse(n).success||s.addIssue({code:"custom",message:"Local Experiment configuration changed."}),(t.operationId!==t.configuration.operationId||t.teamId!==t.configuration.request.teamId||t.maximumCostUsd!==t.configuration.maximumCostUsd)&&s.addIssue({code:"custom",message:"Local Experiment differs from its sealed admission."})}),we=e.object({items:e.array(L).max(100),nextCursor:e.string().nullable()}).strict(),be=e.object({teamId:e.string().min(1).max(200),id:e.string().min(1).max(200),configurationHash:e.string().regex(/^[a-f0-9]{64}$/).optional()}).strict(),Se=e.object({operationId:m,execution:e.object({id:m,executionHash:d}).strict(),graderPackage:C,graders:e.array(re).min(1).max(100),maximumCostUsd:e.number().finite().positive().max(1e4)}).strict(),Qe=Se.omit({graderPackage:!0}),Ie=T,Le=e.object({sessionId:m,turnId:m,source:F,profileRef:q,admissionHash:d,modelConfigurationHash:d,traceHash:d,runtimeEventRefs:e.array(m).max(1e4),startedAt:e.iso.datetime(),completedAt:e.iso.datetime(),outputHash:d,partialOutputAvailable:e.boolean()}).strict(),le=e.object({receiptId:m,taskId:m,seed:e.string(),status:e.enum(["pending","running","completed","failed","cancelled","unknown"]),input:e.record(e.string(),e.unknown()),policyVisibleContext:e.record(e.string(),e.unknown()),output:e.string().nullable(),messages:e.array(e.unknown()).max(4002),grade:ne.nullable(),error:e.string().nullable(),native:Ie.optional(),profileNative:Le.optional(),externalProcess:te.optional()}).strict(),Xe=e.object({execution:e.union([L,y]),cases:e.array(le).max(1e4),contentHash:d}).strict(),ye=e.object({items:e.array(e.object({sequence:e.number().int().positive(),type:e.string().min(1),payload:e.unknown()}).strict()).max(500),nextCursor:e.number().int().positive().nullable()}).strict(),We=e.object({location:e.literal("local"),execution:e.union([L,y]),case:le,trace:ye}).strict(),Ye=e.object({items:e.array(y).max(100),nextCursor:m.nullable()}).strict(),Ze=e.object({execution:y,graders:e.array(I).min(1).max(100),graderPackageHash:d}).strict(),se=e.object({execution:y,manifest:D,result:G}).strict().superRefine((t,s)=>{try{if(B(t),t.manifest.id!==t.execution.id||t.manifest.teamId!==t.execution.teamId||t.manifest.lineage?.execution.id!==(t.execution.sourceExecution?.id??t.execution.id)||t.manifest.lineage.execution.contentHash!==(t.execution.sourceExecution?.executionHash??t.execution.executionHash)||t.manifest.lineage.scoringPassId!==(t.execution.kind==="scoring"?t.execution.id:null)||t.manifest.maximumCostUsd!==t.execution.maximumCostUsd)throw new Error("Portable evidence differs from its retained local execution.")}catch(n){s.addIssue({code:"custom",message:n instanceof Error?n.message:"Local portable evidence verification failed."})}}),pe=e.object({location:e.literal("local"),baseline:se,candidate:se}).strict();async function de(t,s){let[n,r,b]=s,h=o(t,"team");if(t.revision!==void 0)throw new Error("A local Experiment is one immutable run; read it by id rather than a saved configuration revision.");if(n!=="read"&&t.contentHash!==void 0)throw new Error("An exact configuration hash requires the local read action.");if(!h||!n||s.length>(n==="compare"?3:2))throw new Error("Local Experiments require an action and --team; use --server-url for an existing local server.");let S=o(t,"serverUrl")||process.env.OPENPOND_LOCAL_API_URL||ie,a=new URL(S);if(a.protocol!=="http:"||!["localhost","127.0.0.1"].includes(a.hostname)||a.username||a.password||a.search||a.hash||a.pathname!=="/")throw new Error("Local Experiments require an HTTP loopback server origin.");let l=await ae(a.origin);async function i(u,g){let c=await l(new URL("/v1/local-experiments",a),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:h,action:u,payload:g})}),p=await c.json();if(!c.ok)throw new Error(typeof p.error=="string"?p.error:`Local Experiment request failed (${c.status}).`);return p}x(i,"command");async function E(){let u=o(t,"inputFile");if(!u||(await He(u)).size>67108864)throw new Error("Provide a bounded --input-file with exact local configuration and retained package bytes.");return JSON.parse(await Re(u,"utf8"))}x(E,"input");let f;if(n==="prepare-harness"){if(r)throw new Error("Local Profile preparation accepts --input-file rather than an id.");f=await i("prepareHarness",await E())}else if(n==="run"){if(r)throw new Error("Local Run accepts reviewed configuration through --input-file rather than an id.");let u=await E();f=await i(u.package?"run":"runFromRelease",u)}else if(n==="list"){if(r)throw new Error("Local List does not accept an id.");let u=o(t,"status"),g=o(t,"limit"),c=o(t,"project"),p=o(t,"afterId"),R=o(t,"datasetHash"),$=o(t,"search");f=await i("list",{...u?{status:u}:{},...c?{projectId:c}:{},...R?{datasetHash:R}:{},...$?{search:$}:{},...p?{afterId:p}:{},...g?{limit:Number(g)}:{}})}else{if(!r)throw new Error(`${n} requires a local Experiment or scoring pass id.`);let u=o(t,"afterId"),g=o(t,"limit");if(n==="duplicate"){let c=o(t,"operationId");if(!c)throw new Error("Duplicate requires --operation-id for safe replay.");let p=L.parse(await i("read",{id:r})),R=P.parse({...p.configuration,operationId:c,request:{...p.configuration.request,operationId:c},sourceExperimentId:p.id});f=await i("runFromRelease",{configuration:R,expectedPackageHash:p.packageHash})}else if(n==="passes")f=await i("passes",{executionId:r,...u?{afterId:u}:{},...g?{limit:Number(g)}:{}});else if(n==="case"){let c=o(t,"receiptId"),p=o(t,"afterSequence");if(!c)throw new Error("Local case inspection requires --receipt-id from the retained execution.");f=await i("case",{id:r,receiptId:c,...p?{afterSequence:Number(p)}:{},...g?{limit:Number(g)}:{}})}else if(n==="score"){let c=await E();if(c.execution?.id!==r)throw new Error("Local scoring input belongs to a different retained execution.");f=await i("score",c)}else if(n==="compare"){if(!b)throw new Error("Local Compare requires baseline and candidate execution ids.");let c=pe.parse(await i("compare",{baselineId:r,candidateId:b}));f={...c,comparison:J(c.baseline,c.candidate)}}else if(n==="read"){let c=o(t,"contentHash");f=await i("read",{id:r,...c?{configurationHash:c}:{}})}else if(["status","cancel","result","pass"].includes(n))f=await i(n,{id:r});else if(n==="cancel-pass")f=await i("cancel",{id:r});else if(n==="pass-result")f=await i("result",{id:r});else throw new Error(`Local Experiment action is unavailable: ${n}`)}console.log(JSON.stringify(f,null,2))}x(de,"runLocalExperimentsCommand");async function Et(t,s){if(t.local===!0||t.local==="true")return de(t,s);if(t.revision!==void 0||t.contentHash!==void 0)throw new Error("Experiments retain their immutable configuration on the run; definition revisions are not selectable.");let[n,r]=s,b=o(t,"team");if(!b||!n||s.length>(n==="compare"?3:2))throw new Error("usage: experiments <prepare-harness|run|read|list|status|cancel|duplicate|score|passes|pass|cancel-pass|pass-result|result|compare|case> [id] [candidate-id] --team <id> [--input-file <path>] [--operation-id <id>]");let h=await V(),S={teamId:b,apiKey:await X(h,ee(h)),baseUrl:Z(t)??h.apiBaseUrl??Q},a=new Y(S),l;if(n==="prepare-harness"){let i=o(t,"inputFile");if(!i||r||(await z(i)).size>1048576)throw new Error("Harness preparation requires a bounded --input-file with its released target, model and ceiling.");l=await a.prepareHarness(M.parse(JSON.parse(await N(i,"utf8"))))}else if(n==="run"){let i=o(t,"inputFile");if(!i||r)throw new Error("Run requires --input-file with the reviewed configuration and stable operationId.");if((await z(i)).size>1048576)throw new Error("Experiment input exceeds one MiB.");l=await a.run(P.parse(JSON.parse(await N(i,"utf8"))))}else if(n==="list"){if(r)throw new Error("List does not accept an Experiment id.");let i=o(t,"limit");l=await a.list(K.parse({projectId:o(t,"project")||void 0,datasetHash:o(t,"datasetHash")||void 0,search:o(t,"search")||void 0,status:o(t,"status")||void 0,afterId:o(t,"afterId")||void 0,...i?{limit:Number(i)}:{}}))}else{if(!r)throw new Error(`${n} requires an id.`);if(n==="read")l=await a.get(r);else if(n==="status")l=await a.get(r);else if(n==="cancel")l=await a.cancel(r);else if(n==="duplicate"){let i=o(t,"operationId");if(!i)throw new Error("Duplicate requires a stable --operation-id for the new Experiment.");l=await a.duplicate(r,i)}else if(n==="score"){let i=o(t,"inputFile");if(!i||(await z(i)).size>1048576)throw new Error("Score requires --input-file containing an exact execution reference, grader releases and explicit ceiling, within one MiB.");let E=W.parse(JSON.parse(await N(i,"utf8")));if(E.execution.id!==r)throw new Error("Scoring input belongs to a different execution.");l=await a.score(E)}else if(n==="passes")l=await a.scoringPasses(r,{afterId:o(t,"afterId")||void 0});else if(n==="pass")l=await a.scoringPass(r);else if(n==="cancel-pass")l=await a.cancelScoringPass(r);else if(n==="pass-result")l=await a.scoringResult(r);else if(n==="result")l=await a.result(r);else if(n==="case"){let i=o(t,"receiptId");if(!i)throw new Error("Case inspection requires --receipt-id from the retained Experiment.");let E=await a.get(r);l=await new v(S).case(r,i,{manifestHash:E.manifest.contentHash,afterId:o(t,"afterId")||void 0})}else if(n==="compare"){if(!s[2])throw new Error("Compare requires a baseline and candidate execution id.");l=await a.compare(r,s[2])}else throw new Error(`Unknown Experiment action: ${n}`)}console.log(JSON.stringify(l,null,2))}x(Et,"runExperimentsCommand");export{Et as runExperimentsCommand};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as L,x as se}from"./chunk-MH3LHSGX.js";import"./chunk-R27YGT77.js";import"./chunk-6FA3GG5B.js";import{f as z}from"./chunk-3M53YXEI.js";import"./chunk-BT5YNE5U.js";import"./chunk-TERVLCRG.js";import{f as F}from"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import"./chunk-KGNCKIFP.js";import{b as c}from"./chunk-ES2ISFJC.js";import{f as ne,h as q,p as D,r as ie}from"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";var u=class extends Error{static{r(this,"GithubExtensionError")}code;status;constructor(t,i){super(t),this.name="GithubExtensionError",this.code=i.code,this.status=i.status??400}};import{createHash as de}from"node:crypto";import B from"node:path";var oe="HEAD",re=64,ae=512,ue=20*1024*1024,V=5*1024*1024,pe=8,Ge=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,le=/^[A-Za-z0-9_.-]+$/,ce=new Set(["agents","assets","references","scripts"]);function he(e={}){let t=e.fetch??fetch,i=e.githubToken?.trim()||process.env.GITHUB_TOKEN?.trim()||process.env.GH_TOKEN?.trim()||null;return{async resolve(n){let s=await Ie(n,t,i);return{preview:await Ae(s,t,i),files:ge(s)}},async download(n,s){await Me({resolution:n,fetchImpl:t,githubToken:i,writeFile:s})}}}r(he,"createGithubSourceClient");function k(e){let t=e.trim(),i="",n="";if(/^(?:https?:\/\/)?github\.com\//i.test(t)){let l=new URL(t.startsWith("http")?t:`https://${t}`);if(l.hostname.toLowerCase()!=="github.com")throw M(e);let a=l.pathname.replace(/^\/+|\/+$/g,"").split("/");if(a.length!==2)throw M(e);[i="",n=""]=a}else{let a=t.replace(/^github:/i,"").replace(/^\/+|\/+$/g,"").split("/");if(a.length!==2)throw M(e);[i="",n=""]=a}if(n=n.replace(/\.git$/i,""),!le.test(i)||!le.test(n))throw M(e);let s=i.toLowerCase(),o=n.toLowerCase();return{id:`github:${s}/${o}`,owner:s,repo:o,repositoryUrl:`https://github.com/${s}/${o}`}}r(k,"parseGithubExtensionSource");async function Ie(e,t,i){let n=k(e.source),s=e.ref?.trim()||oe,o=await K(t,i,`/repos/${n.owner}/${n.repo}`),l=s===oe?o.default_branch?.trim()||"main":s,a=await K(t,i,`/repos/${n.owner}/${n.repo}/commits/${encodeURIComponent(l)}`),w=a.sha?.trim(),v=a.commit?.tree?.sha?.trim();if(!w||!v)throw new u("GitHub returned an incomplete commit response.",{code:"github_invalid_commit",status:502});let P=await K(t,i,`/repos/${n.owner}/${n.repo}/git/trees/${v}?recursive=1`);if(P.truncated)throw new u("The GitHub repository tree is too large to install safely.",{code:"github_tree_truncated"});let S=(P.tree??[]).filter(He),x=Ce(S);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>re)throw new u(`Extension contains more than ${re} skills.`,{code:"extension_too_many_skills"});je(x);let A=S.find(g=>g.type==="blob"&&/^readme(?:\.[^/]+)?$/i.test(g.path))??null;return{identity:n,requestedRef:s,resolvedCommit:w,tree:S,skillPackages:x,readme:A}}r(Ie,"resolveSource");async function Ae(e,t,i){let n=await we(e.skillPackages,pe,async a=>{let w=await Ne(e,a.entry,t,i);return Te(a,w)}),s=qe(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 o=n.flatMap(a=>a.validationMessages.map(w=>`${a.relativePath}: ${w}`)),l=ge(e);return{...e.identity,source:"github",requestedRef:e.requestedRef,resolvedCommit:e.resolvedCommit,sourcePath:null,readmePath:e.readme?.path??null,packageHash:Ue(l),skills:n.sort((a,w)=>a.name.localeCompare(w.name)),validationStatus:o.length===0?"valid":"error",validationMessages:o}}r(Ae,"buildPreview");function Te(e,t){let i=L(t),n=e.root==="."?null:B.posix.basename(e.root),s=i.name??n??"invalid-skill",o=[...i.messages];Ge.test(s)||o.push("Skill name must be lowercase kebab-case."),n&&s!==n&&o.push(`Skill name must match its directory name (${n}).`);let l=e.files.filter(a=>a.path!==e.entry.path).map(a=>ze(e.root,a.path)).sort();return{name:s,description:i.description??"",relativePath:e.root==="."?"SKILL.md":`${e.root}/SKILL.md`,sourcePath:"",charCount:t.length,sourceHash:de("sha256").update(t).digest("hex"),resourceFiles:l,validationStatus:o.length===0?"valid":"error",validationMessages:[...new Set(o)]}}r(Te,"previewSkill");function Ce(e){let t=[],i=e.find(a=>a.type==="blob"&&a.path==="SKILL.md");i&&t.push({root:".",entry:i});let n=e.filter(a=>a.type==="blob"&&a.path.endsWith("/SKILL.md")),s=n.filter(a=>Le(a.path)),o=s.length>0?s:n,l=new Set(o.map(a=>B.posix.dirname(a.path)));for(let a of o){let w=B.posix.dirname(a.path);[...l].some(v=>v!==w&&w.startsWith(`${v}/`))||t.push({root:w,entry:a})}return t.map(({root:a,entry:w})=>{let v=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 ce.has(A)}),P=e.find(x=>x.type!=="blob"&&x.type!=="tree"&&(a==="."?x.path==="SKILL.md"||ce.has(x.path.split("/",1)[0]??""):x.path.startsWith(`${a}/`))),S=v.find(x=>x.mode==="120000");if(P||S)throw new u(`Skill package ${a} contains a symlink or submodule.`,{code:"extension_unsafe_entry"});return{root:a,entry:w,files:v}})}r(Ce,"discoverSkillPackages");function Le(e){let t=e.split("/");if(t.at(-1)!=="SKILL.md")return!1;let i=t.slice(0,-1);if(i.length<2)return!1;let n=i.lastIndexOf("skills");if(n<0||n>2)return!1;let s=i.slice(0,n),o=i.slice(n+1);if(o.length<1||o.length>2)return!1;if(n===0)return!0;let l=s[0]??"";return l.startsWith(".")||l==="agent"||l==="data"}r(Le,"isStandardAgentSkillsPath");function ge(e){let t=new Map;e.readme&&t.set(e.readme.path,e.readme);for(let i of e.skillPackages)for(let n of i.files)t.set(n.path,n);return[...t.values()].sort((i,n)=>i.path.localeCompare(n.path))}r(ge,"filesToDownload");async function Me(e){let t=0;await we(e.resolution.files,pe,async i=>{let n=await fe({owner:e.resolution.preview.owner,repo:e.resolution.preview.repo,commit:e.resolution.preview.resolvedCommit,file:i,fetchImpl:e.fetchImpl,githubToken:e.githubToken});if(t+=n.byteLength,t>ue)throw new u("Extension download exceeds the maximum allowed size.",{code:"extension_too_large"});await e.writeFile(i.path,n,i.mode==="100755")})}r(Me,"downloadFiles");async function Ne(e,t,i,n){let s=await fe({owner:e.identity.owner,repo:e.identity.repo,commit:e.resolvedCommit,file:t,fetchImpl:i,githubToken:n});return new TextDecoder("utf-8",{fatal:!0}).decode(s)}r(Ne,"downloadText");async function fe(e){let t=e.file.path.split("/").map(encodeURIComponent).join("/"),i=`https://raw.githubusercontent.com/${e.owner}/${e.repo}/${e.commit}/${t}`,n=await e.fetchImpl(i,{headers:me(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>V)throw new u(`Extension file is too large: ${e.file.path}`,{code:"extension_file_too_large"});let o=new Uint8Array(await n.arrayBuffer());if(o.byteLength>V)throw new u(`Extension file is too large: ${e.file.path}`,{code:"extension_file_too_large"});return o}r(fe,"downloadBytes");async function K(e,t,i){let n=await e(`https://api.github.com${i}`,{headers:me(t,"application/vnd.github+json")});if(!n.ok){let s=await n.json().catch(()=>null),o=typeof s?.message=="string"?`: ${s.message}`:"";throw new u(`GitHub request failed (${n.status})${o}`,{code:n.status===404?"github_repository_not_found":"github_request_failed",status:n.status})}return await n.json()}r(K,"githubJson");function me(e,t){let i=new Headers({Accept:t,"User-Agent":"openpond-extension-installer","X-GitHub-Api-Version":"2022-11-28"});return e&&i.set("Authorization",`Bearer ${e}`),i}r(me,"githubHeaders");function je(e){let t=new Map;for(let n of e)for(let s of n.files)t.set(s.path,s);if(t.size>ae)throw new u(`Extension contains more than ${ae} skill files.`,{code:"extension_too_many_files"});let i=0;for(let n of t.values()){if((n.size??0)>V)throw new u(`Extension file is too large: ${n.path}`,{code:"extension_file_too_large"});i+=n.size??0}if(i>ue)throw new u("Extension exceeds the maximum allowed size.",{code:"extension_too_large"})}r(je,"validateDownloadLimits");function He(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(He,"validTreeEntry");function Ue(e){let t=de("sha256");for(let i of e)t.update(`${i.path}\0${i.sha}\0${i.size??""}
3
+ `);return t.digest("hex")}r(Ue,"hashTree");function ze(e,t){return e==="."?t:t.slice(e.length+1)}r(ze,"relativeSkillPath");function qe(e){let t=new Set,i=new Set;for(let n of e)t.has(n)&&i.add(n),t.add(n);return i}r(qe,"duplicateValues");async function we(e,t,i){let n=new Array(e.length),s=0;async function o(){for(;s<e.length;){let l=s;s+=1,n[l]=await i(e[l])}}return r(o,"worker"),await Promise.all(Array.from({length:Math.min(t,e.length)},o)),n}r(we,"mapConcurrent");function M(e){return new u(`Invalid GitHub extension source: ${e}. Use owner/repo or https://github.com/owner/repo.`,{code:"github_invalid_source"})}r(M,"invalidSource");import{createHash as Fe,randomUUID as Pe}from"node:crypto";import{existsSync as _}from"node:fs";import{mkdir as W,readFile as De,rename as G,rm as I,stat as Ke,writeFile as ye}from"node:fs/promises";import m from"node:path";var j=1,Be=15e3;function ke(e={}){let t=m.resolve(e.home??e.rootPath??ne()),i=m.resolve(e.rootPath??m.join(t,"library","extensions")),n=q(t).database,s=he({fetch:e.fetch,githubToken:e.githubToken}),o=e.now??(()=>new Date);async function l(){try{let g=await O(t),d=await Promise.all(g.extensions.map(f=>X(i,f)));return Je(d,await R(e.reservedSkillNames)),{rootPath:i,registryPath:n,extensions:d.sort(Q),error:null}}catch(g){return{rootPath:i,registryPath:n,extensions:[],error:g instanceof Error?g.message:String(g)}}}r(l,"list");async function a(g){let d=await s.resolve(g),f=await O(t),p=f.extensions.find(h=>h.id===d.preview.id)??null;return T(d.preview,f.extensions.filter(h=>h.id!==p?.id),await R(e.reservedSkillNames)),d.preview}r(a,"preview");async function w(g){let d=k(g.source);return Y(i,d.id,async()=>{let f=await O(t);if(f.extensions.some(y=>y.id===d.id))throw new u(`${d.owner}/${d.repo} is already installed.`,{code:"extension_already_installed",status:409});let p=await s.resolve(g);Ee(p.preview),T(p.preview,f.extensions,await R(e.reservedSkillNames));let h=o().toISOString(),b=await xe({rootPath:i,resolution:p,installedAt:h,updatedAt:h,github:s});try{let y=await R(e.reservedSkillNames);return await J(t,o,E=>({...E,extensions:We(E,b,y)})),await be(i,b.id),b}catch(y){throw await ve(i,b.id),y}})}r(w,"add");async function v(g){let d=k(g.source);return Y(i,d.id,async()=>{let f=await O(t),p=N(f,d.id),h=await s.resolve({source:p.repositoryUrl,ref:g.ref?.trim()||p.requestedRef});if(Ee(h.preview),T(h.preview,f.extensions.filter(y=>y.id!==p.id),await R(e.reservedSkillNames)),p.resolvedCommit===h.preview.resolvedCommit&&p.packageHash===h.preview.packageHash&&p.requestedRef===h.preview.requestedRef)return X(i,p);let b=await xe({rootPath:i,resolution:h,installedAt:p.installedAt,updatedAt:o().toISOString(),github:s});try{let y=await R(e.reservedSkillNames);return await J(t,o,E=>({...E,extensions:Xe(E,b,y)})),await be(i,b.id),b}catch(y){throw await ve(i,b.id),y}})}r(v,"update");async function P(){let g=await l();if(g.error)throw new u(g.error,{code:"extension_registry_error"});let d={updated:[],unchanged:[],failed:[]};for(let f of g.extensions)try{let p=await v({source:f.repositoryUrl,ref:f.requestedRef});p.resolvedCommit===f.resolvedCommit&&p.packageHash===f.packageHash?d.unchanged.push(p):d.updated.push(p)}catch(p){d.failed.push({id:f.id,error:p instanceof Error?p.message:String(p)})}return d}r(P,"updateAll");async function S(g){let d=k(g),f=await O(t);return X(i,N(f,d.id))}r(S,"inspect");async function x(g){let d=k(g);return Y(i,d.id,async()=>{let f=await O(t),p=N(f,d.id),h=C(i,d.owner,d.repo),b=`${h}.${Pe()}.remove`;_(h)&&await G(h,b);try{return await J(t,o,y=>({...y,extensions:y.extensions.filter(E=>E.id!==p.id)})),await I(b,{recursive:!0,force:!0}),p}catch(y){throw _(b)&&!_(h)&&await G(b,h),y}})}r(x,"remove");async function A(g){let d=g.trim();if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(d))throw new u("Extension skill name must be lowercase kebab-case.",{code:"extension_skill_invalid_name"});let f=await l();if(f.error)throw new u(f.error,{code:"extension_registry_error"});let p=f.extensions.flatMap(te=>te.skills.filter(U=>U.name===d).map(U=>({extension:te,skill:U})));if(p.length===0)throw new u(`Extension skill not found: ${d}`,{code:"extension_skill_not_found",status:404});if(p.length>1)throw new u(`Extension skill name is ambiguous: ${d}`,{code:"extension_skill_conflict",status:409});let h=p[0];if(h.extension.validationStatus!=="valid"||h.skill.validationStatus!=="valid")throw new u(`Extension skill ${d} is not valid.`,{code:"extension_skill_invalid"});let b=Oe(h.extension.sourcePath,h.skill.relativePath),y=await De(b,"utf8"),E=Fe("sha256").update(y).digest("hex");if(E!==h.skill.sourceHash)throw new u(`Extension skill ${d} changed on disk. Update or reinstall its extension before using it.`,{code:"extension_skill_modified"});let $=L(y);if($.messages.length>0||$.name!==d||!$.description)throw new u(`Extension skill ${d} is not valid. ${$.messages.join(" ")}`.trim(),{code:"extension_skill_invalid"});return{name:d,description:$.description,body:$.body,path:h.skill.relativePath,sourcePath:h.extension.sourcePath,sourceHash:E,charCount:y.length,packagePath:m.dirname(b),resourceFiles:h.skill.resourceFiles}}return r(A,"readSkill"),{rootPath:i,registryPath:n,list:l,preview:a,add:w,update:v,updateAll:P,inspect:S,remove:x,readSkill:A}}r(ke,"createGithubExtensionManager");async function xe(e){let t=e.resolution.preview,i=C(e.rootPath,t.owner,t.repo),n=`${i}.${Pe()}.install`,s=Z(e.rootPath,t.id),o=m.join(n,"current");await I(n,{recursive:!0,force:!0}),await I(s,{recursive:!0,force:!0}),await W(o,{recursive:!0,mode:448});try{await e.github.download(e.resolution,async(a,w,v)=>{let P=Oe(o,a);await W(m.dirname(P),{recursive:!0,mode:448}),await ye(P,w,{mode:v?448:384})});let l=Ve(t,i,e.installedAt,e.updatedAt);return await ye(m.join(n,"extension.json"),`${JSON.stringify(l,null,2)}
4
+ `,{mode:384}),await W(m.dirname(i),{recursive:!0,mode:448}),_(i)&&await G(i,s),await G(n,i),l}catch(l){throw await I(n,{recursive:!0,force:!0}),_(s)&&!_(i)&&await G(s,i),l}}r(xe,"materializeExtension");function Ve(e,t,i,n){let s=m.join(t,"current");return{...e,sourcePath:s,readmePath:e.readmePath?m.join(s,e.readmePath):null,installedAt:i,updatedAt:n,skills:e.skills.map(o=>({...o,sourcePath:m.join(s,o.relativePath)}))}}r(Ve,"installedExtension");async function be(e,t){await I(Z(e,t),{recursive:!0,force:!0})}r(be,"finalizeMaterialization");async function ve(e,t){let i=k(t.replace(/^github:/,"")),n=C(e,i.owner,i.repo),s=Z(e,t);await I(n,{recursive:!0,force:!0}),_(s)&&await G(s,n)}r(ve,"rollbackMaterialization");async function X(e,t){let i=C(e,t.owner,t.repo),n=m.join(i,"current"),s=(await Ke(m.join(i,"extension.json")).catch(()=>null))?.isFile()??!1,o=t.validationMessages.filter(l=>l!=="Installed files are missing.");return s||o.push("Installed files are missing."),{...t,sourcePath:n,readmePath:t.readmePath?m.join(n,m.basename(t.readmePath)):null,skills:t.skills.map(l=>({...l,sourcePath:m.join(n,l.relativePath)})),validationStatus:o.length===0?"valid":"error",validationMessages:o}}r(X,"hydrateExtension");function Ee(e){if(e.validationStatus!=="valid")throw new u(`Extension contains invalid skills: ${e.validationMessages.join(" ")}`,{code:"extension_invalid"})}r(Ee,"assertInstallable");function T(e,t,i){let n=new Map;for(let o of i)n.set(o,"a shipped OpenPond skill");for(let o of t)for(let l of o.skills)n.set(l.name,o.id);let s=e.skills.map(o=>({name:o.name,owner:n.get(o.name)})).filter(o=>!!o.owner);if(s.length!==0)throw new u(`Skill name conflict: ${s.map(o=>`${o.name} (${o.owner})`).join(", ")}.`,{code:"extension_skill_conflict",status:409})}r(T,"assertSkillNamesAvailable");function We(e,t,i){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 T(t,e.extensions,i),[...e.extensions,t].sort(Q)}r(We,"appendInstalledExtension");function Xe(e,t,i){return N(e,t.id),T(t,e.extensions.filter(n=>n.id!==t.id),i),e.extensions.map(n=>n.id===t.id?t:n).sort(Q)}r(Xe,"replaceInstalledExtension");function Je(e,t){let i=new Map;for(let n of t)i.set(n,"built-in");for(let n of e)for(let s of n.skills){let o=i.get(s.name);if(!o){i.set(s.name,n.id);continue}let l=`Skill name conflicts with ${o}: ${s.name}`;s.validationStatus="error",s.validationMessages=[...new Set([...s.validationMessages,l])],n.validationStatus="error",n.validationMessages=[...new Set([...n.validationMessages,l])]}}r(Je,"markInstalledSkillConflicts");async function R(e){let t=typeof e=="function"?await e():e??[];return[...new Set(t.map(i=>i.trim()).filter(Boolean))]}r(R,"reservedSkillNames");function N(e,t){let i=e.extensions.find(n=>n.id===t);if(i)return i;throw new u(`${t.replace(/^github:/,"")} is not installed.`,{code:"extension_not_installed",status:404})}r(N,"requireInstalled");async function O(e){let t=D(e,"extension_installations","registry")?.value;if(!t)return Ze();if(t.schemaVersion!==j||!Array.isArray(t.extensions)||!t.extensions.every(Se))throw new Error("Extension registry has an unsupported format.");return Ye(t)}r(O,"readRegistry");async function J(e,t,i){await F(m.join(q(e).runtime,"extension-registry"),async()=>{let n=D(e,"extension_installations","registry"),s=i(await O(e));ie(e,"extension_installations","registry",{...s,schemaVersion:j,updatedAt:t().toISOString()},n?.revision??null)})}r(J,"writeRegistry");function Ye(e){return{schemaVersion:j,updatedAt:typeof e?.updatedAt=="string"?e.updatedAt:null,extensions:Array.isArray(e?.extensions)?e.extensions.filter(Se):[]}}r(Ye,"normalizeRegistry");function Ze(){return{schemaVersion:j,updatedAt:null,extensions:[]}}r(Ze,"emptyRegistry");function Se(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(Se,"isStoredExtension");function Oe(e,t){if(m.isAbsolute(t)||t.split(/[\\/]/).includes(".."))throw new u(`Unsafe extension path: ${t}`,{code:"extension_unsafe_path"});let i=m.resolve(e,...t.split("/")),n=`${m.resolve(e)}${m.sep}`;if(!i.startsWith(n))throw new u(`Unsafe extension path: ${t}`,{code:"extension_unsafe_path"});return i}r(Oe,"safeDestination");function C(e,t,i){return m.join(e,"github",t,i)}r(C,"extensionDirectory");function Z(e,t){let i=k(t.replace(/^github:/,""));return`${C(e,i.owner,i.repo)}.previous`}r(Z,"backupDirectory");async function Y(e,t,i){let n=t.replace(/[^a-z0-9.-]+/gi,"-");return F(m.join(e,".locks",n),i,Be)}r(Y,"withExtensionLock");function Q(e,t){return e.id.localeCompare(t.id)}r(Q,"extensionSort");var _e=["openpond-cli","openpond-desktop-harness","openpond-taskset-authoring","openpond-skill-authoring","openpond-agent-authoring","openpond-refiner-authoring"];var Qe=c.object({name:c.string(),description:c.string(),relativePath:c.string(),sourcePath:c.string(),charCount:c.number().int().nonnegative(),sourceHash:c.string(),resourceFiles:c.array(c.string()),validationStatus:c.enum(["valid","error"]),validationMessages:c.array(c.string())}),$e=c.object({id:c.string(),source:c.literal("github"),owner:c.string(),repo:c.string(),repositoryUrl:c.string().url(),requestedRef:c.string(),resolvedCommit:c.string(),sourcePath:c.string(),readmePath:c.string().nullable(),installedAt:c.string(),updatedAt:c.string(),packageHash:c.string(),skills:c.array(Qe),validationStatus:c.enum(["valid","error"]),validationMessages:c.array(c.string())}),vt=$e.omit({installedAt:!0,updatedAt:!0,sourcePath:!0}).extend({sourcePath:c.null()}),Et=c.object({rootPath:c.string(),registryPath:c.string(),extensions:c.array($e),error:c.string().nullable()}),Pt=c.object({source:c.string().trim().min(1),ref:c.string().trim().min(1).optional()});async function $t(e,t,i=ke({reservedSkillNames:r(async()=>{let n=await se();return[..._e,...n.skills.map(s=>s.name)]},"reservedSkillNames")})){let n=t[0]?.toLowerCase()||"list",s=z(e.json);if(n==="list"){let o=await i.list();if(o.error)throw new Error(o.error);et(o.extensions,s);return}if(n==="add"||n==="preview"){let l={source:H(t[1],n),ref:Re(e.ref)},a=n==="preview"?await i.preview(l):await i.add(l);ee(a,s,n==="preview"?"Preview":"Installed");return}if(n==="inspect"){ee(await i.inspect(H(t[1],n)),s,"Installed");return}if(n==="update"){if(z(e.all)){let a=await i.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 w of a.failed)console.log(`- ${w.id}: ${w.error}`)}a.failed.length>0&&(process.exitCode=1);return}let o=H(t[1],n),l=await i.update({source:o,ref:Re(e.ref)});ee(l,s,"Updated");return}if(n==="remove"){let o=await i.remove(H(t[1],n));console.log(s?JSON.stringify({removed:o},null,2):`Removed ${o.owner}/${o.repo} and ${o.skills.length} skill(s).`);return}throw new Error("usage: openpond extension <add|preview|list|inspect|update|remove> [owner/repo] [--ref <ref>] [--all] [--json]")}r($t,"runOpenPondExtensionCommand");function ee(e,t,i){if(t){console.log(JSON.stringify(e,null,2));return}console.log(`${i} ${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 et(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 i of e)console.log(`- ${i.owner}/${i.repo}@${i.resolvedCommit.slice(0,12)} \xB7 ${i.skills.length} skill(s) \xB7 ${i.validationStatus}`)}r(et,"printExtensionList");function H(e,t){let i=e?.trim();if(i)return i;throw new Error(`usage: openpond extension ${t} <owner/repo>`)}r(H,"requiredSource");function Re(e){return typeof e=="string"&&e.trim()?e.trim():void 0}r(Re,"optionText");export{$t 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-AH22RHPS.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-BQAF5P7K.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{a as Ie,b as ye,c as Re,d as He,e as Ee,f as Pe,h as B,i as Ae,j as je}from"./chunk-QRAKXZOC.js";import{e as Ce,f as U}from"./chunk-CGBI2VYJ.js";import{Lb as xe,Nb as Te,Rb as G,Sb as De,Tb as ze,V as be,Va as Se,W as ke,n as we,o as ve}from"./chunk-YUPBAWBJ.js";import"./chunk-C6D4WAYN.js";import"./chunk-USMZT5FZ.js";import"./chunk-QKD5OMDI.js";import{k as ge}from"./chunk-T4QGDQHP.js";import{a as z}from"./chunk-OSIO7PLX.js";import"./chunk-STDMBJOQ.js";import{E as W,M as me,Ra as fe,Va as D,Wa as he}from"./chunk-2DFR7PJ4.js";import"./chunk-5CMKGD43.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-MVF3F5QS.js";import"./chunk-L4235TRQ.js";import"./chunk-BFKYRQMA.js";import"./chunk-DLVPSCTB.js";import"./chunk-WDFLCNRC.js";import{Kd as le,Nb as de,Ob as ce,Od as V,Q as se,Qd as ue,Wa as C,Xa as $,he as pe}from"./chunk-JIMU3KDA.js";import"./chunk-6MI4KKWF.js";import"./chunk-QDHMP5FS.js";import{ta as ae,wa as ie}from"./chunk-YDT7L3VZ.js";import"./chunk-6FA3GG5B.js";import"./chunk-YR5ID2SS.js";import{S as re,T as oe,V as ne,c as Y,g as ee}from"./chunk-55G6B54U.js";import{hb as M,k as te}from"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import{d as X}from"./chunk-JUJSA7KI.js";import{l as J,m as R}from"./chunk-KGNCKIFP.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{promises as $e}from"node:fs";import Ue from"node:path";import Le from"node:http";var Q=e.object({socketPath:e.string().min(1).max(1e3),capability:e.string().regex(/^[a-f0-9]{64}$/),jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),Ne=e.object({jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/),requestId:e.string().min(1).max(500),model:X,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max","none"]).nullable(),messages:e.array(e.unknown()).min(1).max(1e3),tools:e.array(e.unknown()).max(100),toolChoice:e.unknown(),maxOutputTokens:e.number().int().positive().max(131072),temperature:e.number().finite().optional(),topP:e.number().finite().optional(),seed:e.number().int().optional()}).strict(),Je=e.discriminatedUnion("kind",[e.object({kind:e.literal("chat_completions_reasoning"),reasoningContent:e.string()}).strict(),e.object({kind:e.literal("responses_reasoning_items"),items:e.array(e.record(e.string(),e.unknown()))}).strict()]),Ve=e.object({id:e.string().optional(),type:e.string(),function:e.object({name:e.string().optional(),arguments:e.string().optional()}).passthrough().optional()}).passthrough(),Ge=e.object({text:e.string().optional(),usage:e.unknown().optional(),costUsd:e.number().finite().nonnegative().optional(),continuation:Je.optional(),toolCalls:e.array(Ve).optional()}).strict();function qe(s,r){let t=Q.parse(s);async function n(u,v,I=r){I.throwIfAborted();let x=Buffer.from(JSON.stringify({action:u,jobId:t.jobId,pinHash:t.pinHash,value:v}));if(x.length>8*1024*1024)throw new Error("Hosted advanced request exceeds its private byte limit.");return new Promise((y,h)=>{let l=Le.request({socketPath:t.socketPath,path:"/",method:"POST",headers:{authorization:`Bearer ${t.capability}`,"content-type":"application/json","content-length":x.length},signal:I},H=>{let E=[],P=0;H.on("data",w=>{if(P+=w.length,P>8388608){H.destroy(new Error("Hosted advanced response exceeds its private byte limit."));return}E.push(w)}),H.on("error",h),H.on("end",()=>{try{let w=JSON.parse(Buffer.concat(E).toString("utf8"));if(H.statusCode!==200)throw new Error(typeof w?.error=="string"?w.error:"The actual hosted advanced owner refused this operation.");y(w)}catch(w){h(w)}})});l.on("error",h),l.end(x)})}i(n,"call");let d=i(async function*(u){let v=Ne.parse({jobId:t.jobId,pinHash:t.pinHash,requestId:u.requestId,model:u.model,reasoningEffort:u.reasoningEffort,messages:u.messages,tools:u.tools,toolChoice:u.toolChoice,maxOutputTokens:u.maxOutputTokens??4096,...u.temperature===void 0?{}:{temperature:u.temperature},...u.topP===void 0?{}:{topP:u.topP},...u.seed===void 0?{}:{seed:u.seed}}),I=e.object({deltas:e.array(Ge).max(1e5)}).strict().parse(await n("model",v,AbortSignal.any([r,u.signal])));for(let x of I.deltas)yield x},"stream");return{stream:d,text:i(async u=>{let v="";for await(let I of d({...u,reasoningEffort:u.reasoningEffort??null,tools:[],toolChoice:"none"}))I.text&&(v+=I.text),I.usage!==void 0&&u.onUsage?.(I.usage,I.costUsd);return v},"text"),authorize:i(async()=>{await n("authorize",{})},"authorize"),ceiling:i(async(u,v,I)=>e.object({configurationHash:e.string().regex(/^[a-f0-9]{64}$/),maximumChargeUsd:e.number().finite().positive()}).strict().parse(await n("ceiling",{modelId:u,pricing:v,maximumOutputTokens:I})),"ceiling"),compute:i((u,v=!1)=>n("compute",u,v?AbortSignal.timeout(6e4):r),"compute"),checkpoint:i(u=>n("checkpoint",u),"checkpoint")}}i(qe,"createHostedAdvancedModelBridge");import Qe from"node:path";var Me=e.string().regex(/^[a-f0-9]{64}$/),Ke=e.object({taskId:e.string().min(1),caseHash:Me,session:C,turn:$,events:e.array(se).max(1e4),traceHash:Me,output:e.string().nullable()}).strict(),K=e.object({packageValue:ae,contexts:e.array(Ke).max(1e4)}).strict();async function _e(s){let r=V(s.pin),t=K.parse(s.privateSource),n=ie(t.packageValue),d=M(e.object({manifest:e.unknown(),result:e.unknown()}).parse(s.evidence));async function m(){if(await s.authorize(),r.actorId!==s.actor.actorId||r.teamId!==s.actor.teamId||r.profileRef.source!=="openpond_git"||r.profileRef.repositoryId!==s.source.repositoryId||r.profileRef.profileId!==s.source.profileId||r.sourceRevision!==s.source.sourceRevision)throw new Error("The actual hosted advanced source owner changed.")}if(i(m,"authorize"),await m(),d.manifest.teamId!==r.teamId||d.result.status!=="completed"||d.manifest.id!==r.evidence.id||d.result.contentHash!==r.evidence.contentHash||R(d.manifest.dataset)!==R(r.externalDatasetBinding.dataset))throw new Error("The exact completed hosted advanced evidence changed.");if(n.contentHash!==r.externalDatasetBinding.packageHash||n.contentHash!==r.adaptationDatasetBinding.packageHash||n.environment.contentHash!==r.environmentPolicy.environmentHash||n.environment.contract.networkPolicy!=="none")throw new Error("The hosted advanced environment/package is not the exact reviewed closed-network release.");if(n.taskset.tools.some(l=>l.name==="web_search"||l.name==="web_fetch"))throw new Error("Live external tools require their own qualified frozen-observation and budget owner.");if(n.verifierSet.graders.some(l=>l.kind==="human"||l.kind==="model_judge"&&l.calibrationStatus!=="passed"))throw new Error("Advanced hosted evaluation needs executable, qualified independent graders.");let u=r.adaptationTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),v=r.holdoutTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),I=new Set(u.map(l=>l?.clusterKey));if(u.some(l=>!l||l.split!==r.adaptationSplit)||v.some(l=>!l||l.split!==r.holdoutSplit||I.has(l.clusterKey)))throw new Error("Hosted adaptation/holdout membership or independent families changed.");let x=await s.store.getHarnessReleaseRecord(r.baselineRelease.contentHash);if(!x||x.harnessRelease.id!==r.baselineRelease.id||s.workspace.currentChannel.release?.contentHash!==r.baselineRelease.contentHash)throw new Error("The exact hosted source baseline is unavailable.");let y=await D({workspaceId:typeof x.agentSnapshot.metadata.workspaceId=="string"?x.agentSnapshot.metadata.workspaceId:x.workspaceId,sourceDir:Qe.join(x.bundlePath,"source")});if(z(y).protectedClosureHash!==r.privateClosureHash)throw new Error("The protected hosted Profile closure changed.");let h={packageValue:n,authorize:m};return{read:i(async l=>{if(V(l).contentHash!==r.contentHash)throw new Error("The actual hosted advanced admission changed.");return await m(),h},"read"),evidence:i(async()=>(await m(),d),"evidence"),authorize:i(async()=>m(),"authorize"),reviewContext:i(async(l,H)=>{await m();let E=t.contexts.filter(p=>p.taskId===H),P=d.result.cases.find(p=>p.identity.caseId===H);if(E.length!==1||!P||P.status!=="completed")throw new Error("The actual retained hosted review case is unavailable.");let w=E[0];if(w.caseHash!==R(P)||w.session.cloudTeamId!==r.teamId||w.turn.sessionId!==w.session.id||w.turn.status==="in_progress"||w.events.some(p=>p.sessionId!==w.session.id||p.turnId!==w.turn.id))throw new Error("The actual hosted review session/turn/trace binding changed.");return await m(),{...w,case:{output:w.output}}},"reviewContext")}}i(_e,"createHostedAdvancedRefinerSource");import{randomUUID as Ze}from"node:crypto";function Oe(s){async function r(n){let d=await s.store.getSession(n);if(!d||d.cloudTeamId!==s.teamId||d.metadata?.hostedAdvancedTurnId!==s.hostedTurnId||d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The actual hosted advanced case owner changed.");return d}i(r,"read");async function t(n,d,m){let u=await r(n),v=e.object({action:e.string()}).passthrough().parse(d).action;return ce.parse(await s.bridge.compute({session:u,payload:d,turnId:m??null},v==="sandbox_stop"||v==="sandbox_receipts"))}return i(t,"tool"),{createSession:i(async n=>{await s.bridge.authorize();let d=C.partial().parse(n),m=new Date().toISOString();if(d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The foreground case belongs to another actual advanced Run.");let u=C.parse({...d,id:`hosted-advanced-case-${Ze()}`,provider:"openpond",currentProfile:s.profileRef,cloudTeamId:s.teamId,cwd:null,codexThreadId:null,appId:null,appName:null,createdAt:m,updatedAt:m,status:"active",pinned:!1,archived:!1,order:0,hiddenFromDefaultSidebar:!0,title:d.title??"Advanced hosted evaluation case",metadata:{...d.metadata,source:"hosted-advanced-evaluation",hostedAdvancedTurnId:s.hostedTurnId,actorId:s.actorId,workspaceTarget:"hosted",benchmarkRuntime:"hosted_managed_work"}});return await s.store.insertSessionAtFront(u),await s.bridge.authorize(),u},"createSession"),getSession:r,runtimeEventsForSession:i(n=>s.store.runtimeEventsForSession(n),"runtimeEventsForSession"),executeWorkspaceTool:i((n,d,m)=>t(n,d,m?.turnId),"executeWorkspaceTool"),settleCostEvidence:i((n,d)=>t(n,{action:"sandbox_receipts",args:{}},d?.turnId),"settleCostEvidence")}}i(Oe,"createHostedAdvancedWorkRuntime");var Xe=e.string().regex(/^[a-f0-9]{64}$/),Be=e.object({version:e.string().min(1),source:e.string().min(1),effectiveAt:e.string().min(1),inputUsdPerMillionTokens:e.number().finite().nonnegative(),cachedInputUsdPerMillionTokens:e.number().finite().nonnegative(),outputUsdPerMillionTokens:e.number().finite().nonnegative()}).strict(),Z=e.object({operation:e.enum(["prepare_run","start","read","resume","cancel"]),request:ue,configuration:e.object({id:e.string().min(1),profileId:e.string().min(1),etag:Xe}).strict(),refinerRelease:Y,privateSource:K,upstream:e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict(),judgeModels:e.array(e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict()).max(50),bridge:Q.optional(),hostedTurnId:e.string().min(1).optional()}).strict();async function Fe(s){let r=Z.parse(s.request),t=r.request.pin;if(r.request.model.providerId!=="openpond"||r.request.model.modelId!==r.upstream.modelId||r.configuration.id!==r.request.modelId||r.configuration.profileId!==t.profileRef.profileId||r.request.profileId!==t.profileRef.profileId||r.refinerRelease.id!==t.refinerRelease.id||r.refinerRelease.contentHash!==t.refinerRelease.contentHash)throw new Error("The actual hosted advanced configuration/model/Refiner admission changed.");let n=`advanced-refiner-${R([t.actorId,t.teamId,t.operationId,t.contentHash,r.request.model,[r.request.seed],1]).slice(0,40)}`;if((r.operation==="start"||r.operation==="resume")&&(!r.bridge||!r.hostedTurnId))throw new Error("The actual hosted advanced execution grant is unavailable.");let m=r.bridge?qe(r.bridge,s.signal):null;if(r.bridge&&(r.bridge.jobId!==n||r.bridge.pinHash!==t.contentHash))throw new Error("The hosted model bridge belongs to another actual Run.");let u=i(async()=>{s.signal.throwIfAborted(),await s.authorize(),m&&await m.authorize()},"authorize"),v=await _e({...s,pin:t,privateSource:r.privateSource,authorize:u}),I=we(ve(s.storeDir));await I.persistRelease(r.refinerRelease),await I.writeSource(ee(r.refinerRelease.profile)),I.binding()?.release.contentHash!==t.refinerRelease.contentHash&&await I.transition(r.refinerRelease,{operation:"activate",bindingChanged:!0,actor:s.actor.actorId,reason:"Pin the actual hosted evaluation fork to its admitted immutable Refiner release.",authoringSkillHash:null});let y=ke({storeDir:s.storeDir,authorize:i(async()=>u(),"authorize"),packageForPin:i(async()=>r.privateSource.packageValue,"packageForPin"),prepareModel:i(async(c,f,k)=>{if(!m)throw new Error("The actual hosted model ceiling owner is unavailable.");return m.ceiling(c,k,f)},"prepareModel")}),h=i(async function*(c){let f=be(),k=[r.upstream,...r.judgeModels].find(q=>q.modelId===c.model.modelId);if(!m||!f||!k)throw new Error("The actual hosted model and durable shared budget are unavailable.");let{signal:T,...j}=c,O=c.maxOutputTokens??4096,L=await f.call(c.requestId,j,k.pricing,O,async()=>{let q=[],F=null;for await(let N of m.stream({...c,signal:AbortSignal.any([T,f.signal])}))q.push(N),N.costUsd!==void 0&&(F=(F??0)+N.costUsd);return{value:q,costUsd:F}});for(let q of L)yield q},"stream"),l=i(async c=>{let f="";for await(let k of h({...c,reasoningEffort:c.reasoningEffort??null,tools:[],toolChoice:"none"}))k.text&&(f+=k.text),k.usage!==void 0&&c.onUsage?.(k.usage,k.costUsd);return f},"text"),H=Ie({store:s.store,storeDir:s.storeDir}),E=await H.projectSelected({profileId:t.profileRef.profileId,package:r.privateSource.packageValue,adaptationSplit:t.adaptationSplit,holdoutSplit:t.holdoutSplit}),P=i(async c=>{let f=C.partial().parse(c),k=new Date().toISOString(),T=C.parse({...f,id:`hosted-review-${R([n,f.metadata]).slice(0,40)}`,cloudTeamId:t.teamId,currentProfile:t.profileRef,appId:null,appName:null,cwd:null,codexThreadId:null,title:f.title??"Hosted Refiner review",provider:"openpond",createdAt:k,updatedAt:k,status:"active",pinned:!1,archived:!1,order:0,metadata:{...f.metadata,hostedAdvancedTurnId:r.hostedTurnId??null,actorId:t.actorId,source:"hosted-advanced-evaluation"}});return await s.store.insertSessionAtFront(T),T},"createSession"),w=m&&r.hostedTurnId?Oe({store:s.store,bridge:m,teamId:t.teamId,actorId:t.actorId,hostedTurnId:r.hostedTurnId,modelRunId:n,profileRef:t.profileRef}):void 0,p=Se({store:s.store,storeDir:s.storeDir,modelJudge:ye({store:s.store,modelText:l}),modelText:l,modelStream:h,workRuntime:w,resolveTasksetRelease:i(c=>H.releaseForTaskset(c),"resolveTasksetRelease")}),a={store:s.store,storeDir:s.storeDir,evaluation:p,benchmarkTasksets:H,loadProfileState:i(async()=>s.profile,"loadProfileState"),resolveEvaluationProject:i(async(c,f)=>{if(await u(),c!==r.configuration.id||f!==r.configuration.profileId)throw new Error("The actual hosted evaluation configuration changed.");return{id:c,profileId:f}},"resolveEvaluationProject"),resolveUpstreamModel:i(async()=>({providerId:"openpond",modelId:r.upstream.modelId,revision:r.upstream.revision,pricing:r.upstream.pricing}),"resolveUpstreamModel"),advancedBoundary:y,refinerStream:i(async function*(c){if(!c.requestId)throw new Error("A hosted Refiner call needs its actual retained ID.");yield*h({model:c.model,reasoningEffort:"low",messages:c.messages,tools:[],toolChoice:"none",requestId:c.requestId,maxOutputTokens:4096,signal:c.signal,hostedTokenPricing:c.pricing})},"refinerStream")},o=Re({...a,reviewQuality:He({source:v,boundary:y,benchmark:a,createSession:P})}),g={advancedEvaluation:t,selectedTaskset:{id:E.id,revision:E.revision,contentHash:E.contentHash},modelId:r.request.modelId,profileId:r.request.profileId,model:r.request.model,reasoningEffort:r.request.reasoningEffort,seeds:[r.request.seed],repetitions:1,maximumSpendUsd:t.maximumCostUsd},b,S=i(()=>{o.cancel(n)},"stop");s.signal.addEventListener("abort",S,{once:!0});try{if(r.operation==="prepare_run")return o.prepare(g);let c=await s.store.getModelRun(n);if(!c||c.evaluation?.benchmarkId!=="harness-refiner"||c.evaluation.advancedEvaluation?.contentHash!==t.contentHash)throw new Error("The original hosted advanced Run is unavailable.");if(r.operation==="read")return c;if(r.operation==="cancel")return o.cancel(n);if(m){let T=!1;b=setInterval(()=>{T||(T=!0,s.store.getModelRun(n).then(j=>j?m.checkpoint(j):void 0).catch(()=>S()).finally(()=>{T=!1}))},2e3)}r.operation==="start"?await o.start(g):await o.resume(n);let f=await o.wait(n);if(!f)throw new Error("The actual hosted advanced engine did not retain its Run.");let k=pe.parse(f);return m&&await m.checkpoint(k),k}finally{b&&clearInterval(b),s.signal.removeEventListener("abort",S),await o.close(),await y.close()}}i(Fe,"runHostedAdvancedRefinerOwner");import{promises as _}from"node:fs";import A from"node:path";var Ye=e.object({actor:e.object({actorId:e.string().min(1),teamId:e.string().min(1)}).strict(),storeDir:e.string().min(1),source:e.object({repoPath:e.string().min(1),repositoryId:e.string().min(1),profileId:e.string().min(1),sourceRevision:e.string().regex(/^[a-f0-9]{40,64}$/),filesHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),evidence:e.object({manifest:e.unknown(),result:e.unknown()}).strict(),operation:e.enum(["advanced","describe","command","queue","cancelQueued","bind","finish","beginTesting","cancelTesting","failTesting","comparison","beginAdoption","export","source","tool","toolCatalog"]),advanced:Z.optional(),command:le.optional(),candidateId:e.string().optional(),revision:e.number().int().positive().optional(),actualSession:C.optional(),actualTurn:$.optional(),recipe:e.unknown().optional(),baseline:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),candidate:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),humanProjection:oe.optional(),humanSelections:re.optional(),adoptionReadback:e.unknown().optional(),failure:e.object({message:e.string().max(2e3),cancelled:e.boolean()}).strict().optional(),tool:e.object({name:e.string(),args:e.record(e.string(),e.unknown()),callId:e.string()}).strict().optional(),agentRuntime:e.object({source:e.string(),cliRelativePath:e.string()}).strict().optional(),queued:e.object({sessionId:e.string(),turnId:e.string(),createdAt:e.string().datetime()}).strict().optional()}).strict();async function We(s,r=new AbortController().signal){r.throwIfAborted();let t=Ye.parse(s),{actor:n,source:d}=t;if(!A.isAbsolute(t.storeDir)||!A.isAbsolute(d.repoPath))throw new Error("Hosted candidate owner requires contained absolute private paths.");let m=M(t.evidence),u=[t.baseline,t.candidate].filter(l=>l!==void 0).map(l=>M(l));if(m.manifest.teamId!==n.teamId)throw new Error("Hosted candidate evidence belongs to another team.");if(await B(d.repoPath)!==d.filesHash)throw new Error("The admitted hosted Profile source bytes changed.");let v=`hosted-improve-source-${R([n,d.repositoryId,d.profileId,d.sourceRevision]).slice(0,40)}`,I=A.join(t.storeDir,"library","profile-experiment-origins",v);if(await _.mkdir(A.dirname(I),{recursive:!0,mode:448}),await _.stat(I).catch(()=>null)||await _.cp(d.repoPath,I,{recursive:!0,errorOnExist:!0,force:!1}),await B(I)!==d.filesHash)throw new Error("The private accepted Profile cache changed.");let x=await W(I,d.profileId);if(x.error||!x.sourcePath)throw new Error("The accepted hosted Profile does not compile.");let y=new xe(t.storeDir),h;try{let l=await y.getHarnessWorkspace(v);l||(l=(await fe({store:y,storeDir:t.storeDir,id:v,ownerId:n.actorId,name:d.profileId,profile:x,sourceRevision:d.sourceRevision,repositoryId:d.repositoryId,selectionEligible:!1,originMetadata:{profileExperimentOrigin:{schemaVersion:"openpond.profileExperimentOrigin.v1",...n,sourceRevision:d.sourceRevision,sourcePath:I,sourceFilesHash:d.filesHash},hostedImprovementOwner:!0}})).workspace);let H={source:"openpond_git",repositoryId:d.repositoryId,profileId:d.profileId},E=i(async()=>{if(r.throwIfAborted(),await B(I)!==d.filesHash||await B(d.repoPath)!==d.filesHash)throw new Error("Accepted source changed during private candidate I/O.")},"authorizer");if(t.operation==="advanced"){if(!t.advanced)throw new Error("Missing actual hosted advanced owner command.");return Fe({store:y,storeDir:t.storeDir,actor:n,profile:x,workspace:l,source:d,evidence:m,request:t.advanced,authorize:E,signal:r})}let P=i(()=>{if(!t.adoptionReadback)throw new Error("Actual hosted Git owner has not returned its sealed adoption receipt.");return e.object({receipt:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),activeRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),testedCandidateRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),executableSourceHash:e.string().regex(/^[a-f0-9]{64}$/),protectedClosureHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().parse(t.adoptionReadback)},"readback");h=Ee({store:y,storeDir:t.storeDir,projectHumanComparison:i(async()=>{if(await E(),!t.humanProjection)throw new Error("The current private Human comparison owner is unavailable.");return ne(t.humanProjection)},"projectHumanComparison"),authorizeOwner:i(async(a,o,g,b,S)=>{if(R(a)!==R(n)||R(g)!==R(H)||o.id!==v)throw new Error("Hosted candidate source owner changed.");if(S.requireCurrentBase&&(o.currentChannel.release?.contentHash!==l.currentChannel.release?.contentHash||d.sourceRevision!==o.metadata.profileExperimentOrigin.sourceRevision))throw new Error("Hosted candidate accepted revision changed.");await E()},"authorizeOwner"),loadEvidence:i(async(a,o)=>{if(R(a)!==R(n))throw new Error("Hosted candidate evidence actor changed.");let g=[m,...u].find(b=>b.manifest.id===o.id&&b.result.contentHash===o.contentHash&&b.manifest.teamId===n.teamId);if(!g)throw new Error("Hosted candidate exact retained evidence changed.");return await E(),g},"loadEvidence"),freezeProfile:i(async(a,o,g)=>{let b=await y.getHarnessReleaseRecord(o.baseRelease.contentHash);if(!b)throw new Error("Hosted source baseline is missing.");let S=await D({workspaceId:typeof b.agentSnapshot.metadata.workspaceId=="string"?b.agentSnapshot.metadata.workspaceId:b.workspaceId,sourceDir:A.join(b.bundlePath,"source")}),c=await D({workspaceId:typeof g.release.agentSnapshot.metadata.workspaceId=="string"?g.release.agentSnapshot.metadata.workspaceId:g.release.workspaceId,sourceDir:A.join(g.release.bundlePath,"source")});return Ae({store:y,storeDir:t.storeDir,state:o},async f=>{await Ce({...f,state:o,base:S,candidate:c});let k=await W(f.root,o.profileRef.profileId),T=await U({storeDir:t.storeDir,state:o,profile:k,sourceRevision:g.profileSourceRevision,base:S}),j=z(T);if(j.protectedClosureHash!==z(S).protectedClosureHash)throw new Error("Hosted source candidate changed protected evaluation closure.");let O=A.join(t.storeDir,"library","profile-candidate-archives",o.id,j.contentHash);await _.mkdir(A.dirname(O),{recursive:!0,mode:448}),await _.stat(O).catch(()=>null)||await _.cp(f.root,O,{recursive:!0,errorOnExist:!0,force:!1});let L=await W(O,o.profileRef.profileId);if((await U({storeDir:t.storeDir,state:o,profile:L,sourceRevision:g.profileSourceRevision,base:S})).harnessRelease.contentHash!==T.harnessRelease.contentHash)throw new Error("Hosted frozen Profile archive readback differs.");let F=await he({storeDir:t.storeDir,workspaceId:g.release.workspaceId,compiled:T,createdAt:g.release.createdAt});return await E(),{...g,release:F,executableIdentity:j}})},"freezeProfile"),adopt:i(async()=>P(),"adopt"),readAdoption:i(async()=>t.adoptionReadback?P():null,"readAdoption"),rollback:i(async()=>P(),"rollback")});let w=Pe({store:y,improvements:h,actorId:i(async()=>n.actorId,"actorId"),teamId:i(async()=>n.teamId,"teamId"),loadProfile:i(async a=>{if(R(a)!==R(H))throw new Error("Candidate requested another source owner.");return x},"loadProfile"),agentRuntime:t.agentRuntime,operationSignal:r,loadAgentRuntime:De({storeDir:t.storeDir,loadArchive:ze({storeDir:t.storeDir})})});if(t.operation==="describe"){await E();let a=l.currentChannel.release,o=a?await y.getHarnessReleaseRecord(a.contentHash):null;if(!a||!o||o.workspaceId!==l.id||o.harnessRelease.id!==a.id||o.harnessRelease.contentHash!==a.contentHash||l.ownerScope.kind!=="personal"||l.ownerScope.id!==n.actorId)throw new Error("Hosted source release is unavailable to its admitted owner.");let g=await D({workspaceId:typeof o.agentSnapshot.metadata.workspaceId=="string"?o.agentSnapshot.metadata.workspaceId:v,sourceDir:A.join(o.bundlePath,"source")});if(g.harnessRelease.contentHash!==o.harnessRelease.contentHash)throw new Error("Hosted source compiler readback changed.");let b=await ge({runtime:{release:o},ref:H,sourceRevision:d.sourceRevision,harnessRelease:a}),S=i(c=>{let f=g.sourceFiles.find(k=>k.path===c)?.bytes;return f?JSON.parse(Buffer.from(f).toString("utf8")):null},"readJson");return await E(),{workspaceId:v,ownerRevision:l.revision,profileRef:H,baseRelease:l.currentChannel.release,profileSourceRevision:d.sourceRevision,manifest:g.manifest,executable:z(g),catalogHash:b.catalogHash,workflows:S("workflows/catalog.json"),actions:S("workflows/actions.json")}}if(t.operation==="command"){let a=t.command;if(!a)throw new Error("Missing canonical Improve command.");if(a.operation==="start")return h.start(n,a.request);if(a.operation==="list")return h.list(n,a.limit,a.cursor);if(!("id"in a))throw new Error("Discover exact hosted source choices through the authenticated host.");let o=await h.read(n,a.id);if(a.operation==="read")return o;if(a.operation==="instructions"){let g=await h.partition(n,o.id),b=await me(g.sourceRoot,o.component.path),S=await _.readFile(b);if(S.length>25e4)throw new Error("Instruction editor size limit exceeded.");let c=S.toString("utf8");if(o.component.kind==="workflow"){let f=JSON.parse(c).workflows?.find(k=>k.id===o.component.workflowId);if(f?.invocation?.kind!=="instructions")throw new Error("Use Work to author this executable Workflow.");c=f.invocation.instructions}return{candidateId:o.id,candidateRevision:o.revision,path:o.component.path,text:c,textHash:J(c),contentHash:J(S)}}if(a.operation==="humanComparisonOptions")throw new Error("Read the actual paired sources through their current hosted Experiment owner.");if(!("revision"in a)||o.revision!==a.revision)throw new Error("Candidate revision changed.");if(a.operation==="edit")return h.edit(n,o.id,o.revision,a.expectedFileHash,a.text);if(a.operation==="mode")return h.setMode(n,o.id,o.revision,a.mode);if(a.operation==="freeze")return h.freeze(n,o.id,o.revision);if(a.operation==="useCandidate")return h.useCandidate(n,o.id,o.revision);if(a.operation==="rollback")return h.rollback(n,o.id,o.revision);if(a.operation==="discard")return h.discard(n,o.id,o.revision);throw new Error("Hosted Work/test lifecycle requires the actual host turn/run admission.")}if(!t.candidateId)throw new Error("Missing actual hosted candidate ID.");let p=await h.read(n,t.candidateId);if(t.operation==="beginAdoption")return h.beginAdoption(n,p.id,t.revision);if(t.operation==="export")return je(y,p,"hosted_execution");if(t.operation==="source"){if(!p.frozen||p.status!=="frozen"&&p.status!=="testing"&&p.status!=="ready_for_review"&&p.status!=="adopting")throw new Error("Only the exact frozen source can enter hosted preparation.");let a=await y.getHarnessReleaseRecord(p.frozen.release.contentHash);if(!a||a.harnessRelease.id!==p.frozen.release.id)throw new Error("Frozen hosted source is unavailable.");let o=await D({workspaceId:typeof a.agentSnapshot.metadata.workspaceId=="string"?a.agentSnapshot.metadata.workspaceId:a.workspaceId,sourceDir:A.join(a.bundlePath,"source")}),g=z(o);if(o.harnessRelease.contentHash!==p.frozen.release.contentHash||g.contentHash!==p.frozen.executableSourceHash||g.protectedClosureHash!==p.frozen.protectedClosureHash)throw new Error("Frozen hosted executable changed.");let b=A.join(t.storeDir,"library","profile-candidate-archives",p.id,g.contentHash),S=await W(b,p.profileRef.profileId);if(S.error||!S.sourcePath)throw new Error("Frozen actual Profile archive is unavailable.");let c=await y.getHarnessReleaseRecord(p.baseRelease.contentHash);if(!c)throw new Error("Frozen baseline is unavailable.");let f=await D({workspaceId:typeof c.agentSnapshot.metadata.workspaceId=="string"?c.agentSnapshot.metadata.workspaceId:c.workspaceId,sourceDir:A.join(c.bundlePath,"source")}),k=await U({storeDir:t.storeDir,state:p,profile:S,sourceRevision:p.frozen.profileSourceRevision,base:f});if(k.harnessRelease.contentHash!==p.frozen.release.contentHash||z(k).contentHash!==g.contentHash)throw new Error("Actual frozen Profile archive differs from its compiled release.");return{state:p,profileSource:{repoPath:b,profileId:p.profileRef.profileId,sourceRevision:p.frozen.profileSourceRevision,repositoryId:p.profileRef.repositoryId,filesHash:await B(b)},sourcePackage:te({agentSnapshot:o.agentSnapshot,harnessRelease:o.harnessRelease,files:new Map(o.sourceFiles.map(T=>[T.path,T.bytes]))})}}if(t.operation==="comparison"){if(!t.baseline||!t.candidate)throw new Error("Missing actual hosted paired evidence.");return h.completeComparison(n,p.id,t.revision,M(t.baseline),M(t.candidate),t.humanSelections)}if(t.operation==="beginTesting")return h.beginTesting(n,p.id,t.revision,t.recipe);if(t.operation==="failTesting"){if(!t.failure)throw new Error("Missing actual hosted test failure.");return h.failTesting(n,p.id,t.revision,t.failure.message,t.failure.cancelled)}if(t.operation==="cancelTesting")return h.cancelTesting(n,p.id,t.revision);if(t.operation==="queue"){if(!t.queued)throw new Error("Missing actual hosted queue admission.");return h.queueAuthoringTurn(n,p.id,t.revision,t.queued.sessionId,t.queued.turnId,t.queued.createdAt)}if(t.operation==="cancelQueued")return h.cancelQueuedAuthoring(n,p.id,t.revision);if(t.operation==="bind"||t.operation==="finish"||t.operation==="tool"||t.operation==="toolCatalog"){if(!t.actualSession||!t.actualTurn||t.actualTurn.sessionId!==t.actualSession.id||t.actualSession.cloudTeamId!==n.teamId||R(t.actualSession.currentProfile)!==R(H))throw new Error("Actual hosted candidate Work binding changed.");let a=t.actualSession,o=t.actualTurn,g=await y.getSession(a.id);if(!g)await y.insertSessionAtFront(a);else if(R({...g,updatedAt:a.updatedAt,status:a.status})!==R(a))throw new Error("Retained hosted candidate session changed.");let b=await y.getTurn(o.id);if(!b)await y.insertTurn(o);else{if(b.sessionId!==o.sessionId||R(b.metadata.refinementCandidate)!==R(o.metadata.refinementCandidate)||b.prompt!==o.prompt)throw new Error("Actual hosted candidate turn identity changed.");await y.updateTurn(o.id,()=>o)}if(t.operation==="bind")return h.bindAuthoringTurn(n,p.id,t.revision,a.id,o.id);if(t.operation==="finish")return h.finishAuthoring(n,p.id,t.revision);if(t.operation==="toolCatalog")return await w.candidateAuthoringForTurn(a.id,o.id),[...G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}),...Te(async()=>{throw new Error("Hosted file tools require a bound private call.")}),{name:"exec_command",description:"Run a bounded command confined to the selected public candidate component.",parameters:{type:"object",additionalProperties:!1,properties:{command:{type:"string",minLength:1,maxLength:2e4},cwd:{type:"string"}},required:["command"]}},{name:"view_image",description:"Inspect an image inside the candidate public source tree.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string"}},required:["path"]}}].map(({name:c,description:f,parameters:k})=>({name:c,description:f,parameters:k}));if(!t.tool)throw new Error("Missing candidate tool call.");await w.authorizeCandidateTool({sessionId:a.id,turnId:o.id,name:t.tool.name});let S={session:a,turnId:o.id,args:t.tool.args,callId:t.tool.callId,signal:r,workspaceDiffBaseline:null,turnPermissions:{approvalPolicy:"never",sandbox:"workspace-write",codexPermissionMode:"default"},provider:a.provider,model:o.modelRef?.modelId??a.modelRef?.modelId??"",mentionedApps:[],userPrompt:o.prompt,turnMetadata:o.metadata};if(t.tool.name==="get_profile"||t.tool.name.startsWith("agent_")||t.tool.name==="ask_user"){let c=G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}).find(f=>f.name===t.tool.name);if(!c)throw new Error("Candidate authoring tool is unavailable.");return c.execute(S)}if(t.tool.name==="view_image")return w.executeCandidateImage(S);if(t.tool.name==="exec_command")return w.executeCandidateCommand(S,{session:a,turnId:o.id,command:e.string().min(1).max(2e4).parse(t.tool.args.command),cwd:typeof t.tool.args.cwd=="string"?t.tool.args.cwd:null,signal:S.signal,source:"model_tool"});if(["list_files","read_files","search_files","workspace_status","write_file","write_files","edit_file","delete_file"].includes(t.tool.name))return w.executeCandidateWorkspaceTool({session:a,turnId:o.id,request:de.parse({action:t.tool.name,args:t.tool.args,source:"chat_action"})});throw new Error("This hosted tool has no confined candidate transport.")}throw new Error("Unknown private hosted Improve operation.")}finally{await h?.close(),await y.close()}}i(We,"runHostedExperimentImprovementOwner");async function wr(s){if(s.length!==1||s[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(s[0]))throw new Error("Hosted Improve IPC argument is invalid.");let r=e.object({directory:e.string(),file:e.string().regex(/^[A-Za-z0-9_-]+\.json$/)}).strict().parse(JSON.parse(Buffer.from(s[0],"base64url").toString("utf8")));if(!Ue.isAbsolute(r.directory))throw new Error("Hosted Improve IPC requires an absolute private directory.");let t=Ue.join(r.directory,r.file),n=await $e.lstat(t);if(!n.isFile()||n.isSymbolicLink()||n.size>32*1024*1024)throw new Error("Hosted Improve private request exceeds its byte/type limit.");let d=new AbortController,m=i(()=>d.abort(new Error("The actual hosted owner stopped this private operation.")),"stop");process.once("SIGTERM",m),process.once("SIGINT",m);try{let u=await We(JSON.parse(await $e.readFile(t,"utf8")),d.signal),v=Buffer.from(JSON.stringify(u));if(v.length>32*1024*1024)throw new Error("Hosted Improve private response exceeds its byte limit.");process.stdout.write(`${v.toString("utf8")}
3
+ `)}finally{process.removeListener("SIGTERM",m),process.removeListener("SIGINT",m)}}i(wr,"runHostedExperimentImprovementCli");export{wr as runHostedExperimentImprovementCli};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{b as a,c as b}from"./chunk-VJEZPDBS.js";import"./chunk-STDMBJOQ.js";import"./chunk-2DFR7PJ4.js";import"./chunk-5CMKGD43.js";import"./chunk-4WEUCGJ3.js";import"./chunk-MVF3F5QS.js";import"./chunk-L4235TRQ.js";import"./chunk-DLVPSCTB.js";import"./chunk-WDFLCNRC.js";import"./chunk-JIMU3KDA.js";import"./chunk-6MI4KKWF.js";import"./chunk-QDHMP5FS.js";import"./chunk-YDT7L3VZ.js";import"./chunk-6FA3GG5B.js";import"./chunk-55G6B54U.js";import"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as loadHostedHarnessRuntime,b as loadHostedHarnessRuntimeForSession};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a,e as F}from"./chunk-CGBI2VYJ.js";import{a as O}from"./chunk-QKD5OMDI.js";import{a as h}from"./chunk-OSIO7PLX.js";import{F as w,Sa as I,Va as D,Wa as M}from"./chunk-2DFR7PJ4.js";import"./chunk-5CMKGD43.js";import"./chunk-MVF3F5QS.js";import"./chunk-L4235TRQ.js";import"./chunk-DLVPSCTB.js";import"./chunk-WDFLCNRC.js";import{kf as A}from"./chunk-JIMU3KDA.js";import"./chunk-6MI4KKWF.js";import"./chunk-QDHMP5FS.js";import"./chunk-YDT7L3VZ.js";import"./chunk-6FA3GG5B.js";import"./chunk-55G6B54U.js";import{n as R}from"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import{k as C,l as v}from"./chunk-KGNCKIFP.js";import{b as c}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as f}from"./chunk-FTQLQJQV.js";import{promises as m}from"node:fs";import n from"node:path";var $=c.object({action:c.enum(["stage","readback","rollback"]),repoPath:c.string(),outputDir:c.string(),exportFile:c.string(),commit:c.string().regex(/^[a-f0-9]{40}$/).optional(),expectedExecutableSourceHash:c.string().regex(/^[a-f0-9]{64}$/).optional()}).strict();async function z(l){let e=$.parse(l);if(!n.isAbsolute(e.repoPath)||!n.isAbsolute(e.outputDir)||!/^[a-zA-Z0-9_-]+\.json$/.test(e.exportFile))throw new Error("Hosted candidate private IPC is not contained.");let g=n.join(e.outputDir,e.exportFile),H=await m.lstat(g);if(!H.isFile()||H.isSymbolicLink()||H.size>8*1024*1024)throw new Error("Hosted candidate export exceeds its private IPC bound.");let t=O(JSON.parse(await m.readFile(g,"utf8"))),u=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId});if(u.error||!u.sourcePath)throw new Error("Actual hosted Profile source is unavailable.");if(e.action!=="readback"){let o=!1;try{await a(e.repoPath,["symbolic-ref","-q","HEAD"]),o=!0}catch{}if(o||await a(e.repoPath,["rev-parse","HEAD"])!==(e.action==="rollback"?e.commit:t.expectedCommit)||await a(e.repoPath,["status","--porcelain","--untracked-files=all"]))throw new Error("Candidate staging requires a clean detached exact original source worktree.")}let x=f(async o=>I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),sourceRevision:o,repositoryId:t.compiler.repositoryId}),"compile");if(e.action==="readback"){if(!e.commit||await a(e.repoPath,["rev-parse","HEAD"])!==e.commit)throw new Error("Hosted Profile readback is not the committed source.");let o=await x(e.commit),i=h(o);if(i.profileGitHead!==e.commit||i.contentHash!==(e.expectedExecutableSourceHash??t.executableSourceHash)||i.protectedClosureHash!==t.protectedClosureHash)throw new Error("Hosted active executable differs from the actual tested candidate.");let s=await M({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,compiled:o,createdAt:t.createdAt});return{commit:e.commit,activeRelease:{id:s.harnessRelease.id,contentHash:s.harnessRelease.contentHash},executableSourceHash:i.contentHash,protectedClosureHash:i.protectedClosureHash}}if(e.action==="rollback"){if(!e.commit)throw new Error("Rollback requires the exact accepted commit.");await a(e.repoPath,["-c","core.hooksPath=/dev/null","revert","--no-commit",e.commit])}let p=await x(t.expectedCommit);if(p.harnessRelease.contentHash!==t.baseRelease.contentHash||p.harnessRelease.id!==t.baseRelease.id)throw new Error("Hosted original source differs from the owner-attested baseline release.");if(e.action==="stage"){let o=Buffer.from(t.sourceManifest.base64,"base64");if(o.toString("base64")!==t.sourceManifest.base64||o.length!==t.sourceManifest.sizeBytes||v(o)!==t.sourceManifest.contentHash)throw new Error("Candidate source manifest byte identity differs.");let i=A.parse(JSON.parse(o.toString("utf8"))),s=n.join(e.outputDir,"candidate-source");await m.mkdir(s,{recursive:!0}),await m.writeFile(n.join(s,"harness.json"),C(i));let _=R(t.policySource),j=new Map(p.sourceFiles.filter(r=>r.asset.visibility!=="policy").map(r=>[r.path,r]));for(let r of i.files){let k=r.visibility==="policy"?_.get(r.path):j.get(r.path)?.bytes;if(!k)throw new Error("The hosted source cannot hydrate the exact protected candidate closure.");let y=n.join(s,r.path);if(n.relative(s,y).startsWith(".."))throw new Error("Candidate release path escapes private staging.");await m.mkdir(n.dirname(y),{recursive:!0}),await m.writeFile(y,k)}let P=await D({workspaceId:t.compiler.workspaceId,sourceDir:s}),S=h(P);if(P.harnessRelease.contentHash!==t.policySource.harnessRelease.contentHash||S.contentHash!==t.executableSourceHash||S.protectedClosureHash!==t.protectedClosureHash)throw new Error("Owner-attested candidate differs from independently compiled hosted source.");await F({source:u.sourcePath,state:{component:t.component},base:p,candidate:P,profile:u})}await a(e.repoPath,["add","--all"]),await a(e.repoPath,["-c","core.hooksPath=/dev/null","-c","commit.gpgSign=false","commit","-m",`${e.action==="rollback"?"Roll back":"Adopt"} owner-tested candidate ${t.candidateId}`],{GIT_AUTHOR_NAME:"OpenPond",GIT_AUTHOR_EMAIL:"profile-candidate@openpond.local",GIT_COMMITTER_NAME:"OpenPond",GIT_COMMITTER_EMAIL:"profile-candidate@openpond.local"});let E=await a(e.repoPath,["rev-parse","HEAD"]),T=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),b=await I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:T,sourceRevision:E,repositoryId:t.compiler.repositoryId}),d=h(b);if(e.action==="stage"&&(d.contentHash!==t.executableSourceHash||d.protectedClosureHash!==t.protectedClosureHash)||e.action==="rollback"&&(d.contentHash!==h(p).contentHash||d.protectedClosureHash!==h(p).protectedClosureHash))throw new Error("Staged actual source differs from its exact tested executable graph.");return{commit:E,activeRelease:{id:b.harnessRelease.id,contentHash:b.harnessRelease.contentHash},executableSourceHash:d.contentHash,protectedClosureHash:d.protectedClosureHash}}f(z,"hostedProfileCandidate");async function Q(l){if(l.length!==1||l[0].length>16e3||!/^[a-zA-Z0-9_-]+$/.test(l[0]))throw new Error("Hosted candidate IPC argument is invalid.");process.stdout.write(`${JSON.stringify(await z(JSON.parse(Buffer.from(l[0],"base64url").toString("utf8"))))}
3
+ `)}f(Q,"runHostedProfileCandidateCli");export{z as hostedProfileCandidate,Q as runHostedProfileCandidateCli};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a,b,c,d}from"./chunk-R2BSIRYL.js";import"./chunk-2DFR7PJ4.js";import"./chunk-5CMKGD43.js";import"./chunk-MVF3F5QS.js";import"./chunk-L4235TRQ.js";import"./chunk-DLVPSCTB.js";import"./chunk-WDFLCNRC.js";import"./chunk-JIMU3KDA.js";import"./chunk-6MI4KKWF.js";import"./chunk-QDHMP5FS.js";import"./chunk-YDT7L3VZ.js";import"./chunk-6FA3GG5B.js";import"./chunk-55G6B54U.js";import"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as compileHostedProfileRelease,b as runHostedProfileCompilerCli,c as runHostedProfileEvaluationCli,d as runHostedProfileInspectionCli};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as m,b as c}from"./chunk-GGIG3XU7.js";import{a as l}from"./chunk-MVF3F5QS.js";import{Va as f}from"./chunk-JIMU3KDA.js";import"./chunk-6MI4KKWF.js";import{a as s,e as u}from"./chunk-QDHMP5FS.js";import"./chunk-YDT7L3VZ.js";import"./chunk-6FA3GG5B.js";import"./chunk-55G6B54U.js";import"./chunk-KD3QVRIJ.js";import"./chunk-JUJSA7KI.js";import{n as t}from"./chunk-KGNCKIFP.js";import{b as n}from"./chunk-ES2ISFJC.js";import{a as i}from"./chunk-FTQLQJQV.js";var v=n.object({profileRef:f,sourceRevision:n.string().min(1),action:n.enum(["compare","report"]),request:n.unknown(),runs:n.array(l).max(1e4),comparisons:n.array(s).max(1e4),suiteRuns:n.array(u).max(1e4)}).strict();async function h(p){let o=v.parse(p);for(let e of[...o.runs,...o.comparisons,...o.suiteRuns])t(e,"Hosted evaluation evidence");let a={getProfileEvaluationRun:i(async e=>o.runs.find(r=>r.manifest.id===e)??null,"getProfileEvaluationRun"),getProfileEvaluationComparison:i(async e=>o.comparisons.find(r=>r.id===e)??null,"getProfileEvaluationComparison"),getProfileEvaluationSuiteRun:i(async e=>o.suiteRuns.find(r=>r.id===e)??null,"getProfileEvaluationSuiteRun"),saveProfileEvaluationComparison:i(async(e,r)=>r,"saveProfileEvaluationComparison")};return o.action==="compare"?m({store:a,selectedProfile:i(async()=>({ref:o.profileRef,sourceRevision:o.sourceRevision}),"selectedProfile")})(o.request):c({store:a,profileRef:o.profileRef,request:o.request})}i(h,"controlHostedProfileEvaluation");export{h as controlHostedProfileEvaluation};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{c as R,d as P}from"./chunk-OULAKUIN.js";import{a as E}from"./chunk-MVF3F5QS.js";import{Q as h,Va as v,Wa as S,Xa as w,gb as y}from"./chunk-JIMU3KDA.js";import"./chunk-6MI4KKWF.js";import"./chunk-QDHMP5FS.js";import"./chunk-YDT7L3VZ.js";import"./chunk-6FA3GG5B.js";import{B as g}from"./chunk-55G6B54U.js";import{E as m}from"./chunk-KD3QVRIJ.js";import"./chunk-JUJSA7KI.js";import"./chunk-KGNCKIFP.js";import{b as s}from"./chunk-ES2ISFJC.js";import{a as n}from"./chunk-FTQLQJQV.js";var I=s.object({profileRef:v,inspection:R,run:E.nullable(),receipts:s.array(g).max(1e4),grades:s.array(m).max(1e4),sessions:s.array(S).max(1e4),turns:s.array(w).max(1e4),events:s.array(h).max(1e4),usage:s.array(y).max(1e4)}).strict();async function x(c){let t=I.parse(c),o=n((e,i)=>{let f=new Map;for(let p of e){let d=i(p);if(f.has(d))throw new Error("Hosted evaluation inspection has duplicate evidence identities.");f.set(d,p)}return f},"map"),r=o(t.receipts,e=>e.id),u=o(t.grades,e=>e.contentHash),l=o(t.sessions,e=>e.id),a=o(t.turns,e=>e.id);return P({profileRef:t.profileRef,...t.inspection,store:{getProfileEvaluationRun:n(async e=>t.run?.manifest.id===e?t.run:null,"getProfileEvaluationRun"),getProfileEvaluationReceipt:n(async e=>r.get(e)??null,"getProfileEvaluationReceipt"),getProfileEvaluationGrade:n(async e=>u.get(e)??null,"getProfileEvaluationGrade"),getSession:n(async e=>l.get(e)??null,"getSession"),getTurn:n(async e=>a.get(e)??null,"getTurn"),runtimeEventsForTurn:n(async e=>t.events.filter(i=>i.turnId===e),"runtimeEventsForTurn"),listModelUsageRecords:n(async e=>t.usage.filter(i=>(!e?.sessionId||i.sessionId===e.sessionId)&&(!e?.turnId||i.turnId===e.turnId)),"listModelUsageRecords")}})}n(x,"inspectHostedProfileEvaluation");async function B(c){if(c.length!==0)throw new Error("Hosted evaluation inspection uses bounded standard input.");let t=[],o=0;for await(let l of process.stdin){let a=Buffer.from(l);if(o+=a.length,o>32*1024*1024)throw new Error("Hosted evaluation inspection input is too large.");t.push(a)}let r=JSON.parse(Buffer.concat(t).toString("utf8")),u=r.action==="compare"||r.action==="report"?await(await import("./hosted-profile-evaluation-control-FKGARUEE.js")).controlHostedProfileEvaluation(r):await x(r);process.stdout.write(`${JSON.stringify(u)}
3
+ `)}n(B,"runHostedProfileInspectionCli");export{x as inspectHostedProfileEvaluation,B as runHostedProfileInspectionCli};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as V}from"./chunk-R2BSIRYL.js";import{c as I,f as j,h as D}from"./chunk-OWNLDB2O.js";import{k as x}from"./chunk-T4QGDQHP.js";import{a as E}from"./chunk-OSIO7PLX.js";import"./chunk-STDMBJOQ.js";import{Ma as b,Va as C}from"./chunk-2DFR7PJ4.js";import"./chunk-5CMKGD43.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-4WEUCGJ3.js";import"./chunk-MVF3F5QS.js";import"./chunk-L4235TRQ.js";import"./chunk-DLVPSCTB.js";import"./chunk-WDFLCNRC.js";import"./chunk-JIMU3KDA.js";import"./chunk-6MI4KKWF.js";import{m}from"./chunk-QDHMP5FS.js";import{wa as S}from"./chunk-YDT7L3VZ.js";import"./chunk-6FA3GG5B.js";import"./chunk-55G6B54U.js";import{Ja as H,c as P,f as R,v as y}from"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import{m as d}from"./chunk-KGNCKIFP.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as s}from"./chunk-FTQLQJQV.js";import{readFile as h,realpath as z,lstat as T}from"node:fs/promises";import l from"node:path";var B=e.object({compile:e.object({repoPath:e.string(),profileId:e.string(),repositoryId:e.string(),sourceRevision:e.string(),workspaceId:e.string(),outputDir:e.string()}).strict(),externalDatasetPackage:e.string().regex(/^external-dataset-[a-f0-9-]+\.json$/).optional(),sourceCandidate:H.optional(),action:e.enum(["catalog","prepare"]),request:e.unknown().optional()}).strict();async function G(t){let o=await V(t.compile);if(t.sourceCandidate){let a=await C({workspaceId:typeof o.agentSnapshot.metadata.workspaceId=="string"?o.agentSnapshot.metadata.workspaceId:o.workspaceId,sourceDir:l.join(o.bundlePath,"source")});if(d(t.sourceCandidate.harnessRelease)!==d({id:o.harnessRelease.id,contentHash:o.harnessRelease.contentHash})||E(a).protectedClosureHash!==t.sourceCandidate.protectedClosureHash)throw new Error("Private candidate source differs from its actual frozen compiled release.")}let g={release:b.parse({schemaVersion:"openpond.localHarnessReleaseRecord.v1",workspaceId:o.workspaceId,sourceRevision:o.sourceRevision,agentSnapshot:P.parse(o.agentSnapshot),harnessRelease:R.parse(o.harnessRelease),bundlePath:o.bundlePath,createdAt:new Date().toISOString()})},p={source:"openpond_git",profileId:t.compile.profileId,repositoryId:t.compile.repositoryId},f=t.compile.sourceRevision,c={id:o.harnessRelease.id,contentHash:o.harnessRelease.contentHash},w=s(async a=>x({...a,runtime:g}),"loadCatalog"),q=await w({ref:p,sourceRevision:f,harnessRelease:c}),k=l.join(o.bundlePath,"source"),v=o.harnessRelease.files.some(a=>a.path==="workflows/catalog.json")?await(async()=>{let a=y({agentSnapshot:o.agentSnapshot,harnessRelease:o.harnessRelease,catalogBytes:await h(l.join(k,"workflows/catalog.json")),actionBytes:await h(l.join(k,"workflows/actions.json"))});return a.catalog.workflows.map(r=>({workflow:r,binding:{schemaVersion:"openpond.profileWorkflowBinding.v1",profileId:p.profileId,sourceRevision:f,harnessRelease:c,catalogHash:a.catalogHash,workflowId:r.id}}))})():[],A={profileRef:p,sourceRevision:f,harnessRelease:c,workflows:v};if(t.action==="catalog")return{...q,workflows:v};let u=t.externalDatasetPackage?await(async()=>{let a=await z(t.compile.outputDir),r=l.join(a,t.externalDatasetPackage),i=await T(r);if(!i.isFile()||i.isSymbolicLink()||i.size>32*1024*1024||await z(r)!==r)throw new Error("External Dataset cache is outside its bounded verifier storage.");let n=e.object({packageValue:e.unknown(),graders:e.array(e.object({id:e.string(),version:e.string(),contentHash:e.string(),feedbackKey:e.string(),release:e.object({id:e.string(),revision:e.union([e.string(),e.number()]),contentHash:e.string()}).strict().nullable()}).strict()).max(100)}).strict().parse(JSON.parse(await h(r,"utf8")));return{packageValue:S(n.packageValue),graders:n.graders}})():null;return D({privateGradingPreflight:s(a=>I(a,!1),"privateGradingPreflight"),sourceCandidate:t.sourceCandidate,resolveExternalDataset:u?async a=>{let r=m({binding:a,...u}),i=d(o.harnessRelease.files.filter(n=>n.visibility!=="policy").map(n=>({path:n.path,asset:n})));if(a.protectedProfileClosureHash!==i)throw new Error("The selected Profile's protected evaluator closure changed.");return{binding:a,packageValue:r,authorize:s(async()=>{m({binding:a,...u})},"authorize")}}:void 0,loadCatalog:w,selectedWorkflows:s(async()=>A,"selectedWorkflows"),placement:"remote",boundedWorkComputeAvailable:!0,loadTasksetPackage:s(async a=>{let r=await j({runtime:g,definition:a,harnessRelease:c});if(!r)throw new Error("Hosted evaluation Taskset is absent from its published Profile release.");return r},"loadTasksetPackage"),modelConfigurationHash:s(async(a,r)=>{if(a.providerId!=="openpond"||!r.hostModelConfigurationHash)throw new Error("Hosted evaluation preparation requires a trusted model configuration receipt.");return r.hostModelConfigurationHash},"modelConfigurationHash")})(t.request)}s(G,"prepareHostedProfileEvaluation");async function ae(t){if(t.length!==1||t[0].length>48e3||!/^[A-Za-z0-9_-]+$/.test(t[0]))throw new Error("Hosted Profile evaluation preparation argument is invalid.");let o=B.parse(JSON.parse(Buffer.from(t[0],"base64url").toString("utf8")));process.stdout.write(`${JSON.stringify(await G(o))}
3
+ `)}s(ae,"runHostedProfileEvaluationCli");export{G as prepareHostedProfileEvaluation,ae as runHostedProfileEvaluationCli};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as E,c as S}from"./chunk-NPOHW5OU.js";import"./chunk-NNIRIUSY.js";import{c as I}from"./chunk-U2YMBCX7.js";import{c as x,f as y}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-BTI4N7YO.js";import"./chunk-BQAF5P7K.js";import{c as n}from"./chunk-3M53YXEI.js";import"./chunk-B7QDZPNX.js";import{s as R}from"./chunk-WZYRAR7X.js";import"./chunk-BT5YNE5U.js";import{d as g}from"./chunk-TERVLCRG.js";import{b}from"./chunk-GLUWATL5.js";import"./chunk-73G5UYBB.js";import"./chunk-YR5ID2SS.js";import{Q as v}from"./chunk-55G6B54U.js";import{$ as w,aa as f,ja as p,ka as h}from"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import{m as u}from"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as m}from"./chunk-FTQLQJQV.js";import{readFile as A,stat as L}from"node:fs/promises";async function C(r,l){let[o,a]=l,i=n(r,"team"),q=r.local===!0||r.local==="true";if(!i||!o||l.length>2)throw new Error("usage: human-review <read|inbox|inspect|results|request> [id] --team <id> [--input-file <path>] [--local --server-url <loopback-origin>]");let t;if(o==="request"){let e=n(r,"inputFile");if(a||!e||(await L(e)).size>1048576)throw new Error("Request requires a bounded --input-file with exact scoped pins, revision and stable operationId for mutations.");if(t=p.parse(JSON.parse(await A(e,"utf8"))),t.scope!==i)throw new Error("Input belongs to another workspace.")}else if(o==="inbox"){if(a)throw new Error("Inbox does not accept an assignment id.");t=p.parse({endpoint:"inbox",scope:i,view:n(r,"view")||"mine",status:n(r,"status")||"active",limit:Number(n(r,"limit")||100),...n(r,"project")?{projectId:n(r,"project")}:{},...n(r,"afterId")?{afterId:n(r,"afterId")}:{}})}else{if(!a)throw new Error(`${o} requires an exact assignment or execution id.`);t=p.parse(o==="read"?{endpoint:"get",scope:i,id:a,...n(r,"revision")?{revision:Number(n(r,"revision"))}:{}}:o==="inspect"?{endpoint:"inspect",scope:i,id:a,...n(r,"slot")?{slot:Number(n(r,"slot"))}:{},...n(r,"afterId")?{afterId:n(r,"afterId")}:{}}:o==="results"?{endpoint:"results",scope:i,executionId:a}:{endpoint:o,scope:i,id:a})}let s;if(q){let e=new URL(n(r,"serverUrl")||E);if(e.protocol!=="http:"||!["localhost","127.0.0.1","[::1]"].includes(e.hostname)||e.username||e.password||e.search||e.hash||e.pathname!=="/")throw new Error("Local Human review requires an HTTP loopback server origin.");let c=await S(e.origin),d=await c(new URL("/v1/human-review?location=local",e),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),redirect:"error",signal:AbortSignal.timeout(3e4)}),H=await U(d);if(s=JSON.parse(H),!d.ok)throw new Error(typeof s.error=="string"?s.error:`Local Human request failed (${d.status}).`)}else{let e=await g();s=await new R({scope:i,apiKey:await I(e,y(e)),baseUrl:x(r)??e.apiBaseUrl??b}).request(t,AbortSignal.timeout(3e4))}if(t.endpoint==="get"||t.endpoint==="command"){let e=w.parse(s),c=t.endpoint==="get"?t.id:t.command.id;if(e.id!==c||e.scope!==i)throw new Error("Review response differs from the requested identity.")}if(t.endpoint==="inbox"&&f.parse(s).items.some(c=>c.scope!==i||t.projectId&&c.projectId!==t.projectId))throw new Error("Inbox response differs from the requested scope.");if(t.endpoint==="inspect"&&h.parse(s).some(e=>e.reviewId!==t.id))throw new Error("Inspection response differs from the selected assignment.");if(t.endpoint==="results"){let e=v.parse(s),{contentHash:c,...d}=e;if(e.executionId!==t.executionId||u(d)!==c||t.selection!==void 0&&u(e.selection)!==u(t.selection))throw new Error("Result response differs from the selected execution or retained review revisions.")}console.log(JSON.stringify(s,null,2))}m(C,"runHumanReviewCommand");async function U(r){let l=r.body?.getReader();if(!l)throw new Error("Review response is unavailable.");let o=[],a=0;try{for(;;){let i=await l.read();if(i.done)break;if(a+=i.value.byteLength,a>8388608)throw new Error("Review response exceeds its bounded transport.");o.push(i.value)}}finally{await l.cancel(),l.releaseLock()}return Buffer.concat(o).toString("utf8")}m(U,"boundedResponse");export{C as runHumanReviewCommand};
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as D,b as ce,c as de,d as le,e as M,f as X,g as J,h as L,i as Z,j as B,k as z,l as P,m as ee,n as te,o as ue,p as se,q as pe,r as G}from"./chunk-PYABBF53.js";import{k as W}from"./chunk-N3DEA6PG.js";import{a as we}from"./chunk-PA7XP42P.js";import{c as ve,f as ye}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{c as E,f as H}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import{p as fe,q as me,r as F}from"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import{d as Y,g as he}from"./chunk-R3XFY7VL.js";import{b as ge}from"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import{l as ae,m as T}from"./chunk-NNF6KCHD.js";import{b as I}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as p}from"./chunk-FTQLQJQV.js";import{createInterface as qe}from"node:readline/promises";import{resolve as Ue}from"node:path";import{watch as Pe}from"node:fs";import{randomUUID as je}from"node:crypto";var Me=["source","admission","control","heartbeat"],j=class{static{p(this,"CollectorErrors")}store;constructor(e){this.store=e}read(e){let o=this.store.setting(`errors:${e}`);if(o)return JSON.parse(o);let s=this.store.database.prepare("SELECT error FROM backfill_units WHERE connection_id=? AND state='error' AND error IS NOT NULL ORDER BY session_key LIMIT 1").get(e);return typeof s?.error=="string"?{source:s.error}:{}}message(e,o){let s=this.read(e);return Me.filter(r=>r!==o).map(r=>s[r]).find(Boolean)??null}source(e){return this.read(e).source??null}set(e,o,s){let r=this.read(e);s?r[o]=s.slice(0,500):delete r[o],this.store.set(`errors:${e}`,JSON.stringify(r)),this.store.error(e,this.message(e))}};var Le=I.object({leafId:I.string().min(1).max(200),chainHash:I.string().regex(/^[a-f0-9]{64}$/),sourceInstanceId:I.string().min(1)}).strict(),Se=p((t,e)=>`branch:${JSON.stringify([t,e])}`,"key");function be(t,e,o){let s=t.setting(Se(e,o));if(!s)return;let r=Le.parse(JSON.parse(s));return t.connections().find(g=>g.id===e)?.source.instanceId===r.sourceInstanceId?{leafId:r.leafId,chainHash:r.chainHash}:void 0}p(be,"collectorBranchAnchor");async function Ie(t,e){if(t.source!=="claude_code")throw new Error("Branch selection is currently supported for Claude Code.");let o,s=[];do{let r=await M(t,{cursor:o,limit:100});s.push(...r.items.filter(a=>a.nativeSessionId===e)),o=r.nextCursor??void 0}while(o);if(s.length!==1)throw new Error("Select exactly one native session in this connection's source location.");return s[0]}p(Ie,"findSession");async function Re(t,e,o){let s=await B.open(t);try{let r=s.connections().find(g=>g.id===e);if(!r)throw new Error("Select a connection from openpond import status.");let a=await Ie(r.source,o);return{session:a,...await X(r.source,a)}}finally{s.close()}}p(Re,"inspectCollectorBranches");async function Ce(t,e,o,s){let r=await B.open(t);try{let a=r.connections().find(u=>u.id===e);if(!a||a.state!=="paused")throw new Error(`Pause this connection first: openpond import pause ${e}`);let g=await Ie(a.source,o),c=await X(a.source,g),l=c.branches.find(u=>u.leafId===s.leafId);if(c.revision!==s.revision||!l)throw new Error("This conversation changed. Refresh its branches and choose again.");await J(a.source,g,{branchLeafId:s.leafId,expectedBranchRevision:s.revision}),r.database.exec("BEGIN IMMEDIATE");try{let u=r.connections().find(S=>S.id===e);if(!u||u.state!=="paused"||u.revision!==a.revision||u.source.instanceId!==a.source.instanceId)throw new Error("Connection changed during branch selection. Refresh and try again.");r.set(Se(e,o),JSON.stringify({leafId:l.leafId,chainHash:l.chainHash,sourceInstanceId:a.source.instanceId}));for(let S of["source_scans","checkpoints","pending"])r.database.prepare(`DELETE FROM ${S} WHERE connection_id=?`).run(e);let v=new j(r);v.set(e,"source",v.source(e)),r.progress.reset(e),v.set(e,"admission",null),r.database.exec("COMMIT")}catch(u){throw r.database.exec("ROLLBACK"),u}return{connectionId:e,nativeSessionId:o,leafId:l.leafId,state:"paused"}}finally{r.close()}}p(Ce,"selectCollectorBranch");var V=class{static{p(this,"CollectorSyncRequests")}store;acquisitions=new Map;constructor(e){this.store=e}observe(e,o){let s=o.requestedSyncRevision??e.requestedSyncRevision??0,r=o.completedSyncRevision??0;if(!Number.isSafeInteger(s)||s<0||s>o.revision||!Number.isSafeInteger(r)||r<0||r>s)throw new Error("Invalid remote sync acknowledgement.");let a=this.confirmed(e.id);return r>a&&this.store.set(`syncAcknowledged:${e.id}`,String(r)),{requestedSyncRevision:Math.max(e.requestedSyncRevision??0,s),completedSyncRevision:Math.max(e.completedSyncRevision??0,r)}}needsAcquisition(e){let o=e.requestedSyncRevision??0;if(o<=(e.completedSyncRevision??0))return!1;let s=this.acquisitions.get(e.id);return s?.controlRevision!==e.revision||s.requestedSyncRevision!==o}acquired(e,o){this.acquisitions.set(e,o)}complete(e,o){let s=this.acquisitions.get(e.id),r=e.requestedSyncRevision??0;if(e.state!=="active"||this.store.setting("desiredState")!=="running"||this.store.queued(e.id)||o||!s?.succeeded||s.controlRevision!==e.revision||s.requestedSyncRevision!==r||r<=(e.completedSyncRevision??0))return e;let a={...e,completedSyncRevision:r};return this.store.put(a),a}confirmed(e){return Number(this.store.setting(`syncAcknowledged:${e}`))||0}needsAcknowledgement(e){return(e.completedSyncRevision??0)>this.confirmed(e.id)}};async function Ee(t){let e=await B.open(t.directory),o=je();e.database.exec("BEGIN IMMEDIATE");try{let i=e.setting("owner");if(i){let f=JSON.parse(i),h=!0;try{process.kill(f.pid,0)}catch(n){h=n.code!=="ESRCH"}if(h)throw new Error("The collector already has a live owner.")}e.set("owner",JSON.stringify({pid:process.pid,nonce:o})),e.database.exec("COMMIT")}catch(i){throw e.database.exec("ROLLBACK"),e.close(),i}if(e.setting("desiredState")!=="running"){e.set("owner",""),e.close();return}e.set("pid",String(process.pid));let s=!0,r=0,a=0,g=new Map,c=new j(e),l=new V(e),u=new Map;function v(i){return e.connections().find(f=>f.id===i.id)??i}p(v,"retained");function S(i){let f=e.queued(i.id),h=c.message(i.id,"heartbeat");return{pendingOperations:f,error:h,completedSyncRevision:!f&&!h?i.completedSyncRevision??0:0}}p(S,"heartbeatInput");function d(i,f){let h=v(i);if(h.state==="disconnected"||f.revision<h.revision)return h;let n=l.observe(h,f);f.revision>h.revision&&c.set(h.id,"control",null);let m={...h,...n,...f.revision>h.revision?{revision:f.revision,state:f.state}:{},...f.destinations?{destinations:f.destinations}:{}};return e.put(m),m}p(d,"applyRemote");function R(i,f,h){let n=f instanceof Error?f.message:"Collection failed.";c.set(i.id,h,n);let m=f&&typeof f=="object"&&"status"in f?Number(f.status):0,C=v(i);C.state!=="disconnected"&&[400,401,403].includes(m)&&e.put({...C,state:m===400?"paused":"disconnected"})}p(R,"recordFailure");async function N(i){let f=i.revision,h=i.requestedSyncRevision??0,n,m=[];do{if(Date.now()-a>=L.heartbeatMs){a=Date.now(),e.set("heartbeatAt",new Date().toISOString());for(let w of e.connections())if(w.state!=="disconnected")try{let x=await t.transport.heartbeat(w,S(w));d(w,x),c.set(w.id,"heartbeat",null)}catch(x){R(w,x,"heartbeat")}}if(i=e.connections().find(w=>w.id===i.id)??i,i.state!=="active"||t.signal.aborted||e.setting("desiredState")!=="running")return;let C=await M(i.source,{since:i.since??void 0,cursor:n,limit:50});for(let w of C.items){let x=JSON.stringify([w.path,w.nativeSessionId]),O=w.storageRevision?T([w.storageRevision,de(i.source.source)]):null;if(e.progress.select(i.id,x),t.signal.aborted||e.setting("desiredState")!=="running"||e.connections().find(y=>y.id===i.id)?.state!=="active")return;try{if(O&&!e.sourceChanged(i.id,x,O)&&!e.progress.tracks(i.id,x))continue;let{files:y,preview:b,branchLeafId:k}=await J(i.source,w,{branchAnchor:be(e,i.id,w.nativeSessionId)}),$=!1;for(let q of b.sessions){let _=JSON.stringify([i.source.instanceId,q.sessionId,q.branchId]);e.progress.retained(i.id,x,_);let ne=q.boundaries.filter(A=>A.projection==="turn"&&A.terminal!=="unknown"&&(!i.since||Date.parse(q.events[A.start].occurredAt??w.updatedAt)>=Date.parse(i.since)));$||=ne.length>0;let ie=ne.filter(A=>e.changed(i.id,_,A.id,T([A.inputHash,A.revisionHash])));for(let A=0;A<ie.length;A+=L.batchCases){let Q=ie.slice(A,A+L.batchCases),De=`sync-${T([i.id,_,Q.map(U=>[U.id,U.inputHash,U.revisionHash])]).slice(0,48)}`;e.enqueue({operationId:De,connectionId:i.id,sessionKey:_,contentHash:q.contentHash,files:y,boundaryIds:Q.map(U=>U.id),...k?{branchLeafId:k}:{}},Q.map(U=>({id:U.id,revision:T([U.inputHash,U.revisionHash])})),x)}}e.progress.read(i.id,x,$),O&&e.scanned(i.id,x,O)}catch(y){if(y instanceof le){e.progress.read(i.id,x,!1),O&&e.scanned(i.id,x,O);continue}e.progress.failed(i.id,x,y instanceof Error?y.message:"Unable to read session"),m.push(`${w.nativeSessionId}: ${y instanceof Error?y.message:"Unable to read session"}`)}}n=C.nextCursor??void 0}while(n);e.progress.discovered(i.id),u.set(i.id,f),l.acquired(i.id,{controlRevision:f,requestedSyncRevision:h,succeeded:m.length===0}),c.set(i.id,"source",m.length?`${m.length} session(s) need attention. ${m[0]}`:null)}p(N,"acquire");try{for(;!t.signal.aborted&&e.setting("desiredState")==="running";){let i=e.connections();e.set("heartbeatAt",new Date().toISOString());for(let n of i)if(n.state!=="disconnected"&&!g.has(n.source.root))try{let m=Pe(n.source.root,{recursive:n.source.acquisition!=="sqlite"},()=>{s=!0});m.on("error",()=>{s=!0}),g.set(n.source.root,m)}catch{}let f=Date.now()-a>=L.heartbeatMs;f&&(a=Date.now());let h=s||Date.now()-r>=L.reconcileMs||e.setting("syncNow")==="yes";h&&(s=!1,r=Date.now(),e.set("syncNow","no"));for(let n of i){if(n=v(n),n.state==="disconnected")continue;let m="heartbeat";try{if(f){let w=await t.transport.heartbeat(n,S(n));n=d(n,w),c.set(n.id,"heartbeat",null)}if(n.state!=="active"){u.delete(n.id);continue}if(m="source",(h||u.get(n.id)!==n.revision||l.needsAcquisition(n))&&await N(n),n=e.connections().find(w=>w.id===n.id)??n,n.state!=="active"||t.signal.aborted||e.setting("desiredState")!=="running")continue;m="admission";let C=e.next(n.id);if(C)try{await t.transport.admit(n,C.entry),e.acknowledge(C.entry),c.set(n.id,"admission",null)}catch(w){throw e.retry(C.entry.operationId,C.attempts),w}if(n=v(n),t.signal.aborted||e.setting("desiredState")!=="running"||n.state!=="active")continue;if(n=l.complete(n,c.message(n.id,"heartbeat")),l.needsAcknowledgement(n)&&S(n).completedSyncRevision){m="heartbeat";let w=await t.transport.heartbeat(n,S(n));n=d(n,w),c.set(n.id,"heartbeat",null)}if(!t.signal.aborted&&e.setting("desiredState")==="running"&&n.state==="active"&&!n.keepSyncing&&u.get(n.id)===n.revision&&e.queued(n.id)===0&&e.progress.status(n.id).stage==="complete"&&!c.source(n.id)&&l.confirmed(n.id)>=(n.requestedSyncRevision??0)){if(m="control",!t.transport.pause)throw new Error("This transport cannot acknowledge completion of a one-time import.");let w=await t.transport.pause(n);d(n,w),c.set(n.id,"control",null)}}catch(C){R(n,C,m)}}await new Promise(n=>{let m=p(()=>{clearTimeout(C),t.signal.removeEventListener("abort",m),n()},"done"),C=setTimeout(m,1e3);t.signal.addEventListener("abort",m,{once:!0})})}}finally{for(let f of g.values())f.close();JSON.parse(e.setting("owner")||"{}").nonce===o&&(e.set("pid",""),e.set("heartbeatAt",""),e.set("owner","")),e.close()}}p(Ee,"runCollector");import{createHash as Ne,generateKeyPairSync as Ke,createPublicKey as _e,diffieHellman as Je,createDecipheriv as ze}from"node:crypto";import{spawn as Ge}from"node:child_process";var xe=p(t=>Ne("sha256").update(t).digest("hex"),"hash"),Fe=I.object({publicKey:I.string().max(200),iv:I.string().max(100),tag:I.string().max(100),ciphertext:I.string().max(1e4)}).strict();async function re(t,e,o){let s=await fetch(`${t}${e}`,{method:"POST",redirect:"error",signal:AbortSignal.timeout(15e3),headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),r=await s.text();if(r.length>16384)throw new Error("Authorization response exceeded its limit.");if(!s.ok)throw Object.assign(new Error(`Browser sign-in failed (${s.status}).`),{status:s.status});return JSON.parse(r)}p(re,"post");function Ye(t){let e=process.platform==="darwin"?"open":process.platform==="win32"?"rundll32":"xdg-open",o=process.platform==="win32"?["url.dll,FileProtocolHandler",t]:[t],s=Ge(e,o,{stdio:"ignore",detached:!0});s.on("error",()=>{}),s.unref()}p(Ye,"openBrowser");async function Oe(t,e){let o=await Y(),s=ve(e)||o.apiBaseUrl||ge,r=E(e,"baseUrl")||(new URL(s).hostname==="staging-api.openpond.ai"?"https://staging.openpond.ai":ye(o)),a=new URL(r),g=new URL(s);for(let d of[a,g])if(d.protocol!=="https:"&&!(d.protocol==="http:"&&["localhost","127.0.0.1"].includes(d.hostname))||d.username||d.password||d.search||d.hash)throw new Error("Sign-in requires a clean HTTPS origin or local development origin.");let c=`import-${xe([a.origin,t.machineId,t.instanceId].join(":")).slice(0,24)}`,l=Ke("x25519"),u=l.publicKey.export({format:"der",type:"spki"}).toString("base64"),v=I.object({deviceCode:I.string(),userCode:I.string(),expiresAt:I.string().datetime(),intervalSeconds:I.number().min(2).max(10)}).strict().parse(await re(a.origin,"/api/cli/import/device",{publicKey:u,machineId:t.machineId,sourceInstanceId:t.instanceId,sourceLabel:D[t.source],sourceRoot:t.root,...E(e,"team")?{requestedTeamId:E(e,"team")}:{}})),S=`${a.origin}/console/connections/authorize?code=${encodeURIComponent(v.userCode)}`;for(console.log(`OpenPond sign-in code: ${v.userCode}
2
+ import{a as D,b as ce,c as de,d as le,e as M,f as X,g as J,h as L,i as Z,j as B,k as z,l as P,m as ee,n as te,o as ue,p as se,q as pe,r as G}from"./chunk-IODUCRBA.js";import{k as W}from"./chunk-NNIRIUSY.js";import{a as we}from"./chunk-U2YMBCX7.js";import{c as ve,f as ye}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-BTI4N7YO.js";import"./chunk-BQAF5P7K.js";import{c as E,f as H}from"./chunk-3M53YXEI.js";import"./chunk-B7QDZPNX.js";import{n as fe,o as me,p as F}from"./chunk-WZYRAR7X.js";import"./chunk-BT5YNE5U.js";import{d as Y,g as he}from"./chunk-TERVLCRG.js";import{b as ge}from"./chunk-GLUWATL5.js";import"./chunk-73G5UYBB.js";import"./chunk-YR5ID2SS.js";import"./chunk-55G6B54U.js";import"./chunk-KD3QVRIJ.js";import"./chunk-ARQEJOEK.js";import"./chunk-JUJSA7KI.js";import{l as ae,m as T}from"./chunk-KGNCKIFP.js";import{b as I}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as p}from"./chunk-FTQLQJQV.js";import{createInterface as qe}from"node:readline/promises";import{resolve as Ue}from"node:path";import{watch as Pe}from"node:fs";import{randomUUID as je}from"node:crypto";var Me=["source","admission","control","heartbeat"],j=class{static{p(this,"CollectorErrors")}store;constructor(e){this.store=e}read(e){let o=this.store.setting(`errors:${e}`);if(o)return JSON.parse(o);let s=this.store.database.prepare("SELECT error FROM backfill_units WHERE connection_id=? AND state='error' AND error IS NOT NULL ORDER BY session_key LIMIT 1").get(e);return typeof s?.error=="string"?{source:s.error}:{}}message(e,o){let s=this.read(e);return Me.filter(r=>r!==o).map(r=>s[r]).find(Boolean)??null}source(e){return this.read(e).source??null}set(e,o,s){let r=this.read(e);s?r[o]=s.slice(0,500):delete r[o],this.store.set(`errors:${e}`,JSON.stringify(r)),this.store.error(e,this.message(e))}};var Le=I.object({leafId:I.string().min(1).max(200),chainHash:I.string().regex(/^[a-f0-9]{64}$/),sourceInstanceId:I.string().min(1)}).strict(),Se=p((t,e)=>`branch:${JSON.stringify([t,e])}`,"key");function be(t,e,o){let s=t.setting(Se(e,o));if(!s)return;let r=Le.parse(JSON.parse(s));return t.connections().find(g=>g.id===e)?.source.instanceId===r.sourceInstanceId?{leafId:r.leafId,chainHash:r.chainHash}:void 0}p(be,"collectorBranchAnchor");async function Ie(t,e){if(t.source!=="claude_code")throw new Error("Branch selection is currently supported for Claude Code.");let o,s=[];do{let r=await M(t,{cursor:o,limit:100});s.push(...r.items.filter(a=>a.nativeSessionId===e)),o=r.nextCursor??void 0}while(o);if(s.length!==1)throw new Error("Select exactly one native session in this connection's source location.");return s[0]}p(Ie,"findSession");async function Re(t,e,o){let s=await B.open(t);try{let r=s.connections().find(g=>g.id===e);if(!r)throw new Error("Select a connection from openpond import status.");let a=await Ie(r.source,o);return{session:a,...await X(r.source,a)}}finally{s.close()}}p(Re,"inspectCollectorBranches");async function Ce(t,e,o,s){let r=await B.open(t);try{let a=r.connections().find(u=>u.id===e);if(!a||a.state!=="paused")throw new Error(`Pause this connection first: openpond import pause ${e}`);let g=await Ie(a.source,o),c=await X(a.source,g),l=c.branches.find(u=>u.leafId===s.leafId);if(c.revision!==s.revision||!l)throw new Error("This conversation changed. Refresh its branches and choose again.");await J(a.source,g,{branchLeafId:s.leafId,expectedBranchRevision:s.revision}),r.database.exec("BEGIN IMMEDIATE");try{let u=r.connections().find(S=>S.id===e);if(!u||u.state!=="paused"||u.revision!==a.revision||u.source.instanceId!==a.source.instanceId)throw new Error("Connection changed during branch selection. Refresh and try again.");r.set(Se(e,o),JSON.stringify({leafId:l.leafId,chainHash:l.chainHash,sourceInstanceId:a.source.instanceId}));for(let S of["source_scans","checkpoints","pending"])r.database.prepare(`DELETE FROM ${S} WHERE connection_id=?`).run(e);let v=new j(r);v.set(e,"source",v.source(e)),r.progress.reset(e),v.set(e,"admission",null),r.database.exec("COMMIT")}catch(u){throw r.database.exec("ROLLBACK"),u}return{connectionId:e,nativeSessionId:o,leafId:l.leafId,state:"paused"}}finally{r.close()}}p(Ce,"selectCollectorBranch");var V=class{static{p(this,"CollectorSyncRequests")}store;acquisitions=new Map;constructor(e){this.store=e}observe(e,o){let s=o.requestedSyncRevision??e.requestedSyncRevision??0,r=o.completedSyncRevision??0;if(!Number.isSafeInteger(s)||s<0||s>o.revision||!Number.isSafeInteger(r)||r<0||r>s)throw new Error("Invalid remote sync acknowledgement.");let a=this.confirmed(e.id);return r>a&&this.store.set(`syncAcknowledged:${e.id}`,String(r)),{requestedSyncRevision:Math.max(e.requestedSyncRevision??0,s),completedSyncRevision:Math.max(e.completedSyncRevision??0,r)}}needsAcquisition(e){let o=e.requestedSyncRevision??0;if(o<=(e.completedSyncRevision??0))return!1;let s=this.acquisitions.get(e.id);return s?.controlRevision!==e.revision||s.requestedSyncRevision!==o}acquired(e,o){this.acquisitions.set(e,o)}complete(e,o){let s=this.acquisitions.get(e.id),r=e.requestedSyncRevision??0;if(e.state!=="active"||this.store.setting("desiredState")!=="running"||this.store.queued(e.id)||o||!s?.succeeded||s.controlRevision!==e.revision||s.requestedSyncRevision!==r||r<=(e.completedSyncRevision??0))return e;let a={...e,completedSyncRevision:r};return this.store.put(a),a}confirmed(e){return Number(this.store.setting(`syncAcknowledged:${e}`))||0}needsAcknowledgement(e){return(e.completedSyncRevision??0)>this.confirmed(e.id)}};async function Ee(t){let e=await B.open(t.directory),o=je();e.database.exec("BEGIN IMMEDIATE");try{let i=e.setting("owner");if(i){let f=JSON.parse(i),h=!0;try{process.kill(f.pid,0)}catch(n){h=n.code!=="ESRCH"}if(h)throw new Error("The collector already has a live owner.")}e.set("owner",JSON.stringify({pid:process.pid,nonce:o})),e.database.exec("COMMIT")}catch(i){throw e.database.exec("ROLLBACK"),e.close(),i}if(e.setting("desiredState")!=="running"){e.set("owner",""),e.close();return}e.set("pid",String(process.pid));let s=!0,r=0,a=0,g=new Map,c=new j(e),l=new V(e),u=new Map;function v(i){return e.connections().find(f=>f.id===i.id)??i}p(v,"retained");function S(i){let f=e.queued(i.id),h=c.message(i.id,"heartbeat");return{pendingOperations:f,error:h,completedSyncRevision:!f&&!h?i.completedSyncRevision??0:0}}p(S,"heartbeatInput");function d(i,f){let h=v(i);if(h.state==="disconnected"||f.revision<h.revision)return h;let n=l.observe(h,f);f.revision>h.revision&&c.set(h.id,"control",null);let m={...h,...n,...f.revision>h.revision?{revision:f.revision,state:f.state}:{},...f.destinations?{destinations:f.destinations}:{}};return e.put(m),m}p(d,"applyRemote");function R(i,f,h){let n=f instanceof Error?f.message:"Collection failed.";c.set(i.id,h,n);let m=f&&typeof f=="object"&&"status"in f?Number(f.status):0,C=v(i);C.state!=="disconnected"&&[400,401,403].includes(m)&&e.put({...C,state:m===400?"paused":"disconnected"})}p(R,"recordFailure");async function N(i){let f=i.revision,h=i.requestedSyncRevision??0,n,m=[];do{if(Date.now()-a>=L.heartbeatMs){a=Date.now(),e.set("heartbeatAt",new Date().toISOString());for(let w of e.connections())if(w.state!=="disconnected")try{let x=await t.transport.heartbeat(w,S(w));d(w,x),c.set(w.id,"heartbeat",null)}catch(x){R(w,x,"heartbeat")}}if(i=e.connections().find(w=>w.id===i.id)??i,i.state!=="active"||t.signal.aborted||e.setting("desiredState")!=="running")return;let C=await M(i.source,{since:i.since??void 0,cursor:n,limit:50});for(let w of C.items){let x=JSON.stringify([w.path,w.nativeSessionId]),O=w.storageRevision?T([w.storageRevision,de(i.source.source)]):null;if(e.progress.select(i.id,x),t.signal.aborted||e.setting("desiredState")!=="running"||e.connections().find(y=>y.id===i.id)?.state!=="active")return;try{if(O&&!e.sourceChanged(i.id,x,O)&&!e.progress.tracks(i.id,x))continue;let{files:y,preview:b,branchLeafId:k}=await J(i.source,w,{branchAnchor:be(e,i.id,w.nativeSessionId)}),$=!1;for(let q of b.sessions){let _=JSON.stringify([i.source.instanceId,q.sessionId,q.branchId]);e.progress.retained(i.id,x,_);let ne=q.boundaries.filter(A=>A.projection==="turn"&&A.terminal!=="unknown"&&(!i.since||Date.parse(q.events[A.start].occurredAt??w.updatedAt)>=Date.parse(i.since)));$||=ne.length>0;let ie=ne.filter(A=>e.changed(i.id,_,A.id,T([A.inputHash,A.revisionHash])));for(let A=0;A<ie.length;A+=L.batchCases){let Q=ie.slice(A,A+L.batchCases),De=`sync-${T([i.id,_,Q.map(U=>[U.id,U.inputHash,U.revisionHash])]).slice(0,48)}`;e.enqueue({operationId:De,connectionId:i.id,sessionKey:_,contentHash:q.contentHash,files:y,boundaryIds:Q.map(U=>U.id),...k?{branchLeafId:k}:{}},Q.map(U=>({id:U.id,revision:T([U.inputHash,U.revisionHash])})),x)}}e.progress.read(i.id,x,$),O&&e.scanned(i.id,x,O)}catch(y){if(y instanceof le){e.progress.read(i.id,x,!1),O&&e.scanned(i.id,x,O);continue}e.progress.failed(i.id,x,y instanceof Error?y.message:"Unable to read session"),m.push(`${w.nativeSessionId}: ${y instanceof Error?y.message:"Unable to read session"}`)}}n=C.nextCursor??void 0}while(n);e.progress.discovered(i.id),u.set(i.id,f),l.acquired(i.id,{controlRevision:f,requestedSyncRevision:h,succeeded:m.length===0}),c.set(i.id,"source",m.length?`${m.length} session(s) need attention. ${m[0]}`:null)}p(N,"acquire");try{for(;!t.signal.aborted&&e.setting("desiredState")==="running";){let i=e.connections();e.set("heartbeatAt",new Date().toISOString());for(let n of i)if(n.state!=="disconnected"&&!g.has(n.source.root))try{let m=Pe(n.source.root,{recursive:n.source.acquisition!=="sqlite"},()=>{s=!0});m.on("error",()=>{s=!0}),g.set(n.source.root,m)}catch{}let f=Date.now()-a>=L.heartbeatMs;f&&(a=Date.now());let h=s||Date.now()-r>=L.reconcileMs||e.setting("syncNow")==="yes";h&&(s=!1,r=Date.now(),e.set("syncNow","no"));for(let n of i){if(n=v(n),n.state==="disconnected")continue;let m="heartbeat";try{if(f){let w=await t.transport.heartbeat(n,S(n));n=d(n,w),c.set(n.id,"heartbeat",null)}if(n.state!=="active"){u.delete(n.id);continue}if(m="source",(h||u.get(n.id)!==n.revision||l.needsAcquisition(n))&&await N(n),n=e.connections().find(w=>w.id===n.id)??n,n.state!=="active"||t.signal.aborted||e.setting("desiredState")!=="running")continue;m="admission";let C=e.next(n.id);if(C)try{await t.transport.admit(n,C.entry),e.acknowledge(C.entry),c.set(n.id,"admission",null)}catch(w){throw e.retry(C.entry.operationId,C.attempts),w}if(n=v(n),t.signal.aborted||e.setting("desiredState")!=="running"||n.state!=="active")continue;if(n=l.complete(n,c.message(n.id,"heartbeat")),l.needsAcknowledgement(n)&&S(n).completedSyncRevision){m="heartbeat";let w=await t.transport.heartbeat(n,S(n));n=d(n,w),c.set(n.id,"heartbeat",null)}if(!t.signal.aborted&&e.setting("desiredState")==="running"&&n.state==="active"&&!n.keepSyncing&&u.get(n.id)===n.revision&&e.queued(n.id)===0&&e.progress.status(n.id).stage==="complete"&&!c.source(n.id)&&l.confirmed(n.id)>=(n.requestedSyncRevision??0)){if(m="control",!t.transport.pause)throw new Error("This transport cannot acknowledge completion of a one-time import.");let w=await t.transport.pause(n);d(n,w),c.set(n.id,"control",null)}}catch(C){R(n,C,m)}}await new Promise(n=>{let m=p(()=>{clearTimeout(C),t.signal.removeEventListener("abort",m),n()},"done"),C=setTimeout(m,1e3);t.signal.addEventListener("abort",m,{once:!0})})}}finally{for(let f of g.values())f.close();JSON.parse(e.setting("owner")||"{}").nonce===o&&(e.set("pid",""),e.set("heartbeatAt",""),e.set("owner","")),e.close()}}p(Ee,"runCollector");import{createHash as Ne,generateKeyPairSync as Ke,createPublicKey as _e,diffieHellman as Je,createDecipheriv as ze}from"node:crypto";import{spawn as Ge}from"node:child_process";var xe=p(t=>Ne("sha256").update(t).digest("hex"),"hash"),Fe=I.object({publicKey:I.string().max(200),iv:I.string().max(100),tag:I.string().max(100),ciphertext:I.string().max(1e4)}).strict();async function re(t,e,o){let s=await fetch(`${t}${e}`,{method:"POST",redirect:"error",signal:AbortSignal.timeout(15e3),headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),r=await s.text();if(r.length>16384)throw new Error("Authorization response exceeded its limit.");if(!s.ok)throw Object.assign(new Error(`Browser sign-in failed (${s.status}).`),{status:s.status});return JSON.parse(r)}p(re,"post");function Ye(t){let e=process.platform==="darwin"?"open":process.platform==="win32"?"rundll32":"xdg-open",o=process.platform==="win32"?["url.dll,FileProtocolHandler",t]:[t],s=Ge(e,o,{stdio:"ignore",detached:!0});s.on("error",()=>{}),s.unref()}p(Ye,"openBrowser");async function Oe(t,e){let o=await Y(),s=ve(e)||o.apiBaseUrl||ge,r=E(e,"baseUrl")||(new URL(s).hostname==="staging-api.openpond.ai"?"https://staging.openpond.ai":ye(o)),a=new URL(r),g=new URL(s);for(let d of[a,g])if(d.protocol!=="https:"&&!(d.protocol==="http:"&&["localhost","127.0.0.1"].includes(d.hostname))||d.username||d.password||d.search||d.hash)throw new Error("Sign-in requires a clean HTTPS origin or local development origin.");let c=`import-${xe([a.origin,t.machineId,t.instanceId].join(":")).slice(0,24)}`,l=Ke("x25519"),u=l.publicKey.export({format:"der",type:"spki"}).toString("base64"),v=I.object({deviceCode:I.string(),userCode:I.string(),expiresAt:I.string().datetime(),intervalSeconds:I.number().min(2).max(10)}).strict().parse(await re(a.origin,"/api/cli/import/device",{publicKey:u,machineId:t.machineId,sourceInstanceId:t.instanceId,sourceLabel:D[t.source],sourceRoot:t.root,...E(e,"team")?{requestedTeamId:E(e,"team")}:{}})),S=`${a.origin}/console/connections/authorize?code=${encodeURIComponent(v.userCode)}`;for(console.log(`OpenPond sign-in code: ${v.userCode}
3
3
  ${S}`),Ye(S);Date.now()<Date.parse(v.expiresAt);){await new Promise(m=>setTimeout(m,v.intervalSeconds*1e3));let d;try{d=await re(a.origin,"/api/cli/import/token",{deviceCode:v.deviceCode})}catch(m){if(Number(m.status)===429)continue;throw m}let R=I.object({state:I.enum(["pending","approved","denied","consumed"]),envelope:Fe.nullable().optional()}).strict().parse(d);if(R.state==="denied"||R.state==="consumed")throw new Error("Browser sign-in was declined or already consumed. Start the connection again.");if(R.state!=="approved"||!R.envelope)continue;let N=R.envelope,i=_e({key:Buffer.from(N.publicKey,"base64"),format:"der",type:"spki"});if(i.asymmetricKeyType!=="x25519")throw new Error("Invalid sign-in encryption key.");let f=Ne("sha256").update(Je({privateKey:l.privateKey,publicKey:i})).digest(),h=ze("aes-256-gcm",f,Buffer.from(N.iv,"base64"));h.setAAD(Buffer.from(xe(v.deviceCode))),h.setAuthTag(Buffer.from(N.tag,"base64"));let n=I.object({apiKey:I.string().min(1),teamId:I.string().min(1),expiresAt:I.string().datetime()}).strict().parse(JSON.parse(Buffer.concat([h.update(Buffer.from(N.ciphertext,"base64")),h.final()]).toString("utf8")));if(E(e,"team")&&n.teamId!==E(e,"team"))throw new Error("Browser approved a different workspace.");return await he({handle:c,apiKey:n.apiKey,baseUrl:a.origin,apiBaseUrl:g.origin,setActive:!1}),await re(a.origin,"/api/cli/import/token",{deviceCode:v.deviceCode,acknowledge:!0}),{apiKey:n.apiKey,teamId:n.teamId,baseUrl:g.origin,account:c,accountBaseUrl:a.origin}}throw new Error("Browser sign-in expired. Start the connection again.")}p(Oe,"authorizeImporter");async function K(t){let e=await Y({account:t.account,baseUrl:t.accountBaseUrl}),o=t.account?e.apiKey:we(e);if(!o)throw Object.assign(new Error("This source is disconnected. Reconnect it with OpenPond Importer to authorize collection."),{status:401});let s={apiKey:o,baseUrl:t.apiBaseUrl,teamId:t.teamId};return{evidence:new me(s),sync:new F(s)}}p(K,"collectorClients");var ke={async pause(t){let{sync:e}=await K(t),o=await e.control({id:t.id,expectedRevision:t.revision,action:"pause"});return{revision:o.revision,state:o.state,destinations:Z(t,o),requestedSyncRevision:o.requestedSyncRevision,completedSyncRevision:o.completedSyncRevision}},async heartbeat(t,e){let{sync:o}=await K(t),s=await o.heartbeat({id:t.id,expectedRevision:t.revision,...e});return{revision:s.revision,state:s.state,destinations:Z(t,s),requestedSyncRevision:s.requestedSyncRevision,completedSyncRevision:s.completedSyncRevision}},async admit(t,e){let{evidence:o,sync:s}=await K(t),r=AbortSignal.timeout(6e4),a=Buffer.from(JSON.stringify(e.files.map(d=>({path:d.path,encoding:"utf8",base64:Buffer.from(d.text).toString("base64")})))),g={hash:ae(a),parts:Math.ceil(a.length/2e5)};for(let d=0;d<g.parts;d++)await o.uploadPart({...g,index:d,base64:a.subarray(d*2e5,(d+1)*2e5).toString("base64")},r);let c={upload:g,source:t.source.source,...e.branchLeafId?{branchLeafId:e.branchLeafId}:{},destination:{kind:"existing",projectId:t.projectId},acquisition:{machineId:t.source.machineId,sourceInstanceId:t.source.instanceId}},l=await o.preview(c,r);if(l.issues.length)throw Object.assign(new Error("Source schema was rejected; inspect the connection before resuming."),{status:400});let u=l.sessions.find(d=>d.sessionHash===e.contentHash);if(!u||e.boundaryIds.some(d=>!u.boundaries.some(R=>R.id===d&&R.projection==="turn"&&R.terminal!=="unknown")))throw Object.assign(new Error("Server preview differs from the retained source boundaries."),{status:400});let v={...c,operationId:e.operationId,previewHash:l.previewHash,selection:[{sessionHash:u.sessionHash,boundaryIds:e.boundaryIds}]},S=fe.parse(await s.commit({connectionId:t.id,expectedRevision:t.revision,request:v},r));if(S.state!=="completed"||S.operationId!==e.operationId||S.requestHash!==T(v)||S.projectId!==t.projectId)throw new Error("Admission did not acknowledge this retained operation.")}};import{emitKeypressEvents as We}from"node:readline";async function Ae(t){console.log("Ctrl+C closes this view and keeps syncing. Ctrl+D pauses this connection.");let e=new AbortController,o=p(()=>e.abort(),"detach"),s=!1,r=process.stdin.isRaw,a=p((c,l)=>{l?.ctrl&&(l.name==="c"&&o(),l.name==="d"&&!s&&(s=!0,t.pause().then(o).catch(u=>{console.error(`
4
4
  Unable to pause: ${u instanceof Error?u.message:"connection update failed"}`),s=!1})))},"keypress");We(process.stdin),process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("keypress",a),process.stdin.once("end",o),process.once("SIGINT",o);let g=0;try{for(;!e.signal.aborted;){let c=await P(t.directory),l=c.connections.find(f=>f.id===t.connectionId);if(!l)break;let u=l.backfill,v=u.admitted+u.skipped,S=u.total?v/u.total:u.stage==="complete"?1:0,d=Math.max(0,Math.min(20,Math.floor(S*20))),R=u.stage==="discovering"?`${["|","/","-","\\"][g++%4]} Discovering conversations (${u.total} found)`:`[${"=".repeat(d)}${" ".repeat(20-d)}] ${v}/${u.total} conversations`,N=c.running?l.state!=="active"?l.state:u.stage==="complete"?t.keepSyncing?"Watching for new conversations":"Import complete":u.stage:"Service offline",i=`${R} ${l.admitted} tasks admitted ${u.skipped} skipped ${u.failed} need attention ${l.queued} queued ${l.error||N}${l.lastAdmissionAt?` Last sync ${l.lastAdmissionAt}`:""}`;if(process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(i),!t.keepSyncing&&l.state==="paused"&&l.queued===0)break;await new Promise(f=>{let h=p(()=>{clearTimeout(n),e.signal.removeEventListener("abort",h),f()},"done"),n=setTimeout(h,1e3);e.signal.addEventListener("abort",h,{once:!0})})}}finally{process.stdin.off("keypress",a),process.stdin.off("end",o),process.off("SIGINT",o),process.stdin.setRawMode(r??!1),process.stdin.pause(),console.log()}}p(Ae,"monitorImport");async function oe(t,e){let o=await B.open(t),s;try{s=o.connections().find(r=>r.id===e)}finally{o.close()}if(!s)throw new Error("Select a retained connection from openpond import status.");if(s.source.machineId!==await G(t))throw new Error("This connection belongs to another machine. Use explicit Connect setup.");if(!s.accountBaseUrl)throw new Error("The original sign-in destination is unavailable. Use explicit Connect setup.");return s}p(oe,"retainedReconnect");function Te(t,e){if(!e?.available||!e.capabilities.history||e.source!==t.source.source||e.machineId!==t.source.machineId||e.instanceId!==t.source.instanceId||e.root!==t.source.root)throw new Error("The retained source is unavailable or its identity changed. Restore its original location or use explicit Connect setup.")}p(Te,"assertReconnectSource");async function $e(t,e){let o=await oe(t,e.id),s=p(r=>({...r,destinations:void 0,requestedSyncRevision:r.requestedSyncRevision??0,completedSyncRevision:r.completedSyncRevision??0}),"scope");if(T(s(o))!==T(s(e)))throw new Error("The connection changed during sign-in. Reconnect again after reviewing its current scope.")}p($e,"assertReconnectUnchanged");import{createInterface as Ve}from"node:readline/promises";async function Be(t,e,o,s){let r=E(s,"session");if(!o||!r)throw new Error("Use openpond import branches <connection-id> --session <native-session-id>.");let a=await Re(t,o,r);if(e==="branches"){console.log(JSON.stringify(a,null,2));return}let g=process.stdin.isTTY&&process.stdout.isTTY&&!H(s.json),c=E(s,"leaf"),l=E(s,"revision");if(!c&&g){a.branches.forEach((S,d)=>console.log(`${d+1}. ${S.title||S.leafId} (${S.messages} messages; ${S.updatedAt||"date unavailable"})`));let v=Ve({input:process.stdin,output:process.stdout});try{c=a.branches[Number(await v.question("Choose the branch to sync: "))-1]?.leafId??"",l=a.revision}finally{v.close()}}if(!c||!l)throw new Error("Supply --leaf and --revision from import branches, or choose interactively. No branch was selected.");if(!a.branches.some(v=>v.leafId===c)||l!==a.revision)throw new Error("Branch selection is stale or invalid. Run import branches again.");if(!H(s.yes)&&(!g||!await W("Sync only this branch and its unambiguous future continuation for this conversation? Other branches stay excluded.",!1)))throw new Error("Branch selection was not approved.");let u=await Ce(t,o,r,{leafId:c,revision:l});console.log(JSON.stringify({...u,next:`openpond import resume ${o}`},null,2))}p(Be,"runImporterBranchCommand");async function is(t,e){let[o="connect",s]=e,r=Ue(E(t,"collectorDir")||pe()),a=H(t.json),g=p(y=>console.log(JSON.stringify(y,null,2)),"print");if(o==="branches"||o==="branch"){await Be(r,o,s,t);return}if(o==="service"){if(s==="status"){g(await P(r));return}if(s==="stop"){g(await ee(r,"stop"));return}if(s==="uninstall"){g(await ue(r));return}if(s==="install"){g(await te({directory:r,executable:process.execPath,args:[process.argv[1]],environment:He()}));return}if(s==="start"){g(await se(r));return}if(s==="run"){let y=new AbortController,b=p(()=>y.abort(),"stop");process.once("SIGTERM",b),process.once("SIGINT",b);try{await Ee({directory:r,transport:ke,signal:y.signal})}finally{process.off("SIGTERM",b),process.off("SIGINT",b)}return}throw new Error("usage: openpond import service <install|start|stop|status|run|uninstall>")}if(o==="status"){g(await P(r));return}if(o==="sync"){g(await ee(r,"sync"));return}if(["pause","resume","disconnect"].includes(o)){let y=await B.open(r),b;try{b=y.connections().find(q=>q.id===s)}finally{y.close()}if(!b)throw new Error("Select a connection id from openpond import status.");let{sync:k}=await K(b),$=await k.control({id:b.id,expectedRevision:b.revision,action:o});await z(r,{...b,revision:$.revision,state:$.state}),g($);return}let c=o==="reconnect"?await oe(r,s):null;c&&(t={...t,source:c.source.source,sourcePath:c.source.root,project:c.projectId,connection:c.id,team:c.teamId,apiBaseUrl:c.apiBaseUrl,baseUrl:c.accountBaseUrl,once:!c.keepSyncing});let l=E(t,"source");if(l&&!(l in D))throw new Error("Choose a supported native source name.");let u=await G(r),v=await ce({machineId:u,...l&&E(t,"sourcePath")?{locations:{[l]:Ue(E(t,"sourcePath"))}}:{}});if(o==="discover"){g(v);return}if(o!=="connect"&&o!=="reconnect")throw new Error("usage: openpond import <connect|reconnect|discover|status|sync|pause|resume|disconnect|branches|branch|service>");let S=v.filter(y=>y.source===l),d=S.length===1?S[0]:void 0,R=process.stdin.isTTY&&process.stdout.isTTY&&!a;if(c&&Te(c,d),!d&&R){let y=S.length>1?S:v.filter(k=>k.available);y.forEach((k,$)=>console.log(`${$+1}. ${D[k.source]} ${k.root}${k.capabilities.history?"":` (${k.reason})`}`));let b=qe({input:process.stdin,output:process.stdout});try{d=y[Number(await b.question("Choose a source: "))-1]}finally{b.close()}}if(!d?.capabilities.history)throw new Error(d?.reason??(S.length>1?"Multiple source instances found. Select the exact --source-path or use interactive setup.":"Select --source and optionally --source-path."));let N=E(t,"range")||"week";if(!c&&R&&!t.range){let y=qe({input:process.stdin,output:process.stdout});try{N=(await y.question("History: day, week, or all [week]: ")).trim()||"week"}finally{y.close()}}if(!["day","week","all"].includes(N))throw new Error("--range must be day, week or all.");let i=c?c.since:N==="all"?null:new Date(Date.now()-(N==="day"?1:7)*864e5).toISOString(),f=await M(d,{since:i??void 0,limit:100});a||console.log(`Found ${f.items.length}${f.nextCursor?"+":""} sessions in ${d.root}. History: ${c?i?`since ${i}`:"all":N}.`);let h=!H(t.once),n=E(t,"project");if(!H(t.yes)&&(!R||!await W(`Sync this source to ${n||"your personal Imported conversations Project"} and ${h?"keep syncing":"import once"}?`,!0)))throw new Error("Connection was not approved. No history was uploaded.");let m=await Oe(d,t),C=new F(m),w=E(t,"connection")||`sync-${T([m.baseUrl,m.teamId,d.instanceId,n||"default"]).slice(0,40)}`;c&&await $e(r,c);let x=(await C.list()).items.find(y=>y.id===w),O=await C.register({id:w,source:d.source,machineId:u,sourceInstanceId:d.instanceId,sourceLabel:D[d.source],sourceRoot:d.root,destination:n?{kind:"existing",projectId:n}:{kind:"new",name:"Imported conversations"},since:i,keepSyncing:h,expectedRevision:x?.revision??0});await z(r,{id:O.id,teamId:m.teamId,apiBaseUrl:m.baseUrl,account:m.account,accountBaseUrl:m.accountBaseUrl,source:d,projectId:O.projectId,revision:O.revision,requestedSyncRevision:O.requestedSyncRevision,completedSyncRevision:O.completedSyncRevision,since:i,keepSyncing:h,state:O.state}),await te({directory:r,executable:process.execPath,args:[process.argv[1]],environment:He()}),await se(r),g({connection:O,service:await P(r)}),R&&!H(t.detach)&&await Ae({directory:r,connectionId:w,keepSyncing:h,async pause(){let y=await B.open(r),b;try{b=y.connections().find(q=>q.id===w)}finally{y.close()}if(!b)throw new Error("The connection is unavailable.");let{sync:k}=await K(b),$=await k.control({id:b.id,expectedRevision:b.revision,action:"pause"});await z(r,{...b,revision:$.revision,state:$.state})}})}p(is,"runImportCommand");function He(){return{...process.env.OPENPOND_HOME?{OPENPOND_HOME:process.env.OPENPOND_HOME}:{},...process.env.ELECTRON_RUN_AS_NODE==="1"?{ELECTRON_RUN_AS_NODE:"1"}:{}}}p(He,"collectorEnvironment");export{is as runImportCommand};