@opencode/core 0.0.0-reserved → 2.0.0
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/README.md +1 -3
- package/dist/account/sql.js +34 -0
- package/dist/agent.js +91 -0
- package/dist/aisdk-native.js +9 -0
- package/dist/aisdk.js +15 -0
- package/dist/app.js +18 -0
- package/dist/bus.js +93 -0
- package/dist/catalog.js +89 -0
- package/dist/chunks/aisdk-native-06x8he3q.js +18 -0
- package/dist/chunks/aisdk-native-0artwwxx.js +51 -0
- package/dist/chunks/aisdk-native-0cpfncfh.js +118 -0
- package/dist/chunks/aisdk-native-0fm13a2s.js +329 -0
- package/dist/chunks/aisdk-native-0mesazry.js +4 -0
- package/dist/chunks/aisdk-native-0nzv5c2w.js +39 -0
- package/dist/chunks/aisdk-native-0paq2nw3.js +28 -0
- package/dist/chunks/aisdk-native-0pb75hch.js +72 -0
- package/dist/chunks/aisdk-native-0q0f95c6.js +37 -0
- package/dist/chunks/aisdk-native-0qkdqm5v.js +12 -0
- package/dist/chunks/aisdk-native-0zkw76rk.js +0 -0
- package/dist/chunks/aisdk-native-111hscse.js +198 -0
- package/dist/chunks/aisdk-native-11nvngjf.js +544 -0
- package/dist/chunks/aisdk-native-15rsv8cs.js +123 -0
- package/dist/chunks/aisdk-native-17cy0kzp.js +17 -0
- package/dist/chunks/aisdk-native-1cnp2v09.js +25 -0
- package/dist/chunks/aisdk-native-1dazxqgg.js +154 -0
- package/dist/chunks/aisdk-native-1jdcek6j.js +202 -0
- package/dist/chunks/aisdk-native-1kg9ymc8.js +6 -0
- package/dist/chunks/aisdk-native-1x11rq2a.js +18 -0
- package/dist/chunks/aisdk-native-1xqm2dzv.js +56 -0
- package/dist/chunks/aisdk-native-219neeqh.js +35 -0
- package/dist/chunks/aisdk-native-21r38tys.js +14 -0
- package/dist/chunks/aisdk-native-21sebrtn.js +633 -0
- package/dist/chunks/aisdk-native-21vc9929.js +191 -0
- package/dist/chunks/aisdk-native-23279rje.js +31 -0
- package/dist/chunks/aisdk-native-2402vzrj.js +175 -0
- package/dist/chunks/aisdk-native-265kqrgy.js +28 -0
- package/dist/chunks/aisdk-native-2710q6r3.js +20 -0
- package/dist/chunks/aisdk-native-2a5m3afh.js +36 -0
- package/dist/chunks/aisdk-native-2axfhc9x.js +49 -0
- package/dist/chunks/aisdk-native-2c3vjs8z.js +17 -0
- package/dist/chunks/aisdk-native-2q85qjqp.js +31 -0
- package/dist/chunks/aisdk-native-2scecyhc.js +260 -0
- package/dist/chunks/aisdk-native-2se0afp6.js +213 -0
- package/dist/chunks/aisdk-native-2sqe2en6.js +374 -0
- package/dist/chunks/aisdk-native-3175eqdp.js +115 -0
- package/dist/chunks/aisdk-native-33f8ypwy.js +231 -0
- package/dist/chunks/aisdk-native-33n3bzdy.js +169 -0
- package/dist/chunks/aisdk-native-359p4xyc.js +25 -0
- package/dist/chunks/aisdk-native-35wynegs.js +170 -0
- package/dist/chunks/aisdk-native-361ty1x8.js +42 -0
- package/dist/chunks/aisdk-native-39dcxt5x.js +190 -0
- package/dist/chunks/aisdk-native-3asan66x.js +19 -0
- package/dist/chunks/aisdk-native-3fc6dm20.js +151 -0
- package/dist/chunks/aisdk-native-3hepkmqq.js +13 -0
- package/dist/chunks/aisdk-native-3smtnn6g.js +45 -0
- package/dist/chunks/aisdk-native-3tvqynh2.js +14 -0
- package/dist/chunks/aisdk-native-3v5c85g8.js +151 -0
- package/dist/chunks/aisdk-native-3v8g72cx.js +28 -0
- package/dist/chunks/aisdk-native-3w5fmr99.js +214 -0
- package/dist/chunks/aisdk-native-3wcehsnq.js +17 -0
- package/dist/chunks/aisdk-native-3wx0ktdp.js +117 -0
- package/dist/chunks/aisdk-native-3x8gcmrs.js +126 -0
- package/dist/chunks/aisdk-native-40s62c95.js +55 -0
- package/dist/chunks/aisdk-native-43n2bw4t.js +30 -0
- package/dist/chunks/aisdk-native-45smdebh.js +145 -0
- package/dist/chunks/aisdk-native-467byya2.js +59 -0
- package/dist/chunks/aisdk-native-4b9mceyk.js +96 -0
- package/dist/chunks/aisdk-native-4exee4de.js +49 -0
- package/dist/chunks/aisdk-native-4kkrbspp.js +226 -0
- package/dist/chunks/aisdk-native-4knz6hnm.js +22 -0
- package/dist/chunks/aisdk-native-4ns3h2re.js +49 -0
- package/dist/chunks/aisdk-native-4vcrnpx2.js +678 -0
- package/dist/chunks/aisdk-native-4y66k410.js +396 -0
- package/dist/chunks/aisdk-native-4y7fprxs.js +22 -0
- package/dist/chunks/aisdk-native-53557ph1.js +15 -0
- package/dist/chunks/aisdk-native-550bvhaj.js +17 -0
- package/dist/chunks/aisdk-native-5daktx2q.js +50 -0
- package/dist/chunks/aisdk-native-5pkvz399.js +190 -0
- package/dist/chunks/aisdk-native-5t3nmthw.js +32 -0
- package/dist/chunks/aisdk-native-607tc6va.js +16 -0
- package/dist/chunks/aisdk-native-62zc03d1.js +608 -0
- package/dist/chunks/aisdk-native-669tq793.js +15 -0
- package/dist/chunks/aisdk-native-686tv8fb.js +80 -0
- package/dist/chunks/aisdk-native-6aywe8nf.js +104 -0
- package/dist/chunks/aisdk-native-6fyvx278.js +43 -0
- package/dist/chunks/aisdk-native-6g46d628.js +24 -0
- package/dist/chunks/aisdk-native-6kyz0a76.js +440 -0
- package/dist/chunks/aisdk-native-6msgmcgs.js +75 -0
- package/dist/chunks/aisdk-native-6prwharc.js +16 -0
- package/dist/chunks/aisdk-native-6yxvt9sa.js +201 -0
- package/dist/chunks/aisdk-native-70d2s7af.js +33 -0
- package/dist/chunks/aisdk-native-71q4at8m.js +15 -0
- package/dist/chunks/aisdk-native-76xfeaks.js +193 -0
- package/dist/chunks/aisdk-native-7akdwqpd.js +16 -0
- package/dist/chunks/aisdk-native-7bmhse3q.js +118 -0
- package/dist/chunks/aisdk-native-7m9af43g.js +16 -0
- package/dist/chunks/aisdk-native-7zdm33ac.js +453 -0
- package/dist/chunks/aisdk-native-81rrwt6s.js +20 -0
- package/dist/chunks/aisdk-native-822emrt2.js +31 -0
- package/dist/chunks/aisdk-native-82asvwff.js +164 -0
- package/dist/chunks/aisdk-native-82j2mrwz.js +66 -0
- package/dist/chunks/aisdk-native-83nmqw0w.js +194 -0
- package/dist/chunks/aisdk-native-83s1p0p4.js +33 -0
- package/dist/chunks/aisdk-native-844ef7ks.js +32 -0
- package/dist/chunks/aisdk-native-87j3jmrh.js +193 -0
- package/dist/chunks/aisdk-native-88xbtdfr.js +14 -0
- package/dist/chunks/aisdk-native-8a24hghq.js +226 -0
- package/dist/chunks/aisdk-native-8d7r5vzw.js +106 -0
- package/dist/chunks/aisdk-native-8n3pysct.js +27 -0
- package/dist/chunks/aisdk-native-8p4f9s12.js +41 -0
- package/dist/chunks/aisdk-native-8qqh30s3.js +63 -0
- package/dist/chunks/aisdk-native-8qr4v3ea.js +101 -0
- package/dist/chunks/aisdk-native-8y0t5gr9.js +69 -0
- package/dist/chunks/aisdk-native-922hggd3.js +21 -0
- package/dist/chunks/aisdk-native-94s48bjb.js +185 -0
- package/dist/chunks/aisdk-native-9a4afbnw.js +17 -0
- package/dist/chunks/aisdk-native-9jdakqgh.js +148 -0
- package/dist/chunks/aisdk-native-9r7q4bhe.js +119 -0
- package/dist/chunks/aisdk-native-9rqn6x4v.js +16 -0
- package/dist/chunks/aisdk-native-9sjxd60t.js +37 -0
- package/dist/chunks/aisdk-native-9vfhq93a.js +304 -0
- package/dist/chunks/aisdk-native-9z45pttg.js +285 -0
- package/dist/chunks/aisdk-native-9zvzf66v.js +41 -0
- package/dist/chunks/aisdk-native-a1a50ys5.js +69 -0
- package/dist/chunks/aisdk-native-a1bz86dw.js +114 -0
- package/dist/chunks/aisdk-native-a5fqa70n.js +366 -0
- package/dist/chunks/aisdk-native-a6k6eb26.js +105 -0
- package/dist/chunks/aisdk-native-aaet6srn.js +170 -0
- package/dist/chunks/aisdk-native-ackkwfcq.js +89 -0
- package/dist/chunks/aisdk-native-af5trqkr.js +10 -0
- package/dist/chunks/aisdk-native-afrmfg78.js +16 -0
- package/dist/chunks/aisdk-native-ajy029q4.js +337 -0
- package/dist/chunks/aisdk-native-aqpgmyrr.js +63 -0
- package/dist/chunks/aisdk-native-aqzs7mqg.js +13 -0
- package/dist/chunks/aisdk-native-as4zy6vm.js +604 -0
- package/dist/chunks/aisdk-native-as531t2x.js +207 -0
- package/dist/chunks/aisdk-native-atq7p7m5.js +35 -0
- package/dist/chunks/aisdk-native-axpme2c5.js +77 -0
- package/dist/chunks/aisdk-native-b00gradr.js +194 -0
- package/dist/chunks/aisdk-native-b09hzw3k.js +65 -0
- package/dist/chunks/aisdk-native-b5vcnazb.js +36 -0
- package/dist/chunks/aisdk-native-b6gygkdw.js +83 -0
- package/dist/chunks/aisdk-native-bfexjxds.js +104 -0
- package/dist/chunks/aisdk-native-bkyjaxrp.js +32 -0
- package/dist/chunks/aisdk-native-bmr6ed5q.js +26 -0
- package/dist/chunks/aisdk-native-bp3wckns.js +84 -0
- package/dist/chunks/aisdk-native-bqaq7pjn.js +157 -0
- package/dist/chunks/aisdk-native-bqe1qhvg.js +184 -0
- package/dist/chunks/aisdk-native-btm2ep20.js +113 -0
- package/dist/chunks/aisdk-native-bxz5a0az.js +214 -0
- package/dist/chunks/aisdk-native-c8k0fn6w.js +335 -0
- package/dist/chunks/aisdk-native-cf4snx6d.js +107 -0
- package/dist/chunks/aisdk-native-cfpkc3c9.js +17 -0
- package/dist/chunks/aisdk-native-ch22x6z2.js +137 -0
- package/dist/chunks/aisdk-native-cjg4xdhd.js +35 -0
- package/dist/chunks/aisdk-native-cq37gk0t.js +173 -0
- package/dist/chunks/aisdk-native-cry8ta6n.js +1419 -0
- package/dist/chunks/aisdk-native-cvtmmhw6.js +32 -0
- package/dist/chunks/aisdk-native-cvy3z8tj.js +15 -0
- package/dist/chunks/aisdk-native-cxvbe4d1.js +170 -0
- package/dist/chunks/aisdk-native-d1g6sxjm.js +148 -0
- package/dist/chunks/aisdk-native-d9fn303g.js +29 -0
- package/dist/chunks/aisdk-native-d9jj8t3e.js +14 -0
- package/dist/chunks/aisdk-native-dajrwvna.js +6 -0
- package/dist/chunks/aisdk-native-dap0rakb.js +14 -0
- package/dist/chunks/aisdk-native-deehc0cj.js +162 -0
- package/dist/chunks/aisdk-native-df08tz66.js +13 -0
- package/dist/chunks/aisdk-native-dgf53888.js +182 -0
- package/dist/chunks/aisdk-native-dk95gbn1.js +184 -0
- package/dist/chunks/aisdk-native-dp3vq9x5.js +180 -0
- package/dist/chunks/aisdk-native-dy18nga0.js +0 -0
- package/dist/chunks/aisdk-native-e5kj55wp.js +13 -0
- package/dist/chunks/aisdk-native-e6hmchc5.js +98 -0
- package/dist/chunks/aisdk-native-e73j6tqm.js +38 -0
- package/dist/chunks/aisdk-native-e82z9tr0.js +50 -0
- package/dist/chunks/aisdk-native-ec1grn59.js +5 -0
- package/dist/chunks/aisdk-native-ees1bheg.js +22 -0
- package/dist/chunks/aisdk-native-eh3zwz77.js +31 -0
- package/dist/chunks/aisdk-native-em766tcz.js +80 -0
- package/dist/chunks/aisdk-native-emrn6kk6.js +100 -0
- package/dist/chunks/aisdk-native-es98n7aa.js +768 -0
- package/dist/chunks/aisdk-native-etq0c3wd.js +65 -0
- package/dist/chunks/aisdk-native-f0mxakyp.js +32 -0
- package/dist/chunks/aisdk-native-f6n9ztr4.js +58 -0
- package/dist/chunks/aisdk-native-f828m53h.js +18 -0
- package/dist/chunks/aisdk-native-faypxj3z.js +11 -0
- package/dist/chunks/aisdk-native-fd410y7t.js +13 -0
- package/dist/chunks/aisdk-native-fdv30zvt.js +21 -0
- package/dist/chunks/aisdk-native-fex1jrgj.js +61 -0
- package/dist/chunks/aisdk-native-fggaw9y4.js +38 -0
- package/dist/chunks/aisdk-native-fjc0rzqy.js +51 -0
- package/dist/chunks/aisdk-native-fx1wdxnv.js +470 -0
- package/dist/chunks/aisdk-native-fxbjtjnd.js +74 -0
- package/dist/chunks/aisdk-native-fxgpk5d8.js +146 -0
- package/dist/chunks/aisdk-native-g27wjat6.js +271 -0
- package/dist/chunks/aisdk-native-g4wezp1m.js +14 -0
- package/dist/chunks/aisdk-native-g5eyeasx.js +173 -0
- package/dist/chunks/aisdk-native-g86h250q.js +17 -0
- package/dist/chunks/aisdk-native-gbt8yvwm.js +86 -0
- package/dist/chunks/aisdk-native-gd0e60kd.js +323 -0
- package/dist/chunks/aisdk-native-gd4qta3r.js +25 -0
- package/dist/chunks/aisdk-native-ge3a0kr9.js +88 -0
- package/dist/chunks/aisdk-native-gebd4c9n.js +77 -0
- package/dist/chunks/aisdk-native-gfewnhh8.js +111 -0
- package/dist/chunks/aisdk-native-gftt206x.js +6 -0
- package/dist/chunks/aisdk-native-ghjjbadh.js +134 -0
- package/dist/chunks/aisdk-native-h03wrkyp.js +492 -0
- package/dist/chunks/aisdk-native-h05a6ep0.js +294 -0
- package/dist/chunks/aisdk-native-h251t0cq.js +480 -0
- package/dist/chunks/aisdk-native-h6t842eb.js +326 -0
- package/dist/chunks/aisdk-native-h6vf3j39.js +14 -0
- package/dist/chunks/aisdk-native-h7ch2b13.js +38 -0
- package/dist/chunks/aisdk-native-hamfyrt4.js +82 -0
- package/dist/chunks/aisdk-native-hf4q8sgp.js +74 -0
- package/dist/chunks/aisdk-native-hj31wtn3.js +137 -0
- package/dist/chunks/aisdk-native-hjbc5kem.js +13 -0
- package/dist/chunks/aisdk-native-hk9envan.js +25 -0
- package/dist/chunks/aisdk-native-hrnqkpcd.js +20 -0
- package/dist/chunks/aisdk-native-hyq5kv93.js +197 -0
- package/dist/chunks/aisdk-native-hzekcpqj.js +135 -0
- package/dist/chunks/aisdk-native-j2ntwpah.js +28 -0
- package/dist/chunks/aisdk-native-j56e64zr.js +40 -0
- package/dist/chunks/aisdk-native-j5zkgpj8.js +226 -0
- package/dist/chunks/aisdk-native-jghsd1wz.js +49 -0
- package/dist/chunks/aisdk-native-jr7sbwjy.js +15 -0
- package/dist/chunks/aisdk-native-jwfs4k6c.js +41 -0
- package/dist/chunks/aisdk-native-jwx4y25k.js +54 -0
- package/dist/chunks/aisdk-native-jx8g4evx.js +81 -0
- package/dist/chunks/aisdk-native-jz5sxy2v.js +21 -0
- package/dist/chunks/aisdk-native-jzg6c2d5.js +109 -0
- package/dist/chunks/aisdk-native-k8z4brtb.js +96 -0
- package/dist/chunks/aisdk-native-k996mbzp.js +260 -0
- package/dist/chunks/aisdk-native-kg06axw8.js +162 -0
- package/dist/chunks/aisdk-native-km19zyfq.js +207 -0
- package/dist/chunks/aisdk-native-kns4vs3f.js +49 -0
- package/dist/chunks/aisdk-native-kwn61asm.js +42 -0
- package/dist/chunks/aisdk-native-m9w0rfyh.js +123 -0
- package/dist/chunks/aisdk-native-mb3974r6.js +79 -0
- package/dist/chunks/aisdk-native-mfqp6xfm.js +64 -0
- package/dist/chunks/aisdk-native-mhkvc446.js +264 -0
- package/dist/chunks/aisdk-native-mjymc32g.js +41 -0
- package/dist/chunks/aisdk-native-mp448xyj.js +23 -0
- package/dist/chunks/aisdk-native-ms882c9x.js +76 -0
- package/dist/chunks/aisdk-native-msq0jde0.js +55 -0
- package/dist/chunks/aisdk-native-msx8hqn2.js +14 -0
- package/dist/chunks/aisdk-native-mz6ae2yf.js +32 -0
- package/dist/chunks/aisdk-native-n05xt0ee.js +19 -0
- package/dist/chunks/aisdk-native-n09f2zd2.js +325 -0
- package/dist/chunks/aisdk-native-n0xcs1rn.js +71 -0
- package/dist/chunks/aisdk-native-n3j8tn72.js +13 -0
- package/dist/chunks/aisdk-native-n88zggmf.js +318 -0
- package/dist/chunks/aisdk-native-nhqh66qs.js +34 -0
- package/dist/chunks/aisdk-native-njntx4h6.js +31 -0
- package/dist/chunks/aisdk-native-p2fyeaa4.js +74 -0
- package/dist/chunks/aisdk-native-p33ejz0k.js +257 -0
- package/dist/chunks/aisdk-native-paphc93g.js +9 -0
- package/dist/chunks/aisdk-native-pjvnvgmy.js +229 -0
- package/dist/chunks/aisdk-native-pknna89w.js +18 -0
- package/dist/chunks/aisdk-native-pt1wzm9p.js +328 -0
- package/dist/chunks/aisdk-native-pvvztgda.js +95 -0
- package/dist/chunks/aisdk-native-pwb5z5tv.js +114 -0
- package/dist/chunks/aisdk-native-q3sfg36h.js +13 -0
- package/dist/chunks/aisdk-native-q5az2q1p.js +381 -0
- package/dist/chunks/aisdk-native-q74kybfr.js +18 -0
- package/dist/chunks/aisdk-native-qaymkmh1.js +14 -0
- package/dist/chunks/aisdk-native-qb87gjwd.js +15 -0
- package/dist/chunks/aisdk-native-qb9gpeer.js +310 -0
- package/dist/chunks/aisdk-native-qfa1cgps.js +8 -0
- package/dist/chunks/aisdk-native-qfw56etf.js +202 -0
- package/dist/chunks/aisdk-native-qh3awkqg.js +74 -0
- package/dist/chunks/aisdk-native-qjwa214h.js +814 -0
- package/dist/chunks/aisdk-native-qm5vd5ej.js +128 -0
- package/dist/chunks/aisdk-native-qrg20bc0.js +26 -0
- package/dist/chunks/aisdk-native-qsdy395h.js +20 -0
- package/dist/chunks/aisdk-native-qv308p2a.js +325 -0
- package/dist/chunks/aisdk-native-qx0n0hnh.js +213 -0
- package/dist/chunks/aisdk-native-r4kwqy5f.js +193 -0
- package/dist/chunks/aisdk-native-r9mregkx.js +263 -0
- package/dist/chunks/aisdk-native-ra3qct3x.js +61 -0
- package/dist/chunks/aisdk-native-rcb2kzg1.js +21 -0
- package/dist/chunks/aisdk-native-rd6pz67j.js +117 -0
- package/dist/chunks/aisdk-native-rdzxvy4m.js +156 -0
- package/dist/chunks/aisdk-native-rga4dawr.js +43 -0
- package/dist/chunks/aisdk-native-rhjbct0v.js +196 -0
- package/dist/chunks/aisdk-native-rmbt0h7x.js +623 -0
- package/dist/chunks/aisdk-native-rn79xn25.js +130 -0
- package/dist/chunks/aisdk-native-rqysayyh.js +330 -0
- package/dist/chunks/aisdk-native-rrbca1ec.js +77 -0
- package/dist/chunks/aisdk-native-rsym84ch.js +31 -0
- package/dist/chunks/aisdk-native-s0hza5ac.js +37 -0
- package/dist/chunks/aisdk-native-s5ga8gke.js +283 -0
- package/dist/chunks/aisdk-native-sdp7kfr6.js +153 -0
- package/dist/chunks/aisdk-native-sembr0kd.js +462 -0
- package/dist/chunks/aisdk-native-sjbct61y.js +35 -0
- package/dist/chunks/aisdk-native-sk3qaz4a.js +511 -0
- package/dist/chunks/aisdk-native-smbad60v.js +130 -0
- package/dist/chunks/aisdk-native-ssg3fenm.js +22 -0
- package/dist/chunks/aisdk-native-st09aja5.js +183 -0
- package/dist/chunks/aisdk-native-svw2bsx3.js +114 -0
- package/dist/chunks/aisdk-native-sxnsykqc.js +603 -0
- package/dist/chunks/aisdk-native-t0fxg8b9.js +34 -0
- package/dist/chunks/aisdk-native-t0x5rdq8.js +53 -0
- package/dist/chunks/aisdk-native-tazgh4e4.js +116 -0
- package/dist/chunks/aisdk-native-tcezcvh9.js +63 -0
- package/dist/chunks/aisdk-native-tdstcens.js +51 -0
- package/dist/chunks/aisdk-native-th5km1p3.js +25 -0
- package/dist/chunks/aisdk-native-tmmjahvp.js +97 -0
- package/dist/chunks/aisdk-native-tpbhnsa4.js +574 -0
- package/dist/chunks/aisdk-native-tvtrv512.js +51 -0
- package/dist/chunks/aisdk-native-twg0f83k.js +261 -0
- package/dist/chunks/aisdk-native-twwx0ekz.js +131 -0
- package/dist/chunks/aisdk-native-v2ctr6fa.js +170 -0
- package/dist/chunks/aisdk-native-v3hym01v.js +75 -0
- package/dist/chunks/aisdk-native-v5dw3fed.js +74 -0
- package/dist/chunks/aisdk-native-v6yxqhem.js +105 -0
- package/dist/chunks/aisdk-native-v9kga7nj.js +145 -0
- package/dist/chunks/aisdk-native-vcmavarf.js +61 -0
- package/dist/chunks/aisdk-native-veqvce7d.js +15 -0
- package/dist/chunks/aisdk-native-vfccn5yp.js +82 -0
- package/dist/chunks/aisdk-native-vhbgy75s.js +118 -0
- package/dist/chunks/aisdk-native-vv78xzwk.js +46 -0
- package/dist/chunks/aisdk-native-vy36sswr.js +40 -0
- package/dist/chunks/aisdk-native-vzcthcp8.js +21 -0
- package/dist/chunks/aisdk-native-w3wsvvr9.js +80 -0
- package/dist/chunks/aisdk-native-w4arg62q.js +84 -0
- package/dist/chunks/aisdk-native-w69f1nhp.js +140 -0
- package/dist/chunks/aisdk-native-w803qqfp.js +16 -0
- package/dist/chunks/aisdk-native-wavq5vqb.js +24 -0
- package/dist/chunks/aisdk-native-wb8tnnnp.js +99 -0
- package/dist/chunks/aisdk-native-wbvqwd2e.js +44 -0
- package/dist/chunks/aisdk-native-wd87259q.js +102 -0
- package/dist/chunks/aisdk-native-wer8tq1h.js +13 -0
- package/dist/chunks/aisdk-native-wf1cyng1.js +38 -0
- package/dist/chunks/aisdk-native-wggajky5.js +226 -0
- package/dist/chunks/aisdk-native-wh6nx8gk.js +341 -0
- package/dist/chunks/aisdk-native-whczfbjh.js +176 -0
- package/dist/chunks/aisdk-native-wtztk69x.js +24 -0
- package/dist/chunks/aisdk-native-wvvbdh4b.js +279 -0
- package/dist/chunks/aisdk-native-wzcb8dk1.js +109 -0
- package/dist/chunks/aisdk-native-x0ckcb58.js +54 -0
- package/dist/chunks/aisdk-native-x0v86zgp.js +121 -0
- package/dist/chunks/aisdk-native-x1ezjp6w.js +39 -0
- package/dist/chunks/aisdk-native-x61499pn.js +18 -0
- package/dist/chunks/aisdk-native-xbfgt74t.js +38 -0
- package/dist/chunks/aisdk-native-xbrnje9f.js +83 -0
- package/dist/chunks/aisdk-native-xekzrwwc.js +155 -0
- package/dist/chunks/aisdk-native-xkq70t77.js +96 -0
- package/dist/chunks/aisdk-native-xmvvg8ty.js +121 -0
- package/dist/chunks/aisdk-native-xpf9b544.js +105 -0
- package/dist/chunks/aisdk-native-xrekznn2.js +463 -0
- package/dist/chunks/aisdk-native-xv61b48b.js +116 -0
- package/dist/chunks/aisdk-native-y1fvbwt7.js +19 -0
- package/dist/chunks/aisdk-native-y3z1zdtj.js +184 -0
- package/dist/chunks/aisdk-native-y44na4kk.js +19 -0
- package/dist/chunks/aisdk-native-y6f0p4jw.js +7 -0
- package/dist/chunks/aisdk-native-y6jb2tes.js +161 -0
- package/dist/chunks/aisdk-native-y71avatq.js +31 -0
- package/dist/chunks/aisdk-native-y8cydn3q.js +68 -0
- package/dist/chunks/aisdk-native-y8f7s663.js +13 -0
- package/dist/chunks/aisdk-native-y9f55719.js +228 -0
- package/dist/chunks/aisdk-native-y9tfvs3x.js +254 -0
- package/dist/chunks/aisdk-native-ybc7xzk8.js +208 -0
- package/dist/chunks/aisdk-native-ygaqb7jw.js +25 -0
- package/dist/chunks/aisdk-native-ykq8g6tf.js +282 -0
- package/dist/chunks/aisdk-native-ym463w8f.js +17 -0
- package/dist/chunks/aisdk-native-ynnjbwyb.js +145 -0
- package/dist/chunks/aisdk-native-yp2x3t23.js +92 -0
- package/dist/chunks/aisdk-native-yppnjwr8.js +141 -0
- package/dist/chunks/aisdk-native-yrhqyw5v.js +15 -0
- package/dist/chunks/aisdk-native-yrznvahk.js +60 -0
- package/dist/chunks/aisdk-native-z0bkrqjs.js +15 -0
- package/dist/chunks/aisdk-native-z63w68vq.js +46 -0
- package/dist/chunks/aisdk-native-z7tgbaqx.js +48 -0
- package/dist/chunks/aisdk-native-z9919s4g.js +16 -0
- package/dist/chunks/aisdk-native-zeh9ct20.js +29 -0
- package/dist/chunks/aisdk-native-znwg340w.js +338 -0
- package/dist/chunks/aisdk-native-zr2ceqn5.js +13 -0
- package/dist/chunks/aisdk-native-zxq2ej10.js +34 -0
- package/dist/chunks/aisdk-native-zzabxn0f.js +21 -0
- package/dist/chunks/aisdk-native-zzet69ff.js +247 -0
- package/dist/codemode/catalog.js +14 -0
- package/dist/codemode/instructions.js +14 -0
- package/dist/codemode/tool.js +11 -0
- package/dist/command.js +89 -0
- package/dist/config/discovery.js +87 -0
- package/dist/config/markdown.js +12 -0
- package/dist/config/normalize.js +26 -0
- package/dist/config/plugin/agent.js +121 -0
- package/dist/config/plugin/command.js +213 -0
- package/dist/config/plugin/compaction.js +161 -0
- package/dist/config/plugin/entry-observer.js +8 -0
- package/dist/config/plugin/formatter.js +123 -0
- package/dist/config/plugin/image.js +121 -0
- package/dist/config/plugin/instruction.js +91 -0
- package/dist/config/plugin/location-watcher.js +121 -0
- package/dist/config/plugin/mcp.js +132 -0
- package/dist/config/plugin/policy.js +120 -0
- package/dist/config/plugin/provider.js +119 -0
- package/dist/config/plugin/reference.js +123 -0
- package/dist/config/plugin/shell.js +122 -0
- package/dist/config/plugin/skill-file.js +105 -0
- package/dist/config/plugin/skill.js +140 -0
- package/dist/config/plugin/snapshot.js +121 -0
- package/dist/config/plugin/source.js +125 -0
- package/dist/config/plugin/tool-output.js +123 -0
- package/dist/config/plugin/websearch.js +119 -0
- package/dist/config/plugin/worktree.js +124 -0
- package/dist/config/variable.js +10 -0
- package/dist/config/watch.js +8 -0
- package/dist/config.js +131 -0
- package/dist/credential/sql.js +7 -0
- package/dist/credential.js +93 -0
- package/dist/database/database.js +84 -0
- package/dist/database/drizzle/effect-sqlite/driver.js +23 -0
- package/dist/database/drizzle/effect-sqlite/index.js +34 -0
- package/dist/database/drizzle/effect-sqlite/session.js +20 -0
- package/dist/database/drizzle/index.js +36 -0
- package/dist/database/drizzle/internal/drizzle-utils.js +20 -0
- package/dist/database/drizzle/sqlite-core/effect/count.js +6 -0
- package/dist/database/drizzle/sqlite-core/effect/db.js +14 -0
- package/dist/database/drizzle/sqlite-core/effect/delete.js +7 -0
- package/dist/database/drizzle/sqlite-core/effect/index.js +51 -0
- package/dist/database/drizzle/sqlite-core/effect/insert.js +9 -0
- package/dist/database/drizzle/sqlite-core/effect/query.js +8 -0
- package/dist/database/drizzle/sqlite-core/effect/raw.js +6 -0
- package/dist/database/drizzle/sqlite-core/effect/select.js +9 -0
- package/dist/database/drizzle/sqlite-core/effect/session.js +19 -0
- package/dist/database/drizzle/sqlite-core/effect/update.js +9 -0
- package/dist/database/drizzle.js +37 -0
- package/dist/database/migration/20260127222353_familiar_lady_ursula.js +6 -0
- package/dist/database/migration/20260211171708_add_project_commands.js +6 -0
- package/dist/database/migration/20260213144116_wakeful_the_professor.js +6 -0
- package/dist/database/migration/20260225215848_workspace.js +6 -0
- package/dist/database/migration/20260227213759_add_session_workspace_id.js +6 -0
- package/dist/database/migration/20260228203230_blue_harpoon.js +6 -0
- package/dist/database/migration/20260303231226_add_workspace_fields.js +6 -0
- package/dist/database/migration/20260309230000_move_org_to_state.js +6 -0
- package/dist/database/migration/20260312043431_session_message_cursor.js +6 -0
- package/dist/database/migration/20260323234822_events.js +6 -0
- package/dist/database/migration/20260410174513_workspace-name.js +6 -0
- package/dist/database/migration/20260413175956_chief_energizer.js +6 -0
- package/dist/database/migration/20260423070820_add_icon_url_override.js +6 -0
- package/dist/database/migration/20260427172553_slow_nightmare.js +6 -0
- package/dist/database/migration/20260428004200_add_session_path.js +6 -0
- package/dist/database/migration/20260501142318_next_venus.js +6 -0
- package/dist/database/migration/20260504145000_add_sync_owner.js +6 -0
- package/dist/database/migration/20260507164347_add_workspace_time.js +6 -0
- package/dist/database/migration/20260510033149_session_usage.js +6 -0
- package/dist/database/migration/20260511000411_data_migration_state.js +6 -0
- package/dist/database/migration/20260511173437_session-metadata.js +6 -0
- package/dist/database/migration/20260601010001_normalize_storage_paths.js +6 -0
- package/dist/database/migration/20260601202201_amazing_prowler.js +6 -0
- package/dist/database/migration/20260602002951_lowly_union_jack.js +6 -0
- package/dist/database/migration/20260602182828_add_project_directories.js +6 -0
- package/dist/database/migration/20260603001617_session_message_projection_indexes.js +6 -0
- package/dist/database/migration/20260603040000_session_message_projection_order.js +6 -0
- package/dist/database/migration/20260603141458_session_input_inbox.js +6 -0
- package/dist/database/migration/20260603160727_jittery_ezekiel_stane.js +6 -0
- package/dist/database/migration/20260604172448_event_sourced_session_input.js +6 -0
- package/dist/database/migration/20260605003541_add_session_context_snapshot.js +6 -0
- package/dist/database/migration/20260605042240_add_context_epoch_agent.js +6 -0
- package/dist/database/migration/20260611035744_credential.js +6 -0
- package/dist/database/migration/20260611192811_lush_chimera.js +6 -0
- package/dist/database/migration/20260612174303_project_dir_strategy.js +6 -0
- package/dist/database/migration/20260622142730_simplify_session_context_epoch.js +6 -0
- package/dist/database/migration/20260622170816_reset_v2_session_state.js +6 -0
- package/dist/database/migration/20260622202450_simplify_session_input.js +6 -0
- package/dist/database/migration/20260804233008_loose_psylocke.js +6 -0
- package/dist/database/migration/20260805200742_import_legacy_credentials.js +8 -0
- package/dist/database/migration/20260808023530_workspace_domain.js +6 -0
- package/dist/database/migration/20260811161259_execution_claim_attempts.js +6 -0
- package/dist/database/migration/20260812181746_session_inbox.js +6 -0
- package/dist/database/migration/20260812213948_worktree.js +6 -0
- package/dist/database/migration/20260819222447_session_viewed_state.js +6 -0
- package/dist/database/migration/20260823191254_nullable_workspace_binding.js +6 -0
- package/dist/database/migration/20260910120000_clear_v1_session_permission.js +6 -0
- package/dist/database/migration.gen.js +53 -0
- package/dist/database/migration.js +59 -0
- package/dist/database/path.js +13 -0
- package/dist/database/schema.gen.js +6 -0
- package/dist/database/schema.sql.js +6 -0
- package/dist/database/sqlite.bun.js +79 -0
- package/dist/database/sqlite.js +12 -0
- package/dist/database/sqlite.node.js +75 -0
- package/dist/database/sqlite.workerd.js +108 -0
- package/dist/database/v1-migration.bun.js +796 -0
- package/dist/database/v1-migration.js +6 -0
- package/dist/database/v1-migration.noop.js +14 -0
- package/dist/effect/app-node-builder.js +390 -0
- package/dist/effect/app-node-platform.js +13 -0
- package/dist/effect/keyed-mutex.js +10 -0
- package/dist/effect/websocket-constructor.js +6 -0
- package/dist/environment/driver.js +12 -0
- package/dist/environment/environment.js +94 -0
- package/dist/environment/exec-defaults.js +9 -0
- package/dist/environment/files.js +16 -0
- package/dist/environment/index.js +114 -0
- package/dist/environment/local.js +9 -0
- package/dist/environment/memory.js +9 -0
- package/dist/environment/unavailable.js +25 -0
- package/dist/event/sql.js +8 -0
- package/dist/event-logger.js +96 -0
- package/dist/file-access.js +113 -0
- package/dist/file-mutation.js +99 -0
- package/dist/file-retention.js +8 -0
- package/dist/file.js +16 -0
- package/dist/filesystem/fff.bun.js +23 -0
- package/dist/filesystem/fff.js +6 -0
- package/dist/filesystem/fff.node.js +23 -0
- package/dist/filesystem/fff.workerd.js +22 -0
- package/dist/filesystem/ignore.js +58 -0
- package/dist/filesystem/location-watcher-policy.js +11 -0
- package/dist/filesystem/location-watcher.js +226 -0
- package/dist/filesystem/protected.js +12 -0
- package/dist/filesystem/search.js +109 -0
- package/dist/filesystem/watcher-binding.js +6 -0
- package/dist/filesystem/watcher.js +32 -0
- package/dist/filesystem.js +124 -0
- package/dist/form.js +112 -0
- package/dist/formatter/builtins.js +7 -0
- package/dist/formatter.js +88 -0
- package/dist/generate.js +99 -0
- package/dist/git.js +22 -0
- package/dist/github-copilot/chat/convert-to-openai-compatible-chat-messages.js +6 -0
- package/dist/github-copilot/chat/get-response-metadata.js +6 -0
- package/dist/github-copilot/chat/map-openai-compatible-finish-reason.js +6 -0
- package/dist/github-copilot/chat/openai-compatible-api-types.js +0 -0
- package/dist/github-copilot/chat/openai-compatible-chat-language-model.js +12 -0
- package/dist/github-copilot/chat/openai-compatible-chat-options.js +6 -0
- package/dist/github-copilot/chat/openai-compatible-metadata-extractor.js +0 -0
- package/dist/github-copilot/chat/openai-compatible-prepare-tools.js +6 -0
- package/dist/github-copilot/copilot-provider.js +65 -0
- package/dist/github-copilot/models.js +10 -0
- package/dist/github-copilot/openai-compatible-error.js +8 -0
- package/dist/github-copilot/responses/convert-to-openai-responses-input.js +6 -0
- package/dist/github-copilot/responses/map-openai-responses-finish-reason.js +6 -0
- package/dist/github-copilot/responses/openai-config.js +0 -0
- package/dist/github-copilot/responses/openai-error.js +8 -0
- package/dist/github-copilot/responses/openai-responses-api-types.js +0 -0
- package/dist/github-copilot/responses/openai-responses-language-model.js +15 -0
- package/dist/github-copilot/responses/openai-responses-prepare-tools.js +13 -0
- package/dist/github-copilot/responses/openai-responses-settings.js +0 -0
- package/dist/github-copilot/responses/tool/code-interpreter.js +14 -0
- package/dist/github-copilot/responses/tool/file-search.js +10 -0
- package/dist/github-copilot/responses/tool/image-generation.js +8 -0
- package/dist/github-copilot/responses/tool/web-search-preview.js +6 -0
- package/dist/github-copilot/responses/tool/web-search.js +6 -0
- package/dist/id/id.js +14 -0
- package/dist/image/photon-wasm.bun.js +6 -0
- package/dist/image/photon-wasm.node.js +6 -0
- package/dist/image/photon-wasm.workerd.js +5 -0
- package/dist/image/photon.js +93 -0
- package/dist/image.js +17 -0
- package/dist/instance/service.js +10 -0
- package/dist/instance.js +362 -0
- package/dist/instruction-discovery.js +91 -0
- package/dist/instructions/builtins.js +88 -0
- package/dist/instructions/index.js +42 -0
- package/dist/integration/connection.js +22 -0
- package/dist/integration.js +118 -0
- package/dist/job.js +83 -0
- package/dist/kv/sql.js +7 -0
- package/dist/kv.js +77 -0
- package/dist/location-activity.js +219 -0
- package/dist/location-mutation.js +114 -0
- package/dist/location-service-map.js +89 -0
- package/dist/location-services.js +357 -0
- package/dist/location.js +94 -0
- package/dist/mcp/client.js +366 -0
- package/dist/mcp/index.js +145 -0
- package/dist/mcp/instructions.js +126 -0
- package/dist/mcp/oauth.js +262 -0
- package/dist/mcp/stdio.js +93 -0
- package/dist/mime.js +8 -0
- package/dist/modal/models.js +10 -0
- package/dist/model-resolver.js +114 -0
- package/dist/model.js +29 -0
- package/dist/models-dev.js +96 -0
- package/dist/oauth/page.js +12 -0
- package/dist/permission/saved.js +88 -0
- package/dist/permission/sql.js +10 -0
- package/dist/permission.js +138 -0
- package/dist/persistent-pty/binary.bun.js +88 -0
- package/dist/persistent-pty/binary.node.js +7 -0
- package/dist/persistent-pty/binary.workerd.js +7 -0
- package/dist/persistent-pty/daemon.js +12 -0
- package/dist/persistent-pty/index.js +94 -0
- package/dist/persistent-pty/pty-binding.js +6 -0
- package/dist/persistent-pty.js +79 -0
- package/dist/plugin/agent.js +103 -0
- package/dist/plugin/command.js +100 -0
- package/dist/plugin/hooks.js +10 -0
- package/dist/plugin/host.js +225 -0
- package/dist/plugin/instance.js +12 -0
- package/dist/plugin/internal.js +332 -0
- package/dist/plugin/mcp-codemode-exclusion.js +8 -0
- package/dist/plugin/models-dev.js +81 -0
- package/dist/plugin/module.js +14 -0
- package/dist/plugin/optimize.js +23 -0
- package/dist/plugin/plan.js +103 -0
- package/dist/plugin/promise.js +8 -0
- package/dist/plugin/provider/alibaba.js +7 -0
- package/dist/plugin/provider/amazon-bedrock.js +7 -0
- package/dist/plugin/provider/azure.js +124 -0
- package/dist/plugin/provider/cerebras.js +7 -0
- package/dist/plugin/provider/cloudflare-ai-gateway.js +123 -0
- package/dist/plugin/provider/cloudflare-workers-ai.js +123 -0
- package/dist/plugin/provider/cohere.js +7 -0
- package/dist/plugin/provider/configured.js +122 -0
- package/dist/plugin/provider/digitalocean.js +85 -0
- package/dist/plugin/provider/dynamic.js +7 -0
- package/dist/plugin/provider/factory.js +6 -0
- package/dist/plugin/provider/gateway.js +7 -0
- package/dist/plugin/provider/github-copilot.js +94 -0
- package/dist/plugin/provider/gitlab.js +8 -0
- package/dist/plugin/provider/google-vertex.js +7 -0
- package/dist/plugin/provider/kilo.js +7 -0
- package/dist/plugin/provider/llmgateway.js +82 -0
- package/dist/plugin/provider/lmstudio.js +123 -0
- package/dist/plugin/provider/modal.js +85 -0
- package/dist/plugin/provider/nvidia.js +7 -0
- package/dist/plugin/provider/ollama.js +123 -0
- package/dist/plugin/provider/openai-compatible.js +6 -0
- package/dist/plugin/provider/openai.js +84 -0
- package/dist/plugin/provider/opencode.js +85 -0
- package/dist/plugin/provider/openrouter.js +8 -0
- package/dist/plugin/provider/perplexity.js +7 -0
- package/dist/plugin/provider/poe.js +82 -0
- package/dist/plugin/provider/sap-ai-core.js +8 -0
- package/dist/plugin/provider/sdk-factory.js +6 -0
- package/dist/plugin/provider/snowflake-cortex.js +123 -0
- package/dist/plugin/provider/venice.js +7 -0
- package/dist/plugin/provider/vercel.js +7 -0
- package/dist/plugin/provider/vllm.js +123 -0
- package/dist/plugin/provider/xai.js +83 -0
- package/dist/plugin/provider/zenmux.js +7 -0
- package/dist/plugin/provider.js +162 -0
- package/dist/plugin/sdk.js +82 -0
- package/dist/plugin/service.js +10 -0
- package/dist/plugin/skill.js +143 -0
- package/dist/plugin/source-directory.js +10 -0
- package/dist/plugin/supervisor.js +347 -0
- package/dist/plugin/update.js +11 -0
- package/dist/plugin/variant.js +11 -0
- package/dist/plugin/vcs/git.js +88 -0
- package/dist/plugin/vcs/hg.js +88 -0
- package/dist/plugin/warming.js +118 -0
- package/dist/plugin/websearch/exa.js +12 -0
- package/dist/plugin/websearch/firecrawl.js +13 -0
- package/dist/plugin/websearch/index.js +13 -0
- package/dist/plugin/websearch/mcp.js +13 -0
- package/dist/plugin/websearch/parallel.js +13 -0
- package/dist/plugin/websearch/tavily.js +11 -0
- package/dist/plugin.js +237 -0
- package/dist/project/schema.js +19 -0
- package/dist/project/sql.js +13 -0
- package/dist/project.js +99 -0
- package/dist/provider.js +32 -0
- package/dist/pty/protocol.js +45 -0
- package/dist/pty/pty.bun.js +39 -0
- package/dist/pty/pty.js +0 -0
- package/dist/pty/pty.node.js +28 -0
- package/dist/pty/pty.workerd.js +7 -0
- package/dist/pty/schema.js +6 -0
- package/dist/pty/ticket.js +49 -0
- package/dist/pty.js +104 -0
- package/dist/reference/instructions.js +88 -0
- package/dist/reference.js +96 -0
- package/dist/repository-cache.js +100 -0
- package/dist/repository.js +28 -0
- package/dist/ripgrep/binary.js +7 -0
- package/dist/ripgrep.js +101 -0
- package/dist/rpc.js +89 -0
- package/dist/schema.js +20 -0
- package/dist/session/command.js +80 -0
- package/dist/session/compaction.js +145 -0
- package/dist/session/context.js +153 -0
- package/dist/session/environment.js +10 -0
- package/dist/session/error.js +36 -0
- package/dist/session/event.js +6 -0
- package/dist/session/execution/restart.js +357 -0
- package/dist/session/execution.js +132 -0
- package/dist/session/generate.js +154 -0
- package/dist/session/history.js +30 -0
- package/dist/session/inbox.js +136 -0
- package/dist/session/info.js +8 -0
- package/dist/session/instruction-entry.js +95 -0
- package/dist/session/instruction-state.js +33 -0
- package/dist/session/instructions.js +98 -0
- package/dist/session/message-updater.js +9 -0
- package/dist/session/message.js +6 -0
- package/dist/session/model-request.js +125 -0
- package/dist/session/model-transport.js +16 -0
- package/dist/session/move.js +138 -0
- package/dist/session/projector.js +92 -0
- package/dist/session/prompt.js +108 -0
- package/dist/session/provider-context.js +20 -0
- package/dist/session/revert.js +100 -0
- package/dist/session/run-coordinator.js +8 -0
- package/dist/session/runner/index.js +10 -0
- package/dist/session/runner/llm.js +231 -0
- package/dist/session/runner/max-steps.js +6 -0
- package/dist/session/runner/model.js +110 -0
- package/dist/session/runner/publish-llm-event.js +8 -0
- package/dist/session/runner/retry.js +122 -0
- package/dist/session/runner/step.js +129 -0
- package/dist/session/runner/to-llm-message.js +7 -0
- package/dist/session/schema.js +10 -0
- package/dist/session/session.js +175 -0
- package/dist/session/shell.js +139 -0
- package/dist/session/skill.js +106 -0
- package/dist/session/sql.js +22 -0
- package/dist/session/stats.js +370 -0
- package/dist/session/store.js +91 -0
- package/dist/session/subagent-completion.js +12 -0
- package/dist/session/subagent-job.js +211 -0
- package/dist/session/system-prompt.js +10 -0
- package/dist/session/title.js +159 -0
- package/dist/session/to-session-error.js +113 -0
- package/dist/session/transfer.js +504 -0
- package/dist/session/usage.js +14 -0
- package/dist/session.js +250 -0
- package/dist/shell/parse.js +15 -0
- package/dist/shell/parser-wasm.bun.js +8 -0
- package/dist/shell/parser-wasm.node.js +11 -0
- package/dist/shell/parser-wasm.workerd.js +5 -0
- package/dist/shell/result.js +18 -0
- package/dist/shell/scan.js +1480 -0
- package/dist/shell/select.js +32 -0
- package/dist/shell.js +145 -0
- package/dist/skill/discovery.js +11 -0
- package/dist/skill/instructions.js +106 -0
- package/dist/skill.js +127 -0
- package/dist/snapshot.js +94 -0
- package/dist/state.js +18 -0
- package/dist/tool/html-markdown.js +8 -0
- package/dist/tool/http-body.js +6 -0
- package/dist/tool/mcp.js +129 -0
- package/dist/tool/plugin/edit.js +121 -0
- package/dist/tool/plugin/file-diff.js +6 -0
- package/dist/tool/plugin/glob.js +126 -0
- package/dist/tool/plugin/grep.js +126 -0
- package/dist/tool/plugin/opencode.js +12 -0
- package/dist/tool/plugin/patch.js +125 -0
- package/dist/tool/plugin/question.js +116 -0
- package/dist/tool/plugin/read.js +127 -0
- package/dist/tool/plugin/shell.js +218 -0
- package/dist/tool/plugin/skill.js +114 -0
- package/dist/tool/plugin/subagent.js +220 -0
- package/dist/tool/plugin/webfetch.js +122 -0
- package/dist/tool/plugin/websearch.js +115 -0
- package/dist/tool/plugin/write.js +123 -0
- package/dist/tool/read-filesystem.js +130 -0
- package/dist/tool/runtime.js +14 -0
- package/dist/tool-output.js +21 -0
- package/dist/tool.js +28 -0
- package/dist/types/account/sql.d.ts +325 -0
- package/dist/types/agent.d.ts +119 -0
- package/dist/types/aisdk-native.d.ts +16 -0
- package/dist/types/aisdk.d.ts +52 -0
- package/dist/types/app.d.ts +13 -0
- package/dist/types/bus.d.ts +101 -0
- package/dist/types/catalog.d.ts +49 -0
- package/dist/types/codemode/catalog.d.ts +47 -0
- package/dist/types/codemode/instructions.d.ts +6 -0
- package/dist/types/codemode/tool.d.ts +66 -0
- package/dist/types/command.d.ts +52 -0
- package/dist/types/config/discovery.d.ts +35 -0
- package/dist/types/config/markdown.d.ts +5 -0
- package/dist/types/config/normalize.d.ts +15 -0
- package/dist/types/config/plugin/agent.d.ts +5 -0
- package/dist/types/config/plugin/command.d.ts +9 -0
- package/dist/types/config/plugin/compaction.d.ts +4 -0
- package/dist/types/config/plugin/entry-observer.d.ts +7 -0
- package/dist/types/config/plugin/formatter.d.ts +9 -0
- package/dist/types/config/plugin/image.d.ts +4 -0
- package/dist/types/config/plugin/instruction.d.ts +7 -0
- package/dist/types/config/plugin/location-watcher.d.ts +4 -0
- package/dist/types/config/plugin/mcp.d.ts +8 -0
- package/dist/types/config/plugin/policy.d.ts +3 -0
- package/dist/types/config/plugin/provider.d.ts +3 -0
- package/dist/types/config/plugin/reference.d.ts +5 -0
- package/dist/types/config/plugin/shell.d.ts +4 -0
- package/dist/types/config/plugin/skill-file.d.ts +15 -0
- package/dist/types/config/plugin/skill.d.ts +8 -0
- package/dist/types/config/plugin/snapshot.d.ts +4 -0
- package/dist/types/config/plugin/source.d.ts +25 -0
- package/dist/types/config/plugin/tool-output.d.ts +4 -0
- package/dist/types/config/plugin/websearch.d.ts +3 -0
- package/dist/types/config/plugin/worktree.d.ts +6 -0
- package/dist/types/config/variable.d.ts +60 -0
- package/dist/types/config/watch.d.ts +11 -0
- package/dist/types/config.d.ts +45 -0
- package/dist/types/credential/sql.d.ts +169 -0
- package/dist/types/credential.d.ts +237 -0
- package/dist/types/database/database.d.ts +25 -0
- package/dist/types/database/drizzle/effect-sqlite/driver.d.ts +43 -0
- package/dist/types/database/drizzle/effect-sqlite/index.d.ts +3 -0
- package/dist/types/database/drizzle/effect-sqlite/session.d.ts +57 -0
- package/dist/types/database/drizzle/index.d.ts +4 -0
- package/dist/types/database/drizzle/internal/drizzle-utils.d.ts +21 -0
- package/dist/types/database/drizzle/sqlite-core/effect/count.d.ts +20 -0
- package/dist/types/database/drizzle/sqlite-core/effect/db.d.ts +77 -0
- package/dist/types/database/drizzle/sqlite-core/effect/delete.d.ts +69 -0
- package/dist/types/database/drizzle/sqlite-core/effect/index.d.ts +9 -0
- package/dist/types/database/drizzle/sqlite-core/effect/insert.d.ts +95 -0
- package/dist/types/database/drizzle/sqlite-core/effect/query.d.ts +63 -0
- package/dist/types/database/drizzle/sqlite-core/effect/raw.d.ts +32 -0
- package/dist/types/database/drizzle/sqlite-core/effect/select.d.ts +64 -0
- package/dist/types/database/drizzle/sqlite-core/effect/session.d.ts +82 -0
- package/dist/types/database/drizzle/sqlite-core/effect/update.d.ts +90 -0
- package/dist/types/database/drizzle.d.ts +1 -0
- package/dist/types/database/migration/20260127222353_familiar_lady_ursula.d.ts +3 -0
- package/dist/types/database/migration/20260211171708_add_project_commands.d.ts +3 -0
- package/dist/types/database/migration/20260213144116_wakeful_the_professor.d.ts +3 -0
- package/dist/types/database/migration/20260225215848_workspace.d.ts +3 -0
- package/dist/types/database/migration/20260227213759_add_session_workspace_id.d.ts +3 -0
- package/dist/types/database/migration/20260228203230_blue_harpoon.d.ts +3 -0
- package/dist/types/database/migration/20260303231226_add_workspace_fields.d.ts +3 -0
- package/dist/types/database/migration/20260309230000_move_org_to_state.d.ts +3 -0
- package/dist/types/database/migration/20260312043431_session_message_cursor.d.ts +3 -0
- package/dist/types/database/migration/20260323234822_events.d.ts +3 -0
- package/dist/types/database/migration/20260410174513_workspace-name.d.ts +3 -0
- package/dist/types/database/migration/20260413175956_chief_energizer.d.ts +3 -0
- package/dist/types/database/migration/20260423070820_add_icon_url_override.d.ts +3 -0
- package/dist/types/database/migration/20260427172553_slow_nightmare.d.ts +3 -0
- package/dist/types/database/migration/20260428004200_add_session_path.d.ts +3 -0
- package/dist/types/database/migration/20260501142318_next_venus.d.ts +3 -0
- package/dist/types/database/migration/20260504145000_add_sync_owner.d.ts +3 -0
- package/dist/types/database/migration/20260507164347_add_workspace_time.d.ts +3 -0
- package/dist/types/database/migration/20260510033149_session_usage.d.ts +3 -0
- package/dist/types/database/migration/20260511000411_data_migration_state.d.ts +3 -0
- package/dist/types/database/migration/20260511173437_session-metadata.d.ts +3 -0
- package/dist/types/database/migration/20260601010001_normalize_storage_paths.d.ts +3 -0
- package/dist/types/database/migration/20260601202201_amazing_prowler.d.ts +3 -0
- package/dist/types/database/migration/20260602002951_lowly_union_jack.d.ts +3 -0
- package/dist/types/database/migration/20260602182828_add_project_directories.d.ts +3 -0
- package/dist/types/database/migration/20260603001617_session_message_projection_indexes.d.ts +3 -0
- package/dist/types/database/migration/20260603040000_session_message_projection_order.d.ts +3 -0
- package/dist/types/database/migration/20260603141458_session_input_inbox.d.ts +3 -0
- package/dist/types/database/migration/20260603160727_jittery_ezekiel_stane.d.ts +3 -0
- package/dist/types/database/migration/20260604172448_event_sourced_session_input.d.ts +3 -0
- package/dist/types/database/migration/20260605003541_add_session_context_snapshot.d.ts +3 -0
- package/dist/types/database/migration/20260605042240_add_context_epoch_agent.d.ts +3 -0
- package/dist/types/database/migration/20260611035744_credential.d.ts +3 -0
- package/dist/types/database/migration/20260611192811_lush_chimera.d.ts +3 -0
- package/dist/types/database/migration/20260612174303_project_dir_strategy.d.ts +3 -0
- package/dist/types/database/migration/20260622142730_simplify_session_context_epoch.d.ts +3 -0
- package/dist/types/database/migration/20260622170816_reset_v2_session_state.d.ts +3 -0
- package/dist/types/database/migration/20260622202450_simplify_session_input.d.ts +3 -0
- package/dist/types/database/migration/20260804233008_loose_psylocke.d.ts +3 -0
- package/dist/types/database/migration/20260805200742_import_legacy_credentials.d.ts +5 -0
- package/dist/types/database/migration/20260808023530_workspace_domain.d.ts +3 -0
- package/dist/types/database/migration/20260811161259_execution_claim_attempts.d.ts +3 -0
- package/dist/types/database/migration/20260812181746_session_inbox.d.ts +3 -0
- package/dist/types/database/migration/20260812213948_worktree.d.ts +3 -0
- package/dist/types/database/migration/20260819222447_session_viewed_state.d.ts +3 -0
- package/dist/types/database/migration/20260823191254_nullable_workspace_binding.d.ts +3 -0
- package/dist/types/database/migration/20260910120000_clear_v1_session_permission.d.ts +3 -0
- package/dist/types/database/migration.d.ts +13 -0
- package/dist/types/database/migration.gen.d.ts +2 -0
- package/dist/types/database/path.d.ts +68 -0
- package/dist/types/database/schema.gen.d.ts +3 -0
- package/dist/types/database/schema.sql.d.ts +4 -0
- package/dist/types/database/sqlite.bun.d.ts +14 -0
- package/dist/types/database/sqlite.d.ts +20 -0
- package/dist/types/database/sqlite.node.d.ts +16 -0
- package/dist/types/database/sqlite.workerd.d.ts +29 -0
- package/dist/types/database/v1-migration.bun.d.ts +71 -0
- package/dist/types/database/v1-migration.d.ts +2 -0
- package/dist/types/database/v1-migration.noop.d.ts +11 -0
- package/dist/types/effect/app-node-builder.d.ts +4 -0
- package/dist/types/effect/app-node-platform.d.ts +6 -0
- package/dist/types/effect/keyed-mutex.d.ts +19 -0
- package/dist/types/effect/websocket-constructor.d.ts +8 -0
- package/dist/types/environment/driver.d.ts +7 -0
- package/dist/types/environment/environment.d.ts +12 -0
- package/dist/types/environment/exec-defaults.d.ts +4 -0
- package/dist/types/environment/files.d.ts +60 -0
- package/dist/types/environment/index.d.ts +10 -0
- package/dist/types/environment/local.d.ts +13 -0
- package/dist/types/environment/memory.d.ts +8 -0
- package/dist/types/environment/unavailable.d.ts +20 -0
- package/dist/types/event/sql.d.ts +158 -0
- package/dist/types/event-logger.d.ts +5 -0
- package/dist/types/file-access.d.ts +52 -0
- package/dist/types/file-mutation.d.ts +38 -0
- package/dist/types/file-retention.d.ts +4 -0
- package/dist/types/file.d.ts +9 -0
- package/dist/types/filesystem/fff.bun.d.ts +7 -0
- package/dist/types/filesystem/fff.d.ts +60 -0
- package/dist/types/filesystem/fff.node.d.ts +4 -0
- package/dist/types/filesystem/fff.workerd.d.ts +4 -0
- package/dist/types/filesystem/ignore.d.ts +2 -0
- package/dist/types/filesystem/location-watcher-policy.d.ts +15 -0
- package/dist/types/filesystem/location-watcher.d.ts +8 -0
- package/dist/types/filesystem/protected.d.ts +6 -0
- package/dist/types/filesystem/search.d.ts +20 -0
- package/dist/types/filesystem/watcher-binding.d.ts +1 -0
- package/dist/types/filesystem/watcher.d.ts +109 -0
- package/dist/types/filesystem.d.ts +133 -0
- package/dist/types/form.d.ts +449 -0
- package/dist/types/formatter/builtins.d.ts +18 -0
- package/dist/types/formatter.d.ts +15 -0
- package/dist/types/generate.d.ts +28 -0
- package/dist/types/git.d.ts +134 -0
- package/dist/types/github-copilot/chat/convert-to-openai-compatible-chat-messages.d.ts +3 -0
- package/dist/types/github-copilot/chat/get-response-metadata.d.ts +9 -0
- package/dist/types/github-copilot/chat/map-openai-compatible-finish-reason.d.ts +2 -0
- package/dist/types/github-copilot/chat/openai-compatible-api-types.d.ts +48 -0
- package/dist/types/github-copilot/chat/openai-compatible-chat-language-model.d.ts +135 -0
- package/dist/types/github-copilot/chat/openai-compatible-chat-options.d.ts +9 -0
- package/dist/types/github-copilot/chat/openai-compatible-metadata-extractor.d.ts +43 -0
- package/dist/types/github-copilot/chat/openai-compatible-prepare-tools.d.ts +21 -0
- package/dist/types/github-copilot/copilot-provider.d.ts +36 -0
- package/dist/types/github-copilot/models.d.ts +3 -0
- package/dist/types/github-copilot/openai-compatible-error.d.ts +16 -0
- package/dist/types/github-copilot/responses/convert-to-openai-responses-input.d.ts +18 -0
- package/dist/types/github-copilot/responses/map-openai-responses-finish-reason.d.ts +5 -0
- package/dist/types/github-copilot/responses/openai-config.d.ts +20 -0
- package/dist/types/github-copilot/responses/openai-error.d.ts +11 -0
- package/dist/types/github-copilot/responses/openai-responses-api-types.d.ts +165 -0
- package/dist/types/github-copilot/responses/openai-responses-language-model.d.ts +205 -0
- package/dist/types/github-copilot/responses/openai-responses-prepare-tools.d.ts +32 -0
- package/dist/types/github-copilot/responses/openai-responses-settings.d.ts +1 -0
- package/dist/types/github-copilot/responses/tool/code-interpreter.d.ts +86 -0
- package/dist/types/github-copilot/responses/tool/file-search.d.ts +95 -0
- package/dist/types/github-copilot/responses/tool/image-generation.d.ts +42 -0
- package/dist/types/github-copilot/responses/tool/web-search-preview.d.ts +15 -0
- package/dist/types/github-copilot/responses/tool/web-search.d.ts +18 -0
- package/dist/types/id/id.d.ts +19 -0
- package/dist/types/image/photon-wasm.bun.d.ts +2 -0
- package/dist/types/image/photon-wasm.node.d.ts +2 -0
- package/dist/types/image/photon-wasm.workerd.d.ts +2 -0
- package/dist/types/image/photon.d.ts +19 -0
- package/dist/types/image.d.ts +45 -0
- package/dist/types/instance/service.d.ts +14 -0
- package/dist/types/instance.d.ts +60 -0
- package/dist/types/instruction-discovery.d.ts +75 -0
- package/dist/types/instructions/builtins.d.ts +11 -0
- package/dist/types/instructions/index.d.ts +87 -0
- package/dist/types/integration/connection.d.ts +26 -0
- package/dist/types/integration.d.ts +1652 -0
- package/dist/types/job.d.ts +103 -0
- package/dist/types/kv/sql.d.ts +71 -0
- package/dist/types/kv.d.ts +26 -0
- package/dist/types/location-activity.d.ts +14 -0
- package/dist/types/location-mutation.d.ts +3 -0
- package/dist/types/location-service-map.d.ts +15 -0
- package/dist/types/location-services.d.ts +8 -0
- package/dist/types/location.d.ts +16 -0
- package/dist/types/mcp/client.d.ts +285 -0
- package/dist/types/mcp/index.d.ts +270 -0
- package/dist/types/mcp/instructions.d.ts +13 -0
- package/dist/types/mcp/oauth.d.ts +101 -0
- package/dist/types/mcp/stdio.d.ts +29 -0
- package/dist/types/mime.d.ts +2 -0
- package/dist/types/modal/models.d.ts +3 -0
- package/dist/types/model-resolver.d.ts +174 -0
- package/dist/types/model.d.ts +234 -0
- package/dist/types/models-dev.d.ts +34 -0
- package/dist/types/oauth/page.d.ts +15 -0
- package/dist/types/permission/saved.d.ts +40 -0
- package/dist/types/permission/sql.d.ts +103 -0
- package/dist/types/permission.d.ts +127 -0
- package/dist/types/persistent-pty/binary.bun.d.ts +1 -0
- package/dist/types/persistent-pty/binary.node.d.ts +1 -0
- package/dist/types/persistent-pty/binary.workerd.d.ts +1 -0
- package/dist/types/persistent-pty/daemon.d.ts +782 -0
- package/dist/types/persistent-pty/index.d.ts +84 -0
- package/dist/types/persistent-pty/pty-binding.d.ts +6 -0
- package/dist/types/persistent-pty.d.ts +1 -0
- package/dist/types/plugin/agent.d.ts +2 -0
- package/dist/types/plugin/command.d.ts +5 -0
- package/dist/types/plugin/hooks.d.ts +36 -0
- package/dist/types/plugin/host.d.ts +30 -0
- package/dist/types/plugin/instance.d.ts +24 -0
- package/dist/types/plugin/internal.d.ts +56 -0
- package/dist/types/plugin/mcp-codemode-exclusion.d.ts +2 -0
- package/dist/types/plugin/models-dev.d.ts +3 -0
- package/dist/types/plugin/module.d.ts +44 -0
- package/dist/types/plugin/optimize.d.ts +9 -0
- package/dist/types/plugin/plan.d.ts +3 -0
- package/dist/types/plugin/promise.d.ts +2 -0
- package/dist/types/plugin/provider/alibaba.d.ts +1 -0
- package/dist/types/plugin/provider/amazon-bedrock.d.ts +1 -0
- package/dist/types/plugin/provider/azure.d.ts +3 -0
- package/dist/types/plugin/provider/cerebras.d.ts +1 -0
- package/dist/types/plugin/provider/cloudflare-ai-gateway.d.ts +1 -0
- package/dist/types/plugin/provider/cloudflare-workers-ai.d.ts +1 -0
- package/dist/types/plugin/provider/cohere.d.ts +1 -0
- package/dist/types/plugin/provider/configured.d.ts +10 -0
- package/dist/types/plugin/provider/digitalocean.d.ts +3 -0
- package/dist/types/plugin/provider/dynamic.d.ts +2 -0
- package/dist/types/plugin/provider/factory.d.ts +6 -0
- package/dist/types/plugin/provider/gateway.d.ts +1 -0
- package/dist/types/plugin/provider/github-copilot.d.ts +14 -0
- package/dist/types/plugin/provider/gitlab.d.ts +1 -0
- package/dist/types/plugin/provider/google-vertex.d.ts +1 -0
- package/dist/types/plugin/provider/kilo.d.ts +1 -0
- package/dist/types/plugin/provider/llmgateway.d.ts +2 -0
- package/dist/types/plugin/provider/lmstudio.d.ts +5 -0
- package/dist/types/plugin/provider/modal.d.ts +3 -0
- package/dist/types/plugin/provider/nvidia.d.ts +1 -0
- package/dist/types/plugin/provider/ollama.d.ts +5 -0
- package/dist/types/plugin/provider/openai-compatible.d.ts +1 -0
- package/dist/types/plugin/provider/openai.d.ts +2 -0
- package/dist/types/plugin/provider/opencode.d.ts +4 -0
- package/dist/types/plugin/provider/openrouter.d.ts +1 -0
- package/dist/types/plugin/provider/perplexity.d.ts +1 -0
- package/dist/types/plugin/provider/poe.d.ts +2 -0
- package/dist/types/plugin/provider/sap-ai-core.d.ts +2 -0
- package/dist/types/plugin/provider/sdk-factory.d.ts +3 -0
- package/dist/types/plugin/provider/snowflake-cortex.d.ts +5 -0
- package/dist/types/plugin/provider/venice.d.ts +1 -0
- package/dist/types/plugin/provider/vercel.d.ts +1 -0
- package/dist/types/plugin/provider/vllm.d.ts +5 -0
- package/dist/types/plugin/provider/xai.d.ts +2 -0
- package/dist/types/plugin/provider/zenmux.d.ts +1 -0
- package/dist/types/plugin/provider.d.ts +2 -0
- package/dist/types/plugin/sdk.d.ts +57 -0
- package/dist/types/plugin/service.d.ts +32 -0
- package/dist/types/plugin/skill.d.ts +6 -0
- package/dist/types/plugin/source-directory.d.ts +5 -0
- package/dist/types/plugin/supervisor.d.ts +10 -0
- package/dist/types/plugin/update.d.ts +20 -0
- package/dist/types/plugin/variant.d.ts +10 -0
- package/dist/types/plugin/vcs/git.d.ts +4 -0
- package/dist/types/plugin/vcs/hg.d.ts +5 -0
- package/dist/types/plugin/warming.d.ts +4 -0
- package/dist/types/plugin/websearch/exa.d.ts +5 -0
- package/dist/types/plugin/websearch/firecrawl.d.ts +5 -0
- package/dist/types/plugin/websearch/index.d.ts +1 -0
- package/dist/types/plugin/websearch/mcp.d.ts +9 -0
- package/dist/types/plugin/websearch/parallel.d.ts +5 -0
- package/dist/types/plugin/websearch/tavily.d.ts +5 -0
- package/dist/types/plugin.d.ts +8 -0
- package/dist/types/project/schema.d.ts +247 -0
- package/dist/types/project/sql.d.ts +300 -0
- package/dist/types/project.d.ts +101 -0
- package/dist/types/provider.d.ts +113 -0
- package/dist/types/pty/protocol.d.ts +5 -0
- package/dist/types/pty/pty.bun.d.ts +4 -0
- package/dist/types/pty/pty.d.ts +22 -0
- package/dist/types/pty/pty.node.d.ts +4 -0
- package/dist/types/pty/pty.workerd.d.ts +3 -0
- package/dist/types/pty/schema.d.ts +1 -0
- package/dist/types/pty/ticket.d.ts +24 -0
- package/dist/types/pty.d.ts +80 -0
- package/dist/types/reference/instructions.d.ts +10 -0
- package/dist/types/reference.d.ts +65 -0
- package/dist/types/repository-cache.d.ts +72 -0
- package/dist/types/repository.d.ts +50 -0
- package/dist/types/ripgrep/binary.d.ts +11 -0
- package/dist/types/ripgrep.d.ts +52 -0
- package/dist/types/rpc.d.ts +16 -0
- package/dist/types/schema.d.ts +45 -0
- package/dist/types/session/command.d.ts +16 -0
- package/dist/types/session/compaction.d.ts +64 -0
- package/dist/types/session/context.d.ts +53 -0
- package/dist/types/session/environment.d.ts +13 -0
- package/dist/types/session/error.d.ts +135 -0
- package/dist/types/session/event.d.ts +2 -0
- package/dist/types/session/execution/restart.d.ts +48 -0
- package/dist/types/session/execution.d.ts +56 -0
- package/dist/types/session/generate.d.ts +15 -0
- package/dist/types/session/history.d.ts +1626 -0
- package/dist/types/session/inbox.d.ts +971 -0
- package/dist/types/session/info.d.ts +3 -0
- package/dist/types/session/instruction-entry.d.ts +52 -0
- package/dist/types/session/instruction-state.d.ts +48 -0
- package/dist/types/session/instructions.d.ts +15 -0
- package/dist/types/session/message-updater.d.ts +18 -0
- package/dist/types/session/message.d.ts +2 -0
- package/dist/types/session/model-request.d.ts +68 -0
- package/dist/types/session/model-transport.d.ts +16 -0
- package/dist/types/session/move.d.ts +34 -0
- package/dist/types/session/projector.d.ts +4 -0
- package/dist/types/session/prompt.d.ts +66 -0
- package/dist/types/session/provider-context.d.ts +46 -0
- package/dist/types/session/revert.d.ts +27 -0
- package/dist/types/session/run-coordinator.d.ts +47 -0
- package/dist/types/session/runner/index.d.ts +81 -0
- package/dist/types/session/runner/llm.d.ts +3 -0
- package/dist/types/session/runner/max-steps.d.ts +1 -0
- package/dist/types/session/runner/model.d.ts +66 -0
- package/dist/types/session/runner/publish-llm-event.d.ts +74 -0
- package/dist/types/session/runner/retry.d.ts +50 -0
- package/dist/types/session/runner/step.d.ts +185 -0
- package/dist/types/session/runner/to-llm-message.d.ts +5 -0
- package/dist/types/session/schema.d.ts +190 -0
- package/dist/types/session/session.d.ts +246 -0
- package/dist/types/session/shell.d.ts +13 -0
- package/dist/types/session/skill.d.ts +10 -0
- package/dist/types/session/sql.d.ts +1194 -0
- package/dist/types/session/stats.d.ts +82 -0
- package/dist/types/session/store.d.ts +120 -0
- package/dist/types/session/subagent-completion.d.ts +13 -0
- package/dist/types/session/subagent-job.d.ts +13 -0
- package/dist/types/session/system-prompt.d.ts +3 -0
- package/dist/types/session/title.d.ts +17 -0
- package/dist/types/session/to-session-error.d.ts +2 -0
- package/dist/types/session/transfer.d.ts +922 -0
- package/dist/types/session/usage.d.ts +13 -0
- package/dist/types/session.d.ts +229 -0
- package/dist/types/shell/parse.d.ts +13 -0
- package/dist/types/shell/parser-wasm.bun.d.ts +5 -0
- package/dist/types/shell/parser-wasm.node.d.ts +5 -0
- package/dist/types/shell/parser-wasm.workerd.d.ts +5 -0
- package/dist/types/shell/result.d.ts +54 -0
- package/dist/types/shell/scan.d.ts +20 -0
- package/dist/types/shell/select.d.ts +39 -0
- package/dist/types/shell.d.ts +44 -0
- package/dist/types/skill/discovery.d.ts +10 -0
- package/dist/types/skill/instructions.d.ts +11 -0
- package/dist/types/skill.d.ts +90 -0
- package/dist/types/snapshot.d.ts +57 -0
- package/dist/types/state.d.ts +73 -0
- package/dist/types/tool/html-markdown.d.ts +2 -0
- package/dist/types/tool/http-body.d.ts +3 -0
- package/dist/types/tool/mcp.d.ts +20 -0
- package/dist/types/tool/plugin/edit.d.ts +38 -0
- package/dist/types/tool/plugin/file-diff.d.ts +2 -0
- package/dist/types/tool/plugin/glob.d.ts +27 -0
- package/dist/types/tool/plugin/grep.d.ts +39 -0
- package/dist/types/tool/plugin/opencode.d.ts +21 -0
- package/dist/types/tool/plugin/patch.d.ts +38 -0
- package/dist/types/tool/plugin/question.d.ts +32 -0
- package/dist/types/tool/plugin/read.d.ts +35 -0
- package/dist/types/tool/plugin/shell.d.ts +23 -0
- package/dist/types/tool/plugin/skill.d.ts +21 -0
- package/dist/types/tool/plugin/subagent.d.ts +32 -0
- package/dist/types/tool/plugin/webfetch.d.ts +22 -0
- package/dist/types/tool/plugin/websearch.d.ts +16 -0
- package/dist/types/tool/plugin/write.d.ts +32 -0
- package/dist/types/tool/read-filesystem.d.ts +103 -0
- package/dist/types/tool/runtime.d.ts +28 -0
- package/dist/types/tool-output.d.ts +24 -0
- package/dist/types/tool.d.ts +54 -0
- package/dist/types/util/array.d.ts +1 -0
- package/dist/types/util/error-summary.d.ts +7 -0
- package/dist/types/util/error.d.ts +269 -0
- package/dist/types/util/identifier.d.ts +1 -0
- package/dist/types/util/iife.d.ts +1 -0
- package/dist/types/util/lazy.d.ts +1 -0
- package/dist/types/util/process-lock-ffi.bun.d.ts +12 -0
- package/dist/types/util/process-lock-ffi.node.d.ts +12 -0
- package/dist/types/util/process-lock-ffi.workerd.d.ts +12 -0
- package/dist/types/util/process-lock.d.ts +20 -0
- package/dist/types/util/slug.d.ts +3 -0
- package/dist/types/util/token.d.ts +2 -0
- package/dist/types/util/which.d.ts +1 -0
- package/dist/types/util/wildcard.d.ts +2 -0
- package/dist/types/v1/config/agent.d.ts +96 -0
- package/dist/types/v1/config/attachment.d.ts +18 -0
- package/dist/types/v1/config/command.d.ts +11 -0
- package/dist/types/v1/config/config.d.ts +1243 -0
- package/dist/types/v1/config/error.d.ts +1773 -0
- package/dist/types/v1/config/formatter.d.ts +15 -0
- package/dist/types/v1/config/layout.d.ts +4 -0
- package/dist/types/v1/config/lsp.d.ts +38 -0
- package/dist/types/v1/config/mcp.d.ts +56 -0
- package/dist/types/v1/config/migrate.d.ts +444 -0
- package/dist/types/v1/config/permission.d.ts +59 -0
- package/dist/types/v1/config/plugin.d.ts +6 -0
- package/dist/types/v1/config/provider-options.d.ts +11 -0
- package/dist/types/v1/config/provider.d.ts +112 -0
- package/dist/types/v1/config/server.d.ts +10 -0
- package/dist/types/v1/config/skills.d.ts +7 -0
- package/dist/types/v1/permission.d.ts +27 -0
- package/dist/types/vcs/patch.d.ts +21 -0
- package/dist/types/vcs.d.ts +34 -0
- package/dist/types/websearch.d.ts +74 -0
- package/dist/types/wellknown/plugin.d.ts +4 -0
- package/dist/types/wellknown.d.ts +106 -0
- package/dist/types/workspace/driver.d.ts +72 -0
- package/dist/types/workspace/sql.d.ts +89 -0
- package/dist/types/workspace.d.ts +61 -0
- package/dist/types/worktree/directory.d.ts +9 -0
- package/dist/types/worktree/git.d.ts +23 -0
- package/dist/types/worktree/refresh.d.ts +2 -0
- package/dist/types/worktree/sql.d.ts +71 -0
- package/dist/types/worktree.d.ts +319 -0
- package/dist/util/array.js +12 -0
- package/dist/util/error-summary.js +8 -0
- package/dist/util/error.js +6 -0
- package/dist/util/identifier.js +5 -0
- package/dist/util/iife.js +6 -0
- package/dist/util/lazy.js +6 -0
- package/dist/util/process-lock-ffi.bun.js +51 -0
- package/dist/util/process-lock-ffi.node.js +44 -0
- package/dist/util/process-lock-ffi.workerd.js +10 -0
- package/dist/util/process-lock.js +121 -0
- package/dist/util/slug.js +6 -0
- package/dist/util/token.js +8 -0
- package/dist/util/which.js +6 -0
- package/dist/util/wildcard.js +8 -0
- package/dist/v1/config/agent.js +10 -0
- package/dist/v1/config/attachment.js +11 -0
- package/dist/v1/config/command.js +8 -0
- package/dist/v1/config/config.js +23 -0
- package/dist/v1/config/error.js +17 -0
- package/dist/v1/config/formatter.js +10 -0
- package/dist/v1/config/layout.js +8 -0
- package/dist/v1/config/lsp.js +16 -0
- package/dist/v1/config/mcp.js +15 -0
- package/dist/v1/config/migrate.js +23 -0
- package/dist/v1/config/permission.js +14 -0
- package/dist/v1/config/plugin.js +10 -0
- package/dist/v1/config/provider-options.js +10 -0
- package/dist/v1/config/provider.js +13 -0
- package/dist/v1/config/server.js +9 -0
- package/dist/v1/config/skills.js +8 -0
- package/dist/v1/permission.js +51 -0
- package/dist/vcs/patch.js +26 -0
- package/dist/vcs.js +101 -0
- package/dist/websearch.js +106 -0
- package/dist/wellknown/plugin.js +80 -0
- package/dist/wellknown.js +95 -0
- package/dist/workspace/driver.js +22 -0
- package/dist/workspace/sql.js +6 -0
- package/dist/workspace.js +88 -0
- package/dist/worktree/directory.js +11 -0
- package/dist/worktree/git.js +12 -0
- package/dist/worktree/refresh.js +346 -0
- package/dist/worktree/sql.js +10 -0
- package/dist/worktree.js +122 -0
- package/package.json +145 -6
|
@@ -0,0 +1,1480 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "../chunks/aisdk-native-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/shell/scan.ts
|
|
6
|
+
var exports_scan = {};
|
|
7
|
+
__export(exports_scan, {
|
|
8
|
+
ShellScan: () => exports_scan,
|
|
9
|
+
scan: () => scan,
|
|
10
|
+
scanPowerShell: () => scanPowerShell
|
|
11
|
+
});
|
|
12
|
+
var BASH_REDIRECTS = ["&>>", "&>", "<<<", "<<-", "<<", "<>", "<&", ">&", ">|", ">>", ">", "<"];
|
|
13
|
+
var BASH_DECLARATIONS = new Set(["declare", "typeset", "export", "readonly", "local", "unset", "unsetenv"]);
|
|
14
|
+
var MAX_INPUT_LENGTH = 64 * 1024;
|
|
15
|
+
var MAX_SUBSTITUTION_DEPTH = 32;
|
|
16
|
+
function scan(input) {
|
|
17
|
+
return scanBash(input, 0, { remaining: MAX_INPUT_LENGTH * MAX_SUBSTITUTION_DEPTH });
|
|
18
|
+
}
|
|
19
|
+
function scanBash(input, depth, budget) {
|
|
20
|
+
budget.remaining -= input.length;
|
|
21
|
+
if (input.length > MAX_INPUT_LENGTH || budget.remaining < 0 || depth > MAX_SUBSTITUTION_DEPTH)
|
|
22
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
23
|
+
const commands = [];
|
|
24
|
+
const nestedCommands = [];
|
|
25
|
+
const words = [];
|
|
26
|
+
const rawWords = [];
|
|
27
|
+
const assignmentWords = [];
|
|
28
|
+
let word = "";
|
|
29
|
+
let wordStarted = false;
|
|
30
|
+
let wordStart = 0;
|
|
31
|
+
let wordEnd = 0;
|
|
32
|
+
let commandEnd = 0;
|
|
33
|
+
let resourceEnd;
|
|
34
|
+
let redirectWordCount;
|
|
35
|
+
let assignmentWord = false;
|
|
36
|
+
let assignmentHeadUnsafe = false;
|
|
37
|
+
let segment = 0;
|
|
38
|
+
let quote;
|
|
39
|
+
let invalidRedirect = false;
|
|
40
|
+
let invalidStructure = false;
|
|
41
|
+
let separated = false;
|
|
42
|
+
let redirectTarget = false;
|
|
43
|
+
let hasRedirect = false;
|
|
44
|
+
let dangling = false;
|
|
45
|
+
let inList = false;
|
|
46
|
+
let compoundEnd = false;
|
|
47
|
+
const heredocs = [];
|
|
48
|
+
const structures = [];
|
|
49
|
+
const addSubstitutions = (substitution) => {
|
|
50
|
+
for (const source of substitution.substitutions ?? [substitution.source]) {
|
|
51
|
+
const result = scanBash(source, depth + 1, budget);
|
|
52
|
+
if (result.kind === "opaque")
|
|
53
|
+
return result;
|
|
54
|
+
nestedCommands.push(...result.commands);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const statement = () => {
|
|
58
|
+
const structure = structures.at(-1);
|
|
59
|
+
if (structure)
|
|
60
|
+
structure.count++;
|
|
61
|
+
};
|
|
62
|
+
const header = () => ["header", "pattern", "do"].includes(structures.at(-1)?.phase ?? "");
|
|
63
|
+
const finishWord = () => {
|
|
64
|
+
if (!wordStarted)
|
|
65
|
+
return;
|
|
66
|
+
if (!redirectTarget) {
|
|
67
|
+
words.push(word);
|
|
68
|
+
rawWords.push(input.slice(wordStart, wordEnd));
|
|
69
|
+
assignmentWords.push(assignmentWord);
|
|
70
|
+
commandEnd = wordEnd;
|
|
71
|
+
}
|
|
72
|
+
redirectTarget = false;
|
|
73
|
+
word = "";
|
|
74
|
+
wordStarted = false;
|
|
75
|
+
assignmentWord = false;
|
|
76
|
+
assignmentHeadUnsafe = false;
|
|
77
|
+
};
|
|
78
|
+
const finishCommand = (boundary = false) => {
|
|
79
|
+
finishWord();
|
|
80
|
+
if (redirectTarget)
|
|
81
|
+
invalidRedirect = true;
|
|
82
|
+
redirectTarget = false;
|
|
83
|
+
if (compoundEnd && words.length > 0)
|
|
84
|
+
invalidStructure = true;
|
|
85
|
+
const resource = input.slice(segment, resourceEnd ?? wordEnd).replace(/^[ \t\n]+|[ \t\n]+$/g, "");
|
|
86
|
+
const name = assignmentWords.findIndex((assignment) => !assignment);
|
|
87
|
+
if (name >= 0 && !words[name])
|
|
88
|
+
invalidStructure = true;
|
|
89
|
+
if (rawWords[name] === "}")
|
|
90
|
+
invalidStructure = true;
|
|
91
|
+
if (resource && name >= 0 && !header()) {
|
|
92
|
+
const command = {
|
|
93
|
+
resource,
|
|
94
|
+
words: words.slice(name),
|
|
95
|
+
rawWords: rawWords.slice(name),
|
|
96
|
+
...name === 0 && BASH_DECLARATIONS.has(rawWords[0]) && resource.startsWith(rawWords[0]) ? { declaration: true } : {},
|
|
97
|
+
...redirectWordCount !== undefined && redirectWordCount < words.length ? { redirectWordCount: redirectWordCount - name } : {}
|
|
98
|
+
};
|
|
99
|
+
commands.push(command);
|
|
100
|
+
if (resourceEnd === undefined) {
|
|
101
|
+
for (const heredoc of heredocs) {
|
|
102
|
+
if (heredoc.command)
|
|
103
|
+
continue;
|
|
104
|
+
heredoc.command = command;
|
|
105
|
+
heredoc.start = segment;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} else if (!header() && !compoundEnd && (hasRedirect || boundary || separated)) {
|
|
109
|
+
const assignmentOnly = assignmentWords.length > 0 && assignmentWords.every(Boolean);
|
|
110
|
+
if (!assignmentOnly && !hasRedirect)
|
|
111
|
+
invalidStructure = true;
|
|
112
|
+
}
|
|
113
|
+
commands.push(...nestedCommands.splice(0));
|
|
114
|
+
if (!header() && (words.length > 0 || hasRedirect))
|
|
115
|
+
statement();
|
|
116
|
+
words.length = 0;
|
|
117
|
+
rawWords.length = 0;
|
|
118
|
+
assignmentWords.length = 0;
|
|
119
|
+
separated = true;
|
|
120
|
+
hasRedirect = false;
|
|
121
|
+
resourceEnd = undefined;
|
|
122
|
+
redirectWordCount = undefined;
|
|
123
|
+
compoundEnd = false;
|
|
124
|
+
};
|
|
125
|
+
for (let index = 0;index < input.length; index++) {
|
|
126
|
+
const char = input[index];
|
|
127
|
+
if (!wordStarted)
|
|
128
|
+
wordStart = index;
|
|
129
|
+
if (!quote && !wordStarted) {
|
|
130
|
+
if (char === " " || char === "\t")
|
|
131
|
+
continue;
|
|
132
|
+
const structure = structures.at(-1);
|
|
133
|
+
const token = /^[A-Za-z_][A-Za-z0-9_]*(?=[ \t\n;()<>]|$)/.exec(input.slice(index))?.[0];
|
|
134
|
+
if (structure?.kind === "case" && structure.phase === "header" && token === "in") {
|
|
135
|
+
finishCommand();
|
|
136
|
+
structure.phase = "pattern";
|
|
137
|
+
index += token.length - 1;
|
|
138
|
+
segment = index + 1;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (structure?.phase === "pattern" && (char === "(" || char === "|"))
|
|
142
|
+
continue;
|
|
143
|
+
if (structure?.phase === "pattern" && char === ")") {
|
|
144
|
+
finishCommand();
|
|
145
|
+
structure.phase = "body";
|
|
146
|
+
structure.count = 0;
|
|
147
|
+
segment = index + 1;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (structure?.kind === "for" && structure.phase === "header" && char === "(" && input[index + 1] !== "(") {
|
|
151
|
+
const values = bashExpansion(input, index, depth, "array");
|
|
152
|
+
if (!values)
|
|
153
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
154
|
+
finishCommand();
|
|
155
|
+
const failure = addSubstitutions(values);
|
|
156
|
+
if (failure)
|
|
157
|
+
return failure;
|
|
158
|
+
commands.push(...nestedCommands.splice(0));
|
|
159
|
+
structure.phase = "do";
|
|
160
|
+
if (!/^(?:[ \t\n;]|\\\n|#[^\n]*(?:\n|$))*do(?=[ \t\n;]|$)/.test(input.slice(values.end + 1)))
|
|
161
|
+
structures.pop();
|
|
162
|
+
index = values.end;
|
|
163
|
+
segment = index + 1;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (!words.length && !hasRedirect && !compoundEnd) {
|
|
167
|
+
const definition = bashFunctionHead(input, index);
|
|
168
|
+
if (definition && !header()) {
|
|
169
|
+
index += definition.length - 1;
|
|
170
|
+
segment = index + 1;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (!header() && (token === "if" || token === "while" || token === "until" || token === "for" || token === "select" || token === "case")) {
|
|
174
|
+
if (depth + structures.length >= MAX_SUBSTITUTION_DEPTH)
|
|
175
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
176
|
+
structures.push({
|
|
177
|
+
kind: token === "select" ? "for" : token,
|
|
178
|
+
phase: ["for", "select", "case"].includes(token) ? "header" : "condition",
|
|
179
|
+
count: 0
|
|
180
|
+
});
|
|
181
|
+
index += token.length - 1;
|
|
182
|
+
segment = index + 1;
|
|
183
|
+
inList = false;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (token && ["then", "elif", "else", "fi", "do", "done", "esac"].includes(token) && (!header() || token === "do" && structure?.phase === "do" || token === "esac" && structure?.phase === "pattern")) {
|
|
187
|
+
if (!structure || dangling)
|
|
188
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
189
|
+
if (token === "then") {
|
|
190
|
+
if (structure.kind !== "if" || structure.phase !== "condition" || !structure.count)
|
|
191
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
192
|
+
structure.phase = "body";
|
|
193
|
+
} else if (token === "elif" || token === "else") {
|
|
194
|
+
if (structure.kind !== "if" || structure.phase !== "body" || !structure.count || structure.sawElse)
|
|
195
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
196
|
+
structure.phase = token === "elif" ? "condition" : "body";
|
|
197
|
+
structure.sawElse = token === "else";
|
|
198
|
+
} else if (token === "do") {
|
|
199
|
+
if (!["for", "while", "until"].includes(structure.kind) || !["condition", "do"].includes(structure.phase) || structure.kind !== "for" && !structure.count)
|
|
200
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
201
|
+
structure.phase = "body";
|
|
202
|
+
} else {
|
|
203
|
+
if (token === "fi" && (structure.kind !== "if" || structure.phase !== "body" || !structure.count) || token === "done" && (!["for", "while", "until"].includes(structure.kind) || structure.phase !== "body" || !structure.count) || token === "esac" && (structure.kind !== "case" || structure.phase === "header"))
|
|
204
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
205
|
+
structures.pop();
|
|
206
|
+
statement();
|
|
207
|
+
compoundEnd = true;
|
|
208
|
+
dangling = false;
|
|
209
|
+
}
|
|
210
|
+
structure.count = 0;
|
|
211
|
+
index += token.length - 1;
|
|
212
|
+
segment = index + 1;
|
|
213
|
+
inList = false;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (!header() && (char === "!" && /[ \t\n]/.test(input[index + 1] ?? "") || token === "coproc" && /^coproc[ \t]+(?:[A-Za-z_][A-Za-z0-9_]*[ \t]+)?(?:[{(]|(?:if|while|until|for|case)\b)/.test(input.slice(index)) || token === "time" && /^time[ \t]+(?:-p[ \t]+)?(?:[{(]|(?:if|while|until|for|case)\b)/.test(input.slice(index)))) {
|
|
217
|
+
index += token ? token.length - 1 : 0;
|
|
218
|
+
if (token === "time")
|
|
219
|
+
index += /^[ \t]+-p\b/.exec(input.slice(index + 1))?.[0].length ?? 0;
|
|
220
|
+
if (token === "coproc")
|
|
221
|
+
index += /^[ \t]+[A-Za-z_][A-Za-z0-9_]*[ \t]+(?=[{(]|(?:if|while|until|for|case)\b)/.exec(input.slice(index + 1))?.[0].length ?? 0;
|
|
222
|
+
segment = index + 1;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if ((!words.length && !hasRedirect && !header() || structure?.kind === "for" && structure.phase === "header") && input.startsWith("((", index)) {
|
|
227
|
+
const expression = bashExpansion(input, index, depth, "arithmetic");
|
|
228
|
+
if (!expression)
|
|
229
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
230
|
+
const failure = addSubstitutions(expression);
|
|
231
|
+
if (failure)
|
|
232
|
+
return failure;
|
|
233
|
+
commands.push(...nestedCommands.splice(0));
|
|
234
|
+
statement();
|
|
235
|
+
compoundEnd = !header();
|
|
236
|
+
dangling = false;
|
|
237
|
+
index = expression.end;
|
|
238
|
+
segment = index + 1;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (!words.length && !hasRedirect && !header() && (char === "(" || char === "{" && /[ \t\n]/.test(input[index + 1] ?? ""))) {
|
|
242
|
+
const group = bashDelimited(input, index, depth);
|
|
243
|
+
if (!group || !group.source.trim())
|
|
244
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
245
|
+
const result = scanBash(group.source, depth + 1, budget);
|
|
246
|
+
if (result.kind === "opaque")
|
|
247
|
+
return result;
|
|
248
|
+
commands.push(...result.commands);
|
|
249
|
+
statement();
|
|
250
|
+
compoundEnd = true;
|
|
251
|
+
dangling = false;
|
|
252
|
+
index = group.end;
|
|
253
|
+
segment = index + 1;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (!words.length && !hasRedirect && input.startsWith("[[", index)) {
|
|
257
|
+
const expression = bashExpansion(input, index, depth, "test");
|
|
258
|
+
if (!expression)
|
|
259
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
260
|
+
const failure = addSubstitutions(expression);
|
|
261
|
+
if (failure)
|
|
262
|
+
return failure;
|
|
263
|
+
commands.push(...nestedCommands.splice(0));
|
|
264
|
+
statement();
|
|
265
|
+
compoundEnd = true;
|
|
266
|
+
dangling = false;
|
|
267
|
+
index = expression.end;
|
|
268
|
+
segment = index + 1;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (quote === "single") {
|
|
273
|
+
wordStarted = true;
|
|
274
|
+
wordEnd = index + 1;
|
|
275
|
+
if (char === "'")
|
|
276
|
+
quote = undefined;
|
|
277
|
+
else
|
|
278
|
+
word += char;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (quote === "double") {
|
|
282
|
+
wordStarted = true;
|
|
283
|
+
if (char === '"')
|
|
284
|
+
quote = undefined;
|
|
285
|
+
else if (char === "\\" && index + 1 < input.length) {
|
|
286
|
+
const next = input[index + 1];
|
|
287
|
+
if ('$`"\\\n'.includes(next)) {
|
|
288
|
+
index++;
|
|
289
|
+
if (next !== `
|
|
290
|
+
`)
|
|
291
|
+
word += next;
|
|
292
|
+
} else
|
|
293
|
+
word += char;
|
|
294
|
+
} else if (char === "$" && "({[".includes(input[index + 1] ?? "\x00") || char === "`") {
|
|
295
|
+
const substitution = bashExpansion(input, index, depth, undefined, true);
|
|
296
|
+
if (!substitution || depth >= MAX_SUBSTITUTION_DEPTH)
|
|
297
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
298
|
+
const failure = addSubstitutions(substitution);
|
|
299
|
+
if (failure)
|
|
300
|
+
return failure;
|
|
301
|
+
word += input.slice(index, substitution.end + 1);
|
|
302
|
+
index = substitution.end;
|
|
303
|
+
} else
|
|
304
|
+
word += char;
|
|
305
|
+
wordEnd = index + 1;
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (char === "$" && input[index + 1] === "'") {
|
|
309
|
+
const literal = bashAnsiQuote(input, index + 1);
|
|
310
|
+
if (!literal)
|
|
311
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
312
|
+
wordStarted = true;
|
|
313
|
+
if (!assignmentWord)
|
|
314
|
+
assignmentHeadUnsafe = true;
|
|
315
|
+
word += literal.value;
|
|
316
|
+
index = literal.end;
|
|
317
|
+
wordEnd = index + 1;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (char === "$" && input[index + 1] === '"') {
|
|
321
|
+
quote = "double";
|
|
322
|
+
wordStarted = true;
|
|
323
|
+
if (!assignmentWord)
|
|
324
|
+
assignmentHeadUnsafe = true;
|
|
325
|
+
wordEnd = ++index + 1;
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (char === "'") {
|
|
329
|
+
quote = "single";
|
|
330
|
+
wordStarted = true;
|
|
331
|
+
wordEnd = index + 1;
|
|
332
|
+
if (!assignmentWord)
|
|
333
|
+
assignmentHeadUnsafe = true;
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (char === '"') {
|
|
337
|
+
quote = "double";
|
|
338
|
+
wordStarted = true;
|
|
339
|
+
wordEnd = index + 1;
|
|
340
|
+
if (!assignmentWord)
|
|
341
|
+
assignmentHeadUnsafe = true;
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (char === "\\") {
|
|
345
|
+
if (index + 1 >= input.length)
|
|
346
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
347
|
+
if (input[index + 1] === `
|
|
348
|
+
`)
|
|
349
|
+
index++;
|
|
350
|
+
else {
|
|
351
|
+
wordStarted = true;
|
|
352
|
+
if (!assignmentWord)
|
|
353
|
+
assignmentHeadUnsafe = true;
|
|
354
|
+
word += input[++index];
|
|
355
|
+
wordEnd = index + 1;
|
|
356
|
+
}
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (char === "$" && "({[".includes(input[index + 1] ?? "\x00") || char === "`" || char === "[" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(word) && /^\[[\s\S]*?\]\+?=/.test(input.slice(index)) || char === "(" && (assignmentWord || /[?*+@!]$/.test(word))) {
|
|
360
|
+
const substitution = char === "(" ? bashExpansion(input, index, depth, assignmentWord ? "array" : "pattern") : char === "[" ? bashExpansion(input, index, depth, "subscript") : bashExpansion(input, index, depth);
|
|
361
|
+
if (!substitution || depth >= MAX_SUBSTITUTION_DEPTH)
|
|
362
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
363
|
+
const failure = addSubstitutions(substitution);
|
|
364
|
+
if (failure)
|
|
365
|
+
return failure;
|
|
366
|
+
wordStarted = true;
|
|
367
|
+
word += input.slice(index, substitution.end + 1);
|
|
368
|
+
index = substitution.end;
|
|
369
|
+
wordEnd = index + 1;
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if ((char === "<" || char === ">" || char === "=" && !wordStarted) && input[index + 1] === "(") {
|
|
373
|
+
const substitution = bashDelimited(input, index + 1, depth);
|
|
374
|
+
if (!substitution || depth >= MAX_SUBSTITUTION_DEPTH)
|
|
375
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
376
|
+
const failure = addSubstitutions(substitution);
|
|
377
|
+
if (failure)
|
|
378
|
+
return failure;
|
|
379
|
+
wordStarted = true;
|
|
380
|
+
word += input.slice(index, substitution.end + 1);
|
|
381
|
+
index = substitution.end;
|
|
382
|
+
wordEnd = index + 1;
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (char === "#" && !wordStarted) {
|
|
386
|
+
const newline = input.indexOf(`
|
|
387
|
+
`, index);
|
|
388
|
+
if (words.length > 0 || hasRedirect) {
|
|
389
|
+
finishCommand();
|
|
390
|
+
dangling = false;
|
|
391
|
+
inList = false;
|
|
392
|
+
}
|
|
393
|
+
if (newline === -1)
|
|
394
|
+
break;
|
|
395
|
+
index = newline - 1;
|
|
396
|
+
segment = newline;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
const redirect = "<>&".includes(char) ? BASH_REDIRECTS.find((candidate) => input.startsWith(candidate, index)) : undefined;
|
|
400
|
+
if (redirect) {
|
|
401
|
+
hasRedirect = true;
|
|
402
|
+
if (redirectTarget)
|
|
403
|
+
invalidRedirect = true;
|
|
404
|
+
if (wordStarted && !assignmentHeadUnsafe && /^(?:\d+|\{[A-Za-z_][A-Za-z0-9_]*\})$/.test(word)) {
|
|
405
|
+
if (wordEnd < index)
|
|
406
|
+
commandEnd = wordEnd;
|
|
407
|
+
word = "";
|
|
408
|
+
wordStarted = false;
|
|
409
|
+
} else
|
|
410
|
+
finishWord();
|
|
411
|
+
if (redirectWordCount === undefined && assignmentWords.some((assignment) => !assignment)) {
|
|
412
|
+
redirectWordCount = words.length;
|
|
413
|
+
if (inList)
|
|
414
|
+
resourceEnd = commandEnd;
|
|
415
|
+
}
|
|
416
|
+
if (redirect === "<<" || redirect === "<<-") {
|
|
417
|
+
const delimiter = bashHeredocDelimiter(input, index);
|
|
418
|
+
if (!delimiter)
|
|
419
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
420
|
+
heredocs.push(delimiter);
|
|
421
|
+
wordEnd = delimiter.end + 1;
|
|
422
|
+
index = delimiter.end;
|
|
423
|
+
redirectTarget = false;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
redirectTarget = true;
|
|
427
|
+
index += redirect.length - 1;
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (structures.at(-1)?.phase === "pattern" && (char === ")" || char === "|")) {
|
|
431
|
+
finishWord();
|
|
432
|
+
index--;
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
if ("()".includes(char))
|
|
436
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
437
|
+
if (/\s/.test(char) && !`
|
|
438
|
+
`.includes(char))
|
|
439
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
440
|
+
if (char === " " || char === "\t") {
|
|
441
|
+
finishWord();
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
const next = input[index + 1];
|
|
445
|
+
const separator = char === "&" && next === "&" || char === "|" && (next === "|" || next === "&") ? char + next : char === ";" || char === "|" || char === "&" || char === `
|
|
446
|
+
` ? char : undefined;
|
|
447
|
+
if (separator) {
|
|
448
|
+
const structure = structures.at(-1);
|
|
449
|
+
if (char === ";" && structure?.kind === "case" && structure.phase === "body" && (next === ";" || next === "&")) {
|
|
450
|
+
if (wordStarted || words.length || hasRedirect || compoundEnd)
|
|
451
|
+
finishCommand();
|
|
452
|
+
structure.phase = "pattern";
|
|
453
|
+
index += input.startsWith(";;&", index) ? 2 : 1;
|
|
454
|
+
segment = index + 1;
|
|
455
|
+
inList = false;
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (separator === `
|
|
459
|
+
` && !wordStarted && words.length === 0 && !hasRedirect && !compoundEnd) {
|
|
460
|
+
if (heredocs.length) {
|
|
461
|
+
for (const heredoc of heredocs.splice(0)) {
|
|
462
|
+
const body = bashHeredoc(input, index + 1, heredoc);
|
|
463
|
+
if (!body)
|
|
464
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
465
|
+
if (heredoc.command)
|
|
466
|
+
heredoc.command.resource = input.slice(heredoc.start, body.end).trim();
|
|
467
|
+
if (!heredoc.quoted) {
|
|
468
|
+
const expansion = bashExpansion(body.source, 0, depth, "heredoc");
|
|
469
|
+
if (!expansion)
|
|
470
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
471
|
+
const failure = addSubstitutions(expansion);
|
|
472
|
+
if (failure)
|
|
473
|
+
return failure;
|
|
474
|
+
commands.push(...nestedCommands.splice(0));
|
|
475
|
+
}
|
|
476
|
+
index = body.end;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
segment = index + 1;
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
finishCommand(true);
|
|
483
|
+
if (structure?.kind === "for" && structure.phase === "header")
|
|
484
|
+
structure.phase = "do";
|
|
485
|
+
dangling = separator !== "&" && separator !== ";" && separator !== `
|
|
486
|
+
`;
|
|
487
|
+
inList = dangling;
|
|
488
|
+
if (separator === `
|
|
489
|
+
` && heredocs.length) {
|
|
490
|
+
index--;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
index += separator.length - 1;
|
|
494
|
+
segment = index + 1;
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
wordStarted = true;
|
|
498
|
+
if (char === "=" && !assignmentHeadUnsafe && /^[A-Za-z_][A-Za-z0-9_]*(?:\[.*\])?\+?$/.test(word))
|
|
499
|
+
assignmentWord = true;
|
|
500
|
+
word += char;
|
|
501
|
+
wordEnd = index + 1;
|
|
502
|
+
}
|
|
503
|
+
if (quote)
|
|
504
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
505
|
+
if (heredocs.length)
|
|
506
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
507
|
+
if (wordStarted || words.length > 0 || hasRedirect) {
|
|
508
|
+
finishCommand();
|
|
509
|
+
dangling = false;
|
|
510
|
+
}
|
|
511
|
+
if (dangling)
|
|
512
|
+
invalidStructure = true;
|
|
513
|
+
if (invalidStructure)
|
|
514
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
515
|
+
if (invalidRedirect)
|
|
516
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
517
|
+
if (structures.length)
|
|
518
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
519
|
+
return { kind: "scanned", commands };
|
|
520
|
+
}
|
|
521
|
+
function bashFunctionHead(input, start) {
|
|
522
|
+
return /^(?!if(?:[ \t]|\\\n)*\()(?:function[ \t]+(?:\\\n[ \t]*)*[A-Za-z_][A-Za-z0-9_.:-]*(?:(?:[ \t]|\\\n)*\([ \t]*\))?|(?:[A-Za-z_][A-Za-z0-9_.:-]*(?:[ \t]|\\\n)*)?\([ \t]*\))(?:[ \t\n]|\\\n|#[^\n]*(?:\n|$))*(?=[{(]|\[\[(?=[ \t\n])|(?:if|while|until|for|select|case)[ \t\n])/.exec(input.slice(start))?.[0];
|
|
523
|
+
}
|
|
524
|
+
function bashDelimited(input, start, depth) {
|
|
525
|
+
if (depth >= MAX_SUBSTITUTION_DEPTH)
|
|
526
|
+
return;
|
|
527
|
+
const close = input[start] === "{" ? "}" : ")";
|
|
528
|
+
const cases = [];
|
|
529
|
+
const heredocs = [];
|
|
530
|
+
let commandStart = true;
|
|
531
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
532
|
+
const char = input[index];
|
|
533
|
+
if (char === " " || char === "\t")
|
|
534
|
+
continue;
|
|
535
|
+
if (char === "\\") {
|
|
536
|
+
if (input[index + 1] !== `
|
|
537
|
+
`)
|
|
538
|
+
commandStart = false;
|
|
539
|
+
index++;
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
if (char === "'" || char === '"' || char === "`" || char === "$" && `({['"`.includes(input[index + 1] ?? "\x00")) {
|
|
543
|
+
commandStart = false;
|
|
544
|
+
if (char === "'" || input.startsWith("$'", index)) {
|
|
545
|
+
const end = char === "'" ? input.indexOf("'", index + 1) : bashAnsiQuote(input, index + 1)?.end;
|
|
546
|
+
if (end === undefined || end < 0)
|
|
547
|
+
return;
|
|
548
|
+
index = end;
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
const nested = char === '"' || input.startsWith('$"', index) ? bashExpansion(input, index + (char === "$" ? 1 : 0), depth + 1, "double") : bashExpansion(input, index, depth + 1);
|
|
552
|
+
if (!nested)
|
|
553
|
+
return;
|
|
554
|
+
index = nested.end;
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
const boundary = index === start + 1 || /[ \t\n;|&(){}]/.test(input[index - 1]);
|
|
558
|
+
const definition = commandStart && boundary ? bashFunctionHead(input, index) : undefined;
|
|
559
|
+
if (definition) {
|
|
560
|
+
index += definition.length - 1;
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (char === "#" && boundary) {
|
|
564
|
+
const newline = input.indexOf(`
|
|
565
|
+
`, index);
|
|
566
|
+
if (newline < 0)
|
|
567
|
+
return;
|
|
568
|
+
index = newline - 1;
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
if (input.startsWith("<<<", index)) {
|
|
572
|
+
index += 2;
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
if (input.startsWith("<<", index)) {
|
|
576
|
+
const delimiter = bashHeredocDelimiter(input, index);
|
|
577
|
+
if (!delimiter)
|
|
578
|
+
return;
|
|
579
|
+
heredocs.push(delimiter);
|
|
580
|
+
index = delimiter.end;
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
if (char === `
|
|
584
|
+
` && heredocs.length) {
|
|
585
|
+
for (const heredoc of heredocs.splice(0)) {
|
|
586
|
+
const body = bashHeredoc(input, index + 1, heredoc);
|
|
587
|
+
if (!body)
|
|
588
|
+
return;
|
|
589
|
+
index = body.end;
|
|
590
|
+
}
|
|
591
|
+
commandStart = true;
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
const token = boundary ? /^[A-Za-z_][A-Za-z0-9_]*(?=[ \t\n;()<>]|$)/.exec(input.slice(index))?.[0] : undefined;
|
|
595
|
+
if (token === "case" && commandStart)
|
|
596
|
+
cases.push("header");
|
|
597
|
+
if (token === "in" && cases.at(-1) === "header")
|
|
598
|
+
cases[cases.length - 1] = "pattern";
|
|
599
|
+
if (token === "esac" && (commandStart || cases.at(-1) === "pattern"))
|
|
600
|
+
cases.pop();
|
|
601
|
+
if (token) {
|
|
602
|
+
commandStart = commandStart && ["if", "while", "until", "then", "elif", "else", "do"].includes(token);
|
|
603
|
+
index += token.length - 1;
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
if (cases.length && char === ";" && /[;&]/.test(input[index + 1] ?? ""))
|
|
607
|
+
cases[cases.length - 1] = "pattern";
|
|
608
|
+
if (cases.at(-1) === "pattern" && char === "(")
|
|
609
|
+
continue;
|
|
610
|
+
if (cases.at(-1) === "pattern" && char === ")") {
|
|
611
|
+
cases[cases.length - 1] = "body";
|
|
612
|
+
commandStart = true;
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
if (input.startsWith("((", index)) {
|
|
616
|
+
const nested = bashExpansion(input, index, depth + 1, "arithmetic");
|
|
617
|
+
if (!nested)
|
|
618
|
+
return;
|
|
619
|
+
index = nested.end;
|
|
620
|
+
commandStart = false;
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (char === "(" || char === "{" && boundary && /[ \t\n]/.test(input[index + 1] ?? "")) {
|
|
624
|
+
const nested = bashDelimited(input, index, depth + 1);
|
|
625
|
+
if (!nested)
|
|
626
|
+
return;
|
|
627
|
+
index = nested.end;
|
|
628
|
+
commandStart = false;
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
if (char === close && (close === ")" || boundary))
|
|
632
|
+
return { source: input.slice(start + 1, index), end: index };
|
|
633
|
+
if (/[\n;&|]/.test(char))
|
|
634
|
+
commandStart = true;
|
|
635
|
+
else if (!/[ \t]/.test(char))
|
|
636
|
+
commandStart = false;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
function bashExpansion(input, start, depth, mode, quoted = false) {
|
|
640
|
+
if (depth >= MAX_SUBSTITUTION_DEPTH)
|
|
641
|
+
return;
|
|
642
|
+
if (!mode && input[start] === "`") {
|
|
643
|
+
let source = "";
|
|
644
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
645
|
+
if (input[index] === "`")
|
|
646
|
+
return { source, end: index };
|
|
647
|
+
if (input[index] === "\\" && "$`\\\n".includes(input[index + 1] ?? "\x00")) {
|
|
648
|
+
if (input[++index] !== `
|
|
649
|
+
`)
|
|
650
|
+
source += input[index];
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
source += input[index];
|
|
654
|
+
}
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (!mode && input.startsWith("$(", start) && !input.startsWith("$((", start))
|
|
658
|
+
return bashDelimited(input, start + 1, depth);
|
|
659
|
+
if (!mode && /^\$\{[ \t\n|]/.test(input.slice(start))) {
|
|
660
|
+
const nested = bashDelimited(input, start + 1, depth);
|
|
661
|
+
if (!nested)
|
|
662
|
+
return;
|
|
663
|
+
return { ...nested, source: nested.source.startsWith("|") ? nested.source.slice(1) : nested.source };
|
|
664
|
+
}
|
|
665
|
+
const kind = mode ?? (input[start + 1] === "{" ? "parameter" : input[start + 1] === "[" ? "subscript" : "arithmetic");
|
|
666
|
+
const arithmetic = ["arithmetic", "arithmetic-group", "subscript"].includes(kind);
|
|
667
|
+
const offset = mode ? kind === "heredoc" ? 0 : kind === "arithmetic" || kind === "test" ? 2 : 1 : kind === "arithmetic" ? 3 : 2;
|
|
668
|
+
const close = kind === "heredoc" ? undefined : kind === "double" ? '"' : kind === "parameter" ? "}" : kind === "subscript" ? "]" : kind === "test" ? "]]" : kind === "arithmetic" ? "))" : ")";
|
|
669
|
+
const substitutions = [];
|
|
670
|
+
for (let index = start + offset;index < input.length; index++) {
|
|
671
|
+
const char = input[index];
|
|
672
|
+
if (close && input.startsWith(close, index))
|
|
673
|
+
return { source: input.slice(start + offset, index), end: index + close.length - 1, substitutions };
|
|
674
|
+
if (char === "\\") {
|
|
675
|
+
if (kind !== "heredoc" && kind !== "double" || '$`\\\n"'.includes(input[index + 1] ?? "\x00"))
|
|
676
|
+
index++;
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
if ((char === "'" || input.startsWith("$'", index)) && kind !== "double" && kind !== "heredoc" && !arithmetic && !(kind === "parameter" && quoted)) {
|
|
680
|
+
const end = char === "'" ? input.indexOf("'", index + 1) : bashAnsiQuote(input, index + 1)?.end;
|
|
681
|
+
if (end === undefined || end < 0)
|
|
682
|
+
return;
|
|
683
|
+
index = end;
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
if (char === '"' && kind !== "heredoc") {
|
|
687
|
+
const nested = bashExpansion(input, index, depth + 1, "double");
|
|
688
|
+
if (!nested)
|
|
689
|
+
return;
|
|
690
|
+
substitutions.push(...nested.substitutions);
|
|
691
|
+
index = nested.end;
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
if (char === "`" || char === "$" && "({[".includes(input[index + 1] ?? "\x00")) {
|
|
695
|
+
const nested = bashExpansion(input, index, depth + 1, undefined, kind === "double" || quoted);
|
|
696
|
+
if (!nested)
|
|
697
|
+
return;
|
|
698
|
+
substitutions.push(...nested.substitutions ?? [nested.source]);
|
|
699
|
+
index = nested.end;
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
if ((kind === "array" && "<>=".includes(char) || kind === "test" && "<>".includes(char)) && input[index + 1] === "(") {
|
|
703
|
+
const nested = bashDelimited(input, index + 1, depth + 1);
|
|
704
|
+
if (!nested)
|
|
705
|
+
return;
|
|
706
|
+
substitutions.push(nested.source);
|
|
707
|
+
index = nested.end;
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
if ((arithmetic || kind === "array" || kind === "pattern") && (char === "(" || char === "[") || kind === "parameter" && char === "[" && /^[!#]?[A-Za-z_][A-Za-z0-9_]*$/.test(input.slice(start + offset, index))) {
|
|
711
|
+
const nested = bashExpansion(input, index, depth + 1, char === "[" ? "subscript" : arithmetic ? "arithmetic-group" : kind);
|
|
712
|
+
if (!nested)
|
|
713
|
+
return;
|
|
714
|
+
substitutions.push(...nested.substitutions);
|
|
715
|
+
index = nested.end;
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
if (!mode && kind === "arithmetic" && char === ";")
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
if (kind === "heredoc")
|
|
722
|
+
return { source: input.slice(start), end: input.length - 1, substitutions };
|
|
723
|
+
}
|
|
724
|
+
function bashAnsiQuote(input, start) {
|
|
725
|
+
let value = "";
|
|
726
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
727
|
+
if (input[index] === "'")
|
|
728
|
+
return { value, end: index };
|
|
729
|
+
if (input[index] !== "\\") {
|
|
730
|
+
value += input[index];
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
const escaped = input[++index];
|
|
734
|
+
const simple = {
|
|
735
|
+
a: "\x07",
|
|
736
|
+
b: "\b",
|
|
737
|
+
e: "\x1B",
|
|
738
|
+
E: "\x1B",
|
|
739
|
+
f: "\f",
|
|
740
|
+
n: `
|
|
741
|
+
`,
|
|
742
|
+
r: "\r",
|
|
743
|
+
t: "\t",
|
|
744
|
+
v: "\v",
|
|
745
|
+
"\\": "\\",
|
|
746
|
+
"'": "'",
|
|
747
|
+
'"': '"',
|
|
748
|
+
"?": "?"
|
|
749
|
+
};
|
|
750
|
+
if (escaped in simple)
|
|
751
|
+
value += simple[escaped];
|
|
752
|
+
else if (escaped === "c" && index + 1 < input.length)
|
|
753
|
+
value += String.fromCharCode(input[++index].toUpperCase().charCodeAt(0) & 31);
|
|
754
|
+
else {
|
|
755
|
+
const digits = escaped === "x" ? /^[\da-fA-F]{1,2}/.exec(input.slice(index + 1))?.[0] : escaped === "u" ? /^[\da-fA-F]{1,4}/.exec(input.slice(index + 1))?.[0] : escaped === "U" ? /^[\da-fA-F]{1,8}/.exec(input.slice(index + 1))?.[0] : /[0-7]/.test(escaped ?? "") ? /^[0-7]{1,3}/.exec(input.slice(index))?.[0] : undefined;
|
|
756
|
+
if (!digits)
|
|
757
|
+
value += `\\${escaped}`;
|
|
758
|
+
else {
|
|
759
|
+
const octal = /[0-7]/.test(escaped);
|
|
760
|
+
const point = parseInt(digits, octal ? 8 : 16);
|
|
761
|
+
value += point <= 1114111 ? String.fromCodePoint(point) : "";
|
|
762
|
+
index += digits.length - (octal ? 1 : 0);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function bashHeredocDelimiter(input, start) {
|
|
768
|
+
const tabs = input[start + 2] === "-";
|
|
769
|
+
let delimiter = "";
|
|
770
|
+
let quoted = false;
|
|
771
|
+
let quote;
|
|
772
|
+
let end = start;
|
|
773
|
+
let started = false;
|
|
774
|
+
for (let index = start + (tabs ? 3 : 2);index < input.length; index++) {
|
|
775
|
+
const char = input[index];
|
|
776
|
+
if (!started && /[ \t]/.test(char))
|
|
777
|
+
continue;
|
|
778
|
+
if (!started && char === "#")
|
|
779
|
+
return;
|
|
780
|
+
if (!quote && /[ \t\n;&|()<>]/.test(char))
|
|
781
|
+
return started ? { delimiter, quoted, tabs, end } : undefined;
|
|
782
|
+
if (!quote && input.startsWith("$'", index)) {
|
|
783
|
+
const literal = bashAnsiQuote(input, index + 1);
|
|
784
|
+
if (!literal)
|
|
785
|
+
return;
|
|
786
|
+
delimiter += literal.value;
|
|
787
|
+
quoted = true;
|
|
788
|
+
started = true;
|
|
789
|
+
index = literal.end;
|
|
790
|
+
end = index;
|
|
791
|
+
continue;
|
|
792
|
+
}
|
|
793
|
+
if (!quote && input.startsWith('$"', index)) {
|
|
794
|
+
quote = '"';
|
|
795
|
+
quoted = true;
|
|
796
|
+
started = true;
|
|
797
|
+
end = ++index;
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
if (char === quote) {
|
|
801
|
+
quote = undefined;
|
|
802
|
+
end = index;
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
805
|
+
if (char === "\\" && quote !== "'") {
|
|
806
|
+
const next = input[index + 1];
|
|
807
|
+
if (next === undefined)
|
|
808
|
+
return;
|
|
809
|
+
if (next === `
|
|
810
|
+
`) {
|
|
811
|
+
index++;
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
if (!quote || '$`"\\'.includes(next)) {
|
|
815
|
+
quoted = true;
|
|
816
|
+
started = true;
|
|
817
|
+
delimiter += input[++index];
|
|
818
|
+
end = index;
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
if (!quote && (char === "'" || char === '"')) {
|
|
823
|
+
quote = char;
|
|
824
|
+
quoted = true;
|
|
825
|
+
started = true;
|
|
826
|
+
end = index;
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
delimiter += char;
|
|
830
|
+
started = true;
|
|
831
|
+
end = index;
|
|
832
|
+
}
|
|
833
|
+
if (started && !quote)
|
|
834
|
+
return { delimiter, quoted, tabs, end };
|
|
835
|
+
}
|
|
836
|
+
function bashHeredoc(input, start, delimiter) {
|
|
837
|
+
const bodyStart = start;
|
|
838
|
+
let lineStart = start;
|
|
839
|
+
let line = "";
|
|
840
|
+
for (let index = start;index <= input.length; index++) {
|
|
841
|
+
if (index < input.length && input[index] !== `
|
|
842
|
+
`)
|
|
843
|
+
continue;
|
|
844
|
+
const text = input.slice(start, index);
|
|
845
|
+
line += delimiter.tabs ? text.replace(/^\t+/, "") : text;
|
|
846
|
+
if (!delimiter.quoted && /(?<!\\)(?:\\\\)*\\$/.test(line) && index < input.length) {
|
|
847
|
+
line = line.slice(0, -1);
|
|
848
|
+
start = index + 1;
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
if (line === delimiter.delimiter)
|
|
852
|
+
return { source: input.slice(bodyStart, lineStart), end: index };
|
|
853
|
+
line = "";
|
|
854
|
+
start = index + 1;
|
|
855
|
+
lineStart = start;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
function scanPowerShell(input) {
|
|
859
|
+
return scanPowerShellNested(input, 0, { remaining: MAX_INPUT_LENGTH * MAX_SUBSTITUTION_DEPTH });
|
|
860
|
+
}
|
|
861
|
+
function scanPowerShellNested(input, depth, budget, hash = false) {
|
|
862
|
+
budget.remaining -= input.length;
|
|
863
|
+
if (input.length > MAX_INPUT_LENGTH || depth >= MAX_SUBSTITUTION_DEPTH || budget.remaining < 0)
|
|
864
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
865
|
+
if (/[\0\u0085\u2013-\u2015\u2018-\u201e\ufeff]/.test(input))
|
|
866
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
867
|
+
const commands = [];
|
|
868
|
+
const nestedCommands = [];
|
|
869
|
+
const words = [];
|
|
870
|
+
const rawWords = [];
|
|
871
|
+
const wordEnds = [];
|
|
872
|
+
let segment = 0;
|
|
873
|
+
let word = "";
|
|
874
|
+
let started = false;
|
|
875
|
+
let wordStart = 0;
|
|
876
|
+
let quote;
|
|
877
|
+
let standalone = false;
|
|
878
|
+
let expression = hash;
|
|
879
|
+
let compound = false;
|
|
880
|
+
let stopParsing = false;
|
|
881
|
+
let commandEnd = 0;
|
|
882
|
+
let statementHead = true;
|
|
883
|
+
let invalid = false;
|
|
884
|
+
let redirectTarget = false;
|
|
885
|
+
let comment = false;
|
|
886
|
+
let dangling = false;
|
|
887
|
+
let invocation = false;
|
|
888
|
+
const finishWord = (end) => {
|
|
889
|
+
if (!started)
|
|
890
|
+
return;
|
|
891
|
+
if (word === "--%" && words.length > 0 && !expression && !/['"]/.test(input[wordStart]))
|
|
892
|
+
stopParsing = true;
|
|
893
|
+
if (!redirectTarget) {
|
|
894
|
+
if (!words.length && !invocation && !expression)
|
|
895
|
+
segment = wordStart;
|
|
896
|
+
words.push(word);
|
|
897
|
+
rawWords.push(input.slice(wordStart, end));
|
|
898
|
+
wordEnds.push(end);
|
|
899
|
+
dangling = false;
|
|
900
|
+
}
|
|
901
|
+
commandEnd = end;
|
|
902
|
+
redirectTarget = false;
|
|
903
|
+
word = "";
|
|
904
|
+
started = false;
|
|
905
|
+
};
|
|
906
|
+
const finishCommand = (end, required = false) => {
|
|
907
|
+
finishWord(end);
|
|
908
|
+
const start = segment + input.slice(segment, commandEnd).search(/\S|$/);
|
|
909
|
+
const resource = input.slice(start, commandEnd).trimEnd();
|
|
910
|
+
if (words.length && !expression)
|
|
911
|
+
commands.push({
|
|
912
|
+
resource,
|
|
913
|
+
words: [...words],
|
|
914
|
+
rawWords: [...rawWords],
|
|
915
|
+
wordEnds: wordEnds.map((end) => end - start),
|
|
916
|
+
...statementHead && !invocation ? { statementHead: true } : {}
|
|
917
|
+
});
|
|
918
|
+
else if (!expression && invocation || required && !words.length && !nestedCommands.length)
|
|
919
|
+
invalid = true;
|
|
920
|
+
if (redirectTarget)
|
|
921
|
+
invalid = true;
|
|
922
|
+
commands.push(...nestedCommands.splice(0));
|
|
923
|
+
words.length = 0;
|
|
924
|
+
rawWords.length = 0;
|
|
925
|
+
wordEnds.length = 0;
|
|
926
|
+
redirectTarget = false;
|
|
927
|
+
invocation = false;
|
|
928
|
+
expression = hash;
|
|
929
|
+
compound = false;
|
|
930
|
+
stopParsing = false;
|
|
931
|
+
};
|
|
932
|
+
for (let index = 0;index < input.length; index++) {
|
|
933
|
+
const char = input[index];
|
|
934
|
+
if (!started)
|
|
935
|
+
wordStart = index;
|
|
936
|
+
if (stopParsing) {
|
|
937
|
+
const stop = powerShellStopParsing(input, index);
|
|
938
|
+
const text = input.slice(index, stop).trim();
|
|
939
|
+
if (text) {
|
|
940
|
+
wordStart = index + input.slice(index, stop).search(/\S/);
|
|
941
|
+
word = text;
|
|
942
|
+
started = true;
|
|
943
|
+
finishWord(wordStart + text.length);
|
|
944
|
+
}
|
|
945
|
+
stopParsing = false;
|
|
946
|
+
index = stop - 1;
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
if (quote === "single") {
|
|
950
|
+
started = true;
|
|
951
|
+
if (char === "'" && input[index + 1] === "'") {
|
|
952
|
+
word += "'";
|
|
953
|
+
index++;
|
|
954
|
+
} else if (char === "'") {
|
|
955
|
+
quote = undefined;
|
|
956
|
+
if (standalone)
|
|
957
|
+
finishWord(index + 1);
|
|
958
|
+
} else
|
|
959
|
+
word += char;
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
if (quote === "double") {
|
|
963
|
+
if (char === '"' && input[index + 1] === '"') {
|
|
964
|
+
word += '"';
|
|
965
|
+
index++;
|
|
966
|
+
} else if (char === '"') {
|
|
967
|
+
quote = undefined;
|
|
968
|
+
if (standalone)
|
|
969
|
+
finishWord(index + 1);
|
|
970
|
+
} else if (char === "`") {
|
|
971
|
+
const escape = powerShellEscape(input, index);
|
|
972
|
+
if (!escape)
|
|
973
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
974
|
+
word += escape.value;
|
|
975
|
+
index = escape.end;
|
|
976
|
+
} else if (char === "$" && input[index + 1] === "(") {
|
|
977
|
+
const block = powerShellBlock(input, index + 1, depth);
|
|
978
|
+
if (!block)
|
|
979
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
980
|
+
const result = scanPowerShellNested(block.source, depth + 1, budget);
|
|
981
|
+
if (result.kind === "opaque")
|
|
982
|
+
return result;
|
|
983
|
+
nestedCommands.push(...result.commands);
|
|
984
|
+
word += input.slice(index, block.end + 1);
|
|
985
|
+
index = block.end;
|
|
986
|
+
} else
|
|
987
|
+
word += char;
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
if (char === "'" || char === '"') {
|
|
991
|
+
if (!started && words.length === 0 && !invocation)
|
|
992
|
+
expression = true;
|
|
993
|
+
quote = char === "'" ? "single" : "double";
|
|
994
|
+
standalone = !started;
|
|
995
|
+
started = true;
|
|
996
|
+
continue;
|
|
997
|
+
}
|
|
998
|
+
if (char === "`") {
|
|
999
|
+
const escape = powerShellEscape(input, index);
|
|
1000
|
+
if (!escape)
|
|
1001
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
1002
|
+
if (started || /\S/.test(escape.value)) {
|
|
1003
|
+
started = true;
|
|
1004
|
+
word += escape.value;
|
|
1005
|
+
}
|
|
1006
|
+
index = escape.end;
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
if (!started && words.length > 0 && !expression && /^--%(?=$|[\s;|&(){}])/.test(input.slice(index))) {
|
|
1010
|
+
word = "--%";
|
|
1011
|
+
started = true;
|
|
1012
|
+
finishWord(index + 3);
|
|
1013
|
+
stopParsing = true;
|
|
1014
|
+
index += 2;
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
if (char === "<" && input[index + 1] === "#" && !started) {
|
|
1018
|
+
const end = powerShellComment(input, index);
|
|
1019
|
+
if (end === undefined)
|
|
1020
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1021
|
+
if (!words.length && !invocation)
|
|
1022
|
+
segment = end + 1;
|
|
1023
|
+
index = end;
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
if (char === "#" && (!started || expression)) {
|
|
1027
|
+
if (words.length || started || invocation)
|
|
1028
|
+
finishCommand(index);
|
|
1029
|
+
statementHead = !dangling;
|
|
1030
|
+
comment = true;
|
|
1031
|
+
const endings = [input.indexOf(`
|
|
1032
|
+
`, index), input.indexOf("\r", index)].filter((ending) => ending >= 0);
|
|
1033
|
+
const newline = endings.length > 0 ? Math.min(...endings) : -1;
|
|
1034
|
+
if (newline === -1)
|
|
1035
|
+
break;
|
|
1036
|
+
comment = false;
|
|
1037
|
+
index = input[newline] === "\r" && input[newline + 1] === `
|
|
1038
|
+
` ? newline + 1 : newline;
|
|
1039
|
+
segment = index + 1;
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
const redirect = !started && (char === ">" || char === "*" || /\d/.test(char)) ? powerShellRedirect(input, index) : undefined;
|
|
1043
|
+
if (redirect === false)
|
|
1044
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
1045
|
+
if (redirect) {
|
|
1046
|
+
if (redirectTarget)
|
|
1047
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
1048
|
+
if (words.length === 0)
|
|
1049
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
1050
|
+
redirectTarget = !redirect.includes("&");
|
|
1051
|
+
index += redirect.length - 1;
|
|
1052
|
+
commandEnd = index + 1;
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
if (!started && !words.length && !invocation && !expression && /[A-Za-z]/.test(char)) {
|
|
1056
|
+
const keyword = /^[A-Za-z]+(?=$|[\s({])/.exec(input.slice(index))?.[0]?.toLowerCase();
|
|
1057
|
+
if (keyword && /^(?:if|elseif|else|for|while|do|until|switch|function|filter|try|catch|finally|begin|process|end|clean|param|trap|class|enum|data|dynamicparam|using)$/.test(keyword)) {
|
|
1058
|
+
expression = true;
|
|
1059
|
+
compound = true;
|
|
1060
|
+
index += keyword.length - 1;
|
|
1061
|
+
continue;
|
|
1062
|
+
}
|
|
1063
|
+
if (keyword === "foreach" && /^foreach\s*\(/i.test(input.slice(index))) {
|
|
1064
|
+
expression = true;
|
|
1065
|
+
compound = true;
|
|
1066
|
+
index += keyword.length - 1;
|
|
1067
|
+
continue;
|
|
1068
|
+
}
|
|
1069
|
+
if (keyword && /^(?:return|throw|exit|break|continue)$/.test(keyword)) {
|
|
1070
|
+
index += keyword.length - 1;
|
|
1071
|
+
segment = index + 1;
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (expression && !compound && (char === "=" || /[-+*/%]/.test(char) && input[index + 1] === "=")) {
|
|
1076
|
+
finishWord(index);
|
|
1077
|
+
words.length = 0;
|
|
1078
|
+
rawWords.length = 0;
|
|
1079
|
+
wordEnds.length = 0;
|
|
1080
|
+
expression = false;
|
|
1081
|
+
if (char !== "=")
|
|
1082
|
+
index++;
|
|
1083
|
+
segment = index + 1;
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
if (expression && !started && /^in\b/i.test(input.slice(index))) {
|
|
1087
|
+
words.length = 0;
|
|
1088
|
+
rawWords.length = 0;
|
|
1089
|
+
wordEnds.length = 0;
|
|
1090
|
+
expression = false;
|
|
1091
|
+
index++;
|
|
1092
|
+
segment = index + 1;
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
if (char === "@" && /['"]/.test(input[index + 1] ?? "")) {
|
|
1096
|
+
const literal = powerShellHereString(input, index);
|
|
1097
|
+
if (!literal)
|
|
1098
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
1099
|
+
if (!words.length && !invocation)
|
|
1100
|
+
expression = true;
|
|
1101
|
+
if (input[index + 1] === '"') {
|
|
1102
|
+
const result = powerShellExpansions(literal.source, depth + 1, budget);
|
|
1103
|
+
if (result.kind === "opaque")
|
|
1104
|
+
return result;
|
|
1105
|
+
nestedCommands.push(...result.commands);
|
|
1106
|
+
}
|
|
1107
|
+
word = literal.source;
|
|
1108
|
+
started = true;
|
|
1109
|
+
index = literal.end;
|
|
1110
|
+
finishWord(index + 1);
|
|
1111
|
+
continue;
|
|
1112
|
+
}
|
|
1113
|
+
if (char === "$" && input[index + 1] === "{") {
|
|
1114
|
+
const end = input.indexOf("}", index + 2);
|
|
1115
|
+
if (end < 0)
|
|
1116
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1117
|
+
if (!started && !words.length && !invocation)
|
|
1118
|
+
expression = true;
|
|
1119
|
+
word += input.slice(index, end + 1);
|
|
1120
|
+
started = true;
|
|
1121
|
+
index = end;
|
|
1122
|
+
continue;
|
|
1123
|
+
}
|
|
1124
|
+
const opener = (char === "$" || char === "@") && input[index + 1] === "(" ? index + 1 : char === "@" && input[index + 1] === "{" ? index + 1 : char === "(" || char === "{" || char === "[" && (expression || !started) ? index : undefined;
|
|
1125
|
+
if (opener !== undefined) {
|
|
1126
|
+
if (started && (char === "{" || char === "(")) {
|
|
1127
|
+
finishWord(index);
|
|
1128
|
+
wordStart = index;
|
|
1129
|
+
}
|
|
1130
|
+
if (!started && !words.length && !invocation)
|
|
1131
|
+
expression = true;
|
|
1132
|
+
const block = powerShellBlock(input, opener, depth);
|
|
1133
|
+
if (!block)
|
|
1134
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1135
|
+
const result = scanPowerShellNested(block.source, depth + 1, budget, input[opener] === "[" || char === "@" && input[opener] === "{");
|
|
1136
|
+
if (result.kind === "opaque")
|
|
1137
|
+
return result;
|
|
1138
|
+
nestedCommands.push(...result.commands);
|
|
1139
|
+
started = true;
|
|
1140
|
+
word += input.slice(index, block.end + 1);
|
|
1141
|
+
index = block.end;
|
|
1142
|
+
if (input[opener] === "{" || char === "(")
|
|
1143
|
+
finishWord(index + 1);
|
|
1144
|
+
if (compound && input[opener] === "{") {
|
|
1145
|
+
finishCommand(index + 1);
|
|
1146
|
+
segment = index + 1;
|
|
1147
|
+
}
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
if (char === "}" || char === ")")
|
|
1151
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1152
|
+
if (!started && words.length === 0 && (char === "&" && input[index + 1] !== "&" || char === "." && (/\s/.test(input[index + 1] ?? "") || !input[index + 1]))) {
|
|
1153
|
+
if (invocation)
|
|
1154
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1155
|
+
invocation = true;
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
if (!started && !words.length && !invocation && powerShellExpression(input.slice(index)))
|
|
1159
|
+
expression = true;
|
|
1160
|
+
if (/\s/.test(char) && char !== `
|
|
1161
|
+
` && char !== "\r") {
|
|
1162
|
+
finishWord(index);
|
|
1163
|
+
continue;
|
|
1164
|
+
}
|
|
1165
|
+
const next = input[index + 1];
|
|
1166
|
+
const separator = char === "\r" && next === `
|
|
1167
|
+
` ? char + next : char === "&" && next === "&" || char === "|" && next === "|" ? char + next : char === ";" || char === "|" || char === "&" || char === `
|
|
1168
|
+
` || char === "\r" ? char : undefined;
|
|
1169
|
+
if (separator) {
|
|
1170
|
+
if ((separator === `
|
|
1171
|
+
` || separator === "\r" || separator === `\r
|
|
1172
|
+
`) && !started && !words.length && !invocation) {
|
|
1173
|
+
index += separator.length - 1;
|
|
1174
|
+
segment = index + 1;
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
finishCommand(index, dangling || ![";", `
|
|
1178
|
+
`, "\r", `\r
|
|
1179
|
+
`].includes(separator));
|
|
1180
|
+
dangling = ![";", "&", `
|
|
1181
|
+
`, "\r", `\r
|
|
1182
|
+
`].includes(separator);
|
|
1183
|
+
statementHead = !dangling;
|
|
1184
|
+
index += separator.length - 1;
|
|
1185
|
+
segment = index + 1;
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
started = true;
|
|
1189
|
+
dangling = false;
|
|
1190
|
+
word += char;
|
|
1191
|
+
}
|
|
1192
|
+
if (quote)
|
|
1193
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
1194
|
+
if (!comment)
|
|
1195
|
+
finishCommand(input.length);
|
|
1196
|
+
if (redirectTarget || invalid || dangling)
|
|
1197
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1198
|
+
if (commands.some((command) => !command.words[0]))
|
|
1199
|
+
return { kind: "opaque", reason: "dynamic-command-name" };
|
|
1200
|
+
return { kind: "scanned", commands };
|
|
1201
|
+
}
|
|
1202
|
+
function powerShellBlock(input, start, depth) {
|
|
1203
|
+
if (depth >= MAX_SUBSTITUTION_DEPTH)
|
|
1204
|
+
return;
|
|
1205
|
+
let quote;
|
|
1206
|
+
let standalone = false;
|
|
1207
|
+
let started = false;
|
|
1208
|
+
let head = true;
|
|
1209
|
+
let expression = false;
|
|
1210
|
+
let token = "";
|
|
1211
|
+
const close = input[start] === "(" ? ")" : input[start] === "[" ? "]" : "}";
|
|
1212
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
1213
|
+
const char = input[index];
|
|
1214
|
+
if (quote === "single") {
|
|
1215
|
+
if (char === "'" && input[index + 1] === "'") {
|
|
1216
|
+
token += "'";
|
|
1217
|
+
index++;
|
|
1218
|
+
} else if (char === "'") {
|
|
1219
|
+
quote = undefined;
|
|
1220
|
+
started = !standalone;
|
|
1221
|
+
if (standalone)
|
|
1222
|
+
token = "";
|
|
1223
|
+
} else
|
|
1224
|
+
token += char;
|
|
1225
|
+
continue;
|
|
1226
|
+
}
|
|
1227
|
+
if (quote === "double") {
|
|
1228
|
+
if (char === "`") {
|
|
1229
|
+
const escape = powerShellEscape(input, index);
|
|
1230
|
+
if (!escape)
|
|
1231
|
+
return;
|
|
1232
|
+
token += escape.value;
|
|
1233
|
+
index = escape.end;
|
|
1234
|
+
} else if (char === '"' && input[index + 1] === '"') {
|
|
1235
|
+
token += '"';
|
|
1236
|
+
index++;
|
|
1237
|
+
} else if (char === '"') {
|
|
1238
|
+
quote = undefined;
|
|
1239
|
+
started = !standalone;
|
|
1240
|
+
if (standalone)
|
|
1241
|
+
token = "";
|
|
1242
|
+
} else if (char === "$" && input[index + 1] === "(") {
|
|
1243
|
+
const nested = powerShellBlock(input, index + 1, depth + 1);
|
|
1244
|
+
if (!nested)
|
|
1245
|
+
return;
|
|
1246
|
+
index = nested.end;
|
|
1247
|
+
} else
|
|
1248
|
+
token += char;
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
if (char === "`") {
|
|
1252
|
+
const escape = powerShellEscape(input, index);
|
|
1253
|
+
if (!escape)
|
|
1254
|
+
return;
|
|
1255
|
+
if (started || /\S/.test(escape.value)) {
|
|
1256
|
+
started = true;
|
|
1257
|
+
token += escape.value;
|
|
1258
|
+
}
|
|
1259
|
+
index = escape.end;
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
if (char === "<" && input[index + 1] === "#" && !started) {
|
|
1263
|
+
const end = powerShellComment(input, index);
|
|
1264
|
+
if (end === undefined)
|
|
1265
|
+
return;
|
|
1266
|
+
index = end;
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
if (char === "#" && (!started || expression)) {
|
|
1270
|
+
const endings = [input.indexOf(`
|
|
1271
|
+
`, index), input.indexOf("\r", index)].filter((ending) => ending >= 0);
|
|
1272
|
+
const newline = endings.length > 0 ? Math.min(...endings) : -1;
|
|
1273
|
+
if (newline < 0)
|
|
1274
|
+
return;
|
|
1275
|
+
index = newline;
|
|
1276
|
+
started = false;
|
|
1277
|
+
head = true;
|
|
1278
|
+
expression = false;
|
|
1279
|
+
token = "";
|
|
1280
|
+
continue;
|
|
1281
|
+
}
|
|
1282
|
+
if (char === "@" && /['"]/.test(input[index + 1] ?? "")) {
|
|
1283
|
+
const literal = powerShellHereString(input, index);
|
|
1284
|
+
if (!literal)
|
|
1285
|
+
return;
|
|
1286
|
+
index = literal.end;
|
|
1287
|
+
started = false;
|
|
1288
|
+
head = false;
|
|
1289
|
+
continue;
|
|
1290
|
+
}
|
|
1291
|
+
if (head && !started && (char === "&" && input[index + 1] !== "&" || char === "." && /\s/.test(input[index + 1] ?? ""))) {
|
|
1292
|
+
head = false;
|
|
1293
|
+
continue;
|
|
1294
|
+
}
|
|
1295
|
+
if (expression && (char === "=" || !started && /^in\b/i.test(input.slice(index)))) {
|
|
1296
|
+
if (char !== "=")
|
|
1297
|
+
index++;
|
|
1298
|
+
expression = false;
|
|
1299
|
+
head = true;
|
|
1300
|
+
started = false;
|
|
1301
|
+
token = "";
|
|
1302
|
+
continue;
|
|
1303
|
+
}
|
|
1304
|
+
if (char === "'" || char === '"') {
|
|
1305
|
+
quote = char === "'" ? "single" : "double";
|
|
1306
|
+
standalone = !started;
|
|
1307
|
+
if (head && !started)
|
|
1308
|
+
expression = true;
|
|
1309
|
+
started = true;
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
const redirect = !started && (char === ">" || char === "*" || /\d/.test(char)) ? powerShellRedirect(input, index) : undefined;
|
|
1313
|
+
if (redirect === false)
|
|
1314
|
+
return;
|
|
1315
|
+
if (redirect) {
|
|
1316
|
+
index += redirect.length - 1;
|
|
1317
|
+
token = "";
|
|
1318
|
+
continue;
|
|
1319
|
+
}
|
|
1320
|
+
if (char === "$" && input[index + 1] === "{") {
|
|
1321
|
+
const end = input.indexOf("}", index + 2);
|
|
1322
|
+
if (end < 0)
|
|
1323
|
+
return;
|
|
1324
|
+
if (head && !started)
|
|
1325
|
+
expression = true;
|
|
1326
|
+
index = end;
|
|
1327
|
+
started = true;
|
|
1328
|
+
continue;
|
|
1329
|
+
}
|
|
1330
|
+
if (!started && !head && !expression && /^--%(?=$|[\s;|&(){}])/.test(input.slice(index))) {
|
|
1331
|
+
index = powerShellStopParsing(input, index + 3) - 1;
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
if (char === close)
|
|
1335
|
+
return { source: input.slice(start + 1, index), end: index };
|
|
1336
|
+
if (char === "(" || char === "{" || char === "[" && (!started || expression)) {
|
|
1337
|
+
if (head && !started)
|
|
1338
|
+
expression = true;
|
|
1339
|
+
const nested = powerShellBlock(input, index, depth + 1);
|
|
1340
|
+
if (!nested)
|
|
1341
|
+
return;
|
|
1342
|
+
index = nested.end;
|
|
1343
|
+
started = false;
|
|
1344
|
+
head = false;
|
|
1345
|
+
token = "";
|
|
1346
|
+
continue;
|
|
1347
|
+
}
|
|
1348
|
+
if (/[\s;&|]/.test(char)) {
|
|
1349
|
+
if (token === "--%" && !expression) {
|
|
1350
|
+
index = powerShellStopParsing(input, index) - 1;
|
|
1351
|
+
token = "";
|
|
1352
|
+
continue;
|
|
1353
|
+
}
|
|
1354
|
+
if (/[;&|\r\n]/.test(char)) {
|
|
1355
|
+
head = true;
|
|
1356
|
+
expression = false;
|
|
1357
|
+
} else if (started)
|
|
1358
|
+
head = false;
|
|
1359
|
+
started = false;
|
|
1360
|
+
token = "";
|
|
1361
|
+
continue;
|
|
1362
|
+
}
|
|
1363
|
+
if (head && !started && powerShellExpression(input.slice(index)))
|
|
1364
|
+
expression = true;
|
|
1365
|
+
started = true;
|
|
1366
|
+
token += char;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
var POWERSHELL_ESCAPES = {
|
|
1370
|
+
"0": "\x00",
|
|
1371
|
+
a: "\x07",
|
|
1372
|
+
b: "\b",
|
|
1373
|
+
e: "\x1B",
|
|
1374
|
+
f: "\f",
|
|
1375
|
+
n: `
|
|
1376
|
+
`,
|
|
1377
|
+
r: "\r",
|
|
1378
|
+
t: "\t",
|
|
1379
|
+
v: "\v"
|
|
1380
|
+
};
|
|
1381
|
+
function powerShellEscape(input, start) {
|
|
1382
|
+
const char = input[start + 1];
|
|
1383
|
+
if (char === undefined)
|
|
1384
|
+
return;
|
|
1385
|
+
if (char === "\r" || char === `
|
|
1386
|
+
`)
|
|
1387
|
+
return {
|
|
1388
|
+
value: char === "\r" && input[start + 2] === `
|
|
1389
|
+
` ? `\r
|
|
1390
|
+
` : char,
|
|
1391
|
+
end: start + (char === "\r" && input[start + 2] === `
|
|
1392
|
+
` ? 2 : 1)
|
|
1393
|
+
};
|
|
1394
|
+
if (char === "u" && input[start + 2] === "{") {
|
|
1395
|
+
const code = /^u\{([0-9a-f]{1,6})\}/i.exec(input.slice(start + 1));
|
|
1396
|
+
if (!code || Number.parseInt(code[1], 16) > 1114111)
|
|
1397
|
+
return;
|
|
1398
|
+
return { value: String.fromCodePoint(Number.parseInt(code[1], 16)), end: start + code[0].length };
|
|
1399
|
+
}
|
|
1400
|
+
return { value: POWERSHELL_ESCAPES[char] ?? char, end: start + 1 };
|
|
1401
|
+
}
|
|
1402
|
+
function powerShellExpression(input) {
|
|
1403
|
+
return /^(?:[$!,+]|[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?(?:[dDlLnNuU]|[kKmMgGtTpP][bB])?(?![\w'"`])|0[xX][\da-fA-F]+\b|0[bB][01]+\b|\.[0-9]|-(?:not|bnot|join|split)\b)/i.test(input);
|
|
1404
|
+
}
|
|
1405
|
+
function powerShellStopParsing(input, start) {
|
|
1406
|
+
let quoted = false;
|
|
1407
|
+
for (let index = start;index < input.length; index++) {
|
|
1408
|
+
if (input[index] === '"')
|
|
1409
|
+
quoted = !quoted;
|
|
1410
|
+
if (input[index] === "\r" || input[index] === `
|
|
1411
|
+
` || input[index] === "|" && !quoted)
|
|
1412
|
+
return index;
|
|
1413
|
+
}
|
|
1414
|
+
return input.length;
|
|
1415
|
+
}
|
|
1416
|
+
function powerShellComment(input, start) {
|
|
1417
|
+
const end = input.indexOf("#>", start + 2);
|
|
1418
|
+
return end < 0 ? undefined : end + 1;
|
|
1419
|
+
}
|
|
1420
|
+
function powerShellHereString(input, start) {
|
|
1421
|
+
const header = /^@['"][ \t]*(?:\r\n|\r|\n)/.exec(input.slice(start));
|
|
1422
|
+
if (!header)
|
|
1423
|
+
return;
|
|
1424
|
+
const body = start + header[0].length;
|
|
1425
|
+
for (let index = body;index < input.length; index++) {
|
|
1426
|
+
if (index !== body && input[index - 1] !== "\r" && input[index - 1] !== `
|
|
1427
|
+
`)
|
|
1428
|
+
continue;
|
|
1429
|
+
if (input[index] !== input[start + 1] || input[index + 1] !== "@")
|
|
1430
|
+
continue;
|
|
1431
|
+
const end = index > body && input[index - 1] === `
|
|
1432
|
+
` && input[index - 2] === "\r" ? index - 2 : index > body ? index - 1 : index;
|
|
1433
|
+
return { source: input.slice(body, end), end: index + 1 };
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
function powerShellExpansions(input, depth, budget) {
|
|
1437
|
+
const commands = [];
|
|
1438
|
+
for (let index = 0;index < input.length; index++) {
|
|
1439
|
+
if (input[index] === "`") {
|
|
1440
|
+
index++;
|
|
1441
|
+
continue;
|
|
1442
|
+
}
|
|
1443
|
+
if (!input.startsWith("$(", index))
|
|
1444
|
+
continue;
|
|
1445
|
+
const block = powerShellBlock(input, index + 1, depth);
|
|
1446
|
+
if (!block)
|
|
1447
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1448
|
+
const result = scanPowerShellNested(block.source, depth + 1, budget);
|
|
1449
|
+
if (result.kind === "opaque")
|
|
1450
|
+
return result;
|
|
1451
|
+
commands.push(...result.commands);
|
|
1452
|
+
index = block.end;
|
|
1453
|
+
}
|
|
1454
|
+
return { kind: "scanned", commands };
|
|
1455
|
+
}
|
|
1456
|
+
function powerShellRedirect(input, index) {
|
|
1457
|
+
let cursor = index;
|
|
1458
|
+
if (input[cursor] === "*")
|
|
1459
|
+
cursor++;
|
|
1460
|
+
else
|
|
1461
|
+
while (/\d/.test(input[cursor] ?? ""))
|
|
1462
|
+
cursor++;
|
|
1463
|
+
if (input[cursor] !== ">")
|
|
1464
|
+
return;
|
|
1465
|
+
cursor++;
|
|
1466
|
+
if (input[cursor] === ">")
|
|
1467
|
+
cursor++;
|
|
1468
|
+
if (input[cursor] === "&") {
|
|
1469
|
+
cursor++;
|
|
1470
|
+
while (/\d/.test(input[cursor] ?? ""))
|
|
1471
|
+
cursor++;
|
|
1472
|
+
}
|
|
1473
|
+
const redirect = input.slice(index, cursor);
|
|
1474
|
+
return /^(?:(?:[1-6]|\*)?>>?|[2-6*]>&1)$/.test(redirect) ? redirect : false;
|
|
1475
|
+
}
|
|
1476
|
+
export {
|
|
1477
|
+
exports_scan as ShellScan,
|
|
1478
|
+
scan,
|
|
1479
|
+
scanPowerShell
|
|
1480
|
+
};
|