openpond 0.2.66 → 0.2.67

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 (375) hide show
  1. package/dist/app-server.d.ts +23 -0
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/{acp-YYZ3ZO3Q.js → acp-NASAJV5E.js} +1 -1
  4. package/dist/chunks/{acp-agent-T26S7TU2.js → acp-agent-C3CRF6DT.js} +1 -1
  5. package/dist/chunks/{actions-command-VLKMHCMI.js → actions-command-BYPLSGZL.js} +1 -1
  6. package/dist/chunks/{app-layer-5XUMNHDO.js → app-layer-XIEZ6ALX.js} +1 -1
  7. package/dist/chunks/{app-server-evaluations-V6LRWDUF.js → app-server-evaluations-5YZUFXQ2.js} +1 -1
  8. package/dist/chunks/{app-server-harness-services-6ZRLA3YD.js → app-server-harness-services-N5F5QVZI.js} +1 -1
  9. package/dist/chunks/{app-server-runtime-TH56EG2Z.js → app-server-runtime-HJ2N57DL.js} +1 -1
  10. package/dist/chunks/{apps-MNT3KXIY.js → apps-WJTW64NW.js} +1 -1
  11. package/dist/chunks/{chunk-ZWW227M3.js → chunk-263WS3TB.js} +1 -1
  12. package/dist/chunks/{chunk-HX6GXMDK.js → chunk-26ID6A5C.js} +1 -1
  13. package/dist/chunks/{chunk-DSJZS77R.js → chunk-2RSGVLZT.js} +4 -4
  14. package/dist/chunks/{chunk-L4EJ5R3B.js → chunk-2UZHLO2V.js} +1 -1
  15. package/dist/chunks/{chunk-QYQZQVVN.js → chunk-375PADDM.js} +1 -1
  16. package/dist/chunks/{chunk-FUFI4THX.js → chunk-43QYVOYA.js} +1 -1
  17. package/dist/chunks/{chunk-H5ML7735.js → chunk-46RMTR2Z.js} +1 -1
  18. package/dist/chunks/{chunk-Z2TOBS3P.js → chunk-4B7EGNYX.js} +1 -1
  19. package/dist/chunks/{chunk-2GJD23CM.js → chunk-4EZI4KCT.js} +1 -1
  20. package/dist/chunks/{chunk-DMO3UIS7.js → chunk-4JJ4RYIB.js} +1 -1
  21. package/dist/chunks/{chunk-JKI53ED7.js → chunk-4NN5OLKW.js} +2 -2
  22. package/dist/chunks/{chunk-66HFW4OU.js → chunk-4VZJQRQI.js} +1 -1
  23. package/dist/chunks/{chunk-7PKTCMZ6.js → chunk-543QHE3D.js} +1 -1
  24. package/dist/chunks/{chunk-TVDZXDQW.js → chunk-5QOFUGYQ.js} +1 -1
  25. package/dist/chunks/{chunk-6S2MWJVD.js → chunk-5TPYBXWM.js} +1 -1
  26. package/dist/chunks/{chunk-WLZJOCLA.js → chunk-5ZNE43XC.js} +1 -1
  27. package/dist/chunks/{chunk-KOKBDIGR.js → chunk-6HQUIKC5.js} +1 -1
  28. package/dist/chunks/{chunk-3BJ7LPE3.js → chunk-6IS5OLI5.js} +1 -1
  29. package/dist/chunks/{chunk-VS3AMJEK.js → chunk-6LFTQBXP.js} +1 -1
  30. package/dist/chunks/{chunk-VD2TQCMH.js → chunk-7HAGSE7L.js} +1 -1
  31. package/dist/chunks/{chunk-NTM3KQ25.js → chunk-ADOCQA4D.js} +1 -1
  32. package/dist/chunks/{chunk-4D3CICBG.js → chunk-ATFV2NA4.js} +1 -1
  33. package/dist/chunks/{chunk-YU4JYWCA.js → chunk-AXO6OHJB.js} +1 -1
  34. package/dist/chunks/{chunk-5KJMFK65.js → chunk-AXYAEWWA.js} +1 -1
  35. package/dist/chunks/{chunk-Q4AXZY2P.js → chunk-B2K5WQZE.js} +1 -1
  36. package/dist/chunks/{chunk-ANG2YMMD.js → chunk-B7XJBP4U.js} +1 -1
  37. package/dist/chunks/{chunk-BQVB2SPF.js → chunk-BBIA24GD.js} +6 -6
  38. package/dist/chunks/{chunk-CYQLXS2U.js → chunk-BUZ7CBJC.js} +1 -1
  39. package/dist/chunks/{chunk-MVPKU72J.js → chunk-CJDGLPNX.js} +1 -1
  40. package/dist/chunks/{chunk-ZU3YBRXS.js → chunk-CSU7RDA5.js} +1 -1
  41. package/dist/chunks/{chunk-JLW5BQVO.js → chunk-CWAQOFLP.js} +1 -1
  42. package/dist/chunks/{chunk-WKHGXLJD.js → chunk-CX7HKSQ4.js} +2 -2
  43. package/dist/chunks/{chunk-M5QPL5NO.js → chunk-D5OFN47Z.js} +1 -1
  44. package/dist/chunks/{chunk-QCJY6FTC.js → chunk-FCXDPVGJ.js} +1 -1
  45. package/dist/chunks/{chunk-FEQ7HNJR.js → chunk-FE2ENE3U.js} +1 -1
  46. package/dist/chunks/{chunk-6TRVEA3T.js → chunk-FVK4W27G.js} +1 -1
  47. package/dist/chunks/{chunk-7FBWUVX7.js → chunk-GC6RJBRZ.js} +1 -1
  48. package/dist/chunks/{chunk-5Z3AU5CL.js → chunk-H2XG5N7D.js} +1 -1
  49. package/dist/chunks/chunk-H6EUFJJK.js +2 -0
  50. package/dist/chunks/{chunk-V3S2B6WU.js → chunk-IDILAYCW.js} +1 -1
  51. package/dist/chunks/{chunk-PLVWARB7.js → chunk-IF5A3XWP.js} +1 -1
  52. package/dist/chunks/chunk-IHAEZ73V.js +2 -0
  53. package/dist/chunks/{chunk-GDJ4X2ZN.js → chunk-IR2Y2VQY.js} +1 -1
  54. package/dist/chunks/{chunk-WBO6FQHR.js → chunk-IXZ5ZGIL.js} +1 -1
  55. package/dist/chunks/{chunk-67HXM6AL.js → chunk-K3LS5SK7.js} +1 -1
  56. package/dist/chunks/{chunk-4MQHIFZL.js → chunk-K6DB5QWG.js} +1 -1
  57. package/dist/chunks/{chunk-QJJNHKLT.js → chunk-KQD36SBJ.js} +1 -1
  58. package/dist/chunks/{chunk-LXZLLTYQ.js → chunk-LI56PPCN.js} +1 -1
  59. package/dist/chunks/{chunk-KAWXVMHI.js → chunk-MX7KV5DA.js} +1 -1
  60. package/dist/chunks/{chunk-LARJARMS.js → chunk-N54CPLVD.js} +1 -1
  61. package/dist/chunks/{chunk-JRGECNP3.js → chunk-OE2OOWEQ.js} +1 -1
  62. package/dist/chunks/{chunk-B32CW3NT.js → chunk-OY4B7Y3T.js} +1 -1
  63. package/dist/chunks/chunk-OYIFH2OM.js +2 -0
  64. package/dist/chunks/{chunk-C5B3FMV3.js → chunk-P6NQYXN6.js} +1 -1
  65. package/dist/chunks/{chunk-D7R2AAX2.js → chunk-QFL2VQKX.js} +1 -1
  66. package/dist/chunks/{chunk-Y3B6ZUE6.js → chunk-QOUOU7FE.js} +1 -1
  67. package/dist/chunks/{chunk-GIU3Z45P.js → chunk-QQLS5FB7.js} +1 -1
  68. package/dist/chunks/chunk-R5GRESW3.js +2 -0
  69. package/dist/chunks/{chunk-6ZTP6CUJ.js → chunk-R6MMWEH4.js} +1 -1
  70. package/dist/chunks/{chunk-XHBMK6LC.js → chunk-R6VI7MX5.js} +1 -1
  71. package/dist/chunks/{chunk-GFAI2MCJ.js → chunk-RS526BG7.js} +1 -1
  72. package/dist/chunks/{chunk-EVQISX7M.js → chunk-RWRKUO5D.js} +1 -1
  73. package/dist/chunks/{chunk-DXA2UHBE.js → chunk-SD2XDZQW.js} +1 -1
  74. package/dist/chunks/{chunk-S6UCVXBC.js → chunk-SODAOLAP.js} +1 -1
  75. package/dist/chunks/{chunk-UK5LGSGT.js → chunk-SVNEPXU3.js} +1 -1
  76. package/dist/chunks/{chunk-5WPMI6QX.js → chunk-TERKCK4I.js} +1 -1
  77. package/dist/chunks/{chunk-OKEC2EIE.js → chunk-TS5HNRZB.js} +1 -1
  78. package/dist/chunks/{chunk-5KWKSR4P.js → chunk-TSQ2I6XV.js} +1 -1
  79. package/dist/chunks/{chunk-YRDPVTEI.js → chunk-TV2LE2BD.js} +1 -1
  80. package/dist/chunks/chunk-U3MVH2YT.js +2 -0
  81. package/dist/chunks/{chunk-FS2VKOT7.js → chunk-UBTP3QWI.js} +1 -1
  82. package/dist/chunks/{chunk-7XOUM6RK.js → chunk-UKSSFB4Q.js} +1 -1
  83. package/dist/chunks/{chunk-W7NXFRHN.js → chunk-UNE52L3Y.js} +1 -1
  84. package/dist/chunks/{chunk-ZUT4EM64.js → chunk-UXO33ST5.js} +1 -1
  85. package/dist/chunks/{chunk-FHLSLOKH.js → chunk-V3ILZQER.js} +1 -1
  86. package/dist/chunks/chunk-V3T2OJBZ.js +33 -0
  87. package/dist/chunks/{chunk-QAEZNFAM.js → chunk-V5AOM5MZ.js} +1 -1
  88. package/dist/chunks/{chunk-LI3FTPAH.js → chunk-VEXJV5H5.js} +1 -1
  89. package/dist/chunks/{chunk-AF3AVDPP.js → chunk-VPAEFG7X.js} +1 -1
  90. package/dist/chunks/{chunk-NABPZ7AK.js → chunk-W3ZILZUL.js} +1 -1
  91. package/dist/chunks/{chunk-U2BD545L.js → chunk-WD6ANOLL.js} +1 -1
  92. package/dist/chunks/{chunk-OTUS7NTQ.js → chunk-WDKZMXIU.js} +1 -1
  93. package/dist/chunks/chunk-WGISITX6.js +4 -0
  94. package/dist/chunks/{chunk-55Q64WWF.js → chunk-XD4ZIQZ2.js} +1 -1
  95. package/dist/chunks/{chunk-W22KWKF6.js → chunk-XDFXKRTI.js} +1 -1
  96. package/dist/chunks/{chunk-GRLQHYAU.js → chunk-XEU4J4GJ.js} +1 -1
  97. package/dist/chunks/{chunk-IEVJLG3V.js → chunk-XGJG2ZKE.js} +1 -1
  98. package/dist/chunks/chunk-XHU4BZQY.js +13 -0
  99. package/dist/chunks/{chunk-DIDQHTAX.js → chunk-XKZ4PFMQ.js} +1 -1
  100. package/dist/chunks/{chunk-B666Z2NS.js → chunk-XT5WUQGT.js} +1 -1
  101. package/dist/chunks/{chunk-UXPO3ZV7.js → chunk-YKTJPCYZ.js} +3 -3
  102. package/dist/chunks/{chunk-5AU5Y6KS.js → chunk-YMCF5GR2.js} +1 -1
  103. package/dist/chunks/{chunk-LYVHYT3L.js → chunk-YONDU5TN.js} +1 -1
  104. package/dist/chunks/{chunk-BTJACFU3.js → chunk-YQBL5P6R.js} +1 -1
  105. package/dist/chunks/{chunk-SAZTOGX6.js → chunk-YR5URT73.js} +1 -1
  106. package/dist/chunks/{chunk-OXRVILDW.js → chunk-ZVMQLIRA.js} +1 -1
  107. package/dist/chunks/{chunk-MHPCVQOE.js → chunk-ZWEY66RT.js} +1 -1
  108. package/dist/chunks/cli-HV32F7HD.js +2 -0
  109. package/dist/chunks/command-NWOZXU57.js +58 -0
  110. package/dist/chunks/{configuration-command-4WTS2MZS.js → configuration-command-ZEIBQKB3.js} +1 -1
  111. package/dist/chunks/{connected-app-executor-7DYMZCD7.js → connected-app-executor-DFHWNMRM.js} +1 -1
  112. package/dist/chunks/{connected-evidence-D7C45HYD.js → connected-evidence-WOM6N5HO.js} +1 -1
  113. package/dist/chunks/{connected-starting-assets-4LDXQVLN.js → connected-starting-assets-66Y46ZPM.js} +1 -1
  114. package/dist/chunks/{continual-HQCFY7GN.js → continual-TNPTWTKK.js} +1 -1
  115. package/dist/chunks/{core-commands-RXPXOYOP.js → core-commands-GWRHH53F.js} +1 -1
  116. package/dist/chunks/{dataset-preparation-authoring-KWRTMKN6.js → dataset-preparation-authoring-WJ2XEUO7.js} +1 -1
  117. package/dist/chunks/{datasets-LBLEKLCS.js → datasets-XIMF54QN.js} +1 -1
  118. package/dist/chunks/{desktop-test-INJPZ5VP.js → desktop-test-HF42V2EP.js} +1 -1
  119. package/dist/chunks/dist-T6ES2TSM.js +2 -0
  120. package/dist/chunks/{evaluation-coordination-3ARLJAFH.js → evaluation-coordination-WZT6FDMS.js} +1 -1
  121. package/dist/chunks/{experiment-improvements-UB4C5CSP.js → experiment-improvements-H35VS6XZ.js} +1 -1
  122. package/dist/chunks/{experiments-AHHKFJD6.js → experiments-F54C32EE.js} +1 -1
  123. package/dist/chunks/{experiments-signal-MTR475QV.js → experiments-signal-ONIGTGYR.js} +1 -1
  124. package/dist/chunks/{help-JQA3YMCX.js → help-O53DTZGN.js} +1 -1
  125. package/dist/chunks/host-profile-evaluation-tools-LMCJ3MDJ.js +2 -0
  126. package/dist/chunks/{host-profile-external-dataset-YRKG2GL5.js → host-profile-external-dataset-4HOXANWK.js} +1 -1
  127. package/dist/chunks/{hosted-app-server-composition-GPXH3BOG.js → hosted-app-server-composition-Y64A2A2B.js} +1 -1
  128. package/dist/chunks/{hosted-experiment-improvement-NZTPZTDH.js → hosted-experiment-improvement-B2V2WIUI.js} +1 -1
  129. package/dist/chunks/hosted-harness-runtime-C7I4KSDK.js +2 -0
  130. package/dist/chunks/{hosted-profile-candidate-3CAT3XBI.js → hosted-profile-candidate-CXPVEEYQ.js} +1 -1
  131. package/dist/chunks/{hosted-profile-compiler-RXU626Q6.js → hosted-profile-compiler-FGCI2VRW.js} +1 -1
  132. package/dist/chunks/{hosted-profile-evaluation-control-CBDRKJ5J.js → hosted-profile-evaluation-control-INNUYMBD.js} +1 -1
  133. package/dist/chunks/{hosted-profile-evaluation-inspection-CHYKDYUQ.js → hosted-profile-evaluation-inspection-UPTBRYMS.js} +1 -1
  134. package/dist/chunks/{hosted-profile-evaluation-preparation-H5S7JZMD.js → hosted-profile-evaluation-preparation-TIQSVKLQ.js} +1 -1
  135. package/dist/chunks/{hosted-tasksets-AMGDDB2R.js → hosted-tasksets-7VMYOTIO.js} +1 -1
  136. package/dist/chunks/{human-review-DVHVJXBA.js → human-review-7XC77NQP.js} +1 -1
  137. package/dist/chunks/{import-CLWTKDG6.js → import-OBAKUJPM.js} +1 -1
  138. package/dist/chunks/javascript-isolate-process-source-YAT3GPW4.js +2 -0
  139. package/dist/chunks/javascript-verifier-worker-source-LGRP74W4.js +2 -0
  140. package/dist/chunks/learning-3XDGIYUL.js +2 -0
  141. package/dist/chunks/{learning-XTY5VOTK.js → learning-CRR6NRPN.js} +1 -1
  142. package/dist/chunks/{local-harness-improvement-runtime-XEA73RGS.js → local-harness-improvement-runtime-UIKQSAMM.js} +1 -1
  143. package/dist/chunks/{local-harness-taskset-review-SW35G4DM.js → local-harness-taskset-review-6KJN3EQL.js} +1 -1
  144. package/dist/chunks/{model-projects-GHWCKDON.js → model-projects-HP4DELCP.js} +1 -1
  145. package/dist/chunks/{opchat-LMKH3OWR.js → opchat-NWYWWIA7.js} +1 -1
  146. package/dist/chunks/{opchat-bounded-chat-PPOWO7H4.js → opchat-bounded-chat-ICURZM6R.js} +1 -1
  147. package/dist/chunks/{organizations-T6ZUSHNJ.js → organizations-7DBQGCCV.js} +1 -1
  148. package/dist/chunks/{profile-RIDNU2I5.js → profile-3WZJ65CT.js} +1 -1
  149. package/dist/chunks/{project-action-payload-2G57RL74.js → project-action-payload-7DRABTHY.js} +1 -1
  150. package/dist/chunks/{project-agent-GBMVDJY3.js → project-agent-AXJOWXRU.js} +1 -1
  151. package/dist/chunks/{published-experiment-source-D3C2AWQD.js → published-experiment-source-YBBPLNF2.js} +1 -1
  152. package/dist/chunks/{refiner-profile-service-PPGGNVOV.js → refiner-profile-service-ATEFPF5O.js} +1 -1
  153. package/dist/chunks/{runtime-VSOOPNYN.js → runtime-XP4DEGR3.js} +1 -1
  154. package/dist/chunks/{sandbox-command-L5VQ2T6C.js → sandbox-command-CF2PJCFX.js} +1 -1
  155. package/dist/chunks/{sandbox-template-NN3XQI7M.js → sandbox-template-YFMHEMUQ.js} +1 -1
  156. package/dist/chunks/{saved-work-LAVTNKPT.js → saved-work-3OAVRBH3.js} +1 -1
  157. package/dist/chunks/setup-RHIMFI2Y.js +2 -0
  158. package/dist/chunks/{src-662QOKNP.js → src-GQPWOPYA.js} +1 -1
  159. package/dist/chunks/{src-HJHIBDFX.js → src-V236S6MV.js} +112 -112
  160. package/dist/chunks/{standalone-experiment-turn-owner-KKYIGGPF.js → standalone-experiment-turn-owner-CDRMGLWW.js} +1 -1
  161. package/dist/chunks/{store-chat-resources-ZWDYMDJF.js → store-chat-resources-P4EKCLSY.js} +1 -1
  162. package/dist/chunks/{store-continual-support-reviews-7PDLGRWF.js → store-continual-support-reviews-VVRQO2JK.js} +1 -1
  163. package/dist/chunks/{store-conversation-serving-WRT4N7N2.js → store-conversation-serving-YFEZYQD3.js} +1 -1
  164. package/dist/chunks/{store-create-improve-G46KIUVT.js → store-create-improve-2XI36AET.js} +1 -1
  165. package/dist/chunks/{store-datasets-O67F75BL.js → store-datasets-UFY422NG.js} +1 -1
  166. package/dist/chunks/{store-evaluation-results-BEPR4LVD.js → store-evaluation-results-VBH4R2U7.js} +1 -1
  167. package/dist/chunks/{store-harness-workspaces-PJJQ74G6.js → store-harness-workspaces-SGUEYDO2.js} +1 -1
  168. package/dist/chunks/{store-human-review-HJ3D7ZFA.js → store-human-review-RFCVZ3HP.js} +1 -1
  169. package/dist/chunks/{store-learned-preference-migration-validation-EXNRDHCO.js → store-learned-preference-migration-validation-FNBGGZU6.js} +1 -1
  170. package/dist/chunks/{store-learning-6P6IS7GH.js → store-learning-BFOT4QVT.js} +1 -1
  171. package/dist/chunks/{store-learning-credentials-EGJ2WTZI.js → store-learning-credentials-DYTMWQTC.js} +1 -1
  172. package/dist/chunks/{store-local-experiments-CBJA56X2.js → store-local-experiments-XPXGYXNM.js} +1 -1
  173. package/dist/chunks/{store-model-batch-review-YIVD7T2T.js → store-model-batch-review-J2L5JQV2.js} +1 -1
  174. package/dist/chunks/{store-model-configuration-T6XJJDAB.js → store-model-configuration-NJFWSYSA.js} +1 -1
  175. package/dist/chunks/{store-model-project-preparation-WWU5CJTV.js → store-model-project-preparation-OCLIFKI2.js} +1 -1
  176. package/dist/chunks/{store-preference-comparison-XQFTLMGH.js → store-preference-comparison-MZAYONCK.js} +1 -1
  177. package/dist/chunks/{store-task-inbox-VVXZUJIO.js → store-task-inbox-3BREANOX.js} +1 -1
  178. package/dist/chunks/{store-task-inventory-MQX44AI6.js → store-task-inventory-5HRZCDUT.js} +1 -1
  179. package/dist/chunks/{store-taskset-drafts-G3WFVN4M.js → store-taskset-drafts-BNKUVHPA.js} +1 -1
  180. package/dist/chunks/{store-training-DUVIDYK5.js → store-training-S3FXWLT6.js} +1 -1
  181. package/dist/chunks/{store-training-jobs-HHFH3V5O.js → store-training-jobs-2LCXPA7G.js} +1 -1
  182. package/dist/chunks/{store-training-models-C7UUZDTO.js → store-training-models-7AMKS7ZW.js} +1 -1
  183. package/dist/chunks/{taskset-7FQCJ55X.js → taskset-PLKWRT4X.js} +1 -1
  184. package/dist/chunks/{taskset-packages-NRRPON7B.js → taskset-packages-SXBLYHSP.js} +1 -1
  185. package/dist/chunks/{taskset-packages-RW4SFGDU.js → taskset-packages-V5T4V7YN.js} +1 -1
  186. package/dist/chunks/{teams-bot-FXMCOCPP.js → teams-bot-VQXUA7U4.js} +1 -1
  187. package/dist/chunks/{tool-learning-O7QTTEDB.js → tool-learning-47XQKELE.js} +1 -1
  188. package/dist/chunks/{training-XFM3OOPN.js → training-7VQNCOGH.js} +1 -1
  189. package/dist/chunks/{training-XILDD5RG.js → training-VKLPNCMC.js} +1 -1
  190. package/dist/chunks/{training-hosted-6BX2IASC.js → training-hosted-NNE6BP6S.js} +1 -1
  191. package/dist/chunks/training-hosted-checkpoint-evaluation-2X7RSOLC.js +2 -0
  192. package/dist/chunks/{training-hosted-learning-YN5VD3PW.js → training-hosted-learning-WQ2IP5FP.js} +1 -1
  193. package/dist/chunks/training-hosted-report-T633TNJG.js +2 -0
  194. package/dist/chunks/training-hosted-serving-report-VZ4SMLMG.js +2 -0
  195. package/dist/chunks/training-hosted-workers-Y2PO5IOA.js +2 -0
  196. package/dist/chunks/{training-model-start-E5MP3URL.js → training-model-start-G7YDZ7ZG.js} +1 -1
  197. package/dist/cli.js +1 -1
  198. package/dist/index.js +1 -1
  199. package/dist/skills/manifest.json +1 -1
  200. package/dist/web/assets/App-DmEA-Lia.js +53 -0
  201. package/dist/web/assets/{AppDialog-DuSd0wk6.js → AppDialog-BvskhHE9.js} +1 -1
  202. package/dist/web/assets/AppTerminalPanel-ScQKJV4z.js +2 -0
  203. package/dist/web/assets/{AppToastContext-Dklk6CaG.js → AppToastContext-D2788RqX.js} +1 -1
  204. package/dist/web/assets/AppsView-B1uNg9IQ.js +1 -0
  205. package/dist/web/assets/{AppsView-DNHWzJb2.css → AppsView-D3vVesNd.css} +1 -1
  206. package/dist/web/assets/{AttachmentTypeIcon-DipNT6Tj.js → AttachmentTypeIcon-DVluUHuc.js} +1 -1
  207. package/dist/web/assets/{BrowserSidebar-BBaaanMS.js → BrowserSidebar-DfVQoJHn.js} +1 -1
  208. package/dist/web/assets/{CartesianChart-UU1sdoUO.js → CartesianChart-DdBZ69lI.js} +1 -1
  209. package/dist/web/assets/{ChatTimelineEntry-Ct59FKw1.js → ChatTimelineEntry-Bbc6HRks.js} +1 -1
  210. package/dist/web/assets/{CollaborationTabs-BWYRQ1PE.js → CollaborationTabs-ba6WupeJ.js} +1 -1
  211. package/dist/web/assets/{CommandMenu-B08F9x5g.js → CommandMenu-D7wTaEgl.js} +1 -1
  212. package/dist/web/assets/{CommunityView-BLTlSxyb.js → CommunityView-mO58f2B0.js} +1 -1
  213. package/dist/web/assets/{ComposerAttachments-srWBKvCv.js → ComposerAttachments-aO90qXYz.js} +1 -1
  214. package/dist/web/assets/{ComposerCreateImproveStrip-DqTpU5cO.js → ComposerCreateImproveStrip-BPUJBSyS.js} +1 -1
  215. package/dist/web/assets/{ConversationImportsSettings-2KC-KQvu.js → ConversationImportsSettings-Bo836wKJ.js} +1 -1
  216. package/dist/web/assets/{FilePagePreview-B-iUVPhh.js → FilePagePreview-C6wIp6uX.js} +2 -2
  217. package/dist/web/assets/{GetStartedView-5v0vBWXy.js → GetStartedView-CxMv8q-h.js} +1 -1
  218. package/dist/web/assets/{GettingStartedDialog-Bn4072K-.js → GettingStartedDialog-CEb0cS-o.js} +1 -1
  219. package/dist/web/assets/{HostedModelLearningReview-DWF6WPao.js → HostedModelLearningReview-BQIS7hkd.js} +1 -1
  220. package/dist/web/assets/HostedModelLearningSettings-BQ-YeFMT.js +1 -0
  221. package/dist/web/assets/{HtmlVisual-C2WsMj90.js → HtmlVisual-CCuUkYT8.js} +1 -1
  222. package/dist/web/assets/{LabModelVersionDetailPage-CQz29DwD.js → LabModelVersionDetailPage-BkHeVbAx.js} +1 -1
  223. package/dist/web/assets/{LabSkillSidebar-C50P74LI.js → LabSkillSidebar-CFROlATQ.js} +1 -1
  224. package/dist/web/assets/LabsRoute-YA9YckKj.js +101 -0
  225. package/dist/web/assets/MainChatThread-DpyPgGKW.js +2 -0
  226. package/dist/web/assets/{MainPane-Dje-hfUM.css → MainPane-BOWkynGB.css} +1 -1
  227. package/dist/web/assets/MainPane-WOeodByM.js +10 -0
  228. package/dist/web/assets/NativeSetupTerminal-fmG2c65K.js +2 -0
  229. package/dist/web/assets/{NativeSkillSidebar-Clv0IWyn.js → NativeSkillSidebar-MAJWS4mL.js} +1 -1
  230. package/dist/web/assets/{NewProjectDialog-Cw_F5Eaa.js → NewProjectDialog-MQiUBVx3.js} +1 -1
  231. package/dist/web/assets/{OutputsPage-Btyiie4B.js → OutputsPage-DpF-aRTu.js} +1 -1
  232. package/dist/web/assets/{PageChrome-BLLw_cEA.js → PageChrome-8gH2hyDb.js} +1 -1
  233. package/dist/web/assets/{ProjectsPage-BpSHWQgj.js → ProjectsPage-BQ98oGyu.js} +1 -1
  234. package/dist/web/assets/{RightChatPanelStack-xW5rKbp0.js → RightChatPanelStack-Bs7A4dLs.js} +1 -1
  235. package/dist/web/assets/RightSidebarHomePanel-C-D4kba2.js +1 -0
  236. package/dist/web/assets/{ScheduledWorkPage-WytWGQgw.js → ScheduledWorkPage-CGCqZz_H.js} +1 -1
  237. package/dist/web/assets/{SettingsView-BJq5zNkv.js → SettingsView-CqpMFLxy.js} +3 -3
  238. package/dist/web/assets/{TasksetDraftEditorPrimitives-BxFEWI9W.js → TasksetDraftEditorPrimitives-DJvIvzBb.js} +1 -1
  239. package/dist/web/assets/{TeamChatView-BisSMAXy.js → TeamChatView-DjmIaLO1.js} +1 -1
  240. package/dist/web/assets/{TerminalOverlay-C7OM2F0-.js → TerminalOverlay-D--M876l.js} +1 -1
  241. package/dist/web/assets/{TrainingCreationPanel-KH5GFacT.js → TrainingCreationPanel-DDUoHQHU.js} +1 -1
  242. package/dist/web/assets/{TrainingDraftPanel-DzOw13Md.js → TrainingDraftPanel-CwLXn3Z7.js} +1 -1
  243. package/dist/web/assets/{TrainingRunLineage-B2WBOchk.js → TrainingRunLineage-CtYe1KGX.js} +1 -1
  244. package/dist/web/assets/{UsageSettingsSection-nZHno_4P.js → UsageSettingsSection-CGwPregx.js} +1 -1
  245. package/dist/web/assets/WorkSidebarPanel-C6wWuo7U.js +1 -0
  246. package/dist/web/assets/{WorkspaceDiffPanel-CyTa8Cjs.js → WorkspaceDiffPanel-JDOUmrC-.js} +3 -3
  247. package/dist/web/assets/{WorkspaceEnvironmentMenu-CtZzxQ1e.js → WorkspaceEnvironmentMenu-sfL5LZeB.js} +1 -1
  248. package/dist/web/assets/{WorkspaceFileLocation-1U8DDj1J.js → WorkspaceFileLocation-D-ctFM4d.js} +1 -1
  249. package/dist/web/assets/{WorkspaceGitDialogs-BO1EUA3G.js → WorkspaceGitDialogs-CQ28j3R7.js} +1 -1
  250. package/dist/web/assets/{WorkspaceMonacoEditor-Rqq_sKW_.js → WorkspaceMonacoEditor-BrZs6-EW.js} +3 -3
  251. package/dist/web/assets/{WorkspacePdfPreview-zmmMp09R.js → WorkspacePdfPreview-CU6PSjjN.js} +2 -2
  252. package/dist/web/assets/{WorkspacePresentationPreview-DNbhGjkE.js → WorkspacePresentationPreview-IjXVXpIy.js} +1 -1
  253. package/dist/web/assets/{app-models-Cz3yxq4x.js → app-models-CKXrDTEU.js} +1 -1
  254. package/dist/web/assets/{bot-D-eTQib6.js → bot-Cd761lRF.js} +1 -1
  255. package/dist/web/assets/{browser-sidebar-links-ZyYiYBBd.js → browser-sidebar-links-D9v2cyJa.js} +1 -1
  256. package/dist/web/assets/chat-resources-BUDXdoG0.js +1 -0
  257. package/dist/web/assets/{chevron-down-75im8nFF.js → chevron-down-DEbd6Ek-.js} +1 -1
  258. package/dist/web/assets/chevron-right-DLYNg_Oq.js +1 -0
  259. package/dist/web/assets/{chevron-up-BD8jg0bQ.js → chevron-up-DFJJccDl.js} +1 -1
  260. package/dist/web/assets/chunk-GHPCQXG5-DKDBSd8H.js +9 -0
  261. package/dist/web/assets/chunk-GJRXJL6G-luaxRTYI.js +1 -0
  262. package/dist/web/assets/chunk-H3JZ3P5T-CzpTARDY.js +2 -0
  263. package/dist/web/assets/chunk-JDQVAG3R-C0-rh1aR.js +1 -0
  264. package/dist/web/assets/chunk-TLSP5JKG-BrrVo5rJ.js +1 -0
  265. package/dist/web/assets/chunk-XMVSQIK4-BBU7r_NH.js +1 -0
  266. package/dist/web/assets/client-BNjO4Xi8.js +1 -0
  267. package/dist/web/assets/{client-choice-storage-CXlWJW5g.js → client-choice-storage-DUWsS4X0.js} +1 -1
  268. package/dist/web/assets/{cloud-upload-4lP-5zmp.js → cloud-upload-CoM1FGeB.js} +1 -1
  269. package/dist/web/assets/{common-BMjyKlX-.js → common-CFsO2ppZ.js} +1 -1
  270. package/dist/web/assets/{copy-DRnATDDY.js → copy-BGOhV6Pk.js} +1 -1
  271. package/dist/web/assets/{create-pipeline-CyUZrbbO.js → create-pipeline-DRR0Qeec.js} +1 -1
  272. package/dist/web/assets/{createLucideIcon-CmkSm39S.js → createLucideIcon-Bv-_eGcE.js} +1 -1
  273. package/dist/web/assets/{cssMode-Cps-05f3.js → cssMode-SclUkqPt.js} +1 -1
  274. package/dist/web/assets/{external-link-D_nBEDFO.js → external-link-CVXsNeO3.js} +1 -1
  275. package/dist/web/assets/{folder-open-tD5Lle1M.js → folder-open-MnOmh19D.js} +1 -1
  276. package/dist/web/assets/{folder-plus-DlZ4hM48.js → folder-plus-BRddLBtO.js} +1 -1
  277. package/dist/web/assets/{git-commit-horizontal-g8KBhvfr.js → git-commit-horizontal-Bm4rkXug.js} +1 -1
  278. package/dist/web/assets/{htmlMode-Do72TyNy.js → htmlMode-X3mQtOeh.js} +1 -1
  279. package/dist/web/assets/icons-CZxmQtZs.js +1 -0
  280. package/dist/web/assets/{image-CUZMnZYi.js → image-BViGUAiq.js} +1 -1
  281. package/dist/web/assets/{index-D7igQSAg.js → index-LXNhSUEL.js} +2 -2
  282. package/dist/web/assets/{info-SmuBZiE5.js → info-DYPIbKKD.js} +1 -1
  283. package/dist/web/assets/intake-contracts-wCkD2ErR.js +1 -0
  284. package/dist/web/assets/{jsonMode-B2N7W15Y.js → jsonMode-BoKiIdHd.js} +1 -1
  285. package/dist/web/assets/loader-circle-JFgFNsP5.js +1 -0
  286. package/dist/web/assets/{lspLanguageFeatures-DPmyOFVA.js → lspLanguageFeatures-CO2mzpy1.js} +1 -1
  287. package/dist/web/assets/{maximize-2-B8HN3jsA.js → maximize-2-DXZCQO0b.js} +1 -1
  288. package/dist/web/assets/{message-square-CrDvzn66.js → message-square-cOCAL8J1.js} +1 -1
  289. package/dist/web/assets/{monaco.contribution-CRdTg0FH.js → monaco.contribution-C7CAQIKF.js} +2 -2
  290. package/dist/web/assets/{monaco.contribution-BfOxF9PJ.js → monaco.contribution-CVe3mWSY.js} +2 -2
  291. package/dist/web/assets/{monaco.contribution-DNONXznc.js → monaco.contribution-hrusiaZi.js} +2 -2
  292. package/dist/web/assets/{monaco.contribution-DqqJBDzF.js → monaco.contribution-wacA5FjV.js} +2 -2
  293. package/dist/web/assets/{monitor-CW-M_aaj.js → monitor-B35XSAvn.js} +1 -1
  294. package/dist/web/assets/{paperclip-DL449Io5.js → paperclip-CKgDxioG.js} +1 -1
  295. package/dist/web/assets/{pdf-BCq2Oosd.js → pdf-Ct3M2mVw.js} +1 -1
  296. package/dist/web/assets/play-DzqLr7fM.js +1 -0
  297. package/dist/web/assets/plus-Ddp1vXnw.js +1 -0
  298. package/dist/web/assets/{ponder-desktop-Dm7tOkKo.js → ponder-desktop-D-zB6X4L.js} +1 -1
  299. package/dist/web/assets/{presentation-CupIXaYv.js → presentation-B0S9v7ib.js} +1 -1
  300. package/dist/web/assets/{profile-ref-DSNkG6Ol.js → profile-ref-CCxrOCio.js} +1 -1
  301. package/dist/web/assets/{python-DuGMr666.js → python-C0-pUUAU.js} +1 -1
  302. package/dist/web/assets/{refresh-cw-CzVf5_oo.js → refresh-cw-D45mW-vs.js} +1 -1
  303. package/dist/web/assets/{requests-BCbaFiqV.js → requests-DjSt-duM.js} +1 -1
  304. package/dist/web/assets/{reward-checks-Bcq9ETCA.js → reward-checks-D139zwha.js} +2 -2
  305. package/dist/web/assets/{save-DatjrYPV.js → save-Gu4R_82E.js} +1 -1
  306. package/dist/web/assets/schemas-C9IwV7NS.js +64 -0
  307. package/dist/web/assets/{settings-D7C-Auyi.js → settings-DdonLCIN.js} +1 -1
  308. package/dist/web/assets/settings-lists-CFHFtO0D.js +5 -0
  309. package/dist/web/assets/square-Dqduqyyu.js +1 -0
  310. package/dist/web/assets/{square-terminal-Buj-s-fz.js → square-terminal-DS3zwi6X.js} +1 -1
  311. package/dist/web/assets/{submit-issue-command-wfngGS6Y.js → submit-issue-command-Gk3RKrY-.js} +1 -1
  312. package/dist/web/assets/{toggleHighContrast-cl0cw2QK.js → toggleHighContrast-BnYUBgZB.js} +1 -1
  313. package/dist/web/assets/training-QBuGBGJd.js +2 -0
  314. package/dist/web/assets/{training-model-data-CWnu1bz9.js → training-model-data-CxR3xpmK.js} +1 -1
  315. package/dist/web/assets/{tsMode-DLEc0PYL.js → tsMode-BVNyOY8h.js} +1 -1
  316. package/dist/web/assets/{upload-DaFVH6R1.js → upload-ABSJxuUM.js} +1 -1
  317. package/dist/web/assets/{useAccountSettings-ByxjI9BG.js → useAccountSettings-4_XfwJQi.js} +1 -1
  318. package/dist/web/assets/{useAgentInventory-Df64T07n.js → useAgentInventory-CVuamyT3.js} +1 -1
  319. package/dist/web/assets/{useLocalAgentSchedules-DNh_x9gQ.js → useLocalAgentSchedules-CmwN4ohy.js} +1 -1
  320. package/dist/web/assets/{useQuery-yUz7Ui8g.js → useQuery-CCjwL8VI.js} +1 -1
  321. package/dist/web/assets/{wifi-off-CtNwnIJc.js → wifi-off-DGJH7Pke.js} +1 -1
  322. package/dist/web/assets/{work-outputs-CK0nHe4g.js → work-outputs-CnbRtTLg.js} +1 -1
  323. package/dist/web/assets/{workers-CnqrOtic.js → workers-CjtQ2aBD.js} +1 -1
  324. package/dist/web/assets/x-B-_zJVOZ.js +1 -0
  325. package/dist/web/assets/{yaml-C9vtYV4w.js → yaml-N1KUjBZ8.js} +1 -1
  326. package/dist/web/index.html +1 -1
  327. package/docs/command-reference.md +7 -1
  328. package/package.json +1 -1
  329. package/dist/chunks/chunk-2ZNW6GUU.js +0 -2
  330. package/dist/chunks/chunk-3MVKXAH7.js +0 -2
  331. package/dist/chunks/chunk-G4E3WGLM.js +0 -13
  332. package/dist/chunks/chunk-I3NYYOSS.js +0 -2
  333. package/dist/chunks/chunk-JBFPTEVE.js +0 -2
  334. package/dist/chunks/chunk-OW3EOC5Q.js +0 -4
  335. package/dist/chunks/chunk-SBQ6KLXB.js +0 -33
  336. package/dist/chunks/chunk-YBKDEEEH.js +0 -2
  337. package/dist/chunks/cli-TE7RP5H7.js +0 -2
  338. package/dist/chunks/command-NW6BGKOM.js +0 -13
  339. package/dist/chunks/dist-J4KHAVO3.js +0 -2
  340. package/dist/chunks/host-profile-evaluation-tools-75EPCRSZ.js +0 -2
  341. package/dist/chunks/hosted-harness-runtime-3AJGEIFD.js +0 -2
  342. package/dist/chunks/javascript-isolate-process-source-ZPQKKLR4.js +0 -2
  343. package/dist/chunks/javascript-verifier-worker-source-F3LSGPOY.js +0 -2
  344. package/dist/chunks/learning-NJLTGZFQ.js +0 -2
  345. package/dist/chunks/setup-TXEM2QSG.js +0 -2
  346. package/dist/chunks/training-hosted-checkpoint-evaluation-UXFW33QL.js +0 -2
  347. package/dist/chunks/training-hosted-report-UVGTPDOK.js +0 -2
  348. package/dist/chunks/training-hosted-serving-report-J4YOZLRP.js +0 -2
  349. package/dist/chunks/training-hosted-workers-6JTDCCWA.js +0 -2
  350. package/dist/web/assets/App-CNQi3RlI.js +0 -53
  351. package/dist/web/assets/AppTerminalPanel-DLz34eSs.js +0 -2
  352. package/dist/web/assets/AppsView-DkCMr67-.js +0 -1
  353. package/dist/web/assets/HostedModelLearningSettings-BYl-2j7B.js +0 -1
  354. package/dist/web/assets/LabsRoute-DJRgF1kQ.js +0 -101
  355. package/dist/web/assets/MainChatThread-gwmhe1Nw.js +0 -2
  356. package/dist/web/assets/MainPane-CqtgV9rU.js +0 -10
  357. package/dist/web/assets/NativeSetupTerminal-DrQldDsG.js +0 -2
  358. package/dist/web/assets/RightSidebarHomePanel-BDmIxvIm.js +0 -1
  359. package/dist/web/assets/WorkSidebarPanel-D3Ub_jVj.js +0 -1
  360. package/dist/web/assets/chat-resources-CTN4f6KC.js +0 -1
  361. package/dist/web/assets/chevron-right-CpbCIUFo.js +0 -1
  362. package/dist/web/assets/chunk-GJRXJL6G-pJp1DyJd.js +0 -9
  363. package/dist/web/assets/chunk-H3JZ3P5T-B0SCoPw4.js +0 -2
  364. package/dist/web/assets/chunk-TLSP5JKG-DZmxtX-4.js +0 -1
  365. package/dist/web/assets/contracts-BLiqJxBv.js +0 -1
  366. package/dist/web/assets/icons-B8_Rkg-l.js +0 -1
  367. package/dist/web/assets/intake-contracts-BW0Y0C2R.js +0 -1
  368. package/dist/web/assets/loader-circle-D_KVxLLz.js +0 -1
  369. package/dist/web/assets/play-DYLqBrwg.js +0 -1
  370. package/dist/web/assets/plus-DXZIpQuY.js +0 -1
  371. package/dist/web/assets/schemas-lO3MoWQr.js +0 -64
  372. package/dist/web/assets/settings-lists-D2ol3uNK.js +0 -5
  373. package/dist/web/assets/square-BWB1nbZF.js +0 -1
  374. package/dist/web/assets/training-DCdoHJ0Y.js +0 -2
  375. package/dist/web/assets/x-Bhl-4Zlt.js +0 -1
