@qitqode/qitqode-android-arm64 0.1.24 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/bundle/{chunk-4kse3awh.js → chunk-0304b7xg.js} +1 -1
  2. package/bundle/{chunk-hqg5qbxk.js → chunk-08ba67f4.js} +1 -1
  3. package/bundle/chunk-0eneddjj.js +2 -0
  4. package/bundle/{chunk-6nhje520.js → chunk-0hsb4knd.js} +1 -1
  5. package/bundle/{chunk-bas6x25m.js → chunk-0jaxgrq0.js} +2 -2
  6. package/bundle/chunk-0ke6x10y.js +5 -0
  7. package/bundle/{chunk-hh4c02fh.js → chunk-0rmmg3g4.js} +1 -1
  8. package/bundle/chunk-0vqrakhw.js +3 -0
  9. package/bundle/{chunk-sgtgvzv6.js → chunk-0x7dbj5e.js} +1 -1
  10. package/bundle/{chunk-7yf15a3a.js → chunk-0xmx2zfg.js} +1 -1
  11. package/bundle/chunk-0yb4pxjv.js +2 -0
  12. package/bundle/chunk-129kq1w7.js +2 -0
  13. package/bundle/{chunk-8cr7ks31.js → chunk-14qvaxtp.js} +1 -1
  14. package/bundle/chunk-1a5hq7d5.js +2 -0
  15. package/bundle/{chunk-k16hzy2q.js → chunk-1ce5jpdc.js} +1 -1
  16. package/bundle/{chunk-xv8gnkh5.js → chunk-1e8mja6v.js} +1 -1
  17. package/bundle/{chunk-cy2586rv.js → chunk-1n1dh6zj.js} +1 -1
  18. package/bundle/{chunk-pb7rnkke.js → chunk-1txkz6dt.js} +1 -1
  19. package/bundle/chunk-1w3y1dkk.js +2 -0
  20. package/bundle/{chunk-v7r9np94.js → chunk-23f6rc7a.js} +1 -1
  21. package/bundle/chunk-26qt44f1.js +3 -0
  22. package/bundle/{chunk-6mscvf6y.js → chunk-2armxd20.js} +1 -1
  23. package/bundle/{chunk-21ejqv4v.js → chunk-2je5tp0x.js} +1 -1
  24. package/bundle/{chunk-0rtshz2r.js → chunk-2k2axg73.js} +1 -1
  25. package/bundle/chunk-2pkake0h.js +2 -0
  26. package/bundle/{chunk-7y3y3j51.js → chunk-2rxt1s22.js} +2 -2
  27. package/bundle/{chunk-te1zfpzv.js → chunk-2s28fdbp.js} +1 -1
  28. package/bundle/{chunk-8pe047p0.js → chunk-2sy1wx99.js} +1 -1
  29. package/bundle/{chunk-9easaxy7.js → chunk-2z35ewwc.js} +1 -1
  30. package/bundle/{chunk-zeh481tm.js → chunk-2zj3h3xj.js} +2 -2
  31. package/bundle/chunk-32188rww.js +2 -0
  32. package/bundle/chunk-334tc1rh.js +2 -0
  33. package/bundle/{chunk-tzc4jkzg.js → chunk-3dvyfmgc.js} +1 -1
  34. package/bundle/{chunk-q3x4x2tq.js → chunk-3e8p4a3y.js} +1 -1
  35. package/bundle/{chunk-7mhffm9f.js → chunk-3f054f69.js} +183 -183
  36. package/bundle/chunk-3ff94m8r.js +2 -0
  37. package/bundle/{chunk-7a6p7dfx.js → chunk-3fy57jcy.js} +1 -1
  38. package/bundle/{chunk-ve5gb789.js → chunk-3h08jdq8.js} +2 -2
  39. package/bundle/{chunk-w7p2x973.js → chunk-3j7skhxg.js} +2 -2
  40. package/bundle/{chunk-p4hpr8d7.js → chunk-3jhx8g5d.js} +1 -1
  41. package/bundle/{chunk-jr9xnvjq.js → chunk-3nhth7c2.js} +1 -1
  42. package/bundle/{chunk-8ace31r2.js → chunk-3tnek022.js} +1 -1
  43. package/bundle/{chunk-rvvfs9ps.js → chunk-3xna2rk5.js} +1 -1
  44. package/bundle/{chunk-k9d927xe.js → chunk-42t25nkb.js} +1 -1
  45. package/bundle/chunk-4aqd2bty.js +2 -0
  46. package/bundle/{chunk-am73j1bt.js → chunk-4kb2efq3.js} +1 -1
  47. package/bundle/{chunk-wmw2gne9.js → chunk-4pssh5d3.js} +2 -2
  48. package/bundle/{chunk-pyq01301.js → chunk-4stgw33j.js} +1 -1
  49. package/bundle/{chunk-k9g77a02.js → chunk-4w5t515p.js} +1 -1
  50. package/bundle/chunk-4wa0gf8y.js +28 -0
  51. package/bundle/{chunk-jegn6jc3.js → chunk-4wgb80jm.js} +2 -2
  52. package/bundle/{chunk-jbd9k041.js → chunk-4wyjapes.js} +2 -2
  53. package/bundle/chunk-4xg5ptk9.js +2 -0
  54. package/bundle/{chunk-23geekk5.js → chunk-54pk7nna.js} +1 -1
  55. package/bundle/chunk-58680z2j.js +3 -0
  56. package/bundle/{chunk-ygj1cy0n.js → chunk-5mdsrv0a.js} +1 -1
  57. package/bundle/{chunk-xj73j10a.js → chunk-5mp82az0.js} +1 -1
  58. package/bundle/chunk-5nm36wxa.js +2 -0
  59. package/bundle/{chunk-7tgm8wp5.js → chunk-5zw7knvd.js} +1 -1
  60. package/bundle/{chunk-yz7rqzby.js → chunk-61ks7c71.js} +3 -3
  61. package/bundle/chunk-64jet8nc.js +2 -0
  62. package/bundle/chunk-6584d9m8.js +2 -0
  63. package/bundle/chunk-66hv9bbw.js +2 -0
  64. package/bundle/{chunk-mj24ntn9.js → chunk-692vn48b.js} +1 -1
  65. package/bundle/chunk-6a1g6jzn.js +2 -0
  66. package/bundle/chunk-6be8p915.js +2 -0
  67. package/bundle/{chunk-8651hq0k.js → chunk-6ddp36ar.js} +1 -1
  68. package/bundle/chunk-6f03158n.js +2 -0
  69. package/bundle/{chunk-zavtsfxz.js → chunk-6gbaw2pk.js} +1 -1
  70. package/bundle/{chunk-5h2hcp46.js → chunk-6rrmjrm2.js} +1 -1
  71. package/bundle/{chunk-ps543k72.js → chunk-6s2f5sv4.js} +1 -1
  72. package/bundle/{chunk-9jf67xb0.js → chunk-754varfr.js} +2 -2
  73. package/bundle/{chunk-wa2ce2sg.js → chunk-78h5dd4t.js} +2 -2
  74. package/bundle/{chunk-4d1a547n.js → chunk-7d6jhzng.js} +1 -1
  75. package/bundle/{chunk-kc3hpmr2.js → chunk-7fx6x8x9.js} +2 -2
  76. package/bundle/chunk-7jnjttqx.js +2 -0
  77. package/bundle/{chunk-jz3aav8a.js → chunk-7q5srx7q.js} +2 -2
  78. package/bundle/chunk-7q8pa6s8.js +2 -0
  79. package/bundle/{chunk-vvypb02q.js → chunk-7qvkyjjg.js} +1 -1
  80. package/bundle/{chunk-8r79zf3y.js → chunk-7rjf9b8n.js} +2 -2
  81. package/bundle/{chunk-t488d66k.js → chunk-7v4fzkbb.js} +1 -1
  82. package/bundle/chunk-7w84hfxs.js +3 -0
  83. package/bundle/{chunk-8717htya.js → chunk-7ws3gdjq.js} +1 -1
  84. package/bundle/{chunk-va4davgy.js → chunk-87x607rz.js} +259 -253
  85. package/bundle/{chunk-vftqwdpg.js → chunk-8ahpk8td.js} +1 -1
  86. package/bundle/{chunk-9vcw33dv.js → chunk-8atry88r.js} +1 -1
  87. package/bundle/chunk-8casywce.js +2 -0
  88. package/bundle/{chunk-tsn1jkr7.js → chunk-8cty50g7.js} +1 -1
  89. package/bundle/{chunk-qywwj58s.js → chunk-8gy99gfb.js} +2 -2
  90. package/bundle/chunk-8hxwxt5p.js +2 -0
  91. package/bundle/{chunk-58enbars.js → chunk-8jcx4tep.js} +2 -2
  92. package/bundle/chunk-8y8140dm.js +2 -0
  93. package/bundle/{chunk-frdc3ysq.js → chunk-8za87zkr.js} +1 -1
  94. package/bundle/{chunk-2qcndbxv.js → chunk-99p5m2f1.js} +1 -1
  95. package/bundle/{chunk-y3n31nnx.js → chunk-9dpn4792.js} +2 -2
  96. package/bundle/chunk-9dqcyt6x.js +2 -0
  97. package/bundle/{chunk-7gczzccz.js → chunk-9f6pqped.js} +1 -1
  98. package/bundle/chunk-9he248a8.js +2 -0
  99. package/bundle/{chunk-8h9r6c8g.js → chunk-9jncnqbj.js} +2 -2
  100. package/bundle/{chunk-cvchztkc.js → chunk-9jvnc14g.js} +1 -1
  101. package/bundle/chunk-9qmmse2n.js +2 -0
  102. package/bundle/chunk-9r6bvkp4.js +8 -0
  103. package/bundle/{chunk-dkv2mg97.js → chunk-9va5eh9s.js} +1 -1
  104. package/bundle/{chunk-hg563h5r.js → chunk-9w5rx0fb.js} +2 -2
  105. package/bundle/{chunk-xccs5c50.js → chunk-a27yjp71.js} +1 -1
  106. package/bundle/chunk-aabrsxrq.js +2 -0
  107. package/bundle/{chunk-dkm7x8rj.js → chunk-ag9thqkv.js} +2 -2
  108. package/bundle/chunk-amx3x4kd.js +3 -0
  109. package/bundle/{chunk-ktmazmas.js → chunk-aqm597px.js} +2 -2
  110. package/bundle/chunk-atd0q4v8.js +3 -0
  111. package/bundle/{chunk-ewyk4py6.js → chunk-av290sja.js} +1 -1
  112. package/bundle/chunk-avaba4sr.js +2 -0
  113. package/bundle/{chunk-dgzyn27r.js → chunk-aw0q4y3s.js} +1 -1
  114. package/bundle/{chunk-4k149ews.js → chunk-b2xya6pq.js} +1 -1
  115. package/bundle/{chunk-3tdqsm5c.js → chunk-b50t4jc5.js} +1 -1
  116. package/bundle/chunk-bdy1etja.js +2 -0
  117. package/bundle/{chunk-6szvs3k9.js → chunk-bnc4626b.js} +1 -1
  118. package/bundle/{chunk-fm4xa6yx.js → chunk-bpnpxdyv.js} +2 -2
  119. package/bundle/chunk-bqdvqmjc.js +2 -0
  120. package/bundle/chunk-bqs6a1ts.js +14 -0
  121. package/bundle/{chunk-78bajmqm.js → chunk-bsqcfqya.js} +1 -1
  122. package/bundle/{chunk-ecwz9nhs.js → chunk-c1ypbbka.js} +2 -2
  123. package/bundle/{chunk-1jsywey3.js → chunk-c27rpvdz.js} +1 -1
  124. package/bundle/chunk-cdws8ggq.js +2 -0
  125. package/bundle/{chunk-6j0365q3.js → chunk-cjxp72dv.js} +2 -2
  126. package/bundle/chunk-cqs9a2cs.js +2 -0
  127. package/bundle/{chunk-3wzqs241.js → chunk-crap29f6.js} +1 -1
  128. package/bundle/{chunk-1jh5p5qw.js → chunk-d0m7nbbx.js} +2 -2
  129. package/bundle/chunk-d0rjst58.js +2 -0
  130. package/bundle/{chunk-2eardzxs.js → chunk-d1bsxz2t.js} +1 -1
  131. package/bundle/{chunk-b6m4yyww.js → chunk-d5b0bqbr.js} +1 -1
  132. package/bundle/chunk-d833a2fj.js +2 -0
  133. package/bundle/{chunk-tk3bve0x.js → chunk-dd11kryy.js} +2 -2
  134. package/bundle/chunk-dday4nm2.js +2 -0
  135. package/bundle/{chunk-qw2hgs5b.js → chunk-ddxjc803.js} +2 -2
  136. package/bundle/{chunk-3tkp27x7.js → chunk-dee1a3yk.js} +2 -2
  137. package/bundle/{chunk-q6fbyvpq.js → chunk-dgggvses.js} +1 -1
  138. package/bundle/{chunk-apq38bt4.js → chunk-dk3z4k46.js} +3 -3
  139. package/bundle/{chunk-wf09j72q.js → chunk-e075v4e9.js} +2 -2
  140. package/bundle/{chunk-1xyn0sp2.js → chunk-e1pwnf0b.js} +2 -2
  141. package/bundle/chunk-e2sj30hk.js +2 -0
  142. package/bundle/{chunk-dann9gfq.js → chunk-eaatrmcg.js} +1 -1
  143. package/bundle/{chunk-1y9t7nxn.js → chunk-eg7drzzt.js} +1 -1
  144. package/bundle/chunk-enc0fykg.js +2 -0
  145. package/bundle/chunk-evan93av.js +2 -0
  146. package/bundle/{chunk-9f7y0dj0.js → chunk-evmfntm3.js} +1 -1
  147. package/bundle/{chunk-2gxjjqfx.js → chunk-ey4ktbyb.js} +1 -1
  148. package/bundle/{chunk-sswbfqcq.js → chunk-f55txcsa.js} +1 -1
  149. package/bundle/chunk-f600dzsr.js +2 -0
  150. package/bundle/chunk-f6jzwydk.js +2 -0
  151. package/bundle/{chunk-s9amvacw.js → chunk-f84cd0a1.js} +2 -2
  152. package/bundle/{chunk-6sdh1q7g.js → chunk-fgw420gb.js} +1 -1
  153. package/bundle/chunk-fv67ng8z.js +2 -0
  154. package/bundle/{chunk-x6z2b63w.js → chunk-g3s2z5xa.js} +1 -1
  155. package/bundle/{chunk-9xvctnjr.js → chunk-g4qwkcdv.js} +1 -1
  156. package/bundle/{chunk-3nhqd8wg.js → chunk-g73drh98.js} +3 -3
  157. package/bundle/{chunk-0pvbk8ks.js → chunk-gaen9ya4.js} +2 -2
  158. package/bundle/{chunk-ac202abt.js → chunk-gefh32jb.js} +1 -1
  159. package/bundle/chunk-gevazsx3.js +2 -0
  160. package/bundle/{chunk-n1chdwrs.js → chunk-gfmfrkxc.js} +1 -1
  161. package/bundle/{chunk-sjrmhd3e.js → chunk-ggeena9t.js} +1 -1
  162. package/bundle/chunk-gh18pzkx.js +2 -0
  163. package/bundle/chunk-gnvvgr4y.js +2 -0
  164. package/bundle/{chunk-4q9w2yve.js → chunk-grkkzrg1.js} +2 -2
  165. package/bundle/chunk-gsbjs2ws.js +2 -0
  166. package/bundle/{chunk-gff87y4n.js → chunk-gsz1wqy6.js} +1 -1
  167. package/bundle/{chunk-vf1r5ckp.js → chunk-gvtw9c44.js} +1 -1
  168. package/bundle/chunk-gw0j8hr9.js +3 -0
  169. package/bundle/{chunk-cesrhm09.js → chunk-h19ty95q.js} +1 -1
  170. package/bundle/{chunk-9nx8hm57.js → chunk-h2fh1g8g.js} +1 -1
  171. package/bundle/{chunk-p54bzjtv.js → chunk-h56jxxvj.js} +1 -1
  172. package/bundle/{chunk-jmjg8d8a.js → chunk-hmfefq0d.js} +4 -4
  173. package/bundle/{chunk-gn7xgd4c.js → chunk-hvpe07pt.js} +1 -1
  174. package/bundle/{chunk-gvzfffr4.js → chunk-hwbxehhf.js} +1 -1
  175. package/bundle/{chunk-zp2ffbc2.js → chunk-hznsed5n.js} +2 -2
  176. package/bundle/{chunk-w1atxyz0.js → chunk-j5b5h08g.js} +1 -1
  177. package/bundle/chunk-j7pdz979.js +2 -0
  178. package/bundle/{chunk-02txthqv.js → chunk-j9s62g01.js} +2 -2
  179. package/bundle/chunk-jfe2qbv8.js +2 -0
  180. package/bundle/{chunk-wj6aq50n.js → chunk-jgs6ngte.js} +1 -1
  181. package/bundle/{chunk-ep8zn49w.js → chunk-jhq5bvhs.js} +2 -2
  182. package/bundle/{chunk-2z6fzwyc.js → chunk-jq81hb32.js} +2 -2
  183. package/bundle/{chunk-dcx8hjbs.js → chunk-jqzejny3.js} +1 -1
  184. package/bundle/{chunk-j1veq3zr.js → chunk-jtrcnpm7.js} +2 -2
  185. package/bundle/{chunk-hbnr0j7h.js → chunk-jv98gw88.js} +2 -2
  186. package/bundle/{chunk-e346x00p.js → chunk-jvaffe5d.js} +1 -1
  187. package/bundle/chunk-k6zvb8xm.js +2 -0
  188. package/bundle/{chunk-5y8efy5b.js → chunk-k8bp3jjv.js} +1 -1
  189. package/bundle/{chunk-0ae5q6ck.js → chunk-kb14wxcs.js} +2 -2
  190. package/bundle/chunk-kcht9kvx.js +2 -0
  191. package/bundle/{chunk-edvcz2gd.js → chunk-kdcspxvq.js} +1 -1
  192. package/bundle/{chunk-t6w96xq2.js → chunk-kdct3e8s.js} +1 -1
  193. package/bundle/{chunk-1fnmkm0z.js → chunk-kgsq240v.js} +2 -2
  194. package/bundle/chunk-knvsa1d4.js +2 -0
  195. package/bundle/chunk-kp6d68hd.js +2 -0
  196. package/bundle/{chunk-jpygkh1c.js → chunk-kwm87f18.js} +1 -1
  197. package/bundle/{chunk-1p34bx7c.js → chunk-kyny0t2g.js} +2 -2
  198. package/bundle/{chunk-b8ag61vj.js → chunk-m2ang7yb.js} +1 -1
  199. package/bundle/{chunk-99n6czag.js → chunk-mbh1pdv9.js} +2 -2
  200. package/bundle/{chunk-y1srca0c.js → chunk-mczw8e3s.js} +2 -2
  201. package/bundle/chunk-me78p9x4.js +2 -0
  202. package/bundle/{chunk-g7vkkmsk.js → chunk-meaybtcc.js} +3 -3
  203. package/bundle/{chunk-9rqrm9y8.js → chunk-mkdyknbz.js} +1 -1
  204. package/bundle/{chunk-bf146hz2.js → chunk-mkyrg7gt.js} +2 -2
  205. package/bundle/{chunk-0pbt75ev.js → chunk-mr7agwgn.js} +1 -1
  206. package/bundle/{chunk-0w4v0fbs.js → chunk-msm3r7ny.js} +2 -2
  207. package/bundle/chunk-mv1d7wyt.js +2 -0
  208. package/bundle/{chunk-hh3w51wp.js → chunk-mybpgrjj.js} +2 -2
  209. package/bundle/{chunk-gf4ek7rv.js → chunk-n8dcmjph.js} +1 -1
  210. package/bundle/chunk-n8xmmxh5.js +2 -0
  211. package/bundle/chunk-n90219q9.js +2 -0
  212. package/bundle/chunk-nckg3ydx.js +2 -0
  213. package/bundle/{chunk-a5zjrwqy.js → chunk-nf8gkxbk.js} +2 -2
  214. package/bundle/chunk-nhaenjw3.js +2 -0
  215. package/bundle/chunk-nhtrt5ec.js +2 -0
  216. package/bundle/{chunk-6dxaty1v.js → chunk-nhx2xp2x.js} +1 -1
  217. package/bundle/{chunk-najzfhb2.js → chunk-nmnsf3fc.js} +1 -1
  218. package/bundle/{chunk-84gnbzky.js → chunk-nqefvn28.js} +1 -1
  219. package/bundle/{chunk-v2kyarwz.js → chunk-p409grvp.js} +2 -2
  220. package/bundle/chunk-p72n0tfq.js +2 -0
  221. package/bundle/{chunk-jr8qcf99.js → chunk-p80dc6kt.js} +2 -2
  222. package/bundle/{chunk-2wp1w8cy.js → chunk-p883sz67.js} +1 -1
  223. package/bundle/{chunk-fdezde1z.js → chunk-p8enedkf.js} +1 -1
  224. package/bundle/chunk-pd33qvr0.js +2 -0
  225. package/bundle/{chunk-d56zc21w.js → chunk-pepn5jp4.js} +1 -1
  226. package/bundle/chunk-pf7cj4jd.js +3 -0
  227. package/bundle/{chunk-bd21p9zz.js → chunk-pfn1db1m.js} +2 -2
  228. package/bundle/{chunk-srf73nm4.js → chunk-pk0tytcm.js} +1 -1
  229. package/bundle/chunk-pq3622ae.js +2 -0
  230. package/bundle/{chunk-ebjhggdw.js → chunk-psveqqv2.js} +1 -1
  231. package/bundle/{chunk-wfnk2vsd.js → chunk-pvee151a.js} +1 -1
  232. package/bundle/chunk-qatj4h6b.js +2 -0
  233. package/bundle/{chunk-3vbtra1j.js → chunk-qdnxv55k.js} +1 -1
  234. package/bundle/{chunk-gen6f3dn.js → chunk-qe0sfafy.js} +2 -2
  235. package/bundle/chunk-qfz0a58d.js +2 -0
  236. package/bundle/chunk-qjwfj51e.js +2 -0
  237. package/bundle/chunk-qkg73rs9.js +2 -0
  238. package/bundle/{chunk-5kmfnkzv.js → chunk-qm9ezq93.js} +1 -1
  239. package/bundle/{chunk-5rkmhzq0.js → chunk-qnqqrvvs.js} +2 -2
  240. package/bundle/{chunk-9pe4agdz.js → chunk-qnv2v02g.js} +2 -2
  241. package/bundle/{chunk-7dckfame.js → chunk-qpm5afdz.js} +1 -1
  242. package/bundle/chunk-qvcfst7n.js +11 -0
  243. package/bundle/{chunk-r48g0kaq.js → chunk-rgecc41f.js} +2 -2
  244. package/bundle/chunk-rjcptzem.js +8 -0
  245. package/bundle/{chunk-hh9a709t.js → chunk-rjf21v5c.js} +1 -1
  246. package/bundle/chunk-rmsqb6r4.js +10 -0
  247. package/bundle/{chunk-2mmspnr3.js → chunk-rq4hqwjy.js} +1 -1
  248. package/bundle/chunk-rqrpbcm6.js +2 -0
  249. package/bundle/{chunk-ftk58wxe.js → chunk-rs1mm5ef.js} +1 -1
  250. package/bundle/{chunk-a9y27zd2.js → chunk-rze20q68.js} +1 -1
  251. package/bundle/chunk-s76hdgw6.js +2 -0
  252. package/bundle/chunk-s7vhjg9e.js +2 -0
  253. package/bundle/{chunk-fkvccmgk.js → chunk-se79ke63.js} +2 -2
  254. package/bundle/chunk-sec3a60m.js +2 -0
  255. package/bundle/chunk-sjnt5e6w.js +2 -0
  256. package/bundle/chunk-sntb757q.js +2 -0
  257. package/bundle/chunk-svscftd7.js +2 -0
  258. package/bundle/chunk-sx0cabcs.js +2 -0
  259. package/bundle/{chunk-gn9p1d50.js → chunk-sx5m81em.js} +1 -1
  260. package/bundle/chunk-syhay5ye.js +7 -0
  261. package/bundle/{chunk-9798jffg.js → chunk-t07a5431.js} +1 -1
  262. package/bundle/{chunk-c31k8yh0.js → chunk-t0amhhsk.js} +1 -1
  263. package/bundle/{chunk-pfhp78cr.js → chunk-t2tsyazc.js} +1 -1
  264. package/bundle/{chunk-spm1yy6w.js → chunk-tdmaxc6n.js} +1 -1
  265. package/bundle/{chunk-gc9q0x8z.js → chunk-tf1me2r4.js} +3 -3
  266. package/bundle/{chunk-zfnbk5gy.js → chunk-tfggzzqw.js} +1 -1
  267. package/bundle/chunk-tmdm6vm6.js +2 -0
  268. package/bundle/{chunk-9sy9ws1w.js → chunk-v4xgceeq.js} +1 -1
  269. package/bundle/chunk-v6g0ksks.js +2 -0
  270. package/bundle/chunk-v7ah9gg0.js +3 -0
  271. package/bundle/{chunk-kr0fsqas.js → chunk-vb4e7y4d.js} +1 -1
  272. package/bundle/chunk-vbf73c7z.js +2 -0
  273. package/bundle/chunk-vbf9jpas.js +2 -0
  274. package/bundle/{chunk-r3yqe7x0.js → chunk-veev25yg.js} +1 -1
  275. package/bundle/{chunk-kaeyhw2n.js → chunk-vfj5nwab.js} +2 -2
  276. package/bundle/{chunk-6g3m7yxf.js → chunk-vmgknvxs.js} +2 -2
  277. package/bundle/{chunk-2y8qz8te.js → chunk-vq6bh2z9.js} +1 -1
  278. package/bundle/{chunk-b643cra9.js → chunk-vqq5vmh1.js} +195 -195
  279. package/bundle/chunk-vrcf5q4s.js +2 -0
  280. package/bundle/chunk-vxrsp6n7.js +2 -0
  281. package/bundle/chunk-w8ax3pvh.js +2 -0
  282. package/bundle/chunk-w98r39gd.js +9 -0
  283. package/bundle/{chunk-j1a64ade.js → chunk-wb69d52j.js} +2 -2
  284. package/bundle/{chunk-hg9nk090.js → chunk-wrgg270f.js} +1 -1
  285. package/bundle/{chunk-yzdty5t9.js → chunk-ww8ear80.js} +2 -2
  286. package/bundle/{chunk-ha1w0xzh.js → chunk-x36jhtex.js} +1 -1
  287. package/bundle/{chunk-hjbks7r9.js → chunk-x6b99nt3.js} +1 -1
  288. package/bundle/{chunk-yh174jhg.js → chunk-xdde80rf.js} +2 -2
  289. package/bundle/{chunk-17ggas8k.js → chunk-xjrt0dta.js} +1 -1
  290. package/bundle/chunk-xk2cmh49.js +2 -0
  291. package/bundle/{chunk-f819a7ec.js → chunk-xqa6qkx2.js} +1 -1
  292. package/bundle/{chunk-f3kjp838.js → chunk-xw283h2r.js} +2 -2
  293. package/bundle/{chunk-82gs5cmn.js → chunk-xy4t5qf8.js} +1 -1
  294. package/bundle/{chunk-0w0jfzb4.js → chunk-xyn3xxfs.js} +1 -1
  295. package/bundle/chunk-xzhkfctf.js +2 -0
  296. package/bundle/chunk-y0xt5a6g.js +2 -0
  297. package/bundle/{chunk-hxgb0y1w.js → chunk-ybn8tb09.js} +1 -1
  298. package/bundle/chunk-ydmrvx7q.js +2 -0
  299. package/bundle/{chunk-ns0pswww.js → chunk-ydsen7w0.js} +1 -1
  300. package/bundle/{chunk-hv4nhx6q.js → chunk-yhqk8bzk.js} +2 -2
  301. package/bundle/{chunk-g0v9g37f.js → chunk-ykfq8bem.js} +1 -1
  302. package/bundle/{chunk-r7xp0xcn.js → chunk-ym4ydwrz.js} +2 -2
  303. package/bundle/{chunk-4tn69nqs.js → chunk-yzchwmb4.js} +1 -1
  304. package/bundle/{chunk-1d64dywx.js → chunk-z015twaq.js} +2 -2
  305. package/bundle/chunk-z2rtcgad.js +3 -0
  306. package/bundle/{chunk-ms1fd6h4.js → chunk-z3zx6g09.js} +1 -1
  307. package/bundle/chunk-z9b3t2jm.js +2 -0
  308. package/bundle/{chunk-agdfqncf.js → chunk-zbdbsagd.js} +2 -2
  309. package/bundle/{chunk-evqxvhdb.js → chunk-zh808d4t.js} +1 -1
  310. package/bundle/{chunk-fhng5her.js → chunk-zny2qaqa.js} +2 -2
  311. package/bundle/{chunk-y2jmtfdh.js → chunk-zsnbxsdx.js} +2 -2
  312. package/bundle/{chunk-pv8jcpnf.js → chunk-zss93r48.js} +1 -1
  313. package/bundle/chunk-zzr8smtm.js +2 -0
  314. package/bundle/index.js +16 -16
  315. package/bundle/parser.worker.js +2 -2
  316. package/bundle/worker.js +1 -1
  317. package/package.json +1 -1
  318. package/bundle/chunk-0bvde0cx.js +0 -2
  319. package/bundle/chunk-0kbxnazj.js +0 -2
  320. package/bundle/chunk-0z3z0gk1.js +0 -5
  321. package/bundle/chunk-19z5q33z.js +0 -2
  322. package/bundle/chunk-1a0wnwna.js +0 -2
  323. package/bundle/chunk-1ddm2wxv.js +0 -2
  324. package/bundle/chunk-1fk4vsmc.js +0 -2
  325. package/bundle/chunk-1j2f9nd5.js +0 -2
  326. package/bundle/chunk-27s736an.js +0 -2
  327. package/bundle/chunk-2j17xrzj.js +0 -2
  328. package/bundle/chunk-2zca3nak.js +0 -2
  329. package/bundle/chunk-2zcvcfq4.js +0 -2
  330. package/bundle/chunk-38hwkfj5.js +0 -2
  331. package/bundle/chunk-3afqxvsn.js +0 -2
  332. package/bundle/chunk-3avc1ppg.js +0 -7
  333. package/bundle/chunk-3v4vtah1.js +0 -2
  334. package/bundle/chunk-3ypk0j2f.js +0 -2
  335. package/bundle/chunk-3z1y040p.js +0 -3
  336. package/bundle/chunk-4aykrj51.js +0 -9
  337. package/bundle/chunk-4dtbmqmq.js +0 -2
  338. package/bundle/chunk-4zjb6rps.js +0 -2
  339. package/bundle/chunk-5hkcjgwh.js +0 -2
  340. package/bundle/chunk-5snrz263.js +0 -2
  341. package/bundle/chunk-653c0mxr.js +0 -11
  342. package/bundle/chunk-6av7hrrk.js +0 -7
  343. package/bundle/chunk-6bswn7w5.js +0 -2
  344. package/bundle/chunk-6epghftw.js +0 -2
  345. package/bundle/chunk-6jjhxh8p.js +0 -2
  346. package/bundle/chunk-6ws7xyc5.js +0 -2
  347. package/bundle/chunk-7g28zhar.js +0 -2
  348. package/bundle/chunk-7v02b2ms.js +0 -2
  349. package/bundle/chunk-7vmp2034.js +0 -2
  350. package/bundle/chunk-7wxrypkr.js +0 -2
  351. package/bundle/chunk-8kk9gvdy.js +0 -2
  352. package/bundle/chunk-8ygpp4y3.js +0 -2
  353. package/bundle/chunk-95q60g1p.js +0 -2
  354. package/bundle/chunk-9mjbenja.js +0 -2
  355. package/bundle/chunk-9vn1gy8h.js +0 -2
  356. package/bundle/chunk-ajp3f08k.js +0 -2
  357. package/bundle/chunk-aptkpdkc.js +0 -2
  358. package/bundle/chunk-bky5a42k.js +0 -3
  359. package/bundle/chunk-bry94ar5.js +0 -2
  360. package/bundle/chunk-btzyvqkf.js +0 -2
  361. package/bundle/chunk-c94pjdfh.js +0 -2
  362. package/bundle/chunk-cct9ds5c.js +0 -2
  363. package/bundle/chunk-czn535v0.js +0 -2
  364. package/bundle/chunk-d7wd5hz1.js +0 -2
  365. package/bundle/chunk-d86cmjrp.js +0 -2
  366. package/bundle/chunk-dnq65xvn.js +0 -2
  367. package/bundle/chunk-dpqv8rtn.js +0 -2
  368. package/bundle/chunk-e9mh7s3z.js +0 -2
  369. package/bundle/chunk-ek2y5f6g.js +0 -2
  370. package/bundle/chunk-epdsay73.js +0 -2
  371. package/bundle/chunk-f89gntcy.js +0 -3
  372. package/bundle/chunk-ffnsn7tv.js +0 -2
  373. package/bundle/chunk-fkezc7ew.js +0 -2
  374. package/bundle/chunk-fsxddgj0.js +0 -2
  375. package/bundle/chunk-gbcsfg6v.js +0 -2
  376. package/bundle/chunk-gfmz85hp.js +0 -2
  377. package/bundle/chunk-gk63k4t6.js +0 -2
  378. package/bundle/chunk-j0vf8s12.js +0 -2
  379. package/bundle/chunk-j1bxt69x.js +0 -2
  380. package/bundle/chunk-jcem8s30.js +0 -2
  381. package/bundle/chunk-jjwjb9w0.js +0 -3
  382. package/bundle/chunk-jpham2a3.js +0 -2
  383. package/bundle/chunk-jzkymnr5.js +0 -2
  384. package/bundle/chunk-k0qtwnhb.js +0 -2
  385. package/bundle/chunk-k2rsky7z.js +0 -2
  386. package/bundle/chunk-kcetcysa.js +0 -2
  387. package/bundle/chunk-kjfc5v3s.js +0 -2
  388. package/bundle/chunk-kkvb2c2z.js +0 -8
  389. package/bundle/chunk-km2ayfyf.js +0 -2
  390. package/bundle/chunk-knrh89eb.js +0 -2
  391. package/bundle/chunk-ksqfjawv.js +0 -2
  392. package/bundle/chunk-m8djypsy.js +0 -11
  393. package/bundle/chunk-mjhb1q0n.js +0 -3
  394. package/bundle/chunk-mxcger73.js +0 -2
  395. package/bundle/chunk-nazkrkeb.js +0 -2
  396. package/bundle/chunk-nk01s49e.js +0 -2
  397. package/bundle/chunk-ns8b7rx1.js +0 -2
  398. package/bundle/chunk-ny6vpkx2.js +0 -2
  399. package/bundle/chunk-q0dd3ak6.js +0 -3
  400. package/bundle/chunk-q2s057bm.js +0 -2
  401. package/bundle/chunk-q5cqg2c0.js +0 -28
  402. package/bundle/chunk-qk2wnp2x.js +0 -2
  403. package/bundle/chunk-r012q335.js +0 -3
  404. package/bundle/chunk-rbdjbgkb.js +0 -2
  405. package/bundle/chunk-rxjprhgh.js +0 -2
  406. package/bundle/chunk-s3w9bmze.js +0 -2
  407. package/bundle/chunk-s3zste1a.js +0 -2
  408. package/bundle/chunk-sbt7qmwm.js +0 -3
  409. package/bundle/chunk-sf6h44pb.js +0 -2
  410. package/bundle/chunk-sgvzxs7m.js +0 -2
  411. package/bundle/chunk-sp9bndyh.js +0 -2
  412. package/bundle/chunk-vavrczqm.js +0 -3
  413. package/bundle/chunk-vg4styg5.js +0 -2
  414. package/bundle/chunk-vh09hhcs.js +0 -2
  415. package/bundle/chunk-vhktpm0n.js +0 -2
  416. package/bundle/chunk-vzjcmwry.js +0 -14
  417. package/bundle/chunk-wtp0yvqw.js +0 -2
  418. package/bundle/chunk-xmzs7q66.js +0 -2
  419. package/bundle/chunk-xv80476w.js +0 -2
  420. package/bundle/chunk-yjvr0et1.js +0 -2
  421. package/bundle/chunk-zk8n8hnh.js +0 -3
  422. package/bundle/chunk-zx3kcfkj.js +0 -2
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ig as o}from"./chunk-aqm597px.js";import{hO as n}from"./chunk-0rmmg3g4.js";async function a(){try{let{toJsonSchema:t}=await import("./chunk-vq6bh2z9.js");return t}catch{throw new o("@valibot/to-json-schema")}}export{a as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ig as t}from"./chunk-aqm597px.js";import{hO as o}from"./chunk-0rmmg3g4.js";async function e(){try{let{toJSONSchema:r}=await import("./chunk-rjf21v5c.js");return r}catch{throw new t("sury")}}export{e as default};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Qs as w}from"./chunk-f3kjp838.js";import{Ss as z}from"./chunk-tsn1jkr7.js";import{Bt as J}from"./chunk-1jh5p5qw.js";function H(j,v){return typeof j==="object"&&j!==null&&"_tag"in j&&j._tag===v}function V(j){if(w.hasName(j,"MCPFailed"))return`MCP server "${j.data?.name}" failed. Note, qitqode does not support MCP authentication yet.`;if(H(j,"AccountServiceError")||H(j,"AccountTransportError"))return j.message??"";if(w.hasName(j,"ProviderModelNotFoundError")){let k=j.data,A=Array.isArray(k?.suggestions)?k.suggestions:[];return[`Model not found: ${k?.providerID}/${k?.modelID}`,...A.length?["Did you mean: "+A.join(", ")]:[],"Try: `qitqode models` to list available models","Or check your config (qitqode.json) provider/model names"].join(`
2
+ import{ur as w}from"./chunk-xw283h2r.js";import{wr as z}from"./chunk-8cty50g7.js";import{Es as J}from"./chunk-d0m7nbbx.js";function H(j,v){return typeof j==="object"&&j!==null&&"_tag"in j&&j._tag===v}function V(j){if(w.hasName(j,"MCPFailed"))return`MCP server "${j.data?.name}" failed. Note, qitqode does not support MCP authentication yet.`;if(H(j,"AccountServiceError")||H(j,"AccountTransportError"))return j.message??"";if(w.hasName(j,"ProviderModelNotFoundError")){let k=j.data,A=Array.isArray(k?.suggestions)?k.suggestions:[];return[`Model not found: ${k?.providerID}/${k?.modelID}`,...A.length?["Did you mean: "+A.join(", ")]:[],"Try: `qitqode models` to list available models","Or check your config (qitqode.json) provider/model names"].join(`
3
3
  `)}if(w.hasName(j,"ProviderInitError"))return`Failed to initialize provider "${j.data?.providerID}". Check credentials and configuration.`;if(w.hasName(j,"ConfigJsonError")){let k=j.data;return`Config file at ${k?.path} is not valid JSON(C)`+(k?.message?`: ${k.message}`:"")}if(w.hasName(j,"ConfigDirectoryTypoError")){let k=j.data;return`Directory "${k?.dir}" in ${k?.path} is not valid. Rename the directory to "${k?.suggestion}" or remove it. This is a common typo.`}if(w.hasName(j,"ConfigFrontmatterError"))return j.data?.message??"";if(w.hasName(j,"ConfigInvalidError")){let k=j.data,A=k?.path,B=k?.message,K=Array.isArray(k?.issues)?k.issues:[];return[`Configuration is invalid${A&&A!=="config"?` at ${A}`:""}`+(B?`: ${B}`:""),...K.map((G)=>"\u21B3 "+G.message+" "+G.path.join("."))].join(`
4
4
  `)}if(w.hasName(j,"UICancelledError"))return"";let v=typeof j==="object"&&j!==null&&"name"in j?j.name:void 0;if(v==="QlexNotLoggedInError")return z.copy().notLoggedIn;if(v==="QlexInsufficientBalanceError")return(j.message??z.copy().insufficientBalanceFallback)+z.copy().insufficientBalanceCliSuffix;if(v==="QlexRateLimitError")return z.copy().rateLimit;if(v==="BackendInsufficientBalanceError")return(j.message??z.copy().insufficientBalanceFallback)+z.copy().insufficientBalanceCliSuffix;if(v==="BackendRateLimitError")return j.message??z.copy().rateLimit;if(v==="QlexInvalidCredentialsError")return j.message??z.copy().invalidCredentialsFallback}function W(j){return J(j)}function D({onlyFirst:j=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",j?void 0:"g")}var L=D();function M(j){if(typeof j!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof j}\``);return j.replace(L,"")}
5
- export{M as Hf,V as If,W as Jf};
5
+ export{M as If,V as Jf,W as Kf};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$f as e,Xf as a,Yf as b,Zf as c,_f as d}from"./chunk-bqs6a1ts.js";import"./chunk-cjxp72dv.js";import"./chunk-2rxt1s22.js";import"./chunk-w98r39gd.js";import"./chunk-atd0q4v8.js";import"./chunk-nfg7nt13.js";import"./chunk-aqm597px.js";import"./chunk-8gy99gfb.js";import"./chunk-87x607rz.js";import"./chunk-9w5rx0fb.js";import"./chunk-wb69d52j.js";import"./chunk-pfn1db1m.js";import"./chunk-h56jxxvj.js";import"./chunk-x36jhtex.js";import"./chunk-c1ypbbka.js";import"./chunk-qnqqrvvs.js";import"./chunk-3f054f69.js";import"./chunk-26qt44f1.js";import"./chunk-0ke6x10y.js";import"./chunk-meaybtcc.js";import"./chunk-rmsqb6r4.js";import"./chunk-3j7skhxg.js";import"./chunk-4pssh5d3.js";import"./chunk-9dpn4792.js";import"./chunk-pf7cj4jd.js";import"./chunk-9r6bvkp4.js";import"./chunk-amx3x4kd.js";import"./chunk-b50t4jc5.js";import"./chunk-nf8gkxbk.js";import"./chunk-zny2qaqa.js";import"./chunk-9va5eh9s.js";import"./chunk-mkyrg7gt.js";import"./chunk-7v4fzkbb.js";import"./chunk-cqtkxwd8.js";import"./chunk-pk0tytcm.js";import"./chunk-ww8ear80.js";import"./chunk-kyny0t2g.js";import"./chunk-3e8p4a3y.js";import"./chunk-qpm5afdz.js";import"./chunk-jtrcnpm7.js";import"./chunk-gaen9ya4.js";import"./chunk-dd11kryy.js";import"./chunk-msm3r7ny.js";import"./chunk-e075v4e9.js";import"./chunk-jv98gw88.js";import"./chunk-jhq5bvhs.js";import"./chunk-xw283h2r.js";import"./chunk-8cty50g7.js";import"./chunk-v7ah9gg0.js";import"./chunk-d0m7nbbx.js";import"./chunk-vfj5nwab.js";import"./chunk-7w84hfxs.js";import"./chunk-ym4ydwrz.js";import"./chunk-vmgknvxs.js";import"./chunk-p409grvp.js";import"./chunk-ag9thqkv.js";import"./chunk-qnv2v02g.js";import"./chunk-7fx6x8x9.js";import"./chunk-0rmmg3g4.js";export{c as url,b as openapi,d as listen,e as Server,a as Default};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ee as x,He as F,Me as v,Ne as m,Qe as u,Ze as R,bf as M,cf as _,df as g,ff as d}from"./chunk-1fnmkm0z.js";import{_q as C,br as h}from"./chunk-t488d66k.js";import"./chunk-cqtkxwd8.js";import"./chunk-srf73nm4.js";import{Pu as z}from"./chunk-r7xp0xcn.js";import"./chunk-6g3m7yxf.js";import"./chunk-hh4c02fh.js";function I(D){var G,Q,N;if(D==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let U=(G=D.prompt_tokens)!=null?G:0,Y=(Q=D.completion_tokens)!=null?Q:0,B=(N=D.reasoning_tokens)!=null?N:0;return{inputTokens:{total:U,noCache:U,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:Y,text:Y-B,reasoning:B},raw:D}}function i(D){let G=[];for(let{role:Q,content:N}of D)switch(Q){case"system":{G.push({role:"system",content:N});break}case"user":case"assistant":{let U=N.some((B)=>B.type==="file"&&B.mediaType.startsWith("image/")||B.type==="file"&&B.mediaType==="application/pdf"),Y=N.map((B,$)=>{var Z;switch(B.type){case"text":return{type:"text",text:B.text};case"file":if(B.mediaType==="application/pdf")return B.data instanceof URL?{type:"file_url",file_url:{url:B.data.toString()},file_name:B.filename}:{type:"file_url",file_url:{url:typeof B.data==="string"?B.data:F(B.data)},file_name:B.filename||`document-${$}.pdf`};else if(B.mediaType.startsWith("image/"))return B.data instanceof URL?{type:"image_url",image_url:{url:B.data.toString()}}:{type:"image_url",image_url:{url:`data:${(Z=B.mediaType)!=null?Z:"image/jpeg"};base64,${typeof B.data==="string"?B.data:F(B.data)}`}}}}).filter(Boolean);G.push({role:Q,content:U?Y:Y.filter((B)=>B.type==="text").map((B)=>B.text).join("")});break}case"tool":throw new h({functionality:"Tool messages"});default:throw Error(`Unsupported role: ${Q}`)}return G}function b(D){switch(D){case"stop":case"length":return D;default:return"other"}}var p=class{constructor(D,G){this.specificationVersion="v3",this.provider="perplexity",this.supportedUrls={},this.modelId=D,this.config=G}getArgs({prompt:D,maxOutputTokens:G,temperature:Q,topP:N,topK:U,frequencyPenalty:Y,presencePenalty:B,stopSequences:$,responseFormat:Z,seed:J,providerOptions:E}){var L;let W=[];if(U!=null)W.push({type:"unsupported",feature:"topK"});if($!=null)W.push({type:"unsupported",feature:"stopSequences"});if(J!=null)W.push({type:"unsupported",feature:"seed"});return{args:{model:this.modelId,frequency_penalty:Y,max_tokens:G,presence_penalty:B,temperature:Q,top_k:U,top_p:N,response_format:(Z==null?void 0:Z.type)==="json"?{type:"json_schema",json_schema:{schema:Z.schema}}:void 0,...(L=E==null?void 0:E.perplexity)!=null?L:{},messages:i(D)},warnings:W}}async doGenerate(D){var G,Q,N,U,Y,B,$,Z,J,E,L,W;let{args:j,warnings:O}=this.getArgs(D),{responseHeaders:P,value:X,rawValue:w}=await R({url:`${this.config.baseURL}/chat/completions`,headers:x(this.config.headers(),D.headers),body:j,failedResponseHandler:M({errorSchema:f,errorToMessage:k}),successfulResponseHandler:g(n),abortSignal:D.abortSignal,fetch:this.config.fetch}),q=X.choices[0],H=[],A=q.message.content;if(A.length>0)H.push({type:"text",text:A});if(X.citations!=null)for(let V of X.citations)H.push({type:"source",sourceType:"url",id:this.config.generateId(),url:V});return{content:H,finishReason:{unified:b(q.finish_reason),raw:(G=q.finish_reason)!=null?G:void 0},usage:I(X.usage),request:{body:j},response:{...T(X),headers:P,body:w},warnings:O,providerMetadata:{perplexity:{images:(N=(Q=X.images)==null?void 0:Q.map((V)=>({imageUrl:V.image_url,originUrl:V.origin_url,height:V.height,width:V.width})))!=null?N:null,usage:{citationTokens:(Y=(U=X.usage)==null?void 0:U.citation_tokens)!=null?Y:null,numSearchQueries:($=(B=X.usage)==null?void 0:B.num_search_queries)!=null?$:null},cost:((Z=X.usage)==null?void 0:Z.cost)?{inputTokensCost:(J=X.usage.cost.input_tokens_cost)!=null?J:null,outputTokensCost:(E=X.usage.cost.output_tokens_cost)!=null?E:null,requestCost:(L=X.usage.cost.request_cost)!=null?L:null,totalCost:(W=X.usage.cost.total_cost)!=null?W:null}:null}}}}async doStream(D){let{args:G,warnings:Q}=this.getArgs(D),N={...G,stream:!0},{responseHeaders:U,value:Y}=await R({url:`${this.config.baseURL}/chat/completions`,headers:x(this.config.headers(),D.headers),body:N,failedResponseHandler:M({errorSchema:f,errorToMessage:k}),successfulResponseHandler:_(a),abortSignal:D.abortSignal,fetch:this.config.fetch}),B={unified:"other",raw:void 0},$=void 0,Z={perplexity:{usage:{citationTokens:null,numSearchQueries:null},cost:null,images:null}},J=!0,E=!1,L=this;return{stream:Y.pipeThrough(new TransformStream({start(W){W.enqueue({type:"stream-start",warnings:Q})},transform(W,j){var O,P,X,w,q,H,A;if(D.includeRawChunks)j.enqueue({type:"raw",rawValue:W.rawValue});if(!W.success){j.enqueue({type:"error",error:W.error});return}let V=W.value;if(J)j.enqueue({type:"response-metadata",...T(V)}),(O=V.citations)==null||O.forEach((K)=>{j.enqueue({type:"source",sourceType:"url",id:L.config.generateId(),url:K})}),J=!1;if(V.usage!=null)$=V.usage,Z.perplexity.usage={citationTokens:(P=V.usage.citation_tokens)!=null?P:null,numSearchQueries:(X=V.usage.num_search_queries)!=null?X:null},Z.perplexity.cost=V.usage.cost?{inputTokensCost:(w=V.usage.cost.input_tokens_cost)!=null?w:null,outputTokensCost:(q=V.usage.cost.output_tokens_cost)!=null?q:null,requestCost:(H=V.usage.cost.request_cost)!=null?H:null,totalCost:(A=V.usage.cost.total_cost)!=null?A:null}:null;if(V.images!=null)Z.perplexity.images=V.images.map((K)=>({imageUrl:K.image_url,originUrl:K.origin_url,height:K.height,width:K.width}));let S=V.choices[0];if((S==null?void 0:S.finish_reason)!=null)B={unified:b(S.finish_reason),raw:S.finish_reason};if((S==null?void 0:S.delta)==null)return;let y=S.delta.content;if(y!=null){if(!E)j.enqueue({type:"text-start",id:"0"}),E=!0;j.enqueue({type:"text-delta",id:"0",delta:y})}},flush(W){if(E)W.enqueue({type:"text-end",id:"0"});W.enqueue({type:"finish",finishReason:B,usage:I($),providerMetadata:Z})}})),request:{body:N},response:{headers:U}}}};function T({id:D,model:G,created:Q}){return{id:D,modelId:G,timestamp:new Date(Q*1000)}}var s=z.object({input_tokens_cost:z.number().nullish(),output_tokens_cost:z.number().nullish(),request_cost:z.number().nullish(),total_cost:z.number().nullish()}),c=z.object({prompt_tokens:z.number(),completion_tokens:z.number(),total_tokens:z.number().nullish(),citation_tokens:z.number().nullish(),num_search_queries:z.number().nullish(),reasoning_tokens:z.number().nullish(),cost:s.nullish()}),l=z.object({image_url:z.string(),origin_url:z.string(),height:z.number(),width:z.number()}),n=z.object({id:z.string(),created:z.number(),model:z.string(),choices:z.array(z.object({message:z.object({role:z.literal("assistant"),content:z.string()}),finish_reason:z.string().nullish()})),citations:z.array(z.string()).nullish(),images:z.array(l).nullish(),usage:c.nullish()}),a=z.object({id:z.string(),created:z.number(),model:z.string(),choices:z.array(z.object({delta:z.object({role:z.literal("assistant"),content:z.string()}),finish_reason:z.string().nullish()})),citations:z.array(z.string()).nullish(),images:z.array(l).nullish(),usage:c.nullish()}),f=z.object({error:z.object({code:z.number(),message:z.string().nullish(),type:z.string().nullish()})}),k=(D)=>{var G,Q;return(Q=(G=D.error.message)!=null?G:D.error.type)!=null?Q:"unknown error"},t="3.0.26";function r(D={}){let G=()=>m({Authorization:`Bearer ${u({apiKey:D.apiKey,environmentVariableName:"PERPLEXITY_API_KEY",description:"Perplexity"})}`,...D.headers},`ai-sdk/perplexity/${t}`),Q=(U)=>{var Y;return new p(U,{baseURL:d((Y=D.baseURL)!=null?Y:"https://api.perplexity.ai"),headers:G,generateId:v,fetch:D.fetch})},N=(U)=>Q(U);return N.specificationVersion="v3",N.languageModel=Q,N.embeddingModel=(U)=>{throw new C({modelId:U,modelType:"embeddingModel"})},N.textEmbeddingModel=N.embeddingModel,N.imageModel=(U)=>{throw new C({modelId:U,modelType:"imageModel"})},N}var Qz=r();export{Qz as perplexity,r as createPerplexity,t as VERSION};
2
+ import{Fe as x,Ie as F,Ne as v,Oe as m,Re as u,_e as R,cf as M,df as _,ef as g,gf as d}from"./chunk-kgsq240v.js";import{Ep as C,Hp as h}from"./chunk-7v4fzkbb.js";import"./chunk-cqtkxwd8.js";import"./chunk-pk0tytcm.js";import{ut as z}from"./chunk-ym4ydwrz.js";import"./chunk-vmgknvxs.js";import"./chunk-0rmmg3g4.js";function I(D){var G,Q,N;if(D==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let U=(G=D.prompt_tokens)!=null?G:0,Y=(Q=D.completion_tokens)!=null?Q:0,B=(N=D.reasoning_tokens)!=null?N:0;return{inputTokens:{total:U,noCache:U,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:Y,text:Y-B,reasoning:B},raw:D}}function i(D){let G=[];for(let{role:Q,content:N}of D)switch(Q){case"system":{G.push({role:"system",content:N});break}case"user":case"assistant":{let U=N.some((B)=>B.type==="file"&&B.mediaType.startsWith("image/")||B.type==="file"&&B.mediaType==="application/pdf"),Y=N.map((B,$)=>{var Z;switch(B.type){case"text":return{type:"text",text:B.text};case"file":if(B.mediaType==="application/pdf")return B.data instanceof URL?{type:"file_url",file_url:{url:B.data.toString()},file_name:B.filename}:{type:"file_url",file_url:{url:typeof B.data==="string"?B.data:F(B.data)},file_name:B.filename||`document-${$}.pdf`};else if(B.mediaType.startsWith("image/"))return B.data instanceof URL?{type:"image_url",image_url:{url:B.data.toString()}}:{type:"image_url",image_url:{url:`data:${(Z=B.mediaType)!=null?Z:"image/jpeg"};base64,${typeof B.data==="string"?B.data:F(B.data)}`}}}}).filter(Boolean);G.push({role:Q,content:U?Y:Y.filter((B)=>B.type==="text").map((B)=>B.text).join("")});break}case"tool":throw new h({functionality:"Tool messages"});default:throw Error(`Unsupported role: ${Q}`)}return G}function b(D){switch(D){case"stop":case"length":return D;default:return"other"}}var p=class{constructor(D,G){this.specificationVersion="v3",this.provider="perplexity",this.supportedUrls={},this.modelId=D,this.config=G}getArgs({prompt:D,maxOutputTokens:G,temperature:Q,topP:N,topK:U,frequencyPenalty:Y,presencePenalty:B,stopSequences:$,responseFormat:Z,seed:J,providerOptions:E}){var L;let W=[];if(U!=null)W.push({type:"unsupported",feature:"topK"});if($!=null)W.push({type:"unsupported",feature:"stopSequences"});if(J!=null)W.push({type:"unsupported",feature:"seed"});return{args:{model:this.modelId,frequency_penalty:Y,max_tokens:G,presence_penalty:B,temperature:Q,top_k:U,top_p:N,response_format:(Z==null?void 0:Z.type)==="json"?{type:"json_schema",json_schema:{schema:Z.schema}}:void 0,...(L=E==null?void 0:E.perplexity)!=null?L:{},messages:i(D)},warnings:W}}async doGenerate(D){var G,Q,N,U,Y,B,$,Z,J,E,L,W;let{args:j,warnings:O}=this.getArgs(D),{responseHeaders:P,value:X,rawValue:w}=await R({url:`${this.config.baseURL}/chat/completions`,headers:x(this.config.headers(),D.headers),body:j,failedResponseHandler:M({errorSchema:f,errorToMessage:k}),successfulResponseHandler:g(n),abortSignal:D.abortSignal,fetch:this.config.fetch}),q=X.choices[0],H=[],A=q.message.content;if(A.length>0)H.push({type:"text",text:A});if(X.citations!=null)for(let V of X.citations)H.push({type:"source",sourceType:"url",id:this.config.generateId(),url:V});return{content:H,finishReason:{unified:b(q.finish_reason),raw:(G=q.finish_reason)!=null?G:void 0},usage:I(X.usage),request:{body:j},response:{...T(X),headers:P,body:w},warnings:O,providerMetadata:{perplexity:{images:(N=(Q=X.images)==null?void 0:Q.map((V)=>({imageUrl:V.image_url,originUrl:V.origin_url,height:V.height,width:V.width})))!=null?N:null,usage:{citationTokens:(Y=(U=X.usage)==null?void 0:U.citation_tokens)!=null?Y:null,numSearchQueries:($=(B=X.usage)==null?void 0:B.num_search_queries)!=null?$:null},cost:((Z=X.usage)==null?void 0:Z.cost)?{inputTokensCost:(J=X.usage.cost.input_tokens_cost)!=null?J:null,outputTokensCost:(E=X.usage.cost.output_tokens_cost)!=null?E:null,requestCost:(L=X.usage.cost.request_cost)!=null?L:null,totalCost:(W=X.usage.cost.total_cost)!=null?W:null}:null}}}}async doStream(D){let{args:G,warnings:Q}=this.getArgs(D),N={...G,stream:!0},{responseHeaders:U,value:Y}=await R({url:`${this.config.baseURL}/chat/completions`,headers:x(this.config.headers(),D.headers),body:N,failedResponseHandler:M({errorSchema:f,errorToMessage:k}),successfulResponseHandler:_(a),abortSignal:D.abortSignal,fetch:this.config.fetch}),B={unified:"other",raw:void 0},$=void 0,Z={perplexity:{usage:{citationTokens:null,numSearchQueries:null},cost:null,images:null}},J=!0,E=!1,L=this;return{stream:Y.pipeThrough(new TransformStream({start(W){W.enqueue({type:"stream-start",warnings:Q})},transform(W,j){var O,P,X,w,q,H,A;if(D.includeRawChunks)j.enqueue({type:"raw",rawValue:W.rawValue});if(!W.success){j.enqueue({type:"error",error:W.error});return}let V=W.value;if(J)j.enqueue({type:"response-metadata",...T(V)}),(O=V.citations)==null||O.forEach((K)=>{j.enqueue({type:"source",sourceType:"url",id:L.config.generateId(),url:K})}),J=!1;if(V.usage!=null)$=V.usage,Z.perplexity.usage={citationTokens:(P=V.usage.citation_tokens)!=null?P:null,numSearchQueries:(X=V.usage.num_search_queries)!=null?X:null},Z.perplexity.cost=V.usage.cost?{inputTokensCost:(w=V.usage.cost.input_tokens_cost)!=null?w:null,outputTokensCost:(q=V.usage.cost.output_tokens_cost)!=null?q:null,requestCost:(H=V.usage.cost.request_cost)!=null?H:null,totalCost:(A=V.usage.cost.total_cost)!=null?A:null}:null;if(V.images!=null)Z.perplexity.images=V.images.map((K)=>({imageUrl:K.image_url,originUrl:K.origin_url,height:K.height,width:K.width}));let S=V.choices[0];if((S==null?void 0:S.finish_reason)!=null)B={unified:b(S.finish_reason),raw:S.finish_reason};if((S==null?void 0:S.delta)==null)return;let y=S.delta.content;if(y!=null){if(!E)j.enqueue({type:"text-start",id:"0"}),E=!0;j.enqueue({type:"text-delta",id:"0",delta:y})}},flush(W){if(E)W.enqueue({type:"text-end",id:"0"});W.enqueue({type:"finish",finishReason:B,usage:I($),providerMetadata:Z})}})),request:{body:N},response:{headers:U}}}};function T({id:D,model:G,created:Q}){return{id:D,modelId:G,timestamp:new Date(Q*1000)}}var s=z.object({input_tokens_cost:z.number().nullish(),output_tokens_cost:z.number().nullish(),request_cost:z.number().nullish(),total_cost:z.number().nullish()}),c=z.object({prompt_tokens:z.number(),completion_tokens:z.number(),total_tokens:z.number().nullish(),citation_tokens:z.number().nullish(),num_search_queries:z.number().nullish(),reasoning_tokens:z.number().nullish(),cost:s.nullish()}),l=z.object({image_url:z.string(),origin_url:z.string(),height:z.number(),width:z.number()}),n=z.object({id:z.string(),created:z.number(),model:z.string(),choices:z.array(z.object({message:z.object({role:z.literal("assistant"),content:z.string()}),finish_reason:z.string().nullish()})),citations:z.array(z.string()).nullish(),images:z.array(l).nullish(),usage:c.nullish()}),a=z.object({id:z.string(),created:z.number(),model:z.string(),choices:z.array(z.object({delta:z.object({role:z.literal("assistant"),content:z.string()}),finish_reason:z.string().nullish()})),citations:z.array(z.string()).nullish(),images:z.array(l).nullish(),usage:c.nullish()}),f=z.object({error:z.object({code:z.number(),message:z.string().nullish(),type:z.string().nullish()})}),k=(D)=>{var G,Q;return(Q=(G=D.error.message)!=null?G:D.error.type)!=null?Q:"unknown error"},t="3.0.26";function r(D={}){let G=()=>m({Authorization:`Bearer ${u({apiKey:D.apiKey,environmentVariableName:"PERPLEXITY_API_KEY",description:"Perplexity"})}`,...D.headers},`ai-sdk/perplexity/${t}`),Q=(U)=>{var Y;return new p(U,{baseURL:d((Y=D.baseURL)!=null?Y:"https://api.perplexity.ai"),headers:G,generateId:v,fetch:D.fetch})},N=(U)=>Q(U);return N.specificationVersion="v3",N.languageModel=Q,N.embeddingModel=(U)=>{throw new C({modelId:U,modelType:"embeddingModel"})},N.textEmbeddingModel=N.embeddingModel,N.imageModel=(U)=>{throw new C({modelId:U,modelType:"imageModel"})},N}var Qz=r();export{Qz as perplexity,r as createPerplexity,t as VERSION};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ze as C}from"./chunk-3nhqd8wg.js";import{uf as A}from"./chunk-jbd9k041.js";import{yP as _}from"./chunk-hh4c02fh.js";var S=_(C(),1),p=_(A(),1),N="AWS_ACCESS_KEY_ID",a="AWS_SECRET_ACCESS_KEY",i="AWS_SESSION_TOKEN",I="AWS_CREDENTIAL_EXPIRATION",d="AWS_CREDENTIAL_SCOPE",v="AWS_ACCOUNT_ID",T=(e)=>async()=>{e?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");let o=process.env[N],r=process.env[a],n=process.env[i],s=process.env[I],t=process.env[d],E=process.env[v];if(o&&r){let c={accessKeyId:o,secretAccessKey:r,...n&&{sessionToken:n},...s&&{expiration:new Date(s)},...t&&{credentialScope:t},...E&&{accountId:E}};return S.setCredentialFeature(c,"CREDENTIALS_ENV_VARS","g"),c}throw new p.CredentialsProviderError("Unable to find environment variable credentials.",{logger:e?.logger})};export{N as je,a as ke,i as le,I as me,d as ne,v as oe,T as pe};
2
+ import{Ae as C}from"./chunk-g73drh98.js";import{vf as A}from"./chunk-4wyjapes.js";import{dO as _}from"./chunk-0rmmg3g4.js";var S=_(C(),1),p=_(A(),1),N="AWS_ACCESS_KEY_ID",a="AWS_SECRET_ACCESS_KEY",i="AWS_SESSION_TOKEN",I="AWS_CREDENTIAL_EXPIRATION",d="AWS_CREDENTIAL_SCOPE",v="AWS_ACCOUNT_ID",T=(e)=>async()=>{e?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");let o=process.env[N],r=process.env[a],n=process.env[i],s=process.env[I],t=process.env[d],E=process.env[v];if(o&&r){let c={accessKeyId:o,secretAccessKey:r,...n&&{sessionToken:n},...s&&{expiration:new Date(s)},...t&&{credentialScope:t},...E&&{accountId:E}};return S.setCredentialFeature(c,"CREDENTIALS_ENV_VARS","g"),c}throw new p.CredentialsProviderError("Unable to find environment variable credentials.",{logger:e?.logger})};export{N as ke,a as le,i as me,I as ne,d as oe,v as pe,T as qe};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{fn as E,gn as e,hn as I}from"./chunk-3j7skhxg.js";import{En as _0,Fn as O0,Gn as G,Hn as Z0,jn as b,ln as g,mn as n,pn as i,qn as x}from"./chunk-4pssh5d3.js";import{do as p}from"./chunk-amx3x4kd.js";import{Ar as y,Cr as A,Cs as q,Hr as c,ss as T,ts as X,xr as t}from"./chunk-v7ah9gg0.js";import{Ds as s,Ss as d,Ws as Q}from"./chunk-d0m7nbbx.js";import{Ys as w}from"./chunk-7w84hfxs.js";import{TG as B,bC as v,gI as a,qE as o,tM as M}from"./chunk-ag9thqkv.js";import{fO as F}from"./chunk-0rmmg3g4.js";var h={};F(h,{waitForDependencies:()=>R0,layer:()=>$0,get:()=>C0,defaultLayer:()=>j0,TuiConfig:()=>h,Service:()=>C,Info:()=>W0});import r from"path";var D={};F(D,{Keybinds:()=>Q0,ConfigKeybinds:()=>D});var _=(O,Z)=>M.String.pipe(M.optional,M.withDecodingDefault(B.succeed(O))).annotate({description:Z}),B0=process.platform==="win32"?"ctrl+z,ctrl+-,super+z":"ctrl+-,super+z",K0=M.Struct({leader:_("ctrl+x","Leader key for keybind combinations"),app_exit:_("ctrl+c,ctrl+d,<leader>q","Exit the application"),editor_open:_("<leader>e","Open external editor"),theme_list:_("<leader>t","List available themes"),sidebar_toggle:_("<leader>b","Toggle sidebar"),scrollbar_toggle:_("none","Toggle session scrollbar"),status_view:_("<leader>s","View status"),session_export:_("<leader>x","Export session to editor"),session_new:_("<leader>n","Create a new session"),session_list:_("<leader>l","List all sessions"),session_timeline:_("<leader>g","Show session timeline"),session_fork:_("none","Fork session from message"),session_rename:_("ctrl+r","Rename session"),session_delete:_("ctrl+d","Delete session"),stash_delete:_("ctrl+d","Delete stash entry"),model_provider_list:_("ctrl+a","Open provider list from model dialog"),model_favorite_toggle:_("ctrl+f","Toggle model favorite status"),session_share:_("none","Share current session"),session_unshare:_("none","Unshare current session"),session_interrupt:_("escape","Interrupt current session"),session_compact:_("<leader>c","Compact the session"),messages_page_up:_("pageup,ctrl+alt+b","Scroll messages up by one page"),messages_page_down:_("pagedown,ctrl+alt+f","Scroll messages down by one page"),messages_line_up:_("ctrl+alt+y","Scroll messages up by one line"),messages_line_down:_("ctrl+alt+e","Scroll messages down by one line"),messages_half_page_up:_("ctrl+alt+u","Scroll messages up by half page"),messages_half_page_down:_("ctrl+alt+d","Scroll messages down by half page"),messages_first:_("ctrl+g,home","Navigate to first message"),messages_last:_("ctrl+alt+g,end","Navigate to last message"),messages_next:_("none","Navigate to next message"),messages_previous:_("none","Navigate to previous message"),messages_last_user:_("none","Navigate to last user message"),messages_copy:_("<leader>y","Copy message"),messages_undo:_("<leader>u","Undo message"),messages_redo:_("<leader>r","Redo message"),messages_toggle_conceal:_("<leader>h","Toggle code block concealment in messages"),tool_details:_("none","Toggle tool details visibility"),model_list:_("<leader>m","List available models"),model_cycle_recent:_("f2","Next recently used model"),model_cycle_recent_reverse:_("shift+f2","Previous recently used model"),model_cycle_favorite:_("none","Next favorite model"),model_cycle_favorite_reverse:_("none","Previous favorite model"),command_list:_("ctrl+p","List available commands"),agent_list:_("<leader>a","List agents"),agent_cycle:_("ctrl+space","Next agent"),agent_cycle_reverse:_("none","Previous agent"),variant_cycle:_("ctrl+t","Cycle model variants"),variant_list:_("none","List model variants"),input_clear:_("ctrl+c","Clear input field"),input_paste:_("super+v,ctrl+v","Paste from clipboard"),input_submit:_("return","Submit input"),input_newline:_("shift+return,ctrl+return,alt+return,ctrl+j","Insert newline in input"),input_move_left:_("left,ctrl+b","Move cursor left in input"),input_move_right:_("right,ctrl+f","Move cursor right in input"),input_move_up:_("up","Move cursor up in input"),input_move_down:_("down","Move cursor down in input"),input_select_left:_("shift+left","Select left in input"),input_select_right:_("shift+right","Select right in input"),input_select_up:_("shift+up","Select up in input"),input_select_down:_("shift+down","Select down in input"),input_line_home:_("ctrl+a","Move to start of line in input"),input_line_end:_("ctrl+e","Move to end of line in input"),input_select_line_home:_("ctrl+shift+a","Select to start of line in input"),input_select_line_end:_("ctrl+shift+e","Select to end of line in input"),input_visual_line_home:_("alt+a","Move to start of visual line in input"),input_visual_line_end:_("alt+e","Move to end of visual line in input"),input_select_visual_line_home:_("alt+shift+a","Select to start of visual line in input"),input_select_visual_line_end:_("alt+shift+e","Select to end of visual line in input"),input_buffer_home:_("home","Move to start of buffer in input"),input_buffer_end:_("end","Move to end of buffer in input"),input_select_buffer_home:_("shift+home","Select to start of buffer in input"),input_select_buffer_end:_("shift+end","Select to end of buffer in input"),input_delete_line:_("ctrl+shift+d","Delete line in input"),input_delete_to_line_end:_("ctrl+k","Delete to end of line in input"),input_delete_to_line_start:_("ctrl+u","Delete to start of line in input"),input_backspace:_("backspace,shift+backspace","Backspace in input"),input_delete:_("ctrl+d,delete,shift+delete","Delete character in input"),input_undo:_(B0,"Undo in input"),input_redo:_("ctrl+.,super+shift+z","Redo in input"),input_word_forward:_("alt+f,alt+right,ctrl+right","Move word forward in input"),input_word_backward:_("alt+b,alt+left,ctrl+left","Move word backward in input"),input_select_word_forward:_("alt+shift+f,alt+shift+right","Select word forward in input"),input_select_word_backward:_("alt+shift+b,alt+shift+left","Select word backward in input"),input_delete_word_forward:_("alt+d,alt+delete,ctrl+delete","Delete word forward in input"),input_delete_word_backward:_("ctrl+w,ctrl+backspace,alt+backspace","Delete word backward in input"),history_previous:_("up","Previous history item"),history_next:_("down","Next history item"),session_child_first:_("<leader>down","Go to first child session"),session_child_cycle:_("right","Go to next child session"),session_child_cycle_reverse:_("left","Go to previous child session"),session_parent:_("up","Go to parent session"),terminal_suspend:_("ctrl+z","Suspend terminal"),terminal_title_toggle:_("none","Toggle terminal title"),tips_toggle:_("<leader>h","Toggle tips on home screen"),plugin_manager:_("none","Open plugin manager dialog"),display_thinking:_("none","Toggle thinking blocks visibility")}).annotate({identifier:"KeybindsConfig"}),Q0=p(K0);var V0=w.object(Object.fromEntries(Object.keys(D.Keybinds.shape).map((O)=>[O,w.string().optional()]))).strict(),R=w.object({scroll_speed:w.number().min(0.001).optional().describe("TUI scroll speed"),scroll_acceleration:w.object({enabled:w.boolean().describe("Enable scroll acceleration")}).optional().describe("Scroll acceleration settings"),diff_style:w.enum(["auto","stacked"]).optional().describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),mouse:w.boolean().optional().describe("Enable or disable mouse capture (default: true on desktop, false on Android/Termux)"),accessible:w.boolean().optional().describe("Screen-reader friendly mode: linear main-screen rendering, no mouse capture, reduced motion, no sound (default: false)"),reduce_motion:w.boolean().optional().describe("Disable spinners and other animations, showing static text instead (default: false)"),sound:w.boolean().optional().describe("Enable or disable sound cues (default: true)"),announcements:w.enum(["quiet","normal","verbose"]).optional().describe("Verbosity of accessible-mode screen-reader announcements: 'quiet' announces only turn boundaries, errors, and stops; 'normal' adds tool-start lines; 'verbose' adds tool-completion lines (default: normal). Errors are always announced.")}),P=w.object({$schema:w.string().optional(),theme:w.string().optional(),keybinds:V0.optional(),plugin:I.Spec.zod.array().optional(),plugin_enabled:w.record(w.string(),w.boolean()).optional()}).extend(R.shape).strict();var H=q.create({service:"tui.migrate"}),Y0="https://qitqode.com/tui.json",D0=P.shape.theme.optional(),l=w.record(w.string(),w.unknown()).optional(),H0=w.object({scroll_speed:R.shape.scroll_speed.catch(void 0),scroll_acceleration:R.shape.scroll_acceleration.catch(void 0),diff_style:R.shape.diff_style.catch(void 0)}).strip();async function k(O){let Z=await G0(O);for(let W of Z){let j=await Q.readText(W).catch((m)=>{H.warn("failed to read config for tui migration",{path:W,error:m});return});if(!j)continue;let V=[],K=b(j,V,{allowTrailingComma:!0});if(V.length||!K||typeof K!=="object"||Array.isArray(K))continue;let $=D0.safeParse("theme"in K?K.theme:void 0),J=l.safeParse("keybinds"in K?K.keybinds:void 0),N=l.safeParse("tui"in K?K.tui:void 0),Y={theme:$.success?$.data:void 0,keybinds:J.success?J.data:void 0,tui:N.success?N.data:void 0},L=Y.tui?J0(Y.tui):void 0;if(Y.theme===void 0&&Y.keybinds===void 0&&!L)continue;let U=r.join(r.dirname(W),"tui.json");if(await Q.exists(U))continue;let z={$schema:Y0};if(Y.theme!==void 0)z.theme=Y.theme;if(Y.keybinds!==void 0)z.keybinds=Y.keybinds;if(L)Object.assign(z,L);if(!await Q.write(U,JSON.stringify(z,null,2)).then(()=>!0).catch((m)=>{return H.warn("failed to write tui migration target",{from:W,to:U,error:m}),!1}))continue;if(!await A0(W,j)){H.warn("tui config migrated but source file was not stripped",{from:W,to:U});continue}H.info("migrated tui config",{from:W,to:U})}}function J0(O){let Z=H0.parse(O);if(Z.scroll_speed===void 0&&Z.diff_style===void 0&&Z.scroll_acceleration===void 0)return;return Z}async function A0(O,Z){let W=O+".tui-migration.bak";if(!(await Q.exists(W)?!0:await Q.write(W,Z).then(()=>!0).catch(($)=>{return H.warn("failed to backup source config during tui migration",{path:O,backup:W,error:$}),!1})))return!1;let K=["theme","keybinds","tui"].reduce(($,J)=>{let N=g($,[J],void 0,{formattingOptions:{insertSpaces:!0,tabSize:2}});if(!N.length)return $;return n($,N)},Z);return Q.write(O,K).then(()=>{return H.info("stripped tui keys from server config",{path:O,backup:W}),!0}).catch(($)=>{return H.warn("failed to strip legacy tui keys from server config",{path:O,backup:W,error:$}),!1})}async function G0(O){let Z=[...G(T.Path.config,"qitqode"),...await Q.findUp(["qitqode.json","qitqode.jsonc"],O.cwd,void 0,{rootFirst:!0})];for(let j of A(O.directories))Z.push(...G(j,"qitqode"));if(X.QITQODE_CONFIG)Z.push(X.QITQODE_CONFIG);return(await Promise.all(A(Z).map(async(j)=>{return await Q.exists(j)?j:void 0}))).filter((j)=>!!j)}var f=v.Reference("CurrentWorkingDirectory",{defaultValue:()=>process.cwd()});var u=q.create({service:"tui.config"}),W0=P;class C extends v.Service()("@qitqode/TuiConfig"){}function N0(O,Z){if(Q.contains(Z.directory,O))return"local";return"global"}function U0(O){let Z={...O};if(!("tui"in Z))return Z;if(!s(Z.tui))return delete Z.tui,Z;let W=Z.tui;return delete Z.tui,{...W,...Z}}async function M0(O,Z){if(!O.plugin)return O;for(let W=0;W<O.plugin.length;W++)O.plugin[W]=await I.resolvePluginSpec(O.plugin[W],Z);return O}async function S(O,Z,W){let j=await z0(Z);if(O.result=c(O.result,j),!j.plugin?.length)return;let V=N0(Z,W),K=I.deduplicatePluginOrigins([...O.result.plugin_origins??[],...j.plugin.map(($)=>({spec:$,scope:V,source:Z}))]);O.result.plugin=K.map(($)=>$.spec),O.result.plugin_origins=K}var I0=B.fn("TuiConfig.loadState")(function*(O){let Z=yield*O0(O.directory);yield*B.promise(()=>k({directories:Z,cwd:O.directory}));let W=X.QITQODE_DISABLE_PROJECT_CONFIG?[]:yield*_0("tui",O.directory),j={result:{}};for(let $ of G(T.Path.config,"tui"))yield*B.promise(()=>S(j,$,O)).pipe(B.orDie);if(X.QITQODE_TUI_CONFIG){let $=X.QITQODE_TUI_CONFIG;yield*B.promise(()=>S(j,$,O)).pipe(B.orDie),u.debug("loaded custom tui config",{path:$})}for(let $ of W)yield*B.promise(()=>S(j,$,O)).pipe(B.orDie);let V=A(Z).filter(($)=>$.endsWith(".qitqode")||$===X.QITQODE_CONFIG_DIR);for(let $ of V){if(!$.endsWith(".qitqode")&&$!==X.QITQODE_CONFIG_DIR)continue;for(let J of G($,"tui"))yield*B.promise(()=>S(j,J,O)).pipe(B.orDie)}let K={...j.result.keybinds??{}};if(process.platform==="win32")K.terminal_suspend="none",K.input_undo??=A(["ctrl+z",...D.Keybinds.shape.input_undo.parse(void 0).split(",")]).join(",");return j.result.keybinds=D.Keybinds.parse(K),{config:j.result,dirs:j.result.plugin?.length?V:[]}}),$0=o.effect(C,B.gen(function*(){let O=yield*f,Z=yield*x.Service,W=yield*I0({directory:O}),j=yield*B.forEach(W.dirs,($)=>Z.install($,{add:[{name:"@qitqode/plugin",version:y?void 0:t}]}).pipe(B.forkScoped),{concurrency:"unbounded"}),V=B.fn("TuiConfig.get")(()=>B.succeed(W.config)),K=B.fn("TuiConfig.waitForDependencies")(()=>B.forEach(j,a.join,{concurrency:"unbounded"}).pipe(B.ignore(),B.asVoid));return C.of({get:V,waitForDependencies:K})}).pipe(B.withSpan("TuiConfig.layer"))),j0=$0.pipe(o.provide(x.defaultLayer),o.provide(d.defaultLayer)),{runPromise:w0}=i(C,j0);async function R0(){await w0((O)=>O.waitForDependencies())}async function C0(){return w0((O)=>O.get())}async function z0(O){let Z=await Z0(O);if(!Z)return{};return P0(Z,O).catch((W)=>{return u.warn("failed to load tui config",{path:O,error:W}),{}})}async function P0(O,Z){return e.substitute({text:O,type:"path",path:Z,missing:"empty"}).then((W)=>E.jsonc(W,Z)).then((W)=>{if(!s(W))return{};return E.schema(W0,U0(W),Z)}).then((W)=>M0(W,Z)).catch((W)=>{return u.warn("invalid tui config",{path:Z,error:W}),{}})}
3
+ export{W0 as t,C as u,$0 as v,j0 as w,R0 as x,C0 as y,h as z};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Ad as W$}from"./chunk-r48g0kaq.js";import{Cd as j$}from"./chunk-jz3aav8a.js";import{Pd as A$}from"./chunk-9xvctnjr.js";import{Mf as J$}from"./chunk-02txthqv.js";import{_f as Z$}from"./chunk-vzjcmwry.js";import"./chunk-6j0365q3.js";import"./chunk-7y3y3j51.js";import"./chunk-4aykrj51.js";import"./chunk-sbt7qmwm.js";import"./chunk-nfg7nt13.js";import"./chunk-ktmazmas.js";import"./chunk-qywwj58s.js";import{ih as hD,sh as MD}from"./chunk-va4davgy.js";import"./chunk-hg563h5r.js";import"./chunk-j1a64ade.js";import"./chunk-bd21p9zz.js";import"./chunk-p54bzjtv.js";import"./chunk-ha1w0xzh.js";import"./chunk-ecwz9nhs.js";import"./chunk-5rkmhzq0.js";import{$j as P,Sk as _$,Tk as U,Uj as sD,Vk as G$,_j as k}from"./chunk-7mhffm9f.js";import"./chunk-r012q335.js";import"./chunk-0z3z0gk1.js";import"./chunk-g7vkkmsk.js";import"./chunk-m8djypsy.js";import"./chunk-w7p2x973.js";import"./chunk-wmw2gne9.js";import"./chunk-y3n31nnx.js";import"./chunk-3z1y040p.js";import{mp as X$,pp as Y$}from"./chunk-kkvb2c2z.js";import"./chunk-3tdqsm5c.js";import"./chunk-a5zjrwqy.js";import"./chunk-fhng5her.js";import"./chunk-dkv2mg97.js";import"./chunk-bf146hz2.js";import{Yq as f$}from"./chunk-t488d66k.js";import"./chunk-cqtkxwd8.js";import"./chunk-srf73nm4.js";import"./chunk-yzdty5t9.js";import"./chunk-1p34bx7c.js";import"./chunk-q3x4x2tq.js";import"./chunk-7dckfame.js";import"./chunk-j1veq3zr.js";import"./chunk-0pvbk8ks.js";import"./chunk-tk3bve0x.js";import"./chunk-0w4v0fbs.js";import"./chunk-wf09j72q.js";import"./chunk-hbnr0j7h.js";import"./chunk-ep8zn49w.js";import"./chunk-f3kjp838.js";import"./chunk-tsn1jkr7.js";import{Ts as Q$,lt as w$,zt as H}from"./chunk-zk8n8hnh.js";import{Tt as kD}from"./chunk-1jh5p5qw.js";import"./chunk-kaeyhw2n.js";import"./chunk-f89gntcy.js";import"./chunk-bky5a42k.js";import{Pu as D}from"./chunk-r7xp0xcn.js";import"./chunk-6g3m7yxf.js";import"./chunk-v2kyarwz.js";import"./chunk-dkm7x8rj.js";import"./chunk-9pe4agdz.js";import"./chunk-kc3hpmr2.js";import{AP as ow}from"./chunk-hh4c02fh.js";var O={authenticate:"authenticate",initialize:"initialize",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},F={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"};var K$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),terminal:D.boolean().optional().default(!1)}),B$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),label:D.string().nullish(),name:D.string(),optional:D.boolean().optional().default(!1),secret:D.boolean().optional().default(!0)}),O$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),id:D.string(),name:D.string()}),N$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),id:D.string(),link:D.string().nullish(),name:D.string(),vars:D.array(B$)}),F$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),args:D.array(D.string()).optional(),description:D.string().nullish(),env:D.record(D.string(),D.string()).optional(),id:D.string(),name:D.string()}),L$=D.union([N$.and(D.object({type:D.literal("env_var")})),F$.and(D.object({type:D.literal("terminal")})),O$]),n=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),methodId:D.string()}),x$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),V$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),blob:D.string(),mimeType:D.string().nullish(),uri:D.string()}),H$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),P$=D.object({amount:D.number(),currency:D.string()}),k$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),terminalId:D.string()}),T$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),newText:D.string(),oldText:D.string().nullish(),path:D.string()}),vD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),name:D.string(),value:D.string()}),U$=D.union([D.literal(-32700),D.literal(-32600),D.literal(-32601),D.literal(-32602),D.literal(-32603),D.literal(-32800),D.literal(-32000),D.literal(-32002),D.number().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),ID=D.object({code:U$,data:D.unknown().optional(),message:D.string()}),qD=D.unknown(),SD=D.unknown(),RD=D.unknown(),b$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),readTextFile:D.boolean().optional().default(!1),writeTextFile:D.boolean().optional().default(!1)}),h$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),auth:K$.optional().default({terminal:!1}),fs:b$.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:D.boolean().optional().default(!1)}),cD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),name:D.string(),value:D.string()}),uD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),name:D.string(),title:D.string().nullish(),version:D.string()}),M$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),t=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cursor:D.string().nullish(),cwd:D.string().nullish()}),C$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),http:D.boolean().optional().default(!1),sse:D.boolean().optional().default(!1)}),E$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),headers:D.array(cD),name:D.string(),url:D.string()}),v$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),headers:D.array(cD),name:D.string(),url:D.string()}),I$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),args:D.array(D.string()),command:D.string(),env:D.array(vD),name:D.string()}),I=D.union([E$.and(D.object({type:D.literal("http")})),v$.and(D.object({type:D.literal("sse")})),I$]),o=D.string(),q$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),modelId:o,name:D.string()}),r=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I)}),gD=D.string(),S$=D.union([D.literal("allow_once"),D.literal("allow_always"),D.literal("reject_once"),D.literal("reject_always")]),R$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),kind:S$,name:D.string(),optionId:gD}),c$=D.union([D.literal("high"),D.literal("medium"),D.literal("low")]),u$=D.union([D.literal("pending"),D.literal("in_progress"),D.literal("completed")]),g$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.string(),priority:c$,status:u$}),l$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),entries:D.array(g$)}),d$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),audio:D.boolean().optional().default(!1),embeddedContext:D.boolean().optional().default(!1),image:D.boolean().optional().default(!1)}),lD=D.number().int().gte(0).lte(65535),z=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),clientCapabilities:h$.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:uD.nullish(),protocolVersion:lD}),i$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.string()}),m$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),T=D.union([D.number(),D.string()]).nullable(),sw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),requestId:T}),p$=D.enum(["assistant","user"]),E=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),audience:D.array(p$).nullish(),lastModified:D.string().nullish(),priority:D.number().nullish()}),n$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),data:D.string(),mimeType:D.string()}),t$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),data:D.string(),mimeType:D.string(),uri:D.string().nullish()}),o$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),description:D.string().nullish(),mimeType:D.string().nullish(),name:D.string(),size:D.number().nullish(),title:D.string().nullish(),uri:D.string()}),r$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),optionId:gD}),z$=D.union([D.object({outcome:D.literal("cancelled")}),r$.and(D.object({outcome:D.literal("selected")}))]),a$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),outcome:z$}),s$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),e$=D.object({currentValue:D.boolean()}),Dw=D.string(),dD=D.string(),$w=D.union([D.literal("mode"),D.literal("model"),D.literal("thought_level"),D.string()]),a=D.string(),iD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),name:D.string(),value:a}),ww=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),group:Dw,name:D.string(),options:D.array(iD)}),Qw=D.union([D.array(iD),D.array(ww)]),fw=D.object({currentValue:a,options:Qw}),M=D.intersection(D.union([fw.and(D.object({type:D.literal("select")})),e$.and(D.object({type:D.literal("boolean")}))]),D.object({_meta:D.record(D.string(),D.unknown()).nullish(),category:$w.nullish(),description:D.string().nullish(),id:dD,name:D.string()})),_w=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M)}),Gw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),N=D.string(),s=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N}),ew=D.object({method:D.string(),params:D.union([s,qD]).nullish()}),e=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N}),DD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),args:D.array(D.string()).optional(),command:D.string(),cwd:D.string().nullish(),env:D.array(vD).optional(),outputByteLimit:D.number().nullish(),sessionId:N}),$D=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I).optional(),sessionId:N}),wD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),QD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I),sessionId:N}),fD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),limit:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:D.string(),sessionId:N}),_D=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),GD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I).optional(),sessionId:N}),Jw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),sessionId:N,title:D.string().nullish(),updatedAt:D.string().nullish()}),Xw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),nextCursor:D.string().nullish(),sessions:D.array(Jw)}),Yw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),title:D.string().nullish(),updatedAt:D.string().nullish()}),Zw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),q=D.string(),jw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),currentModeId:q}),Aw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),id:q,name:D.string()}),S=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),availableModes:D.array(Aw),currentModeId:q}),R=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),availableModels:D.array(q$),currentModelId:o}),Ww=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish(),sessionId:N}),yw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish()}),Kw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish(),sessionId:N}),Bw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish()}),Ow=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),Nw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),close:s$.nullish(),fork:Gw.nullish(),list:Zw.nullish(),resume:Ow.nullish()}),Fw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),loadSession:D.boolean().optional().default(!1),mcpCapabilities:C$.optional().default({http:!1,sse:!1}),promptCapabilities:d$.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:Nw.optional().default({})}),Lw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),agentCapabilities:Fw.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:uD.nullish(),authMethods:D.array(L$).optional().default([]),protocolVersion:lD}),JD=D.intersection(D.union([D.object({type:D.literal("boolean"),value:D.boolean()}),D.object({value:a})]),D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configId:dD,sessionId:N})),xw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M)}),XD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),modeId:q,sessionId:N}),Vw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),YD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),modelId:o,sessionId:N}),Hw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),Pw=D.union([D.literal("end_turn"),D.literal("max_tokens"),D.literal("max_turn_requests"),D.literal("refusal"),D.literal("cancelled")]),kw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),terminalId:D.string()}),Tw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),exitCode:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:D.string().nullish()}),ZD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),Uw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),exitStatus:Tw.nullish(),output:D.string(),truncated:D.boolean()}),bw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),text:D.string()}),hw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),mimeType:D.string().nullish(),text:D.string(),uri:D.string()}),Mw=D.union([hw,V$]),Cw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),resource:Mw}),jD=D.union([bw.and(D.object({type:D.literal("text")})),t$.and(D.object({type:D.literal("image")})),n$.and(D.object({type:D.literal("audio")})),o$.and(D.object({type:D.literal("resource_link")})),Cw.and(D.object({type:D.literal("resource")}))]),Ew=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:jD}),p=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:jD,messageId:D.string().nullish()}),AD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),messageId:D.string().nullish(),prompt:D.array(jD),sessionId:N}),DQ=D.object({id:T,method:D.string(),params:D.union([z,n,r,QD,t,$D,GD,e,XD,JD,AD,YD,SD]).nullish()}),mD=D.union([Ew.and(D.object({type:D.literal("content")})),T$.and(D.object({type:D.literal("diff")})),kw.and(D.object({type:D.literal("terminal")}))]),pD=D.string(),nD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),line:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:D.string()}),tD=D.union([D.literal("pending"),D.literal("in_progress"),D.literal("completed"),D.literal("failed")]),oD=D.union([D.literal("read"),D.literal("edit"),D.literal("delete"),D.literal("move"),D.literal("search"),D.literal("execute"),D.literal("think"),D.literal("fetch"),D.literal("switch_mode"),D.literal("other")]),vw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.array(mD).optional(),kind:oD.optional(),locations:D.array(nD).optional(),rawInput:D.unknown().optional(),rawOutput:D.unknown().optional(),status:tD.optional(),title:D.string(),toolCallId:pD}),rD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.array(mD).nullish(),kind:oD.nullish(),locations:D.array(nD).nullish(),rawInput:D.unknown().optional(),rawOutput:D.unknown().optional(),status:tD.nullish(),title:D.string().nullish(),toolCallId:pD}),WD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),options:D.array(R$),sessionId:N,toolCall:rD}),Iw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),hint:D.string()}),qw=Iw,Sw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string(),input:qw.nullish(),name:D.string()}),Rw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),availableCommands:D.array(Sw)}),cw=D.object({cachedReadTokens:D.number().nullish(),cachedWriteTokens:D.number().nullish(),inputTokens:D.number(),outputTokens:D.number(),thoughtTokens:D.number().nullish(),totalTokens:D.number()}),uw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),stopReason:Pw,usage:cw.nullish(),userMessageId:D.string().nullish()}),$Q=D.union([D.object({id:T,result:D.union([Lw,x$,Kw,yw,Xw,Ww,Bw,H$,Vw,xw,uw,Hw,RD])}),D.object({error:ID,id:T})]),gw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cost:P$.nullish(),size:D.number(),used:D.number()}),lw=D.union([p.and(D.object({sessionUpdate:D.literal("user_message_chunk")})),p.and(D.object({sessionUpdate:D.literal("agent_message_chunk")})),p.and(D.object({sessionUpdate:D.literal("agent_thought_chunk")})),vw.and(D.object({sessionUpdate:D.literal("tool_call")})),rD.and(D.object({sessionUpdate:D.literal("tool_call_update")})),l$.and(D.object({sessionUpdate:D.literal("plan")})),Rw.and(D.object({sessionUpdate:D.literal("available_commands_update")})),jw.and(D.object({sessionUpdate:D.literal("current_mode_update")})),_w.and(D.object({sessionUpdate:D.literal("config_option_update")})),Yw.and(D.object({sessionUpdate:D.literal("session_info_update")})),gw.and(D.object({sessionUpdate:D.literal("usage_update")}))]),yD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,update:lw}),wQ=D.object({method:D.string(),params:D.union([yD,qD]).nullish()}),KD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),dw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),exitCode:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:D.string().nullish()}),BD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.string(),path:D.string(),sessionId:N}),QQ=D.object({id:T,method:D.string(),params:D.union([BD,fD,WD,DD,ZD,_D,KD,wD,SD]).nullish()}),iw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),fQ=D.union([D.object({id:T,result:D.union([iw,i$,a$,k$,Uw,m$,dw,M$,RD])}),D.object({error:ID,id:T})]);function zD($,Q){let w=new TextEncoder,f=new TextDecoder,X=new ReadableStream({async start(_){let J="",j=Q.getReader();try{while(!0){let{value:B,done:Y}=await j.read();if(Y)break;if(!B)continue;J+=f.decode(B,{stream:!0});let Z=J.split(`
2
+ import{Bd as W$}from"./chunk-rgecc41f.js";import{Dd as j$}from"./chunk-7q5srx7q.js";import{Qd as A$}from"./chunk-g4qwkcdv.js";import{Nf as J$}from"./chunk-j9s62g01.js";import{$f as Z$}from"./chunk-bqs6a1ts.js";import"./chunk-cjxp72dv.js";import"./chunk-2rxt1s22.js";import"./chunk-w98r39gd.js";import"./chunk-atd0q4v8.js";import"./chunk-nfg7nt13.js";import"./chunk-aqm597px.js";import"./chunk-8gy99gfb.js";import{kh as hD,uh as MD}from"./chunk-87x607rz.js";import"./chunk-9w5rx0fb.js";import"./chunk-wb69d52j.js";import"./chunk-pfn1db1m.js";import"./chunk-h56jxxvj.js";import"./chunk-x36jhtex.js";import"./chunk-c1ypbbka.js";import"./chunk-qnqqrvvs.js";import{$j as k,Tk as _$,Uk as U,Vj as sD,Wk as G$,ak as P}from"./chunk-3f054f69.js";import"./chunk-26qt44f1.js";import"./chunk-0ke6x10y.js";import"./chunk-meaybtcc.js";import"./chunk-rmsqb6r4.js";import"./chunk-3j7skhxg.js";import"./chunk-4pssh5d3.js";import"./chunk-9dpn4792.js";import"./chunk-pf7cj4jd.js";import{Pn as X$,Sn as Y$}from"./chunk-9r6bvkp4.js";import"./chunk-amx3x4kd.js";import"./chunk-b50t4jc5.js";import"./chunk-nf8gkxbk.js";import"./chunk-zny2qaqa.js";import"./chunk-9va5eh9s.js";import"./chunk-mkyrg7gt.js";import{Cp as f$}from"./chunk-7v4fzkbb.js";import"./chunk-cqtkxwd8.js";import"./chunk-pk0tytcm.js";import"./chunk-ww8ear80.js";import"./chunk-kyny0t2g.js";import"./chunk-3e8p4a3y.js";import"./chunk-qpm5afdz.js";import"./chunk-jtrcnpm7.js";import"./chunk-gaen9ya4.js";import"./chunk-dd11kryy.js";import"./chunk-msm3r7ny.js";import"./chunk-e075v4e9.js";import"./chunk-jv98gw88.js";import"./chunk-jhq5bvhs.js";import"./chunk-xw283h2r.js";import"./chunk-8cty50g7.js";import{Cs as H,os as w$,xr as Q$}from"./chunk-v7ah9gg0.js";import{Ws as kD}from"./chunk-d0m7nbbx.js";import"./chunk-vfj5nwab.js";import"./chunk-7w84hfxs.js";import{ut as D}from"./chunk-ym4ydwrz.js";import"./chunk-vmgknvxs.js";import"./chunk-p409grvp.js";import"./chunk-ag9thqkv.js";import"./chunk-qnv2v02g.js";import"./chunk-7fx6x8x9.js";import{fO as ow}from"./chunk-0rmmg3g4.js";var O={authenticate:"authenticate",initialize:"initialize",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},F={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"};var K$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),terminal:D.boolean().optional().default(!1)}),B$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),label:D.string().nullish(),name:D.string(),optional:D.boolean().optional().default(!1),secret:D.boolean().optional().default(!0)}),O$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),id:D.string(),name:D.string()}),N$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),id:D.string(),link:D.string().nullish(),name:D.string(),vars:D.array(B$)}),F$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),args:D.array(D.string()).optional(),description:D.string().nullish(),env:D.record(D.string(),D.string()).optional(),id:D.string(),name:D.string()}),L$=D.union([N$.and(D.object({type:D.literal("env_var")})),F$.and(D.object({type:D.literal("terminal")})),O$]),n=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),methodId:D.string()}),x$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),V$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),blob:D.string(),mimeType:D.string().nullish(),uri:D.string()}),H$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),P$=D.object({amount:D.number(),currency:D.string()}),k$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),terminalId:D.string()}),T$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),newText:D.string(),oldText:D.string().nullish(),path:D.string()}),vD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),name:D.string(),value:D.string()}),U$=D.union([D.literal(-32700),D.literal(-32600),D.literal(-32601),D.literal(-32602),D.literal(-32603),D.literal(-32800),D.literal(-32000),D.literal(-32002),D.number().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),ID=D.object({code:U$,data:D.unknown().optional(),message:D.string()}),qD=D.unknown(),SD=D.unknown(),RD=D.unknown(),b$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),readTextFile:D.boolean().optional().default(!1),writeTextFile:D.boolean().optional().default(!1)}),h$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),auth:K$.optional().default({terminal:!1}),fs:b$.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:D.boolean().optional().default(!1)}),cD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),name:D.string(),value:D.string()}),uD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),name:D.string(),title:D.string().nullish(),version:D.string()}),M$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),t=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cursor:D.string().nullish(),cwd:D.string().nullish()}),C$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),http:D.boolean().optional().default(!1),sse:D.boolean().optional().default(!1)}),E$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),headers:D.array(cD),name:D.string(),url:D.string()}),v$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),headers:D.array(cD),name:D.string(),url:D.string()}),I$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),args:D.array(D.string()),command:D.string(),env:D.array(vD),name:D.string()}),I=D.union([E$.and(D.object({type:D.literal("http")})),v$.and(D.object({type:D.literal("sse")})),I$]),o=D.string(),q$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),modelId:o,name:D.string()}),r=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I)}),gD=D.string(),S$=D.union([D.literal("allow_once"),D.literal("allow_always"),D.literal("reject_once"),D.literal("reject_always")]),R$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),kind:S$,name:D.string(),optionId:gD}),c$=D.union([D.literal("high"),D.literal("medium"),D.literal("low")]),u$=D.union([D.literal("pending"),D.literal("in_progress"),D.literal("completed")]),g$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.string(),priority:c$,status:u$}),l$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),entries:D.array(g$)}),d$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),audio:D.boolean().optional().default(!1),embeddedContext:D.boolean().optional().default(!1),image:D.boolean().optional().default(!1)}),lD=D.number().int().gte(0).lte(65535),z=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),clientCapabilities:h$.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:uD.nullish(),protocolVersion:lD}),i$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.string()}),m$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),T=D.union([D.number(),D.string()]).nullable(),sw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),requestId:T}),p$=D.enum(["assistant","user"]),E=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),audience:D.array(p$).nullish(),lastModified:D.string().nullish(),priority:D.number().nullish()}),n$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),data:D.string(),mimeType:D.string()}),t$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),data:D.string(),mimeType:D.string(),uri:D.string().nullish()}),o$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),description:D.string().nullish(),mimeType:D.string().nullish(),name:D.string(),size:D.number().nullish(),title:D.string().nullish(),uri:D.string()}),r$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),optionId:gD}),z$=D.union([D.object({outcome:D.literal("cancelled")}),r$.and(D.object({outcome:D.literal("selected")}))]),a$=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),outcome:z$}),s$=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),e$=D.object({currentValue:D.boolean()}),Dw=D.string(),dD=D.string(),$w=D.union([D.literal("mode"),D.literal("model"),D.literal("thought_level"),D.string()]),a=D.string(),iD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),name:D.string(),value:a}),ww=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),group:Dw,name:D.string(),options:D.array(iD)}),Qw=D.union([D.array(iD),D.array(ww)]),fw=D.object({currentValue:a,options:Qw}),M=D.intersection(D.union([fw.and(D.object({type:D.literal("select")})),e$.and(D.object({type:D.literal("boolean")}))]),D.object({_meta:D.record(D.string(),D.unknown()).nullish(),category:$w.nullish(),description:D.string().nullish(),id:dD,name:D.string()})),_w=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M)}),Gw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),N=D.string(),s=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N}),ew=D.object({method:D.string(),params:D.union([s,qD]).nullish()}),e=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N}),DD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),args:D.array(D.string()).optional(),command:D.string(),cwd:D.string().nullish(),env:D.array(vD).optional(),outputByteLimit:D.number().nullish(),sessionId:N}),$D=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I).optional(),sessionId:N}),wD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),QD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I),sessionId:N}),fD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),limit:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:D.string(),sessionId:N}),_D=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),GD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),mcpServers:D.array(I).optional(),sessionId:N}),Jw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cwd:D.string(),sessionId:N,title:D.string().nullish(),updatedAt:D.string().nullish()}),Xw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),nextCursor:D.string().nullish(),sessions:D.array(Jw)}),Yw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),title:D.string().nullish(),updatedAt:D.string().nullish()}),Zw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),q=D.string(),jw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),currentModeId:q}),Aw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string().nullish(),id:q,name:D.string()}),S=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),availableModes:D.array(Aw),currentModeId:q}),R=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),availableModels:D.array(q$),currentModelId:o}),Ww=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish(),sessionId:N}),yw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish()}),Kw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish(),sessionId:N}),Bw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M).nullish(),models:R.nullish(),modes:S.nullish()}),Ow=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),Nw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),close:s$.nullish(),fork:Gw.nullish(),list:Zw.nullish(),resume:Ow.nullish()}),Fw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),loadSession:D.boolean().optional().default(!1),mcpCapabilities:C$.optional().default({http:!1,sse:!1}),promptCapabilities:d$.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:Nw.optional().default({})}),Lw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),agentCapabilities:Fw.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:uD.nullish(),authMethods:D.array(L$).optional().default([]),protocolVersion:lD}),JD=D.intersection(D.union([D.object({type:D.literal("boolean"),value:D.boolean()}),D.object({value:a})]),D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configId:dD,sessionId:N})),xw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),configOptions:D.array(M)}),XD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),modeId:q,sessionId:N}),Vw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),YD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),modelId:o,sessionId:N}),Hw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),Pw=D.union([D.literal("end_turn"),D.literal("max_tokens"),D.literal("max_turn_requests"),D.literal("refusal"),D.literal("cancelled")]),kw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),terminalId:D.string()}),Tw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),exitCode:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:D.string().nullish()}),ZD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),Uw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),exitStatus:Tw.nullish(),output:D.string(),truncated:D.boolean()}),bw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),text:D.string()}),hw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),mimeType:D.string().nullish(),text:D.string(),uri:D.string()}),Mw=D.union([hw,V$]),Cw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),annotations:E.nullish(),resource:Mw}),jD=D.union([bw.and(D.object({type:D.literal("text")})),t$.and(D.object({type:D.literal("image")})),n$.and(D.object({type:D.literal("audio")})),o$.and(D.object({type:D.literal("resource_link")})),Cw.and(D.object({type:D.literal("resource")}))]),Ew=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:jD}),p=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:jD,messageId:D.string().nullish()}),AD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),messageId:D.string().nullish(),prompt:D.array(jD),sessionId:N}),DQ=D.object({id:T,method:D.string(),params:D.union([z,n,r,QD,t,$D,GD,e,XD,JD,AD,YD,SD]).nullish()}),mD=D.union([Ew.and(D.object({type:D.literal("content")})),T$.and(D.object({type:D.literal("diff")})),kw.and(D.object({type:D.literal("terminal")}))]),pD=D.string(),nD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),line:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:D.string()}),tD=D.union([D.literal("pending"),D.literal("in_progress"),D.literal("completed"),D.literal("failed")]),oD=D.union([D.literal("read"),D.literal("edit"),D.literal("delete"),D.literal("move"),D.literal("search"),D.literal("execute"),D.literal("think"),D.literal("fetch"),D.literal("switch_mode"),D.literal("other")]),vw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.array(mD).optional(),kind:oD.optional(),locations:D.array(nD).optional(),rawInput:D.unknown().optional(),rawOutput:D.unknown().optional(),status:tD.optional(),title:D.string(),toolCallId:pD}),rD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.array(mD).nullish(),kind:oD.nullish(),locations:D.array(nD).nullish(),rawInput:D.unknown().optional(),rawOutput:D.unknown().optional(),status:tD.nullish(),title:D.string().nullish(),toolCallId:pD}),WD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),options:D.array(R$),sessionId:N,toolCall:rD}),Iw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),hint:D.string()}),qw=Iw,Sw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),description:D.string(),input:qw.nullish(),name:D.string()}),Rw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),availableCommands:D.array(Sw)}),cw=D.object({cachedReadTokens:D.number().nullish(),cachedWriteTokens:D.number().nullish(),inputTokens:D.number(),outputTokens:D.number(),thoughtTokens:D.number().nullish(),totalTokens:D.number()}),uw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),stopReason:Pw,usage:cw.nullish(),userMessageId:D.string().nullish()}),$Q=D.union([D.object({id:T,result:D.union([Lw,x$,Kw,yw,Xw,Ww,Bw,H$,Vw,xw,uw,Hw,RD])}),D.object({error:ID,id:T})]),gw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),cost:P$.nullish(),size:D.number(),used:D.number()}),lw=D.union([p.and(D.object({sessionUpdate:D.literal("user_message_chunk")})),p.and(D.object({sessionUpdate:D.literal("agent_message_chunk")})),p.and(D.object({sessionUpdate:D.literal("agent_thought_chunk")})),vw.and(D.object({sessionUpdate:D.literal("tool_call")})),rD.and(D.object({sessionUpdate:D.literal("tool_call_update")})),l$.and(D.object({sessionUpdate:D.literal("plan")})),Rw.and(D.object({sessionUpdate:D.literal("available_commands_update")})),jw.and(D.object({sessionUpdate:D.literal("current_mode_update")})),_w.and(D.object({sessionUpdate:D.literal("config_option_update")})),Yw.and(D.object({sessionUpdate:D.literal("session_info_update")})),gw.and(D.object({sessionUpdate:D.literal("usage_update")}))]),yD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,update:lw}),wQ=D.object({method:D.string(),params:D.union([yD,qD]).nullish()}),KD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),sessionId:N,terminalId:D.string()}),dw=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),exitCode:D.number().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:D.string().nullish()}),BD=D.object({_meta:D.record(D.string(),D.unknown()).nullish(),content:D.string(),path:D.string(),sessionId:N}),QQ=D.object({id:T,method:D.string(),params:D.union([BD,fD,WD,DD,ZD,_D,KD,wD,SD]).nullish()}),iw=D.object({_meta:D.record(D.string(),D.unknown()).nullish()}),fQ=D.union([D.object({id:T,result:D.union([iw,i$,a$,k$,Uw,m$,dw,M$,RD])}),D.object({error:ID,id:T})]);function zD($,Q){let w=new TextEncoder,f=new TextDecoder,X=new ReadableStream({async start(_){let J="",j=Q.getReader();try{while(!0){let{value:B,done:Y}=await j.read();if(Y)break;if(!B)continue;J+=f.decode(B,{stream:!0});let Z=J.split(`
3
3
  `);J=Z.pop()||"";for(let A of Z){let y=A.trim();if(y)try{let W=JSON.parse(y);_.enqueue(W)}catch(W){console.error("Failed to parse JSON message:",y,W)}}}}finally{j.releaseLock(),_.close()}}}),G=new WritableStream({async write(_){let J=JSON.stringify(_)+`
4
4
  `,j=$.getWriter();try{await j.write(w.encode(J))}finally{j.releaseLock()}}});return{readable:X,writable:G}}class OD{#D;constructor($,Q){let w=$(this),f=async(G,_)=>{switch(G){case O.initialize:{let J=z.parse(_);return w.initialize(J)}case O.session_new:{let J=r.parse(_);return w.newSession(J)}case O.session_load:{if(!w.loadSession)throw K.methodNotFound(G);let J=QD.parse(_);return w.loadSession(J)}case O.session_list:{if(!w.listSessions)throw K.methodNotFound(G);let J=t.parse(_);return w.listSessions(J)}case O.session_fork:{if(!w.unstable_forkSession)throw K.methodNotFound(G);let J=$D.parse(_);return w.unstable_forkSession(J)}case O.session_resume:{if(!w.unstable_resumeSession)throw K.methodNotFound(G);let J=GD.parse(_);return w.unstable_resumeSession(J)}case O.session_close:{if(!w.unstable_closeSession)throw K.methodNotFound(G);let J=e.parse(_);return w.unstable_closeSession(J)}case O.session_set_mode:{if(!w.setSessionMode)throw K.methodNotFound(G);let J=XD.parse(_);return await w.setSessionMode(J)??{}}case O.authenticate:{let J=n.parse(_);return await w.authenticate(J)??{}}case O.session_prompt:{let J=AD.parse(_);return w.prompt(J)}case O.session_set_model:{if(!w.unstable_setSessionModel)throw K.methodNotFound(G);let J=YD.parse(_);return await w.unstable_setSessionModel(J)??{}}case O.session_set_config_option:{if(!w.setSessionConfigOption)throw K.methodNotFound(G);let J=JD.parse(_);return w.setSessionConfigOption(J)}default:if(w.extMethod)return w.extMethod(G,_);throw K.methodNotFound(G)}},X=async(G,_)=>{switch(G){case O.session_cancel:{let J=s.parse(_);return w.cancel(J)}default:if(w.extNotification)return w.extNotification(G,_);throw K.methodNotFound(G)}};this.#D=new ND(f,X,Q)}async sessionUpdate($){return await this.#D.sendNotification(F.session_update,$)}async requestPermission($){return await this.#D.sendRequest(F.session_request_permission,$)}async readTextFile($){return await this.#D.sendRequest(F.fs_read_text_file,$)}async writeTextFile($){return await this.#D.sendRequest(F.fs_write_text_file,$)??{}}async createTerminal($){let Q=await this.#D.sendRequest(F.terminal_create,$);return new aD(Q.terminalId,$.sessionId,this.#D)}async extMethod($,Q){return await this.#D.sendRequest($,Q)}async extNotification($,Q){return await this.#D.sendNotification($,Q)}get signal(){return this.#D.signal}get closed(){return this.#D.closed}}class aD{id;#D;#$;constructor($,Q,w){this.id=$,this.#D=Q,this.#$=w}async currentOutput(){return await this.#$.sendRequest(F.terminal_output,{sessionId:this.#D,terminalId:this.id})}async waitForExit(){return await this.#$.sendRequest(F.terminal_wait_for_exit,{sessionId:this.#D,terminalId:this.id})}async kill(){return await this.#$.sendRequest(F.terminal_kill,{sessionId:this.#D,terminalId:this.id})??{}}async release(){return await this.#$.sendRequest(F.terminal_release,{sessionId:this.#D,terminalId:this.id})??{}}async[Symbol.asyncDispose](){await this.release()}}class pw{#D;constructor($,Q){let w=$(this),f=async(G,_)=>{switch(G){case F.fs_write_text_file:{let J=BD.parse(_);return w.writeTextFile?.(J)}case F.fs_read_text_file:{let J=fD.parse(_);return w.readTextFile?.(J)}case F.session_request_permission:{let J=WD.parse(_);return w.requestPermission(J)}case F.terminal_create:{let J=DD.parse(_);return w.createTerminal?.(J)}case F.terminal_output:{let J=ZD.parse(_);return w.terminalOutput?.(J)}case F.terminal_release:{let J=_D.parse(_);return await w.releaseTerminal?.(J)??{}}case F.terminal_wait_for_exit:{let J=KD.parse(_);return w.waitForTerminalExit?.(J)}case F.terminal_kill:{let J=wD.parse(_);return await w.killTerminal?.(J)??{}}default:if(w.extMethod)return w.extMethod(G,_);throw K.methodNotFound(G)}},X=async(G,_)=>{switch(G){case F.session_update:{let J=yD.parse(_);return w.sessionUpdate(J)}default:if(w.extNotification)return w.extNotification(G,_);throw K.methodNotFound(G)}};this.#D=new ND(f,X,Q)}async initialize($){return await this.#D.sendRequest(O.initialize,$)}async newSession($){return await this.#D.sendRequest(O.session_new,$)}async loadSession($){return await this.#D.sendRequest(O.session_load,$)??{}}async unstable_forkSession($){return await this.#D.sendRequest(O.session_fork,$)}async listSessions($){return await this.#D.sendRequest(O.session_list,$)}async unstable_resumeSession($){return await this.#D.sendRequest(O.session_resume,$)}async unstable_closeSession($){return await this.#D.sendRequest(O.session_close,$)}async setSessionMode($){return await this.#D.sendRequest(O.session_set_mode,$)??{}}async unstable_setSessionModel($){return await this.#D.sendRequest(O.session_set_model,$)??{}}async setSessionConfigOption($){return await this.#D.sendRequest(O.session_set_config_option,$)}async authenticate($){return await this.#D.sendRequest(O.authenticate,$)??{}}async prompt($){return await this.#D.sendRequest(O.session_prompt,$)}async cancel($){return await this.#D.sendNotification(O.session_cancel,$)}async extMethod($,Q){return await this.#D.sendRequest($,Q)}async extNotification($,Q){return await this.#D.sendNotification($,Q)}get signal(){return this.#D.signal}get closed(){return this.#D.closed}}class ND{#D=new Map;#$=0;#G;#J;#Q;#f=Promise.resolve();#_=new AbortController;#X;constructor($,Q,w){this.#G=$,this.#J=Q,this.#Q=w,this.#X=new Promise((f)=>{this.#_.signal.addEventListener("abort",()=>f())}),this.#Y()}get signal(){return this.#_.signal}get closed(){return this.#X}async#Y(){let $=this.#Q.readable.getReader();try{while(!0){let{value:Q,done:w}=await $.read();if(w)break;if(!Q)continue;try{this.#Z(Q)}catch(f){if(console.error("Unexpected error during message processing:",Q,f),"id"in Q&&Q.id!==void 0)this.#w({jsonrpc:"2.0",id:Q.id,error:{code:-32700,message:"Parse error"}})}}}finally{$.releaseLock(),this.#_.abort()}}async#Z($){if("method"in $&&"id"in $){let Q=await this.#j($.method,$.params);if("error"in Q)console.error("Error handling request",$,Q.error);await this.#w({jsonrpc:"2.0",id:$.id,...Q})}else if("method"in $){let Q=await this.#A($.method,$.params);if("error"in Q)console.error("Error handling notification",$,Q.error)}else if("id"in $)this.#W($);else console.error("Invalid message",{message:$})}async#j($,Q){try{return{result:await this.#G($,Q)??null}}catch(w){if(w instanceof K)return w.toResult();if(w instanceof D.ZodError)return K.invalidParams(w.format()).toResult();let f;if(w instanceof Error)f=w.message;else if(typeof w==="object"&&w!=null&&"message"in w&&typeof w.message==="string")f=w.message;try{return K.internalError(f?JSON.parse(f):{}).toResult()}catch{return K.internalError({details:f}).toResult()}}}async#A($,Q){try{return await this.#J($,Q),{result:null}}catch(w){if(w instanceof K)return w.toResult();if(w instanceof D.ZodError)return K.invalidParams(w.format()).toResult();let f;if(w instanceof Error)f=w.message;else if(typeof w==="object"&&w!=null&&"message"in w&&typeof w.message==="string")f=w.message;try{return K.internalError(f?JSON.parse(f):{}).toResult()}catch{return K.internalError({details:f}).toResult()}}}#W($){let Q=this.#D.get($.id);if(Q){if("result"in $)Q.resolve($.result);else if("error"in $)Q.reject($.error);this.#D.delete($.id)}else console.error("Got response to unknown request",$.id)}async sendRequest($,Q){let w=this.#$++,f=new Promise((X,G)=>{this.#D.set(w,{resolve:X,reject:G})});return await this.#w({jsonrpc:"2.0",id:w,method:$,params:Q}),f}async sendNotification($,Q){await this.#w({jsonrpc:"2.0",method:$,params:Q})}async#w($){return this.#f=this.#f.then(async()=>{let Q=this.#Q.writable.getWriter();try{await Q.write($)}finally{Q.releaseLock()}}).catch((Q)=>{console.error("ACP write error:",Q)}),this.#f}}class K extends Error{code;data;constructor($,Q,w){super(Q);this.code=$,this.name="RequestError",this.data=w}static parseError($,Q){return new K(-32700,`Parse error${Q?`: ${Q}`:""}`,$)}static invalidRequest($,Q){return new K(-32600,`Invalid request${Q?`: ${Q}`:""}`,$)}static methodNotFound($){return new K(-32601,`"Method not found": ${$}`,{method:$})}static invalidParams($,Q){return new K(-32602,`Invalid params${Q?`: ${Q}`:""}`,$)}static internalError($,Q){return new K(-32603,`Internal error${Q?`: ${Q}`:""}`,$)}static authRequired($,Q){return new K(-32000,`Authentication required${Q?`: ${Q}`:""}`,$)}static resourceNotFound($){return new K(-32002,`Resource not found${$?`: ${$}`:""}`,$&&{uri:$})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}var v={};ow(v,{init:()=>zw,Agent:()=>CD,ACP:()=>v});var FD=H.create({service:"acp-session-manager"});class LD{sessions=new Map;sdk;constructor($){this.sdk=$}tryGet($){return this.sessions.get($)}async create($,Q,w){let X=(await this.sdk.session.create({directory:$},{throwOnError:!0}).then((J)=>J.data)).id,_={id:X,cwd:$,mcpServers:Q,createdAt:new Date,model:w};return FD.info("creating_session",{state:_}),this.sessions.set(X,_),_}async load($,Q,w,f){let X=await this.sdk.session.get({sessionID:$,directory:Q},{throwOnError:!0}).then((J)=>J.data),G=f,_={id:$,cwd:Q,mcpServers:w,createdAt:new Date(X.time.created),model:G};return FD.info("loading_session",{state:_}),this.sessions.set($,_),_}get($){let Q=this.sessions.get($);if(!Q)throw FD.error("session not found",{sessionId:$}),K.invalidParams(JSON.stringify({error:`Session not found: ${$}`}));return Q}getModel($){return this.get($).model}setModel($,Q){let w=this.get($);return w.model=Q,this.sessions.set($,w),w}getVariant($){return this.get($).variant}setVariant($,Q){let w=this.get($);return w.variant=Q,this.sessions.set($,w),w}setMode($,Q){let w=this.get($);return w.modeId=Q,this.sessions.set($,w),w}}import{pathToFileURL as c}from"url";var nw=H.create({service:"acp-message-translator"}),tw="default";function b($){switch($.toLocaleLowerCase()){case"bash":return"execute";case"webfetch":return"fetch";case"edit":case"patch":case"write":return"edit";case"grep":case"glob":case"context7_resolve_library_id":case"context7_get_library_docs":return"search";case"read":return"read";default:return"other"}}function u($,Q){switch($.toLocaleLowerCase()){case"read":case"edit":case"write":return Q.filePath?[{path:Q.filePath}]:[];case"glob":case"grep":return Q.path?[{path:Q.path}]:[];case"bash":return[];default:return[]}}function g($){try{if($.startsWith("file://")){let Q=$.slice(7),w=Q.split("/").pop()||Q;return{type:"file",url:$,filename:w,mime:"text/plain"}}if($.startsWith("zed://")){let w=new URL($).searchParams.get("path");if(w){let f=w.split("/").pop()||w;return{type:"file",url:c(w).href,filename:f,mime:"text/plain"}}}return{type:"text",text:$}}catch{return{type:"text",text:$}}}function eD($,Q){let w=sD($,Q);if(w===!1){nw.error("Failed to apply unified diff (context mismatch)");return}return w}function xD($){if($.tool!=="bash")return;if(!("metadata"in $.state)||!$.state.metadata||typeof $.state.metadata!=="object")return;let Q=$.state.metadata.output;if(typeof Q!=="string")return;return Q}function l($){return[...$].sort((Q,w)=>{let f=Q.name.toLowerCase(),X=w.name.toLowerCase();if(f<X)return-1;if(f>X)return 1;return 0})}function VD($,Q){let w=$.find((X)=>X.id===Q.providerID);if(!w)return[];let f=w.models[Q.modelID];if(!f?.variants)return[];return Object.keys(f.variants)}function D$($,Q={}){let w=Q.includeVariants??!1;return $.flatMap((f)=>{let X=Object.values(f.models);return U.sort(X).flatMap((_)=>{let J={modelId:`${f.id}/${_.id}`,name:`${f.name}/${_.name}`};if(!w||!_.variants)return[J];let B=Object.keys(_.variants).filter((Y)=>Y!==tw).map((Y)=>({modelId:`${f.id}/${_.id}/${Y}`,name:`${f.name}/${_.name} (${Y})`}));return[J,...B]})})}function d($,Q,w,f){let X=`${$.providerID}/${$.modelID}`;if(!f||!Q||!w.includes(Q))return X;return`${X}/${Q}`}function HD($){return{opencode:{modelId:`${$.model.providerID}/${$.model.modelID}`,variant:$.variant??null,availableVariants:$.availableVariants}}}function PD($,Q){let w=U.parseModel($),f=Q.find((G)=>G.id===w.providerID);if(!f)return{model:w,variant:void 0};if(f.models[w.modelID])return{model:w,variant:void 0};let X=w.modelID.split("/");if(X.length>1){let G=X[X.length-1],_=X.slice(0,-1).join("/"),J=f.models[_];if(J?.variants&&G in J.variants)return{model:{providerID:w.providerID,modelID:P.make(_)},variant:G}}return{model:w,variant:void 0}}function i($){let Q=[{id:"model",name:"Model",category:"model",type:"select",currentValue:$.currentModelId,options:$.availableModels.map((w)=>({value:w.modelId,name:w.name}))}];if($.modes)Q.push({id:"mode",name:"Session Mode",category:"mode",type:"select",currentValue:$.modes.currentModeId,options:$.modes.availableModes.map((w)=>({value:w.id,name:w.name,...w.description?{description:w.description}:{}}))});return Q}var $$=H.create({service:"acp-permissions"});class TD{connection;sdk;sessionManager;permissionQueues=new Map;permissionOptions=[{optionId:"once",kind:"allow_once",name:"Allow once"},{optionId:"always",kind:"allow_always",name:"Always allow"},{optionId:"reject",kind:"reject_once",name:"Reject"}];constructor($,Q,w){this.connection=$;this.sdk=Q;this.sessionManager=w}handle($){let Q=this.sessionManager.tryGet($.sessionID);if(!Q)return;let f=(this.permissionQueues.get($.sessionID)??Promise.resolve()).then(async()=>{let X=Q.cwd,G=await this.connection.requestPermission({sessionId:$.sessionID,toolCall:{toolCallId:$.tool?.callID??$.id,status:"pending",title:$.permission,rawInput:$.metadata,kind:b($.permission),locations:u($.permission,$.metadata??{})},options:this.permissionOptions}).catch(async(_)=>{$$.error("failed to request permission from ACP",{error:_,permissionID:$.id,sessionID:$.sessionID}),await this.sdk.permission.reply({requestID:$.id,reply:"reject",directory:X});return});if(!G)return;if(G.outcome.outcome!=="selected"){await this.sdk.permission.reply({requestID:$.id,reply:"reject",directory:X});return}if(G.outcome.optionId!=="reject"&&$.permission=="edit"){let _=$.metadata||{},J=typeof _.filepath==="string"?_.filepath:"",j=typeof _.diff==="string"?_.diff:"",B=await kD.exists(J)?await kD.readText(J):"",Y=eD(B,j);if(Y)this.connection.writeTextFile({sessionId:Q.id,path:J,content:Y})}await this.sdk.permission.reply({requestID:$.id,reply:G.outcome.optionId,directory:X})}).catch((X)=>{$$.error("failed to handle permission",{error:X,permissionID:$.id})}).finally(()=>{if(this.permissionQueues.get($.sessionID)===f)this.permissionQueues.delete($.sessionID)});this.permissionQueues.set($.sessionID,f)}}var L=H.create({service:"acp-event-bridge"});class UD{connection;sdk;sessionManager;eventAbort=new AbortController;eventStarted=!1;bashSnapshots=new Map;toolStarts=new Set;permissionHandler;constructor($,Q,w){this.connection=$;this.sdk=Q;this.sessionManager=w;this.permissionHandler=new TD($,Q,w)}start(){if(this.eventStarted)return;this.eventStarted=!0,this.runEventSubscription().catch(($)=>{if(this.eventAbort.signal.aborted)return;L.error("event subscription failed",{error:$})})}stop(){this.eventAbort.abort()}async runEventSubscription(){while(!0){if(this.eventAbort.signal.aborted)return;let $=await this.sdk.global.event({signal:this.eventAbort.signal,sseMaxRetryAttempts:0});for await(let Q of $.stream){if(this.eventAbort.signal.aborted)return;let w=Q?.payload;if(!w)continue;await this.handleEvent(w).catch((f)=>{L.error("failed to handle event",{error:f,type:w.type})})}if(this.eventAbort.signal.aborted)return;await new Promise((Q)=>{let w=()=>{clearTimeout(f),this.eventAbort.signal.removeEventListener("abort",w),Q()},f=setTimeout(w,1000);if(this.eventAbort.signal.addEventListener("abort",w,{once:!0}),this.eventAbort.signal.aborted)w()})}}async handleEvent($){switch($.type){case"permission.asked":{this.permissionHandler.handle($.properties);return}case"message.part.updated":{L.info("message part updated",{event:$.properties});let w=$.properties.part,f=this.sessionManager.tryGet(w.sessionID);if(!f)return;let X=f.id;if(w.type==="tool")switch(await this.toolStart(X,w),w.state.status){case"pending":this.bashSnapshots.delete(w.callID);return;case"running":{let G=xD(w),_=[];if(G){let J=w$.fast(G);if(w.tool==="bash"){if(this.bashSnapshots.get(w.callID)===J){await this.sendToolInProgress(X,w,w.state,[]);return}this.bashSnapshots.set(w.callID,J)}_.push({type:"content",content:{type:"text",text:G}})}await this.sendToolInProgress(X,w,w.state,_);return}case"completed":await this.sendToolCompleted(X,w,w.state);return;case"error":await this.sendToolError(X,w,w.state);return}if(w.type!=="text"&&w.type!=="file")return;return}case"message.part.delta":{let Q=$.properties,w=this.sessionManager.tryGet(Q.sessionID);if(!w)return;let f=w.id,X=await this.sdk.session.message({sessionID:Q.sessionID,messageID:Q.messageID,directory:w.cwd},{throwOnError:!0}).then((_)=>_.data).catch((_)=>{L.error("unexpected error when fetching message",{error:_});return});if(!X||X.info.role!=="assistant")return;let G=X.parts.find((_)=>_.id===Q.partID);if(!G)return;if(G.type==="text"&&Q.field==="text"&&G.ignored!==!0){await this.connection.sessionUpdate({sessionId:f,update:{sessionUpdate:"agent_message_chunk",messageId:Q.messageID,content:{type:"text",text:Q.delta}}}).catch((_)=>{L.error("failed to send text delta to ACP",{error:_})});return}if(G.type==="reasoning"&&Q.field==="text")await this.connection.sessionUpdate({sessionId:f,update:{sessionUpdate:"agent_thought_chunk",messageId:Q.messageID,content:{type:"text",text:Q.delta}}}).catch((_)=>{L.error("failed to send reasoning delta to ACP",{error:_})});return}}}async sendToolInProgress($,Q,w,f){await this.connection.sessionUpdate({sessionId:$,update:{sessionUpdate:"tool_call_update",toolCallId:Q.callID,status:"in_progress",kind:b(Q.tool),title:Q.tool,locations:u(Q.tool,w.input),rawInput:w.input,...f.length>0&&{content:f}}}).catch((X)=>{L.error("failed to send tool in_progress to ACP",{error:X})})}async sendToolCompleted($,Q,w){this.toolStarts.delete(Q.callID),this.bashSnapshots.delete(Q.callID);let f=b(Q.tool),X=[{type:"content",content:{type:"text",text:w.output}}];if(f==="edit"){let G=w.input,_=typeof G.filePath==="string"?G.filePath:"",J=typeof G.oldString==="string"?G.oldString:"",j=typeof G.newString==="string"?G.newString:typeof G.content==="string"?G.content:"";X.push({type:"diff",path:_,oldText:J,newText:j})}await this.connection.sessionUpdate({sessionId:$,update:{sessionUpdate:"tool_call_update",toolCallId:Q.callID,status:"completed",kind:f,content:X,title:w.title,rawInput:w.input,rawOutput:{output:w.output,metadata:w.metadata}}}).catch((G)=>{L.error("failed to send tool completed to ACP",{error:G})})}async sendToolError($,Q,w){this.toolStarts.delete(Q.callID),this.bashSnapshots.delete(Q.callID),await this.connection.sessionUpdate({sessionId:$,update:{sessionUpdate:"tool_call_update",toolCallId:Q.callID,status:"failed",kind:b(Q.tool),title:Q.tool,rawInput:w.input,content:[{type:"content",content:{type:"text",text:w.error}}],rawOutput:{error:w.error,metadata:w.metadata}}}).catch((f)=>{L.error("failed to send tool error to ACP",{error:f})})}async toolStart($,Q){if(this.toolStarts.has(Q.callID))return;this.toolStarts.add(Q.callID),await this.connection.sessionUpdate({sessionId:$,update:{sessionUpdate:"tool_call",toolCallId:Q.callID,title:Q.tool,kind:b(Q.tool),status:"pending",locations:[],rawInput:{}}}).catch((w)=>{L.error("failed to send tool pending to ACP",{error:w})})}async processMessage($){if(L.debug("process message",$),$.info.role!=="assistant"&&$.info.role!=="user")return;let Q=$.info.sessionID;for(let w of $.parts)if(w.type==="tool")switch(await this.toolStart(Q,w),w.state.status){case"pending":this.bashSnapshots.delete(w.callID);break;case"running":{let f=xD(w),X=[];if(f)X.push({type:"content",content:{type:"text",text:f}});await this.sendToolInProgress(Q,w,w.state,X);break}case"completed":await this.sendToolCompleted(Q,w,w.state);break;case"error":await this.sendToolError(Q,w,w.state);break}else if(w.type==="text"){if(w.text){let f=w.synthetic?["assistant"]:w.ignored?["user"]:void 0;await this.connection.sessionUpdate({sessionId:Q,update:{sessionUpdate:$.info.role==="user"?"user_message_chunk":"agent_message_chunk",messageId:$.info.id,content:{type:"text",text:w.text,...f&&{annotations:{audience:f}}}}}).catch((X)=>{L.error("failed to send text to ACP",{error:X})})}}else if(w.type==="file"){let f=w.url,X=w.filename??"file",G=w.mime||"application/octet-stream",_=$.info.role==="user"?"user_message_chunk":"agent_message_chunk";if(f.startsWith("file://"))await this.connection.sessionUpdate({sessionId:Q,update:{sessionUpdate:_,messageId:$.info.id,content:{type:"resource_link",uri:f,name:X,mimeType:G}}}).catch((J)=>{L.error("failed to send resource_link to ACP",{error:J})});else if(f.startsWith("data:")){let J=f.match(/^data:([^;]+);base64,(.*)$/),j=J?.[1],B=J?.[2]??"",Y=j||G;if(Y.startsWith("image/"))await this.connection.sessionUpdate({sessionId:Q,update:{sessionUpdate:_,messageId:$.info.id,content:{type:"image",mimeType:Y,data:B,uri:c(X).href}}}).catch((Z)=>{L.error("failed to send image to ACP",{error:Z})});else{let Z=Y.startsWith("text/")||Y==="application/json",A=c(X).href,y=Z?{uri:A,mimeType:Y,text:Buffer.from(B,"base64").toString("utf-8")}:{uri:A,mimeType:Y,blob:B};await this.connection.sessionUpdate({sessionId:Q,update:{sessionUpdate:_,messageId:$.info.id,content:{type:"resource",resource:y}}}).catch((W)=>{L.error("failed to send resource to ACP",{error:W})})}}}else if(w.type==="reasoning"){if(w.text)await this.connection.sessionUpdate({sessionId:Q,update:{sessionUpdate:"agent_thought_chunk",messageId:$.info.id,content:{type:"text",text:w.text}}}).catch((f)=>{L.error("failed to send reasoning to ACP",{error:f})})}}}var V=H.create({service:"acp-agent"});async function rw($,Q,w,f){return(await $.config.providers({directory:f}).then((J)=>J.data?.providers??[]).catch((J)=>{return V.error("failed to get providers for context limit",{error:J}),[]})).find((J)=>J.id===Q)?.models[w]?.limit.context??null}async function bD($,Q,w,f){let X=await Q.session.messages({sessionID:w,directory:f,agent_id:"main"},{throwOnError:!0}).then((Z)=>Z.data).catch((Z)=>{V.error("failed to fetch messages for usage update",{error:Z});return});if(!X)return;let G=X.filter((Z)=>Z.info.role==="assistant"),_=G[G.length-1];if(!_)return;let J=_.info;if(!J.providerID||!J.modelID)return;let j=await rw(Q,k.make(J.providerID),P.make(J.modelID),f);if(!j)return;let B=J.tokens.input+(J.tokens.cache?.read??0),Y=G.reduce((Z,A)=>Z+A.info.cost,0);await $.sessionUpdate({sessionId:w,update:{sessionUpdate:"usage_update",used:B,size:j,cost:{amount:Y,currency:"USD"}}}).catch((Z)=>{V.error("failed to send usage update",{error:Z})})}async function zw({sdk:$}){return{create:(Q,w)=>{return new CD(Q,w)}}}class CD{connection;config;sdk;sessionManager;eventBridge;constructor($,Q){this.connection=$,this.config=Q,this.sdk=Q.sdk,this.sessionManager=new LD(this.sdk),this.eventBridge=new UD($,this.sdk,this.sessionManager),this.eventBridge.start()}async initialize($){V.info("initialize",{protocolVersion:$.protocolVersion});let Q={description:"Run `qitqode auth login` in the terminal",name:"Login with qitqode",id:"qitqode-login"};if($.clientCapabilities?._meta?.["terminal-auth"]===!0)Q._meta={"terminal-auth":{command:"qitqode",args:["auth","login"],label:"QitQode Login"}};return{protocolVersion:1,agentCapabilities:{loadSession:!0,mcpCapabilities:{http:!0,sse:!0},promptCapabilities:{embeddedContext:!0,image:!0},sessionCapabilities:{fork:{},list:{},resume:{}}},authMethods:[Q],agentInfo:{name:"QitQode",version:Q$}}}async authenticate($){throw Error("Authentication not implemented")}rethrowSessionError($){let Q=G$.fromError($,{providerID:k.make(this.config.defaultModel?.providerID??"unknown")});if(f$.isInstance(Q))throw K.authRequired();throw $}fetchSessionMessages($,Q){return this.sdk.session.messages({sessionID:$,directory:Q,agent_id:"main"},{throwOnError:!0}).then((w)=>w.data).catch((w)=>{V.error("unexpected error when fetching message",{error:w});return})}loadSessionProviders($){return this.sdk.config.providers({directory:$},{throwOnError:!0}).then((Q)=>Q.data.providers)}async newSession($){let Q=$.cwd;try{let w=await h(this.config,Q),X=(await this.sessionManager.create($.cwd,$.mcpServers,w)).id;V.info("creating_session",{sessionId:X,mcpServers:$.mcpServers.length});let G=await this.loadSessionMode({cwd:Q,mcpServers:$.mcpServers,sessionId:X});return{sessionId:X,configOptions:G.configOptions,models:G.models,modes:G.modes,_meta:G._meta}}catch(w){this.rethrowSessionError(w)}}async loadSession($){let{cwd:Q,sessionId:w}=$;try{let f=await h(this.config,Q);await this.sessionManager.load(w,$.cwd,$.mcpServers,f),V.info("load_session",{sessionId:w,mcpServers:$.mcpServers.length});let X=await this.loadSessionMode({cwd:Q,mcpServers:$.mcpServers,sessionId:w}),G=await this.fetchSessionMessages(w,Q),_=G?.findLast((J)=>J.info.role==="user")?.info;if(_?.role==="user"){if(X.models.currentModelId=`${_.model.providerID}/${_.model.modelID}`,this.sessionManager.setModel(w,{providerID:k.make(_.model.providerID),modelID:P.make(_.model.modelID)}),X.modes?.availableModes.some((J)=>J.id===_.agent))X.modes.currentModeId=_.agent,this.sessionManager.setMode(w,_.agent);X.configOptions=i({currentModelId:X.models.currentModelId,availableModels:X.models.availableModels,modes:X.modes})}return await this.replayMessagesAndSendUsage(G,w,Q),X}catch(f){this.rethrowSessionError(f)}}async listSessions($){try{let w=await this.sdk.session.list({directory:$.cwd??void 0,roots:!0},{throwOnError:!0}).then((Z)=>Z.data??[]),f=$.cursor?Number($.cursor):void 0,X=w.toSorted((Z,A)=>A.time.updated-Z.time.updated),G=f?X.filter((Z)=>Z.time.updated<f):X,_=G.slice(0,100),J=_.map((Z)=>({sessionId:Z.id,cwd:Z.directory,title:Z.title,updatedAt:new Date(Z.time.updated).toISOString()})),j=_[_.length-1],B=G.length>100&&j?String(j.time.updated):void 0,Y={sessions:J};if(B)Y.nextCursor=B;return Y}catch(Q){this.rethrowSessionError(Q)}}async unstable_forkSession($){let Q=$.cwd,w=$.mcpServers??[];try{let f=await h(this.config,Q),X=await this.sdk.session.fork({sessionID:$.sessionId,directory:Q},{throwOnError:!0}).then((j)=>j.data);if(!X)throw Error("Fork session returned no data");let G=X.id;await this.sessionManager.load(G,Q,w,f),V.info("fork_session",{sessionId:G,mcpServers:w.length});let _=await this.loadSessionMode({cwd:Q,mcpServers:w,sessionId:G}),J=await this.fetchSessionMessages(G,Q);return await this.replayMessagesAndSendUsage(J,G,Q),_}catch(f){this.rethrowSessionError(f)}}async unstable_resumeSession($){let{cwd:Q,sessionId:w}=$,f=$.mcpServers??[];try{let X=await h(this.config,Q);await this.sessionManager.load(w,Q,f,X),V.info("resume_session",{sessionId:w,mcpServers:f.length});let G=await this.loadSessionMode({cwd:Q,mcpServers:f,sessionId:w});return await bD(this.connection,this.sdk,w,Q),G}catch(X){this.rethrowSessionError(X)}}async loadAvailableModes($){return(await this.config.sdk.app.agents({directory:$},{throwOnError:!0}).then((w)=>w.data)).filter((w)=>w.mode!=="subagent"&&!w.hidden).map((w)=>({id:w.name,name:w.name,description:w.description}))}async resolveModeState($,Q){let w=await this.loadAvailableModes($),f=this.sessionManager.get(Q).modeId||await(async()=>{if(!w.length)return;let X=await MD.runPromise(hD.Service.use((_)=>_.defaultAgent())),G=w.find((_)=>_.name===X)?.id??w[0].id;return this.sessionManager.setMode(Q,G),G})();return{availableModes:w,currentModeId:f}}async replayMessagesAndSendUsage($,Q,w){for(let f of $??[])V.debug("replay message",f),await this.eventBridge.processMessage(f);await bD(this.connection,this.sdk,Q,w)}async resolveModelsAndModes($){let Q=VD($.entries,$.model);$.onVariants?.(Q);let w=D$($.entries,{includeVariants:!0}),f=await this.resolveModeState($.directory,$.sessionId),X=f.currentModeId?{availableModes:f.availableModes,currentModeId:f.currentModeId}:void 0;return{availableVariants:Q,availableModels:w,modes:X}}async loadSessionMode($){let Q=$.cwd,w=await h(this.config,Q),f=$.sessionId,X=await this.sdk.config.providers({directory:Q}).then((W)=>W.data.providers),G=l(X),_=this.sessionManager.getVariant(f),{availableVariants:J,availableModels:j,modes:B}=await this.resolveModelsAndModes({entries:G,model:w,directory:Q,sessionId:f,onVariants:(W)=>{if(_&&!W.includes(_))this.sessionManager.setVariant(f,void 0)}}),Z=(await this.config.sdk.command.list({directory:Q},{throwOnError:!0}).then((W)=>W.data)).map((W)=>({name:W.name,description:W.description??""}));if(!new Set(Z.map((W)=>W.name)).has("compact"))Z.push({name:"compact",description:"summarize the session to reduce context"});let y={};for(let W of $.mcpServers)if("type"in W)y[W.name]={url:W.url,headers:W.headers.reduce((x,{name:C,value:m})=>{return x[C]=m,x},{}),type:"remote"};else y[W.name]={type:"local",command:[W.command,...W.args],environment:W.env.reduce((x,{name:C,value:m})=>{return x[C]=m,x},{})};return await Promise.all(Object.entries(y).map(async([W,x])=>{await this.sdk.mcp.add({directory:Q,name:W,config:x},{throwOnError:!0}).catch((C)=>{V.error("failed to add mcp server",{name:W,error:C})})})),setTimeout(()=>{this.connection.sessionUpdate({sessionId:f,update:{sessionUpdate:"available_commands_update",availableCommands:Z}})},0),{sessionId:f,models:{currentModelId:d(w,_,J,!0),availableModels:j},modes:B,configOptions:i({currentModelId:d(w,_,J,!0),availableModels:j,modes:B}),_meta:HD({model:w,variant:this.sessionManager.getVariant(f),availableVariants:J})}}async unstable_setSessionModel($){let Q=this.sessionManager.get($.sessionId),w=await this.loadSessionProviders(Q.cwd),f=PD($.modelId,w);this.sessionManager.setModel(Q.id,f.model),this.sessionManager.setVariant(Q.id,f.variant);let X=l(w),G=VD(X,f.model);return{_meta:HD({model:f.model,variant:f.variant,availableVariants:G})}}async setSessionMode($){let Q=this.sessionManager.get($.sessionId);if(!(await this.loadAvailableModes(Q.cwd)).some((f)=>f.id===$.modeId))throw Error(`Agent not found: ${$.modeId}`);this.sessionManager.setMode($.sessionId,$.modeId)}async setSessionConfigOption($){let Q=this.sessionManager.get($.sessionId),w=await this.loadSessionProviders(Q.cwd),f=l(w);if($.configId==="model"){if(typeof $.value!=="string")throw K.invalidParams("model value must be a string");let Y=PD($.value,w);this.sessionManager.setModel(Q.id,Y.model),this.sessionManager.setVariant(Q.id,Y.variant)}else if($.configId==="mode"){if(typeof $.value!=="string")throw K.invalidParams("mode value must be a string");if(!(await this.loadAvailableModes(Q.cwd)).some((Z)=>Z.id===$.value))throw K.invalidParams(JSON.stringify({error:`Mode not found: ${$.value}`}));this.sessionManager.setMode(Q.id,$.value)}else throw K.invalidParams(JSON.stringify({error:`Unknown config option: ${$.configId}`}));let X=this.sessionManager.get(Q.id),G=X.model??await h(this.config,Q.cwd),{availableVariants:_,availableModels:J,modes:j}=await this.resolveModelsAndModes({entries:f,model:G,directory:Q.cwd,sessionId:Q.id}),B=d(G,X.variant,_,!0);return{configOptions:i({currentModelId:B,availableModels:J,modes:j})}}async prompt($){let Q=$.sessionId,w=this.sessionManager.get(Q),f=w.cwd,X=w.model,G=X??await h(this.config,f);if(!X)this.sessionManager.setModel(w.id,G);let _=w.modeId??await MD.runPromise(hD.Service.use((A)=>A.defaultAgent())),J=[];for(let A of $.prompt)switch(A.type){case"text":{let y=A.annotations?.audience,W=y?.length===1&&y[0]==="assistant",x=y?.length===1&&y[0]==="user";J.push({type:"text",text:A.text,...W&&{synthetic:!0},...x&&{ignored:!0}});break}case"image":{let y=g(A.uri??""),W=y.type==="file"?y.filename:"image";if(A.data)J.push({type:"file",url:`data:${A.mimeType};base64,${A.data}`,filename:W,mime:A.mimeType});else if(A.uri&&A.uri.startsWith("http:"))J.push({type:"file",url:A.uri,filename:W,mime:A.mimeType});break}case"resource_link":{let y=g(A.uri);if(A.name&&y.type==="file")y.filename=A.name;J.push(y);break}case"resource":{let y=A.resource;if("text"in y&&y.text)J.push({type:"text",text:y.text});else if("blob"in y&&y.blob&&y.mimeType){let W=g(y.uri??""),x=W.type==="file"?W.filename:"file";J.push({type:"file",url:`data:${y.mimeType};base64,${y.blob}`,filename:x,mime:y.mimeType})}break}default:break}V.info("parts",{parts:J});let j=(()=>{let A=J.filter((x)=>x.type==="text").map((x)=>x.text).join("").trim();if(!A.startsWith("/"))return;let[y,...W]=A.slice(1).split(/\s+/);return{name:y,args:W.join(" ").trim()}})(),B=(A)=>({totalTokens:A.tokens.input+A.tokens.output+A.tokens.reasoning+(A.tokens.cache?.read??0)+(A.tokens.cache?.write??0),inputTokens:A.tokens.input,outputTokens:A.tokens.output,thoughtTokens:A.tokens.reasoning||void 0,cachedReadTokens:A.tokens.cache?.read||void 0,cachedWriteTokens:A.tokens.cache?.write||void 0}),Y,Z=!1;if(!j)Z=!0,Y=(await this.sdk.session.prompt({sessionID:Q,model:{providerID:G.providerID,modelID:G.modelID},variant:this.sessionManager.getVariant(Q),parts:J,agent:_,directory:f})).data?.info;else{let A=await this.config.sdk.command.list({directory:f},{throwOnError:!0}).then((y)=>y.data.find((W)=>W.name===j.name));if(A)Z=!0,Y=(await this.sdk.session.command({sessionID:Q,command:A.name,arguments:j.args,model:G.providerID+"/"+G.modelID,agent:_,directory:f})).data?.info;else switch(j.name){case"compact":await this.config.sdk.session.summarize({sessionID:Q,directory:f,providerID:G.providerID,modelID:G.modelID},{throwOnError:!0});break}}return await bD(this.connection,this.sdk,Q,f),{stopReason:"end_turn",...Z?{usage:Y?B(Y):void 0}:{},_meta:{}}}async cancel($){let Q=this.sessionManager.get($.sessionId);await this.config.sdk.session.abort({sessionID:$.sessionId,directory:Q.cwd},{throwOnError:!0})}}async function h($,Q){let{sdk:w,defaultModel:f}=$;if(f)return f;let X=Q??process.cwd(),G=await w.config.get({directory:X},{throwOnError:!0}).then((Y)=>{let Z=Y.data;if(!Z||!Z.model)return;return U.parseModel(Z.model)}).catch((Y)=>{V.error("failed to load user config for default model",{error:Y});return}),_=await w.config.providers({directory:X},{throwOnError:!0}).then((Y)=>Y.data?.providers??[]).catch((Y)=>{return V.error("failed to list providers for default model",{error:Y}),[]});if(G&&_.length){let Y=_.find((Z)=>Z.id===G.providerID);if(Y&&Y.models[G.modelID])return G}if(G&&!_.length)return G;let J=_.find((Y)=>Y.id==="opencode");if(J){if(J.models["big-pickle"])return{providerID:k.opencode,modelID:P.make("big-pickle")};let[Y]=U.sort(Object.values(J.models));if(Y)return{providerID:k.make(Y.providerID),modelID:P.make(Y.id)}}for(let Y of["default","fast","economical","power"]){let Z=_$[Y];if(!Z)continue;if(_.find((y)=>y.id===Z.providerID)?.models[Z.modelID])return{providerID:k.make(Z.providerID),modelID:P.make(Z.modelID)}}let j=_.flatMap((Y)=>Object.values(Y.models)),[B]=U.sort(j);if(B)return{providerID:k.make(B.providerID),modelID:P.make(B.id)};if(G)return G;return{providerID:k.opencode,modelID:P.make("big-pickle")}}var ED=H.create({service:"acp-command"}),sQ=A$({command:"acp",describe:"start ACP (Agent Client Protocol) server",builder:($)=>{return J$($).option("cwd",{describe:"working directory",type:"string",default:process.cwd()})},handler:async($)=>{if(process.env.QITQODE_CLIENT="acp",process.env.QITQODE_KEY)ED.info("Using QITQODE_KEY for authentication.");else if(!await Y$())ED.warn("No QitQode credential found. AI features will not work until you sign in (`qitqode auth login`) or set QITQODE_KEY.");await j$(process.cwd(),async()=>{let Q=await W$($),w=await Z$.listen(Q),f=X$({baseUrl:`http://${w.hostname}:${w.port}`}),X=new WritableStream({write(j){return new Promise((B,Y)=>{process.stdout.write(j,(Z)=>{if(Z)Y(Z);else B()})})}}),G=new ReadableStream({start(j){process.stdin.on("data",(B)=>{j.enqueue(new Uint8Array(B))}),process.stdin.on("end",()=>j.close()),process.stdin.on("error",(B)=>j.error(B))}}),_=zD(X,G),J=await v.init({sdk:f});new OD((j)=>{return J.create(j,{sdk:f})},_),ED.info("setup connection"),process.stdin.resume(),await new Promise((j,B)=>{process.stdin.on("end",j),process.stdin.on("error",B)})})}});export{sQ as AcpCommand};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-hh4c02fh.js";var{create:tr,defineProperty:Pe,getOwnPropertyDescriptor:rr,getOwnPropertyNames:nr,getPrototypeOf:ir}=Object,or=Object.prototype.hasOwnProperty,vt=(u)=>{throw TypeError(u)},N=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports),xt=(u,e)=>{for(var t in e)Pe(u,t,{get:e[t],enumerable:!0})},ar=(u,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nr(e))!or.call(u,r)&&r!==t&&Pe(u,r,{get:()=>e[r],enumerable:!(n=rr(e,r))||n.enumerable});return u},Uu=(u,e,t)=>(t=u!=null?tr(ir(u)):{},ar(e||!u||!u.__esModule?Pe(t,"default",{value:u,enumerable:!0}):t,u)),Bt=(u,e,t)=>e.has(u)||vt("Cannot "+t),ku=(u,e,t)=>(Bt(u,e,"read from private field"),t?t.call(u):e.get(u)),sr=(u,e,t)=>e.has(u)?vt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,t),Dr=(u,e,t,n)=>(Bt(u,e,"write to private field"),n?n.call(u,t):e.set(u,t),t),je=N((u,e)=>{e.exports=t;function t(n){return String(n).replace(/\s+/g," ")}}),lr=N((u,e)=>{e.exports=p;var t=9,n=10,r=32,i=33,a=58,o=91,s=92,l=93,D=94,c=96,f=4,h=1024;function p(d){var C=this.Parser,g=this.Compiler;E(C)&&v(C,d),A(g)&&F(g)}function E(d){return!!(d&&d.prototype&&d.prototype.blockTokenizers)}function A(d){return!!(d&&d.prototype&&d.prototype.visitors)}function v(d,C){for(var g=C||{},y=d.prototype,w=y.blockTokenizers,T=y.inlineTokenizers,b=y.blockMethods,k=y.inlineMethods,L=w.definition,I=T.reference,x=[],S=-1,M=b.length,z;++S<M;)z=b[S],!(z==="newline"||z==="indentedCode"||z==="paragraph"||z==="footnoteDefinition")&&x.push([z]);x.push(["footnoteDefinition"]),g.inlineNotes&&(B(k,"reference","inlineNote"),T.inlineNote=J),B(b,"definition","footnoteDefinition"),B(k,"reference","footnoteCall"),w.definition=O,w.footnoteDefinition=V,T.footnoteCall=q,T.reference=j,y.interruptFootnoteDefinition=x,j.locator=I.locator,q.locator=$,J.locator=U;function V(R,P,G){for(var W=this,Y=W.interruptFootnoteDefinition,K=W.offset,eu=P.length+1,H=0,Q=[],lu,Du,uu,_,X,pu,yu,hu,Fu,nu,du,tu,Z;H<eu&&(_=P.charCodeAt(H),!(_!==t&&_!==r));)H++;if(P.charCodeAt(H++)===o&&P.charCodeAt(H++)===D){for(Du=H;H<eu;){if(_=P.charCodeAt(H),_!==_||_===n||_===t||_===r)return;if(_===l){uu=H,H++;break}H++}if(!(uu===void 0||Du===uu||P.charCodeAt(H++)!==a)){if(G)return!0;for(lu=P.slice(Du,uu),X=R.now(),Fu=0,nu=0,du=H,tu=[];H<eu;){if(_=P.charCodeAt(H),_!==_||_===n)Z={start:Fu,contentStart:du||H,contentEnd:H,end:H},tu.push(Z),_===n&&(Fu=H+1,nu=0,du=void 0,Z.end=Fu);else if(nu!==void 0)if(_===r||_===t)nu+=_===r?1:f-nu%f,nu>f&&(nu=void 0,du=H);else{if(nu<f&&Z&&(Z.contentStart===Z.contentEnd||m(Y,w,W,[R,P.slice(H,h),!0])))break;nu=void 0,du=H}H++}for(H=-1,eu=tu.length;eu>0&&(Z=tu[eu-1],Z.contentStart===Z.contentEnd);)eu--;for(pu=R(P.slice(0,Z.contentEnd));++H<eu;)Z=tu[H],K[X.line+H]=(K[X.line+H]||0)+(Z.contentStart-Z.start),Q.push(P.slice(Z.contentStart,Z.end));return yu=W.enterBlock(),hu=W.tokenizeBlock(Q.join(""),X),yu(),pu({type:"footnoteDefinition",identifier:lu.toLowerCase(),label:lu,children:hu})}}}function q(R,P,G){var W=P.length+1,Y=0,K,eu,H,Q;if(P.charCodeAt(Y++)===o&&P.charCodeAt(Y++)===D){for(eu=Y;Y<W;){if(Q=P.charCodeAt(Y),Q!==Q||Q===n||Q===t||Q===r)return;if(Q===l){H=Y,Y++;break}Y++}if(!(H===void 0||eu===H))return G?!0:(K=P.slice(eu,H),R(P.slice(0,Y))({type:"footnoteReference",identifier:K.toLowerCase(),label:K}))}}function J(R,P,G){var W=this,Y=P.length+1,K=0,eu=0,H,Q,lu,Du,uu,_,X;if(P.charCodeAt(K++)===D&&P.charCodeAt(K++)===o){for(lu=K;K<Y;){if(Q=P.charCodeAt(K),Q!==Q)return;if(_===void 0)if(Q===s)K+=2;else if(Q===o)eu++,K++;else if(Q===l)if(eu===0){Du=K,K++;break}else eu--,K++;else if(Q===c){for(uu=K,_=1;P.charCodeAt(uu+_)===c;)_++;K+=_}else K++;else if(Q===c){for(uu=K,X=1;P.charCodeAt(uu+X)===c;)X++;K+=X,_===X&&(_=void 0),X=void 0}else K++}if(Du!==void 0)return G?!0:(H=R.now(),H.column+=2,H.offset+=2,R(P.slice(0,K))({type:"footnote",children:W.tokenizeInline(P.slice(lu,Du),H)}))}}function j(R,P,G){var W=0;if(P.charCodeAt(W)===i&&W++,P.charCodeAt(W)===o&&P.charCodeAt(W+1)!==D)return I.call(this,R,P,G)}function O(R,P,G){for(var W=0,Y=P.charCodeAt(W);Y===r||Y===t;)Y=P.charCodeAt(++W);if(Y===o&&P.charCodeAt(W+1)!==D)return L.call(this,R,P,G)}function $(R,P){return R.indexOf("[",P)}function U(R,P){return R.indexOf("^[",P)}}function F(d){var C=d.prototype.visitors,g=" ";C.footnote=y,C.footnoteReference=w,C.footnoteDefinition=T;function y(b){return"^["+this.all(b).join("")+"]"}function w(b){return"[^"+(b.label||b.identifier)+"]"}function T(b){for(var k=this.all(b).join(`
2
+ import"./chunk-0rmmg3g4.js";var{create:tr,defineProperty:Pe,getOwnPropertyDescriptor:rr,getOwnPropertyNames:nr,getPrototypeOf:ir}=Object,or=Object.prototype.hasOwnProperty,vt=(u)=>{throw TypeError(u)},N=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports),xt=(u,e)=>{for(var t in e)Pe(u,t,{get:e[t],enumerable:!0})},ar=(u,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nr(e))!or.call(u,r)&&r!==t&&Pe(u,r,{get:()=>e[r],enumerable:!(n=rr(e,r))||n.enumerable});return u},Uu=(u,e,t)=>(t=u!=null?tr(ir(u)):{},ar(e||!u||!u.__esModule?Pe(t,"default",{value:u,enumerable:!0}):t,u)),Bt=(u,e,t)=>e.has(u)||vt("Cannot "+t),ku=(u,e,t)=>(Bt(u,e,"read from private field"),t?t.call(u):e.get(u)),sr=(u,e,t)=>e.has(u)?vt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,t),Dr=(u,e,t,n)=>(Bt(u,e,"write to private field"),n?n.call(u,t):e.set(u,t),t),je=N((u,e)=>{e.exports=t;function t(n){return String(n).replace(/\s+/g," ")}}),lr=N((u,e)=>{e.exports=p;var t=9,n=10,r=32,i=33,a=58,o=91,s=92,l=93,D=94,c=96,f=4,h=1024;function p(d){var C=this.Parser,g=this.Compiler;E(C)&&v(C,d),A(g)&&F(g)}function E(d){return!!(d&&d.prototype&&d.prototype.blockTokenizers)}function A(d){return!!(d&&d.prototype&&d.prototype.visitors)}function v(d,C){for(var g=C||{},y=d.prototype,w=y.blockTokenizers,T=y.inlineTokenizers,b=y.blockMethods,k=y.inlineMethods,L=w.definition,I=T.reference,x=[],S=-1,M=b.length,z;++S<M;)z=b[S],!(z==="newline"||z==="indentedCode"||z==="paragraph"||z==="footnoteDefinition")&&x.push([z]);x.push(["footnoteDefinition"]),g.inlineNotes&&(B(k,"reference","inlineNote"),T.inlineNote=J),B(b,"definition","footnoteDefinition"),B(k,"reference","footnoteCall"),w.definition=O,w.footnoteDefinition=V,T.footnoteCall=q,T.reference=j,y.interruptFootnoteDefinition=x,j.locator=I.locator,q.locator=$,J.locator=U;function V(R,P,G){for(var W=this,Y=W.interruptFootnoteDefinition,K=W.offset,eu=P.length+1,H=0,Q=[],lu,Du,uu,_,X,pu,yu,hu,Fu,nu,du,tu,Z;H<eu&&(_=P.charCodeAt(H),!(_!==t&&_!==r));)H++;if(P.charCodeAt(H++)===o&&P.charCodeAt(H++)===D){for(Du=H;H<eu;){if(_=P.charCodeAt(H),_!==_||_===n||_===t||_===r)return;if(_===l){uu=H,H++;break}H++}if(!(uu===void 0||Du===uu||P.charCodeAt(H++)!==a)){if(G)return!0;for(lu=P.slice(Du,uu),X=R.now(),Fu=0,nu=0,du=H,tu=[];H<eu;){if(_=P.charCodeAt(H),_!==_||_===n)Z={start:Fu,contentStart:du||H,contentEnd:H,end:H},tu.push(Z),_===n&&(Fu=H+1,nu=0,du=void 0,Z.end=Fu);else if(nu!==void 0)if(_===r||_===t)nu+=_===r?1:f-nu%f,nu>f&&(nu=void 0,du=H);else{if(nu<f&&Z&&(Z.contentStart===Z.contentEnd||m(Y,w,W,[R,P.slice(H,h),!0])))break;nu=void 0,du=H}H++}for(H=-1,eu=tu.length;eu>0&&(Z=tu[eu-1],Z.contentStart===Z.contentEnd);)eu--;for(pu=R(P.slice(0,Z.contentEnd));++H<eu;)Z=tu[H],K[X.line+H]=(K[X.line+H]||0)+(Z.contentStart-Z.start),Q.push(P.slice(Z.contentStart,Z.end));return yu=W.enterBlock(),hu=W.tokenizeBlock(Q.join(""),X),yu(),pu({type:"footnoteDefinition",identifier:lu.toLowerCase(),label:lu,children:hu})}}}function q(R,P,G){var W=P.length+1,Y=0,K,eu,H,Q;if(P.charCodeAt(Y++)===o&&P.charCodeAt(Y++)===D){for(eu=Y;Y<W;){if(Q=P.charCodeAt(Y),Q!==Q||Q===n||Q===t||Q===r)return;if(Q===l){H=Y,Y++;break}Y++}if(!(H===void 0||eu===H))return G?!0:(K=P.slice(eu,H),R(P.slice(0,Y))({type:"footnoteReference",identifier:K.toLowerCase(),label:K}))}}function J(R,P,G){var W=this,Y=P.length+1,K=0,eu=0,H,Q,lu,Du,uu,_,X;if(P.charCodeAt(K++)===D&&P.charCodeAt(K++)===o){for(lu=K;K<Y;){if(Q=P.charCodeAt(K),Q!==Q)return;if(_===void 0)if(Q===s)K+=2;else if(Q===o)eu++,K++;else if(Q===l)if(eu===0){Du=K,K++;break}else eu--,K++;else if(Q===c){for(uu=K,_=1;P.charCodeAt(uu+_)===c;)_++;K+=_}else K++;else if(Q===c){for(uu=K,X=1;P.charCodeAt(uu+X)===c;)X++;K+=X,_===X&&(_=void 0),X=void 0}else K++}if(Du!==void 0)return G?!0:(H=R.now(),H.column+=2,H.offset+=2,R(P.slice(0,K))({type:"footnote",children:W.tokenizeInline(P.slice(lu,Du),H)}))}}function j(R,P,G){var W=0;if(P.charCodeAt(W)===i&&W++,P.charCodeAt(W)===o&&P.charCodeAt(W+1)!==D)return I.call(this,R,P,G)}function O(R,P,G){for(var W=0,Y=P.charCodeAt(W);Y===r||Y===t;)Y=P.charCodeAt(++W);if(Y===o&&P.charCodeAt(W+1)!==D)return L.call(this,R,P,G)}function $(R,P){return R.indexOf("[",P)}function U(R,P){return R.indexOf("^[",P)}}function F(d){var C=d.prototype.visitors,g=" ";C.footnote=y,C.footnoteReference=w,C.footnoteDefinition=T;function y(b){return"^["+this.all(b).join("")+"]"}function w(b){return"[^"+(b.label||b.identifier)+"]"}function T(b){for(var k=this.all(b).join(`
3
3
 
4
4
  `).split(`
5
5
  `),L=0,I=k.length,x;++L<I;)x=k[L],x!==""&&(k[L]=g+x);return"[^"+(b.label||b.identifier)+"]: "+k.join(`
@@ -5,4 +5,4 @@ Lifetime used`):new P("Lifetime not alive")}},J=class extends Q{constructor(W,Y)
5
5
  Then, failed to dispose scope: ${Z.message}`,disposeError:Z}),Y;if(Y||Z)throw Y||Z}var z=class W extends q{constructor(){super(...arguments);this._disposables=new Q(new Set),this.manage=(Y)=>(this._disposables.value.add(Y),Y)}static withScope(Y){let Z=new W,$;try{return Y(Z)}catch(X){throw $=X,X}finally{E(Z,$)}}static withScopeMaybeAsync(Y,Z){return XW(void 0,function*($){let X=new W,j;try{return yield*$.of(Z.call(Y,$,X))}catch(G){throw j=G,G}finally{E(X,j)}})}static async withScopeAsync(Y){let Z=new W,$;try{return await Y(Z)}catch(X){throw $=X,X}finally{E(Z,$)}}get alive(){return this._disposables.alive}dispose(){let Y=Array.from(this._disposables.value.values()).reverse();for(let Z of Y)Z.alive&&Z.dispose();this._disposables.dispose()}};function jW(W){let Y=W?Array.from(W):[];function Z(){return Y.forEach((X)=>X.alive?X.dispose():void 0)}function $(){return Y.some((X)=>X.alive)}return Object.defineProperty(Y,S,{configurable:!0,enumerable:!1,value:Z}),Object.defineProperty(Y,"dispose",{configurable:!0,enumerable:!1,value:Z}),Object.defineProperty(Y,"alive",{configurable:!0,enumerable:!1,get:$}),Y}function F(W){return!!(W&&(typeof W=="object"||typeof W=="function")&&("alive"in W)&&typeof W.alive=="boolean"&&("dispose"in W)&&typeof W.dispose=="function")}var f=class W extends q{static success(Y){return new KW(Y)}static fail(Y,Z){return new GW(Y,Z)}static is(Y){return Y instanceof W}},KW=class extends f{constructor(W){super();this.value=W}get alive(){return F(this.value)?this.value.alive:!0}dispose(){F(this.value)&&this.value.dispose()}unwrap(){return this.value}unwrapOr(W){return this.value}},GW=class extends f{constructor(W,Y){super();this.error=W,this.onUnwrap=Y}get alive(){return F(this.error)?this.error.alive:!0}dispose(){F(this.error)&&this.error.dispose()}unwrap(){throw this.onUnwrap(this),this.error}unwrapOr(W){return W}},w=f,VW=class extends q{constructor(W){super();this.resolve=(Y)=>{this.resolveHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.resolveHandle,this.context.undefined,Y||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.reject=(Y)=>{this.rejectHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.rejectHandle,this.context.undefined,Y||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.dispose=()=>{this.handle.alive&&this.handle.dispose(),this.disposeResolvers()},this.context=W.context,this.owner=W.context.runtime,this.handle=W.promiseHandle,this.settled=new Promise((Y)=>{this.onSettled=Y}),this.resolveHandle=W.resolveHandle,this.rejectHandle=W.rejectHandle}get alive(){return this.handle.alive||this.resolveHandle.alive||this.rejectHandle.alive}disposeResolvers(){this.resolveHandle.alive&&this.resolveHandle.dispose(),this.rejectHandle.alive&&this.rejectHandle.dispose()}},t=class{constructor(W){this.module=W}toPointerArray(W){let Y=new Int32Array(W.map((X)=>X.value)),Z=Y.length*Y.BYTES_PER_ELEMENT,$=this.module._malloc(Z);return new Uint8Array(this.module.HEAPU8.buffer,$,Z).set(new Uint8Array(Y.buffer)),new Q($,void 0,(X)=>this.module._free(X))}newTypedArray(W,Y){let Z=new W(Array(Y).fill(0)),$=Z.length*Z.BYTES_PER_ELEMENT,X=this.module._malloc($),j=new W(this.module.HEAPU8.buffer,X,Y);return j.set(Z),new Q({typedArray:j,ptr:X},void 0,(G)=>this.module._free(G.ptr))}newMutablePointerArray(W){return this.newTypedArray(Int32Array,W)}newHeapCharPointer(W){let Y=this.module.lengthBytesUTF8(W),Z=Y+1,$=this.module._malloc(Z);return this.module.stringToUTF8(W,$,Z),new Q({ptr:$,strlen:Y},void 0,(X)=>this.module._free(X.ptr))}newHeapBufferPointer(W){let Y=W.byteLength,Z=this.module._malloc(Y);return this.module.HEAPU8.set(W,Z),new Q({pointer:Z,numBytes:Y},void 0,($)=>this.module._free($.pointer))}consumeHeapCharPointer(W){let Y=this.module.UTF8ToString(W);return this.module._free(W),Y}},FW=Symbol("Unstable"),OW=Object.freeze({BaseObjects:!0,Date:!0,Eval:!0,StringNormalize:!0,RegExp:!0,JSON:!0,Proxy:!0,MapSet:!0,TypedArrays:!0,Promise:!0});function TW(W){if(!W)return 0;let Y=0;for(let[Z,$]of Object.entries(W)){if(!(Z in O))throw new n(Z);$&&(Y|=O[Z])}return Y}function QW(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{type:Y,strict:Z,strip:$,compileOnly:X,backtraceBarrier:j}=W,G=0;return Y==="global"&&(G|=L.JS_EVAL_TYPE_GLOBAL),Y==="module"&&(G|=L.JS_EVAL_TYPE_MODULE),Z&&(G|=L.JS_EVAL_FLAG_STRICT),$&&(G|=L.JS_EVAL_FLAG_STRIP),X&&(G|=L.JS_EVAL_FLAG_COMPILE_ONLY),j&&(G|=L.JS_EVAL_FLAG_BACKTRACE_BARRIER),G}function zW(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{strings:Y,symbols:Z,quickjsPrivate:$,onlyEnumerable:X,numbers:j,numbersAsStrings:G}=W,K=0;return Y&&(K|=U.JS_GPN_STRING_MASK),Z&&(K|=U.JS_GPN_SYMBOL_MASK),$&&(K|=U.JS_GPN_PRIVATE_MASK),X&&(K|=U.JS_GPN_ENUM_ONLY),j&&(K|=U.QTS_GPN_NUMBER_MASK),G&&(K|=U.QTS_STANDARD_COMPLIANT_NUMBER),K}function qW(...W){let Y=[];for(let Z of W)Z!==void 0&&(Y=Y.concat(Z));return Y}var CW=class extends q{constructor(W,Y){super();this.handle=W,this.context=Y,this._isDone=!1,this.owner=Y.runtime}[Symbol.iterator](){return this}next(W){if(!this.alive||this._isDone)return{done:!0,value:void 0};let Y=this._next??(this._next=this.context.getProp(this.handle,"next"));return this.callIteratorMethod(Y,W)}return(W){if(!this.alive)return{done:!0,value:void 0};let Y=this.context.getProp(this.handle,"return");if(Y===this.context.undefined&&W===void 0)return this.dispose(),{done:!0,value:void 0};let Z=this.callIteratorMethod(Y,W);return Y.dispose(),this.dispose(),Z}throw(W){if(!this.alive)return{done:!0,value:void 0};let Y=W instanceof Q?W:this.context.newError(W),Z=this.context.getProp(this.handle,"throw"),$=this.callIteratorMethod(Z,W);return Y.alive&&Y.dispose(),Z.dispose(),this.dispose(),$}get alive(){return this.handle.alive}dispose(){this._isDone=!0,this.handle.dispose(),this._next?.dispose()}callIteratorMethod(W,Y){let Z=Y?this.context.callFunction(W,this.handle,Y):this.context.callFunction(W,this.handle);if(Z.error)return this.dispose(),{value:Z};let $=this.context.getProp(Z.value,"done").consume((j)=>this.context.dump(j)),X=this.context.getProp(Z.value,"value");return Z.value.dispose(),$&&this.dispose(),{value:w.success(X),done:$}}},g=-2147483648,m=2147483647,A=0;function H(W){return W>>8}var BW=class{constructor(){this.nextId=g,this.freelist=[],this.groups=new Map}put(W){let Y=this.allocateId(),Z=H(Y),$=this.groups.get(Z);return $||($=new Map,this.groups.set(Z,$)),$.set(Y,W),Y}get(W){if(W===A)throw new C("no host reference id defined");let Y=H(W),Z=this.groups.get(Y);if(!Z)throw new C(`host reference id ${W} is not defined`);let $=Z.get(W);if(!$)throw new C(`host reference id ${W} is not defined`);return $}delete(W){if(W===A)throw new C("no host reference id defined");let Y=H(W),Z=this.groups.get(Y);if(!Z)throw new C(`host reference id ${W} is not defined`);Z.delete(W),Z.size===0&&this.groups.delete(Y),this.freelist.push(W)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===A&&this.nextId++,this.nextId>m)throw new s(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${m-g}`);return this.nextId++}},c=class extends q{constructor(W,Y,Z){if(Z===A)throw new C("cannot create HostRef with undefined id");super();this.runtime=W,this.handle=Y,this.id=Z}get alive(){return this.handle.alive}dispose(){this.handle.dispose()}get value(){return this.runtime.hostRefs.get(this.id)}},LW=class extends t{constructor(W){super(W.module);this.scope=new z,this.copyJSValue=(Y)=>this.ffi.QTS_DupValuePointer(this.ctx.value,Y),this.freeJSValue=(Y)=>{this.ffi.QTS_FreeValuePointer(this.ctx.value,Y)},W.ownedLifetimes?.forEach((Y)=>this.scope.manage(Y)),this.owner=W.owner,this.module=W.module,this.ffi=W.ffi,this.rt=W.rt,this.ctx=this.scope.manage(W.ctx)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}[Symbol.dispose](){return this.dispose()}manage(W){return this.scope.manage(W)}consumeJSCharPointer(W){let Y=this.module.UTF8ToString(W);return this.ffi.QTS_FreeCString(this.ctx.value,W),Y}heapValueHandle(W,Y){let Z=Y?($)=>{Y(),this.freeJSValue($)}:this.freeJSValue;return new Q(W,this.copyJSValue,Z,this.owner)}staticHeapValueHandle(W){return this.manage(this.heapValueHandle(W)),new J(W,this.owner)}},UW=class extends q{constructor(W){super();this._undefined=void 0,this._null=void 0,this._false=void 0,this._true=void 0,this._global=void 0,this._BigInt=void 0,this._Symbol=void 0,this._SymbolIterator=void 0,this._SymbolAsyncIterator=void 0,this.cToHostCallbacks={callFunction:(Y,Z,$,X,j)=>{if(Y!==this.ctx.value)throw Error("QuickJSContext instance received C -> JS call with mismatched ctx");let G=this.getFunction(j);return z.withScopeMaybeAsync(this,function*(K,V){let B=V.manage(new h(Z,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime)),D=Array($);for(let T=0;T<$;T++){let M=this.ffi.QTS_ArgvGetJSValueConstPointer(X,T);D[T]=V.manage(new h(M,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime))}try{let T=yield*K(G.apply(B,D));if(T){if("error"in T&&T.error)throw this.runtime.debugLog("throw error",T.error),T.error;let M=V.manage(T instanceof Q?T:T.value);return this.ffi.QTS_DupValuePointer(this.ctx.value,M.value)}return 0}catch(T){return this.errorToHandle(T).consume((M)=>this.ffi.QTS_Throw(this.ctx.value,M.value))}})}},this.runtime=W.runtime,this.module=W.module,this.ffi=W.ffi,this.rt=W.rt,this.ctx=W.ctx,this.memory=new LW({...W,owner:this.runtime}),W.callbacks.setContextCallbacks(this.ctx.value,this.cToHostCallbacks),this.dump=this.dump.bind(this),this.getString=this.getString.bind(this),this.getNumber=this.getNumber.bind(this),this.resolvePromise=this.resolvePromise.bind(this),this.uint32Out=this.memory.manage(this.memory.newTypedArray(Uint32Array,1))}get alive(){return this.memory.alive}dispose(){this.memory.dispose()}get undefined(){if(this._undefined)return this._undefined;let W=this.ffi.QTS_GetUndefined();return this._undefined=new J(W)}get null(){if(this._null)return this._null;let W=this.ffi.QTS_GetNull();return this._null=new J(W)}get true(){if(this._true)return this._true;let W=this.ffi.QTS_GetTrue();return this._true=new J(W)}get false(){if(this._false)return this._false;let W=this.ffi.QTS_GetFalse();return this._false=new J(W)}get global(){if(this._global)return this._global;let W=this.ffi.QTS_GetGlobalObject(this.ctx.value);return this._global=this.memory.staticHeapValueHandle(W),this._global}newNumber(W){return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value,W))}newString(W){let Y=this.memory.newHeapCharPointer(W).consume((Z)=>this.ffi.QTS_NewString(this.ctx.value,Z.value.ptr));return this.memory.heapValueHandle(Y)}newUniqueSymbol(W){let Y=(typeof W=="symbol"?W.description:W)??"",Z=this.memory.newHeapCharPointer(Y).consume(($)=>this.ffi.QTS_NewSymbol(this.ctx.value,$.value.ptr,0));return this.memory.heapValueHandle(Z)}newSymbolFor(W){let Y=(typeof W=="symbol"?W.description:W)??"",Z=this.memory.newHeapCharPointer(Y).consume(($)=>this.ffi.QTS_NewSymbol(this.ctx.value,$.value.ptr,1));return this.memory.heapValueHandle(Z)}getWellKnownSymbol(W){return this._Symbol??(this._Symbol=this.memory.manage(this.getProp(this.global,"Symbol"))),this.getProp(this._Symbol,W)}newBigInt(W){if(!this._BigInt){let $=this.getProp(this.global,"BigInt");this.memory.manage($),this._BigInt=new J($.value,this.runtime)}let Y=this._BigInt,Z=String(W);return this.newString(Z).consume(($)=>this.unwrapResult(this.callFunction(Y,this.undefined,$)))}newObject(W){W&&this.runtime.assertOwned(W);let Y=W?this.ffi.QTS_NewObjectProto(this.ctx.value,W.value):this.ffi.QTS_NewObject(this.ctx.value);return this.memory.heapValueHandle(Y)}newArray(){let W=this.ffi.QTS_NewArray(this.ctx.value);return this.memory.heapValueHandle(W)}newArrayBuffer(W){let Y=new Uint8Array(W),Z=this.memory.newHeapBufferPointer(Y),$=this.ffi.QTS_NewArrayBuffer(this.ctx.value,Z.value.pointer,Y.length);return this.memory.heapValueHandle($)}newPromise(W){let Y=z.withScope((Z)=>{let $=Z.manage(this.memory.newMutablePointerArray(2)),X=this.ffi.QTS_NewPromiseCapability(this.ctx.value,$.value.ptr),j=this.memory.heapValueHandle(X),[G,K]=Array.from($.value.typedArray).map((V)=>this.memory.heapValueHandle(V));return new VW({context:this,promiseHandle:j,resolveHandle:G,rejectHandle:K})});return W&&typeof W=="function"&&(W=new Promise(W)),W&&Promise.resolve(W).then(Y.resolve,(Z)=>Z instanceof Q?Y.reject(Z):this.newError(Z).consume(Y.reject)),Y}newFunction(W,Y){let Z=typeof W=="function"?W:Y;if(!Z)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof W=="string"?W:void 0,length:Z.length,isConstructor:!1,fn:Z})}newConstructorFunction(W,Y){let Z=typeof W=="function"?W:Y;if(!Z)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof W=="string"?W:void 0,length:Z.length,isConstructor:!0,fn:Z})}newFunctionWithOptions(W){let{name:Y,length:Z,isConstructor:$,fn:X}=W,j=this.runtime.hostRefs.put(X);try{return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value,Y??"",Z,$,j))}catch(G){throw this.runtime.hostRefs.delete(j),G}}newError(W){let Y=this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value));return W&&typeof W=="object"?(W.name!==void 0&&this.newString(W.name).consume((Z)=>this.setProp(Y,"name",Z)),W.message!==void 0&&this.newString(W.message).consume((Z)=>this.setProp(Y,"message",Z))):typeof W=="string"?this.newString(W).consume((Z)=>this.setProp(Y,"message",Z)):W!==void 0&&this.newString(String(W)).consume((Z)=>this.setProp(Y,"message",Z)),Y}newHostRef(W){let Y=this.runtime.hostRefs.put(W);try{let Z=this.memory.heapValueHandle(this.ffi.QTS_NewHostRef(this.ctx.value,Y));return new c(this.runtime,Z,Y)}catch(Z){throw this.runtime.hostRefs.delete(Y),Z}}toHostRef(W){let Y=this.ffi.QTS_GetHostRefId(W.value);if(Y!==0)return this.runtime.hostRefs.get(Y),new c(this.runtime,W.dup(),Y)}unwrapHostRef(W){let Y=this.ffi.QTS_GetHostRefId(W.value);if(Y===0)throw new C("handle is not a HostRef");return this.runtime.hostRefs.get(Y)}typeof(W){return this.runtime.assertOwned(W),this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value,W.value))}getNumber(W){return this.runtime.assertOwned(W),this.ffi.QTS_GetFloat64(this.ctx.value,W.value)}getString(W){return this.runtime.assertOwned(W),this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value,W.value))}getSymbol(W){this.runtime.assertOwned(W);let Y=this.memory.consumeJSCharPointer(this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value,W.value));return this.ffi.QTS_IsGlobalSymbol(this.ctx.value,W.value)?Symbol.for(Y):Symbol(Y)}getBigInt(W){this.runtime.assertOwned(W);let Y=this.getString(W);return BigInt(Y)}getArrayBuffer(W){this.runtime.assertOwned(W);let Y=this.ffi.QTS_GetArrayBufferLength(this.ctx.value,W.value),Z=this.ffi.QTS_GetArrayBuffer(this.ctx.value,W.value);if(!Z)throw Error("Couldn't allocate memory to get ArrayBuffer");return new Q(this.module.HEAPU8.subarray(Z,Z+Y),void 0,()=>this.module._free(Z))}getPromiseState(W){this.runtime.assertOwned(W);let Y=this.ffi.QTS_PromiseState(this.ctx.value,W.value);if(Y<0)return{type:"fulfilled",value:W,notAPromise:!0};if(Y===I.Pending)return{type:"pending",get error(){return new l("Cannot unwrap a pending promise")}};let Z=this.ffi.QTS_PromiseResult(this.ctx.value,W.value),$=this.memory.heapValueHandle(Z);if(Y===I.Fulfilled)return{type:"fulfilled",value:$};if(Y===I.Rejected)return{type:"rejected",error:$};throw $.dispose(),Error(`Unknown JSPromiseStateEnum: ${Y}`)}resolvePromise(W){this.runtime.assertOwned(W);let Y=z.withScope((Z)=>{let $=Z.manage(this.getProp(this.global,"Promise")),X=Z.manage(this.getProp($,"resolve"));return this.callFunction(X,$,W)});return Y.error?Promise.resolve(Y):new Promise((Z)=>{z.withScope(($)=>{let X=$.manage(this.newFunction("resolve",(V)=>{Z(this.success(V&&V.dup()))})),j=$.manage(this.newFunction("reject",(V)=>{Z(this.fail(V&&V.dup()))})),G=$.manage(Y.value),K=$.manage(this.getProp(G,"then"));this.callFunction(K,G,X,j).unwrap().dispose()})})}isEqual(W,Y,Z=R.IsStrictlyEqual){if(W===Y)return!0;this.runtime.assertOwned(W),this.runtime.assertOwned(Y);let $=this.ffi.QTS_IsEqual(this.ctx.value,W.value,Y.value,Z);if($===-1)throw new p("WASM variant does not expose equality");return!!$}eq(W,Y){return this.isEqual(W,Y,R.IsStrictlyEqual)}sameValue(W,Y){return this.isEqual(W,Y,R.IsSameValue)}sameValueZero(W,Y){return this.isEqual(W,Y,R.IsSameValueZero)}getProp(W,Y){this.runtime.assertOwned(W);let Z;return typeof Y=="number"&&Y>=0?Z=this.ffi.QTS_GetPropNumber(this.ctx.value,W.value,Y):Z=this.borrowPropertyKey(Y).consume(($)=>this.ffi.QTS_GetProp(this.ctx.value,W.value,$.value)),this.memory.heapValueHandle(Z)}getLength(W){if(this.runtime.assertOwned(W),!(this.ffi.QTS_GetLength(this.ctx.value,this.uint32Out.value.ptr,W.value)<0))return this.uint32Out.value.typedArray[0]}getOwnPropertyNames(W,Y={strings:!0,numbersAsStrings:!0}){this.runtime.assertOwned(W),W.value;let Z=zW(Y);if(Z===0)throw new o("No options set, will return an empty array");return z.withScope(($)=>{let X=$.manage(this.memory.newMutablePointerArray(1)),j=this.ffi.QTS_GetOwnPropertyNames(this.ctx.value,X.value.ptr,this.uint32Out.value.ptr,W.value,Z);if(j)return this.fail(this.memory.heapValueHandle(j));let G=this.uint32Out.value.typedArray[0],K=X.value.typedArray[0],V=new Uint32Array(this.module.HEAP8.buffer,K,G),B=Array.from(V).map((D)=>this.memory.heapValueHandle(D));return this.ffi.QTS_FreeVoidPointer(this.ctx.value,K),this.success(jW(B))})}getIterator(W){let Y=this._SymbolIterator??(this._SymbolIterator=this.memory.manage(this.getWellKnownSymbol("iterator")));return z.withScope((Z)=>{let $=Z.manage(this.getProp(W,Y)),X=this.callFunction($,W);return X.error?X:this.success(new CW(X.value,this))})}setProp(W,Y,Z){this.runtime.assertOwned(W),this.borrowPropertyKey(Y).consume(($)=>this.ffi.QTS_SetProp(this.ctx.value,W.value,$.value,Z.value))}defineProp(W,Y,Z){this.runtime.assertOwned(W),z.withScope(($)=>{let X=$.manage(this.borrowPropertyKey(Y)),j=Z.value||this.undefined,G=!!Z.configurable,K=!!Z.enumerable,V=!!Z.value,B=Z.get?$.manage(this.newFunction(Z.get.name,Z.get)):this.undefined,D=Z.set?$.manage(this.newFunction(Z.set.name,Z.set)):this.undefined;this.ffi.QTS_DefineProp(this.ctx.value,W.value,X.value,j.value,B.value,D.value,G,K,V)})}callFunction(W,Y,...Z){this.runtime.assertOwned(W);let $,X=Z[0];X===void 0||Array.isArray(X)?$=X??[]:$=Z;let j=this.memory.toPointerArray($).consume((K)=>this.ffi.QTS_Call(this.ctx.value,W.value,Y.value,$.length,K.value)),G=this.ffi.QTS_ResolveException(this.ctx.value,j);return G?(this.ffi.QTS_FreeValuePointer(this.ctx.value,j),this.fail(this.memory.heapValueHandle(G))):this.success(this.memory.heapValueHandle(j))}callMethod(W,Y,Z=[]){return this.getProp(W,Y).consume(($)=>this.callFunction($,W,Z))}evalCode(W,Y="eval.js",Z){let $=Z===void 0?1:0,X=QW(Z),j=this.memory.newHeapCharPointer(W).consume((K)=>this.ffi.QTS_Eval(this.ctx.value,K.value.ptr,K.value.strlen,Y,$,X)),G=this.ffi.QTS_ResolveException(this.ctx.value,j);return G?(this.ffi.QTS_FreeValuePointer(this.ctx.value,j),this.fail(this.memory.heapValueHandle(G))):this.success(this.memory.heapValueHandle(j))}throw(W){return this.errorToHandle(W).consume((Y)=>this.ffi.QTS_Throw(this.ctx.value,Y.value))}borrowPropertyKey(W){return typeof W=="number"?this.newNumber(W):typeof W=="string"?this.newString(W):new J(W.value,this.runtime)}getMemory(W){if(W===this.rt.value)return this.memory;throw Error("Private API. Cannot get memory from a different runtime")}dump(W){this.runtime.assertOwned(W);let Y=this.typeof(W);if(Y==="string")return this.getString(W);if(Y==="number")return this.getNumber(W);if(Y==="bigint")return this.getBigInt(W);if(Y==="undefined")return;if(Y==="symbol")return this.getSymbol(W);let Z=this.getPromiseState(W);if(Z.type==="fulfilled"&&!Z.notAPromise)return W.dispose(),{type:Z.type,value:Z.value.consume(this.dump)};if(Z.type==="pending")return W.dispose(),{type:Z.type};if(Z.type==="rejected")return W.dispose(),{type:Z.type,error:Z.error.consume(this.dump)};let $=this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value,W.value));try{return JSON.parse($)}catch{return $}}unwrapResult(W){if(W.error){let Y="context"in W.error?W.error.context:this,Z=W.error.consume(($)=>this.dump($));if(Z&&typeof Z=="object"&&typeof Z.message=="string"){let{message:$,name:X,stack:j,...G}=Z,K=new _(Z,Y);typeof X=="string"&&(K.name=Z.name),K.message=$;let V=K.stack;throw typeof j=="string"&&(K.stack=`${X}: ${$}
6
6
  ${Z.stack}Host: ${V}`),Object.assign(K,G),K}throw new _(Z)}return W.value}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { ctx: ${this.ctx.value} rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getFunction(W){let Y=this.runtime.hostRefs.get(W);if(typeof Y!="function")throw Error(`Host reference ${W} is not a function`);return Y}errorToHandle(W){return W instanceof Q?W:this.newError(W)}encodeBinaryJSON(W){let Y=this.ffi.QTS_bjson_encode(this.ctx.value,W.value);return this.memory.heapValueHandle(Y)}decodeBinaryJSON(W){let Y=this.ffi.QTS_bjson_decode(this.ctx.value,W.value);return this.memory.heapValueHandle(Y)}success(W){return w.success(W)}fail(W){return w.fail(W,(Y)=>this.unwrapResult(Y))}},JW=class extends q{constructor(W){super();this.scope=new z,this.contextMap=new Map,this.hostRefs=new BW,this._debugMode=!1,this.cToHostCallbacks={freeHostRef:(Y,Z)=>{if(Y!==this.rt.value)throw Error("Runtime pointer mismatch");this.hostRefs.delete(Z)},shouldInterrupt:(Y)=>{if(Y!==this.rt.value)throw Error("QuickJSContext instance received C -> JS interrupt with mismatched rt");let Z=this.interruptHandler;if(!Z)throw Error("QuickJSContext had no interrupt handler");return Z(this)?1:0},loadModuleSource:v(this,function*(Y,Z,$,X){let j=this.moduleLoader;if(!j)throw Error("Runtime has no module loader");if(Z!==this.rt.value)throw Error("Runtime pointer mismatch");let G=this.contextMap.get($)??this.newContext({contextPointer:$});try{let K=yield*Y(j(X,G));if(typeof K=="object"&&"error"in K&&K.error)throw this.debugLog("cToHostLoadModule: loader returned error",K.error),K.error;let V=typeof K=="string"?K:("value"in K)?K.value:K;return this.memory.newHeapCharPointer(V).value.ptr}catch(K){return this.debugLog("cToHostLoadModule: caught error",K),G.throw(K),0}}),normalizeModule:v(this,function*(Y,Z,$,X,j){let G=this.moduleNormalizer;if(!G)throw Error("Runtime has no module normalizer");if(Z!==this.rt.value)throw Error("Runtime pointer mismatch");let K=this.contextMap.get($)??this.newContext({contextPointer:$});try{let V=yield*Y(G(X,j,K));if(typeof V=="object"&&"error"in V&&V.error)throw this.debugLog("cToHostNormalizeModule: normalizer returned error",V.error),V.error;let B=typeof V=="string"?V:V.value;return K.getMemory(this.rt.value).newHeapCharPointer(B).value.ptr}catch(V){return this.debugLog("normalizeModule: caught error",V),K.throw(V),0}})},W.ownedLifetimes?.forEach((Y)=>this.scope.manage(Y)),this.module=W.module,this.memory=new t(this.module),this.ffi=W.ffi,this.rt=W.rt,this.callbacks=W.callbacks,this.scope.manage(this.rt),this.callbacks.setRuntimeCallbacks(this.rt.value,this.cToHostCallbacks),this.executePendingJobs=this.executePendingJobs.bind(this),x&&this.setDebugMode(!0)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}newContext(W={}){let Y=TW(W.intrinsics),Z=new Q(W.contextPointer||this.ffi.QTS_NewContext(this.rt.value,Y),void 0,(X)=>{this.contextMap.delete(X),this.callbacks.deleteContext(X),this.ffi.QTS_FreeContext(X)}),$=new UW({module:this.module,ctx:Z,ffi:this.ffi,rt:this.rt,ownedLifetimes:W.ownedLifetimes,runtime:this,callbacks:this.callbacks});return this.contextMap.set(Z.value,$),$}setModuleLoader(W,Y){this.moduleLoader=W,this.moduleNormalizer=Y,this.ffi.QTS_RuntimeEnableModuleLoader(this.rt.value,this.moduleNormalizer?1:0)}removeModuleLoader(){this.moduleLoader=void 0,this.ffi.QTS_RuntimeDisableModuleLoader(this.rt.value)}hasPendingJob(){return!!this.ffi.QTS_IsJobPending(this.rt.value)}setInterruptHandler(W){let Y=this.interruptHandler;this.interruptHandler=W,Y||this.ffi.QTS_RuntimeEnableInterruptHandler(this.rt.value)}removeInterruptHandler(){this.interruptHandler&&(this.ffi.QTS_RuntimeDisableInterruptHandler(this.rt.value),this.interruptHandler=void 0)}executePendingJobs(W=-1){let Y=this.memory.newMutablePointerArray(1),Z=this.ffi.QTS_ExecutePendingJob(this.rt.value,W??-1,Y.value.ptr),$=Y.value.typedArray[0];if(Y.dispose(),$===0)return this.ffi.QTS_FreeValuePointerRuntime(this.rt.value,Z),w.success(0);let X=this.contextMap.get($)??this.newContext({contextPointer:$}),j=X.getMemory(this.rt.value).heapValueHandle(Z);if(X.typeof(j)==="number"){let G=X.getNumber(j);return j.dispose(),w.success(G)}else{let G=Object.assign(j,{context:X});return w.fail(G,(K)=>X.unwrapResult(K))}}setMemoryLimit(W){if(W<0&&W!==-1)throw Error("Cannot set memory limit to negative number. To unset, pass -1");this.ffi.QTS_RuntimeSetMemoryLimit(this.rt.value,W)}computeMemoryUsage(){let W=this.getSystemContext().getMemory(this.rt.value);return W.heapValueHandle(this.ffi.QTS_RuntimeComputeMemoryUsage(this.rt.value,W.ctx.value))}dumpMemoryUsage(){return this.memory.consumeHeapCharPointer(this.ffi.QTS_RuntimeDumpMemoryUsage(this.rt.value))}setMaxStackSize(W){if(W<0)throw Error("Cannot set memory limit to negative number. To unset, pass 0.");this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value,W)}assertOwned(W){if(W.owner&&W.owner.rt!==this.rt)throw new u(`Handle is not owned by this runtime: ${W.owner.rt.value} != ${this.rt.value}`)}setDebugMode(W){this._debugMode=W,this.ffi.DEBUG&&this.rt.alive&&this.ffi.QTS_SetDebugLogEnabled(this.rt.value,W?1:0)}isDebugMode(){return this._debugMode}debugLog(...W){this._debugMode&&console.log("quickjs-emscripten:",...W)}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getSystemContext(){return this.context||(this.context=this.scope.manage(this.newContext())),this.context}},DW=class{constructor(W){this.freeHostRef=W.freeHostRef,this.callFunction=W.callFunction,this.shouldInterrupt=W.shouldInterrupt,this.loadModuleSource=W.loadModuleSource,this.normalizeModule=W.normalizeModule}},wW=class{constructor(W){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new DW({freeHostRef:(Y,Z,$)=>{let X=this.runtimeCallbacks.get(Z);if(!X)throw Error(`QuickJSRuntime(rt = ${Z}) not found when trying to free HostRef(id = ${$})`);X.freeHostRef(Z,$)},callFunction:(Y,Z,$,X,j,G)=>this.handleAsyncify(Y,()=>{try{let K=this.contextCallbacks.get(Z);if(!K)throw Error(`QuickJSContext(ctx = ${Z}) not found for C function call "${G}"`);return K.callFunction(Z,$,X,j,G)}catch(K){return console.error("[C to host error: returning null]",K),0}}),shouldInterrupt:(Y,Z)=>this.handleAsyncify(Y,()=>{try{let $=this.runtimeCallbacks.get(Z);if(!$)throw Error(`QuickJSRuntime(rt = ${Z}) not found for C interrupt`);return $.shouldInterrupt(Z)}catch($){return console.error("[C to host interrupt: returning error]",$),1}}),loadModuleSource:(Y,Z,$,X)=>this.handleAsyncify(Y,()=>{try{let j=this.runtimeCallbacks.get(Z);if(!j)throw Error(`QuickJSRuntime(rt = ${Z}) not found for C module loader`);let G=j.loadModuleSource;if(!G)throw Error(`QuickJSRuntime(rt = ${Z}) does not support module loading`);return G(Z,$,X)}catch(j){return console.error("[C to host module loader error: returning null]",j),0}}),normalizeModule:(Y,Z,$,X,j)=>this.handleAsyncify(Y,()=>{try{let G=this.runtimeCallbacks.get(Z);if(!G)throw Error(`QuickJSRuntime(rt = ${Z}) not found for C module loader`);let K=G.normalizeModule;if(!K)throw Error(`QuickJSRuntime(rt = ${Z}) does not support module loading`);return K(Z,$,X,j)}catch(G){return console.error("[C to host module loader error: returning null]",G),0}})}),this.module=W,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(W,Y){this.runtimeCallbacks.set(W,Y)}deleteRuntime(W){this.runtimeCallbacks.delete(W)}setContextCallbacks(W,Y){this.contextCallbacks.set(W,Y)}deleteContext(W){this.contextCallbacks.delete(W)}handleAsyncify(W,Y){if(W)return W.handleSleep(($)=>{try{let X=Y();if(!(X instanceof Promise)){N("asyncify.handleSleep: not suspending:",X),$(X);return}if(this.suspended)throw new d(`Already suspended at: ${this.suspended.stack}
7
7
  Attempted to suspend at:`);this.suspended=new i(`(${this.suspendedCount++})`),N("asyncify.handleSleep: suspending:",this.suspended),X.then((j)=>{this.suspended=void 0,N("asyncify.handleSleep: resolved:",j),$(j)},(j)=>{N("asyncify.handleSleep: rejected:",j),console.error("QuickJS: cannot handle error in suspended function",j),this.suspended=void 0})}catch(X){throw N("asyncify.handleSleep: error:",X),this.suspended=void 0,X}});let Z=Y();if(Z instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return Z}};function MW(W,Y){Y.interruptHandler&&W.setInterruptHandler(Y.interruptHandler),Y.maxStackSizeBytes!==void 0&&W.setMaxStackSize(Y.maxStackSizeBytes),Y.memoryLimitBytes!==void 0&&W.setMemoryLimit(Y.memoryLimitBytes)}function RW(W,Y){Y.moduleLoader&&W.setModuleLoader(Y.moduleLoader),Y.shouldInterrupt&&W.setInterruptHandler(Y.shouldInterrupt),Y.memoryLimitBytes!==void 0&&W.setMemoryLimit(Y.memoryLimitBytes),Y.maxStackSizeBytes!==void 0&&W.setMaxStackSize(Y.maxStackSizeBytes)}var EW=class{constructor(W,Y){this.module=W,this.ffi=Y,this.callbacks=new wW(W)}newRuntime(W={}){let Y=new Q(this.ffi.QTS_NewRuntime(),void 0,($)=>{this.ffi.QTS_FreeRuntime($),this.callbacks.deleteRuntime($)}),Z=new JW({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:Y});return MW(Z,W),W.moduleLoader&&Z.setModuleLoader(W.moduleLoader),Z}newContext(W={}){let Y=this.newRuntime(),Z=Y.newContext({...W,ownedLifetimes:qW(Y,W.ownedLifetimes)});return Y.context=Z,Z}evalCode(W,Y={}){return z.withScope((Z)=>{let $=Z.manage(this.newContext());RW($.runtime,Y);let X=$.evalCode(W,"eval.js");if(Y.memoryLimitBytes!==void 0&&$.runtime.setMemoryLimit(-1),X.error)throw $.dump(Z.manage(X.error));return $.dump(Z.manage(X.value))})}getWasmMemory(){let W=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!W)throw Error("Variant does not support getting WebAssembly.Memory");return W}getFFI(){return this.ffi}};
8
- export{p as Eh,Q as Fh,z as Gh,TW as Hh,QW as Ih,UW as Jh,JW as Kh,wW as Lh,MW as Mh,RW as Nh,EW as Oh};
8
+ export{p as Gh,Q as Hh,z as Ih,TW as Jh,QW as Kh,UW as Lh,JW as Mh,wW as Nh,MW as Oh,RW as Ph,EW as Qh};