openpond 0.2.54 → 0.2.56

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 (432) hide show
  1. package/dist/app-server.d.ts +10823 -9118
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/actions-command-QU4H53OG.js +2 -0
  4. package/dist/chunks/{app-layer-I7MZYVLL.js → app-layer-NSTE5HIT.js} +1 -1
  5. package/dist/chunks/app-server-connected-apps-JHGWLBXT.js +2 -0
  6. package/dist/chunks/app-server-evaluations-GJPFWIDA.js +2 -0
  7. package/dist/chunks/app-server-harness-services-IH4G6POY.js +2 -0
  8. package/dist/chunks/app-server-runtime-DVKOZ5B6.js +2 -0
  9. package/dist/chunks/apps-BKTOR4F7.js +2 -0
  10. package/dist/chunks/chunk-25MBPJVY.js +2 -0
  11. package/dist/chunks/chunk-2D4Y3HNW.js +2 -0
  12. package/dist/chunks/chunk-2IHO4GDJ.js +2 -0
  13. package/dist/chunks/chunk-2QUCCP6Z.js +2 -0
  14. package/dist/chunks/chunk-3K4VVB7S.js +6 -0
  15. package/dist/chunks/chunk-3QIB5FXI.js +10 -0
  16. package/dist/chunks/chunk-3RCRSMWZ.js +17 -0
  17. package/dist/chunks/chunk-3VUATFZD.js +2 -0
  18. package/dist/chunks/chunk-3Z47M3YY.js +2 -0
  19. package/dist/chunks/{chunk-GXSTZBM6.js → chunk-4D7HWVWD.js} +1 -1
  20. package/dist/chunks/chunk-4EPSHPZL.js +2 -0
  21. package/dist/chunks/chunk-4NESNOK5.js +2 -0
  22. package/dist/chunks/chunk-523TE4BI.js +2 -0
  23. package/dist/chunks/chunk-5MCNZCVQ.js +2 -0
  24. package/dist/chunks/chunk-6QSSIT62.js +2 -0
  25. package/dist/chunks/chunk-6ZFPQYHG.js +2 -0
  26. package/dist/chunks/chunk-74IIXVAE.js +2 -0
  27. package/dist/chunks/chunk-74ZXXBGN.js +6 -0
  28. package/dist/chunks/chunk-773TH7FN.js +2 -0
  29. package/dist/chunks/chunk-7E6T7GP5.js +2 -0
  30. package/dist/chunks/chunk-7ED24PP6.js +2 -0
  31. package/dist/chunks/chunk-7HPDGZOR.js +86 -0
  32. package/dist/chunks/chunk-7KWD2I6W.js +2 -0
  33. package/dist/chunks/chunk-7PXZ4X4P.js +2 -0
  34. package/dist/chunks/chunk-A6USMRWK.js +2 -0
  35. package/dist/chunks/chunk-ABD5M2D2.js +2 -0
  36. package/dist/chunks/chunk-ACYFMLWG.js +10 -0
  37. package/dist/chunks/chunk-AN525SPP.js +6 -0
  38. package/dist/chunks/chunk-APB2STJK.js +2 -0
  39. package/dist/chunks/chunk-AY64VY4E.js +2 -0
  40. package/dist/chunks/{chunk-UJ5EFSEC.js → chunk-B7RFL4N2.js} +1 -1
  41. package/dist/chunks/chunk-BFKYRQMA.js +2 -0
  42. package/dist/chunks/chunk-BLXEAZCQ.js +12 -0
  43. package/dist/chunks/chunk-D74JEERO.js +5 -0
  44. package/dist/chunks/{chunk-PA7XP42P.js → chunk-DARVPBZ4.js} +1 -1
  45. package/dist/chunks/chunk-DBK66CJP.js +8 -0
  46. package/dist/chunks/chunk-DDMZSZFL.js +1 -0
  47. package/dist/chunks/chunk-DIO5CB6U.js +2 -0
  48. package/dist/chunks/chunk-DMFUEUAZ.js +5 -0
  49. package/dist/chunks/chunk-DMVD2RFZ.js +2 -0
  50. package/dist/chunks/chunk-DUURYZOI.js +2 -0
  51. package/dist/chunks/chunk-DZUAT3TP.js +1 -0
  52. package/dist/chunks/chunk-EIEZHFIW.js +6 -0
  53. package/dist/chunks/chunk-EIRYMSEG.js +19 -0
  54. package/dist/chunks/{chunk-JDLAHVAJ.js → chunk-EKM2D7JU.js} +1 -1
  55. package/dist/chunks/chunk-EQFGBL3O.js +2 -0
  56. package/dist/chunks/chunk-EYPCBBMS.js +2 -0
  57. package/dist/chunks/chunk-F4KOGISR.js +10 -0
  58. package/dist/chunks/chunk-F74GBN6K.js +2 -0
  59. package/dist/chunks/chunk-FEAKTSRS.js +2 -0
  60. package/dist/chunks/chunk-FFRFSDBM.js +2 -0
  61. package/dist/chunks/chunk-FTEOCCPB.js +23 -0
  62. package/dist/chunks/chunk-FUOEIDMA.js +8 -0
  63. package/dist/chunks/{chunk-AH22RHPS.js → chunk-FV2R5RUN.js} +2 -2
  64. package/dist/chunks/chunk-FWIPHEVA.js +12 -0
  65. package/dist/chunks/chunk-FY5KHLMW.js +2 -0
  66. package/dist/chunks/chunk-G3RXYI2L.js +6 -0
  67. package/dist/chunks/chunk-GJ2ZJFDD.js +2 -0
  68. package/dist/chunks/chunk-GLDYJM7O.js +1 -0
  69. package/dist/chunks/chunk-GPVCOEUH.js +2 -0
  70. package/dist/chunks/chunk-GW766ZSO.js +5 -0
  71. package/dist/chunks/chunk-GWCHDF2C.js +4 -0
  72. package/dist/chunks/chunk-GZ7M5XBP.js +2 -0
  73. package/dist/chunks/chunk-H6IW2R22.js +140 -0
  74. package/dist/chunks/chunk-HCYX6RHP.js +2 -0
  75. package/dist/chunks/chunk-HDL5YSAA.js +2 -0
  76. package/dist/chunks/chunk-HIOKCIL7.js +2 -0
  77. package/dist/chunks/chunk-HY3GOBFJ.js +58 -0
  78. package/dist/chunks/chunk-HZEIRHEB.js +2 -0
  79. package/dist/chunks/chunk-I2NXNMRZ.js +2 -0
  80. package/dist/chunks/chunk-I7AQMAQI.js +33 -0
  81. package/dist/chunks/chunk-IZ6DLEVY.js +2 -0
  82. package/dist/chunks/chunk-J2TWKFML.js +1871 -0
  83. package/dist/chunks/chunk-JDEEWOD7.js +2 -0
  84. package/dist/chunks/chunk-JFXWI3EN.js +6 -0
  85. package/dist/chunks/chunk-JYKRR7E5.js +5 -0
  86. package/dist/chunks/chunk-KCJVFLBB.js +2 -0
  87. package/dist/chunks/{chunk-5CMKGD43.js → chunk-KG325WTN.js} +1 -1
  88. package/dist/chunks/chunk-KGNCKIFP.js +3 -0
  89. package/dist/chunks/chunk-KUERKVEU.js +3 -0
  90. package/dist/chunks/chunk-KVTBX2UP.js +2 -0
  91. package/dist/chunks/chunk-L6K7ERG5.js +2 -0
  92. package/dist/chunks/{chunk-N5QNXMIS.js → chunk-LQQNBVEB.js} +1 -1
  93. package/dist/chunks/{chunk-YJ4PNAST.js → chunk-M4JWQSV7.js} +1 -1
  94. package/dist/chunks/chunk-MQULU465.js +2 -0
  95. package/dist/chunks/chunk-N4FFQPLR.js +2 -0
  96. package/dist/chunks/chunk-N73MU2C3.js +2 -0
  97. package/dist/chunks/chunk-NHQ36THU.js +3 -0
  98. package/dist/chunks/{chunk-4SHKI3BH.js → chunk-O6ULLQJ6.js} +1 -1
  99. package/dist/chunks/chunk-O72BSKSO.js +2 -0
  100. package/dist/chunks/chunk-OGDADQGH.js +143 -0
  101. package/dist/chunks/chunk-OIUTWU6K.js +2 -0
  102. package/dist/chunks/chunk-OLLLZVHF.js +2 -0
  103. package/dist/chunks/{chunk-XM26DGML.js → chunk-OPNRWESL.js} +1 -1
  104. package/dist/chunks/chunk-OQKJGTTO.js +4 -0
  105. package/dist/chunks/chunk-OQPJ7FJF.js +9 -0
  106. package/dist/chunks/{chunk-R3XFY7VL.js → chunk-OS3LO5J3.js} +1 -1
  107. package/dist/chunks/{chunk-T5LE6R5S.js → chunk-OSIO7PLX.js} +1 -1
  108. package/dist/chunks/chunk-OUVIWDL2.js +2 -0
  109. package/dist/chunks/chunk-PCSIOUHF.js +7 -0
  110. package/dist/chunks/chunk-PF5R6CMP.js +21 -0
  111. package/dist/chunks/chunk-PPAPVGJP.js +3 -0
  112. package/dist/chunks/chunk-PRGBLQVH.js +2 -0
  113. package/dist/chunks/chunk-PSGGOZFM.js +2 -0
  114. package/dist/chunks/chunk-PUZQU66L.js +2 -0
  115. package/dist/chunks/{chunk-WITSXYEW.js → chunk-Q2QL6UWN.js} +1 -1
  116. package/dist/chunks/chunk-Q4TBTRIG.js +2 -0
  117. package/dist/chunks/chunk-Q5LEXXJG.js +16 -0
  118. package/dist/chunks/{chunk-YL6VFJ4P.js → chunk-QDC4OW3S.js} +1 -1
  119. package/dist/chunks/chunk-QEFHOJFE.js +7 -0
  120. package/dist/chunks/chunk-QHWGQ3A4.js +5 -0
  121. package/dist/chunks/chunk-QIKWJ2AA.js +11 -0
  122. package/dist/chunks/chunk-QNG27G3T.js +6 -0
  123. package/dist/chunks/chunk-QOGJAQDO.js +3 -0
  124. package/dist/chunks/chunk-QOTVNQDI.js +4 -0
  125. package/dist/chunks/{chunk-N3DEA6PG.js → chunk-RAXOSUSW.js} +1 -1
  126. package/dist/chunks/chunk-RNIAFXMB.js +50 -0
  127. package/dist/chunks/chunk-S5ESN275.js +42 -0
  128. package/dist/chunks/chunk-SDAUS5PY.js +2 -0
  129. package/dist/chunks/chunk-SDXFLO7J.js +5 -0
  130. package/dist/chunks/chunk-SH5CBAFC.js +2 -0
  131. package/dist/chunks/chunk-SWUEFLOH.js +2 -0
  132. package/dist/chunks/chunk-SYUKES6H.js +3 -0
  133. package/dist/chunks/chunk-T5AACNJI.js +2 -0
  134. package/dist/chunks/chunk-TRQQNFMO.js +4 -0
  135. package/dist/chunks/chunk-TVQAPBLZ.js +2 -0
  136. package/dist/chunks/chunk-UCPGRPWY.js +2 -0
  137. package/dist/chunks/chunk-UGL7WF3W.js +2 -0
  138. package/dist/chunks/chunk-UHFZHBGW.js +2 -0
  139. package/dist/chunks/chunk-UKMA4R6X.js +6 -0
  140. package/dist/chunks/{chunk-7ZG3IT7C.js → chunk-VRIEKBBH.js} +6 -6
  141. package/dist/chunks/chunk-VYLGI3IH.js +13 -0
  142. package/dist/chunks/chunk-W45RKGM6.js +1 -0
  143. package/dist/chunks/chunk-WJ43MJ3F.js +2 -0
  144. package/dist/chunks/chunk-WMKYHXVM.js +3 -0
  145. package/dist/chunks/chunk-WN3V6KDN.js +3 -0
  146. package/dist/chunks/chunk-X4OSOOSU.js +3 -0
  147. package/dist/chunks/chunk-XDQMGUWL.js +2 -0
  148. package/dist/chunks/chunk-XTFPDQMH.js +3 -0
  149. package/dist/chunks/chunk-XVDFJ3ZF.js +2 -0
  150. package/dist/chunks/chunk-XW6HGSIT.js +8 -0
  151. package/dist/chunks/chunk-XXYGGNVM.js +2 -0
  152. package/dist/chunks/chunk-Y4OWBBDD.js +184 -0
  153. package/dist/chunks/chunk-YBT2NB32.js +2 -0
  154. package/dist/chunks/chunk-YCJO3YVD.js +10 -0
  155. package/dist/chunks/{chunk-YD55Z5H3.js → chunk-YOBN7KTF.js} +11 -11
  156. package/dist/chunks/chunk-YOQRYNLP.js +2 -0
  157. package/dist/chunks/chunk-YR5ID2SS.js +2 -0
  158. package/dist/chunks/chunk-YY7LEQGP.js +2 -0
  159. package/dist/chunks/chunk-Z4Z5UOZM.js +22 -0
  160. package/dist/chunks/chunk-Z54O534A.js +3 -0
  161. package/dist/chunks/chunk-ZCHXGRRU.js +2 -0
  162. package/dist/chunks/chunk-ZFSHBFG5.js +40 -0
  163. package/dist/chunks/chunk-ZGTOK7ZK.js +12 -0
  164. package/dist/chunks/{chunk-NAZ26IZL.js → chunk-ZRDGQDZL.js} +1 -1
  165. package/dist/chunks/chunk-ZUJ3XUCP.js +2 -0
  166. package/dist/chunks/chunk-ZZWAQBA2.js +2 -0
  167. package/dist/chunks/cli-X25RSO2X.js +2 -0
  168. package/dist/chunks/configuration-command-6C5UO7GE.js +2 -0
  169. package/dist/chunks/connected-app-executor-IVLGQP65.js +2 -0
  170. package/dist/chunks/connected-evidence-GH2ATNEX.js +2 -0
  171. package/dist/chunks/connection-HTF6CC7M.js +2 -0
  172. package/dist/chunks/{continual-PKK2BOTB.js → continual-6CQAMTTR.js} +3 -3
  173. package/dist/chunks/core-commands-A2DGGIPS.js +2 -0
  174. package/dist/chunks/datasets-7BNMVJOY.js +2 -0
  175. package/dist/chunks/desktop-test-3CUHVLXV.js +3 -0
  176. package/dist/chunks/dist-OMGUJYPD.js +2 -0
  177. package/dist/chunks/{chunk-6VF3Q6QJ.js → dist-SKYG5LZO.js} +2 -4
  178. package/dist/chunks/dist-VYC5VMQB.js +2 -0
  179. package/dist/chunks/dist-ZVJPJLXR.js +2 -0
  180. package/dist/chunks/enclave-QS4BUNDU.js +2 -0
  181. package/dist/chunks/evaluation-coordination-XEF5L7KZ.js +2 -0
  182. package/dist/chunks/experiment-improvements-KRX2DP27.js +2 -0
  183. package/dist/chunks/experiments-DFGQYA4O.js +2 -0
  184. package/dist/chunks/experiments-VFQGE4HC.js +2 -0
  185. package/dist/chunks/extension-XKXXOP5N.js +4 -0
  186. package/dist/chunks/{help-WLKSACLZ.js → help-S7THC6IE.js} +1 -1
  187. package/dist/chunks/host-profile-evaluation-tools-JJQWJUBT.js +2 -0
  188. package/dist/chunks/host-profile-external-dataset-K3ICDHIP.js +2 -0
  189. package/dist/chunks/hosted-app-server-composition-BCOO5ANF.js +2 -0
  190. package/dist/chunks/hosted-experiment-improvement-NFSVS5TU.js +3 -0
  191. package/dist/chunks/hosted-harness-runtime-723S5ZSH.js +2 -0
  192. package/dist/chunks/hosted-profile-candidate-2S5LFUWD.js +3 -0
  193. package/dist/chunks/hosted-profile-compiler-2DQIFSXW.js +2 -0
  194. package/dist/chunks/hosted-profile-evaluation-control-76BTRTYD.js +2 -0
  195. package/dist/chunks/hosted-profile-evaluation-inspection-V6Z3A5XJ.js +3 -0
  196. package/dist/chunks/hosted-profile-evaluation-preparation-IDJYREW3.js +3 -0
  197. package/dist/chunks/hosted-tasksets-ANAE2PIW.js +2 -0
  198. package/dist/chunks/human-review-WR777ODH.js +2 -0
  199. package/dist/chunks/import-MLZUHITH.js +4 -0
  200. package/dist/chunks/javascript-isolate-process-source-ZPQKKLR4.js +2 -0
  201. package/dist/chunks/javascript-verifier-worker-source-F3LSGPOY.js +2 -0
  202. package/dist/chunks/learning-ACEVFL5M.js +2 -0
  203. package/dist/chunks/local-harness-improvement-runtime-JIQ6ZVDW.js +2 -0
  204. package/dist/chunks/local-harness-taskset-review-XVYTGAGK.js +2 -0
  205. package/dist/chunks/local-scope-HVF2GZ5W.js +2 -0
  206. package/dist/chunks/model-projects-QPO22JPA.js +2 -0
  207. package/dist/chunks/opchat-T4QTNEIY.js +3 -0
  208. package/dist/chunks/organizations-75L5DZDV.js +2 -0
  209. package/dist/chunks/profile-TFZMUEDR.js +3 -0
  210. package/dist/chunks/profile-training-source-6GOT7AHM.js +2 -0
  211. package/dist/chunks/project-action-payload-7VGL7OER.js +2 -0
  212. package/dist/chunks/project-agent-6RRO233B.js +2 -0
  213. package/dist/chunks/published-experiment-source-DZFENAQA.js +2 -0
  214. package/dist/chunks/refiner-profile-service-UUIWFJVT.js +2 -0
  215. package/dist/chunks/runtime-A7OZXM43.js +6 -0
  216. package/dist/chunks/sandbox-command-IU5XFTJP.js +2 -0
  217. package/dist/chunks/{sandbox-template-BBGGPJMI.js → sandbox-template-C4V6T36U.js} +1 -1
  218. package/dist/chunks/saved-work-6BMBFP43.js +2 -0
  219. package/dist/chunks/send-turn-XTAIS2JN.js +2 -0
  220. package/dist/chunks/sql-execution-process-source-B4HQM6ZV.js +2 -0
  221. package/dist/chunks/src-CJM6HY5Y.js +326 -0
  222. package/dist/chunks/{src-CR6UZYTX.js → src-LMC3K6LH.js} +1 -1
  223. package/dist/chunks/standalone-experiment-turn-owner-JCY5LL5R.js +2 -0
  224. package/dist/chunks/store-chat-workflows-S72HZXQR.js +18 -0
  225. package/dist/chunks/store-continual-support-reviews-HHA6NX7K.js +7 -0
  226. package/dist/chunks/store-conversation-serving-KPC62UEY.js +2 -0
  227. package/dist/chunks/store-create-improve-QV54XIZW.js +40 -0
  228. package/dist/chunks/store-datasets-RXJ33SUN.js +86 -0
  229. package/dist/chunks/store-evaluation-results-3F3P527G.js +7 -0
  230. package/dist/chunks/store-harness-evaluation-review-settings-I2R3HPO3.js +29 -0
  231. package/dist/chunks/store-harness-memory-VINCZ4GK.js +17 -0
  232. package/dist/chunks/store-harness-refinement-candidates-EA5KFQPH.js +21 -0
  233. package/dist/chunks/store-harness-workspaces-XUM4Z66X.js +2 -0
  234. package/dist/chunks/store-human-review-RAH7WMIP.js +7 -0
  235. package/dist/chunks/store-learned-preference-migration-validation-4CI2IRUF.js +2 -0
  236. package/dist/chunks/store-learning-WLG6KFIO.js +2 -0
  237. package/dist/chunks/store-learning-credentials-WZQJ4HPJ.js +2 -0
  238. package/dist/chunks/store-local-experiments-5LUJR7GI.js +97 -0
  239. package/dist/chunks/store-model-batch-review-YEGX327M.js +2 -0
  240. package/dist/chunks/store-model-configuration-5ZURQATB.js +3 -0
  241. package/dist/chunks/store-preference-comparison-LV32MHVL.js +6 -0
  242. package/dist/chunks/store-schedules-VGTEQVKH.js +53 -0
  243. package/dist/chunks/store-sidebar-file-bookmarks-VB5GTLFY.js +18 -0
  244. package/dist/chunks/store-sidebar-preferences-GWIOG2NH.js +16 -0
  245. package/dist/chunks/store-subagents-T7R2Z6TB.js +67 -0
  246. package/dist/chunks/store-task-inbox-JJTBW76C.js +33 -0
  247. package/dist/chunks/store-task-inventory-OB3F2APC.js +10 -0
  248. package/dist/chunks/store-taskset-drafts-EKQWWFYQ.js +9 -0
  249. package/dist/chunks/store-training-G6YLFSIR.js +70 -0
  250. package/dist/chunks/store-training-jobs-RC46YBF6.js +19 -0
  251. package/dist/chunks/store-training-models-6BA43IPP.js +49 -0
  252. package/dist/chunks/store-usage-IE2U2FD3.js +63 -0
  253. package/dist/chunks/store-work-evidence-QQDKM5AQ.js +8 -0
  254. package/dist/chunks/taskset-EQRFQBYM.js +2 -0
  255. package/dist/chunks/taskset-packages-XC6HEE3K.js +2 -0
  256. package/dist/chunks/{teams-bot-7I4BAUVO.js → teams-bot-EAPGPTHZ.js} +1 -1
  257. package/dist/chunks/training-UF6RPI4T.js +2 -0
  258. package/dist/chunks/web-search-CZ3NCLPY.js +2 -0
  259. package/dist/chunks/workspaces-EKKE5NAC.js +2 -0
  260. package/dist/cli.js +1 -1
  261. package/dist/index.js +1 -1
  262. package/dist/web/assets/App-CaRMZoxo.css +1 -0
  263. package/dist/web/assets/App-s-CJswyt.js +154 -0
  264. package/dist/web/assets/{AppDialog-BdusXgU0.js → AppDialog-t2Fx5tK3.js} +1 -1
  265. package/dist/web/assets/{AppTerminalPanel-C4uRpnBz.js → AppTerminalPanel-Dj1Y32oI.js} +2 -2
  266. package/dist/web/assets/AppsView-BYE5EBDJ.js +1 -0
  267. package/dist/web/assets/{BrowserSidebar-Bl7V6YO2.js → BrowserSidebar-jhWi4rVm.js} +1 -1
  268. package/dist/web/assets/{CartesianChart-BstFbsdn.js → CartesianChart-C1DIx0Ia.js} +1 -1
  269. package/dist/web/assets/{CollaborationTabs-B8YAf0c1.js → CollaborationTabs-Bdr-HmOL.js} +1 -1
  270. package/dist/web/assets/{CommandMenu-DZct7zUJ.js → CommandMenu-Ux2yOHAc.js} +1 -1
  271. package/dist/web/assets/{CommunityView-CR0-W-uG.js → CommunityView-DPEeVKFn.js} +1 -1
  272. package/dist/web/assets/{ComposerCreateImproveStrip-DR-Qo7b4.js → ComposerCreateImproveStrip-CEgh4OtN.js} +1 -1
  273. package/dist/web/assets/{GetStartedView-xqQoMMei.js → GetStartedView-CFHP0AaI.js} +1 -1
  274. package/dist/web/assets/HostedModelLearningReview-D8BGTPVN.js +1 -0
  275. package/dist/web/assets/{HostedModelLearningSettings-De3i9wF4.js → HostedModelLearningSettings-JS1S7vNO.js} +1 -1
  276. package/dist/web/assets/{LabModelVersionDetailPage-DAY1MmqP.js → LabModelVersionDetailPage-Dx5Q3xV2.js} +1 -1
  277. package/dist/web/assets/{LabSkillSidebar-DLnIgnry.js → LabSkillSidebar-BxffN-pN.js} +1 -1
  278. package/dist/web/assets/LabsRoute-CyYF8-dw.js +99 -0
  279. package/dist/web/assets/MainChatThread-DZpcFRFl.js +2 -0
  280. package/dist/web/assets/MainPane-5DTtwVCk.js +65 -0
  281. package/dist/web/assets/MainPane-BIM_UJ3q.css +1 -0
  282. package/dist/web/assets/{MarkdownText-gJMuefaJ.js → MarkdownText-BR4V6lNO.js} +24 -24
  283. package/dist/web/assets/{NativeSkillSidebar-Dlxb8iOC.js → NativeSkillSidebar-DU9IEgIO.js} +1 -1
  284. package/dist/web/assets/{NewExperienceSwitcher-DM-cqJ-K.js → NewExperienceSwitcher-mIy6FzCj.js} +1 -1
  285. package/dist/web/assets/{NewProjectDialog-Cu1q75gq.js → NewProjectDialog-RfTZTHxl.js} +1 -1
  286. package/dist/web/assets/{OutputsPage-DiXMkasl.js → OutputsPage-Cr1Spf7S.js} +1 -1
  287. package/dist/web/assets/{ProjectsPage-DqiBHiCB.js → ProjectsPage-CE6QUB-b.js} +1 -1
  288. package/dist/web/assets/RightChatPanelStack-T6VRWuHo.js +1 -0
  289. package/dist/web/assets/RightSidebarHomePanel-CK0rP3WT.js +1 -0
  290. package/dist/web/assets/ScheduledWorkPage-vOrYv8pp.js +1 -0
  291. package/dist/web/assets/SettingsView-DCKVrfjj.js +5 -0
  292. package/dist/web/assets/SettingsView-Dulr_xlq.css +1 -0
  293. package/dist/web/assets/{TeamChatView-DM0adMtj.js → TeamChatView-Bwrjr-vk.js} +2 -2
  294. package/dist/web/assets/{TerminalOverlay-CFlH51DD.js → TerminalOverlay-DhPoKZAq.js} +1 -1
  295. package/dist/web/assets/TrainingCreationPanel-BXHfohNm.js +1 -0
  296. package/dist/web/assets/{TrainingDraftPanel-Bbo3RRie.js → TrainingDraftPanel-C9cRX5qf.js} +1 -1
  297. package/dist/web/assets/{UsageSettingsSection-CSRjJUSa.js → UsageSettingsSection-CrdcSGeW.js} +1 -1
  298. package/dist/web/assets/{WorkSidebarPanel-DwlEMEoG.js → WorkSidebarPanel-DSSikNFQ.js} +1 -1
  299. package/dist/web/assets/WorkspaceDiffPanel-BAFo0CPN.js +14 -0
  300. package/dist/web/assets/WorkspaceEnvironmentMenu-BVHAhwnJ.js +63 -0
  301. package/dist/web/assets/WorkspaceGitDialogs-CwVoiDQ2.js +1 -0
  302. package/dist/web/assets/{WorkspaceMonacoEditor-BR4qxMgU.js → WorkspaceMonacoEditor-TxLyhzNp.js} +3 -3
  303. package/dist/web/assets/arrow-up-right-C9aE8Mfz.js +1 -0
  304. package/dist/web/assets/chunk-P3BRSSRD-DUGfuKA8.js +1 -0
  305. package/dist/web/assets/{clipboard-BZzZ82Bk.js → clipboard-Dk158Qp4.js} +1 -1
  306. package/dist/web/assets/{cloud-upload-CJPYPVl8.js → cloud-upload-k9eqBsHr.js} +1 -1
  307. package/dist/web/assets/{cssMode-WC4Rg1l-.js → cssMode-CO35ARZp.js} +1 -1
  308. package/dist/web/assets/{folder-open-sLZJxLQy.js → folder-open-sYgceW_f.js} +1 -1
  309. package/dist/web/assets/folder-plus-CS0R49m9.js +1 -0
  310. package/dist/web/assets/{git-commit-horizontal-Cotm7KEC.js → git-commit-horizontal-DrGxH2h4.js} +1 -1
  311. package/dist/web/assets/{htmlMode-C6oZGeaB.js → htmlMode-REMmzdfq.js} +1 -1
  312. package/dist/web/assets/index-3iPNbbER.css +1 -0
  313. package/dist/web/assets/{index-BxWTVKtn.js → index-C8aCGagb.js} +2 -2
  314. package/dist/web/assets/info-DLdbiUrh.js +1 -0
  315. package/dist/web/assets/{jsonMode-BET4LQIn.js → jsonMode-KEdMfkIf.js} +1 -1
  316. package/dist/web/assets/{lspLanguageFeatures-BPxA_-Kg.js → lspLanguageFeatures-5KZwEoxW.js} +1 -1
  317. package/dist/web/assets/minimize-2-CqcI4zcM.js +1 -0
  318. package/dist/web/assets/{monaco.contribution-DFzEyaHi.js → monaco.contribution-BJGj65F9.js} +2 -2
  319. package/dist/web/assets/{monaco.contribution-DXzyQfVi.js → monaco.contribution-Cly9Wt7L.js} +2 -2
  320. package/dist/web/assets/{monaco.contribution-BH6kkO4b.js → monaco.contribution-DO10L0zW.js} +2 -2
  321. package/dist/web/assets/{monaco.contribution-7AUuf2NS.js → monaco.contribution-omszXBEj.js} +2 -2
  322. package/dist/web/assets/monitor-BFVCcbxp.js +1 -0
  323. package/dist/web/assets/play-C469pVZq.js +1 -0
  324. package/dist/web/assets/{python-PzBkTjWx.js → python-Dw0YcVy9.js} +1 -1
  325. package/dist/web/assets/{save-DpezrtH2.js → save-CtSjPydi.js} +1 -1
  326. package/dist/web/assets/square-BuImvLhT.js +1 -0
  327. package/dist/web/assets/{toggleHighContrast-Cto-fOXm.js → toggleHighContrast-DjCO9lIP.js} +1 -1
  328. package/dist/web/assets/{tsMode-BYA4LNc6.js → tsMode-BAOnxKd6.js} +1 -1
  329. package/dist/web/assets/{upload-C5YFNgtS.js → upload-2JkFZo3h.js} +1 -1
  330. package/dist/web/assets/{useLocalAgentSchedules-CnyTsqlf.js → useLocalAgentSchedules-BNqAisfS.js} +1 -1
  331. package/dist/web/assets/useProviderSettings-C4L4wDoh.js +5 -0
  332. package/dist/web/assets/{useProviderSettings-Bw-csWbH.css → useProviderSettings-CmL_BaxP.css} +1 -1
  333. package/dist/web/assets/{useSessionTurnCache-DICuJSJW.js → useSessionTurnCache-BHU2-Jmz.js} +1 -1
  334. package/dist/web/assets/{wifi-off-nzHj7JXp.js → wifi-off-CpOAH62M.js} +1 -1
  335. package/dist/web/assets/{workers-Dboaw6f_.js → workers-0QvlA2T5.js} +1 -1
  336. package/dist/web/assets/{yaml-uuY5JmO8.js → yaml-BK3qxo7D.js} +1 -1
  337. package/dist/web/index.html +2 -2
  338. package/package.json +3 -3
  339. package/dist/chunks/actions-command-DSO6YOEE.js +0 -2
  340. package/dist/chunks/app-server-runtime-7AXV6JZI.js +0 -2
  341. package/dist/chunks/apps-TM74FFQB.js +0 -2
  342. package/dist/chunks/chunk-2JO2KWT3.js +0 -5
  343. package/dist/chunks/chunk-2SPZYBDN.js +0 -16
  344. package/dist/chunks/chunk-37DXASQL.js +0 -191
  345. package/dist/chunks/chunk-4EEH7MEC.js +0 -2
  346. package/dist/chunks/chunk-4TZHH5FC.js +0 -2409
  347. package/dist/chunks/chunk-5TNDPNS3.js +0 -2
  348. package/dist/chunks/chunk-6JAN4RMN.js +0 -42
  349. package/dist/chunks/chunk-7QEE4PBI.js +0 -8
  350. package/dist/chunks/chunk-BX4J2VDU.js +0 -2
  351. package/dist/chunks/chunk-DALJMSJG.js +0 -33
  352. package/dist/chunks/chunk-EMKZVP7Z.js +0 -2
  353. package/dist/chunks/chunk-FPUUZQUP.js +0 -6
  354. package/dist/chunks/chunk-GCOUYYHG.js +0 -5
  355. package/dist/chunks/chunk-GS2NKNKG.js +0 -4
  356. package/dist/chunks/chunk-H2VT22JK.js +0 -2
  357. package/dist/chunks/chunk-HA7EFTPF.js +0 -23
  358. package/dist/chunks/chunk-IKWDL3RB.js +0 -17
  359. package/dist/chunks/chunk-NHFGEVVH.js +0 -518
  360. package/dist/chunks/chunk-NNF6KCHD.js +0 -3
  361. package/dist/chunks/chunk-PJM2G7SG.js +0 -21
  362. package/dist/chunks/chunk-PQHTZ5CP.js +0 -2
  363. package/dist/chunks/chunk-PYABBF53.js +0 -53
  364. package/dist/chunks/chunk-QRWPEW3Z.js +0 -24
  365. package/dist/chunks/chunk-QXVIIM4T.js +0 -2
  366. package/dist/chunks/chunk-SDEDAHV6.js +0 -160
  367. package/dist/chunks/chunk-TGIB24K4.js +0 -22
  368. package/dist/chunks/chunk-UE3DMPGM.js +0 -3
  369. package/dist/chunks/chunk-USKE34VR.js +0 -9
  370. package/dist/chunks/chunk-USMZT5FZ.js +0 -18
  371. package/dist/chunks/chunk-WV2APYWG.js +0 -2
  372. package/dist/chunks/chunk-YIB3J4RC.js +0 -2
  373. package/dist/chunks/chunk-Z3D4C7BG.js +0 -12
  374. package/dist/chunks/cli-JVB345H2.js +0 -2
  375. package/dist/chunks/configuration-command-MATM4XR5.js +0 -2
  376. package/dist/chunks/connected-evidence-YDPGNHLP.js +0 -2
  377. package/dist/chunks/core-commands-MTV4EKXY.js +0 -2
  378. package/dist/chunks/datasets-CP3IT47T.js +0 -2
  379. package/dist/chunks/desktop-test-IAZC5MAH.js +0 -3
  380. package/dist/chunks/dist-4HV2W6V4.js +0 -2
  381. package/dist/chunks/dist-SAABJU5F.js +0 -2
  382. package/dist/chunks/evaluation-coordination-EPHLZXYM.js +0 -2
  383. package/dist/chunks/experiment-improvements-6JTOPA74.js +0 -2
  384. package/dist/chunks/experiments-XHPFGECH.js +0 -2
  385. package/dist/chunks/extension-GX7DLW2X.js +0 -4
  386. package/dist/chunks/hosted-experiment-improvement-HAB3UE6A.js +0 -3
  387. package/dist/chunks/hosted-harness-runtime-YM23QNDK.js +0 -2
  388. package/dist/chunks/hosted-profile-candidate-EOBGKQAS.js +0 -3
  389. package/dist/chunks/hosted-profile-compiler-SCVJI2CP.js +0 -2
  390. package/dist/chunks/hosted-profile-evaluation-control-RJ6XJZCS.js +0 -2
  391. package/dist/chunks/hosted-profile-evaluation-inspection-OC4XNGL2.js +0 -3
  392. package/dist/chunks/hosted-profile-evaluation-preparation-ZD4FM3FD.js +0 -3
  393. package/dist/chunks/human-review-AAVMISBF.js +0 -2
  394. package/dist/chunks/import-V3HUGRHR.js +0 -4
  395. package/dist/chunks/learning-FNBEIAY6.js +0 -2
  396. package/dist/chunks/opchat-QK43DXTY.js +0 -3
  397. package/dist/chunks/organizations-SRPAWKC7.js +0 -2
  398. package/dist/chunks/profile-C6CQNVYE.js +0 -3
  399. package/dist/chunks/project-agent-GZV5HNYI.js +0 -2
  400. package/dist/chunks/sandbox-command-4TJXQTKT.js +0 -2
  401. package/dist/chunks/src-NE6R4XC6.js +0 -329
  402. package/dist/chunks/taskset-LUG3ZU6J.js +0 -2
  403. package/dist/chunks/training-XHE6FVII.js +0 -2
  404. package/dist/chunks/workspaces-MFZ3OO6O.js +0 -2
  405. package/dist/web/assets/App-CO2F717V.css +0 -1
  406. package/dist/web/assets/App-CuhaCsfb.js +0 -235
  407. package/dist/web/assets/AppsView-BS1czXUP.js +0 -1
  408. package/dist/web/assets/HostedModelLearningReview-CHxxf_Lu.js +0 -1
  409. package/dist/web/assets/LabsRoute-CXJRJMhr.js +0 -99
  410. package/dist/web/assets/MainChatThread-BwAla81W.js +0 -2
  411. package/dist/web/assets/MainPane-CakOBCHw.js +0 -19
  412. package/dist/web/assets/MainPane-DOWsSew1.css +0 -1
  413. package/dist/web/assets/RightChatPanelStack-VaOOmxwd.js +0 -1
  414. package/dist/web/assets/RightSidebarHomePanel-CeSFJM5s.js +0 -1
  415. package/dist/web/assets/ScheduledWorkPage-D1jRQxFs.js +0 -1
  416. package/dist/web/assets/SettingsView-BnANbPLS.css +0 -1
  417. package/dist/web/assets/SettingsView-RA9OXgcu.js +0 -5
  418. package/dist/web/assets/TrainingCreationPanel-CgIBVGha.js +0 -1
  419. package/dist/web/assets/WorkspaceDiffPanel-pGVezNMw.js +0 -14
  420. package/dist/web/assets/WorkspaceEnvironmentMenu-Byjngd9V.js +0 -32
  421. package/dist/web/assets/WorkspaceGitDialogs-Dgmg-6XG.js +0 -1
  422. package/dist/web/assets/arrow-up-right-H0pvnH2s.js +0 -1
  423. package/dist/web/assets/chunk-UHVJOMWN-BqXRe639.js +0 -1
  424. package/dist/web/assets/folder-plus-C84wrpt_.js +0 -1
  425. package/dist/web/assets/index-dSmk3FLJ.css +0 -1
  426. package/dist/web/assets/info-Dc81lEfw.js +0 -1
  427. package/dist/web/assets/minimize-2-Bs7MVN3C.js +0 -1
  428. package/dist/web/assets/monitor-DXL019Wf.js +0 -1
  429. package/dist/web/assets/play-CXkxUZeU.js +0 -1
  430. package/dist/web/assets/square-oy7f5Ce6.js +0 -1
  431. package/dist/web/assets/useProviderSettings-B_KeQjE5.js +0 -5
  432. /package/dist/chunks/{chunk-OGPHXXCD.js → chunk-BT5YNE5U.js} +0 -0
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{A as z,C as R,D as M,a as v,s as E,t as B,z as O}from"./chunk-PJM2G7SG.js";import{m as y}from"./chunk-NNF6KCHD.js";import{b as p}from"./chunk-ES2ISFJC.js";import{a as w}from"./chunk-FTQLQJQV.js";var S=p.number().int().nonnegative().nullable(),U=p.object({requestId:p.string().min(1),startedAt:p.string().datetime(),provider:p.string(),model:p.string(),mode:p.string(),status:p.string(),source:p.string(),projectId:p.string().nullable(),inputTokens:S,cachedInputTokens:S,outputTokens:S,totalTokens:S}).strict();var H=p.number().int().nonnegative(),C=p.object({invocations:H,inputTokens:H,cachedInputTokens:H,outputTokens:H,totalTokens:H,missingInput:H,missingCachedInput:H,missingOutput:H,missingTotal:H,failures:H,unattributed:H}).strict(),K=p.object({total:C,days:p.array(C.extend({key:p.string().regex(/^\d{4}-\d{2}-\d{2}$/)})),modes:p.array(C.extend({key:p.string()})),models:p.array(C.extend({key:p.string()}))}).strict();var $=w(h=>["accepted","rejected","cancelled"].includes(h.status),"closed");function a(h,r=422){throw new v(h,r)}w(a,"fail");function V(h,r,b){try{M(h.form,r,b)}catch(l){a(l instanceof Error?l.message:"human_answer_invalid")}}w(V,"answers");function X(h,r,b=()=>new Date().toISOString()){async function l(i,t){t.scope!==i.scope&&a("human_scope_denied",403),await r.member(i);let e=await r.owner(i,t.projectId),s=e||t.policy.managerIds.includes(i.actorId),n=e||t.assigneeId===i.actorId||t.policy.reviewerIds.includes(i.actorId);return e||s||n||t.policy.teamVisible||a("human_review_not_found",404),await r.evidence(i,t),{owner:e,manager:s,reviewer:n}}w(l,"access");async function A(i,t){let e=z.parse(t);return h.transaction(i.scope,async s=>{await r.member(i);let n=await s.get(e.id),c={owner:!1,manager:!1,reviewer:!1};if(e.action==="create"){let I={projectId:e.projectId,evidence:e.evidence,form:e.form};await r.owner(i,e.projectId)||a("human_assignment_owner_required",403),await r.evidence(i,I);for(let q of new Set([...e.assigneeId?[e.assigneeId]:[],...e.policy.managerIds,...e.policy.reviewerIds]))await r.assignee(i,q,I);e.kind==="grade"&&!e.evidence.attempts.length&&a("human_grade_requires_attempt"),e.kind!=="grade"&&!e.evidence.taskIds?.length&&a("human_task_assignment_requires_tasks"),e.form.mode==="pairwise"!=(e.evidence.attempts.length===2)&&a("human_form_evidence_mode_mismatch")}else n||a("human_review_not_found",404),c=await l(i,n),e.action==="bind_author_publication"&&!c.owner&&a("human_task_publication_owner_required",403),["reassign","cancel","decide"].includes(e.action)&&!c.manager&&a("human_manager_required",403),["save_draft","submit","reserve_execution","bind_execution"].includes(e.action)&&!c.reviewer&&!(e.action==="bind_execution"&&n.status==="cancelled"&&c.manager)&&a("human_assignee_required",403),e.action==="claim"&&(!n.policy.queueClaim||!n.policy.teamVisible||n.policy.reviewerIds.length&&!n.policy.reviewerIds.includes(i.actorId)&&!c.owner)&&a("human_claim_denied",403);let _=y([i.actorId,e.operationId]),d=y(e),k=await s.operation(_);if(k){k.requestHash!==d&&a("human_operation_conflict",409);let I=await s.get(k.reviewId,k.revision);return I||a("human_operation_result_unavailable",409),I}(n?.revision??0)!==e.expectedRevision&&a("human_revision_conflict",409);let o=b();if(e.action==="create")(n||e.expectedRevision!==0)&&a("human_review_exists",409),n=O.parse(R({schemaVersion:"openpond.humanReview.v1",id:e.id,revision:1,scope:i.scope,projectId:e.projectId,createdBy:i.actorId,kind:e.kind,title:e.title,...e.dueAt?{dueAt:e.dueAt}:{},authorPublication:null,evidence:e.evidence,form:e.form,policy:e.policy,status:e.assigneeId?"assigned":"queued",assigneeId:e.assigneeId,generation:1,drafts:[],submissions:[],decisions:[],audit:[],execution:null,createdAt:o,updatedAt:o}));else{n||a("human_review_not_found",404),$(n)&&e.action!=="bind_author_publication"&&!(n.status==="cancelled"&&e.action==="bind_execution")&&a("human_review_closed",409);let{contentHash:I,...q}=n,u={...q,revision:n.revision+1,updatedAt:o};if(e.action==="bind_author_publication")(n.kind!=="author"||n.status!=="accepted"||n.decisions.at(-1)?.taskProposalHash!==e.proposalHash||n.authorPublication)&&a("human_task_publication_stale",409),r.publication||a("human_task_publication_owner_unavailable",422),await r.publication(i,n,e.dataset,e.proposalHash),u.authorPublication={proposalHash:e.proposalHash,dataset:e.dataset,publishedBy:i.actorId,operationId:e.operationId,publishedAt:o};else if(e.action==="claim")(n.assigneeId||n.status!=="queued")&&a("human_already_claimed",409),await r.assignee(i,i.actorId,n),u={...u,assigneeId:i.actorId,status:"assigned",generation:n.generation+1,audit:[...n.audit,{actorId:i.actorId,action:"claim",priorAssigneeId:n.assigneeId,assigneeId:i.actorId,generation:n.generation+1,note:"",occurredAt:o}]};else if(e.action==="reserve_execution"||e.action==="bind_execution")if((n.kind!=="execute"||e.generation!==n.generation)&&a("human_execution_assignment_stale",409),e.action==="reserve_execution")n.execution&&a("human_execution_already_reserved",409),u.execution={executionId:null,operationId:e.runOperationId,boundBy:i.actorId,configurationHash:e.configurationHash,generation:e.generation,result:null},u.status="in_progress";else{let f=n.execution;(!f||f.executionId||f.operationId!==e.runOperationId||f.configurationHash!==e.configurationHash||f.boundBy!==i.actorId&&!(n.status==="cancelled"&&c.manager)||f.generation!==e.generation)&&a("human_execution_binding_conflict",409);let g={...f,executionId:e.executionId};r.execution||a("human_execution_owner_unavailable",422),await r.execution(i,n,g),u.execution=g}else if(e.action==="reassign")n.execution&&!n.execution.result&&a("human_execution_transfer_requires_completion",409),e.assigneeId&&await r.assignee(i,e.assigneeId,n),u={...u,execution:null,assigneeId:e.assigneeId,generation:n.generation+1,status:e.assigneeId?"assigned":"queued",audit:[...n.audit,{actorId:i.actorId,action:"reassign",priorAssigneeId:n.assigneeId,assigneeId:e.assigneeId,generation:n.generation+1,note:e.note,occurredAt:o}]};else if(e.action==="cancel")u.status="cancelled",u.audit=[...n.audit,{actorId:i.actorId,action:"cancel",priorAssigneeId:n.assigneeId,assigneeId:n.assigneeId,generation:n.generation,note:e.note,occurredAt:o}];else if(e.action==="save_draft"||e.action==="submit"){n.kind==="execute"&&!n.execution?.executionId&&a("human_execution_not_bound",409),e.generation!==n.generation&&a("human_assignment_generation_stale",409);let f=n.decisions.at(-1),g=n.submissions.filter(m=>m.actorId===i.actorId&&m.generation===n.generation).at(-1);if(g&&!(f?.outcome==="request_changes"&&f.submissions.some(m=>m.id===g.id))&&a("human_submission_already_sealed",409),e.taskProposal?.tasks.some(m=>m.expectedOutput!==void 0)&&!c.owner&&a("human_reference_edit_owner_required",403),e.taskProposal||e.action==="submit")try{B(n,e.taskProposal)}catch(m){a(m instanceof Error?m.message:"human_task_proposal_invalid")}if(V(n,e.answers,e.action==="submit"),e.action==="save_draft")u.drafts=[...n.drafts.filter(m=>m.actorId!==i.actorId),{actorId:i.actorId,generation:n.generation,...e.taskProposal?{taskProposal:e.taskProposal}:{},answers:e.answers,note:e.note,updatedAt:o}],u.status=n.status==="returned"?"returned":"in_progress";else{n.kind==="execute"&&((!e.executionResult||!r.completeExecution)&&a("human_execution_result_required",409),await r.completeExecution(i,n,e.executionResult),u.execution={...n.execution,result:e.executionResult}),(e.evidenceHash!==y(n.evidence)||e.formHash!==y(n.form))&&a("human_review_snapshot_stale",409);let m=R({...e.taskProposal?{taskProposal:e.taskProposal}:{},id:`submission-${_}`,revision:1,actorId:i.actorId,generation:n.generation,evidenceHash:e.evidenceHash,formHash:e.formHash,answers:e.answers,note:e.note,submittedAt:o,supersedes:g?.id??null});u.submissions=[...n.submissions,m],u.drafts=n.drafts.filter(x=>x.actorId!==i.actorId),u.status=n.policy.approval==="none"?"accepted":"submitted",n.policy.approval==="none"&&(u.decisions=[...n.decisions,R({id:`decision-${_}`,revision:1,actorId:i.actorId,outcome:"accept",...e.taskProposal?{taskProposalHash:e.taskProposal.contentHash}:{},submissions:[{id:m.id,contentHash:m.contentHash}],answers:e.answers,note:"",decidedAt:o})])}}else if(e.action==="decide"){(n.policy.approval!=="manager"||n.status!=="submitted")&&a("human_decision_not_required",409);let f=e.submissions.map(g=>n.submissions.find(m=>m.id===g.id&&m.contentHash===g.contentHash&&m.generation===n.generation&&!n.submissions.some(x=>x.supersedes===m.id))??a("human_submission_revision_stale",409));n.policy.distinctManager&&f.some(g=>g.actorId===i.actorId)&&a("human_distinct_manager_required",403),new Set(f.map(g=>g.id)).size!==f.length&&a("human_duplicate_submission"),e.outcome==="accept"&&new Set(f.map(g=>g.actorId)).size<n.policy.minimumRaters&&a("human_more_raters_required",409),e.outcome!=="accept"&&!e.note.trim()&&a("human_decision_reason_required"),n.kind==="author"&&e.outcome==="accept"&&!f.some(g=>g.taskProposal?.contentHash===e.taskProposalHash)&&a("human_task_proposal_decision_required",409),n.kind!=="author"&&e.taskProposalHash&&a("human_task_proposal_unexpected"),V(n,e.answers,e.outcome==="accept"),u.decisions=[...n.decisions,R({...e.taskProposalHash?{taskProposalHash:e.taskProposalHash}:{},id:`decision-${_}`,revision:1,actorId:i.actorId,outcome:e.outcome,submissions:e.submissions,answers:e.answers,note:e.note,decidedAt:o})],u.status=e.outcome==="accept"?"accepted":e.outcome==="reject"?"rejected":"returned"}n=O.parse(R(u))}return await s.put(n,e.expectedRevision),await s.saveOperation(_,{requestHash:d,reviewId:n.id,revision:n.revision}),n})}w(A,"command");async function T(i,t,e){return h.transaction(i.scope,async s=>{let n=await s.get(t);n||a("human_review_not_found",404),await l(i,n);let c=e===void 0?n:await s.get(t,e);return c||a("human_review_not_found",404),await r.evidence(i,c),c})}w(T,"get");async function P(i,t){return await r.member(i),h.transaction(i.scope,async e=>{let s,n=[],c=new Set,_=!1;do{let k=await e.list({projectId:t.projectId,afterId:s,limit:100});for(let o of k.items){let I;try{I=await l(i,o)}catch(x){if(x instanceof v&&[403,404].includes(x.status))continue;throw x}let q=!$(o),u=o.assigneeId===i.actorId||o.policy.reviewerIds.includes(i.actorId)||I.owner&&o.assigneeId===null&&o.createdBy===i.actorId,f=u&&I.reviewer&&q&&!o.submissions.some(x=>x.actorId===i.actorId&&x.generation===o.generation&&o.status!=="returned"),g=I.manager&&o.policy.approval==="manager"&&o.status==="submitted";I.manager&&o.policy.approval==="manager"&&(_=!0),(f||g)&&c.add(o.id),(t.view==="mine"?u:t.view==="approval"?I.manager&&o.policy.approval==="manager":o.policy.teamVisible||I.manager)&&(t.status==="active"?q:!q)&&(!t.afterId||o.id>t.afterId)&&n.push(o)}s=k.nextCursor??void 0}while(s);let d=n.slice(0,t.limit);return{items:d,nextCursor:n.length>t.limit?d.at(-1).id:null,actionCount:c.size,approvalAvailable:_}})}w(P,"inbox");async function j(i,t){let e=await T(i,t.id),s=await l(i,e),n=s.owner||s.manager,c=!n&&e.form.mode==="pairwise"&&e.policy.blindPair,_=!n&&e.policy.independentRaters;return{...t,evidence:c?null:t.evidence,evidenceHash:y(t.evidence),formHash:y(t.form),drafts:t.drafts.filter(d=>d.actorId===i.actorId).map(d=>({...d,taskProposal:s.owner?d.taskProposal:E(d.taskProposal)})),submissions:(_?t.submissions.filter(d=>d.actorId===i.actorId):t.submissions).map(d=>({...d,taskProposal:s.owner?d.taskProposal:E(d.taskProposal)})),decisions:_&&!$(e)?[]:t.decisions,audit:n?t.audit:[],createdBy:c?"owner":t.createdBy,permissions:{...s,claim:e.status==="queued"&&e.policy.queueClaim&&e.policy.teamVisible&&(!e.policy.reviewerIds.length||e.policy.reviewerIds.includes(i.actorId)||s.owner)}}}return w(j,"view"),{command:A,get:T,inbox:P,view:j}}w(X,"createHumanReviewService");async function ie(h){let{service:r,context:b,request:l}=h,A=await r.get(b,l.id);if(A.kind!=="execute"||A.generation!==l.generation)throw new v("human_execution_assignment_stale",409);let T=A.execution;if(T&&T.boundBy!==b.actorId)throw new v("human_execution_executor_changed",403);let P=T?.operationId??`human-run-${y([b.actorId,l.id,l.operationId])}`,j=h.configuration,i={...j,operationId:P,request:{...j.request,operationId:P}},t=y(i),e=T?A:await r.command(b,{action:"reserve_execution",id:l.id,expectedRevision:l.expectedRevision,operationId:`reserve-${l.operationId}`,generation:l.generation,runOperationId:P,configurationHash:t});if(!e.execution||e.execution.operationId!==P||e.execution.configurationHash!==t)throw new v("human_execution_reservation_conflict",409);let s=await r.get(b,l.id);if(s.execution?.executionId)return s.status==="cancelled"&&await h.cancel(s),s;let n;if(T)n=await h.recover(s);else{if(s.generation!==e.generation||["accepted","rejected","cancelled"].includes(s.status))throw new v("human_execution_assignment_stale",409);try{n=await h.dispatch(i,s)}catch(c){if(n=await h.recover(await r.get(b,l.id)),!n)throw c}}if(!n)throw new v("human_execution_admission_recovery_pending",409,"The original execution admission is unavailable. Recover its retained owner outcome before retrying this assignment.");for(let c=0;c<3;c++){let _=await r.get(b,l.id);if(_.generation!==e.generation||!_.execution||_.execution.operationId!==P)throw new v("human_execution_assignment_stale",409);let d;try{d=_.execution.executionId?_:await r.command(b,{action:"bind_execution",id:l.id,expectedRevision:_.revision,operationId:`bind-${P}`,generation:l.generation,runOperationId:P,configurationHash:t,executionId:n.id})}catch(k){if(k instanceof v&&k.code==="human_revision_conflict")continue;throw k}if(d.execution?.executionId!==n.id)throw new v("human_execution_binding_conflict",409);return d.status==="cancelled"&&await h.cancel(d),d}throw new v("human_execution_binding_recovery_pending",409,"The assignment changed while retaining its execution. Retry the original operation to recover that exact run.")}w(ie,"dispatchAssignedHumanExecution");export{K as a,X as b,ie as c};
2
+ import{I as E,J as B,P as O,Q as z,S as R,T as M,h as v}from"./chunk-ACYFMLWG.js";import{m as x}from"./chunk-KGNCKIFP.js";import{b as p}from"./chunk-ES2ISFJC.js";import{a as w}from"./chunk-FTQLQJQV.js";var S=p.number().int().nonnegative().nullable(),L=p.object({requestId:p.string().min(1),startedAt:p.string().datetime(),provider:p.string(),model:p.string(),mode:p.string(),status:p.string(),source:p.string(),projectId:p.string().nullable(),inputTokens:S,cachedInputTokens:S,outputTokens:S,totalTokens:S}).strict();var y=p.number().int().nonnegative(),C=p.object({invocations:y,inputTokens:y,cachedInputTokens:y,outputTokens:y,totalTokens:y,missingInput:y,missingCachedInput:y,missingOutput:y,missingTotal:y,failures:y,unattributed:y}).strict(),U=p.object({total:C,days:p.array(C.extend({key:p.string().regex(/^\d{4}-\d{2}-\d{2}$/)})),modes:p.array(C.extend({key:p.string()})),models:p.array(C.extend({key:p.string()}))}).strict();var $=w(h=>["accepted","rejected","cancelled"].includes(h.status),"closed");function a(h,r=422){throw new v(h,r)}w(a,"fail");function V(h,r,b){try{M(h.form,r,b)}catch(l){a(l instanceof Error?l.message:"human_answer_invalid")}}w(V,"answers");function Q(h,r,b=()=>new Date().toISOString()){async function l(i,t){t.scope!==i.scope&&a("human_scope_denied",403),await r.member(i);let e=await r.owner(i,t.projectId),s=e||t.policy.managerIds.includes(i.actorId),n=e||t.assigneeId===i.actorId||t.policy.reviewerIds.includes(i.actorId);return e||s||n||t.policy.teamVisible||a("human_review_not_found",404),await r.evidence(i,t),{owner:e,manager:s,reviewer:n}}w(l,"access");async function A(i,t){let e=z.parse(t);return h.transaction(i.scope,async s=>{await r.member(i);let n=await s.get(e.id),c={owner:!1,manager:!1,reviewer:!1};if(e.action==="create"){let I={projectId:e.projectId,evidence:e.evidence,form:e.form};await r.owner(i,e.projectId)||a("human_assignment_owner_required",403),await r.evidence(i,I);for(let q of new Set([...e.assigneeId?[e.assigneeId]:[],...e.policy.managerIds,...e.policy.reviewerIds]))await r.assignee(i,q,I);e.kind==="grade"&&!e.evidence.attempts.length&&a("human_grade_requires_attempt"),e.kind!=="grade"&&!e.evidence.taskIds?.length&&a("human_task_assignment_requires_tasks"),e.form.mode==="pairwise"!=(e.evidence.attempts.length===2)&&a("human_form_evidence_mode_mismatch")}else n||a("human_review_not_found",404),c=await l(i,n),e.action==="bind_author_publication"&&!c.owner&&a("human_task_publication_owner_required",403),["reassign","cancel","decide"].includes(e.action)&&!c.manager&&a("human_manager_required",403),["save_draft","submit","reserve_execution","bind_execution"].includes(e.action)&&!c.reviewer&&!(e.action==="bind_execution"&&n.status==="cancelled"&&c.manager)&&a("human_assignee_required",403),e.action==="claim"&&(!n.policy.queueClaim||!n.policy.teamVisible||n.policy.reviewerIds.length&&!n.policy.reviewerIds.includes(i.actorId)&&!c.owner)&&a("human_claim_denied",403);let _=x([i.actorId,e.operationId]),d=x(e),k=await s.operation(_);if(k){k.requestHash!==d&&a("human_operation_conflict",409);let I=await s.get(k.reviewId,k.revision);return I||a("human_operation_result_unavailable",409),I}(n?.revision??0)!==e.expectedRevision&&a("human_revision_conflict",409);let o=b();if(e.action==="create")(n||e.expectedRevision!==0)&&a("human_review_exists",409),n=O.parse(R({schemaVersion:"openpond.humanReview.v1",id:e.id,revision:1,scope:i.scope,projectId:e.projectId,createdBy:i.actorId,kind:e.kind,title:e.title,...e.dueAt?{dueAt:e.dueAt}:{},authorPublication:null,evidence:e.evidence,form:e.form,policy:e.policy,status:e.assigneeId?"assigned":"queued",assigneeId:e.assigneeId,generation:1,drafts:[],submissions:[],decisions:[],audit:[],execution:null,createdAt:o,updatedAt:o}));else{n||a("human_review_not_found",404),$(n)&&e.action!=="bind_author_publication"&&!(n.status==="cancelled"&&e.action==="bind_execution")&&a("human_review_closed",409);let{contentHash:I,...q}=n,u={...q,revision:n.revision+1,updatedAt:o};if(e.action==="bind_author_publication")(n.kind!=="author"||n.status!=="accepted"||n.decisions.at(-1)?.taskProposalHash!==e.proposalHash||n.authorPublication)&&a("human_task_publication_stale",409),r.publication||a("human_task_publication_owner_unavailable",422),await r.publication(i,n,e.dataset,e.proposalHash),u.authorPublication={proposalHash:e.proposalHash,dataset:e.dataset,publishedBy:i.actorId,operationId:e.operationId,publishedAt:o};else if(e.action==="claim")(n.assigneeId||n.status!=="queued")&&a("human_already_claimed",409),await r.assignee(i,i.actorId,n),u={...u,assigneeId:i.actorId,status:"assigned",generation:n.generation+1,audit:[...n.audit,{actorId:i.actorId,action:"claim",priorAssigneeId:n.assigneeId,assigneeId:i.actorId,generation:n.generation+1,note:"",occurredAt:o}]};else if(e.action==="reserve_execution"||e.action==="bind_execution")if((n.kind!=="execute"||e.generation!==n.generation)&&a("human_execution_assignment_stale",409),e.action==="reserve_execution")n.execution&&a("human_execution_already_reserved",409),u.execution={executionId:null,operationId:e.runOperationId,boundBy:i.actorId,configurationHash:e.configurationHash,generation:e.generation,result:null},u.status="in_progress";else{let f=n.execution;(!f||f.executionId||f.operationId!==e.runOperationId||f.configurationHash!==e.configurationHash||f.boundBy!==i.actorId&&!(n.status==="cancelled"&&c.manager)||f.generation!==e.generation)&&a("human_execution_binding_conflict",409);let g={...f,executionId:e.executionId};r.execution||a("human_execution_owner_unavailable",422),await r.execution(i,n,g),u.execution=g}else if(e.action==="reassign")n.execution&&!n.execution.result&&a("human_execution_transfer_requires_completion",409),e.assigneeId&&await r.assignee(i,e.assigneeId,n),u={...u,execution:null,assigneeId:e.assigneeId,generation:n.generation+1,status:e.assigneeId?"assigned":"queued",audit:[...n.audit,{actorId:i.actorId,action:"reassign",priorAssigneeId:n.assigneeId,assigneeId:e.assigneeId,generation:n.generation+1,note:e.note,occurredAt:o}]};else if(e.action==="cancel")u.status="cancelled",u.audit=[...n.audit,{actorId:i.actorId,action:"cancel",priorAssigneeId:n.assigneeId,assigneeId:n.assigneeId,generation:n.generation,note:e.note,occurredAt:o}];else if(e.action==="save_draft"||e.action==="submit"){n.kind==="execute"&&!n.execution?.executionId&&a("human_execution_not_bound",409),e.generation!==n.generation&&a("human_assignment_generation_stale",409);let f=n.decisions.at(-1),g=n.submissions.filter(m=>m.actorId===i.actorId&&m.generation===n.generation).at(-1);if(g&&!(f?.outcome==="request_changes"&&f.submissions.some(m=>m.id===g.id))&&a("human_submission_already_sealed",409),e.taskProposal?.tasks.some(m=>m.expectedOutput!==void 0)&&!c.owner&&a("human_reference_edit_owner_required",403),e.taskProposal||e.action==="submit")try{B(n,e.taskProposal)}catch(m){a(m instanceof Error?m.message:"human_task_proposal_invalid")}if(V(n,e.answers,e.action==="submit"),e.action==="save_draft")u.drafts=[...n.drafts.filter(m=>m.actorId!==i.actorId),{actorId:i.actorId,generation:n.generation,...e.taskProposal?{taskProposal:e.taskProposal}:{},answers:e.answers,note:e.note,updatedAt:o}],u.status=n.status==="returned"?"returned":"in_progress";else{n.kind==="execute"&&((!e.executionResult||!r.completeExecution)&&a("human_execution_result_required",409),await r.completeExecution(i,n,e.executionResult),u.execution={...n.execution,result:e.executionResult}),(e.evidenceHash!==x(n.evidence)||e.formHash!==x(n.form))&&a("human_review_snapshot_stale",409);let m=R({...e.taskProposal?{taskProposal:e.taskProposal}:{},id:`submission-${_}`,revision:1,actorId:i.actorId,generation:n.generation,evidenceHash:e.evidenceHash,formHash:e.formHash,answers:e.answers,note:e.note,submittedAt:o,supersedes:g?.id??null});u.submissions=[...n.submissions,m],u.drafts=n.drafts.filter(H=>H.actorId!==i.actorId),u.status=n.policy.approval==="none"?"accepted":"submitted",n.policy.approval==="none"&&(u.decisions=[...n.decisions,R({id:`decision-${_}`,revision:1,actorId:i.actorId,outcome:"accept",...e.taskProposal?{taskProposalHash:e.taskProposal.contentHash}:{},submissions:[{id:m.id,contentHash:m.contentHash}],answers:e.answers,note:"",decidedAt:o})])}}else if(e.action==="decide"){(n.policy.approval!=="manager"||n.status!=="submitted")&&a("human_decision_not_required",409);let f=e.submissions.map(g=>n.submissions.find(m=>m.id===g.id&&m.contentHash===g.contentHash&&m.generation===n.generation&&!n.submissions.some(H=>H.supersedes===m.id))??a("human_submission_revision_stale",409));n.policy.distinctManager&&f.some(g=>g.actorId===i.actorId)&&a("human_distinct_manager_required",403),new Set(f.map(g=>g.id)).size!==f.length&&a("human_duplicate_submission"),e.outcome==="accept"&&new Set(f.map(g=>g.actorId)).size<n.policy.minimumRaters&&a("human_more_raters_required",409),e.outcome!=="accept"&&!e.note.trim()&&a("human_decision_reason_required"),n.kind==="author"&&e.outcome==="accept"&&!f.some(g=>g.taskProposal?.contentHash===e.taskProposalHash)&&a("human_task_proposal_decision_required",409),n.kind!=="author"&&e.taskProposalHash&&a("human_task_proposal_unexpected"),V(n,e.answers,e.outcome==="accept"),u.decisions=[...n.decisions,R({...e.taskProposalHash?{taskProposalHash:e.taskProposalHash}:{},id:`decision-${_}`,revision:1,actorId:i.actorId,outcome:e.outcome,submissions:e.submissions,answers:e.answers,note:e.note,decidedAt:o})],u.status=e.outcome==="accept"?"accepted":e.outcome==="reject"?"rejected":"returned"}n=O.parse(R(u))}return await s.put(n,e.expectedRevision),await s.saveOperation(_,{requestHash:d,reviewId:n.id,revision:n.revision}),n})}w(A,"command");async function T(i,t,e){return h.transaction(i.scope,async s=>{let n=await s.get(t);n||a("human_review_not_found",404),await l(i,n);let c=e===void 0?n:await s.get(t,e);return c||a("human_review_not_found",404),await r.evidence(i,c),c})}w(T,"get");async function P(i,t){return await r.member(i),h.transaction(i.scope,async e=>{let s,n=[],c=new Set,_=!1;do{let k=await e.list({projectId:t.projectId,afterId:s,limit:100});for(let o of k.items){let I;try{I=await l(i,o)}catch(H){if(H instanceof v&&[403,404].includes(H.status))continue;throw H}let q=!$(o),u=o.assigneeId===i.actorId||o.policy.reviewerIds.includes(i.actorId)||I.owner&&o.assigneeId===null&&o.createdBy===i.actorId,f=u&&I.reviewer&&q&&!o.submissions.some(H=>H.actorId===i.actorId&&H.generation===o.generation&&o.status!=="returned"),g=I.manager&&o.policy.approval==="manager"&&o.status==="submitted";I.manager&&o.policy.approval==="manager"&&(_=!0),(f||g)&&c.add(o.id),(t.view==="mine"?u:t.view==="approval"?I.manager&&o.policy.approval==="manager":o.policy.teamVisible||I.manager)&&(t.status==="active"?q:!q)&&(!t.afterId||o.id>t.afterId)&&n.push(o)}s=k.nextCursor??void 0}while(s);let d=n.slice(0,t.limit);return{items:d,nextCursor:n.length>t.limit?d.at(-1).id:null,actionCount:c.size,approvalAvailable:_}})}w(P,"inbox");async function j(i,t){let e=await T(i,t.id),s=await l(i,e),n=s.owner||s.manager,c=!n&&e.form.mode==="pairwise"&&e.policy.blindPair,_=!n&&e.policy.independentRaters;return{...t,evidence:c?null:t.evidence,evidenceHash:x(t.evidence),formHash:x(t.form),drafts:t.drafts.filter(d=>d.actorId===i.actorId).map(d=>({...d,taskProposal:s.owner?d.taskProposal:E(d.taskProposal)})),submissions:(_?t.submissions.filter(d=>d.actorId===i.actorId):t.submissions).map(d=>({...d,taskProposal:s.owner?d.taskProposal:E(d.taskProposal)})),decisions:_&&!$(e)?[]:t.decisions,audit:n?t.audit:[],createdBy:c?"owner":t.createdBy,permissions:{...s,claim:e.status==="queued"&&e.policy.queueClaim&&e.policy.teamVisible&&(!e.policy.reviewerIds.length||e.policy.reviewerIds.includes(i.actorId)||s.owner)}}}return w(j,"view"),{command:A,get:T,inbox:P,view:j}}w(Q,"createHumanReviewService");async function ne(h){let{service:r,context:b,request:l}=h,A=await r.get(b,l.id);if(A.kind!=="execute"||A.generation!==l.generation)throw new v("human_execution_assignment_stale",409);let T=A.execution;if(T&&T.boundBy!==b.actorId)throw new v("human_execution_executor_changed",403);let P=T?.operationId??`human-run-${x([b.actorId,l.id,l.operationId])}`,j=h.configuration,i={...j,operationId:P,request:{...j.request,operationId:P}},t=x(i),e=T?A:await r.command(b,{action:"reserve_execution",id:l.id,expectedRevision:l.expectedRevision,operationId:`reserve-${l.operationId}`,generation:l.generation,runOperationId:P,configurationHash:t});if(!e.execution||e.execution.operationId!==P||e.execution.configurationHash!==t)throw new v("human_execution_reservation_conflict",409);let s=await r.get(b,l.id);if(s.execution?.executionId)return s.status==="cancelled"&&await h.cancel(s),s;let n;if(T)n=await h.recover(s);else{if(s.generation!==e.generation||["accepted","rejected","cancelled"].includes(s.status))throw new v("human_execution_assignment_stale",409);try{n=await h.dispatch(i,s)}catch(c){if(n=await h.recover(await r.get(b,l.id)),!n)throw c}}if(!n)throw new v("human_execution_admission_recovery_pending",409,"The original execution admission is unavailable. Recover its retained owner outcome before retrying this assignment.");for(let c=0;c<3;c++){let _=await r.get(b,l.id);if(_.generation!==e.generation||!_.execution||_.execution.operationId!==P)throw new v("human_execution_assignment_stale",409);let d;try{d=_.execution.executionId?_:await r.command(b,{action:"bind_execution",id:l.id,expectedRevision:_.revision,operationId:`bind-${P}`,generation:l.generation,runOperationId:P,configurationHash:t,executionId:n.id})}catch(k){if(k instanceof v&&k.code==="human_revision_conflict")continue;throw k}if(d.execution?.executionId!==n.id)throw new v("human_execution_binding_conflict",409);return d.status==="cancelled"&&await h.cancel(d),d}throw new v("human_execution_binding_recovery_pending",409,"The assignment changed while retaining its execution. Retry the original operation to recover that exact run.")}w(ne,"dispatchAssignedHumanExecution");export{U as a,Q as b,ne as c};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as Me,b as Be}from"./chunk-3K4VVB7S.js";import{b as Le}from"./chunk-773TH7FN.js";import{c as Oe}from"./chunk-AN525SPP.js";import{b as Te}from"./chunk-XW6HGSIT.js";import{a as te,c as ae}from"./chunk-FUOEIDMA.js";import{a as _e,b as De}from"./chunk-NHQ36THU.js";import{g as Ie,j as ne}from"./chunk-N4FFQPLR.js";import{d as ee,e as xe,f as Pe,g as qe}from"./chunk-AY64VY4E.js";import{d as Se,f as Ae,h as Ce}from"./chunk-JFXWI3EN.js";import{m as D}from"./chunk-KGNCKIFP.js";import{b as C}from"./chunk-ES2ISFJC.js";import{a as o}from"./chunk-FTQLQJQV.js";function ze(e){let t=new Map,s=new Map,r=new Map,i=new Map(e.triggers.map(a=>[L(a),a])),u=new Map(e.observations.map(a=>[L(a),a])),c=new Map(e.outcomes.map(a=>[L(a.trigger),a]));return async a=>{let[p,f,R]=await Promise.all([d(a.runRef),m(a.runRef),e.store.getSession(a.runRef)]),A=f.slice().sort((S,x)=>S.startedAt.localeCompare(x.startedAt)),w=A.find(S=>S.id===a.turnId)??await e.store.getTurn(a.turnId),T=A.findIndex(S=>S.id===a.turnId),M=T>0?A.slice(0,T):[],F=M.slice(-e.limits.maxPrecedingTurns),$=tt(F,p,e.limits.maxConversationChars),W=p.filter(S=>S.turnId===a.turnId).filter(S=>["tool.completed","validation.completed","workspace_action_result"].includes(S.name)).filter(S=>S.status==="failed"||["validation.completed","workspace_action_result"].includes(S.name)),O=r.get(a.runRef);O||(O=await Me(R?.cwd),r.set(a.runRef,O));let g=e.sourcePolicies.get(a.runRef)??null,v=H(a),_=b(a),I=_.results,E={schemaVersion:"openpond.localHarnessDeepReviewContext.v1",binding:{ownerScope:e.workspace.ownerScope,workspaceId:e.workspace.id,sourceRef:a.runRef,sourceTurn:a.turnId,admittedHarness:a.harnessRelease,observation:Q(a),refinerOutcome:v?Q(v):null,sourcePolicy:g?{policy:g.policy,state:g.state,checkedAt:g.checkedAt}:null},conversation:{precedingTurns:$,currentTurn:w?We(w,p,2e3,6e3):null},artifactDiagnostics:O.slice(0,e.limits.maxArtifactDiagnostics),events:W.slice(-e.limits.maxContextEvents).map(nt),currentResult:v?l(v):null,laterResults:I,truncation:{availablePrecedingTurns:M.length,includedPrecedingTurns:$.length,precedingTurnsTruncated:M.length>$.length,conversationChars:rt($),availableContextEvents:W.length,includedContextEvents:Math.min(W.length,e.limits.maxContextEvents),availableArtifactDiagnostics:O.length,includedArtifactDiagnostics:Math.min(O.length,e.limits.maxArtifactDiagnostics),availableLaterResults:_.total,includedLaterResults:I.length,laterResultsTruncated:_.total>I.length,sessionMissing:R===null,turnMissing:w===null}};return{...E,contentHash:D(E)}};async function d(a){let p=t.get(a);if(p)return p;let f=await e.store.runtimeEventsForSession(a);return t.set(a,f),f}async function m(a){let p=s.get(a);if(p)return p;let f=await e.store.turnsForSession(a,500);return s.set(a,f),f}function H(a){for(let p of e.triggers)if(p.observations.some(f=>L(f)===L(a)))return c.get(L(p))??null;return null}function b(a){if(!a.deterministicClass)return{results:[],total:0};let f=e.outcomes.flatMap(R=>R.createdAt<=a.createdAt?[]:(i.get(L(R.trigger))?.observations.map(T=>u.get(L(T))).filter(T=>!!T)??[]).some(T=>T.deterministicClass===a.deterministicClass)?[l(R)]:[]).sort((R,A)=>String(R.createdAt).localeCompare(String(A.createdAt)));return{results:f.slice(0,e.limits.maxLaterResults),total:f.length}}function l(a){let p=a.proposal?e.applyReceipts.filter(w=>L(w.proposal)===L(a.proposal)):[],f=a.proposal?e.advanceReceipts.filter(w=>w.proposal&&L(w.proposal)===L(a.proposal)):[],R=new Set(f.map(w=>L(w))),A=e.advanceReceipts.filter(w=>w.rollbackOf&&R.has(L(w.rollbackOf)));return{outcome:Q(a),decision:a.decision,reason:N(a.reason,1500),proposal:a.proposal,createdAt:a.createdAt,applyReceipts:p.map(w=>({...Q(w),decision:w.decision,createdAt:w.createdAt})),advanceReceipts:f.map(w=>({...Q(w),decision:w.decision,previousRelease:w.previousRelease,nextRelease:w.nextRelease,createdAt:w.createdAt})),rollbackReceipts:A.map(w=>({...Q(w),decision:w.decision,rollbackOf:w.rollbackOf,nextRelease:w.nextRelease,createdAt:w.createdAt}))}}}o(ze,"createLocalHarnessDeepReviewContextLoader");function tt(e,t,s){if(!e.length||s<=0)return[];let r=Math.max(1,Math.floor(s/(e.length*2)));return e.map(i=>We(i,t,r,r))}o(tt,"boundedConversationTurns");function We(e,t,s,r){return{id:e.id,startedAt:e.startedAt,completedAt:e.completedAt,status:e.status,error:N(e.error??"",1e3),prompt:N(e.prompt,s),assistantOutput:N(st(t,e.id),r)}}o(We,"boundedTurn");function st(e,t){return e.filter(s=>s.turnId===t&&s.name==="assistant.delta").map(s=>s.output??"").join("")}o(st,"assistantOutputForTurn");function rt(e){return e.reduce((t,s)=>t+(typeof s.prompt=="string"?s.prompt.length:0)+(typeof s.assistantOutput=="string"?s.assistantOutput.length:0),0)}o(rt,"conversationCharacterCount");function nt(e){let t=$e(e.data),s=$e(t.result);return{id:e.id,name:e.name,action:e.action??(typeof t.tool=="string"?t.tool:null),status:e.status??null,error:N(e.error??"",750),output:N(typeof s.output=="string"?s.output:e.output??"",750),stderr:N(typeof s.stderr=="string"?s.stderr:"",750),exitCode:typeof s.exitCode=="number"?s.exitCode:null,timedOut:s.timedOut===!0}}o(nt,"boundedReviewEvent");function N(e,t){if(!e||t<=0)return null;let s=e.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,"Bearer [redacted]").replace(/\b(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/gi,"$1$2[redacted]");if(s.length<=t)return s;let r=`
3
+ [... middle omitted ...]
4
+ `;if(r.length>=t)return s.slice(0,t);let i=Math.max(0,t-r.length),u=Math.ceil(i/2),c=Math.floor(i/2);return`${s.slice(0,u)}${r}${s.slice(-c)}`}o(N,"boundedReviewText");function Q(e){return{id:e.id,contentHash:e.contentHash}}o(Q,"artifactRef");function L(e){return`${e.id}:${e.contentHash}`}o(L,"artifactKey");function $e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}o($e,"asRecord");var at=2160*60*60*1e3;async function fe(e){let t=[],s=await e.store.listHarnessRefinementCandidates(e.workspace.id),r=e.upsertReviewClaim!==!1&&e.review.classification==="harness_maintenance"?e.review.claim?.fingerprint??null:null;for(let c of s){if(c.fingerprint===r)continue;let d=ot({...e,candidate:c});d&&(await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.workspace.id,...d}),t.push(d.receipt))}let i=null;if(e.upsertReviewClaim!==!1&&e.review.classification==="harness_maintenance"&&e.review.claim){let c=await e.store.getHarnessRefinementCandidateByFingerprint(e.workspace.id,e.review.claim.fingerprint),d=it({...e,candidate:c});d?(await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.workspace.id,...d}),t.push(d.receipt),i=d.candidate):i=c}let u=await e.store.listHarnessRefinementCandidates(e.workspace.id);return e.upsertReviewClaim===!1&&(i=u.find(c=>c.status==="confirmed"&&c.sourceReviews.some(d=>d.id===e.review.id&&d.contentHash===e.review.contentHash))??null),{activeCandidate:i,candidates:u,lifecycleReceipts:t}}o(fe,"reconcileLocalHarnessRefinementCandidates");async function Ue(e){if(!["unresolved","confirmed"].includes(e.candidate.status))return e.candidate;let t=ee({...we(e.candidate),sourceReviews:V([...e.candidate.sourceReviews,z(e.review)]),relatedHarnessReleases:V([...e.candidate.relatedHarnessReleases,...e.relatedHarnessRelease?[e.relatedHarnessRelease]:[]]),lastReviewedAt:e.now,updatedAt:e.now,resolution:null}),s=ie({before:e.candidate,candidate:t,review:e.review,decision:"merged",addedEvidence:[],removedEvidence:[],reason:e.reason,now:e.now});return await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.candidate.workspaceRef,...s}),t}o(Ue,"recordAppliedLocalHarnessRefinementCandidate");async function Fe(e){if(e.candidate.status!=="confirmed")throw new Error("Later-success resolution requires a confirmed candidate.");let t=e.review.harnessRelease,s=e.candidate.relatedHarnessReleases.at(-1);if(e.candidate.relatedHarnessReleases.length<2||!s||s.id!==t.id||s.contentHash!==t.contentHash)throw new Error("Later-success evidence is not bound to the candidate's applied Harness release.");let r=new Set(e.candidate.occurrences.map(d=>d.sourceRef)),i=e.evidence.filter(d=>!r.has(d.sourceRef));if(i.length===0)throw new Error("Later-success resolution requires evidence from an independent work source.");let u=ee({...we(e.candidate),status:"resolved",sourceReviews:V([...e.candidate.sourceReviews,z(e.review)]),lastReviewedAt:e.now,updatedAt:e.now,resolution:{kind:"later_success",reason:e.reason,evidenceRefs:V(i.map(d=>d.evidence)),resolvedAt:e.now}}),c=ie({before:e.candidate,candidate:u,review:e.review,decision:"resolved",addedEvidence:i,removedEvidence:[],reason:e.reason,now:e.now});return await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.candidate.workspaceRef,...c}),u}o(Fe,"resolveLocalHarnessRefinementCandidateFromLaterSuccess");function ot(e){if(!["unresolved","confirmed"].includes(e.candidate.status))return null;let t=[],s=oe(e.candidate.occurrences,e.sourcePolicies,t),r=oe(e.candidate.counterevidence,e.sourcePolicies,t),i=V([...e.candidate.sourceReviews,z(e.review)]),u=Date.parse(e.candidate.expiresAt)<=Date.parse(e.now),c=s.length===0,d=c?"rejected":u?"expired":t.length>0?"unresolved":e.candidate.status,m=c?"rejected":u?"expired":"merged";if(!(t.length>0||e.candidate.lastReviewedAt!==e.now||e.candidate.sourceReviews.length!==i.length)&&!u)return null;let b=c?"All supporting occurrences were revoked, deleted, expired, or unavailable at review time.":u?"The bounded candidate lifetime elapsed without sufficient confirming evidence.":"Candidate evidence was reauthorized against the current source policy set.",l=ee({...we(e.candidate),status:d,occurrences:s,counterevidence:r,sourceReviews:i,lastReviewedAt:e.now,updatedAt:e.now,expiresAt:u?e.now:e.candidate.expiresAt,resolution:c||u?{kind:c?"source_revoked":"expired",reason:b,evidenceRefs:t.map(a=>a.evidence),resolvedAt:e.now}:null});return ie({before:e.candidate,candidate:l,review:e.review,decision:m,addedEvidence:[],removedEvidence:t.map(a=>a.evidence),reason:b,now:e.now})}o(ot,"reauthorizeOrExpireCandidate");function it(e){let t=e.review.claim,s=e.candidate,r=[],i=s?oe(s.occurrences,e.sourcePolicies,r):[],u=s?oe(s.counterevidence,e.sourcePolicies,r):[],c=new Set(s&&["unresolved","confirmed"].includes(s.status)?i.map(f=>f.occurrenceKey):[]),d=e.review.selectedEvidence.filter(f=>!c.has(f.occurrenceKey));if(s&&d.length===0&&r.length===0&&["unresolved","confirmed"].includes(s.status))return null;let m=ct([...i,...e.review.selectedEvidence]),H=t.candidateDisposition==="confirm"?"confirmed":"unresolved",b=m.map(f=>f.occurredAt).sort()[0],l=m.map(f=>f.occurredAt).sort().at(-1),a=ee({schemaVersion:"openpond.harnessRefinementCandidate.v1",id:s?.id??`refinement-candidate-${t.fingerprint.slice(0,24)}`,ownerScope:e.workspace.ownerScope,workspaceRef:e.workspace.id,fingerprint:t.fingerprint,recurrenceFamily:t.recurrenceFamily,statement:t.statement,status:H,occurrences:m,counterevidence:u,sourceReviews:V([...s?.sourceReviews??[],z(e.review)]),relatedHarnessReleases:V([...s?.relatedHarnessReleases??[],e.review.harnessRelease]),firstSeenAt:b,lastSeenAt:l,lastReviewedAt:e.now,expiresAt:new Date(Date.parse(e.now)+at).toISOString(),resolution:null,createdAt:s?.createdAt??e.now,updatedAt:e.now}),p=s?["resolved","rejected","expired"].includes(s.status)?"reopened":"merged":"created";return ie({before:s,candidate:a,review:e.review,decision:p,addedEvidence:d,removedEvidence:r.map(f=>f.evidence),reason:p==="created"?"Created a bounded candidate from an authorized cross-Work Harness claim.":p==="reopened"?"New authorized evidence reopened the prior candidate.":"Merged new authorized evidence into the existing candidate.",now:e.now})}o(it,"upsertCandidateFromReview");function ie(e){let t=xe({schemaVersion:"openpond.harnessRefinementCandidateLifecycleReceipt.v1",id:`candidate-lifecycle-${D({candidate:z(e.candidate),review:z(e.review),decision:e.decision}).slice(0,24)}`,candidateId:e.candidate.id,decision:e.decision,beforeCandidate:e.before?z(e.before):null,afterCandidate:z(e.candidate),review:z(e.review),addedEvidence:e.addedEvidence,removedEvidence:e.removedEvidence,reason:e.reason,createdAt:e.now});return{candidate:e.candidate,receipt:t}}o(ie,"transition");function oe(e,t,s){return e.flatMap(r=>{let i=t.get(r.sourceRef);return!i||i.state!=="authorized"?(s.push(r),[]):[{...r,sourcePolicy:i}]})}o(oe,"reauthorizedEvidence");function ct(e){return[...new Map(e.map(t=>[t.occurrenceKey,t])).values()].sort((t,s)=>t.occurredAt.localeCompare(s.occurredAt)||t.occurrenceKey.localeCompare(s.occurrenceKey))}o(ct,"uniqueEvidence");function V(e){return[...new Map(e.map(t=>[`${t.id}:${t.contentHash}`,t])).values()]}o(V,"uniqueRefs");function z(e){return{id:e.id,contentHash:e.contentHash}}o(z,"artifactRef");function we(e){let{contentHash:t,...s}=e;return s}o(we,"withoutHash");var dt={memory:!0,prompt:!0,skill:!0,agent:!1};async function je(e){if(e.candidate.status!=="confirmed")return null;if(e.review.classification!=="harness_maintenance"||e.review.contentHash!==e.candidate.sourceReviews.at(-1)?.contentHash)throw new Error("Cross-run continuation requires the candidate's confirming Harness review.");let t=await e.store.getHarnessWorkspace(e.candidate.workspaceRef),s=t?.currentChannel.release??null;if(!t||t.location!=="local"||!s)throw new Error("Cross-run continuation requires an active Local Harness release.");let r=Pe({workspaceRef:t.id,candidateFingerprint:e.candidate.fingerprint,admittedHarness:s}),i=(e.now??(()=>new Date().toISOString()))(),u=qe({schemaVersion:"openpond.harnessCrossRunRefinementRequest.v1",id:`cross-run-refinement-${r.slice(0,24)}`,ownerScope:t.ownerScope,workspaceRef:t.id,candidate:ce(e.candidate),candidateFingerprint:e.candidate.fingerprint,review:ce(e.review),admittedHarness:s,evidence:e.candidate.occurrences,capabilities:dt,deduplicationKey:r,createdAt:i}),c=await e.store.saveHarnessCrossRunRefinementRequestIfAbsent({workspaceId:t.id,request:u});if(!c.created)return null;let d=await ut(e.store,t.id,c.request.evidence);if(d.length===0)throw new Error("Confirmed cross-run candidate has no verifiable source observations.");let m=`cross-run-${c.request.deduplicationKey.slice(0,24)}`,H=await Le({store:e.store,runId:m,workspace:t,harnessRelease:c.request.admittedHarness,admittedAt:c.request.createdAt}),b=lt({request:c.request,overlay:H,observations:d});await e.store.saveHarnessImprovementArtifact(t.id,"trigger_decision",b);let l=await Be({store:e.store,storeDir:e.storeDir,trigger:b,additionalEvidence:{reviewScope:"cross_run_candidate",request:c.request,candidate:e.candidate,review:e.review},reviewScope:"cross_run_candidate",stream:e.stream,signal:e.signal,now:e.now}),a=e.candidate;return l.applyReceipt?.decision==="applied"&&(a=await Ue({store:e.store,candidate:a,review:e.review,relatedHarnessRelease:l.workspace.currentChannel.release??null,reason:"The confirmed candidate produced a validated applied Harness change and now awaits independent outcome evidence.",now:(e.now??(()=>new Date().toISOString()))()})),{candidate:a,worker:l}}o(je,"continueConfirmedLocalHarnessCandidate");function lt(e){let t=e.observations.slice(0,100).map(ce);return Ie({schemaVersion:"openpond.refinementTriggerDecision.v1",id:`cross-run-trigger-${e.request.deduplicationKey.slice(0,24)}`,runRef:e.overlay.runId,turnId:`candidate-${e.request.candidate.id}`,harnessRelease:e.request.admittedHarness,overlay:{id:e.overlay.id,revision:e.overlay.revision,contentHash:e.overlay.contentHash},observations:t,decision:"queue_refiner",deterministicRoute:null,suggestedRoutes:[],reason:"A confirmed authorized cross-Work candidate is ready for one bounded Refiner continuation.",deduplicationKey:e.request.deduplicationKey,policy:{schemaVersion:"openpond.refinementTriggerPolicy.v1",maxEstimatedCostUsd:.05,cooldownMs:0,maxPendingPlans:1,maxEvidenceEvents:100,maxProposalEdits:4,maxProposalBytes:2e4},estimatedMaxCostUsd:.05,pendingPlanCount:0,boundary:{kind:"turn_completed",eventSequence:0,occurredAt:e.request.createdAt},cooldownUntil:null,createdAt:e.request.createdAt,metadata:{origin:"cross_run_candidate",crossRunRefinementRequest:ce(e.request),candidate:e.request.candidate}})}o(lt,"createCrossRunTrigger");async function ut(e,t,s){let[r,i,u,c]=await Promise.all([e.listHarnessImprovementArtifacts(t,"observation",1e3),e.listHarnessImprovementArtifacts(t,"trigger_decision",1e3),e.listHarnessImprovementArtifacts(t,"route_decision",1e3),e.listHarnessImprovementArtifacts(t,"refiner_outcome",1e3)]),d=new Map(r.map(a=>[B(a),a])),m=new Map(i.map(a=>[B(a),a])),H=new Map(u.map(a=>[B(a),a])),b=new Map(c.map(a=>[B(a),a])),l=new Map;for(let a of s){if(a.kind==="observation"){let R=d.get(B(a.evidence));R&&l.set(B(R),R);continue}let p=a.kind==="route_decision"?H.get(B(a.evidence))?.trigger:a.kind==="refiner_outcome"?b.get(B(a.evidence))?.trigger:null,f=p?m.get(B(p)):null;for(let R of f?.observations??[]){let A=d.get(B(R));A&&l.set(B(A),A)}}return[...l.values()].sort((a,p)=>a.createdAt.localeCompare(p.createdAt)||a.id.localeCompare(p.id))}o(ut,"resolveCandidateObservations");function ce(e){return{id:e.id,contentHash:e.contentHash}}o(ce,"artifactRef");function B(e){return`${e.id}:${e.contentHash}`}o(B,"artifactKey");var mt=C.object({sourceRef:C.string().trim().min(1),policy:C.object({id:C.string().trim().min(1),contentHash:C.string().regex(/^[a-f0-9]{64}$/)}).strict(),state:C.enum(["authorized","revoked","deleted","expired"]),checkedAt:C.string().datetime()}).strict(),vt=C.object({previousWatermark:Se.nullable().optional(),sourcePolicies:C.array(mt).max(1e4).default([]),limits:C.object({maxEvidence:C.number().int().min(1).max(1e3).default(200),maxTokens:C.number().int().min(1).max(1e6).default(5e4),maxDurationMs:C.number().int().min(1).max(3e5).default(24e4),maxEstimatedCostUsd:C.number().finite().nonnegative().default(.1),maxPrecedingTurns:C.number().int().min(0).max(10).default(3),maxConversationChars:C.number().int().min(0).max(1e5).default(12e3),maxContextEvents:C.number().int().min(1).max(100).default(12),maxArtifactDiagnostics:C.number().int().min(0).max(100).default(20),maxLaterResults:C.number().int().min(0).max(50).default(8)}).strict().default({maxEvidence:200,maxTokens:5e4,maxDurationMs:24e4,maxEstimatedCostUsd:.1,maxPrecedingTurns:3,maxConversationChars:12e3,maxContextEvents:12,maxArtifactDiagnostics:20,maxLaterResults:8})}).strict(),de=new WeakMap;function Qe(e){let t=de.get(e.store);if(t)return t;let s=pt(e).finally(()=>{de.get(e.store)===s&&de.delete(e.store)});return de.set(e.store,s),s}o(Qe,"reviewSelectedLocalHarnessEvaluation");async function pt(e){let t=vt.parse(e.request??{}),s=performance.now(),r=await ae(e.store);if(!r)throw new Error("No Local Harness release is selected for evaluation review.");let i=await e.store.getHarnessWorkspace(r.workspaceId);if(!i)throw new Error(`Selected Harness workspace ${r.workspaceId} does not exist.`);let[u,c,d,m,H,b,l,a]=await Promise.all([e.store.listHarnessImprovementArtifacts(i.id,"evaluation_review",1e3),e.store.listHarnessImprovementArtifacts(i.id,"route_decision",1e3),e.store.listHarnessImprovementArtifacts(i.id,"trigger_decision",1e3),e.store.listHarnessImprovementArtifacts(i.id,"observation",1e3),e.store.listHarnessImprovementArtifacts(i.id,"apply_receipt",1e3),e.store.listHarnessImprovementArtifacts(i.id,"refiner_outcome",1e3),e.store.listHarnessAdvanceReceipts(i.id),e.store.listHarnessRefinementCandidates(i.id)]),p=u[0]??null,f=t.previousWatermark??p?.nextWatermark??null,R=c,A=d,w=m,T=H,M=b,F=[...R,...w,...M];if(t.previousWatermark===void 0&&p&&!F.some(n=>n.createdAt>p.nextWatermark.throughCreatedAt)){let n=(e.now??(()=>new Date().toISOString()))(),y=await fe({store:e.store,workspace:i,review:p,sourcePolicies:new Map(t.sourcePolicies.map(k=>[k.sourceRef,J(k)])),now:n,upsertReviewClaim:!1});return await Ke({...e,candidate:y.activeCandidate,review:p}),p}let $=new Map(A.map(n=>[P(n),n])),Y=new Set(A.filter(n=>n.metadata.origin==="cross_run_candidate").map(P)),W=new Map(w.map(n=>[P(n),n])),O=new Map(t.sourcePolicies.map(n=>[n.sourceRef,n])),g=ze({store:e.store,workspace:i,sourcePolicies:O,observations:w,triggers:A,outcomes:M,applyReceipts:T,advanceReceipts:l,limits:{maxPrecedingTurns:t.limits.maxPrecedingTurns,maxConversationChars:t.limits.maxConversationChars,maxContextEvents:t.limits.maxContextEvents,maxArtifactDiagnostics:t.limits.maxArtifactDiagnostics,maxLaterResults:t.limits.maxLaterResults}}),v=[],_=[],I=new Set,E=new Set(R.map(n=>P(n.trigger)));for(let n of R){let y=$.get(P(n.trigger));if(!y){v.push({evidence:q(n),sourcePolicy:null,reason:"unverified"});continue}if(Y.has(P(y))){v.push({evidence:q(n),sourcePolicy:null,reason:"resolved"});continue}let k=y.observations.map(j=>W.get(P(j))).filter(j=>!!j);for(let j of k)I.add(P(j));_.push({id:`route_decision:${n.id}`,artifact:n,kind:"route_decision",sourceRef:k[0]?.runRef??y.runRef,payload:{routeDecision:n,trigger:y,observations:k,turnContexts:await Ve(k,g)}})}for(let n of M){if(E.has(P(n.trigger)))continue;let y=$.get(P(n.trigger));if(!y){v.push({evidence:q(n),sourcePolicy:null,reason:"unverified"});continue}if(Y.has(P(y))){v.push({evidence:q(n),sourcePolicy:null,reason:"resolved"});continue}let k=y.observations.map(K=>W.get(P(K))).filter(K=>!!K);for(let K of k)I.add(P(K));let j=n.proposal?T.filter(K=>P(K.proposal)===P(n.proposal)):[];_.push({id:`refiner_outcome:${n.id}`,artifact:n,kind:"refiner_outcome",sourceRef:k[0]?.runRef??y.runRef,payload:{outcome:n,trigger:y,observations:k,turnContexts:await Ve(k,g),applyReceipts:j}})}for(let n of w)I.has(P(n))||_.push({id:`observation:${n.id}`,artifact:n,kind:"observation",sourceRef:n.runRef,payload:{observation:n,turnContext:await g(n)}});let S=[],x=[],Z=0,ue=0;for(let n of _.slice().sort((y,k)=>y.artifact.createdAt.localeCompare(k.artifact.createdAt)||y.id.localeCompare(k.id))){if(performance.now()-s>=t.limits.maxDurationMs){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"budget"});continue}if(f&&n.artifact.createdAt<=f.throughCreatedAt){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"before_watermark"});continue}if(Z>=t.limits.maxEvidence){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"budget"});continue}Z+=1;let y=Math.ceil(JSON.stringify(n.payload).length/4);if(ue+y>t.limits.maxTokens){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"budget"});continue}ue+=y,x.push(n.artifact);let k=O.get(n.sourceRef);if(!k||k.state!=="authorized"){v.push({evidence:q(n.artifact),sourcePolicy:k?J(k):null,reason:k&&k.state!=="authorized"?k.state:"unverified"});continue}S.push(n)}let h={schemaVersion:"openpond.harnessEvaluationReviewModelDecision.v2",decision:"no_action",reason:"No authorized unresolved evidence qualified for model review.",ignoredEvidence:[]},G={promptTokens:0,completionTokens:0,totalTokens:0},se={selectedIds:null};if(S.length>0&&t.limits.maxEstimatedCostUsd===0){for(let n of S)v.push({evidence:q(n.artifact),sourcePolicy:J(O.get(n.sourceRef)),reason:"budget"});h={schemaVersion:"openpond.harnessEvaluationReviewModelDecision.v2",decision:"no_action",reason:"Continuous review is disabled by a zero model-cost ceiling.",ignoredEvidence:S.map(n=>({id:n.id,reason:"The configured model-cost ceiling is zero."}))}}else if(S.length>0){if(!e.stream)throw new Error("Harness continuous review requires a model stream.");h=await Ce({evidence:S.map(n=>({id:n.id,evidence:q(n.artifact),kind:n.kind,sourceRef:n.sourceRef,occurredAt:n.artifact.createdAt,payload:n.payload})),harnessRelease:q(r.harnessRelease),previousReviews:u.slice(0,20),candidates:a.map(n=>({id:n.id,fingerprint:n.fingerprint,statement:n.statement,status:n.status,occurrences:n.occurrences,relatedHarnessReleases:n.relatedHarnessReleases,resolution:n.resolution})),stream:o(async function*(n){let y=null;for await(let k of e.stream(n))k.usage&&(y=k.usage),yield k;y&&(G={promptTokens:G.promptTokens+y.promptTokens,completionTokens:G.completionTokens+y.completionTokens,totalTokens:G.totalTokens+y.totalTokens})},"stream"),signal:e.signal??new AbortController().signal,timeoutMs:t.limits.maxDurationMs,onNavigation:o(n=>{se.selectedIds=new Set(n.selectedEvidenceIds)},"onNavigation")})}let He=se.selectedIds?S.filter(n=>!se.selectedIds.has(n.id)):[];for(let n of He)v.push({evidence:q(n.artifact),sourcePolicy:J(O.get(n.sourceRef)),reason:"budget"});let me=h.decision==="review"||h.decision==="resolve_candidate"?h.selectedEvidenceIds.map(n=>{let y=S.find(k=>k.id===n);if(!y)throw new Error(`Review selected unavailable evidence ${n}.`);return y}):[],ve=h.decision==="review"?h.classification:"no_action",pe=me.map(n=>ft(n,O.get(n.sourceRef))),re=(e.now??(()=>new Date().toISOString()))(),Xe=new Set(He.map(n=>P(n.artifact))),he=x.filter(n=>!Xe.has(P(n))),ye=he.map(n=>n.createdAt).sort().at(-1),ke=ye?Ne(f?.throughCreatedAt,ye):Ne(f?.throughCreatedAt,re),Ee=D({previousCursor:f?.cursor??null,throughCreatedAt:ke,examined:he.map(q)}),et=`evaluation-review-${D({workspaceId:i.id,harnessRelease:r.harnessRelease,previousWatermark:f,cursor:Ee}).slice(0,24)}`,X=Ae({schemaVersion:"openpond.harnessEvaluationReviewReceipt.v1",id:et,ownerScope:i.ownerScope,workspaceRef:i.id,harnessRelease:q(r.harnessRelease),previousWatermark:f,nextWatermark:{cursor:Ee,throughCreatedAt:ke},selectedEvidence:pe,excludedEvidence:v,claim:h.decision==="review"?{fingerprint:D({schemaVersion:"openpond.harnessRefinementCandidateFingerprint.v1",classification:ve,triageLayer:h.triageLayer,recurrenceFamily:Rt(h.recurrenceFamily)}),recurrenceFamily:h.recurrenceFamily,statement:h.statement,...h.classification==="harness_maintenance"?{candidateDisposition:h.candidateDisposition}:{},independentOccurrences:new Set(me.map(n=>n.sourceRef)).size,unresolvedOccurrences:new Set(me.map(n=>n.sourceRef)).size}:null,classification:ve,triage:h.decision==="review"?[{layer:h.triageLayer,status:"unresolved",reason:h.reason,evidenceRefs:pe.map(n=>n.evidence)}]:[],reason:h.reason,nextAuthority:wt(ve),maxEstimatedCostUsd:t.limits.maxEstimatedCostUsd,tasksetProposal:null,evaluation:null,trainingQualification:null,policyVersion:"public-model-driven-harness-review-v1",createdAt:re,metadata:{examinedEvidence:Z,fullyReviewedEvidence:se.selectedIds?.size??S.length,estimatedTokens:ue,elapsedMs:performance.now()-s,explicitInvocation:!0,modelDecision:h.decision,modelConfidence:h.decision==="review"||h.decision==="resolve_candidate"?h.confidence:null,counterevidence:h.decision==="review"?h.counterevidence:null,expectedOutcome:h.decision==="review"?h.expectedOutcome:null,ignoredEvidence:h.ignoredEvidence,modelUsage:G}});await e.store.saveHarnessImprovementArtifact(i.id,"evaluation_review",X);let be=await fe({store:e.store,workspace:i,review:X,sourcePolicies:new Map(t.sourcePolicies.map(n=>[n.sourceRef,J(n)])),now:re});if(h.decision==="resolve_candidate"){let n=be.candidates.find(y=>y.id===h.candidateId&&y.fingerprint===h.candidateFingerprint);if(!n)throw new Error("Later-success decision referenced an unavailable candidate.");await Fe({store:e.store,candidate:n,review:X,evidence:pe,reason:h.reason,now:re})}return await Ke({...e,candidate:be.activeCandidate,review:X}),X}o(pt,"runSelectedLocalHarnessEvaluation");async function Ke(e){!e.continuation||e.candidate?.status!=="confirmed"||await je({store:e.store,storeDir:e.continuation.storeDir,candidate:e.candidate,review:e.review,stream:e.continuation.stream,signal:e.signal??new AbortController().signal,now:e.now})}o(Ke,"continueCandidateIfEnabled");function q(e){return{id:e.id,contentHash:e.contentHash}}o(q,"artifactRef");function P(e){return`${e.id}:${e.contentHash}`}o(P,"artifactKey");function J(e){return{policy:e.policy,state:e.state,checkedAt:e.checkedAt}}o(J,"sourcePolicyRef");function ft(e,t){return{evidence:q(e.artifact),kind:e.kind,sourceRef:e.sourceRef,sourcePolicy:J(t),occurrenceKey:D({evidence:q(e.artifact),sourceRef:e.sourceRef}),occurredAt:e.artifact.createdAt}}o(ft,"evidenceRef");function wt(e){return e==="runtime"?"runtime_service":e==="product"?"product_team":e==="taskset"||e==="harness_maintenance"?"human_review":e==="model_improvement"?"training_system":"none"}o(wt,"nextAuthority");function Ne(...e){return e.filter(t=>!!t).sort().at(-1)}o(Ne,"maxTimestamp");function Rt(e){return e.trim().toLocaleLowerCase("en-US").replace(/\s+/g," ")}o(Rt,"normalizeRecurrenceFamily");async function Ve(e,t){let s=new Map;for(let r of e)s.set(`${r.runRef}:${r.turnId}`,r);return Promise.all([...s.values()].map(t))}o(Ve,"uniqueTurnContexts");var Je="local-personal-work-v1";async function le(e){let t=await ae(e.store);if(!t||t.workspaceId!==e.workspaceId)throw new Error("Evaluation review requires the selected Personal Local Harness.");let s=await e.store.getHarnessWorkspace(e.workspaceId);if(!s||s.ownerScope.kind!=="personal"||s.location!=="local")throw new Error("Evaluation review requires the selected Personal Local Harness.");let[r,i]=await Promise.all([e.store.listHarnessImprovementArtifacts(e.workspaceId,"observation",1e4),e.store.listHarnessImprovementArtifacts(e.workspaceId,"trigger_decision",1e4)]),u=new Set([...r.map(m=>m.runRef),...i.map(m=>m.runRef)]),c=(e.now??(()=>new Date().toISOString()))(),d=await Promise.all([...u].sort().map(async m=>{let H=await e.store.getSession(m);return{sourceRef:m,policy:{id:`source-policy-${D({workspaceId:e.workspaceId,sourceRef:m,policyVersion:Je}).slice(0,24)}`,contentHash:D({workspaceId:e.workspaceId,sourceRef:m,policyVersion:Je})},state:H?"authorized":"deleted",checkedAt:c}}));return Qe({store:e.store,request:{sourcePolicies:d,limits:{maxEvidence:200,maxTokens:5e4,maxDurationMs:24e4,maxEstimatedCostUsd:e.maxEstimatedCostUsd}},stream:e.stream,signal:e.signal,now:e.now,continuation:e.stream?{storeDir:e.storeDir,stream:e.stream}:void 0})}o(le,"reviewSelectedLocalHarnessEvaluationFromHost");var gt=15e3;function Re(e,t){if(e==="manual")return null;let s=new Date(t);return s.setUTCDate(s.getUTCDate()+(e==="daily"?1:7)),s.toISOString()}o(Re,"nextHarnessEvaluationReviewRunAt");function us(e){let t=null,s=null,r=e.now??(()=>new Date().toISOString());async function i(){return s||(s=(async()=>{let u=await e.store.getSelectedHarnessWorkspace({ownerKind:"personal",ownerId:te});if(!u)return null;let c=await e.store.getHarnessEvaluationReviewSettings(u.id),d=r();if(!c.enabled&&!c.activityEnabled)return null;let m=c.enabled&&c.cadence!=="manual"&&!!c.nextRunAt&&c.nextRunAt<=d,H=c.activityEnabled&&await Ht({store:e.store,workspaceId:u.id,batchSize:c.activityBatchSize});if(!m&&!H)return null;let b={...c,nextRunAt:m?Re(c.cadence,d):c.nextRunAt,lastRunAt:d,lastError:null,updatedAt:d};await e.store.setHarnessEvaluationReviewSettings({workspaceId:u.id,settings:b});try{let l=await le({store:e.store,storeDir:e.storeDir,workspaceId:u.id,maxEstimatedCostUsd:c.maxEstimatedCostUsd,stream:e.stream,now:r});return await e.store.setHarnessEvaluationReviewSettings({workspaceId:u.id,settings:{...b,lastResult:{id:l.id,contentHash:l.contentHash,classification:l.classification},updatedAt:r()}}),e.logger?.info("Harness evaluation review schedule completed",{workspaceId:u.id,reviewId:l.id,classification:l.classification}),l}catch(l){let a=l instanceof Error?l.message:String(l);return await e.store.setHarnessEvaluationReviewSettings({workspaceId:u.id,settings:{...b,lastError:a,updatedAt:r()}}),e.logger?.warn("Harness evaluation review schedule failed",{workspaceId:u.id,error:a}),null}})().finally(()=>{s=null}),s)}return o(i,"runDueNow"),{start(){t||(t=setInterval(()=>{e.isClosing()||i()},e.tickMs??gt),t.unref?.(),i())},async stop(){t&&clearInterval(t),t=null,await s},runDueNow:i}}o(us,"createLocalHarnessEvaluationReviewScheduler");async function Ht(e){let[t,s]=await Promise.all([e.store.listHarnessImprovementArtifacts(e.workspaceId,"refiner_outcome",e.batchSize),e.store.listHarnessImprovementArtifacts(e.workspaceId,"evaluation_review",1)]),r=s[0]?.nextWatermark.throughCreatedAt??null;return t.filter(i=>!r||i.createdAt>r).length>=e.batchSize}o(Ht,"hasEventDrivenReviewBatch");import ge from"node:path";function Us(e){return{harnessHistoryPayload:o(()=>U(e.store),"harnessHistoryPayload"),updateHarnessBackgroundReviewPayload:o(t=>It({store:e.store,request:kt(t)}),"updateHarnessBackgroundReviewPayload"),reviewHarnessEvaluationPayload:o(t=>At({store:e.store,storeDir:e.storeDir,stream:e.evaluationReviewStream,request:ht(t)}),"reviewHarnessEvaluationPayload"),updateHarnessEvaluationReviewSchedulePayload:o(t=>Ct({store:e.store,request:yt(t)}),"updateHarnessEvaluationReviewSchedulePayload"),harnessDiffPayload:o(t=>qt({...e,request:Et(t)}),"harnessDiffPayload"),rollbackHarnessPayload:o(t=>_t({...e,request:bt(t)}),"rollbackHarnessPayload"),reviewHarnessProposalPayload:o(t=>Dt({...e,request:St(t)}),"reviewHarnessProposalPayload")}}o(Us,"createLocalHarnessSettingsRoutePayloads");function ht(e){if(!e||typeof e!="object")throw new Error("Harness evaluation review requires a workspace.");let t=e;if(typeof t.workspaceId!="string")throw new Error("Harness evaluation review requires a workspace.");if(t.maxEstimatedCostUsd!==void 0&&(typeof t.maxEstimatedCostUsd!="number"||!Number.isFinite(t.maxEstimatedCostUsd)||t.maxEstimatedCostUsd<0))throw new Error("Harness evaluation review cost must be a non-negative number.");return{workspaceId:t.workspaceId,maxEstimatedCostUsd:t.maxEstimatedCostUsd}}o(ht,"parseHarnessEvaluationReviewRequest");function yt(e){if(!e||typeof e!="object")throw new Error("Harness evaluation review schedule requires a workspace and cadence.");let t=e;if(typeof t.workspaceId!="string"||typeof t.enabled!="boolean"||typeof t.activityEnabled!="boolean"||typeof t.activityBatchSize!="number"||!Number.isInteger(t.activityBatchSize)||t.activityBatchSize<1||t.activityBatchSize>100||t.cadence!=="manual"&&t.cadence!=="daily"&&t.cadence!=="weekly"||typeof t.maxEstimatedCostUsd!="number"||!Number.isFinite(t.maxEstimatedCostUsd)||t.maxEstimatedCostUsd<0)throw new Error("Harness evaluation review schedule requires a valid workspace, cadence, and cost limit.");return{workspaceId:t.workspaceId,enabled:t.enabled,activityEnabled:t.activityEnabled,activityBatchSize:t.activityBatchSize,cadence:t.cadence,maxEstimatedCostUsd:t.maxEstimatedCostUsd}}o(yt,"parseHarnessEvaluationReviewScheduleRequest");function kt(e){if(!e||typeof e!="object")throw new Error("Harness background review requires a workspace and enabled state.");let t=e;if(typeof t.workspaceId!="string"||typeof t.enabled!="boolean")throw new Error("Harness background review requires a workspace and enabled state.");return{workspaceId:t.workspaceId,enabled:t.enabled}}o(kt,"parseHarnessBackgroundReviewRequest");function Ye(e,t){if(!e||typeof e!="object")throw new Error(`${t} requires an id and content hash.`);let s=e;if(typeof s.id!="string"||typeof s.contentHash!="string")throw new Error(`${t} requires an id and content hash.`);return{id:s.id,contentHash:s.contentHash}}o(Ye,"parseHarnessReleaseRef");function Et(e){if(!e||typeof e!="object")throw new Error("Harness release diff requires a workspace and target release.");let t=e;if(typeof t.workspaceId!="string")throw new Error("Harness release diff requires a workspace and target release.");return{workspaceId:t.workspaceId,baseRelease:t.baseRelease===null?null:Ye(t.baseRelease,"Harness base release"),targetRelease:Ye(t.targetRelease,"Harness target release")}}o(Et,"parseHarnessReleaseDiffRequest");function bt(e){if(!e||typeof e!="object")throw new Error("Harness rollback requires a workspace and target release.");let t=e,s=t.targetRelease;if(typeof t.workspaceId!="string"||!s||typeof s!="object")throw new Error("Harness rollback requires a workspace and target release.");let r=s;if(typeof r.id!="string"||typeof r.contentHash!="string")throw new Error("Harness rollback target requires an id and content hash.");return{workspaceId:t.workspaceId,targetRelease:{id:r.id,contentHash:r.contentHash}}}o(bt,"parseHarnessRollbackRequest");function St(e){if(!e||typeof e!="object")throw new Error("Harness review requires a workspace, proposal, and decision.");let t=e,s=t.proposal;if(typeof t.workspaceId!="string"||t.decision!=="approve"&&t.decision!=="decline"||!s||typeof s!="object")throw new Error("Harness review requires a workspace, proposal, and decision.");let r=s;if(typeof r.id!="string"||typeof r.contentHash!="string")throw new Error("Harness proposal review requires an id and content hash.");return{workspaceId:t.workspaceId,proposal:{id:r.id,contentHash:r.contentHash},decision:t.decision}}o(St,"parseHarnessProposalReviewRequest");async function U(e){let t=await e.getSelectedHarnessWorkspace({ownerKind:"personal",ownerId:te});if(!t)return{workspace:null,backgroundReview:{enabled:!0,updatedAt:null},evaluationReviewSchedule:{enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:0,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},releases:[],changes:[],routes:[],evaluationReviews:[],refinementCandidates:[],modelImprovementQualifications:[],pendingReviews:[],memories:[]};let[s,r,i,u,c,d,m,H,b,l,a,p,f]=await Promise.all([e.getHarnessBackgroundReviewSettings(t.id),e.getHarnessEvaluationReviewSettings(t.id),e.listHarnessReleaseRecords(t.id),e.listHarnessAdvanceReceipts(t.id),e.listHarnessImprovementArtifacts(t.id,"proposal",1e3),e.listHarnessImprovementArtifacts(t.id,"targeted_validation",1e3),e.listHarnessImprovementArtifacts(t.id,"route_decision",1e3),e.listHarnessImprovementArtifacts(t.id,"evaluation_review",1e3),e.listHarnessRefinementCandidates(t.id),e.listHarnessImprovementArtifacts(t.id,"training_qualification",1e3),e.listHarnessImprovementArtifacts(t.id,"apply_receipt",1e3),e.listHarnessImprovementArtifacts(t.id,"refiner_outcome",1e3),e.listHarnessImprovementArtifacts(t.id,"trigger_decision",1e3)]),R=c,A=d,w=m,T=a,M=p,F=f,$=u.slice().reverse().map(g=>{let v=g.proposal?R.find(E=>E.id===g.proposal.id&&E.contentHash===g.proposal.contentHash)??null:null,_=v?M.find(E=>E.proposal?.id===v.id&&E.proposal.contentHash===v.contentHash)??null:null,I=_?F.find(E=>E.id===_.trigger.id&&E.contentHash===_.trigger.contentHash)??null:null;return{receipt:g,proposal:v,validations:v?A.filter(E=>E.proposal.id===v.id&&E.proposal.contentHash===v.contentHash):[],routeDecision:v?w.find(E=>E.metadata.proposalId===v.id)??null:null,applyReceipt:v?T.find(E=>E.proposal.id===v.id&&E.proposal.contentHash===v.contentHash)??null:null,outcome:_,trigger:I}}),Y=new Set($.flatMap(g=>g.routeDecision?[g.routeDecision.id]:[])),W=w.filter(g=>!Y.has(g.id)).map(g=>{let v=F.find(I=>I.id===g.trigger.id&&I.contentHash===g.trigger.contentHash)??null,_=M.find(I=>I.trigger.id===g.trigger.id&&I.trigger.contentHash===g.trigger.contentHash)??null;return{decision:g,trigger:v,outcome:_}}),O=R.reduce((g,v)=>{let I=T.filter(x=>x.proposal.id===v.id&&x.proposal.contentHash===v.contentHash).sort((x,Z)=>Z.createdAt.localeCompare(x.createdAt))[0]??null;if(!I||I.decision!=="retained")return g;let E=M.find(x=>x.proposal?.id===v.id&&x.proposal.contentHash===v.contentHash)??null,S=E?F.find(x=>x.id===E.trigger.id&&x.contentHash===E.trigger.contentHash)??null:null;return g.push({proposal:v,validations:A.filter(x=>x.proposal.id===v.id&&x.proposal.contentHash===v.contentHash),applyReceipt:I,outcome:E,trigger:S}),g},[]);return{workspace:t,backgroundReview:s,evaluationReviewSchedule:r,releases:i.map(g=>({id:g.harnessRelease.id,contentHash:g.harnessRelease.contentHash,sourceRevision:g.sourceRevision,createdAt:g.createdAt,current:t.currentChannel.release?.contentHash===g.harnessRelease.contentHash,files:g.harnessRelease.files.map(v=>({id:v.id,path:v.path,contentHash:v.contentHash,sizeBytes:v.sizeBytes,mediaType:v.mediaType}))})),changes:$,routes:W,evaluationReviews:H,refinementCandidates:b,modelImprovementQualifications:l,pendingReviews:O,memories:await e.listHarnessMemories(t.id)}}o(U,"localHarnessHistoryPayload");async function At(e){let t=await e.store.getHarnessEvaluationReviewSettings(e.request.workspaceId),s=await le({store:e.store,storeDir:e.storeDir,workspaceId:e.request.workspaceId,maxEstimatedCostUsd:e.request.maxEstimatedCostUsd??t.maxEstimatedCostUsd,stream:e.stream}),r=new Date().toISOString();return await e.store.setHarnessEvaluationReviewSettings({workspaceId:e.request.workspaceId,settings:{...t,lastRunAt:r,lastResult:{id:s.id,contentHash:s.contentHash,classification:s.classification},lastError:null,updatedAt:r}}),{receipt:s,history:await U(e.store)}}o(At,"reviewLocalHarnessEvaluationFromSettings");async function Ct(e){let t=await e.store.getHarnessWorkspace(e.request.workspaceId);if(!t||t.ownerScope.kind!=="personal"||t.location!=="local")throw new Error("Evaluation review schedule requires the selected Personal Local Harness.");if((await e.store.getSelectedHarnessWorkspace({ownerKind:"personal",ownerId:te}))?.id!==t.id)throw new Error("Evaluation review schedule requires the selected Personal Local Harness.");let r=await e.store.getHarnessEvaluationReviewSettings(t.id),i=new Date().toISOString(),u=e.request.enabled&&e.request.cadence!=="manual";return await e.store.setHarnessEvaluationReviewSettings({workspaceId:t.id,settings:{...r,enabled:u,activityEnabled:e.request.activityEnabled,activityBatchSize:e.request.activityBatchSize,cadence:e.request.cadence,maxEstimatedCostUsd:e.request.maxEstimatedCostUsd,nextRunAt:u?Re(e.request.cadence,i):null,lastError:null,updatedAt:i}}),{history:await U(e.store)}}o(Ct,"updateLocalHarnessEvaluationReviewScheduleFromSettings");async function It(e){let t=await e.store.getHarnessWorkspace(e.request.workspaceId);if(!t||t.ownerScope.kind!=="personal"||t.location!=="local")throw new Error("Background review settings require the selected Personal Local Harness.");return await e.store.setHarnessBackgroundReviewSettings({workspaceId:t.id,enabled:e.request.enabled,updatedAt:new Date().toISOString()}),{history:await U(e.store)}}o(It,"updateLocalHarnessBackgroundReviewFromSettings");async function Ze(e){let t=await e.store.getHarnessReleaseRecord(e.release.contentHash);if(!t||t.workspaceId!==e.workspaceId||t.harnessRelease.id!==e.release.id||t.harnessRelease.contentHash!==e.release.contentHash)throw new Error(`${e.label} is unavailable or hash-mismatched.`);return t}o(Ze,"requireHarnessReleaseRecord");function Ge(e,t){let s=ge.resolve(e.bundlePath,"source"),r=ge.resolve(s,...t.split("/"));if(r!==s&&!r.startsWith(`${s}${ge.sep}`))throw new Error(`Harness release contains an unsafe file path: ${t}.`);return r}o(Ge,"releaseSourcePath");function xt(e){return e.patch.split(`
5
+ `).map(t=>t.startsWith("diff --git ")?`diff --git a/${e.filePath} b/${e.filePath}`:t.startsWith("--- ")?e.baseExists?`--- a/${e.filePath}`:"--- /dev/null":t.startsWith("+++ ")?e.targetExists?`+++ b/${e.filePath}`:"+++ /dev/null":t).join(`
6
+ `)}o(xt,"normalizeHarnessPatch");function Pt(e){let t=0,s=0;for(let r of e.split(`
7
+ `))r.startsWith("+++")||r.startsWith("---")||(r.startsWith("+")&&(t+=1),r.startsWith("-")&&(s+=1));return{additions:t,deletions:s}}o(Pt,"countHarnessPatchLines");async function qt(e){let t=await e.store.getHarnessWorkspace(e.request.workspaceId);if(!t||t.ownerScope.kind!=="personal")throw new Error("Harness release diff requires the selected Personal workspace.");let s=await Ze({store:e.store,workspaceId:t.id,release:e.request.targetRelease,label:"Harness target release"}),r=e.request.baseRelease?await Ze({store:e.store,workspaceId:t.id,release:e.request.baseRelease,label:"Harness base release"}):null,i=new Set(r?.harnessRelease.files.map(m=>m.path)??[]),u=new Set(s.harnessRelease.files.map(m=>m.path)),c=[...new Set([...i,...u])].sort((m,H)=>m.localeCompare(H)),d=[];for(let m of c){let H=i.has(m),b=u.has(m),l=r&&H?Ge(r,m):"/dev/null",a=b?Ge(s,m):"/dev/null",p=await Te("git",["diff","--no-index","--no-ext-diff","--unified=80","--",l,a],e.storeDir);if(p.code!==0&&p.code!==1)throw new Error(p.stderr.trim()||p.stdout.trim()||`Unable to diff ${m}.`);if(p.code===0)continue;let f=Oe(xt({patch:p.stdout||p.stderr,filePath:m,baseExists:H,targetExists:b})),R=Pt(f);d.push({path:m,status:H?b?"modified":"deleted":"added",additions:R.additions,deletions:R.deletions,patch:f,content:null})}return{baseRelease:e.request.baseRelease,targetRelease:e.request.targetRelease,filesChanged:d.length,additions:d.reduce((m,H)=>m+H.additions,0),deletions:d.reduce((m,H)=>m+H.deletions,0),files:d}}o(qt,"localHarnessReleaseDiffPayload");async function _t(e){let t=await e.store.getHarnessWorkspace(e.request.workspaceId);if(!t?.currentChannel.release)throw new Error("The selected Harness workspace has no current release to roll back.");if(t.ownerScope.kind!=="personal")throw new Error("Settings rollback currently requires a Personal Harness workspace.");return{receipt:(await De({store:e.store,storeDir:e.storeDir,workspaceId:t.id,targetRelease:e.request.targetRelease,rollbackOf:t.currentChannel.release,receiptId:`rollback-${D({workspaceId:t.id,current:t.currentChannel.release,target:e.request.targetRelease,channelRevision:t.currentChannel.revision}).slice(0,24)}`})).receipt,history:await U(e.store)}}o(_t,"rollbackLocalHarnessFromSettings");async function Dt(e){let t=await e.store.getHarnessWorkspace(e.request.workspaceId);if(!t||t.ownerScope.kind!=="personal")throw new Error("Harness proposal review requires the selected Personal workspace.");let r=(await e.store.listHarnessImprovementArtifacts(t.id,"proposal",1e3)).find(l=>l.id===e.request.proposal.id&&l.contentHash===e.request.proposal.contentHash);if(!r)throw new Error("Harness proposal is unavailable or hash-mismatched.");let u=(await e.store.listHarnessImprovementArtifacts(t.id,"run_overlay",1e3)).find(l=>l.id===r.overlay.id&&l.revision===r.overlay.revision&&l.contentHash===r.overlay.contentHash);if(!u)throw new Error("Harness proposal overlay is unavailable or hash-mismatched.");let c=(await e.store.listHarnessImprovementArtifacts(t.id,"targeted_validation",1e3)).filter(l=>l.proposal.id===r.id&&l.proposal.contentHash===r.contentHash),d=new Date().toISOString();if((await e.store.listHarnessImprovementArtifacts(t.id,"apply_receipt",1e3)).filter(l=>l.proposal.id===r.id&&l.proposal.contentHash===r.contentHash).sort((l,a)=>a.createdAt.localeCompare(l.createdAt))[0]?.decision!=="retained")throw new Error("Only a currently retained Harness proposal can be reviewed.");if(e.request.decision==="decline"){let l=ne({schemaVersion:"openpond.improvementApplyReceipt.v1",id:`review-decline-${D(e.request).slice(0,24)}`,proposal:e.request.proposal,beforeOverlay:r.overlay,afterOverlay:null,decision:"declined",boundary:{kind:"turn_paused",eventSequence:0,occurredAt:d},validationRefs:c.map(a=>({id:a.id,contentHash:a.contentHash})),outcomeEvidenceRefs:[],rollbackOf:null,createdAt:d,metadata:{authority:"human_review",reviewer:"local_user"}});return await e.store.saveHarnessImprovementArtifact(t.id,"apply_receipt",l),{receipt:l,history:await U(e.store)}}if(r.route==="memory"){if(!r.validationPlan.filter(R=>R.required).every(R=>c.some(A=>A.validationId===R.id&&A.status==="passed")))throw new Error("The memory proposal cannot be approved until required validations pass.");let a=r.edits.find(R=>R.route==="memory");if(!a)throw new Error("The memory proposal has no memory edit.");let p=Tt(a.target);await e.store.writeHarnessMemory({workspaceId:t.id,key:p,content:a.content,expectedRevision:Ot(r,p),sourceRunId:null,sourceProposal:{id:r.id,contentHash:r.contentHash},createdAt:d});let f=ne({schemaVersion:"openpond.improvementApplyReceipt.v1",id:`review-apply-${r.contentHash.slice(0,24)}`,proposal:e.request.proposal,beforeOverlay:r.overlay,afterOverlay:r.overlay,decision:"applied",boundary:{kind:"turn_paused",eventSequence:0,occurredAt:d},validationRefs:c.map(R=>({id:R.id,contentHash:R.contentHash})),outcomeEvidenceRefs:[],rollbackOf:null,createdAt:d,metadata:{authority:"human_review",reviewer:"local_user",externalState:"harness_memory"}});return await e.store.saveHarnessImprovementArtifact(t.id,"apply_receipt",f),{receipt:f,history:await U(e.store)}}let H=await _e({store:e.store,storeDir:e.storeDir,overlay:u,proposal:r,validations:c,receiptId:`review-advance-${r.contentHash.slice(0,24)}`,reviewAuthority:{reviewer:"local_user"},now:o(()=>d,"now")}),b=ne({schemaVersion:"openpond.improvementApplyReceipt.v1",id:`review-apply-${r.contentHash.slice(0,24)}`,proposal:e.request.proposal,beforeOverlay:r.overlay,afterOverlay:H.receipt.decision==="advanced"?r.overlay:null,decision:H.receipt.decision==="advanced"?"applied":"conflict",boundary:{kind:"turn_paused",eventSequence:0,occurredAt:d},validationRefs:c.map(l=>({id:l.id,contentHash:l.contentHash})),outcomeEvidenceRefs:[],rollbackOf:null,createdAt:d,metadata:{authority:"human_review",reviewer:"local_user",workspaceAdvanceReceipt:{id:H.receipt.id,contentHash:H.receipt.contentHash}}});return await e.store.saveHarnessImprovementArtifact(t.id,"apply_receipt",b),{receipt:H.receipt,history:await U(e.store)}}o(Dt,"reviewLocalHarnessProposalFromSettings");function Tt(e){let t=/^memory\/([a-z0-9][a-z0-9-]{0,119})$/.exec(e.replaceAll("\\","/"));if(!t)throw new Error(`Invalid Harness memory target: ${e}.`);return t[1]}o(Tt,"memoryKeyFromTarget");function Ot(e,t){let s=e.metadata.expectedMemory;if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Memory proposal is missing its expected revision snapshot.");let r=s;if(r.key!==t)throw new Error("Memory proposal expected revision targets a different key.");if(r.revision===null)return null;if(!Number.isInteger(r.revision)||Number(r.revision)<1)throw new Error("Memory proposal expected revision is invalid.");return Number(r.revision)}o(Ot,"expectedMemoryRevision");export{Qe as a,us as b,Us as c,U as d};
@@ -0,0 +1,5 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{g as M}from"./chunk-3Z47M3YY.js";import{a as G}from"./chunk-2QUCCP6Z.js";import{t as O,x as N}from"./chunk-QOTVNQDI.js";import{o as C,s as B,u as q}from"./chunk-WJ43MJ3F.js";import{ca as V}from"./chunk-25MBPJVY.js";import{Pb as F,Rb as L,v as x,z as A}from"./chunk-Y4OWBBDD.js";import{f as S}from"./chunk-FFRFSDBM.js";import{d as I,e as H,qa as b,ta as j}from"./chunk-ACYFMLWG.js";import{b as T,c as y,d as D,i as $,l as W,m as c}from"./chunk-KGNCKIFP.js";import{b as P}from"./chunk-ES2ISFJC.js";import{a as m}from"./chunk-FTQLQJQV.js";import U from"node:path";import{constants as J}from"node:fs";import{open as ee,realpath as Y}from"node:fs/promises";async function K(e){let n=e.attempt.profileNative,h=P.array($).max(16).parse(e.attempt.artifactRefs??[]);if(!h.length)return[];if(!n||!e.storeDir)throw new Error("The actual retained artifact owner is unavailable.");await e.authorize();let t=await e.events(n.turnId);if(c(t)!==n.traceHash||t.some(f=>f.sessionId!==n.sessionId||f.turnId!==n.turnId))throw new Error("The saved artifacts differ from their actual retained case trace.");let r=[],s=0;for(let f of h){let o=t.filter(u=>(u.action==="work_output_save"||u.action==="sandbox_save_output")&&u.status==="completed").flatMap(u=>{let R=P.object({outputRef:O}).passthrough().safeParse(u.data);return R.success?[R.data.outputRef]:[]}).filter(u=>`${n.sessionId}/${u.id}/${u.revision}/${u.title}`===f.id&&u.sourceTaskId===n.sessionId&&u.sourceTurnId===n.turnId&&u.sha256===f.contentHash&&u.sizeBytes===f.sizeBytes&&u.contentType===f.mediaType);if(o.length!==1)throw new Error("The selected artifact has no unique actual saved output.");let i=o[0];if(i.location.kind!=="local"&&(i.location.kind!=="managed"||!e.readManaged)||i.sizeBytes>N)throw new Error("The retained artifact has no supported local byte owner.");if((s+=i.sizeBytes)>2e7)throw new Error("The retained artifacts exceed their aggregate grading byte limit.");await e.authorize(),e.signal?.throwIfAborted();let l;if(i.location.kind==="managed")l=await e.readManaged(i,e.signal);else if(i.location.kind==="local"){let u=await Y(U.join(e.storeDir,"work","outputs")),R=await Y(i.location.path);if(!R.startsWith(`${u}${U.sep}`))throw new Error("The artifact escaped canonical output storage.");let v=await ee(R,J.O_RDONLY|J.O_NOFOLLOW);try{let w=await v.stat();if(!w.isFile()||w.size!==i.sizeBytes)throw new Error("The artifact bytes changed.");l=await v.readFile()}finally{await v.close()}}else throw new Error("The saved artifact has no admitted byte owner.");if(l.length!==i.sizeBytes||W(l)!==i.sha256)throw new Error("The artifact bytes differ from their sealed receipt.");await e.authorize(),r.push({reference:f,title:i.title,contentType:i.contentType,base64:l.toString("base64"),...i.contentType.startsWith("text/")||i.contentType==="application/json"?{text:new TextDecoder("utf8",{fatal:!0}).decode(l)}:{}})}return await e.authorize(),r}m(K,"readLocalProfileArtifacts");import te from"node:path";async function X(e,n){if(e.limits.maximumSpendUsd===null)return;let h=process.env.OPENPOND_API_KEY?.trim(),t=process.env.OPENPOND_OPCHAT_API_URL?.trim();if(!h||!t)throw new Error("Profile evaluation requires an admitted hosted spend ceiling.");let r=new URL(`${t.replace(/\/+$/,"")}/experiment-budget`);if(r.protocol!=="https:"||r.username||r.password||r.search||r.hash)throw new Error("Profile evaluation spend authority URL is invalid.");r.searchParams.set("runId",e.id),r.searchParams.set("manifestHash",e.contentHash);let s=await fetch(r,{headers:{Authorization:`Bearer ${h}`},signal:n});if(!s.ok)throw new Error("The exact Profile evaluation spend ceiling is unavailable.");let f=P.object({runId:P.string(),manifestHash:P.string(),maximumCostUsd:P.number().positive()}).strict().parse(await s.json());if(f.runId!==e.id||f.manifestHash!==e.contentHash||f.maximumCostUsd!==e.limits.maximumSpendUsd)throw new Error("Profile evaluation spend authority differs from its admitted manifest.")}m(X,"assertProfileEvaluationSpendAuthority");async function Q(e){e.signal?.throwIfAborted();let n,h,t=m(()=>{},"rejectCancellation"),r=new Promise((i,l)=>{t=l}),s=m((i,l)=>{h||(h=new Error(i),e.onInterrupt?.(l),e.interrupt?(n=e.interrupt(i),n.catch(()=>{})):t(h))},"cancel"),f=m(()=>s("Profile evaluation run cancelled.","cancelled"),"aborted"),o=setTimeout(()=>s(`Profile evaluation case exceeded its ${e.timeoutMs}ms timeout.`,"timed_out"),e.timeoutMs);e.signal?.addEventListener("abort",f,{once:!0});try{e.signal?.aborted&&f();let i=await Promise.race([e.send(),r]);if(n){let l=await n;if(l.status==="in_progress"||!l.completedAt)throw new Error("Profile evaluation cleanup remains unconfirmed.")}if(i.status==="in_progress"||!i.completedAt)throw new Error("Workflow evaluation turn did not settle.");return i}catch(i){if(n){let l=await n;if(l.status==="in_progress"||!l.completedAt)throw new Error("Profile evaluation cleanup remains unconfirmed.",{cause:i})}throw i}finally{clearTimeout(o),e.signal?.removeEventListener("abort",f)}}m(Q,"awaitProfileEvaluationTurn");function Z(e){let n=e.manifest.profileEvaluation,h=e.manifest.policy;if(!n||h.kind!=="model"||e.manifest.execution.kind!=="harness")throw new Error("Profile evaluation requires a released source and model policy.");if(n.profileId!==e.profileRef.profileId||n.profileId!==e.binding.profileId||n.sourceRevision!==e.binding.sourceRevision||n.harnessRelease.id!==e.binding.harnessRelease.id||n.harnessRelease.contentHash!==e.binding.harnessRelease.contentHash||(e.binding.schemaVersion==="openpond.profileWorkflowBinding.v1"?n.target.kind!=="workflow"||n.target.workflowId!==e.binding.workflowId:n.target.kind==="workflow"||c(n.target)!==c(e.binding.target)))throw new Error("Profile evaluation binding differs from its admitted source.");if(h.model.provider!==e.modelRef.providerId||h.model.model!==e.modelRef.modelId||h.configurationHash!==e.modelConfigurationHash)throw new Error("Workflow evaluation model differs from its admitted configuration.");return async t=>{if(c(t.source)!==c(n))throw new Error("Workflow evaluation case differs from its admitted Profile source.");t.signal?.throwIfAborted(),await(e.assertSpendAuthority??X)(e.manifest,t.signal);let r=!!(e.attachments?.length||e.requiredOutputs?.length),s=await e.createSession({...r?{experience:"work"}:{},provider:e.modelRef.providerId,modelRef:e.modelRef,currentProfile:e.profileRef,...e.binding.schemaVersion==="openpond.profileWorkflowBinding.v1"?{profileWorkflowBinding:e.binding}:{profileComponentBinding:e.binding},hiddenFromDefaultSidebar:!0,metadata:{profileEvaluationRun:{id:e.manifest.id,contentHash:e.manifest.contentHash},taskId:t.task.id,seed:t.seed,...r&&e.profileRef.source==="local"?{workspaceTarget:"local"}:{},...e.ownedSessionMetadata}}),f=[typeof t.task.input=="string"?t.task.input:JSON.stringify(t.task.input),...Object.keys(t.task.policyVisibleContext).length?[`Policy-visible task context:
3
+ ${JSON.stringify(t.task.policyVisibleContext)}`]:[]].join(`
4
+
5
+ `)||" ";await e.admitSession?.(s);try{let o=await Q({signal:t.signal,timeoutMs:e.manifest.limits.timeoutMs,onInterrupt:e.onInterrupt,...e.interruptSessionTurn?{interrupt:m(a=>e.interruptSessionTurn(s.id,a),"interrupt")}:{},send:m(()=>e.sendTurn(s.id,{prompt:f,...e.binding.schemaVersion==="openpond.profileWorkflowBinding.v1"?{workflowInput:{}}:e.binding.target.kind==="agent_action"?{workflowInput:t.task.input}:{},modelRef:e.modelRef,approvalPolicy:"on-request",...r?{sandbox:"workspace-write",codexPermissionMode:"default"}:{},...e.attachments?.length?{attachments:e.attachments}:{}}),"send")});if(o.status==="in_progress"||!o.completedAt)throw new Error("Workflow evaluation turn did not settle.");if(await e.validateTerminalTurn?.(s,o),!o.harnessSnapshot||o.harnessSnapshot.harnessRelease.id!==n.harnessRelease.id||o.harnessSnapshot.harnessRelease.contentHash!==n.harnessRelease.contentHash)throw new Error("Workflow evaluation turn executed a different Harness release.");if(!o.modelRef||c(o.modelRef)!==c(e.modelRef))throw new Error("Workflow evaluation turn executed a different model.");let i=await e.runtimeEventsForTurn(o.id),l=i.filter(a=>a.name==="workspace_action_result"&&(a.action==="sandbox_save_output"||a.action==="work_output_save")&&a.status==="completed"&&a.turnId===o.id).flatMap(a=>z(a.data)).filter(a=>a.sourceTaskId===s.id&&a.sourceTurnId===o.id&&a.location.kind!=="external"),R=(e.requiredOutputs??[]).flatMap(a=>{let E=[...l].reverse().find(k=>k.title===a.path&&k.contentType===a.mediaType&&(a.maxBytes===null||k.sizeBytes<=a.maxBytes));return E?[E]:[]}).map(a=>({id:`${s.id}/${a.id}/${a.revision}/${a.title}`,contentHash:a.sha256,mediaType:a.contentType,sizeBytes:a.sizeBytes})),v=-1;for(let a=i.length-1;a>=0;a-=1)if(i[a]?.name.endsWith(".delta")){v=a;break}let w=i.flatMap((a,E)=>a.name.endsWith(".delta")&&E!==v?[]:[a.id]);if(w.length+R.length>1e4)throw new Error("Profile evaluation produced more than 10,000 substantive evidence references.");let p=G(i,n.target.kind,o.status),g=Math.min(e.manifest.limits.maxOutputBytes,e.maximumOutputBytes??e.manifest.limits.maxOutputBytes);if(!Number.isSafeInteger(g)||g<1)throw new Error("Profile evaluation requires a positive bounded output limit.");let d=Buffer.byteLength(p,"utf8")>g;if(d&&!e.retainOutputLimitEvidence)throw new Error(`Profile evaluation case exceeded its ${g}-byte output limit.`);return d&&e.onOutputLimit?.(c(p)),{evidence:{output:{text:d?"":p},runtimeEventRefs:w,artifactRefs:R.map(a=>a.id),...d?{infrastructureError:`Profile evaluation case exceeded its ${g}-byte output limit.`}:o.status!=="completed"?{infrastructureError:o.error??`Workflow evaluation turn ${o.status}.`}:{}},traceHash:c(i),retainedEvidenceRef:{sessionId:s.id,turnId:o.id},artifactRefs:R,startedAt:o.startedAt,completedAt:o.completedAt,latencyMs:Math.max(0,Date.parse(o.completedAt)-Date.parse(o.startedAt)),costUsd:null,terminal:o.status==="completed"&&!d,failureClass:o.status==="completed"&&!d?null:o.status==="interrupted"?"cancelled":"infrastructure_failure"}}finally{await e.settleSession?.(s.id)}}}m(Z,"createProfileWorkflowEvaluationExecutor");function z(e,n=0){if(e==null||n>8)return[];let h=O.safeParse(e);return h.success?[h.data]:Array.isArray(e)?e.flatMap(t=>z(t,n+1)):typeof e!="object"?[]:Object.values(e).flatMap(t=>z(t,n+1))}m(z,"findFileOutputs");var ae=P.object({manifest:x,taskset:b,profileRef:C,binding:P.union([I,H]),modelRef:S,modelConfigurationHash:y,taskId:T,seed:P.string().trim().min(1).max(500)}).strict();function Be(e){return async(n,h)=>{let t=ae.parse(n),r=await e.selectedProfile();if(!r||c(r.ref)!==c(t.profileRef)||r.sourceRevision!==t.binding.sourceRevision)throw new Error("Evaluation Profile differs from the app-server's authorized selection.");let s=await e.loadCatalog({ref:r.ref,sourceRevision:r.sourceRevision,harnessRelease:t.binding.harnessRelease}),f=t.manifest.profileEvaluation,o=await M({manifest:t.manifest,taskset:t.taskset,selected:{profileRef:r.ref,sourceRevision:r.sourceRevision,harnessRelease:t.binding.harnessRelease},loadCatalog:e.loadCatalog,resolveExternalDataset:e.resolveExternalDataset}),i=o?.definition??s.definitions.find(d=>d.id===f?.definitionId);if(A(t.manifest,t.taskset,o?.catalog??{schemaVersion:"openpond.profileEvaluations.v1",definitions:s.definitions,suites:s.suites}),!f||!i||(o?c(o.catalog):s.catalogHash)!==f.catalogHash||c(i)!==f.definitionHash||c(i.target)!==c(f.target)||i.tasksetRelease.id!==t.manifest.tasksetRelease.id||i.tasksetRelease.contentHash!==t.manifest.tasksetRelease.contentHash||!i.taskIds.includes(t.taskId)||!i.seeds.includes(t.seed)||t.manifest.population.filter(d=>d.taskId===t.taskId&&d.seed===t.seed).length!==1)throw new Error("Evaluation case differs from its released definition or admitted population.");let l=t.taskset.tasks.find(d=>d.id===t.taskId),u=j(l);if(u.artifactRefs.length!==l.artifactRefs.length||u.artifactRefs.length>B.maxAttachments)throw new Error("Evaluation case has an unauthorized task attachment.");if(u.artifactRefs.length&&!e.storeDir)throw new Error("Evaluation case attachment storage is unavailable.");let R=o?.packageValue??(u.artifactRefs.length||l.requiredOutputs?.length?await e.loadTasksetPackage(i,r.ref.profileId,t.binding.harnessRelease):null);if(R&&(R.contentHash!==t.manifest.packageHash||R.taskset.contentHash!==t.taskset.contentHash))throw new Error("Evaluation case Taskset differs from its frozen package or admitted manifest.");let v=u.artifactRefs.map(d=>{if(d.mediaType!=="application/pdf"||d.sizeBytes>B.maxAttachmentBytes)throw new Error(`Evaluation case attachment ${d.id} is not an admitted PDF.`);let a=R?.files.find(E=>E.asset.id===d.id);if(!a||c(a.asset)!==c(d))throw new Error(`Evaluation case attachment ${d.id} differs from its frozen Taskset file.`);return V(a),q.parse({id:d.id,name:te.basename(d.path),kind:"file",mediaType:d.mediaType,sizeBytes:d.sizeBytes,contentsBase64:a.base64})}),w=Z({manifest:t.manifest,profileRef:r.ref,binding:t.binding,modelRef:t.modelRef,modelConfigurationHash:t.modelConfigurationHash,createSession:e.createSession,sendTurn:e.sendTurn,...e.admitSession?{admitSession:m(d=>e.admitSession(d,t.manifest,t.taskId,t.seed,v),"admitSession")}:{},...e.settleSession?{settleSession:e.settleSession}:{},interruptSessionTurn:e.interruptSessionTurn,runtimeEventsForTurn:m(d=>e.store.runtimeEventsForTurn(d),"runtimeEventsForTurn"),attachments:v,requiredOutputs:l.requiredOutputs??[]});o&&await o.authorize(),h?.throwIfAborted();let p=await w({task:u,seed:t.seed,source:f,...h?{signal:h}:{}}),g=await K({storeDir:e.storeDir,readManaged:e.readManagedArtifact,attempt:{artifactRefs:p.artifactRefs,profileNative:p.retainedEvidenceRef?.sessionId&&p.retainedEvidenceRef.turnId?{sessionId:p.retainedEvidenceRef.sessionId,turnId:p.retainedEvidenceRef.turnId,traceHash:p.traceHash}:null},events:m(d=>e.store.runtimeEventsForTurn(d),"events"),signal:h,authorize:m(async()=>{h?.throwIfAborted();let d=await e.selectedProfile();if(!d||c(d)!==c(r))throw new Error("The current artifact Profile authority changed.");o&&await o.authorize()},"authorize")});return{...p,evidence:{...p.evidence,artifacts:g,caseOwner:{...p.retainedEvidenceRef,traceHash:p.traceHash}}}}}m(Be,"createProfileEvaluationCaseService");var oe=P.object({manifest:x,taskset:b,profileRef:C,binding:P.union([I,H]),modelRef:S,modelConfigurationHash:y}).strict();function Le(e){let n=new Map,h=m(async(t,r)=>{let s=await e.selectedProfile();if(!s||c(s.ref)!==c(t.profileRef)||s.sourceRevision!==t.binding.sourceRevision)throw new Error("Evaluation Profile differs from the app-server's authorized selection.");let f=await e.loadCatalog({ref:s.ref,sourceRevision:s.sourceRevision,harnessRelease:t.binding.harnessRelease}),o=await M({manifest:t.manifest,taskset:t.taskset,selected:{profileRef:s.ref,sourceRevision:s.sourceRevision,harnessRelease:t.binding.harnessRelease},loadCatalog:e.loadCatalog,resolveExternalDataset:e.resolveExternalDataset}),i=o?.catalog??{schemaVersion:"openpond.profileEvaluations.v1",definitions:f.definitions,suites:f.suites};if(A(t.manifest,t.taskset,i),!e.privateGrading&&(t.taskset.graders.some(a=>a.kind==="model_judge"||a.kind==="custom_verifier")||t.taskset.metrics?.aggregation==="custom"))throw new Error("Profile evaluation cannot run this Taskset's model judge, custom verifier, or custom metric in the current app-server runtime.");let l=t.manifest.profileEvaluation,u=t.manifest.policy;if(l.profileId!==s.ref.profileId||l.sourceRevision!==t.binding.sourceRevision||l.harnessRelease.id!==t.binding.harnessRelease.id||l.harnessRelease.contentHash!==t.binding.harnessRelease.contentHash||(t.binding.schemaVersion==="openpond.profileWorkflowBinding.v1"?l.target.kind!=="workflow"||l.target.workflowId!==t.binding.workflowId:l.target.kind==="workflow"||c(l.target)!==c(t.binding.target))||u.kind!=="model"||u.model.provider!==t.modelRef.providerId||u.model.model!==t.modelRef.modelId||u.configurationHash!==t.modelConfigurationHash)throw new Error("Evaluation request differs from its admitted Profile workflow or model configuration.");let R=i.definitions.find(a=>a.id===l.definitionId),v=e.privateGrading?o?.packageValue??await(e.loadTasksetPackage?e.loadTasksetPackage(R,s.ref.profileId,l.harnessRelease):Promise.reject(new Error("The current private Taskset owner is unavailable."))):null,w=v?await e.privateGrading?.(t.manifest,v,r):void 0;await w?.authorize();let p=await e.store.getProfileEvaluationRun(t.manifest.id);if(p){if(p.manifest.contentHash!==t.manifest.contentHash||c(p.profileRef)!==c(s.ref))throw new Error(`Profile evaluation run ${t.manifest.id} already exists with another manifest.`);return p}o&&await o.authorize(),r?.throwIfAborted();let g=await L({manifest:t.manifest,taskset:t.taskset,catalog:i,...w?{customVerifier:w.customVerifier,modelJudge:w.modelJudge,metricSource:w.metricSource,metricExecutor:w.metricExecutor}:{},execute:m(({task:a,seed:E,signal:k})=>e.executeCase({...t,taskId:a.id,seed:E},k),"execute"),...r?{signal:r}:{},saveGrade:m(async a=>(await e.store.saveProfileEvaluationGrade(a),{id:a.contentHash,contentHash:a.contentHash,mediaType:"application/json",sizeBytes:null}),"saveGrade"),saveReceipt:m(async a=>{await e.store.saveProfileEvaluationReceipt(a)},"saveReceipt"),loadCompletedMember:m(async({receiptId:a})=>{let E=await e.store.getProfileEvaluationReceipt(a);if(!E)return null;let k=E.graderEvidenceRefs[0],_=k&&await e.store.getProfileEvaluationGrade(k.contentHash);if(!_)throw new Error(`Retained Profile evaluation receipt ${a} is missing its grade.`);return{receipt:E,grade:_}},"loadCompletedMember")});await w?.authorize(),o&&await o.authorize();let d={profileRef:s.ref,manifest:t.manifest,metric:g.metric,gradeRefs:g.grades.map(a=>({id:a.contentHash,contentHash:a.contentHash})),receiptRefs:g.receipts.map(a=>({id:a.id,contentHash:a.contentHash})),passRate:g.passRate,passed:g.passed,completedAt:new Date().toISOString()};return e.store.saveProfileEvaluationRun({...d,contentHash:c(d)})},"run");return(t,r)=>{let s=oe.parse(t),f=n.get(s.manifest.id);if(f){if(f.manifestHash!==s.manifest.contentHash)throw new Error(`Profile evaluation run ${s.manifest.id} is already running with another manifest.`);return f.promise}let o=h(s,r);return n.set(s.manifest.id,{manifestHash:s.manifest.contentHash,promise:o}),o.finally(()=>{n.get(s.manifest.id)?.promise===o&&n.delete(s.manifest.id)}).catch(()=>{}),o}}m(Le,"createProfileEvaluationRunService");var re=P.object({id:T,suiteId:T,createdAt:D,modelRef:S,hostModelConfigurationHash:y.optional()}).strict();function Je(e){let n=new Map,h=m(async t=>{let r=await e.selectedWorkflows(),s=await e.loadCatalog({ref:r.profileRef,sourceRevision:r.sourceRevision,harnessRelease:r.harnessRelease}),f={schemaVersion:"openpond.profileEvaluations.v1",definitions:s.definitions,suites:s.suites},o=f.suites.find(v=>v.id===t.suiteId);if(!o)throw new Error(`Profile evaluation suite ${t.suiteId} is absent from the selected release.`);let i=[];for(let v of o.definitionIds)i.push(await e.prepareRun({id:`suite-${c([t.id,v]).slice(0,32)}`,createdAt:t.createdAt,definitionId:v,modelRef:t.modelRef,...t.hostModelConfigurationHash?{hostModelConfigurationHash:t.hostModelConfigurationHash}:{}}));let l=await e.store.getProfileEvaluationSuiteRun(t.id);if(l){if(l.suiteId!==o.id||l.catalogHash!==c(f)||l.profileId!==r.profileRef.profileId||l.sourceRevision!==r.sourceRevision||l.harnessRelease.id!==r.harnessRelease.id||l.harnessRelease.contentHash!==r.harnessRelease.contentHash||l.createdAt!==t.createdAt)throw new Error(`Profile evaluation suite run ${t.id} already exists with another request.`);for(let[v,w]of l.members.entries()){let p=await e.store.getProfileEvaluationRun(w.runManifest.id);if(!p||p.contentHash!==w.runHash||p.manifest.contentHash!==w.runManifest.contentHash||p.manifest.contentHash!==i[v]?.manifest.contentHash)throw new Error("Retained Profile evaluation suite is missing member evidence.");let g=p.manifest.policy;if(g.kind!=="model"||g.model.provider!==t.modelRef.providerId||g.model.model!==t.modelRef.modelId)throw new Error(`Profile evaluation suite run ${t.id} already exists with another model.`)}return l}let u=[];for(let[v,w]of o.definitionIds.entries()){let p=i[v],g=await e.executeRun(p);u.push({definitionId:w,manifest:g.manifest,runHash:g.contentHash,passed:g.passed,score:g.metric.value})}let R=F({id:t.id,suiteId:o.id,catalog:f,members:u,createdAt:t.createdAt,completedAt:new Date().toISOString()});return e.store.saveProfileEvaluationSuiteRun(r.profileRef,f,R)},"run");return t=>{let r=re.parse(t),s=c(r),f=n.get(r.id);if(f){if(f.requestHash!==s)throw new Error(`Profile evaluation suite run ${r.id} is already running with another request.`);return f.promise}let o=h(r);return n.set(r.id,{requestHash:s,promise:o}),o.finally(()=>{n.get(r.id)?.promise===o&&n.delete(r.id)}).catch(()=>{}),o}}m(Je,"createProfileEvaluationSuiteService");export{K as a,Z as b,Be as c,Le as d,Je as e};
@@ -0,0 +1,11 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as R}from"./chunk-KCJVFLBB.js";import{ib as u,kb as E}from"./chunk-VYLGI3IH.js";import{a as d}from"./chunk-FTQLQJQV.js";var S=class extends R{static{d(this,"SqliteLearningStore")}async listLearningScopes(){return await this.ready,await this.writeQueue,(await this.all("SELECT DISTINCT scope FROM learning_resources ORDER BY scope",[])).map(t=>t.scope)}learningRepository(){return{transaction:d(async(t,o)=>{if(!t.trim())throw new Error("learning_scope_required");await this.ready;let a=this.writeQueue.then(async()=>{let e=this.db;if(!e)throw new Error("learning_store_closed");e.exec("BEGIN IMMEDIATE");let n=!0,i=_(e,t,()=>{if(!n)throw new Error("learning_transaction_closed")});try{let r=await o(i);return e.exec("COMMIT"),r}catch(r){throw e.exec("ROLLBACK"),r}finally{n=!1}});return this.writeQueue=a.then(()=>{},()=>{}),a},"transaction")}}};function _(s,t,o){let a=d((e,n)=>u[e].parse(JSON.parse(n.payload)),"parse");return{async get(e,n,i){o();let r=i===void 0?s.get(`SELECT history.payload FROM learning_resources current
3
+ JOIN learning_revisions history USING (scope, kind, id, revision)
4
+ WHERE current.scope = ? AND current.kind = ? AND current.id = ?`,[t,e,n]):s.get("SELECT payload FROM learning_revisions WHERE scope = ? AND kind = ? AND id = ? AND revision = ?",[t,e,n,i]);return r?a(e,r):null},async put(e,n,i,r){o(),N(s,t,e,n,i,r)},async list(e,n){o();let i=Math.max(1,Math.min(100,Math.trunc(n.limit)));if(!Number.isFinite(i))throw new Error("learning_query_limit_invalid");let r=["current.scope = ?","current.kind = ?"],c=[t,e];if(n.reviewState!==void 0){if(e!=="evidence")throw new Error("learning_review_filter_requires_evidence");let l=`EXISTS (SELECT 1 FROM learning_resources decision
5
+ JOIN learning_revisions decision_history USING (scope, kind, id, revision)
6
+ WHERE decision.scope = current.scope AND decision.kind = 'decision'
7
+ AND decision.parent_id = current.id AND decision.status IN ('approved', 'rejected')
8
+ AND json_extract(decision_history.payload, '$.evidence.contentHash') = json_extract(history.payload, '$.contentHash'))`;r.push(n.reviewState==="reviewed"?l:`NOT ${l}`)}for(let[l,y]of[["parent_id",n.parentId],["status",n.status]])y!==void 0&&(r.push(`current.${l} = ?`),c.push(y));n.afterId!==void 0&&(r.push("current.id > ?"),c.push(n.afterId));let p=s.all(`SELECT history.payload FROM learning_resources current
9
+ JOIN learning_revisions history USING (scope, kind, id, revision)
10
+ WHERE ${r.join(" AND ")} ORDER BY current.id LIMIT ?`,[...c,i+1]),g=p.slice(0,i).map(l=>a(e,l));return{items:g,nextCursor:p.length>i?g.at(-1).id:null}},async operation(e){o();let n=s.get("SELECT payload FROM learning_operations WHERE scope = ? AND id = ?",[t,e]);return n?JSON.parse(n.payload):null},async saveOperation(e,n){o(),s.run("INSERT INTO learning_operations (scope, id, payload) VALUES (?, ?, ?)",[t,e,JSON.stringify(n)])},async familySplit(e,n,i){return o(),s.get("SELECT split FROM learning_family_splits WHERE scope = ? AND namespace = ? AND kind = ? AND key = ?",[t,e,n,i])?.split??null},async reserveFamilySplit(e,n,i,r){o();let c=s.get("SELECT split FROM learning_family_splits WHERE scope = ? AND namespace = ? AND kind = ? AND key = ?",[t,e,n,i]);if(c&&c.split!==r)throw new Error("task_family_split_conflict");c||s.run("INSERT INTO learning_family_splits (scope, namespace, kind, key, split) VALUES (?, ?, ?, ?, ?)",[t,e,n,i,r])}}}d(_,"createLearningTransaction");function N(s,t,o,a,e,n){let i=u[o].parse(a),r=s.get("SELECT revision FROM learning_resources WHERE scope = ? AND kind = ? AND id = ?",[t,o,i.id]);if((r?.revision??0)!==e)throw new E(o,i.id,e,r?.revision??0);if(i.revision!==e+1)throw new Error("learning_resource_revision_invalid");s.run("INSERT INTO learning_revisions (scope, kind, id, revision, payload) VALUES (?, ?, ?, ?, ?)",[t,o,i.id,i.revision,JSON.stringify(i)]),s.run(`INSERT INTO learning_resources (scope, kind, id, revision, parent_id, status) VALUES (?, ?, ?, ?, ?, ?)
11
+ ON CONFLICT (scope, kind, id) DO UPDATE SET revision = excluded.revision, parent_id = excluded.parent_id, status = excluded.status`,[t,o,i.id,i.revision,n?.parentId??null,n?.status??null])}d(N,"putLearningResourceInTransaction");export{S as a,_ as b,N as c};
@@ -0,0 +1,6 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{F as Ie}from"./chunk-EIRYMSEG.js";import{a as B}from"./chunk-7ED24PP6.js";import{a as Ee}from"./chunk-2IHO4GDJ.js";import{a as je}from"./chunk-GJ2ZJFDD.js";import{e as He}from"./chunk-H6IW2R22.js";import{b as Re,c as ie,m as ne}from"./chunk-ACYFMLWG.js";import{e as ve,i as Se,l as Pe,m as be}from"./chunk-TVQAPBLZ.js";import{k as v,l as fe,m as j}from"./chunk-KGNCKIFP.js";import{a as c}from"./chunk-FTQLQJQV.js";import{promises as f}from"node:fs";import n from"node:path";import te from"node:path";import{constants as De,promises as D}from"node:fs";import R from"node:path";async function Fe(e){let t=await D.lstat(e);if(t.isSymbolicLink())throw new Error(`Profile source cannot be a symlink: ${e}`);if(t.isFile())return[R.basename(e)];if(!t.isDirectory())throw new Error(`Profile source is not a file or directory: ${e}`);return _(e)}c(Fe,"sourceFilesForImport");function xe(e){for(let t of["agent.ts","index.ts","agent/agent.ts","agent.yaml","agent.yml","agent.json"])if(e.includes(t))return t;return e[0]}c(xe,"selectAgentPrimaryFile");async function $e(e,t){let a=await D.lstat(e);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Harness import source must be a regular non-symlink file: ${e}`);await D.mkdir(R.dirname(t),{recursive:!0}),await D.copyFile(e,t,De.COPYFILE_EXCL)}c($e,"copyRegularFile");function Z(e){let t=R.extname(e).toLowerCase();return[".md",".txt"].includes(t)?t===".md"?"text/markdown":"text/plain":[".json"].includes(t)?"application/json":[".yaml",".yml"].includes(t)?"application/yaml":[".ts",".tsx",".js",".mjs",".cjs"].includes(t)?"text/javascript":t===".py"?"text/x-python":"application/octet-stream"}c(Z,"mediaTypeForPath");async function ee(e,t){let a=R.resolve(e,...t.split("/")),o=R.relative(e,a);if(!o||o.startsWith("..")||R.isAbsolute(o))throw new Error(`Harness source path escapes its root: ${t}`);let s=await D.lstat(a);if(!s.isFile()||s.isSymbolicLink())throw new Error(`Harness source path must be a regular non-symlink file: ${t}`);let r=await D.realpath(a),w=R.relative(await D.realpath(e),r);if(w.startsWith("..")||R.isAbsolute(w))throw new Error(`Harness source path resolves outside its root: ${t}`);return a}c(ee,"resolveContainedRegularFile");async function _(e,t=e){let a=await D.readdir(t,{withFileTypes:!0}),o=[];for(let s of a){if(["node_modules",".git",".openpond"].includes(s.name)||s.name.startsWith(".env"))continue;let r=R.join(t,s.name);if(s.isSymbolicLink())throw new Error(`Harness source cannot contain symlinks: ${R.relative(e,r)}`);if(s.isDirectory())o.push(...await _(e,r));else if(s.isFile())o.push(R.relative(e,r).split(R.sep).join("/"));else throw new Error(`Harness source contains an unsupported entry: ${R.relative(e,r)}`)}return o.sort()}c(_,"listRegularFiles");function H(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"harness"}c(H,"safeSegment");function Ae(e,t){let a=[];return{async copy(o,s){await $e(o,s);let r=te.relative(e,o),w=te.relative(t,s);r&&!r.startsWith("..")&&!te.isAbsolute(r)&&a.push({releasedPath:w.split(te.sep).join("/"),profileRelativePath:r.split(te.sep).join("/")})},add(o,s){a.push({releasedPath:o,profileRelativePath:s})},policy(o){return a.filter(s=>o.some(r=>r.path===s.releasedPath&&r.visibility==="policy"))}}}c(Ae,"createProfileSourceBindings");var Le=c(e=>e==="evals/catalog.json"||/^evals\/(definitions|suites|tasksets)\//.test(e)||/^workflows\/[^/]+\/evals\//.test(e),"isProfilePrivateEvaluationPath");import{execFile as _e}from"node:child_process";import{promises as L}from"node:fs";import G from"node:path";import{promisify as Ne}from"node:util";var ze=Ne(_e);async function nt(e){let t=G.join(e.runPath,"package.json"),a=await L.lstat(t).catch(()=>null);if(a&&(!a.isFile()||a.isSymbolicLink()))throw new Error("Released Profile Agent package manifest must be a regular file.");a||await L.writeFile(t,`{"type":"module"}
3
+ `,{flag:"wx"});let o=await me(e.runPath);if(o){let r=o==="npm"?["ci","--omit=dev","--ignore-scripts","--no-audit","--no-fund"]:["install","--prod","--frozen-lockfile","--ignore-scripts","--config.node-linker=hoisted"];await(e.install??Je)(o,r,e.runPath)}let s=G.join(e.runPath,"node_modules","openpond-agent-sdk");if(!await L.lstat(s).catch(()=>null)){let r=JSON.parse(await L.readFile(t,"utf8"));if({...le(r.dependencies),...le(r.optionalDependencies)}["openpond-agent-sdk"])throw new Error("Released Profile Agent declared an SDK dependency that the locked installation did not provide.");let P=await Ie();await L.mkdir(G.dirname(s),{recursive:!0}),await L.symlink(P,s,"dir")}}c(nt,"prepareReleasedProfileActionDependencies");async function me(e){let t=G.join(e,"package.json"),a=await L.lstat(t).catch(()=>null);if(!a)return null;if(!a.isFile()||a.isSymbolicLink())throw new Error("Released Profile Agent package manifest must be a regular file.");let o=JSON.parse(await L.readFile(t,"utf8")),s={...le(o.dependencies),...le(o.optionalDependencies)};if(Object.keys(s).length){for(let[P,u]of Object.entries(s))if(/^(?:file:|link:|workspace:|git\+|https?:)/i.test(u))throw new Error(`Released Profile Agent dependency ${P} must use a portable registry version.`);let r=await We(G.join(e,"package-lock.json")),w=await We(G.join(e,"pnpm-lock.yaml"));if(r===w)throw new Error("Released Profile Agent with third-party dependencies requires exactly one npm or pnpm lockfile.");return r?"npm":"pnpm"}return null}c(me,"inspectReleasedProfileActionDependencies");function le(e){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Released Profile Agent dependencies must be a package map.");let t=Object.entries(e);if(t.some(([a,o])=>!a||typeof o!="string"||!o.trim()))throw new Error("Released Profile Agent dependencies must name portable versions.");return Object.fromEntries(t)}c(le,"dependencyMap");async function We(e){let t=await L.lstat(e).catch(()=>null);if(t&&(!t.isFile()||t.isSymbolicLink()))throw new Error("Released Profile Agent lockfile must be a regular file.");return!!t}c(We,"regularFile");async function Je(e,t,a){try{let o=process.platform==="win32"?`${e}.cmd`:e;await ze(o,t,{cwd:a,timeout:3e5,maxBuffer:1e6,...process.platform==="win32"?{shell:!0}:{}})}catch{throw new Error(`Released Profile Agent locked ${e} dependency installation failed.`)}}c(Je,"installLockedDependencies");var Te="harness.json";async function we(e,t,a,o,s){let r=n.resolve(a.sourcePath),w=[],P=Ae(r,e),u=P.copy,N=new Set((await _(r)).filter(Le)),E=new Set,y=c(i=>{let h=i.id;E.has(h)&&(h=`${h}-${j(i.path).slice(0,8)}`),E.add(h);let b={...i,id:h};return w.push(b),b},"addDeclaration");await f.mkdir(e,{recursive:!0});let ae=n.join(r,"instructions","system.md"),V=await f.lstat(ae).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(V){if(!V.isFile()||V.isSymbolicLink())throw new Error("Profile instructions require an actual regular source file.");await u(ae,n.join(e,"instructions","system.md")),y({id:"instruction-system",kind:"instruction",path:"instructions/system.md",parentId:null,mediaType:"text/markdown",visibility:"policy",portability:"portable"})}for(let i of a.skills.filter(h=>h.enabled)){if(i.validationStatus!=="valid")throw new Error(`Cannot import invalid Profile Skill ${i.name}: ${i.validationMessages.join(" ")}`);let h=n.dirname(n.join(r,i.path)),b=`skills/${H(i.name)}/SKILL.md`;await u(n.join(h,"SKILL.md"),n.join(e,...b.split("/")));let T=y({id:`skill-${H(i.name)}`,kind:"skill",path:b,parentId:null,mediaType:"text/markdown",visibility:"policy",portability:"portable"});for(let p of i.resourceFiles){let O=`skills/${H(i.name)}/${p.split(n.sep).join("/")}`;await u(n.join(h,p),n.join(e,...O.split("/"))),y({id:`skill-resource-${H(i.name)}-${j(p).slice(0,12)}`,kind:"skill_resource",path:O,parentId:T.id,mediaType:Z(O),visibility:"policy",portability:"portable"})}}for(let i of a.agents.filter(h=>h.enabled)){let h=n.resolve(r,i.path),b=await f.realpath(h),T=await f.realpath(r),p=n.relative(T,b);if(p.startsWith("..")||n.isAbsolute(p))throw new Error("Profile Agent source escapes its admitted Profile root.");let O=await f.lstat(h),U=(await Fe(h)).filter(A=>{let C=O.isDirectory()?n.join(b,...A.split("/")):b;return!N.has(n.relative(T,C).split(n.sep).join("/"))});if(U.length===0)throw new Error(`Profile Agent ${i.id} has no source files.`);let Y=xe(U);for(let A of U){let C=`agents/${H(i.id)}/${A}`,Q=(await f.stat(h)).isDirectory()?n.join(h,...A.split("/")):h;await u(Q,n.join(e,...C.split("/"))),y({id:A===Y?`agent-${H(i.id)}`:`agent-asset-${H(i.id)}-${j(A).slice(0,12)}`,kind:A===Y?"agent":"asset",path:C,parentId:null,mediaType:Z(C),visibility:"policy",portability:"portable"})}await me(n.join(e,"agents",H(i.id)))}let X=new Set,se=new Set(a.agents.filter(i=>i.enabled).map(i=>i.id)),W=a.actionCatalog.filter(i=>i.agentId&&se.has(i.agentId)).map(i=>({id:i.id,agentId:H(i.agentId),sourceActionId:i.sourceActionId??i.id,inputSchema:typeof i.inputSchema=="object"&&i.inputSchema!==null?i.inputSchema:{type:"object",additionalProperties:!0}})),re=new Set(W.map(i=>i.id)),z=n.join(r,"workflows","catalog.json"),F=await f.lstat(z).catch(()=>null),l=(await _(r)).filter(i=>i.startsWith("workflows/")),S=l.some(i=>/^workflows\/[^/]+\/(PROMPT\.md|ACTION\.json)$/.test(i));if(S&&F)throw new Error("Authored Workflow packages and legacy workflows/catalog.json cannot coexist; migrate the catalog first.");if(F||S||W.length){if(F&&(!F.isFile()||F.isSymbolicLink()))throw new Error("Profile workflow catalog must be a regular file.");let i=S?He({files:new Map(await Promise.all(l.map(async p=>[p,await f.readFile(await ee(r,p),"utf8")]))),skillPaths:new Set(w.filter(p=>p.kind==="skill").map(p=>p.path)),actionIds:re}):null,h=i?Buffer.from(v(i.catalog)):F?await f.readFile(z):Buffer.from(v({schemaVersion:"openpond.profileWorkflows.v1",workflows:[]}));F&&P.add("workflows/catalog.json","workflows/catalog.json");let b=ie({catalog:JSON.parse(h.toString("utf8")),sourcePaths:new Set(w.filter(p=>p.kind==="skill").map(p=>p.path)),actionIds:new Set(W.map(p=>p.id))});for(let p of b.workflows)X.add(p.id);ue(b);let T="workflows/catalog.json";await f.mkdir(n.join(e,"workflows"),{recursive:!0}),await f.writeFile(n.join(e,"workflows","catalog.json"),h,{flag:"wx"});for(let p of i?.referencedPaths??[])await u(n.join(r,...p.split("/")),n.join(e,...p.split("/"))),y({id:`profile-workflow-source-${j(p).slice(0,16)}`,kind:"asset",path:p,parentId:null,mediaType:Z(p),visibility:"policy",portability:"portable"});y({id:"profile-workflows",kind:"workflow",path:T,parentId:null,mediaType:"application/json",visibility:"policy",portability:"portable"})}(F||S||W.length)&&(await f.writeFile(n.join(e,"workflows","actions.json"),v({schemaVersion:"openpond.profileWorkflowActions.v1",actions:W}),{flag:"wx"}),y({id:"profile-workflow-actions",kind:"asset",path:"workflows/actions.json",parentId:null,mediaType:"application/json",visibility:"policy",portability:"portable"}));let I=n.join(r,"evals","catalog.json"),J=await f.lstat(I).catch(()=>null),$=(await _(r)).filter(i=>/^workflows\/[^/]+\/evals\/[^/]+\.json$/.test(i)||/^evals\/(definitions|suites)\/[^/]+\.json$/.test(i));if(J&&$.length)throw new Error("Authored evaluation definitions and legacy evals/catalog.json cannot coexist; migrate the catalog first.");if(J||$.length){let[{ProfileEvaluationDefinitionSchema:i,ProfileEvaluationSuiteSchema:h,validateProfileEvaluationCatalog:b},{validateTasksetPackage:T}]=await Promise.all([import("./dist-OMGUJYPD.js"),import("./taskset-packages-XC6HEE3K.js")]);if(J&&(!J.isFile()||J.isSymbolicLink()))throw new Error("Profile evaluation catalog must be a regular file.");let p=[],O=[];for(let g of $){let x=JSON.parse(await f.readFile(await ee(r,g),"utf8"));if(g.startsWith("evals/suites/"))O.push(h.parse(x));else{let M=i.parse(x),K=/^workflows\/([^/]+)\/evals\//.exec(g)?.[1];if(K&&(M.target.kind!=="workflow"||M.target.workflowId!==K))throw new Error(`Profile evaluation ${M.id} must target its containing Workflow ${K}.`);p.push(M)}}let U=$.length?Buffer.from(v({schemaVersion:"openpond.profileEvaluations.v1",definitions:p.sort((g,x)=>g.id.localeCompare(x.id)),suites:O.sort((g,x)=>g.id.localeCompare(x.id))})):await f.readFile(I),{catalog:Y}=b({catalog:JSON.parse(U.toString("utf8")),workflowIds:X,skillPaths:new Set(w.filter(g=>g.kind==="skill").map(g=>g.path)),actionIds:re});await f.mkdir(n.join(e,"evals"),{recursive:!0}),await f.writeFile(n.join(e,"evals","catalog.json"),U,{flag:"wx"});for(let g of $)await u(n.join(r,...g.split("/")),n.join(e,...g.split("/"))),y({id:`profile-evaluation-source-${j(g).slice(0,16)}`,kind:"asset",path:g,parentId:null,mediaType:"application/json",visibility:"verifier",portability:"portable"});y({id:"profile-evaluations",kind:"asset",path:"evals/catalog.json",parentId:null,mediaType:"application/json",visibility:"verifier",portability:"portable"});let A=new Set(Y.definitions.map(g=>g.tasksetRelease.contentHash)),C=n.join(r,"evals","tasksets"),Q=await f.lstat(C).catch(()=>null);if(Q&&(!Q.isDirectory()||Q.isSymbolicLink()))throw new Error("Profile evaluation Taskset directory must be a regular directory.");for(let g of A){let x=n.join(C,`${g}.json`),M=await f.lstat(x).catch(()=>null);if(!M)throw new Error(`Profile evaluation Taskset package ${g} is missing.`);if(!M.isFile()||M.isSymbolicLink())throw new Error("Profile evaluation Taskset package must be a regular file.");let K=T(JSON.parse(await f.readFile(x,"utf8")));if(K.taskset.contentHash!==g||!Y.definitions.some(ye=>ye.tasksetRelease.contentHash===g&&ye.tasksetRelease.id===K.taskset.id))throw new Error("Profile evaluation Taskset package differs from its catalog reference.");let ke=`evals/tasksets/${g}.json`;await u(x,n.join(e,...ke.split("/"))),y({id:`profile-evaluation-taskset-${g.slice(0,16)}`,kind:"asset",path:ke,parentId:null,mediaType:"application/json",visibility:"verifier",portability:"portable"})}}let q=await Be(a,o),k=`dependency-lock/${q.name}`;await f.mkdir(n.join(e,"dependency-lock"),{recursive:!0}),q.sourcePath?await u(q.sourcePath,n.join(e,...k.split("/"))):await f.writeFile(n.join(e,...k.split("/")),v(q.generated),{flag:"wx"}),y({id:"dependency-lock",kind:"dependency_lock",path:k,parentId:null,mediaType:Z(k),visibility:"policy",portability:"portable"}),await f.writeFile(n.join(e,"program.json"),v({runtimeProtocol:"openpond.agent-runtime.v1"}),{flag:"wx"}),y({id:"agent-runtime-program",kind:"program",path:"program.json",parentId:null,mediaType:"application/json",visibility:"policy",portability:"portable"});let de=B.parse({schemaVersion:"openpond.harnessSourceManifest.v1",name:t,files:w,toolDeclarations:[],capabilityRequirements:[],lifecycle:{create:!0,reset:!0,step:!0,collect:!0,destroy:!0,resetScope:"attempt"},graderInterface:{visibleEvidence:["output","runtime_events","artifacts"],privilegedEvidence:["expected_output","private_verifier"],privateVerifierIsolation:!0},runtimeProtocol:"openpond.agent-runtime.v1",metadata:{importedFrom:"openpond.profile",profileId:a.activeProfile,...s?{profileRepositoryId:s}:{},profileGitHead:o??a.git?.head??null,profileSourceBindings:P.policy(w),profileInstructionSourcePath:"instructions/system.md",excludedEvalCount:a.evals.length,actionConversionPending:a.actionCatalog.length>0}});await f.writeFile(n.join(e,Te),v(de),{flag:"wx"}),await ce(e,t)}c(we,"writeImportedProfileSource");function ue(e){for(let t of e.workflows){let a=ne(t.inputSchema);if(!a.valid)throw new Error(`Profile workflow ${t.id} has an invalid input schema: ${a.issues[0]?.message??"schema mismatch"}`)}}c(ue,"assertProfileWorkflowInputSchemas");async function ce(e,t){let a=n.join(e,Te),o=B.parse(JSON.parse(await f.readFile(a,"utf8")));if(o.files.some(u=>u.kind==="instruction"))return;let s="instructions/system.md";await f.mkdir(n.join(e,"instructions"),{recursive:!0}),await f.writeFile(n.join(e,...s.split("/")),`# ${t}
4
+
5
+ Keep reusable, provider-neutral execution guidance for this Harness here.
6
+ `,{flag:"wx"});let w=new Set(o.files.map(u=>u.id)).has("instruction-system")?`instruction-system-${j(s).slice(0,8)}`:"instruction-system",P=B.parse({...o,name:t,files:[...o.files,{id:w,kind:"instruction",path:s,parentId:null,mediaType:"text/markdown",visibility:"policy",portability:"portable"}]});await f.writeFile(a,v(P),{flag:"w"})}c(ce,"ensureHarnessInstructionSurface");async function Be(e,t){let a=e.repoPath?n.resolve(e.repoPath):null;if(a)for(let o of["pnpm-lock.yaml","package-lock.json","yarn.lock"]){let s=n.join(a,o),r=await f.lstat(s).catch(()=>null);if(r?.isFile()&&!r.isSymbolicLink())return{name:o,sourcePath:s}}return{name:"profile-import.json",sourcePath:null,generated:{source:"openpond.profile",profileId:e.activeProfile,profileGitHead:t??e.git?.head??null,dependenciesResolved:!1}}}c(Be,"importedDependencyLock");import{randomUUID as ge}from"node:crypto";import{promises as d}from"node:fs";import m from"node:path";var oe="harness.json",Oe=25e7;function Ve(e,t){let a=`${H(t)}-${j(t).slice(0,16)}`,o=m.join(e,"library","harnesses","workspaces",a);return{root:o,source:m.join(o,"source")}}c(Ve,"localHarnessWorkspacePaths");async function xt(e){return pe({...e,initializeSource:c(t=>Ue(t,e.name),"initializeSource")})}c(xt,"createLocalHarnessWorkspace");async function $t(e){if(e.profile.mode!=="local"||!e.profile.sourcePath)throw new Error("Only a loaded local Profile with a source path can be imported.");return pe({...e,compilationWorkspaceId:e.repositoryId?Me(e.repositoryId,e.name):e.id,initializeSource:c(t=>we(t,e.name,e.profile,e.sourceRevision,e.repositoryId),"initializeSource")})}c($t,"importProfileIntoLocalHarnessWorkspace");function Me(e,t){return`profile-source-${j([e,t]).slice(0,24)}`}c(Me,"profileCompilationWorkspaceId");async function At(e){if(e.profile.mode!=="local"||!e.profile.sourcePath)throw new Error("Only a loaded Profile source can be compiled.");let t=m.join(e.storeDir,"library","harnesses","profile-previews");await d.mkdir(t,{recursive:!0});let a=m.join(t,ge());try{await we(a,e.name,e.profile,e.sourceRevision,e.repositoryId);let o=e.repositoryId?Me(e.repositoryId,e.name):e.workspaceId;return await he({workspaceId:o,sourceDir:a})}finally{await d.rm(a,{recursive:!0,force:!0})}}c(At,"compileProfileHarnessSource");async function Lt(e){let t=await he({workspaceId:e.id,sourceDir:e.sourceDir}),a=await e.store.getHarnessWorkspace(e.id);if(a){let o=a.currentChannel.release?await e.store.getHarnessReleaseRecord(a.currentChannel.release.contentHash):null;if(a.ownerScope.id!==e.ownerId||a.sourceRevision!==t.sourceRevision||o?.harnessRelease.contentHash!==t.harnessRelease.contentHash)throw new Error("Configured Harness source changed; use a new workspace ID for the new release.");return}await pe({...e,initializeSource:c(async o=>{await d.mkdir(o,{recursive:!0}),await d.writeFile(m.join(o,oe),v(t.manifest));for(let s of t.sourceFiles){let r=m.join(o,s.path);await d.mkdir(m.dirname(r),{recursive:!0}),await d.writeFile(r,s.bytes)}},"initializeSource")})}c(Lt,"importLocalHarnessWorkspaceSource");async function Wt(e){let t=await e.store.getHarnessReleaseRecord(e.sourceRelease.contentHash);if(!t||t.harnessRelease.id!==e.sourceRelease.id)throw new Error("Harness workspace fork source release is unavailable.");return pe({...e,initializeSource:c(async a=>{await d.cp(m.join(t.bundlePath,"source"),a,{recursive:!0,force:!1,errorOnExist:!0,verbatimSymlinks:!1}),await ce(a,e.name)},"initializeSource")})}c(Wt,"forkLocalHarnessWorkspaceFromRelease");async function pe(e){let t=e.now??(()=>new Date().toISOString()),a=Ve(e.storeDir,e.id),o=m.dirname(a.root);await d.mkdir(o,{recursive:!0});let s=m.join(o,`.${m.basename(a.root)}.creating-${ge()}`),r=m.join(s,"source");try{await e.initializeSource(r),await d.rename(s,a.root)}catch(w){throw await d.rm(s,{recursive:!0,force:!0}).catch(()=>{}),w}try{let w=await he({workspaceId:e.compilationWorkspaceId??e.id,sourceDir:a.source}),P=await qe({storeDir:e.storeDir,workspaceId:e.id,compiled:w,createdAt:t()}),u=t(),N=je.parse({schemaVersion:"openpond.harnessWorkspace.v1",id:e.id,ownerScope:e.originOwnerScope??{kind:"personal",id:e.ownerId},name:e.name,location:"local",sourceRevision:w.sourceRevision,revision:0,dirty:!1,currentChannel:{name:"personal",release:{id:w.harnessRelease.id,contentHash:w.harnessRelease.contentHash},revision:1},createdAt:u,updatedAt:u,metadata:{...e.originMetadata,sourceLayout:"openpond.harnessSourceManifest.v1",...e.selectionEligible===!1?{selectionEligible:!1}:{}}});return await e.store.createHarnessWorkspaceWithRelease({workspace:N,release:P})}catch(w){throw await d.rm(a.root,{recursive:!0,force:!0}).catch(()=>{}),w}}c(pe,"createLocalHarnessWorkspaceFromInitializer");async function he(e){let t=m.resolve(e.sourceDir),a=m.join(t,oe),o=B.parse(JSON.parse(await d.readFile(a,"utf8"))),s=new Set(o.files.map(l=>l.path)),r=(await _(t)).filter(l=>l!==oe),w=r.filter(l=>!s.has(l)),P=[...s].filter(l=>!r.includes(l));if(w.length||P.length)throw new Error(`Harness source manifest mismatch. Unlisted: ${w.join(", ")||"none"}; missing: ${P.join(", ")||"none"}.`);let u=[];for(let l of o.files){let S=await ee(t,l.path),I=await d.readFile(S);if(I.byteLength>Oe)throw new Error(`Harness source file ${l.path} exceeds ${Oe} bytes.`);u.push({path:l.path,bytes:I,asset:{id:l.id,path:l.path,contentHash:fe(I),sizeBytes:I.byteLength,mediaType:l.mediaType,visibility:l.visibility}})}let N=u.find(({path:l})=>l==="workflows/catalog.json");if(N){let l=o.files.find(k=>k.path===N.path);if(l?.kind!=="workflow"||l.visibility!=="policy")throw new Error("Profile workflow catalog requires a policy-visible workflow declaration.");let S=u.find(({path:k})=>k==="workflows/actions.json"),I=o.files.find(k=>k.path==="workflows/actions.json");if(!S||I?.visibility!=="policy")throw new Error("Profile workflow catalog requires a released action inventory.");let J=Re.parse(JSON.parse(new TextDecoder().decode(S.bytes))).actions,$=new Set;for(let k of J){if($.has(k.id))throw new Error(`Duplicate Profile workflow action ${k.id}.`);if($.add(k.id),!ne(k.inputSchema).valid)throw new Error(`Profile workflow action ${k.id} has an invalid input schema.`);if(!o.files.some(de=>de.path.startsWith(`agents/${k.agentId}/`)))throw new Error(`Profile workflow action ${k.id} lacks its Agent source.`)}let q=ie({catalog:JSON.parse(new TextDecoder().decode(N.bytes)),sourcePaths:new Set(o.files.filter(k=>k.kind==="skill").map(k=>k.path)),actionIds:$});ue(q)}let E=j({manifest:o,files:u.map(({path:l,asset:S})=>({path:l,contentHash:S.contentHash,sizeBytes:S.sizeBytes}))}),y=c(l=>u.filter(({path:S})=>o.files.find(I=>I.path===S)?.kind===l).map(({asset:S})=>S),"byKind"),ae=y("dependency_lock")[0],V=y("program")[0],X=o.files.filter(l=>l.portability==="local_only").map(l=>l.id),se=o.files.filter(l=>l.visibility==="host_private").map(l=>l.id),W=[...X.map(l=>`Asset ${l} is local-only.`),...se.map(l=>`Asset ${l} is host-private.`)],re={id:`harness-source-${E.slice(0,24)}`,contentHash:E},z=Pe({schemaVersion:"openpond.agentSnapshot.v2",id:`agent-snapshot-${j([E,o.toolDeclarations]).slice(0,24)}`,sourceRelease:re,instructions:y("instruction"),skills:y("skill"),agents:y("agent"),toolDeclarations:o.toolDeclarations,capabilityRequirements:o.capabilityRequirements,dependencyLock:ae,portability:{portable:W.length===0,blockers:W,localOnlyAssetRefs:X,hostPrivateAssetRefs:se},metadata:{workspaceId:e.workspaceId,sourceRevision:E,sourceLayout:o.schemaVersion}}),F=be({schemaVersion:"openpond.harnessRelease.v2",id:`harness-${j([z.contentHash,V.contentHash,o.lifecycle]).slice(0,24)}`,agentSnapshot:{id:z.id,contentHash:z.contentHash},program:V,tools:o.toolDeclarations,lifecycle:o.lifecycle,graderInterface:o.graderInterface,files:u.map(({asset:l})=>l),metadata:{runtimeProtocol:o.runtimeProtocol,sourceRevision:E,sourceLayout:o.schemaVersion,...o.metadata.importedFrom==="openpond.profile"?{profile:{id:o.metadata.profileId,sourceRevision:o.metadata.profileGitHead??E,...o.metadata.profileRepositoryId?{repositoryId:o.metadata.profileRepositoryId}:{}}}:{}}});return{manifest:o,sourceRevision:E,agentSnapshot:z,harnessRelease:F,sourceFiles:u}}c(he,"compileLocalHarnessSource");async function qe(e){let t=m.join(e.storeDir,"library","harnesses","releases"),a=m.join(t,e.compiled.harnessRelease.contentHash);await d.mkdir(t,{recursive:!0});let o=m.join(t,`.${e.compiled.harnessRelease.contentHash}.materializing-${ge()}`);try{await d.mkdir(m.join(o,"source"),{recursive:!0});for(let s of e.compiled.sourceFiles){let r=m.join(o,"source",...s.path.split("/"));await d.mkdir(m.dirname(r),{recursive:!0}),await d.writeFile(r,s.bytes,{flag:"wx"})}await d.writeFile(m.join(o,"source",oe),v(e.compiled.manifest),{flag:"wx"}),await d.writeFile(m.join(o,"agent-snapshot.json"),v(e.compiled.agentSnapshot),{flag:"wx"}),await d.writeFile(m.join(o,"harness-release.json"),v(e.compiled.harnessRelease),{flag:"wx"});try{await d.rename(o,a)}catch(s){if(s.code!=="EEXIST"&&s.code!=="ENOTEMPTY")throw s;await Ce(a,e.compiled),await d.rm(o,{recursive:!0,force:!0})}await Ce(a,e.compiled)}catch(s){throw await d.rm(o,{recursive:!0,force:!0}).catch(()=>{}),s}return Ee.parse({schemaVersion:"openpond.localHarnessReleaseRecord.v1",workspaceId:e.workspaceId,sourceRevision:e.compiled.sourceRevision,agentSnapshot:e.compiled.agentSnapshot,harnessRelease:e.compiled.harnessRelease,bundlePath:a,createdAt:e.createdAt})}c(qe,"materializeLocalHarnessRelease");async function Ue(e,t){let a=B.parse({schemaVersion:"openpond.harnessSourceManifest.v1",name:t,files:[{id:"dependency-lock",kind:"dependency_lock",path:"dependency-lock.json",parentId:null,mediaType:"application/json",visibility:"policy",portability:"portable"},{id:"agent-runtime-program",kind:"program",path:"program.json",parentId:null,mediaType:"application/json",visibility:"policy",portability:"portable"}],toolDeclarations:[],capabilityRequirements:[],lifecycle:{create:!0,reset:!0,step:!0,collect:!0,destroy:!0,resetScope:"attempt"},graderInterface:{visibleEvidence:["output","runtime_events","artifacts"],privilegedEvidence:["expected_output","private_verifier"],privateVerifierIsolation:!0},runtimeProtocol:"openpond.agent-runtime.v1",metadata:{}});await d.mkdir(e,{recursive:!0}),await d.writeFile(m.join(e,"dependency-lock.json"),v({dependencies:{}}),{flag:"wx"}),await d.writeFile(m.join(e,"program.json"),v({runtimeProtocol:"openpond.agent-runtime.v1"}),{flag:"wx"}),await d.writeFile(m.join(e,oe),v(a),{flag:"wx"}),await ce(e,t)}c(Ue,"writeDefaultHarnessSource");async function Ce(e,t){let a=ve.parse(JSON.parse(await d.readFile(m.join(e,"agent-snapshot.json"),"utf8"))),o=Se.parse(JSON.parse(await d.readFile(m.join(e,"harness-release.json"),"utf8")));if(a.contentHash!==t.agentSnapshot.contentHash||o.contentHash!==t.harnessRelease.contentHash)throw new Error("Materialized Harness release does not match the compiled immutable objects.");for(let s of t.sourceFiles){let r=await d.readFile(m.join(e,"source",...s.path.split("/")));if(fe(r)!==s.asset.contentHash)throw new Error(`Materialized Harness asset ${s.path} failed hash verification.`)}}c(Ce,"verifyMaterializedRelease");export{Z as a,ee as b,_ as c,H as d,Le as e,nt as f,Ve as g,xt as h,$t as i,At as j,Lt as k,Wt as l,he as m,qe as n};