openpond 0.2.57 → 0.2.59

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 (291) hide show
  1. package/dist/app-server.d.ts +2 -1
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/{actions-command-QU4H53OG.js → actions-command-JJ3CU7J6.js} +1 -1
  4. package/dist/chunks/{app-layer-NSTE5HIT.js → app-layer-KAUZAHGE.js} +1 -1
  5. package/dist/chunks/{app-server-connected-apps-JHGWLBXT.js → app-server-connected-apps-SXGZOUJJ.js} +1 -1
  6. package/dist/chunks/{app-server-evaluations-GJPFWIDA.js → app-server-evaluations-N4OMTPCI.js} +1 -1
  7. package/dist/chunks/{app-server-harness-services-IH4G6POY.js → app-server-harness-services-DDFUMNYC.js} +1 -1
  8. package/dist/chunks/app-server-runtime-SVB6L26M.js +2 -0
  9. package/dist/chunks/{apps-BKTOR4F7.js → apps-EZB56RHV.js} +1 -1
  10. package/dist/chunks/{chunk-SDXFLO7J.js → chunk-22VMH6JV.js} +1 -1
  11. package/dist/chunks/{chunk-FTEOCCPB.js → chunk-25JDHAZ5.js} +1 -1
  12. package/dist/chunks/{chunk-PPAPVGJP.js → chunk-2G4BEISF.js} +1 -1
  13. package/dist/chunks/{chunk-O72BSKSO.js → chunk-2L5XWJJ5.js} +1 -1
  14. package/dist/chunks/{chunk-QOTVNQDI.js → chunk-2RNQQNB7.js} +2 -2
  15. package/dist/chunks/{chunk-O6ULLQJ6.js → chunk-2WKUBGIF.js} +1 -1
  16. package/dist/chunks/{chunk-F4KOGISR.js → chunk-37MWETFU.js} +1 -1
  17. package/dist/chunks/{chunk-D74JEERO.js → chunk-3CDEBKSU.js} +1 -1
  18. package/dist/chunks/{chunk-L6K7ERG5.js → chunk-4EDIRCD3.js} +1 -1
  19. package/dist/chunks/{chunk-JYKRR7E5.js → chunk-4GPXTISD.js} +1 -1
  20. package/dist/chunks/chunk-57TRXBLT.js +3 -0
  21. package/dist/chunks/{chunk-LQQNBVEB.js → chunk-76M2MEHV.js} +1 -1
  22. package/dist/chunks/{chunk-HCYX6RHP.js → chunk-776WNDV2.js} +1 -1
  23. package/dist/chunks/{chunk-HDL5YSAA.js → chunk-7AVNZF36.js} +1 -1
  24. package/dist/chunks/{chunk-3K4VVB7S.js → chunk-7K7O3CKY.js} +1 -1
  25. package/dist/chunks/chunk-7UH4YDA7.js +3 -0
  26. package/dist/chunks/{chunk-KUERKVEU.js → chunk-ABZ2ZOLU.js} +1 -1
  27. package/dist/chunks/{chunk-ZRDGQDZL.js → chunk-ANFDRKUU.js} +1 -1
  28. package/dist/chunks/{chunk-GWCHDF2C.js → chunk-AQD7K4Z5.js} +1 -1
  29. package/dist/chunks/{chunk-4D7HWVWD.js → chunk-ARLOVWQ3.js} +1 -1
  30. package/dist/chunks/{chunk-2QUCCP6Z.js → chunk-ATAOHSFR.js} +1 -1
  31. package/dist/chunks/{chunk-3RCRSMWZ.js → chunk-BE6SS65L.js} +2 -2
  32. package/dist/chunks/{chunk-Z54O534A.js → chunk-BGJYITVI.js} +1 -1
  33. package/dist/chunks/{chunk-BLXEAZCQ.js → chunk-BL3YH2QU.js} +1 -1
  34. package/dist/chunks/{chunk-2D4Y3HNW.js → chunk-BO5JZYWG.js} +1 -1
  35. package/dist/chunks/{chunk-ZGTOK7ZK.js → chunk-BQS7Z4AP.js} +1 -1
  36. package/dist/chunks/{chunk-7HPDGZOR.js → chunk-BRORSFJX.js} +3 -3
  37. package/dist/chunks/{chunk-XXYGGNVM.js → chunk-BVQWVIGK.js} +1 -1
  38. package/dist/chunks/{chunk-SWUEFLOH.js → chunk-C37PUHA6.js} +1 -1
  39. package/dist/chunks/{chunk-3VUATFZD.js → chunk-CGWA54LE.js} +1 -1
  40. package/dist/chunks/{chunk-EQFGBL3O.js → chunk-CKMSBAI2.js} +1 -1
  41. package/dist/chunks/{chunk-YOBN7KTF.js → chunk-COHMDT7A.js} +7 -7
  42. package/dist/chunks/{chunk-JDEEWOD7.js → chunk-DPHAN6N3.js} +1 -1
  43. package/dist/chunks/{chunk-YOQRYNLP.js → chunk-DZUN5YWB.js} +1 -1
  44. package/dist/chunks/{chunk-6FDWRG55.js → chunk-E72UU4VX.js} +1 -1
  45. package/dist/chunks/{chunk-ABD5M2D2.js → chunk-EOBHQ3JT.js} +1 -1
  46. package/dist/chunks/chunk-EQOV34UH.js +2 -0
  47. package/dist/chunks/chunk-EUMXMT3S.js +2 -0
  48. package/dist/chunks/{chunk-773TH7FN.js → chunk-EWOSLZDX.js} +1 -1
  49. package/dist/chunks/{chunk-HIOKCIL7.js → chunk-FAYASU7Z.js} +1 -1
  50. package/dist/chunks/{chunk-EIRYMSEG.js → chunk-FKJHEZCW.js} +1 -1
  51. package/dist/chunks/{chunk-Q2QL6UWN.js → chunk-GL3NX3F3.js} +1 -1
  52. package/dist/chunks/{chunk-UKMA4R6X.js → chunk-GOPFFQZU.js} +1 -1
  53. package/dist/chunks/{chunk-RAXOSUSW.js → chunk-GUOLMLZN.js} +1 -1
  54. package/dist/chunks/{chunk-GZ7M5XBP.js → chunk-GVZLGS2U.js} +1 -1
  55. package/dist/chunks/chunk-GYJQKCEO.js +5 -0
  56. package/dist/chunks/{chunk-XDQMGUWL.js → chunk-H7ATCPPB.js} +1 -1
  57. package/dist/chunks/{chunk-J2TWKFML.js → chunk-IFDALGZE.js} +4 -4
  58. package/dist/chunks/{chunk-S5ESN275.js → chunk-IRV6GWGG.js} +3 -3
  59. package/dist/chunks/chunk-JFXINDOQ.js +3 -0
  60. package/dist/chunks/{chunk-PRGBLQVH.js → chunk-JMBQYBPI.js} +1 -1
  61. package/dist/chunks/{chunk-DBK66CJP.js → chunk-JQKSXCAJ.js} +1 -1
  62. package/dist/chunks/{chunk-DARVPBZ4.js → chunk-JUQMSHNR.js} +1 -1
  63. package/dist/chunks/{chunk-3Z47M3YY.js → chunk-K44RHALX.js} +1 -1
  64. package/dist/chunks/{chunk-4EPSHPZL.js → chunk-KO3HNMLJ.js} +1 -1
  65. package/dist/chunks/{chunk-4NESNOK5.js → chunk-LNCHFVHT.js} +1 -1
  66. package/dist/chunks/{chunk-7E6T7GP5.js → chunk-LPWBIGKW.js} +1 -1
  67. package/dist/chunks/{chunk-OIUTWU6K.js → chunk-MFMYWZK2.js} +1 -1
  68. package/dist/chunks/{chunk-A6USMRWK.js → chunk-MMQRHR3V.js} +1 -1
  69. package/dist/chunks/{chunk-I7AQMAQI.js → chunk-MNC4YUDI.js} +6 -6
  70. package/dist/chunks/{chunk-ZFSHBFG5.js → chunk-N6ENLEMY.js} +2 -2
  71. package/dist/chunks/{chunk-SH5CBAFC.js → chunk-NTB2O4RP.js} +1 -1
  72. package/dist/chunks/{chunk-OQKJGTTO.js → chunk-O3RF72BT.js} +1 -1
  73. package/dist/chunks/{chunk-QEFHOJFE.js → chunk-O4VIXU7A.js} +1 -1
  74. package/dist/chunks/{chunk-5MCNZCVQ.js → chunk-OLDK2LKJ.js} +1 -1
  75. package/dist/chunks/{chunk-WMKYHXVM.js → chunk-OX3XZKGK.js} +2 -2
  76. package/dist/chunks/{chunk-SDAUS5PY.js → chunk-P2RSBSCT.js} +1 -1
  77. package/dist/chunks/{chunk-EKM2D7JU.js → chunk-PFSMXKTI.js} +1 -1
  78. package/dist/chunks/{chunk-FUOEIDMA.js → chunk-PH6IORGZ.js} +1 -1
  79. package/dist/chunks/{chunk-PUZQU66L.js → chunk-PQJTYOR2.js} +1 -1
  80. package/dist/chunks/{chunk-OLLLZVHF.js → chunk-PY6K2JRH.js} +1 -1
  81. package/dist/chunks/{chunk-EYPCBBMS.js → chunk-RBZH6A6M.js} +1 -1
  82. package/dist/chunks/{chunk-6QSSIT62.js → chunk-RZUEVS64.js} +1 -1
  83. package/dist/chunks/{chunk-Q5LEXXJG.js → chunk-SF5HJ7PL.js} +4 -4
  84. package/dist/chunks/{chunk-NHQ36THU.js → chunk-TG7P7BSV.js} +1 -1
  85. package/dist/chunks/{chunk-G3RXYI2L.js → chunk-TIHXUKFD.js} +1 -1
  86. package/dist/chunks/{chunk-QOGJAQDO.js → chunk-TKLBP3MM.js} +1 -1
  87. package/dist/chunks/{chunk-M4JWQSV7.js → chunk-U2MAPON2.js} +1 -1
  88. package/dist/chunks/chunk-U5FKRYJO.js +86 -0
  89. package/dist/chunks/{chunk-QNG27G3T.js → chunk-V34H7Y2T.js} +2 -2
  90. package/dist/chunks/chunk-VGRMAGOK.js +9 -0
  91. package/dist/chunks/chunk-VRODAXFS.js +145 -0
  92. package/dist/chunks/{chunk-EIEZHFIW.js → chunk-WC42WOLG.js} +1 -1
  93. package/dist/chunks/{chunk-OS3LO5J3.js → chunk-WRI4XKSK.js} +1 -1
  94. package/dist/chunks/{chunk-XTFPDQMH.js → chunk-XJZSIXEO.js} +2 -2
  95. package/dist/chunks/{chunk-25MBPJVY.js → chunk-XMKCCLGB.js} +1 -1
  96. package/dist/chunks/{chunk-HZEIRHEB.js → chunk-XMWXH7TS.js} +1 -1
  97. package/dist/chunks/chunk-YCQSVHCD.js +9 -0
  98. package/dist/chunks/{chunk-B7RFL4N2.js → chunk-YHHF4Q7Y.js} +1 -1
  99. package/dist/chunks/{chunk-DMVD2RFZ.js → chunk-ZAN4DYLH.js} +1 -1
  100. package/dist/chunks/chunk-ZH3K7LKQ.js +2 -0
  101. package/dist/chunks/cli-5DFVQL5Y.js +2 -0
  102. package/dist/chunks/{configuration-command-6C5UO7GE.js → configuration-command-JS6U3RMC.js} +1 -1
  103. package/dist/chunks/connected-app-executor-UBMGMV76.js +2 -0
  104. package/dist/chunks/{connected-evidence-GH2ATNEX.js → connected-evidence-NLAIEVQ3.js} +1 -1
  105. package/dist/chunks/connection-NZSD3U5O.js +2 -0
  106. package/dist/chunks/{continual-6CQAMTTR.js → continual-WFPIDWPH.js} +1 -1
  107. package/dist/chunks/core-commands-U4IBRRY5.js +2 -0
  108. package/dist/chunks/{datasets-7BNMVJOY.js → datasets-UX47DTTB.js} +1 -1
  109. package/dist/chunks/{desktop-test-3CUHVLXV.js → desktop-test-UUU7PD4P.js} +1 -1
  110. package/dist/chunks/{dist-VYC5VMQB.js → dist-OGLX76LL.js} +1 -1
  111. package/dist/chunks/{dist-ZVJPJLXR.js → dist-W5MJYSPF.js} +1 -1
  112. package/dist/chunks/{evaluation-coordination-XEF5L7KZ.js → evaluation-coordination-3YQN5JQW.js} +1 -1
  113. package/dist/chunks/{experiment-improvements-KRX2DP27.js → experiment-improvements-ZRVD2AGY.js} +1 -1
  114. package/dist/chunks/{experiments-DFGQYA4O.js → experiments-JEB5A2N5.js} +1 -1
  115. package/dist/chunks/{extension-XKXXOP5N.js → extension-JCUA3RWV.js} +1 -1
  116. package/dist/chunks/{help-S7THC6IE.js → help-KA4OINP5.js} +1 -1
  117. package/dist/chunks/host-profile-evaluation-tools-2URLU5SG.js +2 -0
  118. package/dist/chunks/host-profile-external-dataset-B2AQNSDR.js +2 -0
  119. package/dist/chunks/{hosted-app-server-composition-HPL3CRXN.js → hosted-app-server-composition-VJQ3FM4I.js} +1 -1
  120. package/dist/chunks/{hosted-experiment-improvement-NFSVS5TU.js → hosted-experiment-improvement-42YWXB3P.js} +1 -1
  121. package/dist/chunks/hosted-harness-runtime-BM4WONJN.js +2 -0
  122. package/dist/chunks/{hosted-profile-candidate-2S5LFUWD.js → hosted-profile-candidate-HVVC43XQ.js} +1 -1
  123. package/dist/chunks/hosted-profile-compiler-RKDWHYK3.js +2 -0
  124. package/dist/chunks/{hosted-profile-evaluation-control-76BTRTYD.js → hosted-profile-evaluation-control-57V24UGU.js} +1 -1
  125. package/dist/chunks/{hosted-profile-evaluation-inspection-V6Z3A5XJ.js → hosted-profile-evaluation-inspection-BUWLCKCD.js} +1 -1
  126. package/dist/chunks/{hosted-profile-evaluation-preparation-IDJYREW3.js → hosted-profile-evaluation-preparation-3XLRR6UH.js} +1 -1
  127. package/dist/chunks/{hosted-tasksets-ANAE2PIW.js → hosted-tasksets-THKM5QY5.js} +1 -1
  128. package/dist/chunks/{human-review-WR777ODH.js → human-review-CSYAW4PC.js} +1 -1
  129. package/dist/chunks/import-CBDJ4DME.js +3 -0
  130. package/dist/chunks/local-harness-improvement-runtime-3T6E7I5Q.js +2 -0
  131. package/dist/chunks/local-harness-taskset-review-LQPQBALH.js +2 -0
  132. package/dist/chunks/{opchat-T4QTNEIY.js → opchat-6ADSONAD.js} +1 -1
  133. package/dist/chunks/{organizations-75L5DZDV.js → organizations-GT24ZTCN.js} +1 -1
  134. package/dist/chunks/{profile-TFZMUEDR.js → profile-Y2MCSOUK.js} +1 -1
  135. package/dist/chunks/project-action-payload-GHSLE7K3.js +2 -0
  136. package/dist/chunks/{project-agent-6RRO233B.js → project-agent-YYSQIHVE.js} +1 -1
  137. package/dist/chunks/{published-experiment-source-DZFENAQA.js → published-experiment-source-5TMGLKDM.js} +1 -1
  138. package/dist/chunks/refiner-profile-service-ZK7KAFP5.js +2 -0
  139. package/dist/chunks/{runtime-A7OZXM43.js → runtime-QFXCXSVB.js} +2 -2
  140. package/dist/chunks/{sandbox-command-IU5XFTJP.js → sandbox-command-U6346TVJ.js} +1 -1
  141. package/dist/chunks/{sandbox-template-C4V6T36U.js → sandbox-template-XWWPWWNR.js} +1 -1
  142. package/dist/chunks/saved-work-SWHZ4OLO.js +2 -0
  143. package/dist/chunks/{send-turn-XTAIS2JN.js → send-turn-SIXOZUVJ.js} +1 -1
  144. package/dist/chunks/{src-LMC3K6LH.js → src-6SHCCYEN.js} +1 -1
  145. package/dist/chunks/{src-INHPJ63Z.js → src-EZAKCCUV.js} +56 -56
  146. package/dist/chunks/standalone-experiment-turn-owner-LIAQWTGI.js +2 -0
  147. package/dist/chunks/{store-continual-support-reviews-HHA6NX7K.js → store-continual-support-reviews-GDX6CSUU.js} +1 -1
  148. package/dist/chunks/{store-conversation-serving-KPC62UEY.js → store-conversation-serving-W55XMDH4.js} +1 -1
  149. package/dist/chunks/{store-create-improve-QV54XIZW.js → store-create-improve-A7E7CUPZ.js} +1 -1
  150. package/dist/chunks/{store-datasets-RXJ33SUN.js → store-datasets-HKF3EO7B.js} +1 -1
  151. package/dist/chunks/{store-evaluation-results-3F3P527G.js → store-evaluation-results-645RFBGR.js} +1 -1
  152. package/dist/chunks/{store-human-review-RAH7WMIP.js → store-human-review-F5KESW52.js} +1 -1
  153. package/dist/chunks/{store-learned-preference-migration-validation-4CI2IRUF.js → store-learned-preference-migration-validation-V27XD4I7.js} +1 -1
  154. package/dist/chunks/{store-local-experiments-5LUJR7GI.js → store-local-experiments-HWQWNTIU.js} +1 -1
  155. package/dist/chunks/{store-model-batch-review-YEGX327M.js → store-model-batch-review-TOCSDVAP.js} +1 -1
  156. package/dist/chunks/{store-model-configuration-5ZURQATB.js → store-model-configuration-6543ASY2.js} +1 -1
  157. package/dist/chunks/{store-sidebar-file-bookmarks-VB5GTLFY.js → store-sidebar-file-bookmarks-53B7QIGS.js} +1 -1
  158. package/dist/chunks/{store-sidebar-preferences-GWIOG2NH.js → store-sidebar-preferences-YXGEJVUO.js} +1 -1
  159. package/dist/chunks/{store-subagents-T7R2Z6TB.js → store-subagents-HRCAK7VZ.js} +1 -1
  160. package/dist/chunks/{store-task-inbox-JJTBW76C.js → store-task-inbox-WF74W4U2.js} +11 -11
  161. package/dist/chunks/{store-task-inventory-OB3F2APC.js → store-task-inventory-KHCTEZVK.js} +1 -1
  162. package/dist/chunks/{store-taskset-drafts-EKQWWFYQ.js → store-taskset-drafts-3ACG5AVX.js} +1 -1
  163. package/dist/chunks/{store-training-G6YLFSIR.js → store-training-R46WOGXB.js} +1 -1
  164. package/dist/chunks/{store-training-jobs-RC46YBF6.js → store-training-jobs-D4LECE7O.js} +1 -1
  165. package/dist/chunks/{store-training-models-6BA43IPP.js → store-training-models-EQVNXOVB.js} +1 -1
  166. package/dist/chunks/{taskset-EQRFQBYM.js → taskset-NR2X2UOK.js} +1 -1
  167. package/dist/chunks/{taskset-packages-XC6HEE3K.js → taskset-packages-ONULEIVI.js} +1 -1
  168. package/dist/chunks/{teams-bot-EAPGPTHZ.js → teams-bot-CHUYMD6K.js} +1 -1
  169. package/dist/chunks/{training-UF6RPI4T.js → training-IDSGYGU2.js} +1 -1
  170. package/dist/chunks/{web-search-CZ3NCLPY.js → web-search-BPON7H5N.js} +1 -1
  171. package/dist/chunks/{workspaces-EKKE5NAC.js → workspaces-2TJRDM5K.js} +1 -1
  172. package/dist/cli.js +1 -1
  173. package/dist/index.js +1 -1
  174. package/dist/web/assets/App-pcwmC4IR.js +154 -0
  175. package/dist/web/assets/{AppDialog-t2Fx5tK3.js → AppDialog-CdHad7GT.js} +1 -1
  176. package/dist/web/assets/{AppTerminalPanel-Dj1Y32oI.js → AppTerminalPanel-CrmoOgd4.js} +2 -2
  177. package/dist/web/assets/AppsView-0P6cBsD4.js +1 -0
  178. package/dist/web/assets/{BrowserSidebar-jhWi4rVm.js → BrowserSidebar-Cb6edJw6.js} +1 -1
  179. package/dist/web/assets/{CartesianChart-C1DIx0Ia.js → CartesianChart-B2Sxi0lv.js} +1 -1
  180. package/dist/web/assets/{CollaborationTabs-Bdr-HmOL.js → CollaborationTabs-PP0AIXhb.js} +1 -1
  181. package/dist/web/assets/{CommandMenu-Ux2yOHAc.js → CommandMenu-GfQIMe6W.js} +1 -1
  182. package/dist/web/assets/{CommunityView-DPEeVKFn.js → CommunityView-V6KmMl5n.js} +1 -1
  183. package/dist/web/assets/ComposerCreateImproveStrip-oeVeyhPX.js +1 -0
  184. package/dist/web/assets/ConversationImportsSettings-CuQcvVgE.js +1 -0
  185. package/dist/web/assets/ConversationImportsSettings-PfUa8V7X.css +1 -0
  186. package/dist/web/assets/{GetStartedView-CFHP0AaI.js → GetStartedView-2oZ068h_.js} +1 -1
  187. package/dist/web/assets/{HostedModelLearningReview-D8BGTPVN.js → HostedModelLearningReview-DLzak_Vf.js} +1 -1
  188. package/dist/web/assets/{HostedModelLearningSettings-JS1S7vNO.js → HostedModelLearningSettings-Eca6Pd9R.js} +1 -1
  189. package/dist/web/assets/{LabModelVersionDetailPage-Dx5Q3xV2.js → LabModelVersionDetailPage-DsBblnMp.js} +1 -1
  190. package/dist/web/assets/LabSkillSidebar-DDknttrB.js +1 -0
  191. package/dist/web/assets/{LabsRoute-CyYF8-dw.js → LabsRoute-CgNiUHsy.js} +4 -4
  192. package/dist/web/assets/MainChatThread-yCVg99LU.js +2 -0
  193. package/dist/web/assets/MainPane-C86le7UF.js +65 -0
  194. package/dist/web/assets/{MarkdownText-BR4V6lNO.js → MarkdownText-BBVriBCj.js} +1 -1
  195. package/dist/web/assets/{NativeSkillSidebar-DU9IEgIO.js → NativeSkillSidebar-D2uVZkqh.js} +1 -1
  196. package/dist/web/assets/{NewExperienceSwitcher-mIy6FzCj.js → NewExperienceSwitcher-DuD6GScJ.js} +1 -1
  197. package/dist/web/assets/{NewProjectDialog-RfTZTHxl.js → NewProjectDialog-B6XZkJrU.js} +1 -1
  198. package/dist/web/assets/OutputsPage-PUlmcWjv.js +1 -0
  199. package/dist/web/assets/{ProjectsPage-CE6QUB-b.js → ProjectsPage-DWBRmej6.js} +1 -1
  200. package/dist/web/assets/RightChatPanelStack-HaCVep4t.js +1 -0
  201. package/dist/web/assets/{RightSidebarHomePanel-CK0rP3WT.js → RightSidebarHomePanel-BUtdPb2L.js} +1 -1
  202. package/dist/web/assets/{ScheduledWorkPage-vOrYv8pp.js → ScheduledWorkPage-Dg9GkGrT.js} +1 -1
  203. package/dist/web/assets/SettingsView-DjjnCnlb.css +1 -0
  204. package/dist/web/assets/{SettingsView-DCKVrfjj.js → SettingsView-DtldfnV-.js} +4 -4
  205. package/dist/web/assets/{TeamChatView-Bwrjr-vk.js → TeamChatView-C71JX4je.js} +2 -2
  206. package/dist/web/assets/{TerminalOverlay-DhPoKZAq.js → TerminalOverlay-B4F6Q36s.js} +1 -1
  207. package/dist/web/assets/TrainingCreationPanel-B9MxFzQx.js +1 -0
  208. package/dist/web/assets/{TrainingDraftPanel-C9cRX5qf.js → TrainingDraftPanel-7C48sHfC.js} +1 -1
  209. package/dist/web/assets/{UsageSettingsSection-CrdcSGeW.js → UsageSettingsSection-CC57FcUB.js} +1 -1
  210. package/dist/web/assets/{WorkSidebarPanel-DSSikNFQ.js → WorkSidebarPanel-Cto1usLM.js} +1 -1
  211. package/dist/web/assets/{WorkspaceDiffPanel-BAFo0CPN.js → WorkspaceDiffPanel-CL7wi3kp.js} +3 -3
  212. package/dist/web/assets/{WorkspaceEnvironmentMenu-BVHAhwnJ.js → WorkspaceEnvironmentMenu-zdzSDofs.js} +18 -18
  213. package/dist/web/assets/{WorkspaceGitDialogs-CwVoiDQ2.js → WorkspaceGitDialogs-CZSmjnrc.js} +1 -1
  214. package/dist/web/assets/{WorkspaceMonacoEditor-TxLyhzNp.js → WorkspaceMonacoEditor-TrUDJMKb.js} +3 -3
  215. package/dist/web/assets/agent-connections-4Dza2mDg.js +1 -0
  216. package/dist/web/assets/{arrow-up-right-C9aE8Mfz.js → arrow-up-right-xKb5kWQJ.js} +1 -1
  217. package/dist/web/assets/{chunk-P3BRSSRD-DUGfuKA8.js → chunk-P3BRSSRD-BsGTkgyC.js} +1 -1
  218. package/dist/web/assets/{clipboard-Dk158Qp4.js → clipboard-BgjV3aCx.js} +1 -1
  219. package/dist/web/assets/{cloud-upload-k9eqBsHr.js → cloud-upload-Bw9XUsKQ.js} +1 -1
  220. package/dist/web/assets/{cssMode-CO35ARZp.js → cssMode-DxsFJGb-.js} +1 -1
  221. package/dist/web/assets/{folder-open-sYgceW_f.js → folder-open-CbmUjIYS.js} +1 -1
  222. package/dist/web/assets/{folder-plus-CS0R49m9.js → folder-plus-slsst7Ct.js} +1 -1
  223. package/dist/web/assets/{git-commit-horizontal-DrGxH2h4.js → git-commit-horizontal-BIS-8MuS.js} +1 -1
  224. package/dist/web/assets/{htmlMode-REMmzdfq.js → htmlMode-BE4VOrZo.js} +1 -1
  225. package/dist/web/assets/{index-C8aCGagb.js → index-DEg0S7Qk.js} +2 -2
  226. package/dist/web/assets/index-erq7hUne.css +1 -0
  227. package/dist/web/assets/{info-DLdbiUrh.js → info-5bL9xSSf.js} +1 -1
  228. package/dist/web/assets/{jsonMode-KEdMfkIf.js → jsonMode-CYimnBhD.js} +1 -1
  229. package/dist/web/assets/{lspLanguageFeatures-5KZwEoxW.js → lspLanguageFeatures-CiFuk-P7.js} +1 -1
  230. package/dist/web/assets/{minimize-2-CqcI4zcM.js → minimize-2-BGVWKvTg.js} +1 -1
  231. package/dist/web/assets/{monaco.contribution-omszXBEj.js → monaco.contribution-BTY4dJ0f.js} +2 -2
  232. package/dist/web/assets/{monaco.contribution-BJGj65F9.js → monaco.contribution-C7sMrcos.js} +2 -2
  233. package/dist/web/assets/{monaco.contribution-DO10L0zW.js → monaco.contribution-DUE3CQph.js} +2 -2
  234. package/dist/web/assets/{monaco.contribution-Cly9Wt7L.js → monaco.contribution-DkLVGT8N.js} +2 -2
  235. package/dist/web/assets/{monitor-BFVCcbxp.js → monitor-B5hx_tzp.js} +1 -1
  236. package/dist/web/assets/{play-C469pVZq.js → play-pmSO95Qg.js} +1 -1
  237. package/dist/web/assets/{python-Dw0YcVy9.js → python-CiZvL3LX.js} +1 -1
  238. package/dist/web/assets/{save-CtSjPydi.js → save-CvYL4DUg.js} +1 -1
  239. package/dist/web/assets/{square-BuImvLhT.js → square-DT_uFOml.js} +1 -1
  240. package/dist/web/assets/{toggleHighContrast-DjCO9lIP.js → toggleHighContrast-CrE1_HY0.js} +1 -1
  241. package/dist/web/assets/{tsMode-BAOnxKd6.js → tsMode-CI_PdZmj.js} +1 -1
  242. package/dist/web/assets/{upload-2JkFZo3h.js → upload-PVi8vC3T.js} +1 -1
  243. package/dist/web/assets/{useLocalAgentSchedules-BNqAisfS.js → useLocalAgentSchedules-BHJNVf42.js} +1 -1
  244. package/dist/web/assets/useProviderSettings-CU3zXyie.js +5 -0
  245. package/dist/web/assets/{useProviderSettings-CmL_BaxP.css → useProviderSettings-Cktvzinz.css} +1 -1
  246. package/dist/web/assets/{useSessionTurnCache-BHU2-Jmz.js → useSessionTurnCache-BE7cipLX.js} +1 -1
  247. package/dist/web/assets/{wifi-off-CpOAH62M.js → wifi-off-7WiFuOhD.js} +1 -1
  248. package/dist/web/assets/{workers-0QvlA2T5.js → workers-Cv8r4CvM.js} +1 -1
  249. package/dist/web/assets/{yaml-BK3qxo7D.js → yaml-Bj7mdkV2.js} +1 -1
  250. package/dist/web/index.html +2 -2
  251. package/docs/command-reference.md +10 -3
  252. package/docs/conversation-imports.md +57 -0
  253. package/package.json +1 -1
  254. package/dist/chunks/app-server-runtime-VCRNCNX2.js +0 -2
  255. package/dist/chunks/chunk-FV2R5RUN.js +0 -3
  256. package/dist/chunks/chunk-FY5KHLMW.js +0 -2
  257. package/dist/chunks/chunk-HY3GOBFJ.js +0 -58
  258. package/dist/chunks/chunk-KG325WTN.js +0 -2
  259. package/dist/chunks/chunk-MULXCKG7.js +0 -10
  260. package/dist/chunks/chunk-OGDADQGH.js +0 -143
  261. package/dist/chunks/chunk-QHWGQ3A4.js +0 -5
  262. package/dist/chunks/chunk-VRIEKBBH.js +0 -9
  263. package/dist/chunks/chunk-WJ43MJ3F.js +0 -2
  264. package/dist/chunks/chunk-YY7LEQGP.js +0 -2
  265. package/dist/chunks/cli-X25RSO2X.js +0 -2
  266. package/dist/chunks/connected-app-executor-IVLGQP65.js +0 -2
  267. package/dist/chunks/connection-HTF6CC7M.js +0 -2
  268. package/dist/chunks/core-commands-A2DGGIPS.js +0 -2
  269. package/dist/chunks/host-profile-evaluation-tools-NRLXL2S5.js +0 -2
  270. package/dist/chunks/host-profile-external-dataset-K3ICDHIP.js +0 -2
  271. package/dist/chunks/hosted-harness-runtime-723S5ZSH.js +0 -2
  272. package/dist/chunks/hosted-profile-compiler-2DQIFSXW.js +0 -2
  273. package/dist/chunks/import-MLZUHITH.js +0 -4
  274. package/dist/chunks/local-harness-improvement-runtime-JIQ6ZVDW.js +0 -2
  275. package/dist/chunks/local-harness-taskset-review-XVYTGAGK.js +0 -2
  276. package/dist/chunks/project-action-payload-7VGL7OER.js +0 -2
  277. package/dist/chunks/refiner-profile-service-UUIWFJVT.js +0 -2
  278. package/dist/chunks/saved-work-6BMBFP43.js +0 -2
  279. package/dist/chunks/standalone-experiment-turn-owner-JCY5LL5R.js +0 -2
  280. package/dist/web/assets/App-s-CJswyt.js +0 -154
  281. package/dist/web/assets/AppsView-BYE5EBDJ.js +0 -1
  282. package/dist/web/assets/ComposerCreateImproveStrip-CEgh4OtN.js +0 -1
  283. package/dist/web/assets/LabSkillSidebar-BxffN-pN.js +0 -1
  284. package/dist/web/assets/MainChatThread-DZpcFRFl.js +0 -2
  285. package/dist/web/assets/MainPane-5DTtwVCk.js +0 -65
  286. package/dist/web/assets/OutputsPage-Cr1Spf7S.js +0 -1
  287. package/dist/web/assets/RightChatPanelStack-T6VRWuHo.js +0 -1
  288. package/dist/web/assets/SettingsView-Dulr_xlq.css +0 -1
  289. package/dist/web/assets/TrainingCreationPanel-BXHfohNm.js +0 -1
  290. package/dist/web/assets/index-3iPNbbER.css +0 -1
  291. package/dist/web/assets/useProviderSettings-C4L4wDoh.js +0 -5
