@struktoai/mirage-node 0.0.3 → 0.0.5-alpha.1

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 (465) hide show
  1. package/README.md +2 -1
  2. package/dist/aliyun-S62BR3TB.js +11 -0
  3. package/dist/append.lua +17 -0
  4. package/dist/backblaze-4EKSW63F.js +11 -0
  5. package/dist/box-ZPLZAGMK.js +8 -0
  6. package/dist/cas.lua +15 -0
  7. package/dist/ceph-ALKLD3MO.js +11 -0
  8. package/dist/{chunk-QCZ2XUKH.js → chunk-2A4YGVBM.js} +16 -23
  9. package/dist/chunk-2A4YGVBM.js.map +1 -0
  10. package/dist/chunk-2HCYLVGY.js +28 -0
  11. package/dist/chunk-2HCYLVGY.js.map +1 -0
  12. package/dist/chunk-2VPZAH5Q.js +20 -0
  13. package/dist/chunk-2VPZAH5Q.js.map +1 -0
  14. package/dist/{chunk-UT2OPSN4.js → chunk-3JZQ6VSZ.js} +5 -5
  15. package/dist/chunk-3JZQ6VSZ.js.map +1 -0
  16. package/dist/chunk-4IF4TGAI.js +11 -0
  17. package/dist/chunk-4IF4TGAI.js.map +1 -0
  18. package/dist/{chunk-47AVIIOT.js → chunk-5H6KNEPP.js} +4 -5
  19. package/dist/{chunk-47AVIIOT.js.map → chunk-5H6KNEPP.js.map} +1 -1
  20. package/dist/{chunk-I5THIMPP.js → chunk-5K2MWDCE.js} +6 -7
  21. package/dist/{chunk-I5THIMPP.js.map → chunk-5K2MWDCE.js.map} +1 -1
  22. package/dist/{chunk-3WIO7NBR.js → chunk-6SVXWRKX.js} +4 -5
  23. package/dist/{chunk-3WIO7NBR.js.map → chunk-6SVXWRKX.js.map} +1 -1
  24. package/dist/{chunk-RQK5UPMP.js → chunk-6VOIUGAD.js} +25 -12
  25. package/dist/chunk-6VOIUGAD.js.map +1 -0
  26. package/dist/{chunk-NOHWIBRX.js → chunk-7JYHFXXC.js} +15 -20
  27. package/dist/chunk-7JYHFXXC.js.map +1 -0
  28. package/dist/chunk-7VQQFWV6.js +20 -0
  29. package/dist/chunk-7VQQFWV6.js.map +1 -0
  30. package/dist/chunk-7ZP6TPHX.js +87 -0
  31. package/dist/chunk-7ZP6TPHX.js.map +1 -0
  32. package/dist/{chunk-SWCDFEUK.js → chunk-ADEXNSYU.js} +20 -22
  33. package/dist/chunk-ADEXNSYU.js.map +1 -0
  34. package/dist/chunk-AQSYAXL4.js +16 -0
  35. package/dist/chunk-AQSYAXL4.js.map +1 -0
  36. package/dist/{chunk-RO5IQEDQ.js → chunk-ATLXMNKD.js} +8 -4
  37. package/dist/chunk-ATLXMNKD.js.map +1 -0
  38. package/dist/{chunk-MPCCRRE6.js → chunk-BYCUGFRF.js} +16 -16
  39. package/dist/chunk-BYCUGFRF.js.map +1 -0
  40. package/dist/{chunk-HJJMP6IX.js → chunk-BZTVYOES.js} +3 -3
  41. package/dist/{chunk-B2ZOKNN4.js → chunk-CRC4YWXB.js} +27 -9
  42. package/dist/chunk-CRC4YWXB.js.map +1 -0
  43. package/dist/chunk-CTGXJHO5.js +39 -0
  44. package/dist/chunk-CTGXJHO5.js.map +1 -0
  45. package/dist/{chunk-Q2IAILVC.js → chunk-DCDBIXVZ.js} +14 -5
  46. package/dist/chunk-DCDBIXVZ.js.map +1 -0
  47. package/dist/chunk-DDAFNROK.js +750 -0
  48. package/dist/chunk-DDAFNROK.js.map +1 -0
  49. package/dist/chunk-DQIEWEAW.js +85 -0
  50. package/dist/chunk-DQIEWEAW.js.map +1 -0
  51. package/dist/{chunk-QGRDPSAH.js → chunk-EBI4IHDC.js} +23 -12
  52. package/dist/chunk-EBI4IHDC.js.map +1 -0
  53. package/dist/{chunk-JAGJTM3Q.js → chunk-EIUTZ6N7.js} +19 -34
  54. package/dist/chunk-EIUTZ6N7.js.map +1 -0
  55. package/dist/{chunk-TA3WMOMU.js → chunk-EJZG5VUF.js} +38 -32
  56. package/dist/chunk-EJZG5VUF.js.map +1 -0
  57. package/dist/{chunk-X5HF2OFP.js → chunk-ENW5BVYN.js} +3 -3
  58. package/dist/{chunk-HGCRXJGP.js → chunk-ETIAW4YD.js} +3 -3
  59. package/dist/chunk-EUPXAYPB.js +20 -0
  60. package/dist/chunk-EUPXAYPB.js.map +1 -0
  61. package/dist/{chunk-YAHRT6MB.js → chunk-FA6YNU75.js} +4 -5
  62. package/dist/{chunk-YAHRT6MB.js.map → chunk-FA6YNU75.js.map} +1 -1
  63. package/dist/{chunk-TWGVQLG2.js → chunk-FFH6R5VQ.js} +7 -3
  64. package/dist/chunk-FFH6R5VQ.js.map +1 -0
  65. package/dist/{chunk-JCC4CU2I.js → chunk-GE6H2COM.js} +15 -23
  66. package/dist/chunk-GE6H2COM.js.map +1 -0
  67. package/dist/{chunk-DM4GSE26.js → chunk-GMMQ3ZK4.js} +3 -3
  68. package/dist/{chunk-ZEGAMJO2.js → chunk-GSGE3M5P.js} +15 -23
  69. package/dist/chunk-GSGE3M5P.js.map +1 -0
  70. package/dist/{chunk-GCFYZSVR.js → chunk-H64SB6VO.js} +32 -13
  71. package/dist/chunk-H64SB6VO.js.map +1 -0
  72. package/dist/{chunk-N5FSLVKO.js → chunk-HCRYAFBI.js} +3 -3
  73. package/dist/{chunk-IDYHQQOH.js → chunk-HOPUP6LA.js} +358 -471
  74. package/dist/chunk-HOPUP6LA.js.map +1 -0
  75. package/dist/chunk-HS24BL6W.js +160 -0
  76. package/dist/chunk-HS24BL6W.js.map +1 -0
  77. package/dist/chunk-HVYVG5KQ.js +16 -0
  78. package/dist/chunk-HVYVG5KQ.js.map +1 -0
  79. package/dist/{chunk-FQ33BYFR.js → chunk-I7CPLZNW.js} +4 -5
  80. package/dist/{chunk-FQ33BYFR.js.map → chunk-I7CPLZNW.js.map} +1 -1
  81. package/dist/{chunk-VGLHY6BK.js → chunk-IFUCGI4I.js} +7 -3
  82. package/dist/chunk-IFUCGI4I.js.map +1 -0
  83. package/dist/{chunk-RNQN2FOU.js → chunk-IFYXSSKR.js} +24 -13
  84. package/dist/chunk-IFYXSSKR.js.map +1 -0
  85. package/dist/chunk-IXA4DQE4.js +20 -0
  86. package/dist/chunk-IXA4DQE4.js.map +1 -0
  87. package/dist/chunk-IZMKMD3O.js +11 -0
  88. package/dist/chunk-IZMKMD3O.js.map +1 -0
  89. package/dist/{chunk-7CW3BMPH.js → chunk-JJERW2BI.js} +4 -5
  90. package/dist/{chunk-7CW3BMPH.js.map → chunk-JJERW2BI.js.map} +1 -1
  91. package/dist/{chunk-EM4J5EQS.js → chunk-JQR4HVUX.js} +13 -16
  92. package/dist/chunk-JQR4HVUX.js.map +1 -0
  93. package/dist/{chunk-VWKUT4CW.js → chunk-JXOMDLFS.js} +21 -26
  94. package/dist/chunk-JXOMDLFS.js.map +1 -0
  95. package/dist/chunk-KIX6N7NT.js +1001 -0
  96. package/dist/chunk-KIX6N7NT.js.map +1 -0
  97. package/dist/{chunk-OZAEWZZ3.js → chunk-L42UTDFK.js} +12 -3
  98. package/dist/chunk-L42UTDFK.js.map +1 -0
  99. package/dist/{chunk-54NTYJEO.js → chunk-LPDLPRPS.js} +1 -3
  100. package/dist/{chunk-54NTYJEO.js.map → chunk-LPDLPRPS.js.map} +1 -1
  101. package/dist/chunk-M2UF2JHJ.js +11 -0
  102. package/dist/chunk-M2UF2JHJ.js.map +1 -0
  103. package/dist/{chunk-UGK4TAVK.js → chunk-MONC734W.js} +7 -3
  104. package/dist/chunk-MONC734W.js.map +1 -0
  105. package/dist/{chunk-IK2L4EN3.js → chunk-N72RLCMU.js} +4 -5
  106. package/dist/{chunk-IK2L4EN3.js.map → chunk-N72RLCMU.js.map} +1 -1
  107. package/dist/{chunk-H3I2KZIY.js → chunk-ND4IWJ4V.js} +7 -3
  108. package/dist/chunk-ND4IWJ4V.js.map +1 -0
  109. package/dist/chunk-NZ3EKGW4.js +1312 -0
  110. package/dist/chunk-NZ3EKGW4.js.map +1 -0
  111. package/dist/{chunk-XGJ2QERC.js → chunk-OAE57MNL.js} +27 -11
  112. package/dist/chunk-OAE57MNL.js.map +1 -0
  113. package/dist/{chunk-EZQ5HBAC.js → chunk-OHKGIQB4.js} +12 -16
  114. package/dist/chunk-OHKGIQB4.js.map +1 -0
  115. package/dist/{chunk-E2ISWXLB.js → chunk-OQKNDS66.js} +1 -1
  116. package/dist/{chunk-E2ISWXLB.js.map → chunk-OQKNDS66.js.map} +1 -1
  117. package/dist/{chunk-UINQOUZR.js → chunk-OXEQSPND.js} +3 -3
  118. package/dist/{chunk-A7IVFIOP.js → chunk-PKNE5J2B.js} +15 -23
  119. package/dist/chunk-PKNE5J2B.js.map +1 -0
  120. package/dist/chunk-PSXXEGYQ.js +16 -0
  121. package/dist/chunk-PSXXEGYQ.js.map +1 -0
  122. package/dist/{chunk-EGB7V74Z.js → chunk-QAOVABCR.js} +7 -4
  123. package/dist/chunk-QAOVABCR.js.map +1 -0
  124. package/dist/{chunk-X3G37FXT.js → chunk-QQ7FP4GD.js} +4 -5
  125. package/dist/{chunk-X3G37FXT.js.map → chunk-QQ7FP4GD.js.map} +1 -1
  126. package/dist/{chunk-WAR4Q2NM.js → chunk-QYLVMC6B.js} +13 -15
  127. package/dist/chunk-QYLVMC6B.js.map +1 -0
  128. package/dist/{chunk-KPULTUOK.js → chunk-RX3XR65X.js} +4 -5
  129. package/dist/{chunk-KPULTUOK.js.map → chunk-RX3XR65X.js.map} +1 -1
  130. package/dist/chunk-RYQJJB4C.js +30 -0
  131. package/dist/chunk-RYQJJB4C.js.map +1 -0
  132. package/dist/{chunk-QQBJC2FQ.js → chunk-TUF7TCN7.js} +4 -5
  133. package/dist/{chunk-QQBJC2FQ.js.map → chunk-TUF7TCN7.js.map} +1 -1
  134. package/dist/{chunk-AUHSTJJ3.js → chunk-TUX36JY5.js} +4 -5
  135. package/dist/{chunk-AUHSTJJ3.js.map → chunk-TUX36JY5.js.map} +1 -1
  136. package/dist/chunk-TWRQCQWU.js +1153 -0
  137. package/dist/chunk-TWRQCQWU.js.map +1 -0
  138. package/dist/chunk-U6DFQRG3.js +20 -0
  139. package/dist/chunk-U6DFQRG3.js.map +1 -0
  140. package/dist/chunk-VI5YTKNY.js +20 -0
  141. package/dist/chunk-VI5YTKNY.js.map +1 -0
  142. package/dist/chunk-WG5YS6TC.js +872 -0
  143. package/dist/chunk-WG5YS6TC.js.map +1 -0
  144. package/dist/{chunk-ZGSER5TG.js → chunk-WMJJ4WGF.js} +4 -5
  145. package/dist/{chunk-ZGSER5TG.js.map → chunk-WMJJ4WGF.js.map} +1 -1
  146. package/dist/{chunk-LV2G7VHL.js → chunk-WY4FNH42.js} +21 -18
  147. package/dist/chunk-WY4FNH42.js.map +1 -0
  148. package/dist/{chunk-LAJJPLEV.js → chunk-XIG5BWWH.js} +25 -12
  149. package/dist/chunk-XIG5BWWH.js.map +1 -0
  150. package/dist/chunk-XJBC3OYX.js +11 -0
  151. package/dist/chunk-XJBC3OYX.js.map +1 -0
  152. package/dist/{chunk-G2WCEUQL.js → chunk-XPRDXWK7.js} +21 -20
  153. package/dist/chunk-XPRDXWK7.js.map +1 -0
  154. package/dist/chunk-YKRQSZS7.js +96 -0
  155. package/dist/chunk-YKRQSZS7.js.map +1 -0
  156. package/dist/{chunk-M5FVUIYP.js → chunk-YMBL3VJB.js} +21 -19
  157. package/dist/chunk-YMBL3VJB.js.map +1 -0
  158. package/dist/chunk-YUJBXFYK.js +1205 -0
  159. package/dist/chunk-YUJBXFYK.js.map +1 -0
  160. package/dist/{chunk-JALIYI6M.js → chunk-YZ4ZJNOL.js} +28 -11
  161. package/dist/chunk-YZ4ZJNOL.js.map +1 -0
  162. package/dist/chunk-ZTHVEXIV.js +11 -0
  163. package/dist/chunk-ZTHVEXIV.js.map +1 -0
  164. package/dist/{chunk-GS5AUKUO.js → chunk-ZVSYUCYS.js} +11 -7
  165. package/dist/chunk-ZVSYUCYS.js.map +1 -0
  166. package/dist/{config-QAA646XB.js → config-2YBCHU2W.js} +2 -4
  167. package/dist/{config-IVY5EQQ2.js → config-3YRGRW72.js} +3 -4
  168. package/dist/config-4GSOMUMF.js +9 -0
  169. package/dist/config-5YBUWFUP.js +9 -0
  170. package/dist/{config-34LHOGLM.js → config-5ZRKJTKG.js} +3 -4
  171. package/dist/config-A25LTL5W.js +11 -0
  172. package/dist/config-CLU7JABG.js +9 -0
  173. package/dist/config-D2RF7L3N.js +9 -0
  174. package/dist/{config-LHFFXVYI.js → config-E55TKM6K.js} +2 -4
  175. package/dist/config-ELDOFRJW.js +9 -0
  176. package/dist/{config-GE4W4ZJC.js → config-FPC3RBFD.js} +2 -4
  177. package/dist/config-FPM3LAW7.js +9 -0
  178. package/dist/{config-HKRMKD76.js → config-G3F54CS4.js} +3 -4
  179. package/dist/config-G43HRUI3.js +9 -0
  180. package/dist/{config-WDAZFXYD.js → config-GG3WO5PB.js} +3 -4
  181. package/dist/config-JUYBWAZE.js +9 -0
  182. package/dist/{config-CVZ2AGCO.js → config-LJ5T6TVA.js} +2 -6
  183. package/dist/config-MDSAE4O3.js +11 -0
  184. package/dist/{config-EIHSP5DZ.js → config-NRIOKK5T.js} +2 -4
  185. package/dist/config-OYK2BSJK.js +9 -0
  186. package/dist/config-PB3KA2CE.js +9 -0
  187. package/dist/{config-ZFJYQZCH.js → config-QY4IL3PH.js} +3 -4
  188. package/dist/config-R4LAOEDS.js +9 -0
  189. package/dist/{config-QNMKWJ4M.js → config-RIAAD6RW.js} +3 -4
  190. package/dist/config-SYNEQAUB.js +9 -0
  191. package/dist/{config-Q45Y46YT.js → config-TJKGYA2B.js} +3 -4
  192. package/dist/{config-NV5WXP64.js → config-UU27ALAA.js} +2 -4
  193. package/dist/{config-3IVQJBNW.js → config-UURRGA7U.js} +2 -2
  194. package/dist/{config-VM526IKB.js → config-VPLHQXVE.js} +2 -4
  195. package/dist/config-WRACCRPN.js +9 -0
  196. package/dist/{config-GHRUKEQ6.js → config-WVHKXEVE.js} +3 -4
  197. package/dist/{config-EO23EY62.js → config-XU7R36IE.js} +3 -4
  198. package/dist/config-Y2KOUYSS.js +9 -0
  199. package/dist/databricks_volume-CNCPTZHS.js +7 -0
  200. package/dist/digitalocean-DJZOUB6Q.js +11 -0
  201. package/dist/discord-ETB2CADR.js +7 -0
  202. package/dist/disk-WEHSTK3F.js +7 -0
  203. package/dist/dropbox-XN6PGLNE.js +8 -0
  204. package/dist/email-OV7XCP3T.js +8 -0
  205. package/dist/gcal-P56MRCGU.js +8 -0
  206. package/dist/gcs-HFBIAE2C.js +10 -0
  207. package/dist/gdocs-LQ3UXP3J.js +8 -0
  208. package/dist/gdrive-N6UBYLON.js +8 -0
  209. package/dist/github-BPZREGPI.js +8 -0
  210. package/dist/github_ci-7A4LUIZ7.js +8 -0
  211. package/dist/gmail-YED2MF6H.js +8 -0
  212. package/dist/gridfs-CPLQ4G62.js +9 -0
  213. package/dist/gsheets-4BNIJPQ6.js +8 -0
  214. package/dist/gslides-GDBYLO5A.js +8 -0
  215. package/dist/hf_buckets-FTJITQ3P.js +10 -0
  216. package/dist/hf_datasets-6GXVKQD7.js +10 -0
  217. package/dist/hf_models-PJPGZAC5.js +10 -0
  218. package/dist/hf_spaces-LFNFOLBF.js +10 -0
  219. package/dist/index.d.ts +1311 -569
  220. package/dist/index.js +3359 -964
  221. package/dist/index.js.map +1 -1
  222. package/dist/jaeger-GCA6MJ6E.js +8 -0
  223. package/dist/lancedb-TJ5YSJY5.js +7 -0
  224. package/dist/langfuse-RUMTUMXS.js +8 -0
  225. package/dist/linear-BCE4KEAC.js +7 -0
  226. package/dist/minio-5SO6KBTK.js +11 -0
  227. package/dist/mongodb-L5CMN2EE.js +7 -0
  228. package/dist/nextcloud-4O2LZVW2.js +9 -0
  229. package/dist/notion-RVKEAQ2M.js +7 -0
  230. package/dist/oci-OQXOIC62.js +10 -0
  231. package/dist/postgres-AV45GNRS.js +7 -0
  232. package/dist/qingstor-W277YA4K.js +11 -0
  233. package/dist/r2-FUA4IORE.js +10 -0
  234. package/dist/redis-LPS357NF.js +8 -0
  235. package/dist/s3-FPNWWIVM.js +8 -0
  236. package/dist/scaleway-BP3732U7.js +11 -0
  237. package/dist/seaweedfs-MC6HIEP4.js +11 -0
  238. package/dist/slack-JFGW7VLN.js +7 -0
  239. package/dist/ssh-UYPG42LM.js +8 -0
  240. package/dist/ssh-UYPG42LM.js.map +1 -0
  241. package/dist/supabase-A3KUFMDC.js +10 -0
  242. package/dist/supabase-A3KUFMDC.js.map +1 -0
  243. package/dist/tencent-5464UQ2X.js +11 -0
  244. package/dist/tencent-5464UQ2X.js.map +1 -0
  245. package/dist/trello-O2KB3FUO.js +8 -0
  246. package/dist/trello-O2KB3FUO.js.map +1 -0
  247. package/dist/wasabi-2IKBIWNO.js +10 -0
  248. package/dist/wasabi-2IKBIWNO.js.map +1 -0
  249. package/package.json +17 -3
  250. package/dist/aliyun-JMJ3PFYY.js +0 -10
  251. package/dist/backblaze-TDFD23QO.js +0 -10
  252. package/dist/box-GQ2U2R6R.js +0 -8
  253. package/dist/ceph-S2VOYO6G.js +0 -10
  254. package/dist/chunk-2CC5VW7K.js +0 -52
  255. package/dist/chunk-2CC5VW7K.js.map +0 -1
  256. package/dist/chunk-A7IVFIOP.js.map +0 -1
  257. package/dist/chunk-B2ZOKNN4.js.map +0 -1
  258. package/dist/chunk-DNBAMB5J.js +0 -18
  259. package/dist/chunk-DNBAMB5J.js.map +0 -1
  260. package/dist/chunk-DP2PP5V2.js +0 -26
  261. package/dist/chunk-DP2PP5V2.js.map +0 -1
  262. package/dist/chunk-DYXEITK3.js +0 -52
  263. package/dist/chunk-DYXEITK3.js.map +0 -1
  264. package/dist/chunk-EGB7V74Z.js.map +0 -1
  265. package/dist/chunk-EM4J5EQS.js.map +0 -1
  266. package/dist/chunk-EZQ5HBAC.js.map +0 -1
  267. package/dist/chunk-G2WCEUQL.js.map +0 -1
  268. package/dist/chunk-GCFYZSVR.js.map +0 -1
  269. package/dist/chunk-GS5AUKUO.js.map +0 -1
  270. package/dist/chunk-H3BST2LI.js +0 -26
  271. package/dist/chunk-H3BST2LI.js.map +0 -1
  272. package/dist/chunk-H3I2KZIY.js.map +0 -1
  273. package/dist/chunk-IDYHQQOH.js.map +0 -1
  274. package/dist/chunk-JAGJTM3Q.js.map +0 -1
  275. package/dist/chunk-JALIYI6M.js.map +0 -1
  276. package/dist/chunk-JCC4CU2I.js.map +0 -1
  277. package/dist/chunk-JZT4QGIP.js +0 -24
  278. package/dist/chunk-JZT4QGIP.js.map +0 -1
  279. package/dist/chunk-LAJJPLEV.js.map +0 -1
  280. package/dist/chunk-LV2G7VHL.js.map +0 -1
  281. package/dist/chunk-LW25LMIH.js +0 -26
  282. package/dist/chunk-LW25LMIH.js.map +0 -1
  283. package/dist/chunk-M5FVUIYP.js.map +0 -1
  284. package/dist/chunk-MPCCRRE6.js.map +0 -1
  285. package/dist/chunk-NJMGCT63.js +0 -54
  286. package/dist/chunk-NJMGCT63.js.map +0 -1
  287. package/dist/chunk-NOHWIBRX.js.map +0 -1
  288. package/dist/chunk-OHROA3FQ.js +0 -54
  289. package/dist/chunk-OHROA3FQ.js.map +0 -1
  290. package/dist/chunk-OPYQ5KIO.js +0 -52
  291. package/dist/chunk-OPYQ5KIO.js.map +0 -1
  292. package/dist/chunk-OZAEWZZ3.js.map +0 -1
  293. package/dist/chunk-Q2IAILVC.js.map +0 -1
  294. package/dist/chunk-QCZ2XUKH.js.map +0 -1
  295. package/dist/chunk-QGRDPSAH.js.map +0 -1
  296. package/dist/chunk-RNQN2FOU.js.map +0 -1
  297. package/dist/chunk-RO5IQEDQ.js.map +0 -1
  298. package/dist/chunk-RQK5UPMP.js.map +0 -1
  299. package/dist/chunk-S5OVP467.js +0 -1795
  300. package/dist/chunk-S5OVP467.js.map +0 -1
  301. package/dist/chunk-SFUCUARB.js +0 -21
  302. package/dist/chunk-SFUCUARB.js.map +0 -1
  303. package/dist/chunk-SWCDFEUK.js.map +0 -1
  304. package/dist/chunk-TA3WMOMU.js.map +0 -1
  305. package/dist/chunk-TURD42QO.js +0 -1782
  306. package/dist/chunk-TURD42QO.js.map +0 -1
  307. package/dist/chunk-TWGVQLG2.js.map +0 -1
  308. package/dist/chunk-U6QSXTUS.js +0 -7
  309. package/dist/chunk-U6QSXTUS.js.map +0 -1
  310. package/dist/chunk-UGK4TAVK.js.map +0 -1
  311. package/dist/chunk-UT2OPSN4.js.map +0 -1
  312. package/dist/chunk-VGLHY6BK.js.map +0 -1
  313. package/dist/chunk-VWKUT4CW.js.map +0 -1
  314. package/dist/chunk-W7FLHT65.js +0 -26
  315. package/dist/chunk-W7FLHT65.js.map +0 -1
  316. package/dist/chunk-WAR4Q2NM.js.map +0 -1
  317. package/dist/chunk-WHFUWWI6.js +0 -2097
  318. package/dist/chunk-WHFUWWI6.js.map +0 -1
  319. package/dist/chunk-XGJ2QERC.js.map +0 -1
  320. package/dist/chunk-XHCBHYN4.js +0 -54
  321. package/dist/chunk-XHCBHYN4.js.map +0 -1
  322. package/dist/chunk-XLQI4IT2.js +0 -54
  323. package/dist/chunk-XLQI4IT2.js.map +0 -1
  324. package/dist/chunk-XWVDS66D.js +0 -963
  325. package/dist/chunk-XWVDS66D.js.map +0 -1
  326. package/dist/chunk-YGZMVNN5.js +0 -54
  327. package/dist/chunk-YGZMVNN5.js.map +0 -1
  328. package/dist/chunk-YUK3X3B4.js +0 -27
  329. package/dist/chunk-YUK3X3B4.js.map +0 -1
  330. package/dist/chunk-ZEGAMJO2.js.map +0 -1
  331. package/dist/chunk-ZNWVJ6UW.js +0 -54
  332. package/dist/chunk-ZNWVJ6UW.js.map +0 -1
  333. package/dist/config-3BBWD5AB.js +0 -11
  334. package/dist/config-4UDVSUQJ.js +0 -11
  335. package/dist/config-CMDBAPDH.js +0 -11
  336. package/dist/config-D3RLSPNF.js +0 -11
  337. package/dist/config-DG65OEG3.js +0 -11
  338. package/dist/config-GCQK6NJY.js +0 -11
  339. package/dist/config-GVH27UPE.js +0 -11
  340. package/dist/config-HXVYIXP5.js +0 -11
  341. package/dist/config-IDZMEW73.js +0 -11
  342. package/dist/config-IJJXGLBQ.js +0 -11
  343. package/dist/config-KJOLGVB2.js +0 -11
  344. package/dist/config-KMVCVBYN.js +0 -15
  345. package/dist/config-KYTRXAB2.js +0 -15
  346. package/dist/config-OT2TQQCN.js +0 -11
  347. package/dist/config-QWCY3LBQ.js +0 -11
  348. package/dist/config-ZV6G2ZEC.js +0 -11
  349. package/dist/databricks_volume-7XOUYSTY.js +0 -7
  350. package/dist/digitalocean-3CQ4CPPZ.js +0 -10
  351. package/dist/discord-BG7OSRJG.js +0 -8
  352. package/dist/disk-XVLBCVKE.js +0 -8
  353. package/dist/dropbox-74GYLV3R.js +0 -8
  354. package/dist/email-5IZ7OBQ4.js +0 -8
  355. package/dist/gcs-EMEYU2XT.js +0 -10
  356. package/dist/gdocs-R67TDPON.js +0 -8
  357. package/dist/gdrive-PRN2ALRK.js +0 -8
  358. package/dist/github-DV7E6OFV.js +0 -8
  359. package/dist/github_ci-Q554V5PA.js +0 -8
  360. package/dist/gmail-OLN2LT4O.js +0 -8
  361. package/dist/gsheets-H4RYMQJ5.js +0 -8
  362. package/dist/gslides-YLCHKJOM.js +0 -8
  363. package/dist/hf_buckets-DTKXKKFF.js +0 -10
  364. package/dist/hf_datasets-55C4APKR.js +0 -10
  365. package/dist/hf_models-RO5JR36V.js +0 -10
  366. package/dist/hf_spaces-ZVZ3EDRX.js +0 -10
  367. package/dist/langfuse-ACASJZ7O.js +0 -8
  368. package/dist/linear-IC37LZV7.js +0 -8
  369. package/dist/minio-HZ576XFQ.js +0 -10
  370. package/dist/mongodb-JVR62OIO.js +0 -7
  371. package/dist/notion-HKRPQMJS.js +0 -8
  372. package/dist/oci-ZLVECXTW.js +0 -10
  373. package/dist/postgres-P36Z2YN4.js +0 -7
  374. package/dist/qingstor-YLP6K3L4.js +0 -10
  375. package/dist/r2-RPK25ANI.js +0 -10
  376. package/dist/redis-V5ULXULL.js +0 -8
  377. package/dist/s3-4OIOCAAT.js +0 -8
  378. package/dist/scaleway-CCWCLUHB.js +0 -10
  379. package/dist/seaweedfs-QSWKF2FN.js +0 -10
  380. package/dist/slack-YPS7PII3.js +0 -8
  381. package/dist/ssh-YFP3SMTJ.js +0 -9
  382. package/dist/supabase-6CFTOKGZ.js +0 -10
  383. package/dist/tencent-IWZZOSQ4.js +0 -10
  384. package/dist/trello-XYKWZD6P.js +0 -8
  385. package/dist/wasabi-6Z4DC5S5.js +0 -10
  386. /package/dist/{aliyun-JMJ3PFYY.js.map → aliyun-S62BR3TB.js.map} +0 -0
  387. /package/dist/{backblaze-TDFD23QO.js.map → backblaze-4EKSW63F.js.map} +0 -0
  388. /package/dist/{box-GQ2U2R6R.js.map → box-ZPLZAGMK.js.map} +0 -0
  389. /package/dist/{ceph-S2VOYO6G.js.map → ceph-ALKLD3MO.js.map} +0 -0
  390. /package/dist/{chunk-HJJMP6IX.js.map → chunk-BZTVYOES.js.map} +0 -0
  391. /package/dist/{chunk-X5HF2OFP.js.map → chunk-ENW5BVYN.js.map} +0 -0
  392. /package/dist/{chunk-HGCRXJGP.js.map → chunk-ETIAW4YD.js.map} +0 -0
  393. /package/dist/{chunk-DM4GSE26.js.map → chunk-GMMQ3ZK4.js.map} +0 -0
  394. /package/dist/{chunk-N5FSLVKO.js.map → chunk-HCRYAFBI.js.map} +0 -0
  395. /package/dist/{chunk-UINQOUZR.js.map → chunk-OXEQSPND.js.map} +0 -0
  396. /package/dist/{config-34LHOGLM.js.map → config-2YBCHU2W.js.map} +0 -0
  397. /package/dist/{config-3BBWD5AB.js.map → config-3YRGRW72.js.map} +0 -0
  398. /package/dist/{config-3IVQJBNW.js.map → config-4GSOMUMF.js.map} +0 -0
  399. /package/dist/{config-4UDVSUQJ.js.map → config-5YBUWFUP.js.map} +0 -0
  400. /package/dist/{config-CMDBAPDH.js.map → config-5ZRKJTKG.js.map} +0 -0
  401. /package/dist/{config-CVZ2AGCO.js.map → config-A25LTL5W.js.map} +0 -0
  402. /package/dist/{config-D3RLSPNF.js.map → config-CLU7JABG.js.map} +0 -0
  403. /package/dist/{config-DG65OEG3.js.map → config-D2RF7L3N.js.map} +0 -0
  404. /package/dist/{config-EIHSP5DZ.js.map → config-E55TKM6K.js.map} +0 -0
  405. /package/dist/{config-EO23EY62.js.map → config-ELDOFRJW.js.map} +0 -0
  406. /package/dist/{config-GCQK6NJY.js.map → config-FPC3RBFD.js.map} +0 -0
  407. /package/dist/{config-GE4W4ZJC.js.map → config-FPM3LAW7.js.map} +0 -0
  408. /package/dist/{config-GHRUKEQ6.js.map → config-G3F54CS4.js.map} +0 -0
  409. /package/dist/{config-GVH27UPE.js.map → config-G43HRUI3.js.map} +0 -0
  410. /package/dist/{config-HKRMKD76.js.map → config-GG3WO5PB.js.map} +0 -0
  411. /package/dist/{config-HXVYIXP5.js.map → config-JUYBWAZE.js.map} +0 -0
  412. /package/dist/{config-IDZMEW73.js.map → config-LJ5T6TVA.js.map} +0 -0
  413. /package/dist/{config-IJJXGLBQ.js.map → config-MDSAE4O3.js.map} +0 -0
  414. /package/dist/{config-IVY5EQQ2.js.map → config-NRIOKK5T.js.map} +0 -0
  415. /package/dist/{config-KJOLGVB2.js.map → config-OYK2BSJK.js.map} +0 -0
  416. /package/dist/{config-KMVCVBYN.js.map → config-PB3KA2CE.js.map} +0 -0
  417. /package/dist/{config-KYTRXAB2.js.map → config-QY4IL3PH.js.map} +0 -0
  418. /package/dist/{config-LHFFXVYI.js.map → config-R4LAOEDS.js.map} +0 -0
  419. /package/dist/{config-NV5WXP64.js.map → config-RIAAD6RW.js.map} +0 -0
  420. /package/dist/{config-OT2TQQCN.js.map → config-SYNEQAUB.js.map} +0 -0
  421. /package/dist/{config-Q45Y46YT.js.map → config-TJKGYA2B.js.map} +0 -0
  422. /package/dist/{config-QAA646XB.js.map → config-UU27ALAA.js.map} +0 -0
  423. /package/dist/{config-QNMKWJ4M.js.map → config-UURRGA7U.js.map} +0 -0
  424. /package/dist/{config-QWCY3LBQ.js.map → config-VPLHQXVE.js.map} +0 -0
  425. /package/dist/{config-VM526IKB.js.map → config-WRACCRPN.js.map} +0 -0
  426. /package/dist/{config-WDAZFXYD.js.map → config-WVHKXEVE.js.map} +0 -0
  427. /package/dist/{config-ZFJYQZCH.js.map → config-XU7R36IE.js.map} +0 -0
  428. /package/dist/{config-ZV6G2ZEC.js.map → config-Y2KOUYSS.js.map} +0 -0
  429. /package/dist/{databricks_volume-7XOUYSTY.js.map → databricks_volume-CNCPTZHS.js.map} +0 -0
  430. /package/dist/{digitalocean-3CQ4CPPZ.js.map → digitalocean-DJZOUB6Q.js.map} +0 -0
  431. /package/dist/{discord-BG7OSRJG.js.map → discord-ETB2CADR.js.map} +0 -0
  432. /package/dist/{disk-XVLBCVKE.js.map → disk-WEHSTK3F.js.map} +0 -0
  433. /package/dist/{dropbox-74GYLV3R.js.map → dropbox-XN6PGLNE.js.map} +0 -0
  434. /package/dist/{email-5IZ7OBQ4.js.map → email-OV7XCP3T.js.map} +0 -0
  435. /package/dist/{gcs-EMEYU2XT.js.map → gcal-P56MRCGU.js.map} +0 -0
  436. /package/dist/{gdocs-R67TDPON.js.map → gcs-HFBIAE2C.js.map} +0 -0
  437. /package/dist/{gdrive-PRN2ALRK.js.map → gdocs-LQ3UXP3J.js.map} +0 -0
  438. /package/dist/{github-DV7E6OFV.js.map → gdrive-N6UBYLON.js.map} +0 -0
  439. /package/dist/{github_ci-Q554V5PA.js.map → github-BPZREGPI.js.map} +0 -0
  440. /package/dist/{gmail-OLN2LT4O.js.map → github_ci-7A4LUIZ7.js.map} +0 -0
  441. /package/dist/{gsheets-H4RYMQJ5.js.map → gmail-YED2MF6H.js.map} +0 -0
  442. /package/dist/{gslides-YLCHKJOM.js.map → gridfs-CPLQ4G62.js.map} +0 -0
  443. /package/dist/{hf_buckets-DTKXKKFF.js.map → gsheets-4BNIJPQ6.js.map} +0 -0
  444. /package/dist/{hf_datasets-55C4APKR.js.map → gslides-GDBYLO5A.js.map} +0 -0
  445. /package/dist/{hf_models-RO5JR36V.js.map → hf_buckets-FTJITQ3P.js.map} +0 -0
  446. /package/dist/{hf_spaces-ZVZ3EDRX.js.map → hf_datasets-6GXVKQD7.js.map} +0 -0
  447. /package/dist/{langfuse-ACASJZ7O.js.map → hf_models-PJPGZAC5.js.map} +0 -0
  448. /package/dist/{linear-IC37LZV7.js.map → hf_spaces-LFNFOLBF.js.map} +0 -0
  449. /package/dist/{minio-HZ576XFQ.js.map → jaeger-GCA6MJ6E.js.map} +0 -0
  450. /package/dist/{mongodb-JVR62OIO.js.map → lancedb-TJ5YSJY5.js.map} +0 -0
  451. /package/dist/{notion-HKRPQMJS.js.map → langfuse-RUMTUMXS.js.map} +0 -0
  452. /package/dist/{oci-ZLVECXTW.js.map → linear-BCE4KEAC.js.map} +0 -0
  453. /package/dist/{postgres-P36Z2YN4.js.map → minio-5SO6KBTK.js.map} +0 -0
  454. /package/dist/{qingstor-YLP6K3L4.js.map → mongodb-L5CMN2EE.js.map} +0 -0
  455. /package/dist/{r2-RPK25ANI.js.map → nextcloud-4O2LZVW2.js.map} +0 -0
  456. /package/dist/{redis-V5ULXULL.js.map → notion-RVKEAQ2M.js.map} +0 -0
  457. /package/dist/{s3-4OIOCAAT.js.map → oci-OQXOIC62.js.map} +0 -0
  458. /package/dist/{scaleway-CCWCLUHB.js.map → postgres-AV45GNRS.js.map} +0 -0
  459. /package/dist/{seaweedfs-QSWKF2FN.js.map → qingstor-W277YA4K.js.map} +0 -0
  460. /package/dist/{slack-YPS7PII3.js.map → r2-FUA4IORE.js.map} +0 -0
  461. /package/dist/{ssh-YFP3SMTJ.js.map → redis-LPS357NF.js.map} +0 -0
  462. /package/dist/{supabase-6CFTOKGZ.js.map → s3-FPNWWIVM.js.map} +0 -0
  463. /package/dist/{tencent-IWZZOSQ4.js.map → scaleway-BP3732U7.js.map} +0 -0
  464. /package/dist/{trello-XYKWZD6P.js.map → seaweedfs-MC6HIEP4.js.map} +0 -0
  465. /package/dist/{wasabi-6Z4DC5S5.js.map → slack-JFGW7VLN.js.map} +0 -0
