openpond 0.2.56 → 0.2.58

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 (73) hide show
  1. package/dist/app-server.d.ts +1 -0
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/{app-server-evaluations-GJPFWIDA.js → app-server-evaluations-K52NAQLP.js} +1 -1
  4. package/dist/chunks/{app-server-harness-services-IH4G6POY.js → app-server-harness-services-QMUOEYOA.js} +1 -1
  5. package/dist/chunks/{app-server-runtime-DVKOZ5B6.js → app-server-runtime-ISGGLQHU.js} +1 -1
  6. package/dist/chunks/{chunk-XTFPDQMH.js → chunk-4EQA2M7K.js} +1 -1
  7. package/dist/chunks/chunk-5IPFI25K.js +2 -0
  8. package/dist/chunks/{chunk-3K4VVB7S.js → chunk-65PL62KH.js} +1 -1
  9. package/dist/chunks/{chunk-OGDADQGH.js → chunk-6UDGARFC.js} +1 -1
  10. package/dist/chunks/{chunk-2QUCCP6Z.js → chunk-7SC46OFC.js} +1 -1
  11. package/dist/chunks/{chunk-L6K7ERG5.js → chunk-APB4O67E.js} +1 -1
  12. package/dist/chunks/{chunk-S5ESN275.js → chunk-H4QHIHMK.js} +1 -1
  13. package/dist/chunks/{chunk-PPAPVGJP.js → chunk-HDGTHRY7.js} +1 -1
  14. package/dist/chunks/{chunk-XXYGGNVM.js → chunk-HPBQ4VTW.js} +1 -1
  15. package/dist/chunks/{chunk-FY5KHLMW.js → chunk-I3HZKJB3.js} +1 -1
  16. package/dist/chunks/{chunk-QHWGQ3A4.js → chunk-I3VVWNUW.js} +1 -1
  17. package/dist/chunks/{chunk-KUERKVEU.js → chunk-IIZ4CWBX.js} +1 -1
  18. package/dist/chunks/{chunk-SH5CBAFC.js → chunk-JAJ46T5X.js} +1 -1
  19. package/dist/chunks/{chunk-QEFHOJFE.js → chunk-JE7RJZOA.js} +1 -1
  20. package/dist/chunks/{chunk-GWCHDF2C.js → chunk-JUHZ5S3R.js} +1 -1
  21. package/dist/chunks/{chunk-PUZQU66L.js → chunk-L3KCP52O.js} +1 -1
  22. package/dist/chunks/{chunk-EQFGBL3O.js → chunk-NC27T4AB.js} +1 -1
  23. package/dist/chunks/{chunk-7HPDGZOR.js → chunk-NH6UUX5S.js} +1 -1
  24. package/dist/chunks/{chunk-QOTVNQDI.js → chunk-QL4OIPEZ.js} +1 -1
  25. package/dist/chunks/{chunk-ZFSHBFG5.js → chunk-RNQF63ZR.js} +1 -1
  26. package/dist/chunks/chunk-ROGF26KV.js +2 -0
  27. package/dist/chunks/{chunk-HDL5YSAA.js → chunk-RWWE5OXU.js} +1 -1
  28. package/dist/chunks/{chunk-YOBN7KTF.js → chunk-TJ6GVTYB.js} +1 -1
  29. package/dist/chunks/{chunk-3RCRSMWZ.js → chunk-TTVS6JMC.js} +1 -1
  30. package/dist/chunks/{chunk-WMKYHXVM.js → chunk-VVCKLCF3.js} +1 -1
  31. package/dist/chunks/{chunk-OIUTWU6K.js → chunk-X2HIHF2I.js} +1 -1
  32. package/dist/chunks/{chunk-J2TWKFML.js → chunk-XX6SMFDY.js} +4 -4
  33. package/dist/chunks/{chunk-GZ7M5XBP.js → chunk-YNH3NMPF.js} +1 -1
  34. package/dist/chunks/{chunk-YCJO3YVD.js → chunk-ZTNHW2K7.js} +3 -3
  35. package/dist/chunks/{cli-X25RSO2X.js → cli-XZENDZ7Z.js} +1 -1
  36. package/dist/chunks/{connected-app-executor-IVLGQP65.js → connected-app-executor-LQNIU5NR.js} +1 -1
  37. package/dist/chunks/host-profile-evaluation-tools-JOFBL5OF.js +2 -0
  38. package/dist/chunks/{hosted-app-server-composition-BCOO5ANF.js → hosted-app-server-composition-T5IWGOTA.js} +1 -1
  39. package/dist/chunks/{hosted-experiment-improvement-NFSVS5TU.js → hosted-experiment-improvement-HVMDGS75.js} +1 -1
  40. package/dist/chunks/{hosted-harness-runtime-723S5ZSH.js → hosted-harness-runtime-YCKB6NBI.js} +1 -1
  41. package/dist/chunks/{hosted-profile-candidate-2S5LFUWD.js → hosted-profile-candidate-EXNN6MVN.js} +1 -1
  42. package/dist/chunks/{hosted-profile-compiler-2DQIFSXW.js → hosted-profile-compiler-IYLLHCRY.js} +1 -1
  43. package/dist/chunks/{hosted-profile-evaluation-control-76BTRTYD.js → hosted-profile-evaluation-control-TJVER3NW.js} +1 -1
  44. package/dist/chunks/{hosted-profile-evaluation-inspection-V6Z3A5XJ.js → hosted-profile-evaluation-inspection-ZUANDYZ6.js} +1 -1
  45. package/dist/chunks/{hosted-profile-evaluation-preparation-IDJYREW3.js → hosted-profile-evaluation-preparation-ORVZ6MBD.js} +1 -1
  46. package/dist/chunks/{local-harness-improvement-runtime-JIQ6ZVDW.js → local-harness-improvement-runtime-QRFGPFRM.js} +1 -1
  47. package/dist/chunks/{local-harness-taskset-review-XVYTGAGK.js → local-harness-taskset-review-HR7KLY4B.js} +1 -1
  48. package/dist/chunks/{project-action-payload-7VGL7OER.js → project-action-payload-JDS6OQAW.js} +1 -1
  49. package/dist/chunks/{published-experiment-source-DZFENAQA.js → published-experiment-source-HVP5IGRH.js} +1 -1
  50. package/dist/chunks/{refiner-profile-service-UUIWFJVT.js → refiner-profile-service-FDTQKY33.js} +1 -1
  51. package/dist/chunks/{saved-work-6BMBFP43.js → saved-work-SHEEDZ6Z.js} +1 -1
  52. package/dist/chunks/{src-LMC3K6LH.js → src-DZL5T2MT.js} +1 -1
  53. package/dist/chunks/{src-CJM6HY5Y.js → src-R36AGJY7.js} +103 -103
  54. package/dist/chunks/{store-continual-support-reviews-HHA6NX7K.js → store-continual-support-reviews-LJPNG4SP.js} +1 -1
  55. package/dist/chunks/{store-create-improve-QV54XIZW.js → store-create-improve-SW5FTBTL.js} +1 -1
  56. package/dist/chunks/{store-datasets-RXJ33SUN.js → store-datasets-WMA7AJKN.js} +1 -1
  57. package/dist/chunks/{store-evaluation-results-3F3P527G.js → store-evaluation-results-ZO6R653G.js} +1 -1
  58. package/dist/chunks/{store-human-review-RAH7WMIP.js → store-human-review-7QQ7ZQ6P.js} +1 -1
  59. package/dist/chunks/{store-learned-preference-migration-validation-4CI2IRUF.js → store-learned-preference-migration-validation-NADPXOTG.js} +1 -1
  60. package/dist/chunks/{store-local-experiments-5LUJR7GI.js → store-local-experiments-SAULQSBN.js} +1 -1
  61. package/dist/chunks/{store-model-batch-review-YEGX327M.js → store-model-batch-review-VKLDYGH3.js} +1 -1
  62. package/dist/chunks/{store-model-configuration-5ZURQATB.js → store-model-configuration-BYRJUR3C.js} +1 -1
  63. package/dist/chunks/{store-task-inbox-JJTBW76C.js → store-task-inbox-QPE44OSS.js} +11 -11
  64. package/dist/chunks/{store-task-inventory-OB3F2APC.js → store-task-inventory-I3RDRI52.js} +1 -1
  65. package/dist/chunks/{store-taskset-drafts-EKQWWFYQ.js → store-taskset-drafts-2IULRV2W.js} +1 -1
  66. package/dist/chunks/{store-training-G6YLFSIR.js → store-training-B2TW2MLA.js} +1 -1
  67. package/dist/chunks/{store-training-jobs-RC46YBF6.js → store-training-jobs-VBNG23RL.js} +1 -1
  68. package/dist/chunks/{store-training-models-6BA43IPP.js → store-training-models-OMV5FIC4.js} +1 -1
  69. package/dist/cli.js +1 -1
  70. package/package.json +1 -1
  71. package/dist/chunks/chunk-UHFZHBGW.js +0 -2
  72. package/dist/chunks/chunk-YY7LEQGP.js +0 -2
  73. package/dist/chunks/host-profile-evaluation-tools-JJQWJUBT.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{i as a,j as b,k as c}from"./chunk-S5ESN275.js";import"./chunk-SH5CBAFC.js";import"./chunk-DMVD2RFZ.js";import"./chunk-JYKRR7E5.js";import"./chunk-OSIO7PLX.js";import"./chunk-JDEEWOD7.js";import"./chunk-4NESNOK5.js";import"./chunk-UKMA4R6X.js";import"./chunk-KG325WTN.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import"./chunk-VRIEKBBH.js";import"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as resolveWebLaunchMessages,c as runOpenPondAppServerCli,b as runOpenPondServerCli};
