@qitqode/qitqode-android-arm64 0.1.22 → 0.1.24
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/bundle/{chunk-18xhxdsh.js → chunk-02txthqv.js} +2 -2
- package/bundle/{chunk-t4c0zy2s.js → chunk-0ae5q6ck.js} +2 -2
- package/bundle/chunk-0bvde0cx.js +2 -0
- package/bundle/chunk-0kbxnazj.js +2 -0
- package/bundle/{chunk-n68xjm4p.js → chunk-0pbt75ev.js} +1 -1
- package/bundle/{chunk-hmm1m733.js → chunk-0pvbk8ks.js} +2 -2
- package/bundle/{chunk-j6cpsxva.js → chunk-0rtshz2r.js} +1 -1
- package/bundle/{chunk-mbkw9s6e.js → chunk-0w0jfzb4.js} +1 -1
- package/bundle/{chunk-qq9pvscd.js → chunk-0w4v0fbs.js} +2 -2
- package/bundle/{chunk-jee9y4t0.js → chunk-0z3z0gk1.js} +2 -2
- package/bundle/{chunk-mr7ya5kc.js → chunk-17ggas8k.js} +1 -1
- package/bundle/chunk-19z5q33z.js +2 -0
- package/bundle/chunk-1a0wnwna.js +2 -0
- package/bundle/{chunk-y2tnzn1y.js → chunk-1d64dywx.js} +2 -2
- package/bundle/chunk-1ddm2wxv.js +2 -0
- package/bundle/chunk-1fk4vsmc.js +2 -0
- package/bundle/{chunk-x4c8drpe.js → chunk-1fnmkm0z.js} +2 -2
- package/bundle/chunk-1j2f9nd5.js +2 -0
- package/bundle/{chunk-b5x3zghc.js → chunk-1jh5p5qw.js} +2 -2
- package/bundle/{chunk-mbmc1mg0.js → chunk-1jsywey3.js} +1 -1
- package/bundle/{chunk-t2n6fmpy.js → chunk-1p34bx7c.js} +2 -2
- package/bundle/{chunk-7yw60h8j.js → chunk-1xyn0sp2.js} +2 -2
- package/bundle/{chunk-yy91rm3y.js → chunk-1y9t7nxn.js} +1 -1
- package/bundle/{chunk-h99n5rv7.js → chunk-21ejqv4v.js} +1 -1
- package/bundle/chunk-23geekk5.js +3 -0
- package/bundle/chunk-27s736an.js +2 -0
- package/bundle/{chunk-4qegdkss.js → chunk-2eardzxs.js} +1 -1
- package/bundle/{chunk-6emme4kp.js → chunk-2gxjjqfx.js} +1 -1
- package/bundle/chunk-2j17xrzj.js +2 -0
- package/bundle/{chunk-s4epqtge.js → chunk-2mmspnr3.js} +1 -1
- package/bundle/{chunk-30233h8f.js → chunk-2qcndbxv.js} +1 -1
- package/bundle/{chunk-8rcpj28e.js → chunk-2wp1w8cy.js} +1 -1
- package/bundle/{chunk-6r4gn18m.js → chunk-2y8qz8te.js} +1 -1
- package/bundle/{chunk-8r4xs1q9.js → chunk-2z6fzwyc.js} +2 -2
- package/bundle/chunk-2zca3nak.js +2 -0
- package/bundle/chunk-2zcvcfq4.js +2 -0
- package/bundle/chunk-38hwkfj5.js +2 -0
- package/bundle/chunk-3afqxvsn.js +2 -0
- package/bundle/chunk-3avc1ppg.js +7 -0
- package/bundle/{chunk-a2ty2e0g.js → chunk-3nhqd8wg.js} +3 -3
- package/bundle/{chunk-jfy6bfvv.js → chunk-3tdqsm5c.js} +1 -1
- package/bundle/{chunk-c88rh38d.js → chunk-3tkp27x7.js} +2 -2
- package/bundle/chunk-3v4vtah1.js +2 -0
- package/bundle/{chunk-x8w2xgx6.js → chunk-3vbtra1j.js} +1 -1
- package/bundle/{chunk-b54t7ycj.js → chunk-3wzqs241.js} +1 -1
- package/bundle/chunk-3ypk0j2f.js +2 -0
- package/bundle/{chunk-tq258v8s.js → chunk-3z1y040p.js} +2 -2
- package/bundle/{chunk-3w60y2x5.js → chunk-453wpzg6.js} +1 -1
- package/bundle/chunk-4aykrj51.js +9 -0
- package/bundle/{chunk-qryeqw9s.js → chunk-4d1a547n.js} +1 -1
- package/bundle/chunk-4dtbmqmq.js +2 -0
- package/bundle/{chunk-s1mx3bkw.js → chunk-4k149ews.js} +1 -1
- package/bundle/{chunk-hyr049cr.js → chunk-4kse3awh.js} +1 -1
- package/bundle/chunk-4q9w2yve.js +5 -0
- package/bundle/{chunk-cx0z3mm3.js → chunk-4tn69nqs.js} +1 -1
- package/bundle/chunk-4zjb6rps.js +2 -0
- package/bundle/{chunk-cpkega70.js → chunk-58enbars.js} +2 -2
- package/bundle/{chunk-p64fb4rm.js → chunk-5h2hcp46.js} +1 -1
- package/bundle/chunk-5hkcjgwh.js +2 -0
- package/bundle/{chunk-7b69jj5g.js → chunk-5kmfnkzv.js} +1 -1
- package/bundle/{chunk-k19zvbzh.js → chunk-5rkmhzq0.js} +2 -2
- package/bundle/chunk-5snrz263.js +2 -0
- package/bundle/{chunk-ht1hqsaa.js → chunk-5y8efy5b.js} +1 -1
- package/bundle/chunk-653c0mxr.js +11 -0
- package/bundle/chunk-6av7hrrk.js +7 -0
- package/bundle/chunk-6bswn7w5.js +2 -0
- package/bundle/{chunk-fgtyrvan.js → chunk-6dxaty1v.js} +1 -1
- package/bundle/chunk-6epghftw.js +2 -0
- package/bundle/{chunk-bbznk59q.js → chunk-6g3m7yxf.js} +2 -2
- package/bundle/{chunk-xjdxyeja.js → chunk-6j0365q3.js} +2 -2
- package/bundle/chunk-6jjhxh8p.js +2 -0
- package/bundle/{chunk-y0fxwgrv.js → chunk-6mscvf6y.js} +1 -1
- package/bundle/{chunk-30p5pm3w.js → chunk-6nhje520.js} +1 -1
- package/bundle/{chunk-bjw39da9.js → chunk-6sdh1q7g.js} +1 -1
- package/bundle/{chunk-1eqcgkyq.js → chunk-6szvs3k9.js} +1 -1
- package/bundle/chunk-6ws7xyc5.js +2 -0
- package/bundle/{chunk-1d6ret10.js → chunk-78bajmqm.js} +1 -1
- package/bundle/{chunk-xtjsfqam.js → chunk-7a6p7dfx.js} +1 -1
- package/bundle/{chunk-ng85b73s.js → chunk-7dckfame.js} +1 -1
- package/bundle/chunk-7g28zhar.js +2 -0
- package/bundle/{chunk-8t1whx0k.js → chunk-7gczzccz.js} +1 -1
- package/bundle/chunk-7mhffm9f.js +800 -0
- package/bundle/{chunk-68jsyydc.js → chunk-7tgm8wp5.js} +1 -1
- package/bundle/chunk-7v02b2ms.js +2 -0
- package/bundle/chunk-7vmp2034.js +2 -0
- package/bundle/chunk-7wxrypkr.js +2 -0
- package/bundle/{chunk-1zb95qfx.js → chunk-7y3y3j51.js} +2 -2
- package/bundle/{chunk-mgp034y0.js → chunk-7yf15a3a.js} +1 -1
- package/bundle/{chunk-bwyf1bvf.js → chunk-82gs5cmn.js} +1 -1
- package/bundle/{chunk-hkmx6w54.js → chunk-84gnbzky.js} +1 -1
- package/bundle/{chunk-fyd31m33.js → chunk-8651hq0k.js} +1 -1
- package/bundle/{chunk-ymv05pbt.js → chunk-8717htya.js} +1 -1
- package/bundle/{chunk-fjtq8164.js → chunk-8ace31r2.js} +1 -1
- package/bundle/{chunk-7276th89.js → chunk-8cr7ks31.js} +1 -1
- package/bundle/{chunk-9g05wsae.js → chunk-8h9r6c8g.js} +2 -2
- package/bundle/chunk-8kk9gvdy.js +2 -0
- package/bundle/{chunk-haw1jzwb.js → chunk-8pe047p0.js} +1 -1
- package/bundle/{chunk-j2k4wxsk.js → chunk-8r79zf3y.js} +2 -2
- package/bundle/chunk-8ygpp4y3.js +2 -0
- package/bundle/chunk-95q60g1p.js +2 -0
- package/bundle/{chunk-rvz05kxy.js → chunk-9798jffg.js} +1 -1
- package/bundle/{chunk-7hx0pza2.js → chunk-99n6czag.js} +2 -2
- package/bundle/{chunk-m79gd4yt.js → chunk-9easaxy7.js} +1 -1
- package/bundle/{chunk-jyh2g13j.js → chunk-9f7y0dj0.js} +1 -1
- package/bundle/{chunk-x1dfc7qd.js → chunk-9jf67xb0.js} +2 -2
- package/bundle/chunk-9mjbenja.js +2 -0
- package/bundle/{chunk-9fdv5d8a.js → chunk-9nx8hm57.js} +1 -1
- package/bundle/{chunk-0ddhkapd.js → chunk-9pe4agdz.js} +2 -2
- package/bundle/{chunk-f72j5yx8.js → chunk-9rqrm9y8.js} +1 -1
- package/bundle/{chunk-mqt5qh3t.js → chunk-9sy9ws1w.js} +1 -1
- package/bundle/{chunk-zfw873yt.js → chunk-9vcw33dv.js} +1 -1
- package/bundle/chunk-9vn1gy8h.js +2 -0
- package/bundle/{chunk-wmmck56g.js → chunk-9xvctnjr.js} +1 -1
- package/bundle/{chunk-2p6w3w8f.js → chunk-a5zjrwqy.js} +2 -2
- package/bundle/{chunk-jj7wrfty.js → chunk-a9y27zd2.js} +1 -1
- package/bundle/{chunk-pcctf3gs.js → chunk-ac202abt.js} +1 -1
- package/bundle/{chunk-tcp31yv0.js → chunk-agdfqncf.js} +2 -2
- package/bundle/chunk-ajp3f08k.js +2 -0
- package/bundle/{chunk-7w01dxp9.js → chunk-am73j1bt.js} +1 -1
- package/bundle/{chunk-ne8ftsv3.js → chunk-apq38bt4.js} +3 -3
- package/bundle/chunk-aptkpdkc.js +2 -0
- package/bundle/{chunk-vpp88hhd.js → chunk-b643cra9.js} +229 -229
- package/bundle/{chunk-6hkv9411.js → chunk-b6m4yyww.js} +1 -1
- package/bundle/{chunk-rry321tn.js → chunk-b8ag61vj.js} +1 -1
- package/bundle/{chunk-hzexvrnj.js → chunk-bas6x25m.js} +2 -2
- package/bundle/{chunk-q6x5bmc3.js → chunk-bd21p9zz.js} +2 -2
- package/bundle/{chunk-t7v8wzr9.js → chunk-bf146hz2.js} +2 -2
- package/bundle/{chunk-pkdk0ppc.js → chunk-bky5a42k.js} +2 -2
- package/bundle/chunk-bry94ar5.js +2 -0
- package/bundle/chunk-btzyvqkf.js +2 -0
- package/bundle/{chunk-xce77xex.js → chunk-c31k8yh0.js} +1 -1
- package/bundle/chunk-c94pjdfh.js +2 -0
- package/bundle/chunk-cct9ds5c.js +2 -0
- package/bundle/chunk-cesrhm09.js +4 -0
- package/bundle/{chunk-pqyds00j.js → chunk-cvchztkc.js} +1 -1
- package/bundle/{chunk-x6gzygc3.js → chunk-cy2586rv.js} +1 -1
- package/bundle/chunk-czn535v0.js +2 -0
- package/bundle/chunk-d56zc21w.js +3 -0
- package/bundle/chunk-d7wd5hz1.js +2 -0
- package/bundle/chunk-d86cmjrp.js +2 -0
- package/bundle/{chunk-1kje2a6g.js → chunk-dann9gfq.js} +1 -1
- package/bundle/{chunk-fssgbz70.js → chunk-dcx8hjbs.js} +1 -1
- package/bundle/{chunk-x4b0ywbs.js → chunk-dgzyn27r.js} +1 -1
- package/bundle/{chunk-meaa7wrs.js → chunk-dkm7x8rj.js} +2 -2
- package/bundle/chunk-dkv2mg97.js +3 -0
- package/bundle/chunk-dnq65xvn.js +2 -0
- package/bundle/chunk-dpqv8rtn.js +2 -0
- package/bundle/chunk-e346x00p.js +10 -0
- package/bundle/chunk-e9mh7s3z.js +2 -0
- package/bundle/{chunk-kywg73qz.js → chunk-ebjhggdw.js} +1 -1
- package/bundle/{chunk-prrrw8t8.js → chunk-ecwz9nhs.js} +2 -2
- package/bundle/{chunk-m9bc5csy.js → chunk-edvcz2gd.js} +1 -1
- package/bundle/chunk-ek2y5f6g.js +2 -0
- package/bundle/{chunk-dhvwrrqx.js → chunk-ep8zn49w.js} +2 -2
- package/bundle/chunk-epdsay73.js +2 -0
- package/bundle/{chunk-adgrn60n.js → chunk-evqxvhdb.js} +1 -1
- package/bundle/{chunk-n1wawwry.js → chunk-ewyk4py6.js} +1 -1
- package/bundle/{chunk-56cty7nr.js → chunk-f3kjp838.js} +2 -2
- package/bundle/{chunk-c9afcdba.js → chunk-f819a7ec.js} +1 -1
- package/bundle/chunk-f89gntcy.js +3 -0
- package/bundle/{chunk-qwf258sw.js → chunk-fdezde1z.js} +1 -1
- package/bundle/chunk-ffnsn7tv.js +2 -0
- package/bundle/{chunk-98nh88th.js → chunk-fhng5her.js} +2 -2
- package/bundle/chunk-fkezc7ew.js +2 -0
- package/bundle/{chunk-78wt9ad8.js → chunk-fkvccmgk.js} +2 -2
- package/bundle/{chunk-1123xk5a.js → chunk-fm4xa6yx.js} +2 -2
- package/bundle/{chunk-j1kqhxnq.js → chunk-frdc3ysq.js} +1 -1
- package/bundle/chunk-fsxddgj0.js +2 -0
- package/bundle/{chunk-ah9cm91p.js → chunk-ftk58wxe.js} +1 -1
- package/bundle/{chunk-zz192a31.js → chunk-g0v9g37f.js} +1 -1
- package/bundle/{chunk-50aznc8e.js → chunk-g7vkkmsk.js} +3 -3
- package/bundle/chunk-gbcsfg6v.js +2 -0
- package/bundle/{chunk-s6qdtfty.js → chunk-gc9q0x8z.js} +3 -3
- package/bundle/{chunk-ntmn6epc.js → chunk-gen6f3dn.js} +2 -2
- package/bundle/{chunk-fkdbba26.js → chunk-gf4ek7rv.js} +1 -1
- package/bundle/{chunk-ee5r4h0v.js → chunk-gff87y4n.js} +1 -1
- package/bundle/chunk-gfmz85hp.js +2 -0
- package/bundle/chunk-gk63k4t6.js +2 -0
- package/bundle/{chunk-b3x13ndd.js → chunk-gn7xgd4c.js} +1 -1
- package/bundle/{chunk-4gfryje2.js → chunk-gn9p1d50.js} +1 -1
- package/bundle/{chunk-b1t8d1s8.js → chunk-gvzfffr4.js} +1 -1
- package/bundle/{chunk-zeh3mjgp.js → chunk-ha1w0xzh.js} +1 -1
- package/bundle/{chunk-r8ddb02d.js → chunk-hbnr0j7h.js} +2 -2
- package/bundle/chunk-hg563h5r.js +3 -0
- package/bundle/{chunk-y3x5m3e8.js → chunk-hg9nk090.js} +1 -1
- package/bundle/{chunk-67wvdfs5.js → chunk-hh3w51wp.js} +2 -2
- package/bundle/{chunk-fa03gsff.js → chunk-hh4c02fh.js} +1 -1
- package/bundle/{chunk-5z8gpy3x.js → chunk-hh9a709t.js} +1 -1
- package/bundle/{chunk-dgsg31vm.js → chunk-hjbks7r9.js} +1 -1
- package/bundle/{chunk-qafcfb4x.js → chunk-hqg5qbxk.js} +1 -1
- package/bundle/{chunk-jtbf88gw.js → chunk-hv4nhx6q.js} +2 -2
- package/bundle/{chunk-n4spe0sv.js → chunk-hxgb0y1w.js} +1 -1
- package/bundle/chunk-j0vf8s12.js +2 -0
- package/bundle/chunk-j1a64ade.js +3 -0
- package/bundle/chunk-j1bxt69x.js +2 -0
- package/bundle/{chunk-351wfvhp.js → chunk-j1veq3zr.js} +2 -2
- package/bundle/{chunk-60dxyp37.js → chunk-jbd9k041.js} +2 -2
- package/bundle/chunk-jcem8s30.js +2 -0
- package/bundle/{chunk-v9sfzkg5.js → chunk-jegn6jc3.js} +2 -2
- package/bundle/chunk-jjwjb9w0.js +3 -0
- package/bundle/{chunk-3degq6rv.js → chunk-jmjg8d8a.js} +4 -4
- package/bundle/chunk-jpham2a3.js +2 -0
- package/bundle/{chunk-rpy4rgmm.js → chunk-jpygkh1c.js} +1 -1
- package/bundle/{chunk-n39gqxkz.js → chunk-jr8qcf99.js} +2 -2
- package/bundle/{chunk-9hrpcnt8.js → chunk-jr9xnvjq.js} +1 -1
- package/bundle/{chunk-07b36w5g.js → chunk-jz3aav8a.js} +2 -2
- package/bundle/chunk-jzkymnr5.js +2 -0
- package/bundle/chunk-k0qtwnhb.js +2 -0
- package/bundle/{chunk-6w15nfph.js → chunk-k16hzy2q.js} +1 -1
- package/bundle/chunk-k2rsky7z.js +2 -0
- package/bundle/{chunk-61ndvjmm.js → chunk-k9d927xe.js} +1 -1
- package/bundle/{chunk-jrwfx6d8.js → chunk-k9g77a02.js} +1 -1
- package/bundle/{chunk-t1f7jeat.js → chunk-kaeyhw2n.js} +2 -2
- package/bundle/{chunk-gvj8qg7x.js → chunk-kc3hpmr2.js} +2 -2
- package/bundle/chunk-kcetcysa.js +2 -0
- package/bundle/chunk-kjfc5v3s.js +2 -0
- package/bundle/chunk-kkvb2c2z.js +8 -0
- package/bundle/chunk-km2ayfyf.js +2 -0
- package/bundle/chunk-knrh89eb.js +2 -0
- package/bundle/{chunk-8wzc27e3.js → chunk-kr0fsqas.js} +1 -1
- package/bundle/chunk-ksqfjawv.js +2 -0
- package/bundle/{chunk-awdpkgxf.js → chunk-ktmazmas.js} +2 -2
- package/bundle/{chunk-c4x99ayd.js → chunk-m8djypsy.js} +1 -1
- package/bundle/{chunk-10qkxzhh.js → chunk-mj24ntn9.js} +1 -1
- package/bundle/chunk-mjhb1q0n.js +3 -0
- package/bundle/{chunk-4xpfmpjf.js → chunk-ms1fd6h4.js} +1 -1
- package/bundle/chunk-mxcger73.js +2 -0
- package/bundle/{chunk-fzhgxcej.js → chunk-n1chdwrs.js} +1 -1
- package/bundle/{chunk-jatba8z8.js → chunk-najzfhb2.js} +1 -1
- package/bundle/chunk-nazkrkeb.js +2 -0
- package/bundle/chunk-nk01s49e.js +2 -0
- package/bundle/{chunk-pp44xnd7.js → chunk-ns0pswww.js} +1 -1
- package/bundle/chunk-ns8b7rx1.js +2 -0
- package/bundle/chunk-ny6vpkx2.js +2 -0
- package/bundle/{chunk-0vw5a7m9.js → chunk-p4hpr8d7.js} +1 -1
- package/bundle/{chunk-n1m5qdf5.js → chunk-p54bzjtv.js} +1 -1
- package/bundle/{chunk-f8xnn26j.js → chunk-pb7rnkke.js} +1 -1
- package/bundle/{chunk-4se8cbmb.js → chunk-pfhp78cr.js} +1 -1
- package/bundle/{chunk-y2r3zker.js → chunk-ps543k72.js} +1 -1
- package/bundle/chunk-pv8jcpnf.js +2 -0
- package/bundle/{chunk-vqxyph4q.js → chunk-pyq01301.js} +1 -1
- package/bundle/chunk-q0dd3ak6.js +3 -0
- package/bundle/chunk-q2s057bm.js +2 -0
- package/bundle/{chunk-x1naayst.js → chunk-q3x4x2tq.js} +1 -1
- package/bundle/chunk-q5cqg2c0.js +28 -0
- package/bundle/{chunk-msqx5bb0.js → chunk-q6fbyvpq.js} +1 -1
- package/bundle/chunk-qk2wnp2x.js +2 -0
- package/bundle/{chunk-wm3b050v.js → chunk-qw2hgs5b.js} +2 -2
- package/bundle/{chunk-8x6x3g16.js → chunk-qywwj58s.js} +2 -2
- package/bundle/chunk-r012q335.js +3 -0
- package/bundle/{chunk-gzwcj7c9.js → chunk-r3yqe7x0.js} +1 -1
- package/bundle/{chunk-2epf5806.js → chunk-r48g0kaq.js} +2 -2
- package/bundle/{chunk-hrnx60em.js → chunk-r7xp0xcn.js} +2 -2
- package/bundle/chunk-rbdjbgkb.js +2 -0
- package/bundle/{chunk-a3a9bbk7.js → chunk-rvvfs9ps.js} +2 -2
- package/bundle/chunk-rxjprhgh.js +2 -0
- package/bundle/chunk-s3w9bmze.js +2 -0
- package/bundle/chunk-s3zste1a.js +2 -0
- package/bundle/{chunk-bdzgtazc.js → chunk-s9amvacw.js} +2 -2
- package/bundle/chunk-sbt7qmwm.js +3 -0
- package/bundle/chunk-sf6h44pb.js +2 -0
- package/bundle/{chunk-aznbvrbm.js → chunk-sgtgvzv6.js} +1 -1
- package/bundle/chunk-sgvzxs7m.js +2 -0
- package/bundle/{chunk-h7rxnbf0.js → chunk-sjrmhd3e.js} +1 -1
- package/bundle/chunk-sp9bndyh.js +2 -0
- package/bundle/{chunk-ck65rcxb.js → chunk-spm1yy6w.js} +1 -1
- package/bundle/{chunk-h6htvj2y.js → chunk-srf73nm4.js} +1 -1
- package/bundle/{chunk-c2w3bqsa.js → chunk-sswbfqcq.js} +1 -1
- package/bundle/{chunk-er5q8nhp.js → chunk-t488d66k.js} +1 -1
- package/bundle/{chunk-aftpj9fe.js → chunk-t6w96xq2.js} +1 -1
- package/bundle/{chunk-t8365msg.js → chunk-te1zfpzv.js} +1 -1
- package/bundle/{chunk-2bxy8zm1.js → chunk-tk3bve0x.js} +2 -2
- package/bundle/chunk-tsn1jkr7.js +2 -0
- package/bundle/{chunk-z9b0ydw1.js → chunk-tzc4jkzg.js} +1 -1
- package/bundle/{chunk-01gtn79f.js → chunk-v2kyarwz.js} +2 -2
- package/bundle/{chunk-0qmaxpkv.js → chunk-v7r9np94.js} +1 -1
- package/bundle/{chunk-0jv8r99k.js → chunk-va4davgy.js} +317 -297
- package/bundle/{chunk-2bbvvh0d.js → chunk-vavrczqm.js} +1 -1
- package/bundle/{chunk-43xq4p51.js → chunk-ve5gb789.js} +2 -2
- package/bundle/{chunk-n9gzj085.js → chunk-vf1r5ckp.js} +1 -1
- package/bundle/{chunk-hnzs3ywg.js → chunk-vftqwdpg.js} +1 -1
- package/bundle/chunk-vg4styg5.js +2 -0
- package/bundle/chunk-vh09hhcs.js +2 -0
- package/bundle/chunk-vhktpm0n.js +2 -0
- package/bundle/{chunk-5a80qybt.js → chunk-vvypb02q.js} +1 -1
- package/bundle/{chunk-h5wh2d49.js → chunk-vzjcmwry.js} +2 -2
- package/bundle/{chunk-6nhgkw5r.js → chunk-w1atxyz0.js} +1 -1
- package/bundle/{chunk-73d0dy03.js → chunk-w7p2x973.js} +2 -2
- package/bundle/{chunk-db7hykjs.js → chunk-wa2ce2sg.js} +2 -2
- package/bundle/{chunk-3nc9wy1m.js → chunk-wf09j72q.js} +2 -2
- package/bundle/{chunk-wfb9dwmc.js → chunk-wfnk2vsd.js} +1 -1
- package/bundle/{chunk-zt8kghd2.js → chunk-wj6aq50n.js} +1 -1
- package/bundle/{chunk-39h565hz.js → chunk-wmrq9qqf.js} +1 -1
- package/bundle/{chunk-ha5qct06.js → chunk-wmw2gne9.js} +2 -2
- package/bundle/chunk-wtp0yvqw.js +2 -0
- package/bundle/{chunk-btjcs9ee.js → chunk-x6z2b63w.js} +1 -1
- package/bundle/{chunk-3xbtg0hn.js → chunk-xccs5c50.js} +1 -1
- package/bundle/{chunk-abc7ccfd.js → chunk-xj73j10a.js} +1 -1
- package/bundle/chunk-xmzs7q66.js +2 -0
- package/bundle/chunk-xv80476w.js +2 -0
- package/bundle/{chunk-tepesp0b.js → chunk-xv8gnkh5.js} +1 -1
- package/bundle/{chunk-hf0gny5t.js → chunk-y1srca0c.js} +2 -2
- package/bundle/{chunk-zy0zn8yx.js → chunk-y2jmtfdh.js} +2 -2
- package/bundle/{chunk-w8xaw2dv.js → chunk-y3n31nnx.js} +2 -2
- package/bundle/{chunk-6v4mhtha.js → chunk-ygj1cy0n.js} +1 -1
- package/bundle/{chunk-496rb1e4.js → chunk-yh174jhg.js} +2 -2
- package/bundle/chunk-yjvr0et1.js +2 -0
- package/bundle/{chunk-h9ftcgs2.js → chunk-yz7rqzby.js} +3 -3
- package/bundle/{chunk-2qy62cv4.js → chunk-yzdty5t9.js} +2 -2
- package/bundle/{chunk-5mrjxapq.js → chunk-zavtsfxz.js} +1 -1
- package/bundle/{chunk-h725tttx.js → chunk-zeh481tm.js} +2 -2
- package/bundle/{chunk-cn7nnjsf.js → chunk-zfnbk5gy.js} +1 -1
- package/bundle/{chunk-p20ft5mj.js → chunk-zk8n8hnh.js} +2 -2
- package/bundle/{chunk-en7nxqvn.js → chunk-zp2ffbc2.js} +2 -2
- package/bundle/chunk-zx3kcfkj.js +2 -0
- package/bundle/index.js +4 -4
- package/bundle/parser.worker.js +2 -2
- package/bundle/worker.js +1 -1
- package/package.json +1 -1
- package/bundle/chunk-04ezvjjf.js +0 -2
- package/bundle/chunk-0msr85tj.js +0 -2
- package/bundle/chunk-0qrpg3n8.js +0 -2
- package/bundle/chunk-0w8ztgmg.js +0 -2
- package/bundle/chunk-0y2nwncb.js +0 -2
- package/bundle/chunk-0zh8tykf.js +0 -2
- package/bundle/chunk-21z1vfgm.js +0 -2
- package/bundle/chunk-2ec8msmq.js +0 -2
- package/bundle/chunk-2n5m61m9.js +0 -2
- package/bundle/chunk-362z696e.js +0 -2
- package/bundle/chunk-367rm03h.js +0 -2
- package/bundle/chunk-3f6t3wde.js +0 -799
- package/bundle/chunk-40vz0fhv.js +0 -3
- package/bundle/chunk-43k17qzb.js +0 -2
- package/bundle/chunk-4r574drd.js +0 -2
- package/bundle/chunk-6c2xn1ab.js +0 -2
- package/bundle/chunk-6pe3xzkk.js +0 -11
- package/bundle/chunk-6rak9ez9.js +0 -2
- package/bundle/chunk-71dbq1d0.js +0 -2
- package/bundle/chunk-73r1zvgw.js +0 -2
- package/bundle/chunk-7az1bpy8.js +0 -2
- package/bundle/chunk-7bm1t462.js +0 -2
- package/bundle/chunk-7nq8126b.js +0 -2
- package/bundle/chunk-80a0d0js.js +0 -2
- package/bundle/chunk-9ac4h2d9.js +0 -2
- package/bundle/chunk-9zp746aj.js +0 -2
- package/bundle/chunk-a0vpemkf.js +0 -2
- package/bundle/chunk-anqjy235.js +0 -7
- package/bundle/chunk-atjzxp7b.js +0 -2
- package/bundle/chunk-ax4f4fbm.js +0 -2
- package/bundle/chunk-aybmm0jf.js +0 -2
- package/bundle/chunk-b2scgkye.js +0 -2
- package/bundle/chunk-b5h8vd5n.js +0 -3
- package/bundle/chunk-bbpze4hq.js +0 -2
- package/bundle/chunk-bn6mg34g.js +0 -7
- package/bundle/chunk-c6wrjyep.js +0 -2
- package/bundle/chunk-cckshvkb.js +0 -9
- package/bundle/chunk-ce3c03mh.js +0 -2
- package/bundle/chunk-cm31dbwq.js +0 -2
- package/bundle/chunk-cqaw6hka.js +0 -2
- package/bundle/chunk-cxbkhs5y.js +0 -2
- package/bundle/chunk-d9vs6zd0.js +0 -2
- package/bundle/chunk-dcyzpkww.js +0 -2
- package/bundle/chunk-dj3rct8v.js +0 -2
- package/bundle/chunk-djcsvcby.js +0 -5
- package/bundle/chunk-ds162xgb.js +0 -3
- package/bundle/chunk-e1zv873k.js +0 -2
- package/bundle/chunk-eb0ksh4x.js +0 -2
- package/bundle/chunk-efxshjyz.js +0 -2
- package/bundle/chunk-enry018j.js +0 -2
- package/bundle/chunk-f03yje8k.js +0 -3
- package/bundle/chunk-fd1vbz1f.js +0 -3
- package/bundle/chunk-fydd2nmw.js +0 -2
- package/bundle/chunk-g2bw2qf5.js +0 -2
- package/bundle/chunk-h9a4zzr4.js +0 -2
- package/bundle/chunk-hkqcpdmt.js +0 -3
- package/bundle/chunk-jx3kvzka.js +0 -2
- package/bundle/chunk-k6eyc1wv.js +0 -8
- package/bundle/chunk-k9m536te.js +0 -2
- package/bundle/chunk-khkv9s5c.js +0 -2
- package/bundle/chunk-kv58j3yk.js +0 -2
- package/bundle/chunk-m3sr6xdg.js +0 -2
- package/bundle/chunk-mmyhzhzt.js +0 -2
- package/bundle/chunk-mt8zem33.js +0 -24
- package/bundle/chunk-mw60bmaf.js +0 -2
- package/bundle/chunk-nk42gy65.js +0 -2
- package/bundle/chunk-ps8xnz0h.js +0 -2
- package/bundle/chunk-pvn4dz8e.js +0 -2
- package/bundle/chunk-pw3tnt2j.js +0 -2
- package/bundle/chunk-pzajshbc.js +0 -2
- package/bundle/chunk-q2weasmk.js +0 -2
- package/bundle/chunk-qe8zp79w.js +0 -2
- package/bundle/chunk-qvcnvqvf.js +0 -2
- package/bundle/chunk-qxrjbw22.js +0 -2
- package/bundle/chunk-qy9s3nmy.js +0 -2
- package/bundle/chunk-r0zsgad8.js +0 -4
- package/bundle/chunk-r4hkkcj4.js +0 -2
- package/bundle/chunk-r50kjthp.js +0 -2
- package/bundle/chunk-rbrkvj3x.js +0 -2
- package/bundle/chunk-rhgfyvth.js +0 -2
- package/bundle/chunk-rjdpw6at.js +0 -2
- package/bundle/chunk-s6c5c940.js +0 -2
- package/bundle/chunk-s79zd152.js +0 -2
- package/bundle/chunk-skjx57kv.js +0 -2
- package/bundle/chunk-ssfgge5z.js +0 -2
- package/bundle/chunk-t813v629.js +0 -2
- package/bundle/chunk-tdqbsbyb.js +0 -2
- package/bundle/chunk-th189x63.js +0 -3
- package/bundle/chunk-thbjhgw0.js +0 -2
- package/bundle/chunk-tk6gjy9d.js +0 -3
- package/bundle/chunk-tsfpkwvr.js +0 -2
- package/bundle/chunk-tz8qhbk9.js +0 -3
- package/bundle/chunk-v07wtbmt.js +0 -2
- package/bundle/chunk-v6kenrks.js +0 -2
- package/bundle/chunk-v7dfqwxx.js +0 -2
- package/bundle/chunk-vf7hhxsa.js +0 -2
- package/bundle/chunk-vmhq6cyz.js +0 -2
- package/bundle/chunk-vvs87e61.js +0 -2
- package/bundle/chunk-w6z123g2.js +0 -2
- package/bundle/chunk-wg0849tq.js +0 -2
- package/bundle/chunk-xa0f5g9z.js +0 -2
- package/bundle/chunk-xj0ba60b.js +0 -2
- package/bundle/chunk-xtfcdgwe.js +0 -2
- package/bundle/chunk-xz7dccwp.js +0 -2
- package/bundle/chunk-ye6j8k26.js +0 -2
- package/bundle/chunk-zbvf09bm.js +0 -3
- package/bundle/chunk-zmqmccbc.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$l as Qi,Vl as no,Wl as Vi,Xl as oo,Yl as ci,_l as $i}from"./chunk-50aznc8e.js";import{$m as yt,$n as Zt,Am as Er,An as Nt,Bm as Wr,Bn as Tt,Cm as Pr,Cn as lt,Dm as Ur,Dn as At,Em as Zr,En as Ot,Eo as Zi,Fm as vr,Fn as dt,Gm as Xr,Gn as Lo,Hm as Yr,Hn as Go,Im as H,In as $t,Jm as zr,Jn as Qt,Km as kr,Kn as Bt,Lm as Vr,Ln as Dt,Mm as cr,Mn as It,Nm as wr,Nn as Lt,Om as qr,On as Gt,Pm as Fr,Pn as Mt,Qm as ar,Qn as xt,Rm as jr,Rn as Ct,Sm as br,Sn as Jt,Tm as hr,Tn as Ht,Um as nt,Un as Kt,Vm as ot,Vn as Rt,Wm as rt,Wn as St,Xm as tt,Xn as Et,Ym as it,Yn as Wt,Zm as et,Zn as Pt,_m as mt,_n as Ut,am as pr,an as ft,ao as vt,bm as _r,bn as gt,bo as Xt,cm as En,cn as a,co as Yt,dm as Wn,dn as Q,do as zt,em as Nr,en as fn,eo as kt,fm as Tr,fn as yn,fo as Vt,gm as lr,gn as Yo,go as ct,hn as ut,ho as wt,im as Ar,in as X,io as qt,jm as Or,jn as so,jo as Ft,km as dr,kn as Pn,ko as at,lm as $r,ln as po,lo as jt,mm as Qr,mn as _o,mo as bt,nm as Br,nn as No,no as ht,om as Dr,on as To,oo as ni,pm as Ir,pn as lo,po as oi,qm as Lr,qn as Ao,qo as ri,rm as Gr,rn as Oo,ro as ti,sm as Mr,sn as st,so as ii,tm as xr,tn as $o,to as ei,um as Cr,un as Qo,uo as mi,vm as Jr,vn as Bo,vo as yi,wm as Hr,wn as pt,wo as ao,xm as Kr,xn as Do,xo as fi,ym as Rr,yn as _t,yo as gi,zm as Sr,zn as Io,zo as ui}from"./chunk-c4x99ayd.js";import{ip as bn,mp as hn}from"./chunk-tq258v8s.js";import{rp as Yi}from"./chunk-jfy6bfvv.js";import{sp as Jo}from"./chunk-2p6w3w8f.js";import{qr as Xn,rr as ro,sr as Nn,tr as Hi,ur as Wi,wr as Ki}from"./chunk-2bxy8zm1.js";import{xr as Si}from"./chunk-qq9pvscd.js";import{Ds as eo}from"./chunk-56cty7nr.js";import{Hs as Wo,Us as un,ct as dn,dt as nn,mt as V}from"./chunk-p20ft5mj.js";import{Bt as wo,Ct as c,Gt as go,yt as di}from"./chunk-b5x3zghc.js";import{It as j}from"./chunk-tk6gjy9d.js";import{Vz as Tn,bA as Cn,pA as Kn}from"./chunk-01gtn79f.js";import{$H as r,BN as N,GE as Eo,MO as Oi,NE as kn,NN as vo,UE as sn,eC as wn,iF as Ai,jD as Qn,oJ as Ln,yF as h}from"./chunk-meaa7wrs.js";import{nP as On}from"./chunk-fa03gsff.js";var qo={};On(qo,{run:()=>ji});var mn={time_created:a().notNull().$default(()=>Date.now()),time_updated:a().notNull().$onUpdate(()=>Date.now())};var x=yn("project",{id:Q().$type().primaryKey(),worktree:Q().notNull(),vcs:Q(),name:Q(),icon_url:Q(),icon_color:Q(),...mn,time_initialized:a(),sandboxes:Q({mode:"json"}).notNull().$type(),commands:Q({mode:"json"}).$type()});var gn=yn("session",{id:Q().$type().primaryKey(),project_id:Q().$type().notNull().references(()=>x.id,{onDelete:"cascade"}),workspace_id:Q().$type(),parent_id:Q().$type(),context_from:Q().$type(),context_watermark:Q().$type(),slug:Q().notNull(),directory:Q().notNull(),title:Q().notNull(),version:Q().notNull(),share_url:Q(),summary_additions:a(),summary_deletions:a(),summary_files:a(),summary_diffs:Q({mode:"json"}).$type(),revert:Q({mode:"json"}).$type(),permission:Q({mode:"json"}).$type(),...mn,time_compacting:a(),time_archived:a(),last_checkpoint_message_id:Q().$type()},(n)=>[fn("session_project_idx").on(n.project_id),fn("session_workspace_idx").on(n.workspace_id),fn("session_parent_idx").on(n.parent_id),fn("session_context_from_idx").on(n.context_from)]),fo=yn("message",{id:Q().$type().primaryKey(),session_id:Q().$type().notNull().references(()=>gn.id,{onDelete:"cascade"}),agent_id:Q().notNull().default("main"),...mn,data:Q({mode:"json"}).notNull().$type()},(n)=>[fn("message_session_time_created_id_idx").on(n.session_id,n.time_created,n.id),fn("message_session_agent_idx").on(n.session_id,n.agent_id,n.id)]),zo=yn("part",{id:Q().$type().primaryKey(),message_id:Q().$type().notNull().references(()=>fo.id,{onDelete:"cascade"}),session_id:Q().$type().notNull(),...mn,data:Q({mode:"json"}).notNull().$type()},(n)=>[fn("part_message_id_id_idx").on(n.message_id,n.id),fn("part_session_idx").on(n.session_id)]),ko=yn("todo",{session_id:Q().$type().notNull().references(()=>gn.id,{onDelete:"cascade"}),content:Q().notNull(),status:Q().notNull(),position:a().notNull(),...mn},(n)=>[Yo({columns:[n.session_id,n.position]}),fn("todo_session_idx").on(n.session_id)]),Vo=yn("permission",{project_id:Q().primaryKey().references(()=>x.id,{onDelete:"cascade"}),...mn,data:Q({mode:"json"}).notNull().$type()});var co=yn("session_share",{session_id:Q().primaryKey().references(()=>gn.id,{onDelete:"cascade"}),id:Q().notNull(),secret:Q().notNull(),url:Q().notNull(),...mn});import k from"path";var v=V.create({service:"json-migration"});async function ji(n,o){let t=k.join(dn.Path.data,"storage");if(!await go.exists(t))return v.info("storage directory does not exist, skipping migration"),{projects:0,sessions:0,messages:0,parts:0,todos:0,permissions:0,shares:0,errors:[]};v.info("starting json to sqlite migration",{storageDir:t});let s=performance.now();n.run("PRAGMA journal_mode = WAL"),n.run("PRAGMA synchronous = OFF"),n.run("PRAGMA cache_size = 10000"),n.run("PRAGMA temp_store = MEMORY");let e={projects:0,sessions:0,messages:0,parts:0,todos:0,permissions:0,shares:0,errors:[]},l={sessions:0,todos:0,permissions:0,shares:0},_=e.errors,A=1000,C=Date.now();async function S(g){return wo.scan(g,{cwd:t,absolute:!0})}async function K(g,G,J){let B=J-G,T=Array(B);for(let P=0;P<B;P++)T[P]=go.readJson(g[G+P]);let M=await Promise.allSettled(T),Z=Array(B);for(let P=0;P<M.length;P++){let w=M[P];if(w.status==="fulfilled"){Z[P]=w.value;continue}_.push(`failed to read ${g[G+P]}: ${w.reason}`)}return Z}function R(g,G,J){if(g.length===0)return 0;try{return n.insert(G).values(g).onConflictDoNothing().run(),g.length}catch(B){return _.push(`failed to migrate ${J} batch: ${B}`),0}}v.info("scanning files...");let[E,d,D,L,u,p,m]=await Promise.all([S("project/*.json"),S("session/*/*.json"),S("message/*/*.json"),S("part/*/*.json"),S("todo/*.json"),S("permission/*.json"),S("session_share/*.json")]);v.info("file scan complete",{projects:E.length,sessions:d.length,messages:D.length,parts:L.length,todos:u.length,permissions:p.length,shares:m.length});let f=Math.max(1,E.length+d.length+D.length+L.length+u.length+p.length+m.length),i=o?.progress,y=0,$=(g,G)=>{y=Math.min(f,y+G),i?.({current:y,total:f,label:g})};i?.({current:y,total:f,label:"starting"}),n.run("BEGIN TRANSACTION");let I=new Set,O=[];for(let g=0;g<E.length;g+=A){let G=Math.min(g+A,E.length),J=await K(E,g,G);O.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=k.basename(E[g+B],".json");I.add(M),O.push({id:M,worktree:T.worktree??"/",vcs:T.vcs,name:T.name??void 0,icon_url:T.icon?.url,icon_color:T.icon?.color,time_created:T.time?.created??C,time_updated:T.time?.updated??C,time_initialized:T.time?.initialized,sandboxes:T.sandboxes??[],commands:T.commands})}e.projects+=R(O,x,"project"),$("projects",G-g)}v.info("migrated projects",{count:e.projects,duration:Math.round(performance.now()-s)});let U=d.map((g)=>k.basename(k.dirname(g))),z=new Set,en=[];for(let g=0;g<d.length;g+=A){let G=Math.min(g+A,d.length),J=await K(d,g,G);en.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=k.basename(d[g+B],".json"),Z=U[g+B];if(!I.has(Z)){l.sessions++;continue}z.add(M),en.push({id:M,project_id:Z,parent_id:T.parentID??null,slug:T.slug??"",directory:T.directory??"",title:T.title??"",version:T.version??"",share_url:T.share?.url??null,summary_additions:T.summary?.additions??null,summary_deletions:T.summary?.deletions??null,summary_files:T.summary?.files??null,summary_diffs:T.summary?.diffs??null,revert:T.revert??null,permission:T.permission??null,time_created:T.time?.created??C,time_updated:T.time?.updated??C,time_compacting:T.time?.compacting??null,time_archived:T.time?.archived??null})}e.sessions+=R(en,gn,"session"),$("sessions",G-g)}if(v.info("migrated sessions",{count:e.sessions}),l.sessions>0)v.warn("skipped orphaned sessions",{count:l.sessions});let pn=[],W=[],qn=new Map;for(let g of D){let G=k.basename(k.dirname(g));if(!z.has(G))continue;pn.push(g),W.push(G)}for(let g=0;g<pn.length;g+=A){let G=Math.min(g+A,pn.length),J=await K(pn,g,G),B=Array(J.length),T=0;for(let M=0;M<J.length;M++){let Z=J[M];if(!Z)continue;let P=pn[g+M],w=k.basename(P,".json"),Sn=W[g+M];qn.set(w,Sn);let Bn=Z;delete Bn.id,delete Bn.sessionID,B[T++]={id:w,session_id:Sn,time_created:Z.time?.created??C,time_updated:Z.time?.updated??C,data:Bn}}B.length=T,e.messages+=R(B,fo,"message"),$("messages",G-g)}v.info("migrated messages",{count:e.messages});for(let g=0;g<L.length;g+=A){let G=Math.min(g+A,L.length),J=await K(L,g,G),B=Array(J.length),T=0;for(let M=0;M<J.length;M++){let Z=J[M];if(!Z)continue;let P=L[g+M],w=k.basename(P,".json"),Sn=k.basename(k.dirname(P)),Bn=qn.get(Sn);if(!Bn){_.push(`part missing message session: ${P}`);continue}if(!z.has(Bn))continue;let jn=Z;delete jn.id,delete jn.messageID,delete jn.sessionID,B[T++]={id:w,message_id:Sn,session_id:Bn,time_created:Z.time?.created??C,time_updated:Z.time?.updated??C,data:jn}}B.length=T,e.parts+=R(B,zo,"part"),$("parts",G-g)}v.info("migrated parts",{count:e.parts});let An=u.map((g)=>k.basename(g,".json"));for(let g=0;g<u.length;g+=A){let G=Math.min(g+A,u.length),J=await K(u,g,G),B=[];for(let T=0;T<J.length;T++){let M=J[T];if(!M)continue;let Z=An[g+T];if(!z.has(Z)){l.todos++;continue}if(!Array.isArray(M)){_.push(`todo not an array: ${u[g+T]}`);continue}for(let P=0;P<M.length;P++){let w=M[P];if(!w?.content||!w?.status)continue;B.push({session_id:Z,content:w.content,status:w.status,position:P,time_created:C,time_updated:C})}}e.todos+=R(B,ko,"todo"),$("todos",G-g)}if(v.info("migrated todos",{count:e.todos}),l.todos>0)v.warn("skipped orphaned todos",{count:l.todos});let Fn=p.map((g)=>k.basename(g,".json")),Rn=[];for(let g=0;g<p.length;g+=A){let G=Math.min(g+A,p.length),J=await K(p,g,G);Rn.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=Fn[g+B];if(!I.has(M)){l.permissions++;continue}Rn.push({project_id:M,data:T})}e.permissions+=R(Rn,Vo,"permission"),$("permissions",G-g)}if(v.info("migrated permissions",{count:e.permissions}),l.permissions>0)v.warn("skipped orphaned permissions",{count:l.permissions});let an=m.map((g)=>k.basename(g,".json")),Gn=[];for(let g=0;g<m.length;g+=A){let G=Math.min(g+A,m.length),J=await K(m,g,G);Gn.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=an[g+B];if(!z.has(M)){l.shares++;continue}if(!T?.id||!T?.secret||!T?.url){_.push(`session_share missing id/secret/url: ${m[g+B]}`);continue}Gn.push({session_id:M,id:T.id,secret:T.secret,url:T.url})}e.shares+=R(Gn,co,"session_share"),$("shares",G-g)}if(v.info("migrated session shares",{count:e.shares}),l.shares>0)v.warn("skipped orphaned session shares",{count:l.shares});if(n.run("COMMIT"),v.info("json migration complete",{projects:e.projects,sessions:e.sessions,messages:e.messages,parts:e.parts,todos:e.todos,permissions:e.permissions,shares:e.shares,errorCount:e.errors.length,duration:Math.round(performance.now()-s)}),e.errors.length>0)v.warn("migration errors",{errors:e.errors.slice(0,20)});return i?.({current:f,total:f,label:"complete"}),e}var In={};On(In,{use:()=>Je,transaction:()=>Ke,textDecoder:()=>mt,sumDistinct:()=>tr,sum:()=>rr,sql:()=>H,relationsOrderToSQL:()=>ii,relationsFilterToSQL:()=>ti,relationToSQL:()=>mi,relationExtrasToSQL:()=>ei,processRelations:()=>Wt,placeholder:()=>kr,param:()=>Yr,orderSelectedFields:()=>ar,orderByOperators:()=>Vt,or:()=>po,operators:()=>kt,notLike:()=>Nt,notInArray:()=>st,notIlike:()=>lt,notExists:()=>pt,notBetween:()=>_t,not:()=>_o,noopMapper:()=>vr,noopEncoder:()=>Zr,noopDecoder:()=>Ur,ne:()=>so,name:()=>Wr,min:()=>er,max:()=>ir,mapUpdateSet:()=>br,mapResultRow:()=>Fr,mapRelationalRow:()=>wt,mapColumnsInSQLToAlias:()=>Ht,mapColumnsInAliasedSQLToAlias:()=>Jt,lte:()=>Ao,lt:()=>lo,like:()=>Io,l2Distance:()=>mr,l1Distance:()=>yr,jaccardDistance:()=>sr,isWithEnum:()=>ft,isView:()=>wr,isTable:()=>Lr,isSQLWrapper:()=>Kr,isNull:()=>$o,isNotNull:()=>Qo,isDriverValueEncoder:()=>Pr,isConfig:()=>et,is:()=>En,innerProduct:()=>fr,inArray:()=>Oo,ilike:()=>Tt,haveSameKeys:()=>jr,hasOwnEntityKind:()=>_r,hammingDistance:()=>ur,gte:()=>To,gt:()=>No,getViewSelectedFields:()=>ot,getViewName:()=>qr,getTableUniqueName:()=>Mr,getTableName:()=>Gr,getTableLikeName:()=>tt,getTableColumns:()=>nt,getTableAsAliasSQL:()=>yi,getOriginalColumnFromAlias:()=>Kt,getOrderByOperators:()=>ct,getColumns:()=>rt,getColumnTable:()=>Nr,getColumnNameAndConfig:()=>it,getChannelPath:()=>zi,fillPlaceholders:()=>Vr,fieldSelectionToSQL:()=>ri,extractTablesFromSchema:()=>ht,extractExtendedColumnType:()=>Tr,exists:()=>Bo,eq:()=>X,entityKind:()=>pr,effect:()=>He,desc:()=>Go,defineRelationsPart:()=>oi,defineRelations:()=>ni,createRelationsHelper:()=>bt,countDistinct:()=>ho,count:()=>uo,cosineDistance:()=>gr,close:()=>Ce,buildRelationsParts:()=>Ut,buildRelations:()=>Pt,bindIfParam:()=>ut,between:()=>Do,avgDistinct:()=>or,avg:()=>nr,assertUnreachable:()=>yt,asc:()=>Lo,arrayOverlaps:()=>dt,arrayContains:()=>At,arrayContained:()=>Ot,applyMixins:()=>hr,and:()=>Pn,aliasedTableColumn:()=>Ct,aliasedTable:()=>Gt,aliasedRelation:()=>xt,aliasedColumn:()=>Mt,WithSubquery:()=>Cr,ViewSelectionAliasProxyHandler:()=>Bt,ViewBaseConfig:()=>Jr,View:()=>cr,TransactionRollbackError:()=>Et,TableSchema:()=>Ar,TableColumns:()=>Or,TableAliasProxyHandler:()=>Dt,Table:()=>Ir,Subquery:()=>xr,StringChunk:()=>Rr,SQL:()=>Sr,RelationsHelperStatic:()=>jt,RelationsBuilderTable:()=>qt,RelationsBuilderJunctionColumn:()=>at,RelationsBuilderColumn:()=>Ft,RelationTableAliasProxyHandler:()=>Lt,Relation:()=>Zt,QueryPromise:()=>$t,Placeholder:()=>zr,Path:()=>Po,Param:()=>Xr,OriginalName:()=>$r,One:()=>vt,NotFoundError:()=>xe,NoopLogger:()=>ui,Name:()=>Er,Many:()=>Xt,IsAlias:()=>Br,FakePrimitiveParam:()=>Hr,ExtraConfigColumns:()=>dr,ExtraConfigBuilder:()=>Dr,DrizzleQueryError:()=>St,DrizzleError:()=>Rt,DefaultLogger:()=>gi,Count:()=>zt,ConsoleLogWriter:()=>fi,ColumnTableAliasProxyHandler:()=>Qt,ColumnBuilder:()=>lr,ColumnAliasProxyHandler:()=>It,Column:()=>Wn,Client:()=>Jn,CONSTANTS:()=>gt,BaseName:()=>Qr,AggregatedField:()=>Yt});import bi from"crypto";import Fo,{existsSync as hi,readdirSync as ne}from"fs";import{join as oe}from"path";function jo(n){if(Fo.existsSync(`${n.migrationsFolder}/meta/_journal.json`))throw Error('We detected that you have old drizzle-kit migration folders. You must upgrade drizzle-kit and run "drizzle-kit up"');let o=n.migrationsFolder,t=[],s=ne(o).map((e)=>({path:oe(o,e,"migration.sql"),name:e})).filter((e)=>hi(e.path));s.sort((e,l)=>e.name.localeCompare(l.name));for(let e of s){let l=e.path,_=e.name.slice(0,14),A=Fo.readFileSync(l).toString(),C=A.split("--> statement-breakpoint").map((K)=>{return K}),S=ao(_);t.push({sql:C,bps:!0,folderMillis:S,hash:bi.createHash("sha256").update(A).digest("hex"),name:e.name})}return t}function bo(n,o){if(Array.isArray(o)||"migrationsJournal"in o){let s=Array.isArray(o)?o:o.migrationsJournal,e=Array.isArray(o)?void 0:o.migrationsTable,l=s.map((_)=>({sql:_.sql.split("--> statement-breakpoint"),folderMillis:_.timestamp,hash:"",bps:!0,name:_.name}));return n.dialect.migrate(l,n.session,{migrationsTable:e})}let t=jo(o);return n.dialect.migrate(t,n.session,o)}function uo(n){return H`count(${n||H.raw("*")})`.mapWith(Number)}function ho(n){return H`count(distinct ${n})`.mapWith(Number)}function nr(n){return H`avg(${n})`.mapWith(String)}function or(n){return H`avg(distinct ${n})`.mapWith(String)}function rr(n){return H`sum(${n})`.mapWith(String)}function tr(n){return H`sum(distinct ${n})`.mapWith(String)}function ir(n){return H`max(${n})`.mapWith(En(n,Wn)?n:String)}function er(n){return H`min(${n})`.mapWith(En(n,Wn)?n:String)}function Mn(n){return JSON.stringify(n)}function mr(n,o){if(Array.isArray(o))return H`${n} <-> ${Mn(o)}`;return H`${n} <-> ${o}`}function yr(n,o){if(Array.isArray(o))return H`${n} <+> ${Mn(o)}`;return H`${n} <+> ${o}`}function fr(n,o){if(Array.isArray(o))return H`${n} <#> ${Mn(o)}`;return H`${n} <#> ${o}`}function gr(n,o){if(Array.isArray(o))return H`${n} <=> ${Mn(o)}`;return H`${n} <=> ${o}`}function ur(n,o){if(Array.isArray(o))return H`${n} <~> ${Mn(o)}`;return H`${n} <~> ${o}`}function sr(n,o){if(Array.isArray(o))return H`${n} <%> ${Mn(o)}`;return H`${n} <%> ${o}`}import io from"path";var Yn={};On(Yn,{workspaceID:()=>de,useEffect:()=>Be,use:()=>Qe,make:()=>$e,invalidate:()=>Ie,has:()=>De,get:()=>So,directory:()=>to,context:()=>Ro,bind:()=>Oe});import{EventEmitter as re}from"events";var Un=new re;var Mo=new Set;function si(n){return Mo.add(n),()=>{Mo.delete(n)}}async function xo(n){await Promise.allSettled([...Mo].map((o)=>o(n)))}function Zn(n){return n()}var xi={};On(xi,{setInitialized:()=>se,list:()=>ge,layer:()=>Mi,get:()=>ue,fromRow:()=>_n,defaultLayer:()=>Ko,UpdateInput:()=>fe,Service:()=>xn,Info:()=>Li,Event:()=>Gi});import*as F from"fs/promises";import*as Bi from"os";import*as $n from"path";var te=N.String.pipe(N.brand("ProjectID")),q=te.pipe(bn((n)=>({global:n.make("global"),zod:j.string().pipe(j.custom())})));import*as Dn from"fs/promises";import*as b from"path";import*as Ni from"crypto";async function Co(n){let o=b.resolve(n);while(!0){let t=b.join(o,".git"),s=await Dn.stat(t).catch(()=>null);if(s){if(s.isDirectory())return t;let _=(await Dn.readFile(t,"utf-8")).trim().match(/^gitdir:\s*(.+)$/);if(!_)return null;let A=b.isAbsolute(_[1])?_[1]:b.resolve(o,_[1]);return b.resolve(A,"../..")}let e=b.dirname(o);if(e===o)return null;o=e}}async function pi(n){let o=await Dn.readFile(n,"utf-8").catch(()=>null);if(o===null)return null;return o.trim()||null}async function _i(n){let o=await pi(n);if(o)return o;let t=Ni.randomUUID();try{return await Dn.writeFile(n,t,{flag:"wx"}),t}catch(s){if(s.code!=="EEXIST")throw s;let e=await pi(n);if(e)return e;throw Error(`Project ID file was concurrently created but is empty: ${n}`)}}async function Ti(n){let o=await Co(n);if(o){let s=b.join(o,"qitqode-project-id");return q.make(await _i(s))}let t=b.join(n,".qitqode-project-id");return q.make(await _i(t))}async function ee(n){let o=await Co(n);if(!o)return;let t=$n.join(n,".qitqode-project-id"),s=$n.join(o,"qitqode-project-id"),e=(A)=>F.access(A).then(()=>!0).catch(()=>!1);if(await e(t)){if(!await e(s)){let A=await F.readFile(t,"utf-8");await F.writeFile(s,A)}await F.unlink(t).catch(()=>{})}let l=$n.join(o,"info","exclude");if(await F.mkdir($n.dirname(l),{recursive:!0}),!(await F.readFile(l,"utf-8").catch(()=>"")).includes(".qitqode-project-id"))await F.appendFile(l,`
|
|
2
|
+
import{Tl as no,Ul as Vi,Vl as oo,Wl as ci,Yl as $i,Zl as Qi}from"./chunk-g7vkkmsk.js";import{$l as _r,$m as gt,$n as Xt,Am as Pr,An as lt,Bm as Ur,Bn as At,Cm as Zr,Cn as Ot,Co as Zi,Dm as vr,Dn as dt,Em as Xr,En as Lo,Fm as Yr,Fn as Go,Gm as H,Gn as $t,Hm as zr,Hn as Qt,Im as kr,In as Bt,Jm as Vr,Jn as Dt,Km as cr,Kn as It,Lm as wr,Ln as Lt,Mm as qr,Mn as Gt,Nm as Fr,Nn as Mt,Om as ar,On as xt,Pm as jr,Pn as Ct,Qm as br,Qn as Jt,Rm as hr,Rn as Ht,Sm as nt,Sn as Kt,Tm as ot,Tn as Rt,Um as rt,Un as St,Vm as tt,Vn as Et,Wm as it,Wn as Wt,Xm as et,Xn as Pt,Ym as mt,Yn as Ut,Zm as yt,Zn as Zt,_l as pr,_m as ft,_n as vt,am as En,an as a,ao as Yt,bm as Wn,bn as Q,bo as zt,cm as Nr,cn as fn,co as kt,dm as Tr,dn as yn,do as Vt,em as lr,en as Yo,eo as ct,fn as ut,fo as wt,gm as Ar,gn as X,go as qt,hm as Or,hn as so,ho as Ft,im as dr,in as Pn,io as at,jm as $r,jn as po,jo as jt,km as Qr,kn as _o,ko as bt,lm as Br,ln as No,lo as ht,mm as Dr,mn as To,mo as ni,nm as Ir,nn as lo,no as oi,om as Lr,on as Ao,oo as ri,pm as Gr,pn as Oo,po as ti,qm as Mr,qn as st,qo as ii,rm as xr,rn as $o,ro as ei,sm as Cr,sn as Qo,so as mi,tm as Jr,tn as Bo,to as yi,um as Hr,un as pt,uo as ao,vm as Kr,vn as Do,vo as fi,wm as Rr,wn as _t,wo as gi,xm as Sr,xn as Io,xo as ui,ym as Er,yn as Nt,zm as Wr,zn as Tt}from"./chunk-m8djypsy.js";import{gp as bn,kp as hn}from"./chunk-3z1y040p.js";import{Ap as Yi}from"./chunk-3tdqsm5c.js";import{Bp as Jo}from"./chunk-a5zjrwqy.js";import{Dr as Xn,Er as ro,Fr as Nn,Gr as Hi,Hr as Wi,Jr as Ki}from"./chunk-tk3bve0x.js";import{Kr as Si}from"./chunk-0w4v0fbs.js";import{Qs as eo}from"./chunk-f3kjp838.js";import{Us as Wo,ft as un,pt as dn,qt as nn,zt as V}from"./chunk-zk8n8hnh.js";import{Lt as di,Ot as wo,Pt as c,Tt as go}from"./chunk-1jh5p5qw.js";import{Vt as j}from"./chunk-f89gntcy.js";import{CA as Kn,gA as Tn,oA as Cn}from"./chunk-v2kyarwz.js";import{BJ as Ln,LF as h,ON as N,TE as Eo,ZO as Oi,_E as kn,_N as vo,fF as sn,mI as r,rC as wn,vF as Ai,wD as Qn}from"./chunk-dkm7x8rj.js";import{AP as On}from"./chunk-hh4c02fh.js";var qo={};On(qo,{run:()=>ji});var mn={time_created:a().notNull().$default(()=>Date.now()),time_updated:a().notNull().$onUpdate(()=>Date.now())};var x=yn("project",{id:Q().$type().primaryKey(),worktree:Q().notNull(),vcs:Q(),name:Q(),icon_url:Q(),icon_color:Q(),...mn,time_initialized:a(),sandboxes:Q({mode:"json"}).notNull().$type(),commands:Q({mode:"json"}).$type()});var gn=yn("session",{id:Q().$type().primaryKey(),project_id:Q().$type().notNull().references(()=>x.id,{onDelete:"cascade"}),workspace_id:Q().$type(),parent_id:Q().$type(),context_from:Q().$type(),context_watermark:Q().$type(),slug:Q().notNull(),directory:Q().notNull(),title:Q().notNull(),version:Q().notNull(),share_url:Q(),summary_additions:a(),summary_deletions:a(),summary_files:a(),summary_diffs:Q({mode:"json"}).$type(),revert:Q({mode:"json"}).$type(),permission:Q({mode:"json"}).$type(),...mn,time_compacting:a(),time_archived:a(),last_checkpoint_message_id:Q().$type()},(n)=>[fn("session_project_idx").on(n.project_id),fn("session_workspace_idx").on(n.workspace_id),fn("session_parent_idx").on(n.parent_id),fn("session_context_from_idx").on(n.context_from)]),fo=yn("message",{id:Q().$type().primaryKey(),session_id:Q().$type().notNull().references(()=>gn.id,{onDelete:"cascade"}),agent_id:Q().notNull().default("main"),...mn,data:Q({mode:"json"}).notNull().$type()},(n)=>[fn("message_session_time_created_id_idx").on(n.session_id,n.time_created,n.id),fn("message_session_agent_idx").on(n.session_id,n.agent_id,n.id)]),zo=yn("part",{id:Q().$type().primaryKey(),message_id:Q().$type().notNull().references(()=>fo.id,{onDelete:"cascade"}),session_id:Q().$type().notNull(),...mn,data:Q({mode:"json"}).notNull().$type()},(n)=>[fn("part_message_id_id_idx").on(n.message_id,n.id),fn("part_session_idx").on(n.session_id)]),ko=yn("todo",{session_id:Q().$type().notNull().references(()=>gn.id,{onDelete:"cascade"}),content:Q().notNull(),status:Q().notNull(),position:a().notNull(),...mn},(n)=>[Yo({columns:[n.session_id,n.position]}),fn("todo_session_idx").on(n.session_id)]),Vo=yn("permission",{project_id:Q().primaryKey().references(()=>x.id,{onDelete:"cascade"}),...mn,data:Q({mode:"json"}).notNull().$type()});var co=yn("session_share",{session_id:Q().primaryKey().references(()=>gn.id,{onDelete:"cascade"}),id:Q().notNull(),secret:Q().notNull(),url:Q().notNull(),...mn});import k from"path";var v=V.create({service:"json-migration"});async function ji(n,o){let t=k.join(dn.Path.data,"storage");if(!await go.exists(t))return v.info("storage directory does not exist, skipping migration"),{projects:0,sessions:0,messages:0,parts:0,todos:0,permissions:0,shares:0,errors:[]};v.info("starting json to sqlite migration",{storageDir:t});let s=performance.now();n.run("PRAGMA journal_mode = WAL"),n.run("PRAGMA synchronous = OFF"),n.run("PRAGMA cache_size = 10000"),n.run("PRAGMA temp_store = MEMORY");let e={projects:0,sessions:0,messages:0,parts:0,todos:0,permissions:0,shares:0,errors:[]},l={sessions:0,todos:0,permissions:0,shares:0},_=e.errors,A=1000,C=Date.now();async function S(g){return wo.scan(g,{cwd:t,absolute:!0})}async function K(g,G,J){let B=J-G,T=Array(B);for(let P=0;P<B;P++)T[P]=go.readJson(g[G+P]);let M=await Promise.allSettled(T),Z=Array(B);for(let P=0;P<M.length;P++){let w=M[P];if(w.status==="fulfilled"){Z[P]=w.value;continue}_.push(`failed to read ${g[G+P]}: ${w.reason}`)}return Z}function R(g,G,J){if(g.length===0)return 0;try{return n.insert(G).values(g).onConflictDoNothing().run(),g.length}catch(B){return _.push(`failed to migrate ${J} batch: ${B}`),0}}v.info("scanning files...");let[E,d,D,L,u,p,m]=await Promise.all([S("project/*.json"),S("session/*/*.json"),S("message/*/*.json"),S("part/*/*.json"),S("todo/*.json"),S("permission/*.json"),S("session_share/*.json")]);v.info("file scan complete",{projects:E.length,sessions:d.length,messages:D.length,parts:L.length,todos:u.length,permissions:p.length,shares:m.length});let f=Math.max(1,E.length+d.length+D.length+L.length+u.length+p.length+m.length),i=o?.progress,y=0,$=(g,G)=>{y=Math.min(f,y+G),i?.({current:y,total:f,label:g})};i?.({current:y,total:f,label:"starting"}),n.run("BEGIN TRANSACTION");let I=new Set,O=[];for(let g=0;g<E.length;g+=A){let G=Math.min(g+A,E.length),J=await K(E,g,G);O.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=k.basename(E[g+B],".json");I.add(M),O.push({id:M,worktree:T.worktree??"/",vcs:T.vcs,name:T.name??void 0,icon_url:T.icon?.url,icon_color:T.icon?.color,time_created:T.time?.created??C,time_updated:T.time?.updated??C,time_initialized:T.time?.initialized,sandboxes:T.sandboxes??[],commands:T.commands})}e.projects+=R(O,x,"project"),$("projects",G-g)}v.info("migrated projects",{count:e.projects,duration:Math.round(performance.now()-s)});let U=d.map((g)=>k.basename(k.dirname(g))),z=new Set,en=[];for(let g=0;g<d.length;g+=A){let G=Math.min(g+A,d.length),J=await K(d,g,G);en.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=k.basename(d[g+B],".json"),Z=U[g+B];if(!I.has(Z)){l.sessions++;continue}z.add(M),en.push({id:M,project_id:Z,parent_id:T.parentID??null,slug:T.slug??"",directory:T.directory??"",title:T.title??"",version:T.version??"",share_url:T.share?.url??null,summary_additions:T.summary?.additions??null,summary_deletions:T.summary?.deletions??null,summary_files:T.summary?.files??null,summary_diffs:T.summary?.diffs??null,revert:T.revert??null,permission:T.permission??null,time_created:T.time?.created??C,time_updated:T.time?.updated??C,time_compacting:T.time?.compacting??null,time_archived:T.time?.archived??null})}e.sessions+=R(en,gn,"session"),$("sessions",G-g)}if(v.info("migrated sessions",{count:e.sessions}),l.sessions>0)v.warn("skipped orphaned sessions",{count:l.sessions});let pn=[],W=[],qn=new Map;for(let g of D){let G=k.basename(k.dirname(g));if(!z.has(G))continue;pn.push(g),W.push(G)}for(let g=0;g<pn.length;g+=A){let G=Math.min(g+A,pn.length),J=await K(pn,g,G),B=Array(J.length),T=0;for(let M=0;M<J.length;M++){let Z=J[M];if(!Z)continue;let P=pn[g+M],w=k.basename(P,".json"),Sn=W[g+M];qn.set(w,Sn);let Bn=Z;delete Bn.id,delete Bn.sessionID,B[T++]={id:w,session_id:Sn,time_created:Z.time?.created??C,time_updated:Z.time?.updated??C,data:Bn}}B.length=T,e.messages+=R(B,fo,"message"),$("messages",G-g)}v.info("migrated messages",{count:e.messages});for(let g=0;g<L.length;g+=A){let G=Math.min(g+A,L.length),J=await K(L,g,G),B=Array(J.length),T=0;for(let M=0;M<J.length;M++){let Z=J[M];if(!Z)continue;let P=L[g+M],w=k.basename(P,".json"),Sn=k.basename(k.dirname(P)),Bn=qn.get(Sn);if(!Bn){_.push(`part missing message session: ${P}`);continue}if(!z.has(Bn))continue;let jn=Z;delete jn.id,delete jn.messageID,delete jn.sessionID,B[T++]={id:w,message_id:Sn,session_id:Bn,time_created:Z.time?.created??C,time_updated:Z.time?.updated??C,data:jn}}B.length=T,e.parts+=R(B,zo,"part"),$("parts",G-g)}v.info("migrated parts",{count:e.parts});let An=u.map((g)=>k.basename(g,".json"));for(let g=0;g<u.length;g+=A){let G=Math.min(g+A,u.length),J=await K(u,g,G),B=[];for(let T=0;T<J.length;T++){let M=J[T];if(!M)continue;let Z=An[g+T];if(!z.has(Z)){l.todos++;continue}if(!Array.isArray(M)){_.push(`todo not an array: ${u[g+T]}`);continue}for(let P=0;P<M.length;P++){let w=M[P];if(!w?.content||!w?.status)continue;B.push({session_id:Z,content:w.content,status:w.status,position:P,time_created:C,time_updated:C})}}e.todos+=R(B,ko,"todo"),$("todos",G-g)}if(v.info("migrated todos",{count:e.todos}),l.todos>0)v.warn("skipped orphaned todos",{count:l.todos});let Fn=p.map((g)=>k.basename(g,".json")),Rn=[];for(let g=0;g<p.length;g+=A){let G=Math.min(g+A,p.length),J=await K(p,g,G);Rn.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=Fn[g+B];if(!I.has(M)){l.permissions++;continue}Rn.push({project_id:M,data:T})}e.permissions+=R(Rn,Vo,"permission"),$("permissions",G-g)}if(v.info("migrated permissions",{count:e.permissions}),l.permissions>0)v.warn("skipped orphaned permissions",{count:l.permissions});let an=m.map((g)=>k.basename(g,".json")),Gn=[];for(let g=0;g<m.length;g+=A){let G=Math.min(g+A,m.length),J=await K(m,g,G);Gn.length=0;for(let B=0;B<J.length;B++){let T=J[B];if(!T)continue;let M=an[g+B];if(!z.has(M)){l.shares++;continue}if(!T?.id||!T?.secret||!T?.url){_.push(`session_share missing id/secret/url: ${m[g+B]}`);continue}Gn.push({session_id:M,id:T.id,secret:T.secret,url:T.url})}e.shares+=R(Gn,co,"session_share"),$("shares",G-g)}if(v.info("migrated session shares",{count:e.shares}),l.shares>0)v.warn("skipped orphaned session shares",{count:l.shares});if(n.run("COMMIT"),v.info("json migration complete",{projects:e.projects,sessions:e.sessions,messages:e.messages,parts:e.parts,todos:e.todos,permissions:e.permissions,shares:e.shares,errorCount:e.errors.length,duration:Math.round(performance.now()-s)}),e.errors.length>0)v.warn("migration errors",{errors:e.errors.slice(0,20)});return i?.({current:f,total:f,label:"complete"}),e}var In={};On(In,{use:()=>Je,transaction:()=>Ke,textDecoder:()=>mt,sumDistinct:()=>tr,sum:()=>rr,sql:()=>H,relationsOrderToSQL:()=>ii,relationsFilterToSQL:()=>ti,relationToSQL:()=>mi,relationExtrasToSQL:()=>ei,processRelations:()=>Wt,placeholder:()=>kr,param:()=>Yr,orderSelectedFields:()=>ar,orderByOperators:()=>Vt,or:()=>po,operators:()=>kt,notLike:()=>Nt,notInArray:()=>st,notIlike:()=>lt,notExists:()=>pt,notBetween:()=>_t,not:()=>_o,noopMapper:()=>vr,noopEncoder:()=>Zr,noopDecoder:()=>Ur,ne:()=>so,name:()=>Wr,min:()=>er,max:()=>ir,mapUpdateSet:()=>br,mapResultRow:()=>Fr,mapRelationalRow:()=>wt,mapColumnsInSQLToAlias:()=>Ht,mapColumnsInAliasedSQLToAlias:()=>Jt,lte:()=>Ao,lt:()=>lo,like:()=>Io,l2Distance:()=>mr,l1Distance:()=>yr,jaccardDistance:()=>sr,isWithEnum:()=>ft,isView:()=>wr,isTable:()=>Lr,isSQLWrapper:()=>Kr,isNull:()=>$o,isNotNull:()=>Qo,isDriverValueEncoder:()=>Pr,isConfig:()=>et,is:()=>En,innerProduct:()=>fr,inArray:()=>Oo,ilike:()=>Tt,haveSameKeys:()=>jr,hasOwnEntityKind:()=>_r,hammingDistance:()=>ur,gte:()=>To,gt:()=>No,getViewSelectedFields:()=>ot,getViewName:()=>qr,getTableUniqueName:()=>Mr,getTableName:()=>Gr,getTableLikeName:()=>tt,getTableColumns:()=>nt,getTableAsAliasSQL:()=>yi,getOriginalColumnFromAlias:()=>Kt,getOrderByOperators:()=>ct,getColumns:()=>rt,getColumnTable:()=>Nr,getColumnNameAndConfig:()=>it,getChannelPath:()=>zi,fillPlaceholders:()=>Vr,fieldSelectionToSQL:()=>ri,extractTablesFromSchema:()=>ht,extractExtendedColumnType:()=>Tr,exists:()=>Bo,eq:()=>X,entityKind:()=>pr,effect:()=>He,desc:()=>Go,defineRelationsPart:()=>oi,defineRelations:()=>ni,createRelationsHelper:()=>bt,countDistinct:()=>ho,count:()=>uo,cosineDistance:()=>gr,close:()=>Ce,buildRelationsParts:()=>Ut,buildRelations:()=>Pt,bindIfParam:()=>ut,between:()=>Do,avgDistinct:()=>or,avg:()=>nr,assertUnreachable:()=>yt,asc:()=>Lo,arrayOverlaps:()=>dt,arrayContains:()=>At,arrayContained:()=>Ot,applyMixins:()=>hr,and:()=>Pn,aliasedTableColumn:()=>Ct,aliasedTable:()=>Gt,aliasedRelation:()=>xt,aliasedColumn:()=>Mt,WithSubquery:()=>Cr,ViewSelectionAliasProxyHandler:()=>Bt,ViewBaseConfig:()=>Jr,View:()=>cr,TransactionRollbackError:()=>Et,TableSchema:()=>Ar,TableColumns:()=>Or,TableAliasProxyHandler:()=>Dt,Table:()=>Ir,Subquery:()=>xr,StringChunk:()=>Rr,SQL:()=>Sr,RelationsHelperStatic:()=>jt,RelationsBuilderTable:()=>qt,RelationsBuilderJunctionColumn:()=>at,RelationsBuilderColumn:()=>Ft,RelationTableAliasProxyHandler:()=>Lt,Relation:()=>Zt,QueryPromise:()=>$t,Placeholder:()=>zr,Path:()=>Po,Param:()=>Xr,OriginalName:()=>$r,One:()=>vt,NotFoundError:()=>xe,NoopLogger:()=>ui,Name:()=>Er,Many:()=>Xt,IsAlias:()=>Br,FakePrimitiveParam:()=>Hr,ExtraConfigColumns:()=>dr,ExtraConfigBuilder:()=>Dr,DrizzleQueryError:()=>St,DrizzleError:()=>Rt,DefaultLogger:()=>gi,Count:()=>zt,ConsoleLogWriter:()=>fi,ColumnTableAliasProxyHandler:()=>Qt,ColumnBuilder:()=>lr,ColumnAliasProxyHandler:()=>It,Column:()=>Wn,Client:()=>Jn,CONSTANTS:()=>gt,BaseName:()=>Qr,AggregatedField:()=>Yt});import bi from"crypto";import Fo,{existsSync as hi,readdirSync as ne}from"fs";import{join as oe}from"path";function jo(n){if(Fo.existsSync(`${n.migrationsFolder}/meta/_journal.json`))throw Error('We detected that you have old drizzle-kit migration folders. You must upgrade drizzle-kit and run "drizzle-kit up"');let o=n.migrationsFolder,t=[],s=ne(o).map((e)=>({path:oe(o,e,"migration.sql"),name:e})).filter((e)=>hi(e.path));s.sort((e,l)=>e.name.localeCompare(l.name));for(let e of s){let l=e.path,_=e.name.slice(0,14),A=Fo.readFileSync(l).toString(),C=A.split("--> statement-breakpoint").map((K)=>{return K}),S=ao(_);t.push({sql:C,bps:!0,folderMillis:S,hash:bi.createHash("sha256").update(A).digest("hex"),name:e.name})}return t}function bo(n,o){if(Array.isArray(o)||"migrationsJournal"in o){let s=Array.isArray(o)?o:o.migrationsJournal,e=Array.isArray(o)?void 0:o.migrationsTable,l=s.map((_)=>({sql:_.sql.split("--> statement-breakpoint"),folderMillis:_.timestamp,hash:"",bps:!0,name:_.name}));return n.dialect.migrate(l,n.session,{migrationsTable:e})}let t=jo(o);return n.dialect.migrate(t,n.session,o)}function uo(n){return H`count(${n||H.raw("*")})`.mapWith(Number)}function ho(n){return H`count(distinct ${n})`.mapWith(Number)}function nr(n){return H`avg(${n})`.mapWith(String)}function or(n){return H`avg(distinct ${n})`.mapWith(String)}function rr(n){return H`sum(${n})`.mapWith(String)}function tr(n){return H`sum(distinct ${n})`.mapWith(String)}function ir(n){return H`max(${n})`.mapWith(En(n,Wn)?n:String)}function er(n){return H`min(${n})`.mapWith(En(n,Wn)?n:String)}function Mn(n){return JSON.stringify(n)}function mr(n,o){if(Array.isArray(o))return H`${n} <-> ${Mn(o)}`;return H`${n} <-> ${o}`}function yr(n,o){if(Array.isArray(o))return H`${n} <+> ${Mn(o)}`;return H`${n} <+> ${o}`}function fr(n,o){if(Array.isArray(o))return H`${n} <#> ${Mn(o)}`;return H`${n} <#> ${o}`}function gr(n,o){if(Array.isArray(o))return H`${n} <=> ${Mn(o)}`;return H`${n} <=> ${o}`}function ur(n,o){if(Array.isArray(o))return H`${n} <~> ${Mn(o)}`;return H`${n} <~> ${o}`}function sr(n,o){if(Array.isArray(o))return H`${n} <%> ${Mn(o)}`;return H`${n} <%> ${o}`}import io from"path";var Yn={};On(Yn,{workspaceID:()=>de,useEffect:()=>Be,use:()=>Qe,make:()=>$e,invalidate:()=>Ie,has:()=>De,get:()=>So,directory:()=>to,context:()=>Ro,bind:()=>Oe});import{EventEmitter as re}from"events";var Un=new re;var Mo=new Set;function si(n){return Mo.add(n),()=>{Mo.delete(n)}}async function xo(n){await Promise.allSettled([...Mo].map((o)=>o(n)))}function Zn(n){return n()}var xi={};On(xi,{setInitialized:()=>se,list:()=>ge,layer:()=>Mi,get:()=>ue,fromRow:()=>_n,defaultLayer:()=>Ko,UpdateInput:()=>fe,Service:()=>xn,Info:()=>Li,Event:()=>Gi});import*as F from"fs/promises";import*as Bi from"os";import*as $n from"path";var te=N.String.pipe(N.brand("ProjectID")),q=te.pipe(bn((n)=>({global:n.make("global"),zod:j.string().pipe(j.custom())})));import*as Dn from"fs/promises";import*as b from"path";import*as Ni from"crypto";async function Co(n){let o=b.resolve(n);while(!0){let t=b.join(o,".git"),s=await Dn.stat(t).catch(()=>null);if(s){if(s.isDirectory())return t;let _=(await Dn.readFile(t,"utf-8")).trim().match(/^gitdir:\s*(.+)$/);if(!_)return null;let A=b.isAbsolute(_[1])?_[1]:b.resolve(o,_[1]);return b.resolve(A,"../..")}let e=b.dirname(o);if(e===o)return null;o=e}}async function pi(n){let o=await Dn.readFile(n,"utf-8").catch(()=>null);if(o===null)return null;return o.trim()||null}async function _i(n){let o=await pi(n);if(o)return o;let t=Ni.randomUUID();try{return await Dn.writeFile(n,t,{flag:"wx"}),t}catch(s){if(s.code!=="EEXIST")throw s;let e=await pi(n);if(e)return e;throw Error(`Project ID file was concurrently created but is empty: ${n}`)}}async function Ti(n){let o=await Co(n);if(o){let s=b.join(o,"qitqode-project-id");return q.make(await _i(s))}let t=b.join(n,".qitqode-project-id");return q.make(await _i(t))}async function ee(n){let o=await Co(n);if(!o)return;let t=$n.join(n,".qitqode-project-id"),s=$n.join(o,"qitqode-project-id"),e=(A)=>F.access(A).then(()=>!0).catch(()=>!1);if(await e(t)){if(!await e(s)){let A=await F.readFile(t,"utf-8");await F.writeFile(s,A)}await F.unlink(t).catch(()=>{})}let l=$n.join(o,"info","exclude");if(await F.mkdir($n.dirname(l),{recursive:!0}),!(await F.readFile(l,"utf-8").catch(()=>"")).includes(".qitqode-project-id"))await F.appendFile(l,`
|
|
3
3
|
.qitqode-project-id
|
|
4
4
|
`)}var li=V.create({service:"project"}),me=262144,Ho=N.Literal("git"),Di=N.Struct({url:N.optional(N.String),override:N.optional(N.String),color:N.optional(N.String)}),Ii=N.Struct({start:N.optional(N.String.annotate({description:"Startup script to run when creating a new workspace (worktree)"}))}),ye=N.Struct({created:N.Number,updated:N.Number,initialized:N.optional(N.Number)}),Li=N.Struct({id:q,worktree:N.String,vcs:N.optional(Ho),name:N.optional(N.String),icon:N.optional(Di),commands:N.optional(Ii),time:ye,sandboxes:N.Array(N.String)}).annotate({identifier:"Project"}).pipe(bn((n)=>({zod:hn(n)}))),Gi={Updated:Qi.define("project.updated",Li.zod)};function _n(n){let o=n.icon_url||n.icon_color?{url:n.icon_url??void 0,color:n.icon_color??void 0}:void 0;return{id:n.id,worktree:n.worktree,vcs:n.vcs?N.decodeUnknownSync(Ho)(n.vcs):void 0,name:n.name??void 0,icon:o,time:{created:n.time_created,updated:n.time_updated,initialized:n.time_initialized??void 0},sandboxes:n.sandboxes,commands:n.commands??void 0}}var fe=j.object({projectID:q.zod,name:j.string().optional(),icon:hn(Di).optional(),commands:hn(Ii).optional()});class xn extends Qn.Service()("@qitqode/Project"){}var Mi=h.effect(xn,r.gen(function*(){let n=yield*c.Service,o=yield*Oi.Path,t=yield*no.ChildProcessSpawner,s=r.fnUntraced(function*(i,y){return yield*$i(t,i,y)},r.catch(()=>r.succeed({code:1,text:"",stderr:""}))),e=(i)=>r.sync(()=>In.use(i)),l=(i)=>r.sync(()=>Un.emit("event",{directory:"global",project:i.id,payload:{type:Gi.Updated.type,properties:i}})),_=N.decodeUnknownSync(N.optional(Ho))(nn.QITQODE_FAKE_VCS),A=(i,y)=>{if(!y)return i;if(y=y.replace(/[\r\n]+$/,""),!y)return i;if(y=c.windowsPath(y),o.isAbsolute(y))return o.normalize(y);return o.resolve(i,y)},C=yield*Ai.Scope,S=r.fn("Project.fromDirectory")(function*(i){li.info("fromDirectory",{directory:i});let y=yield*r.gen(function*(){if(nn.QITQODE_DISABLE_GIT)return{id:q.global,worktree:i,sandbox:i,vcs:_};let z=(yield*n.up({targets:[".git"],start:i}).pipe(r.orDie))[0];if(!z)return{id:q.global,worktree:"/",sandbox:"/",vcs:_};let en=o.dirname(z),pn=process.env.HOME??process.env.USERPROFILE??Bi.homedir();if(en===pn||$n.parse(en).root===en)return li.warn("ignoring .git at home or filesystem root, snapshots disabled",{dotgit:z}),{id:q.global,worktree:i,sandbox:i,vcs:_};let W=en,qn=yield*r.sync(()=>Jo("git")),An;if(!qn)return{id:An??q.global,worktree:W,sandbox:W,vcs:_};let Fn=yield*s(["rev-parse","--git-common-dir"],{cwd:W});if(Fn.code!==0)return{id:An??q.global,worktree:W,sandbox:W,vcs:_};let Rn=(()=>{let Gn=A(W,Fn.text.trim());return Gn===W?W:o.dirname(Gn)})();if(An==null)yield*r.promise(()=>ee(W)),An=yield*r.promise(()=>Ti(W));let an=yield*s(["rev-parse","--show-toplevel"],{cwd:W});if(an.code!==0)return{id:An,worktree:W,sandbox:W,vcs:_};return W=A(W,an.text.trim()),{id:An,sandbox:W,worktree:Rn,vcs:"git"}}),$=yield*e((U)=>U.select().from(x).where(X(x.id,y.id)).get()),I=$?_n($):{id:y.id,worktree:y.worktree,vcs:y.vcs,sandboxes:[],time:{created:Date.now(),updated:Date.now()}};if(nn.QITQODE_EXPERIMENTAL_ICON_DISCOVERY)yield*K(I).pipe(r.ignore,r.forkIn(C));let O={...I,worktree:y.worktree,vcs:y.vcs,time:{...I.time,updated:Date.now()}};if(y.sandbox!==O.worktree&&!O.sandboxes.includes(y.sandbox))O.sandboxes.push(y.sandbox);if(O.sandboxes=yield*r.forEach(O.sandboxes,(U)=>n.exists(U).pipe(r.orDie,r.map((z)=>z?U:void 0)),{concurrency:16}).pipe(r.map((U)=>U.filter((z)=>z!==void 0))),yield*e((U)=>U.insert(x).values({id:O.id,worktree:O.worktree,vcs:O.vcs??null,name:O.name,icon_url:O.icon?.url,icon_color:O.icon?.color,time_created:O.time.created,time_updated:O.time.updated,time_initialized:O.time.initialized,sandboxes:O.sandboxes,commands:O.commands}).onConflictDoUpdate({target:x.id,set:{worktree:O.worktree,vcs:O.vcs??null,name:O.name,icon_url:O.icon?.url,icon_color:O.icon?.color,time_updated:O.time.updated,time_initialized:O.time.initialized,sandboxes:O.sandboxes,commands:O.commands}}).run()),y.id!==q.global)yield*e((U)=>U.update(gn).set({project_id:y.id}).where(Pn(X(gn.project_id,q.global),X(gn.directory,y.worktree))).run());return yield*l(O),{project:O,sandbox:y.sandbox}}),K=r.fn("Project.discover")(function*(i){if(i.vcs!=="git")return;if(i.icon?.override)return;if(i.icon?.url)return;let $=(yield*n.glob("**/favicon.{ico,png,svg,jpg,jpeg,webp}",{cwd:i.worktree,absolute:!0,include:"file"}).pipe(r.orDie)).sort((pn,W)=>pn.length-W.length)[0];if(!$)return;let I=yield*n.stat($).pipe(r.orDie);if(Number(I.size)>me)return;let O=yield*n.readFile($).pipe(r.orDie),U=Buffer.from(O).toString("base64"),en=`data:${c.mimeType($)};base64,${U}`;yield*d({projectID:i.id,icon:{url:en}})}),R=r.fn("Project.list")(function*(){return yield*e((i)=>i.select().from(x).all().map(_n))}),E=r.fn("Project.get")(function*(i){let y=yield*e(($)=>$.select().from(x).where(X(x.id,i)).get());return y?_n(y):void 0}),d=r.fn("Project.update")(function*(i){let y=yield*e((I)=>I.update(x).set({name:i.name,icon_url:i.icon?.url,icon_color:i.icon?.color,commands:i.commands,time_updated:Date.now()}).where(X(x.id,i.projectID)).returning().get());if(!y)throw Error(`Project not found: ${i.projectID}`);let $=_n(y);return yield*l($),$}),D=r.fn("Project.initGit")(function*(i){if(i.project.vcs==="git")return i.project;if(!(yield*r.sync(()=>Jo("git"))))throw Error("Git is not installed");let y=yield*s(["init","--quiet"],{cwd:i.directory});if(y.code!==0)throw Error(y.stderr.trim()||y.text.trim()||"Failed to initialize git repository");let{project:$}=yield*S(i.directory);return $}),L=r.fn("Project.setInitialized")(function*(i){yield*e((y)=>y.update(x).set({time_initialized:Date.now()}).where(X(x.id,i)).run())}),u=r.fn("Project.sandboxes")(function*(i){let y=yield*e((I)=>I.select().from(x).where(X(x.id,i)).get());if(!y)return[];let $=_n(y);return yield*r.forEach($.sandboxes,(I)=>n.isDir(I).pipe(r.orDie,r.map((O)=>O?I:void 0)),{concurrency:16}).pipe(r.map((I)=>I.filter((O)=>O!==void 0)))}),p=r.fnUntraced(function*(i,y){let $=yield*e((I)=>I.update(x).set({sandboxes:y,time_updated:Date.now()}).where(X(x.id,i)).returning().get());if(!$)throw Error(`Project not found: ${i}`);yield*l(_n($))}),m=r.fn("Project.addSandbox")(function*(i,y){let $=yield*e((O)=>O.select().from(x).where(X(x.id,i)).get());if(!$)throw Error(`Project not found: ${i}`);let I=[...$.sandboxes];if(!I.includes(y))I.push(y);yield*p(i,I)}),f=r.fn("Project.removeSandbox")(function*(i,y){let $=yield*e((O)=>O.select().from(x).where(X(x.id,i)).get());if(!$)throw Error(`Project not found: ${i}`);let I=$.sandboxes.filter((O)=>O!==y);yield*p(i,I)});return xn.of({fromDirectory:S,discover:K,list:R,get:E,update:d,initGit:D,setInitialized:L,sandboxes:u,addSandbox:m,removeSandbox:f})})),Ko=Mi.pipe(h.provide(oo),h.provide(c.defaultLayer),h.provide(di.layer));function ge(){return In.use((n)=>n.select().from(x).all().map((o)=>_n(o)))}function ue(n){let o=In.use((t)=>t.select().from(x).where(X(x.id,n)).get());if(!o)return;return _n(o)}function se(n){In.use((o)=>o.update(x).set({time_initialized:Date.now()}).where(X(x.id,n)).run())}import{parse as pe}from"path";var rn=un.create("instance");Hi(()=>rn.use());var tn=new Map,_e=Ki(xn,Ko),Ne=new Set(["/etc","/proc","/sys","/dev","/boot","/root","/var","/private/etc","/private/var"]);function Te(n){if(n===pe(n).root)return"filesystem root is not a valid project directory";for(let o of Ne)if(n===o||c.contains(o,n))return"target is a protected system directory";return null}function le(n){let o=Te(n);if(o)throw Error("Access denied: "+o)}var vn={all:void 0};function Ci(n){return Zn(async()=>{let o=n.project&&n.worktree?{directory:n.directory,worktree:n.worktree,project:n.project}:await _e.runPromise((t)=>t.fromDirectory(n.directory)).then(({project:t,sandbox:s})=>({directory:n.directory,worktree:s,project:t}));return await rn.provide(o,async()=>{await n.init?.()}),o})}function Ji(n,o){let t=o.catch((s)=>{if(tn.get(n)===t)tn.delete(n);throw s});return tn.set(n,t),t}var on={async provide(n){let o=c.resolve(n.directory);le(o);let t=tn.get(o);if(!t)V.Default.info("creating instance",{directory:o}),t=Ji(o,Ci({directory:o,init:n.init}));let s=await t;return rn.provide(s,async()=>{return n.fn()})},get current(){return rn.use()},get directory(){return rn.use().directory},get worktree(){return rn.use().worktree},get project(){return rn.use().project},containsPath(n,o){let t=o??on;if(c.contains(t.directory,n))return!0;if(t.worktree==="/")return!1;return c.contains(t.worktree,n)},bind(n){let o=rn.use();return(...t)=>rn.provide(o,()=>n(...t))},restore(n,o){return rn.provide(n,o)},async reload(n){let o=c.resolve(n.directory);V.Default.info("reloading instance",{directory:o}),await xo(o),tn.delete(o);let t=Ji(o,Ci({...n,directory:o}));return Un.emit("event",{directory:o,project:n.project?.id,workspace:Nn.workspaceID,payload:{type:"server.instance.disposed",properties:{directory:o}}}),await t},async dispose(){let{directory:n,project:o}=on;V.Default.info("disposing instance",{directory:n}),await xo(n),tn.delete(n),Un.emit("event",{directory:n,project:o.id,workspace:Nn.workspaceID,payload:{type:"server.instance.disposed",properties:{directory:n}}})},async disposeAll(){if(vn.all)return vn.all;return vn.all=Zn(async()=>{V.Default.info("disposing all instances");let n=[...tn.entries()];for(let[o,t]of n){if(tn.get(o)!==t)continue;let s=await t.catch((e)=>{V.Default.warn("instance dispose failed",{key:o,error:e});return});if(!s){if(tn.get(o)===t)tn.delete(o);continue}if(tn.get(o)!==t)continue;await rn.provide(s,async()=>{await on.dispose()})}}).finally(()=>{vn.all=void 0}),vn.all}};var Ri="~qitqode/InstanceState",Oe=(n)=>{try{return on.bind(n)}catch(s){if(!(s instanceof un.NotFound))throw s}let o=Ln.getCurrent(),t=o?Qn.getReferenceUnsafe(o.context,Xn):void 0;if(!t)return n;return(...s)=>on.restore(t,()=>n(...s))},Ro=r.gen(function*(){return(yield*Xn)??on.current}),de=r.gen(function*(){return(yield*ro)??Nn.workspaceID}),to=r.map(Ro,(n)=>n.directory),$e=(n)=>r.gen(function*(){let o=yield*Cn.make({capacity:Number.POSITIVE_INFINITY,lookup:()=>r.gen(function*(){return yield*n(yield*Ro)})}),t=si((s)=>r.runPromise(Cn.invalidate(o,s).pipe(r.provide(Si))));return yield*r.addFinalizer(()=>r.sync(t)),{[Ri]:Ri,cache:o}}),So=(n)=>r.gen(function*(){return yield*Cn.get(n.cache,yield*to)}),Qe=(n,o)=>r.map(So(n),o),Be=(n,o)=>r.flatMap(So(n),o),De=(n)=>r.gen(function*(){return yield*Cn.has(n.cache,yield*to)}),Ie=(n)=>r.gen(function*(){return yield*Cn.invalidate(n.cache,yield*to)});var Pi={};On(Pi,{make:()=>Le});function Ei(n,o,t){if(n&&o!==void 0)return Nn.restore(o,()=>on.restore(n,t));if(n)return on.restore(n,t);if(o!==void 0)return Nn.restore(o,t);return t()}function Le(){return r.gen(function*(){let n=yield*r.context(),t=(yield*Xn)??(()=>{try{return on.current}catch(_){if(!(_ instanceof un.NotFound))throw _}})(),s=(yield*ro)??Nn.workspaceID,e=(_)=>Wi(_,{instance:t,workspace:s}),l=(_)=>e(_).pipe(r.provide(n));return{promise:(_)=>Ei(t,s,()=>r.runPromise(l(_))),fork:(_)=>Ei(t,s,()=>r.runFork(l(_)))}})}var Ui={};On(Ui,{make:()=>Ge,Cancelled:()=>zn});class zn extends N.TaggedErrorClass()("RunnerCancelled",{}){}var Ge=(n,o)=>{let t=Tn.makeUnsafe({_tag:"Idle"}),s=o?.onIdle??r.void,e=o?.onBusy??r.void,l=o?.onInterrupt,_=0,A=()=>Tn.getUnsafe(t),C=()=>{return _+=1,_},S=(m,f)=>kn.isFailure(f)&&Eo.hasInterruptsOnly(f.cause)?sn.fail(m,new zn).pipe(r.asVoid):sn.done(m,f).pipe(r.asVoid),K=()=>Tn.modify(t,(m)=>[m._tag==="Idle"?s:r.void,m]).pipe(r.flatten),R=(m,f,i)=>Tn.modify(t,(y)=>[r.gen(function*(){if(y._tag==="Running"&&y.run.id===m)yield*s;yield*S(f,i)}),y._tag==="Running"&&y.run.id===m?{_tag:"Idle"}:y]).pipe(r.flatten),E=(m,f)=>r.gen(function*(){let i=C(),y=yield*m.pipe(r.onExit(($)=>R(i,f,$)),r.forkIn(n));return{id:i,done:f,fiber:y}}),d=(m)=>Tn.modifyEffect(t,r.fnUntraced(function*(f){if(f._tag==="Shell"&&f.shell.id===m)return[s,{_tag:"Idle"}];if(f._tag==="ShellThenRun"&&f.shell.id===m){let i=yield*E(f.run.work,f.run.done);return[r.void,{_tag:"Running",run:i}]}return[r.void,f]})).pipe(r.flatten),D=(m)=>Ln.interrupt(m.fiber),L=(m)=>Tn.modifyEffect(t,r.fnUntraced(function*(f){switch(f._tag){case"Running":case"ShellThenRun":if(o?.onReentryWarn)yield*o.onReentryWarn({label:o.label??"(unlabeled)",existingRunId:f.run.id});return[sn.await(f.run.done),f];case"Shell":{let i={id:C(),done:yield*sn.make(),work:m};return[sn.await(i.done),{_tag:"ShellThenRun",shell:f.shell,run:i}]}case"Idle":{let i=yield*sn.make(),y=yield*E(m,i);return[sn.await(i),{_tag:"Running",run:y}]}}})).pipe(r.flatten,r.catch((f)=>f instanceof zn?l??r.die(f):r.fail(f))),u=(m)=>Tn.modifyEffect(t,r.fnUntraced(function*(f){if(f._tag!=="Idle")return[r.sync(()=>{if(o?.busy)o.busy();throw Error("Runner is busy")}),f];yield*e;let i=C(),y=yield*m.pipe(r.ensuring(d(i)),r.forkChild),$={id:i,fiber:y};return[r.gen(function*(){let I=yield*Ln.await(y);if(kn.isSuccess(I))return I.value;if(Eo.hasInterruptsOnly(I.cause)&&l)return yield*l;return yield*r.failCause(I.cause)}),{_tag:"Shell",shell:$}]})).pipe(r.flatten),p=Tn.modify(t,(m)=>{switch(m._tag){case"Idle":return[r.void,m];case"Running":return[r.gen(function*(){yield*Ln.interrupt(m.run.fiber);let f=yield*Ln.await(m.run.fiber);yield*S(m.run.done,f),yield*sn.await(m.run.done).pipe(r.exit,r.asVoid),yield*K()}),{_tag:"Idle"}];case"Shell":return[r.gen(function*(){yield*D(m.shell),yield*K()}),{_tag:"Idle"}];case"ShellThenRun":return[r.gen(function*(){yield*sn.fail(m.run.done,new zn).pipe(r.asVoid),yield*D(m.shell),yield*K()}),{_tag:"Idle"}]}}).pipe(r.flatten);return{get state(){return A()},get busy(){return A()._tag!=="Idle"},ensureRunning:L,startShell:u,cancel:p}};import{Database as Me}from"bun:sqlite";function vi(n){let o=new Me(n,{create:!0});return Zi({client:o})}var xe=eo.create("NotFoundError",j.object({message:j.string()})),Xi=V.create({service:"db"});function zi(){if(["latest","beta","prod"].includes(Wo)||nn.QITQODE_DISABLE_CHANNEL_DB)return io.join(dn.Path.data,"qitqode.db");let n=Wo.replace(/[^a-zA-Z0-9._-]/g,"-");return io.join(dn.Path.data,`qitqode-${n}.db`)}var Po=Zn(()=>{if(nn.QITQODE_DB){if(nn.QITQODE_DB===":memory:"||io.isAbsolute(nn.QITQODE_DB))return nn.QITQODE_DB;return io.join(dn.Path.data,nn.QITQODE_DB)}return zi()}),Jn=Yi(()=>{Xi.info("opening database",{path:Po});let n=vi(Po);n.run("PRAGMA journal_mode = WAL"),n.run("PRAGMA synchronous = NORMAL"),n.run("PRAGMA busy_timeout = 5000"),n.run("PRAGMA cache_size = -64000"),n.run("PRAGMA foreign_keys = ON"),n.run("PRAGMA wal_checkpoint(PASSIVE)");let o=[{sql:"CREATE TABLE `project` (\n\t`id` text PRIMARY KEY,\n\t`worktree` text NOT NULL,\n\t`vcs` text,\n\t`name` text,\n\t`icon_url` text,\n\t`icon_color` text,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`time_initialized` integer,\n\t`sandboxes` text NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `message` (\n\t`id` text PRIMARY KEY,\n\t`session_id` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_message_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `part` (\n\t`id` text PRIMARY KEY,\n\t`message_id` text NOT NULL,\n\t`session_id` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_part_message_id_message_id_fk` FOREIGN KEY (`message_id`) REFERENCES `message`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `permission` (\n\t`project_id` text PRIMARY KEY,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_permission_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `session` (\n\t`id` text PRIMARY KEY,\n\t`project_id` text NOT NULL,\n\t`parent_id` text,\n\t`slug` text NOT NULL,\n\t`directory` text NOT NULL,\n\t`title` text NOT NULL,\n\t`version` text NOT NULL,\n\t`share_url` text,\n\t`summary_additions` integer,\n\t`summary_deletions` integer,\n\t`summary_files` integer,\n\t`summary_diffs` text,\n\t`revert` text,\n\t`permission` text,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`time_compacting` integer,\n\t`time_archived` integer,\n\tCONSTRAINT `fk_session_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `todo` (\n\t`session_id` text NOT NULL,\n\t`content` text NOT NULL,\n\t`status` text NOT NULL,\n\t`priority` text NOT NULL,\n\t`position` integer NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\tCONSTRAINT `todo_pk` PRIMARY KEY(`session_id`, `position`),\n\tCONSTRAINT `fk_todo_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `session_share` (\n\t`session_id` text PRIMARY KEY,\n\t`id` text NOT NULL,\n\t`secret` text NOT NULL,\n\t`url` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\tCONSTRAINT `fk_session_share_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE INDEX `message_session_idx` ON `message` (`session_id`);--> statement-breakpoint\nCREATE INDEX `part_message_idx` ON `part` (`message_id`);--> statement-breakpoint\nCREATE INDEX `part_session_idx` ON `part` (`session_id`);--> statement-breakpoint\nCREATE INDEX `session_project_idx` ON `session` (`project_id`);--> statement-breakpoint\nCREATE INDEX `session_parent_idx` ON `session` (`parent_id`);--> statement-breakpoint\nCREATE INDEX `todo_session_idx` ON `todo` (`session_id`);",timestamp:1769552633000,name:"20260127222353_familiar_lady_ursula"},{sql:"ALTER TABLE `project` ADD `commands` text;",timestamp:1770830228000,name:"20260211171708_add_project_commands"},{sql:"CREATE TABLE `control_account` (\n\t`email` text NOT NULL,\n\t`url` text NOT NULL,\n\t`access_token` text NOT NULL,\n\t`refresh_token` text NOT NULL,\n\t`token_expiry` integer,\n\t`active` integer NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\tCONSTRAINT `control_account_pk` PRIMARY KEY(`email`, `url`)\n);\n",timestamp:1770993676000,name:"20260213144116_wakeful_the_professor"},{sql:"CREATE TABLE `workspace` (\n\t`id` text PRIMARY KEY,\n\t`branch` text,\n\t`project_id` text NOT NULL,\n\t`config` text NOT NULL,\n\tCONSTRAINT `fk_workspace_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n",timestamp:1772056728000,name:"20260225215848_workspace"},{sql:"ALTER TABLE `session` ADD `workspace_id` text;--> statement-breakpoint\nCREATE INDEX `session_workspace_idx` ON `session` (`workspace_id`);",timestamp:1772228279000,name:"20260227213759_add_session_workspace_id"},{sql:"CREATE TABLE `account` (\n\t`id` text PRIMARY KEY,\n\t`email` text NOT NULL,\n\t`url` text NOT NULL,\n\t`access_token` text NOT NULL,\n\t`refresh_token` text NOT NULL,\n\t`token_expiry` integer,\n\t`selected_org_id` text,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `account_state` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`active_account_id` text,\n\tFOREIGN KEY (`active_account_id`) REFERENCES `account`(`id`) ON UPDATE no action ON DELETE set null\n);\n",timestamp:1772310750000,name:"20260228203230_blue_harpoon"},{sql:"ALTER TABLE `workspace` ADD `type` text NOT NULL;--> statement-breakpoint\nALTER TABLE `workspace` ADD `name` text;--> statement-breakpoint\nALTER TABLE `workspace` ADD `directory` text;--> statement-breakpoint\nALTER TABLE `workspace` ADD `extra` text;--> statement-breakpoint\nALTER TABLE `workspace` DROP COLUMN `config`;",timestamp:1772579546000,name:"20260303231226_add_workspace_fields"},{sql:"ALTER TABLE `account_state` ADD `active_org_id` text;--> statement-breakpoint\nUPDATE `account_state` SET `active_org_id` = (SELECT `selected_org_id` FROM `account` WHERE `account`.`id` = `account_state`.`active_account_id`);--> statement-breakpoint\nALTER TABLE `account` DROP COLUMN `selected_org_id`;\n",timestamp:1773097200000,name:"20260309230000_move_org_to_state"},{sql:"DROP INDEX IF EXISTS `message_session_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `part_message_idx`;--> statement-breakpoint\nCREATE INDEX `message_session_time_created_id_idx` ON `message` (`session_id`,`time_created`,`id`);--> statement-breakpoint\nCREATE INDEX `part_message_id_id_idx` ON `part` (`message_id`,`id`);",timestamp:1773290071000,name:"20260312043431_session_message_cursor"},{sql:"CREATE TABLE `event_sequence` (\n\t`aggregate_id` text PRIMARY KEY,\n\t`seq` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `event` (\n\t`id` text PRIMARY KEY,\n\t`aggregate_id` text NOT NULL,\n\t`seq` integer NOT NULL,\n\t`type` text NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_event_aggregate_id_event_sequence_aggregate_id_fk` FOREIGN KEY (`aggregate_id`) REFERENCES `event_sequence`(`aggregate_id`) ON DELETE CASCADE\n);\n",timestamp:1774309702000,name:"20260323234822_events"},{sql:"PRAGMA foreign_keys=OFF;--> statement-breakpoint\nCREATE TABLE `__new_workspace` (\n\t`id` text PRIMARY KEY,\n\t`type` text NOT NULL,\n\t`name` text DEFAULT '' NOT NULL,\n\t`branch` text,\n\t`directory` text,\n\t`extra` text,\n\t`project_id` text NOT NULL,\n\tCONSTRAINT `fk_workspace_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nINSERT INTO `__new_workspace`(`id`, `type`, `branch`, `name`, `directory`, `extra`, `project_id`) SELECT `id`, `type`, `branch`, `name`, `directory`, `extra`, `project_id` FROM `workspace`;--> statement-breakpoint\nDROP TABLE `workspace`;--> statement-breakpoint\nALTER TABLE `__new_workspace` RENAME TO `workspace`;--> statement-breakpoint\nPRAGMA foreign_keys=ON;",timestamp:1775843113000,name:"20260410174513_workspace-name"},{sql:"CREATE TABLE `session_entry` (\n\t`id` text PRIMARY KEY,\n\t`session_id` text NOT NULL,\n\t`type` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_session_entry_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE INDEX `session_entry_session_idx` ON `session_entry` (`session_id`);--> statement-breakpoint\nCREATE INDEX `session_entry_session_type_idx` ON `session_entry` (`session_id`,`type`);--> statement-breakpoint\nCREATE INDEX `session_entry_time_created_idx` ON `session_entry` (`time_created`);",timestamp:1776103196000,name:"20260413175956_chief_energizer"},{sql:"ALTER TABLE `session` ADD `context_from` text;--> statement-breakpoint\nALTER TABLE `session` ADD `context_watermark` text;--> statement-breakpoint\nCREATE INDEX `session_context_from_idx` ON `session` (`context_from`);\n",timestamp:1776873600000,name:"20260422160000_context_inheritance"},{sql:"CREATE TABLE `task_registry` (\n `id` text PRIMARY KEY,\n `parent_session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `status` text NOT NULL,\n `agent` text NOT NULL,\n `description` text NOT NULL,\n `context_mode` text NOT NULL,\n `background` integer NOT NULL,\n `last_turn_time` integer NOT NULL,\n `turn_count` integer NOT NULL DEFAULT 0,\n `error` text,\n `time_completed` integer,\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `task_registry_parent_idx` ON `task_registry` (`parent_session_id`);--> statement-breakpoint\nCREATE INDEX `task_registry_status_idx` ON `task_registry` (`status`);--> statement-breakpoint\nCREATE INDEX `task_registry_status_last_turn_idx` ON `task_registry` (`status`, `last_turn_time`);\n",timestamp:1776877200000,name:"20260422170000_task_registry"},{sql:"DROP INDEX IF EXISTS `session_entry_session_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `session_entry_session_type_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `session_entry_time_created_idx`;--> statement-breakpoint\nDROP TABLE IF EXISTS `session_entry`;\n",timestamp:1776956061000,name:"20260423145421_remove_session_entry"},{sql:"DROP INDEX IF EXISTS `task_registry_parent_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `task_registry_status_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `task_registry_status_last_turn_idx`;--> statement-breakpoint\nALTER TABLE `task_registry` RENAME TO `actor_registry`;--> statement-breakpoint\nCREATE INDEX `actor_registry_parent_idx` ON `actor_registry` (`parent_session_id`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_idx` ON `actor_registry` (`status`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_last_turn_idx` ON `actor_registry` (`status`, `last_turn_time`);\n",timestamp:1778803200000,name:"20260515000000_actor_rename"},{sql:"CREATE TABLE `memory_fts` (\n `path` text PRIMARY KEY NOT NULL,\n `scope` text NOT NULL,\n `scope_id` text DEFAULT '' NOT NULL,\n `type` text NOT NULL,\n `body` text NOT NULL,\n `fingerprint` text NOT NULL,\n `last_indexed_at` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE INDEX `memory_fts_scope_idx` ON `memory_fts` (`scope`, `scope_id`);\n--> statement-breakpoint\nCREATE INDEX `memory_fts_type_idx` ON `memory_fts` (`type`);\n--> statement-breakpoint\nCREATE VIRTUAL TABLE `memory_fts_idx` USING fts5(\n body,\n content='memory_fts',\n content_rowid='rowid',\n tokenize='unicode61 remove_diacritics 1'\n);\n--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ai` AFTER INSERT ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;\n--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ad` AFTER DELETE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.rowid;\nEND;\n--> statement-breakpoint\nCREATE TRIGGER `memory_fts_au` AFTER UPDATE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.rowid;\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;\n",timestamp:1778806800000,name:"20260515010000_memory_fts"},{sql:"CREATE TABLE `task` (\n `id` text NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `parent_task_id` text,\n `kind` text NOT NULL DEFAULT 'user',\n `status` text NOT NULL,\n `focus` integer NOT NULL DEFAULT 0,\n `summary` text NOT NULL,\n `created_at` integer NOT NULL,\n `last_event_at` integer NOT NULL,\n `ended_at` integer,\n `cleanup_after` integer,\n PRIMARY KEY (`session_id`, `id`)\n);--> statement-breakpoint\nCREATE INDEX `task_session_idx` ON `task` (`session_id`);--> statement-breakpoint\nCREATE INDEX `task_parent_idx` ON `task` (`session_id`, `parent_task_id`);--> statement-breakpoint\nCREATE INDEX `task_status_idx` ON `task` (`status`);--> statement-breakpoint\nCREATE INDEX `task_kind_idx` ON `task` (`kind`);--> statement-breakpoint\nCREATE UNIQUE INDEX `task_focus_per_session_idx` ON `task` (`session_id`) WHERE focus = 1;--> statement-breakpoint\nCREATE TABLE `task_event` (\n `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `task_id` text NOT NULL,\n `at` integer NOT NULL,\n `kind` text NOT NULL,\n `summary` text,\n FOREIGN KEY (`session_id`, `task_id`) REFERENCES `task`(`session_id`, `id`) ON DELETE CASCADE\n);--> statement-breakpoint\nCREATE INDEX `task_event_task_idx` ON `task_event` (`session_id`, `task_id`, `at`);\n",timestamp:1778810400000,name:"20260515020000_user_task"},{sql:"ALTER TABLE `session` ADD `last_checkpoint_message_id` text;\n",timestamp:1779148800000,name:"20260519000000_last_checkpoint_message_id"},{sql:"ALTER TABLE `message` ADD `agent_id` text;--> statement-breakpoint\nCREATE INDEX `message_session_agent_idx` ON `message` (`session_id`,`agent_id`,`id`);\n",timestamp:1779321600000,name:"20260521000000_message_agent_id"},{sql:"DROP TABLE `actor_registry`;--> statement-breakpoint\nCREATE TABLE `actor_registry` (\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `actor_id` text NOT NULL,\n `mode` text NOT NULL,\n `parent_actor_id` text,\n `status` text NOT NULL,\n `agent` text NOT NULL,\n `description` text NOT NULL,\n `context_mode` text NOT NULL,\n `context_watermark` text,\n `background` integer NOT NULL,\n `tools` text,\n `last_turn_time` integer NOT NULL,\n `turn_count` integer NOT NULL DEFAULT 0,\n `error` text,\n `time_completed` integer,\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL,\n PRIMARY KEY (`session_id`, `actor_id`)\n);--> statement-breakpoint\nCREATE INDEX `actor_registry_session_agent_idx` ON `actor_registry` (`session_id`, `agent`);--> statement-breakpoint\nCREATE INDEX `actor_registry_session_parent_idx` ON `actor_registry` (`session_id`, `parent_actor_id`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_idx` ON `actor_registry` (`status`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_last_turn_idx` ON `actor_registry` (`status`, `last_turn_time`);\n",timestamp:1779321660000,name:"20260521000100_actor_registry_v6"},{sql:"DROP TRIGGER IF EXISTS `memory_fts_ai`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_ad`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_au`;--> statement-breakpoint\nDROP TABLE IF EXISTS `memory_fts_idx`;--> statement-breakpoint\nDROP TABLE IF EXISTS `memory_fts`;--> statement-breakpoint\nCREATE TABLE `memory_fts` (\n `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n `path` text NOT NULL UNIQUE,\n `scope` text NOT NULL,\n `scope_id` text DEFAULT '' NOT NULL,\n `type` text NOT NULL,\n `body` text NOT NULL,\n `fingerprint` text NOT NULL,\n `last_indexed_at` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `memory_fts_scope_idx` ON `memory_fts` (`scope`, `scope_id`);--> statement-breakpoint\nCREATE INDEX `memory_fts_type_idx` ON `memory_fts` (`type`);--> statement-breakpoint\nCREATE VIRTUAL TABLE `memory_fts_idx` USING fts5(\n body,\n content='memory_fts',\n content_rowid='id',\n tokenize='unicode61 remove_diacritics 1'\n);--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ai` AFTER INSERT ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ad` AFTER DELETE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.id;\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_au` AFTER UPDATE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.id;\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;\n",timestamp:1779325200000,name:"20260521010000_memory_fts_v6"},{sql:"-- Fix v6.1 trigger pattern: external content FTS5 vtab requires the 'delete'\n-- magic command to remove OLD body's tokens, NOT a plain DELETE FROM the vtab.\n-- The previous DELETE FROM pattern was contentless-mode syntax misapplied to\n-- external-content mode, leaving stale tokens accumulating until vtab corrupts.\nDROP TRIGGER IF EXISTS `memory_fts_ai`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_ad`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_au`;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ai` AFTER INSERT ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ad` AFTER DELETE ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(`memory_fts_idx`, rowid, body) VALUES('delete', OLD.id, OLD.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_au` AFTER UPDATE ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(`memory_fts_idx`, rowid, body) VALUES('delete', OLD.id, OLD.body);\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;\n",timestamp:1779328800000,name:"20260521020000_memory_fts_triggers"},{sql:"UPDATE `message` SET `agent_id` = 'main' WHERE `agent_id` IS NULL;--> statement-breakpoint\nCREATE TABLE `message_new` (\n `id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `agent_id` text NOT NULL DEFAULT 'main',\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL,\n `data` text NOT NULL\n);--> statement-breakpoint\nINSERT INTO `message_new` SELECT `id`, `session_id`, COALESCE(`agent_id`, 'main'), `time_created`, `time_updated`, `data` FROM `message`;--> statement-breakpoint\nDROP TABLE `message`;--> statement-breakpoint\nALTER TABLE `message_new` RENAME TO `message`;--> statement-breakpoint\nCREATE INDEX `message_session_time_created_id_idx` ON `message` (`session_id`,`time_created`,`id`);--> statement-breakpoint\nCREATE INDEX `message_session_agent_idx` ON `message` (`session_id`,`agent_id`,`id`);\n",timestamp:1779753600000,name:"20260526000000_agent_id_main"},{sql:"ALTER TABLE `actor_registry` ADD COLUMN `last_outcome` text;--> statement-breakpoint\nALTER TABLE `actor_registry` ADD COLUMN `lifecycle` text NOT NULL DEFAULT 'ephemeral';--> statement-breakpoint\nALTER TABLE `actor_registry` RENAME COLUMN `error` TO `last_error`;--> statement-breakpoint\nUPDATE `actor_registry` SET `last_outcome` = 'success' WHERE `status` = 'completed';--> statement-breakpoint\nUPDATE `actor_registry` SET `last_outcome` = 'failure' WHERE `status` = 'failed';--> statement-breakpoint\nUPDATE `actor_registry` SET `last_outcome` = 'cancelled' WHERE `status` = 'cancelled';--> statement-breakpoint\nUPDATE `actor_registry` SET `status` = 'idle' WHERE `status` IN ('completed','failed','cancelled');--> statement-breakpoint\nUPDATE `actor_registry` SET `lifecycle` = CASE `mode` WHEN 'peer' THEN 'persistent' WHEN 'main' THEN 'persistent' ELSE 'ephemeral' END;\n",timestamp:1779840000000,name:"20260527000000_actor_lifecycle"},{sql:"CREATE TABLE `inbox` (\n `id` text PRIMARY KEY NOT NULL,\n `receiver_session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `receiver_actor_id` text NOT NULL,\n `sender_session_id` text,\n `sender_actor_id` text,\n `type` text NOT NULL DEFAULT 'text',\n `content` text NOT NULL,\n `created_at` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `inbox_receiver_idx` ON `inbox` (`receiver_session_id`,`receiver_actor_id`,`id`);--> statement-breakpoint\nCREATE INDEX `inbox_created_idx` ON `inbox` (`created_at`);\n",timestamp:1779840060000,name:"20260527000100_inbox"},{sql:"-- todo: drop priority column\nALTER TABLE `todo` DROP COLUMN `priority`;\n--> statement-breakpoint\n\n-- task: drop focus-dependent index before dropping its column\nDROP INDEX `task_focus_per_session_idx`;\n--> statement-breakpoint\nDROP INDEX `task_kind_idx`;\n--> statement-breakpoint\nALTER TABLE `task` DROP COLUMN `focus`;\n--> statement-breakpoint\nALTER TABLE `task` DROP COLUMN `kind`;\n--> statement-breakpoint\n\n-- migrate status values: proposed/active -> open\nUPDATE `task` SET `status` = 'open' WHERE `status` IN ('proposed', 'active');\n",timestamp:1780012800000,name:"20260529000000_task_todo_redesign"},{sql:"ALTER TABLE `task` ADD COLUMN `owner` text;\n",timestamp:1780444800000,name:"20260603000000_task_in_progress_owner"},{sql:"CREATE TABLE `workflow_run` (\n `id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `name` text NOT NULL,\n `status` text NOT NULL,\n `running` integer NOT NULL DEFAULT 0,\n `succeeded` integer NOT NULL DEFAULT 0,\n `failed` integer NOT NULL DEFAULT 0,\n `current_phase` text,\n `parent_actor_id` text,\n `args` text,\n `error` text,\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `workflow_run_session_idx` ON `workflow_run` (`session_id`);--> statement-breakpoint\nCREATE INDEX `workflow_run_status_idx` ON `workflow_run` (`status`);\n",timestamp:1780444800000,name:"20260603000000_workflow_run"},{sql:"ALTER TABLE `workflow_run` ADD COLUMN `script_sha` text;\n",timestamp:1780531200000,name:"20260604000000_workflow_script_sha"},{sql:"CREATE TABLE `claude_import` (\n `source_uuid` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL,\n `source_path` text NOT NULL,\n `source_mtime` integer NOT NULL,\n `time_imported` integer NOT NULL\n);\n",timestamp:1780876800000,name:"20260608000000_claude_import"},{sql:"ALTER TABLE `claude_import` ADD `message_ids` text;\n",timestamp:1780880400000,name:"20260608010000_claude_import_message_ids"},{sql:"CREATE TABLE `history_fts` (\n `part_id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL,\n `message_id` text NOT NULL,\n `project_id` text NOT NULL,\n `kind` text NOT NULL,\n `tool_name` text,\n `body` text NOT NULL,\n `time_created` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `history_fts_session_idx` ON `history_fts` (`session_id`, `time_created`);--> statement-breakpoint\nCREATE INDEX `history_fts_project_idx` ON `history_fts` (`project_id`, `time_created`);--> statement-breakpoint\nCREATE INDEX `history_fts_message_idx` ON `history_fts` (`message_id`);--> statement-breakpoint\nCREATE VIRTUAL TABLE `history_fts_idx` USING fts5(\n body,\n content='history_fts',\n content_rowid='rowid',\n tokenize='unicode61 remove_diacritics 1'\n);--> statement-breakpoint\nCREATE TRIGGER `history_fts_ai` AFTER INSERT ON `history_fts` BEGIN\n INSERT INTO `history_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `history_fts_ad` AFTER DELETE ON `history_fts` BEGIN\n INSERT INTO `history_fts_idx`(`history_fts_idx`, rowid, body) VALUES('delete', OLD.rowid, OLD.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `history_fts_au` AFTER UPDATE ON `history_fts` BEGIN\n INSERT INTO `history_fts_idx`(`history_fts_idx`, rowid, body) VALUES('delete', OLD.rowid, OLD.body);\n INSERT INTO `history_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;\n",timestamp:1780963200000,name:"20260609000000_history_fts"},{sql:"ALTER TABLE `workflow_run` ADD COLUMN `agent_timeout_ms` integer;\n",timestamp:1781046000000,name:"20260609230000_workflow_agent_timeout"},{sql:"CREATE TABLE `external_import` (\n `source` text NOT NULL,\n `source_key` text NOT NULL,\n `session_id` text NOT NULL,\n `source_path` text NOT NULL,\n `source_mtime` integer NOT NULL,\n `time_imported` integer NOT NULL,\n `message_ids` text,\n PRIMARY KEY (`source`, `source_key`)\n);\n\nINSERT INTO `external_import` (`source`, `source_key`, `session_id`, `source_path`, `source_mtime`, `time_imported`, `message_ids`)\nSELECT 'cc', `source_uuid`, `session_id`, `source_path`, `source_mtime`, `time_imported`, `message_ids`\nFROM `claude_import`;\n\nDROP TABLE `claude_import`;\n",timestamp:1781222400000,name:"20260612000000_external_import"}];if(o.length>0){if(Xi.info("applying migrations",{count:o.length,mode:"bundled"}),nn.QITQODE_SKIP_MIGRATIONS)for(let t of o)t.sql="select 1;";bo(n,o)}return n});function Ce(){Jn().$client.close(),Jn.reset()}var Vn=un.create("database");function Je(n){try{return n(Vn.use().tx)}catch(o){if(o instanceof un.NotFound){let t=[],s=Vn.provide({effects:t,tx:Jn()},()=>n(Jn()));for(let e of t)e();return s}throw o}}function He(n){let o=Yn.bind(n);try{Vn.use().effects.push(o)}catch{o()}}function Ke(n,o){try{return n(Vn.use().tx)}catch(t){if(t instanceof un.NotFound){let s=[],e=Yn.bind((_)=>Vn.provide({tx:_,effects:s},()=>n(_))),l=Jn().transaction(e,{behavior:o?.behavior});for(let _ of s)_();return l}throw t}}var ai={};On(ai,{layer:()=>Fi,defaultLayer:()=>we,Service:()=>yo,NotFoundError:()=>Xo});import Y from"path";var Hn={};On(Hn,{layer:()=>wi,defaultLayer:()=>Ee,Service:()=>mo,Git:()=>Hn});var Re=["--no-optional-locks","-c","core.autocrlf=false","-c","core.fsmonitor=false","-c","core.longpaths=true","-c","core.symlinks=true","-c","core.quotepath=false"],cn=(n)=>n.text().trim(),Uo=(n)=>n.split("\x00").filter(Boolean),Se=(n)=>({exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:Buffer.from(n instanceof Error?n.message:String(n))}),ki=(n)=>{if(n==="??")return"added";if(n.includes("U"))return"modified";if(n.includes("A")&&!n.includes("D"))return"added";if(n.includes("D")&&!n.includes("A"))return"deleted";return"modified"};class mo extends Qn.Service()("@qitqode/Git"){}var wi=h.effect(mo,r.gen(function*(){let n=yield*no.ChildProcessSpawner,o=r.fn("Git.run")(function*(u,p){let m=Vi.make("git",[...Re,...u],{cwd:p.cwd,env:p.env,extendEnv:!0,stdin:"ignore",stdout:"pipe",stderr:"pipe"}),f=yield*ci(n,m);return{exitCode:f.code,text:()=>f.text,stdout:Buffer.from(f.text),stderr:Buffer.from(f.stderr)}},r.scoped,r.catch((u)=>r.succeed(Se(u)))),t=r.fn("Git.text")(function*(u,p){return(yield*o(u,p)).text()}),s=r.fn("Git.lines")(function*(u,p){return(yield*t(u,p)).split(/\r?\n/).map((m)=>m.trim()).filter(Boolean)}),e=r.fnUntraced(function*(u){return yield*s(["for-each-ref","--format=%(refname:short)","refs/heads"],{cwd:u})}),l=r.fnUntraced(function*(u,p){let m=yield*o(["config","init.defaultBranch"],{cwd:u}),f=cn(m);if(!f||!p.includes(f))return;return{name:f,ref:f}}),_=r.fnUntraced(function*(u){let p=yield*s(["remote"],{cwd:u});if(p.includes("origin"))return"origin";if(p.length===1)return p[0];if(p.includes("upstream"))return"upstream";return p[0]}),A=r.fn("Git.branch")(function*(u){let p=yield*o(["symbolic-ref","--quiet","--short","HEAD"],{cwd:u});if(p.exitCode!==0)return;return cn(p)||void 0}),C=r.fn("Git.prefix")(function*(u){let p=yield*o(["rev-parse","--show-prefix"],{cwd:u});if(p.exitCode!==0)return"";return cn(p)}),S=r.fn("Git.defaultBranch")(function*(u){let p=yield*_(u);if(p){let i=yield*o(["symbolic-ref",`refs/remotes/${p}/HEAD`],{cwd:u});if(i.exitCode===0){let y=cn(i).replace(/^refs\/remotes\//,""),$=y.startsWith(`${p}/`)?y.slice(`${p}/`.length):"";if($)return{name:$,ref:y}}}let m=yield*e(u),f=yield*l(u,m);if(f)return f;if(m.includes("main"))return{name:"main",ref:"main"};if(m.includes("master"))return{name:"master",ref:"master"}}),K=r.fn("Git.hasHead")(function*(u){return(yield*o(["rev-parse","--verify","HEAD"],{cwd:u})).exitCode===0}),R=r.fn("Git.mergeBase")(function*(u,p,m="HEAD"){let f=yield*o(["merge-base",p,m],{cwd:u});if(f.exitCode!==0)return;return cn(f)||void 0}),E=r.fn("Git.show")(function*(u,p,m,f=""){let i=f?`${f}${m}`:m,y=yield*o(["show",`${p}:${i}`],{cwd:u});if(y.exitCode!==0)return"";if(y.stdout.includes(0))return"";return y.text()}),d=r.fn("Git.status")(function*(u){return Uo(yield*t(["status","--porcelain=v1","--untracked-files=all","--no-renames","-z","--","."],{cwd:u})).flatMap((p)=>{let m=p.slice(3);if(!m)return[];let f=p.slice(0,2);return[{file:m,code:f,status:ki(f)}]})}),D=r.fn("Git.diff")(function*(u,p){let m=Uo(yield*t(["diff","--no-ext-diff","--no-renames","--name-status","-z",p,"--","."],{cwd:u}));return m.flatMap((f,i)=>{if(i%2!==0)return[];let y=m[i+1];if(!f||!y)return[];return[{file:y,code:f,status:ki(f)}]})}),L=r.fn("Git.stats")(function*(u,p){return Uo(yield*t(["diff","--no-ext-diff","--no-renames","--numstat","-z",p,"--","."],{cwd:u})).flatMap((m)=>{let f=m.indexOf("\t"),i=m.indexOf("\t",f+1);if(f===-1||i===-1)return[];let y=m.slice(i+1);if(!y)return[];let $=m.slice(0,f),I=m.slice(f+1,i),O=$==="-"?0:Number.parseInt($||"0",10),U=I==="-"?0:Number.parseInt(I||"0",10);return[{file:y,additions:Number.isFinite(O)?O:0,deletions:Number.isFinite(U)?U:0}]})});return mo.of({run:o,branch:A,prefix:C,defaultBranch:S,hasHead:K,mergeBase:R,show:E,status:d,diff:D,stats:L})})),Ee=wi.pipe(h.provide(oo));var ln=V.create({service:"storage"}),Xo=eo.create("NotFoundError",j.object({message:j.string()})),We=N.Struct({path:N.optional(N.Struct({root:N.optional(N.String)}))}),Pe=N.Struct({id:N.String}),Ue=N.Struct({id:N.String}),Ze=N.Struct({additions:N.Number,deletions:N.Number}),ve=N.Struct({id:N.String,projectID:N.String,summary:N.Struct({diffs:N.Array(Ze)})}),Xe=N.decodeUnknownOption(We),Ye=N.decodeUnknownOption(Pe),ze=N.decodeUnknownOption(Ue),ke=N.decodeUnknownOption(ve);class yo extends Qn.Service()("@qitqode/Storage"){}function Ve(n,o){return Y.join(n,...o)+".json"}function Zo(n){if(!n||typeof n!=="object")return!1;if("code"in n&&n.code==="ENOENT")return!0;if("reason"in n&&n.reason&&typeof n.reason==="object"&&"_tag"in n.reason)return n.reason._tag==="NotFound";return!1}function ce(n){let o=Number.parseInt(n,10);return Number.isNaN(o)?0:o}var qi=[r.fn("Storage.migration.1")(function*(n,o,t){let s=Y.resolve(n,"../project");if(!(yield*o.isDir(s)))return;let e=yield*o.glob("*",{cwd:s,include:"all"});for(let l of e){let _=Y.join(s,l);if(!(yield*o.isDir(_)))continue;ln.info(`migrating project ${l}`);let A=l,C="/";if(A!=="global"){for(let R of yield*o.glob("storage/session/message/*/*.json",{cwd:_,absolute:!0})){let E=Xe(yield*o.readJson(R),{onExcessProperty:"preserve"}),d=wn.isSome(E)?E.value.path?.root:void 0;if(!d)continue;C=d;break}if(!C)continue;if(!(yield*o.isDir(C)))continue;let S=yield*t.run(["rev-list","--max-parents=0","--all"],{cwd:C}),[K]=S.text().split(`
|
|
5
|
-
`).filter(Boolean).map((R)=>R.trim()).toSorted();if(!K)continue;A=K,yield*o.writeWithDirs(Y.join(n,"project",A+".json"),JSON.stringify({id:K,vcs:"git",worktree:C,time:{created:Date.now(),initialized:Date.now()}},null,2)),ln.info(`migrating sessions for project ${A}`);for(let R of yield*o.glob("storage/session/info/*.json",{cwd:_,absolute:!0})){let E=Y.join(n,"session",A,Y.basename(R));ln.info("copying",{sessionFile:R,dest:E});let d=yield*o.readJson(R),D=Ye(d,{onExcessProperty:"preserve"});if(yield*o.writeWithDirs(E,JSON.stringify(d,null,2)),wn.isNone(D))continue;ln.info(`migrating messages for session ${D.value.id}`);for(let L of yield*o.glob(`storage/session/message/${D.value.id}/*.json`,{cwd:_,absolute:!0})){let u=Y.join(n,"message",D.value.id,Y.basename(L));ln.info("copying",{msgFile:L,dest:u});let p=yield*o.readJson(L),m=ze(p,{onExcessProperty:"preserve"});if(yield*o.writeWithDirs(u,JSON.stringify(p,null,2)),wn.isNone(m))continue;ln.info(`migrating parts for message ${m.value.id}`);for(let f of yield*o.glob(`storage/session/part/${D.value.id}/${m.value.id}/*.json`,{cwd:_,absolute:!0})){let i=Y.join(n,"part",m.value.id,Y.basename(f)),y=yield*o.readJson(f);ln.info("copying",{partFile:f,dest:i}),yield*o.writeWithDirs(i,JSON.stringify(y,null,2))}}}}}}),r.fn("Storage.migration.2")(function*(n,o){for(let t of yield*o.glob("session/*/*.json",{cwd:n,absolute:!0})){let s=yield*o.readJson(t),e=ke(s,{onExcessProperty:"preserve"});if(wn.isNone(e))continue;let l=e.value.summary.diffs;yield*o.writeWithDirs(Y.join(n,"session_diff",e.value.id+".json"),JSON.stringify(l,null,2)),yield*o.writeWithDirs(Y.join(n,"session",e.value.projectID,e.value.id+".json"),JSON.stringify({...s,summary:{additions:l.reduce((_,A)=>_+A.additions,0),deletions:l.reduce((_,A)=>_+A.deletions,0)}},null,2))}})],Fi=h.effect(yo,r.gen(function*(){let n=yield*c.Service,o=yield*Hn.Service,t=yield*vo.make({lookup:()=>Kn.make(),idleTimeToLive:0}),s=yield*r.cached(r.gen(function*(){let d=Y.join(dn.Path.data,"storage"),D=Y.join(d,"migration"),L=yield*n.readFileString(D).pipe(r.map(ce),r.catchIf(Zo,()=>r.succeed(0)),r.orElseSucceed(()=>0));for(let u=L;u<qi.length;u++){ln.info("running migration",{index:u});let p=qi[u],m=yield*r.exit(p(d,n,o));if(kn.isFailure(m)){ln.error("failed to run migration",{index:u,cause:m.cause});break}yield*n.writeWithDirs(D,String(u+1))}return{dir:d}})),e=(d)=>r.fail(new Xo({message:`Resource not found: ${d}`})),l=(d,D)=>D.pipe(r.catchIf(Zo,()=>e(d))),_=r.fnUntraced(function*(d,D){yield*n.writeWithDirs(d,JSON.stringify(D,null,2))}),A=(d,D)=>r.scoped(r.gen(function*(){let L=Ve((yield*s).dir,d);return yield*D(L,yield*vo.get(t,L))})),C=r.fn("Storage.remove")(function*(d){yield*A(d,(D,L)=>Kn.withWriteLock(L,n.remove(D).pipe(r.catchIf(Zo,()=>r.void))))}),S=(d)=>r.gen(function*(){return yield*A(d,(L,u)=>Kn.withReadLock(u,l(L,n.readJson(L))))}),K=(d,D)=>r.gen(function*(){return yield*A(d,(u,p)=>Kn.withWriteLock(p,r.gen(function*(){let m=yield*l(u,n.readJson(u));return D(m),yield*_(u,m),m})))}),R=(d,D)=>r.gen(function*(){yield*A(d,(L,u)=>Kn.withWriteLock(u,_(L,D)))}),E=r.fn("Storage.list")(function*(d){let D=(yield*s).dir,L=Y.join(D,...d);return(yield*n.glob("**/*",{cwd:L,include:"file"}).pipe(r.catch(()=>r.succeed([])))).map((p)=>[...d,...p.slice(0,-5).split(Y.sep)]).toSorted((p,m)=>p.join("/").localeCompare(m.join("/")))});return yo.of({remove:C,read:S,update:K,write:R,list:E})})),we=Fi.pipe(h.provide(c.defaultLayer),h.provide(Hn.defaultLayer));export{Un as
|
|
5
|
+
`).filter(Boolean).map((R)=>R.trim()).toSorted();if(!K)continue;A=K,yield*o.writeWithDirs(Y.join(n,"project",A+".json"),JSON.stringify({id:K,vcs:"git",worktree:C,time:{created:Date.now(),initialized:Date.now()}},null,2)),ln.info(`migrating sessions for project ${A}`);for(let R of yield*o.glob("storage/session/info/*.json",{cwd:_,absolute:!0})){let E=Y.join(n,"session",A,Y.basename(R));ln.info("copying",{sessionFile:R,dest:E});let d=yield*o.readJson(R),D=Ye(d,{onExcessProperty:"preserve"});if(yield*o.writeWithDirs(E,JSON.stringify(d,null,2)),wn.isNone(D))continue;ln.info(`migrating messages for session ${D.value.id}`);for(let L of yield*o.glob(`storage/session/message/${D.value.id}/*.json`,{cwd:_,absolute:!0})){let u=Y.join(n,"message",D.value.id,Y.basename(L));ln.info("copying",{msgFile:L,dest:u});let p=yield*o.readJson(L),m=ze(p,{onExcessProperty:"preserve"});if(yield*o.writeWithDirs(u,JSON.stringify(p,null,2)),wn.isNone(m))continue;ln.info(`migrating parts for message ${m.value.id}`);for(let f of yield*o.glob(`storage/session/part/${D.value.id}/${m.value.id}/*.json`,{cwd:_,absolute:!0})){let i=Y.join(n,"part",m.value.id,Y.basename(f)),y=yield*o.readJson(f);ln.info("copying",{partFile:f,dest:i}),yield*o.writeWithDirs(i,JSON.stringify(y,null,2))}}}}}}),r.fn("Storage.migration.2")(function*(n,o){for(let t of yield*o.glob("session/*/*.json",{cwd:n,absolute:!0})){let s=yield*o.readJson(t),e=ke(s,{onExcessProperty:"preserve"});if(wn.isNone(e))continue;let l=e.value.summary.diffs;yield*o.writeWithDirs(Y.join(n,"session_diff",e.value.id+".json"),JSON.stringify(l,null,2)),yield*o.writeWithDirs(Y.join(n,"session",e.value.projectID,e.value.id+".json"),JSON.stringify({...s,summary:{additions:l.reduce((_,A)=>_+A.additions,0),deletions:l.reduce((_,A)=>_+A.deletions,0)}},null,2))}})],Fi=h.effect(yo,r.gen(function*(){let n=yield*c.Service,o=yield*Hn.Service,t=yield*vo.make({lookup:()=>Kn.make(),idleTimeToLive:0}),s=yield*r.cached(r.gen(function*(){let d=Y.join(dn.Path.data,"storage"),D=Y.join(d,"migration"),L=yield*n.readFileString(D).pipe(r.map(ce),r.catchIf(Zo,()=>r.succeed(0)),r.orElseSucceed(()=>0));for(let u=L;u<qi.length;u++){ln.info("running migration",{index:u});let p=qi[u],m=yield*r.exit(p(d,n,o));if(kn.isFailure(m)){ln.error("failed to run migration",{index:u,cause:m.cause});break}yield*n.writeWithDirs(D,String(u+1))}return{dir:d}})),e=(d)=>r.fail(new Xo({message:`Resource not found: ${d}`})),l=(d,D)=>D.pipe(r.catchIf(Zo,()=>e(d))),_=r.fnUntraced(function*(d,D){yield*n.writeWithDirs(d,JSON.stringify(D,null,2))}),A=(d,D)=>r.scoped(r.gen(function*(){let L=Ve((yield*s).dir,d);return yield*D(L,yield*vo.get(t,L))})),C=r.fn("Storage.remove")(function*(d){yield*A(d,(D,L)=>Kn.withWriteLock(L,n.remove(D).pipe(r.catchIf(Zo,()=>r.void))))}),S=(d)=>r.gen(function*(){return yield*A(d,(L,u)=>Kn.withReadLock(u,l(L,n.readJson(L))))}),K=(d,D)=>r.gen(function*(){return yield*A(d,(u,p)=>Kn.withWriteLock(p,r.gen(function*(){let m=yield*l(u,n.readJson(u));return D(m),yield*_(u,m),m})))}),R=(d,D)=>r.gen(function*(){yield*A(d,(L,u)=>Kn.withWriteLock(u,_(L,D)))}),E=r.fn("Storage.list")(function*(d){let D=(yield*s).dir,L=Y.join(D,...d);return(yield*n.glob("**/*",{cwd:L,include:"file"}).pipe(r.catch(()=>r.succeed([])))).map((p)=>[...d,...p.slice(0,-5).split(Y.sep)]).toSorted((p,m)=>p.join("/").localeCompare(m.join("/")))});return yo.of({remove:C,read:S,update:K,write:R,list:E})})),we=Fi.pipe(h.provide(c.defaultLayer),h.provide(Hn.defaultLayer));export{Un as ql,si as rl,Zn as sl,mn as tl,x as ul,gn as vl,fo as wl,zo as xl,ko as yl,Vo as zl,co as Al,qo as Bl,uo as Cl,In as Dl,Hn as El,Xo as Fl,ai as Gl,q as Hl,Co as Il,Ti as Jl,se as Kl,xi as Ll,Te as Ml,on as Nl,Yn as Ol,Le as Pl,Pi as Ql,Ui as Rl};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$p as JG,Bq as d,Cp as V,Ep as l,Ip as e,Jp as t,Sp as a,Xp as o,Yp as GG,dq as NG,gq as QG,lq as g,nq as v,oq as k,uq as b,vq as R,wq as XG,xq as I}from"./chunk-t7v8wzr9.js";import{Dq as f,Jq as C,Nq as m,Qq as O}from"./chunk-er5q8nhp.js";import"./chunk-cqtkxwd8.js";import"./chunk-h6htvj2y.js";import{Cu as G}from"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-fa03gsff.js";function c(J){var Q,$,K,j,z,q;if(J==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let A=(Q=J.prompt_tokens)!=null?Q:0,Z=($=J.completion_tokens)!=null?$:0,N=(j=(K=J.prompt_tokens_details)==null?void 0:K.cached_tokens)!=null?j:0,X=(q=(z=J.completion_tokens_details)==null?void 0:z.reasoning_tokens)!=null?q:0;return{inputTokens:{total:A,noCache:A-N,cacheRead:N,cacheWrite:void 0},outputTokens:{total:Z,text:Z-X,reasoning:X},raw:J}}function _(J){switch(J){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"other"}}function u({id:J,model:Q,created:$}){return{id:J!=null?J:void 0,modelId:Q!=null?Q:void 0,timestamp:$!=null?new Date($*1000):void 0}}function i({tools:J,toolChoice:Q}){J=(J==null?void 0:J.length)?J:void 0;let $=[];if(J==null)return{tools:void 0,toolChoice:void 0,toolWarnings:$};let K=[];for(let z of J)if(z.type==="provider")$.push({type:"unsupported",feature:`provider-defined tool ${z.id}`});else K.push({type:"function",function:{name:z.name,description:z.description,parameters:z.inputSchema,...z.strict!=null?{strict:z.strict}:{}}});if(Q==null)return{tools:K,toolChoice:void 0,toolWarnings:$};let j=Q.type;switch(j){case"auto":case"none":case"required":return{tools:K,toolChoice:j,toolWarnings:$};case"tool":return{tools:K,toolChoice:{type:"function",function:{name:Q.toolName}},toolWarnings:$};default:throw new O({functionality:`tool choice type: ${j}`})}}var $G=G.object({enableThinking:G.boolean().optional(),thinkingBudget:G.number().positive().optional(),parallelToolCalls:G.boolean().optional()});function p(J){var Q,$,K,j;let z=c(J),q=($=(Q=J==null?void 0:J.prompt_tokens_details)==null?void 0:Q.cache_creation_input_tokens)!=null?$:0,A=((K=z.inputTokens.total)!=null?K:0)-((j=z.inputTokens.cacheRead)!=null?j:0)-q;return{...z,inputTokens:{...z.inputTokens,cacheWrite:q,noCache:A}}}function zG({data:J,mediaType:Q}){return J instanceof URL?J.toString():`data:${Q};base64,${t(J)}`}function BG({prompt:J,cacheControlValidator:Q}){var $,K;let j=[];for(let{role:z,content:q,...A}of J){let Z=Q==null?void 0:Q.getCacheControl(A.providerOptions);switch(z){case"system":{if(Z)j.push({role:"system",content:[{type:"text",text:q,cache_control:Z}]});else j.push({role:"system",content:q});break}case"user":{j.push({role:"user",content:q.map((N,X)=>{var E;let L=X===q.length-1,B=(E=Q==null?void 0:Q.getCacheControl(N.providerOptions))!=null?E:L?Z:void 0;switch(N.type){case"text":return{type:"text",text:N.text,...B?{cache_control:B}:{}};case"file":if(N.mediaType.startsWith("image/")){let U=N.mediaType==="image/*"?"image/jpeg":N.mediaType;return{type:"image_url",image_url:{url:zG({data:N.data,mediaType:U})},...B?{cache_control:B}:{}}}else throw new O({functionality:"Only image file parts are supported"})}})});break}case"assistant":{let N="",X=[];for(let E of q)switch(E.type){case"text":{N+=E.text;break}case"tool-call":{X.push({id:E.toolCallId,type:"function",function:{name:E.toolName,arguments:JSON.stringify(E.input)}});break}case"reasoning":{N+=E.text;break}}j.push({role:"assistant",content:Z?[{type:"text",text:N,cache_control:Z}]:N||null,tool_calls:X.length>0?X:void 0});break}case"tool":{let N=q.filter((X)=>X.type!=="tool-approval-response");for(let X=0;X<N.length;X++){let E=N[X],L=E.output,B=X===N.length-1,U=($=Q==null?void 0:Q.getCacheControl(E.providerOptions))!=null?$:B?Z:void 0,Y;switch(L.type){case"text":case"error-text":Y=L.value;break;case"execution-denied":Y=(K=L.reason)!=null?K:"Tool execution denied.";break;case"content":case"json":case"error-json":Y=JSON.stringify(L.value);break}j.push({role:"tool",tool_call_id:E.toolCallId,content:U?[{type:"text",text:Y,cache_control:U}]:Y})}break}default:throw Error(`Unsupported role: ${z}`)}}return j}var r=4;function EG(J){var Q;let $=J==null?void 0:J.alibaba;return(Q=$==null?void 0:$.cacheControl)!=null?Q:$==null?void 0:$.cache_control}var jG=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(J){let Q=EG(J);if(!Q)return;if(this.breakpointCount++,this.breakpointCount>r)this.warnings.push({type:"other",message:`Max breakpoint limit exceeded. Only the last ${r} cache markers will take effect.`});return Q}getWarnings(){return this.warnings}},KG=class{constructor(J,Q){this.specificationVersion="v3",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=J,this.config=Q}get provider(){return this.config.provider}async getArgs({prompt:J,maxOutputTokens:Q,temperature:$,topP:K,topK:j,frequencyPenalty:z,presencePenalty:q,stopSequences:A,responseFormat:Z,seed:N,providerOptions:X,tools:E,toolChoice:L}){var B;let U=[],Y=new jG,P=await v({provider:"alibaba",providerOptions:X,schema:$G});if(z!=null)U.push({type:"unsupported",feature:"frequencyPenalty"});let w={model:this.modelId,max_tokens:Q,temperature:$,top_p:K,top_k:j,presence_penalty:q,stop:A,seed:N,response_format:(Z==null?void 0:Z.type)==="json"?Z.schema!=null?{type:"json_schema",json_schema:{schema:Z.schema,name:(B=Z.name)!=null?B:"response",description:Z.description}}:{type:"json_object"}:void 0,...(P==null?void 0:P.enableThinking)!=null?{enable_thinking:P.enableThinking}:{},...(P==null?void 0:P.thinkingBudget)!=null?{thinking_budget:P.thinkingBudget}:{},messages:BG({prompt:J,cacheControlValidator:Y})},{tools:y,toolChoice:S,toolWarnings:F}=i({tools:E,toolChoice:L});return U.push(...Y.getWarnings()),{args:{...w,tools:y,tool_choice:S,...y!=null&&(P==null?void 0:P.parallelToolCalls)!==void 0?{parallel_tool_calls:P.parallelToolCalls}:{}},warnings:[...U,...F]}}async doGenerate(J){var Q;let{args:$,warnings:K}=await this.getArgs(J),{responseHeaders:j,value:z,rawValue:q}=await k({url:`${this.config.baseURL}/chat/completions`,headers:V(this.config.headers(),J.headers),body:$,failedResponseHandler:s,successfulResponseHandler:I(qG),abortSignal:J.abortSignal,fetch:this.config.fetch}),A=z.choices[0],Z=[],N=A.message.content;if(N!=null&&N.length>0)Z.push({type:"text",text:N});let X=A.message.reasoning_content;if(X!=null&&X.length>0)Z.push({type:"reasoning",text:X});if(A.message.tool_calls!=null)for(let E of A.message.tool_calls)Z.push({type:"tool-call",toolCallId:E.id,toolName:E.function.name,input:E.function.arguments});return{content:Z,finishReason:{unified:_(A.finish_reason),raw:(Q=A.finish_reason)!=null?Q:void 0},usage:p(z.usage),request:{body:JSON.stringify($)},response:{...u(z),headers:j,body:q},warnings:K}}async doStream(J){let{args:Q,warnings:$}=await this.getArgs(J),K={...Q,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},{responseHeaders:j,value:z}=await k({url:`${this.config.baseURL}/chat/completions`,headers:V(this.config.headers(),J.headers),body:K,failedResponseHandler:s,successfulResponseHandler:XG(AG),abortSignal:J.abortSignal,fetch:this.config.fetch}),q={unified:"other",raw:void 0},A=void 0,Z=!0,N=!1,X=null,E=[];return{stream:z.pipeThrough(new TransformStream({start(L){L.enqueue({type:"stream-start",warnings:$})},transform(L,B){var U,Y,P,w;if(J.includeRawChunks)B.enqueue({type:"raw",rawValue:L.rawValue});if(!L.success){B.enqueue({type:"error",error:L.error});return}let y=L.value;if(Z)Z=!1,B.enqueue({type:"response-metadata",...u(y)});if(y.usage!=null)A=y.usage;if(y.choices.length===0)return;let S=y.choices[0],F=S.delta;if(F.reasoning_content!=null&&F.reasoning_content.length>0){if(X==null){if(N)B.enqueue({type:"text-end",id:"0"}),N=!1;X=a(),B.enqueue({type:"reasoning-start",id:X})}B.enqueue({type:"reasoning-delta",id:X,delta:F.reasoning_content})}if(F.content!=null&&F.content.length>0){if(X!=null)B.enqueue({type:"reasoning-end",id:X}),X=null;if(!N)B.enqueue({type:"text-start",id:"0"}),N=!0;B.enqueue({type:"text-delta",id:"0",delta:F.content})}if(F.tool_calls!=null){if(X!=null)B.enqueue({type:"reasoning-end",id:X}),X=null;if(N)B.enqueue({type:"text-end",id:"0"}),N=!1;for(let W of F.tool_calls){let M=(U=W.index)!=null?U:E.length;if(E[M]==null){if(W.id==null)throw new C({data:W,message:"Expected 'id' to be a string."});if(((Y=W.function)==null?void 0:Y.name)==null)throw new C({data:W,message:"Expected 'function.name' to be a string."});B.enqueue({type:"tool-input-start",id:W.id,toolName:W.function.name}),E[M]={id:W.id,type:"function",function:{name:W.function.name,arguments:(P=W.function.arguments)!=null?P:""},hasFinished:!1};let D=E[M];if(D.function.arguments.length>0)B.enqueue({type:"tool-input-delta",id:D.id,delta:D.function.arguments});if(g(D.function.arguments))B.enqueue({type:"tool-input-end",id:D.id}),B.enqueue({type:"tool-call",toolCallId:D.id,toolName:D.function.name,input:D.function.arguments}),D.hasFinished=!0;continue}let H=E[M];if(H.hasFinished)continue;if(((w=W.function)==null?void 0:w.arguments)!=null)H.function.arguments+=W.function.arguments,B.enqueue({type:"tool-input-delta",id:H.id,delta:W.function.arguments});if(g(H.function.arguments))B.enqueue({type:"tool-input-end",id:H.id}),B.enqueue({type:"tool-call",toolCallId:H.id,toolName:H.function.name,input:H.function.arguments}),H.hasFinished=!0}}if(S.finish_reason!=null)q={unified:_(S.finish_reason),raw:S.finish_reason}},flush(L){if(X!=null)L.enqueue({type:"reasoning-end",id:X});if(N)L.enqueue({type:"text-end",id:"0"});L.enqueue({type:"finish",finishReason:q,usage:p(A)})}})),request:{body:JSON.stringify(K)},response:{headers:j}}}},YG=G.object({prompt_tokens:G.number(),completion_tokens:G.number(),total_tokens:G.number(),prompt_tokens_details:G.object({cached_tokens:G.number().nullish(),cache_creation_input_tokens:G.number().nullish()}).nullish(),completion_tokens_details:G.object({reasoning_tokens:G.number().nullish()}).nullish()}),qG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({message:G.object({role:G.literal("assistant").nullish(),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({id:G.string(),type:G.literal("function"),function:G.object({name:G.string(),arguments:G.string()})})).nullish()}),finish_reason:G.string().nullish(),index:G.number()})),usage:YG.nullish()}),AG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({delta:G.object({role:G.enum(["assistant"]).nullish(),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({index:G.number().nullish(),id:G.string().nullish(),type:G.literal("function").nullish(),function:G.object({name:G.string().nullish(),arguments:G.string().nullish()}).nullish()})).nullish()}),finish_reason:G.string().nullish(),index:G.number()})),usage:YG.nullish()}),HG=NG(()=>QG(G.object({negativePrompt:G.string().nullish(),audioUrl:G.string().nullish(),promptExtend:G.boolean().nullish(),shotType:G.enum(["single","multi"]).nullish(),watermark:G.boolean().nullish(),audio:G.boolean().nullish(),referenceUrls:G.array(G.string()).nullish(),pollIntervalMs:G.number().positive().nullish(),pollTimeoutMs:G.number().positive().nullish()}).passthrough())),LG=G.object({code:G.string().nullish(),message:G.string(),request_id:G.string().nullish()}),n=R({errorSchema:LG,errorToMessage:(J)=>J.message}),PG=G.object({output:G.object({task_status:G.string(),task_id:G.string()}).nullish(),request_id:G.string().nullish()}),WG=G.object({output:G.object({task_id:G.string(),task_status:G.string(),video_url:G.string().nullish(),submit_time:G.string().nullish(),scheduled_time:G.string().nullish(),end_time:G.string().nullish(),orig_prompt:G.string().nullish(),actual_prompt:G.string().nullish(),code:G.string().nullish(),message:G.string().nullish()}).nullish(),usage:G.object({duration:G.number().nullish(),output_video_duration:G.number().nullish(),SR:G.number().nullish(),size:G.string().nullish()}).nullish(),request_id:G.string().nullish()});function UG(J){if(J.includes("-i2v"))return"i2v";if(J.includes("-r2v"))return"r2v";return"t2v"}var wG=class{constructor(J,Q){this.modelId=J,this.config=Q,this.specificationVersion="v3",this.maxVideosPerCall=1}get provider(){return this.config.provider}async doGenerate(J){var Q,$,K,j,z,q,A,Z,N,X,E;let L=(K=($=(Q=this.config._internal)==null?void 0:Q.currentDate)==null?void 0:$.call(Q))!=null?K:new Date,B=[],U=UG(this.modelId),Y=await v({provider:"alibaba",providerOptions:J.providerOptions,schema:HG}),P={};if(J.prompt!=null)P.prompt=J.prompt;if((Y==null?void 0:Y.negativePrompt)!=null)P.negative_prompt=Y.negativePrompt;if((Y==null?void 0:Y.audioUrl)!=null)P.audio_url=Y.audioUrl;if(U==="i2v"&&J.image!=null)if(J.image.type==="url")P.img_url=J.image.url;else{let x=typeof J.image.data==="string"?J.image.data:e(J.image.data);P.img_url=x}if(U==="r2v"&&(Y==null?void 0:Y.referenceUrls)!=null)P.reference_urls=Y.referenceUrls;let w={};if(J.duration!=null)w.duration=J.duration;if(J.seed!=null)w.seed=J.seed;if(J.resolution!=null)if(U==="i2v"){let x={"1280x720":"720P","720x1280":"720P","960x960":"720P","1088x832":"720P","832x1088":"720P","1920x1080":"1080P","1080x1920":"1080P","1440x1440":"1080P","1632x1248":"1080P","1248x1632":"1080P","832x480":"480P","480x832":"480P","624x624":"480P"};w.resolution=x[J.resolution]||J.resolution}else w.size=J.resolution.replace("x","*");if((Y==null?void 0:Y.promptExtend)!=null)w.prompt_extend=Y.promptExtend;if((Y==null?void 0:Y.shotType)!=null)w.shot_type=Y.shotType;if((Y==null?void 0:Y.watermark)!=null)w.watermark=Y.watermark;if((Y==null?void 0:Y.audio)!=null)w.audio=Y.audio;if(J.aspectRatio)B.push({type:"unsupported",feature:"aspectRatio",details:"Alibaba video models use explicit size/resolution dimensions. Use the resolution option or providerOptions.alibaba for size control."});if(J.fps)B.push({type:"unsupported",feature:"fps",details:"Alibaba video models do not support custom FPS."});if(J.n!=null&&J.n>1)B.push({type:"unsupported",feature:"n",details:"Alibaba video models only support generating 1 video per call."});let{value:y}=await k({url:`${this.config.baseURL}/api/v1/services/aigc/video-generation/video-synthesis`,headers:V(await b(this.config.headers),J.headers,{"X-DashScope-Async":"enable"}),body:{model:this.modelId,input:P,parameters:w},successfulResponseHandler:I(PG),failedResponseHandler:n,abortSignal:J.abortSignal,fetch:this.config.fetch}),S=(j=y.output)==null?void 0:j.task_id;if(!S)throw new f({name:"ALIBABA_VIDEO_GENERATION_ERROR",message:`No task_id returned from Alibaba API. Response: ${JSON.stringify(y)}`});let F=(z=Y==null?void 0:Y.pollIntervalMs)!=null?z:5000,W=(q=Y==null?void 0:Y.pollTimeoutMs)!=null?q:600000,M=Date.now(),H,D;while(!0){if(await l(F,{abortSignal:J.abortSignal}),Date.now()-M>W)throw new f({name:"ALIBABA_VIDEO_GENERATION_TIMEOUT",message:`Video generation timed out after ${W}ms`});let{value:x,responseHeaders:ZG}=await GG({url:`${this.config.baseURL}/api/v1/tasks/${S}`,headers:V(await b(this.config.headers),J.headers),successfulResponseHandler:I(WG),failedResponseHandler:n,abortSignal:J.abortSignal,fetch:this.config.fetch});D=ZG;let T=(A=x.output)==null?void 0:A.task_status;if(T==="SUCCEEDED"){H=x;break}if(T==="FAILED"||T==="CANCELED")throw new f({name:"ALIBABA_VIDEO_GENERATION_FAILED",message:`Video generation ${T.toLowerCase()}. Task ID: ${S}. ${(N=(Z=x.output)==null?void 0:Z.message)!=null?N:""}`})}let h=(X=H==null?void 0:H.output)==null?void 0:X.video_url;if(!h)throw new f({name:"ALIBABA_VIDEO_GENERATION_ERROR",message:`No video URL in response. Task ID: ${S}`});return{videos:[{type:"url",url:h,mediaType:"video/mp4"}],warnings:B,response:{timestamp:L,modelId:this.modelId,headers:D},providerMetadata:{alibaba:{taskId:S,videoUrl:h,...((E=H==null?void 0:H.output)==null?void 0:E.actual_prompt)?{actualPrompt:H.output.actual_prompt}:{},...(H==null?void 0:H.usage)?{usage:{duration:H.usage.duration,outputVideoDuration:H.usage.output_video_duration,resolution:H.usage.SR,size:H.usage.size}}:{}}}}}},SG="1.0.17",FG=G.object({error:G.object({message:G.string(),code:G.string().nullish(),type:G.string().nullish()})}),s=R({errorSchema:FG,errorToMessage:(J)=>J.error.message});function DG(J={}){var Q,$;let K=(Q=d(J.baseURL))!=null?Q:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",j=($=d(J.videoBaseURL))!=null?$:"https://dashscope-intl.aliyuncs.com",z=()=>o({Authorization:`Bearer ${JG({apiKey:J.apiKey,environmentVariableName:"ALIBABA_API_KEY",description:"Alibaba Cloud (DashScope)"})}`,...J.headers},`ai-sdk/alibaba/${SG}`),q=(N)=>{var X;return new KG(N,{provider:"alibaba.chat",baseURL:K,headers:z,fetch:J.fetch,includeUsage:(X=J.includeUsage)!=null?X:!0})},A=(N)=>new wG(N,{provider:"alibaba.video",baseURL:j,headers:z,fetch:J.fetch}),Z=function(N){if(new.target)throw Error("The Alibaba model function cannot be called with the new keyword.");return q(N)};return Z.specificationVersion="v3",Z.languageModel=q,Z.chatModel=q,Z.video=A,Z.videoModel=A,Z.imageModel=(N)=>{throw new m({modelId:N,modelType:"imageModel"})},Z.embeddingModel=(N)=>{throw new m({modelId:N,modelType:"embeddingModel"})},Z}var gG=DG();export{DG as createAlibaba,gG as alibaba,SG as VERSION};
|
|
2
|
+
import{Aq as v,Bq as k,Hq as b,Iq as R,Jq as XG,Kq as I,Oq as d,Pp as V,Rp as l,Vp as e,Wp as t,dq as a,iq as o,jq as GG,mq as JG,qq as NG,tq as QG,yq as g}from"./chunk-bf146hz2.js";import{Qq as f,Wq as C,_q as m,br as O}from"./chunk-t488d66k.js";import"./chunk-cqtkxwd8.js";import"./chunk-srf73nm4.js";import{Pu as G}from"./chunk-r7xp0xcn.js";import"./chunk-6g3m7yxf.js";import"./chunk-hh4c02fh.js";function c(J){var Q,$,K,j,z,q;if(J==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let A=(Q=J.prompt_tokens)!=null?Q:0,Z=($=J.completion_tokens)!=null?$:0,N=(j=(K=J.prompt_tokens_details)==null?void 0:K.cached_tokens)!=null?j:0,X=(q=(z=J.completion_tokens_details)==null?void 0:z.reasoning_tokens)!=null?q:0;return{inputTokens:{total:A,noCache:A-N,cacheRead:N,cacheWrite:void 0},outputTokens:{total:Z,text:Z-X,reasoning:X},raw:J}}function _(J){switch(J){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"other"}}function u({id:J,model:Q,created:$}){return{id:J!=null?J:void 0,modelId:Q!=null?Q:void 0,timestamp:$!=null?new Date($*1000):void 0}}function i({tools:J,toolChoice:Q}){J=(J==null?void 0:J.length)?J:void 0;let $=[];if(J==null)return{tools:void 0,toolChoice:void 0,toolWarnings:$};let K=[];for(let z of J)if(z.type==="provider")$.push({type:"unsupported",feature:`provider-defined tool ${z.id}`});else K.push({type:"function",function:{name:z.name,description:z.description,parameters:z.inputSchema,...z.strict!=null?{strict:z.strict}:{}}});if(Q==null)return{tools:K,toolChoice:void 0,toolWarnings:$};let j=Q.type;switch(j){case"auto":case"none":case"required":return{tools:K,toolChoice:j,toolWarnings:$};case"tool":return{tools:K,toolChoice:{type:"function",function:{name:Q.toolName}},toolWarnings:$};default:throw new O({functionality:`tool choice type: ${j}`})}}var $G=G.object({enableThinking:G.boolean().optional(),thinkingBudget:G.number().positive().optional(),parallelToolCalls:G.boolean().optional()});function p(J){var Q,$,K,j;let z=c(J),q=($=(Q=J==null?void 0:J.prompt_tokens_details)==null?void 0:Q.cache_creation_input_tokens)!=null?$:0,A=((K=z.inputTokens.total)!=null?K:0)-((j=z.inputTokens.cacheRead)!=null?j:0)-q;return{...z,inputTokens:{...z.inputTokens,cacheWrite:q,noCache:A}}}function zG({data:J,mediaType:Q}){return J instanceof URL?J.toString():`data:${Q};base64,${t(J)}`}function BG({prompt:J,cacheControlValidator:Q}){var $,K;let j=[];for(let{role:z,content:q,...A}of J){let Z=Q==null?void 0:Q.getCacheControl(A.providerOptions);switch(z){case"system":{if(Z)j.push({role:"system",content:[{type:"text",text:q,cache_control:Z}]});else j.push({role:"system",content:q});break}case"user":{j.push({role:"user",content:q.map((N,X)=>{var E;let L=X===q.length-1,B=(E=Q==null?void 0:Q.getCacheControl(N.providerOptions))!=null?E:L?Z:void 0;switch(N.type){case"text":return{type:"text",text:N.text,...B?{cache_control:B}:{}};case"file":if(N.mediaType.startsWith("image/")){let U=N.mediaType==="image/*"?"image/jpeg":N.mediaType;return{type:"image_url",image_url:{url:zG({data:N.data,mediaType:U})},...B?{cache_control:B}:{}}}else throw new O({functionality:"Only image file parts are supported"})}})});break}case"assistant":{let N="",X=[];for(let E of q)switch(E.type){case"text":{N+=E.text;break}case"tool-call":{X.push({id:E.toolCallId,type:"function",function:{name:E.toolName,arguments:JSON.stringify(E.input)}});break}case"reasoning":{N+=E.text;break}}j.push({role:"assistant",content:Z?[{type:"text",text:N,cache_control:Z}]:N||null,tool_calls:X.length>0?X:void 0});break}case"tool":{let N=q.filter((X)=>X.type!=="tool-approval-response");for(let X=0;X<N.length;X++){let E=N[X],L=E.output,B=X===N.length-1,U=($=Q==null?void 0:Q.getCacheControl(E.providerOptions))!=null?$:B?Z:void 0,Y;switch(L.type){case"text":case"error-text":Y=L.value;break;case"execution-denied":Y=(K=L.reason)!=null?K:"Tool execution denied.";break;case"content":case"json":case"error-json":Y=JSON.stringify(L.value);break}j.push({role:"tool",tool_call_id:E.toolCallId,content:U?[{type:"text",text:Y,cache_control:U}]:Y})}break}default:throw Error(`Unsupported role: ${z}`)}}return j}var r=4;function EG(J){var Q;let $=J==null?void 0:J.alibaba;return(Q=$==null?void 0:$.cacheControl)!=null?Q:$==null?void 0:$.cache_control}var jG=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(J){let Q=EG(J);if(!Q)return;if(this.breakpointCount++,this.breakpointCount>r)this.warnings.push({type:"other",message:`Max breakpoint limit exceeded. Only the last ${r} cache markers will take effect.`});return Q}getWarnings(){return this.warnings}},KG=class{constructor(J,Q){this.specificationVersion="v3",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=J,this.config=Q}get provider(){return this.config.provider}async getArgs({prompt:J,maxOutputTokens:Q,temperature:$,topP:K,topK:j,frequencyPenalty:z,presencePenalty:q,stopSequences:A,responseFormat:Z,seed:N,providerOptions:X,tools:E,toolChoice:L}){var B;let U=[],Y=new jG,P=await v({provider:"alibaba",providerOptions:X,schema:$G});if(z!=null)U.push({type:"unsupported",feature:"frequencyPenalty"});let w={model:this.modelId,max_tokens:Q,temperature:$,top_p:K,top_k:j,presence_penalty:q,stop:A,seed:N,response_format:(Z==null?void 0:Z.type)==="json"?Z.schema!=null?{type:"json_schema",json_schema:{schema:Z.schema,name:(B=Z.name)!=null?B:"response",description:Z.description}}:{type:"json_object"}:void 0,...(P==null?void 0:P.enableThinking)!=null?{enable_thinking:P.enableThinking}:{},...(P==null?void 0:P.thinkingBudget)!=null?{thinking_budget:P.thinkingBudget}:{},messages:BG({prompt:J,cacheControlValidator:Y})},{tools:y,toolChoice:S,toolWarnings:F}=i({tools:E,toolChoice:L});return U.push(...Y.getWarnings()),{args:{...w,tools:y,tool_choice:S,...y!=null&&(P==null?void 0:P.parallelToolCalls)!==void 0?{parallel_tool_calls:P.parallelToolCalls}:{}},warnings:[...U,...F]}}async doGenerate(J){var Q;let{args:$,warnings:K}=await this.getArgs(J),{responseHeaders:j,value:z,rawValue:q}=await k({url:`${this.config.baseURL}/chat/completions`,headers:V(this.config.headers(),J.headers),body:$,failedResponseHandler:s,successfulResponseHandler:I(qG),abortSignal:J.abortSignal,fetch:this.config.fetch}),A=z.choices[0],Z=[],N=A.message.content;if(N!=null&&N.length>0)Z.push({type:"text",text:N});let X=A.message.reasoning_content;if(X!=null&&X.length>0)Z.push({type:"reasoning",text:X});if(A.message.tool_calls!=null)for(let E of A.message.tool_calls)Z.push({type:"tool-call",toolCallId:E.id,toolName:E.function.name,input:E.function.arguments});return{content:Z,finishReason:{unified:_(A.finish_reason),raw:(Q=A.finish_reason)!=null?Q:void 0},usage:p(z.usage),request:{body:JSON.stringify($)},response:{...u(z),headers:j,body:q},warnings:K}}async doStream(J){let{args:Q,warnings:$}=await this.getArgs(J),K={...Q,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},{responseHeaders:j,value:z}=await k({url:`${this.config.baseURL}/chat/completions`,headers:V(this.config.headers(),J.headers),body:K,failedResponseHandler:s,successfulResponseHandler:XG(AG),abortSignal:J.abortSignal,fetch:this.config.fetch}),q={unified:"other",raw:void 0},A=void 0,Z=!0,N=!1,X=null,E=[];return{stream:z.pipeThrough(new TransformStream({start(L){L.enqueue({type:"stream-start",warnings:$})},transform(L,B){var U,Y,P,w;if(J.includeRawChunks)B.enqueue({type:"raw",rawValue:L.rawValue});if(!L.success){B.enqueue({type:"error",error:L.error});return}let y=L.value;if(Z)Z=!1,B.enqueue({type:"response-metadata",...u(y)});if(y.usage!=null)A=y.usage;if(y.choices.length===0)return;let S=y.choices[0],F=S.delta;if(F.reasoning_content!=null&&F.reasoning_content.length>0){if(X==null){if(N)B.enqueue({type:"text-end",id:"0"}),N=!1;X=a(),B.enqueue({type:"reasoning-start",id:X})}B.enqueue({type:"reasoning-delta",id:X,delta:F.reasoning_content})}if(F.content!=null&&F.content.length>0){if(X!=null)B.enqueue({type:"reasoning-end",id:X}),X=null;if(!N)B.enqueue({type:"text-start",id:"0"}),N=!0;B.enqueue({type:"text-delta",id:"0",delta:F.content})}if(F.tool_calls!=null){if(X!=null)B.enqueue({type:"reasoning-end",id:X}),X=null;if(N)B.enqueue({type:"text-end",id:"0"}),N=!1;for(let W of F.tool_calls){let M=(U=W.index)!=null?U:E.length;if(E[M]==null){if(W.id==null)throw new C({data:W,message:"Expected 'id' to be a string."});if(((Y=W.function)==null?void 0:Y.name)==null)throw new C({data:W,message:"Expected 'function.name' to be a string."});B.enqueue({type:"tool-input-start",id:W.id,toolName:W.function.name}),E[M]={id:W.id,type:"function",function:{name:W.function.name,arguments:(P=W.function.arguments)!=null?P:""},hasFinished:!1};let D=E[M];if(D.function.arguments.length>0)B.enqueue({type:"tool-input-delta",id:D.id,delta:D.function.arguments});if(g(D.function.arguments))B.enqueue({type:"tool-input-end",id:D.id}),B.enqueue({type:"tool-call",toolCallId:D.id,toolName:D.function.name,input:D.function.arguments}),D.hasFinished=!0;continue}let H=E[M];if(H.hasFinished)continue;if(((w=W.function)==null?void 0:w.arguments)!=null)H.function.arguments+=W.function.arguments,B.enqueue({type:"tool-input-delta",id:H.id,delta:W.function.arguments});if(g(H.function.arguments))B.enqueue({type:"tool-input-end",id:H.id}),B.enqueue({type:"tool-call",toolCallId:H.id,toolName:H.function.name,input:H.function.arguments}),H.hasFinished=!0}}if(S.finish_reason!=null)q={unified:_(S.finish_reason),raw:S.finish_reason}},flush(L){if(X!=null)L.enqueue({type:"reasoning-end",id:X});if(N)L.enqueue({type:"text-end",id:"0"});L.enqueue({type:"finish",finishReason:q,usage:p(A)})}})),request:{body:JSON.stringify(K)},response:{headers:j}}}},YG=G.object({prompt_tokens:G.number(),completion_tokens:G.number(),total_tokens:G.number(),prompt_tokens_details:G.object({cached_tokens:G.number().nullish(),cache_creation_input_tokens:G.number().nullish()}).nullish(),completion_tokens_details:G.object({reasoning_tokens:G.number().nullish()}).nullish()}),qG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({message:G.object({role:G.literal("assistant").nullish(),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({id:G.string(),type:G.literal("function"),function:G.object({name:G.string(),arguments:G.string()})})).nullish()}),finish_reason:G.string().nullish(),index:G.number()})),usage:YG.nullish()}),AG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({delta:G.object({role:G.enum(["assistant"]).nullish(),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({index:G.number().nullish(),id:G.string().nullish(),type:G.literal("function").nullish(),function:G.object({name:G.string().nullish(),arguments:G.string().nullish()}).nullish()})).nullish()}),finish_reason:G.string().nullish(),index:G.number()})),usage:YG.nullish()}),HG=NG(()=>QG(G.object({negativePrompt:G.string().nullish(),audioUrl:G.string().nullish(),promptExtend:G.boolean().nullish(),shotType:G.enum(["single","multi"]).nullish(),watermark:G.boolean().nullish(),audio:G.boolean().nullish(),referenceUrls:G.array(G.string()).nullish(),pollIntervalMs:G.number().positive().nullish(),pollTimeoutMs:G.number().positive().nullish()}).passthrough())),LG=G.object({code:G.string().nullish(),message:G.string(),request_id:G.string().nullish()}),n=R({errorSchema:LG,errorToMessage:(J)=>J.message}),PG=G.object({output:G.object({task_status:G.string(),task_id:G.string()}).nullish(),request_id:G.string().nullish()}),WG=G.object({output:G.object({task_id:G.string(),task_status:G.string(),video_url:G.string().nullish(),submit_time:G.string().nullish(),scheduled_time:G.string().nullish(),end_time:G.string().nullish(),orig_prompt:G.string().nullish(),actual_prompt:G.string().nullish(),code:G.string().nullish(),message:G.string().nullish()}).nullish(),usage:G.object({duration:G.number().nullish(),output_video_duration:G.number().nullish(),SR:G.number().nullish(),size:G.string().nullish()}).nullish(),request_id:G.string().nullish()});function UG(J){if(J.includes("-i2v"))return"i2v";if(J.includes("-r2v"))return"r2v";return"t2v"}var wG=class{constructor(J,Q){this.modelId=J,this.config=Q,this.specificationVersion="v3",this.maxVideosPerCall=1}get provider(){return this.config.provider}async doGenerate(J){var Q,$,K,j,z,q,A,Z,N,X,E;let L=(K=($=(Q=this.config._internal)==null?void 0:Q.currentDate)==null?void 0:$.call(Q))!=null?K:new Date,B=[],U=UG(this.modelId),Y=await v({provider:"alibaba",providerOptions:J.providerOptions,schema:HG}),P={};if(J.prompt!=null)P.prompt=J.prompt;if((Y==null?void 0:Y.negativePrompt)!=null)P.negative_prompt=Y.negativePrompt;if((Y==null?void 0:Y.audioUrl)!=null)P.audio_url=Y.audioUrl;if(U==="i2v"&&J.image!=null)if(J.image.type==="url")P.img_url=J.image.url;else{let x=typeof J.image.data==="string"?J.image.data:e(J.image.data);P.img_url=x}if(U==="r2v"&&(Y==null?void 0:Y.referenceUrls)!=null)P.reference_urls=Y.referenceUrls;let w={};if(J.duration!=null)w.duration=J.duration;if(J.seed!=null)w.seed=J.seed;if(J.resolution!=null)if(U==="i2v"){let x={"1280x720":"720P","720x1280":"720P","960x960":"720P","1088x832":"720P","832x1088":"720P","1920x1080":"1080P","1080x1920":"1080P","1440x1440":"1080P","1632x1248":"1080P","1248x1632":"1080P","832x480":"480P","480x832":"480P","624x624":"480P"};w.resolution=x[J.resolution]||J.resolution}else w.size=J.resolution.replace("x","*");if((Y==null?void 0:Y.promptExtend)!=null)w.prompt_extend=Y.promptExtend;if((Y==null?void 0:Y.shotType)!=null)w.shot_type=Y.shotType;if((Y==null?void 0:Y.watermark)!=null)w.watermark=Y.watermark;if((Y==null?void 0:Y.audio)!=null)w.audio=Y.audio;if(J.aspectRatio)B.push({type:"unsupported",feature:"aspectRatio",details:"Alibaba video models use explicit size/resolution dimensions. Use the resolution option or providerOptions.alibaba for size control."});if(J.fps)B.push({type:"unsupported",feature:"fps",details:"Alibaba video models do not support custom FPS."});if(J.n!=null&&J.n>1)B.push({type:"unsupported",feature:"n",details:"Alibaba video models only support generating 1 video per call."});let{value:y}=await k({url:`${this.config.baseURL}/api/v1/services/aigc/video-generation/video-synthesis`,headers:V(await b(this.config.headers),J.headers,{"X-DashScope-Async":"enable"}),body:{model:this.modelId,input:P,parameters:w},successfulResponseHandler:I(PG),failedResponseHandler:n,abortSignal:J.abortSignal,fetch:this.config.fetch}),S=(j=y.output)==null?void 0:j.task_id;if(!S)throw new f({name:"ALIBABA_VIDEO_GENERATION_ERROR",message:`No task_id returned from Alibaba API. Response: ${JSON.stringify(y)}`});let F=(z=Y==null?void 0:Y.pollIntervalMs)!=null?z:5000,W=(q=Y==null?void 0:Y.pollTimeoutMs)!=null?q:600000,M=Date.now(),H,D;while(!0){if(await l(F,{abortSignal:J.abortSignal}),Date.now()-M>W)throw new f({name:"ALIBABA_VIDEO_GENERATION_TIMEOUT",message:`Video generation timed out after ${W}ms`});let{value:x,responseHeaders:ZG}=await GG({url:`${this.config.baseURL}/api/v1/tasks/${S}`,headers:V(await b(this.config.headers),J.headers),successfulResponseHandler:I(WG),failedResponseHandler:n,abortSignal:J.abortSignal,fetch:this.config.fetch});D=ZG;let T=(A=x.output)==null?void 0:A.task_status;if(T==="SUCCEEDED"){H=x;break}if(T==="FAILED"||T==="CANCELED")throw new f({name:"ALIBABA_VIDEO_GENERATION_FAILED",message:`Video generation ${T.toLowerCase()}. Task ID: ${S}. ${(N=(Z=x.output)==null?void 0:Z.message)!=null?N:""}`})}let h=(X=H==null?void 0:H.output)==null?void 0:X.video_url;if(!h)throw new f({name:"ALIBABA_VIDEO_GENERATION_ERROR",message:`No video URL in response. Task ID: ${S}`});return{videos:[{type:"url",url:h,mediaType:"video/mp4"}],warnings:B,response:{timestamp:L,modelId:this.modelId,headers:D},providerMetadata:{alibaba:{taskId:S,videoUrl:h,...((E=H==null?void 0:H.output)==null?void 0:E.actual_prompt)?{actualPrompt:H.output.actual_prompt}:{},...(H==null?void 0:H.usage)?{usage:{duration:H.usage.duration,outputVideoDuration:H.usage.output_video_duration,resolution:H.usage.SR,size:H.usage.size}}:{}}}}}},SG="1.0.17",FG=G.object({error:G.object({message:G.string(),code:G.string().nullish(),type:G.string().nullish()})}),s=R({errorSchema:FG,errorToMessage:(J)=>J.error.message});function DG(J={}){var Q,$;let K=(Q=d(J.baseURL))!=null?Q:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",j=($=d(J.videoBaseURL))!=null?$:"https://dashscope-intl.aliyuncs.com",z=()=>o({Authorization:`Bearer ${JG({apiKey:J.apiKey,environmentVariableName:"ALIBABA_API_KEY",description:"Alibaba Cloud (DashScope)"})}`,...J.headers},`ai-sdk/alibaba/${SG}`),q=(N)=>{var X;return new KG(N,{provider:"alibaba.chat",baseURL:K,headers:z,fetch:J.fetch,includeUsage:(X=J.includeUsage)!=null?X:!0})},A=(N)=>new wG(N,{provider:"alibaba.video",baseURL:j,headers:z,fetch:J.fetch}),Z=function(N){if(new.target)throw Error("The Alibaba model function cannot be called with the new keyword.");return q(N)};return Z.specificationVersion="v3",Z.languageModel=q,Z.chatModel=q,Z.video=A,Z.videoModel=A,Z.imageModel=(N)=>{throw new m({modelId:N,modelType:"imageModel"})},Z.embeddingModel=(N)=>{throw new m({modelId:N,modelType:"embeddingModel"})},Z}var gG=DG();export{DG as createAlibaba,gG as alibaba,SG as VERSION};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ag as k,Bg as l,Cg as m,Dg as n,qg as a,rg as b,sg as c,tg as d,ug as e,vg as f,wg as g,xg as h,yg as i,zg as j}from"./chunk-4aykrj51.js";import"./chunk-j1a64ade.js";import"./chunk-kkvb2c2z.js";import"./chunk-dkv2mg97.js";import"./chunk-1p34bx7c.js";import"./chunk-q3x4x2tq.js";import"./chunk-tsn1jkr7.js";import"./chunk-zk8n8hnh.js";import"./chunk-1jh5p5qw.js";import"./chunk-kaeyhw2n.js";import"./chunk-f89gntcy.js";import"./chunk-bky5a42k.js";import"./chunk-r7xp0xcn.js";import"./chunk-6g3m7yxf.js";import"./chunk-v2kyarwz.js";import"./chunk-dkm7x8rj.js";import"./chunk-hh4c02fh.js";export{e as resolveDevicePoll,j as refreshAccessToken,i as probeToken,k as loginDevice,m as loginBrowser,l as login,c as isReplitEnv,g as isNearExpiry,d as getConfig,f as getCallbackUri,h as fetchQreditsBalance,n as checkoutApiKey,a as ForgewiseError,b as DeviceFlowUnsupportedError};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{n as
|
|
2
|
+
import{pf as u}from"./chunk-yh174jhg.js";import{CP as Kq,zP as Q}from"./chunk-hh4c02fh.js";var D=Q((iq,j)=>{var{defineProperty:X,getOwnPropertyDescriptor:r,getOwnPropertyNames:o}=Object,a=Object.prototype.hasOwnProperty,t=(q,z)=>X(q,"name",{value:z,configurable:!0}),qq=(q,z)=>{for(var G in z)X(q,G,{get:z[G],enumerable:!0})},zq=(q,z,G,K)=>{if(z&&typeof z==="object"||typeof z==="function"){for(let I of o(z))if(!a.call(q,I)&&I!==G)X(q,I,{get:()=>z[I],enumerable:!(K=r(z,I))||K.enumerable})}return q},Gq=(q)=>zq(X({},"__esModule",{value:!0}),q),J={};qq(J,{isArrayBuffer:()=>Iq});j.exports=Gq(J);var Iq=t((q)=>typeof ArrayBuffer==="function"&&q instanceof ArrayBuffer||Object.prototype.toString.call(q)==="[object ArrayBuffer]","isArrayBuffer")});var O=Q((dq,R)=>{var{defineProperty:Y,getOwnPropertyDescriptor:Qq,getOwnPropertyNames:Vq}=Object,Wq=Object.prototype.hasOwnProperty,E=(q,z)=>Y(q,"name",{value:z,configurable:!0}),Xq=(q,z)=>{for(var G in z)Y(q,G,{get:z[G],enumerable:!0})},Yq=(q,z,G,K)=>{if(z&&typeof z==="object"||typeof z==="function"){for(let I of Vq(z))if(!Wq.call(q,I)&&I!==G)Y(q,I,{get:()=>z[I],enumerable:!(K=Qq(z,I))||K.enumerable})}return q},Zq=(q)=>Yq(Y({},"__esModule",{value:!0}),q),L={};Xq(L,{fromArrayBuffer:()=>Nq,fromString:()=>Fq});R.exports=Zq(L);var $q=D(),$=Kq("buffer"),Nq=E((q,z=0,G=q.byteLength-z)=>{if(!(0,$q.isArrayBuffer)(q))throw TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof q} (${q})`);return $.Buffer.from(q,z,G)},"fromArrayBuffer"),Fq=E((q,z)=>{if(typeof q!=="string")throw TypeError(`The "input" argument must be of type string. Received type ${typeof q} (${q})`);return z?$.Buffer.from(q,z):$.Buffer.from(q)},"fromString")});var A=Q((mq,h)=>{var{defineProperty:Z,getOwnPropertyDescriptor:Hq,getOwnPropertyNames:Bq}=Object,Jq=Object.prototype.hasOwnProperty,N=(q,z)=>Z(q,"name",{value:z,configurable:!0}),jq=(q,z)=>{for(var G in z)Z(q,G,{get:z[G],enumerable:!0})},Dq=(q,z,G,K)=>{if(z&&typeof z==="object"||typeof z==="function"){for(let I of Bq(z))if(!Jq.call(q,I)&&I!==G)Z(q,I,{get:()=>z[I],enumerable:!(K=Hq(z,I))||K.enumerable})}return q},Eq=(q)=>Dq(Z({},"__esModule",{value:!0}),q),v={};jq(v,{fromUtf8:()=>S,toUint8Array:()=>Lq,toUtf8:()=>Rq});h.exports=Eq(v);var M=O(),S=N((q)=>{let z=(0,M.fromString)(q,"utf8");return new Uint8Array(z.buffer,z.byteOffset,z.byteLength/Uint8Array.BYTES_PER_ELEMENT)},"fromUtf8"),Lq=N((q)=>{if(typeof q==="string")return S(q);if(ArrayBuffer.isView(q))return new Uint8Array(q.buffer,q.byteOffset,q.byteLength/Uint8Array.BYTES_PER_ELEMENT);return new Uint8Array(q)},"toUint8Array"),Rq=N((q)=>{if(typeof q==="string")return q;if(typeof q!=="object"||typeof q.byteOffset!=="number"||typeof q.byteLength!=="number")throw Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return(0,M.fromArrayBuffer)(q.buffer,q.byteOffset,q.byteLength).toString("utf8")},"toUtf8")});var w=Q((C)=>{Object.defineProperty(C,"__esModule",{value:!0});C.convertToBuffer=void 0;var Oq=A(),vq=typeof Buffer<"u"&&Buffer.from?function(q){return Buffer.from(q,"utf8")}:Oq.fromUtf8;function Mq(q){if(q instanceof Uint8Array)return q;if(typeof q==="string")return vq(q);if(ArrayBuffer.isView(q))return new Uint8Array(q.buffer,q.byteOffset,q.byteLength/Uint8Array.BYTES_PER_ELEMENT);return new Uint8Array(q)}C.convertToBuffer=Mq});var U=Q((P)=>{Object.defineProperty(P,"__esModule",{value:!0});P.isEmptyData=void 0;function Sq(q){if(typeof q==="string")return q.length===0;return q.byteLength===0}P.isEmptyData=Sq});var y=Q((b)=>{Object.defineProperty(b,"__esModule",{value:!0});b.numToUint8=void 0;function hq(q){return new Uint8Array([(q&4278190080)>>24,(q&16711680)>>16,(q&65280)>>8,q&255])}b.numToUint8=hq});var l=Q((x)=>{Object.defineProperty(x,"__esModule",{value:!0});x.uint32ArrayFrom=void 0;function Aq(q){if(!Uint32Array.from){var z=new Uint32Array(q.length),G=0;while(G<q.length)z[G]=q[G],G+=1;return z}return Uint32Array.from(q)}x.uint32ArrayFrom=Aq});var F=Q((V)=>{Object.defineProperty(V,"__esModule",{value:!0});V.uint32ArrayFrom=V.numToUint8=V.isEmptyData=V.convertToBuffer=void 0;var Cq=w();Object.defineProperty(V,"convertToBuffer",{enumerable:!0,get:function(){return Cq.convertToBuffer}});var Tq=U();Object.defineProperty(V,"isEmptyData",{enumerable:!0,get:function(){return Tq.isEmptyData}});var wq=y();Object.defineProperty(V,"numToUint8",{enumerable:!0,get:function(){return wq.numToUint8}});var Pq=l();Object.defineProperty(V,"uint32ArrayFrom",{enumerable:!0,get:function(){return Pq.uint32ArrayFrom}})});var m=Q((i)=>{Object.defineProperty(i,"__esModule",{value:!0});i.AwsCrc32=void 0;var s=u(),H=F(),f=n(),Uq=function(){function q(){this.crc32=new f.Crc32}return q.prototype.update=function(z){if((0,H.isEmptyData)(z))return;this.crc32.update((0,H.convertToBuffer)(z))},q.prototype.digest=function(){return s.__awaiter(this,void 0,void 0,function(){return s.__generator(this,function(z){return[2,(0,H.numToUint8)(this.crc32.digest())]})})},q.prototype.reset=function(){this.crc32=new f.Crc32},q}();i.AwsCrc32=Uq});var n=Q((B)=>{Object.defineProperty(B,"__esModule",{value:!0});B.AwsCrc32=B.Crc32=B.crc32=void 0;var bq=u(),gq=F();function yq(q){return new p().update(q).digest()}B.crc32=yq;var p=function(){function q(){this.checksum=4294967295}return q.prototype.update=function(z){var G,K;try{for(var I=bq.__values(z),W=I.next();!W.done;W=I.next()){var _=W.value;this.checksum=this.checksum>>>8^cq[(this.checksum^_)&255]}}catch(e){G={error:e}}finally{try{if(W&&!W.done&&(K=I.return))K.call(I)}finally{if(G)throw G.error}}return this},q.prototype.digest=function(){return(this.checksum^4294967295)>>>0},q}();B.Crc32=p;var xq=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918000,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],cq=(0,gq.uint32ArrayFrom)(xq),lq=m();Object.defineProperty(B,"AwsCrc32",{enumerable:!0,get:function(){return lq.AwsCrc32}})});
|
|
3
|
+
export{n as of};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{rh as a,sh as b}from"./chunk-va4davgy.js";import"./chunk-hg563h5r.js";import"./chunk-j1a64ade.js";import"./chunk-bd21p9zz.js";import"./chunk-p54bzjtv.js";import"./chunk-ha1w0xzh.js";import"./chunk-ecwz9nhs.js";import"./chunk-5rkmhzq0.js";import"./chunk-7mhffm9f.js";import"./chunk-r012q335.js";import"./chunk-0z3z0gk1.js";import"./chunk-g7vkkmsk.js";import"./chunk-m8djypsy.js";import"./chunk-w7p2x973.js";import"./chunk-wmw2gne9.js";import"./chunk-y3n31nnx.js";import"./chunk-3z1y040p.js";import"./chunk-kkvb2c2z.js";import"./chunk-3tdqsm5c.js";import"./chunk-a5zjrwqy.js";import"./chunk-fhng5her.js";import"./chunk-dkv2mg97.js";import"./chunk-bf146hz2.js";import"./chunk-t488d66k.js";import"./chunk-cqtkxwd8.js";import"./chunk-srf73nm4.js";import"./chunk-yzdty5t9.js";import"./chunk-1p34bx7c.js";import"./chunk-q3x4x2tq.js";import"./chunk-7dckfame.js";import"./chunk-j1veq3zr.js";import"./chunk-0pvbk8ks.js";import"./chunk-tk3bve0x.js";import"./chunk-0w4v0fbs.js";import"./chunk-wf09j72q.js";import"./chunk-hbnr0j7h.js";import"./chunk-ep8zn49w.js";import"./chunk-f3kjp838.js";import"./chunk-tsn1jkr7.js";import"./chunk-zk8n8hnh.js";import"./chunk-1jh5p5qw.js";import"./chunk-kaeyhw2n.js";import"./chunk-f89gntcy.js";import"./chunk-bky5a42k.js";import"./chunk-r7xp0xcn.js";import"./chunk-6g3m7yxf.js";import"./chunk-v2kyarwz.js";import"./chunk-dkm7x8rj.js";import"./chunk-9pe4agdz.js";import"./chunk-kc3hpmr2.js";import"./chunk-hh4c02fh.js";export{b as AppRuntime,a as AppLayer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{g as G}from"./chunk-vavrczqm.js";import{E as x,F,G as Z}from"./chunk-d56zc21w.js";import"./chunk-mjhb1q0n.js";import{Pd as P}from"./chunk-9xvctnjr.js";import{Tf as j}from"./chunk-gen6f3dn.js";import{xg as v}from"./chunk-4aykrj51.js";import{sh as X}from"./chunk-va4davgy.js";import"./chunk-hg563h5r.js";import"./chunk-j1a64ade.js";import"./chunk-bd21p9zz.js";import"./chunk-p54bzjtv.js";import"./chunk-ha1w0xzh.js";import"./chunk-ecwz9nhs.js";import"./chunk-5rkmhzq0.js";import{xj as $}from"./chunk-7mhffm9f.js";import"./chunk-r012q335.js";import"./chunk-0z3z0gk1.js";import"./chunk-g7vkkmsk.js";import"./chunk-m8djypsy.js";import"./chunk-w7p2x973.js";import"./chunk-wmw2gne9.js";import"./chunk-y3n31nnx.js";import"./chunk-3z1y040p.js";import"./chunk-kkvb2c2z.js";import"./chunk-3tdqsm5c.js";import"./chunk-a5zjrwqy.js";import"./chunk-fhng5her.js";import"./chunk-dkv2mg97.js";import"./chunk-bf146hz2.js";import"./chunk-t488d66k.js";import"./chunk-cqtkxwd8.js";import"./chunk-srf73nm4.js";import"./chunk-yzdty5t9.js";import"./chunk-1p34bx7c.js";import"./chunk-q3x4x2tq.js";import"./chunk-7dckfame.js";import"./chunk-j1veq3zr.js";import"./chunk-0pvbk8ks.js";import"./chunk-tk3bve0x.js";import"./chunk-0w4v0fbs.js";import"./chunk-wf09j72q.js";import"./chunk-hbnr0j7h.js";import"./chunk-ep8zn49w.js";import"./chunk-f3kjp838.js";import"./chunk-tsn1jkr7.js";import"./chunk-zk8n8hnh.js";import"./chunk-1jh5p5qw.js";import"./chunk-kaeyhw2n.js";import"./chunk-f89gntcy.js";import"./chunk-bky5a42k.js";import"./chunk-r7xp0xcn.js";import"./chunk-6g3m7yxf.js";import"./chunk-v2kyarwz.js";import{mI as D}from"./chunk-dkm7x8rj.js";import"./chunk-9pe4agdz.js";import"./chunk-kc3hpmr2.js";import"./chunk-hh4c02fh.js";var Y="forgewise";function _(J){return D.gen(function*(){let z=yield*J.get(Y);if(!z||z.type!=="api")return null;let M=(z.metadata??{}).sub,V=z.key;if(!M)return null;return{sub:M,accessToken:V}})}var H=()=>D.gen(function*(){if((yield*G())==="revoked")return null;let J=yield*$.Service,z=yield*_(J);if(!z)return yield*D.sync(()=>j.println(j.Style.TEXT_DANGER+"Not signed in to Forgewise. Run `qitqode auth login` first."+j.Style.TEXT_NORMAL)),null;return z}),k=()=>D.gen(function*(){let J=yield*H();if(!J)return;let z=yield*D.tryPromise({try:()=>v(J.accessToken),catch:()=>null}).pipe(D.orElseSucceed(()=>null));if(!z){yield*D.sync(()=>j.println(j.Style.TEXT_DANGER+"Could not fetch balance."+j.Style.TEXT_NORMAL));return}yield*D.sync(()=>j.println(j.Style.TEXT_SUCCESS+"Qredits balance: "+j.Style.TEXT_NORMAL+j.Style.TEXT_HIGHLIGHT_BOLD+Z(z.balance)+j.Style.TEXT_NORMAL))}).pipe(D.withSpan("qredits.balance")),w=()=>D.gen(function*(){let J=yield*H();if(!J)return;let z=yield*D.tryPromise({try:()=>F({userId:J.sub,accessToken:J.accessToken,limit:20}),catch:(L)=>L});if(z instanceof Error){let L=z instanceof x?z.message:String(z);yield*D.sync(()=>j.println(j.Style.TEXT_DANGER+"Could not fetch history: "+L+j.Style.TEXT_NORMAL));return}if(z.length===0){yield*D.sync(()=>j.println("No spend history yet."));return}let N=j.Style.TEXT_DIM,M=j.Style.TEXT_NORMAL,V=j.Style.TEXT_DANGER;yield*D.sync(()=>{j.println(N+" Date Description Amount"+M),j.println(N+" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500"+M);for(let L of z){let K=(L.date||"").slice(0,10).padEnd(18),O=(L.description||"").slice(0,32).padEnd(32),T=(L.amount<0?"-":" ")+Z(Math.abs(L.amount)),W=L.amount<0?V:M;j.println(` ${N}${K}${M} ${O} ${W}${T}${M}`)}})}).pipe(D.withSpan("qredits.history")),g=P({command:"qredits <command>",describe:"Check Qredits balance and spend history",builder:(J)=>J.command(P({command:"balance",describe:"Show current Qredits balance",builder:(z)=>z,async handler(){j.empty(),await X.runPromise(k())}})).command(P({command:"history",describe:"Show recent Qredit spend history",builder:(z)=>z,async handler(){j.empty(),await X.runPromise(w())}})).demandCommand(),async handler(){}});export{w as historyEffect,k as balanceEffect,g as QreditsCommand};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Qq as j,Rq as M,Sq as f,Uq as N,Xq as H,Yq as z,Zq as A,ar as I,fr as t}from"./chunk-t488d66k.js";import{gr as U}from"./chunk-srf73nm4.js";import{tu as n}from"./chunk-r7xp0xcn.js";import{Dz as d}from"./chunk-6g3m7yxf.js";function NJ(...F){return F.reduce((J,Q)=>({...J,...Q!=null?Q:{}}),{})}function VJ({tools:F=[],providerToolNames:J,resolveProviderToolName:Q}){var W;let X={},Y={};for(let Z of F)if(Z.type==="provider"){let $=(W=Q==null?void 0:Q(Z))!=null?W:(Z.id in J)?J[Z.id]:void 0;if($==null)continue;X[Z.name]=$,Y[$]=Z.name}return{toProviderToolName:(Z)=>{var $;return($=X[Z])!=null?$:Z},toCustomToolName:(Z)=>{var $;return($=Y[Z])!=null?$:Z}}}function B(F){return Object.fromEntries([...F.headers])}var{btoa:$F,atob:LF}=globalThis;function TJ(F){let J=F.replace(/-/g,"+").replace(/_/g,"/"),Q=LF(J);return Uint8Array.from(Q,(W)=>W.codePointAt(0))}function o(F){let J="";for(let Q=0;Q<F.length;Q++)J+=String.fromCodePoint(F[Q]);return $F(J)}function _J(F){return F instanceof Uint8Array?o(F):F}function jJ(F){if(F.type==="url")return F.url;return`data:${F.mediaType};base64,${typeof F.data==="string"?F.data:o(F.data)}`}function kJ(F,J={}){let{useArrayBrackets:Q=!0}=J,W=new FormData;for(let[X,Y]of Object.entries(F)){if(Y==null)continue;if(Array.isArray(Y)){if(Y.length===1){W.append(X,Y[0]);continue}let Z=Q?`${X}[]`:X;for(let $ of Y)W.append(Z,$);continue}W.append(X,Y)}return W}var a="AI_DownloadError",s=`vercel.ai.error.${a}`,UF=Symbol.for(s),m,u,O=class extends(u=j,m=UF,u){constructor({url:F,statusCode:J,statusText:Q,cause:W,message:X=W==null?`Failed to download ${F}: ${J} ${Q}`:`Failed to download ${F}: ${W}`}){super({name:a,message:X,cause:W});this[m]=!0,this.url=F,this.statusCode=J,this.statusText=Q}static isInstance(F){return j.hasMarker(F,s)}},r=2147483648;async function wF({response:F,url:J,maxBytes:Q=r}){let W=F.headers.get("content-length");if(W!=null){let G=parseInt(W,10);if(!isNaN(G)&&G>Q)throw new O({url:J,message:`Download of ${J} exceeded maximum size of ${Q} bytes (Content-Length: ${G}).`})}let X=F.body;if(X==null)return new Uint8Array(0);let Y=X.getReader(),Z=[],$=0;try{while(!0){let{done:G,value:R}=await Y.read();if(G)break;if($+=R.length,$>Q)throw new O({url:J,message:`Download of ${J} exceeded maximum size of ${Q} bytes.`});Z.push(R)}}finally{try{await Y.cancel()}finally{Y.releaseLock()}}let w=new Uint8Array($),L=0;for(let G of Z)w.set(G,L),L+=G.length;return w}function i(F){let J;try{J=new URL(F)}catch(W){throw new O({url:F,message:`Invalid URL: ${F}`})}if(J.protocol!=="http:"&&J.protocol!=="https:")throw new O({url:F,message:`URL scheme must be http or https, got ${J.protocol}`});let Q=J.hostname;if(!Q)throw new O({url:F,message:"URL must have a hostname"});if(Q==="localhost"||Q.endsWith(".local")||Q.endsWith(".localhost"))throw new O({url:F,message:`URL with hostname ${Q} is not allowed`});if(Q.startsWith("[")&&Q.endsWith("]")){let W=Q.slice(1,-1);if(EF(W))throw new O({url:F,message:`URL with IPv6 address ${Q} is not allowed`});return}if(e(Q)){if(k(Q))throw new O({url:F,message:`URL with IP address ${Q} is not allowed`});return}}function e(F){let J=F.split(".");if(J.length!==4)return!1;return J.every((Q)=>{let W=Number(Q);return Number.isInteger(W)&&W>=0&&W<=255&&String(W)===Q})}function k(F){let J=F.split(".").map(Number),[Q,W]=J;if(Q===0)return!0;if(Q===10)return!0;if(Q===127)return!0;if(Q===169&&W===254)return!0;if(Q===172&&W>=16&&W<=31)return!0;if(Q===192&&W===168)return!0;return!1}function EF(F){let J=F.toLowerCase();if(J==="::1")return!0;if(J==="::")return!0;if(J.startsWith("::ffff:")){let Q=J.slice(7);if(e(Q))return k(Q);let W=Q.split(":");if(W.length===2){let X=parseInt(W[0],16),Y=parseInt(W[1],16);if(!isNaN(X)&&!isNaN(Y)){let Z=X>>8&255,$=X&255,w=Y>>8&255,L=Y&255;return k(`${Z}.${$}.${w}.${L}`)}}}if(J.startsWith("fc")||J.startsWith("fd"))return!0;if(J.startsWith("fe80"))return!0;return!1}async function SJ(F,J){var Q,W;i(F);try{let X=await fetch(F,{signal:J==null?void 0:J.abortSignal});if(X.redirected)i(X.url);if(!X.ok)throw new O({url:F,statusCode:X.status,statusText:X.statusText});let Y=await wF({response:X,url:F,maxBytes:(Q=J==null?void 0:J.maxBytes)!=null?Q:r}),Z=(W=X.headers.get("content-type"))!=null?W:void 0;return new Blob([Y],Z?{type:Z}:void 0)}catch(X){if(O.isInstance(X))throw X;throw new O({url:F,cause:X})}}var GF=({prefix:F,size:J=16,alphabet:Q="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:W="-"}={})=>{let X=()=>{let Y=Q.length,Z=Array(J);for(let $=0;$<J;$++)Z[$]=Q[Math.random()*Y|0];return Z.join("")};if(F==null)return X;if(Q.includes(W))throw new N({argument:"separator",message:`The separator "${W}" must not be part of the alphabet "${Q}".`});return()=>`${F}${W}${X()}`},xJ=GF();function b(F){return(F instanceof Error||F instanceof DOMException)&&(F.name==="AbortError"||F.name==="ResponseAborted"||F.name==="TimeoutError")}var CF=["fetch failed","failed to fetch"],MF=["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE"];function KF(F){if(!(F instanceof Error))return!1;let J=F.code;if(typeof J==="string"&&MF.includes(J))return!0;return!1}function qF({error:F,url:J,requestBodyValues:Q}){if(b(F))return F;if(F instanceof TypeError&&CF.includes(F.message.toLowerCase())){let W=F.cause;if(W!=null)return new M({message:`Cannot connect to API: ${W.message}`,cause:W,url:J,requestBodyValues:Q,isRetryable:!0})}if(KF(F))return new M({message:`Cannot connect to API: ${F.message}`,cause:F,url:J,requestBodyValues:Q,isRetryable:!0});return F}function DF(F=globalThis){var J,Q,W;if(F.window)return"runtime/browser";if((J=F.navigator)==null?void 0:J.userAgent)return`runtime/${F.navigator.userAgent.toLowerCase()}`;if((W=(Q=F.process)==null?void 0:Q.versions)==null?void 0:W.node)return`runtime/node.js/${F.process.version.substring(0)}`;if(F.EdgeRuntime)return"runtime/vercel-edge";return"runtime/unknown"}function OF(F){if(F==null)return{};let J={};if(F instanceof Headers)F.forEach((Q,W)=>{J[W.toLowerCase()]=Q});else{if(!Array.isArray(F))F=Object.entries(F);for(let[Q,W]of F)if(W!=null)J[Q.toLowerCase()]=W}return J}function IF(F,...J){let Q=new Headers(OF(F)),W=Q.get("user-agent")||"";return Q.set("user-agent",[W,...J].filter(Boolean).join(" ")),Object.fromEntries(Q.entries())}var PF="4.0.21";var zF="JSON schema:",AF="You MUST answer with a JSON object that matches the JSON schema above.",HF="You MUST answer with JSON.";function BF({prompt:F,schema:J,schemaPrefix:Q=J!=null?zF:void 0,schemaSuffix:W=J!=null?AF:HF}){return[F!=null&&F.length>0?F:void 0,F!=null&&F.length>0?"":void 0,Q,J!=null?JSON.stringify(J):void 0,W].filter((X)=>X!=null).join(`
|
|
3
3
|
`)}function yJ({messages:F,schema:J,schemaPrefix:Q,schemaSuffix:W}){var X,Y;let Z=((X=F[0])==null?void 0:X.role)==="system"?{...F[0]}:{role:"system",content:""};return Z.content=BF({prompt:Z.content,schema:J,schemaPrefix:Q,schemaSuffix:W}),[Z,...((Y=F[0])==null?void 0:Y.role)==="system"?F.slice(1):F]}function hJ(F){return F!=null}function uJ({apiKey:F,environmentVariableName:J,apiKeyParameterName:Q="apiKey",description:W}){if(typeof F==="string")return F;if(F!=null)throw new z({message:`${W} API key must be a string.`});if(typeof process>"u")throw new z({message:`${W} API key is missing. Pass it using the '${Q}' parameter. Environment variables is not supported in this environment.`});if(F=process.env[J],F==null)throw new z({message:`${W} API key is missing. Pass it using the '${Q}' parameter or the ${J} environment variable.`});if(typeof F!=="string")throw new z({message:`${W} API key must be a string. The value of the ${J} environment variable is not a string.`});return F}function pJ({settingValue:F,environmentVariableName:J,settingName:Q,description:W}){if(typeof F==="string")return F;if(F!=null)throw new A({message:`${W} setting must be a string.`});if(typeof process>"u")throw new A({message:`${W} setting is missing. Pass it using the '${Q}' parameter. Environment variables is not supported in this environment.`});if(F=process.env[J],F==null)throw new A({message:`${W} setting is missing. Pass it using the '${Q}' parameter or the ${J} environment variable.`});if(typeof F!=="string")throw new A({message:`${W} setting must be a string. The value of the ${J} environment variable is not a string.`});return F}function lJ(F){var J;let[Q,W=""]=F.toLowerCase().split("/");return(J={mpeg:"mp3","x-wav":"wav",opus:"ogg",mp4:"m4a","x-m4a":"m4a"}[W])!=null?J:W}var RF=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,NF=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function p(F){let J=JSON.parse(F);if(J===null||typeof J!=="object")return J;if(RF.test(F)===!1&&NF.test(F)===!1)return J;return VF(J)}function VF(F){let J=[F];while(J.length){let Q=J;J=[];for(let W of Q){if(Object.prototype.hasOwnProperty.call(W,"__proto__"))throw SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(W,"constructor")&&W.constructor!==null&&typeof W.constructor==="object"&&Object.prototype.hasOwnProperty.call(W.constructor,"prototype"))throw SyntaxError("Object contains forbidden prototype property");for(let X in W){let Y=W[X];if(Y&&typeof Y==="object")J.push(Y)}}}return F}function x(F){let{stackTraceLimit:J}=Error;try{Error.stackTraceLimit=0}catch(Q){return p(F)}try{return p(F)}finally{Error.stackTraceLimit=J}}function v(F){if(F.type==="object"||Array.isArray(F.type)&&F.type.includes("object")){F.additionalProperties=!1;let{properties:Q}=F;if(Q!=null)for(let W of Object.keys(Q))Q[W]=P(Q[W])}if(F.items!=null)F.items=Array.isArray(F.items)?F.items.map(P):P(F.items);if(F.anyOf!=null)F.anyOf=F.anyOf.map(P);if(F.allOf!=null)F.allOf=F.allOf.map(P);if(F.oneOf!=null)F.oneOf=F.oneOf.map(P);let{definitions:J}=F;if(J!=null)for(let Q of Object.keys(J))J[Q]=P(J[Q]);return F}function P(F){if(typeof F==="boolean")return F;return v(F)}var TF=Symbol("Let zodToJsonSchema decide on which parser to use"),l={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},_F=(F)=>typeof F==="string"?{...l,name:F}:{...l,...F};function K(){return{}}function jF(F,J){var Q,W,X;let Y={type:"array"};if(((Q=F.type)==null?void 0:Q._def)&&((X=(W=F.type)==null?void 0:W._def)==null?void 0:X.typeName)!==U.ZodAny)Y.items=E(F.type._def,{...J,currentPath:[...J.currentPath,"items"]});if(F.minLength)Y.minItems=F.minLength.value;if(F.maxLength)Y.maxItems=F.maxLength.value;if(F.exactLength)Y.minItems=F.exactLength.value,Y.maxItems=F.exactLength.value;return Y}function kF(F){let J={type:"integer",format:"int64"};if(!F.checks)return J;for(let Q of F.checks)switch(Q.kind){case"min":if(Q.inclusive)J.minimum=Q.value;else J.exclusiveMinimum=Q.value;break;case"max":if(Q.inclusive)J.maximum=Q.value;else J.exclusiveMaximum=Q.value;break;case"multipleOf":J.multipleOf=Q.value;break}return J}function bF(){return{type:"boolean"}}function FF(F,J){return E(F.type._def,J)}var SF=(F,J)=>{return E(F.innerType._def,J)};function JF(F,J,Q){let W=Q!=null?Q:J.dateStrategy;if(Array.isArray(W))return{anyOf:W.map((X,Y)=>JF(F,J,X))};switch(W){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return gF(F)}}var gF=(F)=>{let J={type:"integer",format:"unix-time"};for(let Q of F.checks)switch(Q.kind){case"min":J.minimum=Q.value;break;case"max":J.maximum=Q.value;break}return J};function xF(F,J){return{...E(F.innerType._def,J),default:F.defaultValue()}}function vF(F,J){return J.effectStrategy==="input"?E(F.schema._def,J):K()}function yF(F){return{type:"string",enum:Array.from(F.values)}}var hF=(F)=>{if("type"in F&&F.type==="string")return!1;return"allOf"in F};function mF(F,J){let Q=[E(F.left._def,{...J,currentPath:[...J.currentPath,"allOf","0"]}),E(F.right._def,{...J,currentPath:[...J.currentPath,"allOf","1"]})].filter((X)=>!!X),W=[];return Q.forEach((X)=>{if(hF(X))W.push(...X.allOf);else{let Y=X;if("additionalProperties"in X&&X.additionalProperties===!1){let{additionalProperties:Z,...$}=X;Y=$}W.push(Y)}}),W.length?{allOf:W}:void 0}function uF(F){let J=typeof F.value;if(J!=="bigint"&&J!=="number"&&J!=="boolean"&&J!=="string")return{type:Array.isArray(F.value)?"array":"object"};return{type:J==="bigint"?"integer":J,const:F.value}}var T=void 0,q={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(T===void 0)T=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return T},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function QF(F,J){let Q={type:"string"};if(F.checks)for(let W of F.checks)switch(W.kind){case"min":Q.minLength=typeof Q.minLength==="number"?Math.max(Q.minLength,W.value):W.value;break;case"max":Q.maxLength=typeof Q.maxLength==="number"?Math.min(Q.maxLength,W.value):W.value;break;case"email":switch(J.emailStrategy){case"format:email":D(Q,"email",W.message,J);break;case"format:idn-email":D(Q,"idn-email",W.message,J);break;case"pattern:zod":C(Q,q.email,W.message,J);break}break;case"url":D(Q,"uri",W.message,J);break;case"uuid":D(Q,"uuid",W.message,J);break;case"regex":C(Q,W.regex,W.message,J);break;case"cuid":C(Q,q.cuid,W.message,J);break;case"cuid2":C(Q,q.cuid2,W.message,J);break;case"startsWith":C(Q,RegExp(`^${_(W.value,J)}`),W.message,J);break;case"endsWith":C(Q,RegExp(`${_(W.value,J)}$`),W.message,J);break;case"datetime":D(Q,"date-time",W.message,J);break;case"date":D(Q,"date",W.message,J);break;case"time":D(Q,"time",W.message,J);break;case"duration":D(Q,"duration",W.message,J);break;case"length":Q.minLength=typeof Q.minLength==="number"?Math.max(Q.minLength,W.value):W.value,Q.maxLength=typeof Q.maxLength==="number"?Math.min(Q.maxLength,W.value):W.value;break;case"includes":{C(Q,RegExp(_(W.value,J)),W.message,J);break}case"ip":{if(W.version!=="v6")D(Q,"ipv4",W.message,J);if(W.version!=="v4")D(Q,"ipv6",W.message,J);break}case"base64url":C(Q,q.base64url,W.message,J);break;case"jwt":C(Q,q.jwt,W.message,J);break;case"cidr":{if(W.version!=="v6")C(Q,q.ipv4Cidr,W.message,J);if(W.version!=="v4")C(Q,q.ipv6Cidr,W.message,J);break}case"emoji":C(Q,q.emoji(),W.message,J);break;case"ulid":{C(Q,q.ulid,W.message,J);break}case"base64":{switch(J.base64Strategy){case"format:binary":{D(Q,"binary",W.message,J);break}case"contentEncoding:base64":{Q.contentEncoding="base64";break}case"pattern:zod":{C(Q,q.base64,W.message,J);break}}break}case"nanoid":C(Q,q.nanoid,W.message,J);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return Q}function _(F,J){return J.patternStrategy==="escape"?pF(F):F}var iF=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function pF(F){let J="";for(let Q=0;Q<F.length;Q++){if(!iF.has(F[Q]))J+="\\";J+=F[Q]}return J}function D(F,J,Q,W){var X;if(F.format||((X=F.anyOf)==null?void 0:X.some((Y)=>Y.format))){if(!F.anyOf)F.anyOf=[];if(F.format)F.anyOf.push({format:F.format}),delete F.format;F.anyOf.push({format:J,...Q&&W.errorMessages&&{errorMessage:{format:Q}}})}else F.format=J}function C(F,J,Q,W){var X;if(F.pattern||((X=F.allOf)==null?void 0:X.some((Y)=>Y.pattern))){if(!F.allOf)F.allOf=[];if(F.pattern)F.allOf.push({pattern:F.pattern}),delete F.pattern;F.allOf.push({pattern:c(J,W),...Q&&W.errorMessages&&{errorMessage:{pattern:Q}}})}else F.pattern=c(J,W)}function c(F,J){var Q;if(!J.applyRegexFlags||!F.flags)return F.source;let W={i:F.flags.includes("i"),m:F.flags.includes("m"),s:F.flags.includes("s")},X=W.i?F.source.toLowerCase():F.source,Y="",Z=!1,$=!1,w=!1;for(let L=0;L<X.length;L++){if(Z){Y+=X[L],Z=!1;continue}if(W.i){if($){if(X[L].match(/[a-z]/)){if(w)Y+=X[L],Y+=`${X[L-2]}-${X[L]}`.toUpperCase(),w=!1;else if(X[L+1]==="-"&&((Q=X[L+2])==null?void 0:Q.match(/[a-z]/)))Y+=X[L],w=!0;else Y+=`${X[L]}${X[L].toUpperCase()}`;continue}}else if(X[L].match(/[a-z]/)){Y+=`[${X[L]}${X[L].toUpperCase()}]`;continue}}if(W.m){if(X[L]==="^"){Y+=`(^|(?<=[\r
|
|
4
4
|
]))`;continue}else if(X[L]==="$"){Y+=`($|(?=[\r
|
|
5
5
|
]))`;continue}}if(W.s&&X[L]==="."){Y+=$?`${X[L]}\r
|
|
6
6
|
`:`[${X[L]}\r
|
|
7
7
|
]`;continue}if(Y+=X[L],X[L]==="\\")Z=!0;else if($&&X[L]==="]")$=!1;else if(!$&&X[L]==="[")$=!0}try{new RegExp(Y)}catch(L){return console.warn(`Could not convert regex pattern at ${J.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),F.source}return Y}function WF(F,J){var Q,W,X,Y,Z,$;let w={type:"object",additionalProperties:(Q=E(F.valueType._def,{...J,currentPath:[...J.currentPath,"additionalProperties"]}))!=null?Q:J.allowedAdditionalProperties};if(((W=F.keyType)==null?void 0:W._def.typeName)===U.ZodString&&((X=F.keyType._def.checks)==null?void 0:X.length)){let{type:L,...G}=QF(F.keyType._def,J);return{...w,propertyNames:G}}else if(((Y=F.keyType)==null?void 0:Y._def.typeName)===U.ZodEnum)return{...w,propertyNames:{enum:F.keyType._def.values}};else if(((Z=F.keyType)==null?void 0:Z._def.typeName)===U.ZodBranded&&F.keyType._def.type._def.typeName===U.ZodString&&(($=F.keyType._def.type._def.checks)==null?void 0:$.length)){let{type:L,...G}=FF(F.keyType._def,J);return{...w,propertyNames:G}}return w}function lF(F,J){if(J.mapStrategy==="record")return WF(F,J);let Q=E(F.keyType._def,{...J,currentPath:[...J.currentPath,"items","items","0"]})||K(),W=E(F.valueType._def,{...J,currentPath:[...J.currentPath,"items","items","1"]})||K();return{type:"array",maxItems:125,items:{type:"array",items:[Q,W],minItems:2,maxItems:2}}}function cF(F){let J=F.values,W=Object.keys(F.values).filter((Y)=>{return typeof J[J[Y]]!=="number"}).map((Y)=>J[Y]),X=Array.from(new Set(W.map((Y)=>typeof Y)));return{type:X.length===1?X[0]==="string"?"string":"number":["string","number"],enum:W}}function dF(){return{not:K()}}function nF(){return{type:"null"}}var S={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function fF(F,J){let Q=F.options instanceof Map?Array.from(F.options.values()):F.options;if(Q.every((W)=>(W._def.typeName in S)&&(!W._def.checks||!W._def.checks.length))){let W=Q.reduce((X,Y)=>{let Z=S[Y._def.typeName];return Z&&!X.includes(Z)?[...X,Z]:X},[]);return{type:W.length>1?W:W[0]}}else if(Q.every((W)=>W._def.typeName==="ZodLiteral"&&!W.description)){let W=Q.reduce((X,Y)=>{let Z=typeof Y._def.value;switch(Z){case"string":case"number":case"boolean":return[...X,Z];case"bigint":return[...X,"integer"];case"object":if(Y._def.value===null)return[...X,"null"];case"symbol":case"undefined":case"function":default:return X}},[]);if(W.length===Q.length){let X=W.filter((Y,Z,$)=>$.indexOf(Y)===Z);return{type:X.length>1?X:X[0],enum:Q.reduce((Y,Z)=>{return Y.includes(Z._def.value)?Y:[...Y,Z._def.value]},[])}}}else if(Q.every((W)=>W._def.typeName==="ZodEnum"))return{type:"string",enum:Q.reduce((W,X)=>[...W,...X._def.values.filter((Y)=>!W.includes(Y))],[])};return tF(F,J)}var tF=(F,J)=>{let Q=(F.options instanceof Map?Array.from(F.options.values()):F.options).map((W,X)=>E(W._def,{...J,currentPath:[...J.currentPath,"anyOf",`${X}`]})).filter((W)=>!!W&&(!J.strictUnions||typeof W==="object"&&Object.keys(W).length>0));return Q.length?{anyOf:Q}:void 0};function oF(F,J){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(F.innerType._def.typeName)&&(!F.innerType._def.checks||!F.innerType._def.checks.length))return{type:[S[F.innerType._def.typeName],"null"]};let Q=E(F.innerType._def,{...J,currentPath:[...J.currentPath,"anyOf","0"]});return Q&&{anyOf:[Q,{type:"null"}]}}function aF(F){let J={type:"number"};if(!F.checks)return J;for(let Q of F.checks)switch(Q.kind){case"int":J.type="integer";break;case"min":if(Q.inclusive)J.minimum=Q.value;else J.exclusiveMinimum=Q.value;break;case"max":if(Q.inclusive)J.maximum=Q.value;else J.exclusiveMaximum=Q.value;break;case"multipleOf":J.multipleOf=Q.value;break}return J}function sF(F,J){let Q={type:"object",properties:{}},W=[],X=F.shape();for(let Z in X){let $=X[Z];if($===void 0||$._def===void 0)continue;let w=eF($),L=E($._def,{...J,currentPath:[...J.currentPath,"properties",Z],propertyPath:[...J.currentPath,"properties",Z]});if(L===void 0)continue;if(Q.properties[Z]=L,!w)W.push(Z)}if(W.length)Q.required=W;let Y=rF(F,J);if(Y!==void 0)Q.additionalProperties=Y;return Q}function rF(F,J){if(F.catchall._def.typeName!=="ZodNever")return E(F.catchall._def,{...J,currentPath:[...J.currentPath,"additionalProperties"]});switch(F.unknownKeys){case"passthrough":return J.allowedAdditionalProperties;case"strict":return J.rejectedAdditionalProperties;case"strip":return J.removeAdditionalStrategy==="strict"?J.allowedAdditionalProperties:J.rejectedAdditionalProperties}}function eF(F){try{return F.isOptional()}catch(J){return!0}}var FJ=(F,J)=>{var Q;if(J.currentPath.toString()===((Q=J.propertyPath)==null?void 0:Q.toString()))return E(F.innerType._def,J);let W=E(F.innerType._def,{...J,currentPath:[...J.currentPath,"anyOf","1"]});return W?{anyOf:[{not:K()},W]}:K()},JJ=(F,J)=>{if(J.pipeStrategy==="input")return E(F.in._def,J);else if(J.pipeStrategy==="output")return E(F.out._def,J);let Q=E(F.in._def,{...J,currentPath:[...J.currentPath,"allOf","0"]}),W=E(F.out._def,{...J,currentPath:[...J.currentPath,"allOf",Q?"1":"0"]});return{allOf:[Q,W].filter((X)=>X!==void 0)}};function QJ(F,J){return E(F.type._def,J)}function WJ(F,J){let W={type:"array",uniqueItems:!0,items:E(F.valueType._def,{...J,currentPath:[...J.currentPath,"items"]})};if(F.minSize)W.minItems=F.minSize.value;if(F.maxSize)W.maxItems=F.maxSize.value;return W}function XJ(F,J){if(F.rest)return{type:"array",minItems:F.items.length,items:F.items.map((Q,W)=>E(Q._def,{...J,currentPath:[...J.currentPath,"items",`${W}`]})).reduce((Q,W)=>W===void 0?Q:[...Q,W],[]),additionalItems:E(F.rest._def,{...J,currentPath:[...J.currentPath,"additionalItems"]})};else return{type:"array",minItems:F.items.length,maxItems:F.items.length,items:F.items.map((Q,W)=>E(Q._def,{...J,currentPath:[...J.currentPath,"items",`${W}`]})).reduce((Q,W)=>W===void 0?Q:[...Q,W],[])}}function YJ(){return{not:K()}}function ZJ(){return K()}var $J=(F,J)=>{return E(F.innerType._def,J)},LJ=(F,J,Q)=>{switch(J){case U.ZodString:return QF(F,Q);case U.ZodNumber:return aF(F);case U.ZodObject:return sF(F,Q);case U.ZodBigInt:return kF(F);case U.ZodBoolean:return bF();case U.ZodDate:return JF(F,Q);case U.ZodUndefined:return YJ();case U.ZodNull:return nF();case U.ZodArray:return jF(F,Q);case U.ZodUnion:case U.ZodDiscriminatedUnion:return fF(F,Q);case U.ZodIntersection:return mF(F,Q);case U.ZodTuple:return XJ(F,Q);case U.ZodRecord:return WF(F,Q);case U.ZodLiteral:return uF(F);case U.ZodEnum:return yF(F);case U.ZodNativeEnum:return cF(F);case U.ZodNullable:return oF(F,Q);case U.ZodOptional:return FJ(F,Q);case U.ZodMap:return lF(F,Q);case U.ZodSet:return WJ(F,Q);case U.ZodLazy:return()=>F.getter()._def;case U.ZodPromise:return QJ(F,Q);case U.ZodNaN:case U.ZodNever:return dF();case U.ZodEffects:return vF(F,Q);case U.ZodAny:return K();case U.ZodUnknown:return ZJ();case U.ZodDefault:return xF(F,Q);case U.ZodBranded:return FF(F,Q);case U.ZodReadonly:return $J(F,Q);case U.ZodCatch:return SF(F,Q);case U.ZodPipeline:return JJ(F,Q);case U.ZodFunction:case U.ZodVoid:case U.ZodSymbol:return;default:return((W)=>{return})(J)}},UJ=(F,J)=>{let Q=0;for(;Q<F.length&&Q<J.length;Q++)if(F[Q]!==J[Q])break;return[(F.length-Q).toString(),...J.slice(Q)].join("/")};function E(F,J,Q=!1){var W;let X=J.seen.get(F);if(J.override){let w=(W=J.override)==null?void 0:W.call(J,F,J,X,Q);if(w!==TF)return w}if(X&&!Q){let w=wJ(X,J);if(w!==void 0)return w}let Y={def:F,path:J.currentPath,jsonSchema:void 0};J.seen.set(F,Y);let Z=LJ(F,F.typeName,J),$=typeof Z==="function"?E(Z(),J):Z;if($)EJ(F,J,$);if(J.postProcess){let w=J.postProcess($,F,J);return Y.jsonSchema=$,w}return Y.jsonSchema=$,$}var wJ=(F,J)=>{switch(J.$refStrategy){case"root":return{$ref:F.path.join("/")};case"relative":return{$ref:UJ(J.currentPath,F.path)};case"none":case"seen":{if(F.path.length<J.currentPath.length&&F.path.every((Q,W)=>J.currentPath[W]===Q))return console.warn(`Recursive reference detected at ${J.currentPath.join("/")}! Defaulting to any`),K();return J.$refStrategy==="seen"?K():void 0}}},EJ=(F,J,Q)=>{if(F.description)Q.description=F.description;return Q},GJ=(F)=>{let J=_F(F),Q=J.name!==void 0?[...J.basePath,J.definitionPath,J.name]:J.basePath;return{...J,currentPath:Q,propertyPath:void 0,seen:new Map(Object.entries(J.definitions).map(([W,X])=>[X._def,{def:X._def,path:[...J.basePath,J.definitionPath,W],jsonSchema:void 0}]))}},CJ=(F,J)=>{var Q;let W=GJ(J),X=typeof J==="object"&&J.definitions?Object.entries(J.definitions).reduce((L,[G,R])=>{var h;return{...L,[G]:(h=E(R._def,{...W,currentPath:[...W.basePath,W.definitionPath,G]},!0))!=null?h:K()}},{}):void 0,Y=typeof J==="string"?J:(J==null?void 0:J.nameStrategy)==="title"?void 0:J==null?void 0:J.name,Z=(Q=E(F._def,Y===void 0?W:{...W,currentPath:[...W.basePath,W.definitionPath,Y]},!1))!=null?Q:K(),$=typeof J==="object"&&J.name!==void 0&&J.nameStrategy==="title"?J.name:void 0;if($!==void 0)Z.title=$;let w=Y===void 0?X?{...Z,[W.definitionPath]:X}:Z:{$ref:[...W.$refStrategy==="relative"?[]:W.basePath,W.definitionPath,Y].join("/"),[W.definitionPath]:{...X,[Y]:Z}};return w.$schema="http://json-schema.org/draft-07/schema#",w},g=Symbol.for("vercel.ai.schema");function aJ(F){let J;return()=>{if(J==null)J=F();return J}}function V(F,{validate:J}={}){return{[g]:!0,_type:void 0,get jsonSchema(){if(typeof F==="function")F=F();return F},validate:J}}function MJ(F){return typeof F==="object"&&F!==null&&g in F&&F[g]===!0&&"jsonSchema"in F&&"validate"in F}function KJ(F){return F==null?V({properties:{},additionalProperties:!1}):MJ(F)?F:("~standard"in F)?F["~standard"].vendor==="zod"?PJ(F):qJ(F):F()}function qJ(F){return V(()=>v(F["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async(J)=>{let Q=await F["~standard"].validate(J);return"value"in Q?{success:!0,value:Q.value}:{success:!1,error:new I({value:J,cause:Q.issues})}}})}function DJ(F,J){var Q;let W=(Q=J==null?void 0:J.useReferences)!=null?Q:!1;return V(()=>CJ(F,{$refStrategy:W?"root":"none"}),{validate:async(X)=>{let Y=await F.safeParseAsync(X);return Y.success?{success:!0,value:Y.data}:{success:!1,error:Y.error}}})}function OJ(F,J){var Q;let W=(Q=J==null?void 0:J.useReferences)!=null?Q:!1;return V(()=>v(d(F,{target:"draft-7",io:"input",reused:W?"ref":"inline"})),{validate:async(X)=>{let Y=await n(F,X);return Y.success?{success:!0,value:Y.data}:{success:!1,error:Y.error}}})}function IJ(F){return"_zod"in F}function PJ(F,J){if(IJ(F))return OJ(F,J);else return DJ(F,J)}async function zJ({value:F,schema:J,context:Q}){let W=await y({value:F,schema:J,context:Q});if(!W.success)throw I.wrap({value:F,cause:W.error,context:Q});return W.value}async function y({value:F,schema:J,context:Q}){let W=KJ(J);try{if(W.validate==null)return{success:!0,value:F,rawValue:F};let X=await W.validate(F);if(X.success)return{success:!0,value:X.value,rawValue:F};return{success:!1,error:I.wrap({value:F,cause:X.error,context:Q}),rawValue:F}}catch(X){return{success:!1,error:I.wrap({value:F,cause:X,context:Q}),rawValue:F}}}async function AJ({text:F,schema:J}){try{let Q=x(F);if(J==null)return Q;return zJ({value:Q,schema:J})}catch(Q){if(H.isInstance(Q)||I.isInstance(Q))throw Q;throw new H({text:F,cause:Q})}}async function XF({text:F,schema:J}){try{let Q=x(F);if(J==null)return{success:!0,value:Q,rawValue:Q};return await y({value:Q,schema:J})}catch(Q){return{success:!1,error:H.isInstance(Q)?Q:new H({text:F,cause:Q}),rawValue:void 0}}}function sJ(F){try{return x(F),!0}catch(J){return!1}}function HJ({stream:F,schema:J}){return F.pipeThrough(new TextDecoderStream).pipeThrough(new t).pipeThrough(new TransformStream({async transform({data:Q},W){if(Q==="[DONE]")return;W.enqueue(await XF({text:Q,schema:J}))}}))}async function FQ({provider:F,providerOptions:J,schema:Q}){if((J==null?void 0:J[F])==null)return;let W=await y({value:J[F],schema:Q});if(!W.success)throw new N({argument:"providerOptions",message:`invalid ${F} provider options`,cause:W.error});return W.value}var BJ=()=>globalThis.fetch,QQ=async({url:F,headers:J,body:Q,failedResponseHandler:W,successfulResponseHandler:X,abortSignal:Y,fetch:Z})=>YF({url:F,headers:{"Content-Type":"application/json",...J},body:{content:JSON.stringify(Q),values:Q},failedResponseHandler:W,successfulResponseHandler:X,abortSignal:Y,fetch:Z}),WQ=async({url:F,headers:J,formData:Q,failedResponseHandler:W,successfulResponseHandler:X,abortSignal:Y,fetch:Z})=>YF({url:F,headers:J,body:{content:Q,values:Object.fromEntries(Q.entries())},failedResponseHandler:W,successfulResponseHandler:X,abortSignal:Y,fetch:Z}),YF=async({url:F,headers:J={},body:Q,successfulResponseHandler:W,failedResponseHandler:X,abortSignal:Y,fetch:Z=BJ()})=>{try{let $=await Z(F,{method:"POST",headers:IF(J,`ai-sdk/provider-utils/${PF}`,DF()),body:Q.content,signal:Y}),w=B($);if(!$.ok){let L;try{L=await X({response:$,url:F,requestBodyValues:Q.values})}catch(G){if(b(G)||M.isInstance(G))throw G;throw new M({message:"Failed to process error response",cause:G,statusCode:$.status,url:F,responseHeaders:w,requestBodyValues:Q.values})}throw L.value}try{return await W({response:$,url:F,requestBodyValues:Q.values})}catch(L){if(L instanceof Error){if(b(L)||M.isInstance(L))throw L}throw new M({message:"Failed to process successful response",cause:L,statusCode:$.status,url:F,responseHeaders:w,requestBodyValues:Q.values})}}catch($){throw qF({error:$,url:F,requestBodyValues:Q.values})}};function ZF(F){return F}function XQ({id:F,inputSchema:J}){return({execute:Q,outputSchema:W,needsApproval:X,toModelOutput:Y,onInputStart:Z,onInputDelta:$,onInputAvailable:w,...L})=>ZF({type:"provider",id:F,args:L,inputSchema:J,outputSchema:W,execute:Q,needsApproval:X,toModelOutput:Y,onInputStart:Z,onInputDelta:$,onInputAvailable:w})}function YQ({id:F,inputSchema:J,outputSchema:Q,supportsDeferredResults:W}){return({execute:X,needsApproval:Y,toModelOutput:Z,onInputStart:$,onInputDelta:w,onInputAvailable:L,...G})=>ZF({type:"provider",id:F,args:G,inputSchema:J,outputSchema:Q,execute:X,needsApproval:Y,toModelOutput:Z,onInputStart:$,onInputDelta:w,onInputAvailable:L,supportsDeferredResults:W})}var $Q=({errorSchema:F,errorToMessage:J,isRetryable:Q})=>async({response:W,url:X,requestBodyValues:Y})=>{let Z=await W.text(),$=B(W);if(Z.trim()==="")return{responseHeaders:$,value:new M({message:W.statusText,url:X,requestBodyValues:Y,statusCode:W.status,responseHeaders:$,responseBody:Z,isRetryable:Q==null?void 0:Q(W)})};try{let w=await AJ({text:Z,schema:F});return{responseHeaders:$,value:new M({message:J(w),url:X,requestBodyValues:Y,statusCode:W.status,responseHeaders:$,responseBody:Z,data:w,isRetryable:Q==null?void 0:Q(W,w)})}}catch(w){return{responseHeaders:$,value:new M({message:W.statusText,url:X,requestBodyValues:Y,statusCode:W.status,responseHeaders:$,responseBody:Z,isRetryable:Q==null?void 0:Q(W)})}}},LQ=(F)=>async({response:J})=>{let Q=B(J);if(J.body==null)throw new f({});return{responseHeaders:Q,value:HJ({stream:J.body,schema:F})}},UQ=(F)=>async({response:J,url:Q,requestBodyValues:W})=>{let X=await J.text(),Y=await XF({text:X,schema:F}),Z=B(J);if(!Y.success)throw new M({message:"Invalid JSON response",cause:Y.error,statusCode:J.status,responseHeaders:Z,responseBody:X,url:Q,requestBodyValues:W});return{responseHeaders:Z,value:Y.value,rawValue:Y.rawValue}},wQ=()=>async({response:F,url:J,requestBodyValues:Q})=>{let W=B(F);if(!F.body)throw new M({message:"Response body is empty",url:J,requestBodyValues:Q,statusCode:F.status,responseHeaders:W,responseBody:void 0});try{let X=await F.arrayBuffer();return{responseHeaders:W,value:new Uint8Array(X)}}catch(X){throw new M({message:"Failed to read response as array buffer",url:J,requestBodyValues:Q,statusCode:F.status,responseHeaders:W,responseBody:void 0,cause:X})}};function EQ(F){return F==null?void 0:F.replace(/\/$/,"")}
|
|
8
|
-
export{NJ as
|
|
8
|
+
export{NJ as Ee,VJ as Fe,TJ as Ge,o as He,_J as Ie,jJ as Je,kJ as Ke,SJ as Le,xJ as Me,IF as Ne,yJ as Oe,hJ as Pe,uJ as Qe,pJ as Re,lJ as Se,aJ as Te,PJ as Ue,zJ as Ve,AJ as We,sJ as Xe,FQ as Ye,QQ as Ze,WQ as _e,XQ as $e,YQ as af,$Q as bf,LQ as cf,UQ as df,wQ as ef,EQ as ff};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hr as a,Ir as b,Jr as c}from"./chunk-tk3bve0x.js";import"./chunk-0w4v0fbs.js";import"./chunk-wf09j72q.js";import"./chunk-zk8n8hnh.js";import"./chunk-1jh5p5qw.js";import"./chunk-kaeyhw2n.js";import"./chunk-f89gntcy.js";import"./chunk-bky5a42k.js";import"./chunk-r7xp0xcn.js";import"./chunk-6g3m7yxf.js";import"./chunk-v2kyarwz.js";import"./chunk-dkm7x8rj.js";import"./chunk-hh4c02fh.js";export{c as makeRuntime,a as attachWith,b as attach};
|