openpond 0.2.63 → 0.2.65

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 (561) hide show
  1. package/dist/app-server.d.ts +76 -2
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/account-context-TIJOM22A.js +12 -0
  4. package/dist/chunks/acp-PHMBLRCV.js +2 -0
  5. package/dist/chunks/acp-agent-A7GK2VSH.js +19 -0
  6. package/dist/chunks/actions-command-VLKMHCMI.js +2 -0
  7. package/dist/chunks/app-layer-J66CQ2QN.js +3 -0
  8. package/dist/chunks/app-server-connected-apps-IB6M35NS.js +2 -0
  9. package/dist/chunks/app-server-evaluations-V6LRWDUF.js +2 -0
  10. package/dist/chunks/app-server-harness-services-6ZRLA3YD.js +2 -0
  11. package/dist/chunks/app-server-runtime-OMR2VE6L.js +2 -0
  12. package/dist/chunks/apps-IHUFERZO.js +2 -0
  13. package/dist/chunks/{chunk-NZTCH6K5.js → chunk-2GJD23CM.js} +1 -1
  14. package/dist/chunks/{chunk-BKEDG3A4.js → chunk-2MEOUS24.js} +1 -1
  15. package/dist/chunks/{chunk-DUL6DXOI.js → chunk-2W22IXHB.js} +1 -1
  16. package/dist/chunks/{chunk-GGJUWIGR.js → chunk-36FNNR5N.js} +1 -1
  17. package/dist/chunks/chunk-3BJ7LPE3.js +2 -0
  18. package/dist/chunks/chunk-3MVKXAH7.js +2 -0
  19. package/dist/chunks/{chunk-UTNGEMW5.js → chunk-3WJQ4IGK.js} +1 -1
  20. package/dist/chunks/{chunk-G6OR5NB6.js → chunk-4D3CICBG.js} +1 -1
  21. package/dist/chunks/chunk-4DYWVGVS.js +2 -0
  22. package/dist/chunks/{chunk-KUPJNBWG.js → chunk-4JYTFEND.js} +1 -1
  23. package/dist/chunks/chunk-4MQHIFZL.js +2 -0
  24. package/dist/chunks/chunk-4TO743HO.js +4 -0
  25. package/dist/chunks/{chunk-B4RKHHF7.js → chunk-4TTXNVCE.js} +1 -1
  26. package/dist/chunks/{chunk-3YXYBYWK.js → chunk-4V73I4OL.js} +1 -1
  27. package/dist/chunks/chunk-55Q64WWF.js +2 -0
  28. package/dist/chunks/{chunk-F7QTIHXX.js → chunk-5AU5Y6KS.js} +1 -1
  29. package/dist/chunks/chunk-5HPZGLOL.js +2 -0
  30. package/dist/chunks/{chunk-LCSBCCYC.js → chunk-5JVJQA5H.js} +1 -1
  31. package/dist/chunks/chunk-5KJMFK65.js +2 -0
  32. package/dist/chunks/{chunk-BSPFY3Y5.js → chunk-5KWKSR4P.js} +1 -1
  33. package/dist/chunks/chunk-5WPMI6QX.js +2 -0
  34. package/dist/chunks/{chunk-SHJY5RLU.js → chunk-5Z3AU5CL.js} +1 -1
  35. package/dist/chunks/{chunk-DQI5TE6A.js → chunk-66HFW4OU.js} +1 -1
  36. package/dist/chunks/{chunk-NT7N6KLE.js → chunk-67HXM6AL.js} +1 -1
  37. package/dist/chunks/{chunk-J7ZTPXRQ.js → chunk-6C3CXME7.js} +1 -1
  38. package/dist/chunks/{chunk-PWK5Z5S3.js → chunk-6ESBAHWK.js} +1 -1
  39. package/dist/chunks/{chunk-XNOMIWEY.js → chunk-6I5AUTVO.js} +1 -1
  40. package/dist/chunks/{chunk-OG33QAG6.js → chunk-6S2MWJVD.js} +1 -1
  41. package/dist/chunks/{chunk-KCOTDUGW.js → chunk-6TRVEA3T.js} +1 -1
  42. package/dist/chunks/chunk-6ZTP6CUJ.js +2 -0
  43. package/dist/chunks/{chunk-4L6DU6Z2.js → chunk-7FBWUVX7.js} +1 -1
  44. package/dist/chunks/{chunk-GPL2Z65R.js → chunk-7P5SH3CI.js} +2 -2
  45. package/dist/chunks/chunk-7PKTCMZ6.js +2 -0
  46. package/dist/chunks/chunk-7XOUM6RK.js +2 -0
  47. package/dist/chunks/chunk-A77DLBR4.js +2 -0
  48. package/dist/chunks/chunk-AF3AVDPP.js +2 -0
  49. package/dist/chunks/{chunk-RV7PUSI2.js → chunk-AJXWJLZA.js} +1 -1
  50. package/dist/chunks/chunk-AMC4Z7G4.js +2 -0
  51. package/dist/chunks/chunk-ANG2YMMD.js +2 -0
  52. package/dist/chunks/{chunk-ZPTKR3GB.js → chunk-B32CW3NT.js} +1 -1
  53. package/dist/chunks/{chunk-Y766IN7Y.js → chunk-B666Z2NS.js} +1 -1
  54. package/dist/chunks/chunk-BJXPQIVD.js +2 -0
  55. package/dist/chunks/{chunk-WBUK73ST.js → chunk-BL3CZWWD.js} +1 -1
  56. package/dist/chunks/{chunk-XMHIQ3SK.js → chunk-BTJACFU3.js} +2 -2
  57. package/dist/chunks/{chunk-25XXZS3E.js → chunk-C5B3FMV3.js} +1 -1
  58. package/dist/chunks/chunk-CRDKBFRN.js +2 -0
  59. package/dist/chunks/chunk-CYQLXS2U.js +2 -0
  60. package/dist/chunks/{chunk-N4VHLJBZ.js → chunk-D7R2AAX2.js} +1 -1
  61. package/dist/chunks/{chunk-LSZJ5M3X.js → chunk-DAEUVT2I.js} +1 -1
  62. package/dist/chunks/{chunk-ELX7VRSU.js → chunk-DIDQHTAX.js} +1 -1
  63. package/dist/chunks/chunk-DMO3UIS7.js +6 -0
  64. package/dist/chunks/{chunk-4BJGUCHY.js → chunk-DRMOHADV.js} +1 -1
  65. package/dist/chunks/{chunk-FYYYECHE.js → chunk-DSJZS77R.js} +4 -4
  66. package/dist/chunks/{chunk-7HRLWPPZ.js → chunk-DXA2UHBE.js} +1 -1
  67. package/dist/chunks/chunk-E2S2EMYQ.js +10 -0
  68. package/dist/chunks/{chunk-T6JN4PND.js → chunk-EBOTNBUS.js} +1 -1
  69. package/dist/chunks/chunk-ECOH24MC.js +9 -0
  70. package/dist/chunks/{chunk-6PKXJEJM.js → chunk-EICS777E.js} +1 -1
  71. package/dist/chunks/{chunk-4SZ3HKHU.js → chunk-EVQISX7M.js} +1 -1
  72. package/dist/chunks/chunk-FEQ7HNJR.js +2 -0
  73. package/dist/chunks/{chunk-2HAWOMZK.js → chunk-FGOTSCSE.js} +1 -1
  74. package/dist/chunks/{chunk-IWWXIUAQ.js → chunk-FHLSLOKH.js} +8 -8
  75. package/dist/chunks/{chunk-BU27SLZP.js → chunk-FS2VKOT7.js} +1 -1
  76. package/dist/chunks/{chunk-4FNCBA3Y.js → chunk-FUFI4THX.js} +1 -1
  77. package/dist/chunks/{chunk-W5W4IODW.js → chunk-FYWQWKVS.js} +1 -1
  78. package/dist/chunks/{chunk-IZ56L2ZK.js → chunk-G4747MOW.js} +1 -1
  79. package/dist/chunks/{chunk-J572ANHX.js → chunk-G4E3WGLM.js} +4 -4
  80. package/dist/chunks/{chunk-P7HRF4FM.js → chunk-GD3RCUDH.js} +1 -1
  81. package/dist/chunks/{chunk-HUCBKXTU.js → chunk-GDJ4X2ZN.js} +1 -1
  82. package/dist/chunks/{chunk-JHR3LF2F.js → chunk-GF55VEMR.js} +1 -1
  83. package/dist/chunks/{chunk-GXCUH2VV.js → chunk-GFAI2MCJ.js} +3 -3
  84. package/dist/chunks/{chunk-KOKX7PBS.js → chunk-GI7LTJV3.js} +1 -1
  85. package/dist/chunks/{chunk-TCOTXCV6.js → chunk-GIU3Z45P.js} +1 -1
  86. package/dist/chunks/{chunk-GXZCMO6S.js → chunk-GRLQHYAU.js} +2 -2
  87. package/dist/chunks/{chunk-M3SCON53.js → chunk-GUG2SWRZ.js} +1 -1
  88. package/dist/chunks/{chunk-JQRMDFF3.js → chunk-H42UW6IF.js} +1 -1
  89. package/dist/chunks/{chunk-EZRUWIP6.js → chunk-H5ML7735.js} +1 -1
  90. package/dist/chunks/{chunk-VNJAAYNQ.js → chunk-HIQPGYVH.js} +1 -1
  91. package/dist/chunks/{chunk-DLANLLKH.js → chunk-HNDAGZCF.js} +1 -1
  92. package/dist/chunks/{chunk-OE22TAXP.js → chunk-HNQPEOJD.js} +1 -1
  93. package/dist/chunks/chunk-HORMGT2Q.js +2 -0
  94. package/dist/chunks/{chunk-2V4LPUBH.js → chunk-HPTEJBP4.js} +1 -1
  95. package/dist/chunks/{chunk-UWHIU24L.js → chunk-HVM2GUM3.js} +1 -1
  96. package/dist/chunks/{chunk-NEJLJ2XY.js → chunk-HX6GXMDK.js} +1 -1
  97. package/dist/chunks/chunk-I3NYYOSS.js +2 -0
  98. package/dist/chunks/{chunk-LV3CQ72P.js → chunk-I6VMRQF4.js} +1 -1
  99. package/dist/chunks/{chunk-QU4UE73E.js → chunk-IEVJLG3V.js} +1 -1
  100. package/dist/chunks/chunk-IOSBGCRT.js +2 -0
  101. package/dist/chunks/{chunk-SO42ZB5K.js → chunk-JBFPTEVE.js} +1 -1
  102. package/dist/chunks/{chunk-G32BO6M5.js → chunk-JD76ANPN.js} +1 -1
  103. package/dist/chunks/{chunk-ERJV5BMC.js → chunk-JFZ6USNQ.js} +1 -1
  104. package/dist/chunks/{chunk-UPWJSNL5.js → chunk-JLW5BQVO.js} +1 -1
  105. package/dist/chunks/chunk-JRGECNP3.js +2 -0
  106. package/dist/chunks/{chunk-DABBHWSF.js → chunk-KAWXVMHI.js} +1 -1
  107. package/dist/chunks/chunk-KGUPAPGR.js +2 -0
  108. package/dist/chunks/{chunk-AHOBCBVZ.js → chunk-KOKBDIGR.js} +1 -1
  109. package/dist/chunks/chunk-KTIBXRWQ.js +2 -0
  110. package/dist/chunks/chunk-L4EJ5R3B.js +23 -0
  111. package/dist/chunks/{chunk-SI5W5LBV.js → chunk-LARJARMS.js} +1 -1
  112. package/dist/chunks/{chunk-MPNJ2BB4.js → chunk-LE75SVEL.js} +1 -1
  113. package/dist/chunks/{chunk-ERT32RZA.js → chunk-LI3FTPAH.js} +5 -5
  114. package/dist/chunks/chunk-LK77GI6M.js +2 -0
  115. package/dist/chunks/chunk-LOIYNRBC.js +33 -0
  116. package/dist/chunks/{chunk-7WYL2IDD.js → chunk-LXZLLTYQ.js} +1 -1
  117. package/dist/chunks/{chunk-RZUCVF2Q.js → chunk-LYVHYT3L.js} +1 -1
  118. package/dist/chunks/{chunk-MWXW2CA6.js → chunk-LZPCA6DH.js} +1 -1
  119. package/dist/chunks/{chunk-GVARQXYI.js → chunk-M5QPL5NO.js} +1 -1
  120. package/dist/chunks/{chunk-WWQNMC7C.js → chunk-MCBRB5D6.js} +1 -1
  121. package/dist/chunks/chunk-MHPCVQOE.js +2 -0
  122. package/dist/chunks/chunk-MMJU6PZV.js +2 -0
  123. package/dist/chunks/chunk-MVPKU72J.js +4 -0
  124. package/dist/chunks/{chunk-AGVOGPAZ.js → chunk-MWS2NAHJ.js} +1 -1
  125. package/dist/chunks/{chunk-R6VJDOQM.js → chunk-N2AV7PHV.js} +4 -4
  126. package/dist/chunks/{chunk-R6WMY6AH.js → chunk-NTM3KQ25.js} +1 -1
  127. package/dist/chunks/chunk-NXN7GJOH.js +2 -0
  128. package/dist/chunks/chunk-O6ZYDHEJ.js +3 -0
  129. package/dist/chunks/chunk-OKEC2EIE.js +2 -0
  130. package/dist/chunks/{chunk-KCV5VN4X.js → chunk-OKKNDQJF.js} +1 -1
  131. package/dist/chunks/{chunk-ZYVHOVKL.js → chunk-OPTJYDZN.js} +1 -1
  132. package/dist/chunks/{chunk-NJLULBTM.js → chunk-OTDDXEQ6.js} +1 -1
  133. package/dist/chunks/{chunk-RDSVU6F6.js → chunk-OTUS7NTQ.js} +1 -1
  134. package/dist/chunks/{chunk-UH4JSSRL.js → chunk-OTXGAKFH.js} +8 -8
  135. package/dist/chunks/chunk-OW3EOC5Q.js +4 -0
  136. package/dist/chunks/chunk-OXRVILDW.js +2 -0
  137. package/dist/chunks/{chunk-JEISPWWM.js → chunk-PWKJ5KLZ.js} +1 -1
  138. package/dist/chunks/{chunk-RFMME46Z.js → chunk-PYNW5OFA.js} +1 -1
  139. package/dist/chunks/{chunk-AKGCM53D.js → chunk-Q3WXB465.js} +1 -1
  140. package/dist/chunks/{chunk-KHTAAVC2.js → chunk-Q4AXZY2P.js} +1 -1
  141. package/dist/chunks/{chunk-QJ6KUVAR.js → chunk-QAEZNFAM.js} +1 -1
  142. package/dist/chunks/{chunk-ABF3W2MO.js → chunk-QAFXQHHG.js} +2 -2
  143. package/dist/chunks/chunk-QCJY6FTC.js +3 -0
  144. package/dist/chunks/{chunk-5MHYGMJG.js → chunk-QJJNHKLT.js} +1 -1
  145. package/dist/chunks/{chunk-ERL2M773.js → chunk-QYQZQVVN.js} +1 -1
  146. package/dist/chunks/{chunk-VVNV4NNW.js → chunk-RCT3O3HQ.js} +1 -1
  147. package/dist/chunks/{chunk-7R56WC7L.js → chunk-RHMULF56.js} +1 -1
  148. package/dist/chunks/chunk-RRWL5BHZ.js +2 -0
  149. package/dist/chunks/{chunk-RG3NH6YQ.js → chunk-S4WILIRA.js} +1 -1
  150. package/dist/chunks/{chunk-N33D7KCW.js → chunk-S6UCVXBC.js} +1 -1
  151. package/dist/chunks/{chunk-IHB5GTOJ.js → chunk-SAZTOGX6.js} +3 -3
  152. package/dist/chunks/{chunk-2EPR4HLF.js → chunk-SH7POUVX.js} +6 -6
  153. package/dist/chunks/{chunk-NLYZ5K7U.js → chunk-SSJV3VX7.js} +1 -1
  154. package/dist/chunks/chunk-TBODQT4W.js +2 -0
  155. package/dist/chunks/chunk-TGULVWPV.js +2 -0
  156. package/dist/chunks/{chunk-HIYQPZ7C.js → chunk-TPOAAJKA.js} +1 -1
  157. package/dist/chunks/{chunk-42V4NV2F.js → chunk-TVDZXDQW.js} +1 -1
  158. package/dist/chunks/{chunk-FVRII5XO.js → chunk-U2BD545L.js} +1 -1
  159. package/dist/chunks/chunk-UK5LGSGT.js +2 -0
  160. package/dist/chunks/{chunk-HFJUXKT5.js → chunk-ULJZ7NUF.js} +1 -1
  161. package/dist/chunks/chunk-UM6EQOT2.js +161 -0
  162. package/dist/chunks/chunk-UN2LKLGV.js +2 -0
  163. package/dist/chunks/{chunk-4NXEYPPX.js → chunk-UOFDKMRU.js} +1 -1
  164. package/dist/chunks/{chunk-2ITZW2CN.js → chunk-UTIELP6F.js} +1 -1
  165. package/dist/chunks/{chunk-NWQL6FNF.js → chunk-V3KEG6MI.js} +1 -1
  166. package/dist/chunks/{chunk-BPZOABMC.js → chunk-V3S2B6WU.js} +2 -2
  167. package/dist/chunks/{chunk-ZG6353RM.js → chunk-VD2TQCMH.js} +1 -1
  168. package/dist/chunks/{chunk-4ZBOYWQ3.js → chunk-VS2LOUCT.js} +1 -1
  169. package/dist/chunks/{chunk-V7KR74NO.js → chunk-VS3AMJEK.js} +1 -1
  170. package/dist/chunks/{chunk-YCZZ62C2.js → chunk-W22KWKF6.js} +1 -1
  171. package/dist/chunks/chunk-W7NXFRHN.js +2 -0
  172. package/dist/chunks/{chunk-DTTFUANI.js → chunk-WBO6FQHR.js} +2 -2
  173. package/dist/chunks/{chunk-5ZBLCWEJ.js → chunk-WJSJXK2N.js} +1 -1
  174. package/dist/chunks/{chunk-C2LAEGOW.js → chunk-WKHGXLJD.js} +2 -2
  175. package/dist/chunks/{chunk-H6C4MAUN.js → chunk-WLQEONBF.js} +1 -1
  176. package/dist/chunks/chunk-WLZJOCLA.js +10 -0
  177. package/dist/chunks/chunk-WMBOXX7G.js +2 -0
  178. package/dist/chunks/{chunk-PF56N7ZY.js → chunk-X2J2P5ZT.js} +5 -5
  179. package/dist/chunks/{chunk-AH26AQN7.js → chunk-XHBMK6LC.js} +1 -1
  180. package/dist/chunks/{chunk-ZZHXQCNB.js → chunk-Y3B6ZUE6.js} +1 -1
  181. package/dist/chunks/{chunk-WP2L2NY2.js → chunk-YBKDEEEH.js} +1 -1
  182. package/dist/chunks/chunk-YRDPVTEI.js +3 -0
  183. package/dist/chunks/{chunk-JORRZ4BB.js → chunk-YU4JYWCA.js} +1 -1
  184. package/dist/chunks/{chunk-CZ5R4JXZ.js → chunk-Z2TOBS3P.js} +1 -1
  185. package/dist/chunks/chunk-ZFJWA4JK.js +1 -0
  186. package/dist/chunks/chunk-ZSZXA7WB.js +2 -0
  187. package/dist/chunks/{chunk-LK2K3SPM.js → chunk-ZU3YBRXS.js} +2 -2
  188. package/dist/chunks/{chunk-5FU5RLML.js → chunk-ZUT4EM64.js} +1 -1
  189. package/dist/chunks/chunk-ZWW227M3.js +2 -0
  190. package/dist/chunks/chunk-ZY32SZ2P.js +3 -0
  191. package/dist/chunks/cli-TE7RP5H7.js +2 -0
  192. package/dist/chunks/client-I5MYOJEJ.js +2 -0
  193. package/dist/chunks/command-NDHFZAKA.js +13 -0
  194. package/dist/chunks/configuration-command-465ODYTC.js +2 -0
  195. package/dist/chunks/connected-app-executor-7DYMZCD7.js +2 -0
  196. package/dist/chunks/connected-evidence-XPAZQRFQ.js +2 -0
  197. package/dist/chunks/{connected-starting-assets-JONPTII6.js → connected-starting-assets-2YX3QVDB.js} +1 -1
  198. package/dist/chunks/connection-GDWPMHPC.js +2 -0
  199. package/dist/chunks/{continual-Z7MO2PF6.js → continual-HQCFY7GN.js} +3 -3
  200. package/dist/chunks/core-commands-PJOGRBHJ.js +2 -0
  201. package/dist/chunks/dataset-preparation-authoring-KWRTMKN6.js +4 -0
  202. package/dist/chunks/datasets-OTE2I4VT.js +2 -0
  203. package/dist/chunks/desktop-test-Q6REQJ7K.js +3 -0
  204. package/dist/chunks/dist-GR56E3QK.js +2 -0
  205. package/dist/chunks/dist-J4KHAVO3.js +2 -0
  206. package/dist/chunks/dist-O7HXZUBW.js +2 -0
  207. package/dist/chunks/enclave-7VLABNIX.js +2 -0
  208. package/dist/chunks/evaluation-coordination-KRCY2H4C.js +2 -0
  209. package/dist/chunks/experiment-improvements-7MI2VYBR.js +2 -0
  210. package/dist/chunks/experiments-CNUQKJZE.js +2 -0
  211. package/dist/chunks/experiments-VOCZ4DW3.js +2 -0
  212. package/dist/chunks/experiments-signal-4N344D4Y.js +2 -0
  213. package/dist/chunks/{extension-ZM6NI5O5.js → extension-UH34ZF7N.js} +1 -1
  214. package/dist/chunks/{help-7HXFWIKS.js → help-ZUKVY6RO.js} +1 -1
  215. package/dist/chunks/host-profile-evaluation-tools-75EPCRSZ.js +2 -0
  216. package/dist/chunks/host-profile-external-dataset-YRKG2GL5.js +2 -0
  217. package/dist/chunks/hosted-app-server-composition-DWSU6ASL.js +2 -0
  218. package/dist/chunks/hosted-experiment-improvement-NZTPZTDH.js +3 -0
  219. package/dist/chunks/hosted-harness-runtime-3AJGEIFD.js +2 -0
  220. package/dist/chunks/hosted-profile-candidate-3CAT3XBI.js +3 -0
  221. package/dist/chunks/hosted-profile-compiler-RXU626Q6.js +2 -0
  222. package/dist/chunks/hosted-profile-evaluation-control-CBDRKJ5J.js +2 -0
  223. package/dist/chunks/hosted-profile-evaluation-inspection-CHYKDYUQ.js +3 -0
  224. package/dist/chunks/hosted-profile-evaluation-preparation-H5S7JZMD.js +3 -0
  225. package/dist/chunks/hosted-tasksets-AMGDDB2R.js +2 -0
  226. package/dist/chunks/human-review-HOBGC6RC.js +2 -0
  227. package/dist/chunks/{import-6SI4BEKS.js → import-Q3YRFVY7.js} +2 -2
  228. package/dist/chunks/learning-NJLTGZFQ.js +2 -0
  229. package/dist/chunks/learning-XTY5VOTK.js +2 -0
  230. package/dist/chunks/local-harness-improvement-runtime-XEA73RGS.js +2 -0
  231. package/dist/chunks/local-harness-taskset-review-SW35G4DM.js +2 -0
  232. package/dist/chunks/local-scope-X3737QXT.js +2 -0
  233. package/dist/chunks/model-projects-GHWCKDON.js +2 -0
  234. package/dist/chunks/opchat-2LLDIWEJ.js +3 -0
  235. package/dist/chunks/opchat-bounded-chat-FLDS36LU.js +2 -0
  236. package/dist/chunks/organizations-VIFSOY6P.js +2 -0
  237. package/dist/chunks/{profile-O5HL5DTQ.js → profile-KIHMW2WB.js} +1 -1
  238. package/dist/chunks/profile-training-source-VIND2MM2.js +2 -0
  239. package/dist/chunks/project-action-payload-2G57RL74.js +2 -0
  240. package/dist/chunks/project-agent-TJLQNMLA.js +2 -0
  241. package/dist/chunks/published-experiment-source-D3C2AWQD.js +2 -0
  242. package/dist/chunks/refiner-profile-service-PPGGNVOV.js +2 -0
  243. package/dist/chunks/{runtime-XBA744HJ.js → runtime-VSOOPNYN.js} +2 -2
  244. package/dist/chunks/sandbox-command-CQO6BEMQ.js +2 -0
  245. package/dist/chunks/{sandbox-template-27U3FQN7.js → sandbox-template-MU33IILL.js} +1 -1
  246. package/dist/chunks/saved-work-LAVTNKPT.js +2 -0
  247. package/dist/chunks/send-turn-D3GTSSHI.js +2 -0
  248. package/dist/chunks/setup-HSRCZ3WR.js +2 -0
  249. package/dist/chunks/{src-PU7QTFO5.js → src-662QOKNP.js} +1 -1
  250. package/dist/chunks/{src-BLWX6DRG.js → src-CHQVWHV7.js} +117 -117
  251. package/dist/chunks/standalone-experiment-turn-owner-KKYIGGPF.js +2 -0
  252. package/dist/chunks/stdio-Z65UIX55.js +2 -0
  253. package/dist/chunks/store-chat-resources-ZWDYMDJF.js +2 -0
  254. package/dist/chunks/{store-continual-support-reviews-FOMYYS25.js → store-continual-support-reviews-7PDLGRWF.js} +1 -1
  255. package/dist/chunks/store-conversation-serving-WRT4N7N2.js +2 -0
  256. package/dist/chunks/{store-create-improve-3LQMIYAP.js → store-create-improve-G46KIUVT.js} +1 -1
  257. package/dist/chunks/{store-datasets-3KSX7RSO.js → store-datasets-O67F75BL.js} +1 -1
  258. package/dist/chunks/store-evaluation-results-BEPR4LVD.js +7 -0
  259. package/dist/chunks/{store-harness-memory-2L7ARBR4.js → store-harness-memory-4XEUITXE.js} +1 -1
  260. package/dist/chunks/{store-harness-refinement-candidates-3PHL3BUY.js → store-harness-refinement-candidates-LCN4NV23.js} +1 -1
  261. package/dist/chunks/store-harness-workspaces-PJJQ74G6.js +2 -0
  262. package/dist/chunks/store-human-review-HJ3D7ZFA.js +7 -0
  263. package/dist/chunks/store-learned-preference-migration-validation-EXNRDHCO.js +2 -0
  264. package/dist/chunks/store-learning-6P6IS7GH.js +2 -0
  265. package/dist/chunks/store-learning-credentials-EGJ2WTZI.js +2 -0
  266. package/dist/chunks/{store-local-experiments-QTVHJAEP.js → store-local-experiments-CBJA56X2.js} +1 -1
  267. package/dist/chunks/store-model-batch-review-YIVD7T2T.js +2 -0
  268. package/dist/chunks/{store-model-configuration-3SU73CMS.js → store-model-configuration-T6XJJDAB.js} +2 -2
  269. package/dist/chunks/store-model-project-preparation-WWU5CJTV.js +2 -0
  270. package/dist/chunks/{store-preference-comparison-DWV5XSMY.js → store-preference-comparison-XQFTLMGH.js} +1 -1
  271. package/dist/chunks/{store-schedules-2KUY4T6M.js → store-schedules-JPFVWL3Q.js} +1 -1
  272. package/dist/chunks/{store-sidebar-file-bookmarks-A4XCS7RM.js → store-sidebar-file-bookmarks-J3JEVAYR.js} +1 -1
  273. package/dist/chunks/{store-sidebar-preferences-V2PKRXUZ.js → store-sidebar-preferences-2JHTFXJK.js} +1 -1
  274. package/dist/chunks/{store-subagents-UGVEFA6M.js → store-subagents-PUBQVWSU.js} +1 -1
  275. package/dist/chunks/{store-task-inbox-QABI4ZAH.js → store-task-inbox-VVXZUJIO.js} +1 -1
  276. package/dist/chunks/{store-task-inventory-GEQIZELY.js → store-task-inventory-MQX44AI6.js} +1 -1
  277. package/dist/chunks/store-taskset-drafts-G3WFVN4M.js +9 -0
  278. package/dist/chunks/{store-training-CQV7PL3V.js → store-training-DUVIDYK5.js} +1 -1
  279. package/dist/chunks/{store-training-jobs-XKN6K66J.js → store-training-jobs-HHFH3V5O.js} +1 -1
  280. package/dist/chunks/{store-training-models-Q7DTTR4S.js → store-training-models-C7UUZDTO.js} +1 -1
  281. package/dist/chunks/{store-usage-XGAX7NLB.js → store-usage-6DMZM7WV.js} +1 -1
  282. package/dist/chunks/{store-work-evidence-VSLLZ6UF.js → store-work-evidence-77B36LRC.js} +1 -1
  283. package/dist/chunks/taskset-7FQCJ55X.js +2 -0
  284. package/dist/chunks/taskset-packages-NRRPON7B.js +2 -0
  285. package/dist/chunks/taskset-packages-RW4SFGDU.js +2 -0
  286. package/dist/chunks/{teams-bot-UTQAJA6H.js → teams-bot-D3LWA4S5.js} +1 -1
  287. package/dist/chunks/tool-learning-NGO7QHYK.js +2 -0
  288. package/dist/chunks/training-XFM3OOPN.js +2 -0
  289. package/dist/chunks/training-XILDD5RG.js +2 -0
  290. package/dist/chunks/training-error-LQKCOQDJ.js +2 -0
  291. package/dist/chunks/training-hardware-ESXRWUIK.js +3 -0
  292. package/dist/chunks/training-hosted-6BX2IASC.js +2 -0
  293. package/dist/chunks/training-hosted-checkpoint-evaluation-UXFW33QL.js +2 -0
  294. package/dist/chunks/training-hosted-learning-YN5VD3PW.js +2 -0
  295. package/dist/chunks/training-hosted-serving-N2MHWGZN.js +2 -0
  296. package/dist/chunks/training-hosted-serving-report-J4YOZLRP.js +2 -0
  297. package/dist/chunks/training-hosted-workers-6JTDCCWA.js +2 -0
  298. package/dist/chunks/training-model-start-E5MP3URL.js +2 -0
  299. package/dist/chunks/web-search-56QRZGPR.js +2 -0
  300. package/dist/chunks/workspaces-MCS2AQX6.js +2 -0
  301. package/dist/cli.js +1 -1
  302. package/dist/index.js +1 -1
  303. package/dist/sandbox-template/manifest.js +1 -1
  304. package/dist/skills/manifest.json +1 -1
  305. package/dist/web/assets/App-BZuSv1XM.js +53 -0
  306. package/dist/web/assets/{AppDialog-8Y0FYalT.js → AppDialog-BILEK4np.js} +1 -1
  307. package/dist/web/assets/AppTerminalPanel-BvxZ8bwD.js +2 -0
  308. package/dist/web/assets/{AppToastContext-BiQbbVxq.js → AppToastContext-C-FsCKXW.js} +1 -1
  309. package/dist/web/assets/{AppsView-Dtte4h6e.js → AppsView-BMaq5oxx.js} +1 -1
  310. package/dist/web/assets/{AttachmentTypeIcon-DgADV7dn.js → AttachmentTypeIcon-Bh7Ft_UL.js} +1 -1
  311. package/dist/web/assets/{BrowserSidebar-BUqDvEv9.js → BrowserSidebar-BG2MLJ9I.js} +1 -1
  312. package/dist/web/assets/{CartesianChart-J4ChOjvG.js → CartesianChart-CS6ES_XT.js} +1 -1
  313. package/dist/web/assets/ChatTimelineEntry-Dr5X_XyN.js +8 -0
  314. package/dist/web/assets/{ChatTimelineEntry-DztFb85D.css → ChatTimelineEntry-vs8RaEGD.css} +1 -1
  315. package/dist/web/assets/{CollaborationTabs-CFCpk2Ck.js → CollaborationTabs-CPJ2w67F.js} +1 -1
  316. package/dist/web/assets/{CommandMenu-EPPjB14H.js → CommandMenu-Fe1V7NJd.js} +1 -1
  317. package/dist/web/assets/{CommunityView-Okydjpqm.js → CommunityView-DHTcmOnI.js} +1 -1
  318. package/dist/web/assets/{ComposerAttachments-RXCiE88M.js → ComposerAttachments-Ck9VWD6o.js} +1 -1
  319. package/dist/web/assets/{ComposerCreateImproveStrip-CSngc8-V.js → ComposerCreateImproveStrip-yiXO7cf8.js} +1 -1
  320. package/dist/web/assets/{ConversationImportsSettings-DS73kyfj.js → ConversationImportsSettings-_VLzUnHQ.js} +1 -1
  321. package/dist/web/assets/{FilePagePreview-Qc4B0vue.js → FilePagePreview-BpcM1DfE.js} +2 -2
  322. package/dist/web/assets/{GetStartedView-DGFPQ1We.js → GetStartedView-BH-WJ-rW.js} +1 -1
  323. package/dist/web/assets/{GettingStartedDialog-DFBYQdHz.js → GettingStartedDialog-CdQfj7RA.js} +1 -1
  324. package/dist/web/assets/{HostedModelLearningReview-BDu3FlcU.js → HostedModelLearningReview-C3GsOlu9.js} +1 -1
  325. package/dist/web/assets/{HostedModelLearningSettings-CHaTHwC8.js → HostedModelLearningSettings-SSMst6dl.js} +1 -1
  326. package/dist/web/assets/{HtmlVisual-D9Mh7xds.js → HtmlVisual-CH0tb3fv.js} +1 -1
  327. package/dist/web/assets/{LabModelVersionDetailPage-DgY7lAu5.js → LabModelVersionDetailPage-J2t9yILv.js} +1 -1
  328. package/dist/web/assets/{LabSkillSidebar-BwtlThO7.js → LabSkillSidebar-DdDYvfj2.js} +1 -1
  329. package/dist/web/assets/LabsRoute-MJwIjSKg.js +101 -0
  330. package/dist/web/assets/MainChatThread-BcwtaTDZ.js +2 -0
  331. package/dist/web/assets/MainPane-DDO6diPt.js +10 -0
  332. package/dist/web/assets/NativeSetupTerminal-BPSUFpRm.js +2 -0
  333. package/dist/web/assets/{NativeSkillSidebar-BEJvt5_H.js → NativeSkillSidebar-DPYavzau.js} +1 -1
  334. package/dist/web/assets/{NewProjectDialog-CjrjgkTN.js → NewProjectDialog-BtmvE9Sp.js} +1 -1
  335. package/dist/web/assets/{OutputsPage-jzx93QQ3.js → OutputsPage-BMRY7RK2.js} +1 -1
  336. package/dist/web/assets/{PageChrome-C1M13qG2.js → PageChrome-5VRxH6Rp.js} +1 -1
  337. package/dist/web/assets/{ProjectsPage-DZrjlMp2.js → ProjectsPage-1LHqxOMo.js} +1 -1
  338. package/dist/web/assets/RightChatPanelStack-D_7KgExz.js +1 -0
  339. package/dist/web/assets/RightSidebarHomePanel-iznJwDMf.js +1 -0
  340. package/dist/web/assets/{ScheduledWorkPage-Cw1ja2GF.js → ScheduledWorkPage-Dtz4zJ0T.js} +1 -1
  341. package/dist/web/assets/{SettingsView-CckoIki3.js → SettingsView-BeDYNPcD.js} +3 -3
  342. package/dist/web/assets/{TasksetDraftEditorPrimitives-ByC8bDjp.js → TasksetDraftEditorPrimitives-CcvKO3YA.js} +1 -1
  343. package/dist/web/assets/{TeamChatView-OprnSKLF.js → TeamChatView-DaXxOkTe.js} +1 -1
  344. package/dist/web/assets/{TerminalOverlay-d7A2F9Lx.js → TerminalOverlay-CF8uB4qA.js} +1 -1
  345. package/dist/web/assets/{TrainingCreationPanel-Cyn6R6I6.js → TrainingCreationPanel-DmMO7x5T.js} +1 -1
  346. package/dist/web/assets/{TrainingDraftPanel-Mpb5e7t5.js → TrainingDraftPanel-DCHbXjSx.js} +1 -1
  347. package/dist/web/assets/{TrainingRunLineage-VcKz7dIR.js → TrainingRunLineage-CwisTWs_.js} +1 -1
  348. package/dist/web/assets/UsageSettingsSection-Drt7gwRb.js +7 -0
  349. package/dist/web/assets/WorkSidebarPanel-BrIIRtGW.js +1 -0
  350. package/dist/web/assets/WorkspaceDiffPanel-Dmbrg0-y.js +11 -0
  351. package/dist/web/assets/{WorkspaceEnvironmentMenu-C8y3537a.js → WorkspaceEnvironmentMenu-KEZm1gdb.js} +1 -1
  352. package/dist/web/assets/{WorkspaceFileLocation-LrEWj4UK.js → WorkspaceFileLocation-ChbOKrPO.js} +1 -1
  353. package/dist/web/assets/{WorkspaceGitDialogs-NRIMXnkS.js → WorkspaceGitDialogs-BS2JQKNQ.js} +1 -1
  354. package/dist/web/assets/{WorkspaceMonacoEditor-CvDGjKAL.js → WorkspaceMonacoEditor-CN1hE_C4.js} +3 -3
  355. package/dist/web/assets/{WorkspacePdfPreview-BZ0BbnHv.js → WorkspacePdfPreview-Clb4m0le.js} +2 -2
  356. package/dist/web/assets/{WorkspacePresentationPreview-DJrjrvT0.js → WorkspacePresentationPreview-CwQsdvAR.js} +1 -1
  357. package/dist/web/assets/app-models-Cz3yxq4x.js +1 -0
  358. package/dist/web/assets/{bot-6OhUEmkE.js → bot-BNFltD5O.js} +1 -1
  359. package/dist/web/assets/chat-resources-CTN4f6KC.js +1 -0
  360. package/dist/web/assets/{chevron-down-jmVA1BIf.js → chevron-down-BnnT0tnM.js} +1 -1
  361. package/dist/web/assets/chevron-right-C8K5PZj7.js +1 -0
  362. package/dist/web/assets/{chevron-up-CstyLXH3.js → chevron-up-BAnwJJN3.js} +1 -1
  363. package/dist/web/assets/chunk-GJRXJL6G-pJp1DyJd.js +9 -0
  364. package/dist/web/assets/chunk-TLSP5JKG-DZmxtX-4.js +1 -0
  365. package/dist/web/assets/{client-choice-storage-BdQ_YDuk.js → client-choice-storage-Iuzoszas.js} +1 -1
  366. package/dist/web/assets/{cloud-upload-Ck1ufAr8.js → cloud-upload-CdSXJ7ms.js} +1 -1
  367. package/dist/web/assets/{copy-CPkbMfXt.js → copy-CBFg6m0d.js} +1 -1
  368. package/dist/web/assets/{createLucideIcon-CXQny8HU.js → createLucideIcon-DF2VR6WA.js} +1 -1
  369. package/dist/web/assets/{cssMode-CYxYl_om.js → cssMode-BSQUZhUO.js} +1 -1
  370. package/dist/web/assets/{external-link-CDKOLG_v.js → external-link-Cql9bKdv.js} +1 -1
  371. package/dist/web/assets/{folder-open-CEtOb_lK.js → folder-open-BXdVB5J1.js} +1 -1
  372. package/dist/web/assets/{folder-plus-CVMYZs3e.js → folder-plus-Cma2HulC.js} +1 -1
  373. package/dist/web/assets/{git-commit-horizontal-DDyhPjxS.js → git-commit-horizontal-eF--16ps.js} +1 -1
  374. package/dist/web/assets/{htmlMode-DoY4V_j0.js → htmlMode-aLPlQtyU.js} +1 -1
  375. package/dist/web/assets/icons-c3vt7y6n.js +1 -0
  376. package/dist/web/assets/{image-B-PjDSwU.js → image-CqKPwnBn.js} +1 -1
  377. package/dist/web/assets/{index-D9WbJMSq.js → index-CM0IRu1U.js} +2 -2
  378. package/dist/web/assets/{info-CCnw-K3b.js → info-CqeYEqG0.js} +1 -1
  379. package/dist/web/assets/{jsonMode-CeOpZdPj.js → jsonMode-fu7bEcHB.js} +1 -1
  380. package/dist/web/assets/loader-circle-pxp89T5x.js +1 -0
  381. package/dist/web/assets/{lspLanguageFeatures-DAbgLCqZ.js → lspLanguageFeatures-DraXQA4w.js} +1 -1
  382. package/dist/web/assets/{maximize-2-BZX38cpr.js → maximize-2-yMp8X9ts.js} +1 -1
  383. package/dist/web/assets/{message-square-CvgSecgD.js → message-square-DbIMQqfj.js} +1 -1
  384. package/dist/web/assets/model-display-zPvC4L2B.js +1 -0
  385. package/dist/web/assets/models-route-CWcJuOd0.js +1 -0
  386. package/dist/web/assets/{monaco.contribution-cbDqt48m.js → monaco.contribution-BQhp1CJs.js} +2 -2
  387. package/dist/web/assets/{monaco.contribution-CF2JDhi4.js → monaco.contribution-Bd8EqYGR.js} +2 -2
  388. package/dist/web/assets/{monaco.contribution-m2ze2EsL.js → monaco.contribution-CYWKnVxQ.js} +2 -2
  389. package/dist/web/assets/{monaco.contribution-yeyow_-Q.js → monaco.contribution-CmbWO0tB.js} +2 -2
  390. package/dist/web/assets/{monitor-By0s4hxb.js → monitor-DFE2fTkT.js} +1 -1
  391. package/dist/web/assets/{paperclip-BJ2QgJLa.js → paperclip-D_qsKbVs.js} +1 -1
  392. package/dist/web/assets/{pdf-C4x-1jjP.js → pdf-DkQRsi4n.js} +1 -1
  393. package/dist/web/assets/play-BtlX2stU.js +1 -0
  394. package/dist/web/assets/plus-DbASL_gy.js +1 -0
  395. package/dist/web/assets/{presentation-I86G1Gd9.js → presentation-BN_kIBPL.js} +1 -1
  396. package/dist/web/assets/{python-CqFTPj8r.js → python-DB9pj5Hr.js} +1 -1
  397. package/dist/web/assets/{refresh-cw-Dga35Eay.js → refresh-cw-B27ohHfn.js} +1 -1
  398. package/dist/web/assets/{save-BLKjYtzR.js → save-D-rwjKop.js} +1 -1
  399. package/dist/web/assets/settings-lists-DgSaJQA4.js +5 -0
  400. package/dist/web/assets/square-C2caJ3NG.js +1 -0
  401. package/dist/web/assets/{square-terminal-B-n7vUex.js → square-terminal-CeoK51wH.js} +1 -1
  402. package/dist/web/assets/{submit-issue-command-B7Hrt2tU.js → submit-issue-command-DZNW7Evj.js} +1 -1
  403. package/dist/web/assets/{toggleHighContrast-BhmBE5XE.js → toggleHighContrast-Bs8L1gx0.js} +1 -1
  404. package/dist/web/assets/{training-QrdkRQZQ.js → training-DCdoHJ0Y.js} +2 -2
  405. package/dist/web/assets/{training-model-data-DB-jg6L_.js → training-model-data-wHvE7xL1.js} +1 -1
  406. package/dist/web/assets/{tsMode-BSWEII2p.js → tsMode-C7EqshxC.js} +1 -1
  407. package/dist/web/assets/{upload-C4MPhQn8.js → upload-BWgjC2Jf.js} +1 -1
  408. package/dist/web/assets/{useAccountSettings-9oqWdRLs.js → useAccountSettings-Dva1MpsJ.js} +1 -1
  409. package/dist/web/assets/{useAgentInventory-isO79ui9.js → useAgentInventory-CrjIOmvb.js} +1 -1
  410. package/dist/web/assets/{useLocalAgentSchedules-CZX6PxoK.js → useLocalAgentSchedules-P-UaUKMb.js} +1 -1
  411. package/dist/web/assets/{useQuery-BD0Uexmh.js → useQuery-Bn3KqR4r.js} +1 -1
  412. package/dist/web/assets/{wifi-off-Cloe0WuQ.js → wifi-off--mKrSPFc.js} +1 -1
  413. package/dist/web/assets/{workers-BXagz5eg.js → workers-p0Kn2KMK.js} +1 -1
  414. package/dist/web/assets/x-D9GTV9ke.js +1 -0
  415. package/dist/web/assets/{yaml-sBdvVbCc.js → yaml-BeIdC4tu.js} +1 -1
  416. package/dist/web/index.html +1 -1
  417. package/docs/command-reference.md +44 -2
  418. package/package.json +1 -1
  419. package/dist/chunks/acp-H3MJCPHX.js +0 -2
  420. package/dist/chunks/acp-agent-DWA7272M.js +0 -21
  421. package/dist/chunks/actions-command-IIYOO4LL.js +0 -2
  422. package/dist/chunks/app-layer-K7H2WJ56.js +0 -3
  423. package/dist/chunks/app-server-connected-apps-RM5E2VWF.js +0 -2
  424. package/dist/chunks/app-server-evaluations-XGMGS67X.js +0 -2
  425. package/dist/chunks/app-server-harness-services-BHD6S5II.js +0 -2
  426. package/dist/chunks/app-server-runtime-LFIL6F7D.js +0 -2
  427. package/dist/chunks/apps-QKAHJGQ4.js +0 -2
  428. package/dist/chunks/chunk-5EP2DZLJ.js +0 -2
  429. package/dist/chunks/chunk-6EBCS57F.js +0 -2
  430. package/dist/chunks/chunk-6RS4NAOY.js +0 -2
  431. package/dist/chunks/chunk-7O6Z3VOZ.js +0 -2
  432. package/dist/chunks/chunk-7YLXGILH.js +0 -2
  433. package/dist/chunks/chunk-7ZLXFKRI.js +0 -2
  434. package/dist/chunks/chunk-B5R53U74.js +0 -2
  435. package/dist/chunks/chunk-C2AXMKK4.js +0 -2
  436. package/dist/chunks/chunk-F6UQ6PPK.js +0 -2
  437. package/dist/chunks/chunk-GS6ZUSIN.js +0 -3
  438. package/dist/chunks/chunk-JSQRLLN6.js +0 -2
  439. package/dist/chunks/chunk-LAOLJDVB.js +0 -2
  440. package/dist/chunks/chunk-LKKMLBOH.js +0 -3
  441. package/dist/chunks/chunk-M3FLEZ4E.js +0 -4
  442. package/dist/chunks/chunk-MEGKXGW3.js +0 -2
  443. package/dist/chunks/chunk-MILEWROZ.js +0 -2
  444. package/dist/chunks/chunk-N42HT64M.js +0 -2
  445. package/dist/chunks/chunk-NG2L6D7G.js +0 -2
  446. package/dist/chunks/chunk-OSVGNONV.js +0 -2
  447. package/dist/chunks/chunk-OTUBJV6C.js +0 -6
  448. package/dist/chunks/chunk-PBTXLQAU.js +0 -2
  449. package/dist/chunks/chunk-PBZCXPPC.js +0 -10
  450. package/dist/chunks/chunk-SFKZITAG.js +0 -9
  451. package/dist/chunks/chunk-SXMR6E2W.js +0 -2
  452. package/dist/chunks/chunk-U2K7QJCG.js +0 -2
  453. package/dist/chunks/chunk-URNMC46H.js +0 -157
  454. package/dist/chunks/chunk-VHXDWAEH.js +0 -2
  455. package/dist/chunks/chunk-W2TICQ62.js +0 -2
  456. package/dist/chunks/chunk-WSOUMXH3.js +0 -24
  457. package/dist/chunks/chunk-XOB6FKQV.js +0 -2
  458. package/dist/chunks/chunk-YBNKGA5C.js +0 -2
  459. package/dist/chunks/chunk-YM4PSVFW.js +0 -4
  460. package/dist/chunks/chunk-YNQWJWIC.js +0 -10
  461. package/dist/chunks/chunk-Z3BWCFLV.js +0 -2
  462. package/dist/chunks/cli-PSXMIJTF.js +0 -2
  463. package/dist/chunks/configuration-command-XYKMXIWF.js +0 -2
  464. package/dist/chunks/connected-app-executor-6G2LA3PQ.js +0 -2
  465. package/dist/chunks/connected-evidence-IRXYN6YD.js +0 -2
  466. package/dist/chunks/connection-XMAAGMXJ.js +0 -2
  467. package/dist/chunks/core-commands-WWN7X3XC.js +0 -2
  468. package/dist/chunks/dataset-preparation-authoring-F3OZIQSP.js +0 -4
  469. package/dist/chunks/datasets-2PC2HP7N.js +0 -2
  470. package/dist/chunks/desktop-test-VU6AFAMO.js +0 -3
  471. package/dist/chunks/dist-47AYOIH6.js +0 -2
  472. package/dist/chunks/dist-HSC43RG4.js +0 -2
  473. package/dist/chunks/dist-MXBEBM4D.js +0 -2
  474. package/dist/chunks/enclave-VURYNILU.js +0 -2
  475. package/dist/chunks/evaluation-coordination-UOWZHHC5.js +0 -2
  476. package/dist/chunks/experiment-improvements-EB2CV5RA.js +0 -2
  477. package/dist/chunks/experiments-CLXGM3TZ.js +0 -2
  478. package/dist/chunks/experiments-SZQYR6MH.js +0 -2
  479. package/dist/chunks/experiments-signal-2KJCP25D.js +0 -2
  480. package/dist/chunks/host-profile-evaluation-tools-Y2LQ4WQN.js +0 -2
  481. package/dist/chunks/host-profile-external-dataset-FRIGXOO7.js +0 -2
  482. package/dist/chunks/hosted-app-server-composition-PGKQNDW6.js +0 -2
  483. package/dist/chunks/hosted-experiment-improvement-UXC542SZ.js +0 -3
  484. package/dist/chunks/hosted-harness-runtime-6PEI7F2U.js +0 -2
  485. package/dist/chunks/hosted-profile-candidate-HM44BIUX.js +0 -3
  486. package/dist/chunks/hosted-profile-compiler-UAZ4PHYE.js +0 -2
  487. package/dist/chunks/hosted-profile-evaluation-control-EUL57FAB.js +0 -2
  488. package/dist/chunks/hosted-profile-evaluation-inspection-7USY75Z4.js +0 -3
  489. package/dist/chunks/hosted-profile-evaluation-preparation-2LSMZQNA.js +0 -3
  490. package/dist/chunks/hosted-tasksets-WGXGXJ7E.js +0 -2
  491. package/dist/chunks/human-review-M26UKGJL.js +0 -2
  492. package/dist/chunks/learning-HM3NWOV5.js +0 -2
  493. package/dist/chunks/local-harness-improvement-runtime-QGWFWNSR.js +0 -2
  494. package/dist/chunks/local-harness-taskset-review-KS4WPMN6.js +0 -2
  495. package/dist/chunks/local-scope-62GWHDXS.js +0 -2
  496. package/dist/chunks/model-projects-YUAMBQTO.js +0 -2
  497. package/dist/chunks/opchat-AG4CWVY4.js +0 -3
  498. package/dist/chunks/opchat-bounded-chat-IQMP5IIO.js +0 -2
  499. package/dist/chunks/organizations-KDKX77XZ.js +0 -2
  500. package/dist/chunks/profile-training-source-3DXFM2XI.js +0 -2
  501. package/dist/chunks/project-action-payload-QA24HYGF.js +0 -2
  502. package/dist/chunks/project-agent-XBOOM5TS.js +0 -2
  503. package/dist/chunks/published-experiment-source-GZGN354O.js +0 -2
  504. package/dist/chunks/refiner-profile-service-BJMOYKTC.js +0 -2
  505. package/dist/chunks/sandbox-command-5ECGS7DG.js +0 -2
  506. package/dist/chunks/saved-work-KUNVTJ7O.js +0 -2
  507. package/dist/chunks/send-turn-FIPWOXWV.js +0 -2
  508. package/dist/chunks/standalone-experiment-turn-owner-XIE46VNH.js +0 -2
  509. package/dist/chunks/store-chat-resources-YOEJ2BI6.js +0 -2
  510. package/dist/chunks/store-conversation-serving-K324SQTO.js +0 -2
  511. package/dist/chunks/store-evaluation-results-LHCCNNE6.js +0 -7
  512. package/dist/chunks/store-harness-workspaces-ZHNCNWVI.js +0 -2
  513. package/dist/chunks/store-human-review-QJY3ZPPF.js +0 -7
  514. package/dist/chunks/store-learned-preference-migration-validation-X32SRBOM.js +0 -2
  515. package/dist/chunks/store-learning-DW3QLQXU.js +0 -2
  516. package/dist/chunks/store-learning-credentials-67QNTPA7.js +0 -2
  517. package/dist/chunks/store-model-batch-review-PBYQZJJJ.js +0 -2
  518. package/dist/chunks/store-model-project-preparation-TFCG2F2F.js +0 -2
  519. package/dist/chunks/store-taskset-drafts-GXABQR5G.js +0 -9
  520. package/dist/chunks/taskset-ARKJQKYQ.js +0 -2
  521. package/dist/chunks/taskset-packages-X4K65DTW.js +0 -2
  522. package/dist/chunks/taskset-packages-XK7FSD45.js +0 -2
  523. package/dist/chunks/training-3IWW4256.js +0 -2
  524. package/dist/chunks/training-RVIESURJ.js +0 -2
  525. package/dist/chunks/training-error-2EWDOQ4G.js +0 -2
  526. package/dist/chunks/training-hosted-PFJHYTEU.js +0 -2
  527. package/dist/chunks/training-hosted-checkpoint-evaluation-JJPP7KFW.js +0 -2
  528. package/dist/chunks/training-hosted-learning-Y7NHRY4V.js +0 -2
  529. package/dist/chunks/training-hosted-serving-QAV7ZGGV.js +0 -2
  530. package/dist/chunks/training-hosted-serving-report-OX4A5OKB.js +0 -2
  531. package/dist/chunks/training-hosted-workers-LST4ZUXN.js +0 -2
  532. package/dist/chunks/training-model-start-ROLS3E4V.js +0 -2
  533. package/dist/chunks/web-search-7FBUBZ66.js +0 -2
  534. package/dist/chunks/workspaces-G3CMY7ZA.js +0 -2
  535. package/dist/web/assets/App-DY2R8Z6r.js +0 -53
  536. package/dist/web/assets/AppTerminalPanel-YcnBD5DF.js +0 -2
  537. package/dist/web/assets/ChatTimelineEntry-DC93wlDa.js +0 -8
  538. package/dist/web/assets/LabsRoute-BV7ZJGEw.js +0 -101
  539. package/dist/web/assets/MainChatThread-pzHKd_YN.js +0 -2
  540. package/dist/web/assets/MainPane-6OlLiKKb.js +0 -10
  541. package/dist/web/assets/NativeSetupTerminal-CPDChcMi.js +0 -2
  542. package/dist/web/assets/RightChatPanelStack-BsxJg9sy.js +0 -1
  543. package/dist/web/assets/RightSidebarHomePanel-CCVQ9LMB.js +0 -1
  544. package/dist/web/assets/UsageSettingsSection-FhYymrfc.js +0 -7
  545. package/dist/web/assets/WorkSidebarPanel-u87uptH0.js +0 -1
  546. package/dist/web/assets/WorkspaceDiffPanel-B5rlW7bA.js +0 -11
  547. package/dist/web/assets/app-models-CUA9XB9U.js +0 -1
  548. package/dist/web/assets/chat-resources-CI8KFVO5.js +0 -1
  549. package/dist/web/assets/chevron-right-BYmDQ7ti.js +0 -1
  550. package/dist/web/assets/chunk-ONGOAEY6-C__DQmRT.js +0 -9
  551. package/dist/web/assets/chunk-SQBYHWZU-DumrB9SB.js +0 -1
  552. package/dist/web/assets/icons-D7jkCa2d.js +0 -1
  553. package/dist/web/assets/loader-circle-CPaJeTDy.js +0 -1
  554. package/dist/web/assets/models-route-Bl_TmMl6.js +0 -1
  555. package/dist/web/assets/play-D_SuGDBM.js +0 -1
  556. package/dist/web/assets/plus-yw95Iaj8.js +0 -1
  557. package/dist/web/assets/settings-lists-DMKA1lCN.js +0 -5
  558. package/dist/web/assets/square-BY5lG2Ol.js +0 -1
  559. package/dist/web/assets/x-Dqpel42h.js +0 -1
  560. /package/dist/chunks/{chunk-IDOGNIMV.js → chunk-7J2NMUTK.js} +0 -0
  561. /package/dist/chunks/{chunk-PCB65K4G.js → chunk-SFR32TMJ.js} +0 -0
