@struktoai/mirage-node 0.0.2-alpha.0 → 0.0.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -127
- package/dist/aliyun-TMZRUYCG.js +10 -0
- package/dist/backblaze-OHW57DLK.js +10 -0
- package/dist/box-UXTCAFOZ.js +8 -0
- package/dist/ceph-TNN4I2FT.js +10 -0
- package/dist/chunk-2CC5VW7K.js +52 -0
- package/dist/chunk-2CC5VW7K.js.map +1 -0
- package/dist/chunk-3IJSIVKT.js +57 -0
- package/dist/chunk-3IJSIVKT.js.map +1 -0
- package/dist/chunk-3T3RMDNX.js +57 -0
- package/dist/chunk-3T3RMDNX.js.map +1 -0
- package/dist/chunk-54NTYJEO.js +13 -0
- package/dist/chunk-54NTYJEO.js.map +1 -0
- package/dist/{chunk-DCJQ2PIX.js → chunk-5DLOHQJ2.js} +5 -8
- package/dist/chunk-5DLOHQJ2.js.map +1 -0
- package/dist/chunk-5HCVKTP3.js +2086 -0
- package/dist/chunk-5HCVKTP3.js.map +1 -0
- package/dist/{chunk-5E6BULAK.js → chunk-5YOCVEUB.js} +5 -8
- package/dist/chunk-5YOCVEUB.js.map +1 -0
- package/dist/{chunk-6M2NL363.js → chunk-A4Z6DZ22.js} +6 -8
- package/dist/chunk-A4Z6DZ22.js.map +1 -0
- package/dist/{chunk-NOZZFJEB.js → chunk-A7X4L4JM.js} +5 -8
- package/dist/chunk-A7X4L4JM.js.map +1 -0
- package/dist/{chunk-GCB4JUF7.js → chunk-ABTEGAFB.js} +5 -8
- package/dist/chunk-ABTEGAFB.js.map +1 -0
- package/dist/chunk-AJICZLHT.js +57 -0
- package/dist/chunk-AJICZLHT.js.map +1 -0
- package/dist/{chunk-H74QYTN7.js → chunk-B2ZOKNN4.js} +14 -3
- package/dist/chunk-B2ZOKNN4.js.map +1 -0
- package/dist/{chunk-ICSS5ETT.js → chunk-B6SXRCBO.js} +8 -18
- package/dist/chunk-B6SXRCBO.js.map +1 -0
- package/dist/{chunk-HEQL3LPK.js → chunk-BYTU2YC3.js} +8 -18
- package/dist/chunk-BYTU2YC3.js.map +1 -0
- package/dist/{chunk-V5OLWE7F.js → chunk-C6NHEDHY.js} +5 -8
- package/dist/chunk-C6NHEDHY.js.map +1 -0
- package/dist/chunk-C6NHFMIP.js +57 -0
- package/dist/chunk-C6NHFMIP.js.map +1 -0
- package/dist/chunk-CASCUFK2.js +87 -0
- package/dist/chunk-CASCUFK2.js.map +1 -0
- package/dist/chunk-DNBAMB5J.js +18 -0
- package/dist/chunk-DNBAMB5J.js.map +1 -0
- package/dist/chunk-DP2PP5V2.js +26 -0
- package/dist/chunk-DP2PP5V2.js.map +1 -0
- package/dist/{chunk-OYJXYJTE.js → chunk-DTAY7LPC.js} +303 -866
- package/dist/chunk-DTAY7LPC.js.map +1 -0
- package/dist/chunk-DYXEITK3.js +52 -0
- package/dist/chunk-DYXEITK3.js.map +1 -0
- package/dist/chunk-E2ISWXLB.js +7 -0
- package/dist/chunk-E2ISWXLB.js.map +1 -0
- package/dist/{chunk-XDEEOTVK.js → chunk-E7RW3SBV.js} +5 -8
- package/dist/chunk-E7RW3SBV.js.map +1 -0
- package/dist/chunk-EGB7V74Z.js +76 -0
- package/dist/chunk-EGB7V74Z.js.map +1 -0
- package/dist/{chunk-LBBM3LKK.js → chunk-ERELJ7BS.js} +5 -8
- package/dist/chunk-ERELJ7BS.js.map +1 -0
- package/dist/chunk-FXFDBF3P.js +57 -0
- package/dist/chunk-FXFDBF3P.js.map +1 -0
- package/dist/chunk-G5BZE7UA.js +50 -0
- package/dist/chunk-G5BZE7UA.js.map +1 -0
- package/dist/chunk-H3BST2LI.js +26 -0
- package/dist/chunk-H3BST2LI.js.map +1 -0
- package/dist/chunk-H3I2KZIY.js +25 -0
- package/dist/chunk-H3I2KZIY.js.map +1 -0
- package/dist/{chunk-UWMOTOXA.js → chunk-HEHERHQ5.js} +8 -15
- package/dist/chunk-HEHERHQ5.js.map +1 -0
- package/dist/chunk-HQ4KWN76.js +57 -0
- package/dist/chunk-HQ4KWN76.js.map +1 -0
- package/dist/{chunk-MY3NUJJD.js → chunk-IQVNVTOP.js} +8 -18
- package/dist/chunk-IQVNVTOP.js.map +1 -0
- package/dist/chunk-JALIYI6M.js +55 -0
- package/dist/chunk-JALIYI6M.js.map +1 -0
- package/dist/chunk-JZQHKDSY.js +216 -0
- package/dist/chunk-JZQHKDSY.js.map +1 -0
- package/dist/chunk-JZT4QGIP.js +24 -0
- package/dist/chunk-JZT4QGIP.js.map +1 -0
- package/dist/chunk-KTNDT45N.js +57 -0
- package/dist/chunk-KTNDT45N.js.map +1 -0
- package/dist/chunk-L6JPBJAS.js +57 -0
- package/dist/chunk-L6JPBJAS.js.map +1 -0
- package/dist/{chunk-6VKNSO6U.js → chunk-LAJJPLEV.js} +17 -11
- package/dist/chunk-LAJJPLEV.js.map +1 -0
- package/dist/chunk-LW25LMIH.js +26 -0
- package/dist/chunk-LW25LMIH.js.map +1 -0
- package/dist/{chunk-WSDQ2MRG.js → chunk-LYDMMNL2.js} +5 -8
- package/dist/chunk-LYDMMNL2.js.map +1 -0
- package/dist/{chunk-G7O6DAWU.js → chunk-MHCMHKM6.js} +15 -9
- package/dist/chunk-MHCMHKM6.js.map +1 -0
- package/dist/chunk-N72CAZEH.js +1990 -0
- package/dist/chunk-N72CAZEH.js.map +1 -0
- package/dist/{chunk-XQUQSNCA.js → chunk-NHS7WLEQ.js} +4 -5
- package/dist/chunk-NHS7WLEQ.js.map +1 -0
- package/dist/chunk-NJMGCT63.js +54 -0
- package/dist/chunk-NJMGCT63.js.map +1 -0
- package/dist/chunk-O7ODGJYL.js +57 -0
- package/dist/chunk-O7ODGJYL.js.map +1 -0
- package/dist/chunk-OHROA3FQ.js +54 -0
- package/dist/chunk-OHROA3FQ.js.map +1 -0
- package/dist/chunk-OPYQ5KIO.js +52 -0
- package/dist/chunk-OPYQ5KIO.js.map +1 -0
- package/dist/chunk-OYV2DN66.js +50 -0
- package/dist/chunk-OYV2DN66.js.map +1 -0
- package/dist/chunk-OZAEWZZ3.js +31 -0
- package/dist/chunk-OZAEWZZ3.js.map +1 -0
- package/dist/chunk-PBBG7VFT.js +1896 -0
- package/dist/chunk-PBBG7VFT.js.map +1 -0
- package/dist/{chunk-HXWGG4K7.js → chunk-PJBQKMCD.js} +10 -20
- package/dist/chunk-PJBQKMCD.js.map +1 -0
- package/dist/chunk-Q2IAILVC.js +26 -0
- package/dist/chunk-Q2IAILVC.js.map +1 -0
- package/dist/chunk-Q6CDMOM6.js +57 -0
- package/dist/chunk-Q6CDMOM6.js.map +1 -0
- package/dist/{chunk-ALAMUIGJ.js → chunk-QGRDPSAH.js} +17 -12
- package/dist/chunk-QGRDPSAH.js.map +1 -0
- package/dist/{chunk-7QXJ4KWQ.js → chunk-RLGWMJD3.js} +63 -9
- package/dist/chunk-RLGWMJD3.js.map +1 -0
- package/dist/chunk-RO5IQEDQ.js +30 -0
- package/dist/chunk-RO5IQEDQ.js.map +1 -0
- package/dist/{chunk-ZC4KNEOQ.js → chunk-RQK5UPMP.js} +16 -11
- package/dist/chunk-RQK5UPMP.js.map +1 -0
- package/dist/chunk-RQYEEA2O.js +50 -0
- package/dist/chunk-RQYEEA2O.js.map +1 -0
- package/dist/chunk-SFUCUARB.js +21 -0
- package/dist/chunk-SFUCUARB.js.map +1 -0
- package/dist/{chunk-MVE5VVMQ.js → chunk-TRTUHCS4.js} +5 -8
- package/dist/chunk-TRTUHCS4.js.map +1 -0
- package/dist/chunk-TWGVQLG2.js +24 -0
- package/dist/chunk-TWGVQLG2.js.map +1 -0
- package/dist/chunk-UGK4TAVK.js +32 -0
- package/dist/chunk-UGK4TAVK.js.map +1 -0
- package/dist/{chunk-LPMPTQYP.js → chunk-UT2OPSN4.js} +12 -10
- package/dist/chunk-UT2OPSN4.js.map +1 -0
- package/dist/chunk-VGLHY6BK.js +31 -0
- package/dist/chunk-VGLHY6BK.js.map +1 -0
- package/dist/chunk-W7FLHT65.js +26 -0
- package/dist/chunk-W7FLHT65.js.map +1 -0
- package/dist/chunk-WL7HS7EM.js +50 -0
- package/dist/chunk-WL7HS7EM.js.map +1 -0
- package/dist/chunk-WSGEIVY3.js +1766 -0
- package/dist/chunk-WSGEIVY3.js.map +1 -0
- package/dist/{chunk-H3JR7MN3.js → chunk-XGJ2QERC.js} +17 -10
- package/dist/chunk-XGJ2QERC.js.map +1 -0
- package/dist/chunk-XHCBHYN4.js +54 -0
- package/dist/chunk-XHCBHYN4.js.map +1 -0
- package/dist/chunk-XLQI4IT2.js +54 -0
- package/dist/chunk-XLQI4IT2.js.map +1 -0
- package/dist/{chunk-3PBSL7BS.js → chunk-XRU5WXZX.js} +5 -8
- package/dist/chunk-XRU5WXZX.js.map +1 -0
- package/dist/{chunk-UZZD4MRJ.js → chunk-YAVGCQUP.js} +5 -8
- package/dist/chunk-YAVGCQUP.js.map +1 -0
- package/dist/chunk-YGZMVNN5.js +54 -0
- package/dist/chunk-YGZMVNN5.js.map +1 -0
- package/dist/{chunk-PEZYBKZH.js → chunk-YPT4JBUY.js} +10 -24
- package/dist/chunk-YPT4JBUY.js.map +1 -0
- package/dist/chunk-YUK3X3B4.js +27 -0
- package/dist/chunk-YUK3X3B4.js.map +1 -0
- package/dist/chunk-ZNWVJ6UW.js +54 -0
- package/dist/chunk-ZNWVJ6UW.js.map +1 -0
- package/dist/config-34LHOGLM.js +13 -0
- package/dist/config-3BBWD5AB.js +11 -0
- package/dist/{config-FNR6LJ5H.js → config-3IVQJBNW.js} +4 -2
- package/dist/config-4UDVSUQJ.js +11 -0
- package/dist/config-CMDBAPDH.js +11 -0
- package/dist/config-CVZ2AGCO.js +21 -0
- package/dist/config-D3RLSPNF.js +11 -0
- package/dist/config-DG65OEG3.js +11 -0
- package/dist/{config-HNSDNQZH.js → config-EIHSP5DZ.js} +4 -2
- package/dist/config-EO23EY62.js +15 -0
- package/dist/config-GCQK6NJY.js +11 -0
- package/dist/{config-5ZPGISS6.js → config-GE4W4ZJC.js} +4 -2
- package/dist/config-GHRUKEQ6.js +13 -0
- package/dist/config-GVH27UPE.js +11 -0
- package/dist/config-HKRMKD76.js +15 -0
- package/dist/config-HXVYIXP5.js +11 -0
- package/dist/config-IDZMEW73.js +11 -0
- package/dist/config-IJJXGLBQ.js +11 -0
- package/dist/config-IVY5EQQ2.js +15 -0
- package/dist/config-KJOLGVB2.js +11 -0
- package/dist/{config-S47UDVRZ.js → config-KMVCVBYN.js} +4 -2
- package/dist/{config-UKZ72IDO.js → config-KYTRXAB2.js} +4 -2
- package/dist/{config-MOLWOSRG.js → config-LHFFXVYI.js} +4 -2
- package/dist/config-NV5WXP64.js +11 -0
- package/dist/config-OT2TQQCN.js +11 -0
- package/dist/config-Q45Y46YT.js +15 -0
- package/dist/config-QAA646XB.js +15 -0
- package/dist/config-QNMKWJ4M.js +15 -0
- package/dist/config-QWCY3LBQ.js +11 -0
- package/dist/{config-HIZHA5VD.js → config-VM526IKB.js} +4 -2
- package/dist/config-WDAZFXYD.js +15 -0
- package/dist/config-ZFJYQZCH.js +13 -0
- package/dist/config-ZV6G2ZEC.js +11 -0
- package/dist/databricks_volume-HNQ4DJVJ.js +7 -0
- package/dist/digitalocean-6SPR4S7V.js +10 -0
- package/dist/discord-SAV2RBJV.js +8 -0
- package/dist/{disk-C7TJNU2B.js → disk-POACMF4G.js} +2 -2
- package/dist/dropbox-CQ7MTYX2.js +8 -0
- package/dist/email-KBQ7CXS7.js +8 -0
- package/dist/gcs-SMIE4VMT.js +10 -0
- package/dist/gdocs-X5Y2SIQX.js +8 -0
- package/dist/gdrive-SIQPRIGI.js +8 -0
- package/dist/github-KBHWANKQ.js +8 -0
- package/dist/github-KBHWANKQ.js.map +1 -0
- package/dist/github_ci-HPITNK37.js +8 -0
- package/dist/github_ci-HPITNK37.js.map +1 -0
- package/dist/gmail-DKHAGJNX.js +8 -0
- package/dist/gmail-DKHAGJNX.js.map +1 -0
- package/dist/gsheets-ZSUDIWGK.js +8 -0
- package/dist/gsheets-ZSUDIWGK.js.map +1 -0
- package/dist/gslides-GYXM7IMJ.js +8 -0
- package/dist/gslides-GYXM7IMJ.js.map +1 -0
- package/dist/hf_buckets-RIOMV7WG.js +10 -0
- package/dist/hf_buckets-RIOMV7WG.js.map +1 -0
- package/dist/hf_datasets-QF4BQ3OK.js +10 -0
- package/dist/hf_datasets-QF4BQ3OK.js.map +1 -0
- package/dist/hf_models-62GC2HPZ.js +10 -0
- package/dist/hf_models-62GC2HPZ.js.map +1 -0
- package/dist/hf_spaces-NVSMUNRM.js +10 -0
- package/dist/hf_spaces-NVSMUNRM.js.map +1 -0
- package/dist/index.d.ts +722 -277
- package/dist/index.js +646 -2268
- package/dist/index.js.map +1 -1
- package/dist/langfuse-HUAYVPHF.js +8 -0
- package/dist/langfuse-HUAYVPHF.js.map +1 -0
- package/dist/linear-2MM55KBC.js +8 -0
- package/dist/linear-2MM55KBC.js.map +1 -0
- package/dist/minio-L3XE6PQS.js +10 -0
- package/dist/minio-L3XE6PQS.js.map +1 -0
- package/dist/mongodb-ZOX4FRHJ.js +7 -0
- package/dist/mongodb-ZOX4FRHJ.js.map +1 -0
- package/dist/notion-UK4GTMT4.js +8 -0
- package/dist/notion-UK4GTMT4.js.map +1 -0
- package/dist/oci-NURLWPL2.js +10 -0
- package/dist/oci-NURLWPL2.js.map +1 -0
- package/dist/postgres-JNFMPAO2.js +7 -0
- package/dist/postgres-JNFMPAO2.js.map +1 -0
- package/dist/qingstor-W55D5YFO.js +10 -0
- package/dist/qingstor-W55D5YFO.js.map +1 -0
- package/dist/r2-FSZK7IFI.js +10 -0
- package/dist/r2-FSZK7IFI.js.map +1 -0
- package/dist/redis-S6GIPA4Z.js +8 -0
- package/dist/redis-S6GIPA4Z.js.map +1 -0
- package/dist/s3-GMPUJ65D.js +8 -0
- package/dist/s3-GMPUJ65D.js.map +1 -0
- package/dist/scaleway-5VM55Y6D.js +10 -0
- package/dist/scaleway-5VM55Y6D.js.map +1 -0
- package/dist/seaweedfs-J3EPUEPE.js +10 -0
- package/dist/seaweedfs-J3EPUEPE.js.map +1 -0
- package/dist/slack-FVBXY7KD.js +8 -0
- package/dist/slack-FVBXY7KD.js.map +1 -0
- package/dist/ssh-GCXETJ3Z.js +9 -0
- package/dist/ssh-GCXETJ3Z.js.map +1 -0
- package/dist/supabase-HLWNHBBE.js +10 -0
- package/dist/supabase-HLWNHBBE.js.map +1 -0
- package/dist/tencent-YDO73XBD.js +10 -0
- package/dist/tencent-YDO73XBD.js.map +1 -0
- package/dist/trello-CQ53BQUL.js +8 -0
- package/dist/trello-CQ53BQUL.js.map +1 -0
- package/dist/wasabi-SOZKPMRQ.js +10 -0
- package/dist/wasabi-SOZKPMRQ.js.map +1 -0
- package/package.json +39 -13
- package/dist/box-4P7DCJH7.js +0 -8
- package/dist/chunk-35PVZRWU.js +0 -24
- package/dist/chunk-35PVZRWU.js.map +0 -1
- package/dist/chunk-3PBSL7BS.js.map +0 -1
- package/dist/chunk-3Y625AUP.js +0 -24
- package/dist/chunk-3Y625AUP.js.map +0 -1
- package/dist/chunk-5E6BULAK.js.map +0 -1
- package/dist/chunk-5ITBZN55.js +0 -24
- package/dist/chunk-5ITBZN55.js.map +0 -1
- package/dist/chunk-6M2NL363.js.map +0 -1
- package/dist/chunk-6M3QVVOH.js +0 -32
- package/dist/chunk-6M3QVVOH.js.map +0 -1
- package/dist/chunk-6VKNSO6U.js.map +0 -1
- package/dist/chunk-6Y6GWMFF.js +0 -24
- package/dist/chunk-6Y6GWMFF.js.map +0 -1
- package/dist/chunk-7QXJ4KWQ.js.map +0 -1
- package/dist/chunk-ALAMUIGJ.js.map +0 -1
- package/dist/chunk-DCJQ2PIX.js.map +0 -1
- package/dist/chunk-EKPH4MMD.js +0 -27
- package/dist/chunk-EKPH4MMD.js.map +0 -1
- package/dist/chunk-FZ2GJ4BJ.js +0 -29
- package/dist/chunk-FZ2GJ4BJ.js.map +0 -1
- package/dist/chunk-G7O6DAWU.js.map +0 -1
- package/dist/chunk-GCB4JUF7.js.map +0 -1
- package/dist/chunk-GKQNMLQU.js +0 -7757
- package/dist/chunk-GKQNMLQU.js.map +0 -1
- package/dist/chunk-GO67AOYK.js +0 -24
- package/dist/chunk-GO67AOYK.js.map +0 -1
- package/dist/chunk-GPF66TH2.js +0 -24
- package/dist/chunk-GPF66TH2.js.map +0 -1
- package/dist/chunk-H3JR7MN3.js.map +0 -1
- package/dist/chunk-H74QYTN7.js.map +0 -1
- package/dist/chunk-HEQL3LPK.js.map +0 -1
- package/dist/chunk-HXWGG4K7.js.map +0 -1
- package/dist/chunk-I4RRGZGB.js +0 -24
- package/dist/chunk-I4RRGZGB.js.map +0 -1
- package/dist/chunk-ICSS5ETT.js.map +0 -1
- package/dist/chunk-KINMBZHC.js +0 -18
- package/dist/chunk-KINMBZHC.js.map +0 -1
- package/dist/chunk-LBBM3LKK.js.map +0 -1
- package/dist/chunk-LPMPTQYP.js.map +0 -1
- package/dist/chunk-M42JTWPR.js +0 -2794
- package/dist/chunk-M42JTWPR.js.map +0 -1
- package/dist/chunk-MVE5VVMQ.js.map +0 -1
- package/dist/chunk-MY3NUJJD.js.map +0 -1
- package/dist/chunk-NOZZFJEB.js.map +0 -1
- package/dist/chunk-OYJXYJTE.js.map +0 -1
- package/dist/chunk-PEZYBKZH.js.map +0 -1
- package/dist/chunk-QWWOBAYU.js +0 -26
- package/dist/chunk-QWWOBAYU.js.map +0 -1
- package/dist/chunk-RQYYYBQG.js +0 -24
- package/dist/chunk-RQYYYBQG.js.map +0 -1
- package/dist/chunk-T2WWAEKH.js +0 -7591
- package/dist/chunk-T2WWAEKH.js.map +0 -1
- package/dist/chunk-UWMOTOXA.js.map +0 -1
- package/dist/chunk-UZZD4MRJ.js.map +0 -1
- package/dist/chunk-V5OLWE7F.js.map +0 -1
- package/dist/chunk-VCLMTMSO.js +0 -23
- package/dist/chunk-VCLMTMSO.js.map +0 -1
- package/dist/chunk-WSDQ2MRG.js.map +0 -1
- package/dist/chunk-XDEEOTVK.js.map +0 -1
- package/dist/chunk-XQUQSNCA.js.map +0 -1
- package/dist/chunk-XVYZO2FG.js +0 -14
- package/dist/chunk-XVYZO2FG.js.map +0 -1
- package/dist/chunk-ZC4KNEOQ.js.map +0 -1
- package/dist/config-6HWSKHEU.js +0 -9
- package/dist/config-6TNFPYZF.js +0 -9
- package/dist/config-BHLXQ3OL.js +0 -9
- package/dist/config-E7UOEWEP.js +0 -9
- package/dist/config-IXLFUSMQ.js +0 -9
- package/dist/config-J3TM7NIS.js +0 -9
- package/dist/config-JXLZ4XEW.js +0 -9
- package/dist/config-KQCEMLNZ.js +0 -9
- package/dist/config-R3XJ5OW4.js +0 -9
- package/dist/config-V7XI5UTG.js +0 -9
- package/dist/config-YLIX3ZBT.js +0 -9
- package/dist/config-Z5JGDOKE.js +0 -9
- package/dist/config-ZCZZAH5W.js +0 -9
- package/dist/config-ZZGIWDUC.js +0 -9
- package/dist/discord-2PWP2MGX.js +0 -8
- package/dist/dropbox-L5DPYGKR.js +0 -8
- package/dist/email-HASRFBKC.js +0 -8
- package/dist/gcs-P5QMKTPR.js +0 -10
- package/dist/gdocs-IF2I35HZ.js +0 -8
- package/dist/gdrive-TAETVCKP.js +0 -8
- package/dist/github-5E6GSCNZ.js +0 -8
- package/dist/github_ci-2DSZI3Y7.js +0 -8
- package/dist/gmail-F5VYGKOT.js +0 -8
- package/dist/gsheets-BAO54CQ7.js +0 -8
- package/dist/gslides-A62CEEMR.js +0 -8
- package/dist/langfuse-YKBYRQLU.js +0 -8
- package/dist/linear-WJDQ6JDE.js +0 -8
- package/dist/mongodb-MK4DVSIK.js +0 -7
- package/dist/oci-KZ7XFZ2X.js +0 -10
- package/dist/postgres-M2N2APFZ.js +0 -7
- package/dist/r2-X4DDNSAZ.js +0 -10
- package/dist/redis-NVCXUUIO.js +0 -7
- package/dist/s3-HVAL7ZX3.js +0 -8
- package/dist/slack-GUQMDGLP.js +0 -8
- package/dist/ssh-LY6WYVVD.js +0 -9
- package/dist/supabase-H3ZP4Y3W.js +0 -10
- package/dist/trello-WR6TEDYD.js +0 -8
- /package/dist/{box-4P7DCJH7.js.map → aliyun-TMZRUYCG.js.map} +0 -0
- /package/dist/{config-5ZPGISS6.js.map → backblaze-OHW57DLK.js.map} +0 -0
- /package/dist/{config-6HWSKHEU.js.map → box-UXTCAFOZ.js.map} +0 -0
- /package/dist/{config-6TNFPYZF.js.map → ceph-TNN4I2FT.js.map} +0 -0
- /package/dist/{config-BHLXQ3OL.js.map → config-34LHOGLM.js.map} +0 -0
- /package/dist/{config-E7UOEWEP.js.map → config-3BBWD5AB.js.map} +0 -0
- /package/dist/{config-FNR6LJ5H.js.map → config-3IVQJBNW.js.map} +0 -0
- /package/dist/{config-HIZHA5VD.js.map → config-4UDVSUQJ.js.map} +0 -0
- /package/dist/{config-HNSDNQZH.js.map → config-CMDBAPDH.js.map} +0 -0
- /package/dist/{config-IXLFUSMQ.js.map → config-CVZ2AGCO.js.map} +0 -0
- /package/dist/{config-J3TM7NIS.js.map → config-D3RLSPNF.js.map} +0 -0
- /package/dist/{config-JXLZ4XEW.js.map → config-DG65OEG3.js.map} +0 -0
- /package/dist/{config-KQCEMLNZ.js.map → config-EIHSP5DZ.js.map} +0 -0
- /package/dist/{config-MOLWOSRG.js.map → config-EO23EY62.js.map} +0 -0
- /package/dist/{config-R3XJ5OW4.js.map → config-GCQK6NJY.js.map} +0 -0
- /package/dist/{config-S47UDVRZ.js.map → config-GE4W4ZJC.js.map} +0 -0
- /package/dist/{config-UKZ72IDO.js.map → config-GHRUKEQ6.js.map} +0 -0
- /package/dist/{config-V7XI5UTG.js.map → config-GVH27UPE.js.map} +0 -0
- /package/dist/{config-YLIX3ZBT.js.map → config-HKRMKD76.js.map} +0 -0
- /package/dist/{config-Z5JGDOKE.js.map → config-HXVYIXP5.js.map} +0 -0
- /package/dist/{config-ZCZZAH5W.js.map → config-IDZMEW73.js.map} +0 -0
- /package/dist/{config-ZZGIWDUC.js.map → config-IJJXGLBQ.js.map} +0 -0
- /package/dist/{discord-2PWP2MGX.js.map → config-IVY5EQQ2.js.map} +0 -0
- /package/dist/{disk-C7TJNU2B.js.map → config-KJOLGVB2.js.map} +0 -0
- /package/dist/{dropbox-L5DPYGKR.js.map → config-KMVCVBYN.js.map} +0 -0
- /package/dist/{email-HASRFBKC.js.map → config-KYTRXAB2.js.map} +0 -0
- /package/dist/{gcs-P5QMKTPR.js.map → config-LHFFXVYI.js.map} +0 -0
- /package/dist/{gdocs-IF2I35HZ.js.map → config-NV5WXP64.js.map} +0 -0
- /package/dist/{gdrive-TAETVCKP.js.map → config-OT2TQQCN.js.map} +0 -0
- /package/dist/{github-5E6GSCNZ.js.map → config-Q45Y46YT.js.map} +0 -0
- /package/dist/{github_ci-2DSZI3Y7.js.map → config-QAA646XB.js.map} +0 -0
- /package/dist/{gmail-F5VYGKOT.js.map → config-QNMKWJ4M.js.map} +0 -0
- /package/dist/{gsheets-BAO54CQ7.js.map → config-QWCY3LBQ.js.map} +0 -0
- /package/dist/{gslides-A62CEEMR.js.map → config-VM526IKB.js.map} +0 -0
- /package/dist/{langfuse-YKBYRQLU.js.map → config-WDAZFXYD.js.map} +0 -0
- /package/dist/{linear-WJDQ6JDE.js.map → config-ZFJYQZCH.js.map} +0 -0
- /package/dist/{mongodb-MK4DVSIK.js.map → config-ZV6G2ZEC.js.map} +0 -0
- /package/dist/{oci-KZ7XFZ2X.js.map → databricks_volume-HNQ4DJVJ.js.map} +0 -0
- /package/dist/{postgres-M2N2APFZ.js.map → digitalocean-6SPR4S7V.js.map} +0 -0
- /package/dist/{r2-X4DDNSAZ.js.map → discord-SAV2RBJV.js.map} +0 -0
- /package/dist/{redis-NVCXUUIO.js.map → disk-POACMF4G.js.map} +0 -0
- /package/dist/{s3-HVAL7ZX3.js.map → dropbox-CQ7MTYX2.js.map} +0 -0
- /package/dist/{slack-GUQMDGLP.js.map → email-KBQ7CXS7.js.map} +0 -0
- /package/dist/{ssh-LY6WYVVD.js.map → gcs-SMIE4VMT.js.map} +0 -0
- /package/dist/{supabase-H3ZP4Y3W.js.map → gdocs-X5Y2SIQX.js.map} +0 -0
- /package/dist/{trello-WR6TEDYD.js.map → gdrive-SIQPRIGI.js.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
redactEmailConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-B2ZOKNN4.js";
|
|
4
4
|
|
|
5
5
|
// src/resource/email/email.ts
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
BaseResource,
|
|
8
|
+
PathSpec as PathSpec4,
|
|
9
9
|
ResourceName as ResourceName25
|
|
10
10
|
} from "@struktoai/mirage-core";
|
|
11
11
|
|
|
@@ -34,7 +34,12 @@ var EmailAccessor = class extends Accessor {
|
|
|
34
34
|
await client.connect();
|
|
35
35
|
return client;
|
|
36
36
|
})();
|
|
37
|
-
|
|
37
|
+
try {
|
|
38
|
+
return await this.clientPromise;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
this.clientPromise = null;
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
38
43
|
}
|
|
39
44
|
async close() {
|
|
40
45
|
if (this.clientPromise === null) return;
|
|
@@ -48,46 +53,27 @@ var EmailAccessor = class extends Accessor {
|
|
|
48
53
|
};
|
|
49
54
|
|
|
50
55
|
// src/commands/builtin/email/basename.ts
|
|
51
|
-
import {
|
|
52
|
-
IOResult,
|
|
53
|
-
ResourceName,
|
|
54
|
-
command,
|
|
55
|
-
specOf
|
|
56
|
-
} from "@struktoai/mirage-core";
|
|
57
|
-
var ENC = new TextEncoder();
|
|
58
|
-
function basenameOf(p) {
|
|
59
|
-
const trimmed = p.replace(/\/+$/, "");
|
|
60
|
-
const idx = trimmed.lastIndexOf("/");
|
|
61
|
-
return idx === -1 ? trimmed : trimmed.slice(idx + 1);
|
|
62
|
-
}
|
|
63
|
-
function basenameCommand(_accessor, _paths, texts, _opts) {
|
|
64
|
-
const lines = texts.map((t) => basenameOf(t));
|
|
65
|
-
const out = ENC.encode(lines.join("\n") + "\n");
|
|
66
|
-
return [out, new IOResult()];
|
|
67
|
-
}
|
|
56
|
+
import { ResourceName, command, specOf, basenameFn } from "@struktoai/mirage-core";
|
|
68
57
|
var EMAIL_BASENAME = command({
|
|
69
58
|
name: "basename",
|
|
70
59
|
resource: ResourceName.EMAIL,
|
|
71
60
|
spec: specOf("basename"),
|
|
72
|
-
fn:
|
|
61
|
+
fn: basenameFn
|
|
73
62
|
});
|
|
74
63
|
|
|
75
64
|
// src/commands/builtin/email/cat.ts
|
|
76
65
|
import {
|
|
77
|
-
AsyncLineIterator,
|
|
78
|
-
IOResult as IOResult2,
|
|
79
66
|
ResourceName as ResourceName2,
|
|
67
|
+
catGeneric,
|
|
80
68
|
command as command2,
|
|
81
|
-
|
|
82
|
-
specOf as specOf2,
|
|
83
|
-
wrapBytes
|
|
69
|
+
specOf as specOf2
|
|
84
70
|
} from "@struktoai/mirage-core";
|
|
85
71
|
|
|
86
72
|
// src/core/email/glob.ts
|
|
87
|
-
import { PathSpec as PathSpecCtor2 } from "@struktoai/mirage-core";
|
|
73
|
+
import { PathSpec as PathSpecCtor2, rstripSlash } from "@struktoai/mirage-core";
|
|
88
74
|
|
|
89
75
|
// src/core/email/readdir.ts
|
|
90
|
-
import { IndexEntry, PathSpec as PathSpecCtor } from "@struktoai/mirage-core";
|
|
76
|
+
import { IndexEntry, PathSpec as PathSpecCtor, stripSlash } from "@struktoai/mirage-core";
|
|
91
77
|
|
|
92
78
|
// src/core/email/_parse.ts
|
|
93
79
|
import { loadOptionalPeer as loadOptionalPeer2 } from "@struktoai/mirage-core";
|
|
@@ -157,7 +143,7 @@ async function parseWithPayloads(raw) {
|
|
|
157
143
|
async function listFolders(accessor) {
|
|
158
144
|
const imap = await accessor.getImap();
|
|
159
145
|
const tree = await imap.list();
|
|
160
|
-
return tree.map((m) => m.
|
|
146
|
+
return tree.map((m) => m.pathAsListed);
|
|
161
147
|
}
|
|
162
148
|
async function listMessageUids(accessor, folder, searchCriteria = "ALL", maxResults = null) {
|
|
163
149
|
const imap = await accessor.getImap();
|
|
@@ -351,7 +337,7 @@ async function readdir(accessor, path, index) {
|
|
|
351
337
|
const raw = path.pattern !== null ? path.directory : path.original;
|
|
352
338
|
let p = raw;
|
|
353
339
|
if (prefix !== "" && p.startsWith(prefix)) p = p.slice(prefix.length) || "/";
|
|
354
|
-
const key = p
|
|
340
|
+
const key = stripSlash(p);
|
|
355
341
|
const virtualKey = key !== "" ? `${prefix}/${key}` : prefix !== "" ? prefix : "/";
|
|
356
342
|
const parts = key === "" ? [] : key.split("/");
|
|
357
343
|
const depth = parts.length;
|
|
@@ -462,11 +448,8 @@ async function readdir(accessor, path, index) {
|
|
|
462
448
|
}
|
|
463
449
|
|
|
464
450
|
// src/core/email/glob.ts
|
|
451
|
+
import { fnmatch } from "@struktoai/mirage-core";
|
|
465
452
|
var SCOPE_ERROR = 1e3;
|
|
466
|
-
function fnmatch(name, pattern) {
|
|
467
|
-
const re = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\?/g, ".").replace(/\*/g, ".*");
|
|
468
|
-
return new RegExp(`^${re}$`).test(name);
|
|
469
|
-
}
|
|
470
453
|
async function resolveGlob(accessor, paths, index) {
|
|
471
454
|
const result = [];
|
|
472
455
|
for (const p of paths) {
|
|
@@ -478,7 +461,7 @@ async function resolveGlob(accessor, paths, index) {
|
|
|
478
461
|
const entries = await readdir(accessor, p, index);
|
|
479
462
|
const matched = [];
|
|
480
463
|
for (const entry of entries) {
|
|
481
|
-
const trimmed = entry
|
|
464
|
+
const trimmed = rstripSlash(entry);
|
|
482
465
|
const base = trimmed.split("/").pop() ?? trimmed;
|
|
483
466
|
if (!fnmatch(base, p.pattern)) continue;
|
|
484
467
|
matched.push(PathSpecCtor2.fromStrPath(trimmed, p.prefix));
|
|
@@ -493,7 +476,8 @@ async function resolveGlob(accessor, paths, index) {
|
|
|
493
476
|
}
|
|
494
477
|
|
|
495
478
|
// src/core/email/read.ts
|
|
496
|
-
|
|
479
|
+
import { gnuDirname, stripSlash as stripSlash2 } from "@struktoai/mirage-core";
|
|
480
|
+
var ENC = new TextEncoder();
|
|
497
481
|
function enoent2(p) {
|
|
498
482
|
const e = new Error(`ENOENT: ${p}`);
|
|
499
483
|
e.code = "ENOENT";
|
|
@@ -504,17 +488,11 @@ function eisdir(p) {
|
|
|
504
488
|
e.code = "EISDIR";
|
|
505
489
|
return e;
|
|
506
490
|
}
|
|
507
|
-
function dirname(p) {
|
|
508
|
-
const norm = p.replace(/\/+$/, "");
|
|
509
|
-
const idx = norm.lastIndexOf("/");
|
|
510
|
-
if (idx <= 0) return "/";
|
|
511
|
-
return norm.slice(0, idx);
|
|
512
|
-
}
|
|
513
491
|
async function read(accessor, path, index) {
|
|
514
492
|
const prefix = path.prefix;
|
|
515
493
|
let p = path.original;
|
|
516
494
|
if (prefix !== "" && p.startsWith(prefix)) p = p.slice(prefix.length) || "/";
|
|
517
|
-
const key = p
|
|
495
|
+
const key = stripSlash2(p);
|
|
518
496
|
if (index === void 0) throw enoent2(path.original);
|
|
519
497
|
const virtualKey = prefix !== "" ? `${prefix}/${key}` : `/${key}`;
|
|
520
498
|
const result = await index.get(virtualKey);
|
|
@@ -524,24 +502,93 @@ async function read(accessor, path, index) {
|
|
|
524
502
|
throw eisdir(path.original);
|
|
525
503
|
}
|
|
526
504
|
if (rt === "email/attachment") {
|
|
527
|
-
const parentKey =
|
|
505
|
+
const parentKey = gnuDirname(virtualKey);
|
|
528
506
|
const parentResult = await index.get(parentKey);
|
|
529
507
|
if (parentResult.entry === void 0 || parentResult.entry === null) {
|
|
530
508
|
throw enoent2(path.original);
|
|
531
509
|
}
|
|
532
510
|
const uid2 = parentResult.entry.id;
|
|
533
|
-
const parts2 = virtualKey
|
|
511
|
+
const parts2 = stripSlash2(virtualKey).split("/");
|
|
534
512
|
const folder2 = prefix !== "" ? parts2[1] ?? "" : parts2[0] ?? "";
|
|
535
513
|
const filename = result.entry.vfsName !== "" ? result.entry.vfsName : result.entry.name;
|
|
536
514
|
const data = await fetchAttachment(accessor, folder2, uid2, filename);
|
|
537
515
|
if (data === null) throw enoent2(path.original);
|
|
538
516
|
return data;
|
|
539
517
|
}
|
|
540
|
-
const parts = virtualKey
|
|
518
|
+
const parts = stripSlash2(virtualKey).split("/");
|
|
541
519
|
const folder = prefix !== "" ? parts[1] ?? "" : parts[0] ?? "";
|
|
542
520
|
const uid = result.entry.id;
|
|
543
521
|
const msg = await fetchMessage(accessor, folder, uid);
|
|
544
|
-
return
|
|
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 } });
|
|
545
592
|
}
|
|
546
593
|
|
|
547
594
|
// src/commands/builtin/email/provision.ts
|
|
@@ -576,37 +623,18 @@ function metadataProvision(_accessor, _paths, _texts, _opts) {
|
|
|
576
623
|
}
|
|
577
624
|
|
|
578
625
|
// src/commands/builtin/email/cat.ts
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
const nFlag = opts.flags.n === true;
|
|
592
|
-
if (paths.length > 0) {
|
|
593
|
-
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
594
|
-
const first = resolved[0];
|
|
595
|
-
if (first === void 0) return [null, new IOResult2()];
|
|
596
|
-
const data = await read(accessor, first, opts.index ?? void 0);
|
|
597
|
-
const io = new IOResult2({ reads: { [first.stripPrefix]: data }, cache: [first.stripPrefix] });
|
|
598
|
-
if (nFlag) return [numberLinesStream(wrapBytes(data)), io];
|
|
599
|
-
return [data, io];
|
|
600
|
-
}
|
|
601
|
-
try {
|
|
602
|
-
const source = resolveSource(opts.stdin, "cat: missing operand");
|
|
603
|
-
if (nFlag) return [numberLinesStream(source), new IOResult2()];
|
|
604
|
-
return [source, new IOResult2()];
|
|
605
|
-
} catch (err) {
|
|
606
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
607
|
-
return [null, new IOResult2({ exitCode: 1, stderr: ENC3.encode(`${msg}
|
|
608
|
-
`) })];
|
|
609
|
-
}
|
|
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
|
+
);
|
|
610
638
|
}
|
|
611
639
|
var EMAIL_CAT = command2({
|
|
612
640
|
name: "cat",
|
|
@@ -617,45 +645,27 @@ var EMAIL_CAT = command2({
|
|
|
617
645
|
});
|
|
618
646
|
|
|
619
647
|
// src/commands/builtin/email/dirname.ts
|
|
620
|
-
import {
|
|
621
|
-
IOResult as IOResult3,
|
|
622
|
-
ResourceName as ResourceName3,
|
|
623
|
-
command as command3,
|
|
624
|
-
specOf as specOf3
|
|
625
|
-
} from "@struktoai/mirage-core";
|
|
626
|
-
var ENC4 = new TextEncoder();
|
|
627
|
-
function dirnameOf(p) {
|
|
628
|
-
const trimmed = p.replace(/\/+$/, "");
|
|
629
|
-
const idx = trimmed.lastIndexOf("/");
|
|
630
|
-
if (idx === -1) return ".";
|
|
631
|
-
if (idx === 0) return "/";
|
|
632
|
-
return trimmed.slice(0, idx);
|
|
633
|
-
}
|
|
634
|
-
function dirnameCommand(_accessor, _paths, texts, _opts) {
|
|
635
|
-
const lines = texts.map((t) => dirnameOf(t));
|
|
636
|
-
const out = ENC4.encode(lines.join("\n") + "\n");
|
|
637
|
-
return [out, new IOResult3()];
|
|
638
|
-
}
|
|
648
|
+
import { ResourceName as ResourceName3, command as command3, specOf as specOf3, dirnameFn } from "@struktoai/mirage-core";
|
|
639
649
|
var EMAIL_DIRNAME = command3({
|
|
640
650
|
name: "dirname",
|
|
641
651
|
resource: ResourceName3.EMAIL,
|
|
642
652
|
spec: specOf3("dirname"),
|
|
643
|
-
fn:
|
|
653
|
+
fn: dirnameFn
|
|
644
654
|
});
|
|
645
655
|
|
|
646
656
|
// src/commands/builtin/email/find.ts
|
|
647
657
|
import {
|
|
648
|
-
IOResult
|
|
658
|
+
IOResult,
|
|
649
659
|
PathSpec,
|
|
650
660
|
ResourceName as ResourceName4,
|
|
651
661
|
command as command4,
|
|
652
|
-
specOf as specOf4
|
|
662
|
+
specOf as specOf4,
|
|
663
|
+
rstripSlash as rstripSlash2,
|
|
664
|
+
stripSlash as stripSlash4,
|
|
665
|
+
formatRecords
|
|
653
666
|
} from "@struktoai/mirage-core";
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
const re = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\?/g, ".").replace(/\*/g, ".*");
|
|
657
|
-
return new RegExp(`^${re}$`).test(name);
|
|
658
|
-
}
|
|
667
|
+
import { fnmatch as fnmatch2 } from "@struktoai/mirage-core";
|
|
668
|
+
import { findSizeMtimeError, invalidFindArg } from "@struktoai/mirage-core";
|
|
659
669
|
async function walk(accessor, path, index, maxDepth, depth) {
|
|
660
670
|
if (maxDepth !== null && depth > maxDepth) return [];
|
|
661
671
|
let children;
|
|
@@ -667,7 +677,7 @@ async function walk(accessor, path, index, maxDepth, depth) {
|
|
|
667
677
|
const results = [];
|
|
668
678
|
for (const child of children) {
|
|
669
679
|
const isFolder = child.endsWith("/");
|
|
670
|
-
const trimmed = isFolder ? child
|
|
680
|
+
const trimmed = isFolder ? rstripSlash2(child) : child;
|
|
671
681
|
results.push(trimmed);
|
|
672
682
|
if (isFolder) {
|
|
673
683
|
const childSpec = new PathSpec({
|
|
@@ -696,13 +706,21 @@ async function findCommand(accessor, paths, _texts, opts) {
|
|
|
696
706
|
const minDepthRaw = typeof opts.flags.mindepth === "string" ? opts.flags.mindepth : null;
|
|
697
707
|
const maxDepth = maxDepthRaw !== null ? Number.parseInt(maxDepthRaw, 10) : null;
|
|
698
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;
|
|
699
717
|
const allPaths = await walk(accessor, p0, opts.index, maxDepth, 0);
|
|
700
|
-
const searchKey = p0.stripPrefix
|
|
718
|
+
const searchKey = stripSlash4(p0.stripPrefix);
|
|
701
719
|
const baseDepth = searchKey === "" ? -1 : searchKey.split("/").length - 1;
|
|
702
720
|
const results = [];
|
|
703
721
|
for (const p of [...allPaths].sort()) {
|
|
704
722
|
const stripped = p.startsWith(p0.prefix) ? p.slice(p0.prefix.length) : p;
|
|
705
|
-
const trimmed = stripped
|
|
723
|
+
const trimmed = stripSlash4(stripped);
|
|
706
724
|
const depth = trimmed === "" ? -1 : trimmed.split("/").length - (baseDepth + 2);
|
|
707
725
|
if (minDepth !== null && depth < minDepth) continue;
|
|
708
726
|
const entryName = p.split("/").pop() ?? p;
|
|
@@ -710,8 +728,8 @@ async function findCommand(accessor, paths, _texts, opts) {
|
|
|
710
728
|
if (inameFlag !== null && !fnmatch2(entryName.toLowerCase(), inameFlag.toLowerCase())) continue;
|
|
711
729
|
results.push(p);
|
|
712
730
|
}
|
|
713
|
-
const out =
|
|
714
|
-
return [out, new
|
|
731
|
+
const out = formatRecords(results);
|
|
732
|
+
return [out, new IOResult()];
|
|
715
733
|
}
|
|
716
734
|
var EMAIL_FIND = command4({
|
|
717
735
|
name: "find",
|
|
@@ -724,7 +742,7 @@ var EMAIL_FIND = command4({
|
|
|
724
742
|
// src/commands/builtin/email/email_forward.ts
|
|
725
743
|
import {
|
|
726
744
|
CommandSpec,
|
|
727
|
-
IOResult as
|
|
745
|
+
IOResult as IOResult2,
|
|
728
746
|
OperandKind,
|
|
729
747
|
Option,
|
|
730
748
|
ResourceName as ResourceName5,
|
|
@@ -805,7 +823,7 @@ Subject: ${original.subject}
|
|
|
805
823
|
}
|
|
806
824
|
|
|
807
825
|
// src/commands/builtin/email/email_forward.ts
|
|
808
|
-
var
|
|
826
|
+
var ENC2 = new TextEncoder();
|
|
809
827
|
var SPEC = new CommandSpec({
|
|
810
828
|
options: [
|
|
811
829
|
new Option({ long: "--uid", valueKind: OperandKind.TEXT }),
|
|
@@ -818,18 +836,18 @@ async function emailForwardCommand(accessor, _paths, _texts, opts) {
|
|
|
818
836
|
const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
|
|
819
837
|
const to = typeof opts.flags.to === "string" ? opts.flags.to : "";
|
|
820
838
|
if (uid === "") {
|
|
821
|
-
return [null, new
|
|
839
|
+
return [null, new IOResult2({ exitCode: 2, stderr: ENC2.encode("--uid is required\n") })];
|
|
822
840
|
}
|
|
823
841
|
if (folder === "") {
|
|
824
|
-
return [null, new
|
|
842
|
+
return [null, new IOResult2({ exitCode: 2, stderr: ENC2.encode("--folder is required\n") })];
|
|
825
843
|
}
|
|
826
844
|
if (to === "") {
|
|
827
|
-
return [null, new
|
|
845
|
+
return [null, new IOResult2({ exitCode: 2, stderr: ENC2.encode("--to is required\n") })];
|
|
828
846
|
}
|
|
829
847
|
const original = await fetchMessage(accessor, folder, uid);
|
|
830
848
|
const result = await forwardMessage(accessor.config, original, to);
|
|
831
|
-
const out =
|
|
832
|
-
return [out, new
|
|
849
|
+
const out = ENC2.encode(JSON.stringify(result));
|
|
850
|
+
return [out, new IOResult2()];
|
|
833
851
|
}
|
|
834
852
|
var EMAIL_FORWARD = command5({
|
|
835
853
|
name: "email-forward",
|
|
@@ -841,7 +859,7 @@ var EMAIL_FORWARD = command5({
|
|
|
841
859
|
|
|
842
860
|
// src/commands/builtin/email/grep.ts
|
|
843
861
|
import {
|
|
844
|
-
IOResult as
|
|
862
|
+
IOResult as IOResult3,
|
|
845
863
|
PathSpec as PathSpec2,
|
|
846
864
|
ResourceName as ResourceName6,
|
|
847
865
|
command as command6,
|
|
@@ -852,83 +870,16 @@ import {
|
|
|
852
870
|
grepStream,
|
|
853
871
|
prefixAggregate,
|
|
854
872
|
quietMatch,
|
|
855
|
-
resolveSource
|
|
873
|
+
resolveSource,
|
|
856
874
|
specOf as specOf5,
|
|
857
|
-
yieldBytes
|
|
875
|
+
yieldBytes,
|
|
876
|
+
formatRecords as formatRecords2
|
|
858
877
|
} from "@struktoai/mirage-core";
|
|
859
878
|
|
|
860
|
-
// src/core/email/stat.ts
|
|
861
|
-
import { FileStat, FileType } from "@struktoai/mirage-core";
|
|
862
|
-
function guessType(name) {
|
|
863
|
-
const lower = name.toLowerCase();
|
|
864
|
-
if (lower.endsWith(".json") || lower.endsWith(".email.json")) return FileType.JSON;
|
|
865
|
-
if (lower.endsWith(".csv")) return FileType.CSV;
|
|
866
|
-
if (lower.endsWith(".png")) return FileType.IMAGE_PNG;
|
|
867
|
-
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg")) return FileType.IMAGE_JPEG;
|
|
868
|
-
if (lower.endsWith(".gif")) return FileType.IMAGE_GIF;
|
|
869
|
-
if (lower.endsWith(".zip")) return FileType.ZIP;
|
|
870
|
-
if (lower.endsWith(".gz") || lower.endsWith(".gzip")) return FileType.GZIP;
|
|
871
|
-
if (lower.endsWith(".pdf")) return FileType.PDF;
|
|
872
|
-
if (lower.endsWith(".txt") || lower.endsWith(".md") || lower.endsWith(".log")) {
|
|
873
|
-
return FileType.TEXT;
|
|
874
|
-
}
|
|
875
|
-
return FileType.BINARY;
|
|
876
|
-
}
|
|
877
|
-
function enoent3(p) {
|
|
878
|
-
const e = new Error(`ENOENT: ${p}`);
|
|
879
|
-
e.code = "ENOENT";
|
|
880
|
-
return e;
|
|
881
|
-
}
|
|
882
|
-
async function stat(accessor, path, index) {
|
|
883
|
-
const prefix = path.prefix;
|
|
884
|
-
let p = path.original;
|
|
885
|
-
if (prefix !== "" && p.startsWith(prefix)) p = p.slice(prefix.length) || "/";
|
|
886
|
-
const key = p.replace(/^\/+|\/+$/g, "");
|
|
887
|
-
if (key === "") return new FileStat({ name: "/", type: FileType.DIRECTORY });
|
|
888
|
-
if (index === void 0) throw enoent3(path.original);
|
|
889
|
-
const virtualKey = prefix !== "" ? `${prefix}/${key}` : `/${key}`;
|
|
890
|
-
const result = await index.get(virtualKey);
|
|
891
|
-
if (result.entry === void 0 || result.entry === null) {
|
|
892
|
-
if (!key.includes("/")) {
|
|
893
|
-
const folders = await listFolders2(accessor);
|
|
894
|
-
if (folders.includes(key)) return new FileStat({ name: key, type: FileType.DIRECTORY });
|
|
895
|
-
throw enoent3(path.original);
|
|
896
|
-
}
|
|
897
|
-
throw enoent3(path.original);
|
|
898
|
-
}
|
|
899
|
-
const rt = result.entry.resourceType;
|
|
900
|
-
const vfsName = result.entry.vfsName !== "" ? result.entry.vfsName : result.entry.name;
|
|
901
|
-
if (rt === "email/folder") return new FileStat({ name: vfsName, type: FileType.DIRECTORY });
|
|
902
|
-
if (rt === "email/date") return new FileStat({ name: vfsName, type: FileType.DIRECTORY });
|
|
903
|
-
if (rt === "email/message") {
|
|
904
|
-
return new FileStat({
|
|
905
|
-
name: vfsName,
|
|
906
|
-
type: FileType.JSON,
|
|
907
|
-
size: result.entry.size,
|
|
908
|
-
extra: { uid: result.entry.id }
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
if (rt === "email/attachment_dir") {
|
|
912
|
-
return new FileStat({
|
|
913
|
-
name: vfsName,
|
|
914
|
-
type: FileType.DIRECTORY,
|
|
915
|
-
extra: { uid: result.entry.id }
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
if (rt === "email/attachment") {
|
|
919
|
-
return new FileStat({
|
|
920
|
-
name: vfsName,
|
|
921
|
-
type: guessType(vfsName),
|
|
922
|
-
size: result.entry.size,
|
|
923
|
-
extra: { attachment_id: result.entry.id }
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
return new FileStat({ name: vfsName, type: FileType.JSON, extra: { uid: result.entry.id } });
|
|
927
|
-
}
|
|
928
|
-
|
|
929
879
|
// src/core/email/scope.ts
|
|
880
|
+
import { stripSlash as stripSlash5 } from "@struktoai/mirage-core";
|
|
930
881
|
function detectScope(path) {
|
|
931
|
-
const key = path.stripPrefix
|
|
882
|
+
const key = stripSlash5(path.stripPrefix);
|
|
932
883
|
if (key === "") {
|
|
933
884
|
return { useNative: false, folder: null, resourcePath: "/" };
|
|
934
885
|
}
|
|
@@ -1013,7 +964,7 @@ async function searchAndFormat(accessor, scope, pattern, prefix, maxResults = nu
|
|
|
1013
964
|
}
|
|
1014
965
|
|
|
1015
966
|
// src/commands/builtin/email/grep.ts
|
|
1016
|
-
var
|
|
967
|
+
var ENC3 = new TextEncoder();
|
|
1017
968
|
var DEC = new TextDecoder("utf-8", { fatal: false });
|
|
1018
969
|
function parseFlags(flags) {
|
|
1019
970
|
const toInt = (v) => typeof v === "string" ? Number.parseInt(v, 10) : null;
|
|
@@ -1050,7 +1001,7 @@ async function grepCommand(accessor, paths, texts, opts) {
|
|
|
1050
1001
|
pattern = getPattern(texts, opts.flags);
|
|
1051
1002
|
} catch (err) {
|
|
1052
1003
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1053
|
-
return [null, new
|
|
1004
|
+
return [null, new IOResult3({ exitCode: 2, stderr: ENC3.encode(`${msg}
|
|
1054
1005
|
`) })];
|
|
1055
1006
|
}
|
|
1056
1007
|
const f = parseFlags(opts.flags);
|
|
@@ -1072,13 +1023,13 @@ async function grepCommand(accessor, paths, texts, opts) {
|
|
|
1072
1023
|
);
|
|
1073
1024
|
for (const line of matched) lines.push(`${vfsPath}:${line}`);
|
|
1074
1025
|
}
|
|
1075
|
-
if (lines.length === 0) return [new Uint8Array(0), new
|
|
1076
|
-
const out =
|
|
1077
|
-
return [out, new
|
|
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()];
|
|
1078
1029
|
}
|
|
1079
1030
|
}
|
|
1080
1031
|
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
1081
|
-
if (resolved.length === 0) return [new Uint8Array(0), new
|
|
1032
|
+
if (resolved.length === 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1 })];
|
|
1082
1033
|
const filePrefix = resolved[0]?.prefix ?? "";
|
|
1083
1034
|
const readdirFn = async (path) => {
|
|
1084
1035
|
const spec = new PathSpec2({
|
|
@@ -1110,7 +1061,7 @@ async function grepCommand(accessor, paths, texts, opts) {
|
|
|
1110
1061
|
if (f.filesOnly) {
|
|
1111
1062
|
const warnings = [];
|
|
1112
1063
|
const firstResolved2 = resolved[0];
|
|
1113
|
-
if (firstResolved2 === void 0) return [new Uint8Array(0), new
|
|
1064
|
+
if (firstResolved2 === void 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1 })];
|
|
1114
1065
|
const results = await grepFilesOnly(
|
|
1115
1066
|
readdirFn,
|
|
1116
1067
|
statFn,
|
|
@@ -1130,10 +1081,10 @@ async function grepCommand(accessor, paths, texts, opts) {
|
|
|
1130
1081
|
},
|
|
1131
1082
|
warnings
|
|
1132
1083
|
);
|
|
1133
|
-
const stderr = warnings.length > 0 ?
|
|
1134
|
-
if (results.length === 0) return [new Uint8Array(0), new
|
|
1135
|
-
const out =
|
|
1136
|
-
return [out, new
|
|
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 })];
|
|
1137
1088
|
}
|
|
1138
1089
|
const pat2 = compilePattern(pattern, f.ignoreCase, f.fixedString, f.wholeWord);
|
|
1139
1090
|
if (resolved.length > 1) {
|
|
@@ -1149,37 +1100,37 @@ async function grepCommand(accessor, paths, texts, opts) {
|
|
|
1149
1100
|
for (const h of hits) allResults.push(`${p.original}:${h}`);
|
|
1150
1101
|
}
|
|
1151
1102
|
}
|
|
1152
|
-
if (allResults.length === 0) return [new Uint8Array(0), new
|
|
1153
|
-
const out =
|
|
1154
|
-
return [out, new
|
|
1103
|
+
if (allResults.length === 0) return [new Uint8Array(0), new IOResult3({ exitCode: 1 })];
|
|
1104
|
+
const out = formatRecords2(allResults);
|
|
1105
|
+
return [out, new IOResult3()];
|
|
1155
1106
|
}
|
|
1156
1107
|
const firstResolved = resolved[0];
|
|
1157
|
-
if (firstResolved === void 0) return [null, new
|
|
1108
|
+
if (firstResolved === void 0) return [null, new IOResult3()];
|
|
1158
1109
|
const data = await read(accessor, firstResolved, opts.index ?? void 0);
|
|
1159
1110
|
const source2 = yieldBytes(data);
|
|
1160
1111
|
const stream2 = grepStream(source2, pat2, f);
|
|
1161
1112
|
if (f.quiet) {
|
|
1162
|
-
const io3 = new
|
|
1113
|
+
const io3 = new IOResult3({ exitCode: 1 });
|
|
1163
1114
|
return [quietMatch(stream2, io3), io3];
|
|
1164
1115
|
}
|
|
1165
|
-
const io2 = new
|
|
1116
|
+
const io2 = new IOResult3();
|
|
1166
1117
|
return [exitOnEmpty(stream2, io2), io2];
|
|
1167
1118
|
}
|
|
1168
1119
|
let source;
|
|
1169
1120
|
try {
|
|
1170
|
-
source =
|
|
1121
|
+
source = resolveSource(opts.stdin, "grep: usage: grep [flags] pattern [path]");
|
|
1171
1122
|
} catch (err) {
|
|
1172
1123
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1173
|
-
return [null, new
|
|
1124
|
+
return [null, new IOResult3({ exitCode: 2, stderr: ENC3.encode(`${msg}
|
|
1174
1125
|
`) })];
|
|
1175
1126
|
}
|
|
1176
1127
|
const pat = compilePattern(pattern, f.ignoreCase, f.fixedString, f.wholeWord);
|
|
1177
1128
|
const stream = grepStream(source, pat, f);
|
|
1178
1129
|
if (f.quiet) {
|
|
1179
|
-
const io2 = new
|
|
1130
|
+
const io2 = new IOResult3({ exitCode: 1 });
|
|
1180
1131
|
return [quietMatch(stream, io2), io2];
|
|
1181
1132
|
}
|
|
1182
|
-
const io = new
|
|
1133
|
+
const io = new IOResult3();
|
|
1183
1134
|
return [exitOnEmpty(stream, io), io];
|
|
1184
1135
|
}
|
|
1185
1136
|
var EMAIL_GREP = command6({
|
|
@@ -1193,43 +1144,23 @@ var EMAIL_GREP = command6({
|
|
|
1193
1144
|
|
|
1194
1145
|
// src/commands/builtin/email/head.ts
|
|
1195
1146
|
import {
|
|
1196
|
-
IOResult as IOResult7,
|
|
1197
1147
|
ResourceName as ResourceName7,
|
|
1198
1148
|
command as command7,
|
|
1199
|
-
|
|
1149
|
+
headGeneric,
|
|
1200
1150
|
specOf as specOf6
|
|
1201
1151
|
} from "@struktoai/mirage-core";
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
return data.slice(0, end - 1);
|
|
1215
|
-
}
|
|
1216
|
-
async function headCommand(accessor, paths, _texts, opts) {
|
|
1217
|
-
const lines = typeof opts.flags.n === "string" ? Number.parseInt(opts.flags.n, 10) : 10;
|
|
1218
|
-
const bytesMode = typeof opts.flags.c === "string" ? Number.parseInt(opts.flags.c, 10) : null;
|
|
1219
|
-
if (paths.length > 0) {
|
|
1220
|
-
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
1221
|
-
const first = resolved[0];
|
|
1222
|
-
if (first === void 0) return [null, new IOResult7()];
|
|
1223
|
-
const data = await read(accessor, first, opts.index ?? void 0);
|
|
1224
|
-
const out2 = headBytes(data, lines, bytesMode);
|
|
1225
|
-
return [out2, new IOResult7()];
|
|
1226
|
-
}
|
|
1227
|
-
const raw = await readStdinAsync(opts.stdin);
|
|
1228
|
-
if (raw === null) {
|
|
1229
|
-
return [null, new IOResult7({ exitCode: 1, stderr: ENC8.encode("head: missing operand\n") })];
|
|
1230
|
-
}
|
|
1231
|
-
const out = headBytes(raw, lines, bytesMode);
|
|
1232
|
-
return [out, new IOResult7()];
|
|
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
|
+
);
|
|
1233
1164
|
}
|
|
1234
1165
|
var EMAIL_HEAD = command7({
|
|
1235
1166
|
name: "head",
|
|
@@ -1241,79 +1172,18 @@ var EMAIL_HEAD = command7({
|
|
|
1241
1172
|
|
|
1242
1173
|
// src/commands/builtin/email/jq.ts
|
|
1243
1174
|
import {
|
|
1244
|
-
IOResult as IOResult8,
|
|
1245
1175
|
ResourceName as ResourceName8,
|
|
1246
1176
|
command as command8,
|
|
1247
|
-
|
|
1248
|
-
parseJsonAuto,
|
|
1249
|
-
parseJsonPath,
|
|
1250
|
-
readStdinAsync as readStdinAsync2,
|
|
1177
|
+
jqGeneric,
|
|
1251
1178
|
specOf as specOf7
|
|
1252
1179
|
} from "@struktoai/mirage-core";
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
if (raw && typeof result === "string") return ENC9.encode(result + "\n");
|
|
1256
|
-
const json = compact ? JSON.stringify(result) : JSON.stringify(result, null, 2);
|
|
1257
|
-
return ENC9.encode(json + "\n");
|
|
1258
|
-
}
|
|
1259
|
-
function formatResults(results, raw, compact, spread) {
|
|
1260
|
-
if (spread && Array.isArray(results)) {
|
|
1261
|
-
const parts = [];
|
|
1262
|
-
for (const item of results) parts.push(formatResult(item, raw, compact));
|
|
1263
|
-
let total = 0;
|
|
1264
|
-
for (const p of parts) total += p.byteLength;
|
|
1265
|
-
const out = new Uint8Array(total);
|
|
1266
|
-
let offset = 0;
|
|
1267
|
-
for (const p of parts) {
|
|
1268
|
-
out.set(p, offset);
|
|
1269
|
-
offset += p.byteLength;
|
|
1270
|
-
}
|
|
1271
|
-
return out;
|
|
1272
|
-
}
|
|
1273
|
-
return formatResult(results, raw, compact);
|
|
1180
|
+
async function* emailStream3(accessor, p, index) {
|
|
1181
|
+
yield await read(accessor, p, index);
|
|
1274
1182
|
}
|
|
1275
1183
|
async function jqCommand(accessor, paths, texts, opts) {
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
new IOResult8({ exitCode: 2, stderr: ENC9.encode("jq: usage: jq EXPRESSION [path]\n") })
|
|
1280
|
-
];
|
|
1281
|
-
}
|
|
1282
|
-
const expression = texts[0];
|
|
1283
|
-
const r = opts.flags.r === true;
|
|
1284
|
-
const c = opts.flags.c === true;
|
|
1285
|
-
const s = opts.flags.s === true;
|
|
1286
|
-
const spread = expression.includes("[]");
|
|
1287
|
-
if (paths.length > 0) {
|
|
1288
|
-
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
1289
|
-
const parts = [];
|
|
1290
|
-
for (const p of resolved) {
|
|
1291
|
-
const raw2 = await read(accessor, p, opts.index ?? void 0);
|
|
1292
|
-
let data2 = parseJsonPath(raw2, p.original);
|
|
1293
|
-
if (s) data2 = Array.isArray(data2) ? data2 : [data2];
|
|
1294
|
-
const result3 = await jqEval(data2, expression.trim());
|
|
1295
|
-
parts.push(formatResults(result3, r, c, spread));
|
|
1296
|
-
}
|
|
1297
|
-
let total = 0;
|
|
1298
|
-
for (const part of parts) total += part.byteLength;
|
|
1299
|
-
const out2 = new Uint8Array(total);
|
|
1300
|
-
let offset = 0;
|
|
1301
|
-
for (const part of parts) {
|
|
1302
|
-
out2.set(part, offset);
|
|
1303
|
-
offset += part.byteLength;
|
|
1304
|
-
}
|
|
1305
|
-
const result2 = out2;
|
|
1306
|
-
return [result2, new IOResult8()];
|
|
1307
|
-
}
|
|
1308
|
-
const raw = await readStdinAsync2(opts.stdin);
|
|
1309
|
-
if (raw === null) {
|
|
1310
|
-
return [null, new IOResult8({ exitCode: 2, stderr: ENC9.encode("jq: missing input\n") })];
|
|
1311
|
-
}
|
|
1312
|
-
let data = parseJsonAuto(raw);
|
|
1313
|
-
if (s && !Array.isArray(data)) data = [data];
|
|
1314
|
-
const result = await jqEval(data, expression.trim());
|
|
1315
|
-
const out = formatResults(result, r, c, spread);
|
|
1316
|
-
return [out, new IOResult8()];
|
|
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);
|
|
1317
1187
|
}
|
|
1318
1188
|
var EMAIL_JQ = command8({
|
|
1319
1189
|
name: "jq",
|
|
@@ -1324,138 +1194,31 @@ var EMAIL_JQ = command8({
|
|
|
1324
1194
|
|
|
1325
1195
|
// src/commands/builtin/email/ls.ts
|
|
1326
1196
|
import {
|
|
1327
|
-
FileType as FileType2,
|
|
1328
|
-
IOResult as IOResult9,
|
|
1329
1197
|
PathSpec as PathSpec3,
|
|
1330
1198
|
ResourceName as ResourceName9,
|
|
1331
1199
|
command as command9,
|
|
1332
|
-
|
|
1200
|
+
lsGeneric,
|
|
1333
1201
|
specOf as specOf8
|
|
1334
1202
|
} from "@struktoai/mirage-core";
|
|
1335
|
-
var ENC10 = new TextEncoder();
|
|
1336
|
-
async function lsEntries(accessor, path, allFiles, sortBy, reverse, recursive, listDir, warnings, indexCache) {
|
|
1337
|
-
if (listDir) {
|
|
1338
|
-
const s = await stat(accessor, path, indexCache ?? void 0);
|
|
1339
|
-
return [s];
|
|
1340
|
-
}
|
|
1341
|
-
let entries;
|
|
1342
|
-
try {
|
|
1343
|
-
entries = await readdir(accessor, path, indexCache ?? void 0);
|
|
1344
|
-
} catch (err) {
|
|
1345
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1346
|
-
warnings.push(`ls: cannot access '${path.original}': ${msg}`);
|
|
1347
|
-
return [];
|
|
1348
|
-
}
|
|
1349
|
-
const stats = [];
|
|
1350
|
-
for (const entry of entries) {
|
|
1351
|
-
try {
|
|
1352
|
-
const eSpec = new PathSpec3({
|
|
1353
|
-
original: entry,
|
|
1354
|
-
directory: entry,
|
|
1355
|
-
resolved: false,
|
|
1356
|
-
prefix: path.prefix
|
|
1357
|
-
});
|
|
1358
|
-
const s = await stat(accessor, eSpec, indexCache ?? void 0);
|
|
1359
|
-
if (!allFiles && s.name.startsWith(".")) continue;
|
|
1360
|
-
stats.push(s);
|
|
1361
|
-
} catch (err) {
|
|
1362
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1363
|
-
warnings.push(`ls: cannot access '${entry}': ${msg}`);
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
if (sortBy === "size") {
|
|
1367
|
-
stats.sort((a, b) => (a.size ?? 0) - (b.size ?? 0));
|
|
1368
|
-
if (!reverse) stats.reverse();
|
|
1369
|
-
} else {
|
|
1370
|
-
stats.sort((a, b) => a.name.localeCompare(b.name));
|
|
1371
|
-
if (reverse) stats.reverse();
|
|
1372
|
-
}
|
|
1373
|
-
if (recursive) {
|
|
1374
|
-
const subEntries = [];
|
|
1375
|
-
for (const s of stats) {
|
|
1376
|
-
subEntries.push(s);
|
|
1377
|
-
if (s.type === FileType2.DIRECTORY) {
|
|
1378
|
-
const childPath = path.child(s.name);
|
|
1379
|
-
const childSpec = new PathSpec3({
|
|
1380
|
-
original: childPath,
|
|
1381
|
-
directory: childPath,
|
|
1382
|
-
resolved: false,
|
|
1383
|
-
prefix: path.prefix
|
|
1384
|
-
});
|
|
1385
|
-
const sub = await lsEntries(
|
|
1386
|
-
accessor,
|
|
1387
|
-
childSpec,
|
|
1388
|
-
allFiles,
|
|
1389
|
-
sortBy,
|
|
1390
|
-
reverse,
|
|
1391
|
-
recursive,
|
|
1392
|
-
false,
|
|
1393
|
-
warnings,
|
|
1394
|
-
indexCache
|
|
1395
|
-
);
|
|
1396
|
-
subEntries.push(...sub);
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
return subEntries;
|
|
1400
|
-
}
|
|
1401
|
-
return stats;
|
|
1402
|
-
}
|
|
1403
1203
|
async function lsCommand(accessor, paths, _texts, opts) {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
const allFiles = opts.flags.a === true || opts.flags.A === true;
|
|
1415
|
-
const human = opts.flags.h === true;
|
|
1416
|
-
const reverse = opts.flags.r === true;
|
|
1417
|
-
const recursive = opts.flags.R === true;
|
|
1418
|
-
const listDir = opts.flags.d === true;
|
|
1419
|
-
const classify = opts.flags.F === true;
|
|
1420
|
-
const sortBy = opts.flags.S === true ? "size" : "name";
|
|
1421
|
-
const warnings = [];
|
|
1422
|
-
const results = [];
|
|
1423
|
-
for (const p of targets) {
|
|
1424
|
-
let entries;
|
|
1425
|
-
try {
|
|
1426
|
-
entries = await lsEntries(
|
|
1427
|
-
accessor,
|
|
1428
|
-
p,
|
|
1429
|
-
allFiles,
|
|
1430
|
-
sortBy,
|
|
1431
|
-
reverse,
|
|
1432
|
-
recursive,
|
|
1433
|
-
listDir,
|
|
1434
|
-
warnings,
|
|
1435
|
-
opts.index
|
|
1436
|
-
);
|
|
1437
|
-
} catch (err) {
|
|
1438
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1439
|
-
warnings.push(`ls: cannot access '${p.original}': ${msg}`);
|
|
1440
|
-
continue;
|
|
1441
|
-
}
|
|
1442
|
-
if (long) {
|
|
1443
|
-
for (const e of entries) {
|
|
1444
|
-
const sizeStr = human ? humanSize(e.size ?? 0) : String(e.size ?? 0);
|
|
1445
|
-
results.push(`${e.type ?? "-"} ${sizeStr} ${e.modified ?? ""} ${e.name}`);
|
|
1446
|
-
}
|
|
1447
|
-
} else {
|
|
1448
|
-
for (const e of entries) {
|
|
1449
|
-
const isDir = classify && e.type === FileType2.DIRECTORY;
|
|
1450
|
-
const name = isDir ? e.name + "/" : e.name;
|
|
1451
|
-
results.push(name);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
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
|
+
];
|
|
1454
1214
|
}
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
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
|
+
);
|
|
1459
1222
|
}
|
|
1460
1223
|
var EMAIL_LS = command9({
|
|
1461
1224
|
name: "ls",
|
|
@@ -1467,78 +1230,36 @@ var EMAIL_LS = command9({
|
|
|
1467
1230
|
|
|
1468
1231
|
// src/commands/builtin/email/nl.ts
|
|
1469
1232
|
import {
|
|
1470
|
-
IOResult as IOResult10,
|
|
1471
1233
|
ResourceName as ResourceName10,
|
|
1472
1234
|
command as command10,
|
|
1473
|
-
|
|
1235
|
+
nlGeneric,
|
|
1474
1236
|
specOf as specOf9
|
|
1475
1237
|
} from "@struktoai/mirage-core";
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
function shouldNumber(line, mode, pattern) {
|
|
1479
|
-
if (mode === "n") return false;
|
|
1480
|
-
if (mode === "a") return true;
|
|
1481
|
-
if (mode === "p" && pattern !== null) return pattern.test(line);
|
|
1482
|
-
return line.trim() !== "";
|
|
1483
|
-
}
|
|
1484
|
-
function pad(n, width) {
|
|
1485
|
-
const s = String(n);
|
|
1486
|
-
return s.length >= width ? s : " ".repeat(width - s.length) + s;
|
|
1238
|
+
async function* emailStream4(accessor, p, index) {
|
|
1239
|
+
yield await read(accessor, p, index);
|
|
1487
1240
|
}
|
|
1488
1241
|
async function nlCommand(accessor, paths, _texts, opts) {
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
let pattern = null;
|
|
1492
|
-
if (bRaw.startsWith("p")) {
|
|
1493
|
-
mode = "p";
|
|
1494
|
-
pattern = new RegExp(bRaw.slice(1));
|
|
1495
|
-
}
|
|
1496
|
-
const start = typeof opts.flags.v === "string" ? Number.parseInt(opts.flags.v, 10) : 1;
|
|
1497
|
-
const increment = typeof opts.flags.i === "string" ? Number.parseInt(opts.flags.i, 10) : 1;
|
|
1498
|
-
const width = typeof opts.flags.w === "string" ? Number.parseInt(opts.flags.w, 10) : 6;
|
|
1499
|
-
const separator = typeof opts.flags.s === "string" ? opts.flags.s : " ";
|
|
1500
|
-
let raw = null;
|
|
1501
|
-
if (paths.length > 0) {
|
|
1502
|
-
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
1503
|
-
const first = resolved[0];
|
|
1504
|
-
if (first === void 0) return [null, new IOResult10()];
|
|
1505
|
-
raw = await read(accessor, first, opts.index ?? void 0);
|
|
1506
|
-
} else {
|
|
1507
|
-
raw = await readStdinAsync3(opts.stdin);
|
|
1508
|
-
if (raw === null) {
|
|
1509
|
-
return [null, new IOResult10({ exitCode: 1, stderr: ENC11.encode("nl: missing operand\n") })];
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
let num = start;
|
|
1513
|
-
const outLines = [];
|
|
1514
|
-
for (const line of DEC2.decode(raw).split("\n")) {
|
|
1515
|
-
if (shouldNumber(line, mode, pattern)) {
|
|
1516
|
-
outLines.push(`${pad(num, width)}${separator}${line}`);
|
|
1517
|
-
num += increment;
|
|
1518
|
-
} else {
|
|
1519
|
-
outLines.push(`${" ".repeat(width)}${separator}${line}`);
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
const out = ENC11.encode(outLines.join("\n") + "\n");
|
|
1523
|
-
return [out, new IOResult10()];
|
|
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));
|
|
1524
1244
|
}
|
|
1525
1245
|
var EMAIL_NL = command10({
|
|
1526
1246
|
name: "nl",
|
|
1527
1247
|
resource: ResourceName10.EMAIL,
|
|
1528
1248
|
spec: specOf9("nl"),
|
|
1529
|
-
fn: nlCommand
|
|
1249
|
+
fn: nlCommand,
|
|
1250
|
+
provision: fileReadProvision
|
|
1530
1251
|
});
|
|
1531
1252
|
|
|
1532
1253
|
// src/commands/builtin/email/email_read.ts
|
|
1533
1254
|
import {
|
|
1534
1255
|
CommandSpec as CommandSpec2,
|
|
1535
|
-
IOResult as
|
|
1256
|
+
IOResult as IOResult4,
|
|
1536
1257
|
OperandKind as OperandKind2,
|
|
1537
1258
|
Option as Option2,
|
|
1538
1259
|
ResourceName as ResourceName11,
|
|
1539
1260
|
command as command11
|
|
1540
1261
|
} from "@struktoai/mirage-core";
|
|
1541
|
-
var
|
|
1262
|
+
var ENC4 = new TextEncoder();
|
|
1542
1263
|
var SPEC2 = new CommandSpec2({
|
|
1543
1264
|
options: [
|
|
1544
1265
|
new Option2({ long: "--uid", valueKind: OperandKind2.TEXT }),
|
|
@@ -1549,14 +1270,14 @@ async function emailReadCommand(accessor, _paths, _texts, opts) {
|
|
|
1549
1270
|
const uid = typeof opts.flags.uid === "string" ? opts.flags.uid : "";
|
|
1550
1271
|
const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
|
|
1551
1272
|
if (uid === "") {
|
|
1552
|
-
return [null, new
|
|
1273
|
+
return [null, new IOResult4({ exitCode: 2, stderr: ENC4.encode("--uid is required\n") })];
|
|
1553
1274
|
}
|
|
1554
1275
|
if (folder === "") {
|
|
1555
|
-
return [null, new
|
|
1276
|
+
return [null, new IOResult4({ exitCode: 2, stderr: ENC4.encode("--folder is required\n") })];
|
|
1556
1277
|
}
|
|
1557
1278
|
const processed = await fetchMessage(accessor, folder, uid);
|
|
1558
|
-
const out =
|
|
1559
|
-
return [out, new
|
|
1279
|
+
const out = ENC4.encode(JSON.stringify(processed));
|
|
1280
|
+
return [out, new IOResult4()];
|
|
1560
1281
|
}
|
|
1561
1282
|
var EMAIL_READ = command11({
|
|
1562
1283
|
name: "email-read",
|
|
@@ -1566,72 +1287,24 @@ var EMAIL_READ = command11({
|
|
|
1566
1287
|
});
|
|
1567
1288
|
|
|
1568
1289
|
// src/commands/builtin/email/realpath.ts
|
|
1569
|
-
import {
|
|
1570
|
-
IOResult as IOResult12,
|
|
1571
|
-
PathSpec as PathSpec4,
|
|
1572
|
-
ResourceName as ResourceName12,
|
|
1573
|
-
command as command12,
|
|
1574
|
-
specOf as specOf10
|
|
1575
|
-
} from "@struktoai/mirage-core";
|
|
1576
|
-
var ENC13 = new TextEncoder();
|
|
1577
|
-
function normalize(p) {
|
|
1578
|
-
const isAbs = p.startsWith("/");
|
|
1579
|
-
const segments = p.split("/").filter((s) => s !== "" && s !== ".");
|
|
1580
|
-
const out = [];
|
|
1581
|
-
for (const s of segments) {
|
|
1582
|
-
if (s === "..") {
|
|
1583
|
-
if (out.length > 0) out.pop();
|
|
1584
|
-
else if (!isAbs) out.push("..");
|
|
1585
|
-
} else {
|
|
1586
|
-
out.push(s);
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
const joined = out.join("/");
|
|
1590
|
-
return isAbs ? "/" + joined : joined === "" ? "." : joined;
|
|
1591
|
-
}
|
|
1592
|
-
async function exists(accessor, path, index, prefix) {
|
|
1593
|
-
try {
|
|
1594
|
-
const spec = new PathSpec4({ original: path, directory: path, prefix });
|
|
1595
|
-
await stat(accessor, spec, index ?? void 0);
|
|
1596
|
-
return true;
|
|
1597
|
-
} catch {
|
|
1598
|
-
return false;
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
async function realpathCommand(accessor, paths, _texts, opts) {
|
|
1602
|
-
const prefix = opts.mountPrefix ?? "";
|
|
1603
|
-
const e = opts.flags.e === true;
|
|
1604
|
-
const lines = [];
|
|
1605
|
-
for (const p of paths) {
|
|
1606
|
-
const full = prefix !== "" ? prefix + p.original : p.original;
|
|
1607
|
-
const resolved = normalize(full);
|
|
1608
|
-
if (e && !await exists(accessor, resolved, opts.index, prefix)) {
|
|
1609
|
-
const msg = `realpath: '${p.original}': No such file or directory
|
|
1610
|
-
`;
|
|
1611
|
-
return [null, new IOResult12({ exitCode: 1, stderr: ENC13.encode(msg) })];
|
|
1612
|
-
}
|
|
1613
|
-
lines.push(resolved);
|
|
1614
|
-
}
|
|
1615
|
-
const out = ENC13.encode(lines.join("\n") + "\n");
|
|
1616
|
-
return [out, new IOResult12()];
|
|
1617
|
-
}
|
|
1290
|
+
import { ResourceName as ResourceName12, command as command12, realpathGeneric, specOf as specOf10 } from "@struktoai/mirage-core";
|
|
1618
1291
|
var EMAIL_REALPATH = command12({
|
|
1619
1292
|
name: "realpath",
|
|
1620
1293
|
resource: ResourceName12.EMAIL,
|
|
1621
1294
|
spec: specOf10("realpath"),
|
|
1622
|
-
fn:
|
|
1295
|
+
fn: (accessor, paths, texts, opts) => realpathGeneric(paths, texts, opts, (p) => stat(accessor, p, opts.index ?? void 0))
|
|
1623
1296
|
});
|
|
1624
1297
|
|
|
1625
1298
|
// src/commands/builtin/email/email_reply.ts
|
|
1626
1299
|
import {
|
|
1627
1300
|
CommandSpec as CommandSpec3,
|
|
1628
|
-
IOResult as
|
|
1301
|
+
IOResult as IOResult5,
|
|
1629
1302
|
OperandKind as OperandKind3,
|
|
1630
1303
|
Option as Option3,
|
|
1631
1304
|
ResourceName as ResourceName13,
|
|
1632
1305
|
command as command13
|
|
1633
1306
|
} from "@struktoai/mirage-core";
|
|
1634
|
-
var
|
|
1307
|
+
var ENC5 = new TextEncoder();
|
|
1635
1308
|
var SPEC3 = new CommandSpec3({
|
|
1636
1309
|
options: [
|
|
1637
1310
|
new Option3({ long: "--uid", valueKind: OperandKind3.TEXT }),
|
|
@@ -1644,18 +1317,18 @@ async function emailReplyCommand(accessor, _paths, _texts, opts) {
|
|
|
1644
1317
|
const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
|
|
1645
1318
|
const body = typeof opts.flags.body === "string" ? opts.flags.body : "";
|
|
1646
1319
|
if (uid === "") {
|
|
1647
|
-
return [null, new
|
|
1320
|
+
return [null, new IOResult5({ exitCode: 2, stderr: ENC5.encode("--uid is required\n") })];
|
|
1648
1321
|
}
|
|
1649
1322
|
if (folder === "") {
|
|
1650
|
-
return [null, new
|
|
1323
|
+
return [null, new IOResult5({ exitCode: 2, stderr: ENC5.encode("--folder is required\n") })];
|
|
1651
1324
|
}
|
|
1652
1325
|
if (body === "") {
|
|
1653
|
-
return [null, new
|
|
1326
|
+
return [null, new IOResult5({ exitCode: 2, stderr: ENC5.encode("--body is required\n") })];
|
|
1654
1327
|
}
|
|
1655
1328
|
const original = await fetchMessage(accessor, folder, uid);
|
|
1656
1329
|
const result = await replyMessage(accessor.config, original, body);
|
|
1657
|
-
const out =
|
|
1658
|
-
return [out, new
|
|
1330
|
+
const out = ENC5.encode(JSON.stringify(result));
|
|
1331
|
+
return [out, new IOResult5()];
|
|
1659
1332
|
}
|
|
1660
1333
|
var EMAIL_REPLY = command13({
|
|
1661
1334
|
name: "email-reply",
|
|
@@ -1668,13 +1341,13 @@ var EMAIL_REPLY = command13({
|
|
|
1668
1341
|
// src/commands/builtin/email/email_reply_all.ts
|
|
1669
1342
|
import {
|
|
1670
1343
|
CommandSpec as CommandSpec4,
|
|
1671
|
-
IOResult as
|
|
1344
|
+
IOResult as IOResult6,
|
|
1672
1345
|
OperandKind as OperandKind4,
|
|
1673
1346
|
Option as Option4,
|
|
1674
1347
|
ResourceName as ResourceName14,
|
|
1675
1348
|
command as command14
|
|
1676
1349
|
} from "@struktoai/mirage-core";
|
|
1677
|
-
var
|
|
1350
|
+
var ENC6 = new TextEncoder();
|
|
1678
1351
|
var SPEC4 = new CommandSpec4({
|
|
1679
1352
|
options: [
|
|
1680
1353
|
new Option4({ long: "--uid", valueKind: OperandKind4.TEXT }),
|
|
@@ -1687,18 +1360,18 @@ async function emailReplyAllCommand(accessor, _paths, _texts, opts) {
|
|
|
1687
1360
|
const folder = typeof opts.flags.folder === "string" ? opts.flags.folder : "";
|
|
1688
1361
|
const body = typeof opts.flags.body === "string" ? opts.flags.body : "";
|
|
1689
1362
|
if (uid === "") {
|
|
1690
|
-
return [null, new
|
|
1363
|
+
return [null, new IOResult6({ exitCode: 2, stderr: ENC6.encode("--uid is required\n") })];
|
|
1691
1364
|
}
|
|
1692
1365
|
if (folder === "") {
|
|
1693
|
-
return [null, new
|
|
1366
|
+
return [null, new IOResult6({ exitCode: 2, stderr: ENC6.encode("--folder is required\n") })];
|
|
1694
1367
|
}
|
|
1695
1368
|
if (body === "") {
|
|
1696
|
-
return [null, new
|
|
1369
|
+
return [null, new IOResult6({ exitCode: 2, stderr: ENC6.encode("--body is required\n") })];
|
|
1697
1370
|
}
|
|
1698
1371
|
const original = await fetchMessage(accessor, folder, uid);
|
|
1699
1372
|
const result = await replyAllMessage(accessor.config, original, body);
|
|
1700
|
-
const out =
|
|
1701
|
-
return [out, new
|
|
1373
|
+
const out = ENC6.encode(JSON.stringify(result));
|
|
1374
|
+
return [out, new IOResult6()];
|
|
1702
1375
|
}
|
|
1703
1376
|
var EMAIL_REPLY_ALL = command14({
|
|
1704
1377
|
name: "email-reply-all",
|
|
@@ -1710,48 +1383,23 @@ var EMAIL_REPLY_ALL = command14({
|
|
|
1710
1383
|
|
|
1711
1384
|
// src/commands/builtin/email/rg.ts
|
|
1712
1385
|
import {
|
|
1713
|
-
IOResult as
|
|
1714
|
-
PathSpec as PathSpec5,
|
|
1386
|
+
IOResult as IOResult7,
|
|
1715
1387
|
ResourceName as ResourceName15,
|
|
1716
1388
|
command as command15,
|
|
1717
1389
|
compilePattern as compilePattern2,
|
|
1718
1390
|
grepLines as grepLines2,
|
|
1719
|
-
|
|
1391
|
+
rgGeneric,
|
|
1720
1392
|
specOf as specOf11
|
|
1721
1393
|
} from "@struktoai/mirage-core";
|
|
1722
|
-
var
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
if (path.original.endsWith(".json") || path.original.endsWith(".jsonl")) {
|
|
1726
|
-
return [path.original];
|
|
1727
|
-
}
|
|
1728
|
-
let children;
|
|
1729
|
-
try {
|
|
1730
|
-
children = await readdir(accessor, path, index ?? void 0);
|
|
1731
|
-
} catch {
|
|
1732
|
-
return [];
|
|
1733
|
-
}
|
|
1734
|
-
const files = [];
|
|
1735
|
-
for (const child of children) {
|
|
1736
|
-
if (child.endsWith(".email.json")) {
|
|
1737
|
-
files.push(child);
|
|
1738
|
-
} else {
|
|
1739
|
-
const childSpec = new PathSpec5({
|
|
1740
|
-
original: child,
|
|
1741
|
-
directory: child,
|
|
1742
|
-
resolved: false,
|
|
1743
|
-
prefix: path.prefix
|
|
1744
|
-
});
|
|
1745
|
-
files.push(...await collectFiles(accessor, childSpec, index));
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
return files;
|
|
1394
|
+
var ENC7 = new TextEncoder();
|
|
1395
|
+
async function* emailStream5(accessor, p, index) {
|
|
1396
|
+
yield await read(accessor, p, index);
|
|
1749
1397
|
}
|
|
1750
1398
|
async function rgCommand(accessor, paths, texts, opts) {
|
|
1751
1399
|
if (texts.length === 0 || texts[0] === void 0) {
|
|
1752
1400
|
return [
|
|
1753
1401
|
null,
|
|
1754
|
-
new
|
|
1402
|
+
new IOResult7({ exitCode: 2, stderr: ENC7.encode("rg: usage: rg [flags] pattern [path]\n") })
|
|
1755
1403
|
];
|
|
1756
1404
|
}
|
|
1757
1405
|
const pattern = texts[0];
|
|
@@ -1764,7 +1412,6 @@ async function rgCommand(accessor, paths, texts, opts) {
|
|
|
1764
1412
|
const fixedString = opts.flags.F === true;
|
|
1765
1413
|
const onlyMatching = opts.flags.o === true;
|
|
1766
1414
|
const maxCount = typeof opts.flags.m === "string" ? Number.parseInt(opts.flags.m, 10) : null;
|
|
1767
|
-
const hidden = opts.flags.hidden === true;
|
|
1768
1415
|
const pat = compilePattern2(pattern, ignoreCase, fixedString, wholeWord);
|
|
1769
1416
|
const lineOpts = {
|
|
1770
1417
|
invert,
|
|
@@ -1779,74 +1426,30 @@ async function rgCommand(accessor, paths, texts, opts) {
|
|
|
1779
1426
|
if (first !== void 0) {
|
|
1780
1427
|
const scope = detectScope(first);
|
|
1781
1428
|
if (scope.useNative) {
|
|
1782
|
-
const
|
|
1783
|
-
const pairs = await searchAndFormat(accessor, scope, pattern,
|
|
1784
|
-
const
|
|
1429
|
+
const filePrefix = first.prefix !== "" ? first.prefix : "";
|
|
1430
|
+
const pairs = await searchAndFormat(accessor, scope, pattern, filePrefix, maxCount ?? 50);
|
|
1431
|
+
const lines = [];
|
|
1785
1432
|
for (const [vfsPath, msgText] of pairs) {
|
|
1786
|
-
const
|
|
1787
|
-
for (const line of
|
|
1433
|
+
const matched = grepLines2(vfsPath, [msgText], pat, lineOpts);
|
|
1434
|
+
for (const line of matched) lines.push(`${vfsPath}:${line}`);
|
|
1788
1435
|
}
|
|
1789
|
-
if (
|
|
1790
|
-
const
|
|
1791
|
-
return [
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
1795
|
-
const filePrefix = resolved[0]?.prefix ?? "";
|
|
1796
|
-
const blobPaths = [];
|
|
1797
|
-
for (const p of resolved) blobPaths.push(...await collectFiles(accessor, p, opts.index));
|
|
1798
|
-
const sortedUnique = [...new Set(blobPaths)].sort();
|
|
1799
|
-
const allResults = [];
|
|
1800
|
-
let anyMatch = false;
|
|
1801
|
-
for (const bp of sortedUnique) {
|
|
1802
|
-
if (!hidden && bp.split("/").some((part) => part.startsWith("."))) continue;
|
|
1803
|
-
let data;
|
|
1804
|
-
try {
|
|
1805
|
-
const spec = new PathSpec5({
|
|
1806
|
-
original: bp,
|
|
1807
|
-
directory: bp,
|
|
1808
|
-
resolved: true,
|
|
1809
|
-
prefix: filePrefix
|
|
1810
|
-
});
|
|
1811
|
-
data = await read(accessor, spec, opts.index ?? void 0);
|
|
1812
|
-
} catch {
|
|
1813
|
-
continue;
|
|
1814
|
-
}
|
|
1815
|
-
const text = DEC3.decode(data);
|
|
1816
|
-
if (text === "") continue;
|
|
1817
|
-
const lines2 = text.split("\n");
|
|
1818
|
-
if (lines2.length > 0 && lines2[lines2.length - 1] === "") lines2.pop();
|
|
1819
|
-
const matched2 = grepLines2(bp, lines2, pat, lineOpts);
|
|
1820
|
-
if (matched2.length === 0) continue;
|
|
1821
|
-
anyMatch = true;
|
|
1822
|
-
if (filesOnly) {
|
|
1823
|
-
allResults.push(bp);
|
|
1824
|
-
continue;
|
|
1825
|
-
}
|
|
1826
|
-
if (countOnly) {
|
|
1827
|
-
allResults.push(`${bp}:${String(matched2.length)}`);
|
|
1828
|
-
continue;
|
|
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()];
|
|
1829
1439
|
}
|
|
1830
|
-
for (const line of matched2) allResults.push(`${bp}:${line}`);
|
|
1831
1440
|
}
|
|
1832
|
-
if (!anyMatch) return [new Uint8Array(0), new IOResult15({ exitCode: 1 })];
|
|
1833
|
-
const out2 = ENC16.encode(allResults.join("\n"));
|
|
1834
|
-
return [out2, new IOResult15()];
|
|
1835
1441
|
}
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
if (countOnly) return [ENC16.encode(String(matched.length)), new IOResult15()];
|
|
1848
|
-
const out = ENC16.encode(matched.join("\n"));
|
|
1849
|
-
return [out, new IOResult15()];
|
|
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
|
+
);
|
|
1850
1453
|
}
|
|
1851
1454
|
var EMAIL_RG = command15({
|
|
1852
1455
|
name: "rg",
|
|
@@ -1858,13 +1461,13 @@ var EMAIL_RG = command15({
|
|
|
1858
1461
|
// src/commands/builtin/email/email_send.ts
|
|
1859
1462
|
import {
|
|
1860
1463
|
CommandSpec as CommandSpec5,
|
|
1861
|
-
IOResult as
|
|
1464
|
+
IOResult as IOResult8,
|
|
1862
1465
|
OperandKind as OperandKind5,
|
|
1863
1466
|
Option as Option5,
|
|
1864
1467
|
ResourceName as ResourceName16,
|
|
1865
1468
|
command as command16
|
|
1866
1469
|
} from "@struktoai/mirage-core";
|
|
1867
|
-
var
|
|
1470
|
+
var ENC8 = new TextEncoder();
|
|
1868
1471
|
var SPEC5 = new CommandSpec5({
|
|
1869
1472
|
options: [
|
|
1870
1473
|
new Option5({ long: "--to", valueKind: OperandKind5.TEXT }),
|
|
@@ -1877,17 +1480,17 @@ async function emailSendCommand(accessor, _paths, _texts, opts) {
|
|
|
1877
1480
|
const subject = typeof opts.flags.subject === "string" ? opts.flags.subject : "";
|
|
1878
1481
|
const body = typeof opts.flags.body === "string" ? opts.flags.body : "";
|
|
1879
1482
|
if (to === "") {
|
|
1880
|
-
return [null, new
|
|
1483
|
+
return [null, new IOResult8({ exitCode: 2, stderr: ENC8.encode("--to is required\n") })];
|
|
1881
1484
|
}
|
|
1882
1485
|
if (subject === "") {
|
|
1883
|
-
return [null, new
|
|
1486
|
+
return [null, new IOResult8({ exitCode: 2, stderr: ENC8.encode("--subject is required\n") })];
|
|
1884
1487
|
}
|
|
1885
1488
|
if (body === "") {
|
|
1886
|
-
return [null, new
|
|
1489
|
+
return [null, new IOResult8({ exitCode: 2, stderr: ENC8.encode("--body is required\n") })];
|
|
1887
1490
|
}
|
|
1888
1491
|
const result = await sendMessage(accessor.config, to, subject, body);
|
|
1889
|
-
const out =
|
|
1890
|
-
return [out, new
|
|
1492
|
+
const out = ENC8.encode(JSON.stringify(result));
|
|
1493
|
+
return [out, new IOResult8()];
|
|
1891
1494
|
}
|
|
1892
1495
|
var EMAIL_SEND = command16({
|
|
1893
1496
|
name: "email-send",
|
|
@@ -1899,50 +1502,14 @@ var EMAIL_SEND = command16({
|
|
|
1899
1502
|
|
|
1900
1503
|
// src/commands/builtin/email/stat.ts
|
|
1901
1504
|
import {
|
|
1902
|
-
FileType as FileType3,
|
|
1903
|
-
IOResult as IOResult17,
|
|
1904
1505
|
ResourceName as ResourceName17,
|
|
1905
1506
|
command as command17,
|
|
1906
|
-
specOf as specOf12
|
|
1507
|
+
specOf as specOf12,
|
|
1508
|
+
statGeneric
|
|
1907
1509
|
} from "@struktoai/mirage-core";
|
|
1908
|
-
var ENC18 = new TextEncoder();
|
|
1909
|
-
var TYPE_LABELS = {
|
|
1910
|
-
[FileType3.DIRECTORY]: "directory",
|
|
1911
|
-
[FileType3.TEXT]: "regular file",
|
|
1912
|
-
[FileType3.BINARY]: "regular file",
|
|
1913
|
-
[FileType3.JSON]: "regular file",
|
|
1914
|
-
[FileType3.CSV]: "regular file"
|
|
1915
|
-
};
|
|
1916
|
-
function formatStat(fmt, s) {
|
|
1917
|
-
return fmt.replace(/%(.)/g, (_, spec) => {
|
|
1918
|
-
if (spec === "n") return s.name;
|
|
1919
|
-
if (spec === "s") return String(s.size ?? 0);
|
|
1920
|
-
if (spec === "F")
|
|
1921
|
-
return s.type !== null ? TYPE_LABELS[s.type] ?? "regular file" : "regular file";
|
|
1922
|
-
if (spec === "y") return s.modified ?? "";
|
|
1923
|
-
return "?";
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
1510
|
async function statCommand(accessor, paths, _texts, opts) {
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
}
|
|
1930
|
-
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
1931
|
-
const fmt = typeof opts.flags.c === "string" ? opts.flags.c : typeof opts.flags.f === "string" ? opts.flags.f : null;
|
|
1932
|
-
const lines = [];
|
|
1933
|
-
for (const p of resolved) {
|
|
1934
|
-
const s = await stat(accessor, p, opts.index ?? void 0);
|
|
1935
|
-
if (fmt !== null) {
|
|
1936
|
-
lines.push(formatStat(fmt, s));
|
|
1937
|
-
} else {
|
|
1938
|
-
const sizeStr = s.size === null ? "None" : String(s.size);
|
|
1939
|
-
const modStr = s.modified ?? "None";
|
|
1940
|
-
const typeStr = s.type ?? "None";
|
|
1941
|
-
lines.push(`name=${s.name} size=${sizeStr} modified=${modStr} type=${typeStr}`);
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
const out = ENC18.encode(lines.join("\n"));
|
|
1945
|
-
return [out, new IOResult17()];
|
|
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));
|
|
1946
1513
|
}
|
|
1947
1514
|
var EMAIL_STAT = command17({
|
|
1948
1515
|
name: "stat",
|
|
@@ -1954,32 +1521,22 @@ var EMAIL_STAT = command17({
|
|
|
1954
1521
|
|
|
1955
1522
|
// src/commands/builtin/email/tail.ts
|
|
1956
1523
|
import {
|
|
1957
|
-
IOResult as IOResult18,
|
|
1958
1524
|
ResourceName as ResourceName18,
|
|
1959
1525
|
command as command18,
|
|
1960
|
-
parseN,
|
|
1961
|
-
readStdinAsync as readStdinAsync5,
|
|
1962
1526
|
specOf as specOf13,
|
|
1963
|
-
|
|
1527
|
+
tailGeneric
|
|
1964
1528
|
} from "@struktoai/mirage-core";
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
}
|
|
1977
|
-
const raw = await readStdinAsync5(opts.stdin);
|
|
1978
|
-
if (raw === null) {
|
|
1979
|
-
return [null, new IOResult18({ exitCode: 1, stderr: ENC19.encode("tail: missing operand\n") })];
|
|
1980
|
-
}
|
|
1981
|
-
const out = tailBytes(raw, lines, bytesMode, plusMode);
|
|
1982
|
-
return [out, new IOResult18()];
|
|
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
|
+
);
|
|
1983
1540
|
}
|
|
1984
1541
|
var EMAIL_TAIL = command18({
|
|
1985
1542
|
name: "tail",
|
|
@@ -1991,95 +1548,19 @@ var EMAIL_TAIL = command18({
|
|
|
1991
1548
|
|
|
1992
1549
|
// src/commands/builtin/email/tree.ts
|
|
1993
1550
|
import {
|
|
1994
|
-
FileType as FileType4,
|
|
1995
|
-
IOResult as IOResult19,
|
|
1996
|
-
PathSpec as PathSpec6,
|
|
1997
1551
|
ResourceName as ResourceName19,
|
|
1998
1552
|
command as command19,
|
|
1999
|
-
specOf as specOf14
|
|
1553
|
+
specOf as specOf14,
|
|
1554
|
+
treeGeneric
|
|
2000
1555
|
} from "@struktoai/mirage-core";
|
|
2001
|
-
var ENC20 = new TextEncoder();
|
|
2002
|
-
function fnmatch3(name, pattern) {
|
|
2003
|
-
const re = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\?/g, ".").replace(/\*/g, ".*");
|
|
2004
|
-
return new RegExp(`^${re}$`).test(name);
|
|
2005
|
-
}
|
|
2006
|
-
async function treeRecurse(accessor, path, prefix, depth, treeOpts, warnings, indexCache) {
|
|
2007
|
-
const lines = [];
|
|
2008
|
-
let entries;
|
|
2009
|
-
try {
|
|
2010
|
-
entries = await readdir(accessor, path, indexCache ?? void 0);
|
|
2011
|
-
} catch (err) {
|
|
2012
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
2013
|
-
warnings.push(`tree: '${path.original}': ${msg}`);
|
|
2014
|
-
return lines;
|
|
2015
|
-
}
|
|
2016
|
-
const filtered = [];
|
|
2017
|
-
for (const entry of entries) {
|
|
2018
|
-
try {
|
|
2019
|
-
const entrySpec = new PathSpec6({
|
|
2020
|
-
original: entry,
|
|
2021
|
-
directory: entry,
|
|
2022
|
-
resolved: false,
|
|
2023
|
-
prefix: path.prefix
|
|
2024
|
-
});
|
|
2025
|
-
const s = await stat(accessor, entrySpec, indexCache ?? void 0);
|
|
2026
|
-
if (!treeOpts.showHidden && s.name.startsWith(".")) continue;
|
|
2027
|
-
if (treeOpts.ignorePattern !== null && fnmatch3(s.name, treeOpts.ignorePattern)) continue;
|
|
2028
|
-
if (treeOpts.dirsOnly && s.type !== FileType4.DIRECTORY) continue;
|
|
2029
|
-
const notDir = s.type !== FileType4.DIRECTORY;
|
|
2030
|
-
if (treeOpts.matchPattern !== null && notDir && !fnmatch3(s.name, treeOpts.matchPattern))
|
|
2031
|
-
continue;
|
|
2032
|
-
filtered.push([entrySpec, s]);
|
|
2033
|
-
} catch (err) {
|
|
2034
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
2035
|
-
warnings.push(`tree: '${entry}': ${msg}`);
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
for (let i = 0; i < filtered.length; i++) {
|
|
2039
|
-
const pair = filtered[i];
|
|
2040
|
-
if (pair === void 0) continue;
|
|
2041
|
-
const [entrySpec, s] = pair;
|
|
2042
|
-
const isLast = i === filtered.length - 1;
|
|
2043
|
-
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
2044
|
-
lines.push(prefix + connector + s.name);
|
|
2045
|
-
if (s.type === FileType4.DIRECTORY) {
|
|
2046
|
-
if (treeOpts.maxDepth !== null && depth >= treeOpts.maxDepth) continue;
|
|
2047
|
-
const extension = isLast ? " " : "\u2502 ";
|
|
2048
|
-
const sub = await treeRecurse(
|
|
2049
|
-
accessor,
|
|
2050
|
-
entrySpec,
|
|
2051
|
-
prefix + extension,
|
|
2052
|
-
depth + 1,
|
|
2053
|
-
treeOpts,
|
|
2054
|
-
warnings,
|
|
2055
|
-
indexCache
|
|
2056
|
-
);
|
|
2057
|
-
lines.push(...sub);
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
return lines;
|
|
2061
|
-
}
|
|
2062
1556
|
async function treeCommand(accessor, paths, _texts, opts) {
|
|
2063
1557
|
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
const maxDepth = typeof opts.flags.L === "string" ? Number.parseInt(opts.flags.L, 10) : null;
|
|
2071
|
-
const treeOpts = {
|
|
2072
|
-
maxDepth,
|
|
2073
|
-
showHidden: opts.flags.a === true,
|
|
2074
|
-
ignorePattern: typeof opts.flags.args_I === "string" ? opts.flags.args_I : null,
|
|
2075
|
-
dirsOnly: opts.flags.d === true,
|
|
2076
|
-
matchPattern: typeof opts.flags.P === "string" ? opts.flags.P : null
|
|
2077
|
-
};
|
|
2078
|
-
const warnings = [];
|
|
2079
|
-
const results = await treeRecurse(accessor, p0, "", 0, treeOpts, warnings, opts.index);
|
|
2080
|
-
const out = ENC20.encode(results.join("\n"));
|
|
2081
|
-
const stderr = warnings.length > 0 ? ENC20.encode(warnings.join("\n")) : null;
|
|
2082
|
-
return [out, new IOResult19({ stderr })];
|
|
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
|
+
);
|
|
2083
1564
|
}
|
|
2084
1565
|
var EMAIL_TREE = command19({
|
|
2085
1566
|
name: "tree",
|
|
@@ -2091,13 +1572,13 @@ var EMAIL_TREE = command19({
|
|
|
2091
1572
|
// src/commands/builtin/email/email_triage.ts
|
|
2092
1573
|
import {
|
|
2093
1574
|
CommandSpec as CommandSpec6,
|
|
2094
|
-
IOResult as
|
|
1575
|
+
IOResult as IOResult9,
|
|
2095
1576
|
OperandKind as OperandKind6,
|
|
2096
1577
|
Option as Option6,
|
|
2097
1578
|
ResourceName as ResourceName20,
|
|
2098
1579
|
command as command20
|
|
2099
1580
|
} from "@struktoai/mirage-core";
|
|
2100
|
-
var
|
|
1581
|
+
var ENC9 = new TextEncoder();
|
|
2101
1582
|
var SPEC6 = new CommandSpec6({
|
|
2102
1583
|
options: [
|
|
2103
1584
|
new Option6({ long: "--folder", valueKind: OperandKind6.TEXT }),
|
|
@@ -2129,12 +1610,12 @@ async function emailTriageCommand(accessor, _paths, _texts, opts) {
|
|
|
2129
1610
|
maxResults
|
|
2130
1611
|
);
|
|
2131
1612
|
if (uids.length === 0) {
|
|
2132
|
-
const out2 =
|
|
2133
|
-
return [out2, new
|
|
1613
|
+
const out2 = ENC9.encode("[]");
|
|
1614
|
+
return [out2, new IOResult9()];
|
|
2134
1615
|
}
|
|
2135
1616
|
const headers = await fetchHeaders(accessor, folder, uids);
|
|
2136
|
-
const out =
|
|
2137
|
-
return [out, new
|
|
1617
|
+
const out = ENC9.encode(JSON.stringify(headers));
|
|
1618
|
+
return [out, new IOResult9()];
|
|
2138
1619
|
}
|
|
2139
1620
|
var EMAIL_TRIAGE = command20({
|
|
2140
1621
|
name: "email-triage",
|
|
@@ -2145,58 +1626,17 @@ var EMAIL_TRIAGE = command20({
|
|
|
2145
1626
|
|
|
2146
1627
|
// src/commands/builtin/email/wc.ts
|
|
2147
1628
|
import {
|
|
2148
|
-
IOResult as IOResult21,
|
|
2149
1629
|
ResourceName as ResourceName21,
|
|
2150
1630
|
command as command21,
|
|
2151
|
-
|
|
2152
|
-
|
|
1631
|
+
specOf as specOf15,
|
|
1632
|
+
wcGeneric
|
|
2153
1633
|
} from "@struktoai/mirage-core";
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
return
|
|
2160
|
-
}
|
|
2161
|
-
function countWords(text) {
|
|
2162
|
-
const trimmed = text.trim();
|
|
2163
|
-
if (trimmed === "") return 0;
|
|
2164
|
-
return trimmed.split(/\s+/).length;
|
|
2165
|
-
}
|
|
2166
|
-
function maxLineLen(text) {
|
|
2167
|
-
let max = 0;
|
|
2168
|
-
for (const line of text.split("\n")) if (line.length > max) max = line.length;
|
|
2169
|
-
return max;
|
|
2170
|
-
}
|
|
2171
|
-
async function wcCommand(accessor, paths, _texts, opts) {
|
|
2172
|
-
let data = null;
|
|
2173
|
-
if (paths.length > 0) {
|
|
2174
|
-
const resolved = await resolveGlob(accessor, paths, opts.index ?? void 0);
|
|
2175
|
-
const first = resolved[0];
|
|
2176
|
-
if (first === void 0) return [null, new IOResult21()];
|
|
2177
|
-
data = await read(accessor, first, opts.index ?? void 0);
|
|
2178
|
-
} else {
|
|
2179
|
-
data = await readStdinAsync6(opts.stdin);
|
|
2180
|
-
if (data === null) {
|
|
2181
|
-
return [null, new IOResult21({ exitCode: 1, stderr: ENC22.encode("wc: missing operand\n") })];
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
const text = DEC4.decode(data);
|
|
2185
|
-
const lineCount = countLines(text);
|
|
2186
|
-
const wordCount = countWords(text);
|
|
2187
|
-
const byteCount = data.byteLength;
|
|
2188
|
-
if (opts.flags.L === true) {
|
|
2189
|
-
const out2 = ENC22.encode(String(maxLineLen(text)));
|
|
2190
|
-
return [out2, new IOResult21()];
|
|
2191
|
-
}
|
|
2192
|
-
if (opts.flags.args_l === true) return [ENC22.encode(String(lineCount)), new IOResult21()];
|
|
2193
|
-
if (opts.flags.w === true) return [ENC22.encode(String(wordCount)), new IOResult21()];
|
|
2194
|
-
if (opts.flags.m === true) return [ENC22.encode(String(text.length)), new IOResult21()];
|
|
2195
|
-
if (opts.flags.c === true) return [ENC22.encode(String(byteCount)), new IOResult21()];
|
|
2196
|
-
const out = ENC22.encode(
|
|
2197
|
-
`${String(lineCount)} ${String(wordCount)} ${String(byteCount)}`
|
|
2198
|
-
);
|
|
2199
|
-
return [out, new IOResult21()];
|
|
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));
|
|
2200
1640
|
}
|
|
2201
1641
|
var EMAIL_WC = command21({
|
|
2202
1642
|
name: "wc",
|
|
@@ -2284,18 +1724,17 @@ var EMAIL_WRITE_PROMPT = ` Write commands:
|
|
|
2284
1724
|
email-forward <email-path> "to@email.com"`;
|
|
2285
1725
|
|
|
2286
1726
|
// src/resource/email/email.ts
|
|
2287
|
-
var EmailResource = class {
|
|
1727
|
+
var EmailResource = class extends BaseResource {
|
|
2288
1728
|
kind = ResourceName25.EMAIL;
|
|
2289
1729
|
isRemote = true;
|
|
2290
1730
|
indexTtl = 86400;
|
|
2291
1731
|
prompt = EMAIL_PROMPT;
|
|
2292
1732
|
config;
|
|
2293
1733
|
accessor;
|
|
2294
|
-
index;
|
|
2295
1734
|
constructor(config) {
|
|
1735
|
+
super();
|
|
2296
1736
|
this.config = config;
|
|
2297
1737
|
this.accessor = new EmailAccessor(config);
|
|
2298
|
-
this.index = new RAMIndexCacheStore({ ttl: 86400 });
|
|
2299
1738
|
}
|
|
2300
1739
|
open() {
|
|
2301
1740
|
return Promise.resolve();
|
|
@@ -2324,7 +1763,7 @@ var EmailResource = class {
|
|
|
2324
1763
|
}
|
|
2325
1764
|
glob(paths, prefix = "") {
|
|
2326
1765
|
const effective = prefix !== "" ? paths.map(
|
|
2327
|
-
(p) => p.prefix !== "" ? p : new
|
|
1766
|
+
(p) => p.prefix !== "" ? p : new PathSpec4({
|
|
2328
1767
|
original: p.original,
|
|
2329
1768
|
directory: p.directory,
|
|
2330
1769
|
...p.pattern !== null ? { pattern: p.pattern } : {},
|
|
@@ -2337,8 +1776,6 @@ var EmailResource = class {
|
|
|
2337
1776
|
getState() {
|
|
2338
1777
|
return Promise.resolve({
|
|
2339
1778
|
type: this.kind,
|
|
2340
|
-
needsOverride: true,
|
|
2341
|
-
redactedFields: ["password"],
|
|
2342
1779
|
config: redactEmailConfig(this.config)
|
|
2343
1780
|
});
|
|
2344
1781
|
}
|
|
@@ -2355,4 +1792,4 @@ export {
|
|
|
2355
1792
|
EMAIL_WRITE_PROMPT,
|
|
2356
1793
|
EmailResource
|
|
2357
1794
|
};
|
|
2358
|
-
//# sourceMappingURL=chunk-
|
|
1795
|
+
//# sourceMappingURL=chunk-DTAY7LPC.js.map
|