@opencode/core 0.0.0-dev-261 → 0.0.0-dev-275

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (855) hide show
  1. package/dist/account/sql.js +1 -1
  2. package/dist/agent.js +91 -91
  3. package/dist/aisdk-native.js +101 -101
  4. package/dist/aisdk.js +107 -107
  5. package/dist/app.js +9 -9
  6. package/dist/bus.js +83 -83
  7. package/dist/chunks/{mime-j8c8vpy0.js → bus-00j11h94.js} +55 -55
  8. package/dist/chunks/{mime-034tev2y.js → bus-034tev2y.js} +2 -2
  9. package/dist/chunks/{mime-9kq27ct5.js → bus-05t31zmj.js} +59 -45
  10. package/dist/chunks/{mime-05ga3jym.js → bus-09a1qcfh.js} +32 -32
  11. package/dist/chunks/{mime-6fpf7z8r.js → bus-0ebq21h6.js} +5 -5
  12. package/dist/chunks/{mime-sqjzf8x2.js → bus-0j7gp832.js} +4 -4
  13. package/dist/chunks/{mime-vzppetdn.js → bus-0ma4nchc.js} +3 -3
  14. package/dist/chunks/{mime-d1zc5akg.js → bus-0pnx2fzg.js} +13 -13
  15. package/dist/chunks/{mime-kk2a6haj.js → bus-10tay87v.js} +12 -12
  16. package/dist/chunks/{mime-11hfp36g.js → bus-11hfp36g.js} +1 -1
  17. package/dist/chunks/{mime-qatgy48x.js → bus-17pe40wz.js} +24 -24
  18. package/dist/chunks/{mime-1aqsckx4.js → bus-1aqsckx4.js} +1 -1
  19. package/dist/chunks/{mime-q5fg6nv3.js → bus-1cybwrec.js} +50 -50
  20. package/dist/chunks/{mime-ew1cbhhw.js → bus-1efvewcy.js} +5 -5
  21. package/dist/chunks/{mime-1ep2p91f.js → bus-1ep2p91f.js} +2 -2
  22. package/dist/chunks/{mime-7s9zy64f.js → bus-1hm6kjpw.js} +9 -9
  23. package/dist/chunks/{mime-r1b7wght.js → bus-1kba74ng.js} +24 -24
  24. package/dist/chunks/{mime-qsawh7eg.js → bus-1kn0xbnj.js} +51 -27
  25. package/dist/chunks/{mime-5g59k7nb.js → bus-1tcwzehe.js} +48 -38
  26. package/dist/chunks/{mime-mf0cbe1f.js → bus-1wk7sp0m.js} +24 -24
  27. package/dist/chunks/{mime-1x2knyw4.js → bus-1x2knyw4.js} +1 -1
  28. package/dist/chunks/{mime-p7vhpwh8.js → bus-1yq9hg58.js} +5 -5
  29. package/dist/chunks/bus-1z47fh1w.js +257 -0
  30. package/dist/chunks/{mime-dbqn72gh.js → bus-1zmzx9ha.js} +36 -36
  31. package/dist/chunks/{mime-204s3925.js → bus-204s3925.js} +1 -1
  32. package/dist/chunks/{mime-cpbq744t.js → bus-21g5995g.js} +3 -3
  33. package/dist/chunks/{mime-91xttez3.js → bus-226jktjv.js} +11 -11
  34. package/dist/chunks/{mime-tdjh7w66.js → bus-28d1e7vq.js} +50 -50
  35. package/dist/chunks/{mime-de5ev1ss.js → bus-2992epsb.js} +5 -5
  36. package/dist/chunks/{mime-3h56g0x5.js → bus-2dsx8k42.js} +43 -43
  37. package/dist/chunks/{mime-mpqhh0ff.js → bus-2kqka8y6.js} +9 -9
  38. package/dist/chunks/{mime-ej397f02.js → bus-2p4qkans.js} +4 -4
  39. package/dist/chunks/{mime-dmbvkkjp.js → bus-2pj77wb6.js} +2 -2
  40. package/dist/chunks/{mime-xqpnzpk3.js → bus-2we0z9ck.js} +14 -14
  41. package/dist/chunks/{mime-eek85r7s.js → bus-2y8abx4q.js} +13 -13
  42. package/dist/chunks/{mime-zeba2tf9.js → bus-2ytpdq6b.js} +11 -11
  43. package/dist/chunks/{mime-msj7tqt3.js → bus-31wms35x.js} +8 -8
  44. package/dist/chunks/{mime-4a1s8y4n.js → bus-34e1kmth.js} +18 -18
  45. package/dist/chunks/{mime-0rhd3fk1.js → bus-3979474a.js} +9 -9
  46. package/dist/chunks/{mime-fym7nwga.js → bus-3fb7g6nx.js} +23 -23
  47. package/dist/chunks/{mime-3hepkmqq.js → bus-3hepkmqq.js} +1 -1
  48. package/dist/chunks/{mime-ghzabfw7.js → bus-3nnrc6vy.js} +15 -15
  49. package/dist/chunks/{mime-3nnrz6f6.js → bus-3nnrz6f6.js} +1 -1
  50. package/dist/chunks/{mime-0cjt6hj4.js → bus-3s914nqp.js} +17 -17
  51. package/dist/chunks/{mime-xr2mnjhn.js → bus-3sn4w2fq.js} +16 -16
  52. package/dist/chunks/{mime-d8p3t516.js → bus-3v50s0nm.js} +4 -4
  53. package/dist/chunks/{mime-x2kc3zfh.js → bus-41saj7d3.js} +8 -8
  54. package/dist/chunks/{mime-yvg33581.js → bus-482s3mas.js} +15 -15
  55. package/dist/chunks/{mime-69nya0q4.js → bus-4a32f4de.js} +16 -16
  56. package/dist/chunks/{mime-4dx1dgte.js → bus-4dx1dgte.js} +1 -1
  57. package/dist/chunks/{mime-kzcsdwss.js → bus-4gpw4gsw.js} +3 -3
  58. package/dist/chunks/{mime-4pyp9zr9.js → bus-4pyp9zr9.js} +1 -1
  59. package/dist/chunks/{mime-4v008n1t.js → bus-4v008n1t.js} +1 -1
  60. package/dist/chunks/{mime-ys5ht53z.js → bus-4v8aj50q.js} +26 -26
  61. package/dist/chunks/{mime-zfvpppwm.js → bus-58ect7fx.js} +24 -24
  62. package/dist/chunks/{mime-3xm4v4zv.js → bus-5e5199mn.js} +28 -28
  63. package/dist/chunks/{mime-p36gpr4j.js → bus-5e791j03.js} +3 -3
  64. package/dist/chunks/{mime-5m9w47nd.js → bus-5m9w47nd.js} +1 -1
  65. package/dist/chunks/{mime-c5q03pmb.js → bus-5rfzbttg.js} +5 -5
  66. package/dist/chunks/{mime-2135gcnk.js → bus-62qx2g0z.js} +13 -13
  67. package/dist/chunks/bus-682dpnwj.js +390 -0
  68. package/dist/chunks/{mime-qkevpenz.js → bus-69hetzez.js} +12 -12
  69. package/dist/chunks/{mime-6esdw8yj.js → bus-6esdw8yj.js} +1 -1
  70. package/dist/chunks/{mime-qx2f3s6n.js → bus-6g7dge60.js} +21 -21
  71. package/dist/chunks/{mime-6447hfkj.js → bus-6ws2vnt1.js} +197 -197
  72. package/dist/chunks/{mime-9zk9amhx.js → bus-7248j9gj.js} +21 -21
  73. package/dist/chunks/{mime-76cb1hcw.js → bus-76cb1hcw.js} +1 -1
  74. package/dist/chunks/{mime-7bmhse3q.js → bus-7bmhse3q.js} +1 -1
  75. package/dist/chunks/{mime-1w8p0a18.js → bus-7gn3gxx1.js} +15 -15
  76. package/dist/chunks/{mime-7ssbg7yb.js → bus-7kx48r5w.js} +23 -23
  77. package/dist/chunks/{mime-90g6tx1j.js → bus-7p6s7qrj.js} +11 -11
  78. package/dist/chunks/{mime-7w2ypzdf.js → bus-7w2ypzdf.js} +1 -1
  79. package/dist/chunks/{mime-vh5h3cx2.js → bus-7xy5j6y0.js} +29 -29
  80. package/dist/chunks/{mime-h2atfgt1.js → bus-83gc5kcm.js} +8 -8
  81. package/dist/chunks/{mime-k989ntyt.js → bus-85zye1zb.js} +9 -9
  82. package/dist/chunks/{mime-k9xb07cm.js → bus-86p3vx58.js} +10 -10
  83. package/dist/chunks/{mime-25h84942.js → bus-8b3vzgkx.js} +4 -4
  84. package/dist/chunks/{mime-cw43sd18.js → bus-8bjrjs1n.js} +4 -4
  85. package/dist/chunks/{mime-1wpsahk2.js → bus-8g0en9rg.js} +10 -10
  86. package/dist/chunks/{mime-98sj2w4a.js → bus-8hq15dve.js} +37 -37
  87. package/dist/chunks/{mime-1ene02nc.js → bus-8nxx61kp.js} +31 -31
  88. package/dist/chunks/{mime-njqr3cdm.js → bus-8qxrenr7.js} +9 -9
  89. package/dist/chunks/{mime-mpc1wbnc.js → bus-8tmhq2sq.js} +28 -28
  90. package/dist/chunks/{mime-dgy529yc.js → bus-8vbscmtw.js} +28 -28
  91. package/dist/chunks/{mime-8wtp7s3z.js → bus-8wtp7s3z.js} +1 -1
  92. package/dist/chunks/{mime-d390zwf3.js → bus-8ykqf5wm.js} +8 -8
  93. package/dist/chunks/{mime-90zstvax.js → bus-90zstvax.js} +1 -1
  94. package/dist/chunks/{mime-2b25mbj3.js → bus-928v60yv.js} +3 -3
  95. package/dist/chunks/{mime-xk2zn0cv.js → bus-95sp4hdf.js} +4 -4
  96. package/dist/chunks/{mime-ztytxe50.js → bus-96kzvzq7.js} +11 -11
  97. package/dist/chunks/{mime-tspwpfmw.js → bus-98w60ksq.js} +3 -3
  98. package/dist/chunks/{mime-1hma5w09.js → bus-9ew7ajy0.js} +97 -97
  99. package/dist/chunks/{mime-v7a0snhq.js → bus-9f3sjfep.js} +9 -9
  100. package/dist/chunks/{mime-ddb1fpa4.js → bus-9fhmc1w3.js} +18 -18
  101. package/dist/chunks/{mime-85aybcep.js → bus-9smg2fxp.js} +77 -77
  102. package/dist/chunks/{mime-nj6nnwwx.js → bus-a013n6rr.js} +30 -30
  103. package/dist/chunks/{mime-c4phwmq5.js → bus-a4ww6fpm.js} +6 -6
  104. package/dist/chunks/{mime-0h3385jp.js → bus-ac3vkw7y.js} +2 -2
  105. package/dist/chunks/{mime-36qx82yz.js → bus-agqd6nxz.js} +2 -2
  106. package/dist/chunks/{mime-sefdxvs5.js → bus-arth2bzp.js} +23 -23
  107. package/dist/chunks/{mime-ayjs7tqn.js → bus-ayjs7tqn.js} +2 -2
  108. package/dist/chunks/{mime-mgvjndd7.js → bus-b5qmte8y.js} +10 -10
  109. package/dist/chunks/{mime-h5060pr3.js → bus-b6twm7ry.js} +11 -11
  110. package/dist/chunks/{mime-b6vsg801.js → bus-b6vsg801.js} +2 -2
  111. package/dist/chunks/{mime-4yscp7k1.js → bus-bcsckb3t.js} +23 -23
  112. package/dist/chunks/bus-c078hgae.js +2050 -0
  113. package/dist/chunks/{mime-hbe771na.js → bus-c0kkxqfe.js} +17 -17
  114. package/dist/chunks/{mime-3k3cm4zk.js → bus-c8zchzzf.js} +11 -11
  115. package/dist/chunks/{mime-ssfehs1z.js → bus-c9t2ty9q.js} +4 -4
  116. package/dist/chunks/{mime-mz88wxq7.js → bus-chhg004d.js} +22 -22
  117. package/dist/chunks/{mime-ekd6nmzx.js → bus-cm8n6e1j.js} +18 -13
  118. package/dist/chunks/{mime-cwrgdav8.js → bus-cwrgdav8.js} +2 -2
  119. package/dist/chunks/{mime-kpj4bnmp.js → bus-d1k7zqa6.js} +9 -9
  120. package/dist/chunks/{mime-hkv8mm0v.js → bus-d2zq2nk9.js} +16 -16
  121. package/dist/chunks/{mime-ya13x5xa.js → bus-d441h1x7.js} +16 -16
  122. package/dist/chunks/{mime-bvk25jmh.js → bus-d4tdxwg3.js} +4 -4
  123. package/dist/chunks/{mime-d4v9tmah.js → bus-d4v9tmah.js} +2 -2
  124. package/dist/chunks/{mime-bcyfntnp.js → bus-d9mxzqst.js} +17 -17
  125. package/dist/chunks/{mime-z2dgfpsc.js → bus-darnxsvb.js} +6 -6
  126. package/dist/chunks/{mime-avgzkss2.js → bus-dbmp929s.js} +5 -5
  127. package/dist/chunks/{mime-enkpkfwx.js → bus-ddvn7d3w.js} +8 -8
  128. package/dist/chunks/{mime-8p46qq0s.js → bus-degxk2tg.js} +19 -19
  129. package/dist/chunks/{mime-kehv92bx.js → bus-dev678md.js} +51 -51
  130. package/dist/chunks/{mime-8f7wz2tq.js → bus-dgpxhmaz.js} +15 -15
  131. package/dist/chunks/{mime-4thnqhg3.js → bus-dpyfckyt.js} +1 -1
  132. package/dist/chunks/{mime-dt77769w.js → bus-dt77769w.js} +1 -1
  133. package/dist/chunks/{mime-zba90nwx.js → bus-dtfn9c89.js} +13 -13
  134. package/dist/chunks/{mime-8pyn3tva.js → bus-dxzy608a.js} +6 -6
  135. package/dist/chunks/{mime-xmcerbsc.js → bus-e5kybrsq.js} +23 -23
  136. package/dist/chunks/{mime-e834z07m.js → bus-e834z07m.js} +1 -1
  137. package/dist/chunks/{mime-ecgyc3nf.js → bus-ec95eyzx.js} +4 -4
  138. package/dist/chunks/{mime-9wkv0v86.js → bus-ef6dy9g0.js} +27 -27
  139. package/dist/chunks/{mime-7qrckcvm.js → bus-ehhwdvk1.js} +24 -24
  140. package/dist/chunks/{mime-jgmjv1sa.js → bus-ehtz5q4m.js} +30 -30
  141. package/dist/chunks/{mime-v4g74xq2.js → bus-f0hs2mq3.js} +21 -21
  142. package/dist/chunks/{mime-1kmbt0nq.js → bus-f0vtm8p6.js} +16 -16
  143. package/dist/chunks/{mime-kt9zkheb.js → bus-f2xxa684.js} +62 -62
  144. package/dist/chunks/{mime-fffv3p7h.js → bus-fffv3p7h.js} +1 -1
  145. package/dist/chunks/{mime-fg9p65nk.js → bus-fg9p65nk.js} +2 -2
  146. package/dist/chunks/{mime-nf5vm8zn.js → bus-fq9s0kxx.js} +31 -31
  147. package/dist/chunks/{mime-m6jwak7z.js → bus-fv7v599h.js} +13 -13
  148. package/dist/chunks/{mime-6zh541c7.js → bus-fybtq79z.js} +58 -58
  149. package/dist/chunks/{mime-ape62p7n.js → bus-g8vb0hj0.js} +30 -30
  150. package/dist/chunks/{mime-gd8sx287.js → bus-gcye4jv7.js} +4 -4
  151. package/dist/chunks/{mime-abne355d.js → bus-ghcecwt0.js} +47 -47
  152. package/dist/chunks/{mime-6vkwvj03.js → bus-gs1x404j.js} +21 -21
  153. package/dist/chunks/{mime-dn75kjkt.js → bus-gxb4nygb.js} +10 -10
  154. package/dist/chunks/{mime-t6t8h010.js → bus-ha5ntr8a.js} +42 -42
  155. package/dist/chunks/{mime-mg356nz4.js → bus-hgfegmhz.js} +58 -26
  156. package/dist/chunks/{mime-hh7kjqtw.js → bus-hh7kjqtw.js} +1 -1
  157. package/dist/chunks/{mime-7q2ytnwk.js → bus-hmeh93yc.js} +29 -29
  158. package/dist/chunks/{mime-k4s79gcj.js → bus-hpejq3g9.js} +9 -9
  159. package/dist/chunks/{mime-hpg1pkwy.js → bus-hpg1pkwy.js} +1 -1
  160. package/dist/chunks/{mime-bx6g05dx.js → bus-hq4c2e72.js} +17 -17
  161. package/dist/chunks/{mime-9esxa6rs.js → bus-hq8347db.js} +13 -13
  162. package/dist/chunks/{mime-0eq01nmm.js → bus-hs9b4b47.js} +9 -9
  163. package/dist/chunks/{mime-dt8yqcce.js → bus-hxch9gky.js} +19 -19
  164. package/dist/chunks/{mime-zeg6dwe8.js → bus-j4rzh0zg.js} +37 -37
  165. package/dist/chunks/{mime-4tdcetb8.js → bus-j9mte5pw.js} +27 -27
  166. package/dist/chunks/{mime-dja1b12h.js → bus-jchjggqf.js} +2 -2
  167. package/dist/chunks/{mime-jfaecv01.js → bus-jfaecv01.js} +1 -1
  168. package/dist/chunks/{mime-crttzga9.js → bus-jjescw8y.js} +8 -8
  169. package/dist/chunks/{mime-7h09t6vy.js → bus-jns4gqy7.js} +4 -4
  170. package/dist/chunks/{mime-dtpswqs3.js → bus-jqqh3nrt.js} +28 -28
  171. package/dist/chunks/{mime-2qwjmz35.js → bus-js92w05q.js} +11 -11
  172. package/dist/chunks/{mime-jtnps1zs.js → bus-jtnps1zs.js} +2 -2
  173. package/dist/chunks/{mime-hj8ktf3x.js → bus-jwckxkn1.js} +11 -11
  174. package/dist/chunks/{mime-4hebgate.js → bus-jydzs9jd.js} +12 -12
  175. package/dist/chunks/{mime-e11a9bx3.js → bus-jywsdv1w.js} +3 -3
  176. package/dist/chunks/{mime-fg9n74ny.js → bus-k6fx5fwj.js} +22 -22
  177. package/dist/chunks/{mime-c4vfmmrn.js → bus-k7fcp7vh.js} +8 -8
  178. package/dist/chunks/{mime-k814nvkf.js → bus-k814nvkf.js} +1 -1
  179. package/dist/chunks/{mime-zjqm9jqg.js → bus-kc03nrdn.js} +47 -47
  180. package/dist/chunks/{mime-wwgpyqzb.js → bus-kcg78dnn.js} +9 -9
  181. package/dist/chunks/{mime-dgzhj2a3.js → bus-kf78hse3.js} +17 -17
  182. package/dist/chunks/{mime-ych9pyce.js → bus-kh233pt5.js} +10 -10
  183. package/dist/chunks/{mime-904xv1p5.js → bus-knh1jnvy.js} +27 -27
  184. package/dist/chunks/{mime-hw311zkt.js → bus-ksw9k14w.js} +46 -53
  185. package/dist/chunks/{mime-kt3bjfbg.js → bus-kt3bjfbg.js} +1 -1
  186. package/dist/chunks/{mime-q5654s0t.js → bus-kz8v4jkb.js} +27 -27
  187. package/dist/chunks/{mime-f1md2d8q.js → bus-m0qs22fp.js} +19 -19
  188. package/dist/chunks/{mime-m1714858.js → bus-m1714858.js} +1 -1
  189. package/dist/chunks/{mime-zcf14pnt.js → bus-m2w2s527.js} +4 -4
  190. package/dist/chunks/{mime-vmfhgzt5.js → bus-m37sd98t.js} +4 -4
  191. package/dist/chunks/{mime-c3gnxtmm.js → bus-m5vcha6x.js} +12 -12
  192. package/dist/chunks/{mime-m9w0rfyh.js → bus-m9w0rfyh.js} +1 -1
  193. package/dist/chunks/{mime-mb7mbhnz.js → bus-mb7mbhnz.js} +3 -3
  194. package/dist/chunks/{mime-aes06p6b.js → bus-meq8xbkf.js} +5 -5
  195. package/dist/chunks/{mime-f004ykrw.js → bus-mh65p8pj.js} +25 -25
  196. package/dist/chunks/{mime-h3pj7a7m.js → bus-mh93svdp.js} +18 -18
  197. package/dist/chunks/{mime-w81tm3vv.js → bus-mmw6hwzc.js} +17 -17
  198. package/dist/chunks/{mime-50x74c5d.js → bus-mnad5nn2.js} +33 -33
  199. package/dist/chunks/{mime-4qxqnvmw.js → bus-mpza5t97.js} +29 -29
  200. package/dist/chunks/{mime-2zp5a6yg.js → bus-mqe7nf5n.js} +3 -3
  201. package/dist/chunks/{mime-45xte6ee.js → bus-mz45bcy6.js} +26 -26
  202. package/dist/chunks/{mime-ykcxy4jb.js → bus-n3x35gjg.js} +14 -14
  203. package/dist/chunks/{mime-sg2p3jg1.js → bus-n76e6m8b.js} +11 -11
  204. package/dist/chunks/{mime-nah043kf.js → bus-nah043kf.js} +1 -1
  205. package/dist/chunks/{mime-8dnnkdqt.js → bus-ncr9krzg.js} +22 -22
  206. package/dist/chunks/{mime-9pf0pmfk.js → bus-nrtmfbdc.js} +11 -11
  207. package/dist/chunks/{mime-y24rddh5.js → bus-nvgj5k0n.js} +14 -14
  208. package/dist/chunks/{mime-p015t6z3.js → bus-p015t6z3.js} +2 -2
  209. package/dist/chunks/{mime-xcmevbrr.js → bus-p2rrmpys.js} +11 -11
  210. package/dist/chunks/{mime-y2bdgeyh.js → bus-p59qfrvx.js} +3 -3
  211. package/dist/chunks/{mime-br6xvyb6.js → bus-p6bk0asb.js} +21 -21
  212. package/dist/chunks/{mime-kprjpmw6.js → bus-pdw1qznx.js} +33 -33
  213. package/dist/chunks/{mime-6evmzryz.js → bus-pexrpc5k.js} +9 -9
  214. package/dist/chunks/{mime-jw5zbn3z.js → bus-pjptrb5y.js} +37 -37
  215. package/dist/chunks/{mime-pknna89w.js → bus-pknna89w.js} +1 -1
  216. package/dist/chunks/{mime-nym9wyb3.js → bus-pzsa5b6k.js} +6 -6
  217. package/dist/chunks/{mime-s4fkafj4.js → bus-q0ye6e4s.js} +2 -2
  218. package/dist/chunks/{mime-hk82q6eb.js → bus-q17cwwmb.js} +12 -12
  219. package/dist/chunks/{mime-1dtbfpzr.js → bus-q498qw3k.js} +28 -28
  220. package/dist/chunks/{mime-hcaakz9a.js → bus-q6sa0fx3.js} +14 -14
  221. package/dist/chunks/{mime-bgwcavjj.js → bus-q6yx0pgq.js} +9 -9
  222. package/dist/chunks/{mime-hbqfs0kq.js → bus-q7rm49kv.js} +11 -11
  223. package/dist/chunks/{mime-sj7qk1wq.js → bus-qbc6w44s.js} +20 -20
  224. package/dist/chunks/{mime-09npetjp.js → bus-qbj75hz3.js} +36 -36
  225. package/dist/chunks/{mime-qp7r0hxv.js → bus-qp7r0hxv.js} +1 -1
  226. package/dist/chunks/{mime-1kn6jdkn.js → bus-qqpbcr2p.js} +4 -4
  227. package/dist/chunks/{mime-qqvy8y24.js → bus-qqvy8y24.js} +1 -1
  228. package/dist/chunks/{mime-x3a4n8aj.js → bus-qspstntz.js} +13 -13
  229. package/dist/chunks/{mime-91a9ea02.js → bus-qwhg5edk.js} +21 -21
  230. package/dist/chunks/{mime-1nwvfgjk.js → bus-qy40w2mn.js} +25 -25
  231. package/dist/chunks/{mime-gy1k9bkm.js → bus-r13t3b9j.js} +5 -5
  232. package/dist/chunks/{mime-xp4cjnvy.js → bus-r2s7w9p5.js} +4 -4
  233. package/dist/chunks/{mime-q8jvga0v.js → bus-r2vthv2q.js} +53 -53
  234. package/dist/chunks/{mime-r542h3bh.js → bus-r542h3bh.js} +1 -1
  235. package/dist/chunks/{mime-2e3yfjq6.js → bus-r8d5ttcp.js} +8 -8
  236. package/dist/chunks/{mime-rb9dy4dg.js → bus-rb9dy4dg.js} +1 -1
  237. package/dist/chunks/{mime-y3a4nh1w.js → bus-rcds6jmy.js} +19 -19
  238. package/dist/chunks/{mime-tr6n2pd7.js → bus-rekbjepc.js} +22 -22
  239. package/dist/chunks/{mime-vrcsa8qx.js → bus-rjnacbrz.js} +9 -9
  240. package/dist/chunks/{mime-ksxm71aw.js → bus-rk7zzszn.js} +8 -8
  241. package/dist/chunks/{mime-3f6130kj.js → bus-rt4hpzta.js} +27 -27
  242. package/dist/chunks/{mime-rt5dr6hb.js → bus-rt5dr6hb.js} +1 -1
  243. package/dist/chunks/{mime-zw960apb.js → bus-rwcj15n0.js} +353 -353
  244. package/dist/chunks/{mime-87vy0wwt.js → bus-ryyta8gj.js} +11 -11
  245. package/dist/chunks/{mime-pcc4d2n5.js → bus-s4vgxntc.js} +9 -9
  246. package/dist/chunks/{mime-2kg89srt.js → bus-s7kyse9r.js} +4 -4
  247. package/dist/chunks/{mime-z6b5kr5f.js → bus-s8sx6y1x.js} +23 -23
  248. package/dist/chunks/{mime-sa3fpqfw.js → bus-sa3fpqfw.js} +2 -2
  249. package/dist/chunks/{mime-qnt4yn7k.js → bus-sm5prsna.js} +2 -2
  250. package/dist/chunks/{mime-9e3hvwnw.js → bus-sp4h8jpm.js} +30 -30
  251. package/dist/chunks/{mime-sqbb0ctm.js → bus-sqbb0ctm.js} +5 -5
  252. package/dist/chunks/{mime-6vmee23j.js → bus-sqrwb7ek.js} +3 -3
  253. package/dist/chunks/{mime-svcy3p9a.js → bus-svcy3p9a.js} +1 -1
  254. package/dist/chunks/{mime-qevqwm2d.js → bus-sxdhpgmr.js} +29 -29
  255. package/dist/chunks/{mime-bpyckyws.js → bus-t3dqt28d.js} +15 -15
  256. package/dist/chunks/{mime-78p2h4ex.js → bus-t8erkws8.js} +5 -5
  257. package/dist/chunks/{mime-tczq8hjw.js → bus-tczq8hjw.js} +1 -1
  258. package/dist/chunks/{mime-h6sym59v.js → bus-tg1716pc.js} +6 -6
  259. package/dist/chunks/{mime-ajntjgfc.js → bus-tt3yxz2r.js} +15 -15
  260. package/dist/chunks/{mime-twssxy5n.js → bus-twssxy5n.js} +2 -2
  261. package/dist/chunks/{mime-kdd90951.js → bus-v0dqmjgm.js} +53 -53
  262. package/dist/chunks/{mime-v2r1d0zg.js → bus-v2r1d0zg.js} +1 -1
  263. package/dist/chunks/{mime-fddcjhj2.js → bus-v4mtj4vv.js} +25 -25
  264. package/dist/chunks/{mime-jjv1q8d4.js → bus-vdj2189h.js} +14 -14
  265. package/dist/chunks/{mime-0j9k711p.js → bus-vhazrdaa.js} +15 -15
  266. package/dist/chunks/{mime-48es43h7.js → bus-vhjra7pn.js} +10 -10
  267. package/dist/chunks/{mime-kewx5hse.js → bus-vje3bk9q.js} +7 -7
  268. package/dist/chunks/{mime-jjmhfyts.js → bus-vrxpgxjt.js} +13 -13
  269. package/dist/chunks/{mime-hz5a1k95.js → bus-vsq2sm2q.js} +26 -26
  270. package/dist/chunks/{mime-5enarcya.js → bus-w2eysc6j.js} +6 -6
  271. package/dist/chunks/{mime-gqwtxsn1.js → bus-w36nberk.js} +33 -33
  272. package/dist/chunks/{mime-w3wsvvr9.js → bus-w3wsvvr9.js} +1 -1
  273. package/dist/chunks/{mime-107zh63q.js → bus-w52wajpr.js} +3 -3
  274. package/dist/chunks/{mime-x7qkck9a.js → bus-w6v1rynq.js} +15 -15
  275. package/dist/chunks/{mime-wakvkjy4.js → bus-wakvkjy4.js} +1 -1
  276. package/dist/chunks/{mime-wd87259q.js → bus-wd87259q.js} +1 -1
  277. package/dist/chunks/{mime-wegkxhrn.js → bus-wegkxhrn.js} +2 -2
  278. package/dist/chunks/{mime-f0ay53g6.js → bus-wfz8zxsv.js} +3 -3
  279. package/dist/chunks/{mime-wnhgecwx.js → bus-wnhgecwx.js} +1 -1
  280. package/dist/chunks/{mime-0h8y3ex8.js → bus-wr3re1en.js} +4 -4
  281. package/dist/chunks/bus-wtgvz1w4.js +26 -0
  282. package/dist/chunks/{mime-gw7tqdxz.js → bus-wwszdvz7.js} +5 -5
  283. package/dist/chunks/{mime-czey47wt.js → bus-wxtbyv82.js} +4 -4
  284. package/dist/chunks/{mime-b4hen3e4.js → bus-x271axaw.js} +7 -7
  285. package/dist/chunks/{mime-sdvfaqjv.js → bus-x686a40m.js} +22 -22
  286. package/dist/chunks/{mime-d64mgb0d.js → bus-x6vg8sze.js} +37 -37
  287. package/dist/chunks/{mime-7q3qfmpr.js → bus-x7xp1w7g.js} +29 -29
  288. package/dist/chunks/{mime-xd9cc171.js → bus-xd9cc171.js} +1 -1
  289. package/dist/chunks/bus-xj80yh0e.js +407 -0
  290. package/dist/chunks/{mime-c6x7d2ts.js → bus-xmx7xj34.js} +4 -4
  291. package/dist/chunks/{mime-1dy1zrej.js → bus-y4c93yhq.js} +89 -89
  292. package/dist/chunks/{mime-tt26s4vq.js → bus-y6ycwz8c.js} +11 -11
  293. package/dist/chunks/{mime-yara3q77.js → bus-yara3q77.js} +2 -2
  294. package/dist/chunks/{mime-yb20nhc3.js → bus-yb20nhc3.js} +1 -1
  295. package/dist/chunks/{mime-w4ykgd89.js → bus-yn7vgazy.js} +5 -5
  296. package/dist/chunks/{mime-p87480bx.js → bus-z28kzp3s.js} +9 -9
  297. package/dist/chunks/{mime-5f3qf23k.js → bus-z6e3jbzz.js} +20 -20
  298. package/dist/chunks/{mime-17x7vgjp.js → bus-z6wb4d7c.js} +29 -29
  299. package/dist/chunks/bus-z7bdqmx5.js +18 -0
  300. package/dist/chunks/{mime-2hrk5wbs.js → bus-zmg3gahh.js} +15 -15
  301. package/dist/chunks/{mime-29db0j4x.js → bus-zqs4wz9p.js} +4 -4
  302. package/dist/chunks/{mime-x6tax50b.js → bus-zvv2gg2z.js} +6 -6
  303. package/dist/codemode/catalog.js +1 -1
  304. package/dist/codemode/instructions.js +7 -7
  305. package/dist/codemode/tool.js +8 -4
  306. package/dist/codemode/web.js +1 -1
  307. package/dist/command.js +91 -91
  308. package/dist/config/discovery.js +94 -94
  309. package/dist/config/integration.js +3 -3
  310. package/dist/config/managed.js +1 -1
  311. package/dist/config/markdown.js +1 -1
  312. package/dist/config/normalize.js +111 -111
  313. package/dist/config/plugin/agent.js +129 -129
  314. package/dist/config/plugin/command.js +226 -226
  315. package/dist/config/plugin/compaction.js +169 -169
  316. package/dist/config/plugin/compatibility.js +149 -149
  317. package/dist/config/plugin/entry-observer.js +1 -1
  318. package/dist/config/plugin/formatter.js +130 -130
  319. package/dist/config/plugin/image.js +129 -129
  320. package/dist/config/plugin/instruction.js +129 -129
  321. package/dist/config/plugin/location-watcher.js +129 -129
  322. package/dist/config/plugin/mcp.js +136 -136
  323. package/dist/config/plugin/policy.js +129 -129
  324. package/dist/config/plugin/provider.js +129 -129
  325. package/dist/config/plugin/reference.js +131 -131
  326. package/dist/config/plugin/shell.js +131 -131
  327. package/dist/config/plugin/skill-file.js +145 -145
  328. package/dist/config/plugin/skill-scan.js +1 -1
  329. package/dist/config/plugin/skill.js +152 -152
  330. package/dist/config/plugin/snapshot.js +129 -129
  331. package/dist/config/plugin/source.js +126 -126
  332. package/dist/config/plugin/tool-output.js +130 -130
  333. package/dist/config/plugin/websearch.js +130 -130
  334. package/dist/config/plugin/worktree.js +131 -131
  335. package/dist/config/variable.js +1 -1
  336. package/dist/config/watch.js +1 -1
  337. package/dist/config.js +132 -132
  338. package/dist/console-access.js +1 -1
  339. package/dist/credential/sql.js +2 -2
  340. package/dist/credential.js +93 -93
  341. package/dist/database/database.js +80 -80
  342. package/dist/database/drizzle/effect-sqlite/driver.js +12 -12
  343. package/dist/database/drizzle/effect-sqlite/index.js +12 -12
  344. package/dist/database/drizzle/effect-sqlite/session.js +11 -11
  345. package/dist/database/drizzle/index.js +13 -13
  346. package/dist/database/drizzle/internal/drizzle-utils.js +1 -1
  347. package/dist/database/drizzle/sqlite-core/effect/count.js +1 -1
  348. package/dist/database/drizzle/sqlite-core/effect/db.js +9 -9
  349. package/dist/database/drizzle/sqlite-core/effect/delete.js +2 -2
  350. package/dist/database/drizzle/sqlite-core/effect/index.js +10 -10
  351. package/dist/database/drizzle/sqlite-core/effect/insert.js +2 -2
  352. package/dist/database/drizzle/sqlite-core/effect/query.js +1 -1
  353. package/dist/database/drizzle/sqlite-core/effect/raw.js +1 -1
  354. package/dist/database/drizzle/sqlite-core/effect/select.js +2 -2
  355. package/dist/database/drizzle/sqlite-core/effect/session.js +10 -10
  356. package/dist/database/drizzle/sqlite-core/effect/update.js +2 -2
  357. package/dist/database/drizzle.js +14 -14
  358. package/dist/database/migration/20260127222353_familiar_lady_ursula.js +1 -1
  359. package/dist/database/migration/20260211171708_add_project_commands.js +1 -1
  360. package/dist/database/migration/20260213144116_wakeful_the_professor.js +1 -1
  361. package/dist/database/migration/20260225215848_workspace.js +1 -1
  362. package/dist/database/migration/20260227213759_add_session_workspace_id.js +1 -1
  363. package/dist/database/migration/20260228203230_blue_harpoon.js +1 -1
  364. package/dist/database/migration/20260303231226_add_workspace_fields.js +1 -1
  365. package/dist/database/migration/20260309230000_move_org_to_state.js +1 -1
  366. package/dist/database/migration/20260312043431_session_message_cursor.js +1 -1
  367. package/dist/database/migration/20260323234822_events.js +1 -1
  368. package/dist/database/migration/20260410174513_workspace-name.js +1 -1
  369. package/dist/database/migration/20260413175956_chief_energizer.js +1 -1
  370. package/dist/database/migration/20260423070820_add_icon_url_override.js +1 -1
  371. package/dist/database/migration/20260427172553_slow_nightmare.js +1 -1
  372. package/dist/database/migration/20260428004200_add_session_path.js +1 -1
  373. package/dist/database/migration/20260501142318_next_venus.js +1 -1
  374. package/dist/database/migration/20260504145000_add_sync_owner.js +1 -1
  375. package/dist/database/migration/20260507164347_add_workspace_time.js +1 -1
  376. package/dist/database/migration/20260510033149_session_usage.js +1 -1
  377. package/dist/database/migration/20260511000411_data_migration_state.js +1 -1
  378. package/dist/database/migration/20260511173437_session-metadata.js +1 -1
  379. package/dist/database/migration/20260601010001_normalize_storage_paths.js +1 -1
  380. package/dist/database/migration/20260601202201_amazing_prowler.js +1 -1
  381. package/dist/database/migration/20260602002951_lowly_union_jack.js +1 -1
  382. package/dist/database/migration/20260602182828_add_project_directories.js +1 -1
  383. package/dist/database/migration/20260603001617_session_message_projection_indexes.js +1 -1
  384. package/dist/database/migration/20260603040000_session_message_projection_order.js +1 -1
  385. package/dist/database/migration/20260603141458_session_input_inbox.js +1 -1
  386. package/dist/database/migration/20260603160727_jittery_ezekiel_stane.js +1 -1
  387. package/dist/database/migration/20260604172448_event_sourced_session_input.js +1 -1
  388. package/dist/database/migration/20260605003541_add_session_context_snapshot.js +1 -1
  389. package/dist/database/migration/20260605042240_add_context_epoch_agent.js +1 -1
  390. package/dist/database/migration/20260611035744_credential.js +1 -1
  391. package/dist/database/migration/20260611192811_lush_chimera.js +1 -1
  392. package/dist/database/migration/20260612174303_project_dir_strategy.js +1 -1
  393. package/dist/database/migration/20260622142730_simplify_session_context_epoch.js +1 -1
  394. package/dist/database/migration/20260622170816_reset_v2_session_state.js +1 -1
  395. package/dist/database/migration/20260622202450_simplify_session_input.js +1 -1
  396. package/dist/database/migration/20260804233008_loose_psylocke.js +1 -1
  397. package/dist/database/migration/20260805200742_import_legacy_credentials.js +1 -1
  398. package/dist/database/migration/20260808023530_workspace_domain.js +1 -1
  399. package/dist/database/migration/20260811161259_execution_claim_attempts.js +1 -1
  400. package/dist/database/migration/20260812181746_session_inbox.js +1 -1
  401. package/dist/database/migration/20260812213948_worktree.js +1 -1
  402. package/dist/database/migration/20260819222447_session_viewed_state.js +1 -1
  403. package/dist/database/migration/20260823191254_nullable_workspace_binding.js +1 -1
  404. package/dist/database/migration/20260910120000_clear_v1_session_permission.js +1 -1
  405. package/dist/database/migration/20260923013825_project_time_active.js +1 -1
  406. package/dist/database/migration/20261007190000_azure_cli_external_credential.js +1 -1
  407. package/dist/database/migration/20261010180456_project_time_archived.js +1 -1
  408. package/dist/database/migration/20261024002554_session_allowance.js +1 -1
  409. package/dist/database/migration/20261024175301_drop_session_allowance.js +1 -1
  410. package/dist/database/migration/20261025123711_blob.js +1 -1
  411. package/dist/database/migration/20261025154125_drop_session_pending.js +1 -1
  412. package/dist/database/migration/20261026223005_schedule.js +1 -1
  413. package/dist/database/migration/20261029002625_session_part.js +1 -1
  414. package/dist/database/migration/20261029073502_session_time_busy.js +1 -1
  415. package/dist/database/migration/20261029165540_schedule_checks.js +1 -1
  416. package/dist/database/migration.gen.js +59 -59
  417. package/dist/database/migration.js +61 -61
  418. package/dist/database/path.js +2 -2
  419. package/dist/database/schema.gen.js +1 -1
  420. package/dist/database/schema.sql.js +1 -1
  421. package/dist/database/sqlite.bun.js +1 -1
  422. package/dist/database/sqlite.js +1 -1
  423. package/dist/database/sqlite.node.js +1 -1
  424. package/dist/database/sqlite.workerd.js +1 -1
  425. package/dist/database/v1-migration.bun.js +107 -107
  426. package/dist/database/v1-migration.js +1 -1
  427. package/dist/effect/app-node-builder.js +392 -391
  428. package/dist/effect/app-node-platform.js +2 -2
  429. package/dist/effect/keyed-mutex.js +1 -1
  430. package/dist/effect/websocket-constructor.js +1 -1
  431. package/dist/environment/driver.js +1 -1
  432. package/dist/environment/environment.js +105 -105
  433. package/dist/environment/exec-defaults.js +2 -2
  434. package/dist/environment/files.js +1 -1
  435. package/dist/environment/index.js +107 -107
  436. package/dist/environment/local.js +2 -2
  437. package/dist/environment/memory.js +2 -2
  438. package/dist/environment/unavailable.js +3 -3
  439. package/dist/event/sql.js +1 -1
  440. package/dist/event-logger.js +84 -84
  441. package/dist/file-access.js +153 -153
  442. package/dist/file-mutation.js +106 -106
  443. package/dist/file-retention.js +1 -1
  444. package/dist/filesystem/fff.bun.js +2 -2
  445. package/dist/filesystem/fff.js +1 -1
  446. package/dist/filesystem/fff.node.js +2 -2
  447. package/dist/filesystem/fff.workerd.js +2 -2
  448. package/dist/filesystem/file-watch.js +90 -90
  449. package/dist/filesystem/location-watcher-policy.js +6 -6
  450. package/dist/filesystem/location-watcher.js +235 -235
  451. package/dist/filesystem/protected.js +1 -1
  452. package/dist/filesystem/search.js +111 -111
  453. package/dist/filesystem/watcher-binding.js +1 -1
  454. package/dist/filesystem/watcher.js +9 -9
  455. package/dist/filesystem.js +114 -114
  456. package/dist/form.js +92 -92
  457. package/dist/formatter/builtins.js +4 -4
  458. package/dist/formatter.js +99 -99
  459. package/dist/generate.js +119 -119
  460. package/dist/git.js +11 -11
  461. package/dist/github-copilot/chat/convert-to-openai-compatible-chat-messages.js +1 -1
  462. package/dist/github-copilot/chat/get-response-metadata.js +1 -1
  463. package/dist/github-copilot/chat/map-openai-compatible-finish-reason.js +1 -1
  464. package/dist/github-copilot/chat/openai-compatible-chat-language-model.js +7 -7
  465. package/dist/github-copilot/chat/openai-compatible-chat-options.js +1 -1
  466. package/dist/github-copilot/chat/openai-compatible-prepare-tools.js +1 -1
  467. package/dist/github-copilot/copilot-provider.js +17 -17
  468. package/dist/github-copilot/models.js +103 -103
  469. package/dist/github-copilot/openai-compatible-error.js +1 -1
  470. package/dist/github-copilot/responses/convert-to-openai-responses-input.js +1 -1
  471. package/dist/github-copilot/responses/map-openai-responses-finish-reason.js +1 -1
  472. package/dist/github-copilot/responses/openai-error.js +1 -1
  473. package/dist/github-copilot/responses/openai-responses-language-model.js +10 -10
  474. package/dist/github-copilot/responses/openai-responses-prepare-tools.js +6 -6
  475. package/dist/github-copilot/responses/tool/code-interpreter.js +1 -1
  476. package/dist/github-copilot/responses/tool/file-search.js +1 -1
  477. package/dist/github-copilot/responses/tool/image-generation.js +1 -1
  478. package/dist/github-copilot/responses/tool/web-search-preview.js +1 -1
  479. package/dist/github-copilot/responses/tool/web-search.js +1 -1
  480. package/dist/image/notice.js +3 -3
  481. package/dist/image/photon-normalize.js +1 -1
  482. package/dist/image/photon-worker.js +1 -1
  483. package/dist/image/photon.js +4 -4
  484. package/dist/image.js +6 -6
  485. package/dist/instance/service.js +5 -5
  486. package/dist/instance.js +383 -382
  487. package/dist/instruction-discovery.js +94 -94
  488. package/dist/instructions/builtins.js +97 -97
  489. package/dist/instructions/index.js +3 -3
  490. package/dist/integration/connection.js +3 -3
  491. package/dist/integration.js +99 -99
  492. package/dist/job.js +88 -88
  493. package/dist/kv/sql.js +2 -2
  494. package/dist/kv.js +83 -83
  495. package/dist/location-activity.js +173 -173
  496. package/dist/location-lifecycle.js +149 -149
  497. package/dist/location-service-map.js +98 -98
  498. package/dist/location-services.js +380 -379
  499. package/dist/location.js +101 -101
  500. package/dist/managed-policy.js +3 -3
  501. package/dist/mcp/client.js +103 -103
  502. package/dist/mcp/index.js +121 -121
  503. package/dist/mcp/instructions.js +175 -175
  504. package/dist/mcp/oauth.js +88 -88
  505. package/dist/mcp/socket-client.js +1 -1
  506. package/dist/mcp/stdio.js +102 -102
  507. package/dist/mime.js +1 -1
  508. package/dist/modal/models.js +103 -103
  509. package/dist/model-resolver.js +111 -111
  510. package/dist/model-retry.js +1 -1
  511. package/dist/model.js +112 -112
  512. package/dist/models-dev/v1.js +1 -1
  513. package/dist/models-dev.js +120 -120
  514. package/dist/oauth/page.js +1 -1
  515. package/dist/permission/saved.js +92 -92
  516. package/dist/permission/sql.js +5 -5
  517. package/dist/permission.js +154 -154
  518. package/dist/persistent-pty/binary.bun.js +1 -1
  519. package/dist/persistent-pty/daemon.js +1 -1
  520. package/dist/persistent-pty/index.js +100 -100
  521. package/dist/persistent-pty/pty-binding.js +1 -1
  522. package/dist/persistent-pty.js +85 -85
  523. package/dist/plugin/agent.js +84 -84
  524. package/dist/plugin/command.js +112 -112
  525. package/dist/plugin/goal.js +3 -3
  526. package/dist/plugin/hooks.js +5 -5
  527. package/dist/plugin/host.js +232 -232
  528. package/dist/plugin/identity.js +5 -5
  529. package/dist/plugin/instance.js +5 -5
  530. package/dist/plugin/internal.js +359 -358
  531. package/dist/plugin/mcp-codemode-defaults.js +3 -3
  532. package/dist/plugin/models-dev.js +109 -109
  533. package/dist/plugin/module.js +128 -128
  534. package/dist/plugin/optimize.js +2 -2
  535. package/dist/plugin/plan.js +145 -145
  536. package/dist/plugin/promise.js +1 -1
  537. package/dist/plugin/provider/amazon-bedrock.js +103 -103
  538. package/dist/plugin/provider/azure.js +129 -129
  539. package/dist/plugin/provider/cerebras.js +1 -1
  540. package/dist/plugin/provider/chatgpt.js +129 -129
  541. package/dist/plugin/provider/cloudflare-ai-gateway.js +127 -127
  542. package/dist/plugin/provider/cloudflare-workers-ai.js +127 -127
  543. package/dist/plugin/provider/configured.js +125 -125
  544. package/dist/plugin/provider/credential-settings.js +84 -84
  545. package/dist/plugin/provider/databricks.js +1 -1
  546. package/dist/plugin/provider/digitalocean.js +105 -105
  547. package/dist/plugin/provider/dynamic.js +2 -2
  548. package/dist/plugin/provider/github-copilot.js +107 -107
  549. package/dist/plugin/provider/gitlab.js +106 -106
  550. package/dist/plugin/provider/google-vertex.js +126 -126
  551. package/dist/plugin/provider/kilo.js +1 -1
  552. package/dist/plugin/provider/llmgateway.js +88 -88
  553. package/dist/plugin/provider/lmstudio.js +138 -138
  554. package/dist/plugin/provider/local.js +135 -135
  555. package/dist/plugin/provider/modal.js +104 -104
  556. package/dist/plugin/provider/neon.js +1 -1
  557. package/dist/plugin/provider/nvidia.js +1 -1
  558. package/dist/plugin/provider/ollama.js +138 -138
  559. package/dist/plugin/provider/openai-context-caps.js +102 -102
  560. package/dist/plugin/provider/openai.js +129 -129
  561. package/dist/plugin/provider/opencode.js +131 -131
  562. package/dist/plugin/provider/openrouter.js +103 -103
  563. package/dist/plugin/provider/poe.js +89 -89
  564. package/dist/plugin/provider/prompt-cache-key.js +1 -1
  565. package/dist/plugin/provider/sap-ai-core.js +103 -103
  566. package/dist/plugin/provider/sdk-factory.js +1 -1
  567. package/dist/plugin/provider/snowflake-cortex.js +128 -128
  568. package/dist/plugin/provider/vllm.js +138 -138
  569. package/dist/plugin/provider/xai.js +103 -103
  570. package/dist/plugin/provider/zenmux.js +1 -1
  571. package/dist/plugin/provider.js +179 -179
  572. package/dist/plugin/sdk.js +86 -86
  573. package/dist/plugin/service.js +3 -3
  574. package/dist/plugin/skill.js +148 -148
  575. package/dist/plugin/source-directory.js +1 -1
  576. package/dist/plugin/supervisor.js +367 -366
  577. package/dist/plugin/tool-input-repair.js +4 -4
  578. package/dist/plugin/update.js +6 -6
  579. package/dist/plugin/vcs/git.js +98 -98
  580. package/dist/plugin/vcs/hg.js +98 -98
  581. package/dist/plugin/verbosity.js +105 -105
  582. package/dist/plugin/warming.js +127 -127
  583. package/dist/plugin/websearch/exa.js +5 -5
  584. package/dist/plugin/websearch/firecrawl.js +8 -8
  585. package/dist/plugin/websearch/index.js +9 -9
  586. package/dist/plugin/websearch/mcp.js +4 -4
  587. package/dist/plugin/websearch/parallel.js +8 -8
  588. package/dist/plugin/websearch/tavily.js +6 -6
  589. package/dist/plugin/websearch/tinyfish.js +8 -8
  590. package/dist/plugin.js +243 -243
  591. package/dist/project/icon.js +5 -5
  592. package/dist/project/schema.js +8 -8
  593. package/dist/project/sql.js +4 -4
  594. package/dist/project.js +102 -102
  595. package/dist/provider.js +105 -105
  596. package/dist/pty/protocol.js +1 -1
  597. package/dist/pty/ticket.js +1 -1
  598. package/dist/pty.js +110 -110
  599. package/dist/reference/instructions.js +98 -98
  600. package/dist/reference.js +102 -102
  601. package/dist/repository-cache.js +92 -92
  602. package/dist/repository.js +1 -1
  603. package/dist/ripgrep/binary.js +2 -2
  604. package/dist/ripgrep.js +107 -107
  605. package/dist/rpc.js +98 -98
  606. package/dist/schedule/check.js +237 -236
  607. package/dist/schedule/sql.js +6 -6
  608. package/dist/schedule.js +245 -244
  609. package/dist/schema.js +1 -1
  610. package/dist/session/affinity.js +1 -1
  611. package/dist/session/background.js +1 -1
  612. package/dist/session/blob.js +128 -128
  613. package/dist/session/command.js +84 -84
  614. package/dist/session/compaction.js +171 -171
  615. package/dist/session/context.js +195 -195
  616. package/dist/session/diff.js +100 -100
  617. package/dist/session/environment.js +5 -5
  618. package/dist/session/error.js +5 -5
  619. package/dist/session/event.js +1 -1
  620. package/dist/session/execution/restart.js +243 -243
  621. package/dist/session/execution.js +161 -161
  622. package/dist/session/generate.js +195 -195
  623. package/dist/session/history.js +135 -135
  624. package/dist/session/inbox.js +146 -146
  625. package/dist/session/info.js +3 -3
  626. package/dist/session/instruction-entry.js +87 -87
  627. package/dist/session/instruction-state.js +8 -8
  628. package/dist/session/instructions.js +140 -140
  629. package/dist/session/message-updater.js +2 -2
  630. package/dist/session/message.js +1 -1
  631. package/dist/session/model-request.js +160 -160
  632. package/dist/session/model-transport.js +7 -7
  633. package/dist/session/move.js +163 -163
  634. package/dist/session/projector.js +142 -142
  635. package/dist/session/prompt.js +147 -147
  636. package/dist/session/recent-text.js +1 -1
  637. package/dist/session/revert.js +138 -138
  638. package/dist/session/run-coordinator.js +3 -3
  639. package/dist/session/runner/index.js +3 -3
  640. package/dist/session/runner/llm.js +244 -244
  641. package/dist/session/runner/max-steps.js +1 -1
  642. package/dist/session/runner/model.js +112 -112
  643. package/dist/session/runner/publish-llm-event.js +148 -148
  644. package/dist/session/runner/retry.js +3 -3
  645. package/dist/session/runner/step.js +159 -159
  646. package/dist/session/runner/to-llm-message.js +136 -136
  647. package/dist/session/schema.js +5 -5
  648. package/dist/session/session.js +179 -179
  649. package/dist/session/shell.js +143 -143
  650. package/dist/session/skill.js +146 -146
  651. package/dist/session/sql.js +5 -5
  652. package/dist/session/stats.js +85 -85
  653. package/dist/session/store.js +141 -141
  654. package/dist/session/stored.js +2 -2
  655. package/dist/session/subagent-completion.js +3 -3
  656. package/dist/session/subagent-job.js +226 -226
  657. package/dist/session/system-prompt.js +3 -3
  658. package/dist/session/title.js +193 -193
  659. package/dist/session/to-session-error.js +147 -147
  660. package/dist/session/transfer.js +240 -240
  661. package/dist/session/usage.js +1 -1
  662. package/dist/session.js +232 -232
  663. package/dist/shell/parse.js +6 -6
  664. package/dist/shell/result.js +1 -1
  665. package/dist/shell/scan.js +6 -2007
  666. package/dist/shell/select.js +13 -13
  667. package/dist/shell.js +145 -145
  668. package/dist/skill/discovery.js +6 -6
  669. package/dist/skill/instructions.js +148 -148
  670. package/dist/skill.js +157 -157
  671. package/dist/snapshot.js +103 -103
  672. package/dist/state.js +1 -1
  673. package/dist/tool/html-markdown.js +1 -1
  674. package/dist/tool/http-body.js +1 -1
  675. package/dist/tool/mcp.js +174 -174
  676. package/dist/tool/plugin/edit.js +163 -163
  677. package/dist/tool/plugin/file-diff.js +1 -1
  678. package/dist/tool/plugin/glob.js +163 -163
  679. package/dist/tool/plugin/grep.js +163 -163
  680. package/dist/tool/plugin/image-generate.js +236 -236
  681. package/dist/tool/plugin/mcp-resource.js +161 -161
  682. package/dist/tool/plugin/opencode.js +160 -160
  683. package/dist/tool/plugin/patch.js +159 -159
  684. package/dist/tool/plugin/question.js +147 -147
  685. package/dist/tool/plugin/read.js +168 -168
  686. package/dist/tool/plugin/schedule.js +243 -242
  687. package/dist/tool/plugin/shell.js +232 -231
  688. package/dist/tool/plugin/skill.js +156 -156
  689. package/dist/tool/plugin/subagent.js +233 -233
  690. package/dist/tool/plugin/todo.js +152 -152
  691. package/dist/tool/plugin/webfetch.js +154 -154
  692. package/dist/tool/plugin/websearch.js +154 -154
  693. package/dist/tool/plugin/write.js +163 -163
  694. package/dist/tool/read-filesystem.js +114 -114
  695. package/dist/tool/runtime.js +1 -1
  696. package/dist/tool-output.js +7 -7
  697. package/dist/tool.js +14 -14
  698. package/dist/types/codemode/tool.d.ts +39 -0
  699. package/dist/types/schedule/check.d.ts +35 -4
  700. package/dist/types/schedule/sql.d.ts +3 -0
  701. package/dist/types/shell/parse.d.ts +2 -6
  702. package/dist/types/tool/plugin/schedule.d.ts +12 -0
  703. package/dist/types/tool/plugin/shell.d.ts +1 -2
  704. package/dist/types/tool.d.ts +14 -0
  705. package/dist/usage-limits.js +99 -99
  706. package/dist/util/error-summary.js +1 -1
  707. package/dist/util/git-executable.js +3 -3
  708. package/dist/util/lazy.js +1 -1
  709. package/dist/util/slug.js +1 -1
  710. package/dist/util/token.js +1 -1
  711. package/dist/util/which.js +1 -1
  712. package/dist/util/wildcard.js +1 -1
  713. package/dist/v1/config/agent.js +5 -5
  714. package/dist/v1/config/command.js +3 -3
  715. package/dist/v1/config/mcp.js +4 -4
  716. package/dist/v1/config/migrate.js +104 -104
  717. package/dist/v1/config/permission.js +3 -3
  718. package/dist/v1/config/plugin.js +3 -3
  719. package/dist/v1/config/provider-options.js +1 -1
  720. package/dist/v1/config/provider.js +4 -4
  721. package/dist/variant.js +103 -103
  722. package/dist/vcs/patch.js +1 -1
  723. package/dist/vcs.js +101 -101
  724. package/dist/voice.js +100 -100
  725. package/dist/websearch.js +94 -94
  726. package/dist/wellknown/plugin.js +86 -86
  727. package/dist/wellknown.js +91 -91
  728. package/dist/workspace/driver.js +7 -7
  729. package/dist/workspace/sql.js +1 -1
  730. package/dist/workspace.js +92 -92
  731. package/dist/worktree/directory.js +2 -2
  732. package/dist/worktree/git.js +11 -11
  733. package/dist/worktree/sql.js +5 -5
  734. package/dist/worktree/strategies.js +101 -101
  735. package/dist/worktree.js +112 -112
  736. package/package.json +8 -17
  737. package/dist/chunks/mime-1hm0b4am.js +0 -257
  738. package/dist/chunks/mime-2dkjcnxp.js +0 -18
  739. package/dist/chunks/mime-52zxaxjc.js +0 -26
  740. package/dist/chunks/mime-vf16q2b1.js +0 -356
  741. package/dist/chunks/mime-z8xs1n5t.js +0 -222
  742. package/dist/shell/parser-wasm.bun.js +0 -8
  743. package/dist/shell/parser-wasm.node.js +0 -11
  744. package/dist/shell/parser-wasm.workerd.js +0 -5
  745. package/dist/types/shell/parser-wasm.bun.d.ts +0 -5
  746. package/dist/types/shell/parser-wasm.node.d.ts +0 -5
  747. package/dist/types/shell/parser-wasm.workerd.d.ts +0 -5
  748. /package/dist/chunks/{mime-0qkdqm5v.js → bus-0qkdqm5v.js} +0 -0
  749. /package/dist/chunks/{mime-0zkw76rk.js → bus-0zkw76rk.js} +0 -0
  750. /package/dist/chunks/{mime-17cy0kzp.js → bus-17cy0kzp.js} +0 -0
  751. /package/dist/chunks/{mime-1cnp2v09.js → bus-1cnp2v09.js} +0 -0
  752. /package/dist/chunks/{mime-1kah00gy.js → bus-1kah00gy.js} +0 -0
  753. /package/dist/chunks/{mime-24dcb14g.js → bus-24dcb14g.js} +0 -0
  754. /package/dist/chunks/{mime-2710q6r3.js → bus-2710q6r3.js} +0 -0
  755. /package/dist/chunks/{mime-2bv980vf.js → bus-2bv980vf.js} +0 -0
  756. /package/dist/chunks/{mime-2c3vjs8z.js → bus-2c3vjs8z.js} +0 -0
  757. /package/dist/chunks/{mime-359p4xyc.js → bus-359p4xyc.js} +0 -0
  758. /package/dist/chunks/{mime-3asan66x.js → bus-3asan66x.js} +0 -0
  759. /package/dist/chunks/{mime-3v8g72cx.js → bus-3v8g72cx.js} +0 -0
  760. /package/dist/chunks/{mime-3wcehsnq.js → bus-3wcehsnq.js} +0 -0
  761. /package/dist/chunks/{mime-43n2bw4t.js → bus-43n2bw4t.js} +0 -0
  762. /package/dist/chunks/{mime-4knz6hnm.js → bus-4knz6hnm.js} +0 -0
  763. /package/dist/chunks/{mime-4vcrnpx2.js → bus-4vcrnpx2.js} +0 -0
  764. /package/dist/chunks/{mime-4y7fprxs.js → bus-4y7fprxs.js} +0 -0
  765. /package/dist/chunks/{mime-53557ph1.js → bus-53557ph1.js} +0 -0
  766. /package/dist/chunks/{mime-550bvhaj.js → bus-550bvhaj.js} +0 -0
  767. /package/dist/chunks/{mime-5w3e23ze.js → bus-5w3e23ze.js} +0 -0
  768. /package/dist/chunks/{mime-6prwharc.js → bus-6prwharc.js} +0 -0
  769. /package/dist/chunks/{mime-6q2bdcd1.js → bus-6q2bdcd1.js} +0 -0
  770. /package/dist/chunks/{mime-7akdwqpd.js → bus-7akdwqpd.js} +0 -0
  771. /package/dist/chunks/{mime-7m9af43g.js → bus-7m9af43g.js} +0 -0
  772. /package/dist/chunks/{mime-7stb81gk.js → bus-7stb81gk.js} +0 -0
  773. /package/dist/chunks/{mime-822emrt2.js → bus-822emrt2.js} +0 -0
  774. /package/dist/chunks/{mime-84wd9syh.js → bus-84wd9syh.js} +0 -0
  775. /package/dist/chunks/{mime-88xbtdfr.js → bus-88xbtdfr.js} +0 -0
  776. /package/dist/chunks/{mime-8n3pysct.js → bus-8n3pysct.js} +0 -0
  777. /package/dist/chunks/{mime-8wj87zfr.js → bus-8wj87zfr.js} +0 -0
  778. /package/dist/chunks/{mime-9a4afbnw.js → bus-9a4afbnw.js} +0 -0
  779. /package/dist/chunks/{mime-9rqn6x4v.js → bus-9rqn6x4v.js} +0 -0
  780. /package/dist/chunks/{mime-a058387c.js → bus-a058387c.js} +0 -0
  781. /package/dist/chunks/{mime-a6k6eb26.js → bus-a6k6eb26.js} +0 -0
  782. /package/dist/chunks/{mime-af5trqkr.js → bus-af5trqkr.js} +0 -0
  783. /package/dist/chunks/{mime-afrmfg78.js → bus-afrmfg78.js} +0 -0
  784. /package/dist/chunks/{mime-aqzs7mqg.js → bus-aqzs7mqg.js} +0 -0
  785. /package/dist/chunks/{mime-atq7p7m5.js → bus-atq7p7m5.js} +0 -0
  786. /package/dist/chunks/{mime-beh6qq61.js → bus-beh6qq61.js} +0 -0
  787. /package/dist/chunks/{mime-bkyjaxrp.js → bus-bkyjaxrp.js} +0 -0
  788. /package/dist/chunks/{mime-bmr6ed5q.js → bus-bmr6ed5q.js} +0 -0
  789. /package/dist/chunks/{mime-cf4snx6d.js → bus-cf4snx6d.js} +0 -0
  790. /package/dist/chunks/{mime-cqv5kn06.js → bus-cqv5kn06.js} +0 -0
  791. /package/dist/chunks/{mime-cvy3z8tj.js → bus-cvy3z8tj.js} +0 -0
  792. /package/dist/chunks/{mime-d9fn303g.js → bus-d9fn303g.js} +0 -0
  793. /package/dist/chunks/{mime-d9jj8t3e.js → bus-d9jj8t3e.js} +0 -0
  794. /package/dist/chunks/{mime-dap0rakb.js → bus-dap0rakb.js} +0 -0
  795. /package/dist/chunks/{mime-df08tz66.js → bus-df08tz66.js} +0 -0
  796. /package/dist/chunks/{mime-dy18nga0.js → bus-dy18nga0.js} +0 -0
  797. /package/dist/chunks/{mime-e5kj55wp.js → bus-e5kj55wp.js} +0 -0
  798. /package/dist/chunks/{mime-e73j6tqm.js → bus-e73j6tqm.js} +0 -0
  799. /package/dist/chunks/{mime-ean2d8b5.js → bus-ean2d8b5.js} +0 -0
  800. /package/dist/chunks/{mime-ec1grn59.js → bus-ec1grn59.js} +0 -0
  801. /package/dist/chunks/{mime-eh3zwz77.js → bus-eh3zwz77.js} +0 -0
  802. /package/dist/chunks/{mime-emrn6kk6.js → bus-emrn6kk6.js} +0 -0
  803. /package/dist/chunks/{mime-f0mxakyp.js → bus-f0mxakyp.js} +0 -0
  804. /package/dist/chunks/{mime-f6n9ztr4.js → bus-f6n9ztr4.js} +0 -0
  805. /package/dist/chunks/{mime-faypxj3z.js → bus-faypxj3z.js} +0 -0
  806. /package/dist/chunks/{mime-fd410y7t.js → bus-fd410y7t.js} +0 -0
  807. /package/dist/chunks/{mime-fkpq3x5p.js → bus-fkpq3x5p.js} +0 -0
  808. /package/dist/chunks/{mime-g4wezp1m.js → bus-g4wezp1m.js} +0 -0
  809. /package/dist/chunks/{mime-g86h250q.js → bus-g86h250q.js} +0 -0
  810. /package/dist/chunks/{mime-gebd4c9n.js → bus-gebd4c9n.js} +0 -0
  811. /package/dist/chunks/{mime-gftt206x.js → bus-gftt206x.js} +0 -0
  812. /package/dist/chunks/{mime-hcxmzztb.js → bus-hcxmzztb.js} +0 -0
  813. /package/dist/chunks/{mime-hk9envan.js → bus-hk9envan.js} +0 -0
  814. /package/dist/chunks/{mime-j2ntwpah.js → bus-j2ntwpah.js} +0 -0
  815. /package/dist/chunks/{mime-j5zkgpj8.js → bus-j5zkgpj8.js} +0 -0
  816. /package/dist/chunks/{mime-jjkms2e6.js → bus-jjkms2e6.js} +0 -0
  817. /package/dist/chunks/{mime-jr7sbwjy.js → bus-jr7sbwjy.js} +0 -0
  818. /package/dist/chunks/{mime-jwfs4k6c.js → bus-jwfs4k6c.js} +0 -0
  819. /package/dist/chunks/{mime-jwr30sdr.js → bus-jwr30sdr.js} +0 -0
  820. /package/dist/chunks/{mime-jze0r7bz.js → bus-jze0r7bz.js} +0 -0
  821. /package/dist/chunks/{mime-jzg6c2d5.js → bus-jzg6c2d5.js} +0 -0
  822. /package/dist/chunks/{mime-m18g726c.js → bus-m18g726c.js} +0 -0
  823. /package/dist/chunks/{mime-mp448xyj.js → bus-mp448xyj.js} +0 -0
  824. /package/dist/chunks/{mime-msx8hqn2.js → bus-msx8hqn2.js} +0 -0
  825. /package/dist/chunks/{mime-n05xt0ee.js → bus-n05xt0ee.js} +0 -0
  826. /package/dist/chunks/{mime-n3j8tn72.js → bus-n3j8tn72.js} +0 -0
  827. /package/dist/chunks/{mime-ncqqe42p.js → bus-ncqqe42p.js} +0 -0
  828. /package/dist/chunks/{mime-nh4v3znn.js → bus-nh4v3znn.js} +0 -0
  829. /package/dist/chunks/{mime-njntx4h6.js → bus-njntx4h6.js} +0 -0
  830. /package/dist/chunks/{mime-p71gwv9c.js → bus-p71gwv9c.js} +0 -0
  831. /package/dist/chunks/{mime-q3sfg36h.js → bus-q3sfg36h.js} +0 -0
  832. /package/dist/chunks/{mime-q74kybfr.js → bus-q74kybfr.js} +0 -0
  833. /package/dist/chunks/{mime-qaymkmh1.js → bus-qaymkmh1.js} +0 -0
  834. /package/dist/chunks/{mime-qb87gjwd.js → bus-qb87gjwd.js} +0 -0
  835. /package/dist/chunks/{mime-qfa1cgps.js → bus-qfa1cgps.js} +0 -0
  836. /package/dist/chunks/{mime-qg3g05ea.js → bus-qg3g05ea.js} +0 -0
  837. /package/dist/chunks/{mime-qrg20bc0.js → bus-qrg20bc0.js} +0 -0
  838. /package/dist/chunks/{mime-rcb2kzg1.js → bus-rcb2kzg1.js} +0 -0
  839. /package/dist/chunks/{mime-sdp7kfr6.js → bus-sdp7kfr6.js} +0 -0
  840. /package/dist/chunks/{mime-ssg3fenm.js → bus-ssg3fenm.js} +0 -0
  841. /package/dist/chunks/{mime-stkk57rt.js → bus-stkk57rt.js} +0 -0
  842. /package/dist/chunks/{mime-t03h4f5z.js → bus-t03h4f5z.js} +0 -0
  843. /package/dist/chunks/{mime-ty7weeps.js → bus-ty7weeps.js} +0 -0
  844. /package/dist/chunks/{mime-ve7vex1e.js → bus-ve7vex1e.js} +0 -0
  845. /package/dist/chunks/{mime-w803qqfp.js → bus-w803qqfp.js} +0 -0
  846. /package/dist/chunks/{mime-wc3fc9cn.js → bus-wc3fc9cn.js} +0 -0
  847. /package/dist/chunks/{mime-wer8tq1h.js → bus-wer8tq1h.js} +0 -0
  848. /package/dist/chunks/{mime-wtztk69x.js → bus-wtztk69x.js} +0 -0
  849. /package/dist/chunks/{mime-x0ckcb58.js → bus-x0ckcb58.js} +0 -0
  850. /package/dist/chunks/{mime-x61499pn.js → bus-x61499pn.js} +0 -0
  851. /package/dist/chunks/{mime-y44na4kk.js → bus-y44na4kk.js} +0 -0
  852. /package/dist/chunks/{mime-y8f7s663.js → bus-y8f7s663.js} +0 -0
  853. /package/dist/chunks/{mime-ygaqb7jw.js → bus-ygaqb7jw.js} +0 -0
  854. /package/dist/chunks/{mime-z5v4ffb3.js → bus-z5v4ffb3.js} +0 -0
  855. /package/dist/chunks/{mime-z9919s4g.js → bus-z9919s4g.js} +0 -0