@@ -1,3 +1,3 @@
1
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-YOBN7KTF.js";import{A as Se,s as be,t as ke}from"./chunk-7HPDGZOR.js";import"./chunk-PPAPVGJP.js";import{e as Ce,f as U}from"./chunk-HZEIRHEB.js";import{b as De,c as ze}from"./chunk-PF5R6CMP.js";import"./chunk-X4OSOOSU.js";import"./chunk-3K4VVB7S.js";import"./chunk-XVDFJ3ZF.js";import"./chunk-EQFGBL3O.js";import"./chunk-GZ7M5XBP.js";import"./chunk-HCYX6RHP.js";import{b as pe}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import{a as z}from"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as we,b as ve}from"./chunk-FY5KHLMW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import{a as xe}from"./chunk-J2TWKFML.js";import"./chunk-773TH7FN.js";import{g as Te,j as G}from"./chunk-HDL5YSAA.js";import"./chunk-ZFSHBFG5.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import"./chunk-UKMA4R6X.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-7KWD2I6W.js";import"./chunk-OLLLZVHF.js";import"./chunk-7PXZ4X4P.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import"./chunk-KG325WTN.js";import"./chunk-3RCRSMWZ.js";import"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{b as ce,i as le,m as D,n as ue}from"./chunk-QNG27G3T.js";import{y as W}from"./chunk-EIRYMSEG.js";import{a as me,r as fe,s as he}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{p as C,q as $}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import{u as ge}from"./chunk-QOGJAQDO.js";import{g as se,l as V,n as de}from"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import{ia as ae,la as ie}from"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YR5ID2SS.js";import{c as re,d as oe,f as ne}from"./chunk-YBT2NB32.js";import{c as Y,g as ee}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import{f as X}from"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{Cb as M}from"./chunk-ACYFMLWG.js";import{r as te}from"./chunk-TVQAPBLZ.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(me).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 he.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:de,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=ge.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:se.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 le({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 ue({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 pe({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 ce(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:fe.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")}
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-COHMDT7A.js";import{A as Se,s as be,t as ke}from"./chunk-BRORSFJX.js";import"./chunk-2G4BEISF.js";import{e as Ce,f as U}from"./chunk-XMWXH7TS.js";import{b as De,c as ze}from"./chunk-PF5R6CMP.js";import"./chunk-X4OSOOSU.js";import"./chunk-7K7O3CKY.js";import"./chunk-XVDFJ3ZF.js";import"./chunk-CKMSBAI2.js";import"./chunk-GVZLGS2U.js";import"./chunk-776WNDV2.js";import{b as pe}from"./chunk-EOBHQ3JT.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import{a as z}from"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-I2NXNMRZ.js";import"./chunk-2L5XWJJ5.js";import{a as we,b as ve}from"./chunk-EQOV34UH.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-JQKSXCAJ.js";import{a as xe}from"./chunk-IFDALGZE.js";import"./chunk-EWOSLZDX.js";import{g as Te,j as G}from"./chunk-7AVNZF36.js";import"./chunk-N6ENLEMY.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-FAYASU7Z.js";import"./chunk-GOPFFQZU.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-7KWD2I6W.js";import"./chunk-PY6K2JRH.js";import"./chunk-7PXZ4X4P.js";import"./chunk-BQS7Z4AP.js";import"./chunk-XW6HGSIT.js";import"./chunk-57TRXBLT.js";import"./chunk-BE6SS65L.js";import"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-PH6IORGZ.js";import"./chunk-TG7P7BSV.js";import{b as ce,i as le,m as D,n as ue}from"./chunk-V34H7Y2T.js";import{y as W}from"./chunk-FKJHEZCW.js";import{a as me,r as fe,s as he}from"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import{p as C,q as $}from"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import{u as ge}from"./chunk-TKLBP3MM.js";import{g as se,l as V,n as de}from"./chunk-RBZH6A6M.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-RZUEVS64.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import{ia as ae,la as ie}from"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YR5ID2SS.js";import{c as re,d as oe,f as ne}from"./chunk-YBT2NB32.js";import{c as Y,g as ee}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import{f as X}from"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import{Cb as M}from"./chunk-ACYFMLWG.js";import{r as te}from"./chunk-TVQAPBLZ.js";import{l as J,m as R}from"./chunk-KGNCKIFP.js";import{b as e}from"./chunk-ES2ISFJC.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(me).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 he.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:de,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=ge.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:se.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 le({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 ue({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 pe({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 ce(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:fe.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
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-4GPXTISD.js";import"./chunk-PH6IORGZ.js";import"./chunk-TG7P7BSV.js";import"./chunk-VGRMAGOK.js";import"./chunk-V34H7Y2T.js";import"./chunk-FKJHEZCW.js";import"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-TKLBP3MM.js";import"./chunk-RBZH6A6M.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-RZUEVS64.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-FTQLQJQV.js";export{a as loadHostedHarnessRuntime,b as loadHostedHarnessRuntimeForSession};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a,e as F}from"./chunk-HZEIRHEB.js";import{a as h}from"./chunk-OSIO7PLX.js";import{a as O}from"./chunk-HIOKCIL7.js";import{j as I,m as D,n as M}from"./chunk-QNG27G3T.js";import{z as w}from"./chunk-EIRYMSEG.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import{a as A}from"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import{u as R}from"./chunk-TVQAPBLZ.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"))))}
2
+ import{a,e as F}from"./chunk-XMWXH7TS.js";import{a as h}from"./chunk-OSIO7PLX.js";import{a as O}from"./chunk-FAYASU7Z.js";import{j as I,m as D,n as M}from"./chunk-V34H7Y2T.js";import{z as w}from"./chunk-FKJHEZCW.js";import"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-TKLBP3MM.js";import"./chunk-RBZH6A6M.js";import"./chunk-DIO5CB6U.js";import{a as A}from"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-RZUEVS64.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import{u as R}from"./chunk-TVQAPBLZ.js";import{k as C,l as v}from"./chunk-KGNCKIFP.js";import{b as c}from"./chunk-ES2ISFJC.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
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-XJZSIXEO.js";import"./chunk-V34H7Y2T.js";import"./chunk-FKJHEZCW.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-RZUEVS64.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-LPWBIGKW.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-FTQLQJQV.js";export{a as compileHostedProfileRelease,b as runHostedProfileCompilerCli,c as runHostedProfileEvaluationCli,d as runHostedProfileInspectionCli};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as m,b as c}from"./chunk-OPNRWESL.js";import{a as l}from"./chunk-O6ULLQJ6.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{o as f}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{Hb as s,Ob as u}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.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};
2
+ import{a as m,b as c}from"./chunk-OPNRWESL.js";import{a as l}from"./chunk-2WKUBGIF.js";import"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import{o as f}from"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-TKLBP3MM.js";import"./chunk-RBZH6A6M.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import{Hb as s,Ob as u}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.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};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{b as R,c as P}from"./chunk-2QUCCP6Z.js";import{a as E}from"./chunk-O6ULLQJ6.js";import{a as h}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{o as v,p as S,q as w}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import{b as y}from"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{f as g}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{w as m}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.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-76BTRTYD.js")).controlHostedProfileEvaluation(r):await x(r);process.stdout.write(`${JSON.stringify(u)}
2
+ import{b as R,c as P}from"./chunk-ATAOHSFR.js";import{a as E}from"./chunk-2WKUBGIF.js";import{a as h}from"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import{o as v,p as S,q as w}from"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-TKLBP3MM.js";import"./chunk-RBZH6A6M.js";import{b as y}from"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import{f as g}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{w as m}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.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-57V24UGU.js")).controlHostedProfileEvaluation(r):await x(r);process.stdout.write(`${JSON.stringify(u)}
3
3
  `)}n(B,"runHostedProfileInspectionCli");export{x as inspectHostedProfileEvaluation,B as runHostedProfileInspectionCli};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{c as I,f as j,h as D}from"./chunk-3Z47M3YY.js";import{b as x}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import{a as E}from"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-SDAUS5PY.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as V}from"./chunk-XTFPDQMH.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import"./chunk-VRIEKBBH.js";import{m as C}from"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import{a as b}from"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import{e as m}from"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import{la as S}from"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{Pa as H,f as y}from"./chunk-ACYFMLWG.js";import{e as P,i as R}from"./chunk-TVQAPBLZ.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))}
2
+ import{c as I,f as j,h as D}from"./chunk-K44RHALX.js";import{b as x}from"./chunk-EOBHQ3JT.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import{a as E}from"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-P2RSBSCT.js";import"./chunk-I2NXNMRZ.js";import"./chunk-2L5XWJJ5.js";import{a as V}from"./chunk-XJZSIXEO.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-JQKSXCAJ.js";import"./chunk-PH6IORGZ.js";import"./chunk-TG7P7BSV.js";import"./chunk-VGRMAGOK.js";import{m as C}from"./chunk-V34H7Y2T.js";import"./chunk-FKJHEZCW.js";import"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-TKLBP3MM.js";import"./chunk-RBZH6A6M.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import{a as b}from"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-RZUEVS64.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import{e as m}from"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import{la as S}from"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import{Pa as H,f as y}from"./chunk-ACYFMLWG.js";import{e as P,i as R}from"./chunk-TVQAPBLZ.js";import{m as d}from"./chunk-KGNCKIFP.js";import{b as e}from"./chunk-ES2ISFJC.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
3
  `)}s(ae,"runHostedProfileEvaluationCli");export{G as prepareHostedProfileEvaluation,ae as runHostedProfileEvaluationCli};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{v as h}from"./chunk-BLXEAZCQ.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import"./chunk-UKMA4R6X.js";import"./chunk-GPVCOEUH.js";import"./chunk-OQPJ7FJF.js";import"./chunk-EYPCBBMS.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";import{createHash as p}from"node:crypto";import{setTimeout as b}from"node:timers/promises";async function T(e){if(e.signal.throwIfAborted(),!e.turnId.trim()||!e.callId.trim())throw new Error("Hosted Taskset actions require their originating turn and tool call.");let s=y(e.session.metadata?.hostConversationId),l=y(e.session.metadata?.hostSandboxId);if(e.session.workspaceKind!=="sandbox"||!l||e.session.workspaceId!==l||!s)throw new Error("Hosted Taskset actions require the bound Work workspace.");if(e.action==="answer_questions")throw new Error("Hosted Taskset authoring has no separate question queue. Revise with the complete buildSpecification.");if(e.action==="revise"&&!e.payload.buildSpecification)throw new Error("Hosted Taskset revisions require the complete buildSpecification.");let g=I(e.payload.sourceReferenceIds??e.payload.sourceIds),u=k({action:e.action,clientRequestId:w(e),creationId:e.payload.creationId,tasksetId:e.payload.tasksetId,objective:e.payload.objective,buildIntent:e.payload.buildIntent,buildSpecification:e.payload.buildSpecification,sourceReferenceIds:g,methodHint:e.payload.methodHint,approved:e.payload.approved,split:e.payload.split,taskLimit:e.payload.taskLimit,attemptsPerTask:e.payload.attemptsPerTask,maximumSpendUsd:e.payload.maximumSpendUsd,message:e.payload.message,answers:e.payload.answers}),f=e.request??h,n=["audit_graders","calibrate_judges","baseline","readiness"].includes(e.action),o=n?AbortSignal.any([e.signal,AbortSignal.timeout(900*1e3)]):e.signal,c=null;try{for(;;){o.throwIfAborted();let a=await f({path:"/hosted-tasksets/actions",method:"POST",body:u,signal:o,...n?{timeoutMs:3e4}:{}});o.throwIfAborted();let t=a.result;if(!n||!t||typeof t!="object"||Array.isArray(t)||!("schemaVersion"in t)||t.schemaVersion!=="openpond.hostedTasksetOperation.v1")return a;let m="status"in t?t.status:null,i="id"in t?t.id:null,d="retryAfterMs"in t?t.retryAfterMs:null;if(m!=="queued"&&m!=="running"||typeof i!="string"||!i||typeof d!="number"||!Number.isFinite(d)||d<1)throw new Error("Hosted Taskset check returned an invalid operation status.");if(c!==null&&c!==i)throw new Error("Hosted Taskset check operation identity changed while polling.");c=i,await b(Math.min(d,5e3),void 0,{signal:o})}}catch(a){throw n&&o.aborted&&(await f({path:"/hosted-tasksets/actions",method:"POST",body:{...u,cancelCheck:!0},timeoutMs:1e4,signal:AbortSignal.timeout(1e4)}).catch(()=>{}),o.throwIfAborted()),a}}r(T,"executeHostedTasksetAction");function w(e){let s=p("sha256").update(JSON.stringify([e.session.id,e.turnId,e.callId])).digest("hex").slice(0,32);return`${e.session.id}:${s}`.slice(0,191)}r(w,"actionRequestId");function k(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(k,"compact");function y(e){return typeof e=="string"&&e.trim()?e.trim():null}r(y,"stringValue");function I(e){return Array.isArray(e)&&e.every(s=>typeof s=="string")?e:void 0}r(I,"stringArray");export{T as executeHostedTasksetAction};
