@poe-platform/safe-bash 0.1.803 → 0.1.804
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 +56 -31
- package/dist/image-ast/ast.d.ts +1 -0
- package/dist/image-ast/browser/ast.d.ts +1 -0
- package/dist/image-ast/browser/codecs/jpeg.d.ts +2 -2
- package/dist/image-ast/codecs/jpeg.d.ts +2 -2
- package/dist/image-ast/index.browser.js +692 -8364
- package/dist/image-ast/index.js +692 -8364
- package/dist/mp4-ast/codecs.d.ts +7 -2
- package/dist/safe-bash/chunks/{chunk-CHYGPFVM.js → chunk-22SX3F2R.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-FBUCWVTE.js → chunk-2IVBJTBD.js} +1 -1
- package/dist/safe-bash/chunks/chunk-2POETUMB.js +190 -0
- package/dist/safe-bash/chunks/{chunk-XVOSKJE2.js → chunk-47D7WBJK.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-VKNVHEX3.js → chunk-4ESI236Y.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-74GHTNJA.js → chunk-4KTMKD5W.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-55YJASTN.js → chunk-4T53AERN.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-DQP3VHSB.js → chunk-5XIFJVOO.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-5OHX7C2V.js → chunk-62BOHHJT.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-HZAMGT5I.js → chunk-67WIFM3N.js} +17 -6
- package/dist/safe-bash/chunks/{chunk-4D4N7IU2.js → chunk-6LNFRPW5.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-6O77NL2S.js → chunk-6SMICPI3.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-4BSJLKNM.js → chunk-7O76UFQD.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PNBBUWSM.js → chunk-AW5KIT6V.js} +3488 -39
- package/dist/safe-bash/chunks/{chunk-JMMEIDPF.js → chunk-B2Z73HTZ.js} +52 -28
- package/dist/safe-bash/chunks/chunk-B3ZMOJVM.js +319 -0
- package/dist/safe-bash/chunks/{chunk-7ZBU7KYV.js → chunk-CFAWS3O4.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-I5HZ4FGE.js → chunk-CL2FCTTO.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-2LSAMQER.js → chunk-CTXNARJH.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-TFIBK2GI.js → chunk-D5Q7NFWI.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-OQRVVGR6.js → chunk-DSOOVZ6Q.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-VTH3MLDU.js → chunk-DUTAG6ZD.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-XAQMU6OY.js → chunk-EE5YGFIZ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-FZE4HW6G.js → chunk-EJOYT2ME.js} +1 -1
- package/dist/safe-bash/chunks/chunk-FAAIR6EJ.js +887 -0
- package/dist/safe-bash/chunks/{chunk-OV6IHKO6.js → chunk-FOB2FZR4.js} +2 -2
- package/dist/safe-bash/chunks/chunk-G6V4RRSQ.js +14 -0
- package/dist/safe-bash/chunks/{chunk-UTBUUFDM.js → chunk-GGQAGQXQ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-K6VCD7IY.js → chunk-HIIYIJ5G.js} +2 -4
- package/dist/safe-bash/chunks/{chunk-VBTDHOWC.js → chunk-IOHH2GTI.js} +4 -3
- package/dist/safe-bash/chunks/{chunk-CTVWDACF.js → chunk-IQW34XQT.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-HZ7BWKQ3.js → chunk-IS572AAT.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-AUSNDQTJ.js → chunk-JPSUHHOA.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-ZVD5IS4V.js → chunk-KBZ4UB2O.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-AM5ESLPH.js → chunk-KU5CVWKA.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-RYFQ3LZG.js → chunk-LPOVNKNB.js} +173 -153
- package/dist/safe-bash/chunks/{chunk-46Z5E5EV.js → chunk-MBOC3LZ4.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-6PAVEFT3.js → chunk-N4BQFD3P.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-CS4MNM6I.js → chunk-NGKCVNWS.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-7R5BDCG7.js → chunk-OHML2BEU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-C5OWC2TL.js → chunk-OQ3AGYCZ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-B7TAL7S5.js → chunk-PTAEWLSE.js} +0 -2
- package/dist/safe-bash/chunks/{chunk-LVOBFF4D.js → chunk-Q4FNLOTI.js} +1 -1
- package/dist/safe-bash/chunks/chunk-Q5XO3NAS.js +1036 -0
- package/dist/safe-bash/chunks/{chunk-GEG3BWGE.js → chunk-RHFRJIWQ.js} +1 -1
- package/dist/safe-bash/chunks/chunk-RUR6J33T.js +11 -0
- package/dist/safe-bash/chunks/{chunk-EEEWOYEG.js → chunk-S4RFUUXO.js} +839 -24
- package/dist/safe-bash/chunks/{chunk-RRR7AQ24.js → chunk-SD2ISU5L.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-3NDIFSNM.js → chunk-SUJ3NTMH.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-R3NAKOED.js → chunk-SZRUU5HS.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-PH63PLPZ.js → chunk-TC3F4UFF.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-3R3AANOR.js → chunk-TCKYOLUE.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-D3ANYGMC.js → chunk-UV4X32QU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-E7OYNDGL.js → chunk-V7QT2RWC.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-B7PIL77G.js → chunk-W2IYOVHK.js} +804 -1195
- package/dist/safe-bash/chunks/{chunk-3HQU4OJO.js → chunk-XNGVOSGI.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-J42RIHHJ.js → chunk-XQWCQSRN.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-A7XEHALN.js → chunk-Y7FW6GLT.js} +6 -6
- package/dist/safe-bash/chunks/{chunk-QGUV42T5.js → chunk-YL3GBUG4.js} +1 -1
- package/dist/safe-bash/chunks/chunk-YOXUCJER.js +389 -0
- package/dist/safe-bash/chunks/{chunk-HBCN24ZA.js → chunk-Z2AAYYJN.js} +2 -2
- package/dist/safe-bash/chunks/chunk-ZKYKJCZZ.js +30 -0
- package/dist/safe-bash/chunks/core-IE3AFIDX.js +85806 -0
- package/dist/safe-bash/chunks/{ffmpeg-WTC3TEFI.js → ffmpeg-YANDK6HU.js} +2 -2
- package/dist/safe-bash/chunks/{gh-6WU6PXL4.js → gh-4MBJ2S5V.js} +2 -2
- package/dist/safe-bash/chunks/{git-EFZIGJW4.js → git-2QONJNRQ.js} +2 -2
- package/dist/safe-bash/chunks/{imagemagick-EIEYGWPF.js → imagemagick-JLEHGYSN.js} +2 -2
- package/dist/safe-bash/chunks/{mmdc-ROQJT5HQ.js → mmdc-6LD7A6ND.js} +2 -2
- package/dist/safe-bash/chunks/{pdfimages-DW7LWXFI.js → pdfimages-RSHL7LOP.js} +2 -2
- package/dist/safe-bash/chunks/{pdfinfo-TIP6XLUQ.js → pdfinfo-L3SGWPNG.js} +2 -2
- package/dist/safe-bash/chunks/{pdftk-DMG22ITZ.js → pdftk-LFBJNU5A.js} +2 -2
- package/dist/safe-bash/chunks/{pdftoppm-WNDYR72T.js → pdftoppm-NXXFUIHG.js} +2 -2
- package/dist/safe-bash/chunks/{pdftotext-5IPZ4NI7.js → pdftotext-4IHNWT6F.js} +2 -2
- package/dist/safe-bash/chunks/{qpdf-TTX2DIUA.js → qpdf-ZEIREV63.js} +2 -2
- package/dist/safe-bash/chunks/read-builtin-A4QKAT45.js +9 -0
- package/dist/safe-bash/chunks/{sips-XYS46JPJ.js → sips-D5YBG2V3.js} +2 -2
- package/dist/safe-bash/chunks/{soffice-TU73E5KL.js → soffice-RAJU3JUT.js} +2 -2
- package/dist/safe-bash/chunks/source-files-3XWRRHFA.js +7 -0
- package/dist/safe-bash/chunks/{wkhtmltopdf-FSZ2CHGE.js → wkhtmltopdf-7UE4FORZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-7KWZXKY6.js → chunk-26RTBV2I.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-AQJ2ROJO.js → chunk-2WYNMZR2.js} +10 -8
- package/dist/safe-bash/command-chunks/{chunk-BDSMROQZ.js → chunk-36GFRF2N.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-GC5TJZOF.js → chunk-3VIA2IA7.js} +114 -31
- package/dist/safe-bash/command-chunks/{chunk-NKFYQSES.js → chunk-4CTI3ZTX.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-WH627NJL.js → chunk-4MYP2FX4.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-ZDN7MJE6.js → chunk-4R5ADJM5.js} +11 -1
- package/dist/safe-bash/command-chunks/{chunk-P2N33UMN.js → chunk-5MIKM54M.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DB453IE6.js → chunk-6FZQUOSJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-PICVQ6B5.js → chunk-6GKYHPJG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-7K6JYKPJ.js → chunk-6M2ELGEN.js} +17 -15
- package/dist/safe-bash/command-chunks/{chunk-PXEIT2O4.js → chunk-6UR7V3ET.js} +8 -1
- package/dist/safe-bash/command-chunks/{chunk-6KJ3LPI2.js → chunk-6XBS5B46.js} +26 -3
- package/dist/safe-bash/command-chunks/{chunk-5PWJG2UK.js → chunk-6YXLZX7L.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-EK6YNAXT.js → chunk-753YOR54.js} +31 -5
- package/dist/safe-bash/command-chunks/{chunk-RMWQAAO5.js → chunk-7IR4NRNE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-FZTK4MFI.js → chunk-7NM73SVK.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-NXEQ3ESQ.js → chunk-7QD5YY4F.js} +6 -11
- package/dist/safe-bash/command-chunks/{chunk-EMPU65ZK.js → chunk-A5LBSJGH.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-4FEVBOL5.js → chunk-ARZMP2L2.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-NKIELG7Y.js → chunk-BAKFZ477.js} +40 -19
- package/dist/safe-bash/command-chunks/{chunk-QRRYN2KO.js → chunk-BC7BK6R6.js} +0 -2424
- package/dist/safe-bash/command-chunks/{chunk-CQHP3I66.js → chunk-BOEOJS2Q.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XS72HTMA.js → chunk-BWGGLYEB.js} +5 -22
- package/dist/safe-bash/command-chunks/{chunk-PMBFZXTK.js → chunk-C5ZZKP7V.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-LHIOAFWW.js → chunk-C7SEB6WU.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XPT2UGBF.js → chunk-CHJKFRT7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TIOCQVUQ.js → chunk-CON26Q2O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-E55UKBIE.js → chunk-DBAT3IK2.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z45N42QC.js → chunk-DPAYAVMS.js} +15 -1
- package/dist/safe-bash/command-chunks/chunk-DS3NXVUM.js +368 -0
- package/dist/safe-bash/command-chunks/{chunk-5ZMZ573Q.js → chunk-DSJ3VRL3.js} +16 -4
- package/dist/safe-bash/command-chunks/{chunk-K2GDEMEU.js → chunk-EFRCFWVR.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DZCY63VJ.js → chunk-EV6HIJ5H.js} +6 -5
- package/dist/safe-bash/command-chunks/{chunk-JDYXY44P.js → chunk-FJURV46Y.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-TZZ4WUKH.js → chunk-FZAWGKSE.js} +6 -4
- package/dist/safe-bash/command-chunks/{chunk-YHFXOX6U.js → chunk-GOCFQ6XV.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-QVOS4YXL.js → chunk-HH5O7DJI.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3HHCU5YU.js → chunk-HK7F5SDC.js} +13 -0
- package/dist/safe-bash/command-chunks/{chunk-JNZ3CVAE.js → chunk-HQBXIZC7.js} +8 -3
- package/dist/safe-bash/command-chunks/{chunk-V4K2JDYU.js → chunk-I63DBZXZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-WNE7FPVR.js → chunk-I64TLTIW.js} +24 -16
- package/dist/safe-bash/command-chunks/{chunk-GFC2NTDG.js → chunk-ICANWOXH.js} +5 -29
- package/dist/safe-bash/command-chunks/{chunk-SQRQW3CT.js → chunk-IJ6LGLXM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TGSNCQSR.js → chunk-JT4RYCA6.js} +1771 -1663
- package/dist/safe-bash/command-chunks/{chunk-II77KPZN.js → chunk-JWW6FYBN.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-ZYXH3B66.js → chunk-LCJWKTCJ.js} +250 -203
- package/dist/safe-bash/command-chunks/chunk-LU4HBPP2.js +97 -0
- package/dist/safe-bash/command-chunks/{chunk-XJXU3VVH.js → chunk-LWOE65OE.js} +20 -5
- package/dist/safe-bash/command-chunks/{chunk-GMIHJYDG.js → chunk-M32HFSX7.js} +22 -6
- package/dist/safe-bash/command-chunks/{chunk-YG4EPFWC.js → chunk-M3NINRDU.js} +2880 -172
- package/dist/safe-bash/command-chunks/chunk-MQREDAL6.js +164 -0
- package/dist/safe-bash/command-chunks/{chunk-LWS62ISU.js → chunk-N6DIASO2.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-NGL7YK7O.js +188 -0
- package/dist/safe-bash/command-chunks/{chunk-EARHPPPJ.js → chunk-NJYHWKIL.js} +39 -9
- package/dist/safe-bash/command-chunks/{chunk-6JSIFWYT.js → chunk-OJQRSCBP.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-OQU6UT6X.js → chunk-OV3XREFN.js} +11 -0
- package/dist/safe-bash/command-chunks/{chunk-MIXBO6U7.js → chunk-PTZLF456.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-ALDC4XP4.js → chunk-QILLRNES.js} +34 -10
- package/dist/safe-bash/command-chunks/{chunk-L22T3H7L.js → chunk-QR25JLKO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-NASVPT6F.js → chunk-R7C4MGZ5.js} +17 -224
- package/dist/safe-bash/command-chunks/{chunk-LCF3OB7P.js → chunk-RBME3JEH.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2KG2QLJE.js → chunk-RFWGYT7G.js} +3 -0
- package/dist/safe-bash/command-chunks/{chunk-5TBUOBDE.js → chunk-RZMVRT26.js} +27 -13
- package/dist/safe-bash/command-chunks/chunk-TFR6B3WB.js +44 -0
- package/dist/safe-bash/command-chunks/chunk-TOH3OF3O.js +179 -0
- package/dist/safe-bash/command-chunks/chunk-TT4DAFBT.js +13621 -0
- package/dist/safe-bash/command-chunks/{chunk-LWSBAWLT.js → chunk-TXI64OAG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GIRNFXP3.js → chunk-TZRI7BJZ.js} +45 -15
- package/dist/safe-bash/command-chunks/{chunk-QOKBZFFD.js → chunk-U3MMODA5.js} +2 -7
- package/dist/safe-bash/command-chunks/{chunk-ZYHTWNAE.js → chunk-UAW423ZL.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-C5YYCQHW.js → chunk-UXEEUGOV.js} +222 -12
- package/dist/safe-bash/command-chunks/{chunk-GY3BWK7K.js → chunk-VOZPMJRX.js} +87 -80
- package/dist/safe-bash/command-chunks/{chunk-ILX2NOLF.js → chunk-WPANOB4A.js} +20 -20
- package/dist/safe-bash/command-chunks/{chunk-Y2WBSJG6.js → chunk-X4QZQI5Q.js} +65 -64
- package/dist/safe-bash/command-chunks/{chunk-HDCNKOIX.js → chunk-XGI57GCN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5UBXNSFZ.js → chunk-XUCU7QQT.js} +1281 -1278
- package/dist/safe-bash/command-chunks/chunk-Y22VXJBD.js +296 -0
- package/dist/safe-bash/command-chunks/{chunk-WVHONVZ4.js → chunk-YMFUUPDX.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-IR2BY7EL.js → chunk-YYGIBXFZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-MSFXC3OC.js → chunk-Z4FO6OHE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-WWIBP2ET.js → chunk-Z5ZZVDUD.js} +143 -22
- package/dist/safe-bash/command-chunks/{chunk-LOICUCHG.js → chunk-ZHN3QDCI.js} +1 -1
- package/dist/safe-bash/commands/alias/index.d.ts +2 -0
- package/dist/safe-bash/commands/alias/index.js +2 -0
- package/dist/safe-bash/commands/apply-patch/index.browser.js +2 -3
- package/dist/safe-bash/commands/apply-patch/index.d.ts +0 -1
- package/dist/safe-bash/commands/apply-patch/index.js +0 -1
- package/dist/safe-bash/commands/archive/index.browser.js +2 -3
- package/dist/safe-bash/commands/archive/index.d.ts +0 -1
- package/dist/safe-bash/commands/archive/index.js +0 -1
- package/dist/safe-bash/commands/bytes/index.js +2 -1
- package/dist/safe-bash/commands/chmod/index.browser.js +1 -1
- package/dist/safe-bash/commands/column/index.browser.js +2 -3
- package/dist/safe-bash/commands/column/index.d.ts +0 -1
- package/dist/safe-bash/commands/column/index.js +0 -1
- package/dist/safe-bash/commands/copy-source.js +1 -0
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/csvkit/index.browser.js +72 -0
- package/dist/safe-bash/commands/csvkit/index.d.ts +0 -5
- package/dist/safe-bash/commands/csvkit/index.js +0 -50
- package/dist/safe-bash/commands/docx/index.browser.js +5 -7
- package/dist/safe-bash/commands/du/index.browser.js +2 -3
- package/dist/safe-bash/commands/du/index.d.ts +0 -1
- package/dist/safe-bash/commands/du/index.js +0 -1
- package/dist/safe-bash/commands/expr/index.browser.js +2 -3
- package/dist/safe-bash/commands/expr/index.d.ts +0 -1
- package/dist/safe-bash/commands/expr/index.js +0 -1
- package/dist/safe-bash/commands/factor/index.browser.js +2 -2
- package/dist/safe-bash/commands/file/index.browser.js +2 -3
- package/dist/safe-bash/commands/file/index.d.ts +0 -1
- package/dist/safe-bash/commands/file/index.js +0 -1
- package/dist/safe-bash/commands/filesystem.js +1 -1
- package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
- package/dist/safe-bash/commands/grep-aliases/index.browser.js +3 -3
- package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
- package/dist/safe-bash/commands/html-to-markdown/index.browser.js +2 -3
- package/dist/safe-bash/commands/html-to-markdown/index.d.ts +0 -1
- package/dist/safe-bash/commands/html-to-markdown/index.js +0 -1
- package/dist/safe-bash/commands/htmlq/index.d.ts +1 -5
- package/dist/safe-bash/commands/htmlq/index.js +1 -143
- package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
- package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
- package/dist/safe-bash/commands/media/index.browser.js +4 -16314
- package/dist/safe-bash/commands/media/index.d.ts +1 -5
- package/dist/safe-bash/commands/media/index.js +1 -3
- package/dist/safe-bash/commands/media/plugin.d.ts +1 -18
- package/dist/safe-bash/commands/media/plugin.js +1 -90
- package/dist/safe-bash/commands/media/remote.d.ts +1 -63
- package/dist/safe-bash/commands/media/remote.js +1 -405
- package/dist/safe-bash/commands/media/settings.d.ts +1 -4
- package/dist/safe-bash/commands/media/settings.js +1 -26
- package/dist/safe-bash/commands/metadata/index.browser.js +3 -4
- package/dist/safe-bash/commands/metadata/index.d.ts +0 -1
- package/dist/safe-bash/commands/metadata/index.js +2 -2
- package/dist/safe-bash/commands/mktemp/index.browser.js +1 -1
- package/dist/safe-bash/commands/network/curl.js +1 -3
- package/dist/safe-bash/commands/network/index.browser.js +3 -4
- package/dist/safe-bash/commands/network/public.d.ts +0 -1
- package/dist/safe-bash/commands/network/public.js +0 -1
- package/dist/safe-bash/commands/network/transport.js +2 -1
- package/dist/safe-bash/commands/network/wget.js +1 -3
- package/dist/safe-bash/commands/node/browser.d.ts +0 -1
- package/dist/safe-bash/commands/node/browser.js +0 -1
- package/dist/safe-bash/commands/node/default-runtime.d.ts +3 -0
- package/dist/safe-bash/commands/node/default-runtime.js +15 -0
- package/dist/safe-bash/commands/node/index.browser.js +7 -8
- package/dist/safe-bash/commands/node/index.js +3 -3
- package/dist/safe-bash/commands/node/path.js +1 -1
- package/dist/safe-bash/commands/node/preload.d.ts +1 -1
- package/dist/safe-bash/commands/node/preload.js +4 -1
- package/dist/safe-bash/commands/node/quickjs.d.ts +2 -0
- package/dist/safe-bash/commands/node/quickjs.js +2 -0
- package/dist/safe-bash/commands/node/safejs.js +26 -12
- package/dist/safe-bash/commands/op/index.browser.js +2 -3
- package/dist/safe-bash/commands/op/index.d.ts +0 -11
- package/dist/safe-bash/commands/op/index.js +0 -84
- package/dist/safe-bash/commands/pandoc/index.browser.js +44 -0
- package/dist/safe-bash/commands/pandoc/index.d.ts +0 -1
- package/dist/safe-bash/commands/pandoc/index.js +0 -1
- package/dist/safe-bash/commands/pr/index.browser.js +2 -2
- package/dist/safe-bash/commands/python/docker-runner.js +4 -3
- package/dist/safe-bash/commands/python/docker.d.ts +1 -0
- package/dist/safe-bash/commands/python/docker.js +5 -2
- package/dist/safe-bash/commands/python/index.browser.js +17 -13
- package/dist/safe-bash/commands/python/index.d.ts +2 -1
- package/dist/safe-bash/commands/python/index.js +10 -8
- package/dist/safe-bash/commands/python/llm-capability.js +65 -2
- package/dist/safe-bash/commands/python/llm-dependencies.d.ts +27 -0
- package/dist/safe-bash/commands/python/llm-dependencies.js +66 -0
- package/dist/safe-bash/commands/python/llm-module.js +6 -4
- package/dist/safe-bash/commands/python/llm-reference-module.d.ts +3 -0
- package/dist/safe-bash/commands/python/llm-reference-module.js +690 -0
- package/dist/safe-bash/commands/python/worker.browser.js +2 -3
- package/dist/safe-bash/commands/python/worker.d.ts +0 -1
- package/dist/safe-bash/commands/python/worker.js +0 -1
- package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.d.ts +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.js +3 -3
- package/dist/safe-bash/commands/regex-execution/public.browser.js +7 -7
- package/dist/safe-bash/commands/safejs/options.js +5 -1
- package/dist/safe-bash/commands/safejs/runtime.d.ts +1 -0
- package/dist/safe-bash/commands/safejs/runtime.js +1 -1
- package/dist/safe-bash/commands/split/index.browser.js +2 -3
- package/dist/safe-bash/commands/split/index.d.ts +0 -1
- package/dist/safe-bash/commands/split/index.js +0 -1
- package/dist/safe-bash/commands/ssconvert/index.browser.js +98 -0
- package/dist/safe-bash/commands/stat/index.browser.js +1 -1
- package/dist/safe-bash/commands/stream-format/index.browser.js +3 -4
- package/dist/safe-bash/commands/stream-format/index.d.ts +0 -1
- package/dist/safe-bash/commands/stream-format/index.js +0 -1
- package/dist/safe-bash/commands/stream-inspection/index.browser.js +3 -4
- package/dist/safe-bash/commands/stream-inspection/index.d.ts +0 -1
- package/dist/safe-bash/commands/stream-inspection/index.js +0 -1
- package/dist/safe-bash/commands/streams.js +2 -1
- package/dist/safe-bash/commands/table-text/index.browser.js +3 -4
- package/dist/safe-bash/commands/table-text/index.d.ts +0 -1
- package/dist/safe-bash/commands/table-text/index.js +0 -1
- package/dist/safe-bash/commands/text.js +28 -24
- package/dist/safe-bash/commands/time-env/index.browser.js +3 -4
- package/dist/safe-bash/commands/time-env/index.d.ts +0 -1
- package/dist/safe-bash/commands/time-env/index.js +0 -1
- package/dist/safe-bash/commands/tree/index.browser.js +2 -3
- package/dist/safe-bash/commands/tree/index.d.ts +0 -1
- package/dist/safe-bash/commands/tree/index.js +0 -1
- package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
- package/dist/safe-bash/commands/unalias/index.d.ts +2 -0
- package/dist/safe-bash/commands/unalias/index.js +2 -0
- package/dist/safe-bash/commands/xml/index.browser.js +2 -2
- package/dist/safe-bash/commands/yq/index.browser.js +2 -2
- package/dist/safe-bash/core.browser.js +2 -2
- package/dist/safe-bash/core.d.ts +7 -1
- package/dist/safe-bash/core.js +7 -1
- package/dist/safe-bash/execution-runtime.js +2 -1
- package/dist/safe-bash/fs/s3/http/index.d.ts +2 -2
- package/dist/safe-bash/fs/s3/http/index.js +1 -1
- package/dist/safe-bash/full-core.browser.js +283 -945
- package/dist/safe-bash/internal/op/types.d.ts +1 -0
- package/dist/safe-bash/jobs.browser.js +5 -5
- package/dist/safe-bash/lazy-optional.d.ts +3 -3
- package/dist/safe-bash/lazy-optional.js +1 -1
- package/dist/safe-bash/opt-in/commands/cmp/index.js +7 -6
- package/dist/safe-bash/opt-in/commands/dd/index.js +1 -1
- package/dist/safe-bash/opt-in/commands/dd/io.js +51 -5
- package/dist/safe-bash/opt-in/commands/truncate/index.js +2 -2
- package/dist/safe-bash/opt-in/commands/yq/native-work.js +2 -0
- package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +2 -1
- package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +4 -2
- package/dist/safe-bash/opt-in/optional.d.ts +1 -1
- package/dist/safe-bash/opt-in/optional.js +1 -1
- package/dist/safe-bash/opt-in/shell/extensions/read/index.js +2 -344
- package/dist/safe-bash/optional-host.browser.js +23 -18
- package/dist/safe-bash/optional-host.d.ts +1 -0
- package/dist/safe-bash/optional-host.js +1 -0
- package/dist/safe-bash/playwright/controller.js +41 -3
- package/dist/safe-bash/playwright/native-storage-targets.js +4 -2
- package/dist/safe-bash/plugins/base.d.ts +1 -1
- package/dist/safe-bash/plugins/base.js +3 -3
- package/dist/safe-bash/plugins/composition.d.ts +5 -2
- package/dist/safe-bash/plugins/composition.js +10 -7
- package/dist/safe-bash/plugins/index.browser.js +44 -41
- package/dist/safe-bash/plugins/index.js +3 -2
- package/dist/safe-bash/plugins/portable-commands.d.ts +3 -0
- package/dist/safe-bash/plugins/portable-commands.js +31 -0
- package/dist/safe-bash/registry-entry.browser.js +41 -42
- package/dist/safe-bash/search.browser.js +32 -33
- package/dist/safe-bash/shell/arithmetic.js +19 -6
- package/dist/safe-bash/shell/arrays/state.js +1 -1
- package/dist/safe-bash/shell/arrays/syntax.js +4 -3
- package/dist/safe-bash/shell/index.d.ts +0 -1
- package/dist/safe-bash/shell/index.js +0 -1
- package/dist/safe-bash/shell/parser.d.ts +2 -2
- package/dist/safe-bash/shell/parser.js +268 -64
- package/dist/safe-bash/shell/read-builtin.d.ts +3 -0
- package/dist/safe-bash/shell/read-builtin.js +344 -0
- package/dist/safe-bash/shell/runtime.d.ts +21 -4
- package/dist/safe-bash/shell/runtime.js +373 -412
- package/dist/safe-bash/shell/session-state.js +25 -0
- package/dist/safe-bash/shell/shell.js +76 -154
- package/dist/safe-bash/shell/tilde-expansion.d.ts +1 -1
- package/dist/safe-bash/shell/tilde-expansion.js +2 -2
- package/dist/safe-bash/shell/types.d.ts +5 -0
- package/dist/safe-bash/shell/value-state.js +1 -1
- package/dist/safe-bash/shell-entry.browser.js +32 -33
- package/dist/safe-bash/trap.browser.js +4 -4
- package/dist/safe-bash/yq-browser/index.js +1 -1
- package/dist/safe-bash-calendar-engine/time-env/calendar.d.ts +1 -1
- package/dist/safe-bash-calendar-engine/time-env/calendar.js +1 -1
- package/dist/safe-bash-calendar-engine/time-env/format.js +1 -1
- package/dist/safe-bash-command-alias/index.d.ts +13 -0
- package/dist/safe-bash-command-alias/index.js +88 -0
- package/dist/safe-bash-command-apply-patch/apply.js +3 -3
- package/dist/safe-bash-command-apply-patch/index.js +3 -3
- package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
- package/dist/safe-bash-command-apply-patch/parser.js +1 -1
- package/dist/safe-bash-command-awk/awk-pipes.js +2 -2
- package/dist/safe-bash-command-awk/awk-reader.js +1 -1
- package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
- package/dist/safe-bash-command-awk/awk.js +5 -5
- package/dist/safe-bash-command-awk/index.js +5 -5
- package/dist/safe-bash-command-bc/index.js +206 -60
- package/dist/safe-bash-command-cmp/index.js +7 -6
- package/dist/safe-bash-command-column/column.js +3 -3
- package/dist/safe-bash-command-column/index.js +3 -3
- package/dist/safe-bash-command-column/layout.js +2 -2
- package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/index.js +1505 -7
- package/dist/safe-bash-command-csvkit/sync-support.js +2 -7
- package/dist/safe-bash-command-curl/curl.js +1 -1
- package/dist/safe-bash-command-curl/index.js +1 -1
- package/dist/safe-bash-command-date/date.js +1 -1
- package/dist/safe-bash-command-date/index.js +1 -1
- package/dist/safe-bash-command-dd/index.js +1 -1
- package/dist/safe-bash-command-dd/io.js +51 -5
- package/dist/safe-bash-command-diff/diff.js +1 -1
- package/dist/safe-bash-command-diff/index.js +1 -1
- package/dist/safe-bash-command-diff3/index.js +10 -13
- package/dist/safe-bash-command-exiftool/index.js +278 -50
- package/dist/safe-bash-command-exiftool/registry.d.ts +4 -2
- package/dist/safe-bash-command-factor/command.js +2 -2
- package/dist/safe-bash-command-factor/index.js +2 -2
- package/dist/safe-bash-command-fd/arguments.d.ts +2 -0
- package/dist/safe-bash-command-fd/index.js +42 -12
- package/dist/safe-bash-command-ffmpeg/index.js +356 -66
- package/dist/safe-bash-command-find/find-format.d.ts +3 -0
- package/dist/safe-bash-command-find/find-format.js +1 -1
- package/dist/safe-bash-command-find/find.js +2 -2
- package/dist/safe-bash-command-find/index.js +2 -2
- package/dist/safe-bash-command-fmt/index.js +1 -4
- package/dist/safe-bash-command-fold/engine.d.ts +1 -1
- package/dist/safe-bash-command-fold/family.js +2 -2
- package/dist/safe-bash-command-fold/index.js +1 -1
- package/dist/safe-bash-command-hexdump/command.js +2 -2
- package/dist/safe-bash-command-hexdump/index.js +2 -2
- package/dist/safe-bash-command-html-to-markdown/entities.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/index.js +4 -4
- package/dist/safe-bash-command-html-to-markdown/input.js +3 -3
- package/dist/safe-bash-command-html-to-markdown/parser.js +2 -2
- package/dist/safe-bash-command-html-to-markdown/render.js +3 -3
- package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -2
- package/dist/safe-bash-command-htmlq/index.d.ts +2 -1
- package/dist/safe-bash-command-htmlq/index.js +175 -49
- package/dist/safe-bash-command-htmlq/sync.d.ts +1 -0
- package/dist/safe-bash-command-imagemagick/index.js +56 -6
- package/dist/safe-bash-command-install/arguments.d.ts +27 -0
- package/dist/safe-bash-command-install/arguments.js +224 -0
- package/dist/safe-bash-command-install/index.d.ts +7 -0
- package/dist/safe-bash-command-install/index.js +942 -0
- package/dist/safe-bash-command-install/mode.d.ts +6 -0
- package/dist/safe-bash-command-install/mode.js +71 -0
- package/dist/safe-bash-command-install/options.d.ts +40 -0
- package/dist/safe-bash-command-install/options.js +27 -0
- package/dist/safe-bash-command-jq/index.js +1 -1
- package/dist/safe-bash-command-jq/jq.js +1 -1
- package/dist/safe-bash-command-less/index.js +37 -61
- package/dist/safe-bash-command-llm/command.js +1 -1
- package/dist/safe-bash-command-llm/elevenlabs.js +2 -2
- package/dist/safe-bash-command-llm/index.js +4 -4
- package/dist/safe-bash-command-llm/openai.js +2 -2
- package/dist/safe-bash-command-llm/providers/elevenlabs.js +2 -2
- package/dist/safe-bash-command-llm/providers/index.js +3 -3
- package/dist/safe-bash-command-llm/providers/openai.js +2 -2
- package/dist/safe-bash-command-llm/providers/shared.js +1 -1
- package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.browser.d.ts +463 -46
- package/dist/safe-bash-command-mcp/index.browser.js +19308 -0
- package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.d.ts +15 -6
- package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.js +2804 -2771
- package/dist/safe-bash-command-media/LICENSE +21 -0
- package/dist/safe-bash-command-media/index.d.ts +6 -0
- package/dist/safe-bash-command-media/index.js +30 -0
- package/dist/safe-bash-command-media/plugin.d.ts +18 -0
- package/dist/safe-bash-command-media/plugin.js +11 -0
- package/dist/safe-bash-command-media/remote.d.ts +63 -0
- package/dist/safe-bash-command-media/remote.js +11 -0
- package/dist/safe-bash-command-media/settings.d.ts +4 -0
- package/dist/safe-bash-command-media/settings.js +41 -0
- package/dist/safe-bash-command-mktemp/command.js +1 -1
- package/dist/safe-bash-command-mktemp/index.js +1 -1
- package/dist/safe-bash-command-mmdc/arguments.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/command.d.ts +2 -0
- package/dist/safe-bash-command-mmdc/contracts.d.ts +8 -1
- package/dist/safe-bash-command-mmdc/index.js +359 -7
- package/dist/safe-bash-command-nl/index.js +1 -1
- package/dist/safe-bash-command-nl/nl.js +1 -1
- package/dist/safe-bash-command-node/LICENSE +21 -0
- package/dist/safe-bash-command-node/index.d.ts +17 -0
- package/dist/safe-bash-command-node/index.js +328 -0
- package/dist/safe-bash-command-numfmt/index.js +1 -0
- package/dist/safe-bash-command-od/index.js +10 -6
- package/dist/safe-bash-command-op/index.js +39 -32
- package/dist/safe-bash-command-op/types.d.ts +1 -0
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.d.ts +1 -0
- package/dist/safe-bash-command-pandoc/index.js +5 -3
- package/dist/safe-bash-command-pandoc/sync.d.ts +1 -0
- package/dist/safe-bash-command-patch/index.js +4 -4
- package/dist/safe-bash-command-patch/patch.js +4 -4
- package/dist/safe-bash-command-pdfimages/index.js +1 -1
- package/dist/safe-bash-command-pdfinfo/index.js +30 -5
- package/dist/safe-bash-command-pdftk/index.js +21 -23
- package/dist/safe-bash-command-pdftoppm/index.js +17 -4
- package/dist/safe-bash-command-pdftotext/index.js +11 -14
- package/dist/safe-bash-command-qpdf/index.d.ts +1 -0
- package/dist/safe-bash-command-qpdf/index.js +9 -6
- package/dist/safe-bash-command-rg/index.js +1 -1
- package/dist/safe-bash-command-rg/rg-command.js +1 -1
- package/dist/safe-bash-command-sed/index.js +1 -1
- package/dist/safe-bash-command-sed/sed.js +1 -1
- package/dist/safe-bash-command-shuf/input.d.ts +2 -2
- package/dist/safe-bash-command-shuf/input.js +2 -1
- package/dist/safe-bash-command-shuf/shuf.js +4 -2
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +97 -12
- package/dist/safe-bash-command-sponge/index.js +4 -1
- package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/index.js +510 -70
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +2 -2
- package/dist/safe-bash-command-ssconvert/index.js +44 -22
- package/dist/safe-bash-command-stat/command.js +1 -1
- package/dist/safe-bash-command-stat/index.js +1 -1
- package/dist/safe-bash-command-tar/create.d.ts +1 -0
- package/dist/safe-bash-command-tar/create.js +2 -2
- package/dist/safe-bash-command-tar/extract.js +2 -2
- package/dist/safe-bash-command-tar/index.js +4 -4
- package/dist/safe-bash-command-tar/modes.js +4 -4
- package/dist/safe-bash-command-tar/options.js +1 -1
- package/dist/safe-bash-command-truncate/index.js +2 -2
- package/dist/safe-bash-command-tsort/command.js +2 -2
- package/dist/safe-bash-command-tsort/index.js +2 -2
- package/dist/safe-bash-command-unalias/index.d.ts +12 -0
- package/dist/safe-bash-command-unalias/index.js +67 -0
- package/dist/safe-bash-command-unrtf/index.js +26 -4
- package/dist/safe-bash-command-xan/argv.d.ts +1 -1
- package/dist/safe-bash-command-xan/argv.js +2 -2
- package/dist/safe-bash-command-xan/budget.d.ts +0 -1
- package/dist/safe-bash-command-xan/budget.js +1 -1
- package/dist/safe-bash-command-xan/commands.js +6 -6
- package/dist/safe-bash-command-xan/csv.js +2 -2
- package/dist/safe-bash-command-xan/index.js +8 -9
- package/dist/safe-bash-command-xan/io.js +4 -4
- package/dist/safe-bash-command-xan/options.js +1 -1
- package/dist/safe-bash-command-xan/selector.js +2 -2
- package/dist/safe-bash-command-xmllint/index.js +45 -23
- package/dist/safe-bash-command-xxd/index.js +41 -10
- package/dist/safe-bash-command-yq/accounting.js +1 -1
- package/dist/safe-bash-command-yq/index.js +3 -2
- package/dist/safe-bash-command-yq/native-work.js +2 -0
- package/dist/safe-bash-command-yq/parser.js +2 -2
- package/dist/safe-bash-command-yq/query.js +5 -5
- package/dist/safe-bash-command-yq/toml.js +2 -2
- package/dist/safe-bash-command-zip/index.js +3 -3
- package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
- package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
- package/dist/safe-bash-compression-engine/files.js +5 -5
- package/dist/safe-bash-compression-engine/index.js +4 -4
- package/dist/safe-bash-compression-engine/operand.js +5 -5
- package/dist/safe-bash-compression-engine/stream.js +4 -4
- package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
- package/dist/safe-bash-contracts/command.js +3 -3
- package/dist/safe-bash-contracts/default-executor.js +2 -2
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +6 -6
- package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
- package/dist/safe-bash-contracts/filesystem-output.js +5 -5
- package/dist/safe-bash-contracts/http.d.ts +7 -0
- package/dist/safe-bash-contracts/index.js +8 -8
- package/dist/safe-bash-contracts/io.js +2 -2
- package/dist/safe-bash-contracts/output.js +3 -3
- package/dist/safe-bash-contracts/runtime-control.d.ts +2 -2
- package/dist/safe-bash-contracts/runtime-control.js +4 -2
- package/dist/safe-bash-contracts/signals.d.ts +2 -0
- package/dist/safe-bash-contracts/signals.js +3 -1
- package/dist/safe-bash-contracts/yield.js +1 -1
- package/dist/safe-bash-csv-engine/index.d.ts +2 -1
- package/dist/safe-bash-csv-engine/index.js +21 -15
- package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +6 -6
- package/dist/safe-bash-io-engine/internal.js +1 -1
- package/dist/safe-bash-io-engine/shell/pattern.js +38 -18
- package/dist/safe-bash-line-ending-engine/convert.js +9 -204
- package/dist/safe-bash-line-ending-engine/encoding.js +9 -42
- package/dist/safe-bash-line-ending-engine/index.js +48 -0
- package/dist/safe-bash-line-ending-engine/info.js +9 -90
- package/dist/safe-bash-line-ending-engine/internal.js +15 -160
- package/dist/safe-bash-line-ending-engine/io.js +12 -289
- package/dist/safe-bash-line-ending-engine/stage.js +10 -160
- package/dist/safe-bash-markdown-engine/index.js +3 -3
- package/dist/safe-bash-network-engine/args.d.ts +6 -0
- package/dist/safe-bash-network-engine/args.js +4 -2
- package/dist/safe-bash-network-engine/body.js +1 -1
- package/dist/safe-bash-network-engine/fetch-transport.js +3 -1
- package/dist/safe-bash-network-engine/index.js +3 -1
- package/dist/safe-bash-network-engine/input.js +2 -2
- package/dist/safe-bash-network-engine/platform-portable.js +3 -1
- package/dist/safe-bash-query-engine/dates.d.ts +1 -1
- package/dist/safe-bash-query-engine/dates.js +1 -1
- package/dist/safe-bash-query-engine/index.js +6 -6
- package/dist/safe-bash-query-engine/interpreter.js +4 -4
- package/dist/safe-bash-query-engine/parser.js +1 -1
- package/dist/safe-bash-query-engine/query-core.js +6 -6
- package/dist/safe-bash-regex-engine/execution/bounded-provider.js +10 -0
- package/dist/safe-bash-regex-engine/index.js +1 -1
- package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -1
- package/dist/safe-bash-regex-engine/text/regex.js +1 -1
- package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +1 -0
- package/dist/safe-bash-search-engine/ergonomic-regex.js +1 -1
- package/dist/safe-bash-search-engine/grep.js +16 -9
- package/dist/safe-bash-search-engine/matcher.d.ts +2 -2
- package/dist/safe-bash-search-engine/matcher.js +12 -8
- package/dist/safe-bash-search-engine/shared.js +1 -1
- package/dist/safe-bash-search-engine/walk.js +13 -1
- package/dist/safe-bash-text-stream-engine/stream-format/shared.d.ts +1 -1
- package/dist/safe-bash-text-stream-engine/stream-format/shared.js +2 -1
- package/dist/safe-bash-xml-engine/document.js +3 -3
- package/dist/safe-bash-xml-engine/evaluate.js +2 -2
- package/dist/safe-bash-xml-engine/index.js +4 -4
- package/dist/safe-bash-xml-engine/io.js +7 -2
- package/dist/safe-bash-xml-engine/limits.d.ts +0 -2
- package/dist/safe-bash-xml-engine/limits.js +1 -1
- package/dist/safe-bash-xml-engine/query.js +3 -3
- package/dist/safe-bash-zip-engine/index.js +3 -3
- package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
- package/dist/safe-bash-zip-engine/zip/safety.js +1 -1
- package/dist/safe-bash-zip-engine/zip/sfx.js +3 -3
- package/dist/safe-bash-zip-engine/zip/volumes.js +1 -1
- package/dist/safe-bash-zip-engine/zip-format.js +3 -3
- package/dist/safe-playwright-cloudflare/browser-socket-closure.js +18 -3
- package/dist/safe-playwright-cloudflare/shell-browser-resource.js +1 -1
- package/dist/xlsx-ast/xlsx.js +6 -5
- package/package.json +86 -98
- package/dist/media-cli/bytes.d.ts +0 -8
- package/dist/media-cli/bytes.js +0 -40
- package/dist/media-cli/concat.d.ts +0 -30
- package/dist/media-cli/concat.js +0 -197
- package/dist/media-cli/content.js +0 -66
- package/dist/media-cli/dependency-grammars.d.ts +0 -12
- package/dist/media-cli/dependency-grammars.js +0 -557
- package/dist/media-cli/discover.js +0 -286
- package/dist/media-cli/engine.js +0 -190
- package/dist/media-cli/filename-expression.js +0 -147
- package/dist/media-cli/filesystem.js +0 -35
- package/dist/media-cli/frontend-contract.js +0 -8
- package/dist/media-cli/frontend-issues.d.ts +0 -6
- package/dist/media-cli/frontend-issues.js +0 -9
- package/dist/media-cli/imagemagick-operand.d.ts +0 -42
- package/dist/media-cli/imagemagick-operand.js +0 -229
- package/dist/media-cli/imagemagick-references.d.ts +0 -7
- package/dist/media-cli/imagemagick-references.js +0 -42
- package/dist/media-cli/imagemagick.generated.js +0 -3254
- package/dist/media-cli/imagemagick.js +0 -615
- package/dist/media-cli/index.js +0 -12
- package/dist/media-cli/mvg.d.ts +0 -10
- package/dist/media-cli/mvg.js +0 -102
- package/dist/media-cli/network.js +0 -78
- package/dist/media-cli/options.generated.js +0 -3312
- package/dist/media-cli/preset.d.ts +0 -11
- package/dist/media-cli/preset.js +0 -57
- package/dist/media-cli/resolution-path.d.ts +0 -23
- package/dist/media-cli/resolution-path.js +0 -217
- package/dist/media-cli/resolver.js +0 -494
- package/dist/media-cli/resources.d.ts +0 -16
- package/dist/media-cli/resources.js +0 -187
- package/dist/media-cli/shim.js +0 -52
- package/dist/media-cli/tee.d.ts +0 -6
- package/dist/media-cli/tee.js +0 -38
- package/dist/office-package/zip-sync.js +0 -111
- package/dist/remote-execution/binary.js +0 -178
- package/dist/remote-execution/callback-result.js +0 -26
- package/dist/remote-execution/canonical-capabilities.d.ts +0 -5
- package/dist/remote-execution/canonical-capabilities.js +0 -45
- package/dist/remote-execution/canonical-metadata.d.ts +0 -4
- package/dist/remote-execution/canonical-metadata.js +0 -32
- package/dist/remote-execution/client.js +0 -824
- package/dist/remote-execution/deployment.js +0 -131
- package/dist/remote-execution/descriptors.js +0 -267
- package/dist/remote-execution/effects.js +0 -357
- package/dist/remote-execution/endpoint.js +0 -224
- package/dist/remote-execution/files.js +0 -291
- package/dist/remote-execution/hosting-operation.js +0 -26
- package/dist/remote-execution/hosting-request.d.ts +0 -4
- package/dist/remote-execution/hosting-request.js +0 -12
- package/dist/remote-execution/hosting-stream.d.ts +0 -8
- package/dist/remote-execution/hosting-stream.js +0 -64
- package/dist/remote-execution/index.js +0 -18
- package/dist/remote-execution/invocation-admission.d.ts +0 -3
- package/dist/remote-execution/invocation-admission.js +0 -17
- package/dist/remote-execution/job-binding.js +0 -1269
- package/dist/remote-execution/materializations.js +0 -284
- package/dist/remote-execution/modal-driver.js +0 -90
- package/dist/remote-execution/native-result.d.ts +0 -3
- package/dist/remote-execution/native-result.js +0 -16
- package/dist/remote-execution/output-freshness.d.ts +0 -4
- package/dist/remote-execution/output-freshness.js +0 -19
- package/dist/remote-execution/output-retrieval.js +0 -474
- package/dist/remote-execution/process-http.js +0 -607
- package/dist/remote-execution/process.js +0 -577
- package/dist/remote-execution/protocol.js +0 -208
- package/dist/remote-execution/relay.js +0 -91
- package/dist/remote-execution/rest-driver.js +0 -93
- package/dist/remote-execution/upload-descriptor.js +0 -201
- package/dist/remote-execution/upload-protocol.js +0 -62
- package/dist/remote-execution/uploads.js +0 -324
- package/dist/remote-execution/wire-json.d.ts +0 -4
- package/dist/remote-execution/wire-json.js +0 -44
- package/dist/remote-execution/wire-validation.js +0 -131
- package/dist/remote-execution/wire.generated.js +0 -4224
- package/dist/safe-bash/chunks/chunk-GDYNCWRV.js +0 -161
- package/dist/safe-bash/chunks/chunk-IWDICZVK.js +0 -20
- package/dist/safe-bash/chunks/chunk-MHMMRCYC.js +0 -3464
- package/dist/safe-bash/chunks/chunk-UE5KZDEK.js +0 -77
- package/dist/safe-bash/chunks/csvkit-TACDU7FC.js +0 -1618
- package/dist/safe-bash/chunks/implementation-MLFHUQ5M.js +0 -133
- package/dist/safe-bash/commands/csvkit/sync.js +0 -1639
- package/dist/safe-bash/commands/node/unconfigured.d.ts +0 -3
- package/dist/safe-bash/commands/node/unconfigured.js +0 -10
- package/dist/safe-bash/commands/pandoc/implementation.d.ts +0 -8
- package/dist/safe-bash/commands/pandoc/implementation.js +0 -94
- package/dist/safe-bash-mcp/index.browser.js +0 -9167
- package/dist/safe-bash/command-chunks/{chunk-ZRRBXU3M.js → chunk-GIN5GUDP.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-LAOM65EE.js → chunk-IEO4XVN6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-BXCXRYVU.js → chunk-JNANXVJV.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-364TMWBT.js → chunk-MWREVL44.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-464RVBGB.js → chunk-Q5TDKFHK.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-AJR3AQYA.js → chunk-UKX3LZHR.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-XIIBTGC5.js → chunk-XPXEQKRW.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-FDBUV4HJ.js → chunk-Y4HGTG3E.js} +3 -3
- /package/dist/{safe-bash/commands/csvkit → safe-bash-command-csvkit}/sync.d.ts +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createOutputOperation
|
|
2
|
+
createOutputOperation
|
|
3
|
+
} from "./chunk-RUR6J33T.js";
|
|
4
|
+
import {
|
|
3
5
|
sha256
|
|
4
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-67WIFM3N.js";
|
|
5
7
|
import {
|
|
6
8
|
PythonFailure,
|
|
7
9
|
PythonInvocationError,
|
|
@@ -14,32 +16,32 @@ import {
|
|
|
14
16
|
pythonStatProjection,
|
|
15
17
|
pythonTreeCleanup,
|
|
16
18
|
reportPythonFailure
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-Q4FNLOTI.js";
|
|
18
20
|
import {
|
|
19
21
|
openCommandFile
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import {
|
|
22
|
-
FsError
|
|
23
|
-
} from "./chunk-VTH3MLDU.js";
|
|
22
|
+
} from "./chunk-CL2FCTTO.js";
|
|
24
23
|
import {
|
|
25
24
|
dirname,
|
|
26
25
|
inheritYieldCheckpoint,
|
|
27
26
|
resolvePath,
|
|
28
27
|
yieldTurn
|
|
29
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-62BOHHJT.js";
|
|
29
|
+
import {
|
|
30
|
+
FsError
|
|
31
|
+
} from "./chunk-DUTAG6ZD.js";
|
|
30
32
|
import {
|
|
31
33
|
readBytes,
|
|
32
34
|
writeBytes
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-4KTMKD5W.js";
|
|
34
36
|
import {
|
|
35
37
|
validateExitCode
|
|
36
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-OHML2BEU.js";
|
|
37
39
|
import {
|
|
38
40
|
pathOf
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-V7QT2RWC.js";
|
|
40
42
|
import {
|
|
41
43
|
init_platform
|
|
42
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-PTAEWLSE.js";
|
|
43
45
|
|
|
44
46
|
// packages/safe-bash/src/commands/python/index.ts
|
|
45
47
|
init_platform();
|
|
@@ -1043,7 +1045,7 @@ function createPythonShellCapability(context, options = {}) {
|
|
|
1043
1045
|
|
|
1044
1046
|
// packages/safe-bash/src/commands/python/llm-capability.ts
|
|
1045
1047
|
init_platform();
|
|
1046
|
-
import { loadLlmStoredSchema, selectLlmModelByQuery, getLlmModelAliases, createLlmConfiguration, createLlmTemplateStore, evaluateLlmTemplate, findExtractedRange, llmTemplateUsesInput, validateLlmTemplateParameters } from "../../safe-bash-command-llm/index.js";
|
|
1048
|
+
import { parseLlmSchemaDsl, loadLlmStoredSchema, selectLlmModelByQuery, getLlmModelAliases, createLlmConfiguration, createLlmTemplateStore, evaluateLlmTemplate, findExtractedRange, llmTemplateUsesInput, validateLlmTemplateParameters } from "../../safe-bash-command-llm/index.js";
|
|
1047
1049
|
|
|
1048
1050
|
// packages/safe-bash/src/commands/llm/mime.ts
|
|
1049
1051
|
init_platform();
|
|
@@ -1243,6 +1245,33 @@ ${input}` : evaluated.prompt : input,
|
|
|
1243
1245
|
}
|
|
1244
1246
|
for (const value2 of inputs) {
|
|
1245
1247
|
const attachment = record(value2);
|
|
1248
|
+
if (attachment.content !== void 0) {
|
|
1249
|
+
const content = attachment.content;
|
|
1250
|
+
if (!Array.isArray(content) || !content.every((byte) => typeof byte === "number" && Number.isInteger(byte) && byte >= 0 && byte <= 255)) throw new TypeError("Invalid inline attachment bytes");
|
|
1251
|
+
if (attachment.path !== void 0 || attachment.url !== void 0) throw new TypeError("Invalid inline attachment location");
|
|
1252
|
+
if (attachment.mimeType !== void 0 && typeof attachment.mimeType !== "string") throw new TypeError("Invalid attachment MIME type");
|
|
1253
|
+
if (content.length > inputLimit - admitted) throw new RangeError("LLM input byte limit exceeded");
|
|
1254
|
+
admitted += content.length;
|
|
1255
|
+
context.inputBudget?.check(admitted);
|
|
1256
|
+
const bytes = Uint8Array.from(content);
|
|
1257
|
+
const controller2 = new AbortController();
|
|
1258
|
+
const source2 = { bytes: (async function* () {
|
|
1259
|
+
for (let offset = 0; offset < bytes.length; offset += 16384) {
|
|
1260
|
+
signal.throwIfAborted();
|
|
1261
|
+
controller2.signal.throwIfAborted();
|
|
1262
|
+
const chunk = bytes.subarray(offset, offset + 16384);
|
|
1263
|
+
if (chunk.byteLength > inputLimit - consumed) throw new RangeError("LLM input byte limit exceeded");
|
|
1264
|
+
consumed += chunk.byteLength;
|
|
1265
|
+
context.inputBudget?.check(consumed);
|
|
1266
|
+
yield chunk;
|
|
1267
|
+
}
|
|
1268
|
+
})(), async dispose() {
|
|
1269
|
+
controller2.abort();
|
|
1270
|
+
} };
|
|
1271
|
+
sources.push(source2);
|
|
1272
|
+
attachments.push({ mimeType: attachment.mimeType ?? sniffMimeType("", bytes.subarray(0, 4096)), source: source2 });
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1246
1275
|
if (typeof attachment.path !== "string" || !attachment.path || attachment.path.includes("\0") || attachment.path.includes("://")) throw new TypeError("Attachment requires a canonical filesystem path");
|
|
1247
1276
|
if (attachment.mimeType !== void 0 && typeof attachment.mimeType !== "string") throw new TypeError("Invalid attachment MIME type");
|
|
1248
1277
|
const path = pathOf(requestContext, attachment.path);
|
|
@@ -1355,6 +1384,21 @@ ${input}` : evaluated.prompt : input,
|
|
|
1355
1384
|
const operation = record(value);
|
|
1356
1385
|
const payload = record(operation.payload ?? {});
|
|
1357
1386
|
jsonBytes(payload, bufferedInputLimit, "input");
|
|
1387
|
+
if (operation.operation === "schema_dsl") {
|
|
1388
|
+
if (typeof payload.schema !== "string" || typeof payload.multi !== "boolean") throw new TypeError("Invalid schema DSL input");
|
|
1389
|
+
const result = parseLlmSchemaDsl(payload.schema, payload.multi);
|
|
1390
|
+
jsonBytes(result, bufferedLimit);
|
|
1391
|
+
return result;
|
|
1392
|
+
}
|
|
1393
|
+
if (operation.operation === "attachment_type") {
|
|
1394
|
+
const prefix = payload.prefix;
|
|
1395
|
+
if (typeof payload.path !== "string" || !Array.isArray(prefix) || prefix.length > 4096 || prefix.some((byte) => typeof byte !== "number" || !Number.isInteger(byte) || byte < 0 || byte > 255)) {
|
|
1396
|
+
throw new TypeError("Invalid bounded attachment prefix");
|
|
1397
|
+
}
|
|
1398
|
+
const result = sniffMimeType(payload.path, Uint8Array.from(prefix));
|
|
1399
|
+
jsonBytes(result, bufferedLimit);
|
|
1400
|
+
return result;
|
|
1401
|
+
}
|
|
1358
1402
|
if (operation.operation === "load_schema") {
|
|
1359
1403
|
const id = payload.schema_id;
|
|
1360
1404
|
if (typeof id !== "string" || !id || id.includes("\0")) throw new TypeError("Stored schema ID must be a nonempty string");
|
|
@@ -1372,6 +1416,15 @@ ${input}` : evaluated.prompt : input,
|
|
|
1372
1416
|
jsonBytes(result, bufferedLimit);
|
|
1373
1417
|
return result;
|
|
1374
1418
|
}
|
|
1419
|
+
if (operation.operation === "resolve_model") {
|
|
1420
|
+
const configuration = createLlmConfiguration(configurationContext(context, payload, signal));
|
|
1421
|
+
const selected = payload.model ?? await configuration.defaultModel();
|
|
1422
|
+
if (selected !== void 0 && typeof selected !== "string") throw new TypeError("Model must be a string");
|
|
1423
|
+
const identity = selected === void 0 ? void 0 : await configuration.resolveAlias(selected);
|
|
1424
|
+
const resolved = service.resolve(identity).model.id;
|
|
1425
|
+
jsonBytes(resolved, bufferedLimit);
|
|
1426
|
+
return resolved;
|
|
1427
|
+
}
|
|
1375
1428
|
if (operation.operation === "select_model") {
|
|
1376
1429
|
const queries = payload.queries;
|
|
1377
1430
|
if (!Array.isArray(queries) || !queries.length || queries.some((query) => typeof query !== "string")) throw new TypeError("Model queries must be a nonempty array of strings");
|
|
@@ -1387,7 +1440,13 @@ ${input}` : evaluated.prompt : input,
|
|
|
1387
1440
|
id: entry.model.id,
|
|
1388
1441
|
aliases: getLlmModelAliases(entry, aliases),
|
|
1389
1442
|
capabilities: [...entry.model.capabilities ?? []],
|
|
1390
|
-
metadata: {
|
|
1443
|
+
metadata: { ...entry.model.options === void 0 ? {} : { options: Object.fromEntries(Object.entries(entry.model.options).map(([name, option]) => [name, {
|
|
1444
|
+
type: option.type,
|
|
1445
|
+
...option.minimum === void 0 ? {} : { minimum: option.minimum },
|
|
1446
|
+
...option.maximum === void 0 ? {} : { maximum: option.maximum },
|
|
1447
|
+
...option.nullable === void 0 ? {} : { nullable: option.nullable },
|
|
1448
|
+
...option.description === void 0 ? {} : { description: option.description }
|
|
1449
|
+
}])) }, provider: entry.provider.name, attachmentTypes: [...entry.model.attachmentTypes ?? []], outputType: entry.model.outputType ?? "text/plain" }
|
|
1391
1450
|
}));
|
|
1392
1451
|
jsonBytes(models, bufferedLimit);
|
|
1393
1452
|
return models;
|
|
@@ -1591,6 +1650,699 @@ import { createPythonNativeSyscalls } from "@poe-platform/safe-fs/core";
|
|
|
1591
1650
|
|
|
1592
1651
|
// packages/safe-bash/src/commands/python/llm-module.ts
|
|
1593
1652
|
init_platform();
|
|
1653
|
+
|
|
1654
|
+
// packages/safe-bash/src/commands/python/llm-reference-module.ts
|
|
1655
|
+
init_platform();
|
|
1656
|
+
var pythonLlmReferenceModule = /* @__PURE__ */ (() => String.raw`
|
|
1657
|
+
"""Lazy synchronous and asynchronous model responses backed by JavaScript."""
|
|
1658
|
+
import asyncio
|
|
1659
|
+
import inspect
|
|
1660
|
+
import datetime as _datetime
|
|
1661
|
+
from dataclasses import dataclass, field
|
|
1662
|
+
import os
|
|
1663
|
+
import time
|
|
1664
|
+
from pydantic import BaseModel, ConfigDict, Field, create_model
|
|
1665
|
+
import poe_llm as _core
|
|
1666
|
+
|
|
1667
|
+
Error = _core.LlmError
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
class Options(BaseModel):
|
|
1671
|
+
model_config = ConfigDict(extra="forbid")
|
|
1672
|
+
|
|
1673
|
+
|
|
1674
|
+
def _sync(awaitable):
|
|
1675
|
+
try:
|
|
1676
|
+
from pyodide.ffi import run_sync
|
|
1677
|
+
except ImportError:
|
|
1678
|
+
# The native path is for capability tests; production suspension is JSPI.
|
|
1679
|
+
try:
|
|
1680
|
+
asyncio.get_running_loop()
|
|
1681
|
+
except RuntimeError:
|
|
1682
|
+
global _native_loop
|
|
1683
|
+
if _native_loop is None or _native_loop.is_closed():
|
|
1684
|
+
_native_loop = asyncio.new_event_loop()
|
|
1685
|
+
return _native_loop.run_until_complete(awaitable)
|
|
1686
|
+
awaitable.close()
|
|
1687
|
+
raise RuntimeError("Use the asynchronous model API inside an asyncio event loop")
|
|
1688
|
+
return run_sync(awaitable)
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
_native_loop = None
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
@dataclass
|
|
1695
|
+
class Usage:
|
|
1696
|
+
input: object = None
|
|
1697
|
+
output: object = None
|
|
1698
|
+
details: object = None
|
|
1699
|
+
|
|
1700
|
+
|
|
1701
|
+
@dataclass
|
|
1702
|
+
class Attachment:
|
|
1703
|
+
type: object = None
|
|
1704
|
+
path: object = None
|
|
1705
|
+
url: object = None
|
|
1706
|
+
content: object = None
|
|
1707
|
+
_id: object = None
|
|
1708
|
+
|
|
1709
|
+
def payload(self):
|
|
1710
|
+
if self.content is not None:
|
|
1711
|
+
if not isinstance(self.content, bytes):
|
|
1712
|
+
raise TypeError("Attachment content must be bytes")
|
|
1713
|
+
return {"content": list(self.content), "mimeType": self.resolve_type()}
|
|
1714
|
+
if self.url is not None:
|
|
1715
|
+
raise NotImplementedError("URL attachment acquisition requires shared service support")
|
|
1716
|
+
return _core.Attachment(os.fspath(self.path), self.type).payload()
|
|
1717
|
+
|
|
1718
|
+
def id(self):
|
|
1719
|
+
import hashlib
|
|
1720
|
+
import json
|
|
1721
|
+
if self._id is None:
|
|
1722
|
+
digest = hashlib.sha256()
|
|
1723
|
+
if self.content:
|
|
1724
|
+
digest.update(self.content)
|
|
1725
|
+
elif self.path:
|
|
1726
|
+
with open(self.path, "rb") as source:
|
|
1727
|
+
for chunk in iter(lambda: source.read(65536), b""):
|
|
1728
|
+
digest.update(chunk)
|
|
1729
|
+
else:
|
|
1730
|
+
digest.update(json.dumps({"url": self.url}).encode("utf-8"))
|
|
1731
|
+
self._id = digest.hexdigest()
|
|
1732
|
+
return self._id
|
|
1733
|
+
|
|
1734
|
+
def content_bytes(self):
|
|
1735
|
+
if self.content:
|
|
1736
|
+
return self.content
|
|
1737
|
+
if self.path:
|
|
1738
|
+
with open(self.path, "rb") as source:
|
|
1739
|
+
return source.read()
|
|
1740
|
+
if self.url:
|
|
1741
|
+
raise NotImplementedError("URL attachment acquisition requires shared service support")
|
|
1742
|
+
return self.content
|
|
1743
|
+
|
|
1744
|
+
def base64_content(self):
|
|
1745
|
+
import base64
|
|
1746
|
+
return base64.b64encode(self.content_bytes()).decode("utf-8")
|
|
1747
|
+
|
|
1748
|
+
def resolve_type(self):
|
|
1749
|
+
if self.type:
|
|
1750
|
+
return self.type
|
|
1751
|
+
if self.path:
|
|
1752
|
+
with open(self.path, "rb") as source:
|
|
1753
|
+
prefix = source.read(4096)
|
|
1754
|
+
elif self.content:
|
|
1755
|
+
prefix = self.content[:4096]
|
|
1756
|
+
elif self.url:
|
|
1757
|
+
raise NotImplementedError("URL attachment acquisition requires shared service support")
|
|
1758
|
+
else:
|
|
1759
|
+
raise ValueError("Attachment has no type and no content to derive it from")
|
|
1760
|
+
async def resolve():
|
|
1761
|
+
async with _core.Client() as client:
|
|
1762
|
+
payload = {"path": os.fspath(self.path) if self.path else "", "prefix": list(prefix)}
|
|
1763
|
+
return await client._run(lambda: client._bridge.call("attachment_type", payload), client._timeout)
|
|
1764
|
+
return _sync(resolve())
|
|
1765
|
+
|
|
1766
|
+
@classmethod
|
|
1767
|
+
def from_row(cls, row):
|
|
1768
|
+
return cls(_id=row["id"], type=row["type"], path=row["path"], url=row["url"], content=row["content"])
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
class Prompt:
|
|
1772
|
+
def __init__(self, prompt, model, *, fragments=None, attachments=None,
|
|
1773
|
+
system=None, system_fragments=None, prompt_json=None,
|
|
1774
|
+
options=None, schema=None, tools=None, tool_results=None):
|
|
1775
|
+
if tools or tool_results:
|
|
1776
|
+
raise NotImplementedError("Tools require shared service support")
|
|
1777
|
+
self._prompt = prompt
|
|
1778
|
+
self.model = model
|
|
1779
|
+
self.fragments = fragments or []
|
|
1780
|
+
self._system = system
|
|
1781
|
+
self.system_fragments = system_fragments or []
|
|
1782
|
+
self.prompt_json = prompt_json
|
|
1783
|
+
self.attachments = list(attachments or [])
|
|
1784
|
+
if schema is not None and hasattr(schema, "model_json_schema"):
|
|
1785
|
+
schema = schema.model_json_schema()
|
|
1786
|
+
self.schema = schema
|
|
1787
|
+
self.options = options or {}
|
|
1788
|
+
self.tools = []
|
|
1789
|
+
self.tool_results = []
|
|
1790
|
+
|
|
1791
|
+
@property
|
|
1792
|
+
def prompt(self):
|
|
1793
|
+
return "\n".join(self.fragments + ([self._prompt] if self._prompt else []))
|
|
1794
|
+
|
|
1795
|
+
@property
|
|
1796
|
+
def system(self):
|
|
1797
|
+
bits = [bit.strip() for bit in self.system_fragments + [self._system or ""] if bit.strip()]
|
|
1798
|
+
return "\n\n".join(bits)
|
|
1799
|
+
|
|
1800
|
+
|
|
1801
|
+
_last_id = 0
|
|
1802
|
+
|
|
1803
|
+
|
|
1804
|
+
def _new_id():
|
|
1805
|
+
global _last_id
|
|
1806
|
+
_last_id = max((int(time.time() * 1000) << 80) | int.from_bytes(os.urandom(10), "big"), _last_id + 1)
|
|
1807
|
+
alphabet = "0123456789abcdefghjkmnpqrstvwxyz"
|
|
1808
|
+
return "".join(alphabet[(_last_id >> shift) & 31] for shift in range(125, -1, -5))
|
|
1809
|
+
|
|
1810
|
+
|
|
1811
|
+
class _Response:
|
|
1812
|
+
def __init__(self, prompt, model, stream, conversation=None, key=None):
|
|
1813
|
+
if prompt.schema and not model.supports_schema:
|
|
1814
|
+
raise ValueError(str(model) + " does not support schemas")
|
|
1815
|
+
self.id = _new_id()
|
|
1816
|
+
self.prompt = prompt
|
|
1817
|
+
self.model = model
|
|
1818
|
+
self.stream = stream
|
|
1819
|
+
self.conversation = conversation
|
|
1820
|
+
self._key = key
|
|
1821
|
+
self._chunks = []
|
|
1822
|
+
self._done = False
|
|
1823
|
+
self._closed = False
|
|
1824
|
+
self._client = None
|
|
1825
|
+
self._iterator = None
|
|
1826
|
+
self._custom_iterator = None
|
|
1827
|
+
self.response_json = None
|
|
1828
|
+
self.input_tokens = None
|
|
1829
|
+
self.output_tokens = None
|
|
1830
|
+
self.token_details = None
|
|
1831
|
+
self.done_callbacks = []
|
|
1832
|
+
self.resolved_model = None
|
|
1833
|
+
self.attachments = []
|
|
1834
|
+
self._tool_calls = []
|
|
1835
|
+
self._prompt_json = None
|
|
1836
|
+
self._start = None
|
|
1837
|
+
self._end = None
|
|
1838
|
+
self._start_utcnow = None
|
|
1839
|
+
|
|
1840
|
+
def set_usage(self, *, input=None, output=None, details=None):
|
|
1841
|
+
self.input_tokens = input
|
|
1842
|
+
self.output_tokens = output
|
|
1843
|
+
self.token_details = details
|
|
1844
|
+
|
|
1845
|
+
def set_resolved_model(self, model_id):
|
|
1846
|
+
self.resolved_model = model_id
|
|
1847
|
+
|
|
1848
|
+
def token_usage(self):
|
|
1849
|
+
import json
|
|
1850
|
+
parts = []
|
|
1851
|
+
if self.input_tokens is not None:
|
|
1852
|
+
parts.append(format(self.input_tokens, ",") + " input")
|
|
1853
|
+
if self.output_tokens is not None:
|
|
1854
|
+
parts.append(format(self.output_tokens, ",") + " output")
|
|
1855
|
+
if self.token_details:
|
|
1856
|
+
parts.append(json.dumps(self.token_details))
|
|
1857
|
+
return ", ".join(parts)
|
|
1858
|
+
|
|
1859
|
+
async def _finish(self):
|
|
1860
|
+
self._end = time.monotonic()
|
|
1861
|
+
self._done = True
|
|
1862
|
+
if self.conversation is not None:
|
|
1863
|
+
self.conversation.responses.append(self)
|
|
1864
|
+
await self._close()
|
|
1865
|
+
callbacks, self.done_callbacks = self.done_callbacks, []
|
|
1866
|
+
for callback in callbacks:
|
|
1867
|
+
value = callback(self)
|
|
1868
|
+
if inspect.isawaitable(value):
|
|
1869
|
+
await value
|
|
1870
|
+
|
|
1871
|
+
async def _close(self):
|
|
1872
|
+
if self._custom_iterator is not None:
|
|
1873
|
+
iterator, self._custom_iterator = self._custom_iterator, None
|
|
1874
|
+
close = getattr(iterator, "aclose", None) or getattr(iterator, "close", None)
|
|
1875
|
+
if close is not None:
|
|
1876
|
+
result = close()
|
|
1877
|
+
if inspect.isawaitable(result):
|
|
1878
|
+
await result
|
|
1879
|
+
if self._client is not None:
|
|
1880
|
+
await self._client.aclose()
|
|
1881
|
+
|
|
1882
|
+
def _metadata(self, response):
|
|
1883
|
+
# json() returns provider response metadata, not parsed generated text.
|
|
1884
|
+
self.response_json = response.metadata.get("response_json")
|
|
1885
|
+
self.input_tokens = response.usage.get("input_tokens")
|
|
1886
|
+
self.output_tokens = response.usage.get("output_tokens")
|
|
1887
|
+
self.token_details = response.usage.get("details")
|
|
1888
|
+
|
|
1889
|
+
async def _next(self):
|
|
1890
|
+
if self._done or self._closed:
|
|
1891
|
+
raise StopAsyncIteration
|
|
1892
|
+
try:
|
|
1893
|
+
execute = getattr(self.model, "execute", None)
|
|
1894
|
+
if execute is not None:
|
|
1895
|
+
if self._custom_iterator is None:
|
|
1896
|
+
self._start = time.monotonic()
|
|
1897
|
+
self._start_utcnow = _datetime.datetime.now(_datetime.timezone.utc)
|
|
1898
|
+
self._custom_iterator = execute(self.prompt, self.stream, self, self.conversation)
|
|
1899
|
+
try:
|
|
1900
|
+
if isinstance(self.model, AsyncModel):
|
|
1901
|
+
chunk = await self._custom_iterator.__anext__()
|
|
1902
|
+
else:
|
|
1903
|
+
chunk = next(self._custom_iterator)
|
|
1904
|
+
except (StopIteration, StopAsyncIteration):
|
|
1905
|
+
await self._finish()
|
|
1906
|
+
raise StopAsyncIteration
|
|
1907
|
+
self._chunks.append(chunk)
|
|
1908
|
+
return chunk
|
|
1909
|
+
if self._client is None:
|
|
1910
|
+
self._start = time.monotonic()
|
|
1911
|
+
self._start_utcnow = _datetime.datetime.now(_datetime.timezone.utc)
|
|
1912
|
+
self._client = _core.Client(model=self.model.model_id, key=self._key)
|
|
1913
|
+
options = self.prompt.options
|
|
1914
|
+
if hasattr(options, "model_dump"):
|
|
1915
|
+
options = options.model_dump(exclude_none=True)
|
|
1916
|
+
values = dict(system=self.prompt.system, options=options,
|
|
1917
|
+
attachments=self.prompt.attachments, schema=self.prompt.schema)
|
|
1918
|
+
if self.conversation is not None:
|
|
1919
|
+
messages = []
|
|
1920
|
+
for response in self.conversation.responses:
|
|
1921
|
+
if response.prompt.system:
|
|
1922
|
+
messages.append(_core.Message("system", response.prompt.system))
|
|
1923
|
+
messages.extend((_core.Message("user", response.prompt.prompt or ""),
|
|
1924
|
+
_core.Message("assistant", "".join(response._chunks))))
|
|
1925
|
+
values.update(messages=messages)
|
|
1926
|
+
if not self.stream:
|
|
1927
|
+
response = await self._client.complete(self.prompt.prompt or "", **values)
|
|
1928
|
+
self._metadata(response)
|
|
1929
|
+
self._chunks.append(response.text)
|
|
1930
|
+
await self._finish()
|
|
1931
|
+
return response.text
|
|
1932
|
+
self._iterator = self._client.stream(self.prompt.prompt or "", **values)
|
|
1933
|
+
while True:
|
|
1934
|
+
try:
|
|
1935
|
+
event = await self._iterator.__anext__()
|
|
1936
|
+
except StopAsyncIteration:
|
|
1937
|
+
await self._finish()
|
|
1938
|
+
raise
|
|
1939
|
+
if event.type == "response":
|
|
1940
|
+
self._metadata(event.response)
|
|
1941
|
+
elif event.type == "text":
|
|
1942
|
+
self._chunks.append(event.text)
|
|
1943
|
+
return event.text
|
|
1944
|
+
except BaseException:
|
|
1945
|
+
await self._close()
|
|
1946
|
+
raise
|
|
1947
|
+
|
|
1948
|
+
|
|
1949
|
+
class Response(_Response):
|
|
1950
|
+
def __str__(self):
|
|
1951
|
+
return self.text()
|
|
1952
|
+
|
|
1953
|
+
def text_or_raise(self):
|
|
1954
|
+
return self.text()
|
|
1955
|
+
|
|
1956
|
+
def duration_ms(self):
|
|
1957
|
+
self.text()
|
|
1958
|
+
return int(((self._end or 0) - (self._start or 0)) * 1000)
|
|
1959
|
+
|
|
1960
|
+
def datetime_utc(self):
|
|
1961
|
+
self.text()
|
|
1962
|
+
return self._start_utcnow.isoformat() if self._start_utcnow else ""
|
|
1963
|
+
|
|
1964
|
+
def __iter__(self):
|
|
1965
|
+
if self._done:
|
|
1966
|
+
yield from self._chunks
|
|
1967
|
+
return
|
|
1968
|
+
try:
|
|
1969
|
+
while True:
|
|
1970
|
+
try:
|
|
1971
|
+
chunk = _sync(self._next())
|
|
1972
|
+
except StopAsyncIteration:
|
|
1973
|
+
return
|
|
1974
|
+
yield chunk
|
|
1975
|
+
finally:
|
|
1976
|
+
if not self._done:
|
|
1977
|
+
self.close()
|
|
1978
|
+
|
|
1979
|
+
def text(self):
|
|
1980
|
+
if not self._done:
|
|
1981
|
+
for _ in self:
|
|
1982
|
+
pass
|
|
1983
|
+
return "".join(self._chunks)
|
|
1984
|
+
|
|
1985
|
+
def json(self):
|
|
1986
|
+
self.text()
|
|
1987
|
+
return self.response_json
|
|
1988
|
+
|
|
1989
|
+
def usage(self):
|
|
1990
|
+
self.text()
|
|
1991
|
+
return Usage(self.input_tokens, self.output_tokens, self.token_details)
|
|
1992
|
+
|
|
1993
|
+
def on_done(self, callback):
|
|
1994
|
+
if self._done:
|
|
1995
|
+
callback(self)
|
|
1996
|
+
else:
|
|
1997
|
+
self.done_callbacks.append(callback)
|
|
1998
|
+
|
|
1999
|
+
def close(self):
|
|
2000
|
+
self._closed = True
|
|
2001
|
+
_sync(self._close())
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
class AsyncResponse(_Response):
|
|
2005
|
+
def __await__(self):
|
|
2006
|
+
async def complete():
|
|
2007
|
+
await self.text()
|
|
2008
|
+
return self
|
|
2009
|
+
return complete().__await__()
|
|
2010
|
+
|
|
2011
|
+
def text_or_raise(self):
|
|
2012
|
+
if not self._done:
|
|
2013
|
+
raise ValueError("Response not yet awaited")
|
|
2014
|
+
return "".join(self._chunks)
|
|
2015
|
+
|
|
2016
|
+
async def duration_ms(self):
|
|
2017
|
+
await self.text()
|
|
2018
|
+
return int(((self._end or 0) - (self._start or 0)) * 1000)
|
|
2019
|
+
|
|
2020
|
+
async def datetime_utc(self):
|
|
2021
|
+
await self.text()
|
|
2022
|
+
return self._start_utcnow.isoformat() if self._start_utcnow else ""
|
|
2023
|
+
|
|
2024
|
+
async def to_sync_response(self):
|
|
2025
|
+
await self.text()
|
|
2026
|
+
conversation = self.conversation.to_sync_conversation() if self.conversation else None
|
|
2027
|
+
response = Response(self.prompt, self.model, self.stream, conversation=conversation)
|
|
2028
|
+
for name in ("id", "_done", "_end", "_start", "_start_utcnow", "input_tokens",
|
|
2029
|
+
"output_tokens", "token_details", "_prompt_json", "response_json", "resolved_model"):
|
|
2030
|
+
setattr(response, name, getattr(self, name))
|
|
2031
|
+
response._chunks = list(self._chunks)
|
|
2032
|
+
response._tool_calls = list(self._tool_calls)
|
|
2033
|
+
response.attachments = list(self.attachments)
|
|
2034
|
+
return response
|
|
2035
|
+
|
|
2036
|
+
def __aiter__(self):
|
|
2037
|
+
if self._done:
|
|
2038
|
+
self._replay = iter(self._chunks)
|
|
2039
|
+
return self
|
|
2040
|
+
|
|
2041
|
+
async def __anext__(self):
|
|
2042
|
+
if self._done:
|
|
2043
|
+
try:
|
|
2044
|
+
return next(getattr(self, "_replay", iter(())))
|
|
2045
|
+
except StopIteration:
|
|
2046
|
+
raise StopAsyncIteration from None
|
|
2047
|
+
return await self._next()
|
|
2048
|
+
|
|
2049
|
+
async def text(self):
|
|
2050
|
+
if not self._done:
|
|
2051
|
+
async for _ in self:
|
|
2052
|
+
pass
|
|
2053
|
+
return "".join(self._chunks)
|
|
2054
|
+
|
|
2055
|
+
async def json(self):
|
|
2056
|
+
await self.text()
|
|
2057
|
+
return self.response_json
|
|
2058
|
+
|
|
2059
|
+
async def usage(self):
|
|
2060
|
+
await self.text()
|
|
2061
|
+
return Usage(self.input_tokens, self.output_tokens, self.token_details)
|
|
2062
|
+
|
|
2063
|
+
async def on_done(self, callback):
|
|
2064
|
+
if self._done:
|
|
2065
|
+
value = callback(self)
|
|
2066
|
+
if inspect.isawaitable(value):
|
|
2067
|
+
await value
|
|
2068
|
+
else:
|
|
2069
|
+
self.done_callbacks.append(callback)
|
|
2070
|
+
|
|
2071
|
+
async def aclose(self):
|
|
2072
|
+
self._closed = True
|
|
2073
|
+
await self._close()
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
class Model:
|
|
2077
|
+
class Options(Options):
|
|
2078
|
+
pass
|
|
2079
|
+
supports_schema = False
|
|
2080
|
+
supports_tools = False
|
|
2081
|
+
attachment_types = set()
|
|
2082
|
+
|
|
2083
|
+
def __init__(self, model_id=None, *, capabilities=None, metadata=None):
|
|
2084
|
+
if model_id is not None:
|
|
2085
|
+
self.model_id = model_id
|
|
2086
|
+
if capabilities is not None:
|
|
2087
|
+
self.supports_schema = "schema" in capabilities
|
|
2088
|
+
if metadata is not None:
|
|
2089
|
+
self.attachment_types = set(metadata.get("attachmentTypes", ()))
|
|
2090
|
+
if "options" not in metadata:
|
|
2091
|
+
self.Options = create_model("Options", __base__=type(self).Options, __config__=ConfigDict(extra="allow"))
|
|
2092
|
+
else:
|
|
2093
|
+
from typing import Optional
|
|
2094
|
+
types = {"number": float, "integer": int, "boolean": bool, "string": str}
|
|
2095
|
+
fields = {}
|
|
2096
|
+
for name, declaration in metadata["options"].items():
|
|
2097
|
+
value_type = types[declaration["type"]]
|
|
2098
|
+
if declaration.get("nullable"):
|
|
2099
|
+
value_type = Optional[value_type]
|
|
2100
|
+
constraints = {}
|
|
2101
|
+
for source, target in (("minimum", "ge"), ("maximum", "le"), ("description", "description")):
|
|
2102
|
+
if source in declaration:
|
|
2103
|
+
constraints[target] = declaration[source]
|
|
2104
|
+
fields[name] = (value_type, Field(default=None, **constraints))
|
|
2105
|
+
self.Options = create_model("Options", __base__=type(self).Options, **fields)
|
|
2106
|
+
|
|
2107
|
+
def __str__(self):
|
|
2108
|
+
suffix = " (async)" if isinstance(self, AsyncModel) else ""
|
|
2109
|
+
return self.__class__.__name__ + suffix + ": " + self.model_id
|
|
2110
|
+
|
|
2111
|
+
def __repr__(self):
|
|
2112
|
+
return "<" + str(self) + ">"
|
|
2113
|
+
|
|
2114
|
+
def _validate_attachments(self, attachments=None):
|
|
2115
|
+
if attachments and not self.attachment_types:
|
|
2116
|
+
raise ValueError("This model does not support attachments")
|
|
2117
|
+
for attachment in attachments or []:
|
|
2118
|
+
attachment_type = attachment.resolve_type()
|
|
2119
|
+
if attachment_type not in self.attachment_types:
|
|
2120
|
+
raise ValueError(
|
|
2121
|
+
"This model does not support attachments of type '" + attachment_type
|
|
2122
|
+
+ "', only " + ", ".join(self.attachment_types)
|
|
2123
|
+
)
|
|
2124
|
+
|
|
2125
|
+
def prompt(self, prompt=None, *, fragments=None, attachments=None, system=None,
|
|
2126
|
+
system_fragments=None, stream=True, schema=None, tools=None,
|
|
2127
|
+
tool_results=None, **options):
|
|
2128
|
+
self._validate_attachments(attachments)
|
|
2129
|
+
key = options.pop("key", None)
|
|
2130
|
+
options = self.Options(**options)
|
|
2131
|
+
if schema is not None and hasattr(schema, "model_json_schema"):
|
|
2132
|
+
schema = schema.model_json_schema()
|
|
2133
|
+
return Response(Prompt(prompt, self, system=system, attachments=attachments,
|
|
2134
|
+
fragments=fragments, system_fragments=system_fragments,
|
|
2135
|
+
tools=tools, tool_results=tool_results,
|
|
2136
|
+
schema=schema, options=options), self, stream, key=key)
|
|
2137
|
+
|
|
2138
|
+
|
|
2139
|
+
def conversation(self, tools=None, before_call=None, after_call=None, chain_limit=None):
|
|
2140
|
+
return Conversation(self, tools=tools, before_call=before_call, after_call=after_call, chain_limit=chain_limit)
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
class AsyncModel(Model):
|
|
2144
|
+
def prompt(self, prompt=None, *, fragments=None, attachments=None, system=None,
|
|
2145
|
+
schema=None, tools=None, tool_results=None, system_fragments=None,
|
|
2146
|
+
stream=True, **options):
|
|
2147
|
+
response = super().prompt(prompt, fragments=fragments, attachments=attachments,
|
|
2148
|
+
system=system, schema=schema, tools=tools,
|
|
2149
|
+
tool_results=tool_results, system_fragments=system_fragments,
|
|
2150
|
+
stream=stream, **options)
|
|
2151
|
+
return AsyncResponse(response.prompt, self, stream, key=response._key)
|
|
2152
|
+
|
|
2153
|
+
|
|
2154
|
+
def conversation(self, tools=None, before_call=None, after_call=None, chain_limit=None):
|
|
2155
|
+
return AsyncConversation(self, tools=tools, before_call=before_call, after_call=after_call, chain_limit=chain_limit)
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
@dataclass
|
|
2159
|
+
class Conversation:
|
|
2160
|
+
model: object
|
|
2161
|
+
id: str = field(default_factory=_new_id)
|
|
2162
|
+
name: object = None
|
|
2163
|
+
responses: list = field(default_factory=list)
|
|
2164
|
+
tools: object = None
|
|
2165
|
+
chain_limit: object = None
|
|
2166
|
+
before_call: object = None
|
|
2167
|
+
after_call: object = None
|
|
2168
|
+
|
|
2169
|
+
def prompt(self, prompt=None, *, fragments=None, attachments=None, system=None,
|
|
2170
|
+
schema=None, tools=None, tool_results=None, system_fragments=None,
|
|
2171
|
+
stream=True, key=None, **options):
|
|
2172
|
+
response = self.model.prompt(prompt, fragments=fragments, attachments=attachments,
|
|
2173
|
+
system=system, schema=schema, tools=tools or self.tools,
|
|
2174
|
+
tool_results=tool_results, system_fragments=system_fragments,
|
|
2175
|
+
stream=stream, key=key, **options)
|
|
2176
|
+
response.conversation = self
|
|
2177
|
+
return response
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
class AsyncConversation(Conversation):
|
|
2181
|
+
def to_sync_conversation(self):
|
|
2182
|
+
return Conversation(model=self.model, id=self.id, name=self.name, responses=[],
|
|
2183
|
+
tools=self.tools, chain_limit=self.chain_limit)
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
class UnknownModelError(KeyError):
|
|
2187
|
+
pass
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
async def _models():
|
|
2191
|
+
async with _core.Client() as client:
|
|
2192
|
+
return await client.models()
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
def get_models():
|
|
2196
|
+
return [Model(item.id, capabilities=item.capabilities, metadata=item.metadata) for item in _sync(_models())]
|
|
2197
|
+
|
|
2198
|
+
|
|
2199
|
+
def get_async_models():
|
|
2200
|
+
return [AsyncModel(item.id, capabilities=item.capabilities, metadata=item.metadata) for item in _sync(_models())]
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
def get_model_aliases():
|
|
2204
|
+
result = {}
|
|
2205
|
+
for item in _sync(_models()):
|
|
2206
|
+
model = Model(item.id, capabilities=item.capabilities, metadata=item.metadata)
|
|
2207
|
+
for name in (item.id, *item.aliases):
|
|
2208
|
+
result[name] = model
|
|
2209
|
+
return result
|
|
2210
|
+
|
|
2211
|
+
|
|
2212
|
+
def get_async_model_aliases():
|
|
2213
|
+
result = {}
|
|
2214
|
+
for item in _sync(_models()):
|
|
2215
|
+
model = AsyncModel(item.id, capabilities=item.capabilities, metadata=item.metadata)
|
|
2216
|
+
for name in (item.id, *item.aliases):
|
|
2217
|
+
result[name] = model
|
|
2218
|
+
return result
|
|
2219
|
+
|
|
2220
|
+
|
|
2221
|
+
def get_default_model():
|
|
2222
|
+
async def read():
|
|
2223
|
+
async with _core.Client() as client:
|
|
2224
|
+
return await client._run(lambda: client._bridge.call("resolve_model", _core._configuration_context()), client._timeout)
|
|
2225
|
+
return _sync(read())
|
|
2226
|
+
|
|
2227
|
+
|
|
2228
|
+
def get_model(name=None, _skip_async=False):
|
|
2229
|
+
aliases = get_model_aliases()
|
|
2230
|
+
name = name or get_default_model()
|
|
2231
|
+
try:
|
|
2232
|
+
return aliases[name]
|
|
2233
|
+
except KeyError:
|
|
2234
|
+
raise UnknownModelError("Unknown model: " + str(name)) from None
|
|
2235
|
+
|
|
2236
|
+
|
|
2237
|
+
def get_async_model(name=None):
|
|
2238
|
+
aliases = get_async_model_aliases()
|
|
2239
|
+
name = name or get_default_model()
|
|
2240
|
+
try:
|
|
2241
|
+
return aliases[name]
|
|
2242
|
+
except KeyError:
|
|
2243
|
+
raise UnknownModelError("Unknown model: " + str(name)) from None
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
def schema_dsl(schema_dsl, multi=False):
|
|
2247
|
+
async def parse():
|
|
2248
|
+
async with _core.Client() as client:
|
|
2249
|
+
payload = {"schema": schema_dsl, "multi": bool(multi)}
|
|
2250
|
+
return await client._run(lambda: client._bridge.call("schema_dsl", payload), client._timeout)
|
|
2251
|
+
return _sync(parse())
|
|
2252
|
+
|
|
2253
|
+
|
|
2254
|
+
def encode(values):
|
|
2255
|
+
import struct
|
|
2256
|
+
return struct.pack("<" + "f" * len(values), *values)
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
def decode(binary):
|
|
2260
|
+
import struct
|
|
2261
|
+
return struct.unpack("<" + "f" * (len(binary) // 4), binary)
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
def cosine_similarity(a, b):
|
|
2265
|
+
dot_product = sum(x * y for x, y in zip(a, b))
|
|
2266
|
+
magnitude_a = sum(x * x for x in a) ** 0.5
|
|
2267
|
+
magnitude_b = sum(x * x for x in b) ** 0.5
|
|
2268
|
+
return dot_product / (magnitude_a * magnitude_b)
|
|
2269
|
+
|
|
2270
|
+
|
|
2271
|
+
class EmbeddingModel:
|
|
2272
|
+
supports_text = True
|
|
2273
|
+
supports_binary = False
|
|
2274
|
+
batch_size = None
|
|
2275
|
+
key = None
|
|
2276
|
+
|
|
2277
|
+
def __init__(self, model_id=None):
|
|
2278
|
+
if model_id is not None:
|
|
2279
|
+
self.model_id = model_id
|
|
2280
|
+
|
|
2281
|
+
def __str__(self):
|
|
2282
|
+
return self.__class__.__name__ + ": " + self.model_id
|
|
2283
|
+
|
|
2284
|
+
def __repr__(self):
|
|
2285
|
+
return "<" + str(self) + ">"
|
|
2286
|
+
|
|
2287
|
+
def _check(self, item):
|
|
2288
|
+
if not self.supports_binary and isinstance(item, bytes):
|
|
2289
|
+
raise ValueError("This model does not support binary data, only text strings")
|
|
2290
|
+
if not self.supports_text and isinstance(item, str):
|
|
2291
|
+
raise ValueError("This model does not support text strings, only binary data")
|
|
2292
|
+
|
|
2293
|
+
def embed_batch(self, items):
|
|
2294
|
+
async def embed():
|
|
2295
|
+
async with _core.Client(model=self.model_id, key=self.key) as client:
|
|
2296
|
+
return await client.embed(items)
|
|
2297
|
+
result = _sync(embed())
|
|
2298
|
+
for vector in result.vectors:
|
|
2299
|
+
yield list(vector)
|
|
2300
|
+
|
|
2301
|
+
def embed(self, item):
|
|
2302
|
+
self._check(item)
|
|
2303
|
+
return next(iter(self.embed_batch([item])))
|
|
2304
|
+
|
|
2305
|
+
def embed_multi(self, items, batch_size=None):
|
|
2306
|
+
from itertools import islice
|
|
2307
|
+
def checked():
|
|
2308
|
+
for item in items:
|
|
2309
|
+
self._check(item)
|
|
2310
|
+
yield item
|
|
2311
|
+
iterator = checked()
|
|
2312
|
+
effective_batch_size = self.batch_size if batch_size is None else batch_size
|
|
2313
|
+
if effective_batch_size is None:
|
|
2314
|
+
yield from self.embed_batch(iterator)
|
|
2315
|
+
return
|
|
2316
|
+
while True:
|
|
2317
|
+
batch = list(islice(iterator, effective_batch_size))
|
|
2318
|
+
if not batch:
|
|
2319
|
+
return
|
|
2320
|
+
yield from self.embed_batch(batch)
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
def get_embedding_models():
|
|
2324
|
+
return [EmbeddingModel(item.id) for item in _sync(_models()) if "embed" in item.capabilities]
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
def get_embedding_model_aliases():
|
|
2328
|
+
result = {}
|
|
2329
|
+
for item in _sync(_models()):
|
|
2330
|
+
if "embed" not in item.capabilities:
|
|
2331
|
+
continue
|
|
2332
|
+
model = EmbeddingModel(item.id)
|
|
2333
|
+
for name in (item.id, *item.aliases):
|
|
2334
|
+
result[name] = model
|
|
2335
|
+
return result
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
def get_embedding_model(name):
|
|
2339
|
+
try:
|
|
2340
|
+
return get_embedding_model_aliases()[name]
|
|
2341
|
+
except KeyError:
|
|
2342
|
+
raise UnknownModelError("Unknown model: " + str(name)) from None
|
|
2343
|
+
`)();
|
|
2344
|
+
|
|
2345
|
+
// packages/safe-bash/src/commands/python/llm-module.ts
|
|
1594
2346
|
var pythonLlmModule = /* @__PURE__ */ (() => String.raw`
|
|
1595
2347
|
"""Async Python workflows for the invocation-owned JavaScript LLM service."""
|
|
1596
2348
|
from __future__ import annotations
|
|
@@ -2080,13 +2832,14 @@ class _SafeLlmLoader:
|
|
|
2080
2832
|
self._source = source
|
|
2081
2833
|
self._spec = spec
|
|
2082
2834
|
def find_spec(self, fullname, path=None, target=None):
|
|
2083
|
-
if fullname
|
|
2835
|
+
if fullname in ('poe_llm', 'llm'):
|
|
2084
2836
|
return self._spec(fullname, self, origin='poe_llm.py')
|
|
2085
2837
|
def create_module(self, spec):
|
|
2086
2838
|
return None
|
|
2087
2839
|
def exec_module(self, module):
|
|
2088
|
-
module.__file__ = '
|
|
2089
|
-
|
|
2840
|
+
module.__file__ = module.__name__ + '.py'
|
|
2841
|
+
source = self._source if module.__name__ == 'poe_llm' else ${JSON.stringify(pythonLlmReferenceModule)}
|
|
2842
|
+
exec(compile(source, module.__file__, 'exec'), module.__dict__)
|
|
2090
2843
|
_safe_llm_sys.meta_path.insert(0, _SafeLlmLoader(_safe_llm_source, _safe_llm_imports.ModuleSpec))
|
|
2091
2844
|
del _SafeLlmLoader, _safe_llm_sys, _safe_llm_imports
|
|
2092
2845
|
`);
|
|
@@ -3359,6 +4112,65 @@ function createPythonJspiAssets(options) {
|
|
|
3359
4112
|
} };
|
|
3360
4113
|
}
|
|
3361
4114
|
|
|
4115
|
+
// packages/safe-bash/src/commands/python/llm-dependencies.ts
|
|
4116
|
+
init_platform();
|
|
4117
|
+
var pythonLlmDependencies = Object.freeze({
|
|
4118
|
+
pyodideVersion: "314.0.6",
|
|
4119
|
+
baseUrl: "https://cdn.jsdelivr.net/pyodide/v314.0.6/full/",
|
|
4120
|
+
archives: Object.freeze([
|
|
4121
|
+
{
|
|
4122
|
+
"fileName": "typing_extensions-4.15.0-py3-none-any.whl",
|
|
4123
|
+
"byteLength": 44613,
|
|
4124
|
+
"sha256": "3f122252f0d498d80f7a684cc1d8baa6fa65b75e99447d77a6dd90e0f04302e3"
|
|
4125
|
+
},
|
|
4126
|
+
{
|
|
4127
|
+
"fileName": "typing_inspection-0.4.2-py3-none-any.whl",
|
|
4128
|
+
"byteLength": 14610,
|
|
4129
|
+
"sha256": "c9270737700f07813e1a87b63138993997afedbd2548f20fa739cc398f1b9f2f"
|
|
4130
|
+
},
|
|
4131
|
+
{
|
|
4132
|
+
"fileName": "annotated_types-0.7.0-py3-none-any.whl",
|
|
4133
|
+
"byteLength": 11963,
|
|
4134
|
+
"sha256": "6b34f564725f8d309442f8d15abcceed1bf140fe2412e2c58da721426ae2222e"
|
|
4135
|
+
},
|
|
4136
|
+
{
|
|
4137
|
+
"fileName": "pydantic_core-2.41.5-cp314-cp314-pyemscripten_2026_0_wasm32.whl",
|
|
4138
|
+
"byteLength": 1310163,
|
|
4139
|
+
"sha256": "9802bd7a5e6679ec4c13be778f19f021e6147459c89cc916b913f7970f86dddb"
|
|
4140
|
+
},
|
|
4141
|
+
{
|
|
4142
|
+
"fileName": "pydantic-2.12.5-py3-none-any.whl",
|
|
4143
|
+
"byteLength": 463578,
|
|
4144
|
+
"sha256": "52d15d19fbe2a62ac9b63348df7b38e5ebb186063a9b923a837dd6e43273b414"
|
|
4145
|
+
}
|
|
4146
|
+
].map((archive) => Object.freeze(archive))),
|
|
4147
|
+
nativeModules: Object.freeze([Object.freeze({
|
|
4148
|
+
archive: "pydantic_core-2.41.5-cp314-cp314-pyemscripten_2026_0_wasm32.whl",
|
|
4149
|
+
path: "pydantic_core/_pydantic_core.cpython-314-wasm32-emscripten.so",
|
|
4150
|
+
sha256: "94477475eb48c67b6b25fd47a7955c1d01479f7971522aff90215bb517be8246"
|
|
4151
|
+
})])
|
|
4152
|
+
});
|
|
4153
|
+
async function installPythonLlmDependencies(runtime, archives) {
|
|
4154
|
+
if (runtime.version !== pythonLlmDependencies.pyodideVersion) throw new Error("Python LLM dependencies require Pyodide 314.0.6");
|
|
4155
|
+
const supplied = new Map(archives.map((archive) => [archive.fileName, archive.bytes]));
|
|
4156
|
+
if (archives.length !== pythonLlmDependencies.archives.length || supplied.size !== archives.length || pythonLlmDependencies.archives.some((archive) => !supplied.has(archive.fileName))) {
|
|
4157
|
+
throw new Error("A complete pinned Python LLM dependency bundle is required");
|
|
4158
|
+
}
|
|
4159
|
+
const snapshots = pythonLlmDependencies.archives.map((archive) => {
|
|
4160
|
+
const bytes = supplied.get(archive.fileName);
|
|
4161
|
+
if (!(bytes instanceof Uint8Array) || bytes.byteLength !== archive.byteLength) {
|
|
4162
|
+
throw new Error("Python LLM dependency size or digest mismatch: " + archive.fileName);
|
|
4163
|
+
}
|
|
4164
|
+
return { archive, bytes: new Uint8Array(bytes) };
|
|
4165
|
+
});
|
|
4166
|
+
for (const { archive, bytes } of snapshots) {
|
|
4167
|
+
const digest2 = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
|
|
4168
|
+
const sha2562 = Array.from(digest2, (value) => value.toString(16).padStart(2, "0")).join("");
|
|
4169
|
+
if (sha2562 !== archive.sha256) throw new Error("Python LLM dependency digest mismatch: " + archive.fileName);
|
|
4170
|
+
}
|
|
4171
|
+
for (const { bytes } of snapshots) runtime.unpackArchive(bytes, "zip", { extractDir: "/lib/python3.14/site-packages" });
|
|
4172
|
+
}
|
|
4173
|
+
|
|
3362
4174
|
// packages/safe-bash/src/commands/python/index.ts
|
|
3363
4175
|
var PythonInputChunkError = class extends RangeError {
|
|
3364
4176
|
};
|
|
@@ -3367,14 +4179,15 @@ function createPythonCommands(options) {
|
|
|
3367
4179
|
if (options.createCapabilities && !options.createExecutor) throw new TypeError("Python host capabilities require an asynchronous executor");
|
|
3368
4180
|
if (options.onDiagnostic !== void 0 && typeof options.onDiagnostic !== "function") throw new TypeError("Python onDiagnostic must be a function");
|
|
3369
4181
|
if (options.environment && options.provisioning) throw new TypeError("A borrowed Python environment cannot be combined with provisioning options");
|
|
3370
|
-
const maxTransferBytes = options.maxTransferBytes ??
|
|
4182
|
+
const maxTransferBytes = options.maxTransferBytes ?? Infinity;
|
|
4183
|
+
const transferChunkBytes = Math.min(maxTransferBytes, 65536);
|
|
3371
4184
|
const maxOpenFiles = options.maxOpenFiles;
|
|
3372
4185
|
const maxConcurrentWorkers = options.maxConcurrentWorkers ?? Infinity;
|
|
3373
4186
|
const maxInputChunkBytes = options.maxInputChunkBytes ?? Infinity;
|
|
3374
|
-
if (
|
|
3375
|
-
if (
|
|
4187
|
+
if (maxConcurrentWorkers !== Infinity && (!Number.isSafeInteger(maxConcurrentWorkers) || maxConcurrentWorkers < 1)) throw new RangeError("Invalid Python worker concurrency limit");
|
|
4188
|
+
if (maxInputChunkBytes !== Infinity && (!Number.isSafeInteger(maxInputChunkBytes) || maxInputChunkBytes < 1)) throw new RangeError("Invalid Python input chunk limit");
|
|
3376
4189
|
let activeWorkers = 0;
|
|
3377
|
-
for (const size of [maxTransferBytes, maxOpenFiles, options.maxDirectoryEntries]) if (size !== void 0 && (!Number.isSafeInteger(size) || size < 1)) throw new RangeError("Invalid Python resource limit");
|
|
4190
|
+
for (const size of [maxTransferBytes, maxOpenFiles, options.maxDirectoryEntries]) if (size !== void 0 && size !== Infinity && (!Number.isSafeInteger(size) || size < 1)) throw new RangeError("Invalid Python resource limit");
|
|
3378
4191
|
const runtimeMount = options.runtimeMount ?? "/.pyodide-runtime";
|
|
3379
4192
|
if (!runtimeMount.startsWith("/") || runtimeMount === "/" || runtimeMount.slice(1).includes("/") || runtimeMount.includes("\0") || runtimeMount.split("/").some((part) => part === ".." || part === ".")) throw new TypeError("Python runtime mount must be an absolute top-level canonical path");
|
|
3380
4193
|
const environment = options.environment ?? createPythonPackageEnvironment(options.provisioning);
|
|
@@ -3526,7 +4339,7 @@ function createPythonCommands(options) {
|
|
|
3526
4339
|
if (options.createCapabilities) {
|
|
3527
4340
|
const capabilityInput = { async *[Symbol.asyncIterator]() {
|
|
3528
4341
|
while (true) {
|
|
3529
|
-
const bytes = await dispatch({ op: "stdin", args: [
|
|
4342
|
+
const bytes = await dispatch({ op: "stdin", args: [transferChunkBytes] });
|
|
3530
4343
|
if (!bytes.length) break;
|
|
3531
4344
|
yield Uint8Array.from(bytes);
|
|
3532
4345
|
}
|
|
@@ -3634,7 +4447,7 @@ function createPythonCommands(options) {
|
|
|
3634
4447
|
} else {
|
|
3635
4448
|
let shared;
|
|
3636
4449
|
try {
|
|
3637
|
-
shared = new SharedArrayBuffer(8 +
|
|
4450
|
+
shared = new SharedArrayBuffer(8 + transferChunkBytes * 6 + 65536);
|
|
3638
4451
|
} catch (reason) {
|
|
3639
4452
|
throw reportPythonFailure("transport-unavailable", reason, options.onDiagnostic);
|
|
3640
4453
|
}
|
|
@@ -3752,7 +4565,7 @@ function createPythonCommands(options) {
|
|
|
3752
4565
|
transportFailure(reason);
|
|
3753
4566
|
}
|
|
3754
4567
|
if (settled) return;
|
|
3755
|
-
const start = { type: "start", shared, invocation: { command: context.command, args: [...context.args], cwd: context.cwd, env: { ...context.env } }, runtimeMount, maxTransferBytes, ...packages ? { packages } : {}, installOnly: !!installation };
|
|
4568
|
+
const start = { type: "start", shared, invocation: { command: context.command, args: [...context.args], cwd: context.cwd, env: { ...context.env } }, runtimeMount, maxTransferBytes: transferChunkBytes, ...packages ? { packages } : {}, installOnly: !!installation };
|
|
3756
4569
|
signal.throwIfAborted();
|
|
3757
4570
|
try {
|
|
3758
4571
|
endpoint.postMessage(start);
|
|
@@ -3823,6 +4636,8 @@ export {
|
|
|
3823
4636
|
createPythonJspiStatResult,
|
|
3824
4637
|
createPythonJspiExecutor,
|
|
3825
4638
|
createPythonJspiAssets,
|
|
4639
|
+
pythonLlmDependencies,
|
|
4640
|
+
installPythonLlmDependencies,
|
|
3826
4641
|
createPythonCommands,
|
|
3827
4642
|
pythonCommands
|
|
3828
4643
|
};
|