@bkm016/basalt 0.1.16 → 0.1.17

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 (534) hide show
  1. package/{chunk-9ymm1gge.js → chunk-9jtvj8md.js} +202 -202
  2. package/compiled.js +1 -1
  3. package/package.json +1 -1
  4. package/web/{chunk-75meb0dh.js → chunk-013et20n.js} +2 -2
  5. package/web/chunk-013et20n.js.br +0 -0
  6. package/web/chunk-013et20n.js.gz +0 -0
  7. package/web/chunk-0ernj3c0.js +1 -0
  8. package/web/chunk-0ernj3c0.js.br +0 -0
  9. package/web/chunk-0ernj3c0.js.gz +0 -0
  10. package/web/chunk-0j65yg1p.js +1 -0
  11. package/web/chunk-0j65yg1p.js.br +0 -0
  12. package/web/chunk-0j65yg1p.js.gz +0 -0
  13. package/web/chunk-0khcpaa8.js +1 -0
  14. package/web/chunk-0khcpaa8.js.br +0 -0
  15. package/web/chunk-0khcpaa8.js.gz +0 -0
  16. package/web/chunk-0wbdd74r.js +1 -0
  17. package/web/chunk-0wbdd74r.js.br +2 -0
  18. package/web/chunk-0wbdd74r.js.gz +0 -0
  19. package/web/chunk-1f2wvhq9.js +1 -0
  20. package/web/chunk-1f2wvhq9.js.br +0 -0
  21. package/web/chunk-1f2wvhq9.js.gz +0 -0
  22. package/web/{chunk-75kzvpf3.js → chunk-1q2kmv35.js} +18 -18
  23. package/web/chunk-1q2kmv35.js.br +0 -0
  24. package/web/chunk-1q2kmv35.js.gz +0 -0
  25. package/web/{chunk-36e78034.js → chunk-1tfrm3pk.js} +2 -2
  26. package/web/chunk-1tfrm3pk.js.br +0 -0
  27. package/web/chunk-1tfrm3pk.js.gz +0 -0
  28. package/web/chunk-2qt5fy5n.js +1 -0
  29. package/web/chunk-2qt5fy5n.js.br +0 -0
  30. package/web/chunk-2qt5fy5n.js.gz +0 -0
  31. package/web/chunk-2sxtb709.js +1 -0
  32. package/web/chunk-2sxtb709.js.br +0 -0
  33. package/web/chunk-2sxtb709.js.gz +0 -0
  34. package/web/chunk-2wrwm0qe.js +1 -0
  35. package/web/chunk-2wrwm0qe.js.br +0 -0
  36. package/web/chunk-2wrwm0qe.js.gz +0 -0
  37. package/web/{chunk-5sss3r97.js → chunk-2wwj27b9.js} +3 -3
  38. package/web/chunk-2wwj27b9.js.br +0 -0
  39. package/web/chunk-2wwj27b9.js.gz +0 -0
  40. package/web/chunk-33mmrjdp.js +1 -0
  41. package/web/chunk-33mmrjdp.js.br +2 -0
  42. package/web/chunk-33mmrjdp.js.gz +0 -0
  43. package/web/chunk-33tb7q04.js +2 -0
  44. package/web/chunk-33tb7q04.js.br +0 -0
  45. package/web/chunk-33tb7q04.js.gz +0 -0
  46. package/web/chunk-3txb4sha.js +1 -0
  47. package/web/chunk-3txb4sha.js.br +0 -0
  48. package/web/chunk-3txb4sha.js.gz +0 -0
  49. package/web/{chunk-n3f5a91k.js → chunk-3xgfsx7y.js} +2 -2
  50. package/web/chunk-3xgfsx7y.js.br +0 -0
  51. package/web/chunk-3xgfsx7y.js.gz +0 -0
  52. package/web/chunk-40jka4r7.js +2 -0
  53. package/web/chunk-40jka4r7.js.br +0 -0
  54. package/web/chunk-40jka4r7.js.gz +0 -0
  55. package/web/{chunk-mcm3t5wr.js → chunk-41vh5n86.js} +1 -1
  56. package/web/chunk-41vh5n86.js.br +0 -0
  57. package/web/chunk-41vh5n86.js.gz +0 -0
  58. package/web/chunk-4wd9r73y.js.br +0 -0
  59. package/web/chunk-4wd9r73y.js.gz +0 -0
  60. package/web/chunk-5kz048x3.js +2 -0
  61. package/web/chunk-5kz048x3.js.br +0 -0
  62. package/web/chunk-5kz048x3.js.gz +0 -0
  63. package/web/chunk-5mbz8yj9.js +3 -0
  64. package/web/chunk-5mbz8yj9.js.br +0 -0
  65. package/web/chunk-5mbz8yj9.js.gz +0 -0
  66. package/web/chunk-6024wfxb.js +30 -0
  67. package/web/chunk-6024wfxb.js.br +0 -0
  68. package/web/chunk-6024wfxb.js.gz +0 -0
  69. package/web/chunk-6ey4c6gw.js +2 -0
  70. package/web/chunk-6ey4c6gw.js.br +0 -0
  71. package/web/chunk-6ey4c6gw.js.gz +0 -0
  72. package/web/chunk-6q3p851n.js +1 -0
  73. package/web/chunk-6q3p851n.js.br +2 -0
  74. package/web/chunk-6q3p851n.js.gz +0 -0
  75. package/web/{chunk-qbhv18t0.js → chunk-74g3wh08.js} +2 -2
  76. package/web/chunk-74g3wh08.js.br +0 -0
  77. package/web/chunk-74g3wh08.js.gz +0 -0
  78. package/web/{chunk-vcnsvj49.js → chunk-78akzkgs.js} +14 -14
  79. package/web/chunk-78akzkgs.js.br +0 -0
  80. package/web/chunk-78akzkgs.js.gz +0 -0
  81. package/web/chunk-7ck99bsp.js +62 -0
  82. package/web/chunk-7ck99bsp.js.br +0 -0
  83. package/web/chunk-7ck99bsp.js.gz +0 -0
  84. package/web/chunk-7fjbyns9.js +1 -0
  85. package/web/chunk-7fjbyns9.js.br +0 -0
  86. package/web/chunk-7fjbyns9.js.gz +0 -0
  87. package/web/chunk-7n6b2xra.js +21 -0
  88. package/web/chunk-7n6b2xra.js.br +0 -0
  89. package/web/chunk-7n6b2xra.js.gz +0 -0
  90. package/web/chunk-7p4mcqkd.js +78 -0
  91. package/web/chunk-7p4mcqkd.js.br +0 -0
  92. package/web/chunk-7p4mcqkd.js.gz +0 -0
  93. package/web/chunk-7ztwkhg5.js +1 -0
  94. package/web/chunk-7ztwkhg5.js.br +0 -0
  95. package/web/chunk-7ztwkhg5.js.gz +0 -0
  96. package/web/{chunk-t89tfrpj.js → chunk-823etvc3.js} +19 -19
  97. package/web/chunk-823etvc3.js.br +0 -0
  98. package/web/chunk-823etvc3.js.gz +0 -0
  99. package/web/{chunk-ps489yjy.js → chunk-8ec53vjd.js} +1 -1
  100. package/web/chunk-8ec53vjd.js.br +0 -0
  101. package/web/chunk-8ec53vjd.js.gz +0 -0
  102. package/web/chunk-8g239029.js.br +0 -0
  103. package/web/chunk-8g239029.js.gz +0 -0
  104. package/web/{chunk-p0jghn6b.js → chunk-8g55ytgz.js} +1 -1
  105. package/web/chunk-8g55ytgz.js.br +0 -0
  106. package/web/chunk-8g55ytgz.js.gz +0 -0
  107. package/web/chunk-8nxjthxc.js +1 -0
  108. package/web/chunk-8nxjthxc.js.br +0 -0
  109. package/web/chunk-8nxjthxc.js.gz +0 -0
  110. package/web/chunk-8q76yd76.js +291 -0
  111. package/web/chunk-8q76yd76.js.br +0 -0
  112. package/web/chunk-8q76yd76.js.gz +0 -0
  113. package/web/chunk-9kbrjmtz.js +1 -0
  114. package/web/chunk-9kbrjmtz.js.br +0 -0
  115. package/web/chunk-9kbrjmtz.js.gz +0 -0
  116. package/web/chunk-9s4bh6qm.js +40 -0
  117. package/web/chunk-9s4bh6qm.js.br +0 -0
  118. package/web/chunk-9s4bh6qm.js.gz +0 -0
  119. package/web/chunk-9v1f6yc8.js.br +0 -0
  120. package/web/chunk-9v1f6yc8.js.gz +0 -0
  121. package/web/{chunk-a205cj09.js → chunk-9vf3zy3d.js} +2 -2
  122. package/web/chunk-9vf3zy3d.js.br +0 -0
  123. package/web/chunk-9vf3zy3d.js.gz +0 -0
  124. package/web/{chunk-ef03t1mb.js → chunk-a449xjq6.js} +6 -6
  125. package/web/chunk-a449xjq6.js.br +0 -0
  126. package/web/chunk-a449xjq6.js.gz +0 -0
  127. package/web/chunk-ad6x47yy.js.br +0 -0
  128. package/web/chunk-ad6x47yy.js.gz +0 -0
  129. package/web/chunk-b05eay33.js +1 -0
  130. package/web/chunk-b05eay33.js.br +0 -0
  131. package/web/chunk-b05eay33.js.gz +0 -0
  132. package/web/{chunk-tfsrk2rc.js → chunk-bdypt5mj.js} +55 -55
  133. package/web/chunk-bdypt5mj.js.br +0 -0
  134. package/web/chunk-bdypt5mj.js.gz +0 -0
  135. package/web/chunk-bvyjy17t.js +14 -0
  136. package/web/chunk-bvyjy17t.js.br +0 -0
  137. package/web/chunk-bvyjy17t.js.gz +0 -0
  138. package/web/{chunk-ctmxm4qd.js → chunk-ccy2q2z0.js} +2 -2
  139. package/web/chunk-ccy2q2z0.js.br +0 -0
  140. package/web/chunk-ccy2q2z0.js.gz +0 -0
  141. package/web/{chunk-wvt76598.js → chunk-ceg13tma.js} +2 -2
  142. package/web/chunk-ceg13tma.js.br +0 -0
  143. package/web/chunk-ceg13tma.js.gz +0 -0
  144. package/web/{chunk-z2hvvkf5.js → chunk-ch60a61d.js} +2 -2
  145. package/web/chunk-ch60a61d.js.br +0 -0
  146. package/web/chunk-ch60a61d.js.gz +0 -0
  147. package/web/chunk-czvdg0c5.js +1 -0
  148. package/web/chunk-czvdg0c5.js.br +0 -0
  149. package/web/chunk-czvdg0c5.js.gz +0 -0
  150. package/web/chunk-d18r4m14.js.br +0 -0
  151. package/web/chunk-d18r4m14.js.gz +0 -0
  152. package/web/chunk-dmqtdeb4.js.br +0 -0
  153. package/web/chunk-dmqtdeb4.js.gz +0 -0
  154. package/web/chunk-drr7mqg2.js +1 -0
  155. package/web/chunk-drr7mqg2.js.br +0 -0
  156. package/web/chunk-drr7mqg2.js.gz +0 -0
  157. package/web/{chunk-chh8bg2h.js → chunk-dsa5m3h6.js} +34 -34
  158. package/web/chunk-dsa5m3h6.js.br +0 -0
  159. package/web/chunk-dsa5m3h6.js.gz +0 -0
  160. package/web/chunk-dww3grm3.js +24 -0
  161. package/web/chunk-dww3grm3.js.br +0 -0
  162. package/web/chunk-dww3grm3.js.gz +0 -0
  163. package/web/chunk-e187gt5x.js +1 -0
  164. package/web/chunk-e187gt5x.js.br +0 -0
  165. package/web/chunk-e187gt5x.js.gz +0 -0
  166. package/web/{chunk-pf65cank.js → chunk-emxa4wv3.js} +2 -2
  167. package/web/chunk-emxa4wv3.js.br +0 -0
  168. package/web/chunk-emxa4wv3.js.gz +0 -0
  169. package/web/{chunk-gjchc4kg.js → chunk-ey0zwvbx.js} +1 -1
  170. package/web/chunk-ey0zwvbx.js.br +0 -0
  171. package/web/chunk-ey0zwvbx.js.gz +0 -0
  172. package/web/chunk-ey14knbn.js +2 -0
  173. package/web/chunk-ey14knbn.js.br +0 -0
  174. package/web/chunk-ey14knbn.js.gz +0 -0
  175. package/web/chunk-fba06jm8.js +1132 -0
  176. package/web/chunk-fba06jm8.js.br +0 -0
  177. package/web/chunk-fba06jm8.js.gz +0 -0
  178. package/web/chunk-fh56vgfx.js +39 -0
  179. package/web/chunk-fh56vgfx.js.br +0 -0
  180. package/web/chunk-fh56vgfx.js.gz +0 -0
  181. package/web/chunk-ft05x3my.js +169 -0
  182. package/web/chunk-ft05x3my.js.br +0 -0
  183. package/web/chunk-ft05x3my.js.gz +0 -0
  184. package/web/chunk-fzmrnh17.js +303 -0
  185. package/web/chunk-fzmrnh17.js.br +0 -0
  186. package/web/chunk-fzmrnh17.js.gz +0 -0
  187. package/web/{chunk-ybqt106a.js → chunk-gbt7asd7.js} +2 -2
  188. package/web/chunk-gbt7asd7.js.br +0 -0
  189. package/web/chunk-gbt7asd7.js.gz +0 -0
  190. package/web/chunk-gh9fkn3t.js +1 -0
  191. package/web/chunk-gh9fkn3t.js.br +2 -0
  192. package/web/chunk-gh9fkn3t.js.gz +0 -0
  193. package/web/{chunk-sd3cdqcm.js → chunk-h1syyjqq.js} +2 -2
  194. package/web/chunk-h1syyjqq.js.br +0 -0
  195. package/web/chunk-h1syyjqq.js.gz +0 -0
  196. package/web/{chunk-mv5axm2y.js → chunk-h7byk4z3.js} +12 -12
  197. package/web/chunk-h7byk4z3.js.br +0 -0
  198. package/web/chunk-h7byk4z3.js.gz +0 -0
  199. package/web/chunk-hby0hkv4.js +1 -0
  200. package/web/chunk-hby0hkv4.js.br +0 -0
  201. package/web/chunk-hby0hkv4.js.gz +0 -0
  202. package/web/chunk-hjvsp2yx.js +1 -0
  203. package/web/chunk-hjvsp2yx.js.br +0 -0
  204. package/web/chunk-hjvsp2yx.js.gz +0 -0
  205. package/web/chunk-hp167dbv.js.br +0 -0
  206. package/web/chunk-hp167dbv.js.gz +0 -0
  207. package/web/{chunk-qwwqdmhv.js → chunk-hpjzy5ww.js} +1 -1
  208. package/web/chunk-hpjzy5ww.js.br +0 -0
  209. package/web/chunk-hpjzy5ww.js.gz +0 -0
  210. package/web/{chunk-1np2aamb.js → chunk-hzfp8kqx.js} +11 -11
  211. package/web/chunk-hzfp8kqx.js.br +0 -0
  212. package/web/chunk-hzfp8kqx.js.gz +0 -0
  213. package/web/{chunk-5d9veaef.js → chunk-j6jjk46a.js} +2 -2
  214. package/web/chunk-j6jjk46a.js.br +0 -0
  215. package/web/chunk-j6jjk46a.js.gz +0 -0
  216. package/web/chunk-j8f0m1dq.js +1 -0
  217. package/web/chunk-j8f0m1dq.js.br +0 -0
  218. package/web/chunk-j8f0m1dq.js.gz +0 -0
  219. package/web/{chunk-t9pg7qf8.js → chunk-jc178ad5.js} +2 -2
  220. package/web/chunk-jc178ad5.js.br +0 -0
  221. package/web/chunk-jc178ad5.js.gz +0 -0
  222. package/web/chunk-jcsf0ke5.js +41 -0
  223. package/web/chunk-jcsf0ke5.js.br +0 -0
  224. package/web/chunk-jcsf0ke5.js.gz +0 -0
  225. package/web/chunk-jg43a2xk.js +139 -0
  226. package/web/chunk-jg43a2xk.js.br +0 -0
  227. package/web/chunk-jg43a2xk.js.gz +0 -0
  228. package/web/chunk-jrgdxqtq.js +7 -0
  229. package/web/chunk-jrgdxqtq.js.br +0 -0
  230. package/web/chunk-jrgdxqtq.js.gz +0 -0
  231. package/web/chunk-js8dvtfg.js +2 -0
  232. package/web/chunk-js8dvtfg.js.br +0 -0
  233. package/web/chunk-js8dvtfg.js.gz +0 -0
  234. package/web/chunk-jt0s9qs7.js +1 -0
  235. package/web/chunk-jt0s9qs7.js.br +0 -0
  236. package/web/chunk-jt0s9qs7.js.gz +0 -0
  237. package/web/chunk-jv5faf88.js +34 -0
  238. package/web/chunk-jv5faf88.js.br +0 -0
  239. package/web/chunk-jv5faf88.js.gz +0 -0
  240. package/web/{chunk-vb2z2azk.js → chunk-k295x81w.js} +79 -79
  241. package/web/chunk-k295x81w.js.br +0 -0
  242. package/web/chunk-k295x81w.js.gz +0 -0
  243. package/web/{chunk-wcj3bxdf.js → chunk-k3aa37pw.js} +2 -2
  244. package/web/chunk-k3aa37pw.js.br +0 -0
  245. package/web/chunk-k3aa37pw.js.gz +0 -0
  246. package/web/{chunk-wgmwgaw4.js → chunk-k6wxwgp1.js} +26 -26
  247. package/web/chunk-k6wxwgp1.js.br +0 -0
  248. package/web/chunk-k6wxwgp1.js.gz +0 -0
  249. package/web/chunk-k9vc7kp2.js +292 -0
  250. package/web/chunk-k9vc7kp2.js.br +0 -0
  251. package/web/chunk-k9vc7kp2.js.gz +0 -0
  252. package/web/chunk-kxyws7q7.js +1 -0
  253. package/web/chunk-kxyws7q7.js.br +0 -0
  254. package/web/chunk-kxyws7q7.js.gz +0 -0
  255. package/web/{chunk-c0hdp2zj.js → chunk-mcgf645h.js} +1 -1
  256. package/web/chunk-mcgf645h.js.br +4 -0
  257. package/web/chunk-mcgf645h.js.gz +0 -0
  258. package/web/{chunk-3gj2t10x.js → chunk-mj3tshy8.js} +31 -31
  259. package/web/chunk-mj3tshy8.js.br +0 -0
  260. package/web/chunk-mj3tshy8.js.gz +0 -0
  261. package/web/chunk-mnb2wdvy.js +24 -0
  262. package/web/chunk-mnb2wdvy.js.br +0 -0
  263. package/web/chunk-mnb2wdvy.js.gz +0 -0
  264. package/web/chunk-ndf58dgc.js +1 -0
  265. package/web/chunk-ndf58dgc.js.br +0 -0
  266. package/web/chunk-ndf58dgc.js.gz +0 -0
  267. package/web/chunk-nhpm5nd5.js +2 -0
  268. package/web/chunk-nhpm5nd5.js.br +0 -0
  269. package/web/chunk-nhpm5nd5.js.gz +0 -0
  270. package/web/chunk-nj0cv1cq.js.br +0 -0
  271. package/web/chunk-nj0cv1cq.js.gz +0 -0
  272. package/web/{chunk-0zyekjym.js → chunk-nwxjdetb.js} +1 -1
  273. package/web/chunk-nwxjdetb.js.br +0 -0
  274. package/web/chunk-nwxjdetb.js.gz +0 -0
  275. package/web/chunk-nyjfcard.js +106 -0
  276. package/web/chunk-nyjfcard.js.br +0 -0
  277. package/web/chunk-nyjfcard.js.gz +0 -0
  278. package/web/chunk-nzey7cpv.js.br +0 -0
  279. package/web/chunk-nzey7cpv.js.gz +0 -0
  280. package/web/{chunk-g8wy9sa6.js → chunk-pcfjcy3a.js} +23 -23
  281. package/web/chunk-pcfjcy3a.js.br +0 -0
  282. package/web/chunk-pcfjcy3a.js.gz +0 -0
  283. package/web/chunk-pry6wdbe.js +1 -0
  284. package/web/chunk-pry6wdbe.js.br +0 -0
  285. package/web/chunk-pry6wdbe.js.gz +0 -0
  286. package/web/chunk-pvahdcgy.js +2 -0
  287. package/web/chunk-pvahdcgy.js.br +0 -0
  288. package/web/chunk-pvahdcgy.js.gz +0 -0
  289. package/web/{chunk-ffn1a0zw.js → chunk-q3njnnef.js} +2 -2
  290. package/web/chunk-q3njnnef.js.br +0 -0
  291. package/web/chunk-q3njnnef.js.gz +0 -0
  292. package/web/chunk-qxvqkkmw.js +1 -0
  293. package/web/chunk-qxvqkkmw.js.br +0 -0
  294. package/web/chunk-qxvqkkmw.js.gz +0 -0
  295. package/web/chunk-qych3sbs.js +1 -0
  296. package/web/chunk-qych3sbs.js.br +0 -0
  297. package/web/chunk-qych3sbs.js.gz +0 -0
  298. package/web/chunk-r1dnh0s8.js.br +0 -0
  299. package/web/chunk-r1dnh0s8.js.gz +0 -0
  300. package/web/chunk-r5eakmw6.js.br +0 -0
  301. package/web/chunk-r5eakmw6.js.gz +0 -0
  302. package/web/chunk-rbmp2e4b.js +1 -0
  303. package/web/chunk-rbmp2e4b.js.br +0 -0
  304. package/web/chunk-rbmp2e4b.js.gz +0 -0
  305. package/web/chunk-rcre1stj.js +1 -0
  306. package/web/chunk-rcre1stj.js.br +0 -0
  307. package/web/chunk-rcre1stj.js.gz +0 -0
  308. package/web/chunk-rdb6091n.js +89 -0
  309. package/web/chunk-rdb6091n.js.br +0 -0
  310. package/web/chunk-rdb6091n.js.gz +0 -0
  311. package/web/chunk-ryw7xnab.js +1 -0
  312. package/web/chunk-ryw7xnab.js.br +0 -0
  313. package/web/chunk-ryw7xnab.js.gz +0 -0
  314. package/web/{chunk-1hx4xtdk.js → chunk-sbbmy02e.js} +2 -2
  315. package/web/chunk-sbbmy02e.js.br +0 -0
  316. package/web/chunk-sbbmy02e.js.gz +0 -0
  317. package/web/{chunk-s0xy00v5.js → chunk-sgbc835w.js} +2 -2
  318. package/web/chunk-sgbc835w.js.br +0 -0
  319. package/web/chunk-sgbc835w.js.gz +0 -0
  320. package/web/chunk-sydy10mb.js +1 -0
  321. package/web/chunk-sydy10mb.js.br +0 -0
  322. package/web/chunk-sydy10mb.js.gz +0 -0
  323. package/web/chunk-t0ywnp5e.js +1 -0
  324. package/web/chunk-t0ywnp5e.js.br +0 -0
  325. package/web/chunk-t0ywnp5e.js.gz +0 -0
  326. package/web/chunk-t6agpn2z.js.br +0 -0
  327. package/web/chunk-t6agpn2z.js.gz +0 -0
  328. package/web/{chunk-hhnhgthx.js → chunk-t72jq97z.js} +2 -2
  329. package/web/chunk-t72jq97z.js.br +0 -0
  330. package/web/chunk-t72jq97z.js.gz +0 -0
  331. package/web/{chunk-6ty9vw27.js → chunk-tfcc9bcz.js} +3 -3
  332. package/web/chunk-tfcc9bcz.js.br +0 -0
  333. package/web/chunk-tfcc9bcz.js.gz +0 -0
  334. package/web/{chunk-27tchdxd.js → chunk-v2bvbgfc.js} +2 -2
  335. package/web/chunk-v2bvbgfc.js.br +0 -0
  336. package/web/chunk-v2bvbgfc.js.gz +0 -0
  337. package/web/{chunk-madrcnm1.js → chunk-v7zq4vc9.js} +5 -5
  338. package/web/chunk-v7zq4vc9.js.br +0 -0
  339. package/web/chunk-v7zq4vc9.js.gz +0 -0
  340. package/web/chunk-vh8pkcem.css.br +0 -0
  341. package/web/chunk-vh8pkcem.css.gz +0 -0
  342. package/web/chunk-vq3sby7x.js +1 -0
  343. package/web/chunk-vq3sby7x.js.br +0 -0
  344. package/web/chunk-vq3sby7x.js.gz +0 -0
  345. package/web/{chunk-vvvd3grf.js → chunk-vszya05r.js} +2 -2
  346. package/web/chunk-vszya05r.js.br +0 -0
  347. package/web/chunk-vszya05r.js.gz +0 -0
  348. package/web/chunk-was9xf03.js +8 -0
  349. package/web/chunk-was9xf03.js.br +0 -0
  350. package/web/chunk-was9xf03.js.gz +0 -0
  351. package/web/chunk-we1v1829.js +2 -0
  352. package/web/chunk-we1v1829.js.br +0 -0
  353. package/web/chunk-we1v1829.js.gz +0 -0
  354. package/web/chunk-wfa1c8dn.js +1 -0
  355. package/web/chunk-wfa1c8dn.js.br +0 -0
  356. package/web/chunk-wfa1c8dn.js.gz +0 -0
  357. package/web/chunk-wg2exnxe.js +1 -0
  358. package/web/chunk-wg2exnxe.js.br +2 -0
  359. package/web/chunk-wg2exnxe.js.gz +0 -0
  360. package/web/chunk-wvd3zj1m.js +70 -0
  361. package/web/chunk-wvd3zj1m.js.br +0 -0
  362. package/web/chunk-wvd3zj1m.js.gz +0 -0
  363. package/web/chunk-wzmxtr30.js +1 -0
  364. package/web/chunk-wzmxtr30.js.br +0 -0
  365. package/web/chunk-wzmxtr30.js.gz +0 -0
  366. package/web/chunk-x815g7yp.js +1 -0
  367. package/web/chunk-x815g7yp.js.br +0 -0
  368. package/web/chunk-x815g7yp.js.gz +0 -0
  369. package/web/{chunk-0qnetvsc.js → chunk-x8ps0p82.js} +14 -14
  370. package/web/chunk-x8ps0p82.js.br +0 -0
  371. package/web/chunk-x8ps0p82.js.gz +0 -0
  372. package/web/{chunk-y2ykn1gm.js → chunk-xea3snym.js} +1 -1
  373. package/web/chunk-xea3snym.js.br +0 -0
  374. package/web/chunk-xea3snym.js.gz +0 -0
  375. package/web/chunk-xet1jjy9.js.br +0 -0
  376. package/web/chunk-xet1jjy9.js.gz +0 -0
  377. package/web/{chunk-vjnvfb8z.js → chunk-xg4v60m7.js} +1 -1
  378. package/web/chunk-xg4v60m7.js.br +0 -0
  379. package/web/chunk-xg4v60m7.js.gz +0 -0
  380. package/web/chunk-xhr9jrjt.js +89 -0
  381. package/web/chunk-xhr9jrjt.js.br +0 -0
  382. package/web/chunk-xhr9jrjt.js.gz +0 -0
  383. package/web/chunk-xp90g2e7.js +36 -0
  384. package/web/chunk-xp90g2e7.js.br +0 -0
  385. package/web/chunk-xp90g2e7.js.gz +0 -0
  386. package/web/{chunk-e229cr90.js → chunk-xs1g97qa.js} +2 -2
  387. package/web/chunk-xs1g97qa.js.br +0 -0
  388. package/web/chunk-xs1g97qa.js.gz +0 -0
  389. package/web/chunk-xyk1wpr4.js +1 -0
  390. package/web/chunk-xyk1wpr4.js.br +3 -0
  391. package/web/chunk-xyk1wpr4.js.gz +0 -0
  392. package/web/chunk-yavbdwyt.js +1 -0
  393. package/web/chunk-yavbdwyt.js.br +0 -0
  394. package/web/chunk-yavbdwyt.js.gz +0 -0
  395. package/web/chunk-yfnhnsxe.js +4 -0
  396. package/web/chunk-yfnhnsxe.js.br +0 -0
  397. package/web/chunk-yfnhnsxe.js.gz +0 -0
  398. package/web/chunk-yk965yth.js +1 -0
  399. package/web/chunk-yk965yth.js.br +0 -0
  400. package/web/chunk-yk965yth.js.gz +0 -0
  401. package/web/{chunk-c1z290wm.js → chunk-ynhcjhsx.js} +2 -2
  402. package/web/chunk-ynhcjhsx.js.br +0 -0
  403. package/web/chunk-ynhcjhsx.js.gz +0 -0
  404. package/web/chunk-ypmm1gts.js +1 -0
  405. package/web/chunk-ypmm1gts.js.br +0 -0
  406. package/web/chunk-ypmm1gts.js.gz +0 -0
  407. package/web/chunk-yssx5a5q.js +1 -0
  408. package/web/chunk-yssx5a5q.js.br +0 -0
  409. package/web/chunk-yssx5a5q.js.gz +0 -0
  410. package/web/chunk-z09emmrb.js.br +0 -0
  411. package/web/chunk-z09emmrb.js.gz +0 -0
  412. package/web/chunk-z0a8cnq8.js +1 -0
  413. package/web/chunk-z0a8cnq8.js.br +0 -0
  414. package/web/chunk-z0a8cnq8.js.gz +0 -0
  415. package/web/{chunk-gaf9brzv.js → chunk-z1afsvbv.js} +2 -2
  416. package/web/chunk-z1afsvbv.js.br +0 -0
  417. package/web/chunk-z1afsvbv.js.gz +0 -0
  418. package/web/{chunk-w60dxtyz.js → chunk-z1ka8jtd.js} +2 -2
  419. package/web/chunk-z1ka8jtd.js.br +0 -0
  420. package/web/chunk-z1ka8jtd.js.gz +0 -0
  421. package/web/chunk-z7tdzen9.js +1 -0
  422. package/web/chunk-z7tdzen9.js.br +0 -0
  423. package/web/chunk-z7tdzen9.js.gz +0 -0
  424. package/web/{chunk-444xfger.js → chunk-zbwjj06m.js} +7 -7
  425. package/web/chunk-zbwjj06m.js.br +0 -0
  426. package/web/chunk-zbwjj06m.js.gz +0 -0
  427. package/web/chunk-zd2j189j.js +1 -0
  428. package/web/chunk-zd2j189j.js.br +0 -0
  429. package/web/chunk-zd2j189j.js.gz +0 -0
  430. package/web/chunk-zfgpq4n4.js +120 -0
  431. package/web/chunk-zfgpq4n4.js.br +0 -0
  432. package/web/chunk-zfgpq4n4.js.gz +0 -0
  433. package/web/chunk-zgas56xw.js +1 -0
  434. package/web/chunk-zgas56xw.js.br +0 -0
  435. package/web/chunk-zgas56xw.js.gz +0 -0
  436. package/web/chunk-zkfepf91.js +1 -0
  437. package/web/chunk-zkfepf91.js.br +0 -0
  438. package/web/chunk-zkfepf91.js.gz +0 -0
  439. package/web/icon-1wgy7kzy.svg.br +0 -0
  440. package/web/icon-1wgy7kzy.svg.gz +0 -0
  441. package/web/icon.svg.br +0 -0
  442. package/web/icon.svg.gz +0 -0
  443. package/web/index.html +11 -1
  444. package/web/index.html.br +0 -0
  445. package/web/index.html.gz +0 -0
  446. package/web/manifest-txf6vfbq.webmanifest.br +0 -0
  447. package/web/manifest-txf6vfbq.webmanifest.gz +0 -0
  448. package/web/manifest.webmanifest.br +0 -0
  449. package/web/manifest.webmanifest.gz +0 -0
  450. package/web/sw.js +146 -27
  451. package/web/sw.js.br +0 -0
  452. package/web/sw.js.gz +0 -0
  453. package/web/chunk-0zb330w3.js +0 -89
  454. package/web/chunk-11byy7vm.js +0 -1
  455. package/web/chunk-160x5pv7.js +0 -1
  456. package/web/chunk-19g09ekr.js +0 -40
  457. package/web/chunk-1gzprnyd.js +0 -1
  458. package/web/chunk-1je4p601.js +0 -139
  459. package/web/chunk-1rjtqf8h.js +0 -2
  460. package/web/chunk-1y387f45.js +0 -1
  461. package/web/chunk-23258z1r.js +0 -1
  462. package/web/chunk-27592nd8.js +0 -36
  463. package/web/chunk-2hqmdqn3.js +0 -41
  464. package/web/chunk-2q79n966.js +0 -2
  465. package/web/chunk-2ws74tfa.js +0 -21
  466. package/web/chunk-2z8epr8f.js +0 -34
  467. package/web/chunk-4k62e61g.js +0 -291
  468. package/web/chunk-4z6wma3s.js +0 -78
  469. package/web/chunk-5wkqqa59.js +0 -1
  470. package/web/chunk-5yczs6sb.js +0 -1
  471. package/web/chunk-5yn7mwvt.js +0 -1
  472. package/web/chunk-705tkt2r.js +0 -1
  473. package/web/chunk-753qp8sa.js +0 -4
  474. package/web/chunk-76e3npmd.js +0 -2
  475. package/web/chunk-7p04dn0k.js +0 -1
  476. package/web/chunk-7qq1ypvj.js +0 -1
  477. package/web/chunk-7rb3v8gy.js +0 -1
  478. package/web/chunk-7yz88k97.js +0 -39
  479. package/web/chunk-85d7jkp0.js +0 -2
  480. package/web/chunk-90kgn35s.js +0 -1
  481. package/web/chunk-931y1g0h.js +0 -1
  482. package/web/chunk-at0xtfhy.js +0 -1
  483. package/web/chunk-bcp6na49.js +0 -1145
  484. package/web/chunk-bz1q7qdd.js +0 -8
  485. package/web/chunk-c0evk1xy.js +0 -1
  486. package/web/chunk-cge0cjfm.js +0 -2
  487. package/web/chunk-e9mmkrc3.js +0 -7
  488. package/web/chunk-f8nnrk6y.js +0 -292
  489. package/web/chunk-fcrswzgm.js +0 -106
  490. package/web/chunk-fw4fa7j6.js +0 -1
  491. package/web/chunk-fx8hheqz.js +0 -1
  492. package/web/chunk-gj16e7z0.js +0 -1
  493. package/web/chunk-h0c42zy3.js +0 -1
  494. package/web/chunk-h1y8y203.js +0 -1
  495. package/web/chunk-h6vy008x.js +0 -24
  496. package/web/chunk-h8mhnze5.js +0 -303
  497. package/web/chunk-j27mtdr2.js +0 -1
  498. package/web/chunk-jys02310.js +0 -1
  499. package/web/chunk-kew13yzg.js +0 -1
  500. package/web/chunk-kx5r8nf2.js +0 -1
  501. package/web/chunk-m7c0xk69.js +0 -1
  502. package/web/chunk-mrnx4f74.js +0 -70
  503. package/web/chunk-mtdsrtc5.js +0 -1
  504. package/web/chunk-n3spc397.js +0 -24
  505. package/web/chunk-nbcpbqq4.js +0 -1
  506. package/web/chunk-nhc280n0.js +0 -1
  507. package/web/chunk-nx1bcekh.js +0 -2
  508. package/web/chunk-p8t7s4z4.js +0 -1
  509. package/web/chunk-pgh1cx6w.js +0 -1
  510. package/web/chunk-qgzn0ha5.js +0 -89
  511. package/web/chunk-qtwxq6hj.js +0 -3
  512. package/web/chunk-qwp3dhmf.js +0 -1
  513. package/web/chunk-rjh54ygb.js +0 -120
  514. package/web/chunk-ryh8jdzy.js +0 -1
  515. package/web/chunk-s3t8dkkz.js +0 -1
  516. package/web/chunk-sk1w7f7h.js +0 -1
  517. package/web/chunk-smkrxjm5.js +0 -1
  518. package/web/chunk-sv5ph7fa.js +0 -1
  519. package/web/chunk-t9twxmsg.js +0 -1
  520. package/web/chunk-tfdchqn4.js +0 -62
  521. package/web/chunk-tvvggvjt.js +0 -169
  522. package/web/chunk-ty87gdvr.js +0 -1
  523. package/web/chunk-v16s0x7c.js +0 -1
  524. package/web/chunk-vgyp8wa2.js +0 -2
  525. package/web/chunk-vphzndz8.js +0 -2
  526. package/web/chunk-xtss82z2.js +0 -1
  527. package/web/chunk-y0mef85j.js +0 -1
  528. package/web/chunk-ym9qfsjs.js +0 -30
  529. package/web/chunk-ypdptddq.js +0 -1
  530. package/web/chunk-z08c63ph.js +0 -2
  531. package/web/chunk-z6x74qfh.js +0 -1
  532. package/web/chunk-z86pjpqp.js +0 -1
  533. package/web/chunk-zh0vjc6g.js +0 -1
  534. package/web/chunk-zns9wmab.js +0 -1
