openpond 0.2.58 → 0.2.60

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 (389) hide show
  1. package/README.md +27 -0
  2. package/dist/app-server.d.ts +8 -1
  3. package/dist/app-server.js +1 -1
  4. package/dist/chunks/acp-ARBNMIPT.js +2 -0
  5. package/dist/chunks/acp-agent-53COYDHB.js +21 -0
  6. package/dist/chunks/{actions-command-QU4H53OG.js → actions-command-6YSZ7EJS.js} +1 -1
  7. package/dist/chunks/{app-layer-NSTE5HIT.js → app-layer-TVG7KTW6.js} +1 -1
  8. package/dist/chunks/{app-server-connected-apps-JHGWLBXT.js → app-server-connected-apps-K62M6LCT.js} +1 -1
  9. package/dist/chunks/{app-server-evaluations-K52NAQLP.js → app-server-evaluations-RM6WXX3H.js} +1 -1
  10. package/dist/chunks/app-server-harness-services-RLKMWOQ4.js +2 -0
  11. package/dist/chunks/app-server-runtime-OKMEHNEU.js +2 -0
  12. package/dist/chunks/apps-YWZL2H34.js +2 -0
  13. package/dist/chunks/{chunk-DARVPBZ4.js → chunk-23P2O7PH.js} +1 -1
  14. package/dist/chunks/{chunk-PF5R6CMP.js → chunk-2GICDASL.js} +1 -1
  15. package/dist/chunks/{chunk-6MI4KKWF.js → chunk-2ITZW2CN.js} +1 -1
  16. package/dist/chunks/chunk-2MMCZHKL.js +2 -0
  17. package/dist/chunks/{chunk-ABD5M2D2.js → chunk-2PAJCXFC.js} +1 -1
  18. package/dist/chunks/chunk-2RNCXDJC.js +5 -0
  19. package/dist/chunks/{chunk-APB2STJK.js → chunk-2SUMZ73C.js} +1 -1
  20. package/dist/chunks/{chunk-YOQRYNLP.js → chunk-3CWRTKHY.js} +1 -1
  21. package/dist/chunks/{chunk-TRQQNFMO.js → chunk-44LWH5U6.js} +1 -1
  22. package/dist/chunks/{chunk-HPBQ4VTW.js → chunk-52KIORRX.js} +1 -1
  23. package/dist/chunks/{chunk-NHQ36THU.js → chunk-5RHYSQZ5.js} +1 -1
  24. package/dist/chunks/{chunk-3QIB5FXI.js → chunk-5ZBLCWEJ.js} +1 -1
  25. package/dist/chunks/{chunk-FTEOCCPB.js → chunk-637UACKH.js} +1 -1
  26. package/dist/chunks/chunk-655DQ6AX.js +145 -0
  27. package/dist/chunks/{chunk-N4FFQPLR.js → chunk-6GWOVHIG.js} +1 -1
  28. package/dist/chunks/chunk-6HQB3MQO.js +2 -0
  29. package/dist/chunks/{chunk-UKMA4R6X.js → chunk-7LZISGTA.js} +2 -2
  30. package/dist/chunks/{chunk-A6USMRWK.js → chunk-7RC5WPVT.js} +1 -1
  31. package/dist/chunks/{chunk-H6IW2R22.js → chunk-7YTHEMWI.js} +1 -1
  32. package/dist/chunks/{chunk-PCSIOUHF.js → chunk-A3L74U3W.js} +1 -1
  33. package/dist/chunks/{chunk-25MBPJVY.js → chunk-A66CSUBJ.js} +1 -1
  34. package/dist/chunks/{chunk-OUVIWDL2.js → chunk-AGVOGPAZ.js} +1 -1
  35. package/dist/chunks/{chunk-M4JWQSV7.js → chunk-AW5Q6NXT.js} +1 -1
  36. package/dist/chunks/{chunk-RWWE5OXU.js → chunk-B46HZ3MX.js} +1 -1
  37. package/dist/chunks/{chunk-KGNCKIFP.js → chunk-BIPQCJ5V.js} +1 -1
  38. package/dist/chunks/{chunk-HCYX6RHP.js → chunk-BIQ33JV5.js} +1 -1
  39. package/dist/chunks/{chunk-JFXWI3EN.js → chunk-BK63OQRW.js} +1 -1
  40. package/dist/chunks/{chunk-2D4Y3HNW.js → chunk-CFSIU6CW.js} +1 -1
  41. package/dist/chunks/{chunk-EIEZHFIW.js → chunk-D3RRUWNN.js} +1 -1
  42. package/dist/chunks/{chunk-X4OSOOSU.js → chunk-D4UX2O45.js} +1 -1
  43. package/dist/chunks/{chunk-GJ2ZJFDD.js → chunk-DG4TYVPF.js} +1 -1
  44. package/dist/chunks/{chunk-QIKWJ2AA.js → chunk-DGIEXZJV.js} +1 -1
  45. package/dist/chunks/{chunk-PRGBLQVH.js → chunk-DIGX56JY.js} +1 -1
  46. package/dist/chunks/{chunk-JYKRR7E5.js → chunk-DISNCX6R.js} +1 -1
  47. package/dist/chunks/{chunk-773TH7FN.js → chunk-DK7IKI7O.js} +1 -1
  48. package/dist/chunks/{chunk-74IIXVAE.js → chunk-DX7YEUNQ.js} +1 -1
  49. package/dist/chunks/{chunk-523TE4BI.js → chunk-E63VWAQA.js} +1 -1
  50. package/dist/chunks/{chunk-5MCNZCVQ.js → chunk-EL454L26.js} +1 -1
  51. package/dist/chunks/{chunk-OS3LO5J3.js → chunk-ENSB6ZTM.js} +1 -1
  52. package/dist/chunks/{chunk-EAPFMACH.js → chunk-ERJV5BMC.js} +1 -1
  53. package/dist/chunks/{chunk-RNIAFXMB.js → chunk-EXJGCNRS.js} +1 -1
  54. package/dist/chunks/chunk-F5KCCDQM.js +2 -0
  55. package/dist/chunks/chunk-FSQWAANK.js +3 -0
  56. package/dist/chunks/{chunk-Z54O534A.js → chunk-G5B3PB5X.js} +1 -1
  57. package/dist/chunks/{chunk-4D7HWVWD.js → chunk-GAWGIJQG.js} +1 -1
  58. package/dist/chunks/{chunk-IIZ4CWBX.js → chunk-GGGF5NHJ.js} +1 -1
  59. package/dist/chunks/{chunk-APB4O67E.js → chunk-GOYBYYPQ.js} +1 -1
  60. package/dist/chunks/{chunk-XDQMGUWL.js → chunk-H3BSIAQO.js} +1 -1
  61. package/dist/chunks/{chunk-EYPCBBMS.js → chunk-HCEJAOIF.js} +1 -1
  62. package/dist/chunks/{chunk-OPNRWESL.js → chunk-IFQCOSU6.js} +1 -1
  63. package/dist/chunks/chunk-IJHZBHEK.js +9 -0
  64. package/dist/chunks/{chunk-RAXOSUSW.js → chunk-ISFIDCIH.js} +1 -1
  65. package/dist/chunks/{chunk-OLLLZVHF.js → chunk-ITKTILKI.js} +1 -1
  66. package/dist/chunks/{chunk-D74JEERO.js → chunk-IUBARBGI.js} +1 -1
  67. package/dist/chunks/{chunk-O72BSKSO.js → chunk-J24I74EM.js} +1 -1
  68. package/dist/chunks/{chunk-H4QHIHMK.js → chunk-J7QGHA7G.js} +3 -3
  69. package/dist/chunks/chunk-JFXINDOQ.js +3 -0
  70. package/dist/chunks/{chunk-HIOKCIL7.js → chunk-JGWINTT5.js} +1 -1
  71. package/dist/chunks/{chunk-Q2QL6UWN.js → chunk-JHEFWB6O.js} +1 -1
  72. package/dist/chunks/{chunk-QNG27G3T.js → chunk-JHMS2WXM.js} +2 -2
  73. package/dist/chunks/{chunk-PSGGOZFM.js → chunk-JHR3LF2F.js} +1 -1
  74. package/dist/chunks/{chunk-JE7RJZOA.js → chunk-KGLJU66U.js} +3 -3
  75. package/dist/chunks/{chunk-XEOEKFG6.js → chunk-KJFRCVQC.js} +1 -1
  76. package/dist/chunks/chunk-KNO355LC.js +2 -0
  77. package/dist/chunks/{chunk-ZGTOK7ZK.js → chunk-LD7PGREF.js} +2 -2
  78. package/dist/chunks/{chunk-I7AQMAQI.js → chunk-LHA7RQBA.js} +6 -6
  79. package/dist/chunks/{chunk-6QSSIT62.js → chunk-LO3O45IX.js} +1 -1
  80. package/dist/chunks/{chunk-G3RXYI2L.js → chunk-M2SKXY5C.js} +2 -2
  81. package/dist/chunks/{chunk-2IHO4GDJ.js → chunk-M3ZQDPRS.js} +1 -1
  82. package/dist/chunks/{chunk-JDEEWOD7.js → chunk-M4ZF44H5.js} +1 -1
  83. package/dist/chunks/{chunk-Y4OWBBDD.js → chunk-M55H7KVR.js} +1 -1
  84. package/dist/chunks/{chunk-JAJ46T5X.js → chunk-MGKMIRYG.js} +1 -1
  85. package/dist/chunks/{chunk-4EQA2M7K.js → chunk-MJGU2JJ2.js} +2 -2
  86. package/dist/chunks/{chunk-65PL62KH.js → chunk-MS37ISA4.js} +2 -2
  87. package/dist/chunks/{chunk-NH6UUX5S.js → chunk-NCKXI2VB.js} +11 -11
  88. package/dist/chunks/chunk-NHUUCNAD.js +2 -0
  89. package/dist/chunks/{chunk-O6ULLQJ6.js → chunk-O3VP46SE.js} +1 -1
  90. package/dist/chunks/chunk-O4FBOUNX.js +2 -0
  91. package/dist/chunks/chunk-O6IFVTZT.js +9 -0
  92. package/dist/chunks/{chunk-5IPFI25K.js → chunk-O7B44IYN.js} +1 -1
  93. package/dist/chunks/{chunk-DMVD2RFZ.js → chunk-OGMDEA3Y.js} +1 -1
  94. package/dist/chunks/{chunk-BLXEAZCQ.js → chunk-OKBIWRHC.js} +1 -1
  95. package/dist/chunks/{chunk-FFRFSDBM.js → chunk-ON2RNOCG.js} +1 -1
  96. package/dist/chunks/{chunk-LQQNBVEB.js → chunk-ONDCV5QC.js} +1 -1
  97. package/dist/chunks/{chunk-UCPGRPWY.js → chunk-OQ4VGCRG.js} +1 -1
  98. package/dist/chunks/{chunk-YNH3NMPF.js → chunk-OWK7HU5I.js} +1 -1
  99. package/dist/chunks/{chunk-DBK66CJP.js → chunk-OY5HC2P6.js} +1 -1
  100. package/dist/chunks/{chunk-T5AACNJI.js → chunk-P7HRF4FM.js} +1 -1
  101. package/dist/chunks/{chunk-7ED24PP6.js → chunk-PCNLC5H3.js} +1 -1
  102. package/dist/chunks/{chunk-ES2ISFJC.js → chunk-PF56N7ZY.js} +1 -1
  103. package/dist/chunks/{chunk-VVCKLCF3.js → chunk-PKALOVHC.js} +2 -2
  104. package/dist/chunks/{chunk-ZCHXGRRU.js → chunk-PR5TYTY4.js} +1 -1
  105. package/dist/chunks/{chunk-Q4TBTRIG.js → chunk-PWK5Z5S3.js} +1 -1
  106. package/dist/chunks/chunk-PXS4SVQG.js +16 -0
  107. package/dist/chunks/{chunk-AY64VY4E.js → chunk-QGOPYQW3.js} +1 -1
  108. package/dist/chunks/{chunk-7E6T7GP5.js → chunk-R7YEURUQ.js} +1 -1
  109. package/dist/chunks/{chunk-ACYFMLWG.js → chunk-RCA6NGVA.js} +2 -2
  110. package/dist/chunks/{chunk-DUURYZOI.js → chunk-RG3NH6YQ.js} +1 -1
  111. package/dist/chunks/{chunk-7SC46OFC.js → chunk-RJIUOLWY.js} +1 -1
  112. package/dist/chunks/{chunk-F4KOGISR.js → chunk-RXE3FYMJ.js} +1 -1
  113. package/dist/chunks/chunk-RYGWCN2R.js +2 -0
  114. package/dist/chunks/{chunk-VYLGI3IH.js → chunk-SFNCAPCJ.js} +1 -1
  115. package/dist/chunks/{chunk-Z4Z5UOZM.js → chunk-SG6JZ7HD.js} +1 -1
  116. package/dist/chunks/{chunk-XX6SMFDY.js → chunk-SKRNWRKV.js} +5 -5
  117. package/dist/chunks/{chunk-ZRDGQDZL.js → chunk-SLZH4Z6C.js} +1 -1
  118. package/dist/chunks/{chunk-WN3V6KDN.js → chunk-SPDSSMFD.js} +1 -1
  119. package/dist/chunks/chunk-STWRTNRK.js +2 -0
  120. package/dist/chunks/{chunk-HZEIRHEB.js → chunk-T5J7HIHR.js} +1 -1
  121. package/dist/chunks/{chunk-ROGF26KV.js → chunk-TBUAQWFS.js} +1 -1
  122. package/dist/chunks/{chunk-ZUJ3XUCP.js → chunk-TEPRCBDV.js} +1 -1
  123. package/dist/chunks/{chunk-HDGTHRY7.js → chunk-TOFMA2L5.js} +2 -2
  124. package/dist/chunks/{chunk-QOGJAQDO.js → chunk-UFHLLSCE.js} +1 -1
  125. package/dist/chunks/{chunk-TTVS6JMC.js → chunk-UJKQLO6B.js} +2 -2
  126. package/dist/chunks/{chunk-OQKJGTTO.js → chunk-UZQNFTLR.js} +1 -1
  127. package/dist/chunks/{chunk-F74GBN6K.js → chunk-V2HMWCT6.js} +1 -1
  128. package/dist/chunks/{chunk-6ZFPQYHG.js → chunk-V4KT5FCJ.js} +1 -1
  129. package/dist/chunks/{chunk-TVQAPBLZ.js → chunk-VHSX3JPX.js} +1 -1
  130. package/dist/chunks/{chunk-SDXFLO7J.js → chunk-W2SXOGTQ.js} +1 -1
  131. package/dist/chunks/{chunk-FUOEIDMA.js → chunk-WDEO44UN.js} +1 -1
  132. package/dist/chunks/{chunk-4NESNOK5.js → chunk-WEHBK3MC.js} +1 -1
  133. package/dist/chunks/{chunk-4EPSHPZL.js → chunk-WGX7WY4N.js} +1 -1
  134. package/dist/chunks/{chunk-NC27T4AB.js → chunk-WHREO7A2.js} +1 -1
  135. package/dist/chunks/{chunk-RNQF63ZR.js → chunk-WS2ZZBAQ.js} +4 -4
  136. package/dist/chunks/{chunk-DIO5CB6U.js → chunk-WYZWDMMF.js} +1 -1
  137. package/dist/chunks/{chunk-MQULU465.js → chunk-XO3H32KX.js} +1 -1
  138. package/dist/chunks/{chunk-EIRYMSEG.js → chunk-XQBIHPPX.js} +1 -1
  139. package/dist/chunks/chunk-XRKFTPHD.js +2 -0
  140. package/dist/chunks/{chunk-B7RFL4N2.js → chunk-XSCIOQYE.js} +1 -1
  141. package/dist/chunks/{chunk-TJ6GVTYB.js → chunk-XTWEWYK7.js} +9 -9
  142. package/dist/chunks/{chunk-JUHZ5S3R.js → chunk-Y3GIM6WK.js} +1 -1
  143. package/dist/chunks/{chunk-74ZXXBGN.js → chunk-Y54RKLOI.js} +1 -1
  144. package/dist/chunks/{chunk-SWUEFLOH.js → chunk-Y777GISF.js} +1 -1
  145. package/dist/chunks/{chunk-EKM2D7JU.js → chunk-YDU3S6UT.js} +1 -1
  146. package/dist/chunks/{chunk-UGL7WF3W.js → chunk-YOZIZYSC.js} +1 -1
  147. package/dist/chunks/{chunk-OSIO7PLX.js → chunk-YQKOB56U.js} +1 -1
  148. package/dist/chunks/chunk-YVNDDNMK.js +3 -0
  149. package/dist/chunks/chunk-ZAZKJJOT.js +86 -0
  150. package/dist/chunks/{chunk-QL4OIPEZ.js → chunk-ZR7LIMJS.js} +2 -2
  151. package/dist/chunks/{chunk-L3KCP52O.js → chunk-ZTJOOY2F.js} +1 -1
  152. package/dist/chunks/{chunk-GPVCOEUH.js → chunk-ZTVXRZ6D.js} +1 -1
  153. package/dist/chunks/cli-CNYNXKGQ.js +2 -0
  154. package/dist/chunks/configuration-command-5K7EE2J5.js +2 -0
  155. package/dist/chunks/connected-app-executor-E25XCNAS.js +2 -0
  156. package/dist/chunks/connected-evidence-QNSO5BTF.js +2 -0
  157. package/dist/chunks/connection-Y2KCMBYD.js +2 -0
  158. package/dist/chunks/{continual-6CQAMTTR.js → continual-SOO3QBNQ.js} +1 -1
  159. package/dist/chunks/core-commands-ZTWPYAFQ.js +2 -0
  160. package/dist/chunks/datasets-XPUMWGOC.js +2 -0
  161. package/dist/chunks/desktop-test-HVSW4JHY.js +3 -0
  162. package/dist/chunks/dist-4N6AHWNN.js +2 -0
  163. package/dist/chunks/{dist-OMGUJYPD.js → dist-N6R6VNFD.js} +1 -1
  164. package/dist/chunks/{dist-VYC5VMQB.js → dist-QN7WKZ2D.js} +1 -1
  165. package/dist/chunks/{enclave-QS4BUNDU.js → enclave-VURYNILU.js} +1 -1
  166. package/dist/chunks/evaluation-coordination-AOTFPVMS.js +2 -0
  167. package/dist/chunks/experiment-improvements-75CN3VI7.js +2 -0
  168. package/dist/chunks/experiments-AGAHM2AK.js +2 -0
  169. package/dist/chunks/{experiments-VFQGE4HC.js → experiments-DYSHYBGB.js} +1 -1
  170. package/dist/chunks/{extension-XKXXOP5N.js → extension-UT4CSDJF.js} +1 -1
  171. package/dist/chunks/help-KU52CFMW.js +8 -0
  172. package/dist/chunks/host-profile-evaluation-tools-LZDMQCMT.js +2 -0
  173. package/dist/chunks/host-profile-external-dataset-VK3NJHMC.js +2 -0
  174. package/dist/chunks/hosted-app-server-composition-P7V7K7CG.js +2 -0
  175. package/dist/chunks/{hosted-experiment-improvement-HVMDGS75.js → hosted-experiment-improvement-P433KDX2.js} +1 -1
  176. package/dist/chunks/hosted-harness-runtime-Y4DONWPC.js +2 -0
  177. package/dist/chunks/{hosted-profile-candidate-EXNN6MVN.js → hosted-profile-candidate-72MMPN6U.js} +1 -1
  178. package/dist/chunks/hosted-profile-compiler-RXHLK224.js +2 -0
  179. package/dist/chunks/hosted-profile-evaluation-control-LS4DCSDO.js +2 -0
  180. package/dist/chunks/{hosted-profile-evaluation-inspection-ZUANDYZ6.js → hosted-profile-evaluation-inspection-3Q6EHO66.js} +1 -1
  181. package/dist/chunks/{hosted-profile-evaluation-preparation-ORVZ6MBD.js → hosted-profile-evaluation-preparation-ZD27HNLF.js} +1 -1
  182. package/dist/chunks/{hosted-tasksets-ANAE2PIW.js → hosted-tasksets-V2PQZJN4.js} +1 -1
  183. package/dist/chunks/human-review-4FJFINQX.js +2 -0
  184. package/dist/chunks/import-GBHSLA3G.js +3 -0
  185. package/dist/chunks/{learning-ACEVFL5M.js → learning-U3FZL5YB.js} +1 -1
  186. package/dist/chunks/local-harness-improvement-runtime-UP2P7UT4.js +2 -0
  187. package/dist/chunks/local-harness-taskset-review-ZNOKSPJJ.js +2 -0
  188. package/dist/chunks/{local-scope-HVF2GZ5W.js → local-scope-62GWHDXS.js} +1 -1
  189. package/dist/chunks/{model-projects-QPO22JPA.js → model-projects-LQ4C6R3X.js} +1 -1
  190. package/dist/chunks/opchat-Q4PIWPYW.js +3 -0
  191. package/dist/chunks/organizations-TEH6HBQ3.js +2 -0
  192. package/dist/chunks/{profile-TFZMUEDR.js → profile-SWPVCGTR.js} +1 -1
  193. package/dist/chunks/{profile-training-source-6GOT7AHM.js → profile-training-source-J73ZLNSC.js} +1 -1
  194. package/dist/chunks/project-action-payload-OU3ZPHW7.js +2 -0
  195. package/dist/chunks/project-agent-J7ILCRBS.js +2 -0
  196. package/dist/chunks/{published-experiment-source-HVP5IGRH.js → published-experiment-source-HVHKSYDL.js} +1 -1
  197. package/dist/chunks/refiner-profile-service-E7YU4E3N.js +2 -0
  198. package/dist/chunks/{runtime-A7OZXM43.js → runtime-LIPHPKKJ.js} +2 -2
  199. package/dist/chunks/sandbox-command-G6KID3OP.js +2 -0
  200. package/dist/chunks/{sandbox-template-C4V6T36U.js → sandbox-template-MZTMAUFS.js} +1 -1
  201. package/dist/chunks/saved-work-LOUWLF37.js +2 -0
  202. package/dist/chunks/{send-turn-XTAIS2JN.js → send-turn-UEUEGY5W.js} +1 -1
  203. package/dist/chunks/{src-R36AGJY7.js → src-7WMZOWZZ.js} +107 -100
  204. package/dist/chunks/{src-DZL5T2MT.js → src-MVAK6D6Y.js} +1 -1
  205. package/dist/chunks/standalone-experiment-turn-owner-YRKEOEJ2.js +2 -0
  206. package/dist/chunks/{store-continual-support-reviews-LJPNG4SP.js → store-continual-support-reviews-FJLLNKCY.js} +1 -1
  207. package/dist/chunks/{store-conversation-serving-KPC62UEY.js → store-conversation-serving-4KWR4IZY.js} +1 -1
  208. package/dist/chunks/{store-create-improve-SW5FTBTL.js → store-create-improve-JWBJZRAU.js} +1 -1
  209. package/dist/chunks/{store-datasets-WMA7AJKN.js → store-datasets-4N2M6Y3K.js} +2 -2
  210. package/dist/chunks/{store-evaluation-results-ZO6R653G.js → store-evaluation-results-OBM4623U.js} +1 -1
  211. package/dist/chunks/{store-harness-memory-VINCZ4GK.js → store-harness-memory-4HUEMRCD.js} +1 -1
  212. package/dist/chunks/{store-harness-refinement-candidates-EA5KFQPH.js → store-harness-refinement-candidates-NMRWMN23.js} +1 -1
  213. package/dist/chunks/store-harness-workspaces-BGONIQDY.js +2 -0
  214. package/dist/chunks/{store-human-review-7QQ7ZQ6P.js → store-human-review-J75SIZAL.js} +1 -1
  215. package/dist/chunks/store-learned-preference-migration-validation-VLASM4CT.js +2 -0
  216. package/dist/chunks/store-learning-TUCQFBLT.js +2 -0
  217. package/dist/chunks/{store-learning-credentials-WZQJ4HPJ.js → store-learning-credentials-S4RF57NV.js} +1 -1
  218. package/dist/chunks/{store-local-experiments-SAULQSBN.js → store-local-experiments-LULRLTII.js} +5 -5
  219. package/dist/chunks/{store-model-batch-review-VKLDYGH3.js → store-model-batch-review-SVL4MT6D.js} +1 -1
  220. package/dist/chunks/{store-model-configuration-BYRJUR3C.js → store-model-configuration-ZHDSM3XM.js} +2 -2
  221. package/dist/chunks/{store-preference-comparison-LV32MHVL.js → store-preference-comparison-YMMCKXS5.js} +1 -1
  222. package/dist/chunks/{store-schedules-VGTEQVKH.js → store-schedules-6Z4QS3NU.js} +1 -1
  223. package/dist/chunks/{store-sidebar-file-bookmarks-VB5GTLFY.js → store-sidebar-file-bookmarks-MX6EP6OB.js} +2 -2
  224. package/dist/chunks/{store-sidebar-preferences-GWIOG2NH.js → store-sidebar-preferences-VYREPW26.js} +1 -1
  225. package/dist/chunks/{store-subagents-T7R2Z6TB.js → store-subagents-WGBCRALX.js} +1 -1
  226. package/dist/chunks/{store-task-inbox-QPE44OSS.js → store-task-inbox-43BNZSB7.js} +6 -6
  227. package/dist/chunks/{store-task-inventory-I3RDRI52.js → store-task-inventory-AEW4POAJ.js} +2 -2
  228. package/dist/chunks/{store-taskset-drafts-2IULRV2W.js → store-taskset-drafts-DKFO2CYB.js} +1 -1
  229. package/dist/chunks/{store-training-B2TW2MLA.js → store-training-6PFFR6ST.js} +1 -1
  230. package/dist/chunks/{store-training-jobs-VBNG23RL.js → store-training-jobs-ANDEBQ67.js} +2 -2
  231. package/dist/chunks/{store-training-models-OMV5FIC4.js → store-training-models-OOI4ZJPX.js} +2 -2
  232. package/dist/chunks/{store-usage-IE2U2FD3.js → store-usage-U72RNW64.js} +1 -1
  233. package/dist/chunks/{store-work-evidence-QQDKM5AQ.js → store-work-evidence-NY5OBATB.js} +1 -1
  234. package/dist/chunks/{taskset-EQRFQBYM.js → taskset-SL3YOXW7.js} +1 -1
  235. package/dist/chunks/{taskset-packages-XC6HEE3K.js → taskset-packages-3PCEYYDA.js} +1 -1
  236. package/dist/chunks/{teams-bot-EAPGPTHZ.js → teams-bot-IDEF3BMI.js} +1 -1
  237. package/dist/chunks/{training-UF6RPI4T.js → training-57ISIC7U.js} +1 -1
  238. package/dist/chunks/web-search-222Y63QW.js +2 -0
  239. package/dist/chunks/{workspaces-EKKE5NAC.js → workspaces-5DF4H5EX.js} +1 -1
  240. package/dist/cli.js +1 -1
  241. package/dist/index.js +1 -1
  242. package/dist/sandbox-template/manifest.js +1 -1
  243. package/dist/web/assets/{App-CaRMZoxo.css → App-DbYvV_W6.css} +1 -1
  244. package/dist/web/assets/App-nzE7JU_O.js +154 -0
  245. package/dist/web/assets/{AppDialog-t2Fx5tK3.js → AppDialog-VtNvqbDm.js} +1 -1
  246. package/dist/web/assets/{AppTerminalPanel-Dj1Y32oI.js → AppTerminalPanel-BMfKdrrN.js} +2 -2
  247. package/dist/web/assets/AppsView-CdWyrDEb.js +1 -0
  248. package/dist/web/assets/{BrowserSidebar-jhWi4rVm.js → BrowserSidebar-CtOIciOa.js} +1 -1
  249. package/dist/web/assets/{CartesianChart-C1DIx0Ia.js → CartesianChart-u1lvLM30.js} +1 -1
  250. package/dist/web/assets/{CollaborationTabs-Bdr-HmOL.js → CollaborationTabs-CaBfDYRW.js} +1 -1
  251. package/dist/web/assets/{CommandMenu-Ux2yOHAc.js → CommandMenu-CFW3WJ11.js} +1 -1
  252. package/dist/web/assets/{CommunityView-DPEeVKFn.js → CommunityView-D2EjaeuH.js} +1 -1
  253. package/dist/web/assets/ComposerCreateImproveStrip-6wYSJdzv.js +1 -0
  254. package/dist/web/assets/ConversationImportsSettings-BJ4QhF7p.js +1 -0
  255. package/dist/web/assets/ConversationImportsSettings-PfUa8V7X.css +1 -0
  256. package/dist/web/assets/{GetStartedView-CFHP0AaI.js → GetStartedView-DBcOwIJn.js} +1 -1
  257. package/dist/web/assets/{HostedModelLearningReview-D8BGTPVN.js → HostedModelLearningReview-BNpK6_W9.js} +1 -1
  258. package/dist/web/assets/{HostedModelLearningSettings-JS1S7vNO.js → HostedModelLearningSettings-SrsdeeoA.js} +1 -1
  259. package/dist/web/assets/{LabModelVersionDetailPage-Dx5Q3xV2.js → LabModelVersionDetailPage-Cd6bRHt9.js} +1 -1
  260. package/dist/web/assets/LabSkillSidebar-CQfvel4w.js +1 -0
  261. package/dist/web/assets/{LabsRoute-CyYF8-dw.js → LabsRoute-sXLJt1KR.js} +4 -4
  262. package/dist/web/assets/MainChatThread-dlDDK2JM.js +2 -0
  263. package/dist/web/assets/MainPane-DCz38-qy.js +65 -0
  264. package/dist/web/assets/{MarkdownText-BR4V6lNO.js → MarkdownText-Drjq6-JM.js} +1 -1
  265. package/dist/web/assets/{NativeSkillSidebar-DU9IEgIO.js → NativeSkillSidebar-jncZijt-.js} +1 -1
  266. package/dist/web/assets/{NewExperienceSwitcher-mIy6FzCj.js → NewExperienceSwitcher-DXKzoMaM.js} +1 -1
  267. package/dist/web/assets/{NewProjectDialog-RfTZTHxl.js → NewProjectDialog-DIyjAxJG.js} +1 -1
  268. package/dist/web/assets/OutputsPage-Dy1cNr3n.js +1 -0
  269. package/dist/web/assets/{ProjectsPage-CE6QUB-b.js → ProjectsPage-D2EeybIv.js} +1 -1
  270. package/dist/web/assets/RightChatPanelStack-4wUL-W9_.js +1 -0
  271. package/dist/web/assets/{RightSidebarHomePanel-CK0rP3WT.js → RightSidebarHomePanel-Bd_AHUp8.js} +1 -1
  272. package/dist/web/assets/{ScheduledWorkPage-vOrYv8pp.js → ScheduledWorkPage-BJkSzwz2.js} +1 -1
  273. package/dist/web/assets/{SettingsView-DCKVrfjj.js → SettingsView-BhcP72KH.js} +4 -4
  274. package/dist/web/assets/SettingsView-DjjnCnlb.css +1 -0
  275. package/dist/web/assets/{TeamChatView-Bwrjr-vk.js → TeamChatView-CR0fdicZ.js} +2 -2
  276. package/dist/web/assets/{TerminalOverlay-DhPoKZAq.js → TerminalOverlay-DGrZRZ_3.js} +10 -10
  277. package/dist/web/assets/TrainingCreationPanel-BsTG7aFS.js +1 -0
  278. package/dist/web/assets/{TrainingDraftPanel-C9cRX5qf.js → TrainingDraftPanel-ByErrht7.js} +1 -1
  279. package/dist/web/assets/{UsageSettingsSection-CrdcSGeW.js → UsageSettingsSection-DeYTJbcM.js} +1 -1
  280. package/dist/web/assets/{WorkSidebarPanel-DSSikNFQ.js → WorkSidebarPanel-DcNvEEoy.js} +1 -1
  281. package/dist/web/assets/{WorkspaceDiffPanel-BAFo0CPN.js → WorkspaceDiffPanel-CdPRcYWN.js} +3 -3
  282. package/dist/web/assets/{WorkspaceEnvironmentMenu-BVHAhwnJ.js → WorkspaceEnvironmentMenu-xUYg-iGn.js} +18 -18
  283. package/dist/web/assets/{WorkspaceGitDialogs-CwVoiDQ2.js → WorkspaceGitDialogs-CBViLL3S.js} +1 -1
  284. package/dist/web/assets/{WorkspaceMonacoEditor-TxLyhzNp.js → WorkspaceMonacoEditor-frxie2_S.js} +3 -3
  285. package/dist/web/assets/agent-connections-D7ao-vbU.js +1 -0
  286. package/dist/web/assets/{arrow-up-right-C9aE8Mfz.js → arrow-up-right-DCWPxdbD.js} +1 -1
  287. package/dist/web/assets/{chunk-P3BRSSRD-DUGfuKA8.js → chunk-P3BRSSRD-B5JXa0Nh.js} +1 -1
  288. package/dist/web/assets/{clipboard-Dk158Qp4.js → clipboard-B-GnMVLp.js} +1 -1
  289. package/dist/web/assets/{cloud-upload-k9eqBsHr.js → cloud-upload-DpaGFZ9J.js} +1 -1
  290. package/dist/web/assets/{cssMode-CO35ARZp.js → cssMode-DJHE7R3W.js} +1 -1
  291. package/dist/web/assets/{folder-open-sYgceW_f.js → folder-open-B-DFLDFH.js} +1 -1
  292. package/dist/web/assets/{folder-plus-CS0R49m9.js → folder-plus-CPXxPvSH.js} +1 -1
  293. package/dist/web/assets/{git-commit-horizontal-DrGxH2h4.js → git-commit-horizontal-DCTzcivA.js} +1 -1
  294. package/dist/web/assets/{htmlMode-REMmzdfq.js → htmlMode-DxZVBAYd.js} +1 -1
  295. package/dist/web/assets/index-BojtIRzO.css +1 -0
  296. package/dist/web/assets/{index-C8aCGagb.js → index-Di1MU6Xr.js} +2 -2
  297. package/dist/web/assets/{info-DLdbiUrh.js → info-BMxsR_bn.js} +1 -1
  298. package/dist/web/assets/{jsonMode-KEdMfkIf.js → jsonMode-CzWoMkpp.js} +1 -1
  299. package/dist/web/assets/{lspLanguageFeatures-5KZwEoxW.js → lspLanguageFeatures-15K7ND6Q.js} +1 -1
  300. package/dist/web/assets/{minimize-2-CqcI4zcM.js → minimize-2-DwUgqXoR.js} +1 -1
  301. package/dist/web/assets/{monaco.contribution-Cly9Wt7L.js → monaco.contribution-BBLKjER5.js} +2 -2
  302. package/dist/web/assets/{monaco.contribution-omszXBEj.js → monaco.contribution-DBjvSu8p.js} +2 -2
  303. package/dist/web/assets/{monaco.contribution-DO10L0zW.js → monaco.contribution-DUWvjhIG.js} +2 -2
  304. package/dist/web/assets/{monaco.contribution-BJGj65F9.js → monaco.contribution-w0zfkYLX.js} +2 -2
  305. package/dist/web/assets/{monitor-BFVCcbxp.js → monitor-Ihu5LVYx.js} +1 -1
  306. package/dist/web/assets/{play-C469pVZq.js → play-D_YGCdxU.js} +1 -1
  307. package/dist/web/assets/{python-Dw0YcVy9.js → python-Q4OuoXYc.js} +1 -1
  308. package/dist/web/assets/{save-CtSjPydi.js → save-DJYUOhtD.js} +1 -1
  309. package/dist/web/assets/{square-BuImvLhT.js → square-DXtoCBNw.js} +1 -1
  310. package/dist/web/assets/{toggleHighContrast-DjCO9lIP.js → toggleHighContrast-CaNeuWVE.js} +1 -1
  311. package/dist/web/assets/{tsMode-BAOnxKd6.js → tsMode-CJnQ2wmM.js} +1 -1
  312. package/dist/web/assets/{upload-2JkFZo3h.js → upload-fCP3_OEO.js} +1 -1
  313. package/dist/web/assets/{useLocalAgentSchedules-BNqAisfS.js → useLocalAgentSchedules-BFoH_gwZ.js} +1 -1
  314. package/dist/web/assets/useProviderSettings-2eysgqiA.js +5 -0
  315. package/dist/web/assets/{useProviderSettings-CmL_BaxP.css → useProviderSettings-Cktvzinz.css} +1 -1
  316. package/dist/web/assets/{useSessionTurnCache-BHU2-Jmz.js → useSessionTurnCache-DLF5SPD-.js} +1 -1
  317. package/dist/web/assets/{wifi-off-CpOAH62M.js → wifi-off-DZoiFrRz.js} +1 -1
  318. package/dist/web/assets/{workers-0QvlA2T5.js → workers-D5nr74M-.js} +1 -1
  319. package/dist/web/assets/{yaml-BK3qxo7D.js → yaml-CwsoTJmk.js} +1 -1
  320. package/dist/web/index.html +2 -2
  321. package/docs/command-reference.md +22 -3
  322. package/docs/conversation-imports.md +57 -0
  323. package/package.json +1 -1
  324. package/dist/chunks/app-server-harness-services-QMUOEYOA.js +0 -2
  325. package/dist/chunks/app-server-runtime-ISGGLQHU.js +0 -2
  326. package/dist/chunks/apps-BKTOR4F7.js +0 -2
  327. package/dist/chunks/chunk-3VUATFZD.js +0 -2
  328. package/dist/chunks/chunk-3Z47M3YY.js +0 -2
  329. package/dist/chunks/chunk-6UDGARFC.js +0 -143
  330. package/dist/chunks/chunk-FV2R5RUN.js +0 -3
  331. package/dist/chunks/chunk-HY3GOBFJ.js +0 -58
  332. package/dist/chunks/chunk-I3HZKJB3.js +0 -2
  333. package/dist/chunks/chunk-I3VVWNUW.js +0 -5
  334. package/dist/chunks/chunk-KG325WTN.js +0 -2
  335. package/dist/chunks/chunk-Q5LEXXJG.js +0 -16
  336. package/dist/chunks/chunk-QDC4OW3S.js +0 -2
  337. package/dist/chunks/chunk-SDAUS5PY.js +0 -2
  338. package/dist/chunks/chunk-VRIEKBBH.js +0 -9
  339. package/dist/chunks/chunk-WJ43MJ3F.js +0 -2
  340. package/dist/chunks/chunk-X2HIHF2I.js +0 -2
  341. package/dist/chunks/chunk-YBT2NB32.js +0 -2
  342. package/dist/chunks/chunk-ZTNHW2K7.js +0 -10
  343. package/dist/chunks/cli-XZENDZ7Z.js +0 -2
  344. package/dist/chunks/configuration-command-6C5UO7GE.js +0 -2
  345. package/dist/chunks/connected-app-executor-LQNIU5NR.js +0 -2
  346. package/dist/chunks/connected-evidence-GH2ATNEX.js +0 -2
  347. package/dist/chunks/connection-HTF6CC7M.js +0 -2
  348. package/dist/chunks/core-commands-A2DGGIPS.js +0 -2
  349. package/dist/chunks/datasets-7BNMVJOY.js +0 -2
  350. package/dist/chunks/desktop-test-3CUHVLXV.js +0 -3
  351. package/dist/chunks/dist-ZVJPJLXR.js +0 -2
  352. package/dist/chunks/evaluation-coordination-XEF5L7KZ.js +0 -2
  353. package/dist/chunks/experiment-improvements-KRX2DP27.js +0 -2
  354. package/dist/chunks/experiments-DFGQYA4O.js +0 -2
  355. package/dist/chunks/help-S7THC6IE.js +0 -8
  356. package/dist/chunks/host-profile-evaluation-tools-JOFBL5OF.js +0 -2
  357. package/dist/chunks/host-profile-external-dataset-K3ICDHIP.js +0 -2
  358. package/dist/chunks/hosted-app-server-composition-T5IWGOTA.js +0 -2
  359. package/dist/chunks/hosted-harness-runtime-YCKB6NBI.js +0 -2
  360. package/dist/chunks/hosted-profile-compiler-IYLLHCRY.js +0 -2
  361. package/dist/chunks/hosted-profile-evaluation-control-TJVER3NW.js +0 -2
  362. package/dist/chunks/human-review-WR777ODH.js +0 -2
  363. package/dist/chunks/import-MLZUHITH.js +0 -4
  364. package/dist/chunks/local-harness-improvement-runtime-QRFGPFRM.js +0 -2
  365. package/dist/chunks/local-harness-taskset-review-HR7KLY4B.js +0 -2
  366. package/dist/chunks/opchat-T4QTNEIY.js +0 -3
  367. package/dist/chunks/organizations-75L5DZDV.js +0 -2
  368. package/dist/chunks/project-action-payload-JDS6OQAW.js +0 -2
  369. package/dist/chunks/project-agent-6RRO233B.js +0 -2
  370. package/dist/chunks/refiner-profile-service-FDTQKY33.js +0 -2
  371. package/dist/chunks/sandbox-command-IU5XFTJP.js +0 -2
  372. package/dist/chunks/saved-work-SHEEDZ6Z.js +0 -2
  373. package/dist/chunks/standalone-experiment-turn-owner-JCY5LL5R.js +0 -2
  374. package/dist/chunks/store-harness-workspaces-XUM4Z66X.js +0 -2
  375. package/dist/chunks/store-learned-preference-migration-validation-NADPXOTG.js +0 -2
  376. package/dist/chunks/store-learning-WLG6KFIO.js +0 -2
  377. package/dist/chunks/web-search-CZ3NCLPY.js +0 -2
  378. package/dist/web/assets/App-s-CJswyt.js +0 -154
  379. package/dist/web/assets/AppsView-BYE5EBDJ.js +0 -1
  380. package/dist/web/assets/ComposerCreateImproveStrip-CEgh4OtN.js +0 -1
  381. package/dist/web/assets/LabSkillSidebar-BxffN-pN.js +0 -1
  382. package/dist/web/assets/MainChatThread-DZpcFRFl.js +0 -2
  383. package/dist/web/assets/MainPane-5DTtwVCk.js +0 -65
  384. package/dist/web/assets/OutputsPage-Cr1Spf7S.js +0 -1
  385. package/dist/web/assets/RightChatPanelStack-T6VRWuHo.js +0 -1
  386. package/dist/web/assets/SettingsView-Dulr_xlq.css +0 -1
  387. package/dist/web/assets/TrainingCreationPanel-BXHfohNm.js +0 -1
  388. package/dist/web/assets/index-3iPNbbER.css +0 -1
  389. package/dist/web/assets/useProviderSettings-C4L4wDoh.js +0 -5
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as Me,b as Be}from"./chunk-65PL62KH.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=`
2
+ import{a as Me,b as Be}from"./chunk-MS37ISA4.js";import{b as Te}from"./chunk-DK7IKI7O.js";import{c as Le}from"./chunk-AN525SPP.js";import{a as te,c as ae}from"./chunk-WDEO44UN.js";import{a as _e,b as De}from"./chunk-5RHYSQZ5.js";import{b as Oe}from"./chunk-XW6HGSIT.js";import{g as Ie,j as ne}from"./chunk-6GWOVHIG.js";import{d as ee,e as xe,f as Pe,g as qe}from"./chunk-QGOPYQW3.js";import{d as Se,f as Ae,h as Ce}from"./chunk-BK63OQRW.js";import{m as D}from"./chunk-BIPQCJ5V.js";import{A as C}from"./chunk-PF56N7ZY.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
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(`
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 Te({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
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
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};
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 Oe("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=Le(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};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{b as f}from"./chunk-ES2ISFJC.js";import{a as c}from"./chunk-FTQLQJQV.js";import{promises as K}from"node:fs";import k from"node:path";function _(t){return!!(t&&typeof t=="object"&&t.kind==="openpond-project-action"&&typeof t.id=="string"&&typeof t.run=="function")}c(_,"isProjectActionDefinition");var I="openpond/project-actions.json",G=f.object({values:f.record(f.string(),f.unknown()).optional().default({}),environment:f.record(f.string(),f.string().trim().min(1)).optional().default({})}).strict(),q=f.object({sourceDirectory:f.string().trim().min(1).optional(),outputDirectory:f.string().trim().min(1).optional(),environment:f.record(f.string(),f.string().trim().min(1)).optional().default({}),connections:f.record(f.string(),G).optional().default({})}).strict();async function R(t){let r=k.resolve(t),e=k.join(r,I),o=await K.readFile(e,"utf8").catch(n=>{if(n.code==="ENOENT")return null;throw n});if(o===null)return q.parse({});let s;try{s=JSON.parse(o)}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`${I} is not valid JSON: ${i}`)}return q.parse(s)}c(R,"loadProjectActionConfiguration");function C(t,r=process.env){let e={};for(let[s,n]of Object.entries(t.environment)){let i=r[n];i!==void 0&&(e[s]=i)}let o={};for(let[s,n]of Object.entries(t.connections)){let i={...n.values};for(let[u,a]of Object.entries(n.environment)){let p=r[a];p!==void 0&&(i[u]=p)}o[s]=i}return{environment:e,connections:o}}c(C,"resolveProjectActionRuntime");import{randomUUID as x}from"node:crypto";import{spawn as Z}from"node:child_process";import{promises as E}from"node:fs";import m from"node:path";import{promises as v}from"node:fs";import l from"node:path";import{fileURLToPath as X,pathToFileURL as Y}from"node:url";import{build as Q}from"esbuild";import{promises as z}from"node:fs";import P from"node:path";import{createHash as ct}from"node:crypto";import{promises as at}from"node:fs";import{createRequire as ut}from"node:module";import O from"node:path";function J(t){return f.toJSONSchema(t,{unrepresentable:"any"})}c(J,"projectActionJsonSchema");function tt(t){let r=[],e=new Set,o=c(n=>{if(!e.has(n)){if(n&&(typeof n=="object"||typeof n=="function")&&e.add(n),_(n)){r.push(n);return}if(Array.isArray(n)){n.forEach(o);return}n&&typeof n=="object"&&Object.values(n).forEach(o)}},"visit");t.forEach(o);let s=new Map;for(let n of r){if(s.has(n.id))throw new Error(`Duplicate Project Action id: ${n.id}`);s.set(n.id,n)}return[...s.values()].sort((n,i)=>n.id.localeCompare(i.id))}c(tt,"collectProjectActions");function et(t){return{schemaVersion:"openpond.projectActionRegistry.v1",actions:t.map(ot)}}c(et,"createProjectActionRegistry");function ot(t){return{id:t.id,sourceActionId:t.id,name:t.id,label:t.label,description:t.description,visibility:"default",inputSchema:J(t.inputSchema),outputSchema:J(t.outputSchema),approvalPolicy:{...t.approval,required:t.approval.mode==="always"||t.approval.mode==="sensitive"||t.approval.mode==="writes"&&t.behavior==="write",risk:t.behavior},artifactPolicy:{outputArtifacts:[],persistRunSummary:!0,persistTrace:!0},setupRequirements:[...t.setup],mcp:{enabled:!1},schedulePolicy:{enabled:!1,allowAdHoc:!0},trace:{name:t.id,namespace:"project-actions"},implementation:{type:"openpond-project-action",actionId:t.id,behavior:t.behavior,timeoutMs:t.timeoutMs,concurrency:t.concurrency},invokesModel:t.invokesModel}}c(ot,"toCatalogEntry");var rt=/\.(?:[cm]?[jt]s)$/i,nt=/(?:\.d\.ts|\.test\.[cm]?[jt]s|\.spec\.[cm]?[jt]s)$/i;async function it(t){let r=P.resolve(t.projectRoot),e=P.resolve(r,t.sourceDirectory??"openpond/actions");if(!st(r,e))throw new Error("Project Action source directory must stay inside the Project root.");if(!(await z.stat(e).catch(()=>null))?.isDirectory())throw new Error(`Project Action source directory does not exist: ${e}`);let n=(await B(e)).filter(i=>rt.test(i)&&!nt.test(i)).map(i=>P.relative(r,i).split(P.sep).join("/")).sort();if(n.length===0)throw new Error(`No Project Action files were found under ${e}.`);return{projectRoot:r,sourceRoot:e,files:n}}c(it,"discoverProjectActionFiles");async function B(t){let r=await z.readdir(t,{withFileTypes:!0}),e=[];for(let o of r.sort((s,n)=>s.name.localeCompare(n.name))){if(o.name.startsWith(".")||o.name==="node_modules")continue;let s=P.join(t,o.name);o.isDirectory()?e.push(...await B(s)):o.isFile()&&e.push(s)}return e}c(B,"walk");function st(t,r){let e=P.relative(t,r);return e===""||!e.startsWith("..")&&!P.isAbsolute(e)}c(st,"isWithin");function L(t){return ct("sha256").update(t).digest("hex")}c(L,"sha256");function M(t){return`${JSON.stringify(N(t),null,2)}
2
+ import{A as f}from"./chunk-PF56N7ZY.js";import{a as c}from"./chunk-FTQLQJQV.js";import{promises as K}from"node:fs";import k from"node:path";function _(t){return!!(t&&typeof t=="object"&&t.kind==="openpond-project-action"&&typeof t.id=="string"&&typeof t.run=="function")}c(_,"isProjectActionDefinition");var I="openpond/project-actions.json",G=f.object({values:f.record(f.string(),f.unknown()).optional().default({}),environment:f.record(f.string(),f.string().trim().min(1)).optional().default({})}).strict(),q=f.object({sourceDirectory:f.string().trim().min(1).optional(),outputDirectory:f.string().trim().min(1).optional(),environment:f.record(f.string(),f.string().trim().min(1)).optional().default({}),connections:f.record(f.string(),G).optional().default({})}).strict();async function R(t){let r=k.resolve(t),e=k.join(r,I),o=await K.readFile(e,"utf8").catch(n=>{if(n.code==="ENOENT")return null;throw n});if(o===null)return q.parse({});let s;try{s=JSON.parse(o)}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`${I} is not valid JSON: ${i}`)}return q.parse(s)}c(R,"loadProjectActionConfiguration");function C(t,r=process.env){let e={};for(let[s,n]of Object.entries(t.environment)){let i=r[n];i!==void 0&&(e[s]=i)}let o={};for(let[s,n]of Object.entries(t.connections)){let i={...n.values};for(let[u,a]of Object.entries(n.environment)){let p=r[a];p!==void 0&&(i[u]=p)}o[s]=i}return{environment:e,connections:o}}c(C,"resolveProjectActionRuntime");import{randomUUID as x}from"node:crypto";import{spawn as Z}from"node:child_process";import{promises as E}from"node:fs";import m from"node:path";import{promises as v}from"node:fs";import l from"node:path";import{fileURLToPath as X,pathToFileURL as Y}from"node:url";import{build as Q}from"esbuild";import{promises as z}from"node:fs";import P from"node:path";import{createHash as ct}from"node:crypto";import{promises as at}from"node:fs";import{createRequire as ut}from"node:module";import O from"node:path";function J(t){return f.toJSONSchema(t,{unrepresentable:"any"})}c(J,"projectActionJsonSchema");function tt(t){let r=[],e=new Set,o=c(n=>{if(!e.has(n)){if(n&&(typeof n=="object"||typeof n=="function")&&e.add(n),_(n)){r.push(n);return}if(Array.isArray(n)){n.forEach(o);return}n&&typeof n=="object"&&Object.values(n).forEach(o)}},"visit");t.forEach(o);let s=new Map;for(let n of r){if(s.has(n.id))throw new Error(`Duplicate Project Action id: ${n.id}`);s.set(n.id,n)}return[...s.values()].sort((n,i)=>n.id.localeCompare(i.id))}c(tt,"collectProjectActions");function et(t){return{schemaVersion:"openpond.projectActionRegistry.v1",actions:t.map(ot)}}c(et,"createProjectActionRegistry");function ot(t){return{id:t.id,sourceActionId:t.id,name:t.id,label:t.label,description:t.description,visibility:"default",inputSchema:J(t.inputSchema),outputSchema:J(t.outputSchema),approvalPolicy:{...t.approval,required:t.approval.mode==="always"||t.approval.mode==="sensitive"||t.approval.mode==="writes"&&t.behavior==="write",risk:t.behavior},artifactPolicy:{outputArtifacts:[],persistRunSummary:!0,persistTrace:!0},setupRequirements:[...t.setup],mcp:{enabled:!1},schedulePolicy:{enabled:!1,allowAdHoc:!0},trace:{name:t.id,namespace:"project-actions"},implementation:{type:"openpond-project-action",actionId:t.id,behavior:t.behavior,timeoutMs:t.timeoutMs,concurrency:t.concurrency},invokesModel:t.invokesModel}}c(ot,"toCatalogEntry");var rt=/\.(?:[cm]?[jt]s)$/i,nt=/(?:\.d\.ts|\.test\.[cm]?[jt]s|\.spec\.[cm]?[jt]s)$/i;async function it(t){let r=P.resolve(t.projectRoot),e=P.resolve(r,t.sourceDirectory??"openpond/actions");if(!st(r,e))throw new Error("Project Action source directory must stay inside the Project root.");if(!(await z.stat(e).catch(()=>null))?.isDirectory())throw new Error(`Project Action source directory does not exist: ${e}`);let n=(await B(e)).filter(i=>rt.test(i)&&!nt.test(i)).map(i=>P.relative(r,i).split(P.sep).join("/")).sort();if(n.length===0)throw new Error(`No Project Action files were found under ${e}.`);return{projectRoot:r,sourceRoot:e,files:n}}c(it,"discoverProjectActionFiles");async function B(t){let r=await z.readdir(t,{withFileTypes:!0}),e=[];for(let o of r.sort((s,n)=>s.name.localeCompare(n.name))){if(o.name.startsWith(".")||o.name==="node_modules")continue;let s=P.join(t,o.name);o.isDirectory()?e.push(...await B(s)):o.isFile()&&e.push(s)}return e}c(B,"walk");function st(t,r){let e=P.relative(t,r);return e===""||!e.startsWith("..")&&!P.isAbsolute(e)}c(st,"isWithin");function L(t){return ct("sha256").update(t).digest("hex")}c(L,"sha256");function M(t){return`${JSON.stringify(N(t),null,2)}
3
3
  `}c(M,"canonicalJson");function N(t){return Array.isArray(t)?t.map(N):!t||typeof t!="object"?t:Object.fromEntries(Object.entries(t).sort(([r],[e])=>r.localeCompare(e)).map(([r,e])=>[r,N(e)]))}c(N,"sortValue");async function W(t,r){for(let e of r)if(e.required!==!1){if(e.kind==="package")try{ut(O.join(t,"package.json")).resolve(e.name)}catch{throw new Error(`Project Action package is not installed: ${e.name}`)}if(e.kind==="native_tool"&&!await ft(e.name))throw new Error(`Project Action native tool is not installed: ${e.name}`)}}c(W,"validateProjectActionStaticSetup");async function lt(t,r,e){await W(t,r);for(let o of r)if(o.required!==!1){if(o.kind==="connection"&&!(o.name in(e.connections??{})))throw new Error(`Project Action connection is not configured: ${o.name}`);if(o.kind==="env"&&!(o.name in(e.environment??{})))throw new Error(`Project Action environment value is not configured: ${o.name}`)}}c(lt,"validateProjectActionRunSetup");async function ft(t){if(!t.trim()||t.includes("/")||t.includes("\\"))return!1;for(let r of(process.env.PATH??"").split(O.delimiter).filter(Boolean)){let e=process.platform==="win32"?(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").map(o=>O.join(r,`${t}${o}`)):[O.join(r,t)];for(let o of e)if(await at.access(o).then(()=>!0).catch(()=>!1))return!0}return!1}c(ft,"executableExists");var H=".openpond/actions";async function dt(t){let r=await R(t.projectRoot),e=await it({projectRoot:t.projectRoot,sourceDirectory:t.sourceDirectory??r.sourceDirectory}),o=l.resolve(e.projectRoot,t.outputDirectory??r.outputDirectory??H);mt(e.projectRoot,o),await v.mkdir(o,{recursive:!0});let s=l.join(o,"entry.mjs"),n=l.join(o,"bundle.mjs"),i=l.join(o,"runner.mjs"),u=l.join(o,"action-registry.json"),a=l.join(o,"build-manifest.json"),p=e.files.map((h,A)=>{let T=l.relative(o,l.join(e.projectRoot,h)).split(l.sep).join("/"),V=T.startsWith(".")?T:`./${T}`;return`import * as actionModule${A} from ${JSON.stringify(V)};`}),d=e.files.map((h,A)=>`actionModule${A}`).join(", ");await v.writeFile(s,[...p,`export const projectActionModules = [${d}];`,"export default projectActionModules;",""].join(`
4
4
  `),"utf8"),await Q({entryPoints:[s],outfile:n,bundle:!0,platform:"node",format:"esm",target:"node22.14",sourcemap:!1,legalComments:"none",logLevel:"silent",nodePaths:pt(e.projectRoot)});let g=`openpond_action_build=${Date.now()}_${Math.random().toString(16).slice(2)}`,w=await import(`${Y(n).href}?${g}`),$=tt(w.projectActionModules??w.default??[]);for(let h of $)await W(e.projectRoot,h.setup);let j=et($);await v.writeFile(u,M(j),"utf8"),await v.writeFile(i,ht(),{encoding:"utf8",mode:493});let D=L(await v.readFile(n)),b=L(M(j)),y={schemaVersion:"openpond.projectActionBuild.v1",sourceDirectory:l.relative(e.projectRoot,e.sourceRoot).split(l.sep).join("/"),sourceFiles:e.files,bundleFile:l.basename(n),runnerFile:l.basename(i),registryFile:l.basename(u),bundleHash:D,registryHash:b};return await v.writeFile(a,M(y),"utf8"),await v.rm(s,{force:!0}),{projectRoot:e.projectRoot,outputDirectory:o,bundlePath:n,runnerPath:i,registryPath:u,manifestPath:a,registry:j,manifest:y}}c(dt,"buildProjectActions");function pt(t){let r=[],e=t;for(;;){r.push(l.join(e,"node_modules"));let o=l.dirname(e);if(o===e)break;e=o}return r.push(l.resolve(l.dirname(X(import.meta.url)),"../../../node_modules")),[...new Set(r)]}c(pt,"dependencySearchPaths");function mt(t,r){let e=l.relative(t,r);if(e.startsWith("..")||l.isAbsolute(e))throw new Error("Project Action output directory must stay inside the Project root.")}c(mt,"assertWithinProject");function ht(){return`#!/usr/bin/env node
5
5
  import { promises as fs } from "node:fs";
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{Cb as z,Db as U,Fb as F,Kb as G,Lb as Q,Mb as W,Nb as P,W as S,Z as J,_ as K,ba as q,h as R}from"./chunk-RCA6NGVA.js";import{f as $,m as r}from"./chunk-BIPQCJ5V.js";import{A as e}from"./chunk-PF56N7ZY.js";import{a as I}from"./chunk-FTQLQJQV.js";var X=e.object({schemaVersion:e.literal("openpond.humanResultView.v1"),executionId:e.string().min(1),executionHash:e.string().regex(/^[a-f0-9]{64}$/),selection:e.array(S).max(1e4),coverage:e.object({pending:e.number().int().nonnegative(),submitted:e.number().int().nonnegative(),accepted:e.number().int().nonnegative(),rejected:e.number().int().nonnegative(),cancelled:e.number().int().nonnegative()}).strict(),results:e.array(e.object({review:S,decision:S.nullable(),attemptIds:e.array(e.string().min(1)).min(1).max(2),mode:e.enum(["individual","pairwise"]),origin:e.enum(["hosted_retained","recorded_evidence","owner_attested_local","native_local"]),status:e.enum(["pending","submitted","accepted","rejected","cancelled"]),grader:S,answers:e.array(J).max(100)}).strict()).max(1e4)}).strict(),M=X.extend({contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict();function Y(o){let m=o.reviews.map(s=>{let i=K.parse(s),{contentHash:p,...f}=i;if(r(f)!==p||!i.evidence.attempts.some(v=>v.experimentId===o.executionId))throw new R("human_result_selection_mismatch",409);return i});if(new Set(m.map(s=>s.id)).size!==m.length)throw new R("human_result_duplicate_review",422);let n=m.map(s=>{let i=s.decisions.at(-1);return{review:{id:s.id,revision:s.revision,contentHash:s.contentHash},decision:i?{id:i.id,revision:i.revision,contentHash:i.contentHash}:null,attemptIds:s.evidence.attempts.map(p=>p.attemptId),mode:s.form.mode,origin:s.evidence.attempts.some(p=>p.localSource?.kind==="owner_attested_local")?"owner_attested_local":s.evidence.attempts.some(p=>p.localSource?.kind==="native_local")?"native_local":s.evidence.attempts.some(p=>p.recordedSource)?"recorded_evidence":"hosted_retained",status:s.status==="accepted"?"accepted":s.status==="rejected"?"rejected":s.status==="cancelled"?"cancelled":s.status==="submitted"?"submitted":"pending",grader:s.evidence.grader,answers:s.status==="accepted"&&i?.outcome==="accept"?i.answers:[]}}),y={pending:0,submitted:0,accepted:0,rejected:0,cancelled:0};for(let s of n)y[s.status]++;return M.parse(q(X.parse({schemaVersion:"openpond.humanResultView.v1",executionId:o.executionId,executionHash:o.executionHash,selection:n.map(s=>s.review),coverage:y,results:n})))}I(Y,"createHumanResultView");function Z(o,m){let n=K.parse(o),{contentHash:y,...s}=n,i=n.decisions.at(-1);if(y!==r(s)||y!==m.reviewHash||n.status!=="accepted"||!i||i.outcome!=="accept"||i.contentHash!==m.decisionHash)throw new R("human_accepted_revision_unavailable",409);let p=i.submissions.map(f=>{let v=n.submissions.find(w=>w.id===f.id&&w.contentHash===f.contentHash);if(!v||v.evidenceHash!==r(n.evidence)||v.formHash!==r(n.form))throw new R("human_accepted_lineage_invalid",409);return{id:v.id,revision:v.revision,contentHash:v.contentHash}});return{schemaVersion:"openpond.acceptedHumanEvidence.v1",scope:n.scope,projectId:n.projectId,review:{id:n.id,revision:n.revision,contentHash:y},sourceOrigins:n.evidence.attempts.map(f=>f.localSource?f.localSource.kind:f.recordedSource?"recorded_evidence":"hosted_retained"),decision:{id:i.id,revision:i.revision,contentHash:i.contentHash},submissions:p,evidence:n.evidence,answers:i.answers,...n.execution?.result?{execution:{id:n.execution.executionId,result:n.execution.result,configurationHash:n.execution.configurationHash}}:{},...i.taskProposalHash?{taskProposal:n.submissions.find(f=>f.taskProposal?.contentHash===i.taskProposalHash).taskProposal}:{}}}I(Z,"acceptedHumanEvidence");var T=e.string().regex(/^[a-f0-9]{64}$/),V=e.string().min(1).max(240),L={feedbackKey:V,criterionId:V},he=e.discriminatedUnion("kind",[e.object({...L,kind:e.literal("normalized_score"),minimum:e.number().finite(),maximum:e.number().finite(),passThreshold:e.number().min(0).max(1).optional()}).strict(),e.object({...L,kind:e.literal("boolean")}).strict(),e.object({...L,kind:e.literal("category")}).strict(),e.object({...L,kind:e.literal("preference_score"),tieScore:e.number().min(0).max(1).nullable()}).strict()]),ee=e.object({execution:$,resultHash:T,reviews:e.array(e.object({review:S,decision:S}).strict()).min(1).max(1e4)}).strict(),ie=e.object({rules:e.array(he).min(1).max(100),baseline:ee,candidate:ee}).strict().superRefine((o,m)=>{new Set(o.rules.map(n=>n.feedbackKey)).size!==o.rules.length&&m.addIssue({code:"custom",message:"Select each Human feedback key once."})}),ne=e.object({manifest:F,result:G}).strict(),te=e.object({id:V,manifestHash:T,resultHash:T}).strict(),ae=e.object({schemaVersion:e.literal("openpond.humanComparisonProjection.v1"),teamId:V,projectId:V,selections:ie,original:e.object({baseline:te,candidate:te}).strict(),humanResults:e.object({baseline:M,candidate:M}).strict(),baseline:ne,candidate:ne}).strict(),se=ae.extend({contentHash:T}).strict();function d(o){throw new R(o,409)}I(d,"fail");async function Ve(o){let m=ie.parse(o.selections);await o.authorize();let n={baseline:P(o.baseline),candidate:P(o.candidate)},y=new Set([m.baseline.execution.id,m.candidate.execution.id]);y.size!==2&&d("human_comparison_distinct_executions_required");let s=0;async function i(H){let l=n[H],j=m[H],_=l.manifest.lineage?.execution;l.manifest.lineage?.humanProjection&&d("human_comparison_recursive_projection"),(!_||r(_)!==r(j.execution)||l.manifest.teamId!==o.teamId)&&d("human_comparison_execution_changed");let E=[],A=new Map;for(let a of j.reviews){let t=await o.readReview(a.review);(t.scope!==o.teamId||t.projectId!==o.projectId||t.kind!=="grade"||t.revision!==a.review.revision||t.id!==a.review.id)&&d("human_comparison_review_scope_changed");let b=Z(t,{reviewHash:a.review.contentHash,decisionHash:a.decision.contentHash});s+=new TextEncoder().encode(JSON.stringify({answers:b.answers,form:t.form})).byteLength,s>4194304&&d("human_comparison_projection_too_large"),r(b.decision)!==r(a.decision)&&d("human_comparison_decision_changed"),t.evidence.attempts.some(k=>!y.has(k.experimentId))&&d("human_comparison_foreign_attempt");let u=t.evidence.attempts.filter(k=>k.experimentId===_.id);u.length!==1&&d("human_comparison_attempt_ambiguous");let c=u[0],g=await o.caseIdentity(c),h=l.result.cases.find(k=>z(k.identity)===z(g));(!h||g.caseId!==c.taskId||!h.traceRef||h.traceRef.contentHash!==c.trace?.contentHash||h.output===null)&&d("human_comparison_receipt_changed");let x=z(g)+":"+t.evidence.grader.id;A.has(x)&&d("human_comparison_duplicate_assessment"),A.set(x,{review:t,accepted:b,attempt:c}),E.push(t)}let D=Y({executionId:_.id,executionHash:_.contentHash,reviews:E});(D.contentHash!==j.resultHash||D.coverage.accepted!==E.length)&&d("human_comparison_result_changed");let N=new Map(m.rules.map(a=>[a.feedbackKey,a])),oe=l.manifest.evaluators.map(a=>{let t=N.get(a.feedbackKey);if(!t)return a;let b=E.filter(c=>c.evidence.grader.id===a.release.id&&String(c.evidence.grader.revision)===String(a.release.revision)&&c.evidence.grader.contentHash===a.release.contentHash).map(c=>c.form);(!b.length||new Set(b.map(r)).size!==1)&&d("human_comparison_form_changed");let u=b[0].criteria.find(c=>c.id===t.criterionId);return u||d("human_comparison_criterion_unavailable"),(t.kind==="normalized_score"&&(u.kind!=="score"||t.minimum!==u.minimum||t.maximum!==u.maximum||t.maximum<=t.minimum)||t.kind==="boolean"&&u.kind!=="boolean"||t.kind==="category"&&u.kind!=="category"||t.kind==="preference_score"&&(u.kind!=="preference"||b[0].mode!=="pairwise"))&&d("human_comparison_rule_changed"),{...a,output:t.kind==="boolean"?"boolean":t.kind==="category"?"category":"score",categories:u.kind==="category"?u.options:[],configurationHash:r({original:a.configurationHash,rule:t,formHash:r(b[0])})}});m.rules.some(a=>!l.manifest.evaluators.some(t=>t.feedbackKey===a.feedbackKey))&&d("human_comparison_grader_unavailable");let{contentHash:ce,...re}=l.manifest,C={originalManifest:{id:l.manifest.id,contentHash:l.manifest.contentHash},selectionHash:r(j),rulesHash:r(m.rules)},B=Q({...re,id:U(C.originalManifest,C.selectionHash,C.rulesHash),lineage:{...l.manifest.lineage,humanProjection:C},evaluators:oe}),de=l.result.cases.map(a=>{let t=a.feedback.map(u=>{let c=N.get(u.feedbackKey);if(!c)return u;let g=A.get(z(a.identity)+":"+u.evaluator.id);(!g||g.review.evidence.grader.contentHash!==u.evaluator.contentHash)&&d("human_comparison_assessment_missing");let h=g.accepted.answers.find(k=>k.criterionId===c.criterionId),x=null;if(h&&!h.abstain&&(c.kind==="normalized_score"&&typeof h.value=="number"&&(x=(h.value-c.minimum)/(c.maximum-c.minimum)),c.kind==="boolean"&&typeof h.value=="boolean"&&(x=h.value),c.kind==="category"&&typeof h.value=="string"&&(x=h.value),c.kind==="preference_score")){let k=g.review.evidence.attempts.findIndex(O=>O.experimentId===_.id&&O.attemptId===g.attempt.attemptId);x=h.value==="tie"?c.tieScore:h.value==="A"||h.value==="B"?h.value===(k===0?"A":"B")?1:0:null}return{...u,status:x===null?"unavailable":"scored",value:x,passed:x===null?null:c.kind==="boolean"?x:c.kind==="normalized_score"&&c.passThreshold!==void 0?Number(x)>=c.passThreshold:null,reasoning:h?.note??null,evidenceRefs:[{id:g.accepted.review.id,contentHash:g.accepted.review.contentHash,mediaType:"application/vnd.openpond.human-review+json",sizeBytes:null},{id:g.accepted.decision.id,contentHash:g.accepted.decision.contentHash,mediaType:"application/vnd.openpond.human-decision+json",sizeBytes:null}]}}),b=a.output!==null&&t.every(u=>u.status==="scored");return{...a,feedback:t,status:b?"completed":a.status,error:b?null:a.error}}),{contentHash:me,...ue}=l.result,le=W({...ue,manifest:{id:B.id,contentHash:B.contentHash},cases:de},B);for(let a of E){let t=await o.readReview({id:a.id,revision:a.revision,contentHash:a.contentHash});(t.contentHash!==a.contentHash||t.status!=="accepted")&&d("human_comparison_review_changed")}return await o.authorize(),{evidence:{manifest:B,result:le},humanResult:D}}I(i,"lane");let p=await i("baseline"),f=await i("candidate");for(let H of[...m.baseline.reviews,...m.candidate.reviews]){let l=await o.readReview(H.review);(l.contentHash!==H.review.contentHash||l.status!=="accepted"||l.decisions.at(-1)?.contentHash!==H.decision.contentHash)&&d("human_comparison_review_changed")}await o.authorize();let v={baseline:{id:n.baseline.manifest.id,manifestHash:n.baseline.manifest.contentHash,resultHash:n.baseline.result.contentHash},candidate:{id:n.candidate.manifest.id,manifestHash:n.candidate.manifest.contentHash,resultHash:n.candidate.result.contentHash}},w=ae.parse({schemaVersion:"openpond.humanComparisonProjection.v1",teamId:o.teamId,projectId:o.projectId,selections:m,original:v,humanResults:{baseline:p.humanResult,candidate:f.humanResult},baseline:p.evidence,candidate:f.evidence});return new TextEncoder().encode(JSON.stringify(w)).byteLength>8388608&&d("human_comparison_projection_too_large"),se.parse({...w,contentHash:r(w)})}I(Ve,"projectAcceptedHumanComparison");function Ce(o,m){let n=se.parse(o),{contentHash:y,...s}=n;y!==r(s)&&d("human_comparison_projection_invalid");for(let i of["baseline","candidate"]){let p=P(n[i]),f=p.manifest.lineage,v=f?.humanProjection,w=n.original[i],H=n.selections[i];(!f||!v||v.originalManifest.id!==w.id||v.originalManifest.contentHash!==w.manifestHash||v.selectionHash!==r(H)||v.rulesHash!==r(n.selections.rules)||r(f.execution)!==r(H.execution)||p.manifest.teamId!==n.teamId||n.humanResults[i].contentHash!==H.resultHash)&&d("human_comparison_projection_lineage_changed");let{contentHash:l,...j}=n.humanResults[i];if((r(j)!==l||j.executionId!==H.execution.id||j.executionHash!==H.execution.contentHash||r(j.selection)!==r(H.reviews.map(_=>_.review)))&&d("human_comparison_human_result_changed"),m){let _=P(m[i]);(_.manifest.lineage?.humanProjection||_.manifest.id!==w.id||_.manifest.contentHash!==w.manifestHash||_.result.contentHash!==w.resultHash||r(_.manifest.lineage?.execution)!==r(H.execution))&&d("human_comparison_original_changed")}}return n}I(Ce,"verifyHumanComparisonProjection");export{M as a,Y as b,ie as c,se as d,Ve as e,Ce as f};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{A as it,B as K,C as A,D as rt,E as at,b as u,f as I,g as Y,h as $,i as L,j as N,k as G,l as T,o as Q,r as Z,s as k,t as x,u as tt,v as M,w as et,x as z,y as q,z as nt}from"./chunk-XW6HGSIT.js";import{d as b}from"./chunk-KG325WTN.js";import{a as l}from"./chunk-FTQLQJQV.js";import{promises as mt}from"node:fs";async function $t(t,e,n={}){return O(A(t,e.id),e,n)}l($t,"loadWorkspaceState");async function O(t,e,n={}){let{workspacePath:i,repoPath:r}=t,a=it(e,n.gitBaseUrl);await mt.mkdir(i,{recursive:!0});let o=await L(r),s=null;if(!o&&n.clone&&a)try{await rt(r,i,a,n.token),o=!0}catch(m){s=m instanceof Error?m.message:String(m)}if(!o)return n.allowPlainFolder&&await $(r)?{appId:e.id,source:"local_folder",workspacePath:i,repoPath:r,initialized:!0,remoteUrl:null,expectedRemoteUrl:a,currentBranch:null,headCommit:null,upstreamBranch:null,ahead:0,behind:0,diverged:!1,linkedSourceHeadCommit:n.linkedSourceHeadCommit?.trim()||null,aheadOfLinkedSource:0,behindLinkedSource:0,divergedFromLinkedSource:!1,linkedSourceComparisonError:null,lastFetchAt:null,defaultBranch:e.defaultBranch??null,branches:[],dirty:!1,changedFilesCount:0,untrackedFilesCount:0,error:s,updatedAt:b()}:{appId:e.id,source:I(a),workspacePath:i,repoPath:r,initialized:o,remoteUrl:null,expectedRemoteUrl:a,currentBranch:null,headCommit:null,upstreamBranch:null,ahead:0,behind:0,diverged:!1,linkedSourceHeadCommit:n.linkedSourceHeadCommit?.trim()||null,aheadOfLinkedSource:0,behindLinkedSource:0,divergedFromLinkedSource:!1,linkedSourceComparisonError:null,lastFetchAt:null,defaultBranch:e.defaultBranch??null,branches:[],dirty:!1,changedFilesCount:0,untrackedFilesCount:0,error:s,updatedAt:b()};let[p,d,h,P,y]=await Promise.all([u("git",["branch","--show-current"],r),u("git",["branch","--format=%(refname:short)"],r),u("git",["status","--porcelain=v1","-b"],r),u("git",["config","--get","remote.origin.url"],r),u("git",["rev-parse","--verify","HEAD"],r)]),E=P.code===0&&Y(P.stdout.trim())||null,W=h.code===0?h.stdout.split(`
2
+ import{A as it,B as K,C as A,D as rt,E as at,b as u,f as I,g as Y,h as $,i as L,j as N,k as G,l as T,o as Q,r as Z,s as k,t as x,u as tt,v as M,w as et,x as z,y as q,z as nt}from"./chunk-XW6HGSIT.js";import{d as b}from"./chunk-FSQWAANK.js";import{a as l}from"./chunk-FTQLQJQV.js";import{promises as mt}from"node:fs";async function $t(t,e,n={}){return O(A(t,e.id),e,n)}l($t,"loadWorkspaceState");async function O(t,e,n={}){let{workspacePath:i,repoPath:r}=t,a=it(e,n.gitBaseUrl);await mt.mkdir(i,{recursive:!0});let o=await L(r),s=null;if(!o&&n.clone&&a)try{await rt(r,i,a,n.token),o=!0}catch(m){s=m instanceof Error?m.message:String(m)}if(!o)return n.allowPlainFolder&&await $(r)?{appId:e.id,source:"local_folder",workspacePath:i,repoPath:r,initialized:!0,remoteUrl:null,expectedRemoteUrl:a,currentBranch:null,headCommit:null,upstreamBranch:null,ahead:0,behind:0,diverged:!1,linkedSourceHeadCommit:n.linkedSourceHeadCommit?.trim()||null,aheadOfLinkedSource:0,behindLinkedSource:0,divergedFromLinkedSource:!1,linkedSourceComparisonError:null,lastFetchAt:null,defaultBranch:e.defaultBranch??null,branches:[],dirty:!1,changedFilesCount:0,untrackedFilesCount:0,error:s,updatedAt:b()}:{appId:e.id,source:I(a),workspacePath:i,repoPath:r,initialized:o,remoteUrl:null,expectedRemoteUrl:a,currentBranch:null,headCommit:null,upstreamBranch:null,ahead:0,behind:0,diverged:!1,linkedSourceHeadCommit:n.linkedSourceHeadCommit?.trim()||null,aheadOfLinkedSource:0,behindLinkedSource:0,divergedFromLinkedSource:!1,linkedSourceComparisonError:null,lastFetchAt:null,defaultBranch:e.defaultBranch??null,branches:[],dirty:!1,changedFilesCount:0,untrackedFilesCount:0,error:s,updatedAt:b()};let[p,d,h,P,y]=await Promise.all([u("git",["branch","--show-current"],r),u("git",["branch","--format=%(refname:short)"],r),u("git",["status","--porcelain=v1","-b"],r),u("git",["config","--get","remote.origin.url"],r),u("git",["rev-parse","--verify","HEAD"],r)]),E=P.code===0&&Y(P.stdout.trim())||null,W=h.code===0?h.stdout.split(`
3
3
  `).filter(m=>m.trim()):[],S=et(W.find(m=>m.startsWith("## "))??""),f=W.filter(m=>{if(m.startsWith("## "))return!1;let B=M(m),V=B?k(B.path):null;return!!(V&&!x(V))}),C=f.filter(m=>m.startsWith("??")).length,F=p.code===0&&p.stdout.trim()?p.stdout.trim():null,v=y.code===0&&y.stdout.trim()||null,U=d.code===0?d.stdout.split(`
4
4
  `).map(m=>m.trim()).filter(Boolean):[],c=I(E)==="unknown"&&a?a:E??a,g=await ht(r,n.linkedSourceHeadCommit,v);return{appId:e.id,source:c?I(c):"local_git",workspacePath:i,repoPath:r,initialized:o,remoteUrl:E,expectedRemoteUrl:a,currentBranch:F,headCommit:v,upstreamBranch:S.upstreamBranch,ahead:S.ahead,behind:S.behind,diverged:S.ahead>0&&S.behind>0,linkedSourceHeadCommit:g.linkedSourceHeadCommit,aheadOfLinkedSource:g.aheadOfLinkedSource,behindLinkedSource:g.behindLinkedSource,divergedFromLinkedSource:g.divergedFromLinkedSource,linkedSourceComparisonError:g.error,lastFetchAt:await at(r),defaultBranch:e.defaultBranch??null,branches:U,dirty:f.length>0,changedFilesCount:f.length,untrackedFilesCount:C,error:s,updatedAt:b()}}l(O,"loadWorkspaceStateAtPath");async function ht(t,e,n){let i=e?.trim()||null,r={linkedSourceHeadCommit:i,aheadOfLinkedSource:0,behindLinkedSource:0,divergedFromLinkedSource:!1,error:null};if(!i||!n||i===n)return r;let a=await u("git",["rev-list","--left-right","--count",`${i}...${n}`],t);if(a.code!==0)return{...r,error:a.stderr.trim()||a.stdout.trim()||"Unable to compare linked source commit."};let[o,s]=a.stdout.trim().split(/\s+/,2),p=Number(o)||0,d=Number(s)||0;return{linkedSourceHeadCommit:i,aheadOfLinkedSource:d,behindLinkedSource:p,divergedFromLinkedSource:d>0&&p>0,error:null}}l(ht,"compareLinkedSourceCommit");async function zt(t,e,n){return gt(A(t,e.id),e,n)}l(zt,"createAndCheckoutBranch");async function gt(t,e,n,i={}){K(n);let r=await O(t,e,{...i,clone:!1});if(!r.initialized)throw new Error(r.error||"Workspace is not initialized");let a=await u("git",["checkout","-b",n.trim()],r.repoPath);if(a.code!==0)throw new Error(a.stderr.trim()||a.stdout.trim()||"Unable to create branch");return O(t,e,{...i,clone:!1})}l(gt,"createAndCheckoutBranchAtPath");async function Ht(t,e,n){return kt(A(t,e.id),e,n)}l(Ht,"checkoutBranch");async function kt(t,e,n,i={}){K(n);let r=await O(t,e,{...i,clone:!1});if(!r.initialized)throw new Error(r.error||"Workspace is not initialized");if(r.dirty&&r.currentBranch!==n.trim())throw new Error("Commit or discard local changes before switching branches");let a=await u("git",["checkout",n.trim()],r.repoPath);if(a.code!==0)throw new Error(a.stderr.trim()||a.stdout.trim()||"Unable to switch branch");return O(t,e,{...i,clone:!1})}l(kt,"checkoutBranchAtPath");import w from"node:path";import{promises as ct}from"node:fs";var wt=6,Wt=60,st=1e4,D=new Map;async function H(t,e,n=wt){let i=Math.max(1,Math.floor(n)),r=new Array(t.length),a=0;async function o(){for(;a<t.length;){let s=a;a+=1,r[s]=await e(t[s],s)}}return l(o,"worker"),await Promise.all(Array.from({length:Math.min(i,t.length)},()=>o())),r}l(H,"mapWorkspaceDiffEntriesWithConcurrency");function Xt(){D.clear()}l(Xt,"clearWorkspaceDiffCacheForTests");async function Jt(t,e,n={}){let{repoPath:i}=A(t,e.id);return Pt(i,e.id,n)}l(Jt,"loadWorkspaceDiff");async function Pt(t,e,n={}){let i=await L(t);if(!i){let c=await nt(t);return{appId:e,repoPath:t,initialized:c.length>0||await $(t),dirty:!1,filesChanged:0,additions:0,deletions:0,repoFiles:c,files:[],error:null,updatedAt:b()}}let r=await X(t),a=r.pathPrefix||".",[o,s]=await Promise.all([u("git",["rev-parse","HEAD"],r.commandCwd),u("git",["status","--porcelain=v1","-uall","--",a],r.commandCwd)]);if(s.code!==0)return{appId:e,repoPath:t,initialized:i,dirty:!1,filesChanged:0,additions:0,deletions:0,repoFiles:[],files:[],error:s.stderr.trim()||s.stdout.trim()||"Unable to read workspace diff",updatedAt:b()};let p=s.stdout.split(`
5
5
  `).map(M).filter(c=>!!c).map(c=>{let g=R(c.path,r.pathPrefix);if(!g)return null;let m=k(g);return m?{...c,path:m}:null}).filter(c=>c?!x(c.path):!1),d=await Ct(t,p),h=Ft({repoPath:t,workspaceId:e,includeFileDetails:!!n.includeFileDetails,head:o.code===0?o.stdout.trim():"unborn",pathPrefix:r.pathPrefix,status:s.stdout,worktreeSignature:d}),P=D.get(h);if(P)return j(P);let y=(await H(p,async c=>c.status==="deleted"||!await Z(t,c.path)?c:null)).filter(c=>!!c),E=await u("git",["ls-files","--",a],r.commandCwd),W=q([...E.code===0?E.stdout.split(`
@@ -9,4 +9,4 @@ import{A as it,B as K,C as A,D as rt,E as at,b as u,f as I,g as Y,h as $,i as L,
9
9
  `).length:0}l(lt,"countTextLines");async function Ct(t,e){return(await H(e,async i=>{if(i.status==="deleted")return`${i.path} ${i.status} deleted`;let r=w.resolve(t,i.path),a=w.resolve(t);if(r!==a&&!r.startsWith(`${a}${w.sep}`))return`${i.path} ${i.status} outside`;try{let o=await ct.lstat(r),s=o.isDirectory()?"dir":o.isFile()?"file":"other";return`${i.path} ${i.status} ${s} ${o.size} ${Math.trunc(o.mtimeMs)} ${Math.trunc(o.ctimeMs)}`}catch{return`${i.path} ${i.status} missing`}})).sort((i,r)=>i.localeCompare(r)).join(`
10
10
  `)}l(Ct,"workspaceDiffWorktreeSignature");function Ft(t){return JSON.stringify(t)}l(Ft,"workspaceDiffCacheKey");function bt(t,e){for(D.has(t)&&D.delete(t),D.set(t,j(e));D.size>Wt;){let n=D.keys().next().value;if(!n)break;D.delete(n)}}l(bt,"writeWorkspaceDiffCache");function j(t){return{...t,repoFiles:[...t.repoFiles],files:t.files.map(e=>({...e}))}}l(j,"cloneWorkspaceDiffSummary");async function X(t){let e=await u("git",["rev-parse","--show-toplevel"],t);if(e.code!==0)return{commandCwd:t,pathPrefix:""};let n=e.stdout.trim();if(!n)return{commandCwd:t,pathPrefix:""};let i=w.relative(w.resolve(n),w.resolve(t)),r=k(i.replace(/\\/g,"/"))??"";return{commandCwd:n,pathPrefix:r}}l(X,"gitWorkspaceContext");function R(t,e){let n=k(t);return n?e?n===e?null:n.startsWith(`${e}/`)?n.slice(e.length+1):null:n:null}l(R,"pathInWorkspace");function J(t,e){return e?`${e}/${t}`:t}l(J,"gitPathForWorkspacePath");function dt(t,e){let n=new Map;for(let[i,r]of t){let a=R(i,e);a&&n.set(a,r)}return n}l(dt,"scopedNumstat");async function xt(t,e){if(e.length===0)return new Map;let n=t.pathPrefix||".",i=await u("git",["-c","core.quotePath=false","diff","--no-ext-diff","--unified=80","HEAD","--",n],t.commandCwd);return i.code!==0?new Map:ut(i.stdout||i.stderr,t.pathPrefix)}l(xt,"loadTrackedGitPatchMap");function ut(t,e){let n=new Map;for(let i of t.split(/(?=^diff --git )/m)){if(!i.trim())continue;let r=yt(i,e);r&&n.set(r,i)}return n}l(ut,"parseGitPatchStreamByWorkspacePath");function yt(t,e){let n=t.split(`
11
11
  `);for(let o of n){let s=ot(o,"+++ ");if(s)return R(s,e)}for(let o of n){let s=ot(o,"--- ");if(s)return R(s,e)}for(let o of n)if(o.startsWith("rename to ")){let s=k(o.slice(10).trim());if(s)return R(s,e)}let i=n.find(o=>o.startsWith("diff --git "));if(!i)return null;let r=i.lastIndexOf(" b/");if(r<0)return null;let a=k(i.slice(r+3).trim());return a?R(a,e):null}l(yt,"workspacePathForGitPatchChunk");function ot(t,e){if(!t.startsWith(e))return null;let n=t.slice(e.length).trim();if(!n||n==="/dev/null")return null;let i=n.startsWith("a/")||n.startsWith("b/")?n.slice(2):n;return k(i)}l(ot,"gitPatchMarkerPath");async function Yt(t,e,n){let{repoPath:i}=A(t,e.id);return Dt(i,n)}l(Yt,"loadWorkspaceFile");async function Qt(t,e,n){let{repoPath:i}=A(t,e.id);return Et(i,n)}l(Qt,"loadWorkspaceImageFile");async function Et(t,e){let n=await L(t),i=ft(t,e);if(!i)throw new Error("Image not found");if(n&&!await tt(t,i))throw new Error("Image not found");let r=await Q(t,i);if(!r)throw new Error("Image not found");return r}l(Et,"loadWorkspaceImageFileAtPath");function ft(t,e){let n=At(e);if(!n)return null;if(!w.isAbsolute(n))return k(n);let i=w.relative(w.resolve(t),w.resolve(n));return!i||i.startsWith("..")||w.isAbsolute(i)?null:k(i)}l(ft,"normalizeWorkspaceFileRequestPath");function At(t){let e=t.trim();if(!e)return null;e=e.replace(/^['"`]+|['"`]+$/g,"");let n=e.indexOf("#");n>=0&&(e=e.slice(0,n));let i=e.indexOf("?");if(i>=0&&(e=e.slice(0,i)),e.startsWith("file://"))try{e=decodeURIComponent(new URL(e).pathname)}catch{e=e.replace(/^file:\/\//,"")}return e.trim()||null}l(At,"cleanWorkspaceFileRequestPath");async function Dt(t,e){let n=await L(t),i=ft(t,e);if(!i)throw new Error("File not found");if(x(i))throw new Error("File not found");if(n){let o=await Rt(t,i);if(o){if(o.content!==null||o.status==="deleted")return o;let s=await T(t,i);return s===null?o:{...o,content:s}}}let r=i,a=await G(t,r)??await T(t,r);if(a===null){let o=await vt(t,i);o&&(r=o,a=await G(t,r))}if(a===null)throw new Error("File not found");return{path:r,status:"unchanged",additions:0,deletions:0,patch:"",content:a}}l(Dt,"loadWorkspaceFileAtPath");async function Rt(t,e){let n=await X(t),i=J(e,n.pathPrefix),r=await u("git",["status","--porcelain=v1","-uall","--",i],n.commandCwd);if(r.code!==0)return null;let a=r.stdout.split(`
12
- `).map(M).filter(s=>!!s).map(s=>{let p=R(s.path,n.pathPrefix);if(!p)return null;let d=k(p);return d?{...s,path:d}:null}).find(s=>!!(s&&s.path===e));if(!a)return null;let o=a.status==="untracked"?{additions:lt(await G(t,a.path)),deletions:0}:await Bt(n,a.path);return pt(t,a,n,o)}l(Rt,"loadGitWorkspaceFileAtPath");async function vt(t,e){if(e.includes("/")||!Lt(e))return null;let n=e.toLowerCase(),i=[],r=[{absolutePath:t,prefix:""}],a=0;for(;r.length>0&&a<st;){let s=r.shift(),p;try{p=await ct.readdir(s.absolutePath,{withFileTypes:!0})}catch{continue}p.sort((d,h)=>d.name.localeCompare(h.name));for(let d of p){if(a>=st)break;let h=s.prefix?`${s.prefix}/${d.name}`:d.name;if(x(h))continue;a+=1;let P=w.join(s.absolutePath,d.name);d.isDirectory()?r.push({absolutePath:P,prefix:h}):d.isFile()&&d.name.toLowerCase()===n&&i.push(h)}}if(i.length===1)return i[0]??null;let o=i.filter(s=>s.startsWith("docs/working-docs/"));return o.length===1?o[0]??null:null}l(vt,"resolveExplicitMarkdownBasenamePath");function Lt(t){return/\.(?:md|markdown|mdx)$/i.test(t)}l(Lt,"isMarkdownWorkspacePath");async function pt(t,e,n,i,r={}){let a=r.content!==void 0?r.content:e.status==="deleted"?null:await G(t,e.path),o=J(e.path,n.pathPrefix),s=e.status==="untracked"?["diff","--no-index","--unified=80","--","/dev/null",w.join(t,e.path)]:["diff","--no-ext-diff","--unified=80","HEAD","--",o],p=r.patch??"";if(r.patch===null||r.patch===void 0){let d=await u("git",s,n.commandCwd);p=d.stdout||d.stderr}return{path:e.path,status:e.status,additions:i.additions,deletions:i.deletions,patch:N(p),content:a}}l(pt,"loadGitWorkspaceFileDetail");async function Bt(t,e){let n=J(e,t.pathPrefix),i=await u("git",["diff","--numstat","HEAD","--",n],t.commandCwd);return i.code!==0?{additions:0,deletions:0}:dt(z(i.stdout),t.pathPrefix).get(e)??{additions:0,deletions:0}}l(Bt,"gitNumstatForFile");export{$t as a,O as b,zt as c,gt as d,Ht as e,kt as f,H as g,Xt as h,Jt as i,Pt as j,Vt as k,Yt as l,Qt as m,Et as n,Dt as o};
12
+ `).map(M).filter(s=>!!s).map(s=>{let p=R(s.path,n.pathPrefix);if(!p)return null;let d=k(p);return d?{...s,path:d}:null}).find(s=>!!(s&&s.path===e));if(!a)return null;let o=a.status==="untracked"?{additions:lt(await G(t,a.path)),deletions:0}:await Bt(n,a.path);return pt(t,a,n,o)}l(Rt,"loadGitWorkspaceFileAtPath");async function vt(t,e){if(e.includes("/")||!Lt(e))return null;let n=e.toLowerCase(),i=[],r=[{absolutePath:t,prefix:""}],a=0;for(;r.length>0&&a<st;){let s=r.shift(),p;try{p=await ct.readdir(s.absolutePath,{withFileTypes:!0})}catch{continue}p.sort((d,h)=>d.name.localeCompare(h.name));for(let d of p){if(a>=st)break;let h=s.prefix?`${s.prefix}/${d.name}`:d.name;if(x(h))continue;a+=1;let P=w.join(s.absolutePath,d.name);d.isDirectory()?r.push({absolutePath:P,prefix:h}):d.isFile()&&d.name.toLowerCase()===n&&i.push(h)}}if(i.length===1)return i[0]??null;let o=i.filter(s=>s.startsWith("docs/working-docs/"));return o.length===1?o[0]??null:null}l(vt,"resolveExplicitMarkdownBasenamePath");function Lt(t){return/\.(?:md|markdown|mdx)$/i.test(t)}l(Lt,"isMarkdownWorkspacePath");async function pt(t,e,n,i,r={}){let a=r.content!==void 0?r.content:e.status==="deleted"?null:await G(t,e.path),o=J(e.path,n.pathPrefix),s=e.status==="untracked"?["diff","--no-index","--unified=80","--","/dev/null",w.join(t,e.path)]:["diff","--no-ext-diff","--unified=80","HEAD","--",o],p=r.patch??"";if(r.patch===null||r.patch===void 0){let d=await u("git",s,n.commandCwd);p=d.stdout||d.stderr}return{path:e.path,status:e.status,additions:i.additions,deletions:i.deletions,patch:N(p),content:a}}l(pt,"loadGitWorkspaceFileDetail");async function Bt(t,e){let n=J(e,t.pathPrefix),i=await u("git",["diff","--numstat","HEAD","--",n],t.commandCwd);return i.code!==0?{additions:0,deletions:0}:dt(z(i.stdout),t.pathPrefix).get(e)??{additions:0,deletions:0}}l(Bt,"gitNumstatForFile");export{H as a,Xt as b,Jt as c,Pt as d,Vt as e,Yt as f,Qt as g,Et as h,Dt as i,$t as j,O as k,zt as l,gt as m,Ht as n,kt as o};