2
+ import{i as a,j as b,k as c}from"./chunk-H4QHIHMK.js";import"./chunk-JAJ46T5X.js";import"./chunk-DMVD2RFZ.js";import"./chunk-JYKRR7E5.js";import"./chunk-OSIO7PLX.js";import"./chunk-JDEEWOD7.js";import"./chunk-4NESNOK5.js";import"./chunk-UKMA4R6X.js";import"./chunk-KG325WTN.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import"./chunk-VRIEKBBH.js";import"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as resolveWebLaunchMessages,c as runOpenPondAppServerCli,b as runOpenPondServerCli};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a,b,c}from"./chunk-PUZQU66L.js";import"./chunk-UKMA4R6X.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-FWIPHEVA.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as DEFAULT_CONNECTED_APP_TOOL_PATH,b as createCloudConnectedAppToolExecutor,c as resolveCloudConnectedAppToolTarget};
2
+ import{a,b,c}from"./chunk-L3KCP52O.js";import"./chunk-UKMA4R6X.js";import"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-FWIPHEVA.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as DEFAULT_CONNECTED_APP_TOOL_PATH,b as createCloudConnectedAppToolExecutor,c as resolveCloudConnectedAppToolTarget};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{b as a}from"./chunk-ROGF26KV.js";import"./chunk-PF5R6CMP.js";import"./chunk-FEAKTSRS.js";import"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-FTQLQJQV.js";export{a as createHostProfileEvaluationTools};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{c as wt,d as vt,e as yt}from"./chunk-QHWGQ3A4.js";import{b as gt,c as re,e as Rt}from"./chunk-SH5CBAFC.js";import{a as pt,b as ft}from"./chunk-UHFZHBGW.js";import"./chunk-PF5R6CMP.js";import{b as ht}from"./chunk-DMVD2RFZ.js";import{a as ee,b as O,c as te}from"./chunk-JYKRR7E5.js";import{a as St}from"./chunk-OIUTWU6K.js";import"./chunk-X4OSOOSU.js";import"./chunk-3K4VVB7S.js";import{b as De,c as Me,d as ze,f as Ne,h as $e}from"./chunk-3Z47M3YY.js";import{b as je}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-SDAUS5PY.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as Je,b as Ze}from"./chunk-OPNRWESL.js";import{b as Ke,c as Qe}from"./chunk-2QUCCP6Z.js";import{a as Y}from"./chunk-O6ULLQJ6.js";import"./chunk-FY5KHLMW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import{d as tt,e as st,ga as ct,ha as dt,ia as mt,j as ot,k as it,v as lt,w as X,y as ut}from"./chunk-OGDADQGH.js";import{a as rt}from"./chunk-4NESNOK5.js";import"./chunk-BLXEAZCQ.js";import"./chunk-UCPGRPWY.js";import{b as et}from"./chunk-HDL5YSAA.js";import"./chunk-ZFSHBFG5.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import{a as at,b as nt}from"./chunk-GW766ZSO.js";import{p as Ye}from"./chunk-UKMA4R6X.js";import"./chunk-OQKJGTTO.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-A6USMRWK.js";import"./chunk-PCSIOUHF.js";import"./chunk-7KWD2I6W.js";import"./chunk-GPVCOEUH.js";import"./chunk-N73MU2C3.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import{b as Xe}from"./chunk-KG325WTN.js";import"./chunk-3RCRSMWZ.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{F as qe,I as h,K as z,L as Be}from"./chunk-VRIEKBBH.js";import{g as Oe,m as _e}from"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import{a as ge,j as We,k as Ve,t as Ge}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{a as Fe,o as F,p as Ue,q as U,v as Le,y as Z}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as he}from"./chunk-RNIAFXMB.js";import{a as fe}from"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import{b as Te}from"./chunk-N4FFQPLR.js";import{a as Ie,c as ke}from"./chunk-AY64VY4E.js";import{a as ce,h as be}from"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import{c as xe}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import{V as pe,X as Ce}from"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{Hb as Q,Ob as J,f as me,m as Ae}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{w as de}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{l as q,m as g,n as M}from"./chunk-KGNCKIFP.js";import{b as n}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";import{randomUUID as Vt}from"node:crypto";import{promises as _}from"node:fs";import I from"node:path";function Pt(l){let e=new Map,t=new Map;async function o(s,d){let m=(t.get(s)??Promise.resolve()).catch(()=>{}).then(d);t.set(s,m);try{return await m}finally{t.get(s)===m&&t.delete(s)}}r(o,"serial");let a=r((s,d=18e4)=>l.request(z.parse({contractVersion:h,requestId:Vt(),operation:"profile-evaluations/sandbox",params:s}),d),"request");async function c(s,d,m,f){let y=q(f),v=`${d}/${m}/${y}`,b=e.get(s.sessionId)??new Set;if(!b.has(v)){if(f.length>1e7)throw new Error("The public case file exceeds its admitted bound.");for(let R=0;R===0||R<f.length;R+=98304)s.signal.throwIfAborted(),await a({sessionId:s.sessionId,turnId:s.turnId,action:"upload",area:d,path:m,sha256:y,sizeBytes:f.length,offset:R,contentsBase64:f.subarray(R,R+98304).toString("base64")},3e5);b.add(v),e.set(s.sessionId,b)}}r(c,"upload");async function u(s,d=""){let m=[];for(let f of await _.readdir(I.join(s,d),{withFileTypes:!0})){let y=I.posix.join(d,f.name);if(f.isSymbolicLink()){let v=await _.realpath(I.join(s,y));if(!v.startsWith(`${await _.realpath(s)}${I.sep}`)||(await _.stat(v)).isDirectory())throw new Error("The public Agent runtime symlink escapes its file closure.");m.push(y);continue}if(f.isDirectory()?m.push(...await u(s,y)):f.isFile()&&m.push(y),m.length>8192)throw new Error("The public Agent runtime exceeds the file limit.")}return m}return r(u,"runtimeFiles"),{execute:r(s=>o(s.sessionId,async()=>{s.signal.throwIfAborted();for(let[f,y]of Object.entries(s.publicHashes)){let v=await _.realpath(I.join(s.sourceRoot,f)),b=await _.realpath(s.sourceRoot);if(!v.startsWith(`${b}${I.sep}`))throw new Error("The public case file escaped its source root.");let R=await _.readFile(v);if(q(R)!==y)throw new Error("The public case file changed before upload.");await c(s,"policy",f,R)}if(s.runtimeRoot)for(let f of await u(s.runtimeRoot))await c(s,"runtime",f,await _.readFile(I.join(s.runtimeRoot,f)));let d=I.relative(s.sourceRoot,s.cwd??s.sourceRoot);if(d.startsWith("..")||I.isAbsolute(d))throw new Error("The command cwd escaped the admitted case.");let m=n.object({code:n.number().int().nullable(),stdout:n.string().max(75e4),stderr:n.string().max(75e4),timedOut:n.boolean(),stdoutTruncated:n.boolean(),stderrTruncated:n.boolean()}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"exec",command:s.command,stdin:s.stdin,cwd:d.split(I.sep).join("/"),timeoutMs:s.timeoutMs},s.timeoutMs+15e3));return s.signal.throwIfAborted(),m}),"execute"),readOutput:r(s=>o(s.sessionId,async()=>{let d=pt(s.path),m=[],f=null,y=null;for(let b=0;f===null||b<f;b+=98304){s.signal.throwIfAborted();let R=n.object({sizeBytes:n.number().int().min(1).max(1e7),sha256:n.string().regex(/^[a-f0-9]{64}$/),contentsBase64:n.string().max(131072)}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"read",path:d,offset:b},6e4));f??=R.sizeBytes,y??=R.sha256;let p=Buffer.from(R.contentsBase64,"base64");if(R.sizeBytes!==f||R.sha256!==y||p.length!==Math.min(98304,f-b)||p.toString("base64")!==R.contentsBase64)throw new Error("The confined output changed during readback.");m.push(p)}let v=Buffer.concat(m);if(q(v)!==y)throw new Error("The confined output differs from its saved byte identity.");return s.signal.throwIfAborted(),{bytes:v,title:d.split("/").at(-1)}}),"readOutput"),settle:r((s,d)=>o(s,async()=>{try{await a({sessionId:s,turnId:d,action:"stop"},6e4)}finally{e.delete(s)}}),"settle")}}r(Pt,"createHostedProfileCommandOwner");import{randomUUID as Lt}from"node:crypto";var j=98304;function Ht(l){let e=r((t,o)=>l.request(z.parse({contractVersion:h,requestId:Lt(),operation:t,params:o})),"request");return{persistence:{sourceTurnStartedAt:r(async()=>{throw new Error("The case owner must supply its actual turn start time.")},"sourceTurnStartedAt"),saveSandboxFile:r(async()=>{throw new Error("Isolated Profile outputs must be read by the confined case owner.")},"saveSandboxFile"),save:r(async({sessionId:t,turnId:o,identity:a,bytes:c})=>{let u=n.object({uploadId:n.string().min(1),maxChunkBytes:n.literal(j)}).parse(await e("output/begin",{sessionId:t,turnId:o,output:a}));for(let d=0;d<c.length;d+=j){let m=c.subarray(d,d+j);await e("output/chunk",{uploadId:u.uploadId,index:d/j,offset:d,sha256:q(m),contentsBase64:m.toString("base64")})}let{outputRef:s}=n.object({outputRef:Ge}).parse(await e("output/complete",{uploadId:u.uploadId}));if(s.location.kind!=="managed"||s.sha256!==a.sha256||s.sizeBytes!==c.length||s.sourceTaskId!==t||s.sourceTurnId!==o||s.id!==a.id||s.revision!==a.revision)throw new Error("The durable case output differs from its saved identity.");return{outputRef:s,artifact:{artifactRef:s.location.fileId,path:s.location.downloadPath,title:s.title,contentType:s.contentType,sizeBytes:s.sizeBytes}}},"save")},read:r(async(t,o)=>{if(t.location.kind!=="managed"||t.sizeBytes>1e7)throw new Error("Select a bounded managed case output.");let a=[];for(let u=0;u<t.sizeBytes;u+=j){o?.throwIfAborted();let s=n.object({offset:n.number().int(),contentsBase64:n.string().max(131072),sha256:n.string(),sizeBytes:n.number().int()}).parse(await e("output/readBytes",{sessionId:t.sourceTaskId,turnId:t.sourceTurnId,fileId:t.location.fileId,revision:t.revision,sha256:t.sha256,sizeBytes:t.sizeBytes,offset:u})),d=Buffer.from(s.contentsBase64,"base64");if(s.offset!==u||s.sha256!==t.sha256||s.sizeBytes!==t.sizeBytes||d.length!==Math.min(j,t.sizeBytes-u)||d.toString("base64")!==s.contentsBase64)throw new Error("The durable workbook byte range changed.");a.push(d)}o?.throwIfAborted();let c=Buffer.concat(a);if(q(c)!==t.sha256)throw new Error("The durable workbook differs from its sealed hash.");return c},"read")}}r(Ht,"createHostedProfileArtifactOwner");import{randomUUID as Gt}from"node:crypto";var $t=n.object({createdAt:n.string().datetime(),id:n.string().min(1)}).strict(),Kt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:$t.nullable()}).strict(),se=class{constructor(e){this.client=e}client;static{r(this,"HostedProfileEvaluationStorage")}execute(e){return this.client.request({contractVersion:h,requestId:Gt(),operation:"profile-evaluations/execute",params:e})}async get(e,t,o){let a=await this.execute({action:"get",kind:e,id:t});if(a===null)return null;let c=o.parse(a);return M(c,`Hosted Profile evaluation ${e}`),c}async put(e,t,o,a,c){let u=o.parse(t);M(u,`Hosted Profile evaluation ${e}`);let s=o.parse(await this.execute({action:"put",kind:e,payload:u,profileKey:a,createdAt:c}));if(s.contentHash!==u.contentHash||g(s)!==g(u))throw new Error("Hosted Profile evaluation write returned different evidence.");return s}async page(e,t,o){let a=[],c=null;do{let u=Kt.parse(await this.execute({action:"page",kind:e,profileKey:g(F.parse(t)),before:c,limit:100}));if(u.nextBefore&&(u.entries.length===0||c&&(u.nextBefore.createdAt>c.createdAt||u.nextBefore.createdAt===c.createdAt&&u.nextBefore.id>=c.id)))throw new Error("Hosted Profile evaluation cursor did not advance.");for(let s of u.entries){let d=o.parse(s);M(d,`Hosted Profile evaluation ${e}`),a.push(d)}if(a.length>1e4)throw new Error("Hosted Profile evaluation history exceeds the bounded catalog limit.");c=u.nextBefore}while(c);return a}getProfileEvaluationGrade(e){return this.get("grade",e,de)}saveProfileEvaluationGrade(e){return this.put("grade",e,de,null,new Date().toISOString())}getProfileEvaluationReceipt(e){return this.get("receipt",e,me)}saveProfileEvaluationReceipt(e){if(!Ae(e))throw new Error("Hosted Profile evaluation receipt is invalid.");return this.put("receipt",e,me,null,e.completedAt)}getProfileEvaluationRun(e){return this.get("run",e,Y)}saveProfileEvaluationRun(e){return this.put("run",e,Y,g(F.parse(e.profileRef)),e.completedAt)}listProfileEvaluationRuns(e){return this.page("run",e,Y)}getProfileEvaluationComparison(e){return this.get("comparison",e,Q)}saveProfileEvaluationComparison(e,t){return this.put("comparison",t,Q,g(F.parse(e)),t.createdAt)}listProfileEvaluationComparisons(e){return this.page("comparison",e,Q)}getProfileEvaluationSuiteRun(e){return this.get("suite",e,J)}saveProfileEvaluationSuiteRun(e,t,o){if(g(t)!==o.catalogHash)throw new Error("Hosted Profile evaluation suite differs from its catalog.");return this.put("suite",o,J,g(F.parse(e)),o.createdAt)}listProfileEvaluationSuiteRuns(e){return this.page("suite",e,J)}};async function Et(l){let e=l.release;if(!e.hostExecution)throw new Error("Hosted evaluation requires explicit host execution attribution.");let t={hostConversationId:e.hostExecution.conversationId,hostTurnId:e.hostExecution.turnId},o={source:"openpond_git",profileId:e.profileId,repositoryId:e.repositoryId},a=r(async()=>({ref:o,sourceRevision:e.sourceRevision}),"selectedProfile"),c=r(()=>re(l.client,e),"selectedWorkflows"),u=new se(l.client),s=r(async p=>{if(g(p)!==g(e.harnessRelease))throw new Error("Evaluation requires the admitted Profile release.");let S=await O(l.client,p);if(!S)throw new Error("Admitted evaluation Profile is unavailable.");return S},"loadRuntime"),d=r(async p=>{if(g(p.ref)!==g(o)||p.sourceRevision!==e.sourceRevision)throw new Error("Evaluation requires the admitted Profile source.");return je({...p,runtime:await s(p.harnessRelease)})},"loadCatalog"),m=l.externalDataset?await ht({value:l.externalDataset,release:(await s(e.harnessRelease)).release,sourceRevision:e.sourceRevision,client:l.client}):null,f=r(async(p,S,x)=>{if(S!==e.profileId)throw new Error("Evaluation Taskset Profile differs from its admitted source.");let E=await Ne({definition:p,harnessRelease:x,runtime:await s(x)});if(!E)throw new Error("Evaluation Taskset is absent from the admitted Profile release.");return E},"loadTasksetPackage"),y=wt({resolveExternalDataset:m?.resolveExternalDataset,store:{runtimeEventsForTurn:r(p=>l.core.runtimeEventsForTurn(p),"runtimeEventsForTurn")},storeDir:l.storeDir,readManagedArtifact:l.readManagedArtifact,admitSession:l.admitSession,settleSession:l.settleSession,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,createSession:r(p=>{let S=Le.parse(p);return l.createSession({...S,metadata:{...S.metadata,...t}})},"createSession"),sendTurn:r((p,S)=>{let x=Z.parse(S);return l.sendTurn(p,{...x,metadata:{...x.metadata,...t}})},"sendTurn"),interruptSessionTurn:l.interruptSessionTurn}),v=$e({resolveExternalDataset:m?.resolveExternalDataset,sourceCandidate:m?.sourceCandidate,privateGradingPreflight:r(p=>Me(p,!1),"privateGradingPreflight"),loadCatalog:d,selectedWorkflows:c,loadTasksetPackage:f,placement:"remote",boundedWorkComputeAvailable:!0,modelConfigurationHash:r(async(p,S)=>{if(p.providerId!=="openpond"||!S.hostModelConfigurationHash)throw new Error("Hosted evaluation requires a host-admitted model configuration receipt.");return S.hostModelConfigurationHash},"modelConfigurationHash")}),b=vt({resolveExternalDataset:m?.resolveExternalDataset,store:u,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,executeCase:y,privateGrading:r((p,S,x)=>ze({manifest:p,packageValue:S,signal:x,executeSandboxVerifier:De(l.client),authorize:r(async()=>{let E=p.profileEvaluation;if(!E||E.profileId!==e.profileId||E.sourceRevision!==e.sourceRevision)throw new Error("The hosted private grading source changed.");if(E.externalDatasetBinding){if(!m)throw new Error("The frozen Dataset owner is unavailable.");await m.authorize({bindingHash:E.externalDatasetBinding.contentHash,manifestHash:p.contentHash})}let B=await d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:E.harnessRelease});if(!E.externalDatasetBinding&&B.catalogHash!==E.catalogHash)throw new Error("The hosted private grading catalog changed.")},"authorize")}),"privateGrading")}),R={getProfileEvaluationRun:u.getProfileEvaluationRun.bind(u),getProfileEvaluationReceipt:u.getProfileEvaluationReceipt.bind(u),getProfileEvaluationGrade:u.getProfileEvaluationGrade.bind(u),getSession:l.core.getSession.bind(l.core),getTurn:l.core.getTurn.bind(l.core),runtimeEventsForTurn:l.core.runtimeEventsForTurn.bind(l.core),listModelUsageRecords:l.core.listModelUsageRecords.bind(l.core)};return{prepareProfileEvaluationRun:v,executeProfileEvaluationCase:y,executeProfileEvaluationRun:b,runPreparedProfileEvaluation:r(async p=>b(await v(p,{requireExpectedManifestHash:!0})),"runPreparedProfileEvaluation"),runProfileEvaluationSuite:yt({store:u,loadCatalog:d,selectedWorkflows:c,prepareRun:v,executeRun:b}),compareProfileEvaluationRuns:Je({store:u,selectedProfile:a}),buildProfileEvaluationReport:r(p=>Ze({store:u,profileRef:o,request:p}),"buildProfileEvaluationReport"),listProfileEvaluations:r(async p=>{if(p&&typeof p=="object"&&"runId"in p)return Qe({store:R,profileRef:o,...Ke.parse(p)});let[S,x,E,B]=await Promise.all([d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:e.harnessRelease}),u.listProfileEvaluationRuns(o),u.listProfileEvaluationComparisons(o),u.listProfileEvaluationSuiteRuns(o)]);return{...S,runs:x,comparisons:E,suiteRuns:B}},"listProfileEvaluations")}}r(Et,"createHostedProfileEvaluationRuntime");import{mkdir as lr}from"node:fs/promises";import{randomUUID as Dt}from"node:crypto";import W from"node:path";import{randomUUID as bt}from"node:crypto";var Qt=n.object({revision:n.number().int().nonnegative(),payload:n.record(n.string(),n.unknown()).nullable()}).strict(),Jt=n.object({entries:n.array(n.unknown()).max(100),nextAfterId:n.string().min(1).nullable()}).strict(),oe=class{constructor(e){this.client=e}client;static{r(this,"HostedHarnessStateStorage")}async getPreference(e,t){return Qt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:null,limit:1}}))}async listCandidates(e){return(await this.readAll(e,"candidates")).map(t=>Ie.parse(t))}async listCrossRunRequests(e){return(await this.readAll(e,"cross_run_requests")).map(t=>ke.parse(t))}async readAll(e,t){let o=[],a=null;do{let c=Jt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:a,limit:Math.min(100,1001-o.length)}}));if(c.nextAfterId&&(c.entries.length===0||c.nextAfterId===a))throw new Error("Hosted Harness state cursor did not advance.");if(o.push(...c.entries),o.length>1e3)throw new Error("Hosted Harness state exceeds 1,000 entries.");a=c.nextAfterId}while(a);return o}};import{randomUUID as Zt}from"node:crypto";import{cp as Yt,mkdir as Xt,rm as er}from"node:fs/promises";import tr from"node:path";var we=n.object({schemaVersion:n.literal("openpond.harnessMemoryEntry.v1"),id:n.string(),workspaceId:n.string(),key:n.string(),content:n.string(),tags:n.array(n.string()),revision:n.number().int().positive(),status:n.enum(["active","deleted"]),sourceRunId:n.string().nullable(),sourceProposal:n.object({id:n.string(),contentHash:n.string()}).nullable(),createdAt:n.string().datetime(),updatedAt:n.string().datetime(),contentHash:n.string().regex(/^[a-f0-9]{64}$/)}).strict(),rr=n.object({createdAt:n.string().datetime(),id:n.string()}).strict(),Tt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:rr.nullable()}).strict(),ve=n.object({workspace:ce,receipt:be}).strict(),ae=class{constructor(e,t){this.client=e;this.storeDir=t;this.usage=new Rt(e),this.overlay=new ee({request:r(async o=>o.operation==="harness/overlay/get"?this.request({action:"overlay_get",...o.params}):o.operation==="harness/overlay/freezeProposal"?this.request({action:"overlay_freeze",...o.params},o.requestId):e.request(o),"request")})}client;storeDir;static{r(this,"HostedHarnessReviewStorage")}harnessStoragePlacement="hosted";reviewSessionId=null;overlay;usage;request(e,t=Zt()){return this.client.request({contractVersion:h,requestId:t,operation:"harness/review/execute",params:e},e.action==="release_put"?6e4:15e3)}sessionId(){if(!this.reviewSessionId)throw new Error("Hosted review memory requires an admitted review session.");return this.reviewSessionId}async prepareReview(e){let t=await this.getSession(e.runRef);if(!t)throw new Error("Hosted review session is unavailable.");this.reviewSessionId=t.id;let o=await this.getHarnessRunOverlay(t.id);if(!o)throw new Error("Hosted review overlay is unavailable.");let a=await this.getHarnessWorkspace(o.workspace.workspaceId);if(!a?.currentChannel.release)throw new Error("Hosted review workspace release is unavailable.");let c=await this.getHarnessReleaseRecord(a.currentChannel.release.contentHash);if(!c||c.sourceRevision!==a.sourceRevision)throw new Error("Hosted review source binding changed.");let u=Oe(this.storeDir,a.id);await Xt(u.root,{recursive:!0,mode:448}),await er(u.source,{recursive:!0,force:!0}),await Yt(tr.join(c.bundlePath,"source"),u.source,{recursive:!0,force:!1,errorOnExist:!0});let s=await _e({workspaceId:a.id,sourceDir:u.source});if(s.sourceRevision!==a.sourceRevision||s.harnessRelease.contentHash!==c.harnessRelease.contentHash)throw new Error("Hosted review source cache differs from its immutable release.")}getHarnessWorkspace=r(async e=>ce.nullable().parse(await this.request({action:"workspace_get",workspaceId:e})),"getHarnessWorkspace");getHarnessReleaseRecord=r(async e=>fe.nullable().parse(await this.request({action:"release_get",contentHash:e})),"getHarnessReleaseRecord");saveHarnessReleaseRecord=r(async e=>fe.parse(await this.request({action:"release_put",record:e},`review-release:${e.harnessRelease.contentHash}`)),"saveHarnessReleaseRecord");getHarnessRunOverlay=r(e=>this.overlay.getHarnessRunOverlay(e),"getHarnessRunOverlay");createHarnessRunOverlay=r(e=>this.overlay.createHarnessRunOverlay(e),"createHarnessRunOverlay");freezeHarnessRunOverlayWithProposalAtomically=r(e=>this.overlay.freezeHarnessRunOverlayWithProposalAtomically(e),"freezeHarnessRunOverlayWithProposalAtomically");getHarnessBackgroundReviewSettings=r(async e=>n.object({enabled:n.boolean(),updatedAt:n.string().datetime().nullable()}).strict().parse(await this.request({action:"background_get",workspaceId:e})),"getHarnessBackgroundReviewSettings");getHarnessMemory=r(async(e,t)=>we.nullable().parse(await this.request({action:"memory_get",workspaceId:e,sessionId:this.sessionId(),key:t})),"getHarnessMemory");listHarnessMemories=r(async(e,t={})=>{let o=n.object({entries:n.array(we).max(20),nextBefore:n.object({updatedAt:n.string().datetime(),key:n.string()}).nullable()}),a=[],c=null;do{let u=o.parse(await this.request({action:"memory_page",workspaceId:e,sessionId:this.sessionId(),before:c,limit:20,includeDeleted:t.includeDeleted??!1}));if(a.push(...u.entries),u.nextBefore&&(!u.entries.length||g(u.nextBefore)===g(c)))throw new Error("Hosted memory cursor did not advance.");c=u.nextBefore}while(c&&a.length<1e3);if(c)throw new Error("Hosted review memory exceeds its bounded window.");return a},"listHarnessMemories");writeHarnessMemory=r(async e=>we.parse(await this.request({action:"memory_write",sessionId:this.sessionId(),input:e},`review-memory:${g(e)}`)),"writeHarnessMemory");saveHarnessImprovementArtifact=r(async(e,t,o)=>{let a={action:"artifact_put",workspaceId:e,kind:t,artifact:o},c=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse(a);return he[t].parse(await this.request(c,`review-artifact:${t}:${o.contentHash}`))},"saveHarnessImprovementArtifact");listHarnessImprovementArtifacts=r(async(e,t,o=100)=>{let a=[],c=null,u=Math.min(Math.max(1,Math.trunc(o)),1e3);do{let s=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse({action:"artifact_page",workspaceId:e,kind:t,before:c,limit:Math.min(100,u-a.length)}),d=Tt.parse(await this.request(s));if(a.push(...d.entries),d.nextBefore&&(!d.entries.length||g(d.nextBefore)===g(c)))throw new Error("Hosted artifact cursor did not advance.");c=d.nextBefore}while(c&&a.length<u);return a.map(s=>he[t].parse(s))},"listHarnessImprovementArtifacts");listPendingHarnessRefinerTriggers=r(async()=>{let e=await import("./hosted-harness-runtime-723S5ZSH.js").then(a=>a.loadHostedHarnessRuntime(this.client));if(!e)return[];let t=[],o=null;do{let a=Tt.parse(await this.request({action:"pending_page",workspaceId:e.workspace.id,before:o,limit:100}));if(t.push(...a.entries.map(c=>({workspaceId:e.workspace.id,trigger:Te.parse(c)}))),a.nextBefore&&(!a.entries.length||g(a.nextBefore)===g(o)))throw new Error("Hosted pending-review cursor did not advance.");o=a.nextBefore}while(o&&t.length<1e3);if(o)throw new Error("Hosted pending reviews exceed the bounded recovery window.");return t},"listPendingHarnessRefinerTriggers");advanceHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"advance",...e}})),"advanceHarnessWorkspaceAtomically");advanceReviewedHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"reviewedAdvance",...e}})),"advanceReviewedHarnessWorkspaceAtomically");rollbackHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"rollback",...e}})),"rollbackHarnessWorkspaceAtomically");getSession=r(async e=>Ue.nullable().parse(await this.request({action:"session_get",sessionId:e})),"getSession");getTurn=r(async e=>U.nullable().parse(await this.request({action:"turn_get",turnId:e})),"getTurn");updateTurn=r(async(e,t)=>{let o=await this.getTurn(e);if(!o)return null;let a=U.parse(t(o)),{harnessSnapshot:c,...u}=o,{harnessSnapshot:s,...d}=a;if(!s||g(u)!==g(d))throw new Error("Hosted review may only restore a missing Harness snapshot.");return U.parse(await this.request({action:"snapshot_restore",turnId:e,expectedHash:g(o),snapshot:s}))},"updateTurn");turnsForSession=r(async(e,t=1e3)=>{let o=n.object({entries:n.array(U).max(100),nextBefore:n.number().int().positive().nullable()}),a=[],c=null,u=Math.min(Math.max(1,Math.trunc(t)),1e3);do{let s=o.parse(await this.request({action:"turn_page",sessionId:e,before:c,limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),s.nextBefore&&(!s.entries.length||c!==null&&s.nextBefore>=c))throw new Error("Hosted review turn cursor did not advance.");c=s.nextBefore}while(c&&a.length<u);return a.reverse()},"turnsForSession");runtimeEventsForTurn=r(async(e,t={})=>{let o=n.object({entries:n.array(ge).max(100),nextAfterSequence:n.number().int().positive().nullable()}),a=[],c=0,u=Math.min(t.limit??1e4,1e4);do{let s=o.parse(await this.request({action:"event_page",turnId:e,afterSequence:c,names:[...t.names??[]],limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),!s.nextAfterSequence)return a;if(!s.entries.length||s.nextAfterSequence<=c)throw new Error("Hosted review event cursor did not advance.");c=s.nextAfterSequence}while(a.length<u);return a},"runtimeEventsForTurn");listModelUsageRecords=r(e=>this.usage.listModelUsageRecords(e),"listModelUsageRecords");async appendRuntimeEvent(e){return ge.parse(await this.request({action:"event_append",event:e},`review-event:${e.id}`))}async upsertModelUsageRecord(e){await this.request({action:"usage_put",record:e},`review-usage:${g(e)}`)}};import{randomUUID as sr}from"node:crypto";async function xt(l,e){let t=xe.parse(await l.request({contractVersion:h,requestId:sr(),operation:"refiner/execute",params:{action:{action:"active_release",workspaceId:e}}}));return M(t,"Hosted Refiner active release"),t}r(xt,"loadHostedRefinerRelease");import{randomUUID as or}from"node:crypto";var ar=n.object({personalizationSoul:n.string().max(8e3).optional(),userInstructions:n.string().max(64e3).optional(),preferences:pe.optional()}).strict(),nr=n.object({revision:n.number().int().positive(),settings:ar}).strict();async function ye(l){let e=await l.request({contractVersion:h,requestId:or(),operation:"settings/get",params:{}}),t=e===null?null:nr.parse(e);return{revision:t?.revision??null,personalizationSoul:t?.settings.personalizationSoul??Ce[0].content,userInstructions:t?.settings.userInstructions??"",preferences:t?.settings.preferences??pe.parse({})}}r(ye,"loadHostedRuntimeSettings");import{randomUUID as It}from"node:crypto";function kt(l){async function e(t){let o=await te(l,t);if(!o)throw new Error("No hosted Harness is selected for this run.");return o.workspace.id}return r(e,"workspaceId"),[{name:"memory_search",description:"Search bounded active memory for this selected Harness or Profile. Returns keys, revisions and short excerpts.",parameters:{type:"object",additionalProperties:!1,properties:{query:{type:"string",minLength:1,maxLength:500},limit:{type:"integer",minimum:1,maximum:20}},required:["query"]},execute:r(async t=>{let o=t.args.query;if(typeof o!="string"||!o.trim()||o.length>500)throw new Error("Memory query is invalid.");let a=t.args.limit===void 0?8:t.args.limit;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>20)throw new Error("Memory search limit is invalid.");let c=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/search",params:{workspaceId:await e(t.session),query:o,limit:a}});return{toolCallId:t.callId,name:"memory_search",ok:!0,contentText:JSON.stringify(c),data:c}},"execute")},{name:"memory_inspect",description:"Read one exact active memory entry returned by memory_search.",parameters:{type:"object",additionalProperties:!1,properties:{key:{type:"string",minLength:1,maxLength:120}},required:["key"]},execute:r(async t=>{let o=t.args.key;if(typeof o!="string"||!/^[a-z0-9][a-z0-9-]{0,119}$/.test(o))throw new Error("Memory key is invalid.");let a=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/get",params:{workspaceId:await e(t.session),key:o}});if(!a||typeof a!="object"||Array.isArray(a)||a.status!=="active")throw new Error(`Harness memory does not exist: ${o}.`);return{toolCallId:t.callId,name:"memory_inspect",ok:!0,contentText:JSON.stringify(a),data:a}},"execute")}]}r(kt,"createHostedHarnessMemoryTools");import{randomUUID as At}from"node:crypto";function Ct(l){return[{name:"work_list_outputs",description:"List this conversation's published outputs from completed turns without starting sandbox compute. Use this before reading a previously saved file; returns exact file IDs and revisions. New workspace files are published after the current turn ends. Inspect those with workspace tools and finish the turn instead of polling this list.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:r(async e=>{let t=await l.request({contractVersion:h,requestId:At(),operation:"output/list",params:{}});return{toolCallId:e.callId,name:"work_list_outputs",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")},{name:"work_read_output",description:"Read the actual saved text/Markdown or PDF text of a file returned by work_list_outputs, without starting sandbox compute. Prefer this for questions about saved outputs. Use workspace tools for edits, execution and unsaved files. PDF text extraction does not inspect images or page appearance.",parameters:{type:"object",additionalProperties:!1,properties:{fileId:{type:"string",minLength:1,maxLength:191},revision:{type:"integer",minimum:1},offset:{type:"integer",minimum:0,maximum:1e7},maxChars:{type:"integer",minimum:1,maximum:1e5},firstPage:{type:"integer",minimum:1,maximum:1e3},pageCount:{type:"integer",minimum:1,maximum:10}},required:["fileId","revision"]},execute:r(async e=>{let t=await l.request(z.parse({contractVersion:h,requestId:At(),operation:"output/read",params:e.args}),6e4);return{toolCallId:e.callId,name:"work_read_output",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")}]}r(Ct,"createHostedWorkOutputTools");import{randomUUID as Ot}from"node:crypto";function _t(l,e){return{allowedTools:e,authorizeTool:r(async t=>{let o=await l.request({contractVersion:h,requestId:Ot(),operation:"embedding/authorize",params:{sessionId:t.session.id,turnId:t.turnId,name:t.name}});if(!o||typeof o!="object"||Array.isArray(o)||o.allowed!==!0)throw new Error("Hosted tool authorization denied.")},"authorizeTool")}}r(_t,"createHostedEmbeddingAdapter");function qt(l){return async e=>{let t=qe.parse(e);return l.request({contractVersion:h,requestId:Ot(),operation:"sandbox/request",params:{action:t}},e.type==="create"?3e5:e.type==="exec"?18e4:6e4)}}r(qt,"createHostedSandboxRequest");var ir=["sandbox/request","embedding/authorize","output/begin","output/chunk","output/complete","output/saveSandboxFile","output/list","output/read","settings/get","harness/get","harness/overlay/get","harness/overlay/put","harness/memory/get","harness/memory/list","harness/memory/search","harness/memory/write","harness/state/read","task-inbox/execute","create-improve/execute","approval/get","approval/upsert","usage/getByRequestId","usage/upsert","usage/page","session/count","session/get","session/page","session/put","turn/count","turn/wakeCount","turn/get","turn/put","turn/latest","turn/page","thread/turnPage","event/append","events/page","events/latestAssistantText"];function Bt(l){if(ir.some(e=>!l.operations.includes(e)))throw new Error("Hosted Postgres runtime capabilities are incomplete.");if(l.maxRequestBytes<256e3||l.maxInFlight<32||l.maxPageSize<200)throw new Error("Hosted Postgres runtime transport limits are incompatible.")}r(Bt,"assertHostedWorkCapabilities");var w=r(async()=>{throw new Error("This hosted control is not available until its Postgres repository is activated.")},"unavailable"),ur=We(),cr=Ve();async function _o(l){let e=l.runtimeStorage,t=l.hostStorageClient;if(e.kind!=="hosted_postgres"||!t||e.client!==t)throw new Error("Hosted storage selection mismatch.");if(l.embedding||l.sandboxRequest)throw new Error("Hosted Postgres tool and sandbox authority must come from the host transport.");if(!l.streamOpenPondHostedChatTurn)throw new Error("Hosted Postgres runtime requires a host-admitted model stream.");if(l.profileSource||l.harness)throw new Error("Hosted Postgres runtime accepts only host-admitted immutable sources.");if(l.services&&Object.values(l.services).some(i=>i!==!1&&i!==void 0))throw new Error("Hosted service adapters must be admitted by the Postgres composition.");let o=Be.parse(await t.request({contractVersion:h,requestId:Dt(),operation:"capabilities",params:{}}));Bt(o);let a=_t(t,o.allowedTools),c=qt(t),u=W.resolve(l.storeDir??process.cwd()),s=W.resolve(l.workspaceDir??process.cwd());await lr(s,{recursive:!0});let d=st({channel:"app-server",logDir:W.join(u,"logs"),metadata:{version:l.version??Xe,runtimeVersion:Ye(),placement:"hosted_work"}}),m=e.core,f=new ae(t,u),y=e.admittedProfileRelease?await gt(t,e.admittedProfileRelease):{profile:cr,profileLibrary:ur},{appendRuntimeEvent:v,closeEventSubscribers:b,subscribeRuntimeEvents:R}=ut({logger:d,assistantDeltaFlushMs:250,store:{appendRuntimeEvent:r(i=>["harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed"].includes(i.name)?f.appendRuntimeEvent(i):m.appendRuntimeEvent(i),"appendRuntimeEvent"),runtimeEventPageRows:r(i=>m.runtimeEventPageRows(i),"runtimeEventPageRows")}}),p=X({queueId:"turn-follow-up",logger:d}),S=X({queueId:"subagent",logger:d}),x=nt(l.streamOpenPondHostedChatTurn,{enabled:at()}),E=X({queueId:"harness-refiner",logger:d,concurrency:1}),B=St({store:f,storeDir:u,queue:E,streamOpenPondHostedChatTurn:x,appendRuntimeEvent:v,upsertModelUsageRecord:r(i=>f.upsertModelUsageRecord(i),"upsertModelUsageRecord"),prepareReview:r(i=>f.prepareReview(i),"prepareReview"),loadActiveRefinerRelease:r(async()=>{let i=await O(t);if(!i)throw new Error("Hosted review has no admitted Harness workspace.");return xt(t,i.workspace.id)},"loadActiveRefinerRelease")}),Re=r(async()=>(await ye(t)).preferences,"preferences"),{createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt}=dt({store:m,defaultSessionCwd:r(()=>s,"defaultSessionCwd"),appendRuntimeEvent:v,loadAppPreferences:Re,loadLastUsedProfile:r(async()=>y.profileLibrary.lastUsed,"loadLastUsedProfile")}),le=lt({workspaceDir:s,logger:d,getSession:D,updateSession:ie,appendRuntimeEvent:v,sandboxRequest:c,sandboxCreationMode:"hosted_worker"}),V=ot({appendRuntimeEvent:v,findLocalProject:r(async()=>null,"findLocalProject"),onRepositoryInstructionDiagnostic:r((i,P)=>d.warn("repository instruction file skipped",{diagnostic:i,sessionId:P.id}),"onRepositoryInstructionDiagnostic")}),Nt=new ee(t),L=new oe(t),Se=Ht(t),ue=Pt(t),G=e.admittedProfileRelease?.hostExecution?await O(t,e.admittedProfileRelease.harnessRelease):null;if(e.admittedProfileRelease?.hostExecution&&(!G||!o.operations.includes("output/readBytes")||!o.operations.includes("profile-evaluations/sandbox")||!o.operations.includes("profile-evaluations/grade")))throw new Error("Hosted evaluation requires its admitted release, managed artifact owner and private sandbox grader.");let Ft=tt({deviceId:"hosted-evaluation",storeDir:u,runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i),"runtimeEventsForSession"),managedPersistence:{...Se.persistence,sourceTurnStartedAt:r(async(i,P)=>{let H=await m.getTurn(P);if(!H||H.sessionId!==i||!H.startedAt)throw new Error("The managed output has no actual started case turn.");return H.startedAt},"sourceTurnStartedAt")}}),k=G?ft({readOutput:ue.readOutput,executeCommand:ue.execute,settleRemote:ue.settle,runtimeNode:"node",runtimeAgentRoot:"/workspace/runtime",storeDir:u,release:G.release,getSession:D,getTurn:r(i=>m.getTurn(i),"getTurn"),saveOutput:Ft.saveOwnedOutputBytes,recordOutput:r(async(i,P,H)=>{await v({id:Dt(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:i,turnId:P,action:"work_output_save",status:"completed",data:H})},"recordOutput"),authorize:r(async()=>{let i=await O(t,e.admittedProfileRelease.harnessRelease);if(!i||i.release.harnessRelease.contentHash!==G.release.harnessRelease.contentHash)throw new Error("The hosted isolated evaluation source authority changed.")},"authorize")}):null,Ut=mt(a,async(i,P)=>{let H=await m.getTurn(i);if(!H)throw new Error("Embedded turn is unavailable.");let C=await D(H.sessionId),$=C.metadata?.embeddingToolBindings,N=[...P].sort((K,Wt)=>K.name.localeCompare(Wt.name));if($!==void 0&&g($)!==g(N))throw new Error("Embedded tool bindings changed; start a new thread.");await ie(C.id,{metadata:{...C.metadata,embeddingToolBindings:N}}),await m.updateTurn(i,K=>({...K,metadata:{...K.metadata,toolBindings:N}}))}),T=ct({executionHost:"embedded",workInputsForSession:l.workInputsForSession,attachmentRootDir:W.join(u,"attachments"),isolatedProfileEvaluationForTurn:k?async i=>{if(i.metadata?.profileEvaluationRun===void 0)return!1;if(!k.ownsSession(i.id))throw new Error("The hosted evaluation has no actual isolated case owner.");return!0}:void 0,executeProfileEvaluationAction:k?.executeAction,resolveModelTools:r(i=>k?.ownsSession(i.session.id)?k.resolveTools(i):Ut(i),"resolveModelTools"),hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1},store:m,inboxStore:e.inbox,createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt,upsertApproval:r(i=>m.upsertApproval(i),"upsertApproval"),defaultSessionCwd:r(()=>s,"defaultSessionCwd"),findOpenPondApp:r(async i=>({id:i||Fe(s),name:W.basename(s)||"Workspace",description:null,visibility:"private",sandbox:!0}),"findOpenPondApp"),resolveSessionWorkspaceCwd:r(async i=>i.cwd?.trim()||s,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:r(async()=>{throw new Error("Codex process hosting is unavailable.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:le.appendWorkspaceDiffEvent,workspaceDiffBaseline:le.workspaceDiffBaseline,appendRuntimeEvent:v,executeWorkspaceTool:le.executeWorkspaceTool,executeOpenPondCommand:r(async()=>{throw new Error("Hosted commands require durable authorization.")},"executeOpenPondCommand"),loadOpenPondProfileState:r(async()=>y.profile,"loadOpenPondProfileState"),loadOpenPondProfileLibrary:r(async()=>y.profileLibrary,"loadOpenPondProfileLibrary"),readOpenPondProfileSkill:w,loadSelectedHarnessRuntime:r(i=>{if(i.currentProfile&&(!e.admittedProfileRelease||i.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||i.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return te(t,i)},"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:r(i=>Nt.ensureHarnessRunOverlay(i),"ensureHarnessRunOverlay"),processHarnessImprovementBoundary:B,harnessModelTools:[...kt(t),...Ct(t)],loadBuiltInOpenPondSkills:r(async()=>[],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:w,loadPersonalizationSoul:r(async()=>(await ye(t)).personalizationSoul,"loadPersonalizationSoul"),loadAppPreferences:Re,maybeCreateScaffoldForTurn:V.maybeCreateScaffoldForTurn,hostedSystemPrompt:V.hostedSystemPrompt,appendAssistantText:V.appendAssistantText,appendHostedContextUsage:V.appendHostedContextUsage,streamOpenPondHostedChatTurn:x,turnFollowUpQueue:p,subagentQueue:S,maxHostedWorkspaceToolRounds:et(l.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:3});await T.recoverPendingSubagentCompletions(),await T.recoverTaskInbox();let Pe=!1,He=r(async(i,P)=>{if(Z.parse(P).attachments?.length&&!k?.ownsSession(i))throw new Error("Hosted attachments require managed-file admission.");let H=await D(i);if(H.currentProfile&&(!e.admittedProfileRelease||H.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||H.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return Pe||(await B.reconcilePending(),await E.drain(),Pe=!0),T.sendTurn(i,P)},"sendTurn");if(l.profileExternalDataset&&!e.admittedProfileRelease?.hostExecution)throw new Error("External Dataset requires its admitted hosted evaluation.");let A=e.admittedProfileRelease?.hostExecution?await Et({client:t,core:m,release:e.admittedProfileRelease,storeDir:u,...l.profileExternalDataset?{externalDataset:l.profileExternalDataset}:{},readManagedArtifact:Se.read,admitSession:k.admitSession,settleSession:k.settleSession,createSession:ne,sendTurn:He,interruptSessionTurn:T.interruptSessionTurn}):null,Ee=!1;return{...rt({ports:it({bindHome:!1,placement:"hosted_work",connectedAppProviders:[],featureOverrides:{profileWorkflows:!!e.admittedProfileRelease,profileEvaluations:!!A,harnessProposalReview:!1,harnessEvaluationReview:!1,harnessEvaluationReviewAcceptance:!1,harnessEvaluationTasksetMaterialization:!1,harnessEvaluationBaseline:!1,harnessBackgroundReview:!1,harnessDiff:!1,harnessRollback:!1,harnessReview:!1,refinerProfiles:!1,immutableRefinerAdmission:!1},createSession:ne,getSession:D,turnsForSession:r(i=>m.turnsForSession(i,1e3),"turnsForSession"),runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i,{excludeReasoningDeltas:!0}),"runtimeEventsForSession"),sendTurn:He,steerSessionTurn:T.steerSessionTurn,readTaskInbox:T.readTaskInbox,queueTaskInput:T.queueTaskInput,updateTaskInput:T.updateTaskInput,isSessionTurnActive:T.isSessionTurnActive,waitForSessionTurnSettlement:T.waitForSessionTurnSettlement,interruptSessionTurn:T.interruptSessionTurn,resolveApproval:r(async(i,P)=>{let H=await T.resolveCreateImproveApproval(i,P);if(H)return H;let C=await T.resolveSubagentPatchApplyApproval(i,P);if(C)return C;throw new Error(`Approval not found: ${i}`)},"resolveApproval"),listProfileWorkflows:e.admittedProfileRelease?()=>re(t,e.admittedProfileRelease):w,listProfileEvaluations:A?.listProfileEvaluations??w,loadProfileTrainingSource:w,prepareProfileEvaluationRun:A?.prepareProfileEvaluationRun??w,runPreparedProfileEvaluation:A?.runPreparedProfileEvaluation??w,runProfileEvaluationSuite:A?.runProfileEvaluationSuite??w,executeProfileEvaluationCase:A?.executeProfileEvaluationCase??w,executeProfileEvaluationRun:A?.executeProfileEvaluationRun??w,compareProfileEvaluationRuns:A?.compareProfileEvaluationRuns??w,buildProfileEvaluationReport:A?.buildProfileEvaluationReport??w,inspectHarness:r(async()=>{let i=await O(t);if(!i)return null;let P=i.workspace.id,[H,C,$,N]=await Promise.all([L.getPreference(P,"workspace_settings"),L.getPreference(P,"evaluation_review_settings"),L.listCandidates(P),L.listCrossRunRequests(P)]);return{workspace:i.workspace,release:i.release,backgroundReview:H,evaluationReview:C,refinementCandidates:$,crossRunRequests:N}},"inspectHarness"),reviewHarnessProposal:w,reviewHarness:w,acceptHarnessEvaluationReview:w,materializeHarnessEvaluationTaskset:w,runHarnessEvaluationBaseline:w,validateHarness:r(async()=>{let i=await O(t);return i?{valid:!0,workspaceId:i.workspace.id,harnessRelease:i.release.harnessRelease,agentSnapshot:i.release.agentSnapshot}:{valid:!1,reason:"No admitted hosted Harness release."}},"validateHarness"),updateHarnessBackgroundReview:w,diffHarness:w,rollbackHarness:w,inspectRefiner:w,updateRefiner:w,activateRefiner:w,rollbackRefiner:w,subscribeRuntimeEvents:R,observeRuntimeOperation:r(i=>d.info("agent runtime operation",i),"observeRuntimeOperation")}),close:r(async()=>{Ee||(Ee=!0,k?.close(),await T.close(),await Promise.all([p.drain(),S.drain(),E.drain()]),await b(),await d.flush())},"close")}),storePath:"hosted-postgres",workspaceDir:s,composition:["runtime_event_bus","session_store","hosted_provider","workspace_tools","command_approvals","harness","agent_runtime","jsonl_transport"]}}r(_o,"createHostedOwnedAppServer");export{_o as createHostedOwnedAppServer};
2
+ import{c as wt,d as vt,e as yt}from"./chunk-I3VVWNUW.js";import{b as gt,c as re,e as Rt}from"./chunk-JAJ46T5X.js";import{a as pt,b as ft}from"./chunk-ROGF26KV.js";import"./chunk-PF5R6CMP.js";import{b as ht}from"./chunk-DMVD2RFZ.js";import{a as ee,b as O,c as te}from"./chunk-JYKRR7E5.js";import{a as St}from"./chunk-X2HIHF2I.js";import"./chunk-X4OSOOSU.js";import"./chunk-65PL62KH.js";import{b as De,c as Me,d as ze,f as Ne,h as $e}from"./chunk-3Z47M3YY.js";import{b as je}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-SDAUS5PY.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as Je,b as Ze}from"./chunk-OPNRWESL.js";import{b as Ke,c as Qe}from"./chunk-7SC46OFC.js";import{a as Y}from"./chunk-O6ULLQJ6.js";import"./chunk-I3HZKJB3.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import{d as tt,e as st,ga as ct,ha as dt,ia as mt,j as ot,k as it,v as lt,w as X,y as ut}from"./chunk-6UDGARFC.js";import{a as rt}from"./chunk-4NESNOK5.js";import"./chunk-BLXEAZCQ.js";import"./chunk-UCPGRPWY.js";import{b as et}from"./chunk-RWWE5OXU.js";import"./chunk-RNQF63ZR.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import{a as at,b as nt}from"./chunk-GW766ZSO.js";import{p as Ye}from"./chunk-UKMA4R6X.js";import"./chunk-OQKJGTTO.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-A6USMRWK.js";import"./chunk-PCSIOUHF.js";import"./chunk-7KWD2I6W.js";import"./chunk-GPVCOEUH.js";import"./chunk-N73MU2C3.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import{b as Xe}from"./chunk-KG325WTN.js";import"./chunk-TTVS6JMC.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{F as qe,I as h,K as z,L as Be}from"./chunk-VRIEKBBH.js";import{g as Oe,m as _e}from"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import{a as ge,j as We,k as Ve,t as Ge}from"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import{a as Fe,o as F,p as Ue,q as U,v as Le,y as Z}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as he}from"./chunk-RNIAFXMB.js";import{a as fe}from"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import{b as Te}from"./chunk-N4FFQPLR.js";import{a as Ie,c as ke}from"./chunk-AY64VY4E.js";import{a as ce,h as be}from"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import{c as xe}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import{V as pe,X as Ce}from"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{Hb as Q,Ob as J,f as me,m as Ae}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{w as de}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{l as q,m as g,n as M}from"./chunk-KGNCKIFP.js";import{b as n}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";import{randomUUID as Vt}from"node:crypto";import{promises as _}from"node:fs";import I from"node:path";function Pt(l){let e=new Map,t=new Map;async function o(s,d){let m=(t.get(s)??Promise.resolve()).catch(()=>{}).then(d);t.set(s,m);try{return await m}finally{t.get(s)===m&&t.delete(s)}}r(o,"serial");let a=r((s,d=18e4)=>l.request(z.parse({contractVersion:h,requestId:Vt(),operation:"profile-evaluations/sandbox",params:s}),d),"request");async function c(s,d,m,f){let y=q(f),v=`${d}/${m}/${y}`,b=e.get(s.sessionId)??new Set;if(!b.has(v)){if(f.length>1e7)throw new Error("The public case file exceeds its admitted bound.");for(let R=0;R===0||R<f.length;R+=98304)s.signal.throwIfAborted(),await a({sessionId:s.sessionId,turnId:s.turnId,action:"upload",area:d,path:m,sha256:y,sizeBytes:f.length,offset:R,contentsBase64:f.subarray(R,R+98304).toString("base64")},3e5);b.add(v),e.set(s.sessionId,b)}}r(c,"upload");async function u(s,d=""){let m=[];for(let f of await _.readdir(I.join(s,d),{withFileTypes:!0})){let y=I.posix.join(d,f.name);if(f.isSymbolicLink()){let v=await _.realpath(I.join(s,y));if(!v.startsWith(`${await _.realpath(s)}${I.sep}`)||(await _.stat(v)).isDirectory())throw new Error("The public Agent runtime symlink escapes its file closure.");m.push(y);continue}if(f.isDirectory()?m.push(...await u(s,y)):f.isFile()&&m.push(y),m.length>8192)throw new Error("The public Agent runtime exceeds the file limit.")}return m}return r(u,"runtimeFiles"),{execute:r(s=>o(s.sessionId,async()=>{s.signal.throwIfAborted();for(let[f,y]of Object.entries(s.publicHashes)){let v=await _.realpath(I.join(s.sourceRoot,f)),b=await _.realpath(s.sourceRoot);if(!v.startsWith(`${b}${I.sep}`))throw new Error("The public case file escaped its source root.");let R=await _.readFile(v);if(q(R)!==y)throw new Error("The public case file changed before upload.");await c(s,"policy",f,R)}if(s.runtimeRoot)for(let f of await u(s.runtimeRoot))await c(s,"runtime",f,await _.readFile(I.join(s.runtimeRoot,f)));let d=I.relative(s.sourceRoot,s.cwd??s.sourceRoot);if(d.startsWith("..")||I.isAbsolute(d))throw new Error("The command cwd escaped the admitted case.");let m=n.object({code:n.number().int().nullable(),stdout:n.string().max(75e4),stderr:n.string().max(75e4),timedOut:n.boolean(),stdoutTruncated:n.boolean(),stderrTruncated:n.boolean()}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"exec",command:s.command,stdin:s.stdin,cwd:d.split(I.sep).join("/"),timeoutMs:s.timeoutMs},s.timeoutMs+15e3));return s.signal.throwIfAborted(),m}),"execute"),readOutput:r(s=>o(s.sessionId,async()=>{let d=pt(s.path),m=[],f=null,y=null;for(let b=0;f===null||b<f;b+=98304){s.signal.throwIfAborted();let R=n.object({sizeBytes:n.number().int().min(1).max(1e7),sha256:n.string().regex(/^[a-f0-9]{64}$/),contentsBase64:n.string().max(131072)}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"read",path:d,offset:b},6e4));f??=R.sizeBytes,y??=R.sha256;let p=Buffer.from(R.contentsBase64,"base64");if(R.sizeBytes!==f||R.sha256!==y||p.length!==Math.min(98304,f-b)||p.toString("base64")!==R.contentsBase64)throw new Error("The confined output changed during readback.");m.push(p)}let v=Buffer.concat(m);if(q(v)!==y)throw new Error("The confined output differs from its saved byte identity.");return s.signal.throwIfAborted(),{bytes:v,title:d.split("/").at(-1)}}),"readOutput"),settle:r((s,d)=>o(s,async()=>{try{await a({sessionId:s,turnId:d,action:"stop"},6e4)}finally{e.delete(s)}}),"settle")}}r(Pt,"createHostedProfileCommandOwner");import{randomUUID as Lt}from"node:crypto";var j=98304;function Ht(l){let e=r((t,o)=>l.request(z.parse({contractVersion:h,requestId:Lt(),operation:t,params:o})),"request");return{persistence:{sourceTurnStartedAt:r(async()=>{throw new Error("The case owner must supply its actual turn start time.")},"sourceTurnStartedAt"),saveSandboxFile:r(async()=>{throw new Error("Isolated Profile outputs must be read by the confined case owner.")},"saveSandboxFile"),save:r(async({sessionId:t,turnId:o,identity:a,bytes:c})=>{let u=n.object({uploadId:n.string().min(1),maxChunkBytes:n.literal(j)}).parse(await e("output/begin",{sessionId:t,turnId:o,output:a}));for(let d=0;d<c.length;d+=j){let m=c.subarray(d,d+j);await e("output/chunk",{uploadId:u.uploadId,index:d/j,offset:d,sha256:q(m),contentsBase64:m.toString("base64")})}let{outputRef:s}=n.object({outputRef:Ge}).parse(await e("output/complete",{uploadId:u.uploadId}));if(s.location.kind!=="managed"||s.sha256!==a.sha256||s.sizeBytes!==c.length||s.sourceTaskId!==t||s.sourceTurnId!==o||s.id!==a.id||s.revision!==a.revision)throw new Error("The durable case output differs from its saved identity.");return{outputRef:s,artifact:{artifactRef:s.location.fileId,path:s.location.downloadPath,title:s.title,contentType:s.contentType,sizeBytes:s.sizeBytes}}},"save")},read:r(async(t,o)=>{if(t.location.kind!=="managed"||t.sizeBytes>1e7)throw new Error("Select a bounded managed case output.");let a=[];for(let u=0;u<t.sizeBytes;u+=j){o?.throwIfAborted();let s=n.object({offset:n.number().int(),contentsBase64:n.string().max(131072),sha256:n.string(),sizeBytes:n.number().int()}).parse(await e("output/readBytes",{sessionId:t.sourceTaskId,turnId:t.sourceTurnId,fileId:t.location.fileId,revision:t.revision,sha256:t.sha256,sizeBytes:t.sizeBytes,offset:u})),d=Buffer.from(s.contentsBase64,"base64");if(s.offset!==u||s.sha256!==t.sha256||s.sizeBytes!==t.sizeBytes||d.length!==Math.min(j,t.sizeBytes-u)||d.toString("base64")!==s.contentsBase64)throw new Error("The durable workbook byte range changed.");a.push(d)}o?.throwIfAborted();let c=Buffer.concat(a);if(q(c)!==t.sha256)throw new Error("The durable workbook differs from its sealed hash.");return c},"read")}}r(Ht,"createHostedProfileArtifactOwner");import{randomUUID as Gt}from"node:crypto";var $t=n.object({createdAt:n.string().datetime(),id:n.string().min(1)}).strict(),Kt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:$t.nullable()}).strict(),se=class{constructor(e){this.client=e}client;static{r(this,"HostedProfileEvaluationStorage")}execute(e){return this.client.request({contractVersion:h,requestId:Gt(),operation:"profile-evaluations/execute",params:e})}async get(e,t,o){let a=await this.execute({action:"get",kind:e,id:t});if(a===null)return null;let c=o.parse(a);return M(c,`Hosted Profile evaluation ${e}`),c}async put(e,t,o,a,c){let u=o.parse(t);M(u,`Hosted Profile evaluation ${e}`);let s=o.parse(await this.execute({action:"put",kind:e,payload:u,profileKey:a,createdAt:c}));if(s.contentHash!==u.contentHash||g(s)!==g(u))throw new Error("Hosted Profile evaluation write returned different evidence.");return s}async page(e,t,o){let a=[],c=null;do{let u=Kt.parse(await this.execute({action:"page",kind:e,profileKey:g(F.parse(t)),before:c,limit:100}));if(u.nextBefore&&(u.entries.length===0||c&&(u.nextBefore.createdAt>c.createdAt||u.nextBefore.createdAt===c.createdAt&&u.nextBefore.id>=c.id)))throw new Error("Hosted Profile evaluation cursor did not advance.");for(let s of u.entries){let d=o.parse(s);M(d,`Hosted Profile evaluation ${e}`),a.push(d)}if(a.length>1e4)throw new Error("Hosted Profile evaluation history exceeds the bounded catalog limit.");c=u.nextBefore}while(c);return a}getProfileEvaluationGrade(e){return this.get("grade",e,de)}saveProfileEvaluationGrade(e){return this.put("grade",e,de,null,new Date().toISOString())}getProfileEvaluationReceipt(e){return this.get("receipt",e,me)}saveProfileEvaluationReceipt(e){if(!Ae(e))throw new Error("Hosted Profile evaluation receipt is invalid.");return this.put("receipt",e,me,null,e.completedAt)}getProfileEvaluationRun(e){return this.get("run",e,Y)}saveProfileEvaluationRun(e){return this.put("run",e,Y,g(F.parse(e.profileRef)),e.completedAt)}listProfileEvaluationRuns(e){return this.page("run",e,Y)}getProfileEvaluationComparison(e){return this.get("comparison",e,Q)}saveProfileEvaluationComparison(e,t){return this.put("comparison",t,Q,g(F.parse(e)),t.createdAt)}listProfileEvaluationComparisons(e){return this.page("comparison",e,Q)}getProfileEvaluationSuiteRun(e){return this.get("suite",e,J)}saveProfileEvaluationSuiteRun(e,t,o){if(g(t)!==o.catalogHash)throw new Error("Hosted Profile evaluation suite differs from its catalog.");return this.put("suite",o,J,g(F.parse(e)),o.createdAt)}listProfileEvaluationSuiteRuns(e){return this.page("suite",e,J)}};async function Et(l){let e=l.release;if(!e.hostExecution)throw new Error("Hosted evaluation requires explicit host execution attribution.");let t={hostConversationId:e.hostExecution.conversationId,hostTurnId:e.hostExecution.turnId},o={source:"openpond_git",profileId:e.profileId,repositoryId:e.repositoryId},a=r(async()=>({ref:o,sourceRevision:e.sourceRevision}),"selectedProfile"),c=r(()=>re(l.client,e),"selectedWorkflows"),u=new se(l.client),s=r(async p=>{if(g(p)!==g(e.harnessRelease))throw new Error("Evaluation requires the admitted Profile release.");let S=await O(l.client,p);if(!S)throw new Error("Admitted evaluation Profile is unavailable.");return S},"loadRuntime"),d=r(async p=>{if(g(p.ref)!==g(o)||p.sourceRevision!==e.sourceRevision)throw new Error("Evaluation requires the admitted Profile source.");return je({...p,runtime:await s(p.harnessRelease)})},"loadCatalog"),m=l.externalDataset?await ht({value:l.externalDataset,release:(await s(e.harnessRelease)).release,sourceRevision:e.sourceRevision,client:l.client}):null,f=r(async(p,S,x)=>{if(S!==e.profileId)throw new Error("Evaluation Taskset Profile differs from its admitted source.");let E=await Ne({definition:p,harnessRelease:x,runtime:await s(x)});if(!E)throw new Error("Evaluation Taskset is absent from the admitted Profile release.");return E},"loadTasksetPackage"),y=wt({resolveExternalDataset:m?.resolveExternalDataset,store:{runtimeEventsForTurn:r(p=>l.core.runtimeEventsForTurn(p),"runtimeEventsForTurn")},storeDir:l.storeDir,readManagedArtifact:l.readManagedArtifact,admitSession:l.admitSession,settleSession:l.settleSession,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,createSession:r(p=>{let S=Le.parse(p);return l.createSession({...S,metadata:{...S.metadata,...t}})},"createSession"),sendTurn:r((p,S)=>{let x=Z.parse(S);return l.sendTurn(p,{...x,metadata:{...x.metadata,...t}})},"sendTurn"),interruptSessionTurn:l.interruptSessionTurn}),v=$e({resolveExternalDataset:m?.resolveExternalDataset,sourceCandidate:m?.sourceCandidate,privateGradingPreflight:r(p=>Me(p,!1),"privateGradingPreflight"),loadCatalog:d,selectedWorkflows:c,loadTasksetPackage:f,placement:"remote",boundedWorkComputeAvailable:!0,modelConfigurationHash:r(async(p,S)=>{if(p.providerId!=="openpond"||!S.hostModelConfigurationHash)throw new Error("Hosted evaluation requires a host-admitted model configuration receipt.");return S.hostModelConfigurationHash},"modelConfigurationHash")}),b=vt({resolveExternalDataset:m?.resolveExternalDataset,store:u,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,executeCase:y,privateGrading:r((p,S,x)=>ze({manifest:p,packageValue:S,signal:x,executeSandboxVerifier:De(l.client),authorize:r(async()=>{let E=p.profileEvaluation;if(!E||E.profileId!==e.profileId||E.sourceRevision!==e.sourceRevision)throw new Error("The hosted private grading source changed.");if(E.externalDatasetBinding){if(!m)throw new Error("The frozen Dataset owner is unavailable.");await m.authorize({bindingHash:E.externalDatasetBinding.contentHash,manifestHash:p.contentHash})}let B=await d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:E.harnessRelease});if(!E.externalDatasetBinding&&B.catalogHash!==E.catalogHash)throw new Error("The hosted private grading catalog changed.")},"authorize")}),"privateGrading")}),R={getProfileEvaluationRun:u.getProfileEvaluationRun.bind(u),getProfileEvaluationReceipt:u.getProfileEvaluationReceipt.bind(u),getProfileEvaluationGrade:u.getProfileEvaluationGrade.bind(u),getSession:l.core.getSession.bind(l.core),getTurn:l.core.getTurn.bind(l.core),runtimeEventsForTurn:l.core.runtimeEventsForTurn.bind(l.core),listModelUsageRecords:l.core.listModelUsageRecords.bind(l.core)};return{prepareProfileEvaluationRun:v,executeProfileEvaluationCase:y,executeProfileEvaluationRun:b,runPreparedProfileEvaluation:r(async p=>b(await v(p,{requireExpectedManifestHash:!0})),"runPreparedProfileEvaluation"),runProfileEvaluationSuite:yt({store:u,loadCatalog:d,selectedWorkflows:c,prepareRun:v,executeRun:b}),compareProfileEvaluationRuns:Je({store:u,selectedProfile:a}),buildProfileEvaluationReport:r(p=>Ze({store:u,profileRef:o,request:p}),"buildProfileEvaluationReport"),listProfileEvaluations:r(async p=>{if(p&&typeof p=="object"&&"runId"in p)return Qe({store:R,profileRef:o,...Ke.parse(p)});let[S,x,E,B]=await Promise.all([d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:e.harnessRelease}),u.listProfileEvaluationRuns(o),u.listProfileEvaluationComparisons(o),u.listProfileEvaluationSuiteRuns(o)]);return{...S,runs:x,comparisons:E,suiteRuns:B}},"listProfileEvaluations")}}r(Et,"createHostedProfileEvaluationRuntime");import{mkdir as lr}from"node:fs/promises";import{randomUUID as Dt}from"node:crypto";import W from"node:path";import{randomUUID as bt}from"node:crypto";var Qt=n.object({revision:n.number().int().nonnegative(),payload:n.record(n.string(),n.unknown()).nullable()}).strict(),Jt=n.object({entries:n.array(n.unknown()).max(100),nextAfterId:n.string().min(1).nullable()}).strict(),oe=class{constructor(e){this.client=e}client;static{r(this,"HostedHarnessStateStorage")}async getPreference(e,t){return Qt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:null,limit:1}}))}async listCandidates(e){return(await this.readAll(e,"candidates")).map(t=>Ie.parse(t))}async listCrossRunRequests(e){return(await this.readAll(e,"cross_run_requests")).map(t=>ke.parse(t))}async readAll(e,t){let o=[],a=null;do{let c=Jt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:a,limit:Math.min(100,1001-o.length)}}));if(c.nextAfterId&&(c.entries.length===0||c.nextAfterId===a))throw new Error("Hosted Harness state cursor did not advance.");if(o.push(...c.entries),o.length>1e3)throw new Error("Hosted Harness state exceeds 1,000 entries.");a=c.nextAfterId}while(a);return o}};import{randomUUID as Zt}from"node:crypto";import{cp as Yt,mkdir as Xt,rm as er}from"node:fs/promises";import tr from"node:path";var we=n.object({schemaVersion:n.literal("openpond.harnessMemoryEntry.v1"),id:n.string(),workspaceId:n.string(),key:n.string(),content:n.string(),tags:n.array(n.string()),revision:n.number().int().positive(),status:n.enum(["active","deleted"]),sourceRunId:n.string().nullable(),sourceProposal:n.object({id:n.string(),contentHash:n.string()}).nullable(),createdAt:n.string().datetime(),updatedAt:n.string().datetime(),contentHash:n.string().regex(/^[a-f0-9]{64}$/)}).strict(),rr=n.object({createdAt:n.string().datetime(),id:n.string()}).strict(),Tt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:rr.nullable()}).strict(),ve=n.object({workspace:ce,receipt:be}).strict(),ae=class{constructor(e,t){this.client=e;this.storeDir=t;this.usage=new Rt(e),this.overlay=new ee({request:r(async o=>o.operation==="harness/overlay/get"?this.request({action:"overlay_get",...o.params}):o.operation==="harness/overlay/freezeProposal"?this.request({action:"overlay_freeze",...o.params},o.requestId):e.request(o),"request")})}client;storeDir;static{r(this,"HostedHarnessReviewStorage")}harnessStoragePlacement="hosted";reviewSessionId=null;overlay;usage;request(e,t=Zt()){return this.client.request({contractVersion:h,requestId:t,operation:"harness/review/execute",params:e},e.action==="release_put"?6e4:15e3)}sessionId(){if(!this.reviewSessionId)throw new Error("Hosted review memory requires an admitted review session.");return this.reviewSessionId}async prepareReview(e){let t=await this.getSession(e.runRef);if(!t)throw new Error("Hosted review session is unavailable.");this.reviewSessionId=t.id;let o=await this.getHarnessRunOverlay(t.id);if(!o)throw new Error("Hosted review overlay is unavailable.");let a=await this.getHarnessWorkspace(o.workspace.workspaceId);if(!a?.currentChannel.release)throw new Error("Hosted review workspace release is unavailable.");let c=await this.getHarnessReleaseRecord(a.currentChannel.release.contentHash);if(!c||c.sourceRevision!==a.sourceRevision)throw new Error("Hosted review source binding changed.");let u=Oe(this.storeDir,a.id);await Xt(u.root,{recursive:!0,mode:448}),await er(u.source,{recursive:!0,force:!0}),await Yt(tr.join(c.bundlePath,"source"),u.source,{recursive:!0,force:!1,errorOnExist:!0});let s=await _e({workspaceId:a.id,sourceDir:u.source});if(s.sourceRevision!==a.sourceRevision||s.harnessRelease.contentHash!==c.harnessRelease.contentHash)throw new Error("Hosted review source cache differs from its immutable release.")}getHarnessWorkspace=r(async e=>ce.nullable().parse(await this.request({action:"workspace_get",workspaceId:e})),"getHarnessWorkspace");getHarnessReleaseRecord=r(async e=>fe.nullable().parse(await this.request({action:"release_get",contentHash:e})),"getHarnessReleaseRecord");saveHarnessReleaseRecord=r(async e=>fe.parse(await this.request({action:"release_put",record:e},`review-release:${e.harnessRelease.contentHash}`)),"saveHarnessReleaseRecord");getHarnessRunOverlay=r(e=>this.overlay.getHarnessRunOverlay(e),"getHarnessRunOverlay");createHarnessRunOverlay=r(e=>this.overlay.createHarnessRunOverlay(e),"createHarnessRunOverlay");freezeHarnessRunOverlayWithProposalAtomically=r(e=>this.overlay.freezeHarnessRunOverlayWithProposalAtomically(e),"freezeHarnessRunOverlayWithProposalAtomically");getHarnessBackgroundReviewSettings=r(async e=>n.object({enabled:n.boolean(),updatedAt:n.string().datetime().nullable()}).strict().parse(await this.request({action:"background_get",workspaceId:e})),"getHarnessBackgroundReviewSettings");getHarnessMemory=r(async(e,t)=>we.nullable().parse(await this.request({action:"memory_get",workspaceId:e,sessionId:this.sessionId(),key:t})),"getHarnessMemory");listHarnessMemories=r(async(e,t={})=>{let o=n.object({entries:n.array(we).max(20),nextBefore:n.object({updatedAt:n.string().datetime(),key:n.string()}).nullable()}),a=[],c=null;do{let u=o.parse(await this.request({action:"memory_page",workspaceId:e,sessionId:this.sessionId(),before:c,limit:20,includeDeleted:t.includeDeleted??!1}));if(a.push(...u.entries),u.nextBefore&&(!u.entries.length||g(u.nextBefore)===g(c)))throw new Error("Hosted memory cursor did not advance.");c=u.nextBefore}while(c&&a.length<1e3);if(c)throw new Error("Hosted review memory exceeds its bounded window.");return a},"listHarnessMemories");writeHarnessMemory=r(async e=>we.parse(await this.request({action:"memory_write",sessionId:this.sessionId(),input:e},`review-memory:${g(e)}`)),"writeHarnessMemory");saveHarnessImprovementArtifact=r(async(e,t,o)=>{let a={action:"artifact_put",workspaceId:e,kind:t,artifact:o},c=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse(a);return he[t].parse(await this.request(c,`review-artifact:${t}:${o.contentHash}`))},"saveHarnessImprovementArtifact");listHarnessImprovementArtifacts=r(async(e,t,o=100)=>{let a=[],c=null,u=Math.min(Math.max(1,Math.trunc(o)),1e3);do{let s=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse({action:"artifact_page",workspaceId:e,kind:t,before:c,limit:Math.min(100,u-a.length)}),d=Tt.parse(await this.request(s));if(a.push(...d.entries),d.nextBefore&&(!d.entries.length||g(d.nextBefore)===g(c)))throw new Error("Hosted artifact cursor did not advance.");c=d.nextBefore}while(c&&a.length<u);return a.map(s=>he[t].parse(s))},"listHarnessImprovementArtifacts");listPendingHarnessRefinerTriggers=r(async()=>{let e=await import("./hosted-harness-runtime-YCKB6NBI.js").then(a=>a.loadHostedHarnessRuntime(this.client));if(!e)return[];let t=[],o=null;do{let a=Tt.parse(await this.request({action:"pending_page",workspaceId:e.workspace.id,before:o,limit:100}));if(t.push(...a.entries.map(c=>({workspaceId:e.workspace.id,trigger:Te.parse(c)}))),a.nextBefore&&(!a.entries.length||g(a.nextBefore)===g(o)))throw new Error("Hosted pending-review cursor did not advance.");o=a.nextBefore}while(o&&t.length<1e3);if(o)throw new Error("Hosted pending reviews exceed the bounded recovery window.");return t},"listPendingHarnessRefinerTriggers");advanceHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"advance",...e}})),"advanceHarnessWorkspaceAtomically");advanceReviewedHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"reviewedAdvance",...e}})),"advanceReviewedHarnessWorkspaceAtomically");rollbackHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"rollback",...e}})),"rollbackHarnessWorkspaceAtomically");getSession=r(async e=>Ue.nullable().parse(await this.request({action:"session_get",sessionId:e})),"getSession");getTurn=r(async e=>U.nullable().parse(await this.request({action:"turn_get",turnId:e})),"getTurn");updateTurn=r(async(e,t)=>{let o=await this.getTurn(e);if(!o)return null;let a=U.parse(t(o)),{harnessSnapshot:c,...u}=o,{harnessSnapshot:s,...d}=a;if(!s||g(u)!==g(d))throw new Error("Hosted review may only restore a missing Harness snapshot.");return U.parse(await this.request({action:"snapshot_restore",turnId:e,expectedHash:g(o),snapshot:s}))},"updateTurn");turnsForSession=r(async(e,t=1e3)=>{let o=n.object({entries:n.array(U).max(100),nextBefore:n.number().int().positive().nullable()}),a=[],c=null,u=Math.min(Math.max(1,Math.trunc(t)),1e3);do{let s=o.parse(await this.request({action:"turn_page",sessionId:e,before:c,limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),s.nextBefore&&(!s.entries.length||c!==null&&s.nextBefore>=c))throw new Error("Hosted review turn cursor did not advance.");c=s.nextBefore}while(c&&a.length<u);return a.reverse()},"turnsForSession");runtimeEventsForTurn=r(async(e,t={})=>{let o=n.object({entries:n.array(ge).max(100),nextAfterSequence:n.number().int().positive().nullable()}),a=[],c=0,u=Math.min(t.limit??1e4,1e4);do{let s=o.parse(await this.request({action:"event_page",turnId:e,afterSequence:c,names:[...t.names??[]],limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),!s.nextAfterSequence)return a;if(!s.entries.length||s.nextAfterSequence<=c)throw new Error("Hosted review event cursor did not advance.");c=s.nextAfterSequence}while(a.length<u);return a},"runtimeEventsForTurn");listModelUsageRecords=r(e=>this.usage.listModelUsageRecords(e),"listModelUsageRecords");async appendRuntimeEvent(e){return ge.parse(await this.request({action:"event_append",event:e},`review-event:${e.id}`))}async upsertModelUsageRecord(e){await this.request({action:"usage_put",record:e},`review-usage:${g(e)}`)}};import{randomUUID as sr}from"node:crypto";async function xt(l,e){let t=xe.parse(await l.request({contractVersion:h,requestId:sr(),operation:"refiner/execute",params:{action:{action:"active_release",workspaceId:e}}}));return M(t,"Hosted Refiner active release"),t}r(xt,"loadHostedRefinerRelease");import{randomUUID as or}from"node:crypto";var ar=n.object({personalizationSoul:n.string().max(8e3).optional(),userInstructions:n.string().max(64e3).optional(),preferences:pe.optional()}).strict(),nr=n.object({revision:n.number().int().positive(),settings:ar}).strict();async function ye(l){let e=await l.request({contractVersion:h,requestId:or(),operation:"settings/get",params:{}}),t=e===null?null:nr.parse(e);return{revision:t?.revision??null,personalizationSoul:t?.settings.personalizationSoul??Ce[0].content,userInstructions:t?.settings.userInstructions??"",preferences:t?.settings.preferences??pe.parse({})}}r(ye,"loadHostedRuntimeSettings");import{randomUUID as It}from"node:crypto";function kt(l){async function e(t){let o=await te(l,t);if(!o)throw new Error("No hosted Harness is selected for this run.");return o.workspace.id}return r(e,"workspaceId"),[{name:"memory_search",description:"Search bounded active memory for this selected Harness or Profile. Returns keys, revisions and short excerpts.",parameters:{type:"object",additionalProperties:!1,properties:{query:{type:"string",minLength:1,maxLength:500},limit:{type:"integer",minimum:1,maximum:20}},required:["query"]},execute:r(async t=>{let o=t.args.query;if(typeof o!="string"||!o.trim()||o.length>500)throw new Error("Memory query is invalid.");let a=t.args.limit===void 0?8:t.args.limit;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>20)throw new Error("Memory search limit is invalid.");let c=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/search",params:{workspaceId:await e(t.session),query:o,limit:a}});return{toolCallId:t.callId,name:"memory_search",ok:!0,contentText:JSON.stringify(c),data:c}},"execute")},{name:"memory_inspect",description:"Read one exact active memory entry returned by memory_search.",parameters:{type:"object",additionalProperties:!1,properties:{key:{type:"string",minLength:1,maxLength:120}},required:["key"]},execute:r(async t=>{let o=t.args.key;if(typeof o!="string"||!/^[a-z0-9][a-z0-9-]{0,119}$/.test(o))throw new Error("Memory key is invalid.");let a=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/get",params:{workspaceId:await e(t.session),key:o}});if(!a||typeof a!="object"||Array.isArray(a)||a.status!=="active")throw new Error(`Harness memory does not exist: ${o}.`);return{toolCallId:t.callId,name:"memory_inspect",ok:!0,contentText:JSON.stringify(a),data:a}},"execute")}]}r(kt,"createHostedHarnessMemoryTools");import{randomUUID as At}from"node:crypto";function Ct(l){return[{name:"work_list_outputs",description:"List this conversation's published outputs from completed turns without starting sandbox compute. Use this before reading a previously saved file; returns exact file IDs and revisions. New workspace files are published after the current turn ends. Inspect those with workspace tools and finish the turn instead of polling this list.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:r(async e=>{let t=await l.request({contractVersion:h,requestId:At(),operation:"output/list",params:{}});return{toolCallId:e.callId,name:"work_list_outputs",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")},{name:"work_read_output",description:"Read the actual saved text/Markdown or PDF text of a file returned by work_list_outputs, without starting sandbox compute. Prefer this for questions about saved outputs. Use workspace tools for edits, execution and unsaved files. PDF text extraction does not inspect images or page appearance.",parameters:{type:"object",additionalProperties:!1,properties:{fileId:{type:"string",minLength:1,maxLength:191},revision:{type:"integer",minimum:1},offset:{type:"integer",minimum:0,maximum:1e7},maxChars:{type:"integer",minimum:1,maximum:1e5},firstPage:{type:"integer",minimum:1,maximum:1e3},pageCount:{type:"integer",minimum:1,maximum:10}},required:["fileId","revision"]},execute:r(async e=>{let t=await l.request(z.parse({contractVersion:h,requestId:At(),operation:"output/read",params:e.args}),6e4);return{toolCallId:e.callId,name:"work_read_output",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")}]}r(Ct,"createHostedWorkOutputTools");import{randomUUID as Ot}from"node:crypto";function _t(l,e){return{allowedTools:e,authorizeTool:r(async t=>{let o=await l.request({contractVersion:h,requestId:Ot(),operation:"embedding/authorize",params:{sessionId:t.session.id,turnId:t.turnId,name:t.name}});if(!o||typeof o!="object"||Array.isArray(o)||o.allowed!==!0)throw new Error("Hosted tool authorization denied.")},"authorizeTool")}}r(_t,"createHostedEmbeddingAdapter");function qt(l){return async e=>{let t=qe.parse(e);return l.request({contractVersion:h,requestId:Ot(),operation:"sandbox/request",params:{action:t}},e.type==="create"?3e5:e.type==="exec"?18e4:6e4)}}r(qt,"createHostedSandboxRequest");var ir=["sandbox/request","embedding/authorize","output/begin","output/chunk","output/complete","output/saveSandboxFile","output/list","output/read","settings/get","harness/get","harness/overlay/get","harness/overlay/put","harness/memory/get","harness/memory/list","harness/memory/search","harness/memory/write","harness/state/read","task-inbox/execute","create-improve/execute","approval/get","approval/upsert","usage/getByRequestId","usage/upsert","usage/page","session/count","session/get","session/page","session/put","turn/count","turn/wakeCount","turn/get","turn/put","turn/latest","turn/page","thread/turnPage","event/append","events/page","events/latestAssistantText"];function Bt(l){if(ir.some(e=>!l.operations.includes(e)))throw new Error("Hosted Postgres runtime capabilities are incomplete.");if(l.maxRequestBytes<256e3||l.maxInFlight<32||l.maxPageSize<200)throw new Error("Hosted Postgres runtime transport limits are incompatible.")}r(Bt,"assertHostedWorkCapabilities");var w=r(async()=>{throw new Error("This hosted control is not available until its Postgres repository is activated.")},"unavailable"),ur=We(),cr=Ve();async function _o(l){let e=l.runtimeStorage,t=l.hostStorageClient;if(e.kind!=="hosted_postgres"||!t||e.client!==t)throw new Error("Hosted storage selection mismatch.");if(l.embedding||l.sandboxRequest)throw new Error("Hosted Postgres tool and sandbox authority must come from the host transport.");if(!l.streamOpenPondHostedChatTurn)throw new Error("Hosted Postgres runtime requires a host-admitted model stream.");if(l.profileSource||l.harness)throw new Error("Hosted Postgres runtime accepts only host-admitted immutable sources.");if(l.services&&Object.values(l.services).some(i=>i!==!1&&i!==void 0))throw new Error("Hosted service adapters must be admitted by the Postgres composition.");let o=Be.parse(await t.request({contractVersion:h,requestId:Dt(),operation:"capabilities",params:{}}));Bt(o);let a=_t(t,o.allowedTools),c=qt(t),u=W.resolve(l.storeDir??process.cwd()),s=W.resolve(l.workspaceDir??process.cwd());await lr(s,{recursive:!0});let d=st({channel:"app-server",logDir:W.join(u,"logs"),metadata:{version:l.version??Xe,runtimeVersion:Ye(),placement:"hosted_work"}}),m=e.core,f=new ae(t,u),y=e.admittedProfileRelease?await gt(t,e.admittedProfileRelease):{profile:cr,profileLibrary:ur},{appendRuntimeEvent:v,closeEventSubscribers:b,subscribeRuntimeEvents:R}=ut({logger:d,assistantDeltaFlushMs:250,store:{appendRuntimeEvent:r(i=>["harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed"].includes(i.name)?f.appendRuntimeEvent(i):m.appendRuntimeEvent(i),"appendRuntimeEvent"),runtimeEventPageRows:r(i=>m.runtimeEventPageRows(i),"runtimeEventPageRows")}}),p=X({queueId:"turn-follow-up",logger:d}),S=X({queueId:"subagent",logger:d}),x=nt(l.streamOpenPondHostedChatTurn,{enabled:at()}),E=X({queueId:"harness-refiner",logger:d,concurrency:1}),B=St({store:f,storeDir:u,queue:E,streamOpenPondHostedChatTurn:x,appendRuntimeEvent:v,upsertModelUsageRecord:r(i=>f.upsertModelUsageRecord(i),"upsertModelUsageRecord"),prepareReview:r(i=>f.prepareReview(i),"prepareReview"),loadActiveRefinerRelease:r(async()=>{let i=await O(t);if(!i)throw new Error("Hosted review has no admitted Harness workspace.");return xt(t,i.workspace.id)},"loadActiveRefinerRelease")}),Re=r(async()=>(await ye(t)).preferences,"preferences"),{createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt}=dt({store:m,defaultSessionCwd:r(()=>s,"defaultSessionCwd"),appendRuntimeEvent:v,loadAppPreferences:Re,loadLastUsedProfile:r(async()=>y.profileLibrary.lastUsed,"loadLastUsedProfile")}),le=lt({workspaceDir:s,logger:d,getSession:D,updateSession:ie,appendRuntimeEvent:v,sandboxRequest:c,sandboxCreationMode:"hosted_worker"}),V=ot({appendRuntimeEvent:v,findLocalProject:r(async()=>null,"findLocalProject"),onRepositoryInstructionDiagnostic:r((i,P)=>d.warn("repository instruction file skipped",{diagnostic:i,sessionId:P.id}),"onRepositoryInstructionDiagnostic")}),Nt=new ee(t),L=new oe(t),Se=Ht(t),ue=Pt(t),G=e.admittedProfileRelease?.hostExecution?await O(t,e.admittedProfileRelease.harnessRelease):null;if(e.admittedProfileRelease?.hostExecution&&(!G||!o.operations.includes("output/readBytes")||!o.operations.includes("profile-evaluations/sandbox")||!o.operations.includes("profile-evaluations/grade")))throw new Error("Hosted evaluation requires its admitted release, managed artifact owner and private sandbox grader.");let Ft=tt({deviceId:"hosted-evaluation",storeDir:u,runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i),"runtimeEventsForSession"),managedPersistence:{...Se.persistence,sourceTurnStartedAt:r(async(i,P)=>{let H=await m.getTurn(P);if(!H||H.sessionId!==i||!H.startedAt)throw new Error("The managed output has no actual started case turn.");return H.startedAt},"sourceTurnStartedAt")}}),k=G?ft({readOutput:ue.readOutput,executeCommand:ue.execute,settleRemote:ue.settle,runtimeNode:"node",runtimeAgentRoot:"/workspace/runtime",storeDir:u,release:G.release,getSession:D,getTurn:r(i=>m.getTurn(i),"getTurn"),saveOutput:Ft.saveOwnedOutputBytes,recordOutput:r(async(i,P,H)=>{await v({id:Dt(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:i,turnId:P,action:"work_output_save",status:"completed",data:H})},"recordOutput"),authorize:r(async()=>{let i=await O(t,e.admittedProfileRelease.harnessRelease);if(!i||i.release.harnessRelease.contentHash!==G.release.harnessRelease.contentHash)throw new Error("The hosted isolated evaluation source authority changed.")},"authorize")}):null,Ut=mt(a,async(i,P)=>{let H=await m.getTurn(i);if(!H)throw new Error("Embedded turn is unavailable.");let C=await D(H.sessionId),$=C.metadata?.embeddingToolBindings,N=[...P].sort((K,Wt)=>K.name.localeCompare(Wt.name));if($!==void 0&&g($)!==g(N))throw new Error("Embedded tool bindings changed; start a new thread.");await ie(C.id,{metadata:{...C.metadata,embeddingToolBindings:N}}),await m.updateTurn(i,K=>({...K,metadata:{...K.metadata,toolBindings:N}}))}),T=ct({executionHost:"embedded",workInputsForSession:l.workInputsForSession,attachmentRootDir:W.join(u,"attachments"),isolatedProfileEvaluationForTurn:k?async i=>{if(i.metadata?.profileEvaluationRun===void 0)return!1;if(!k.ownsSession(i.id))throw new Error("The hosted evaluation has no actual isolated case owner.");return!0}:void 0,executeProfileEvaluationAction:k?.executeAction,resolveModelTools:r(i=>k?.ownsSession(i.session.id)?k.resolveTools(i):Ut(i),"resolveModelTools"),hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1},store:m,inboxStore:e.inbox,createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt,upsertApproval:r(i=>m.upsertApproval(i),"upsertApproval"),defaultSessionCwd:r(()=>s,"defaultSessionCwd"),findOpenPondApp:r(async i=>({id:i||Fe(s),name:W.basename(s)||"Workspace",description:null,visibility:"private",sandbox:!0}),"findOpenPondApp"),resolveSessionWorkspaceCwd:r(async i=>i.cwd?.trim()||s,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:r(async()=>{throw new Error("Codex process hosting is unavailable.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:le.appendWorkspaceDiffEvent,workspaceDiffBaseline:le.workspaceDiffBaseline,appendRuntimeEvent:v,executeWorkspaceTool:le.executeWorkspaceTool,executeOpenPondCommand:r(async()=>{throw new Error("Hosted commands require durable authorization.")},"executeOpenPondCommand"),loadOpenPondProfileState:r(async()=>y.profile,"loadOpenPondProfileState"),loadOpenPondProfileLibrary:r(async()=>y.profileLibrary,"loadOpenPondProfileLibrary"),readOpenPondProfileSkill:w,loadSelectedHarnessRuntime:r(i=>{if(i.currentProfile&&(!e.admittedProfileRelease||i.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||i.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return te(t,i)},"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:r(i=>Nt.ensureHarnessRunOverlay(i),"ensureHarnessRunOverlay"),processHarnessImprovementBoundary:B,harnessModelTools:[...kt(t),...Ct(t)],loadBuiltInOpenPondSkills:r(async()=>[],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:w,loadPersonalizationSoul:r(async()=>(await ye(t)).personalizationSoul,"loadPersonalizationSoul"),loadAppPreferences:Re,maybeCreateScaffoldForTurn:V.maybeCreateScaffoldForTurn,hostedSystemPrompt:V.hostedSystemPrompt,appendAssistantText:V.appendAssistantText,appendHostedContextUsage:V.appendHostedContextUsage,streamOpenPondHostedChatTurn:x,turnFollowUpQueue:p,subagentQueue:S,maxHostedWorkspaceToolRounds:et(l.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:3});await T.recoverPendingSubagentCompletions(),await T.recoverTaskInbox();let Pe=!1,He=r(async(i,P)=>{if(Z.parse(P).attachments?.length&&!k?.ownsSession(i))throw new Error("Hosted attachments require managed-file admission.");let H=await D(i);if(H.currentProfile&&(!e.admittedProfileRelease||H.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||H.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return Pe||(await B.reconcilePending(),await E.drain(),Pe=!0),T.sendTurn(i,P)},"sendTurn");if(l.profileExternalDataset&&!e.admittedProfileRelease?.hostExecution)throw new Error("External Dataset requires its admitted hosted evaluation.");let A=e.admittedProfileRelease?.hostExecution?await Et({client:t,core:m,release:e.admittedProfileRelease,storeDir:u,...l.profileExternalDataset?{externalDataset:l.profileExternalDataset}:{},readManagedArtifact:Se.read,admitSession:k.admitSession,settleSession:k.settleSession,createSession:ne,sendTurn:He,interruptSessionTurn:T.interruptSessionTurn}):null,Ee=!1;return{...rt({ports:it({bindHome:!1,placement:"hosted_work",connectedAppProviders:[],featureOverrides:{profileWorkflows:!!e.admittedProfileRelease,profileEvaluations:!!A,harnessProposalReview:!1,harnessEvaluationReview:!1,harnessEvaluationReviewAcceptance:!1,harnessEvaluationTasksetMaterialization:!1,harnessEvaluationBaseline:!1,harnessBackgroundReview:!1,harnessDiff:!1,harnessRollback:!1,harnessReview:!1,refinerProfiles:!1,immutableRefinerAdmission:!1},createSession:ne,getSession:D,turnsForSession:r(i=>m.turnsForSession(i,1e3),"turnsForSession"),runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i,{excludeReasoningDeltas:!0}),"runtimeEventsForSession"),sendTurn:He,steerSessionTurn:T.steerSessionTurn,readTaskInbox:T.readTaskInbox,queueTaskInput:T.queueTaskInput,updateTaskInput:T.updateTaskInput,isSessionTurnActive:T.isSessionTurnActive,waitForSessionTurnSettlement:T.waitForSessionTurnSettlement,interruptSessionTurn:T.interruptSessionTurn,resolveApproval:r(async(i,P)=>{let H=await T.resolveCreateImproveApproval(i,P);if(H)return H;let C=await T.resolveSubagentPatchApplyApproval(i,P);if(C)return C;throw new Error(`Approval not found: ${i}`)},"resolveApproval"),listProfileWorkflows:e.admittedProfileRelease?()=>re(t,e.admittedProfileRelease):w,listProfileEvaluations:A?.listProfileEvaluations??w,loadProfileTrainingSource:w,prepareProfileEvaluationRun:A?.prepareProfileEvaluationRun??w,runPreparedProfileEvaluation:A?.runPreparedProfileEvaluation??w,runProfileEvaluationSuite:A?.runProfileEvaluationSuite??w,executeProfileEvaluationCase:A?.executeProfileEvaluationCase??w,executeProfileEvaluationRun:A?.executeProfileEvaluationRun??w,compareProfileEvaluationRuns:A?.compareProfileEvaluationRuns??w,buildProfileEvaluationReport:A?.buildProfileEvaluationReport??w,inspectHarness:r(async()=>{let i=await O(t);if(!i)return null;let P=i.workspace.id,[H,C,$,N]=await Promise.all([L.getPreference(P,"workspace_settings"),L.getPreference(P,"evaluation_review_settings"),L.listCandidates(P),L.listCrossRunRequests(P)]);return{workspace:i.workspace,release:i.release,backgroundReview:H,evaluationReview:C,refinementCandidates:$,crossRunRequests:N}},"inspectHarness"),reviewHarnessProposal:w,reviewHarness:w,acceptHarnessEvaluationReview:w,materializeHarnessEvaluationTaskset:w,runHarnessEvaluationBaseline:w,validateHarness:r(async()=>{let i=await O(t);return i?{valid:!0,workspaceId:i.workspace.id,harnessRelease:i.release.harnessRelease,agentSnapshot:i.release.agentSnapshot}:{valid:!1,reason:"No admitted hosted Harness release."}},"validateHarness"),updateHarnessBackgroundReview:w,diffHarness:w,rollbackHarness:w,inspectRefiner:w,updateRefiner:w,activateRefiner:w,rollbackRefiner:w,subscribeRuntimeEvents:R,observeRuntimeOperation:r(i=>d.info("agent runtime operation",i),"observeRuntimeOperation")}),close:r(async()=>{Ee||(Ee=!0,k?.close(),await T.close(),await Promise.all([p.drain(),S.drain(),E.drain()]),await b(),await d.flush())},"close")}),storePath:"hosted-postgres",workspaceDir:s,composition:["runtime_event_bus","session_store","hosted_provider","workspace_tools","command_approvals","harness","agent_runtime","jsonl_transport"]}}r(_o,"createHostedOwnedAppServer");export{_o as createHostedOwnedAppServer};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as Ie,b as ye,c as Re,d as He,e as Ee,f as Pe,h as B,i as Ae,j as je}from"./chunk-YOBN7KTF.js";import{A as Se,s as be,t as ke}from"./chunk-7HPDGZOR.js";import"./chunk-PPAPVGJP.js";import{e as Ce,f as U}from"./chunk-HZEIRHEB.js";import{b as De,c as ze}from"./chunk-PF5R6CMP.js";import"./chunk-X4OSOOSU.js";import"./chunk-3K4VVB7S.js";import"./chunk-XVDFJ3ZF.js";import"./chunk-EQFGBL3O.js";import"./chunk-GZ7M5XBP.js";import"./chunk-HCYX6RHP.js";import{b as pe}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import{a as z}from"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as we,b as ve}from"./chunk-FY5KHLMW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import{a as xe}from"./chunk-J2TWKFML.js";import"./chunk-773TH7FN.js";import{g as Te,j as G}from"./chunk-HDL5YSAA.js";import"./chunk-ZFSHBFG5.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import"./chunk-UKMA4R6X.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-7KWD2I6W.js";import"./chunk-OLLLZVHF.js";import"./chunk-7PXZ4X4P.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import"./chunk-KG325WTN.js";import"./chunk-3RCRSMWZ.js";import"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{b as ce,i as le,m as D,n as ue}from"./chunk-QNG27G3T.js";import{y as W}from"./chunk-EIRYMSEG.js";import{a as me,r as fe,s as he}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{p as C,q as $}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import{u as ge}from"./chunk-QOGJAQDO.js";import{g as se,l as V,n as de}from"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import{ia as ae,la as ie}from"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YR5ID2SS.js";import{c as re,d as oe,f as ne}from"./chunk-YBT2NB32.js";import{c as Y,g as ee}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import{f as X}from"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{Cb as M}from"./chunk-ACYFMLWG.js";import{r as te}from"./chunk-TVQAPBLZ.js";import{l as J,m as R}from"./chunk-KGNCKIFP.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{promises as $e}from"node:fs";import Ue from"node:path";import Le from"node:http";var Q=e.object({socketPath:e.string().min(1).max(1e3),capability:e.string().regex(/^[a-f0-9]{64}$/),jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),Ne=e.object({jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/),requestId:e.string().min(1).max(500),model:X,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max","none"]).nullable(),messages:e.array(e.unknown()).min(1).max(1e3),tools:e.array(e.unknown()).max(100),toolChoice:e.unknown(),maxOutputTokens:e.number().int().positive().max(131072),temperature:e.number().finite().optional(),topP:e.number().finite().optional(),seed:e.number().int().optional()}).strict(),Je=e.discriminatedUnion("kind",[e.object({kind:e.literal("chat_completions_reasoning"),reasoningContent:e.string()}).strict(),e.object({kind:e.literal("responses_reasoning_items"),items:e.array(e.record(e.string(),e.unknown()))}).strict()]),Ve=e.object({id:e.string().optional(),type:e.string(),function:e.object({name:e.string().optional(),arguments:e.string().optional()}).passthrough().optional()}).passthrough(),Ge=e.object({text:e.string().optional(),usage:e.unknown().optional(),costUsd:e.number().finite().nonnegative().optional(),continuation:Je.optional(),toolCalls:e.array(Ve).optional()}).strict();function qe(s,r){let t=Q.parse(s);async function n(u,v,I=r){I.throwIfAborted();let x=Buffer.from(JSON.stringify({action:u,jobId:t.jobId,pinHash:t.pinHash,value:v}));if(x.length>8*1024*1024)throw new Error("Hosted advanced request exceeds its private byte limit.");return new Promise((y,h)=>{let l=Le.request({socketPath:t.socketPath,path:"/",method:"POST",headers:{authorization:`Bearer ${t.capability}`,"content-type":"application/json","content-length":x.length},signal:I},H=>{let E=[],P=0;H.on("data",w=>{if(P+=w.length,P>8388608){H.destroy(new Error("Hosted advanced response exceeds its private byte limit."));return}E.push(w)}),H.on("error",h),H.on("end",()=>{try{let w=JSON.parse(Buffer.concat(E).toString("utf8"));if(H.statusCode!==200)throw new Error(typeof w?.error=="string"?w.error:"The actual hosted advanced owner refused this operation.");y(w)}catch(w){h(w)}})});l.on("error",h),l.end(x)})}i(n,"call");let d=i(async function*(u){let v=Ne.parse({jobId:t.jobId,pinHash:t.pinHash,requestId:u.requestId,model:u.model,reasoningEffort:u.reasoningEffort,messages:u.messages,tools:u.tools,toolChoice:u.toolChoice,maxOutputTokens:u.maxOutputTokens??4096,...u.temperature===void 0?{}:{temperature:u.temperature},...u.topP===void 0?{}:{topP:u.topP},...u.seed===void 0?{}:{seed:u.seed}}),I=e.object({deltas:e.array(Ge).max(1e5)}).strict().parse(await n("model",v,AbortSignal.any([r,u.signal])));for(let x of I.deltas)yield x},"stream");return{stream:d,text:i(async u=>{let v="";for await(let I of d({...u,reasoningEffort:u.reasoningEffort??null,tools:[],toolChoice:"none"}))I.text&&(v+=I.text),I.usage!==void 0&&u.onUsage?.(I.usage,I.costUsd);return v},"text"),authorize:i(async()=>{await n("authorize",{})},"authorize"),ceiling:i(async(u,v,I)=>e.object({configurationHash:e.string().regex(/^[a-f0-9]{64}$/),maximumChargeUsd:e.number().finite().positive()}).strict().parse(await n("ceiling",{modelId:u,pricing:v,maximumOutputTokens:I})),"ceiling"),compute:i((u,v=!1)=>n("compute",u,v?AbortSignal.timeout(6e4):r),"compute"),checkpoint:i(u=>n("checkpoint",u),"checkpoint")}}i(qe,"createHostedAdvancedModelBridge");import Qe from"node:path";var Me=e.string().regex(/^[a-f0-9]{64}$/),Ke=e.object({taskId:e.string().min(1),caseHash:Me,session:C,turn:$,events:e.array(me).max(1e4),traceHash:Me,output:e.string().nullable()}).strict(),K=e.object({packageValue:ae,contexts:e.array(Ke).max(1e4)}).strict();async function _e(s){let r=V(s.pin),t=K.parse(s.privateSource),n=ie(t.packageValue),d=M(e.object({manifest:e.unknown(),result:e.unknown()}).parse(s.evidence));async function m(){if(await s.authorize(),r.actorId!==s.actor.actorId||r.teamId!==s.actor.teamId||r.profileRef.source!=="openpond_git"||r.profileRef.repositoryId!==s.source.repositoryId||r.profileRef.profileId!==s.source.profileId||r.sourceRevision!==s.source.sourceRevision)throw new Error("The actual hosted advanced source owner changed.")}if(i(m,"authorize"),await m(),d.manifest.teamId!==r.teamId||d.result.status!=="completed"||d.manifest.id!==r.evidence.id||d.result.contentHash!==r.evidence.contentHash||R(d.manifest.dataset)!==R(r.externalDatasetBinding.dataset))throw new Error("The exact completed hosted advanced evidence changed.");if(n.contentHash!==r.externalDatasetBinding.packageHash||n.contentHash!==r.adaptationDatasetBinding.packageHash||n.environment.contentHash!==r.environmentPolicy.environmentHash||n.environment.contract.networkPolicy!=="none")throw new Error("The hosted advanced environment/package is not the exact reviewed closed-network release.");if(n.taskset.tools.some(l=>l.name==="web_search"||l.name==="web_fetch"))throw new Error("Live external tools require their own qualified frozen-observation and budget owner.");if(n.verifierSet.graders.some(l=>l.kind==="human"||l.kind==="model_judge"&&l.calibrationStatus!=="passed"))throw new Error("Advanced hosted evaluation needs executable, qualified independent graders.");let u=r.adaptationTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),v=r.holdoutTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),I=new Set(u.map(l=>l?.clusterKey));if(u.some(l=>!l||l.split!==r.adaptationSplit)||v.some(l=>!l||l.split!==r.holdoutSplit||I.has(l.clusterKey)))throw new Error("Hosted adaptation/holdout membership or independent families changed.");let x=await s.store.getHarnessReleaseRecord(r.baselineRelease.contentHash);if(!x||x.harnessRelease.id!==r.baselineRelease.id||s.workspace.currentChannel.release?.contentHash!==r.baselineRelease.contentHash)throw new Error("The exact hosted source baseline is unavailable.");let y=await D({workspaceId:typeof x.agentSnapshot.metadata.workspaceId=="string"?x.agentSnapshot.metadata.workspaceId:x.workspaceId,sourceDir:Qe.join(x.bundlePath,"source")});if(z(y).protectedClosureHash!==r.privateClosureHash)throw new Error("The protected hosted Profile closure changed.");let h={packageValue:n,authorize:m};return{read:i(async l=>{if(V(l).contentHash!==r.contentHash)throw new Error("The actual hosted advanced admission changed.");return await m(),h},"read"),evidence:i(async()=>(await m(),d),"evidence"),authorize:i(async()=>m(),"authorize"),reviewContext:i(async(l,H)=>{await m();let E=t.contexts.filter(p=>p.taskId===H),P=d.result.cases.find(p=>p.identity.caseId===H);if(E.length!==1||!P||P.status!=="completed")throw new Error("The actual retained hosted review case is unavailable.");let w=E[0];if(w.caseHash!==R(P)||w.session.cloudTeamId!==r.teamId||w.turn.sessionId!==w.session.id||w.turn.status==="in_progress"||w.events.some(p=>p.sessionId!==w.session.id||p.turnId!==w.turn.id))throw new Error("The actual hosted review session/turn/trace binding changed.");return await m(),{...w,case:{output:w.output}}},"reviewContext")}}i(_e,"createHostedAdvancedRefinerSource");import{randomUUID as Ze}from"node:crypto";function Oe(s){async function r(n){let d=await s.store.getSession(n);if(!d||d.cloudTeamId!==s.teamId||d.metadata?.hostedAdvancedTurnId!==s.hostedTurnId||d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The actual hosted advanced case owner changed.");return d}i(r,"read");async function t(n,d,m){let u=await r(n),v=e.object({action:e.string()}).passthrough().parse(d).action;return he.parse(await s.bridge.compute({session:u,payload:d,turnId:m??null},v==="sandbox_stop"||v==="sandbox_receipts"))}return i(t,"tool"),{createSession:i(async n=>{await s.bridge.authorize();let d=C.partial().parse(n),m=new Date().toISOString();if(d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The foreground case belongs to another actual advanced Run.");let u=C.parse({...d,id:`hosted-advanced-case-${Ze()}`,provider:"openpond",currentProfile:s.profileRef,cloudTeamId:s.teamId,cwd:null,codexThreadId:null,appId:null,appName:null,createdAt:m,updatedAt:m,status:"active",pinned:!1,archived:!1,order:0,hiddenFromDefaultSidebar:!0,title:d.title??"Advanced hosted evaluation case",metadata:{...d.metadata,source:"hosted-advanced-evaluation",hostedAdvancedTurnId:s.hostedTurnId,actorId:s.actorId,workspaceTarget:"hosted",benchmarkRuntime:"hosted_managed_work"}});return await s.store.insertSessionAtFront(u),await s.bridge.authorize(),u},"createSession"),getSession:r,runtimeEventsForSession:i(n=>s.store.runtimeEventsForSession(n),"runtimeEventsForSession"),executeWorkspaceTool:i((n,d,m)=>t(n,d,m?.turnId),"executeWorkspaceTool"),settleCostEvidence:i((n,d)=>t(n,{action:"sandbox_receipts",args:{}},d?.turnId),"settleCostEvidence")}}i(Oe,"createHostedAdvancedWorkRuntime");var Xe=e.string().regex(/^[a-f0-9]{64}$/),Be=e.object({version:e.string().min(1),source:e.string().min(1),effectiveAt:e.string().min(1),inputUsdPerMillionTokens:e.number().finite().nonnegative(),cachedInputUsdPerMillionTokens:e.number().finite().nonnegative(),outputUsdPerMillionTokens:e.number().finite().nonnegative()}).strict(),Z=e.object({operation:e.enum(["prepare_run","start","read","resume","cancel"]),request:de,configuration:e.object({id:e.string().min(1),profileId:e.string().min(1),etag:Xe}).strict(),refinerRelease:Y,privateSource:K,upstream:e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict(),judgeModels:e.array(e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict()).max(50),bridge:Q.optional(),hostedTurnId:e.string().min(1).optional()}).strict();async function Fe(s){let r=Z.parse(s.request),t=r.request.pin;if(r.request.model.providerId!=="openpond"||r.request.model.modelId!==r.upstream.modelId||r.configuration.id!==r.request.modelId||r.configuration.profileId!==t.profileRef.profileId||r.request.profileId!==t.profileRef.profileId||r.refinerRelease.id!==t.refinerRelease.id||r.refinerRelease.contentHash!==t.refinerRelease.contentHash)throw new Error("The actual hosted advanced configuration/model/Refiner admission changed.");let n=`advanced-refiner-${R([t.actorId,t.teamId,t.operationId,t.contentHash,r.request.model,[r.request.seed],1]).slice(0,40)}`;if((r.operation==="start"||r.operation==="resume")&&(!r.bridge||!r.hostedTurnId))throw new Error("The actual hosted advanced execution grant is unavailable.");let m=r.bridge?qe(r.bridge,s.signal):null;if(r.bridge&&(r.bridge.jobId!==n||r.bridge.pinHash!==t.contentHash))throw new Error("The hosted model bridge belongs to another actual Run.");let u=i(async()=>{s.signal.throwIfAborted(),await s.authorize(),m&&await m.authorize()},"authorize"),v=await _e({...s,pin:t,privateSource:r.privateSource,authorize:u}),I=we(ve(s.storeDir));await I.persistRelease(r.refinerRelease),await I.writeSource(ee(r.refinerRelease.profile)),I.binding()?.release.contentHash!==t.refinerRelease.contentHash&&await I.transition(r.refinerRelease,{operation:"activate",bindingChanged:!0,actor:s.actor.actorId,reason:"Pin the actual hosted evaluation fork to its admitted immutable Refiner release.",authoringSkillHash:null});let y=ke({storeDir:s.storeDir,authorize:i(async()=>u(),"authorize"),packageForPin:i(async()=>r.privateSource.packageValue,"packageForPin"),prepareModel:i(async(c,f,k)=>{if(!m)throw new Error("The actual hosted model ceiling owner is unavailable.");return m.ceiling(c,k,f)},"prepareModel")}),h=i(async function*(c){let f=be(),k=[r.upstream,...r.judgeModels].find(q=>q.modelId===c.model.modelId);if(!m||!f||!k)throw new Error("The actual hosted model and durable shared budget are unavailable.");let{signal:T,...j}=c,O=c.maxOutputTokens??4096,L=await f.call(c.requestId,j,k.pricing,O,async()=>{let q=[],F=null;for await(let N of m.stream({...c,signal:AbortSignal.any([T,f.signal])}))q.push(N),N.costUsd!==void 0&&(F=(F??0)+N.costUsd);return{value:q,costUsd:F}});for(let q of L)yield q},"stream"),l=i(async c=>{let f="";for await(let k of h({...c,reasoningEffort:c.reasoningEffort??null,tools:[],toolChoice:"none"}))k.text&&(f+=k.text),k.usage!==void 0&&c.onUsage?.(k.usage,k.costUsd);return f},"text"),H=Ie({store:s.store,storeDir:s.storeDir}),E=await H.projectSelected({profileId:t.profileRef.profileId,package:r.privateSource.packageValue,adaptationSplit:t.adaptationSplit,holdoutSplit:t.holdoutSplit}),P=i(async c=>{let f=C.partial().parse(c),k=new Date().toISOString(),T=C.parse({...f,id:`hosted-review-${R([n,f.metadata]).slice(0,40)}`,cloudTeamId:t.teamId,currentProfile:t.profileRef,appId:null,appName:null,cwd:null,codexThreadId:null,title:f.title??"Hosted Refiner review",provider:"openpond",createdAt:k,updatedAt:k,status:"active",pinned:!1,archived:!1,order:0,metadata:{...f.metadata,hostedAdvancedTurnId:r.hostedTurnId??null,actorId:t.actorId,source:"hosted-advanced-evaluation"}});return await s.store.insertSessionAtFront(T),T},"createSession"),w=m&&r.hostedTurnId?Oe({store:s.store,bridge:m,teamId:t.teamId,actorId:t.actorId,hostedTurnId:r.hostedTurnId,modelRunId:n,profileRef:t.profileRef}):void 0,p=Se({store:s.store,storeDir:s.storeDir,modelJudge:ye({store:s.store,modelText:l}),modelText:l,modelStream:h,workRuntime:w,resolveTasksetRelease:i(c=>H.releaseForTaskset(c),"resolveTasksetRelease")}),a={store:s.store,storeDir:s.storeDir,evaluation:p,benchmarkTasksets:H,loadProfileState:i(async()=>s.profile,"loadProfileState"),resolveEvaluationProject:i(async(c,f)=>{if(await u(),c!==r.configuration.id||f!==r.configuration.profileId)throw new Error("The actual hosted evaluation configuration changed.");return{id:c,profileId:f}},"resolveEvaluationProject"),resolveUpstreamModel:i(async()=>({providerId:"openpond",modelId:r.upstream.modelId,revision:r.upstream.revision,pricing:r.upstream.pricing}),"resolveUpstreamModel"),advancedBoundary:y,refinerStream:i(async function*(c){if(!c.requestId)throw new Error("A hosted Refiner call needs its actual retained ID.");yield*h({model:c.model,reasoningEffort:"low",messages:c.messages,tools:[],toolChoice:"none",requestId:c.requestId,maxOutputTokens:4096,signal:c.signal,hostedTokenPricing:c.pricing})},"refinerStream")},o=Re({...a,reviewQuality:He({source:v,boundary:y,benchmark:a,createSession:P})}),g={advancedEvaluation:t,selectedTaskset:{id:E.id,revision:E.revision,contentHash:E.contentHash},modelId:r.request.modelId,profileId:r.request.profileId,model:r.request.model,reasoningEffort:r.request.reasoningEffort,seeds:[r.request.seed],repetitions:1,maximumSpendUsd:t.maximumCostUsd},b,S=i(()=>{o.cancel(n)},"stop");s.signal.addEventListener("abort",S,{once:!0});try{if(r.operation==="prepare_run")return o.prepare(g);let c=await s.store.getModelRun(n);if(!c||c.evaluation?.benchmarkId!=="harness-refiner"||c.evaluation.advancedEvaluation?.contentHash!==t.contentHash)throw new Error("The original hosted advanced Run is unavailable.");if(r.operation==="read")return c;if(r.operation==="cancel")return o.cancel(n);if(m){let T=!1;b=setInterval(()=>{T||(T=!0,s.store.getModelRun(n).then(j=>j?m.checkpoint(j):void 0).catch(()=>S()).finally(()=>{T=!1}))},2e3)}r.operation==="start"?await o.start(g):await o.resume(n);let f=await o.wait(n);if(!f)throw new Error("The actual hosted advanced engine did not retain its Run.");let k=ge.parse(f);return m&&await m.checkpoint(k),k}finally{b&&clearInterval(b),s.signal.removeEventListener("abort",S),await o.close(),await y.close()}}i(Fe,"runHostedAdvancedRefinerOwner");import{promises as _}from"node:fs";import A from"node:path";var Ye=e.object({actor:e.object({actorId:e.string().min(1),teamId:e.string().min(1)}).strict(),storeDir:e.string().min(1),source:e.object({repoPath:e.string().min(1),repositoryId:e.string().min(1),profileId:e.string().min(1),sourceRevision:e.string().regex(/^[a-f0-9]{40,64}$/),filesHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),evidence:e.object({manifest:e.unknown(),result:e.unknown()}).strict(),operation:e.enum(["advanced","describe","command","queue","cancelQueued","bind","finish","beginTesting","cancelTesting","failTesting","comparison","beginAdoption","export","source","tool","toolCatalog"]),advanced:Z.optional(),command:se.optional(),candidateId:e.string().optional(),revision:e.number().int().positive().optional(),actualSession:C.optional(),actualTurn:$.optional(),recipe:e.unknown().optional(),baseline:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),candidate:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),humanProjection:oe.optional(),humanSelections:re.optional(),adoptionReadback:e.unknown().optional(),failure:e.object({message:e.string().max(2e3),cancelled:e.boolean()}).strict().optional(),tool:e.object({name:e.string(),args:e.record(e.string(),e.unknown()),callId:e.string()}).strict().optional(),agentRuntime:e.object({source:e.string(),cliRelativePath:e.string()}).strict().optional(),queued:e.object({sessionId:e.string(),turnId:e.string(),createdAt:e.string().datetime()}).strict().optional()}).strict();async function We(s,r=new AbortController().signal){r.throwIfAborted();let t=Ye.parse(s),{actor:n,source:d}=t;if(!A.isAbsolute(t.storeDir)||!A.isAbsolute(d.repoPath))throw new Error("Hosted candidate owner requires contained absolute private paths.");let m=M(t.evidence),u=[t.baseline,t.candidate].filter(l=>l!==void 0).map(l=>M(l));if(m.manifest.teamId!==n.teamId)throw new Error("Hosted candidate evidence belongs to another team.");if(await B(d.repoPath)!==d.filesHash)throw new Error("The admitted hosted Profile source bytes changed.");let v=`hosted-improve-source-${R([n,d.repositoryId,d.profileId,d.sourceRevision]).slice(0,40)}`,I=A.join(t.storeDir,"library","profile-experiment-origins",v);if(await _.mkdir(A.dirname(I),{recursive:!0,mode:448}),await _.stat(I).catch(()=>null)||await _.cp(d.repoPath,I,{recursive:!0,errorOnExist:!0,force:!1}),await B(I)!==d.filesHash)throw new Error("The private accepted Profile cache changed.");let x=await W(I,d.profileId);if(x.error||!x.sourcePath)throw new Error("The accepted hosted Profile does not compile.");let y=new xe(t.storeDir),h;try{let l=await y.getHarnessWorkspace(v);l||(l=(await le({store:y,storeDir:t.storeDir,id:v,ownerId:n.actorId,name:d.profileId,profile:x,sourceRevision:d.sourceRevision,repositoryId:d.repositoryId,selectionEligible:!1,originMetadata:{profileExperimentOrigin:{schemaVersion:"openpond.profileExperimentOrigin.v1",...n,sourceRevision:d.sourceRevision,sourcePath:I,sourceFilesHash:d.filesHash},hostedImprovementOwner:!0}})).workspace);let H={source:"openpond_git",repositoryId:d.repositoryId,profileId:d.profileId},E=i(async()=>{if(r.throwIfAborted(),await B(I)!==d.filesHash||await B(d.repoPath)!==d.filesHash)throw new Error("Accepted source changed during private candidate I/O.")},"authorizer");if(t.operation==="advanced"){if(!t.advanced)throw new Error("Missing actual hosted advanced owner command.");return Fe({store:y,storeDir:t.storeDir,actor:n,profile:x,workspace:l,source:d,evidence:m,request:t.advanced,authorize:E,signal:r})}let P=i(()=>{if(!t.adoptionReadback)throw new Error("Actual hosted Git owner has not returned its sealed adoption receipt.");return e.object({receipt:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),activeRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),testedCandidateRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),executableSourceHash:e.string().regex(/^[a-f0-9]{64}$/),protectedClosureHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().parse(t.adoptionReadback)},"readback");h=Ee({store:y,storeDir:t.storeDir,projectHumanComparison:i(async()=>{if(await E(),!t.humanProjection)throw new Error("The current private Human comparison owner is unavailable.");return ne(t.humanProjection)},"projectHumanComparison"),authorizeOwner:i(async(a,o,g,b,S)=>{if(R(a)!==R(n)||R(g)!==R(H)||o.id!==v)throw new Error("Hosted candidate source owner changed.");if(S.requireCurrentBase&&(o.currentChannel.release?.contentHash!==l.currentChannel.release?.contentHash||d.sourceRevision!==o.metadata.profileExperimentOrigin.sourceRevision))throw new Error("Hosted candidate accepted revision changed.");await E()},"authorizeOwner"),loadEvidence:i(async(a,o)=>{if(R(a)!==R(n))throw new Error("Hosted candidate evidence actor changed.");let g=[m,...u].find(b=>b.manifest.id===o.id&&b.result.contentHash===o.contentHash&&b.manifest.teamId===n.teamId);if(!g)throw new Error("Hosted candidate exact retained evidence changed.");return await E(),g},"loadEvidence"),freezeProfile:i(async(a,o,g)=>{let b=await y.getHarnessReleaseRecord(o.baseRelease.contentHash);if(!b)throw new Error("Hosted source baseline is missing.");let S=await D({workspaceId:typeof b.agentSnapshot.metadata.workspaceId=="string"?b.agentSnapshot.metadata.workspaceId:b.workspaceId,sourceDir:A.join(b.bundlePath,"source")}),c=await D({workspaceId:typeof g.release.agentSnapshot.metadata.workspaceId=="string"?g.release.agentSnapshot.metadata.workspaceId:g.release.workspaceId,sourceDir:A.join(g.release.bundlePath,"source")});return Ae({store:y,storeDir:t.storeDir,state:o},async f=>{await Ce({...f,state:o,base:S,candidate:c});let k=await W(f.root,o.profileRef.profileId),T=await U({storeDir:t.storeDir,state:o,profile:k,sourceRevision:g.profileSourceRevision,base:S}),j=z(T);if(j.protectedClosureHash!==z(S).protectedClosureHash)throw new Error("Hosted source candidate changed protected evaluation closure.");let O=A.join(t.storeDir,"library","profile-candidate-archives",o.id,j.contentHash);await _.mkdir(A.dirname(O),{recursive:!0,mode:448}),await _.stat(O).catch(()=>null)||await _.cp(f.root,O,{recursive:!0,errorOnExist:!0,force:!1});let L=await W(O,o.profileRef.profileId);if((await U({storeDir:t.storeDir,state:o,profile:L,sourceRevision:g.profileSourceRevision,base:S})).harnessRelease.contentHash!==T.harnessRelease.contentHash)throw new Error("Hosted frozen Profile archive readback differs.");let F=await ue({storeDir:t.storeDir,workspaceId:g.release.workspaceId,compiled:T,createdAt:g.release.createdAt});return await E(),{...g,release:F,executableIdentity:j}})},"freezeProfile"),adopt:i(async()=>P(),"adopt"),readAdoption:i(async()=>t.adoptionReadback?P():null,"readAdoption"),rollback:i(async()=>P(),"rollback")});let w=Pe({store:y,improvements:h,actorId:i(async()=>n.actorId,"actorId"),teamId:i(async()=>n.teamId,"teamId"),loadProfile:i(async a=>{if(R(a)!==R(H))throw new Error("Candidate requested another source owner.");return x},"loadProfile"),agentRuntime:t.agentRuntime,operationSignal:r,loadAgentRuntime:De({storeDir:t.storeDir,loadArchive:ze({storeDir:t.storeDir})})});if(t.operation==="describe"){await E();let a=l.currentChannel.release,o=a?await y.getHarnessReleaseRecord(a.contentHash):null;if(!a||!o||o.workspaceId!==l.id||o.harnessRelease.id!==a.id||o.harnessRelease.contentHash!==a.contentHash||l.ownerScope.kind!=="personal"||l.ownerScope.id!==n.actorId)throw new Error("Hosted source release is unavailable to its admitted owner.");let g=await D({workspaceId:typeof o.agentSnapshot.metadata.workspaceId=="string"?o.agentSnapshot.metadata.workspaceId:v,sourceDir:A.join(o.bundlePath,"source")});if(g.harnessRelease.contentHash!==o.harnessRelease.contentHash)throw new Error("Hosted source compiler readback changed.");let b=await pe({runtime:{release:o},ref:H,sourceRevision:d.sourceRevision,harnessRelease:a}),S=i(c=>{let f=g.sourceFiles.find(k=>k.path===c)?.bytes;return f?JSON.parse(Buffer.from(f).toString("utf8")):null},"readJson");return await E(),{workspaceId:v,ownerRevision:l.revision,profileRef:H,baseRelease:l.currentChannel.release,profileSourceRevision:d.sourceRevision,manifest:g.manifest,executable:z(g),catalogHash:b.catalogHash,workflows:S("workflows/catalog.json"),actions:S("workflows/actions.json")}}if(t.operation==="command"){let a=t.command;if(!a)throw new Error("Missing canonical Improve command.");if(a.operation==="start")return h.start(n,a.request);if(a.operation==="list")return h.list(n,a.limit,a.cursor);if(!("id"in a))throw new Error("Discover exact hosted source choices through the authenticated host.");let o=await h.read(n,a.id);if(a.operation==="read")return o;if(a.operation==="instructions"){let g=await h.partition(n,o.id),b=await ce(g.sourceRoot,o.component.path),S=await _.readFile(b);if(S.length>25e4)throw new Error("Instruction editor size limit exceeded.");let c=S.toString("utf8");if(o.component.kind==="workflow"){let f=JSON.parse(c).workflows?.find(k=>k.id===o.component.workflowId);if(f?.invocation?.kind!=="instructions")throw new Error("Use Work to author this executable Workflow.");c=f.invocation.instructions}return{candidateId:o.id,candidateRevision:o.revision,path:o.component.path,text:c,textHash:J(c),contentHash:J(S)}}if(a.operation==="humanComparisonOptions")throw new Error("Read the actual paired sources through their current hosted Experiment owner.");if(!("revision"in a)||o.revision!==a.revision)throw new Error("Candidate revision changed.");if(a.operation==="edit")return h.edit(n,o.id,o.revision,a.expectedFileHash,a.text);if(a.operation==="mode")return h.setMode(n,o.id,o.revision,a.mode);if(a.operation==="freeze")return h.freeze(n,o.id,o.revision);if(a.operation==="useCandidate")return h.useCandidate(n,o.id,o.revision);if(a.operation==="rollback")return h.rollback(n,o.id,o.revision);if(a.operation==="discard")return h.discard(n,o.id,o.revision);throw new Error("Hosted Work/test lifecycle requires the actual host turn/run admission.")}if(!t.candidateId)throw new Error("Missing actual hosted candidate ID.");let p=await h.read(n,t.candidateId);if(t.operation==="beginAdoption")return h.beginAdoption(n,p.id,t.revision);if(t.operation==="export")return je(y,p,"hosted_execution");if(t.operation==="source"){if(!p.frozen||p.status!=="frozen"&&p.status!=="testing"&&p.status!=="ready_for_review"&&p.status!=="adopting")throw new Error("Only the exact frozen source can enter hosted preparation.");let a=await y.getHarnessReleaseRecord(p.frozen.release.contentHash);if(!a||a.harnessRelease.id!==p.frozen.release.id)throw new Error("Frozen hosted source is unavailable.");let o=await D({workspaceId:typeof a.agentSnapshot.metadata.workspaceId=="string"?a.agentSnapshot.metadata.workspaceId:a.workspaceId,sourceDir:A.join(a.bundlePath,"source")}),g=z(o);if(o.harnessRelease.contentHash!==p.frozen.release.contentHash||g.contentHash!==p.frozen.executableSourceHash||g.protectedClosureHash!==p.frozen.protectedClosureHash)throw new Error("Frozen hosted executable changed.");let b=A.join(t.storeDir,"library","profile-candidate-archives",p.id,g.contentHash),S=await W(b,p.profileRef.profileId);if(S.error||!S.sourcePath)throw new Error("Frozen actual Profile archive is unavailable.");let c=await y.getHarnessReleaseRecord(p.baseRelease.contentHash);if(!c)throw new Error("Frozen baseline is unavailable.");let f=await D({workspaceId:typeof c.agentSnapshot.metadata.workspaceId=="string"?c.agentSnapshot.metadata.workspaceId:c.workspaceId,sourceDir:A.join(c.bundlePath,"source")}),k=await U({storeDir:t.storeDir,state:p,profile:S,sourceRevision:p.frozen.profileSourceRevision,base:f});if(k.harnessRelease.contentHash!==p.frozen.release.contentHash||z(k).contentHash!==g.contentHash)throw new Error("Actual frozen Profile archive differs from its compiled release.");return{state:p,profileSource:{repoPath:b,profileId:p.profileRef.profileId,sourceRevision:p.frozen.profileSourceRevision,repositoryId:p.profileRef.repositoryId,filesHash:await B(b)},sourcePackage:te({agentSnapshot:o.agentSnapshot,harnessRelease:o.harnessRelease,files:new Map(o.sourceFiles.map(T=>[T.path,T.bytes]))})}}if(t.operation==="comparison"){if(!t.baseline||!t.candidate)throw new Error("Missing actual hosted paired evidence.");return h.completeComparison(n,p.id,t.revision,M(t.baseline),M(t.candidate),t.humanSelections)}if(t.operation==="beginTesting")return h.beginTesting(n,p.id,t.revision,t.recipe);if(t.operation==="failTesting"){if(!t.failure)throw new Error("Missing actual hosted test failure.");return h.failTesting(n,p.id,t.revision,t.failure.message,t.failure.cancelled)}if(t.operation==="cancelTesting")return h.cancelTesting(n,p.id,t.revision);if(t.operation==="queue"){if(!t.queued)throw new Error("Missing actual hosted queue admission.");return h.queueAuthoringTurn(n,p.id,t.revision,t.queued.sessionId,t.queued.turnId,t.queued.createdAt)}if(t.operation==="cancelQueued")return h.cancelQueuedAuthoring(n,p.id,t.revision);if(t.operation==="bind"||t.operation==="finish"||t.operation==="tool"||t.operation==="toolCatalog"){if(!t.actualSession||!t.actualTurn||t.actualTurn.sessionId!==t.actualSession.id||t.actualSession.cloudTeamId!==n.teamId||R(t.actualSession.currentProfile)!==R(H))throw new Error("Actual hosted candidate Work binding changed.");let a=t.actualSession,o=t.actualTurn,g=await y.getSession(a.id);if(!g)await y.insertSessionAtFront(a);else if(R({...g,updatedAt:a.updatedAt,status:a.status})!==R(a))throw new Error("Retained hosted candidate session changed.");let b=await y.getTurn(o.id);if(!b)await y.insertTurn(o);else{if(b.sessionId!==o.sessionId||R(b.metadata.refinementCandidate)!==R(o.metadata.refinementCandidate)||b.prompt!==o.prompt)throw new Error("Actual hosted candidate turn identity changed.");await y.updateTurn(o.id,()=>o)}if(t.operation==="bind")return h.bindAuthoringTurn(n,p.id,t.revision,a.id,o.id);if(t.operation==="finish")return h.finishAuthoring(n,p.id,t.revision);if(t.operation==="toolCatalog")return await w.candidateAuthoringForTurn(a.id,o.id),[...G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}),...Te(async()=>{throw new Error("Hosted file tools require a bound private call.")}),{name:"exec_command",description:"Run a bounded command confined to the selected public candidate component.",parameters:{type:"object",additionalProperties:!1,properties:{command:{type:"string",minLength:1,maxLength:2e4},cwd:{type:"string"}},required:["command"]}},{name:"view_image",description:"Inspect an image inside the candidate public source tree.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string"}},required:["path"]}}].map(({name:c,description:f,parameters:k})=>({name:c,description:f,parameters:k}));if(!t.tool)throw new Error("Missing candidate tool call.");await w.authorizeCandidateTool({sessionId:a.id,turnId:o.id,name:t.tool.name});let S={session:a,turnId:o.id,args:t.tool.args,callId:t.tool.callId,signal:r,workspaceDiffBaseline:null,turnPermissions:{approvalPolicy:"never",sandbox:"workspace-write",codexPermissionMode:"default"},provider:a.provider,model:o.modelRef?.modelId??a.modelRef?.modelId??"",mentionedApps:[],userPrompt:o.prompt,turnMetadata:o.metadata};if(t.tool.name==="get_profile"||t.tool.name.startsWith("agent_")||t.tool.name==="ask_user"){let c=G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}).find(f=>f.name===t.tool.name);if(!c)throw new Error("Candidate authoring tool is unavailable.");return c.execute(S)}if(t.tool.name==="view_image")return w.executeCandidateImage(S);if(t.tool.name==="exec_command")return w.executeCandidateCommand(S,{session:a,turnId:o.id,command:e.string().min(1).max(2e4).parse(t.tool.args.command),cwd:typeof t.tool.args.cwd=="string"?t.tool.args.cwd:null,signal:S.signal,source:"model_tool"});if(["list_files","read_files","search_files","workspace_status","write_file","write_files","edit_file","delete_file"].includes(t.tool.name))return w.executeCandidateWorkspaceTool({session:a,turnId:o.id,request:fe.parse({action:t.tool.name,args:t.tool.args,source:"chat_action"})});throw new Error("This hosted tool has no confined candidate transport.")}throw new Error("Unknown private hosted Improve operation.")}finally{await h?.close(),await y.close()}}i(We,"runHostedExperimentImprovementOwner");async function wr(s){if(s.length!==1||s[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(s[0]))throw new Error("Hosted Improve IPC argument is invalid.");let r=e.object({directory:e.string(),file:e.string().regex(/^[A-Za-z0-9_-]+\.json$/)}).strict().parse(JSON.parse(Buffer.from(s[0],"base64url").toString("utf8")));if(!Ue.isAbsolute(r.directory))throw new Error("Hosted Improve IPC requires an absolute private directory.");let t=Ue.join(r.directory,r.file),n=await $e.lstat(t);if(!n.isFile()||n.isSymbolicLink()||n.size>32*1024*1024)throw new Error("Hosted Improve private request exceeds its byte/type limit.");let d=new AbortController,m=i(()=>d.abort(new Error("The actual hosted owner stopped this private operation.")),"stop");process.once("SIGTERM",m),process.once("SIGINT",m);try{let u=await We(JSON.parse(await $e.readFile(t,"utf8")),d.signal),v=Buffer.from(JSON.stringify(u));if(v.length>32*1024*1024)throw new Error("Hosted Improve private response exceeds its byte limit.");process.stdout.write(`${v.toString("utf8")}
2
+ import{a as Ie,b as ye,c as Re,d as He,e as Ee,f as Pe,h as B,i as Ae,j as je}from"./chunk-TJ6GVTYB.js";import{A as Se,s as be,t as ke}from"./chunk-NH6UUX5S.js";import"./chunk-HDGTHRY7.js";import{e as Ce,f as U}from"./chunk-HZEIRHEB.js";import{b as De,c as ze}from"./chunk-PF5R6CMP.js";import"./chunk-X4OSOOSU.js";import"./chunk-65PL62KH.js";import"./chunk-XVDFJ3ZF.js";import"./chunk-NC27T4AB.js";import"./chunk-YNH3NMPF.js";import"./chunk-HCYX6RHP.js";import{b as pe}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import{a as z}from"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as we,b as ve}from"./chunk-I3HZKJB3.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import{a as xe}from"./chunk-XX6SMFDY.js";import"./chunk-773TH7FN.js";import{g as Te,j as G}from"./chunk-RWWE5OXU.js";import"./chunk-RNQF63ZR.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import"./chunk-UKMA4R6X.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-7KWD2I6W.js";import"./chunk-OLLLZVHF.js";import"./chunk-7PXZ4X4P.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import"./chunk-KG325WTN.js";import"./chunk-TTVS6JMC.js";import"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{b as ce,i as le,m as D,n as ue}from"./chunk-QNG27G3T.js";import{y as W}from"./chunk-EIRYMSEG.js";import{a as me,r as fe,s as he}from"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import{p as C,q as $}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import{u as ge}from"./chunk-QOGJAQDO.js";import{g as se,l as V,n as de}from"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import{ia as ae,la as ie}from"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YR5ID2SS.js";import{c as re,d as oe,f as ne}from"./chunk-YBT2NB32.js";import{c as Y,g as ee}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import{f as X}from"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{Cb as M}from"./chunk-ACYFMLWG.js";import{r as te}from"./chunk-TVQAPBLZ.js";import{l as J,m as R}from"./chunk-KGNCKIFP.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{promises as $e}from"node:fs";import Ue from"node:path";import Le from"node:http";var Q=e.object({socketPath:e.string().min(1).max(1e3),capability:e.string().regex(/^[a-f0-9]{64}$/),jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),Ne=e.object({jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/),requestId:e.string().min(1).max(500),model:X,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max","none"]).nullable(),messages:e.array(e.unknown()).min(1).max(1e3),tools:e.array(e.unknown()).max(100),toolChoice:e.unknown(),maxOutputTokens:e.number().int().positive().max(131072),temperature:e.number().finite().optional(),topP:e.number().finite().optional(),seed:e.number().int().optional()}).strict(),Je=e.discriminatedUnion("kind",[e.object({kind:e.literal("chat_completions_reasoning"),reasoningContent:e.string()}).strict(),e.object({kind:e.literal("responses_reasoning_items"),items:e.array(e.record(e.string(),e.unknown()))}).strict()]),Ve=e.object({id:e.string().optional(),type:e.string(),function:e.object({name:e.string().optional(),arguments:e.string().optional()}).passthrough().optional()}).passthrough(),Ge=e.object({text:e.string().optional(),usage:e.unknown().optional(),costUsd:e.number().finite().nonnegative().optional(),continuation:Je.optional(),toolCalls:e.array(Ve).optional()}).strict();function qe(s,r){let t=Q.parse(s);async function n(u,v,I=r){I.throwIfAborted();let x=Buffer.from(JSON.stringify({action:u,jobId:t.jobId,pinHash:t.pinHash,value:v}));if(x.length>8*1024*1024)throw new Error("Hosted advanced request exceeds its private byte limit.");return new Promise((y,h)=>{let l=Le.request({socketPath:t.socketPath,path:"/",method:"POST",headers:{authorization:`Bearer ${t.capability}`,"content-type":"application/json","content-length":x.length},signal:I},H=>{let E=[],P=0;H.on("data",w=>{if(P+=w.length,P>8388608){H.destroy(new Error("Hosted advanced response exceeds its private byte limit."));return}E.push(w)}),H.on("error",h),H.on("end",()=>{try{let w=JSON.parse(Buffer.concat(E).toString("utf8"));if(H.statusCode!==200)throw new Error(typeof w?.error=="string"?w.error:"The actual hosted advanced owner refused this operation.");y(w)}catch(w){h(w)}})});l.on("error",h),l.end(x)})}i(n,"call");let d=i(async function*(u){let v=Ne.parse({jobId:t.jobId,pinHash:t.pinHash,requestId:u.requestId,model:u.model,reasoningEffort:u.reasoningEffort,messages:u.messages,tools:u.tools,toolChoice:u.toolChoice,maxOutputTokens:u.maxOutputTokens??4096,...u.temperature===void 0?{}:{temperature:u.temperature},...u.topP===void 0?{}:{topP:u.topP},...u.seed===void 0?{}:{seed:u.seed}}),I=e.object({deltas:e.array(Ge).max(1e5)}).strict().parse(await n("model",v,AbortSignal.any([r,u.signal])));for(let x of I.deltas)yield x},"stream");return{stream:d,text:i(async u=>{let v="";for await(let I of d({...u,reasoningEffort:u.reasoningEffort??null,tools:[],toolChoice:"none"}))I.text&&(v+=I.text),I.usage!==void 0&&u.onUsage?.(I.usage,I.costUsd);return v},"text"),authorize:i(async()=>{await n("authorize",{})},"authorize"),ceiling:i(async(u,v,I)=>e.object({configurationHash:e.string().regex(/^[a-f0-9]{64}$/),maximumChargeUsd:e.number().finite().positive()}).strict().parse(await n("ceiling",{modelId:u,pricing:v,maximumOutputTokens:I})),"ceiling"),compute:i((u,v=!1)=>n("compute",u,v?AbortSignal.timeout(6e4):r),"compute"),checkpoint:i(u=>n("checkpoint",u),"checkpoint")}}i(qe,"createHostedAdvancedModelBridge");import Qe from"node:path";var Me=e.string().regex(/^[a-f0-9]{64}$/),Ke=e.object({taskId:e.string().min(1),caseHash:Me,session:C,turn:$,events:e.array(me).max(1e4),traceHash:Me,output:e.string().nullable()}).strict(),K=e.object({packageValue:ae,contexts:e.array(Ke).max(1e4)}).strict();async function _e(s){let r=V(s.pin),t=K.parse(s.privateSource),n=ie(t.packageValue),d=M(e.object({manifest:e.unknown(),result:e.unknown()}).parse(s.evidence));async function m(){if(await s.authorize(),r.actorId!==s.actor.actorId||r.teamId!==s.actor.teamId||r.profileRef.source!=="openpond_git"||r.profileRef.repositoryId!==s.source.repositoryId||r.profileRef.profileId!==s.source.profileId||r.sourceRevision!==s.source.sourceRevision)throw new Error("The actual hosted advanced source owner changed.")}if(i(m,"authorize"),await m(),d.manifest.teamId!==r.teamId||d.result.status!=="completed"||d.manifest.id!==r.evidence.id||d.result.contentHash!==r.evidence.contentHash||R(d.manifest.dataset)!==R(r.externalDatasetBinding.dataset))throw new Error("The exact completed hosted advanced evidence changed.");if(n.contentHash!==r.externalDatasetBinding.packageHash||n.contentHash!==r.adaptationDatasetBinding.packageHash||n.environment.contentHash!==r.environmentPolicy.environmentHash||n.environment.contract.networkPolicy!=="none")throw new Error("The hosted advanced environment/package is not the exact reviewed closed-network release.");if(n.taskset.tools.some(l=>l.name==="web_search"||l.name==="web_fetch"))throw new Error("Live external tools require their own qualified frozen-observation and budget owner.");if(n.verifierSet.graders.some(l=>l.kind==="human"||l.kind==="model_judge"&&l.calibrationStatus!=="passed"))throw new Error("Advanced hosted evaluation needs executable, qualified independent graders.");let u=r.adaptationTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),v=r.holdoutTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),I=new Set(u.map(l=>l?.clusterKey));if(u.some(l=>!l||l.split!==r.adaptationSplit)||v.some(l=>!l||l.split!==r.holdoutSplit||I.has(l.clusterKey)))throw new Error("Hosted adaptation/holdout membership or independent families changed.");let x=await s.store.getHarnessReleaseRecord(r.baselineRelease.contentHash);if(!x||x.harnessRelease.id!==r.baselineRelease.id||s.workspace.currentChannel.release?.contentHash!==r.baselineRelease.contentHash)throw new Error("The exact hosted source baseline is unavailable.");let y=await D({workspaceId:typeof x.agentSnapshot.metadata.workspaceId=="string"?x.agentSnapshot.metadata.workspaceId:x.workspaceId,sourceDir:Qe.join(x.bundlePath,"source")});if(z(y).protectedClosureHash!==r.privateClosureHash)throw new Error("The protected hosted Profile closure changed.");let h={packageValue:n,authorize:m};return{read:i(async l=>{if(V(l).contentHash!==r.contentHash)throw new Error("The actual hosted advanced admission changed.");return await m(),h},"read"),evidence:i(async()=>(await m(),d),"evidence"),authorize:i(async()=>m(),"authorize"),reviewContext:i(async(l,H)=>{await m();let E=t.contexts.filter(p=>p.taskId===H),P=d.result.cases.find(p=>p.identity.caseId===H);if(E.length!==1||!P||P.status!=="completed")throw new Error("The actual retained hosted review case is unavailable.");let w=E[0];if(w.caseHash!==R(P)||w.session.cloudTeamId!==r.teamId||w.turn.sessionId!==w.session.id||w.turn.status==="in_progress"||w.events.some(p=>p.sessionId!==w.session.id||p.turnId!==w.turn.id))throw new Error("The actual hosted review session/turn/trace binding changed.");return await m(),{...w,case:{output:w.output}}},"reviewContext")}}i(_e,"createHostedAdvancedRefinerSource");import{randomUUID as Ze}from"node:crypto";function Oe(s){async function r(n){let d=await s.store.getSession(n);if(!d||d.cloudTeamId!==s.teamId||d.metadata?.hostedAdvancedTurnId!==s.hostedTurnId||d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The actual hosted advanced case owner changed.");return d}i(r,"read");async function t(n,d,m){let u=await r(n),v=e.object({action:e.string()}).passthrough().parse(d).action;return he.parse(await s.bridge.compute({session:u,payload:d,turnId:m??null},v==="sandbox_stop"||v==="sandbox_receipts"))}return i(t,"tool"),{createSession:i(async n=>{await s.bridge.authorize();let d=C.partial().parse(n),m=new Date().toISOString();if(d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The foreground case belongs to another actual advanced Run.");let u=C.parse({...d,id:`hosted-advanced-case-${Ze()}`,provider:"openpond",currentProfile:s.profileRef,cloudTeamId:s.teamId,cwd:null,codexThreadId:null,appId:null,appName:null,createdAt:m,updatedAt:m,status:"active",pinned:!1,archived:!1,order:0,hiddenFromDefaultSidebar:!0,title:d.title??"Advanced hosted evaluation case",metadata:{...d.metadata,source:"hosted-advanced-evaluation",hostedAdvancedTurnId:s.hostedTurnId,actorId:s.actorId,workspaceTarget:"hosted",benchmarkRuntime:"hosted_managed_work"}});return await s.store.insertSessionAtFront(u),await s.bridge.authorize(),u},"createSession"),getSession:r,runtimeEventsForSession:i(n=>s.store.runtimeEventsForSession(n),"runtimeEventsForSession"),executeWorkspaceTool:i((n,d,m)=>t(n,d,m?.turnId),"executeWorkspaceTool"),settleCostEvidence:i((n,d)=>t(n,{action:"sandbox_receipts",args:{}},d?.turnId),"settleCostEvidence")}}i(Oe,"createHostedAdvancedWorkRuntime");var Xe=e.string().regex(/^[a-f0-9]{64}$/),Be=e.object({version:e.string().min(1),source:e.string().min(1),effectiveAt:e.string().min(1),inputUsdPerMillionTokens:e.number().finite().nonnegative(),cachedInputUsdPerMillionTokens:e.number().finite().nonnegative(),outputUsdPerMillionTokens:e.number().finite().nonnegative()}).strict(),Z=e.object({operation:e.enum(["prepare_run","start","read","resume","cancel"]),request:de,configuration:e.object({id:e.string().min(1),profileId:e.string().min(1),etag:Xe}).strict(),refinerRelease:Y,privateSource:K,upstream:e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict(),judgeModels:e.array(e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict()).max(50),bridge:Q.optional(),hostedTurnId:e.string().min(1).optional()}).strict();async function Fe(s){let r=Z.parse(s.request),t=r.request.pin;if(r.request.model.providerId!=="openpond"||r.request.model.modelId!==r.upstream.modelId||r.configuration.id!==r.request.modelId||r.configuration.profileId!==t.profileRef.profileId||r.request.profileId!==t.profileRef.profileId||r.refinerRelease.id!==t.refinerRelease.id||r.refinerRelease.contentHash!==t.refinerRelease.contentHash)throw new Error("The actual hosted advanced configuration/model/Refiner admission changed.");let n=`advanced-refiner-${R([t.actorId,t.teamId,t.operationId,t.contentHash,r.request.model,[r.request.seed],1]).slice(0,40)}`;if((r.operation==="start"||r.operation==="resume")&&(!r.bridge||!r.hostedTurnId))throw new Error("The actual hosted advanced execution grant is unavailable.");let m=r.bridge?qe(r.bridge,s.signal):null;if(r.bridge&&(r.bridge.jobId!==n||r.bridge.pinHash!==t.contentHash))throw new Error("The hosted model bridge belongs to another actual Run.");let u=i(async()=>{s.signal.throwIfAborted(),await s.authorize(),m&&await m.authorize()},"authorize"),v=await _e({...s,pin:t,privateSource:r.privateSource,authorize:u}),I=we(ve(s.storeDir));await I.persistRelease(r.refinerRelease),await I.writeSource(ee(r.refinerRelease.profile)),I.binding()?.release.contentHash!==t.refinerRelease.contentHash&&await I.transition(r.refinerRelease,{operation:"activate",bindingChanged:!0,actor:s.actor.actorId,reason:"Pin the actual hosted evaluation fork to its admitted immutable Refiner release.",authoringSkillHash:null});let y=ke({storeDir:s.storeDir,authorize:i(async()=>u(),"authorize"),packageForPin:i(async()=>r.privateSource.packageValue,"packageForPin"),prepareModel:i(async(c,f,k)=>{if(!m)throw new Error("The actual hosted model ceiling owner is unavailable.");return m.ceiling(c,k,f)},"prepareModel")}),h=i(async function*(c){let f=be(),k=[r.upstream,...r.judgeModels].find(q=>q.modelId===c.model.modelId);if(!m||!f||!k)throw new Error("The actual hosted model and durable shared budget are unavailable.");let{signal:T,...j}=c,O=c.maxOutputTokens??4096,L=await f.call(c.requestId,j,k.pricing,O,async()=>{let q=[],F=null;for await(let N of m.stream({...c,signal:AbortSignal.any([T,f.signal])}))q.push(N),N.costUsd!==void 0&&(F=(F??0)+N.costUsd);return{value:q,costUsd:F}});for(let q of L)yield q},"stream"),l=i(async c=>{let f="";for await(let k of h({...c,reasoningEffort:c.reasoningEffort??null,tools:[],toolChoice:"none"}))k.text&&(f+=k.text),k.usage!==void 0&&c.onUsage?.(k.usage,k.costUsd);return f},"text"),H=Ie({store:s.store,storeDir:s.storeDir}),E=await H.projectSelected({profileId:t.profileRef.profileId,package:r.privateSource.packageValue,adaptationSplit:t.adaptationSplit,holdoutSplit:t.holdoutSplit}),P=i(async c=>{let f=C.partial().parse(c),k=new Date().toISOString(),T=C.parse({...f,id:`hosted-review-${R([n,f.metadata]).slice(0,40)}`,cloudTeamId:t.teamId,currentProfile:t.profileRef,appId:null,appName:null,cwd:null,codexThreadId:null,title:f.title??"Hosted Refiner review",provider:"openpond",createdAt:k,updatedAt:k,status:"active",pinned:!1,archived:!1,order:0,metadata:{...f.metadata,hostedAdvancedTurnId:r.hostedTurnId??null,actorId:t.actorId,source:"hosted-advanced-evaluation"}});return await s.store.insertSessionAtFront(T),T},"createSession"),w=m&&r.hostedTurnId?Oe({store:s.store,bridge:m,teamId:t.teamId,actorId:t.actorId,hostedTurnId:r.hostedTurnId,modelRunId:n,profileRef:t.profileRef}):void 0,p=Se({store:s.store,storeDir:s.storeDir,modelJudge:ye({store:s.store,modelText:l}),modelText:l,modelStream:h,workRuntime:w,resolveTasksetRelease:i(c=>H.releaseForTaskset(c),"resolveTasksetRelease")}),a={store:s.store,storeDir:s.storeDir,evaluation:p,benchmarkTasksets:H,loadProfileState:i(async()=>s.profile,"loadProfileState"),resolveEvaluationProject:i(async(c,f)=>{if(await u(),c!==r.configuration.id||f!==r.configuration.profileId)throw new Error("The actual hosted evaluation configuration changed.");return{id:c,profileId:f}},"resolveEvaluationProject"),resolveUpstreamModel:i(async()=>({providerId:"openpond",modelId:r.upstream.modelId,revision:r.upstream.revision,pricing:r.upstream.pricing}),"resolveUpstreamModel"),advancedBoundary:y,refinerStream:i(async function*(c){if(!c.requestId)throw new Error("A hosted Refiner call needs its actual retained ID.");yield*h({model:c.model,reasoningEffort:"low",messages:c.messages,tools:[],toolChoice:"none",requestId:c.requestId,maxOutputTokens:4096,signal:c.signal,hostedTokenPricing:c.pricing})},"refinerStream")},o=Re({...a,reviewQuality:He({source:v,boundary:y,benchmark:a,createSession:P})}),g={advancedEvaluation:t,selectedTaskset:{id:E.id,revision:E.revision,contentHash:E.contentHash},modelId:r.request.modelId,profileId:r.request.profileId,model:r.request.model,reasoningEffort:r.request.reasoningEffort,seeds:[r.request.seed],repetitions:1,maximumSpendUsd:t.maximumCostUsd},b,S=i(()=>{o.cancel(n)},"stop");s.signal.addEventListener("abort",S,{once:!0});try{if(r.operation==="prepare_run")return o.prepare(g);let c=await s.store.getModelRun(n);if(!c||c.evaluation?.benchmarkId!=="harness-refiner"||c.evaluation.advancedEvaluation?.contentHash!==t.contentHash)throw new Error("The original hosted advanced Run is unavailable.");if(r.operation==="read")return c;if(r.operation==="cancel")return o.cancel(n);if(m){let T=!1;b=setInterval(()=>{T||(T=!0,s.store.getModelRun(n).then(j=>j?m.checkpoint(j):void 0).catch(()=>S()).finally(()=>{T=!1}))},2e3)}r.operation==="start"?await o.start(g):await o.resume(n);let f=await o.wait(n);if(!f)throw new Error("The actual hosted advanced engine did not retain its Run.");let k=ge.parse(f);return m&&await m.checkpoint(k),k}finally{b&&clearInterval(b),s.signal.removeEventListener("abort",S),await o.close(),await y.close()}}i(Fe,"runHostedAdvancedRefinerOwner");import{promises as _}from"node:fs";import A from"node:path";var Ye=e.object({actor:e.object({actorId:e.string().min(1),teamId:e.string().min(1)}).strict(),storeDir:e.string().min(1),source:e.object({repoPath:e.string().min(1),repositoryId:e.string().min(1),profileId:e.string().min(1),sourceRevision:e.string().regex(/^[a-f0-9]{40,64}$/),filesHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),evidence:e.object({manifest:e.unknown(),result:e.unknown()}).strict(),operation:e.enum(["advanced","describe","command","queue","cancelQueued","bind","finish","beginTesting","cancelTesting","failTesting","comparison","beginAdoption","export","source","tool","toolCatalog"]),advanced:Z.optional(),command:se.optional(),candidateId:e.string().optional(),revision:e.number().int().positive().optional(),actualSession:C.optional(),actualTurn:$.optional(),recipe:e.unknown().optional(),baseline:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),candidate:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),humanProjection:oe.optional(),humanSelections:re.optional(),adoptionReadback:e.unknown().optional(),failure:e.object({message:e.string().max(2e3),cancelled:e.boolean()}).strict().optional(),tool:e.object({name:e.string(),args:e.record(e.string(),e.unknown()),callId:e.string()}).strict().optional(),agentRuntime:e.object({source:e.string(),cliRelativePath:e.string()}).strict().optional(),queued:e.object({sessionId:e.string(),turnId:e.string(),createdAt:e.string().datetime()}).strict().optional()}).strict();async function We(s,r=new AbortController().signal){r.throwIfAborted();let t=Ye.parse(s),{actor:n,source:d}=t;if(!A.isAbsolute(t.storeDir)||!A.isAbsolute(d.repoPath))throw new Error("Hosted candidate owner requires contained absolute private paths.");let m=M(t.evidence),u=[t.baseline,t.candidate].filter(l=>l!==void 0).map(l=>M(l));if(m.manifest.teamId!==n.teamId)throw new Error("Hosted candidate evidence belongs to another team.");if(await B(d.repoPath)!==d.filesHash)throw new Error("The admitted hosted Profile source bytes changed.");let v=`hosted-improve-source-${R([n,d.repositoryId,d.profileId,d.sourceRevision]).slice(0,40)}`,I=A.join(t.storeDir,"library","profile-experiment-origins",v);if(await _.mkdir(A.dirname(I),{recursive:!0,mode:448}),await _.stat(I).catch(()=>null)||await _.cp(d.repoPath,I,{recursive:!0,errorOnExist:!0,force:!1}),await B(I)!==d.filesHash)throw new Error("The private accepted Profile cache changed.");let x=await W(I,d.profileId);if(x.error||!x.sourcePath)throw new Error("The accepted hosted Profile does not compile.");let y=new xe(t.storeDir),h;try{let l=await y.getHarnessWorkspace(v);l||(l=(await le({store:y,storeDir:t.storeDir,id:v,ownerId:n.actorId,name:d.profileId,profile:x,sourceRevision:d.sourceRevision,repositoryId:d.repositoryId,selectionEligible:!1,originMetadata:{profileExperimentOrigin:{schemaVersion:"openpond.profileExperimentOrigin.v1",...n,sourceRevision:d.sourceRevision,sourcePath:I,sourceFilesHash:d.filesHash},hostedImprovementOwner:!0}})).workspace);let H={source:"openpond_git",repositoryId:d.repositoryId,profileId:d.profileId},E=i(async()=>{if(r.throwIfAborted(),await B(I)!==d.filesHash||await B(d.repoPath)!==d.filesHash)throw new Error("Accepted source changed during private candidate I/O.")},"authorizer");if(t.operation==="advanced"){if(!t.advanced)throw new Error("Missing actual hosted advanced owner command.");return Fe({store:y,storeDir:t.storeDir,actor:n,profile:x,workspace:l,source:d,evidence:m,request:t.advanced,authorize:E,signal:r})}let P=i(()=>{if(!t.adoptionReadback)throw new Error("Actual hosted Git owner has not returned its sealed adoption receipt.");return e.object({receipt:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),activeRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),testedCandidateRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),executableSourceHash:e.string().regex(/^[a-f0-9]{64}$/),protectedClosureHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().parse(t.adoptionReadback)},"readback");h=Ee({store:y,storeDir:t.storeDir,projectHumanComparison:i(async()=>{if(await E(),!t.humanProjection)throw new Error("The current private Human comparison owner is unavailable.");return ne(t.humanProjection)},"projectHumanComparison"),authorizeOwner:i(async(a,o,g,b,S)=>{if(R(a)!==R(n)||R(g)!==R(H)||o.id!==v)throw new Error("Hosted candidate source owner changed.");if(S.requireCurrentBase&&(o.currentChannel.release?.contentHash!==l.currentChannel.release?.contentHash||d.sourceRevision!==o.metadata.profileExperimentOrigin.sourceRevision))throw new Error("Hosted candidate accepted revision changed.");await E()},"authorizeOwner"),loadEvidence:i(async(a,o)=>{if(R(a)!==R(n))throw new Error("Hosted candidate evidence actor changed.");let g=[m,...u].find(b=>b.manifest.id===o.id&&b.result.contentHash===o.contentHash&&b.manifest.teamId===n.teamId);if(!g)throw new Error("Hosted candidate exact retained evidence changed.");return await E(),g},"loadEvidence"),freezeProfile:i(async(a,o,g)=>{let b=await y.getHarnessReleaseRecord(o.baseRelease.contentHash);if(!b)throw new Error("Hosted source baseline is missing.");let S=await D({workspaceId:typeof b.agentSnapshot.metadata.workspaceId=="string"?b.agentSnapshot.metadata.workspaceId:b.workspaceId,sourceDir:A.join(b.bundlePath,"source")}),c=await D({workspaceId:typeof g.release.agentSnapshot.metadata.workspaceId=="string"?g.release.agentSnapshot.metadata.workspaceId:g.release.workspaceId,sourceDir:A.join(g.release.bundlePath,"source")});return Ae({store:y,storeDir:t.storeDir,state:o},async f=>{await Ce({...f,state:o,base:S,candidate:c});let k=await W(f.root,o.profileRef.profileId),T=await U({storeDir:t.storeDir,state:o,profile:k,sourceRevision:g.profileSourceRevision,base:S}),j=z(T);if(j.protectedClosureHash!==z(S).protectedClosureHash)throw new Error("Hosted source candidate changed protected evaluation closure.");let O=A.join(t.storeDir,"library","profile-candidate-archives",o.id,j.contentHash);await _.mkdir(A.dirname(O),{recursive:!0,mode:448}),await _.stat(O).catch(()=>null)||await _.cp(f.root,O,{recursive:!0,errorOnExist:!0,force:!1});let L=await W(O,o.profileRef.profileId);if((await U({storeDir:t.storeDir,state:o,profile:L,sourceRevision:g.profileSourceRevision,base:S})).harnessRelease.contentHash!==T.harnessRelease.contentHash)throw new Error("Hosted frozen Profile archive readback differs.");let F=await ue({storeDir:t.storeDir,workspaceId:g.release.workspaceId,compiled:T,createdAt:g.release.createdAt});return await E(),{...g,release:F,executableIdentity:j}})},"freezeProfile"),adopt:i(async()=>P(),"adopt"),readAdoption:i(async()=>t.adoptionReadback?P():null,"readAdoption"),rollback:i(async()=>P(),"rollback")});let w=Pe({store:y,improvements:h,actorId:i(async()=>n.actorId,"actorId"),teamId:i(async()=>n.teamId,"teamId"),loadProfile:i(async a=>{if(R(a)!==R(H))throw new Error("Candidate requested another source owner.");return x},"loadProfile"),agentRuntime:t.agentRuntime,operationSignal:r,loadAgentRuntime:De({storeDir:t.storeDir,loadArchive:ze({storeDir:t.storeDir})})});if(t.operation==="describe"){await E();let a=l.currentChannel.release,o=a?await y.getHarnessReleaseRecord(a.contentHash):null;if(!a||!o||o.workspaceId!==l.id||o.harnessRelease.id!==a.id||o.harnessRelease.contentHash!==a.contentHash||l.ownerScope.kind!=="personal"||l.ownerScope.id!==n.actorId)throw new Error("Hosted source release is unavailable to its admitted owner.");let g=await D({workspaceId:typeof o.agentSnapshot.metadata.workspaceId=="string"?o.agentSnapshot.metadata.workspaceId:v,sourceDir:A.join(o.bundlePath,"source")});if(g.harnessRelease.contentHash!==o.harnessRelease.contentHash)throw new Error("Hosted source compiler readback changed.");let b=await pe({runtime:{release:o},ref:H,sourceRevision:d.sourceRevision,harnessRelease:a}),S=i(c=>{let f=g.sourceFiles.find(k=>k.path===c)?.bytes;return f?JSON.parse(Buffer.from(f).toString("utf8")):null},"readJson");return await E(),{workspaceId:v,ownerRevision:l.revision,profileRef:H,baseRelease:l.currentChannel.release,profileSourceRevision:d.sourceRevision,manifest:g.manifest,executable:z(g),catalogHash:b.catalogHash,workflows:S("workflows/catalog.json"),actions:S("workflows/actions.json")}}if(t.operation==="command"){let a=t.command;if(!a)throw new Error("Missing canonical Improve command.");if(a.operation==="start")return h.start(n,a.request);if(a.operation==="list")return h.list(n,a.limit,a.cursor);if(!("id"in a))throw new Error("Discover exact hosted source choices through the authenticated host.");let o=await h.read(n,a.id);if(a.operation==="read")return o;if(a.operation==="instructions"){let g=await h.partition(n,o.id),b=await ce(g.sourceRoot,o.component.path),S=await _.readFile(b);if(S.length>25e4)throw new Error("Instruction editor size limit exceeded.");let c=S.toString("utf8");if(o.component.kind==="workflow"){let f=JSON.parse(c).workflows?.find(k=>k.id===o.component.workflowId);if(f?.invocation?.kind!=="instructions")throw new Error("Use Work to author this executable Workflow.");c=f.invocation.instructions}return{candidateId:o.id,candidateRevision:o.revision,path:o.component.path,text:c,textHash:J(c),contentHash:J(S)}}if(a.operation==="humanComparisonOptions")throw new Error("Read the actual paired sources through their current hosted Experiment owner.");if(!("revision"in a)||o.revision!==a.revision)throw new Error("Candidate revision changed.");if(a.operation==="edit")return h.edit(n,o.id,o.revision,a.expectedFileHash,a.text);if(a.operation==="mode")return h.setMode(n,o.id,o.revision,a.mode);if(a.operation==="freeze")return h.freeze(n,o.id,o.revision);if(a.operation==="useCandidate")return h.useCandidate(n,o.id,o.revision);if(a.operation==="rollback")return h.rollback(n,o.id,o.revision);if(a.operation==="discard")return h.discard(n,o.id,o.revision);throw new Error("Hosted Work/test lifecycle requires the actual host turn/run admission.")}if(!t.candidateId)throw new Error("Missing actual hosted candidate ID.");let p=await h.read(n,t.candidateId);if(t.operation==="beginAdoption")return h.beginAdoption(n,p.id,t.revision);if(t.operation==="export")return je(y,p,"hosted_execution");if(t.operation==="source"){if(!p.frozen||p.status!=="frozen"&&p.status!=="testing"&&p.status!=="ready_for_review"&&p.status!=="adopting")throw new Error("Only the exact frozen source can enter hosted preparation.");let a=await y.getHarnessReleaseRecord(p.frozen.release.contentHash);if(!a||a.harnessRelease.id!==p.frozen.release.id)throw new Error("Frozen hosted source is unavailable.");let o=await D({workspaceId:typeof a.agentSnapshot.metadata.workspaceId=="string"?a.agentSnapshot.metadata.workspaceId:a.workspaceId,sourceDir:A.join(a.bundlePath,"source")}),g=z(o);if(o.harnessRelease.contentHash!==p.frozen.release.contentHash||g.contentHash!==p.frozen.executableSourceHash||g.protectedClosureHash!==p.frozen.protectedClosureHash)throw new Error("Frozen hosted executable changed.");let b=A.join(t.storeDir,"library","profile-candidate-archives",p.id,g.contentHash),S=await W(b,p.profileRef.profileId);if(S.error||!S.sourcePath)throw new Error("Frozen actual Profile archive is unavailable.");let c=await y.getHarnessReleaseRecord(p.baseRelease.contentHash);if(!c)throw new Error("Frozen baseline is unavailable.");let f=await D({workspaceId:typeof c.agentSnapshot.metadata.workspaceId=="string"?c.agentSnapshot.metadata.workspaceId:c.workspaceId,sourceDir:A.join(c.bundlePath,"source")}),k=await U({storeDir:t.storeDir,state:p,profile:S,sourceRevision:p.frozen.profileSourceRevision,base:f});if(k.harnessRelease.contentHash!==p.frozen.release.contentHash||z(k).contentHash!==g.contentHash)throw new Error("Actual frozen Profile archive differs from its compiled release.");return{state:p,profileSource:{repoPath:b,profileId:p.profileRef.profileId,sourceRevision:p.frozen.profileSourceRevision,repositoryId:p.profileRef.repositoryId,filesHash:await B(b)},sourcePackage:te({agentSnapshot:o.agentSnapshot,harnessRelease:o.harnessRelease,files:new Map(o.sourceFiles.map(T=>[T.path,T.bytes]))})}}if(t.operation==="comparison"){if(!t.baseline||!t.candidate)throw new Error("Missing actual hosted paired evidence.");return h.completeComparison(n,p.id,t.revision,M(t.baseline),M(t.candidate),t.humanSelections)}if(t.operation==="beginTesting")return h.beginTesting(n,p.id,t.revision,t.recipe);if(t.operation==="failTesting"){if(!t.failure)throw new Error("Missing actual hosted test failure.");return h.failTesting(n,p.id,t.revision,t.failure.message,t.failure.cancelled)}if(t.operation==="cancelTesting")return h.cancelTesting(n,p.id,t.revision);if(t.operation==="queue"){if(!t.queued)throw new Error("Missing actual hosted queue admission.");return h.queueAuthoringTurn(n,p.id,t.revision,t.queued.sessionId,t.queued.turnId,t.queued.createdAt)}if(t.operation==="cancelQueued")return h.cancelQueuedAuthoring(n,p.id,t.revision);if(t.operation==="bind"||t.operation==="finish"||t.operation==="tool"||t.operation==="toolCatalog"){if(!t.actualSession||!t.actualTurn||t.actualTurn.sessionId!==t.actualSession.id||t.actualSession.cloudTeamId!==n.teamId||R(t.actualSession.currentProfile)!==R(H))throw new Error("Actual hosted candidate Work binding changed.");let a=t.actualSession,o=t.actualTurn,g=await y.getSession(a.id);if(!g)await y.insertSessionAtFront(a);else if(R({...g,updatedAt:a.updatedAt,status:a.status})!==R(a))throw new Error("Retained hosted candidate session changed.");let b=await y.getTurn(o.id);if(!b)await y.insertTurn(o);else{if(b.sessionId!==o.sessionId||R(b.metadata.refinementCandidate)!==R(o.metadata.refinementCandidate)||b.prompt!==o.prompt)throw new Error("Actual hosted candidate turn identity changed.");await y.updateTurn(o.id,()=>o)}if(t.operation==="bind")return h.bindAuthoringTurn(n,p.id,t.revision,a.id,o.id);if(t.operation==="finish")return h.finishAuthoring(n,p.id,t.revision);if(t.operation==="toolCatalog")return await w.candidateAuthoringForTurn(a.id,o.id),[...G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}),...Te(async()=>{throw new Error("Hosted file tools require a bound private call.")}),{name:"exec_command",description:"Run a bounded command confined to the selected public candidate component.",parameters:{type:"object",additionalProperties:!1,properties:{command:{type:"string",minLength:1,maxLength:2e4},cwd:{type:"string"}},required:["command"]}},{name:"view_image",description:"Inspect an image inside the candidate public source tree.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string"}},required:["path"]}}].map(({name:c,description:f,parameters:k})=>({name:c,description:f,parameters:k}));if(!t.tool)throw new Error("Missing candidate tool call.");await w.authorizeCandidateTool({sessionId:a.id,turnId:o.id,name:t.tool.name});let S={session:a,turnId:o.id,args:t.tool.args,callId:t.tool.callId,signal:r,workspaceDiffBaseline:null,turnPermissions:{approvalPolicy:"never",sandbox:"workspace-write",codexPermissionMode:"default"},provider:a.provider,model:o.modelRef?.modelId??a.modelRef?.modelId??"",mentionedApps:[],userPrompt:o.prompt,turnMetadata:o.metadata};if(t.tool.name==="get_profile"||t.tool.name.startsWith("agent_")||t.tool.name==="ask_user"){let c=G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}).find(f=>f.name===t.tool.name);if(!c)throw new Error("Candidate authoring tool is unavailable.");return c.execute(S)}if(t.tool.name==="view_image")return w.executeCandidateImage(S);if(t.tool.name==="exec_command")return w.executeCandidateCommand(S,{session:a,turnId:o.id,command:e.string().min(1).max(2e4).parse(t.tool.args.command),cwd:typeof t.tool.args.cwd=="string"?t.tool.args.cwd:null,signal:S.signal,source:"model_tool"});if(["list_files","read_files","search_files","workspace_status","write_file","write_files","edit_file","delete_file"].includes(t.tool.name))return w.executeCandidateWorkspaceTool({session:a,turnId:o.id,request:fe.parse({action:t.tool.name,args:t.tool.args,source:"chat_action"})});throw new Error("This hosted tool has no confined candidate transport.")}throw new Error("Unknown private hosted Improve operation.")}finally{await h?.close(),await y.close()}}i(We,"runHostedExperimentImprovementOwner");async function wr(s){if(s.length!==1||s[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(s[0]))throw new Error("Hosted Improve IPC argument is invalid.");let r=e.object({directory:e.string(),file:e.string().regex(/^[A-Za-z0-9_-]+\.json$/)}).strict().parse(JSON.parse(Buffer.from(s[0],"base64url").toString("utf8")));if(!Ue.isAbsolute(r.directory))throw new Error("Hosted Improve IPC requires an absolute private directory.");let t=Ue.join(r.directory,r.file),n=await $e.lstat(t);if(!n.isFile()||n.isSymbolicLink()||n.size>32*1024*1024)throw new Error("Hosted Improve private request exceeds its byte/type limit.");let d=new AbortController,m=i(()=>d.abort(new Error("The actual hosted owner stopped this private operation.")),"stop");process.once("SIGTERM",m),process.once("SIGINT",m);try{let u=await We(JSON.parse(await $e.readFile(t,"utf8")),d.signal),v=Buffer.from(JSON.stringify(u));if(v.length>32*1024*1024)throw new Error("Hosted Improve private response exceeds its byte limit.");process.stdout.write(`${v.toString("utf8")}
3
3
  `)}finally{process.removeListener("SIGTERM",m),process.removeListener("SIGINT",m)}}i(wr,"runHostedExperimentImprovementCli");export{wr as runHostedExperimentImprovementCli};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{b as a,c as b}from"./chunk-JYKRR7E5.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import"./chunk-VRIEKBBH.js";import"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as loadHostedHarnessRuntime,b as loadHostedHarnessRuntimeForSession};
2
+ import{b as a,c as b}from"./chunk-JYKRR7E5.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import"./chunk-VRIEKBBH.js";import"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as loadHostedHarnessRuntime,b as loadHostedHarnessRuntimeForSession};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a,e as F}from"./chunk-HZEIRHEB.js";import{a as h}from"./chunk-OSIO7PLX.js";import{a as O}from"./chunk-HIOKCIL7.js";import{j as I,m as D,n as M}from"./chunk-QNG27G3T.js";import{z as w}from"./chunk-EIRYMSEG.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import{a as A}from"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import{u as R}from"./chunk-TVQAPBLZ.js";import{k as C,l as v}from"./chunk-KGNCKIFP.js";import{b as c}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as f}from"./chunk-FTQLQJQV.js";import{promises as m}from"node:fs";import n from"node:path";var $=c.object({action:c.enum(["stage","readback","rollback"]),repoPath:c.string(),outputDir:c.string(),exportFile:c.string(),commit:c.string().regex(/^[a-f0-9]{40}$/).optional(),expectedExecutableSourceHash:c.string().regex(/^[a-f0-9]{64}$/).optional()}).strict();async function z(l){let e=$.parse(l);if(!n.isAbsolute(e.repoPath)||!n.isAbsolute(e.outputDir)||!/^[a-zA-Z0-9_-]+\.json$/.test(e.exportFile))throw new Error("Hosted candidate private IPC is not contained.");let g=n.join(e.outputDir,e.exportFile),H=await m.lstat(g);if(!H.isFile()||H.isSymbolicLink()||H.size>8*1024*1024)throw new Error("Hosted candidate export exceeds its private IPC bound.");let t=O(JSON.parse(await m.readFile(g,"utf8"))),u=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId});if(u.error||!u.sourcePath)throw new Error("Actual hosted Profile source is unavailable.");if(e.action!=="readback"){let o=!1;try{await a(e.repoPath,["symbolic-ref","-q","HEAD"]),o=!0}catch{}if(o||await a(e.repoPath,["rev-parse","HEAD"])!==(e.action==="rollback"?e.commit:t.expectedCommit)||await a(e.repoPath,["status","--porcelain","--untracked-files=all"]))throw new Error("Candidate staging requires a clean detached exact original source worktree.")}let x=f(async o=>I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),sourceRevision:o,repositoryId:t.compiler.repositoryId}),"compile");if(e.action==="readback"){if(!e.commit||await a(e.repoPath,["rev-parse","HEAD"])!==e.commit)throw new Error("Hosted Profile readback is not the committed source.");let o=await x(e.commit),i=h(o);if(i.profileGitHead!==e.commit||i.contentHash!==(e.expectedExecutableSourceHash??t.executableSourceHash)||i.protectedClosureHash!==t.protectedClosureHash)throw new Error("Hosted active executable differs from the actual tested candidate.");let s=await M({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,compiled:o,createdAt:t.createdAt});return{commit:e.commit,activeRelease:{id:s.harnessRelease.id,contentHash:s.harnessRelease.contentHash},executableSourceHash:i.contentHash,protectedClosureHash:i.protectedClosureHash}}if(e.action==="rollback"){if(!e.commit)throw new Error("Rollback requires the exact accepted commit.");await a(e.repoPath,["-c","core.hooksPath=/dev/null","revert","--no-commit",e.commit])}let p=await x(t.expectedCommit);if(p.harnessRelease.contentHash!==t.baseRelease.contentHash||p.harnessRelease.id!==t.baseRelease.id)throw new Error("Hosted original source differs from the owner-attested baseline release.");if(e.action==="stage"){let o=Buffer.from(t.sourceManifest.base64,"base64");if(o.toString("base64")!==t.sourceManifest.base64||o.length!==t.sourceManifest.sizeBytes||v(o)!==t.sourceManifest.contentHash)throw new Error("Candidate source manifest byte identity differs.");let i=A.parse(JSON.parse(o.toString("utf8"))),s=n.join(e.outputDir,"candidate-source");await m.mkdir(s,{recursive:!0}),await m.writeFile(n.join(s,"harness.json"),C(i));let _=R(t.policySource),j=new Map(p.sourceFiles.filter(r=>r.asset.visibility!=="policy").map(r=>[r.path,r]));for(let r of i.files){let k=r.visibility==="policy"?_.get(r.path):j.get(r.path)?.bytes;if(!k)throw new Error("The hosted source cannot hydrate the exact protected candidate closure.");let y=n.join(s,r.path);if(n.relative(s,y).startsWith(".."))throw new Error("Candidate release path escapes private staging.");await m.mkdir(n.dirname(y),{recursive:!0}),await m.writeFile(y,k)}let P=await D({workspaceId:t.compiler.workspaceId,sourceDir:s}),S=h(P);if(P.harnessRelease.contentHash!==t.policySource.harnessRelease.contentHash||S.contentHash!==t.executableSourceHash||S.protectedClosureHash!==t.protectedClosureHash)throw new Error("Owner-attested candidate differs from independently compiled hosted source.");await F({source:u.sourcePath,state:{component:t.component},base:p,candidate:P,profile:u})}await a(e.repoPath,["add","--all"]),await a(e.repoPath,["-c","core.hooksPath=/dev/null","-c","commit.gpgSign=false","commit","-m",`${e.action==="rollback"?"Roll back":"Adopt"} owner-tested candidate ${t.candidateId}`],{GIT_AUTHOR_NAME:"OpenPond",GIT_AUTHOR_EMAIL:"profile-candidate@openpond.local",GIT_COMMITTER_NAME:"OpenPond",GIT_COMMITTER_EMAIL:"profile-candidate@openpond.local"});let E=await a(e.repoPath,["rev-parse","HEAD"]),T=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),b=await I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:T,sourceRevision:E,repositoryId:t.compiler.repositoryId}),d=h(b);if(e.action==="stage"&&(d.contentHash!==t.executableSourceHash||d.protectedClosureHash!==t.protectedClosureHash)||e.action==="rollback"&&(d.contentHash!==h(p).contentHash||d.protectedClosureHash!==h(p).protectedClosureHash))throw new Error("Staged actual source differs from its exact tested executable graph.");return{commit:E,activeRelease:{id:b.harnessRelease.id,contentHash:b.harnessRelease.contentHash},executableSourceHash:d.contentHash,protectedClosureHash:d.protectedClosureHash}}f(z,"hostedProfileCandidate");async function Q(l){if(l.length!==1||l[0].length>16e3||!/^[a-zA-Z0-9_-]+$/.test(l[0]))throw new Error("Hosted candidate IPC argument is invalid.");process.stdout.write(`${JSON.stringify(await z(JSON.parse(Buffer.from(l[0],"base64url").toString("utf8"))))}
2
+ import{a,e as F}from"./chunk-HZEIRHEB.js";import{a as h}from"./chunk-OSIO7PLX.js";import{a as O}from"./chunk-HIOKCIL7.js";import{j as I,m as D,n as M}from"./chunk-QNG27G3T.js";import{z as w}from"./chunk-EIRYMSEG.js";import"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import{a as A}from"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import{u as R}from"./chunk-TVQAPBLZ.js";import{k as C,l as v}from"./chunk-KGNCKIFP.js";import{b as c}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as f}from"./chunk-FTQLQJQV.js";import{promises as m}from"node:fs";import n from"node:path";var $=c.object({action:c.enum(["stage","readback","rollback"]),repoPath:c.string(),outputDir:c.string(),exportFile:c.string(),commit:c.string().regex(/^[a-f0-9]{40}$/).optional(),expectedExecutableSourceHash:c.string().regex(/^[a-f0-9]{64}$/).optional()}).strict();async function z(l){let e=$.parse(l);if(!n.isAbsolute(e.repoPath)||!n.isAbsolute(e.outputDir)||!/^[a-zA-Z0-9_-]+\.json$/.test(e.exportFile))throw new Error("Hosted candidate private IPC is not contained.");let g=n.join(e.outputDir,e.exportFile),H=await m.lstat(g);if(!H.isFile()||H.isSymbolicLink()||H.size>8*1024*1024)throw new Error("Hosted candidate export exceeds its private IPC bound.");let t=O(JSON.parse(await m.readFile(g,"utf8"))),u=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId});if(u.error||!u.sourcePath)throw new Error("Actual hosted Profile source is unavailable.");if(e.action!=="readback"){let o=!1;try{await a(e.repoPath,["symbolic-ref","-q","HEAD"]),o=!0}catch{}if(o||await a(e.repoPath,["rev-parse","HEAD"])!==(e.action==="rollback"?e.commit:t.expectedCommit)||await a(e.repoPath,["status","--porcelain","--untracked-files=all"]))throw new Error("Candidate staging requires a clean detached exact original source worktree.")}let x=f(async o=>I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),sourceRevision:o,repositoryId:t.compiler.repositoryId}),"compile");if(e.action==="readback"){if(!e.commit||await a(e.repoPath,["rev-parse","HEAD"])!==e.commit)throw new Error("Hosted Profile readback is not the committed source.");let o=await x(e.commit),i=h(o);if(i.profileGitHead!==e.commit||i.contentHash!==(e.expectedExecutableSourceHash??t.executableSourceHash)||i.protectedClosureHash!==t.protectedClosureHash)throw new Error("Hosted active executable differs from the actual tested candidate.");let s=await M({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,compiled:o,createdAt:t.createdAt});return{commit:e.commit,activeRelease:{id:s.harnessRelease.id,contentHash:s.harnessRelease.contentHash},executableSourceHash:i.contentHash,protectedClosureHash:i.protectedClosureHash}}if(e.action==="rollback"){if(!e.commit)throw new Error("Rollback requires the exact accepted commit.");await a(e.repoPath,["-c","core.hooksPath=/dev/null","revert","--no-commit",e.commit])}let p=await x(t.expectedCommit);if(p.harnessRelease.contentHash!==t.baseRelease.contentHash||p.harnessRelease.id!==t.baseRelease.id)throw new Error("Hosted original source differs from the owner-attested baseline release.");if(e.action==="stage"){let o=Buffer.from(t.sourceManifest.base64,"base64");if(o.toString("base64")!==t.sourceManifest.base64||o.length!==t.sourceManifest.sizeBytes||v(o)!==t.sourceManifest.contentHash)throw new Error("Candidate source manifest byte identity differs.");let i=A.parse(JSON.parse(o.toString("utf8"))),s=n.join(e.outputDir,"candidate-source");await m.mkdir(s,{recursive:!0}),await m.writeFile(n.join(s,"harness.json"),C(i));let _=R(t.policySource),j=new Map(p.sourceFiles.filter(r=>r.asset.visibility!=="policy").map(r=>[r.path,r]));for(let r of i.files){let k=r.visibility==="policy"?_.get(r.path):j.get(r.path)?.bytes;if(!k)throw new Error("The hosted source cannot hydrate the exact protected candidate closure.");let y=n.join(s,r.path);if(n.relative(s,y).startsWith(".."))throw new Error("Candidate release path escapes private staging.");await m.mkdir(n.dirname(y),{recursive:!0}),await m.writeFile(y,k)}let P=await D({workspaceId:t.compiler.workspaceId,sourceDir:s}),S=h(P);if(P.harnessRelease.contentHash!==t.policySource.harnessRelease.contentHash||S.contentHash!==t.executableSourceHash||S.protectedClosureHash!==t.protectedClosureHash)throw new Error("Owner-attested candidate differs from independently compiled hosted source.");await F({source:u.sourcePath,state:{component:t.component},base:p,candidate:P,profile:u})}await a(e.repoPath,["add","--all"]),await a(e.repoPath,["-c","core.hooksPath=/dev/null","-c","commit.gpgSign=false","commit","-m",`${e.action==="rollback"?"Roll back":"Adopt"} owner-tested candidate ${t.candidateId}`],{GIT_AUTHOR_NAME:"OpenPond",GIT_AUTHOR_EMAIL:"profile-candidate@openpond.local",GIT_COMMITTER_NAME:"OpenPond",GIT_COMMITTER_EMAIL:"profile-candidate@openpond.local"});let E=await a(e.repoPath,["rev-parse","HEAD"]),T=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),b=await I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:T,sourceRevision:E,repositoryId:t.compiler.repositoryId}),d=h(b);if(e.action==="stage"&&(d.contentHash!==t.executableSourceHash||d.protectedClosureHash!==t.protectedClosureHash)||e.action==="rollback"&&(d.contentHash!==h(p).contentHash||d.protectedClosureHash!==h(p).protectedClosureHash))throw new Error("Staged actual source differs from its exact tested executable graph.");return{commit:E,activeRelease:{id:b.harnessRelease.id,contentHash:b.harnessRelease.contentHash},executableSourceHash:d.contentHash,protectedClosureHash:d.protectedClosureHash}}f(z,"hostedProfileCandidate");async function Q(l){if(l.length!==1||l[0].length>16e3||!/^[a-zA-Z0-9_-]+$/.test(l[0]))throw new Error("Hosted candidate IPC argument is invalid.");process.stdout.write(`${JSON.stringify(await z(JSON.parse(Buffer.from(l[0],"base64url").toString("utf8"))))}
3
3
  `)}f(Q,"runHostedProfileCandidateCli");export{z as hostedProfileCandidate,Q as runHostedProfileCandidateCli};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a,b,c,d}from"./chunk-XTFPDQMH.js";import"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-7E6T7GP5.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as compileHostedProfileRelease,b as runHostedProfileCompilerCli,c as runHostedProfileEvaluationCli,d as runHostedProfileInspectionCli};
