@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
@@ -1,1795 +0,0 @@
1
- import {
2
- redactEmailConfig
3
- } from "./chunk-B2ZOKNN4.js";
4
-
5
- // src/resource/email/email.ts
6
- import {
7
- BaseResource,
8
- PathSpec as PathSpec4,
9
- ResourceName as ResourceName25
10
- } from "@struktoai/mirage-core";
11
-
12
- // src/accessor/email.ts
13
- import { Accessor, loadOptionalPeer } from "@struktoai/mirage-core";
14
- var EmailAccessor = class extends Accessor {
15
- config;
16
- clientPromise = null;
17
- constructor(config) {
18
- super();
19
- this.config = config;
20
- }
21
- async getImap() {
22
- this.clientPromise ??= (async () => {
23
- const mod = await loadOptionalPeer(
24
- () => import("imapflow"),
25
- { feature: "EmailAccessor", packageName: "imapflow" }
26
- );
27
- const client = new mod.ImapFlow({
28
- host: this.config.imapHost,
29
- port: this.config.imapPort,
30
- secure: this.config.useSsl,
31
- auth: { user: this.config.username, pass: this.config.password },
32
- logger: false
33
- });
34
- await client.connect();
35
- return client;
36
- })();
37
- try {
38
- return await this.clientPromise;
39
- } catch (err) {
40
- this.clientPromise = null;
41
- throw err;
42
- }
43
- }
44
- async close() {
45
- if (this.clientPromise === null) return;
46
- try {
47
- const c = await this.clientPromise;
48
- await c.logout();
49
- } catch {
50
- }
51
- this.clientPromise = null;
52
- }
53
- };
54
-
55
- // src/commands/builtin/email/basename.ts
56
- import { ResourceName, command, specOf, basenameFn } from "@struktoai/mirage-core";
57
- var EMAIL_BASENAME = command({
58
- name: "basename",
59
- resource: ResourceName.EMAIL,
60
- spec: specOf("basename"),
61
- fn: basenameFn
62
- });
63
-
64
- // src/commands/builtin/email/cat.ts
65
- import {
66
- ResourceName as ResourceName2,
67
- catGeneric,
68
- command as command2,
69
- specOf as specOf2
70
- } from "@struktoai/mirage-core";
71
-
72
- // src/core/email/glob.ts
73
- import { PathSpec as PathSpecCtor2, rstripSlash } from "@struktoai/mirage-core";
74
-
75
- // src/core/email/readdir.ts
76
- import { IndexEntry, PathSpec as PathSpecCtor, stripSlash } from "@struktoai/mirage-core";
77
-
78
- // src/core/email/_parse.ts
79
- import { loadOptionalPeer as loadOptionalPeer2 } from "@struktoai/mirage-core";
80
- var parserPromise = null;
81
- async function getParser() {
82
- parserPromise ??= (async () => {
83
- const mod = await loadOptionalPeer2(
84
- () => import("mailparser"),
85
- { feature: "parseRfc822", packageName: "mailparser" }
86
- );
87
- return mod.simpleParser;
88
- })();
89
- return parserPromise;
90
- }
91
- function toAddr(a) {
92
- if (a === void 0) return { name: "", email: "" };
93
- return { name: a.name, email: a.address ?? "" };
94
- }
95
- function toAddrList(list) {
96
- if (list === void 0) return [];
97
- const objs = Array.isArray(list) ? list : [list];
98
- return objs.flatMap((obj) => obj.value.map((a) => toAddr(a)));
99
- }
100
- function fromParsed(parsed, headersOnly) {
101
- const text = headersOnly ? "" : parsed.text ?? "";
102
- const html = headersOnly ? "" : typeof parsed.html === "string" ? parsed.html : "";
103
- const attachments = headersOnly ? [] : parsed.attachments.map((a) => ({
104
- filename: a.filename ?? "unnamed",
105
- content_type: a.contentType,
106
- size: a.size
107
- }));
108
- const refsRaw = parsed.references;
109
- const references = typeof refsRaw === "string" ? refsRaw.split(/\s+/).filter((s) => s !== "") : refsRaw ?? [];
110
- return {
111
- from: toAddr(parsed.from?.value[0]),
112
- to: toAddrList(parsed.to),
113
- cc: toAddrList(parsed.cc),
114
- subject: parsed.subject ?? "",
115
- date: parsed.date instanceof Date ? parsed.date.toUTCString() : "",
116
- body_text: text,
117
- body_html: html,
118
- snippet: text.slice(0, 100),
119
- message_id: parsed.messageId ?? "",
120
- in_reply_to: typeof parsed.inReplyTo === "string" && parsed.inReplyTo !== "" ? parsed.inReplyTo : null,
121
- references,
122
- has_attachments: attachments.length > 0,
123
- attachments
124
- };
125
- }
126
- async function parseRfc822(raw, headersOnly = false) {
127
- const parser = await getParser();
128
- const parsed = await parser(Buffer.from(raw), { skipHtmlToText: false });
129
- return fromParsed(parsed, headersOnly);
130
- }
131
- async function parseWithPayloads(raw) {
132
- const parser = await getParser();
133
- const parsed = await parser(Buffer.from(raw));
134
- return parsed.attachments.map((a) => ({
135
- filename: a.filename ?? "unnamed",
136
- content_type: a.contentType,
137
- size: a.size,
138
- payload: new Uint8Array(a.content)
139
- }));
140
- }
141
-
142
- // src/core/email/_client.ts
143
- async function listFolders(accessor) {
144
- const imap = await accessor.getImap();
145
- const tree = await imap.list();
146
- return tree.map((m) => m.pathAsListed);
147
- }
148
- async function listMessageUids(accessor, folder, searchCriteria = "ALL", maxResults = null) {
149
- const imap = await accessor.getImap();
150
- const lock = await imap.getMailboxLock(folder);
151
- try {
152
- const query = parseSearchCriteria(searchCriteria);
153
- const uidsRaw = await imap.search(query, { uid: true });
154
- if (uidsRaw === false) return [];
155
- const uids = uidsRaw.map((n) => String(n));
156
- if (maxResults !== null && uids.length > maxResults) {
157
- return uids.slice(uids.length - maxResults);
158
- }
159
- return uids;
160
- } finally {
161
- lock.release();
162
- }
163
- }
164
- function parseSearchCriteria(criteria) {
165
- if (criteria === "ALL" || criteria === "") return { all: true };
166
- const out = {};
167
- const tokens = tokenizeCriteria(criteria);
168
- let i = 0;
169
- while (i < tokens.length) {
170
- const tok = (tokens[i] ?? "").toUpperCase();
171
- if (tok === "UNSEEN") {
172
- out.unseen = true;
173
- i += 1;
174
- continue;
175
- }
176
- if (tok === "TEXT" || tok === "SUBJECT" || tok === "FROM" || tok === "TO" || tok === "SINCE" || tok === "BEFORE") {
177
- const v = tokens[i + 1] ?? "";
178
- if (tok === "TEXT") out.text = v;
179
- else if (tok === "SUBJECT") out.subject = v;
180
- else if (tok === "FROM") out.from = v;
181
- else if (tok === "TO") out.to = v;
182
- else if (tok === "SINCE") {
183
- const d = parseImapDate(v);
184
- if (d !== null) out.since = d;
185
- } else {
186
- const d = parseImapDate(v);
187
- if (d !== null) out.before = d;
188
- }
189
- i += 2;
190
- continue;
191
- }
192
- i += 1;
193
- }
194
- return out;
195
- }
196
- function tokenizeCriteria(criteria) {
197
- const tokens = [];
198
- let i = 0;
199
- while (i < criteria.length) {
200
- if (criteria[i] === " ") {
201
- i += 1;
202
- continue;
203
- }
204
- if (criteria[i] === '"') {
205
- const end2 = criteria.indexOf('"', i + 1);
206
- if (end2 === -1) {
207
- tokens.push(criteria.slice(i + 1));
208
- break;
209
- }
210
- tokens.push(criteria.slice(i + 1, end2));
211
- i = end2 + 1;
212
- continue;
213
- }
214
- let end = criteria.indexOf(" ", i);
215
- if (end === -1) end = criteria.length;
216
- tokens.push(criteria.slice(i, end));
217
- i = end;
218
- }
219
- return tokens;
220
- }
221
- function parseImapDate(s) {
222
- const m = /^(\d{1,2})-([A-Za-z]{3})-(\d{4})$/.exec(s);
223
- if (m === null) return null;
224
- const months = {
225
- Jan: 0,
226
- Feb: 1,
227
- Mar: 2,
228
- Apr: 3,
229
- May: 4,
230
- Jun: 5,
231
- Jul: 6,
232
- Aug: 7,
233
- Sep: 8,
234
- Oct: 9,
235
- Nov: 10,
236
- Dec: 11
237
- };
238
- const day = Number.parseInt(m[1] ?? "0", 10);
239
- const monKey = (m[2] ?? "").slice(0, 1).toUpperCase() + (m[2] ?? "").slice(1).toLowerCase();
240
- const mon = months[monKey] ?? 0;
241
- const year = Number.parseInt(m[3] ?? "1970", 10);
242
- return new Date(Date.UTC(year, mon, day));
243
- }
244
- async function fetchMessage(accessor, folder, uid) {
245
- const imap = await accessor.getImap();
246
- const lock = await imap.getMailboxLock(folder);
247
- try {
248
- const msg = await imap.fetchOne(uid, { source: true, flags: true, uid: true }, { uid: true });
249
- if (msg === false) {
250
- throw new Error(`email: uid ${uid} not found in ${folder}`);
251
- }
252
- const source = msg.source instanceof Buffer ? new Uint8Array(msg.source) : new Uint8Array(0);
253
- const parsed = await parseRfc822(source);
254
- return {
255
- ...parsed,
256
- uid,
257
- flags: msg.flags !== void 0 ? [...msg.flags] : []
258
- };
259
- } finally {
260
- lock.release();
261
- }
262
- }
263
- async function fetchHeaders(accessor, folder, uids) {
264
- if (uids.length === 0) return [];
265
- const imap = await accessor.getImap();
266
- const lock = await imap.getMailboxLock(folder);
267
- try {
268
- const results = [];
269
- for (const uid of uids) {
270
- const msg = await imap.fetchOne(uid, { headers: true, flags: true, uid: true }, { uid: true });
271
- if (msg === false) continue;
272
- const headers = msg.headers instanceof Buffer ? new Uint8Array(msg.headers) : new Uint8Array(0);
273
- const parsed = await parseRfc822(headers, true);
274
- results.push({
275
- ...parsed,
276
- uid,
277
- flags: msg.flags !== void 0 ? [...msg.flags] : []
278
- });
279
- }
280
- return results;
281
- } finally {
282
- lock.release();
283
- }
284
- }
285
- async function fetchAttachment(accessor, folder, uid, filename) {
286
- const imap = await accessor.getImap();
287
- const lock = await imap.getMailboxLock(folder);
288
- try {
289
- const msg = await imap.fetchOne(uid, { source: true }, { uid: true });
290
- if (msg === false) return null;
291
- const source = msg.source instanceof Buffer ? new Uint8Array(msg.source) : new Uint8Array(0);
292
- const attachments = await parseWithPayloads(source);
293
- for (const att of attachments) {
294
- if (att.filename === filename) return att.payload;
295
- }
296
- return null;
297
- } finally {
298
- lock.release();
299
- }
300
- }
301
-
302
- // src/core/email/folders.ts
303
- async function listFolders2(accessor) {
304
- return listFolders(accessor);
305
- }
306
-
307
- // src/core/email/readdir.ts
308
- var TITLE_MAX = 80;
309
- var UNSAFE = /[^\w\s\-.]/g;
310
- var MULTI_UNDERSCORE = /_+/g;
311
- function sanitize(text) {
312
- if (text.trim() === "") return "No_Subject";
313
- let cleaned = text.replace(UNSAFE, "_").replace(/ /g, "_");
314
- cleaned = cleaned.replace(MULTI_UNDERSCORE, "_").replace(/^_+|_+$/g, "");
315
- if (cleaned.length > TITLE_MAX) cleaned = `${cleaned.slice(0, TITLE_MAX - 3)}...`;
316
- return cleaned;
317
- }
318
- function msgFilename(subject, uid) {
319
- return `${sanitize(subject)}__${uid}.email.json`;
320
- }
321
- function dateFromHeader(dateStr) {
322
- if (dateStr === "") return "1970-01-01";
323
- const d = new Date(dateStr);
324
- if (Number.isNaN(d.getTime())) return "1970-01-01";
325
- const yyyy = d.getUTCFullYear().toString().padStart(4, "0");
326
- const mm = (d.getUTCMonth() + 1).toString().padStart(2, "0");
327
- const dd = d.getUTCDate().toString().padStart(2, "0");
328
- return `${yyyy}-${mm}-${dd}`;
329
- }
330
- function enoent(p) {
331
- const e = new Error(`ENOENT: ${p}`);
332
- e.code = "ENOENT";
333
- return e;
334
- }
335
- async function readdir(accessor, path, index) {
336
- const prefix = path.prefix;
337
- const raw = path.pattern !== null ? path.directory : path.original;
338
- let p = raw;
339
- if (prefix !== "" && p.startsWith(prefix)) p = p.slice(prefix.length) || "/";
340
- const key = stripSlash(p);
341
- const virtualKey = key !== "" ? `${prefix}/${key}` : prefix !== "" ? prefix : "/";
342
- const parts = key === "" ? [] : key.split("/");
343
- const depth = parts.length;
344
- if (depth === 0) {
345
- if (index !== void 0) {
346
- const cached = await index.listDir(virtualKey);
347
- if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
348
- }
349
- const folders = await listFolders2(accessor);
350
- const entries = [];
351
- for (const folderName of folders) {
352
- const entry = new IndexEntry({
353
- id: folderName,
354
- name: folderName,
355
- resourceType: "email/folder",
356
- vfsName: folderName
357
- });
358
- entries.push([folderName, entry]);
359
- }
360
- if (index !== void 0) await index.setDir(virtualKey, entries);
361
- return entries.map(([name]) => `${prefix}/${name}`);
362
- }
363
- if (depth === 1) {
364
- const folderName = parts[0] ?? "";
365
- if (index !== void 0) {
366
- const cached = await index.listDir(virtualKey);
367
- if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
368
- }
369
- if (index === void 0) throw enoent(path.original);
370
- const maxMessages = accessor.config.maxMessages;
371
- const uids = await listMessageUids(accessor, folderName, "ALL", maxMessages);
372
- const headersList = await fetchHeaders(accessor, folderName, uids);
373
- const dateGroups = /* @__PURE__ */ new Map();
374
- for (const hdr of headersList) {
375
- const dateStr = dateFromHeader(hdr.date);
376
- let bucket = dateGroups.get(dateStr);
377
- if (bucket === void 0) {
378
- bucket = [];
379
- dateGroups.set(dateStr, bucket);
380
- }
381
- bucket.push(hdr);
382
- }
383
- const sortedDates = [...dateGroups.keys()].sort().reverse();
384
- const dateEntries = [];
385
- for (const dateStr of sortedDates) {
386
- const dateEntry = new IndexEntry({
387
- id: dateStr,
388
- name: dateStr,
389
- resourceType: "email/date",
390
- vfsName: dateStr
391
- });
392
- dateEntries.push([dateStr, dateEntry]);
393
- const msgEntries = [];
394
- for (const hdr of dateGroups.get(dateStr) ?? []) {
395
- const uid = hdr.uid;
396
- const subject = hdr.subject || "No Subject";
397
- const filename = msgFilename(subject, uid);
398
- const msgEntry = new IndexEntry({
399
- id: uid,
400
- name: subject,
401
- resourceType: "email/message",
402
- vfsName: filename
403
- });
404
- msgEntries.push([filename, msgEntry]);
405
- const attachments = hdr.attachments;
406
- if (attachments.length > 0) {
407
- const attDirName = filename.replace(".email.json", "");
408
- const attDirEntry = new IndexEntry({
409
- id: uid,
410
- name: attDirName,
411
- resourceType: "email/attachment_dir",
412
- vfsName: attDirName
413
- });
414
- msgEntries.push([attDirName, attDirEntry]);
415
- const attEntries = [];
416
- for (const att of attachments) {
417
- const attEntry = new IndexEntry({
418
- id: att.filename,
419
- name: att.filename,
420
- resourceType: "email/attachment",
421
- vfsName: att.filename,
422
- size: att.size
423
- });
424
- attEntries.push([att.filename, attEntry]);
425
- }
426
- const attDirVKey = `${virtualKey}/${dateStr}/${attDirName}`;
427
- await index.setDir(attDirVKey, attEntries);
428
- }
429
- }
430
- const dateVKey = `${virtualKey}/${dateStr}`;
431
- await index.setDir(dateVKey, msgEntries);
432
- }
433
- await index.setDir(virtualKey, dateEntries);
434
- return dateEntries.map(([name]) => `${prefix}/${key}/${name}`);
435
- }
436
- if (depth === 2 || depth === 3) {
437
- if (index === void 0) throw enoent(path.original);
438
- let cached = await index.listDir(virtualKey);
439
- if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
440
- const folderPath = prefix !== "" ? `${prefix}/${parts[0] ?? ""}` : `/${parts[0] ?? ""}`;
441
- const folderSpec = new PathSpecCtor({ original: folderPath, directory: folderPath, prefix });
442
- await readdir(accessor, folderSpec, index);
443
- cached = await index.listDir(virtualKey);
444
- if (cached.entries !== void 0 && cached.entries !== null) return cached.entries;
445
- throw enoent(path.original);
446
- }
447
- throw enoent(path.original);
448
- }
449
-
450
- // src/core/email/glob.ts
451
- import { fnmatch } from "@struktoai/mirage-core";
452
- var SCOPE_ERROR = 1e3;
453
- async function resolveGlob(accessor, paths, index) {
454
- const result = [];
455
- for (const p of paths) {
456
- if (p.resolved) {
457
- result.push(p);
458
- continue;
459
- }
460
- if (p.pattern !== null && p.pattern !== "") {
461
- const entries = await readdir(accessor, p, index);
462
- const matched = [];
463
- for (const entry of entries) {
464
- const trimmed = rstripSlash(entry);
465
- const base = trimmed.split("/").pop() ?? trimmed;
466
- if (!fnmatch(base, p.pattern)) continue;
467
- matched.push(PathSpecCtor2.fromStrPath(trimmed, p.prefix));
468
- }
469
- const truncated = matched.length > SCOPE_ERROR ? matched.slice(0, SCOPE_ERROR) : matched;
470
- result.push(...truncated);
471
- } else {
472
- result.push(p);
473
- }
474
- }
475
- return result;
476
- }
477
-
478
- // src/core/email/read.ts
479
- import { gnuDirname, stripSlash as stripSlash2 } from "@struktoai/mirage-core";
480
- var ENC = new TextEncoder();
481
- function enoent2(p) {
482
- const e = new Error(`ENOENT: ${p}`);
483
- e.code = "ENOENT";
484
- return e;
485
- }
486
- function eisdir(p) {
487
- const e = new Error(`EISDIR: ${p}`);
488
- e.code = "EISDIR";
489
- return e;
490
- }
491
- async function read(accessor, path, index) {
492
- const prefix = path.prefix;
493
- let p = path.original;
494
- if (prefix !== "" && p.startsWith(prefix)) p = p.slice(prefix.length) || "/";
495
- const key = stripSlash2(p);
496
- if (index === void 0) throw enoent2(path.original);
497
- const virtualKey = prefix !== "" ? `${prefix}/${key}` : `/${key}`;
498
- const result = await index.get(virtualKey);
499
- if (result.entry === void 0 || result.entry === null) throw enoent2(path.original);
500
- const rt = result.entry.resourceType;
501
- if (rt === "email/folder" || rt === "email/date" || rt === "email/attachment_dir") {
502
- throw eisdir(path.original);
503
- }
504
- if (rt === "email/attachment") {
505
- const parentKey = gnuDirname(virtualKey);
506
- const parentResult = await index.get(parentKey);
507
- if (parentResult.entry === void 0 || parentResult.entry === null) {
508
- throw enoent2(path.original);
509
- }
510
- const uid2 = parentResult.entry.id;
511
- const parts2 = stripSlash2(virtualKey).split("/");
512
- const folder2 = prefix !== "" ? parts2[1] ?? "" : parts2[0] ?? "";
513
- const filename = result.entry.vfsName !== "" ? result.entry.vfsName : result.entry.name;
514
- const data = await fetchAttachment(accessor, folder2, uid2, filename);
515
- if (data === null) throw enoent2(path.original);
516
- return data;
517
- }
518
- const parts = stripSlash2(virtualKey).split("/");
519
- const folder = prefix !== "" ? parts[1] ?? "" : parts[0] ?? "";
520
- const uid = result.entry.id;
521
- const msg = await fetchMessage(accessor, folder, uid);
522
- return ENC.encode(JSON.stringify(msg));
523
- }
524
-
525
- // src/core/email/stat.ts
526
- import { FileStat, FileType, stripSlash as stripSlash3 } from "@struktoai/mirage-core";
527
- function guessType(name) {
528
- const lower = name.toLowerCase();
529
- if (lower.endsWith(".json") || lower.endsWith(".email.json")) return FileType.JSON;
530
- if (lower.endsWith(".csv")) return FileType.CSV;
531
- if (lower.endsWith(".png")) return FileType.IMAGE_PNG;
532
- if (lower.endsWith(".jpg") || lower.endsWith(".jpeg")) return FileType.IMAGE_JPEG;
533
- if (lower.endsWith(".gif")) return FileType.IMAGE_GIF;
534
- if (lower.endsWith(".zip")) return FileType.ZIP;
535
- if (lower.endsWith(".gz") || lower.endsWith(".gzip")) return FileType.GZIP;
536
- if (lower.endsWith(".pdf")) return FileType.PDF;
537
- if (lower.endsWith(".txt") || lower.endsWith(".md") || lower.endsWith(".log")) {
538
- return FileType.TEXT;
539
- }
540
- return FileType.BINARY;
541
- }
542
- function enoent3(p) {
543
- const e = new Error(`ENOENT: ${p}`);
544
- e.code = "ENOENT";
545
- return e;
546
- }
547
- async function stat(accessor, path, index) {
548
- const prefix = path.prefix;
549
- let p = path.original;
550
- if (prefix !== "" && p.startsWith(prefix)) p = p.slice(prefix.length) || "/";
551
- const key = stripSlash3(p);
552
- if (key === "") return new FileStat({ name: "/", type: FileType.DIRECTORY });
553
- if (index === void 0) throw enoent3(path.original);
554
- const virtualKey = prefix !== "" ? `${prefix}/${key}` : `/${key}`;
555
- const result = await index.get(virtualKey);
556
- if (result.entry === void 0 || result.entry === null) {
557
- if (!key.includes("/")) {
558
- const folders = await listFolders2(accessor);
559
- if (folders.includes(key)) return new FileStat({ name: key, type: FileType.DIRECTORY });
560
- throw enoent3(path.original);
561
- }
562
- throw enoent3(path.original);
563
- }
564
- const rt = result.entry.resourceType;
565
- const vfsName = result.entry.vfsName !== "" ? result.entry.vfsName : result.entry.name;
566
- if (rt === "email/folder") return new FileStat({ name: vfsName, type: FileType.DIRECTORY });
567
- if (rt === "email/date") return new FileStat({ name: vfsName, type: FileType.DIRECTORY });
568
- if (rt === "email/message") {
569
- return new FileStat({
570
- name: vfsName,
571
- type: FileType.JSON,
572
- size: result.entry.size,
573
- extra: { uid: result.entry.id }
574
- });
575
- }
576
- if (rt === "email/attachment_dir") {
577
- return new FileStat({
578
- name: vfsName,
579
- type: FileType.DIRECTORY,
580
- extra: { uid: result.entry.id }
581
- });
582
- }
583
- if (rt === "email/attachment") {
584
- return new FileStat({
585
- name: vfsName,
586
- type: guessType(vfsName),
587
- size: result.entry.size,
588
- extra: { attachment_id: result.entry.id }
589
- });
590
- }
591
- return new FileStat({ name: vfsName, type: FileType.JSON, extra: { uid: result.entry.id } });
592
- }
593
-
594
- // src/commands/builtin/email/provision.ts
595
- import {
596
- Precision,
597
- ProvisionResult
598
- } from "@struktoai/mirage-core";
599
- async function fileReadProvision(_accessor, paths, _texts, opts) {
600
- if (paths.length === 0) return new ProvisionResult({ precision: Precision.UNKNOWN });
601
- const index = opts.index ?? void 0;
602
- let ops = 0;
603
- if (index !== void 0) {
604
- for (const p of paths) {
605
- const lookup = await index.get(p.original);
606
- if (lookup.entry !== void 0 && lookup.entry !== null) ops += 1;
607
- }
608
- }
609
- return new ProvisionResult({
610
- networkReadLow: 0,
611
- networkReadHigh: 0,
612
- readOps: ops,
613
- precision: Precision.EXACT
614
- });
615
- }
616
- function metadataProvision(_accessor, _paths, _texts, _opts) {
617
- return new ProvisionResult({
618
- networkReadLow: 0,
619
- networkReadHigh: 0,
620
- readOps: 0,
621
- precision: Precision.EXACT
622
- });
623
- }
624
-
625
- // src/commands/builtin/email/cat.ts
626
- async function* emailStream(accessor, p, index) {
627
- yield await read(accessor, p, index);
628
- }
629
- async function catCommand(accessor, paths, texts, opts) {
630
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
631
- return catGeneric(
632
- resolved,
633
- texts,
634
- opts,
635
- (p) => stat(accessor, p, opts.index ?? void 0),
636
- (p) => emailStream(accessor, p, opts.index ?? void 0)
637
- );
638
- }
639
- var EMAIL_CAT = command2({
640
- name: "cat",
641
- resource: ResourceName2.EMAIL,
642
- spec: specOf2("cat"),
643
- fn: catCommand,
644
- provision: fileReadProvision
645
- });
646
-
647
- // src/commands/builtin/email/dirname.ts
648
- import { ResourceName as ResourceName3, command as command3, specOf as specOf3, dirnameFn } from "@struktoai/mirage-core";
649
- var EMAIL_DIRNAME = command3({
650
- name: "dirname",
651
- resource: ResourceName3.EMAIL,
652
- spec: specOf3("dirname"),
653
- fn: dirnameFn
654
- });
655
-
656
- // src/commands/builtin/email/find.ts
657
- import {
658
- IOResult,
659
- PathSpec,
660
- ResourceName as ResourceName4,
661
- command as command4,
662
- specOf as specOf4,
663
- rstripSlash as rstripSlash2,
664
- stripSlash as stripSlash4,
665
- formatRecords
666
- } from "@struktoai/mirage-core";
667
- import { fnmatch as fnmatch2 } from "@struktoai/mirage-core";
668
- import { findSizeMtimeError, invalidFindArg } from "@struktoai/mirage-core";
669
- async function walk(accessor, path, index, maxDepth, depth) {
670
- if (maxDepth !== null && depth > maxDepth) return [];
671
- let children;
672
- try {
673
- children = await readdir(accessor, path, index ?? void 0);
674
- } catch {
675
- return [];
676
- }
677
- const results = [];
678
- for (const child of children) {
679
- const isFolder = child.endsWith("/");
680
- const trimmed = isFolder ? rstripSlash2(child) : child;
681
- results.push(trimmed);
682
- if (isFolder) {
683
- const childSpec = new PathSpec({
684
- original: trimmed,
685
- directory: trimmed,
686
- resolved: false,
687
- prefix: path.prefix
688
- });
689
- const sub = await walk(accessor, childSpec, index, maxDepth, depth + 1);
690
- results.push(...sub);
691
- }
692
- }
693
- return results;
694
- }
695
- async function findCommand(accessor, paths, _texts, opts) {
696
- const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
697
- const p0 = resolved[0] ?? new PathSpec({
698
- original: "/",
699
- directory: "/",
700
- resolved: false,
701
- prefix: opts.mountPrefix ?? ""
702
- });
703
- const nameFlag = typeof opts.flags.name === "string" ? opts.flags.name : null;
704
- const inameFlag = typeof opts.flags.iname === "string" ? opts.flags.iname : null;
705
- const maxDepthRaw = typeof opts.flags.maxdepth === "string" ? opts.flags.maxdepth : null;
706
- const minDepthRaw = typeof opts.flags.mindepth === "string" ? opts.flags.mindepth : null;
707
- const maxDepth = maxDepthRaw !== null ? Number.parseInt(maxDepthRaw, 10) : null;
708
- const minDepth = minDepthRaw !== null ? Number.parseInt(minDepthRaw, 10) : null;
709
- if (maxDepthRaw !== null && Number.isNaN(maxDepth))
710
- return invalidFindArg(maxDepthRaw, "-maxdepth");
711
- if (minDepthRaw !== null && Number.isNaN(minDepth))
712
- return invalidFindArg(minDepthRaw, "-mindepth");
713
- const sizeFlag = typeof opts.flags.size === "string" ? opts.flags.size : null;
714
- const mtimeFlag = typeof opts.flags.mtime === "string" ? opts.flags.mtime : null;
715
- const sizeMtimeErr = findSizeMtimeError(sizeFlag, mtimeFlag);
716
- if (sizeMtimeErr !== null) return sizeMtimeErr;
717
- const allPaths = await walk(accessor, p0, opts.index, maxDepth, 0);
718
- const searchKey = stripSlash4(p0.stripPrefix);
719
- const baseDepth = searchKey === "" ? -1 : searchKey.split("/").length - 1;
720
- const results = [];
721
- for (const p of [...allPaths].sort()) {
722
- const stripped = p.startsWith(p0.prefix) ? p.slice(p0.prefix.length) : p;
723
- const trimmed = stripSlash4(stripped);
724
- const depth = trimmed === "" ? -1 : trimmed.split("/").length - (baseDepth + 2);
725
- if (minDepth !== null && depth < minDepth) continue;
726
- const entryName = p.split("/").pop() ?? p;
727
- if (nameFlag !== null && !fnmatch2(entryName, nameFlag)) continue;
728
- if (inameFlag !== null && !fnmatch2(entryName.toLowerCase(), inameFlag.toLowerCase())) continue;
729
- results.push(p);
730
- }
731
- const out = formatRecords(results);
732
- return [out, new IOResult()];
733
- }
734
- var EMAIL_FIND = command4({
735
- name: "find",
736
- resource: ResourceName4.EMAIL,
737
- spec: specOf4("find"),
738
- fn: findCommand,
739
- provision: metadataProvision
740
- });
741
-
742
- // src/commands/builtin/email/email_forward.ts
743
- import {
744
- CommandSpec,
745
- IOResult as IOResult2,
746
- OperandKind,
747
- Option,
748
- ResourceName as ResourceName5,
749
- command as command5
750
- } from "@struktoai/mirage-core";
751
-
752
- // src/core/email/send.ts
753
- import { loadOptionalPeer as loadOptionalPeer3 } from "@struktoai/mirage-core";
754
- var transporterCache = /* @__PURE__ */ new WeakMap();
755
- async function getTransporter(config) {
756
- const existing = transporterCache.get(config);
757
- if (existing !== void 0) return existing;
758
- const mod = await loadOptionalPeer3(
759
- () => import("nodemailer"),
760
- { feature: "email send/reply/forward", packageName: "nodemailer" }
761
- );
762
- const transporter = mod.createTransport({
763
- host: config.smtpHost,
764
- port: config.smtpPort,
765
- secure: config.smtpPort === 465,
766
- auth: { user: config.username, pass: config.password }
767
- });
768
- transporterCache.set(config, transporter);
769
- return transporter;
770
- }
771
- async function sendMessage(config, to, subject, body) {
772
- const t = await getTransporter(config);
773
- await t.sendMail({ from: config.username, to, subject, text: body });
774
- return { status: "sent", to, subject };
775
- }
776
- async function replyMessage(config, original, body) {
777
- const t = await getTransporter(config);
778
- const refs = [...original.references];
779
- if (original.message_id !== "") refs.push(original.message_id);
780
- const subject = `Re: ${original.subject}`;
781
- await t.sendMail({
782
- from: config.username,
783
- to: original.from.email,
784
- subject,
785
- text: body,
786
- inReplyTo: original.message_id,
787
- references: refs
788
- });
789
- return { status: "sent", to: original.from.email, subject };
790
- }
791
- async function replyAllMessage(config, original, body) {
792
- const t = await getTransporter(config);
793
- const all = /* @__PURE__ */ new Set();
794
- if (original.from.email !== "") all.add(original.from.email);
795
- for (const r of original.to) if (r.email !== "") all.add(r.email);
796
- for (const r of original.cc) if (r.email !== "") all.add(r.email);
797
- all.delete(config.username);
798
- const recipients = [...all].sort();
799
- const refs = [...original.references];
800
- if (original.message_id !== "") refs.push(original.message_id);
801
- const subject = `Re: ${original.subject}`;
802
- await t.sendMail({
803
- from: config.username,
804
- to: recipients,
805
- subject,
806
- text: body,
807
- inReplyTo: original.message_id,
808
- references: refs
809
- });
810
- return { status: "sent", to: recipients, subject };
811
- }
812
- async function forwardMessage(config, original, to) {
813
- const t = await getTransporter(config);
814
- const subject = `Fwd: ${original.subject}`;
815
- const fwdBody = `---------- Forwarded message ----------
816
- From: ${original.from.name} <${original.from.email}>
817
- Date: ${original.date}
818
- Subject: ${original.subject}
819
-
820
- ` + original.body_text;
821
- await t.sendMail({ from: config.username, to, subject, text: fwdBody });
822
- return { status: "sent", to, subject };
823
- }
824
-
825
- // src/commands/builtin/email/email_forward.ts
826
- var ENC2 = new TextEncoder();
827
- var SPEC = new CommandSpec({
828
- options: [
829
- new Option({ long: "--uid", valueKind: OperandKind.TEXT }),
830
- new Option({ long: "--folder", valueKind: OperandKind.TEXT }),
831
- new Option({ long: "--to", valueKind: OperandKind.TEXT })
832
- ]
833
- });
834
- async function emailForwardCommand(accessor, _paths, _texts, opts) {
835
- const uid = typeof opts.flags.uid === "string" ? opts.flags.uid : "";
836
- const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
837
- const to = typeof opts.flags.to === "string" ? opts.flags.to : "";
838
- if (uid === "") {
839
- return [null, new IOResult2({ exitCode: 2, stderr: ENC2.encode("--uid is required\n") })];
840
- }
841
- if (folder === "") {
842
- return [null, new IOResult2({ exitCode: 2, stderr: ENC2.encode("--folder is required\n") })];
843
- }
844
- if (to === "") {
845
- return [null, new IOResult2({ exitCode: 2, stderr: ENC2.encode("--to is required\n") })];
846
- }
847
- const original = await fetchMessage(accessor, folder, uid);
848
- const result = await forwardMessage(accessor.config, original, to);
849
- const out = ENC2.encode(JSON.stringify(result));
850
- return [out, new IOResult2()];
851
- }
852
- var EMAIL_FORWARD = command5({
853
- name: "email-forward",
854
- resource: ResourceName5.EMAIL,
855
- spec: SPEC,
856
- fn: emailForwardCommand,
857
- write: true
858
- });
859
-
860
- // src/commands/builtin/email/grep.ts
861
- import {
862
- IOResult as IOResult3,
863
- PathSpec as PathSpec2,
864
- ResourceName as ResourceName6,
865
- command as command6,
866
- compilePattern,
867
- exitOnEmpty,
868
- grepFilesOnly,
869
- grepLines,
870
- grepStream,
871
- prefixAggregate,
872
- quietMatch,
873
- resolveSource,
874
- specOf as specOf5,
875
- yieldBytes,
876
- formatRecords as formatRecords2
877
- } from "@struktoai/mirage-core";
878
-
879
- // src/core/email/scope.ts
880
- import { stripSlash as stripSlash5 } from "@struktoai/mirage-core";
881
- function detectScope(path) {
882
- const key = stripSlash5(path.stripPrefix);
883
- if (key === "") {
884
- return { useNative: false, folder: null, resourcePath: "/" };
885
- }
886
- const parts = key.split("/").filter((s) => s !== "");
887
- if (parts.length === 0) {
888
- return { useNative: false, folder: null, resourcePath: "/" };
889
- }
890
- if (key.endsWith(".email.json")) {
891
- return { useNative: false, folder: parts[0] ?? null, resourcePath: key };
892
- }
893
- if (parts.length <= 2) {
894
- return { useNative: true, folder: parts[0] ?? null, resourcePath: key };
895
- }
896
- return { useNative: false, folder: parts[0] ?? null, resourcePath: key };
897
- }
898
-
899
- // src/core/email/search.ts
900
- var TITLE_MAX2 = 80;
901
- var UNSAFE2 = /[^\w\s\-.]/g;
902
- var MULTI_UNDERSCORE2 = /_+/g;
903
- function sanitize2(text) {
904
- if (text.trim() === "") return "No_Subject";
905
- let cleaned = text.replace(UNSAFE2, "_").replace(/ /g, "_");
906
- cleaned = cleaned.replace(MULTI_UNDERSCORE2, "_").replace(/^_+|_+$/g, "");
907
- if (cleaned.length > TITLE_MAX2) cleaned = `${cleaned.slice(0, TITLE_MAX2 - 3)}...`;
908
- return cleaned;
909
- }
910
- function dateFromHeader2(dateStr) {
911
- if (dateStr === "") return "1970-01-01";
912
- const d = new Date(dateStr);
913
- if (Number.isNaN(d.getTime())) return "1970-01-01";
914
- const yyyy = d.getUTCFullYear().toString().padStart(4, "0");
915
- const mm = (d.getUTCMonth() + 1).toString().padStart(2, "0");
916
- const dd = d.getUTCDate().toString().padStart(2, "0");
917
- return `${yyyy}-${mm}-${dd}`;
918
- }
919
- function buildSearchCriteria(opts) {
920
- const parts = [];
921
- if (opts.unseen === true) parts.push("UNSEEN");
922
- if (opts.text !== void 0 && opts.text !== null && opts.text !== "") {
923
- parts.push(`TEXT "${opts.text}"`);
924
- }
925
- if (opts.subject !== void 0 && opts.subject !== null && opts.subject !== "") {
926
- parts.push(`SUBJECT "${opts.subject}"`);
927
- }
928
- if (opts.fromAddr !== void 0 && opts.fromAddr !== null && opts.fromAddr !== "") {
929
- parts.push(`FROM "${opts.fromAddr}"`);
930
- }
931
- if (opts.toAddr !== void 0 && opts.toAddr !== null && opts.toAddr !== "") {
932
- parts.push(`TO "${opts.toAddr}"`);
933
- }
934
- if (opts.since !== void 0 && opts.since !== null && opts.since !== "") {
935
- parts.push(`SINCE ${opts.since}`);
936
- }
937
- if (opts.before !== void 0 && opts.before !== null && opts.before !== "") {
938
- parts.push(`BEFORE ${opts.before}`);
939
- }
940
- return parts.length > 0 ? parts.join(" ") : "ALL";
941
- }
942
- async function searchMessages(accessor, folder, opts = {}, maxResults = null) {
943
- const criteria = buildSearchCriteria(opts);
944
- return listMessageUids(accessor, folder, criteria, maxResults);
945
- }
946
- function buildVfsPath(prefix, folder, msg) {
947
- const dateStr = dateFromHeader2(msg.date);
948
- const subject = sanitize2(msg.subject !== "" ? msg.subject : "No Subject");
949
- const filename = `${subject}__${msg.uid}.email.json`;
950
- return [prefix, folder, dateStr, filename].filter((p) => p !== "").join("/");
951
- }
952
- async function searchAndFormat(accessor, scope, pattern, prefix, maxResults = null) {
953
- const folder = scope.folder ?? "";
954
- if (folder === "") return [];
955
- const uids = await searchMessages(accessor, folder, { text: pattern }, maxResults);
956
- const pairs = [];
957
- for (const uid of uids) {
958
- const msg = await fetchMessage(accessor, folder, uid);
959
- const msgText = JSON.stringify(msg);
960
- const vfsPath = buildVfsPath(prefix, folder, msg);
961
- pairs.push([vfsPath, msgText]);
962
- }
963
- return pairs;
964
- }
965
-
966
- // src/commands/builtin/email/grep.ts
967
- var ENC3 = new TextEncoder();
968
- var DEC = new TextDecoder("utf-8", { fatal: false });
969
- function parseFlags(flags) {
970
- const toInt = (v) => typeof v === "string" ? Number.parseInt(v, 10) : null;
971
- const aCtx = toInt(flags.A);
972
- const bCtx = toInt(flags.B);
973
- const cCtx = toInt(flags.C);
974
- return {
975
- ignoreCase: flags.i === true,
976
- invert: flags.v === true,
977
- lineNumbers: flags.n === true,
978
- countOnly: flags.c === true,
979
- filesOnly: flags.args_l === true || flags.l === true,
980
- wholeWord: flags.w === true,
981
- fixedString: flags.F === true,
982
- onlyMatching: flags.o === true,
983
- maxCount: toInt(flags.m),
984
- quiet: flags.q === true,
985
- afterContext: aCtx ?? cCtx ?? 0,
986
- beforeContext: bCtx ?? cCtx ?? 0
987
- };
988
- }
989
- function getPattern(texts, flags) {
990
- if (typeof flags.e === "string") return flags.e;
991
- if (texts.length > 0 && texts[0] !== void 0) return texts[0];
992
- throw new Error("grep: usage: grep [flags] pattern [path]");
993
- }
994
- function splitLinesNoTrailing(text) {
995
- const stripped = text.endsWith("\n") ? text.slice(0, -1) : text;
996
- return stripped === "" ? [] : stripped.split("\n");
997
- }
998
- async function grepCommand(accessor, paths, texts, opts) {
999
- let pattern;
1000
- try {
1001
- pattern = getPattern(texts, opts.flags);
1002
- } catch (err) {
1003
- const msg = err instanceof Error ? err.message : String(err);
1004
- return [null, new IOResult3({ exitCode: 2, stderr: ENC3.encode(`${msg}
1005
- `) })];
1006
- }
1007
- const f = parseFlags(opts.flags);
1008
- const recursive = opts.flags.r === true || opts.flags.R === true;
1009
- if (paths.length > 0) {
1010
- const first = paths[0];
1011
- if (first !== void 0) {
1012
- const scope = detectScope(first);
1013
- if (scope.useNative) {
1014
- const filePrefix2 = first.prefix !== "" ? first.prefix : "";
1015
- const pairs = await searchAndFormat(accessor, scope, pattern, filePrefix2, f.maxCount ?? 50);
1016
- const lines = [];
1017
- for (const [vfsPath, msgText] of pairs) {
1018
- const matched = grepLines(
1019
- vfsPath,
1020
- [msgText],
1021
- compilePattern(pattern, f.ignoreCase, f.fixedString, f.wholeWord),
1022
- f
1023
- );
1024
- for (const line of matched) lines.push(`${vfsPath}:${line}`);
1025
- }
1026
- if (lines.length === 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1 })];
1027
- const out = ENC3.encode(lines.join("\n") + "\n");
1028
- return [out, new IOResult3()];
1029
- }
1030
- }
1031
- const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
1032
- if (resolved.length === 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1 })];
1033
- const filePrefix = resolved[0]?.prefix ?? "";
1034
- const readdirFn = async (path) => {
1035
- const spec = new PathSpec2({
1036
- original: path,
1037
- directory: path,
1038
- resolved: false,
1039
- prefix: filePrefix
1040
- });
1041
- return readdir(accessor, spec, opts.index ?? void 0);
1042
- };
1043
- const statFn = async (path) => {
1044
- const spec = new PathSpec2({
1045
- original: path,
1046
- directory: path,
1047
- resolved: false,
1048
- prefix: filePrefix
1049
- });
1050
- return stat(accessor, spec, opts.index ?? void 0);
1051
- };
1052
- const readBytesFn = async (path) => {
1053
- const spec = new PathSpec2({
1054
- original: path,
1055
- directory: path,
1056
- resolved: true,
1057
- prefix: filePrefix
1058
- });
1059
- return read(accessor, spec, opts.index ?? void 0);
1060
- };
1061
- if (f.filesOnly) {
1062
- const warnings = [];
1063
- const firstResolved2 = resolved[0];
1064
- if (firstResolved2 === void 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1 })];
1065
- const results = await grepFilesOnly(
1066
- readdirFn,
1067
- statFn,
1068
- readBytesFn,
1069
- firstResolved2.original,
1070
- pattern,
1071
- {
1072
- recursive,
1073
- ignoreCase: f.ignoreCase,
1074
- invert: f.invert,
1075
- lineNumbers: f.lineNumbers,
1076
- countOnly: f.countOnly,
1077
- fixedString: f.fixedString,
1078
- onlyMatching: f.onlyMatching,
1079
- maxCount: f.maxCount,
1080
- wholeWord: f.wholeWord
1081
- },
1082
- warnings
1083
- );
1084
- const stderr = warnings.length > 0 ? formatRecords2(warnings) : null;
1085
- if (results.length === 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1, stderr })];
1086
- const out = formatRecords2(results);
1087
- return [out, new IOResult3({ stderr })];
1088
- }
1089
- const pat2 = compilePattern(pattern, f.ignoreCase, f.fixedString, f.wholeWord);
1090
- if (resolved.length > 1) {
1091
- const allResults = [];
1092
- for (const p of resolved) {
1093
- const data2 = splitLinesNoTrailing(
1094
- DEC.decode(await read(accessor, p, opts.index ?? void 0))
1095
- );
1096
- const hits = grepLines(p.original, data2, pat2, f);
1097
- if (f.countOnly) {
1098
- if (hits.length > 0) allResults.push(`${p.original}:${hits[0] ?? ""}`);
1099
- } else {
1100
- for (const h of hits) allResults.push(`${p.original}:${h}`);
1101
- }
1102
- }
1103
- if (allResults.length === 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1 })];
1104
- const out = formatRecords2(allResults);
1105
- return [out, new IOResult3()];
1106
- }
1107
- const firstResolved = resolved[0];
1108
- if (firstResolved === void 0) return [null, new IOResult3()];
1109
- const data = await read(accessor, firstResolved, opts.index ?? void 0);
1110
- const source2 = yieldBytes(data);
1111
- const stream2 = grepStream(source2, pat2, f);
1112
- if (f.quiet) {
1113
- const io3 = new IOResult3({ exitCode: 1 });
1114
- return [quietMatch(stream2, io3), io3];
1115
- }
1116
- const io2 = new IOResult3();
1117
- return [exitOnEmpty(stream2, io2), io2];
1118
- }
1119
- let source;
1120
- try {
1121
- source = resolveSource(opts.stdin, "grep: usage: grep [flags] pattern [path]");
1122
- } catch (err) {
1123
- const msg = err instanceof Error ? err.message : String(err);
1124
- return [null, new IOResult3({ exitCode: 2, stderr: ENC3.encode(`${msg}
1125
- `) })];
1126
- }
1127
- const pat = compilePattern(pattern, f.ignoreCase, f.fixedString, f.wholeWord);
1128
- const stream = grepStream(source, pat, f);
1129
- if (f.quiet) {
1130
- const io2 = new IOResult3({ exitCode: 1 });
1131
- return [quietMatch(stream, io2), io2];
1132
- }
1133
- const io = new IOResult3();
1134
- return [exitOnEmpty(stream, io), io];
1135
- }
1136
- var EMAIL_GREP = command6({
1137
- name: "grep",
1138
- resource: ResourceName6.EMAIL,
1139
- spec: specOf5("grep"),
1140
- fn: grepCommand,
1141
- aggregate: prefixAggregate,
1142
- provision: fileReadProvision
1143
- });
1144
-
1145
- // src/commands/builtin/email/head.ts
1146
- import {
1147
- ResourceName as ResourceName7,
1148
- command as command7,
1149
- headGeneric,
1150
- specOf as specOf6
1151
- } from "@struktoai/mirage-core";
1152
- async function* emailStream2(accessor, p, index) {
1153
- yield await read(accessor, p, index);
1154
- }
1155
- async function headCommand(accessor, paths, texts, opts) {
1156
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
1157
- return headGeneric(
1158
- resolved,
1159
- texts,
1160
- opts,
1161
- (p) => stat(accessor, p, opts.index ?? void 0),
1162
- (p) => emailStream2(accessor, p, opts.index ?? void 0)
1163
- );
1164
- }
1165
- var EMAIL_HEAD = command7({
1166
- name: "head",
1167
- resource: ResourceName7.EMAIL,
1168
- spec: specOf6("head"),
1169
- fn: headCommand,
1170
- provision: fileReadProvision
1171
- });
1172
-
1173
- // src/commands/builtin/email/jq.ts
1174
- import {
1175
- ResourceName as ResourceName8,
1176
- command as command8,
1177
- jqGeneric,
1178
- specOf as specOf7
1179
- } from "@struktoai/mirage-core";
1180
- async function* emailStream3(accessor, p, index) {
1181
- yield await read(accessor, p, index);
1182
- }
1183
- async function jqCommand(accessor, paths, texts, opts) {
1184
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
1185
- const stream = (p) => emailStream3(accessor, p, opts.index ?? void 0);
1186
- return jqGeneric(resolved, texts, opts, stream);
1187
- }
1188
- var EMAIL_JQ = command8({
1189
- name: "jq",
1190
- resource: ResourceName8.EMAIL,
1191
- spec: specOf7("jq"),
1192
- fn: jqCommand
1193
- });
1194
-
1195
- // src/commands/builtin/email/ls.ts
1196
- import {
1197
- PathSpec as PathSpec3,
1198
- ResourceName as ResourceName9,
1199
- command as command9,
1200
- lsGeneric,
1201
- specOf as specOf8
1202
- } from "@struktoai/mirage-core";
1203
- async function lsCommand(accessor, paths, _texts, opts) {
1204
- let workingPaths = paths;
1205
- if (workingPaths.length === 0) {
1206
- workingPaths = [
1207
- new PathSpec3({
1208
- original: opts.cwd,
1209
- directory: opts.cwd,
1210
- resolved: false,
1211
- prefix: opts.mountPrefix ?? ""
1212
- })
1213
- ];
1214
- }
1215
- const resolved = await resolveGlob(accessor, workingPaths, opts.index ?? void 0);
1216
- return lsGeneric(
1217
- resolved,
1218
- opts,
1219
- (p) => readdir(accessor, p, opts.index ?? void 0),
1220
- (p) => stat(accessor, p, opts.index ?? void 0)
1221
- );
1222
- }
1223
- var EMAIL_LS = command9({
1224
- name: "ls",
1225
- resource: ResourceName9.EMAIL,
1226
- spec: specOf8("ls"),
1227
- fn: lsCommand,
1228
- provision: metadataProvision
1229
- });
1230
-
1231
- // src/commands/builtin/email/nl.ts
1232
- import {
1233
- ResourceName as ResourceName10,
1234
- command as command10,
1235
- nlGeneric,
1236
- specOf as specOf9
1237
- } from "@struktoai/mirage-core";
1238
- async function* emailStream4(accessor, p, index) {
1239
- yield await read(accessor, p, index);
1240
- }
1241
- async function nlCommand(accessor, paths, _texts, opts) {
1242
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
1243
- return nlGeneric(resolved, opts, (p) => emailStream4(accessor, p, opts.index ?? void 0));
1244
- }
1245
- var EMAIL_NL = command10({
1246
- name: "nl",
1247
- resource: ResourceName10.EMAIL,
1248
- spec: specOf9("nl"),
1249
- fn: nlCommand,
1250
- provision: fileReadProvision
1251
- });
1252
-
1253
- // src/commands/builtin/email/email_read.ts
1254
- import {
1255
- CommandSpec as CommandSpec2,
1256
- IOResult as IOResult4,
1257
- OperandKind as OperandKind2,
1258
- Option as Option2,
1259
- ResourceName as ResourceName11,
1260
- command as command11
1261
- } from "@struktoai/mirage-core";
1262
- var ENC4 = new TextEncoder();
1263
- var SPEC2 = new CommandSpec2({
1264
- options: [
1265
- new Option2({ long: "--uid", valueKind: OperandKind2.TEXT }),
1266
- new Option2({ long: "--folder", valueKind: OperandKind2.TEXT })
1267
- ]
1268
- });
1269
- async function emailReadCommand(accessor, _paths, _texts, opts) {
1270
- const uid = typeof opts.flags.uid === "string" ? opts.flags.uid : "";
1271
- const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
1272
- if (uid === "") {
1273
- return [null, new IOResult4({ exitCode: 2, stderr: ENC4.encode("--uid is required\n") })];
1274
- }
1275
- if (folder === "") {
1276
- return [null, new IOResult4({ exitCode: 2, stderr: ENC4.encode("--folder is required\n") })];
1277
- }
1278
- const processed = await fetchMessage(accessor, folder, uid);
1279
- const out = ENC4.encode(JSON.stringify(processed));
1280
- return [out, new IOResult4()];
1281
- }
1282
- var EMAIL_READ = command11({
1283
- name: "email-read",
1284
- resource: ResourceName11.EMAIL,
1285
- spec: SPEC2,
1286
- fn: emailReadCommand
1287
- });
1288
-
1289
- // src/commands/builtin/email/realpath.ts
1290
- import { ResourceName as ResourceName12, command as command12, realpathGeneric, specOf as specOf10 } from "@struktoai/mirage-core";
1291
- var EMAIL_REALPATH = command12({
1292
- name: "realpath",
1293
- resource: ResourceName12.EMAIL,
1294
- spec: specOf10("realpath"),
1295
- fn: (accessor, paths, texts, opts) => realpathGeneric(paths, texts, opts, (p) => stat(accessor, p, opts.index ?? void 0))
1296
- });
1297
-
1298
- // src/commands/builtin/email/email_reply.ts
1299
- import {
1300
- CommandSpec as CommandSpec3,
1301
- IOResult as IOResult5,
1302
- OperandKind as OperandKind3,
1303
- Option as Option3,
1304
- ResourceName as ResourceName13,
1305
- command as command13
1306
- } from "@struktoai/mirage-core";
1307
- var ENC5 = new TextEncoder();
1308
- var SPEC3 = new CommandSpec3({
1309
- options: [
1310
- new Option3({ long: "--uid", valueKind: OperandKind3.TEXT }),
1311
- new Option3({ long: "--folder", valueKind: OperandKind3.TEXT }),
1312
- new Option3({ long: "--body", valueKind: OperandKind3.TEXT })
1313
- ]
1314
- });
1315
- async function emailReplyCommand(accessor, _paths, _texts, opts) {
1316
- const uid = typeof opts.flags.uid === "string" ? opts.flags.uid : "";
1317
- const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
1318
- const body = typeof opts.flags.body === "string" ? opts.flags.body : "";
1319
- if (uid === "") {
1320
- return [null, new IOResult5({ exitCode: 2, stderr: ENC5.encode("--uid is required\n") })];
1321
- }
1322
- if (folder === "") {
1323
- return [null, new IOResult5({ exitCode: 2, stderr: ENC5.encode("--folder is required\n") })];
1324
- }
1325
- if (body === "") {
1326
- return [null, new IOResult5({ exitCode: 2, stderr: ENC5.encode("--body is required\n") })];
1327
- }
1328
- const original = await fetchMessage(accessor, folder, uid);
1329
- const result = await replyMessage(accessor.config, original, body);
1330
- const out = ENC5.encode(JSON.stringify(result));
1331
- return [out, new IOResult5()];
1332
- }
1333
- var EMAIL_REPLY = command13({
1334
- name: "email-reply",
1335
- resource: ResourceName13.EMAIL,
1336
- spec: SPEC3,
1337
- fn: emailReplyCommand,
1338
- write: true
1339
- });
1340
-
1341
- // src/commands/builtin/email/email_reply_all.ts
1342
- import {
1343
- CommandSpec as CommandSpec4,
1344
- IOResult as IOResult6,
1345
- OperandKind as OperandKind4,
1346
- Option as Option4,
1347
- ResourceName as ResourceName14,
1348
- command as command14
1349
- } from "@struktoai/mirage-core";
1350
- var ENC6 = new TextEncoder();
1351
- var SPEC4 = new CommandSpec4({
1352
- options: [
1353
- new Option4({ long: "--uid", valueKind: OperandKind4.TEXT }),
1354
- new Option4({ long: "--folder", valueKind: OperandKind4.TEXT }),
1355
- new Option4({ long: "--body", valueKind: OperandKind4.TEXT })
1356
- ]
1357
- });
1358
- async function emailReplyAllCommand(accessor, _paths, _texts, opts) {
1359
- const uid = typeof opts.flags.uid === "string" ? opts.flags.uid : "";
1360
- const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
1361
- const body = typeof opts.flags.body === "string" ? opts.flags.body : "";
1362
- if (uid === "") {
1363
- return [null, new IOResult6({ exitCode: 2, stderr: ENC6.encode("--uid is required\n") })];
1364
- }
1365
- if (folder === "") {
1366
- return [null, new IOResult6({ exitCode: 2, stderr: ENC6.encode("--folder is required\n") })];
1367
- }
1368
- if (body === "") {
1369
- return [null, new IOResult6({ exitCode: 2, stderr: ENC6.encode("--body is required\n") })];
1370
- }
1371
- const original = await fetchMessage(accessor, folder, uid);
1372
- const result = await replyAllMessage(accessor.config, original, body);
1373
- const out = ENC6.encode(JSON.stringify(result));
1374
- return [out, new IOResult6()];
1375
- }
1376
- var EMAIL_REPLY_ALL = command14({
1377
- name: "email-reply-all",
1378
- resource: ResourceName14.EMAIL,
1379
- spec: SPEC4,
1380
- fn: emailReplyAllCommand,
1381
- write: true
1382
- });
1383
-
1384
- // src/commands/builtin/email/rg.ts
1385
- import {
1386
- IOResult as IOResult7,
1387
- ResourceName as ResourceName15,
1388
- command as command15,
1389
- compilePattern as compilePattern2,
1390
- grepLines as grepLines2,
1391
- rgGeneric,
1392
- specOf as specOf11
1393
- } from "@struktoai/mirage-core";
1394
- var ENC7 = new TextEncoder();
1395
- async function* emailStream5(accessor, p, index) {
1396
- yield await read(accessor, p, index);
1397
- }
1398
- async function rgCommand(accessor, paths, texts, opts) {
1399
- if (texts.length === 0 || texts[0] === void 0) {
1400
- return [
1401
- null,
1402
- new IOResult7({ exitCode: 2, stderr: ENC7.encode("rg: usage: rg [flags] pattern [path]\n") })
1403
- ];
1404
- }
1405
- const pattern = texts[0];
1406
- const ignoreCase = opts.flags.i === true;
1407
- const invert = opts.flags.v === true;
1408
- const lineNumbers = opts.flags.n === true;
1409
- const countOnly = opts.flags.c === true;
1410
- const filesOnly = opts.flags.args_l === true || opts.flags.l === true;
1411
- const wholeWord = opts.flags.w === true;
1412
- const fixedString = opts.flags.F === true;
1413
- const onlyMatching = opts.flags.o === true;
1414
- const maxCount = typeof opts.flags.m === "string" ? Number.parseInt(opts.flags.m, 10) : null;
1415
- const pat = compilePattern2(pattern, ignoreCase, fixedString, wholeWord);
1416
- const lineOpts = {
1417
- invert,
1418
- lineNumbers,
1419
- countOnly,
1420
- filesOnly,
1421
- onlyMatching,
1422
- maxCount
1423
- };
1424
- if (paths.length > 0) {
1425
- const first = paths[0];
1426
- if (first !== void 0) {
1427
- const scope = detectScope(first);
1428
- if (scope.useNative) {
1429
- const filePrefix = first.prefix !== "" ? first.prefix : "";
1430
- const pairs = await searchAndFormat(accessor, scope, pattern, filePrefix, maxCount ?? 50);
1431
- const lines = [];
1432
- for (const [vfsPath, msgText] of pairs) {
1433
- const matched = grepLines2(vfsPath, [msgText], pat, lineOpts);
1434
- for (const line of matched) lines.push(`${vfsPath}:${line}`);
1435
- }
1436
- if (lines.length === 0) return [new Uint8Array(0), new IOResult7({ exitCode: 1 })];
1437
- const out = ENC7.encode(lines.join("\n") + "\n");
1438
- return [out, new IOResult7()];
1439
- }
1440
- }
1441
- }
1442
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
1443
- const stat2 = (p) => stat(accessor, p, opts.index ?? void 0);
1444
- const readdir2 = (p) => readdir(accessor, p, opts.index ?? void 0);
1445
- return rgGeneric(
1446
- resolved,
1447
- texts,
1448
- opts,
1449
- stat2,
1450
- readdir2,
1451
- (p) => emailStream5(accessor, p, opts.index ?? void 0)
1452
- );
1453
- }
1454
- var EMAIL_RG = command15({
1455
- name: "rg",
1456
- resource: ResourceName15.EMAIL,
1457
- spec: specOf11("rg"),
1458
- fn: rgCommand
1459
- });
1460
-
1461
- // src/commands/builtin/email/email_send.ts
1462
- import {
1463
- CommandSpec as CommandSpec5,
1464
- IOResult as IOResult8,
1465
- OperandKind as OperandKind5,
1466
- Option as Option5,
1467
- ResourceName as ResourceName16,
1468
- command as command16
1469
- } from "@struktoai/mirage-core";
1470
- var ENC8 = new TextEncoder();
1471
- var SPEC5 = new CommandSpec5({
1472
- options: [
1473
- new Option5({ long: "--to", valueKind: OperandKind5.TEXT }),
1474
- new Option5({ long: "--subject", valueKind: OperandKind5.TEXT }),
1475
- new Option5({ long: "--body", valueKind: OperandKind5.TEXT })
1476
- ]
1477
- });
1478
- async function emailSendCommand(accessor, _paths, _texts, opts) {
1479
- const to = typeof opts.flags.to === "string" ? opts.flags.to : "";
1480
- const subject = typeof opts.flags.subject === "string" ? opts.flags.subject : "";
1481
- const body = typeof opts.flags.body === "string" ? opts.flags.body : "";
1482
- if (to === "") {
1483
- return [null, new IOResult8({ exitCode: 2, stderr: ENC8.encode("--to is required\n") })];
1484
- }
1485
- if (subject === "") {
1486
- return [null, new IOResult8({ exitCode: 2, stderr: ENC8.encode("--subject is required\n") })];
1487
- }
1488
- if (body === "") {
1489
- return [null, new IOResult8({ exitCode: 2, stderr: ENC8.encode("--body is required\n") })];
1490
- }
1491
- const result = await sendMessage(accessor.config, to, subject, body);
1492
- const out = ENC8.encode(JSON.stringify(result));
1493
- return [out, new IOResult8()];
1494
- }
1495
- var EMAIL_SEND = command16({
1496
- name: "email-send",
1497
- resource: ResourceName16.EMAIL,
1498
- spec: SPEC5,
1499
- fn: emailSendCommand,
1500
- write: true
1501
- });
1502
-
1503
- // src/commands/builtin/email/stat.ts
1504
- import {
1505
- ResourceName as ResourceName17,
1506
- command as command17,
1507
- specOf as specOf12,
1508
- statGeneric
1509
- } from "@struktoai/mirage-core";
1510
- async function statCommand(accessor, paths, _texts, opts) {
1511
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
1512
- return statGeneric(resolved, opts, (p) => stat(accessor, p, opts.index ?? void 0));
1513
- }
1514
- var EMAIL_STAT = command17({
1515
- name: "stat",
1516
- resource: ResourceName17.EMAIL,
1517
- spec: specOf12("stat"),
1518
- fn: statCommand,
1519
- provision: metadataProvision
1520
- });
1521
-
1522
- // src/commands/builtin/email/tail.ts
1523
- import {
1524
- ResourceName as ResourceName18,
1525
- command as command18,
1526
- specOf as specOf13,
1527
- tailGeneric
1528
- } from "@struktoai/mirage-core";
1529
- async function* emailStream6(accessor, p, index) {
1530
- yield await read(accessor, p, index);
1531
- }
1532
- async function tailCommand(accessor, paths, texts, opts) {
1533
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
1534
- return tailGeneric(
1535
- resolved,
1536
- texts,
1537
- opts,
1538
- (p) => emailStream6(accessor, p, opts.index ?? void 0)
1539
- );
1540
- }
1541
- var EMAIL_TAIL = command18({
1542
- name: "tail",
1543
- resource: ResourceName18.EMAIL,
1544
- spec: specOf13("tail"),
1545
- fn: tailCommand,
1546
- provision: fileReadProvision
1547
- });
1548
-
1549
- // src/commands/builtin/email/tree.ts
1550
- import {
1551
- ResourceName as ResourceName19,
1552
- command as command19,
1553
- specOf as specOf14,
1554
- treeGeneric
1555
- } from "@struktoai/mirage-core";
1556
- async function treeCommand(accessor, paths, _texts, opts) {
1557
- const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
1558
- return treeGeneric(
1559
- resolved,
1560
- opts,
1561
- (p) => readdir(accessor, p, opts.index ?? void 0),
1562
- (p) => stat(accessor, p, opts.index ?? void 0)
1563
- );
1564
- }
1565
- var EMAIL_TREE = command19({
1566
- name: "tree",
1567
- resource: ResourceName19.EMAIL,
1568
- spec: specOf14("tree"),
1569
- fn: treeCommand
1570
- });
1571
-
1572
- // src/commands/builtin/email/email_triage.ts
1573
- import {
1574
- CommandSpec as CommandSpec6,
1575
- IOResult as IOResult9,
1576
- OperandKind as OperandKind6,
1577
- Option as Option6,
1578
- ResourceName as ResourceName20,
1579
- command as command20
1580
- } from "@struktoai/mirage-core";
1581
- var ENC9 = new TextEncoder();
1582
- var SPEC6 = new CommandSpec6({
1583
- options: [
1584
- new Option6({ long: "--folder", valueKind: OperandKind6.TEXT }),
1585
- new Option6({ long: "--max", valueKind: OperandKind6.TEXT }),
1586
- new Option6({ long: "--unseen" }),
1587
- new Option6({ long: "--subject", valueKind: OperandKind6.TEXT }),
1588
- new Option6({ long: "--from", valueKind: OperandKind6.TEXT }),
1589
- new Option6({ long: "--to", valueKind: OperandKind6.TEXT }),
1590
- new Option6({ long: "--body", valueKind: OperandKind6.TEXT }),
1591
- new Option6({ long: "--since", valueKind: OperandKind6.TEXT }),
1592
- new Option6({ long: "--before", valueKind: OperandKind6.TEXT })
1593
- ]
1594
- });
1595
- async function emailTriageCommand(accessor, _paths, _texts, opts) {
1596
- const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "INBOX";
1597
- const maxResults = typeof opts.flags.max === "string" ? Number.parseInt(opts.flags.max, 10) : 20;
1598
- const uids = await searchMessages(
1599
- accessor,
1600
- folder,
1601
- {
1602
- text: typeof opts.flags.body === "string" ? opts.flags.body : null,
1603
- subject: typeof opts.flags.subject === "string" ? opts.flags.subject : null,
1604
- fromAddr: typeof opts.flags.from === "string" ? opts.flags.from : null,
1605
- toAddr: typeof opts.flags.to === "string" ? opts.flags.to : null,
1606
- since: typeof opts.flags.since === "string" ? opts.flags.since : null,
1607
- before: typeof opts.flags.before === "string" ? opts.flags.before : null,
1608
- unseen: opts.flags.unseen === true
1609
- },
1610
- maxResults
1611
- );
1612
- if (uids.length === 0) {
1613
- const out2 = ENC9.encode("[]");
1614
- return [out2, new IOResult9()];
1615
- }
1616
- const headers = await fetchHeaders(accessor, folder, uids);
1617
- const out = ENC9.encode(JSON.stringify(headers));
1618
- return [out, new IOResult9()];
1619
- }
1620
- var EMAIL_TRIAGE = command20({
1621
- name: "email-triage",
1622
- resource: ResourceName20.EMAIL,
1623
- spec: SPEC6,
1624
- fn: emailTriageCommand
1625
- });
1626
-
1627
- // src/commands/builtin/email/wc.ts
1628
- import {
1629
- ResourceName as ResourceName21,
1630
- command as command21,
1631
- specOf as specOf15,
1632
- wcGeneric
1633
- } from "@struktoai/mirage-core";
1634
- async function* emailStream7(accessor, p, index) {
1635
- yield await read(accessor, p, index);
1636
- }
1637
- async function wcCommand(accessor, paths, texts, opts) {
1638
- const resolved = paths.length > 0 ? await resolveGlob(accessor, paths, opts.index ?? void 0) : [];
1639
- return wcGeneric(resolved, texts, opts, (p) => emailStream7(accessor, p, opts.index ?? void 0));
1640
- }
1641
- var EMAIL_WC = command21({
1642
- name: "wc",
1643
- resource: ResourceName21.EMAIL,
1644
- spec: specOf15("wc"),
1645
- fn: wcCommand,
1646
- provision: fileReadProvision
1647
- });
1648
-
1649
- // src/commands/builtin/email/index.ts
1650
- var EMAIL_COMMANDS = [
1651
- ...EMAIL_BASENAME,
1652
- ...EMAIL_CAT,
1653
- ...EMAIL_DIRNAME,
1654
- ...EMAIL_FIND,
1655
- ...EMAIL_GREP,
1656
- ...EMAIL_HEAD,
1657
- ...EMAIL_JQ,
1658
- ...EMAIL_LS,
1659
- ...EMAIL_NL,
1660
- ...EMAIL_REALPATH,
1661
- ...EMAIL_RG,
1662
- ...EMAIL_STAT,
1663
- ...EMAIL_TAIL,
1664
- ...EMAIL_TREE,
1665
- ...EMAIL_WC,
1666
- ...EMAIL_SEND,
1667
- ...EMAIL_REPLY,
1668
- ...EMAIL_REPLY_ALL,
1669
- ...EMAIL_FORWARD,
1670
- ...EMAIL_TRIAGE,
1671
- ...EMAIL_READ
1672
- ];
1673
-
1674
- // src/ops/email/read.ts
1675
- import { ResourceName as ResourceName22 } from "@struktoai/mirage-core";
1676
- var readOp = {
1677
- name: "read",
1678
- resource: ResourceName22.EMAIL,
1679
- filetype: null,
1680
- write: false,
1681
- fn: (accessor, path, _args, kwargs) => {
1682
- return read(accessor, path, kwargs.index);
1683
- }
1684
- };
1685
-
1686
- // src/ops/email/readdir.ts
1687
- import { ResourceName as ResourceName23 } from "@struktoai/mirage-core";
1688
- var readdirOp = {
1689
- name: "readdir",
1690
- resource: ResourceName23.EMAIL,
1691
- filetype: null,
1692
- write: false,
1693
- fn: (accessor, path, _args, kwargs) => {
1694
- return readdir(accessor, path, kwargs.index);
1695
- }
1696
- };
1697
-
1698
- // src/ops/email/stat.ts
1699
- import { ResourceName as ResourceName24 } from "@struktoai/mirage-core";
1700
- var statOp = {
1701
- name: "stat",
1702
- resource: ResourceName24.EMAIL,
1703
- filetype: null,
1704
- write: false,
1705
- fn: (accessor, path, _args, kwargs) => {
1706
- return stat(accessor, path, kwargs.index);
1707
- }
1708
- };
1709
-
1710
- // src/ops/email/index.ts
1711
- var EMAIL_OPS = [readdirOp, readOp, statOp];
1712
-
1713
- // src/resource/email/prompt.ts
1714
- var EMAIL_PROMPT = `{prefix}
1715
- <folder>/
1716
- <yyyy-mm-dd>/
1717
- <subject>__<uid>.email.json
1718
- <subject>__<uid>/ # if attachments exist
1719
- <attachment-filename>
1720
- Folders include: INBOX, Sent, Drafts, etc. cat shows email as JSON.`;
1721
- var EMAIL_WRITE_PROMPT = ` Write commands:
1722
- email-send "to@email.com" "subject" "body"
1723
- email-reply <email-path> "reply body"
1724
- email-forward <email-path> "to@email.com"`;
1725
-
1726
- // src/resource/email/email.ts
1727
- var EmailResource = class extends BaseResource {
1728
- kind = ResourceName25.EMAIL;
1729
- cachesReads = true;
1730
- indexTtl = 86400;
1731
- prompt = EMAIL_PROMPT;
1732
- config;
1733
- accessor;
1734
- constructor(config) {
1735
- super();
1736
- this.config = config;
1737
- this.accessor = new EmailAccessor(config);
1738
- }
1739
- open() {
1740
- return Promise.resolve();
1741
- }
1742
- async close() {
1743
- await this.accessor.close();
1744
- }
1745
- commands() {
1746
- return EMAIL_COMMANDS;
1747
- }
1748
- ops() {
1749
- return EMAIL_OPS;
1750
- }
1751
- readFile(p) {
1752
- return read(this.accessor, p, this.index);
1753
- }
1754
- readdir(p) {
1755
- return readdir(this.accessor, p, this.index);
1756
- }
1757
- stat(p) {
1758
- return stat(this.accessor, p, this.index);
1759
- }
1760
- async fingerprint(p) {
1761
- const lookup = await this.index.get(p.original);
1762
- return lookup.entry?.remoteTime ?? null;
1763
- }
1764
- glob(paths, prefix = "") {
1765
- const effective = prefix !== "" ? paths.map(
1766
- (p) => p.prefix !== "" ? p : new PathSpec4({
1767
- original: p.original,
1768
- directory: p.directory,
1769
- ...p.pattern !== null ? { pattern: p.pattern } : {},
1770
- resolved: p.resolved,
1771
- prefix
1772
- })
1773
- ) : paths;
1774
- return resolveGlob(this.accessor, effective, this.index);
1775
- }
1776
- getState() {
1777
- return Promise.resolve({
1778
- type: this.kind,
1779
- config: redactEmailConfig(this.config)
1780
- });
1781
- }
1782
- loadState(_state) {
1783
- return Promise.resolve();
1784
- }
1785
- };
1786
-
1787
- export {
1788
- EmailAccessor,
1789
- EMAIL_COMMANDS,
1790
- EMAIL_OPS,
1791
- EMAIL_PROMPT,
1792
- EMAIL_WRITE_PROMPT,
1793
- EmailResource
1794
- };
1795
- //# sourceMappingURL=chunk-S5OVP467.js.map