2
+ import{v as h}from"./chunk-BL3YH2QU.js";import"./chunk-SYUKES6H.js";import"./chunk-FAYASU7Z.js";import"./chunk-GOPFFQZU.js";import"./chunk-GPVCOEUH.js";import"./chunk-OQPJ7FJF.js";import"./chunk-RBZH6A6M.js";import"./chunk-BFKYRQMA.js";import"./chunk-RZUEVS64.js";import"./chunk-3QIB5FXI.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import{a as r}from"./chunk-FTQLQJQV.js";import{createHash as p}from"node:crypto";import{setTimeout as b}from"node:timers/promises";async function T(e){if(e.signal.throwIfAborted(),!e.turnId.trim()||!e.callId.trim())throw new Error("Hosted Taskset actions require their originating turn and tool call.");let s=y(e.session.metadata?.hostConversationId),l=y(e.session.metadata?.hostSandboxId);if(e.session.workspaceKind!=="sandbox"||!l||e.session.workspaceId!==l||!s)throw new Error("Hosted Taskset actions require the bound Work workspace.");if(e.action==="answer_questions")throw new Error("Hosted Taskset authoring has no separate question queue. Revise with the complete buildSpecification.");if(e.action==="revise"&&!e.payload.buildSpecification)throw new Error("Hosted Taskset revisions require the complete buildSpecification.");let g=I(e.payload.sourceReferenceIds??e.payload.sourceIds),u=k({action:e.action,clientRequestId:w(e),creationId:e.payload.creationId,tasksetId:e.payload.tasksetId,objective:e.payload.objective,buildIntent:e.payload.buildIntent,buildSpecification:e.payload.buildSpecification,sourceReferenceIds:g,methodHint:e.payload.methodHint,approved:e.payload.approved,split:e.payload.split,taskLimit:e.payload.taskLimit,attemptsPerTask:e.payload.attemptsPerTask,maximumSpendUsd:e.payload.maximumSpendUsd,message:e.payload.message,answers:e.payload.answers}),f=e.request??h,n=["audit_graders","calibrate_judges","baseline","readiness"].includes(e.action),o=n?AbortSignal.any([e.signal,AbortSignal.timeout(900*1e3)]):e.signal,c=null;try{for(;;){o.throwIfAborted();let a=await f({path:"/hosted-tasksets/actions",method:"POST",body:u,signal:o,...n?{timeoutMs:3e4}:{}});o.throwIfAborted();let t=a.result;if(!n||!t||typeof t!="object"||Array.isArray(t)||!("schemaVersion"in t)||t.schemaVersion!=="openpond.hostedTasksetOperation.v1")return a;let m="status"in t?t.status:null,i="id"in t?t.id:null,d="retryAfterMs"in t?t.retryAfterMs:null;if(m!=="queued"&&m!=="running"||typeof i!="string"||!i||typeof d!="number"||!Number.isFinite(d)||d<1)throw new Error("Hosted Taskset check returned an invalid operation status.");if(c!==null&&c!==i)throw new Error("Hosted Taskset check operation identity changed while polling.");c=i,await b(Math.min(d,5e3),void 0,{signal:o})}}catch(a){throw n&&o.aborted&&(await f({path:"/hosted-tasksets/actions",method:"POST",body:{...u,cancelCheck:!0},timeoutMs:1e4,signal:AbortSignal.timeout(1e4)}).catch(()=>{}),o.throwIfAborted()),a}}r(T,"executeHostedTasksetAction");function w(e){let s=p("sha256").update(JSON.stringify([e.session.id,e.turnId,e.callId])).digest("hex").slice(0,32);return`${e.session.id}:${s}`.slice(0,191)}r(w,"actionRequestId");function k(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(k,"compact");function y(e){return typeof e=="string"&&e.trim()?e.trim():null}r(y,"stringValue");function I(e){return Array.isArray(e)&&e.every(s=>typeof s=="string")?e:void 0}r(I,"stringArray");export{T as executeHostedTasksetAction};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import"./chunk-RAXOSUSW.js";import{c as I}from"./chunk-DARVPBZ4.js";import{a as E,c as S}from"./chunk-NPOHW5OU.js";import"./chunk-M4JWQSV7.js";import"./chunk-FV2R5RUN.js";import{c as x,f as y}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as n}from"./chunk-3M53YXEI.js";import"./chunk-5MCNZCVQ.js";import"./chunk-BT5YNE5U.js";import{s as R}from"./chunk-Q5LEXXJG.js";import"./chunk-FWIPHEVA.js";import{d as g}from"./chunk-OS3LO5J3.js";import{b}from"./chunk-GLUWATL5.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import{a as v}from"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{U as w,V as f,ca as p,da as h}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.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};
2
+ import"./chunk-GUOLMLZN.js";import{c as I}from"./chunk-JUQMSHNR.js";import{a as E,c as S}from"./chunk-NPOHW5OU.js";import"./chunk-U2MAPON2.js";import"./chunk-7UH4YDA7.js";import{c as x,f as y}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as n}from"./chunk-3M53YXEI.js";import"./chunk-OLDK2LKJ.js";import"./chunk-BT5YNE5U.js";import{s as R}from"./chunk-SF5HJ7PL.js";import"./chunk-FWIPHEVA.js";import{d as g}from"./chunk-WRI4XKSK.js";import{b}from"./chunk-GLUWATL5.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import{a as v}from"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import{U as w,V as f,ca as p,da as h}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{m as u}from"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.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};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as P,b as ue,c as pe,d as fe,e as L,f as re,g as z,h as B,i as me,j as oe,k as he,l as we,m as ge,n as J,o as ye,p as ve,q as D,r as ne,s as M,t as se,u as Se,v as Y,w as be,x as Ie,y as G}from"./chunk-U5FKRYJO.js";import{k as Q}from"./chunk-GUOLMLZN.js";import{a as Oe}from"./chunk-JUQMSHNR.js";import"./chunk-U2MAPON2.js";import"./chunk-7UH4YDA7.js";import{c as Ae,f as ke}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as x,f as k}from"./chunk-3M53YXEI.js";import"./chunk-JFXINDOQ.js";import"./chunk-OLDK2LKJ.js";import"./chunk-BT5YNE5U.js";import{n as Ce,o as Ee,p as W}from"./chunk-SF5HJ7PL.js";import"./chunk-FWIPHEVA.js";import{d as V,g as Re}from"./chunk-WRI4XKSK.js";import{b as xe}from"./chunk-GLUWATL5.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import{a as F,f as de}from"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{l as le,m as $}from"./chunk-KGNCKIFP.js";import{b as O}from"./chunk-ES2ISFJC.js";import{a as c}from"./chunk-FTQLQJQV.js";import{createInterface as ze}from"node:readline/promises";import{join as lt,resolve as Ye}from"node:path";import{homedir as ut}from"node:os";import{randomUUID as Qe}from"node:crypto";import{setTimeout as Xe}from"node:timers/promises";var We=["source","admission","control","heartbeat"],_=class{static{c(this,"CollectorErrors")}store;constructor(e){this.store=e}read(e){let r=this.store.setting(`errors:${e}`);if(r)return JSON.parse(r);let n=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 n?.error=="string"?{source:n.error}:{}}message(e,r){let n=this.read(e);return We.filter(o=>o!==r).map(o=>n[o]).find(Boolean)??null}source(e){return this.read(e).source??null}set(e,r,n){let o=this.read(e);n?o[r]=n.slice(0,500):delete o[r],this.store.set(`errors:${e}`,JSON.stringify(o)),this.store.error(e,this.message(e))}};var X=class{static{c(this,"CollectorSyncRequests")}store;acquisitions=new Map;constructor(e){this.store=e}observe(e,r){let n=r.requestedSyncRevision??e.requestedSyncRevision??0,o=r.completedSyncRevision??0;if(!Number.isSafeInteger(n)||n<0||n>r.revision||!Number.isSafeInteger(o)||o<0||o>n)throw new Error("Invalid remote sync acknowledgement.");let s=this.confirmed(e.id);return o>s&&this.store.set(`syncAcknowledged:${e.id}`,String(o)),{requestedSyncRevision:Math.max(e.requestedSyncRevision??0,n),completedSyncRevision:Math.max(e.completedSyncRevision??0,o)}}needsAcquisition(e){let r=e.requestedSyncRevision??0;if(r<=(e.completedSyncRevision??0))return!1;let n=this.acquisitions.get(e.id);return n?.controlRevision!==e.revision||n.requestedSyncRevision!==r}acquired(e,r){this.acquisitions.set(e,r)}complete(e,r){let n=this.acquisitions.get(e.id),o=e.requestedSyncRevision??0;if(e.state!=="active"||this.store.setting("desiredState")!=="running"||this.store.queued(e.id)||r||!n?.succeeded||n.controlRevision!==e.revision||n.requestedSyncRevision!==o||o<=(e.completedSyncRevision??0))return e;let s={...e,completedSyncRevision:o};return this.store.put(s),s}confirmed(e){return Number(this.store.setting(`syncAcknowledged:${e}`))||0}needsAcknowledgement(e){return(e.completedSyncRevision??0)>this.confirmed(e.id)}};var Ve=O.object({leafId:O.string().min(1).max(200),chainHash:O.string().regex(/^[a-f0-9]{64}$/),sourceInstanceId:O.string().min(1)}).strict(),Ne=c((t,e)=>`branch:${JSON.stringify([t,e])}`,"key");function $e(t,e,r){let n=t.setting(Ne(e,r));if(!n)return;let o=Ve.parse(JSON.parse(n));return t.connections().find(l=>l.id===e)?.source.instanceId===o.sourceInstanceId?{leafId:o.leafId,chainHash:o.chainHash}:void 0}c($e,"collectorBranchAnchor");async function Te(t,e){if(t.source!=="claude_code")throw new Error("Branch selection is currently supported for Claude Code.");let r,n=[];do{let o=await L(t,{cursor:r,limit:100});n.push(...o.items.filter(s=>s.nativeSessionId===e)),r=o.nextCursor??void 0}while(r);if(n.length!==1)throw new Error("Select exactly one native session in this connection's source location.");return n[0]}c(Te,"findSession");async function qe(t,e,r){let n=await D.open(t);try{let o=n.connections().find(l=>l.id===e);if(!o)throw new Error("Select a connection from openpond import status.");let s=await Te(o.source,r);return{session:s,...await re(o.source,s)}}finally{n.close()}}c(qe,"inspectCollectorBranches");async function Be(t,e,r,n){let o=await D.open(t);try{let s=o.connections().find(f=>f.id===e);if(!s||s.state!=="paused")throw new Error(`Pause this connection first: openpond import pause ${e}`);let l=await Te(s.source,r),a=await re(s.source,l),d=a.branches.find(f=>f.leafId===n.leafId);if(a.revision!==n.revision||!d)throw new Error("This conversation changed. Refresh its branches and choose again.");await z(s.source,l,{branchLeafId:n.leafId,expectedBranchRevision:n.revision}),o.database.exec("BEGIN IMMEDIATE");try{let f=o.connections().find(h=>h.id===e);if(!f||f.state!=="paused"||f.revision!==s.revision||f.source.instanceId!==s.source.instanceId)throw new Error("Connection changed during branch selection. Refresh and try again.");o.set(Ne(e,r),JSON.stringify({leafId:d.leafId,chainHash:d.chainHash,sourceInstanceId:s.source.instanceId}));for(let h of["source_scans","checkpoints","pending"])o.database.prepare(`DELETE FROM ${h} WHERE connection_id=?`).run(e);o.snapshots.collect();let w=new _(o);w.set(e,"source",w.source(e)),o.progress.reset(e),w.set(e,"admission",null),o.database.exec("COMMIT")}catch(f){throw o.database.exec("ROLLBACK"),f}return{connectionId:e,nativeSessionId:r,leafId:d.leafId,state:"paused"}}finally{o.close()}}c(Be,"selectCollectorBranch");async function Ue(t){let{store:e,connection:r,check:n,drain:o,progress:s}=t,l,a=0,d=0,f=[];do{await n(),s({phase:"discovering"});let w=await L(r.source,{since:r.since??void 0,cursor:l,limit:50});d+=w.items.length,s({discovered:d});for(let h of w.items){if(await n(),await o(),Number(e.database.prepare("SELECT COALESCE(SUM(bytes),0) AS n FROM pending").get()?.n)+e.snapshots.bytes()>=B.maxBytes)throw new oe;s({phase:"reading"});let p=JSON.stringify([h.path,h.nativeSessionId]),S=h.storageRevision?$([h.storageRevision,pe(r.source.source)]):null;e.progress.select(r.id,p);try{if(S&&!e.sourceChanged(r.id,p,S)&&!e.progress.tracks(r.id,p))continue;let{files:v,preview:i,branchLeafId:u}=await z(r.source,h,{branchAnchor:$e(e,r.id,h.nativeSessionId)});await n();let m=e.snapshots.prepare(v),I=!1;for(let R of i.sessions){let A=JSON.stringify([r.source.instanceId,R.sessionId,R.branchId]);e.progress.retained(r.id,p,A);let T=R.boundaries.filter(g=>g.projection==="turn"&&g.terminal!=="unknown"&&(!r.since||Date.parse(R.events[g.start].occurredAt??h.updatedAt)>=Date.parse(r.since)));I||=T.length>0;let U=T.filter(g=>e.changed(r.id,A,g.id,$([g.inputHash,g.revisionHash])));for(let g=0;g<U.length;g+=B.batchCases){await n();let C=U.slice(g,g+B.batchCases),y=`sync-${$([r.id,A,C.map(b=>[b.id,b.inputHash,b.revisionHash])]).slice(0,48)}`;e.enqueue({operationId:y,connectionId:r.id,sessionKey:A,contentHash:R.contentHash,files:v,boundaryIds:C.map(b=>b.id),...u?{branchLeafId:u}:{}},C.map(b=>({id:b.id,revision:$([b.inputHash,b.revisionHash])})),p,m)}}e.progress.read(r.id,p,I),S&&e.scanned(r.id,p,S)}catch(v){if(v instanceof fe){e.progress.read(r.id,p,!1),S&&e.scanned(r.id,p,S);continue}if(v instanceof oe||v instanceof q||v instanceof j)throw v;let i=v instanceof Error?v.message:"Unable to read session";e.progress.failed(r.id,p,i),f.push(`${h.nativeSessionId}: ${i}`)}finally{s({processed:++a})}await o()}l=w.nextCursor??void 0}while(l);if(e.progress.discovered(r.id),f.length)throw new Error(`${f.length} session(s) need attention. ${f[0]}`)}c(Ue,"acquireCollectorSource");var q=class extends Error{static{c(this,"CollectorInterruptedError")}},j=class extends Error{static{c(this,"CollectorScopeChangedError")}};async function De(t){let e=await D.open(t.directory),r=Qe(),n=[];e.database.exec("BEGIN IMMEDIATE");try{let i=e.setting("owner");if(i){let m=JSON.parse(i),I=!0;try{process.kill(m.pid,0)}catch(R){I=R.code!=="ESRCH"}if(I){if(t.trigger==="scheduled"){e.database.exec("COMMIT"),e.close();return}throw new Error("An import is already running. Cancel it or wait for it to finish.")}}let u=new Date;if(n=e.connections().filter(m=>m.state!=="disconnected"&&(!t.connectionIds||t.connectionIds.includes(m.id))&&(t.trigger!=="scheduled"||m.state==="active"&&ve(e.schedule(m.id),e.setting(`scheduledMinute:${m.id}`),u))),t.trigger==="scheduled")for(let m of n)e.set(`scheduledMinute:${m.id}`,ye(u));if(n.length&&t.trigger&&e.set("desiredState","running"),!n.length||e.setting("desiredState")!=="running"||t.signal.aborted){e.database.exec("COMMIT"),e.close();return}e.set("owner",JSON.stringify({pid:process.pid,nonce:r})),e.set("pid",String(process.pid)),e.set("heartbeatAt",u.toISOString()),e.database.exec("COMMIT")}catch(i){throw e.database.exec("ROLLBACK"),e.close(),i}let o=new AbortController,s=Date.now()+(t.maxDurationMs??B.runMs),l=AbortSignal.any([t.signal,o.signal]),a=setTimeout(()=>o.abort(new Error("Import exceeded its one-hour time budget. Remaining work is retained for the next run.")),t.maxDurationMs??B.runMs),d=setInterval(()=>{e.setting("desiredState")!=="running"?o.abort(new q("Import cancelled.")):e.set("heartbeatAt",new Date().toISOString())},250),f=new _(e),w=new X(e),h=c(i=>e.connections().find(u=>u.id===i.id)??i,"retained"),E=c(i=>{let u=e.queued(i.id),m=f.message(i.id,"heartbeat");return{pendingOperations:u,error:m,completedSyncRevision:!u&&!m?i.completedSyncRevision??0:0}},"heartbeatInput");function p(i,u){let m=h(i);if(m.state==="disconnected"||u.revision<m.revision)return m;let I=w.observe(m,u);u.revision>m.revision&&f.set(m.id,"control",null);let R={...m,...I,...u.revision>m.revision?{revision:u.revision,state:u.state}:{},...u.destinations?{destinations:u.destinations}:{}};return e.put(R),R}c(p,"applyRemote");function S(i,u,m){f.set(i.id,m,u instanceof Error?u.message:"Import failed.");let I=u&&typeof u=="object"&&"status"in u?Number(u.status):0,R=h(i);R.state!=="disconnected"&&[400,401,403].includes(I)&&e.put({...R,state:I===400?"paused":"disconnected"})}c(S,"recordFailure");function v(){if(Date.now()>=s&&!o.signal.aborted&&o.abort(new Error("Import time budget reached. Remaining work is retained for the next run.")),l.aborted)throw l.reason??new q("Import cancelled.");if(e.setting("desiredState")!=="running")throw new q("Import cancelled.")}c(v,"checkCancelled");try{await e.snapshots.migrate(()=>l.aborted||Date.now()>=s||e.setting("desiredState")!=="running");for(let i of n){let u="heartbeat",m=0,I={id:r,state:"running",phase:"discovering",startedAt:new Date().toISOString(),finishedAt:null,processed:0,discovered:0,uploaded:0,error:null},R=c(g=>{I={...I,...g},e.set(`run:${i.id}`,JSON.stringify(I))},"progress");R({});let A=c(async()=>{v(),u="heartbeat",i=h(i);let g=await t.transport.heartbeat(i,E(i),l);i=p(i,g),f.set(i.id,"heartbeat",null),m=Date.now()},"heartbeat"),T=c(async()=>{if(v(),Date.now()-m>=B.heartbeatMs&&await A(),i=h(i),i.state!=="active")throw new q(`Source ${i.state}.`)},"check"),U=c(async()=>{for(;e.queued(i.id);){await T();let g=e.next(i.id);if(!g)break;R({phase:"uploading"});let C=!1;for(let y=0;y<B.attemptsPerRun;y++){if(await T(),!e.database.prepare("SELECT 1 FROM pending WHERE id=? AND connection_id=?").get(g.entry.operationId,i.id)){C=!0;break}u="admission";try{await t.transport.admit(i,g.entry,l),e.acknowledge(g.entry),f.set(i.id,"admission",null),R({uploaded:I.uploaded+g.entry.boundaryIds.length}),C=!0;break}catch(b){e.retry(g.entry.operationId,g.attempts+y);let N=b&&typeof b=="object"&&"status"in b?Number(b.status):0;if(l.aborted||[400,401,403,409].includes(N)||y+1>=B.attemptsPerRun)throw b;await Xe(1e3*2**y,void 0,{signal:l})}}if(!C)throw new Error("Pending import was not acknowledged.")}},"drain");try{if(await A(),i.state!=="active")throw new q(`Source ${i.state}.`);await U();let g;for(let C=0;C<3;C++){await T();let y=i.revision,b=i.requestedSyncRevision??0;u="source";let N=c(async()=>{if(await T(),u="source",i.revision!==y)throw new j("Source settings changed during acquisition.")},"checkAcquisition");try{await Ue({store:e,connection:i,check:N,drain:c(async()=>{await U(),await N()},"drain"),progress:R})}catch(H){if(H instanceof j&&C<2)continue;throw H}if(f.set(i.id,"source",null),await U(),i=h(i),i.revision!==y){if(C===2)throw new Error("Source settings changed repeatedly during import. Run Sync now again.");continue}if(w.acquired(i.id,{controlRevision:y,requestedSyncRevision:b,succeeded:!0}),i=w.complete(i,f.message(i.id,"heartbeat")),await A(),i.revision!==y||w.needsAcquisition(i)){if(C===2)throw new Error("Source settings changed during completion. Run Sync now again.");continue}if(w.needsAcknowledgement(i))throw new Error("The server has not acknowledged sync completion. Retry with Sync now.");g=y;break}if(await T(),i.revision!==g)throw new j("Source settings changed before completion. Run Sync now again.");R({state:"completed",finishedAt:new Date().toISOString()}),e.set(`lastSuccess:${i.id}`,I.finishedAt)}catch(g){let C=g instanceof q||t.signal.aborted||l.reason instanceof q,y=l.aborted?l.reason:g,b=y instanceof Error?y.message:"Import cancelled.";C||S(i,y,u),R({state:C?"cancelled":"failed",error:b,finishedAt:new Date().toISOString()})}if(l.aborted||e.setting("desiredState")!=="running")break}}finally{clearInterval(d),clearTimeout(a),JSON.parse(e.setting("owner")||"{}").nonce===r&&(e.set("pid",""),e.set("heartbeatAt",""),e.set("owner",""),e.set("desiredState","stopped")),e.close()}}c(De,"runCollector");import{createHash as Me,generateKeyPairSync as Ze,createPublicKey as et,diffieHellman as tt,createDecipheriv as rt}from"node:crypto";import{spawn as ot}from"node:child_process";var He=c(t=>Me("sha256").update(t).digest("hex"),"hash"),nt=O.object({publicKey:O.string().max(200),iv:O.string().max(100),tag:O.string().max(100),ciphertext:O.string().max(1e4)}).strict();async function ie(t,e,r){let n=await fetch(`${t}${e}`,{method:"POST",redirect:"error",signal:AbortSignal.timeout(15e3),headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),o=await n.text();if(o.length>16384)throw new Error("Authorization response exceeded its limit.");if(!n.ok)throw Object.assign(new Error(`Browser sign-in failed (${n.status}).`),{status:n.status});return JSON.parse(o)}c(ie,"post");function st(t){let e=process.platform==="darwin"?"open":process.platform==="win32"?"rundll32":"xdg-open",r=process.platform==="win32"?["url.dll,FileProtocolHandler",t]:[t],n=ot(e,r,{stdio:"ignore",detached:!0});n.on("error",()=>{}),n.unref()}c(st,"openBrowser");async function je(t,e){let r=await V(),n=Ae(e)||r.apiBaseUrl||xe,o=x(e,"baseUrl")||(new URL(n).hostname==="staging-api.openpond.ai"?"https://staging.openpond.ai":ke(r)),s=new URL(o),l=new URL(n);for(let E of[s,l])if(E.protocol!=="https:"&&!(E.protocol==="http:"&&["localhost","127.0.0.1"].includes(E.hostname))||E.username||E.password||E.search||E.hash)throw new Error("Sign-in requires a clean HTTPS origin or local development origin.");let a=`import-${He([s.origin,t.machineId,t.instanceId].join(":")).slice(0,24)}`,d=Ze("x25519"),f=d.publicKey.export({format:"der",type:"spki"}).toString("base64"),w=O.object({deviceCode:O.string(),userCode:O.string(),expiresAt:O.string().datetime(),intervalSeconds:O.number().min(2).max(10)}).strict().parse(await ie(s.origin,"/api/cli/import/device",{publicKey:f,machineId:t.machineId,sourceInstanceId:t.instanceId,sourceLabel:P[t.source],sourceRoot:t.root,...x(e,"team")?{requestedTeamId:x(e,"team")}:{}})),h=`${s.origin}/console/connections/authorize?code=${encodeURIComponent(w.userCode)}`;for(console.log(`OpenPond sign-in code: ${w.userCode}
3
+ ${h}`),st(h);Date.now()<Date.parse(w.expiresAt);){await new Promise(I=>setTimeout(I,w.intervalSeconds*1e3));let E;try{E=await ie(s.origin,"/api/cli/import/token",{deviceCode:w.deviceCode})}catch(I){if(Number(I.status)===429)continue;throw I}let p=O.object({state:O.enum(["pending","approved","denied","consumed"]),envelope:nt.nullable().optional()}).strict().parse(E);if(p.state==="denied"||p.state==="consumed")throw new Error("Browser sign-in was declined or already consumed. Start the connection again.");if(p.state!=="approved"||!p.envelope)continue;let S=p.envelope,v=et({key:Buffer.from(S.publicKey,"base64"),format:"der",type:"spki"});if(v.asymmetricKeyType!=="x25519")throw new Error("Invalid sign-in encryption key.");let i=Me("sha256").update(tt({privateKey:d.privateKey,publicKey:v})).digest(),u=rt("aes-256-gcm",i,Buffer.from(S.iv,"base64"));u.setAAD(Buffer.from(He(w.deviceCode))),u.setAuthTag(Buffer.from(S.tag,"base64"));let m=O.object({apiKey:O.string().min(1),teamId:O.string().min(1),expiresAt:O.string().datetime()}).strict().parse(JSON.parse(Buffer.concat([u.update(Buffer.from(S.ciphertext,"base64")),u.final()]).toString("utf8")));if(x(e,"team")&&m.teamId!==x(e,"team"))throw new Error("Browser approved a different workspace.");return await Re({handle:a,apiKey:m.apiKey,baseUrl:s.origin,apiBaseUrl:l.origin,setActive:!1}),await ie(s.origin,"/api/cli/import/token",{deviceCode:w.deviceCode,acknowledge:!0}),{apiKey:m.apiKey,teamId:m.teamId,baseUrl:l.origin,account:a,accountBaseUrl:s.origin}}throw new Error("Browser sign-in expired. Start the connection again.")}c(je,"authorizeImporter");import{homedir as it}from"node:os";import{join as at}from"node:path";async function Z(t){let e=await F(t.credentialHome??at(it(),".openpond"),()=>V({account:t.account,baseUrl:t.accountBaseUrl})),r=t.account?e.apiKey:Oe(e);if(!r)throw Object.assign(new Error("This source is disconnected. Reconnect it with OpenPond Importer to authorize collection."),{status:401});let n={apiKey:r,baseUrl:t.apiBaseUrl,teamId:t.teamId};return{evidence:new Ee(n),sync:new W(n)}}c(Z,"collectorClients");var ae=null,Pe={async heartbeat(t,e,r){let{sync:n}=await Z(t),o=await n.heartbeat({id:t.id,expectedRevision:t.revision,...e},AbortSignal.any([AbortSignal.timeout(6e4),...r?[r]:[]]));return{revision:o.revision,state:o.state,destinations:me(t,o),requestedSyncRevision:o.requestedSyncRevision,completedSyncRevision:o.completedSyncRevision}},async admit(t,e,r){let{evidence:n,sync:o}=await Z(t),s=AbortSignal.any([AbortSignal.timeout(6e4),...r?[r]:[]]),l=$([t.id,t.revision,t.apiBaseUrl,t.teamId,t.account,t.credentialHome,t.projectId,t.source.instanceId,e.branchLeafId,e.files]);if(ae?.key!==l){let S=Buffer.from(JSON.stringify(e.files.map(v=>({path:v.path,encoding:"utf8",base64:Buffer.from(v.text).toString("base64")}))));ae={key:l,bytes:S,upload:{hash:le(S),parts:Math.ceil(S.length/2e5)},nextPart:0}}let a=ae,d=a.upload;for(;a.nextPart<d.parts;){let S=a.nextPart;await n.uploadPart({...d,index:S,base64:a.bytes.subarray(S*2e5,(S+1)*2e5).toString("base64")},s),a.nextPart++}let f={upload:d,source:t.source.source,...e.branchLeafId?{branchLeafId:e.branchLeafId}:{},destination:{kind:"existing",projectId:t.projectId},acquisition:{machineId:t.source.machineId,sourceInstanceId:t.source.instanceId}},w=a.preview??=await n.preview(f,s);if(w.issues.length)throw Object.assign(new Error("Source schema was rejected; inspect the connection before resuming."),{status:400});let h=w.sessions.find(S=>S.sessionHash===e.contentHash);if(!h||e.boundaryIds.some(S=>!h.boundaries.some(v=>v.id===S&&v.projection==="turn"&&v.terminal!=="unknown")))throw Object.assign(new Error("Server preview differs from the retained source boundaries."),{status:400});let E={...f,operationId:e.operationId,previewHash:w.previewHash,selection:[{sessionHash:h.sessionHash,boundaryIds:e.boundaryIds}]},p=Ce.parse(await o.commit({connectionId:t.id,expectedRevision:t.revision,request:E},s));if(p.state!=="completed"||p.operationId!==e.operationId||p.requestHash!==$(E)||p.projectId!==t.projectId)throw new Error("Admission did not acknowledge this retained operation.")}};function ee(t){if(t.everyMinute!==void 0)throw new Error("Every-minute imports are no longer supported. Use --continual --hourly or a slower schedule.");let e=k(t.continual),r=["daily","weekly","hourly"].filter(d=>k(t[d]));t.cron!==void 0&&r.push("cron");let n=t.at!==void 0||t.on!==void 0;if(!e&&(r.length||n))throw new Error("Add --continual to enable recurring imports. Without it, imports run once.");if(!e)return null;if(r.length>1)throw new Error("Choose one cadence: --daily, --weekly, --hourly, or --cron.");if(t.off!==void 0)throw new Error("Choose --continual or --off, not both.");let o=r[0]??"daily";if(["cron","hourly"].includes(o)){if(n)throw new Error("--at and --on are for daily/weekly imports; use a cron expression for other times.");return o==="cron"?ge({frequency:"cron",expression:x(t,"cron")}):{frequency:"hourly"}}if(o!=="weekly"&&t.on!==void 0)throw new Error("--on selects a weekday and requires --weekly.");let s=we(t.at===void 0?"00:00":x(t,"at"));if(o==="daily")return{frequency:"daily",time:s};let l=t.on===void 0?"mon":x(t,"on").toLowerCase(),a=he.findIndex(d=>d===l);if(a<0)throw new Error("Use --on sun|mon|tue|wed|thu|fri|sat (default: mon).");return{frequency:"weekly",time:s,day:a}}c(ee,"importSchedule");import{setTimeout as ct}from"node:timers/promises";async function Le(t){console.log("Importing saved conversations. Ctrl+C cancels this run; queued work is retained.");let e=0;try{for(;!t.signal.aborted;){let o=(await M(t.directory)).connections.filter(a=>!t.connectionId||a.id===t.connectionId).find(a=>a.run?.state==="running"),s=o?.run,l=o&&s?`${o.source}: ${s.phase} \xB7 ${s.processed}/${s.discovered} conversations checked \xB7 ${s.uploaded} turns uploaded \xB7 ${o.queued} queued`:"Starting import\u2026";process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(`${["|","/","-","\\"][e++%4]} ${l}`);try{await ct(500,void 0,{signal:t.signal})}catch{if(!t.signal.aborted)throw new Error("Import progress interrupted.")}}}finally{process.stdout.clearLine(0),process.stdout.cursorTo(0)}}c(Le,"monitorImport");async function K(t){let e=new AbortController,r=c(()=>e.abort(new Error("Import cancelled.")),"stop");process.once("SIGINT",r),process.once("SIGTERM",r);let n=new AbortController,o=!!process.stdin.isTTY&&!!process.stdout.isTTY&&!t.json,s;try{let a=De({directory:t.directory,signal:e.signal,...t.connectionId?{connectionIds:[t.connectionId]}:{},...t.retainedStart?{}:{trigger:t.scheduled?"scheduled":"manual"},transport:Pe}).finally(()=>n.abort());await Promise.all([a,o?Le({directory:t.directory,connectionId:t.connectionId,signal:n.signal}):Promise.resolve()]),s=await M(t.directory)}finally{n.abort(),process.off("SIGINT",r),process.off("SIGTERM",r)}let l=s.connections.filter(a=>!t.connectionId||a.id===t.connectionId);if(t.json)console.log(JSON.stringify(s,null,2));else for(let a of l){let d=a.run;d&&console.log(`${a.source}: ${d.state}. ${d.processed} conversations checked, ${d.uploaded} turns uploaded, ${a.queued} queued.${d.error?` ${d.error}`:""}`),console.log(a.schedule?`Continual imports: ${J(a.schedule)} (${s.timezone}). Next: ${a.nextRunAt??"source paused"}.`:"Automatic sync is off. Run openpond import sync to import again.")}return e.signal.aborted?process.exitCode=130:l.some(a=>a.run?.state==="failed")&&(process.exitCode=1),s}c(K,"runImportJob");function te(t){return{directory:t,executable:process.execPath,args:[...process.execArgv,process.argv[1]],environment:{...process.env.OPENPOND_HOME?{OPENPOND_HOME:process.env.OPENPOND_HOME}:{},...process.env.ELECTRON_RUN_AS_NODE==="1"?{ELECTRON_RUN_AS_NODE:"1"}:{}}}}c(te,"collectorSetup");async function _e(t,e,r,n){let o=c(l=>console.log(JSON.stringify(l,null,2)),"print"),s=k(n.json);if(e==="status")return o(await M(t)),!0;if(e==="cancel")return o(await se(t,"stop")),!0;if(e==="schedule"){if(!r)throw new Error("Use openpond import schedule <connection-id> --continual [--daily|--weekly|--hourly|--cron <expression>] or --off.");let l=ee(n),a=k(n.off);if(!l&&!a)throw new Error("Choose --continual [--daily|--weekly|--hourly|--cron <expression>] or --off.");return o(await Y(te(t),r,l)),!0}if(e==="sync"){let l=await M(t);if(r&&!l.connections.some(a=>a.id===r&&a.state==="active"))throw new Error("Select an active connection from import status; resume or reconnect it first.");if(!l.connections.some(a=>a.state==="active"))throw new Error("No active sources. Connect or resume a source first.");return await K({directory:t,connectionId:r,json:s}),!0}if(e!=="service")return!1;if(r==="status")o(await M(t));else if(r==="stop")o(await se(t,"stop"));else if(r==="uninstall")o(await be(t));else if(r==="install")o(await Se(te(t)));else if(r==="start")await K({directory:t,json:s});else if(r==="run")await K({directory:t,json:s,scheduled:k(n.scheduled),retainedStart:!k(n.scheduled)});else throw new Error("usage: openpond import service <install|start|stop|status|run|uninstall>");return!0}c(_e,"runImporterControl");async function ce(t,e){let r=await D.open(t),n;try{n=r.connections().find(o=>o.id===e)}finally{r.close()}if(!n)throw new Error("Select a retained connection from openpond import status.");if(n.source.machineId!==await G(t))throw new Error("This connection belongs to another machine. Use explicit Connect setup.");if(!n.accountBaseUrl)throw new Error("The original sign-in destination is unavailable. Use explicit Connect setup.");return n}c(ce,"retainedReconnect");function Ke(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.")}c(Ke,"assertReconnectSource");async function Je(t,e){let r=await ce(t,e.id),n=c(o=>({...o,destinations:void 0,requestedSyncRevision:o.requestedSyncRevision??0,completedSyncRevision:o.completedSyncRevision??0}),"scope");if($(n(r))!==$(n(e)))throw new Error("The connection changed during sign-in. Reconnect again after reviewing its current scope.")}c(Je,"assertReconnectUnchanged");import{createInterface as dt}from"node:readline/promises";async function Fe(t,e,r,n){let o=x(n,"session");if(!r||!o)throw new Error("Use openpond import branches <connection-id> --session <native-session-id>.");let s=await qe(t,r,o);if(e==="branches"){console.log(JSON.stringify(s,null,2));return}let l=process.stdin.isTTY&&process.stdout.isTTY&&!k(n.json),a=x(n,"leaf"),d=x(n,"revision");if(!a&&l){s.branches.forEach((h,E)=>console.log(`${E+1}. ${h.title||h.leafId} (${h.messages} messages; ${h.updatedAt||"date unavailable"})`));let w=dt({input:process.stdin,output:process.stdout});try{a=s.branches[Number(await w.question("Choose the branch to sync: "))-1]?.leafId??"",d=s.revision}finally{w.close()}}if(!a||!d)throw new Error("Supply --leaf and --revision from import branches, or choose interactively. No branch was selected.");if(!s.branches.some(w=>w.leafId===a)||d!==s.revision)throw new Error("Branch selection is stale or invalid. Run import branches again.");if(!k(n.yes)&&(!l||!await Q("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 f=await Be(t,r,o,{leafId:a,revision:d});console.log(JSON.stringify({...f,next:`openpond import resume ${r}`},null,2))}c(Fe,"runImporterBranchCommand");async function Wr(t,e){let[r="connect",n]=e,o=Ye(x(t,"collectorDir")||Ie()),s=k(t.json),l=c(y=>console.log(JSON.stringify(y,null,2)),"print"),a=ee(t);if(a&&!["connect","reconnect","schedule"].includes(r))throw new Error("Use --continual with import connect, reconnect, or schedule.");if(k(t.off)&&r!=="schedule")throw new Error("Use import schedule <connection-id> --off to disable recurring imports.");if(r==="branches"||r==="branch"){await Fe(o,r,n,t);return}if(await _e(o,r,n,t))return;if(["pause","resume","disconnect"].includes(r)){let y=await D.open(o),b;try{b=y.connections().find(Ge=>Ge.id===n)}finally{y.close()}if(!b)throw new Error("Select a connection id from openpond import status.");let{sync:N}=await Z(b),H=await N.control({id:b.id,expectedRevision:b.revision,action:r});await ne(o,{...b,revision:H.revision,state:H.state}),l(H);return}let d=r==="reconnect"?await ce(o,n):null;d&&(t={...t,source:d.source.source,sourcePath:d.source.root,project:d.projectId,connection:d.id,team:d.teamId,apiBaseUrl:d.apiBaseUrl,baseUrl:d.accountBaseUrl});let f=x(t,"source");if(f&&!(f in P))throw new Error("Choose a supported native source name.");let w=await G(o),h=await ue({machineId:w,...f&&x(t,"sourcePath")?{locations:{[f]:Ye(x(t,"sourcePath"))}}:{}});if(r==="discover"){l(h);return}if(r!=="connect"&&r!=="reconnect")throw new Error("usage: openpond import <connect|reconnect|discover|status|sync|schedule|cancel|pause|resume|disconnect|branches|branch|service>");let E=h.filter(y=>y.source===f),p=E.length===1?E[0]:void 0,S=process.stdin.isTTY&&process.stdout.isTTY&&!s;if(d&&Ke(d,p),!p&&S){let y=E.length>1?E:h.filter(N=>N.available);y.forEach((N,H)=>console.log(`${H+1}. ${P[N.source]} ${N.root}${N.capabilities.history?"":` (${N.reason})`}`));let b=ze({input:process.stdin,output:process.stdout});try{p=y[Number(await b.question("Choose a source: "))-1]}finally{b.close()}}if(!p?.capabilities.history)throw new Error(p?.reason??(E.length>1?"Multiple source instances found. Select the exact --source-path or use interactive setup.":"Select --source and optionally --source-path."));let v=x(t,"range")||"week";if(!d&&S&&!t.range){let y=ze({input:process.stdin,output:process.stdout});try{v=(await y.question("Initial history: day, week, or all [default: week]: ")).trim()||"week"}finally{y.close()}}if(!["day","week","all"].includes(v))throw new Error("--range must be day, week or all.");let i=d?d.since:v==="all"?null:new Date(Date.now()-(v==="day"?1:7)*864e5).toISOString(),u=d?i?`since ${i}`:"all":v==="week"?`last week${t.range?"":" (default)"}`:v==="day"?"last day":"all",m=await L(p,{since:i??void 0,limit:100});s||console.log(`Found ${m.items.length}${m.nextCursor?"+":""} sessions in ${p.root}. Initial history: ${u}.`),s||console.log(a?`Continual imports: ${J(a)} local time. Continual learning is unchanged.`:"One-time import. Continual imports default to off; existing schedules are unchanged.");let I=x(t,"project");if(!k(t.yes)&&(!S||!await Q(`Sync this source to ${I||"your personal Imported conversations Project"} and ${a?`enable continual imports ${J(a)} local time`:"import once (no new schedule)"}?`,!0)))throw new Error("Connection was not approved. No history was uploaded.");let R=d?d.credentialHome??lt(ut(),".openpond"):de(),A=await F(R,()=>je(p,t)),T=new W(A),U=x(t,"connection")||`sync-${$([A.baseUrl,A.teamId,p.instanceId,I||"default"]).slice(0,40)}`;d&&await Je(o,d);let g=(await T.list()).items.find(y=>y.id===U),C=await T.register({id:U,source:p.source,machineId:w,sourceInstanceId:p.instanceId,sourceLabel:P[p.source],sourceRoot:p.root,destination:I?{kind:"existing",projectId:I}:{kind:"new",name:"Imported conversations"},since:i,keepSyncing:!1,expectedRevision:g?.revision??0});await ne(o,{id:C.id,teamId:A.teamId,apiBaseUrl:A.baseUrl,account:A.account,accountBaseUrl:A.accountBaseUrl,credentialHome:R,source:p,projectId:C.projectId,revision:C.revision,requestedSyncRevision:C.requestedSyncRevision,completedSyncRevision:C.completedSyncRevision,since:i,keepSyncing:!1,state:C.state}),a&&await Y(te(o),C.id,a),await K({directory:o,connectionId:C.id,json:s})}c(Wr,"runImportCommand");export{Wr as runImportCommand};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a}from"./chunk-MFMYWZK2.js";import"./chunk-X4OSOOSU.js";import"./chunk-7K7O3CKY.js";import"./chunk-EQOV34UH.js";import"./chunk-IZ6DLEVY.js";import"./chunk-MMQRHR3V.js";import"./chunk-PCSIOUHF.js";import"./chunk-7KWD2I6W.js";import"./chunk-57TRXBLT.js";import"./chunk-TG7P7BSV.js";import"./chunk-V34H7Y2T.js";import"./chunk-FKJHEZCW.js";import"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-TKLBP3MM.js";import"./chunk-RBZH6A6M.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-RZUEVS64.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-FTQLQJQV.js";export{a as createLocalHarnessImprovementRuntime};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{i as a,j as b}from"./chunk-OX3XZKGK.js";import"./chunk-BRORSFJX.js";import"./chunk-2G4BEISF.js";import"./chunk-XVDFJ3ZF.js";import"./chunk-CKMSBAI2.js";import"./chunk-GVZLGS2U.js";import"./chunk-776WNDV2.js";import"./chunk-TRQQNFMO.js";import"./chunk-F74GBN6K.js";import"./chunk-I2NXNMRZ.js";import"./chunk-2L5XWJJ5.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-JQKSXCAJ.js";import"./chunk-4EDIRCD3.js";import"./chunk-N6ENLEMY.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-GOPFFQZU.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-PCSIOUHF.js";import"./chunk-7KWD2I6W.js";import"./chunk-BQS7Z4AP.js";import"./chunk-XW6HGSIT.js";import"./chunk-57TRXBLT.js";import"./chunk-FKJHEZCW.js";import"./chunk-2RNQQNB7.js";import"./chunk-OQPJ7FJF.js";import"./chunk-EUMXMT3S.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-TKLBP3MM.js";import"./chunk-RBZH6A6M.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-RZUEVS64.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-CGWA54LE.js";import"./chunk-KO3HNMLJ.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-JMBQYBPI.js";import"./chunk-LPWBIGKW.js";import"./chunk-DZUAT3TP.js";import"./chunk-H7ATCPPB.js";import"./chunk-25JDHAZ5.js";import"./chunk-XMKCCLGB.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-6FA3GG5B.js";import"./chunk-MNC4YUDI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-FTQLQJQV.js";export{a as createLocalHarnessTasksetReviewControl,b as runLocalHarnessEvaluationBaseline};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import"./chunk-RAXOSUSW.js";import{c as B}from"./chunk-DARVPBZ4.js";import"./chunk-M4JWQSV7.js";import"./chunk-FV2R5RUN.js";import{c as U,d as C,f as O}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{f as m}from"./chunk-3M53YXEI.js";import{a as u,c as A,d as x,i as v,j as S,k as R}from"./chunk-JEVA7YQL.js";import"./chunk-5MCNZCVQ.js";import"./chunk-BT5YNE5U.js";import"./chunk-Q5LEXXJG.js";import"./chunk-FWIPHEVA.js";import{d as k}from"./chunk-OS3LO5J3.js";import"./chunk-GLUWATL5.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import{M as y}from"./chunk-Z4Z5UOZM.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{randomUUID as b}from"node:crypto";async function G(r,t){let e=t[0]||"smoke",n=await k(),l=await B(n,O(n)),c=P(n,r);if(e==="provider-catalog"||e==="providers-catalog"||e==="catalog"){let a=await E({apiBaseUrl:c,token:l});console.log(JSON.stringify(a,null,2));return}if(e==="models"||e==="model-list"){let a=await A({apiBaseUrl:c,token:l});console.log(JSON.stringify(a,null,2));return}if(e==="model"||e==="model-get"){let a=t[1]||o(r,"model");if(!a)throw new Error("usage: opchat model <model>");let p=await x({apiBaseUrl:c,token:l,model:a});console.log(JSON.stringify(p,null,2));return}if(e==="chat"){let a=o(r,"model")||"openpond-chat",p=o(r,"effort"),f=p?y.parse(p):void 0,d=o(r,"message")||o(r,"prompt")||"Reply with a short confirmation from OpChat.";if(!m(r.stream)){let s=await v({apiBaseUrl:c,token:l,model:a,reasoningEffort:f,messages:[{role:"user",content:d}]});console.log(JSON.stringify(s,null,2));return}let g="",h=null,w=null;for await(let s of S({apiBaseUrl:c,token:l,model:a,reasoningEffort:f,messages:[{role:"user",content:d}]}))s.type==="text_delta"?(g+=s.text,process.stdout.write(s.text)):s.type==="finish"?h=s.finishReason:s.type==="usage"&&(w=s.usage);process.stdout.write(`
2
+ import"./chunk-GUOLMLZN.js";import{c as B}from"./chunk-JUQMSHNR.js";import"./chunk-U2MAPON2.js";import"./chunk-7UH4YDA7.js";import{c as U,d as C,f as O}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{f as m}from"./chunk-3M53YXEI.js";import{a as u,c as A,d as x,i as v,j as S,k as R}from"./chunk-JEVA7YQL.js";import"./chunk-OLDK2LKJ.js";import"./chunk-BT5YNE5U.js";import"./chunk-SF5HJ7PL.js";import"./chunk-FWIPHEVA.js";import{d as k}from"./chunk-WRI4XKSK.js";import"./chunk-GLUWATL5.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-MNC4YUDI.js";import{M as y}from"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-H7IWJN7L.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import{a as i}from"./chunk-FTQLQJQV.js";import{randomUUID as b}from"node:crypto";async function G(r,t){let e=t[0]||"smoke",n=await k(),l=await B(n,O(n)),c=P(n,r);if(e==="provider-catalog"||e==="providers-catalog"||e==="catalog"){let a=await E({apiBaseUrl:c,token:l});console.log(JSON.stringify(a,null,2));return}if(e==="models"||e==="model-list"){let a=await A({apiBaseUrl:c,token:l});console.log(JSON.stringify(a,null,2));return}if(e==="model"||e==="model-get"){let a=t[1]||o(r,"model");if(!a)throw new Error("usage: opchat model <model>");let p=await x({apiBaseUrl:c,token:l,model:a});console.log(JSON.stringify(p,null,2));return}if(e==="chat"){let a=o(r,"model")||"openpond-chat",p=o(r,"effort"),f=p?y.parse(p):void 0,d=o(r,"message")||o(r,"prompt")||"Reply with a short confirmation from OpChat.";if(!m(r.stream)){let s=await v({apiBaseUrl:c,token:l,model:a,reasoningEffort:f,messages:[{role:"user",content:d}]});console.log(JSON.stringify(s,null,2));return}let g="",h=null,w=null;for await(let s of S({apiBaseUrl:c,token:l,model:a,reasoningEffort:f,messages:[{role:"user",content:d}]}))s.type==="text_delta"?(g+=s.text,process.stdout.write(s.text)):s.type==="finish"?h=s.finishReason:s.type==="usage"&&(w=s.usage);process.stdout.write(`
3
3
  `),console.log(JSON.stringify({finishReason:h,usage:w,text:g},null,2));return}if(e==="smoke"){let a=await R({apiBaseUrl:c,token:l,defaultModel:o(r,"model")||void 0,compatibilityModel:o(r,"compatibilityModel")||o(r,"compatModel")||void 0,skipStream:m(r.skipStream),skipTool:m(r.skipTool),log:i(p=>console.log(p),"log")});m(r.json)&&console.log(JSON.stringify(a,null,2));return}throw new Error("usage: opchat <provider-catalog|models|model|chat|smoke> [--opchat-api-base-url <url>] [chat --model <id> --effort <off|low|medium|high|xhigh|max>]")}i(G,"runOpChatCommand");async function E(r){let t=r.apiBaseUrl.trim().replace(/\/+$/,"");if(!t)throw new Error("OpChat API base URL is required.");let e=r.token.trim();if(!e)throw new Error("OpenPond API key is required.");let n=await fetch(`${t}/provider-catalog`,{method:"GET",headers:{Authorization:`Bearer ${e}`,Accept:"application/json","Content-Type":"application/json","x-openpond-client":"openpond-cli","x-openpond-request-id":b()}});if(!n.ok)throw new Error(`Hosted provider catalog failed: ${n.status} ${await T(n)}`);return n.json()}i(E,"getOpChatProviderCatalog");async function T(r){let t=await r.text().catch(()=>"");if(!t)return r.statusText||`HTTP ${r.status}`;try{let e=JSON.parse(t);if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;if(e.error&&typeof e.error=="object"&&!Array.isArray(e.error)){let n=e.error;return[n.code,n.message].filter(Boolean).join(": ")||t}return t}catch{return t}}i(T,"readResponseError");function P(r,t){let e=o(t,"opchatApiBaseUrl")||o(t,"opchatApiBaseurl")||o(t,"opChatApiBaseUrl")||o(t,"opChatApiBaseurl")||o(t,"opchatApiUrl")||o(t,"opChatApiUrl");return e?u({opChatApiBaseUrl:e}):u({apiBaseUrl:U(t)||r.apiBaseUrl,chatApiBaseUrl:C(t)||r.chatApiBaseUrl})}i(P,"resolveOpChatCliBaseUrl");function o(r,t){let e=r[t];return typeof e=="string"?e.trim():""}i(o,"optionString");export{G as runOpChatCommand};