@@ -0,0 +1,1153 @@
1
+ import {
2
+ redactEmailConfig
3
+ } from "./chunk-CRC4YWXB.js";
4
+
5
+ // src/resource/email/email.ts
6
+ import {
7
+ BaseResource,
8
+ PathSpec as PathSpec2,
9
+ ResourceName as ResourceName6,
10
+ makeResolveGlob,
11
+ mountKey as mountKey3,
12
+ mountPrefixOf as mountPrefixOf6
13
+ } from "@struktoai/mirage-core";
14
+
15
+ // src/accessor/email.ts
16
+ import { Accessor, loadOptionalPeer } from "@struktoai/mirage-core";
17
+ var EmailAccessor = class extends Accessor {
18
+ config;
19
+ clientPromise = null;
20
+ constructor(config) {
21
+ super();
22
+ this.config = config;
23
+ }
24
+ async getImap() {
25
+ this.clientPromise ??= (async () => {
26
+ const mod = await loadOptionalPeer(
27
+ () => import("imapflow"),
28
+ { feature: "EmailAccessor", packageName: "imapflow" }
29
+ );
30
+ const client = new mod.ImapFlow({
31
+ host: this.config.imapHost,
32
+ port: this.config.imapPort,
33
+ secure: this.config.useSsl,
34
+ auth: { user: this.config.username, pass: this.config.password },
35
+ logger: false
36
+ });
37
+ await client.connect();
38
+ return client;
39
+ })();
40
+ try {
41
+ return await this.clientPromise;
42
+ } catch (err) {
43
+ this.clientPromise = null;
44
+ throw err;
45
+ }
46
+ }
47
+ async close() {
48
+ if (this.clientPromise === null) return;
49
+ try {
50
+ const c = await this.clientPromise;
51
+ await c.logout();
52
+ } catch {
53
+ }
54
+ this.clientPromise = null;
55
+ }
56
+ };
57
+
58
+ // src/commands/builtin/email/index.ts
59
+ import { ResourceName as ResourceName4, makeGenericCommands } from "@struktoai/mirage-core";
60
+
61
+ // src/commands/builtin/email/find.ts
62
+ import {
63
+ ResourceName,
64
+ command,
65
+ findGeneric,
66
+ resolveGlobOf,
67
+ specOf,
68
+ walkFind
69
+ } from "@struktoai/mirage-core";
70
+
71
+ // src/core/email/readdir.ts
72
+ import {
73
+ enoent,
74
+ IndexEntry,
75
+ PathSpec as PathSpecCtor,
76
+ mountKey,
77
+ mountPrefixOf,
78
+ compareCodePoints
79
+ } from "@struktoai/mirage-core";
80
+
81
+ // src/core/email/_parse.ts
82
+ import { loadOptionalPeer as loadOptionalPeer2 } from "@struktoai/mirage-core";
83
+ var parserPromise = null;
84
+ async function getParser() {
85
+ parserPromise ??= (async () => {
86
+ const mod = await loadOptionalPeer2(
87
+ () => import("mailparser"),
88
+ { feature: "parseRfc822", packageName: "mailparser" }
89
+ );
90
+ return mod.simpleParser;
91
+ })();
92
+ return parserPromise;
93
+ }
94
+ function toAddr(a) {
95
+ if (a === void 0) return { name: "", email: "" };
96
+ return { name: a.name, email: a.address ?? "" };
97
+ }
98
+ function toAddrList(list) {
99
+ if (list === void 0) return [];
100
+ const objs = Array.isArray(list) ? list : [list];
101
+ return objs.flatMap((obj) => obj.value.map((a) => toAddr(a)));
102
+ }
103
+ function rawDateHeader(parsed) {
104
+ const found = parsed.headerLines.find((h) => h.key === "date");
105
+ if (found === void 0) return "";
106
+ const colon = found.line.indexOf(":");
107
+ return colon === -1 ? "" : found.line.slice(colon + 1).trim();
108
+ }
109
+ function fromParsed(parsed, headersOnly) {
110
+ const text = headersOnly ? "" : parsed.text ?? "";
111
+ const html = headersOnly ? "" : typeof parsed.html === "string" ? parsed.html : "";
112
+ const attachments = headersOnly ? [] : parsed.attachments.map((a) => ({
113
+ filename: a.filename ?? "unnamed",
114
+ content_type: a.contentType,
115
+ size: a.size
116
+ }));
117
+ const refsRaw = parsed.references;
118
+ const references = typeof refsRaw === "string" ? refsRaw.split(/\s+/).filter((s) => s !== "") : refsRaw ?? [];
119
+ return {
120
+ from: toAddr(parsed.from?.value[0]),
121
+ reply_to: toAddrList(parsed.replyTo),
122
+ to: toAddrList(parsed.to),
123
+ cc: toAddrList(parsed.cc),
124
+ subject: parsed.subject ?? "",
125
+ date: rawDateHeader(parsed),
126
+ body_text: text,
127
+ body_html: html,
128
+ snippet: text.slice(0, 100),
129
+ message_id: parsed.messageId ?? "",
130
+ in_reply_to: typeof parsed.inReplyTo === "string" && parsed.inReplyTo !== "" ? parsed.inReplyTo : null,
131
+ references,
132
+ has_attachments: attachments.length > 0,
133
+ attachments
134
+ };
135
+ }
136
+ async function parseRfc822(raw, headersOnly = false) {
137
+ const parser = await getParser();
138
+ const parsed = await parser(Buffer.from(raw), { skipHtmlToText: false });
139
+ return fromParsed(parsed, headersOnly);
140
+ }
141
+ async function parseWithPayloads(raw) {
142
+ const parser = await getParser();
143
+ const parsed = await parser(Buffer.from(raw));
144
+ return parsed.attachments.map((a) => ({
145
+ filename: a.filename ?? "unnamed",
146
+ content_type: a.contentType,
147
+ size: a.size,
148
+ payload: new Uint8Array(a.content)
149
+ }));
150
+ }
151
+
152
+ // src/core/email/_client.ts
153
+ function internalDateOf(value) {
154
+ if (value === void 0) return "";
155
+ if (typeof value === "string") return value;
156
+ return value.toISOString();
157
+ }
158
+ async function listFolderEntries(accessor) {
159
+ const imap = await accessor.getImap();
160
+ const tree = await imap.list();
161
+ return tree.map((m) => ({ name: m.pathAsListed, specialUse: m.specialUse ?? null }));
162
+ }
163
+ async function listFolders(accessor) {
164
+ return (await listFolderEntries(accessor)).map((entry) => entry.name);
165
+ }
166
+ async function lockMailbox(imap, folder) {
167
+ try {
168
+ return await imap.getMailboxLock(folder);
169
+ } catch (error) {
170
+ const answered = error.responseText !== void 0;
171
+ if (answered) throw new Error(`no such mailbox '${folder}'`);
172
+ throw error;
173
+ }
174
+ }
175
+ async function listMessageUids(accessor, folder, searchCriteria = "ALL", maxResults = null) {
176
+ const imap = await accessor.getImap();
177
+ const lock = await lockMailbox(imap, folder);
178
+ try {
179
+ const query = parseSearchCriteria(searchCriteria);
180
+ const uidsRaw = await imap.search(query, { uid: true });
181
+ if (uidsRaw === false) throw new Error(`IMAP rejected the search: ${searchCriteria}`);
182
+ const uids = uidsRaw.map((n) => String(n));
183
+ if (maxResults !== null && uids.length > maxResults) {
184
+ return uids.slice(uids.length - maxResults);
185
+ }
186
+ return uids;
187
+ } finally {
188
+ lock.release();
189
+ }
190
+ }
191
+ var FLAG_KEYS = {
192
+ SEEN: "seen",
193
+ ANSWERED: "answered",
194
+ FLAGGED: "flagged",
195
+ DRAFT: "draft",
196
+ DELETED: "deleted"
197
+ };
198
+ var TEXT_KEYS = {
199
+ BODY: "body",
200
+ TEXT: "text",
201
+ SUBJECT: "subject",
202
+ FROM: "from",
203
+ TO: "to"
204
+ };
205
+ var DATE_KEYS = {
206
+ ON: "on",
207
+ SINCE: "since",
208
+ BEFORE: "before",
209
+ SENTON: "sentOn",
210
+ SENTSINCE: "sentSince",
211
+ SENTBEFORE: "sentBefore"
212
+ };
213
+ function andQueries(left, right) {
214
+ const collides = Object.keys(right).some((key) => key in left);
215
+ if (!collides) return { ...left, ...right };
216
+ return { not: { or: [{ not: left }, { not: right }] } };
217
+ }
218
+ var CriteriaParser = class {
219
+ constructor(tokens) {
220
+ this.tokens = tokens;
221
+ }
222
+ tokens;
223
+ index = 0;
224
+ peek() {
225
+ return this.tokens[this.index];
226
+ }
227
+ take() {
228
+ const token = this.peek();
229
+ if (token === void 0) throw new Error("email: truncated IMAP search criteria");
230
+ this.index += 1;
231
+ return token;
232
+ }
233
+ atEnd() {
234
+ return this.index >= this.tokens.length;
235
+ }
236
+ /** One or more keys juxtaposed, which IMAP reads as AND. */
237
+ parseSequence(stopAtParen = false) {
238
+ let query = null;
239
+ while (!this.atEnd()) {
240
+ if (stopAtParen && this.peek() === ")") break;
241
+ const next = this.parseKey();
242
+ query = query === null ? next : andQueries(query, next);
243
+ }
244
+ return query ?? { all: true };
245
+ }
246
+ parseKey() {
247
+ const token = this.take();
248
+ if (token === "(") {
249
+ const inner = this.parseSequence(true);
250
+ if (this.peek() !== ")") throw new Error("email: unbalanced IMAP search criteria");
251
+ this.index += 1;
252
+ return inner;
253
+ }
254
+ const word = token.toUpperCase();
255
+ if (word === "ALL") return { all: true };
256
+ if (word === "NOT") return { not: this.parseKey() };
257
+ if (word === "OR") return { or: [this.parseKey(), this.parseKey()] };
258
+ if (word === "UNSEEN") return { seen: false };
259
+ const flag = FLAG_KEYS[word];
260
+ if (flag !== void 0) return { [flag]: true };
261
+ const textKey = TEXT_KEYS[word];
262
+ if (textKey !== void 0) return { [textKey]: this.take() };
263
+ const dateKey = DATE_KEYS[word];
264
+ if (dateKey !== void 0) {
265
+ const parsed = parseImapDate(this.take());
266
+ if (parsed === null) throw new Error(`email: bad date in IMAP search criteria: ${token}`);
267
+ return { [dateKey]: parsed };
268
+ }
269
+ throw new Error(`email: unsupported IMAP search key '${token}'`);
270
+ }
271
+ };
272
+ function parseSearchCriteria(criteria) {
273
+ if (criteria === "ALL" || criteria === "") return { all: true };
274
+ return new CriteriaParser(tokenizeCriteria(criteria)).parseSequence();
275
+ }
276
+ function tokenizeCriteria(criteria) {
277
+ const tokens = [];
278
+ let i = 0;
279
+ while (i < criteria.length) {
280
+ const char = criteria.charAt(i);
281
+ if (char === " ") {
282
+ i += 1;
283
+ continue;
284
+ }
285
+ if (char === "(" || char === ")") {
286
+ tokens.push(char);
287
+ i += 1;
288
+ continue;
289
+ }
290
+ if (char === '"') {
291
+ let value = "";
292
+ let j = i + 1;
293
+ while (j < criteria.length && criteria.charAt(j) !== '"') {
294
+ if (criteria.charAt(j) === "\\" && j + 1 < criteria.length) j += 1;
295
+ value += criteria.charAt(j);
296
+ j += 1;
297
+ }
298
+ tokens.push(value);
299
+ i = j + 1;
300
+ continue;
301
+ }
302
+ let end = i;
303
+ while (end < criteria.length && !" ()".includes(criteria.charAt(end))) end += 1;
304
+ tokens.push(criteria.slice(i, end));
305
+ i = end;
306
+ }
307
+ return tokens;
308
+ }
309
+ function parseImapDate(s) {
310
+ const m = /^(\d{1,2})-([A-Za-z]{3})-(\d{4})$/.exec(s);
311
+ if (m === null) return null;
312
+ const months = {
313
+ Jan: 0,
314
+ Feb: 1,
315
+ Mar: 2,
316
+ Apr: 3,
317
+ May: 4,
318
+ Jun: 5,
319
+ Jul: 6,
320
+ Aug: 7,
321
+ Sep: 8,
322
+ Oct: 9,
323
+ Nov: 10,
324
+ Dec: 11
325
+ };
326
+ const day = Number.parseInt(m[1] ?? "0", 10);
327
+ const monKey = (m[2] ?? "").slice(0, 1).toUpperCase() + (m[2] ?? "").slice(1).toLowerCase();
328
+ const mon = months[monKey];
329
+ const year = Number.parseInt(m[3] ?? "1970", 10);
330
+ if (mon === void 0) return null;
331
+ const value = new Date(Date.UTC(year, mon, day));
332
+ if (value.getUTCMonth() !== mon || value.getUTCDate() !== day) return null;
333
+ return value;
334
+ }
335
+ async function fetchRawMessage(accessor, folder, uid) {
336
+ const imap = await accessor.getImap();
337
+ const lock = await lockMailbox(imap, folder);
338
+ try {
339
+ const msg = await imap.fetchOne(uid, { source: true, uid: true }, { uid: true });
340
+ if (msg === false) {
341
+ throw new Error(`email: uid ${uid} not found in ${folder}`);
342
+ }
343
+ return msg.source instanceof Buffer ? new Uint8Array(msg.source) : new Uint8Array(0);
344
+ } finally {
345
+ lock.release();
346
+ }
347
+ }
348
+ async function fetchMessage(accessor, folder, uid) {
349
+ const imap = await accessor.getImap();
350
+ const lock = await lockMailbox(imap, folder);
351
+ try {
352
+ const msg = await imap.fetchOne(
353
+ uid,
354
+ { source: true, flags: true, uid: true, internalDate: true },
355
+ { uid: true }
356
+ );
357
+ if (msg === false) {
358
+ throw new Error(`email: uid ${uid} not found in ${folder}`);
359
+ }
360
+ const source = msg.source instanceof Buffer ? new Uint8Array(msg.source) : new Uint8Array(0);
361
+ const parsed = await parseRfc822(source);
362
+ return {
363
+ ...parsed,
364
+ uid,
365
+ flags: msg.flags !== void 0 ? [...msg.flags] : [],
366
+ internalDate: internalDateOf(msg.internalDate)
367
+ };
368
+ } finally {
369
+ lock.release();
370
+ }
371
+ }
372
+ async function fetchHeaders(accessor, folder, uids) {
373
+ if (uids.length === 0) return [];
374
+ const imap = await accessor.getImap();
375
+ const lock = await lockMailbox(imap, folder);
376
+ try {
377
+ const results = [];
378
+ for (const uid of uids) {
379
+ const msg = await imap.fetchOne(
380
+ uid,
381
+ { source: true, flags: true, uid: true, internalDate: true },
382
+ { uid: true }
383
+ );
384
+ if (msg === false) continue;
385
+ const source = msg.source instanceof Buffer ? new Uint8Array(msg.source) : new Uint8Array(0);
386
+ const parsed = await parseRfc822(source);
387
+ results.push({
388
+ ...parsed,
389
+ uid,
390
+ flags: msg.flags !== void 0 ? [...msg.flags] : [],
391
+ internalDate: internalDateOf(msg.internalDate)
392
+ });
393
+ }
394
+ return results;
395
+ } finally {
396
+ lock.release();
397
+ }
398
+ }
399
+ async function fetchAttachment(accessor, folder, uid, filename) {
400
+ const imap = await accessor.getImap();
401
+ const lock = await lockMailbox(imap, folder);
402
+ try {
403
+ const msg = await imap.fetchOne(uid, { source: true }, { uid: true });
404
+ if (msg === false) return null;
405
+ const source = msg.source instanceof Buffer ? new Uint8Array(msg.source) : new Uint8Array(0);
406
+ const attachments = await parseWithPayloads(source);
407
+ for (const att of attachments) {
408
+ if (att.filename === filename) return att.payload;
409
+ }
410
+ return null;
411
+ } finally {
412
+ lock.release();
413
+ }
414
+ }
415
+
416
+ // src/core/email/folders.ts
417
+ async function listFolders2(accessor) {
418
+ return listFolders(accessor);
419
+ }
420
+
421
+ // src/core/email/render.ts
422
+ var encoder = new TextEncoder();
423
+ function messageDocument(message) {
424
+ const body = { ...message };
425
+ delete body.internalDate;
426
+ return body;
427
+ }
428
+ function messageJsonText(message) {
429
+ return JSON.stringify(messageDocument(message));
430
+ }
431
+ function messageJsonBytes(message) {
432
+ return encoder.encode(messageJsonText(message));
433
+ }
434
+ function messagesJsonBytes(messages) {
435
+ return encoder.encode(JSON.stringify(messages.map((m) => messageDocument(m))));
436
+ }
437
+
438
+ // src/core/email/readdir.ts
439
+ var TITLE_MAX = 80;
440
+ var UNSAFE = /[^\w\s\-.]/g;
441
+ var MULTI_UNDERSCORE = /_+/g;
442
+ var EPOCH_DATE = "1970-01-01";
443
+ function sanitize(text) {
444
+ if (text.trim() === "") return "No_Subject";
445
+ let cleaned = text.replace(UNSAFE, "_").replace(/ /g, "_");
446
+ cleaned = cleaned.replace(MULTI_UNDERSCORE, "_").replace(/^_+|_+$/g, "");
447
+ if (cleaned.length > TITLE_MAX) cleaned = `${cleaned.slice(0, TITLE_MAX - 3)}...`;
448
+ return cleaned;
449
+ }
450
+ function msgFilename(subject, uid) {
451
+ return `${sanitize(subject)}__${uid}.email.json`;
452
+ }
453
+ var NAMED_ZONES = {
454
+ UT: 0,
455
+ UTC: 0,
456
+ GMT: 0,
457
+ Z: 0,
458
+ EST: -300,
459
+ EDT: -240,
460
+ CST: -360,
461
+ CDT: -300,
462
+ MST: -420,
463
+ MDT: -360,
464
+ PST: -480,
465
+ PDT: -420
466
+ };
467
+ function statedOffset(value) {
468
+ const numeric = /([+-])(\d{2}):?(\d{2})\s*$/.exec(value);
469
+ if (numeric !== null) {
470
+ const sign = numeric[1] === "-" ? -1 : 1;
471
+ return sign * (Number(numeric[2]) * 60 + Number(numeric[3]));
472
+ }
473
+ const named = /([A-Z]{1,3})\s*$/.exec(value.toUpperCase());
474
+ return NAMED_ZONES[named?.[1] ?? ""] ?? null;
475
+ }
476
+ function ymd(year, month, day) {
477
+ return `${year.toString().padStart(4, "0")}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}`;
478
+ }
479
+ function parseDate(value) {
480
+ if (value.trim() === "") return null;
481
+ const d = new Date(value);
482
+ if (Number.isNaN(d.getTime())) return null;
483
+ const offset = statedOffset(value);
484
+ if (offset === null) return ymd(d.getFullYear(), d.getMonth() + 1, d.getDate());
485
+ const shifted = new Date(d.getTime() + offset * 6e4);
486
+ return ymd(shifted.getUTCFullYear(), shifted.getUTCMonth() + 1, shifted.getUTCDate());
487
+ }
488
+ function dateBucket(message) {
489
+ return parseDate(message.date) ?? parseDate(message.internalDate) ?? EPOCH_DATE;
490
+ }
491
+ async function readdir(accessor, path, index) {
492
+ const prefix = mountPrefixOf(path.virtual, path.resourcePath);
493
+ const key = (path.pattern !== null ? path.dir : path).resourcePath;
494
+ const virtualKey = key !== "" ? `${prefix}/${key}` : prefix !== "" ? prefix : "/";
495
+ const parts = key === "" ? [] : key.split("/");
496
+ const depth = parts.length;
497
+ if (depth === 0) {
498
+ if (index !== void 0) {
499
+ const cached = await index.listDir(virtualKey);
500
+ if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
501
+ }
502
+ const folders = await listFolders2(accessor);
503
+ const entries = [];
504
+ for (const folderName of folders) {
505
+ const entry = new IndexEntry({
506
+ id: folderName,
507
+ name: folderName,
508
+ resourceType: "email/folder",
509
+ vfsName: folderName
510
+ });
511
+ entries.push([folderName, entry]);
512
+ }
513
+ if (index !== void 0) await index.setDir(virtualKey, entries);
514
+ return entries.map(([name]) => `${prefix}/${name}`);
515
+ }
516
+ if (depth === 1) {
517
+ const folderName = parts[0] ?? "";
518
+ if (index !== void 0) {
519
+ const cached = await index.listDir(virtualKey);
520
+ if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
521
+ }
522
+ if (index === void 0) throw enoent(path.virtual);
523
+ if (!(await listFolders2(accessor)).includes(folderName)) throw enoent(path.virtual);
524
+ const maxMessages = accessor.config.maxMessages;
525
+ const uids = await listMessageUids(accessor, folderName, "ALL", maxMessages);
526
+ const headersList = await fetchHeaders(accessor, folderName, uids);
527
+ const dateGroups = /* @__PURE__ */ new Map();
528
+ for (const hdr of headersList) {
529
+ const dateStr = dateBucket(hdr);
530
+ let bucket = dateGroups.get(dateStr);
531
+ if (bucket === void 0) {
532
+ bucket = [];
533
+ dateGroups.set(dateStr, bucket);
534
+ }
535
+ bucket.push(hdr);
536
+ }
537
+ const sortedDates = [...dateGroups.keys()].sort(compareCodePoints).reverse();
538
+ const dateEntries = [];
539
+ for (const dateStr of sortedDates) {
540
+ const dateEntry = new IndexEntry({
541
+ id: dateStr,
542
+ name: dateStr,
543
+ resourceType: "email/date",
544
+ vfsName: dateStr
545
+ });
546
+ dateEntries.push([dateStr, dateEntry]);
547
+ const msgEntries = [];
548
+ for (const hdr of dateGroups.get(dateStr) ?? []) {
549
+ const uid = hdr.uid;
550
+ const subject = hdr.subject || "No Subject";
551
+ const filename = msgFilename(subject, uid);
552
+ const msgEntry = new IndexEntry({
553
+ id: uid,
554
+ name: subject,
555
+ resourceType: "email/message",
556
+ vfsName: filename,
557
+ size: messageJsonBytes(hdr).byteLength
558
+ });
559
+ msgEntries.push([filename, msgEntry]);
560
+ const attachments = hdr.attachments;
561
+ if (attachments.length > 0) {
562
+ const attDirName = filename.replace(".email.json", "");
563
+ const attDirEntry = new IndexEntry({
564
+ id: uid,
565
+ name: attDirName,
566
+ resourceType: "email/attachment_dir",
567
+ vfsName: attDirName
568
+ });
569
+ msgEntries.push([attDirName, attDirEntry]);
570
+ const attEntries = [];
571
+ for (const att of attachments) {
572
+ const attEntry = new IndexEntry({
573
+ id: att.filename,
574
+ name: att.filename,
575
+ resourceType: "email/attachment",
576
+ vfsName: att.filename,
577
+ size: att.size
578
+ });
579
+ attEntries.push([att.filename, attEntry]);
580
+ }
581
+ const attDirVKey = `${virtualKey}/${dateStr}/${attDirName}`;
582
+ await index.setDir(attDirVKey, attEntries);
583
+ }
584
+ }
585
+ const dateVKey = `${virtualKey}/${dateStr}`;
586
+ await index.setDir(dateVKey, msgEntries);
587
+ }
588
+ await index.setDir(virtualKey, dateEntries);
589
+ return dateEntries.map(([name]) => `${prefix}/${key}/${name}`);
590
+ }
591
+ if (depth === 2 || depth === 3) {
592
+ if (index === void 0) throw enoent(path.virtual);
593
+ let cached = await index.listDir(virtualKey);
594
+ if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
595
+ const folderPath = prefix !== "" ? `${prefix}/${parts[0] ?? ""}` : `/${parts[0] ?? ""}`;
596
+ const folderSpec = new PathSpecCtor({
597
+ virtual: folderPath,
598
+ directory: folderPath,
599
+ resourcePath: mountKey(folderPath, prefix)
600
+ });
601
+ await readdir(accessor, folderSpec, index);
602
+ cached = await index.listDir(virtualKey);
603
+ if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
604
+ throw enoent(path.virtual);
605
+ }
606
+ throw enoent(path.virtual);
607
+ }
608
+
609
+ // src/core/email/stat.ts
610
+ import {
611
+ FileStat,
612
+ FileType,
613
+ PathSpec,
614
+ enoent as enoent2,
615
+ guessType,
616
+ mountKey as mountKey2,
617
+ mountPrefixOf as mountPrefixOf2
618
+ } from "@struktoai/mirage-core";
619
+ async function stat(accessor, path, index) {
620
+ const prefix = mountPrefixOf2(path.virtual, path.resourcePath);
621
+ const key = path.resourcePath;
622
+ if (key === "") return new FileStat({ name: "/", type: FileType.DIRECTORY });
623
+ if (index === void 0) throw enoent2(path.virtual);
624
+ const virtualKey = prefix !== "" ? `${prefix}/${key}` : `/${key}`;
625
+ let result = await index.get(virtualKey);
626
+ if (result.entry === void 0 || result.entry === null) {
627
+ if (!key.includes("/")) {
628
+ const folders = await listFolders2(accessor);
629
+ if (folders.includes(key)) return new FileStat({ name: key, type: FileType.DIRECTORY });
630
+ throw enoent2(path.virtual);
631
+ }
632
+ const parentVirtual = virtualKey.slice(0, virtualKey.lastIndexOf("/")) || "/";
633
+ try {
634
+ await readdir(
635
+ accessor,
636
+ new PathSpec({
637
+ virtual: parentVirtual,
638
+ directory: parentVirtual,
639
+ resolved: false,
640
+ resourcePath: mountKey2(parentVirtual, prefix)
641
+ }),
642
+ index
643
+ );
644
+ } catch {
645
+ throw enoent2(path.virtual);
646
+ }
647
+ result = await index.get(virtualKey);
648
+ if (result.entry === void 0 || result.entry === null) throw enoent2(path.virtual);
649
+ }
650
+ const rt = result.entry.resourceType;
651
+ const vfsName = result.entry.vfsName !== "" ? result.entry.vfsName : result.entry.name;
652
+ if (rt === "email/folder") return new FileStat({ name: vfsName, type: FileType.DIRECTORY });
653
+ if (rt === "email/date") return new FileStat({ name: vfsName, type: FileType.DIRECTORY });
654
+ if (rt === "email/message") {
655
+ return new FileStat({
656
+ name: vfsName,
657
+ type: FileType.JSON,
658
+ size: result.entry.size,
659
+ extra: { uid: result.entry.id }
660
+ });
661
+ }
662
+ if (rt === "email/attachment_dir") {
663
+ return new FileStat({
664
+ name: vfsName,
665
+ type: FileType.DIRECTORY,
666
+ extra: { uid: result.entry.id }
667
+ });
668
+ }
669
+ if (rt === "email/attachment") {
670
+ return new FileStat({
671
+ name: vfsName,
672
+ type: guessType(vfsName),
673
+ size: result.entry.size,
674
+ extra: { attachment_id: result.entry.id }
675
+ });
676
+ }
677
+ return new FileStat({ name: vfsName, type: FileType.JSON, extra: { uid: result.entry.id } });
678
+ }
679
+
680
+ // src/core/email/read.ts
681
+ import { eisdir, enoent as enoent3, gnuDirname, mountPrefixOf as mountPrefixOf3, stripSlash } from "@struktoai/mirage-core";
682
+ async function read(accessor, path, index) {
683
+ const prefix = mountPrefixOf3(path.virtual, path.resourcePath);
684
+ const key = path.resourcePath;
685
+ if (index === void 0) throw enoent3(path.virtual);
686
+ const virtualKey = prefix !== "" ? `${prefix}/${key}` : `/${key}`;
687
+ const result = await index.get(virtualKey);
688
+ if (result.entry === void 0 || result.entry === null) throw enoent3(path.virtual);
689
+ const rt = result.entry.resourceType;
690
+ if (rt === "email/folder" || rt === "email/date" || rt === "email/attachment_dir") {
691
+ throw eisdir(path.virtual);
692
+ }
693
+ if (rt === "email/attachment") {
694
+ const parentKey = gnuDirname(virtualKey);
695
+ const parentResult = await index.get(parentKey);
696
+ if (parentResult.entry === void 0 || parentResult.entry === null) {
697
+ throw enoent3(path.virtual);
698
+ }
699
+ const uid2 = parentResult.entry.id;
700
+ const parts2 = stripSlash(virtualKey).split("/");
701
+ const folder2 = prefix !== "" ? parts2[1] ?? "" : parts2[0] ?? "";
702
+ const filename = result.entry.vfsName !== "" ? result.entry.vfsName : result.entry.name;
703
+ const data = await fetchAttachment(accessor, folder2, uid2, filename);
704
+ if (data === null) throw enoent3(path.virtual);
705
+ return data;
706
+ }
707
+ const parts = stripSlash(virtualKey).split("/");
708
+ const folder = prefix !== "" ? parts[1] ?? "" : parts[0] ?? "";
709
+ const uid = result.entry.id;
710
+ const msg = await fetchMessage(accessor, folder, uid);
711
+ return messageJsonBytes(msg);
712
+ }
713
+
714
+ // src/commands/builtin/email/io.ts
715
+ async function* emailReadStream(accessor, path, index) {
716
+ yield await read(accessor, path, index);
717
+ }
718
+ var EMAIL_IO = {
719
+ readdir,
720
+ readBytes: read,
721
+ readStream: emailReadStream,
722
+ stat,
723
+ isMounted: () => true,
724
+ local: false
725
+ };
726
+
727
+ // src/commands/builtin/email/provision.ts
728
+ import {
729
+ Precision,
730
+ ProvisionResult
731
+ } from "@struktoai/mirage-core";
732
+ async function fileReadProvision(_accessor, paths, _texts, opts) {
733
+ if (paths.length === 0) return new ProvisionResult({ precision: Precision.UNKNOWN });
734
+ const index = opts.index ?? void 0;
735
+ let ops = 0;
736
+ if (index !== void 0) {
737
+ for (const p of paths) {
738
+ const lookup = await index.get(p.virtual);
739
+ if (lookup.entry !== void 0 && lookup.entry !== null) ops += 1;
740
+ }
741
+ }
742
+ return new ProvisionResult({
743
+ networkReadLow: 0,
744
+ networkReadHigh: 0,
745
+ readOps: ops,
746
+ precision: Precision.EXACT
747
+ });
748
+ }
749
+ function metadataProvision(_accessor, _paths, _texts, _opts) {
750
+ return new ProvisionResult({
751
+ networkReadLow: 0,
752
+ networkReadHigh: 0,
753
+ readOps: 0,
754
+ precision: Precision.EXACT
755
+ });
756
+ }
757
+
758
+ // src/commands/builtin/email/find.ts
759
+ var resolveGlob = resolveGlobOf(EMAIL_IO);
760
+ async function findCommand(accessor, paths, texts, opts) {
761
+ const idx = opts.index ?? void 0;
762
+ const resolved = await resolveGlob(accessor, paths, idx);
763
+ const dirEmpty = async (spec) => (await readdir(accessor, spec, idx)).length === 0;
764
+ return findGeneric(
765
+ resolved,
766
+ texts,
767
+ opts,
768
+ (root, options) => walkFind(
769
+ root,
770
+ {
771
+ readdir: (spec, i) => readdir(accessor, spec, i),
772
+ stat: async (spec, i) => {
773
+ const st = await stat(accessor, spec, i);
774
+ const overlay = opts.ns?.statOverlay;
775
+ return overlay !== void 0 ? overlay(spec.virtual, st) : st;
776
+ },
777
+ links: opts.ns?.links ?? null
778
+ },
779
+ options,
780
+ idx
781
+ ),
782
+ void 0,
783
+ dirEmpty
784
+ );
785
+ }
786
+ var EMAIL_FIND = command({
787
+ name: "find",
788
+ resource: ResourceName.EMAIL,
789
+ spec: specOf("find"),
790
+ fn: findCommand,
791
+ provision: metadataProvision
792
+ });
793
+
794
+ // src/commands/builtin/email/grep.ts
795
+ import {
796
+ IOResult,
797
+ ResourceName as ResourceName2,
798
+ command as command2,
799
+ compilePattern,
800
+ grepGeneric,
801
+ grepLines,
802
+ mountPrefixOf as mountPrefixOf4,
803
+ prefixAggregate,
804
+ resolveGlobOf as resolveGlobOf2,
805
+ specOf as specOf2
806
+ } from "@struktoai/mirage-core";
807
+
808
+ // src/core/email/scope.ts
809
+ import { stripSlash as stripSlash2 } from "@struktoai/mirage-core";
810
+ function detectScope(path) {
811
+ const key = stripSlash2(path.mountPath);
812
+ if (key === "") {
813
+ return { useNative: false, folder: null, resourcePath: "/" };
814
+ }
815
+ const parts = key.split("/").filter((s) => s !== "");
816
+ if (parts.length === 0) {
817
+ return { useNative: false, folder: null, resourcePath: "/" };
818
+ }
819
+ if (key.endsWith(".email.json")) {
820
+ return { useNative: false, folder: parts[0] ?? null, resourcePath: key };
821
+ }
822
+ if (parts.length <= 2) {
823
+ return { useNative: true, folder: parts[0] ?? null, resourcePath: key };
824
+ }
825
+ return { useNative: false, folder: parts[0] ?? null, resourcePath: key };
826
+ }
827
+
828
+ // src/core/email/search.ts
829
+ function buildSearchCriteria(opts) {
830
+ const parts = [];
831
+ if (opts.unseen === true) parts.push("UNSEEN");
832
+ if (opts.text !== void 0 && opts.text !== null && opts.text !== "") {
833
+ parts.push(`TEXT "${opts.text}"`);
834
+ }
835
+ if (opts.subject !== void 0 && opts.subject !== null && opts.subject !== "") {
836
+ parts.push(`SUBJECT "${opts.subject}"`);
837
+ }
838
+ if (opts.fromAddr !== void 0 && opts.fromAddr !== null && opts.fromAddr !== "") {
839
+ parts.push(`FROM "${opts.fromAddr}"`);
840
+ }
841
+ if (opts.toAddr !== void 0 && opts.toAddr !== null && opts.toAddr !== "") {
842
+ parts.push(`TO "${opts.toAddr}"`);
843
+ }
844
+ if (opts.since !== void 0 && opts.since !== null && opts.since !== "") {
845
+ parts.push(`SINCE ${opts.since}`);
846
+ }
847
+ if (opts.before !== void 0 && opts.before !== null && opts.before !== "") {
848
+ parts.push(`BEFORE ${opts.before}`);
849
+ }
850
+ return parts.length > 0 ? parts.join(" ") : "ALL";
851
+ }
852
+ async function searchMessages(accessor, folder, opts = {}, maxResults = null) {
853
+ const criteria = buildSearchCriteria(opts);
854
+ return listMessageUids(accessor, folder, criteria, maxResults);
855
+ }
856
+ function buildVfsPath(prefix, folder, msg) {
857
+ const dateStr = dateBucket(msg);
858
+ const subject = sanitize(msg.subject !== "" ? msg.subject : "No Subject");
859
+ const filename = `${subject}__${msg.uid}.email.json`;
860
+ return [prefix, folder, dateStr, filename].filter((p) => p !== "").join("/");
861
+ }
862
+ async function searchAndFormat(accessor, scope, pattern, prefix, maxResults = null) {
863
+ const folder = scope.folder ?? "";
864
+ if (folder === "") return [];
865
+ const uids = await searchMessages(accessor, folder, { text: pattern }, maxResults);
866
+ const pairs = [];
867
+ for (const uid of uids) {
868
+ const msg = await fetchMessage(accessor, folder, uid);
869
+ const msgText = messageJsonText(msg);
870
+ const vfsPath = buildVfsPath(prefix, folder, msg);
871
+ pairs.push([vfsPath, msgText]);
872
+ }
873
+ return pairs;
874
+ }
875
+
876
+ // src/commands/builtin/email/grep.ts
877
+ var resolveGlob2 = resolveGlobOf2(EMAIL_IO);
878
+ var ENC = new TextEncoder();
879
+ async function* emailStream(accessor, p, index) {
880
+ yield await read(accessor, p, index);
881
+ }
882
+ function parseFlags(flags) {
883
+ const toInt = (v) => typeof v === "string" ? Number.parseInt(v, 10) : null;
884
+ const aCtx = toInt(flags.A);
885
+ const bCtx = toInt(flags.B);
886
+ const cCtx = toInt(flags.C);
887
+ return {
888
+ ignoreCase: flags.i === true,
889
+ invert: flags.v === true,
890
+ lineNumbers: flags.n === true,
891
+ countOnly: flags.c === true,
892
+ filesOnly: flags.args_l === true || flags.l === true,
893
+ wholeWord: flags.w === true,
894
+ fixedString: flags.F === true,
895
+ onlyMatching: flags.o === true,
896
+ maxCount: toInt(flags.m),
897
+ quiet: flags.q === true,
898
+ afterContext: aCtx ?? cCtx ?? 0,
899
+ beforeContext: bCtx ?? cCtx ?? 0
900
+ };
901
+ }
902
+ function getPattern(texts, flags) {
903
+ if (typeof flags.e === "string") return flags.e;
904
+ if (texts.length > 0 && texts[0] !== void 0) return texts[0];
905
+ throw new Error("grep: usage: grep [flags] pattern [path]");
906
+ }
907
+ async function grepCommand(accessor, paths, texts, opts) {
908
+ let pattern;
909
+ try {
910
+ pattern = getPattern(texts, opts.flags);
911
+ } catch (err) {
912
+ const msg = err instanceof Error ? err.message : String(err);
913
+ return [null, new IOResult({ exitCode: 2, stderr: ENC.encode(`${msg}
914
+ `) })];
915
+ }
916
+ const f = parseFlags(opts.flags);
917
+ if (paths.length > 0) {
918
+ const first = paths[0];
919
+ if (first !== void 0) {
920
+ const scope = detectScope(first);
921
+ if (scope.useNative && !pattern.includes("\n")) {
922
+ const filePrefix = mountPrefixOf4(first.virtual, first.resourcePath) !== "" ? mountPrefixOf4(first.virtual, first.resourcePath) : "";
923
+ const pairs = await searchAndFormat(accessor, scope, pattern, filePrefix, f.maxCount ?? 50);
924
+ const lines = [];
925
+ for (const [vfsPath, msgText] of pairs) {
926
+ const matched = grepLines(
927
+ vfsPath,
928
+ [msgText],
929
+ compilePattern(pattern, f.ignoreCase, f.fixedString, f.wholeWord),
930
+ f
931
+ );
932
+ for (const line of matched) lines.push(`${vfsPath}:${line}`);
933
+ }
934
+ if (lines.length === 0) return [new Uint8Array(0), new IOResult({ exitCode: 1 })];
935
+ const out = ENC.encode(lines.join("\n") + "\n");
936
+ return [out, new IOResult()];
937
+ }
938
+ }
939
+ }
940
+ const resolved = paths.length > 0 ? await resolveGlob2(accessor, paths, opts.index ?? void 0) : [];
941
+ const stat2 = (p) => stat(accessor, p, opts.index ?? void 0);
942
+ const readdir2 = (p) => readdir(accessor, p, opts.index ?? void 0);
943
+ return grepGeneric(
944
+ "grep",
945
+ resolved,
946
+ texts,
947
+ opts,
948
+ stat2,
949
+ readdir2,
950
+ (p) => emailStream(accessor, p, opts.index ?? void 0)
951
+ );
952
+ }
953
+ var EMAIL_GREP = command2({
954
+ name: "grep",
955
+ resource: ResourceName2.EMAIL,
956
+ spec: specOf2("grep"),
957
+ fn: grepCommand,
958
+ aggregate: prefixAggregate,
959
+ provision: fileReadProvision
960
+ });
961
+
962
+ // src/commands/builtin/email/rg.ts
963
+ import {
964
+ FlagView,
965
+ IOResult as IOResult2,
966
+ ResourceName as ResourceName3,
967
+ command as command3,
968
+ compilePattern as compilePattern2,
969
+ grepLines as grepLines2,
970
+ mountPrefixOf as mountPrefixOf5,
971
+ patternArg,
972
+ resolveGlobOf as resolveGlobOf3,
973
+ rgGeneric,
974
+ specOf as specOf3
975
+ } from "@struktoai/mirage-core";
976
+ var resolveGlob3 = resolveGlobOf3(EMAIL_IO);
977
+ var ENC2 = new TextEncoder();
978
+ async function* emailStream2(accessor, p, index) {
979
+ yield await read(accessor, p, index);
980
+ }
981
+ async function rgCommand(accessor, paths, texts, opts) {
982
+ const pattern = patternArg(texts, opts.flags);
983
+ if (pattern === null) {
984
+ return [
985
+ null,
986
+ new IOResult2({ exitCode: 2, stderr: ENC2.encode("rg: usage: rg [flags] pattern [path]\n") })
987
+ ];
988
+ }
989
+ const fl = new FlagView(opts.flags, specOf3("rg"));
990
+ const ignoreCase = fl.asBool("i");
991
+ const invert = fl.asBool("v");
992
+ const lineNumbers = fl.asBool("n");
993
+ const countOnly = fl.asBool("c");
994
+ const filesOnly = fl.asBool("args_l");
995
+ const wholeWord = fl.asBool("w");
996
+ const fixedString = fl.asBool("F");
997
+ const onlyMatching = fl.asBool("o");
998
+ const maxCount = fl.asInt("m") ?? null;
999
+ const pat = compilePattern2(pattern, ignoreCase, fixedString, wholeWord);
1000
+ const lineOpts = {
1001
+ invert,
1002
+ lineNumbers,
1003
+ countOnly,
1004
+ filesOnly,
1005
+ onlyMatching,
1006
+ maxCount
1007
+ };
1008
+ if (paths.length > 0) {
1009
+ const first = paths[0];
1010
+ if (first !== void 0) {
1011
+ const scope = detectScope(first);
1012
+ if (scope.useNative && !pattern.includes("\n")) {
1013
+ const filePrefix = mountPrefixOf5(first.virtual, first.resourcePath) !== "" ? mountPrefixOf5(first.virtual, first.resourcePath) : "";
1014
+ const pairs = await searchAndFormat(accessor, scope, pattern, filePrefix, maxCount ?? 50);
1015
+ const lines = [];
1016
+ for (const [vfsPath, msgText] of pairs) {
1017
+ const matched = grepLines2(vfsPath, [msgText], pat, lineOpts);
1018
+ for (const line of matched) lines.push(`${vfsPath}:${line}`);
1019
+ }
1020
+ if (lines.length === 0) return [new Uint8Array(0), new IOResult2({ exitCode: 1 })];
1021
+ const out = ENC2.encode(lines.join("\n") + "\n");
1022
+ return [out, new IOResult2()];
1023
+ }
1024
+ }
1025
+ }
1026
+ const resolved = paths.length > 0 ? await resolveGlob3(accessor, paths, opts.index ?? void 0) : [];
1027
+ const stat2 = (p) => stat(accessor, p, opts.index ?? void 0);
1028
+ const readdir2 = (p) => readdir(accessor, p, opts.index ?? void 0);
1029
+ return rgGeneric(
1030
+ resolved,
1031
+ texts,
1032
+ opts,
1033
+ stat2,
1034
+ readdir2,
1035
+ (p) => emailStream2(accessor, p, opts.index ?? void 0)
1036
+ );
1037
+ }
1038
+ var EMAIL_RG = command3({
1039
+ name: "rg",
1040
+ resource: ResourceName3.EMAIL,
1041
+ spec: specOf3("rg"),
1042
+ fn: rgCommand
1043
+ });
1044
+
1045
+ // src/commands/builtin/email/index.ts
1046
+ var EMAIL_OVERRIDES = /* @__PURE__ */ new Set(["find", "grep", "rg"]);
1047
+ var EMAIL_COMMANDS = [
1048
+ ...makeGenericCommands(ResourceName4.EMAIL, EMAIL_IO, {
1049
+ overrides: EMAIL_OVERRIDES
1050
+ }),
1051
+ ...EMAIL_FIND,
1052
+ ...EMAIL_GREP,
1053
+ ...EMAIL_RG
1054
+ ];
1055
+
1056
+ // src/ops/email/index.ts
1057
+ import { ResourceName as ResourceName5, makeGenericOps } from "@struktoai/mirage-core";
1058
+ var EMAIL_OPS = makeGenericOps(ResourceName5.EMAIL, EMAIL_IO);
1059
+
1060
+ // src/resource/email/prompt.ts
1061
+ var EMAIL_PROMPT = `{prefix}
1062
+ <folder>/
1063
+ <yyyy-mm-dd>/
1064
+ <subject>__<uid>.email.json
1065
+ <subject>__<uid>/ # if attachments exist
1066
+ <attachment-filename>
1067
+ Folders include: INBOX, Sent, Drafts, etc. cat shows email as JSON.
1068
+
1069
+ To act on mail (list/read/send/reply/forward), use the himalaya CLI
1070
+ if installed: himalaya --help`;
1071
+ var EMAIL_WRITE_PROMPT = ` Sending mail goes through the himalaya CLI if installed:
1072
+ himalaya message send --to "to@email.com" --subject "Hi" --body "..."`;
1073
+
1074
+ // src/resource/email/email.ts
1075
+ var resolveGlob4 = makeResolveGlob(readdir);
1076
+ var EmailResource = class extends BaseResource {
1077
+ kind = ResourceName6.EMAIL;
1078
+ cachesReads = true;
1079
+ // Every listed file carries an exact size: .email.json is rendered at
1080
+ // readdir from the full message source the listing already fetches, and an
1081
+ // attachment's size is its decoded payload length.
1082
+ sizesAlwaysKnown = true;
1083
+ indexTtl = 86400;
1084
+ prompt = EMAIL_PROMPT;
1085
+ config;
1086
+ accessor;
1087
+ constructor(config) {
1088
+ super();
1089
+ this.config = config;
1090
+ this.accessor = new EmailAccessor(config);
1091
+ }
1092
+ open() {
1093
+ return Promise.resolve();
1094
+ }
1095
+ async close() {
1096
+ await this.accessor.close();
1097
+ await super.close();
1098
+ }
1099
+ commands() {
1100
+ return EMAIL_COMMANDS;
1101
+ }
1102
+ ops() {
1103
+ return EMAIL_OPS;
1104
+ }
1105
+ readFile(p) {
1106
+ return read(this.accessor, p, this.index);
1107
+ }
1108
+ readdir(p) {
1109
+ return readdir(this.accessor, p, this.index);
1110
+ }
1111
+ stat(p) {
1112
+ return stat(this.accessor, p, this.index);
1113
+ }
1114
+ glob(paths, prefix = "") {
1115
+ const effective = prefix !== "" ? paths.map(
1116
+ (p) => mountPrefixOf6(p.virtual, p.resourcePath) !== "" ? p : new PathSpec2({
1117
+ virtual: p.virtual,
1118
+ directory: p.directory,
1119
+ ...p.pattern !== null ? { pattern: p.pattern } : {},
1120
+ resolved: p.resolved,
1121
+ resourcePath: mountKey3(p.virtual, prefix)
1122
+ })
1123
+ ) : paths;
1124
+ return resolveGlob4(this.accessor, effective, this.index);
1125
+ }
1126
+ getState() {
1127
+ return Promise.resolve({
1128
+ type: this.kind,
1129
+ config: redactEmailConfig(this.config)
1130
+ });
1131
+ }
1132
+ loadState(_state) {
1133
+ return Promise.resolve();
1134
+ }
1135
+ };
1136
+
1137
+ export {
1138
+ EmailAccessor,
1139
+ parseRfc822,
1140
+ listFolderEntries,
1141
+ listMessageUids,
1142
+ fetchRawMessage,
1143
+ fetchMessage,
1144
+ fetchHeaders,
1145
+ messageJsonBytes,
1146
+ messagesJsonBytes,
1147
+ EMAIL_COMMANDS,
1148
+ EMAIL_OPS,
1149
+ EMAIL_PROMPT,
1150
+ EMAIL_WRITE_PROMPT,
1151
+ EmailResource
1152
+ };
1153
+ //# sourceMappingURL=chunk-TWRQCQWU.js.map