@@ -1,2011 +1,10 @@
1
1
  import {
2
- __export
3
- } from "../chunks/mime-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_LIST_OPERATORS = ["&&", "||", "|&"];
14
- var BASH_CASE_OPERATORS = [";;&", ";;", ";&", ";|", ...BASH_LIST_OPERATORS];
15
- var BASH_BINDING_BUILTINS = new Set([
16
- "declare",
17
- "typeset",
18
- "local",
19
- "export",
20
- "readonly",
21
- "private",
22
- "unset",
23
- "read",
24
- "getln",
25
- "vared",
26
- "getopts",
27
- "mapfile",
28
- "readarray",
29
- "compgen",
30
- "zparseopts",
31
- "zregexparse",
32
- "zformat",
33
- "zstyle",
34
- "zstat",
35
- "stat"
36
- ]);
37
- var BASH_ARITHMETIC_COMPARISONS = new Set(["-eq", "-ne", "-lt", "-le", "-gt", "-ge"]);
38
- var BASH_EXPANSION_RE = /\$(?:\\.|\\\n)*[({]|`/;
39
- var BASH_ESCAPE_RE = /\\(?:x[\da-fA-F]{1,2}|[0-7]{1,3}|u[\da-fA-F]{1,4}|U[\da-fA-F]{1,8})/;
40
- var BASH_ASSIGNMENT_DECLARATIONS = new Set(["declare", "typeset", "export", "readonly", "local"]);
41
- var BASH_DECLARATIONS = new Set([...BASH_ASSIGNMENT_DECLARATIONS, "unset", "unsetenv"]);
42
- var BASH_PRECOMMANDS = new Set(["builtin", "command", "time", "coproc", "!"]);
43
- var ZSH_PRECOMMANDS = new Set(["noglob", "nocorrect", "exec", "-"]);
44
- var ZSH_ARITHMETIC_BUILTINS = new Set([
45
- "integer",
46
- "float",
47
- "exit",
48
- "return",
49
- "shift",
50
- "break",
51
- "continue",
52
- "bye",
53
- "logout"
54
- ]);
55
- var BASH_NON_FUNCTION_KEYWORDS = new Set([
56
- "if",
57
- "for",
58
- "select",
59
- "case",
60
- "then",
61
- "elif",
62
- "else",
63
- "fi",
64
- "do",
65
- "done",
66
- "in",
67
- "esac"
68
- ]);
69
- var BASH_UNIT_STARTS = "\\$'\"`<>";
70
- var MAX_INPUT_LENGTH = 64 * 1024;
71
- var MAX_SUBSTITUTION_DEPTH = 32;
72
- var TOKEN_RE = /[A-Za-z_][A-Za-z0-9_]*(?=(?:\\\n)*(?:[ \t\n;|&()<>]|$))/y;
73
- var BRACE_CLOSE_AHEAD_RE = /(?:\\\n)*(?:[ \t\n;&|()<>]|$)/y;
74
- var SPACE_CONTINUATION_AHEAD_RE = /(?:\\\n)*[ \t\n]/y;
75
- var NEGATION_AHEAD_RE = /(?:\\\n)*[ \t\n(]/y;
76
- var COPROC_AHEAD_RE = /coproc(?:[ \t]|\\\n)+(?:--(?:[ \t]|\\\n)+)?(?:[A-Za-z_][A-Za-z0-9_]*(?:[ \t]|\\\n)+)?(?=(?:!(?:[ \t]|\\\n)*)*(?:[{(]|\[\[(?:\\\n)*[ \t\n]|(?:if|while|until|for|select|case|repeat)\b))/y;
77
- var TIME_AHEAD_RE = /time(?:[ \t]|\\\n)+(?:-p(?:[ \t]|\\\n)+)?(?:--(?:[ \t]|\\\n)+)?(?=(?:!(?:[ \t]|\\\n)*)*(?:[{(]|\[\[(?:\\\n)*[ \t\n]|(?:if|while|until|for|select|case|repeat)\b))/y;
78
- var FUNCTION_HEAD_RE = /(function[ \t](?:[ \t]|\\\n)*)?([A-Za-z_][\w.:+@%-]*)?(?:[ \t]|\\\n)*(\([ \t]*\))?((?:[ \t\n]|\\\n|#[^\n]*\n)*)/y;
79
- var FUNCTION_BODY_RE = /[{(]|\[\[(?=(?:\\\n)*[ \t\n])|(?:if|while|until|for|select|case|repeat)(?=(?:\\\n)*(?:[ \t\n(]|$))/y;
80
- var DO_AHEAD_RE = /(?:[ \t\n;]|\\\n|#[^\n]*(?:\n|$))*(?:do(?=(?:\\\n)*(?:[ \t\n;{(]|$))|\{(?=(?:\\\n)*[ \t\n]))/y;
81
- var NOFORK_OPEN_RE = /\$\{(?:\\\n)*(?:[ \t\n]|\|)/y;
82
- var ZSH_SAFE_FLAGS_RE = /\$\{\((?:[@AaBbCcDEfFikLMmNnOopqStUuVvWwXZz0-]|q[-+]?|[js]([^({[<\\])(?:(?!\1)[^)])*\1)*\)/y;
83
- var ZSH_GLOB_MODIFIER_RE = /(?:[\^=~#+]|\\\n)*~/y;
84
- var ZSH_SUBSCRIPT_RE = /\$(?:[\^=+~#]|\\\n)*(?:[A-Za-z_](?:[A-Za-z0-9_]|\\\n)*|[@*#?$!0-9-])(?:\\\n)*\[/y;
85
- var LINE_CONTINUATION_RE = /(?:\\\n)*/y;
86
- var PARAMETER_PREFIX_RE = /(?:\\\n)*(?:\([^)]*\))?(?:[!#^=+~]|\\\n)*/y;
87
- var PARAMETER_NAME_RE = /(?:[A-Za-z_](?:[A-Za-z0-9_]|\\\n)*|\d(?:\d|\\\n)*|[@*#?$!-])(?:\\\n)*/y;
88
- var PARAMETER_PROMPT_RE = /@(?:\\\n)*[EP](?:\\\n)*\}/y;
89
- var BASH_ANSI_ESCAPES = {
90
- a: "\x07",
91
- b: "\b",
92
- e: "\x1B",
93
- E: "\x1B",
94
- f: "\f",
95
- n: `
96
- `,
97
- r: "\r",
98
- t: "\t",
99
- v: "\v",
100
- "\\": "\\",
101
- "'": "'",
102
- '"': '"',
103
- "?": "?"
104
- };
105
- function scan(input, dialect = "posix") {
106
- if (input.length > MAX_INPUT_LENGTH)
107
- return { kind: "opaque", reason: "invalid-structure" };
108
- const context = { remaining: MAX_INPUT_LENGTH * MAX_SUBSTITUTION_DEPTH, dialect };
109
- const result = scanBash(input, 0, 0, context);
110
- if (result.kind === "opaque")
111
- return result;
112
- if (context.boundDollar && context.boundOpen && context.variableSink)
113
- return { kind: "opaque", reason: "dynamic-execution" };
114
- return { kind: "scanned", commands: result.commands };
115
- }
116
- function bashStatement(state) {
117
- const structure = state.structures.at(-1);
118
- if (structure)
119
- structure.count++;
120
- }
121
- function bashInHeader(state) {
122
- const phase = state.structures.at(-1)?.phase;
123
- return phase === "header" || phase === "pattern" || phase === "do";
124
- }
125
- function atCommandStart(state) {
126
- return !state.words.length && !state.hasRedirect && !state.compoundEnd && !bashInHeader(state);
127
- }
128
- function pending(state) {
129
- return state.wordStarted || state.words.length > 0 || state.hasRedirect || state.compoundEnd;
130
- }
131
- function endBashList(state) {
132
- if (pending(state))
133
- finishBashCommand(state);
134
- return !state.dangling;
135
- }
136
- function closeBashList(state, end) {
137
- if (!endBashList(state))
138
- return { kind: "opaque", reason: "invalid-structure" };
139
- if (state.invalid)
140
- return { kind: "opaque", reason: state.invalid };
141
- if (state.structures.length)
142
- return { kind: "opaque", reason: "compound-command" };
143
- return { kind: "scanned", commands: state.commands, end };
144
- }
145
- function finishBashWord(state) {
146
- if (!state.wordStarted)
147
- return;
148
- if (/PS4/.test(state.word))
149
- state.context.variableSink = true;
150
- const evaluation = bashWordEvaluation(state);
151
- if (state.context.dialect !== "bash" && (/(?:READ)?NULLCMD/.test(state.word) || (state.assignmentWord || evaluation === "binding") && /^(?:-[A-Za-z]*v)?(?:(?:dis_)?(?:functions|[gs]?aliases)|options|commands)(?:\+?=|\[|$)/.test(state.word)))
152
- state.invalid ??= "dynamic-execution";
153
- if (evaluation && bashEvaluatesExpansion(state, evaluation, state.context))
154
- state.invalid ??= "dynamic-execution";
155
- if (state.outer)
156
- state.outer.output += ` ${state.literal} ${state.output}`;
157
- const structure = state.structures.at(-1);
158
- const repeatHeader = structure?.kind === "repeat" && structure.phase === "header";
159
- if (!state.redirectTarget && repeatHeader)
160
- structure.phase = "do";
161
- if (!state.redirectTarget && !repeatHeader) {
162
- if (!state.assignmentWord && state.commandWordIndex < 0)
163
- state.commandWordIndex = state.words.length;
164
- state.commandStart ??= state.wordStart;
165
- state.words.push(state.word);
166
- state.rawWords.push(state.input.slice(state.wordStart, state.wordEnd));
167
- state.commandEnd = state.wordEnd;
168
- }
169
- state.redirectTarget = false;
170
- state.hereString = false;
171
- state.word = "";
172
- state.literal = "";
173
- state.output = "";
174
- state.wordStarted = false;
175
- state.assignmentWord = false;
176
- state.assignmentHeadUnsafe = false;
177
- }
178
- function bashWordEvaluation(state) {
179
- if (state.redirectTarget)
180
- return state.hereString ? "deferred" : undefined;
181
- const structure = state.structures.at(-1);
182
- if (structure?.kind === "repeat" && structure.phase === "header")
183
- return "arithmetic";
184
- if (structure?.kind === "for" && structure.phase === "header" && structure.sawIn)
185
- return "deferred";
186
- if (state.commandWordIndex < 0)
187
- return state.assignmentWord ? "deferred" : undefined;
188
- const name = bashBuiltinIndex(state);
189
- const command = state.words[name];
190
- if (command === undefined)
191
- return;
192
- if (command === "let" || state.context.dialect !== "bash" && ZSH_ARITHMETIC_BUILTINS.has(command))
193
- return "arithmetic";
194
- if (command === "set")
195
- return state.words.slice(name + 1).some((word) => /^[-+][A-Za-z0-9]*A/.test(word)) ? "binding" : "deferred";
196
- if (BASH_BINDING_BUILTINS.has(command)) {
197
- const options = state.words.slice(name + 1);
198
- if (options.some((word) => word.startsWith("-") && /[EFin]/.test(word)))
199
- return "arithmetic";
200
- if (state.assignmentWord && BASH_ASSIGNMENT_DECLARATIONS.has(command) && options.every((word) => !word.startsWith("-")) && (command === "export" || command === "readonly" || state.context.dialect === "zsh" || !/\+?=(?:\(|[$`])/.test(state.word)))
201
- return "deferred";
202
- return "binding";
203
- }
204
- if (command === "printf" || command === "print") {
205
- const options = [...state.words.slice(name + 1), state.word];
206
- const flag = command === "print" ? /^-[A-Za-z]*v/ : /^-v/;
207
- return options.some((word) => flag.test(word)) ? "binding" : undefined;
208
- }
209
- if (command === "wait")
210
- return /^-[nf]*p/.test(state.word) || /^-[nf]*p$/.test(state.words.at(-1) ?? "") ? "binding" : undefined;
211
- if (command === "test" || command === "[") {
212
- if (state.words.at(-1) === "-v")
213
- return "binding";
214
- if (state.context.dialect !== "bash" && state.words.at(-1) === "-t")
215
- return "arithmetic";
216
- }
217
- return;
218
- }
219
- function bashBuiltinIndex(state) {
220
- let name = state.commandWordIndex;
221
- while (BASH_PRECOMMANDS.has(state.words[name] ?? "") || state.context.dialect !== "bash" && ZSH_PRECOMMANDS.has(state.words[name] ?? "")) {
222
- const precommand = state.words[name++];
223
- while (precommand !== "-" && state.words[name]?.startsWith("-")) {
224
- if (precommand === "exec" && /^-[cl]*a$/.test(state.words[name]))
225
- name++;
226
- name++;
227
- }
228
- }
229
- return name;
230
- }
231
- function finishBashCommand(state, boundary = false) {
232
- finishBashWord(state);
233
- if (state.redirectTarget)
234
- state.invalid ??= "invalid-redirect";
235
- state.redirectTarget = false;
236
- if (state.compoundEnd && state.words.length > 0)
237
- state.invalid ??= "invalid-structure";
238
- const name = state.commandWordIndex;
239
- const inHeader = bashInHeader(state);
240
- if (name >= 0 && !state.words[name])
241
- state.invalid ??= "invalid-structure";
242
- if (name >= 0 && !inHeader) {
243
- const resource = state.input.slice(state.commandStart, state.resourceEnd ?? state.wordEnd).replace(/^[ \t\n]+|[ \t\n]+$/g, "");
244
- const command = {
245
- resource,
246
- words: state.words.slice(name),
247
- rawWords: state.rawWords.slice(name),
248
- ...name === 0 && BASH_DECLARATIONS.has(state.rawWords[0]) && resource.startsWith(state.rawWords[0]) ? { declaration: true } : {},
249
- ...state.redirectWordCount !== undefined && state.redirectWordCount < state.words.length ? { redirectWordCount: state.redirectWordCount - name } : {}
250
- };
251
- state.commands.push(command);
252
- const builtin = bashBuiltinIndex(state);
253
- const builtinName = state.words[builtin];
254
- const builtinArgs = state.words.slice(builtin + 1);
255
- if (builtinName === "eval")
256
- state.context.variableSink = true;
257
- if (builtinName === "set" && builtinArgs.some((word) => /^-[A-Za-z0-9]*k/.test(word) || word === "keyword"))
258
- state.invalid ??= "dynamic-execution";
259
- if (builtinName === "alias" && builtinArgs.some((word) => word.includes("=")))
260
- state.invalid ??= "dynamic-execution";
261
- if (state.context.dialect !== "bash" && (builtinName === "emulate" || (builtinName === "setopt" || builtinName === "unsetopt" || builtinName === "set" && builtinArgs.some((word) => /^[-+][A-Za-z0-9]*o/.test(word))) && builtinArgs.some((word) => /^-[A-Za-z0-9]*m/.test(word) || /^(?:no)?(?:globsubst|kshglob|promptsubst|promptvars|aliases)$/.test(word.replace(/^[-+][A-Za-z0-9]*?o/i, "").toLowerCase().replace(/[_-]/g, "")))))
262
- state.invalid ??= "dynamic-execution";
263
- if (state.context.dialect !== "zsh" && builtinName === "compgen" && builtinArgs.some((word) => word.startsWith("-") && /[CF]/.test(word)))
264
- state.invalid ??= "dynamic-execution";
265
- if (BASH_BINDING_BUILTINS.has(builtinName ?? "")) {
266
- for (const heredoc of state.heredocs)
267
- heredoc.binding ??= true;
268
- }
269
- if (state.resourceEnd === undefined) {
270
- for (const heredoc of state.heredocs) {
271
- if (heredoc.command)
272
- continue;
273
- heredoc.command = command;
274
- heredoc.start = state.commandStart;
275
- }
276
- }
277
- }
278
- if (boundary && !state.words.length && !state.hasRedirect && !state.compoundEnd && !inHeader)
279
- state.invalid ??= "invalid-structure";
280
- if (state.words.length > (state.ampersandRedirectWords ?? Infinity))
281
- state.invalid ??= "invalid-redirect";
282
- state.commands.push(...state.nestedCommands.splice(0));
283
- if (!inHeader && (state.words.length > 0 || state.hasRedirect))
284
- bashStatement(state);
285
- state.words.length = 0;
286
- state.rawWords.length = 0;
287
- state.commandWordIndex = -1;
288
- state.commandStart = undefined;
289
- state.hasRedirect = false;
290
- state.resourceEnd = undefined;
291
- state.redirectWordCount = undefined;
292
- state.ampersandRedirectWords = undefined;
293
- state.compoundEnd = false;
294
- state.dangling = false;
295
- }
296
- function scanBash(input, start, depth, context, close, heredocs, outer) {
297
- if (depth > MAX_SUBSTITUTION_DEPTH || context.remaining < 0)
298
- return { kind: "opaque", reason: "invalid-structure" };
299
- const state = {
300
- input,
301
- context,
302
- commands: [],
303
- nestedCommands: [],
304
- words: [],
305
- rawWords: [],
306
- heredocs: heredocs ?? [],
307
- structures: [],
308
- word: "",
309
- literal: "",
310
- output: "",
311
- wordStarted: false,
312
- wordStart: start,
313
- wordEnd: start,
314
- commandStart: undefined,
315
- commandEnd: start,
316
- resourceEnd: undefined,
317
- redirectWordCount: undefined,
318
- ampersandRedirectWords: undefined,
319
- commandWordIndex: -1,
320
- assignmentWord: false,
321
- assignmentHeadUnsafe: false,
322
- invalid: undefined,
323
- redirectTarget: false,
324
- hereString: false,
325
- hasRedirect: false,
326
- compoundEnd: false,
327
- dangling: false,
328
- outer
329
- };
330
- for (let index = start;index < input.length; index++) {
331
- if (--context.remaining < 0)
332
- return { kind: "opaque", reason: "invalid-structure" };
333
- const char = input[index];
334
- if (char === "\\" && input[index + 1] === `
335
- `) {
336
- index++;
337
- continue;
338
- }
339
- if (!state.wordStarted) {
340
- state.wordStart = index;
341
- if (char === " " || char === "\t")
342
- continue;
343
- if (char === "}" && state.words.length === 0 && !state.redirectTarget && (close === "}" || close === "nofork") && state.structures.length === 0 && (heredocs !== undefined || state.heredocs.length === 0) && (close === "nofork" || (BRACE_CLOSE_AHEAD_RE.lastIndex = index + 1, BRACE_CLOSE_AHEAD_RE.test(input))))
344
- return closeBashList(state, index);
345
- if (char === "}")
346
- return { kind: "opaque", reason: state.structures.length ? "compound-command" : "invalid-structure" };
347
- const step = scanBashCommandStart(state, index, depth, context);
348
- if (typeof step === "object")
349
- return step;
350
- if (step !== undefined) {
351
- index = step;
352
- continue;
353
- }
354
- }
355
- if (char === "\\" && index + 1 >= input.length)
356
- return { kind: "opaque", reason: "unterminated-escape" };
357
- if (!state.assignmentWord && (`'"\\`.includes(char) || char === "$" && (input[index + 1] === "'" || input[index + 1] === '"')))
358
- state.assignmentHeadUnsafe = true;
359
- const inCasePattern = state.structures.at(-1)?.phase === "pattern";
360
- const array = (char === "=" || char === "(") && state.assignmentWord && state.word.length > 1 && state.word.endsWith("=") && !state.word.endsWith("==") && (state.commandWordIndex < 0 || BASH_ASSIGNMENT_DECLARATIONS.has(state.rawWords[state.commandWordIndex]));
361
- if (char === "=" && (!state.wordStarted || array) && input[index + 1] === "(") {
362
- const end = scanBashNested(input, index + 2, depth, context, state.nestedCommands, ")");
363
- if (typeof end === "object")
364
- return end;
365
- state.wordStarted = true;
366
- state.word += input.slice(index, end + 1);
367
- index = end;
368
- state.wordEnd = index + 1;
369
- continue;
370
- }
371
- const unit = BASH_UNIT_STARTS.includes(char) ? scanBashUnit(input, index, depth, context, state.nestedCommands, "word", !state.assignmentWord && state.commandWordIndex >= 0 && !BASH_DECLARATIONS.has(state.rawWords[0]), state) : undefined;
372
- if (typeof unit === "object")
373
- return unit;
374
- if (unit !== undefined) {
375
- state.wordStarted = true;
376
- index = unit;
377
- state.wordEnd = index + 1;
378
- continue;
379
- }
380
- if (char === "[" && !inCasePattern && !state.assignmentWord && !state.assignmentHeadUnsafe && state.commandWordIndex < 0 && /^[A-Za-z_][A-Za-z0-9_]*$/.test(state.word)) {
381
- const subscript = [];
382
- const end = scanBashSubscript(input, index + 1, depth, context, subscript, BASH_SPANS.assignmentSubscript);
383
- if (typeof end === "object")
384
- return end;
385
- const assign = bashOperator(input, end + 1, ["+=", "="]);
386
- if (typeof assign === "object")
387
- return assign;
388
- if (assign) {
389
- if (context.dialect === "posix" && /[$`]/.test(input.slice(index + 1, end)))
390
- return { kind: "opaque", reason: "invalid-structure" };
391
- state.nestedCommands.push(...subscript);
392
- state.assignmentWord = true;
393
- state.word += input.slice(index, end + 1);
394
- index = end;
395
- state.wordEnd = index + 1;
396
- continue;
397
- }
398
- }
399
- if (char === "(" && (array || (inCasePattern || context.dialect === "bash") && /[?*+@!]$/.test(state.word))) {
400
- const mode = array ? "array" : "pattern";
401
- const end = scanBashArrayOrPattern(input, index, depth + 1, context, state.nestedCommands, mode);
402
- if (typeof end === "object")
403
- return end;
404
- if (bashCrossesHeredoc(state, index, end))
405
- return { kind: "opaque", reason: "heredoc" };
406
- if (array && end + 1 < input.length && !`
407
- ;&|<>)`.includes(input[end + 1]))
408
- return { kind: "opaque", reason: "invalid-structure" };
409
- state.wordStarted = true;
410
- state.word += input.slice(index, end + 1);
411
- index = end;
412
- state.wordEnd = index + 1;
413
- continue;
414
- }
415
- if (char === "#" && !state.wordStarted) {
416
- const newline = input.indexOf(`
417
- `, index);
418
- if (newline === -1)
419
- break;
420
- index = newline - 1;
421
- continue;
422
- }
423
- if (`<>&|;
424
- `.includes(char)) {
425
- const step = scanBashOperatorOrSeparator(state, index, depth, context);
426
- if (typeof step === "object")
427
- return step;
428
- index = step;
429
- continue;
430
- }
431
- if (inCasePattern && char === ")") {
432
- finishBashWord(state);
433
- index--;
434
- continue;
435
- }
436
- if (char === ")") {
437
- if (close !== ")" || state.structures.length > 0 || heredocs === undefined && state.heredocs.length > 0)
438
- return { kind: "opaque", reason: "compound-command" };
439
- return closeBashList(state, index);
440
- }
441
- if (char === "(")
442
- return { kind: "opaque", reason: state.wordStarted ? "dynamic-execution" : "compound-command" };
443
- if (/\s/.test(char) && !`
444
- `.includes(char))
445
- return { kind: "opaque", reason: "invalid-structure" };
446
- if (char === " " || char === "\t") {
447
- finishBashWord(state);
448
- continue;
449
- }
450
- state.wordStarted = true;
451
- if (char === "=" && !state.assignmentWord && !state.assignmentHeadUnsafe && /^[A-Za-z_][A-Za-z0-9_]*\+?$/.test(state.word))
452
- state.assignmentWord = true;
453
- bashAppend(state, char);
454
- state.wordEnd = index + 1;
455
- }
456
- if (close)
457
- return { kind: "opaque", reason: close === ")" ? "command-substitution" : "invalid-structure" };
458
- if (state.heredocs.length)
459
- return { kind: "opaque", reason: "heredoc" };
460
- return closeBashList(state, input.length);
461
- }
462
- function scanBashOperatorOrSeparator(state, index, depth, context) {
463
- const input = state.input;
464
- const char = input[index];
465
- const redirect = "<>&".includes(char) ? bashOperator(input, index, BASH_REDIRECTS) : undefined;
466
- if (typeof redirect === "object")
467
- return redirect;
468
- const caseHead = state.structures.at(-1);
469
- if (redirect && caseHead?.kind === "case" && caseHead.phase !== "body")
470
- return { kind: "opaque", reason: "invalid-redirect" };
471
- if (redirect) {
472
- state.hasRedirect = true;
473
- state.commandStart ??= state.wordStart;
474
- if (state.redirectTarget)
475
- state.invalid ??= "invalid-redirect";
476
- const fdPrefix = state.wordStarted && !state.assignmentHeadUnsafe && /^(?:\d+|\{[A-Za-z_][A-Za-z0-9_]*\})$/.test(state.word);
477
- if (fdPrefix) {
478
- if (state.wordEnd < index)
479
- state.commandEnd = state.wordEnd;
480
- state.word = "";
481
- state.literal = "";
482
- state.output = "";
483
- state.wordStarted = false;
484
- }
485
- if (!fdPrefix)
486
- finishBashWord(state);
487
- if (redirect.startsWith("&") && context.dialect === "posix")
488
- state.ampersandRedirectWords ??= state.words.length;
489
- if (state.redirectWordCount === undefined && state.commandWordIndex >= 0) {
490
- state.redirectWordCount = state.words.length;
491
- if (state.dangling)
492
- state.resourceEnd = state.commandEnd;
493
- }
494
- if (redirect === "<<" || redirect === "<<-") {
495
- const delimiter = bashHeredocDelimiter(input, index + redirect.length, redirect === "<<-");
496
- if (!delimiter)
497
- return { kind: "opaque", reason: "invalid-redirect" };
498
- state.heredocs.push(delimiter);
499
- state.wordEnd = delimiter.end + 1;
500
- state.redirectTarget = false;
501
- return delimiter.end;
502
- }
503
- state.redirectTarget = true;
504
- state.hereString = redirect === "<<<";
505
- return index + redirect.length - 1;
506
- }
507
- if (state.structures.at(-1)?.phase === "pattern" && char === "|") {
508
- finishBashWord(state);
509
- return index - 1;
510
- }
511
- const structure = state.structures.at(-1);
512
- const caseBody = structure?.kind === "case" && structure.phase === "body";
513
- const operator = bashOperator(input, index, caseBody ? BASH_CASE_OPERATORS : BASH_LIST_OPERATORS);
514
- if (typeof operator === "object")
515
- return operator;
516
- const separator = operator ?? char;
517
- if (caseBody && separator.startsWith(";") && separator.length > 1) {
518
- if (!endBashList(state))
519
- return { kind: "opaque", reason: "invalid-structure" };
520
- structure.phase = "pattern";
521
- structure.patternStarted = false;
522
- return index + separator.length - 1;
523
- }
524
- if (structure?.kind === "case" && (structure.phase === "header" || structure.phase === "pattern")) {
525
- if (separator !== `
526
- `)
527
- return { kind: "opaque", reason: "compound-command" };
528
- if (structure.phase === "pattern" && (state.wordStarted || state.words.length > 0))
529
- return { kind: "opaque", reason: "compound-command" };
530
- finishBashWord(state);
531
- return readBashHeredocs(state, index, depth, context);
532
- }
533
- if ((structure?.kind === "for" || structure?.kind === "repeat") && (structure.phase === "header" || structure.phase === "do")) {
534
- if (separator !== ";" && separator !== `
535
- `)
536
- return { kind: "opaque", reason: "compound-command" };
537
- if (structure.phase === "header" && !structure.sawIn && !state.wordStarted && state.words.length === 0)
538
- return { kind: "opaque", reason: "compound-command" };
539
- }
540
- if (separator === `
541
- ` && !pending(state))
542
- return readBashHeredocs(state, index, depth, context);
543
- finishBashCommand(state, true);
544
- if (structure?.kind === "for" && structure.phase === "header")
545
- structure.phase = "do";
546
- state.dangling = separator !== "&" && separator !== ";" && separator !== `
547
- `;
548
- if (separator === `
549
- ` && state.heredocs.length)
550
- return index - 1;
551
- return index + separator.length - 1;
552
- }
553
- function bashCommandKey(command) {
554
- return JSON.stringify([command.resource, command.words]);
555
- }
556
- function readBashHeredocs(state, index, depth, context) {
557
- let end = index;
558
- for (const heredoc of state.heredocs.splice(0)) {
559
- const body = bashHeredoc(state.input, end + 1, heredoc);
560
- if (!body)
561
- return { kind: "opaque", reason: "heredoc" };
562
- if (heredoc.command)
563
- heredoc.command.resource = state.input.slice(heredoc.start, body.end).trim();
564
- const text = heredoc.quoted ? { word: body.source, literal: body.source, output: "" } : bashText();
565
- if (!heredoc.quoted) {
566
- const expansion = scanBashSpan(body.source, 0, depth, context, state.commands, BASH_SPANS.heredoc, true, text);
567
- if (typeof expansion === "object")
568
- return expansion;
569
- }
570
- if (heredoc.binding)
571
- bashEvaluatesExpansion(text, "deferred", context);
572
- end = body.end;
573
- }
574
- return end;
575
- }
576
- function bashCrossesHeredoc(state, start, end) {
577
- return state.heredocs.length > 0 && state.input.slice(start, end).includes(`
578
- `);
579
- }
580
- function scanBashCommandStart(state, index, depth, context) {
581
- const input = state.input;
582
- const char = input[index];
583
- const structure = state.structures.at(-1);
584
- if (structure?.phase === "pattern" && !structure.patternStarted && !state.words.length && char === "(") {
585
- structure.patternStarted = true;
586
- return index;
587
- }
588
- if (structure?.phase === "pattern" && char === "|") {
589
- if (!state.words.length)
590
- return { kind: "opaque", reason: "compound-command" };
591
- finishBashWord(state);
592
- structure.patternStarted = true;
593
- return index;
594
- }
595
- if (structure?.phase === "pattern" && char === ")") {
596
- if (!state.words.length)
597
- return { kind: "opaque", reason: "compound-command" };
598
- finishBashCommand(state);
599
- structure.phase = "body";
600
- structure.count = 0;
601
- return index;
602
- }
603
- if (structure?.kind === "for" && structure.phase === "header" && char === "(" && input[index + 1] !== "(") {
604
- const end = scanBashArrayOrPattern(input, index, depth + 1, context, state.nestedCommands, "array");
605
- if (typeof end === "object")
606
- return end;
607
- if (bashCrossesHeredoc(state, index, end))
608
- return { kind: "opaque", reason: "heredoc" };
609
- finishBashCommand(state);
610
- structure.phase = "do";
611
- structure.parenthesized = true;
612
- DO_AHEAD_RE.lastIndex = end + 1;
613
- if (!DO_AHEAD_RE.test(input))
614
- state.structures.pop();
615
- return end;
616
- }
617
- if (structure?.kind === "repeat" && structure.phase === "do" && char !== `
618
- ` && char !== "#" && char !== ";") {
619
- TOKEN_RE.lastIndex = index;
620
- if (TOKEN_RE.exec(input)?.[0] !== "do")
621
- state.structures.pop();
622
- }
623
- const keywordStep = scanBashKeyword(state, index, depth, context);
624
- if (keywordStep !== undefined)
625
- return keywordStep;
626
- if (structure?.kind === "for" && structure.phase === "do" && char !== `
627
- ` && char !== "#" && char !== ";") {
628
- SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 1;
629
- if (char !== "{" || !SPACE_CONTINUATION_AHEAD_RE.test(input))
630
- return { kind: "opaque", reason: "compound-command" };
631
- state.structures.pop();
632
- }
633
- const atStart = atCommandStart(state);
634
- const functionHead = atStart && char === "(" ? bashFunctionHeadLength(input, index) : 0;
635
- if (functionHead)
636
- return index + functionHead - 1;
637
- if (atStart && char === "!") {
638
- NEGATION_AHEAD_RE.lastIndex = index + 1;
639
- if (NEGATION_AHEAD_RE.test(input))
640
- return index;
641
- }
642
- const forHeader = structure?.kind === "for" && structure.phase === "header";
643
- const compoundOpen = (atStart || forHeader) && "([".includes(char) ? bashOperator(input, index, ["((", "[["]) : undefined;
644
- if (typeof compoundOpen === "object")
645
- return compoundOpen;
646
- if (compoundOpen === "((") {
647
- if (forHeader && state.words.length > 0)
648
- return { kind: "opaque", reason: "compound-command" };
649
- const span = forHeader ? BASH_SPANS.forArithmetic : BASH_SPANS.arithmetic;
650
- const end = scanBashArithmetic(input, index + 2, depth, context, state.commands, span);
651
- if (typeof end === "number") {
652
- if (bashCrossesHeredoc(state, index, end))
653
- return { kind: "opaque", reason: "heredoc" };
654
- if (!forHeader && context.dialect === "posix") {
655
- const subshells = scanBash(input, index + 1, depth + 1, context, ")");
656
- if (subshells.kind === "opaque")
657
- return subshells;
658
- if (subshells.end !== end)
659
- return { kind: "opaque", reason: "compound-command" };
660
- const seen = new Set(state.commands.map(bashCommandKey));
661
- state.commands.push(...subshells.commands.filter((command) => !seen.has(bashCommandKey(command))));
662
- }
663
- if (forHeader) {
664
- structure.phase = "do";
665
- structure.sawIn = true;
666
- }
667
- if (!forHeader) {
668
- bashStatement(state);
669
- state.compoundEnd = true;
670
- }
671
- return end;
672
- }
673
- if (end)
674
- return end;
675
- if (forHeader)
676
- return { kind: "opaque", reason: "invalid-structure" };
677
- }
678
- if (atStart && (char === "(" || char === "{" && (SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 1, SPACE_CONTINUATION_AHEAD_RE.test(input)))) {
679
- const group = scanBash(input, index + 1, depth + 1, context, char === "{" ? "}" : ")", state.heredocs);
680
- if (group.kind === "opaque")
681
- return group;
682
- if (!input.slice(index + 1, group.end).trim())
683
- return { kind: "opaque", reason: "invalid-structure" };
684
- state.commands.push(...group.commands);
685
- bashStatement(state);
686
- state.compoundEnd = true;
687
- return group.end;
688
- }
689
- if (atStart && compoundOpen === "[[" && (SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 2, SPACE_CONTINUATION_AHEAD_RE.test(input))) {
690
- const end = scanBashConditional(input, index + 2, depth, context, state.commands);
691
- if (typeof end === "object")
692
- return end;
693
- if (bashCrossesHeredoc(state, index, end))
694
- return { kind: "opaque", reason: "heredoc" };
695
- bashStatement(state);
696
- state.compoundEnd = true;
697
- return end;
698
- }
699
- return;
700
- }
701
- function scanBashKeyword(state, index, depth, context) {
702
- const input = state.input;
703
- const char = input[index];
704
- if (!(char >= "A" && char <= "Z" || char >= "a" && char <= "z" || char === "_"))
705
- return;
706
- const structure = state.structures.at(-1);
707
- TOKEN_RE.lastIndex = index;
708
- const token = TOKEN_RE.exec(input)?.[0];
709
- const end = index + (token?.length ?? 0) - 1;
710
- if (structure?.kind === "case" && structure.phase === "header" && token === "in") {
711
- if (state.words.length !== 1 || state.hasRedirect)
712
- return { kind: "opaque", reason: "compound-command" };
713
- finishBashCommand(state);
714
- structure.phase = "pattern";
715
- structure.patternStarted = false;
716
- return end;
717
- }
718
- if (structure?.kind === "for" && (structure.phase === "header" || structure.phase === "do") && !structure.sawIn && !structure.parenthesized && token === "in" && (structure.phase === "do" || state.words.length >= 1)) {
719
- structure.sawIn = true;
720
- structure.phase = "header";
721
- return end;
722
- }
723
- if (structure?.phase === "pattern" && !structure.patternStarted && !state.words.length && token === "esac") {
724
- state.structures.pop();
725
- bashStatement(state);
726
- state.compoundEnd = true;
727
- return end;
728
- }
729
- if (structure?.kind === "for" && structure.phase === "header" && !structure.sawIn && state.words.length === 1 && !state.hasRedirect && token === "do") {
730
- finishBashCommand(state);
731
- structure.phase = "do";
732
- }
733
- const inHeader = bashInHeader(state);
734
- if (token && ["then", "elif", "else", "fi", "do", "done", "esac"].includes(token) && !state.words.length && !state.redirectTarget && (!inHeader || token === "do" && structure?.phase === "do")) {
735
- if (state.hasRedirect && context.dialect !== "zsh" || !endBashList(state) || !structure)
736
- return { kind: "opaque", reason: "compound-command" };
737
- if (token === "then") {
738
- if (structure.kind !== "if" || structure.phase !== "condition" || !structure.count)
739
- return { kind: "opaque", reason: "compound-command" };
740
- structure.phase = "body";
741
- structure.count = 0;
742
- return end;
743
- }
744
- if (token === "elif" || token === "else") {
745
- if (structure.kind !== "if" || structure.phase !== "body" || !structure.count || structure.sawElse)
746
- return { kind: "opaque", reason: "compound-command" };
747
- structure.phase = token === "elif" ? "condition" : "body";
748
- structure.sawElse = token === "else";
749
- structure.count = 0;
750
- return end;
751
- }
752
- if (token === "do") {
753
- if (!["for", "while", "until", "repeat"].includes(structure.kind) || !["condition", "do"].includes(structure.phase) || structure.kind !== "for" && structure.kind !== "repeat" && !structure.count)
754
- return { kind: "opaque", reason: "compound-command" };
755
- structure.phase = "body";
756
- structure.count = 0;
757
- return end;
758
- }
759
- if (token === "fi" && (structure.kind !== "if" || structure.phase !== "body" || !structure.count) || token === "done" && (!["for", "while", "until", "repeat"].includes(structure.kind) || structure.phase !== "body" || !structure.count) || token === "esac" && (structure.kind !== "case" || structure.phase === "header"))
760
- return { kind: "opaque", reason: "compound-command" };
761
- state.structures.pop();
762
- bashStatement(state);
763
- state.compoundEnd = true;
764
- return end;
765
- }
766
- if (!atCommandStart(state))
767
- return;
768
- const definitionLength = bashFunctionHeadLength(input, index);
769
- if (definitionLength > 0)
770
- return index + definitionLength - 1;
771
- if (token === "if" || token === "while" || token === "until" || token === "for" || token === "select" || token === "case" || token === "repeat" && context.dialect !== "bash") {
772
- if (depth + state.structures.length >= MAX_SUBSTITUTION_DEPTH)
773
- return { kind: "opaque", reason: "compound-command" };
774
- state.structures.push({
775
- kind: token === "select" ? "for" : token,
776
- phase: ["for", "select", "case", "repeat"].includes(token) ? "header" : "condition",
777
- count: 0
778
- });
779
- state.dangling = false;
780
- return end;
781
- }
782
- if (token === "coproc") {
783
- COPROC_AHEAD_RE.lastIndex = index;
784
- const coprocMatch = COPROC_AHEAD_RE.exec(input)?.[0];
785
- if (coprocMatch)
786
- return index + coprocMatch.length - 1;
787
- }
788
- if (token === "time") {
789
- TIME_AHEAD_RE.lastIndex = index;
790
- const timeMatch = TIME_AHEAD_RE.exec(input)?.[0];
791
- if (timeMatch)
792
- return index + timeMatch.length - 1;
793
- }
794
- return;
795
- }
796
- function bashFunctionHeadLength(input, start) {
797
- FUNCTION_HEAD_RE.lastIndex = start;
798
- const head = FUNCTION_HEAD_RE.exec(input);
799
- if (!head || (head[1] ? !head[2] : !head[3] || BASH_NON_FUNCTION_KEYWORDS.has(head[2] ?? "")))
800
- return 0;
801
- FUNCTION_BODY_RE.lastIndex = start + head[0].length;
802
- return FUNCTION_BODY_RE.test(input) ? head[0].length - head[4].length : 0;
803
- }
804
- var BASH_SPANS = {
805
- double: { close: '"', reject: "", mode: "quoted" },
806
- heredoc: { reject: "", mode: "quoted" },
807
- arithmetic: { open: "(", close: ")", reject: ";#}", mode: "arithmetic" },
808
- forArithmetic: { open: "(", close: ")", reject: "#}", mode: "arithmetic" },
809
- bracketArithmetic: { close: "]", reject: `;|&<>()[
810
- '"\\#`, mode: "arithmetic" },
811
- subscript: { open: "[", close: "]", reject: '"}', mode: "arithmetic" },
812
- quotedSubscript: { open: "[", close: "]", reject: '"', mode: "quoted" },
813
- assignmentSubscript: { open: "[", close: "]", reject: `
814
- \r\v\f;&|<>()`, mode: "arithmetic" },
815
- arithmeticQuote: { close: "'", reject: '()[];"}', mode: "quoted" },
816
- arithmeticDouble: { close: '"', reject: "()[];}", mode: "quoted" },
817
- parameterQuote: { close: "'", reject: '"}[]', mode: "quoted" }
818
- };
819
- function scanBashUnit(input, index, depth, context, commands, mode, allowBracket, text) {
820
- const char = input[index];
821
- const next = input[index + 1] ?? "\x00";
822
- if (char === "\\") {
823
- if (mode === "quoted" && !'$`"\\\n'.includes(next))
824
- return;
825
- if (text && next !== `
826
- `)
827
- bashAppend(text, input.slice(index + 1, index + 2));
828
- return index + 1;
829
- }
830
- if (char === "$" && context.dialect !== "bash" && zshEvaluates(input, index))
831
- return { kind: "opaque", reason: "dynamic-execution" };
832
- if (char === "$" && context.dialect !== "bash" && (mode === "word" || mode === "quoted") && (ZSH_SUBSCRIPT_RE.lastIndex = index, ZSH_SUBSCRIPT_RE.test(input))) {
833
- const bracket = ZSH_SUBSCRIPT_RE.lastIndex;
834
- const subscript = bashText();
835
- const span = mode === "quoted" ? BASH_SPANS.quotedSubscript : BASH_SPANS.subscript;
836
- const end = scanBashSpan(input, bracket, depth, context, commands, span, false, subscript);
837
- if (typeof end === "object")
838
- return end;
839
- if (bashEvaluatesExpansion(subscript, "arithmetic", context))
840
- return { kind: "opaque", reason: "dynamic-execution" };
841
- if (text)
842
- text.word += `${input.slice(index, bracket)}${subscript.word}]`;
843
- return end;
844
- }
845
- const opener = char === "$" ? bashOperator(input, index, ["$$", "$((", "$(", "${", "$[", "$'", '$"']) : mode === "word" && (char === "<" || char === ">") ? bashOperator(input, index, [`${char}(`]) : undefined;
846
- if (typeof opener === "object")
847
- return opener;
848
- if (opener === "$$") {
849
- LINE_CONTINUATION_RE.lastIndex = index + 2;
850
- const quoteStart = LINE_CONTINUATION_RE.exec(input) ? LINE_CONTINUATION_RE.lastIndex : index + 2;
851
- if (input[quoteStart] === "'") {
852
- const nextQuote = input.indexOf("'", quoteStart + 1);
853
- if (nextQuote < 0)
854
- return { kind: "opaque", reason: "unterminated-quote" };
855
- if (input.slice(quoteStart + 1, nextQuote).includes("\\") && input.includes("'", nextQuote + 1))
856
- return { kind: "opaque", reason: "unterminated-quote" };
857
- }
858
- if (text)
859
- text.word += "$$";
860
- return index + 1;
861
- }
862
- if (mode === "word" && opener === "$'") {
863
- const quote = bashAnsiQuote(input, index + 1);
864
- if (!quote)
865
- return { kind: "opaque", reason: "unterminated-quote" };
866
- const firstQuote = input.indexOf("'", index + 2);
867
- if (quote.end !== firstQuote && (context.dialect !== "bash" && index >= 2 && input[index - 2] === "$" || context.dialect === "posix" && (input.indexOf("'", firstQuote + 1) < quote.end || /[#"\n]|\\'/.test(input.slice(firstQuote + 1)))))
868
- return { kind: "opaque", reason: "unterminated-quote" };
869
- if (text)
870
- bashAppend(text, quote.value);
871
- return quote.end;
872
- }
873
- if (mode === "arithmetic" && opener === "$'") {
874
- const quote = bashAnsiQuote(input, index + 1);
875
- if (!quote || quote.end !== input.indexOf("'", index + 2) || /[()[\];"}]/.test(quote.value))
876
- return { kind: "opaque", reason: "invalid-structure" };
877
- if (text)
878
- bashAppend(text, quote.value);
879
- return scanBashSpan(input, index + 2, depth, context, commands, BASH_SPANS.arithmeticQuote, allowBracket, text);
880
- }
881
- if (mode === "word" && char === "'") {
882
- const end = input.indexOf("'", index + 1);
883
- if (end < 0)
884
- return { kind: "opaque", reason: "unterminated-quote" };
885
- if (text)
886
- bashAppend(text, input.slice(index + 1, end));
887
- return end;
888
- }
889
- if (mode === "arithmetic" && char === "'")
890
- return scanBashSpan(input, index + 1, depth, context, commands, BASH_SPANS.arithmeticQuote, allowBracket, text);
891
- if (mode === "word" && opener === '$"')
892
- return scanBashSpan(input, index + 2, depth, context, commands, BASH_SPANS.double, allowBracket, text);
893
- if (mode !== "quoted" && char === '"') {
894
- const span = mode === "arithmetic" ? BASH_SPANS.arithmeticDouble : BASH_SPANS.double;
895
- return scanBashSpan(input, index + 1, depth, context, commands, span, allowBracket, text);
896
- }
897
- const end = opener === "<(" || opener === ">(" ? scanBashNested(input, index + 2, depth, context, commands, ")") : opener && opener !== "$'" && opener !== '$"' || char === "`" ? scanBashDollarOrBacktick(input, index, depth, context, commands, mode !== "word", allowBracket, text) : undefined;
898
- if (end === undefined && char === "$" && /[A-Za-z_0-9@*#?$!-]/.test(next)) {
899
- if (text)
900
- text.word += "$";
901
- return index;
902
- }
903
- if (text && typeof end === "number")
904
- text.word += input.slice(index, end + 1);
905
- return end;
906
- }
907
- function zshEvaluates(input, index) {
908
- let at = index + 1;
909
- if (input.startsWith("{\\\n", at))
910
- return true;
911
- if (input[at] === "{" && input[at + 1] === "(") {
912
- ZSH_SAFE_FLAGS_RE.lastIndex = index;
913
- if (!ZSH_SAFE_FLAGS_RE.test(input))
914
- return true;
915
- at = ZSH_SAFE_FLAGS_RE.lastIndex;
916
- }
917
- if (input[at] === "{")
918
- at++;
919
- ZSH_GLOB_MODIFIER_RE.lastIndex = at;
920
- return ZSH_GLOB_MODIFIER_RE.test(input);
921
- }
922
- function bashAppend(text, value) {
923
- text.word += value;
924
- text.literal += value;
925
- }
926
- function bashEvaluatesExpansion(text, evaluation, context) {
927
- const combined = `${text.literal} ${text.output}`;
928
- const hasExpansion = BASH_EXPANSION_RE.test(combined);
929
- const hasEscape = BASH_ESCAPE_RE.test(text.literal);
930
- if (hasExpansion || hasEscape || /[$`]/.test(text.literal))
931
- context.boundDollar = true;
932
- if (hasExpansion || hasEscape || /[({`]/.test(text.literal))
933
- context.boundOpen = true;
934
- if (evaluation === "deferred")
935
- return false;
936
- if (evaluation === "arithmetic" ? /[A-Za-z_]|(?:\$(?![?#!-]|\$(?!\[)))/.test(text.word) : text.word.includes("$") || combined.includes("["))
937
- context.variableSink = true;
938
- if (evaluation === "arithmetic")
939
- return hasExpansion;
940
- return combined.includes("[") && hasExpansion;
941
- }
942
- function bashText() {
943
- return { word: "", literal: "", output: "" };
944
- }
945
- function scanBashSubscript(input, start, depth, context, commands, span = BASH_SPANS.subscript) {
946
- const text = bashText();
947
- const end = scanBashSpan(input, start, depth, context, commands, span, false, text);
948
- if (typeof end === "number" && bashEvaluatesExpansion(text, "arithmetic", context))
949
- return { kind: "opaque", reason: "dynamic-execution" };
950
- return end;
951
- }
952
- function scanBashSpan(input, start, depth, context, commands, span, allowBracket, text) {
953
- let nesting = 0;
954
- for (let index = start;index < input.length; index++) {
955
- if (--context.remaining < 0)
956
- return { kind: "opaque", reason: "invalid-structure" };
957
- const char = input[index];
958
- if (char === span.close && !nesting)
959
- return index;
960
- if (span.reject.includes(char) && !(char === "#" && /[\d$]/.test(input[index - 1] ?? "")))
961
- return { kind: "opaque", reason: "invalid-structure" };
962
- if (char === span.open && ++nesting + depth > MAX_SUBSTITUTION_DEPTH)
963
- return { kind: "opaque", reason: "invalid-structure" };
964
- if (char === span.close)
965
- nesting--;
966
- const unit = char === span.open || char === span.close ? undefined : scanBashUnit(input, index, depth, context, commands, span.mode, allowBracket, text);
967
- if (typeof unit === "object")
968
- return unit;
969
- if (unit !== undefined)
970
- index = unit;
971
- else if (char === "\\" && (input[index + 1] === span.open || input[index + 1] === span.close)) {
972
- if (text)
973
- bashAppend(text, input.slice(index, index + 2));
974
- index++;
975
- } else if (text)
976
- bashAppend(text, char);
977
- }
978
- return span.close ? { kind: "opaque", reason: "unterminated-quote" } : input.length;
979
- }
980
- function scanBashNested(input, start, depth, context, commands, close, text) {
981
- const nested = scanBash(input, start, depth + 1, context, close, undefined, text);
982
- if (nested.kind === "opaque")
983
- return nested;
984
- commands.push(...nested.commands);
985
- return nested.end;
986
- }
987
- function bashOperator(input, index, operators) {
988
- let text = "";
989
- for (let cursor = index;text.length < 3 && cursor < input.length; cursor++) {
990
- if (input.startsWith("\\\n", cursor))
991
- cursor++;
992
- else
993
- text += input[cursor];
994
- }
995
- const operator = operators.find((candidate) => text.startsWith(candidate));
996
- if (operator && !input.startsWith(operator, index))
997
- return { kind: "opaque", reason: "invalid-structure" };
998
- return operator;
999
- }
1000
- function scanBashDollarOrBacktick(input, start, depth, context, commands, quoted, allowBracket, text) {
1001
- if (depth >= MAX_SUBSTITUTION_DEPTH)
1002
- return { kind: "opaque", reason: "command-substitution" };
1003
- if (input[start] === "`")
1004
- return scanBashBacktick(input, start, depth + 1, context, commands, quoted, text);
1005
- if (input.startsWith("$((", start)) {
1006
- const end = scanBashArithmetic(input, start + 3, depth + 1, context, commands, BASH_SPANS.arithmetic);
1007
- if (end !== undefined)
1008
- return end;
1009
- }
1010
- if (input.startsWith("$(", start))
1011
- return scanBashNested(input, start + 2, depth, context, commands, ")", text);
1012
- NOFORK_OPEN_RE.lastIndex = start;
1013
- const nofork = NOFORK_OPEN_RE.exec(input);
1014
- if (nofork)
1015
- return scanBashNested(input, start + nofork[0].length, depth, context, commands, "nofork", text);
1016
- if (input.startsWith("${", start)) {
1017
- const parameter = bashText();
1018
- const end = scanBashParameter(input, start + 2, depth + 1, context, commands, quoted, parameter);
1019
- if (/^(?:\\\n)*!/.test(input.slice(start + 2))) {
1020
- context.variableSink = true;
1021
- if (bashEvaluatesExpansion(parameter, "binding", context))
1022
- return { kind: "opaque", reason: "dynamic-execution" };
1023
- }
1024
- if (text) {
1025
- text.literal += parameter.literal;
1026
- text.output += parameter.output;
1027
- }
1028
- return end;
1029
- }
1030
- if (!allowBracket && context.dialect === "posix")
1031
- return { kind: "opaque", reason: "command-substitution" };
1032
- const expression = bashText();
1033
- const end = scanBashSpan(input, start + 2, depth + 1, context, commands, BASH_SPANS.bracketArithmetic, true, expression);
1034
- if (typeof end === "number" && bashEvaluatesExpansion(expression, "arithmetic", context))
1035
- return { kind: "opaque", reason: "dynamic-execution" };
1036
- return end;
1037
- }
1038
- function scanBashArithmetic(input, start, depth, context, commands, span) {
1039
- const arithmetic = [];
1040
- const text = bashText();
1041
- const end = scanBashSpan(input, start, depth, context, arithmetic, span, true, text);
1042
- if (typeof end === "object")
1043
- return { kind: "opaque", reason: "invalid-structure" };
1044
- const close = bashOperator(input, end, ["))"]);
1045
- if (typeof close === "object")
1046
- return close;
1047
- if (!close)
1048
- return;
1049
- if (bashEvaluatesExpansion(text, "arithmetic", context))
1050
- return { kind: "opaque", reason: "dynamic-execution" };
1051
- commands.push(...arithmetic);
1052
- return end + 1;
1053
- }
1054
- function scanBashBacktick(input, start, depth, context, commands, quoted, text) {
1055
- let source = "";
1056
- for (let index = start + 1;index < input.length; index++) {
1057
- if (--context.remaining < 0)
1058
- return { kind: "opaque", reason: "invalid-structure" };
1059
- if (input[index] === "`") {
1060
- const inner = scanBash(source, 0, depth, context, undefined, undefined, text);
1061
- if (inner.kind === "opaque")
1062
- return { kind: "opaque", reason: "command-substitution" };
1063
- commands.push(...inner.commands);
1064
- return index;
1065
- }
1066
- const next = input[index + 1] ?? "\x00";
1067
- if (input[index] === "\\" && ("$`\\\n".includes(next) || quoted && next === '"')) {
1068
- index++;
1069
- if (next !== `
1070
- `)
1071
- source += next;
1072
- continue;
1073
- }
1074
- source += input[index];
1075
- }
1076
- return { kind: "opaque", reason: "command-substitution" };
1077
- }
1078
- function scanBashParameter(input, start, depth, context, commands, quoted, text) {
1079
- PARAMETER_PREFIX_RE.lastIndex = start;
1080
- const nameStart = PARAMETER_PREFIX_RE.exec(input) ? PARAMETER_PREFIX_RE.lastIndex : start;
1081
- PARAMETER_NAME_RE.lastIndex = nameStart;
1082
- let colon = PARAMETER_NAME_RE.test(input) ? PARAMETER_NAME_RE.lastIndex : -1;
1083
- const name = colon > nameStart ? input.slice(nameStart, colon).replace(/\\\n/g, "") : "";
1084
- if (context.dialect !== "bash" && (/^(?:READ)?NULLCMD$/.test(name) || /^(?:(?:dis_)?(?:functions|[gs]?aliases)|options|commands)$/.test(name) && "[=:".includes(input[colon] ?? "")))
1085
- return { kind: "opaque", reason: "dynamic-execution" };
1086
- if (name === "PS4")
1087
- context.variableSink = true;
1088
- let evaluation;
1089
- let wordOffset = 0;
1090
- let literalOffset = 0;
1091
- for (let index = start;index < input.length; index++) {
1092
- if (--context.remaining < 0)
1093
- return { kind: "opaque", reason: "invalid-structure" };
1094
- const char = input[index];
1095
- if (char === "}") {
1096
- if (evaluation && bashEvaluatesExpansion({ word: text.word.slice(wordOffset), literal: text.literal.slice(literalOffset), output: text.output }, evaluation, context))
1097
- return { kind: "opaque", reason: "dynamic-execution" };
1098
- return index;
1099
- }
1100
- if (index === colon && !evaluation) {
1101
- if (char === ":" && !"-=?+".includes(input[index + 1] ?? ""))
1102
- evaluation = "arithmetic";
1103
- if (char === "=" || char === ":" && input[index + 1] === "=")
1104
- evaluation = "deferred";
1105
- if (evaluation) {
1106
- wordOffset = text.word.length;
1107
- literalOffset = text.literal.length;
1108
- }
1109
- }
1110
- if (char === "@") {
1111
- PARAMETER_PROMPT_RE.lastIndex = index;
1112
- if (PARAMETER_PROMPT_RE.test(input))
1113
- return { kind: "opaque", reason: "dynamic-execution" };
1114
- }
1115
- if (!quoted && context.dialect !== "bash" && char === "(" && index > start)
1116
- return { kind: "opaque", reason: "dynamic-execution" };
1117
- if (quoted && char === "'" && input[index - 1] === "$") {
1118
- const ansi = bashAnsiQuote(input, index);
1119
- if (!ansi)
1120
- return { kind: "opaque", reason: "unterminated-quote" };
1121
- text.literal += ansi.value;
1122
- }
1123
- const subscript = index === colon && char === "[";
1124
- const unit = subscript ? scanBashSubscript(input, index + 1, depth, context, commands) : quoted && char === "'" ? scanBashSpan(input, index + 1, depth, context, commands, BASH_SPANS.parameterQuote, false, text) : quoted && char === '"' ? scanBashSpan(input, index + 1, depth, context, commands, BASH_SPANS.double, false, text) : scanBashUnit(input, index, depth, context, commands, quoted ? "quoted" : "word", false, text);
1125
- if (typeof unit === "object")
1126
- return unit;
1127
- if (quoted && unit !== undefined && input.startsWith("$(", index) && input.slice(index, unit + 1).includes("}"))
1128
- return { kind: "opaque", reason: "command-substitution" };
1129
- if (subscript || index === nameStart && input.startsWith("${", index) && unit !== undefined) {
1130
- LINE_CONTINUATION_RE.lastIndex = Number(unit) + 1;
1131
- colon = LINE_CONTINUATION_RE.exec(input) ? LINE_CONTINUATION_RE.lastIndex : Number(unit) + 1;
1132
- }
1133
- if (unit !== undefined)
1134
- index = unit;
1135
- else
1136
- bashAppend(text, char);
1137
- }
1138
- return { kind: "opaque", reason: "command-substitution" };
1139
- }
1140
- function scanBashConditional(input, start, depth, context, commands) {
1141
- const words = [];
1142
- let text = bashText();
1143
- let wordStarted = false;
1144
- let hasWord = false;
1145
- let parenDepth = 0;
1146
- let patternParenDepth = 0;
1147
- const flushWord = () => {
1148
- if (!hasWord)
1149
- return;
1150
- words.push(text);
1151
- text = bashText();
1152
- hasWord = false;
1153
- };
1154
- for (let index = start;index < input.length; index++) {
1155
- if (--context.remaining < 0)
1156
- return { kind: "opaque", reason: "invalid-structure" };
1157
- const char = input[index];
1158
- if (char === "\\" && input[index + 1] === `
1159
- `) {
1160
- index++;
1161
- continue;
1162
- }
1163
- if (!wordStarted)
1164
- flushWord();
1165
- const close = !wordStarted && char === "]" ? bashOperator(input, index, ["]]"]) : undefined;
1166
- if (typeof close === "object")
1167
- return close;
1168
- if (close) {
1169
- BRACE_CLOSE_AHEAD_RE.lastIndex = index + 2;
1170
- if (BRACE_CLOSE_AHEAD_RE.test(input)) {
1171
- if (parenDepth !== 0)
1172
- return { kind: "opaque", reason: "invalid-structure" };
1173
- const evaluated = words.some((word, at) => words[at - 1]?.word === "-v" && bashEvaluatesExpansion(word, "binding", context) || (context.dialect !== "bash" && words[at - 1]?.word === "-t" || BASH_ARITHMETIC_COMPARISONS.has(words[at - 1]?.word ?? "") || BASH_ARITHMETIC_COMPARISONS.has(words[at + 1]?.word ?? "")) && bashEvaluatesExpansion(word, "arithmetic", context));
1174
- if (evaluated)
1175
- return { kind: "opaque", reason: "dynamic-execution" };
1176
- return index + 1;
1177
- }
1178
- }
1179
- if (!wordStarted && char === "#") {
1180
- const newline = input.indexOf(`
1181
- `, index);
1182
- if (newline < 0)
1183
- return { kind: "opaque", reason: "invalid-structure" };
1184
- index = newline;
1185
- continue;
1186
- }
1187
- if (char === " " || char === "\t" || char === `
1188
- `) {
1189
- if (!patternParenDepth)
1190
- wordStarted = false;
1191
- continue;
1192
- }
1193
- if (char === ";")
1194
- return { kind: "opaque", reason: "invalid-structure" };
1195
- if (char === "(" || char === ")") {
1196
- if (char === ")" && parenDepth === 0)
1197
- return { kind: "opaque", reason: "invalid-structure" };
1198
- const inPattern = patternParenDepth > 0 || char === "(" && ["=", "==", "!=", "=~"].includes(words.at(-1)?.word ?? "");
1199
- parenDepth += char === "(" ? 1 : -1;
1200
- if (inPattern) {
1201
- patternParenDepth += char === "(" ? 1 : -1;
1202
- wordStarted = true;
1203
- hasWord = true;
1204
- bashAppend(text, char);
1205
- continue;
1206
- }
1207
- flushWord();
1208
- words.push({ word: char, literal: "", output: "" });
1209
- wordStarted = false;
1210
- continue;
1211
- }
1212
- const unit = scanBashUnit(input, index, depth, context, commands, "word", true, text);
1213
- if (typeof unit === "object")
1214
- return unit;
1215
- if (unit !== undefined)
1216
- index = unit;
1217
- if (unit === undefined && !patternParenDepth && "&|<>".includes(char)) {
1218
- flushWord();
1219
- words.push({ word: char, literal: "", output: "" });
1220
- wordStarted = false;
1221
- continue;
1222
- }
1223
- wordStarted = true;
1224
- hasWord = true;
1225
- if (unit === undefined)
1226
- bashAppend(text, char);
1227
- }
1228
- return { kind: "opaque", reason: "invalid-structure" };
1229
- }
1230
- function scanBashArrayOrPattern(input, start, depth, context, commands, mode) {
1231
- if (depth > MAX_SUBSTITUTION_DEPTH)
1232
- return { kind: "opaque", reason: "command-substitution" };
1233
- const text = mode === "array" ? bashText() : undefined;
1234
- let wordStarted = false;
1235
- for (let index = start + 1;index < input.length; index++) {
1236
- if (--context.remaining < 0)
1237
- return { kind: "opaque", reason: "invalid-structure" };
1238
- const char = input[index];
1239
- if (char === "\\" && input[index + 1] === `
1240
- `) {
1241
- index++;
1242
- continue;
1243
- }
1244
- if (text && (char === ")" || char === " " || char === "\t" || char === `
1245
- `)) {
1246
- bashEvaluatesExpansion(text, "deferred", context);
1247
- text.literal = "";
1248
- text.output = "";
1249
- }
1250
- if (char === ")")
1251
- return index;
1252
- if (mode === "array" && !wordStarted && char === "#") {
1253
- const newline = input.indexOf(`
1254
- `, index);
1255
- if (newline < 0)
1256
- return { kind: "opaque", reason: "command-substitution" };
1257
- index = newline;
1258
- continue;
1259
- }
1260
- if (char === " " || char === "\t" || mode === "array" && char === `
1261
- `) {
1262
- wordStarted = false;
1263
- continue;
1264
- }
1265
- if (char === `
1266
- ` || char === ";" || char === "&" || mode === "array" && "|(".includes(char))
1267
- return { kind: "opaque", reason: "command-substitution" };
1268
- wordStarted = true;
1269
- const unit = mode === "array" && char === "=" && input[index + 1] === "(" ? scanBashNested(input, index + 2, depth, context, commands, ")") : char === "(" ? scanBashArrayOrPattern(input, index, depth + 1, context, commands, mode) : char === "[" ? scanBashSubscript(input, index + 1, depth, context, commands) : scanBashUnit(input, index, depth, context, commands, "word", false, text);
1270
- if (typeof unit === "object")
1271
- return unit;
1272
- if (unit !== undefined)
1273
- index = unit;
1274
- else if (text)
1275
- text.literal += char;
1276
- }
1277
- return { kind: "opaque", reason: "command-substitution" };
1278
- }
1279
- function bashAnsiQuote(input, start) {
1280
- let value = "";
1281
- for (let index = start + 1;index < input.length; index++) {
1282
- if (input[index] === "'")
1283
- return { value, end: index };
1284
- if (input[index] !== "\\") {
1285
- value += input[index];
1286
- continue;
1287
- }
1288
- const escaped = input[++index];
1289
- if (escaped === undefined)
1290
- return;
1291
- if (escaped in BASH_ANSI_ESCAPES) {
1292
- value += BASH_ANSI_ESCAPES[escaped];
1293
- continue;
1294
- }
1295
- const digits = escaped === "x" ? /^[\da-fA-F]{1,2}/.exec(input.slice(index + 1, index + 3))?.[0] : /[0-7]/.test(escaped) ? /^[0-7]{1,3}/.exec(input.slice(index, index + 3))?.[0] : undefined;
1296
- if (!digits)
1297
- return;
1298
- const octal = /[0-7]/.test(escaped);
1299
- const point = parseInt(digits, octal ? 8 : 16);
1300
- if (point === 0)
1301
- return;
1302
- value += String.fromCodePoint(point);
1303
- index += digits.length - (octal ? 1 : 0);
1304
- }
1305
- }
1306
- function bashHeredocDelimiter(input, start, tabs) {
1307
- let delimiter = "";
1308
- let dashDelimiter;
1309
- let quoted = false;
1310
- let quote;
1311
- let end = start;
1312
- let started = false;
1313
- for (let index = start;index < input.length; index++) {
1314
- const char = input[index];
1315
- if (!started && /[ \t]/.test(char))
1316
- continue;
1317
- if (!started && char === "#")
1318
- return;
1319
- if (!quote && /[ \t\n;&|()<>]/.test(char))
1320
- return started ? { delimiter, dashDelimiter, quoted, tabs, end } : undefined;
1321
- if (!quote && char === "$" && input.startsWith("\\\n", index + 1))
1322
- return;
1323
- if (!quote && input.startsWith("$'", index)) {
1324
- const literal = bashAnsiQuote(input, index + 1);
1325
- if (!literal || literal.end !== input.indexOf("'", index + 2))
1326
- return;
1327
- dashDelimiter = `${dashDelimiter ?? delimiter}$${input.slice(index + 2, literal.end)}`;
1328
- delimiter += literal.value;
1329
- quoted = true;
1330
- started = true;
1331
- index = literal.end;
1332
- end = index;
1333
- continue;
1334
- }
1335
- if (!quote && input.startsWith('$"', index))
1336
- return;
1337
- if (char === quote) {
1338
- quote = undefined;
1339
- end = index;
1340
- continue;
1341
- }
1342
- if (char === "\\" && quote !== "'") {
1343
- const next = input[index + 1];
1344
- if (next === undefined)
1345
- return;
1346
- if (next === `
1347
- `) {
1348
- index++;
1349
- continue;
1350
- }
1351
- if (!quote || '$`"\\'.includes(next)) {
1352
- quoted = true;
1353
- started = true;
1354
- const escaped = input[++index];
1355
- if (dashDelimiter !== undefined)
1356
- dashDelimiter += escaped;
1357
- delimiter += escaped;
1358
- end = index;
1359
- continue;
1360
- }
1361
- }
1362
- if (!quote && (char === "'" || char === '"')) {
1363
- quote = char;
1364
- quoted = true;
1365
- started = true;
1366
- end = index;
1367
- continue;
1368
- }
1369
- if (dashDelimiter !== undefined)
1370
- dashDelimiter += char;
1371
- delimiter += char;
1372
- started = true;
1373
- end = index;
1374
- }
1375
- if (started && !quote)
1376
- return { delimiter, dashDelimiter, quoted, tabs, end };
1377
- }
1378
- function bashHeredoc(input, start, delimiter) {
1379
- const bodyStart = start;
1380
- let lineStart = start;
1381
- let line = "";
1382
- let backslashes = 0;
1383
- for (let index = start;index <= input.length; index++) {
1384
- if (index < input.length && input[index] !== `
1385
- `)
1386
- continue;
1387
- const text = delimiter.tabs && start === lineStart ? input.slice(start, index).replace(/^\t+/, "") : input.slice(start, index);
1388
- let run = 0;
1389
- while (text[text.length - 1 - run] === "\\")
1390
- run++;
1391
- backslashes = run === text.length ? backslashes + run : run;
1392
- const continued = !delimiter.quoted && backslashes % 2 === 1 && index < input.length;
1393
- const maxLength = Math.max(delimiter.delimiter.length, delimiter.dashDelimiter?.length ?? 0);
1394
- if (line.length <= maxLength)
1395
- line += continued ? text.slice(0, -1) : text;
1396
- if (continued) {
1397
- backslashes--;
1398
- start = index + 1;
1399
- continue;
1400
- }
1401
- if (delimiter.dashDelimiter !== undefined && line === delimiter.dashDelimiter)
1402
- return;
1403
- if (line === delimiter.delimiter) {
1404
- if (start > lineStart && input.slice(index + 1).includes(delimiter.delimiter))
1405
- return;
1406
- return { source: input.slice(bodyStart, lineStart), end: index };
1407
- }
1408
- line = "";
1409
- backslashes = 0;
1410
- start = index + 1;
1411
- lineStart = start;
1412
- }
1413
- }
1414
- function scanPowerShell(input) {
1415
- if (input.length > MAX_INPUT_LENGTH)
1416
- return { kind: "opaque", reason: "invalid-structure" };
1417
- if (/[\0\u0085\u2013-\u2015\u2018-\u201e\ufeff]/.test(input))
1418
- return { kind: "opaque", reason: "invalid-structure" };
1419
- const result = scanPowerShellList(input, 0, 0, { remaining: MAX_INPUT_LENGTH * MAX_SUBSTITUTION_DEPTH });
1420
- if (result.kind === "opaque")
1421
- return result;
1422
- return { kind: "scanned", commands: result.commands };
1423
- }
1424
- function scanPowerShellList(input, start, depth, budget, close, hash = false, skipped) {
1425
- if (depth >= MAX_SUBSTITUTION_DEPTH || budget.remaining < 0)
1426
- return { kind: "opaque", reason: "invalid-structure" };
1427
- const commands = [];
1428
- const nestedCommands = [];
1429
- const words = [];
1430
- const rawWords = [];
1431
- const wordEnds = [];
1432
- const initialExpression = hash === true || hash === "clause";
1433
- const initialClause = hash === "clause" || hash === "switch" ? "member" : undefined;
1434
- let segment = start;
1435
- let word = "";
1436
- let started = false;
1437
- let wordStart = start;
1438
- let quote;
1439
- let standalone = false;
1440
- let expression = initialExpression;
1441
- let clause = initialClause;
1442
- let after;
1443
- let indexable = false;
1444
- let stopParsing = false;
1445
- let commandEnd = start;
1446
- let statementHead = true;
1447
- let invalid = false;
1448
- let redirectTarget = false;
1449
- let dangling = false;
1450
- let invocation = false;
1451
- const finishWord = (end) => {
1452
- if (!started)
1453
- return;
1454
- if (word === "--%" && words.length > 0 && !expression && !clause && !redirectTarget && !/['"]/.test(input[wordStart]) && !rawWords.at(-1)?.endsWith(",") && !POWERSHELL_PARAMETER_COLON_RE.test(rawWords.at(-1) ?? ""))
1455
- stopParsing = true;
1456
- if (!redirectTarget) {
1457
- if (!words.length && !invocation && !expression)
1458
- segment = wordStart;
1459
- words.push(word);
1460
- rawWords.push(input.slice(wordStart, end));
1461
- wordEnds.push(end);
1462
- dangling = false;
1463
- }
1464
- commandEnd = end;
1465
- redirectTarget = false;
1466
- word = "";
1467
- started = false;
1468
- };
1469
- const finishCommand = (end, required = false) => {
1470
- finishWord(end);
1471
- if (words.length && !expression && !clause)
1472
- commands.push({
1473
- resource: input.slice(segment, commandEnd).trimEnd(),
1474
- words: [...words],
1475
- rawWords: [...rawWords],
1476
- wordEnds: wordEnds.map((value) => value - segment),
1477
- ...statementHead && !invocation ? { statementHead: true } : {}
1478
- });
1479
- else if (!expression && !clause && invocation || required && !words.length && !nestedCommands.length || clause !== undefined && clause !== "member")
1480
- invalid = true;
1481
- if (redirectTarget)
1482
- invalid = true;
1483
- commands.push(...nestedCommands.splice(0));
1484
- words.length = 0;
1485
- rawWords.length = 0;
1486
- wordEnds.length = 0;
1487
- redirectTarget = false;
1488
- invocation = false;
1489
- expression = initialExpression;
1490
- clause = initialClause;
1491
- after = undefined;
1492
- indexable = false;
1493
- stopParsing = false;
1494
- };
1495
- let index = start;
1496
- for (;index < input.length; index++) {
1497
- if (--budget.remaining < 0)
1498
- return { kind: "opaque", reason: "invalid-structure" };
1499
- if (skipped?.has(index))
1500
- continue;
1501
- const char = input[index];
1502
- const inExpression = expression && !redirectTarget;
1503
- const atBoundary = !started || !inExpression && word.endsWith(",");
1504
- if (!started)
1505
- wordStart = index;
1506
- if (stopParsing) {
1507
- const stop = powerShellStopParsing(input, index, skipped);
1508
- const text = input.slice(index, stop).trim();
1509
- if (text) {
1510
- wordStart = index + input.slice(index, stop).search(/\S/);
1511
- word = text;
1512
- started = true;
1513
- finishWord(wordStart + text.length);
1514
- }
1515
- stopParsing = false;
1516
- index = stop - 1;
1517
- continue;
1518
- }
1519
- if (quote) {
1520
- let nextQuote = index + 1;
1521
- while (skipped?.has(nextQuote))
1522
- nextQuote++;
1523
- if (char === quote && input[nextQuote] === quote) {
1524
- word += quote;
1525
- index = nextQuote;
1526
- } else if (char === quote) {
1527
- quote = undefined;
1528
- if (standalone) {
1529
- finishWord(index + 1);
1530
- indexable = "closed";
1531
- }
1532
- } else if (quote === '"' && char === "`") {
1533
- const escape = powerShellEscape(input, index, false, skipped);
1534
- if (!escape)
1535
- return { kind: "opaque", reason: "unterminated-escape" };
1536
- word += escape.value;
1537
- index = escape.end;
1538
- } else if (quote === '"' && char === "$" && input[index + 1] === "{") {
1539
- const end = powerShellBracedVariable(input, index, skipped);
1540
- if (end === undefined)
1541
- return { kind: "opaque", reason: "invalid-structure" };
1542
- word += input.slice(index, end + 1);
1543
- index = end;
1544
- } else if (quote === '"' && char === "$" && input[index + 1] === "(") {
1545
- const sub = powerShellSubExpression(input, index + 2, false, budget, skipped);
1546
- if (!sub)
1547
- return { kind: "opaque", reason: "invalid-structure" };
1548
- const result = scanPowerShellList(input, index + 2, depth + 1, budget, ")", false, sub.skipped);
1549
- if (result.kind === "opaque")
1550
- return result;
1551
- nestedCommands.push(...result.commands);
1552
- const end = sub.rawEnd !== undefined && sub.rawEnd > result.end ? sub.rawEnd : result.end;
1553
- word += input.slice(index, end + 1);
1554
- index = end;
1555
- } else
1556
- word += char;
1557
- continue;
1558
- }
1559
- if (char === "'" || char === '"') {
1560
- if (!started && words.length === 0 && !invocation)
1561
- expression = true;
1562
- quote = char;
1563
- standalone = atBoundary || expression && !redirectTarget || indexable === "member" && /[.:]$/.test(word);
1564
- if (!standalone)
1565
- indexable = false;
1566
- started = true;
1567
- continue;
1568
- }
1569
- if (char === "`") {
1570
- const escape = powerShellEscape(input, index, atBoundary || inExpression, skipped);
1571
- if (!escape)
1572
- return { kind: "opaque", reason: "unterminated-escape" };
1573
- const rawSpace = /\s/.test(input[index + 1] ?? "");
1574
- if ((inExpression || atBoundary) && started && rawSpace)
1575
- finishWord(index);
1576
- else if (!atBoundary || !rawSpace) {
1577
- started = true;
1578
- indexable = false;
1579
- word += escape.value;
1580
- }
1581
- index = escape.end;
1582
- continue;
1583
- }
1584
- if (!started && words.length > 0 && !expression && !clause && !redirectTarget && testAt(POWERSHELL_STOP_PARSING_RE, input, index)) {
1585
- word = "--%";
1586
- started = true;
1587
- finishWord(index + 3);
1588
- index += 2;
1589
- continue;
1590
- }
1591
- if (char === "<" && input[index + 1] === "#" && (atBoundary || inExpression || indexable === "member")) {
1592
- const memberOperator = indexable === "member" && /[.:]$/.test(started ? word : words.at(-1) ?? "");
1593
- if (started)
1594
- finishWord(index);
1595
- const end = input.indexOf("#>", index + 2);
1596
- if (end < 0)
1597
- return { kind: "opaque", reason: "invalid-structure" };
1598
- if (!memberOperator)
1599
- indexable = false;
1600
- index = end + 1;
1601
- continue;
1602
- }
1603
- if (char === "#" && (atBoundary || indexable === "member" || inExpression && !(close === "]" && /^[\p{L}\p{Nl}_][\p{L}\p{Nl}\d_.#+`\\]*$/u.test(word)))) {
1604
- const prev = started ? word : words.at(-1) ?? "";
1605
- const memberOperator = indexable === "member" && /[.:]$/.test(prev);
1606
- if (clause && clause !== "member" || prev.endsWith(",") || memberOperator)
1607
- finishWord(index);
1608
- else if (words.length || started || invocation)
1609
- finishCommand(index);
1610
- statementHead = !dangling;
1611
- const endings = [input.indexOf(`
1612
- `, index), input.indexOf("\r", index)].filter((ending) => ending >= 0);
1613
- const newline = endings.length > 0 ? Math.min(...endings) : -1;
1614
- if (newline === -1) {
1615
- index = input.length;
1616
- break;
1617
- }
1618
- index = input[newline] === "\r" && input[newline + 1] === `
1619
- ` ? newline + 1 : newline;
1620
- continue;
1621
- }
1622
- if (inExpression && started && (char === ">" || char === "*" && input[index + 1] === ">"))
1623
- finishWord(index);
1624
- const redirect = !started && (char === ">" || char === "*" || /\d/.test(char) && (words.length > 0 || testAt(POWERSHELL_MERGE_REDIRECT_RE, input, index))) ? powerShellRedirect(input, index) : undefined;
1625
- if (redirect === false)
1626
- return { kind: "opaque", reason: "invalid-redirect" };
1627
- if (redirect) {
1628
- if (redirectTarget || words.length === 0 || clause && clause !== "member")
1629
- return { kind: "opaque", reason: "invalid-redirect" };
1630
- redirectTarget = !redirect.includes("&");
1631
- indexable = false;
1632
- index += redirect.length - 1;
1633
- commandEnd = index + 1;
1634
- continue;
1635
- }
1636
- if (!started && !words.length && !invocation && !expression && !clause && char === ":") {
1637
- const label = matchAt(POWERSHELL_LABEL_RE, input, index);
1638
- if (label) {
1639
- index += label[0].length - 1;
1640
- continue;
1641
- }
1642
- }
1643
- if (!started && !invocation && !clause && (!words.length ? !expression : words.every((item) => item.startsWith("["))) && /[A-Za-z]/.test(char)) {
1644
- const keyword = matchAt(POWERSHELL_KEYWORD_RE, input, index)?.[0]?.toLowerCase();
1645
- if (keyword && (words.length > 0 ? keyword === "param" && testAt(POWERSHELL_PARAM_RE, input, index) || keyword === "class" || keyword === "enum" : keyword === "param" && testAt(POWERSHELL_PARAM_RE, input, index) || keyword === "foreach" && testAt(POWERSHELL_FOREACH_RE, input, index) || keyword === "until" && after === "do" || (keyword === "else" || keyword === "elseif") && after === "if" || (keyword === "catch" || keyword === "finally") && after === "try" || /^(?:if|for|while|do|switch|function|filter|workflow|parallel|sequence|configuration|try|begin|process|end|clean|trap|class|enum|data|dynamicparam|using|break|continue)$/.test(keyword))) {
1646
- expression = /^(?:class|enum|break|continue)$/.test(keyword);
1647
- clause = keyword === "using" || keyword === "break" || keyword === "continue" ? "member" : keyword === "param" || keyword === "until" || keyword === "while" && after === "do" ? "paren" : keyword === "do" ? "do" : keyword === "if" || keyword === "elseif" ? "if" : keyword === "try" || keyword === "catch" ? "try" : keyword === "switch" ? "switch" : keyword === "class" || keyword === "enum" ? "clause" : "block";
1648
- after = undefined;
1649
- index += keyword.length - 1;
1650
- continue;
1651
- }
1652
- if (!words.length && keyword && /^(?:return|throw|exit)$/.test(keyword)) {
1653
- after = undefined;
1654
- index += keyword.length - 1;
1655
- continue;
1656
- }
1657
- }
1658
- const assign = inExpression && !clause && (char === "=" || /[-+*/%]/.test(char) && input[index + 1] === "=");
1659
- if (assign || inExpression && close === ")" && !started && testAt(POWERSHELL_IN_RE, input, index)) {
1660
- if (assign)
1661
- finishWord(index);
1662
- words.length = 0;
1663
- rawWords.length = 0;
1664
- wordEnds.length = 0;
1665
- expression = false;
1666
- indexable = false;
1667
- if (!assign || char !== "=")
1668
- index++;
1669
- continue;
1670
- }
1671
- if (atBoundary && char === "@" && !testAt(POWERSHELL_AT_OPENER_RE, input, index + 1))
1672
- return { kind: "opaque", reason: "invalid-structure" };
1673
- if (atBoundary && char === "@" && (input[index + 1] === "'" || input[index + 1] === '"')) {
1674
- if (started)
1675
- finishWord(index);
1676
- wordStart = index;
1677
- const literal = powerShellHereString(input, index, depth, budget, skipped);
1678
- if (literal.kind === "opaque")
1679
- return literal;
1680
- if (!words.length && !invocation)
1681
- expression = true;
1682
- nestedCommands.push(...literal.commands);
1683
- word = literal.source;
1684
- started = true;
1685
- index = literal.end;
1686
- finishWord(index + 1);
1687
- indexable = "closed";
1688
- continue;
1689
- }
1690
- if (char === "$" && input[index + 1] === "{") {
1691
- const end = powerShellBracedVariable(input, index, skipped);
1692
- if (end === undefined)
1693
- return { kind: "opaque", reason: "invalid-structure" };
1694
- if (!started && !words.length && !invocation && hash !== "switch")
1695
- expression = true;
1696
- indexable = atBoundary || indexable === "member" && /[.:]$/.test(word) ? "closed" : false;
1697
- word += input.slice(index, end + 1);
1698
- started = true;
1699
- index = end;
1700
- if (expression && !redirectTarget && input[index + 1] !== "[")
1701
- finishWord(index + 1);
1702
- continue;
1703
- }
1704
- const opener = (char === "$" || atBoundary && char === "@") && input[index + 1] === "(" ? index + 1 : atBoundary && char === "@" && input[index + 1] === "{" ? index + 1 : char === "(" || char === "{" || char === "[" && (inExpression || Boolean(indexable) || !started && !invocation && (!words.length || clause === "block" || clause === "try")) ? index : undefined;
1705
- if (opener !== undefined) {
1706
- const openChar = input[opener];
1707
- const standaloneBlock = atBoundary || inExpression || char === "(" || openChar === "{";
1708
- const blockClose = openChar === "(" ? ")" : openChar === "[" ? "]" : "}";
1709
- const blockHash = openChar === "[" ? true : char === "@" && openChar === "{" ? true : clause === "switch" && openChar === "{" ? "switch" : clause === "clause" && openChar === "{" ? "clause" : close === "]" && char === "(" && started ? "clause" : false;
1710
- if (started && (char === "{" || char === "(" || char === "@" && atBoundary)) {
1711
- finishWord(index);
1712
- if (stopParsing) {
1713
- index--;
1714
- continue;
1715
- }
1716
- wordStart = index;
1717
- }
1718
- if (!started && !words.length && !invocation)
1719
- expression = true;
1720
- const result = scanPowerShellList(input, opener + 1, depth + 1, budget, blockClose, blockHash, skipped);
1721
- if (result.kind === "opaque")
1722
- return result;
1723
- nestedCommands.push(...result.commands);
1724
- started = true;
1725
- word += input.slice(index, result.end + 1);
1726
- index = result.end;
1727
- if (openChar === "[") {
1728
- indexable = "closed";
1729
- if (input[index + 1] !== "[")
1730
- finishWord(index + 1);
1731
- } else if (standaloneBlock) {
1732
- finishWord(index + 1);
1733
- indexable = "closed";
1734
- }
1735
- if (clause === "paren" && char === "(" || clause && clause !== "paren" && char === "{") {
1736
- const completed = clause === "do" || clause === "if" || clause === "try" ? clause : undefined;
1737
- clause = "member";
1738
- finishCommand(index + 1);
1739
- after = completed;
1740
- }
1741
- continue;
1742
- }
1743
- if (char === close)
1744
- break;
1745
- if (char === "}" || char === ")" || char === "]" && inExpression)
1746
- return { kind: "opaque", reason: "invalid-structure" };
1747
- if (!started && words.length === 0 && (char === "&" && input[index + 1] !== "&" || char === "." && (!input[index + 1] || /[\s"'$(),;{|}&]/.test(input[index + 1])))) {
1748
- if (invocation)
1749
- return { kind: "opaque", reason: "invalid-structure" };
1750
- segment = index;
1751
- invocation = true;
1752
- after = undefined;
1753
- continue;
1754
- }
1755
- if (/\s/.test(char) && char !== `
1756
- ` && char !== "\r") {
1757
- finishWord(index);
1758
- indexable = false;
1759
- continue;
1760
- }
1761
- const next = input[index + 1];
1762
- const separator = char === "\r" && next === `
1763
- ` ? char + next : char === "&" && next === "&" || char === "|" && next === "|" ? char + next : char === ";" || char === "|" || char === "&" || char === `
1764
- ` || char === "\r" ? char : undefined;
1765
- if (separator) {
1766
- if (close === "]" && (separator === ";" || separator === "|" || separator === "||" || separator === "&&" || separator === "&"))
1767
- return { kind: "opaque", reason: "invalid-structure" };
1768
- if (separator === `
1769
- ` || separator === "\r" || separator === `\r
1770
- `) {
1771
- const prev = started ? word : words.at(-1) ?? "";
1772
- const memberOperator = indexable === "member" && /[.:]$/.test(prev);
1773
- if (clause && clause !== "member" || prev.endsWith(",") || memberOperator) {
1774
- finishWord(index);
1775
- index += separator.length - 1;
1776
- if (!memberOperator)
1777
- indexable = false;
1778
- continue;
1779
- }
1780
- if (!started && !words.length && !invocation) {
1781
- index += separator.length - 1;
1782
- indexable = false;
1783
- continue;
1784
- }
1785
- }
1786
- finishCommand(index, dangling || ![";", `
1787
- `, "\r", `\r
1788
- `].includes(separator));
1789
- dangling = ![";", "&", `
1790
- `, "\r", `\r
1791
- `].includes(separator);
1792
- statementHead = !dangling;
1793
- index += separator.length - 1;
1794
- continue;
1795
- }
1796
- if (!started && !words.length && !invocation && hash !== "switch" && testAt(POWERSHELL_EXPRESSION_RE, input, index))
1797
- expression = true;
1798
- if ((atBoundary || indexable === "member" && /[.:]$/.test(word)) && char === "$")
1799
- indexable = testAt(POWERSHELL_INDEXABLE_VAR_RE, input, index + 1) ? "variable" : false;
1800
- else if (indexable === "closed")
1801
- indexable = char === "." && input[index + 1] !== "." && !/\s/.test(input[index + 1] ?? "") || !started && char === ":" && input[index + 1] === ":" && !/\s/.test(input[index + 2] ?? "") || !started && char === "?" && input[index + 1] === "." && input[index + 2] !== "." && !/\s/.test(input[index + 2] ?? "") ? "member" : !started && char === "?" && input[index + 1] === "[" ? "closed" : false;
1802
- else if (indexable === "variable")
1803
- indexable = char === "." && input[index + 1] !== "." && !/\s/.test(input[index + 1] ?? "") || char === ":" && input[index + 1] === ":" && !/\s/.test(input[index + 2] ?? "") ? "member" : char === "." && input[index + 1] === "." || !/[\p{L}\p{Nl}\d_:?]/u.test(char) ? false : "variable";
1804
- else if (indexable === "member")
1805
- indexable = char === "." && input[index + 1] === "." ? false : char === "." && !/\s/.test(input[index + 1] ?? "") || char === ":" && (input[index + 1] === ":" || input[index - 1] === ":") || char === "?" && input[index + 1] === "." && input[index + 2] !== "." || /[\p{L}\p{Nl}\d_]/u.test(char) ? "member" : false;
1806
- after = undefined;
1807
- started = true;
1808
- dangling = false;
1809
- word += char;
1810
- }
1811
- if (close !== undefined && input[index] !== close)
1812
- return { kind: "opaque", reason: "invalid-structure" };
1813
- if (quote)
1814
- return { kind: "opaque", reason: "unterminated-quote" };
1815
- finishCommand(index);
1816
- if (redirectTarget || invalid || dangling)
1817
- return { kind: "opaque", reason: "invalid-structure" };
1818
- if (commands.some((command) => !command.words[0]))
1819
- return { kind: "opaque", reason: "dynamic-command-name" };
1820
- return { kind: "scanned", commands, end: index };
1821
- }
1822
- var POWERSHELL_STOP_PARSING_RE = /--%(?=$|[\s;|&(){}])/y;
1823
- var POWERSHELL_PARAMETER_COLON_RE = /^-[\p{L}\p{Nl}_?][\p{L}\p{Nl}\d_?-]*:$/u;
1824
- var POWERSHELL_MERGE_REDIRECT_RE = /\d>&/y;
1825
- var POWERSHELL_LABEL_RE = /:[A-Za-z_]\w*(?=\s*(?:while|for|foreach|do|switch)(?=$|[\s&(),;{|}]))/iy;
1826
- var POWERSHELL_KEYWORD_RE = /[A-Za-z]+(?=$|[\s&(),;{|}])/y;
1827
- var POWERSHELL_FOREACH_RE = /foreach\s*\(/isy;
1828
- var POWERSHELL_PARAM_RE = /param\s*\(/isy;
1829
- var POWERSHELL_IN_RE = /in(?=$|[\s&(),;{|}])/iy;
1830
- var POWERSHELL_AT_OPENER_RE = /[({'"\p{L}\p{Nl}\d_?]/uy;
1831
- var POWERSHELL_INDEXABLE_VAR_RE = /(?::[\p{L}\p{Nl}\d_?]+|[\p{L}\p{Nl}\d_][\p{L}\p{Nl}\d_?]*)/uy;
1832
- var POWERSHELL_HERE_HEADER_RE = /@['"][^\S\r\n]*(?:\r\n|\r|\n)/y;
1833
- var POWERSHELL_UNICODE_ESCAPE_RE = /u\{([0-9a-f]{1,6})\}/iy;
1834
- var POWERSHELL_EXPRESSION_RE = /(?:!*(?:\+\+|--|[+-])?\$(?:\{|(?:\?|\$|\^)(?=$|[\s;|&(){},#>])|:[\p{L}\p{Nl}\d_?]+|[\p{L}\p{Nl}\d_][\p{L}\p{Nl}\d_?]*(?::[\p{L}\p{Nl}\d_?]+)?)|!(?![\p{L}\p{Nl}_.\d])|\+(?![=\p{L}\p{Nl}_.\d])|--(?!=)|-(?![=\p{L}\p{Nl}\d_?.])|,(?!\s*$)|!*[+-]?(?:0[xX][\da-fA-F]+|0[bB][01]+|(?:\d+(?:\.(?!\.)\d*|(?!\.(?!\.)))|\.\d+)(?:[eE][+-]?\d+)?)(?:[dDlLnN]|[uU][sSyYlL]?|[sSyY])?(?:[kKmMgGtTpP][bB])?(?=$|[\s!#%&()*+,\-/.;<=>\]|{}])|-(?:not|bnot|join|[ic]?split)(?![\p{L}\p{Nl}]))/iuy;
1835
- var POWERSHELL_ESCAPES = {
1836
- "0": "\x00",
1837
- a: "\x07",
1838
- b: "\b",
1839
- e: "\x1B",
1840
- f: "\f",
1841
- n: `
1842
- `,
1843
- r: "\r",
1844
- t: "\t",
1845
- v: "\v"
1846
- };
1847
- function matchAt(regex, input, index) {
1848
- regex.lastIndex = index;
1849
- return regex.exec(input);
1850
- }
1851
- function testAt(regex, input, index) {
1852
- regex.lastIndex = index;
1853
- return regex.test(input);
1854
- }
1855
- function powerShellEscape(input, start, lineContinuation = false, skipped) {
1856
- let next = start + 1;
1857
- while (skipped?.has(next))
1858
- next++;
1859
- const char = input[next];
1860
- if (char === undefined)
1861
- return;
1862
- if (char === "\r" || char === `
1863
- `)
1864
- return {
1865
- value: lineContinuation && char === "\r" && input[next + 1] === `
1866
- ` ? `\r
1867
- ` : char,
1868
- end: next + (lineContinuation && char === "\r" && input[next + 1] === `
1869
- ` ? 1 : 0)
1870
- };
1871
- if (char === "u" && input[next + 1] === "{") {
1872
- const code = matchAt(POWERSHELL_UNICODE_ESCAPE_RE, input, next);
1873
- if (!code || Number.parseInt(code[1], 16) > 1114111)
1874
- return;
1875
- return { value: String.fromCodePoint(Number.parseInt(code[1], 16)), end: next + code[0].length - 1 };
1876
- }
1877
- return { value: POWERSHELL_ESCAPES[char] ?? char, end: next };
1878
- }
1879
- function powerShellBracedVariable(input, start, skipped) {
1880
- for (let index = start + 2;index < input.length; index++) {
1881
- if (skipped?.has(index))
1882
- continue;
1883
- if (input[index] === "`") {
1884
- const escape = powerShellEscape(input, index, false, skipped);
1885
- if (!escape)
1886
- return;
1887
- index = escape.end;
1888
- continue;
1889
- }
1890
- if (input[index] === "}")
1891
- return index > start + 2 ? index : undefined;
1892
- }
1893
- }
1894
- function powerShellSubExpression(input, start, hereString, budget, skipped) {
1895
- const nextSkipped = new Set(skipped);
1896
- let depth = 1;
1897
- let rawEnd;
1898
- for (let index = start;index < input.length; index++) {
1899
- if (--budget.remaining < 0)
1900
- return;
1901
- if (nextSkipped.has(index))
1902
- continue;
1903
- const char = input[index];
1904
- if (char === "(")
1905
- depth++;
1906
- else if (char === ")") {
1907
- if (--depth === 0 && rawEnd === undefined)
1908
- rawEnd = index;
1909
- } else if (!hereString && (char === '"' || char === "`")) {
1910
- let next = index + 1;
1911
- while (nextSkipped.has(next))
1912
- next++;
1913
- if (input[next] === '"') {
1914
- nextSkipped.add(index);
1915
- index = next;
1916
- }
1917
- }
1918
- }
1919
- return { skipped: nextSkipped, rawEnd };
1920
- }
1921
- function powerShellStopParsing(input, start, skipped) {
1922
- let quoted = false;
1923
- for (let index = start;index < input.length; index++) {
1924
- if (skipped?.has(index))
1925
- continue;
1926
- if (input[index] === '"')
1927
- quoted = !quoted;
1928
- if (input[index] === "\r" || input[index] === `
1929
- ` || (input[index] === "|" || input[index] === "&" && input[index + 1] === "&") && !quoted)
1930
- return index;
1931
- }
1932
- return input.length;
1933
- }
1934
- function powerShellHereString(input, start, depth, budget, skipped) {
1935
- const header = matchAt(POWERSHELL_HERE_HEADER_RE, input, start);
1936
- if (!header)
1937
- return { kind: "opaque", reason: "unterminated-quote" };
1938
- const quote = input[start + 1];
1939
- const body = start + header[0].length;
1940
- const commands = [];
1941
- let lineStart = true;
1942
- for (let index = body;index < input.length; index++) {
1943
- if (--budget.remaining < 0)
1944
- return { kind: "opaque", reason: "invalid-structure" };
1945
- if (skipped?.has(index))
1946
- continue;
1947
- if (lineStart && input[index] === quote && input[index + 1] === "@") {
1948
- const end = index > body && input[index - 1] === `
1949
- ` && input[index - 2] === "\r" ? index - 2 : index > body ? index - 1 : index;
1950
- return { kind: "scanned", commands, source: input.slice(body, end), end: index + 1 };
1951
- }
1952
- if (quote === '"') {
1953
- if (input[index] === "`") {
1954
- const escape = powerShellEscape(input, index, false, skipped);
1955
- if (!escape)
1956
- return { kind: "opaque", reason: "unterminated-escape" };
1957
- index = escape.end;
1958
- lineStart = false;
1959
- continue;
1960
- }
1961
- if (input[index] === "$" && input[index + 1] === "{") {
1962
- const end = powerShellBracedVariable(input, index, skipped);
1963
- if (end === undefined)
1964
- return { kind: "opaque", reason: "invalid-structure" };
1965
- index = end;
1966
- lineStart = false;
1967
- continue;
1968
- }
1969
- if (input[index] === "$" && input[index + 1] === "(") {
1970
- const sub = powerShellSubExpression(input, index + 2, true, budget, skipped);
1971
- if (!sub)
1972
- return { kind: "opaque", reason: "invalid-structure" };
1973
- const result = scanPowerShellList(input, index + 2, depth + 1, budget, ")", false, sub.skipped);
1974
- if (result.kind === "opaque")
1975
- return result;
1976
- commands.push(...result.commands);
1977
- index = sub.rawEnd !== undefined && sub.rawEnd > result.end ? sub.rawEnd : result.end;
1978
- lineStart = false;
1979
- continue;
1980
- }
1981
- }
1982
- lineStart = input[index] === "\r" || input[index] === `
1983
- `;
1984
- }
1985
- return { kind: "opaque", reason: "unterminated-quote" };
1986
- }
1987
- function powerShellRedirect(input, index) {
1988
- let cursor = index;
1989
- if (input[cursor] === "*")
1990
- cursor++;
1991
- else
1992
- while (/\d/.test(input[cursor] ?? ""))
1993
- cursor++;
1994
- if (input[cursor] !== ">")
1995
- return;
1996
- cursor++;
1997
- if (input[cursor] === ">")
1998
- cursor++;
1999
- if (input[cursor] === "&") {
2000
- cursor++;
2001
- while (/\d/.test(input[cursor] ?? ""))
2002
- cursor++;
2003
- }
2004
- const redirect = input.slice(index, cursor);
2005
- return /^(?:(?:[1-6]|\*)?>>?|[2-6*]>&1)$/.test(redirect) ? redirect : false;
2006
- }
2
+ scan4,
3
+ scanPowerShell2,
4
+ exports_scan
5
+ } from "../chunks/bus-c078hgae.js";
2007
6
  export {
2008
7
  exports_scan as ShellScan,
2009
- scan,
2010
- scanPowerShell
8
+ scan4 as scan,
9
+ scanPowerShell2 as scanPowerShell
2011
10
  };