openpond 0.2.70 → 0.2.71

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 (349) hide show
  1. package/dist/app-server.js +1 -1
  2. package/dist/chunks/{acp-QTA6IU6W.js → acp-VWPJ2EL4.js} +1 -1
  3. package/dist/chunks/{acp-agent-N77HPAYQ.js → acp-agent-OZHZMQ6R.js} +1 -1
  4. package/dist/chunks/{actions-command-BZQCUDMD.js → actions-command-AXGXBU75.js} +1 -1
  5. package/dist/chunks/{app-layer-YQQNLIXA.js → app-layer-OHPIYEOJ.js} +1 -1
  6. package/dist/chunks/{app-server-evaluations-RRLYWLPK.js → app-server-evaluations-Y5UEF2Y7.js} +1 -1
  7. package/dist/chunks/{app-server-harness-services-XXM336NU.js → app-server-harness-services-GUHAIIPS.js} +1 -1
  8. package/dist/chunks/{app-server-runtime-B7AMBGQZ.js → app-server-runtime-CH5STRJP.js} +1 -1
  9. package/dist/chunks/{apps-WG7WY5CB.js → apps-DNLT6P4J.js} +1 -1
  10. package/dist/chunks/{chunk-MOXIGLN2.js → chunk-23YW5PAQ.js} +1 -1
  11. package/dist/chunks/{chunk-ZDEIVUUI.js → chunk-27OJ2OLP.js} +1 -1
  12. package/dist/chunks/{chunk-NSSZ2ZIU.js → chunk-2EAZB2MW.js} +1 -1
  13. package/dist/chunks/{chunk-DRLP7GIU.js → chunk-2GEZ3ZY7.js} +1 -1
  14. package/dist/chunks/{chunk-PAYFJHPO.js → chunk-2PVW2XFF.js} +1 -1
  15. package/dist/chunks/{chunk-Y2WNZWT2.js → chunk-2Q6FTL4C.js} +1 -1
  16. package/dist/chunks/{chunk-KP2MYTP5.js → chunk-2QHB5P2K.js} +1 -1
  17. package/dist/chunks/{chunk-FNGZ4UDZ.js → chunk-33UVQ7DU.js} +1 -1
  18. package/dist/chunks/{chunk-M4ZHFDRJ.js → chunk-3JVZ7OCQ.js} +1 -1
  19. package/dist/chunks/{chunk-4BUM6JEC.js → chunk-3JYPUOK4.js} +1 -1
  20. package/dist/chunks/{chunk-DXJC3QW7.js → chunk-3VT2PPKW.js} +1 -1
  21. package/dist/chunks/{chunk-Z33RVGP6.js → chunk-5LKEVB2P.js} +1 -1
  22. package/dist/chunks/{chunk-P4QM63L3.js → chunk-5ZBDHIIE.js} +1 -1
  23. package/dist/chunks/{chunk-WD4KAKEX.js → chunk-64EDQ7UV.js} +1 -1
  24. package/dist/chunks/{chunk-OL3L3U36.js → chunk-6BTX66SV.js} +1 -1
  25. package/dist/chunks/{chunk-KU4TPDPH.js → chunk-6LAGMWJE.js} +1 -1
  26. package/dist/chunks/{chunk-65FJWWXG.js → chunk-6YR5IYHH.js} +1 -1
  27. package/dist/chunks/{chunk-AUO5DCEU.js → chunk-73COPJ32.js} +1 -1
  28. package/dist/chunks/{chunk-KDER7R45.js → chunk-7PDF2UX2.js} +1 -1
  29. package/dist/chunks/{chunk-SO4GMSNP.js → chunk-7SOHV5BH.js} +1 -1
  30. package/dist/chunks/{chunk-XOPHFUUY.js → chunk-ASMQTMQB.js} +1 -1
  31. package/dist/chunks/{chunk-ESYPMD7Q.js → chunk-AT3ZYNX4.js} +1 -1
  32. package/dist/chunks/{chunk-NMMHXYDJ.js → chunk-AVEHWUML.js} +1 -1
  33. package/dist/chunks/{chunk-M4A7G4S5.js → chunk-B7SCVTE6.js} +1 -1
  34. package/dist/chunks/{chunk-DKOVZ6R2.js → chunk-BQNU4HZW.js} +1 -1
  35. package/dist/chunks/{chunk-UANH7U3Y.js → chunk-BTEBZYK3.js} +1 -1
  36. package/dist/chunks/{chunk-BU6MW65V.js → chunk-BYVE4TMU.js} +1 -1
  37. package/dist/chunks/{chunk-PNPV2LDE.js → chunk-BZS2PA4O.js} +1 -1
  38. package/dist/chunks/{chunk-AFYYIJ6K.js → chunk-C7NQPICU.js} +1 -1
  39. package/dist/chunks/{chunk-K7KBFM2T.js → chunk-CBD554GZ.js} +1 -1
  40. package/dist/chunks/{chunk-GYYJ47GX.js → chunk-CWE2N3JI.js} +1 -1
  41. package/dist/chunks/{chunk-ZYLLPRPU.js → chunk-CX4T7I47.js} +1 -1
  42. package/dist/chunks/{chunk-AQUZCWM3.js → chunk-D2V2Y3FB.js} +1 -1
  43. package/dist/chunks/{chunk-2PXKSAG6.js → chunk-DLOJG7LP.js} +1 -1
  44. package/dist/chunks/{chunk-5G7BQAUA.js → chunk-DNNWMOMG.js} +1 -1
  45. package/dist/chunks/{chunk-BGMAWETL.js → chunk-DNRC6TPJ.js} +1 -1
  46. package/dist/chunks/{chunk-5FSPDSAO.js → chunk-DUR32LJG.js} +1 -1
  47. package/dist/chunks/{chunk-JZKTBYNB.js → chunk-E57PUTV2.js} +1 -1
  48. package/dist/chunks/{chunk-OUJ63LMU.js → chunk-ER2VONWQ.js} +1 -1
  49. package/dist/chunks/{chunk-TAXCMCYZ.js → chunk-ESOIZG2G.js} +4 -4
  50. package/dist/chunks/{chunk-CCZ276IA.js → chunk-F2EUZG2W.js} +1 -1
  51. package/dist/chunks/{chunk-VJR2GNRY.js → chunk-FVMTQSVW.js} +1 -1
  52. package/dist/chunks/{chunk-YI6ME6PU.js → chunk-GG6PM7TB.js} +1 -1
  53. package/dist/chunks/{chunk-DDOIPTOM.js → chunk-GMA365GI.js} +1 -1
  54. package/dist/chunks/{chunk-JVMSN7LH.js → chunk-GR4MJJCE.js} +1 -1
  55. package/dist/chunks/{chunk-FHDH4OUA.js → chunk-GUWNSMGH.js} +1 -1
  56. package/dist/chunks/{chunk-AFH462DO.js → chunk-HT6ILPD6.js} +1 -1
  57. package/dist/chunks/{chunk-3Z4VM2LF.js → chunk-HUMNLSCV.js} +1 -1
  58. package/dist/chunks/{chunk-XYZV3FKD.js → chunk-I6KTJ3GH.js} +1 -1
  59. package/dist/chunks/{chunk-WZ35ICTE.js → chunk-IFMWAOBR.js} +1 -1
  60. package/dist/chunks/{chunk-R2FYCJL6.js → chunk-IJJ7FYZE.js} +1 -1
  61. package/dist/chunks/{chunk-XHACK2KR.js → chunk-IUYGQO2K.js} +1 -1
  62. package/dist/chunks/{chunk-55YD4UTW.js → chunk-IV2HEX3I.js} +1 -1
  63. package/dist/chunks/{chunk-U7X5ZLAL.js → chunk-JCHLDNCX.js} +1 -1
  64. package/dist/chunks/{chunk-7PKDJHT6.js → chunk-JH4RACOB.js} +1 -1
  65. package/dist/chunks/{chunk-65WRWLUD.js → chunk-JVEIK4RH.js} +1 -1
  66. package/dist/chunks/{chunk-PPF6EBTQ.js → chunk-K3WM4NEC.js} +1 -1
  67. package/dist/chunks/{chunk-EGP6DF34.js → chunk-KASHK2U5.js} +2 -2
  68. package/dist/chunks/{chunk-7OFD6TFD.js → chunk-LMLGEOKV.js} +1 -1
  69. package/dist/chunks/{chunk-QUNQM2E3.js → chunk-MPEK4ZNY.js} +1 -1
  70. package/dist/chunks/{chunk-SDHG6CKU.js → chunk-NDNSLCPE.js} +1 -1
  71. package/dist/chunks/chunk-NK2L5HA2.js +2 -0
  72. package/dist/chunks/{chunk-WCNPGKST.js → chunk-O4YHISU2.js} +1 -1
  73. package/dist/chunks/{chunk-RCQYEHHD.js → chunk-O5ZOW474.js} +1 -1
  74. package/dist/chunks/{chunk-OXQ2WFIH.js → chunk-OEAKX5TS.js} +1 -1
  75. package/dist/chunks/{chunk-54755JYM.js → chunk-OFV26C2U.js} +2 -2
  76. package/dist/chunks/{chunk-IO5DZUKL.js → chunk-OI4DAZ4U.js} +1 -1
  77. package/dist/chunks/{chunk-Q73RKX7I.js → chunk-OIIE5GUK.js} +1 -1
  78. package/dist/chunks/{chunk-CUB6PWAJ.js → chunk-OKPV6MBX.js} +6 -6
  79. package/dist/chunks/{chunk-N5EAVX4G.js → chunk-OOKHHOIU.js} +1 -1
  80. package/dist/chunks/{chunk-MIFVX5PK.js → chunk-OQ4RWCYI.js} +1 -1
  81. package/dist/chunks/{chunk-EWH64WRR.js → chunk-OTG77H7U.js} +1 -1
  82. package/dist/chunks/{chunk-7OKZCJHS.js → chunk-OXRN2257.js} +1 -1
  83. package/dist/chunks/{chunk-JVNKSU27.js → chunk-PJJSQ4ZI.js} +1 -1
  84. package/dist/chunks/{chunk-7TM25J6S.js → chunk-PXQZOVSV.js} +2 -2
  85. package/dist/chunks/{chunk-YAA7F5LI.js → chunk-QKGNAYSC.js} +1 -1
  86. package/dist/chunks/{chunk-67U7PAMU.js → chunk-QN4CFJQC.js} +1 -1
  87. package/dist/chunks/{chunk-HES4VP3D.js → chunk-RJY4EI46.js} +1 -1
  88. package/dist/chunks/{chunk-E2JB5OCO.js → chunk-RP4DPUN2.js} +1 -1
  89. package/dist/chunks/{chunk-QLGP2OAQ.js → chunk-SNBFWBJI.js} +1 -1
  90. package/dist/chunks/{chunk-ZK3ET5EP.js → chunk-SRJTQS2D.js} +3 -3
  91. package/dist/chunks/{chunk-XY7HFXLH.js → chunk-SVLVIYH2.js} +1 -1
  92. package/dist/chunks/{chunk-7NCM6GBN.js → chunk-TOWY6Y23.js} +1 -1
  93. package/dist/chunks/{chunk-VWWKWYSQ.js → chunk-TWLPZHH7.js} +1 -1
  94. package/dist/chunks/{chunk-Y4I6CFZJ.js → chunk-UGDBMRCT.js} +1 -1
  95. package/dist/chunks/{chunk-JQOVC35K.js → chunk-UKTPX2EE.js} +1 -1
  96. package/dist/chunks/{chunk-CO23RRN7.js → chunk-UMRQKE3W.js} +1 -1
  97. package/dist/chunks/{chunk-B66QCXH2.js → chunk-USKCFST5.js} +1 -1
  98. package/dist/chunks/{chunk-3A2Y7UK3.js → chunk-USTDWGR4.js} +1 -1
  99. package/dist/chunks/{chunk-CIZI6Z7D.js → chunk-VMW23TIZ.js} +1 -1
  100. package/dist/chunks/{chunk-Y4E5AAI7.js → chunk-VND53FAU.js} +1 -1
  101. package/dist/chunks/{chunk-4G3GTEVS.js → chunk-VSQPWLAG.js} +1 -1
  102. package/dist/chunks/{chunk-KCLMA2IH.js → chunk-VV4K5YPD.js} +1 -1
  103. package/dist/chunks/{chunk-7RJOCGQ6.js → chunk-WAUFXZ5B.js} +1 -1
  104. package/dist/chunks/{chunk-HG2YFMVU.js → chunk-WXG3G2O6.js} +1 -1
  105. package/dist/chunks/{chunk-PACLKDTN.js → chunk-XBAB3HMA.js} +1 -1
  106. package/dist/chunks/chunk-XJU47QS2.js +2 -0
  107. package/dist/chunks/{chunk-WGQ3FMRF.js → chunk-XKDOPNQ5.js} +1 -1
  108. package/dist/chunks/{chunk-EYTTZ5H4.js → chunk-XLZMSD5K.js} +1 -1
  109. package/dist/chunks/{chunk-Q7FBVLLB.js → chunk-XNPTLJ5Z.js} +1 -1
  110. package/dist/chunks/{chunk-ZIQJDTQB.js → chunk-XTT3K3TR.js} +1 -1
  111. package/dist/chunks/{chunk-Q7P34B2O.js → chunk-YFHQRDNQ.js} +1 -1
  112. package/dist/chunks/{chunk-UGFSAG4U.js → chunk-YG3HITOU.js} +1 -1
  113. package/dist/chunks/{chunk-DWF3FCY4.js → chunk-Z5R4OSGC.js} +1 -1
  114. package/dist/chunks/{chunk-JT5YQ52I.js → chunk-Z6HWSTEP.js} +1 -1
  115. package/dist/chunks/{chunk-4PUOWSDE.js → chunk-ZEOYNUHL.js} +1 -1
  116. package/dist/chunks/{chunk-6C6ZCYTL.js → chunk-ZG3DBXQG.js} +1 -1
  117. package/dist/chunks/{chunk-4KTGYHCE.js → chunk-ZMRP2A7K.js} +1 -1
  118. package/dist/chunks/cli-5JARGJOD.js +2 -0
  119. package/dist/chunks/{command-5AXJMFYC.js → command-AI3SMEAH.js} +3 -3
  120. package/dist/chunks/{configuration-command-5LUNWPOL.js → configuration-command-NPA46ZOT.js} +1 -1
  121. package/dist/chunks/{connected-app-executor-DHXZE4X3.js → connected-app-executor-DLC23O43.js} +1 -1
  122. package/dist/chunks/{connected-evidence-NWMPICKJ.js → connected-evidence-TVORI55Q.js} +1 -1
  123. package/dist/chunks/{connected-starting-assets-NRVXIKQ2.js → connected-starting-assets-WGGBWH4K.js} +1 -1
  124. package/dist/chunks/{continual-UCKQ2QLH.js → continual-UHQI2EQD.js} +1 -1
  125. package/dist/chunks/{core-commands-ZPBX35M2.js → core-commands-QNZUBKOC.js} +1 -1
  126. package/dist/chunks/{dataset-preparation-authoring-UUYFWWCT.js → dataset-preparation-authoring-OBMJLGA4.js} +1 -1
  127. package/dist/chunks/{datasets-6K3ZANIV.js → datasets-USJLJOEQ.js} +1 -1
  128. package/dist/chunks/{desktop-test-57INNJ76.js → desktop-test-IYHAOR47.js} +1 -1
  129. package/dist/chunks/{dist-2MKJC6HN.js → dist-C5XFRP53.js} +1 -1
  130. package/dist/chunks/{evaluation-coordination-B7CN4R2D.js → evaluation-coordination-UJENK4WQ.js} +1 -1
  131. package/dist/chunks/{experiment-improvements-G357VLDB.js → experiment-improvements-6GJMKIER.js} +1 -1
  132. package/dist/chunks/{experiments-BHQO26LJ.js → experiments-FZHILSC6.js} +1 -1
  133. package/dist/chunks/{experiments-signal-BI6NKETB.js → experiments-signal-E32CWBS4.js} +1 -1
  134. package/dist/chunks/{help-UQN5RUPA.js → help-32DLAPJR.js} +1 -1
  135. package/dist/chunks/host-profile-evaluation-tools-QAV2UGSB.js +2 -0
  136. package/dist/chunks/{host-profile-external-dataset-KSEPXY2S.js → host-profile-external-dataset-C6ZPMTX6.js} +1 -1
  137. package/dist/chunks/{hosted-app-server-composition-WDDO6F23.js → hosted-app-server-composition-5DVBKNV3.js} +1 -1
  138. package/dist/chunks/{hosted-experiment-improvement-VVYXQ65K.js → hosted-experiment-improvement-YQ24C54D.js} +1 -1
  139. package/dist/chunks/hosted-harness-runtime-KLIORGWV.js +2 -0
  140. package/dist/chunks/{hosted-profile-candidate-PTGQLPZO.js → hosted-profile-candidate-RCWFLOVJ.js} +1 -1
  141. package/dist/chunks/{hosted-profile-compiler-FS5R6CHJ.js → hosted-profile-compiler-UDG4BCEW.js} +1 -1
  142. package/dist/chunks/{hosted-profile-evaluation-control-UUEZEMXU.js → hosted-profile-evaluation-control-4R3L4FTK.js} +1 -1
  143. package/dist/chunks/{hosted-profile-evaluation-inspection-4F7OEF4T.js → hosted-profile-evaluation-inspection-NA4SSY7N.js} +1 -1
  144. package/dist/chunks/{hosted-profile-evaluation-preparation-LIJJZDHQ.js → hosted-profile-evaluation-preparation-B4BW6JTB.js} +1 -1
  145. package/dist/chunks/{hosted-tasksets-KCLNMPG5.js → hosted-tasksets-IUK3VWSL.js} +1 -1
  146. package/dist/chunks/{human-review-PX6DBIFT.js → human-review-D6QCZLYN.js} +1 -1
  147. package/dist/chunks/{import-2HEYPHPW.js → import-UCG75PN5.js} +1 -1
  148. package/dist/chunks/{learning-Y3UKNUGE.js → learning-3XDYMYBE.js} +1 -1
  149. package/dist/chunks/{learning-LSXBL5DB.js → learning-OR4CYV4B.js} +1 -1
  150. package/dist/chunks/local-harness-improvement-runtime-GZBMBZB2.js +2 -0
  151. package/dist/chunks/local-harness-taskset-review-YVP2ZQJG.js +2 -0
  152. package/dist/chunks/{model-projects-6YWVD2TS.js → model-projects-POZRHXTF.js} +1 -1
  153. package/dist/chunks/{opchat-66BCRKEZ.js → opchat-APJUUTT7.js} +1 -1
  154. package/dist/chunks/{opchat-bounded-chat-KQWXZVFN.js → opchat-bounded-chat-PBUSUAY2.js} +1 -1
  155. package/dist/chunks/{organizations-IOYWDOCC.js → organizations-WK6EZ6L3.js} +1 -1
  156. package/dist/chunks/{profile-YH6G3ZTD.js → profile-BQMS7ALQ.js} +1 -1
  157. package/dist/chunks/{project-action-payload-53OH6WDH.js → project-action-payload-CGV77JSA.js} +1 -1
  158. package/dist/chunks/{project-agent-RYVMKW2F.js → project-agent-XVFYTEUQ.js} +1 -1
  159. package/dist/chunks/{published-experiment-source-SDXUVPE7.js → published-experiment-source-2CYFIRBL.js} +1 -1
  160. package/dist/chunks/{refiner-profile-service-56VYLZQJ.js → refiner-profile-service-OLJHA4DI.js} +1 -1
  161. package/dist/chunks/{runtime-ISLJIGWC.js → runtime-32KYSVZR.js} +1 -1
  162. package/dist/chunks/{sandbox-command-DI45NRTV.js → sandbox-command-OY3VZXGG.js} +1 -1
  163. package/dist/chunks/{sandbox-template-T42MDUSR.js → sandbox-template-YOOSJ4FK.js} +1 -1
  164. package/dist/chunks/saved-work-L4KNWLZB.js +2 -0
  165. package/dist/chunks/{setup-D6TY2GWV.js → setup-EU6CMRXQ.js} +1 -1
  166. package/dist/chunks/{src-LF5X4RNQ.js → src-3DJR7OAH.js} +1 -1
  167. package/dist/chunks/{src-7RN7BF4W.js → src-HYOTHMRX.js} +111 -113
  168. package/dist/chunks/{standalone-experiment-turn-owner-TW5MTWIO.js → standalone-experiment-turn-owner-UYPA6XHW.js} +1 -1
  169. package/dist/chunks/{store-chat-resources-IRHBW2EC.js → store-chat-resources-HISLEZZM.js} +1 -1
  170. package/dist/chunks/{store-continual-support-reviews-3KK42L4I.js → store-continual-support-reviews-ORWHS57V.js} +1 -1
  171. package/dist/chunks/{store-conversation-serving-IVURK52V.js → store-conversation-serving-5UGYKEGJ.js} +1 -1
  172. package/dist/chunks/{store-create-improve-UTCLBXF2.js → store-create-improve-APLPTVYQ.js} +1 -1
  173. package/dist/chunks/{store-datasets-4AQOVAQY.js → store-datasets-HDW6IYBL.js} +1 -1
  174. package/dist/chunks/{store-evaluation-results-PK2P3IMH.js → store-evaluation-results-KB2UDCF3.js} +1 -1
  175. package/dist/chunks/{store-harness-workspaces-YEXB4IRV.js → store-harness-workspaces-TKX5PZWP.js} +1 -1
  176. package/dist/chunks/{store-human-review-O4BVHP25.js → store-human-review-IURNTX3C.js} +1 -1
  177. package/dist/chunks/{store-learned-preference-migration-validation-44SVX6YB.js → store-learned-preference-migration-validation-TH2LKQWV.js} +1 -1
  178. package/dist/chunks/{store-learning-SIUQIY5C.js → store-learning-WLUW2PWE.js} +1 -1
  179. package/dist/chunks/{store-learning-credentials-BUHR7SN6.js → store-learning-credentials-FDKCEDHK.js} +1 -1
  180. package/dist/chunks/{store-local-experiments-BHVTKPPE.js → store-local-experiments-M4V5RLHJ.js} +1 -1
  181. package/dist/chunks/{store-model-batch-review-RVAYUVK2.js → store-model-batch-review-DDZLWVTG.js} +1 -1
  182. package/dist/chunks/{store-model-configuration-AYFGMC5D.js → store-model-configuration-ATOFA5OH.js} +1 -1
  183. package/dist/chunks/{store-model-project-preparation-5DEIS7TB.js → store-model-project-preparation-ZRSCQEQR.js} +1 -1
  184. package/dist/chunks/{store-modification-recordings-LCPK6K2T.js → store-modification-recordings-YJIDUPVJ.js} +1 -1
  185. package/dist/chunks/{store-preference-comparison-5YVIQNVB.js → store-preference-comparison-JKURBESE.js} +1 -1
  186. package/dist/chunks/{store-task-inbox-L6IQTY26.js → store-task-inbox-L53OT6ZC.js} +1 -1
  187. package/dist/chunks/{store-task-inventory-QWS2C656.js → store-task-inventory-R2JJGAHW.js} +1 -1
  188. package/dist/chunks/{store-taskset-drafts-EAOOY6CR.js → store-taskset-drafts-FPNJPFPO.js} +1 -1
  189. package/dist/chunks/{store-training-FYXZU2FE.js → store-training-DIBW7OMP.js} +1 -1
  190. package/dist/chunks/{store-training-jobs-3N3VKPIY.js → store-training-jobs-K7I4SXWW.js} +1 -1
  191. package/dist/chunks/{store-training-models-VOFVGPZR.js → store-training-models-LCSB37YY.js} +1 -1
  192. package/dist/chunks/{taskset-HNDIGYQG.js → taskset-XI5SJBJL.js} +1 -1
  193. package/dist/chunks/{taskset-packages-WMG5DUBN.js → taskset-packages-FUQWNTSB.js} +1 -1
  194. package/dist/chunks/{taskset-packages-T6B6HYKZ.js → taskset-packages-GM6IUOTY.js} +1 -1
  195. package/dist/chunks/{teams-bot-Z5CZLWE4.js → teams-bot-CYC5TR64.js} +1 -1
  196. package/dist/chunks/{tool-learning-ZQ6NSJ5K.js → tool-learning-52QZIJIR.js} +1 -1
  197. package/dist/chunks/{training-JTYQA7GA.js → training-GDLLLXSV.js} +1 -1
  198. package/dist/chunks/training-RL7UUBER.js +2 -0
  199. package/dist/chunks/training-UJ62NOJJ.js +2 -0
  200. package/dist/chunks/{training-hosted-36SZFS4U.js → training-hosted-V5CHG3M3.js} +1 -1
  201. package/dist/chunks/{training-hosted-alphaedit-HSMRDJTD.js → training-hosted-alphaedit-R5PVATV4.js} +1 -1
  202. package/dist/chunks/{training-hosted-decision-7JALOU6O.js → training-hosted-decision-WNK5DE3M.js} +1 -1
  203. package/dist/chunks/{training-hosted-engram-SXO75MFG.js → training-hosted-engram-ZQDOKXAV.js} +1 -1
  204. package/dist/chunks/{training-hosted-learning-E2N32YU5.js → training-hosted-learning-UEBGSSNC.js} +1 -1
  205. package/dist/chunks/{training-hosted-modification-comparison-TXFDJFTG.js → training-hosted-modification-comparison-KKI5CKOH.js} +1 -1
  206. package/dist/chunks/{training-hosted-neuron-training-J42WK4EH.js → training-hosted-neuron-training-CFWEDRSR.js} +1 -1
  207. package/dist/chunks/{training-hosted-serving-report-BAEABGJH.js → training-hosted-serving-report-N4NF5AVW.js} +1 -1
  208. package/dist/chunks/{training-hosted-steering-T556BUBG.js → training-hosted-steering-4MDUQ2YV.js} +1 -1
  209. package/dist/chunks/{training-model-start-P3PXDWNT.js → training-model-start-NOA6TYQK.js} +1 -1
  210. package/dist/cli.js +1 -1
  211. package/dist/index.js +1 -1
  212. package/dist/skills/manifest.json +3 -3
  213. package/dist/skills/openpond-cli/references/experiments-and-training.md +19 -0
  214. package/dist/web/assets/App-L7RV4D0A.js +54 -0
  215. package/dist/web/assets/{AppDialog-x1HU1uLv.js → AppDialog-B2V84J7f.js} +1 -1
  216. package/dist/web/assets/{AppTerminalPanel-CNIKmqKc.js → AppTerminalPanel-DfYpUDKT.js} +2 -2
  217. package/dist/web/assets/{AppToastContext-DNWd43HS.js → AppToastContext-DuiPouLz.js} +1 -1
  218. package/dist/web/assets/{AppsView-BvOD83Z1.js → AppsView-B20RHDCy.js} +1 -1
  219. package/dist/web/assets/{AttachmentTypeIcon-BLdDr3JZ.js → AttachmentTypeIcon-l-GRNxaz.js} +1 -1
  220. package/dist/web/assets/{BrowserSidebar-Ar0FlFKg.js → BrowserSidebar-Ce0ToS2O.js} +1 -1
  221. package/dist/web/assets/{CartesianChart-tS7f1HZv.js → CartesianChart-CtfMRAfp.js} +1 -1
  222. package/dist/web/assets/{ChatTimelineEntry-z7_kur3h.js → ChatTimelineEntry-DzcucW20.js} +1 -1
  223. package/dist/web/assets/{CollaborationTabs-CaiFEKrv.js → CollaborationTabs-BpmKjNAC.js} +1 -1
  224. package/dist/web/assets/{CommandMenu-BpubEqaA.js → CommandMenu-JXsoxijv.js} +1 -1
  225. package/dist/web/assets/{CommunityView-TGR4s99l.js → CommunityView-ggdn8pcH.js} +1 -1
  226. package/dist/web/assets/{ComposerAttachments-DPWCjKXz.js → ComposerAttachments-BMmALUs_.js} +1 -1
  227. package/dist/web/assets/{ComposerCreateImproveStrip-Drji01_6.js → ComposerCreateImproveStrip-DcM1bkfu.js} +1 -1
  228. package/dist/web/assets/{ConversationImportsSettings-B_oW0cz7.js → ConversationImportsSettings-BKNeARHI.js} +1 -1
  229. package/dist/web/assets/{DatasetReviewImport-Dr3unJSY.js → DatasetReviewImport-DyFOE0Q0.js} +1 -1
  230. package/dist/web/assets/{ExperimentTrainingDataWorkspace-DObvpJAw.js → ExperimentTrainingDataWorkspace-CfOyoMrq.js} +2 -2
  231. package/dist/web/assets/{FilePagePreview-9kkXbARN.js → FilePagePreview-B7bWObJN.js} +2 -2
  232. package/dist/web/assets/{GetStartedView-Dv2b_SlH.js → GetStartedView-BYbFl93M.js} +1 -1
  233. package/dist/web/assets/{GettingStartedDialog-sPaPMc61.js → GettingStartedDialog-UgreDozV.js} +1 -1
  234. package/dist/web/assets/{HostedModelLearningReview-BlwhGxS6.js → HostedModelLearningReview-C_kng2U_.js} +1 -1
  235. package/dist/web/assets/{HostedModelLearningSettings-B5ahk3je.js → HostedModelLearningSettings-aesD_ifF.js} +1 -1
  236. package/dist/web/assets/{HtmlVisual-rGsClq0p.js → HtmlVisual-nvl1x-jh.js} +1 -1
  237. package/dist/web/assets/{LabModelVersionDetailPage-Da7AwZWV.js → LabModelVersionDetailPage-DrdoNvI-.js} +1 -1
  238. package/dist/web/assets/{LabModelWorkspace-DTeYViWH.js → LabModelWorkspace-CHlhzG3q.js} +1 -1
  239. package/dist/web/assets/{LabSkillSidebar-BieHbNl6.js → LabSkillSidebar-CqHeZzoj.js} +1 -1
  240. package/dist/web/assets/{LabsRoute-D3XqPB0-.js → LabsRoute-DzEbPpMK.js} +4 -4
  241. package/dist/web/assets/{LearningBatchesPage-CCBuf2u4.js → LearningBatchesPage-A2dFQW2j.js} +1 -1
  242. package/dist/web/assets/{MainChatThread-B6BQJfcq.js → MainChatThread-BSvKu4e5.js} +2 -2
  243. package/dist/web/assets/{MainPane-D3fQou29.js → MainPane-DiWIAxMj.js} +6 -6
  244. package/dist/web/assets/{ModelProjectPageHeader-BZn9Lu_J.js → ModelProjectPageHeader-lu6iRXHK.js} +1 -1
  245. package/dist/web/assets/{NativeSetupTerminal-Bglqab_g.js → NativeSetupTerminal-kZ-nFPE8.js} +2 -2
  246. package/dist/web/assets/{NativeSkillSidebar-pUGRdnV_.js → NativeSkillSidebar-DkkD1uH2.js} +1 -1
  247. package/dist/web/assets/{NewProjectDialog-BpHN38MA.js → NewProjectDialog-Dg8dMEpc.js} +1 -1
  248. package/dist/web/assets/{OutputsPage-LunDCQ6w.js → OutputsPage-Dz190U9t.js} +1 -1
  249. package/dist/web/assets/{PageChrome-DThEcWAx.js → PageChrome-Bncv-ps0.js} +1 -1
  250. package/dist/web/assets/{ProjectsPage-vct_TQgL.js → ProjectsPage-DVkYvLtd.js} +1 -1
  251. package/dist/web/assets/{RightChatPanelStack-CgFK7DY0.js → RightChatPanelStack-CP4leenI.js} +1 -1
  252. package/dist/web/assets/RightSidebarHomePanel-C0etQXpt.js +1 -0
  253. package/dist/web/assets/{ScheduledWorkPage-mmaZfybl.js → ScheduledWorkPage-DI0mgt82.js} +1 -1
  254. package/dist/web/assets/{SettingsView-CJfeRsWR.js → SettingsView-cCtkr089.js} +3 -3
  255. package/dist/web/assets/{TasksetDraftEditorPrimitives-CuimAfkv.js → TasksetDraftEditorPrimitives-DCQTuswJ.js} +1 -1
  256. package/dist/web/assets/{TeamChatView-BcK0lF1b.js → TeamChatView-BBEomfQ7.js} +1 -1
  257. package/dist/web/assets/{TerminalOverlay-0pzEvy-C.js → TerminalOverlay-Dj5NUDMp.js} +1 -1
  258. package/dist/web/assets/{TrainingCreationPanel-CcyzFz7l.js → TrainingCreationPanel-Ds4PLfsd.js} +1 -1
  259. package/dist/web/assets/{TrainingDraftPanel-DSLZXdLz.js → TrainingDraftPanel-BAuh_BF3.js} +1 -1
  260. package/dist/web/assets/{UsageSettingsSection-BT9pcnCn.js → UsageSettingsSection-DbzeatcW.js} +1 -1
  261. package/dist/web/assets/WorkSidebarPanel-BaNuXoZc.js +1 -0
  262. package/dist/web/assets/{WorkspaceDiffPanel-Bbz5qrVA.js → WorkspaceDiffPanel-xk-ve1MO.js} +3 -3
  263. package/dist/web/assets/{WorkspaceEnvironmentMenu-6hXpvMTl.js → WorkspaceEnvironmentMenu-D8GSuoYz.js} +1 -1
  264. package/dist/web/assets/{WorkspaceFileLocation-BijVemBl.js → WorkspaceFileLocation-Dl8M2ZKN.js} +1 -1
  265. package/dist/web/assets/{WorkspaceGitDialogs-BOO0E5i9.js → WorkspaceGitDialogs-9BhLjYx4.js} +1 -1
  266. package/dist/web/assets/{WorkspaceMonacoEditor-B_YzK7Do.js → WorkspaceMonacoEditor-DYPuC7pj.js} +3 -3
  267. package/dist/web/assets/{WorkspacePdfPreview-CFti1fvu.js → WorkspacePdfPreview-B7BI9tLR.js} +2 -2
  268. package/dist/web/assets/{WorkspacePresentationPreview-DPAhNaV6.js → WorkspacePresentationPreview-sP7JUT7m.js} +1 -1
  269. package/dist/web/assets/{bot-BE2rL_qv.js → bot-D7M8ZtE6.js} +1 -1
  270. package/dist/web/assets/{chat-resources-Beh5lB36.js → chat-resources-DhKAnljP.js} +1 -1
  271. package/dist/web/assets/chevron-down-BAEcJitl.js +1 -0
  272. package/dist/web/assets/chevron-right-3G9s2cQ9.js +1 -0
  273. package/dist/web/assets/chevron-up-DTYF52H1.js +1 -0
  274. package/dist/web/assets/{chunk-C3TS766N-j1MK0e3c.js → chunk-C3TS766N-DENE60SE.js} +1 -1
  275. package/dist/web/assets/{client-choice-storage-CQ0CNkzG.js → client-choice-storage-DYZsrVr9.js} +1 -1
  276. package/dist/web/assets/{client-BnJhN-14.js → client-gy7zrd7a.js} +1 -1
  277. package/dist/web/assets/{cloud-upload-DFjZE4O4.js → cloud-upload-De-XSMUr.js} +1 -1
  278. package/dist/web/assets/{copy-CGrLUtw5.js → copy-DEK20zbZ.js} +1 -1
  279. package/dist/web/assets/{cssMode-DvRw2fUx.js → cssMode-Dau-Fhqf.js} +1 -1
  280. package/dist/web/assets/{external-link-3ZnEFUXd.js → external-link-DwDry0Fb.js} +1 -1
  281. package/dist/web/assets/{folder-open-i9n8450i.js → folder-open-DOb4AjV6.js} +1 -1
  282. package/dist/web/assets/{folder-plus-cu8Md_ej.js → folder-plus-BAouDaXv.js} +1 -1
  283. package/dist/web/assets/{git-commit-horizontal-CwckmC09.js → git-commit-horizontal-DZbHXcai.js} +1 -1
  284. package/dist/web/assets/{htmlMode-8VF4Ovtw.js → htmlMode-DlNEe6hu.js} +1 -1
  285. package/dist/web/assets/{icons-4yRSxBZj.js → icons-OQhKVrDc.js} +1 -1
  286. package/dist/web/assets/{image-D-umhyyK.js → image-BkYJDChH.js} +1 -1
  287. package/dist/web/assets/{index-DiVhx1GM.js → index-M_h2Ok4V.js} +2 -2
  288. package/dist/web/assets/{info-Dq2RsPDJ.js → info-Mj5lp4Ic.js} +1 -1
  289. package/dist/web/assets/{jsonMode-CvCYQHkB.js → jsonMode-CyOEyonV.js} +1 -1
  290. package/dist/web/assets/loader-circle-DXVtGvuV.js +1 -0
  291. package/dist/web/assets/{lspLanguageFeatures-CjufNNFF.js → lspLanguageFeatures-DAYPzatg.js} +1 -1
  292. package/dist/web/assets/{maximize-2-CKY8dua6.js → maximize-2-BwFXSX6b.js} +1 -1
  293. package/dist/web/assets/{message-square-CVDgKlKX.js → message-square-C2nqfNLn.js} +1 -1
  294. package/dist/web/assets/{monaco.contribution-BYAgjZbj.js → monaco.contribution-BZcNCJER.js} +2 -2
  295. package/dist/web/assets/{monaco.contribution-BYY3-y9l.js → monaco.contribution-BZkfRhss.js} +2 -2
  296. package/dist/web/assets/{monaco.contribution-Bh0CKj9i.js → monaco.contribution-D7_X8TXe.js} +2 -2
  297. package/dist/web/assets/{monaco.contribution-PjJ1258q.js → monaco.contribution-KyLdVay7.js} +2 -2
  298. package/dist/web/assets/{monitor-UYe42gew.js → monitor-B0Qj5Wea.js} +1 -1
  299. package/dist/web/assets/{paperclip-DrlSVUoz.js → paperclip-CmrRruxi.js} +1 -1
  300. package/dist/web/assets/{pdf-BMhday2W.js → pdf-BM-9_48p.js} +1 -1
  301. package/dist/web/assets/play-CkACZ6Zo.js +1 -0
  302. package/dist/web/assets/plus-CB258e62.js +1 -0
  303. package/dist/web/assets/{presentation-DcZKqH7w.js → presentation-BYxhoSIo.js} +1 -1
  304. package/dist/web/assets/{python-CiA01i07.js → python-B3Mj03I5.js} +1 -1
  305. package/dist/web/assets/{refresh-cw-00D-GDnF.js → refresh-cw-CwEmO71D.js} +1 -1
  306. package/dist/web/assets/{save-CXe7bqR7.js → save-S--FOuce.js} +1 -1
  307. package/dist/web/assets/{settings-lists-B5J40WM6.js → settings-lists-ChqDppMP.js} +1 -1
  308. package/dist/web/assets/square-BmPfHjGU.js +1 -0
  309. package/dist/web/assets/{square-terminal-DxC7TTds.js → square-terminal-CawpQtCi.js} +1 -1
  310. package/dist/web/assets/{submit-issue-command-Dq3TqJLV.js → submit-issue-command-CFitxxmO.js} +1 -1
  311. package/dist/web/assets/{toggleHighContrast-BH3Jckfo.js → toggleHighContrast-D-cMCvXx.js} +1 -1
  312. package/dist/web/assets/training-CzbWtx75.js +1 -0
  313. package/dist/web/assets/{training-model-data-B6IZ3x-t.js → training-model-data-G-D64935.js} +1 -1
  314. package/dist/web/assets/{tsMode-DXkj4bqC.js → tsMode-9kzS1ijG.js} +1 -1
  315. package/dist/web/assets/{upload-B3KRHVHl.js → upload-CtYsSYrM.js} +1 -1
  316. package/dist/web/assets/{useAccountSettings-BGRkTRrp.js → useAccountSettings-DYYa6puz.js} +1 -1
  317. package/dist/web/assets/{useAgentInventory-D_1AlAZJ.js → useAgentInventory-c5B_Tszj.js} +1 -1
  318. package/dist/web/assets/{useChatContextSelection-hoMSuUSE.js → useChatContextSelection-DOISZpTz.js} +1 -1
  319. package/dist/web/assets/{useLocalAgentSchedules-DxTER7Ow.js → useLocalAgentSchedules-QJ8RsMKm.js} +1 -1
  320. package/dist/web/assets/{useQuery-DkPec_9x.js → useQuery-DuTGOe2b.js} +1 -1
  321. package/dist/web/assets/{wifi-off-CMzpvbWl.js → wifi-off-BOfP4Vmg.js} +1 -1
  322. package/dist/web/assets/{workers-ziY_bTv2.js → workers-BwGpyrdj.js} +1 -1
  323. package/dist/web/assets/x-5_iy6IDd.js +1 -0
  324. package/dist/web/assets/{yaml-mSvqVSko.js → yaml-BU4IWV_7.js} +1 -1
  325. package/dist/web/index.html +1 -1
  326. package/docs/command-reference.md +1 -0
  327. package/package.json +1 -1
  328. package/dist/chunks/chunk-6D3FI2XT.js +0 -2
  329. package/dist/chunks/chunk-VEBW7NKD.js +0 -2
  330. package/dist/chunks/cli-ALEEFAJ7.js +0 -2
  331. package/dist/chunks/host-profile-evaluation-tools-UF4ATIUF.js +0 -2
  332. package/dist/chunks/hosted-harness-runtime-MMTLCL23.js +0 -2
  333. package/dist/chunks/local-harness-improvement-runtime-3YJQRYXC.js +0 -2
  334. package/dist/chunks/local-harness-taskset-review-E5GN5LTR.js +0 -2
  335. package/dist/chunks/saved-work-54I5ZJTC.js +0 -2
  336. package/dist/chunks/training-5NT2YB2L.js +0 -2
  337. package/dist/chunks/training-UY6KRG4M.js +0 -2
  338. package/dist/web/assets/App-CXhxya9x.js +0 -54
  339. package/dist/web/assets/RightSidebarHomePanel-BJmzUcmy.js +0 -1
  340. package/dist/web/assets/WorkSidebarPanel-CP-nHAsJ.js +0 -1
  341. package/dist/web/assets/chevron-down-Bn8yph2O.js +0 -1
  342. package/dist/web/assets/chevron-right-BU-jUmb2.js +0 -1
  343. package/dist/web/assets/chevron-up-DacwuDJZ.js +0 -1
  344. package/dist/web/assets/loader-circle-DBl6qqtR.js +0 -1
  345. package/dist/web/assets/play-DIqZnaNf.js +0 -1
  346. package/dist/web/assets/plus-CFNxAPMK.js +0 -1
  347. package/dist/web/assets/square-DJEaBefe.js +0 -1
  348. package/dist/web/assets/training-DWfghwfZ.js +0 -1
  349. package/dist/web/assets/x-omjwMPbJ.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as Ae}from"./chunk-GW766ZSO.js";import{B as O,a as Ce,b as Pe}from"./chunk-OFJPOTES.js";import{b as be}from"./chunk-YU3C6U5V.js";import{d as H}from"./chunk-U7D6Q744.js";import{a as re,b as ye,j as A}from"./chunk-6ESBAHWK.js";import{f as Ie}from"./chunk-JT5YQ52I.js";import{D as we}from"./chunk-2MEOUS24.js";import{n as $}from"./chunk-RCT3O3HQ.js";import{a as o}from"./chunk-FTQLQJQV.js";import{existsSync as z}from"node:fs";import{cp as xe,mkdir as Ee,readFile as Oe}from"node:fs/promises";import k from"node:path";import{existsSync as L}from"node:fs";import{readFile as K}from"node:fs/promises";import q from"node:path";async function F(e){await V(e.target);let t={},a=new Set([`${e.target.sourceRootRelativePath}/.openpond/agent-inspect.json`,`${e.target.sourceRootRelativePath}/.openpond/action-registry.json`,`${e.target.sourceRootRelativePath}/.openpond/eval-results.json`]),n=[{name:"inspect",command:"inspect",args:["--json"]},{name:"build",command:"build"},{name:"validate",command:"validate",args:["--json"]},{name:"eval",command:"eval",args:["--json"]},{name:"direct-run",command:"run",args:[e.target.defaultAction,"--json","--input",JSON.stringify({prompt:e.snapshot.objective,channel:"openpond_chat"})]}];for(let r of n){let s=await O({cwd:e.target.sourceRoot,command:r.command,args:r.args,...r.command==="eval"&&e.requireEvalPass===!1?{throwOnFailure:!1}:{}});if(s.code!==0&&!(r.command==="eval"&&e.requireEvalPass===!1))throw new Error(s.stderr.trim()||s.stdout.trim()||`${r.command} failed with exit code ${s.code??"unknown"}`);let i=lt(s.stdout),d=mt(i);d&&a.add(q.join(e.target.sourceRootRelativePath,d)),t[r.name]={summary:pt(r.name,i),traceArtifactRef:d,stdout:s.stdout.trim().slice(0,4e3),stderr:s.stderr.trim().slice(0,4e3)}}return await dt(e.target,e.requireEvalPass!==!1),{checkRefs:[...a],metadata:t}}o(F,"runLocalCreatePipelineChecks");async function V(e){if(!L(e.sourceRoot))throw new Error(`Codex did not create the expected agent source root: ${e.sourceRoot}`);let t=q.join(e.sourceRoot,"agent","agent.ts");if(!L(t))throw new Error(`Codex did not create the expected SDK agent source: ${t}`);let a=q.join(e.repoPath,"openpond-profile.json");if(!L(a))throw new Error(`Codex did not update the profile repo manifest: ${a}`);let n=q.join(e.sourcePath,"settings","profile.yaml");if(!L(n))throw new Error(`Codex did not update the profile manifest: ${n}`);let s=JSON.parse(await K(a,"utf8")).profiles?.[e.activeProfile];if(!s)throw new Error(`openpond-profile.json does not register profile ${e.activeProfile}.`);if(!s.enabledAgents?.includes(e.agentId))throw new Error(`openpond-profile.json does not enable generated agent ${e.agentId}.`);let i=await K(n,"utf8");if(!i.includes(`id: ${e.agentId}`)&&!i.includes(`id: "${e.agentId}"`))throw new Error(`settings/profile.yaml does not register generated agent ${e.agentId}.`);let d=e.agentId==="default"?["agent/agent.ts","agent"]:[`agents/${e.agentId}`];if(!d.some(u=>i.includes(u)))throw new Error(`settings/profile.yaml does not point ${e.agentId} at ${d[0]}.`)}o(V,"assertLocalCreateSourceLayout");async function dt(e,t=!0){let a=q.join(e.sourceRoot,".openpond","action-registry.json"),n=q.join(e.sourceRoot,".openpond","eval-results.json");if(!L(a))throw new Error(`Generated source did not produce an action registry: ${a}`);if(!L(n))throw new Error(`Generated source did not produce eval results: ${n}`);let r=JSON.parse(await K(a,"utf8")),s=Array.isArray(r.actions)?r.actions:[];if(!new Set(s.map(c=>typeof c.id=="string"?c.id:null).filter(c=>!!c)).has(e.defaultAction))throw new Error(`Generated action registry does not expose default action ${e.defaultAction}.`);let d=s.filter(c=>typeof c.id=="string"&&(!W(c.label)||!W(c.description)||typeof c.timeoutSeconds!="number"));if(d.length>0)throw new Error(`Generated action registry has actions missing labels, descriptions, or timeout policies: ${d.map(c=>c.id).join(", ")}`);let u=Ce({actionCatalog:s.filter(c=>typeof c.id=="string").map(c=>({id:c.id,name:W(c.name),setupRequirements:ut(c.setupRequirements)??[]})),actionId:e.defaultAction});if(u.blockingRequirements.length>0)throw new Error(`Generated default action ${e.defaultAction} has unresolved required setup and cannot be ready_local: ${u.blockingRequirements.map(Pe).join("; ")}. Mark built-in/local fixture requirements ready or optional when they are satisfied, or leave the pipeline blocked until the setup is configured.`);let m=JSON.parse(await K(n,"utf8"));if(typeof m.summary?.total!="number"||m.summary.total<1)throw new Error("Generated source must define at least one deterministic SDK eval.");if(t&&m.summary.failed!==0)throw new Error("Generated source evals did not all pass.")}o(dt,"assertGeneratedSdkArtifacts");function lt(e){let t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{return JSON.parse(t)}catch{return null}}o(lt,"parseJsonOutput");function E(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}o(E,"asRecord");function ut(e){return Array.isArray(e)?e.filter(t=>!!E(t)):null}o(ut,"recordArray");function mt(e){let t=E(e),a=W(t?.traceArtifactRef);return a?.startsWith(".openpond/")?a:null}o(mt,"traceRefFromCommandResult");function pt(e,t){let a=E(t);return a?e==="inspect"?{actionCount:Array.isArray(a.actionCatalog)?a.actionCatalog.length:null,defaultAction:E(a.agent)?.defaultAction??null,projectName:E(a.project)?.name??null}:e==="validate"?{status:a.status??null,errors:E(a.summary)?.errors??null,warnings:E(a.summary)?.warnings??null}:e==="eval"?E(a.summary):e==="direct-run"?{hasResult:!!E(a.result),resultKeys:Object.keys(E(a.result)??{})}:null:null}o(pt,"summaryFromCommandResult");function W(e){return typeof e=="string"&&e.trim()?e.trim():null}o(W,"stringValue");var gt="Approved local Create plans require model-backed SDK source application; no source mutation was performed.",ft=1800*1e3,Te=".openpond-harness-source-application.json",ht=300*1e3,vt=2*1e3,Rt=5*1e3;async function He(e,t={}){if(!kt(e))return e;let a=t.now??(()=>new Date().toISOString()),n=e.adapter;if(n.kind!=="local")return e;if(!t.session||!t.turn||!t.ensureCodexRuntime||!t.appendRuntimeEvent||!t.setProviderTurnId)return Y(e,{now:a(),reason:gt,metadata:{reason:"model_backed_source_application_required",sourcePath:n.sourcePath??null,repoPath:n.repoPath??null,activeProfile:n.activeProfile??null,operation:e.operation,requestedAgentId:e.target.kind==="agent"?e.target.id:null}});let r;try{r=se(e)}catch(i){return Y(e,{now:a(),reason:i instanceof Error?i.message:String(i),metadata:{reason:"local_create_target_unresolved"}})}try{await ie({snapshot:e,session:t.session,turn:t.turn,target:r,ensureCodexRuntime:t.ensureCodexRuntime,appendRuntimeEvent:t.appendRuntimeEvent,setProviderTurnId:t.setProviderTurnId,model:t.model??we,codexReasoningEffort:t.codexReasoningEffort})}catch(i){return Y(e,{now:a(),reason:i instanceof Error?i.message:String(i),metadata:{reason:"model_backed_source_application_failed",target:r}})}let s=oe(e,{state:"running_checks",now:a(),blockedReason:null,sourceRefs:[r.sourceRootRelativePath,k.join(r.profileRelativePath,"settings","profile.yaml"),"openpond-profile.json"],metadata:{localCreatePipeline:{status:"running_checks",target:r}},candidates:[{id:Se(e.id),target:{kind:"agent",id:r.agentId,displayName:e.target.displayName,defaultActionKey:r.defaultAction},status:"checking",git:null,parentCandidateId:null,tasksetRef:e.tasksetRef,authoringModelRef:t.model??null,allowedPaths:e.plan?.sourcePlan.map(i=>i.path)??[],sourceRefs:[r.sourceRootRelativePath,k.join(r.profileRelativePath,"settings","profile.yaml"),"openpond-profile.json"],artifactRefs:[],checkRefs:[],evaluationReceiptRefs:[],createdAt:e.createdAt,updatedAt:a(),metadata:{sourceAuthority:e.adapter.sourceAuthority}}]});await t.onSnapshot?.(s);try{let i=await(t.runChecks??F)({snapshot:s,target:r}),d=a(),u=Se(e.id),m=`agent_eval_${e.id}`;return oe(s,{state:"ready_local",now:d,blockedReason:null,checkRefs:i.checkRefs,candidates:s.candidates.map(c=>c.id===u?{...c,status:"accepted",checkRefs:X(c.checkRefs,i.checkRefs),evaluationReceiptRefs:X(c.evaluationReceiptRefs,[m]),updatedAt:d}:c),evaluationReceipts:[...s.evaluationReceipts.filter(c=>c.id!==m),{id:m,candidateId:u,target:{kind:"agent",id:r.agentId,displayName:e.target.displayName,defaultActionKey:r.defaultAction},evaluatorKind:"agent_sdk",subject:"candidate",sourceCommit:e.adapter.kind==="local"?e.adapter.localHead:null,sourceBranch:null,tasksetId:e.tasksetRef?.id??null,tasksetHash:e.tasksetRef?.contentHash??null,taskAttemptRefs:i.checkRefs.filter(c=>c.includes("eval")),status:"passed",publishGate:"passed",summaryCounts:null,evalRefs:i.checkRefs.filter(c=>c.includes("eval")),artifactRefs:i.checkRefs,summary:wt(i.metadata),createdAt:d,metadata:i.metadata??{}}],metadata:{localCreatePipeline:{status:"ready_local",target:r,checks:i.metadata??{}}}})}catch(i){return Y(s,{now:a(),reason:i instanceof Error?i.message:String(i),metadata:{reason:"local_create_checks_failed",target:r}})}}o(He,"applyApprovedLocalCreateImproveRun");function kt(e){return e.state==="applying_source"&&e.plan?.status==="approved"&&e.adapter.kind==="local"&&e.target.kind==="agent"}o(kt,"shouldApplyLocalCreatePipeline");function oe(e,t){return A(e,{state:t.state,blockedReason:t.blockedReason===void 0?e.blockedReason:t.blockedReason,checkRefs:X(e.checkRefs,t.checkRefs??[]),sourceRefs:X(e.sourceRefs,t.sourceRefs??[]),candidates:t.candidates??e.candidates,evaluationReceipts:t.evaluationReceipts??e.evaluationReceipts,metadata:{...e.metadata,...t.metadata??{}},updatedAt:t.now})}o(oe,"transitionCreatePipeline");function Y(e,t){return oe(e,{state:"blocked",now:t.now,blockedReason:t.reason,metadata:{localCreatePipeline:{status:"blocked",...t.metadata}}})}o(Y,"blockLocalCreatePipeline");function X(e,t){return Array.from(new Set([...e,...t].filter(Boolean)))}o(X,"mergeRefs");function Se(e){return`agent_candidate_${e}`}o(Se,"agentCandidateId");function wt(e){let t=M(e?.eval),a=typeof t?.total=="number"?t.total:null;return a===null?"Agent SDK checks and deterministic Evals passed.":`${a} Agent SDK Eval${a===1?"":"s"} passed.`}o(wt,"checkSummary");function se(e){let t=e.adapter;if(t.kind!=="local")throw new Error("Create/Improve target must use the local adapter.");if(e.target.kind!=="agent")throw new Error("Local agent source application requires an Agent target.");let a=t.sourcePath?.trim(),n=t.repoPath?.trim();if(!a)throw new Error("Local Create approval is missing a profile source path.");if(!n)throw new Error("Local Create approval is missing a profile repo path.");let r=t.activeProfile?.trim()||"default",s=k.resolve(a),i=k.resolve(n),d=qe(e.target.id)??xt(e)??St(e.objective),u=Tt(Et(e.plan?.defaultChatAction.key)??"chat",d),m=e.operation==="improve"&&d==="default"?s:k.join(s,"agents",d);return{activeProfile:r,agentId:d,defaultAction:u,repoPath:i,sourcePath:s,workspaceRoot:i,profileRelativePath:je(k.relative(i,s)),sourceRoot:m,sourceRootRelativePath:je(k.relative(i,m))}}o(se,"resolveLocalCreatePipelineTarget");async function ie(e){if(!z(e.target.workspaceRoot))throw new Error(`Profile repo path does not exist: ${e.target.workspaceRoot}`);if(!z(e.target.sourcePath))throw new Error(`Profile source path does not exist: ${e.target.sourcePath}`);if(await Ct(e.snapshot,e.target)){await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"completed",output:`Applied prepared harness ${e.snapshot.operation==="improve"?"Improve":"Create"} source for ${e.target.agentId}; running local checks.`,data:{phase:"prepared_source_apply_completed",runId:e.snapshot.id,target:e.target}}));return}await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"started",output:`Applying approved ${e.snapshot.operation==="improve"?"Improve":"Create"} plan with Codex in ${e.target.sourceRootRelativePath}.`,data:{phase:"source_apply_started",runId:e.snapshot.id,target:e.target}}));let t={...e.session,provider:"codex",cwd:e.target.workspaceRoot,workspaceKind:"local_project",workspaceId:e.session.workspaceId??`openpond-profile:${e.target.activeProfile}`,workspaceName:e.session.workspaceName??`OpenPond profile ${e.target.activeProfile}`},a=e.session.provider==="codex"?e.model:null,n=await e.ensureCodexRuntime(t,{approvalPolicy:"never",sandbox:"workspace-write",model:a,codexPermissionMode:"auto-review",codexReasoningEffort:e.codexReasoningEffort}),r=await n.client.startTurn({threadId:n.threadId,prompt:At(e.snapshot,e.target),cwd:e.target.workspaceRoot,model:a,approvalPolicy:"never",sandbox:"workspace-write"});await e.setProviderTurnId(r.turnId);try{await n.client.waitForTurn(r.turnId,ft)}catch(s){if(!$e(s,r.turnId)&&!It(s))throw s;let i=$e(s,r.turnId)?"timed out":"exited cleanly before returning a turn completion";if(await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"started",output:`Codex source application ${i}; checking for completed generated source before blocking.`,data:{phase:"source_apply_recovery_started",runId:e.snapshot.id,providerTurnId:r.turnId,reason:i,target:e.target}})),!await yt(e.target))throw s;await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"completed",output:`Recovered completed ${e.snapshot.operation==="improve"?"Improve":"Create"} source after Codex source application ${i} for ${e.target.agentId}; running local checks.`,data:{phase:"source_apply_recovered",runId:e.snapshot.id,providerTurnId:r.turnId,reason:i,target:e.target}}))}await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"provider",appId:e.session.appId,status:"completed",output:`Codex completed approved ${e.snapshot.operation==="improve"?"Improve":"Create"} source application for ${e.target.agentId}.`,data:{phase:"source_apply_completed",runId:e.snapshot.id,providerTurnId:r.turnId,target:e.target}}))}o(ie,"runModelBackedLocalCreateSourceApplication");async function Ct(e,t,a=process.env){if(!Ae(a))return!1;let n=k.join(t.workspaceRoot,Te);if(!z(n))return!1;let r=JSON.parse(await Oe(n,"utf8")),s=M(r);if(s?.schema!=="openpond.harnessPreparedSource.v1")throw new Error(`${Te} must use schema openpond.harnessPreparedSource.v1.`);let i=M(s.agents),d=M(i?.[t.agentId]),u=Pt(d?.[e.operation]);if(!u)return!1;let m=ne(t.workspaceRoot,u.source,"source");if(!z(m))throw new Error(`Prepared harness source does not exist: ${u.source}`);await Ee(t.sourceRoot,{recursive:!0}),await xe(m,t.sourceRoot,{recursive:!0,force:!0});for(let c of u.registrations??[]){let g=ne(t.workspaceRoot,c.source,"registration source"),l=ne(t.workspaceRoot,c.target,"registration target");if(!z(g))throw new Error(`Prepared harness registration source does not exist: ${c.source}`);await Ee(k.dirname(l),{recursive:!0}),await xe(g,l,{force:!0})}return!0}o(Ct,"applyPreparedHarnessSourceApplication");function Pt(e){let t=M(e);if(!t||typeof t.source!="string"||!t.source.trim())return null;if(t.registrations!==void 0&&!Array.isArray(t.registrations))throw new Error("Prepared harness source registrations must be an array.");let a=(t.registrations??[]).map(n=>{let r=M(n);if(!r||typeof r.source!="string"||!r.source.trim()||typeof r.target!="string"||!r.target.trim())throw new Error("Prepared harness source registrations require source and target paths.");return{source:r.source,target:r.target}});return{source:t.source,registrations:a}}o(Pt,"asHarnessPreparedSourceOperation");function ne(e,t,a){if(k.isAbsolute(t))throw new Error(`Prepared harness ${a} must be relative to the profile repo.`);let n=k.resolve(e),r=k.resolve(n,t);if(r!==n&&!r.startsWith(`${n}${k.sep}`))throw new Error(`Prepared harness ${a} must stay inside the profile repo.`);return r}o(ne,"resolveHarnessManifestPath");function $e(e,t){return(e instanceof Error?e.message:String(e))===`codex turn ${t} timed out`}o($e,"isCodexTurnTimeoutError");function It(e){return(e instanceof Error?e.message:String(e)).startsWith("codex app-server exited with code 0")}o(It,"isCodexAppServerCleanExitError");async function yt(e){let t=Date.now()+ht;for(;Date.now()<t;){if(await bt(e))return!0;await Le(vt)}return!1}o(yt,"waitForTimedOutSourceApplication");async function bt(e){try{await V(e);let t=await _e(e);await Le(Rt),await V(e);let a=await _e(e);return t===a}catch{return!1}}o(bt,"localCreateSourceLayoutIsStable");async function _e(e){let t=[k.join(e.sourceRoot,"agent","agent.ts"),k.join(e.sourceRoot,"package.json"),k.join(e.repoPath,"openpond-profile.json"),k.join(e.sourcePath,"settings","profile.yaml")];return(await Promise.all(t.map(async n=>{let r=await Oe(n,"utf8");return`${n}:${r.length}:${r}`}))).join(`
2
+ import{a as Ae}from"./chunk-GW766ZSO.js";import{B as O,a as Ce,b as Pe}from"./chunk-OFJPOTES.js";import{b as be}from"./chunk-YU3C6U5V.js";import{d as H}from"./chunk-U7D6Q744.js";import{a as re,b as ye,j as A}from"./chunk-6ESBAHWK.js";import{f as Ie}from"./chunk-Z6HWSTEP.js";import{D as we}from"./chunk-2MEOUS24.js";import{n as $}from"./chunk-RCT3O3HQ.js";import{a as o}from"./chunk-FTQLQJQV.js";import{existsSync as z}from"node:fs";import{cp as xe,mkdir as Ee,readFile as Oe}from"node:fs/promises";import k from"node:path";import{existsSync as L}from"node:fs";import{readFile as K}from"node:fs/promises";import q from"node:path";async function F(e){await V(e.target);let t={},a=new Set([`${e.target.sourceRootRelativePath}/.openpond/agent-inspect.json`,`${e.target.sourceRootRelativePath}/.openpond/action-registry.json`,`${e.target.sourceRootRelativePath}/.openpond/eval-results.json`]),n=[{name:"inspect",command:"inspect",args:["--json"]},{name:"build",command:"build"},{name:"validate",command:"validate",args:["--json"]},{name:"eval",command:"eval",args:["--json"]},{name:"direct-run",command:"run",args:[e.target.defaultAction,"--json","--input",JSON.stringify({prompt:e.snapshot.objective,channel:"openpond_chat"})]}];for(let r of n){let s=await O({cwd:e.target.sourceRoot,command:r.command,args:r.args,...r.command==="eval"&&e.requireEvalPass===!1?{throwOnFailure:!1}:{}});if(s.code!==0&&!(r.command==="eval"&&e.requireEvalPass===!1))throw new Error(s.stderr.trim()||s.stdout.trim()||`${r.command} failed with exit code ${s.code??"unknown"}`);let i=lt(s.stdout),d=mt(i);d&&a.add(q.join(e.target.sourceRootRelativePath,d)),t[r.name]={summary:pt(r.name,i),traceArtifactRef:d,stdout:s.stdout.trim().slice(0,4e3),stderr:s.stderr.trim().slice(0,4e3)}}return await dt(e.target,e.requireEvalPass!==!1),{checkRefs:[...a],metadata:t}}o(F,"runLocalCreatePipelineChecks");async function V(e){if(!L(e.sourceRoot))throw new Error(`Codex did not create the expected agent source root: ${e.sourceRoot}`);let t=q.join(e.sourceRoot,"agent","agent.ts");if(!L(t))throw new Error(`Codex did not create the expected SDK agent source: ${t}`);let a=q.join(e.repoPath,"openpond-profile.json");if(!L(a))throw new Error(`Codex did not update the profile repo manifest: ${a}`);let n=q.join(e.sourcePath,"settings","profile.yaml");if(!L(n))throw new Error(`Codex did not update the profile manifest: ${n}`);let s=JSON.parse(await K(a,"utf8")).profiles?.[e.activeProfile];if(!s)throw new Error(`openpond-profile.json does not register profile ${e.activeProfile}.`);if(!s.enabledAgents?.includes(e.agentId))throw new Error(`openpond-profile.json does not enable generated agent ${e.agentId}.`);let i=await K(n,"utf8");if(!i.includes(`id: ${e.agentId}`)&&!i.includes(`id: "${e.agentId}"`))throw new Error(`settings/profile.yaml does not register generated agent ${e.agentId}.`);let d=e.agentId==="default"?["agent/agent.ts","agent"]:[`agents/${e.agentId}`];if(!d.some(u=>i.includes(u)))throw new Error(`settings/profile.yaml does not point ${e.agentId} at ${d[0]}.`)}o(V,"assertLocalCreateSourceLayout");async function dt(e,t=!0){let a=q.join(e.sourceRoot,".openpond","action-registry.json"),n=q.join(e.sourceRoot,".openpond","eval-results.json");if(!L(a))throw new Error(`Generated source did not produce an action registry: ${a}`);if(!L(n))throw new Error(`Generated source did not produce eval results: ${n}`);let r=JSON.parse(await K(a,"utf8")),s=Array.isArray(r.actions)?r.actions:[];if(!new Set(s.map(c=>typeof c.id=="string"?c.id:null).filter(c=>!!c)).has(e.defaultAction))throw new Error(`Generated action registry does not expose default action ${e.defaultAction}.`);let d=s.filter(c=>typeof c.id=="string"&&(!W(c.label)||!W(c.description)||typeof c.timeoutSeconds!="number"));if(d.length>0)throw new Error(`Generated action registry has actions missing labels, descriptions, or timeout policies: ${d.map(c=>c.id).join(", ")}`);let u=Ce({actionCatalog:s.filter(c=>typeof c.id=="string").map(c=>({id:c.id,name:W(c.name),setupRequirements:ut(c.setupRequirements)??[]})),actionId:e.defaultAction});if(u.blockingRequirements.length>0)throw new Error(`Generated default action ${e.defaultAction} has unresolved required setup and cannot be ready_local: ${u.blockingRequirements.map(Pe).join("; ")}. Mark built-in/local fixture requirements ready or optional when they are satisfied, or leave the pipeline blocked until the setup is configured.`);let m=JSON.parse(await K(n,"utf8"));if(typeof m.summary?.total!="number"||m.summary.total<1)throw new Error("Generated source must define at least one deterministic SDK eval.");if(t&&m.summary.failed!==0)throw new Error("Generated source evals did not all pass.")}o(dt,"assertGeneratedSdkArtifacts");function lt(e){let t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{return JSON.parse(t)}catch{return null}}o(lt,"parseJsonOutput");function E(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}o(E,"asRecord");function ut(e){return Array.isArray(e)?e.filter(t=>!!E(t)):null}o(ut,"recordArray");function mt(e){let t=E(e),a=W(t?.traceArtifactRef);return a?.startsWith(".openpond/")?a:null}o(mt,"traceRefFromCommandResult");function pt(e,t){let a=E(t);return a?e==="inspect"?{actionCount:Array.isArray(a.actionCatalog)?a.actionCatalog.length:null,defaultAction:E(a.agent)?.defaultAction??null,projectName:E(a.project)?.name??null}:e==="validate"?{status:a.status??null,errors:E(a.summary)?.errors??null,warnings:E(a.summary)?.warnings??null}:e==="eval"?E(a.summary):e==="direct-run"?{hasResult:!!E(a.result),resultKeys:Object.keys(E(a.result)??{})}:null:null}o(pt,"summaryFromCommandResult");function W(e){return typeof e=="string"&&e.trim()?e.trim():null}o(W,"stringValue");var gt="Approved local Create plans require model-backed SDK source application; no source mutation was performed.",ft=1800*1e3,Te=".openpond-harness-source-application.json",ht=300*1e3,vt=2*1e3,Rt=5*1e3;async function He(e,t={}){if(!kt(e))return e;let a=t.now??(()=>new Date().toISOString()),n=e.adapter;if(n.kind!=="local")return e;if(!t.session||!t.turn||!t.ensureCodexRuntime||!t.appendRuntimeEvent||!t.setProviderTurnId)return Y(e,{now:a(),reason:gt,metadata:{reason:"model_backed_source_application_required",sourcePath:n.sourcePath??null,repoPath:n.repoPath??null,activeProfile:n.activeProfile??null,operation:e.operation,requestedAgentId:e.target.kind==="agent"?e.target.id:null}});let r;try{r=se(e)}catch(i){return Y(e,{now:a(),reason:i instanceof Error?i.message:String(i),metadata:{reason:"local_create_target_unresolved"}})}try{await ie({snapshot:e,session:t.session,turn:t.turn,target:r,ensureCodexRuntime:t.ensureCodexRuntime,appendRuntimeEvent:t.appendRuntimeEvent,setProviderTurnId:t.setProviderTurnId,model:t.model??we,codexReasoningEffort:t.codexReasoningEffort})}catch(i){return Y(e,{now:a(),reason:i instanceof Error?i.message:String(i),metadata:{reason:"model_backed_source_application_failed",target:r}})}let s=oe(e,{state:"running_checks",now:a(),blockedReason:null,sourceRefs:[r.sourceRootRelativePath,k.join(r.profileRelativePath,"settings","profile.yaml"),"openpond-profile.json"],metadata:{localCreatePipeline:{status:"running_checks",target:r}},candidates:[{id:Se(e.id),target:{kind:"agent",id:r.agentId,displayName:e.target.displayName,defaultActionKey:r.defaultAction},status:"checking",git:null,parentCandidateId:null,tasksetRef:e.tasksetRef,authoringModelRef:t.model??null,allowedPaths:e.plan?.sourcePlan.map(i=>i.path)??[],sourceRefs:[r.sourceRootRelativePath,k.join(r.profileRelativePath,"settings","profile.yaml"),"openpond-profile.json"],artifactRefs:[],checkRefs:[],evaluationReceiptRefs:[],createdAt:e.createdAt,updatedAt:a(),metadata:{sourceAuthority:e.adapter.sourceAuthority}}]});await t.onSnapshot?.(s);try{let i=await(t.runChecks??F)({snapshot:s,target:r}),d=a(),u=Se(e.id),m=`agent_eval_${e.id}`;return oe(s,{state:"ready_local",now:d,blockedReason:null,checkRefs:i.checkRefs,candidates:s.candidates.map(c=>c.id===u?{...c,status:"accepted",checkRefs:X(c.checkRefs,i.checkRefs),evaluationReceiptRefs:X(c.evaluationReceiptRefs,[m]),updatedAt:d}:c),evaluationReceipts:[...s.evaluationReceipts.filter(c=>c.id!==m),{id:m,candidateId:u,target:{kind:"agent",id:r.agentId,displayName:e.target.displayName,defaultActionKey:r.defaultAction},evaluatorKind:"agent_sdk",subject:"candidate",sourceCommit:e.adapter.kind==="local"?e.adapter.localHead:null,sourceBranch:null,tasksetId:e.tasksetRef?.id??null,tasksetHash:e.tasksetRef?.contentHash??null,taskAttemptRefs:i.checkRefs.filter(c=>c.includes("eval")),status:"passed",publishGate:"passed",summaryCounts:null,evalRefs:i.checkRefs.filter(c=>c.includes("eval")),artifactRefs:i.checkRefs,summary:wt(i.metadata),createdAt:d,metadata:i.metadata??{}}],metadata:{localCreatePipeline:{status:"ready_local",target:r,checks:i.metadata??{}}}})}catch(i){return Y(s,{now:a(),reason:i instanceof Error?i.message:String(i),metadata:{reason:"local_create_checks_failed",target:r}})}}o(He,"applyApprovedLocalCreateImproveRun");function kt(e){return e.state==="applying_source"&&e.plan?.status==="approved"&&e.adapter.kind==="local"&&e.target.kind==="agent"}o(kt,"shouldApplyLocalCreatePipeline");function oe(e,t){return A(e,{state:t.state,blockedReason:t.blockedReason===void 0?e.blockedReason:t.blockedReason,checkRefs:X(e.checkRefs,t.checkRefs??[]),sourceRefs:X(e.sourceRefs,t.sourceRefs??[]),candidates:t.candidates??e.candidates,evaluationReceipts:t.evaluationReceipts??e.evaluationReceipts,metadata:{...e.metadata,...t.metadata??{}},updatedAt:t.now})}o(oe,"transitionCreatePipeline");function Y(e,t){return oe(e,{state:"blocked",now:t.now,blockedReason:t.reason,metadata:{localCreatePipeline:{status:"blocked",...t.metadata}}})}o(Y,"blockLocalCreatePipeline");function X(e,t){return Array.from(new Set([...e,...t].filter(Boolean)))}o(X,"mergeRefs");function Se(e){return`agent_candidate_${e}`}o(Se,"agentCandidateId");function wt(e){let t=M(e?.eval),a=typeof t?.total=="number"?t.total:null;return a===null?"Agent SDK checks and deterministic Evals passed.":`${a} Agent SDK Eval${a===1?"":"s"} passed.`}o(wt,"checkSummary");function se(e){let t=e.adapter;if(t.kind!=="local")throw new Error("Create/Improve target must use the local adapter.");if(e.target.kind!=="agent")throw new Error("Local agent source application requires an Agent target.");let a=t.sourcePath?.trim(),n=t.repoPath?.trim();if(!a)throw new Error("Local Create approval is missing a profile source path.");if(!n)throw new Error("Local Create approval is missing a profile repo path.");let r=t.activeProfile?.trim()||"default",s=k.resolve(a),i=k.resolve(n),d=qe(e.target.id)??xt(e)??St(e.objective),u=Tt(Et(e.plan?.defaultChatAction.key)??"chat",d),m=e.operation==="improve"&&d==="default"?s:k.join(s,"agents",d);return{activeProfile:r,agentId:d,defaultAction:u,repoPath:i,sourcePath:s,workspaceRoot:i,profileRelativePath:je(k.relative(i,s)),sourceRoot:m,sourceRootRelativePath:je(k.relative(i,m))}}o(se,"resolveLocalCreatePipelineTarget");async function ie(e){if(!z(e.target.workspaceRoot))throw new Error(`Profile repo path does not exist: ${e.target.workspaceRoot}`);if(!z(e.target.sourcePath))throw new Error(`Profile source path does not exist: ${e.target.sourcePath}`);if(await Ct(e.snapshot,e.target)){await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"completed",output:`Applied prepared harness ${e.snapshot.operation==="improve"?"Improve":"Create"} source for ${e.target.agentId}; running local checks.`,data:{phase:"prepared_source_apply_completed",runId:e.snapshot.id,target:e.target}}));return}await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"started",output:`Applying approved ${e.snapshot.operation==="improve"?"Improve":"Create"} plan with Codex in ${e.target.sourceRootRelativePath}.`,data:{phase:"source_apply_started",runId:e.snapshot.id,target:e.target}}));let t={...e.session,provider:"codex",cwd:e.target.workspaceRoot,workspaceKind:"local_project",workspaceId:e.session.workspaceId??`openpond-profile:${e.target.activeProfile}`,workspaceName:e.session.workspaceName??`OpenPond profile ${e.target.activeProfile}`},a=e.session.provider==="codex"?e.model:null,n=await e.ensureCodexRuntime(t,{approvalPolicy:"never",sandbox:"workspace-write",model:a,codexPermissionMode:"auto-review",codexReasoningEffort:e.codexReasoningEffort}),r=await n.client.startTurn({threadId:n.threadId,prompt:At(e.snapshot,e.target),cwd:e.target.workspaceRoot,model:a,approvalPolicy:"never",sandbox:"workspace-write"});await e.setProviderTurnId(r.turnId);try{await n.client.waitForTurn(r.turnId,ft)}catch(s){if(!$e(s,r.turnId)&&!It(s))throw s;let i=$e(s,r.turnId)?"timed out":"exited cleanly before returning a turn completion";if(await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"started",output:`Codex source application ${i}; checking for completed generated source before blocking.`,data:{phase:"source_apply_recovery_started",runId:e.snapshot.id,providerTurnId:r.turnId,reason:i,target:e.target}})),!await yt(e.target))throw s;await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"server",appId:e.session.appId,status:"completed",output:`Recovered completed ${e.snapshot.operation==="improve"?"Improve":"Create"} source after Codex source application ${i} for ${e.target.agentId}; running local checks.`,data:{phase:"source_apply_recovered",runId:e.snapshot.id,providerTurnId:r.turnId,reason:i,target:e.target}}))}await e.appendRuntimeEvent(H({sessionId:e.session.id,turnId:e.turn.id,name:"create_improve.updated",source:"provider",appId:e.session.appId,status:"completed",output:`Codex completed approved ${e.snapshot.operation==="improve"?"Improve":"Create"} source application for ${e.target.agentId}.`,data:{phase:"source_apply_completed",runId:e.snapshot.id,providerTurnId:r.turnId,target:e.target}}))}o(ie,"runModelBackedLocalCreateSourceApplication");async function Ct(e,t,a=process.env){if(!Ae(a))return!1;let n=k.join(t.workspaceRoot,Te);if(!z(n))return!1;let r=JSON.parse(await Oe(n,"utf8")),s=M(r);if(s?.schema!=="openpond.harnessPreparedSource.v1")throw new Error(`${Te} must use schema openpond.harnessPreparedSource.v1.`);let i=M(s.agents),d=M(i?.[t.agentId]),u=Pt(d?.[e.operation]);if(!u)return!1;let m=ne(t.workspaceRoot,u.source,"source");if(!z(m))throw new Error(`Prepared harness source does not exist: ${u.source}`);await Ee(t.sourceRoot,{recursive:!0}),await xe(m,t.sourceRoot,{recursive:!0,force:!0});for(let c of u.registrations??[]){let g=ne(t.workspaceRoot,c.source,"registration source"),l=ne(t.workspaceRoot,c.target,"registration target");if(!z(g))throw new Error(`Prepared harness registration source does not exist: ${c.source}`);await Ee(k.dirname(l),{recursive:!0}),await xe(g,l,{force:!0})}return!0}o(Ct,"applyPreparedHarnessSourceApplication");function Pt(e){let t=M(e);if(!t||typeof t.source!="string"||!t.source.trim())return null;if(t.registrations!==void 0&&!Array.isArray(t.registrations))throw new Error("Prepared harness source registrations must be an array.");let a=(t.registrations??[]).map(n=>{let r=M(n);if(!r||typeof r.source!="string"||!r.source.trim()||typeof r.target!="string"||!r.target.trim())throw new Error("Prepared harness source registrations require source and target paths.");return{source:r.source,target:r.target}});return{source:t.source,registrations:a}}o(Pt,"asHarnessPreparedSourceOperation");function ne(e,t,a){if(k.isAbsolute(t))throw new Error(`Prepared harness ${a} must be relative to the profile repo.`);let n=k.resolve(e),r=k.resolve(n,t);if(r!==n&&!r.startsWith(`${n}${k.sep}`))throw new Error(`Prepared harness ${a} must stay inside the profile repo.`);return r}o(ne,"resolveHarnessManifestPath");function $e(e,t){return(e instanceof Error?e.message:String(e))===`codex turn ${t} timed out`}o($e,"isCodexTurnTimeoutError");function It(e){return(e instanceof Error?e.message:String(e)).startsWith("codex app-server exited with code 0")}o(It,"isCodexAppServerCleanExitError");async function yt(e){let t=Date.now()+ht;for(;Date.now()<t;){if(await bt(e))return!0;await Le(vt)}return!1}o(yt,"waitForTimedOutSourceApplication");async function bt(e){try{await V(e);let t=await _e(e);await Le(Rt),await V(e);let a=await _e(e);return t===a}catch{return!1}}o(bt,"localCreateSourceLayoutIsStable");async function _e(e){let t=[k.join(e.sourceRoot,"agent","agent.ts"),k.join(e.sourceRoot,"package.json"),k.join(e.repoPath,"openpond-profile.json"),k.join(e.sourcePath,"settings","profile.yaml")];return(await Promise.all(t.map(async n=>{let r=await Oe(n,"utf8");return`${n}:${r.length}:${r}`}))).join(`
3
3
  ---
4
4
  `)}o(_e,"sourceLayoutFingerprint");function Le(e){return new Promise(t=>setTimeout(t,e))}o(Le,"sleep");function At(e,t){return[`Apply this already-approved OpenPond ${e.operation==="improve"?"Improve":"Create"} plan by editing the local profile repo source.`,"","This is the source-materialization step, not another plan review. Make the file changes, inspect the existing profile shape first, and leave the repo with a valid openpond-agent-sdk source project.","","Hard requirements:",`- Current working directory is the profile repo root: ${t.workspaceRoot}`,`- Active profile source path relative to cwd: ${t.profileRelativePath}`,`- Target agent id: ${t.agentId}`,`- Target generated source root: ${t.sourceRootRelativePath}`,`- Default action to expose: ${t.defaultAction}`,`- For a create request, create the new SDK project under ${t.profileRelativePath}/agents/<agent-id>; do not overwrite ${t.profileRelativePath}/agent/agent.ts or unrelated existing agents.`,"- For an edit request, only edit the approved target agent source and shared profile registration files required for that edit.",`- Update openpond-profile.json and ${t.profileRelativePath}/settings/profile.yaml so the generated agent is registered, enabled, and catalog-discoverable.`,"- The generated source must be an actual openpond-agent-sdk project with package.json, tsconfig.json when needed, agent/agent.ts, deterministic evals, and action metadata.","- Preserve the approved objective and any captured conversation context in source metadata, instructions, fixture comments, or eval intent so source readback can prove what was captured.","- Treat plan.metadata.actionShape as the approved public action-shape decision when actionShapeDecisionSource is request_metadata or another explicit planner source.","- If plan.metadata.actionShapeDecisionSource is default_chat_fallback, use the approved objective and captured context to choose the actual generated public actions: keep chat-only for conversational assistants, create direct actions for explicit repeatable runs/workflows/artifact transforms, and expose both when the user needs normal chat plus a repeatable catalog action.","- When refining a default fallback during source materialization, encode the chosen public actions in generated SDK action metadata and evals; do not use business-example hardcoding.","- Every public action must have a stable action id, label, description, input/output schema when useful, timeout policy, artifact policy, setup requirement metadata, and deterministic eval coverage.","- The default action must be invocable through the local profile setup gate after checks. Do not leave built-in openpond_chat or committed local fixture/artifact requirements as unresolved required setup; mark those rows ready/satisfied or optional when the generated source already provides them.","- If the approved objective names multiple capabilities or direct action ids, implement each requested public action instead of collapsing everything into a single chat-only action.","- If a capability writes an artifact, declare it in the action artifact policy and assert it from at least one eval.","- Package scripts must be portable from the generated source root; do not hardcode absolute machine-local paths to this repository or CLI.","- Do not hardcode secrets, API keys, provider tokens, or user credentials in source, evals, traces, fixtures, or comments.","- Use realistic deterministic fixture-backed behavior when external systems are unavailable. Declare setup requirements rather than pretending live integrations exist.","- Run or prepare the source so these commands can pass from the target source root: inspect, build, validate, eval, and run of the default action.","","Approved Create request and plan:",JSON.stringify({run:e,plan:e.plan,questions:e.questions,workflowCapture:e.workflowCapture},null,2)].join(`
5
5
  `)}o(At,"localCreatePipelinePrompt");function xt(e){for(let t of e.plan?.sourcePlan??[]){let a=/^agents\/([^/]+)/.exec(t.path),n=qe(a?.[1]);if(n)return n}return null}o(xt,"agentIdFromSourcePlan");function qe(e){let t=e?.trim();return t&&t.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||null}o(qe,"normalizeAgentId");function Et(e){return e?.trim()||null}o(Et,"normalizeActionId");function M(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}o(M,"asRecord");function Tt(e,t){let a=`${t}.`;return e.startsWith(a)?e.slice(a.length)||"chat":e}o(Tt,"sourceActionIdForAgent");function St(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64).replace(/-+$/g,"")||"generated-agent"}o(St,"slugFromObjective");function je(e){return e.replace(/\\/g,"/")||"."}o(je,"normalizeRelativePath");import de from"node:path";function Pa(e){let t=e.sources.length?e.sources.map(r=>({kind:"conversation",id:r.id,sourceHash:r.sourceHash,excerptRef:`training-source:${r.id}`})):[{kind:"manual_intent",id:`manual_intent_${$(e.objective).slice(0,24)}`,sourceHash:$({objective:e.objective}),excerptRef:null}],a={consent:{status:"granted",scope:e.sources.length?"selected_turns":"direct_intent",reviewedBy:"local_user",reviewedAt:e.timestamp},sources:t,reviewerIntent:e.objective},n=$(a);return re.parse({schemaVersion:"openpond.createImprove.evidenceSnapshot.v1",id:`evidence_snapshot_${n.slice(0,24)}`,contentHash:n,...a,createdAt:e.timestamp,metadata:{immutable:!0,sourceCount:t.length}})}o(Pa,"createEvidenceSnapshot");function Ia(e){let t={runId:e.run.id,candidateId:e.candidateId,tasksetId:e.run.tasksetRef?.id??null,tasksetRevision:e.run.tasksetRef?.revision??null,tasksetHash:e.run.tasksetRef?.contentHash??null,outcome:e.outcome,reason:e.reason,receiptRefs:e.receiptRefs},a=$(t);return re.parse({schemaVersion:"openpond.createImprove.evidenceSnapshot.v1",id:`evidence_outcome_${a.slice(0,24)}`,contentHash:a,consent:{status:"granted",scope:"direct_intent",reviewedBy:e.run.actor.id??"local_user",reviewedAt:e.timestamp},sources:[{kind:"artifact",id:`${e.outcome}:${e.run.id}:${e.candidateId}`,sourceHash:a,excerptRef:e.receiptRefs[0]??null}],reviewerIntent:e.reason,createdAt:e.timestamp,metadata:{immutable:!0,evidenceKind:"candidate_outcome",outcome:e.outcome,priorTasksetRevision:e.run.tasksetRef?.revision??null,recommendedNextTasksetRevision:e.run.tasksetRef?e.run.tasksetRef.revision+1:1,receiptRefs:e.receiptRefs}})}o(Ia,"createOutcomeEvidenceSnapshot");function ya(e){let t=e.proposal?$t(e.proposal):{kind:"model",rationale:["A reviewed training plan selected Model execution for this Taskset."],confidence:1};return ye.parse({schemaVersion:"openpond.createImprove.tasksetRef.v1",id:e.taskset.id,revision:e.taskset.revision,contentHash:e.taskset.contentHash,evidenceSnapshotIds:e.evidenceSnapshotIds,policyBoundary:e.taskset.policy,targetRecommendation:t,authoringSplitRefs:e.taskset.tasks.filter(a=>a.split==="train"||a.split==="validation").map(a=>a.id),privateSplitRefs:e.taskset.tasks.filter(a=>a.split==="test"||a.split==="frozen_eval").map(a=>a.id),approvedBy:"local_user",approvedAt:e.approvedAt,metadata:{immutable:!0,taskCreationProposalId:e.proposal?.id??null}})}o(ya,"createTasksetRef");function Me(e,t){if(e.id!==t.id||e.revision!==t.revision||e.contentHash!==t.contentHash)throw new Error(`Taskset lineage mismatch: the run approved ${e.id}@${e.revision} (${e.contentHash}), but execution resolved ${t.id}@${t.revision} (${t.contentHash}).`)}o(Me,"assertTasksetRefMatches");function $t(e){let t=_t(e);return{kind:t,rationale:e.diagnosis.rationale.length?e.diagnosis.rationale:[`${t} best matches the reviewed behavior boundary.`],confidence:e.diagnosis.confidence}}o($t,"recommendationForProposal");function _t(e){return e.diagnosis.trainingEligible?"model":e.diagnosis.intervention==="retrieval"?"configuration":"agent"}o(_t,"targetKindForProposal");async function Ge(e){let t=e.run.tasksetRef;if(!t)throw new Error("Agent Taskset execution requires an approved Taskset ref.");if(Me(t,e.taskset),e.taskset.environment.kind!=="agent")throw new Error(`Taskset ${e.taskset.id} is not an Agent-shaped Taskset.`);let a=new Set(t.privateSplitRefs),n=e.taskset.tasks.filter(c=>a.has(c.id));if(!n.length||n.length!==a.size)throw new Error("The approved Agent Taskset private split could not be resolved exactly.");let r={tasksetId:t.id,tasksetRevision:t.revision,tasksetHash:t.contentHash,taskRefs:n.map(c=>c.id),seed:0,timeoutMs:e.taskset.environment.defaultTimeoutMs,entrypoint:e.taskset.environment.entrypoint,evaluator:"openpond-agent-sdk-taskset.v1"},s=$(r),i=[],d=[],u=[];for(let c of n){let g=new Date().toISOString(),l=Date.now(),p=await(e.execute??O)({cwd:e.cwd,command:"run",args:[e.taskset.environment.entrypoint,"--json","--input",JSON.stringify({...c.input,channel:"manual"})],timeoutMs:e.taskset.environment.defaultTimeoutMs,throwOnFailure:!1}),x=p.code===0?jt(p.stdout):null,b=`agent_task_attempt_${$([e.run.id,e.subject,e.sourceCommit,t.contentHash,c.id,0]).slice(0,24)}`,f=Ot(x?.traceArtifactRef),P=Ie.parse({schemaVersion:"openpond.taskAttempt.v1",id:b,tasksetId:e.taskset.id,taskId:c.id,split:c.split,attempt:0,seed:0,modelRef:null,startedAt:g,completedAt:new Date().toISOString(),output:ce(x?.result),runtimeEventRefs:f?[f]:[],artifactRefs:f?[f]:[],privilegedOutcomeRef:c.privilegedContextRef,infrastructureError:p.code===0?null:p.stderr.trim().slice(0,1e4)||`Agent SDK action exited with code ${String(p.code)}.`,costUsd:0,latencyMs:Math.max(0,Date.now()-l),userInterventions:0,metadata:{executor:"openpond-agent-sdk",trustedTasksetExecution:!0,tasksetRevision:t.revision,tasksetHash:t.contentHash,sourceCommit:e.sourceCommit,subject:e.subject,executionContractHash:s}}),R=await e.gradeAttempt({tasksetId:e.taskset.id,taskId:c.id,attempt:P});d.push(P.id),i.push(R),f&&u.push(f)}let m=i.filter(c=>c.passed).length;return{taskAttemptRefs:d,gradeRefs:i.map(c=>c.id),taskRefs:n.map(c=>c.id),artifactRefs:[...new Set(u)],total:i.length,passed:m,failed:i.length-m,executionContractHash:s}}o(Ge,"executeAgentTasksetEvaluation");function jt(e){let t=e.trim();if(!t)return null;try{return ce(JSON.parse(t))}catch{let a=t.indexOf("{"),n=t.lastIndexOf("}");if(a<0||n<=a)return null;try{return ce(JSON.parse(t.slice(a,n+1)))}catch{return null}}}o(jt,"parseAgentRunPayload");function ce(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}o(ce,"recordValue");function Ot(e){return typeof e=="string"&&e.trim()?e.trim():null}o(Ot,"stringValue");async function le(e){let t=await(e.execute??O)({cwd:e.cwd,command:"eval",args:["--json"],throwOnFailure:!1}),a=qt(t.stdout),n=G(a.summary?.total)??0,r=G(a.summary?.passed)??0,s=G(a.summary?.failed)??Math.max(0,n-r),i=a.publishGate?.status==="passed"?"passed":"failed",d=Array.isArray(a.results)?a.results:[],u=d.map(R=>I(R.name)).filter(R=>!!R),m=new Set([de.posix.join(e.sourceRef,".openpond/eval-results.json")]);for(let R of d){let _=I(R.traceArtifactRef);_&&m.add(de.posix.join(e.sourceRef,Ne(_)));for(let J of De(R.artifacts))m.add(de.posix.join(e.sourceRef,Ne(J)))}let c=e.run.tasksetRef?await Ge({run:e.run,taskset:Ht(e.taskset),cwd:e.cwd,sourceCommit:e.sourceCommit,subject:e.subject,gradeAttempt:Lt(e.gradeAttempt),execute:e.execute}):null;for(let R of c?.artifactRefs??[])m.add(R);let g=n+(c?.total??0),l=r+(c?.passed??0),p=s+(c?.failed??0),x=[...new Set([...u,...c?.taskRefs??[]])],b=i==="passed"&&(c?.failed??0)===0?"passed":"failed",f=t.code===0&&p===0&&b==="passed"?"passed":"failed",P=e.timestamp??new Date().toISOString();return{id:`agent_eval_${e.run.id}_${e.subject}_${e.sourceCommit.slice(0,12)}`,candidateId:e.candidateId,target:e.run.target,evaluatorKind:"agent_sdk",subject:e.subject,sourceCommit:e.sourceCommit,sourceBranch:e.sourceBranch,tasksetId:e.run.tasksetRef?.id??null,tasksetHash:e.run.tasksetRef?.contentHash??null,taskAttemptRefs:c?.taskAttemptRefs??u,status:f,publishGate:b,summaryCounts:{total:g,passed:l,failed:p},evalRefs:x,artifactRefs:[...m],summary:`${e.subject==="active"?"Active":e.subject==="candidate"?"Candidate":"Post-release"} Agent SDK and Taskset Evals: ${l}/${g} passed${b==="failed"?"; publish gate failed":""}.`,createdAt:P,metadata:{schemaVersion:I(a.schemaVersion),schema:I(a.schema),project:{name:I(a.project?.name),version:I(a.project?.version)},source:{configPath:I(a.source?.configPath),configHash:I(a.source?.configHash)},publishGate:{total:G(a.publishGate?.total),passed:G(a.publishGate?.passed),failed:G(a.publishGate?.failed),blockingFailures:De(a.publishGate?.blockingFailures)},command:{code:t.code,timedOut:t.timedOut,stderr:t.stderr.trim().slice(0,4e3)},trustedTasksetExecution:!!c,tasksetRevision:e.run.tasksetRef?.revision??null,executionContractHash:c?.executionContractHash??null,gradeRefs:c?.gradeRefs??[],results:d.map(R=>({name:I(R.name),status:I(R.status),error:I(R.error),traceArtifactRef:I(R.traceArtifactRef)}))}}}o(le,"runNormalizedAgentEvaluation");function Ht(e){if(!e)throw new Error("The approved Agent Taskset could not be resolved for evaluation.");return e}o(Ht,"requireTaskset");function Lt(e){if(!e)throw new Error("Trusted Taskset grading is unavailable for Agent evaluation.");return e}o(Lt,"requireGradeAttempt");function qt(e){let t=e.trim();if(!t)throw new Error("Agent SDK Eval returned no JSON output.");try{return JSON.parse(t)}catch{let a=t.indexOf("{"),n=t.lastIndexOf("}");if(a>=0&&n>a)try{return JSON.parse(t.slice(a,n+1))}catch{}throw new Error("Agent SDK Eval returned invalid JSON output.")}}o(qt,"parseAgentEvalPayload");function Ne(e){return e.replace(/^\.\//,"").replaceAll("\\","/")}o(Ne,"normalizeRef");function I(e){return typeof e=="string"&&e.trim()?e.trim():null}o(I,"stringValue");function G(e){return typeof e=="number"&&Number.isFinite(e)?e:null}o(G,"numberValue");function De(e){return Array.isArray(e)?e.map(I).filter(t=>!!t):[]}o(De,"stringArray");import{existsSync as Z}from"node:fs";import{mkdir as Xe,realpath as Qe,rm as he,writeFile as Ft}from"node:fs/promises";import Ze from"node:os";import S from"node:path";import{existsSync as ue}from"node:fs";import{cp as Mt,lstat as Gt,mkdir as Be,rm as Nt,symlink as Dt,writeFile as Bt}from"node:fs/promises";import w from"node:path";function Ue(e,t){let a=C(t.profileRelativePath),n=[C(t.sourceRootRelativePath),w.posix.join(a,"evals"),w.posix.join(a,"settings"),w.posix.join(a,"package.json"),w.posix.join(a,"tsconfig.json"),w.posix.join(a,"openpond.lock"),w.posix.join(a,".gitignore"),"openpond-profile.json"],r=(e.plan?.sourcePlan??[]).flatMap(s=>{let i=C(s.path);return i?i==="."||i.startsWith(`${a}/`)?[i]:[w.posix.join(a,i),i]:[]});return[...new Set([...n,...r])]}o(Ue,"allowedAgentImprovementPaths");function Je(e,t){let a=C(e);return t.some(n=>a===n||a.startsWith(`${n}/`))}o(Je,"pathAllowed");function me(e){return C(e).split("/").some(a=>a==="node_modules"||a===".openpond"||a==="artifacts")}o(me,"isCandidateRuntimePath");function Fe(e){return e.split(/\r?\n/).map(t=>t.trimEnd()).filter(Boolean).map(t=>{let a=t.slice(3),n=a.split(" -> ");return C(n.at(-1)??a)})}o(Fe,"parseGitStatusPaths");async function pe(e,t,a){let n=await e("git",["diff","--name-only","-z",a,"--","."],t);return h(n,"Unable to inspect Agent candidate paths."),[...new Set(n.stdout.split("\0").map(C).filter(r=>r!=="."&&!me(r)))]}o(pe,"gitChangedPaths");async function ge(e){for(let t of e.paths){let a=await B(e.command,e.repoPath,["rev-parse",`${e.commit}:${t}`]),n=w.join(e.repoPath,...t.split("/"));if(!a){if(ue(n))return!1;continue}if(!ue(n))return!1;let r=await B(e.command,e.repoPath,["hash-object","--",t]);if(!r||r!==a)return!1}return!0}o(ge,"workingTreeMatchesCommit");async function ze(e,t){let a=new Set(["node_modules",w.posix.join(C(e.profileRelativePath),"node_modules"),w.posix.join(C(e.sourceRootRelativePath),"node_modules")]);for(let n of a){let r=w.join(e.repoPath,...n.split("/")),s=w.join(t,...n.split("/"));!await Jt(r)||ue(s)||(await Be(w.dirname(s),{recursive:!0}),await Dt(r,s,process.platform==="win32"?"junction":"dir"))}}o(ze,"linkCandidateDependencies");async function We(e){let t=await e.command("git",["diff","--binary","HEAD","--",".",":(exclude)**/tasksets/**"],e.repoPath);if(h(t,"Unable to capture active Profile changes."),t.stdout){let i=w.join(e.workspaceRoot,"active-profile.patch");await Bt(i,t.stdout,"utf8");let d=await e.command("git",["apply","--whitespace=nowarn",i],e.worktreePath);h(d,"Unable to apply active Profile changes to the candidate baseline."),await Nt(i,{force:!0})}let a=await e.command("git",["ls-files","--others","--exclude-standard","-z"],e.repoPath);h(a,"Unable to inspect untracked Profile source.");for(let i of a.stdout.split("\0").filter(Ut)){let d=w.join(e.repoPath,...i.split("/")),u=w.join(e.worktreePath,...i.split("/"));await Be(w.dirname(u),{recursive:!0}),await Mt(d,u,{recursive:!0,preserveTimestamps:!0})}let n=await e.command("git",["add","-A"],e.worktreePath);h(n,"Unable to stage the active Profile snapshot.");let r=await e.command("git",["diff","--cached","--quiet"],e.worktreePath);if(r.code===0)return;r.code!==1&&h(r,"Unable to inspect the active Profile snapshot.");let s=await e.command("git",["commit","-m","Snapshot active Profile before OpenPond improvement"],e.worktreePath,Q());h(s,"Unable to commit the active Profile snapshot.")}o(We,"snapshotActiveProfileChanges");function Ut(e){return e?!C(e).split("/").some(a=>a==="node_modules"||a===".openpond"||a==="artifacts"||a==="tasksets"):!1}o(Ut,"snapshotEligiblePath");function Q(){return{GIT_AUTHOR_NAME:process.env.GIT_AUTHOR_NAME||"OpenPond",GIT_AUTHOR_EMAIL:process.env.GIT_AUTHOR_EMAIL||"openpond@example.invalid",GIT_COMMITTER_NAME:process.env.GIT_COMMITTER_NAME||"OpenPond",GIT_COMMITTER_EMAIL:process.env.GIT_COMMITTER_EMAIL||"openpond@example.invalid"}}o(Q,"gitIdentityEnv");async function Jt(e){try{return(await Gt(e)).isDirectory()}catch{return!1}}o(Jt,"directoryExists");async function Ke(e,t,a){let n=await e("gh",["pr","list","--head",a,"--state","all","--json","number,url,state,mergedAt,mergeCommit,baseRefName,headRefName","--limit","20"],t);h(n,"Unable to inspect existing Agent improvement pull requests.");let r=JSON.parse(n.stdout);return Array.isArray(r)?r.filter(s=>!!(s&&typeof s=="object")):[]}o(Ke,"listPullRequestsForBranch");function fe(e,t=new Date().toISOString(),a=new Date().toISOString()){let n=typeof e.number=="number"?e.number:Number(e.number),r=typeof e.state=="string"?e.state.toLowerCase():"",i=N(e.mergedAt)||r==="merged"?"merged":r==="open"?"open":"closed",d=e.mergeCommit&&typeof e.mergeCommit=="object"?e.mergeCommit:null,u=N(d?.oid)??N(e.mergeCommit),m=N(e.url),c=N(e.baseRefName),g=N(e.headRefName);if(!Number.isInteger(n)||n<=0||!m||!c||!g)throw new Error("GitHub returned an incomplete pull request payload.");return{provider:"github",number:n,url:m,state:i,baseBranch:c,headBranch:g,mergeCommit:u,openedAt:t,updatedAt:a}}o(fe,"normalizePullRequest");function Ve(e,t){return`openpond/improve/${D(t)}/${D(e.id).slice(0,36)}`}o(Ve,"candidateBranch");function U(e){if(!e.worktreePath)throw new Error("Agent candidate worktree is unavailable.");return e.worktreePath}o(U,"requireWorktreePath");function Ye(e){let t=e.replace(/^git@github\.com:/i,"").replace(/^https?:\/\/github\.com\//i,"").replace(/\.git$/i,"").replace(/^\/+|\/+$/g,"");return/^[^/]+\/[^/]+$/.test(t)?t:null}o(Ye,"githubRepoFromRemote");function C(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/^\/+|\/+$/g,"")||"."}o(C,"normalizeRepoPath");function D(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"candidate"}o(D,"safePathSegment");async function y(e,t,a,n){let r=await e("git",a,t);h(r,n);let s=r.stdout.trim();if(!s)throw new Error(n);return s}o(y,"requiredGitText");async function B(e,t,a){let n=await e("git",a,t);return n.code===0&&n.stdout.trim()?n.stdout.trim():null}o(B,"optionalGitText");function h(e,t){if(e.code!==0)throw new Error(e.stderr.trim()||e.stdout.trim()||t)}o(h,"assertCommand");function N(e){return typeof e=="string"&&e.trim()?e.trim():null}o(N,"stringValue");function T(e,t,a,n={}){return be(e,t,a,n)}o(T,"defaultCommandRunner");function et(e,t){let a=U(t);if(!Z(a))throw new Error("The existing Agent candidate worktree is no longer available.");let n=C(e.profileRelativePath),r=C(e.sourceRootRelativePath);return{target:{...e,repoPath:a,workspaceRoot:a,sourcePath:S.join(a,...n.split("/")),sourceRoot:S.join(a,...r.split("/"))},git:t}}o(et,"restoreAgentImprovementWorkspace");async function tt(e){let t=e.command??T,a=await y(t,e.target.repoPath,["rev-parse","--show-toplevel"],"Profile source is not a Git repository."),[n,r]=await Promise.all([Qe(a),Qe(e.target.repoPath)]);if(n!==r)throw new Error("Profile repo path does not match the Git repository root.");let s=await t("git",["status","--porcelain=v1","-uall"],a);h(s,"Unable to inspect Profile Git status.");let[i,d,u]=await Promise.all([y(t,a,["rev-parse","HEAD"],"Profile Git repo has no HEAD commit."),y(t,a,["branch","--show-current"],"Profile Git repo must be on a branch."),B(t,a,["remote","get-url","origin"])]);if(e.run.adapter.kind==="local"&&e.run.adapter.localHead&&e.run.adapter.localHead!==i)throw new Error(`Profile source changed from ${e.run.adapter.localHead.slice(0,12)} to ${i.slice(0,12)}. Re-plan the improvement against the current source.`);let m=Ve(e.run,e.target.agentId),c=S.join(Ze.tmpdir(),"openpond-agent-improvements",D(S.basename(a)||"profile"),D(e.run.id)),g=S.join(c,"repo");await Xe(c,{recursive:!0});let l=await t("git",["show-ref","--verify","--quiet",`refs/heads/${m}`],a);if(Z(g)&&await B(t,g,["branch","--show-current"])!==m&&(await t("git",["worktree","remove","--force",g],a),await he(c,{recursive:!0,force:!0}),await Xe(c,{recursive:!0})),!Z(g)){let P=l.code===0?["worktree","add",g,m]:["worktree","add","-b",m,g,i],R=await t("git",P,a);h(R,"Unable to create the Agent candidate worktree.")}s.stdout.trim()&&await We({command:t,repoPath:a,worktreePath:g,workspaceRoot:c});let p=await y(t,g,["rev-parse","HEAD"],"Agent candidate worktree has no baseline commit.");if(await y(t,g,["rev-parse","HEAD"],"Agent candidate worktree has no HEAD commit.")!==p)throw new Error("Agent candidate baseline could not be resolved.");await ze(e.target,g);let b=C(e.target.profileRelativePath),f=C(e.target.sourceRootRelativePath);return{target:{...e.target,repoPath:g,workspaceRoot:g,sourcePath:S.join(g,...b.split("/")),sourceRoot:S.join(g,...f.split("/"))},git:{baseBranch:d,baseCommit:p,branch:m,headCommit:null,remoteName:"origin",remoteUrl:u,worktreePath:g,changedPaths:[],diffStat:null,pullRequest:null}}}o(tt,"prepareAgentImprovementWorkspace");async function at(e){let t=e.command??T,a=U(e.workspace.git),n=await t("git",["status","--porcelain=v1","-uall"],a);h(n,"Unable to inspect Agent candidate changes.");let r=Fe(n.stdout).filter(g=>!me(g));if(r.length===0)throw new Error("The Agent improvement produced no source changes.");let s=Ue(e.run,e.activeTarget),i=r.filter(g=>!Je(g,s));if(i.length>0)throw new Error(`Agent candidate changed paths outside the approved scope: ${i.join(", ")}`);let d=await t("git",["add","--",...r],a);h(d,"Unable to stage Agent candidate changes.");let u=await t("git",["commit","-m",`Improve ${e.run.target.displayName??e.activeTarget.agentId} via OpenPond`],a,Q());h(u,"Unable to commit Agent candidate changes.");let m=await y(t,a,["rev-parse","HEAD"],"Agent candidate commit was not created."),c=await B(t,a,["diff","--stat",`${e.workspace.git.baseCommit}..${m}`]);return{...e.workspace.git,headCommit:m,changedPaths:r,diffStat:c}}o(at,"commitAgentImprovementCandidate");async function Va(e){let t=e.command??T,a=U(e.git);if(!e.git.headCommit)throw new Error("Agent candidate has no commit to push.");if(!e.git.remoteUrl||!Ye(e.git.remoteUrl))throw new Error("Agent candidate is ready locally. Configure a GitHub origin remote before opening a pull request.");let n=await t("git",["push","--set-upstream",e.git.remoteName,e.git.branch],a);h(n,"Unable to push the Agent candidate branch.");let r=await Ke(t,a,e.git.branch);if(r.length>0)return fe(r[0],e.timestamp);let s=`Improve ${e.run.target.displayName??e.run.target.id??"Agent"}`,i=["## OpenPond Agent improvement","",e.run.objective,"","## Evaluation","",e.evaluationSummary,"",`Create/Improve run: \`${e.run.id}\``,`Base commit: \`${e.git.baseCommit}\``,`Candidate commit: \`${e.git.headCommit}\``].join(`
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as E,b as _}from"./chunk-WZ35ICTE.js";import{a as p}from"./chunk-FTQLQJQV.js";var g=`CREATE TABLE IF NOT EXISTS local_ponder_state (id INTEGER PRIMARY KEY CHECK(id=1),payload TEXT NOT NULL);
2
+ import{a as E,b as _}from"./chunk-IFMWAOBR.js";import{a as p}from"./chunk-FTQLQJQV.js";var g=`CREATE TABLE IF NOT EXISTS local_ponder_state (id INTEGER PRIMARY KEY CHECK(id=1),payload TEXT NOT NULL);
3
3
  CREATE TABLE IF NOT EXISTS local_ponder_agents (session_id TEXT PRIMARY KEY,coordinator_id TEXT NOT NULL,creation_key TEXT NOT NULL UNIQUE,payload TEXT NOT NULL);`;function u(o,n){if(!o.get("SELECT name FROM sqlite_master WHERE type='table' AND name='local_ponder_agents'"))return null;let e=o.get("SELECT payload FROM local_ponder_agents WHERE session_id=?",[n]);return e?_.parse(JSON.parse(e.payload)):null}p(u,"readLocalPonderRelationship");function y(o,n){let e=u(o,n.sessionId);if(!e||e.coordinatorSessionId!==n.senderSessionId)return;let s=n.payload.localPonderControlRevision;if(e.owner!=="ponder"||s!==e.revision)throw new Error("local_ponder_control_changed")}p(y,"assertLocalPonderAdmission");function O(o,n,e,s){let t=u(o,n);if(!t)throw new Error("local_ponder_agent_not_found");if(t.revision!==s)throw new Error("local_ponder_control_changed");let i=o.get("SELECT payload FROM sessions WHERE id=?",[n]);if(!i)throw new Error("local_ponder_agent_not_found");let d=JSON.parse(i.payload),r={...t,owner:e,revision:t.revision+(t.owner===e?0:1),updatedAt:new Date().toISOString()},a={...d,hiddenFromDefaultSidebar:e!=="user",updatedAt:r.updatedAt};if(o.run("UPDATE local_ponder_agents SET payload=? WHERE session_id=?",[JSON.stringify(r),n]),o.run("UPDATE sessions SET payload=?,updated_at=? WHERE id=?",[JSON.stringify(a),a.updatedAt,n]),t.owner!==e){let S=o.all("SELECT id,payload FROM task_inputs WHERE session_id=? AND state='pending'",[n]);for(let l of S){let c=JSON.parse(l.payload);c.senderSessionId===t.coordinatorSessionId&&o.run("UPDATE task_inputs SET state='rejected',payload=? WHERE id=?",[JSON.stringify({...c,state:"rejected",error:"local_ponder_control_changed",updatedAt:r.updatedAt}),l.id])}}return{relationship:r,session:a}}p(O,"changeLocalPonderControl");function R(o,n,e){let s=o.get("SELECT payload FROM local_ponder_state WHERE id=1");if(!s)throw new Error("local_ponder_unavailable");let t=E.parse(JSON.parse(s.payload));if(t.revision!==e||!t.sessionId)throw new Error("local_ponder_configuration_changed");let i=o.get("SELECT payload FROM sessions WHERE id=?",[t.sessionId]);if(!i)throw new Error("local_ponder_unavailable");let d=JSON.parse(i.payload);if(d.status==="active"||o.get("SELECT id FROM turns WHERE session_id=? AND status='in_progress' LIMIT 1",[d.id]))throw new Error("local_ponder_model_change_requires_idle");let r={...d,provider:n.providerId,modelRef:n,updatedAt:new Date().toISOString()},a={...t,modelRef:n,revision:t.revision+1};return o.run("UPDATE sessions SET payload=?,updated_at=? WHERE id=?",[JSON.stringify(r),r.updatedAt,r.id]),o.run("UPDATE local_ponder_state SET payload=? WHERE id=1",[JSON.stringify(a)]),{coordinator:a,session:r}}p(R,"changeLocalPonderModel");export{g as a,y as b,O as c,R as d};
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as pt}from"./chunk-TAXCMCYZ.js";import{a as D,b as Fe,d as de}from"./chunk-PKJHN666.js";import{b as mt,c as ft}from"./chunk-Z33RVGP6.js";import{a as Je,b as Ye,c as Ze,d as ce}from"./chunk-7PKDJHT6.js";import{a as M,b as ue}from"./chunk-65WRWLUD.js";import{_ as lt,a as le,d as $e,e as Ve,g as tt,j as rt,k as st,na as ut,oa as dt,pa as gt,v as at,w as Y,y as it}from"./chunk-54755JYM.js";import{g as ct}from"./chunk-B66QCXH2.js";import{a as ze}from"./chunk-PYNW5OFA.js";import{b as et}from"./chunk-MOXIGLN2.js";import{a as Xe}from"./chunk-VFH5C6D2.js";import{b as Ge,d as Qe}from"./chunk-EYTTZ5H4.js";import{k as Ke}from"./chunk-DKOVZ6R2.js";import{a as ot,b as nt}from"./chunk-GW766ZSO.js";import{i as Be,p as Ue}from"./chunk-2ACX7IW5.js";import{s as L,u as B,v as ie,z as We}from"./chunk-OFJPOTES.js";import{a as T,d as X}from"./chunk-U7D6Q744.js";import{F as Ne,Ga as qe,g as Me}from"./chunk-HG2YFMVU.js";import{a as je}from"./chunk-BL3CZWWD.js";import{c as Oe}from"./chunk-L3KS6MOV.js";import{b as De}from"./chunk-SSHE6B7Z.js";import{a as tr}from"./chunk-JFXINDOQ.js";import{g as Le}from"./chunk-AJXWJLZA.js";import{_ as _e,ca as Ce,fa as He}from"./chunk-SV7ZBEK2.js";import{F as be}from"./chunk-2MEOUS24.js";import{n as H}from"./chunk-RCT3O3HQ.js";import{p as Ie}from"./chunk-UGOK7VTC.js";import{a as n,e as er}from"./chunk-FTQLQJQV.js";import{randomUUID as Pr}from"node:crypto";import{mkdir as Rr}from"node:fs/promises";import q from"node:path";function ht(e){return async(t,r)=>{let s=await e?.(t,r)??null;if((t.metadata?.standaloneExperiment!==void 0||t.metadata?.localProfileExperiment!==void 0)&&!s)throw new Error("This native Experiment session has no active durable model-dispatch owner.");return s}}n(ht,"experimentSessionStreamResolver");var St=er(tr(),1);import{randomUUID as pe}from"node:crypto";var rr=15e3,or=3e4;function Wr(e){let t=new Set,r=null,s=null;async function p(a){if(!a.profileRef||!a.profileWorkflowId)throw new Error(a.profileMigrationError??`Chat Workflow ${a.id} has no Profile package.`);let u=await e.getSession(a.sessionId),i=await e.resolveProfileOwner(u,a.profileRef),c=await e.readProfilePackage(i.sourcePath,a.profileWorkflowId);return{...a,name:c.name,prompt:c.prompt}}n(p,"authoredWorkflow");async function h(){for(let a of await e.store.listChatWorkflows())if(!(a.profileRef&&a.profileWorkflowId))try{let u=await e.getSession(a.sessionId);if(!u.currentProfile)throw new Error("Original session has no explicit Profile owner.");let i=await e.resolveProfileOwner(u,u.currentProfile),c={...a,profileRef:i.ref,profileWorkflowId:a.profileWorkflowId??`chat-${a.id.toLowerCase()}`,profileMigrationError:null};await e.saveProfilePackage(i.sourcePath,c),await e.store.patchChatWorkflow(a.id,()=>c)}catch(u){let i=`Profile package migration unresolved: ${u instanceof Error?u.message:String(u)}`;await e.store.patchChatWorkflow(a.id,c=>({...c,profileMigrationError:i})),e.logger?.warn("chat workflow Profile migration unresolved",{workflowId:a.id,error:i})}}n(h,"migrateExistingWorkflows");async function w(a){let u=await e.getSession(a.sessionId),i=await e.resolveProfileOwner(u),c=T(),g=Z(a.recurrence,new Date,0);if(!g.value)throw new Error(g.error??"This workflow has no future occurrence.");let k={id:pe(),sessionId:u.id,sessionTitle:u.title,sourceTurnId:a.sourceTurnId??null,name:a.name,prompt:a.prompt,profileRef:i.ref,profileWorkflowId:`chat-${pe()}`,recurrence:a.recurrence,enabled:!0,nextRunAt:g.value,lastRunAt:null,lastRunStatus:null,lastRunId:null,lastError:g.error,scheduledRunCount:0,createdAt:c,updatedAt:c};return await e.saveProfilePackage(i.sourcePath,k),e.store.upsertChatWorkflow(k)}n(w,"create");async function v(){if(e.isClosing())return;let a=await e.store.listDueChatWorkflows(T());for(let u of a)if(!t.has(u.id)){if(e.isSessionTurnActive(u.sessionId)){await e.store.patchChatWorkflow(u.id,i=>({...i,nextRunAt:new Date(Date.now()+or).toISOString(),lastError:"Waiting for the attached chat to finish its current turn.",updatedAt:T()}));continue}await d(u,u.nextRunAt??T(),"schedule")}}n(v,"runTick");function l(){if(s)return s;let a=v().finally(()=>{s===a&&(s=null)});return s=a,a}n(l,"trackedTick");async function d(a,u,i){a=await p(a);let c=T(),g=e.store.home?await He(e.store.home):void 0,k={definitionSnapshot:structuredClone(a),...g?{configurationSnapshot:{effectiveRevision:g.effectiveRevision,sources:g.sources}}:{},id:pe(),workflowId:a.id,sessionId:a.sessionId,scheduledFor:u,trigger:i,status:"queued",turnId:null,error:null,createdAt:c,startedAt:null,completedAt:null,updatedAt:c},y=await e.store.insertChatWorkflowRun(k);return t.add(a.id),e.queue.enqueue({label:"chat-workflow-run",metadata:{workflowId:a.id,sessionId:a.sessionId,trigger:i,scheduledFor:u}},async()=>{try{await f(a,y)}finally{t.delete(a.id)}}),y}n(d,"enqueue");async function f(a,u){let i=T();await e.store.patchChatWorkflowRun(u.id,S=>({...S,status:"running",startedAt:i,updatedAt:i}));let c=null,g=null;try{c=await e.sendTurn(a.sessionId,{prompt:a.prompt,metadata:{interactionKind:"scheduled_workflow",chatWorkflowId:a.id,chatWorkflowName:a.name,chatWorkflowRunId:u.id,scheduledFor:u.scheduledFor}})}catch(S){g=S instanceof Error?S.message:String(S)}let k=T(),y=c?.status==="completed"?"succeeded":"failed";await e.store.patchChatWorkflowRun(u.id,S=>({...S,status:y,turnId:c?.id??null,error:g??c?.error??null,completedAt:k,updatedAt:k})),await e.store.patchChatWorkflow(a.id,S=>{let b=S.scheduledRunCount+(u.trigger==="schedule"?1:0),P=u.trigger==="manual"?{value:S.nextRunAt,error:null}:Z(S.recurrence,new Date,b);return{...S,enabled:P.value?S.enabled:!1,nextRunAt:S.enabled?P.value:null,lastRunAt:k,lastRunStatus:y,lastRunId:u.id,lastError:P.error??g??c?.error??null,scheduledRunCount:b,updatedAt:k}})}return n(f,"execute"),{async start(){r||(await h(),l().catch(a=>e.logger?.warn("chat workflow tick failed",{error:String(a)})),r=setInterval(()=>{l().catch(a=>e.logger?.warn("chat workflow tick failed",{error:String(a)}))},e.tickMs??rr),r.unref?.())},async stop(){r&&clearInterval(r),r=null,await s?.catch(()=>{})},create:w,async list(a){let u=await e.store.listChatWorkflows({sessionId:a});return Promise.all(u.map(async i=>{try{return await p(i)}catch(c){return{...i,profileMigrationError:c instanceof Error?c.message:String(c)}}}))},listRuns:n(a=>e.store.listChatWorkflowRuns(a),"listRuns"),async patch(a,u){let i=await e.store.getChatWorkflow(a);if(!i)return null;let c=T();if("enabled"in u){let S=u.enabled?Z(i.recurrence,new Date,i.scheduledRunCount):{value:null,error:null};return e.store.patchChatWorkflow(a,b=>({...b,enabled:u.enabled&&!!S.value,nextRunAt:u.enabled?S.value:null,lastError:S.error,updatedAt:c}))}let g=Z(u.recurrence,new Date,0);if(!i.profileRef||!i.profileWorkflowId)throw new Error(`Chat Workflow ${a} has no resolved Profile owner; migrate it before editing.`);let k=await e.getSession(i.sessionId),y=await e.resolveProfileOwner(k,i.profileRef);return await e.saveProfilePackage(y.sourcePath,{...i,name:u.name,prompt:u.prompt}),e.store.patchChatWorkflow(a,S=>({...S,name:u.name,prompt:u.prompt,recurrence:u.recurrence,enabled:!!g.value,nextRunAt:g.value,lastError:g.error,scheduledRunCount:0,updatedAt:c}))},remove:n(a=>e.store.deleteChatWorkflow(a),"remove"),async runNow(a){let u=await e.store.getChatWorkflow(a);if(!u)throw new Error("Chat workflow not found.");if(e.isSessionTurnActive(u.sessionId))throw new Error("The attached chat is currently running a turn.");return d(u,T(),"manual")}}}n(Wr,"createChatWorkflowLoop");var nr={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6};function Z(e,t,r){try{return{value:me(e,t,r),error:null}}catch(s){return{value:null,error:s instanceof Error?s.message:String(s)}}}n(Z,"safeNextOccurrence");function me(e,t,r){if(e.end.kind==="after_occurrences"&&r>=e.end.occurrences)return null;let s=wt(e.startDate,e.localTime,e.timeZone);if(e.kind==="once")return s.getTime()>t.getTime()?s.toISOString():null;let[p,h]=e.localTime.split(":").map(Number),w=e.kind==="daily"?`${h} ${p} * * *`:e.kind==="weekdays"?`${h} ${p} * * 1-5`:e.kind==="weekly"?`${h} ${p} * * ${(e.weekdays??[]).map(d=>nr[d]).join(",")}`:`${h} ${p} ${e.dayOfMonth} * *`,v=new Date(Math.max(t.getTime(),s.getTime()-1e3)),l=St.CronExpressionParser.parse(w,{currentDate:v,tz:e.timeZone}).next().toDate();if(e.end.kind==="on_date"){let d=wt(e.end.date,"23:59",e.timeZone);if(l.getTime()>d.getTime()+59999)return null}return l.toISOString()}n(me,"nextOccurrence");function wt(e,t,r){let[s,p,h]=e.split("-").map(Number),[w,v]=t.split(":").map(Number),l=Date.UTC(s,p-1,h,w,v),d=new Date(l);for(let f=0;f<3;f+=1){let a=new Intl.DateTimeFormat("en-CA",{timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(d),u=Object.fromEntries(a.map(g=>[g.type,g.value])),i=Date.UTC(Number(u.year),Number(u.month)-1,Number(u.day),Number(u.hour),Number(u.minute)),c=l-i;if(c===0)return d;d=new Date(d.getTime()+c)}return d}n(wt,"zonedLocalDateTime");function vt(e){return Ie(e,t=>{let r=0,s=0;t.exec("BEGIN IMMEDIATE");try{for(let[p,h,w]of[["local_agent_schedule_runs","local_agent_schedules","scheduleId"],["chat_workflow_runs","chat_workflows","workflowId"]]){let v=t.prepare(`SELECT id, payload FROM ${p} WHERE status IN ('queued','running')`).all();for(let l of v){let d=JSON.parse(l.payload),f=new Date().toISOString(),a=typeof d.turnId=="string"?t.prepare("SELECT payload FROM turns WHERE id = ?").get(d.turnId):void 0,i=(a?JSON.parse(a.payload):null)?.status==="completed",c=i?"The previous scheduled turn completed before shutdown.":"OpenPond stopped before this scheduled run was settled. Its external outcome may be unknown. Review the run before retrying or enabling this schedule.",g=i?"succeeded":"failed";t.prepare(`UPDATE ${p} SET status=?, payload=?, updated_at=? WHERE id=?`).run(g,JSON.stringify({...d,status:g,error:i?null:c,completedAt:f,updatedAt:f}),f,l.id);let k=t.prepare(`SELECT payload FROM ${h} WHERE id = ?`).get(String(d[w]));if(k&&!i){let y=JSON.parse(k.payload);t.prepare(`UPDATE ${h} SET enabled=0, next_run_at=NULL, payload=?, updated_at=? WHERE id=?`).run(JSON.stringify({...y,enabled:!1,nextRunAt:null,lastRunStatus:g,lastRunId:l.id,lastError:c,updatedAt:f}),f,String(d[w]))}if(i&&k&&h==="chat_workflows"){let y=qe.parse(JSON.parse(k.payload)),S=y.scheduledRunCount+(d.trigger==="schedule"?1:0),b=d.trigger==="manual"?y.nextRunAt:me(y.recurrence,new Date(f),S),P=y.enabled&&b!==null;t.prepare("UPDATE chat_workflows SET enabled=?, next_run_at=?, payload=?, updated_at=? WHERE id=?").run(P?1:0,P?b:null,JSON.stringify({...y,enabled:P,nextRunAt:P?b:null,scheduledRunCount:S,lastRunStatus:g,lastRunId:l.id,lastRunAt:f,lastError:null,updatedAt:f}),f,y.id)}i?r+=1:s+=1}}return t.exec("COMMIT"),{recovered:r,needsReview:s}}catch(p){throw t.exec("ROLLBACK"),p}})}n(vt,"reconcileInterruptedScheduledWork");async function kt(e,t){let r=sr(e);if(!r)return null;let s=await t.loadProfileState();return r==="help"?ar(s):ir(s)}n(kt,"runProfileSkillCommand");function sr(e){let t=/^\/skill(?:\s+([\s\S]*))?$/i.exec(e.trim());if(!t)return null;let r=t[1]?.trim().toLowerCase()??"";return!r||r==="list"?"list":r==="help"?"help":null}n(sr,"readOnlyProfileSkillAction");function ar(e){return{handled:!0,action:"help",profile:e,message:["Profile skills support:","- /skill list","- /skill create <what the skill should help with>","- /skill create <skill-name>: <what the skill should help with>","- /skill create --name <skill-name> <what the skill should help with>","- /skill edit <skill-name> <change request>","","Create and edit run as normal model turns with the bundled OpenPond Skill Authoring skill. Skills may include SKILL.md plus focused scripts, references, and assets. Use an Agent when the workflow needs code, actions, durable runtime behavior, setup, or Evals."].join(`
2
+ import{a as pt}from"./chunk-ESOIZG2G.js";import{a as D,b as Fe,d as de}from"./chunk-PKJHN666.js";import{b as mt,c as ft}from"./chunk-5LKEVB2P.js";import{a as Je,b as Ye,c as Ze,d as ce}from"./chunk-JH4RACOB.js";import{a as M,b as ue}from"./chunk-JVEIK4RH.js";import{_ as lt,a as le,d as $e,e as Ve,g as tt,j as rt,k as st,na as ut,oa as dt,pa as gt,v as at,w as Y,y as it}from"./chunk-OFV26C2U.js";import{g as ct}from"./chunk-USKCFST5.js";import{a as ze}from"./chunk-PYNW5OFA.js";import{b as et}from"./chunk-23YW5PAQ.js";import{a as Xe}from"./chunk-VFH5C6D2.js";import{b as Ge,d as Qe}from"./chunk-XLZMSD5K.js";import{k as Ke}from"./chunk-BQNU4HZW.js";import{a as ot,b as nt}from"./chunk-GW766ZSO.js";import{i as Be,p as Ue}from"./chunk-2ACX7IW5.js";import{s as L,u as B,v as ie,z as We}from"./chunk-OFJPOTES.js";import{a as T,d as X}from"./chunk-U7D6Q744.js";import{F as Ne,Ga as qe,g as Me}from"./chunk-WXG3G2O6.js";import{a as je}from"./chunk-BL3CZWWD.js";import{c as Oe}from"./chunk-L3KS6MOV.js";import{b as De}from"./chunk-SSHE6B7Z.js";import{a as tr}from"./chunk-JFXINDOQ.js";import{g as Le}from"./chunk-AJXWJLZA.js";import{_ as _e,ca as Ce,fa as He}from"./chunk-SV7ZBEK2.js";import{F as be}from"./chunk-2MEOUS24.js";import{n as H}from"./chunk-RCT3O3HQ.js";import{p as Ie}from"./chunk-UGOK7VTC.js";import{a as n,e as er}from"./chunk-FTQLQJQV.js";import{randomUUID as Pr}from"node:crypto";import{mkdir as Rr}from"node:fs/promises";import q from"node:path";function ht(e){return async(t,r)=>{let s=await e?.(t,r)??null;if((t.metadata?.standaloneExperiment!==void 0||t.metadata?.localProfileExperiment!==void 0)&&!s)throw new Error("This native Experiment session has no active durable model-dispatch owner.");return s}}n(ht,"experimentSessionStreamResolver");var St=er(tr(),1);import{randomUUID as pe}from"node:crypto";var rr=15e3,or=3e4;function Wr(e){let t=new Set,r=null,s=null;async function p(a){if(!a.profileRef||!a.profileWorkflowId)throw new Error(a.profileMigrationError??`Chat Workflow ${a.id} has no Profile package.`);let u=await e.getSession(a.sessionId),i=await e.resolveProfileOwner(u,a.profileRef),c=await e.readProfilePackage(i.sourcePath,a.profileWorkflowId);return{...a,name:c.name,prompt:c.prompt}}n(p,"authoredWorkflow");async function h(){for(let a of await e.store.listChatWorkflows())if(!(a.profileRef&&a.profileWorkflowId))try{let u=await e.getSession(a.sessionId);if(!u.currentProfile)throw new Error("Original session has no explicit Profile owner.");let i=await e.resolveProfileOwner(u,u.currentProfile),c={...a,profileRef:i.ref,profileWorkflowId:a.profileWorkflowId??`chat-${a.id.toLowerCase()}`,profileMigrationError:null};await e.saveProfilePackage(i.sourcePath,c),await e.store.patchChatWorkflow(a.id,()=>c)}catch(u){let i=`Profile package migration unresolved: ${u instanceof Error?u.message:String(u)}`;await e.store.patchChatWorkflow(a.id,c=>({...c,profileMigrationError:i})),e.logger?.warn("chat workflow Profile migration unresolved",{workflowId:a.id,error:i})}}n(h,"migrateExistingWorkflows");async function w(a){let u=await e.getSession(a.sessionId),i=await e.resolveProfileOwner(u),c=T(),g=Z(a.recurrence,new Date,0);if(!g.value)throw new Error(g.error??"This workflow has no future occurrence.");let k={id:pe(),sessionId:u.id,sessionTitle:u.title,sourceTurnId:a.sourceTurnId??null,name:a.name,prompt:a.prompt,profileRef:i.ref,profileWorkflowId:`chat-${pe()}`,recurrence:a.recurrence,enabled:!0,nextRunAt:g.value,lastRunAt:null,lastRunStatus:null,lastRunId:null,lastError:g.error,scheduledRunCount:0,createdAt:c,updatedAt:c};return await e.saveProfilePackage(i.sourcePath,k),e.store.upsertChatWorkflow(k)}n(w,"create");async function v(){if(e.isClosing())return;let a=await e.store.listDueChatWorkflows(T());for(let u of a)if(!t.has(u.id)){if(e.isSessionTurnActive(u.sessionId)){await e.store.patchChatWorkflow(u.id,i=>({...i,nextRunAt:new Date(Date.now()+or).toISOString(),lastError:"Waiting for the attached chat to finish its current turn.",updatedAt:T()}));continue}await d(u,u.nextRunAt??T(),"schedule")}}n(v,"runTick");function l(){if(s)return s;let a=v().finally(()=>{s===a&&(s=null)});return s=a,a}n(l,"trackedTick");async function d(a,u,i){a=await p(a);let c=T(),g=e.store.home?await He(e.store.home):void 0,k={definitionSnapshot:structuredClone(a),...g?{configurationSnapshot:{effectiveRevision:g.effectiveRevision,sources:g.sources}}:{},id:pe(),workflowId:a.id,sessionId:a.sessionId,scheduledFor:u,trigger:i,status:"queued",turnId:null,error:null,createdAt:c,startedAt:null,completedAt:null,updatedAt:c},y=await e.store.insertChatWorkflowRun(k);return t.add(a.id),e.queue.enqueue({label:"chat-workflow-run",metadata:{workflowId:a.id,sessionId:a.sessionId,trigger:i,scheduledFor:u}},async()=>{try{await f(a,y)}finally{t.delete(a.id)}}),y}n(d,"enqueue");async function f(a,u){let i=T();await e.store.patchChatWorkflowRun(u.id,S=>({...S,status:"running",startedAt:i,updatedAt:i}));let c=null,g=null;try{c=await e.sendTurn(a.sessionId,{prompt:a.prompt,metadata:{interactionKind:"scheduled_workflow",chatWorkflowId:a.id,chatWorkflowName:a.name,chatWorkflowRunId:u.id,scheduledFor:u.scheduledFor}})}catch(S){g=S instanceof Error?S.message:String(S)}let k=T(),y=c?.status==="completed"?"succeeded":"failed";await e.store.patchChatWorkflowRun(u.id,S=>({...S,status:y,turnId:c?.id??null,error:g??c?.error??null,completedAt:k,updatedAt:k})),await e.store.patchChatWorkflow(a.id,S=>{let b=S.scheduledRunCount+(u.trigger==="schedule"?1:0),P=u.trigger==="manual"?{value:S.nextRunAt,error:null}:Z(S.recurrence,new Date,b);return{...S,enabled:P.value?S.enabled:!1,nextRunAt:S.enabled?P.value:null,lastRunAt:k,lastRunStatus:y,lastRunId:u.id,lastError:P.error??g??c?.error??null,scheduledRunCount:b,updatedAt:k}})}return n(f,"execute"),{async start(){r||(await h(),l().catch(a=>e.logger?.warn("chat workflow tick failed",{error:String(a)})),r=setInterval(()=>{l().catch(a=>e.logger?.warn("chat workflow tick failed",{error:String(a)}))},e.tickMs??rr),r.unref?.())},async stop(){r&&clearInterval(r),r=null,await s?.catch(()=>{})},create:w,async list(a){let u=await e.store.listChatWorkflows({sessionId:a});return Promise.all(u.map(async i=>{try{return await p(i)}catch(c){return{...i,profileMigrationError:c instanceof Error?c.message:String(c)}}}))},listRuns:n(a=>e.store.listChatWorkflowRuns(a),"listRuns"),async patch(a,u){let i=await e.store.getChatWorkflow(a);if(!i)return null;let c=T();if("enabled"in u){let S=u.enabled?Z(i.recurrence,new Date,i.scheduledRunCount):{value:null,error:null};return e.store.patchChatWorkflow(a,b=>({...b,enabled:u.enabled&&!!S.value,nextRunAt:u.enabled?S.value:null,lastError:S.error,updatedAt:c}))}let g=Z(u.recurrence,new Date,0);if(!i.profileRef||!i.profileWorkflowId)throw new Error(`Chat Workflow ${a} has no resolved Profile owner; migrate it before editing.`);let k=await e.getSession(i.sessionId),y=await e.resolveProfileOwner(k,i.profileRef);return await e.saveProfilePackage(y.sourcePath,{...i,name:u.name,prompt:u.prompt}),e.store.patchChatWorkflow(a,S=>({...S,name:u.name,prompt:u.prompt,recurrence:u.recurrence,enabled:!!g.value,nextRunAt:g.value,lastError:g.error,scheduledRunCount:0,updatedAt:c}))},remove:n(a=>e.store.deleteChatWorkflow(a),"remove"),async runNow(a){let u=await e.store.getChatWorkflow(a);if(!u)throw new Error("Chat workflow not found.");if(e.isSessionTurnActive(u.sessionId))throw new Error("The attached chat is currently running a turn.");return d(u,T(),"manual")}}}n(Wr,"createChatWorkflowLoop");var nr={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6};function Z(e,t,r){try{return{value:me(e,t,r),error:null}}catch(s){return{value:null,error:s instanceof Error?s.message:String(s)}}}n(Z,"safeNextOccurrence");function me(e,t,r){if(e.end.kind==="after_occurrences"&&r>=e.end.occurrences)return null;let s=wt(e.startDate,e.localTime,e.timeZone);if(e.kind==="once")return s.getTime()>t.getTime()?s.toISOString():null;let[p,h]=e.localTime.split(":").map(Number),w=e.kind==="daily"?`${h} ${p} * * *`:e.kind==="weekdays"?`${h} ${p} * * 1-5`:e.kind==="weekly"?`${h} ${p} * * ${(e.weekdays??[]).map(d=>nr[d]).join(",")}`:`${h} ${p} ${e.dayOfMonth} * *`,v=new Date(Math.max(t.getTime(),s.getTime()-1e3)),l=St.CronExpressionParser.parse(w,{currentDate:v,tz:e.timeZone}).next().toDate();if(e.end.kind==="on_date"){let d=wt(e.end.date,"23:59",e.timeZone);if(l.getTime()>d.getTime()+59999)return null}return l.toISOString()}n(me,"nextOccurrence");function wt(e,t,r){let[s,p,h]=e.split("-").map(Number),[w,v]=t.split(":").map(Number),l=Date.UTC(s,p-1,h,w,v),d=new Date(l);for(let f=0;f<3;f+=1){let a=new Intl.DateTimeFormat("en-CA",{timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(d),u=Object.fromEntries(a.map(g=>[g.type,g.value])),i=Date.UTC(Number(u.year),Number(u.month)-1,Number(u.day),Number(u.hour),Number(u.minute)),c=l-i;if(c===0)return d;d=new Date(d.getTime()+c)}return d}n(wt,"zonedLocalDateTime");function vt(e){return Ie(e,t=>{let r=0,s=0;t.exec("BEGIN IMMEDIATE");try{for(let[p,h,w]of[["local_agent_schedule_runs","local_agent_schedules","scheduleId"],["chat_workflow_runs","chat_workflows","workflowId"]]){let v=t.prepare(`SELECT id, payload FROM ${p} WHERE status IN ('queued','running')`).all();for(let l of v){let d=JSON.parse(l.payload),f=new Date().toISOString(),a=typeof d.turnId=="string"?t.prepare("SELECT payload FROM turns WHERE id = ?").get(d.turnId):void 0,i=(a?JSON.parse(a.payload):null)?.status==="completed",c=i?"The previous scheduled turn completed before shutdown.":"OpenPond stopped before this scheduled run was settled. Its external outcome may be unknown. Review the run before retrying or enabling this schedule.",g=i?"succeeded":"failed";t.prepare(`UPDATE ${p} SET status=?, payload=?, updated_at=? WHERE id=?`).run(g,JSON.stringify({...d,status:g,error:i?null:c,completedAt:f,updatedAt:f}),f,l.id);let k=t.prepare(`SELECT payload FROM ${h} WHERE id = ?`).get(String(d[w]));if(k&&!i){let y=JSON.parse(k.payload);t.prepare(`UPDATE ${h} SET enabled=0, next_run_at=NULL, payload=?, updated_at=? WHERE id=?`).run(JSON.stringify({...y,enabled:!1,nextRunAt:null,lastRunStatus:g,lastRunId:l.id,lastError:c,updatedAt:f}),f,String(d[w]))}if(i&&k&&h==="chat_workflows"){let y=qe.parse(JSON.parse(k.payload)),S=y.scheduledRunCount+(d.trigger==="schedule"?1:0),b=d.trigger==="manual"?y.nextRunAt:me(y.recurrence,new Date(f),S),P=y.enabled&&b!==null;t.prepare("UPDATE chat_workflows SET enabled=?, next_run_at=?, payload=?, updated_at=? WHERE id=?").run(P?1:0,P?b:null,JSON.stringify({...y,enabled:P,nextRunAt:P?b:null,scheduledRunCount:S,lastRunStatus:g,lastRunId:l.id,lastRunAt:f,lastError:null,updatedAt:f}),f,y.id)}i?r+=1:s+=1}}return t.exec("COMMIT"),{recovered:r,needsReview:s}}catch(p){throw t.exec("ROLLBACK"),p}})}n(vt,"reconcileInterruptedScheduledWork");async function kt(e,t){let r=sr(e);if(!r)return null;let s=await t.loadProfileState();return r==="help"?ar(s):ir(s)}n(kt,"runProfileSkillCommand");function sr(e){let t=/^\/skill(?:\s+([\s\S]*))?$/i.exec(e.trim());if(!t)return null;let r=t[1]?.trim().toLowerCase()??"";return!r||r==="list"?"list":r==="help"?"help":null}n(sr,"readOnlyProfileSkillAction");function ar(e){return{handled:!0,action:"help",profile:e,message:["Profile skills support:","- /skill list","- /skill create <what the skill should help with>","- /skill create <skill-name>: <what the skill should help with>","- /skill create --name <skill-name> <what the skill should help with>","- /skill edit <skill-name> <change request>","","Create and edit run as normal model turns with the bundled OpenPond Skill Authoring skill. Skills may include SKILL.md plus focused scripts, references, and assets. Use an Agent when the workflow needs code, actions, durable runtime behavior, setup, or Evals."].join(`
3
3
  `)}}n(ar,"profileSkillHelp");function ir(e){let t=e.skills.slice().sort((s,p)=>s.name.localeCompare(p.name));return{handled:!0,action:"list",message:t.length===0?"No profile skills found in the active profile.":[`Profile skills (${t.length}):`,...t.map(s=>{let p=s.validationStatus==="valid"?"valid":`invalid: ${s.validationMessages.join("; ")}`;return`- ${s.name} (${p}) ${s.path}`})].join(`
4
4
  `),skills:t,profile:e}}n(ir,"listProfileSkills");import{randomUUID as lr}from"node:crypto";function yt(e){return async function*({messages:t,signal:r}){for await(let s of e({model:be,messages:t,requestId:`harness-continuous-review:${lr()}`,reasoningEffort:"medium",maxTokens:Le,signal:r}))s.type==="text_delta"&&s.text?yield{text:s.text}:s.type==="usage"&&(yield{usage:{promptTokens:s.usage.prompt_tokens??0,completionTokens:s.usage.completion_tokens??0,totalTokens:s.usage.total_tokens??0}})}}n(yt,"createLocalHarnessEvaluationReviewModelStream");import{promises as Ct}from"node:fs";import N from"node:path";import{createHash as ur}from"node:crypto";import{access as cr,readFile as Pt}from"node:fs/promises";import x from"node:path";import{fileURLToPath as dr}from"node:url";var Tt=["openpond-cli","openpond-skill-authoring","openpond-agent-authoring","openpond-refiner-authoring"],Rt={"openpond-cli":["references/experiments-and-training.md","references/compact-resource-tables.md","references/diagnose-and-improve.md"],"openpond-skill-authoring":["references/skill-package-layout.md","references/copying-and-adaptation.md","references/validation-and-repair.md"],"openpond-agent-authoring":["references/profile-layout.md","references/action-and-chat-design.md","references/integrations-and-setup.md","references/validation-and-repair.md"],"openpond-refiner-authoring":["references/review-profile.md","references/core-boundary.md","references/validation-and-activation.md"]},Et=x.dirname(dr(import.meta.url));function At(e){return Tt.includes(e)}n(At,"isBundledAuthoringSkillName");async function xt(e=process.cwd()){return Promise.all(Tt.map(t=>ee(t,e)))}n(xt,"loadBundledAuthoringSkills");async function ee(e,t=process.cwd()){let r=await _t(e,t),s=await It(e,t),p=Ne.find(h=>h.name===e);if(!p)throw new Error(`Built-in OpenPond authoring skill metadata not found: ${e}`);return{...p,path:x.join(r,"SKILL.md"),sourcePath:r,charCount:s.length,sourceHash:ur("sha256").update(s).digest("hex"),validationMessages:[...p.validationMessages],resourceFiles:[...p.resourceFiles]}}n(ee,"loadBundledAuthoringProfileSkill");async function bt(e,t=process.cwd()){let r=await ee(e,t),s=await It(e,t);return{name:r.name,description:r.description,body:s,path:r.path,sourceHash:r.sourceHash,charCount:r.charCount,packagePath:r.sourcePath,resourceFiles:r.resourceFiles}}n(bt,"readBundledAuthoringProfileSkill");async function It(e,t=process.cwd()){let r=await _t(e,t),[s,...p]=await Promise.all([Pt(x.join(r,"SKILL.md"),"utf8"),...Rt[e].map(h=>Pt(x.join(r,h),"utf8"))]);return[s.trim(),...p.map((h,w)=>`
5
5
  ## Bundled reference: ${Rt[e][w]}
6
6
 
7
7
  ${h.trim()}`)].join(`
8
- `)}n(It,"loadBundledAuthoringSkillBundle");async function _t(e,t=process.cwd(),r=process.execPath){let s=[x.resolve(t,"apps","cli","skills",e),x.resolve(t,"dist","skills",e),x.resolve(x.dirname(r),"skills",e),x.resolve(Et,"skills",e),x.resolve(Et,"..","skills",e)];for(let p of s)if(await cr(x.join(p,"SKILL.md")).then(()=>!0,()=>!1))return p;throw new Error(`Bundled OpenPond authoring skill ${e} was not found. Checked: ${s.join(", ")}`)}n(_t,"resolveBundledAuthoringSkillRoot");var Ht=24e3;function Wt(e){return[{name:"refiner_profile_inspect",description:"Inspect the separately versioned active Refiner Review Profile, its immutable release identity, and recent transitions. Use before editing Refiner behavior.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:n(async t=>I(t.callId,"refiner_profile_inspect",await(await import("./refiner-profile-service-56VYLZQJ.js")).inspectRefinerProfile(e.storeDir)),"execute")},{name:"refiner_profile_update",description:"Validate and write a complete JSON Refiner Review Profile as a new immutable Refiner release. Activation is explicit; normal Harness refinement never calls this tool.",parameters:{type:"object",additionalProperties:!1,properties:{profile:{type:"object",additionalProperties:!1,properties:{schemaVersion:{type:"string",const:"openpond.refinerReviewProfile.v1"},id:{type:"string",minLength:1,maxLength:120},version:{type:"string",minLength:1,maxLength:120},name:{type:"string",minLength:1,maxLength:200},objective:{type:"string",minLength:1,maxLength:1e4},instructions:{type:"array",maxItems:100,items:{type:"object",additionalProperties:!1,properties:{id:{type:"string",minLength:1,maxLength:120},text:{type:"string",minLength:1,maxLength:1e4}},required:["id","text"]}},allowedProposalRoutes:{type:"array",items:{type:"string",enum:["memory","prompt","skill","agent"]},maxItems:4},allowedExternalRoutes:{type:"array",items:{type:"string",enum:["runtime","product","taskset","training"]},maxItems:4}},required:["schemaVersion","id","version","name","objective","instructions","allowedProposalRoutes","allowedExternalRoutes"]},activate:{type:"boolean"},reason:{type:"string",minLength:1,maxLength:1e4}},required:["profile","activate","reason"]},execute:n(async t=>{let r=await ee("openpond-refiner-authoring");return I(t.callId,"refiner_profile_update",await(await import("./refiner-profile-service-56VYLZQJ.js")).updateRefinerProfile(e.storeDir,{profile:t.args.profile,activate:t.args.activate,reason:te(t.args.reason,1e4),actor:`work:${t.session.id}`,authoringSkillHash:r.sourceHash}))},"execute")},{name:"memory_search",description:"Search bounded active Personal Harness memory without loading the full memory corpus into context. Returns ranked stable memory keys and excerpts.",parameters:{type:"object",additionalProperties:!1,properties:{query:{type:"string",minLength:1,maxLength:500},limit:{type:"integer",minimum:1,maximum:20}},required:["query"]},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let s=te(t.args.query,500).toLowerCase(),p=[...new Set(s.split(/[^a-z0-9]+/).filter(l=>l.length>1))],h=typeof t.args.limit=="number"?Math.max(1,Math.min(20,Math.trunc(t.args.limit))):8,v=(await e.store.listHarnessMemories(r.workspace.id)).map(l=>{let d=`${l.key} ${l.tags.join(" ")} ${l.content}`.toLowerCase(),f=p.reduce((a,u)=>a+(d.includes(u)?1:0),0);return{entry:l,score:f}}).filter(({score:l})=>p.length===0||l>0).sort((l,d)=>d.score-l.score||d.entry.updatedAt.localeCompare(l.entry.updatedAt)).slice(0,h).map(({entry:l,score:d})=>({key:l.key,revision:l.revision,score:d,excerpt:l.content.slice(0,1e3),tags:l.tags,updatedAt:l.updatedAt}));return I(t.callId,"memory_search",{query:s,matches:v})},"execute")},{name:"memory_inspect",description:"Read one exact active Personal Harness memory entry returned by memory_search.",parameters:{type:"object",additionalProperties:!1,properties:{key:{type:"string",minLength:1,maxLength:120}},required:["key"]},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let s=te(t.args.key,120).toLowerCase(),p=await e.store.getHarnessMemory(r.workspace.id,s);if(!p||p.status!=="active")throw new Error(`Harness memory does not exist: ${s}.`);return I(t.callId,"memory_inspect",p)},"execute")},{name:"context_read",description:"Read a bounded slice of the current Agent run's canonical host-owned turns or runtime events. This never exposes other conversations or the whole history corpus.",parameters:{type:"object",additionalProperties:!1,properties:{scope:{type:"string",enum:["turns","events"]},limit:{type:"integer",minimum:1,maximum:50}},required:["scope"]},execute:n(async t=>{let r=typeof t.args.limit=="number"?Math.max(1,Math.min(50,Math.trunc(t.args.limit))):12;if(t.args.scope==="turns"){let s=await e.store.turnsForSession(t.session.id,r);return I(t.callId,"context_read",{scope:"turns",values:s.map(p=>Ot(p,6e3))})}if(t.args.scope==="events"){let s=await e.store.runtimeEventsForSession(t.session.id,{limit:r});return I(t.callId,"context_read",{scope:"events",values:s.map(p=>Ot(p,6e3))})}throw new Error("context_read scope must be turns or events.")},"execute")},{name:"harness_inspect",description:"Inspect the immutable Harness release pinned to this Agent run. With no path, returns its release, overlay, and component catalog. With a policy-visible text path, returns bounded exact source content.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string",minLength:1,description:"Optional exact Harness-relative source path from the returned catalog."}}},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness release is selected for this run.");let s=await e.store.getHarnessRunOverlay(t.session.id),p=N.join(r.release.bundlePath,"source"),h=je.parse(JSON.parse(await Ct.readFile(N.join(p,"harness.json"),"utf8"))),w=typeof t.args.path=="string"?t.args.path.trim().replaceAll("\\","/"):null,v=null;if(w){let l=h.files.find(f=>f.path===w);if(!l||l.visibility!=="policy")throw new Error(`Harness source is not policy-visible or declared: ${w}`);if(!l.mediaType.startsWith("text/")&&l.mediaType!=="application/json")throw new Error(`Harness source is not inspectable text: ${w}`);let d=await Ct.readFile(pr(p,w),"utf8");v={path:w,content:d.slice(0,Ht),truncated:d.length>Ht}}return I(t.callId,"harness_inspect",{workspace:{id:r.workspace.id,name:r.workspace.name,revision:r.workspace.revision,channel:r.workspace.currentChannel},pinnedRelease:{id:r.release.harnessRelease.id,contentHash:r.release.harnessRelease.contentHash,sourceRevision:r.release.sourceRevision},overlay:s?{id:s.id,revision:s.revision,status:s.status,contentHash:s.contentHash}:null,components:h.files.filter(l=>l.visibility==="policy").map(l=>({kind:l.kind,path:l.path,portability:l.portability})),source:v})},"execute")},{name:"skill_inspect",description:"Read one exact textual Skill from the immutable Harness release pinned to this run. Use this before asking the Refiner to update an existing Skill.",parameters:{type:"object",additionalProperties:!1,properties:{name:{type:"string",minLength:1,description:"Exact Skill name from harness_inspect."}},required:["name"]},execute:n(async t=>{let r=await M(e.store,t.session.id),s=typeof t.args.name=="string"?t.args.name.trim():"";if(!r?.skillRuntime.readSkill||!s)throw new Error("A valid Skill name and a selected Local Harness are required.");return I(t.callId,"skill_inspect",await r.skillRuntime.readSkill(s))},"execute")},{name:"refine_request",description:"Mark a concrete reusable lesson from the current turn for bounded Harness refinement at the next safe tool boundary. Immediate task recovery remains your responsibility. Do not call for one-off errors or transient facts.",parameters:{type:"object",additionalProperties:!1,properties:{summary:{type:"string",minLength:1,maxLength:2e3},suggestedRoute:{type:"string",enum:["runtime","memory","prompt","skill","agent","product","taskset","training"]}},required:["summary"]},execute:n(async t=>I(t.callId,"refine_request",{queuedAtBoundary:!0,summary:te(t.args.summary,2e3),suggestedRoute:typeof t.args.suggestedRoute=="string"?t.args.suggestedRoute:null}),"execute")},{name:"refine_status",description:"Inspect bounded Refiner trigger, proposal, route, validation, and outcome status for this Agent run.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let s=n(async i=>e.store.listHarnessImprovementArtifacts(r.workspace.id,i,200),"all"),p=(await s("trigger_decision")).filter(i=>i.schemaVersion==="openpond.refinementTriggerDecision.v1").filter(i=>i.runRef===t.session.id),h=new Set(p.map(i=>U(i))),w=n(i=>h.has(U(fe(i.trigger))),"relatedToTrigger"),v=(await s("route_decision")).filter(i=>i.schemaVersion==="openpond.improvementRouteDecision.v1").filter(w),l=(await s("refiner_outcome")).filter(i=>i.schemaVersion==="openpond.harnessRefinerOutcome.v1").filter(w),d=new Set(l.flatMap(i=>{let c=fe(i.proposal);return c.id&&c.contentHash?[U(c)]:[]})),f=(await s("proposal")).filter(i=>i.schemaVersion==="openpond.harnessImprovementProposal.v1").filter(i=>d.has(U(i))),a=n(i=>d.has(U(fe(i.proposal))),"relatedToProposal"),u=[{kind:"trigger_decision",values:p},{kind:"route_decision",values:v},{kind:"proposal",values:f},{kind:"targeted_validation",values:(await s("targeted_validation")).filter(a)},{kind:"apply_receipt",values:(await s("apply_receipt")).filter(a)},{kind:"refiner_outcome",values:l}];return I(t.callId,"refine_status",{runId:t.session.id,artifacts:u})},"execute")}]}n(Wt,"createLocalHarnessModelToolDefinitions");function U(e){return`${String(e.id??"")}:${String(e.contentHash??"")}`}n(U,"artifactRefKey");function fe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}n(fe,"asRecord");function I(e,t,r){return{toolCallId:e,name:t,ok:!0,contentText:JSON.stringify(r),data:r}}n(I,"modelResult");function te(e,t){if(typeof e!="string"||!e.trim())throw new Error("A non-empty refinement summary is required.");return e.trim().slice(0,t)}n(te,"boundedText");function Ot(e,t){let r=JSON.stringify(e);return r.length<=t?e:{truncated:!0,json:r.slice(0,t)}}n(Ot,"boundedJson");function pr(e,t){let r=N.resolve(e),s=N.resolve(r,...t.split("/")),p=N.relative(r,s);if(!p||p.startsWith("..")||N.isAbsolute(p))throw new Error(`Harness source path escapes its release: ${t}`);return s}n(pr,"containedSourcePath");function Lt(){return{loadOpenPondProfileStateForRef:ie,executeProfileSkillCommand:n(({prompt:e,profileRef:t})=>kt(e,{loadProfileState:n(()=>ie(t),"loadProfileState")}),"executeProfileSkillCommand")}}n(Lt,"createProfileTurnDependencies");import{randomUUID as mr}from"node:crypto";import{setTimeout as fr}from"node:timers/promises";async function Dt(e,t){if(t.metadata?.titleSource||t.archived||t.hiddenFromDefaultSidebar)return t;let s=(await e.runtimeEventsForSession(t.id,{names:["session.title.updated"]})).at(-1)?.data,p=s?.session;if(s?.titleSource!=="fallback"||p?.title!==t.title)return t;let[h]=await e.runtimeEventsForSession(t.id,{names:["turn.started"],limit:1}),w=h?.turnId?await e.getTurn(h.turnId):null;return w?.prompt.trim()?await e.updateSession(t.id,v=>v.metadata?.titleSource||v.title!==t.title?v:{...v,metadata:{...v.metadata,titleSource:"fallback",autoTitle:{prompt:w.prompt.slice(0,2e4),title:v.title,attempts:0,nextAttemptAt:0}}})??t:t}n(Dt,"recoverTemporarySessionTitle");var ge="accounts/fireworks/models/deepseek-v4-flash",gr="off",hr=12e3,Mt=7,wr=["Make a concise conversation title from the user's message.","Return only the title: 3 to 7 words, plain text, sentence case.","Do not use quotation marks, markdown, labels, or ending punctuation."].join(" ");function Sr(e){let s=(e.replace(/<[^>]*>/gu," ").replace(/[\r\n]+/gu," ").replace(/\s+/gu," ").trim().match(/[\p{L}\p{N}][\p{L}\p{N}'’._/+:-]*/gu)??[]).slice(0,Mt).join(" ");return s?`${s.charAt(0).toUpperCase()}${s.slice(1)}`:"New conversation"}n(Sr,"fallbackSessionTitle");function vr(e){let r=e.replace(/<think>[\s\S]*?<\/think>/giu," ").replace(/^\s*(?:title|conversation title)\s*:\s*/iu,"").replace(/^[\s`"'“”‘’*_#-]+|[\s`"'“”‘’*_#.!?,;:-]+$/gu,"").replace(/[\r\n]+/gu," ").replace(/\s+/gu," ").trim().split(" ").filter(Boolean);return r.length<2?null:r.slice(0,Mt).join(" ")}n(vr,"generatedSessionTitle");function kr(e){return["Make a title from this request. Do not execute it.","<user_request>",e.slice(0,2e4),"</user_request>"].join(`
9
- `)}n(kr,"titleRequestMessage");function Nt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.autoTitlePrompt;return typeof t=="string"&&t.trim()?t.trim():null}n(Nt,"autoTitlePromptFromPayload");function yr(e){let t=Nt(e);if(!t||!e||typeof e!="object"||Array.isArray(e))return e;let r=e,s=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:{};return{...r,title:"",metadata:{...s,titleSource:"pending",autoTitle:{prompt:t.slice(0,2e4),title:"",attempts:0,nextAttemptAt:0}}}}n(yr,"withPendingAutoTitle");function re(e){if(!e||!["pending","fallback"].includes(String(e.metadata?.titleSource)))return null;let t=e.metadata?.autoTitle;return t&&typeof t.prompt=="string"&&t.title===e.title&&Number.isInteger(t.attempts)&&t.attempts>=0&&Number.isFinite(t.nextAttemptAt)?t:null}n(re,"pendingTitle");function qt(e){let t=new Map,r=null,s=new AbortController,p=[5e3,3e4];async function h(l){let d=new AbortController,f=setTimeout(()=>d.abort(new Error("session_title_generation_timeout")),hr);f.unref?.();let a="";try{for await(let i of e.stream({model:ge,messages:[{role:"system",content:wr},{role:"user",content:kr(l)}],reasoningEffort:gr,maxTokens:128,temperature:.2,requestId:`session-title-${mr()}`,signal:AbortSignal.any([d.signal,s.signal])}))i.type==="text_delta"&&i.text&&(a+=i.text);let u=vr(a);if(!u)throw new Error("session_title_generation_empty_response");return u}finally{clearTimeout(f)}}n(h,"generate");async function w(l){for(;!s.signal.aborted;){let d=re(await e.store.getSession(l));if(!d||d.attempts>=3)return;let f=d.nextAttemptAt-Date.now();f>0&&await fr(f,void 0,{signal:s.signal,ref:!1});let a=re(await e.store.getSession(l));if(!a||a.attempts!==d.attempts)return;let u,i="model";try{u=await h(d.prompt)}catch(k){if(s.signal.aborted)return;u=Sr(d.prompt),i="fallback",e.logger.warn("session title generation used temporary title",{error:k instanceof Error?k.message:String(k),model:ge,sessionId:l,attempt:d.attempts+1})}if(s.signal.aborted)return;let c=!1,g=await e.store.updateSession(l,k=>{let y=re(k);return!y||y.attempts!==d.attempts||y.prompt!==d.prompt?k:(c=!0,{...k,title:u,metadata:{...k.metadata,titleSource:i,autoTitle:i==="model"?null:{...d,title:u,attempts:d.attempts+1,nextAttemptAt:Date.now()+(p[d.attempts]??0)}}})});if(!c||!g||(await e.appendRuntimeEvent(X({sessionId:l,name:"session.title.updated",source:"server",status:"completed",data:{session:g,model:ge,titleSource:i}})),i==="model"))return}}n(w,"run");function v(l){if(s.signal.aborted)return Promise.resolve();let d=t.get(l);if(d)return d;let f=w(l).catch(a=>{s.signal.aborted||e.logger.warn("session title generation failed",{error:a instanceof Error?a.message:String(a),sessionId:l})}).finally(()=>t.delete(l));return t.set(l,f),f}return n(v,"schedule"),{wrapCreateSession(l){return this.recover().catch(d=>e.logger.warn("Session title recovery failed",{error:String(d)})),async d=>{let f=await l(yr(d));return Nt(d)&&v(f.id),f}},schedule:v,recover(){return r||(r=(async()=>{for(let l of await e.store.sessionShells()){if(s.signal.aborted)return;let d=await Dt(e.store,l);re(d)&&v(l.id)}})().finally(()=>{r=null}),r)},async close(){s.abort(),await r?.catch(()=>{}),await Promise.allSettled(t.values())}}}n(qt,"createSessionTitleService");var Er=3,Tr=["sqlite_store","runtime_event_bus","session_store","hosted_provider","web_search","connected_apps","workspace_tools","command_approvals","harness","refiner","agent_runtime","jsonl_transport"];async function gn(e={}){if(e.runtimeStorage)return(await import("./hosted-app-server-composition-WDDO6F23.js")).createHostedOwnedAppServer({...e,runtimeStorage:e.runtimeStorage});let t=q.resolve(e.storeDir??de());return Fe(t,()=>Ar({...e,storeDir:t}))}n(gn,"createOpenPondAppServer");async function Ar(e){let t=q.resolve(e.storeDir??de()),r=!!e.embedding;if(r&&!e.streamOpenPondHostedChatTurn)throw new Error("Embedded Work requires an explicit model-stream adapter.");let s=e.services??{},p=await $(s.webSearch,r,async()=>(await import("./web-search-FTVNZ7PH.js")).createWebSearchExecutorFromEnv()),h=await $(s.scheduling,r,async()=>(await import("./saved-work-54I5ZJTC.js")).createHostedSavedWork),w=await $(s.connectedApps,r,async()=>{let[o,m]=await Promise.all([import("./connected-app-executor-DHXZE4X3.js"),import("./app-server-connected-apps-NH4667QJ.js")]);return{execute:o.createCloudConnectedAppToolExecutor(),list:m.listAppServerIntegrationConnections}}),v=await $(s.tasksets,r,async()=>(await import("./hosted-tasksets-KCLNMPG5.js")).executeHostedTasksetAction),l=s.backgroundReview??!r,d=!r&&!!v;await _e(t),l&&await(await import("./refiner-profile-service-56VYLZQJ.js")).initializeRefinerProfile(t);let f=q.resolve(e.workspaceDir??process.cwd());await Rr(f,{recursive:!0});let a=e.version??De,u=Ue(),i=Ve({channel:"app-server",logDir:q.join(t,"logs"),metadata:{version:a,runtimeVersion:u,placement:"hosted_work"}});D(()=>i.flush());let c=new pt(t,{logger:i});D(()=>c.close()),await c.recentTurns(1);let g=c,k=n(async()=>(await Ce(t)).preferences,"loadRuntimePreferences"),y=vt(t);(y.recovered||y.needsReview)&&i.warn("Scheduled work requires review after restart",y);let S=nt(e.streamOpenPondHostedChatTurn??Be,{enabled:ot()}),b=yt(S),{appendRuntimeEvent:P,closeEventSubscribers:jt,subscribeRuntimeEvents:Ft}=it({logger:i,store:g}),he=Y({queueId:"turn-follow-up",logger:i}),we=Y({queueId:"harness-refiner",logger:i}),Se=Y({queueId:"subagent",logger:i});if(e.harness&&e.profileSource)throw new Error("Configure either an explicit Harness source or Profile source for this app-server.");let A=null,z,oe;if(e.experimentHarnessSource){if(!e.experimentPolicyClient||e.profileSource||e.harness||e.runtimeStorage)throw new Error("A published standalone Experiment source requires its isolated policy owner and local case store.");let o=e.experimentHarnessSource.sourcePackage;z=await(await import("./published-experiment-source-SDXUVPE7.js")).installPublishedExperimentSource({store:c,storeDir:t,ownerId:e.experimentHarnessSource.ownerId,sourcePackage:o,reference:{harnessRelease:{id:o.harnessRelease.id,contentHash:o.harnessRelease.contentHash},agentSnapshot:{id:o.agentSnapshot.id,contentHash:o.agentSnapshot.contentHash},sourcePackageHash:o.contentHash},createdAt:T()})}if(e.profileSource){let o=e.profileSource;if(!o.repositoryId.trim()||!o.profileId.trim()||!o.sourceRevision.trim())throw new Error("Explicit Profile source requires an identity and accepted revision.");let m=await We({repoPath:o.repoPath,profileId:o.profileId});if(m.mode!=="local"||!m.sourcePath||m.error||m.git?.isRepo&&(m.git.head!==o.sourceRevision||m.git.dirty))throw new Error("Explicit Profile source does not match its accepted revision.");A=await Je({store:c,storeDir:t,workspaceId:`${Xe}${H({profileId:o.profileId,sourceRevision:o.sourceRevision}).slice(0,24)}`,ownerId:"desktop-personal",name:o.profileId,profile:m,sourceRevision:o.sourceRevision,repositoryId:o.repositoryId})}e.harness&&(await Ke({store:c,storeDir:t,sourceDir:e.harness.sourceDirectory,id:e.harness.workspaceId,name:e.harness.name,ownerId:"desktop-personal"}),await c.selectHarnessWorkspace({ownerKind:"personal",ownerId:"desktop-personal",workspaceId:e.harness.workspaceId,updatedAt:T()})),await Ge({store:c,storeDir:t,loadProfileState:L,now:T}).catch(o=>{i.warn("app-server Harness initialization failed",{error:o})});let V=rt({appendRuntimeEvent:P,findLocalProject:n(o=>lt(c,o),"findLocalProject"),onRepositoryInstructionDiagnostic:n((o,m)=>{i.warn("repository instruction file skipped",{diagnostic:o,sessionId:m.id})},"onRepositoryInstructionDiagnostic")}),{createSession:j,getSession:C,updateSession:K,completeTurn:Bt,failTurn:Ut,interruptTurn:$t}=dt({store:g,defaultSessionCwd:n(()=>f,"defaultSessionCwd"),appendRuntimeEvent:P,loadAppPreferences:k,loadLastUsedProfile:n(async()=>(await B()).lastUsed,"loadLastUsedProfile")}),ve=qt({appendRuntimeEvent:P,store:g,logger:i,stream:S}),ke=r?j:ve.wrapCreateSession(j),J=at({workspaceDir:f,logger:i,getSession:C,updateSession:K,appendRuntimeEvent:P,sandboxRequest:e.sandboxRequest??(r?async()=>{throw new Error("Sandbox execution is not configured in this app-server deployment.")}:void 0)}),zt=d?await(await import("./local-harness-taskset-review-E5GN5LTR.js")).createLocalHarnessTasksetReviewControl({store:c,storeDir:t,evaluationRuntime:{streamOpenPondHostedChatTurn:S,workRuntime:{createSession:j,getSession:C,executeWorkspaceTool:J.executeWorkspaceTool,runtimeEventsForSession:n(o=>g.runtimeEventsForSession(o),"runtimeEventsForSession")},resolveReleasedHarness:n(async()=>{let o=await Qe(c);return o?{agentSnapshot:o.release.agentSnapshot,harnessRelease:o.release.harnessRelease,instructionContext:o.instructionContext}:null},"resolveReleasedHarness")}}):void 0,ye=n(async o=>{await g.upsertApproval(o)},"upsertApproval"),Pe=et({upsertApproval:ye,appendRuntimeEvent:P}),Vt=await $(s.projectActions,r,async()=>(await import("./project-action-payload-53OH6WDH.js")).createProjectActionRunPayload({appendRuntimeEvent:P,resolveProjectRoot:n(async()=>null,"resolveProjectRoot")})),Kt=n(async o=>{try{await g.upsertModelUsageRecord(o)}catch(m){await P(br(o,m)).catch(()=>{})}},"safeUpsertModelUsageRecord"),Re=l?(await import("./local-harness-improvement-runtime-3YJQRYXC.js")).createLocalHarnessImprovementRuntime({store:c,storeDir:t,queue:we,streamOpenPondHostedChatTurn:S,appendRuntimeEvent:P,upsertModelUsageRecord:Kt}):void 0;await Re?.reconcilePending();let ne=e.profileExternalDataset?await(A&&e.profileExternalDatasetClient?(await import("./host-profile-external-dataset-KSEPXY2S.js")).createHostProfileExternalDataset({value:e.profileExternalDataset,release:A,sourceRevision:e.profileSource.sourceRevision,client:e.profileExternalDatasetClient}):Promise.reject(new Error("External Dataset execution requires an explicit private Profile source owner."))):null,Jt=$e({deviceId:`evaluation-${H(t).slice(0,24)}`,storeDir:t,runtimeEventsForSession:n(o=>g.runtimeEventsForSession(o),"runtimeEventsForSession")}),_=A?(await import("./host-profile-evaluation-tools-UF4ATIUF.js")).createHostProfileEvaluationTools({storeDir:t,release:A,getTurn:n(o=>g.getTurn(o),"getTurn"),getSession:C,saveOutput:Jt.saveOwnedOutputBytes,recordOutput:n(async(o,m,E)=>{await P({id:Pr(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:o,turnId:m,action:"work_output_save",status:"completed",output:`Saved ${E.outputRef.title} as immutable case output.`,data:E})},"recordOutput"),authorize:n(async o=>{if(ne){await ne.authorize(o);return}let m=await Te();if(!m||m.ref.profileId!==e.profileSource?.profileId||m.sourceRevision!==e.profileSource?.sourceRevision)throw new Error("The released evaluation source authority changed.");let E=await c.getHarnessReleaseRecord(A.harnessRelease.contentHash);if(!E||E.harnessRelease.contentHash!==A.harnessRelease.contentHash)throw new Error("The isolated evaluation release is unavailable.")},"authorize")}):null,G=e.embedding?gt(e.embedding,async(o,m)=>{let E=await g.getTurn(o);if(!E)throw new Error("Embedded turn is unavailable.");let O=await C(E.sessionId),F=O.metadata?.embeddingToolBindings,W=[...m].sort((Q,Zt)=>Q.name.localeCompare(Zt.name));if(F!==void 0&&H(F)!==H(W))throw new Error("Embedded tool bindings changed; start a new thread.");await K(O.id,{metadata:{...O.metadata,embeddingToolBindings:W}}),await g.updateTurn(o,Q=>({...Q,metadata:{...Q.metadata,toolBindings:W}}))}):void 0,R=ut({executionHost:r?"embedded":"local",storageHome:t,workInputsForSession:e.workInputsForSession,finalizeWorkTurn:e.finalizeWorkTurn,isolatedProfileEvaluationForTurn:_?async o=>{if(o.metadata?.profileEvaluationRun===void 0)return!1;if(!_.ownsSession(o.id))throw new Error("A Profile evaluation target has no actual admitted case owner.");return!0}:void 0,executeProfileEvaluationAction:_?.executeAction,resolveModelTools:e.resolveModelTools||_||G?async o=>{let m=_?_.ownsSession(o.session.id)?await _.resolveTools(o):await G?.(o)??[]:G?await G(o):o.tools;return e.resolveModelTools?e.resolveModelTools({...o,tools:m}):m}:void 0,...r?{hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1}}:{},attachmentRootDir:q.join(t,"attachments"),store:g,inboxStore:c,createSession:j,upsertApproval:ye,getSession:C,updateSession:K,completeTurn:Bt,failTurn:Ut,interruptTurn:$t,defaultSessionCwd:n(()=>f,"defaultSessionCwd"),findOpenPondApp:n(async o=>xr(o,f),"findOpenPondApp"),resolveSessionWorkspaceCwd:n(async o=>o.cwd?.trim()||f,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:n(async()=>{throw new Error("The hosted app-server placement uses the OpenPond provider; Codex process hosting is not configured.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:J.appendWorkspaceDiffEvent,workspaceDiffBaseline:J.workspaceDiffBaseline,appendRuntimeEvent:P,processHarnessImprovementBoundary:Re,executeWorkspaceTool:J.executeWorkspaceTool,executeOpenPondCommand:Pe.executeCommand,executeProjectAction:Vt,executeDatasetBuilderAction:v,loadOpenPondProfileState:L,...Lt(),...r||s.profileActions===!1?{executeProfileSkillCommand:void 0}:{},loadOpenPondProfileLibrary:B,readOpenPondProfileSkill:Oe,loadSelectedHarnessRuntime:n(o=>ce(c,o),"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:n(o=>ue({store:c,...o}),"ensureHarnessRunOverlay"),harnessModelTools:Wt({store:c,storeDir:t}).filter(o=>l||!["refiner_profile_inspect","refiner_profile_update","refine_request","refine_status"].includes(o.name)),loadBuiltInOpenPondSkills:n(async()=>[await mt(),...await xt()],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:n(async o=>{if(o==="openpond-taskset-authoring")return ft();if(At(o))return bt(o);throw new Error(`Built-in OpenPond skill not found: ${o}`)},"readBuiltInOpenPondSkill"),executeWebSearch:p,createScheduledWork:h,executeConnectedAppTool:w?.execute,listIntegrationConnections:w?.list,loadPersonalizationSoul:n(async()=>(await tt(c,t)).soul,"loadPersonalizationSoul"),loadAppPreferences:k,maybeCreateScaffoldForTurn:V.maybeCreateScaffoldForTurn,hostedSystemPrompt:V.hostedSystemPrompt,appendAssistantText:V.appendAssistantText,appendHostedContextUsage:V.appendHostedContextUsage,streamOpenPondHostedChatTurn:S,turnFollowUpQueue:he,resolveSessionModelStream:ht(async(o,m)=>await oe?.resolveSessionModelStream(o,m)??await e.resolveSessionModelStream?.(o,m)??null),subagentQueue:Se,maxHostedWorkspaceToolRounds:e.experimentHarnessSource?(await import("./experiments-VOCZ4DW3.js")).STANDALONE_EXPERIMENT_MAX_POLICY_CALLS:ct(e.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:Er});D(()=>R.close()),await R.recoverPendingSubagentCompletions(),await R.recoverTaskInbox();async function Gt(o,m){let E=await R.resolveNativeAgentApproval(o,m);if(E)return E;let O=await Pe.resolveApproval(o,m);if(O)return O;let F=await R.resolveCreateImproveApproval(o,m);if(F)return F;let W=await R.resolveSubagentPatchApplyApproval(o,m);if(W)return W;throw new Error(`Approval not found: ${o}`)}n(Gt,"resolveApproval");let Ee=!1,Te=n(async()=>{if(e.profileSource)return{ref:{source:"openpond_git",repositoryId:e.profileSource.repositoryId,profileId:e.profileSource.profileId},sourceRevision:e.profileSource.sourceRevision};let[o,m]=await Promise.all([B(),L()]);return o.lastUsed&&m.git?.head&&!m.git.dirty?{ref:o.lastUsed,sourceRevision:m.git.head}:null},"selectedEvaluationProfile"),Ae=n(async()=>{if(e.profileSource&&A)return Ze({store:c,release:A,ref:{source:"openpond_git",repositoryId:e.profileSource.repositoryId,profileId:e.profileSource.profileId},sourceRevision:e.profileSource.sourceRevision});let[o,m]=await Promise.all([B(),L()]);if(!o.lastUsed)throw new Error("Select a Profile before loading its workflows.");return Ye({store:c,storeDir:t,ref:o.lastUsed,profile:m,reloadProfile:L})},"listProfileWorkflows");if(z){let o=z;oe=(await import("./standalone-experiment-turn-owner-TW5MTWIO.js")).createStandaloneExperimentTurnOwner({store:c,createSession:j,sendTurn:R.sendTurn,interruptSessionTurn:R.interruptSessionTurn,authorizeWorkspace:n(async(m,E)=>{if(E.id!==o.workspace.id||H(E.ownerScope)!==H(o.workspace.ownerScope)||m.sourcePackageHash!==o.workspace.metadata.experimentSourcePackageHash||m.harnessRelease.id!==o.release.harnessRelease.id||m.harnessRelease.contentHash!==o.release.harnessRelease.contentHash)throw new Error("Standalone Experiment source differs from this execution owner's admitted closure.")},"authorizeWorkspace")})}let se=le(async()=>{let{createAppServerEvaluations:o}=await import("./app-server-evaluations-RRLYWLPK.js");return o({options:e,store:c,storeDir:t,explicitProfileRelease:A,externalDataset:ne,isolatedProfileTools:_,selectedEvaluationProfile:Te,listProfileWorkflows:Ae,createSessionWithAutoTitle:ke,turnRunner:R,streamOpenPondHostedChatTurn:S,publishedExperimentSource:z,standaloneExperimentOwner:oe})}),Qt=se.methods(["listProfileEvaluations","executeProfileEvaluationCase","executeExperimentCase","cancelExperimentCase","executeProfileEvaluationRun","prepareProfileEvaluationRun","runPreparedProfileEvaluation","runProfileEvaluationSuite","compareProfileEvaluationRuns","buildProfileEvaluationReport"]);D(()=>se.close());let ae=le(async()=>{let{createAppServerHarnessServices:o}=await import("./app-server-harness-services-XXM336NU.js");return o({store:c,storeDir:t,backgroundReview:l,harnessEvaluationEnabled:d,harnessEvaluationReviewStream:b,harnessTasksetReview:zt})}),Xt=ae.methods(["inspectHarness","reviewHarnessProposal","reviewHarness","acceptHarnessEvaluationReview","materializeHarnessEvaluationTaskset","runHarnessEvaluationBaseline","validateHarness","updateHarnessBackgroundReview","diffHarness","rollbackHarness","inspectRefiner","updateRefiner","activateRefiner","rollbackRefiner"]);D(()=>ae.close());let Yt=ze({ports:st({placement:"hosted_work",connectedAppProviders:w?void 0:[],featureOverrides:{harnessBackgroundReview:l,harnessProposalReview:l,harnessReview:d,harnessEvaluationReview:d,harnessEvaluationReviewAcceptance:d,harnessEvaluationTasksetMaterialization:d,harnessEvaluationBaseline:d,refinerProfiles:l,immutableRefinerAdmission:l},createSession:ke,getSession:C,turnsForSession:n(o=>g.turnsForSession(o,1e3),"turnsForSession"),runtimeEventsForSession:n(o=>g.runtimeEventsForSession(o),"runtimeEventsForSession"),sendTurn:R.sendTurn,steerSessionTurn:R.steerSessionTurn,readTaskInbox:R.readTaskInbox,queueTaskInput:R.queueTaskInput,updateTaskInput:R.updateTaskInput,isSessionTurnActive:R.isSessionTurnActive,waitForSessionTurnSettlement:R.waitForSessionTurnSettlement,interruptSessionTurn:R.interruptSessionTurn,resolveApproval:Gt,listProfileWorkflows:Ae,loadProfileTrainingSource:n(async()=>{if(!e.profileSource||!A)throw new Error("An explicit published Profile is required for hosted training source export.");return(await import("./profile-training-source-VIND2MM2.js")).profileTrainingSource({release:A,storeDir:t})},"loadProfileTrainingSource"),...Qt,...Xt,subscribeRuntimeEvents:Ft,observeRuntimeOperation:n(o=>{i.info("agent runtime operation",o)},"observeRuntimeOperation")}),close:n(async()=>{Ee||(Ee=!0,await ve.close(),await Promise.all([se.close(),ae.close(),R.close()]),_?.close(),await Promise.all([he.drain(),we.drain(),Se.drain()]),await jt(),await c.close(),await i.flush())},"close")}),xe=Tr.filter(o=>(o!=="web_search"||!!p)&&(o!=="connected_apps"||!!w)&&(o!=="refiner"||l));return i.info("app-server ready",{storePath:c.storePath,workspaceDir:f,composition:xe}),{...Yt,updateSession:K,pinSessionHarness:n(async o=>{let m=await ce(c,await C(o));if(!m)return null;let E={id:m.release.harnessRelease.id,contentHash:m.release.harnessRelease.contentHash};return await ue({store:c,runId:o,workspace:m.workspace,harnessRelease:E,admittedAt:T()}),E},"pinSessionHarness"),storePath:c.storePath,workspaceDir:f,composition:xe}}n(Ar,"createOwnedAppServer");function xr(e,t){return{id:e||Me(t),name:q.basename(t)||"Sandbox workspace",description:null,visibility:"private",gitOwner:null,gitRepo:null,gitHost:null,defaultBranch:null,sandbox:!1,updatedAt:T(),latestDeployment:null}}n(xr,"workspaceApp");function br(e,t){return X({sessionId:e.sessionId??void 0,turnId:e.turnId??void 0,name:"diagnostic",source:"server",status:"failed",output:t instanceof Error?t.message:"Failed to persist model usage record.",data:{kind:"model_usage_record_failed",requestId:e.requestId,provider:e.provider,model:e.model}})}n(br,"runtimeDiagnostic");async function $(e,t,r){if(e!==!1)return e!==void 0?e:t?void 0:r()}n($,"selectService");export{ht as a,Wr as b,vt as c,yt as d,At as e,xt as f,ee as g,bt as h,Wt as i,Lt as j,qt as k,Tr as l,gn as m};
8
+ `)}n(It,"loadBundledAuthoringSkillBundle");async function _t(e,t=process.cwd(),r=process.execPath){let s=[x.resolve(t,"apps","cli","skills",e),x.resolve(t,"dist","skills",e),x.resolve(x.dirname(r),"skills",e),x.resolve(Et,"skills",e),x.resolve(Et,"..","skills",e)];for(let p of s)if(await cr(x.join(p,"SKILL.md")).then(()=>!0,()=>!1))return p;throw new Error(`Bundled OpenPond authoring skill ${e} was not found. Checked: ${s.join(", ")}`)}n(_t,"resolveBundledAuthoringSkillRoot");var Ht=24e3;function Wt(e){return[{name:"refiner_profile_inspect",description:"Inspect the separately versioned active Refiner Review Profile, its immutable release identity, and recent transitions. Use before editing Refiner behavior.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:n(async t=>I(t.callId,"refiner_profile_inspect",await(await import("./refiner-profile-service-OLJHA4DI.js")).inspectRefinerProfile(e.storeDir)),"execute")},{name:"refiner_profile_update",description:"Validate and write a complete JSON Refiner Review Profile as a new immutable Refiner release. Activation is explicit; normal Harness refinement never calls this tool.",parameters:{type:"object",additionalProperties:!1,properties:{profile:{type:"object",additionalProperties:!1,properties:{schemaVersion:{type:"string",const:"openpond.refinerReviewProfile.v1"},id:{type:"string",minLength:1,maxLength:120},version:{type:"string",minLength:1,maxLength:120},name:{type:"string",minLength:1,maxLength:200},objective:{type:"string",minLength:1,maxLength:1e4},instructions:{type:"array",maxItems:100,items:{type:"object",additionalProperties:!1,properties:{id:{type:"string",minLength:1,maxLength:120},text:{type:"string",minLength:1,maxLength:1e4}},required:["id","text"]}},allowedProposalRoutes:{type:"array",items:{type:"string",enum:["memory","prompt","skill","agent"]},maxItems:4},allowedExternalRoutes:{type:"array",items:{type:"string",enum:["runtime","product","taskset","training"]},maxItems:4}},required:["schemaVersion","id","version","name","objective","instructions","allowedProposalRoutes","allowedExternalRoutes"]},activate:{type:"boolean"},reason:{type:"string",minLength:1,maxLength:1e4}},required:["profile","activate","reason"]},execute:n(async t=>{let r=await ee("openpond-refiner-authoring");return I(t.callId,"refiner_profile_update",await(await import("./refiner-profile-service-OLJHA4DI.js")).updateRefinerProfile(e.storeDir,{profile:t.args.profile,activate:t.args.activate,reason:te(t.args.reason,1e4),actor:`work:${t.session.id}`,authoringSkillHash:r.sourceHash}))},"execute")},{name:"memory_search",description:"Search bounded active Personal Harness memory without loading the full memory corpus into context. Returns ranked stable memory keys and excerpts.",parameters:{type:"object",additionalProperties:!1,properties:{query:{type:"string",minLength:1,maxLength:500},limit:{type:"integer",minimum:1,maximum:20}},required:["query"]},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let s=te(t.args.query,500).toLowerCase(),p=[...new Set(s.split(/[^a-z0-9]+/).filter(l=>l.length>1))],h=typeof t.args.limit=="number"?Math.max(1,Math.min(20,Math.trunc(t.args.limit))):8,v=(await e.store.listHarnessMemories(r.workspace.id)).map(l=>{let d=`${l.key} ${l.tags.join(" ")} ${l.content}`.toLowerCase(),f=p.reduce((a,u)=>a+(d.includes(u)?1:0),0);return{entry:l,score:f}}).filter(({score:l})=>p.length===0||l>0).sort((l,d)=>d.score-l.score||d.entry.updatedAt.localeCompare(l.entry.updatedAt)).slice(0,h).map(({entry:l,score:d})=>({key:l.key,revision:l.revision,score:d,excerpt:l.content.slice(0,1e3),tags:l.tags,updatedAt:l.updatedAt}));return I(t.callId,"memory_search",{query:s,matches:v})},"execute")},{name:"memory_inspect",description:"Read one exact active Personal Harness memory entry returned by memory_search.",parameters:{type:"object",additionalProperties:!1,properties:{key:{type:"string",minLength:1,maxLength:120}},required:["key"]},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let s=te(t.args.key,120).toLowerCase(),p=await e.store.getHarnessMemory(r.workspace.id,s);if(!p||p.status!=="active")throw new Error(`Harness memory does not exist: ${s}.`);return I(t.callId,"memory_inspect",p)},"execute")},{name:"context_read",description:"Read a bounded slice of the current Agent run's canonical host-owned turns or runtime events. This never exposes other conversations or the whole history corpus.",parameters:{type:"object",additionalProperties:!1,properties:{scope:{type:"string",enum:["turns","events"]},limit:{type:"integer",minimum:1,maximum:50}},required:["scope"]},execute:n(async t=>{let r=typeof t.args.limit=="number"?Math.max(1,Math.min(50,Math.trunc(t.args.limit))):12;if(t.args.scope==="turns"){let s=await e.store.turnsForSession(t.session.id,r);return I(t.callId,"context_read",{scope:"turns",values:s.map(p=>Ot(p,6e3))})}if(t.args.scope==="events"){let s=await e.store.runtimeEventsForSession(t.session.id,{limit:r});return I(t.callId,"context_read",{scope:"events",values:s.map(p=>Ot(p,6e3))})}throw new Error("context_read scope must be turns or events.")},"execute")},{name:"harness_inspect",description:"Inspect the immutable Harness release pinned to this Agent run. With no path, returns its release, overlay, and component catalog. With a policy-visible text path, returns bounded exact source content.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string",minLength:1,description:"Optional exact Harness-relative source path from the returned catalog."}}},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness release is selected for this run.");let s=await e.store.getHarnessRunOverlay(t.session.id),p=N.join(r.release.bundlePath,"source"),h=je.parse(JSON.parse(await Ct.readFile(N.join(p,"harness.json"),"utf8"))),w=typeof t.args.path=="string"?t.args.path.trim().replaceAll("\\","/"):null,v=null;if(w){let l=h.files.find(f=>f.path===w);if(!l||l.visibility!=="policy")throw new Error(`Harness source is not policy-visible or declared: ${w}`);if(!l.mediaType.startsWith("text/")&&l.mediaType!=="application/json")throw new Error(`Harness source is not inspectable text: ${w}`);let d=await Ct.readFile(pr(p,w),"utf8");v={path:w,content:d.slice(0,Ht),truncated:d.length>Ht}}return I(t.callId,"harness_inspect",{workspace:{id:r.workspace.id,name:r.workspace.name,revision:r.workspace.revision,channel:r.workspace.currentChannel},pinnedRelease:{id:r.release.harnessRelease.id,contentHash:r.release.harnessRelease.contentHash,sourceRevision:r.release.sourceRevision},overlay:s?{id:s.id,revision:s.revision,status:s.status,contentHash:s.contentHash}:null,components:h.files.filter(l=>l.visibility==="policy").map(l=>({kind:l.kind,path:l.path,portability:l.portability})),source:v})},"execute")},{name:"skill_inspect",description:"Read one exact textual Skill from the immutable Harness release pinned to this run. Use this before asking the Refiner to update an existing Skill.",parameters:{type:"object",additionalProperties:!1,properties:{name:{type:"string",minLength:1,description:"Exact Skill name from harness_inspect."}},required:["name"]},execute:n(async t=>{let r=await M(e.store,t.session.id),s=typeof t.args.name=="string"?t.args.name.trim():"";if(!r?.skillRuntime.readSkill||!s)throw new Error("A valid Skill name and a selected Local Harness are required.");return I(t.callId,"skill_inspect",await r.skillRuntime.readSkill(s))},"execute")},{name:"refine_request",description:"Mark a concrete reusable lesson from the current turn for bounded Harness refinement at the next safe tool boundary. Immediate task recovery remains your responsibility. Do not call for one-off errors or transient facts.",parameters:{type:"object",additionalProperties:!1,properties:{summary:{type:"string",minLength:1,maxLength:2e3},suggestedRoute:{type:"string",enum:["runtime","memory","prompt","skill","agent","product","taskset","training"]}},required:["summary"]},execute:n(async t=>I(t.callId,"refine_request",{queuedAtBoundary:!0,summary:te(t.args.summary,2e3),suggestedRoute:typeof t.args.suggestedRoute=="string"?t.args.suggestedRoute:null}),"execute")},{name:"refine_status",description:"Inspect bounded Refiner trigger, proposal, route, validation, and outcome status for this Agent run.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:n(async t=>{let r=await M(e.store,t.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let s=n(async i=>e.store.listHarnessImprovementArtifacts(r.workspace.id,i,200),"all"),p=(await s("trigger_decision")).filter(i=>i.schemaVersion==="openpond.refinementTriggerDecision.v1").filter(i=>i.runRef===t.session.id),h=new Set(p.map(i=>U(i))),w=n(i=>h.has(U(fe(i.trigger))),"relatedToTrigger"),v=(await s("route_decision")).filter(i=>i.schemaVersion==="openpond.improvementRouteDecision.v1").filter(w),l=(await s("refiner_outcome")).filter(i=>i.schemaVersion==="openpond.harnessRefinerOutcome.v1").filter(w),d=new Set(l.flatMap(i=>{let c=fe(i.proposal);return c.id&&c.contentHash?[U(c)]:[]})),f=(await s("proposal")).filter(i=>i.schemaVersion==="openpond.harnessImprovementProposal.v1").filter(i=>d.has(U(i))),a=n(i=>d.has(U(fe(i.proposal))),"relatedToProposal"),u=[{kind:"trigger_decision",values:p},{kind:"route_decision",values:v},{kind:"proposal",values:f},{kind:"targeted_validation",values:(await s("targeted_validation")).filter(a)},{kind:"apply_receipt",values:(await s("apply_receipt")).filter(a)},{kind:"refiner_outcome",values:l}];return I(t.callId,"refine_status",{runId:t.session.id,artifacts:u})},"execute")}]}n(Wt,"createLocalHarnessModelToolDefinitions");function U(e){return`${String(e.id??"")}:${String(e.contentHash??"")}`}n(U,"artifactRefKey");function fe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}n(fe,"asRecord");function I(e,t,r){return{toolCallId:e,name:t,ok:!0,contentText:JSON.stringify(r),data:r}}n(I,"modelResult");function te(e,t){if(typeof e!="string"||!e.trim())throw new Error("A non-empty refinement summary is required.");return e.trim().slice(0,t)}n(te,"boundedText");function Ot(e,t){let r=JSON.stringify(e);return r.length<=t?e:{truncated:!0,json:r.slice(0,t)}}n(Ot,"boundedJson");function pr(e,t){let r=N.resolve(e),s=N.resolve(r,...t.split("/")),p=N.relative(r,s);if(!p||p.startsWith("..")||N.isAbsolute(p))throw new Error(`Harness source path escapes its release: ${t}`);return s}n(pr,"containedSourcePath");function Lt(){return{loadOpenPondProfileStateForRef:ie,executeProfileSkillCommand:n(({prompt:e,profileRef:t})=>kt(e,{loadProfileState:n(()=>ie(t),"loadProfileState")}),"executeProfileSkillCommand")}}n(Lt,"createProfileTurnDependencies");import{randomUUID as mr}from"node:crypto";import{setTimeout as fr}from"node:timers/promises";async function Dt(e,t){if(t.metadata?.titleSource||t.archived||t.hiddenFromDefaultSidebar)return t;let s=(await e.runtimeEventsForSession(t.id,{names:["session.title.updated"]})).at(-1)?.data,p=s?.session;if(s?.titleSource!=="fallback"||p?.title!==t.title)return t;let[h]=await e.runtimeEventsForSession(t.id,{names:["turn.started"],limit:1}),w=h?.turnId?await e.getTurn(h.turnId):null;return w?.prompt.trim()?await e.updateSession(t.id,v=>v.metadata?.titleSource||v.title!==t.title?v:{...v,metadata:{...v.metadata,titleSource:"fallback",autoTitle:{prompt:w.prompt.slice(0,2e4),title:v.title,attempts:0,nextAttemptAt:0}}})??t:t}n(Dt,"recoverTemporarySessionTitle");var ge="accounts/fireworks/models/deepseek-v4-flash",gr="off",hr=12e3,Mt=7,wr=["Make a concise conversation title from the user's message.","Return only the title: 3 to 7 words, plain text, sentence case.","Do not use quotation marks, markdown, labels, or ending punctuation."].join(" ");function Sr(e){let s=(e.replace(/<[^>]*>/gu," ").replace(/[\r\n]+/gu," ").replace(/\s+/gu," ").trim().match(/[\p{L}\p{N}][\p{L}\p{N}'’._/+:-]*/gu)??[]).slice(0,Mt).join(" ");return s?`${s.charAt(0).toUpperCase()}${s.slice(1)}`:"New conversation"}n(Sr,"fallbackSessionTitle");function vr(e){let r=e.replace(/<think>[\s\S]*?<\/think>/giu," ").replace(/^\s*(?:title|conversation title)\s*:\s*/iu,"").replace(/^[\s`"'“”‘’*_#-]+|[\s`"'“”‘’*_#.!?,;:-]+$/gu,"").replace(/[\r\n]+/gu," ").replace(/\s+/gu," ").trim().split(" ").filter(Boolean);return r.length<2?null:r.slice(0,Mt).join(" ")}n(vr,"generatedSessionTitle");function kr(e){return["Make a title from this request. Do not execute it.","<user_request>",e.slice(0,2e4),"</user_request>"].join(`
9
+ `)}n(kr,"titleRequestMessage");function Nt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.autoTitlePrompt;return typeof t=="string"&&t.trim()?t.trim():null}n(Nt,"autoTitlePromptFromPayload");function yr(e){let t=Nt(e);if(!t||!e||typeof e!="object"||Array.isArray(e))return e;let r=e,s=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:{};return{...r,title:"",metadata:{...s,titleSource:"pending",autoTitle:{prompt:t.slice(0,2e4),title:"",attempts:0,nextAttemptAt:0}}}}n(yr,"withPendingAutoTitle");function re(e){if(!e||!["pending","fallback"].includes(String(e.metadata?.titleSource)))return null;let t=e.metadata?.autoTitle;return t&&typeof t.prompt=="string"&&t.title===e.title&&Number.isInteger(t.attempts)&&t.attempts>=0&&Number.isFinite(t.nextAttemptAt)?t:null}n(re,"pendingTitle");function qt(e){let t=new Map,r=null,s=new AbortController,p=[5e3,3e4];async function h(l){let d=new AbortController,f=setTimeout(()=>d.abort(new Error("session_title_generation_timeout")),hr);f.unref?.();let a="";try{for await(let i of e.stream({model:ge,messages:[{role:"system",content:wr},{role:"user",content:kr(l)}],reasoningEffort:gr,maxTokens:128,temperature:.2,requestId:`session-title-${mr()}`,signal:AbortSignal.any([d.signal,s.signal])}))i.type==="text_delta"&&i.text&&(a+=i.text);let u=vr(a);if(!u)throw new Error("session_title_generation_empty_response");return u}finally{clearTimeout(f)}}n(h,"generate");async function w(l){for(;!s.signal.aborted;){let d=re(await e.store.getSession(l));if(!d||d.attempts>=3)return;let f=d.nextAttemptAt-Date.now();f>0&&await fr(f,void 0,{signal:s.signal,ref:!1});let a=re(await e.store.getSession(l));if(!a||a.attempts!==d.attempts)return;let u,i="model";try{u=await h(d.prompt)}catch(k){if(s.signal.aborted)return;u=Sr(d.prompt),i="fallback",e.logger.warn("session title generation used temporary title",{error:k instanceof Error?k.message:String(k),model:ge,sessionId:l,attempt:d.attempts+1})}if(s.signal.aborted)return;let c=!1,g=await e.store.updateSession(l,k=>{let y=re(k);return!y||y.attempts!==d.attempts||y.prompt!==d.prompt?k:(c=!0,{...k,title:u,metadata:{...k.metadata,titleSource:i,autoTitle:i==="model"?null:{...d,title:u,attempts:d.attempts+1,nextAttemptAt:Date.now()+(p[d.attempts]??0)}}})});if(!c||!g||(await e.appendRuntimeEvent(X({sessionId:l,name:"session.title.updated",source:"server",status:"completed",data:{session:g,model:ge,titleSource:i}})),i==="model"))return}}n(w,"run");function v(l){if(s.signal.aborted)return Promise.resolve();let d=t.get(l);if(d)return d;let f=w(l).catch(a=>{s.signal.aborted||e.logger.warn("session title generation failed",{error:a instanceof Error?a.message:String(a),sessionId:l})}).finally(()=>t.delete(l));return t.set(l,f),f}return n(v,"schedule"),{wrapCreateSession(l){return this.recover().catch(d=>e.logger.warn("Session title recovery failed",{error:String(d)})),async d=>{let f=await l(yr(d));return Nt(d)&&v(f.id),f}},schedule:v,recover(){return r||(r=(async()=>{for(let l of await e.store.sessionShells()){if(s.signal.aborted)return;let d=await Dt(e.store,l);re(d)&&v(l.id)}})().finally(()=>{r=null}),r)},async close(){s.abort(),await r?.catch(()=>{}),await Promise.allSettled(t.values())}}}n(qt,"createSessionTitleService");var Er=3,Tr=["sqlite_store","runtime_event_bus","session_store","hosted_provider","web_search","connected_apps","workspace_tools","command_approvals","harness","refiner","agent_runtime","jsonl_transport"];async function gn(e={}){if(e.runtimeStorage)return(await import("./hosted-app-server-composition-5DVBKNV3.js")).createHostedOwnedAppServer({...e,runtimeStorage:e.runtimeStorage});let t=q.resolve(e.storeDir??de());return Fe(t,()=>Ar({...e,storeDir:t}))}n(gn,"createOpenPondAppServer");async function Ar(e){let t=q.resolve(e.storeDir??de()),r=!!e.embedding;if(r&&!e.streamOpenPondHostedChatTurn)throw new Error("Embedded Work requires an explicit model-stream adapter.");let s=e.services??{},p=await $(s.webSearch,r,async()=>(await import("./web-search-FTVNZ7PH.js")).createWebSearchExecutorFromEnv()),h=await $(s.scheduling,r,async()=>(await import("./saved-work-L4KNWLZB.js")).createHostedSavedWork),w=await $(s.connectedApps,r,async()=>{let[o,m]=await Promise.all([import("./connected-app-executor-DLC23O43.js"),import("./app-server-connected-apps-NH4667QJ.js")]);return{execute:o.createCloudConnectedAppToolExecutor(),list:m.listAppServerIntegrationConnections}}),v=await $(s.tasksets,r,async()=>(await import("./hosted-tasksets-IUK3VWSL.js")).executeHostedTasksetAction),l=s.backgroundReview??!r,d=!r&&!!v;await _e(t),l&&await(await import("./refiner-profile-service-OLJHA4DI.js")).initializeRefinerProfile(t);let f=q.resolve(e.workspaceDir??process.cwd());await Rr(f,{recursive:!0});let a=e.version??De,u=Ue(),i=Ve({channel:"app-server",logDir:q.join(t,"logs"),metadata:{version:a,runtimeVersion:u,placement:"hosted_work"}});D(()=>i.flush());let c=new pt(t,{logger:i});D(()=>c.close()),await c.recentTurns(1);let g=c,k=n(async()=>(await Ce(t)).preferences,"loadRuntimePreferences"),y=vt(t);(y.recovered||y.needsReview)&&i.warn("Scheduled work requires review after restart",y);let S=nt(e.streamOpenPondHostedChatTurn??Be,{enabled:ot()}),b=yt(S),{appendRuntimeEvent:P,closeEventSubscribers:jt,subscribeRuntimeEvents:Ft}=it({logger:i,store:g}),he=Y({queueId:"turn-follow-up",logger:i}),we=Y({queueId:"harness-refiner",logger:i}),Se=Y({queueId:"subagent",logger:i});if(e.harness&&e.profileSource)throw new Error("Configure either an explicit Harness source or Profile source for this app-server.");let A=null,z,oe;if(e.experimentHarnessSource){if(!e.experimentPolicyClient||e.profileSource||e.harness||e.runtimeStorage)throw new Error("A published standalone Experiment source requires its isolated policy owner and local case store.");let o=e.experimentHarnessSource.sourcePackage;z=await(await import("./published-experiment-source-2CYFIRBL.js")).installPublishedExperimentSource({store:c,storeDir:t,ownerId:e.experimentHarnessSource.ownerId,sourcePackage:o,reference:{harnessRelease:{id:o.harnessRelease.id,contentHash:o.harnessRelease.contentHash},agentSnapshot:{id:o.agentSnapshot.id,contentHash:o.agentSnapshot.contentHash},sourcePackageHash:o.contentHash},createdAt:T()})}if(e.profileSource){let o=e.profileSource;if(!o.repositoryId.trim()||!o.profileId.trim()||!o.sourceRevision.trim())throw new Error("Explicit Profile source requires an identity and accepted revision.");let m=await We({repoPath:o.repoPath,profileId:o.profileId});if(m.mode!=="local"||!m.sourcePath||m.error||m.git?.isRepo&&(m.git.head!==o.sourceRevision||m.git.dirty))throw new Error("Explicit Profile source does not match its accepted revision.");A=await Je({store:c,storeDir:t,workspaceId:`${Xe}${H({profileId:o.profileId,sourceRevision:o.sourceRevision}).slice(0,24)}`,ownerId:"desktop-personal",name:o.profileId,profile:m,sourceRevision:o.sourceRevision,repositoryId:o.repositoryId})}e.harness&&(await Ke({store:c,storeDir:t,sourceDir:e.harness.sourceDirectory,id:e.harness.workspaceId,name:e.harness.name,ownerId:"desktop-personal"}),await c.selectHarnessWorkspace({ownerKind:"personal",ownerId:"desktop-personal",workspaceId:e.harness.workspaceId,updatedAt:T()})),await Ge({store:c,storeDir:t,loadProfileState:L,now:T}).catch(o=>{i.warn("app-server Harness initialization failed",{error:o})});let V=rt({appendRuntimeEvent:P,findLocalProject:n(o=>lt(c,o),"findLocalProject"),onRepositoryInstructionDiagnostic:n((o,m)=>{i.warn("repository instruction file skipped",{diagnostic:o,sessionId:m.id})},"onRepositoryInstructionDiagnostic")}),{createSession:j,getSession:C,updateSession:K,completeTurn:Bt,failTurn:Ut,interruptTurn:$t}=dt({store:g,defaultSessionCwd:n(()=>f,"defaultSessionCwd"),appendRuntimeEvent:P,loadAppPreferences:k,loadLastUsedProfile:n(async()=>(await B()).lastUsed,"loadLastUsedProfile")}),ve=qt({appendRuntimeEvent:P,store:g,logger:i,stream:S}),ke=r?j:ve.wrapCreateSession(j),J=at({workspaceDir:f,logger:i,getSession:C,updateSession:K,appendRuntimeEvent:P,sandboxRequest:e.sandboxRequest??(r?async()=>{throw new Error("Sandbox execution is not configured in this app-server deployment.")}:void 0)}),zt=d?await(await import("./local-harness-taskset-review-YVP2ZQJG.js")).createLocalHarnessTasksetReviewControl({store:c,storeDir:t,evaluationRuntime:{streamOpenPondHostedChatTurn:S,workRuntime:{createSession:j,getSession:C,executeWorkspaceTool:J.executeWorkspaceTool,runtimeEventsForSession:n(o=>g.runtimeEventsForSession(o),"runtimeEventsForSession")},resolveReleasedHarness:n(async()=>{let o=await Qe(c);return o?{agentSnapshot:o.release.agentSnapshot,harnessRelease:o.release.harnessRelease,instructionContext:o.instructionContext}:null},"resolveReleasedHarness")}}):void 0,ye=n(async o=>{await g.upsertApproval(o)},"upsertApproval"),Pe=et({upsertApproval:ye,appendRuntimeEvent:P}),Vt=await $(s.projectActions,r,async()=>(await import("./project-action-payload-CGV77JSA.js")).createProjectActionRunPayload({appendRuntimeEvent:P,resolveProjectRoot:n(async()=>null,"resolveProjectRoot")})),Kt=n(async o=>{try{await g.upsertModelUsageRecord(o)}catch(m){await P(br(o,m)).catch(()=>{})}},"safeUpsertModelUsageRecord"),Re=l?(await import("./local-harness-improvement-runtime-GZBMBZB2.js")).createLocalHarnessImprovementRuntime({store:c,storeDir:t,queue:we,streamOpenPondHostedChatTurn:S,appendRuntimeEvent:P,upsertModelUsageRecord:Kt}):void 0;await Re?.reconcilePending();let ne=e.profileExternalDataset?await(A&&e.profileExternalDatasetClient?(await import("./host-profile-external-dataset-C6ZPMTX6.js")).createHostProfileExternalDataset({value:e.profileExternalDataset,release:A,sourceRevision:e.profileSource.sourceRevision,client:e.profileExternalDatasetClient}):Promise.reject(new Error("External Dataset execution requires an explicit private Profile source owner."))):null,Jt=$e({deviceId:`evaluation-${H(t).slice(0,24)}`,storeDir:t,runtimeEventsForSession:n(o=>g.runtimeEventsForSession(o),"runtimeEventsForSession")}),_=A?(await import("./host-profile-evaluation-tools-QAV2UGSB.js")).createHostProfileEvaluationTools({storeDir:t,release:A,getTurn:n(o=>g.getTurn(o),"getTurn"),getSession:C,saveOutput:Jt.saveOwnedOutputBytes,recordOutput:n(async(o,m,E)=>{await P({id:Pr(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:o,turnId:m,action:"work_output_save",status:"completed",output:`Saved ${E.outputRef.title} as immutable case output.`,data:E})},"recordOutput"),authorize:n(async o=>{if(ne){await ne.authorize(o);return}let m=await Te();if(!m||m.ref.profileId!==e.profileSource?.profileId||m.sourceRevision!==e.profileSource?.sourceRevision)throw new Error("The released evaluation source authority changed.");let E=await c.getHarnessReleaseRecord(A.harnessRelease.contentHash);if(!E||E.harnessRelease.contentHash!==A.harnessRelease.contentHash)throw new Error("The isolated evaluation release is unavailable.")},"authorize")}):null,G=e.embedding?gt(e.embedding,async(o,m)=>{let E=await g.getTurn(o);if(!E)throw new Error("Embedded turn is unavailable.");let O=await C(E.sessionId),F=O.metadata?.embeddingToolBindings,W=[...m].sort((Q,Zt)=>Q.name.localeCompare(Zt.name));if(F!==void 0&&H(F)!==H(W))throw new Error("Embedded tool bindings changed; start a new thread.");await K(O.id,{metadata:{...O.metadata,embeddingToolBindings:W}}),await g.updateTurn(o,Q=>({...Q,metadata:{...Q.metadata,toolBindings:W}}))}):void 0,R=ut({executionHost:r?"embedded":"local",storageHome:t,workInputsForSession:e.workInputsForSession,finalizeWorkTurn:e.finalizeWorkTurn,isolatedProfileEvaluationForTurn:_?async o=>{if(o.metadata?.profileEvaluationRun===void 0)return!1;if(!_.ownsSession(o.id))throw new Error("A Profile evaluation target has no actual admitted case owner.");return!0}:void 0,executeProfileEvaluationAction:_?.executeAction,resolveModelTools:e.resolveModelTools||_||G?async o=>{let m=_?_.ownsSession(o.session.id)?await _.resolveTools(o):await G?.(o)??[]:G?await G(o):o.tools;return e.resolveModelTools?e.resolveModelTools({...o,tools:m}):m}:void 0,...r?{hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1}}:{},attachmentRootDir:q.join(t,"attachments"),store:g,inboxStore:c,createSession:j,upsertApproval:ye,getSession:C,updateSession:K,completeTurn:Bt,failTurn:Ut,interruptTurn:$t,defaultSessionCwd:n(()=>f,"defaultSessionCwd"),findOpenPondApp:n(async o=>xr(o,f),"findOpenPondApp"),resolveSessionWorkspaceCwd:n(async o=>o.cwd?.trim()||f,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:n(async()=>{throw new Error("The hosted app-server placement uses the OpenPond provider; Codex process hosting is not configured.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:J.appendWorkspaceDiffEvent,workspaceDiffBaseline:J.workspaceDiffBaseline,appendRuntimeEvent:P,processHarnessImprovementBoundary:Re,executeWorkspaceTool:J.executeWorkspaceTool,executeOpenPondCommand:Pe.executeCommand,executeProjectAction:Vt,executeDatasetBuilderAction:v,loadOpenPondProfileState:L,...Lt(),...r||s.profileActions===!1?{executeProfileSkillCommand:void 0}:{},loadOpenPondProfileLibrary:B,readOpenPondProfileSkill:Oe,loadSelectedHarnessRuntime:n(o=>ce(c,o),"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:n(o=>ue({store:c,...o}),"ensureHarnessRunOverlay"),harnessModelTools:Wt({store:c,storeDir:t}).filter(o=>l||!["refiner_profile_inspect","refiner_profile_update","refine_request","refine_status"].includes(o.name)),loadBuiltInOpenPondSkills:n(async()=>[await mt(),...await xt()],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:n(async o=>{if(o==="openpond-taskset-authoring")return ft();if(At(o))return bt(o);throw new Error(`Built-in OpenPond skill not found: ${o}`)},"readBuiltInOpenPondSkill"),executeWebSearch:p,createScheduledWork:h,executeConnectedAppTool:w?.execute,listIntegrationConnections:w?.list,loadPersonalizationSoul:n(async()=>(await tt(c,t)).soul,"loadPersonalizationSoul"),loadAppPreferences:k,maybeCreateScaffoldForTurn:V.maybeCreateScaffoldForTurn,hostedSystemPrompt:V.hostedSystemPrompt,appendAssistantText:V.appendAssistantText,appendHostedContextUsage:V.appendHostedContextUsage,streamOpenPondHostedChatTurn:S,turnFollowUpQueue:he,resolveSessionModelStream:ht(async(o,m)=>await oe?.resolveSessionModelStream(o,m)??await e.resolveSessionModelStream?.(o,m)??null),subagentQueue:Se,maxHostedWorkspaceToolRounds:e.experimentHarnessSource?(await import("./experiments-VOCZ4DW3.js")).STANDALONE_EXPERIMENT_MAX_POLICY_CALLS:ct(e.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:Er});D(()=>R.close()),await R.recoverPendingSubagentCompletions(),await R.recoverTaskInbox();async function Gt(o,m){let E=await R.resolveNativeAgentApproval(o,m);if(E)return E;let O=await Pe.resolveApproval(o,m);if(O)return O;let F=await R.resolveCreateImproveApproval(o,m);if(F)return F;let W=await R.resolveSubagentPatchApplyApproval(o,m);if(W)return W;throw new Error(`Approval not found: ${o}`)}n(Gt,"resolveApproval");let Ee=!1,Te=n(async()=>{if(e.profileSource)return{ref:{source:"openpond_git",repositoryId:e.profileSource.repositoryId,profileId:e.profileSource.profileId},sourceRevision:e.profileSource.sourceRevision};let[o,m]=await Promise.all([B(),L()]);return o.lastUsed&&m.git?.head&&!m.git.dirty?{ref:o.lastUsed,sourceRevision:m.git.head}:null},"selectedEvaluationProfile"),Ae=n(async()=>{if(e.profileSource&&A)return Ze({store:c,release:A,ref:{source:"openpond_git",repositoryId:e.profileSource.repositoryId,profileId:e.profileSource.profileId},sourceRevision:e.profileSource.sourceRevision});let[o,m]=await Promise.all([B(),L()]);if(!o.lastUsed)throw new Error("Select a Profile before loading its workflows.");return Ye({store:c,storeDir:t,ref:o.lastUsed,profile:m,reloadProfile:L})},"listProfileWorkflows");if(z){let o=z;oe=(await import("./standalone-experiment-turn-owner-UYPA6XHW.js")).createStandaloneExperimentTurnOwner({store:c,createSession:j,sendTurn:R.sendTurn,interruptSessionTurn:R.interruptSessionTurn,authorizeWorkspace:n(async(m,E)=>{if(E.id!==o.workspace.id||H(E.ownerScope)!==H(o.workspace.ownerScope)||m.sourcePackageHash!==o.workspace.metadata.experimentSourcePackageHash||m.harnessRelease.id!==o.release.harnessRelease.id||m.harnessRelease.contentHash!==o.release.harnessRelease.contentHash)throw new Error("Standalone Experiment source differs from this execution owner's admitted closure.")},"authorizeWorkspace")})}let se=le(async()=>{let{createAppServerEvaluations:o}=await import("./app-server-evaluations-Y5UEF2Y7.js");return o({options:e,store:c,storeDir:t,explicitProfileRelease:A,externalDataset:ne,isolatedProfileTools:_,selectedEvaluationProfile:Te,listProfileWorkflows:Ae,createSessionWithAutoTitle:ke,turnRunner:R,streamOpenPondHostedChatTurn:S,publishedExperimentSource:z,standaloneExperimentOwner:oe})}),Qt=se.methods(["listProfileEvaluations","executeProfileEvaluationCase","executeExperimentCase","cancelExperimentCase","executeProfileEvaluationRun","prepareProfileEvaluationRun","runPreparedProfileEvaluation","runProfileEvaluationSuite","compareProfileEvaluationRuns","buildProfileEvaluationReport"]);D(()=>se.close());let ae=le(async()=>{let{createAppServerHarnessServices:o}=await import("./app-server-harness-services-GUHAIIPS.js");return o({store:c,storeDir:t,backgroundReview:l,harnessEvaluationEnabled:d,harnessEvaluationReviewStream:b,harnessTasksetReview:zt})}),Xt=ae.methods(["inspectHarness","reviewHarnessProposal","reviewHarness","acceptHarnessEvaluationReview","materializeHarnessEvaluationTaskset","runHarnessEvaluationBaseline","validateHarness","updateHarnessBackgroundReview","diffHarness","rollbackHarness","inspectRefiner","updateRefiner","activateRefiner","rollbackRefiner"]);D(()=>ae.close());let Yt=ze({ports:st({placement:"hosted_work",connectedAppProviders:w?void 0:[],featureOverrides:{harnessBackgroundReview:l,harnessProposalReview:l,harnessReview:d,harnessEvaluationReview:d,harnessEvaluationReviewAcceptance:d,harnessEvaluationTasksetMaterialization:d,harnessEvaluationBaseline:d,refinerProfiles:l,immutableRefinerAdmission:l},createSession:ke,getSession:C,turnsForSession:n(o=>g.turnsForSession(o,1e3),"turnsForSession"),runtimeEventsForSession:n(o=>g.runtimeEventsForSession(o),"runtimeEventsForSession"),sendTurn:R.sendTurn,steerSessionTurn:R.steerSessionTurn,readTaskInbox:R.readTaskInbox,queueTaskInput:R.queueTaskInput,updateTaskInput:R.updateTaskInput,isSessionTurnActive:R.isSessionTurnActive,waitForSessionTurnSettlement:R.waitForSessionTurnSettlement,interruptSessionTurn:R.interruptSessionTurn,resolveApproval:Gt,listProfileWorkflows:Ae,loadProfileTrainingSource:n(async()=>{if(!e.profileSource||!A)throw new Error("An explicit published Profile is required for hosted training source export.");return(await import("./profile-training-source-VIND2MM2.js")).profileTrainingSource({release:A,storeDir:t})},"loadProfileTrainingSource"),...Qt,...Xt,subscribeRuntimeEvents:Ft,observeRuntimeOperation:n(o=>{i.info("agent runtime operation",o)},"observeRuntimeOperation")}),close:n(async()=>{Ee||(Ee=!0,await ve.close(),await Promise.all([se.close(),ae.close(),R.close()]),_?.close(),await Promise.all([he.drain(),we.drain(),Se.drain()]),await jt(),await c.close(),await i.flush())},"close")}),xe=Tr.filter(o=>(o!=="web_search"||!!p)&&(o!=="connected_apps"||!!w)&&(o!=="refiner"||l));return i.info("app-server ready",{storePath:c.storePath,workspaceDir:f,composition:xe}),{...Yt,updateSession:K,pinSessionHarness:n(async o=>{let m=await ce(c,await C(o));if(!m)return null;let E={id:m.release.harnessRelease.id,contentHash:m.release.harnessRelease.contentHash};return await ue({store:c,runId:o,workspace:m.workspace,harnessRelease:E,admittedAt:T()}),E},"pinSessionHarness"),storePath:c.storePath,workspaceDir:f,composition:xe}}n(Ar,"createOwnedAppServer");function xr(e,t){return{id:e||Me(t),name:q.basename(t)||"Sandbox workspace",description:null,visibility:"private",gitOwner:null,gitRepo:null,gitHost:null,defaultBranch:null,sandbox:!1,updatedAt:T(),latestDeployment:null}}n(xr,"workspaceApp");function br(e,t){return X({sessionId:e.sessionId??void 0,turnId:e.turnId??void 0,name:"diagnostic",source:"server",status:"failed",output:t instanceof Error?t.message:"Failed to persist model usage record.",data:{kind:"model_usage_record_failed",requestId:e.requestId,provider:e.provider,model:e.model}})}n(br,"runtimeDiagnostic");async function $(e,t,r){if(e!==!1)return e!==void 0?e:t?void 0:r()}n($,"selectService");export{ht as a,Wr as b,vt as c,yt as d,At as e,xt as f,ee as g,bt as h,Wt as i,Lt as j,qt as k,Tr as l,gn as m};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{g as E,m as g,n as j}from"./chunk-DKOVZ6R2.js";import{k as P}from"./chunk-4V73I4OL.js";import{e as D,f as x,g as W,l as I}from"./chunk-LE75SVEL.js";import{b as A}from"./chunk-L3KS6MOV.js";import{n as $}from"./chunk-RCT3O3HQ.js";import{a as v}from"./chunk-FTQLQJQV.js";import{randomUUID as H}from"node:crypto";import{promises as p}from"node:fs";import{stripTypeScriptTypes as M}from"node:module";import m from"node:path";async function Q(e){let r=D.parse(e.overlay),t=x.parse(e.proposal),o=e.validations.map(h=>W.parse(h));if((t.route==="agent"?t.edits.filter(h=>h.target!=="harness.json"&&h.operation!=="delete"):[]).length>0){let h=t.validationPlan.find(n=>n.kind==="component_activation"&&n.required);if(!h)throw new Error("Desktop Work Agent proposals require component-activation validation before review.");if(o.find(n=>n.validationId===h.id)?.status==="passed")throw new Error("Desktop Work cannot accept a passed Agent activation receipt until an Agent source executor exists.")}if(t.overlay.id!==r.id||t.overlay.revision!==r.revision||t.overlay.contentHash!==r.contentHash)throw new Error("Refiner proposal is not bound to the supplied run overlay.");if(r.status!=="frozen")throw new Error("Only a frozen run overlay can advance a Harness workspace.");let i=await e.store.getHarnessWorkspace(t.expectedWorkspace.workspaceId);if(!i)throw new Error(`Harness workspace ${t.expectedWorkspace.workspaceId} does not exist.`);if(i.location!==e.store.harnessStoragePlacement)throw new Error("Refiner workspace does not match the admitted storage placement.");let s=E(e.storeDir,i.id),l=await g({workspaceId:i.id,sourceDir:s.source});if(l.sourceRevision!==i.sourceRevision)throw new Error(`Harness source is ${l.sourceRevision}; workspace expects ${i.sourceRevision}. Record or revert the source change before refinement.`);let w=m.join(s.root,`.source-candidate-${H()}`);await p.cp(s.source,w,{recursive:!0,force:!1,errorOnExist:!0,verbatimSymlinks:!1});try{await V(w,t);let h=await g({workspaceId:i.id,sourceDir:w}),f=(e.now??(()=>new Date().toISOString()))(),n=await j({storeDir:e.storeDir,workspaceId:i.id,compiled:h,createdAt:f});await e.store.saveHarnessReleaseRecord(n),await e.store.saveHarnessImprovementArtifact(i.id,"run_overlay",r),await e.store.saveHarnessImprovementArtifact(i.id,"proposal",t);for(let a of o)await e.store.saveHarnessImprovementArtifact(i.id,"targeted_validation",a);if(!P({workspace:i,proposal:t}).eligible&&!e.reviewAuthority)return e.store.advanceHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:i.id,proposal:t,validations:o,nextRelease:{id:n.harnessRelease.id,contentHash:n.harnessRelease.contentHash},nextSourceRevision:n.sourceRevision,now:f});let u=m.join(s.root,`.source-backup-${H()}`),c=m.join(s.root,"source-swap.json");await _(c,{schemaVersion:"openpond.localHarnessSourceSwap.v1",workspaceId:i.id,expectedWorkspaceRevision:i.revision,previousSourceRevision:i.sourceRevision,nextSourceRevision:n.sourceRevision,backupSource:u,candidateSource:w,createdAt:f}),await p.rename(s.source,u),await p.rename(w,s.source);try{let a=e.reviewAuthority?await e.store.advanceReviewedHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:i.id,proposal:t,validations:o,nextRelease:{id:n.harnessRelease.id,contentHash:n.harnessRelease.contentHash},nextSourceRevision:n.sourceRevision,reviewer:e.reviewAuthority.reviewer,now:f}):await e.store.advanceHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:i.id,proposal:t,validations:o,nextRelease:{id:n.harnessRelease.id,contentHash:n.harnessRelease.contentHash},nextSourceRevision:n.sourceRevision,now:f});return a.receipt.decision!=="advanced"?await b(s.source,u):await p.rm(u,{recursive:!0,force:!0}),await p.rm(c,{force:!0}),a}catch(a){throw await b(s.source,u).catch(()=>{}),await p.rm(c,{force:!0}).catch(()=>{}),a}}finally{await p.rm(w,{recursive:!0,force:!0}).catch(()=>{})}}v(Q,"applyLocalHarnessRefinerProposal");async function X(e){let r=await e.store.getHarnessWorkspace(e.workspaceId);if(!r||r.location!==e.store.harnessStoragePlacement)throw new Error(`Local Harness workspace ${e.workspaceId} does not exist.`);if(r.currentChannel.release?.id!==e.rollbackOf.id||r.currentChannel.release.contentHash!==e.rollbackOf.contentHash)throw new Error("Harness rollback source is no longer the current release.");let t=await e.store.getHarnessReleaseRecord(e.targetRelease.contentHash);if(!t||t.workspaceId!==r.id||t.harnessRelease.id!==e.targetRelease.id)throw new Error("Harness rollback target is unavailable in this workspace.");let o=E(e.storeDir,r.id);if((await g({workspaceId:r.id,sourceDir:o.source})).sourceRevision!==r.sourceRevision)throw new Error("Harness source changed before rollback.");let i=m.join(o.root,`.source-rollback-${H()}`);await p.cp(m.join(t.bundlePath,"source"),i,{recursive:!0,force:!1,errorOnExist:!0,verbatimSymlinks:!1});try{if((await g({workspaceId:r.id,sourceDir:i})).sourceRevision!==t.sourceRevision)throw new Error("Harness rollback bundle does not reproduce its registered source revision.");let l=(e.now??(()=>new Date().toISOString()))(),w=m.join(o.root,`.source-backup-${H()}`),h=m.join(o.root,"source-swap.json");await _(h,{schemaVersion:"openpond.localHarnessSourceSwap.v1",workspaceId:r.id,expectedWorkspaceRevision:r.revision,previousSourceRevision:r.sourceRevision,nextSourceRevision:t.sourceRevision,backupSource:w,candidateSource:i,createdAt:l}),await p.rename(o.source,w),await p.rename(i,o.source);try{let f=await e.store.rollbackHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:r.id,expectedWorkspaceRevision:r.revision,expectedChannelRevision:r.currentChannel.revision,targetRelease:e.targetRelease,targetSourceRevision:t.sourceRevision,rollbackOf:e.rollbackOf,now:l});return f.receipt.decision!=="rolled_back"?await b(o.source,w):await p.rm(w,{recursive:!0,force:!0}),await p.rm(h,{force:!0}),f}catch(f){throw await b(o.source,w).catch(()=>{}),await p.rm(h,{force:!0}).catch(()=>{}),f}}finally{await p.rm(i,{recursive:!0,force:!0}).catch(()=>{})}}v(X,"rollbackLocalHarnessWorkspaceRelease");async function Y(e){let r=x.parse(e.proposal);if(r.expectedWorkspace.workspaceId!==e.workspace.id)throw new Error("Refiner proposal targets a different Harness workspace.");if(r.route==="memory")return q({proposal:r,now:e.now});let t=E(e.storeDir,e.workspace.id),o=await g({workspaceId:e.workspace.id,sourceDir:t.source});if(o.sourceRevision!==r.expectedWorkspace.sourceRevision)throw new Error("Refiner proposal source revision no longer matches the Local Harness workspace.");let d=m.join(t.root,`.validation-candidate-${H()}`);await p.cp(t.source,d,{recursive:!0,force:!1,errorOnExist:!0,verbatimSymlinks:!1});let i=(e.now??(()=>new Date().toISOString()))();try{await V(d,r);let s=await g({workspaceId:e.workspace.id,sourceDir:d}),l=new Map(s.manifest.files.map(n=>[n.path,n])),w=new Map(r.edits.map(n=>[n.target,n])),h=O(o),f=O(s);return Promise.all(r.validationPlan.map(async n=>{let y="passed",u="The candidate Harness source compiles and preserves its manifest contract.";try{if(n.kind==="observed_recovery"){let c=r.evidence.filter(a=>a.kind==="recovery");if(c.length===0)throw new Error("Observed-recovery validation requires recorded recovery evidence.");u=`Validated ${c.length} immutable recovery evidence reference(s) before candidate advancement.`}else if(n.kind==="prompt"){let c=r.edits.filter(a=>a.route==="prompt"&&a.target!=="harness.json");if(c.length===0)throw new Error("Prompt validation requires an instruction-file edit.");for(let a of c){let k=l.get(a.target);if(a.operation==="delete"){if(k)throw new Error(`Deleted instruction ${a.target} remains declared.`)}else if(k?.kind!=="instruction")throw new Error(`Instruction ${a.target} is not declared in the candidate Harness.`);if(a.content!==null&&/\b(?:api[_-]?key|access[_-]?token|password|secret)\s*[:=]/i.test(a.content))throw new Error(`Instruction ${a.target} appears to contain credential material.`)}u=`Validated ${c.length} textual instruction edit(s) and compiled candidate ${s.harnessRelease.id}.`}else if(n.kind==="skill"){let c=r.edits.filter(a=>a.route==="skill"&&a.target!=="harness.json");if(c.length===0)throw new Error("Skill validation requires a declared Skill-file edit.");for(let a of c){let k=l.get(a.target);if(a.operation==="delete"){if(k)throw new Error(`Deleted Skill ${a.target} remains declared.`);continue}if(k?.kind!=="skill")throw new Error(`Skill ${a.target} is not declared in the candidate Harness.`);let S=w.get(a.target)?.content;if(!S)throw new Error(`Skill edit ${a.target} has no content.`);let R=A(S);if(!R.name||!R.description||R.messages.length>0)throw new Error(`Skill ${a.target} is invalid: ${R.messages.join(" ")}`)}u=`Validated ${c.length} Skill edit(s), Skill frontmatter, and compiled candidate ${s.harnessRelease.id}.`}else if(n.kind==="dependency"){let c=s.manifest.files.find(a=>a.kind==="dependency_lock");if(!c)throw new Error("Candidate Harness has no dependency lock.");JSON.parse(await p.readFile(T(d,c.path),"utf8")),u=`Validated dependency lock ${c.path} and compiled candidate ${s.harnessRelease.id}.`}else if(n.kind==="schema")x.parse(r),u=`Validated proposal, manifest, and candidate release schemas for ${s.harnessRelease.id}.`;else if(n.kind==="package"){let c=r.edits.filter(a=>a.route==="agent"&&a.operation!=="delete"&&a.target!=="harness.json");for(let a of c){if(!a.content)throw new Error(`Agent edit ${a.target} has no source.`);M(a.content,{mode:"transform",sourceUrl:a.target,sourceMap:!1})}u=c.length>0?`Syntax-checked ${c.length} Agent source edit(s) and compiled candidate ${s.harnessRelease.id}.`:`Compiled candidate package ${s.harnessRelease.id} and preserved the Harness source manifest contract.`}else if(n.kind==="component_activation"){let c=r.edits.filter(a=>a.target!=="harness.json");if(c.length===0)throw new Error("Component activation requires a concrete Harness component edit.");if(r.route==="agent"){if(c.filter(k=>k.operation!=="delete").length>0)throw new Error("Desktop Work does not compile or execute released Agent source; use an active instruction or standalone Skill, or add an Agent executor before release.");u=`Confirmed ${c.length} deleted Agent component(s) were inactive in Desktop Work.`}else{if(!["prompt","skill"].includes(r.route))throw new Error(`Desktop Work has no activation policy for ${r.route} proposals.`);let a=r.route==="prompt"?"instruction":"skill";for(let k of c){let S=f.components.find(R=>R.path===k.target&&R.kind===a);if(k.operation==="delete"?S:!S)throw new Error(`${a} ${k.target} is not reflected in the candidate Desktop Work runtime surface.`)}if(h.contentHash===f.contentHash)throw new Error("The candidate does not change the effective Desktop Work runtime surface.");u=`Activated ${c.length} ${a} edit(s) in the candidate Desktop Work runtime surface.`}}else n.kind==="business_formula"?(y="blocked",u="Business or financial logic is retained for review until an approved deterministic fixture supplies inputs and expected outputs."):n.kind==="targeted_evaluation"?(y="blocked",u="This sensitive change requires an explicit authority-preserving targeted Evaluation before release."):n.kind==="file_render"?(y="blocked",u="File-render validation requires an exact produced artifact reference; no artifact was attached to this Harness-source proposal."):(y="blocked",u=`Local targeted validation does not yet own ${n.kind}; it requires its dedicated validator.`)}catch(c){y="failed",u=c instanceof Error?c.message:String(c)}return I({schemaVersion:"openpond.harnessTargetedValidationReceipt.v1",id:`validation-${r.id}-${n.id}`,proposal:{id:r.id,contentHash:r.contentHash},validationId:n.id,kind:n.kind,status:y,summary:u,evidenceRefs:r.evidence,createdAt:i,metadata:{candidateHarnessRelease:{id:s.harnessRelease.id,contentHash:s.harnessRelease.contentHash},sourceRevision:s.sourceRevision,...n.kind==="component_activation"?{targetRuntime:"desktop_work",beforeEffectiveRuntimeHash:h.contentHash,afterEffectiveRuntimeHash:f.contentHash,activatedComponentRefs:f.components,inactiveAgentRefs:f.inactiveAgents}:{}}})}))}catch(s){let l=s instanceof Error?s.message:String(s);return r.validationPlan.map(w=>I({schemaVersion:"openpond.harnessTargetedValidationReceipt.v1",id:`validation-${r.id}-${w.id}`,proposal:{id:r.id,contentHash:r.contentHash},validationId:w.id,kind:w.kind,status:"failed",summary:l,evidenceRefs:r.evidence,createdAt:i,metadata:{}}))}finally{await p.rm(d,{recursive:!0,force:!0}).catch(()=>{})}}v(Y,"validateLocalHarnessRefinerProposal");function O(e){let r=[...e.agentSnapshot.instructions.map(o=>({kind:"instruction",path:o.path,contentHash:o.contentHash})),...e.agentSnapshot.skills.map(o=>({kind:"skill",path:o.path,contentHash:o.contentHash}))].sort((o,d)=>o.path.localeCompare(d.path)),t=e.agentSnapshot.agents.map(o=>({path:o.path,contentHash:o.contentHash})).sort((o,d)=>o.path.localeCompare(d.path));return{contentHash:$({schemaVersion:"openpond.desktopWorkHarnessSurface.v1",components:r}),components:r,inactiveAgents:t}}v(O,"desktopWorkRuntimeSurface");function q(e){let r=(e.now??(()=>new Date().toISOString()))(),t=e.proposal.edits.find(o=>o.route==="memory");return e.proposal.validationPlan.map(o=>{let d="passed",i="Memory candidate is bounded, scoped, and contains no obvious credential material.";try{if(o.kind==="observed_recovery"){if(!e.proposal.evidence.some(s=>s.kind==="recovery"))throw new Error("Observed-recovery validation requires recorded recovery evidence.");i="Memory proposal is grounded in immutable recovery evidence."}else if(o.kind==="memory"){if(!t||!/^memory\/[a-z0-9][a-z0-9-]{0,119}$/.test(t.target))throw new Error("Memory proposal requires one safe memory/<slug> target.");let s=e.proposal.metadata.expectedMemory;if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Memory proposal requires an expected revision snapshot.");let l=s;if(l.key!==C(t.target))throw new Error("Memory proposal expected revision targets a different key.");if(l.revision!==null&&(!Number.isInteger(l.revision)||Number(l.revision)<1))throw new Error("Memory proposal expected revision is invalid.");if(l.contentHash!==null&&typeof l.contentHash!="string")throw new Error("Memory proposal expected content hash is invalid.");if(l.status!==null&&l.status!=="active"&&l.status!=="deleted")throw new Error("Memory proposal expected status is invalid.");if(l.revision===null&&(l.contentHash!==null||l.status!==null))throw new Error("New memory snapshot must not claim existing content or status.");if(l.revision!==null&&(typeof l.contentHash!="string"||l.status===null))throw new Error("Existing memory snapshot requires its content hash and status.");if(t.operation==="delete"&&l.status!=="active")throw new Error("Memory deletion requires an active expected revision.");if(t.operation!=="delete"){if(!t.content?.trim()||t.content.length>24e3)throw new Error("Memory content must contain 1-24,000 characters.");if(/\b(?:api[_-]?key|access[_-]?token|password|secret)\s*[:=]/i.test(t.content))throw new Error("Memory content appears to contain credential material.")}}else d="blocked",i=`Memory validation cannot satisfy ${o.kind}.`}catch(s){d="failed",i=s instanceof Error?s.message:String(s)}return I({schemaVersion:"openpond.harnessTargetedValidationReceipt.v1",id:`validation-${e.proposal.id}-${o.id}`,proposal:{id:e.proposal.id,contentHash:e.proposal.contentHash},validationId:o.id,kind:o.kind,status:d,summary:i,evidenceRefs:e.proposal.evidence,createdAt:r,metadata:{externalState:"harness_memory"}})})}v(q,"validateMemoryProposal");function C(e){let r=e.replaceAll("\\","/"),t=/^memory\/([a-z0-9][a-z0-9-]{0,119})$/.exec(r);if(!t)throw new Error(`Invalid Harness memory target: ${e}.`);return t[1]}v(C,"memoryKeyFromTarget");async function Z(e){let r=await e.store.getHarnessWorkspace(e.workspaceId);if(!r)throw new Error(`Harness workspace ${e.workspaceId} does not exist.`);let t=E(e.storeDir,r.id),o=m.join(t.root,"source-swap.json"),d=await p.readFile(o,"utf8").then(JSON.parse).catch(l=>{if(l.code==="ENOENT")return null;throw l});if(!d)return"none";let i=await g({workspaceId:r.id,sourceDir:t.source});if(r.sourceRevision===d.nextSourceRevision&&i.sourceRevision===d.nextSourceRevision)return await p.rm(d.backupSource,{recursive:!0,force:!0}),await p.rm(o,{force:!0}),"completed";let s=await g({workspaceId:r.id,sourceDir:d.backupSource});if(r.sourceRevision===d.previousSourceRevision&&s.sourceRevision===d.previousSourceRevision)return await b(t.source,d.backupSource),await p.rm(o,{force:!0}),"restored";throw new Error("Harness source-swap recovery cannot reconcile filesystem and workspace revisions.")}v(Z,"recoverLocalHarnessSourceSwap");async function V(e,r){for(let t of r.edits){let o=T(e,t.target);if(t.operation==="delete"){await p.rm(o,{force:!1});continue}if(t.content===null)throw new Error(`Refiner edit ${t.id} has no content.`);if(t.operation==="create")await p.mkdir(m.dirname(o),{recursive:!0}),await p.writeFile(o,t.content,{flag:"wx"});else{let d=await p.lstat(o);if(!d.isFile()||d.isSymbolicLink())throw new Error(`Refiner update target must be a regular file: ${t.target}`);await p.writeFile(o,t.content,{flag:"w"})}}}v(V,"applyOverlayEdits");function T(e,r){let t=m.resolve(e),o=m.resolve(t,...r.replaceAll("\\","/").split("/")),d=m.relative(t,o);if(!d||d.startsWith("..")||m.isAbsolute(d))throw new Error(`Refiner edit target escapes the Harness source: ${r}`);return o}v(T,"containedPath");async function _(e,r){let t=`${e}.${H()}.tmp`;await p.writeFile(t,`${JSON.stringify(r,null,2)}
2
+ import{g as E,m as g,n as j}from"./chunk-BQNU4HZW.js";import{k as P}from"./chunk-4V73I4OL.js";import{e as D,f as x,g as W,l as I}from"./chunk-LE75SVEL.js";import{b as A}from"./chunk-L3KS6MOV.js";import{n as $}from"./chunk-RCT3O3HQ.js";import{a as v}from"./chunk-FTQLQJQV.js";import{randomUUID as H}from"node:crypto";import{promises as p}from"node:fs";import{stripTypeScriptTypes as M}from"node:module";import m from"node:path";async function Q(e){let r=D.parse(e.overlay),t=x.parse(e.proposal),o=e.validations.map(h=>W.parse(h));if((t.route==="agent"?t.edits.filter(h=>h.target!=="harness.json"&&h.operation!=="delete"):[]).length>0){let h=t.validationPlan.find(n=>n.kind==="component_activation"&&n.required);if(!h)throw new Error("Desktop Work Agent proposals require component-activation validation before review.");if(o.find(n=>n.validationId===h.id)?.status==="passed")throw new Error("Desktop Work cannot accept a passed Agent activation receipt until an Agent source executor exists.")}if(t.overlay.id!==r.id||t.overlay.revision!==r.revision||t.overlay.contentHash!==r.contentHash)throw new Error("Refiner proposal is not bound to the supplied run overlay.");if(r.status!=="frozen")throw new Error("Only a frozen run overlay can advance a Harness workspace.");let i=await e.store.getHarnessWorkspace(t.expectedWorkspace.workspaceId);if(!i)throw new Error(`Harness workspace ${t.expectedWorkspace.workspaceId} does not exist.`);if(i.location!==e.store.harnessStoragePlacement)throw new Error("Refiner workspace does not match the admitted storage placement.");let s=E(e.storeDir,i.id),l=await g({workspaceId:i.id,sourceDir:s.source});if(l.sourceRevision!==i.sourceRevision)throw new Error(`Harness source is ${l.sourceRevision}; workspace expects ${i.sourceRevision}. Record or revert the source change before refinement.`);let w=m.join(s.root,`.source-candidate-${H()}`);await p.cp(s.source,w,{recursive:!0,force:!1,errorOnExist:!0,verbatimSymlinks:!1});try{await V(w,t);let h=await g({workspaceId:i.id,sourceDir:w}),f=(e.now??(()=>new Date().toISOString()))(),n=await j({storeDir:e.storeDir,workspaceId:i.id,compiled:h,createdAt:f});await e.store.saveHarnessReleaseRecord(n),await e.store.saveHarnessImprovementArtifact(i.id,"run_overlay",r),await e.store.saveHarnessImprovementArtifact(i.id,"proposal",t);for(let a of o)await e.store.saveHarnessImprovementArtifact(i.id,"targeted_validation",a);if(!P({workspace:i,proposal:t}).eligible&&!e.reviewAuthority)return e.store.advanceHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:i.id,proposal:t,validations:o,nextRelease:{id:n.harnessRelease.id,contentHash:n.harnessRelease.contentHash},nextSourceRevision:n.sourceRevision,now:f});let u=m.join(s.root,`.source-backup-${H()}`),c=m.join(s.root,"source-swap.json");await _(c,{schemaVersion:"openpond.localHarnessSourceSwap.v1",workspaceId:i.id,expectedWorkspaceRevision:i.revision,previousSourceRevision:i.sourceRevision,nextSourceRevision:n.sourceRevision,backupSource:u,candidateSource:w,createdAt:f}),await p.rename(s.source,u),await p.rename(w,s.source);try{let a=e.reviewAuthority?await e.store.advanceReviewedHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:i.id,proposal:t,validations:o,nextRelease:{id:n.harnessRelease.id,contentHash:n.harnessRelease.contentHash},nextSourceRevision:n.sourceRevision,reviewer:e.reviewAuthority.reviewer,now:f}):await e.store.advanceHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:i.id,proposal:t,validations:o,nextRelease:{id:n.harnessRelease.id,contentHash:n.harnessRelease.contentHash},nextSourceRevision:n.sourceRevision,now:f});return a.receipt.decision!=="advanced"?await b(s.source,u):await p.rm(u,{recursive:!0,force:!0}),await p.rm(c,{force:!0}),a}catch(a){throw await b(s.source,u).catch(()=>{}),await p.rm(c,{force:!0}).catch(()=>{}),a}}finally{await p.rm(w,{recursive:!0,force:!0}).catch(()=>{})}}v(Q,"applyLocalHarnessRefinerProposal");async function X(e){let r=await e.store.getHarnessWorkspace(e.workspaceId);if(!r||r.location!==e.store.harnessStoragePlacement)throw new Error(`Local Harness workspace ${e.workspaceId} does not exist.`);if(r.currentChannel.release?.id!==e.rollbackOf.id||r.currentChannel.release.contentHash!==e.rollbackOf.contentHash)throw new Error("Harness rollback source is no longer the current release.");let t=await e.store.getHarnessReleaseRecord(e.targetRelease.contentHash);if(!t||t.workspaceId!==r.id||t.harnessRelease.id!==e.targetRelease.id)throw new Error("Harness rollback target is unavailable in this workspace.");let o=E(e.storeDir,r.id);if((await g({workspaceId:r.id,sourceDir:o.source})).sourceRevision!==r.sourceRevision)throw new Error("Harness source changed before rollback.");let i=m.join(o.root,`.source-rollback-${H()}`);await p.cp(m.join(t.bundlePath,"source"),i,{recursive:!0,force:!1,errorOnExist:!0,verbatimSymlinks:!1});try{if((await g({workspaceId:r.id,sourceDir:i})).sourceRevision!==t.sourceRevision)throw new Error("Harness rollback bundle does not reproduce its registered source revision.");let l=(e.now??(()=>new Date().toISOString()))(),w=m.join(o.root,`.source-backup-${H()}`),h=m.join(o.root,"source-swap.json");await _(h,{schemaVersion:"openpond.localHarnessSourceSwap.v1",workspaceId:r.id,expectedWorkspaceRevision:r.revision,previousSourceRevision:r.sourceRevision,nextSourceRevision:t.sourceRevision,backupSource:w,candidateSource:i,createdAt:l}),await p.rename(o.source,w),await p.rename(i,o.source);try{let f=await e.store.rollbackHarnessWorkspaceAtomically({receiptId:e.receiptId,workspaceId:r.id,expectedWorkspaceRevision:r.revision,expectedChannelRevision:r.currentChannel.revision,targetRelease:e.targetRelease,targetSourceRevision:t.sourceRevision,rollbackOf:e.rollbackOf,now:l});return f.receipt.decision!=="rolled_back"?await b(o.source,w):await p.rm(w,{recursive:!0,force:!0}),await p.rm(h,{force:!0}),f}catch(f){throw await b(o.source,w).catch(()=>{}),await p.rm(h,{force:!0}).catch(()=>{}),f}}finally{await p.rm(i,{recursive:!0,force:!0}).catch(()=>{})}}v(X,"rollbackLocalHarnessWorkspaceRelease");async function Y(e){let r=x.parse(e.proposal);if(r.expectedWorkspace.workspaceId!==e.workspace.id)throw new Error("Refiner proposal targets a different Harness workspace.");if(r.route==="memory")return q({proposal:r,now:e.now});let t=E(e.storeDir,e.workspace.id),o=await g({workspaceId:e.workspace.id,sourceDir:t.source});if(o.sourceRevision!==r.expectedWorkspace.sourceRevision)throw new Error("Refiner proposal source revision no longer matches the Local Harness workspace.");let d=m.join(t.root,`.validation-candidate-${H()}`);await p.cp(t.source,d,{recursive:!0,force:!1,errorOnExist:!0,verbatimSymlinks:!1});let i=(e.now??(()=>new Date().toISOString()))();try{await V(d,r);let s=await g({workspaceId:e.workspace.id,sourceDir:d}),l=new Map(s.manifest.files.map(n=>[n.path,n])),w=new Map(r.edits.map(n=>[n.target,n])),h=O(o),f=O(s);return Promise.all(r.validationPlan.map(async n=>{let y="passed",u="The candidate Harness source compiles and preserves its manifest contract.";try{if(n.kind==="observed_recovery"){let c=r.evidence.filter(a=>a.kind==="recovery");if(c.length===0)throw new Error("Observed-recovery validation requires recorded recovery evidence.");u=`Validated ${c.length} immutable recovery evidence reference(s) before candidate advancement.`}else if(n.kind==="prompt"){let c=r.edits.filter(a=>a.route==="prompt"&&a.target!=="harness.json");if(c.length===0)throw new Error("Prompt validation requires an instruction-file edit.");for(let a of c){let k=l.get(a.target);if(a.operation==="delete"){if(k)throw new Error(`Deleted instruction ${a.target} remains declared.`)}else if(k?.kind!=="instruction")throw new Error(`Instruction ${a.target} is not declared in the candidate Harness.`);if(a.content!==null&&/\b(?:api[_-]?key|access[_-]?token|password|secret)\s*[:=]/i.test(a.content))throw new Error(`Instruction ${a.target} appears to contain credential material.`)}u=`Validated ${c.length} textual instruction edit(s) and compiled candidate ${s.harnessRelease.id}.`}else if(n.kind==="skill"){let c=r.edits.filter(a=>a.route==="skill"&&a.target!=="harness.json");if(c.length===0)throw new Error("Skill validation requires a declared Skill-file edit.");for(let a of c){let k=l.get(a.target);if(a.operation==="delete"){if(k)throw new Error(`Deleted Skill ${a.target} remains declared.`);continue}if(k?.kind!=="skill")throw new Error(`Skill ${a.target} is not declared in the candidate Harness.`);let S=w.get(a.target)?.content;if(!S)throw new Error(`Skill edit ${a.target} has no content.`);let R=A(S);if(!R.name||!R.description||R.messages.length>0)throw new Error(`Skill ${a.target} is invalid: ${R.messages.join(" ")}`)}u=`Validated ${c.length} Skill edit(s), Skill frontmatter, and compiled candidate ${s.harnessRelease.id}.`}else if(n.kind==="dependency"){let c=s.manifest.files.find(a=>a.kind==="dependency_lock");if(!c)throw new Error("Candidate Harness has no dependency lock.");JSON.parse(await p.readFile(T(d,c.path),"utf8")),u=`Validated dependency lock ${c.path} and compiled candidate ${s.harnessRelease.id}.`}else if(n.kind==="schema")x.parse(r),u=`Validated proposal, manifest, and candidate release schemas for ${s.harnessRelease.id}.`;else if(n.kind==="package"){let c=r.edits.filter(a=>a.route==="agent"&&a.operation!=="delete"&&a.target!=="harness.json");for(let a of c){if(!a.content)throw new Error(`Agent edit ${a.target} has no source.`);M(a.content,{mode:"transform",sourceUrl:a.target,sourceMap:!1})}u=c.length>0?`Syntax-checked ${c.length} Agent source edit(s) and compiled candidate ${s.harnessRelease.id}.`:`Compiled candidate package ${s.harnessRelease.id} and preserved the Harness source manifest contract.`}else if(n.kind==="component_activation"){let c=r.edits.filter(a=>a.target!=="harness.json");if(c.length===0)throw new Error("Component activation requires a concrete Harness component edit.");if(r.route==="agent"){if(c.filter(k=>k.operation!=="delete").length>0)throw new Error("Desktop Work does not compile or execute released Agent source; use an active instruction or standalone Skill, or add an Agent executor before release.");u=`Confirmed ${c.length} deleted Agent component(s) were inactive in Desktop Work.`}else{if(!["prompt","skill"].includes(r.route))throw new Error(`Desktop Work has no activation policy for ${r.route} proposals.`);let a=r.route==="prompt"?"instruction":"skill";for(let k of c){let S=f.components.find(R=>R.path===k.target&&R.kind===a);if(k.operation==="delete"?S:!S)throw new Error(`${a} ${k.target} is not reflected in the candidate Desktop Work runtime surface.`)}if(h.contentHash===f.contentHash)throw new Error("The candidate does not change the effective Desktop Work runtime surface.");u=`Activated ${c.length} ${a} edit(s) in the candidate Desktop Work runtime surface.`}}else n.kind==="business_formula"?(y="blocked",u="Business or financial logic is retained for review until an approved deterministic fixture supplies inputs and expected outputs."):n.kind==="targeted_evaluation"?(y="blocked",u="This sensitive change requires an explicit authority-preserving targeted Evaluation before release."):n.kind==="file_render"?(y="blocked",u="File-render validation requires an exact produced artifact reference; no artifact was attached to this Harness-source proposal."):(y="blocked",u=`Local targeted validation does not yet own ${n.kind}; it requires its dedicated validator.`)}catch(c){y="failed",u=c instanceof Error?c.message:String(c)}return I({schemaVersion:"openpond.harnessTargetedValidationReceipt.v1",id:`validation-${r.id}-${n.id}`,proposal:{id:r.id,contentHash:r.contentHash},validationId:n.id,kind:n.kind,status:y,summary:u,evidenceRefs:r.evidence,createdAt:i,metadata:{candidateHarnessRelease:{id:s.harnessRelease.id,contentHash:s.harnessRelease.contentHash},sourceRevision:s.sourceRevision,...n.kind==="component_activation"?{targetRuntime:"desktop_work",beforeEffectiveRuntimeHash:h.contentHash,afterEffectiveRuntimeHash:f.contentHash,activatedComponentRefs:f.components,inactiveAgentRefs:f.inactiveAgents}:{}}})}))}catch(s){let l=s instanceof Error?s.message:String(s);return r.validationPlan.map(w=>I({schemaVersion:"openpond.harnessTargetedValidationReceipt.v1",id:`validation-${r.id}-${w.id}`,proposal:{id:r.id,contentHash:r.contentHash},validationId:w.id,kind:w.kind,status:"failed",summary:l,evidenceRefs:r.evidence,createdAt:i,metadata:{}}))}finally{await p.rm(d,{recursive:!0,force:!0}).catch(()=>{})}}v(Y,"validateLocalHarnessRefinerProposal");function O(e){let r=[...e.agentSnapshot.instructions.map(o=>({kind:"instruction",path:o.path,contentHash:o.contentHash})),...e.agentSnapshot.skills.map(o=>({kind:"skill",path:o.path,contentHash:o.contentHash}))].sort((o,d)=>o.path.localeCompare(d.path)),t=e.agentSnapshot.agents.map(o=>({path:o.path,contentHash:o.contentHash})).sort((o,d)=>o.path.localeCompare(d.path));return{contentHash:$({schemaVersion:"openpond.desktopWorkHarnessSurface.v1",components:r}),components:r,inactiveAgents:t}}v(O,"desktopWorkRuntimeSurface");function q(e){let r=(e.now??(()=>new Date().toISOString()))(),t=e.proposal.edits.find(o=>o.route==="memory");return e.proposal.validationPlan.map(o=>{let d="passed",i="Memory candidate is bounded, scoped, and contains no obvious credential material.";try{if(o.kind==="observed_recovery"){if(!e.proposal.evidence.some(s=>s.kind==="recovery"))throw new Error("Observed-recovery validation requires recorded recovery evidence.");i="Memory proposal is grounded in immutable recovery evidence."}else if(o.kind==="memory"){if(!t||!/^memory\/[a-z0-9][a-z0-9-]{0,119}$/.test(t.target))throw new Error("Memory proposal requires one safe memory/<slug> target.");let s=e.proposal.metadata.expectedMemory;if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Memory proposal requires an expected revision snapshot.");let l=s;if(l.key!==C(t.target))throw new Error("Memory proposal expected revision targets a different key.");if(l.revision!==null&&(!Number.isInteger(l.revision)||Number(l.revision)<1))throw new Error("Memory proposal expected revision is invalid.");if(l.contentHash!==null&&typeof l.contentHash!="string")throw new Error("Memory proposal expected content hash is invalid.");if(l.status!==null&&l.status!=="active"&&l.status!=="deleted")throw new Error("Memory proposal expected status is invalid.");if(l.revision===null&&(l.contentHash!==null||l.status!==null))throw new Error("New memory snapshot must not claim existing content or status.");if(l.revision!==null&&(typeof l.contentHash!="string"||l.status===null))throw new Error("Existing memory snapshot requires its content hash and status.");if(t.operation==="delete"&&l.status!=="active")throw new Error("Memory deletion requires an active expected revision.");if(t.operation!=="delete"){if(!t.content?.trim()||t.content.length>24e3)throw new Error("Memory content must contain 1-24,000 characters.");if(/\b(?:api[_-]?key|access[_-]?token|password|secret)\s*[:=]/i.test(t.content))throw new Error("Memory content appears to contain credential material.")}}else d="blocked",i=`Memory validation cannot satisfy ${o.kind}.`}catch(s){d="failed",i=s instanceof Error?s.message:String(s)}return I({schemaVersion:"openpond.harnessTargetedValidationReceipt.v1",id:`validation-${e.proposal.id}-${o.id}`,proposal:{id:e.proposal.id,contentHash:e.proposal.contentHash},validationId:o.id,kind:o.kind,status:d,summary:i,evidenceRefs:e.proposal.evidence,createdAt:r,metadata:{externalState:"harness_memory"}})})}v(q,"validateMemoryProposal");function C(e){let r=e.replaceAll("\\","/"),t=/^memory\/([a-z0-9][a-z0-9-]{0,119})$/.exec(r);if(!t)throw new Error(`Invalid Harness memory target: ${e}.`);return t[1]}v(C,"memoryKeyFromTarget");async function Z(e){let r=await e.store.getHarnessWorkspace(e.workspaceId);if(!r)throw new Error(`Harness workspace ${e.workspaceId} does not exist.`);let t=E(e.storeDir,r.id),o=m.join(t.root,"source-swap.json"),d=await p.readFile(o,"utf8").then(JSON.parse).catch(l=>{if(l.code==="ENOENT")return null;throw l});if(!d)return"none";let i=await g({workspaceId:r.id,sourceDir:t.source});if(r.sourceRevision===d.nextSourceRevision&&i.sourceRevision===d.nextSourceRevision)return await p.rm(d.backupSource,{recursive:!0,force:!0}),await p.rm(o,{force:!0}),"completed";let s=await g({workspaceId:r.id,sourceDir:d.backupSource});if(r.sourceRevision===d.previousSourceRevision&&s.sourceRevision===d.previousSourceRevision)return await b(t.source,d.backupSource),await p.rm(o,{force:!0}),"restored";throw new Error("Harness source-swap recovery cannot reconcile filesystem and workspace revisions.")}v(Z,"recoverLocalHarnessSourceSwap");async function V(e,r){for(let t of r.edits){let o=T(e,t.target);if(t.operation==="delete"){await p.rm(o,{force:!1});continue}if(t.content===null)throw new Error(`Refiner edit ${t.id} has no content.`);if(t.operation==="create")await p.mkdir(m.dirname(o),{recursive:!0}),await p.writeFile(o,t.content,{flag:"wx"});else{let d=await p.lstat(o);if(!d.isFile()||d.isSymbolicLink())throw new Error(`Refiner update target must be a regular file: ${t.target}`);await p.writeFile(o,t.content,{flag:"w"})}}}v(V,"applyOverlayEdits");function T(e,r){let t=m.resolve(e),o=m.resolve(t,...r.replaceAll("\\","/").split("/")),d=m.relative(t,o);if(!d||d.startsWith("..")||m.isAbsolute(d))throw new Error(`Refiner edit target escapes the Harness source: ${r}`);return o}v(T,"containedPath");async function _(e,r){let t=`${e}.${H()}.tmp`;await p.writeFile(t,`${JSON.stringify(r,null,2)}
3
3
  `,{flag:"wx"}),await p.rename(t,e)}v(_,"writeSwapJournal");async function b(e,r){await p.rm(e,{recursive:!0,force:!0}),await p.rename(r,e)}v(b,"restoreSource");export{Q as a,X as b,Y as c,Z as d};