openpond 0.2.63 → 0.2.64

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-G5GCLP44.js +2 -0
  5. package/dist/chunks/acp-agent-JM5THNMF.js +19 -0
  6. package/dist/chunks/actions-command-VLKMHCMI.js +2 -0
  7. package/dist/chunks/app-layer-DZHMJUBC.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-6LCX46RF.js +2 -0
  12. package/dist/chunks/apps-7LPKIYRY.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-T6JN4PND.js → chunk-EBOTNBUS.js} +1 -1
  68. package/dist/chunks/chunk-ECOH24MC.js +9 -0
  69. package/dist/chunks/{chunk-6PKXJEJM.js → chunk-EICS777E.js} +1 -1
  70. package/dist/chunks/{chunk-4SZ3HKHU.js → chunk-EVQISX7M.js} +1 -1
  71. package/dist/chunks/{chunk-2HAWOMZK.js → chunk-EW7CD7OA.js} +1 -1
  72. package/dist/chunks/chunk-FEQ7HNJR.js +2 -0
  73. package/dist/chunks/{chunk-IWWXIUAQ.js → chunk-FHLSLOKH.js} +8 -8
  74. package/dist/chunks/{chunk-BU27SLZP.js → chunk-FS2VKOT7.js} +1 -1
  75. package/dist/chunks/{chunk-4FNCBA3Y.js → chunk-FUFI4THX.js} +1 -1
  76. package/dist/chunks/{chunk-W5W4IODW.js → chunk-FYWQWKVS.js} +1 -1
  77. package/dist/chunks/{chunk-IZ56L2ZK.js → chunk-G4747MOW.js} +1 -1
  78. package/dist/chunks/{chunk-J572ANHX.js → chunk-G4E3WGLM.js} +4 -4
  79. package/dist/chunks/{chunk-P7HRF4FM.js → chunk-GD3RCUDH.js} +1 -1
  80. package/dist/chunks/{chunk-HUCBKXTU.js → chunk-GDJ4X2ZN.js} +1 -1
  81. package/dist/chunks/{chunk-JHR3LF2F.js → chunk-GF55VEMR.js} +1 -1
  82. package/dist/chunks/{chunk-GXCUH2VV.js → chunk-GFAI2MCJ.js} +3 -3
  83. package/dist/chunks/{chunk-KOKX7PBS.js → chunk-GI7LTJV3.js} +1 -1
  84. package/dist/chunks/{chunk-TCOTXCV6.js → chunk-GIU3Z45P.js} +1 -1
  85. package/dist/chunks/chunk-GKLZQN6P.js +161 -0
  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-R6VJDOQM.js → chunk-HQQJKWZY.js} +4 -4
  96. package/dist/chunks/{chunk-UWHIU24L.js → chunk-HVM2GUM3.js} +1 -1
  97. package/dist/chunks/{chunk-NEJLJ2XY.js → chunk-HX6GXMDK.js} +1 -1
  98. package/dist/chunks/chunk-I3NYYOSS.js +2 -0
  99. package/dist/chunks/{chunk-LV3CQ72P.js → chunk-I6VMRQF4.js} +1 -1
  100. package/dist/chunks/{chunk-QU4UE73E.js → chunk-IEVJLG3V.js} +1 -1
  101. package/dist/chunks/chunk-IOSBGCRT.js +2 -0
  102. package/dist/chunks/{chunk-SO42ZB5K.js → chunk-JBFPTEVE.js} +1 -1
  103. package/dist/chunks/{chunk-G32BO6M5.js → chunk-JD76ANPN.js} +1 -1
  104. package/dist/chunks/{chunk-ERJV5BMC.js → chunk-JFZ6USNQ.js} +1 -1
  105. package/dist/chunks/{chunk-UPWJSNL5.js → chunk-JLW5BQVO.js} +1 -1
  106. package/dist/chunks/chunk-JRGECNP3.js +2 -0
  107. package/dist/chunks/{chunk-DABBHWSF.js → chunk-KAWXVMHI.js} +1 -1
  108. package/dist/chunks/chunk-KGUPAPGR.js +2 -0
  109. package/dist/chunks/{chunk-AHOBCBVZ.js → chunk-KOKBDIGR.js} +1 -1
  110. package/dist/chunks/chunk-KTIBXRWQ.js +2 -0
  111. package/dist/chunks/chunk-L4EJ5R3B.js +23 -0
  112. package/dist/chunks/{chunk-SI5W5LBV.js → chunk-LARJARMS.js} +1 -1
  113. package/dist/chunks/{chunk-MPNJ2BB4.js → chunk-LE75SVEL.js} +1 -1
  114. package/dist/chunks/{chunk-ERT32RZA.js → chunk-LI3FTPAH.js} +5 -5
  115. package/dist/chunks/chunk-LK77GI6M.js +2 -0
  116. package/dist/chunks/chunk-LOIYNRBC.js +33 -0
  117. package/dist/chunks/{chunk-7WYL2IDD.js → chunk-LXZLLTYQ.js} +1 -1
  118. package/dist/chunks/{chunk-RZUCVF2Q.js → chunk-LYVHYT3L.js} +1 -1
  119. package/dist/chunks/{chunk-MWXW2CA6.js → chunk-LZPCA6DH.js} +1 -1
  120. package/dist/chunks/{chunk-GVARQXYI.js → chunk-M5QPL5NO.js} +1 -1
  121. package/dist/chunks/{chunk-WWQNMC7C.js → chunk-MCBRB5D6.js} +1 -1
  122. package/dist/chunks/chunk-MHPCVQOE.js +2 -0
  123. package/dist/chunks/chunk-MMJU6PZV.js +2 -0
  124. package/dist/chunks/chunk-MVPKU72J.js +4 -0
  125. package/dist/chunks/{chunk-AGVOGPAZ.js → chunk-MWS2NAHJ.js} +1 -1
  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-SQX22LQT.js +10 -0
  154. package/dist/chunks/{chunk-NLYZ5K7U.js → chunk-SSJV3VX7.js} +1 -1
  155. package/dist/chunks/chunk-TBODQT4W.js +2 -0
  156. package/dist/chunks/chunk-TGULVWPV.js +2 -0
  157. package/dist/chunks/{chunk-HIYQPZ7C.js → chunk-TPOAAJKA.js} +1 -1
  158. package/dist/chunks/{chunk-42V4NV2F.js → chunk-TVDZXDQW.js} +1 -1
  159. package/dist/chunks/{chunk-FVRII5XO.js → chunk-U2BD545L.js} +1 -1
  160. package/dist/chunks/chunk-UK5LGSGT.js +2 -0
  161. package/dist/chunks/{chunk-HFJUXKT5.js → chunk-ULJZ7NUF.js} +1 -1
  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-HPMGH7WR.js +2 -0
  195. package/dist/chunks/connected-app-executor-7DYMZCD7.js +2 -0
  196. package/dist/chunks/connected-evidence-FNHTBUDG.js +2 -0
  197. package/dist/chunks/{connected-starting-assets-JONPTII6.js → connected-starting-assets-O4X6D6BG.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-LEFFBKR7.js +2 -0
  201. package/dist/chunks/dataset-preparation-authoring-KWRTMKN6.js +4 -0
  202. package/dist/chunks/datasets-BWHI23IB.js +2 -0
  203. package/dist/chunks/desktop-test-XROQ7K5H.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-JTQIKHW6.js +2 -0
  209. package/dist/chunks/experiment-improvements-2TV2DA3K.js +2 -0
  210. package/dist/chunks/experiments-VOCZ4DW3.js +2 -0
  211. package/dist/chunks/experiments-VUJ4SEMG.js +2 -0
  212. package/dist/chunks/experiments-signal-TSTEBORD.js +2 -0
  213. package/dist/chunks/{extension-ZM6NI5O5.js → extension-UH34ZF7N.js} +1 -1
  214. package/dist/chunks/{help-7HXFWIKS.js → help-OPN36XRA.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-7WZ4RIX2.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-NVKBEYG5.js +2 -0
  227. package/dist/chunks/{import-6SI4BEKS.js → import-P5DCYMQ6.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-ZJ5DO4RT.js +3 -0
  235. package/dist/chunks/opchat-bounded-chat-JVZ5LRH2.js +2 -0
  236. package/dist/chunks/organizations-UKXORVYS.js +2 -0
  237. package/dist/chunks/{profile-O5HL5DTQ.js → profile-XL5LABHR.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-CCGEMNR7.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-L6BMKDGY.js +2 -0
  245. package/dist/chunks/{sandbox-template-27U3FQN7.js → sandbox-template-QL5ID5GJ.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-KWOSLOBH.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-LGV7UKX2.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,6 +1,6 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{D as Lr,H as Or,J as Pt,K as Cr,L as Nr,M as xr,V as Z,X as it,e as Tr,j as Er,q as br,r as Ar,s as Sr,t as vr,u as Ir}from"./chunk-BKEDG3A4.js";import{d as wr}from"./chunk-OE22TAXP.js";import{c as w,d as hr,e as R,f as gr,g as _r,h as _,i as je,j as yr,k as Rt,l as me,m as D,n as kr,o as Rr,p as he,q as Pr,r as ae,t as $}from"./chunk-UGOK7VTC.js";import{A as d}from"./chunk-PF56N7ZY.js";import{a as c}from"./chunk-FTQLQJQV.js";import{randomUUID as Dt,createHash as ho}from"node:crypto";import{promises as V,constants as Mt}from"node:fs";import Be from"node:path";var go="missing";function G(e){return e===null?go:ho("sha256").update(e).digest("hex")}c(G,"fileRevision");async function S(e){me(Be.dirname(e));try{let t=await V.lstat(e);if(!t.isFile()||t.isSymbolicLink())throw new w({code:"UNSAFE_STORAGE_PATH",path:e,message:"Storage must be a regular file, not a symbolic link.",action:"Use a regular file in the OpenPond home."});return await V.readFile(e,"utf8")}catch(t){if(R(t))return null;throw t}}c(S,"readOptionalFile");async function U(e){if(me(e),await V.mkdir(e,{recursive:!0,mode:448}),(await V.lstat(e)).isSymbolicLink())throw new w({code:"UNSAFE_STORAGE_PATH",path:e,message:"Managed storage directories cannot be symbolic links.",action:"Select a regular local storage folder."});Rt(e)}c(U,"privateDirectory");async function I(e,t,r={}){let n=Be.dirname(e);r.privateParent===!1?await V.mkdir(n,{recursive:!0,mode:448}):await U(n);let o=await V.lstat(e).catch(a=>{if(R(a))return null;throw a});if(o&&(!o.isFile()||o.isSymbolicLink()))throw new w({code:"UNSAFE_STORAGE_PATH",path:e,message:"Cannot replace a non-regular storage file.",action:"Use a regular file in the OpenPond home."});let i=Be.join(n,`.${Be.basename(e)}.${process.pid}.${Dt()}.tmp`);try{let a=await V.open(i,Mt.O_CREAT|Mt.O_EXCL|Mt.O_WRONLY,384);try{await a.writeFile(t),await a.sync()}finally{await a.close()}if(await V.rename(i,e),process.platform!=="win32"){let s=await V.open(n,"r");try{await s.sync()}finally{await s.close()}}}finally{await V.rm(i,{force:!0})}}c(I,"atomicWriteFile");async function L(e,t,r=1e4){let n=await we(e,r);try{return await t()}finally{await n()}}c(L,"withFileLock");async function _o(e,t){let r=`${e}.${process.pid}.${Dt()}.candidate`;try{let n=await V.open(r,"wx",384);try{await n.writeFile(t),await n.sync()}finally{await n.close()}await V.link(r,e)}finally{await V.rm(r,{force:!0})}}c(_o,"publishLock");async function we(e,t=1e4){await U(Be.dirname(e));let r=`${e}.lock`,n={pid:process.pid,nonce:Dt()},o=JSON.stringify(n),i=Date.now()+t;for(;;)try{await _o(r,o);break}catch(a){if(a.code!=="EEXIST")throw a;let s=await S(r);if(s){let l;try{l=JSON.parse(s).pid}catch{}if(typeof l=="number"&&Number.isInteger(l)&&l>0&&yo(l)){let p=await we(`${r}.reclaim`,Math.max(0,i-Date.now()));try{await S(r)===s&&await V.unlink(r).catch(f=>{if(!R(f))throw f})}finally{await p()}}}if(Date.now()>=i)throw new w({code:"STORAGE_BUSY",path:e,message:"Another OpenPond process is updating this storage.",action:"Wait for that process to finish, then retry. Do not delete a live process lock."});await new Promise(l=>setTimeout(l,25))}return async()=>{await S(r)===o&&await V.unlink(r)}}c(we,"acquireFileLock");function yo(e){try{return process.kill(e,0),!1}catch(t){return t.code==="ESRCH"}}c(yo,"processIsDead");async function M(e,t){let r=await S(e);if(r===null)return t();try{return JSON.parse(r)}catch(n){throw new w({code:"INVALID_STORAGE_JSON",path:e,message:"A storage file contains invalid JSON.",action:"Restore a verified backup or correct the file, then retry."},{cause:n})}}c(M,"readJsonFile");async function ba(e,t,r){return L(e,async()=>{let n=await r(await M(e,t));return await I(e,`${JSON.stringify(n,null,2)}
3
- `),n})}c(ba,"updateJsonFile");var F=d.string().trim().min(1),at=d.string().trim().max(4096),st=F.max(200).refine(e=>!["__proto__","prototype","constructor"].includes(e),"Reserved identifier"),ct=F.max(2048).refine(e=>{try{let t=new URL(e);return["http:","https:"].includes(t.protocol)&&!t.username&&!t.password&&!t.hash&&![...t.searchParams.keys()].some(r=>/(?:token|secret|password|authorization|api[_-]?key|credential)/i.test(r))}catch{return!1}},"Use an HTTP endpoint without embedded credentials; configure authentication through a credential reference."),Dr=d.strictObject({provider_id:wr,model_id:F.max(300)}),Ft=d.discriminatedUnion("mode",[d.strictObject({mode:d.literal("inherit")}),d.strictObject({mode:d.literal("custom"),ref:Dr})]),Ur=d.discriminatedUnion("source",[d.strictObject({source:d.literal("secret"),id:st}),d.strictObject({source:d.literal("env"),name:F.regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(160)})]),wo=d.strictObject({handle:F,base_url:ct.optional(),api_base_url:ct.optional(),chat_api_base_url:ct.optional(),environment:F.optional(),credential:Ur.optional(),enabled:d.boolean().optional()}),To=Tr.omit({registryId:!0,version:!0,installUrl:!0,authMethodId:!0}).extend({registryId:F.max(160).optional(),version:F.max(200).optional(),installUrl:d.string().url().optional(),authMethodId:F.max(200).optional()}),Eo=d.strictObject({acp:To.optional(),enabled:d.boolean().optional(),binary_path:F.max(4096).optional(),source_home:F.max(4096).optional(),native_mode:F.max(200).optional(),native_options:d.record(d.string().max(200),d.string().max(300)).optional(),base_url:ct.optional(),default_model:F.max(300).optional(),model_overrides:d.array(F.max(300)).max(500).optional(),credential:Ur.optional()}),Ut=d.strictObject({mode:d.enum(["auto","disabled","custom"]).optional(),custom_command:at.optional()}),Mr=d.union([d.number().int().min(1).max(32),d.literal("unlimited")]),bo=d.strictObject({enabled:d.boolean().optional(),model:Ft.optional(),isolation_mode:Ar.optional(),max_concurrent_runs:d.number().int().min(1).max(16).optional(),tool_policy:Sr.optional(),background:d.boolean().optional(),peer_messages:vr.optional()}),Ao=d.strictObject({source:d.enum(["local","github","openpond_git"]),repository_id:F,profile_id:F}),jt=d.strictObject({schema_version:d.literal(1),chat:d.strictObject({model:Dr.optional(),steer_active_responses:d.boolean().optional()}).optional(),codex:d.strictObject({reasoning_effort:xr.optional()}).optional(),permissions:d.strictObject({command_access:Nr.optional(),codex_mode:Cr.optional()}).optional(),context_compaction:d.strictObject({auto_enabled:d.boolean().optional(),trigger_percent:d.number().int().min(50).max(95).optional(),summary_model:d.literal("same_model").optional()}).optional(),subagents:d.strictObject({enabled:d.boolean().optional(),delegation_mode:Ir.optional(),default_model:Ft.optional(),max_concurrent_runs:d.number().int().min(1).max(32).optional(),max_concurrent_runs_per_provider:Mr.optional(),max_concurrent_runs_per_workspace_target:Mr.optional(),roles:d.record(br,bo).refine(e=>Object.keys(e).length<=64,"At most 64 roles").optional()}).optional(),projects:d.strictObject({branch_prefix:d.string().trim().max(48).optional(),new_project_directory:at.optional()}).optional(),defaults:d.strictObject({account_id:st.optional(),team_id:F.max(191).optional(),profile_ref:Ao.optional()}).optional(),editor:d.strictObject({language_servers:d.enum(["auto","off"]).optional(),diagnostics_while_editing:d.boolean().optional(),check_on_save:d.boolean().optional(),languages:d.strictObject({typescript:Ut.optional(),python:Ut.optional(),rust:Ut.optional()}).optional()}).optional(),training:d.strictObject({default_model:Ft.optional(),creation_mode:d.enum(["defaults","customize"]).optional(),auto_approve_evidence:d.boolean().optional()}).optional(),notifications:d.strictObject({team_chat:d.enum(["all","direct_mentions","none"]).optional()}).optional(),ui:d.strictObject({advanced_workspace_controls:d.boolean().optional()}).optional(),runtime:d.strictObject({execution_mode:d.enum(["local","hosted"]).optional(),mode:d.enum(["general","builder"]).optional()}).optional(),personalization:d.strictObject({active:F.regex(/^(builtin|custom):[a-zA-Z0-9_-]+$/).optional(),mode:d.enum(["enabled","disabled"]).optional(),user_instructions:at.optional()}).optional(),storage:d.strictObject({datasets_dir:at.optional()}).optional(),accounts:d.record(st,wo).optional(),providers:d.record(st,Eo).optional()});function ne(e,t="user"){let r=jt.parse(e);if(t==="project"){let n=new Set(["schema_version","chat","codex","permissions","context_compaction","subagents","projects","editor"]);for(let o of Object.keys(r))if(!n.has(o))throw new Error(`Setting ${o} is not permitted in project configuration.`);if(r.projects?.new_project_directory!==void 0)throw new Error("projects.new_project_directory is a user-only setting.");for(let o of Object.values(r.editor?.languages??{}))if(o.custom_command!==void 0)throw new Error("Custom editor commands must be configured in user settings.");if(r.permissions?.command_access==="full-access"||r.permissions?.codex_mode==="full-access"||r.permissions?.codex_mode==="auto-review")throw new Error("Project configuration can restrict permissions but cannot grant additional access.");for(let o of Object.values(r.subagents?.roles??{}))if(o.tool_policy&&o.tool_policy!=="read_only")throw new Error("Project roles cannot grant additional tool access.")}return r}c(ne,"validateConfigDocument");import{promises as Xt}from"node:fs";import Ne from"node:path";var lt={ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],AwaitExpression:["argument"],BinaryExpression:["left","right"],BlockStatement:["body"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],ExportAllDeclaration:["exported","source","attributes"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes"],ExportSpecifier:["local","exported"],ExpressionStatement:["expression"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportAttribute:["key","value"],ImportDeclaration:["specifiers","source","attributes"],ImportDefaultSpecifier:["local"],ImportExpression:["source","options"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXClosingFragment:[],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXFragment:["openingFragment","children","closingFragment"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes"],JSXOpeningFragment:[],JSXSpreadAttribute:["argument"],JSXSpreadChild:["expression"],JSXText:[],LabeledStatement:["label","body"],Literal:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],StaticBlock:["body"],Super:[],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},So=Object.keys(lt);for(let e of So)Object.freeze(lt[e]);Object.freeze(lt);var Fr=lt;function jr(e){let t=Object.assign({},Fr);for(let r of Object.keys(e))if(Object.hasOwn(t,r)){let n=new Set(e[r]);for(let o of t[r])n.add(o);t[r]=Object.freeze(Array.from(n))}else t[r]=Object.freeze(Array.from(e[r]));return Object.freeze(t)}c(jr,"unionWith");function Te(e){return e[e.length-1]??null}c(Te,"last");function Kt(e){return e.type==="TOMLBare"?e.name:e.value}c(Kt,"toKeyName");var qr=class{static{c(this,"TOMLVerImpl")}constructor(e,t){this.major=e,this.minor=t}lt(e,t){return this.major<e||this.major===e&&this.minor<t}gte(e,t){return this.major>e||this.major===e&&this.minor>=t}},Br=new qr(1,0),Je=new qr(1,1),vo=Je,Io={"1.0":Br,"1.0.0":Br,"1.1":Je,"1.1.0":Je,latest:Je,next:Je};function Qr(e){return e&&Io[e]||vo}c(Qr,"getTOMLVer");var $r={"unterminated-string":"Unterminated string constant","unterminated-table-key":"Unterminated table-key","unterminated-array":"Unterminated array","unterminated-inline-table":"Unterminated inline table","missing-key":"Empty bare keys are not allowed","missing-newline":"Must be a newline","missing-equals-sign":"Expected equal (=) token","missing-value":"Unspecified values are invalid","missing-comma":"Expected comma (,) token","dupe-keys":"Defining a key multiple times is invalid","unexpected-char":"Unexpected character","unexpected-token":"Unexpected token","invalid-control-character":"Control characters (codes < 0x1f and 0x7f) are not allowed","invalid-comment-character":"Invalid code point {{cp}} within comments","invalid-key-value-newline":"The key, equals sign, and value must be on the same line","invalid-inline-table-newline":"No newlines are allowed between the curly braces unless they are valid within a value","invalid-underscore":"Underscores are allowed between digits","invalid-space":"Unexpected spaces","invalid-three-quotes":"Three or more quotes are not permitted","invalid-date":"Unexpected invalid date","invalid-time":"Unexpected invalid time","invalid-leading-zero":"Leading zeros are not allowed","invalid-trailing-comma-in-inline-table":"Trailing comma is not permitted in an inline table","invalid-char-in-escape-sequence":"Invalid character in escape sequence","invalid-consecutive-dots-in-key":"Consecutive dots are not permitted in keys","invalid-code-point":"Invalid code point {{cp}}","invalid-trailing-dot-in-key":"Keys cannot end with a dot","invalid-leading-dot-in-key":"Keys cannot start with a dot"};function Lo(e,t){return t?$r[e].replace(/\{\{(.*?)\}\}/gu,(r,n)=>n in t?t[n]:`{{${n}}}`):$r[e]}c(Lo,"getMessage");var Yr=class extends SyntaxError{static{c(this,"ParseError")}constructor(e,t,r,n,o){super(Lo(e,o)),this.index=t,this.lineNumber=r,this.column=n}},u={EOF:-1,NULL:0,SOH:1,BACKSPACE:8,TABULATION:9,LINE_FEED:10,FORM_FEED:12,CARRIAGE_RETURN:13,ESCAPE:27,SO:14,US:31,SPACE:32,QUOTATION_MARK:34,HASH:35,SINGLE_QUOTE:39,PLUS_SIGN:43,COMMA:44,DASH:45,DOT:46,DIGIT_0:48,DIGIT_1:49,DIGIT_2:50,DIGIT_3:51,DIGIT_7:55,DIGIT_9:57,COLON:58,EQUALS_SIGN:61,LATIN_CAPITAL_A:65,LATIN_CAPITAL_E:69,LATIN_CAPITAL_F:70,LATIN_CAPITAL_T:84,LATIN_CAPITAL_U:85,LATIN_CAPITAL_Z:90,LEFT_BRACKET:91,BACKSLASH:92,RIGHT_BRACKET:93,UNDERSCORE:95,LATIN_SMALL_A:97,LATIN_SMALL_B:98,LATIN_SMALL_E:101,LATIN_SMALL_F:102,LATIN_SMALL_I:105,LATIN_SMALL_L:108,LATIN_SMALL_N:110,LATIN_SMALL_O:111,LATIN_SMALL_R:114,LATIN_SMALL_S:115,LATIN_SMALL_T:116,LATIN_SMALL_U:117,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,LEFT_BRACE:123,RIGHT_BRACE:125,TILDE:126,DELETE:127,PAD:128,SUPERSCRIPT_TWO:178,SUPERSCRIPT_THREE:179,SUPERSCRIPT_ONE:185,VULGAR_FRACTION_ONE_QUARTER:188,VULGAR_FRACTION_THREE_QUARTERS:190,LATIN_CAPITAL_LETTER_A_WITH_GRAVE:192,LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:214,LATIN_CAPITAL_LETTER_O_WITH_STROKE:216,LATIN_SMALL_LETTER_O_WITH_DIAERESIS:246,LATIN_SMALL_LETTER_O_WITH_STROKE:248,GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL:891,GREEK_CAPITAL_LETTER_YOT:895,CP_1FFF:8191,ZERO_WIDTH_NON_JOINER:8204,ZERO_WIDTH_JOINER:8205,UNDERTIE:8255,CHARACTER_TIE:8256,SUPERSCRIPT_ZERO:8304,CP_218F:8591,CIRCLED_DIGIT_ONE:9312,NEGATIVE_CIRCLED_DIGIT_ZERO:9471,GLAGOLITIC_CAPITAL_LETTER_AZU:11264,CP_2FEF:12271,IDEOGRAPHIC_COMMA:12289,CP_D7FF:55295,CP_E000:57344,CJK_COMPATIBILITY_IDEOGRAPH_F900:63744,ARABIC_LIGATURE_SALAAMUHU_ALAYNAA:64975,ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM:65008,REPLACEMENT_CHARACTER:65533,LINEAR_B_SYLLABLE_B008_A:65536,CP_EFFFF:983039,CP_10FFFF:1114111};function Oo(e){return e>=u.NULL&&e<=u.US}c(Oo,"isControl");function $e(e){return e===u.TABULATION||e===u.SPACE}c($e,"isWhitespace");function Vr(e){return e===u.LINE_FEED||e===u.CARRIAGE_RETURN}c(Vr,"isEOL");function Co(e){return e>=u.LATIN_CAPITAL_A&&e<=u.LATIN_CAPITAL_Z}c(Co,"isUpperLetter");function No(e){return e>=u.LATIN_SMALL_A&&e<=u.LATIN_SMALL_Z}c(No,"isLowerLetter");function xo(e){return No(e)||Co(e)}c(xo,"isLetter");function N(e){return e>=u.DIGIT_0&&e<=u.DIGIT_9}c(N,"isDigit");function Gr(e){return N(e)||e>=u.LATIN_SMALL_A&&e<=u.LATIN_SMALL_F||e>=u.LATIN_CAPITAL_A&&e<=u.LATIN_CAPITAL_F}c(Gr,"isHexDig");function ko(e){return e>=u.DIGIT_0&&e<=u.DIGIT_7}c(ko,"isOctalDig");function Ro(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}c(Ro,"isUnicodeScalarValue");function Po(e,t){let r=0,n=e.length;for(;r<n;){let o=r+n>>>1,i=e[o];if(i===t)return o+1;i<t?r=o+1:n=o}return r}c(Po,"sortedLastIndex");var Mo=class{static{c(this,"Locations")}constructor(){this.offsets=[]}addOffset(e){for(let t=this.offsets.length-1;t>=0;t--){let r=this.offsets[t];if(r===e)return;if(r<e)break}this.offsets.push(e)}getLocFromIndex(e){let t=Po(this.offsets,e)+1;return{line:t,column:e-(t===1?0:this.offsets[t-2])}}},Do=class{static{c(this,"CodePointIterator")}constructor(e){this.locs=new Mo,this.lastCodePoint=u.NULL,this.start=-1,this.end=0,this.text=e}next(){return this.lastCodePoint===u.EOF?u.EOF:this.lastCodePoint=this.moveAt(this.end)}getLocFromIndex(e){return this.locs.getLocFromIndex(e)}eat(e){return this.text.codePointAt(this.end)===e?(this.next(),!0):!1}moveAt(e){this.start=this.end=e;let t=this.text.codePointAt(this.start)??u.EOF;if(t===u.EOF)return this.end=this.start,t;if(this.end+=t>=65536?2:1,t===u.LINE_FEED)this.locs.addOffset(this.end);else if(t===u.CARRIAGE_RETURN)return this.text.codePointAt(this.end)===u.LINE_FEED&&(this.end++,this.locs.addOffset(this.end)),u.LINE_FEED;return t}},Uo=typeof BigInt<"u",Fo={16:"0x",10:"",8:"0o",2:"0b"},Zr={[u.QUOTATION_MARK]:u.QUOTATION_MARK,[u.BACKSLASH]:u.BACKSLASH,[u.LATIN_SMALL_B]:u.BACKSPACE,[u.LATIN_SMALL_F]:u.FORM_FEED,[u.LATIN_SMALL_N]:u.LINE_FEED,[u.LATIN_SMALL_R]:u.CARRIAGE_RETURN,[u.LATIN_SMALL_T]:u.TABULATION},jo={...Zr,[u.LATIN_SMALL_E]:u.ESCAPE},Bo=class{static{c(this,"Tokenizer")}constructor(e,t){this.backCode=!1,this.lastCodePoint=u.NULL,this.state="DATA",this.token=null,this.tokenStart=-1,this.valuesEnabled=!1,this.text=e,this.parserOptions=t||{},this.codePointIterator=new Do(e),this.tomlVersion=Qr(this.parserOptions.tomlVersion),this.ESCAPES=this.tomlVersion.gte(1,1)?jo:Zr}get start(){return this.codePointIterator.start}get end(){return this.codePointIterator.end}getLocFromIndex(e){return this.codePointIterator.getLocFromIndex(e)}reportParseError(e,t){let r=this.codePointIterator.start,n=this.codePointIterator.getLocFromIndex(r);throw new Yr(e,r,n.line,n.column,t)}nextToken(){let e=this.token;if(e!=null)return this.token=null,e;let t=this.lastCodePoint;for(;t!==u.EOF&&!this.token;){t=this.nextCode();let r=this[this.state](t);if(!r)throw new Error(`Unknown error: pre state=${this.state}`);this.state=r}return e=this.token,this.token=null,e}nextCode(){return this.lastCodePoint===u.EOF?u.EOF:this.backCode?(this.backCode=!1,this.lastCodePoint):this.lastCodePoint=this.codePointIterator.next()}eatCode(e){return this.lastCodePoint===u.EOF?!1:this.backCode?this.lastCodePoint===e?(this.backCode=!1,!0):!1:this.codePointIterator.eat(e)}moveAt(e){this.backCode&&(this.backCode=!1),this.lastCodePoint=this.codePointIterator.moveAt(e)}back(e){return this.backCode=!0,e}punctuatorToken(){this.startToken(),this.endToken("Punctuator","end")}startToken(){this.tokenStart=this.codePointIterator.start}endToken(e,t,r,n){let{tokenStart:o}=this,i=this.codePointIterator[t],a=[o,i],s={start:this.codePointIterator.getLocFromIndex(o),end:this.codePointIterator.getLocFromIndex(i)};if(e==="Block")this.token={type:e,value:this.text.slice(o+1,i),range:a,loc:s};else{let l,p=this.text.slice(o,i);if(e==="BasicString"||e==="LiteralString"||e==="MultiLineBasicString"||e==="MultiLineLiteralString")l={type:e,value:p,string:r,range:a,loc:s};else if(e==="Integer"){let f=r;l={type:e,value:p,number:parseInt(f,n),bigint:Uo?BigInt(Fo[n]+f):null,range:a,loc:s}}else e==="Float"?l={type:e,value:p,number:r,range:a,loc:s}:e==="Boolean"?l={type:e,value:p,boolean:r,range:a,loc:s}:e==="LocalDate"||e==="LocalTime"||e==="LocalDateTime"||e==="OffsetDateTime"?l={type:e,value:p,date:r,range:a,loc:s}:l={type:e,value:p,range:a,loc:s};this.token=l}}DATA(e){for(;$e(e)||Vr(e);)e=this.nextCode();if(e===u.HASH)return this.startToken(),"COMMENT";if(e===u.QUOTATION_MARK)return this.startToken(),"BASIC_STRING";if(e===u.SINGLE_QUOTE)return this.startToken(),"LITERAL_STRING";if(e===u.DOT||e===u.EQUALS_SIGN||e===u.LEFT_BRACKET||e===u.RIGHT_BRACKET||e===u.LEFT_BRACE||e===u.RIGHT_BRACE||e===u.COMMA)return this.punctuatorToken(),"DATA";if(this.valuesEnabled){if(e===u.DASH||e===u.PLUS_SIGN)return this.startToken(),"SIGN";if(e===u.LATIN_SMALL_N||e===u.LATIN_SMALL_I)return this.startToken(),this.back("NAN_OR_INF");if(N(e))return this.startToken(),this.back("NUMBER");if(e===u.LATIN_SMALL_T||e===u.LATIN_SMALL_F)return this.startToken(),this.back("BOOLEAN")}else if(Kr(e,this.tomlVersion))return this.startToken(),"BARE";return e===u.EOF?"DATA":this.reportParseError("unexpected-char")}COMMENT(e){let t=this.tomlVersion.gte(1,1)?r=>{$o(r)||this.reportParseError("invalid-comment-character",{cp:JSON.stringify(String.fromCodePoint(r)).slice(1,-1)})}:r=>{Ve(r)&&this.reportParseErrorControlChar()};for(;!Vr(e)&&e!==u.EOF;)t(e),e=this.nextCode();return this.endToken("Block","start"),"DATA"}BARE(e){for(;Kr(e,this.tomlVersion);)e=this.nextCode();return this.endToken("Bare","start"),this.back("DATA")}BASIC_STRING(e){if(e===u.QUOTATION_MARK)return e=this.nextCode(),e===u.QUOTATION_MARK?"MULTI_LINE_BASIC_STRING":(this.endToken("BasicString","start",""),this.back("DATA"));let t=[];for(;e!==u.QUOTATION_MARK&&e!==u.EOF&&e!==u.LINE_FEED;){if(Ve(e))return this.reportParseErrorControlChar();if(e===u.BACKSLASH){e=this.nextCode();let r=this.ESCAPES[e];if(r){t.push(r),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}return this.reportParseError("invalid-char-in-escape-sequence")}t.push(e),e=this.nextCode()}return e!==u.QUOTATION_MARK?this.reportParseError("unterminated-string"):(this.endToken("BasicString","end",String.fromCodePoint(...t)),"DATA")}MULTI_LINE_BASIC_STRING(e){let t=[];for(e===u.LINE_FEED&&(e=this.nextCode());e!==u.EOF;){if(e!==u.LINE_FEED&&Ve(e))return this.reportParseErrorControlChar();if(e===u.QUOTATION_MARK){let r=this.codePointIterator.start;if(this.eatCode(u.QUOTATION_MARK)&&this.eatCode(u.QUOTATION_MARK))return this.eatCode(u.QUOTATION_MARK)&&(t.push(u.QUOTATION_MARK),this.eatCode(u.QUOTATION_MARK)&&(t.push(u.QUOTATION_MARK),this.eatCode(u.QUOTATION_MARK)))?(this.moveAt(r),this.reportParseError("invalid-three-quotes")):(this.endToken("MultiLineBasicString","end",String.fromCodePoint(...t)),"DATA");this.moveAt(r)}if(e===u.BACKSLASH){e=this.nextCode();let r=this.ESCAPES[e];if(r){t.push(r),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}else if(e===u.LINE_FEED){for(e=this.nextCode();$e(e)||e===u.LINE_FEED;)e=this.nextCode();continue}else if($e(e)){let n=!0,o=this.codePointIterator.start,i;for(;(i=this.nextCode())!==u.EOF&&i!==u.LINE_FEED;)if(!$e(i)){this.moveAt(o),n=!1;break}if(n){for(e=this.nextCode();$e(e)||e===u.LINE_FEED;)e=this.nextCode();continue}}return this.reportParseError("invalid-char-in-escape-sequence")}t.push(e),e=this.nextCode()}return this.reportParseError("unterminated-string")}LITERAL_STRING(e){if(e===u.SINGLE_QUOTE)return e=this.nextCode(),e===u.SINGLE_QUOTE?"MULTI_LINE_LITERAL_STRING":(this.endToken("LiteralString","start",""),this.back("DATA"));let t=[];for(;e!==u.SINGLE_QUOTE&&e!==u.EOF&&e!==u.LINE_FEED;){if(Ve(e))return this.reportParseErrorControlChar();t.push(e),e=this.nextCode()}return e!==u.SINGLE_QUOTE?this.reportParseError("unterminated-string"):(this.endToken("LiteralString","end",String.fromCodePoint(...t)),"DATA")}MULTI_LINE_LITERAL_STRING(e){let t=[];for(e===u.LINE_FEED&&(e=this.nextCode());e!==u.EOF;){if(e!==u.LINE_FEED&&Ve(e))return this.reportParseErrorControlChar();if(e===u.SINGLE_QUOTE){let r=this.codePointIterator.start;if(this.eatCode(u.SINGLE_QUOTE)&&this.eatCode(u.SINGLE_QUOTE))return this.eatCode(u.SINGLE_QUOTE)&&(t.push(u.SINGLE_QUOTE),this.eatCode(u.SINGLE_QUOTE)&&(t.push(u.SINGLE_QUOTE),this.eatCode(u.SINGLE_QUOTE)))?(this.moveAt(r),this.reportParseError("invalid-three-quotes")):(this.endToken("MultiLineLiteralString","end",String.fromCodePoint(...t)),"DATA");this.moveAt(r)}t.push(e),e=this.nextCode()}return this.reportParseError("unterminated-string")}SIGN(e){return e===u.LATIN_SMALL_N||e===u.LATIN_SMALL_I?this.back("NAN_OR_INF"):N(e)?this.back("NUMBER"):this.reportParseError("unexpected-char")}NAN_OR_INF(e){if(e===u.LATIN_SMALL_N){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_A)&&this.eatCode(u.LATIN_SMALL_N))return this.endToken("Float","end",NaN),"DATA";this.moveAt(t)}else if(e===u.LATIN_SMALL_I){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_N)&&this.eatCode(u.LATIN_SMALL_F))return this.endToken("Float","end",this.text[this.tokenStart]==="-"?-1/0:1/0),"DATA";this.moveAt(t)}return this.reportParseError("unexpected-char")}NUMBER(e){let t=this.text[this.tokenStart],r=t==="+"?u.PLUS_SIGN:t==="-"?u.DASH:u.NULL;if(e===u.DIGIT_0){if(r===u.NULL){let a=this.codePointIterator.start,s=this.nextCode();if(N(s)){let l=this.nextCode();if(l===u.COLON)return this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(u.DIGIT_0,s)),minute:0,second:0},"TIME_MINUTE";if(N(l)){let p=this.nextCode();if(N(p)&&this.eatCode(u.DASH))return this.data={hasDate:!0,year:Number(String.fromCodePoint(u.DIGIT_0,s,l,p)),month:0,day:0,hour:0,minute:0,second:0},"DATE_MONTH"}return this.moveAt(a),this.reportParseError("invalid-leading-zero")}this.moveAt(a)}return e=this.nextCode(),e===u.LATIN_SMALL_X||e===u.LATIN_SMALL_O||e===u.LATIN_SMALL_B?r!==u.NULL?this.reportParseError("unexpected-char"):e===u.LATIN_SMALL_X?"HEX":e===u.LATIN_SMALL_O?"OCTAL":"BINARY":e===u.LATIN_SMALL_E||e===u.LATIN_CAPITAL_E?(this.data={minus:r===u.DASH,left:[u.DIGIT_0]},"EXPONENT_RIGHT"):e===u.DOT?(this.data={minus:r===u.DASH,absInt:[u.DIGIT_0]},"FRACTIONAL_RIGHT"):(this.endToken("Integer","start","0",10),this.back("DATA"))}let{out:n,nextCp:o,hasUnderscore:i}=this.parseDigits(e,N);return o===u.DASH&&r===u.NULL&&!i&&n.length===4?(this.data={hasDate:!0,year:Number(String.fromCodePoint(...n)),month:0,day:0,hour:0,minute:0,second:0},"DATE_MONTH"):o===u.COLON&&r===u.NULL&&!i&&n.length===2?(this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(...n)),minute:0,second:0},"TIME_MINUTE"):o===u.LATIN_SMALL_E||o===u.LATIN_CAPITAL_E?(this.data={minus:r===u.DASH,left:n},"EXPONENT_RIGHT"):o===u.DOT?(this.data={minus:r===u.DASH,absInt:n},"FRACTIONAL_RIGHT"):(this.endToken("Integer","start",r===u.DASH?String.fromCodePoint(u.DASH,...n):String.fromCodePoint(...n),10),this.back("DATA"))}HEX(e){let{out:t}=this.parseDigits(e,Gr);return this.endToken("Integer","start",String.fromCodePoint(...t),16),this.back("DATA")}OCTAL(e){let{out:t}=this.parseDigits(e,ko);return this.endToken("Integer","start",String.fromCodePoint(...t),8),this.back("DATA")}BINARY(e){let{out:t}=this.parseDigits(e,r=>r===u.DIGIT_0||r===u.DIGIT_1);return this.endToken("Integer","start",String.fromCodePoint(...t),2),this.back("DATA")}FRACTIONAL_RIGHT(e){let{minus:t,absInt:r}=this.data,{out:n,nextCp:o}=this.parseDigits(e,N),i=[...r,u.DOT,...n];if(o===u.LATIN_SMALL_E||o===u.LATIN_CAPITAL_E)return this.data={minus:t,left:i},"EXPONENT_RIGHT";let a=Number(t?String.fromCodePoint(u.DASH,...i):String.fromCodePoint(...i));return this.endToken("Float","start",a),this.back("DATA")}EXPONENT_RIGHT(e){let{left:t,minus:r}=this.data,n=!1;(e===u.DASH||e===u.PLUS_SIGN)&&(n=e===u.DASH,e=this.nextCode());let{out:o}=this.parseDigits(e,N),i=o;n&&i.unshift(u.DASH);let a=Number(r?String.fromCodePoint(u.DASH,...t,u.LATIN_SMALL_E,...i):String.fromCodePoint(...t,u.LATIN_SMALL_E,...i));return this.endToken("Float","start",a),this.back("DATA")}BOOLEAN(e){if(e===u.LATIN_SMALL_T){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_R)&&this.eatCode(u.LATIN_SMALL_U)&&this.eatCode(u.LATIN_SMALL_E))return this.endToken("Boolean","end",!0),"DATA";this.moveAt(t)}else if(e===u.LATIN_SMALL_F){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_A)&&this.eatCode(u.LATIN_SMALL_L)&&this.eatCode(u.LATIN_SMALL_S)&&this.eatCode(u.LATIN_SMALL_E))return this.endToken("Boolean","end",!1),"DATA";this.moveAt(t)}return this.reportParseError("unexpected-char")}DATE_MONTH(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),e!==u.DASH)return this.reportParseError("unexpected-char");let r=this.codePointIterator.start,n=this.data;return n.month=Number(this.text.slice(t,r)),"DATE_DAY"}DATE_DAY(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let r=this.codePointIterator.end,n=this.data;if(n.day=Number(this.text.slice(t,r)),!Go(n.year,n.month,n.day))return this.reportParseError("invalid-date");if(e=this.nextCode(),e===u.LATIN_CAPITAL_T||e===u.LATIN_SMALL_T)return"TIME_HOUR";if(e===u.SPACE){let i=this.codePointIterator.start;if(N(this.nextCode())&&N(this.nextCode()))return this.moveAt(i),"TIME_HOUR";this.moveAt(i)}let o=Ge(n,"");return this.endToken("LocalDate","start",o),this.back("DATA")}TIME_HOUR(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),e!==u.COLON)return this.reportParseError("unexpected-char");let r=this.codePointIterator.start,n=this.data;return n.hour=Number(this.text.slice(t,r)),"TIME_MINUTE"}TIME_MINUTE(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let r=this.codePointIterator.end,n=this.data;return n.minute=Number(this.text.slice(t,r)),e=this.nextCode(),e===u.COLON?"TIME_SECOND":this.tomlVersion.lt(1,1)?this.reportParseError("unexpected-char"):Bt(n.hour,n.minute,n.second)?this.processTimeEnd(e,n):this.reportParseError("invalid-time")}TIME_SECOND(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let r=this.codePointIterator.end,n=this.data;return n.second=Number(this.text.slice(t,r)),Bt(n.hour,n.minute,n.second)?(e=this.nextCode(),e===u.DOT?"TIME_SEC_FRAC":this.processTimeEnd(e,n)):this.reportParseError("invalid-time")}TIME_SEC_FRAC(e){if(!N(e))return this.reportParseError("unexpected-char");let t=this.codePointIterator.start;for(;N(e);)e=this.nextCode();let r=this.codePointIterator.start,n=this.data;return n.frac=this.text.slice(t,r),this.processTimeEnd(e,n)}processTimeEnd(e,t){if(t.hasDate){if(e===u.DASH||e===u.PLUS_SIGN)return t.offsetSign=e,"TIME_OFFSET";if(e===u.LATIN_CAPITAL_Z||e===u.LATIN_SMALL_Z){let o=Ge(t,"Z");return this.endToken("OffsetDateTime","end",o),"DATA"}let n=Ge(t,"");return this.endToken("LocalDateTime","start",n),this.back("DATA")}let r=Ge(t,"");return this.endToken("LocalTime","start",r),this.back("DATA")}TIME_OFFSET(e){if(!N(e))return this.reportParseError("unexpected-char");let t=this.codePointIterator.start;if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),e!==u.COLON)return this.reportParseError("unexpected-char");let r=this.codePointIterator.start;e=this.nextCode();let n=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let o=this.codePointIterator.end,i=Number(this.text.slice(t,r)),a=Number(this.text.slice(n,o));if(!Bt(i,a,0))return this.reportParseError("invalid-time");let s=this.data,l=Ge(s,`${String.fromCodePoint(s.offsetSign)}${ge(i,2)}:${ge(a,2)}`);return this.endToken("OffsetDateTime","end",l),"DATA"}parseDigits(e,t){if(e===u.UNDERSCORE)return this.reportParseError("invalid-underscore");if(!t(e))return this.reportParseError("unexpected-char");let r=[],n=u.NULL,o=!1;for(;t(e)||e===u.UNDERSCORE;){if(e===u.UNDERSCORE){if(o=!0,n===u.UNDERSCORE)return this.reportParseError("invalid-underscore")}else r.push(e);n=e,e=this.nextCode()}return n===u.UNDERSCORE?this.reportParseError("invalid-underscore"):{out:r,nextCp:e,hasUnderscore:o}}parseUnicode(e){let t=this.codePointIterator.start,r=this.codePointIterator.end,n=0,o;for(;(o=this.nextCode())!==u.EOF;){if(!Gr(o))return this.moveAt(t),this.reportParseError("invalid-char-in-escape-sequence");if(n++,n>=e)break}let i=this.codePointIterator.end,a=this.text.slice(r,i),s=parseInt(a,16);return Ro(s)?s:this.reportParseError("invalid-code-point",{cp:a})}reportParseErrorControlChar(){return this.reportParseError("invalid-control-character")}};function Kr(e,t){return xo(e)||N(e)||e===u.UNDERSCORE||e===u.DASH?!0:(t.lt(1,1),!1)}c(Kr,"isUnquotedKeyChar");function Ve(e){return Oo(e)&&e!==u.TABULATION||e===u.DELETE}c(Ve,"isControlOtherThanTab");function $o(e){return e===u.TABULATION||u.SPACE<=e&&e<=u.TILDE||Vo(e)}c($o,"isNonEOL");function Vo(e){return u.PAD<=e&&e<=u.CP_D7FF||u.CP_E000<=e&&e<=u.CP_10FFFF}c(Vo,"isNonAscii");function Go(e,t,r){return e>=0&&t<=12&&t>=1&&r>=1?r<=(t===2?e&3||!(e%25)&&e&15?28:29:30+(t+(t>>3)&1)):!1}c(Go,"isValidDate");function Bt(e,t,r){return!(e>=24||e<0||t>59||t<0||r>60||r<0)}c(Bt,"isValidTime");function Ge(e,t){let r=ge(e.year,4),n=e.month?ge(e.month,2):"01",o=e.day?ge(e.day,2):"01",i=ge(e.hour,2),a=ge(e.minute,2),s=ge(e.second,2),l=`${r}-${n}-${o}`,p=e.frac?`.${e.frac}`:"",f=new Date(`${l}T${i}:${a}:${s}${p}${t}`);return!isNaN(f.getTime())||e.second!==60?f:new Date(`${l}T${i}:${a}:59${p}${t}`)}c(Ge,"getDateFromDateTimeData");function ge(e,t){return String(e).padStart(t,"0")}c(ge,"padStart");var Ht=Symbol("VALUE_KIND_VALUE"),Hr=Symbol("VALUE_KIND_INTERMEDIATE"),Ko=class{static{c(this,"KeysResolver")}constructor(e){this.rootKeys=new Map,this.tables=[],this.ctx=e}applyResolveKeyForTable(e){let t=this.rootKeys,r=e.key.keys.length-1;for(let a=0;a<r;a++){let s=e.key.keys[a],l=Kt(s);e.resolvedKey.push(l);let p=t.get(l);if(!p)p={node:s,keys:new Map},t.set(l,p);else if(p.table==="array"){let f=p.peekIndex;e.resolvedKey.push(f),p=p.keys.get(f)}t=p.keys}let n=e.key.keys[r],o=Kt(n);e.resolvedKey.push(o);let i=t.get(o);if(i)if(i.table)if(i.table==="array")if(e.kind==="array"){let a={node:n,keys:new Map},s=i.peekIndex+1;e.resolvedKey.push(s),i.keys.set(s,a),i.peekIndex=s,this.tables.push({node:e,keys:a.keys})}else this.ctx.reportParseError("dupe-keys",n);else this.ctx.reportParseError("dupe-keys",n);else if(e.kind==="array")this.ctx.reportParseError("dupe-keys",n);else{let a={table:e.kind,node:n,keys:i.keys};t.set(o,a),this.tables.push({node:e,keys:a.keys})}else if(e.kind==="array"){e.resolvedKey.push(0);let a={node:n,keys:new Map};t.set(o,{table:e.kind,node:n,keys:new Map([[0,a]]),peekIndex:0}),this.tables.push({node:e,keys:a.keys})}else{let a={table:e.kind,node:n,keys:new Map};t.set(o,a),this.tables.push({node:e,keys:a.keys})}}verifyDuplicateKeys(e){for(let t of e.body)t.type==="TOMLKeyValue"&&Jt(this.ctx,this.rootKeys,t);for(let{node:t,keys:r}of this.tables)for(let n of t.body)Jt(this.ctx,r,n)}};function Jt(e,t,r){let n=t,o=Te(r.key.keys);for(let i of r.key.keys){let a=Kt(i),s=n.get(a);s?((s.value===Ht||o===i||s.table)&&e.reportParseError("dupe-keys",ut(i,s.node)),s.value=Hr):(o===i?s={value:Ht,node:i,keys:new Map}:s={value:Hr,node:i,keys:new Map},n.set(a,s)),n=s.keys}r.value.type==="TOMLInlineTable"?en(e,n,r.value):r.value.type==="TOMLArray"&&tn(e,n,r.value)}c(Jt,"verifyDuplicateKeysForKeyValue");function en(e,t,r){for(let n of r.body)Jt(e,t,n)}c(en,"verifyDuplicateKeysForInlineTable");function tn(e,t,r){let n=t;for(let o=0;o<r.elements.length;o++){let i=r.elements[o],a=n.get(o);a?e.reportParseError("dupe-keys",ut(i,a.node)):(a={value:Ht,node:i,keys:new Map},t.set(o,a),i.type==="TOMLInlineTable"?en(e,a.keys,i):i.type==="TOMLArray"&&tn(e,a.keys,i))}}c(tn,"verifyDuplicateKeysForArray");function ut(e,t){return e.range[0]<=t.range[0]?t:e}c(ut,"getAfterNode");var Ho=class{static{c(this,"Context")}constructor(e){this.tokens=[],this.comments=[],this.back=null,this.stateStack=[],this.needNewLine=!1,this.needSameLine=!1,this.currToken=null,this.prevToken=null,this.valueContainerStack=[],this.tokenizer=new Bo(e.text,e.parserOptions),this.topLevelTable=e.topLevelTable,this.table=e.topLevelTable,this.keysResolver=new Ko(this)}nextToken(e){if(this.prevToken=this.currToken,this.back?(this.currToken=this.back,this.back=null):this.currToken=this._nextTokenFromTokenizer(e),(this.needNewLine||this.needSameLine||e?.needSameLine)&&this.prevToken&&this.currToken)if(this.prevToken.loc.end.line===this.currToken.loc.start.line){if(this.needNewLine)return this.reportParseError("missing-newline",this.currToken)}else{let t=this.needSameLine||e?.needSameLine;if(t)return this.reportParseError(t,this.currToken)}return this.needNewLine=!1,this.needSameLine=!1,this.currToken}_nextTokenFromTokenizer(e){let t=this.tokenizer.valuesEnabled;e?.valuesEnabled&&(this.tokenizer.valuesEnabled=e.valuesEnabled);let r=this.tokenizer.nextToken();for(;r&&r.type==="Block";)this.comments.push(r),r=this.tokenizer.nextToken();return r&&this.tokens.push(r),this.tokenizer.valuesEnabled=t,r}backToken(){if(this.back)throw new Error("Illegal state");this.back=this.currToken,this.currToken=this.prevToken}addValueContainer(e){this.valueContainerStack.push(e),this.tokenizer.valuesEnabled=!0}consumeValueContainer(){let e=this.valueContainerStack.pop();return this.tokenizer.valuesEnabled=this.valueContainerStack.length>0,e}applyResolveKeyForTable(e){this.keysResolver.applyResolveKeyForTable(e)}verifyDuplicateKeys(){this.keysResolver.verifyDuplicateKeys(this.topLevelTable)}reportParseError(e,t){let r,n,o;if(t)r=t.range[0],n=t.loc.start.line,o=t.loc.start.column;else{r=this.tokenizer.start;let i=this.tokenizer.getLocFromIndex(r);n=i.line,o=i.column}throw new Yr(e,r,n,o)}},Jr={VALUE:"missing-value"},Jo={BasicString:"basic",MultiLineBasicString:"basic",LiteralString:"literal",MultiLineLiteralString:"literal"},zo={BasicString:"basic",LiteralString:"literal"},Wo={OffsetDateTime:"offset-date-time",LocalDateTime:"local-date-time",LocalDate:"local-date",LocalTime:"local-time"},Xo=class{static{c(this,"TOMLParser")}constructor(e,t){this.text=e,this.parserOptions=t||{},this.tomlVersion=Qr(this.parserOptions.tomlVersion)}parse(){let e={type:"Program",body:[],sourceType:"module",tokens:[],comments:[],parent:null,range:[0,0],loc:{start:{line:1,column:0},end:{line:1,column:0}}},t={type:"TOMLTopLevelTable",body:[],parent:e,range:H(e.range),loc:J(e.loc)};e.body=[t];let r=new Ho({text:this.text,parserOptions:this.parserOptions,topLevelTable:t}),n=r.nextToken();if(n){for(t.range[0]=n.range[0],t.loc.start=ft(n.loc.start);n;){let s=r.stateStack.pop()||"TABLE";r.stateStack.push(...this[s](n,r)),n=r.nextToken()}let a=r.stateStack.pop()||"TABLE";if(a in Jr)return r.reportParseError(Jr[a],null);r.table.type==="TOMLTable"&&oe(r.table,Te(r.table.body)),oe(t,Te(t.body))}r.verifyDuplicateKeys(),e.tokens=r.tokens,e.comments=r.comments;let o=r.tokenizer.end,i=r.tokenizer.getLocFromIndex(o);return e.range[1]=o,e.loc.end={line:i.line,column:i.column},e}TABLE(e,t){return dt(e)||He(e)?this.processKeyValue(e,t.table,t):Vt(e)?this.processTable(e,t.topLevelTable,t):t.reportParseError("unexpected-token",e)}VALUE(e,t){return He(e)||Xr(e)?this.processStringValue(e,t):Qo(e)?this.processNumberValue(e,t):Yo(e)?this.processBooleanValue(e,t):Zo(e)?this.processDateTimeValue(e,t):Vt(e)?this.processArray(e,t):qo(e)?this.processInlineTable(e,t):t.reportParseError("unexpected-token",e)}processTable(e,t,r){let n={type:"TOMLTable",kind:"standard",key:null,resolvedKey:[],body:[],parent:t,range:H(e.range),loc:J(e.loc)};r.table.type==="TOMLTable"&&oe(r.table,Te(r.table.body)),t.body.push(n),r.table=n;let o=r.nextToken({needSameLine:"invalid-key-value-newline"});if(Vt(o)){if(e.range[1]<o.range[0])return r.reportParseError("invalid-space",o);n.kind="array",o=r.nextToken({needSameLine:"invalid-key-value-newline"})}if(Ke(o))return r.reportParseError("missing-key",o);if(!o)return r.reportParseError("unterminated-table-key",null);if(o=this.processKeyNode(o,n,r).nextToken,!Ke(o))return r.reportParseError("unterminated-table-key",o);if(n.kind==="array"){let i=o;if(o=r.nextToken({needSameLine:"invalid-key-value-newline"}),!Ke(o))return r.reportParseError("unterminated-table-key",o);if(i.range[1]<o.range[0])return r.reportParseError("invalid-space",o)}return oe(n,o),r.applyResolveKeyForTable(n),r.needNewLine=!0,[]}processKeyValue(e,t,r){let n={type:"TOMLKeyValue",key:null,value:null,parent:t,range:H(e.range),loc:J(e.loc)};t.body.push(n);let{nextToken:o}=this.processKeyNode(e,n,r);return zr(o)?(r.addValueContainer({parent:n,set:c(i=>(n.value=i,oe(n,i),r.needNewLine=!0,[]),"set")}),r.needSameLine="invalid-key-value-newline",["VALUE"]):r.reportParseError("missing-equals-sign",o)}processKeyNode(e,t,r){$t(e)&&r.reportParseError("invalid-leading-dot-in-key",e);let n={type:"TOMLKey",keys:[],parent:t,range:H(e.range),loc:J(e.loc)};t.key=n;let o=e,i=null;do{if(dt(o))this.processBareKey(o,n);else if(He(o))this.processStringKey(o,n);else break;if(i=null,o=r.nextToken({needSameLine:"invalid-key-value-newline"}),!$t(o))break;i=o,o=r.nextToken({needSameLine:"invalid-key-value-newline"})}while(o);return i&&r.reportParseError($t(o)?"invalid-consecutive-dots-in-key":"invalid-trailing-dot-in-key",i),oe(n,Te(n.keys)),{keyNode:n,nextToken:o}}processBareKey(e,t){let r={type:"TOMLBare",name:e.value,parent:t,range:H(e.range),loc:J(e.loc)};t.keys.push(r)}processStringKey(e,t){let r={type:"TOMLQuoted",kind:"string",value:e.string,style:zo[e.type],multiline:!1,parent:t,range:H(e.range),loc:J(e.loc)};t.keys.push(r)}processStringValue(e,t){let r=t.consumeValueContainer(),n={type:"TOMLValue",kind:"string",value:e.string,style:Jo[e.type],multiline:Xr(e),parent:r.parent,range:H(e.range),loc:J(e.loc)};return r.set(n)}processNumberValue(e,t){let r=t.consumeValueContainer(),n=this.text,[o,i]=e.range,a=null,s=c(()=>a??(a=n.slice(o,i).replace(/_/g,"")),"getNumberText"),l;return e.type==="Integer"?l={type:"TOMLValue",kind:"integer",value:e.number,bigint:e.bigint,get number(){return s()},parent:r.parent,range:H(e.range),loc:J(e.loc)}:l={type:"TOMLValue",kind:"float",value:e.number,get number(){return s()},parent:r.parent,range:H(e.range),loc:J(e.loc)},r.set(l)}processBooleanValue(e,t){let r=t.consumeValueContainer(),n={type:"TOMLValue",kind:"boolean",value:e.boolean,parent:r.parent,range:H(e.range),loc:J(e.loc)};return r.set(n)}processDateTimeValue(e,t){let r=t.consumeValueContainer(),n={type:"TOMLValue",kind:Wo[e.type],value:e.date,datetime:e.value,parent:r.parent,range:H(e.range),loc:J(e.loc)};return r.set(n)}processArray(e,t){let r=t.consumeValueContainer(),n={type:"TOMLArray",elements:[],parent:r.parent,range:H(e.range),loc:J(e.loc)},o=t.nextToken({valuesEnabled:!0});return Ke(o)?(oe(n,o),r.set(n)):(t.backToken(),this.processArrayValue(n,r,t))}processArrayValue(e,t,r){return r.addValueContainer({parent:e,set:c(n=>{e.elements.push(n);let o=r.nextToken({valuesEnabled:!0}),i=Wr(o);return i&&(o=r.nextToken({valuesEnabled:!0})),Ke(o)?(oe(e,o),t.set(e)):i?(r.backToken(),this.processArrayValue(e,t,r)):r.reportParseError(o?"missing-comma":"unterminated-array",o)},"set")}),["VALUE"]}processInlineTable(e,t){let r=t.consumeValueContainer(),n={type:"TOMLInlineTable",body:[],parent:r.parent,range:H(e.range),loc:J(e.loc)},o=this.tomlVersion.gte(1,1)?void 0:"invalid-inline-table-newline",i=t.nextToken({needSameLine:o});if(i){if(dt(i)||He(i))return this.processInlineTableKeyValue(i,n,r,t);if(Gt(i))return oe(n,i),r.set(n)}return t.reportParseError("unexpected-token",i)}processInlineTableKeyValue(e,t,r,n){let o={type:"TOMLKeyValue",key:null,value:null,parent:t,range:H(e.range),loc:J(e.loc)};t.body.push(o);let{nextToken:i}=this.processKeyNode(e,o,n);if(!zr(i))return n.reportParseError("missing-equals-sign",i);let a=this.tomlVersion.gte(1,1)?void 0:"invalid-inline-table-newline";return n.addValueContainer({parent:o,set:c(s=>{o.value=s,oe(o,s);let l=n.nextToken({needSameLine:a});if(Wr(l)){if(l=n.nextToken({needSameLine:a}),l&&(dt(l)||He(l)))return this.processInlineTableKeyValue(l,t,r,n);if(Gt(l)){if(this.tomlVersion.lt(1,1))return n.reportParseError("invalid-trailing-comma-in-inline-table",l)}else return n.reportParseError(l?"unexpected-token":"unterminated-inline-table",l)}return Gt(l)?(oe(t,l),r.set(t)):n.reportParseError(l?"missing-comma":"unterminated-inline-table",l)},"set")}),n.needSameLine="invalid-key-value-newline",["VALUE"]}};function $t(e){return Ee(e)&&e.value==="."}c($t,"isDot");function zr(e){return Ee(e)&&e.value==="="}c(zr,"isEq");function Vt(e){return Ee(e)&&e.value==="["}c(Vt,"isLeftBracket");function Ke(e){return Ee(e)&&e.value==="]"}c(Ke,"isRightBracket");function qo(e){return Ee(e)&&e.value==="{"}c(qo,"isLeftBrace");function Gt(e){return Ee(e)&&e.value==="}"}c(Gt,"isRightBrace");function Wr(e){return Ee(e)&&e.value===","}c(Wr,"isComma");function Ee(e){return!!(e&&e.type==="Punctuator")}c(Ee,"isPunctuator");function dt(e){return e.type==="Bare"}c(dt,"isBare");function He(e){return e.type==="BasicString"||e.type==="LiteralString"}c(He,"isString");function Xr(e){return e.type==="MultiLineBasicString"||e.type==="MultiLineLiteralString"}c(Xr,"isMultiLineString");function Qo(e){return e.type==="Integer"||e.type==="Float"}c(Qo,"isNumber");function Yo(e){return e.type==="Boolean"}c(Yo,"isBoolean");function Zo(e){return e.type==="OffsetDateTime"||e.type==="LocalDateTime"||e.type==="LocalDate"||e.type==="LocalTime"}c(Zo,"isDateTime");function oe(e,t){t&&(e.range[1]=t.range[1],e.loc.end=ft(t.loc.end))}c(oe,"applyEndLoc");function H(e){return[e[0],e[1]]}c(H,"cloneRange");function J(e){return{start:ft(e.start),end:ft(e.end)}}c(J,"cloneLoc");function ft(e){return{line:e.line,column:e.column}}c(ft,"clonePos");var ei={Program:["body"],TOMLTopLevelTable:["body"],TOMLTable:["key","body"],TOMLKeyValue:["key","value"],TOMLKey:["keys"],TOMLArray:["elements"],TOMLInlineTable:["body"],TOMLBare:[],TOMLQuoted:[],TOMLValue:[]},ti=jr(ei);function ri(e,t){return{ast:new Xo(e,t).parse(),visitorKeys:ti,services:{isTOML:!0}}}c(ri,"parseForESLint");var zt=ni(e=>e.value);function ni(e){function t(n,o){return r[n.type](n,o)}c(t,"resolveValue");let r={Program(n,o={}){return t(n.body[0],o)},TOMLTopLevelTable(n,o={}){for(let i of n.body)t(i,o);return o},TOMLKeyValue(n,o={}){let i=t(n.value);return ii(o,t(n.key),i),o},TOMLTable(n,o={}){let i=oi(o,t(n.key),n.kind==="array");for(let a of n.body)t(a,i);return o},TOMLArray(n){return n.elements.map(o=>t(o))},TOMLInlineTable(n){let o={};for(let i of n.body)t(i,o);return o},TOMLKey(n){return n.keys.map(o=>t(o))},TOMLBare(n){return n.name},TOMLQuoted(n){return n.value},TOMLValue(n){return e(n)}};return n=>t(n)}c(ni,"generateConvertTOMLValue");function oi(e,t,r){let n=e;for(let l=0;l<t.length-1;l++){let p=t[l];n=s(n,p)}let o=Te(t),i=n[o];if(i==null){let l={};return n[o]=r?[l]:l,l}if(pt(i)){let l={};return n[o]=r?[l]:l,l}if(!r){if(Array.isArray(i)){let l={};return n[o]=l,l}return i}if(Array.isArray(i)){let l={};return i.push(l),l}let a={};return n[o]=[a],a;function s(l,p){let f=l[p];if(f==null){let m={};return l[p]=m,m}if(pt(f)){let m={};return l[p]=m,m}let g=f;for(;Array.isArray(g);){let m=g.length-1,h=g[m];if(pt(h)){let y={};return g[m]=y,y}g=h}return g}c(s,"getNextTargetFromKey")}c(oi,"getTable");function ii(e,t,r){let n=e;for(let o=0;o<t.length-1;o++){let i=t[o],a=n[i];if(a==null){let s={};n[i]=s,n=s}else if(pt(a)||Array.isArray(a)){let s={};n[i]=s,n=s}else n=a}n[Te(t)]=r}c(ii,"set");function pt(e){return typeof e!="object"||e instanceof Date}c(pt,"isValue");function rn(e,t){return ri(e,t).ast}c(rn,"parseTOML");function te(e,t){try{let r=rn(e,{tomlVersion:"1.0"}),n=zt(r);return an(n),{ast:r,value:n}}catch(r){let n=r;throw new w({code:"INVALID_CONFIG",path:t,message:"Configuration contains invalid TOML or an unsupported value.",line:n.lineNumber,column:n.column===void 0?void 0:n.column+1,action:"Open config.toml, correct the indicated value, and retry."},{cause:r})}}c(te,"parseToml");function an(e){if(e instanceof Date||typeof e=="bigint"||typeof e=="number"&&(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)))throw new Error("Unsupported TOML value");if(e&&typeof e=="object")for(let[t,r]of Object.entries(e)){if(["__proto__","prototype","constructor"].includes(t))throw new Error("Reserved key");an(r)}}c(an,"assertJsonValue");function _e(e){if(typeof e=="string")return JSON.stringify(e).replace(/\\u([0-9a-f]{4})/gi,"\\u$1");if(typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e))return`[${e.map(_e).join(", ")}]`;if(se(e))return`{ ${Object.entries(e).filter(([,t])=>t!==void 0).map(([t,r])=>`${be(t)} = ${_e(r)}`).join(", ")} }`;throw new Error("Configuration cannot contain null or unsupported values.")}c(_e,"tomlValue");var be=c(e=>/^[A-Za-z0-9_-]+$/.test(e)?e:JSON.stringify(e),"tomlKey"),nn=c(e=>e.keys.map(t=>t.type==="TOMLBare"?t.name:t.value),"keyPath"),ai=c((e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),"samePath"),mt=c((e,t)=>e.length<=t.length&&e.every((r,n)=>r===t[n]),"prefix");function se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Date)}c(se,"isRecord");function ze(e,t,r){let n=e;for(let o of t)n=sn(n,o,r);return te(n,r),n.endsWith(`
2
+ import{D as Lr,H as Or,J as Pt,K as Cr,L as Nr,M as xr,V as Z,X as it,e as Tr,j as Er,q as br,r as Ar,s as Sr,t as vr,u as Ir}from"./chunk-2MEOUS24.js";import{d as hr}from"./chunk-HNQPEOJD.js";import{A as d}from"./chunk-X2J2P5ZT.js";import{c as w,d as gr,e as R,f as _r,g as yr,h as _,i as je,j as wr,k as Rt,l as me,m as D,n as kr,o as Rr,p as he,q as Pr,r as ae,t as $}from"./chunk-UGOK7VTC.js";import{a as c}from"./chunk-FTQLQJQV.js";import{randomUUID as Dt,createHash as ho}from"node:crypto";import{promises as V,constants as Mt}from"node:fs";import Be from"node:path";var go="missing";function G(e){return e===null?go:ho("sha256").update(e).digest("hex")}c(G,"fileRevision");async function S(e){me(Be.dirname(e));try{let t=await V.lstat(e);if(!t.isFile()||t.isSymbolicLink())throw new w({code:"UNSAFE_STORAGE_PATH",path:e,message:"Storage must be a regular file, not a symbolic link.",action:"Use a regular file in the OpenPond home."});return await V.readFile(e,"utf8")}catch(t){if(R(t))return null;throw t}}c(S,"readOptionalFile");async function U(e){if(me(e),await V.mkdir(e,{recursive:!0,mode:448}),(await V.lstat(e)).isSymbolicLink())throw new w({code:"UNSAFE_STORAGE_PATH",path:e,message:"Managed storage directories cannot be symbolic links.",action:"Select a regular local storage folder."});Rt(e)}c(U,"privateDirectory");async function I(e,t,r={}){let n=Be.dirname(e);r.privateParent===!1?await V.mkdir(n,{recursive:!0,mode:448}):await U(n);let o=await V.lstat(e).catch(a=>{if(R(a))return null;throw a});if(o&&(!o.isFile()||o.isSymbolicLink()))throw new w({code:"UNSAFE_STORAGE_PATH",path:e,message:"Cannot replace a non-regular storage file.",action:"Use a regular file in the OpenPond home."});let i=Be.join(n,`.${Be.basename(e)}.${process.pid}.${Dt()}.tmp`);try{let a=await V.open(i,Mt.O_CREAT|Mt.O_EXCL|Mt.O_WRONLY,384);try{await a.writeFile(t),await a.sync()}finally{await a.close()}if(await V.rename(i,e),process.platform!=="win32"){let s=await V.open(n,"r");try{await s.sync()}finally{await s.close()}}}finally{await V.rm(i,{force:!0})}}c(I,"atomicWriteFile");async function L(e,t,r=1e4){let n=await we(e,r);try{return await t()}finally{await n()}}c(L,"withFileLock");async function _o(e,t){let r=`${e}.${process.pid}.${Dt()}.candidate`;try{let n=await V.open(r,"wx",384);try{await n.writeFile(t),await n.sync()}finally{await n.close()}await V.link(r,e)}finally{await V.rm(r,{force:!0})}}c(_o,"publishLock");async function we(e,t=1e4){await U(Be.dirname(e));let r=`${e}.lock`,n={pid:process.pid,nonce:Dt()},o=JSON.stringify(n),i=Date.now()+t;for(;;)try{await _o(r,o);break}catch(a){if(a.code!=="EEXIST")throw a;let s=await S(r);if(s){let l;try{l=JSON.parse(s).pid}catch{}if(typeof l=="number"&&Number.isInteger(l)&&l>0&&yo(l)){let p=await we(`${r}.reclaim`,Math.max(0,i-Date.now()));try{await S(r)===s&&await V.unlink(r).catch(f=>{if(!R(f))throw f})}finally{await p()}}}if(Date.now()>=i)throw new w({code:"STORAGE_BUSY",path:e,message:"Another OpenPond process is updating this storage.",action:"Wait for that process to finish, then retry. Do not delete a live process lock."});await new Promise(l=>setTimeout(l,25))}return async()=>{await S(r)===o&&await V.unlink(r)}}c(we,"acquireFileLock");function yo(e){try{return process.kill(e,0),!1}catch(t){return t.code==="ESRCH"}}c(yo,"processIsDead");async function M(e,t){let r=await S(e);if(r===null)return t();try{return JSON.parse(r)}catch(n){throw new w({code:"INVALID_STORAGE_JSON",path:e,message:"A storage file contains invalid JSON.",action:"Restore a verified backup or correct the file, then retry."},{cause:n})}}c(M,"readJsonFile");async function ba(e,t,r){return L(e,async()=>{let n=await r(await M(e,t));return await I(e,`${JSON.stringify(n,null,2)}
3
+ `),n})}c(ba,"updateJsonFile");var F=d.string().trim().min(1),at=d.string().trim().max(4096),st=F.max(200).refine(e=>!["__proto__","prototype","constructor"].includes(e),"Reserved identifier"),ct=F.max(2048).refine(e=>{try{let t=new URL(e);return["http:","https:"].includes(t.protocol)&&!t.username&&!t.password&&!t.hash&&![...t.searchParams.keys()].some(r=>/(?:token|secret|password|authorization|api[_-]?key|credential)/i.test(r))}catch{return!1}},"Use an HTTP endpoint without embedded credentials; configure authentication through a credential reference."),Dr=d.strictObject({provider_id:hr,model_id:F.max(300)}),Ft=d.discriminatedUnion("mode",[d.strictObject({mode:d.literal("inherit")}),d.strictObject({mode:d.literal("custom"),ref:Dr})]),Ur=d.discriminatedUnion("source",[d.strictObject({source:d.literal("secret"),id:st}),d.strictObject({source:d.literal("env"),name:F.regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(160)})]),wo=d.strictObject({handle:F,base_url:ct.optional(),api_base_url:ct.optional(),chat_api_base_url:ct.optional(),environment:F.optional(),credential:Ur.optional(),enabled:d.boolean().optional()}),To=Tr.omit({registryId:!0,version:!0,installUrl:!0,authMethodId:!0}).extend({registryId:F.max(160).optional(),version:F.max(200).optional(),installUrl:d.string().url().optional(),authMethodId:F.max(200).optional()}),Eo=d.strictObject({acp:To.optional(),enabled:d.boolean().optional(),binary_path:F.max(4096).optional(),source_home:F.max(4096).optional(),native_mode:F.max(200).optional(),native_options:d.record(d.string().max(200),d.string().max(300)).optional(),base_url:ct.optional(),default_model:F.max(300).optional(),model_overrides:d.array(F.max(300)).max(500).optional(),credential:Ur.optional()}),Ut=d.strictObject({mode:d.enum(["auto","disabled","custom"]).optional(),custom_command:at.optional()}),Mr=d.union([d.number().int().min(1).max(32),d.literal("unlimited")]),bo=d.strictObject({enabled:d.boolean().optional(),model:Ft.optional(),isolation_mode:Ar.optional(),max_concurrent_runs:d.number().int().min(1).max(16).optional(),tool_policy:Sr.optional(),background:d.boolean().optional(),peer_messages:vr.optional()}),Ao=d.strictObject({source:d.enum(["local","github","openpond_git"]),repository_id:F,profile_id:F}),jt=d.strictObject({schema_version:d.literal(1),chat:d.strictObject({model:Dr.optional(),steer_active_responses:d.boolean().optional()}).optional(),codex:d.strictObject({reasoning_effort:xr.optional()}).optional(),permissions:d.strictObject({command_access:Nr.optional(),codex_mode:Cr.optional()}).optional(),context_compaction:d.strictObject({auto_enabled:d.boolean().optional(),trigger_percent:d.number().int().min(50).max(95).optional(),summary_model:d.literal("same_model").optional()}).optional(),subagents:d.strictObject({enabled:d.boolean().optional(),delegation_mode:Ir.optional(),default_model:Ft.optional(),max_concurrent_runs:d.number().int().min(1).max(32).optional(),max_concurrent_runs_per_provider:Mr.optional(),max_concurrent_runs_per_workspace_target:Mr.optional(),roles:d.record(br,bo).refine(e=>Object.keys(e).length<=64,"At most 64 roles").optional()}).optional(),projects:d.strictObject({branch_prefix:d.string().trim().max(48).optional(),new_project_directory:at.optional()}).optional(),defaults:d.strictObject({account_id:st.optional(),team_id:F.max(191).optional(),profile_ref:Ao.optional()}).optional(),editor:d.strictObject({language_servers:d.enum(["auto","off"]).optional(),diagnostics_while_editing:d.boolean().optional(),check_on_save:d.boolean().optional(),languages:d.strictObject({typescript:Ut.optional(),python:Ut.optional(),rust:Ut.optional()}).optional()}).optional(),training:d.strictObject({default_model:Ft.optional(),creation_mode:d.enum(["defaults","customize"]).optional(),auto_approve_evidence:d.boolean().optional()}).optional(),notifications:d.strictObject({team_chat:d.enum(["all","direct_mentions","none"]).optional()}).optional(),ui:d.strictObject({advanced_workspace_controls:d.boolean().optional()}).optional(),runtime:d.strictObject({execution_mode:d.enum(["local","hosted"]).optional(),mode:d.enum(["general","builder"]).optional()}).optional(),personalization:d.strictObject({active:F.regex(/^(builtin|custom):[a-zA-Z0-9_-]+$/).optional(),mode:d.enum(["enabled","disabled"]).optional(),user_instructions:at.optional()}).optional(),storage:d.strictObject({datasets_dir:at.optional()}).optional(),accounts:d.record(st,wo).optional(),providers:d.record(st,Eo).optional()});function ne(e,t="user"){let r=jt.parse(e);if(t==="project"){let n=new Set(["schema_version","chat","codex","permissions","context_compaction","subagents","projects","editor"]);for(let o of Object.keys(r))if(!n.has(o))throw new Error(`Setting ${o} is not permitted in project configuration.`);if(r.projects?.new_project_directory!==void 0)throw new Error("projects.new_project_directory is a user-only setting.");for(let o of Object.values(r.editor?.languages??{}))if(o.custom_command!==void 0)throw new Error("Custom editor commands must be configured in user settings.");if(r.permissions?.command_access==="full-access"||r.permissions?.codex_mode==="full-access"||r.permissions?.codex_mode==="auto-review")throw new Error("Project configuration can restrict permissions but cannot grant additional access.");for(let o of Object.values(r.subagents?.roles??{}))if(o.tool_policy&&o.tool_policy!=="read_only")throw new Error("Project roles cannot grant additional tool access.")}return r}c(ne,"validateConfigDocument");import{promises as Xt}from"node:fs";import Ne from"node:path";var lt={ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],AwaitExpression:["argument"],BinaryExpression:["left","right"],BlockStatement:["body"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],ExportAllDeclaration:["exported","source","attributes"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes"],ExportSpecifier:["local","exported"],ExpressionStatement:["expression"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportAttribute:["key","value"],ImportDeclaration:["specifiers","source","attributes"],ImportDefaultSpecifier:["local"],ImportExpression:["source","options"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXClosingFragment:[],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXFragment:["openingFragment","children","closingFragment"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes"],JSXOpeningFragment:[],JSXSpreadAttribute:["argument"],JSXSpreadChild:["expression"],JSXText:[],LabeledStatement:["label","body"],Literal:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],StaticBlock:["body"],Super:[],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},So=Object.keys(lt);for(let e of So)Object.freeze(lt[e]);Object.freeze(lt);var Fr=lt;function jr(e){let t=Object.assign({},Fr);for(let r of Object.keys(e))if(Object.hasOwn(t,r)){let n=new Set(e[r]);for(let o of t[r])n.add(o);t[r]=Object.freeze(Array.from(n))}else t[r]=Object.freeze(Array.from(e[r]));return Object.freeze(t)}c(jr,"unionWith");function Te(e){return e[e.length-1]??null}c(Te,"last");function Kt(e){return e.type==="TOMLBare"?e.name:e.value}c(Kt,"toKeyName");var qr=class{static{c(this,"TOMLVerImpl")}constructor(e,t){this.major=e,this.minor=t}lt(e,t){return this.major<e||this.major===e&&this.minor<t}gte(e,t){return this.major>e||this.major===e&&this.minor>=t}},Br=new qr(1,0),Je=new qr(1,1),vo=Je,Io={"1.0":Br,"1.0.0":Br,"1.1":Je,"1.1.0":Je,latest:Je,next:Je};function Qr(e){return e&&Io[e]||vo}c(Qr,"getTOMLVer");var $r={"unterminated-string":"Unterminated string constant","unterminated-table-key":"Unterminated table-key","unterminated-array":"Unterminated array","unterminated-inline-table":"Unterminated inline table","missing-key":"Empty bare keys are not allowed","missing-newline":"Must be a newline","missing-equals-sign":"Expected equal (=) token","missing-value":"Unspecified values are invalid","missing-comma":"Expected comma (,) token","dupe-keys":"Defining a key multiple times is invalid","unexpected-char":"Unexpected character","unexpected-token":"Unexpected token","invalid-control-character":"Control characters (codes < 0x1f and 0x7f) are not allowed","invalid-comment-character":"Invalid code point {{cp}} within comments","invalid-key-value-newline":"The key, equals sign, and value must be on the same line","invalid-inline-table-newline":"No newlines are allowed between the curly braces unless they are valid within a value","invalid-underscore":"Underscores are allowed between digits","invalid-space":"Unexpected spaces","invalid-three-quotes":"Three or more quotes are not permitted","invalid-date":"Unexpected invalid date","invalid-time":"Unexpected invalid time","invalid-leading-zero":"Leading zeros are not allowed","invalid-trailing-comma-in-inline-table":"Trailing comma is not permitted in an inline table","invalid-char-in-escape-sequence":"Invalid character in escape sequence","invalid-consecutive-dots-in-key":"Consecutive dots are not permitted in keys","invalid-code-point":"Invalid code point {{cp}}","invalid-trailing-dot-in-key":"Keys cannot end with a dot","invalid-leading-dot-in-key":"Keys cannot start with a dot"};function Lo(e,t){return t?$r[e].replace(/\{\{(.*?)\}\}/gu,(r,n)=>n in t?t[n]:`{{${n}}}`):$r[e]}c(Lo,"getMessage");var Yr=class extends SyntaxError{static{c(this,"ParseError")}constructor(e,t,r,n,o){super(Lo(e,o)),this.index=t,this.lineNumber=r,this.column=n}},u={EOF:-1,NULL:0,SOH:1,BACKSPACE:8,TABULATION:9,LINE_FEED:10,FORM_FEED:12,CARRIAGE_RETURN:13,ESCAPE:27,SO:14,US:31,SPACE:32,QUOTATION_MARK:34,HASH:35,SINGLE_QUOTE:39,PLUS_SIGN:43,COMMA:44,DASH:45,DOT:46,DIGIT_0:48,DIGIT_1:49,DIGIT_2:50,DIGIT_3:51,DIGIT_7:55,DIGIT_9:57,COLON:58,EQUALS_SIGN:61,LATIN_CAPITAL_A:65,LATIN_CAPITAL_E:69,LATIN_CAPITAL_F:70,LATIN_CAPITAL_T:84,LATIN_CAPITAL_U:85,LATIN_CAPITAL_Z:90,LEFT_BRACKET:91,BACKSLASH:92,RIGHT_BRACKET:93,UNDERSCORE:95,LATIN_SMALL_A:97,LATIN_SMALL_B:98,LATIN_SMALL_E:101,LATIN_SMALL_F:102,LATIN_SMALL_I:105,LATIN_SMALL_L:108,LATIN_SMALL_N:110,LATIN_SMALL_O:111,LATIN_SMALL_R:114,LATIN_SMALL_S:115,LATIN_SMALL_T:116,LATIN_SMALL_U:117,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,LEFT_BRACE:123,RIGHT_BRACE:125,TILDE:126,DELETE:127,PAD:128,SUPERSCRIPT_TWO:178,SUPERSCRIPT_THREE:179,SUPERSCRIPT_ONE:185,VULGAR_FRACTION_ONE_QUARTER:188,VULGAR_FRACTION_THREE_QUARTERS:190,LATIN_CAPITAL_LETTER_A_WITH_GRAVE:192,LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:214,LATIN_CAPITAL_LETTER_O_WITH_STROKE:216,LATIN_SMALL_LETTER_O_WITH_DIAERESIS:246,LATIN_SMALL_LETTER_O_WITH_STROKE:248,GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL:891,GREEK_CAPITAL_LETTER_YOT:895,CP_1FFF:8191,ZERO_WIDTH_NON_JOINER:8204,ZERO_WIDTH_JOINER:8205,UNDERTIE:8255,CHARACTER_TIE:8256,SUPERSCRIPT_ZERO:8304,CP_218F:8591,CIRCLED_DIGIT_ONE:9312,NEGATIVE_CIRCLED_DIGIT_ZERO:9471,GLAGOLITIC_CAPITAL_LETTER_AZU:11264,CP_2FEF:12271,IDEOGRAPHIC_COMMA:12289,CP_D7FF:55295,CP_E000:57344,CJK_COMPATIBILITY_IDEOGRAPH_F900:63744,ARABIC_LIGATURE_SALAAMUHU_ALAYNAA:64975,ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM:65008,REPLACEMENT_CHARACTER:65533,LINEAR_B_SYLLABLE_B008_A:65536,CP_EFFFF:983039,CP_10FFFF:1114111};function Oo(e){return e>=u.NULL&&e<=u.US}c(Oo,"isControl");function $e(e){return e===u.TABULATION||e===u.SPACE}c($e,"isWhitespace");function Vr(e){return e===u.LINE_FEED||e===u.CARRIAGE_RETURN}c(Vr,"isEOL");function Co(e){return e>=u.LATIN_CAPITAL_A&&e<=u.LATIN_CAPITAL_Z}c(Co,"isUpperLetter");function No(e){return e>=u.LATIN_SMALL_A&&e<=u.LATIN_SMALL_Z}c(No,"isLowerLetter");function xo(e){return No(e)||Co(e)}c(xo,"isLetter");function N(e){return e>=u.DIGIT_0&&e<=u.DIGIT_9}c(N,"isDigit");function Gr(e){return N(e)||e>=u.LATIN_SMALL_A&&e<=u.LATIN_SMALL_F||e>=u.LATIN_CAPITAL_A&&e<=u.LATIN_CAPITAL_F}c(Gr,"isHexDig");function ko(e){return e>=u.DIGIT_0&&e<=u.DIGIT_7}c(ko,"isOctalDig");function Ro(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}c(Ro,"isUnicodeScalarValue");function Po(e,t){let r=0,n=e.length;for(;r<n;){let o=r+n>>>1,i=e[o];if(i===t)return o+1;i<t?r=o+1:n=o}return r}c(Po,"sortedLastIndex");var Mo=class{static{c(this,"Locations")}constructor(){this.offsets=[]}addOffset(e){for(let t=this.offsets.length-1;t>=0;t--){let r=this.offsets[t];if(r===e)return;if(r<e)break}this.offsets.push(e)}getLocFromIndex(e){let t=Po(this.offsets,e)+1;return{line:t,column:e-(t===1?0:this.offsets[t-2])}}},Do=class{static{c(this,"CodePointIterator")}constructor(e){this.locs=new Mo,this.lastCodePoint=u.NULL,this.start=-1,this.end=0,this.text=e}next(){return this.lastCodePoint===u.EOF?u.EOF:this.lastCodePoint=this.moveAt(this.end)}getLocFromIndex(e){return this.locs.getLocFromIndex(e)}eat(e){return this.text.codePointAt(this.end)===e?(this.next(),!0):!1}moveAt(e){this.start=this.end=e;let t=this.text.codePointAt(this.start)??u.EOF;if(t===u.EOF)return this.end=this.start,t;if(this.end+=t>=65536?2:1,t===u.LINE_FEED)this.locs.addOffset(this.end);else if(t===u.CARRIAGE_RETURN)return this.text.codePointAt(this.end)===u.LINE_FEED&&(this.end++,this.locs.addOffset(this.end)),u.LINE_FEED;return t}},Uo=typeof BigInt<"u",Fo={16:"0x",10:"",8:"0o",2:"0b"},Zr={[u.QUOTATION_MARK]:u.QUOTATION_MARK,[u.BACKSLASH]:u.BACKSLASH,[u.LATIN_SMALL_B]:u.BACKSPACE,[u.LATIN_SMALL_F]:u.FORM_FEED,[u.LATIN_SMALL_N]:u.LINE_FEED,[u.LATIN_SMALL_R]:u.CARRIAGE_RETURN,[u.LATIN_SMALL_T]:u.TABULATION},jo={...Zr,[u.LATIN_SMALL_E]:u.ESCAPE},Bo=class{static{c(this,"Tokenizer")}constructor(e,t){this.backCode=!1,this.lastCodePoint=u.NULL,this.state="DATA",this.token=null,this.tokenStart=-1,this.valuesEnabled=!1,this.text=e,this.parserOptions=t||{},this.codePointIterator=new Do(e),this.tomlVersion=Qr(this.parserOptions.tomlVersion),this.ESCAPES=this.tomlVersion.gte(1,1)?jo:Zr}get start(){return this.codePointIterator.start}get end(){return this.codePointIterator.end}getLocFromIndex(e){return this.codePointIterator.getLocFromIndex(e)}reportParseError(e,t){let r=this.codePointIterator.start,n=this.codePointIterator.getLocFromIndex(r);throw new Yr(e,r,n.line,n.column,t)}nextToken(){let e=this.token;if(e!=null)return this.token=null,e;let t=this.lastCodePoint;for(;t!==u.EOF&&!this.token;){t=this.nextCode();let r=this[this.state](t);if(!r)throw new Error(`Unknown error: pre state=${this.state}`);this.state=r}return e=this.token,this.token=null,e}nextCode(){return this.lastCodePoint===u.EOF?u.EOF:this.backCode?(this.backCode=!1,this.lastCodePoint):this.lastCodePoint=this.codePointIterator.next()}eatCode(e){return this.lastCodePoint===u.EOF?!1:this.backCode?this.lastCodePoint===e?(this.backCode=!1,!0):!1:this.codePointIterator.eat(e)}moveAt(e){this.backCode&&(this.backCode=!1),this.lastCodePoint=this.codePointIterator.moveAt(e)}back(e){return this.backCode=!0,e}punctuatorToken(){this.startToken(),this.endToken("Punctuator","end")}startToken(){this.tokenStart=this.codePointIterator.start}endToken(e,t,r,n){let{tokenStart:o}=this,i=this.codePointIterator[t],a=[o,i],s={start:this.codePointIterator.getLocFromIndex(o),end:this.codePointIterator.getLocFromIndex(i)};if(e==="Block")this.token={type:e,value:this.text.slice(o+1,i),range:a,loc:s};else{let l,p=this.text.slice(o,i);if(e==="BasicString"||e==="LiteralString"||e==="MultiLineBasicString"||e==="MultiLineLiteralString")l={type:e,value:p,string:r,range:a,loc:s};else if(e==="Integer"){let f=r;l={type:e,value:p,number:parseInt(f,n),bigint:Uo?BigInt(Fo[n]+f):null,range:a,loc:s}}else e==="Float"?l={type:e,value:p,number:r,range:a,loc:s}:e==="Boolean"?l={type:e,value:p,boolean:r,range:a,loc:s}:e==="LocalDate"||e==="LocalTime"||e==="LocalDateTime"||e==="OffsetDateTime"?l={type:e,value:p,date:r,range:a,loc:s}:l={type:e,value:p,range:a,loc:s};this.token=l}}DATA(e){for(;$e(e)||Vr(e);)e=this.nextCode();if(e===u.HASH)return this.startToken(),"COMMENT";if(e===u.QUOTATION_MARK)return this.startToken(),"BASIC_STRING";if(e===u.SINGLE_QUOTE)return this.startToken(),"LITERAL_STRING";if(e===u.DOT||e===u.EQUALS_SIGN||e===u.LEFT_BRACKET||e===u.RIGHT_BRACKET||e===u.LEFT_BRACE||e===u.RIGHT_BRACE||e===u.COMMA)return this.punctuatorToken(),"DATA";if(this.valuesEnabled){if(e===u.DASH||e===u.PLUS_SIGN)return this.startToken(),"SIGN";if(e===u.LATIN_SMALL_N||e===u.LATIN_SMALL_I)return this.startToken(),this.back("NAN_OR_INF");if(N(e))return this.startToken(),this.back("NUMBER");if(e===u.LATIN_SMALL_T||e===u.LATIN_SMALL_F)return this.startToken(),this.back("BOOLEAN")}else if(Kr(e,this.tomlVersion))return this.startToken(),"BARE";return e===u.EOF?"DATA":this.reportParseError("unexpected-char")}COMMENT(e){let t=this.tomlVersion.gte(1,1)?r=>{$o(r)||this.reportParseError("invalid-comment-character",{cp:JSON.stringify(String.fromCodePoint(r)).slice(1,-1)})}:r=>{Ve(r)&&this.reportParseErrorControlChar()};for(;!Vr(e)&&e!==u.EOF;)t(e),e=this.nextCode();return this.endToken("Block","start"),"DATA"}BARE(e){for(;Kr(e,this.tomlVersion);)e=this.nextCode();return this.endToken("Bare","start"),this.back("DATA")}BASIC_STRING(e){if(e===u.QUOTATION_MARK)return e=this.nextCode(),e===u.QUOTATION_MARK?"MULTI_LINE_BASIC_STRING":(this.endToken("BasicString","start",""),this.back("DATA"));let t=[];for(;e!==u.QUOTATION_MARK&&e!==u.EOF&&e!==u.LINE_FEED;){if(Ve(e))return this.reportParseErrorControlChar();if(e===u.BACKSLASH){e=this.nextCode();let r=this.ESCAPES[e];if(r){t.push(r),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}return this.reportParseError("invalid-char-in-escape-sequence")}t.push(e),e=this.nextCode()}return e!==u.QUOTATION_MARK?this.reportParseError("unterminated-string"):(this.endToken("BasicString","end",String.fromCodePoint(...t)),"DATA")}MULTI_LINE_BASIC_STRING(e){let t=[];for(e===u.LINE_FEED&&(e=this.nextCode());e!==u.EOF;){if(e!==u.LINE_FEED&&Ve(e))return this.reportParseErrorControlChar();if(e===u.QUOTATION_MARK){let r=this.codePointIterator.start;if(this.eatCode(u.QUOTATION_MARK)&&this.eatCode(u.QUOTATION_MARK))return this.eatCode(u.QUOTATION_MARK)&&(t.push(u.QUOTATION_MARK),this.eatCode(u.QUOTATION_MARK)&&(t.push(u.QUOTATION_MARK),this.eatCode(u.QUOTATION_MARK)))?(this.moveAt(r),this.reportParseError("invalid-three-quotes")):(this.endToken("MultiLineBasicString","end",String.fromCodePoint(...t)),"DATA");this.moveAt(r)}if(e===u.BACKSLASH){e=this.nextCode();let r=this.ESCAPES[e];if(r){t.push(r),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}else if(e===u.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}else if(e===u.LINE_FEED){for(e=this.nextCode();$e(e)||e===u.LINE_FEED;)e=this.nextCode();continue}else if($e(e)){let n=!0,o=this.codePointIterator.start,i;for(;(i=this.nextCode())!==u.EOF&&i!==u.LINE_FEED;)if(!$e(i)){this.moveAt(o),n=!1;break}if(n){for(e=this.nextCode();$e(e)||e===u.LINE_FEED;)e=this.nextCode();continue}}return this.reportParseError("invalid-char-in-escape-sequence")}t.push(e),e=this.nextCode()}return this.reportParseError("unterminated-string")}LITERAL_STRING(e){if(e===u.SINGLE_QUOTE)return e=this.nextCode(),e===u.SINGLE_QUOTE?"MULTI_LINE_LITERAL_STRING":(this.endToken("LiteralString","start",""),this.back("DATA"));let t=[];for(;e!==u.SINGLE_QUOTE&&e!==u.EOF&&e!==u.LINE_FEED;){if(Ve(e))return this.reportParseErrorControlChar();t.push(e),e=this.nextCode()}return e!==u.SINGLE_QUOTE?this.reportParseError("unterminated-string"):(this.endToken("LiteralString","end",String.fromCodePoint(...t)),"DATA")}MULTI_LINE_LITERAL_STRING(e){let t=[];for(e===u.LINE_FEED&&(e=this.nextCode());e!==u.EOF;){if(e!==u.LINE_FEED&&Ve(e))return this.reportParseErrorControlChar();if(e===u.SINGLE_QUOTE){let r=this.codePointIterator.start;if(this.eatCode(u.SINGLE_QUOTE)&&this.eatCode(u.SINGLE_QUOTE))return this.eatCode(u.SINGLE_QUOTE)&&(t.push(u.SINGLE_QUOTE),this.eatCode(u.SINGLE_QUOTE)&&(t.push(u.SINGLE_QUOTE),this.eatCode(u.SINGLE_QUOTE)))?(this.moveAt(r),this.reportParseError("invalid-three-quotes")):(this.endToken("MultiLineLiteralString","end",String.fromCodePoint(...t)),"DATA");this.moveAt(r)}t.push(e),e=this.nextCode()}return this.reportParseError("unterminated-string")}SIGN(e){return e===u.LATIN_SMALL_N||e===u.LATIN_SMALL_I?this.back("NAN_OR_INF"):N(e)?this.back("NUMBER"):this.reportParseError("unexpected-char")}NAN_OR_INF(e){if(e===u.LATIN_SMALL_N){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_A)&&this.eatCode(u.LATIN_SMALL_N))return this.endToken("Float","end",NaN),"DATA";this.moveAt(t)}else if(e===u.LATIN_SMALL_I){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_N)&&this.eatCode(u.LATIN_SMALL_F))return this.endToken("Float","end",this.text[this.tokenStart]==="-"?-1/0:1/0),"DATA";this.moveAt(t)}return this.reportParseError("unexpected-char")}NUMBER(e){let t=this.text[this.tokenStart],r=t==="+"?u.PLUS_SIGN:t==="-"?u.DASH:u.NULL;if(e===u.DIGIT_0){if(r===u.NULL){let a=this.codePointIterator.start,s=this.nextCode();if(N(s)){let l=this.nextCode();if(l===u.COLON)return this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(u.DIGIT_0,s)),minute:0,second:0},"TIME_MINUTE";if(N(l)){let p=this.nextCode();if(N(p)&&this.eatCode(u.DASH))return this.data={hasDate:!0,year:Number(String.fromCodePoint(u.DIGIT_0,s,l,p)),month:0,day:0,hour:0,minute:0,second:0},"DATE_MONTH"}return this.moveAt(a),this.reportParseError("invalid-leading-zero")}this.moveAt(a)}return e=this.nextCode(),e===u.LATIN_SMALL_X||e===u.LATIN_SMALL_O||e===u.LATIN_SMALL_B?r!==u.NULL?this.reportParseError("unexpected-char"):e===u.LATIN_SMALL_X?"HEX":e===u.LATIN_SMALL_O?"OCTAL":"BINARY":e===u.LATIN_SMALL_E||e===u.LATIN_CAPITAL_E?(this.data={minus:r===u.DASH,left:[u.DIGIT_0]},"EXPONENT_RIGHT"):e===u.DOT?(this.data={minus:r===u.DASH,absInt:[u.DIGIT_0]},"FRACTIONAL_RIGHT"):(this.endToken("Integer","start","0",10),this.back("DATA"))}let{out:n,nextCp:o,hasUnderscore:i}=this.parseDigits(e,N);return o===u.DASH&&r===u.NULL&&!i&&n.length===4?(this.data={hasDate:!0,year:Number(String.fromCodePoint(...n)),month:0,day:0,hour:0,minute:0,second:0},"DATE_MONTH"):o===u.COLON&&r===u.NULL&&!i&&n.length===2?(this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(...n)),minute:0,second:0},"TIME_MINUTE"):o===u.LATIN_SMALL_E||o===u.LATIN_CAPITAL_E?(this.data={minus:r===u.DASH,left:n},"EXPONENT_RIGHT"):o===u.DOT?(this.data={minus:r===u.DASH,absInt:n},"FRACTIONAL_RIGHT"):(this.endToken("Integer","start",r===u.DASH?String.fromCodePoint(u.DASH,...n):String.fromCodePoint(...n),10),this.back("DATA"))}HEX(e){let{out:t}=this.parseDigits(e,Gr);return this.endToken("Integer","start",String.fromCodePoint(...t),16),this.back("DATA")}OCTAL(e){let{out:t}=this.parseDigits(e,ko);return this.endToken("Integer","start",String.fromCodePoint(...t),8),this.back("DATA")}BINARY(e){let{out:t}=this.parseDigits(e,r=>r===u.DIGIT_0||r===u.DIGIT_1);return this.endToken("Integer","start",String.fromCodePoint(...t),2),this.back("DATA")}FRACTIONAL_RIGHT(e){let{minus:t,absInt:r}=this.data,{out:n,nextCp:o}=this.parseDigits(e,N),i=[...r,u.DOT,...n];if(o===u.LATIN_SMALL_E||o===u.LATIN_CAPITAL_E)return this.data={minus:t,left:i},"EXPONENT_RIGHT";let a=Number(t?String.fromCodePoint(u.DASH,...i):String.fromCodePoint(...i));return this.endToken("Float","start",a),this.back("DATA")}EXPONENT_RIGHT(e){let{left:t,minus:r}=this.data,n=!1;(e===u.DASH||e===u.PLUS_SIGN)&&(n=e===u.DASH,e=this.nextCode());let{out:o}=this.parseDigits(e,N),i=o;n&&i.unshift(u.DASH);let a=Number(r?String.fromCodePoint(u.DASH,...t,u.LATIN_SMALL_E,...i):String.fromCodePoint(...t,u.LATIN_SMALL_E,...i));return this.endToken("Float","start",a),this.back("DATA")}BOOLEAN(e){if(e===u.LATIN_SMALL_T){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_R)&&this.eatCode(u.LATIN_SMALL_U)&&this.eatCode(u.LATIN_SMALL_E))return this.endToken("Boolean","end",!0),"DATA";this.moveAt(t)}else if(e===u.LATIN_SMALL_F){let t=this.codePointIterator.start;if(this.eatCode(u.LATIN_SMALL_A)&&this.eatCode(u.LATIN_SMALL_L)&&this.eatCode(u.LATIN_SMALL_S)&&this.eatCode(u.LATIN_SMALL_E))return this.endToken("Boolean","end",!1),"DATA";this.moveAt(t)}return this.reportParseError("unexpected-char")}DATE_MONTH(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),e!==u.DASH)return this.reportParseError("unexpected-char");let r=this.codePointIterator.start,n=this.data;return n.month=Number(this.text.slice(t,r)),"DATE_DAY"}DATE_DAY(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let r=this.codePointIterator.end,n=this.data;if(n.day=Number(this.text.slice(t,r)),!Go(n.year,n.month,n.day))return this.reportParseError("invalid-date");if(e=this.nextCode(),e===u.LATIN_CAPITAL_T||e===u.LATIN_SMALL_T)return"TIME_HOUR";if(e===u.SPACE){let i=this.codePointIterator.start;if(N(this.nextCode())&&N(this.nextCode()))return this.moveAt(i),"TIME_HOUR";this.moveAt(i)}let o=Ge(n,"");return this.endToken("LocalDate","start",o),this.back("DATA")}TIME_HOUR(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),e!==u.COLON)return this.reportParseError("unexpected-char");let r=this.codePointIterator.start,n=this.data;return n.hour=Number(this.text.slice(t,r)),"TIME_MINUTE"}TIME_MINUTE(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let r=this.codePointIterator.end,n=this.data;return n.minute=Number(this.text.slice(t,r)),e=this.nextCode(),e===u.COLON?"TIME_SECOND":this.tomlVersion.lt(1,1)?this.reportParseError("unexpected-char"):Bt(n.hour,n.minute,n.second)?this.processTimeEnd(e,n):this.reportParseError("invalid-time")}TIME_SECOND(e){let t=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let r=this.codePointIterator.end,n=this.data;return n.second=Number(this.text.slice(t,r)),Bt(n.hour,n.minute,n.second)?(e=this.nextCode(),e===u.DOT?"TIME_SEC_FRAC":this.processTimeEnd(e,n)):this.reportParseError("invalid-time")}TIME_SEC_FRAC(e){if(!N(e))return this.reportParseError("unexpected-char");let t=this.codePointIterator.start;for(;N(e);)e=this.nextCode();let r=this.codePointIterator.start,n=this.data;return n.frac=this.text.slice(t,r),this.processTimeEnd(e,n)}processTimeEnd(e,t){if(t.hasDate){if(e===u.DASH||e===u.PLUS_SIGN)return t.offsetSign=e,"TIME_OFFSET";if(e===u.LATIN_CAPITAL_Z||e===u.LATIN_SMALL_Z){let o=Ge(t,"Z");return this.endToken("OffsetDateTime","end",o),"DATA"}let n=Ge(t,"");return this.endToken("LocalDateTime","start",n),this.back("DATA")}let r=Ge(t,"");return this.endToken("LocalTime","start",r),this.back("DATA")}TIME_OFFSET(e){if(!N(e))return this.reportParseError("unexpected-char");let t=this.codePointIterator.start;if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),e!==u.COLON)return this.reportParseError("unexpected-char");let r=this.codePointIterator.start;e=this.nextCode();let n=this.codePointIterator.start;if(!N(e))return this.reportParseError("unexpected-char");if(e=this.nextCode(),!N(e))return this.reportParseError("unexpected-char");let o=this.codePointIterator.end,i=Number(this.text.slice(t,r)),a=Number(this.text.slice(n,o));if(!Bt(i,a,0))return this.reportParseError("invalid-time");let s=this.data,l=Ge(s,`${String.fromCodePoint(s.offsetSign)}${ge(i,2)}:${ge(a,2)}`);return this.endToken("OffsetDateTime","end",l),"DATA"}parseDigits(e,t){if(e===u.UNDERSCORE)return this.reportParseError("invalid-underscore");if(!t(e))return this.reportParseError("unexpected-char");let r=[],n=u.NULL,o=!1;for(;t(e)||e===u.UNDERSCORE;){if(e===u.UNDERSCORE){if(o=!0,n===u.UNDERSCORE)return this.reportParseError("invalid-underscore")}else r.push(e);n=e,e=this.nextCode()}return n===u.UNDERSCORE?this.reportParseError("invalid-underscore"):{out:r,nextCp:e,hasUnderscore:o}}parseUnicode(e){let t=this.codePointIterator.start,r=this.codePointIterator.end,n=0,o;for(;(o=this.nextCode())!==u.EOF;){if(!Gr(o))return this.moveAt(t),this.reportParseError("invalid-char-in-escape-sequence");if(n++,n>=e)break}let i=this.codePointIterator.end,a=this.text.slice(r,i),s=parseInt(a,16);return Ro(s)?s:this.reportParseError("invalid-code-point",{cp:a})}reportParseErrorControlChar(){return this.reportParseError("invalid-control-character")}};function Kr(e,t){return xo(e)||N(e)||e===u.UNDERSCORE||e===u.DASH?!0:(t.lt(1,1),!1)}c(Kr,"isUnquotedKeyChar");function Ve(e){return Oo(e)&&e!==u.TABULATION||e===u.DELETE}c(Ve,"isControlOtherThanTab");function $o(e){return e===u.TABULATION||u.SPACE<=e&&e<=u.TILDE||Vo(e)}c($o,"isNonEOL");function Vo(e){return u.PAD<=e&&e<=u.CP_D7FF||u.CP_E000<=e&&e<=u.CP_10FFFF}c(Vo,"isNonAscii");function Go(e,t,r){return e>=0&&t<=12&&t>=1&&r>=1?r<=(t===2?e&3||!(e%25)&&e&15?28:29:30+(t+(t>>3)&1)):!1}c(Go,"isValidDate");function Bt(e,t,r){return!(e>=24||e<0||t>59||t<0||r>60||r<0)}c(Bt,"isValidTime");function Ge(e,t){let r=ge(e.year,4),n=e.month?ge(e.month,2):"01",o=e.day?ge(e.day,2):"01",i=ge(e.hour,2),a=ge(e.minute,2),s=ge(e.second,2),l=`${r}-${n}-${o}`,p=e.frac?`.${e.frac}`:"",f=new Date(`${l}T${i}:${a}:${s}${p}${t}`);return!isNaN(f.getTime())||e.second!==60?f:new Date(`${l}T${i}:${a}:59${p}${t}`)}c(Ge,"getDateFromDateTimeData");function ge(e,t){return String(e).padStart(t,"0")}c(ge,"padStart");var Ht=Symbol("VALUE_KIND_VALUE"),Hr=Symbol("VALUE_KIND_INTERMEDIATE"),Ko=class{static{c(this,"KeysResolver")}constructor(e){this.rootKeys=new Map,this.tables=[],this.ctx=e}applyResolveKeyForTable(e){let t=this.rootKeys,r=e.key.keys.length-1;for(let a=0;a<r;a++){let s=e.key.keys[a],l=Kt(s);e.resolvedKey.push(l);let p=t.get(l);if(!p)p={node:s,keys:new Map},t.set(l,p);else if(p.table==="array"){let f=p.peekIndex;e.resolvedKey.push(f),p=p.keys.get(f)}t=p.keys}let n=e.key.keys[r],o=Kt(n);e.resolvedKey.push(o);let i=t.get(o);if(i)if(i.table)if(i.table==="array")if(e.kind==="array"){let a={node:n,keys:new Map},s=i.peekIndex+1;e.resolvedKey.push(s),i.keys.set(s,a),i.peekIndex=s,this.tables.push({node:e,keys:a.keys})}else this.ctx.reportParseError("dupe-keys",n);else this.ctx.reportParseError("dupe-keys",n);else if(e.kind==="array")this.ctx.reportParseError("dupe-keys",n);else{let a={table:e.kind,node:n,keys:i.keys};t.set(o,a),this.tables.push({node:e,keys:a.keys})}else if(e.kind==="array"){e.resolvedKey.push(0);let a={node:n,keys:new Map};t.set(o,{table:e.kind,node:n,keys:new Map([[0,a]]),peekIndex:0}),this.tables.push({node:e,keys:a.keys})}else{let a={table:e.kind,node:n,keys:new Map};t.set(o,a),this.tables.push({node:e,keys:a.keys})}}verifyDuplicateKeys(e){for(let t of e.body)t.type==="TOMLKeyValue"&&Jt(this.ctx,this.rootKeys,t);for(let{node:t,keys:r}of this.tables)for(let n of t.body)Jt(this.ctx,r,n)}};function Jt(e,t,r){let n=t,o=Te(r.key.keys);for(let i of r.key.keys){let a=Kt(i),s=n.get(a);s?((s.value===Ht||o===i||s.table)&&e.reportParseError("dupe-keys",ut(i,s.node)),s.value=Hr):(o===i?s={value:Ht,node:i,keys:new Map}:s={value:Hr,node:i,keys:new Map},n.set(a,s)),n=s.keys}r.value.type==="TOMLInlineTable"?en(e,n,r.value):r.value.type==="TOMLArray"&&tn(e,n,r.value)}c(Jt,"verifyDuplicateKeysForKeyValue");function en(e,t,r){for(let n of r.body)Jt(e,t,n)}c(en,"verifyDuplicateKeysForInlineTable");function tn(e,t,r){let n=t;for(let o=0;o<r.elements.length;o++){let i=r.elements[o],a=n.get(o);a?e.reportParseError("dupe-keys",ut(i,a.node)):(a={value:Ht,node:i,keys:new Map},t.set(o,a),i.type==="TOMLInlineTable"?en(e,a.keys,i):i.type==="TOMLArray"&&tn(e,a.keys,i))}}c(tn,"verifyDuplicateKeysForArray");function ut(e,t){return e.range[0]<=t.range[0]?t:e}c(ut,"getAfterNode");var Ho=class{static{c(this,"Context")}constructor(e){this.tokens=[],this.comments=[],this.back=null,this.stateStack=[],this.needNewLine=!1,this.needSameLine=!1,this.currToken=null,this.prevToken=null,this.valueContainerStack=[],this.tokenizer=new Bo(e.text,e.parserOptions),this.topLevelTable=e.topLevelTable,this.table=e.topLevelTable,this.keysResolver=new Ko(this)}nextToken(e){if(this.prevToken=this.currToken,this.back?(this.currToken=this.back,this.back=null):this.currToken=this._nextTokenFromTokenizer(e),(this.needNewLine||this.needSameLine||e?.needSameLine)&&this.prevToken&&this.currToken)if(this.prevToken.loc.end.line===this.currToken.loc.start.line){if(this.needNewLine)return this.reportParseError("missing-newline",this.currToken)}else{let t=this.needSameLine||e?.needSameLine;if(t)return this.reportParseError(t,this.currToken)}return this.needNewLine=!1,this.needSameLine=!1,this.currToken}_nextTokenFromTokenizer(e){let t=this.tokenizer.valuesEnabled;e?.valuesEnabled&&(this.tokenizer.valuesEnabled=e.valuesEnabled);let r=this.tokenizer.nextToken();for(;r&&r.type==="Block";)this.comments.push(r),r=this.tokenizer.nextToken();return r&&this.tokens.push(r),this.tokenizer.valuesEnabled=t,r}backToken(){if(this.back)throw new Error("Illegal state");this.back=this.currToken,this.currToken=this.prevToken}addValueContainer(e){this.valueContainerStack.push(e),this.tokenizer.valuesEnabled=!0}consumeValueContainer(){let e=this.valueContainerStack.pop();return this.tokenizer.valuesEnabled=this.valueContainerStack.length>0,e}applyResolveKeyForTable(e){this.keysResolver.applyResolveKeyForTable(e)}verifyDuplicateKeys(){this.keysResolver.verifyDuplicateKeys(this.topLevelTable)}reportParseError(e,t){let r,n,o;if(t)r=t.range[0],n=t.loc.start.line,o=t.loc.start.column;else{r=this.tokenizer.start;let i=this.tokenizer.getLocFromIndex(r);n=i.line,o=i.column}throw new Yr(e,r,n,o)}},Jr={VALUE:"missing-value"},Jo={BasicString:"basic",MultiLineBasicString:"basic",LiteralString:"literal",MultiLineLiteralString:"literal"},zo={BasicString:"basic",LiteralString:"literal"},Wo={OffsetDateTime:"offset-date-time",LocalDateTime:"local-date-time",LocalDate:"local-date",LocalTime:"local-time"},Xo=class{static{c(this,"TOMLParser")}constructor(e,t){this.text=e,this.parserOptions=t||{},this.tomlVersion=Qr(this.parserOptions.tomlVersion)}parse(){let e={type:"Program",body:[],sourceType:"module",tokens:[],comments:[],parent:null,range:[0,0],loc:{start:{line:1,column:0},end:{line:1,column:0}}},t={type:"TOMLTopLevelTable",body:[],parent:e,range:H(e.range),loc:J(e.loc)};e.body=[t];let r=new Ho({text:this.text,parserOptions:this.parserOptions,topLevelTable:t}),n=r.nextToken();if(n){for(t.range[0]=n.range[0],t.loc.start=ft(n.loc.start);n;){let s=r.stateStack.pop()||"TABLE";r.stateStack.push(...this[s](n,r)),n=r.nextToken()}let a=r.stateStack.pop()||"TABLE";if(a in Jr)return r.reportParseError(Jr[a],null);r.table.type==="TOMLTable"&&oe(r.table,Te(r.table.body)),oe(t,Te(t.body))}r.verifyDuplicateKeys(),e.tokens=r.tokens,e.comments=r.comments;let o=r.tokenizer.end,i=r.tokenizer.getLocFromIndex(o);return e.range[1]=o,e.loc.end={line:i.line,column:i.column},e}TABLE(e,t){return dt(e)||He(e)?this.processKeyValue(e,t.table,t):Vt(e)?this.processTable(e,t.topLevelTable,t):t.reportParseError("unexpected-token",e)}VALUE(e,t){return He(e)||Xr(e)?this.processStringValue(e,t):Qo(e)?this.processNumberValue(e,t):Yo(e)?this.processBooleanValue(e,t):Zo(e)?this.processDateTimeValue(e,t):Vt(e)?this.processArray(e,t):qo(e)?this.processInlineTable(e,t):t.reportParseError("unexpected-token",e)}processTable(e,t,r){let n={type:"TOMLTable",kind:"standard",key:null,resolvedKey:[],body:[],parent:t,range:H(e.range),loc:J(e.loc)};r.table.type==="TOMLTable"&&oe(r.table,Te(r.table.body)),t.body.push(n),r.table=n;let o=r.nextToken({needSameLine:"invalid-key-value-newline"});if(Vt(o)){if(e.range[1]<o.range[0])return r.reportParseError("invalid-space",o);n.kind="array",o=r.nextToken({needSameLine:"invalid-key-value-newline"})}if(Ke(o))return r.reportParseError("missing-key",o);if(!o)return r.reportParseError("unterminated-table-key",null);if(o=this.processKeyNode(o,n,r).nextToken,!Ke(o))return r.reportParseError("unterminated-table-key",o);if(n.kind==="array"){let i=o;if(o=r.nextToken({needSameLine:"invalid-key-value-newline"}),!Ke(o))return r.reportParseError("unterminated-table-key",o);if(i.range[1]<o.range[0])return r.reportParseError("invalid-space",o)}return oe(n,o),r.applyResolveKeyForTable(n),r.needNewLine=!0,[]}processKeyValue(e,t,r){let n={type:"TOMLKeyValue",key:null,value:null,parent:t,range:H(e.range),loc:J(e.loc)};t.body.push(n);let{nextToken:o}=this.processKeyNode(e,n,r);return zr(o)?(r.addValueContainer({parent:n,set:c(i=>(n.value=i,oe(n,i),r.needNewLine=!0,[]),"set")}),r.needSameLine="invalid-key-value-newline",["VALUE"]):r.reportParseError("missing-equals-sign",o)}processKeyNode(e,t,r){$t(e)&&r.reportParseError("invalid-leading-dot-in-key",e);let n={type:"TOMLKey",keys:[],parent:t,range:H(e.range),loc:J(e.loc)};t.key=n;let o=e,i=null;do{if(dt(o))this.processBareKey(o,n);else if(He(o))this.processStringKey(o,n);else break;if(i=null,o=r.nextToken({needSameLine:"invalid-key-value-newline"}),!$t(o))break;i=o,o=r.nextToken({needSameLine:"invalid-key-value-newline"})}while(o);return i&&r.reportParseError($t(o)?"invalid-consecutive-dots-in-key":"invalid-trailing-dot-in-key",i),oe(n,Te(n.keys)),{keyNode:n,nextToken:o}}processBareKey(e,t){let r={type:"TOMLBare",name:e.value,parent:t,range:H(e.range),loc:J(e.loc)};t.keys.push(r)}processStringKey(e,t){let r={type:"TOMLQuoted",kind:"string",value:e.string,style:zo[e.type],multiline:!1,parent:t,range:H(e.range),loc:J(e.loc)};t.keys.push(r)}processStringValue(e,t){let r=t.consumeValueContainer(),n={type:"TOMLValue",kind:"string",value:e.string,style:Jo[e.type],multiline:Xr(e),parent:r.parent,range:H(e.range),loc:J(e.loc)};return r.set(n)}processNumberValue(e,t){let r=t.consumeValueContainer(),n=this.text,[o,i]=e.range,a=null,s=c(()=>a??(a=n.slice(o,i).replace(/_/g,"")),"getNumberText"),l;return e.type==="Integer"?l={type:"TOMLValue",kind:"integer",value:e.number,bigint:e.bigint,get number(){return s()},parent:r.parent,range:H(e.range),loc:J(e.loc)}:l={type:"TOMLValue",kind:"float",value:e.number,get number(){return s()},parent:r.parent,range:H(e.range),loc:J(e.loc)},r.set(l)}processBooleanValue(e,t){let r=t.consumeValueContainer(),n={type:"TOMLValue",kind:"boolean",value:e.boolean,parent:r.parent,range:H(e.range),loc:J(e.loc)};return r.set(n)}processDateTimeValue(e,t){let r=t.consumeValueContainer(),n={type:"TOMLValue",kind:Wo[e.type],value:e.date,datetime:e.value,parent:r.parent,range:H(e.range),loc:J(e.loc)};return r.set(n)}processArray(e,t){let r=t.consumeValueContainer(),n={type:"TOMLArray",elements:[],parent:r.parent,range:H(e.range),loc:J(e.loc)},o=t.nextToken({valuesEnabled:!0});return Ke(o)?(oe(n,o),r.set(n)):(t.backToken(),this.processArrayValue(n,r,t))}processArrayValue(e,t,r){return r.addValueContainer({parent:e,set:c(n=>{e.elements.push(n);let o=r.nextToken({valuesEnabled:!0}),i=Wr(o);return i&&(o=r.nextToken({valuesEnabled:!0})),Ke(o)?(oe(e,o),t.set(e)):i?(r.backToken(),this.processArrayValue(e,t,r)):r.reportParseError(o?"missing-comma":"unterminated-array",o)},"set")}),["VALUE"]}processInlineTable(e,t){let r=t.consumeValueContainer(),n={type:"TOMLInlineTable",body:[],parent:r.parent,range:H(e.range),loc:J(e.loc)},o=this.tomlVersion.gte(1,1)?void 0:"invalid-inline-table-newline",i=t.nextToken({needSameLine:o});if(i){if(dt(i)||He(i))return this.processInlineTableKeyValue(i,n,r,t);if(Gt(i))return oe(n,i),r.set(n)}return t.reportParseError("unexpected-token",i)}processInlineTableKeyValue(e,t,r,n){let o={type:"TOMLKeyValue",key:null,value:null,parent:t,range:H(e.range),loc:J(e.loc)};t.body.push(o);let{nextToken:i}=this.processKeyNode(e,o,n);if(!zr(i))return n.reportParseError("missing-equals-sign",i);let a=this.tomlVersion.gte(1,1)?void 0:"invalid-inline-table-newline";return n.addValueContainer({parent:o,set:c(s=>{o.value=s,oe(o,s);let l=n.nextToken({needSameLine:a});if(Wr(l)){if(l=n.nextToken({needSameLine:a}),l&&(dt(l)||He(l)))return this.processInlineTableKeyValue(l,t,r,n);if(Gt(l)){if(this.tomlVersion.lt(1,1))return n.reportParseError("invalid-trailing-comma-in-inline-table",l)}else return n.reportParseError(l?"unexpected-token":"unterminated-inline-table",l)}return Gt(l)?(oe(t,l),r.set(t)):n.reportParseError(l?"missing-comma":"unterminated-inline-table",l)},"set")}),n.needSameLine="invalid-key-value-newline",["VALUE"]}};function $t(e){return Ee(e)&&e.value==="."}c($t,"isDot");function zr(e){return Ee(e)&&e.value==="="}c(zr,"isEq");function Vt(e){return Ee(e)&&e.value==="["}c(Vt,"isLeftBracket");function Ke(e){return Ee(e)&&e.value==="]"}c(Ke,"isRightBracket");function qo(e){return Ee(e)&&e.value==="{"}c(qo,"isLeftBrace");function Gt(e){return Ee(e)&&e.value==="}"}c(Gt,"isRightBrace");function Wr(e){return Ee(e)&&e.value===","}c(Wr,"isComma");function Ee(e){return!!(e&&e.type==="Punctuator")}c(Ee,"isPunctuator");function dt(e){return e.type==="Bare"}c(dt,"isBare");function He(e){return e.type==="BasicString"||e.type==="LiteralString"}c(He,"isString");function Xr(e){return e.type==="MultiLineBasicString"||e.type==="MultiLineLiteralString"}c(Xr,"isMultiLineString");function Qo(e){return e.type==="Integer"||e.type==="Float"}c(Qo,"isNumber");function Yo(e){return e.type==="Boolean"}c(Yo,"isBoolean");function Zo(e){return e.type==="OffsetDateTime"||e.type==="LocalDateTime"||e.type==="LocalDate"||e.type==="LocalTime"}c(Zo,"isDateTime");function oe(e,t){t&&(e.range[1]=t.range[1],e.loc.end=ft(t.loc.end))}c(oe,"applyEndLoc");function H(e){return[e[0],e[1]]}c(H,"cloneRange");function J(e){return{start:ft(e.start),end:ft(e.end)}}c(J,"cloneLoc");function ft(e){return{line:e.line,column:e.column}}c(ft,"clonePos");var ei={Program:["body"],TOMLTopLevelTable:["body"],TOMLTable:["key","body"],TOMLKeyValue:["key","value"],TOMLKey:["keys"],TOMLArray:["elements"],TOMLInlineTable:["body"],TOMLBare:[],TOMLQuoted:[],TOMLValue:[]},ti=jr(ei);function ri(e,t){return{ast:new Xo(e,t).parse(),visitorKeys:ti,services:{isTOML:!0}}}c(ri,"parseForESLint");var zt=ni(e=>e.value);function ni(e){function t(n,o){return r[n.type](n,o)}c(t,"resolveValue");let r={Program(n,o={}){return t(n.body[0],o)},TOMLTopLevelTable(n,o={}){for(let i of n.body)t(i,o);return o},TOMLKeyValue(n,o={}){let i=t(n.value);return ii(o,t(n.key),i),o},TOMLTable(n,o={}){let i=oi(o,t(n.key),n.kind==="array");for(let a of n.body)t(a,i);return o},TOMLArray(n){return n.elements.map(o=>t(o))},TOMLInlineTable(n){let o={};for(let i of n.body)t(i,o);return o},TOMLKey(n){return n.keys.map(o=>t(o))},TOMLBare(n){return n.name},TOMLQuoted(n){return n.value},TOMLValue(n){return e(n)}};return n=>t(n)}c(ni,"generateConvertTOMLValue");function oi(e,t,r){let n=e;for(let l=0;l<t.length-1;l++){let p=t[l];n=s(n,p)}let o=Te(t),i=n[o];if(i==null){let l={};return n[o]=r?[l]:l,l}if(pt(i)){let l={};return n[o]=r?[l]:l,l}if(!r){if(Array.isArray(i)){let l={};return n[o]=l,l}return i}if(Array.isArray(i)){let l={};return i.push(l),l}let a={};return n[o]=[a],a;function s(l,p){let f=l[p];if(f==null){let m={};return l[p]=m,m}if(pt(f)){let m={};return l[p]=m,m}let g=f;for(;Array.isArray(g);){let m=g.length-1,h=g[m];if(pt(h)){let y={};return g[m]=y,y}g=h}return g}c(s,"getNextTargetFromKey")}c(oi,"getTable");function ii(e,t,r){let n=e;for(let o=0;o<t.length-1;o++){let i=t[o],a=n[i];if(a==null){let s={};n[i]=s,n=s}else if(pt(a)||Array.isArray(a)){let s={};n[i]=s,n=s}else n=a}n[Te(t)]=r}c(ii,"set");function pt(e){return typeof e!="object"||e instanceof Date}c(pt,"isValue");function rn(e,t){return ri(e,t).ast}c(rn,"parseTOML");function te(e,t){try{let r=rn(e,{tomlVersion:"1.0"}),n=zt(r);return an(n),{ast:r,value:n}}catch(r){let n=r;throw new w({code:"INVALID_CONFIG",path:t,message:"Configuration contains invalid TOML or an unsupported value.",line:n.lineNumber,column:n.column===void 0?void 0:n.column+1,action:"Open config.toml, correct the indicated value, and retry."},{cause:r})}}c(te,"parseToml");function an(e){if(e instanceof Date||typeof e=="bigint"||typeof e=="number"&&(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)))throw new Error("Unsupported TOML value");if(e&&typeof e=="object")for(let[t,r]of Object.entries(e)){if(["__proto__","prototype","constructor"].includes(t))throw new Error("Reserved key");an(r)}}c(an,"assertJsonValue");function _e(e){if(typeof e=="string")return JSON.stringify(e).replace(/\\u([0-9a-f]{4})/gi,"\\u$1");if(typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e))return`[${e.map(_e).join(", ")}]`;if(se(e))return`{ ${Object.entries(e).filter(([,t])=>t!==void 0).map(([t,r])=>`${be(t)} = ${_e(r)}`).join(", ")} }`;throw new Error("Configuration cannot contain null or unsupported values.")}c(_e,"tomlValue");var be=c(e=>/^[A-Za-z0-9_-]+$/.test(e)?e:JSON.stringify(e),"tomlKey"),nn=c(e=>e.keys.map(t=>t.type==="TOMLBare"?t.name:t.value),"keyPath"),ai=c((e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),"samePath"),mt=c((e,t)=>e.length<=t.length&&e.every((r,n)=>r===t[n]),"prefix");function se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Date)}c(se,"isRecord");function ze(e,t,r){let n=e;for(let o of t)n=sn(n,o,r);return te(n,r),n.endsWith(`
4
4
  `)?n:`${n}
5
5
  `}c(ze,"editToml");function sn(e,t,r){if(!t.path.length||t.path.some(m=>!m||["__proto__","prototype","constructor"].includes(m)))throw new Error("Invalid configuration key path.");let{ast:n}=te(e,r),o=[],i=[];for(let m of n.body[0].body)if(m.type==="TOMLKeyValue")o.push({path:nn(m.key),node:m});else{if(i.push(m),m.kind!=="standard")continue;for(let h of m.body)o.push({path:[...m.resolvedKey.map(String),...nn(h.key)],node:h})}let a=o.find(m=>ai(m.path,t.path));if(a){let m=a.node;if(t.op==="set")return ht(e,m.value.range,on(e,n,m.value.range,_e(t.value)));let h=n.comments.filter(y=>y.range[0]>=m.range[0]&&y.range[1]<=m.range[1]).map(y=>e.slice(...y.range)).join(`
6
6
  `);return ht(e,m.range,h)}let s=o.find(m=>mt(m.path,t.path));if(s){let m=structuredClone(zt(s.node.value));if(!se(m))throw new Error("Cannot edit a key below a scalar or array.");return si(m,{...t,path:t.path.slice(s.path.length)}),ht(e,s.node.value.range,on(e,n,s.node.value.range,_e(m)))}let l=o.filter(m=>mt(t.path,m.path)),p=i.filter(m=>mt(t.path,m.resolvedKey.map(String)));if(l.length||p.length){let m=[...l.map(h=>h.node.range),...p.map(h=>[h.range[0],h.key.range[1]+1])];for(let h of m.sort((y,T)=>T[0]-y[0])){let y=n.comments.filter(T=>T.range[0]>=h[0]&&T.range[1]<=h[1]).map(T=>e.slice(...T.range)).join(`
@@ -18,16 +18,16 @@ ${be(t.path.at(-1))} = ${_e(t.value)}
18
18
  `)+`
19
19
  `+(n.length?`
20
20
  `+n.join(`
21
- `):"")}c(Wt,"renderTable");function ci(e){let t=Wt(e,[]);return te(t,"config.toml"),t}c(ci,"serializeConfig");function qt(e,t="config.toml",r="user"){return ne(te(e,t).value,r)}c(qt,"validateConfigText");async function gt(e,t){if(t===null)return;try{qt(t)}catch{return}let r=Ne.join(e,"backups","config"),n=Ne.join(r,`${G(t)}.toml`);await S(n)===null&&await I(n,t);let o=await li(e);for(let i of o.slice(32))await Xt.rm(Ne.join(r,`${i.revision}.toml`))}c(gt,"rememberValidConfig");async function li(e){let t=Ne.join(e,"backups","config"),r=await Xt.readdir(t).catch(o=>{if(R(o))return[];throw o}),n=[];for(let o of r){if(!/^[a-f0-9]{64}\.toml$/.test(o))continue;let i=Ne.join(t,o),a=await S(i);if(!(!a||G(a)!==o.slice(0,-5))){try{qt(a,i)}catch{continue}n.push({revision:o.slice(0,-5),createdAt:(await Xt.stat(i)).mtime.toISOString()})}}return n.sort((o,i)=>i.createdAt.localeCompare(o.createdAt))}c(li,"configRecoveryRevisions");async function di(e,t,r){let n=_(e).config;return qt(r,n),L(n,async()=>{let o=await S(n);if(o){let i;try{i=te(o,n).value}catch{}if(i&&typeof i=="object"&&"schema_version"in i&&typeof i.schema_version=="number"&&i.schema_version>1)throw new w({code:"UNSUPPORTED_CONFIG_VERSION",path:n,message:"This configuration was written for a newer OpenPond version.",action:"Update OpenPond or restore a compatible backup into a separate home."})}if(G(o)!==t)throw new w({code:"CONFIG_CONFLICT",path:n,message:"Configuration changed since you opened it.",action:"Reload the file before saving."});if(await gt(e,o),G(await S(n))!==t)throw new w({code:"CONFIG_CONFLICT",path:n,message:"Configuration changed while saving.",action:"Reload the file before saving."});return await I(n,r),{rawRevision:G(r)}})}c(di,"replaceConfigText");async function cs(e,t,r){if(!/^[a-f0-9]{64}$/.test(t))throw new Error("Invalid configuration revision.");let n=Ne.join(e,"backups","config",`${t}.toml`),o=await S(n);if(!o||G(o)!==t)throw new w({code:"INVALID_CONFIG_BACKUP",path:n,message:"This configuration backup is unavailable or changed.",action:"Select another verified revision."});return di(e,r,o)}c(cs,"restoreConfigRevision");function ls(){return d.toJSONSchema(jt)}c(ls,"configEditorSchema");import{realpathSync as ui,watch as pi}from"node:fs";import fi from"node:path";async function O(e=gr(),t={}){let r=t.path??_(e).config,n=await S(r);return{path:r,rawRevision:G(n),document:_t(n===null?{schema_version:1}:te(n,r).value,r,t.scope)}}c(O,"readConfig");function _t(e,t,r){try{return ne(e,r)}catch(n){let o=n instanceof d.ZodError?n.issues.map(i=>`${i.path.join(".")||"config"}: ${i.message}`).join("; "):n instanceof Error?n.message:"Invalid configuration";throw new w({code:"INVALID_CONFIG",path:t,message:o,action:"Open the configuration file and correct the indicated setting."},{cause:n})}}c(_t,"validate");async function Es(e,t,r,n={}){let o=n.path??_(e).config;return L(o,async()=>{let i=await S(o);if(G(i)!==t||(await O(e,n)).rawRevision!==t)throw xe(o);let s=ze(i??`schema_version = 1
21
+ `):"")}c(Wt,"renderTable");function ci(e){let t=Wt(e,[]);return te(t,"config.toml"),t}c(ci,"serializeConfig");function qt(e,t="config.toml",r="user"){return ne(te(e,t).value,r)}c(qt,"validateConfigText");async function gt(e,t){if(t===null)return;try{qt(t)}catch{return}let r=Ne.join(e,"backups","config"),n=Ne.join(r,`${G(t)}.toml`);await S(n)===null&&await I(n,t);let o=await li(e);for(let i of o.slice(32))await Xt.rm(Ne.join(r,`${i.revision}.toml`))}c(gt,"rememberValidConfig");async function li(e){let t=Ne.join(e,"backups","config"),r=await Xt.readdir(t).catch(o=>{if(R(o))return[];throw o}),n=[];for(let o of r){if(!/^[a-f0-9]{64}\.toml$/.test(o))continue;let i=Ne.join(t,o),a=await S(i);if(!(!a||G(a)!==o.slice(0,-5))){try{qt(a,i)}catch{continue}n.push({revision:o.slice(0,-5),createdAt:(await Xt.stat(i)).mtime.toISOString()})}}return n.sort((o,i)=>i.createdAt.localeCompare(o.createdAt))}c(li,"configRecoveryRevisions");async function di(e,t,r){let n=_(e).config;return qt(r,n),L(n,async()=>{let o=await S(n);if(o){let i;try{i=te(o,n).value}catch{}if(i&&typeof i=="object"&&"schema_version"in i&&typeof i.schema_version=="number"&&i.schema_version>1)throw new w({code:"UNSUPPORTED_CONFIG_VERSION",path:n,message:"This configuration was written for a newer OpenPond version.",action:"Update OpenPond or restore a compatible backup into a separate home."})}if(G(o)!==t)throw new w({code:"CONFIG_CONFLICT",path:n,message:"Configuration changed since you opened it.",action:"Reload the file before saving."});if(await gt(e,o),G(await S(n))!==t)throw new w({code:"CONFIG_CONFLICT",path:n,message:"Configuration changed while saving.",action:"Reload the file before saving."});return await I(n,r),{rawRevision:G(r)}})}c(di,"replaceConfigText");async function cs(e,t,r){if(!/^[a-f0-9]{64}$/.test(t))throw new Error("Invalid configuration revision.");let n=Ne.join(e,"backups","config",`${t}.toml`),o=await S(n);if(!o||G(o)!==t)throw new w({code:"INVALID_CONFIG_BACKUP",path:n,message:"This configuration backup is unavailable or changed.",action:"Select another verified revision."});return di(e,r,o)}c(cs,"restoreConfigRevision");function ls(){return d.toJSONSchema(jt)}c(ls,"configEditorSchema");import{realpathSync as ui,watch as pi}from"node:fs";import fi from"node:path";async function O(e=_r(),t={}){let r=t.path??_(e).config,n=await S(r);return{path:r,rawRevision:G(n),document:_t(n===null?{schema_version:1}:te(n,r).value,r,t.scope)}}c(O,"readConfig");function _t(e,t,r){try{return ne(e,r)}catch(n){let o=n instanceof d.ZodError?n.issues.map(i=>`${i.path.join(".")||"config"}: ${i.message}`).join("; "):n instanceof Error?n.message:"Invalid configuration";throw new w({code:"INVALID_CONFIG",path:t,message:o,action:"Open the configuration file and correct the indicated setting."},{cause:n})}}c(_t,"validate");async function Es(e,t,r,n={}){let o=n.path??_(e).config;return L(o,async()=>{let i=await S(o);if(G(i)!==t||(await O(e,n)).rawRevision!==t)throw xe(o);let s=ze(i??`schema_version = 1
22
22
  `,r,o),l=_t(te(s,o).value,o,n.scope);if(G(await S(o))!==t)throw xe(o);return s!==i&&(await gt(e,i),await I(o,s)),{path:o,rawRevision:G(s),document:l}})}c(Es,"patchConfig");async function z(e,t,r){let n=_(e).config;return L(n,async()=>{let o=await O(e);if(r!==void 0&&o.rawRevision!==r)throw xe(n);let i=_t(await t(structuredClone(o.document)),n),a=ie(o.document,i);if(!a.length)return o;let s=await S(n);if(G(s)!==o.rawRevision)throw xe(n);let l=ze(s??`schema_version = 1
23
23
  `,a,n);if(_t(te(l,n).value,n),G(await S(n))!==o.rawRevision)throw xe(n);return await gt(e,s),await I(n,l),{path:n,rawRevision:G(l),document:i}})}c(z,"updateConfig");function xe(e){return new w({code:"CONFIG_CONFLICT",path:e,message:"Configuration changed since this edit began.",action:"Reload the latest settings and apply your change again."})}c(xe,"conflict");function yt(e,t){return cn(e,t)}c(yt,"mergeConfig");function cn(e,t){let r={...e};for(let[n,o]of Object.entries(t))o!==void 0&&(se(o)&&se(r[n])&&!("mode"in o)&&!("source"in o)&&!("provider_id"in o)?r[n]=cn(r[n],o):r[n]=structuredClone(o));return r}c(cn,"mergeTable");function bs(e,t){let r,n=pi(ui.native(fi.dirname(_(e).config)),{persistent:!1},(o,i)=>{i&&String(i)!=="config.toml"||(r&&clearTimeout(r),r=setTimeout(t,100),r.unref())});return n.on("error",t),()=>{r&&clearTimeout(r),n.close()}}c(bs,"watchConfig");var Is=["sidebarWidth","diffPanelWidth","sidebarSectionsCollapsed"],ln=c(e=>({provider_id:e.providerId,model_id:e.modelId}),"modelToConfig"),wt=c(e=>({providerId:e.provider_id,modelId:e.model_id}),"modelFromConfig"),Qt=c(e=>e?{mode:"custom",ref:ln(e)}:{mode:"inherit"},"modelOverride");function Ae(e){let t=Z.parse(e);return{schema_version:1,chat:{model:ln(t.defaultChatModelRef??{providerId:t.defaultChatProvider,modelId:t.defaultChatModel}),steer_active_responses:t.steerActiveResponses},codex:{reasoning_effort:t.codexReasoningEffort},permissions:{command_access:t.openPondCommandAccessMode,codex_mode:t.codexPermissionMode},context_compaction:{auto_enabled:t.contextCompaction.autoEnabled,trigger_percent:t.contextCompaction.triggerPercent,summary_model:t.contextCompaction.summaryModel},projects:{branch_prefix:t.defaultBranchPrefix,new_project_directory:t.defaultNewProjectDirectory},defaults:{...t.defaultTeamId?{team_id:t.defaultTeamId}:{}},ui:{advanced_workspace_controls:t.advancedWorkspaceControls},editor:{language_servers:t.editor.languageServers,diagnostics_while_editing:t.editor.diagnosticsWhileEditing,check_on_save:t.editor.checkOnSave,languages:Object.fromEntries(Object.entries(t.editor.languages).map(([r,n])=>[r,{mode:n.mode,custom_command:n.customCommand}]))},training:{default_model:Qt(t.training.defaultModelRef),creation_mode:t.training.creationMode,auto_approve_evidence:t.training.autoApproveEvidence},subagents:{enabled:t.subagents.enabled,delegation_mode:t.subagents.delegationMode,default_model:Qt(t.subagents.defaultModelRef),max_concurrent_runs:t.subagents.maxConcurrentRuns,max_concurrent_runs_per_provider:t.subagents.maxConcurrentRunsPerProvider??"unlimited",max_concurrent_runs_per_workspace_target:t.subagents.maxConcurrentRunsPerWorkspaceTarget??"unlimited",roles:Object.fromEntries(t.subagents.roles.map(r=>[r.id,{enabled:r.enabled,model:Qt(r.modelRef),isolation_mode:r.isolationMode,max_concurrent_runs:r.maxConcurrentRuns,tool_policy:r.toolPolicy,background:r.background,peer_messages:r.peerMessages}]))}}}c(Ae,"preferencesToConfig");function We(e,t={}){let r=Z.parse({}),n=e.chat?.model?wt(e.chat.model):{providerId:r.defaultChatProvider,modelId:r.defaultChatModel},o=e.subagents,i=new Map(r.subagents.roles.map(a=>[a.id,a]));for(let[a,s]of Object.entries(o?.roles??{})){let l=i.get(a);i.set(a,{id:a,enabled:s.enabled??l?.enabled??!0,modelRef:s.model?s.model.mode==="custom"?wt(s.model.ref):null:l?.modelRef??null,isolationMode:s.isolation_mode??l?.isolationMode??"none",maxConcurrentRuns:s.max_concurrent_runs??l?.maxConcurrentRuns??1,toolPolicy:s.tool_policy??l?.toolPolicy??"read_only",background:s.background??l?.background??!0,peerMessages:s.peer_messages??l?.peerMessages??"parent_scoped"})}return Z.parse({...r,...t,defaultChatProvider:n.providerId,defaultChatModel:n.modelId,defaultChatModelRef:n,codexReasoningEffort:e.codex?.reasoning_effort??r.codexReasoningEffort,codexPermissionMode:e.permissions?.codex_mode??r.codexPermissionMode,openPondCommandAccessMode:e.permissions?.command_access??r.openPondCommandAccessMode,defaultBranchPrefix:e.projects?.branch_prefix??r.defaultBranchPrefix,defaultNewProjectDirectory:e.projects?.new_project_directory??r.defaultNewProjectDirectory,defaultTeamId:e.defaults?.team_id??null,advancedWorkspaceControls:e.ui?.advanced_workspace_controls??r.advancedWorkspaceControls,steerActiveResponses:e.chat?.steer_active_responses??r.steerActiveResponses,contextCompaction:{autoEnabled:e.context_compaction?.auto_enabled??r.contextCompaction.autoEnabled,triggerPercent:e.context_compaction?.trigger_percent??r.contextCompaction.triggerPercent,summaryModel:e.context_compaction?.summary_model??r.contextCompaction.summaryModel},training:{defaultModelRef:e.training?.default_model?.mode==="custom"?wt(e.training.default_model.ref):null,creationMode:e.training?.creation_mode??r.training.creationMode,autoApproveEvidence:e.training?.auto_approve_evidence??r.training.autoApproveEvidence},editor:{languageServers:e.editor?.language_servers??r.editor.languageServers,diagnosticsWhileEditing:e.editor?.diagnostics_while_editing??r.editor.diagnosticsWhileEditing,checkOnSave:e.editor?.check_on_save??r.editor.checkOnSave,languages:Object.fromEntries(Object.entries(r.editor.languages).map(([a,s])=>{let l=e.editor?.languages?.[a];return[a,{mode:l?.mode??s.mode,customCommand:l?.custom_command??s.customCommand}]}))},subagents:{...r.subagents,enabled:o?.enabled??r.subagents.enabled,delegationMode:o?.delegation_mode??r.subagents.delegationMode,defaultModelRef:o?.default_model?.mode==="custom"?wt(o.default_model.ref):null,roles:[...i.values()],maxConcurrentRuns:o?.max_concurrent_runs??r.subagents.maxConcurrentRuns,maxConcurrentRunsPerProvider:o?.max_concurrent_runs_per_provider==="unlimited"?null:o?.max_concurrent_runs_per_provider??r.subagents.maxConcurrentRunsPerProvider,maxConcurrentRunsPerWorkspaceTarget:o?.max_concurrent_runs_per_workspace_target==="unlimited"?null:o?.max_concurrent_runs_per_workspace_target??r.subagents.maxConcurrentRunsPerWorkspaceTarget}})}c(We,"configToPreferences");function Tt(e){return{sidebarWidth:e.sidebarWidth,diffPanelWidth:e.diffPanelWidth,sidebarSectionsCollapsed:e.sidebarSectionsCollapsed}}c(Tt,"layoutPreferences");import mi from"node:path";import{existsSync as dn,promises as hi}from"node:fs";var gi="CREATE TABLE IF NOT EXISTS entries (namespace TEXT NOT NULL, cache_key TEXT NOT NULL, payload TEXT NOT NULL, updated_at TEXT NOT NULL, error TEXT, expires_at INTEGER NOT NULL, last_used INTEGER NOT NULL, PRIMARY KEY(namespace, cache_key));";async function Xe(e,t){return L(mi.join(_(e).runtime,"cache"),async()=>{for(let r=0;;r++){let n;try{return n=D(_(e).cache),n.exec(gi),t(n)}catch(o){if(!un(o)||r>0)throw o;n?.close(),n=void 0;for(let i of["-wal","-shm",""])await hi.rm(`${_(e).cache}${i}`,{force:!0})}finally{n?.close()}}})}c(Xe,"withCache");async function Ms(e,t,r,n={}){let o=c(s=>{if(!s.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='entries'").get())return null;let l=s.prepare("SELECT payload, updated_at, error, expires_at, last_used FROM entries WHERE namespace = ? AND cache_key = ?").get(t,r);return!l||!n.allowStale&&l.expires_at<Date.now()?null:{entry:{payload:JSON.parse(l.payload),updatedAt:l.updated_at,error:l.error},lastUsed:l.last_used}},"read"),i;try{i=kr(_(e).cache,null,o)}catch(s){if(!un(s))throw s;i=await Xe(e,o)}if(!i)return null;let a=Date.now();return i.lastUsed<a-6e4&&await Xe(e,s=>{s.prepare("UPDATE entries SET last_used = ? WHERE namespace = ? AND cache_key = ? AND last_used < ?").run(a,t,r,a-6e4)}),i.entry}c(Ms,"readCache");function un(e){let t=e;return e instanceof SyntaxError||t.errcode!==void 0&&[11,26].includes(t.errcode&255)||["SQLITE_CORRUPT","SQLITE_NOTADB"].includes(t.code??"")}c(un,"isCorruptCache");async function Yt(e,t,r,n,o={}){let i=Date.now(),a=new Date(i).toISOString(),s=JSON.stringify(n);return await Xe(e,l=>{l.prepare("INSERT INTO entries VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT(namespace, cache_key) DO UPDATE SET payload=excluded.payload, updated_at=excluded.updated_at, error=excluded.error, expires_at=excluded.expires_at, last_used=excluded.last_used").run(t,r,s,a,o.error??null,i+(o.ttlMs??36e5),i);let p=Number(l.prepare("DELETE FROM entries WHERE expires_at < ?").run(i-7*864e5).changes)>0,f=Number(l.prepare("SELECT coalesce(sum(length(CAST(payload AS BLOB))),0) AS size FROM entries").get().size);if(f>512*1024*1024){for(let g of l.prepare("SELECT namespace, cache_key, length(CAST(payload AS BLOB)) AS size FROM entries ORDER BY last_used").all())if(l.prepare("DELETE FROM entries WHERE namespace = ? AND cache_key = ?").run(g.namespace,g.cache_key),p=!0,f-=g.size,f<=512*1024*1024)break}p&&l.exec("PRAGMA wal_checkpoint(TRUNCATE); VACUUM;")}),{payload:n,updatedAt:a,error:o.error??null}}c(Yt,"writeCache");async function Ds(e,t){return dn(_(e).cache)?Xe(e,r=>Object.fromEntries(r.prepare("SELECT cache_key, payload, updated_at, error FROM entries WHERE namespace = ? AND expires_at >= ?").all(t,Date.now()).map(n=>[n.cache_key,{payload:JSON.parse(n.payload),updatedAt:n.updated_at,error:n.error}]))):{}}c(Ds,"listCache");async function Us(e,t){dn(_(e).cache)&&await Xe(e,r=>{t?r.prepare("DELETE FROM entries WHERE namespace = ?").run(t):r.exec("DELETE FROM entries"),r.exec("PRAGMA wal_checkpoint(TRUNCATE); VACUUM;")})}c(Us,"clearCache");import{createCipheriv as _i,createDecipheriv as yi,randomBytes as pn,randomUUID as wi,createHash as Zt}from"node:crypto";var Ti=d.strictObject({owner:d.string(),revision:d.number().int().positive(),algorithm:d.literal("aes-256-gcm"),keyId:d.string(),iv:d.string(),ciphertext:d.string(),tag:d.string()}),Ei=d.strictObject({schemaVersion:d.literal("openpond.credentials.v1"),records:d.record(d.string(),Ti)});async function qe(e){let t=_(e).credentials;try{return Ei.parse(await M(t,()=>({schemaVersion:"openpond.credentials.v1",records:{}})))}catch(r){throw r instanceof w?r:er(e,"The credential store has an invalid format.",r)}}c(qe,"readVault");async function Et(e,t){let r=_(e),n=await S(r.key);if(n===null&&t&&await S(r.credentials)===null){let i=pn(32);return await I(r.key,`${i.toString("base64")}
24
24
  `),i}let o=n?Buffer.from(n.trim(),"base64"):null;if(!o||o.length!==32)throw er(e,"The credential encryption key is missing or invalid.");return o}c(Et,"readKey");function er(e,t,r){return new w({code:"CREDENTIAL_RECOVERY_REQUIRED",path:_(e).credentials,message:t,action:"Restore the matching credential store and key from a verified backup. Existing files have been preserved."},{cause:r})}c(er,"credentialError");function tr(e,t,r,n){try{if(r.owner!==t||r.keyId!==Zt("sha256").update(n).digest("hex"))throw new Error("Credential ownership mismatch");let o=yi("aes-256-gcm",n,Buffer.from(r.iv,"base64"));o.setAAD(Buffer.from(`${t}:${r.revision}`)),o.setAuthTag(Buffer.from(r.tag,"base64"));let i=JSON.parse(Buffer.concat([o.update(Buffer.from(r.ciphertext,"base64")),o.final()]).toString("utf8"));return{revision:r.revision,value:i}}catch(o){throw er(e,"A credential could not be verified or decrypted.",o)}}c(tr,"decrypt");async function fn(e,t){let r=await qe(e),n=r.records[t];return n?tr(e,t,n,await Et(e,!1)):null}c(fn,"readCredential");async function mn(e,t){if(Array.isArray(t)&&t.length===0)return{};let r=typeof t=="string"?null:new Set(t),n=await qe(e),o=Object.entries(n.records).filter(([a])=>typeof t=="string"?a.startsWith(t):r.has(a));if(!o.length)return{};let i=await Et(e,!1);return Object.fromEntries(o.map(([a,s])=>[a,tr(e,a,s,i)]))}c(mn,"readCredentials");async function bt(e,t,r,n){return L(_(e).credentials,async()=>{let o=await qe(e),i=o.records[t];if(n!==void 0&&n!==(i?.revision??null))throw new w({code:"CREDENTIAL_CONFLICT",path:t,message:"This credential changed or was revoked.",action:"Reload the connection before retrying."});let a=await Et(e,!0),s=(i?.revision??0)+1,l=pn(12),p=_i("aes-256-gcm",a,l);p.setAAD(Buffer.from(`${t}:${s}`));let f=Buffer.concat([p.update(JSON.stringify(r),"utf8"),p.final()]);return o.records[t]={owner:t,revision:s,algorithm:"aes-256-gcm",keyId:Zt("sha256").update(a).digest("hex"),iv:l.toString("base64"),ciphertext:f.toString("base64"),tag:p.getAuthTag().toString("base64")},await I(_(e).credentials,`${JSON.stringify(o,null,2)}
25
25
  `),s})}c(bt,"writeCredential");async function hn(e,t){await L(_(e).credentials,async()=>{let r=await qe(e);t in r.records&&(delete r.records[t],await I(_(e).credentials,`${JSON.stringify(r,null,2)}
26
- `))})}c(hn,"deleteCredential");function gn(e){return`${e}:${wi()}`}c(gn,"newCredentialId");async function _n(e,t){let r=await qe(e),n=t.some(o=>r.records[o])?await Et(e,!1):null;return Object.fromEntries([...new Set(t)].sort().map(o=>{let i=r.records[o];if(!i||!n)return[o,null];let a=tr(e,o,i,n).value,s=o.startsWith("provider:")&&a?.source==="chatgpt_subscription"?{id:o,keyId:i.keyId,source:a.source,endpoint:a.endpoint,createdAt:a.createdAt,accountId:a.oauth?.accountId}:i;return[o,Zt("sha256").update(JSON.stringify(s)).digest("hex")]}))}c(_n,"credentialVersions");import bi from"node:path";import{createHash as wn}from"node:crypto";function Tn(e){return wn("sha256").update(JSON.stringify([e.handle,e.base_url??null,e.api_base_url??null,e.chat_api_base_url??null])).digest("hex")}c(Tn,"credentialContext");function ue(e,t){return`account-${wn("sha256").update(JSON.stringify([e.trim().toLowerCase(),t?.trim().replace(/\/$/,"")??""])).digest("hex").slice(0,24)}`}c(ue,"accountId");function yn(e){let t=e.activeProfile,r=t&&e.accounts?.find(n=>n.handle.trim().toLowerCase()===t.handle.trim().toLowerCase()&&(!t.baseUrl||ue(n.handle,n.baseUrl)===ue(t.handle,t.baseUrl)))||e.accounts?.[0];return r?[ue(r.handle,r.baseUrl),r.apiBaseUrl,r.chatApiBaseUrl,r.apiKey,r.session?.token]:null}c(yn,"activeAccountAuthority");var rr=new Map;async function En(e){let t=bi.resolve(e),r=rr.get(t);return r||(r=L(`${_(t).runtime}/accounts`,()=>bn(t)).finally(()=>rr.delete(t)),rr.set(t,r)),structuredClone(await r)}c(En,"readAccountConfiguration");async function bn(e,t){let{document:r}=t??await O(e),n=Object.entries(r.accounts??{}),o=Pr(e,[...n.map(([m])=>({table:"account_sessions",id:m})),{table:"account_selection",id:"last_used"},{table:"profile_installations",id:"library"}]),i=new Map(n.map(([m],h)=>[m,o[h]?.value])),a=await mn(e,n.flatMap(([,m])=>m.enabled!==!1&&m.credential?.source==="secret"?[m.credential.id]:[])),s=[];for(let[m,h]of n){if(h.enabled===!1)continue;let y={};if(h.credential?.source==="secret"){let A=a[h.credential.id];if(!A)throw new w({code:"CREDENTIAL_MISSING",path:_(e).config,message:`The credential referenced by account ${m} is unavailable.`,action:"Reconnect this account or restore its credential backup."});y=A.value.context===Tn(h)?A.value:{}}else h.credential?.source==="env"&&(y={apiKey:process.env[h.credential.name]});let T=i.get(m);s.push({handle:h.handle,...h.base_url?{baseUrl:h.base_url}:{},...h.api_base_url?{apiBaseUrl:h.api_base_url}:{},...h.chat_api_base_url?{chatApiBaseUrl:h.chat_api_base_url}:{},...h.environment?{environment:h.environment}:{},...y.apiKey?{apiKey:y.apiKey}:{},...T||y.token?{session:{...T,...y.token?{token:y.token}:{}}}:{}})}let l=r.defaults?.account_id?r.accounts?.[r.defaults.account_id]:void 0;if(r.defaults?.account_id&&(!l||l.enabled===!1))throw new w({code:"INVALID_ACCOUNT_DEFAULT",path:_(e).config,message:"The configured default account is missing or disabled.",action:"Choose an enabled default account or remove defaults.account_id."});let p=l?{handle:l.handle,baseUrl:l.base_url}:o[n.length]?.value,f=o[n.length+1]?.value,g=r.defaults?.profile_ref;if(g){let m=f,h=m?.profiles?.find(y=>y.source===g.source&&y.repositoryId===g.repository_id&&y.profile===g.profile_id);if(!h)throw new w({code:"INVALID_PROFILE_DEFAULT",path:_(e).config,message:"The configured default Profile is not installed.",action:"Install that Profile or remove defaults.profile_ref."});f={...m,repoPath:h.repoPath,profile:h.profile,mode:"local"}}return{accounts:s,...p?{activeProfile:p}:{},...f?{openpondProfile:f}:{},...r.editor?.language_servers?{lspEnabled:r.editor.language_servers!=="off"}:{},...r.runtime?.execution_mode?{executionMode:r.runtime.execution_mode}:{},...r.runtime?.mode?{mode:r.runtime.mode}:{}}}c(bn,"readUnlocked");async function An(e,t){return L(`${_(e).runtime}/accounts`,async()=>{let r=await O(e),n=r.document,o=await bn(e,r),i=await t(structuredClone(o)),a=JSON.stringify(yn(o))!==JSON.stringify(yn(i)),s=new Map,l=Object.fromEntries(Object.entries(n.accounts??{}).filter(([,g])=>g.enabled===!1)),p=new Set;for(let g of i.accounts??[]){let m=ue(g.handle,g.baseUrl);if(p.has(m))throw new w({code:"DUPLICATE_ACCOUNT",path:_(e).config,message:"Two accounts have the same handle and service endpoint.",action:"Resolve the duplicate accounts before saving."});p.add(m);let h=Object.entries(n.accounts??{}).find(([,E])=>ue(E.handle,E.base_url)===ue(g.handle,g.baseUrl))?.[0]??ue(g.handle,g.baseUrl),y=n.accounts?.[h],T={...g.apiKey?{apiKey:g.apiKey}:{},...g.session?.token?{token:g.session.token}:{}},A=y?.credential,x=o.accounts?.find(E=>ue(E.handle,E.baseUrl)===ue(g.handle,g.baseUrl));if((x?.apiKey!==g.apiKey||x?.session?.token!==g.session?.token||x?.apiBaseUrl!==g.apiBaseUrl||x?.chatApiBaseUrl!==g.chatApiBaseUrl||!A&&Object.keys(T).length)&&(A=void 0,Object.keys(T).length)){let E=gn(h);await bt(e,E,{...T,context:Tn({handle:g.handle,base_url:g.baseUrl,api_base_url:g.apiBaseUrl,chat_api_base_url:g.chatApiBaseUrl})},null),A={source:"secret",id:E}}l[h]={...y?.enabled===void 0?{}:{enabled:y.enabled},handle:g.handle,...g.baseUrl?{base_url:g.baseUrl}:{},...g.apiBaseUrl?{api_base_url:g.apiBaseUrl}:{},...g.chatApiBaseUrl?{chat_api_base_url:g.chatApiBaseUrl}:{},...g.environment?{environment:g.environment}:{},...A?{credential:A}:{}},g.session&&s.set(h,{appId:g.session.appId??null,conversationId:g.session.conversationId??null})}await z(e,g=>({...g,accounts:l,...a||g.defaults?.account_id&&!l[g.defaults.account_id]?{defaults:{...g.defaults,...a?{team_id:void 0}:{},...g.defaults?.account_id&&!l[g.defaults.account_id]?{account_id:void 0}:{}}}:{},...i.lspEnabled===void 0?{}:{editor:{...g.editor,language_servers:i.lspEnabled?"auto":"off"}},...i.executionMode||i.mode?{runtime:{...g.runtime,...i.executionMode?{execution_mode:i.executionMode}:{},...i.mode?{mode:i.mode}:{}}}:{}}),r.rawRevision),he(e,g=>{g.exec("BEGIN IMMEDIATE");try{for(let m of new Set([...Object.keys(n.accounts??{}),...Object.keys(l)])){let h=s.get(m);h?g.prepare("INSERT INTO account_sessions VALUES (?, ?, 1) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload, revision=revision+1").run(m,JSON.stringify(h)):g.prepare("DELETE FROM account_sessions WHERE id = ?").run(m)}JSON.stringify(o.activeProfile)!==JSON.stringify(i.activeProfile)&&g.prepare("INSERT INTO account_selection VALUES ('last_used', ?, 1) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload, revision=revision+1").run(JSON.stringify(i.activeProfile??null)),JSON.stringify(o.openpondProfile)!==JSON.stringify(i.openpondProfile)&&g.prepare("INSERT INTO profile_installations VALUES ('library', ?, 1) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload, revision=revision+1").run(JSON.stringify(i.openpondProfile??null)),g.exec("COMMIT")}catch(m){throw g.exec("ROLLBACK"),m}});let f=new Set(Object.values(l).flatMap(g=>g.credential?.source==="secret"?[g.credential.id]:[]));for(let g of Object.values(n.accounts??{}))g.credential?.source==="secret"&&!f.has(g.credential.id)&&await hn(e,g.credential.id);return i})}c(An,"updateAccountConfiguration");import{lstat as Ai}from"node:fs/promises";import Si from"node:path";var Se=new Map;async function nr(e){let t=_(e);me(t.runtime);let r=await Promise.all([t.marker,Si.join(t.runtime,"migration.json")].map(async n=>{try{let o=await Ai(n,{bigint:!0});return o.isFile()?`${o.dev}:${o.ino}:${o.size}:${o.mtimeNs}:${o.ctimeNs}`:null}catch(o){if(R(o))return"missing";throw o}}));return r.some(n=>n===null)||r[0]==="missing"?null:r.join("/")}c(nr,"initializationSignature");function Sn(e,t){let r=Se.get(e);return!t||r?.signature!==t?(Se.delete(e),null):{...r.report}}c(Sn,"cachedInitialization");function vn(e,t,r){Se.delete(e),Se.set(e,{signature:t,report:{...r}}),Se.size>16&&Se.delete(Se.keys().next().value)}c(vn,"rememberInitialization");import{existsSync as vi,promises as Ii}from"node:fs";import Qe from"node:path";var or=new Set(["sessions","projection_session_shells","sidebar_file_bookmarks","saved_local_projects","profile_installations","extension_installations","scaffold_registrations","refiner_bindings","harness_release_records","dataset_artifacts","dataset_import_jobs","taskset_drafts","taskset_draft_workspaces","training_artifacts","task_attempt_artifacts","local_agent_schedules"]);function At(e,t){let r=Qe.relative(t,e);return r===""||r!==".."&&!r.startsWith(`..${Qe.sep}`)&&!Qe.isAbsolute(r)}c(At,"isWithinHome");async function St(e){let t=new Set,r=(await O(e)).document;function n(a){Qe.isAbsolute(a)&&!At(a,e)&&t.add(Qe.normalize(a))}c(n,"add"),r.storage?.datasets_dir&&n(je(r.storage.datasets_dir,e)),r.personalization?.user_instructions&&n(je(r.personalization.user_instructions,e));function o(a,s=""){if(typeof a=="string"&&/(?:path|directory|root|cwd)$/i.test(s))n(a);else if(Array.isArray(a))for(let l of a)o(l,s);else if(a&&typeof a=="object")for(let[l,p]of Object.entries(a))["messages","events","turns","metadata","input","output","result","credential"].includes(l)||o(p,l)}c(o,"visit");let i=_(e).database;if(vi(i)){let a=D(i,!0);try{for(let{name:s}of a.prepare("SELECT name FROM sqlite_master WHERE type='table'").all())if(or.has(s)){let l=a.prepare(`PRAGMA table_info(${s})`).all();if(l.some(p=>p.name==="payload"))for(let p of a.prepare(`SELECT payload FROM ${s}`).all())o(JSON.parse(p.payload));for(let{name:p}of l.filter(f=>/(?:_path|_directory|_root)$/.test(f.name)||f.name==="cwd"))for(let f of a.prepare(`SELECT "${p}" AS value FROM ${s}`).all())typeof f.value=="string"&&n(f.value)}}finally{a.close()}}return Promise.all([...t].sort().map(async a=>({path:a,available:!!await Ii.stat(a).catch(()=>null),included:!1})))}c(St,"externalStorageReferences");import{randomUUID as Li}from"node:crypto";import{promises as vt,existsSync as In}from"node:fs";import Oi from"node:os";import ke from"node:path";async function Ln(e,t,r){let n=await vt.mkdtemp(ke.join(Oi.tmpdir(),"openpond-migration-preview-")),o=`migration-preview-${Li()}`,i={schemaVersion:"openpond.migration.v1",id:o,status:"preparing",home:n,stage:ke.join(ke.dirname(n),`.${ke.basename(n)}-${o}`),backup:ke.join(n,"backups",o),files:[],installed:[],createdAt:new Date().toISOString(),sourceAppHome:t.sourceAppHome,sourceConfig:t.sourceConfig,sourceBrowserState:t.sourceBrowserState};try{try{await r(i)}catch(y){return{issues:[hr(y,e)],counts:{},destinations:[],conflicts:[],estimatedBytes:null,credentialRecords:null}}let a=await O(i.stage),s=In(_(e).config)?await O(e):null,l=s?ie(s.document,a.document).map(y=>({path:y.path,choices:["imported","existing"]})):[],p=ie({schema_version:1},a.document).map(y=>({path:y.path,destination:"config.toml",operation:y.op})),f={},g=_(i.stage).database;if(In(g)){let y=D(g,!0);try{for(let T of y.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'").all())f[T.name]=Number(y.prepare(`SELECT count(*) AS count FROM "${T.name.replaceAll('"','""')}"`).get().count)}finally{y.close()}}let m=0;for(let y of i.files)m+=(await vt.lstat(ke.join(i.stage,y.path))).size;let h=Object.values(a.document.accounts??{}).filter(y=>y.credential?.source==="secret").length+Object.values(a.document.providers??{}).filter(y=>y.credential?.source==="secret").length;return{issues:[],counts:f,destinations:p,conflicts:l,estimatedBytes:m,credentialRecords:h,externalRoots:await St(i.stage),layoutVersion:1,configSchemaVersion:a.document.schema_version}}finally{await vt.rm(i.stage,{recursive:!0,force:!0}),await vt.rm(n,{recursive:!0,force:!0})}}c(Ln,"previewMigration");import{randomUUID as Cn}from"node:crypto";import{promises as j}from"node:fs";import ve from"node:path";import{createHash as Ci}from"node:crypto";import{createReadStream as Ni,promises as On}from"node:fs";async function K(e){let t=await On.lstat(e),r=Ci("sha256");if(t.isSymbolicLink())return r.update(`symlink:${await On.readlink(e)}`).digest("hex");if(!t.isFile())throw new Error(`Unsupported migration object: ${e}`);for await(let n of Ni(e))r.update(n);return r.digest("hex")}c(K,"digestFile");var Nn=d.string().regex(/^[a-f0-9]{64}$/),ir=d.strictObject({schemaVersion:d.literal("openpond.artifact.v1"),sha256:Nn,sizeBytes:d.number().int().nonnegative().safe(),createdAt:d.string().datetime()}),xi=`CREATE TABLE IF NOT EXISTS managed_artifact_objects (sha256 TEXT PRIMARY KEY, payload TEXT NOT NULL, orphaned_at TEXT);
26
+ `))})}c(hn,"deleteCredential");function gn(e){return`${e}:${wi()}`}c(gn,"newCredentialId");async function _n(e,t){let r=await qe(e),n=t.some(o=>r.records[o])?await Et(e,!1):null;return Object.fromEntries([...new Set(t)].sort().map(o=>{let i=r.records[o];if(!i||!n)return[o,null];let a=tr(e,o,i,n).value,s=o.startsWith("provider:")&&a?.source==="chatgpt_subscription"?{id:o,keyId:i.keyId,source:a.source,endpoint:a.endpoint,createdAt:a.createdAt,accountId:a.oauth?.accountId}:i;return[o,Zt("sha256").update(JSON.stringify(s)).digest("hex")]}))}c(_n,"credentialVersions");import bi from"node:path";import{createHash as wn}from"node:crypto";function Tn(e){return wn("sha256").update(JSON.stringify([e.handle,e.base_url??null,e.api_base_url??null,e.chat_api_base_url??null])).digest("hex")}c(Tn,"credentialContext");function ue(e,t){return`account-${wn("sha256").update(JSON.stringify([e.trim().toLowerCase(),t?.trim().replace(/\/$/,"")??""])).digest("hex").slice(0,24)}`}c(ue,"accountId");function yn(e){let t=e.activeProfile,r=t&&e.accounts?.find(n=>n.handle.trim().toLowerCase()===t.handle.trim().toLowerCase()&&(!t.baseUrl||ue(n.handle,n.baseUrl)===ue(t.handle,t.baseUrl)))||e.accounts?.[0];return r?[ue(r.handle,r.baseUrl),r.apiBaseUrl,r.chatApiBaseUrl,r.apiKey,r.session?.token]:null}c(yn,"activeAccountAuthority");var rr=new Map;async function En(e){let t=bi.resolve(e),r=rr.get(t);return r||(r=L(`${_(t).runtime}/accounts`,()=>bn(t)).finally(()=>rr.delete(t)),rr.set(t,r)),structuredClone(await r)}c(En,"readAccountConfiguration");async function bn(e,t){let{document:r}=t??await O(e),n=Object.entries(r.accounts??{}),o=Pr(e,[...n.map(([m])=>({table:"account_sessions",id:m})),{table:"account_selection",id:"last_used"},{table:"profile_installations",id:"library"}]),i=new Map(n.map(([m],h)=>[m,o[h]?.value])),a=await mn(e,n.flatMap(([,m])=>m.enabled!==!1&&m.credential?.source==="secret"?[m.credential.id]:[])),s=[];for(let[m,h]of n){if(h.enabled===!1)continue;let y={};if(h.credential?.source==="secret"){let A=a[h.credential.id];if(!A)throw new w({code:"CREDENTIAL_MISSING",path:_(e).config,message:`The credential referenced by account ${m} is unavailable.`,action:"Reconnect this account or restore its credential backup."});y=A.value.context===Tn(h)?A.value:{}}else h.credential?.source==="env"&&(y={apiKey:process.env[h.credential.name]});let T=i.get(m);s.push({handle:h.handle,...h.base_url?{baseUrl:h.base_url}:{},...h.api_base_url?{apiBaseUrl:h.api_base_url}:{},...h.chat_api_base_url?{chatApiBaseUrl:h.chat_api_base_url}:{},...h.environment?{environment:h.environment}:{},...y.apiKey?{apiKey:y.apiKey}:{},...T||y.token?{session:{...T,...y.token?{token:y.token}:{}}}:{}})}let l=r.defaults?.account_id?r.accounts?.[r.defaults.account_id]:void 0;if(r.defaults?.account_id&&(!l||l.enabled===!1))throw new w({code:"INVALID_ACCOUNT_DEFAULT",path:_(e).config,message:"The configured default account is missing or disabled.",action:"Choose an enabled default account or remove defaults.account_id."});let p=l?{handle:l.handle,baseUrl:l.base_url}:o[n.length]?.value,f=o[n.length+1]?.value,g=r.defaults?.profile_ref;if(g){let m=f,h=m?.profiles?.find(y=>y.source===g.source&&y.repositoryId===g.repository_id&&y.profile===g.profile_id);if(!h)throw new w({code:"INVALID_PROFILE_DEFAULT",path:_(e).config,message:"The configured default Profile is not installed.",action:"Install that Profile or remove defaults.profile_ref."});f={...m,repoPath:h.repoPath,profile:h.profile,mode:"local"}}return{accounts:s,...p?{activeProfile:p}:{},...f?{openpondProfile:f}:{},...r.editor?.language_servers?{lspEnabled:r.editor.language_servers!=="off"}:{},...r.runtime?.execution_mode?{executionMode:r.runtime.execution_mode}:{},...r.runtime?.mode?{mode:r.runtime.mode}:{}}}c(bn,"readUnlocked");async function An(e,t){return L(`${_(e).runtime}/accounts`,async()=>{let r=await O(e),n=r.document,o=await bn(e,r),i=await t(structuredClone(o)),a=JSON.stringify(yn(o))!==JSON.stringify(yn(i)),s=new Map,l=Object.fromEntries(Object.entries(n.accounts??{}).filter(([,g])=>g.enabled===!1)),p=new Set;for(let g of i.accounts??[]){let m=ue(g.handle,g.baseUrl);if(p.has(m))throw new w({code:"DUPLICATE_ACCOUNT",path:_(e).config,message:"Two accounts have the same handle and service endpoint.",action:"Resolve the duplicate accounts before saving."});p.add(m);let h=Object.entries(n.accounts??{}).find(([,E])=>ue(E.handle,E.base_url)===ue(g.handle,g.baseUrl))?.[0]??ue(g.handle,g.baseUrl),y=n.accounts?.[h],T={...g.apiKey?{apiKey:g.apiKey}:{},...g.session?.token?{token:g.session.token}:{}},A=y?.credential,x=o.accounts?.find(E=>ue(E.handle,E.baseUrl)===ue(g.handle,g.baseUrl));if((x?.apiKey!==g.apiKey||x?.session?.token!==g.session?.token||x?.apiBaseUrl!==g.apiBaseUrl||x?.chatApiBaseUrl!==g.chatApiBaseUrl||!A&&Object.keys(T).length)&&(A=void 0,Object.keys(T).length)){let E=gn(h);await bt(e,E,{...T,context:Tn({handle:g.handle,base_url:g.baseUrl,api_base_url:g.apiBaseUrl,chat_api_base_url:g.chatApiBaseUrl})},null),A={source:"secret",id:E}}l[h]={...y?.enabled===void 0?{}:{enabled:y.enabled},handle:g.handle,...g.baseUrl?{base_url:g.baseUrl}:{},...g.apiBaseUrl?{api_base_url:g.apiBaseUrl}:{},...g.chatApiBaseUrl?{chat_api_base_url:g.chatApiBaseUrl}:{},...g.environment?{environment:g.environment}:{},...A?{credential:A}:{}},g.session&&s.set(h,{appId:g.session.appId??null,conversationId:g.session.conversationId??null})}await z(e,g=>({...g,accounts:l,...a||g.defaults?.account_id&&!l[g.defaults.account_id]?{defaults:{...g.defaults,...a?{team_id:void 0}:{},...g.defaults?.account_id&&!l[g.defaults.account_id]?{account_id:void 0}:{}}}:{},...i.lspEnabled===void 0?{}:{editor:{...g.editor,language_servers:i.lspEnabled?"auto":"off"}},...i.executionMode||i.mode?{runtime:{...g.runtime,...i.executionMode?{execution_mode:i.executionMode}:{},...i.mode?{mode:i.mode}:{}}}:{}}),r.rawRevision),he(e,g=>{g.exec("BEGIN IMMEDIATE");try{for(let m of new Set([...Object.keys(n.accounts??{}),...Object.keys(l)])){let h=s.get(m);h?g.prepare("INSERT INTO account_sessions VALUES (?, ?, 1) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload, revision=revision+1").run(m,JSON.stringify(h)):g.prepare("DELETE FROM account_sessions WHERE id = ?").run(m)}JSON.stringify(o.activeProfile)!==JSON.stringify(i.activeProfile)&&g.prepare("INSERT INTO account_selection VALUES ('last_used', ?, 1) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload, revision=revision+1").run(JSON.stringify(i.activeProfile??null)),JSON.stringify(o.openpondProfile)!==JSON.stringify(i.openpondProfile)&&g.prepare("INSERT INTO profile_installations VALUES ('library', ?, 1) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload, revision=revision+1").run(JSON.stringify(i.openpondProfile??null)),g.exec("COMMIT")}catch(m){throw g.exec("ROLLBACK"),m}});let f=new Set(Object.values(l).flatMap(g=>g.credential?.source==="secret"?[g.credential.id]:[]));for(let g of Object.values(n.accounts??{}))g.credential?.source==="secret"&&!f.has(g.credential.id)&&await hn(e,g.credential.id);return i})}c(An,"updateAccountConfiguration");import{lstat as Ai}from"node:fs/promises";import Si from"node:path";var Se=new Map;async function nr(e){let t=_(e);me(t.runtime);let r=await Promise.all([t.marker,Si.join(t.runtime,"migration.json")].map(async n=>{try{let o=await Ai(n,{bigint:!0});return o.isFile()?`${o.dev}:${o.ino}:${o.size}:${o.mtimeNs}:${o.ctimeNs}`:null}catch(o){if(R(o))return"missing";throw o}}));return r.some(n=>n===null)||r[0]==="missing"?null:r.join("/")}c(nr,"initializationSignature");function Sn(e,t){let r=Se.get(e);return!t||r?.signature!==t?(Se.delete(e),null):{...r.report}}c(Sn,"cachedInitialization");function vn(e,t,r){Se.delete(e),Se.set(e,{signature:t,report:{...r}}),Se.size>16&&Se.delete(Se.keys().next().value)}c(vn,"rememberInitialization");import{existsSync as vi,promises as Ii}from"node:fs";import Qe from"node:path";var or=new Set(["sessions","projection_session_shells","sidebar_file_bookmarks","saved_local_projects","profile_installations","extension_installations","scaffold_registrations","refiner_bindings","harness_release_records","dataset_artifacts","dataset_import_jobs","taskset_drafts","taskset_draft_workspaces","training_artifacts","task_attempt_artifacts","local_agent_schedules"]);function At(e,t){let r=Qe.relative(t,e);return r===""||r!==".."&&!r.startsWith(`..${Qe.sep}`)&&!Qe.isAbsolute(r)}c(At,"isWithinHome");async function St(e){let t=new Set,r=(await O(e)).document;function n(a){Qe.isAbsolute(a)&&!At(a,e)&&t.add(Qe.normalize(a))}c(n,"add"),r.storage?.datasets_dir&&n(je(r.storage.datasets_dir,e)),r.personalization?.user_instructions&&n(je(r.personalization.user_instructions,e));function o(a,s=""){if(typeof a=="string"&&/(?:path|directory|root|cwd)$/i.test(s))n(a);else if(Array.isArray(a))for(let l of a)o(l,s);else if(a&&typeof a=="object")for(let[l,p]of Object.entries(a))["messages","events","turns","metadata","input","output","result","credential"].includes(l)||o(p,l)}c(o,"visit");let i=_(e).database;if(vi(i)){let a=D(i,!0);try{for(let{name:s}of a.prepare("SELECT name FROM sqlite_master WHERE type='table'").all())if(or.has(s)){let l=a.prepare(`PRAGMA table_info(${s})`).all();if(l.some(p=>p.name==="payload"))for(let p of a.prepare(`SELECT payload FROM ${s}`).all())o(JSON.parse(p.payload));for(let{name:p}of l.filter(f=>/(?:_path|_directory|_root)$/.test(f.name)||f.name==="cwd"))for(let f of a.prepare(`SELECT "${p}" AS value FROM ${s}`).all())typeof f.value=="string"&&n(f.value)}}finally{a.close()}}return Promise.all([...t].sort().map(async a=>({path:a,available:!!await Ii.stat(a).catch(()=>null),included:!1})))}c(St,"externalStorageReferences");import{randomUUID as Li}from"node:crypto";import{promises as vt,existsSync as In}from"node:fs";import Oi from"node:os";import ke from"node:path";async function Ln(e,t,r){let n=await vt.mkdtemp(ke.join(Oi.tmpdir(),"openpond-migration-preview-")),o=`migration-preview-${Li()}`,i={schemaVersion:"openpond.migration.v1",id:o,status:"preparing",home:n,stage:ke.join(ke.dirname(n),`.${ke.basename(n)}-${o}`),backup:ke.join(n,"backups",o),files:[],installed:[],createdAt:new Date().toISOString(),sourceAppHome:t.sourceAppHome,sourceConfig:t.sourceConfig,sourceBrowserState:t.sourceBrowserState};try{try{await r(i)}catch(y){return{issues:[gr(y,e)],counts:{},destinations:[],conflicts:[],estimatedBytes:null,credentialRecords:null}}let a=await O(i.stage),s=In(_(e).config)?await O(e):null,l=s?ie(s.document,a.document).map(y=>({path:y.path,choices:["imported","existing"]})):[],p=ie({schema_version:1},a.document).map(y=>({path:y.path,destination:"config.toml",operation:y.op})),f={},g=_(i.stage).database;if(In(g)){let y=D(g,!0);try{for(let T of y.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'").all())f[T.name]=Number(y.prepare(`SELECT count(*) AS count FROM "${T.name.replaceAll('"','""')}"`).get().count)}finally{y.close()}}let m=0;for(let y of i.files)m+=(await vt.lstat(ke.join(i.stage,y.path))).size;let h=Object.values(a.document.accounts??{}).filter(y=>y.credential?.source==="secret").length+Object.values(a.document.providers??{}).filter(y=>y.credential?.source==="secret").length;return{issues:[],counts:f,destinations:p,conflicts:l,estimatedBytes:m,credentialRecords:h,externalRoots:await St(i.stage),layoutVersion:1,configSchemaVersion:a.document.schema_version}}finally{await vt.rm(i.stage,{recursive:!0,force:!0}),await vt.rm(n,{recursive:!0,force:!0})}}c(Ln,"previewMigration");import{randomUUID as Cn}from"node:crypto";import{promises as j}from"node:fs";import ve from"node:path";import{createHash as Ci}from"node:crypto";import{createReadStream as Ni,promises as On}from"node:fs";async function K(e){let t=await On.lstat(e),r=Ci("sha256");if(t.isSymbolicLink())return r.update(`symlink:${await On.readlink(e)}`).digest("hex");if(!t.isFile())throw new Error(`Unsupported migration object: ${e}`);for await(let n of Ni(e))r.update(n);return r.digest("hex")}c(K,"digestFile");var Nn=d.string().regex(/^[a-f0-9]{64}$/),ir=d.strictObject({schemaVersion:d.literal("openpond.artifact.v1"),sha256:Nn,sizeBytes:d.number().int().nonnegative().safe(),createdAt:d.string().datetime()}),xi=`CREATE TABLE IF NOT EXISTS managed_artifact_objects (sha256 TEXT PRIMARY KEY, payload TEXT NOT NULL, orphaned_at TEXT);
27
27
  CREATE TABLE IF NOT EXISTS managed_artifact_references (domain TEXT NOT NULL, owner_id TEXT NOT NULL, sha256 TEXT NOT NULL REFERENCES managed_artifact_objects(sha256), payload TEXT NOT NULL, PRIMARY KEY(domain,owner_id));
28
28
  CREATE TABLE IF NOT EXISTS managed_artifact_pins (id TEXT PRIMARY KEY, sha256 TEXT NOT NULL REFERENCES managed_artifact_objects(sha256), owner_pid INTEGER NOT NULL, created_at TEXT NOT NULL);`,It=c((e,t)=>ve.join(e,"artifacts","objects",Nn.parse(t).slice(0,2),t),"artifactPath"),Lt=c(e=>ve.join(_(e).runtime,"artifacts"),"lockPath");function Ie(e,t){return he(e,r=>(r.exec(xi),t(r)))}c(Ie,"database");function pe(e){return new w({code:"ARTIFACT_UNAVAILABLE",path:e,message:"A referenced artifact is missing or failed its checksum.",action:"Restore the object from a verified backup. Its reference has been preserved."})}c(pe,"invalid");async function xn(e){let t=D(_(e).database,!0),r;try{if(!t.prepare("SELECT 1 FROM sqlite_master WHERE name='managed_artifact_references'").get())return;r=t.prepare("SELECT DISTINCT o.sha256,o.payload FROM managed_artifact_objects o JOIN managed_artifact_references r ON r.sha256=o.sha256").all()}finally{t.close()}for(let n of r){let o=It(e,n.sha256);try{let i=ir.parse(JSON.parse(n.payload)),a=ir.parse(JSON.parse(await j.readFile(`${o}.json`,"utf8"))),s=await j.lstat(o);if(!s.isFile()||i.sha256!==n.sha256||JSON.stringify(i)!==JSON.stringify(a)||s.size!==i.sizeBytes||await K(o)!==n.sha256)throw pe(o)}catch{throw pe(o)}}}c(xn,"validateManagedArtifacts");async function kn(e,t){if(!t.owner.id||t.owner.id.length>4096||/[\u0000-\u001f]/.test(t.displayName))throw new Error("Invalid artifact identity or display name.");return L(Lt(e),async()=>{let r=ve.join(e,"artifacts",".staging");await U(r);let n=ve.join(r,Cn());try{if("bytes"in t)await I(n,t.bytes);else{if(!(await j.lstat(t.sourceFile)).isFile())throw pe(t.sourceFile);await j.copyFile(t.sourceFile,n,j.constants.COPYFILE_EXCL);let m=await j.open(n,"r+");try{await m.sync()}finally{await m.close()}}let o=await K(n),i=(await j.stat(n)).size,a=It(e,o),s=`${a}.json`,l=new Date().toISOString();await U(ve.dirname(a));let p=await j.lstat(a).catch(m=>{if(R(m))return null;throw m});if(p){if(!p.isFile()||await K(a)!==o)throw pe(a)}else process.platform!=="win32"&&await j.chmod(n,256),await j.rename(n,a);let f;try{f=ir.parse(JSON.parse(await j.readFile(s,"utf8")))}catch(m){if(!R(m))throw pe(s);f={schemaVersion:"openpond.artifact.v1",sha256:o,sizeBytes:i,createdAt:l},await I(s,JSON.stringify(f))}if(f.sha256!==o||f.sizeBytes!==i)throw pe(s);let g={owner:t.owner,sha256:o,sizeBytes:i,displayName:t.displayName,mediaType:t.mediaType,createdAt:l};return Ie(e,m=>{m.exec("BEGIN IMMEDIATE");try{let h=m.prepare("SELECT sha256 FROM managed_artifact_references WHERE domain=? AND owner_id=?").get(t.owner.domain,t.owner.id);if(h&&h.sha256!==o)throw new w({code:"IMMUTABLE_ARTIFACT_CONFLICT",path:t.owner.id,message:"This artifact identity already refers to different bytes.",action:"Create a new artifact revision instead of replacing immutable content."});m.prepare("INSERT INTO managed_artifact_objects VALUES (?, ?, NULL) ON CONFLICT(sha256) DO UPDATE SET orphaned_at=NULL").run(o,JSON.stringify(f)),m.prepare("INSERT INTO managed_artifact_references VALUES (?, ?, ?, ?) ON CONFLICT(domain,owner_id) DO NOTHING").run(t.owner.domain,t.owner.id,o,JSON.stringify(g)),m.exec("COMMIT")}catch(h){throw m.exec("ROLLBACK"),h}}),{...g,path:a}}finally{await j.rm(n,{force:!0})}})}c(kn,"publishManagedArtifact");function ki(e,t){return Ie(e,r=>{let n=r.prepare("SELECT payload FROM managed_artifact_references WHERE domain=? AND owner_id=?").get(t.domain,t.id);return n?JSON.parse(n.payload):null})}c(ki,"artifactReference");async function Vc(e,t,r){let n=Cn(),o=await L(Lt(e),async()=>{let i=ki(e,t);if(!i)throw pe(t.id);return Ie(e,a=>{a.prepare("INSERT INTO managed_artifact_pins VALUES (?, ?, ?, ?)").run(n,i.sha256,process.pid,new Date().toISOString())}),i});try{let i=It(e,o.sha256),a=await j.lstat(i).catch(()=>null);if(!a?.isFile()||a.size!==o.sizeBytes||await K(i)!==o.sha256)throw pe(i);return await r(i,o)}finally{Ie(e,i=>{i.prepare("DELETE FROM managed_artifact_pins WHERE id=?").run(n)})}}c(Vc,"withManagedArtifact");async function Gc(e,t){await L(Lt(e),async()=>{Ie(e,r=>{r.exec("BEGIN IMMEDIATE");try{r.prepare("DELETE FROM managed_artifact_references WHERE domain=? AND owner_id=?").run(t.domain,t.id),r.prepare("UPDATE managed_artifact_objects SET orphaned_at=coalesce(orphaned_at,?) WHERE sha256 NOT IN (SELECT sha256 FROM managed_artifact_references)").run(new Date().toISOString()),r.exec("COMMIT")}catch(n){throw r.exec("ROLLBACK"),n}})})}c(Gc,"releaseArtifactReference");async function Kc(e){return L(Lt(e),async()=>{let t=Date.now()-6048e5,r=Ie(e,i=>{let a=i.prepare("PRAGMA integrity_check").all();if(a.length!==1||Object.values(a[0])[0]!=="ok"||i.prepare("PRAGMA foreign_key_check").all().length)throw pe(_(e).database);return new Set(i.prepare("SELECT sha256 FROM managed_artifact_references UNION SELECT sha256 FROM managed_artifact_pins UNION SELECT sha256 FROM managed_artifact_objects WHERE orphaned_at IS NULL OR orphaned_at >= ?").all(new Date(t).toISOString()).map(s=>s.sha256))}),n=ve.join(e,"artifacts","objects"),o=[];for(let i of await j.readdir(n,{withFileTypes:!0}).catch(a=>{if(R(a))return[];throw a}))if(!(!i.isDirectory()||!/^[a-f0-9]{2}$/.test(i.name)))for(let a of await j.readdir(ve.join(n,i.name))){if(!/^[a-f0-9]{64}$/.test(a)||!a.startsWith(i.name)||r.has(a))continue;let s=It(e,a),l=await j.lstat(s);!l.isFile()||l.mtimeMs>=t||(await j.rm(s),await j.rm(`${s}.json`,{force:!0}),Ie(e,p=>{p.prepare("DELETE FROM managed_artifact_objects WHERE sha256=?").run(a)}),o.push(a))}return{removed:o}})}c(Kc,"collectArtifactOrphans");var Ot=d.array(d.strictObject({path:d.array(d.string().min(1)).min(1),choice:d.enum(["imported","existing"])})).max(1e4);async function Rn(e,t,r=[]){let n=await O(e),o=await O(t),i=ie(n.document,o.document),a=Ot.parse(r),s=new Map(a.map(f=>[JSON.stringify(f.path),f.choice])),l=i.filter(f=>!s.has(JSON.stringify(f.path)));if(l.length)throw new w({code:"MIGRATION_CONFLICT",path:n.path,message:`Existing configuration conflicts with ${l.length} imported fields: ${l.map(f=>JSON.stringify(f.path)).join(", ")}.`,action:"Preview the migration, choose imported or existing for each conflicting field, and supply the resolution map. Both source versions remain preserved."});let p=ze(await S(n.path)??`schema_version = 1
29
- `,i.filter(f=>s.get(JSON.stringify(f.path))==="imported"),n.path);ne(te(p,n.path).value),await I(o.path,p)}c(Rn,"resolveMigrationTarget");import{createHash as Pn}from"node:crypto";import Ri from"node:path";var ar=d.strictObject({conversations:d.record(d.string(),d.strictObject({activeTabId:d.string().nullable(),tabs:d.array(d.strictObject({id:d.string().min(1),url:d.string(),title:d.string().nullable(),faviconUrl:d.string().nullable(),lastUpdatedAt:d.number().finite()}))}))});async function Mn(e,t){await L(Ri.join(_(e).runtime,"browser-metadata-import"),async()=>{let r=await S(t);if(r===null)return;let n=ar.safeParse(JSON.parse(r));if(!n.success)throw new w({code:"MIGRATION_CONFLICT",path:t,message:"Native browser tab metadata has an unsupported structure.",action:"Preserve this file and resolve the metadata format before retrying."});let o=`browser-import:${Pn("sha256").update(t).digest("hex")}`;he(e,i=>{i.exec("BEGIN IMMEDIATE");try{if(!i.prepare("SELECT 1 FROM client_preferences WHERE id=?").get(o)){for(let[a,s]of Object.entries(n.data.conversations))i.prepare("INSERT INTO browser_tab_state VALUES (?, ?, 1) ON CONFLICT(id) DO NOTHING").run(a,JSON.stringify(s));i.prepare("INSERT INTO client_preferences VALUES (?, ?, 1)").run(o,JSON.stringify({schemaVersion:"openpond.browserMetadataImport.v1",source:t,hash:Pn("sha256").update(r).digest("hex"),importedAt:new Date().toISOString()}))}i.exec("COMMIT")}catch(a){throw i.exec("ROLLBACK"),a}})})}c(Mn,"importBrowserMetadataOnce");import{randomUUID as fr}from"node:crypto";import{existsSync as le,promises as P}from"node:fs";import b from"node:path";import{backup as Hi}from"node:sqlite";import{createDecipheriv as Ui,createHash as cr}from"node:crypto";import{promises as dr}from"node:fs";import ee from"node:path";function sr(e,t){throw new w({code:"MIGRATION_CONFLICT",path:e,message:t,action:"Resolve this source field and restart failed migration preparation. Its original backup is retained."})}c(sr,"conflict");function Ye(e,t,r,n=[]){if(!(!e||typeof e!="object"||!t||typeof t!="object")){if(Array.isArray(e)&&Array.isArray(t)){e.forEach((o,i)=>Ye(o,t[i],r,[...n,String(i)]));return}for(let[o,i]of Object.entries(e))Object.hasOwn(t,o)||sr(r,`Unmapped stored field: ${[...n,o].join(".")}`),Ye(i,t[o],r,[...n,o])}}c(Ye,"assertNoUnmappedFields");var Pi=d.strictObject({token:d.string().optional(),appId:d.string().nullable().optional(),conversationId:d.string().nullable().optional()}),Mi=d.strictObject({handle:d.string().min(1),baseUrl:d.string().optional(),apiBaseUrl:d.string().optional(),chatApiBaseUrl:d.string().optional(),environment:d.string().optional(),apiKey:d.string().optional(),session:Pi.optional()});function Dn(e,t){if(e.accounts!==void 0){let r=d.array(Mi).safeParse(e.accounts);r.success||sr(t,`Invalid stored accounts: ${r.error.issues.map(n=>n.path.join(".")).join(", ")}`)}e.activeProfile!==void 0&&!d.strictObject({handle:d.string().min(1),baseUrl:d.string().nullable().optional()}).safeParse(e.activeProfile).success&&sr(t,"Invalid stored active account selector.")}c(Dn,"validateImportedAccounts");function Un(e,t){let r=Z.parse(e);Ye(e,r,t);let n=Di(e),o=Z.parse(n),i=o.defaultChatProvider==="codex"&&["codex-default","gpt-5.5"].includes(o.defaultChatModel);return{...o,defaultTeamId:o.defaultTeamId?.trim()||null,defaultNewProjectDirectory:_r(o.defaultNewProjectDirectory.trim()),...i?{defaultChatModel:Lr}:{},...i&&o.codexReasoningEffort==="medium"?{codexReasoningEffort:Or}:{}}}c(Un,"normalizeImportedPreferences");function Di(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e,r=t.subagents;if(!r||typeof r!="object"||Array.isArray(r))return e;let n=r,o=n.workspaceDefaultsVersion===1,i=n.toolDefaultsVersion===1;if(o&&i)return e;let a=Array.isArray(n.roles)?n.roles.map(s=>({...s,...!o&&s.isolationMode==="copy_on_write"?{isolationMode:"none"}:{},...i?{}:{toolPolicy:"full_tools"}})):n.roles;return{...t,subagents:{...n,workspaceDefaultsVersion:1,toolDefaultsVersion:1,maxConcurrentRunsPerWorkspaceTarget:!o&&n.maxConcurrentRunsPerWorkspaceTarget===2?1:n.maxConcurrentRunsPerWorkspaceTarget,...a===void 0?{}:{roles:a}}}}c(Di,"migrateSubagentDefaults");var ye=d.string().nullable().optional(),Fn=d.strictObject({version:d.literal(1),providers:d.record(d.string().min(1),d.strictObject({source:d.enum(["local_secret","env","chatgpt_subscription"]),envVar:ye,ciphertext:ye,iv:ye,tag:ye,createdAt:ye,updatedAt:ye,lastValidatedAt:ye,lastError:ye}))}),jn=d.strictObject({accessToken:d.string().nullable(),refreshToken:d.string().min(1),expiresAt:d.number().finite(),accountId:d.string().nullable()}),Bn=d.strictObject({version:d.literal(1),activeTemplateId:d.string(),updatedAt:d.string()}),$n=d.strictObject({schemaVersion:d.literal("openpond.datasetStorageSettings.v1"),datasetStorePath:d.string().min(1),updatedAt:d.string()});function C(e,t){return new w({code:"MIGRATION_CONFLICT",path:e,message:t,action:"Open migration details, resolve this conflict, and retry. The source installation has been preserved."})}c(C,"migrationConflict");async function Vn(e,t){if(!t)return;let r=await M(t,()=>({})),n=new Set(["accounts","activeProfile","openpondProfile","baseUrl","apiBaseUrl","chatApiBaseUrl","apiKey","token","appId","conversationId","lspEnabled","executionMode","mode"]);for(let a of Object.keys(r))if(!n.has(a))throw C(t,`Unmapped account configuration field: ${a}`);Dn(r,t);let o=r.accounts;if(o!==void 0&&!Array.isArray(o))throw C(t,"The account list is invalid.");!o?.length&&(r.apiKey||r.token||r.baseUrl)&&(o=[{handle:r.activeProfile?.handle??"default",...r,session:{token:r.token,appId:r.appId,conversationId:r.conversationId}}]);let i={...r,accounts:o};await An(e,()=>i)}c(Vn,"importAccountConfig");async function Gn(e,t){let r=_(e).database;if(!await dr.stat(r).catch(()=>null))return;let o=D(r),i=[];try{o.exec(Rr),o.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='cache_entries'").get()&&(i=o.prepare("SELECT type, cache_key, payload, updated_at, error FROM cache_entries").all())}finally{o.close()}for(let s of i){let l=JSON.parse(s.payload);if(s.type==="app_preferences"){let p=l;for(let m of Object.keys(p))if(!(m in Z.shape))throw C(r,`Unmapped preference field: ${m}`);let f=Un(l,r),g=(await O(e)).document;if(p.editor&&g.editor?.language_servers&&g.editor.language_servers!==f.editor.languageServers)throw C(r,"CLI language-server configuration conflicts with saved editor settings.");if(f.defaultChatModelRef&&(f.defaultChatModelRef.providerId!==f.defaultChatProvider||f.defaultChatModelRef.modelId!==f.defaultChatModel))throw C(r,"Saved model fields disagree; select which model should be retained.");await z(e,m=>yt(m,Ae(f))),$(e,"client_preferences","global",Tt(f))}else if(s.type==="local.projects"){if(!Array.isArray(l))throw C(r,"Saved projects must be an array.");for(let p of l){if(!p||typeof p.id!="string")throw C(r,"A saved project has no identity.");$(e,"saved_local_projects",p.id,p)}}else if(s.type==="codex_history.sidebar_preferences")$(e,"codex_sidebar_state",s.cache_key,l);else if(s.type==="personalization")$(e,"account_selection","imported_personality",l);else if(s.type==="openpond.scaffoldApps")$(e,"scaffold_registrations",s.cache_key,l);else if(["openpond.account","openpond.apps","openpond.cloudProjects","training.hosted-model-project-catalog.v1"].includes(s.type))await Yt(e,s.type,s.cache_key,l,{error:s.error});else throw C(r,`Unmapped cache namespace: ${s.type}`)}let a=D(r);try{i.length&&a.exec("DELETE FROM cache_entries"),a.exec("PRAGMA wal_checkpoint(TRUNCATE)")}finally{a.close()}}c(Gn,"importPreferenceRecords");async function Kn(e,t){if(!t)return;let r=ee.join(t,"providers.json"),n=await M(r,()=>({}));for(let m of Object.keys(n))if(!["version","providers","modelCaches","catalogCache","statuses","updatedAt"].includes(m))throw C(r,`Unmapped provider field: ${m}`);let o=Er.parse(n);Ye(Object.fromEntries(Object.entries(n).filter(([m])=>m!=="catalogCache")),o,r);let i={};for(let[m,h]of Object.entries(o.providers))i[m]={enabled:h.enabled,...h.baseUrl?{base_url:h.baseUrl}:{},...h.defaultModel?{default_model:h.defaultModel}:{},model_overrides:h.modelOverrides};await z(e,m=>({...m,providers:i})),await Yt(e,"providers","catalog",{modelCaches:o.modelCaches,catalogCache:n.catalogCache??null});let a=ee.join(t,"provider-secrets.json"),s=await M(a,()=>null);if(s===null)return;let l=Fn.safeParse(s);if(!l.success)throw C(a,"The provider vault has an unsupported version or field.");let p=l.data,f=await S(ee.join(t,"provider-secrets.key")),g=f?Buffer.from(f.trim(),"base64"):null;for(let[m,h]of Object.entries(p.providers)){let y=null,T=null;if(h.source!=="env"){if(!g||g.length!==32||!h.ciphertext||!h.iv||!h.tag)throw C(a,"The old provider credential cannot be decrypted with its saved key.");try{let E=Ui("aes-256-gcm",g,Buffer.from(String(h.iv),"base64"));E.setAuthTag(Buffer.from(String(h.tag),"base64")),y=Buffer.concat([E.update(Buffer.from(String(h.ciphertext),"base64")),E.final()]).toString("utf8"),h.source==="chatgpt_subscription"&&(T=jn.parse(JSON.parse(y)),y=null)}catch{throw C(a,"The saved provider credential failed integrity verification.")}}let A=`provider:${m}`,x={endpoint:i[m]?.base_url??null,source:h.source,value:y,oauth:T,envVar:h.envVar??null,createdAt:h.createdAt,updatedAt:h.updatedAt,lastValidatedAt:h.lastValidatedAt??null,lastError:h.lastError??null};await bt(e,A,x,null),await z(e,E=>({...E,providers:{...E.providers,[m]:{...E.providers?.[m],credential:h.source==="env"?{source:"env",name:String(h.envVar)}:{source:"secret",id:A}}}}))}}c(Kn,"importProviderConfig");async function Hn(e,t){if(!t)return;let r=new Map;for(let h of[t,ee.join(t,"souls")]){let y=await dr.readdir(h,{withFileTypes:!0}).catch(()=>[]);for(let T of y){if(!T.isFile()||!(h===t?/^soul-.+\.md$/i:/\.md$/i).test(T.name))continue;let A=await dr.readFile(ee.join(h,T.name),"utf8"),x=`imported-${cr("sha256").update(A).digest("hex").slice(0,16)}`;await lr(e,x,A),r.set(`file:${ee.relative(t,ee.join(h,T.name)).split(ee.sep).join("/")}`,{id:x,content:A})}}let n=await S(ee.join(t,"SOUL.md")),o=ee.join(t,"personalization.json"),i=await M(o,()=>null),a=i===null?null:Bn.safeParse(i);if(a&&!a.success)throw C(o,"Personalization has an unsupported version or field.");let s=a?.success?a.data:{},{getLocalRecord:l}=await import("./database-5LDQO3YA.js"),p=l(e,"account_selection","imported_personality")?.value??s.activeTemplateId??"default",f=r.get(p),g=it.find(h=>h.id===p),m=f?`custom:${f.id}`:g?`builtin:${g.id}`:"builtin:default";if(n?.trim()&&!f&&!g){let h=`imported-${cr("sha256").update(n).digest("hex").slice(0,16)}`;await lr(e,h,n),m=`custom:${h}`}else if(n?.trim()&&n.trim()!==(f?.content??g?.content)?.trim()){let h=`preserved-${cr("sha256").update(n).digest("hex").slice(0,16)}`;await lr(e,h,n)}await z(e,h=>({...h,personalization:{...h.personalization,active:m}}))}c(Hn,"importPersonalization");async function Jn(e,t){if(!t)return;let r=ee.join(t,"datasets","settings.json"),n=await M(r,()=>null),o=n===null?null:$n.safeParse(n);if(o&&!o.success)throw C(r,"Dataset settings have an unsupported version or field.");let i=o?.success?o.data:{};i.datasetStorePath&&await z(e,a=>({...a,storage:{...a.storage,datasets_dir:i.datasetStorePath}})),ne((await O(e)).document)}c(Jn,"importDatasetPreference");async function lr(e,t,r){await I(ee.join(e,"instructions","imported-originals",`${t}.md`),r),await I(ee.join(e,"instructions","personalities",`${t}.md`),r.trim().slice(0,8e3))}c(lr,"preserveImportedPersonality");import{execFile as Fi}from"node:child_process";import{promisify as ji}from"node:util";import{existsSync as Ct,promises as Ze}from"node:fs";import zn from"node:os";import W from"node:path";var Wn=ji(Fi);async function Xn(e,t){let r=e===W.join(zn.homedir(),".openpond-nightly"),n=W.join(zn.homedir(),".openpond"),o=["openpond-app-dev","openpond-app-nightly-dev"].some(g=>e===W.join(n,g)),i=r||o?n:e,a=(o?[e]:[e,W.join(i,r?"openpond-app-nightly":"openpond-app")]).filter(g=>Ct(W.join(g,"state.sqlite"))||Ct(W.join(g,"providers.json"))),s=[...new Set([W.join(i,"config.json"),W.join(e,"config","config.json")])].filter(Ct),l=[];!t.sourceAppHome&&a.length>1&&l.push({code:"AMBIGUOUS_APP_HOME",message:"Select the previous app home with --source-app-home.",paths:a}),!t.sourceConfig&&s.length>1&&l.push({code:"AMBIGUOUS_CONFIG",message:"Select the previous account configuration with --source-config.",paths:s});let p=t.sourceAppHome?W.resolve(t.sourceAppHome):a.length===1?a[0]:void 0,f=t.sourceConfig?W.resolve(t.sourceConfig):s.length===1?s[0]:void 0;for(let g of[p,f,t.sourceBrowserState])if(g&&!Ct(g))throw new w({code:"MIGRATION_SOURCE_MISSING",path:g,message:"The selected migration source is unavailable.",action:"Correct the source path before retrying."});return{...p?{sourceAppHome:p}:{},...f?{sourceConfig:f}:{},...t.sourceBrowserState?{sourceBrowserState:W.resolve(t.sourceBrowserState)}:{},issues:l,sourceCandidates:{appHomes:a,configs:s}}}c(Xn,"discoverMigrationSources");async function et(e,t){let r=[e?W.join(e,"state.sqlite"):null,t].filter(o=>!!o);if(!r.length)return;let n=c(()=>new w({code:"MIGRATION_SOURCE_BUSY",path:e??t,message:"A previous OpenPond process is still using the source installation.",action:"Close that installation and retry. No migration source has been changed."}),"fail");if(process.platform==="linux"){for(let o of await Ze.readdir("/proc"))if(!(!/^\d+$/.test(o)||Number(o)===process.pid))try{let i=`/proc/${o}/fd`;for(let a of await Ze.readdir(i)){let s=await Ze.readlink(W.join(i,a)).catch(l=>{if(R(l))return"";throw l});if(r.some(l=>s===l||s===`${l}-wal`||s===`${l}-shm`))throw n()}}catch(i){if(i instanceof w)throw i;if(R(i))continue;if(["EACCES","EPERM"].includes(i.code??"")){let a=await Ze.stat(`/proc/${o}`).catch(s=>{if(R(s))return null;throw s});if(a&&a.uid===process.getuid?.()){let s=await Ze.readFile(`/proc/${o}/cmdline`,"utf8").catch(f=>{if(R(f))return"";throw f}),l=W.basename(s.split("\0")[0]??"");if(/^(?:node|electron|openpond(?:-code)?)(?:\.exe)?$/i.test(l)&&!s.includes("--type=")||r.some(f=>s.includes(f)))throw new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"A possible previous runtime could not be inspected for open migration sources.",action:"Close the previous OpenPond processes and retry with process inspection available."})}}else throw i}return}if(process.platform==="darwin"){try{if((await Wn("/usr/sbin/lsof",["-F","p","--",...r],{maxBuffer:1e6})).stdout.split(`
30
- `).some(i=>/^p\d+$/.test(i)&&Number(i.slice(1))!==process.pid))throw n()}catch(o){if(o instanceof w)throw o;if(o.code!==1)throw new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"OpenPond could not verify that the previous installation is stopped.",action:"Ensure lsof is available, close the previous app and retry."})}return}if(process.platform==="win32"){let o="Get-CimInstance Win32_Process | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress";try{let{stdout:i}=await Wn("powershell.exe",["-NoProfile","-NonInteractive","-Command",o],{maxBuffer:4e6,env:yr()}),a=JSON.parse(i),s=Array.isArray(a)?a:[a];for(let l of s)if(!(!l.CommandLine||l.ProcessId===process.pid)&&/(?:openpond|apps[\\/]server).*(?:serve|server|desktop)/i.test(l.CommandLine)&&(r.some(p=>l.CommandLine.includes(p))||e&&l.CommandLine.includes(e)))throw n()}catch(i){throw i instanceof w?i:new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"OpenPond could not inspect previous runtime ownership.",action:"Close the previous app and enable local process inspection before retrying."})}return}throw new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"Automatic migration ownership checks are unavailable on this platform.",action:"Migrate this installation on a supported desktop platform."})}c(et,"assertMigrationSourcesStopped");import{randomUUID as Bi}from"node:crypto";import{promises as X}from"node:fs";import q from"node:path";var qn=d.string().min(1).refine(e=>!q.isAbsolute(e)&&!/^[A-Za-z]:/.test(e)&&!e.split(/[\\/]/).some(t=>!t||t==="."||t==="..")),$i=d.strictObject({path:qn,sha256:d.string().regex(/^[a-f0-9]{64}$/),executable:d.boolean().optional()}),Qn=d.strictObject({schemaVersion:d.literal("openpond.migration.v1"),id:d.string().regex(/^migration-[A-Za-z0-9-]+$/),status:d.enum(["preparing","prepared","installing","committed","verified","failed"]),home:d.string(),stage:d.string(),backup:d.string(),files:d.array($i),installed:d.array(qn),sourceAppHome:d.string().optional(),sourceConfig:d.string().optional(),sourceBrowserState:d.string().optional(),resolutions:Ot.optional(),snapshotComplete:d.boolean().optional(),error:d.string().optional(),createdAt:d.string()}),Nt={schemaVersion:"openpond.storage.v1",version:1};async function Re(e){let t=q.join(_(e).runtime,"migration.json"),r=await M(t,()=>null);if(r===null)return null;let n=Qn.safeParse(r);if(!n.success)throw ur(t);let o=n.data,i=q.resolve(e);if(o.home!==i||o.stage!==q.join(q.dirname(i),`.${q.basename(i)}-${o.id}`)||o.backup!==q.join(i,"backups",o.id))throw ur(t);let a=new Set(o.files.map(s=>s.path));if(a.size!==o.files.length||o.installed.some(s=>!a.has(s))||o.files.some(s=>/^(runtime|backups)([\\/]|$)/.test(s.path)||s.path==="storage.json"))throw ur(t);return o}c(Re,"readMigrationJournal");function ur(e){return new w({code:"INVALID_MIGRATION_JOURNAL",path:e,message:"The migration journal could not be verified.",action:"Preserve the journal and backups. Restore a verified backup into a separate home."})}c(ur,"invalidJournal");async function ce(e){Qn.parse(e),await I(q.join(_(e.home).runtime,"migration.json"),`${JSON.stringify(e,null,2)}
29
+ `,i.filter(f=>s.get(JSON.stringify(f.path))==="imported"),n.path);ne(te(p,n.path).value),await I(o.path,p)}c(Rn,"resolveMigrationTarget");import{createHash as Pn}from"node:crypto";import Ri from"node:path";var ar=d.strictObject({conversations:d.record(d.string(),d.strictObject({activeTabId:d.string().nullable(),tabs:d.array(d.strictObject({id:d.string().min(1),url:d.string(),title:d.string().nullable(),faviconUrl:d.string().nullable(),lastUpdatedAt:d.number().finite()}))}))});async function Mn(e,t){await L(Ri.join(_(e).runtime,"browser-metadata-import"),async()=>{let r=await S(t);if(r===null)return;let n=ar.safeParse(JSON.parse(r));if(!n.success)throw new w({code:"MIGRATION_CONFLICT",path:t,message:"Native browser tab metadata has an unsupported structure.",action:"Preserve this file and resolve the metadata format before retrying."});let o=`browser-import:${Pn("sha256").update(t).digest("hex")}`;he(e,i=>{i.exec("BEGIN IMMEDIATE");try{if(!i.prepare("SELECT 1 FROM client_preferences WHERE id=?").get(o)){for(let[a,s]of Object.entries(n.data.conversations))i.prepare("INSERT INTO browser_tab_state VALUES (?, ?, 1) ON CONFLICT(id) DO NOTHING").run(a,JSON.stringify(s));i.prepare("INSERT INTO client_preferences VALUES (?, ?, 1)").run(o,JSON.stringify({schemaVersion:"openpond.browserMetadataImport.v1",source:t,hash:Pn("sha256").update(r).digest("hex"),importedAt:new Date().toISOString()}))}i.exec("COMMIT")}catch(a){throw i.exec("ROLLBACK"),a}})})}c(Mn,"importBrowserMetadataOnce");import{randomUUID as fr}from"node:crypto";import{existsSync as le,promises as P}from"node:fs";import b from"node:path";import{backup as Hi}from"node:sqlite";import{createDecipheriv as Ui,createHash as cr}from"node:crypto";import{promises as dr}from"node:fs";import ee from"node:path";function sr(e,t){throw new w({code:"MIGRATION_CONFLICT",path:e,message:t,action:"Resolve this source field and restart failed migration preparation. Its original backup is retained."})}c(sr,"conflict");function Ye(e,t,r,n=[]){if(!(!e||typeof e!="object"||!t||typeof t!="object")){if(Array.isArray(e)&&Array.isArray(t)){e.forEach((o,i)=>Ye(o,t[i],r,[...n,String(i)]));return}for(let[o,i]of Object.entries(e))Object.hasOwn(t,o)||sr(r,`Unmapped stored field: ${[...n,o].join(".")}`),Ye(i,t[o],r,[...n,o])}}c(Ye,"assertNoUnmappedFields");var Pi=d.strictObject({token:d.string().optional(),appId:d.string().nullable().optional(),conversationId:d.string().nullable().optional()}),Mi=d.strictObject({handle:d.string().min(1),baseUrl:d.string().optional(),apiBaseUrl:d.string().optional(),chatApiBaseUrl:d.string().optional(),environment:d.string().optional(),apiKey:d.string().optional(),session:Pi.optional()});function Dn(e,t){if(e.accounts!==void 0){let r=d.array(Mi).safeParse(e.accounts);r.success||sr(t,`Invalid stored accounts: ${r.error.issues.map(n=>n.path.join(".")).join(", ")}`)}e.activeProfile!==void 0&&!d.strictObject({handle:d.string().min(1),baseUrl:d.string().nullable().optional()}).safeParse(e.activeProfile).success&&sr(t,"Invalid stored active account selector.")}c(Dn,"validateImportedAccounts");function Un(e,t){let r=Z.parse(e);Ye(e,r,t);let n=Di(e),o=Z.parse(n),i=o.defaultChatProvider==="codex"&&["codex-default","gpt-5.5"].includes(o.defaultChatModel);return{...o,defaultTeamId:o.defaultTeamId?.trim()||null,defaultNewProjectDirectory:yr(o.defaultNewProjectDirectory.trim()),...i?{defaultChatModel:Lr}:{},...i&&o.codexReasoningEffort==="medium"?{codexReasoningEffort:Or}:{}}}c(Un,"normalizeImportedPreferences");function Di(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e,r=t.subagents;if(!r||typeof r!="object"||Array.isArray(r))return e;let n=r,o=n.workspaceDefaultsVersion===1,i=n.toolDefaultsVersion===1;if(o&&i)return e;let a=Array.isArray(n.roles)?n.roles.map(s=>({...s,...!o&&s.isolationMode==="copy_on_write"?{isolationMode:"none"}:{},...i?{}:{toolPolicy:"full_tools"}})):n.roles;return{...t,subagents:{...n,workspaceDefaultsVersion:1,toolDefaultsVersion:1,maxConcurrentRunsPerWorkspaceTarget:!o&&n.maxConcurrentRunsPerWorkspaceTarget===2?1:n.maxConcurrentRunsPerWorkspaceTarget,...a===void 0?{}:{roles:a}}}}c(Di,"migrateSubagentDefaults");var ye=d.string().nullable().optional(),Fn=d.strictObject({version:d.literal(1),providers:d.record(d.string().min(1),d.strictObject({source:d.enum(["local_secret","env","chatgpt_subscription"]),envVar:ye,ciphertext:ye,iv:ye,tag:ye,createdAt:ye,updatedAt:ye,lastValidatedAt:ye,lastError:ye}))}),jn=d.strictObject({accessToken:d.string().nullable(),refreshToken:d.string().min(1),expiresAt:d.number().finite(),accountId:d.string().nullable()}),Bn=d.strictObject({version:d.literal(1),activeTemplateId:d.string(),updatedAt:d.string()}),$n=d.strictObject({schemaVersion:d.literal("openpond.datasetStorageSettings.v1"),datasetStorePath:d.string().min(1),updatedAt:d.string()});function C(e,t){return new w({code:"MIGRATION_CONFLICT",path:e,message:t,action:"Open migration details, resolve this conflict, and retry. The source installation has been preserved."})}c(C,"migrationConflict");async function Vn(e,t){if(!t)return;let r=await M(t,()=>({})),n=new Set(["accounts","activeProfile","openpondProfile","baseUrl","apiBaseUrl","chatApiBaseUrl","apiKey","token","appId","conversationId","lspEnabled","executionMode","mode"]);for(let a of Object.keys(r))if(!n.has(a))throw C(t,`Unmapped account configuration field: ${a}`);Dn(r,t);let o=r.accounts;if(o!==void 0&&!Array.isArray(o))throw C(t,"The account list is invalid.");!o?.length&&(r.apiKey||r.token||r.baseUrl)&&(o=[{handle:r.activeProfile?.handle??"default",...r,session:{token:r.token,appId:r.appId,conversationId:r.conversationId}}]);let i={...r,accounts:o};await An(e,()=>i)}c(Vn,"importAccountConfig");async function Gn(e,t){let r=_(e).database;if(!await dr.stat(r).catch(()=>null))return;let o=D(r),i=[];try{o.exec(Rr),o.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='cache_entries'").get()&&(i=o.prepare("SELECT type, cache_key, payload, updated_at, error FROM cache_entries").all())}finally{o.close()}for(let s of i){let l=JSON.parse(s.payload);if(s.type==="app_preferences"){let p=l;for(let m of Object.keys(p))if(!(m in Z.shape))throw C(r,`Unmapped preference field: ${m}`);let f=Un(l,r),g=(await O(e)).document;if(p.editor&&g.editor?.language_servers&&g.editor.language_servers!==f.editor.languageServers)throw C(r,"CLI language-server configuration conflicts with saved editor settings.");if(f.defaultChatModelRef&&(f.defaultChatModelRef.providerId!==f.defaultChatProvider||f.defaultChatModelRef.modelId!==f.defaultChatModel))throw C(r,"Saved model fields disagree; select which model should be retained.");await z(e,m=>yt(m,Ae(f))),$(e,"client_preferences","global",Tt(f))}else if(s.type==="local.projects"){if(!Array.isArray(l))throw C(r,"Saved projects must be an array.");for(let p of l){if(!p||typeof p.id!="string")throw C(r,"A saved project has no identity.");$(e,"saved_local_projects",p.id,p)}}else if(s.type==="codex_history.sidebar_preferences")$(e,"codex_sidebar_state",s.cache_key,l);else if(s.type==="personalization")$(e,"account_selection","imported_personality",l);else if(s.type==="openpond.scaffoldApps")$(e,"scaffold_registrations",s.cache_key,l);else if(["openpond.account","openpond.apps","openpond.cloudProjects","training.hosted-model-project-catalog.v1"].includes(s.type))await Yt(e,s.type,s.cache_key,l,{error:s.error});else throw C(r,`Unmapped cache namespace: ${s.type}`)}let a=D(r);try{i.length&&a.exec("DELETE FROM cache_entries"),a.exec("PRAGMA wal_checkpoint(TRUNCATE)")}finally{a.close()}}c(Gn,"importPreferenceRecords");async function Kn(e,t){if(!t)return;let r=ee.join(t,"providers.json"),n=await M(r,()=>({}));for(let m of Object.keys(n))if(!["version","providers","modelCaches","catalogCache","statuses","updatedAt"].includes(m))throw C(r,`Unmapped provider field: ${m}`);let o=Er.parse(n);Ye(Object.fromEntries(Object.entries(n).filter(([m])=>m!=="catalogCache")),o,r);let i={};for(let[m,h]of Object.entries(o.providers))i[m]={enabled:h.enabled,...h.baseUrl?{base_url:h.baseUrl}:{},...h.defaultModel?{default_model:h.defaultModel}:{},model_overrides:h.modelOverrides};await z(e,m=>({...m,providers:i})),await Yt(e,"providers","catalog",{modelCaches:o.modelCaches,catalogCache:n.catalogCache??null});let a=ee.join(t,"provider-secrets.json"),s=await M(a,()=>null);if(s===null)return;let l=Fn.safeParse(s);if(!l.success)throw C(a,"The provider vault has an unsupported version or field.");let p=l.data,f=await S(ee.join(t,"provider-secrets.key")),g=f?Buffer.from(f.trim(),"base64"):null;for(let[m,h]of Object.entries(p.providers)){let y=null,T=null;if(h.source!=="env"){if(!g||g.length!==32||!h.ciphertext||!h.iv||!h.tag)throw C(a,"The old provider credential cannot be decrypted with its saved key.");try{let E=Ui("aes-256-gcm",g,Buffer.from(String(h.iv),"base64"));E.setAuthTag(Buffer.from(String(h.tag),"base64")),y=Buffer.concat([E.update(Buffer.from(String(h.ciphertext),"base64")),E.final()]).toString("utf8"),h.source==="chatgpt_subscription"&&(T=jn.parse(JSON.parse(y)),y=null)}catch{throw C(a,"The saved provider credential failed integrity verification.")}}let A=`provider:${m}`,x={endpoint:i[m]?.base_url??null,source:h.source,value:y,oauth:T,envVar:h.envVar??null,createdAt:h.createdAt,updatedAt:h.updatedAt,lastValidatedAt:h.lastValidatedAt??null,lastError:h.lastError??null};await bt(e,A,x,null),await z(e,E=>({...E,providers:{...E.providers,[m]:{...E.providers?.[m],credential:h.source==="env"?{source:"env",name:String(h.envVar)}:{source:"secret",id:A}}}}))}}c(Kn,"importProviderConfig");async function Hn(e,t){if(!t)return;let r=new Map;for(let h of[t,ee.join(t,"souls")]){let y=await dr.readdir(h,{withFileTypes:!0}).catch(()=>[]);for(let T of y){if(!T.isFile()||!(h===t?/^soul-.+\.md$/i:/\.md$/i).test(T.name))continue;let A=await dr.readFile(ee.join(h,T.name),"utf8"),x=`imported-${cr("sha256").update(A).digest("hex").slice(0,16)}`;await lr(e,x,A),r.set(`file:${ee.relative(t,ee.join(h,T.name)).split(ee.sep).join("/")}`,{id:x,content:A})}}let n=await S(ee.join(t,"SOUL.md")),o=ee.join(t,"personalization.json"),i=await M(o,()=>null),a=i===null?null:Bn.safeParse(i);if(a&&!a.success)throw C(o,"Personalization has an unsupported version or field.");let s=a?.success?a.data:{},{getLocalRecord:l}=await import("./database-5LDQO3YA.js"),p=l(e,"account_selection","imported_personality")?.value??s.activeTemplateId??"default",f=r.get(p),g=it.find(h=>h.id===p),m=f?`custom:${f.id}`:g?`builtin:${g.id}`:"builtin:default";if(n?.trim()&&!f&&!g){let h=`imported-${cr("sha256").update(n).digest("hex").slice(0,16)}`;await lr(e,h,n),m=`custom:${h}`}else if(n?.trim()&&n.trim()!==(f?.content??g?.content)?.trim()){let h=`preserved-${cr("sha256").update(n).digest("hex").slice(0,16)}`;await lr(e,h,n)}await z(e,h=>({...h,personalization:{...h.personalization,active:m}}))}c(Hn,"importPersonalization");async function Jn(e,t){if(!t)return;let r=ee.join(t,"datasets","settings.json"),n=await M(r,()=>null),o=n===null?null:$n.safeParse(n);if(o&&!o.success)throw C(r,"Dataset settings have an unsupported version or field.");let i=o?.success?o.data:{};i.datasetStorePath&&await z(e,a=>({...a,storage:{...a.storage,datasets_dir:i.datasetStorePath}})),ne((await O(e)).document)}c(Jn,"importDatasetPreference");async function lr(e,t,r){await I(ee.join(e,"instructions","imported-originals",`${t}.md`),r),await I(ee.join(e,"instructions","personalities",`${t}.md`),r.trim().slice(0,8e3))}c(lr,"preserveImportedPersonality");import{execFile as Fi}from"node:child_process";import{promisify as ji}from"node:util";import{existsSync as Ct,promises as Ze}from"node:fs";import zn from"node:os";import W from"node:path";var Wn=ji(Fi);async function Xn(e,t){let r=e===W.join(zn.homedir(),".openpond-nightly"),n=W.join(zn.homedir(),".openpond"),o=["openpond-app-dev","openpond-app-nightly-dev"].some(g=>e===W.join(n,g)),i=r||o?n:e,a=(o?[e]:[e,W.join(i,r?"openpond-app-nightly":"openpond-app")]).filter(g=>Ct(W.join(g,"state.sqlite"))||Ct(W.join(g,"providers.json"))),s=[...new Set([W.join(i,"config.json"),W.join(e,"config","config.json")])].filter(Ct),l=[];!t.sourceAppHome&&a.length>1&&l.push({code:"AMBIGUOUS_APP_HOME",message:"Select the previous app home with --source-app-home.",paths:a}),!t.sourceConfig&&s.length>1&&l.push({code:"AMBIGUOUS_CONFIG",message:"Select the previous account configuration with --source-config.",paths:s});let p=t.sourceAppHome?W.resolve(t.sourceAppHome):a.length===1?a[0]:void 0,f=t.sourceConfig?W.resolve(t.sourceConfig):s.length===1?s[0]:void 0;for(let g of[p,f,t.sourceBrowserState])if(g&&!Ct(g))throw new w({code:"MIGRATION_SOURCE_MISSING",path:g,message:"The selected migration source is unavailable.",action:"Correct the source path before retrying."});return{...p?{sourceAppHome:p}:{},...f?{sourceConfig:f}:{},...t.sourceBrowserState?{sourceBrowserState:W.resolve(t.sourceBrowserState)}:{},issues:l,sourceCandidates:{appHomes:a,configs:s}}}c(Xn,"discoverMigrationSources");async function et(e,t){let r=[e?W.join(e,"state.sqlite"):null,t].filter(o=>!!o);if(!r.length)return;let n=c(()=>new w({code:"MIGRATION_SOURCE_BUSY",path:e??t,message:"A previous OpenPond process is still using the source installation.",action:"Close that installation and retry. No migration source has been changed."}),"fail");if(process.platform==="linux"){for(let o of await Ze.readdir("/proc"))if(!(!/^\d+$/.test(o)||Number(o)===process.pid))try{let i=`/proc/${o}/fd`;for(let a of await Ze.readdir(i)){let s=await Ze.readlink(W.join(i,a)).catch(l=>{if(R(l))return"";throw l});if(r.some(l=>s===l||s===`${l}-wal`||s===`${l}-shm`))throw n()}}catch(i){if(i instanceof w)throw i;if(R(i))continue;if(["EACCES","EPERM"].includes(i.code??"")){let a=await Ze.stat(`/proc/${o}`).catch(s=>{if(R(s))return null;throw s});if(a&&a.uid===process.getuid?.()){let s=await Ze.readFile(`/proc/${o}/cmdline`,"utf8").catch(f=>{if(R(f))return"";throw f}),l=W.basename(s.split("\0")[0]??"");if(/^(?:node|electron|openpond(?:-code)?)(?:\.exe)?$/i.test(l)&&!s.includes("--type=")||r.some(f=>s.includes(f)))throw new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"A possible previous runtime could not be inspected for open migration sources.",action:"Close the previous OpenPond processes and retry with process inspection available."})}}else throw i}return}if(process.platform==="darwin"){try{if((await Wn("/usr/sbin/lsof",["-F","p","--",...r],{maxBuffer:1e6})).stdout.split(`
30
+ `).some(i=>/^p\d+$/.test(i)&&Number(i.slice(1))!==process.pid))throw n()}catch(o){if(o instanceof w)throw o;if(o.code!==1)throw new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"OpenPond could not verify that the previous installation is stopped.",action:"Ensure lsof is available, close the previous app and retry."})}return}if(process.platform==="win32"){let o="Get-CimInstance Win32_Process | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress";try{let{stdout:i}=await Wn("powershell.exe",["-NoProfile","-NonInteractive","-Command",o],{maxBuffer:4e6,env:wr()}),a=JSON.parse(i),s=Array.isArray(a)?a:[a];for(let l of s)if(!(!l.CommandLine||l.ProcessId===process.pid)&&/(?:openpond|apps[\\/]server).*(?:serve|server|desktop)/i.test(l.CommandLine)&&(r.some(p=>l.CommandLine.includes(p))||e&&l.CommandLine.includes(e)))throw n()}catch(i){throw i instanceof w?i:new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"OpenPond could not inspect previous runtime ownership.",action:"Close the previous app and enable local process inspection before retrying."})}return}throw new w({code:"MIGRATION_OWNERSHIP_UNVERIFIED",path:e??t,message:"Automatic migration ownership checks are unavailable on this platform.",action:"Migrate this installation on a supported desktop platform."})}c(et,"assertMigrationSourcesStopped");import{randomUUID as Bi}from"node:crypto";import{promises as X}from"node:fs";import q from"node:path";var qn=d.string().min(1).refine(e=>!q.isAbsolute(e)&&!/^[A-Za-z]:/.test(e)&&!e.split(/[\\/]/).some(t=>!t||t==="."||t==="..")),$i=d.strictObject({path:qn,sha256:d.string().regex(/^[a-f0-9]{64}$/),executable:d.boolean().optional()}),Qn=d.strictObject({schemaVersion:d.literal("openpond.migration.v1"),id:d.string().regex(/^migration-[A-Za-z0-9-]+$/),status:d.enum(["preparing","prepared","installing","committed","verified","failed"]),home:d.string(),stage:d.string(),backup:d.string(),files:d.array($i),installed:d.array(qn),sourceAppHome:d.string().optional(),sourceConfig:d.string().optional(),sourceBrowserState:d.string().optional(),resolutions:Ot.optional(),snapshotComplete:d.boolean().optional(),error:d.string().optional(),createdAt:d.string()}),Nt={schemaVersion:"openpond.storage.v1",version:1};async function Re(e){let t=q.join(_(e).runtime,"migration.json"),r=await M(t,()=>null);if(r===null)return null;let n=Qn.safeParse(r);if(!n.success)throw ur(t);let o=n.data,i=q.resolve(e);if(o.home!==i||o.stage!==q.join(q.dirname(i),`.${q.basename(i)}-${o.id}`)||o.backup!==q.join(i,"backups",o.id))throw ur(t);let a=new Set(o.files.map(s=>s.path));if(a.size!==o.files.length||o.installed.some(s=>!a.has(s))||o.files.some(s=>/^(runtime|backups)([\\/]|$)/.test(s.path)||s.path==="storage.json"))throw ur(t);return o}c(Re,"readMigrationJournal");function ur(e){return new w({code:"INVALID_MIGRATION_JOURNAL",path:e,message:"The migration journal could not be verified.",action:"Preserve the journal and backups. Restore a verified backup into a separate home."})}c(ur,"invalidJournal");async function ce(e){Qn.parse(e),await I(q.join(_(e.home).runtime,"migration.json"),`${JSON.stringify(e,null,2)}
31
31
  `)}c(ce,"saveMigrationJournal");async function tt(e,t=e){let r=[];for(let n of await X.readdir(t,{withFileTypes:!0})){let o=q.join(t,n.name);n.isDirectory()?r.push(...await tt(e,o)):r.push({path:q.relative(e,o),sha256:await K(o),executable:!!((await X.lstat(o)).mode&64)})}return r.sort((n,o)=>n.path.localeCompare(o.path))}c(tt,"fileReceipts");async function Q(e,t){let r=await X.lstat(e),n=await X.lstat(t).catch(o=>{if(R(o))return null;throw o});if(r.isDirectory()){if(n&&!n.isDirectory())throw new Error(`Backup path is not a directory: ${t}`);await U(t);for(let o of await X.readdir(e))await Q(q.join(e,o),q.join(t,o));return}if(n){if(await K(e)!==await K(t))throw new w({code:"SOURCE_CHANGED_DURING_MIGRATION",path:e,message:"A source file changed after its migration backup was created.",action:"Stop the old installation and review the preserved backup before retrying."});return}if(await U(q.dirname(t)),r.isSymbolicLink())await X.symlink(await X.readlink(e),t);else{let o=`${t}.${Bi()}.snapshot`;try{await X.copyFile(e,o,X.constants.COPYFILE_EXCL),await X.chmod(o,r.mode&64?448:384);let i=await X.open(o,"r+");try{await i.sync()}finally{await i.close()}if(await X.link(o,t),process.platform!=="win32"){let a=await X.open(q.dirname(t),"r");try{await a.sync()}finally{await a.close()}}}finally{await X.rm(o,{force:!0})}}}c(Q,"snapshotCopy");import{existsSync as Yn}from"node:fs";import Pe from"node:path";var Vi="CREATE TABLE IF NOT EXISTS storage_path_relocations (source TEXT PRIMARY KEY, destination TEXT NOT NULL)";function xt(e,t){let r=_(e).database;if(!Yn(r))return;let n=[...t].sort((l,p)=>p.from.length-l.from.length);function o(l){if(!Pe.isAbsolute(l))return l;let p=n.find(f=>At(l,f.from));return p?Pe.join(p.to,Pe.relative(p.from,l)):l}c(o,"rebase");function i(l,p=""){return typeof l=="string"&&/(?:path|directory|root|cwd)$/i.test(p)?o(l):Array.isArray(l)?l.map(f=>i(f,p)):l&&typeof l=="object"?Object.fromEntries(Object.entries(l).map(([f,g])=>[f,["messages","events","turns","metadata","input","output","result","credential","manifest"].includes(f)?g:i(g,f)])):l}c(i,"visit");let a=c(l=>`"${l.replaceAll('"','""')}"`,"quote"),s=D(r);try{s.exec("BEGIN IMMEDIATE"),s.exec(Vi);for(let l of s.prepare("SELECT source, destination FROM storage_path_relocations").all())s.prepare("UPDATE storage_path_relocations SET destination=? WHERE source=?").run(o(l.destination),l.source);for(let l of n)l.from!==l.to&&s.prepare("INSERT INTO storage_path_relocations VALUES (?, ?) ON CONFLICT(source) DO UPDATE SET destination=excluded.destination").run(l.from,l.to);for(let{name:l}of s.prepare("SELECT name FROM sqlite_master WHERE type='table'").all())if(or.has(l)){let p=s.prepare(`PRAGMA table_info(${a(l)})`).all(),f=p.filter(h=>h.pk).sort((h,y)=>h.pk-y.pk);if(!f.length)continue;let g=p.filter(h=>h.name==="payload"||/(?:_path|_directory|_root)$/.test(h.name)||h.name==="cwd"),m=f.map(h=>`${a(h.name)}=?`).join(" AND ");for(let h of s.prepare(`SELECT * FROM ${a(l)}`).all())for(let y of g){let T=h[y.name];if(typeof T!="string")continue;let A=y.name==="payload"?JSON.stringify(i(JSON.parse(T))):o(T);T!==A&&s.prepare(`UPDATE ${a(l)} SET ${a(y.name)}=? WHERE ${m}`).run(A,...f.map(x=>h[x.name]))}}s.exec("COMMIT; PRAGMA wal_checkpoint(TRUNCATE)")}finally{s.close()}}c(xt,"rebaseStoragePointers");function Gi(e,t){let r=_(e).database;if(!Pe.isAbsolute(t)||!Yn(r))return t;let n=D(r,!0);try{if(!n.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='storage_path_relocations'").get())return t;let i=n.prepare("SELECT source, destination FROM storage_path_relocations").all().sort((a,s)=>s.source.length-a.source.length).find(a=>At(t,a.source));return i?Pe.join(i.destination,Pe.relative(i.source,t)):t}finally{n.close()}}c(Gi,"resolveStoredPath");import{existsSync as Me,promises as rt}from"node:fs";import v from"node:path";async function Zn(e){let t=v.join(e.backup,"app"),r=v.join(t,"refiners");if(Me(v.join(r,"binding.json"))){let s=await M(v.join(r,"binding.json"),()=>({}));if(s.schemaVersion!=="openpond.refinerBinding.v1")throw C(r,"Unsupported Refiner binding schema.");$(e.stage,"refiner_bindings","active",s);let l=v.join(r,"transitions");if(Me(l))for(let p of await rt.readdir(l)){if(!p.endsWith(".json"))continue;let f=await M(v.join(l,p),()=>({}));if(f.schemaVersion!=="openpond.refinerTransitionReceipt.v1"||typeof f.contentHash!="string")throw C(l,"Unsupported Refiner transition schema.");$(e.stage,"refiner_transitions",f.contentHash,f)}await rt.rm(v.join(e.stage,"library","refiners","binding.json"),{force:!0}),await rt.rm(v.join(e.stage,"library","refiners","transitions"),{recursive:!0,force:!0})}let n=v.join(e.backup,"global","extensions");if(Me(n)&&(await Q(n,v.join(e.stage,"library","extensions")),Me(v.join(n,"registry.json")))){let s=await M(v.join(n,"registry.json"),()=>({}));if(s.schemaVersion!==1||!Array.isArray(s.extensions))throw C(n,"Unsupported extension registry schema.");$(e.stage,"extension_installations","registry",s),await rt.rm(v.join(e.stage,"library","extensions","registry.json"),{force:!0})}let o=v.join(e.backup,"global","profiles");if(Me(o)){await Q(o,v.join(e.stage,"library","profiles"));let s=ae(e.stage,"profile_installations","library"),l=e.sourceConfig?v.join(v.dirname(e.sourceConfig),"profiles"):null;if(s&&l){let p=c(g=>({...g,...typeof g.repoPath=="string"&&Ki(g.repoPath,l)?{repoPath:v.join(e.home,"library","profiles",v.relative(l,g.repoPath))}:{}}),"rebase"),f=p(s.value);Array.isArray(f.profiles)&&(f.profiles=f.profiles.map(g=>p(g))),$(e.stage,"profile_installations","library",f)}}if(e.sourceBrowserState){let s=v.join(e.backup,"browser-sidebar-state.json"),l=ar.safeParse(await M(s,()=>null));if(!l.success)throw C(s,"Unsupported browser tab metadata.");let p=l.data;for(let[f,g]of Object.entries(p.conversations))$(e.stage,"browser_tab_state",f,g)}let i=[];if(e.sourceAppHome){for(let s of["harnesses","refiners"])i.push({from:v.join(e.sourceAppHome,s),to:v.join(e.home,"library",s)});i.push({from:e.sourceAppHome,to:e.home})}if(e.sourceConfig)for(let s of["profiles","extensions"])i.push({from:v.join(v.dirname(e.sourceConfig),s),to:v.join(e.home,"library",s)});xt(e.stage,i);let a=v.join(e.stage,"attachments");Me(a)&&await eo(e.stage,a,[])}c(Zn,"importAdditionalDomains");function Ki(e,t){let r=v.relative(t,e);return r===""||!r.startsWith(`..${v.sep}`)&&r!==".."&&!v.isAbsolute(r)}c(Ki,"within");async function eo(e,t,r){for(let n of await rt.readdir(t,{withFileTypes:!0})){let o=v.join(t,n.name),i=[...r,n.name];if(n.isDirectory())await eo(e,o,i);else if(n.isFile()&&i.length>=3){let a=i.slice(2).join("/");await kn(e,{owner:{domain:"chat_attachment",id:JSON.stringify([i[0],i[1],a])},displayName:n.name,mediaType:"application/octet-stream",sourceFile:o})}else throw C(o,"Attachment storage contains an unsupported file or symbolic link.")}}c(eo,"importAttachments");var Ji=new Set(["config.json","providers.json","provider-secrets.json","provider-secrets.key","personalization.json","SOUL.md","token","state.sqlite","state.sqlite-wal","state.sqlite-shm"]),zi=new Set(["cache","logs","diagnostics","backups","runtime"]);async function ro(e,t={}){e=b.resolve(e),me(e);let r=Object.keys(t).length===0?await nr(e):null,n=Sn(e,r);if(n)return n;let o=await M(_(e).marker,()=>null),i=await Re(e);if(o&&(to(o,e),!i||i.status==="verified")){t.sourceBrowserState&&!t.dryRun&&await Mn(e,t.sourceBrowserState);let f=De(e,"current",i);return r&&r===await nr(e)&&vn(e,r,f),f}if(i&&!t.dryRun)return qi(e);let a=await Xn(e,t),{issues:s,sourceCandidates:l,...p}=a;if(t.dryRun)return{...De(e,"planned",null),sourceAppHome:p.sourceAppHome??null,sourceConfig:p.sourceConfig??null,issues:s,sourceCandidates:l,...s.length?{}:{preview:await Ln(e,p,no)}};if(s.length)throw C(e,s.map(f=>f.message).join(" "));return L(b.join(_(e).runtime,"migration-owner"),async()=>{let f=await M(_(e).marker,()=>null);if(f)return to(f,e),De(e,"current",null);let g=await Re(e);if(g)return pr(g);if(!p.sourceAppHome&&!p.sourceConfig&&!p.sourceBrowserState)return await U(e),await O(e),await I(_(e).marker,`${JSON.stringify({...Nt,migrationId:null},null,2)}
32
32
  `),De(e,"new",null);for(let y of[_(e).database,_(e).credentials])if(y&&le(y))throw C(y,"The destination already contains authoritative state. Import the previous installation into a fresh home; existing history and credentials have been preserved.");await et(p.sourceAppHome,p.sourceConfig);let m=`migration-${new Date().toISOString().replace(/[:.]/g,"-")}-${fr().slice(0,8)}`,h={schemaVersion:"openpond.migration.v1",id:m,status:"preparing",home:e,stage:b.join(b.dirname(e),`.${b.basename(e)}-${m}`),backup:b.join(e,"backups",m),files:[],installed:[],...p,resolutions:t.resolutions,createdAt:new Date().toISOString()};return await ce(h),pr(h)})}c(ro,"initializeHome");function to(e,t){if(e.version!==1||e.schemaVersion!==Nt.schemaVersion)throw new w({code:"UNSUPPORTED_STORAGE_VERSION",path:_(t).marker,message:"This OpenPond home requires a different application version.",action:"Update OpenPond, or restore a compatible backup into a separate home."})}c(to,"assertLayout");async function Wi(e){if(!e.snapshotComplete){if(await et(e.sourceAppHome,e.sourceConfig),await U(e.backup),e.sourceConfig){await Q(e.sourceConfig,b.join(e.backup,"config.json"));for(let t of["extensions","profiles"]){let r=b.join(b.dirname(e.sourceConfig),t);le(r)&&await Q(r,b.join(e.backup,"global",t))}}if(e.sourceBrowserState&&await Q(e.sourceBrowserState,b.join(e.backup,"browser-sidebar-state.json")),e.sourceAppHome){for(let n of await P.readdir(e.sourceAppHome,{withFileTypes:!0}))["openpond-app","openpond-app-nightly","storage.json","config.toml","state","browser"].includes(n.name)||zi.has(n.name)||n.name.startsWith("state.sqlite")||await Q(b.join(e.sourceAppHome,n.name),b.join(e.backup,"app",n.name));let t=b.join(e.sourceAppHome,"state.sqlite"),r=b.join(e.backup,"state.sqlite");if(le(t)&&!le(r)){let n=`${r}.${fr()}.tmp`,o=D(t,!0);try{await Hi(o,n);let i=await P.open(n,"r+");try{await i.sync()}finally{await i.close()}if(await P.rename(n,r),process.platform!=="win32"){let a=await P.open(b.dirname(r),"r");try{await a.sync()}finally{await a.close()}}}finally{o.close(),await P.rm(n,{force:!0})}}}await et(e.sourceAppHome,e.sourceConfig),e.snapshotComplete=!0,await ce(e)}}c(Wi,"captureSources");async function no(e){await Wi(e),await U(e.stage);let t=b.join(e.backup,"app");if(le(t))for(let n of await P.readdir(t)){if(Ji.has(n)||n==="souls"||/^soul-.+\.md$/i.test(n))continue;let o=["harnesses","refiners"].includes(n)?b.join("library",n):n;await Q(b.join(t,n),b.join(e.stage,o))}le(b.join(e.backup,"state.sqlite"))&&await Q(b.join(e.backup,"state.sqlite"),_(e.stage).database),await Vn(e.stage,e.sourceConfig?b.join(e.backup,"config.json"):void 0),await Gn(e.stage,e.sourceAppHome),await Kn(e.stage,e.sourceAppHome?t:void 0),await Hn(e.stage,e.sourceAppHome?t:void 0),await Jn(e.stage,e.sourceAppHome?t:void 0);let r=await S(b.join(t,"token"));r&&await I(_(e.stage).token,r),await Zn(e),le(_(e.home).config)&&await Rn(e.home,e.stage,e.resolutions),await Le(e.stage),await P.rm(b.join(e.stage,"runtime"),{recursive:!0,force:!0}),await P.rm(b.join(e.stage,"backups"),{recursive:!0,force:!0}),await P.rm(b.join(e.stage,"datasets","settings.json"),{force:!0}),e.files=(await tt(e.stage)).filter(n=>!n.path.endsWith("-wal")&&!n.path.endsWith("-shm")),e.status="prepared",await ce(e)}c(no,"prepare");async function Le(e){let{document:t}=await O(e);await En(e);for(let r of Object.values(t.providers??{}))if(r.credential?.source==="secret"&&!await fn(e,r.credential.id))throw C(_(e).config,"An imported provider credential is missing.");if(le(_(e).database)){let r=D(_(e).database);try{let n=r.prepare("PRAGMA integrity_check").all();if(n.length!==1||Object.values(n[0])[0]!=="ok"||r.prepare("PRAGMA foreign_key_check").all().length)throw C(_(e).database,"The imported database failed integrity checks.");r.exec("PRAGMA wal_checkpoint(TRUNCATE)")}finally{r.close()}await xn(e)}}c(Le,"validateMigratedHome");async function Xi(e){e.status="installing",await ce(e);for(let t of e.files){let r=b.join(e.home,t.path),n=b.join(e.stage,t.path),o=le(r)?await K(r):null;if(e.installed.includes(t.path)&&o!==t.sha256)throw C(r,"An installed file changed before migration recovery completed.");if(o!==t.sha256){if(await K(n)!==t.sha256)throw C(n,"A staged file failed its checksum check.");if(o!==null&&await Q(r,b.join(e.backup,"destination",t.path)),await U(b.dirname(r)),(await P.lstat(n)).isSymbolicLink())le(r)&&await P.unlink(r),await P.symlink(await P.readlink(n),r);else{let a=`${r}.${fr()}.migration`;try{await P.copyFile(n,a),await P.chmod(a,t.executable?448:384);let s=await P.open(a,"r+");try{await s.sync()}finally{await s.close()}await P.rename(a,r)}finally{await P.rm(a,{force:!0})}}}if(process.platform!=="win32"){let i=await P.open(b.dirname(r),"r");try{await i.sync()}finally{await i.close()}}e.installed.includes(t.path)||e.installed.push(t.path),await ce(e)}await Le(e.home),await I(_(e.home).marker,`${JSON.stringify({...Nt,migrationId:e.id},null,2)}
33
33
  `),e.status="committed",await ce(e),e.status="verified",delete e.error,await ce(e),await P.rm(e.stage,{recursive:!0,force:!0})}c(Xi,"install");async function qi(e){return L(b.join(_(e).runtime,"migration-owner"),async()=>{let t=await Re(e);if(!t)throw C(e,"No migration journal is available.");return pr(t)})}c(qi,"recoverMigration");async function pr(e){if(e.status==="verified")return De(e.home,"current",e);try{return(e.status==="preparing"||e.status==="failed")&&(await P.rm(e.stage,{recursive:!0,force:!0}),e.status="preparing",await no(e)),e.status!=="committed"?await Xi(e):(await Le(e.home),e.status="verified",await ce(e),await P.rm(e.stage,{recursive:!0,force:!0})),De(e.home,"verified",e)}catch(t){throw e.error=t instanceof w?t.issue.code:"MIGRATION_FAILED",e.status==="preparing"&&(e.status="failed"),await ce(e),t instanceof w?t:new w({code:"MIGRATION_FAILED",path:b.join(_(e.home).runtime,"migration.json"),message:"OpenPond could not finish updating its storage.",action:"Open migration details or run openpond config recover. Original data and snapshots have been preserved."},{cause:t})}}c(pr,"recoverUnlocked");function De(e,t,r){return{id:r?.id??null,status:t,home:e,sourceAppHome:r?.sourceAppHome??null,sourceConfig:r?.sourceConfig??null,backup:r?.backup??null}}c(De,"report");async function Bd(e){return L(b.join(_(e).runtime,"migration-owner"),async()=>{let t=await Re(e);if(!t)return{restarted:!1,backup:null};if(!["preparing","failed"].includes(t.status)||t.installed.length||t.files.length)throw C(e,"Installation has already begun. Resume recovery or restore into a fresh home; preparation cannot be restarted.");return await et(t.sourceAppHome,t.sourceConfig),await I(b.join(t.backup,"abandoned-preparation.json"),JSON.stringify(t,null,2)),await P.rm(t.stage,{recursive:!0,force:!0}),await P.rm(b.join(_(e).runtime,"migration.json")),{restarted:!0,backup:t.backup}})}c(Bd,"restartMigration");async function Qi(e){let t=await O(e),r=ae(e,"client_preferences","global");return{preferences:We(t.document,r?.value),config:t}}c(Qi,"readPreferences");async function Qd(e,t,r){return L(`${_(e).runtime}/preferences`,async()=>{let n=ae(e,"client_preferences","global"),o=n?.value;return await z(e,i=>{let a=We(i,n?.value),s=Z.parse({...a,...t,...t.defaultChatModelRef===void 0&&(t.defaultChatModel!==void 0||t.defaultChatProvider!==void 0)?{defaultChatModelRef:{providerId:t.defaultChatProvider??a.defaultChatProvider,modelId:t.defaultChatModel??a.defaultChatModel}}:{}});o=Tt(s);let l=structuredClone(i);for(let p of ie(Ae(a),Ae(s))){let f=l;for(let m of p.path.slice(0,-1))f[m]??={},f=f[m];let g=p.path.at(-1);p.op==="set"?f[g]=p.value:delete f[g]}return l},r),o&&JSON.stringify(o)!==JSON.stringify(n?.value)&&$(e,"client_preferences","global",o,n?.revision??null),Qi(e)})}c(Qd,"updatePreferences");import{createHash as Yi}from"node:crypto";import{promises as Oe}from"node:fs";import io from"node:path";var fe=c(e=>Yi("sha256").update(JSON.stringify(e)??"null").digest("hex"),"hash"),ao=c((e,t="local")=>fe([e,t]),"trustKey");async function pu(e,t,r,n){let o=await Oe.realpath(t);$(e,"project_trust",ao(o,r),{root:o,accountId:r,trusted:n,updatedAt:new Date().toISOString()})}c(pu,"setProjectTrust");async function so(e,t={}){let r=Ae(Z.parse({})),n=[],o={},i=[];function a(h,y,T,A=fe(y)){let x={layer:h,path:T,revision:A};r=yt(r,y),n.push(x);function E(B,de){if(B&&typeof B=="object"&&!Array.isArray(B)&&!("mode"in B)&&!("source"in B)&&!("provider_id"in B))for(let[Fe,ot]of Object.entries(B))E(ot,[...de,Fe]);else o[JSON.stringify(de)]=x}c(E,"visit"),E(y,[])}c(a,"apply"),a("defaults",r,"shipped"),t.profile&&(oo(t.profile.defaults,"profile"),a("profile",t.profile.defaults,t.profile.id,t.profile.revision));let s=await O(e);a("user",s.document,s.path,s.rawRevision);let l=structuredClone(r.permissions),p=null,f=null;if(t.projectRoot){p=await Oe.realpath(t.projectRoot);let h=io.join(p,".openpond","config.toml");if(await Oe.lstat(h).catch(T=>{if(R(T))return null;throw T})){if(await Oe.realpath(h)!==h)throw new w({code:"UNSAFE_PROJECT_CONFIG",path:h,message:"Project configuration must be a regular file inside its canonical project root.",action:"Replace symbolic links in the project configuration path with a regular local file."});let A=ae(e,"project_trust",ao(p,t.accountId));if(!A?.value.trusted)i.push({code:"PROJECT_CONFIG_UNTRUSTED",path:h,message:"Project settings are ignored until this project is trusted.",action:"Review the project configuration, then trust it in configuration settings."});else{f=A.revision;let x=await O(e,{path:h,scope:"project"});a("project",x.document,x.path,x.rawRevision),l?.command_access==="disabled"&&(r.permissions={...r.permissions,command_access:"disabled"}),l?.codex_mode==="default"&&(r.permissions={...r.permissions,codex_mode:"default"}),l=structuredClone(r.permissions)}}}for(let h of["task","turn"])t[h]&&(oo(t[h],h),a(h,t[h],h));(l?.command_access==="disabled"||l?.command_access==="ask"&&r.permissions?.command_access==="full-access")&&(r.permissions={...r.permissions,command_access:l.command_access}),l?.codex_mode&&l.codex_mode!=="full-access"&&r.permissions?.codex_mode!=="default"&&(r.permissions={...r.permissions,codex_mode:l.codex_mode}),ne(r),await Zi(e,r);let g=[...Object.values(r.accounts??{}),...Object.values(r.providers??{})].flatMap(h=>h.credential?.source==="secret"?[h.credential.id]:[]),m=await _n(e,g);return{document:r,effectiveRevision:fe({document:r,sources:n,projectTrustRevision:f,versions:m}),sources:n,provenance:o,diagnostics:i,projectRoot:p,projectTrustRevision:f,credentialVersions:m}}c(so,"resolveEffectiveConfig");function oo(e,t){ne(e);let r=t==="profile"?["schema_version","chat","codex","context_compaction","subagents","runtime"]:["schema_version","chat","codex","context_compaction","subagents","permissions"];for(let n of Object.keys(e))if(!r.includes(n))throw new w({code:"CONFIG_SCOPE_VIOLATION",path:`${t}.${n}`,message:`This setting is not allowed in ${t} configuration.`,action:"Move host settings to the user configuration file."})}c(oo,"checkScope");async function Zi(e,t){let r=t.defaults;if(r?.account_id&&(!t.accounts?.[r.account_id]||t.accounts[r.account_id].enabled===!1))throw new w({code:"INVALID_ACCOUNT_DEFAULT",path:"defaults.account_id",message:"The default account is missing or disabled.",action:"Choose an enabled account or remove the explicit default."});let n=t.personalization?.active;if(n&&t.personalization?.mode!=="disabled"){let i=n.startsWith("custom:")?io.join(e,"instructions","personalities",`${n.slice(7)}.md`):n,a=n.startsWith("custom:")?await S(i):it.find(s=>s.id===n.slice(8))?.content;if(a==null||a.trim().length>8e3)throw new w({code:"MISSING_INSTRUCTION_SOURCE",path:i,message:"The selected personality is missing or exceeds its supported size.",action:"Restore its Markdown file or select an available personality in Settings."})}let o=t.personalization?.user_instructions;if(o){let i=je(o,e);try{if(!(await Oe.stat(i)).isFile())throw new Error("Not a file");await Oe.access(i,Oe.constants.R_OK)}catch(a){throw new w({code:"MISSING_INSTRUCTION_SOURCE",path:i,message:"The configured user instruction file cannot be read.",action:"Restore the file or remove its configuration reference."},{cause:a})}}}c(Zi,"validateRequiredSources");async function fu(e,t,r={}){let n=await so(e,r);return $(e,"config_run_snapshots",t,{...n,capturedAt:new Date().toISOString()},null),n}c(fu,"captureConfigRun");async function mu(e,t,r={}){let n=await so(e,r);if(t.projectTrustRevision!==null&&n.projectTrustRevision!==t.projectTrustRevision)throw new w({code:"PROJECT_TRUST_CHANGED",path:t.projectRoot??e,message:"Project trust changed during this turn.",action:"Review project trust before starting a new turn."});let o=t.document.permissions,i=n.document.permissions;if(i?.command_access!==o?.command_access||i?.codex_mode!==o?.codex_mode||fe(n.credentialVersions)!==fe(t.credentialVersions)||fe(n.document.accounts)!==fe(t.document.accounts)||fe(n.document.providers)!==fe(t.document.providers))throw new w({code:"EXECUTION_POLICY_CHANGED",path:e,message:"Permissions or credential configuration changed during this turn.",action:"Start a new turn with the current settings."})}c(mu,"assertConfigRunCurrent");function hu(e){return We(e.document)}c(hu,"effectivePreferences");import{createHash as ea}from"node:crypto";var kt=d.strictObject({chatSelection:d.strictObject({provider:Pt,model:d.string().max(500),modelsByProvider:d.record(Pt,d.string().max(500)).optional()}).optional(),chatMode:d.enum(["chat","work"]).optional(),sidebarWorkflowCollapsedIds:d.array(d.string().min(1).max(200)).max(200).optional(),sidebarPresentation:d.enum(["grouped","inbox"]).optional(),notificationMode:d.enum(["all","direct_mentions","none"]).optional(),learningNoticeDismissed:d.boolean().optional(),sidebarVisibility:d.strictObject({showCodexChats:d.boolean(),onlyRunningTasks:d.boolean()}).optional(),scheduledWorkView:d.enum(["calendar","list"]).optional(),editorControlsVisible:d.boolean().optional(),voiceNoticeAcknowledged:d.boolean().optional(),lessonProgress:d.record(d.string().min(1).max(200),d.strictObject({completed:d.boolean(),currentTime:d.number().finite().nonnegative(),duration:d.number().finite().positive(),updatedAt:d.number().finite().nonnegative()})).refine(e=>Object.keys(e).length<=200,"Too many lessons").optional()}),Tu={"openpond:last-chat-selection":"chatSelection","openpond:last-chat-task-mode":"chatMode","openpond.sidebar.workflow-collapse.v1":"sidebarWorkflowCollapsedIds","openpond.sidebar.presentation.v1":"sidebarPresentation","openpond.team-chat.notification-mode":"notificationMode","openpond.sidebar.continuous-learning.dismissed.v1":"learningNoticeDismissed","openpond.sidebar-task-visibility.v1":"sidebarVisibility","openpond.scheduled-work.view.v1":"scheduledWorkView","openpond.workspace.editorControlsVisible":"editorControlsVisible","openpond.voice.setupNoticeAcknowledged":"voiceNoticeAcknowledged","openpond.post-training-progress.v1":"lessonProgress"};import ta from"node:path";async function co(e){let r=(await O(e)).document.defaults?.account_id??ae(e,"account_selection","last_used")?.value??"local";return`choices:${ea("sha256").update(JSON.stringify(r)).digest("hex")}`}c(co,"scope");async function ra(e){let t=await co(e),r=ae(e,"client_preferences",t),n=await O(e);return{owner:t,revision:r?.revision??null,value:kt.parse({...r?.value,notificationMode:n.document.notifications?.team_chat??"all"})}}c(ra,"readClientChoices");async function Nu(e,t,r,n=!1){return L(ta.join(_(e).runtime,"accounts"),async()=>{let o=kt.parse(r);if(await co(e)!==t)throw new w({code:"CLIENT_OWNER_CHANGED",path:"client_preferences",message:"The active account changed before this preference was saved.",action:"Reload preferences for the current account."});let{notificationMode:i,...a}=o;return i!==void 0&&await z(e,s=>n&&s.notifications?.team_chat!==void 0?s:{...s,notifications:{...s.notifications,team_chat:i}}),he(e,s=>{s.exec("BEGIN IMMEDIATE");try{let l=s.prepare("SELECT payload, revision FROM client_preferences WHERE id=?").get(t),p=l?JSON.parse(l.payload):{};delete p.notificationMode;let f=kt.parse(n?{...a,...p}:{...p,...a});s.prepare("INSERT INTO client_preferences VALUES (?, ?, 1) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload, revision=revision+1").run(t,JSON.stringify(f)),s.exec("COMMIT")}catch(l){throw s.exec("ROLLBACK"),l}}),ra(e)})}c(Nu,"updateClientChoices");import{randomUUID as mr}from"node:crypto";import{promises as Y}from"node:fs";import k from"node:path";import{backup as pa}from"node:sqlite";import{createCipheriv as na,createDecipheriv as oa,randomBytes as ia}from"node:crypto";import{createReadStream as lo,createWriteStream as aa,promises as Ue}from"node:fs";import re from"node:path";import{Readable as sa}from"node:stream";import{pipeline as uo}from"node:stream/promises";import{createGzip as ca,createGunzip as la}from"node:zlib";var Ce=Buffer.from("OPBK1\0"),da=d.string().min(1).refine(e=>!re.isAbsolute(e)&&!/^[A-Za-z]:/.test(e)&&!e.split(/[\\/]/).some(t=>!t||t==="."||t==="..")),ua=d.strictObject({path:da,sizeBytes:d.number().safe().int().nonnegative(),sha256:d.string().regex(/^[a-f0-9]{64}$/),executable:d.boolean(),link:d.string().optional()}),po=d.strictObject({schemaVersion:d.literal("openpond.recoveryBackup.v1"),originalHome:d.string(),createdAt:d.string().datetime(),entries:d.array(ua).max(5e5),externalRoots:d.array(d.strictObject({path:d.string(),available:d.boolean(),included:d.literal(!1)})),browserIncluded:d.boolean()});async function fo(e,t,r,n){if(r.byteLength!==32)throw new Error("A backup encryption key must contain exactly 32 bytes.");let o=Buffer.from(JSON.stringify(po.parse(n)));if(o.length>32*1024*1024)throw new Error("Backup manifest exceeds the supported size.");let i=Buffer.alloc(4);i.writeUInt32BE(o.length);let a=ia(12),s=na("aes-256-gcm",r,a);s.setAAD(Ce);let l=await Ue.open(t,"wx",384);try{await l.write(Buffer.concat([Ce,a])),await l.sync()}finally{await l.close()}async function*p(){yield i,yield o;for(let g of n.entries)if(g.link===void 0)for await(let m of lo(re.join(e,g.path)))yield m}c(p,"archive"),await uo(sa.from(p()),ca(),s,aa(t,{flags:"a"}));let f=await Ue.open(t,"a");try{await f.write(s.getAuthTag()),await f.sync()}finally{await f.close()}}c(fo,"encryptBackup");async function mo(e,t,r){if(r.byteLength!==32)throw new Error("A backup encryption key must contain exactly 32 bytes.");let n=(await Ue.stat(e)).size,o=Ce.length+12;if(n<o+16)throw new Error("Truncated recovery backup.");let i=await Ue.open(e,"r"),a=Buffer.alloc(o),s=Buffer.alloc(16);try{await i.read(a,0,a.length,0),await i.read(s,0,16,n-16)}finally{await i.close()}if(!a.subarray(0,Ce.length).equals(Ce))throw new Error("Unsupported recovery backup format.");let l=oa("aes-256-gcm",r,a.subarray(Ce.length));l.setAAD(Ce),l.setAuthTag(s);let p=lo(e,{start:o,end:n-17}),f=la(),g=uo(p,l,f);g.catch(()=>{});let m=f[Symbol.asyncIterator](),h=Buffer.alloc(0),y=0;async function T(A){let x=Buffer.alloc(A),E=0;for(;E<A;){if(y>=h.length){let de=await m.next();if(de.done)throw new Error("Truncated recovery object.");h=Buffer.from(de.value),y=0}let B=Math.min(A-E,h.length-y);h.copy(x,E,y,y+B),y+=B,E+=B}return x}c(T,"take");try{let A=(await T(4)).readUInt32BE();if(A>32*1024*1024)throw new Error("Invalid recovery manifest size.");let x=po.parse(JSON.parse((await T(A)).toString("utf8")));if(new Set(x.entries.map(E=>E.path)).size!==x.entries.length)throw new Error("Duplicate recovery object paths.");for(let E of x.entries){let B=re.join(t,E.path);if(/^(runtime|backups)([\\/]|$)/.test(E.path)||E.path.endsWith("-wal")||E.path.endsWith("-shm"))throw new Error("Recovery manifest contains an unsupported runtime object.");if(await U(re.dirname(B)),E.link!==void 0){if(re.isAbsolute(E.link)||!nt(re.resolve(re.dirname(B),E.link),t))throw new Error("Recovery symlink leaves the backup root.");await Ue.symlink(E.link,B)}else{let de=await Ue.open(B,"wx",E.executable?448:384);try{for(let Fe=E.sizeBytes;Fe>0;){let ot=await T(Math.min(1048576,Fe));await de.writeFile(ot),Fe-=ot.length}await de.sync()}finally{await de.close()}}if(await K(B)!==E.sha256)throw new Error("Recovery object failed its checksum.")}if(y<h.length||!(await m.next()).done)throw new Error("Unexpected trailing recovery data.");return await g,x}catch(A){throw p.destroy(),l.destroy(),f.destroy(),await g.catch(()=>{}),A}}c(mo,"decryptBackup");function nt(e,t){let r=re.relative(re.resolve(t),re.resolve(e));return r===""||r!==".."&&!r.startsWith(`..${re.sep}`)&&!re.isAbsolute(r)}c(nt,"within");var fa=new Set(["backups","runtime","cache","logs","diagnostics","browser","tmp","openpond-app","openpond-app-nightly","config.json","state.sqlite","state.sqlite-wal","state.sqlite-shm","providers.json","provider-secrets.json","provider-secrets.key","personalization.json","SOUL.md","token"]);async function op(e,t,r){if(e=k.resolve(e),t=k.resolve(t),nt(t,e))throw new Error("Export recovery backups outside the active home.");let n=[],o=k.join(k.dirname(e),`.${k.basename(e)}-backup-${mr()}`),i=`${t}.${mr()}.tmp`;try{n.push(await we(k.join(_(e).runtime,"server-owner"),100)),await ro(e);for(let p of["accounts","providers","preferences","personalization","artifacts"])n.push(await we(k.join(_(e).runtime,p)));n.push(await we(_(e).config)),n.push(await we(_(e).credentials)),await U(o);for(let p of await Y.readdir(e))fa.has(p)||p==="state"||await Q(k.join(e,p),k.join(o,p));let a=_(e).database;if(await Y.stat(a).catch(p=>{if(R(p))return null;throw p})){await U(k.dirname(_(o).database));let p=D(a,!0);try{await pa(p,_(o).database)}finally{p.close()}}await Le(o);let s=await St(e),l=[];for(let p of await tt(o)){if(p.path.endsWith("-wal")||p.path.endsWith("-shm")||/^(config\.toml|secrets[\\/](?:credentials\.json|server-token))\.lock(?:\.|$)/.test(p.path))continue;let f=k.join(o,p.path),g=await Y.lstat(f),m=g.isSymbolicLink()?await Y.readlink(f):void 0;if(m!==void 0&&(k.isAbsolute(m)||!nt(k.resolve(k.dirname(f),m),o)))throw new Error(`Source symlink requires rebinding before export: ${p.path}`);l.push({path:p.path,sha256:p.sha256,sizeBytes:m===void 0?g.size:0,executable:p.executable??!1,...m===void 0?{}:{link:m}})}return await Y.mkdir(k.dirname(t),{recursive:!0,mode:448}),await fo(o,i,r,{schemaVersion:"openpond.recoveryBackup.v1",originalHome:e,createdAt:new Date().toISOString(),entries:l,externalRoots:s,browserIncluded:!1}),await Y.link(i,t),{path:t,files:l.length,externalRoots:s}}catch(a){throw a instanceof w?a:new w({code:"BACKUP_FAILED",path:t,message:"The recovery backup could not be completed.",action:"Keep the application stopped, check the destination and supplied encryption key, then retry. Existing backups are never overwritten."},{cause:a})}finally{await Y.rm(o,{recursive:!0,force:!0}),await Y.rm(i,{force:!0});for(let a of n.reverse())await a()}}c(op,"exportRecoveryBackup");async function ip(e,t,r){t=k.resolve(t);let n=await Y.lstat(t).catch(i=>{if(R(i))return null;throw i});if(n&&(!n.isDirectory()||(await Y.readdir(t)).length))throw new Error("Restore requires a fresh, empty home. Existing homes are never overwritten.");let o=k.join(k.dirname(t),`.${k.basename(t)}-restore-${mr()}`);await U(o);try{let i=await mo(e,o,r);return await Le(o),await ma(o,i.originalHome,t),await I(_(o).marker,JSON.stringify({schemaVersion:"openpond.storage.v1",version:1,migrationId:null,restoredAt:new Date().toISOString()})),await I(k.join(o,"restore-receipt.json"),JSON.stringify({schemaVersion:"openpond.restoreReceipt.v1",originalHome:i.originalHome,restoredAt:new Date().toISOString(),externalRoots:i.externalRoots})),await Le(o),n&&await Y.rmdir(t),await Y.rename(o,t),{home:t,files:i.entries.length,externalRoots:await Promise.all(i.externalRoots.map(async a=>({...a,available:!!await Y.stat(a.path).catch(()=>null)})))}}catch(i){throw new w({code:"RESTORE_FAILED",path:t,message:"The backup could not be authenticated and validated for restoration.",action:"Check the backup and its separately stored key. The existing home has not been replaced."},{cause:i})}finally{await Y.rm(o,{recursive:!0,force:!0})}}c(ip,"restoreRecoveryBackup");async function ma(e,t,r){let n=c(o=>nt(o,t)?k.join(r,k.relative(t,o)):o,"rebase");await z(e,o=>({...o,...o.storage?.datasets_dir&&k.isAbsolute(o.storage.datasets_dir)?{storage:{...o.storage,datasets_dir:n(o.storage.datasets_dir)}}:{},...o.personalization?.user_instructions&&k.isAbsolute(o.personalization.user_instructions)?{personalization:{...o.personalization,user_instructions:n(o.personalization.user_instructions)}}:{},...o.projects?.new_project_directory&&k.isAbsolute(o.projects.new_project_directory)?{projects:{...o.projects,new_project_directory:n(o.projects.new_project_directory)}}:{}})),xt(e,[{from:t,to:r}])}c(ma,"rebaseRestoredPointers");async function lp(e){let t=structuredClone((await O(e)).document),r=[];function n(o,i,a,s){o&&Object.hasOwn(o,i)&&(delete o[i],r.push({path:[...a,i],reason:s}))}c(n,"omit");for(let o of["accounts","providers"])for(let[i,a]of Object.entries(t[o]??{}))n(a,"credential",[o,i],"Reconnect or bind a credential on the destination device.");for(let o of["accounts","providers"])for(let[i,a]of Object.entries(t[o]??{}))for(let s of["base_url","api_base_url","chat_api_base_url"]){let l=a[s];if(typeof l=="string")try{let p=new URL(l);(p.username||p.password||[...p.searchParams.keys()].some(f=>/token|key|secret|password|credential|signature/i.test(f))||p.hash)&&n(a,s,[o,i],"Rebind this endpoint without embedded authentication data.")}catch{n(a,s,[o,i],"Validate and bind this endpoint on the destination device.")}}n(t.storage,"datasets_dir",["storage"],"Choose the dataset storage root on the destination device."),n(t.projects,"new_project_directory",["projects"],"Choose the local projects directory."),n(t.personalization,"user_instructions",["personalization"],"Transfer the instruction source and bind its destination path."),t.personalization?.active?.startsWith("custom:")&&n(t.personalization,"active",["personalization"],"Transfer the selected custom personality Markdown before selecting it."),n(t.defaults,"profile_ref",["defaults"],"Install and select the Profile on the destination device.");for(let[o,i]of Object.entries(t.editor?.languages??{}))i.custom_command&&(n(i,"custom_command",["editor","languages",o],"Configure the local language-server command."),i.mode==="custom"&&delete i.mode);return{schemaVersion:"openpond.settingsExport.v1",config:t,requiresRebinding:r}}c(lp,"exportSettings");async function ha(e){let t=_(e).marker,r=await M(t,()=>null);if(r&&(r.schemaVersion!=="openpond.storage.v1"||r.version!==1))throw new w({code:"UNSUPPORTED_STORAGE_VERSION",path:t,message:"This OpenPond home requires a different application version.",action:"Update OpenPond, or restore a compatible backup into a separate home."})}c(ha,"assertHomeCompatible");export{go as a,G as b,S as c,U as d,I as e,L as f,we as g,yo as h,M as i,ba as j,Ur as k,jt as l,ne as m,ie as n,ci as o,qt as p,gt as q,li as r,di as s,cs as t,ls as u,O as v,Es as w,z as x,yt as y,bs as z,Is as A,Ae as B,We as C,Tt as D,Ms as E,Yt as F,Ds as G,Us as H,fn as I,mn as J,bt as K,hn as L,gn as M,_n as N,ue as O,En as P,An as Q,xn as R,kn as S,ki as T,Vc as U,Gc as V,Kc as W,Ot as X,Re as Y,Gi as Z,ro as _,Le as $,qi as aa,Bd as ba,Qi as ca,Qd as da,pu as ea,so as fa,fu as ga,mu as ha,hu as ia,kt as ja,Tu as ka,ra as la,Nu as ma,op as na,ip as oa,lp as pa,ha as qa};