package/compiled.js CHANGED
@@ -93,4 +93,4 @@ import{zr,jr,$n}from"./chunk-bjvv3403.js";import{G}from"./chunk-38g4jd6v.js";imp
93
93
  ${r?`<div class="details">${r}</div>`:""}
94
94
  </main>
95
95
  </body>
96
- </html>`}function Pt(e){return Vr({title:"Authentication successful",heading:"Authentication successful",message:e})}function P(e,t){return Vr({title:"Authentication failed",heading:"Authentication failed",message:e,details:t})}function Q(e,t,o){e.writeHead(t,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),e.end(o)}async function K(e){let{providerName:t,signal:o}=e;if(o?.aborted)throw Error("Login cancelled");let n=()=>{},r=()=>{},s=new Promise((g,h)=>{n=g,r=h});s.catch(()=>{return});let i=!1,d=!1,c,u=()=>l({error:Error("Login cancelled")}),l=(g)=>{if(d)return;if(d=!0,c)clearTimeout(c);if(o?.removeEventListener("abort",u),"error"in g)r(g.error);else n(g.value)},p=Md((g,h)=>{(async()=>{let x=new URL(g.url??"/","http://localhost");if(g.method!=="GET"||x.pathname!==e.path){Q(h,404,P("Callback route not found."));return}if(e.state!==void 0&&x.searchParams.get("state")!==e.state){Q(h,400,P("State mismatch."));return}if(i||d){Q(h,409,P("This sign-in has already been handled."));return}let I=x.searchParams.get("error");if(I){let S=x.searchParams.get("error_description")??I;Q(h,400,P(`${t} authorization failed.`,S)),l({error:Error(`${t} authorization failed: ${S}`)});return}let R=x.searchParams.get("code");if(!R){Q(h,400,P("Missing authorization code."));return}i=!0;try{let S=await e.complete(R);Q(h,200,Pt(`Signed in to ${t}. You may now close this page.`)),l({value:S})}catch(S){let D=S instanceof Error?S:Error(String(S));Q(h,502,P(`${t} sign-in failed.`,D.message)),l({error:D})}})()});await new Promise((g,h)=>{p.once("error",h),p.listen(e.port,e.host,()=>{p.off("error",h),g()})});let C=p.address();if(!C||typeof C==="string")throw p.close(),Error("OAuth callback server did not bind to TCP");if(p.on("error",(g)=>l({error:g})),o?.addEventListener("abort",u,{once:!0}),e.timeoutMs!==void 0)c=setTimeout(()=>l({error:Error(`${t} sign-in timed out`)}),e.timeoutMs);let m=e.redirectHost??e.host;return{redirectUri:`http://${m.includes(":")?`[${m}]`:m}:${C.port}${e.path}`,wait:()=>s,cancel:()=>{if(!i)l({value:void 0})},close:()=>{l({error:Error("OAuth callback server closed")}),p.close()}}}async function ve(e,t,o){let n=new AbortController,r,s=e.prompt({type:"manual_code",...o,signal:n.signal}).then((i)=>(t?.cancel(),i)).catch((i)=>{r=i instanceof Error?i:Error(String(i)),t?.cancel();return});try{let i=await t?.wait();if(r)throw r;if(i!==void 0)return{type:"callback",value:i};let d=await s;if(r)throw r;return{type:"manual",input:d??""}}finally{n.abort()}}function Kr(e){let t="";for(let o of e)t+=String.fromCharCode(o);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function N(){let e=new Uint8Array(32);crypto.getRandomValues(e);let t=Kr(e),n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=Kr(new Uint8Array(r));return{verifier:t,challenge:s}}var Ud=(e)=>atob(e),Gt=Ud("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl"),Yr="https://claude.ai/oauth/authorize",Re="https://platform.claude.com/v1/oauth/token",Bd=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Qr=53692,Zr="/callback",Dd=`http://localhost:${Qr}${Zr}`,Xr="https://platform.claude.com/oauth/code/callback",qr="browser",Jr="copy_code",es="org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";function ts(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Fe(e){if(e instanceof Error){let t=[`${e.name}: ${e.message}`],o=e;if(o.code)t.push(`code=${o.code}`);if(typeof o.errno<"u")t.push(`errno=${String(o.errno)}`);if(typeof e.cause<"u")t.push(`cause=${Fe(e.cause)}`);if(e.stack)t.push(`stack=${e.stack}`);return t.join("; ")}return String(e)}async function os(e,t,o){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t),signal:AbortSignal.any([o,AbortSignal.timeout(30000)])}),r=await n.text();if(!n.ok)throw Error(`HTTP request failed. status=${n.status}; url=${e}; body=${r}`);return r}async function ns(e,t,o,n,r){let s;try{s=await os(Re,{grant_type:"authorization_code",client_id:Gt,code:e,state:t,redirect_uri:n,code_verifier:o},r)}catch(d){throw Error(`Token exchange request failed. url=${Re}; redirect_uri=${n}; response_type=authorization_code; details=${Fe(d)}`)}let i;try{i=JSON.parse(s)}catch(d){throw Error(`Token exchange returned invalid JSON. url=${Re}; body=${s}; details=${Fe(d)}`)}return{type:"oauth",refresh:i.refresh_token,access:i.access_token,expires:Date.now()+i.expires_in*1000-300000}}async function $d(e){let{verifier:t,challenge:o}=await N(),n=(i)=>K({providerName:"Anthropic",host:Bd,port:i,path:Zr,redirectHost:"localhost",state:t,complete:async(d)=>d,signal:e.signal}),r=await n(Qr).catch(()=>n(0)).catch(()=>{return}),s=r?.redirectUri??Dd;try{let i=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:s,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${i.toString()}`,instructions:"Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."});let d=await ve(e,r,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:s}),c,u=t;if(d.type==="callback")c=d.value;else{let l=ts(d.input);if(l.state&&l.state!==t)throw Error("OAuth state mismatch");c=l.code,u=l.state??t}if(!c)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(c,u,t,s,e.signal)}finally{r?.close()}}async function Fd(e){let{verifier:t,challenge:o}=await N(),n=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:Xr,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${n.toString()}`,instructions:"Complete login in your browser, then copy the code Anthropic shows and paste it here."});let r=await e.prompt({type:"manual_code",message:"Paste the code Anthropic shows after you sign in:",placeholder:"code#state",signal:e.signal}),s=ts(r);if(s.state&&s.state!==t)throw Error("OAuth state mismatch");if(!s.code)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(s.code,s.state??t,t,Xr,e.signal)}async function Hd(e,t){let o;try{o=await os(Re,{grant_type:"refresh_token",client_id:Gt,refresh_token:e},t)}catch(r){throw Error(`Anthropic token refresh request failed. url=${Re}; details=${Fe(r)}`)}let n;try{n=JSON.parse(o)}catch(r){throw Error(`Anthropic token refresh returned invalid JSON. url=${Re}; body=${o}; details=${Fe(r)}`)}return{type:"oauth",refresh:n.refresh_token,access:n.access_token,expires:Date.now()+n.expires_in*1000-300000}}var rs={name:"Anthropic (Claude Pro/Max)",isSubscription:!0,async login(e){let t=await e.prompt({type:"select",message:"Select Anthropic login method:",options:[{id:qr,label:"Browser login (default)"},{id:Jr,label:"Copy code login (headless)"}]});if(t===Jr)return Fd(e);if(t!==qr)throw Error(`Unknown Anthropic login method: ${t}`);return $d(e)},refresh:(e,t)=>Hd(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function bt(e,t){return new Promise((o,n)=>{t.throwIfAborted();let r=()=>{clearTimeout(s),n(t.reason)},s=setTimeout(()=>{t.removeEventListener("abort",r),o()},e);t.addEventListener("abort",r,{once:!0})})}function ss(e,t,o){return new Promise((n,r)=>{if(t.aborted){r(Error(o));return}let s=()=>{clearTimeout(i),r(Error(o))},i=setTimeout(()=>{t.removeEventListener("abort",s),n()},e);t.addEventListener("abort",s,{once:!0})})}async function b(e){let t=typeof e.expiresInSeconds==="number"?Date.now()+e.expiresInSeconds*1000:Number.POSITIVE_INFINITY,o=Math.max(1000,Math.floor((e.intervalSeconds??5)*1000)),n=0;if(e.waitBeforeFirstPoll){let r=t-Date.now();if(r>0)await ss(Math.min(o,r),e.signal,"Login cancelled")}while(Date.now()<t){if(e.signal.aborted)throw Error("Login cancelled");let r=await e.poll();if(r.status==="complete")return r.value;if(r.status==="failed")throw Error(r.message);if(r.status==="slow_down")n+=1,o=typeof r.intervalSeconds==="number"&&Number.isFinite(r.intervalSeconds)&&r.intervalSeconds>0?Math.max(1000,Math.floor(r.intervalSeconds*1000)):Math.max(1000,o+5000);let s=t-Date.now();if(s<=0)break;await ss(Math.min(o,s),e.signal,"Login cancelled")}throw Error(n>0?"Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.":"Device flow timed out")}var Wd=(e)=>atob(e),as=Wd("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),lo={"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},Vd="2026-06-01";function cs(e){let t=e.trim();if(!t)return null;try{return(t.includes("://")?new URL(t):new URL(`https://${t}`)).hostname}catch{return null}}function po(e){return{deviceCodeUrl:`https://${e}/login/device/code`,accessTokenUrl:`https://${e}/login/oauth/access_token`,copilotTokenUrl:`https://api.${e}/copilot_internal/v2/token`}}function Kd(e){let t=e.match(/proxy-ep=([^;]+)/);if(!t)return null;return`https://${t[1].replace(/^proxy\./,"api.")}`}function _o(e,t){if(e){let o=Kd(e);if(o)return o}if(t)return`https://copilot-api.${t}`;return"https://api.individual.githubcopilot.com"}function We(e){return e&&typeof e==="object"?e:void 0}function jd(e,t){let o=We(e)?.data;if(!Array.isArray(o))throw Error("Invalid Copilot models response");let n=o.flatMap((c)=>{let u=We(c),l=u?.id;if(!u||typeof l!=="string")return[];let p=We(u.capabilities);if(We(p?.supports)?.tool_calls===!1)return[];return[{id:l,pickerEnabled:u.model_picker_enabled===!0,policyState:We(u.policy)?.state}]}),r=n.filter((c)=>c.pickerEnabled&&c.policyState!=="disabled").map((c)=>c.id),s=t&&r.length===0,i=r.length>0||!t?r:n.filter((c)=>c.policyState==="enabled").map((c)=>c.id),d=n.filter((c)=>c.policyState==="unconfigured"&&Object.hasOwn($r,c.id)&&(c.pickerEnabled||s)).map((c)=>c.id);return{availableModelIds:i,policyModelIds:d}}async function ds(e,t,o,n){let r=n.maxRetries>0&&n.maxElapsedMs>0?AbortSignal.timeout(n.maxElapsedMs):void 0,s=r?AbortSignal.any([o,r]):o,i=r?Date.now()+n.maxElapsedMs:void 0;for(let d=0;;d++){let c=await fetch(e,{...t,signal:AbortSignal.any([s,AbortSignal.timeout(5000)])});if(c.status!==429||d===n.maxRetries)return c;let u=c.headers.get("retry-after"),l=500*2**d;if(u){let p=Number.parseFloat(u);if(l=Number.isNaN(p)?Date.parse(u)-Date.now():p*1000,!Number.isFinite(l))return c}if(l=Math.max(0,l),i!==void 0&&l>=i-Date.now())return c;await c.body?.cancel(),await bt(l,s)}}async function us(e,t,o,n){let r=_o(e,t),s=r==="https://api.individual.githubcopilot.com",i=await ds(`${r}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo,"X-GitHub-Api-Version":Vd}},o,n);if(!i.ok)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return jd(await i.json(),s)}async function ho(e,t){let o=await fetch(e,t);if(!o.ok){let n=await o.text();throw Error(`${o.status} ${o.statusText}: ${n}`)}return o.json()}async function zd(e,t){let o=po(e),n=await ho(o.deviceCodeUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,scope:"read:user"}),signal:t});if(!n||typeof n!=="object")throw Error("Invalid device code response");let{device_code:r,user_code:s,verification_uri:i,interval:d,expires_in:c}=n;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||d!==void 0&&typeof d!=="number"||typeof c!=="number")throw Error("Invalid device code response fields");let u;try{u=new URL(i)}catch{throw Error("Untrusted verification_uri in device code response")}if(u.protocol!=="https:"&&u.protocol!=="http:")throw Error("Untrusted verification_uri in device code response");return{device_code:r,user_code:s,verification_uri:u.href,interval:d,expires_in:c}}async function Xd(e,t,o){let n=po(e);return b({intervalSeconds:t.interval,expiresInSeconds:t.expires_in,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let r=await ho(n.accessTokenUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,device_code:t.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:o});if(r&&typeof r==="object"&&typeof r.access_token==="string")return{status:"complete",value:r.access_token};if(r&&typeof r==="object"&&typeof r.error==="string"){let{error:s,error_description:i,interval:d}=r;if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down")return{status:"slow_down",intervalSeconds:typeof d==="number"?d:void 0};let c=i?`: ${i}`:"";return{status:"failed",message:`Device flow failed: ${s}${c}`}}return{status:"failed",message:"Invalid device token response"}}})}async function ls(e,t,o){let r=po(t||"github.com"),s=await ho(r.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo},signal:o});if(!s||typeof s!=="object")throw Error("Invalid Copilot token response");let{token:i,expires_at:d}=s;if(typeof i!=="string"||typeof d!=="number")throw Error("Invalid Copilot token response fields");return{type:"oauth",refresh:e,access:i,expires:d*1000-300000,enterpriseUrl:t}}async function qd(e,t,o){let n=await ls(e,t,o),{availableModelIds:r}=await us(n.access,t,o,{maxRetries:0,maxElapsedMs:0});return{...n,availableModelIds:r}}async function Jd(e,t,o,n){let s=`${_o(e,o)}/models/${t}/policy`,i;try{i=await ds(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,...lo,"openai-intent":"chat-policy","x-interaction-type":"chat-policy"},body:JSON.stringify({state:"enabled"})},n,{maxRetries:2,maxElapsedMs:5000})}catch(d){if(n.aborted)throw d;return!1}if(i.status===429)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return i.ok}async function Yd(e,t,o,n){let r=[];for(let s of t)try{if(await Jd(e,s,o,n))r.push(s)}catch(i){if(n.aborted)throw i;break}return r}async function Qd(e){let t=await e.prompt({type:"text",message:"GitHub Enterprise URL/domain (blank for github.com)",placeholder:"company.ghe.com"});if(e.signal.aborted)throw Error("Login cancelled");let o=t.trim(),n=cs(t);if(o&&!n)throw Error("Invalid GitHub Enterprise URL/domain");let r=n||"github.com",s=await zd(r,e.signal);e.notify({type:"device_code",userCode:s.user_code,verificationUri:s.verification_uri,intervalSeconds:s.interval,expiresInSeconds:s.expires_in});let i=await Xd(r,s,e.signal),d=await ls(i,n??void 0,e.signal),c=await us(d.access,n??void 0,e.signal,{maxRetries:2,maxElapsedMs:5000}),u=[];if(c.policyModelIds.length>0)e.notify({type:"progress",message:"Enabling models..."}),u=await Yd(d.access,c.policyModelIds,n??void 0,e.signal);return{...d,availableModelIds:[...new Set([...c.availableModelIds,...u])]}}function is(e){let t=e.enterpriseUrl;if(typeof t!=="string"||!t)return;return cs(t)??void 0}var ps={name:"GitHub Copilot",isSubscription:!0,login:Qd,refresh:(e,t)=>qd(e.refresh,is(e),t),async toAuth(e){return{apiKey:e.access,baseUrl:_o(e.access,is(e))}}};var fo="17e5f671-d194-4dfb-9706-5516cb48c098",Zd="https://auth.kimi.com",eu=900,tu=5,ou=30000,_s=3;function fs(){return(_("KIMI_CODE_OAUTH_HOST")||_("KIMI_OAUTH_HOST")||Zd).replace(/\/+$/,"")}function mo(e){return AbortSignal.any([AbortSignal.timeout(ou),e])}function go(e){return new URLSearchParams(e).toString()}async function Co(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function hs(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}async function nu(e,t){let o=await fetch(`${e}/api/oauth/device_authorization`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo}),signal:mo(t)});if(!o.ok){let l=await o.text().catch(()=>"");throw Error(`Kimi Code device authorization failed with status ${o.status}${l?`: ${l}`:""}`)}let n=await Co(o),r=n?.device_code,s=n?.user_code,i=n?.verification_uri,d=n?.verification_uri_complete;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||typeof d!=="string"||!hs(d)||!hs(i))throw Error(`Invalid Kimi Code device authorization response: ${JSON.stringify(n)}`);let c=n?.interval,u=n?.expires_in;return{deviceCode:r,userCode:s,verificationUri:i,verificationUriComplete:d,intervalSeconds:typeof c==="number"&&Number.isFinite(c)&&c>0?c:tu,expiresInSeconds:typeof u==="number"&&Number.isFinite(u)&&u>0?u:eu}}function ms(e,t){let o=e?.access_token,n=e?.refresh_token,r=e?.expires_in;if(typeof o!=="string"||!o||typeof n!=="string"||!n||typeof r!=="number"||!Number.isFinite(r)||r<=0)throw Error(`Kimi Code token ${t} response missing fields: ${JSON.stringify(e)}`);return{access:o,refresh:n,expires:Date.now()+r*1000}}async function ru(e,t,o){return b({intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let n=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,device_code:t.deviceCode,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:mo(o)});if(n.status>=500){let d=await n.text().catch(()=>"");return{status:"failed",message:`Kimi Code device token request failed with status ${n.status}${d?`: ${d}`:""}`}}let r=await Co(n);if(n.ok&&typeof r?.access_token==="string")try{return{status:"complete",value:ms(r,"poll")}}catch(d){return{status:"failed",message:d instanceof Error?d.message:String(d)}}let s=r?.error,i=typeof r?.error_description==="string"?`: ${r.error_description}`:"";if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down"){let d=r?.interval;return{status:"slow_down",intervalSeconds:typeof d==="number"&&d>0?d:void 0}}if(s==="expired_token")return{status:"failed",message:"Kimi Code device authorization expired. Please restart login."};if(s==="access_denied")return{status:"failed",message:"Kimi Code login was denied."};return{status:"failed",message:`Kimi Code device token request failed (status ${n.status})${typeof s==="string"?`: ${s}${i}`:""}`}}})}function su(e){return e.status===429||e.status>=500}async function iu(e,t,o){let n;for(let r=0;r<=_s;r++){if(r>0)await bt(1000*2**(r-1),o);if(o.aborted)throw Error("Kimi Code token refresh aborted");let s;try{s=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,grant_type:"refresh_token",refresh_token:t}),signal:mo(o)})}catch(c){n=c instanceof Error?c:Error(String(c));continue}let i=await Co(s);if(s.ok)return ms(i,"refresh");if(s.status===401||s.status===403||i?.error==="invalid_grant"){let c=typeof i?.error_description==="string"?`: ${i.error_description}`:"";throw Error(`Kimi Code token refresh unauthorized (status ${s.status})${c}`)}if(su(s)&&r<_s){n=Error(`Kimi Code token refresh failed with status ${s.status}`);continue}let d=JSON.stringify(i);throw Error(`Kimi Code token refresh failed with status ${s.status}${d?`: ${d}`:""}`)}throw n??Error("Kimi Code token refresh failed")}async function au(e){let t=fs(),o=await nu(t,e.signal);e.notify({type:"device_code",userCode:o.userCode,verificationUri:o.verificationUriComplete,intervalSeconds:o.intervalSeconds,expiresInSeconds:o.expiresInSeconds});let n=await ru(t,o,e.signal);return{type:"oauth",access:n.access,refresh:n.refresh,expires:n.expires}}var gs={name:"Kimi Code (subscription)",isSubscription:!0,loginLabel:"Sign in with Kimi Code",login:au,refresh:async(e,t)=>{let o=await iu(fs(),e.refresh,t);return{type:"oauth",access:o.access,refresh:o.refresh,expires:o.expires}},async toAuth(e){return{headers:{Authorization:`Bearer ${e.access}`}}}};var Cs="1031625952748946",Ss="https://auth.meta.com",cu=`${Ss}/oidc/device/authorization/`,du=`${Ss}/oidc/device/token/`,uu="https://api.meta.ai/muse-code/key",lu=86400000,pu=30000;function vo(e){return AbortSignal.any([AbortSignal.timeout(pu),e])}async function Ao(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function Nt(e){for(let t of["error_description","detail","message","error"]){let o=e?.[t];if(typeof o==="string"&&o.trim())return`: ${o.trim()}`}return""}function So(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}function Eo(e){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:void 0}async function _u(e){let t=await fetch(cu,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:Cs}).toString(),signal:vo(e)}),o=await Ao(t);if(!t.ok)throw Error(`Meta device authorization failed with status ${t.status}${Nt(o)}`);let n=o?.device_code,r=o?.user_code,s=So(o?.verification_uri_complete)??So(o?.verification_uri);if(typeof n!=="string"||!n||typeof r!=="string"||!r||!s)throw Error(`Invalid Meta device authorization response: ${JSON.stringify(o)}`);return{deviceCode:n,userCode:r,verificationUri:s,intervalSeconds:Eo(o?.interval),expiresInSeconds:Eo(o?.expires_in)}}async function hu(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await fetch(du,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e.deviceCode,client_id:Cs}).toString(),signal:vo(t)}),n=await Ao(o);if(o.ok&&typeof n?.access_token==="string"&&n.access_token)return{status:"complete",value:n.access_token};switch(n?.error){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down",intervalSeconds:Eo(n?.interval)};case"access_denied":return{status:"failed",message:"Meta login was denied."};case"expired_token":return{status:"failed",message:"Meta device authorization expired. Please restart login."};default:return{status:"failed",message:`Meta device token request failed with status ${o.status}${Nt(n)}`}}}})}async function Es(e,t){let o=await fetch(uu,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","x-api-version":"1.0.0"},body:"{}",signal:vo(t)}),n=await Ao(o);if(o.status===401||o.status===403)throw Error(`Meta session expired (status ${o.status}). Run \`/login meta\` to sign in again.${Nt(n)}`);if(!o.ok)throw Error(`Meta API key mint failed with status ${o.status}${Nt(n)}`);let r=n?.api_key;if(typeof r!=="string"||!r){let s=So(n?.action_url);throw Error(`Meta did not issue an API key.${s?` Complete setup at ${s}`:""}`)}return{type:"oauth",refresh:e,access:r,expires:Date.now()+lu}}async function fu(e){try{let t=await _u(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds});let o=await hu(t,e.signal);return e.notify({type:"progress",message:"Enabling Meta Model API access..."}),await Es(o,e.signal)}catch(t){if(e.signal.aborted)throw Error("Login cancelled");throw t}}var vs={name:"Meta (Muse subscription)",isSubscription:!0,loginLabel:"Sign in with Meta",login:fu,refresh:(e,t)=>Es(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};import{randomBytes as mu}from"crypto";import{createServer as gu}from"http";var Cu="dynamic_agent_client",Su="Pi",Eu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,vu="https://auth.openai.com/api/accounts/authorize",Au="https://auth.openai.com/api/accounts/oauth/token",xo="https://api.openai.com/v1",Ru=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Io=1455,Rs="/auth/callback",ye=`http://127.0.0.1:${Io}${Rs}`,yo="chatgpt.tokens.use.direct",yu=`openid profile email offline_access resource.invoke ${yo}`,xu=180000;function As(){return mu(32).toString("base64url")}function ys(e,t){let o=e.searchParams.get("code");if(!o)throw Error("Missing authorization code");let n=e.searchParams.get("state");if(!n)throw Error("Missing OAuth state");if(n!==t)throw Error("OAuth state mismatch");let r=e.searchParams.get("client_id")?.trim();if(!r)throw Error("OpenAI OAuth registration callback did not contain an issued client ID");return{code:o,clientId:r}}function Iu(e,t){let o;try{o=new URL(e.trim())}catch{throw Error("Paste the full callback URL from the browser")}let n=new URL(ye);if(o.origin!==n.origin||o.pathname!==n.pathname)throw Error(`The pasted callback URL must start with ${ye}`);let r=o.searchParams.get("error");if(r)throw Error(`ChatGPT authorization failed: ${r}`);return ys(o,t)}function Ve(e,t,o){e.writeHead(t,{"Content-Type":"text/html; charset=utf-8"}),e.end(o)}function Tu(e){return new Promise((t,o)=>{let n,r,s=new Promise((d,c)=>{n=d,r=c}),i=gu((d,c)=>{try{let u=new URL(d.url||"",ye);if(u.pathname!==Rs){Ve(c,404,P("Callback route not found."));return}let l=u.searchParams.get("error");if(l){Ve(c,400,P("ChatGPT was not connected.",`Error: ${l}`)),r(Error(`ChatGPT authorization failed: ${l}`));return}let p;try{p=ys(u,e)}catch(C){let m=C instanceof Error?C.message:"Invalid callback";Ve(c,400,P(m));return}Ve(c,200,Pt("ChatGPT authentication completed. You can close this window.")),n(p)}catch{Ve(c,500,P("Internal error while processing the callback."))}});i.once("error",o),i.listen(Io,Ru,()=>{i.removeListener("error",o),i.on("error",r),t({server:i,result:s})})})}async function xs(e,t){let o=await fetch(Au,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:e,signal:t});if(!o.ok){let r=await o.text().catch(()=>"");throw Error(`OpenAI OAuth token request failed (${o.status}): ${r||o.statusText}`)}let n=await o.json();if(typeof n!=="object"||n===null||Array.isArray(n))throw Error("OpenAI OAuth token response must be an object");return n}function Ro(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`OpenAI OAuth token response has invalid ${t}`);return e}function Is(e,t,o){let n=Ro(e.access_token,"access_token"),r=Ro(e.refresh_token,"refresh_token"),s=Ro(e.scope,"scope"),i=typeof e.id_token==="string"?e.id_token:o?.idToken;if(typeof e.expires_in!=="number"||!Number.isFinite(e.expires_in)||e.expires_in<=0)throw Error("OpenAI OAuth token response has invalid expires_in");let d=s.trim().split(/\s+/).filter(Boolean);if(!d.includes(yo))throw Error(`OpenAI OAuth grant did not include ${yo}`);return{type:"oauth",...i?{idToken:i}:{},access:n,refresh:r,expires:Date.now()+e.expires_in*1000-xu,clientId:t,scopes:d}}async function wu(e,t,o,n){let r=await xs(new URLSearchParams({grant_type:"authorization_code",client_id:o,code:e,code_verifier:t,redirect_uri:ye,resource:xo}),n);if(typeof r.id_token!=="string"||r.id_token.trim().length===0)throw Error("OpenAI OAuth token response did not contain an ID token");return Is(r,o)}async function ku(e,t){let o=e.clientId;if(typeof o!=="string"||o.trim().length===0)throw Error("Stored OpenAI OAuth credential does not contain an issued client ID; reconnect ChatGPT");let n=await xs(new URLSearchParams({grant_type:"refresh_token",client_id:o,refresh_token:e.refresh,resource:xo}),t);return Is(n,o,e)}function Ou(e){if(!e||!Eu.test(e))throw Error("Sign in with ChatGPT requires a device ID (UUID) for this installation");return`urn:uuid:${e.toLowerCase()}`}async function Pu(e,t){let o=Ou(t?.getDeviceId?.()),{verifier:n,challenge:r}=await N(),s=As(),i=As(),d=await Tu(s).catch((p)=>{if(!(p instanceof Error&&("code"in p)&&p.code==="EADDRINUSE"))throw p;throw Error(`Port ${Io} is in use, probably by an unfinished login in another pi session or by the Codex CLI. Cancel that login and try again.`)}),c=new URL(vu);c.search=new URLSearchParams({client_id:Cu,agent_name_hint:t?.agentName??Su,ext_agent_host_id:o,response_type:"code",redirect_uri:ye,resource:xo,scope:yu,state:s,code_challenge:r,code_challenge_method:"S256",nonce:i}).toString(),e.notify({type:"auth_url",url:c.toString(),instructions:"Complete sign-in in your browser. If the callback does not complete, paste the final redirect URL here."});let u=new AbortController,l=e.prompt({type:"manual_code",message:"Complete login in your browser, or paste the final redirect URL here:",placeholder:ye,signal:AbortSignal.any([u.signal,e.signal])}).then((p)=>Iu(p,s));try{let p=await Promise.race([d.result,l]);return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await wu(p.code,n,p.clientId,e.signal)}catch(p){if(e.signal.aborted)throw Error("Login cancelled");throw p}finally{u.abort(),d.server.close(),d.server.closeAllConnections()}}var Ts={name:"OpenAI (ChatGPT subscription)",isSubscription:!0,loginLabel:"Sign in with ChatGPT",login:Pu,refresh:ku,async toAuth(e){return{apiKey:e.access}}};var To=null;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))import("crypto").then((e)=>{To=e.randomBytes});var Lt="app_EMoamEEZ73f0CkXaXp7hrann",xe="https://auth.openai.com",Gu=`${xe}/oauth/authorize`,Os=`${xe}/oauth/token`,wo="http://localhost:1455/auth/callback",bu=`${xe}/api/accounts/deviceauth/usercode`,Nu=`${xe}/api/accounts/deviceauth/token`,Lu=`${xe}/codex/device`,Mu=`${xe}/deviceauth/callback`,Ps=900,ws="browser",ks="device_code",Uu="openid profile email offline_access",Bu="https://api.openai.com/auth";function Du(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function $u(){if(!To)throw Error("OpenAI Codex OAuth is only available in Node.js environments");return To(16).toString("hex")}function Fu(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Hu(e){try{let t=e.split(".");if(t.length!==3)return null;let o=t[1]??"",n=atob(o);return JSON.parse(n)}catch{return null}}async function ko(e,t){try{return await fetch(e,t)}catch(o){if(t.signal?.aborted)throw Error("Login cancelled");throw o}}async function Gs(e,t){if(!e.ok){let r=await e.text().catch(()=>"");throw Error(`OpenAI Codex token ${t} failed (${e.status}): ${r||e.statusText}`)}let n=await e.json();if(!n?.access_token||!n.refresh_token||typeof n.expires_in!=="number")throw Error(`OpenAI Codex token ${t} response missing fields: ${JSON.stringify(n)}`);return{access:n.access_token,refresh:n.refresh_token,expires:Date.now()+n.expires_in*1000}}async function Wu(e,t,o,n){let r=await ko(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:Lt,code:e,code_verifier:t,redirect_uri:o}),signal:n});return Gs(r,"exchange")}async function Vu(e,t){let o;try{o=await fetch(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:Lt}),signal:t})}catch(n){throw Error(`OpenAI Codex token refresh error: ${n instanceof Error?n.message:String(n)}`)}return Gs(o,"refresh")}async function Ku(e){let t=await ko(bu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:Lt}),signal:e});if(!t.ok){if(t.status===404)throw Error("OpenAI Codex device code login is not enabled for this server. Use browser login or verify the server URL.");let s=await t.text().catch(()=>"");throw Error(`OpenAI Codex device code request failed with status ${t.status}${s?`: ${s}`:""}`)}let n=await t.json(),r=typeof n?.interval==="string"?Number(n.interval.trim()):n?.interval;if(!n?.device_auth_id||!n.user_code||typeof r!=="number"||!Number.isFinite(r)||r<0)throw Error(`Invalid OpenAI Codex device code response: ${JSON.stringify(n)}`);return{deviceAuthId:n.device_auth_id,userCode:n.user_code,intervalSeconds:r}}async function ju(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:Ps,signal:t,poll:async()=>{let o=await ko(Nu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_auth_id:e.deviceAuthId,user_code:e.userCode}),signal:t});if(o.ok){let i=await o.json();if(!i?.authorization_code||!i.code_verifier)return{status:"failed",message:`Invalid OpenAI Codex device auth token response: ${JSON.stringify(i)}`};return{status:"complete",value:{authorizationCode:i.authorization_code,codeVerifier:i.code_verifier}}}if(o.status===403||o.status===404)return{status:"pending"};let n=await o.text().catch(()=>""),r;try{let i=JSON.parse(n)?.error;r=typeof i==="object"?i?.code:i}catch{}if(r==="deviceauth_authorization_pending")return{status:"pending"};if(r==="slow_down")return{status:"slow_down"};return{status:"failed",message:`OpenAI Codex device auth failed with status ${o.status}${n?`: ${n}`:""}`}}})}async function zu(e="pi"){let{verifier:t,challenge:o}=await N(),n=$u(),r=new URL(Gu);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",Lt),r.searchParams.set("redirect_uri",wo),r.searchParams.set("scope",Uu),r.searchParams.set("code_challenge",o),r.searchParams.set("code_challenge_method","S256"),r.searchParams.set("state",n),r.searchParams.set("id_token_add_organizations","true"),r.searchParams.set("codex_cli_simplified_flow","true"),r.searchParams.set("originator",e),{verifier:t,state:n,url:r.toString()}}function Xu(e){let n=Hu(e)?.[Bu]?.chatgpt_account_id;return typeof n==="string"&&n.length>0?n:null}function bs(e){let t=Xu(e.access);if(!t)throw Error("Failed to extract accountId from token");return{type:"oauth",access:e.access,refresh:e.refresh,expires:e.expires,accountId:t}}async function Ns(e,t,o,n){return bs(await Wu(e,t,o,n))}async function qu(e){let t=await Ku(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:Lu,intervalSeconds:t.intervalSeconds,expiresInSeconds:Ps});let o=await ju(t,e.signal);return Ns(o.authorizationCode,o.codeVerifier,Mu,e.signal)}async function Ju(e,t){let{verifier:o,state:n,url:r}=await zu(t?.agentName),s=await K({providerName:"OpenAI",host:Du(),port:1455,path:"/auth/callback",state:n,complete:async(i)=>i,signal:e.signal}).catch(()=>{return});e.notify({type:"auth_url",url:r,instructions:"A browser window should open. Complete login to finish."});try{let i=await ve(e,s,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:wo}),d;if(i.type==="callback")d=i.value;else{let c=Fu(i.input);if(c.state&&c.state!==n)throw Error("State mismatch");d=c.code}if(!d)throw Error("Missing authorization code");return await Ns(d,o,wo,e.signal)}finally{s?.close()}}async function Yu(e,t){return bs(await Vu(e,t))}var Ls={name:"OpenAI (ChatGPT Plus/Pro)",isSubscription:!0,async login(e,t){let o=await e.prompt({type:"select",message:"Select OpenAI Codex login method:",options:[{id:ws,label:"Browser login (default)"},{id:ks,label:"Device code login (headless)"}]});if(o===ks)return qu(e);if(o!==ws)throw Error(`Unknown OpenAI Codex login method: ${o}`);return Ju(e,t)},refresh:(e,t)=>Yu(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};var Qu="https://openrouter.ai/auth",Zu="https://openrouter.ai/api/v1/auth/keys",el=300000,tl=30000;function ol(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function nl(e){let t=e.trim();if(!t)return;try{return new URL(t).searchParams.get("code")??void 0}catch{}if(t.includes("code="))return new URLSearchParams(t).get("code")??void 0;return t}function rl(e){if(typeof e.error_description==="string")return e.error_description;if(typeof e.message==="string")return e.message;if(typeof e.error==="string")return e.error;if(e.error&&typeof e.error==="object"&&!Array.isArray(e.error)){let t=e.error.message;if(typeof t==="string")return t}return}async function Ms(e,t,o){if(o.aborted)throw Error("Login cancelled");let n=new AbortController,r=()=>n.abort(o.reason);o.addEventListener("abort",r,{once:!0});let s=setTimeout(()=>n.abort(Error("OpenRouter OAuth token exchange timed out")),tl),i,d={};try{i=await fetch(Zu,{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:"S256"}),signal:n.signal});try{let c=await i.json();if(c&&typeof c==="object"&&!Array.isArray(c))d=c}catch{if(i.ok)throw Error("OpenRouter OAuth returned invalid JSON")}}catch(c){if(o.aborted)throw Error("Login cancelled");if(n.signal.aborted)throw Error("OpenRouter OAuth token exchange timed out");throw c}finally{clearTimeout(s),o.removeEventListener("abort",r)}if(!i.ok){let c=rl(d);throw Error(`OpenRouter OAuth key exchange failed (HTTP ${i.status})${c?`: ${c}`:""}`)}if(typeof d.key!=="string"||d.key.length===0)throw Error('OpenRouter OAuth response carries no "key"');return{type:"oauth",access:d.key,refresh:"",expires:Number.MAX_SAFE_INTEGER}}async function sl(e){let{verifier:t,challenge:o}=await N(),n=await K({providerName:"OpenRouter",host:ol(),port:0,path:`/oauth/callback/${crypto.randomUUID()}`,complete:(r)=>Ms(r,t,e.signal),signal:e.signal,timeoutMs:el});try{let r=new URL(Qu);r.search=new URLSearchParams({callback_url:n.redirectUri,code_challenge:o,code_challenge_method:"S256"}).toString(),e.notify({type:"progress",message:`Listening for OpenRouter OAuth callback on ${n.redirectUri}`}),e.notify({type:"auth_url",url:r.toString(),instructions:"Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here."});let s=await ve(e,n,{message:"Complete sign-in in your browser, or paste the authorization code / redirect URL here:",placeholder:n.redirectUri});if(s.type==="callback")return s.value;let i=nl(s.input);if(!i)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for an API key..."}),await Ms(i,t,e.signal)}finally{n.close()}}var Us={name:"OpenRouter OAuth",loginLabel:"Sign in with OpenRouter",login:sl,async refresh(e,t){return e},async toAuth(e){return{apiKey:e.access}}};var $s="127.0.0.1",Fs=1456,Hs="/oauth/callback",Oo=`http://${$s}:${Fs}${Hs}`,il=60000,Bs="browser",Ds="device-code",Ke="pi-gateway",Ws="gateway offline_access",al="urn:ietf:params:oauth:grant-type:device_code";async function cl(e,t){let o=await fetch(new URL("/v1/oauth",e),{headers:{accept:"application/json"},signal:t});if(!o.ok)throw Error(`Could not load Radius OAuth config from ${e}: ${o.status} ${await o.text()}`);let n=await o.json();if(typeof n.authorizationEndpoint!=="string")throw Error(`Invalid Radius OAuth config from ${e}`);return{authorizationEndpoint:n.authorizationEndpoint}}class Po extends Error{status;oauthError;constructor(e,t,o,n){let r=t?o?`${t}: ${o}`:t:o||String(e);super(`${n}: ${r}`);this.status=e,this.oauthError=t}}async function Vs(e,t){let o=await e.text().catch(()=>""),n,r;if(o)try{let s=JSON.parse(o);n=typeof s.error==="string"?s.error:void 0,r=typeof s.error_description==="string"?s.error_description:void 0}catch{r=o}return new Po(e.status,n,r,t)}async function Go(e,t,o){let n;try{n=await fetch(new URL("/v1/oauth/token",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:t,signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}if(!n.ok)throw await Vs(n,"Radius OAuth token request failed");let r=await n.json();return{type:"oauth",access:r.access_token,refresh:r.refresh_token,expires:Date.now()+r.expires_in*1000-il,scope:r.scope}}async function dl(e,t,o){let{verifier:n,challenge:r}=await N(),s=crypto.randomUUID(),i=new URL(t);i.search=new URLSearchParams({response_type:"code",client_id:Ke,redirect_uri:Oo,scope:Ws,code_challenge:r,code_challenge_method:"S256",handoff:"url",state:s}).toString();let d=await K({providerName:"Radius",host:$s,port:Fs,path:Hs,state:s,complete:(c)=>Go(e,new URLSearchParams({grant_type:"authorization_code",client_id:Ke,redirect_uri:Oo,code:c,code_verifier:n}),o.signal),signal:o.signal});o.notify({type:"progress",message:`Listening for OAuth callback on ${Oo}`}),o.notify({type:"auth_url",url:i.toString(),instructions:"Continue in your browser."});try{let c=await d.wait();if(!c)throw Error("OAuth callback did not complete.");return c}finally{d.close()}}async function ul(e,t){let o;try{o=await fetch(new URL("/v1/oauth/device",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Ke,scope:Ws}),signal:t})}catch(r){if(t.aborted)throw Error("Login cancelled");throw r}if(!o.ok)throw await Vs(o,"Radius OAuth device authorization failed");let n=await o.json();if(!n.device_code||!n.user_code||!n.verification_uri||!n.expires_in)throw Error("Radius OAuth device authorization response is missing required fields");return{device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,expires_in:n.expires_in,interval:n.interval}}async function ll(e,t){let o=await ul(e,t.signal);return t.notify({type:"device_code",userCode:o.user_code,verificationUri:o.verification_uri,intervalSeconds:o.interval,expiresInSeconds:o.expires_in}),b({intervalSeconds:o.interval,expiresInSeconds:o.expires_in,signal:t.signal,poll:async()=>{try{return{status:"complete",value:await Go(e,new URLSearchParams({grant_type:al,client_id:Ke,device_code:o.device_code}),t.signal)}}catch(n){if(!(n instanceof Po))throw n;switch(n.oauthError){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down"};case"expired_token":return{status:"failed",message:"Device authorization expired."};case"access_denied":return{status:"failed",message:"Device authorization was denied."};default:throw n}}}})}function Ks(e){let t=rr(e.gateway);return{name:e.name,async login(o){let n=await o.prompt({type:"select",message:`Sign in to ${e.name}:`,options:[{id:Bs,label:"Sign in with browser (recommended)"},{id:Ds,label:"Sign in with device code (when signing in from another device)"}]});if(n===Ds)return ll(t,o);if(n===Bs){let r=await cl(t,o.signal);return dl(t,r.authorizationEndpoint,o)}throw Error(`Unknown ${e.name} sign-in method: ${n}`)},async refresh(o,n){return await Go(t,new URLSearchParams({grant_type:"refresh_token",client_id:Ke,refresh_token:o.refresh}),n)},async toAuth(o){return{apiKey:o.access}}}}var bo="b1a00492-073a-47ea-816f-4c329264a828",pl="openid profile email offline_access grok-cli:access api:access",_l="https://auth.x.ai/oauth2/device/code",zs="https://auth.x.ai/oauth2/token",hl=300000,fl=3600;function ze(e,t){let o=e[t];if(typeof o!=="string"||o.length===0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function Xs(e,t){let o=e[t];if(typeof o!=="number"||!Number.isFinite(o)||o<=0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function js(e){let t;try{t=new URL(e)}catch{throw Error("Untrusted verification URI in xAI OAuth response")}if(t.protocol!=="https:")throw Error("Untrusted verification URI in xAI OAuth response");return t.href}async function No(e,t,o){let n;try{n=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t),signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}let r;try{let s=await n.json();r=s&&typeof s==="object"&&!Array.isArray(s)?s:{}}catch{if(o.aborted)throw Error("Login cancelled");throw Error(`xAI OAuth returned invalid JSON (HTTP ${n.status})`)}return{ok:n.ok,status:n.status,body:r}}function Lo(e,t){let o=typeof t.body.error==="string"?t.body.error:void 0,n=typeof t.body.error_description==="string"?t.body.error_description:void 0,r=[o,n].filter(Boolean).join(": ");return Error(`xAI OAuth ${e} failed (HTTP ${t.status})${r?`: ${r}`:""}`)}function ml(e){let t=e.interval,o=typeof t==="number"&&Number.isFinite(t)&&t>0?t:void 0,n=typeof e.verification_uri_complete==="string"&&e.verification_uri_complete.length>0?js(e.verification_uri_complete):void 0;return{deviceCode:ze(e,"device_code"),userCode:ze(e,"user_code"),verificationUri:js(ze(e,"verification_uri")),verificationUriComplete:n,intervalSeconds:o,expiresInSeconds:Xs(e,"expires_in")}}function qs(e,t){let o=ze(e,"access_token"),n=e.refresh_token===void 0&&t?t:ze(e,"refresh_token"),r=e.expires_in===void 0?fl:Xs(e,"expires_in");return{type:"oauth",access:o,refresh:n,expires:Date.now()+r*1000-hl}}async function gl(e){let t=await No(_l,{client_id:bo,scope:pl,referrer:"pi"},e);if(!t.ok)throw Lo("device authorization",t);return ml(t.body)}async function Cl(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await No(zs,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:bo,device_code:e.deviceCode},t);if(o.ok)return{status:"complete",value:qs(o.body)};let n=o.body.error;if(n==="authorization_pending")return{status:"pending"};if(n==="slow_down"){let r=o.body.interval;return{status:"slow_down",intervalSeconds:typeof r==="number"?r:void 0}}if(n==="access_denied"||n==="authorization_denied")return{status:"failed",message:"xAI device authorization was denied"};if(n==="expired_token")return{status:"failed",message:"xAI device code expired"};return{status:"failed",message:Lo("device token polling",o).message}}})}async function Sl(e){let t=await gl(e.signal);return e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUriComplete??t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds}),Cl(t,e.signal)}async function El(e,t){let o=await No(zs,{grant_type:"refresh_token",client_id:bo,refresh_token:e},t);if(!o.ok)throw Lo("token refresh",o);return qs(o.body,e)}var Js={name:"xAI (Grok/X subscription)",isSubscription:!0,loginLabel:"Sign in with SuperGrok or X Premium",login:Sl,refresh:(e,t)=>El(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function Ys(){xi({anthropic:()=>rs,openaiCodex:()=>Ls,openaiChatGPT:()=>Ts,githubCopilot:()=>ps,openrouter:()=>Us,kimiCoding:()=>gs,meta:()=>vs,xai:()=>Js,radius:Ks})}Si(Hr);Ys();await import("./chunk-9ymm1gge.js");
96
+ </html>`}function Pt(e){return Vr({title:"Authentication successful",heading:"Authentication successful",message:e})}function P(e,t){return Vr({title:"Authentication failed",heading:"Authentication failed",message:e,details:t})}function Q(e,t,o){e.writeHead(t,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),e.end(o)}async function K(e){let{providerName:t,signal:o}=e;if(o?.aborted)throw Error("Login cancelled");let n=()=>{},r=()=>{},s=new Promise((g,h)=>{n=g,r=h});s.catch(()=>{return});let i=!1,d=!1,c,u=()=>l({error:Error("Login cancelled")}),l=(g)=>{if(d)return;if(d=!0,c)clearTimeout(c);if(o?.removeEventListener("abort",u),"error"in g)r(g.error);else n(g.value)},p=Md((g,h)=>{(async()=>{let x=new URL(g.url??"/","http://localhost");if(g.method!=="GET"||x.pathname!==e.path){Q(h,404,P("Callback route not found."));return}if(e.state!==void 0&&x.searchParams.get("state")!==e.state){Q(h,400,P("State mismatch."));return}if(i||d){Q(h,409,P("This sign-in has already been handled."));return}let I=x.searchParams.get("error");if(I){let S=x.searchParams.get("error_description")??I;Q(h,400,P(`${t} authorization failed.`,S)),l({error:Error(`${t} authorization failed: ${S}`)});return}let R=x.searchParams.get("code");if(!R){Q(h,400,P("Missing authorization code."));return}i=!0;try{let S=await e.complete(R);Q(h,200,Pt(`Signed in to ${t}. You may now close this page.`)),l({value:S})}catch(S){let D=S instanceof Error?S:Error(String(S));Q(h,502,P(`${t} sign-in failed.`,D.message)),l({error:D})}})()});await new Promise((g,h)=>{p.once("error",h),p.listen(e.port,e.host,()=>{p.off("error",h),g()})});let C=p.address();if(!C||typeof C==="string")throw p.close(),Error("OAuth callback server did not bind to TCP");if(p.on("error",(g)=>l({error:g})),o?.addEventListener("abort",u,{once:!0}),e.timeoutMs!==void 0)c=setTimeout(()=>l({error:Error(`${t} sign-in timed out`)}),e.timeoutMs);let m=e.redirectHost??e.host;return{redirectUri:`http://${m.includes(":")?`[${m}]`:m}:${C.port}${e.path}`,wait:()=>s,cancel:()=>{if(!i)l({value:void 0})},close:()=>{l({error:Error("OAuth callback server closed")}),p.close()}}}async function ve(e,t,o){let n=new AbortController,r,s=e.prompt({type:"manual_code",...o,signal:n.signal}).then((i)=>(t?.cancel(),i)).catch((i)=>{r=i instanceof Error?i:Error(String(i)),t?.cancel();return});try{let i=await t?.wait();if(r)throw r;if(i!==void 0)return{type:"callback",value:i};let d=await s;if(r)throw r;return{type:"manual",input:d??""}}finally{n.abort()}}function Kr(e){let t="";for(let o of e)t+=String.fromCharCode(o);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function N(){let e=new Uint8Array(32);crypto.getRandomValues(e);let t=Kr(e),n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=Kr(new Uint8Array(r));return{verifier:t,challenge:s}}var Ud=(e)=>atob(e),Gt=Ud("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl"),Yr="https://claude.ai/oauth/authorize",Re="https://platform.claude.com/v1/oauth/token",Bd=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Qr=53692,Zr="/callback",Dd=`http://localhost:${Qr}${Zr}`,Xr="https://platform.claude.com/oauth/code/callback",qr="browser",Jr="copy_code",es="org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";function ts(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Fe(e){if(e instanceof Error){let t=[`${e.name}: ${e.message}`],o=e;if(o.code)t.push(`code=${o.code}`);if(typeof o.errno<"u")t.push(`errno=${String(o.errno)}`);if(typeof e.cause<"u")t.push(`cause=${Fe(e.cause)}`);if(e.stack)t.push(`stack=${e.stack}`);return t.join("; ")}return String(e)}async function os(e,t,o){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t),signal:AbortSignal.any([o,AbortSignal.timeout(30000)])}),r=await n.text();if(!n.ok)throw Error(`HTTP request failed. status=${n.status}; url=${e}; body=${r}`);return r}async function ns(e,t,o,n,r){let s;try{s=await os(Re,{grant_type:"authorization_code",client_id:Gt,code:e,state:t,redirect_uri:n,code_verifier:o},r)}catch(d){throw Error(`Token exchange request failed. url=${Re}; redirect_uri=${n}; response_type=authorization_code; details=${Fe(d)}`)}let i;try{i=JSON.parse(s)}catch(d){throw Error(`Token exchange returned invalid JSON. url=${Re}; body=${s}; details=${Fe(d)}`)}return{type:"oauth",refresh:i.refresh_token,access:i.access_token,expires:Date.now()+i.expires_in*1000-300000}}async function $d(e){let{verifier:t,challenge:o}=await N(),n=(i)=>K({providerName:"Anthropic",host:Bd,port:i,path:Zr,redirectHost:"localhost",state:t,complete:async(d)=>d,signal:e.signal}),r=await n(Qr).catch(()=>n(0)).catch(()=>{return}),s=r?.redirectUri??Dd;try{let i=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:s,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${i.toString()}`,instructions:"Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."});let d=await ve(e,r,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:s}),c,u=t;if(d.type==="callback")c=d.value;else{let l=ts(d.input);if(l.state&&l.state!==t)throw Error("OAuth state mismatch");c=l.code,u=l.state??t}if(!c)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(c,u,t,s,e.signal)}finally{r?.close()}}async function Fd(e){let{verifier:t,challenge:o}=await N(),n=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:Xr,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${n.toString()}`,instructions:"Complete login in your browser, then copy the code Anthropic shows and paste it here."});let r=await e.prompt({type:"manual_code",message:"Paste the code Anthropic shows after you sign in:",placeholder:"code#state",signal:e.signal}),s=ts(r);if(s.state&&s.state!==t)throw Error("OAuth state mismatch");if(!s.code)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(s.code,s.state??t,t,Xr,e.signal)}async function Hd(e,t){let o;try{o=await os(Re,{grant_type:"refresh_token",client_id:Gt,refresh_token:e},t)}catch(r){throw Error(`Anthropic token refresh request failed. url=${Re}; details=${Fe(r)}`)}let n;try{n=JSON.parse(o)}catch(r){throw Error(`Anthropic token refresh returned invalid JSON. url=${Re}; body=${o}; details=${Fe(r)}`)}return{type:"oauth",refresh:n.refresh_token,access:n.access_token,expires:Date.now()+n.expires_in*1000-300000}}var rs={name:"Anthropic (Claude Pro/Max)",isSubscription:!0,async login(e){let t=await e.prompt({type:"select",message:"Select Anthropic login method:",options:[{id:qr,label:"Browser login (default)"},{id:Jr,label:"Copy code login (headless)"}]});if(t===Jr)return Fd(e);if(t!==qr)throw Error(`Unknown Anthropic login method: ${t}`);return $d(e)},refresh:(e,t)=>Hd(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function bt(e,t){return new Promise((o,n)=>{t.throwIfAborted();let r=()=>{clearTimeout(s),n(t.reason)},s=setTimeout(()=>{t.removeEventListener("abort",r),o()},e);t.addEventListener("abort",r,{once:!0})})}function ss(e,t,o){return new Promise((n,r)=>{if(t.aborted){r(Error(o));return}let s=()=>{clearTimeout(i),r(Error(o))},i=setTimeout(()=>{t.removeEventListener("abort",s),n()},e);t.addEventListener("abort",s,{once:!0})})}async function b(e){let t=typeof e.expiresInSeconds==="number"?Date.now()+e.expiresInSeconds*1000:Number.POSITIVE_INFINITY,o=Math.max(1000,Math.floor((e.intervalSeconds??5)*1000)),n=0;if(e.waitBeforeFirstPoll){let r=t-Date.now();if(r>0)await ss(Math.min(o,r),e.signal,"Login cancelled")}while(Date.now()<t){if(e.signal.aborted)throw Error("Login cancelled");let r=await e.poll();if(r.status==="complete")return r.value;if(r.status==="failed")throw Error(r.message);if(r.status==="slow_down")n+=1,o=typeof r.intervalSeconds==="number"&&Number.isFinite(r.intervalSeconds)&&r.intervalSeconds>0?Math.max(1000,Math.floor(r.intervalSeconds*1000)):Math.max(1000,o+5000);let s=t-Date.now();if(s<=0)break;await ss(Math.min(o,s),e.signal,"Login cancelled")}throw Error(n>0?"Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.":"Device flow timed out")}var Wd=(e)=>atob(e),as=Wd("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),lo={"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},Vd="2026-06-01";function cs(e){let t=e.trim();if(!t)return null;try{return(t.includes("://")?new URL(t):new URL(`https://${t}`)).hostname}catch{return null}}function po(e){return{deviceCodeUrl:`https://${e}/login/device/code`,accessTokenUrl:`https://${e}/login/oauth/access_token`,copilotTokenUrl:`https://api.${e}/copilot_internal/v2/token`}}function Kd(e){let t=e.match(/proxy-ep=([^;]+)/);if(!t)return null;return`https://${t[1].replace(/^proxy\./,"api.")}`}function _o(e,t){if(e){let o=Kd(e);if(o)return o}if(t)return`https://copilot-api.${t}`;return"https://api.individual.githubcopilot.com"}function We(e){return e&&typeof e==="object"?e:void 0}function jd(e,t){let o=We(e)?.data;if(!Array.isArray(o))throw Error("Invalid Copilot models response");let n=o.flatMap((c)=>{let u=We(c),l=u?.id;if(!u||typeof l!=="string")return[];let p=We(u.capabilities);if(We(p?.supports)?.tool_calls===!1)return[];return[{id:l,pickerEnabled:u.model_picker_enabled===!0,policyState:We(u.policy)?.state}]}),r=n.filter((c)=>c.pickerEnabled&&c.policyState!=="disabled").map((c)=>c.id),s=t&&r.length===0,i=r.length>0||!t?r:n.filter((c)=>c.policyState==="enabled").map((c)=>c.id),d=n.filter((c)=>c.policyState==="unconfigured"&&Object.hasOwn($r,c.id)&&(c.pickerEnabled||s)).map((c)=>c.id);return{availableModelIds:i,policyModelIds:d}}async function ds(e,t,o,n){let r=n.maxRetries>0&&n.maxElapsedMs>0?AbortSignal.timeout(n.maxElapsedMs):void 0,s=r?AbortSignal.any([o,r]):o,i=r?Date.now()+n.maxElapsedMs:void 0;for(let d=0;;d++){let c=await fetch(e,{...t,signal:AbortSignal.any([s,AbortSignal.timeout(5000)])});if(c.status!==429||d===n.maxRetries)return c;let u=c.headers.get("retry-after"),l=500*2**d;if(u){let p=Number.parseFloat(u);if(l=Number.isNaN(p)?Date.parse(u)-Date.now():p*1000,!Number.isFinite(l))return c}if(l=Math.max(0,l),i!==void 0&&l>=i-Date.now())return c;await c.body?.cancel(),await bt(l,s)}}async function us(e,t,o,n){let r=_o(e,t),s=r==="https://api.individual.githubcopilot.com",i=await ds(`${r}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo,"X-GitHub-Api-Version":Vd}},o,n);if(!i.ok)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return jd(await i.json(),s)}async function ho(e,t){let o=await fetch(e,t);if(!o.ok){let n=await o.text();throw Error(`${o.status} ${o.statusText}: ${n}`)}return o.json()}async function zd(e,t){let o=po(e),n=await ho(o.deviceCodeUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,scope:"read:user"}),signal:t});if(!n||typeof n!=="object")throw Error("Invalid device code response");let{device_code:r,user_code:s,verification_uri:i,interval:d,expires_in:c}=n;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||d!==void 0&&typeof d!=="number"||typeof c!=="number")throw Error("Invalid device code response fields");let u;try{u=new URL(i)}catch{throw Error("Untrusted verification_uri in device code response")}if(u.protocol!=="https:"&&u.protocol!=="http:")throw Error("Untrusted verification_uri in device code response");return{device_code:r,user_code:s,verification_uri:u.href,interval:d,expires_in:c}}async function Xd(e,t,o){let n=po(e);return b({intervalSeconds:t.interval,expiresInSeconds:t.expires_in,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let r=await ho(n.accessTokenUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,device_code:t.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:o});if(r&&typeof r==="object"&&typeof r.access_token==="string")return{status:"complete",value:r.access_token};if(r&&typeof r==="object"&&typeof r.error==="string"){let{error:s,error_description:i,interval:d}=r;if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down")return{status:"slow_down",intervalSeconds:typeof d==="number"?d:void 0};let c=i?`: ${i}`:"";return{status:"failed",message:`Device flow failed: ${s}${c}`}}return{status:"failed",message:"Invalid device token response"}}})}async function ls(e,t,o){let r=po(t||"github.com"),s=await ho(r.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo},signal:o});if(!s||typeof s!=="object")throw Error("Invalid Copilot token response");let{token:i,expires_at:d}=s;if(typeof i!=="string"||typeof d!=="number")throw Error("Invalid Copilot token response fields");return{type:"oauth",refresh:e,access:i,expires:d*1000-300000,enterpriseUrl:t}}async function qd(e,t,o){let n=await ls(e,t,o),{availableModelIds:r}=await us(n.access,t,o,{maxRetries:0,maxElapsedMs:0});return{...n,availableModelIds:r}}async function Jd(e,t,o,n){let s=`${_o(e,o)}/models/${t}/policy`,i;try{i=await ds(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,...lo,"openai-intent":"chat-policy","x-interaction-type":"chat-policy"},body:JSON.stringify({state:"enabled"})},n,{maxRetries:2,maxElapsedMs:5000})}catch(d){if(n.aborted)throw d;return!1}if(i.status===429)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return i.ok}async function Yd(e,t,o,n){let r=[];for(let s of t)try{if(await Jd(e,s,o,n))r.push(s)}catch(i){if(n.aborted)throw i;break}return r}async function Qd(e){let t=await e.prompt({type:"text",message:"GitHub Enterprise URL/domain (blank for github.com)",placeholder:"company.ghe.com"});if(e.signal.aborted)throw Error("Login cancelled");let o=t.trim(),n=cs(t);if(o&&!n)throw Error("Invalid GitHub Enterprise URL/domain");let r=n||"github.com",s=await zd(r,e.signal);e.notify({type:"device_code",userCode:s.user_code,verificationUri:s.verification_uri,intervalSeconds:s.interval,expiresInSeconds:s.expires_in});let i=await Xd(r,s,e.signal),d=await ls(i,n??void 0,e.signal),c=await us(d.access,n??void 0,e.signal,{maxRetries:2,maxElapsedMs:5000}),u=[];if(c.policyModelIds.length>0)e.notify({type:"progress",message:"Enabling models..."}),u=await Yd(d.access,c.policyModelIds,n??void 0,e.signal);return{...d,availableModelIds:[...new Set([...c.availableModelIds,...u])]}}function is(e){let t=e.enterpriseUrl;if(typeof t!=="string"||!t)return;return cs(t)??void 0}var ps={name:"GitHub Copilot",isSubscription:!0,login:Qd,refresh:(e,t)=>qd(e.refresh,is(e),t),async toAuth(e){return{apiKey:e.access,baseUrl:_o(e.access,is(e))}}};var fo="17e5f671-d194-4dfb-9706-5516cb48c098",Zd="https://auth.kimi.com",eu=900,tu=5,ou=30000,_s=3;function fs(){return(_("KIMI_CODE_OAUTH_HOST")||_("KIMI_OAUTH_HOST")||Zd).replace(/\/+$/,"")}function mo(e){return AbortSignal.any([AbortSignal.timeout(ou),e])}function go(e){return new URLSearchParams(e).toString()}async function Co(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function hs(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}async function nu(e,t){let o=await fetch(`${e}/api/oauth/device_authorization`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo}),signal:mo(t)});if(!o.ok){let l=await o.text().catch(()=>"");throw Error(`Kimi Code device authorization failed with status ${o.status}${l?`: ${l}`:""}`)}let n=await Co(o),r=n?.device_code,s=n?.user_code,i=n?.verification_uri,d=n?.verification_uri_complete;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||typeof d!=="string"||!hs(d)||!hs(i))throw Error(`Invalid Kimi Code device authorization response: ${JSON.stringify(n)}`);let c=n?.interval,u=n?.expires_in;return{deviceCode:r,userCode:s,verificationUri:i,verificationUriComplete:d,intervalSeconds:typeof c==="number"&&Number.isFinite(c)&&c>0?c:tu,expiresInSeconds:typeof u==="number"&&Number.isFinite(u)&&u>0?u:eu}}function ms(e,t){let o=e?.access_token,n=e?.refresh_token,r=e?.expires_in;if(typeof o!=="string"||!o||typeof n!=="string"||!n||typeof r!=="number"||!Number.isFinite(r)||r<=0)throw Error(`Kimi Code token ${t} response missing fields: ${JSON.stringify(e)}`);return{access:o,refresh:n,expires:Date.now()+r*1000}}async function ru(e,t,o){return b({intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let n=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,device_code:t.deviceCode,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:mo(o)});if(n.status>=500){let d=await n.text().catch(()=>"");return{status:"failed",message:`Kimi Code device token request failed with status ${n.status}${d?`: ${d}`:""}`}}let r=await Co(n);if(n.ok&&typeof r?.access_token==="string")try{return{status:"complete",value:ms(r,"poll")}}catch(d){return{status:"failed",message:d instanceof Error?d.message:String(d)}}let s=r?.error,i=typeof r?.error_description==="string"?`: ${r.error_description}`:"";if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down"){let d=r?.interval;return{status:"slow_down",intervalSeconds:typeof d==="number"&&d>0?d:void 0}}if(s==="expired_token")return{status:"failed",message:"Kimi Code device authorization expired. Please restart login."};if(s==="access_denied")return{status:"failed",message:"Kimi Code login was denied."};return{status:"failed",message:`Kimi Code device token request failed (status ${n.status})${typeof s==="string"?`: ${s}${i}`:""}`}}})}function su(e){return e.status===429||e.status>=500}async function iu(e,t,o){let n;for(let r=0;r<=_s;r++){if(r>0)await bt(1000*2**(r-1),o);if(o.aborted)throw Error("Kimi Code token refresh aborted");let s;try{s=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,grant_type:"refresh_token",refresh_token:t}),signal:mo(o)})}catch(c){n=c instanceof Error?c:Error(String(c));continue}let i=await Co(s);if(s.ok)return ms(i,"refresh");if(s.status===401||s.status===403||i?.error==="invalid_grant"){let c=typeof i?.error_description==="string"?`: ${i.error_description}`:"";throw Error(`Kimi Code token refresh unauthorized (status ${s.status})${c}`)}if(su(s)&&r<_s){n=Error(`Kimi Code token refresh failed with status ${s.status}`);continue}let d=JSON.stringify(i);throw Error(`Kimi Code token refresh failed with status ${s.status}${d?`: ${d}`:""}`)}throw n??Error("Kimi Code token refresh failed")}async function au(e){let t=fs(),o=await nu(t,e.signal);e.notify({type:"device_code",userCode:o.userCode,verificationUri:o.verificationUriComplete,intervalSeconds:o.intervalSeconds,expiresInSeconds:o.expiresInSeconds});let n=await ru(t,o,e.signal);return{type:"oauth",access:n.access,refresh:n.refresh,expires:n.expires}}var gs={name:"Kimi Code (subscription)",isSubscription:!0,loginLabel:"Sign in with Kimi Code",login:au,refresh:async(e,t)=>{let o=await iu(fs(),e.refresh,t);return{type:"oauth",access:o.access,refresh:o.refresh,expires:o.expires}},async toAuth(e){return{headers:{Authorization:`Bearer ${e.access}`}}}};var Cs="1031625952748946",Ss="https://auth.meta.com",cu=`${Ss}/oidc/device/authorization/`,du=`${Ss}/oidc/device/token/`,uu="https://api.meta.ai/muse-code/key",lu=86400000,pu=30000;function vo(e){return AbortSignal.any([AbortSignal.timeout(pu),e])}async function Ao(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function Nt(e){for(let t of["error_description","detail","message","error"]){let o=e?.[t];if(typeof o==="string"&&o.trim())return`: ${o.trim()}`}return""}function So(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}function Eo(e){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:void 0}async function _u(e){let t=await fetch(cu,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:Cs}).toString(),signal:vo(e)}),o=await Ao(t);if(!t.ok)throw Error(`Meta device authorization failed with status ${t.status}${Nt(o)}`);let n=o?.device_code,r=o?.user_code,s=So(o?.verification_uri_complete)??So(o?.verification_uri);if(typeof n!=="string"||!n||typeof r!=="string"||!r||!s)throw Error(`Invalid Meta device authorization response: ${JSON.stringify(o)}`);return{deviceCode:n,userCode:r,verificationUri:s,intervalSeconds:Eo(o?.interval),expiresInSeconds:Eo(o?.expires_in)}}async function hu(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await fetch(du,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e.deviceCode,client_id:Cs}).toString(),signal:vo(t)}),n=await Ao(o);if(o.ok&&typeof n?.access_token==="string"&&n.access_token)return{status:"complete",value:n.access_token};switch(n?.error){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down",intervalSeconds:Eo(n?.interval)};case"access_denied":return{status:"failed",message:"Meta login was denied."};case"expired_token":return{status:"failed",message:"Meta device authorization expired. Please restart login."};default:return{status:"failed",message:`Meta device token request failed with status ${o.status}${Nt(n)}`}}}})}async function Es(e,t){let o=await fetch(uu,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","x-api-version":"1.0.0"},body:"{}",signal:vo(t)}),n=await Ao(o);if(o.status===401||o.status===403)throw Error(`Meta session expired (status ${o.status}). Run \`/login meta\` to sign in again.${Nt(n)}`);if(!o.ok)throw Error(`Meta API key mint failed with status ${o.status}${Nt(n)}`);let r=n?.api_key;if(typeof r!=="string"||!r){let s=So(n?.action_url);throw Error(`Meta did not issue an API key.${s?` Complete setup at ${s}`:""}`)}return{type:"oauth",refresh:e,access:r,expires:Date.now()+lu}}async function fu(e){try{let t=await _u(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds});let o=await hu(t,e.signal);return e.notify({type:"progress",message:"Enabling Meta Model API access..."}),await Es(o,e.signal)}catch(t){if(e.signal.aborted)throw Error("Login cancelled");throw t}}var vs={name:"Meta (Muse subscription)",isSubscription:!0,loginLabel:"Sign in with Meta",login:fu,refresh:(e,t)=>Es(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};import{randomBytes as mu}from"crypto";import{createServer as gu}from"http";var Cu="dynamic_agent_client",Su="Pi",Eu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,vu="https://auth.openai.com/api/accounts/authorize",Au="https://auth.openai.com/api/accounts/oauth/token",xo="https://api.openai.com/v1",Ru=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Io=1455,Rs="/auth/callback",ye=`http://127.0.0.1:${Io}${Rs}`,yo="chatgpt.tokens.use.direct",yu=`openid profile email offline_access resource.invoke ${yo}`,xu=180000;function As(){return mu(32).toString("base64url")}function ys(e,t){let o=e.searchParams.get("code");if(!o)throw Error("Missing authorization code");let n=e.searchParams.get("state");if(!n)throw Error("Missing OAuth state");if(n!==t)throw Error("OAuth state mismatch");let r=e.searchParams.get("client_id")?.trim();if(!r)throw Error("OpenAI OAuth registration callback did not contain an issued client ID");return{code:o,clientId:r}}function Iu(e,t){let o;try{o=new URL(e.trim())}catch{throw Error("Paste the full callback URL from the browser")}let n=new URL(ye);if(o.origin!==n.origin||o.pathname!==n.pathname)throw Error(`The pasted callback URL must start with ${ye}`);let r=o.searchParams.get("error");if(r)throw Error(`ChatGPT authorization failed: ${r}`);return ys(o,t)}function Ve(e,t,o){e.writeHead(t,{"Content-Type":"text/html; charset=utf-8"}),e.end(o)}function Tu(e){return new Promise((t,o)=>{let n,r,s=new Promise((d,c)=>{n=d,r=c}),i=gu((d,c)=>{try{let u=new URL(d.url||"",ye);if(u.pathname!==Rs){Ve(c,404,P("Callback route not found."));return}let l=u.searchParams.get("error");if(l){Ve(c,400,P("ChatGPT was not connected.",`Error: ${l}`)),r(Error(`ChatGPT authorization failed: ${l}`));return}let p;try{p=ys(u,e)}catch(C){let m=C instanceof Error?C.message:"Invalid callback";Ve(c,400,P(m));return}Ve(c,200,Pt("ChatGPT authentication completed. You can close this window.")),n(p)}catch{Ve(c,500,P("Internal error while processing the callback."))}});i.once("error",o),i.listen(Io,Ru,()=>{i.removeListener("error",o),i.on("error",r),t({server:i,result:s})})})}async function xs(e,t){let o=await fetch(Au,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:e,signal:t});if(!o.ok){let r=await o.text().catch(()=>"");throw Error(`OpenAI OAuth token request failed (${o.status}): ${r||o.statusText}`)}let n=await o.json();if(typeof n!=="object"||n===null||Array.isArray(n))throw Error("OpenAI OAuth token response must be an object");return n}function Ro(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`OpenAI OAuth token response has invalid ${t}`);return e}function Is(e,t,o){let n=Ro(e.access_token,"access_token"),r=Ro(e.refresh_token,"refresh_token"),s=Ro(e.scope,"scope"),i=typeof e.id_token==="string"?e.id_token:o?.idToken;if(typeof e.expires_in!=="number"||!Number.isFinite(e.expires_in)||e.expires_in<=0)throw Error("OpenAI OAuth token response has invalid expires_in");let d=s.trim().split(/\s+/).filter(Boolean);if(!d.includes(yo))throw Error(`OpenAI OAuth grant did not include ${yo}`);return{type:"oauth",...i?{idToken:i}:{},access:n,refresh:r,expires:Date.now()+e.expires_in*1000-xu,clientId:t,scopes:d}}async function wu(e,t,o,n){let r=await xs(new URLSearchParams({grant_type:"authorization_code",client_id:o,code:e,code_verifier:t,redirect_uri:ye,resource:xo}),n);if(typeof r.id_token!=="string"||r.id_token.trim().length===0)throw Error("OpenAI OAuth token response did not contain an ID token");return Is(r,o)}async function ku(e,t){let o=e.clientId;if(typeof o!=="string"||o.trim().length===0)throw Error("Stored OpenAI OAuth credential does not contain an issued client ID; reconnect ChatGPT");let n=await xs(new URLSearchParams({grant_type:"refresh_token",client_id:o,refresh_token:e.refresh,resource:xo}),t);return Is(n,o,e)}function Ou(e){if(!e||!Eu.test(e))throw Error("Sign in with ChatGPT requires a device ID (UUID) for this installation");return`urn:uuid:${e.toLowerCase()}`}async function Pu(e,t){let o=Ou(t?.getDeviceId?.()),{verifier:n,challenge:r}=await N(),s=As(),i=As(),d=await Tu(s).catch((p)=>{if(!(p instanceof Error&&("code"in p)&&p.code==="EADDRINUSE"))throw p;throw Error(`Port ${Io} is in use, probably by an unfinished login in another pi session or by the Codex CLI. Cancel that login and try again.`)}),c=new URL(vu);c.search=new URLSearchParams({client_id:Cu,agent_name_hint:t?.agentName??Su,ext_agent_host_id:o,response_type:"code",redirect_uri:ye,resource:xo,scope:yu,state:s,code_challenge:r,code_challenge_method:"S256",nonce:i}).toString(),e.notify({type:"auth_url",url:c.toString(),instructions:"Complete sign-in in your browser. If the callback does not complete, paste the final redirect URL here."});let u=new AbortController,l=e.prompt({type:"manual_code",message:"Complete login in your browser, or paste the final redirect URL here:",placeholder:ye,signal:AbortSignal.any([u.signal,e.signal])}).then((p)=>Iu(p,s));try{let p=await Promise.race([d.result,l]);return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await wu(p.code,n,p.clientId,e.signal)}catch(p){if(e.signal.aborted)throw Error("Login cancelled");throw p}finally{u.abort(),d.server.close(),d.server.closeAllConnections()}}var Ts={name:"OpenAI (ChatGPT subscription)",isSubscription:!0,loginLabel:"Sign in with ChatGPT",login:Pu,refresh:ku,async toAuth(e){return{apiKey:e.access}}};var To=null;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))import("crypto").then((e)=>{To=e.randomBytes});var Lt="app_EMoamEEZ73f0CkXaXp7hrann",xe="https://auth.openai.com",Gu=`${xe}/oauth/authorize`,Os=`${xe}/oauth/token`,wo="http://localhost:1455/auth/callback",bu=`${xe}/api/accounts/deviceauth/usercode`,Nu=`${xe}/api/accounts/deviceauth/token`,Lu=`${xe}/codex/device`,Mu=`${xe}/deviceauth/callback`,Ps=900,ws="browser",ks="device_code",Uu="openid profile email offline_access",Bu="https://api.openai.com/auth";function Du(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function $u(){if(!To)throw Error("OpenAI Codex OAuth is only available in Node.js environments");return To(16).toString("hex")}function Fu(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Hu(e){try{let t=e.split(".");if(t.length!==3)return null;let o=t[1]??"",n=atob(o);return JSON.parse(n)}catch{return null}}async function ko(e,t){try{return await fetch(e,t)}catch(o){if(t.signal?.aborted)throw Error("Login cancelled");throw o}}async function Gs(e,t){if(!e.ok){let r=await e.text().catch(()=>"");throw Error(`OpenAI Codex token ${t} failed (${e.status}): ${r||e.statusText}`)}let n=await e.json();if(!n?.access_token||!n.refresh_token||typeof n.expires_in!=="number")throw Error(`OpenAI Codex token ${t} response missing fields: ${JSON.stringify(n)}`);return{access:n.access_token,refresh:n.refresh_token,expires:Date.now()+n.expires_in*1000}}async function Wu(e,t,o,n){let r=await ko(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:Lt,code:e,code_verifier:t,redirect_uri:o}),signal:n});return Gs(r,"exchange")}async function Vu(e,t){let o;try{o=await fetch(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:Lt}),signal:t})}catch(n){throw Error(`OpenAI Codex token refresh error: ${n instanceof Error?n.message:String(n)}`)}return Gs(o,"refresh")}async function Ku(e){let t=await ko(bu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:Lt}),signal:e});if(!t.ok){if(t.status===404)throw Error("OpenAI Codex device code login is not enabled for this server. Use browser login or verify the server URL.");let s=await t.text().catch(()=>"");throw Error(`OpenAI Codex device code request failed with status ${t.status}${s?`: ${s}`:""}`)}let n=await t.json(),r=typeof n?.interval==="string"?Number(n.interval.trim()):n?.interval;if(!n?.device_auth_id||!n.user_code||typeof r!=="number"||!Number.isFinite(r)||r<0)throw Error(`Invalid OpenAI Codex device code response: ${JSON.stringify(n)}`);return{deviceAuthId:n.device_auth_id,userCode:n.user_code,intervalSeconds:r}}async function ju(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:Ps,signal:t,poll:async()=>{let o=await ko(Nu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_auth_id:e.deviceAuthId,user_code:e.userCode}),signal:t});if(o.ok){let i=await o.json();if(!i?.authorization_code||!i.code_verifier)return{status:"failed",message:`Invalid OpenAI Codex device auth token response: ${JSON.stringify(i)}`};return{status:"complete",value:{authorizationCode:i.authorization_code,codeVerifier:i.code_verifier}}}if(o.status===403||o.status===404)return{status:"pending"};let n=await o.text().catch(()=>""),r;try{let i=JSON.parse(n)?.error;r=typeof i==="object"?i?.code:i}catch{}if(r==="deviceauth_authorization_pending")return{status:"pending"};if(r==="slow_down")return{status:"slow_down"};return{status:"failed",message:`OpenAI Codex device auth failed with status ${o.status}${n?`: ${n}`:""}`}}})}async function zu(e="pi"){let{verifier:t,challenge:o}=await N(),n=$u(),r=new URL(Gu);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",Lt),r.searchParams.set("redirect_uri",wo),r.searchParams.set("scope",Uu),r.searchParams.set("code_challenge",o),r.searchParams.set("code_challenge_method","S256"),r.searchParams.set("state",n),r.searchParams.set("id_token_add_organizations","true"),r.searchParams.set("codex_cli_simplified_flow","true"),r.searchParams.set("originator",e),{verifier:t,state:n,url:r.toString()}}function Xu(e){let n=Hu(e)?.[Bu]?.chatgpt_account_id;return typeof n==="string"&&n.length>0?n:null}function bs(e){let t=Xu(e.access);if(!t)throw Error("Failed to extract accountId from token");return{type:"oauth",access:e.access,refresh:e.refresh,expires:e.expires,accountId:t}}async function Ns(e,t,o,n){return bs(await Wu(e,t,o,n))}async function qu(e){let t=await Ku(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:Lu,intervalSeconds:t.intervalSeconds,expiresInSeconds:Ps});let o=await ju(t,e.signal);return Ns(o.authorizationCode,o.codeVerifier,Mu,e.signal)}async function Ju(e,t){let{verifier:o,state:n,url:r}=await zu(t?.agentName),s=await K({providerName:"OpenAI",host:Du(),port:1455,path:"/auth/callback",state:n,complete:async(i)=>i,signal:e.signal}).catch(()=>{return});e.notify({type:"auth_url",url:r,instructions:"A browser window should open. Complete login to finish."});try{let i=await ve(e,s,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:wo}),d;if(i.type==="callback")d=i.value;else{let c=Fu(i.input);if(c.state&&c.state!==n)throw Error("State mismatch");d=c.code}if(!d)throw Error("Missing authorization code");return await Ns(d,o,wo,e.signal)}finally{s?.close()}}async function Yu(e,t){return bs(await Vu(e,t))}var Ls={name:"OpenAI (ChatGPT Plus/Pro)",isSubscription:!0,async login(e,t){let o=await e.prompt({type:"select",message:"Select OpenAI Codex login method:",options:[{id:ws,label:"Browser login (default)"},{id:ks,label:"Device code login (headless)"}]});if(o===ks)return qu(e);if(o!==ws)throw Error(`Unknown OpenAI Codex login method: ${o}`);return Ju(e,t)},refresh:(e,t)=>Yu(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};var Qu="https://openrouter.ai/auth",Zu="https://openrouter.ai/api/v1/auth/keys",el=300000,tl=30000;function ol(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function nl(e){let t=e.trim();if(!t)return;try{return new URL(t).searchParams.get("code")??void 0}catch{}if(t.includes("code="))return new URLSearchParams(t).get("code")??void 0;return t}function rl(e){if(typeof e.error_description==="string")return e.error_description;if(typeof e.message==="string")return e.message;if(typeof e.error==="string")return e.error;if(e.error&&typeof e.error==="object"&&!Array.isArray(e.error)){let t=e.error.message;if(typeof t==="string")return t}return}async function Ms(e,t,o){if(o.aborted)throw Error("Login cancelled");let n=new AbortController,r=()=>n.abort(o.reason);o.addEventListener("abort",r,{once:!0});let s=setTimeout(()=>n.abort(Error("OpenRouter OAuth token exchange timed out")),tl),i,d={};try{i=await fetch(Zu,{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:"S256"}),signal:n.signal});try{let c=await i.json();if(c&&typeof c==="object"&&!Array.isArray(c))d=c}catch{if(i.ok)throw Error("OpenRouter OAuth returned invalid JSON")}}catch(c){if(o.aborted)throw Error("Login cancelled");if(n.signal.aborted)throw Error("OpenRouter OAuth token exchange timed out");throw c}finally{clearTimeout(s),o.removeEventListener("abort",r)}if(!i.ok){let c=rl(d);throw Error(`OpenRouter OAuth key exchange failed (HTTP ${i.status})${c?`: ${c}`:""}`)}if(typeof d.key!=="string"||d.key.length===0)throw Error('OpenRouter OAuth response carries no "key"');return{type:"oauth",access:d.key,refresh:"",expires:Number.MAX_SAFE_INTEGER}}async function sl(e){let{verifier:t,challenge:o}=await N(),n=await K({providerName:"OpenRouter",host:ol(),port:0,path:`/oauth/callback/${crypto.randomUUID()}`,complete:(r)=>Ms(r,t,e.signal),signal:e.signal,timeoutMs:el});try{let r=new URL(Qu);r.search=new URLSearchParams({callback_url:n.redirectUri,code_challenge:o,code_challenge_method:"S256"}).toString(),e.notify({type:"progress",message:`Listening for OpenRouter OAuth callback on ${n.redirectUri}`}),e.notify({type:"auth_url",url:r.toString(),instructions:"Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here."});let s=await ve(e,n,{message:"Complete sign-in in your browser, or paste the authorization code / redirect URL here:",placeholder:n.redirectUri});if(s.type==="callback")return s.value;let i=nl(s.input);if(!i)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for an API key..."}),await Ms(i,t,e.signal)}finally{n.close()}}var Us={name:"OpenRouter OAuth",loginLabel:"Sign in with OpenRouter",login:sl,async refresh(e,t){return e},async toAuth(e){return{apiKey:e.access}}};var $s="127.0.0.1",Fs=1456,Hs="/oauth/callback",Oo=`http://${$s}:${Fs}${Hs}`,il=60000,Bs="browser",Ds="device-code",Ke="pi-gateway",Ws="gateway offline_access",al="urn:ietf:params:oauth:grant-type:device_code";async function cl(e,t){let o=await fetch(new URL("/v1/oauth",e),{headers:{accept:"application/json"},signal:t});if(!o.ok)throw Error(`Could not load Radius OAuth config from ${e}: ${o.status} ${await o.text()}`);let n=await o.json();if(typeof n.authorizationEndpoint!=="string")throw Error(`Invalid Radius OAuth config from ${e}`);return{authorizationEndpoint:n.authorizationEndpoint}}class Po extends Error{status;oauthError;constructor(e,t,o,n){let r=t?o?`${t}: ${o}`:t:o||String(e);super(`${n}: ${r}`);this.status=e,this.oauthError=t}}async function Vs(e,t){let o=await e.text().catch(()=>""),n,r;if(o)try{let s=JSON.parse(o);n=typeof s.error==="string"?s.error:void 0,r=typeof s.error_description==="string"?s.error_description:void 0}catch{r=o}return new Po(e.status,n,r,t)}async function Go(e,t,o){let n;try{n=await fetch(new URL("/v1/oauth/token",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:t,signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}if(!n.ok)throw await Vs(n,"Radius OAuth token request failed");let r=await n.json();return{type:"oauth",access:r.access_token,refresh:r.refresh_token,expires:Date.now()+r.expires_in*1000-il,scope:r.scope}}async function dl(e,t,o){let{verifier:n,challenge:r}=await N(),s=crypto.randomUUID(),i=new URL(t);i.search=new URLSearchParams({response_type:"code",client_id:Ke,redirect_uri:Oo,scope:Ws,code_challenge:r,code_challenge_method:"S256",handoff:"url",state:s}).toString();let d=await K({providerName:"Radius",host:$s,port:Fs,path:Hs,state:s,complete:(c)=>Go(e,new URLSearchParams({grant_type:"authorization_code",client_id:Ke,redirect_uri:Oo,code:c,code_verifier:n}),o.signal),signal:o.signal});o.notify({type:"progress",message:`Listening for OAuth callback on ${Oo}`}),o.notify({type:"auth_url",url:i.toString(),instructions:"Continue in your browser."});try{let c=await d.wait();if(!c)throw Error("OAuth callback did not complete.");return c}finally{d.close()}}async function ul(e,t){let o;try{o=await fetch(new URL("/v1/oauth/device",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Ke,scope:Ws}),signal:t})}catch(r){if(t.aborted)throw Error("Login cancelled");throw r}if(!o.ok)throw await Vs(o,"Radius OAuth device authorization failed");let n=await o.json();if(!n.device_code||!n.user_code||!n.verification_uri||!n.expires_in)throw Error("Radius OAuth device authorization response is missing required fields");return{device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,expires_in:n.expires_in,interval:n.interval}}async function ll(e,t){let o=await ul(e,t.signal);return t.notify({type:"device_code",userCode:o.user_code,verificationUri:o.verification_uri,intervalSeconds:o.interval,expiresInSeconds:o.expires_in}),b({intervalSeconds:o.interval,expiresInSeconds:o.expires_in,signal:t.signal,poll:async()=>{try{return{status:"complete",value:await Go(e,new URLSearchParams({grant_type:al,client_id:Ke,device_code:o.device_code}),t.signal)}}catch(n){if(!(n instanceof Po))throw n;switch(n.oauthError){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down"};case"expired_token":return{status:"failed",message:"Device authorization expired."};case"access_denied":return{status:"failed",message:"Device authorization was denied."};default:throw n}}}})}function Ks(e){let t=rr(e.gateway);return{name:e.name,async login(o){let n=await o.prompt({type:"select",message:`Sign in to ${e.name}:`,options:[{id:Bs,label:"Sign in with browser (recommended)"},{id:Ds,label:"Sign in with device code (when signing in from another device)"}]});if(n===Ds)return ll(t,o);if(n===Bs){let r=await cl(t,o.signal);return dl(t,r.authorizationEndpoint,o)}throw Error(`Unknown ${e.name} sign-in method: ${n}`)},async refresh(o,n){return await Go(t,new URLSearchParams({grant_type:"refresh_token",client_id:Ke,refresh_token:o.refresh}),n)},async toAuth(o){return{apiKey:o.access}}}}var bo="b1a00492-073a-47ea-816f-4c329264a828",pl="openid profile email offline_access grok-cli:access api:access",_l="https://auth.x.ai/oauth2/device/code",zs="https://auth.x.ai/oauth2/token",hl=300000,fl=3600;function ze(e,t){let o=e[t];if(typeof o!=="string"||o.length===0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function Xs(e,t){let o=e[t];if(typeof o!=="number"||!Number.isFinite(o)||o<=0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function js(e){let t;try{t=new URL(e)}catch{throw Error("Untrusted verification URI in xAI OAuth response")}if(t.protocol!=="https:")throw Error("Untrusted verification URI in xAI OAuth response");return t.href}async function No(e,t,o){let n;try{n=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t),signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}let r;try{let s=await n.json();r=s&&typeof s==="object"&&!Array.isArray(s)?s:{}}catch{if(o.aborted)throw Error("Login cancelled");throw Error(`xAI OAuth returned invalid JSON (HTTP ${n.status})`)}return{ok:n.ok,status:n.status,body:r}}function Lo(e,t){let o=typeof t.body.error==="string"?t.body.error:void 0,n=typeof t.body.error_description==="string"?t.body.error_description:void 0,r=[o,n].filter(Boolean).join(": ");return Error(`xAI OAuth ${e} failed (HTTP ${t.status})${r?`: ${r}`:""}`)}function ml(e){let t=e.interval,o=typeof t==="number"&&Number.isFinite(t)&&t>0?t:void 0,n=typeof e.verification_uri_complete==="string"&&e.verification_uri_complete.length>0?js(e.verification_uri_complete):void 0;return{deviceCode:ze(e,"device_code"),userCode:ze(e,"user_code"),verificationUri:js(ze(e,"verification_uri")),verificationUriComplete:n,intervalSeconds:o,expiresInSeconds:Xs(e,"expires_in")}}function qs(e,t){let o=ze(e,"access_token"),n=e.refresh_token===void 0&&t?t:ze(e,"refresh_token"),r=e.expires_in===void 0?fl:Xs(e,"expires_in");return{type:"oauth",access:o,refresh:n,expires:Date.now()+r*1000-hl}}async function gl(e){let t=await No(_l,{client_id:bo,scope:pl,referrer:"pi"},e);if(!t.ok)throw Lo("device authorization",t);return ml(t.body)}async function Cl(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await No(zs,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:bo,device_code:e.deviceCode},t);if(o.ok)return{status:"complete",value:qs(o.body)};let n=o.body.error;if(n==="authorization_pending")return{status:"pending"};if(n==="slow_down"){let r=o.body.interval;return{status:"slow_down",intervalSeconds:typeof r==="number"?r:void 0}}if(n==="access_denied"||n==="authorization_denied")return{status:"failed",message:"xAI device authorization was denied"};if(n==="expired_token")return{status:"failed",message:"xAI device code expired"};return{status:"failed",message:Lo("device token polling",o).message}}})}async function Sl(e){let t=await gl(e.signal);return e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUriComplete??t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds}),Cl(t,e.signal)}async function El(e,t){let o=await No(zs,{grant_type:"refresh_token",client_id:bo,refresh_token:e},t);if(!o.ok)throw Lo("token refresh",o);return qs(o.body,e)}var Js={name:"xAI (Grok/X subscription)",isSubscription:!0,loginLabel:"Sign in with SuperGrok or X Premium",login:Sl,refresh:(e,t)=>El(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function Ys(){xi({anthropic:()=>rs,openaiCodex:()=>Ls,openaiChatGPT:()=>Ts,githubCopilot:()=>ps,openrouter:()=>Us,kimiCoding:()=>gs,meta:()=>vs,xai:()=>Js,radius:Ks})}Si(Hr);Ys();await import("./chunk-9jtvj8md.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bkm016/basalt",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Local-first AI software engineering agent runtime and web workbench",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,2 +1,2 @@
1
- var n=Object.freeze(JSON.parse('{"displayName":"JSON","name":"json","patterns":[{"include":"#value"}],"repository":{"array":{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.array.begin.json"}},"end":"]","endCaptures":{"0":{"name":"punctuation.definition.array.end.json"}},"name":"meta.structure.array.json","patterns":[{"include":"#value"},{"match":",","name":"punctuation.separator.array.json"},{"match":"[^]\\\\s]","name":"invalid.illegal.expected-array-separator.json"}]},"comments":{"patterns":[{"begin":"/\\\\*\\\\*(?!/)","captures":{"0":{"name":"punctuation.definition.comment.json"}},"end":"\\\\*/","name":"comment.block.documentation.json"},{"begin":"/\\\\*","captures":{"0":{"name":"punctuation.definition.comment.json"}},"end":"\\\\*/","name":"comment.block.json"},{"captures":{"1":{"name":"punctuation.definition.comment.json"}},"match":"(//).*$\\\\n?","name":"comment.line.double-slash.js"}]},"constant":{"match":"\\\\b(?:true|false|null)\\\\b","name":"constant.language.json"},"number":{"match":"-?(?:0|[1-9]\\\\d*)(?:(?:\\\\.\\\\d+)?(?:[Ee][-+]?\\\\d+)?)?","name":"constant.numeric.json"},"object":{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.definition.dictionary.begin.json"}},"end":"}","endCaptures":{"0":{"name":"punctuation.definition.dictionary.end.json"}},"name":"meta.structure.dictionary.json","patterns":[{"include":"#objectkey"},{"include":"#comments"},{"begin":":","beginCaptures":{"0":{"name":"punctuation.separator.dictionary.key-value.json"}},"end":"(,)|(?=})","endCaptures":{"1":{"name":"punctuation.separator.dictionary.pair.json"}},"name":"meta.structure.dictionary.value.json","patterns":[{"include":"#value"},{"match":"[^,\\\\s]","name":"invalid.illegal.expected-dictionary-separator.json"}]},{"match":"[^}\\\\s]","name":"invalid.illegal.expected-dictionary-separator.json"}]},"objectkey":{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.support.type.property-name.begin.json"}},"end":"\\"","endCaptures":{"0":{"name":"punctuation.support.type.property-name.end.json"}},"name":"string.json support.type.property-name.json","patterns":[{"include":"#stringcontent"}]},"string":{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.json"}},"end":"\\"","endCaptures":{"0":{"name":"punctuation.definition.string.end.json"}},"name":"string.quoted.double.json","patterns":[{"include":"#stringcontent"}]},"stringcontent":{"patterns":[{"match":"\\\\\\\\(?:[\\"/\\\\\\\\bfnrt]|u\\\\h{4})","name":"constant.character.escape.json"},{"match":"\\\\\\\\.","name":"invalid.illegal.unrecognized-string-escape.json"}]},"value":{"patterns":[{"include":"#constant"},{"include":"#number"},{"include":"#string"},{"include":"#array"},{"include":"#object"},{"include":"#comments"}]}},"scopeName":"source.json"}')),Ri=[n];
2
- export{Ri};
1
+ var n=Object.freeze(JSON.parse('{"displayName":"JSON","name":"json","patterns":[{"include":"#value"}],"repository":{"array":{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.array.begin.json"}},"end":"]","endCaptures":{"0":{"name":"punctuation.definition.array.end.json"}},"name":"meta.structure.array.json","patterns":[{"include":"#value"},{"match":",","name":"punctuation.separator.array.json"},{"match":"[^]\\\\s]","name":"invalid.illegal.expected-array-separator.json"}]},"comments":{"patterns":[{"begin":"/\\\\*\\\\*(?!/)","captures":{"0":{"name":"punctuation.definition.comment.json"}},"end":"\\\\*/","name":"comment.block.documentation.json"},{"begin":"/\\\\*","captures":{"0":{"name":"punctuation.definition.comment.json"}},"end":"\\\\*/","name":"comment.block.json"},{"captures":{"1":{"name":"punctuation.definition.comment.json"}},"match":"(//).*$\\\\n?","name":"comment.line.double-slash.js"}]},"constant":{"match":"\\\\b(?:true|false|null)\\\\b","name":"constant.language.json"},"number":{"match":"-?(?:0|[1-9]\\\\d*)(?:(?:\\\\.\\\\d+)?(?:[Ee][-+]?\\\\d+)?)?","name":"constant.numeric.json"},"object":{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.definition.dictionary.begin.json"}},"end":"}","endCaptures":{"0":{"name":"punctuation.definition.dictionary.end.json"}},"name":"meta.structure.dictionary.json","patterns":[{"include":"#objectkey"},{"include":"#comments"},{"begin":":","beginCaptures":{"0":{"name":"punctuation.separator.dictionary.key-value.json"}},"end":"(,)|(?=})","endCaptures":{"1":{"name":"punctuation.separator.dictionary.pair.json"}},"name":"meta.structure.dictionary.value.json","patterns":[{"include":"#value"},{"match":"[^,\\\\s]","name":"invalid.illegal.expected-dictionary-separator.json"}]},{"match":"[^}\\\\s]","name":"invalid.illegal.expected-dictionary-separator.json"}]},"objectkey":{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.support.type.property-name.begin.json"}},"end":"\\"","endCaptures":{"0":{"name":"punctuation.support.type.property-name.end.json"}},"name":"string.json support.type.property-name.json","patterns":[{"include":"#stringcontent"}]},"string":{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.json"}},"end":"\\"","endCaptures":{"0":{"name":"punctuation.definition.string.end.json"}},"name":"string.quoted.double.json","patterns":[{"include":"#stringcontent"}]},"stringcontent":{"patterns":[{"match":"\\\\\\\\(?:[\\"/\\\\\\\\bfnrt]|u\\\\h{4})","name":"constant.character.escape.json"},{"match":"\\\\\\\\.","name":"invalid.illegal.unrecognized-string-escape.json"}]},"value":{"patterns":[{"include":"#constant"},{"include":"#number"},{"include":"#string"},{"include":"#array"},{"include":"#object"},{"include":"#comments"}]}},"scopeName":"source.json"}')),ps=[n];
2
+ export{ps};
Binary file
Binary file
@@ -0,0 +1 @@
1
+ import"./chunk-fzmrnh17.js";import"./chunk-ch60a61d.js";import{Nl}from"./chunk-mj3tshy8.js";import"./chunk-q3njnnef.js";import"./chunk-we1v1829.js";import"./chunk-pvahdcgy.js";import"./chunk-ceg13tma.js";export{Nl as diagram};
Binary file
Binary file
@@ -0,0 +1 @@
1
+ import{y,o,ee,i,r,h,e,n,x,nr,ca,dt,Br,et,hr,we,pe,Li,_l,Ii}from"./chunk-fba06jm8.js";function le(d){let{Button:v,confirm:L,PageLayout:b,Switch:_,cn:F,style:z}=x(),{connection:u,onOpen:O}=d,[D,f]=r([]),[w,H]=r([]),[q,J]=r([]),[I,T]=r(),[B,U]=r([]),[A,V]=r(!0),[k,N]=r(),[C,R]=r(),[W,P]=r(!1),[G,c]=r({}),s=i(0),E=y(async()=>{let t=++s.current;try{let[a,l,m,p]=await Promise.all([u.request("/api/automations"),u.request("/api/projects").catch(()=>[]),u.request("/api/info").catch(()=>{return}),u.request("/api/models").catch(()=>({models:[]}))]),Z=[...new Set(a.flatMap((g)=>g.lastSessionID?[g.lastSessionID]:[]))],te=(await Promise.all(Z.map(async(g)=>u.request(`/api/sessions/${encodeURIComponent(g)}`).catch((j)=>{if(j instanceof Error&&"status"in j&&j.status===404)return;throw j})))).filter((g)=>g!==void 0);if(t!==s.current)return;if(f(a.sort((g,j)=>g.created-j.created)),H(l),J(te),T(m),p?.models)U(p.models.map((g)=>g.id));N(void 0)}catch(a){if(t===s.current)N(a instanceof Error?a.message:"加载失败")}finally{if(t===s.current)V(!1)}},[u]);o(()=>(E(),()=>{s.current++}),[E]);let S=(t)=>{R(t),P(!0)},Q=async(t)=>{c((a)=>({...a,[t.id]:!0}));try{let a=await u.request(`/api/automations/${t.id}/run`,{method:"POST"});O(a.id)}catch(a){N(a instanceof Error?a.message:"运行失败")}finally{c((a)=>({...a,[t.id]:!1}))}},X=async(t)=>{if(!await L({title:`删除自动化「${t.name}」?`,description:"已经跑出来的会话会保留。",action:"删除",danger:!0}))return;try{await u.request(`/api/automations/${t.id}`,{method:"DELETE"}),f((l)=>l.filter((m)=>m.id!==t.id))}catch(l){N(l instanceof Error?l.message:"删除失败")}},Y=async(t,a)=>{try{let l=await u.request(`/api/automations/${t.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})});f((m)=>m.map((p)=>p.id===t.id?l:p))}catch(l){N(l instanceof Error?l.message:"状态切换失败")}};return n(b,{title:"自动化",description:n(h,{children:["到点自动开一个新会话执行提示词,跑完的结果在会话里查看。",I?.timezone&&n("span",{className:"text-faint",children:["按服务器时区 ",I.timezone,"。"]})]}),actions:n(v,{variant:"primary",onClick:()=>S(null),children:[e(we,{className:"size-4"}),"新建"]}),children:[k&&e("div",{className:"mb-4 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:k}),A?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载自动化…"}):D.length===0?n("div",{className:z("surface.emptyDashed","animate-fade"),children:[e("div",{className:"grid size-11 place-items-center rounded-xl bg-raised text-dim",children:e(nr,{className:"size-5"})}),n("div",{children:[e("p",{className:"text-[15px] font-medium",children:"还没有自动化"}),e("p",{className:"mt-1 text-sm text-dim",children:"比如「每个工作日 9 点总结昨天的提交」。"})]}),n(v,{size:"sm",onClick:()=>S(null),className:"mt-1",children:[e(we,{className:"size-3.5"}),"新建自动化"]})]}):e("ul",{className:"flex animate-fade flex-col gap-3",children:D.map((t)=>{let a=t.projectID?w.find((p)=>p.id===t.projectID):void 0,l=t.lastSessionID?q.find((p)=>p.id===t.lastSessionID):void 0,m=Boolean(G[t.id]);return e("li",{children:n("article",{className:z("surface.card","group p-4 transition-[border-color,box-shadow] duration-200 hover:border-line-strong hover:shadow-composer"),children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:F("min-w-0 flex-1 transition-opacity duration-200",!t.enabled&&"opacity-55"),children:[e("h2",{className:"truncate text-[15px] font-medium",children:t.name}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-[13px] text-dim",children:[n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(nr,{}),_l(t.schedule)]}),n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[a?e(dt,{}):e(Br,{}),a?a.name:"聊天"]}),t.enabled&&t.nextRun!==null&&n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(ca,{}),"下次 ",Ii(t.nextRun)]})]})]}),e(_,{checked:t.enabled,label:t.enabled?"停用":"启用",onCheckedChange:(p)=>Y(t,p),className:"mt-0.5"})]}),e("p",{className:F("mt-3 line-clamp-2 text-sm leading-6 whitespace-pre-wrap text-faint transition-opacity duration-200",!t.enabled&&"opacity-55"),children:t.prompt}),n("div",{className:"mt-3 -mb-1 flex items-center gap-1",children:[n(v,{size:"sm",onClick:()=>Q(t),disabled:m,children:[e(hr,{className:"size-3.5"}),m?"正在启动…":"立即运行"]}),n(v,{size:"sm",variant:"ghost",onClick:()=>S(t),children:[e(et,{className:"size-3.5"}),"编辑"]}),n(v,{size:"sm",variant:"danger-ghost",onClick:()=>X(t),children:[e(pe,{className:"size-3.5"}),"删除"]}),e("div",{className:"flex-1"}),t.lastRun!==null&&n("button",{type:"button",disabled:!l,onClick:()=>l&&O(l.id),className:"rounded-md px-1.5 py-1 text-[13px] text-faint transition-colors enabled:hover:bg-raised enabled:hover:text-ink",children:["上次运行 ",Ii(t.lastRun),l?.archivedAt!=null?" · 已归档":"",!l?" · 会话已删除":""]})]})]})},t.id)})}),C!==void 0&&e(ne,{open:W,onOpenChange:P,automation:C??void 0,projects:w,models:B,timezone:I?.timezone,onSaved:(t)=>{f((a)=>{let l=a.findIndex((m)=>m.id===t.id);if(l>=0){let m=[...a];return m[l]=t,m}return[...a,t].sort((m,p)=>m.created-p.created)}),P(!1)},connection:u},C?.id??"new")]})}var M="custom",K="chat";function ne(d){let{Button:v,Dialog:L,Field:b,Form:_,FormError:F,Input:z,Select:u,Textarea:O}=x(),D=ee(),f=d.automation,[w,H]=r(f?.name??""),[q,J]=r(f?.prompt??""),[I,T]=r(f?.schedule??Li[0]?.cron??"0 9 * * *"),[B,U]=r(()=>!Li.some((c)=>c.cron===I)),[A,V]=r(f?.projectID??K),[k,N]=r(f?.model??""),[C,R]=r(!1),[W,P]=r();async function G(c){c.preventDefault(),R(!0),P(void 0);try{let s=A===K?void 0:A,E={name:w,prompt:q,schedule:I,model:k||void 0},S;if(f)S=await d.connection.request(`/api/automations/${f.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s??null})});else S=await d.connection.request("/api/automations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s})});d.onSaved(S)}catch(s){P(s instanceof Error?s.message:"保存失败")}finally{R(!1)}}return e(L,{open:d.open,onOpenChange:d.onOpenChange,title:d.automation?"编辑自动化":"新建自动化",size:"lg",footer:n(h,{children:[e("div",{className:"flex-1 max-sm:hidden"}),e(v,{onClick:()=>d.onOpenChange(!1),children:"取消"}),e(v,{type:"submit",form:D,variant:"primary",disabled:C,children:C?"正在保存…":d.automation?"保存":"创建"})]}),children:n(_,{id:D,onSubmit:G,children:[e(b,{label:"名称",children:(c)=>e(z,{id:c,autoFocus:!f,required:!0,value:w,onChange:(s)=>H(s.target.value),placeholder:"例如:每日提交总结"})}),e(b,{label:"提示词",hint:"没人盯着运行,写清楚要做什么、结果怎么汇报。",children:(c)=>e(O,{id:c,required:!0,value:q,onChange:(s)=>J(s.target.value),rows:5,placeholder:"总结昨天到现在的 git 提交,按模块分组,列出需要我关注的改动。"})}),n("div",{className:"grid gap-x-3 gap-y-4 sm:grid-cols-2",children:[e(b,{label:"时间",children:(c)=>e(u,{id:c,value:B?M:I,onValueChange:(s)=>{if(U(s===M),s!==M)T(s)},groups:[{options:Li.map((s)=>({value:s.cron,label:s.label}))},{options:[{value:M,label:"自定义(cron)"}]}]})}),e(b,{label:"在哪里运行",children:(c)=>e(u,{id:c,value:A,onValueChange:V,groups:[{options:[{value:K,label:"聊天",description:"不绑定目录",icon:e(Br,{})}]},...d.projects.length?[{label:"项目",options:d.projects.map((s)=>({value:s.id,label:s.name,icon:e(dt,{})}))}]:[]]})})]}),B&&e(b,{label:"cron 表达式",hint:`分 时 日 月 周,例如 30 8 * * 1-5 是工作日 8:30。${d.timezone?`按 ${d.timezone} 时间。`:""}`,children:(c)=>e(z,{id:c,required:!0,value:I,onChange:(s)=>T(s.target.value),spellCheck:!1,className:"font-mono"})}),d.models.length>0&&e(b,{label:"模型",children:(c)=>e(u,{id:c,value:k||"default",onValueChange:(s)=>N(s==="default"?"":s),groups:[{options:[{value:"default",label:"默认模型"},...d.models.map((s)=>({value:s,label:s}))]}]})}),e(F,{children:W})]})})}export{le as AutomationsPage};
Binary file
Binary file
@@ -0,0 +1 @@
1
+ import{la}from"./chunk-xs1g97qa.js";export{la as default};
Binary file
Binary file
@@ -0,0 +1 @@
1
+ import{ys}from"./chunk-bdypt5mj.js";export{ys as createGitGraphServices};
@@ -0,0 +1,2 @@
1
+ �$�import{ys}from"./chunk-bdypt5mj.js";export{ys as createGitGraphServices};
2
+ 
Binary file
@@ -0,0 +1 @@
1
+ import{fs}from"./chunk-bdypt5mj.js";export{fs as createTreemapServices};
Binary file
Binary file