2
+ import{a,b,c,d}from"./chunk-4EQA2M7K.js";import"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-6QSSIT62.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-7E6T7GP5.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as compileHostedProfileRelease,b as runHostedProfileCompilerCli,c as runHostedProfileEvaluationCli,d as runHostedProfileInspectionCli};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as m,b as c}from"./chunk-OPNRWESL.js";import{a as l}from"./chunk-O6ULLQJ6.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{o as f}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{Hb as s,Ob as u}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{n as t}from"./chunk-KGNCKIFP.js";import{b as n}from"./chunk-ES2ISFJC.js";import{a as i}from"./chunk-FTQLQJQV.js";var v=n.object({profileRef:f,sourceRevision:n.string().min(1),action:n.enum(["compare","report"]),request:n.unknown(),runs:n.array(l).max(1e4),comparisons:n.array(s).max(1e4),suiteRuns:n.array(u).max(1e4)}).strict();async function h(p){let o=v.parse(p);for(let e of[...o.runs,...o.comparisons,...o.suiteRuns])t(e,"Hosted evaluation evidence");let a={getProfileEvaluationRun:i(async e=>o.runs.find(r=>r.manifest.id===e)??null,"getProfileEvaluationRun"),getProfileEvaluationComparison:i(async e=>o.comparisons.find(r=>r.id===e)??null,"getProfileEvaluationComparison"),getProfileEvaluationSuiteRun:i(async e=>o.suiteRuns.find(r=>r.id===e)??null,"getProfileEvaluationSuiteRun"),saveProfileEvaluationComparison:i(async(e,r)=>r,"saveProfileEvaluationComparison")};return o.action==="compare"?m({store:a,selectedProfile:i(async()=>({ref:o.profileRef,sourceRevision:o.sourceRevision}),"selectedProfile")})(o.request):c({store:a,profileRef:o.profileRef,request:o.request})}i(h,"controlHostedProfileEvaluation");export{h as controlHostedProfileEvaluation};
2
+ import{a as m,b as c}from"./chunk-OPNRWESL.js";import{a as l}from"./chunk-O6ULLQJ6.js";import"./chunk-QL4OIPEZ.js";import"./chunk-OQPJ7FJF.js";import{o as f}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{Hb as s,Ob as u}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{n as t}from"./chunk-KGNCKIFP.js";import{b as n}from"./chunk-ES2ISFJC.js";import{a as i}from"./chunk-FTQLQJQV.js";var v=n.object({profileRef:f,sourceRevision:n.string().min(1),action:n.enum(["compare","report"]),request:n.unknown(),runs:n.array(l).max(1e4),comparisons:n.array(s).max(1e4),suiteRuns:n.array(u).max(1e4)}).strict();async function h(p){let o=v.parse(p);for(let e of[...o.runs,...o.comparisons,...o.suiteRuns])t(e,"Hosted evaluation evidence");let a={getProfileEvaluationRun:i(async e=>o.runs.find(r=>r.manifest.id===e)??null,"getProfileEvaluationRun"),getProfileEvaluationComparison:i(async e=>o.comparisons.find(r=>r.id===e)??null,"getProfileEvaluationComparison"),getProfileEvaluationSuiteRun:i(async e=>o.suiteRuns.find(r=>r.id===e)??null,"getProfileEvaluationSuiteRun"),saveProfileEvaluationComparison:i(async(e,r)=>r,"saveProfileEvaluationComparison")};return o.action==="compare"?m({store:a,selectedProfile:i(async()=>({ref:o.profileRef,sourceRevision:o.sourceRevision}),"selectedProfile")})(o.request):c({store:a,profileRef:o.profileRef,request:o.request})}i(h,"controlHostedProfileEvaluation");export{h as controlHostedProfileEvaluation};