@bkm016/basalt 0.1.24 → 0.1.25
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.
- package/{chunk-bdr1170y.js → chunk-2c6seev1.js} +1 -1
- package/{chunk-9y8v1vrt.js → chunk-4mwx4pet.js} +1 -1
- package/{chunk-4x7xnfw1.js → chunk-61e7nvw9.js} +1 -1
- package/{chunk-979mxkzt.js → chunk-93bcazsp.js} +1 -1
- package/{chunk-y16fqzad.js → chunk-9fccgczj.js} +1 -1
- package/{chunk-kh4yq4rd.js → chunk-ff293dj0.js} +1 -1
- package/{chunk-cte9wd9x.js → chunk-g23dnf4y.js} +1 -1
- package/{chunk-c4nxr37s.js → chunk-gwcstcqs.js} +4 -4
- package/{chunk-ma91f4qj.js → chunk-m839588n.js} +1 -1
- package/{chunk-0nxcbf6d.js → chunk-pjv9mppd.js} +109 -108
- package/{chunk-pcd14q8r.js → chunk-rkn6bven.js} +4 -4
- package/compiled.js +1 -1
- package/package.json +1 -1
- package/ui-test-worker.js +1 -1
- package/web/{chunk-ppccb30x.js → chunk-00wh99xz.js} +4 -4
- package/web/chunk-00wh99xz.js.br +0 -0
- package/web/chunk-00wh99xz.js.gz +0 -0
- package/web/{chunk-g7t1bvvx.js → chunk-0a1t2j8h.js} +1 -1
- package/web/chunk-0a1t2j8h.js.br +0 -0
- package/web/chunk-0a1t2j8h.js.gz +0 -0
- package/web/{chunk-59ybhv47.js → chunk-1ar2phwa.js} +1 -1
- package/web/chunk-1ar2phwa.js.br +0 -0
- package/web/chunk-1ar2phwa.js.gz +0 -0
- package/web/{chunk-hqtm67yw.js → chunk-1jfydncj.js} +2 -2
- package/web/chunk-1jfydncj.js.br +0 -0
- package/web/chunk-1jfydncj.js.gz +0 -0
- package/web/{chunk-qqtj88e0.js → chunk-1p1jtvrt.js} +1 -1
- package/web/chunk-1p1jtvrt.js.br +0 -0
- package/web/chunk-1p1jtvrt.js.gz +0 -0
- package/web/chunk-1x38r11w.js +1 -0
- package/web/chunk-1x38r11w.js.br +2 -0
- package/web/chunk-1x38r11w.js.gz +0 -0
- package/web/{chunk-bbyqcvdz.js → chunk-25rf3svt.js} +2 -2
- package/web/chunk-25rf3svt.js.br +0 -0
- package/web/chunk-25rf3svt.js.gz +0 -0
- package/web/chunk-2cfv55j2.js +1 -0
- package/web/chunk-2cfv55j2.js.br +0 -0
- package/web/chunk-2cfv55j2.js.gz +0 -0
- package/web/{chunk-bg2ps35t.js → chunk-2q37qdq2.js} +1 -1
- package/web/chunk-2q37qdq2.js.br +0 -0
- package/web/chunk-2q37qdq2.js.gz +0 -0
- package/web/{chunk-13x3xyyh.js → chunk-2yhmab75.js} +4 -4
- package/web/chunk-2yhmab75.js.br +0 -0
- package/web/chunk-2yhmab75.js.gz +0 -0
- package/web/{chunk-bvmvj35k.js → chunk-3at57qna.js} +1 -1
- package/web/chunk-3at57qna.js.br +0 -0
- package/web/chunk-3at57qna.js.gz +0 -0
- package/web/{chunk-nb3jk1wk.js → chunk-3z9kpkec.js} +1 -1
- package/web/chunk-3z9kpkec.js.br +0 -0
- package/web/chunk-3z9kpkec.js.gz +0 -0
- package/web/chunk-4ncnt1c2.js +2 -0
- package/web/chunk-4ncnt1c2.js.br +0 -0
- package/web/{chunk-k69ysa0v.js → chunk-4ncnt1c2.js.gz} +0 -0
- package/web/chunk-4vc07x6t.js +1 -0
- package/web/chunk-4vc07x6t.js.br +0 -0
- package/web/chunk-4vc07x6t.js.gz +0 -0
- package/web/{chunk-921qw2jf.js → chunk-4ytc5sth.js} +1 -1
- package/web/chunk-4ytc5sth.js.br +0 -0
- package/web/chunk-4ytc5sth.js.gz +0 -0
- package/web/{chunk-zs7c2db4.js → chunk-5c5h90k0.js} +1 -1
- package/web/chunk-5c5h90k0.js.br +0 -0
- package/web/chunk-5c5h90k0.js.gz +0 -0
- package/web/chunk-5zpn3n5a.js +1 -0
- package/web/chunk-5zpn3n5a.js.br +0 -0
- package/web/chunk-5zpn3n5a.js.gz +0 -0
- package/web/chunk-64k06g43.js +1 -0
- package/web/chunk-64k06g43.js.br +0 -0
- package/web/chunk-64k06g43.js.gz +0 -0
- package/web/{chunk-bh0a254y.js → chunk-6pbrtp4e.js} +4 -4
- package/web/chunk-6pbrtp4e.js.br +0 -0
- package/web/chunk-6pbrtp4e.js.gz +0 -0
- package/web/chunk-6sehssym.js +1 -0
- package/web/chunk-6sehssym.js.br +2 -0
- package/web/chunk-6sehssym.js.gz +0 -0
- package/web/chunk-7hxj251q.js +1 -0
- package/web/chunk-7hxj251q.js.br +0 -0
- package/web/chunk-7hxj251q.js.gz +0 -0
- package/web/{chunk-abvtsz6z.js → chunk-7qcmg5ns.js} +1 -1
- package/web/chunk-7qcmg5ns.js.br +0 -0
- package/web/chunk-7qcmg5ns.js.gz +0 -0
- package/web/{chunk-172gywq4.js → chunk-82j6713x.js} +6 -6
- package/web/chunk-82j6713x.js.br +0 -0
- package/web/chunk-82j6713x.js.gz +0 -0
- package/web/{chunk-kbvzxsz7.js → chunk-9vexd52p.js} +1 -1
- package/web/chunk-9vexd52p.js.br +0 -0
- package/web/chunk-9vexd52p.js.gz +0 -0
- package/web/{chunk-crhbhsrh.js → chunk-ajj3nc80.js} +1 -1
- package/web/chunk-ajj3nc80.js.br +0 -0
- package/web/chunk-ajj3nc80.js.gz +0 -0
- package/web/chunk-amrkb4dd.js +1 -0
- package/web/chunk-amrkb4dd.js.br +0 -0
- package/web/chunk-amrkb4dd.js.gz +0 -0
- package/web/{chunk-w563538j.js → chunk-b7d5k9sp.js} +35 -35
- package/web/chunk-b7d5k9sp.js.br +0 -0
- package/web/chunk-b7d5k9sp.js.gz +0 -0
- package/web/chunk-bavn0z5d.js +1 -0
- package/web/chunk-bavn0z5d.js.br +0 -0
- package/web/chunk-bavn0z5d.js.gz +0 -0
- package/web/{chunk-yp75a6yh.js → chunk-bjw74xvy.js} +1 -1
- package/web/chunk-bjw74xvy.js.br +0 -0
- package/web/chunk-bjw74xvy.js.gz +0 -0
- package/web/chunk-bn68ks4x.js +1 -0
- package/web/chunk-bn68ks4x.js.br +0 -0
- package/web/chunk-bn68ks4x.js.gz +0 -0
- package/web/chunk-c59d2j14.js +8 -0
- package/web/chunk-c59d2j14.js.br +0 -0
- package/web/chunk-c59d2j14.js.gz +0 -0
- package/web/{chunk-634vc92s.js → chunk-cfz9ftze.js} +3 -3
- package/web/chunk-cfz9ftze.js.br +0 -0
- package/web/chunk-cfz9ftze.js.gz +0 -0
- package/web/{chunk-zsae1tn8.js → chunk-chq476ch.js} +4 -4
- package/web/chunk-chq476ch.js.br +0 -0
- package/web/chunk-chq476ch.js.gz +0 -0
- package/web/{chunk-5zkw2kkb.js → chunk-d0ey112q.js} +5 -5
- package/web/chunk-d0ey112q.js.br +0 -0
- package/web/chunk-d0ey112q.js.gz +0 -0
- package/web/{chunk-h1cv1kke.js → chunk-d71z7s5r.js} +1 -1
- package/web/chunk-d71z7s5r.js.br +0 -0
- package/web/chunk-d71z7s5r.js.gz +0 -0
- package/web/{chunk-8de69eyx.js → chunk-dembnhph.js} +1 -1
- package/web/chunk-dembnhph.js.br +0 -0
- package/web/chunk-dembnhph.js.gz +0 -0
- package/web/{chunk-m5nt857c.js → chunk-dfq4w8mf.js} +1 -1
- package/web/chunk-dfq4w8mf.js.br +0 -0
- package/web/chunk-dfq4w8mf.js.gz +0 -0
- package/web/{chunk-bbs6yq60.js → chunk-dwdxczxc.js} +3 -3
- package/web/chunk-dwdxczxc.js.br +0 -0
- package/web/chunk-dwdxczxc.js.gz +0 -0
- package/web/chunk-e3b2krd7.js +1 -0
- package/web/chunk-e3b2krd7.js.br +0 -0
- package/web/chunk-e3b2krd7.js.gz +0 -0
- package/web/{chunk-91s1ns6b.js → chunk-e4wbkc1x.js} +11 -11
- package/web/chunk-e4wbkc1x.js.br +0 -0
- package/web/chunk-e4wbkc1x.js.gz +0 -0
- package/web/{chunk-ygzgrjj7.js → chunk-f2qrf0he.js} +1 -1
- package/web/chunk-f2qrf0he.js.br +0 -0
- package/web/chunk-f2qrf0he.js.gz +0 -0
- package/web/{chunk-ca8hnmmv.js → chunk-f88vhwan.js} +5 -5
- package/web/chunk-f88vhwan.js.br +0 -0
- package/web/chunk-f88vhwan.js.gz +0 -0
- package/web/{chunk-yg9a23mv.js → chunk-fpp6jtb4.js} +1 -1
- package/web/chunk-fpp6jtb4.js.br +0 -0
- package/web/chunk-fpp6jtb4.js.gz +0 -0
- package/web/chunk-ft62hfnt.js +1 -0
- package/web/chunk-ft62hfnt.js.br +0 -0
- package/web/chunk-ft62hfnt.js.gz +0 -0
- package/web/{chunk-176tsg6e.js → chunk-g3fahpjw.js} +2 -2
- package/web/chunk-g3fahpjw.js.br +0 -0
- package/web/chunk-g3fahpjw.js.gz +0 -0
- package/web/{chunk-xw8tzrmm.js → chunk-g5b4wjwp.js} +94 -94
- package/web/chunk-g5b4wjwp.js.br +0 -0
- package/web/chunk-g5b4wjwp.js.gz +0 -0
- package/web/chunk-ga3tn73a.js +1 -0
- package/web/chunk-ga3tn73a.js.br +0 -0
- package/web/chunk-ga3tn73a.js.gz +0 -0
- package/web/{chunk-4cbcqcd2.js → chunk-gf4vtpw2.js} +1 -1
- package/web/chunk-gf4vtpw2.js.br +0 -0
- package/web/chunk-gf4vtpw2.js.gz +0 -0
- package/web/{chunk-n9npqkxf.js → chunk-ghxfjwhq.js} +1 -1
- package/web/chunk-ghxfjwhq.js.br +0 -0
- package/web/chunk-ghxfjwhq.js.gz +0 -0
- package/web/{chunk-hsgtzrkh.js → chunk-gxqs7zmy.js} +1 -1
- package/web/chunk-gxqs7zmy.js.br +0 -0
- package/web/chunk-gxqs7zmy.js.gz +0 -0
- package/web/{chunk-9k9p5dat.js → chunk-jpdp0xkd.js} +1 -1
- package/web/chunk-jpdp0xkd.js.br +0 -0
- package/web/chunk-jpdp0xkd.js.gz +0 -0
- package/web/{chunk-kn9bc5z2.js → chunk-jtzbk251.js} +2 -2
- package/web/chunk-jtzbk251.js.br +0 -0
- package/web/chunk-jtzbk251.js.gz +0 -0
- package/web/{chunk-ac8vmj54.js → chunk-kc6k0ect.js} +1 -1
- package/web/chunk-kc6k0ect.js.br +0 -0
- package/web/chunk-kc6k0ect.js.gz +0 -0
- package/web/{chunk-gy2y4zfa.js → chunk-kk7k8xc8.js} +5 -5
- package/web/chunk-kk7k8xc8.js.br +0 -0
- package/web/chunk-kk7k8xc8.js.gz +0 -0
- package/web/{chunk-6n3cwe1h.js → chunk-kmpyntam.js} +19 -19
- package/web/chunk-kmpyntam.js.br +0 -0
- package/web/chunk-kmpyntam.js.gz +0 -0
- package/web/{chunk-q17rem99.js → chunk-mejpj22t.js} +5 -5
- package/web/chunk-mejpj22t.js.br +0 -0
- package/web/chunk-mejpj22t.js.gz +0 -0
- package/web/{chunk-sapy54hm.js → chunk-mm10pm0x.js} +3 -3
- package/web/chunk-mm10pm0x.js.br +0 -0
- package/web/chunk-mm10pm0x.js.gz +0 -0
- package/web/{chunk-r4cr8rvt.js → chunk-mpve4748.js} +1 -1
- package/web/chunk-mpve4748.js.br +0 -0
- package/web/chunk-mpve4748.js.gz +0 -0
- package/web/chunk-ms022qq9.js +1 -0
- package/web/chunk-ms022qq9.js.br +2 -0
- package/web/chunk-ms022qq9.js.gz +0 -0
- package/web/{chunk-xv1d350x.js → chunk-mxf122px.js} +1 -1
- package/web/chunk-mxf122px.js.br +0 -0
- package/web/chunk-mxf122px.js.gz +0 -0
- package/web/chunk-mzv41kv9.js +1 -0
- package/web/chunk-mzv41kv9.js.br +2 -0
- package/web/chunk-mzv41kv9.js.gz +0 -0
- package/web/{chunk-2fms67zg.js → chunk-mzyg8zga.js} +1 -1
- package/web/chunk-mzyg8zga.js.br +0 -0
- package/web/chunk-mzyg8zga.js.gz +0 -0
- package/web/{chunk-c2eqwepm.js → chunk-n8j9jdsh.js} +1 -1
- package/web/chunk-n8j9jdsh.js.br +0 -0
- package/web/chunk-n8j9jdsh.js.gz +0 -0
- package/web/{chunk-fp7q643n.js → chunk-n8ts6ra2.js} +3 -3
- package/web/chunk-n8ts6ra2.js.br +0 -0
- package/web/chunk-n8ts6ra2.js.gz +0 -0
- package/web/chunk-nefchfa1.js +1 -0
- package/web/chunk-nefchfa1.js.br +0 -0
- package/web/chunk-nefchfa1.js.gz +0 -0
- package/web/chunk-ng0bsm6n.js +1 -0
- package/web/chunk-ng0bsm6n.js.br +0 -0
- package/web/chunk-ng0bsm6n.js.gz +0 -0
- package/web/{chunk-ced8pdbc.js → chunk-nz1mm18x.js} +1 -1
- package/web/chunk-nz1mm18x.js.br +0 -0
- package/web/chunk-nz1mm18x.js.gz +0 -0
- package/web/{chunk-mbaw66b5.js → chunk-pdxqp4rh.js} +1 -1
- package/web/chunk-pdxqp4rh.js.br +0 -0
- package/web/chunk-pdxqp4rh.js.gz +0 -0
- package/web/{chunk-g1penf6y.js → chunk-pe2zvyjt.js} +1 -1
- package/web/chunk-pe2zvyjt.js.br +0 -0
- package/web/chunk-pe2zvyjt.js.gz +0 -0
- package/web/{chunk-t7vwsg9r.js → chunk-q8ve5wqt.js} +2 -2
- package/web/chunk-q8ve5wqt.js.br +0 -0
- package/web/chunk-q8ve5wqt.js.gz +0 -0
- package/web/{chunk-ny87aq2j.js → chunk-qh93t9tv.js} +1 -1
- package/web/chunk-qh93t9tv.js.br +0 -0
- package/web/chunk-qh93t9tv.js.gz +0 -0
- package/web/{chunk-3vdw9nn7.js → chunk-qqewmk3y.js} +1 -1
- package/web/chunk-qqewmk3y.js.br +0 -0
- package/web/chunk-qqewmk3y.js.gz +0 -0
- package/web/{chunk-n59nyqcr.js → chunk-qzb06me8.js} +34 -34
- package/web/chunk-qzb06me8.js.br +0 -0
- package/web/chunk-qzb06me8.js.gz +0 -0
- package/web/{chunk-tt7j0m6m.js → chunk-r2zernvz.js} +5 -5
- package/web/chunk-r2zernvz.js.br +0 -0
- package/web/chunk-r2zernvz.js.gz +0 -0
- package/web/{chunk-qdq6wvgt.js → chunk-r8ykja8v.js} +3 -3
- package/web/chunk-r8ykja8v.js.br +0 -0
- package/web/chunk-r8ykja8v.js.gz +0 -0
- package/web/{chunk-qhr6hegh.js → chunk-r9b7eh2j.js} +1 -1
- package/web/chunk-r9b7eh2j.js.br +0 -0
- package/web/chunk-r9b7eh2j.js.gz +0 -0
- package/web/{chunk-eq28qb33.js → chunk-ry1wp3v8.js} +2 -2
- package/web/chunk-ry1wp3v8.js.br +0 -0
- package/web/chunk-ry1wp3v8.js.gz +0 -0
- package/web/chunk-s2bfc2vk.js +1 -0
- package/web/chunk-s2bfc2vk.js.br +0 -0
- package/web/chunk-s2bfc2vk.js.gz +0 -0
- package/web/{chunk-2psxv4dk.js → chunk-s4c6nzj9.js} +5 -5
- package/web/chunk-s4c6nzj9.js.br +0 -0
- package/web/chunk-s4c6nzj9.js.gz +0 -0
- package/web/{chunk-b9fqnzqd.js → chunk-ss23nnmc.js} +4 -4
- package/web/chunk-ss23nnmc.js.br +0 -0
- package/web/chunk-ss23nnmc.js.gz +0 -0
- package/web/{chunk-b2t33c3t.js → chunk-sxmv80th.js} +1 -1
- package/web/chunk-sxmv80th.js.br +0 -0
- package/web/chunk-sxmv80th.js.gz +0 -0
- package/web/{chunk-3sszg3gr.js → chunk-sy2cdka3.js} +1 -1
- package/web/chunk-sy2cdka3.js.br +0 -0
- package/web/chunk-sy2cdka3.js.gz +0 -0
- package/web/{chunk-vgpyff03.js → chunk-sysebfkg.js} +3 -3
- package/web/chunk-sysebfkg.js.br +0 -0
- package/web/chunk-sysebfkg.js.gz +0 -0
- package/web/{chunk-vb3sy3hv.js → chunk-t3620hrb.js} +2 -2
- package/web/chunk-t3620hrb.js.br +0 -0
- package/web/chunk-t3620hrb.js.gz +0 -0
- package/web/{chunk-phr7yps3.js → chunk-t5srz1hs.js} +2 -2
- package/web/chunk-t5srz1hs.js.br +0 -0
- package/web/chunk-t5srz1hs.js.gz +0 -0
- package/web/{chunk-sarkb4p9.js → chunk-v25k7n3r.js} +1 -1
- package/web/chunk-v25k7n3r.js.br +0 -0
- package/web/chunk-v25k7n3r.js.gz +0 -0
- package/web/{chunk-e3d6kvwm.js → chunk-vf0p4ayw.js} +1 -1
- package/web/chunk-vf0p4ayw.js.br +0 -0
- package/web/chunk-vf0p4ayw.js.gz +0 -0
- package/web/chunk-vr6n4pvt.js +1 -0
- package/web/chunk-vr6n4pvt.js.br +0 -0
- package/web/chunk-vr6n4pvt.js.gz +0 -0
- package/web/{chunk-713ygtrs.js → chunk-vx9g94x2.js} +4 -4
- package/web/chunk-vx9g94x2.js.br +0 -0
- package/web/chunk-vx9g94x2.js.gz +0 -0
- package/web/{chunk-cj0cmvbm.js → chunk-w5v80bmk.js} +4 -4
- package/web/chunk-w5v80bmk.js.br +0 -0
- package/web/chunk-w5v80bmk.js.gz +0 -0
- package/web/{chunk-y5zd05mz.js → chunk-wj0ck0pa.js} +1 -1
- package/web/chunk-wj0ck0pa.js.br +0 -0
- package/web/chunk-wj0ck0pa.js.gz +0 -0
- package/web/chunk-wjzdpyhs.css +1 -0
- package/web/chunk-wjzdpyhs.css.br +0 -0
- package/web/chunk-wjzdpyhs.css.gz +0 -0
- package/web/{chunk-17d30546.js → chunk-wmt8d7zv.js} +5 -5
- package/web/chunk-wmt8d7zv.js.br +0 -0
- package/web/chunk-wmt8d7zv.js.gz +0 -0
- package/web/{chunk-ksr360js.js → chunk-wqf0qjbv.js} +2 -2
- package/web/chunk-wqf0qjbv.js.br +0 -0
- package/web/chunk-wqf0qjbv.js.gz +0 -0
- package/web/{chunk-2z4zhtw4.js → chunk-y5f7gy03.js} +2 -2
- package/web/chunk-y5f7gy03.js.br +0 -0
- package/web/chunk-y5f7gy03.js.gz +0 -0
- package/web/{chunk-96n0nem7.js → chunk-yg78fas7.js} +1 -1
- package/web/chunk-yg78fas7.js.br +0 -0
- package/web/chunk-yg78fas7.js.gz +0 -0
- package/web/{chunk-k8x1xbf6.js → chunk-yvkbc3s5.js} +1 -1
- package/web/chunk-yvkbc3s5.js.br +0 -0
- package/web/chunk-yvkbc3s5.js.gz +0 -0
- package/web/{chunk-wrqazg2v.js → chunk-z9nj64n7.js} +1 -1
- package/web/chunk-z9nj64n7.js.br +0 -0
- package/web/chunk-z9nj64n7.js.gz +0 -0
- package/web/{chunk-ms7cscs9.js → chunk-zc0e01j4.js} +1 -1
- package/web/chunk-zc0e01j4.js.br +0 -0
- package/web/chunk-zc0e01j4.js.gz +0 -0
- package/web/{chunk-290wy4yk.js → chunk-zj9s9w76.js} +1 -1
- package/web/chunk-zj9s9w76.js.br +0 -0
- package/web/chunk-zj9s9w76.js.gz +0 -0
- package/web/{chunk-085ttz7c.js → chunk-znwpavn5.js} +4 -4
- package/web/chunk-znwpavn5.js.br +0 -0
- package/web/chunk-znwpavn5.js.gz +0 -0
- package/web/index.html +1 -1
- package/web/index.html.br +0 -0
- package/web/index.html.gz +0 -0
- package/web/chunk-085ttz7c.js.br +0 -0
- package/web/chunk-085ttz7c.js.gz +0 -0
- package/web/chunk-13x3xyyh.js.br +0 -0
- package/web/chunk-13x3xyyh.js.gz +0 -0
- package/web/chunk-172gywq4.js.br +0 -0
- package/web/chunk-172gywq4.js.gz +0 -0
- package/web/chunk-176tsg6e.js.br +0 -0
- package/web/chunk-176tsg6e.js.gz +0 -0
- package/web/chunk-17d30546.js.br +0 -0
- package/web/chunk-17d30546.js.gz +0 -0
- package/web/chunk-1k6jx4hs.js +0 -1
- package/web/chunk-1k6jx4hs.js.br +0 -0
- package/web/chunk-1k6jx4hs.js.gz +0 -0
- package/web/chunk-1kts05s6.css +0 -1
- package/web/chunk-1kts05s6.css.br +0 -0
- package/web/chunk-1kts05s6.css.gz +0 -0
- package/web/chunk-1z0x1j6q.js +0 -1
- package/web/chunk-1z0x1j6q.js.br +0 -0
- package/web/chunk-1z0x1j6q.js.gz +0 -0
- package/web/chunk-290wy4yk.js.br +0 -0
- package/web/chunk-290wy4yk.js.gz +0 -0
- package/web/chunk-2cdw1299.js +0 -1
- package/web/chunk-2cdw1299.js.br +0 -0
- package/web/chunk-2cdw1299.js.gz +0 -0
- package/web/chunk-2fms67zg.js.br +0 -0
- package/web/chunk-2fms67zg.js.gz +0 -0
- package/web/chunk-2psxv4dk.js.br +0 -0
- package/web/chunk-2psxv4dk.js.gz +0 -0
- package/web/chunk-2z4zhtw4.js.br +0 -0
- package/web/chunk-2z4zhtw4.js.gz +0 -0
- package/web/chunk-3sszg3gr.js.br +0 -0
- package/web/chunk-3sszg3gr.js.gz +0 -0
- package/web/chunk-3vdw9nn7.js.br +0 -0
- package/web/chunk-3vdw9nn7.js.gz +0 -0
- package/web/chunk-4cbcqcd2.js.br +0 -0
- package/web/chunk-4cbcqcd2.js.gz +0 -0
- package/web/chunk-4v6n6b36.js +0 -1
- package/web/chunk-4v6n6b36.js.br +0 -0
- package/web/chunk-4v6n6b36.js.gz +0 -0
- package/web/chunk-59ybhv47.js.br +0 -0
- package/web/chunk-59ybhv47.js.gz +0 -0
- package/web/chunk-5zkw2kkb.js.br +0 -0
- package/web/chunk-5zkw2kkb.js.gz +0 -0
- package/web/chunk-634vc92s.js.br +0 -0
- package/web/chunk-634vc92s.js.gz +0 -0
- package/web/chunk-6n3cwe1h.js.br +0 -0
- package/web/chunk-6n3cwe1h.js.gz +0 -0
- package/web/chunk-6zr2j7xj.js +0 -1
- package/web/chunk-6zr2j7xj.js.br +0 -0
- package/web/chunk-6zr2j7xj.js.gz +0 -0
- package/web/chunk-713ygtrs.js.br +0 -0
- package/web/chunk-713ygtrs.js.gz +0 -0
- package/web/chunk-7m4gmjvp.js +0 -1
- package/web/chunk-7m4gmjvp.js.br +0 -0
- package/web/chunk-7m4gmjvp.js.gz +0 -0
- package/web/chunk-7x90pq42.js +0 -1
- package/web/chunk-7x90pq42.js.br +0 -0
- package/web/chunk-7x90pq42.js.gz +0 -0
- package/web/chunk-8de69eyx.js.br +0 -0
- package/web/chunk-8de69eyx.js.gz +0 -0
- package/web/chunk-91s1ns6b.js.br +0 -0
- package/web/chunk-91s1ns6b.js.gz +0 -0
- package/web/chunk-921qw2jf.js.br +0 -0
- package/web/chunk-921qw2jf.js.gz +0 -0
- package/web/chunk-96n0nem7.js.br +0 -0
- package/web/chunk-96n0nem7.js.gz +0 -0
- package/web/chunk-9k9p5dat.js.br +0 -0
- package/web/chunk-9k9p5dat.js.gz +0 -0
- package/web/chunk-a529550j.js +0 -1
- package/web/chunk-a529550j.js.br +0 -0
- package/web/chunk-a529550j.js.gz +0 -0
- package/web/chunk-abvtsz6z.js.br +0 -0
- package/web/chunk-abvtsz6z.js.gz +0 -0
- package/web/chunk-ac8vmj54.js.br +0 -0
- package/web/chunk-ac8vmj54.js.gz +0 -0
- package/web/chunk-b2t33c3t.js.br +0 -0
- package/web/chunk-b2t33c3t.js.gz +0 -0
- package/web/chunk-b9fqnzqd.js.br +0 -0
- package/web/chunk-b9fqnzqd.js.gz +0 -0
- package/web/chunk-bbs6yq60.js.br +0 -0
- package/web/chunk-bbs6yq60.js.gz +0 -0
- package/web/chunk-bbyqcvdz.js.br +0 -0
- package/web/chunk-bbyqcvdz.js.gz +0 -0
- package/web/chunk-bg2ps35t.js.br +0 -0
- package/web/chunk-bg2ps35t.js.gz +0 -0
- package/web/chunk-bh0a254y.js.br +0 -0
- package/web/chunk-bh0a254y.js.gz +0 -0
- package/web/chunk-bvmvj35k.js.br +0 -0
- package/web/chunk-bvmvj35k.js.gz +0 -0
- package/web/chunk-c2eqwepm.js.br +0 -0
- package/web/chunk-c2eqwepm.js.gz +0 -0
- package/web/chunk-ca8hnmmv.js.br +0 -0
- package/web/chunk-ca8hnmmv.js.gz +0 -0
- package/web/chunk-ced8pdbc.js.br +0 -0
- package/web/chunk-ced8pdbc.js.gz +0 -0
- package/web/chunk-cj0cmvbm.js.br +0 -0
- package/web/chunk-cj0cmvbm.js.gz +0 -0
- package/web/chunk-crhbhsrh.js.br +0 -0
- package/web/chunk-crhbhsrh.js.gz +0 -0
- package/web/chunk-e3d6kvwm.js.br +0 -0
- package/web/chunk-e3d6kvwm.js.gz +0 -0
- package/web/chunk-eq28qb33.js.br +0 -3
- package/web/chunk-eq28qb33.js.gz +0 -0
- package/web/chunk-f8ac76br.js +0 -2
- package/web/chunk-f8ac76br.js.br +0 -3
- package/web/chunk-f8ac76br.js.gz +0 -0
- package/web/chunk-fp7q643n.js.br +0 -0
- package/web/chunk-fp7q643n.js.gz +0 -0
- package/web/chunk-g1penf6y.js.br +0 -0
- package/web/chunk-g1penf6y.js.gz +0 -0
- package/web/chunk-g7t1bvvx.js.br +0 -0
- package/web/chunk-g7t1bvvx.js.gz +0 -0
- package/web/chunk-gf4ky7tp.js +0 -8
- package/web/chunk-gf4ky7tp.js.br +0 -0
- package/web/chunk-gf4ky7tp.js.gz +0 -0
- package/web/chunk-gtcjwz0j.js +0 -1
- package/web/chunk-gtcjwz0j.js.br +0 -2
- package/web/chunk-gtcjwz0j.js.gz +0 -0
- package/web/chunk-gy2y4zfa.js.br +0 -0
- package/web/chunk-gy2y4zfa.js.gz +0 -0
- package/web/chunk-h1cv1kke.js.br +0 -0
- package/web/chunk-h1cv1kke.js.gz +0 -0
- package/web/chunk-h6k80vqf.js +0 -1
- package/web/chunk-h6k80vqf.js.br +0 -0
- package/web/chunk-h6k80vqf.js.gz +0 -0
- package/web/chunk-hqtm67yw.js.br +0 -0
- package/web/chunk-hqtm67yw.js.gz +0 -0
- package/web/chunk-hsgtzrkh.js.br +0 -0
- package/web/chunk-hsgtzrkh.js.gz +0 -0
- package/web/chunk-j7phw79h.js +0 -1
- package/web/chunk-j7phw79h.js.br +0 -0
- package/web/chunk-j7phw79h.js.gz +0 -0
- package/web/chunk-k69ysa0v.js.br +0 -0
- package/web/chunk-k69ysa0v.js.gz +0 -0
- package/web/chunk-k7h5g8qj.js +0 -1
- package/web/chunk-k7h5g8qj.js.br +0 -2
- package/web/chunk-k7h5g8qj.js.gz +0 -0
- package/web/chunk-k8x1xbf6.js.br +0 -0
- package/web/chunk-k8x1xbf6.js.gz +0 -0
- package/web/chunk-kbvzxsz7.js.br +0 -0
- package/web/chunk-kbvzxsz7.js.gz +0 -0
- package/web/chunk-kn9bc5z2.js.br +0 -0
- package/web/chunk-kn9bc5z2.js.gz +0 -0
- package/web/chunk-ksr360js.js.br +0 -0
- package/web/chunk-ksr360js.js.gz +0 -0
- package/web/chunk-m5nt857c.js.br +0 -0
- package/web/chunk-m5nt857c.js.gz +0 -0
- package/web/chunk-mbaw66b5.js.br +0 -0
- package/web/chunk-mbaw66b5.js.gz +0 -0
- package/web/chunk-ms7cscs9.js.br +0 -0
- package/web/chunk-ms7cscs9.js.gz +0 -0
- package/web/chunk-n59nyqcr.js.br +0 -0
- package/web/chunk-n59nyqcr.js.gz +0 -0
- package/web/chunk-n9npqkxf.js.br +0 -0
- package/web/chunk-n9npqkxf.js.gz +0 -0
- package/web/chunk-nb3jk1wk.js.br +0 -0
- package/web/chunk-nb3jk1wk.js.gz +0 -0
- package/web/chunk-ny87aq2j.js.br +0 -0
- package/web/chunk-ny87aq2j.js.gz +0 -0
- package/web/chunk-phr7yps3.js.br +0 -0
- package/web/chunk-phr7yps3.js.gz +0 -0
- package/web/chunk-ppccb30x.js.br +0 -0
- package/web/chunk-ppccb30x.js.gz +0 -0
- package/web/chunk-q17rem99.js.br +0 -0
- package/web/chunk-q17rem99.js.gz +0 -0
- package/web/chunk-qdq6wvgt.js.br +0 -0
- package/web/chunk-qdq6wvgt.js.gz +0 -0
- package/web/chunk-qhr6hegh.js.br +0 -0
- package/web/chunk-qhr6hegh.js.gz +0 -0
- package/web/chunk-qqtj88e0.js.br +0 -0
- package/web/chunk-qqtj88e0.js.gz +0 -0
- package/web/chunk-r165xpp5.js +0 -1
- package/web/chunk-r165xpp5.js.br +0 -0
- package/web/chunk-r165xpp5.js.gz +0 -0
- package/web/chunk-r4cr8rvt.js.br +0 -0
- package/web/chunk-r4cr8rvt.js.gz +0 -0
- package/web/chunk-sapy54hm.js.br +0 -0
- package/web/chunk-sapy54hm.js.gz +0 -0
- package/web/chunk-sarkb4p9.js.br +0 -0
- package/web/chunk-sarkb4p9.js.gz +0 -0
- package/web/chunk-t7vwsg9r.js.br +0 -0
- package/web/chunk-t7vwsg9r.js.gz +0 -0
- package/web/chunk-tt7j0m6m.js.br +0 -0
- package/web/chunk-tt7j0m6m.js.gz +0 -0
- package/web/chunk-va1rkfan.js +0 -1
- package/web/chunk-va1rkfan.js.br +0 -0
- package/web/chunk-va1rkfan.js.gz +0 -0
- package/web/chunk-vb3sy3hv.js.br +0 -0
- package/web/chunk-vb3sy3hv.js.gz +0 -0
- package/web/chunk-vgpyff03.js.br +0 -0
- package/web/chunk-vgpyff03.js.gz +0 -0
- package/web/chunk-w563538j.js.br +0 -0
- package/web/chunk-w563538j.js.gz +0 -0
- package/web/chunk-w71t7mes.js +0 -1
- package/web/chunk-w71t7mes.js.br +0 -0
- package/web/chunk-w71t7mes.js.gz +0 -0
- package/web/chunk-w96etr1w.js +0 -1
- package/web/chunk-w96etr1w.js.br +0 -0
- package/web/chunk-w96etr1w.js.gz +0 -0
- package/web/chunk-wrqazg2v.js.br +0 -0
- package/web/chunk-wrqazg2v.js.gz +0 -0
- package/web/chunk-xv1d350x.js.br +0 -0
- package/web/chunk-xv1d350x.js.gz +0 -0
- package/web/chunk-xw8tzrmm.js.br +0 -0
- package/web/chunk-xw8tzrmm.js.gz +0 -0
- package/web/chunk-xwsh4jx7.js +0 -1
- package/web/chunk-xwsh4jx7.js.br +0 -2
- package/web/chunk-xwsh4jx7.js.gz +0 -0
- package/web/chunk-xxk7xkrs.js +0 -1
- package/web/chunk-xxk7xkrs.js.br +0 -0
- package/web/chunk-xxk7xkrs.js.gz +0 -0
- package/web/chunk-y5zd05mz.js.br +0 -0
- package/web/chunk-y5zd05mz.js.gz +0 -0
- package/web/chunk-yg9a23mv.js.br +0 -0
- package/web/chunk-yg9a23mv.js.gz +0 -0
- package/web/chunk-ygzgrjj7.js.br +0 -0
- package/web/chunk-ygzgrjj7.js.gz +0 -0
- package/web/chunk-yp75a6yh.js.br +0 -0
- package/web/chunk-yp75a6yh.js.gz +0 -0
- package/web/chunk-zs7c2db4.js.br +0 -0
- package/web/chunk-zs7c2db4.js.gz +0 -0
- package/web/chunk-zsae1tn8.js.br +0 -0
- package/web/chunk-zsae1tn8.js.gz +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{gt}from"./chunk-
|
|
3
|
+
import{gt}from"./chunk-9fccgczj.js";import{Ne}from"./chunk-8yv55y6g.js";import{Xe,Mr,ns,os,ii}from"./chunk-rmy489b1.js";import{chmodSync as Ur,mkdirSync as Tt,readFileSync as Br,rmSync as mt,writeFileSync as Dr}from"fs";import{dirname as bt,join as ke,resolve as Cr}from"path";import{parseArgs as Lr}from"util";var We=void 0;import{join as Ut}from"path";import{existsSync as Ye,readdirSync as $t}from"fs";import{join as Rt}from"path";var Mt={".html":"text/html; charset=utf-8",".js":"application/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".woff2":"font/woff2",".png":"image/png",".svg":"image/svg+xml; charset=utf-8",".webmanifest":"application/manifest+json; charset=utf-8",".sh":"text/plain; charset=utf-8",".ps1":"text/plain; charset=utf-8"};var Ot=/^chunk-[a-z0-9]+\.(js|css)$|-[a-z0-9]{8}\.(woff2|png|svg|webmanifest)$/;function He(e){let t={};for(let r of $t(e)){if(r.endsWith(".br")||r.endsWith(".gz"))continue;t[`/${r}`]=oe(e,r)}return t["/"]=oe(e,"index.html"),t["/*"]=oe(e,"index.html"),t}function oe(e,t){let r=Rt(e,t),n=Mt[t.slice(t.lastIndexOf("."))]??"application/octet-stream",s=t==="index.html"||t==="sw.js"||t==="manifest.webmanifest"?"no-cache":Ot.test(t)?"public, max-age=31536000, immutable":"public, max-age=3600",o=Ye(`${r}.br`),l=Ye(`${r}.gz`);return(u)=>{let I=u.headers.get("accept-encoding")??"",g=o&&/\bbr\b/.test(I)?"br":l&&/\bgzip\b/.test(I)?"gzip":void 0,d={"content-type":n,"cache-control":s};if(o||l)d.vary="accept-encoding";if(!g)return new Response(Bun.file(r),{headers:d});return d["content-encoding"]=g,new Response(Bun.file(`${r}.${g==="br"?"br":"gz"}`),{headers:d})}}var Ge=He(Ut(import.meta.dir,"web"));import{existsSync as M,mkdirSync as H,rmSync as W,writeFileSync as le}from"fs";import{homedir as pe}from"os";import{dirname as ue,join as P}from"path";import{closeSync as Bt,existsSync as Ve,mkdirSync as Dt,openSync as Ct,readdirSync as Lt,readFileSync as D,rmSync as Nt,writeFileSync as Wt}from"fs";import{join as C,resolve as Qe}from"path";var je=20000,Yt=262144;function T(e){return C(e,"basalt.log")}function ie(e){try{let t=JSON.parse(D(e,"utf8"));if(typeof t!=="object"||t===null)return;let r=t;if(typeof r.pid!=="number"||!Number.isInteger(r.pid)||r.pid<=0)return;if(typeof r.url!=="string")return;let n=new URL(r.url);if(n.protocol!=="http:"&&n.protocol!=="https:")return;let s=Array.isArray(r.argv)&&r.argv.every((o)=>typeof o==="string")?r.argv.map((o)=>String(o)):void 0;return{pid:r.pid,url:r.url,...typeof r.hwnd==="number"&&Number.isInteger(r.hwnd)&&r.hwnd>0?{hwnd:r.hwnd}:{},...s?{argv:s}:{},...typeof r.cwd==="string"&&r.cwd?{cwd:r.cwd}:{},...typeof r.secret==="string"&&r.secret?{secret:r.secret}:{}}}catch{return}}function ae(e){try{return process.kill(e,0),!0}catch{return!1}}async function f(e,t){let r=C(e,"server.json");if(!Ve(r))return;let n=ie(r);if(!n||t!==void 0&&n.pid!==t)return;return ce(n.pid)?n:void 0}async function Ke(e,t=1500){try{return(await fetch(`${e.url}/api/info`,{signal:AbortSignal.timeout(t)})).ok}catch{return!1}}function ce(e){if(!A(e))return!1;let t=Ht(e);return t===void 0||/bun|basalt/i.test(t)}function A(e){if(!ae(e))return!1;if(process.platform!=="linux")return!0;try{return D(`/proc/${e}/stat`,"utf8").split(") ")[1]?.[0]!=="Z"}catch{return!0}}function Ht(e){try{if(process.platform==="linux")return D(`/proc/${e}/cmdline`,"utf8");let t=process.platform==="win32"?Bun.spawnSync(["tasklist","/FI",`PID eq ${e}`,"/FO","CSV","/NH"],{windowsHide:!0}):Bun.spawnSync(["ps","-p",String(e),"-o","command="]);return t.success?t.stdout.toString():void 0}catch{return}}function qe(e,t){Dt(e,{recursive:!0});let r=C(e,`${process.pid}.json`);return Wt(r,JSON.stringify({dataDir:Qe(t)})),r}async function Ze(e){if(!Ve(e))return[];let t=[];for(let r of Lt(e)){let n=/^(\d+)\.json$/.exec(r);if(!n)continue;let s=C(e,r),o=Number(n[1]);if(!A(o)){Nt(s,{force:!0});continue}let l;try{l=JSON.parse(D(s,"utf8"))}catch{continue}if(!l||typeof l!=="object"||!("dataDir"in l)||typeof l.dataDir!=="string")continue;let u=await f(l.dataDir,o);if(u)t.push({dataDir:l.dataDir,service:u})}return t}async function L(e,t){if(t?.secret&&t.pid===e){let r=new URL(t.url);if(["127.0.0.1","localhost","[::1]"].includes(r.hostname))try{if((await fetch(new URL("/api/server/shutdown",r),{method:"POST",headers:{authorization:`Bearer ${t.secret}`},redirect:"error",signal:AbortSignal.timeout(2000)})).ok){for(let s=0;s<220&&A(e);s++)await Bun.sleep(100);if(!A(e))return}}catch(n){if(A(e))console.warn("\u6B63\u5E38\u5173\u505C\u8BF7\u6C42\u5931\u8D25\uFF0C\u56DE\u9000\u5230\u8FDB\u7A0B\u4FE1\u53F7\uFF1A",n instanceof Error?n.message:String(n))}}try{process.kill(e,"SIGTERM")}catch{return}for(let r=0;r<50&&A(e);r++)await Bun.sleep(100);if(A(e)){try{process.kill(e,"SIGKILL")}catch(r){if(!(r instanceof Error&&("code"in r)&&r.code==="ESRCH"))console.error(`\u65E0\u6CD5\u5F3A\u5236\u7ED3\u675F\u8FDB\u7A0B ${e}\uFF1A`,r)}await Bun.sleep(200)}}function N(e,t){let r=[];for(let n=0;n<e.length;n++){let s=e[n];if(s===void 0)continue;if(s==="--data"){n++;continue}if(s.startsWith("--data=")||s==="--open"||s==="--replace"||s==="--foreground")continue;r.push(s)}return[...r,"--data",Qe(t)]}async function Je(e){if(e.command.length===0)throw Error("\u7F3A\u5C11\u540E\u53F0\u670D\u52A1\u542F\u52A8\u5165\u53E3");let t=Ct(T(e.dataDir),"a",384),r;try{r=Bun.spawn([...e.command,...e.args.filter((s)=>s!=="--foreground"),"--foreground"],{cwd:e.cwd??process.cwd(),detached:!0,stdio:["ignore",t,t],windowsHide:!0})}finally{Bt(t)}r.unref();let n=Date.now()+je;while(Date.now()<n){if(r.exitCode!==null)throw Error(`\u670D\u52A1\u8FDB\u7A0B\u5728\u5C31\u7EEA\u524D\u9000\u51FA\uFF08\u9000\u51FA\u7801 ${r.exitCode}\uFF09`);let s=await f(e.dataDir,r.pid);if(s)return s;await Bun.sleep(100)}throw await L(r.pid),Error(`\u7B49\u5F85\u670D\u52A1\u5C31\u7EEA\u8D85\u65F6\uFF08${je/1000} \u79D2\uFF09`)}async function ze(e){let t=Bun.file(T(e));if(!await t.exists()||t.size===0)return;let r=Math.max(0,t.size-Yt),n=await t.slice(r).text();if(r>0){let s=n.indexOf(`
|
|
4
4
|
`);if(s>=0)n=n.slice(s+1)}return n||void 0}var tt="work.basalt",V="basalt.service",Gt=`
|
|
5
5
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
6
6
|
$shell = New-Object -ComObject WScript.Shell
|
|
@@ -375,10 +375,10 @@ ${o}`.trim()}}class _e{options;latest;checkedAt;error;applying=!1;installed;mana
|
|
|
375
375
|
--no-update-check \u4E0D\u81EA\u52A8\u68C0\u67E5\u548C\u5B89\u88C5\u65B0\u7248\u672C\uFF08\u4E5F\u53EF\u8BBE BASALT_NO_UPDATE_CHECK=1\uFF09
|
|
376
376
|
-v, --version \u663E\u793A\u7248\u672C
|
|
377
377
|
-h, --help \u663E\u793A\u5E2E\u52A9
|
|
378
|
-
`,{values:i,positionals:p}=Lr({allowPositionals:!0,options:{host:{type:"string"},port:{type:"string"},"no-auth":{type:"boolean",default:!1},"no-tray":{type:"boolean",default:!1},"insecure-http":{type:"boolean",default:!1},"allow-remote-no-auth":{type:"boolean",default:!1},"allow-origin":{type:"string",multiple:!0,default:[]},"allow-host":{type:"string",multiple:!0,default:[]},"web-url":{type:"string"},model:{type:"string"},demo:{type:"boolean",default:!1},data:{type:"string"},token:{type:"string"},team:{type:"string"},aud:{type:"string"},open:{type:"boolean",default:!1},foreground:{type:"boolean",default:!1},replace:{type:"boolean",default:!1},"no-update-check":{type:"boolean",default:!1},version:{type:"boolean",short:"v",default:!1},help:{type:"boolean",short:"h",default:!1}}});if(i.help||p[0]==="help"&&p.length===1)console.log(Nr),process.exit(0);if(i.version)console.log(gt.version),process.exit(0);var re=process.argv.slice(2),St=ke(Xe(),"instances"),c=i.data??(["status","stop","restart","logs","pair","plugin"].includes(p[0]??"")?await sn():Xe()),$e=!0,q="@bkm016/basalt",ne=$e&&!q?[process.execPath]:[process.execPath,Bun.main],h=p[0],Wr=!i["no-update-check"]&&!process.env.BASALT_NO_UPDATE_CHECK;async function It(){let{ProxyManager:e}=await import("./chunk-
|
|
379
|
-
\u8FD0\u884C basalt --help \u67E5\u770B\u53EF\u7528\u547D\u4EE4`),process.exit(1);Tt(c,{recursive:!0});De();var{chatGPTProvider:Yr,ModelProviderManager:Hr,NetworkManager:Gr,ProviderAuthManager:jr,resolveNetworkHost:Vr,startServer:Qr,TunnelManager:Xr}=await import("./chunk-
|
|
378
|
+
`,{values:i,positionals:p}=Lr({allowPositionals:!0,options:{host:{type:"string"},port:{type:"string"},"no-auth":{type:"boolean",default:!1},"no-tray":{type:"boolean",default:!1},"insecure-http":{type:"boolean",default:!1},"allow-remote-no-auth":{type:"boolean",default:!1},"allow-origin":{type:"string",multiple:!0,default:[]},"allow-host":{type:"string",multiple:!0,default:[]},"web-url":{type:"string"},model:{type:"string"},demo:{type:"boolean",default:!1},data:{type:"string"},token:{type:"string"},team:{type:"string"},aud:{type:"string"},open:{type:"boolean",default:!1},foreground:{type:"boolean",default:!1},replace:{type:"boolean",default:!1},"no-update-check":{type:"boolean",default:!1},version:{type:"boolean",short:"v",default:!1},help:{type:"boolean",short:"h",default:!1}}});if(i.help||p[0]==="help"&&p.length===1)console.log(Nr),process.exit(0);if(i.version)console.log(gt.version),process.exit(0);var re=process.argv.slice(2),St=ke(Xe(),"instances"),c=i.data??(["status","stop","restart","logs","pair","plugin"].includes(p[0]??"")?await sn():Xe()),$e=!0,q="@bkm016/basalt",ne=$e&&!q?[process.execPath]:[process.execPath,Bun.main],h=p[0],Wr=!i["no-update-check"]&&!process.env.BASALT_NO_UPDATE_CHECK;async function It(){let{ProxyManager:e}=await import("./chunk-93bcazsp.js"),t=new e(c);t.load();let r=new _e({current:gt.version,packageName:q,packageDir:bt(Bun.main),fetch:t.createFetch(Mr),env:t.providerOptions({},Mr).env,disabled:q?void 0:$e?"\u5355\u6587\u4EF6\u7248\u4E0D\u652F\u6301\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u6539\u7528 npm i -g @bkm016/basalt \u6216 bun add -g @bkm016/basalt \u5B89\u88C5":"\u4ECE\u6E90\u7801\u8FD0\u884C\uFF0C\u7528 git pull \u66F4\u65B0"});return{proxy:t,updater:r}}var ve=i.host===void 0||Ne(i.host),Re=i.port!==void 0,se=Re?Number(i.port):ii;if(Re&&(!/^\d+$/.test(i.port??"")||se>65535))console.error(`\u7AEF\u53E3\u53C2\u6570\u65E0\u6548\uFF1A${i.port}\u3002--port \u5E94\u4E3A 0-65535 \u4E4B\u95F4\u7684\u6574\u6570\u3002`),process.exit(1);if(h==="update"&&p.length===1)process.exit(await nn());if(h==="tunnel"){let{tunnelCommand:e}=await import("./chunk-ff293dj0.js");process.exit(await e(c,p[1],p[2],{token:i.token,team:i.team,aud:i.aud,port:se}))}if(h==="setup"&&p.length===1)process.exit(it({compiled:$e,npmPackage:q,executable:process.execPath}));if(h==="plugin"){let[,e,t]=p;if(e!=="reload"||!t||p.length!==3)console.error("\u7528\u6CD5: basalt plugin reload <id> [--data <\u76EE\u5F55>]"),process.exit(1);process.exit(await rt(c,t))}if(h==="status"&&p.length===1)process.exit(await an());if(h==="stop"&&p.length===1)process.exit(await cn());if(h==="restart"&&p.length===1)process.exit(await ln());if(h==="logs"&&p.length===1)process.exit(await un());if(h==="pair"&&p.length===1)process.exit(await pn());if(h==="autostart"&&p.length===2)process.exit(await dn(p[1]??""));if(p.length)console.error(`\u672A\u77E5\u547D\u4EE4\uFF1A${p.join(" ")}
|
|
379
|
+
\u8FD0\u884C basalt --help \u67E5\u770B\u53EF\u7528\u547D\u4EE4`),process.exit(1);Tt(c,{recursive:!0});De();var{chatGPTProvider:Yr,ModelProviderManager:Hr,NetworkManager:Gr,ProviderAuthManager:jr,resolveNetworkHost:Vr,startServer:Qr,TunnelManager:Xr}=await import("./chunk-61e7nvw9.js"),Me=new Gr(c);Me.load();var Oe;try{Oe=Vr(Me.settings(),{host:i.host,auth:!i["no-auth"],insecureHttp:i["insecure-http"],allowRemoteNoAuth:i["allow-remote-no-auth"]})}catch(e){console.error(`\u62D2\u7EDD\u542F\u52A8\uFF1A${e instanceof Error?e.message:String(e)}`),process.exit(1)}if(!i.foreground)process.exit(await on());var{builtinPlugins:Kr}=await import("./chunk-gwcstcqs.js"),{FileCredentialStore:qr,modelID:Zr,proxyTargets:Jr,Runtime:zr}=await import("./chunk-93bcazsp.js"),{builtinModels:en}=await import("./chunk-3zv7ryz0.js"),{demoProviders:tn}=await import("./chunk-nwfhbcme.js");await import("./chunk-m839588n.js");var{proxy:Ue,updater:E}=await It(),Be=N(re,c),At=!1,xe=At?{sourceRoot:Cr(bt(Bun.main),"../../.."),watched:!!process.env.BASALT_DEV_GUARD}:void 0,rn=70,ht=20000,Z=ke(c,"server.json"),Pt=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("base64url"),b=await f(c);if(b&&i.replace)await L(b.pid,b),b=void 0;if(b){if(!i["no-tray"]&&typeof b.hwnd==="number")be(b.hwnd);console.log(`basalt \u5DF2\u5728\u8FD0\u884C\uFF1A${b.url}`),process.exit(0)}async function nn(){let{updater:e}=await It(),t=await e.check();if(t.disabled)return console.error(t.disabled),1;if(t.error)return console.error(t.error),1;if(!t.available)return console.log(`\u5DF2\u662F\u6700\u65B0\u7248\u672C v${t.current}`),0;console.log(`\u6B63\u5728\u901A\u8FC7 ${t.manager} \u66F4\u65B0 v${t.current} \u2192 v${t.latest}\u2026`);try{await e.apply()}catch(n){return console.error(n instanceof Error?n.message:String(n)),1}let r=ie(ke(c,"server.json"));if(r&&ae(r.pid))console.log(`\u5DF2\u66F4\u65B0\u5230 v${t.latest}\uFF0C\u6B63\u5728\u8FD0\u884C\u7684 Basalt \u4F1A\u5728\u6240\u6709\u5BF9\u8BDD\u7A7A\u95F2\u540E\u81EA\u52A8\u91CD\u542F`);else console.log(`\u5DF2\u66F4\u65B0\u5230 v${t.latest}`);return 0}async function sn(){let e=Xe();if(await f(e))return e;let t=await Ze(St),r=t.length===1?t[0]:void 0;if(r)return r.dataDir;if(t.length>1){console.error("\u6709\u591A\u4E2A basalt \u5B9E\u4F8B\u5728\u8FD0\u884C\uFF0C\u7528 --data \u6307\u5B9A\u8981\u64CD\u4F5C\u7684\u4E00\u4E2A\uFF1A");for(let{dataDir:n,service:s}of t)console.error(` ${s.url} --data "${n}"`);process.exit(1)}return e}async function on(){let e=await f(c);if(e&&!i.replace){if(!i["no-tray"]&&typeof e.hwnd==="number")be(e.hwnd);return console.log(`basalt \u5DF2\u5728\u8FD0\u884C\uFF1A${e.url}`),0}return _t(re,process.cwd())}async function _t(e,t){try{let r=await Je({command:ne,args:e,dataDir:c,cwd:t});return console.log(`basalt \u5DF2\u5728\u540E\u53F0\u8FD0\u884C\uFF1A${r.url}`),console.log(`\u65E5\u5FD7\uFF1A${T(c)}`),0}catch(r){return console.error(`\u540E\u53F0\u542F\u52A8\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`),console.error(`\u65E5\u5FD7\uFF1A${T(c)}`),1}}async function an(){let e=await f(c);if(!e)return console.log("basalt \u672A\u8FD0\u884C"),1;let t=await Ke(e)?"":"\uFF0C\u6682\u65F6\u65E0\u54CD\u5E94\uFF0C\u53EF\u80FD\u6B63\u5FD9";return console.log(`basalt \u6B63\u5728\u8FD0\u884C\uFF1A${e.url}\uFF08PID ${e.pid}${t}\uFF09`),0}async function vt(e){if(await L(e.pid,e),ce(e.pid))return console.error(`\u65E0\u6CD5\u505C\u6B62 Basalt \u8FDB\u7A0B ${e.pid}`),!1;return!0}async function cn(){let e=await f(c);if(!e)return console.log("basalt \u672A\u8FD0\u884C"),0;if(!await vt(e))return 1;return console.log("basalt \u5DF2\u505C\u6B62"),0}async function ln(){De(),Tt(c,{recursive:!0});let e=await f(c),t=N(e?.argv??re.slice(1),c),r=e?.cwd??process.cwd();if(e&&!await vt(e))return 1;if(i.open)t.push("--open");return _t(t,r)}async function un(){let e=await ze(c);if(!e)return console.error(`\u6CA1\u6709\u540E\u53F0\u65E5\u5FD7\uFF1A${T(c)}`),1;return process.stdout.write(e.endsWith(`
|
|
380
380
|
`)?e:`${e}
|
|
381
|
-
`),0}async function pn(){let e=await f(c);if(!e)return console.error("basalt \u672A\u8FD0\u884C\uFF0C\u5148\u8FD0\u884C basalt \u542F\u52A8\u670D\u52A1"),1;if(!e.secret)return console.error("\u6B63\u5728\u8FD0\u884C\u7684\u670D\u52A1\u7248\u672C\u8FC7\u65E7\uFF0C\u4E0D\u652F\u6301\u8BE5\u547D\u4EE4\uFF1B\u8FD0\u884C basalt restart \u540E\u91CD\u8BD5"),1;let t;try{t=await fetch(`${e.url}/api/pair/code`,{method:"POST",redirect:"error",headers:{Authorization:`Bearer ${e.secret}`},signal:AbortSignal.timeout(1e4)})}catch(o){return console.error(`\u65E0\u6CD5\u8FDE\u63A5 ${e.url}\uFF1A${o instanceof Error?o.message:String(o)}`),1}if(!t.ok){let o=await t.json().catch(()=>{return}),l=o?.error?.message?`\uFF1A${o.error.message}`:"";return console.error(`\u83B7\u53D6\u914D\u5BF9\u7801\u5931\u8D25\uFF08HTTP ${t.status}\uFF09${l}`),1}let{code:r}=await t.json();console.log(`\u914D\u5BF9\u7801 ${r.slice(0,4)}-${r.slice(4)}\uFF0810 \u5206\u949F\u5185\u6709\u6548\uFF0C\u7528\u4E00\u6B21\u5373\u5931\u6548\uFF09`);let{TunnelManager:n}=await import("./chunk-
|
|
381
|
+
`),0}async function pn(){let e=await f(c);if(!e)return console.error("basalt \u672A\u8FD0\u884C\uFF0C\u5148\u8FD0\u884C basalt \u542F\u52A8\u670D\u52A1"),1;if(!e.secret)return console.error("\u6B63\u5728\u8FD0\u884C\u7684\u670D\u52A1\u7248\u672C\u8FC7\u65E7\uFF0C\u4E0D\u652F\u6301\u8BE5\u547D\u4EE4\uFF1B\u8FD0\u884C basalt restart \u540E\u91CD\u8BD5"),1;let t;try{t=await fetch(`${e.url}/api/pair/code`,{method:"POST",redirect:"error",headers:{Authorization:`Bearer ${e.secret}`},signal:AbortSignal.timeout(1e4)})}catch(o){return console.error(`\u65E0\u6CD5\u8FDE\u63A5 ${e.url}\uFF1A${o instanceof Error?o.message:String(o)}`),1}if(!t.ok){let o=await t.json().catch(()=>{return}),l=o?.error?.message?`\uFF1A${o.error.message}`:"";return console.error(`\u83B7\u53D6\u914D\u5BF9\u7801\u5931\u8D25\uFF08HTTP ${t.status}\uFF09${l}`),1}let{code:r}=await t.json();console.log(`\u914D\u5BF9\u7801 ${r.slice(0,4)}-${r.slice(4)}\uFF0810 \u5206\u949F\u5185\u6709\u6548\uFF0C\u7528\u4E00\u6B21\u5373\u5931\u6548\uFF09`);let{TunnelManager:n}=await import("./chunk-61e7nvw9.js"),s=new n(c,{localPort:()=>ii}).publicURL();if(s)console.log(`\u8FDC\u7A0B\uFF1A${te(s,s,r)}`);return console.log(`\u672C\u673A\uFF1A${te(e.url,e.url,r)}`),0}async function dn(e){try{if(e==="status"){let s=Q(c);return console.log(s.enabled?`\u5DF2\u5F00\u542F\u767B\u5F55\u81EA\u542F\uFF1A${s.target}`:`\u672A\u5F00\u542F\u767B\u5F55\u81EA\u542F\uFF1A${s.target}`),0}if(e==="disable"){let s=ye(c);return console.log(`\u5DF2\u5173\u95ED\u767B\u5F55\u81EA\u542F\uFF1A${s}`),0}if(e!=="enable")return console.error("\u7528\u6CD5\uFF1Abasalt autostart <enable|disable|status> [--data <\u76EE\u5F55>]"),1;De();let t=await f(c),r=N(t?.argv??re.slice(2),c),n=he({command:ne,args:r,dataDir:c,cwd:t?.cwd??process.cwd()});return console.log(`\u5DF2\u5F00\u542F\u767B\u5F55\u81EA\u542F\uFF1A${n}`),console.log("\u5F53\u524D\u670D\u52A1\u4FDD\u6301\u4E0D\u53D8\uFF0C\u4E0B\u6B21\u767B\u5F55\u751F\u6548\u3002"),0}catch(t){return console.error(t instanceof Error?t.message:String(t)),1}}function De(){if(!ve&&!i["insecure-http"])console.error("\u62D2\u7EDD\u542F\u52A8\uFF1A\u975E\u672C\u673A\u76D1\u542C\u5FC5\u987B\u901A\u8FC7 HTTPS/WSS\uFF0C\u6216\u663E\u5F0F\u4F20\u5165 --insecure-http\u3002"),process.exit(1);if(!ve&&i["no-auth"]&&!i["allow-remote-no-auth"])console.error("\u62D2\u7EDD\u542F\u52A8\uFF1A\u975E\u672C\u673A\u76D1\u542C\u4E0D\u80FD\u5173\u95ED\u8BA4\u8BC1\uFF0C\u9664\u975E\u663E\u5F0F\u4F20\u5165 --allow-remote-no-auth\u3002"),process.exit(1);for(let t of i["allow-host"])if(!/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9.-]*[a-zA-Z0-9])?|\[[0-9a-fA-F:]+\])$/.test(t))console.error("--allow-host \u5FC5\u987B\u662F\u4E3B\u673A\u540D\uFF0C\u4E0D\u542B\u534F\u8BAE\u3001\u7AEF\u53E3\u3001\u8DEF\u5F84\u6216\u901A\u914D\u7B26\u3002"),process.exit(1);if(i["no-auth"]&&i["allow-origin"].includes("*"))console.error("\u62D2\u7EDD\u542F\u52A8\uFF1A\u5173\u95ED\u8BA4\u8BC1\u65F6\u4E0D\u80FD\u7528 --allow-origin * \u653E\u5F00\u4EFB\u610F\u6765\u6E90\u3002\u53BB\u6389 --allow-origin *\uFF0C\u6216\u53BB\u6389 --no-auth\u3002"),process.exit(1);let e=i["web-url"];if(e!==void 0){let t=URL.canParse(e)?new URL(e).protocol:void 0;if(t!=="http:"&&t!=="https:")console.error(`--web-url \u65E0\u6548\uFF1A${e}\u3002\u5E94\u4E3A\u5B8C\u6574\u7684 http:// \u6216 https:// \u5730\u5740\u3002`),process.exit(1)}}var U=new qr(c);U.load();U.migrateOpenAISubscription();var k=Ue.models(en({credentials:U})),Ce=Yr();k.setProvider(Ce);if(i.demo||process.env.BASALT_DEMO_MODELS)for(let e of tn())k.setProvider(e);var J=new Hr(c,k,Ue);await J.load();var xt=new jr(k,U),Ft=()=>[Ce.id,...i.demo?["demo"]:[],...J.list().map((e)=>e.id)],fn=Ft(),z=i.model??process.env.BASALT_MODEL??(i.demo?"demo/echo":(await k.getAvailable()).filter((e)=>fn.includes(e.provider)).map(Zr)[0]);if(!z)console.warn("\u8FD8\u6CA1\u6709\u53EF\u7528\u7684\u6A21\u578B\uFF1A\u6253\u5F00\u5DE5\u4F5C\u53F0\u6309\u5F15\u5BFC\u6DFB\u52A0\u6A21\u578B\u670D\u52A1\u5546\u4E0E API key\uFF0C\u6216\u52A0 --demo \u8BD5\u7528\u3002");var Le=await zr.create({builtinPlugins:Kr,dataDir:c,models:k,defaultModel:z??"demo/echo",visibleModelProviders:Ft,development:xe}),B=!i["no-auth"],Fe=se,S=new Xr(c,{localPort:()=>Fe});if(!B&&S.status().configured)console.error("\u62D2\u7EDD\u542F\u52A8\uFF1A\u5DF2\u914D\u7F6E\u8FDC\u7A0B\u8BBF\u95EE\uFF0C\u4E0D\u80FD\u540C\u65F6\u7528 --no-auth \u5173\u95ED\u8BA4\u8BC1\u3002\u5148\u8FD0\u884C basalt tunnel off\uFF0C\u6216\u53BB\u6389 --no-auth\u3002"),process.exit(1);var v=[...i["allow-origin"]];if(!v.includes("*")){for(let e of os)if(!v.includes(e))v.push(e)}if(i["web-url"]){let e=new URL(i["web-url"]).origin;if(!v.includes("*")&&!v.includes(e))v.push(e)}var m=Qr({runtime:Le,dataDir:c,host:Oe,network:Me,networkHostOverride:i.host,port:se,fallbackPort:!Re,auth:B,origins:v,allowedHosts:i["allow-host"],web:We,webStatic:Ge,development:At,version:gt.version??"dev",modelProviders:J,providerAuth:xt,proxy:Ue,proxyTargets:()=>Jr([Ce,...J.list()]),tunnel:S,cliSecret:Pt,approveLocalPairing:process.platform==="win32"?lt:void 0,restart:gn,shutdown:()=>{setTimeout(()=>void x(),0)},autostart:{status:()=>Q(c),set(e){if(e)he({command:ne,args:Be,dataDir:c,cwd:process.cwd()});else ye(c);return Q(c)}},updates:{status:()=>E.status(),check:()=>E.check(),async apply(){let e=await E.apply();return setTimeout(()=>void E.watch(),300),e}}});Fe=m.tunnelPort??Fe;S.start();var ee=!1,yt=!1;function Et(){return Le.list(!0,{archive:"all"}).every((e)=>e.status!=="busy")}function gn(){if(yt||ee)return;yt=!0;let e=()=>{if(ee)return;if(!Et()){setTimeout(e,1000).unref?.();return}console.log(`
|
|
382
382
|
\u5BF9\u8BDD\u5747\u5DF2\u7A7A\u95F2\uFF0C\u6B63\u5728\u6309\u539F\u53C2\u6570\u91CD\u542F\u670D\u52A1\u2026`),x(!0)};setTimeout(e,300).unref?.()}var Ee=i["no-tray"]?void 0:await ut({title:`Basalt ${gt.version??"dev"} (${new URL(m.url).host})`,tooltip:`Basalt \u2014 ${m.url}`,auth:B,onOpen:()=>Se(O()),onCopyLink:()=>Ie(O()),onCopyCode:()=>{let e=m.auth.pairingCode();Ie(`${e.slice(0,4)}-${e.slice(4)}`)},onQuit:()=>{x()}});Dr(Z,JSON.stringify({pid:process.pid,url:m.url,argv:Be,cwd:process.cwd(),secret:Pt,...Ee?{hwnd:Ee.hwnd}:{}}),{mode:384});Ur(Z,384);var mn=qe(St,c),x=async(e=!1,t=0)=>{if(ee){if(t!==0)process.exit(t);return}ee=!0;try{let s=JSON.parse(Br(Z,"utf8"));if(s&&typeof s==="object"&&"pid"in s&&s.pid===process.pid)mt(Z,{force:!0})}catch(s){if(!(s instanceof Error&&("code"in s)&&s.code==="ENOENT"))console.error("\u65E0\u6CD5\u6E05\u7406\u670D\u52A1\u8BB0\u5F55\uFF1A",s)}let r=setTimeout(()=>{console.error(`[basalt] \u5173\u95ED\u670D\u52A1\u8D85\u8FC7 ${ht/1000} \u79D2\u4ECD\u672A\u5B8C\u6210\uFF0C\u5F3A\u5236\u9000\u51FA`),process.exit(1)},ht),n=[["\u5355\u5B9E\u4F8B\u767B\u8BB0",()=>mt(mn,{force:!0})],["\u66F4\u65B0\u68C0\u67E5",()=>E.stop()],["\u6A21\u578B\u767B\u5F55\u6D41\u7A0B",()=>xt.close()],["\u8FDC\u7A0B\u8BBF\u95EE\u96A7\u9053",()=>S.stop()],["\u6258\u76D8",()=>Ee?.close()],["HTTP \u670D\u52A1",()=>m.stop()],["\u8FD0\u884C\u65F6",()=>Le.close()],["\u51ED\u636E\u5B58\u50A8",()=>U.close()]];try{for(let[s,o]of n)try{await o()}catch(l){console.error(`[basalt] \u5173\u95ED${s}\u5931\u8D25\uFF0C\u7EE7\u7EED\u5173\u95ED\u5176\u4F59\u8D44\u6E90\uFF1A`,l)}if(e&&!xe?.watched)Bun.spawn([...ne,...Be],{cwd:process.cwd(),detached:!0,stdio:["ignore","ignore","ignore"],windowsHide:!0}).unref()}catch(s){console.error("[basalt] \u91CD\u65B0\u62C9\u8D77\u670D\u52A1\u5931\u8D25\uFF1A",s)}finally{clearTimeout(r),process.exit(e&&xe?.watched?rn:t)}};process.on("SIGINT",()=>void x());process.on("SIGTERM",()=>void x());process.on("unhandledRejection",(e)=>{console.error("[basalt] \u62E6\u622A\u5230\u672A\u5904\u7406\u7684\u5F02\u6B65\u5F02\u5E38\uFF08\u4FDD\u6301\u670D\u52A1\u8FD0\u884C\uFF09\uFF1A",e)});process.on("uncaughtException",(e)=>{console.error("[basalt] \u672A\u6355\u83B7\u7684\u8FD0\u884C\u65F6\u5F02\u5E38\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\uFF1A",e),x(!1,1)});console.log(`
|
|
383
383
|
basalt ${gt.version??""} \u8FD0\u884C\u4E8E ${m.url}`);console.log(`\u6570\u636E\u76EE\u5F55 ${c}`);if(z)console.log(`\u542F\u52A8\u6A21\u578B ${z}`);hn();E.start({idle:Et,restart(e){console.log(`
|
|
384
384
|
\u5DF2\u5B89\u88C5 v${e}\uFF0C\u5BF9\u8BDD\u5747\u5DF2\u7A7A\u95F2\uFF0C\u6B63\u5728\u91CD\u542F\u5230\u65B0\u7248\u672C\u2026`),x(!0)}},Wr);if(i.open)try{Se(O())}catch(e){console.warn("\u65E0\u6CD5\u6253\u5F00\u6D4F\u89C8\u5668\uFF1A",e)}if(!B)console.warn(ve?`
|
package/compiled.js
CHANGED
|
@@ -93,4 +93,4 @@ import{un,pn,Hn}from"./chunk-mmt11y21.js";import{z}from"./chunk-m1w7f6d3.js";imp
|
|
|
93
93
|
${r?`<div class="details">${r}</div>`:""}
|
|
94
94
|
</main>
|
|
95
95
|
</body>
|
|
96
|
-
</html>`}function Pt(e){return jr({title:"Authentication successful",heading:"Authentication successful",message:e})}function P(e,t){return jr({title:"Authentication failed",heading:"Authentication failed",message:e,details:t})}function Y(e,t,o){e.writeHead(t,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),e.end(o)}async function H(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 I=new URL(g.url??"/","http://localhost");if(g.method!=="GET"||I.pathname!==e.path){Y(h,404,P("Callback route not found."));return}if(e.state!==void 0&&I.searchParams.get("state")!==e.state){Y(h,400,P("State mismatch."));return}if(i||d){Y(h,409,P("This sign-in has already been handled."));return}let T=I.searchParams.get("error");if(T){let S=I.searchParams.get("error_description")??T;Y(h,400,P(`${t} authorization failed.`,S)),l({error:Error(`${t} authorization failed: ${S}`)});return}let R=I.searchParams.get("code");if(!R){Y(h,400,P("Missing authorization code."));return}i=!0;try{let S=await e.complete(R);Y(h,200,Pt(`Signed in to ${t}. You may now close this page.`)),l({value:S})}catch(S){let U=S instanceof Error?S:Error(String(S));Y(h,502,P(`${t} sign-in failed.`,U.message)),l({error:U})}})()});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 Ee(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 zr(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=zr(e),n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=zr(new Uint8Array(r));return{verifier:t,challenge:s}}var Ud=(e)=>atob(e),Gt=Ud("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl"),Yr="https://claude.ai/oauth/authorize",Ae="https://platform.claude.com/v1/oauth/token",Bd=E("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 $e(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=${$e(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(Ae,{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=${Ae}; redirect_uri=${n}; response_type=authorization_code; details=${$e(d)}`)}let i;try{i=JSON.parse(s)}catch(d){throw Error(`Token exchange returned invalid JSON. url=${Ae}; body=${s}; details=${$e(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)=>H({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 Ee(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(Ae,{grant_type:"refresh_token",client_id:Gt,refresh_token:e},t)}catch(r){throw Error(`Anthropic token refresh request failed. url=${Ae}; details=${$e(r)}`)}let n;try{n=JSON.parse(o)}catch(r){throw Error(`Anthropic token refresh returned invalid JSON. url=${Ae}; body=${o}; details=${$e(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="),uo={"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 lo(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 po(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 Fe(e){return e&&typeof e==="object"?e:void 0}function jd(e,t){let o=Fe(e)?.data;if(!Array.isArray(o))throw Error("Invalid Copilot models response");let n=o.flatMap((c)=>{let u=Fe(c),l=u?.id;if(!u||typeof l!=="string")return[];let p=Fe(u.capabilities);if(Fe(p?.supports)?.tool_calls===!1)return[];return[{id:l,pickerEnabled:u.model_picker_enabled===!0,policyState:Fe(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(sn,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=po(e,t),s=r==="https://api.individual.githubcopilot.com",i=await ds(`${r}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...uo,"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 _o(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=lo(e),n=await _o(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=lo(e);return b({intervalSeconds:t.interval,expiresInSeconds:t.expires_in,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let r=await _o(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=lo(t||"github.com"),s=await _o(r.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...uo},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=`${po(e,o)}/models/${t}/policy`,i;try{i=await ds(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,...uo,"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:po(e.access,is(e))}}};var ho="17e5f671-d194-4dfb-9706-5516cb48c098",Zd="https://auth.kimi.com",eu=900,tu=5,ou=30000,_s=3;function fs(){return(E("KIMI_CODE_OAUTH_HOST")||E("KIMI_OAUTH_HOST")||Zd).replace(/\/+$/,"")}function fo(e){return AbortSignal.any([AbortSignal.timeout(ou),e])}function mo(e){return new URLSearchParams(e).toString()}async function go(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:mo({client_id:ho}),signal:fo(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 go(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:mo({client_id:ho,device_code:t.deviceCode,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:fo(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 go(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:mo({client_id:ho,grant_type:"refresh_token",refresh_token:t}),signal:fo(o)})}catch(c){n=c instanceof Error?c:Error(String(c));continue}let i=await go(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 Eo(e){return AbortSignal.any([AbortSignal.timeout(pu),e])}async function vo(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 Co(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 So(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:Eo(e)}),o=await vo(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=Co(o?.verification_uri_complete)??Co(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:So(o?.interval),expiresInSeconds:So(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:Eo(t)}),n=await vo(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:So(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:Eo(t)}),n=await vo(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=Co(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",yo="https://api.openai.com/v1",Ru=E("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",xo=1455,Rs="/auth/callback",Re=`http://127.0.0.1:${xo}${Rs}`,Ro="chatgpt.tokens.use.direct",yu=`openid profile email offline_access resource.invoke ${Ro}`,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(Re);if(o.origin!==n.origin||o.pathname!==n.pathname)throw Error(`The pasted callback URL must start with ${Re}`);let r=o.searchParams.get("error");if(r)throw Error(`ChatGPT authorization failed: ${r}`);return ys(o,t)}function He(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||"",Re);if(u.pathname!==Rs){He(c,404,P("Callback route not found."));return}let l=u.searchParams.get("error");if(l){He(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";He(c,400,P(m));return}He(c,200,Pt("ChatGPT authentication completed. You can close this window.")),n(p)}catch{He(c,500,P("Internal error while processing the callback."))}});i.once("error",o),i.listen(xo,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 Ao(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=Ao(e.access_token,"access_token"),r=Ao(e.refresh_token,"refresh_token"),s=Ao(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(Ro))throw Error(`OpenAI OAuth grant did not include ${Ro}`);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:Re,resource:yo}),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:yo}),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 ${xo} 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:Re,resource:yo,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:Re,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 Io=null;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))import("crypto").then((e)=>{Io=e.randomBytes});var Lt="app_EMoamEEZ73f0CkXaXp7hrann",ye="https://auth.openai.com",Gu=`${ye}/oauth/authorize`,Os=`${ye}/oauth/token`,To="http://localhost:1455/auth/callback",bu=`${ye}/api/accounts/deviceauth/usercode`,Nu=`${ye}/api/accounts/deviceauth/token`,Lu=`${ye}/codex/device`,Mu=`${ye}/deviceauth/callback`,Ps=900,ws="browser",ks="device_code",Uu="openid profile email offline_access",Bu="https://api.openai.com/auth";function Du(){return E("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function $u(){if(!Io)throw Error("OpenAI Codex OAuth is only available in Node.js environments");return Io(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 wo(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 wo(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 wo(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 wo(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",To),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 H({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 Ee(e,s,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:To}),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,To,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 E("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 H({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 Ee(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",ko=`http://${$s}:${Fs}${Hs}`,il=60000,Bs="browser",Ds="device-code",je="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 Oo 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 Oo(e.status,n,r,t)}async function Po(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:je,redirect_uri:ko,scope:Ws,code_challenge:r,code_challenge_method:"S256",handoff:"url",state:s}).toString();let d=await H({providerName:"Radius",host:$s,port:Fs,path:Hs,state:s,complete:(c)=>Po(e,new URLSearchParams({grant_type:"authorization_code",client_id:je,redirect_uri:ko,code:c,code_verifier:n}),o.signal),signal:o.signal});o.notify({type:"progress",message:`Listening for OAuth callback on ${ko}`}),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:je,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 Po(e,new URLSearchParams({grant_type:al,client_id:je,device_code:o.device_code}),t.signal)}}catch(n){if(!(n instanceof Oo))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=yr(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 Po(t,new URLSearchParams({grant_type:"refresh_token",client_id:je,refresh_token:o.refresh}),n)},async toAuth(o){return{apiKey:o.access}}}}var Go="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 bo(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 No(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 bo(_l,{client_id:Go,scope:pl,referrer:"pi"},e);if(!t.ok)throw No("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 bo(zs,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:Go,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:No("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 bo(zs,{grant_type:"refresh_token",client_id:Go,refresh_token:e},t);if(!o.ok)throw No("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(){Ii({anthropic:()=>rs,openaiCodex:()=>Ls,openaiChatGPT:()=>Ts,githubCopilot:()=>ps,openrouter:()=>Us,kimiCoding:()=>gs,meta:()=>vs,xai:()=>Js,radius:Ks})}Pi(Kr);Ys();await import("./chunk-pcd14q8r.js");
|
|
96
|
+
</html>`}function Pt(e){return jr({title:"Authentication successful",heading:"Authentication successful",message:e})}function P(e,t){return jr({title:"Authentication failed",heading:"Authentication failed",message:e,details:t})}function Y(e,t,o){e.writeHead(t,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),e.end(o)}async function H(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 I=new URL(g.url??"/","http://localhost");if(g.method!=="GET"||I.pathname!==e.path){Y(h,404,P("Callback route not found."));return}if(e.state!==void 0&&I.searchParams.get("state")!==e.state){Y(h,400,P("State mismatch."));return}if(i||d){Y(h,409,P("This sign-in has already been handled."));return}let T=I.searchParams.get("error");if(T){let S=I.searchParams.get("error_description")??T;Y(h,400,P(`${t} authorization failed.`,S)),l({error:Error(`${t} authorization failed: ${S}`)});return}let R=I.searchParams.get("code");if(!R){Y(h,400,P("Missing authorization code."));return}i=!0;try{let S=await e.complete(R);Y(h,200,Pt(`Signed in to ${t}. You may now close this page.`)),l({value:S})}catch(S){let U=S instanceof Error?S:Error(String(S));Y(h,502,P(`${t} sign-in failed.`,U.message)),l({error:U})}})()});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 Ee(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 zr(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=zr(e),n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=zr(new Uint8Array(r));return{verifier:t,challenge:s}}var Ud=(e)=>atob(e),Gt=Ud("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl"),Yr="https://claude.ai/oauth/authorize",Ae="https://platform.claude.com/v1/oauth/token",Bd=E("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 $e(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=${$e(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(Ae,{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=${Ae}; redirect_uri=${n}; response_type=authorization_code; details=${$e(d)}`)}let i;try{i=JSON.parse(s)}catch(d){throw Error(`Token exchange returned invalid JSON. url=${Ae}; body=${s}; details=${$e(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)=>H({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 Ee(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(Ae,{grant_type:"refresh_token",client_id:Gt,refresh_token:e},t)}catch(r){throw Error(`Anthropic token refresh request failed. url=${Ae}; details=${$e(r)}`)}let n;try{n=JSON.parse(o)}catch(r){throw Error(`Anthropic token refresh returned invalid JSON. url=${Ae}; body=${o}; details=${$e(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="),uo={"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 lo(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 po(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 Fe(e){return e&&typeof e==="object"?e:void 0}function jd(e,t){let o=Fe(e)?.data;if(!Array.isArray(o))throw Error("Invalid Copilot models response");let n=o.flatMap((c)=>{let u=Fe(c),l=u?.id;if(!u||typeof l!=="string")return[];let p=Fe(u.capabilities);if(Fe(p?.supports)?.tool_calls===!1)return[];return[{id:l,pickerEnabled:u.model_picker_enabled===!0,policyState:Fe(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(sn,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=po(e,t),s=r==="https://api.individual.githubcopilot.com",i=await ds(`${r}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...uo,"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 _o(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=lo(e),n=await _o(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=lo(e);return b({intervalSeconds:t.interval,expiresInSeconds:t.expires_in,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let r=await _o(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=lo(t||"github.com"),s=await _o(r.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...uo},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=`${po(e,o)}/models/${t}/policy`,i;try{i=await ds(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,...uo,"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:po(e.access,is(e))}}};var ho="17e5f671-d194-4dfb-9706-5516cb48c098",Zd="https://auth.kimi.com",eu=900,tu=5,ou=30000,_s=3;function fs(){return(E("KIMI_CODE_OAUTH_HOST")||E("KIMI_OAUTH_HOST")||Zd).replace(/\/+$/,"")}function fo(e){return AbortSignal.any([AbortSignal.timeout(ou),e])}function mo(e){return new URLSearchParams(e).toString()}async function go(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:mo({client_id:ho}),signal:fo(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 go(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:mo({client_id:ho,device_code:t.deviceCode,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:fo(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 go(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:mo({client_id:ho,grant_type:"refresh_token",refresh_token:t}),signal:fo(o)})}catch(c){n=c instanceof Error?c:Error(String(c));continue}let i=await go(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 Eo(e){return AbortSignal.any([AbortSignal.timeout(pu),e])}async function vo(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 Co(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 So(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:Eo(e)}),o=await vo(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=Co(o?.verification_uri_complete)??Co(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:So(o?.interval),expiresInSeconds:So(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:Eo(t)}),n=await vo(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:So(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:Eo(t)}),n=await vo(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=Co(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",yo="https://api.openai.com/v1",Ru=E("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",xo=1455,Rs="/auth/callback",Re=`http://127.0.0.1:${xo}${Rs}`,Ro="chatgpt.tokens.use.direct",yu=`openid profile email offline_access resource.invoke ${Ro}`,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(Re);if(o.origin!==n.origin||o.pathname!==n.pathname)throw Error(`The pasted callback URL must start with ${Re}`);let r=o.searchParams.get("error");if(r)throw Error(`ChatGPT authorization failed: ${r}`);return ys(o,t)}function He(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||"",Re);if(u.pathname!==Rs){He(c,404,P("Callback route not found."));return}let l=u.searchParams.get("error");if(l){He(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";He(c,400,P(m));return}He(c,200,Pt("ChatGPT authentication completed. You can close this window.")),n(p)}catch{He(c,500,P("Internal error while processing the callback."))}});i.once("error",o),i.listen(xo,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 Ao(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=Ao(e.access_token,"access_token"),r=Ao(e.refresh_token,"refresh_token"),s=Ao(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(Ro))throw Error(`OpenAI OAuth grant did not include ${Ro}`);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:Re,resource:yo}),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:yo}),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 ${xo} 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:Re,resource:yo,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:Re,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 Io=null;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))import("crypto").then((e)=>{Io=e.randomBytes});var Lt="app_EMoamEEZ73f0CkXaXp7hrann",ye="https://auth.openai.com",Gu=`${ye}/oauth/authorize`,Os=`${ye}/oauth/token`,To="http://localhost:1455/auth/callback",bu=`${ye}/api/accounts/deviceauth/usercode`,Nu=`${ye}/api/accounts/deviceauth/token`,Lu=`${ye}/codex/device`,Mu=`${ye}/deviceauth/callback`,Ps=900,ws="browser",ks="device_code",Uu="openid profile email offline_access",Bu="https://api.openai.com/auth";function Du(){return E("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function $u(){if(!Io)throw Error("OpenAI Codex OAuth is only available in Node.js environments");return Io(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 wo(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 wo(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 wo(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 wo(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",To),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 H({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 Ee(e,s,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:To}),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,To,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 E("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 H({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 Ee(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",ko=`http://${$s}:${Fs}${Hs}`,il=60000,Bs="browser",Ds="device-code",je="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 Oo 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 Oo(e.status,n,r,t)}async function Po(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:je,redirect_uri:ko,scope:Ws,code_challenge:r,code_challenge_method:"S256",handoff:"url",state:s}).toString();let d=await H({providerName:"Radius",host:$s,port:Fs,path:Hs,state:s,complete:(c)=>Po(e,new URLSearchParams({grant_type:"authorization_code",client_id:je,redirect_uri:ko,code:c,code_verifier:n}),o.signal),signal:o.signal});o.notify({type:"progress",message:`Listening for OAuth callback on ${ko}`}),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:je,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 Po(e,new URLSearchParams({grant_type:al,client_id:je,device_code:o.device_code}),t.signal)}}catch(n){if(!(n instanceof Oo))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=yr(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 Po(t,new URLSearchParams({grant_type:"refresh_token",client_id:je,refresh_token:o.refresh}),n)},async toAuth(o){return{apiKey:o.access}}}}var Go="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 bo(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 No(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 bo(_l,{client_id:Go,scope:pl,referrer:"pi"},e);if(!t.ok)throw No("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 bo(zs,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:Go,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:No("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 bo(zs,{grant_type:"refresh_token",client_id:Go,refresh_token:e},t);if(!o.ok)throw No("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(){Ii({anthropic:()=>rs,openaiCodex:()=>Ls,openaiChatGPT:()=>Ts,githubCopilot:()=>ps,openrouter:()=>Us,kimiCoding:()=>gs,meta:()=>vs,xai:()=>Js,radius:Ks})}Pi(Kr);Ys();await import("./chunk-rkn6bven.js");
|
package/package.json
CHANGED
package/ui-test-worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{wr,qn,I,Gn,zn,jn,dn,Vn,vt,mn}from"./chunk-mq0p4ssz.js";import"./chunk-
|
|
2
|
+
import{wr,qn,I,Gn,zn,jn,dn,Vn,vt,mn}from"./chunk-mq0p4ssz.js";import"./chunk-pjv9mppd.js";import"./chunk-m1w7f6d3.js";import"./chunk-w430z452.js";import{Yn,vr}from"./chunk-2c6seev1.js";import"./chunk-g23dnf4y.js";import{a,r,tt,ar}from"./chunk-sfwy8rqg.js";var mh=r(function(FA){FA.removeLeadingAndTrailingHTTPWhitespace=(t)=>t.replace(/^[ \t\n\r]+/u,"").replace(/[ \t\n\r]+$/u,"");FA.removeTrailingHTTPWhitespace=(t)=>t.replace(/[ \t\n\r]+$/u,"");FA.isHTTPWhitespaceChar=(t)=>t===" "||t==="\t"||t===`
|
|
3
3
|
`||t==="\r";FA.solelyContainsHTTPTokenCodePoints=(t)=>/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u.test(t);FA.soleyContainsHTTPQuotedStringTokenCodePoints=(t)=>/^[\t\u0020-\u007E\u0080-\u00FF]*$/u.test(t);FA.asciiLowercase=(t)=>t.replace(/[A-Z]/ug,(e)=>e.toLowerCase());FA.collectAnHTTPQuotedString=(t,e)=>{let o="";e++;while(!0){while(e<t.length&&t[e]!=='"'&&t[e]!=="\\")o+=t[e],++e;if(e>=t.length)break;let i=t[e];if(++e,i==="\\"){if(e>=t.length){o+="\\";break}o+=t[e],++e}else break}return[o,e]}});var PS=r(function(z2,fS){var{asciiLowercase:Rc,solelyContainsHTTPTokenCodePoints:WA,soleyContainsHTTPQuotedStringTokenCodePoints:_A}=mh();fS.exports=class{constructor(e){this._map=e}get size(){return this._map.size}get(e){return e=Rc(String(e)),this._map.get(e)}has(e){return e=Rc(String(e)),this._map.has(e)}set(e,o){if(e=Rc(String(e)),o=String(o),!WA(e))throw Error(`Invalid MIME type parameter name "${e}": only HTTP token code points are valid.`);if(!_A(o))throw Error(`Invalid MIME type parameter value "${o}": only HTTP quoted-string token code points are valid.`);return this._map.set(e,o)}clear(){this._map.clear()}delete(e){return e=Rc(String(e)),this._map.delete(e)}forEach(e,o){this._map.forEach(e,o)}keys(){return this._map.keys()}values(){return this._map.values()}entries(){return this._map.entries()}[Symbol.iterator](){return this._map[Symbol.iterator]()}}});var ES=r(function(J2,wS){var{removeLeadingAndTrailingHTTPWhitespace:YA,removeTrailingHTTPWhitespace:AS,isHTTPWhitespaceChar:KA,solelyContainsHTTPTokenCodePoints:cg,soleyContainsHTTPQuotedStringTokenCodePoints:QA,asciiLowercase:dg,collectAnHTTPQuotedString:jA}=mh();wS.exports=(t)=>{t=YA(t);let e=0,o="";while(e<t.length&&t[e]!=="/")o+=t[e],++e;if(o.length===0||!cg(o))return null;if(e>=t.length)return null;++e;let i="";while(e<t.length&&t[e]!==";")i+=t[e],++e;if(i=AS(i),i.length===0||!cg(i))return null;let s={type:dg(o),subtype:dg(i),parameters:new Map};while(e<t.length){++e;while(KA(t[e]))++e;let n="";while(e<t.length&&t[e]!==";"&&t[e]!=="=")n+=t[e],++e;if(n=dg(n),e<t.length){if(t[e]===";")continue;++e}let l=null;if(t[e]==='"'){[l,e]=jA(t,e);while(e<t.length&&t[e]!==";")++e}else{l="";while(e<t.length&&t[e]!==";")l+=t[e],++e;if(l=AS(l),l==="")continue}if(n.length>0&&cg(n)&&QA(l)&&!s.parameters.has(n))s.parameters.set(n,l)}return s}});var vS=r(function(Z2,xS){var{solelyContainsHTTPTokenCodePoints:qA}=mh();xS.exports=(t)=>{let e=`${t.type}/${t.subtype}`;if(t.parameters.size===0)return e;for(let[o,i]of t.parameters){if(e+=";",e+=o,e+="=",!qA(i)||i.length===0)i=i.replace(/(["\\])/ug,"\\$1"),i=`"${i}"`;e+=i}return e}});var LS=r(function(tU,NS){var $A=PS(),XA=ES(),zA=vS(),{asciiLowercase:TS,solelyContainsHTTPTokenCodePoints:CS}=mh();NS.exports=class{constructor(e){e=String(e);let o=XA(e);if(o===null)throw Error(`Could not parse MIME type string "${e}"`);this._type=o.type,this._subtype=o.subtype,this._parameters=new $A(o.parameters)}static parse(e){try{return new this(e)}catch(o){return null}}get essence(){return`${this.type}/${this.subtype}`}get type(){return this._type}set type(e){if(e=TS(String(e)),e.length===0)throw Error("Invalid type: must be a non-empty string");if(!CS(e))throw Error(`Invalid type ${e}: must contain only HTTP token code points`);this._type=e}get subtype(){return this._subtype}set subtype(e){if(e=TS(String(e)),e.length===0)throw Error("Invalid subtype: must be a non-empty string");if(!CS(e))throw Error(`Invalid subtype ${e}: must contain only HTTP token code points`);this._subtype=e}get parameters(){return this._parameters}toString(){return zA(this)}isJavaScript({prohibitParameters:e=!1}={}){switch(this._type){case"text":switch(this._subtype){case"ecmascript":case"javascript":case"javascript1.0":case"javascript1.1":case"javascript1.2":case"javascript1.3":case"javascript1.4":case"javascript1.5":case"jscript":case"livescript":case"x-ecmascript":case"x-javascript":return!e||this._parameters.size===0;default:return!1}case"application":switch(this._subtype){case"ecmascript":case"javascript":case"x-ecmascript":case"x-javascript":return!e||this._parameters.size===0;default:return!1}default:return!1}}isXML(){return this._subtype==="xml"&&(this._type==="text"||this._type==="application")||this._subtype.endsWith("+xml")}isHTML(){return this._subtype==="html"&&this._type==="text"}}});var $d={};tt($d,{PluginWebUIContext:()=>qd,SlotButton:()=>kw,useDraftReplace:()=>Lw,usePluginWebUI:()=>OS});var Lg={};ar(Lg,{Fragment:()=>GS,jsxDEV:()=>US},{Fragment:(D5)=>GS=D5,jsxDEV:(D5)=>US=D5});var kg={};ar(kg,{Fragment:()=>WS,jsx:()=>_S,jsxs:()=>YS},{Fragment:(B5)=>WS=B5,jsx:(B5)=>_S=B5,jsxs:(B5)=>YS=B5});var An=(t)=>globalThis.postMessage(t),lf=0,zd=new Map;function Rg(t,e){let o=lf++;return new Promise((i,s)=>{zd.set(o,{resolve:i,reject:s}),e.addEventListener("abort",()=>An({type:"cancel",id:o}),{once:!0}),An({type:"request",id:o,input:t})})}function Fg(t){let e=zd.get(t.id);if(zd.delete(t.id),t.error)e?.reject(Error(t.error));else if(t.response)e?.resolve(t.response)}var af="http://basalt.internal";function mf(t){if(!t.startsWith("/api/")||/[\\\r\n#]/.test(t)||!new URL(t,af).pathname.startsWith("/api/"))throw Error("request path must stay within /api/")}function yf(t,e){return new Promise((o,i)=>{let n=setTimeout(()=>{e.removeEventListener("abort",l),o()},t),l=()=>{clearTimeout(n),e.removeEventListener("abort",l),i(Error("Request aborted"))};e.addEventListener("abort",l,{once:!0})})}function pf(t){if(t===void 0||t===null)return;if(typeof t!=="string")throw Error("ui_test requests require a JSON string body");if(!t)return;let e=JSON.parse(t);if(!e||typeof e!=="object"||Array.isArray(e))throw Error("request body must be a JSON object");return e}function Vg(t,e){return{async request(o,i){mf(o);let s=(i?.method??"GET").toUpperCase(),n=i?.signal?AbortSignal.any([i.signal,e]):e;n.throwIfAborted();let l=`${s} ${o}`,y=t&&Object.hasOwn(t,l)?t[l]:void 0;if(y){if(await yf(y.delayMs??0,n),n.throwIfAborted(),y.status<200||y.status>=300)throw Error(`Request failed (${y.status})`);return structuredClone(y.body)}let u=await Rg({path:o,method:s,body:pf(i?.body)},n);if(n.throwIfAborted(),u.status<200||u.status>=300)throw Error(`Request failed (${u.status})`);if(u.truncated)throw Error("API response exceeds ui_test response limit");return JSON.parse(u.body)}}}function Dg(t,e){let o=t.ownerDocument;function i(E){for(let R=E;R;R=R.parentElement){if(R.hasAttribute("hidden")||R.getAttribute("aria-hidden")==="true")return!1;let H=e.getComputedStyle(R);if(H.display==="none"||H.visibility==="hidden")return!1}return!0}function s(E){let R=E.getAttribute("aria-label");if(R!==null)return R;let H=E.getAttribute("aria-labelledby");if(H)return H.split(/\s+/).map((pt)=>o.getElementById(pt)?.textContent??"").join(" ");if("labels"in E){let pt=Array.from(E.labels??[]);if(pt.length)return pt.map((gt)=>gt.textContent).join(" ")}return E.textContent??""}function n(E){return E.hasAttribute("disabled")||E.getAttribute("aria-disabled")==="true"}function l(E){let R=[],H=o.createTreeWalker(E,4);while(H.nextNode()){let pt=H.currentNode,gt=pt?.parentElement;if(gt&&!gt.closest("script,style,textarea")&&i(gt))R.push(pt?.textContent??"")}return R.join(" ").replace(/\s+/g," ").trim()}function y(){return Array.from(t.querySelectorAll("button,[role=button]")).filter(i).map((E)=>({name:s(E).trim(),disabled:n(E),busy:E.getAttribute("aria-busy")==="true"}))}function u(){return Array.from(t.querySelectorAll("input,textarea,select")).filter((E)=>E instanceof e.HTMLInputElement||E instanceof e.HTMLTextAreaElement||E instanceof e.HTMLSelectElement).filter(i).map((E)=>({label:s(E).trim(),value:E.value}))}function c(E=t,R=!0){let H=l(E),pt=y(),gt=u();if(!R)return{text:H,buttons:pt,values:gt,truncated:!1};let Ft=new TextEncoder().encode(H);return{text:new TextDecoder().decode(Ft.slice(0,2048),{stream:!0}),buttons:pt.slice(0,50),values:gt.slice(0,50),truncated:Ft.length>2048||pt.length>50||gt.length>50}}function d(E,R){let H=Array.from(t.querySelectorAll(E)).filter((pt)=>pt instanceof e.HTMLElement).filter((pt)=>i(pt)&&s(pt).trim()===R);if(H.length!==1||!H[0])throw Error(`Expected one control named ${JSON.stringify(R)}, found ${H.length}`);return H[0]}function g(E){let R=Array.from(t.querySelectorAll(E)).filter(i),H=R[0];if(R.length!==1||!(H instanceof e.HTMLElement))throw Error(`Expected one visible element for ${E}, found ${R.length}`);return H}function f(E,R){let H=200,pt=(gt,Ft)=>{H--;let at=[];if(Ft<R)for(let dt of gt.children){if(!H)break;at.push(pt(dt,Ft+1))}return{tag:gt.tagName.toLowerCase(),role:gt.getAttribute("role"),class:gt.className,text:Array.from(gt.childNodes).filter((dt)=>dt.nodeType===3).map((dt)=>dt.textContent).join(" ").trim(),childCount:gt.children.length,children:at}};return pt(E,0)}return{visible:i,isDisabled:n,snapshot:c,findByName:d,selectOne:g,outline:f,count:(E)=>t.querySelectorAll(E).length,anyVisible:(E)=>Array.from(t.querySelectorAll(E)).some(i)}}var ui=Symbol("abort"),Me=Symbol("activeElement"),Pt=Symbol("asyncTaskManager"),hi=Symbol("bodyBuffer"),Lt=Symbol("buffer"),Qo=Symbol("cachedResponse"),ci=Symbol("callbacks"),wn=Symbol("checked"),Ts=Symbol("childNodes"),or=Symbol("children"),Aa=Symbol("classList"),zr=Symbol("connectedToNode"),Vi=Symbol("disconnectedFromNode"),ir=Symbol("connectedToDocument"),sr=Symbol("disconnectedFromDocument"),xl=Symbol("contentLength"),xe=Symbol("contentType"),gr=Symbol("cssText"),Do=Symbol("currentScript"),Bo=Symbol("currentTarget"),Kt=Symbol("data"),Lr=Symbol("defaultView"),At=Symbol("destroy"),En=Symbol("dirtyness"),Y=Symbol("end"),Xe=Symbol("entries"),oE=Symbol("evaluateCSS"),Oo=Symbol("evaluateScript"),Jr=Symbol("exceptionObserver"),Ut=Symbol("formNode"),xn=Symbol("internalId"),F=Symbol("height"),Cs=Symbol("immediatePropagationStopped"),vn=Symbol("indeterminate"),Ns=Symbol("isFirstWrite"),Ls=Symbol("isFirstWriteAfterOpen"),wa=Symbol("isInPassiveEventListener"),Zr=Symbol("isValue"),ks=Symbol("listenerOptions"),he=Symbol("listeners"),Hr=Symbol("itemsByName"),Ms=Symbol("nextActiveElement"),vl=Symbol("observeMutations"),to=Symbol("mutationListeners"),x=Symbol("ownerDocument"),xt=Symbol("ownerElement"),Is=Symbol("propagationStopped"),Ao=Symbol("readyStateManager"),Sr=Symbol("referrer"),di=Symbol("registry"),eo=Symbol("relList"),Ea=Symbol("resetSelection"),ve=Symbol("rootNode"),Ie=Symbol("selectNode"),fr=Symbol("selectedness"),Tn=Symbol("selection"),Tm=Symbol("setupVMContext"),be=Symbol("shadowRoot"),O=Symbol("start"),ge=Symbol("style"),Pr=Symbol("target"),ze=Symbol("textAreaNode"),xa=Symbol("unobserveMutations"),Di=Symbol("reportMutation"),Cn=Symbol("updateSelectedness"),Pe=Symbol("url"),q=Symbol("value"),V=Symbol("width"),m=Symbol("window"),vh=Symbol("windowResizeListener"),Nn=Symbol("mutationObservers"),ro=Symbol("openerFrame"),bi=Symbol("openerWindow"),Cm=Symbol("pointerCaptures"),Ln=Symbol("popup"),et=Symbol("isConnected"),W=Symbol("parentNode"),D=Symbol("nodeType"),z=Symbol("tagName"),Vt=Symbol("prefix"),Jd=Symbol("scrollHeight"),Zd=Symbol("scrollWidth"),Th=Symbol("scrollTop"),Ch=Symbol("scrollLeft"),St=Symbol("attributes"),va=Symbol("attributesProxy"),J=Symbol("namespaceURI"),Ta=Symbol("accessKey"),iE=Symbol("accessKeyLabel"),tb=Symbol("offsetHeight"),eb=Symbol("offsetWidth"),rb=Symbol("offsetLeft"),ob=Symbol("offsetTop"),ib=Symbol("clientHeight"),sb=Symbol("clientWidth"),nb=Symbol("clientLeft"),lb=Symbol("clientTop"),ot=Symbol("name"),Nm=Symbol("specified"),Rs=Symbol("adoptedStyleSheets"),Nh=Symbol("implementation"),kn=Symbol("readyState"),Fs=Symbol("publicId"),Vs=Symbol("systemId"),Ce=Symbol("validationMessage"),Ke=Symbol("validity"),Lh=Symbol("returnValue"),Bi=Symbol("elements"),sE=Symbol("length"),ab=Symbol("complete"),mb=Symbol("naturalHeight"),yb=Symbol("naturalWidth"),Bg=Symbol("loading"),L=Symbol("x"),k=Symbol("y"),nE=Symbol("defaultChecked"),jo=Symbol("files"),Be=Symbol("sheet"),kh=Symbol("volume"),Tl=Symbol("paused"),Mh=Symbol("currentTime"),Ih=Symbol("playbackRate"),Rh=Symbol("defaultPlaybackRate"),Ca=Symbol("muted"),Cl=Symbol("defaultMuted"),Fh=Symbol("preservesPitch"),pb=Symbol("buffered"),ub=Symbol("duration"),Qe=Symbol("error"),hb=Symbol("ended"),cb=Symbol("networkState"),Vh=Symbol("textTracks"),db=Symbol("seeking"),bb=Symbol("seekable"),gb=Symbol("played"),Oi=Symbol("options"),oo=Symbol("content"),Ee=Symbol("mode"),Mn=Symbol("host"),Wr=Symbol("setURL"),it=Symbol("localName"),Na=Symbol("classRegistry"),Lm=Symbol("nodeStream"),io=Symbol("location"),Oe=Symbol("history"),Dh=Symbol("navigator"),Bh=Symbol("screen"),Oh=Symbol("sessionStorage"),Gh=Symbol("localStorage"),km=Symbol("sandbox"),ct=Symbol("cloneNode"),Et=Symbol("appendChild"),ur=Symbol("removeChild"),kr=Symbol("insertBefore"),La=Symbol("replaceChild"),gi=Symbol("tracks"),ka=Symbol("constraints"),Si=Symbol("capabilities"),In=Symbol("settings"),lE=Symbol("clone"),Ds=Symbol("removeNamedItem"),Q=Symbol("items"),Rn=Symbol("selectedOptions"),hr=Symbol("styleNode"),Fn=Symbol("updateSheet"),Mr=Symbol("clearCache"),Re=Symbol("onSetAttribute"),cr=Symbol("onRemoveAttribute"),_=Symbol("nodeArray"),bt=Symbol("elementArray"),U=Symbol("cache"),He=Symbol("affectsCache"),Ma=Symbol("forms"),qo=Symbol("affectsComputedStyleCache"),Nl=Symbol("query"),Ll=Symbol("computedStyle"),so=Symbol("getFormControlItems"),Mm=Symbol("getFormControlNamedItem"),Uh=Symbol("dataset"),aE=Symbol("getNamespaceItemKey"),mE=Symbol("getNamedItemKey"),fi=Symbol("itemsByNamespaceURI"),Dt=Symbol("proxy"),$o=Symbol("setNamedItem"),Ar=Symbol("getTokenList"),Bs=Symbol("attributeName"),Go=Symbol("selectedIndex"),Dn=Symbol("self"),no=Symbol("parent"),Xo=Symbol("top"),Im=Symbol("areas"),lo=Symbol("defaultValue"),Pi=Symbol("elementIdMap"),Bn=Symbol("clonable"),kl=Symbol("delegatesFocus"),Gi=Symbol("serializable"),Ai=Symbol("slotAssignment"),Ui=Symbol("assignedNodes"),zo=Symbol("assignedToSlot"),Rm=Symbol("cells"),Fm=Symbol("rows"),Hh=Symbol("headers"),Vm=Symbol("tBodies"),Ia=Symbol("track"),Dm=Symbol("controlsList"),Wh=Symbol("mediaKeys"),Sb=Symbol("remote"),_h=Symbol("sinkId"),Yh=Symbol("srcObject"),Ml=Symbol("cues"),fb=Symbol("activeCues"),wo=Symbol("kind"),Os=Symbol("label"),Il=Symbol("language"),Bm=Symbol("id"),h=Symbol("illegalConstructor"),Pb=Symbol("state"),Om=Symbol("canvas"),On=Symbol("popoverTargetElement"),Gm=Symbol("composed"),Gs=Symbol("bubbles"),Hi=Symbol("cancelable"),nr=Symbol("defaultPrevented"),Er=Symbol("eventPhase"),Ab=Symbol("timeStamp"),Qt=Symbol("type"),Um=Symbol("detail"),yE=Symbol("globalObject"),Hm=Symbol("destroyed"),Se=Symbol("aborted"),Wm=Symbol("browserFrames"),Kh=Symbol("windowInternalId"),K=Symbol("getItemList"),Wi=Symbol("requiredExtensions"),_i=Symbol("systemLanguage"),_m=Symbol("transform"),se=Symbol("baseVal"),ne=Symbol("animVal"),Ym=Symbol("pathLength"),pE=Symbol("unitType"),Yi=Symbol("viewBox"),Km=Symbol("markerUnits"),Qm=Symbol("markerWidth"),jm=Symbol("markerHeight"),Je=Symbol("values"),qm=Symbol("orientType"),$m=Symbol("orientAngle"),Xm=Symbol("refX"),zm=Symbol("refY"),j=Symbol("readOnly"),lr=Symbol("preserveAspectRatio"),Ki=Symbol("animatedPoints"),Qi=Symbol("points"),ji=Symbol("rx"),qi=Symbol("ry"),ao=Symbol("cx"),mo=Symbol("cy"),$i=Symbol("r"),Jm=Symbol("clipPathUnits"),Zm=Symbol("maskUnits"),ty=Symbol("maskContentUnits"),ey=Symbol("filterUnits"),ry=Symbol("primitiveUnits"),kt=Symbol("href"),Xi=Symbol("x1"),zi=Symbol("y1"),Ji=Symbol("x2"),Zi=Symbol("y2"),oy=Symbol("gradientUnits"),iy=Symbol("gradientTransform"),sy=Symbol("spreadMethod"),ny=Symbol("patternUnits"),ly=Symbol("patternContentUnits"),ay=Symbol("patternTransform"),my=Symbol("fx"),yy=Symbol("fy"),ts=Symbol("offset"),Un=Symbol("disabled"),py=Symbol("textLength"),uy=Symbol("lengthAdjust"),v=Symbol("getAttribute"),A=Symbol("setAttribute"),Ir=Symbol("z"),Rl=Symbol("w"),hy=Symbol("toArray"),Fl=Symbol("fromString"),Eo=Symbol("fromArray"),uE=Symbol("angle"),Mt=Symbol("m11"),Bt=Symbol("m12"),zt=Symbol("m13"),Jt=Symbol("m14"),It=Symbol("m21"),Ot=Symbol("m22"),Zt=Symbol("m23"),te=Symbol("m24"),Wt=Symbol("m31"),jt=Symbol("m32"),qt=Symbol("m33"),_t=Symbol("m34"),Rt=Symbol("m41"),Gt=Symbol("m42"),$t=Symbol("m43"),Xt=Symbol("m44"),Ra=Symbol("setMatrixValue"),xo=Symbol("translateSelf"),Us=Symbol("rotateSelf"),Hs=Symbol("rotateAxisAngleSelf"),es=Symbol("scaleSelf"),cy=Symbol("scale3dSelf"),dy=Symbol("scaleNonUniformSelf"),Vl=Symbol("skewXSelf"),Dl=Symbol("skewYSelf"),vo=Symbol("multiplySelf"),Ws=Symbol("matrix"),hE=Symbol("domMatrix"),Ne=Symbol("getDOMMatrix"),dr=Symbol("setDOMMatrix"),M=Symbol("attributeValue"),by=Symbol("startOffset"),_s=Symbol("method"),gy=Symbol("spacing"),mt=Symbol("in1"),yo=Symbol("in2"),Z=Symbol("result"),Sy=Symbol("bias"),fy=Symbol("divisor"),rs=Symbol("edgeMode"),Py=Symbol("kernelMatrix"),po=Symbol("kernelUnitLengthX"),uo=Symbol("kernelUnitLengthY"),Ay=Symbol("orderX"),wy=Symbol("orderY"),Ey=Symbol("preserveAlpha"),xy=Symbol("targetX"),vy=Symbol("targetY"),Ty=Symbol("diffuseConstant"),os=Symbol("surfaceScale"),Cy=Symbol("scale"),Ny=Symbol("xChannelSelector"),Ly=Symbol("yChannelSelector"),ky=Symbol("azimuth"),My=Symbol("elevation"),ho=Symbol("dx"),co=Symbol("dy"),is=Symbol("stdDeviationX"),ss=Symbol("stdDeviationY"),Iy=Symbol("tableValues"),Ry=Symbol("slope"),Fy=Symbol("intercept"),Vy=Symbol("amplitude"),Dy=Symbol("exponent"),Og=Symbol("crossOrigin"),By=Symbol("operator"),Oy=Symbol("radiusX"),Gy=Symbol("radiusY"),Uy=Symbol("specularConstant"),ns=Symbol("specularExponent"),Hy=Symbol("pointsAtX"),Wy=Symbol("pointsAtY"),_y=Symbol("pointsAtZ"),Yy=Symbol("limitingConeAngle"),Ky=Symbol("baseFrequencyX"),Qy=Symbol("baseFrequencyY"),jy=Symbol("numOctaves"),qy=Symbol("seed"),$y=Symbol("stitchTiles"),Xy=Symbol("rotateFromVectorSelf"),zy=Symbol("flipXSelf"),Jy=Symbol("flipYSelf"),Zy=Symbol("invertSelf"),wb=Symbol("getLength"),Qh=Symbol("currentScale"),tp=Symbol("rotate"),Eb=Symbol("bindMethods"),Hn=Symbol("xmlProcessingInstruction"),cE=Symbol("root"),Uo=Symbol("filterNode"),Ys=Symbol("customElementReactionStack"),Wn=Symbol("dispatching"),ls=Symbol("modules"),Rr=Symbol("preloads"),Ks=Symbol("body"),jh=Symbol("redirect"),Fa=Symbol("referrerPolicy"),qh=Symbol("signal"),wi=Symbol("bodyUsed"),$h=Symbol("credentials"),ep=Symbol("blocking"),Bl=Symbol("moduleImportMap"),le=Symbol("dispatchError"),Xh=Symbol("supports"),To=Symbol("reason"),p=Symbol("propertyEventListeners"),We=Symbol("cssRules"),Qs=Symbol("parentRule"),Co=Symbol("parentStyleSheet"),bo=Symbol("conditionText"),as=Symbol("keyText"),xb=Symbol("media"),rp=Symbol("styleMap"),Ol=Symbol("selectorText"),Gl=Symbol("cssParser"),js=Symbol("cssRule"),Fr=Symbol("rulePrefix"),_r=Symbol("virtualServerFile"),vb=Symbol("frames"),qs=Symbol("disableEvaluation"),Tb=Symbol("validateJavaScriptExecutionEnvironment"),dE=Symbol("currentNode"),_n=Symbol("openWebSockets"),xr=Symbol("webSocket"),Va=Symbol("moduleCache");var Cb;(function(t){t.strict="Strict",t.lax="Lax",t.none="None"})(Cb||(Cb={}));var $s=Cb;var zh={key:null,originURL:null,value:null,domain:"",path:"",expires:null,httpOnly:!1,secure:!1,sameSite:$s.lax};class op{static hasExpired(t){return t.expires&&t.expires.getTime()<Date.now()}}class Jh{static cookieMatchesURL(t,e){let o=e.hostname==="localhost"||e.hostname?.endsWith(".localhost");return(!t.secure||e.protocol==="https:"||o)&&(!t.domain||e.hostname?.endsWith(t.domain))&&(!t.path||e.pathname?.startsWith(t.path))&&(t.sameSite===$s.none&&t.secure||t.originURL?.hostname===e.hostname)}}class ip{#t=[];addCookies(t){let e=new Map,o=(i)=>`${i.key}-${i.originURL.hostname}-${i.path}-${typeof i.value}`;for(let i=0,s=this.#t.length;i<s;i++)e.set(o(this.#t[i]),i);for(let i of t){let s=Object.assign({},zh,i);if(s&&s.key&&s.originURL){let n=e.get(o(s));if(n!==void 0)this.#t.splice(n,1);if(!op.hasExpired(s))e.set(o(s),this.#t.length),this.#t.push(s)}}}getCookies(t=null,e=!1){let o=[];for(let i of this.#t)if(!op.hasExpired(i)&&(!e||!i.httpOnly)&&(!t||Jh.cookieMatchesURL(i,t)))o.push(i);return o}clearCookies(){this.#t=[]}}var Nb;(function(t){t.fresh="fresh",t.stale="stale"})(Nb||(Nb={}));var Kn=Nb;var Lb;(function(t){t.invalidStateError="InvalidStateError",t.indexSizeError="IndexSizeError",t.syntaxError="SyntaxError",t.hierarchyRequestError="HierarchyRequestError",t.notSupportedError="NotSupportedError",t.wrongDocumentError="WrongDocumentError",t.invalidNodeTypeError="InvalidNodeTypeError",t.invalidCharacterError="InvalidCharacterError",t.notFoundError="NotFoundError",t.securityError="SecurityError",t.networkError="NetworkError",t.domException="DOMException",t.invalidAccessError="InvalidAccessError",t.unknownError="UnknownError",t.abortError="AbortError",t.timeoutError="TimeoutError",t.encodingError="EncodingError",t.uriMismatchError="URIMismatchError",t.inUseAttributeError="InUseAttributeError",t.namespaceError="NamespaceError"})(Lb||(Lb={}));var w=Lb;class re extends Error{constructor(t,e=null){super(t);this.name=e||w.domException}}class Ei{[Xe]={};constructor(t){if(t)if(t instanceof Ei)this[Xe]=JSON.parse(JSON.stringify(t[Xe]));else if(Array.isArray(t))for(let e of t){if(e.length!==2)throw new re('Failed to construct "Headers": The provided init is not a valid array.',w.invalidStateError);this.append(e[0],e[1])}else for(let e of Object.keys(t))this.set(e,t[e])}append(t,e){let o=t.toLowerCase();if(this[Xe][o])this[Xe][o].value.push(e);else this[Xe][o]={name:t,value:[e]}}delete(t){delete this[Xe][t.toLowerCase()]}get(t){return this[Xe][t.toLowerCase()]?.value.join(", ")??null}set(t,e){this[Xe][t.toLowerCase()]={name:t,value:[e]}}getSetCookie(){let t=this[Xe]["set-cookie"];if(!t)return[];return t.value}has(t){return!!this[Xe][t.toLowerCase()]}forEach(t,e){let o=e??this[m];for(let i of Object.values(this[Xe]))t.call(o,i.value.join(", "),i.name,this)}*keys(){for(let t of Object.values(this[Xe]))yield t.name}*values(){for(let t of Object.values(this[Xe]))yield t.value.join(", ")}*entries(){for(let t of Object.values(this[Xe]))yield[t.name,t.value.join(", ")]}*[Symbol.iterator](){for(let t of Object.values(this[Xe]))yield[t.name,t.value.join(", ")]}}import Da from"fs";import Ba from"path";import uf from"crypto";class Zh{#t=new Set;#e=new Set;#r;constructor(t){this.#r=t}async load(t){if(!t)throw Error("Failed to execute 'load' on 'ResponseCacheFileSystem': Directory is not specified.");let e=Ba.resolve(t),o=[];try{o=await Da.promises.readdir(e)}catch(n){return}let i=[],s=this.#r;for(let n of o)if(n.endsWith(".json"))i.push(Da.promises.readFile(Ba.join(e,n),"utf8").then((l)=>{let y=JSON.parse(l);if(y.response&&y.request&&!y.virtual)return y.response.headers=new Ei(y.response.headers),y.request.headers=new Ei(y.request.headers),Da.promises.readFile(Ba.join(e,n.split(".")[0]+".data")).then((u)=>{y.response.body=u;let c=s.get(y.response.url);if(!c)c=[],s.set(y.response.url,c);c.push(y)}).catch(()=>{let u=s.get(y.response.url);if(!u)u=[],s.set(y.response.url,u);u.push(y)})}).catch(()=>{}));await Promise.all(i)}async save(t){if(!t)throw Error("Failed to execute 'store' on 'ResponseCacheFileSystem': Directory is not specified.");if(!this.#r.size)return;let e=Ba.resolve(t);if(!this.#t.has(e)){this.#t.add(e);try{await Da.promises.mkdir(e,{recursive:!0})}catch(n){}}let i=this.#r,s=[];for(let n of i.values())for(let l of n)if(!l.virtual){let y={},u={};for(let[f,E]of l.response.headers.entries())y[f]=E;for(let[f,E]of l.request.headers.entries())u[f]=E;let c={...l,response:{...l.response,headers:y,body:null},request:{...l.request,headers:u}},d=JSON.stringify(c,null,3),g=uf.createHash("md5").update(d).digest("hex");if(!this.#e.has(g)){if(this.#e.add(g),s.push(Da.promises.writeFile(Ba.join(e,`${g}.json`),d)),l.response.body)s.push(Da.promises.writeFile(Ba.join(e,`${g}.data`),l.response.body))}}await Promise.all(s)}}var hf=["Cache-Control","Last-Modified","Vary","ETag"];class sp{fileSystem;#t=new Map;constructor(){this.fileSystem=new Zh(this.#t)}get(t){if(t.headers.get("Cache-Control")?.includes("no-cache"))return null;let e=t.url,o=this.#t.get(e);if(o)for(let i=0,s=o.length;i<s;i++){let n=o[i],l=n.request.method===t.method;if(l)for(let y of Object.keys(n.vary)){let u=t.headers.get(y);if(u!==null&&n.vary[y]!==u){l=!1;break}}if(l){if(n.expires&&n.expires<Date.now()){if(n.lastModified)n.state=Kn.stale;else if(!n.etag)return o.splice(i,1),null}return n}}return null}add(t,e){if(t.method!=="GET"&&t.method!=="HEAD"||t.headers.get("Cache-Control")?.includes("no-cache"))return null;let o=t.url,i=this.get(t);if(e.status===304){if(!i)throw Error("ResponseCache: Cached response not found.");for(let s of hf)if(e.headers.has(s))i.response.headers.set(s,e.headers.get(s));i.cacheUpdateTime=Date.now(),i.state=Kn.fresh}else{if(i){let n=this.#t.get(o);if(n){let l=n.indexOf(i);if(l!==-1)n.splice(l,1)}}i={response:{status:e.status,statusText:e.statusText,url:e.url,headers:new Ei(e.headers),waitingForBody:e.waitingForBody,body:e.body??null},request:{headers:t.headers,method:t.method},vary:{},expires:null,etag:null,cacheUpdateTime:Date.now(),lastModified:null,mustRevalidate:!1,staleWhileRevalidate:!1,state:Kn.fresh,virtual:e.virtual??!1};let s=this.#t.get(o);if(!s)s=[],this.#t.set(o,s);s.push(i)}if(e.headers.has("Cache-Control")){let s=e.headers.get("Age");for(let n of e.headers.get("Cache-Control").split(",")){let[l,y]=n.trim().split("=");switch(l){case"max-age":i.expires=Date.now()+parseFloat(y)*1000-(s?parseFloat(s)*1000:0);break;case"no-cache":case"no-store":let u=this.#t.get(o);if(u){let c=u.indexOf(i);if(c!==-1)u.splice(c,1)}return null;case"must-revalidate":i.mustRevalidate=!0;break;case"stale-while-revalidate":i.staleWhileRevalidate=!0;break}}}if(e.headers.has("Last-Modified"))i.lastModified=Date.parse(e.headers.get("Last-Modified"));if(e.headers.has("Vary"))for(let s of e.headers.get("Vary").split(",")){let n=s.trim(),l=t.headers.get(n);if(l)i.vary[n]=l}if(e.headers.has("ETag"))i.etag=e.headers.get("ETag");if(!i.expires){let s=e.headers.get("Expires");if(s)i.expires=Date.parse(s)}if(!i.etag&&(!i.expires||i.expires<Date.now())){let s=this.#t.get(o);if(s){let n=s.indexOf(i);if(n!==-1)s.splice(n,1)}return null}return i}clear(t){if(t){if(t.toTime)for(let e of t.url?[t.url]:this.#t.keys()){let o=this.#t.get(e);if(o){for(let i=0,s=o.length;i<s;i++)if(o[i].cacheUpdateTime<t.toTime)o.splice(i,1),i--,s--}}else if(t.url)this.#t.delete(t.url)}else this.#t.clear()}}var kb;(function(t){t[t.log=0]="log",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error"})(kb||(kb={}));var mr=kb;var Mb;(function(t){t[t.elementNode=1]="elementNode",t[t.attributeNode=2]="attributeNode",t[t.textNode=3]="textNode",t[t.cdataSectionNode=4]="cdataSectionNode",t[t.commentNode=8]="commentNode",t[t.documentNode=9]="documentNode",t[t.documentTypeNode=10]="documentTypeNode",t[t.documentFragmentNode=11]="documentFragmentNode",t[t.processingInstructionNode=7]="processingInstructionNode"})(Mb||(Mb={}));var T=Mb;var Ib;(function(t){t[t.none=0]="none",t[t.capturing=1]="capturing",t[t.atTarget=2]="atTarget",t[t.bubbling=3]="bubbling"})(Ib||(Ib={}));var ae=Ib;class C{static NONE=ae.none;static CAPTURING_PHASE=ae.capturing;static AT_TARGET=ae.atTarget;static BUBBLING_PHASE=ae.bubbling;NONE=C.NONE;CAPTURING_PHASE=C.CAPTURING_PHASE;AT_TARGET=C.AT_TARGET;BUBBLING_PHASE=C.BUBBLING_PHASE;[Gm]=!1;[Gs]=!1;[Hi]=!1;[nr]=!1;[Er]=ae.none;[Ab]=performance.now();[Qt];[Wn]=!1;[Cs]=!1;[Is]=!1;[Pr]=null;[Bo]=null;[wa]=!1;constructor(t,e=null){this[Qt]=t,this[Gs]=e?.bubbles??!1,this[Hi]=e?.cancelable??!1,this[Gm]=e?.composed??!1}get composed(){return this[Gm]}get bubbles(){return this[Gs]}get cancelable(){return this[Hi]}get defaultPrevented(){return this[nr]}get eventPhase(){return this[Er]}get timeStamp(){return this[Ab]}get type(){return this[Qt]}get target(){return this[Pr]}get currentTarget(){return this[Bo]}get cancelBubble(){return this[Is]}composedPath(){if(!this[Pr])return[];let t=[],e=this[Pr];while(e)if(t.push(e),e.parentNode)e=e.parentNode;else if(this[Gm]&&e[D]===T.documentFragmentNode&&e.host)e=e.host;else if(e[D]===T.documentNode&&this[Qt]!=="load")e=e[m];else break;return t}initEvent(t,e=!1,o=!1){this[Qt]=t,this[Gs]=e,this[Hi]=o,this[Is]=!1,this[Cs]=!1,this[nr]=!1}preventDefault(){if(!this[wa]&&this.cancelable)this[nr]=!0}stopImmediatePropagation(){this[Cs]=!0}stopPropagation(){this[Is]=!0}}var Rb;(function(t){t.log="log",t.table="table",t.trace="trace",t.dir="dir",t.dirxml="dirxml",t.group="group",t.groupCollapsed="groupCollapsed",t.debug="debug",t.timeLog="timeLog",t.info="info",t.count="count",t.timeEnd="timeEnd",t.warn="warn",t.countReset="countReset",t.error="error",t.assert="assert"})(Rb||(Rb={}));var Fe=Rb;class tc{static toString(t){if(this.isLogEntryCollapsed(t))return"";let e=this.getLogEntryGroupTabbing(t),o=e;for(let i of t.message)if(o+=o!==""&&o!==e?" ":"",typeof i==="object"&&(i===null||i.constructor.name==="Object"||Array.isArray(i)))try{o+=JSON.stringify(i)}catch(s){o+=Error("Failed to JSON stringify object in log entry.").stack.replace(/\n at/gm,`
|
|
4
4
|
`+e+"at")}else if(typeof i==="object"&&i.message&&i.stack)o+=i.stack.replace(/\n at/gm,`
|
|
5
5
|
`+e+"at");else o+=this.getLogEntryIcon(t)+String(i);return o+`
|