@@ -1,14 +1,14 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as xs}from"./chunk-JFXINDOQ.js";import{a as ce,b as Te,d as ut,e as we}from"./chunk-YBNKGA5C.js";import{a as lt,b as Ee,c as $,g as Oe,h as pt,i as Be}from"./chunk-LV3CQ72P.js";import{a as dt,n as O}from"./chunk-VVNV4NNW.js";import{A as Y}from"./chunk-PF56N7ZY.js";import{a as p,e as Ns}from"./chunk-FTQLQJQV.js";var ft={codex:"Codex",claude_code:"Claude Code",hermes:"Hermes",openclaw:"OpenClaw",opencode:"OpenCode",grok_build:"Grok Build",pi:"Pi",oh_my_pi:"Oh My Pi"},L=32*1024*1024;import{homedir as ks}from"node:os";import{realpath as St,stat as ze,readdir as Ds,readFile as Ms}from"node:fs/promises";import{resolve as Je,join as X,isAbsolute as $s}from"node:path";function ht(s,e){let t=0;for(let i of e){if(!Number.isSafeInteger(i)||i<t||i>s.length)throw new RangeError("Canonical array prefix lengths must be ascending and within the array");t=i}let n=new dt().update("["),r=0;return e.map(i=>{for(;r<i;){let a=JSON.stringify([Pe(s[r])],null,2).slice(2,-2);n.update(r?`,
2
+ import{a as xs}from"./chunk-JFXINDOQ.js";import{b as ce,c as Te,e as ut,f as we}from"./chunk-AMC4Z7G4.js";import{h as lt,i as Ee,j as $,n as Oe,o as pt,p as Be}from"./chunk-I6VMRQF4.js";import{a as dt,n as O}from"./chunk-RCT3O3HQ.js";import{A as Y}from"./chunk-X2J2P5ZT.js";import{a as p,e as Ns}from"./chunk-FTQLQJQV.js";function ft(s,e){let t=0;for(let i of e){if(!Number.isSafeInteger(i)||i<t||i>s.length)throw new RangeError("Canonical array prefix lengths must be ascending and within the array");t=i}let n=new dt().update("["),r=0;return e.map(i=>{for(;r<i;){let a=JSON.stringify([Pe(s[r])],null,2).slice(2,-2);n.update(r?`,
3
3
  `:`
4
4
  `).update(a),r++}return n.clone().update(r?`
5
5
  ]
6
6
  `:`]
7
- `).digestHex()})}p(ht,"contentHashArrayPrefixes");function Pe(s){if(s===null||typeof s=="boolean"||typeof s=="number"||typeof s=="string")return s;if(Array.isArray(s))return Array.from({length:s.length},(t,n)=>{let r=Object.getOwnPropertyDescriptor(s,n);if(!r||r.get||r.set)throw new TypeError("Canonical array prefixes require plain JSON values");return Pe(r.value)});let e=s&&typeof s=="object"?Object.getPrototypeOf(s):void 0;if(s&&typeof s=="object"&&(e===Object.prototype||e===null))return Object.fromEntries(Object.keys(s).sort((t,n)=>t.localeCompare(n)).map(t=>{let n=Object.getOwnPropertyDescriptor(s,t);if(n.get||n.set)throw new TypeError("Canonical array prefixes require plain JSON values");return[t,Pe(n.value)]}));throw new TypeError("Canonical array prefixes require plain JSON values")}p(Pe,"sortJsonValue");import{opendir as Cs,readFile as Rs,stat as xe}from"node:fs/promises";import{basename as As,dirname as Ls,join as k,resolve as je}from"node:path";function yt(s,e){let t=e.HERMES_HOME?.trim();if(t){let r=t.replace(/\$(\w+)|\$\{([^}]+)\}/gu,(i,a,o)=>e[a||o]??i);return je(r==="~"?s:r.startsWith("~/")?k(s,r.slice(2)):r)}let n=e.HERMES_DATA_DIR_SUFFIX||"";return process.platform==="win32"?k(e.LOCALAPPDATA?.trim()||k(s,"AppData","Local"),`hermes${n}`):k(s,`.hermes${n}`)}p(yt,"hermesHome");var mt=p(s=>xe(s).then(e=>e.isDirectory()).catch(()=>!1),"isDirectory"),gt=p(s=>xe(s).then(e=>e.isFile()).catch(()=>!1),"isFile");async function We(s,e){let t=[],n=await Cs(s).catch(()=>null);if(!n)return t;let r=0;for await(let i of n){if(++r>100)throw new Error("More than 100 profile entries. Select the exact --source-path.");i.isDirectory()&&!i.isSymbolicLink()&&e(i.name)&&t.push(i.name)}return t.sort()}p(We,"profileNames");async function Et(s){if(As(Ls(s))==="profiles")return[{root:s}];let e=k(s,"profiles");try{let t=await We(e,a=>/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(a)),n=[];for(let a of t)await xe(k(e,".deleted",a)).then(()=>!0).catch(()=>!1)||await gt(k(e,a,"state.db"))&&n.push({root:k(e,a)});let r="",i=k(s,"active_profile");if(await xe(i).then(a=>a.isFile()&&a.size<=1024).catch(()=>!1)&&(r=(await Rs(i,"utf8")).replace(/^\uFEFF/u,"").trim().toLowerCase()),r&&r!=="default"){if(!/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(r))return[{root:s,reason:"Hermes active profile is invalid. Select the exact --source-path."}];let a=n.findIndex(o=>o.root===k(e,r));a<0?n.unshift({root:k(e,r),reason:"Hermes active profile has no retained live state database. Select a profile explicitly."}):n.unshift(...n.splice(a,1))}return(await gt(k(s,"state.db"))||!n.length)&&n.push({root:s}),n}catch(t){return[{root:s,reason:t instanceof Error?t.message:"Cannot inventory Hermes profiles. Select the exact --source-path."}]}}p(Et,"hermesLocations");function Ne(s){return/^[a-z0-9][a-z0-9._-]{0,63}$/u.test(s)&&!s.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/iu.test(s)}p(Ne,"validOmpProfile");async function wt(s,e){let t=k(s,e.PI_CONFIG_DIR||".omp"),n=(e.OMP_PROFILE!==void 0?e.OMP_PROFILE:e.PI_PROFILE)?.trim();if(n&&n!=="default"&&!Ne(n))return[{root:t,reason:"Oh My Pi profile is invalid. Select the exact --source-path."}];if(e.PI_CODING_AGENT_SESSION_DIR)return[{root:je(e.PI_CODING_AGENT_SESSION_DIR)}];let r=(process.platform==="linux"||process.platform==="darwin")&&e.XDG_DATA_HOME?k(e.XDG_DATA_HOME,"omp"):void 0;async function i(a){let o=a?k(t,"profiles",a,"agent"):k(t,"agent"),l=e.PI_PROFILE?.trim(),c=l&&Ne(l)?k(t,"profiles",l,"agent"):void 0,f=!a&&e.PI_CODING_AGENT_DIR&&e.PI_CODING_AGENT_DIR!==c?je(e.PI_CODING_AGENT_DIR):void 0,u=r&&(a?k(r,"profiles",a):r);return{root:(!f||f===o)&&u&&await mt(u)?u:f||o}}if(p(i,"location"),n||e.OMP_PROFILE!==void 0||e.PI_PROFILE!==void 0||e.PI_CODING_AGENT_DIR)return[await i(n&&n!=="default"?n:void 0)];try{let a=new Set(await We(k(t,"profiles"),Ne));if(r)for(let l of await We(k(r,"profiles"),Ne))a.add(l);let o=[await i()];for(let l of[...a].sort()){let c=await i(l);await mt(k(c.root,"sessions"))&&o.push(c)}return o}catch(a){return[{root:t,reason:a instanceof Error?a.message:"Cannot inventory Oh My Pi profiles. Select the exact --source-path."}]}}p(wt,"ompLocations");async function cr(s){let e=s.home??ks(),t=s.environment??process.env,n={codex:t.CODEX_HOME||X(e,".codex"),claude_code:t.CLAUDE_CONFIG_DIR||X(e,".claude"),hermes:yt(e,t),openclaw:t.OPENCLAW_STATE_DIR||X(e,".openclaw"),opencode:X(t.XDG_DATA_HOME||X(e,".local/share"),"opencode"),grok_build:t.GROK_HOME||X(e,".grok"),pi:t.PI_CODING_AGENT_DIR||X(e,".pi/agent"),oh_my_pi:X(e,".omp/agent")},r=n.pi,i=!1;if(t.PI_CODING_AGENT_SESSION_DIR)n.pi=Je(t.PI_CODING_AGENT_SESSION_DIR);else if(!s.locations?.pi)try{let o=X(r,"settings.json");if((await ze(o)).size<=1024*1024){let l=JSON.parse(await Ms(o,"utf8"));typeof l.sessionDir=="string"&&l.sessionDir.trim()&&($s(l.sessionDir)?n.pi=l.sessionDir:i=!0)}}catch{}let a=[];for(let o of Object.keys(ft)){let l=s.locations?.[o]?[{root:s.locations[o]}]:o==="hermes"?await Et(Je(n.hermes)):o==="oh_my_pi"?await wt(e,t):[{root:n[o]}];for(let c of l){let f=Je(c.root),u=!1,h=!1;try{f=await St(f);let g=await ze(f);h=g.isFile(),u=g.isDirectory()||h}catch{}if(c.reason&&(u=!1),o==="openclaw"&&u&&!h){let g=X(f,"agents"),w=await Ds(g,{withFileTypes:!0}).catch(()=>[]),y=[];for(let m of w.slice(0,100)){if(!m.isDirectory()||m.isSymbolicLink())continue;let d=X(g,m.name,"agent","openclaw-agent.sqlite");await ze(d).then(E=>E.isFile()).catch(()=>!1)&&y.push(await St(d))}if(y.length){for(let m of y)a.push({source:o,root:m,machineId:s.machineId,instanceId:`native-${O([s.machineId,o,m]).slice(0,40)}`,acquisition:"sqlite",available:!0,capabilities:{history:!0,live:!0,nativeResume:!1}});continue}}if(o==="pi"&&i&&!s.locations?.pi){a.push({source:o,root:f,machineId:s.machineId,instanceId:`native-${O([s.machineId,o,f]).slice(0,40)}`,acquisition:"files",available:!1,capabilities:{history:!1,live:!1,nativeResume:!1},reason:"Pi config uses a working-directory-relative sessionDir. Select its resolved directory with --source-path."});continue}a.push({source:o,root:f,machineId:s.machineId,instanceId:`native-${O([s.machineId,o,f]).slice(0,40)}`,acquisition:h&&!/\.(?:db|sqlite)$/u.test(f)?"files":o==="hermes"||o==="opencode"||o==="openclaw"&&h?"sqlite":o==="openclaw"?"bundle":"files",available:u,capabilities:{history:u,live:u&&(o!=="openclaw"||h),nativeResume:!1},...u?{}:{reason:c.reason??"Source location is missing or unreadable. Select a custom location."}})}}return a.filter((o,l)=>a.findIndex(c=>c.instanceId===o.instanceId)===l)}p(cr,"discoverSources");var Se=class extends Error{static{p(this,"ConnectedSessionWithoutUserRequestError")}constructor(){super("The session has no retained user request.")}};function F(s,e="milliseconds"){if(typeof s!="number"&&typeof s!="string")return null;let t=new Date(typeof s=="number"&&e==="seconds"?s*1e3:s);return Number.isFinite(t.getTime())?t.toISOString():null}p(F,"connectedTimestamp");function Ge(s){return{path:s.path,contentHash:O(s.text),sizeBytes:new TextEncoder().encode(s.text).length}}p(Ge,"connectedFileIdentity");function U(s){if(s.events.length+(s.unmappedEvents?.length??0)>$.events)throw new Error("connected_event_limit");let e=s.events.map((c,f)=>({...c,sequence:f}));if(new Set(e.map(c=>c.id)).size!==e.length)throw new Error("connected_duplicate_event");let t=e.flatMap((c,f)=>c.kind==="message"&&c.role==="user"?[f]:[]);if(!t.length)throw new Se;if(t.length+(s.includeConversation===!1?0:1)>$.boundaries)throw new Error("connected_boundary_limit");let n=`family-${O([s.origin,...s.acquisition?[s.acquisition.sourceInstanceId]:[],s.parentSessionId??s.sessionId]).slice(0,32)}`,r=ht(e,t.map(c=>c+1)),i=e.findIndex(c=>c.kind==="compaction"),a=t.map((c,f)=>{let u=t[f+1]??e.length,h=e.slice(c+1,u),g=h.filter(Be).at(-1),w=h.filter(v=>v.kind==="tool_call"||v.kind==="tool_result"),y=new Set(w.filter(v=>v.kind==="tool_call").map(v=>v.callId)),m=new Set(w.filter(v=>v.kind==="tool_result").map(v=>v.callId)),d=w.some(v=>!v.callId)||[...y].some(v=>!m.has(v))||[...m].some(v=>!y.has(v)),E=[...h].reverse().find(v=>v.kind==="terminal"),S=E&&typeof E.content=="object"&&E.content!==null&&!Array.isArray(E.content)?E.content.status:null,b=i>=0&&i<=c,N=h.some(v=>v.kind==="unknown");return{id:`case-${O([s.origin,...s.acquisition?[s.acquisition.sourceInstanceId]:[],s.sessionId,s.branchId??null,e[c].id]).slice(0,40)}`,familyKey:n,projection:"turn",requestEventId:e[c].id,start:c,end:u,inputHash:r[f],outputHash:g?O(g.content):null,revisionHash:O(h),terminal:S==="completed"||S==="failed"||S==="cancelled"?S:"unknown",coverage:{answer:!!g,context:s.contextComplete===!1?"unknown":b?"compacted":"retained",process:w.length?d||N?"partial":"retained":N?"partial":"absent",artifacts:h.some(v=>v.kind==="artifact")?"references_only":"absent",replay:"unavailable",gaps:[...g?[]:["No recorded assistant answer."],...s.contextComplete===!1?["The source omits preceding context."]:[],...b?["Earlier context was compacted by the source."]:[],...d?["Tool call/result correlation is incomplete."]:[],...N?["Some source events have no supported process mapping."]:[],...E?[]:["No terminal receipt was recorded."],"No resettable execution environment was admitted."]}}});if(s.includeConversation!==!1){let c=a[0],f=a.at(-1),u=e.slice(c.start+1),h=u.filter(Be);a.push({...c,id:`conversation-${O([s.origin,...s.acquisition?[s.acquisition.sourceInstanceId]:[],s.sessionId,s.branchId??null]).slice(0,40)}`,projection:"conversation",end:e.length,outputHash:h.length?O(h.map(g=>g.content)):null,revisionHash:O(u),terminal:f.terminal,coverage:{...c.coverage,answer:h.length>0,process:a.some(g=>g.coverage.process==="partial")?"partial":a.some(g=>g.coverage.process==="retained")?"retained":"absent",context:a.some(g=>g.coverage.context==="unknown")?"unknown":a.some(g=>g.coverage.context==="compacted")?"compacted":"retained",artifacts:a.some(g=>g.coverage.artifacts==="references_only")?"references_only":"absent",gaps:[...new Set(a.flatMap(g=>g.coverage.gaps))].slice(0,100)}})}let o={schemaVersion:lt,normalizerVersion:Ee,origin:s.origin,sessionId:s.sessionId,branchId:s.branchId??null,parentSessionId:s.parentSessionId??null,exporterVersion:s.exporterVersion??null,sourceFiles:s.files.map(Ge).sort((c,f)=>c.path.localeCompare(f.path)),...s.acquisition?{acquisition:s.acquisition}:{},...s.repositoryContext?{repositoryContext:s.repositoryContext}:{},events:e,unmappedEvents:(s.unmappedEvents??[]).map((c,f)=>({...c,sequence:f})),boundaries:a,warnings:s.warnings??[]},l=pt.parse({...o,contentHash:O(o)});if(new TextEncoder().encode(JSON.stringify(l)).length>$.decodedBytes)throw new Error("connected_normalized_size_limit");return l}p(U,"normalizeConnectedSession");function Q(s){if(new TextEncoder().encode(s.text).length>$.decodedBytes)throw new Error("Decoded source files exceed 64 MiB.");let e=s.text.replace(/^\uFEFF/u,"").split(/\r?\n/u);if(e.length>$.events+1)throw new Error("connected_event_limit");return e.flatMap((t,n)=>{if(!t.trim())return[];if(new TextEncoder().encode(t).length>$.lineBytes)throw new Error(`Source line ${n+1} exceeds the limit.`);let r;try{r=JSON.parse(t)}catch{throw new Error(`Invalid JSON on line ${n+1}.`)}if(!r||typeof r!="object"||Array.isArray(r))throw new Error(`Unsupported record on line ${n+1}.`);return[r]})}p(Q,"connectedJsonLines");function _(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)?s:{}}p(_,"object");function I(s){return{sequence:0,occurredAt:null,role:null,callId:null,parentId:null,usage:null,...s}}p(I,"event");function T(s){return JSON.parse(JSON.stringify(s??null))}p(T,"json");function z(s,e,t="reported_invocation"){let n=_(s),r=p((...c)=>{let f=c.find(u=>typeof u=="number"&&Number.isSafeInteger(u)&&u>=0);return typeof f=="number"?f:null},"number"),i=r(n.input_tokens,n.prompt_tokens),a=r(n.output_tokens,n.completion_tokens),o=r(n.cache_read_input_tokens,n.cached_input_tokens,_(n.input_tokens_details).cached_tokens),l=r(n.total_tokens);return i===null&&a===null&&o===null&&l===null?null:{invocationId:e,inputTokens:i,outputTokens:a,cachedInputTokens:o,totalTokens:l,provenance:t}}p(z,"sourceUsage");function _t(s,e){let t=new Set(e.map(c=>_(c.params).sessionId).filter(c=>typeof c=="string"));if(t.size!==1)throw new Error("Grok Build updates must identify exactly one retained session.");let n=[],r=new Set,i=new Map,a=null,o=null,l=!0;for(let c of e){let f=_(c.params),u=_(f.update),h=_(f._meta),g=u.sessionUpdate;if(typeof h.eventId!="string"||r.has(h.eventId))throw new Error("Grok Build updates require unique native event IDs.");r.add(h.eventId);let w=h.eventId,y=F(h.agentTimestampMs??(typeof c.timestamp=="number"?c.timestamp*1e3:null)),m=_(u.content);if(g==="user_message_chunk"){if(m.type!=="text"||typeof m.text!="string")throw new Error("Grok user content type requires a qualified adapter.");!a||l?(a=I({id:w,kind:"message",role:"user",occurredAt:y,content:m.text}),n.push(a),o=null,l=!1):a.content=String(a.content)+m.text}else if(g==="agent_message_chunk"){if(m.type!=="text"||typeof m.text!="string"){n.push(I({id:w,kind:"unknown",occurredAt:y,content:T(u)}));continue}o?o.content=String(o.content)+m.text:(o=I({id:w,kind:"message",role:"assistant",occurredAt:y,content:m.text}),n.push(o))}else if(g==="tool_call"||g==="tool_call_update"){let d=typeof u.toolCallId=="string"?u.toolCallId:null;if(!d){n.push(I({id:w,kind:"unknown",occurredAt:y,content:T(u)}));continue}let E=i.get(d);E?u.rawInput!==void 0&&(E.content=T({title:u.title,input:u.rawInput})):(E=I({id:`${w}:call`,kind:"tool_call",callId:d,occurredAt:y,content:T({title:u.title,input:u.rawInput})}),i.set(d,E),n.push(E)),(u.status==="completed"||u.status==="failed")&&n.push(I({id:`${w}:result`,kind:"tool_result",role:"tool",callId:d,occurredAt:y,content:T({status:u.status,output:u.rawOutput,content:u.content})}))}else if(g==="turn_completed"){let d=_(u.usage),E=typeof u.prompt_id=="string"?u.prompt_id:w;n.push(I({id:w,kind:"terminal",occurredAt:y,content:{status:u.stop_reason==="end_turn"?"completed":u.stop_reason==="cancelled"?"cancelled":"failed"},usage:z({input_tokens:d.inputTokens,output_tokens:d.outputTokens,cached_input_tokens:d.cachedReadTokens,total_tokens:d.totalTokens},E)})),l=!0,o=null,a=null}else g!=="agent_thought_chunk"&&n.push(I({id:w,kind:"unknown",occurredAt:y,content:T(u)}))}return U({origin:"grok_build",sessionId:String([...t][0]),files:[s],events:n,contextComplete:!1,warnings:["Grok retained ACP updates omit system context and encrypted reasoning. Tool coverage reflects only logged updates."]})}p(_t,"parseGrokBuildSession");function bt(s,e,t,n){let r=e.filter(d=>d.type==="session"),i=r[0];if(r.length!==1||!i||!(t==="openclaw"?[3,4].includes(Number(i.version)):i.version===3)||typeof i.id!="string")throw new Error("Unsupported native session tree version.");let a,l=(t!=="openclaw"?e:e.map(d=>{if(d.type==="session")return d;if(d.type==="leaf"){if(typeof d.targetId!="string")throw new Error("OpenClaw leaf control does not select a retained entry.");return a=d.targetId,d}if(typeof d.id!="string")throw new Error("OpenClaw transcript entry is missing its native identity.");let E=d.parentId===void 0?a??null:d.parentId;return d.appendMode!=="side"&&(a=d.id),{...d,parentId:E}})).filter(d=>d.type!=="session"&&d.type!=="title"&&d.type!=="leaf"),c=new Map,f=new Set;for(let d of l){if(typeof d.id!="string"||c.has(d.id))throw new Error("Session tree has missing or duplicate entry identities.");c.set(d.id,d),typeof d.parentId=="string"&&f.add(d.parentId)}n??=a;let u=[...c.keys()].filter(d=>!f.has(d));if(!n&&u.length!==1)throw new Error("Select a branch leaf for this branched session.");let h=n??u[0];if(!h||!c.has(h))throw new Error("The selected session branch is unavailable.");let g=[],w=new Set,y=h;for(;y;){if(w.has(y))throw new Error("Session branch contains a cycle.");w.add(y);let d=c.get(y);if(!d)throw new Error("Session branch has a missing ancestor.");g.push(d),y=typeof d.parentId=="string"?d.parentId:null}g.reverse();let m=[];for(let d of g){let E=String(d.id),S={occurredAt:F(d.timestamp),parentId:typeof d.parentId=="string"?d.parentId:null};if(d.type==="compaction"||d.type==="branch_summary"){m.push(I({...S,id:E,kind:"compaction",content:T({summary:d.summary,firstKeptEntryId:d.firstKeptEntryId})}));continue}if(d.type!=="message")continue;let b=_(d.message),N=b.role;if(N==="toolResult"){m.push(I({...S,id:E,kind:"tool_result",role:"tool",callId:typeof b.toolCallId=="string"?b.toolCallId:null,content:T({content:b.content,isError:b.isError===!0})}));continue}if(N!=="user"&&N!=="assistant"&&N!=="system"){m.push(I({...S,id:E,kind:"unknown",content:T({role:N,content:b.content})}));continue}let v=Array.isArray(b.content)?b.content.map(_):[],A=typeof b.content=="string"?b.content:v.filter(R=>R.type==="text").map(R=>String(R.text??"")).join(`
8
- `),M=_(b.usage),x=z({input_tokens:M.input,output_tokens:M.output,cached_input_tokens:M.cacheRead,total_tokens:M.totalTokens},E);A||N!=="assistant"?m.push(I({...S,id:E,kind:"message",role:N,content:N==="system"&&!A&&b.sections?T(b.sections):A,usage:x})):x&&m.push(I({...S,id:`${E}:usage`,kind:"usage",content:null,usage:x}));for(let[R,C]of v.entries())C.type==="toolCall"?m.push(I({...S,id:`${E}:call:${R}`,kind:"tool_call",callId:typeof C.id=="string"?C.id:null,content:T({name:C.name,arguments:C.arguments})})):C.type!=="text"&&C.type!=="thinking"&&m.push(I({...S,id:`${E}:block:${R}`,kind:"unknown",content:T(C)}));N==="assistant"&&["stop","error","aborted"].includes(String(b.stopReason))&&m.push(I({...S,id:`${E}:terminal`,kind:"terminal",content:{status:b.stopReason==="stop"?"completed":b.stopReason==="aborted"?"cancelled":"failed"}}))}return U({origin:t,sessionId:i.id,branchId:null,...t==="openclaw"?{contextComplete:!1}:{},files:[s],events:m,exporterVersion:`session-v${i.version}`,warnings:["Only the selected branch is included. Private provider payloads and credential metadata are excluded."]})}p(bt,"parsePiSession");function vt(s,e){let t=_(e),n=_(t.info);if(typeof n.id!="string"||!Array.isArray(t.messages))throw new Error("OpenCode requires its native JSON session export (info and messages).");let r=[];for(let i of t.messages){let a=_(i),o=_(a.info),l=_(o.time);if(typeof o.id!="string"||o.sessionID!==n.id||!Array.isArray(a.parts))throw new Error("OpenCode message identity does not match its session.");let c=o.role;if(c!=="user"&&c!=="assistant")throw new Error("Unsupported OpenCode message role.");let f={occurredAt:F(l.created),parentId:typeof o.parentID=="string"?o.parentID:null},u=a.parts.map(_);if(u.some(m=>m.sessionID!==n.id||m.messageID!==o.id||typeof m.id!="string"))throw new Error("OpenCode part identity does not match its message.");let h=u.filter(m=>m.type==="text").map(m=>String(m.text??"")).join(`
9
- `),g=_(o.tokens),w=_(g.cache),y=z({input_tokens:g.input,output_tokens:g.output,cached_input_tokens:w.read,total_tokens:g.total},o.id);h||c==="user"?r.push(I({...f,id:o.id,kind:"message",role:c,content:h,usage:y})):y&&r.push(I({...f,id:`${o.id}:usage`,kind:"usage",content:null,usage:y}));for(let m of u){let d=String(m.id);if(m.type==="tool"){let E=_(m.state),S=typeof m.callID=="string"?m.callID:null;r.push(I({...f,id:`${d}:call`,kind:"tool_call",callId:S,content:T({name:m.tool,arguments:E.input})})),(E.status==="completed"||E.status==="error")&&r.push(I({...f,id:`${d}:result`,kind:"tool_result",role:"tool",callId:S,content:T({output:E.output,error:E.error,status:E.status})}))}else m.type==="compaction"?r.push(I({...f,id:d,kind:"compaction",content:T(m)})):["text","reasoning","step-start","step-finish"].includes(String(m.type))||r.push(I({...f,id:d,kind:"unknown",content:T(m)}))}c==="assistant"&&(o.finish==="stop"||o.error)&&r.push(I({...f,id:`${o.id}:terminal`,kind:"terminal",content:{status:o.error?"failed":"completed"}}))}return U({origin:"opencode",sessionId:n.id,parentSessionId:typeof n.parentID=="string"?n.parentID:null,exporterVersion:typeof n.version=="string"?n.version:null,files:[s],events:r,warnings:["Source-reported usage is not an OpenPond billing receipt."]})}p(vt,"parseOpenCodeSession");var Xe="codex-native-authorization-v1",Hs=Xe;function It(s){let e=[],t=p((i,a,o)=>{let l={policy:Hs,sourcePath:i,sourceHash:O(a),entries:o};return e.push(l),l},"omit"),n=p((i,a)=>i.replace(/<permissions instructions>[\s\S]*?<\/permissions instructions>/gu,o=>o.replace(/^## Approved command prefixes\r?\n[\s\S]*?(?=^## |<\/permissions instructions>)/gmu,l=>{let c=t(a,l,null);return`## Approved command prefixes
7
+ `).digestHex()})}p(ft,"contentHashArrayPrefixes");function Pe(s){if(s===null||typeof s=="boolean"||typeof s=="number"||typeof s=="string")return s;if(Array.isArray(s))return Array.from({length:s.length},(t,n)=>{let r=Object.getOwnPropertyDescriptor(s,n);if(!r||r.get||r.set)throw new TypeError("Canonical array prefixes require plain JSON values");return Pe(r.value)});let e=s&&typeof s=="object"?Object.getPrototypeOf(s):void 0;if(s&&typeof s=="object"&&(e===Object.prototype||e===null))return Object.fromEntries(Object.keys(s).sort((t,n)=>t.localeCompare(n)).map(t=>{let n=Object.getOwnPropertyDescriptor(s,t);if(n.get||n.set)throw new TypeError("Canonical array prefixes require plain JSON values");return[t,Pe(n.value)]}));throw new TypeError("Canonical array prefixes require plain JSON values")}p(Pe,"sortJsonValue");var Se=class extends Error{static{p(this,"ConnectedSessionWithoutUserRequestError")}constructor(){super("The session has no retained user request.")}};function F(s,e="milliseconds"){if(typeof s!="number"&&typeof s!="string")return null;let t=new Date(typeof s=="number"&&e==="seconds"?s*1e3:s);return Number.isFinite(t.getTime())?t.toISOString():null}p(F,"connectedTimestamp");function je(s){return{path:s.path,contentHash:O(s.text),sizeBytes:new TextEncoder().encode(s.text).length}}p(je,"connectedFileIdentity");function U(s){if(s.events.length+(s.unmappedEvents?.length??0)>$.events)throw new Error("connected_event_limit");let e=s.events.map((c,f)=>({...c,sequence:f}));if(new Set(e.map(c=>c.id)).size!==e.length)throw new Error("connected_duplicate_event");let t=e.flatMap((c,f)=>c.kind==="message"&&c.role==="user"?[f]:[]);if(!t.length)throw new Se;if(t.length+(s.includeConversation===!1?0:1)>$.boundaries)throw new Error("connected_boundary_limit");let n=`family-${O([s.origin,...s.acquisition?[s.acquisition.sourceInstanceId]:[],s.parentSessionId??s.sessionId]).slice(0,32)}`,r=ft(e,t.map(c=>c+1)),i=e.findIndex(c=>c.kind==="compaction"),a=t.map((c,f)=>{let u=t[f+1]??e.length,h=e.slice(c+1,u),g=h.filter(Be).at(-1),w=h.filter(v=>v.kind==="tool_call"||v.kind==="tool_result"),y=new Set(w.filter(v=>v.kind==="tool_call").map(v=>v.callId)),m=new Set(w.filter(v=>v.kind==="tool_result").map(v=>v.callId)),d=w.some(v=>!v.callId)||[...y].some(v=>!m.has(v))||[...m].some(v=>!y.has(v)),E=[...h].reverse().find(v=>v.kind==="terminal"),S=E&&typeof E.content=="object"&&E.content!==null&&!Array.isArray(E.content)?E.content.status:null,b=i>=0&&i<=c,N=h.some(v=>v.kind==="unknown");return{id:`case-${O([s.origin,...s.acquisition?[s.acquisition.sourceInstanceId]:[],s.sessionId,s.branchId??null,e[c].id]).slice(0,40)}`,familyKey:n,projection:"turn",requestEventId:e[c].id,start:c,end:u,inputHash:r[f],outputHash:g?O(g.content):null,revisionHash:O(h),terminal:S==="completed"||S==="failed"||S==="cancelled"?S:"unknown",coverage:{answer:!!g,context:s.contextComplete===!1?"unknown":b?"compacted":"retained",process:w.length?d||N?"partial":"retained":N?"partial":"absent",artifacts:h.some(v=>v.kind==="artifact")?"references_only":"absent",replay:"unavailable",gaps:[...g?[]:["No recorded assistant answer."],...s.contextComplete===!1?["The source omits preceding context."]:[],...b?["Earlier context was compacted by the source."]:[],...d?["Tool call/result correlation is incomplete."]:[],...N?["Some source events have no supported process mapping."]:[],...E?[]:["No terminal receipt was recorded."],"No resettable execution environment was admitted."]}}});if(s.includeConversation!==!1){let c=a[0],f=a.at(-1),u=e.slice(c.start+1),h=u.filter(Be);a.push({...c,id:`conversation-${O([s.origin,...s.acquisition?[s.acquisition.sourceInstanceId]:[],s.sessionId,s.branchId??null]).slice(0,40)}`,projection:"conversation",end:e.length,outputHash:h.length?O(h.map(g=>g.content)):null,revisionHash:O(u),terminal:f.terminal,coverage:{...c.coverage,answer:h.length>0,process:a.some(g=>g.coverage.process==="partial")?"partial":a.some(g=>g.coverage.process==="retained")?"retained":"absent",context:a.some(g=>g.coverage.context==="unknown")?"unknown":a.some(g=>g.coverage.context==="compacted")?"compacted":"retained",artifacts:a.some(g=>g.coverage.artifacts==="references_only")?"references_only":"absent",gaps:[...new Set(a.flatMap(g=>g.coverage.gaps))].slice(0,100)}})}let o={schemaVersion:lt,normalizerVersion:Ee,origin:s.origin,sessionId:s.sessionId,branchId:s.branchId??null,parentSessionId:s.parentSessionId??null,exporterVersion:s.exporterVersion??null,sourceFiles:s.files.map(je).sort((c,f)=>c.path.localeCompare(f.path)),...s.acquisition?{acquisition:s.acquisition}:{},...s.repositoryContext?{repositoryContext:s.repositoryContext}:{},events:e,unmappedEvents:(s.unmappedEvents??[]).map((c,f)=>({...c,sequence:f})),boundaries:a,warnings:s.warnings??[]},l=pt.parse({...o,contentHash:O(o)});if(new TextEncoder().encode(JSON.stringify(l)).length>$.decodedBytes)throw new Error("connected_normalized_size_limit");return l}p(U,"normalizeConnectedSession");function Q(s){if(new TextEncoder().encode(s.text).length>$.decodedBytes)throw new Error("Decoded source files exceed 64 MiB.");let e=s.text.replace(/^\uFEFF/u,"").split(/\r?\n/u);if(e.length>$.events+1)throw new Error("connected_event_limit");return e.flatMap((t,n)=>{if(!t.trim())return[];if(new TextEncoder().encode(t).length>$.lineBytes)throw new Error(`Source line ${n+1} exceeds the limit.`);let r;try{r=JSON.parse(t)}catch{throw new Error(`Invalid JSON on line ${n+1}.`)}if(!r||typeof r!="object"||Array.isArray(r))throw new Error(`Unsupported record on line ${n+1}.`);return[r]})}p(Q,"connectedJsonLines");function _(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)?s:{}}p(_,"object");function I(s){return{sequence:0,occurredAt:null,role:null,callId:null,parentId:null,usage:null,...s}}p(I,"event");function T(s){return JSON.parse(JSON.stringify(s??null))}p(T,"json");function z(s,e,t="reported_invocation"){let n=_(s),r=p((...c)=>{let f=c.find(u=>typeof u=="number"&&Number.isSafeInteger(u)&&u>=0);return typeof f=="number"?f:null},"number"),i=r(n.input_tokens,n.prompt_tokens),a=r(n.output_tokens,n.completion_tokens),o=r(n.cache_read_input_tokens,n.cached_input_tokens,_(n.input_tokens_details).cached_tokens),l=r(n.total_tokens);return i===null&&a===null&&o===null&&l===null?null:{invocationId:e,inputTokens:i,outputTokens:a,cachedInputTokens:o,totalTokens:l,provenance:t}}p(z,"sourceUsage");function ht(s,e){let t=new Set(e.map(c=>_(c.params).sessionId).filter(c=>typeof c=="string"));if(t.size!==1)throw new Error("Grok Build updates must identify exactly one retained session.");let n=[],r=new Set,i=new Map,a=null,o=null,l=!0;for(let c of e){let f=_(c.params),u=_(f.update),h=_(f._meta),g=u.sessionUpdate;if(typeof h.eventId!="string"||r.has(h.eventId))throw new Error("Grok Build updates require unique native event IDs.");r.add(h.eventId);let w=h.eventId,y=F(h.agentTimestampMs??(typeof c.timestamp=="number"?c.timestamp*1e3:null)),m=_(u.content);if(g==="user_message_chunk"){if(m.type!=="text"||typeof m.text!="string")throw new Error("Grok user content type requires a qualified adapter.");!a||l?(a=I({id:w,kind:"message",role:"user",occurredAt:y,content:m.text}),n.push(a),o=null,l=!1):a.content=String(a.content)+m.text}else if(g==="agent_message_chunk"){if(m.type!=="text"||typeof m.text!="string"){n.push(I({id:w,kind:"unknown",occurredAt:y,content:T(u)}));continue}o?o.content=String(o.content)+m.text:(o=I({id:w,kind:"message",role:"assistant",occurredAt:y,content:m.text}),n.push(o))}else if(g==="tool_call"||g==="tool_call_update"){let d=typeof u.toolCallId=="string"?u.toolCallId:null;if(!d){n.push(I({id:w,kind:"unknown",occurredAt:y,content:T(u)}));continue}let E=i.get(d);E?u.rawInput!==void 0&&(E.content=T({title:u.title,input:u.rawInput})):(E=I({id:`${w}:call`,kind:"tool_call",callId:d,occurredAt:y,content:T({title:u.title,input:u.rawInput})}),i.set(d,E),n.push(E)),(u.status==="completed"||u.status==="failed")&&n.push(I({id:`${w}:result`,kind:"tool_result",role:"tool",callId:d,occurredAt:y,content:T({status:u.status,output:u.rawOutput,content:u.content})}))}else if(g==="turn_completed"){let d=_(u.usage),E=typeof u.prompt_id=="string"?u.prompt_id:w;n.push(I({id:w,kind:"terminal",occurredAt:y,content:{status:u.stop_reason==="end_turn"?"completed":u.stop_reason==="cancelled"?"cancelled":"failed"},usage:z({input_tokens:d.inputTokens,output_tokens:d.outputTokens,cached_input_tokens:d.cachedReadTokens,total_tokens:d.totalTokens},E)})),l=!0,o=null,a=null}else g!=="agent_thought_chunk"&&n.push(I({id:w,kind:"unknown",occurredAt:y,content:T(u)}))}return U({origin:"grok_build",sessionId:String([...t][0]),files:[s],events:n,contextComplete:!1,warnings:["Grok retained ACP updates omit system context and encrypted reasoning. Tool coverage reflects only logged updates."]})}p(ht,"parseGrokBuildSession");function mt(s,e,t,n){let r=e.filter(d=>d.type==="session"),i=r[0];if(r.length!==1||!i||!(t==="openclaw"?[3,4].includes(Number(i.version)):i.version===3)||typeof i.id!="string")throw new Error("Unsupported native session tree version.");let a,l=(t!=="openclaw"?e:e.map(d=>{if(d.type==="session")return d;if(d.type==="leaf"){if(typeof d.targetId!="string")throw new Error("OpenClaw leaf control does not select a retained entry.");return a=d.targetId,d}if(typeof d.id!="string")throw new Error("OpenClaw transcript entry is missing its native identity.");let E=d.parentId===void 0?a??null:d.parentId;return d.appendMode!=="side"&&(a=d.id),{...d,parentId:E}})).filter(d=>d.type!=="session"&&d.type!=="title"&&d.type!=="leaf"),c=new Map,f=new Set;for(let d of l){if(typeof d.id!="string"||c.has(d.id))throw new Error("Session tree has missing or duplicate entry identities.");c.set(d.id,d),typeof d.parentId=="string"&&f.add(d.parentId)}n??=a;let u=[...c.keys()].filter(d=>!f.has(d));if(!n&&u.length!==1)throw new Error("Select a branch leaf for this branched session.");let h=n??u[0];if(!h||!c.has(h))throw new Error("The selected session branch is unavailable.");let g=[],w=new Set,y=h;for(;y;){if(w.has(y))throw new Error("Session branch contains a cycle.");w.add(y);let d=c.get(y);if(!d)throw new Error("Session branch has a missing ancestor.");g.push(d),y=typeof d.parentId=="string"?d.parentId:null}g.reverse();let m=[];for(let d of g){let E=String(d.id),S={occurredAt:F(d.timestamp),parentId:typeof d.parentId=="string"?d.parentId:null};if(d.type==="compaction"||d.type==="branch_summary"){m.push(I({...S,id:E,kind:"compaction",content:T({summary:d.summary,firstKeptEntryId:d.firstKeptEntryId})}));continue}if(d.type!=="message")continue;let b=_(d.message),N=b.role;if(N==="toolResult"){m.push(I({...S,id:E,kind:"tool_result",role:"tool",callId:typeof b.toolCallId=="string"?b.toolCallId:null,content:T({content:b.content,isError:b.isError===!0})}));continue}if(N!=="user"&&N!=="assistant"&&N!=="system"){m.push(I({...S,id:E,kind:"unknown",content:T({role:N,content:b.content})}));continue}let v=Array.isArray(b.content)?b.content.map(_):[],A=typeof b.content=="string"?b.content:v.filter(R=>R.type==="text").map(R=>String(R.text??"")).join(`
8
+ `),M=_(b.usage),x=z({input_tokens:M.input,output_tokens:M.output,cached_input_tokens:M.cacheRead,total_tokens:M.totalTokens},E);A||N!=="assistant"?m.push(I({...S,id:E,kind:"message",role:N,content:N==="system"&&!A&&b.sections?T(b.sections):A,usage:x})):x&&m.push(I({...S,id:`${E}:usage`,kind:"usage",content:null,usage:x}));for(let[R,C]of v.entries())C.type==="toolCall"?m.push(I({...S,id:`${E}:call:${R}`,kind:"tool_call",callId:typeof C.id=="string"?C.id:null,content:T({name:C.name,arguments:C.arguments})})):C.type!=="text"&&C.type!=="thinking"&&m.push(I({...S,id:`${E}:block:${R}`,kind:"unknown",content:T(C)}));N==="assistant"&&["stop","error","aborted"].includes(String(b.stopReason))&&m.push(I({...S,id:`${E}:terminal`,kind:"terminal",content:{status:b.stopReason==="stop"?"completed":b.stopReason==="aborted"?"cancelled":"failed"}}))}return U({origin:t,sessionId:i.id,branchId:null,...t==="openclaw"?{contextComplete:!1}:{},files:[s],events:m,exporterVersion:`session-v${i.version}`,warnings:["Only the selected branch is included. Private provider payloads and credential metadata are excluded."]})}p(mt,"parsePiSession");function gt(s,e){let t=_(e),n=_(t.info);if(typeof n.id!="string"||!Array.isArray(t.messages))throw new Error("OpenCode requires its native JSON session export (info and messages).");let r=[];for(let i of t.messages){let a=_(i),o=_(a.info),l=_(o.time);if(typeof o.id!="string"||o.sessionID!==n.id||!Array.isArray(a.parts))throw new Error("OpenCode message identity does not match its session.");let c=o.role;if(c!=="user"&&c!=="assistant")throw new Error("Unsupported OpenCode message role.");let f={occurredAt:F(l.created),parentId:typeof o.parentID=="string"?o.parentID:null},u=a.parts.map(_);if(u.some(m=>m.sessionID!==n.id||m.messageID!==o.id||typeof m.id!="string"))throw new Error("OpenCode part identity does not match its message.");let h=u.filter(m=>m.type==="text").map(m=>String(m.text??"")).join(`
9
+ `),g=_(o.tokens),w=_(g.cache),y=z({input_tokens:g.input,output_tokens:g.output,cached_input_tokens:w.read,total_tokens:g.total},o.id);h||c==="user"?r.push(I({...f,id:o.id,kind:"message",role:c,content:h,usage:y})):y&&r.push(I({...f,id:`${o.id}:usage`,kind:"usage",content:null,usage:y}));for(let m of u){let d=String(m.id);if(m.type==="tool"){let E=_(m.state),S=typeof m.callID=="string"?m.callID:null;r.push(I({...f,id:`${d}:call`,kind:"tool_call",callId:S,content:T({name:m.tool,arguments:E.input})})),(E.status==="completed"||E.status==="error")&&r.push(I({...f,id:`${d}:result`,kind:"tool_result",role:"tool",callId:S,content:T({output:E.output,error:E.error,status:E.status})}))}else m.type==="compaction"?r.push(I({...f,id:d,kind:"compaction",content:T(m)})):["text","reasoning","step-start","step-finish"].includes(String(m.type))||r.push(I({...f,id:d,kind:"unknown",content:T(m)}))}c==="assistant"&&(o.finish==="stop"||o.error)&&r.push(I({...f,id:`${o.id}:terminal`,kind:"terminal",content:{status:o.error?"failed":"completed"}}))}return U({origin:"opencode",sessionId:n.id,parentSessionId:typeof n.parentID=="string"?n.parentID:null,exporterVersion:typeof n.version=="string"?n.version:null,files:[s],events:r,warnings:["Source-reported usage is not an OpenPond billing receipt."]})}p(gt,"parseOpenCodeSession");var We="codex-native-authorization-v1",Cs=We;function yt(s){let e=[],t=p((i,a,o)=>{let l={policy:Cs,sourcePath:i,sourceHash:O(a),entries:o};return e.push(l),l},"omit"),n=p((i,a)=>i.replace(/<permissions instructions>[\s\S]*?<\/permissions instructions>/gu,o=>o.replace(/^## Approved command prefixes\r?\n[\s\S]*?(?=^## |<\/permissions instructions>)/gmu,l=>{let c=t(a,l,null);return`## Approved command prefixes
10
10
  [Native authorization rules omitted; policy ${c.policy}; source hash ${c.sourceHash}]
11
- `})),"permissionsText"),r=_(s.payload);if(s.type==="response_item"&&r.type==="message"&&["system","developer"].includes(String(r.role))){let i=typeof r.content=="string"?n(r.content,"/payload/content"):Array.isArray(r.content)?r.content.map((a,o)=>{let l=_(a);return typeof l.text=="string"?{...l,text:n(l.text,`/payload/content/${o}/text`)}:a}):r.content;return{row:{...s,payload:{...r,content:i}},omissions:e}}if(s.type==="world_state"){let i=_(r.state),a=_(i.permissions);if(Array.isArray(a.approved_command_prefixes)){let o=t("/payload/state/permissions/approved_command_prefixes",a.approved_command_prefixes,a.approved_command_prefixes.length);return{row:{...s,payload:{...r,state:{...i,permissions:{...a,approved_command_prefixes:{omitted:"native_authorization_state",...o}}}}},omissions:e}}}return{row:s,omissions:e}}p(It,"projectCodexAuthorization");var de=class{static{p(this,"CodexMetadataChain")}metadata=null;parentId=null;closed=!1;ids=new Set;accept(e){if(e.type!=="session_meta")return this.closed=!0,!0;let t=e.payload;if(this.closed||!t||typeof t!="object"||Array.isArray(t))return!1;let n=t;if(typeof n.id!="string"||!n.id||n.id.length>500||this.ids.has(n.id)||this.ids.size>=16)return!1;if(this.metadata){if(n.id!==this.parentId)return!1;for(let r of["creator_user_id","creator_account_id"])if(this.metadata[r]!=null&&n[r]!=null&&this.metadata[r]!==n[r])return!1}else this.metadata=n;return this.ids.add(n.id),this.parentId=typeof n.forked_from_id=="string"?n.forked_from_id:null,!0}};function Ot(s,e){let t=new de;if(e.some(c=>!t.accept(c)))throw new Error("Codex rollout metadata does not match its declared fork ancestry.");let n=t.metadata??{};if(typeof n.id!="string")throw new Error("This is not a supported Codex rollout: session_meta.id is missing.");let r=_(n.git),i=typeof r.commit_hash=="string"&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(r.commit_hash)?{schemaVersion:"openpond.connectedRepositoryContext.v1",kind:"git",commitHash:r.commit_hash,branch:typeof r.branch=="string"&&r.branch.length>0&&r.branch.length<=500?r.branch:null,recordedAt:F(n.timestamp),sourceFileHash:Ge(s).contentHash,metadataHash:O(r)}:void 0;i&&typeof n.cwd=="string"&&Object.assign(i,{workingDirectoryHash:O(n.cwd)});let a=[],o=null,l=0;for(let[c,f]of e.entries()){let u=It(f);l+=u.omissions.length;let h=_(u.row.payload);if(f.type==="session_meta")continue;if(f.type==="turn_context"){o=typeof h.turn_id=="string"?h.turn_id:o;continue}let w={id:typeof h.id=="string"?h.id:`codex-event-${O([c,f]).slice(0,32)}`,occurredAt:F(f.timestamp),parentId:o};if(f.type==="response_item")h.type==="message"&&["user","assistant","system","developer"].includes(String(h.role))?a.push(I({...w,kind:"message",role:h.role==="developer"?"system":h.role,content:T(h.content)})):h.type==="function_call"||h.type==="custom_tool_call"?a.push(I({...w,kind:"tool_call",callId:typeof h.call_id=="string"?h.call_id:null,content:T(h)})):h.type==="function_call_output"||h.type==="custom_tool_call_output"?a.push(I({...w,kind:"tool_result",role:"tool",callId:typeof h.call_id=="string"?h.call_id:null,content:T(h.output)})):a.push(I({...w,kind:"unknown",content:T(h)}));else if(f.type==="compacted")a.push(I({...w,kind:"compaction",content:T(h)}));else if(f.type==="event_msg"){if(["user_message","agent_message","agent_reasoning","task_started"].includes(String(h.type)))continue;if(h.type==="task_complete"||h.type==="turn_aborted")a.push(I({...w,kind:"terminal",content:{status:h.type==="task_complete"?"completed":"cancelled",source:T(h)}}));else if(h.type==="token_count"){let y=_(h.info),m=z(y.total_token_usage,`codex-cumulative:${n.id}:${c}`,"reported_cumulative");a.push(I({...w,kind:"usage",usage:m,content:T(h)}))}else a.push(I({...w,kind:"unknown",content:T(h)}))}else a.push(I({...w,kind:"unknown",content:T(u.row)}))}return U({origin:"codex",sessionId:n.id,parentSessionId:typeof n.forked_from_id=="string"?n.forked_from_id:null,exporterVersion:typeof n.cli_version=="string"?n.cli_version:null,files:[s],events:a,...i?{repositoryContext:i}:{},warnings:["Codex cumulative usage is retained as reported totals and is not summed as billed invocations.","Referenced files are unavailable unless separately admitted.",...l?[`Codex native authorization state excluded by codex-native-authorization-v1 from ${l} locations. Omission markers retain source-section hashes; sourceFiles retains original byte hashes. Other conversation evidence is unchanged and still requires privacy admission.`]:[]]})}p(Ot,"parseCodexSession");function Ce(s){let e=s.filter(u=>(u.type==="user"||u.type==="assistant")&&typeof u.uuid=="string"),t=new Set(e.flatMap(u=>typeof u.sessionId=="string"?[u.sessionId]:[]));if(t.size!==1||!e.length)throw new Error("A supported Claude Code transcript must identify one session with UUID messages.");let n=[...t][0],r=s.filter(u=>typeof u.uuid=="string"&&u.sessionId===n),i=new Map(r.map(u=>[u.uuid,u]));if(i.size!==r.length)throw new Error("Claude Code transcript contains duplicate message UUIDs.");let a=new Set(r.flatMap(u=>typeof u.parentUuid=="string"?[u.parentUuid]:[])),o=r.filter(u=>!a.has(u.uuid));if(!o.length)throw new Error("Claude Code transcript has no selectable branch leaf.");function l(u){let h=i.get(u);if(!h)throw new Error("The selected Claude Code branch leaf is missing.");let g=[],w=new Set,y=!1;for(;h;){let m=h.uuid;if(w.has(m))throw new Error("Claude Code branch contains a parent cycle.");w.add(m),g.unshift(h);let d=h.parentUuid;if(typeof d!="string")break;h=i.get(d),h||(y=!0)}return{chain:g,missingParent:y,chainHash:O(g)}}p(l,"select");function c(){if(o.length>256)throw new Error("This transcript exceeds the 256-branch inspection limit.");return o.map(u=>{let h=l(u.uuid),g=h.chain.filter(d=>d.type==="user"||d.type==="assistant"),w=g.at(-1),y=_(w?.message).content,m=typeof y=="string"?y:Array.isArray(y)?y.flatMap(d=>typeof _(d).text=="string"?[_(d).text]:[]).join(" "):"";return{leafId:u.uuid,chainHash:h.chainHash,title:m.slice(0,180),updatedAt:F(w?.timestamp),messages:g.length}})}p(c,"branches");function f(){let u=new Set;for(let w of o){let y=w,m=new Set;for(;y;){let d=y.uuid;if(m.has(d))throw new Error("Claude Code branch contains a parent cycle.");if(m.add(d),y.type==="user"||y.type==="assistant"){u.add(d);break}y=typeof y.parentUuid=="string"?i.get(y.parentUuid):void 0}}let h,g;for(let w of r){let y=w.uuid;u.has(y)&&(g=y,!w.isSidechain&&!w.teamName&&!w.isMeta&&(h=y))}if(!h&&!g)throw new Error("Claude Code transcript has no conversation message.");return h??g}return p(f,"latestLeafId"),{sessionId:n,leaves:o,select:l,branches:c,latestLeafId:f}}p(Ce,"claudeGraph");function Tt(s,e,t){let n=Ce(e);if(!t&&n.leaves.length!==1)throw new Error("This transcript has multiple branches. Select a branch leaf UUID before importing.");let{chain:r,missingParent:i}=n.select(t??n.leaves[0].uuid),a=[];for(let o of r){if(o.type!=="user"&&o.type!=="assistant")continue;let l=_(o.message),c=l.content,f={occurredAt:F(o.timestamp),parentId:typeof o.parentUuid=="string"?o.parentUuid:null},u=o.type==="user"?"user":"assistant",h=Array.isArray(c)?c:[{type:"text",text:c}],g=h.filter(w=>_(w).type==="text");g.length&&a.push(I({...f,id:o.uuid,kind:"message",role:u,content:T(g)})),u==="assistant"&&l.usage&&a.push(I({...f,id:`${o.uuid}:usage`,kind:"usage",content:T(l.usage),usage:z(l.usage,typeof l.id=="string"?l.id:o.uuid)}));for(let[w,y]of h.entries()){let m=_(y);if(m.type==="text"||m.type==="thinking"||m.type==="redacted_thinking")continue;let d=`${o.uuid}:${w}`;m.type==="tool_use"?a.push(I({...f,id:d,kind:"tool_call",callId:typeof m.id=="string"?m.id:null,content:T(m)})):m.type==="tool_result"?a.push(I({...f,id:d,kind:"tool_result",role:"tool",callId:typeof m.tool_use_id=="string"?m.tool_use_id:null,content:T({...m,...o.tool_use_result!==void 0?{nativeToolResult:o.tool_use_result}:{}})})):a.push(I({...f,id:d,kind:"unknown",content:T(m)}))}l.stop_reason==="end_turn"&&a.push(I({...f,id:`${o.uuid}:terminal`,kind:"terminal",content:{status:"completed"}}))}return e.some(o=>o.type==="system"&&o.subtype==="compact_boundary")&&a.unshift(I({id:`compaction-${O(e.filter(o=>o.subtype==="compact_boundary")).slice(0,32)}`,kind:"compaction",content:{source:"claude_compact_boundary"}})),U({origin:"claude_code",sessionId:n.sessionId,branchId:null,parentSessionId:typeof r[0]?.parentSessionId=="string"?r[0].parentSessionId:null,exporterVersion:typeof r.at(-1)?.version=="string"?r.at(-1).version:null,files:[s],events:a,contextComplete:!i,warnings:[...i?["The transcript omits an ancestor; complete context is unavailable."]:[],...r.some(o=>o.isSidechain)?["This is a subagent/sidechain transcript; parent context is not implicitly imported."]:[],"Claude Code transcript schema is internal; only the declared message shapes are normalized."]})}p(Tt,"parseClaudeSession");function Nt(s,e){let t=[];for(let[n,r]of s.entries()){let i=_(r),a=typeof i.entryId=="string"?i.entryId:typeof i.id=="string"?i.id:typeof i.id=="number"&&Number.isSafeInteger(i.id)?String(i.id):typeof i.message_id=="string"?i.message_id:`${e}-${O([n,i]).slice(0,32)}`,o={occurredAt:F(i.timestamp,e==="hermes"?"seconds":"milliseconds"),parentId:typeof i.parentId=="string"?i.parentId:null};if(i.role==="tool"){t.push(I({...o,id:a,kind:"tool_result",role:"tool",callId:typeof i.tool_call_id=="string"?i.tool_call_id:null,content:T(i.content)}));continue}if(!["user","assistant","system"].includes(String(i.role))){t.push(I({...o,id:a,kind:"unknown",content:T(i)}));continue}if(t.push(I({...o,id:a,kind:"message",role:i.role,content:T(i.content),usage:z(i.usage,a)})),Array.isArray(i.tool_calls))for(let[l,c]of i.tool_calls.entries()){let f=_(c);t.push(I({...o,id:`${a}:call:${l}`,kind:"tool_call",callId:typeof f.id=="string"?f.id:null,content:T(f)}))}(i.finish_reason==="stop"||i.stop_reason==="end_turn")&&t.push(I({...o,id:`${a}:terminal`,kind:"terminal",content:{status:"completed"}}))}return t}p(Nt,"historyEvents");function xt(s,e){let t=typeof e.id=="string"?e.id:typeof e.session_id=="string"?e.session_id:null;if(!t||!Array.isArray(e.messages))throw new Error("Hermes requires a full-session export with id or session_id and messages.");if(e.message_count!==void 0&&e.message_count!==e.messages.length)throw new Error("Hermes full-session message count differs from the retained messages.");let n=Array.isArray(e.lineage_session_ids)?e.lineage_session_ids.find(i=>typeof i=="string"&&i):null,r=Nt(e.messages,"hermes");return typeof e.system_prompt=="string"&&e.system_prompt.trim()&&r.unshift(I({id:`hermes-system-${O(e.system_prompt).slice(0,32)}`,kind:"message",role:"system",content:e.system_prompt})),U({origin:"hermes",sessionId:t,parentSessionId:typeof n=="string"?n:typeof e.parent_session_id=="string"?e.parent_session_id:null,exporterVersion:typeof e.version=="string"?e.version:null,files:[s],events:r,warnings:["Reported usage is not an OpenPond billing receipt.","Exporter redaction and missing tools/artifacts remain evidence gaps.",...e.session_id&&!e.id?["This is a Hermes session backup. Exporter version and terminal receipts may be unavailable."]:[]]})}p(xt,"parseHermesEvidence");function Ct(s){let e=p(u=>{let h=s.find(g=>g.path===u);if(!h)throw new Error(`OpenClaw bundle is missing ${u}.`);return h},"read"),t=_(JSON.parse(e("manifest.json").text)),n=_(JSON.parse(e("session-branch.json").text)),r=e("events.jsonl"),i=Q(r);if(t.traceSchema!=="openclaw-trajectory"||t.schemaVersion!==1||typeof t.sessionId!="string"||typeof t.traceId!="string")throw new Error("Unsupported OpenClaw trajectory manifest.");if(t.leafId!==n.leafId||t.eventCount!==i.length||i.some(u=>u.traceSchema!==t.traceSchema||u.schemaVersion!==1||u.sessionId!==t.sessionId||u.traceId!==t.traceId))throw new Error("OpenClaw bundle identity/count does not match its manifest.");if(!Array.isArray(n.entries))throw new Error("OpenClaw active branch entries are missing.");if(n.header&&_(n.header).id!==t.sessionId)throw new Error("OpenClaw branch header differs from the manifest session.");let a=new Set,o=[];for(let[u,h]of n.entries.entries()){let g=_(h);if(typeof g.id!="string"||a.has(g.id)||u>0&&g.parentId!==_(n.entries[u-1]).id)throw new Error("OpenClaw active branch is duplicate, incomplete or unordered.");a.add(g.id),g.type==="message"&&o.push({..._(g.message),entryId:g.id,parentId:g.parentId??null,timestamp:g.timestamp??_(g.message).timestamp})}if(n.entries.length&&_(n.entries.at(-1)).id!==n.leafId)throw new Error("OpenClaw branch does not reach its leaf.");let l=Nt(o,"openclaw"),c=[],f=new Set;for(let[u,h]of i.entries()){if(!Number.isSafeInteger(h.seq)||h.seq<0||f.has(h.seq)||u>0&&Number(i[u-1].seq)>=Number(h.seq))throw new Error("OpenClaw events have invalid/duplicate/unordered sequences.");f.add(h.seq),c.push(I({id:`trajectory:${t.traceId}:${h.seq}`,kind:"unknown",occurredAt:F(h.ts),content:T(h)}))}return U({origin:"openclaw",sessionId:t.sessionId,files:s,events:l,unmappedEvents:c,exporterVersion:typeof t.openclawVersion=="string"?t.openclawVersion:null,warnings:["Raw trajectory events are retained; unqualified event types are not advertised as complete process grading.",...Array.isArray(t.warnings)?t.warnings.map(u=>typeof _(u).message=="string"?String(_(u).message).slice(0,500):"The source exporter reports incomplete evidence."):[]].slice(0,100)})}p(Ct,"parseOpenClawEvidence");function Re(s){return s==="codex"?`${Ee}/${Xe}/fork-repository-starting-state-v1`:Ee}p(Re,"agentImportNormalizerRevision");function Rt(s){if(!s.files.length||s.files.length>$.files)throw new Error("Choose between 1 and 100 source files.");let e=new Set,t=0;for(let o of s.files){if(o.path.length>500||o.path.startsWith("/")||o.path.includes("\\")||o.path.split("/").some(l=>!l||l==="."||l==="..")||e.has(o.path))throw new Error("Unsafe or duplicate source file path.");e.add(o.path),t+=new TextEncoder().encode(o.text).length}if(t>$.decodedBytes)throw new Error("Decoded source files exceed 64 MiB.");let n=[],r=[],i=p((o,l)=>{try{n.push(...l().map(c=>s.acquisition?U({origin:c.origin,sessionId:c.sessionId,branchId:c.branchId,parentSessionId:c.parentSessionId,exporterVersion:c.exporterVersion,files:s.files.filter(f=>c.sourceFiles.some(u=>u.path===f.path)),events:c.events,unmappedEvents:c.unmappedEvents,warnings:c.warnings,contextComplete:!c.boundaries.some(f=>f.coverage.context==="unknown"),acquisition:s.acquisition,...c.repositoryContext?{repositoryContext:c.repositoryContext}:{}}):c))}catch(c){r.push({file:o,...c instanceof Se?{code:"no_user_request"}:{},message:c instanceof Error?c.message:"Unsupported session."})}},"attempt");if(s.source==="openclaw"&&s.files.some(o=>o.path.endsWith("manifest.json")))i("manifest.json",()=>{let o=s.files[0].path.split("/")[0],l=!s.files.some(c=>c.path==="manifest.json")&&s.files.every(c=>c.path.startsWith(`${o}/`))?s.files.map(c=>({...c,path:c.path.slice(o.length+1)})):s.files;return[Ct(l)]});else for(let o of s.files)i(o.path,()=>{if(s.source==="opencode")return[vt(o,JSON.parse(o.text))];let l;if(s.source==="hermes"&&o.path.endsWith(".json")){let c=JSON.parse(o.text.replace(/^\uFEFF/u,""));if(!c||typeof c!="object"||Array.isArray(c))throw new Error("Hermes session backup must be one JSON object.");l=[c]}else l=Q(o);if(s.source==="grok_build")return[_t(o,l)];if(s.source==="pi"||s.source==="oh_my_pi"||s.source==="openclaw")return[bt(o,l,s.source,s.branchLeafId)];if(s.source==="codex")return[Ot(o,l)];if(s.source==="claude_code")return[Tt(o,l,s.branchLeafId)];if(s.source==="hermes")return l.map(c=>xt(o,c));throw new Error("Unsupported source adapter.")});if(n.length>$.sessions||n.reduce((o,l)=>o+l.events.length+l.unmappedEvents.length,0)>$.events||n.reduce((o,l)=>o+l.boundaries.length,0)>$.boundaries)throw new Error("Import exceeds the session/event/boundary limit.");let a=new Map;for(let o of n){let l=JSON.stringify([o.origin,o.sessionId,o.branchId]),c=a.get(l);if(c&&c!==o.contentHash)throw new Error("The same session has different contents in this selection. Choose one export.");a.set(l,o.contentHash)}return{schemaVersion:"openpond.agentImportPreview.v1",source:s.source,sourceHash:O({source:s.source,files:[...s.files].sort((o,l)=>o.path.localeCompare(l.path)),branchLeafId:s.branchLeafId??null}),sessions:n.filter((o,l)=>n.findIndex(c=>c.contentHash===o.contentHash)===l),issues:r}}p(Rt,"previewAgentImport");import{open as Ys,lstat as Vs,readdir as Zs,readFile as Qs,realpath as Jt,stat as Xt}from"node:fs/promises";import{basename as ee,dirname as Ke,isAbsolute as Ye,join as ke,relative as en,resolve as tn,sep as sn}from"node:path";import{zstdDecompressSync as nn}from"node:zlib";import{DatabaseSync as Js}from"node:sqlite";import{join as Gs}from"node:path";import{DatabaseSync as Ws}from"node:sqlite";import{zstdDecompressSync as $t}from"node:zlib";import{createHash as zs}from"node:crypto";import{createHash as Fs}from"node:crypto";import{readFileSync as Us,realpathSync as At,statSync as qs}from"node:fs";import{basename as Bs,dirname as Lt,join as kt,relative as Ps,sep as Dt}from"node:path";import{zstdDecompressSync as js}from"node:zlib";function Mt(s,e,t){let n=s.prepare("SELECT generation,archive_name,archive_sha256,event_count,raw_bytes,archive_bytes,last_seq,storage,length(archive_blob) AS blob_bytes FROM session_transcript_cold_archives WHERE session_id=?").get(t);if(!n)return null;if(Number(n.archive_bytes)>L||Number(n.raw_bytes)>L||Number(n.event_count)>1e5)throw new Error("OpenClaw cold archive exceeds the retained size limit.");let r;if(n.storage==="sqlite"){if(Number(n.blob_bytes)!==Number(n.archive_bytes))throw new Error("OpenClaw cold archive size differs from its receipt.");let h=s.prepare("SELECT archive_blob FROM session_transcript_cold_archives WHERE session_id=?").get(t);if(!(h.archive_blob instanceof Uint8Array))throw new Error("OpenClaw cold archive is unavailable.");r=h.archive_blob}else if(n.storage==="file"){let h=String(n.archive_name);if(!/^[a-f0-9]{64}\.jsonl\.zst$/.test(h))throw new Error("Invalid OpenClaw cold archive name.");let g=Lt(e.root),w=Bs(g)==="agent"?kt(Lt(g),"sessions"):g,y=At(w),m=At(kt(w,"cold",h)),d=Ps(y,m);if(d===".."||d.startsWith(`..${Dt}`)||d.startsWith(Dt))throw new Error("OpenClaw cold archive leaves the selected agent directory.");let E=qs(m);if(!E.isFile()||E.size!==Number(n.archive_bytes))throw new Error("OpenClaw cold archive size differs from its receipt.");r=Us(m)}else throw new Error("Unsupported OpenClaw cold archive storage.");if(r.length!==Number(n.archive_bytes)||Fs("sha256").update(r).digest("hex")!==n.archive_sha256)throw new Error("OpenClaw cold archive checksum differs from its receipt.");let i=js(r,{maxOutputLength:L}),a=new TextDecoder("utf8",{fatal:!0}).decode(i).trimEnd().split(`
11
+ `})),"permissionsText"),r=_(s.payload);if(s.type==="response_item"&&r.type==="message"&&["system","developer"].includes(String(r.role))){let i=typeof r.content=="string"?n(r.content,"/payload/content"):Array.isArray(r.content)?r.content.map((a,o)=>{let l=_(a);return typeof l.text=="string"?{...l,text:n(l.text,`/payload/content/${o}/text`)}:a}):r.content;return{row:{...s,payload:{...r,content:i}},omissions:e}}if(s.type==="world_state"){let i=_(r.state),a=_(i.permissions);if(Array.isArray(a.approved_command_prefixes)){let o=t("/payload/state/permissions/approved_command_prefixes",a.approved_command_prefixes,a.approved_command_prefixes.length);return{row:{...s,payload:{...r,state:{...i,permissions:{...a,approved_command_prefixes:{omitted:"native_authorization_state",...o}}}}},omissions:e}}}return{row:s,omissions:e}}p(yt,"projectCodexAuthorization");var de=class{static{p(this,"CodexMetadataChain")}metadata=null;parentId=null;closed=!1;ids=new Set;accept(e){if(e.type!=="session_meta")return this.closed=!0,!0;let t=e.payload;if(this.closed||!t||typeof t!="object"||Array.isArray(t))return!1;let n=t;if(typeof n.id!="string"||!n.id||n.id.length>500||this.ids.has(n.id)||this.ids.size>=16)return!1;if(this.metadata){if(n.id!==this.parentId)return!1;for(let r of["creator_user_id","creator_account_id"])if(this.metadata[r]!=null&&n[r]!=null&&this.metadata[r]!==n[r])return!1}else this.metadata=n;return this.ids.add(n.id),this.parentId=typeof n.forked_from_id=="string"?n.forked_from_id:null,!0}};function Et(s,e){let t=new de;if(e.some(c=>!t.accept(c)))throw new Error("Codex rollout metadata does not match its declared fork ancestry.");let n=t.metadata??{};if(typeof n.id!="string")throw new Error("This is not a supported Codex rollout: session_meta.id is missing.");let r=_(n.git),i=typeof r.commit_hash=="string"&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(r.commit_hash)?{schemaVersion:"openpond.connectedRepositoryContext.v1",kind:"git",commitHash:r.commit_hash,branch:typeof r.branch=="string"&&r.branch.length>0&&r.branch.length<=500?r.branch:null,recordedAt:F(n.timestamp),sourceFileHash:je(s).contentHash,metadataHash:O(r)}:void 0;i&&typeof n.cwd=="string"&&Object.assign(i,{workingDirectoryHash:O(n.cwd)});let a=[],o=null,l=0;for(let[c,f]of e.entries()){let u=yt(f);l+=u.omissions.length;let h=_(u.row.payload);if(f.type==="session_meta")continue;if(f.type==="turn_context"){o=typeof h.turn_id=="string"?h.turn_id:o;continue}let w={id:typeof h.id=="string"?h.id:`codex-event-${O([c,f]).slice(0,32)}`,occurredAt:F(f.timestamp),parentId:o};if(f.type==="response_item")h.type==="message"&&["user","assistant","system","developer"].includes(String(h.role))?a.push(I({...w,kind:"message",role:h.role==="developer"?"system":h.role,content:T(h.content)})):h.type==="function_call"||h.type==="custom_tool_call"?a.push(I({...w,kind:"tool_call",callId:typeof h.call_id=="string"?h.call_id:null,content:T(h)})):h.type==="function_call_output"||h.type==="custom_tool_call_output"?a.push(I({...w,kind:"tool_result",role:"tool",callId:typeof h.call_id=="string"?h.call_id:null,content:T(h.output)})):a.push(I({...w,kind:"unknown",content:T(h)}));else if(f.type==="compacted")a.push(I({...w,kind:"compaction",content:T(h)}));else if(f.type==="event_msg"){if(["user_message","agent_message","agent_reasoning","task_started"].includes(String(h.type)))continue;if(h.type==="task_complete"||h.type==="turn_aborted")a.push(I({...w,kind:"terminal",content:{status:h.type==="task_complete"?"completed":"cancelled",source:T(h)}}));else if(h.type==="token_count"){let y=_(h.info),m=z(y.total_token_usage,`codex-cumulative:${n.id}:${c}`,"reported_cumulative");a.push(I({...w,kind:"usage",usage:m,content:T(h)}))}else a.push(I({...w,kind:"unknown",content:T(h)}))}else a.push(I({...w,kind:"unknown",content:T(u.row)}))}return U({origin:"codex",sessionId:n.id,parentSessionId:typeof n.forked_from_id=="string"?n.forked_from_id:null,exporterVersion:typeof n.cli_version=="string"?n.cli_version:null,files:[s],events:a,...i?{repositoryContext:i}:{},warnings:["Codex cumulative usage is retained as reported totals and is not summed as billed invocations.","Referenced files are unavailable unless separately admitted.",...l?[`Codex native authorization state excluded by codex-native-authorization-v1 from ${l} locations. Omission markers retain source-section hashes; sourceFiles retains original byte hashes. Other conversation evidence is unchanged and still requires privacy admission.`]:[]]})}p(Et,"parseCodexSession");function Ne(s){let e=s.filter(u=>(u.type==="user"||u.type==="assistant")&&typeof u.uuid=="string"),t=new Set(e.flatMap(u=>typeof u.sessionId=="string"?[u.sessionId]:[]));if(t.size!==1||!e.length)throw new Error("A supported Claude Code transcript must identify one session with UUID messages.");let n=[...t][0],r=s.filter(u=>typeof u.uuid=="string"&&u.sessionId===n),i=new Map(r.map(u=>[u.uuid,u]));if(i.size!==r.length)throw new Error("Claude Code transcript contains duplicate message UUIDs.");let a=new Set(r.flatMap(u=>typeof u.parentUuid=="string"?[u.parentUuid]:[])),o=r.filter(u=>!a.has(u.uuid));if(!o.length)throw new Error("Claude Code transcript has no selectable branch leaf.");function l(u){let h=i.get(u);if(!h)throw new Error("The selected Claude Code branch leaf is missing.");let g=[],w=new Set,y=!1;for(;h;){let m=h.uuid;if(w.has(m))throw new Error("Claude Code branch contains a parent cycle.");w.add(m),g.unshift(h);let d=h.parentUuid;if(typeof d!="string")break;h=i.get(d),h||(y=!0)}return{chain:g,missingParent:y,chainHash:O(g)}}p(l,"select");function c(){if(o.length>256)throw new Error("This transcript exceeds the 256-branch inspection limit.");return o.map(u=>{let h=l(u.uuid),g=h.chain.filter(d=>d.type==="user"||d.type==="assistant"),w=g.at(-1),y=_(w?.message).content,m=typeof y=="string"?y:Array.isArray(y)?y.flatMap(d=>typeof _(d).text=="string"?[_(d).text]:[]).join(" "):"";return{leafId:u.uuid,chainHash:h.chainHash,title:m.slice(0,180),updatedAt:F(w?.timestamp),messages:g.length}})}p(c,"branches");function f(){let u=new Set;for(let w of o){let y=w,m=new Set;for(;y;){let d=y.uuid;if(m.has(d))throw new Error("Claude Code branch contains a parent cycle.");if(m.add(d),y.type==="user"||y.type==="assistant"){u.add(d);break}y=typeof y.parentUuid=="string"?i.get(y.parentUuid):void 0}}let h,g;for(let w of r){let y=w.uuid;u.has(y)&&(g=y,!w.isSidechain&&!w.teamName&&!w.isMeta&&(h=y))}if(!h&&!g)throw new Error("Claude Code transcript has no conversation message.");return h??g}return p(f,"latestLeafId"),{sessionId:n,leaves:o,select:l,branches:c,latestLeafId:f}}p(Ne,"claudeGraph");function wt(s,e,t){let n=Ne(e);if(!t&&n.leaves.length!==1)throw new Error("This transcript has multiple branches. Select a branch leaf UUID before importing.");let{chain:r,missingParent:i}=n.select(t??n.leaves[0].uuid),a=[];for(let o of r){if(o.type!=="user"&&o.type!=="assistant")continue;let l=_(o.message),c=l.content,f={occurredAt:F(o.timestamp),parentId:typeof o.parentUuid=="string"?o.parentUuid:null},u=o.type==="user"?"user":"assistant",h=Array.isArray(c)?c:[{type:"text",text:c}],g=h.filter(w=>_(w).type==="text");g.length&&a.push(I({...f,id:o.uuid,kind:"message",role:u,content:T(g)})),u==="assistant"&&l.usage&&a.push(I({...f,id:`${o.uuid}:usage`,kind:"usage",content:T(l.usage),usage:z(l.usage,typeof l.id=="string"?l.id:o.uuid)}));for(let[w,y]of h.entries()){let m=_(y);if(m.type==="text"||m.type==="thinking"||m.type==="redacted_thinking")continue;let d=`${o.uuid}:${w}`;m.type==="tool_use"?a.push(I({...f,id:d,kind:"tool_call",callId:typeof m.id=="string"?m.id:null,content:T(m)})):m.type==="tool_result"?a.push(I({...f,id:d,kind:"tool_result",role:"tool",callId:typeof m.tool_use_id=="string"?m.tool_use_id:null,content:T({...m,...o.tool_use_result!==void 0?{nativeToolResult:o.tool_use_result}:{}})})):a.push(I({...f,id:d,kind:"unknown",content:T(m)}))}l.stop_reason==="end_turn"&&a.push(I({...f,id:`${o.uuid}:terminal`,kind:"terminal",content:{status:"completed"}}))}return e.some(o=>o.type==="system"&&o.subtype==="compact_boundary")&&a.unshift(I({id:`compaction-${O(e.filter(o=>o.subtype==="compact_boundary")).slice(0,32)}`,kind:"compaction",content:{source:"claude_compact_boundary"}})),U({origin:"claude_code",sessionId:n.sessionId,branchId:null,parentSessionId:typeof r[0]?.parentSessionId=="string"?r[0].parentSessionId:null,exporterVersion:typeof r.at(-1)?.version=="string"?r.at(-1).version:null,files:[s],events:a,contextComplete:!i,warnings:[...i?["The transcript omits an ancestor; complete context is unavailable."]:[],...r.some(o=>o.isSidechain)?["This is a subagent/sidechain transcript; parent context is not implicitly imported."]:[],"Claude Code transcript schema is internal; only the declared message shapes are normalized."]})}p(wt,"parseClaudeSession");function St(s,e){let t=[];for(let[n,r]of s.entries()){let i=_(r),a=typeof i.entryId=="string"?i.entryId:typeof i.id=="string"?i.id:typeof i.id=="number"&&Number.isSafeInteger(i.id)?String(i.id):typeof i.message_id=="string"?i.message_id:`${e}-${O([n,i]).slice(0,32)}`,o={occurredAt:F(i.timestamp,e==="hermes"?"seconds":"milliseconds"),parentId:typeof i.parentId=="string"?i.parentId:null};if(i.role==="tool"){t.push(I({...o,id:a,kind:"tool_result",role:"tool",callId:typeof i.tool_call_id=="string"?i.tool_call_id:null,content:T(i.content)}));continue}if(!["user","assistant","system"].includes(String(i.role))){t.push(I({...o,id:a,kind:"unknown",content:T(i)}));continue}if(t.push(I({...o,id:a,kind:"message",role:i.role,content:T(i.content),usage:z(i.usage,a)})),Array.isArray(i.tool_calls))for(let[l,c]of i.tool_calls.entries()){let f=_(c);t.push(I({...o,id:`${a}:call:${l}`,kind:"tool_call",callId:typeof f.id=="string"?f.id:null,content:T(f)}))}(i.finish_reason==="stop"||i.stop_reason==="end_turn")&&t.push(I({...o,id:`${a}:terminal`,kind:"terminal",content:{status:"completed"}}))}return t}p(St,"historyEvents");function _t(s,e){let t=typeof e.id=="string"?e.id:typeof e.session_id=="string"?e.session_id:null;if(!t||!Array.isArray(e.messages))throw new Error("Hermes requires a full-session export with id or session_id and messages.");if(e.message_count!==void 0&&e.message_count!==e.messages.length)throw new Error("Hermes full-session message count differs from the retained messages.");let n=Array.isArray(e.lineage_session_ids)?e.lineage_session_ids.find(i=>typeof i=="string"&&i):null,r=St(e.messages,"hermes");return typeof e.system_prompt=="string"&&e.system_prompt.trim()&&r.unshift(I({id:`hermes-system-${O(e.system_prompt).slice(0,32)}`,kind:"message",role:"system",content:e.system_prompt})),U({origin:"hermes",sessionId:t,parentSessionId:typeof n=="string"?n:typeof e.parent_session_id=="string"?e.parent_session_id:null,exporterVersion:typeof e.version=="string"?e.version:null,files:[s],events:r,warnings:["Reported usage is not an OpenPond billing receipt.","Exporter redaction and missing tools/artifacts remain evidence gaps.",...e.session_id&&!e.id?["This is a Hermes session backup. Exporter version and terminal receipts may be unavailable."]:[]]})}p(_t,"parseHermesEvidence");function bt(s){let e=p(u=>{let h=s.find(g=>g.path===u);if(!h)throw new Error(`OpenClaw bundle is missing ${u}.`);return h},"read"),t=_(JSON.parse(e("manifest.json").text)),n=_(JSON.parse(e("session-branch.json").text)),r=e("events.jsonl"),i=Q(r);if(t.traceSchema!=="openclaw-trajectory"||t.schemaVersion!==1||typeof t.sessionId!="string"||typeof t.traceId!="string")throw new Error("Unsupported OpenClaw trajectory manifest.");if(t.leafId!==n.leafId||t.eventCount!==i.length||i.some(u=>u.traceSchema!==t.traceSchema||u.schemaVersion!==1||u.sessionId!==t.sessionId||u.traceId!==t.traceId))throw new Error("OpenClaw bundle identity/count does not match its manifest.");if(!Array.isArray(n.entries))throw new Error("OpenClaw active branch entries are missing.");if(n.header&&_(n.header).id!==t.sessionId)throw new Error("OpenClaw branch header differs from the manifest session.");let a=new Set,o=[];for(let[u,h]of n.entries.entries()){let g=_(h);if(typeof g.id!="string"||a.has(g.id)||u>0&&g.parentId!==_(n.entries[u-1]).id)throw new Error("OpenClaw active branch is duplicate, incomplete or unordered.");a.add(g.id),g.type==="message"&&o.push({..._(g.message),entryId:g.id,parentId:g.parentId??null,timestamp:g.timestamp??_(g.message).timestamp})}if(n.entries.length&&_(n.entries.at(-1)).id!==n.leafId)throw new Error("OpenClaw branch does not reach its leaf.");let l=St(o,"openclaw"),c=[],f=new Set;for(let[u,h]of i.entries()){if(!Number.isSafeInteger(h.seq)||h.seq<0||f.has(h.seq)||u>0&&Number(i[u-1].seq)>=Number(h.seq))throw new Error("OpenClaw events have invalid/duplicate/unordered sequences.");f.add(h.seq),c.push(I({id:`trajectory:${t.traceId}:${h.seq}`,kind:"unknown",occurredAt:F(h.ts),content:T(h)}))}return U({origin:"openclaw",sessionId:t.sessionId,files:s,events:l,unmappedEvents:c,exporterVersion:typeof t.openclawVersion=="string"?t.openclawVersion:null,warnings:["Raw trajectory events are retained; unqualified event types are not advertised as complete process grading.",...Array.isArray(t.warnings)?t.warnings.map(u=>typeof _(u).message=="string"?String(_(u).message).slice(0,500):"The source exporter reports incomplete evidence."):[]].slice(0,100)})}p(bt,"parseOpenClawEvidence");function xe(s){return s==="codex"?`${Ee}/${We}/fork-repository-starting-state-v1`:Ee}p(xe,"agentImportNormalizerRevision");function vt(s){if(!s.files.length||s.files.length>$.files)throw new Error("Choose between 1 and 100 source files.");let e=new Set,t=0;for(let o of s.files){if(o.path.length>500||o.path.startsWith("/")||o.path.includes("\\")||o.path.split("/").some(l=>!l||l==="."||l==="..")||e.has(o.path))throw new Error("Unsafe or duplicate source file path.");e.add(o.path),t+=new TextEncoder().encode(o.text).length}if(t>$.decodedBytes)throw new Error("Decoded source files exceed 64 MiB.");let n=[],r=[],i=p((o,l)=>{try{n.push(...l().map(c=>s.acquisition?U({origin:c.origin,sessionId:c.sessionId,branchId:c.branchId,parentSessionId:c.parentSessionId,exporterVersion:c.exporterVersion,files:s.files.filter(f=>c.sourceFiles.some(u=>u.path===f.path)),events:c.events,unmappedEvents:c.unmappedEvents,warnings:c.warnings,contextComplete:!c.boundaries.some(f=>f.coverage.context==="unknown"),acquisition:s.acquisition,...c.repositoryContext?{repositoryContext:c.repositoryContext}:{}}):c))}catch(c){r.push({file:o,...c instanceof Se?{code:"no_user_request"}:{},message:c instanceof Error?c.message:"Unsupported session."})}},"attempt");if(s.source==="openclaw"&&s.files.some(o=>o.path.endsWith("manifest.json")))i("manifest.json",()=>{let o=s.files[0].path.split("/")[0],l=!s.files.some(c=>c.path==="manifest.json")&&s.files.every(c=>c.path.startsWith(`${o}/`))?s.files.map(c=>({...c,path:c.path.slice(o.length+1)})):s.files;return[bt(l)]});else for(let o of s.files)i(o.path,()=>{if(s.source==="opencode")return[gt(o,JSON.parse(o.text))];let l;if(s.source==="hermes"&&o.path.endsWith(".json")){let c=JSON.parse(o.text.replace(/^\uFEFF/u,""));if(!c||typeof c!="object"||Array.isArray(c))throw new Error("Hermes session backup must be one JSON object.");l=[c]}else l=Q(o);if(s.source==="grok_build")return[ht(o,l)];if(s.source==="pi"||s.source==="oh_my_pi"||s.source==="openclaw")return[mt(o,l,s.source,s.branchLeafId)];if(s.source==="codex")return[Et(o,l)];if(s.source==="claude_code")return[wt(o,l,s.branchLeafId)];if(s.source==="hermes")return l.map(c=>_t(o,c));throw new Error("Unsupported source adapter.")});if(n.length>$.sessions||n.reduce((o,l)=>o+l.events.length+l.unmappedEvents.length,0)>$.events||n.reduce((o,l)=>o+l.boundaries.length,0)>$.boundaries)throw new Error("Import exceeds the session/event/boundary limit.");let a=new Map;for(let o of n){let l=JSON.stringify([o.origin,o.sessionId,o.branchId]),c=a.get(l);if(c&&c!==o.contentHash)throw new Error("The same session has different contents in this selection. Choose one export.");a.set(l,o.contentHash)}return{schemaVersion:"openpond.agentImportPreview.v1",source:s.source,sourceHash:O({source:s.source,files:[...s.files].sort((o,l)=>o.path.localeCompare(l.path)),branchLeafId:s.branchLeafId??null}),sessions:n.filter((o,l)=>n.findIndex(c=>c.contentHash===o.contentHash)===l),issues:r}}p(vt,"previewAgentImport");var It={codex:"Codex",claude_code:"Claude Code",hermes:"Hermes",openclaw:"OpenClaw",opencode:"OpenCode",grok_build:"Grok Build",pi:"Pi",oh_my_pi:"Oh My Pi"},L=32*1024*1024;import{homedir as Ds}from"node:os";import{realpath as Rt,stat as Ge,readdir as Ms,readFile as $s}from"node:fs/promises";import{resolve as Xe,join as X,isAbsolute as Hs}from"node:path";import{opendir as Rs,readFile as As,stat as Re}from"node:fs/promises";import{basename as Ls,dirname as ks,join as k,resolve as ze}from"node:path";function Nt(s,e){let t=e.HERMES_HOME?.trim();if(t){let r=t.replace(/\$(\w+)|\$\{([^}]+)\}/gu,(i,a,o)=>e[a||o]??i);return ze(r==="~"?s:r.startsWith("~/")?k(s,r.slice(2)):r)}let n=e.HERMES_DATA_DIR_SUFFIX||"";return process.platform==="win32"?k(e.LOCALAPPDATA?.trim()||k(s,"AppData","Local"),`hermes${n}`):k(s,`.hermes${n}`)}p(Nt,"hermesHome");var Ot=p(s=>Re(s).then(e=>e.isDirectory()).catch(()=>!1),"isDirectory"),Tt=p(s=>Re(s).then(e=>e.isFile()).catch(()=>!1),"isFile");async function Je(s,e){let t=[],n=await Rs(s).catch(()=>null);if(!n)return t;let r=0;for await(let i of n){if(++r>100)throw new Error("More than 100 profile entries. Select the exact --source-path.");i.isDirectory()&&!i.isSymbolicLink()&&e(i.name)&&t.push(i.name)}return t.sort()}p(Je,"profileNames");async function xt(s){if(Ls(ks(s))==="profiles")return[{root:s}];let e=k(s,"profiles");try{let t=await Je(e,a=>/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(a)),n=[];for(let a of t)await Re(k(e,".deleted",a)).then(()=>!0).catch(()=>!1)||await Tt(k(e,a,"state.db"))&&n.push({root:k(e,a)});let r="",i=k(s,"active_profile");if(await Re(i).then(a=>a.isFile()&&a.size<=1024).catch(()=>!1)&&(r=(await As(i,"utf8")).replace(/^\uFEFF/u,"").trim().toLowerCase()),r&&r!=="default"){if(!/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(r))return[{root:s,reason:"Hermes active profile is invalid. Select the exact --source-path."}];let a=n.findIndex(o=>o.root===k(e,r));a<0?n.unshift({root:k(e,r),reason:"Hermes active profile has no retained live state database. Select a profile explicitly."}):n.unshift(...n.splice(a,1))}return(await Tt(k(s,"state.db"))||!n.length)&&n.push({root:s}),n}catch(t){return[{root:s,reason:t instanceof Error?t.message:"Cannot inventory Hermes profiles. Select the exact --source-path."}]}}p(xt,"hermesLocations");function Ce(s){return/^[a-z0-9][a-z0-9._-]{0,63}$/u.test(s)&&!s.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/iu.test(s)}p(Ce,"validOmpProfile");async function Ct(s,e){let t=k(s,e.PI_CONFIG_DIR||".omp"),n=(e.OMP_PROFILE!==void 0?e.OMP_PROFILE:e.PI_PROFILE)?.trim();if(n&&n!=="default"&&!Ce(n))return[{root:t,reason:"Oh My Pi profile is invalid. Select the exact --source-path."}];if(e.PI_CODING_AGENT_SESSION_DIR)return[{root:ze(e.PI_CODING_AGENT_SESSION_DIR)}];let r=(process.platform==="linux"||process.platform==="darwin")&&e.XDG_DATA_HOME?k(e.XDG_DATA_HOME,"omp"):void 0;async function i(a){let o=a?k(t,"profiles",a,"agent"):k(t,"agent"),l=e.PI_PROFILE?.trim(),c=l&&Ce(l)?k(t,"profiles",l,"agent"):void 0,f=!a&&e.PI_CODING_AGENT_DIR&&e.PI_CODING_AGENT_DIR!==c?ze(e.PI_CODING_AGENT_DIR):void 0,u=r&&(a?k(r,"profiles",a):r);return{root:(!f||f===o)&&u&&await Ot(u)?u:f||o}}if(p(i,"location"),n||e.OMP_PROFILE!==void 0||e.PI_PROFILE!==void 0||e.PI_CODING_AGENT_DIR)return[await i(n&&n!=="default"?n:void 0)];try{let a=new Set(await Je(k(t,"profiles"),Ce));if(r)for(let l of await Je(k(r,"profiles"),Ce))a.add(l);let o=[await i()];for(let l of[...a].sort()){let c=await i(l);await Ot(k(c.root,"sessions"))&&o.push(c)}return o}catch(a){return[{root:t,reason:a instanceof Error?a.message:"Cannot inventory Oh My Pi profiles. Select the exact --source-path."}]}}p(Ct,"ompLocations");async function ho(s){let e=s.home??Ds(),t=s.environment??process.env,n={codex:t.CODEX_HOME||X(e,".codex"),claude_code:t.CLAUDE_CONFIG_DIR||X(e,".claude"),hermes:Nt(e,t),openclaw:t.OPENCLAW_STATE_DIR||X(e,".openclaw"),opencode:X(t.XDG_DATA_HOME||X(e,".local/share"),"opencode"),grok_build:t.GROK_HOME||X(e,".grok"),pi:t.PI_CODING_AGENT_DIR||X(e,".pi/agent"),oh_my_pi:X(e,".omp/agent")},r=n.pi,i=!1;if(t.PI_CODING_AGENT_SESSION_DIR)n.pi=Xe(t.PI_CODING_AGENT_SESSION_DIR);else if(!s.locations?.pi)try{let o=X(r,"settings.json");if((await Ge(o)).size<=1024*1024){let l=JSON.parse(await $s(o,"utf8"));typeof l.sessionDir=="string"&&l.sessionDir.trim()&&(Hs(l.sessionDir)?n.pi=l.sessionDir:i=!0)}}catch{}let a=[];for(let o of Object.keys(It)){let l=s.locations?.[o]?[{root:s.locations[o]}]:o==="hermes"?await xt(Xe(n.hermes)):o==="oh_my_pi"?await Ct(e,t):[{root:n[o]}];for(let c of l){let f=Xe(c.root),u=!1,h=!1;try{f=await Rt(f);let g=await Ge(f);h=g.isFile(),u=g.isDirectory()||h}catch{}if(c.reason&&(u=!1),o==="openclaw"&&u&&!h){let g=X(f,"agents"),w=await Ms(g,{withFileTypes:!0}).catch(()=>[]),y=[];for(let m of w.slice(0,100)){if(!m.isDirectory()||m.isSymbolicLink())continue;let d=X(g,m.name,"agent","openclaw-agent.sqlite");await Ge(d).then(E=>E.isFile()).catch(()=>!1)&&y.push(await Rt(d))}if(y.length){for(let m of y)a.push({source:o,root:m,machineId:s.machineId,instanceId:`native-${O([s.machineId,o,m]).slice(0,40)}`,acquisition:"sqlite",available:!0,capabilities:{history:!0,live:!0,nativeResume:!1}});continue}}if(o==="pi"&&i&&!s.locations?.pi){a.push({source:o,root:f,machineId:s.machineId,instanceId:`native-${O([s.machineId,o,f]).slice(0,40)}`,acquisition:"files",available:!1,capabilities:{history:!1,live:!1,nativeResume:!1},reason:"Pi config uses a working-directory-relative sessionDir. Select its resolved directory with --source-path."});continue}a.push({source:o,root:f,machineId:s.machineId,instanceId:`native-${O([s.machineId,o,f]).slice(0,40)}`,acquisition:h&&!/\.(?:db|sqlite)$/u.test(f)?"files":o==="hermes"||o==="opencode"||o==="openclaw"&&h?"sqlite":o==="openclaw"?"bundle":"files",available:u,capabilities:{history:u,live:u&&(o!=="openclaw"||h),nativeResume:!1},...u?{}:{reason:c.reason??"Source location is missing or unreadable. Select a custom location."}})}}return a.filter((o,l)=>a.findIndex(c=>c.instanceId===o.instanceId)===l)}p(ho,"discoverSources");import{open as Ys,lstat as Vs,readdir as Zs,readFile as Qs,realpath as Jt,stat as Xt}from"node:fs/promises";import{basename as ee,dirname as Ke,isAbsolute as Ye,join as ke,relative as en,resolve as tn,sep as sn}from"node:path";import{zstdDecompressSync as nn}from"node:zlib";import{DatabaseSync as Js}from"node:sqlite";import{join as Gs}from"node:path";import{DatabaseSync as Ws}from"node:sqlite";import{zstdDecompressSync as $t}from"node:zlib";import{createHash as zs}from"node:crypto";import{createHash as Fs}from"node:crypto";import{readFileSync as Us,realpathSync as At,statSync as qs}from"node:fs";import{basename as Bs,dirname as Lt,join as kt,relative as Ps,sep as Dt}from"node:path";import{zstdDecompressSync as js}from"node:zlib";function Mt(s,e,t){let n=s.prepare("SELECT generation,archive_name,archive_sha256,event_count,raw_bytes,archive_bytes,last_seq,storage,length(archive_blob) AS blob_bytes FROM session_transcript_cold_archives WHERE session_id=?").get(t);if(!n)return null;if(Number(n.archive_bytes)>L||Number(n.raw_bytes)>L||Number(n.event_count)>1e5)throw new Error("OpenClaw cold archive exceeds the retained size limit.");let r;if(n.storage==="sqlite"){if(Number(n.blob_bytes)!==Number(n.archive_bytes))throw new Error("OpenClaw cold archive size differs from its receipt.");let h=s.prepare("SELECT archive_blob FROM session_transcript_cold_archives WHERE session_id=?").get(t);if(!(h.archive_blob instanceof Uint8Array))throw new Error("OpenClaw cold archive is unavailable.");r=h.archive_blob}else if(n.storage==="file"){let h=String(n.archive_name);if(!/^[a-f0-9]{64}\.jsonl\.zst$/.test(h))throw new Error("Invalid OpenClaw cold archive name.");let g=Lt(e.root),w=Bs(g)==="agent"?kt(Lt(g),"sessions"):g,y=At(w),m=At(kt(w,"cold",h)),d=Ps(y,m);if(d===".."||d.startsWith(`..${Dt}`)||d.startsWith(Dt))throw new Error("OpenClaw cold archive leaves the selected agent directory.");let E=qs(m);if(!E.isFile()||E.size!==Number(n.archive_bytes))throw new Error("OpenClaw cold archive size differs from its receipt.");r=Us(m)}else throw new Error("Unsupported OpenClaw cold archive storage.");if(r.length!==Number(n.archive_bytes)||Fs("sha256").update(r).digest("hex")!==n.archive_sha256)throw new Error("OpenClaw cold archive checksum differs from its receipt.");let i=js(r,{maxOutputLength:L}),a=new TextDecoder("utf8",{fatal:!0}).decode(i).trimEnd().split(`
12
12
  `),o=JSON.parse(a.shift()??"null");if(o?.kind!=="header"||o.version!==1||o.sessionId!==t||o.generation!==n.generation)throw new Error("OpenClaw cold archive identity differs from its receipt.");let l=[],c=-1,f=0;for(let h of a){let g=JSON.parse(h);if(!["event","identity","active","index","fts"].includes(g?.kind))throw new Error("Unsupported OpenClaw cold archive record.");if(g.kind==="event"){if(!Number.isSafeInteger(g.row?.seq)||g.row.seq<=c||typeof g.row.event_json!="string")throw new Error("Invalid OpenClaw cold archive event sequence.");c=g.row.seq,f+=Buffer.byteLength(g.row.event_json),l.push(g.row.event_json)}}if(l.length!==Number(n.event_count)||c!==Number(n.last_seq)||f+l.length-1!==Number(n.raw_bytes))throw new Error("OpenClaw cold archive contents differ from its receipt.");let u=JSON.parse(l[0]??"null");if(u?.type!=="session"||u.id!==t)throw new Error("OpenClaw transcript identity differs from selected session.");return{path:`${t}.jsonl`,text:l.join(`
13
13
  `)+`
14
14
  `}}p(Mt,"readOpenClawColdArchive");function Ht(s){let e=new Ws(s.root,{readOnly:!0,allowExtension:!1,enableDoubleQuotedStringLiterals:!1});return e.exec("PRAGMA query_only=ON; PRAGMA busy_timeout=1000; BEGIN"),e}p(Ht,"open");function Ae(s,e){return!!s.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(e)}p(Ae,"has");function Ft(s,e){let t=Ht(s);try{let n=Ae(t,"session_transcript_archives")?"UNION ALL SELECT session_id AS id,created_at AS updated,archive_sha256 AS revision FROM session_transcript_archives":"",r=Ae(t,"session_transcript_cold_archives")?"UNION ALL SELECT session_id AS id,archived_at AS updated,archive_sha256 AS revision FROM session_transcript_cold_archives":"",i=t.prepare(`SELECT id,MAX(updated) AS updated,MAX(revision) AS revision FROM (
@@ -24,11 +24,11 @@ import{a as xs}from"./chunk-JFXINDOQ.js";import{a as ce,b as Te,d as ut,e as we}
24
24
  `);if(x=R<0?"":x.slice(R+1),!x.endsWith(`
25
25
  `)){let C=x.lastIndexOf(`
26
26
  `);try{JSON.parse(x.slice(C+1))}catch{x=x.slice(0,C+1)}}o+=`
27
- ${x}`}}finally{await m.close()}}else o=await _e(s,i);let l=s.acquisition==="bundle"||Gt(s,i)?[_(JSON.parse(o))]:o.split(/\r?\n/u).filter(Boolean).slice(0,s.source==="claude_code"?void 0:12).map(m=>_(JSON.parse(m))),c=l.find(m=>m.type==="session"||m.type==="session_meta")??l[0]??{},f=c.type==="session_meta"?_(c.payload):s.source==="grok_build"?_(c.params):s.source==="opencode"?_(c.info):c,u=s.source==="claude_code"?ee(i||s.root).replace(/\.jsonl(?:\.zst)?$/u,""):typeof f.id=="string"?f.id:typeof f.sessionId=="string"?f.sessionId:ee(i).replace(/\.jsonl(?:\.zst)?$/u,""),h=s.source==="claude_code"&&/(?:^|[\/])subagents[\/]agent-[^\/]+\.jsonl$/u.test(i)?l.find(m=>m.isSidechain===!0&&typeof m.agentId=="string"&&`agent-${m.agentId}`===u&&typeof m.sessionId=="string"&&ee(Ke(Ke(i)))===m.sessionId):void 0,w=(s.source==="claude_code"?l.find(m=>m.sessionId===(h?.sessionId??u)&&m.type==="user"&&typeof m.cwd=="string"&&Ye(m.cwd)):void 0)?.cwd??f.cwd,y=s.source==="claude_code"?jt(l,h?String(h.sessionId):u,!!h):Wt(f.title,u);if(s.source==="grok_build"&&i.endsWith("updates.jsonl"))try{let m=_(JSON.parse(await _e(s,ke(Ke(i),"summary.json")))),d=_(m.info);d.id===u&&(w=d.cwd,typeof m.generated_title=="string"&&(y=m.generated_title.slice(0,500)))}catch{}r.push({nativeSessionId:u,...h?{parentNativeSessionId:String(h.sessionId)}:{},sourceInstanceId:s.instanceId,path:i,title:y,cwd:typeof w=="string"&&Ye(w)?w:null,updatedAt:a.mtime.toISOString(),storageRevision:[a.dev,a.ino,a.size,a.mtimeMs,a.ctimeMs].join(":")})}catch(a){if(a.code==="ENOENT")continue;r.push({nativeSessionId:ee(i||s.root),sourceInstanceId:s.instanceId,path:i,title:ee(i||s.root),cwd:null,updatedAt:new Date(0).toISOString(),issue:a instanceof Error?a.message:"Unable to inspect native session"})}if(r.length>t)break}return{items:r.slice(0,t),nextCursor:r.length>t?r[t-1].path:null}}p(pe,"listSessions");function Yt(s,e){let t=Ce(e);if(t.sessionId!==(s.parentNativeSessionId??s.nativeSessionId))throw new Error("Native session changed identity.");if(s.parentNativeSessionId&&e.filter(r=>r.type==="user"||r.type==="assistant").some(r=>r.isSidechain!==!0||`agent-${String(r.agentId)}`!==s.nativeSessionId))throw new Error("Native worker changed identity.");return t}p(Yt,"assertClaudeIdentity");async function Ze(s,e){if(s.source!=="claude_code")return{revision:"",branches:[]};if(e.issue)throw new Error(e.issue);if(e.sourceInstanceId!==s.instanceId)throw new Error("Native session belongs to another selected source.");let t=await _e(s,e.path),n=Yt(e,Q({path:ee(e.path),text:t}));return{revision:O(t),branches:n.branches()}}p(Ze,"inspectSessionBranches");async function De(s,e,t={}){if(e.issue)throw new Error(e.issue);if(e.sourceInstanceId!==s.instanceId)throw new Error("Native session belongs to another selected source.");let n;if(s.acquisition==="sqlite")n=[Pt(s,e.nativeSessionId)];else if(s.acquisition==="bundle"){let i=e.path.slice(0,-13);n=await Promise.all(["manifest.json","events.jsonl","session-branch.json"].map(async a=>({path:a,text:await _e(s,`${i}${a}`)})))}else n=[{path:ee(e.path||s.root).replace(/\.zst$/u,""),text:await _e(s,e.path)}];if(t.expectedBranchRevision&&!t.branchLeafId)throw new Error("Choose a branch before supplying its revision.");if(s.source==="claude_code"){let i=n[0],a=Yt(e,Q(i));if(t.latestBranch){if(t.branchLeafId||t.expectedBranchRevision||t.branchAnchor)throw new Error("Choose either the latest conversation or an explicit branch.");n=[{...i,text:a.select(a.latestLeafId()).chain.map(o=>JSON.stringify(o)).join(`
27
+ ${x}`}}finally{await m.close()}}else o=await _e(s,i);let l=s.acquisition==="bundle"||Gt(s,i)?[_(JSON.parse(o))]:o.split(/\r?\n/u).filter(Boolean).slice(0,s.source==="claude_code"?void 0:12).map(m=>_(JSON.parse(m))),c=l.find(m=>m.type==="session"||m.type==="session_meta")??l[0]??{},f=c.type==="session_meta"?_(c.payload):s.source==="grok_build"?_(c.params):s.source==="opencode"?_(c.info):c,u=s.source==="claude_code"?ee(i||s.root).replace(/\.jsonl(?:\.zst)?$/u,""):typeof f.id=="string"?f.id:typeof f.sessionId=="string"?f.sessionId:ee(i).replace(/\.jsonl(?:\.zst)?$/u,""),h=s.source==="claude_code"&&/(?:^|[\/])subagents[\/]agent-[^\/]+\.jsonl$/u.test(i)?l.find(m=>m.isSidechain===!0&&typeof m.agentId=="string"&&`agent-${m.agentId}`===u&&typeof m.sessionId=="string"&&ee(Ke(Ke(i)))===m.sessionId):void 0,w=(s.source==="claude_code"?l.find(m=>m.sessionId===(h?.sessionId??u)&&m.type==="user"&&typeof m.cwd=="string"&&Ye(m.cwd)):void 0)?.cwd??f.cwd,y=s.source==="claude_code"?jt(l,h?String(h.sessionId):u,!!h):Wt(f.title,u);if(s.source==="grok_build"&&i.endsWith("updates.jsonl"))try{let m=_(JSON.parse(await _e(s,ke(Ke(i),"summary.json")))),d=_(m.info);d.id===u&&(w=d.cwd,typeof m.generated_title=="string"&&(y=m.generated_title.slice(0,500)))}catch{}r.push({nativeSessionId:u,...h?{parentNativeSessionId:String(h.sessionId)}:{},sourceInstanceId:s.instanceId,path:i,title:y,cwd:typeof w=="string"&&Ye(w)?w:null,updatedAt:a.mtime.toISOString(),storageRevision:[a.dev,a.ino,a.size,a.mtimeMs,a.ctimeMs].join(":")})}catch(a){if(a.code==="ENOENT")continue;r.push({nativeSessionId:ee(i||s.root),sourceInstanceId:s.instanceId,path:i,title:ee(i||s.root),cwd:null,updatedAt:new Date(0).toISOString(),issue:a instanceof Error?a.message:"Unable to inspect native session"})}if(r.length>t)break}return{items:r.slice(0,t),nextCursor:r.length>t?r[t-1].path:null}}p(pe,"listSessions");function Yt(s,e){let t=Ne(e);if(t.sessionId!==(s.parentNativeSessionId??s.nativeSessionId))throw new Error("Native session changed identity.");if(s.parentNativeSessionId&&e.filter(r=>r.type==="user"||r.type==="assistant").some(r=>r.isSidechain!==!0||`agent-${String(r.agentId)}`!==s.nativeSessionId))throw new Error("Native worker changed identity.");return t}p(Yt,"assertClaudeIdentity");async function Ze(s,e){if(s.source!=="claude_code")return{revision:"",branches:[]};if(e.issue)throw new Error(e.issue);if(e.sourceInstanceId!==s.instanceId)throw new Error("Native session belongs to another selected source.");let t=await _e(s,e.path),n=Yt(e,Q({path:ee(e.path),text:t}));return{revision:O(t),branches:n.branches()}}p(Ze,"inspectSessionBranches");async function De(s,e,t={}){if(e.issue)throw new Error(e.issue);if(e.sourceInstanceId!==s.instanceId)throw new Error("Native session belongs to another selected source.");let n;if(s.acquisition==="sqlite")n=[Pt(s,e.nativeSessionId)];else if(s.acquisition==="bundle"){let i=e.path.slice(0,-13);n=await Promise.all(["manifest.json","events.jsonl","session-branch.json"].map(async a=>({path:a,text:await _e(s,`${i}${a}`)})))}else n=[{path:ee(e.path||s.root).replace(/\.zst$/u,""),text:await _e(s,e.path)}];if(t.expectedBranchRevision&&!t.branchLeafId)throw new Error("Choose a branch before supplying its revision.");if(s.source==="claude_code"){let i=n[0],a=Yt(e,Q(i));if(t.latestBranch){if(t.branchLeafId||t.expectedBranchRevision||t.branchAnchor)throw new Error("Choose either the latest conversation or an explicit branch.");n=[{...i,text:a.select(a.latestLeafId()).chain.map(o=>JSON.stringify(o)).join(`
28
28
  `)+`
29
29
  `}]}if(t.branchAnchor){if(t.branchLeafId||t.expectedBranchRevision)throw new Error("Choose either a frozen branch snapshot or a followed branch anchor.");if(a.select(t.branchAnchor.leafId).chainHash!==t.branchAnchor.chainHash)throw new Error("The selected branch history changed. Review and select it again before syncing.");let l=a.leaves.filter(c=>a.select(c.uuid).chain.some(f=>f.uuid===t.branchAnchor.leafId));if(l.length!==1)throw new Error("The selected branch diverged. Pause this connection and choose its branch again.");t={...t,branchLeafId:l[0].uuid}}if(t.expectedBranchRevision&&O(i.text)!==t.expectedBranchRevision)throw new Error("This conversation changed. Refresh its branches and choose again.");if(t.branchLeafId){if(!a.leaves.some(o=>o.uuid===t.branchLeafId))throw new Error("The selected Claude branch is no longer a leaf. Refresh and choose again.");n=[{...i,text:a.select(t.branchLeafId).chain.map(o=>JSON.stringify(o)).join(`
30
30
  `)+`
31
- `}]}}else if(t.expectedBranchRevision||t.branchAnchor)throw new Error("Branch revision selection is only supported for Claude Code.");let r=Rt({source:s.source,files:n,acquisition:{machineId:s.machineId,sourceInstanceId:s.instanceId},...t});if(r.issues.length&&r.issues.every(i=>i.code==="no_user_request"))throw new le;if(r.issues.length)throw new Error(r.issues.map(i=>i.message).join("; "));if(s.acquisition==="sqlite"&&r.sessions.some(i=>i.sessionId!==e.nativeSessionId))throw new Error("Native session changed identity.");return{files:n,preview:r,branchLeafId:t.branchLeafId}}p(De,"readSession");var on=Y.object({sourceInstanceId:Y.string().min(1).max(500),sessionKeys:Y.array(Y.string().regex(/^[a-f0-9]{64}$/)).min(1).max(1e4)}).strict().refine(s=>new Set(s.sessionKeys).size===s.sessionKeys.length,"Conversation selection contains duplicates.");function ue(s){return O(JSON.stringify([s.path,s.nativeSessionId]))}p(ue,"nativeSessionSelectionKey");async function an(s){if(!s.available||!s.capabilities.history)throw new Error("The selected conversation source is unavailable.");let e=[],t,n=new Set;do{let r=await pe(s,{cursor:t,limit:100});if(e.push(...r.items),e.length>1e4)throw new Error("Choose a source with no more than 10,000 conversations.");if(t=r.nextCursor??void 0,t&&n.has(t))throw new Error("Conversation listing did not advance. Refresh the source.");t&&n.add(t)}while(t);return e}p(an,"nativeUploadInventory");async function pi(s,e){let t=on.parse(e);if(t.sourceInstanceId!==s.instanceId)throw new Error("Conversation selection belongs to another source installation.");let n=new Set((await an(s)).map(ue));if(t.sessionKeys.some(r=>!n.has(r)))throw new Error("A selected conversation is no longer available. Refresh and select it again.");return t}p(pi,"validateNativeUploadSelection");function ui(s,e,t){let n=(t.query??"").trim().toLocaleLowerCase(),r=t.range??"all",i=t.offset??0;if(n.length>500||!["day","week","all"].includes(r)||!Number.isInteger(i)||i<0||i>1e4)throw new Error("Invalid conversation search or page.");let a=r==="all"?0:Date.now()-(r==="day"?1:7)*864e5,o=e.filter(c=>Date.parse(c.updatedAt)>=a&&(!n||[c.title,c.cwd,c.nativeSessionId].some(f=>f?.toLocaleLowerCase().includes(n)))).sort((c,f)=>f.updatedAt.localeCompare(c.updatedAt)),l=s.selectedSessionKeys?new Set(s.selectedSessionKeys):null;return{total:o.length,nextOffset:i+50<o.length?i+50:null,items:o.slice(i,i+50).map(c=>({key:ue(c),title:c.title,cwd:c.cwd,nativeSessionId:c.nativeSessionId,updatedAt:c.updatedAt,issue:c.issue??null,approved:l===null||l.has(ue(c))}))}}p(ui,"nativeUploadConversationPage");var Vt=Ns(xs(),1);function fe(s,e=new Date){if(s.length>512)throw new Error("Cron expressions must be at most 512 characters.");let t=s.trim().split(/\s+/u);if(t.length!==5)throw new Error("Use five cron fields: minute hour day-of-month month day-of-week.");let n=[[],[],[],["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],["sun","mon","tue","wed","thu","fri","sat"]],r=t.map((c,f)=>c.replace(/[a-z]+/giu,u=>{let h=n[f].indexOf(u.toLowerCase());if(h<0)throw new Error("Cron supports standard month/weekday names, numbers, *, lists, ranges and steps.");return String(h+(f===3?1:0))}));if(r.some(c=>!/^[\d*,/\-]+$/u.test(c)))throw new Error("Cron supports numbers, *, lists, ranges and steps; second-level schedules are not supported.");let i=r.join(" "),a=Vt.CronExpressionParser.parse(i,{currentDate:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone}),o=a.fields;if(o.minute.values.length!==1)throw new Error("Imports support at most one scheduled run per hour. Choose a single cron minute, such as 0 or 30.");let l={minute:[...o.minute.values],hour:[...o.hour.values],month:[...o.month.values],dayOfMonth:o.dayOfMonth.values.map(Number),dayOfWeek:[...new Set(o.dayOfWeek.values.map(c=>Number(c)%7))],anyDayOfMonth:o.dayOfMonth.isWildcard,anyDayOfWeek:o.dayOfWeek.isWildcard};return{expression:i,calendar:l,interval:a}}p(fe,"parseImportCron");function be(s,e){let t=s.dayOfMonth.includes(e.getDate()),n=s.dayOfWeek.includes(e.getDay());return(!s.anyDayOfMonth&&!s.anyDayOfWeek&&(t||n)||t&&s.anyDayOfWeek||s.anyDayOfMonth&&!s.anyDayOfWeek&&n)&&s.month.includes(e.getMonth()+1)&&s.hour.includes(e.getHours())&&s.minute.includes(e.getMinutes())}p(be,"importCalendarMatches");var Qe=["sun","mon","tue","wed","thu","fri","sat"];function cn(s){if(!/^(?:[01]\d|2[0-3]):[0-5]\d$/u.test(s))throw new Error("Use a sync time in 24-hour HH:MM format, such as 00:00.");return s}p(cn,"syncTime");function he(s){if(s.frequency==="hourly")return{frequency:s.frequency};if(s.frequency==="cron"){let t=fe(s.expression);return t.interval.next(),{frequency:"cron",expression:t.expression}}let e=cn(s.time);if(s.frequency==="daily")return{frequency:"daily",time:e};if(s.frequency==="weekly"&&Number.isInteger(s.day)&&s.day>=0&&s.day<=6)return{frequency:"weekly",time:e,day:s.day};throw new Error("Choose a supported import frequency and, for weekly imports, a weekday from Sunday (0) to Saturday (6).")}p(he,"validateCollectorSchedule");function Me(s){if(s.frequency==="cron")return s.expression;if(s.frequency==="hourly")return"0 * * * *";let[e,t]=s.time.split(":").map(Number);return`${t} ${e} * * ${s.frequency==="weekly"?s.day:"*"}`}p(Me,"scheduleExpression");function Ei(s){return s.frequency==="cron"?`cron ${s.expression}`:s.frequency==="hourly"?"hourly at minute 00":s.frequency==="daily"?`daily at ${s.time}`:`weekly on ${Qe[s.day]} at ${s.time}`}p(Ei,"scheduleDescription");function dn(s){return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}p(dn,"localDay");function et(s){return`${dn(s)}T${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`}p(et,"scheduledMinute");function Zt(s,e=new Date){let{interval:t,calendar:n}=fe(Me(s),e);for(let r=0;r<10;r++){let i=t.next().toDate();if(be(n,i))return i.toISOString()}throw new Error("Unable to determine the next sync time.")}p(Zt,"nextScheduledSync");function Qt(s,e,t=new Date){return!s||e===et(t)?!1:be(fe(Me(s),t).calendar,t)}p(Qt,"scheduledSyncDue");import{DatabaseSync as pn}from"node:sqlite";import{mkdir as un,chmod as ts}from"node:fs/promises";import{join as fn}from"node:path";var P={heartbeatMs:1e4,staleMs:6e4,maxPending:1e4,maxBytes:134217728,batchCases:20,runMs:36e5,requestMs:6e4,attemptsPerRun:3};function bi(s,e){if(e.id!==s.id||e.teamId!==s.teamId||e.projectId!==s.projectId||e.machineId!==s.source.machineId||e.sourceInstanceId!==s.source.instanceId||e.sourceRoot!==s.source.root||e.source!==s.source.source)throw new Error("The hosted destination belongs to another source or workspace.");return{taskDatasetId:e.taskDatasetId,conversationDatasetId:e.conversationDatasetId}}p(bi,"collectorDestinations");function es(s){let e={tasks:null,conversations:null};if(!s.accountBaseUrl||!s.destinations)return e;let t;try{t=new URL(s.accountBaseUrl)}catch{return e}if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1"].includes(t.hostname))||t.username||t.password||t.search||t.hash||t.pathname!=="/")return e;let n=p(r=>r?`${t.origin}/console/datasets/${encodeURIComponent(r)}/tasks?project=${encodeURIComponent(s.projectId)}&connection=${encodeURIComponent(s.id)}`:null,"link");return{tasks:n(s.destinations.taskDatasetId),conversations:n(s.destinations.conversationDatasetId)}}p(es,"collectorDestinationLinks");var $e=class{static{p(this,"CollectorProgress")}database;constructor(e){this.database=e,e.exec(`
31
+ `}]}}else if(t.expectedBranchRevision||t.branchAnchor)throw new Error("Branch revision selection is only supported for Claude Code.");let r=vt({source:s.source,files:n,acquisition:{machineId:s.machineId,sourceInstanceId:s.instanceId},...t});if(r.issues.length&&r.issues.every(i=>i.code==="no_user_request"))throw new le;if(r.issues.length)throw new Error(r.issues.map(i=>i.message).join("; "));if(s.acquisition==="sqlite"&&r.sessions.some(i=>i.sessionId!==e.nativeSessionId))throw new Error("Native session changed identity.");return{files:n,preview:r,branchLeafId:t.branchLeafId}}p(De,"readSession");var on=Y.object({sourceInstanceId:Y.string().min(1).max(500),sessionKeys:Y.array(Y.string().regex(/^[a-f0-9]{64}$/)).min(1).max(1e4)}).strict().refine(s=>new Set(s.sessionKeys).size===s.sessionKeys.length,"Conversation selection contains duplicates.");function ue(s){return O(JSON.stringify([s.path,s.nativeSessionId]))}p(ue,"nativeSessionSelectionKey");async function an(s){if(!s.available||!s.capabilities.history)throw new Error("The selected conversation source is unavailable.");let e=[],t,n=new Set;do{let r=await pe(s,{cursor:t,limit:100});if(e.push(...r.items),e.length>1e4)throw new Error("Choose a source with no more than 10,000 conversations.");if(t=r.nextCursor??void 0,t&&n.has(t))throw new Error("Conversation listing did not advance. Refresh the source.");t&&n.add(t)}while(t);return e}p(an,"nativeUploadInventory");async function pi(s,e){let t=on.parse(e);if(t.sourceInstanceId!==s.instanceId)throw new Error("Conversation selection belongs to another source installation.");let n=new Set((await an(s)).map(ue));if(t.sessionKeys.some(r=>!n.has(r)))throw new Error("A selected conversation is no longer available. Refresh and select it again.");return t}p(pi,"validateNativeUploadSelection");function ui(s,e,t){let n=(t.query??"").trim().toLocaleLowerCase(),r=t.range??"all",i=t.offset??0;if(n.length>500||!["day","week","all"].includes(r)||!Number.isInteger(i)||i<0||i>1e4)throw new Error("Invalid conversation search or page.");let a=r==="all"?0:Date.now()-(r==="day"?1:7)*864e5,o=e.filter(c=>Date.parse(c.updatedAt)>=a&&(!n||[c.title,c.cwd,c.nativeSessionId].some(f=>f?.toLocaleLowerCase().includes(n)))).sort((c,f)=>f.updatedAt.localeCompare(c.updatedAt)),l=s.selectedSessionKeys?new Set(s.selectedSessionKeys):null;return{total:o.length,nextOffset:i+50<o.length?i+50:null,items:o.slice(i,i+50).map(c=>({key:ue(c),title:c.title,cwd:c.cwd,nativeSessionId:c.nativeSessionId,updatedAt:c.updatedAt,issue:c.issue??null,approved:l===null||l.has(ue(c))}))}}p(ui,"nativeUploadConversationPage");var Vt=Ns(xs(),1);function fe(s,e=new Date){if(s.length>512)throw new Error("Cron expressions must be at most 512 characters.");let t=s.trim().split(/\s+/u);if(t.length!==5)throw new Error("Use five cron fields: minute hour day-of-month month day-of-week.");let n=[[],[],[],["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],["sun","mon","tue","wed","thu","fri","sat"]],r=t.map((c,f)=>c.replace(/[a-z]+/giu,u=>{let h=n[f].indexOf(u.toLowerCase());if(h<0)throw new Error("Cron supports standard month/weekday names, numbers, *, lists, ranges and steps.");return String(h+(f===3?1:0))}));if(r.some(c=>!/^[\d*,/\-]+$/u.test(c)))throw new Error("Cron supports numbers, *, lists, ranges and steps; second-level schedules are not supported.");let i=r.join(" "),a=Vt.CronExpressionParser.parse(i,{currentDate:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone}),o=a.fields;if(o.minute.values.length!==1)throw new Error("Imports support at most one scheduled run per hour. Choose a single cron minute, such as 0 or 30.");let l={minute:[...o.minute.values],hour:[...o.hour.values],month:[...o.month.values],dayOfMonth:o.dayOfMonth.values.map(Number),dayOfWeek:[...new Set(o.dayOfWeek.values.map(c=>Number(c)%7))],anyDayOfMonth:o.dayOfMonth.isWildcard,anyDayOfWeek:o.dayOfWeek.isWildcard};return{expression:i,calendar:l,interval:a}}p(fe,"parseImportCron");function be(s,e){let t=s.dayOfMonth.includes(e.getDate()),n=s.dayOfWeek.includes(e.getDay());return(!s.anyDayOfMonth&&!s.anyDayOfWeek&&(t||n)||t&&s.anyDayOfWeek||s.anyDayOfMonth&&!s.anyDayOfWeek&&n)&&s.month.includes(e.getMonth()+1)&&s.hour.includes(e.getHours())&&s.minute.includes(e.getMinutes())}p(be,"importCalendarMatches");var Qe=["sun","mon","tue","wed","thu","fri","sat"];function cn(s){if(!/^(?:[01]\d|2[0-3]):[0-5]\d$/u.test(s))throw new Error("Use a sync time in 24-hour HH:MM format, such as 00:00.");return s}p(cn,"syncTime");function he(s){if(s.frequency==="hourly")return{frequency:s.frequency};if(s.frequency==="cron"){let t=fe(s.expression);return t.interval.next(),{frequency:"cron",expression:t.expression}}let e=cn(s.time);if(s.frequency==="daily")return{frequency:"daily",time:e};if(s.frequency==="weekly"&&Number.isInteger(s.day)&&s.day>=0&&s.day<=6)return{frequency:"weekly",time:e,day:s.day};throw new Error("Choose a supported import frequency and, for weekly imports, a weekday from Sunday (0) to Saturday (6).")}p(he,"validateCollectorSchedule");function Me(s){if(s.frequency==="cron")return s.expression;if(s.frequency==="hourly")return"0 * * * *";let[e,t]=s.time.split(":").map(Number);return`${t} ${e} * * ${s.frequency==="weekly"?s.day:"*"}`}p(Me,"scheduleExpression");function Ei(s){return s.frequency==="cron"?`cron ${s.expression}`:s.frequency==="hourly"?"hourly at minute 00":s.frequency==="daily"?`daily at ${s.time}`:`weekly on ${Qe[s.day]} at ${s.time}`}p(Ei,"scheduleDescription");function dn(s){return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}p(dn,"localDay");function et(s){return`${dn(s)}T${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`}p(et,"scheduledMinute");function Zt(s,e=new Date){let{interval:t,calendar:n}=fe(Me(s),e);for(let r=0;r<10;r++){let i=t.next().toDate();if(be(n,i))return i.toISOString()}throw new Error("Unable to determine the next sync time.")}p(Zt,"nextScheduledSync");function Qt(s,e,t=new Date){return!s||e===et(t)?!1:be(fe(Me(s),t).calendar,t)}p(Qt,"scheduledSyncDue");import{DatabaseSync as pn}from"node:sqlite";import{mkdir as un,chmod as ts}from"node:fs/promises";import{join as fn}from"node:path";var P={heartbeatMs:1e4,staleMs:6e4,maxPending:1e4,maxBytes:134217728,batchCases:20,runMs:36e5,requestMs:6e4,attemptsPerRun:3};function bi(s,e){if(e.id!==s.id||e.teamId!==s.teamId||e.projectId!==s.projectId||e.machineId!==s.source.machineId||e.sourceInstanceId!==s.source.instanceId||e.sourceRoot!==s.source.root||e.source!==s.source.source)throw new Error("The hosted destination belongs to another source or workspace.");return{taskDatasetId:e.taskDatasetId,conversationDatasetId:e.conversationDatasetId}}p(bi,"collectorDestinations");function es(s){let e={tasks:null,conversations:null};if(!s.accountBaseUrl||!s.destinations)return e;let t;try{t=new URL(s.accountBaseUrl)}catch{return e}if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1"].includes(t.hostname))||t.username||t.password||t.search||t.hash||t.pathname!=="/")return e;let n=p(r=>r?`${t.origin}/console/datasets/${encodeURIComponent(r)}/tasks?project=${encodeURIComponent(s.projectId)}&connection=${encodeURIComponent(s.id)}`:null,"link");return{tasks:n(s.destinations.taskDatasetId),conversations:n(s.destinations.conversationDatasetId)}}p(es,"collectorDestinationLinks");var $e=class{static{p(this,"CollectorProgress")}database;constructor(e){this.database=e,e.exec(`
32
32
  CREATE TABLE IF NOT EXISTS backfills(connection_id TEXT PRIMARY KEY,discovered INTEGER NOT NULL DEFAULT 0);
33
33
  CREATE TABLE IF NOT EXISTS backfill_units(connection_id TEXT NOT NULL,session_key TEXT NOT NULL,state TEXT NOT NULL,error TEXT,PRIMARY KEY(connection_id,session_key));
34
34
  CREATE TABLE IF NOT EXISTS backfill_operations(operation_id TEXT PRIMARY KEY,connection_id TEXT NOT NULL,session_key TEXT NOT NULL,admitted INTEGER NOT NULL DEFAULT 0);
@@ -93,4 +93,4 @@ WantedBy=timers.target
93
93
  exit $LASTEXITCODE
94
94
  `}}p(ps,"collectorServiceFiles");var gs=Nn(Tn),J=p(async(s,e)=>{await gs(s,e,{timeout:15e3,maxBuffer:16384,windowsHide:!0})},"command");function ys(s){return`openpond-import-${O(s).slice(0,16)}`}p(ys,"identity");async function ya(s,e){let t=await j.open(s);try{t.put(e)}finally{t.close()}}p(ya,"configureCollector");async function Ue(s){let e=await j.open(s);try{return e.status()}finally{e.close()}}p(Ue,"collectorStatus");async function Rn(s,e,t){let n=await j.open(s);try{if(e==="start"||e==="stop")n.set("desiredState",e==="start"?"running":"stopped");else if(e==="sync")n.set("syncNow","yes");else{let r=n.connections().find(i=>i.id===t);if(!r)throw new Error("Select a retained connection.");n.put({...r,state:e==="pause"?"paused":e==="resume"?"active":"disconnected"})}return n.status()}finally{n.close()}}p(Rn,"controlCollector");async function fs(s){if(process.platform==="darwin"&&(await Ue(s.directory)).running)throw new Error("Wait for the current import to finish, or cancel it, before changing its macOS schedule.");if(!us(s.directory)||!us(s.executable)||[s.directory,s.executable,...s.args].some(c=>/[\r\n\0]/u.test(c)))throw new Error("Collector jobs require absolute paths and single-line arguments.");let e=await as(s);e&&(s={...s,...e,environment:{...s.environment,ELECTRON_RUN_AS_NODE:"1",APPIMAGE_EXTRACT_AND_RUN:"1"}});let t=Object.entries(s.environment??{});if(t.some(([c,f])=>!["OPENPOND_HOME","ELECTRON_RUN_AS_NODE","APPIMAGE_EXTRACT_AND_RUN"].includes(c)||typeof f!="string"||/[\r\n\0]/u.test(f)))throw new Error("Unsupported service environment setting.");let n=s.home??ms(),r=ys(s.directory),i=await j.open(s.directory),a;try{a=i.connections().map(c=>i.schedule(c.id)).filter(c=>c!==null)}finally{i.close()}let o=q(s.directory,"calendar-gate.cjs"),l=ps({name:r,gatePath:o,executable:s.executable,args:[...s.args,"import","service","run","--scheduled","--collector-dir",s.directory],environment:t,schedules:a});if(await me(o,l.gate,{mode:384}),process.platform==="linux"){let c=q(n,".config/systemd/user");await ot(c,{recursive:!0,mode:448}),await Ie("systemctl",["--user","disable",`${r}.service`]),await me(q(c,`${r}.service`),l.service,{mode:384}),a.length?(await me(q(c,`${r}.timer`),l.timer,{mode:384}),await J("systemctl",["--user","daemon-reload"]),await J("systemctl",["--user","enable","--now",`${r}.timer`]),await J("systemctl",["--user","restart",`${r}.timer`])):(await Ie("systemctl",["--user","disable","--now",`${r}.timer`]),await Z(q(c,`${r}.timer`),{force:!0}),await J("systemctl",["--user","daemon-reload"]))}else if(process.platform==="darwin"){let c=q(n,"Library/LaunchAgents"),f=q(c,`${r}.plist`);await ot(c,{recursive:!0,mode:448}),await Ie("launchctl",["bootout",`gui/${process.getuid()}/${r}`]),a.length?(await me(f,l.plist,{mode:384}),await J("launchctl",["bootstrap",`gui/${process.getuid()}`,f])):await Z(f,{force:!0})}else if(process.platform==="win32")if(!a.length)await Ie("schtasks",["/Delete","/TN",r,"/F"]);else{let c=(await gs("whoami",[],{timeout:5e3,maxBuffer:1024})).stdout.trim(),f=q(s.directory,"scheduled-task.xml"),u=q(s.directory,"start-collector.ps1");await ot(s.directory,{recursive:!0,mode:448}),await me(u,l.powershell,{mode:384}),await me(f,l.windowsTask(c,u),{mode:384}),await J("schtasks",["/Create","/TN",r,"/XML",f,"/F"])}else throw new Error("Scheduled imports need a supported OS scheduler. Use import sync manually on this OS.");return{name:r,platform:process.platform,status:await Ue(s.directory)}}p(fs,"installCollectorService");async function Ie(s,e){try{await J(s,e)}catch(t){let n=t;if(n.code==="ENOENT"||!/not (?:loaded|found|exist)|does not exist|No such|could not be found|cannot find|not been loaded/iu.test(n.stderr??n.message))throw t}}p(Ie,"optionalCommand");async function Ea(s,e,t){if(t!==null&&(t=he(t)),process.platform==="darwin"&&(await Ue(s.directory)).running)throw new Error("Wait for the current import to finish, or cancel it, before changing its macOS schedule.");let n=await j.open(s.directory),r=hs(),i;n.database.exec("BEGIN IMMEDIATE");try{let a=n.connections().find(l=>l.id===e);if(!a||t&&a.state==="disconnected")throw new Error("Select a connected source before scheduling imports.");if(t&&a.selectedSessionKeys?.length===0)throw new Error("Choose conversations to upload before enabling continual imports.");let o=n.setting("scheduleOwner");if(o){let{pid:l}=JSON.parse(o),c=!0;try{process.kill(l,0)}catch(f){c=f.code!=="ESRCH"}if(c)throw new Error("Another schedule update is in progress. Try again shortly.")}i=n.setting(`schedule:${e}`),n.set("scheduleOwner",JSON.stringify({pid:process.pid,token:r})),n.set(`schedule:${e}`,t?JSON.stringify(t):""),n.database.exec("COMMIT")}catch(a){throw n.database.exec("ROLLBACK"),n.close(),a}try{return await fs(s),n.status()}catch(a){n.set(`schedule:${e}`,i??"");try{await fs(s)}catch{throw new Error(`Schedule installation failed and OS rollback could not be verified. Review the OS scheduler. ${a instanceof Error?a.message:""}`)}throw a}finally{n.set("scheduleOwner",""),n.close()}}p(Ea,"setCollectorSchedule");async function wa(s,e=ms()){await Rn(s,"stop");let t=ys(s);if(process.platform==="linux")await Ie("systemctl",["--user","disable","--now",`${t}.timer`]),await Z(q(e,".config/systemd/user",`${t}.timer`),{force:!0}),await J("systemctl",["--user","disable","--now",`${t}.service`]),await Z(q(e,".config/systemd/user",`${t}.service`),{force:!0}),await J("systemctl",["--user","daemon-reload"]);else if(process.platform==="darwin")await J("launchctl",["bootout",`gui/${process.getuid()}/${t}`]),await Z(q(e,"Library/LaunchAgents",`${t}.plist`),{force:!0});else if(process.platform==="win32")await J("schtasks",["/End","/TN",t]),await J("schtasks",["/Delete","/TN",t,"/F"]),await Z(q(s,"scheduled-task.xml"),{force:!0}),await Z(q(s,"start-collector.ps1"),{force:!0});else throw new Error("No per-user supervisor is available.");await Z(q(s,"calendar-gate.cjs"),{force:!0}),process.platform==="linux"&&await cs(s);let n=await j.open(s);try{for(let r of n.connections())n.set(`schedule:${r.id}`,"")}finally{n.close()}return Ue(s)}p(wa,"uninstallCollectorService");async function me(s,e,t){let n=`${s}.${hs()}.tmp`;try{await xn(n,e,{...t,flag:"wx"}),await Cn(n,s)}finally{await Z(n,{force:!0})}}p(me,"atomicServiceFile");import{homedir as An}from"node:os";import{join as ws,resolve as Es}from"node:path";import{randomUUID as Ln}from"node:crypto";import{mkdir as kn,open as Dn,readFile as Mn}from"node:fs/promises";function $n(s=ws(An(),".openpond")){return process.env.OPENPOND_COLLECTOR_DIR?Es(process.env.OPENPOND_COLLECTOR_DIR):Es(s,"conversation-importer")}p($n,"collectorDirectory");async function Ta(s=$n()){await kn(s,{recursive:!0,mode:448});let e=ws(s,"machine-id");try{let n=await Dn(e,"wx",384);try{await n.writeFile(Ln()),await n.sync()}finally{await n.close()}}catch(n){if(n.code!=="EEXIST")throw n}let t=(await Mn(e,"utf8")).trim();if(!/^[a-f0-9-]{36}$/u.test(t))throw new Error("Collector machine identity is invalid; restore its retained state.");return t}p(Ta,"collectorMachineId");import{execFile as Fn}from"node:child_process";import{realpath as Un}from"node:fs/promises";import{isAbsolute as qn}from"node:path";import{promisify as Bn}from"node:util";import{createHash as Ss}from"node:crypto";function it(s,e){let t=Buffer.from(s,"base64");if(t.toString("base64")!==s||t.byteLength>e)throw new Error("connected_git_object_bytes_invalid");return t}p(it,"bytes");function at(s,e,t){return Ss(t===40?"sha1":"sha256").update(`${s} ${e.byteLength}\0`).update(e).digest("hex")}p(at,"objectHash");function Hn(s,e,t){let n=0,r=new Set,i=null,a=new TextDecoder("utf-8",{fatal:!0});for(;n<s.byteLength;){let o=s.indexOf(32,n),l=s.indexOf(0,o+1),c=l+1+t/2;if(o<n||l<o||c>s.byteLength)throw new Error("connected_git_tree_invalid");let f=s.subarray(n,o).toString("ascii"),u=a.decode(s.subarray(o+1,l));if(!u||u.includes("/")||r.has(u))throw new Error("connected_git_tree_invalid");r.add(u),u===e&&(i={mode:f,hash:s.subarray(l+1,c).toString("hex")}),n=c}if(!i)throw new Error("connected_git_path_missing");return i}p(Hn,"treeEntry");function _s(s,e){let t=Oe.parse(s),n=we.parse(e),r=t.commitHash.length,i=it(n.commit.base64,256*1024);if(n.commit.hash!==t.commitHash||at("commit",i,r)!==t.commitHash)throw new Error("connected_git_commit_mismatch");let a=i.indexOf(10);if(a<0)throw new Error("connected_git_commit_invalid");let o=i.subarray(0,a).toString("ascii");if(!new RegExp(`^tree [a-f0-9]{${r}}$`).test(o))throw new Error("connected_git_commit_invalid");let l=new Map,c=i.byteLength;for(let y of n.trees){let m=it(y.base64,2097152);if(c+=m.byteLength,c>8*1024*1024||l.has(y.hash)||y.hash.length!==r||at("tree",m,r)!==y.hash)throw new Error("connected_git_tree_mismatch");l.set(y.hash,m)}let f=n.path.split("/"),u=new Set,h=o.slice(5),g="";for(let[y,m]of f.entries()){let d=l.get(h);if(!d||u.has(h))throw new Error("connected_git_tree_missing");u.add(h);let E=Hn(d,m,r);if(g=E.mode,y<f.length-1?g!=="40000":!["100644","100755"].includes(g))throw new Error("connected_git_file_mode_invalid");h=E.hash}if(u.size!==l.size)throw new Error("connected_git_unreferenced_tree");let w=it(n.contentsBase64,2*1024*1024);if(at("blob",w,r)!==h)throw new Error("connected_git_blob_mismatch");return{path:n.path,commitHash:t.commitHash,gitObjectHash:h,mode:g,sizeBytes:w.byteLength,sha256:Ss("sha256").update(w).digest("hex"),contentsBase64:w.toString("base64")}}p(_s,"verifyConnectedGitFileProof");var Pn=Bn(Fn);async function jn(s){let e=Oe.parse(s.repositoryContext);if(!qn(s.repositoryPath)||!s.paths.length||s.paths.length>100||new Set(s.paths).size!==s.paths.length)throw new Error("native_git_asset_selection_invalid");for(let c of s.paths)we.shape.path.parse(c);let t=await Un(s.repositoryPath),n=p(async(c,f=2*1024*1024)=>(s.signal?.throwIfAborted(),(await Pn("git",["-C",t,...c],{encoding:"buffer",timeout:15e3,maxBuffer:f,signal:s.signal})).stdout),"read"),r=p(async c=>{let f=(await n(["rev-parse","--verify",c],1024)).toString("ascii").trim();if(!new RegExp(`^[a-f0-9]{${e.commitHash.length}}$`).test(f))throw new Error("native_git_object_identity_invalid");return f},"objectId"),i=await n(["cat-file","commit",e.commitHash],256*1024),a=new Map,o=0,l=[];for(let c of s.paths){let f=["",...c.split("/").slice(0,-1).map((y,m,d)=>d.slice(0,m+1).join("/"))],u=[];for(let y of f){let m=y?`${e.commitHash}:${y}`:`${e.commitHash}^{tree}`,d=a.get(m);if(!d){let E=await r(m);d={hash:E,base64:(await n(["cat-file","tree",E])).toString("base64")},a.set(m,d)}u.push(d)}let h=await r(`${e.commitHash}:${c}`),g=we.parse({schemaVersion:"openpond.connectedGitFileProof.v1",path:c,commit:{hash:e.commitHash,base64:i.toString("base64")},trees:u,contentsBase64:(await n(["cat-file","blob",h])).toString("base64")}),w=_s(e,g);if(o+=Buffer.byteLength(JSON.stringify(g)),o>16*1024*1024)throw new Error("native_git_asset_capture_limit");l.push({proof:g,verified:w})}return l}p(jn,"captureNativeGitAssetProofs");import{randomUUID as Jn}from"node:crypto";import{setTimeout as Gn}from"node:timers/promises";var ge=class{static{p(this,"CollectorSourceCache")}store;constructor(e){this.store=e,e.database.exec(`CREATE TABLE IF NOT EXISTS source_read_cache(
95
95
  connection_id TEXT NOT NULL,session_key TEXT NOT NULL,selection_hash TEXT NOT NULL,value TEXT NOT NULL,
96
- PRIMARY KEY(connection_id,session_key));`)}selection(e,t,n){return O([e.source,e.projectId,e.teamId,e.apiBaseUrl,e.account??null,e.since,e.selectedSessionKeys??null,t,n])}read(e,t,n,r){let i=this.store.database.prepare("SELECT value FROM source_read_cache WHERE connection_id=? AND session_key=? AND selection_hash=?").get(e.id,n,this.selection(e,t,r));return i?ce.parse(JSON.parse(String(i.value))):null}retain(e,t,n,r,i){let a=ce.parse(i);a.nativeRevisionHash===null||a.state!=="admitted"&&!(a.state==="skipped"&&a.reason==="no_eligible_boundaries")||this.store.database.prepare("INSERT INTO source_read_cache VALUES(?,?,?,?) ON CONFLICT(connection_id,session_key) DO UPDATE SET selection_hash=excluded.selection_hash,value=excluded.value").run(e.id,n,this.selection(e,t,r),JSON.stringify(a))}seed(e,t,n){if(!n||n.connectionRevision!==e.revision||n.from!==e.since||n.to!==t||n.sourceInstanceId!==e.source.instanceId||n.machineId!==e.source.machineId)return;let r=new Map(n.sessions.map(i=>[i.sourceKeyHash,i]));for(let i of this.store.database.prepare("SELECT session_key,revision FROM source_scans WHERE connection_id=?").all(e.id)){let a=String(i.session_key),o=r.get(O(a));o&&this.retain(e,t,a,String(i.revision),o)}}};var Wn=["source","admission","control","heartbeat"],ye=class{static{p(this,"CollectorErrors")}store;constructor(e){this.store=e}read(e){let t=this.store.setting(`errors:${e}`);if(t)return JSON.parse(t);let n=this.store.database.prepare("SELECT error FROM backfill_units WHERE connection_id=? AND state='error' AND error IS NOT NULL ORDER BY session_key LIMIT 1").get(e);return typeof n?.error=="string"?{source:n.error}:{}}message(e,t){let n=this.read(e);return Wn.filter(r=>r!==t).map(r=>n[r]).find(Boolean)??null}source(e){return this.read(e).source??null}set(e,t,n){let r=this.read(e);n?r[t]=n.slice(0,500):delete r[t],this.store.set(`errors:${e}`,JSON.stringify(r)),this.store.error(e,this.message(e))}};var qe=class{static{p(this,"CollectorSyncRequests")}store;acquisitions=new Map;constructor(e){this.store=e}observe(e,t){let n=t.requestedSyncRevision??e.requestedSyncRevision??0,r=t.completedSyncRevision??0;if(!Number.isSafeInteger(n)||n<0||n>t.revision||!Number.isSafeInteger(r)||r<0||r>n)throw new Error("Invalid remote sync acknowledgement.");let i=this.confirmed(e.id);return r>i&&this.store.set(`syncAcknowledged:${e.id}`,String(r)),{requestedSyncRevision:Math.max(e.requestedSyncRevision??0,n),completedSyncRevision:Math.max(e.completedSyncRevision??0,r)}}needsAcquisition(e){let t=e.requestedSyncRevision??0;if(t<=(e.completedSyncRevision??0))return!1;let n=this.acquisitions.get(e.id);return n?.controlRevision!==e.revision||n.requestedSyncRevision!==t}acquired(e,t){this.acquisitions.set(e,t)}complete(e,t){let n=this.acquisitions.get(e.id),r=e.requestedSyncRevision??0;if(e.state!=="active"||this.store.setting("desiredState")!=="running"||this.store.queued(e.id)||t||!n?.succeeded||n.controlRevision!==e.revision||n.requestedSyncRevision!==r||r<=(e.completedSyncRevision??0))return e;let i={...e,completedSyncRevision:r};return this.store.put(i),i}confirmed(e){return Number(this.store.setting(`syncAcknowledged:${e}`))||0}needsAcknowledgement(e){return(e.completedSyncRevision??0)>this.confirmed(e.id)}};var zn=Y.object({leafId:Y.string().min(1).max(200),chainHash:Y.string().regex(/^[a-f0-9]{64}$/),sourceInstanceId:Y.string().min(1)}).strict(),bs=p((s,e)=>`branch:${JSON.stringify([s,e])}`,"key");function vs(s,e,t){let n=s.setting(bs(e,t));if(!n)return;let r=zn.parse(JSON.parse(n));return s.connections().find(a=>a.id===e)?.source.instanceId===r.sourceInstanceId?{leafId:r.leafId,chainHash:r.chainHash}:void 0}p(vs,"collectorBranchAnchor");async function Is(s,e){if(s.source!=="claude_code")throw new Error("Branch selection is currently supported for Claude Code.");let t,n=[];do{let r=await pe(s,{cursor:t,limit:100});n.push(...r.items.filter(i=>i.nativeSessionId===e)),t=r.nextCursor??void 0}while(t);if(n.length!==1)throw new Error("Select exactly one native session in this connection's source location.");return n[0]}p(Is,"findSession");async function tc(s,e,t){let n=await j.open(s);try{let r=n.connections().find(a=>a.id===e);if(!r)throw new Error("Select a connection from openpond import status.");let i=await Is(r.source,t);return{session:i,...await Ze(r.source,i)}}finally{n.close()}}p(tc,"inspectCollectorBranches");async function sc(s,e,t,n){let r=await j.open(s);try{let i=r.connections().find(c=>c.id===e);if(!i||i.state!=="paused")throw new Error(`Pause this connection first: openpond import pause ${e}`);let a=await Is(i.source,t),o=await Ze(i.source,a),l=o.branches.find(c=>c.leafId===n.leafId);if(o.revision!==n.revision||!l)throw new Error("This conversation changed. Refresh its branches and choose again.");await De(i.source,a,{branchLeafId:n.leafId,expectedBranchRevision:n.revision}),r.database.exec("BEGIN IMMEDIATE");try{let c=r.connections().find(u=>u.id===e);if(!c||c.state!=="paused"||c.revision!==i.revision||c.source.instanceId!==i.source.instanceId)throw new Error("Connection changed during branch selection. Refresh and try again.");r.set(bs(e,t),JSON.stringify({leafId:l.leafId,chainHash:l.chainHash,sourceInstanceId:i.source.instanceId}));for(let u of["source_scans","checkpoints","pending"])r.database.prepare(`DELETE FROM ${u} WHERE connection_id=?`).run(e);r.snapshots.collect();let f=new ye(r);f.set(e,"source",f.source(e)),r.progress.reset(e),f.set(e,"admission",null),r.database.exec("COMMIT")}catch(c){throw r.database.exec("ROLLBACK"),c}return{connectionId:e,nativeSessionId:t,leafId:l.leafId,state:"paused"}}finally{r.close()}}p(sc,"selectCollectorBranch");async function Os(s){let{store:e,connection:t,check:n,drain:r,progress:i,until:a}=s,o=new ge(e),l,c=0,f=0,u=[],h=t.selectedSessionKeys?new Set(t.selectedSessionKeys):null,g=new Set,w=0;do{await n(),i({phase:"discovering"});let y=await pe(t.source,{cursor:l,limit:50});if(w+=y.items.length,w>1e4)throw new Error("Source inventory exceeds 10,000 sessions. Select a narrower source directory.");let m=y.items.filter(d=>!h||h.has(ue(d)));for(let d of m)g.add(ue(d));f+=m.length;for(let d of m){let E=JSON.stringify([d.path,d.nativeSessionId]);e.coverage.record(t.id,{sourceKeyHash:te.sourceKey(E),nativeRevisionHash:d.storageRevision?O([d.storageRevision,Re(t.source.source)]):null,state:"reading",reason:null,unknownTimeBoundaries:0,normalized:[]})}i({discovered:f});for(let d of m){if(await n(),await r(),Number(e.database.prepare("SELECT COALESCE(SUM(bytes),0) AS n FROM pending").get()?.n)+e.snapshots.bytes()>=P.maxBytes)throw new se;i({phase:"reading"});let S=JSON.stringify([d.path,d.nativeSessionId]),b=d.storageRevision?O([d.storageRevision,Re(t.source.source)]):null;e.progress.select(t.id,S);let N=b?o.read(t,a,S,b):null;if(N){e.coverage.record(t.id,N),e.progress.read(t.id,S,N.state==="admitted"),i({processed:++c});continue}let v={sourceKeyHash:te.sourceKey(S),nativeRevisionHash:b,state:"reading",reason:b?null:"source_revision_unavailable",unknownTimeBoundaries:0,normalized:[]};try{let A=await Kt(t.source,d,{since:t.since,until:a,check:n});if(A){v.nativeRevisionHash=O(["codex-window-inventory-v1",A.sha256]),v.state="skipped",v.reason="no_eligible_boundaries",e.coverage.record(t.id,v),e.progress.read(t.id,S,!1),b&&(e.scanned(t.id,S,b),o.retain(t,a,S,b,v));continue}let{files:M,preview:x,branchLeafId:R}=await De(t.source,d,{branchAnchor:vs(e,t.id,d.nativeSessionId)});v.nativeRevisionHash=O([M,Re(t.source.source)]),await n();let C=e.snapshots.prepare(M),B=!1;for(let H of x.sessions){let W=JSON.stringify([t.source.instanceId,H.sessionId,H.branchId]);e.progress.retained(t.id,S,W);let ae=H.boundaries.filter(D=>{if(D.projection!=="turn"||D.terminal==="unknown")return!1;let G=H.events[D.start]?.occurredAt;return!G||!Number.isFinite(Date.parse(G))?(v.unknownTimeBoundaries++,!1):Date.parse(G)<Date.parse(a)&&(!t.since||Date.parse(G)>=Date.parse(t.since))});v.normalized.push({sessionHash:H.contentHash,boundaries:ae.map(D=>({id:D.id,inputHash:D.inputHash,revisionHash:D.revisionHash,occurredAt:H.events[D.start].occurredAt})).sort((D,G)=>D.id<G.id?-1:D.id>G.id?1:0)}),e.coverage.record(t.id,v),B||=ae.length>0;let ct=ae.filter(D=>e.changed(t.id,W,D.id,O([D.inputHash,D.revisionHash])));for(let D=0;D<ct.length;D+=P.batchCases){await n();let G=ct.slice(D,D+P.batchCases),Ts=`sync-${O([t.id,W,G.map(V=>[V.id,V.inputHash,V.revisionHash])]).slice(0,48)}`;e.enqueue({operationId:Ts,connectionId:t.id,sessionKey:W,contentHash:H.contentHash,files:M,boundaryIds:G.map(V=>V.id),...R?{branchLeafId:R}:{}},G.map(V=>({id:V.id,revision:O([V.inputHash,V.revisionHash])})),S,C)}}e.progress.read(t.id,S,B),b&&e.scanned(t.id,S,b),await r(),v.state=B?"admitted":"skipped",v.reason=B?null:"no_eligible_boundaries",v.normalized.sort((H,W)=>H.sessionHash<W.sessionHash?-1:H.sessionHash>W.sessionHash?1:0),e.coverage.record(t.id,v),b&&o.retain(t,a,S,b,v)}catch(A){if(A instanceof le){v.state="skipped",v.reason="native_session_not_ready",e.coverage.record(t.id,v),e.progress.read(t.id,S,!1),b&&e.scanned(t.id,S,b);continue}if(A instanceof se||A instanceof K||A instanceof ie)throw A;let M=A instanceof Error?A.message:"Unable to read session";v.state="failed",v.reason="source_read_failed",e.coverage.record(t.id,v),e.progress.failed(t.id,S,M),u.push(`${d.nativeSessionId}: ${M}`)}finally{i({processed:++c})}await r()}l=y.nextCursor??void 0}while(l);if(e.progress.discovered(t.id),e.coverage.finish(t.id,h===null),h&&[...h].some(y=>!g.has(y)))throw new Error("A selected conversation is no longer available. Review the upload selection.");if(u.length)throw new Error(`${u.length} session(s) need attention. ${u[0]}`)}p(Os,"acquireCollectorSource");var K=class extends Error{static{p(this,"CollectorInterruptedError")}},ie=class extends Error{static{p(this,"CollectorScopeChangedError")}};async function Tc(s){let e=s.until??new Date().toISOString();if(!Number.isFinite(Date.parse(e))||Date.parse(e)>Date.now())throw new Error("--until must be a valid timestamp no later than now.");let t=await j.open(s.directory),n=Jn(),r=[];t.database.exec("BEGIN IMMEDIATE");try{let d=t.setting("owner");if(d){let S=JSON.parse(d),b=!0;try{process.kill(S.pid,0)}catch(N){b=N.code!=="ESRCH"}if(b){if(s.trigger==="scheduled"){t.database.exec("COMMIT"),t.close();return}throw new Error("An import is already running. Cancel it or wait for it to finish.")}}let E=new Date;if(r=t.connections().filter(S=>S.state!=="disconnected"&&S.selectedSessionKeys?.length!==0&&(!s.connectionIds||s.connectionIds.includes(S.id))&&(s.trigger!=="scheduled"||S.state==="active"&&Qt(t.schedule(S.id),t.setting(`scheduledMinute:${S.id}`),E))),s.trigger==="scheduled")for(let S of r)t.set(`scheduledMinute:${S.id}`,et(E));if(r.length&&s.trigger&&t.set("desiredState","running"),!r.length||t.setting("desiredState")!=="running"||s.signal.aborted){t.database.exec("COMMIT"),t.close();return}t.set("owner",JSON.stringify({pid:process.pid,nonce:n})),t.set("pid",String(process.pid)),t.set("heartbeatAt",E.toISOString()),t.database.exec("COMMIT")}catch(d){throw t.database.exec("ROLLBACK"),t.close(),d}let i=new AbortController,a=Date.now()+(s.maxDurationMs??P.runMs),o=AbortSignal.any([s.signal,i.signal]),l=setTimeout(()=>i.abort(new Error("Import exceeded its one-hour time budget. Remaining work is retained for the next run.")),s.maxDurationMs??P.runMs),c=setInterval(()=>{t.setting("desiredState")!=="running"?i.abort(new K("Import cancelled.")):t.set("heartbeatAt",new Date().toISOString())},250),f=new ye(t),u=new qe(t),h=p(d=>t.connections().find(E=>E.id===d.id)??d,"retained"),g=p(d=>{let E=t.queued(d.id),S=f.message(d.id,"heartbeat");return{pendingOperations:E,error:S,completedSyncRevision:!E&&!S?d.completedSyncRevision??0:0}},"heartbeatInput");function w(d,E){let S=h(d);if(S.state==="disconnected"||E.revision<S.revision)return S;let b=u.observe(S,E);E.revision>S.revision&&f.set(S.id,"control",null);let N={...S,...b,...E.revision>S.revision?{revision:E.revision,state:E.state}:{},...E.destinations?{destinations:E.destinations}:{}};return t.put(N),N}p(w,"applyRemote");function y(d,E,S){f.set(d.id,S,E instanceof Error?E.message:"Import failed.");let b=E&&typeof E=="object"&&"status"in E?Number(E.status):0,N=h(d);N.state!=="disconnected"&&[400,401,403].includes(b)&&t.put({...N,state:b===400?"paused":"disconnected"})}p(y,"recordFailure");function m(){if(Date.now()>=a&&!i.signal.aborted&&i.abort(new Error("Import time budget reached. Remaining work is retained for the next run.")),o.aborted)throw o.reason??new K("Import cancelled.");if(t.setting("desiredState")!=="running")throw new K("Import cancelled.")}p(m,"checkCancelled");try{await t.snapshots.migrate(()=>o.aborted||Date.now()>=a||t.setting("desiredState")!=="running");for(let d of r){let E="heartbeat",S=0,b={id:n,state:"running",phase:"discovering",startedAt:new Date().toISOString(),finishedAt:null,processed:0,discovered:0,uploaded:0,error:null},N=p(x=>{b={...b,...x},t.set(`run:${d.id}`,JSON.stringify(b))},"progress");N({});let v=p(async()=>{m(),E="heartbeat",d=h(d);let x=await s.transport.heartbeat(d,g(d),o);d=w(d,x),f.set(d.id,"heartbeat",null),S=Date.now()},"heartbeat"),A=p(async()=>{if(m(),Date.now()-S>=P.heartbeatMs&&await v(),d=h(d),d.state!=="active")throw new K(`Source ${d.state}.`)},"check"),M=p(async()=>{for(;t.queued(d.id);){await A();let x=t.next(d.id);if(!x)break;N({phase:"uploading"});let R=!1;for(let C=0;C<P.attemptsPerRun;C++){if(await A(),!t.database.prepare("SELECT 1 FROM pending WHERE id=? AND connection_id=?").get(x.entry.operationId,d.id)){R=!0;break}E="admission";try{await s.transport.admit(d,x.entry,o),t.acknowledge(x.entry),f.set(d.id,"admission",null),N({uploaded:b.uploaded+x.entry.boundaryIds.length}),R=!0;break}catch(B){t.retry(x.entry.operationId,x.attempts+C);let H=B&&typeof B=="object"&&"status"in B?Number(B.status):0;if(o.aborted||[400,401,403,409].includes(H)||C+1>=P.attemptsPerRun)throw B;await Gn(1e3*2**C,void 0,{signal:o})}}if(!R)throw new Error("Pending import was not acknowledged.")}},"drain");try{if(await v(),d.state!=="active")throw new K(`Source ${d.state}.`);await M();let x;for(let R=0;R<3;R++){await A();let C=d.revision,B=d.requestedSyncRevision??0,H=JSON.stringify(d.selectedSessionKeys);E="source",new ge(t).seed(d,e,t.coverage.manifest(d.id)),t.coverage.begin(d,`${n}-${R}`,b.startedAt,e);let W=p(async()=>{if(await A(),E="source",d.revision!==C||JSON.stringify(d.selectedSessionKeys)!==H)throw new ie("Source settings changed during acquisition.")},"checkAcquisition");try{await Os({store:t,connection:d,until:e,check:W,drain:p(async()=>{await M(),await W()},"drain"),progress:N})}catch(ae){if(ae instanceof ie&&R<2)continue;throw ae}if(f.set(d.id,"source",null),await M(),await s.transport.publishCoverage(d,t.coverage.finish(d.id,d.selectedSessionKeys===void 0),o),d=h(d),d.revision!==C){if(R===2)throw new Error("Source settings changed repeatedly during import. Run Sync now again.");continue}if(u.acquired(d.id,{controlRevision:C,requestedSyncRevision:B,succeeded:!0}),d=u.complete(d,f.message(d.id,"heartbeat")),await v(),d.revision!==C||u.needsAcquisition(d)){if(R===2)throw new Error("Source settings changed during completion. Run Sync now again.");continue}if(u.needsAcknowledgement(d))throw new Error("The server has not acknowledged sync completion. Retry with Sync now.");x=C;break}if(await A(),d.revision!==x)throw new ie("Source settings changed before completion. Run Sync now again.");N({state:"completed",finishedAt:new Date().toISOString()}),t.set(`lastSuccess:${d.id}`,b.finishedAt)}catch(x){let R=x instanceof K||s.signal.aborted||o.reason instanceof K,C=o.aborted?o.reason:x,B=C instanceof Error?C.message:"Import cancelled.";if(R||y(d,C,E),N({state:R?"cancelled":"failed",error:B,finishedAt:new Date().toISOString()}),t.coverage.manifest(d.id)?.jobId.startsWith(`${n}-`)){let H=t.coverage.finish(d.id,!1);if(!o.aborted&&d.state==="active")try{await s.transport.publishCoverage(d,H,o)}catch(W){y(d,W,"source")}}}if(o.aborted||t.setting("desiredState")!=="running")break}}finally{clearInterval(c),clearTimeout(l),JSON.parse(t.setting("owner")||"{}").nonce===n&&(t.set("pid",""),t.set("heartbeatAt",""),t.set("owner",""),t.set("desiredState","stopped")),t.close()}}p(Tc,"runCollector");export{ft as a,cr as b,Rt as c,pe as d,Ze as e,De as f,on as g,an as h,pi as i,ui as j,bi as k,Qe as l,cn as m,he as n,Ei as o,j as p,tc as q,sc as r,Tc as s,ya as t,Ue as u,Rn as v,fs as w,Ea as x,wa as y,$n as z,Ta as A,_s as B,jn as C};
96
+ PRIMARY KEY(connection_id,session_key));`)}selection(e,t,n){return O([e.source,e.projectId,e.teamId,e.apiBaseUrl,e.account??null,e.since,e.selectedSessionKeys??null,t,n])}read(e,t,n,r){let i=this.store.database.prepare("SELECT value FROM source_read_cache WHERE connection_id=? AND session_key=? AND selection_hash=?").get(e.id,n,this.selection(e,t,r));return i?ce.parse(JSON.parse(String(i.value))):null}retain(e,t,n,r,i){let a=ce.parse(i);a.nativeRevisionHash===null||a.state!=="admitted"&&!(a.state==="skipped"&&a.reason==="no_eligible_boundaries")||this.store.database.prepare("INSERT INTO source_read_cache VALUES(?,?,?,?) ON CONFLICT(connection_id,session_key) DO UPDATE SET selection_hash=excluded.selection_hash,value=excluded.value").run(e.id,n,this.selection(e,t,r),JSON.stringify(a))}seed(e,t,n){if(!n||n.connectionRevision!==e.revision||n.from!==e.since||n.to!==t||n.sourceInstanceId!==e.source.instanceId||n.machineId!==e.source.machineId)return;let r=new Map(n.sessions.map(i=>[i.sourceKeyHash,i]));for(let i of this.store.database.prepare("SELECT session_key,revision FROM source_scans WHERE connection_id=?").all(e.id)){let a=String(i.session_key),o=r.get(O(a));o&&this.retain(e,t,a,String(i.revision),o)}}};var Wn=["source","admission","control","heartbeat"],ye=class{static{p(this,"CollectorErrors")}store;constructor(e){this.store=e}read(e){let t=this.store.setting(`errors:${e}`);if(t)return JSON.parse(t);let n=this.store.database.prepare("SELECT error FROM backfill_units WHERE connection_id=? AND state='error' AND error IS NOT NULL ORDER BY session_key LIMIT 1").get(e);return typeof n?.error=="string"?{source:n.error}:{}}message(e,t){let n=this.read(e);return Wn.filter(r=>r!==t).map(r=>n[r]).find(Boolean)??null}source(e){return this.read(e).source??null}set(e,t,n){let r=this.read(e);n?r[t]=n.slice(0,500):delete r[t],this.store.set(`errors:${e}`,JSON.stringify(r)),this.store.error(e,this.message(e))}};var qe=class{static{p(this,"CollectorSyncRequests")}store;acquisitions=new Map;constructor(e){this.store=e}observe(e,t){let n=t.requestedSyncRevision??e.requestedSyncRevision??0,r=t.completedSyncRevision??0;if(!Number.isSafeInteger(n)||n<0||n>t.revision||!Number.isSafeInteger(r)||r<0||r>n)throw new Error("Invalid remote sync acknowledgement.");let i=this.confirmed(e.id);return r>i&&this.store.set(`syncAcknowledged:${e.id}`,String(r)),{requestedSyncRevision:Math.max(e.requestedSyncRevision??0,n),completedSyncRevision:Math.max(e.completedSyncRevision??0,r)}}needsAcquisition(e){let t=e.requestedSyncRevision??0;if(t<=(e.completedSyncRevision??0))return!1;let n=this.acquisitions.get(e.id);return n?.controlRevision!==e.revision||n.requestedSyncRevision!==t}acquired(e,t){this.acquisitions.set(e,t)}complete(e,t){let n=this.acquisitions.get(e.id),r=e.requestedSyncRevision??0;if(e.state!=="active"||this.store.setting("desiredState")!=="running"||this.store.queued(e.id)||t||!n?.succeeded||n.controlRevision!==e.revision||n.requestedSyncRevision!==r||r<=(e.completedSyncRevision??0))return e;let i={...e,completedSyncRevision:r};return this.store.put(i),i}confirmed(e){return Number(this.store.setting(`syncAcknowledged:${e}`))||0}needsAcknowledgement(e){return(e.completedSyncRevision??0)>this.confirmed(e.id)}};var zn=Y.object({leafId:Y.string().min(1).max(200),chainHash:Y.string().regex(/^[a-f0-9]{64}$/),sourceInstanceId:Y.string().min(1)}).strict(),bs=p((s,e)=>`branch:${JSON.stringify([s,e])}`,"key");function vs(s,e,t){let n=s.setting(bs(e,t));if(!n)return;let r=zn.parse(JSON.parse(n));return s.connections().find(a=>a.id===e)?.source.instanceId===r.sourceInstanceId?{leafId:r.leafId,chainHash:r.chainHash}:void 0}p(vs,"collectorBranchAnchor");async function Is(s,e){if(s.source!=="claude_code")throw new Error("Branch selection is currently supported for Claude Code.");let t,n=[];do{let r=await pe(s,{cursor:t,limit:100});n.push(...r.items.filter(i=>i.nativeSessionId===e)),t=r.nextCursor??void 0}while(t);if(n.length!==1)throw new Error("Select exactly one native session in this connection's source location.");return n[0]}p(Is,"findSession");async function tc(s,e,t){let n=await j.open(s);try{let r=n.connections().find(a=>a.id===e);if(!r)throw new Error("Select a connection from openpond import status.");let i=await Is(r.source,t);return{session:i,...await Ze(r.source,i)}}finally{n.close()}}p(tc,"inspectCollectorBranches");async function sc(s,e,t,n){let r=await j.open(s);try{let i=r.connections().find(c=>c.id===e);if(!i||i.state!=="paused")throw new Error(`Pause this connection first: openpond import pause ${e}`);let a=await Is(i.source,t),o=await Ze(i.source,a),l=o.branches.find(c=>c.leafId===n.leafId);if(o.revision!==n.revision||!l)throw new Error("This conversation changed. Refresh its branches and choose again.");await De(i.source,a,{branchLeafId:n.leafId,expectedBranchRevision:n.revision}),r.database.exec("BEGIN IMMEDIATE");try{let c=r.connections().find(u=>u.id===e);if(!c||c.state!=="paused"||c.revision!==i.revision||c.source.instanceId!==i.source.instanceId)throw new Error("Connection changed during branch selection. Refresh and try again.");r.set(bs(e,t),JSON.stringify({leafId:l.leafId,chainHash:l.chainHash,sourceInstanceId:i.source.instanceId}));for(let u of["source_scans","checkpoints","pending"])r.database.prepare(`DELETE FROM ${u} WHERE connection_id=?`).run(e);r.snapshots.collect();let f=new ye(r);f.set(e,"source",f.source(e)),r.progress.reset(e),f.set(e,"admission",null),r.database.exec("COMMIT")}catch(c){throw r.database.exec("ROLLBACK"),c}return{connectionId:e,nativeSessionId:t,leafId:l.leafId,state:"paused"}}finally{r.close()}}p(sc,"selectCollectorBranch");async function Os(s){let{store:e,connection:t,check:n,drain:r,progress:i,until:a}=s,o=new ge(e),l,c=0,f=0,u=[],h=t.selectedSessionKeys?new Set(t.selectedSessionKeys):null,g=new Set,w=0;do{await n(),i({phase:"discovering"});let y=await pe(t.source,{cursor:l,limit:50});if(w+=y.items.length,w>1e4)throw new Error("Source inventory exceeds 10,000 sessions. Select a narrower source directory.");let m=y.items.filter(d=>!h||h.has(ue(d)));for(let d of m)g.add(ue(d));f+=m.length;for(let d of m){let E=JSON.stringify([d.path,d.nativeSessionId]);e.coverage.record(t.id,{sourceKeyHash:te.sourceKey(E),nativeRevisionHash:d.storageRevision?O([d.storageRevision,xe(t.source.source)]):null,state:"reading",reason:null,unknownTimeBoundaries:0,normalized:[]})}i({discovered:f});for(let d of m){if(await n(),await r(),Number(e.database.prepare("SELECT COALESCE(SUM(bytes),0) AS n FROM pending").get()?.n)+e.snapshots.bytes()>=P.maxBytes)throw new se;i({phase:"reading"});let S=JSON.stringify([d.path,d.nativeSessionId]),b=d.storageRevision?O([d.storageRevision,xe(t.source.source)]):null;e.progress.select(t.id,S);let N=b?o.read(t,a,S,b):null;if(N){e.coverage.record(t.id,N),e.progress.read(t.id,S,N.state==="admitted"),i({processed:++c});continue}let v={sourceKeyHash:te.sourceKey(S),nativeRevisionHash:b,state:"reading",reason:b?null:"source_revision_unavailable",unknownTimeBoundaries:0,normalized:[]};try{let A=await Kt(t.source,d,{since:t.since,until:a,check:n});if(A){v.nativeRevisionHash=O(["codex-window-inventory-v1",A.sha256]),v.state="skipped",v.reason="no_eligible_boundaries",e.coverage.record(t.id,v),e.progress.read(t.id,S,!1),b&&(e.scanned(t.id,S,b),o.retain(t,a,S,b,v));continue}let{files:M,preview:x,branchLeafId:R}=await De(t.source,d,{branchAnchor:vs(e,t.id,d.nativeSessionId)});v.nativeRevisionHash=O([M,xe(t.source.source)]),await n();let C=e.snapshots.prepare(M),B=!1;for(let H of x.sessions){let W=JSON.stringify([t.source.instanceId,H.sessionId,H.branchId]);e.progress.retained(t.id,S,W);let ae=H.boundaries.filter(D=>{if(D.projection!=="turn"||D.terminal==="unknown")return!1;let G=H.events[D.start]?.occurredAt;return!G||!Number.isFinite(Date.parse(G))?(v.unknownTimeBoundaries++,!1):Date.parse(G)<Date.parse(a)&&(!t.since||Date.parse(G)>=Date.parse(t.since))});v.normalized.push({sessionHash:H.contentHash,boundaries:ae.map(D=>({id:D.id,inputHash:D.inputHash,revisionHash:D.revisionHash,occurredAt:H.events[D.start].occurredAt})).sort((D,G)=>D.id<G.id?-1:D.id>G.id?1:0)}),e.coverage.record(t.id,v),B||=ae.length>0;let ct=ae.filter(D=>e.changed(t.id,W,D.id,O([D.inputHash,D.revisionHash])));for(let D=0;D<ct.length;D+=P.batchCases){await n();let G=ct.slice(D,D+P.batchCases),Ts=`sync-${O([t.id,W,G.map(V=>[V.id,V.inputHash,V.revisionHash])]).slice(0,48)}`;e.enqueue({operationId:Ts,connectionId:t.id,sessionKey:W,contentHash:H.contentHash,files:M,boundaryIds:G.map(V=>V.id),...R?{branchLeafId:R}:{}},G.map(V=>({id:V.id,revision:O([V.inputHash,V.revisionHash])})),S,C)}}e.progress.read(t.id,S,B),b&&e.scanned(t.id,S,b),await r(),v.state=B?"admitted":"skipped",v.reason=B?null:"no_eligible_boundaries",v.normalized.sort((H,W)=>H.sessionHash<W.sessionHash?-1:H.sessionHash>W.sessionHash?1:0),e.coverage.record(t.id,v),b&&o.retain(t,a,S,b,v)}catch(A){if(A instanceof le){v.state="skipped",v.reason="native_session_not_ready",e.coverage.record(t.id,v),e.progress.read(t.id,S,!1),b&&e.scanned(t.id,S,b);continue}if(A instanceof se||A instanceof K||A instanceof ie)throw A;let M=A instanceof Error?A.message:"Unable to read session";v.state="failed",v.reason="source_read_failed",e.coverage.record(t.id,v),e.progress.failed(t.id,S,M),u.push(`${d.nativeSessionId}: ${M}`)}finally{i({processed:++c})}await r()}l=y.nextCursor??void 0}while(l);if(e.progress.discovered(t.id),e.coverage.finish(t.id,h===null),h&&[...h].some(y=>!g.has(y)))throw new Error("A selected conversation is no longer available. Review the upload selection.");if(u.length)throw new Error(`${u.length} session(s) need attention. ${u[0]}`)}p(Os,"acquireCollectorSource");var K=class extends Error{static{p(this,"CollectorInterruptedError")}},ie=class extends Error{static{p(this,"CollectorScopeChangedError")}};async function Tc(s){let e=s.until??new Date().toISOString();if(!Number.isFinite(Date.parse(e))||Date.parse(e)>Date.now())throw new Error("--until must be a valid timestamp no later than now.");let t=await j.open(s.directory),n=Jn(),r=[];t.database.exec("BEGIN IMMEDIATE");try{let d=t.setting("owner");if(d){let S=JSON.parse(d),b=!0;try{process.kill(S.pid,0)}catch(N){b=N.code!=="ESRCH"}if(b){if(s.trigger==="scheduled"){t.database.exec("COMMIT"),t.close();return}throw new Error("An import is already running. Cancel it or wait for it to finish.")}}let E=new Date;if(r=t.connections().filter(S=>S.state!=="disconnected"&&S.selectedSessionKeys?.length!==0&&(!s.connectionIds||s.connectionIds.includes(S.id))&&(s.trigger!=="scheduled"||S.state==="active"&&Qt(t.schedule(S.id),t.setting(`scheduledMinute:${S.id}`),E))),s.trigger==="scheduled")for(let S of r)t.set(`scheduledMinute:${S.id}`,et(E));if(r.length&&s.trigger&&t.set("desiredState","running"),!r.length||t.setting("desiredState")!=="running"||s.signal.aborted){t.database.exec("COMMIT"),t.close();return}t.set("owner",JSON.stringify({pid:process.pid,nonce:n})),t.set("pid",String(process.pid)),t.set("heartbeatAt",E.toISOString()),t.database.exec("COMMIT")}catch(d){throw t.database.exec("ROLLBACK"),t.close(),d}let i=new AbortController,a=Date.now()+(s.maxDurationMs??P.runMs),o=AbortSignal.any([s.signal,i.signal]),l=setTimeout(()=>i.abort(new Error("Import exceeded its one-hour time budget. Remaining work is retained for the next run.")),s.maxDurationMs??P.runMs),c=setInterval(()=>{t.setting("desiredState")!=="running"?i.abort(new K("Import cancelled.")):t.set("heartbeatAt",new Date().toISOString())},250),f=new ye(t),u=new qe(t),h=p(d=>t.connections().find(E=>E.id===d.id)??d,"retained"),g=p(d=>{let E=t.queued(d.id),S=f.message(d.id,"heartbeat");return{pendingOperations:E,error:S,completedSyncRevision:!E&&!S?d.completedSyncRevision??0:0}},"heartbeatInput");function w(d,E){let S=h(d);if(S.state==="disconnected"||E.revision<S.revision)return S;let b=u.observe(S,E);E.revision>S.revision&&f.set(S.id,"control",null);let N={...S,...b,...E.revision>S.revision?{revision:E.revision,state:E.state}:{},...E.destinations?{destinations:E.destinations}:{}};return t.put(N),N}p(w,"applyRemote");function y(d,E,S){f.set(d.id,S,E instanceof Error?E.message:"Import failed.");let b=E&&typeof E=="object"&&"status"in E?Number(E.status):0,N=h(d);N.state!=="disconnected"&&[400,401,403].includes(b)&&t.put({...N,state:b===400?"paused":"disconnected"})}p(y,"recordFailure");function m(){if(Date.now()>=a&&!i.signal.aborted&&i.abort(new Error("Import time budget reached. Remaining work is retained for the next run.")),o.aborted)throw o.reason??new K("Import cancelled.");if(t.setting("desiredState")!=="running")throw new K("Import cancelled.")}p(m,"checkCancelled");try{await t.snapshots.migrate(()=>o.aborted||Date.now()>=a||t.setting("desiredState")!=="running");for(let d of r){let E="heartbeat",S=0,b={id:n,state:"running",phase:"discovering",startedAt:new Date().toISOString(),finishedAt:null,processed:0,discovered:0,uploaded:0,error:null},N=p(x=>{b={...b,...x},t.set(`run:${d.id}`,JSON.stringify(b))},"progress");N({});let v=p(async()=>{m(),E="heartbeat",d=h(d);let x=await s.transport.heartbeat(d,g(d),o);d=w(d,x),f.set(d.id,"heartbeat",null),S=Date.now()},"heartbeat"),A=p(async()=>{if(m(),Date.now()-S>=P.heartbeatMs&&await v(),d=h(d),d.state!=="active")throw new K(`Source ${d.state}.`)},"check"),M=p(async()=>{for(;t.queued(d.id);){await A();let x=t.next(d.id);if(!x)break;N({phase:"uploading"});let R=!1;for(let C=0;C<P.attemptsPerRun;C++){if(await A(),!t.database.prepare("SELECT 1 FROM pending WHERE id=? AND connection_id=?").get(x.entry.operationId,d.id)){R=!0;break}E="admission";try{await s.transport.admit(d,x.entry,o),t.acknowledge(x.entry),f.set(d.id,"admission",null),N({uploaded:b.uploaded+x.entry.boundaryIds.length}),R=!0;break}catch(B){t.retry(x.entry.operationId,x.attempts+C);let H=B&&typeof B=="object"&&"status"in B?Number(B.status):0;if(o.aborted||[400,401,403,409].includes(H)||C+1>=P.attemptsPerRun)throw B;await Gn(1e3*2**C,void 0,{signal:o})}}if(!R)throw new Error("Pending import was not acknowledged.")}},"drain");try{if(await v(),d.state!=="active")throw new K(`Source ${d.state}.`);await M();let x;for(let R=0;R<3;R++){await A();let C=d.revision,B=d.requestedSyncRevision??0,H=JSON.stringify(d.selectedSessionKeys);E="source",new ge(t).seed(d,e,t.coverage.manifest(d.id)),t.coverage.begin(d,`${n}-${R}`,b.startedAt,e);let W=p(async()=>{if(await A(),E="source",d.revision!==C||JSON.stringify(d.selectedSessionKeys)!==H)throw new ie("Source settings changed during acquisition.")},"checkAcquisition");try{await Os({store:t,connection:d,until:e,check:W,drain:p(async()=>{await M(),await W()},"drain"),progress:N})}catch(ae){if(ae instanceof ie&&R<2)continue;throw ae}if(f.set(d.id,"source",null),await M(),await s.transport.publishCoverage(d,t.coverage.finish(d.id,d.selectedSessionKeys===void 0),o),d=h(d),d.revision!==C){if(R===2)throw new Error("Source settings changed repeatedly during import. Run Sync now again.");continue}if(u.acquired(d.id,{controlRevision:C,requestedSyncRevision:B,succeeded:!0}),d=u.complete(d,f.message(d.id,"heartbeat")),await v(),d.revision!==C||u.needsAcquisition(d)){if(R===2)throw new Error("Source settings changed during completion. Run Sync now again.");continue}if(u.needsAcknowledgement(d))throw new Error("The server has not acknowledged sync completion. Retry with Sync now.");x=C;break}if(await A(),d.revision!==x)throw new ie("Source settings changed before completion. Run Sync now again.");N({state:"completed",finishedAt:new Date().toISOString()}),t.set(`lastSuccess:${d.id}`,b.finishedAt)}catch(x){let R=x instanceof K||s.signal.aborted||o.reason instanceof K,C=o.aborted?o.reason:x,B=C instanceof Error?C.message:"Import cancelled.";if(R||y(d,C,E),N({state:R?"cancelled":"failed",error:B,finishedAt:new Date().toISOString()}),t.coverage.manifest(d.id)?.jobId.startsWith(`${n}-`)){let H=t.coverage.finish(d.id,!1);if(!o.aborted&&d.state==="active")try{await s.transport.publishCoverage(d,H,o)}catch(W){y(d,W,"source")}}}if(o.aborted||t.setting("desiredState")!=="running")break}}finally{clearInterval(c),clearTimeout(l),JSON.parse(t.setting("owner")||"{}").nonce===n&&(t.set("pid",""),t.set("heartbeatAt",""),t.set("owner",""),t.set("desiredState","stopped")),t.close()}}p(Tc,"runCollector");export{vt as a,It as b,ho as c,pe as d,Ze as e,De as f,on as g,an as h,pi as i,ui as j,bi as k,Qe as l,cn as m,he as n,Ei as o,j as p,tc as q,sc as r,Tc as s,ya as t,Ue as u,Rn as v,fs as w,Ea as x,wa as y,$n as z,Ta as A,_s as B,jn as C};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as z}from"./chunk-FEAKTSRS.js";import{a as P,b as _}from"./chunk-3MVKXAH7.js";import{$ as V,Z as B}from"./chunk-6I5AUTVO.js";import{aa as S,ja as O}from"./chunk-WLZJOCLA.js";import{yb as A}from"./chunk-QAFXQHHG.js";import{v as I}from"./chunk-ZY32SZ2P.js";import{n as k}from"./chunk-RCT3O3HQ.js";import{A as g}from"./chunk-X2J2P5ZT.js";import{a as i}from"./chunk-FTQLQJQV.js";import{randomUUID as E,createHash as $}from"node:crypto";import{mkdtemp as j,mkdir as q,writeFile as R,rm as L}from"node:fs/promises";import C from"node:os";import v from"node:path";var w=g.object({score:g.number().finite().min(0).max(1).nullable(),passed:g.boolean(),feedback:g.string().max(2e4),evidenceRefs:g.array(g.string().max(240)).max(1e3).default([])}).strict().refine(e=>e.score!==null||!e.passed,{message:"Unscorable verifiers cannot pass.",path:["passed"]});function N(e){if(e==="sandbox_process")throw new Error("verifier_sandbox_process_required")}i(N,"assertIsolatedVerifierRuntime");var ce=i(async e=>{let r=O(e.packageValue);if(e.grader.runtime!=="sandbox_process")throw new Error("Select the sandbox process runtime for a local file grader.");if(!r.taskset.graders.some(o=>k(o)===k(e.grader)))throw new Error("The private grader differs from its package.");if(!r.taskset.tasks.some(o=>k(o)===k(e.task)))throw new Error("The private case differs from its package.");await e.authorize(),e.signal?.throwIfAborted();let s=await j(v.join(C.tmpdir(),"profile-private-grade-")),d=E();try{let o=new Map;for(let a of r.files.filter(t=>t.asset.visibility!=="policy")){let t=a.asset.path;if(v.isAbsolute(t)||t.split(/[\\/]/).some(n=>!n||n==="."||n===".."))throw new Error("Private grader asset path invalid.");let u=o.get(t);if(u){if(u.contentHash!==a.asset.contentHash||u.sizeBytes!==a.asset.sizeBytes)throw new Error("Private grader assets declare conflicting bytes at the same path.");continue}o.set(t,{contentHash:a.asset.contentHash,sizeBytes:a.asset.sizeBytes});let x=v.join(s,"package",t);await q(v.dirname(x),{recursive:!0,mode:448}),await R(x,S(a),{mode:256})}await R(v.join(s,"request.json"),JSON.stringify({task:e.task,attempt:e.evidence,input:e.task.input,output:e.evidence.output,artifacts:"artifacts"in e.evidence?e.evidence.artifacts:[],expectedOutput:e.task.expectedOutput}),{mode:256});let c=`import fs from 'node:fs/promises'; const module=await import(${JSON.stringify("./package/"+e.grader.verifierRef.path)}); const result=await module[${JSON.stringify(e.grader.exportName??"verify")}](JSON.parse(await fs.readFile('request.json','utf8'))); console.log(JSON.stringify(result));`;await R(v.join(s,"runner.mjs"),c,{mode:256});let m=await z({authorize:i(async()=>(await e.authorize(),e.signal?.throwIfAborted(),{candidateId:d,candidateRevision:1,ownerId:d,sessionId:d,turnId:d,sourceRoot:s,writablePaths:[]}),"authorize")})({candidateId:d,sessionId:d,turnId:d,expectedRevision:1,command:"/runtime/node --max-old-space-size=512 runner.mjs",timeoutMs:e.grader.timeoutMs,maxOutputBytes:7e4,signal:e.signal});if(await e.authorize(),e.signal?.throwIfAborted(),m.code!==0||m.timedOut||m.stdoutTruncated||m.stderrTruncated)throw new Error("Private grading sandbox did not complete.");return w.parse(JSON.parse(m.stdout))}finally{await L(s,{recursive:!0,force:!0})}},"executeLocalProfileVerifier");function de(e){return async r=>{if(!r.manifest)throw new Error("The hosted grader requires its admitted manifest.");await r.authorize(),r.signal?.throwIfAborted();let s="artifacts"in r.evidence&&Array.isArray(r.evidence.artifacts)?r.evidence.artifacts.map(({reference:a,title:t,contentType:u})=>({reference:a,title:t,contentType:u})):[],d="caseOwner"in r.evidence?r.evidence.caseOwner:null;if(!d?.sessionId||!d.turnId)throw new Error("The private grader has no sealed case owner.");let o=Buffer.from(JSON.stringify({manifest:r.manifest,packageValue:r.packageValue,graderId:r.grader.id,taskId:r.task.id,evidence:{...r.evidence,artifacts:s}}));if(o.length>2e7)throw new Error("The private grading package exceeds its transport limit.");let c={callId:E(),sessionId:d.sessionId,turnId:d.turnId,sha256:$("sha256").update(o).digest("hex"),sizeBytes:o.length,timeoutMs:r.grader.timeoutMs},f=i((a,t=12e4)=>e.request(V.parse({contractVersion:B,requestId:E(),operation:"profile-evaluations/grade",params:a}),t),"request");for(let a=0;a<o.length;a+=98304)await r.authorize(),r.signal?.throwIfAborted(),await f({...c,action:"upload",offset:a,contentsBase64:o.subarray(a,a+98304).toString("base64")});let m=await f({...c,action:"execute"},r.grader.timeoutMs+12e4);return await r.authorize(),r.signal?.throwIfAborted(),w.parse(m)}}i(de,"createHostedProfileVerifier");import{Worker as W}from"node:worker_threads";async function b(e){e.signal?.throwIfAborted(),_(e);let{javascriptVerifierWorkerSource:r}=await import("./javascript-verifier-worker-source-F3LSGPOY.js");e.signal?.throwIfAborted();let s=e.signal,d={source:e.source,exportName:e.exportName,value:e.value,timeoutMs:e.timeoutMs,maxResultBytes:e.maxResultBytes,deterministic:e.deterministic===!0,errorPrefix:e.errorPrefix},o=i(c=>new Error(`${e.errorPrefix}_${c}`),"error");return new Promise((c,f)=>{let m=new W(r,{eval:!0,workerData:d,execArgv:[],env:{},resourceLimits:{maxOldGenerationSizeMb:64,maxYoungGenerationSizeMb:16,stackSizeMb:4}}),a=!1,t=i(n=>{a||(a=!0,clearTimeout(x),s?.removeEventListener("abort",u),m.terminate().then(()=>{"error"in n?f(n.error):c(n.result)},f))},"finish"),u=i(()=>t({error:s?.reason instanceof Error?s.reason:o("cancelled")}),"cancel"),x=setTimeout(()=>t({error:o("timeout")}),e.timeoutMs);s?.addEventListener("abort",u,{once:!0}),m.once("error",n=>t({error:n})),m.once("exit",()=>{a||t({error:o("worker_exited_without_result")})}),m.once("message",n=>{try{if(!n||typeof n!="object"||!("ok"in n))throw o("worker_invalid_response");if(n.ok!==!0)throw new Error("error"in n&&typeof n.error=="string"?n.error:`${e.errorPrefix}_execution_failed`);if(!("result"in n))throw o("worker_invalid_response");I(n.result,e.maxResultBytes),t({result:n.result})}catch(h){t({error:h instanceof Error?h:o("worker_invalid_response")})}}),s?.aborted&&u()})}i(b,"executeJavaScriptIsolateInWorker");import{spawn as F}from"node:child_process";async function ye(e){e.signal?.throwIfAborted(),_(e);let{javascriptIsolateProcessSource:r}=await import("./javascript-isolate-process-source-ZPQKKLR4.js");e.signal?.throwIfAborted();let{signal:s,stripTypeScript:d,...o}=e,c=i(m=>new Error(`${e.errorPrefix}_${m}`),"error"),f=`globalThis.__openpondIsolateInput = JSON.parse(${JSON.stringify(JSON.stringify(o))});
3
+ ${d?`globalThis.__openpondIsolateInput.source = require("node:module").stripTypeScriptTypes(globalThis.__openpondIsolateInput.source, { mode: "strip" });
4
+ `:""}${r}`;return new Promise((m,a)=>{let t=F("node",["--max-old-space-size=64","--input-type=commonjs","-"],{stdio:["pipe","pipe","pipe"],env:{PATH:process.env.PATH},windowsHide:!0}),u,x="",n=0,h=0,y=i(p=>{u??=p,t.kill("SIGKILL")},"stop"),T=i(()=>y(s?.reason instanceof Error?s.reason:c("cancelled")),"cancel"),H=setTimeout(()=>y(e.errorPrefix==="candidate"?new P("candidate_timeout"):c("timeout")),e.timeoutMs);s?.addEventListener("abort",T,{once:!0}),t.stdout.setEncoding("utf8"),t.stdout.on("data",p=>{n+=Buffer.byteLength(p),n>e.maxResultBytes+65536?y(c("process_response_too_large")):x+=p}),t.stderr.on("data",p=>{h+=p.byteLength,h>65536&&y(c("process_stderr_too_large"))}),t.once("error",p=>{u??=p}),t.stdin.on("error",p=>y(p)),t.once("close",p=>{if(clearTimeout(H),s?.removeEventListener("abort",T),u){a(u);return}try{if(p!==0)throw c("process_exited_without_result");let l=JSON.parse(x);if(!l||typeof l!="object"||!("ok"in l))throw c("process_invalid_response");if(l.ok!==!0){let J="error"in l&&typeof l.error=="string"?l.error:`${e.errorPrefix}_execution_failed`;throw"executionError"in l&&l.executionError===!0?new P(J):new Error(J)}if(!("result"in l))throw c("process_invalid_response");I(l.result,e.maxResultBytes),m(l.result)}catch(l){a(l instanceof Error?l:c("process_invalid_response"))}}),t.stdin.end(f),s?.aborted&&T()})}i(ye,"executeJavaScriptIsolateInProcess");async function be(e){return N(e.runtime),w.parse(await b({...e,exportName:e.exportName??"verify",maxResultBytes:65536,errorPrefix:"verifier"}))}i(be,"executeJavaScriptVerifierInWorker");function Oe(e){return A(e,M)}i(Oe,"aggregateTasksetEvaluationInWorker");var M=i(async({source:e,module:r,exportName:s,scores:d,timeoutMs:o,signal:c})=>{let f=/\.[cm]?ts$/.test(r)?(await import("node:module")).stripTypeScriptTypes(e,{mode:"strip"}):e;return b({source:f,exportName:s,value:d,timeoutMs:o,signal:c,maxResultBytes:1024,deterministic:!0,errorPrefix:"metric"})},"executeMetric");var Be=M;import G from"node:path";function $e(e,r){let s=g.array(g.string().min(1).max(240)).max(16).parse(r.metadata.artifactAssetIds??[]);if(new Set(s).size!==s.length)throw new Error("An artifact fixture contains duplicate assets.");let d=0;return s.map(o=>{let c=e.files.filter(a=>a.asset.id===o),f=c[0];if(c.length!==1||!f||f.asset.visibility!=="host_private")throw new Error("Artifact fixtures require a unique private package asset.");let m=S(f);if((d+=m.length)>2e7)throw new Error("Artifact fixtures exceed their aggregate byte limit.");return{reference:{id:`fixture/${r.id}/${f.asset.path}`,contentHash:f.asset.contentHash,mediaType:f.asset.mediaType,sizeBytes:f.asset.sizeBytes},title:G.posix.basename(f.asset.path),contentType:f.asset.mediaType,base64:Buffer.from(m).toString("base64")}})}i($e,"localGraderFixtureArtifacts");export{ce as a,de as b,b as c,ye as d,be as e,$e as f,Oe as g,Be as h};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as w,d as h}from"./chunk-KOKBDIGR.js";import{c as f}from"./chunk-TGULVWPV.js";import{c as l,f as c}from"./chunk-BSHAIAXY.js";import{c as a}from"./chunk-3M53YXEI.js";import{d as u}from"./chunk-3WJQ4IGK.js";import{b as s}from"./chunk-GLUWATL5.js";import{a as i}from"./chunk-FTQLQJQV.js";import{readFile as p,stat as m}from"node:fs/promises";async function v(r,t=1048576){let o=a(r,"inputFile");if(!o)throw new Error("Provide --input-file with the exact reviewed request.");let e=await m(o);if(!e.isFile()||e.size>t)throw new Error(`The request must be a regular JSON file of at most ${t} bytes.`);let n=await p(o);if(n.byteLength>t)throw new Error("The request file grew beyond its byte allowance.");return JSON.parse(n.toString("utf8"))}i(v,"readEvaluationCommandInput");async function E(r){let t=a(r,"team");if(!t)throw new Error("Select --team for the evaluation owner.");if(r.local===!0||r.local==="true"){let e=new URL(a(r,"serverUrl")||w);if(e.protocol!=="http:"||!["localhost","127.0.0.1","[::1]"].includes(e.hostname)||e.username||e.password||e.search||e.hash||e.pathname!=="/")throw new Error("Local evaluation commands require an HTTP loopback server origin.");return{teamId:t,baseUrl:e.origin,apiKey:"local-capability",fetch:await h(e.origin)}}let o=await u();return{teamId:t,apiKey:await f(o,c(o)),baseUrl:l(r)??o.apiBaseUrl??s}}i(E,"evaluationCommandAccess");export{v as a,E as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{E as u,F as h}from"./chunk-2EPR4HLF.js";import{f as c}from"./chunk-UGOK7VTC.js";import{a as s}from"./chunk-FTQLQJQV.js";import{createHash as i}from"node:crypto";import{readFile as m}from"node:fs/promises";import y from"node:path";var U=".openpond/source-upload-cache.json",d="openpond.source-upload-cache.v1";async function E(e){try{let a=(await u(c(),"source-upload.v1",l(e)))?.payload;if(!a)return new Map;if(a.schema!==d||!a.entries)return new Map;let t=new Map;for(let[o,n]of Object.entries(a.entries))!f(n)||o!==p(n)||t.set(o,n);return t}catch{return new Map}}s(E,"readSourceUploadCache");async function b(e,r){let a=await m(e.absolutePath),t=i("sha256").update(a).digest("hex"),o=p({...e,sha256:t}),n=r.get(o);return n&&n.sha256===t&&i("sha256").update(Buffer.from(n.contentsBase64,"base64")).digest("hex")===t?{file:e,entry:{path:e.path,type:"file",contentsBase64:n.contentsBase64},sha256:n.sha256}:{file:e,entry:{path:e.path,type:"file",contentsBase64:a.toString("base64")},sha256:t}}s(b,"materializeSourceUploadFile");async function A(e,r){let a={};for(let t of r){let o={path:t.file.path,size:t.file.size,mtimeMs:t.file.mtimeMs,ctimeMs:t.file.ctimeMs,sha256:t.sha256,contentsBase64:t.entry.contentsBase64};a[p(o)]=o}await h(c(),"source-upload.v1",l(e),{schema:d,generatedAt:new Date().toISOString(),entries:a})}s(A,"writeSourceUploadCache");function p(e){return`${e.path}\0${e.sha256}`}s(p,"cacheKeyForFile");function f(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let r=e;return typeof r.path=="string"&&typeof r.size=="number"&&typeof r.mtimeMs=="number"&&typeof r.ctimeMs=="number"&&typeof r.sha256=="string"&&typeof r.contentsBase64=="string"}s(f,"isCacheEntry");function l(e){return i("sha256").update(y.resolve(e)).digest("hex")}s(l,"sourceScope");export{U as a,E as b,b as c,A as d};
2
+ import{E as u,F as h}from"./chunk-SH7POUVX.js";import{f as c}from"./chunk-UGOK7VTC.js";import{a as s}from"./chunk-FTQLQJQV.js";import{createHash as i}from"node:crypto";import{readFile as m}from"node:fs/promises";import y from"node:path";var U=".openpond/source-upload-cache.json",d="openpond.source-upload-cache.v1";async function E(e){try{let a=(await u(c(),"source-upload.v1",l(e)))?.payload;if(!a)return new Map;if(a.schema!==d||!a.entries)return new Map;let t=new Map;for(let[o,n]of Object.entries(a.entries))!f(n)||o!==p(n)||t.set(o,n);return t}catch{return new Map}}s(E,"readSourceUploadCache");async function b(e,r){let a=await m(e.absolutePath),t=i("sha256").update(a).digest("hex"),o=p({...e,sha256:t}),n=r.get(o);return n&&n.sha256===t&&i("sha256").update(Buffer.from(n.contentsBase64,"base64")).digest("hex")===t?{file:e,entry:{path:e.path,type:"file",contentsBase64:n.contentsBase64},sha256:n.sha256}:{file:e,entry:{path:e.path,type:"file",contentsBase64:a.toString("base64")},sha256:t}}s(b,"materializeSourceUploadFile");async function A(e,r){let a={};for(let t of r){let o={path:t.file.path,size:t.file.size,mtimeMs:t.file.mtimeMs,ctimeMs:t.file.ctimeMs,sha256:t.sha256,contentsBase64:t.entry.contentsBase64};a[p(o)]=o}await h(c(),"source-upload.v1",l(e),{schema:d,generatedAt:new Date().toISOString(),entries:a})}s(A,"writeSourceUploadCache");function p(e){return`${e.path}\0${e.sha256}`}s(p,"cacheKeyForFile");function f(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let r=e;return typeof r.path=="string"&&typeof r.size=="number"&&typeof r.mtimeMs=="number"&&typeof r.ctimeMs=="number"&&typeof r.sha256=="string"&&typeof r.contentsBase64=="string"}s(f,"isCacheEntry");function l(e){return i("sha256").update(y.resolve(e)).digest("hex")}s(l,"sourceScope");export{U as a,E as b,b as c,A as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{d as a,n as o}from"./chunk-XNOMIWEY.js";import{a as t}from"./chunk-FTQLQJQV.js";function i(e){return n({runtime:a(e.ports),close:e.close})}t(i,"createAppServer");function n(e){let r=!1;return{runtime:e.runtime,close:t(async()=>{r||(r=!0,await e.close?.())},"close")}}t(n,"attachAppServer");async function s(e){let r=typeof e.appServer=="function"?null:e.appServer;try{await o({host:r?.runtime??(async()=>(r=await e.appServer(),r.runtime)),readable:e.readable,writable:e.writable,hostStorageClient:e.hostStorageClient})}finally{await r?.close()}}t(s,"runAppServerJsonl");export{i as a,s as b};
2
+ import{d as a,n as o}from"./chunk-6I5AUTVO.js";import{a as t}from"./chunk-FTQLQJQV.js";function i(e){return n({runtime:a(e.ports),close:e.close})}t(i,"createAppServer");function n(e){let r=!1;return{runtime:e.runtime,close:t(async()=>{r||(r=!0,await e.close?.())},"close")}}t(n,"attachAppServer");async function s(e){let r=typeof e.appServer=="function"?null:e.appServer;try{await o({host:r?.runtime??(async()=>(r=await e.appServer(),r.runtime)),readable:e.readable,writable:e.writable,hostStorageClient:e.hostStorageClient})}finally{await r?.close()}}t(s,"runAppServerJsonl");export{i as a,s as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{m as k}from"./chunk-VVNV4NNW.js";import{a as s}from"./chunk-FTQLQJQV.js";var N=String.raw`
2
+ import{m as k}from"./chunk-RCT3O3HQ.js";import{a as s}from"./chunk-FTQLQJQV.js";var N=String.raw`
3
3
  const fs=require('node:fs'),p=require('node:path'),crypto=require('node:crypto');
4
4
  const q=JSON.parse(fs.readFileSync(0,'utf8')),root='/workspace/work',action=q.action,args=q.args||{};
5
5
  function file(value,write=false){if(typeof value!=='string'||!value||p.isAbsolute(value)||value.includes('\\')||value.split('/').some(x=>!x||x==='.'||x==='..'))throw Error('Use a contained candidate relative path.');const target=p.resolve(root,value);if(write&&!q.writablePaths.some(x=>value===x||value.startsWith(x+'/')))throw Error('The file is outside the selected component.');let nearest=target;while(!fs.existsSync(nearest))nearest=p.dirname(nearest);const real=fs.realpathSync(nearest);if(real!==root&&!real.startsWith(root+'/'))throw Error('Candidate symlink escapes the public source tree.');if(fs.existsSync(target)&&!fs.lstatSync(target).isFile())throw Error('Select a regular source file.');return target;}
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{a as R}from"./chunk-KCJVFLBB.js";import{jb as u,lb as E}from"./chunk-J572ANHX.js";import{a as d}from"./chunk-FTQLQJQV.js";var S=class extends R{static{d(this,"SqliteLearningStore")}async listLearningScopes(){return await this.ready,await this.writeQueue,(await this.all("SELECT DISTINCT scope FROM learning_resources ORDER BY scope",[])).map(t=>t.scope)}learningRepository(){return{transaction:d(async(t,o)=>{if(!t.trim())throw new Error("learning_scope_required");await this.ready;let a=this.writeQueue.then(async()=>{let e=this.db;if(!e)throw new Error("learning_store_closed");e.exec("BEGIN IMMEDIATE");let n=!0,i=_(e,t,()=>{if(!n)throw new Error("learning_transaction_closed")});try{let r=await o(i);return e.exec("COMMIT"),r}catch(r){throw e.exec("ROLLBACK"),r}finally{n=!1}});return this.writeQueue=a.then(()=>{},()=>{}),a},"transaction")}}};function _(s,t,o){let a=d((e,n)=>u[e].parse(JSON.parse(n.payload)),"parse");return{async get(e,n,i){o();let r=i===void 0?s.get(`SELECT history.payload FROM learning_resources current
2
+ import{a as R}from"./chunk-KCJVFLBB.js";import{jb as u,lb as E}from"./chunk-G4E3WGLM.js";import{a as d}from"./chunk-FTQLQJQV.js";var S=class extends R{static{d(this,"SqliteLearningStore")}async listLearningScopes(){return await this.ready,await this.writeQueue,(await this.all("SELECT DISTINCT scope FROM learning_resources ORDER BY scope",[])).map(t=>t.scope)}learningRepository(){return{transaction:d(async(t,o)=>{if(!t.trim())throw new Error("learning_scope_required");await this.ready;let a=this.writeQueue.then(async()=>{let e=this.db;if(!e)throw new Error("learning_store_closed");e.exec("BEGIN IMMEDIATE");let n=!0,i=_(e,t,()=>{if(!n)throw new Error("learning_transaction_closed")});try{let r=await o(i);return e.exec("COMMIT"),r}catch(r){throw e.exec("ROLLBACK"),r}finally{n=!1}});return this.writeQueue=a.then(()=>{},()=>{}),a},"transaction")}}};function _(s,t,o){let a=d((e,n)=>u[e].parse(JSON.parse(n.payload)),"parse");return{async get(e,n,i){o();let r=i===void 0?s.get(`SELECT history.payload FROM learning_resources current
3
3
  JOIN learning_revisions history USING (scope, kind, id, revision)
4
4
  WHERE current.scope = ? AND current.kind = ? AND current.id = ?`,[t,e,n]):s.get("SELECT payload FROM learning_revisions WHERE scope = ? AND kind = ? AND id = ? AND revision = ?",[t,e,n,i]);return r?a(e,r):null},async put(e,n,i,r){o(),N(s,t,e,n,i,r)},async list(e,n){o();let i=Math.max(1,Math.min(100,Math.trunc(n.limit)));if(!Number.isFinite(i))throw new Error("learning_query_limit_invalid");let r=["current.scope = ?","current.kind = ?"],c=[t,e];if(n.reviewState!==void 0){if(e!=="evidence")throw new Error("learning_review_filter_requires_evidence");let l=`EXISTS (SELECT 1 FROM learning_resources decision
5
5
  JOIN learning_revisions decision_history USING (scope, kind, id, revision)
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{b}from"./chunk-6PKXJEJM.js";import{b as P}from"./chunk-NZTCH6K5.js";import{a as T}from"./chunk-4NXEYPPX.js";import{d as q,e as I}from"./chunk-AH26AQN7.js";import{qb as k,zb as R}from"./chunk-PBZCXPPC.js";import{r as y}from"./chunk-NJLULBTM.js";import{n as i}from"./chunk-VVNV4NNW.js";import{a as d}from"./chunk-FTQLQJQV.js";import{readFile as B}from"node:fs/promises";import A from"node:path";async function O(t){let o=k.parse(t.source),s;if(t.authorizeWorkspace){let r=await t.store.getHarnessReleaseRecord(o.harnessRelease.contentHash),m=r&&await t.store.getHarnessWorkspace(r.workspaceId);if(!r||!m||r.harnessRelease.id!==o.harnessRelease.id)throw new Error("The selected immutable Harness has no persisted owning workspace.");await t.authorizeWorkspace(o,m),s=await I({workspace:m,release:r})}else s=await q(t.store,o.harnessRelease);if(!s)throw new Error("The selected immutable Harness is unavailable.");let n=s.release;if(i(o.agentSnapshot)!==i({id:n.agentSnapshot.id,contentHash:n.agentSnapshot.contentHash}))throw new Error("The selected Harness differs from its admitted Agent snapshot.");let e=A.join(n.bundlePath,"source"),p=new Map;for(let r of n.harnessRelease.files)p.set(r.path,await B(A.join(e,...r.path.split("/"))));let l=y({agentSnapshot:n.agentSnapshot,harnessRelease:n.harnessRelease,files:p});if(l.contentHash!==o.sourcePackageHash)throw new Error("The selected Harness source bytes differ from the admitted package.");let c=T(n);return b({sourcePackage:l,expectedRelease:o.harnessRelease,baseSystemPrompt:"",runtimeId:"openpond.native-standalone-experiment.v1",tools:c.map(r=>({name:r.name,inputSchema:r.inputSchema,definition:{type:"function",function:{name:r.name,description:r.description,parameters:r.inputSchema}}})),maxContextCharacters:262144}),{runtime:s,sourcePackage:l}}d(O,"resolveStandaloneExperimentSource");function C(t){if(!t.turn.completedAt)throw new Error("Native Experiment receipt requires a settled turn.");let o=Buffer.byteLength(t.output,"utf8")>t.maxOutputBytes,s=t.cancelled?"cancelled":t.timedOut?"timed_out":t.turn.status==="interrupted"?"cancelled":t.turn.status==="completed"&&!o?"completed":"policy_failure",n=s==="completed"?null:o?"Native Harness output exceeded its admitted byte limit.":s==="timed_out"?"Native Harness case timed out.":s==="cancelled"?"Native Harness case was cancelled.":"Native Harness case failed; inspect its retained turn evidence.",e={schemaVersion:"openpond.nativeHarnessExperimentAttempt.v1",taskId:t.request.taskId,status:s,output:s==="completed"?t.output:null,error:n,messages:[{role:"user",text:JSON.stringify({instructions:t.request.instructions,input:t.request.input,policyVisibleContext:t.request.policyVisibleContext})},...s==="completed"?[{role:"assistant",text:t.output,toolCalls:[]}]:[]],collected:s==="completed",environmentCleanupComplete:!0,snapshot:null,native:{sessionId:t.turn.sessionId,turnId:t.turn.id,source:t.source,admissionHash:t.request.admissionHash,modelConfigurationHash:t.request.model.configurationHash,traceHash:t.traceHash,runtimeEventRefs:t.runtimeEventRefs,startedAt:t.turn.startedAt,completedAt:t.turn.completedAt,outputHash:i(t.output),partialOutputAvailable:s!=="completed"&&t.output.length>0}};return R(e)}d(C,"sealStandaloneExperimentReceipt");function ee(t){let o=new Map;async function s(e,p){let l=e.metadata?.standaloneExperiment;if(l===void 0)return null;let c=o.get(e.id);if(!c||i(l)!==i(c.binding)||e.currentProfile||e.profileComponentBinding||e.profileWorkflowBinding||p.sessionId!==e.id||p.profileSnapshot)throw new Error("Standalone Experiment turn has no matching active execution owner.");return c.stream}d(s,"resolveSessionModelStream");async function n(e){if(!Number.isSafeInteger(e.maxOutputBytes)||e.maxOutputBytes<1||e.maxOutputBytes>8388608)throw new Error("Native Experiment requires a bounded positive output limit.");if(!e.request.harness||i(e.request.harness)!==i(e.source))throw new Error("Native Experiment source differs from its admitted case.");if(e.request.environment.kind!=="text")throw new Error("Standalone native Harness execution requires a compatible text Dataset.");if(e.request.model.messages.length)throw new Error("Standalone Harness cases use released instructions; additional raw prompt messages are not qualified.");e.signal.throwIfAborted();let{runtime:p}=await O({store:t.store,source:e.source,authorizeWorkspace:t.authorizeWorkspace}),l={executionId:e.executionId,caseId:e.request.id,admissionHash:e.request.admissionHash,source:e.source,modelConfigurationHash:e.request.model.configurationHash},c={providerId:e.request.model.providerId,modelId:e.request.model.modelId},r=await t.createSession({provider:c.providerId,modelRef:c,currentProfile:null,hiddenFromDefaultSidebar:!0,metadata:{standaloneExperiment:l}});if(r.currentProfile||r.profileComponentBinding||r.profileWorkflowBinding)throw new Error("Standalone Experiment session acquired an unrelated Profile.");await P({store:t.store,runId:r.id,workspace:p.workspace,harnessRelease:e.source.harnessRelease,admittedAt:r.createdAt});let m=AbortSignal.any([e.signal,AbortSignal.timeout(e.request.timeoutMs)]),N=d(async function*(u){if(u.model!==c.modelId)throw new Error("Native Experiment requested a different model.");for await(let a of e.stream({...u,maxTokens:e.request.model.maxOutputTokens,temperature:e.request.model.temperature,topP:e.request.model.topP,signal:u.signal?AbortSignal.any([m,u.signal]):m}))yield a},"stream");o.set(r.id,{binding:l,stream:N});let h,x=d(()=>{h??=t.interruptSessionTurn(r.id,"Standalone Experiment case cancelled or timed out."),h.catch(()=>{})},"onAbort");m.addEventListener("abort",x,{once:!0});let w=!1,g=!1;try{m.throwIfAborted();let u=[e.request.instructions,JSON.stringify({input:e.request.input,policyVisibleContext:e.request.policyVisibleContext})].filter(Boolean).join(`
2
+ import{b}from"./chunk-EICS777E.js";import{b as P}from"./chunk-2GJD23CM.js";import{a as T}from"./chunk-UOFDKMRU.js";import{d as q,e as I}from"./chunk-XHBMK6LC.js";import{fb as k,ob as R}from"./chunk-ZY32SZ2P.js";import{r as y}from"./chunk-OTDDXEQ6.js";import{n as i}from"./chunk-RCT3O3HQ.js";import{a as d}from"./chunk-FTQLQJQV.js";import{readFile as B}from"node:fs/promises";import A from"node:path";async function O(t){let o=k.parse(t.source),s;if(t.authorizeWorkspace){let r=await t.store.getHarnessReleaseRecord(o.harnessRelease.contentHash),m=r&&await t.store.getHarnessWorkspace(r.workspaceId);if(!r||!m||r.harnessRelease.id!==o.harnessRelease.id)throw new Error("The selected immutable Harness has no persisted owning workspace.");await t.authorizeWorkspace(o,m),s=await I({workspace:m,release:r})}else s=await q(t.store,o.harnessRelease);if(!s)throw new Error("The selected immutable Harness is unavailable.");let n=s.release;if(i(o.agentSnapshot)!==i({id:n.agentSnapshot.id,contentHash:n.agentSnapshot.contentHash}))throw new Error("The selected Harness differs from its admitted Agent snapshot.");let e=A.join(n.bundlePath,"source"),p=new Map;for(let r of n.harnessRelease.files)p.set(r.path,await B(A.join(e,...r.path.split("/"))));let l=y({agentSnapshot:n.agentSnapshot,harnessRelease:n.harnessRelease,files:p});if(l.contentHash!==o.sourcePackageHash)throw new Error("The selected Harness source bytes differ from the admitted package.");let c=T(n);return b({sourcePackage:l,expectedRelease:o.harnessRelease,baseSystemPrompt:"",runtimeId:"openpond.native-standalone-experiment.v1",tools:c.map(r=>({name:r.name,inputSchema:r.inputSchema,definition:{type:"function",function:{name:r.name,description:r.description,parameters:r.inputSchema}}})),maxContextCharacters:262144}),{runtime:s,sourcePackage:l}}d(O,"resolveStandaloneExperimentSource");function C(t){if(!t.turn.completedAt)throw new Error("Native Experiment receipt requires a settled turn.");let o=Buffer.byteLength(t.output,"utf8")>t.maxOutputBytes,s=t.cancelled?"cancelled":t.timedOut?"timed_out":t.turn.status==="interrupted"?"cancelled":t.turn.status==="completed"&&!o?"completed":"policy_failure",n=s==="completed"?null:o?"Native Harness output exceeded its admitted byte limit.":s==="timed_out"?"Native Harness case timed out.":s==="cancelled"?"Native Harness case was cancelled.":"Native Harness case failed; inspect its retained turn evidence.",e={schemaVersion:"openpond.nativeHarnessExperimentAttempt.v1",taskId:t.request.taskId,status:s,output:s==="completed"?t.output:null,error:n,messages:[{role:"user",text:JSON.stringify({instructions:t.request.instructions,input:t.request.input,policyVisibleContext:t.request.policyVisibleContext})},...s==="completed"?[{role:"assistant",text:t.output,toolCalls:[]}]:[]],collected:s==="completed",environmentCleanupComplete:!0,snapshot:null,native:{sessionId:t.turn.sessionId,turnId:t.turn.id,source:t.source,admissionHash:t.request.admissionHash,modelConfigurationHash:t.request.model.configurationHash,traceHash:t.traceHash,runtimeEventRefs:t.runtimeEventRefs,startedAt:t.turn.startedAt,completedAt:t.turn.completedAt,outputHash:i(t.output),partialOutputAvailable:s!=="completed"&&t.output.length>0}};return R(e)}d(C,"sealStandaloneExperimentReceipt");function ee(t){let o=new Map;async function s(e,p){let l=e.metadata?.standaloneExperiment;if(l===void 0)return null;let c=o.get(e.id);if(!c||i(l)!==i(c.binding)||e.currentProfile||e.profileComponentBinding||e.profileWorkflowBinding||p.sessionId!==e.id||p.profileSnapshot)throw new Error("Standalone Experiment turn has no matching active execution owner.");return c.stream}d(s,"resolveSessionModelStream");async function n(e){if(!Number.isSafeInteger(e.maxOutputBytes)||e.maxOutputBytes<1||e.maxOutputBytes>8388608)throw new Error("Native Experiment requires a bounded positive output limit.");if(!e.request.harness||i(e.request.harness)!==i(e.source))throw new Error("Native Experiment source differs from its admitted case.");if(e.request.environment.kind!=="text")throw new Error("Standalone native Harness execution requires a compatible text Dataset.");if(e.request.model.messages.length)throw new Error("Standalone Harness cases use released instructions; additional raw prompt messages are not qualified.");e.signal.throwIfAborted();let{runtime:p}=await O({store:t.store,source:e.source,authorizeWorkspace:t.authorizeWorkspace}),l={executionId:e.executionId,caseId:e.request.id,admissionHash:e.request.admissionHash,source:e.source,modelConfigurationHash:e.request.model.configurationHash},c={providerId:e.request.model.providerId,modelId:e.request.model.modelId},r=await t.createSession({provider:c.providerId,modelRef:c,currentProfile:null,hiddenFromDefaultSidebar:!0,metadata:{standaloneExperiment:l}});if(r.currentProfile||r.profileComponentBinding||r.profileWorkflowBinding)throw new Error("Standalone Experiment session acquired an unrelated Profile.");await P({store:t.store,runId:r.id,workspace:p.workspace,harnessRelease:e.source.harnessRelease,admittedAt:r.createdAt});let m=AbortSignal.any([e.signal,AbortSignal.timeout(e.request.timeoutMs)]),N=d(async function*(u){if(u.model!==c.modelId)throw new Error("Native Experiment requested a different model.");for await(let a of e.stream({...u,maxTokens:e.request.model.maxOutputTokens,temperature:e.request.model.temperature,topP:e.request.model.topP,signal:u.signal?AbortSignal.any([m,u.signal]):m}))yield a},"stream");o.set(r.id,{binding:l,stream:N});let h,x=d(()=>{h??=t.interruptSessionTurn(r.id,"Standalone Experiment case cancelled or timed out."),h.catch(()=>{})},"onAbort");m.addEventListener("abort",x,{once:!0});let w=!1,g=!1;try{m.throwIfAborted();let u=[e.request.instructions,JSON.stringify({input:e.request.input,policyVisibleContext:e.request.policyVisibleContext})].filter(Boolean).join(`
3
3
 
4
4
  `);w=!0;let a=await t.sendTurn(r.id,{prompt:u,modelRef:c,approvalPolicy:"on-request"});if(h&&await h,!a.completedAt||a.status==="in_progress")throw new Error("Native Experiment turn did not settle.");if(g=!0,a.profileSnapshot||!a.harnessSnapshot||i(a.harnessSnapshot.harnessRelease)!==i(e.source.harnessRelease)||i(a.modelRef)!==i(c))throw new Error("Native Experiment turn differs from its admitted model or standalone Harness.");let S=await t.store.runtimeEventsForTurn(a.id);if(S.some(f=>f.sessionId!==r.id||f.turnId!==a.id))throw new Error("Native Experiment trace contains evidence from another case.");let W=S.filter(f=>f.name==="assistant.delta"&&typeof f.output=="string").map(f=>f.output).join(""),H=i(S),E=M(S),v=C({request:e.request,source:e.source,turn:a,output:W,traceHash:H,runtimeEventRefs:E,cancelled:e.signal.aborted,timedOut:m.aborted&&!e.signal.aborted,maxOutputBytes:e.maxOutputBytes});return{sessionId:r.id,turn:a,output:v.output,traceHash:H,runtimeEventRefs:E,cleanupComplete:!0,attempt:v}}catch(u){if(w&&!g){let a=await(h??t.interruptSessionTurn(r.id,"Standalone Experiment execution failed."));if(a.status==="in_progress"||!a.completedAt)throw new Error("Standalone Experiment cleanup remains unconfirmed.",{cause:u})}throw u}finally{m.removeEventListener("abort",x),o.delete(r.id)}}return d(n,"execute"),{execute:n,resolveSessionModelStream:s}}d(ee,"createStandaloneExperimentTurnOwner");function M(t){let o=-1;for(let n=t.length-1;n>=0;n--)if(t[n]?.name.endsWith(".delta")){o=n;break}let s=t.flatMap((n,e)=>n.name.endsWith(".delta")&&e!==o?[]:[n.id]);if(s.length>1e4)throw new Error("Native Experiment trace exceeds its evidence-reference limit.");return s}d(M,"retainedEventRefs");export{O as a,ee as b};