@@ -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-ZU3YBRXS.js";import{b as W}from"./chunk-L3KS6MOV.js";import{k as P}from"./chunk-4V73I4OL.js";import{e as A,f as x,g as D,l as I}from"./chunk-LE75SVEL.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=A.parse(e.overlay),t=x.parse(e.proposal),o=e.validations.map(h=>D.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=W(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-CSU7RDA5.js";import{b as W}from"./chunk-L3KS6MOV.js";import{k as P}from"./chunk-4V73I4OL.js";import{e as A,f as x,g as D,l as I}from"./chunk-LE75SVEL.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=A.parse(e.overlay),t=x.parse(e.proposal),o=e.validations.map(h=>D.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=W(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};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{hb as _,kb as C}from"./chunk-WLZJOCLA.js";import{f as R,m}from"./chunk-HIQPGYVH.js";import{Sa as A}from"./chunk-ZY32SZ2P.js";import{A as e}from"./chunk-X2J2P5ZT.js";import{a as l}from"./chunk-FTQLQJQV.js";var u=e.string().trim().min(1).max(200),P=e.object({operationId:u,execution:R,executionKind:e.literal("recorded_evidence").optional(),graders:e.array(A).min(1).max(100),maximumCostUsd:e.number().finite().min(1e-6).max(1e4),mappings:e.array(e.object({graderId:u,fields:_}).strict()).max(100).optional()}).strict().superRefine((a,n)=>{new Set(a.graders.map(o=>o.id)).size!==a.graders.length&&n.addIssue({code:"custom",path:["graders"],message:"Select each grader once."}),a.mappings&&(new Set(a.mappings.map(o=>o.graderId)).size!==a.mappings.length||a.mappings.some(o=>!a.graders.some(c=>c.id===o.graderId)))&&n.addIssue({code:"custom",path:["mappings"],message:"Map each selected grader at most once."})}),q=e.object({schemaVersion:e.literal("openpond.experimentScoringPass.v1"),id:u,teamId:u,revision:e.number().int().positive(),request:P,graders:e.array(C).min(1).max(100),status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]),totalCount:e.number().int().min(1).max(1e4),counts:e.object({pending:e.number().int().nonnegative(),running:e.number().int().nonnegative(),scored:e.number().int().nonnegative(),unavailable:e.number().int().nonnegative(),failed:e.number().int().nonnegative(),cancelled:e.number().int().nonnegative()}).strict(),resultAvailable:e.boolean(),createdAt:e.iso.datetime(),startedAt:e.iso.datetime().nullable(),completedAt:e.iso.datetime().nullable(),error:e.object({code:u,message:e.string().max(2e3)}).strict().nullable()}).strict(),L=q.extend({contentHash:e.string().regex(/^[a-f0-9]{64}$/)});function O(a){let n=L.parse(a),{contentHash:o,...c}=n;if(m(c)!==o||Object.values(n.counts).reduce((r,d)=>r+d,0)!==n.totalCount)throw new Error("Scoring pass integrity or population accounting failed.");let t=["completed","failed","cancelled"].includes(n.status);if(t&&(!n.completedAt||n.counts.pending||n.counts.running)||!t&&(n.completedAt!==null||n.resultAvailable)||n.status==="completed"&&!n.resultAvailable)throw new Error("Scoring pass lifecycle differs from its retained result.");if(n.graders.length!==n.request.graders.length||new Set(n.graders.map(r=>r.feedbackKey)).size!==n.graders.length||n.graders.some((r,d)=>m(r.release)!==m(n.request.graders[d])||m(r.mappings??[])!==m(n.request.mappings?.find(f=>f.graderId===r.release?.id)?.fields??[])))throw new Error("Scoring pass graders differ from their exact admission.");return n}l(O,"verifyExperimentScoringPass");var I=8388608;async function B(a,n,o,c){let t=new AbortController,r=o.signal,d=l(()=>t.abort(r?.reason),"forward");r?.aborted?d():r?.addEventListener("abort",d,{once:!0});let f=setTimeout(()=>t.abort(new Error("Connected evidence request timed out.")),6e4),s,h=l(()=>{s&&s.cancel(t.signal.reason).catch(()=>{})},"abortReader");t.signal.addEventListener("abort",h,{once:!0});let v=new Promise((w,g)=>{let p=l(()=>g(t.signal.reason??new DOMException("Request aborted","AbortError")),"abort");t.signal.aborted?p():t.signal.addEventListener("abort",p,{once:!0})});try{let w=a(n,{...o,signal:t.signal}).then(i=>{if(t.signal.aborted)throw i.body?.cancel(t.signal.reason).catch(()=>{}),t.signal.reason;return i}),g=await Promise.race([w,v]),p=g.headers.get("content-length");if(s=g.body?.getReader(),t.signal.aborted)throw await s?.cancel(t.signal.reason),t.signal.reason;if(p&&Number(p)>I)throw await s?.cancel(),c(502,"connected_response_too_large","Connected evidence response exceeds 8 MiB.");let x=[],b=0;if(s)for(;;){let i=await Promise.race([s.read(),v]);if(i.done)break;if(b+=i.value.byteLength,b>I)throw await s.cancel(),c(502,"connected_response_too_large","Connected evidence response exceeds 8 MiB.");x.push(i.value)}let S=new Uint8Array(b),E=0;for(let i of x)S.set(i,E),E+=i.byteLength;let y;try{y=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(S))}catch{throw c(502,"connected_response_invalid","Connected evidence response is not valid JSON.")}return{response:g,value:y}}finally{clearTimeout(f),r?.removeEventListener("abort",d),t.signal.removeEventListener("abort",h),s?.releaseLock()}}l(B,"fetchConnectedJson");export{P as a,O as b,B as c};
2
+ import{hb as _,kb as C}from"./chunk-5ZNE43XC.js";import{f as R,m}from"./chunk-HIQPGYVH.js";import{Sa as A}from"./chunk-ZY32SZ2P.js";import{A as e}from"./chunk-X2J2P5ZT.js";import{a as l}from"./chunk-FTQLQJQV.js";var u=e.string().trim().min(1).max(200),P=e.object({operationId:u,execution:R,executionKind:e.literal("recorded_evidence").optional(),graders:e.array(A).min(1).max(100),maximumCostUsd:e.number().finite().min(1e-6).max(1e4),mappings:e.array(e.object({graderId:u,fields:_}).strict()).max(100).optional()}).strict().superRefine((a,n)=>{new Set(a.graders.map(o=>o.id)).size!==a.graders.length&&n.addIssue({code:"custom",path:["graders"],message:"Select each grader once."}),a.mappings&&(new Set(a.mappings.map(o=>o.graderId)).size!==a.mappings.length||a.mappings.some(o=>!a.graders.some(c=>c.id===o.graderId)))&&n.addIssue({code:"custom",path:["mappings"],message:"Map each selected grader at most once."})}),q=e.object({schemaVersion:e.literal("openpond.experimentScoringPass.v1"),id:u,teamId:u,revision:e.number().int().positive(),request:P,graders:e.array(C).min(1).max(100),status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]),totalCount:e.number().int().min(1).max(1e4),counts:e.object({pending:e.number().int().nonnegative(),running:e.number().int().nonnegative(),scored:e.number().int().nonnegative(),unavailable:e.number().int().nonnegative(),failed:e.number().int().nonnegative(),cancelled:e.number().int().nonnegative()}).strict(),resultAvailable:e.boolean(),createdAt:e.iso.datetime(),startedAt:e.iso.datetime().nullable(),completedAt:e.iso.datetime().nullable(),error:e.object({code:u,message:e.string().max(2e3)}).strict().nullable()}).strict(),L=q.extend({contentHash:e.string().regex(/^[a-f0-9]{64}$/)});function O(a){let n=L.parse(a),{contentHash:o,...c}=n;if(m(c)!==o||Object.values(n.counts).reduce((r,d)=>r+d,0)!==n.totalCount)throw new Error("Scoring pass integrity or population accounting failed.");let t=["completed","failed","cancelled"].includes(n.status);if(t&&(!n.completedAt||n.counts.pending||n.counts.running)||!t&&(n.completedAt!==null||n.resultAvailable)||n.status==="completed"&&!n.resultAvailable)throw new Error("Scoring pass lifecycle differs from its retained result.");if(n.graders.length!==n.request.graders.length||new Set(n.graders.map(r=>r.feedbackKey)).size!==n.graders.length||n.graders.some((r,d)=>m(r.release)!==m(n.request.graders[d])||m(r.mappings??[])!==m(n.request.mappings?.find(f=>f.graderId===r.release?.id)?.fields??[])))throw new Error("Scoring pass graders differ from their exact admission.");return n}l(O,"verifyExperimentScoringPass");var I=8388608;async function B(a,n,o,c){let t=new AbortController,r=o.signal,d=l(()=>t.abort(r?.reason),"forward");r?.aborted?d():r?.addEventListener("abort",d,{once:!0});let f=setTimeout(()=>t.abort(new Error("Connected evidence request timed out.")),6e4),s,h=l(()=>{s&&s.cancel(t.signal.reason).catch(()=>{})},"abortReader");t.signal.addEventListener("abort",h,{once:!0});let v=new Promise((w,g)=>{let p=l(()=>g(t.signal.reason??new DOMException("Request aborted","AbortError")),"abort");t.signal.aborted?p():t.signal.addEventListener("abort",p,{once:!0})});try{let w=a(n,{...o,signal:t.signal}).then(i=>{if(t.signal.aborted)throw i.body?.cancel(t.signal.reason).catch(()=>{}),t.signal.reason;return i}),g=await Promise.race([w,v]),p=g.headers.get("content-length");if(s=g.body?.getReader(),t.signal.aborted)throw await s?.cancel(t.signal.reason),t.signal.reason;if(p&&Number(p)>I)throw await s?.cancel(),c(502,"connected_response_too_large","Connected evidence response exceeds 8 MiB.");let x=[],b=0;if(s)for(;;){let i=await Promise.race([s.read(),v]);if(i.done)break;if(b+=i.value.byteLength,b>I)throw await s.cancel(),c(502,"connected_response_too_large","Connected evidence response exceeds 8 MiB.");x.push(i.value)}let S=new Uint8Array(b),E=0;for(let i of x)S.set(i,E),E+=i.byteLength;let y;try{y=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(S))}catch{throw c(502,"connected_response_invalid","Connected evidence response is not valid JSON.")}return{response:g,value:y}}finally{clearTimeout(f),r?.removeEventListener("abort",d),t.signal.removeEventListener("abort",h),s?.releaseLock()}}l(B,"fetchConnectedJson");export{P as a,O as b,B as c};
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{h as a}from"./chunk-3MVKXAH7.js";import{Xb as d,_b as p}from"./chunk-MVPKU72J.js";import{a as o}from"./chunk-FTQLQJQV.js";function g(n,e,t,i){let s=n.get(`SELECT payload,package_payload FROM local_experiment_definitions WHERE team_id=? AND id=? ${i===void 0?"ORDER BY revision DESC LIMIT 1":"AND revision=?"}`,i===void 0?[e,t]:[e,t,i]);if(!s)throw new a("local_definition_not_found","Local Experiment definition is unavailable in this workspace.",404);return{definition:d.parse(JSON.parse(s.payload)),package:JSON.parse(s.package_payload)}}o(g,"localDefinition");function _(n,e,t){let i=n.get("SELECT payload FROM local_experiment_executions WHERE team_id=? AND id=?",[e,t]);if(!i)throw new a("local_execution_not_found","Local Experiment execution is unavailable in this workspace.",404);return p.parse(JSON.parse(i.payload))}o(_,"localExecution");function f(n,e,t){return n.all("SELECT receipt_id,status,admission,result,error FROM local_experiment_cases WHERE team_id=? AND execution_id=? ORDER BY ordinal",[e,t]).map(i=>({receiptId:i.receipt_id,status:i.status,admission:JSON.parse(i.admission),result:i.result?JSON.parse(i.result):null,error:i.error}))}o(f,"localCases");function L(n,e,t,i={}){let s=_(n,e,t),c={pending:0,running:0,completed:0,failed:0,cancelled:0,unknown:0};for(let u of n.all("SELECT status,COUNT(*) AS count FROM local_experiment_cases WHERE team_id=? AND execution_id=? GROUP BY status",[e,t]))c[u.status]=u.count;let r=n.get(`SELECT COALESCE(SUM(CASE WHEN status='settled' THEN cost_usd ELSE 0 END),0) AS spent,
2
+ import{h as a}from"./chunk-R5GRESW3.js";import{Xb as d,_b as p}from"./chunk-CJDGLPNX.js";import{a as o}from"./chunk-FTQLQJQV.js";function g(n,e,t,i){let s=n.get(`SELECT payload,package_payload FROM local_experiment_definitions WHERE team_id=? AND id=? ${i===void 0?"ORDER BY revision DESC LIMIT 1":"AND revision=?"}`,i===void 0?[e,t]:[e,t,i]);if(!s)throw new a("local_definition_not_found","Local Experiment definition is unavailable in this workspace.",404);return{definition:d.parse(JSON.parse(s.payload)),package:JSON.parse(s.package_payload)}}o(g,"localDefinition");function _(n,e,t){let i=n.get("SELECT payload FROM local_experiment_executions WHERE team_id=? AND id=?",[e,t]);if(!i)throw new a("local_execution_not_found","Local Experiment execution is unavailable in this workspace.",404);return p.parse(JSON.parse(i.payload))}o(_,"localExecution");function f(n,e,t){return n.all("SELECT receipt_id,status,admission,result,error FROM local_experiment_cases WHERE team_id=? AND execution_id=? ORDER BY ordinal",[e,t]).map(i=>({receiptId:i.receipt_id,status:i.status,admission:JSON.parse(i.admission),result:i.result?JSON.parse(i.result):null,error:i.error}))}o(f,"localCases");function L(n,e,t,i={}){let s=_(n,e,t),c={pending:0,running:0,completed:0,failed:0,cancelled:0,unknown:0};for(let u of n.all("SELECT status,COUNT(*) AS count FROM local_experiment_cases WHERE team_id=? AND execution_id=? GROUP BY status",[e,t]))c[u.status]=u.count;let r=n.get(`SELECT COALESCE(SUM(CASE WHEN status='settled' THEN cost_usd ELSE 0 END),0) AS spent,
3
3
  COALESCE(SUM(CASE WHEN status IN ('reserved','dispatched','unknown') THEN maximum_usd ELSE 0 END),0) AS held,
4
4
  COALESCE(SUM(CASE WHEN status IN ('dispatched','unknown') THEN 1 ELSE 0 END),0) AS uncertain FROM local_experiment_charges WHERE team_id=? AND execution_id=?`,[e,t]),l=p.parse({...s,...i,counts:c,usage:{knownCostUsd:r.spent,costUsd:r.uncertain?null:r.spent,heldUsd:r.held,uncertainRequests:r.uncertain}});return n.run("UPDATE local_experiment_executions SET payload=? WHERE team_id=? AND id=?",[JSON.stringify(l),e,t]),l}o(L,"refreshLocalExecution");function O(n,e,t,i,s,c){let r=n.get("SELECT kind,intent_hash,receipt FROM local_experiment_operations WHERE team_id=? AND operation_id=?",[e,t]);if(r){if(r.kind!==i||r.intent_hash!==s)throw new a("local_operation_conflict","This operation already owns different immutable inputs.");return JSON.parse(r.receipt)}let l=c();return n.run("INSERT INTO local_experiment_operations(team_id,operation_id,kind,intent_hash,receipt) VALUES(?,?,?,?,?)",[e,t,i,s,JSON.stringify(l)]),l}o(O,"localOperation");function w(n,e,t){n.run("INSERT INTO local_experiment_definitions(team_id,id,revision,content_hash,project_id,payload,package_payload) VALUES(?,?,?,?,?,?,?)",[e.teamId,e.id,e.revision,e.contentHash,e.configuration.request.project?.id??null,JSON.stringify(e),JSON.stringify(t)])}o(w,"writeLocalDefinition");var E=15e3;function T(n,e,t){let i=n.get("SELECT owner_id,pid,lease_until FROM local_experiment_owner WHERE singleton=1");if(i&&i.owner_id!==e&&S(i.pid))throw new a("local_runtime_already_owned","Another live local server owns Experiment execution in this installation.");n.run("INSERT INTO local_experiment_owner(singleton,owner_id,pid,lease_until) VALUES(1,?,?,?) ON CONFLICT(singleton) DO UPDATE SET owner_id=excluded.owner_id,pid=excluded.pid,lease_until=excluded.lease_until",[e,t,Date.now()+E])}o(T,"claimLocalExperimentOwner");function m(n,e){let t=n.get("SELECT owner_id,pid FROM local_experiment_owner WHERE singleton=1");if(!t||t.owner_id!==e||t.pid!==process.pid)throw new a("local_runtime_lease_lost","This process no longer owns local Experiment execution.")}o(m,"requireLocalRuntimeOwner");function R(n,e){m(n,e),n.run("UPDATE local_experiment_owner SET lease_until=? WHERE singleton=1 AND owner_id=?",[Date.now()+E,e])}o(R,"renewLocalExperimentOwner");function S(n){if(!Number.isSafeInteger(n)||n<=0)return!0;try{return process.kill(n,0),!0}catch(e){return!(e instanceof Error&&"code"in e&&e.code==="ESRCH")}}o(S,"alive");export{g as a,_ as b,f as c,L as d,O as e,w as f,T as g,m as h,R as i};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{t as l}from"./chunk-Y3B6ZUE6.js";import{a as f}from"./chunk-FTQLQJQV.js";function d(e,s){let{tasks:r,paths:i,policyPaths:c}=p(e.draft,s),o=e.draft.metadata.portableFileInventory,n=e.files.filter(a=>!c.has(a.path)||i.has(a.path)),t=new Set(n.map(a=>a.path));return l({schemaVersion:e.schemaVersion,files:n,draft:{...e.draft,tasks:r,metadata:{...e.draft.metadata,...Array.isArray(o)?{portableFileInventory:o.filter(a=>t.has(a.sourcePath))}:{},localDatasetTaskIds:s}}},Number.POSITIVE_INFINITY)}f(d,"projectLocalDatasetWorkspace");function p(e,s){let r=new Set(s);if(!r.size||r.size!==s.length||s.some(t=>!e.tasks.some(a=>a.id===t)))throw new Error("Select distinct existing local Dataset tasks.");for(let t of e.graderFixtures)r.add(t.taskId);let i=e.tasks.filter(t=>r.has(t.id)),c=new Set(i.flatMap(t=>(t.assets??[]).map(a=>a.artifactRef)));for(let t of e.environment.resources??[])t.kind==="file"&&c.add(t.path);let o=e.metadata.portableFileInventory,n=new Set;if(Array.isArray(o))for(let t of o)t.asset?.visibility==="policy"&&n.add(t.sourcePath);return{tasks:i,paths:c,policyPaths:n}}f(p,"localDatasetProjectionPaths");export{d as a,p as b};
2
+ import{t as l}from"./chunk-QOUOU7FE.js";import{a as f}from"./chunk-FTQLQJQV.js";function d(e,s){let{tasks:r,paths:i,policyPaths:c}=p(e.draft,s),o=e.draft.metadata.portableFileInventory,n=e.files.filter(a=>!c.has(a.path)||i.has(a.path)),t=new Set(n.map(a=>a.path));return l({schemaVersion:e.schemaVersion,files:n,draft:{...e.draft,tasks:r,metadata:{...e.draft.metadata,...Array.isArray(o)?{portableFileInventory:o.filter(a=>t.has(a.sourcePath))}:{},localDatasetTaskIds:s}}},Number.POSITIVE_INFINITY)}f(d,"projectLocalDatasetWorkspace");function p(e,s){let r=new Set(s);if(!r.size||r.size!==s.length||s.some(t=>!e.tasks.some(a=>a.id===t)))throw new Error("Select distinct existing local Dataset tasks.");for(let t of e.graderFixtures)r.add(t.taskId);let i=e.tasks.filter(t=>r.has(t.id)),c=new Set(i.flatMap(t=>(t.assets??[]).map(a=>a.artifactRef)));for(let t of e.environment.resources??[])t.kind==="file"&&c.add(t.path);let o=e.metadata.portableFileInventory,n=new Set;if(Array.isArray(o))for(let t of o)t.asset?.visibility==="policy"&&n.add(t.sourcePath);return{tasks:i,paths:c,policyPaths:n}}f(p,"localDatasetProjectionPaths");export{d as a,p as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{e as ut}from"./chunk-RRWL5BHZ.js";import{c as dt}from"./chunk-NXN7GJOH.js";import{a as A,b as $,c as be,d as p,e as b,f as ie,g as pt,l as xe}from"./chunk-5WPMI6QX.js";import{d as he,e as q,f as fe,g as d,h as y,j as u,k}from"./chunk-5HPZGLOL.js";import{f as ct,ob as mt,qb as ne}from"./chunk-QAFXQHHG.js";import{$b as rt,C as tt,E as nt,H as it,b as U,hc as ot,kc as st,o as Ze,s as et,tb as at}from"./chunk-G4E3WGLM.js";import{Ka as te,Na as Le,Ra as Qe,W as Be,Wa as Fe,Za as Ke,bb as We,fb as Xe,l as Ne,lb as Ye,oa as ee,va as ge}from"./chunk-ZY32SZ2P.js";import{t as $e,v as Ve}from"./chunk-OTDDXEQ6.js";import{g as ue,k as Je,n as w,o as le}from"./chunk-RCT3O3HQ.js";import{A as e}from"./chunk-X2J2P5ZT.js";import{a as s}from"./chunk-FTQLQJQV.js";var lt=e.string().trim().min(1).max(240),an=e.string().trim().min(8).max(256),z=e.object({schemaVersion:e.literal("openpond.sftRecipe.v1"),method:e.literal("sft"),parameterization:e.literal("lora"),baseModel:e.object({id:lt,revision:e.string().trim().min(1).max(256),tokenizerRevision:e.string().trim().min(1).max(256),chatTemplateHash:an}),dataset:e.object({trainSplit:e.literal("train"),validationSplit:e.enum(["validation","frozen_eval"]),completionOnly:e.boolean(),maxSequenceLength:e.number().int().positive().max(32768),maxExamples:e.number().int().positive().max(1e5).default(1e3),selectionStrategy:e.literal("stable_hash_top_n").default("stable_hash_top_n"),selectionSeed:e.number().int().default(17)}),lora:e.object({rank:e.number().int().positive().max(256),alpha:e.number().positive().max(1024),dropout:e.number().min(0).max(1),targetModules:e.array(lt).min(1).max(100)}),optimizer:e.object({learningRate:e.number().positive(),epochs:e.number().positive().max(100),maxSteps:e.number().int().positive().max(1e6),batchSize:e.number().int().positive().max(1e4),gradientAccumulationSteps:e.number().int().positive().max(1e4),seed:e.number().int()}),resourceLimits:e.object({cpuThreads:e.number().int().positive().max(256),memoryBytes:e.number().int().positive(),wallTimeMs:e.number().int().positive()})}),rn=z.safeExtend({dataset:z.shape.dataset.safeExtend({completionOnly:e.literal(!0),maxSequenceLength:e.number().int().min(2).max(8192),maxExamples:e.number().int().min(1).max(1e3).default(1e3)}),lora:z.shape.lora.safeExtend({rank:e.number().int().min(1).max(64),dropout:e.number().min(0).lt(1),targetModules:e.array(e.enum(["q_proj","k_proj","v_proj","o_proj","gate_proj","up_proj","down_proj"])).min(1).max(7)}),optimizer:z.shape.optimizer.safeExtend({learningRate:e.number().positive().max(.001),epochs:e.number().positive().max(10),maxSteps:e.number().int().min(1).max(128),batchSize:e.number().int().min(1).max(32),gradientAccumulationSteps:e.number().int().min(1).max(32),seed:e.number().int().min(-(2**31)).max(2**31-1)}),resourceLimits:z.shape.resourceLimits.safeExtend({wallTimeMs:e.number().int().min(1e3).max(216e5)})}).superRefine((t,n)=>{t.optimizer.batchSize*t.optimizer.gradientAccumulationSteps>32&&n.addIssue({code:"custom",path:["optimizer"],message:"Managed SFT supports at most 32 accumulated examples."}),new Set(t.lora.targetModules).size!==t.lora.targetModules.length&&n.addIssue({code:"custom",path:["lora","targetModules"],message:"Adapter target modules must be unique."})});var C=e.string().trim().min(1).max(240),ye=p.extend({revision:e.number().int().positive()}).strict(),gt=ye.extend({teamId:C,jobId:C,plan:p,baseline:p,candidate:p,state:ot.shape.state,updatedAt:e.string().datetime()}).strict(),ht=e.object({schemaVersion:e.literal("openpond.trainingAcceptanceGroupPage.v1"),teamId:C,jobId:C,groups:e.array(gt).max(100),nextCursor:C.nullable()}).strict(),ft=e.object({cursor:C.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict();function bt(t){let n=s(i=>(C.parse(i.teamId),`/v1/training/jobs/${encodeURIComponent(C.parse(i.jobId))}/acceptance-groups`),"route");return{async acceptanceGroups(i,a={}){let r=ft.parse(a),o=new URLSearchParams({limit:String(r.limit)});r.cursor&&o.set("cursor",r.cursor);let m=ht.parse(await t(`${n(i)}?${o}`));if(m.teamId!==i.teamId||m.jobId!==i.jobId||m.groups.length>r.limit||m.groups.some(c=>c.teamId!==i.teamId||c.jobId!==i.jobId||r.cursor&&c.id<=r.cursor)||new Set(m.groups.map(c=>c.id)).size!==m.groups.length||m.nextCursor!==null&&m.nextCursor!==m.groups.at(-1)?.id)throw new d("acceptance_group_scope_mismatch","Acceptance groups do not match the requested workspace, job or cursor.");return m},async acceptanceGroup(i,a,r){let o=r?ye.parse({id:r.id,revision:r.revision,contentHash:r.contentHash}):null;if(o&&o.id!==a)throw new d("acceptance_group_identity_mismatch","The retained group reference differs from the requested group.");let m=o?`?revision=${o.revision}`:"",c=st(await t(`${n(i)}/${encodeURIComponent(C.parse(a))}${m}`));if(c.manifest.teamId!==i.teamId||c.manifest.trainingJob.id!==i.jobId||c.manifest.id!==a||o&&(c.revision!==o.revision||c.contentHash!==o.contentHash))throw new d("acceptance_group_identity_mismatch","Acceptance evidence does not match the requested workspace, job or retained revision.");return c}}}s(bt,"createTrainingAcceptanceClient");var V=e.object({id:e.string().trim().min(1).max(240),revision:e.number().int().positive(),contentHash:e.string().regex(/^[a-f0-9]{64}$/),targetId:e.string().trim().min(1).max(240).nullable()}).strict(),xt=e.array(e.object({role:e.enum(["system","user","assistant"]),content:e.string().max(1e5)}).strict()).max(100).superRefine((t,n)=>{t.reduce((i,a)=>i+a.content.length,0)>1e5&&n.addIssue({code:"custom",message:"Evaluation prompt exceeds 100,000 characters."})});var N=e.string().regex(/^[a-f0-9]{64}$/),Se=e.object({providerId:e.literal("claude-code"),configurationHash:N,executableHash:N,version:e.string().regex(/^2\.\d+\.\d+$/),capabilityHash:N,maximumRequestCostUsd:e.number().finite().positive().max(1e4),requestTimeoutMs:e.number().int().min(1e3).max(3e5),maximumTurns:e.number().int().min(1).max(100),holdOpen:e.boolean()}).strict(),oi=e.object({id:e.string().min(1).max(200),receiptId:e.string().min(1).max(200),sessionId:e.uuid(),operationId:e.string().min(1).max(200),action:e.enum(["message","seal"]),text:e.string().max(262144).optional()}).strict().superRefine((t,n)=>{t.action==="message"&&!t.text?.trim()&&n.addIssue({code:"custom",message:"A human intervention requires a message."}),t.action==="seal"&&t.text!==void 0&&n.addIssue({code:"custom",message:"Sealing does not add a prompt."})}),si=e.object({provider:e.literal("claude-code"),sessionId:e.uuid(),requestId:e.string().min(1).max(200),modelId:e.string().min(1).max(500),runtime:Se,sourceHash:N,outputHash:N,traceHash:N,runtimeEventRefs:e.array(e.string().min(1).max(200)).min(1).max(2e4),eventCount:e.number().int().positive().max(2e4),startedAt:e.iso.datetime(),completedAt:e.iso.datetime(),cleanupComplete:e.literal(!0)}).strict().superRefine((t,n)=>{(t.runtimeEventRefs.length!==t.eventCount||new Set(t.runtimeEventRefs).size!==t.eventCount)&&n.addIssue({code:"custom",message:"Process event references must match the exact retained trace population."})});var ae=e.object({providerId:e.literal("codex"),configurationHash:e.string().regex(/^[a-f0-9]{64}$/),accountHash:e.string().regex(/^[a-f0-9]{64}$/),reasoningEffort:e.enum(["low","medium","high","xhigh"]),maximumRequestCostUsd:e.number().finite().positive().max(1e4),requestTimeoutMs:e.number().int().min(1e3).max(3e5)}).strict();var yt=e.object({schemaVersion:e.literal("openpond.experimentAttemptGrade.v1"),selectionHash:e.string().regex(/^[a-f0-9]{64}$/),grades:e.array(te).min(1).max(100),score:e.number().min(0).max(1).nullable(),passed:e.boolean(),rewardEligible:e.boolean(),gradingStatus:e.enum(["scored","pending","unscorable","not_configured"]),failureClass:Je.nullable(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().superRefine((t,n)=>{let{contentHash:i,...a}=t;w(a)!==i&&n.addIssue({code:"custom",message:"Experiment grading integrity failed."});let r=t.grades.flatMap(o=>o.components);(r.length!==t.grades.length||new Set(r.map(o=>o.graderId)).size!==r.length)&&n.addIssue({code:"custom",message:"Each selected criterion requires exactly one distinct grader result."});for(let o of t.grades){let{contentHash:m,...c}=o;w(c)!==m&&n.addIssue({code:"custom",message:"A retained criterion changed."});for(let x of o.components){let{contentHash:R,...v}=x;w(v)!==R&&n.addIssue({code:"custom",message:"A retained grader result changed."})}}});var h=e.string().trim().min(1).max(200),G=e.string().regex(/^[a-f0-9]{64}$/),Te=e.discriminatedUnion("kind",[e.object({kind:e.literal("hosted_chat"),modelId:h,localRuntime:e.union([e.object({providerId:e.literal("custom-openai-compatible"),configurationHash:G,maximumRequestCostUsd:e.number().finite().positive().max(1e4),requestTimeoutMs:e.number().int().min(1e3).max(3e5)}).strict(),Se,ae]).optional(),candidate:e.object({artifactId:h,contentHash:G,preparationId:h,dispatchId:h,baseProfileId:h,workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/)}).strict().optional(),harness:Xe.optional(),messages:xt.optional(),maxOutputTokens:e.number().int().min(1).max(1e6).default(1e5),temperature:e.number().min(0).max(2).default(0),topP:e.number().gt(0).max(1).default(1)}).strict(),e.object({kind:e.literal("fixture"),fixtureId:h}).strict()]),on=e.object({schemaVersion:e.literal("openpond.modelStarterAttemptRequest.v1"),operationId:h,teamId:h,modelProjectId:h.nullable(),project:V.optional(),taskset:b,taskId:h,environmentSeed:e.number().int().min(0).max(2147483647).default(0),policy:Te}).strict(),Pi=e.object({modelProjectId:h.nullable(),taskset:b,afterTaskId:h.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),ki=e.object({modelProjectId:h.nullable(),taskset:b,available:e.boolean(),unavailableReason:e.string().max(1e3).nullable(),models:e.array(e.object({id:h,name:e.string().max(500),maximumOutputTokens:e.number().int().min(1).max(1e6).optional()}).strict()).max(200),tasks:e.array(e.object({id:h,split:Be,inputPreview:e.string().max(500),fixtures:e.array(e.object({id:h,label:e.string().max(200)}).strict()).max(1e3)}).strict()).max(100),nextCursor:h.nullable()}).strict(),re=e.object({schemaVersion:e.literal("openpond.modelStarterAttemptSummary.v1"),id:h,revision:e.number().int().positive(),request:on,status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]),policySnapshot:e.object({modelId:h,provider:h,upstreamModelId:e.string().min(1).max(500),configurationHash:G}).strict().nullable(),createdAt:e.iso.datetime(),startedAt:e.iso.datetime().nullable(),completedAt:e.iso.datetime().nullable(),cleanupComplete:e.boolean(),resultAvailable:e.boolean(),score:e.number().min(0).max(1).nullable(),gradingStatus:e.enum(["not_started","pending","scored","unscorable","not_configured"]).default("not_started"),passed:e.boolean().nullable(),outputPreview:e.string().max(500).nullable(),error:e.object({code:h,message:e.string().max(2e3)}).strict().nullable()}).strict().superRefine((t,n)=>{t.request.policy.kind==="fixture"!=(t.policySnapshot===null)&&n.addIssue({code:"custom",path:["policySnapshot"],message:"Fixture execution must not claim a model identity."}),t.status==="completed"&&(!t.cleanupComplete||!t.resultAvailable||!t.completedAt)&&n.addIssue({code:"custom",message:"Completed attempts require retained results and confirmed cleanup."})}),_i=e.object({modelProjectId:h,afterId:h.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),ji=e.object({items:e.array(re).max(100),nextCursor:h.nullable()}).strict(),Hi=e.object({schemaVersion:e.literal("openpond.modelStarterAttemptResult.v1"),attempt:re,output:e.string().max(1048576).nullable(),messages:e.array(e.record(e.string(),e.unknown())).max(4002),composition:Ke.nullable(),grade:te.nullable().optional(),experimentGrade:yt.nullable().optional(),environment:e.object({status:e.enum(["completed","budget_exhausted","cancelled","timed_out","policy_failure","environment_failure"]),collected:e.boolean(),definition:b,initialStateHash:G.nullable(),finalStateHash:G.nullable(),attemptHash:G}).strict(),native:Ye.optional(),providerRequestIds:e.array(h).max(1001),contentHash:G}).strict().superRefine((t,n)=>{let i=t.attempt.request.policy.kind==="hosted_chat"?t.attempt.request.policy.harness:void 0;!!i!=!!t.native&&n.addIssue({code:"custom",path:["native"],message:"Standalone Harness results require their exact native evidence."}),t.native&&(!i||w(i)!==w(t.native.source)||t.native.modelConfigurationHash!==t.attempt.policySnapshot?.configurationHash||t.environment.initialStateHash!==null||t.environment.finalStateHash!==null||t.environment.status==="completed"&&(!t.environment.collected||t.output===null||t.native.partialOutputAvailable||t.native.outputHash!==w(t.output)))&&n.addIssue({code:"custom",path:["native"],message:"Native evidence differs from the admitted source, model or output."}),t.experimentGrade&&((t.grade||t.composition)&&n.addIssue({code:"custom",message:"Selected Experiment grading cannot claim another grade population."}),(!["completed","failed"].includes(t.attempt.status)||!t.attempt.resultAvailable||t.attempt.score!==t.experimentGrade.score||t.attempt.gradingStatus!==t.experimentGrade.gradingStatus||t.attempt.passed!==(t.experimentGrade.score===null?null:t.experimentGrade.passed))&&n.addIssue({code:"custom",message:"Experiment grading differs from its retained attempt summary."})),t.grade&&(t.composition&&n.addIssue({code:"custom",path:["grade"],message:"An ordinary grade cannot also claim a Reward composition."}),(!["completed","failed"].includes(t.attempt.status)||!t.attempt.resultAvailable||t.attempt.score!==t.grade.score||t.attempt.gradingStatus!==t.grade.gradingStatus||t.attempt.passed!==(t.grade.score===null?null:t.grade.passed))&&n.addIssue({code:"custom",path:["grade"],message:"Ordinary grade differs from its terminal attempt summary."}))});var B=e.string().trim().min(1).max(240),ve=e.string().regex(/^[a-f0-9]{64}$/),Ie=e.object({maxOutputTokens:e.number().int().min(1).max(1e6).default(4096),temperature:e.number().min(0).max(2).default(0),topP:e.number().gt(0).max(1).default(1)}).strict();var M=e.object({kind:e.literal("hosted_harness"),modelId:B,maxOutputTokens:Ie.shape.maxOutputTokens.removeDefault().optional(),temperature:Ie.shape.temperature.removeDefault().optional(),topP:Ie.shape.topP.removeDefault().optional(),localRuntime:ae.optional(),candidate:e.object({artifactId:B,contentHash:ve,preparationId:B,dispatchId:B,baseProfileId:B,workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/)}).strict().optional(),sourceCandidate:ge.shape.sourceCandidate,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max"]).optional(),profileRepositoryId:B,source:ge,modelConfigurationHash:ve,packageHash:ve,externalDatasetBinding:ee.optional()}).strict().superRefine((t,n)=>{JSON.stringify(t.externalDatasetBinding??null)!==JSON.stringify(t.source.externalDatasetBinding??null)&&n.addIssue({code:"custom",message:"The policy and source must bind the same external Dataset recipe."}),JSON.stringify(t.sourceCandidate??null)!==JSON.stringify(t.source.sourceCandidate??null)&&n.addIssue({code:"custom",message:"The policy and prepared source must bind the same actual source candidate."})});var _=e.string().trim().min(1).max(200),St=e.string().regex(/^[a-f0-9]{64}$/),sn=e.discriminatedUnion("kind",[Te.options[0],e.object({kind:e.literal("fixture")}).strict(),M]),D=e.object({schemaVersion:e.literal("openpond.modelTasksetRunRequest.v1"),operationId:_,teamId:_,modelProjectId:_.nullable(),name:e.string().trim().min(1).max(200).optional(),project:V.optional(),taskset:b,policy:sn,population:e.array(mt).min(1).max(1e4)}).strict().superRefine((t,n)=>{new Set(t.population.map(i=>i.receiptId)).size!==t.population.length&&n.addIssue({code:"custom",path:["population"],message:"Run receipt identities must be unique."}),t.population.some(i=>i.fixtureId!==null!=(t.policy.kind==="fixture"))&&n.addIssue({code:"custom",path:["population"],message:"Only fixture runs require a fixture identity for every member."}),t.population.some(i=>!/^(0|[1-9][0-9]*)$/.test(i.seed)||Number(i.seed)>2147483647)&&n.addIssue({code:"custom",path:["population"],message:"Hosted environment seeds must be integers from 0 to 2147483647."}),t.policy.kind==="hosted_harness"&&t.modelProjectId!==null&&n.addIssue({code:"custom",path:["modelProjectId"],message:"A Harness target retains its released Profile binding separately from Model artifacts."}),t.policy.kind==="hosted_harness"&&new Set(t.population.map(i=>y([i.taskId,i.seed]))).size!==t.population.length&&n.addIssue({code:"custom",path:["population"],message:"Harness case identities must be unique for each task and seed."})}),Tt=e.object({schemaVersion:e.literal("openpond.modelTasksetRunSummary.v1"),id:_,revision:e.number().int().positive(),teamId:_,modelProjectId:_.nullable(),name:e.string().trim().min(1).max(200).optional(),project:V.optional(),operationId:_,taskset:b,policyKind:e.enum(["hosted_chat","fixture","hosted_harness"]),manifestHash:St,status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]),totalCount:e.number().int().min(1).max(1e4),counts:e.object({pending:e.number().int().nonnegative(),running:e.number().int().nonnegative(),completed:e.number().int().nonnegative(),failed:e.number().int().nonnegative(),cancelled:e.number().int().nonnegative()}).strict(),createdAt:e.iso.datetime(),startedAt:e.iso.datetime().nullable(),completedAt:e.iso.datetime().nullable(),cleanupComplete:e.boolean(),resultAvailable:e.boolean(),score:e.number().min(0).max(1).nullable(),metricName:e.string().min(1).max(240),error:e.object({code:_,message:e.string().max(2e3)}).strict().nullable()}).strict().superRefine((t,n)=>{Object.values(t.counts).reduce((i,a)=>i+a,0)!==t.totalCount&&n.addIssue({code:"custom",path:["counts"],message:"Run counts must account for the complete population."}),t.status!=="completed"&&t.score!==null&&n.addIssue({code:"custom",path:["score"],message:"Only completed evaluations publish a metric value."}),["completed","failed","cancelled"].includes(t.status)&&(!t.completedAt||t.counts.pending||t.counts.running)&&n.addIssue({code:"custom",message:"Terminal runs require complete population accounting."}),t.status==="cancelled"&&!t.cleanupComplete&&n.addIssue({code:"custom",message:"Cancelled runs require confirmed cleanup."}),t.resultAvailable&&!["completed","failed","cancelled"].includes(t.status)&&n.addIssue({code:"custom",message:"Run results require terminal population accounting."}),t.status==="completed"&&(!t.cleanupComplete||!t.resultAvailable)&&n.addIssue({code:"custom",message:"Completed evaluations require retained results and confirmed cleanup."})}),vt=e.object({summary:Tt,request:D,manifest:ne,policySnapshot:re.shape.policySnapshot}).strict(),Ki=e.object({modelProjectId:_.optional(),projectId:V.shape.id.optional(),afterId:_.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),Wi=e.object({items:e.array(Tt).max(100),nextCursor:_.nullable()}).strict(),Xi=e.object({schemaVersion:e.literal("openpond.modelTasksetRunResult.v1"),run:vt,receipts:e.array(ct).min(1).max(1e4),metric:Ne.nullable(),contentHash:St}).strict();function cn(t,n){le(n,"Taskset run manifest");let i=t.policy;if(i.kind!=="hosted_harness"||n.execution.kind!=="harness"||y(n.profileEvaluation)!==y(i.source)||y(n.execution.harnessRelease)!==y(i.source.harnessRelease)||n.metadata.profileRepositoryId!==i.profileRepositoryId||n.packageHash!==i.packageHash||n.policy.kind!=="model"||n.policy.model.provider!==(i.localRuntime?.providerId??"openpond")||n.policy.model.model!==i.modelId||n.policy.model.revision!==null||n.policy.model.artifactHash!==(i.candidate?.contentHash??null)||n.policy.model.tokenizerRevision!==null||n.policy.model.chatTemplateHash!==null||n.policy.configurationHash!==i.modelConfigurationHash||n.tasksetRelease.id!==t.taskset.id||n.tasksetRelease.contentHash!==t.taskset.contentHash||y(n.population)!==y(t.population)||n.population.some(a=>a.receiptId!==`evaluation-${w(n.profileEvaluation?.externalDatasetBinding?[n.id,a.taskId,a.seed,a.fixtureId]:[n.id,a.taskId,a.seed]).slice(0,32)}`))throw new Error("Harness evaluation differs from its admitted source, package or model configuration.")}s(cn,"verifyHarnessExperimentManifest");async function Yi(t){let n=vt.parse(t),{summary:i,request:a,manifest:r,policySnapshot:o}=n;if(le(r,"Taskset run manifest"),r.contentHash!==i.manifestHash||r.id!==i.id||r.createdAt!==i.createdAt||i.teamId!==a.teamId||i.modelProjectId!==a.modelProjectId||y(i.project??null)!==y(a.project??null)||y(r.metadata.project??null)!==y(a.project??null)||(i.name??null)!==(a.name??null)||i.operationId!==a.operationId||i.policyKind!==a.policy.kind||i.totalCount!==a.population.length||i.metricName!==r.metricPolicy.primaryMetric||y(i.taskset)!==y(a.taskset)||r.tasksetRelease.id!==a.taskset.id||r.tasksetRelease.contentHash!==a.taskset.contentHash||y(r.population)!==y(a.population))throw new Error("Evaluation run differs from its admitted request or manifest.");if(a.policy.kind==="fixture"){if(r.policy.kind!=="fixture"||o!==null)throw new Error("Fixture checks cannot claim a model identity.")}else if(a.policy.kind==="hosted_harness"){if(cn(a,r),o!==null)throw new Error("Harness evaluations retain the native host model configuration.")}else if(r.policy.kind!=="model"||!o||o.modelId!==a.policy.modelId||r.policy.model.provider!==o.provider||r.policy.model.model!==o.upstreamModelId||r.policy.model.revision!==null||r.policy.model.artifactHash!==(a.policy.candidate?.contentHash??null)||r.policy.model.tokenizerRevision!==null||r.policy.model.chatTemplateHash!==null||r.policy.configurationHash!==await u({policy:a.policy,snapshot:o}))throw new Error("Evaluation model differs from its admitted policy.");return n}s(Yi,"verifyModelTasksetRunDetails");var wt=e.string().min(1).max(200).refine(t=>!["__proto__","prototype","constructor"].includes(t),"Use an ordinary field name."),mn=e.array(wt).min(1).max(20),It=e.enum(["input","output","expectedOutput","evaluatorContext"]),pn=e.object({destination:It,path:mn,source:It,sourcePath:e.array(wt).max(20)}).strict(),Re=e.array(pn).max(100).superRefine((t,n)=>{for(let[i,a]of t.entries())t.slice(0,i).some(r=>r.destination===a.destination&&(Rt(r.path,a.path)||Rt(a.path,r.path)))&&n.addIssue({code:"custom",path:[i,"path"],message:"Mapped destination paths must not overlap."})});function Rt(t,n){return t.length<=n.length&&t.every((i,a)=>i===n[a])}s(Rt,"prefix");var T=e.string().trim().min(1).max(200),J=e.string().regex(/^[a-f0-9]{64}$/),we=e.object({id:T,revision:e.number().int().positive(),contentHash:J}).strict(),Pe=e.object({id:T,version:e.string().min(1).max(200),contentHash:J,name:e.string().trim().min(1).max(500).optional(),feedbackKey:Le,release:we.nullable(),mappings:Re.optional()}).strict(),ke=e.object({id:T,version:e.string().min(1).max(200),contentHash:J,mappings:Re}).strict(),da=e.object({operationId:T,id:T.optional(),expectedRevision:e.number().int().nonnegative(),request:D,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(ke).min(1).max(100).optional()}).strict().superRefine((t,n)=>{t.request.name||n.addIssue({code:"custom",path:["request","name"],message:"Name this Experiment before saving it."}),!!t.id!=t.expectedRevision>0&&n.addIssue({code:"custom",path:["expectedRevision"],message:"An update requires its saved definition revision."}),Math.round(t.maximumCostUsd*1e6)<1&&n.addIssue({code:"custom",path:["maximumCostUsd"],message:"The budget must be at least $0.000001."}),t.graders&&new Set(t.graders.map(i=>i.id)).size!==t.graders.length&&n.addIssue({code:"custom",path:["graders"],message:"Select each grader once."})}),dn=e.object({schemaVersion:e.literal("openpond.experimentDefinition.v1"),id:T,teamId:T,revision:e.number().int().positive(),request:D,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(Pe).min(1).max(100),createdAt:e.iso.datetime(),updatedAt:e.iso.datetime()}).strict(),ua=dn.extend({contentHash:J}),la=e.object({operationId:T,definition:we}).strict(),ga=e.object({projectId:T.optional(),datasetHash:J.optional(),search:e.string().trim().max(200).optional(),status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]).optional(),afterId:T.optional(),limit:e.number().int().min(1).max(100).default(30)}).strict(),ha=e.object({definition:we.nullable(),configurationHash:J.optional(),admissionRequestHash:J.optional(),sourceExperimentId:T.optional(),maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(Pe).min(1).max(100)}).strict().superRefine((t,n)=>{t.definition===null&&(!t.configurationHash||!t.admissionRequestHash)&&n.addIssue({code:"custom",path:["configurationHash"],message:"A flat Experiment requires its sealed configuration hash."})}),fa=e.object({operationId:T,profileRepositoryId:T,definitionId:T,modelId:T,localRuntime:M.shape.localRuntime,maxOutputTokens:M.shape.maxOutputTokens,temperature:M.shape.temperature,topP:M.shape.topP,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max"]).optional(),maximumCostUsd:e.number().finite().positive().max(1e4),externalDatasetBinding:ee.optional(),sourceCandidate:M.shape.sourceCandidate}).strict(),ba=e.object({request:D,manifest:ne,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(Pe).min(1).max(100)}).strict();var Pt=e.string().trim().min(1).max(200),_e=e.object({operationId:Pt,request:D,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(ke).min(1).max(100).optional(),sourceExperimentId:Pt.optional()}).strict().superRefine((t,n)=>{t.request.name||n.addIssue({code:"custom",path:["request","name"],message:"Name this Experiment before starting it."}),t.operationId!==t.request.operationId&&n.addIssue({code:"custom",path:["request","operationId"],message:"Use one operation identity for this Experiment."}),Math.round(t.maximumCostUsd*1e6)<1&&n.addIssue({code:"custom",path:["maximumCostUsd"],message:"The spending cap must be at least $0.000001."}),t.graders&&new Set(t.graders.map(i=>i.id)).size!==t.graders.length&&n.addIssue({code:"custom",path:["graders"],message:"Select each grader once."})});var g=e.string().trim().min(1).max(200),H=e.string().regex(/^[a-f0-9]{64}$/),oe=e.object({id:g,contentHash:H}).strict(),Aa=e.object({available:e.boolean(),reason:e.string().max(1e3).nullable(),origin:U.nullable()}).strict(),kt=e.object({schemaVersion:e.literal("openpond.postTrainingAttachment.v1"),binding:e.object({kind:e.enum(["preparation","policy"]),id:g,revision:e.number().int().positive(),contentHash:H}).strict(),projectId:g.nullable(),automatic:e.boolean(),maximumSpendUsd:e.number().finite().positive().max(1e4),experiments:e.array(e.object({id:g,configuration:_e}).strict()).min(1).max(20),acceptancePlan:rt.nullable()}).strict().superRefine((t,n)=>{if(new Set(t.experiments.map(i=>i.id)).size!==t.experiments.length&&n.addIssue({code:"custom",message:"Attach each evaluation once."}),t.experiments.reduce((i,a)=>i+a.configuration.maximumCostUsd,0)>t.maximumSpendUsd+1e-9&&n.addIssue({code:"custom",message:"Attached evaluation budgets exceed the total approved budget."}),t.experiments.some(i=>(i.configuration.request.project?.id??null)!==t.projectId)&&n.addIssue({code:"custom",message:"Attached experiments must use the training Project."}),t.acceptancePlan){let i=new Set(t.acceptancePlan.checks.map(r=>r.id));t.acceptancePlan.checks.some(r=>!t.experiments.some(o=>o.id===r.id))&&n.addIssue({code:"custom",message:"Select the frozen Experiment for each acceptance check."}),t.acceptancePlan.maximumSpendUsd+t.experiments.filter(r=>!i.has(r.id)).reduce((r,o)=>r+o.configuration.maximumCostUsd,0)>t.maximumSpendUsd+1e-9&&n.addIssue({code:"custom",message:"Paired acceptance and diagnostic ceilings exceed the approved evaluation budget."})}});var un=e.object({baseline:oe,checks:e.array(e.object({id:g,sourceRunId:g,sourceManifestHash:H,targetConfigurationHash:H,executionHash:H,populationHash:H,evaluator:oe,feedbackKey:g,output:e.enum(["boolean","score"]),unit:e.string().min(1).max(80)}).strict()).min(1).max(100)}).strict(),ln=e.enum(["waiting_for_training","ready","preparing","queued","running","cleaning","completed","failed","blocked","cancelled","budget_exhausted"]),_t=e.object({schemaVersion:e.literal("openpond.postTrainingSummary.v1"),id:g,teamId:g,jobId:g,revision:e.number().int().positive(),planHash:H,automatic:e.boolean(),candidate:oe.nullable(),state:ln,total:e.number().int().positive(),completed:e.number().int().nonnegative(),failed:e.number().int().nonnegative(),requiredOutcome:e.enum(["none","pending","passed","failed","blocked"]),reason:e.string().max(500).nullable(),groupId:g.nullable(),experimentIds:e.array(g).max(20),updatedAt:e.iso.datetime()}).strict().superRefine((t,n)=>{t.completed+t.failed>t.total&&n.addIssue({code:"custom",message:"Evaluation totals are inconsistent."}),["preparing","queued","running","cleaning","completed"].includes(t.state)&&!t.candidate&&n.addIssue({code:"custom",message:"Evaluation execution requires the exact trained candidate."})}),gn=e.object({operationId:g,expectedRevision:e.number().int().positive(),planHash:H}).strict(),hn=e.object({operationId:g,attachment:kt}).strict(),fn=e.object({id:g,teamId:g,ownerUserId:g,attachment:kt,qualification:un.nullable(),contentHash:H,createdAt:e.iso.datetime()}).strict();function bn(t){let n=fn.parse(t);if(n.contentHash!==w({attachment:n.attachment,qualification:n.qualification}))throw new Error("The retained evaluation attachment or qualification changed.");return n}s(bn,"verifyPostTrainingPlan");function jt(t){let{request:n}=t,i={accept:"application/json","content-type":"application/json"},a=s(o=>`/v1/training/jobs/${encodeURIComponent(g.parse(o))}/post-training`,"path");async function r(o,m,c){if(o===null)return null;let x=_t.parse(o);if(x.teamId!==m||x.jobId!==c)throw new d("post_training_scope_mismatch","The evaluation summary belongs to another run or workspace.");return x}return s(r,"read"),{async attach(o,m){let c=hn.parse(m),x=bn(await n("/v1/training/post-training-plans",{method:"POST",headers:i,body:JSON.stringify(c)}));if(x.teamId!==o||await u(x.attachment)!==await u(c.attachment))throw new d("post_training_plan_mismatch","The retained attachment differs from the reviewed plan.");return x},async get(o,m){return r(await n(a(m),{headers:i}),o,m)},async control(o,m,c,x){let R=gn.parse(x),v=await r(await n(`${a(m)}/${c}`,{method:"POST",headers:i,body:JSON.stringify(R)}),o,m);if(!v||v.planHash!==R.planHash)throw new d("post_training_control_mismatch","Evaluation control did not retain the approved plan.");return v}}}s(jt,"createPostTrainingClient");var Ca=e.object({teamId:g,actorId:g,projectId:g.nullable(),configuration:xe,batches:e.array(tt).max(1e4),sources:e.array(et).max(1e4),definitions:e.array(Ze).max(1e4),experiments:e.array(e.object({id:g,name:e.string().max(500),configuration:_e,graders:e.array(e.object({feedbackKey:g,name:e.string().max(500),ref:oe}).strict()).max(100)}).strict()).max(1e4)}).strict(),qa=e.enum(["prepare","start","cancel","publish","attach"]),za=e.object({teamId:g,actorId:g,configuration:xe,policy:nt,inspection:at,iterations:e.array(e.object({iteration:it,evals:_t.nullable()}).strict()).max(100),nextCursor:g.nullable()}).strict(),Ma=e.object({id:g,expectedRevision:e.number().int().positive(),policyHash:H,operationId:g,action:e.enum(["pause","resume","reserve","cancel-iteration","retry-iteration"]),iterationId:g.optional(),iterationRevision:e.number().int().positive().optional()}).strict();var K=e.string().trim().min(1).max(191),se=e.string().regex(/^[a-f0-9]{64}$/),Ht=e.object({schemaVersion:e.literal("openpond.checkpointRecoveryResourceApproval.v1"),ownerUserId:K,teamId:K,sourceJobId:K,sourceJobVersion:e.number().int().positive(),sourceInputManifestSha256:se,checkpointId:K,adapterSha256:se,resumeSha256:se,idempotencyKey:e.string().trim().min(16).max(191),approvedAt:e.iso.datetime({offset:!0}),maximumSpendUsd:e.number().positive().finite().max(30).refine(t=>Number(t.toFixed(6))===t,"Recovery spend must use whole microdollars"),maximumGpuSeconds:e.number().int().positive().max(21600),maximumWallSeconds:e.number().int().positive().max(21600)}).strict(),W=Ht.extend({approvalHash:se}).strict().superRefine((t,n)=>{t.maximumGpuSeconds>t.maximumWallSeconds&&n.addIssue({code:"custom",path:["maximumGpuSeconds"],message:"Recovery GPU duration exceeds its wall"})});async function xn(t){let n=Ht.parse(t);return W.parse({...n,approvalHash:await u(n)})}s(xn,"createTrainingCheckpointRecoveryResourceApproval");var je=e.object({resourceApproval:W.optional(),mode:e.literal("evaluation_only").optional(),evaluationGpuType:e.enum(["NVIDIA A100 80GB PCIe","NVIDIA A100-SXM4-80GB","NVIDIA H100 80GB HBM3"]).optional(),expectedVersion:e.number().int().positive(),checkpointId:K,idempotencyKey:e.string().trim().min(16).max(191),maximumSpendUsd:e.number().positive().finite(),maximumWallSeconds:e.number().int().positive().max(21600)}).strict().superRefine((t,n)=>{t.evaluationGpuType&&t.mode!=="evaluation_only"&&n.addIssue({code:"custom",path:["evaluationGpuType"],message:"GPU substitution requires explicit evaluation-only recovery"});let i=t.resourceApproval;i&&(i.sourceJobVersion!==t.expectedVersion||i.checkpointId!==t.checkpointId||i.idempotencyKey!==t.idempotencyKey||i.maximumSpendUsd!==t.maximumSpendUsd||i.maximumWallSeconds!==t.maximumWallSeconds)&&n.addIssue({code:"custom",path:["resourceApproval"],message:"Recovery resource approval does not match its request"})});var X=e.object({mode:e.literal("reuse_only"),physicalWorkerId:e.string().trim().min(1).max(191),providerPodId:e.string().trim().min(1).max(191),workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/),baseProfileSha256:e.string().regex(/^[a-f0-9]{64}$/),gpuType:e.string().trim().min(1).max(200),sourceJobId:e.string().trim().min(1).max(191),sourceInputManifestSha256:e.string().regex(/^[a-f0-9]{64}$/),ownerTeamId:e.string().trim().min(1).max(191),deadlineAt:e.string().datetime({offset:!0})}).strict();var S=e.string().trim().min(1).max(191),Y=e.string().regex(/^[a-f0-9]{64}$/),Ee=e.object({schemaVersion:e.literal("openpond.trainingPreparationRequest.v1"),teamId:S,operationId:S,projectId:S.nullable(),configuration:e.object({id:S,expectedRevision:e.number().int().positive(),expectedEtag:Y}).strict(),origin:U.optional(),batch:b,name:e.string().trim().min(1).max(191),maximumSpendUsd:e.number().finite().positive().max(1e6),gpuSelection:A.optional(),physicalPlacement:X.optional()}).strict(),Et=e.object({schemaVersion:e.literal("openpond.trainingPreparationPlan.v1"),id:S,creatorUserId:S,request:Ee,requestHash:Y,source:e.lazy(()=>Ce),submissionHash:Y,createdAt:e.string().datetime({offset:!0})}).strict(),At=Et.extend({contentHash:Y}).strict(),Ae=e.object({schemaVersion:e.literal("openpond.trainingPreparationReceipt.v1"),plan:At,revision:e.number().int().positive(),state:e.enum(["prepared","submitted","cancelled"]),jobId:S.nullable()}).strict().superRefine((t,n)=>{t.state==="submitted"!=!!t.jobId&&n.addIssue({code:"custom",path:["jobId"],message:"Only submitted preparations identify a job."})}),He=e.object({teamId:S,planHash:Y,expectedRevision:e.number().int().positive(),estimateReview:$.optional()}).strict(),Ct=e.object({projectId:S.optional(),state:e.enum(["prepared","submitted","cancelled"]).optional(),afterId:S.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),qt=e.object({schemaVersion:e.literal("openpond.trainingPreparationPage.v1"),teamId:S,items:e.array(Ae).max(100),nextCursor:S.nullable()}).strict();async function zt(t){let n=Ae.parse(t),{contentHash:i,...a}=n.plan;if(await u(a)!==i||await u(a.request)!==a.requestHash||a.source.modelProject.id!==a.request.configuration.id||await u(a.source.origin??null)!==await u(a.request.origin??null))throw new d("training_preparation_mismatch","The prepared training inputs changed.");return n}s(zt,"parseAndVerifyTrainingPreparationReceipt");function Mt(t){async function n(i,a,r){let o=await zt(i);if(o.plan.request.teamId!==a||r&&o.plan.id!==r)throw new d("training_preparation_scope_mismatch","The training preparation belongs to a different workspace or request.");return o}return s(n,"read"),{async listPreparations(i,a={}){let r=S.parse(i),o=Ct.parse(a),m=new URLSearchParams;for(let[R,v]of Object.entries(o))m.set(R,String(v));let c=qt.parse(await t(`/v1/training/preparations?${m}`));if(c.teamId!==r||c.items.length>o.limit||new Set(c.items.map(R=>R.plan.id)).size!==c.items.length||c.nextCursor!==null&&(c.nextCursor!==c.items.at(-1)?.plan.id||c.nextCursor===o.afterId))throw new d("training_preparation_page_mismatch","The preparation page does not match its workspace or cursor.");let x=await Promise.all(c.items.map(async R=>{let v=await n(R,r);if(o.projectId&&v.plan.request.projectId!==o.projectId||o.state&&v.state!==o.state)throw new d("training_preparation_page_mismatch","A preparation does not match the requested Project or state.");return v}));return{...c,items:x}},async prepareRun(i){let a=Ee.parse(i),r=await n(await t("/v1/training/preparations",{method:"POST",body:JSON.stringify(a)}),a.teamId);if(r.plan.requestHash!==await u(a))throw new d("training_preparation_request_mismatch","The preparation does not match the requested run.");return r},async getPreparation(i,a){return n(await t(`/v1/training/preparations/${encodeURIComponent(S.parse(a))}`),S.parse(i),a)},async startPreparation(i,a){let r=He.parse(a),o=await n(await t(`/v1/training/preparations/${encodeURIComponent(S.parse(i))}/start`,{method:"POST",body:JSON.stringify(r)}),r.teamId,i);if(o.plan.contentHash!==r.planHash||o.state!=="submitted")throw new d("training_preparation_start_mismatch","The submitted run does not match the approved preparation.");return o},async cancelPreparation(i,a){let r=He.parse(a),o=await n(await t(`/v1/training/preparations/${encodeURIComponent(S.parse(i))}/cancel`,{method:"POST",body:JSON.stringify(r)}),r.teamId,i);if(o.plan.contentHash!==r.planHash||o.state!=="cancelled")throw new d("training_preparation_cancel_mismatch","The preparation cancellation could not be verified.");return o}}}s(Mt,"createTrainingPreparationClient");var I=e.string().trim().min(1).max(191),L=e.string().regex(/^[a-f0-9]{64}$/),qe=e.string().datetime({offset:!0}),P=e.number().finite().nonnegative(),Ot=e.discriminatedUnion("kind",[e.object({kind:e.literal("preparation"),id:I,planHash:L,expectedRevision:e.number().int().positive()}).strict(),e.object({kind:e.literal("configuration"),id:I,expectedRevision:e.number().int().positive(),expectedEtag:L,batch:b.nullable().default(null)}).strict(),e.object({kind:e.literal("submission"),submission:e.lazy(()=>ze)}).strict()]),Ut=e.object({schemaVersion:e.literal("openpond.trainingEstimateRequest.v1"),teamId:I,source:Ot,gpuSelection:A.optional()}).strict(),ce=e.object({low:P,high:P}).strict().refine(t=>t.high>=t.low,"Planning range must be ordered"),Gt=e.object({phase:e.enum(["startup","baseline_evaluation","rollouts","optimization","checkpointing","backbone_materialization","final_evaluation","publication","cleanup","retention"]),resource:e.enum(["gpu","cpu","judge","storage","network"]),expectedUsd:P.nullable(),expectedSeconds:P.nullable(),planningRangeUsd:ce.nullable(),evidence:e.enum(["measured","configured_rate","unavailable"]),reason:e.string().trim().min(1).max(1e3).nullable()}).strict();function Dt(t){return t.kind==="submission"?{kind:t.kind,id:t.submission.idempotencyKey,contentHash:t.submission.contentHash,revision:null}:t.kind==="preparation"?{kind:t.kind,id:t.id,contentHash:t.planHash,revision:t.expectedRevision}:{kind:t.kind,id:t.id,contentHash:t.expectedEtag,revision:t.expectedRevision}}s(Dt,"trainingEstimateSourceIdentity");var Jt=e.object({schemaVersion:e.literal("openpond.trainingEstimate.v1"),id:I,teamId:I,requestHash:L,inputHash:L,source:e.object({kind:e.enum(["preparation","configuration","submission"]),id:I,contentHash:L,revision:e.number().int().positive().nullable()}).strict(),status:e.enum(["available","partial","insufficient_evidence"]),currency:e.literal("USD"),createdAt:qe,expiresAt:qe,estimatorVersion:I,runtimeVersion:I,pricing:e.object({version:I,quoteExpiresAt:qe.nullable()}).strict(),gpu:e.object({requested:A,resolved:e.object({availabilityId:I,gpuType:e.string().min(1).max(256),gpuCount:e.union([e.literal(1),e.literal(2)])}).strict().nullable(),customerHourlyUsd:P.nullable(),availability:e.enum(["available","limited","unavailable","unknown"])}).strict(),configuration:e.object({modelId:I,modelRevision:e.string().min(1).max(256),method:I,loraRank:e.number().int().positive().nullable(),adapterMode:e.enum(["residual_append","shared","sequential_merge"]).nullable(),groups:e.number().int().nonnegative().nullable(),rolloutConcurrency:e.number().int().positive().nullable(),maxOutputTokens:e.number().int().positive().nullable(),trainingRows:e.number().int().nonnegative().nullable(),evaluationRows:e.number().int().nonnegative().nullable(),retentionDays:e.number().int().positive().nullable(),approvedMaximumUsd:P.nullable()}).strict(),cost:e.object({expectedUsd:P.nullable(),planningRangeUsd:ce.nullable(),knownMinimumUsd:P,recommendedMaximumUsd:P.nullable(),minimumCleanupReserveUsd:P.nullable(),components:e.array(Gt).max(50)}).strict(),executionSeconds:e.object({expected:P.nullable(),planningRange:ce.nullable()}).strict(),queueWaitSeconds:e.object({expected:P,planningRange:ce.nullable()}).strict().nullable(),calibration:e.object({version:I,cohortHash:L,completedSamples:e.number().int().nonnegative(),partialSamples:e.number().int().nonnegative(),scope:e.enum(["workspace","authorized_aggregate"])}).strict(),assumptions:e.array(e.string().trim().min(1).max(1e3)).max(50),unknowns:e.array(e.string().trim().min(1).max(1e3)).max(50),review:$}).strict().superRefine((t,n)=>{(t.review.estimateId!==t.id||t.review.inputHash!==t.inputHash||t.review.requestHash!==t.requestHash||t.review.pricingVersion!==t.pricing.version||t.review.expiresAt!==t.expiresAt)&&n.addIssue({code:"custom",path:["review"],message:"Estimate review identity differs from the estimate"}),Date.parse(t.expiresAt)<=Date.parse(t.createdAt)&&n.addIssue({code:"custom",path:["expiresAt"],message:"Estimate must expire after its creation"}),t.status==="available"&&(t.cost.expectedUsd===null||t.executionSeconds.expected===null||t.unknowns.length>0)&&n.addIssue({code:"custom",path:["status"],message:"An available estimate requires complete cost and duration coverage"}),t.gpu.requested.mode==="manual"&&t.gpu.resolved&&(t.gpu.requested.availabilityId!==t.gpu.resolved.availabilityId||t.gpu.requested.gpuType!==t.gpu.resolved.gpuType)&&n.addIssue({code:"custom",path:["gpu"],message:"An explicit GPU offering cannot be substituted"}),t.gpu.resolved&&t.gpu.resolved.gpuCount!==(t.gpu.requested.gpuCount??1)&&n.addIssue({code:"custom",path:["gpu","resolved","gpuCount"],message:"The resolved GPU count must match the requested count"})});function $t(t){return{async estimate(n){let i=Ut.parse(n);i.source.kind==="submission"&&await me(i.source.submission);let a=Jt.parse(await t("/v1/training/estimates",{method:"POST",body:JSON.stringify(i)}));if(a.teamId!==i.teamId||a.requestHash!==await u(i)||await u(a.source)!==await u(Dt(i.source))||i.gpuSelection&&await u(a.gpu.requested)!==await u(i.gpuSelection))throw new d("training_estimate_scope_mismatch","The estimate does not match the requested workspace and exact configuration.");return a}}}s($t,"createTrainingEstimateClient");var pe=e.string().datetime({offset:!0}),Me=e.object({ticketId:e.string().trim().min(1).max(191),ticketNumber:e.number().int().positive().max(Number.MAX_SAFE_INTEGER),label:e.literal("Waiting for resources"),position:e.number().int().positive().nullable(),positionScope:e.literal("compatible_fair_queue"),enqueuedAt:pe,asOf:pe,estimate:e.object({revision:e.number().int().nonnegative(),estimatedStartAt:pe,expiresAt:pe,evidence:e.enum(["observed_capacity","measured_bootstrap","scheduled_release"])}).strict().nullable()}).strict().superRefine((t,n)=>{t.estimate&&Date.parse(t.estimate.expiresAt)<=Date.parse(t.asOf)&&n.addIssue({code:"custom",path:["estimate"],message:"An expired queue forecast must be returned as unavailable"})});var Nt=e.object({schemaVersion:e.literal("openpond.trainingHarnessSourcePublication.v1"),harnessRelease:ue,sourcePackageHash:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().positive().max(67108864)}).strict();function Bt(t){let n=s(i=>{let a=ue.parse(i);return`/v1/training/harness-sources/${encodeURIComponent(a.id)}/${a.contentHash}`},"route");return{async publishHarnessSource(i){k(i,67108864,"Training Harness source");let a=Vt(i),r=a.agentSnapshot.portability;if(!r.portable||r.blockers.length||r.localOnlyAssetRefs.length||r.hostPrivateAssetRefs.length||a.schemaVersion==="openpond.harnessSourcePackage.v1"&&a.harnessRelease.files.some(m=>m.visibility!=="policy"))throw new Error("Hosted training Harness publication requires portable, policy-visible source.");let o=Nt.parse(await t(n({id:a.harnessRelease.id,contentHash:a.harnessRelease.contentHash}),{method:"PUT",body:JSON.stringify(a)}));if(o.harnessRelease.id!==a.harnessRelease.id||o.harnessRelease.contentHash!==a.harnessRelease.contentHash||o.sourcePackageHash!==a.contentHash)throw new Error("Published Harness source differs from the selected immutable package.");return o},async getHarnessSource(i){let a=await t(n(i),void 0,67108864);return k(a,67108864,"Training Harness source"),Vt(a,i)}}}s(Bt,"createTrainingHarnessSourceClient");function Vt(t,n){return typeof t=="object"&&t!==null&&Reflect.get(t,"schemaVersion")==="openpond.harnessPolicySourcePackage.v1"?$e(t,n):Ve(t,n)}s(Vt,"validateSource");var O=e.string().trim().min(1).max(500),yn=e.string().regex(/^[a-f0-9]{64}$/),de=e.object({schemaVersion:e.literal("openpond.trainingCandidateDecisionRequest.v1"),teamId:O,jobId:O,artifact:p,evaluation:p,executionReceipt:p,decision:e.enum(["accepted","rejected"]),reason:e.string().trim().min(1).max(5e3),idempotencyKey:O,expectedDecision:p.nullable()}).strict(),Lt=e.object({schemaVersion:e.literal("openpond.trainingCandidateDecision.v1"),id:O,request:de,revision:e.number().int().positive(),actor:e.object({userId:O,kind:e.enum(["user","api_key","agent_delegate"]),id:O}).strict(),decidedAt:e.string().datetime({offset:!0}),contentHash:yn}).strict().superRefine((t,n)=>{t.revision===1!=(t.request.expectedDecision===null)&&n.addIssue({code:"custom",path:["revision"],message:"A first decision has no predecessor; later decisions must reference the prior decision."}),t.request.expectedDecision?.id===t.id&&n.addIssue({code:"custom",path:["request","expectedDecision"],message:"A decision cannot supersede itself."})});async function Qt(t){let{contentHash:n,...i}=t;return u(i)}s(Qt,"trainingCandidateDecisionHash");async function Oe(t,n){k(t,32768,"Training candidate decision");let i=Lt.parse(t);if(i.contentHash!==await Qt(i))throw new d("content_hash_mismatch","Training candidate decision content hash does not match.");if(i.request.teamId!==n.teamId||i.request.jobId!==n.jobId||i.request.artifact.id!==n.artifact.id||i.request.artifact.contentHash!==n.artifact.contentHash)throw new d("candidate_decision_identity_mismatch","Training candidate decision belongs to a different team, Job or artifact.");if(n.request&&await u(i.request)!==await u(de.parse(n.request)))throw new d("candidate_decision_request_mismatch","Training candidate decision does not match the submitted review.");return i}s(Oe,"parseAndVerifyTrainingCandidateDecision");function Ft(t){function n(i){return`/v1/training/jobs/${encodeURIComponent(O.parse(i.jobId))}/candidates/${encodeURIComponent(p.parse(i.artifact).id)}/decision`}return s(n,"route"),{async candidateDecision(i,a={}){O.parse(i.teamId);let r=a.decision?p.parse(a.decision):void 0,o=r?`?decisionId=${encodeURIComponent(r.id)}`:"",m=e.object({decision:e.unknown().nullable()}).strict().parse(await t(`${n(i)}${o}`));if(m.decision===null&&!r)return null;let c=await Oe(m.decision,i);if(r&&(c.id!==r.id||c.contentHash!==r.contentHash))throw new d("candidate_decision_identity_mismatch","Training candidate decision does not match the requested history entry.");return c},async recordCandidateDecision(i){let a=de.parse(i),r=await t(n(a),{method:"POST",body:JSON.stringify(a)});return Oe(r,{...a,request:a})}}}s(Ft,"createTrainingCandidateDecisionClient");var Q=e.string().trim().min(1).max(500),Z=e.string().regex(/^[a-f0-9]{64}$/),Kt=e.object({taskId:Q,taskSha256:Z,resultSha256:Z,input:e.object({instruction:e.string().max(1e6),context:e.record(e.string(),e.unknown())}).strict(),output:e.string().max(1e6),outputSha256:Z,score:e.number().finite().min(0).max(1),evidence:e.object({kind:e.enum(["worker_command","hosted_trace","local_trace"]),id:Q}).strict()}).strict(),Wt=e.object({schemaVersion:e.literal("openpond.trainingEvaluationTaskPage.v1"),jobId:Q,teamId:Q,evaluation:p,kind:e.enum(["baseline","candidate"]),policyVersion:e.number().int().nonnegative(),taskset:b,panelSha256:Z,offset:e.number().int().nonnegative(),total:e.number().int().min(1).max(1e4),tasks:e.array(Kt).min(1).max(100),nextCursor:e.string().regex(/^[1-9]\d*$/).nullable(),contentHash:Z}).strict().superRefine((t,n)=>{let i=t.offset+t.tasks.length,a=i<t.total?String(i):null;(i>t.total||t.nextCursor!==a)&&n.addIssue({code:"custom",path:["nextCursor"],message:"Evaluation pagination must cover consecutive task positions."}),new Set(t.tasks.map(r=>r.taskId)).size!==t.tasks.length&&n.addIssue({code:"custom",path:["tasks"],message:"Evaluation task identities must be unique."})});async function Xt(t){let{contentHash:n,...i}=t;return u(i)}s(Xt,"trainingEvaluationTaskPageHash");async function Ue(t,n){k(t,8388608,"Training evaluation task page");let i=Wt.parse(t),a=p.parse(n.evaluation);if(i.jobId!==Q.parse(n.jobId)||i.evaluation.id!==a.id||i.evaluation.contentHash!==a.contentHash||i.offset!==(n.offset??0)||n.teamId!==void 0&&i.teamId!==Q.parse(n.teamId))throw new d("evaluation_page_identity_mismatch","Evaluation results differ from the requested Job, evaluation, or page.");if(await Xt(i)!==i.contentHash)throw new d("evaluation_page_hash_mismatch","Evaluation task page content hash did not match.");for(let r of i.tasks)if(await u(r.output)!==r.outputSha256)throw new d("evaluation_output_hash_mismatch","A retained evaluation output hash did not match.");return i}s(Ue,"parseAndVerifyTrainingEvaluationTaskPage");var Sn=e.array(e.object({id:e.string().trim().min(1)}).catchall(e.unknown())).min(1).max(1e3),Tn=e.object({binding:Fe,rewards:e.array(Qe).min(1).max(100)}).strict();async function vn(t){let n=t.rewardExecution?Tn.parse(t.rewardExecution):null,i=Sn.parse(n?We(n.binding,n.rewards):t.graders);if(new Set(i.map(r=>r.id)).size!==i.length)throw new Error("Training grader identities must be unique.");let a=await u({schemaVersion:"openpond.trainingGraderSet.v1",graders:i});return{kind:"deterministic",grader:{id:`training-graders-${a.slice(0,32)}`,contentHash:a},composer:n?{id:n.binding.id,contentHash:n.binding.contentHash}:null}}s(vn,"deterministicTrainingRewardSource");var In="evaluation-source.json",Ge=e.object({id:e.string().trim().min(1),clusterKey:e.string().trim().min(1),split:e.enum(["train","validation","frozen_eval"])}).passthrough(),Yt=e.object({schemaVersion:e.literal("openpond.trainingEvaluationSource.v1"),taskset:b,tasks:e.array(Ge).min(1).max(1e4),assets:e.array(e.object({path:e.string().trim().min(1).max(2e3),sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().nonnegative(),encoding:e.literal("base64"),content:e.string().max(32*1024*1024)}).strict()).max(1e4)}).strict().superRefine((t,n)=>{let i=new Set;t.tasks.forEach((a,r)=>{a.split==="train"&&n.addIssue({code:"custom",path:["tasks",r,"split"],message:"Evaluation sources require held-out tasks."}),i.has(a.id)&&n.addIssue({code:"custom",path:["tasks",r,"id"],message:"Evaluation task identities must be unique."}),i.add(a.id)})});function Rn(t,n){let i=e.array(Ge).min(1).max(1e4).parse(t),a=e.array(Ge).min(1).max(1e4).parse(n),r=new Set,o=new Set;for(let c of i){if(c.split!=="train")throw new Error("The training population contains a held-out task.");if(r.has(c.id))throw new Error("Training task identities must be unique.");r.add(c.id),o.add(c.clusterKey)}let m=new Set;for(let c of a){if(c.split==="train")throw new Error("The evaluation population contains a training task.");if(m.has(c.id))throw new Error("Evaluation task identities must be unique.");if(r.has(c.id)||o.has(c.clusterKey))throw new Error("Training and evaluation tasks or families overlap.");m.add(c.id)}}s(Rn,"assertTrainingEvaluationIsolation");async function wn(t){let n=Yt.parse(t),i=await u(n);return{taskset:n.taskset,dataset:{id:`training-evaluation-${i.slice(0,32)}`,contentHash:i}}}s(wn,"trainingEvaluationSourceRef");var l=e.string().trim().min(1).max(500),f=e.string().regex(/^[a-f0-9]{64}$/),j=e.string().datetime({offset:!0}),Pn=e.object({schemaVersion:e.literal("openpond.trainingInputArtifactUpload.v2"),kind:e.enum(["portable_training_bundle","reward_model_dataset"]),idempotencyKey:e.string().trim().min(1).max(500),sourceManifest:p,payload:e.unknown(),contentHash:f}).strict(),kn=e.object({schemaVersion:e.literal("openpond.trainingInputArtifact.v2"),kind:e.enum(["portable_training_bundle","reward_model_dataset"]),sourceManifest:p,artifactRef:e.string().trim().min(1).max(2e3),contentHash:f,sizeBytes:e.number().int().positive(),createdAt:j}).strict();async function _n(t){let{contentHash:n,...i}=t;return u(i)}s(_n,"trainingInputArtifactUploadHash");async function jn(t){k(t,67108864,"Training input artifact");let n=Pn.parse(t),i=await _n(n);if(n.contentHash!==i)throw new d("content_hash_mismatch",`Training input artifact contentHash ${n.contentHash} does not match ${i}.`);return n}s(jn,"parseAndVerifyTrainingInputArtifactUpload");var en=e.enum(["reward_model_train","policy_optimize"]),Hn=e.enum(["queued","admitting","provisioning","running","stopping","cancelling","succeeded","failed","cancelled"]),En=e.object({id:l,version:e.string().trim().min(1).max(200).nullable().default(null),required:e.boolean().default(!0)}).strict(),Ce=e.object({origin:U.optional(),modelProject:e.object({id:l,portableProjectId:l,revision:e.number().int().positive(),contentHash:f}).strict(),harnessRunManifest:p,harnessRelease:p,taskset:b,tasksetRelease:p,evaluation:e.object({taskset:b,dataset:p}).strict().nullable().optional(),dataset:p,evidenceSets:e.array(p).max(1e4)}).strict(),An=e.object({kind:e.literal("reward_model_train"),baseModel:ie,preferenceDatasetRelease:p,processorRelease:p,recipe:e.object({schemaVersion:e.literal("openpond.rewardModelRecipe.v1"),method:e.literal("reward_model"),parameterization:e.literal("lora_with_scalar_head")}).catchall(e.unknown())}).strict(),Cn=e.object({kind:e.literal("deterministic"),grader:p,composer:p.nullable().default(null)}).strict(),qn=e.object({kind:e.literal("learned_reward"),rewardModelVersion:p,qualificationReport:p.nullable().default(null),evaluationReferences:e.array(p).max(1e3).default([]),scorerArtifact:e.object({artifactRef:e.string().trim().min(1).max(2e3),contentHash:f,executionReceipt:p}).strict(),processorRelease:p,rewardComposerRelease:p}).strict(),tn=ie.extend({revision:e.string().regex(/^[a-f0-9]{40,64}$/),tokenizerRevision:e.string().regex(/^[a-f0-9]{40,64}$/),chatTemplateHash:f}).strict(),zn=e.object({kind:e.literal("policy_optimize"),executionMode:e.literal("qualification").optional(),baseModel:ie,recipe:pt,rewardSource:e.discriminatedUnion("kind",[Cn,qn]),resumeFrom:p.nullable().default(null)}).strict().superRefine((t,n)=>{if(t.recipe.method!=="sft")return;let i=z.safeParse(t.recipe);if(!i.success){n.addIssue({code:"custom",path:["recipe"],message:"The SFT recipe is incomplete or invalid."});return}(t.executionMode||t.resumeFrom||"continuation"in t.recipe)&&n.addIssue({code:"custom",message:"Initial managed SFT requires a fresh supervised run without rollout qualification or continuation."}),(i.data.baseModel.id!==t.baseModel.modelId||i.data.baseModel.revision!==t.baseModel.revision||i.data.baseModel.tokenizerRevision!==t.baseModel.tokenizerRevision||i.data.baseModel.chatTemplateHash!==t.baseModel.chatTemplateHash)&&n.addIssue({code:"custom",path:["baseModel"],message:"The SFT recipe must pin the exact submitted base and tokenizer."})}),Mn=e.discriminatedUnion("kind",[An,zn]),On=e.object({approvalHash:f,approvedAt:j,exportApproved:e.boolean(),maximumSpendUsd:e.number().nonnegative(),retentionDays:e.number().int().nonnegative().nullable(),region:e.string().trim().min(1).max(200).nullable().default(null)}).strict(),ze=e.object({schemaVersion:e.literal("openpond.trainingJobSubmission.v2"),idempotencyKey:e.string().trim().min(1).max(500),name:e.string().trim().min(1).max(200),source:Ce,job:Mn,requestedCapabilities:e.array(En).max(1e3),placementObjective:e.enum(["fast","balanced","economical"]),gpuSelection:A.optional(),physicalPlacement:X.optional(),budget:e.object({maximumSpendUsd:e.number().nonnegative(),maximumWallSeconds:e.number().int().positive()}).strict(),approval:On,contentHash:f}).strict().superRefine((t,n)=>{let i=(t.gpuSelection?.gpuCount??1)===2,a=t.requestedCapabilities.some(r=>r.id==="managed_rl.policy.data_parallel"&&r.version==="1"&&r.required);if(i!==a&&n.addIssue({code:"custom",path:["requestedCapabilities"],message:"Two-GPU training must require managed_rl.policy.data_parallel@1 and bind gpuSelection.gpuCount to 2."}),i&&(t.job.kind!=="policy_optimize"||t.job.executionMode||t.job.recipe.method!=="grpo"||t.physicalPlacement)&&n.addIssue({code:"custom",path:["gpuSelection"],message:"Two-GPU execution requires exclusive GRPO policy training."}),t.physicalPlacement&&(t.job.kind!=="policy_optimize"||t.job.resumeFrom||t.job.executionMode||t.job.recipe.continuation!==void 0)&&n.addIssue({code:"custom",path:["physicalPlacement"],message:"Reuse-only placement requires fresh-base policy training without continuation."}),t.job.kind==="policy_optimize"&&t.job.executionMode==="qualification"){let r=t.job;tn.safeParse(r.baseModel).success||n.addIssue({code:"custom",path:["job","baseModel"],message:"Qualification requires immutable model and tokenizer revisions and a SHA-256 chat-template pin."}),(r.resumeFrom||r.recipe.continuation!==void 0||r.rewardSource.kind!=="deterministic"||r.recipe.method!=="grpo")&&n.addIssue({code:"custom",path:["job"],message:"Qualification requires the original GRPO learner, deterministic reward, and no resume or continuation."}),t.requestedCapabilities.some(o=>o.required&&o.id==="managed_rl.policy.qualification"&&o.version==="1")||n.addIssue({code:"custom",path:["requestedCapabilities"],message:"Qualification must require managed_rl.policy.qualification@1."})}t.approval.maximumSpendUsd!==t.budget.maximumSpendUsd&&n.addIssue({code:"custom",path:["approval","maximumSpendUsd"],message:"Approved spend must equal the immutable Job budget."})});async function Un(t){let{contentHash:n,...i}=t;return u(i)}s(Un,"trainingJobSubmissionHash");async function me(t){k(t,1048576,"Training Job submission");let n=ze.parse(t),i=await Un(n);if(n.contentHash!==i)throw new d("content_hash_mismatch",`Training Job contentHash ${n.contentHash} does not match ${i}.`);return n}s(me,"parseAndVerifyTrainingJobSubmission");var Gn=e.object({resourceApproval:W.optional(),mode:e.literal("evaluation_only").optional(),trainingWorkloadComplete:e.boolean().optional(),sourceJobId:l,checkpointId:l,policyVersion:e.number().int().positive(),completedGroups:e.number().int().positive(),optimizerMode:e.literal("continue")}).strict(),F=e.object({schemaVersion:e.literal("openpond.trainingJob.v2"),id:l,teamId:l,kind:en,executionMode:e.literal("qualification").optional(),recovery:Gn.optional(),modelProjectId:l,portableProjectId:l,sourceProjectRevision:e.number().int().positive(),submissionHash:f,state:Hn,queue:Me.optional(),phase:e.string().trim().min(1).max(200),version:e.number().int().nonnegative(),progress:e.number().min(0).max(1),rolloutProgress:e.object({groupsCompleted:e.number().int().nonnegative(),groupsTarget:e.number().int().nonnegative(),optimizerUpdatesApplied:e.number().int().nonnegative(),optimizerUpdatesSkipped:e.number().int().nonnegative()}).strict(),accruedSpendUsd:e.number().nonnegative(),terminalReason:e.string().trim().min(1).max(5e3).nullable(),createdAt:j,updatedAt:j,completedAt:j.nullable()}).strict(),Dn=e.object({schemaVersion:e.literal("openpond.trainingJobPage.v2"),jobs:e.array(F).max(1e3),nextCursor:e.string().trim().min(1).max(2e3).nullable()}).strict(),Jn=e.object({schemaVersion:e.literal("openpond.trainingJobEvent.v2"),id:l,jobId:l,sequence:e.number().int().nonnegative(),type:l,phase:e.string().trim().min(1).max(200),message:e.string().trim().min(1).max(5e3).nullable(),data:e.record(e.string(),e.unknown()).default({}),createdAt:j}).strict(),$n=e.object({schemaVersion:e.literal("openpond.trainingJobLog.v2"),jobId:l,sequence:e.number().int().nonnegative(),level:e.enum(["debug","info","warning","error"]),message:e.string().max(2e4),createdAt:j}).strict(),Zt=e.object({expectedVersion:e.number().int().nonnegative()}).strict(),Vn=e.object({schemaVersion:e.literal("openpond.trainingJobOutput.v2"),id:l,jobId:l,kind:e.enum(["checkpoint","adapter","scorer","metrics","evaluation","trace","receipt"]),artifactRef:e.string().trim().min(1).max(2e3),contentHash:f,sizeBytes:e.number().int().nonnegative(),metadata:e.record(e.string(),e.unknown()).default({}),createdAt:j}).strict(),nn=e.object({schemaVersion:e.literal("openpond.trainingQualificationEvidence.v1"),baseModel:tn,group:p,rolloutReceipts:e.array(p).min(1).max(1e3),rewardEvidenceHash:f,groupsCompleted:e.literal(1),optimizerUpdatesApplied:e.literal(0),optimizerUpdatesSkipped:e.literal(0),trainingStepsCreated:e.literal(0),checkpointsCreated:e.literal(0),artifactsCreated:e.literal(0)}).strict().superRefine((t,n)=>{new Set(t.rolloutReceipts.map(i=>i.id)).size!==t.rolloutReceipts.length&&n.addIssue({code:"custom",path:["rolloutReceipts"],message:"Qualification rollout receipt identities must be unique."})}),De=e.object({schemaVersion:e.literal("openpond.trainingExecutionReceipt.v2"),id:l,teamId:l,jobId:l,submissionHash:f,manifestHash:f,recipeHash:f,capabilityHash:f,runtimeRelease:p,inputs:e.array(p).max(1e4),outputs:e.array(p).max(1e4),spendUsd:e.number().nonnegative(),durationSeconds:e.number().nonnegative(),cleanupComplete:e.boolean(),qualification:nn.optional(),issuer:l,issuedAt:j,signature:e.string().trim().min(1).max(1e4).nullable()}).strict();async function Nn(t){return u(De.parse(t))}s(Nn,"trainingExecutionReceiptHash");async function po(t,n){let i=De.parse(t),a=l.parse(n.id),r=f.parse(n.contentHash),o=await Nn(i);if(i.id!==a||o!==r)throw new d("execution_receipt_mismatch","The execution receipt identity or canonical content hash did not match.");if(n.teamId!==void 0&&i.teamId!==l.parse(n.teamId))throw new d("execution_receipt_team_mismatch","The execution receipt belongs to a different team.");if(n.jobId!==void 0&&i.jobId!==l.parse(n.jobId))throw new d("execution_receipt_job_mismatch","The execution receipt belongs to a different Training Job.");if((n.requireCleanup??!0)&&!i.cleanupComplete)throw new d("execution_cleanup_incomplete","The execution receipt does not attest complete terminal cleanup.");if(n.qualificationSubmission){let m=await me(n.qualificationSubmission);if(m.job.kind!=="policy_optimize"||m.job.executionMode!=="qualification")throw new d("qualification_submission_required","Expected an immutable qualification submission.");await Bn(i,{submissionHash:m.contentHash,baseModel:m.job.baseModel,outputs:n.outputs})}return i}s(po,"parseAndVerifyTrainingExecutionReceipt");async function Bn(t,n){let i=nn.parse(t.qualification);if(t.submissionHash!==n.submissionHash||!t.cleanupComplete)throw new d("qualification_receipt_mismatch","Qualification must attest the expected submission and complete cleanup.");if(n.baseModel&&await u(i.baseModel)!==await u(n.baseModel))throw new d("qualification_learner_mismatch","Qualification used a different original learner or tokenizer.");if(n.outputs?.some(a=>["checkpoint","adapter","scorer"].includes(a.kind)))throw new d("qualification_updated_artifact","Qualification must not publish trained artifacts or checkpoints.")}s(Bn,"assertTrainingQualificationReceipt");var Ln=e.object({schemaVersion:e.literal("openpond.trainingJobOutputs.v2"),outputs:e.array(Vn).max(1e4),receipt:De.nullable()}).strict(),Qn=e.object({workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/),envelopeRank:e.number().int().positive().max(256),supportedRanks:e.array(e.number().int().positive().max(256)).max(256),qualification:e.object({evidenceRef:e.string().min(1),evidenceSha256:f}).strict().nullable(),continuation:e.object({sharedRequiresSameRank:e.literal(!0),mergedRequiresSameRank:e.literal(!0),residualAppendRequiresFreeCapacity:e.literal(!0),stageOptimizer:e.literal("reset"),interruptedRecoveryOptimizer:e.literal("restore")}).strict()}).strict().superRefine((t,n)=>{(new Set(t.supportedRanks).size!==t.supportedRanks.length||t.supportedRanks.some(i=>i>t.envelopeRank))&&n.addIssue({code:"custom",path:["supportedRanks"],message:"Supported ranks must be unique and fit the physical adapter envelope."}),t.supportedRanks.length&&!t.qualification&&n.addIssue({code:"custom",path:["qualification"],message:"Advertised ranks require immutable image qualification evidence."})});function uo(t,n,i){return t.supportedRanks.includes(n)?i?i.mode==="residual_append"?i.parentEnabledRank+n<=t.envelopeRank:i.parentEnabledRank===n:!0:!1}s(uo,"supportsTrainingPolicyLoraRank");var Fn=e.object({schemaVersion:e.literal("openpond.trainingCapabilities.v2"),capabilityHash:f,jobKinds:e.array(en),methods:e.array(e.string().trim().min(1).max(200)),executionModes:e.array(e.enum(["training","qualification"])).optional(),policyLora:Qn.optional(),policyDataParallel:e.object({capability:e.literal("managed_rl.policy.data_parallel"),version:e.literal("1"),gpuCount:e.literal(2),worldSize:e.literal(2),backend:e.literal("nccl"),allocationMode:e.literal("exclusive"),workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/)}).strict().optional(),structuredOutputs:e.object({capability:e.literal("work.structured-output.v1"),harnessRuntimeHash:f,workHarnessHash:f,schemaHash:f,artifactHash:f,invalidDataRejected:e.literal(!0),invalidBytesRejected:e.literal(!0)}).strict().optional(),placements:e.array(e.enum(["local","remote","colocated","provider_native"])),controls:e.object({cancel:e.boolean(),stopAfterGroup:e.boolean(),resumeFromCheckpoint:e.boolean()}).strict(),estimates:e.object({schemaVersion:e.literal("openpond.trainingEstimate.v1")}).strict().optional(),limits:e.object({maximumSpendUsd:e.number().nonnegative(),maximumWallSeconds:e.number().int().positive(),maximumArtifactBytes:e.number().int().positive()}).strict(),checkedAt:j,expiresAt:j}).strict();function lo(t){let n=dt(t);return{postTraining:jt({request:n}),...Mt(n),...$t(n),...bt(n),...ut(n),...Bt(n),...Ft(n),async capabilities(){return Fn.parse(E(await n("/v1/training/capabilities"),"capabilities"))},async gpuCatalog(){return be.parse(E(await n("/v1/training/gpu-catalog"),"catalog"))},async stageArtifact(i){let a=await jn(i);return kn.parse(E(await n("/v1/training/artifacts",{method:"POST",body:JSON.stringify(a)}),"artifact"))},async createJob(i){let a=await me(i);return F.parse(E(await n("/v1/training/jobs",{method:"POST",body:JSON.stringify(a)}),"job"))},async listJobs(i={}){let a=new URLSearchParams;i.modelProjectId&&a.set("modelProjectId",l.parse(i.modelProjectId)),i.cursor&&a.set("cursor",e.string().trim().min(1).max(2e3).parse(i.cursor)),i.limit!==void 0&&a.set("limit",String(e.number().int().min(1).max(1e3).parse(i.limit)));let r=a.size>0?`?${a.toString()}`:"";return Dn.parse(await n(`/v1/training/jobs${r}`))},async getJob(i){return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}`),"job"))},async cancelJob(i,a){let r=Zt.parse({expectedVersion:a});return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/cancel`,{method:"POST",body:JSON.stringify(r)}),"job"))},async stopAfterGroup(i,a){let r=Zt.parse({expectedVersion:a});return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/stop-after-group`,{method:"POST",body:JSON.stringify(r)}),"job"))},async recoverCheckpoint(i,a){let r=je.parse(a);if(r.resourceApproval){let{approvalHash:o,...m}=r.resourceApproval;if(m.sourceJobId!==i||await u(m)!==o)throw new d("content_hash_mismatch","Recovery resource approval does not bind this source request.")}return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/recover`,{method:"POST",body:JSON.stringify(r)}),"job"))},async events(i){return e.array(Jn).parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/events`),"events"))},async outputs(i){return Ln.parse(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/outputs`))},async evaluationTasks(i,a,r={}){let o=l.parse(i),m=p.parse(a),c=new URLSearchParams,x=r.cursor===void 0?void 0:e.string().regex(/^[1-9]\d*$/).parse(r.cursor),R=x===void 0?0:e.number().int().min(1).max(9999).parse(Number(x));x!==void 0&&c.set("cursor",x),r.limit!==void 0&&c.set("limit",String(e.number().int().min(1).max(100).parse(r.limit)));let v=c.size?`?${c.toString()}`:"";return Ue(await n(`/v1/training/jobs/${encodeURIComponent(o)}/evaluations/${encodeURIComponent(m.id)}/tasks${v}`),{jobId:o,evaluation:m,offset:R})},async logs(i){return e.array($n).max(1e5).parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/logs`),"logs"))}}}s(lo,"createTrainingClient");function E(t,n){return!t||typeof t!="object"||Array.isArray(t)?t:n in t?t[n]:t}s(E,"unwrapObject");export{z as a,rn as b,ye as c,gt as d,ht as e,ft as f,D as g,vt as h,cn as i,Yi as j,Re as k,Pe as l,ga as m,ha as n,fa as o,ba as p,_e as q,W as r,xn as s,je as t,X as u,Ee as v,Et as w,At as x,Ae as y,He as z,Ct as A,qt as B,zt as C,Ot as D,Ut as E,Gt as F,Dt as G,Jt as H,Me as I,Nt as J,de as K,Lt as L,Qt as M,Oe as N,Kt as O,Wt as P,Xt as Q,Ue as R,vn as S,In as T,Yt as U,Rn as V,wn as W,Pn as X,kn as Y,_n as Z,jn as _,en as $,Hn as aa,En as ba,Ce as ca,An as da,tn as ea,zn as fa,Mn as ga,On as ha,ze as ia,Un as ja,me as ka,Gn as la,F as ma,Dn as na,Jn as oa,$n as pa,Zt as qa,Vn as ra,nn as sa,De as ta,Nn as ua,po as va,Bn as wa,Ln as xa,Qn as ya,uo as za,Fn as Aa,lo as Ba};
2
+ import{e as ut}from"./chunk-RRWL5BHZ.js";import{c as dt}from"./chunk-NXN7GJOH.js";import{a as A,b as $,c as be,d as p,e as b,f as ie,g as pt,l as xe}from"./chunk-TERKCK4I.js";import{d as he,e as q,f as fe,g as d,h as y,j as u,k}from"./chunk-5HPZGLOL.js";import{f as ct,ob as mt,qb as ne}from"./chunk-QAFXQHHG.js";import{C as tt,E as nt,H as it,b as U,cc as rt,kc as ot,nc as st,o as Ze,s as et,vb as at}from"./chunk-XHU4BZQY.js";import{Ka as te,Na as Le,Ra as Qe,W as Be,Wa as Fe,Za as Ke,bb as We,fb as Xe,l as Ne,lb as Ye,oa as ee,va as ge}from"./chunk-ZY32SZ2P.js";import{t as $e,v as Ve}from"./chunk-OTDDXEQ6.js";import{g as ue,k as Je,n as w,o as le}from"./chunk-RCT3O3HQ.js";import{A as e}from"./chunk-X2J2P5ZT.js";import{a as s}from"./chunk-FTQLQJQV.js";var lt=e.string().trim().min(1).max(240),an=e.string().trim().min(8).max(256),z=e.object({schemaVersion:e.literal("openpond.sftRecipe.v1"),method:e.literal("sft"),parameterization:e.literal("lora"),baseModel:e.object({id:lt,revision:e.string().trim().min(1).max(256),tokenizerRevision:e.string().trim().min(1).max(256),chatTemplateHash:an}),dataset:e.object({trainSplit:e.literal("train"),validationSplit:e.enum(["validation","frozen_eval"]),completionOnly:e.boolean(),maxSequenceLength:e.number().int().positive().max(32768),maxExamples:e.number().int().positive().max(1e5).default(1e3),selectionStrategy:e.literal("stable_hash_top_n").default("stable_hash_top_n"),selectionSeed:e.number().int().default(17)}),lora:e.object({rank:e.number().int().positive().max(256),alpha:e.number().positive().max(1024),dropout:e.number().min(0).max(1),targetModules:e.array(lt).min(1).max(100)}),optimizer:e.object({learningRate:e.number().positive(),epochs:e.number().positive().max(100),maxSteps:e.number().int().positive().max(1e6),batchSize:e.number().int().positive().max(1e4),gradientAccumulationSteps:e.number().int().positive().max(1e4),seed:e.number().int()}),resourceLimits:e.object({cpuThreads:e.number().int().positive().max(256),memoryBytes:e.number().int().positive(),wallTimeMs:e.number().int().positive()})}),rn=z.safeExtend({dataset:z.shape.dataset.safeExtend({completionOnly:e.literal(!0),maxSequenceLength:e.number().int().min(2).max(8192),maxExamples:e.number().int().min(1).max(1e3).default(1e3)}),lora:z.shape.lora.safeExtend({rank:e.number().int().min(1).max(64),dropout:e.number().min(0).lt(1),targetModules:e.array(e.enum(["q_proj","k_proj","v_proj","o_proj","gate_proj","up_proj","down_proj"])).min(1).max(7)}),optimizer:z.shape.optimizer.safeExtend({learningRate:e.number().positive().max(.001),epochs:e.number().positive().max(10),maxSteps:e.number().int().min(1).max(128),batchSize:e.number().int().min(1).max(32),gradientAccumulationSteps:e.number().int().min(1).max(32),seed:e.number().int().min(-(2**31)).max(2**31-1)}),resourceLimits:z.shape.resourceLimits.safeExtend({wallTimeMs:e.number().int().min(1e3).max(216e5)})}).superRefine((t,n)=>{t.optimizer.batchSize*t.optimizer.gradientAccumulationSteps>32&&n.addIssue({code:"custom",path:["optimizer"],message:"Managed SFT supports at most 32 accumulated examples."}),new Set(t.lora.targetModules).size!==t.lora.targetModules.length&&n.addIssue({code:"custom",path:["lora","targetModules"],message:"Adapter target modules must be unique."})});var C=e.string().trim().min(1).max(240),ye=p.extend({revision:e.number().int().positive()}).strict(),gt=ye.extend({teamId:C,jobId:C,plan:p,baseline:p,candidate:p,state:ot.shape.state,updatedAt:e.string().datetime()}).strict(),ht=e.object({schemaVersion:e.literal("openpond.trainingAcceptanceGroupPage.v1"),teamId:C,jobId:C,groups:e.array(gt).max(100),nextCursor:C.nullable()}).strict(),ft=e.object({cursor:C.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict();function bt(t){let n=s(i=>(C.parse(i.teamId),`/v1/training/jobs/${encodeURIComponent(C.parse(i.jobId))}/acceptance-groups`),"route");return{async acceptanceGroups(i,a={}){let r=ft.parse(a),o=new URLSearchParams({limit:String(r.limit)});r.cursor&&o.set("cursor",r.cursor);let m=ht.parse(await t(`${n(i)}?${o}`));if(m.teamId!==i.teamId||m.jobId!==i.jobId||m.groups.length>r.limit||m.groups.some(c=>c.teamId!==i.teamId||c.jobId!==i.jobId||r.cursor&&c.id<=r.cursor)||new Set(m.groups.map(c=>c.id)).size!==m.groups.length||m.nextCursor!==null&&m.nextCursor!==m.groups.at(-1)?.id)throw new d("acceptance_group_scope_mismatch","Acceptance groups do not match the requested workspace, job or cursor.");return m},async acceptanceGroup(i,a,r){let o=r?ye.parse({id:r.id,revision:r.revision,contentHash:r.contentHash}):null;if(o&&o.id!==a)throw new d("acceptance_group_identity_mismatch","The retained group reference differs from the requested group.");let m=o?`?revision=${o.revision}`:"",c=st(await t(`${n(i)}/${encodeURIComponent(C.parse(a))}${m}`));if(c.manifest.teamId!==i.teamId||c.manifest.trainingJob.id!==i.jobId||c.manifest.id!==a||o&&(c.revision!==o.revision||c.contentHash!==o.contentHash))throw new d("acceptance_group_identity_mismatch","Acceptance evidence does not match the requested workspace, job or retained revision.");return c}}}s(bt,"createTrainingAcceptanceClient");var V=e.object({id:e.string().trim().min(1).max(240),revision:e.number().int().positive(),contentHash:e.string().regex(/^[a-f0-9]{64}$/),targetId:e.string().trim().min(1).max(240).nullable()}).strict(),xt=e.array(e.object({role:e.enum(["system","user","assistant"]),content:e.string().max(1e5)}).strict()).max(100).superRefine((t,n)=>{t.reduce((i,a)=>i+a.content.length,0)>1e5&&n.addIssue({code:"custom",message:"Evaluation prompt exceeds 100,000 characters."})});var N=e.string().regex(/^[a-f0-9]{64}$/),Se=e.object({providerId:e.literal("claude-code"),configurationHash:N,executableHash:N,version:e.string().regex(/^2\.\d+\.\d+$/),capabilityHash:N,maximumRequestCostUsd:e.number().finite().positive().max(1e4),requestTimeoutMs:e.number().int().min(1e3).max(3e5),maximumTurns:e.number().int().min(1).max(100),holdOpen:e.boolean()}).strict(),oi=e.object({id:e.string().min(1).max(200),receiptId:e.string().min(1).max(200),sessionId:e.uuid(),operationId:e.string().min(1).max(200),action:e.enum(["message","seal"]),text:e.string().max(262144).optional()}).strict().superRefine((t,n)=>{t.action==="message"&&!t.text?.trim()&&n.addIssue({code:"custom",message:"A human intervention requires a message."}),t.action==="seal"&&t.text!==void 0&&n.addIssue({code:"custom",message:"Sealing does not add a prompt."})}),si=e.object({provider:e.literal("claude-code"),sessionId:e.uuid(),requestId:e.string().min(1).max(200),modelId:e.string().min(1).max(500),runtime:Se,sourceHash:N,outputHash:N,traceHash:N,runtimeEventRefs:e.array(e.string().min(1).max(200)).min(1).max(2e4),eventCount:e.number().int().positive().max(2e4),startedAt:e.iso.datetime(),completedAt:e.iso.datetime(),cleanupComplete:e.literal(!0)}).strict().superRefine((t,n)=>{(t.runtimeEventRefs.length!==t.eventCount||new Set(t.runtimeEventRefs).size!==t.eventCount)&&n.addIssue({code:"custom",message:"Process event references must match the exact retained trace population."})});var ae=e.object({providerId:e.literal("codex"),configurationHash:e.string().regex(/^[a-f0-9]{64}$/),accountHash:e.string().regex(/^[a-f0-9]{64}$/),reasoningEffort:e.enum(["low","medium","high","xhigh"]),maximumRequestCostUsd:e.number().finite().positive().max(1e4),requestTimeoutMs:e.number().int().min(1e3).max(3e5)}).strict();var yt=e.object({schemaVersion:e.literal("openpond.experimentAttemptGrade.v1"),selectionHash:e.string().regex(/^[a-f0-9]{64}$/),grades:e.array(te).min(1).max(100),score:e.number().min(0).max(1).nullable(),passed:e.boolean(),rewardEligible:e.boolean(),gradingStatus:e.enum(["scored","pending","unscorable","not_configured"]),failureClass:Je.nullable(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().superRefine((t,n)=>{let{contentHash:i,...a}=t;w(a)!==i&&n.addIssue({code:"custom",message:"Experiment grading integrity failed."});let r=t.grades.flatMap(o=>o.components);(r.length!==t.grades.length||new Set(r.map(o=>o.graderId)).size!==r.length)&&n.addIssue({code:"custom",message:"Each selected criterion requires exactly one distinct grader result."});for(let o of t.grades){let{contentHash:m,...c}=o;w(c)!==m&&n.addIssue({code:"custom",message:"A retained criterion changed."});for(let x of o.components){let{contentHash:R,...v}=x;w(v)!==R&&n.addIssue({code:"custom",message:"A retained grader result changed."})}}});var h=e.string().trim().min(1).max(200),G=e.string().regex(/^[a-f0-9]{64}$/),Te=e.discriminatedUnion("kind",[e.object({kind:e.literal("hosted_chat"),modelId:h,localRuntime:e.union([e.object({providerId:e.literal("custom-openai-compatible"),configurationHash:G,maximumRequestCostUsd:e.number().finite().positive().max(1e4),requestTimeoutMs:e.number().int().min(1e3).max(3e5)}).strict(),Se,ae]).optional(),candidate:e.object({artifactId:h,contentHash:G,preparationId:h,dispatchId:h,baseProfileId:h,workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/)}).strict().optional(),harness:Xe.optional(),messages:xt.optional(),maxOutputTokens:e.number().int().min(1).max(1e6).default(1e5),temperature:e.number().min(0).max(2).default(0),topP:e.number().gt(0).max(1).default(1)}).strict(),e.object({kind:e.literal("fixture"),fixtureId:h}).strict()]),on=e.object({schemaVersion:e.literal("openpond.modelStarterAttemptRequest.v1"),operationId:h,teamId:h,modelProjectId:h.nullable(),project:V.optional(),taskset:b,taskId:h,environmentSeed:e.number().int().min(0).max(2147483647).default(0),policy:Te}).strict(),Pi=e.object({modelProjectId:h.nullable(),taskset:b,afterTaskId:h.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),ki=e.object({modelProjectId:h.nullable(),taskset:b,available:e.boolean(),unavailableReason:e.string().max(1e3).nullable(),models:e.array(e.object({id:h,name:e.string().max(500),maximumOutputTokens:e.number().int().min(1).max(1e6).optional()}).strict()).max(200),tasks:e.array(e.object({id:h,split:Be,inputPreview:e.string().max(500),fixtures:e.array(e.object({id:h,label:e.string().max(200)}).strict()).max(1e3)}).strict()).max(100),nextCursor:h.nullable()}).strict(),re=e.object({schemaVersion:e.literal("openpond.modelStarterAttemptSummary.v1"),id:h,revision:e.number().int().positive(),request:on,status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]),policySnapshot:e.object({modelId:h,provider:h,upstreamModelId:e.string().min(1).max(500),configurationHash:G}).strict().nullable(),createdAt:e.iso.datetime(),startedAt:e.iso.datetime().nullable(),completedAt:e.iso.datetime().nullable(),cleanupComplete:e.boolean(),resultAvailable:e.boolean(),score:e.number().min(0).max(1).nullable(),gradingStatus:e.enum(["not_started","pending","scored","unscorable","not_configured"]).default("not_started"),passed:e.boolean().nullable(),outputPreview:e.string().max(500).nullable(),error:e.object({code:h,message:e.string().max(2e3)}).strict().nullable()}).strict().superRefine((t,n)=>{t.request.policy.kind==="fixture"!=(t.policySnapshot===null)&&n.addIssue({code:"custom",path:["policySnapshot"],message:"Fixture execution must not claim a model identity."}),t.status==="completed"&&(!t.cleanupComplete||!t.resultAvailable||!t.completedAt)&&n.addIssue({code:"custom",message:"Completed attempts require retained results and confirmed cleanup."})}),_i=e.object({modelProjectId:h,afterId:h.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),ji=e.object({items:e.array(re).max(100),nextCursor:h.nullable()}).strict(),Hi=e.object({schemaVersion:e.literal("openpond.modelStarterAttemptResult.v1"),attempt:re,output:e.string().max(1048576).nullable(),messages:e.array(e.record(e.string(),e.unknown())).max(4002),composition:Ke.nullable(),grade:te.nullable().optional(),experimentGrade:yt.nullable().optional(),environment:e.object({status:e.enum(["completed","budget_exhausted","cancelled","timed_out","policy_failure","environment_failure"]),collected:e.boolean(),definition:b,initialStateHash:G.nullable(),finalStateHash:G.nullable(),attemptHash:G}).strict(),native:Ye.optional(),providerRequestIds:e.array(h).max(1001),contentHash:G}).strict().superRefine((t,n)=>{let i=t.attempt.request.policy.kind==="hosted_chat"?t.attempt.request.policy.harness:void 0;!!i!=!!t.native&&n.addIssue({code:"custom",path:["native"],message:"Standalone Harness results require their exact native evidence."}),t.native&&(!i||w(i)!==w(t.native.source)||t.native.modelConfigurationHash!==t.attempt.policySnapshot?.configurationHash||t.environment.initialStateHash!==null||t.environment.finalStateHash!==null||t.environment.status==="completed"&&(!t.environment.collected||t.output===null||t.native.partialOutputAvailable||t.native.outputHash!==w(t.output)))&&n.addIssue({code:"custom",path:["native"],message:"Native evidence differs from the admitted source, model or output."}),t.experimentGrade&&((t.grade||t.composition)&&n.addIssue({code:"custom",message:"Selected Experiment grading cannot claim another grade population."}),(!["completed","failed"].includes(t.attempt.status)||!t.attempt.resultAvailable||t.attempt.score!==t.experimentGrade.score||t.attempt.gradingStatus!==t.experimentGrade.gradingStatus||t.attempt.passed!==(t.experimentGrade.score===null?null:t.experimentGrade.passed))&&n.addIssue({code:"custom",message:"Experiment grading differs from its retained attempt summary."})),t.grade&&(t.composition&&n.addIssue({code:"custom",path:["grade"],message:"An ordinary grade cannot also claim a Reward composition."}),(!["completed","failed"].includes(t.attempt.status)||!t.attempt.resultAvailable||t.attempt.score!==t.grade.score||t.attempt.gradingStatus!==t.grade.gradingStatus||t.attempt.passed!==(t.grade.score===null?null:t.grade.passed))&&n.addIssue({code:"custom",path:["grade"],message:"Ordinary grade differs from its terminal attempt summary."}))});var B=e.string().trim().min(1).max(240),ve=e.string().regex(/^[a-f0-9]{64}$/),Ie=e.object({maxOutputTokens:e.number().int().min(1).max(1e6).default(4096),temperature:e.number().min(0).max(2).default(0),topP:e.number().gt(0).max(1).default(1)}).strict();var M=e.object({kind:e.literal("hosted_harness"),modelId:B,maxOutputTokens:Ie.shape.maxOutputTokens.removeDefault().optional(),temperature:Ie.shape.temperature.removeDefault().optional(),topP:Ie.shape.topP.removeDefault().optional(),localRuntime:ae.optional(),candidate:e.object({artifactId:B,contentHash:ve,preparationId:B,dispatchId:B,baseProfileId:B,workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/)}).strict().optional(),sourceCandidate:ge.shape.sourceCandidate,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max"]).optional(),profileRepositoryId:B,source:ge,modelConfigurationHash:ve,packageHash:ve,externalDatasetBinding:ee.optional()}).strict().superRefine((t,n)=>{JSON.stringify(t.externalDatasetBinding??null)!==JSON.stringify(t.source.externalDatasetBinding??null)&&n.addIssue({code:"custom",message:"The policy and source must bind the same external Dataset recipe."}),JSON.stringify(t.sourceCandidate??null)!==JSON.stringify(t.source.sourceCandidate??null)&&n.addIssue({code:"custom",message:"The policy and prepared source must bind the same actual source candidate."})});var _=e.string().trim().min(1).max(200),St=e.string().regex(/^[a-f0-9]{64}$/),sn=e.discriminatedUnion("kind",[Te.options[0],e.object({kind:e.literal("fixture")}).strict(),M]),D=e.object({schemaVersion:e.literal("openpond.modelTasksetRunRequest.v1"),operationId:_,teamId:_,modelProjectId:_.nullable(),name:e.string().trim().min(1).max(200).optional(),project:V.optional(),taskset:b,policy:sn,population:e.array(mt).min(1).max(1e4)}).strict().superRefine((t,n)=>{new Set(t.population.map(i=>i.receiptId)).size!==t.population.length&&n.addIssue({code:"custom",path:["population"],message:"Run receipt identities must be unique."}),t.population.some(i=>i.fixtureId!==null!=(t.policy.kind==="fixture"))&&n.addIssue({code:"custom",path:["population"],message:"Only fixture runs require a fixture identity for every member."}),t.population.some(i=>!/^(0|[1-9][0-9]*)$/.test(i.seed)||Number(i.seed)>2147483647)&&n.addIssue({code:"custom",path:["population"],message:"Hosted environment seeds must be integers from 0 to 2147483647."}),t.policy.kind==="hosted_harness"&&t.modelProjectId!==null&&n.addIssue({code:"custom",path:["modelProjectId"],message:"A Harness target retains its released Profile binding separately from Model artifacts."}),t.policy.kind==="hosted_harness"&&new Set(t.population.map(i=>y([i.taskId,i.seed]))).size!==t.population.length&&n.addIssue({code:"custom",path:["population"],message:"Harness case identities must be unique for each task and seed."})}),Tt=e.object({schemaVersion:e.literal("openpond.modelTasksetRunSummary.v1"),id:_,revision:e.number().int().positive(),teamId:_,modelProjectId:_.nullable(),name:e.string().trim().min(1).max(200).optional(),project:V.optional(),operationId:_,taskset:b,policyKind:e.enum(["hosted_chat","fixture","hosted_harness"]),manifestHash:St,status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]),totalCount:e.number().int().min(1).max(1e4),counts:e.object({pending:e.number().int().nonnegative(),running:e.number().int().nonnegative(),completed:e.number().int().nonnegative(),failed:e.number().int().nonnegative(),cancelled:e.number().int().nonnegative()}).strict(),createdAt:e.iso.datetime(),startedAt:e.iso.datetime().nullable(),completedAt:e.iso.datetime().nullable(),cleanupComplete:e.boolean(),resultAvailable:e.boolean(),score:e.number().min(0).max(1).nullable(),metricName:e.string().min(1).max(240),error:e.object({code:_,message:e.string().max(2e3)}).strict().nullable()}).strict().superRefine((t,n)=>{Object.values(t.counts).reduce((i,a)=>i+a,0)!==t.totalCount&&n.addIssue({code:"custom",path:["counts"],message:"Run counts must account for the complete population."}),t.status!=="completed"&&t.score!==null&&n.addIssue({code:"custom",path:["score"],message:"Only completed evaluations publish a metric value."}),["completed","failed","cancelled"].includes(t.status)&&(!t.completedAt||t.counts.pending||t.counts.running)&&n.addIssue({code:"custom",message:"Terminal runs require complete population accounting."}),t.status==="cancelled"&&!t.cleanupComplete&&n.addIssue({code:"custom",message:"Cancelled runs require confirmed cleanup."}),t.resultAvailable&&!["completed","failed","cancelled"].includes(t.status)&&n.addIssue({code:"custom",message:"Run results require terminal population accounting."}),t.status==="completed"&&(!t.cleanupComplete||!t.resultAvailable)&&n.addIssue({code:"custom",message:"Completed evaluations require retained results and confirmed cleanup."})}),vt=e.object({summary:Tt,request:D,manifest:ne,policySnapshot:re.shape.policySnapshot}).strict(),Ki=e.object({modelProjectId:_.optional(),projectId:V.shape.id.optional(),afterId:_.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),Wi=e.object({items:e.array(Tt).max(100),nextCursor:_.nullable()}).strict(),Xi=e.object({schemaVersion:e.literal("openpond.modelTasksetRunResult.v1"),run:vt,receipts:e.array(ct).min(1).max(1e4),metric:Ne.nullable(),contentHash:St}).strict();function cn(t,n){le(n,"Taskset run manifest");let i=t.policy;if(i.kind!=="hosted_harness"||n.execution.kind!=="harness"||y(n.profileEvaluation)!==y(i.source)||y(n.execution.harnessRelease)!==y(i.source.harnessRelease)||n.metadata.profileRepositoryId!==i.profileRepositoryId||n.packageHash!==i.packageHash||n.policy.kind!=="model"||n.policy.model.provider!==(i.localRuntime?.providerId??"openpond")||n.policy.model.model!==i.modelId||n.policy.model.revision!==null||n.policy.model.artifactHash!==(i.candidate?.contentHash??null)||n.policy.model.tokenizerRevision!==null||n.policy.model.chatTemplateHash!==null||n.policy.configurationHash!==i.modelConfigurationHash||n.tasksetRelease.id!==t.taskset.id||n.tasksetRelease.contentHash!==t.taskset.contentHash||y(n.population)!==y(t.population)||n.population.some(a=>a.receiptId!==`evaluation-${w(n.profileEvaluation?.externalDatasetBinding?[n.id,a.taskId,a.seed,a.fixtureId]:[n.id,a.taskId,a.seed]).slice(0,32)}`))throw new Error("Harness evaluation differs from its admitted source, package or model configuration.")}s(cn,"verifyHarnessExperimentManifest");async function Yi(t){let n=vt.parse(t),{summary:i,request:a,manifest:r,policySnapshot:o}=n;if(le(r,"Taskset run manifest"),r.contentHash!==i.manifestHash||r.id!==i.id||r.createdAt!==i.createdAt||i.teamId!==a.teamId||i.modelProjectId!==a.modelProjectId||y(i.project??null)!==y(a.project??null)||y(r.metadata.project??null)!==y(a.project??null)||(i.name??null)!==(a.name??null)||i.operationId!==a.operationId||i.policyKind!==a.policy.kind||i.totalCount!==a.population.length||i.metricName!==r.metricPolicy.primaryMetric||y(i.taskset)!==y(a.taskset)||r.tasksetRelease.id!==a.taskset.id||r.tasksetRelease.contentHash!==a.taskset.contentHash||y(r.population)!==y(a.population))throw new Error("Evaluation run differs from its admitted request or manifest.");if(a.policy.kind==="fixture"){if(r.policy.kind!=="fixture"||o!==null)throw new Error("Fixture checks cannot claim a model identity.")}else if(a.policy.kind==="hosted_harness"){if(cn(a,r),o!==null)throw new Error("Harness evaluations retain the native host model configuration.")}else if(r.policy.kind!=="model"||!o||o.modelId!==a.policy.modelId||r.policy.model.provider!==o.provider||r.policy.model.model!==o.upstreamModelId||r.policy.model.revision!==null||r.policy.model.artifactHash!==(a.policy.candidate?.contentHash??null)||r.policy.model.tokenizerRevision!==null||r.policy.model.chatTemplateHash!==null||r.policy.configurationHash!==await u({policy:a.policy,snapshot:o}))throw new Error("Evaluation model differs from its admitted policy.");return n}s(Yi,"verifyModelTasksetRunDetails");var wt=e.string().min(1).max(200).refine(t=>!["__proto__","prototype","constructor"].includes(t),"Use an ordinary field name."),mn=e.array(wt).min(1).max(20),It=e.enum(["input","output","expectedOutput","evaluatorContext"]),pn=e.object({destination:It,path:mn,source:It,sourcePath:e.array(wt).max(20)}).strict(),Re=e.array(pn).max(100).superRefine((t,n)=>{for(let[i,a]of t.entries())t.slice(0,i).some(r=>r.destination===a.destination&&(Rt(r.path,a.path)||Rt(a.path,r.path)))&&n.addIssue({code:"custom",path:[i,"path"],message:"Mapped destination paths must not overlap."})});function Rt(t,n){return t.length<=n.length&&t.every((i,a)=>i===n[a])}s(Rt,"prefix");var T=e.string().trim().min(1).max(200),J=e.string().regex(/^[a-f0-9]{64}$/),we=e.object({id:T,revision:e.number().int().positive(),contentHash:J}).strict(),Pe=e.object({id:T,version:e.string().min(1).max(200),contentHash:J,name:e.string().trim().min(1).max(500).optional(),feedbackKey:Le,release:we.nullable(),mappings:Re.optional()}).strict(),ke=e.object({id:T,version:e.string().min(1).max(200),contentHash:J,mappings:Re}).strict(),da=e.object({operationId:T,id:T.optional(),expectedRevision:e.number().int().nonnegative(),request:D,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(ke).min(1).max(100).optional()}).strict().superRefine((t,n)=>{t.request.name||n.addIssue({code:"custom",path:["request","name"],message:"Name this Experiment before saving it."}),!!t.id!=t.expectedRevision>0&&n.addIssue({code:"custom",path:["expectedRevision"],message:"An update requires its saved definition revision."}),Math.round(t.maximumCostUsd*1e6)<1&&n.addIssue({code:"custom",path:["maximumCostUsd"],message:"The budget must be at least $0.000001."}),t.graders&&new Set(t.graders.map(i=>i.id)).size!==t.graders.length&&n.addIssue({code:"custom",path:["graders"],message:"Select each grader once."})}),dn=e.object({schemaVersion:e.literal("openpond.experimentDefinition.v1"),id:T,teamId:T,revision:e.number().int().positive(),request:D,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(Pe).min(1).max(100),createdAt:e.iso.datetime(),updatedAt:e.iso.datetime()}).strict(),ua=dn.extend({contentHash:J}),la=e.object({operationId:T,definition:we}).strict(),ga=e.object({projectId:T.optional(),datasetHash:J.optional(),search:e.string().trim().max(200).optional(),status:e.enum(["queued","running","cancelling","completed","failed","cancelled"]).optional(),afterId:T.optional(),limit:e.number().int().min(1).max(100).default(30)}).strict(),ha=e.object({definition:we.nullable(),configurationHash:J.optional(),admissionRequestHash:J.optional(),sourceExperimentId:T.optional(),maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(Pe).min(1).max(100)}).strict().superRefine((t,n)=>{t.definition===null&&(!t.configurationHash||!t.admissionRequestHash)&&n.addIssue({code:"custom",path:["configurationHash"],message:"A flat Experiment requires its sealed configuration hash."})}),fa=e.object({operationId:T,profileRepositoryId:T,definitionId:T,modelId:T,localRuntime:M.shape.localRuntime,maxOutputTokens:M.shape.maxOutputTokens,temperature:M.shape.temperature,topP:M.shape.topP,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max"]).optional(),maximumCostUsd:e.number().finite().positive().max(1e4),externalDatasetBinding:ee.optional(),sourceCandidate:M.shape.sourceCandidate}).strict(),ba=e.object({request:D,manifest:ne,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(Pe).min(1).max(100)}).strict();var Pt=e.string().trim().min(1).max(200),_e=e.object({operationId:Pt,request:D,maximumCostUsd:e.number().finite().positive().max(1e4),graders:e.array(ke).min(1).max(100).optional(),sourceExperimentId:Pt.optional()}).strict().superRefine((t,n)=>{t.request.name||n.addIssue({code:"custom",path:["request","name"],message:"Name this Experiment before starting it."}),t.operationId!==t.request.operationId&&n.addIssue({code:"custom",path:["request","operationId"],message:"Use one operation identity for this Experiment."}),Math.round(t.maximumCostUsd*1e6)<1&&n.addIssue({code:"custom",path:["maximumCostUsd"],message:"The spending cap must be at least $0.000001."}),t.graders&&new Set(t.graders.map(i=>i.id)).size!==t.graders.length&&n.addIssue({code:"custom",path:["graders"],message:"Select each grader once."})});var g=e.string().trim().min(1).max(200),H=e.string().regex(/^[a-f0-9]{64}$/),oe=e.object({id:g,contentHash:H}).strict(),Aa=e.object({available:e.boolean(),reason:e.string().max(1e3).nullable(),origin:U.nullable()}).strict(),kt=e.object({schemaVersion:e.literal("openpond.postTrainingAttachment.v1"),binding:e.object({kind:e.enum(["preparation","policy"]),id:g,revision:e.number().int().positive(),contentHash:H}).strict(),projectId:g.nullable(),automatic:e.boolean(),maximumSpendUsd:e.number().finite().positive().max(1e4),experiments:e.array(e.object({id:g,configuration:_e}).strict()).min(1).max(20),acceptancePlan:rt.nullable()}).strict().superRefine((t,n)=>{if(new Set(t.experiments.map(i=>i.id)).size!==t.experiments.length&&n.addIssue({code:"custom",message:"Attach each evaluation once."}),t.experiments.reduce((i,a)=>i+a.configuration.maximumCostUsd,0)>t.maximumSpendUsd+1e-9&&n.addIssue({code:"custom",message:"Attached evaluation budgets exceed the total approved budget."}),t.experiments.some(i=>(i.configuration.request.project?.id??null)!==t.projectId)&&n.addIssue({code:"custom",message:"Attached experiments must use the training Project."}),t.acceptancePlan){let i=new Set(t.acceptancePlan.checks.map(r=>r.id));t.acceptancePlan.checks.some(r=>!t.experiments.some(o=>o.id===r.id))&&n.addIssue({code:"custom",message:"Select the frozen Experiment for each acceptance check."}),t.acceptancePlan.maximumSpendUsd+t.experiments.filter(r=>!i.has(r.id)).reduce((r,o)=>r+o.configuration.maximumCostUsd,0)>t.maximumSpendUsd+1e-9&&n.addIssue({code:"custom",message:"Paired acceptance and diagnostic ceilings exceed the approved evaluation budget."})}});var un=e.object({baseline:oe,checks:e.array(e.object({id:g,sourceRunId:g,sourceManifestHash:H,targetConfigurationHash:H,executionHash:H,populationHash:H,evaluator:oe,feedbackKey:g,output:e.enum(["boolean","score"]),unit:e.string().min(1).max(80)}).strict()).min(1).max(100)}).strict(),ln=e.enum(["waiting_for_training","ready","preparing","queued","running","cleaning","completed","failed","blocked","cancelled","budget_exhausted"]),_t=e.object({schemaVersion:e.literal("openpond.postTrainingSummary.v1"),id:g,teamId:g,jobId:g,revision:e.number().int().positive(),planHash:H,automatic:e.boolean(),candidate:oe.nullable(),state:ln,total:e.number().int().positive(),completed:e.number().int().nonnegative(),failed:e.number().int().nonnegative(),requiredOutcome:e.enum(["none","pending","passed","failed","blocked"]),reason:e.string().max(500).nullable(),groupId:g.nullable(),experimentIds:e.array(g).max(20),updatedAt:e.iso.datetime()}).strict().superRefine((t,n)=>{t.completed+t.failed>t.total&&n.addIssue({code:"custom",message:"Evaluation totals are inconsistent."}),["preparing","queued","running","cleaning","completed"].includes(t.state)&&!t.candidate&&n.addIssue({code:"custom",message:"Evaluation execution requires the exact trained candidate."})}),gn=e.object({operationId:g,expectedRevision:e.number().int().positive(),planHash:H}).strict(),hn=e.object({operationId:g,attachment:kt}).strict(),fn=e.object({id:g,teamId:g,ownerUserId:g,attachment:kt,qualification:un.nullable(),contentHash:H,createdAt:e.iso.datetime()}).strict();function bn(t){let n=fn.parse(t);if(n.contentHash!==w({attachment:n.attachment,qualification:n.qualification}))throw new Error("The retained evaluation attachment or qualification changed.");return n}s(bn,"verifyPostTrainingPlan");function jt(t){let{request:n}=t,i={accept:"application/json","content-type":"application/json"},a=s(o=>`/v1/training/jobs/${encodeURIComponent(g.parse(o))}/post-training`,"path");async function r(o,m,c){if(o===null)return null;let x=_t.parse(o);if(x.teamId!==m||x.jobId!==c)throw new d("post_training_scope_mismatch","The evaluation summary belongs to another run or workspace.");return x}return s(r,"read"),{async attach(o,m){let c=hn.parse(m),x=bn(await n("/v1/training/post-training-plans",{method:"POST",headers:i,body:JSON.stringify(c)}));if(x.teamId!==o||await u(x.attachment)!==await u(c.attachment))throw new d("post_training_plan_mismatch","The retained attachment differs from the reviewed plan.");return x},async get(o,m){return r(await n(a(m),{headers:i}),o,m)},async control(o,m,c,x){let R=gn.parse(x),v=await r(await n(`${a(m)}/${c}`,{method:"POST",headers:i,body:JSON.stringify(R)}),o,m);if(!v||v.planHash!==R.planHash)throw new d("post_training_control_mismatch","Evaluation control did not retain the approved plan.");return v}}}s(jt,"createPostTrainingClient");var Ca=e.object({teamId:g,actorId:g,projectId:g.nullable(),configuration:xe,batches:e.array(tt).max(1e4),sources:e.array(et).max(1e4),definitions:e.array(Ze).max(1e4),experiments:e.array(e.object({id:g,name:e.string().max(500),configuration:_e,graders:e.array(e.object({feedbackKey:g,name:e.string().max(500),ref:oe}).strict()).max(100)}).strict()).max(1e4)}).strict(),qa=e.enum(["prepare","start","cancel","publish","attach"]),za=e.object({teamId:g,actorId:g,configuration:xe,policy:nt,inspection:at,iterations:e.array(e.object({iteration:it,evals:_t.nullable()}).strict()).max(100),nextCursor:g.nullable()}).strict(),Ma=e.object({id:g,expectedRevision:e.number().int().positive(),policyHash:H,operationId:g,action:e.enum(["pause","resume","reserve","cancel-iteration","retry-iteration"]),iterationId:g.optional(),iterationRevision:e.number().int().positive().optional()}).strict();var K=e.string().trim().min(1).max(191),se=e.string().regex(/^[a-f0-9]{64}$/),Ht=e.object({schemaVersion:e.literal("openpond.checkpointRecoveryResourceApproval.v1"),ownerUserId:K,teamId:K,sourceJobId:K,sourceJobVersion:e.number().int().positive(),sourceInputManifestSha256:se,checkpointId:K,adapterSha256:se,resumeSha256:se,idempotencyKey:e.string().trim().min(16).max(191),approvedAt:e.iso.datetime({offset:!0}),maximumSpendUsd:e.number().positive().finite().max(30).refine(t=>Number(t.toFixed(6))===t,"Recovery spend must use whole microdollars"),maximumGpuSeconds:e.number().int().positive().max(21600),maximumWallSeconds:e.number().int().positive().max(21600)}).strict(),W=Ht.extend({approvalHash:se}).strict().superRefine((t,n)=>{t.maximumGpuSeconds>t.maximumWallSeconds&&n.addIssue({code:"custom",path:["maximumGpuSeconds"],message:"Recovery GPU duration exceeds its wall"})});async function xn(t){let n=Ht.parse(t);return W.parse({...n,approvalHash:await u(n)})}s(xn,"createTrainingCheckpointRecoveryResourceApproval");var je=e.object({resourceApproval:W.optional(),mode:e.literal("evaluation_only").optional(),evaluationGpuType:e.enum(["NVIDIA A100 80GB PCIe","NVIDIA A100-SXM4-80GB","NVIDIA H100 80GB HBM3"]).optional(),expectedVersion:e.number().int().positive(),checkpointId:K,idempotencyKey:e.string().trim().min(16).max(191),maximumSpendUsd:e.number().positive().finite(),maximumWallSeconds:e.number().int().positive().max(21600)}).strict().superRefine((t,n)=>{t.evaluationGpuType&&t.mode!=="evaluation_only"&&n.addIssue({code:"custom",path:["evaluationGpuType"],message:"GPU substitution requires explicit evaluation-only recovery"});let i=t.resourceApproval;i&&(i.sourceJobVersion!==t.expectedVersion||i.checkpointId!==t.checkpointId||i.idempotencyKey!==t.idempotencyKey||i.maximumSpendUsd!==t.maximumSpendUsd||i.maximumWallSeconds!==t.maximumWallSeconds)&&n.addIssue({code:"custom",path:["resourceApproval"],message:"Recovery resource approval does not match its request"})});var X=e.object({mode:e.literal("reuse_only"),physicalWorkerId:e.string().trim().min(1).max(191),providerPodId:e.string().trim().min(1).max(191),workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/),baseProfileSha256:e.string().regex(/^[a-f0-9]{64}$/),gpuType:e.string().trim().min(1).max(200),sourceJobId:e.string().trim().min(1).max(191),sourceInputManifestSha256:e.string().regex(/^[a-f0-9]{64}$/),ownerTeamId:e.string().trim().min(1).max(191),deadlineAt:e.string().datetime({offset:!0})}).strict();var S=e.string().trim().min(1).max(191),Y=e.string().regex(/^[a-f0-9]{64}$/),Ee=e.object({schemaVersion:e.literal("openpond.trainingPreparationRequest.v1"),teamId:S,operationId:S,projectId:S.nullable(),configuration:e.object({id:S,expectedRevision:e.number().int().positive(),expectedEtag:Y}).strict(),origin:U.optional(),batch:b,name:e.string().trim().min(1).max(191),maximumSpendUsd:e.number().finite().positive().max(1e6),gpuSelection:A.optional(),physicalPlacement:X.optional()}).strict(),Et=e.object({schemaVersion:e.literal("openpond.trainingPreparationPlan.v1"),id:S,creatorUserId:S,request:Ee,requestHash:Y,source:e.lazy(()=>Ce),submissionHash:Y,createdAt:e.string().datetime({offset:!0})}).strict(),At=Et.extend({contentHash:Y}).strict(),Ae=e.object({schemaVersion:e.literal("openpond.trainingPreparationReceipt.v1"),plan:At,revision:e.number().int().positive(),state:e.enum(["prepared","submitted","cancelled"]),jobId:S.nullable()}).strict().superRefine((t,n)=>{t.state==="submitted"!=!!t.jobId&&n.addIssue({code:"custom",path:["jobId"],message:"Only submitted preparations identify a job."})}),He=e.object({teamId:S,planHash:Y,expectedRevision:e.number().int().positive(),estimateReview:$.optional()}).strict(),Ct=e.object({projectId:S.optional(),state:e.enum(["prepared","submitted","cancelled"]).optional(),afterId:S.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),qt=e.object({schemaVersion:e.literal("openpond.trainingPreparationPage.v1"),teamId:S,items:e.array(Ae).max(100),nextCursor:S.nullable()}).strict();async function zt(t){let n=Ae.parse(t),{contentHash:i,...a}=n.plan;if(await u(a)!==i||await u(a.request)!==a.requestHash||a.source.modelProject.id!==a.request.configuration.id||await u(a.source.origin??null)!==await u(a.request.origin??null))throw new d("training_preparation_mismatch","The prepared training inputs changed.");return n}s(zt,"parseAndVerifyTrainingPreparationReceipt");function Mt(t){async function n(i,a,r){let o=await zt(i);if(o.plan.request.teamId!==a||r&&o.plan.id!==r)throw new d("training_preparation_scope_mismatch","The training preparation belongs to a different workspace or request.");return o}return s(n,"read"),{async listPreparations(i,a={}){let r=S.parse(i),o=Ct.parse(a),m=new URLSearchParams;for(let[R,v]of Object.entries(o))m.set(R,String(v));let c=qt.parse(await t(`/v1/training/preparations?${m}`));if(c.teamId!==r||c.items.length>o.limit||new Set(c.items.map(R=>R.plan.id)).size!==c.items.length||c.nextCursor!==null&&(c.nextCursor!==c.items.at(-1)?.plan.id||c.nextCursor===o.afterId))throw new d("training_preparation_page_mismatch","The preparation page does not match its workspace or cursor.");let x=await Promise.all(c.items.map(async R=>{let v=await n(R,r);if(o.projectId&&v.plan.request.projectId!==o.projectId||o.state&&v.state!==o.state)throw new d("training_preparation_page_mismatch","A preparation does not match the requested Project or state.");return v}));return{...c,items:x}},async prepareRun(i){let a=Ee.parse(i),r=await n(await t("/v1/training/preparations",{method:"POST",body:JSON.stringify(a)}),a.teamId);if(r.plan.requestHash!==await u(a))throw new d("training_preparation_request_mismatch","The preparation does not match the requested run.");return r},async getPreparation(i,a){return n(await t(`/v1/training/preparations/${encodeURIComponent(S.parse(a))}`),S.parse(i),a)},async startPreparation(i,a){let r=He.parse(a),o=await n(await t(`/v1/training/preparations/${encodeURIComponent(S.parse(i))}/start`,{method:"POST",body:JSON.stringify(r)}),r.teamId,i);if(o.plan.contentHash!==r.planHash||o.state!=="submitted")throw new d("training_preparation_start_mismatch","The submitted run does not match the approved preparation.");return o},async cancelPreparation(i,a){let r=He.parse(a),o=await n(await t(`/v1/training/preparations/${encodeURIComponent(S.parse(i))}/cancel`,{method:"POST",body:JSON.stringify(r)}),r.teamId,i);if(o.plan.contentHash!==r.planHash||o.state!=="cancelled")throw new d("training_preparation_cancel_mismatch","The preparation cancellation could not be verified.");return o}}}s(Mt,"createTrainingPreparationClient");var I=e.string().trim().min(1).max(191),L=e.string().regex(/^[a-f0-9]{64}$/),qe=e.string().datetime({offset:!0}),P=e.number().finite().nonnegative(),Ot=e.discriminatedUnion("kind",[e.object({kind:e.literal("preparation"),id:I,planHash:L,expectedRevision:e.number().int().positive()}).strict(),e.object({kind:e.literal("configuration"),id:I,expectedRevision:e.number().int().positive(),expectedEtag:L,batch:b.nullable().default(null)}).strict(),e.object({kind:e.literal("submission"),submission:e.lazy(()=>ze)}).strict()]),Ut=e.object({schemaVersion:e.literal("openpond.trainingEstimateRequest.v1"),teamId:I,source:Ot,gpuSelection:A.optional()}).strict(),ce=e.object({low:P,high:P}).strict().refine(t=>t.high>=t.low,"Planning range must be ordered"),Gt=e.object({phase:e.enum(["startup","baseline_evaluation","rollouts","optimization","checkpointing","backbone_materialization","final_evaluation","publication","cleanup","retention"]),resource:e.enum(["gpu","cpu","judge","storage","network"]),expectedUsd:P.nullable(),expectedSeconds:P.nullable(),planningRangeUsd:ce.nullable(),evidence:e.enum(["measured","configured_rate","unavailable"]),reason:e.string().trim().min(1).max(1e3).nullable()}).strict();function Dt(t){return t.kind==="submission"?{kind:t.kind,id:t.submission.idempotencyKey,contentHash:t.submission.contentHash,revision:null}:t.kind==="preparation"?{kind:t.kind,id:t.id,contentHash:t.planHash,revision:t.expectedRevision}:{kind:t.kind,id:t.id,contentHash:t.expectedEtag,revision:t.expectedRevision}}s(Dt,"trainingEstimateSourceIdentity");var Jt=e.object({schemaVersion:e.literal("openpond.trainingEstimate.v1"),id:I,teamId:I,requestHash:L,inputHash:L,source:e.object({kind:e.enum(["preparation","configuration","submission"]),id:I,contentHash:L,revision:e.number().int().positive().nullable()}).strict(),status:e.enum(["available","partial","insufficient_evidence"]),currency:e.literal("USD"),createdAt:qe,expiresAt:qe,estimatorVersion:I,runtimeVersion:I,pricing:e.object({version:I,quoteExpiresAt:qe.nullable()}).strict(),gpu:e.object({requested:A,resolved:e.object({availabilityId:I,gpuType:e.string().min(1).max(256),gpuCount:e.union([e.literal(1),e.literal(2)])}).strict().nullable(),customerHourlyUsd:P.nullable(),availability:e.enum(["available","limited","unavailable","unknown"])}).strict(),configuration:e.object({modelId:I,modelRevision:e.string().min(1).max(256),method:I,loraRank:e.number().int().positive().nullable(),adapterMode:e.enum(["residual_append","shared","sequential_merge"]).nullable(),groups:e.number().int().nonnegative().nullable(),rolloutConcurrency:e.number().int().positive().nullable(),maxOutputTokens:e.number().int().positive().nullable(),trainingRows:e.number().int().nonnegative().nullable(),evaluationRows:e.number().int().nonnegative().nullable(),retentionDays:e.number().int().positive().nullable(),approvedMaximumUsd:P.nullable()}).strict(),cost:e.object({expectedUsd:P.nullable(),planningRangeUsd:ce.nullable(),knownMinimumUsd:P,recommendedMaximumUsd:P.nullable(),minimumCleanupReserveUsd:P.nullable(),components:e.array(Gt).max(50)}).strict(),executionSeconds:e.object({expected:P.nullable(),planningRange:ce.nullable()}).strict(),queueWaitSeconds:e.object({expected:P,planningRange:ce.nullable()}).strict().nullable(),calibration:e.object({version:I,cohortHash:L,completedSamples:e.number().int().nonnegative(),partialSamples:e.number().int().nonnegative(),scope:e.enum(["workspace","authorized_aggregate"])}).strict(),assumptions:e.array(e.string().trim().min(1).max(1e3)).max(50),unknowns:e.array(e.string().trim().min(1).max(1e3)).max(50),review:$}).strict().superRefine((t,n)=>{(t.review.estimateId!==t.id||t.review.inputHash!==t.inputHash||t.review.requestHash!==t.requestHash||t.review.pricingVersion!==t.pricing.version||t.review.expiresAt!==t.expiresAt)&&n.addIssue({code:"custom",path:["review"],message:"Estimate review identity differs from the estimate"}),Date.parse(t.expiresAt)<=Date.parse(t.createdAt)&&n.addIssue({code:"custom",path:["expiresAt"],message:"Estimate must expire after its creation"}),t.status==="available"&&(t.cost.expectedUsd===null||t.executionSeconds.expected===null||t.unknowns.length>0)&&n.addIssue({code:"custom",path:["status"],message:"An available estimate requires complete cost and duration coverage"}),t.gpu.requested.mode==="manual"&&t.gpu.resolved&&(t.gpu.requested.availabilityId!==t.gpu.resolved.availabilityId||t.gpu.requested.gpuType!==t.gpu.resolved.gpuType)&&n.addIssue({code:"custom",path:["gpu"],message:"An explicit GPU offering cannot be substituted"}),t.gpu.resolved&&t.gpu.resolved.gpuCount!==(t.gpu.requested.gpuCount??1)&&n.addIssue({code:"custom",path:["gpu","resolved","gpuCount"],message:"The resolved GPU count must match the requested count"})});function $t(t){return{async estimate(n){let i=Ut.parse(n);i.source.kind==="submission"&&await me(i.source.submission);let a=Jt.parse(await t("/v1/training/estimates",{method:"POST",body:JSON.stringify(i)}));if(a.teamId!==i.teamId||a.requestHash!==await u(i)||await u(a.source)!==await u(Dt(i.source))||i.gpuSelection&&await u(a.gpu.requested)!==await u(i.gpuSelection))throw new d("training_estimate_scope_mismatch","The estimate does not match the requested workspace and exact configuration.");return a}}}s($t,"createTrainingEstimateClient");var pe=e.string().datetime({offset:!0}),Me=e.object({ticketId:e.string().trim().min(1).max(191),ticketNumber:e.number().int().positive().max(Number.MAX_SAFE_INTEGER),label:e.literal("Waiting for resources"),position:e.number().int().positive().nullable(),positionScope:e.literal("compatible_fair_queue"),enqueuedAt:pe,asOf:pe,estimate:e.object({revision:e.number().int().nonnegative(),estimatedStartAt:pe,expiresAt:pe,evidence:e.enum(["observed_capacity","measured_bootstrap","scheduled_release"])}).strict().nullable()}).strict().superRefine((t,n)=>{t.estimate&&Date.parse(t.estimate.expiresAt)<=Date.parse(t.asOf)&&n.addIssue({code:"custom",path:["estimate"],message:"An expired queue forecast must be returned as unavailable"})});var Nt=e.object({schemaVersion:e.literal("openpond.trainingHarnessSourcePublication.v1"),harnessRelease:ue,sourcePackageHash:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().positive().max(67108864)}).strict();function Bt(t){let n=s(i=>{let a=ue.parse(i);return`/v1/training/harness-sources/${encodeURIComponent(a.id)}/${a.contentHash}`},"route");return{async publishHarnessSource(i){k(i,67108864,"Training Harness source");let a=Vt(i),r=a.agentSnapshot.portability;if(!r.portable||r.blockers.length||r.localOnlyAssetRefs.length||r.hostPrivateAssetRefs.length||a.schemaVersion==="openpond.harnessSourcePackage.v1"&&a.harnessRelease.files.some(m=>m.visibility!=="policy"))throw new Error("Hosted training Harness publication requires portable, policy-visible source.");let o=Nt.parse(await t(n({id:a.harnessRelease.id,contentHash:a.harnessRelease.contentHash}),{method:"PUT",body:JSON.stringify(a)}));if(o.harnessRelease.id!==a.harnessRelease.id||o.harnessRelease.contentHash!==a.harnessRelease.contentHash||o.sourcePackageHash!==a.contentHash)throw new Error("Published Harness source differs from the selected immutable package.");return o},async getHarnessSource(i){let a=await t(n(i),void 0,67108864);return k(a,67108864,"Training Harness source"),Vt(a,i)}}}s(Bt,"createTrainingHarnessSourceClient");function Vt(t,n){return typeof t=="object"&&t!==null&&Reflect.get(t,"schemaVersion")==="openpond.harnessPolicySourcePackage.v1"?$e(t,n):Ve(t,n)}s(Vt,"validateSource");var O=e.string().trim().min(1).max(500),yn=e.string().regex(/^[a-f0-9]{64}$/),de=e.object({schemaVersion:e.literal("openpond.trainingCandidateDecisionRequest.v1"),teamId:O,jobId:O,artifact:p,evaluation:p,executionReceipt:p,decision:e.enum(["accepted","rejected"]),reason:e.string().trim().min(1).max(5e3),idempotencyKey:O,expectedDecision:p.nullable()}).strict(),Lt=e.object({schemaVersion:e.literal("openpond.trainingCandidateDecision.v1"),id:O,request:de,revision:e.number().int().positive(),actor:e.object({userId:O,kind:e.enum(["user","api_key","agent_delegate"]),id:O}).strict(),decidedAt:e.string().datetime({offset:!0}),contentHash:yn}).strict().superRefine((t,n)=>{t.revision===1!=(t.request.expectedDecision===null)&&n.addIssue({code:"custom",path:["revision"],message:"A first decision has no predecessor; later decisions must reference the prior decision."}),t.request.expectedDecision?.id===t.id&&n.addIssue({code:"custom",path:["request","expectedDecision"],message:"A decision cannot supersede itself."})});async function Qt(t){let{contentHash:n,...i}=t;return u(i)}s(Qt,"trainingCandidateDecisionHash");async function Oe(t,n){k(t,32768,"Training candidate decision");let i=Lt.parse(t);if(i.contentHash!==await Qt(i))throw new d("content_hash_mismatch","Training candidate decision content hash does not match.");if(i.request.teamId!==n.teamId||i.request.jobId!==n.jobId||i.request.artifact.id!==n.artifact.id||i.request.artifact.contentHash!==n.artifact.contentHash)throw new d("candidate_decision_identity_mismatch","Training candidate decision belongs to a different team, Job or artifact.");if(n.request&&await u(i.request)!==await u(de.parse(n.request)))throw new d("candidate_decision_request_mismatch","Training candidate decision does not match the submitted review.");return i}s(Oe,"parseAndVerifyTrainingCandidateDecision");function Ft(t){function n(i){return`/v1/training/jobs/${encodeURIComponent(O.parse(i.jobId))}/candidates/${encodeURIComponent(p.parse(i.artifact).id)}/decision`}return s(n,"route"),{async candidateDecision(i,a={}){O.parse(i.teamId);let r=a.decision?p.parse(a.decision):void 0,o=r?`?decisionId=${encodeURIComponent(r.id)}`:"",m=e.object({decision:e.unknown().nullable()}).strict().parse(await t(`${n(i)}${o}`));if(m.decision===null&&!r)return null;let c=await Oe(m.decision,i);if(r&&(c.id!==r.id||c.contentHash!==r.contentHash))throw new d("candidate_decision_identity_mismatch","Training candidate decision does not match the requested history entry.");return c},async recordCandidateDecision(i){let a=de.parse(i),r=await t(n(a),{method:"POST",body:JSON.stringify(a)});return Oe(r,{...a,request:a})}}}s(Ft,"createTrainingCandidateDecisionClient");var Q=e.string().trim().min(1).max(500),Z=e.string().regex(/^[a-f0-9]{64}$/),Kt=e.object({taskId:Q,taskSha256:Z,resultSha256:Z,input:e.object({instruction:e.string().max(1e6),context:e.record(e.string(),e.unknown())}).strict(),output:e.string().max(1e6),outputSha256:Z,score:e.number().finite().min(0).max(1),evidence:e.object({kind:e.enum(["worker_command","hosted_trace","local_trace"]),id:Q}).strict()}).strict(),Wt=e.object({schemaVersion:e.literal("openpond.trainingEvaluationTaskPage.v1"),jobId:Q,teamId:Q,evaluation:p,kind:e.enum(["baseline","candidate"]),policyVersion:e.number().int().nonnegative(),taskset:b,panelSha256:Z,offset:e.number().int().nonnegative(),total:e.number().int().min(1).max(1e4),tasks:e.array(Kt).min(1).max(100),nextCursor:e.string().regex(/^[1-9]\d*$/).nullable(),contentHash:Z}).strict().superRefine((t,n)=>{let i=t.offset+t.tasks.length,a=i<t.total?String(i):null;(i>t.total||t.nextCursor!==a)&&n.addIssue({code:"custom",path:["nextCursor"],message:"Evaluation pagination must cover consecutive task positions."}),new Set(t.tasks.map(r=>r.taskId)).size!==t.tasks.length&&n.addIssue({code:"custom",path:["tasks"],message:"Evaluation task identities must be unique."})});async function Xt(t){let{contentHash:n,...i}=t;return u(i)}s(Xt,"trainingEvaluationTaskPageHash");async function Ue(t,n){k(t,8388608,"Training evaluation task page");let i=Wt.parse(t),a=p.parse(n.evaluation);if(i.jobId!==Q.parse(n.jobId)||i.evaluation.id!==a.id||i.evaluation.contentHash!==a.contentHash||i.offset!==(n.offset??0)||n.teamId!==void 0&&i.teamId!==Q.parse(n.teamId))throw new d("evaluation_page_identity_mismatch","Evaluation results differ from the requested Job, evaluation, or page.");if(await Xt(i)!==i.contentHash)throw new d("evaluation_page_hash_mismatch","Evaluation task page content hash did not match.");for(let r of i.tasks)if(await u(r.output)!==r.outputSha256)throw new d("evaluation_output_hash_mismatch","A retained evaluation output hash did not match.");return i}s(Ue,"parseAndVerifyTrainingEvaluationTaskPage");var Sn=e.array(e.object({id:e.string().trim().min(1)}).catchall(e.unknown())).min(1).max(1e3),Tn=e.object({binding:Fe,rewards:e.array(Qe).min(1).max(100)}).strict();async function vn(t){let n=t.rewardExecution?Tn.parse(t.rewardExecution):null,i=Sn.parse(n?We(n.binding,n.rewards):t.graders);if(new Set(i.map(r=>r.id)).size!==i.length)throw new Error("Training grader identities must be unique.");let a=await u({schemaVersion:"openpond.trainingGraderSet.v1",graders:i});return{kind:"deterministic",grader:{id:`training-graders-${a.slice(0,32)}`,contentHash:a},composer:n?{id:n.binding.id,contentHash:n.binding.contentHash}:null}}s(vn,"deterministicTrainingRewardSource");var In="evaluation-source.json",Ge=e.object({id:e.string().trim().min(1),clusterKey:e.string().trim().min(1),split:e.enum(["train","validation","frozen_eval"])}).passthrough(),Yt=e.object({schemaVersion:e.literal("openpond.trainingEvaluationSource.v1"),taskset:b,tasks:e.array(Ge).min(1).max(1e4),assets:e.array(e.object({path:e.string().trim().min(1).max(2e3),sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().nonnegative(),encoding:e.literal("base64"),content:e.string().max(32*1024*1024)}).strict()).max(1e4)}).strict().superRefine((t,n)=>{let i=new Set;t.tasks.forEach((a,r)=>{a.split==="train"&&n.addIssue({code:"custom",path:["tasks",r,"split"],message:"Evaluation sources require held-out tasks."}),i.has(a.id)&&n.addIssue({code:"custom",path:["tasks",r,"id"],message:"Evaluation task identities must be unique."}),i.add(a.id)})});function Rn(t,n){let i=e.array(Ge).min(1).max(1e4).parse(t),a=e.array(Ge).min(1).max(1e4).parse(n),r=new Set,o=new Set;for(let c of i){if(c.split!=="train")throw new Error("The training population contains a held-out task.");if(r.has(c.id))throw new Error("Training task identities must be unique.");r.add(c.id),o.add(c.clusterKey)}let m=new Set;for(let c of a){if(c.split==="train")throw new Error("The evaluation population contains a training task.");if(m.has(c.id))throw new Error("Evaluation task identities must be unique.");if(r.has(c.id)||o.has(c.clusterKey))throw new Error("Training and evaluation tasks or families overlap.");m.add(c.id)}}s(Rn,"assertTrainingEvaluationIsolation");async function wn(t){let n=Yt.parse(t),i=await u(n);return{taskset:n.taskset,dataset:{id:`training-evaluation-${i.slice(0,32)}`,contentHash:i}}}s(wn,"trainingEvaluationSourceRef");var l=e.string().trim().min(1).max(500),f=e.string().regex(/^[a-f0-9]{64}$/),j=e.string().datetime({offset:!0}),Pn=e.object({schemaVersion:e.literal("openpond.trainingInputArtifactUpload.v2"),kind:e.enum(["portable_training_bundle","reward_model_dataset"]),idempotencyKey:e.string().trim().min(1).max(500),sourceManifest:p,payload:e.unknown(),contentHash:f}).strict(),kn=e.object({schemaVersion:e.literal("openpond.trainingInputArtifact.v2"),kind:e.enum(["portable_training_bundle","reward_model_dataset"]),sourceManifest:p,artifactRef:e.string().trim().min(1).max(2e3),contentHash:f,sizeBytes:e.number().int().positive(),createdAt:j}).strict();async function _n(t){let{contentHash:n,...i}=t;return u(i)}s(_n,"trainingInputArtifactUploadHash");async function jn(t){k(t,67108864,"Training input artifact");let n=Pn.parse(t),i=await _n(n);if(n.contentHash!==i)throw new d("content_hash_mismatch",`Training input artifact contentHash ${n.contentHash} does not match ${i}.`);return n}s(jn,"parseAndVerifyTrainingInputArtifactUpload");var en=e.enum(["reward_model_train","policy_optimize"]),Hn=e.enum(["queued","admitting","provisioning","running","stopping","cancelling","succeeded","failed","cancelled"]),En=e.object({id:l,version:e.string().trim().min(1).max(200).nullable().default(null),required:e.boolean().default(!0)}).strict(),Ce=e.object({origin:U.optional(),modelProject:e.object({id:l,portableProjectId:l,revision:e.number().int().positive(),contentHash:f}).strict(),harnessRunManifest:p,harnessRelease:p,taskset:b,tasksetRelease:p,evaluation:e.object({taskset:b,dataset:p}).strict().nullable().optional(),dataset:p,evidenceSets:e.array(p).max(1e4)}).strict(),An=e.object({kind:e.literal("reward_model_train"),baseModel:ie,preferenceDatasetRelease:p,processorRelease:p,recipe:e.object({schemaVersion:e.literal("openpond.rewardModelRecipe.v1"),method:e.literal("reward_model"),parameterization:e.literal("lora_with_scalar_head")}).catchall(e.unknown())}).strict(),Cn=e.object({kind:e.literal("deterministic"),grader:p,composer:p.nullable().default(null)}).strict(),qn=e.object({kind:e.literal("learned_reward"),rewardModelVersion:p,qualificationReport:p.nullable().default(null),evaluationReferences:e.array(p).max(1e3).default([]),scorerArtifact:e.object({artifactRef:e.string().trim().min(1).max(2e3),contentHash:f,executionReceipt:p}).strict(),processorRelease:p,rewardComposerRelease:p}).strict(),tn=ie.extend({revision:e.string().regex(/^[a-f0-9]{40,64}$/),tokenizerRevision:e.string().regex(/^[a-f0-9]{40,64}$/),chatTemplateHash:f}).strict(),zn=e.object({kind:e.literal("policy_optimize"),executionMode:e.literal("qualification").optional(),baseModel:ie,recipe:pt,rewardSource:e.discriminatedUnion("kind",[Cn,qn]),resumeFrom:p.nullable().default(null)}).strict().superRefine((t,n)=>{if(t.recipe.method!=="sft")return;let i=z.safeParse(t.recipe);if(!i.success){n.addIssue({code:"custom",path:["recipe"],message:"The SFT recipe is incomplete or invalid."});return}(t.executionMode||t.resumeFrom||"continuation"in t.recipe)&&n.addIssue({code:"custom",message:"Initial managed SFT requires a fresh supervised run without rollout qualification or continuation."}),(i.data.baseModel.id!==t.baseModel.modelId||i.data.baseModel.revision!==t.baseModel.revision||i.data.baseModel.tokenizerRevision!==t.baseModel.tokenizerRevision||i.data.baseModel.chatTemplateHash!==t.baseModel.chatTemplateHash)&&n.addIssue({code:"custom",path:["baseModel"],message:"The SFT recipe must pin the exact submitted base and tokenizer."})}),Mn=e.discriminatedUnion("kind",[An,zn]),On=e.object({approvalHash:f,approvedAt:j,exportApproved:e.boolean(),maximumSpendUsd:e.number().nonnegative(),retentionDays:e.number().int().nonnegative().nullable(),region:e.string().trim().min(1).max(200).nullable().default(null)}).strict(),ze=e.object({schemaVersion:e.literal("openpond.trainingJobSubmission.v2"),idempotencyKey:e.string().trim().min(1).max(500),name:e.string().trim().min(1).max(200),source:Ce,job:Mn,requestedCapabilities:e.array(En).max(1e3),placementObjective:e.enum(["fast","balanced","economical"]),gpuSelection:A.optional(),physicalPlacement:X.optional(),budget:e.object({maximumSpendUsd:e.number().nonnegative(),maximumWallSeconds:e.number().int().positive()}).strict(),approval:On,contentHash:f}).strict().superRefine((t,n)=>{let i=(t.gpuSelection?.gpuCount??1)===2,a=t.requestedCapabilities.some(r=>r.id==="managed_rl.policy.data_parallel"&&r.version==="1"&&r.required);if(i!==a&&n.addIssue({code:"custom",path:["requestedCapabilities"],message:"Two-GPU training must require managed_rl.policy.data_parallel@1 and bind gpuSelection.gpuCount to 2."}),i&&(t.job.kind!=="policy_optimize"||t.job.executionMode||t.job.recipe.method!=="grpo"||t.physicalPlacement)&&n.addIssue({code:"custom",path:["gpuSelection"],message:"Two-GPU execution requires exclusive GRPO policy training."}),t.physicalPlacement&&(t.job.kind!=="policy_optimize"||t.job.resumeFrom||t.job.executionMode||t.job.recipe.continuation!==void 0)&&n.addIssue({code:"custom",path:["physicalPlacement"],message:"Reuse-only placement requires fresh-base policy training without continuation."}),t.job.kind==="policy_optimize"&&t.job.executionMode==="qualification"){let r=t.job;tn.safeParse(r.baseModel).success||n.addIssue({code:"custom",path:["job","baseModel"],message:"Qualification requires immutable model and tokenizer revisions and a SHA-256 chat-template pin."}),(r.resumeFrom||r.recipe.continuation!==void 0||r.rewardSource.kind!=="deterministic"||r.recipe.method!=="grpo")&&n.addIssue({code:"custom",path:["job"],message:"Qualification requires the original GRPO learner, deterministic reward, and no resume or continuation."}),t.requestedCapabilities.some(o=>o.required&&o.id==="managed_rl.policy.qualification"&&o.version==="1")||n.addIssue({code:"custom",path:["requestedCapabilities"],message:"Qualification must require managed_rl.policy.qualification@1."})}t.approval.maximumSpendUsd!==t.budget.maximumSpendUsd&&n.addIssue({code:"custom",path:["approval","maximumSpendUsd"],message:"Approved spend must equal the immutable Job budget."})});async function Un(t){let{contentHash:n,...i}=t;return u(i)}s(Un,"trainingJobSubmissionHash");async function me(t){k(t,1048576,"Training Job submission");let n=ze.parse(t),i=await Un(n);if(n.contentHash!==i)throw new d("content_hash_mismatch",`Training Job contentHash ${n.contentHash} does not match ${i}.`);return n}s(me,"parseAndVerifyTrainingJobSubmission");var Gn=e.object({resourceApproval:W.optional(),mode:e.literal("evaluation_only").optional(),trainingWorkloadComplete:e.boolean().optional(),sourceJobId:l,checkpointId:l,policyVersion:e.number().int().positive(),completedGroups:e.number().int().positive(),optimizerMode:e.literal("continue")}).strict(),F=e.object({schemaVersion:e.literal("openpond.trainingJob.v2"),id:l,teamId:l,kind:en,executionMode:e.literal("qualification").optional(),recovery:Gn.optional(),modelProjectId:l,portableProjectId:l,sourceProjectRevision:e.number().int().positive(),submissionHash:f,state:Hn,queue:Me.optional(),phase:e.string().trim().min(1).max(200),version:e.number().int().nonnegative(),progress:e.number().min(0).max(1),rolloutProgress:e.object({groupsCompleted:e.number().int().nonnegative(),groupsTarget:e.number().int().nonnegative(),optimizerUpdatesApplied:e.number().int().nonnegative(),optimizerUpdatesSkipped:e.number().int().nonnegative()}).strict(),accruedSpendUsd:e.number().nonnegative(),terminalReason:e.string().trim().min(1).max(5e3).nullable(),createdAt:j,updatedAt:j,completedAt:j.nullable()}).strict(),Dn=e.object({schemaVersion:e.literal("openpond.trainingJobPage.v2"),jobs:e.array(F).max(1e3),nextCursor:e.string().trim().min(1).max(2e3).nullable()}).strict(),Jn=e.object({schemaVersion:e.literal("openpond.trainingJobEvent.v2"),id:l,jobId:l,sequence:e.number().int().nonnegative(),type:l,phase:e.string().trim().min(1).max(200),message:e.string().trim().min(1).max(5e3).nullable(),data:e.record(e.string(),e.unknown()).default({}),createdAt:j}).strict(),$n=e.object({schemaVersion:e.literal("openpond.trainingJobLog.v2"),jobId:l,sequence:e.number().int().nonnegative(),level:e.enum(["debug","info","warning","error"]),message:e.string().max(2e4),createdAt:j}).strict(),Zt=e.object({expectedVersion:e.number().int().nonnegative()}).strict(),Vn=e.object({schemaVersion:e.literal("openpond.trainingJobOutput.v2"),id:l,jobId:l,kind:e.enum(["checkpoint","adapter","scorer","metrics","evaluation","trace","receipt"]),artifactRef:e.string().trim().min(1).max(2e3),contentHash:f,sizeBytes:e.number().int().nonnegative(),metadata:e.record(e.string(),e.unknown()).default({}),createdAt:j}).strict(),nn=e.object({schemaVersion:e.literal("openpond.trainingQualificationEvidence.v1"),baseModel:tn,group:p,rolloutReceipts:e.array(p).min(1).max(1e3),rewardEvidenceHash:f,groupsCompleted:e.literal(1),optimizerUpdatesApplied:e.literal(0),optimizerUpdatesSkipped:e.literal(0),trainingStepsCreated:e.literal(0),checkpointsCreated:e.literal(0),artifactsCreated:e.literal(0)}).strict().superRefine((t,n)=>{new Set(t.rolloutReceipts.map(i=>i.id)).size!==t.rolloutReceipts.length&&n.addIssue({code:"custom",path:["rolloutReceipts"],message:"Qualification rollout receipt identities must be unique."})}),De=e.object({schemaVersion:e.literal("openpond.trainingExecutionReceipt.v2"),id:l,teamId:l,jobId:l,submissionHash:f,manifestHash:f,recipeHash:f,capabilityHash:f,runtimeRelease:p,inputs:e.array(p).max(1e4),outputs:e.array(p).max(1e4),spendUsd:e.number().nonnegative(),durationSeconds:e.number().nonnegative(),cleanupComplete:e.boolean(),qualification:nn.optional(),issuer:l,issuedAt:j,signature:e.string().trim().min(1).max(1e4).nullable()}).strict();async function Nn(t){return u(De.parse(t))}s(Nn,"trainingExecutionReceiptHash");async function po(t,n){let i=De.parse(t),a=l.parse(n.id),r=f.parse(n.contentHash),o=await Nn(i);if(i.id!==a||o!==r)throw new d("execution_receipt_mismatch","The execution receipt identity or canonical content hash did not match.");if(n.teamId!==void 0&&i.teamId!==l.parse(n.teamId))throw new d("execution_receipt_team_mismatch","The execution receipt belongs to a different team.");if(n.jobId!==void 0&&i.jobId!==l.parse(n.jobId))throw new d("execution_receipt_job_mismatch","The execution receipt belongs to a different Training Job.");if((n.requireCleanup??!0)&&!i.cleanupComplete)throw new d("execution_cleanup_incomplete","The execution receipt does not attest complete terminal cleanup.");if(n.qualificationSubmission){let m=await me(n.qualificationSubmission);if(m.job.kind!=="policy_optimize"||m.job.executionMode!=="qualification")throw new d("qualification_submission_required","Expected an immutable qualification submission.");await Bn(i,{submissionHash:m.contentHash,baseModel:m.job.baseModel,outputs:n.outputs})}return i}s(po,"parseAndVerifyTrainingExecutionReceipt");async function Bn(t,n){let i=nn.parse(t.qualification);if(t.submissionHash!==n.submissionHash||!t.cleanupComplete)throw new d("qualification_receipt_mismatch","Qualification must attest the expected submission and complete cleanup.");if(n.baseModel&&await u(i.baseModel)!==await u(n.baseModel))throw new d("qualification_learner_mismatch","Qualification used a different original learner or tokenizer.");if(n.outputs?.some(a=>["checkpoint","adapter","scorer"].includes(a.kind)))throw new d("qualification_updated_artifact","Qualification must not publish trained artifacts or checkpoints.")}s(Bn,"assertTrainingQualificationReceipt");var Ln=e.object({schemaVersion:e.literal("openpond.trainingJobOutputs.v2"),outputs:e.array(Vn).max(1e4),receipt:De.nullable()}).strict(),Qn=e.object({workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/),envelopeRank:e.number().int().positive().max(256),supportedRanks:e.array(e.number().int().positive().max(256)).max(256),qualification:e.object({evidenceRef:e.string().min(1),evidenceSha256:f}).strict().nullable(),continuation:e.object({sharedRequiresSameRank:e.literal(!0),mergedRequiresSameRank:e.literal(!0),residualAppendRequiresFreeCapacity:e.literal(!0),stageOptimizer:e.literal("reset"),interruptedRecoveryOptimizer:e.literal("restore")}).strict()}).strict().superRefine((t,n)=>{(new Set(t.supportedRanks).size!==t.supportedRanks.length||t.supportedRanks.some(i=>i>t.envelopeRank))&&n.addIssue({code:"custom",path:["supportedRanks"],message:"Supported ranks must be unique and fit the physical adapter envelope."}),t.supportedRanks.length&&!t.qualification&&n.addIssue({code:"custom",path:["qualification"],message:"Advertised ranks require immutable image qualification evidence."})});function uo(t,n,i){return t.supportedRanks.includes(n)?i?i.mode==="residual_append"?i.parentEnabledRank+n<=t.envelopeRank:i.parentEnabledRank===n:!0:!1}s(uo,"supportsTrainingPolicyLoraRank");var Fn=e.object({schemaVersion:e.literal("openpond.trainingCapabilities.v2"),capabilityHash:f,jobKinds:e.array(en),methods:e.array(e.string().trim().min(1).max(200)),executionModes:e.array(e.enum(["training","qualification"])).optional(),policyLora:Qn.optional(),policyDataParallel:e.object({capability:e.literal("managed_rl.policy.data_parallel"),version:e.literal("1"),gpuCount:e.literal(2),worldSize:e.literal(2),backend:e.literal("nccl"),allocationMode:e.literal("exclusive"),workerImageDigest:e.string().regex(/^sha256:[a-f0-9]{64}$/)}).strict().optional(),structuredOutputs:e.object({capability:e.literal("work.structured-output.v1"),harnessRuntimeHash:f,workHarnessHash:f,schemaHash:f,artifactHash:f,invalidDataRejected:e.literal(!0),invalidBytesRejected:e.literal(!0)}).strict().optional(),placements:e.array(e.enum(["local","remote","colocated","provider_native"])),controls:e.object({cancel:e.boolean(),stopAfterGroup:e.boolean(),resumeFromCheckpoint:e.boolean()}).strict(),estimates:e.object({schemaVersion:e.literal("openpond.trainingEstimate.v1")}).strict().optional(),limits:e.object({maximumSpendUsd:e.number().nonnegative(),maximumWallSeconds:e.number().int().positive(),maximumArtifactBytes:e.number().int().positive()}).strict(),checkedAt:j,expiresAt:j}).strict();function lo(t){let n=dt(t);return{postTraining:jt({request:n}),...Mt(n),...$t(n),...bt(n),...ut(n),...Bt(n),...Ft(n),async capabilities(){return Fn.parse(E(await n("/v1/training/capabilities"),"capabilities"))},async gpuCatalog(){return be.parse(E(await n("/v1/training/gpu-catalog"),"catalog"))},async stageArtifact(i){let a=await jn(i);return kn.parse(E(await n("/v1/training/artifacts",{method:"POST",body:JSON.stringify(a)}),"artifact"))},async createJob(i){let a=await me(i);return F.parse(E(await n("/v1/training/jobs",{method:"POST",body:JSON.stringify(a)}),"job"))},async listJobs(i={}){let a=new URLSearchParams;i.modelProjectId&&a.set("modelProjectId",l.parse(i.modelProjectId)),i.cursor&&a.set("cursor",e.string().trim().min(1).max(2e3).parse(i.cursor)),i.limit!==void 0&&a.set("limit",String(e.number().int().min(1).max(1e3).parse(i.limit)));let r=a.size>0?`?${a.toString()}`:"";return Dn.parse(await n(`/v1/training/jobs${r}`))},async getJob(i){return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}`),"job"))},async cancelJob(i,a){let r=Zt.parse({expectedVersion:a});return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/cancel`,{method:"POST",body:JSON.stringify(r)}),"job"))},async stopAfterGroup(i,a){let r=Zt.parse({expectedVersion:a});return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/stop-after-group`,{method:"POST",body:JSON.stringify(r)}),"job"))},async recoverCheckpoint(i,a){let r=je.parse(a);if(r.resourceApproval){let{approvalHash:o,...m}=r.resourceApproval;if(m.sourceJobId!==i||await u(m)!==o)throw new d("content_hash_mismatch","Recovery resource approval does not bind this source request.")}return F.parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/recover`,{method:"POST",body:JSON.stringify(r)}),"job"))},async events(i){return e.array(Jn).parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/events`),"events"))},async outputs(i){return Ln.parse(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/outputs`))},async evaluationTasks(i,a,r={}){let o=l.parse(i),m=p.parse(a),c=new URLSearchParams,x=r.cursor===void 0?void 0:e.string().regex(/^[1-9]\d*$/).parse(r.cursor),R=x===void 0?0:e.number().int().min(1).max(9999).parse(Number(x));x!==void 0&&c.set("cursor",x),r.limit!==void 0&&c.set("limit",String(e.number().int().min(1).max(100).parse(r.limit)));let v=c.size?`?${c.toString()}`:"";return Ue(await n(`/v1/training/jobs/${encodeURIComponent(o)}/evaluations/${encodeURIComponent(m.id)}/tasks${v}`),{jobId:o,evaluation:m,offset:R})},async logs(i){return e.array($n).max(1e5).parse(E(await n(`/v1/training/jobs/${encodeURIComponent(l.parse(i))}/logs`),"logs"))}}}s(lo,"createTrainingClient");function E(t,n){return!t||typeof t!="object"||Array.isArray(t)?t:n in t?t[n]:t}s(E,"unwrapObject");export{z as a,rn as b,ye as c,gt as d,ht as e,ft as f,D as g,vt as h,cn as i,Yi as j,Re as k,Pe as l,ga as m,ha as n,fa as o,ba as p,_e as q,W as r,xn as s,je as t,X as u,Ee as v,Et as w,At as x,Ae as y,He as z,Ct as A,qt as B,zt as C,Ot as D,Ut as E,Gt as F,Dt as G,Jt as H,Me as I,Nt as J,de as K,Lt as L,Qt as M,Oe as N,Kt as O,Wt as P,Xt as Q,Ue as R,vn as S,In as T,Yt as U,Rn as V,wn as W,Pn as X,kn as Y,_n as Z,jn as _,en as $,Hn as aa,En as ba,Ce as ca,An as da,tn as ea,zn as fa,Mn as ga,On as ha,ze as ia,Un as ja,me as ka,Gn as la,F as ma,Dn as na,Jn as oa,$n as pa,Zt as qa,Vn as ra,nn as sa,De as ta,Nn as ua,po as va,Bn as wa,Ln as xa,Qn as ya,uo as za,Fn as Aa,lo as Ba};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{e as H,j as R}from"./chunk-ZU3YBRXS.js";import{v as I,z as C}from"./chunk-4TTXNVCE.js";import{m as k,n as b}from"./chunk-RCT3O3HQ.js";import{a as h}from"./chunk-FTQLQJQV.js";import{promises as s}from"node:fs";import n from"node:path";import{execFile as O}from"node:child_process";import{promisify as A}from"node:util";var T=A(O);async function v(e,i,a={}){return(await T("git",["-C",e,...i],{encoding:"utf8",timeout:3e4,maxBuffer:8388608,env:{...process.env,...a}})).stdout.trim()}h(v,"candidateGit");async function j(e,i=I,a=!1){if(e.profileRef.source!=="local"&&!a)throw new Error("This Git adapter requires the actual installed local Profile owner; hosted adoption needs its published-source owner.");let r=await i(e.profileRef);if(r.error||r.mode!=="local"||r.activeProfile!==e.profileRef.profileId||!r.repoPath||!r.sourcePath)throw new Error("The original Profile owner is unavailable.");let l=await s.realpath(r.repoPath),p=await s.realpath(r.sourcePath),f=n.relative(l,p);if(f.startsWith("..")||n.isAbsolute(f))throw new Error("Profile source escapes its actual Git owner.");return{profile:r,repo:l,source:p,sourceRelative:f}}h(j,"originalCandidateProfile");async function ce(e,i,a=!0){if(!/^[a-f0-9]{40}$/.test(i)||await v(e,["rev-parse","HEAD"])!==i)throw new Error("The original Profile Git revision changed.");if(a&&await v(e,["status","--porcelain","--untracked-files=all"]))throw new Error("Commit or reconcile changes in the original Profile before this operation.")}h(ce,"assertCandidateGitHead");async function me(e,i){let a=await j(e.state,e.loadProfile,e.allowRemoteSnapshot),r=n.join(e.storeDir,"library","harnesses","profile-candidate-staging");await s.mkdir(r,{recursive:!0,mode:448});let l=await s.mkdtemp(n.join(r,"source-"));await s.rmdir(l),await v(a.repo,["worktree","add","--detach",l,e.commit]);try{let p=await C({repoPath:l,profileId:e.state.profileRef.profileId});if(p.error||!p.sourcePath)throw new Error("The staged original Profile cannot be loaded.");return await i({root:l,profile:p,repo:a.repo,source:p.sourcePath})}finally{await v(a.repo,["worktree","remove","--force",l]).catch(()=>{}),await s.rm(l,{recursive:!0,force:!0})}}h(me,"withCandidateProfileWorktree");function y(e){if(!e||n.isAbsolute(e)||e.includes("\\")||e.split("/").some(i=>!i||i==="."||i===".."))throw new Error("Original Profile patch path is not contained.");return e}h(y,"portable");async function pe(e){let i=e.base.manifest.metadata.profileSourceBindings;if(!Array.isArray(i))throw new Error("The original release needs compiler source bindings before candidate adoption.");let a=e.state.component.path,r=e.state.component,l=new Map(i.map(t=>{if(!t||typeof t!="object"||typeof t.releasedPath!="string"||typeof t.profileRelativePath!="string")throw new Error("Original Profile source binding is invalid.");return[y(t.releasedPath),y(t.profileRelativePath)]})),p=r.kind==="instruction"&&a==="instructions/system.md"&&e.base.manifest.metadata.profileInstructionSourcePath==="instructions/system.md"&&!l.has(a),f=l.get(a)??(p?"instructions/system.md":void 0),S=r.kind==="workflow"?`workflows/${r.workflowId}/`:r.kind==="agent"?a.split("/").slice(0,2).join("/")+"/":n.posix.dirname(a)+"/",w=f?n.posix.dirname(f)+"/":null;if(r.kind==="workflow"&&!f&&(w=S),r.kind==="agent"){let t=e.profile.agents.find(o=>a.startsWith(`agents/${o.id}/`));if(!t)throw new Error("The selected Agent original source is unavailable.");let c=y(t.path);w=((await s.lstat(n.join(e.source,c))).isDirectory()?c:n.posix.dirname(c))+"/"}let E=new Map(e.base.sourceFiles.map(t=>[t.path,t])),x=new Map(e.candidate.sourceFiles.map(t=>[t.path,t])),g=new Map;for(let t of new Set([...E.keys(),...x.keys()])){let c=E.get(t),m=x.get(t);if(c?.asset.contentHash===m?.asset.contentHash)continue;if(c&&c.asset.visibility!=="policy"||m&&m.asset.visibility!=="policy")throw new Error("A candidate cannot change protected Profile source.");let o=l.get(t)??(p&&t===a?f:void 0);if(!o&&t.startsWith(S)&&w&&(o=w+t.slice(S.length)),!o&&t==="workflows/catalog.json"&&[...l.keys()].some(P=>/^workflows\/[^/]+\/(PROMPT\.md|ACTION\.json)$/.test(P))||!o&&t==="dependency-lock/profile-import.json")continue;if(!o)throw new Error(`The selected component has no original Profile source mapping: ${t}`);if(o=y(o),o!==f&&!(r.kind!=="instruction"&&w&&o.startsWith(w)))throw new Error("Candidate patch changes a different original Profile component.");if(H(o))throw new Error("Candidate patch crosses the protected Profile evaluation closure.");let u=g.get(o),d=m?.bytes??null;if(u&&(u.before!==(c?.asset.contentHash??null)||b(u.bytes===null?null:Array.from(u.bytes))!==b(d===null?null:Array.from(d))))throw new Error("Public component aliases disagree on the original source edit.");g.set(o,{before:p&&t===a?null:c?.asset.contentHash??null,bytes:d})}for(let[t,c]of g){let m=n.join(e.source,...t.split("/")),o=n.dirname(m);for(;!await s.stat(o).catch(()=>null);)o=n.dirname(o);let u=n.relative(await s.realpath(e.source),await s.realpath(o));if(u.startsWith("..")||n.isAbsolute(u))throw new Error("Candidate patch escapes the staged Profile source.");let d=await s.lstat(m).catch(()=>null);if(d?.isSymbolicLink()||d&&!d.isFile())throw new Error("Original source patch needs a regular file.");let P=d?await s.readFile(m):null;if((P?k(P):null)!==c.before)throw new Error("Original source bytes differ from the exact candidate baseline.");c.bytes===null?await s.rm(m):(await s.mkdir(n.dirname(m),{recursive:!0}),await s.writeFile(m,c.bytes,{mode:d?.mode??384}))}return[...g.keys()]}h(pe,"applyCandidateProfileSource");function fe(e){let i=e.base.manifest.metadata.profileRepositoryId;return R({storeDir:e.storeDir,workspaceId:e.state.ownerWorkspaceId,name:e.base.manifest.name,profile:e.profile,sourceRevision:e.sourceRevision,...typeof i=="string"?{repositoryId:i}:{}})}h(fe,"compileOriginalCandidateProfile");export{v as a,j as b,ce as c,me as d,pe as e,fe as f};
2
+ import{e as H,j as R}from"./chunk-CSU7RDA5.js";import{v as I,z as C}from"./chunk-4TTXNVCE.js";import{m as k,n as b}from"./chunk-RCT3O3HQ.js";import{a as h}from"./chunk-FTQLQJQV.js";import{promises as s}from"node:fs";import n from"node:path";import{execFile as O}from"node:child_process";import{promisify as A}from"node:util";var T=A(O);async function v(e,i,a={}){return(await T("git",["-C",e,...i],{encoding:"utf8",timeout:3e4,maxBuffer:8388608,env:{...process.env,...a}})).stdout.trim()}h(v,"candidateGit");async function j(e,i=I,a=!1){if(e.profileRef.source!=="local"&&!a)throw new Error("This Git adapter requires the actual installed local Profile owner; hosted adoption needs its published-source owner.");let r=await i(e.profileRef);if(r.error||r.mode!=="local"||r.activeProfile!==e.profileRef.profileId||!r.repoPath||!r.sourcePath)throw new Error("The original Profile owner is unavailable.");let l=await s.realpath(r.repoPath),p=await s.realpath(r.sourcePath),f=n.relative(l,p);if(f.startsWith("..")||n.isAbsolute(f))throw new Error("Profile source escapes its actual Git owner.");return{profile:r,repo:l,source:p,sourceRelative:f}}h(j,"originalCandidateProfile");async function ce(e,i,a=!0){if(!/^[a-f0-9]{40}$/.test(i)||await v(e,["rev-parse","HEAD"])!==i)throw new Error("The original Profile Git revision changed.");if(a&&await v(e,["status","--porcelain","--untracked-files=all"]))throw new Error("Commit or reconcile changes in the original Profile before this operation.")}h(ce,"assertCandidateGitHead");async function me(e,i){let a=await j(e.state,e.loadProfile,e.allowRemoteSnapshot),r=n.join(e.storeDir,"library","harnesses","profile-candidate-staging");await s.mkdir(r,{recursive:!0,mode:448});let l=await s.mkdtemp(n.join(r,"source-"));await s.rmdir(l),await v(a.repo,["worktree","add","--detach",l,e.commit]);try{let p=await C({repoPath:l,profileId:e.state.profileRef.profileId});if(p.error||!p.sourcePath)throw new Error("The staged original Profile cannot be loaded.");return await i({root:l,profile:p,repo:a.repo,source:p.sourcePath})}finally{await v(a.repo,["worktree","remove","--force",l]).catch(()=>{}),await s.rm(l,{recursive:!0,force:!0})}}h(me,"withCandidateProfileWorktree");function y(e){if(!e||n.isAbsolute(e)||e.includes("\\")||e.split("/").some(i=>!i||i==="."||i===".."))throw new Error("Original Profile patch path is not contained.");return e}h(y,"portable");async function pe(e){let i=e.base.manifest.metadata.profileSourceBindings;if(!Array.isArray(i))throw new Error("The original release needs compiler source bindings before candidate adoption.");let a=e.state.component.path,r=e.state.component,l=new Map(i.map(t=>{if(!t||typeof t!="object"||typeof t.releasedPath!="string"||typeof t.profileRelativePath!="string")throw new Error("Original Profile source binding is invalid.");return[y(t.releasedPath),y(t.profileRelativePath)]})),p=r.kind==="instruction"&&a==="instructions/system.md"&&e.base.manifest.metadata.profileInstructionSourcePath==="instructions/system.md"&&!l.has(a),f=l.get(a)??(p?"instructions/system.md":void 0),S=r.kind==="workflow"?`workflows/${r.workflowId}/`:r.kind==="agent"?a.split("/").slice(0,2).join("/")+"/":n.posix.dirname(a)+"/",w=f?n.posix.dirname(f)+"/":null;if(r.kind==="workflow"&&!f&&(w=S),r.kind==="agent"){let t=e.profile.agents.find(o=>a.startsWith(`agents/${o.id}/`));if(!t)throw new Error("The selected Agent original source is unavailable.");let c=y(t.path);w=((await s.lstat(n.join(e.source,c))).isDirectory()?c:n.posix.dirname(c))+"/"}let E=new Map(e.base.sourceFiles.map(t=>[t.path,t])),x=new Map(e.candidate.sourceFiles.map(t=>[t.path,t])),g=new Map;for(let t of new Set([...E.keys(),...x.keys()])){let c=E.get(t),m=x.get(t);if(c?.asset.contentHash===m?.asset.contentHash)continue;if(c&&c.asset.visibility!=="policy"||m&&m.asset.visibility!=="policy")throw new Error("A candidate cannot change protected Profile source.");let o=l.get(t)??(p&&t===a?f:void 0);if(!o&&t.startsWith(S)&&w&&(o=w+t.slice(S.length)),!o&&t==="workflows/catalog.json"&&[...l.keys()].some(P=>/^workflows\/[^/]+\/(PROMPT\.md|ACTION\.json)$/.test(P))||!o&&t==="dependency-lock/profile-import.json")continue;if(!o)throw new Error(`The selected component has no original Profile source mapping: ${t}`);if(o=y(o),o!==f&&!(r.kind!=="instruction"&&w&&o.startsWith(w)))throw new Error("Candidate patch changes a different original Profile component.");if(H(o))throw new Error("Candidate patch crosses the protected Profile evaluation closure.");let u=g.get(o),d=m?.bytes??null;if(u&&(u.before!==(c?.asset.contentHash??null)||b(u.bytes===null?null:Array.from(u.bytes))!==b(d===null?null:Array.from(d))))throw new Error("Public component aliases disagree on the original source edit.");g.set(o,{before:p&&t===a?null:c?.asset.contentHash??null,bytes:d})}for(let[t,c]of g){let m=n.join(e.source,...t.split("/")),o=n.dirname(m);for(;!await s.stat(o).catch(()=>null);)o=n.dirname(o);let u=n.relative(await s.realpath(e.source),await s.realpath(o));if(u.startsWith("..")||n.isAbsolute(u))throw new Error("Candidate patch escapes the staged Profile source.");let d=await s.lstat(m).catch(()=>null);if(d?.isSymbolicLink()||d&&!d.isFile())throw new Error("Original source patch needs a regular file.");let P=d?await s.readFile(m):null;if((P?k(P):null)!==c.before)throw new Error("Original source bytes differ from the exact candidate baseline.");c.bytes===null?await s.rm(m):(await s.mkdir(n.dirname(m),{recursive:!0}),await s.writeFile(m,c.bytes,{mode:d?.mode??384}))}return[...g.keys()]}h(pe,"applyCandidateProfileSource");function fe(e){let i=e.base.manifest.metadata.profileRepositoryId;return R({storeDir:e.storeDir,workspaceId:e.state.ownerWorkspaceId,name:e.base.manifest.name,profile:e.profile,sourceRevision:e.sourceRevision,...typeof i=="string"?{repositoryId:i}:{}})}h(fe,"compileOriginalCandidateProfile");export{v as a,j as b,ce as c,me as d,pe as e,fe as f};