autohand-cli 0.9.0 → 0.9.2
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 +118 -76
- package/dist/AgentRegistry-BBQRODQC.cjs +18 -0
- package/dist/AgentRegistry-JBXZUPML.js +18 -0
- package/dist/{CommunitySkillsCache-ZEQWP6YM.js → CommunitySkillsCache-CI7UN2DX.js} +2 -2
- package/dist/CommunitySkillsCache-XTQ6RMTA.cjs +8 -0
- package/dist/{HookManager-CWLTFKWO.js → HookManager-BELBPQQI.js} +1 -1
- package/dist/{HookManager-TMAJQU4S.cjs → HookManager-ZL2CLAJW.cjs} +2 -2
- package/dist/{ImportWizard-MQXEED2U.cjs → ImportWizard-U6CIJREW.cjs} +13 -13
- package/dist/{ImportWizard-QBKQEXDW.js → ImportWizard-VJFSWSUQ.js} +4 -4
- package/dist/LearnAdvisor-LAURA3IB.cjs +9 -0
- package/dist/LearnAdvisor-RFOBXFG7.js +9 -0
- package/dist/MemoryManager-3A2VRPF2.js +9 -0
- package/dist/MemoryManager-UOEQZIDC.cjs +9 -0
- package/dist/{NVIDIAProvider-2HR737UE.js → NVIDIAProvider-AFNJNWJM.js} +1 -1
- package/dist/NVIDIAProvider-L5GTYRCQ.cjs +14 -0
- package/dist/{PermissionManager-KMYILJ4Z.js → PermissionManager-N2LDSOYF.js} +3 -3
- package/dist/PermissionManager-ZNURIEYR.cjs +11 -0
- package/dist/ProviderFactory-3BFS65V7.cjs +13 -0
- package/dist/{ProviderFactory-HFPRVQ25.js → ProviderFactory-XUT6BSGB.js} +4 -2
- package/dist/SessionManager-LGPQIA57.cjs +10 -0
- package/dist/{SessionManager-PNBTJJTQ.js → SessionManager-OR4KDDDS.js} +2 -2
- package/dist/{SkillsRegistry-4RRD5GMX.js → SkillsRegistry-IL3GWROU.js} +2 -2
- package/dist/SkillsRegistry-PM34DQNA.cjs +9 -0
- package/dist/SubAgent-2WG4QQB5.cjs +13 -0
- package/dist/SubAgent-ICGN23TQ.js +13 -0
- package/dist/{SyncApiClient-LRPFNCKJ.js → SyncApiClient-G3FM65IV.js} +1 -1
- package/dist/SyncApiClient-ODBDECOG.cjs +11 -0
- package/dist/{about-BW3PDZUU.js → about-OYVGQMJJ.js} +5 -4
- package/dist/about-U2BH7HDR.cjs +15 -0
- package/dist/{acp-VHEL7BOW.js → acp-JWHGXZL5.js} +207 -102
- package/dist/{acp-EOETGAHC.cjs → acp-S37JOBCS.cjs} +226 -121
- package/dist/actionExecutor-2QEPMELQ.cjs +28 -0
- package/dist/actionExecutor-6NCCORRB.js +28 -0
- package/dist/add-dir-KFUHSIR2.cjs +11 -0
- package/dist/{add-dir-VFX7QT4E.js → add-dir-MM2BM2Z2.js} +2 -2
- package/dist/agent-DUIYLIVN.js +132 -0
- package/dist/agent-YYEHGDAK.cjs +132 -0
- package/dist/agents-GBGG4CW7.cjs +19 -0
- package/dist/agents-ZH34C72F.js +19 -0
- package/dist/agents-new-ERXLS7SB.cjs +17 -0
- package/dist/agents-new-EVTGPTA4.js +17 -0
- package/dist/{autoSkill-EFMK6WU6.js → autoSkill-HEWKJ5JV.js} +2 -2
- package/dist/autoSkill-YL6PN6AV.cjs +20 -0
- package/dist/automode-4BJ7FNPL.cjs +10 -0
- package/dist/{automode-BMYSRM34.js → automode-S4U7A7Q2.js} +2 -2
- package/dist/chrome-45ZXHL5N.cjs +22 -0
- package/dist/{chrome-NHJ44WUN.js → chrome-BBSRVG6S.js} +2 -2
- package/dist/chrome-IFVZRHAT.cjs +50 -0
- package/dist/chrome-MYE6DNA2.js +22 -0
- package/dist/chunk-24CEJYEG.cjs +579 -0
- package/dist/{chunk-47PHDKNW.cjs → chunk-255GIVM2.cjs} +6 -6
- package/dist/{chunk-DIZTWFVR.cjs → chunk-2BDSR2OW.cjs} +238 -61
- package/dist/{chunk-BL2UC7HC.js → chunk-2BPIR7LA.js} +121 -4
- package/dist/{chunk-BQ22N3TX.cjs → chunk-2NY7OHBF.cjs} +47 -27
- package/dist/chunk-2WUNHTXL.js +303 -0
- package/dist/{chunk-HQWQZML5.cjs → chunk-34B6ZO6W.cjs} +124 -7
- package/dist/{chunk-5JTTM5SC.js → chunk-3BJN7GAH.js} +1 -1
- package/dist/{chunk-4256YRCO.cjs → chunk-3CAXECWJ.cjs} +30 -17
- package/dist/{chunk-KNTUI4TZ.cjs → chunk-3CBYUBZC.cjs} +5 -5
- package/dist/chunk-3DF3GZQ7.js +277 -0
- package/dist/{chunk-E26KKI46.cjs → chunk-3JURXAL6.cjs} +61 -8
- package/dist/{chunk-MOJ7ADW4.cjs → chunk-3KWAP2Y3.cjs} +88 -9
- package/dist/{chunk-OHWMWKJQ.js → chunk-3MCK6UBL.js} +1 -1
- package/dist/{chunk-5VHP6HDQ.js → chunk-3TH7IK4M.js} +62 -9
- package/dist/{chunk-ACDQGA4Z.js → chunk-3V77OB3W.js} +7 -72
- package/dist/{chunk-HS4USDND.cjs → chunk-3Y5UEK7K.cjs} +4 -4
- package/dist/{chunk-XV2HXRHX.js → chunk-4GPPSBEZ.js} +3 -3
- package/dist/chunk-5CMBAJ6K.js +377 -0
- package/dist/{chunk-MO4KP6XS.cjs → chunk-5YRXFBYZ.cjs} +35 -6
- package/dist/chunk-5ZNYX4VH.cjs +71 -0
- package/dist/chunk-6AC2TT26.js +156 -0
- package/dist/{chunk-UGFVM77J.cjs → chunk-6EIQ6A6U.cjs} +2 -2
- package/dist/{chunk-SWCQM52V.js → chunk-6HSEDXVF.js} +4 -4
- package/dist/{chunk-QQ7PANOP.js → chunk-6NUXK62F.js} +1 -1
- package/dist/{chunk-5CMYEM3R.cjs → chunk-6TGCAPYH.cjs} +62 -9
- package/dist/{chunk-NMQ47RCG.js → chunk-6W3SZCSP.js} +1 -1
- package/dist/{chunk-VRMZO6TB.js → chunk-73LV3DDZ.js} +7 -6
- package/dist/{chunk-3GUEUCZK.js → chunk-7BGGLIQF.js} +85 -1
- package/dist/{chunk-RBHANOYY.js → chunk-7DJJGKM6.js} +47 -3
- package/dist/{chunk-LQBONA55.cjs → chunk-7EEK7CRR.cjs} +85 -1
- package/dist/chunk-7TO3PDMV.cjs +324 -0
- package/dist/chunk-7UU22RSH.cjs +277 -0
- package/dist/{chunk-E6GFD7VR.cjs → chunk-A3GAM6FM.cjs} +11 -11
- package/dist/{chunk-DEQVRSV5.cjs → chunk-A7DJU75T.cjs} +8 -8
- package/dist/{chunk-DPSIGY6L.cjs → chunk-AAAO4ERQ.cjs} +9 -9
- package/dist/{chunk-FQAVGSPW.js → chunk-AAJLMP57.js} +2 -2
- package/dist/chunk-ABR756QN.js +529 -0
- package/dist/{chunk-JYKPWK5O.js → chunk-APFGDIPD.js} +3 -1
- package/dist/{chunk-Y3M2DABP.js → chunk-APQYRMYL.js} +4 -4
- package/dist/{chunk-Q2IL4DDI.cjs → chunk-AZKOIF2G.cjs} +62 -19
- package/dist/{chunk-MXVIDIC6.cjs → chunk-AZLHUPNC.cjs} +2 -2
- package/dist/chunk-B55VCYSQ.cjs +30 -0
- package/dist/{chunk-WZV6UVPY.js → chunk-BLQUMSM3.js} +1 -1
- package/dist/{chunk-PHJO5YAL.cjs → chunk-BXKPX6K4.cjs} +9 -9
- package/dist/{chunk-3KLSNNRW.cjs → chunk-C66FN2LP.cjs} +4 -4
- package/dist/{chunk-OV3PVUYN.js → chunk-CH7KUFAS.js} +9 -9
- package/dist/{chunk-CWINVFRI.cjs → chunk-CILSXOPI.cjs} +17 -17
- package/dist/{chunk-3UT7R3XV.js → chunk-CM24K6ZT.js} +145 -12
- package/dist/chunk-CMEZ42F2.cjs +303 -0
- package/dist/{chunk-46C73ZKK.cjs → chunk-CNQKIWIS.cjs} +152 -19
- package/dist/{chunk-5JFTY3VU.js → chunk-CSTUTDTH.js} +2 -1
- package/dist/{chunk-REMGR23V.cjs → chunk-CSUGNNJY.cjs} +10 -4
- package/dist/{chunk-TBOLJDUG.js → chunk-D6HB3H3L.js} +31 -11
- package/dist/{chunk-OM24WXEE.js → chunk-D7AYKVKW.js} +2 -2
- package/dist/{chunk-6GUODJKM.cjs → chunk-DLCXWOWT.cjs} +23 -23
- package/dist/{chunk-CH2J4PVE.cjs → chunk-DMM2BKSV.cjs} +121 -28
- package/dist/{chunk-M4KNC5BQ.js → chunk-DW3DPV77.js} +1 -1
- package/dist/chunk-ECQD2QC3.cjs +33 -0
- package/dist/{chunk-UEIXJG45.js → chunk-EEYOS3UC.js} +116 -80
- package/dist/{chunk-7HPWMALN.js → chunk-EF2EN5CR.js} +2 -2
- package/dist/{chunk-7LWQCE4Y.cjs → chunk-EFXFURDY.cjs} +192 -58
- package/dist/chunk-EK34UZPB.cjs +40 -0
- package/dist/{chunk-7JLT2VNW.cjs → chunk-FJR6EZLO.cjs} +9666 -7201
- package/dist/{chunk-GZ6DV2UG.js → chunk-FPO7YNPQ.js} +1 -1
- package/dist/{chunk-O64I2GYI.js → chunk-FS4I6BNR.js} +1 -1
- package/dist/{chunk-MX75JYIY.js → chunk-FSJ2MNOC.js} +3 -3
- package/dist/{chunk-7RFJB75Y.js → chunk-GEHZMC4G.js} +11 -8
- package/dist/{chunk-UWFG2R2I.cjs → chunk-GO6C2RAR.cjs} +36 -9
- package/dist/{chunk-WGLBC5AY.cjs → chunk-GSMR6V36.cjs} +4 -4
- package/dist/{chunk-Z3XSSF7B.js → chunk-GSZWATME.js} +1 -1
- package/dist/{chunk-7MU7LWF3.cjs → chunk-GYLGCR6F.cjs} +5 -5
- package/dist/{chunk-O6TQP7U7.cjs → chunk-H3OOWNYQ.cjs} +3 -3
- package/dist/{chunk-2QL6MNXG.js → chunk-H65446XW.js} +115 -20
- package/dist/chunk-H7HXRRHK.js +324 -0
- package/dist/{chunk-ZZ63NW7A.cjs → chunk-HN2JTDN5.cjs} +17 -17
- package/dist/{chunk-AOKCI722.cjs → chunk-HNXUZ5OY.cjs} +2 -2
- package/dist/{chunk-AUYSIEVV.cjs → chunk-HOYT3E65.cjs} +3 -3
- package/dist/{chunk-DMRXF5DU.js → chunk-HTPY5ESD.js} +3 -3
- package/dist/chunk-HTU4W3GB.js +183 -0
- package/dist/{chunk-3DDL2E55.cjs → chunk-HVLWH2AF.cjs} +10 -10
- package/dist/{chunk-HSCUPEA4.cjs → chunk-HZTEU4W5.cjs} +74 -105
- package/dist/{chunk-XGMI6IYB.cjs → chunk-I5T7LPFP.cjs} +7 -7
- package/dist/{chunk-XIVFAD2L.js → chunk-IB5CJXE7.js} +173 -12
- package/dist/chunk-INNXFLDR.cjs +388 -0
- package/dist/{chunk-75EDROHL.cjs → chunk-JFLEP3T7.cjs} +10 -10
- package/dist/chunk-JJGDOBFL.js +40 -0
- package/dist/{chunk-VBOFPU5M.cjs → chunk-JM3ZTQUK.cjs} +13 -9
- package/dist/{chunk-HJIXWGQZ.js → chunk-JSU46T6K.js} +1 -1
- package/dist/{chunk-AT7OWLY5.js → chunk-K6WN6BT4.js} +1 -1
- package/dist/{chunk-LN7D3EJZ.js → chunk-KA2U6MY2.js} +4 -3
- package/dist/{chunk-3S563FNF.cjs → chunk-KIQH3SMT.cjs} +34 -31
- package/dist/{chunk-BWF4VDYE.js → chunk-KPRXHIE2.js} +54 -85
- package/dist/{chunk-Z4LIPMPM.js → chunk-L6OH44HL.js} +13 -9
- package/dist/{chunk-A7HHCIDQ.js → chunk-LIO3RX2Z.js} +2 -2
- package/dist/{chunk-DLP436GI.js → chunk-LOSXLH7P.js} +110 -17
- package/dist/{chunk-IEXKKKOF.cjs → chunk-LSOR72PB.cjs} +23 -23
- package/dist/{chunk-IAGCRVJ3.js → chunk-MA3AVDCC.js} +55 -12
- package/dist/{chunk-B5CGDNMR.js → chunk-ME3S2WIR.js} +3 -3
- package/dist/{chunk-HKYZSUQ5.js → chunk-NC2I2M4P.js} +4 -4
- package/dist/{chunk-GBMDFWJX.cjs → chunk-NC4A4LVC.cjs} +13 -13
- package/dist/{chunk-E46DJH5S.js → chunk-NGEK5FCJ.js} +176 -3
- package/dist/{chunk-TQ33WBY5.cjs → chunk-NHWHEW7M.cjs} +2 -1
- package/dist/{chunk-62RTC3XX.js → chunk-NKW6CHXQ.js} +1 -1
- package/dist/{chunk-3PXKRVCW.js → chunk-NOWCRKP2.js} +10 -4
- package/dist/{chunk-HXJEGMGB.js → chunk-NUB2LMB6.js} +2 -2
- package/dist/chunk-NVATU4V6.cjs +44 -0
- package/dist/chunk-O246MKIW.cjs +267 -0
- package/dist/{chunk-QCHIDZBA.js → chunk-OGFWL2PS.js} +1 -1
- package/dist/{chunk-JJ4KA7HK.cjs → chunk-ONNGAR6W.cjs} +415 -551
- package/dist/{chunk-TKKN34TV.js → chunk-OOFR6A62.js} +33 -4
- package/dist/{chunk-6NVAK6CK.js → chunk-OZ7FHO7J.js} +2 -2
- package/dist/{chunk-2CGE7ZV3.cjs → chunk-P5EWGUI2.cjs} +201 -28
- package/dist/{chunk-GGLKUENP.js → chunk-P6BQJPAI.js} +191 -14
- package/dist/{chunk-TWQDAUZU.js → chunk-PG2JIU5M.js} +60 -7
- package/dist/chunk-PI27G2ED.cjs +377 -0
- package/dist/{chunk-YV63VW4K.js → chunk-PI7LRPL6.js} +1 -1
- package/dist/{chunk-TXPSTCG7.cjs → chunk-PMPEC5HN.cjs} +18 -15
- package/dist/{chunk-ROLA6EFO.cjs → chunk-PYUP7AKY.cjs} +14 -14
- package/dist/{chunk-BFQDQRDE.js → chunk-QC5Z3ZT5.js} +2 -2
- package/dist/chunk-QDO4L2A7.cjs +156 -0
- package/dist/{chunk-LFDPTJYF.cjs → chunk-QDXRI5AM.cjs} +1 -1
- package/dist/{chunk-3LJJG5YY.cjs → chunk-QLZOMZO5.cjs} +4 -3
- package/dist/chunk-QVXMSQOG.js +430 -0
- package/dist/{chunk-ZHJ7JGME.cjs → chunk-R4UKBKDY.cjs} +11 -11
- package/dist/{chunk-IGMPWJ2I.cjs → chunk-R75AWII3.cjs} +118 -23
- package/dist/{chunk-VGEV44V2.cjs → chunk-RD5PLUIX.cjs} +191 -30
- package/dist/{chunk-I24CWKKK.js → chunk-RGB34CV5.js} +3 -3
- package/dist/{chunk-CHI52KFR.cjs → chunk-RJCZLFHE.cjs} +246 -39
- package/dist/{chunk-D2OSPLYC.cjs → chunk-RKWNM2BJ.cjs} +2 -2
- package/dist/{chunk-FGT6KK6T.js → chunk-RMVONICR.js} +3 -3
- package/dist/{chunk-Q6AC3PHY.cjs → chunk-RPSYRJL7.cjs} +10 -4
- package/dist/chunk-RS2E32YB.js +71 -0
- package/dist/chunk-RWKU2X7O.js +388 -0
- package/dist/chunk-RZLEGVMH.cjs +565 -0
- package/dist/{chunk-5F6ZKSHO.js → chunk-S2L3Y677.js} +1 -1
- package/dist/{chunk-ARBEHFCG.js → chunk-S7KVUIOS.js} +1 -1
- package/dist/{chunk-AC7DZ6SK.cjs → chunk-SACJJ6NO.cjs} +5 -3
- package/dist/{chunk-IKUMVBCW.cjs → chunk-SD3NTC7D.cjs} +48 -4
- package/dist/{chunk-CBFH2J3O.js → chunk-SJQU2ZFR.js} +246 -39
- package/dist/{chunk-GWO66KBI.js → chunk-SKAQKQFF.js} +12 -2
- package/dist/chunk-T4DXP5OP.js +30 -0
- package/dist/{chunk-CFFE4VA3.js → chunk-T6FTB6K2.js} +1 -1
- package/dist/{chunk-U4C3HW6P.js → chunk-T6N6GRFT.js} +13 -10
- package/dist/{chunk-D6GZBSOX.js → chunk-TJFKA6A7.js} +82 -3
- package/dist/{chunk-2HOLOHVK.js → chunk-TJZUPS4Z.js} +163 -299
- package/dist/{chunk-RBZ7AFX7.cjs → chunk-TLKHZ425.cjs} +2 -2
- package/dist/{chunk-J2K57QM7.cjs → chunk-TQ24NLXO.cjs} +6 -6
- package/dist/{chunk-LUMV3DB2.js → chunk-TWBAU46X.js} +1 -1
- package/dist/{chunk-OPNI6O7F.cjs → chunk-TZB5XADL.cjs} +4 -4
- package/dist/{chunk-6HH236FV.cjs → chunk-UAYXZXWU.cjs} +4 -4
- package/dist/{chunk-MPULXVC4.cjs → chunk-UKBFNBDO.cjs} +11 -11
- package/dist/chunk-UMJYX5KD.js +565 -0
- package/dist/chunk-USKYTHDL.cjs +235 -0
- package/dist/chunk-V4HGZSKQ.cjs +183 -0
- package/dist/{chunk-MQESBFBZ.cjs → chunk-VAJUSZMC.cjs} +21 -20
- package/dist/{chunk-PQLKJCIE.js → chunk-VGQG4NBJ.js} +2 -2
- package/dist/chunk-VLUIVJ3J.js +235 -0
- package/dist/chunk-VOBINVMV.cjs +430 -0
- package/dist/{chunk-L4F7SUYL.js → chunk-VSHKKCSH.js} +16 -5
- package/dist/{chunk-LDJQ5QHG.cjs → chunk-VSZU3MGA.cjs} +28 -17
- package/dist/{chunk-YFXTE422.cjs → chunk-VWHAUB77.cjs} +8 -3
- package/dist/{chunk-EZJHLOWP.js → chunk-VXGYFX45.js} +20 -7
- package/dist/{chunk-JIMSII7R.js → chunk-WH6YUQDB.js} +193 -59
- package/dist/{chunk-VKBIE6I6.js → chunk-WQ6TD55V.js} +2 -2
- package/dist/{chunk-ZR46OJNZ.js → chunk-WQWECXTY.js} +3 -3
- package/dist/{chunk-SOLBYSLY.cjs → chunk-WVDJUJH6.cjs} +2 -2
- package/dist/{chunk-QKP772OZ.js → chunk-X24VIVDZ.js} +963 -103
- package/dist/{chunk-37M5UM6I.js → chunk-X4NRTLXD.js} +7 -1
- package/dist/chunk-X53SHYCG.js +27 -0
- package/dist/{chunk-PUD76XQT.cjs → chunk-XB2Z4ZAK.cjs} +5 -5
- package/dist/chunk-Y47OJGLB.cjs +27 -0
- package/dist/{chunk-WRTXCQ3V.cjs → chunk-Y4MN27V3.cjs} +1080 -220
- package/dist/{chunk-ZK6HOR62.js → chunk-YEHFYZFU.js} +7 -2
- package/dist/{chunk-FFBDRUO5.cjs → chunk-YICIUY23.cjs} +1 -1
- package/dist/{chunk-PDHT7LQS.cjs → chunk-YMXYC777.cjs} +3 -3
- package/dist/{chunk-TJNBASFD.cjs → chunk-Z3GRWK6O.cjs} +8 -8
- package/dist/{chunk-JP3YHTQ2.cjs → chunk-Z5GG2KSL.cjs} +4 -4
- package/dist/{chunk-ZPD2AO3U.js → chunk-ZER7DYQK.js} +2 -2
- package/dist/{chunk-UXLW45ZE.cjs → chunk-ZFDXZEZJ.cjs} +25 -90
- package/dist/chunk-ZFV4HJA6.js +579 -0
- package/dist/chunk-ZHMYTI5D.cjs +529 -0
- package/dist/{chunk-CCVMREXI.js → chunk-ZLR2TFBC.js} +35 -8
- package/dist/{chunk-J5ADZN6V.cjs → chunk-ZTWNU5QZ.cjs} +20 -20
- package/dist/chunk-ZUYYHKQA.js +44 -0
- package/dist/{chunk-AUFNACED.js → chunk-ZVLVLDYN.js} +9086 -6621
- package/dist/clear-AJGXD2BB.cjs +12 -0
- package/dist/{clear-OFLFQ3MR.js → clear-HAHDSWKW.js} +3 -3
- package/dist/communityInstaller-IRR6M3N6.cjs +22 -0
- package/dist/{communityInstaller-COB2KTOW.js → communityInstaller-OLKEUGMX.js} +6 -6
- package/dist/completion-G7Z436TF.cjs +17 -0
- package/dist/{completion-PT4VM2H2.js → completion-ZS3AXJ6A.js} +5 -5
- package/dist/{config-R4O7GBTY.js → config-OWYAQPCX.js} +5 -3
- package/dist/config-W2BHT2QE.cjs +22 -0
- package/dist/{constants-HVCHVQAF.js → constants-AS6K67AA.js} +5 -3
- package/dist/constants-B4W5BT7F.cjs +23 -0
- package/dist/{export-3PK3VFCE.js → export-5HIU3KMD.js} +5 -5
- package/dist/export-GFD32UY2.cjs +15 -0
- package/dist/{extractSessionMemories-A2JX5WJ2.js → extractSessionMemories-K6ZVAW2F.js} +1 -1
- package/dist/{extractSessionMemories-XL3MS37F.cjs → extractSessionMemories-LLOIJR5U.cjs} +2 -2
- package/dist/feature-KP74CZ3F.cjs +14 -0
- package/dist/feature-OPNVMB2E.js +14 -0
- package/dist/features-LT55MURX.cjs +24 -0
- package/dist/features-ZDIU26WX.js +24 -0
- package/dist/feedback-7WTJFQ6S.js +18 -0
- package/dist/feedback-CEOJ3453.cjs +18 -0
- package/dist/go-2CY5SZNR.js +16 -0
- package/dist/go-O2CSQON4.cjs +16 -0
- package/dist/goal-DL2N2AWT.cjs +16 -0
- package/dist/goal-IJS7VZSG.js +16 -0
- package/dist/help-RNOGDEBA.cjs +12 -0
- package/dist/{help-X3OAZ3CY.js → help-TCWD2IRH.js} +2 -2
- package/dist/{history-YKFPHBJN.js → history-ATOR5OQV.js} +2 -2
- package/dist/history-UUSGX2AL.cjs +14 -0
- package/dist/{hooks-7TA4PIIB.js → hooks-R3Z5QKUP.js} +6 -6
- package/dist/hooks-RWM5UY67.cjs +18 -0
- package/dist/{i18n-2KBUU7XL.js → i18n-4QI4TD4I.js} +1 -1
- package/dist/i18n-MFAEU5RV.cjs +33 -0
- package/dist/ide-6PBTCCUQ.js +15 -0
- package/dist/ide-UE3G7NMQ.cjs +15 -0
- package/dist/{import-I7T4ZHYL.cjs → import-2IG76KAN.cjs} +6 -4
- package/dist/{import-JWPYKXCZ.js → import-E47QL4DW.js} +2 -2
- package/dist/import-NQDNBFUL.cjs +10 -0
- package/dist/{import-4CHYLS4K.js → import-VQIHGJWS.js} +6 -4
- package/dist/index.cjs +512 -305
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +402 -195
- package/dist/init-DX3RDGDT.cjs +10 -0
- package/dist/{init-262MWZV4.js → init-Q54OAAFZ.js} +2 -2
- package/dist/{inputPrompt-YGBHDUEP.js → inputPrompt-V2VBDRM7.js} +3 -3
- package/dist/inputPrompt-WVGVWAHS.cjs +90 -0
- package/dist/language-I6KXAOXD.js +23 -0
- package/dist/language-XMIVOH5E.cjs +23 -0
- package/dist/learn-JPVVGTKU.js +23 -0
- package/dist/learn-NLSHI2MZ.cjs +23 -0
- package/dist/login-NABQYLYC.cjs +28 -0
- package/dist/login-XPOVFSWN.js +28 -0
- package/dist/logout-HNHCGB4Q.js +25 -0
- package/dist/logout-SKGDXJSW.cjs +25 -0
- package/dist/{mcp-5O6PUL4G.js → mcp-EN73YFGZ.js} +8 -6
- package/dist/mcp-TADZCPJQ.cjs +22 -0
- package/dist/{mcp-install-P6DHES7V.cjs → mcp-install-2GKWWBAS.cjs} +15 -13
- package/dist/{mcp-install-6XWXLFVY.js → mcp-install-3TBTVSHW.js} +10 -8
- package/dist/memory-GRXFTDIN.cjs +10 -0
- package/dist/{memory-Q54CESNM.js → memory-K2P3CDCH.js} +2 -2
- package/dist/{model-6AJ77PJG.js → model-DEG22OWA.js} +2 -2
- package/dist/model-OSD74T7Z.cjs +10 -0
- package/dist/new-4NWBOATU.cjs +12 -0
- package/dist/{new-ZXHEWC2S.js → new-KJAP2MB6.js} +3 -3
- package/dist/onboarding-2U5WE2OA.js +39 -0
- package/dist/onboarding-5DZFCO5Q.cjs +39 -0
- package/dist/permissions-KY5I6YQ3.cjs +10 -0
- package/dist/{permissions-YHJMVA6L.js → permissions-TKYON7PP.js} +2 -2
- package/dist/{plan-YYUAXPTL.js → plan-DYHHLZSS.js} +1 -1
- package/dist/plan-PYKP652W.cjs +13 -0
- package/dist/quit-GSKJL42O.js +14 -0
- package/dist/quit-TQSRTBUT.cjs +14 -0
- package/dist/{registry-34GL6BNJ.js → registry-EZ4V4TUQ.js} +1339 -1
- package/dist/{registry-V24W7YK6.cjs → registry-LCWYI4IB.cjs} +1378 -40
- package/dist/resume-4VWJXARX.cjs +17 -0
- package/dist/resume-TLHWWWFN.js +17 -0
- package/dist/{review-QHP2KP4Q.js → review-CSK4IYTO.js} +1 -1
- package/dist/review-XLJEUH5K.cjs +9 -0
- package/dist/{rpc-S3DGW6KV.js → rpc-3DLQBDWU.js} +301 -130
- package/dist/{rpc-NPS3PU4O.cjs → rpc-O36WUU3L.cjs} +399 -228
- package/dist/search-DSX2CY4A.cjs +22 -0
- package/dist/search-I3QUDUQL.js +22 -0
- package/dist/sessionBranching-DVNOUWJT.cjs +19 -0
- package/dist/sessionBranching-FKV4CR36.js +19 -0
- package/dist/sessions-3JUOT3ED.cjs +10 -0
- package/dist/{sessions-IYAXMK23.js → sessions-VWMDIPOS.js} +2 -2
- package/dist/settings-FT2LZZUV.js +45 -0
- package/dist/settings-RL4KNWHB.cjs +45 -0
- package/dist/setup-HQEJVOYT.js +32 -0
- package/dist/setup-MN54LKOL.cjs +32 -0
- package/dist/share-BUAFZNBX.cjs +17 -0
- package/dist/share-CGB6MAVJ.js +17 -0
- package/dist/skills/builtin/code-reviewer/SKILL.md +64 -0
- package/dist/skills/builtin/goal-writer/SKILL.md +124 -0
- package/dist/{skills-VWOMV3CR.js → skills-7DKR3HRZ.js} +8 -8
- package/dist/{skills-MVIZNHT4.js → skills-BBBENOEY.js} +9 -9
- package/dist/skills-OQM7IHAF.cjs +29 -0
- package/dist/{skills-GGMZOVIE.cjs → skills-RA2PKL63.cjs} +10 -10
- package/dist/{skills-install-VTAMCNNY.cjs → skills-install-D7K476SL.cjs} +16 -16
- package/dist/{skills-install-QBA5RCV6.js → skills-install-T4SOKJSL.js} +9 -9
- package/dist/skills-new-S33NGEU3.js +18 -0
- package/dist/skills-new-UVYH53MD.cjs +18 -0
- package/dist/slashCommands-MWOUDSQP.js +111 -0
- package/dist/slashCommands-XASURUTV.cjs +111 -0
- package/dist/squad-PIIYDFVH.cjs +15 -0
- package/dist/squad-VHYOVEJP.js +15 -0
- package/dist/status-GHFTXQBL.js +25 -0
- package/dist/status-WXMIJIU3.cjs +25 -0
- package/dist/statusline-2K7AC6ZQ.js +21 -0
- package/dist/statusline-GROI4HOC.cjs +21 -0
- package/dist/sync-254WF6JI.cjs +42 -0
- package/dist/sync-2DIZN4EH.cjs +24 -0
- package/dist/{sync-7BILIQHP.js → sync-J6I2ZUKQ.js} +6 -4
- package/dist/{sync-7OKF6636.js → sync-Z3LVSEEV.js} +8 -5
- package/dist/{teammate-J6PHGL23.cjs → teammate-EXR76PEQ.cjs} +9 -8
- package/dist/{teammate-GZQSCIMS.js → teammate-K4DAOFEQ.js} +8 -7
- package/dist/templates-ARG2VRWW.cjs +11 -0
- package/dist/templates-UGVZV3KJ.js +11 -0
- package/dist/theme-MVQDSU47.js +23 -0
- package/dist/theme-QAKEYWJG.cjs +23 -0
- package/dist/ui/questionModal.cjs +6 -6
- package/dist/ui/questionModal.js +5 -5
- package/dist/{undo-SZEHLX7X.js → undo-5AU47JHF.js} +2 -2
- package/dist/undo-ME6WKUXZ.cjs +10 -0
- package/dist/usage-QTKO2YMD.js +25 -0
- package/dist/usage-TYNJKVER.cjs +25 -0
- package/package.json +10 -4
- package/dist/AgentRegistry-EGBDIUAK.cjs +0 -10
- package/dist/AgentRegistry-XPWSVO3Q.js +0 -10
- package/dist/CommunitySkillsCache-2OIUV227.cjs +0 -8
- package/dist/LearnAdvisor-46FG2XIP.js +0 -9
- package/dist/LearnAdvisor-XBRDNAGH.cjs +0 -9
- package/dist/MemoryManager-34L4YOKA.cjs +0 -8
- package/dist/MemoryManager-WJMLPWGU.js +0 -8
- package/dist/NVIDIAProvider-MVTL62PR.cjs +0 -14
- package/dist/PermissionManager-5OOJ7FAT.cjs +0 -11
- package/dist/ProviderFactory-C3YPXTDD.cjs +0 -11
- package/dist/SessionManager-WAPTFMDO.cjs +0 -10
- package/dist/SkillsRegistry-7AJP74GJ.cjs +0 -9
- package/dist/SubAgent-FDIH3DXB.js +0 -11
- package/dist/SubAgent-HVL2ICVZ.cjs +0 -11
- package/dist/SyncApiClient-VMBOLQ6H.cjs +0 -11
- package/dist/about-FCAX37YC.cjs +0 -14
- package/dist/actionExecutor-33I47NZS.js +0 -24
- package/dist/actionExecutor-4YBMR3YH.cjs +0 -24
- package/dist/add-dir-7SS6KSH5.cjs +0 -11
- package/dist/agent-DMRUFU4M.cjs +0 -116
- package/dist/agent-WCJEYQJT.js +0 -116
- package/dist/agents-CHROO3VU.cjs +0 -17
- package/dist/agents-UVDUL65K.js +0 -17
- package/dist/agents-new-AUBWSOXP.js +0 -17
- package/dist/agents-new-Y562WC47.cjs +0 -17
- package/dist/autoSkill-YOLLFTP2.cjs +0 -20
- package/dist/automode-DBLKTTKD.cjs +0 -10
- package/dist/chrome-ATC4OO5I.cjs +0 -20
- package/dist/chrome-O62WXV7F.js +0 -20
- package/dist/chrome-XHJLCO4M.cjs +0 -50
- package/dist/chunk-6XVVIY54.cjs +0 -256
- package/dist/chunk-AU6JAGZJ.cjs +0 -231
- package/dist/chunk-N6O3XUZ2.cjs +0 -23
- package/dist/chunk-VDWJMWDF.js +0 -256
- package/dist/clear-33TWQ2ES.cjs +0 -12
- package/dist/communityInstaller-TWMGPSYM.cjs +0 -22
- package/dist/completion-IIZMHXYP.cjs +0 -17
- package/dist/config-KL6WU7R2.cjs +0 -20
- package/dist/constants-RLMJ5D5P.cjs +0 -21
- package/dist/export-WLGNWEMJ.cjs +0 -15
- package/dist/feedback-G635NCLJ.js +0 -18
- package/dist/feedback-LLMK3TZH.cjs +0 -18
- package/dist/help-BAXLP2M2.cjs +0 -12
- package/dist/history-6HOJSEMT.cjs +0 -14
- package/dist/hooks-XVFU67T2.cjs +0 -18
- package/dist/i18n-MUJMKTFM.cjs +0 -33
- package/dist/ide-CCQ33PGC.cjs +0 -15
- package/dist/ide-VLVFBZ5F.js +0 -15
- package/dist/import-J46F54JY.cjs +0 -10
- package/dist/init-EE5Y7RBL.cjs +0 -10
- package/dist/inputPrompt-IIFKCX5Q.cjs +0 -90
- package/dist/language-CVLPB7OV.js +0 -21
- package/dist/language-ZTWFHUSV.cjs +0 -21
- package/dist/learn-PON7I5QS.js +0 -23
- package/dist/learn-XLRSVNA3.cjs +0 -23
- package/dist/login-223QTGBG.cjs +0 -26
- package/dist/login-6IKTBUBY.js +0 -26
- package/dist/logout-RN2AG6SI.js +0 -23
- package/dist/logout-U3M4FFX7.cjs +0 -23
- package/dist/mcp-NUQ76QQB.cjs +0 -20
- package/dist/memory-CYMDQ2YC.cjs +0 -10
- package/dist/model-IDRCKDML.cjs +0 -10
- package/dist/new-7LEWOUF2.cjs +0 -12
- package/dist/onboarding-FXX7YHSJ.cjs +0 -35
- package/dist/onboarding-JYNMK6NI.js +0 -35
- package/dist/permissions-YBNSANIA.cjs +0 -10
- package/dist/plan-XEJMOT55.cjs +0 -13
- package/dist/quit-B43SJ6E4.cjs +0 -10
- package/dist/quit-GWTNHQSP.js +0 -10
- package/dist/resume-DYVOQN5L.cjs +0 -16
- package/dist/resume-M25UQKOX.js +0 -16
- package/dist/review-UWHWQHCB.cjs +0 -9
- package/dist/search-CPX4PWHP.js +0 -20
- package/dist/search-VUF3M4N3.cjs +0 -20
- package/dist/sessions-JODKER5D.cjs +0 -10
- package/dist/settings-55BNW6BF.js +0 -33
- package/dist/settings-BKTS7OMC.cjs +0 -33
- package/dist/setup-IRC5HQG2.js +0 -29
- package/dist/setup-MMQ7TWOP.cjs +0 -29
- package/dist/share-6JRQECAH.cjs +0 -17
- package/dist/share-YM5MJKMO.js +0 -17
- package/dist/skills-LWSOKOSH.cjs +0 -29
- package/dist/skills-new-GPL46YV2.js +0 -18
- package/dist/skills-new-L5BEZN5V.cjs +0 -18
- package/dist/slashCommands-FBPCIWM5.cjs +0 -95
- package/dist/slashCommands-FCWY5DXW.js +0 -95
- package/dist/status-3B5SDZPL.js +0 -17
- package/dist/status-TTGRF6NC.cjs +0 -17
- package/dist/sync-77CXVVTK.cjs +0 -21
- package/dist/sync-EH4K5U3N.cjs +0 -40
- package/dist/theme-64BYGJ57.cjs +0 -21
- package/dist/theme-YJE6HEON.js +0 -21
- package/dist/undo-PRTEGL2J.cjs +0 -10
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
var _chunkGO6C2RARcjs = require('./chunk-GO6C2RAR.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
var _chunk3OF56EMAcjs = require('./chunk-3OF56EMA.cjs');
|
|
8
9
|
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkEK34UZPBcjs = require('./chunk-EK34UZPB.cjs');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunk7TO3PDMVcjs = require('./chunk-7TO3PDMV.cjs');
|
|
17
|
+
|
|
9
18
|
// src/providers/OllamaProvider.ts
|
|
10
19
|
var DEFAULT_TIMEOUT = 12e4;
|
|
11
20
|
var DEFAULT_CHUNK_TIMEOUT = 3e4;
|
|
@@ -33,6 +42,9 @@ var OllamaProvider = (_class = class {
|
|
|
33
42
|
getName() {
|
|
34
43
|
return "ollama";
|
|
35
44
|
}
|
|
45
|
+
getCapabilities() {
|
|
46
|
+
return { nativeToolCalling: true };
|
|
47
|
+
}
|
|
36
48
|
setModel(model) {
|
|
37
49
|
this.model = model;
|
|
38
50
|
}
|
|
@@ -162,9 +174,10 @@ var OllamaProvider = (_class = class {
|
|
|
162
174
|
return this.handleStreamingResponse(response);
|
|
163
175
|
}
|
|
164
176
|
const data = await response.json();
|
|
177
|
+
const message = _nullishCoalesce(data.message, () => ( { role: "assistant", content: "" }));
|
|
165
178
|
let toolCalls;
|
|
166
|
-
if (
|
|
167
|
-
toolCalls =
|
|
179
|
+
if (message.tool_calls && Array.isArray(message.tool_calls)) {
|
|
180
|
+
toolCalls = message.tool_calls.map((tc, index) => {
|
|
168
181
|
let argumentsStr;
|
|
169
182
|
try {
|
|
170
183
|
argumentsStr = JSON.stringify(tc.function.arguments);
|
|
@@ -182,18 +195,14 @@ var OllamaProvider = (_class = class {
|
|
|
182
195
|
};
|
|
183
196
|
});
|
|
184
197
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
completionTokens: _nullishCoalesce(data.eval_count, () => ( 0)),
|
|
190
|
-
totalTokens: (_nullishCoalesce(data.prompt_eval_count, () => ( 0))) + (_nullishCoalesce(data.eval_count, () => ( 0)))
|
|
191
|
-
};
|
|
192
|
-
}
|
|
198
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, {
|
|
199
|
+
prompt_tokens: data.prompt_eval_count,
|
|
200
|
+
completion_tokens: data.eval_count
|
|
201
|
+
});
|
|
193
202
|
return {
|
|
194
203
|
id: `ollama-${Date.now()}`,
|
|
195
204
|
created: Math.floor(new Date(data.created_at).getTime() / 1e3),
|
|
196
|
-
content:
|
|
205
|
+
content: message.content,
|
|
197
206
|
toolCalls,
|
|
198
207
|
finishReason: _optionalChain([toolCalls, 'optionalAccess', _6 => _6.length]) ? "tool_calls" : "stop",
|
|
199
208
|
usage,
|
|
@@ -402,7 +411,7 @@ ${content}`
|
|
|
402
411
|
for (const line of lines) {
|
|
403
412
|
try {
|
|
404
413
|
const data = JSON.parse(line);
|
|
405
|
-
fullContent += data.message.content;
|
|
414
|
+
fullContent += _nullishCoalesce(_optionalChain([data, 'access', _14 => _14.message, 'optionalAccess', _15 => _15.content]), () => ( ""));
|
|
406
415
|
lastData = data;
|
|
407
416
|
if (data.done) {
|
|
408
417
|
streamEndedWithDone = true;
|
|
@@ -502,7 +511,7 @@ function decodeJwtPayload(token) {
|
|
|
502
511
|
}
|
|
503
512
|
function decodeJwtExpiry(token) {
|
|
504
513
|
const payload = decodeJwtPayload(token);
|
|
505
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
514
|
+
if (!_optionalChain([payload, 'optionalAccess', _16 => _16.exp])) return void 0;
|
|
506
515
|
return new Date(payload.exp * 1e3).toISOString();
|
|
507
516
|
}
|
|
508
517
|
function buildTokenBody(params) {
|
|
@@ -612,7 +621,7 @@ async function listenForOAuthCallback(expectedState) {
|
|
|
612
621
|
res.statusCode = 400;
|
|
613
622
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
614
623
|
res.end(callbackErrorHtml(errorDescription || error));
|
|
615
|
-
_optionalChain([settle, 'optionalCall',
|
|
624
|
+
_optionalChain([settle, 'optionalCall', _17 => _17({
|
|
616
625
|
error,
|
|
617
626
|
errorDescription: errorDescription || void 0
|
|
618
627
|
})]);
|
|
@@ -623,7 +632,7 @@ async function listenForOAuthCallback(expectedState) {
|
|
|
623
632
|
res.statusCode = 400;
|
|
624
633
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
625
634
|
res.end(callbackErrorHtml("State mismatch."));
|
|
626
|
-
_optionalChain([settle, 'optionalCall',
|
|
635
|
+
_optionalChain([settle, 'optionalCall', _18 => _18({
|
|
627
636
|
error: "state_mismatch",
|
|
628
637
|
errorDescription: "State mismatch."
|
|
629
638
|
})]);
|
|
@@ -634,7 +643,7 @@ async function listenForOAuthCallback(expectedState) {
|
|
|
634
643
|
res.statusCode = 400;
|
|
635
644
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
636
645
|
res.end(callbackErrorHtml("Missing authorization code."));
|
|
637
|
-
_optionalChain([settle, 'optionalCall',
|
|
646
|
+
_optionalChain([settle, 'optionalCall', _19 => _19({
|
|
638
647
|
error: "missing_code",
|
|
639
648
|
errorDescription: "Missing authorization code."
|
|
640
649
|
})]);
|
|
@@ -643,19 +652,19 @@ async function listenForOAuthCallback(expectedState) {
|
|
|
643
652
|
res.statusCode = 200;
|
|
644
653
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
645
654
|
res.end(callbackSuccessHtml());
|
|
646
|
-
_optionalChain([settle, 'optionalCall',
|
|
655
|
+
_optionalChain([settle, 'optionalCall', _20 => _20({ code })]);
|
|
647
656
|
} catch (e9) {
|
|
648
657
|
res.statusCode = 500;
|
|
649
658
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
650
659
|
res.end(callbackErrorHtml("Internal error while handling the callback."));
|
|
651
|
-
_optionalChain([settle, 'optionalCall',
|
|
660
|
+
_optionalChain([settle, 'optionalCall', _21 => _21({
|
|
652
661
|
error: "callback_error",
|
|
653
662
|
errorDescription: "Internal error while handling the callback."
|
|
654
663
|
})]);
|
|
655
664
|
}
|
|
656
665
|
});
|
|
657
666
|
const timeoutId = setTimeout(() => {
|
|
658
|
-
_optionalChain([settle, 'optionalCall',
|
|
667
|
+
_optionalChain([settle, 'optionalCall', _22 => _22({
|
|
659
668
|
error: "timeout",
|
|
660
669
|
errorDescription: "OpenAI sign-in timed out. Finish the browser sign-in and try again."
|
|
661
670
|
})]);
|
|
@@ -703,7 +712,7 @@ async function listenForOAuthCallback(expectedState) {
|
|
|
703
712
|
}
|
|
704
713
|
function extractChatGPTAccountId(token) {
|
|
705
714
|
const payload = decodeJwtPayload(token);
|
|
706
|
-
return _optionalChain([payload, 'optionalAccess',
|
|
715
|
+
return _optionalChain([payload, 'optionalAccess', _23 => _23["https://api.openai.com/auth"], 'optionalAccess', _24 => _24.chatgpt_account_id]);
|
|
707
716
|
}
|
|
708
717
|
function isChatGPTAuthExpired(auth, leewayMs = 6e4) {
|
|
709
718
|
if (!auth.expiresAt) return false;
|
|
@@ -727,7 +736,7 @@ async function authenticateOpenAIChatGPT(options = {}) {
|
|
|
727
736
|
authorizeUrl.searchParams.set("codex_cli_simplified_flow", "true");
|
|
728
737
|
authorizeUrl.searchParams.set("originator", OPENAI_BROWSER_OAUTH_ORIGINATOR);
|
|
729
738
|
const browserOpened = await openBrowser(authorizeUrl.toString());
|
|
730
|
-
await _optionalChain([options, 'access',
|
|
739
|
+
await _optionalChain([options, 'access', _25 => _25.onPrompt, 'optionalCall', _26 => _26({
|
|
731
740
|
authorizationUrl: authorizeUrl.toString(),
|
|
732
741
|
redirectUri: callback.redirectUri,
|
|
733
742
|
browserOpened
|
|
@@ -812,6 +821,8 @@ async function refreshChatGPTAuth(auth) {
|
|
|
812
821
|
|
|
813
822
|
// src/providers/OpenAIProvider.ts
|
|
814
823
|
var OPENAI_MODELS = [
|
|
824
|
+
"gpt-5.5",
|
|
825
|
+
"gpt-5.5-pro",
|
|
815
826
|
"gpt-5.4",
|
|
816
827
|
"gpt-5.4-pro",
|
|
817
828
|
"gpt-5.4-mini",
|
|
@@ -859,12 +870,17 @@ var OpenAIProvider = class {
|
|
|
859
870
|
setModel(model) {
|
|
860
871
|
this.model = model;
|
|
861
872
|
}
|
|
873
|
+
getCapabilities() {
|
|
874
|
+
return {
|
|
875
|
+
nativeToolCalling: true
|
|
876
|
+
};
|
|
877
|
+
}
|
|
862
878
|
async listModels() {
|
|
863
879
|
return [...OPENAI_MODELS];
|
|
864
880
|
}
|
|
865
881
|
async isAvailable() {
|
|
866
882
|
if (this.authMode === "chatgpt") {
|
|
867
|
-
return !!_optionalChain([this, 'access',
|
|
883
|
+
return !!_optionalChain([this, 'access', _27 => _27.chatgptAuth, 'optionalAccess', _28 => _28.accessToken]) && !!_optionalChain([this, 'access', _29 => _29.chatgptAuth, 'optionalAccess', _30 => _30.accountId]);
|
|
868
884
|
}
|
|
869
885
|
try {
|
|
870
886
|
const headers = await this.buildAuthHeaders();
|
|
@@ -885,9 +901,9 @@ var OpenAIProvider = class {
|
|
|
885
901
|
messages: request.messages.map((msg) => {
|
|
886
902
|
const mapped = {
|
|
887
903
|
role: msg.role === "system" ? "system" : msg.role === "user" ? "user" : msg.role === "tool" ? "tool" : "assistant",
|
|
888
|
-
content: msg.content
|
|
904
|
+
content: this.toChatCompletionContent(msg.content)
|
|
889
905
|
};
|
|
890
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
906
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _31 => _31.tool_calls, 'optionalAccess', _32 => _32.length])) {
|
|
891
907
|
mapped.tool_calls = msg.tool_calls;
|
|
892
908
|
}
|
|
893
909
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
@@ -933,7 +949,7 @@ var OpenAIProvider = class {
|
|
|
933
949
|
});
|
|
934
950
|
} catch (error) {
|
|
935
951
|
const err = error;
|
|
936
|
-
if (err.name === "AbortError" && _optionalChain([request, 'access',
|
|
952
|
+
if (err.name === "AbortError" && _optionalChain([request, 'access', _33 => _33.signal, 'optionalAccess', _34 => _34.aborted])) {
|
|
937
953
|
throw new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
938
954
|
}
|
|
939
955
|
if (err.name === "AbortError") {
|
|
@@ -968,14 +984,7 @@ var OpenAIProvider = class {
|
|
|
968
984
|
}
|
|
969
985
|
}));
|
|
970
986
|
}
|
|
971
|
-
|
|
972
|
-
if (data.usage) {
|
|
973
|
-
usage = {
|
|
974
|
-
promptTokens: data.usage.prompt_tokens,
|
|
975
|
-
completionTokens: data.usage.completion_tokens,
|
|
976
|
-
totalTokens: data.usage.total_tokens
|
|
977
|
-
};
|
|
978
|
-
}
|
|
987
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, data.usage);
|
|
979
988
|
return {
|
|
980
989
|
id: data.id,
|
|
981
990
|
created: data.created,
|
|
@@ -995,7 +1004,7 @@ var OpenAIProvider = class {
|
|
|
995
1004
|
stream: true,
|
|
996
1005
|
tool_choice: "auto",
|
|
997
1006
|
parallel_tool_calls: true,
|
|
998
|
-
input:
|
|
1007
|
+
input: this.toResponsesInputItems(request.messages)
|
|
999
1008
|
};
|
|
1000
1009
|
if (this.reasoningEffort && VALID_REASONING_EFFORTS.has(this.reasoningEffort)) {
|
|
1001
1010
|
body.reasoning = {
|
|
@@ -1035,7 +1044,7 @@ var OpenAIProvider = class {
|
|
|
1035
1044
|
});
|
|
1036
1045
|
} catch (error) {
|
|
1037
1046
|
const err = error;
|
|
1038
|
-
if (err.name === "AbortError" && _optionalChain([request, 'access',
|
|
1047
|
+
if (err.name === "AbortError" && _optionalChain([request, 'access', _35 => _35.signal, 'optionalAccess', _36 => _36.aborted])) {
|
|
1039
1048
|
throw new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
1040
1049
|
}
|
|
1041
1050
|
if (err.name === "AbortError") {
|
|
@@ -1059,17 +1068,13 @@ var OpenAIProvider = class {
|
|
|
1059
1068
|
const data = await this.parseCodexStream(response);
|
|
1060
1069
|
const toolCalls = this.extractResponsesToolCalls(data.output);
|
|
1061
1070
|
const content = this.extractResponsesContent(data);
|
|
1062
|
-
const usage = data.usage
|
|
1063
|
-
promptTokens: _nullishCoalesce(data.usage.input_tokens, () => ( 0)),
|
|
1064
|
-
completionTokens: _nullishCoalesce(data.usage.output_tokens, () => ( 0)),
|
|
1065
|
-
totalTokens: _nullishCoalesce(data.usage.total_tokens, () => ( (_nullishCoalesce(data.usage.input_tokens, () => ( 0))) + (_nullishCoalesce(data.usage.output_tokens, () => ( 0)))))
|
|
1066
|
-
} : void 0;
|
|
1071
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, data.usage);
|
|
1067
1072
|
return {
|
|
1068
1073
|
id: data.id,
|
|
1069
1074
|
created: _nullishCoalesce(data.created_at, () => ( Math.floor(Date.now() / 1e3))),
|
|
1070
1075
|
content,
|
|
1071
1076
|
toolCalls,
|
|
1072
|
-
finishReason: toolCalls.length > 0 ? "tool_calls" : _optionalChain([data, 'access',
|
|
1077
|
+
finishReason: toolCalls.length > 0 ? "tool_calls" : _optionalChain([data, 'access', _37 => _37.incomplete_details, 'optionalAccess', _38 => _38.reason]) === "max_output_tokens" ? "length" : "stop",
|
|
1073
1078
|
usage,
|
|
1074
1079
|
raw: data
|
|
1075
1080
|
};
|
|
@@ -1078,8 +1083,8 @@ var OpenAIProvider = class {
|
|
|
1078
1083
|
let errorDetail = "";
|
|
1079
1084
|
try {
|
|
1080
1085
|
const body = await response.json();
|
|
1081
|
-
const errObj = _optionalChain([body, 'optionalAccess',
|
|
1082
|
-
errorDetail = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([errObj, 'optionalAccess',
|
|
1086
|
+
const errObj = _optionalChain([body, 'optionalAccess', _39 => _39.error]);
|
|
1087
|
+
errorDetail = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([errObj, 'optionalAccess', _40 => _40.message]), () => ( _optionalChain([body, 'optionalAccess', _41 => _41.detail]))), () => ( _optionalChain([body, 'optionalAccess', _42 => _42.error]))), () => ( ""));
|
|
1083
1088
|
if (typeof errorDetail === "object") {
|
|
1084
1089
|
errorDetail = JSON.stringify(errorDetail);
|
|
1085
1090
|
}
|
|
@@ -1115,13 +1120,42 @@ ${error.rawDetail}` : friendlyMessage,
|
|
|
1115
1120
|
const text = await response.text();
|
|
1116
1121
|
let currentEvent = "";
|
|
1117
1122
|
let completedData = null;
|
|
1123
|
+
let streamedOutputText = "";
|
|
1124
|
+
const streamedOutputItems = /* @__PURE__ */ new Map();
|
|
1118
1125
|
for (const line of text.split("\n")) {
|
|
1119
1126
|
if (line.startsWith("event: ")) {
|
|
1120
1127
|
currentEvent = line.slice(7).trim();
|
|
1121
1128
|
continue;
|
|
1122
1129
|
}
|
|
1123
|
-
if (line.startsWith("data: ")
|
|
1124
|
-
|
|
1130
|
+
if (!line.startsWith("data: ")) {
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
const dataLine = line.slice(6);
|
|
1134
|
+
const eventData = JSON.parse(dataLine);
|
|
1135
|
+
const eventType = this.getCodexStreamEventType(currentEvent, eventData);
|
|
1136
|
+
const eventRecord = eventData && typeof eventData === "object" ? eventData : {};
|
|
1137
|
+
if (eventType === "response.output_text.delta") {
|
|
1138
|
+
if (typeof eventRecord.delta === "string") {
|
|
1139
|
+
streamedOutputText += eventRecord.delta;
|
|
1140
|
+
}
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
if (eventType === "response.output_text.done") {
|
|
1144
|
+
if (typeof eventRecord.text === "string" && eventRecord.text.trim()) {
|
|
1145
|
+
streamedOutputText = eventRecord.text;
|
|
1146
|
+
}
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
if (eventType === "response.output_item.added" || eventType === "response.output_item.done") {
|
|
1150
|
+
this.captureStreamedOutputItem(eventData, streamedOutputItems);
|
|
1151
|
+
continue;
|
|
1152
|
+
}
|
|
1153
|
+
if (eventType === "response.function_call_arguments.done") {
|
|
1154
|
+
this.captureStreamedFunctionCallArguments(eventData, streamedOutputItems);
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
if (eventType === "response.completed") {
|
|
1158
|
+
completedData = this.extractCompletedResponse(eventData);
|
|
1125
1159
|
break;
|
|
1126
1160
|
}
|
|
1127
1161
|
}
|
|
@@ -1133,11 +1167,77 @@ ${error.rawDetail}` : friendlyMessage,
|
|
|
1133
1167
|
false
|
|
1134
1168
|
);
|
|
1135
1169
|
}
|
|
1170
|
+
if ((!Array.isArray(completedData.output) || completedData.output.length === 0) && streamedOutputItems.size > 0) {
|
|
1171
|
+
completedData.output = [...streamedOutputItems.entries()].sort(([a], [b]) => a - b).map(([, item]) => item);
|
|
1172
|
+
}
|
|
1173
|
+
if (!this.extractResponsesContent(completedData) && streamedOutputText.trim()) {
|
|
1174
|
+
completedData.output_text = streamedOutputText;
|
|
1175
|
+
}
|
|
1136
1176
|
return completedData;
|
|
1137
1177
|
}
|
|
1178
|
+
getCodexStreamEventType(currentEvent, eventData) {
|
|
1179
|
+
if (currentEvent) {
|
|
1180
|
+
return currentEvent;
|
|
1181
|
+
}
|
|
1182
|
+
if (eventData && typeof eventData === "object" && "type" in eventData) {
|
|
1183
|
+
const type = eventData.type;
|
|
1184
|
+
return typeof type === "string" ? type : "";
|
|
1185
|
+
}
|
|
1186
|
+
return "";
|
|
1187
|
+
}
|
|
1188
|
+
captureStreamedOutputItem(eventData, outputItems) {
|
|
1189
|
+
if (!eventData || typeof eventData !== "object") {
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
const event = eventData;
|
|
1193
|
+
if (!event.item || typeof event.output_index !== "number") {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
const existing = outputItems.get(event.output_index);
|
|
1197
|
+
if (_optionalChain([existing, 'optionalAccess', _43 => _43.type]) === "function_call" && event.item.type === "function_call") {
|
|
1198
|
+
outputItems.set(event.output_index, {
|
|
1199
|
+
...existing,
|
|
1200
|
+
...event.item,
|
|
1201
|
+
arguments: event.item.arguments || existing.arguments
|
|
1202
|
+
});
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
outputItems.set(event.output_index, event.item);
|
|
1206
|
+
}
|
|
1207
|
+
captureStreamedFunctionCallArguments(eventData, outputItems) {
|
|
1208
|
+
if (!eventData || typeof eventData !== "object") {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
const event = eventData;
|
|
1212
|
+
if (typeof event.output_index !== "number" || typeof event.name !== "string" || typeof event.arguments !== "string") {
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const existing = outputItems.get(event.output_index);
|
|
1216
|
+
if (_optionalChain([existing, 'optionalAccess', _44 => _44.type]) === "function_call") {
|
|
1217
|
+
outputItems.set(event.output_index, {
|
|
1218
|
+
...existing,
|
|
1219
|
+
name: event.name,
|
|
1220
|
+
arguments: event.arguments
|
|
1221
|
+
});
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
outputItems.set(event.output_index, {
|
|
1225
|
+
type: "function_call",
|
|
1226
|
+
id: event.item_id,
|
|
1227
|
+
call_id: event.item_id,
|
|
1228
|
+
name: event.name,
|
|
1229
|
+
arguments: event.arguments
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
extractCompletedResponse(eventData) {
|
|
1233
|
+
if (eventData && typeof eventData === "object" && "response" in eventData && eventData.response) {
|
|
1234
|
+
return eventData.response;
|
|
1235
|
+
}
|
|
1236
|
+
return eventData;
|
|
1237
|
+
}
|
|
1138
1238
|
async buildAuthHeaders() {
|
|
1139
1239
|
if (this.authMode === "chatgpt") {
|
|
1140
|
-
if (!_optionalChain([this, 'access',
|
|
1240
|
+
if (!_optionalChain([this, 'access', _45 => _45.chatgptAuth, 'optionalAccess', _46 => _46.accessToken]) || !this.chatgptAuth.accountId) {
|
|
1141
1241
|
throw new (0, _chunk3OF56EMAcjs.ApiError)("ChatGPT authentication is missing. Please sign in again.", "auth_failed", 401, false);
|
|
1142
1242
|
}
|
|
1143
1243
|
if (isChatGPTAuthExpired(this.chatgptAuth)) {
|
|
@@ -1161,12 +1261,73 @@ ${error.rawDetail}` : friendlyMessage,
|
|
|
1161
1261
|
}
|
|
1162
1262
|
return (configBaseUrl || OPENAI_API_BASE_URL).replace(/\/$/, "");
|
|
1163
1263
|
}
|
|
1164
|
-
|
|
1264
|
+
isContentPartsArray(content) {
|
|
1265
|
+
return Array.isArray(content);
|
|
1266
|
+
}
|
|
1267
|
+
toChatCompletionContent(content) {
|
|
1268
|
+
if (!this.isContentPartsArray(content)) {
|
|
1269
|
+
return content;
|
|
1270
|
+
}
|
|
1271
|
+
return content.map((part) => {
|
|
1272
|
+
if (part.type === "text") {
|
|
1273
|
+
return { type: "text", text: part.text };
|
|
1274
|
+
}
|
|
1275
|
+
if (part.type === "image_url") {
|
|
1276
|
+
return {
|
|
1277
|
+
type: "image_url",
|
|
1278
|
+
image_url: part.image_url
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
return null;
|
|
1282
|
+
}).filter((part) => part !== null);
|
|
1283
|
+
}
|
|
1284
|
+
toResponsesMessageContent(role, content) {
|
|
1285
|
+
const textType = role === "assistant" ? "output_text" : "input_text";
|
|
1286
|
+
if (!this.isContentPartsArray(content)) {
|
|
1287
|
+
return [{ type: textType, text: content }];
|
|
1288
|
+
}
|
|
1289
|
+
const parts = [];
|
|
1290
|
+
for (const part of content) {
|
|
1291
|
+
if (part.type === "text") {
|
|
1292
|
+
parts.push({ type: textType, text: part.text });
|
|
1293
|
+
continue;
|
|
1294
|
+
}
|
|
1295
|
+
if (part.type === "image_url" && role !== "assistant") {
|
|
1296
|
+
parts.push({
|
|
1297
|
+
type: "input_image",
|
|
1298
|
+
image_url: part.image_url.url
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
return parts;
|
|
1303
|
+
}
|
|
1304
|
+
toResponsesInputItems(messages) {
|
|
1305
|
+
const assistantToolCallIds = /* @__PURE__ */ new Set();
|
|
1306
|
+
const toolOutputIds = /* @__PURE__ */ new Set();
|
|
1307
|
+
for (const msg of messages) {
|
|
1308
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _47 => _47.tool_calls, 'optionalAccess', _48 => _48.length])) {
|
|
1309
|
+
for (const toolCall of msg.tool_calls) {
|
|
1310
|
+
assistantToolCallIds.add(toolCall.id);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (msg.role === "tool" && msg.tool_call_id) {
|
|
1314
|
+
toolOutputIds.add(msg.tool_call_id);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
const matchedToolCallIds = new Set(
|
|
1318
|
+
[...assistantToolCallIds].filter((id) => toolOutputIds.has(id))
|
|
1319
|
+
);
|
|
1320
|
+
return messages.flatMap((msg) => this.toResponsesInputItemsForMessage(msg, matchedToolCallIds));
|
|
1321
|
+
}
|
|
1322
|
+
toResponsesInputItemsForMessage(msg, matchedToolCallIds) {
|
|
1165
1323
|
const items = [];
|
|
1166
1324
|
if (msg.role === "system") {
|
|
1167
1325
|
return items;
|
|
1168
1326
|
}
|
|
1169
1327
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
1328
|
+
if (!matchedToolCallIds.has(msg.tool_call_id)) {
|
|
1329
|
+
return items;
|
|
1330
|
+
}
|
|
1170
1331
|
items.push({
|
|
1171
1332
|
type: "function_call_output",
|
|
1172
1333
|
call_id: msg.tool_call_id,
|
|
@@ -1175,14 +1336,18 @@ ${error.rawDetail}` : friendlyMessage,
|
|
|
1175
1336
|
return items;
|
|
1176
1337
|
}
|
|
1177
1338
|
if (msg.content) {
|
|
1339
|
+
const content = this.toResponsesMessageContent(msg.role, msg.content);
|
|
1178
1340
|
items.push({
|
|
1179
1341
|
type: "message",
|
|
1180
1342
|
role: msg.role === "tool" ? "user" : msg.role,
|
|
1181
|
-
content
|
|
1343
|
+
content
|
|
1182
1344
|
});
|
|
1183
1345
|
}
|
|
1184
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
1346
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _49 => _49.tool_calls, 'optionalAccess', _50 => _50.length])) {
|
|
1185
1347
|
for (const toolCall of msg.tool_calls) {
|
|
1348
|
+
if (!matchedToolCallIds.has(toolCall.id)) {
|
|
1349
|
+
continue;
|
|
1350
|
+
}
|
|
1186
1351
|
items.push({
|
|
1187
1352
|
type: "function_call",
|
|
1188
1353
|
call_id: toolCall.id,
|
|
@@ -1204,7 +1369,7 @@ ${error.rawDetail}` : friendlyMessage,
|
|
|
1204
1369
|
if (!Array.isArray(output)) {
|
|
1205
1370
|
return [];
|
|
1206
1371
|
}
|
|
1207
|
-
return output.filter((entry) => _optionalChain([entry, 'optionalAccess',
|
|
1372
|
+
return output.filter((entry) => _optionalChain([entry, 'optionalAccess', _51 => _51.type]) === "function_call").map((toolCall, index) => ({
|
|
1208
1373
|
id: _nullishCoalesce(toolCall.call_id, () => ( `call_${index + 1}`)),
|
|
1209
1374
|
type: "function",
|
|
1210
1375
|
function: {
|
|
@@ -1230,11 +1395,11 @@ ${error.rawDetail}` : friendlyMessage,
|
|
|
1230
1395
|
}
|
|
1231
1396
|
const parts = [];
|
|
1232
1397
|
for (const item of data.output) {
|
|
1233
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
1398
|
+
if (_optionalChain([item, 'optionalAccess', _52 => _52.type]) !== "message" || !Array.isArray(item.content)) {
|
|
1234
1399
|
continue;
|
|
1235
1400
|
}
|
|
1236
1401
|
for (const contentItem of item.content) {
|
|
1237
|
-
if (_optionalChain([contentItem, 'optionalAccess',
|
|
1402
|
+
if (_optionalChain([contentItem, 'optionalAccess', _53 => _53.type]) === "output_text" && typeof contentItem.text === "string") {
|
|
1238
1403
|
parts.push(contentItem.text);
|
|
1239
1404
|
}
|
|
1240
1405
|
}
|
|
@@ -1256,6 +1421,9 @@ var LlamaCppProvider = (_class2 = class _LlamaCppProvider {
|
|
|
1256
1421
|
getName() {
|
|
1257
1422
|
return "llamacpp";
|
|
1258
1423
|
}
|
|
1424
|
+
getCapabilities() {
|
|
1425
|
+
return { nativeToolCalling: true };
|
|
1426
|
+
}
|
|
1259
1427
|
setModel(model) {
|
|
1260
1428
|
this.model = model;
|
|
1261
1429
|
}
|
|
@@ -1266,7 +1434,7 @@ var LlamaCppProvider = (_class2 = class _LlamaCppProvider {
|
|
|
1266
1434
|
return this.model ? [this.model] : [];
|
|
1267
1435
|
}
|
|
1268
1436
|
const data = await response.json();
|
|
1269
|
-
return _nullishCoalesce(_optionalChain([data, 'access',
|
|
1437
|
+
return _nullishCoalesce(_optionalChain([data, 'access', _54 => _54.data, 'optionalAccess', _55 => _55.map, 'call', _56 => _56((m) => m.id)]), () => ( [this.model]));
|
|
1270
1438
|
} catch (e13) {
|
|
1271
1439
|
return this.model ? [this.model] : [];
|
|
1272
1440
|
}
|
|
@@ -1320,7 +1488,7 @@ var LlamaCppProvider = (_class2 = class _LlamaCppProvider {
|
|
|
1320
1488
|
const data = await response.json();
|
|
1321
1489
|
const choice = data.choices[0];
|
|
1322
1490
|
let toolCalls;
|
|
1323
|
-
if (_optionalChain([choice, 'optionalAccess',
|
|
1491
|
+
if (_optionalChain([choice, 'optionalAccess', _57 => _57.message, 'access', _58 => _58.tool_calls, 'optionalAccess', _59 => _59.length])) {
|
|
1324
1492
|
toolCalls = choice.message.tool_calls.map((tc) => ({
|
|
1325
1493
|
id: tc.id,
|
|
1326
1494
|
type: "function",
|
|
@@ -1338,11 +1506,11 @@ var LlamaCppProvider = (_class2 = class _LlamaCppProvider {
|
|
|
1338
1506
|
totalTokens: data.usage.total_tokens
|
|
1339
1507
|
};
|
|
1340
1508
|
}
|
|
1341
|
-
const finishReason = _optionalChain([toolCalls, 'optionalAccess',
|
|
1509
|
+
const finishReason = _optionalChain([toolCalls, 'optionalAccess', _60 => _60.length]) ? "tool_calls" : _optionalChain([choice, 'optionalAccess', _61 => _61.finish_reason]) === "stop" || _optionalChain([choice, 'optionalAccess', _62 => _62.finish_reason]) === "length" || _optionalChain([choice, 'optionalAccess', _63 => _63.finish_reason]) === "content_filter" ? choice.finish_reason : "stop";
|
|
1342
1510
|
return {
|
|
1343
1511
|
id: data.id || `llamacpp-${Date.now()}`,
|
|
1344
1512
|
created: data.created || Math.floor(Date.now() / 1e3),
|
|
1345
|
-
content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess',
|
|
1513
|
+
content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess', _64 => _64.message, 'access', _65 => _65.content]), () => ( "")),
|
|
1346
1514
|
toolCalls,
|
|
1347
1515
|
finishReason,
|
|
1348
1516
|
usage,
|
|
@@ -1427,13 +1595,13 @@ function getInputModalities(capability) {
|
|
|
1427
1595
|
if (Array.isArray(capability.input_modalities)) {
|
|
1428
1596
|
return capability.input_modalities;
|
|
1429
1597
|
}
|
|
1430
|
-
if (Array.isArray(_optionalChain([capability, 'access',
|
|
1598
|
+
if (Array.isArray(_optionalChain([capability, 'access', _66 => _66.architecture, 'optionalAccess', _67 => _67.input_modalities]))) {
|
|
1431
1599
|
return capability.architecture.input_modalities;
|
|
1432
1600
|
}
|
|
1433
1601
|
return [];
|
|
1434
1602
|
}
|
|
1435
1603
|
function getOpenRouterCapabilityContextWindow(capability) {
|
|
1436
|
-
const contextWindow = _nullishCoalesce(_optionalChain([capability, 'optionalAccess',
|
|
1604
|
+
const contextWindow = _nullishCoalesce(_optionalChain([capability, 'optionalAccess', _68 => _68.top_provider, 'optionalAccess', _69 => _69.context_length]), () => ( _optionalChain([capability, 'optionalAccess', _70 => _70.context_length])));
|
|
1437
1605
|
return typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0 ? Math.floor(contextWindow) : void 0;
|
|
1438
1606
|
}
|
|
1439
1607
|
async function getOpenRouterModelContextWindow(model) {
|
|
@@ -1469,7 +1637,7 @@ async function fetchOpenRouterModelCapabilities(forceRefresh = false) {
|
|
|
1469
1637
|
throw new Error(`Failed to fetch model capabilities: ${response.status} ${response.statusText}`);
|
|
1470
1638
|
}
|
|
1471
1639
|
const data = await response.json();
|
|
1472
|
-
const models = Array.isArray(_optionalChain([data, 'optionalAccess',
|
|
1640
|
+
const models = Array.isArray(_optionalChain([data, 'optionalAccess', _71 => _71.data])) ? data.data : [];
|
|
1473
1641
|
cache = {
|
|
1474
1642
|
models,
|
|
1475
1643
|
fetchedAt: Date.now()
|
|
@@ -1565,7 +1733,7 @@ function sanitizeMessages(messages, allowImageInputs) {
|
|
|
1565
1733
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
1566
1734
|
sanitized.tool_call_id = msg.tool_call_id;
|
|
1567
1735
|
}
|
|
1568
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
1736
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _72 => _72.tool_calls, 'optionalAccess', _73 => _73.length])) {
|
|
1569
1737
|
sanitized.tool_calls = msg.tool_calls;
|
|
1570
1738
|
}
|
|
1571
1739
|
if (msg.name) {
|
|
@@ -1613,13 +1781,13 @@ var OpenRouterClient = class {
|
|
|
1613
1781
|
this.apiKey = _nullishCoalesce(settings.apiKey, () => ( ""));
|
|
1614
1782
|
this.baseUrl = _nullishCoalesce(settings.baseUrl, () => ( DEFAULT_BASE_URL));
|
|
1615
1783
|
this.defaultModel = settings.model;
|
|
1616
|
-
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
1784
|
+
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _74 => _74.maxRetries]), () => ( DEFAULT_MAX_RETRIES2));
|
|
1617
1785
|
this.maxRetries = Math.min(
|
|
1618
1786
|
Math.max(0, configuredRetries),
|
|
1619
1787
|
MAX_ALLOWED_RETRIES2
|
|
1620
1788
|
);
|
|
1621
|
-
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
1622
|
-
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
1789
|
+
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _75 => _75.retryDelay]), () => ( DEFAULT_RETRY_DELAY2));
|
|
1790
|
+
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _76 => _76.timeout]), () => ( DEFAULT_TIMEOUT2));
|
|
1623
1791
|
}
|
|
1624
1792
|
setDefaultModel(model) {
|
|
1625
1793
|
this.defaultModel = model;
|
|
@@ -1737,7 +1905,7 @@ var OpenRouterClient = class {
|
|
|
1737
1905
|
}
|
|
1738
1906
|
} catch (error) {
|
|
1739
1907
|
const err = error;
|
|
1740
|
-
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess',
|
|
1908
|
+
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess', _77 => _77.aborted])) {
|
|
1741
1909
|
throw new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
1742
1910
|
}
|
|
1743
1911
|
if (err.name === "AbortError") {
|
|
@@ -1759,31 +1927,24 @@ var OpenRouterClient = class {
|
|
|
1759
1927
|
throw await this.buildApiError(response);
|
|
1760
1928
|
}
|
|
1761
1929
|
const json = await response.json();
|
|
1762
|
-
const message = _optionalChain([json, 'optionalAccess',
|
|
1763
|
-
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess',
|
|
1764
|
-
const finishReason = _optionalChain([json, 'optionalAccess',
|
|
1930
|
+
const message = _optionalChain([json, 'optionalAccess', _78 => _78.choices, 'optionalAccess', _79 => _79[0], 'optionalAccess', _80 => _80.message]);
|
|
1931
|
+
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _81 => _81.content]), () => ( ""));
|
|
1932
|
+
const finishReason = _optionalChain([json, 'optionalAccess', _82 => _82.choices, 'optionalAccess', _83 => _83[0], 'optionalAccess', _84 => _84.finish_reason]);
|
|
1765
1933
|
let toolCalls;
|
|
1766
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
1934
|
+
if (_optionalChain([message, 'optionalAccess', _85 => _85.tool_calls]) && Array.isArray(message.tool_calls)) {
|
|
1767
1935
|
toolCalls = message.tool_calls.map((tc) => {
|
|
1768
|
-
const rawArgs = _optionalChain([tc, 'access',
|
|
1936
|
+
const rawArgs = _optionalChain([tc, 'access', _86 => _86.function, 'optionalAccess', _87 => _87.arguments]);
|
|
1769
1937
|
return {
|
|
1770
1938
|
id: tc.id,
|
|
1771
1939
|
type: "function",
|
|
1772
1940
|
function: {
|
|
1773
|
-
name: _nullishCoalesce(_optionalChain([tc, 'access',
|
|
1941
|
+
name: _nullishCoalesce(_optionalChain([tc, 'access', _88 => _88.function, 'optionalAccess', _89 => _89.name]), () => ( "")),
|
|
1774
1942
|
arguments: _nullishCoalesce(rawArgs, () => ( "{}"))
|
|
1775
1943
|
}
|
|
1776
1944
|
};
|
|
1777
1945
|
});
|
|
1778
1946
|
}
|
|
1779
|
-
|
|
1780
|
-
if (_optionalChain([json, 'optionalAccess', _84 => _84.usage])) {
|
|
1781
|
-
usage = {
|
|
1782
|
-
promptTokens: _nullishCoalesce(json.usage.prompt_tokens, () => ( 0)),
|
|
1783
|
-
completionTokens: _nullishCoalesce(json.usage.completion_tokens, () => ( 0)),
|
|
1784
|
-
totalTokens: _nullishCoalesce(json.usage.total_tokens, () => ( 0))
|
|
1785
|
-
};
|
|
1786
|
-
}
|
|
1947
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, _optionalChain([json, 'optionalAccess', _90 => _90.usage]));
|
|
1787
1948
|
return {
|
|
1788
1949
|
id: _nullishCoalesce(json.id, () => ( "autohand-local")),
|
|
1789
1950
|
created: _nullishCoalesce(json.created, () => ( Date.now())),
|
|
@@ -1799,7 +1960,7 @@ var OpenRouterClient = class {
|
|
|
1799
1960
|
let errorDetail = "";
|
|
1800
1961
|
try {
|
|
1801
1962
|
const body = await response.json();
|
|
1802
|
-
errorDetail = _optionalChain([body, 'optionalAccess',
|
|
1963
|
+
errorDetail = _optionalChain([body, 'optionalAccess', _91 => _91.error, 'optionalAccess', _92 => _92.message]) || _optionalChain([body, 'optionalAccess', _93 => _93.error]) || _optionalChain([body, 'optionalAccess', _94 => _94.message]) || "";
|
|
1803
1964
|
if (typeof errorDetail === "object") {
|
|
1804
1965
|
errorDetail = JSON.stringify(errorDetail);
|
|
1805
1966
|
}
|
|
@@ -1844,6 +2005,9 @@ var OpenRouterProvider = class {
|
|
|
1844
2005
|
getName() {
|
|
1845
2006
|
return "openrouter";
|
|
1846
2007
|
}
|
|
2008
|
+
getCapabilities() {
|
|
2009
|
+
return { nativeToolCalling: true };
|
|
2010
|
+
}
|
|
1847
2011
|
setModel(model) {
|
|
1848
2012
|
this.model = model;
|
|
1849
2013
|
this.client.setDefaultModel(model);
|
|
@@ -1898,14 +2062,17 @@ var MLXProvider = class {
|
|
|
1898
2062
|
const port = config.port || 8080;
|
|
1899
2063
|
this.baseUrl = config.baseUrl || `http://localhost:${port}`;
|
|
1900
2064
|
this.model = config.model || "mlx-model";
|
|
1901
|
-
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2065
|
+
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _95 => _95.maxRetries]), () => ( DEFAULT_MAX_RETRIES3));
|
|
1902
2066
|
this.maxRetries = Math.min(Math.max(0, configuredRetries), MAX_ALLOWED_RETRIES3);
|
|
1903
|
-
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
1904
|
-
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2067
|
+
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _96 => _96.retryDelay]), () => ( DEFAULT_RETRY_DELAY3));
|
|
2068
|
+
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _97 => _97.timeout]), () => ( DEFAULT_TIMEOUT3));
|
|
1905
2069
|
}
|
|
1906
2070
|
getName() {
|
|
1907
2071
|
return "mlx";
|
|
1908
2072
|
}
|
|
2073
|
+
getCapabilities() {
|
|
2074
|
+
return { nativeToolCalling: true };
|
|
2075
|
+
}
|
|
1909
2076
|
setModel(model) {
|
|
1910
2077
|
this.model = model;
|
|
1911
2078
|
}
|
|
@@ -1924,7 +2091,7 @@ var MLXProvider = class {
|
|
|
1924
2091
|
return this.model ? [this.model] : [];
|
|
1925
2092
|
}
|
|
1926
2093
|
const data = await response.json();
|
|
1927
|
-
return _nullishCoalesce(_optionalChain([data, 'access',
|
|
2094
|
+
return _nullishCoalesce(_optionalChain([data, 'access', _98 => _98.data, 'optionalAccess', _99 => _99.map, 'call', _100 => _100((m) => m.id)]), () => ( (this.model ? [this.model] : [])));
|
|
1928
2095
|
} finally {
|
|
1929
2096
|
clearTimeout(timerId);
|
|
1930
2097
|
}
|
|
@@ -2023,7 +2190,7 @@ var MLXProvider = class {
|
|
|
2023
2190
|
}
|
|
2024
2191
|
} catch (error) {
|
|
2025
2192
|
const err = error;
|
|
2026
|
-
if (err.name === "AbortError" && _optionalChain([userSignal, 'optionalAccess',
|
|
2193
|
+
if (err.name === "AbortError" && _optionalChain([userSignal, 'optionalAccess', _101 => _101.aborted])) {
|
|
2027
2194
|
throw new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
2028
2195
|
}
|
|
2029
2196
|
if (err.name === "AbortError") {
|
|
@@ -2062,7 +2229,7 @@ var MLXProvider = class {
|
|
|
2062
2229
|
}
|
|
2063
2230
|
const choice = data.choices[0];
|
|
2064
2231
|
let toolCalls;
|
|
2065
|
-
if (_optionalChain([choice, 'optionalAccess',
|
|
2232
|
+
if (_optionalChain([choice, 'optionalAccess', _102 => _102.message, 'access', _103 => _103.tool_calls, 'optionalAccess', _104 => _104.length])) {
|
|
2066
2233
|
toolCalls = choice.message.tool_calls.map((tc) => ({
|
|
2067
2234
|
id: tc.id,
|
|
2068
2235
|
type: "function",
|
|
@@ -2080,11 +2247,11 @@ var MLXProvider = class {
|
|
|
2080
2247
|
totalTokens: data.usage.total_tokens
|
|
2081
2248
|
};
|
|
2082
2249
|
}
|
|
2083
|
-
const finishReason = _optionalChain([toolCalls, 'optionalAccess',
|
|
2250
|
+
const finishReason = _optionalChain([toolCalls, 'optionalAccess', _105 => _105.length]) ? "tool_calls" : _optionalChain([choice, 'optionalAccess', _106 => _106.finish_reason]) === "stop" || _optionalChain([choice, 'optionalAccess', _107 => _107.finish_reason]) === "length" || _optionalChain([choice, 'optionalAccess', _108 => _108.finish_reason]) === "content_filter" ? choice.finish_reason : "stop";
|
|
2084
2251
|
return {
|
|
2085
2252
|
id: data.id || `mlx-${Date.now()}`,
|
|
2086
2253
|
created: data.created || Math.floor(Date.now() / 1e3),
|
|
2087
|
-
content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess',
|
|
2254
|
+
content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess', _109 => _109.message, 'access', _110 => _110.content]), () => ( "")),
|
|
2088
2255
|
toolCalls,
|
|
2089
2256
|
finishReason,
|
|
2090
2257
|
usage,
|
|
@@ -2095,12 +2262,12 @@ var MLXProvider = class {
|
|
|
2095
2262
|
let errorDetail = "";
|
|
2096
2263
|
try {
|
|
2097
2264
|
const body = await response.json();
|
|
2098
|
-
const maybeError = _optionalChain([body, 'optionalAccess',
|
|
2265
|
+
const maybeError = _optionalChain([body, 'optionalAccess', _111 => _111.error]);
|
|
2099
2266
|
if (maybeError && typeof maybeError === "object") {
|
|
2100
|
-
errorDetail = _nullishCoalesce(_optionalChain([maybeError, 'optionalAccess',
|
|
2267
|
+
errorDetail = _nullishCoalesce(_optionalChain([maybeError, 'optionalAccess', _112 => _112.message]), () => ( ""));
|
|
2101
2268
|
} else if (typeof maybeError === "string") {
|
|
2102
2269
|
errorDetail = maybeError;
|
|
2103
|
-
} else if (typeof _optionalChain([body, 'optionalAccess',
|
|
2270
|
+
} else if (typeof _optionalChain([body, 'optionalAccess', _113 => _113.message]) === "string") {
|
|
2104
2271
|
errorDetail = body.message;
|
|
2105
2272
|
}
|
|
2106
2273
|
if (typeof errorDetail === "object") {
|
|
@@ -2138,7 +2305,24 @@ var MLXProvider = class {
|
|
|
2138
2305
|
|
|
2139
2306
|
// src/providers/LLMGatewayClient.ts
|
|
2140
2307
|
function sanitizeMessages2(messages) {
|
|
2141
|
-
|
|
2308
|
+
const toolOutputIds = new Set(
|
|
2309
|
+
messages.filter((msg) => msg.role === "tool" && msg.tool_call_id).map((msg) => msg.tool_call_id)
|
|
2310
|
+
);
|
|
2311
|
+
const matchedToolCallIds = /* @__PURE__ */ new Set();
|
|
2312
|
+
for (const msg of messages) {
|
|
2313
|
+
if (msg.role !== "assistant" || !_optionalChain([msg, 'access', _114 => _114.tool_calls, 'optionalAccess', _115 => _115.length])) {
|
|
2314
|
+
continue;
|
|
2315
|
+
}
|
|
2316
|
+
for (const toolCall of msg.tool_calls) {
|
|
2317
|
+
if (toolOutputIds.has(toolCall.id)) {
|
|
2318
|
+
matchedToolCallIds.add(toolCall.id);
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
return messages.flatMap((msg) => {
|
|
2323
|
+
if (msg.role === "tool" && (!msg.tool_call_id || !matchedToolCallIds.has(msg.tool_call_id))) {
|
|
2324
|
+
return [];
|
|
2325
|
+
}
|
|
2142
2326
|
const sanitized = {
|
|
2143
2327
|
role: msg.role,
|
|
2144
2328
|
content: msg.content
|
|
@@ -2146,13 +2330,18 @@ function sanitizeMessages2(messages) {
|
|
|
2146
2330
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
2147
2331
|
sanitized.tool_call_id = msg.tool_call_id;
|
|
2148
2332
|
}
|
|
2149
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
2150
|
-
|
|
2333
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _116 => _116.tool_calls, 'optionalAccess', _117 => _117.length])) {
|
|
2334
|
+
const matchedToolCalls = msg.tool_calls.filter((toolCall) => matchedToolCallIds.has(toolCall.id));
|
|
2335
|
+
if (matchedToolCalls.length > 0) {
|
|
2336
|
+
sanitized.tool_calls = matchedToolCalls;
|
|
2337
|
+
} else if (!msg.content) {
|
|
2338
|
+
return [];
|
|
2339
|
+
}
|
|
2151
2340
|
}
|
|
2152
2341
|
if (msg.name) {
|
|
2153
2342
|
sanitized.name = msg.name;
|
|
2154
2343
|
}
|
|
2155
|
-
return sanitized;
|
|
2344
|
+
return [sanitized];
|
|
2156
2345
|
});
|
|
2157
2346
|
}
|
|
2158
2347
|
var DEFAULT_BASE_URL2 = "https://api.llmgateway.io/v1";
|
|
@@ -2167,18 +2356,26 @@ var DEFAULT_ERROR_LABELS = {
|
|
|
2167
2356
|
};
|
|
2168
2357
|
function buildFriendlyErrors(labels) {
|
|
2169
2358
|
return {
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
504: `The request timed out. The ${labels.serviceName} service may be experiencing high load.`
|
|
2359
|
+
invalid_request: "The request was malformed and could not be processed.",
|
|
2360
|
+
context_overflow: "The conversation is too long for this model. Try /undo to remove recent turns or /new to start fresh.",
|
|
2361
|
+
model_not_found: "The requested model was not found. Use /model to select a different one.",
|
|
2362
|
+
auth_failed: `Authentication failed. Please verify your ${labels.credentialName} in ~/.autohand/config.json.`,
|
|
2363
|
+
payment_required: `Payment required. Please check your ${labels.accountName} balance or billing settings.`,
|
|
2364
|
+
access_denied: `Access denied. Your ${labels.credentialName} may not have permission for this model.`,
|
|
2365
|
+
rate_limited: "Rate limit exceeded. Please wait a moment and try again, or choose a different model.",
|
|
2366
|
+
server_error: `The ${labels.serviceName} service is temporarily unavailable. Please try again later.`,
|
|
2367
|
+
timeout: `The request timed out. The ${labels.serviceName} service may be experiencing high load.`
|
|
2180
2368
|
};
|
|
2181
2369
|
}
|
|
2370
|
+
function coerceErrorDetail(value) {
|
|
2371
|
+
if (typeof value === "string") {
|
|
2372
|
+
return value;
|
|
2373
|
+
}
|
|
2374
|
+
if (value && typeof value === "object") {
|
|
2375
|
+
return JSON.stringify(value);
|
|
2376
|
+
}
|
|
2377
|
+
return "";
|
|
2378
|
+
}
|
|
2182
2379
|
var LLMGatewayClient = class {
|
|
2183
2380
|
|
|
2184
2381
|
|
|
@@ -2187,18 +2384,20 @@ var LLMGatewayClient = class {
|
|
|
2187
2384
|
|
|
2188
2385
|
|
|
2189
2386
|
|
|
2387
|
+
|
|
2190
2388
|
constructor(settings, networkSettings, errorLabels = DEFAULT_ERROR_LABELS) {
|
|
2191
2389
|
this.apiKey = _nullishCoalesce(settings.apiKey, () => ( ""));
|
|
2192
2390
|
this.baseUrl = _nullishCoalesce(settings.baseUrl, () => ( DEFAULT_BASE_URL2));
|
|
2193
2391
|
this.defaultModel = settings.model;
|
|
2392
|
+
this.reasoningEffort = settings.reasoningEffort;
|
|
2194
2393
|
this.errorLabels = errorLabels;
|
|
2195
|
-
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2394
|
+
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _118 => _118.maxRetries]), () => ( DEFAULT_MAX_RETRIES4));
|
|
2196
2395
|
this.maxRetries = Math.min(
|
|
2197
2396
|
Math.max(0, configuredRetries),
|
|
2198
2397
|
MAX_ALLOWED_RETRIES4
|
|
2199
2398
|
);
|
|
2200
|
-
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2201
|
-
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2399
|
+
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _119 => _119.retryDelay]), () => ( DEFAULT_RETRY_DELAY4));
|
|
2400
|
+
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _120 => _120.timeout]), () => ( DEFAULT_TIMEOUT4));
|
|
2202
2401
|
}
|
|
2203
2402
|
setDefaultModel(model) {
|
|
2204
2403
|
this.defaultModel = model;
|
|
@@ -2271,6 +2470,9 @@ var LLMGatewayClient = class {
|
|
|
2271
2470
|
max_tokens: _nullishCoalesce(request.maxTokens, () => ( 16e3)),
|
|
2272
2471
|
stream: _nullishCoalesce(request.stream, () => ( false))
|
|
2273
2472
|
};
|
|
2473
|
+
if (this.reasoningEffort) {
|
|
2474
|
+
payload.reasoning_effort = this.reasoningEffort;
|
|
2475
|
+
}
|
|
2274
2476
|
return payload;
|
|
2275
2477
|
}
|
|
2276
2478
|
buildChatTemplateKwargs(kwargs) {
|
|
@@ -2302,7 +2504,7 @@ var LLMGatewayClient = class {
|
|
|
2302
2504
|
}
|
|
2303
2505
|
} catch (error) {
|
|
2304
2506
|
const err = error;
|
|
2305
|
-
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess',
|
|
2507
|
+
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess', _121 => _121.aborted])) {
|
|
2306
2508
|
throw new Error("Request cancelled.");
|
|
2307
2509
|
}
|
|
2308
2510
|
if (err.name === "AbortError") {
|
|
@@ -2321,31 +2523,24 @@ var LLMGatewayClient = class {
|
|
|
2321
2523
|
return this.handleStreamingResponse(response);
|
|
2322
2524
|
}
|
|
2323
2525
|
const json = await response.json();
|
|
2324
|
-
const message = _optionalChain([json, 'optionalAccess',
|
|
2325
|
-
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess',
|
|
2326
|
-
const finishReason = _optionalChain([json, 'optionalAccess',
|
|
2526
|
+
const message = _optionalChain([json, 'optionalAccess', _122 => _122.choices, 'optionalAccess', _123 => _123[0], 'optionalAccess', _124 => _124.message]);
|
|
2527
|
+
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _125 => _125.content]), () => ( ""));
|
|
2528
|
+
const finishReason = _optionalChain([json, 'optionalAccess', _126 => _126.choices, 'optionalAccess', _127 => _127[0], 'optionalAccess', _128 => _128.finish_reason]);
|
|
2327
2529
|
let toolCalls;
|
|
2328
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
2530
|
+
if (_optionalChain([message, 'optionalAccess', _129 => _129.tool_calls]) && Array.isArray(message.tool_calls)) {
|
|
2329
2531
|
toolCalls = message.tool_calls.map((tc) => {
|
|
2330
|
-
const rawArgs = _optionalChain([tc, 'access',
|
|
2532
|
+
const rawArgs = _optionalChain([tc, 'access', _130 => _130.function, 'optionalAccess', _131 => _131.arguments]);
|
|
2331
2533
|
return {
|
|
2332
2534
|
id: tc.id,
|
|
2333
2535
|
type: "function",
|
|
2334
2536
|
function: {
|
|
2335
|
-
name: _nullishCoalesce(_optionalChain([tc, 'access',
|
|
2537
|
+
name: _nullishCoalesce(_optionalChain([tc, 'access', _132 => _132.function, 'optionalAccess', _133 => _133.name]), () => ( "")),
|
|
2336
2538
|
arguments: _nullishCoalesce(rawArgs, () => ( "{}"))
|
|
2337
2539
|
}
|
|
2338
2540
|
};
|
|
2339
2541
|
});
|
|
2340
2542
|
}
|
|
2341
|
-
|
|
2342
|
-
if (_optionalChain([json, 'optionalAccess', _126 => _126.usage])) {
|
|
2343
|
-
usage = {
|
|
2344
|
-
promptTokens: _nullishCoalesce(json.usage.prompt_tokens, () => ( 0)),
|
|
2345
|
-
completionTokens: _nullishCoalesce(json.usage.completion_tokens, () => ( 0)),
|
|
2346
|
-
totalTokens: _nullishCoalesce(json.usage.total_tokens, () => ( 0))
|
|
2347
|
-
};
|
|
2348
|
-
}
|
|
2543
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, _optionalChain([json, 'optionalAccess', _134 => _134.usage]));
|
|
2349
2544
|
return {
|
|
2350
2545
|
id: _nullishCoalesce(json.id, () => ( "llmgateway-response")),
|
|
2351
2546
|
created: _nullishCoalesce(json.created, () => ( Date.now())),
|
|
@@ -2357,7 +2552,7 @@ var LLMGatewayClient = class {
|
|
|
2357
2552
|
};
|
|
2358
2553
|
}
|
|
2359
2554
|
async handleStreamingResponse(response) {
|
|
2360
|
-
const reader = _optionalChain([response, 'access',
|
|
2555
|
+
const reader = _optionalChain([response, 'access', _135 => _135.body, 'optionalAccess', _136 => _136.getReader, 'call', _137 => _137()]);
|
|
2361
2556
|
if (!reader) {
|
|
2362
2557
|
throw new Error("No response body for streaming");
|
|
2363
2558
|
}
|
|
@@ -2379,7 +2574,7 @@ var LLMGatewayClient = class {
|
|
|
2379
2574
|
try {
|
|
2380
2575
|
const data = JSON.parse(dataStr);
|
|
2381
2576
|
lastChunk = data;
|
|
2382
|
-
const delta = _optionalChain([data, 'access',
|
|
2577
|
+
const delta = _optionalChain([data, 'access', _138 => _138.choices, 'optionalAccess', _139 => _139[0], 'optionalAccess', _140 => _140.delta]);
|
|
2383
2578
|
if (!delta) continue;
|
|
2384
2579
|
const reasoning = delta.reasoning || delta.reasoning_content;
|
|
2385
2580
|
if (reasoning) {
|
|
@@ -2388,7 +2583,7 @@ var LLMGatewayClient = class {
|
|
|
2388
2583
|
if (delta.content) {
|
|
2389
2584
|
fullContent += delta.content;
|
|
2390
2585
|
}
|
|
2391
|
-
if (_optionalChain([data, 'access',
|
|
2586
|
+
if (_optionalChain([data, 'access', _141 => _141.choices, 'optionalAccess', _142 => _142[0], 'optionalAccess', _143 => _143.finish_reason])) {
|
|
2392
2587
|
finishReason = data.choices[0].finish_reason;
|
|
2393
2588
|
}
|
|
2394
2589
|
} catch (e26) {
|
|
@@ -2403,8 +2598,8 @@ var LLMGatewayClient = class {
|
|
|
2403
2598
|
|
|
2404
2599
|
${fullContent}` : fullContent;
|
|
2405
2600
|
return {
|
|
2406
|
-
id: _nullishCoalesce(_optionalChain([lastChunk, 'optionalAccess',
|
|
2407
|
-
created: _nullishCoalesce(_optionalChain([lastChunk, 'optionalAccess',
|
|
2601
|
+
id: _nullishCoalesce(_optionalChain([lastChunk, 'optionalAccess', _144 => _144.id]), () => ( `llmgateway-stream-${Date.now()}`)),
|
|
2602
|
+
created: _nullishCoalesce(_optionalChain([lastChunk, 'optionalAccess', _145 => _145.created]), () => ( Math.floor(Date.now() / 1e3))),
|
|
2408
2603
|
content: finalContent,
|
|
2409
2604
|
finishReason,
|
|
2410
2605
|
raw: { content: fullContent, reasoning: fullReasoning, chunks: lastChunk }
|
|
@@ -2415,17 +2610,15 @@ ${fullContent}` : fullContent;
|
|
|
2415
2610
|
let errorDetail = "";
|
|
2416
2611
|
try {
|
|
2417
2612
|
const body = await response.json();
|
|
2418
|
-
errorDetail = _optionalChain([body, 'optionalAccess',
|
|
2419
|
-
if (typeof errorDetail === "object") {
|
|
2420
|
-
errorDetail = JSON.stringify(errorDetail);
|
|
2421
|
-
}
|
|
2613
|
+
errorDetail = coerceErrorDetail(_optionalChain([body, 'optionalAccess', _146 => _146.error, 'optionalAccess', _147 => _147.message]) || _optionalChain([body, 'optionalAccess', _148 => _148.error]) || _optionalChain([body, 'optionalAccess', _149 => _149.message]));
|
|
2422
2614
|
} catch (e27) {
|
|
2423
2615
|
try {
|
|
2424
2616
|
errorDetail = await response.text();
|
|
2425
2617
|
} catch (e28) {
|
|
2426
2618
|
}
|
|
2427
2619
|
}
|
|
2428
|
-
const
|
|
2620
|
+
const classified = _chunk3OF56EMAcjs.classifyApiError.call(void 0, status, errorDetail, response.headers);
|
|
2621
|
+
const friendlyMessage = buildFriendlyErrors(this.errorLabels)[classified.code];
|
|
2429
2622
|
if (friendlyMessage) {
|
|
2430
2623
|
return errorDetail ? `${friendlyMessage}
|
|
2431
2624
|
${errorDetail}` : friendlyMessage;
|
|
@@ -2483,6 +2676,9 @@ var LLMGatewayProvider = class {
|
|
|
2483
2676
|
getName() {
|
|
2484
2677
|
return "llmgateway";
|
|
2485
2678
|
}
|
|
2679
|
+
getCapabilities() {
|
|
2680
|
+
return { nativeToolCalling: true };
|
|
2681
|
+
}
|
|
2486
2682
|
setModel(model) {
|
|
2487
2683
|
this.model = model;
|
|
2488
2684
|
this.client.setDefaultModel(model);
|
|
@@ -2613,7 +2809,7 @@ function sanitizeMessages3(messages) {
|
|
|
2613
2809
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
2614
2810
|
sanitized.tool_call_id = msg.tool_call_id;
|
|
2615
2811
|
}
|
|
2616
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
2812
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _150 => _150.tool_calls, 'optionalAccess', _151 => _151.length])) {
|
|
2617
2813
|
sanitized.tool_calls = msg.tool_calls;
|
|
2618
2814
|
}
|
|
2619
2815
|
if (msg.name) {
|
|
@@ -2650,13 +2846,13 @@ var AzureClient = class {
|
|
|
2650
2846
|
this.options = options;
|
|
2651
2847
|
this.tokenManager = new AzureTokenManager();
|
|
2652
2848
|
this.defaultModel = options.model;
|
|
2653
|
-
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2849
|
+
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _152 => _152.maxRetries]), () => ( DEFAULT_MAX_RETRIES5));
|
|
2654
2850
|
this.maxRetries = Math.min(
|
|
2655
2851
|
Math.max(0, configuredRetries),
|
|
2656
2852
|
MAX_ALLOWED_RETRIES5
|
|
2657
2853
|
);
|
|
2658
|
-
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2659
|
-
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
2854
|
+
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _153 => _153.retryDelay]), () => ( DEFAULT_RETRY_DELAY5));
|
|
2855
|
+
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _154 => _154.timeout]), () => ( DEFAULT_TIMEOUT5));
|
|
2660
2856
|
}
|
|
2661
2857
|
setDefaultModel(model) {
|
|
2662
2858
|
this.defaultModel = model;
|
|
@@ -2784,7 +2980,7 @@ var AzureClient = class {
|
|
|
2784
2980
|
}
|
|
2785
2981
|
} catch (error) {
|
|
2786
2982
|
const err = error;
|
|
2787
|
-
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess',
|
|
2983
|
+
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess', _155 => _155.aborted])) {
|
|
2788
2984
|
throw new Error("Request cancelled.");
|
|
2789
2985
|
}
|
|
2790
2986
|
if (err.name === "AbortError") {
|
|
@@ -2800,31 +2996,24 @@ var AzureClient = class {
|
|
|
2800
2996
|
throw new Error(await this.buildFriendlyError(response));
|
|
2801
2997
|
}
|
|
2802
2998
|
const json = await response.json();
|
|
2803
|
-
const message = _optionalChain([json, 'optionalAccess',
|
|
2804
|
-
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess',
|
|
2805
|
-
const finishReason = _optionalChain([json, 'optionalAccess',
|
|
2999
|
+
const message = _optionalChain([json, 'optionalAccess', _156 => _156.choices, 'optionalAccess', _157 => _157[0], 'optionalAccess', _158 => _158.message]);
|
|
3000
|
+
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _159 => _159.content]), () => ( ""));
|
|
3001
|
+
const finishReason = _optionalChain([json, 'optionalAccess', _160 => _160.choices, 'optionalAccess', _161 => _161[0], 'optionalAccess', _162 => _162.finish_reason]);
|
|
2806
3002
|
let toolCalls;
|
|
2807
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
3003
|
+
if (_optionalChain([message, 'optionalAccess', _163 => _163.tool_calls]) && Array.isArray(message.tool_calls)) {
|
|
2808
3004
|
toolCalls = message.tool_calls.map((tc) => {
|
|
2809
|
-
const rawArgs = _optionalChain([tc, 'access',
|
|
3005
|
+
const rawArgs = _optionalChain([tc, 'access', _164 => _164.function, 'optionalAccess', _165 => _165.arguments]);
|
|
2810
3006
|
return {
|
|
2811
3007
|
id: tc.id,
|
|
2812
3008
|
type: "function",
|
|
2813
3009
|
function: {
|
|
2814
|
-
name: _nullishCoalesce(_optionalChain([tc, 'access',
|
|
3010
|
+
name: _nullishCoalesce(_optionalChain([tc, 'access', _166 => _166.function, 'optionalAccess', _167 => _167.name]), () => ( "")),
|
|
2815
3011
|
arguments: _nullishCoalesce(rawArgs, () => ( "{}"))
|
|
2816
3012
|
}
|
|
2817
3013
|
};
|
|
2818
3014
|
});
|
|
2819
3015
|
}
|
|
2820
|
-
|
|
2821
|
-
if (_optionalChain([json, 'optionalAccess', _160 => _160.usage])) {
|
|
2822
|
-
usage = {
|
|
2823
|
-
promptTokens: _nullishCoalesce(json.usage.prompt_tokens, () => ( 0)),
|
|
2824
|
-
completionTokens: _nullishCoalesce(json.usage.completion_tokens, () => ( 0)),
|
|
2825
|
-
totalTokens: _nullishCoalesce(json.usage.total_tokens, () => ( 0))
|
|
2826
|
-
};
|
|
2827
|
-
}
|
|
3016
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, _optionalChain([json, 'optionalAccess', _168 => _168.usage]));
|
|
2828
3017
|
return {
|
|
2829
3018
|
id: _nullishCoalesce(json.id, () => ( "autohand-azure")),
|
|
2830
3019
|
created: _nullishCoalesce(json.created, () => ( Date.now())),
|
|
@@ -2840,7 +3029,7 @@ var AzureClient = class {
|
|
|
2840
3029
|
let errorDetail = "";
|
|
2841
3030
|
try {
|
|
2842
3031
|
const body = await response.json();
|
|
2843
|
-
errorDetail = _optionalChain([body, 'optionalAccess',
|
|
3032
|
+
errorDetail = _optionalChain([body, 'optionalAccess', _169 => _169.error, 'optionalAccess', _170 => _170.message]) || _optionalChain([body, 'optionalAccess', _171 => _171.error]) || _optionalChain([body, 'optionalAccess', _172 => _172.message]) || "";
|
|
2844
3033
|
if (typeof errorDetail === "object") {
|
|
2845
3034
|
errorDetail = JSON.stringify(errorDetail);
|
|
2846
3035
|
}
|
|
@@ -2922,6 +3111,9 @@ var AzureProvider = class {
|
|
|
2922
3111
|
getName() {
|
|
2923
3112
|
return "azure";
|
|
2924
3113
|
}
|
|
3114
|
+
getCapabilities() {
|
|
3115
|
+
return { nativeToolCalling: true };
|
|
3116
|
+
}
|
|
2925
3117
|
setModel(model) {
|
|
2926
3118
|
this.model = model;
|
|
2927
3119
|
this.client.setDefaultModel(model);
|
|
@@ -2940,6 +3132,8 @@ var AzureProvider = class {
|
|
|
2940
3132
|
// src/providers/ZaiProvider.ts
|
|
2941
3133
|
var ZAI_DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
|
|
2942
3134
|
var ZAI_MODELS = [
|
|
3135
|
+
"glm-5.2",
|
|
3136
|
+
"glm-5.1",
|
|
2943
3137
|
"glm-4.5",
|
|
2944
3138
|
"glm-4.5v",
|
|
2945
3139
|
"glm-4.5-air",
|
|
@@ -2966,6 +3160,9 @@ var ZaiProvider = class {
|
|
|
2966
3160
|
getName() {
|
|
2967
3161
|
return "zai";
|
|
2968
3162
|
}
|
|
3163
|
+
getCapabilities() {
|
|
3164
|
+
return { nativeToolCalling: true };
|
|
3165
|
+
}
|
|
2969
3166
|
setModel(model) {
|
|
2970
3167
|
this.model = model;
|
|
2971
3168
|
this.client.setDefaultModel(model);
|
|
@@ -2981,6 +3178,48 @@ var ZaiProvider = class {
|
|
|
2981
3178
|
}
|
|
2982
3179
|
};
|
|
2983
3180
|
|
|
3181
|
+
// src/providers/SakanaProvider.ts
|
|
3182
|
+
var SAKANA_DEFAULT_BASE_URL = "https://api.sakana.ai/v1";
|
|
3183
|
+
var SAKANA_MODELS = [
|
|
3184
|
+
"fugu",
|
|
3185
|
+
"fugu-ultra"
|
|
3186
|
+
];
|
|
3187
|
+
var SakanaProvider = class {
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
constructor(config, networkSettings) {
|
|
3191
|
+
const effectiveConfig = {
|
|
3192
|
+
...config,
|
|
3193
|
+
baseUrl: _nullishCoalesce(config.baseUrl, () => ( SAKANA_DEFAULT_BASE_URL))
|
|
3194
|
+
};
|
|
3195
|
+
this.client = new LLMGatewayClient(effectiveConfig, networkSettings, {
|
|
3196
|
+
serviceName: "Sakana.AI",
|
|
3197
|
+
credentialName: "Sakana API key",
|
|
3198
|
+
accountName: "Sakana account"
|
|
3199
|
+
});
|
|
3200
|
+
this.model = config.model;
|
|
3201
|
+
}
|
|
3202
|
+
getName() {
|
|
3203
|
+
return "sakana";
|
|
3204
|
+
}
|
|
3205
|
+
getCapabilities() {
|
|
3206
|
+
return { nativeToolCalling: true };
|
|
3207
|
+
}
|
|
3208
|
+
setModel(model) {
|
|
3209
|
+
this.model = model;
|
|
3210
|
+
this.client.setDefaultModel(model);
|
|
3211
|
+
}
|
|
3212
|
+
async listModels() {
|
|
3213
|
+
return [...SAKANA_MODELS];
|
|
3214
|
+
}
|
|
3215
|
+
async isAvailable() {
|
|
3216
|
+
return true;
|
|
3217
|
+
}
|
|
3218
|
+
async complete(request) {
|
|
3219
|
+
return this.client.complete(request);
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3222
|
+
|
|
2984
3223
|
// src/utils/gcloudAuth.ts
|
|
2985
3224
|
var _child_process = require('child_process');
|
|
2986
3225
|
var _util = require('util');
|
|
@@ -3062,7 +3301,7 @@ function sanitizeMessages4(messages) {
|
|
|
3062
3301
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
3063
3302
|
sanitized.tool_call_id = msg.tool_call_id;
|
|
3064
3303
|
}
|
|
3065
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
3304
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _173 => _173.tool_calls, 'optionalAccess', _174 => _174.length])) {
|
|
3066
3305
|
sanitized.tool_calls = msg.tool_calls;
|
|
3067
3306
|
}
|
|
3068
3307
|
if (msg.name) {
|
|
@@ -3166,17 +3405,20 @@ var VertexAIProvider = class {
|
|
|
3166
3405
|
this.defaultModel = settings.model;
|
|
3167
3406
|
this.useGcloudRefresh = this.authToken.startsWith("ya29.") && this.authToken.length > 100;
|
|
3168
3407
|
this.baseUrl = `https://${this.endpoint}/v1/projects/${this.projectId}/locations/${this.region}/endpoints/openapi`;
|
|
3169
|
-
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
3408
|
+
const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _175 => _175.maxRetries]), () => ( DEFAULT_MAX_RETRIES6));
|
|
3170
3409
|
this.maxRetries = Math.min(
|
|
3171
3410
|
Math.max(0, configuredRetries),
|
|
3172
3411
|
MAX_ALLOWED_RETRIES6
|
|
3173
3412
|
);
|
|
3174
|
-
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
3175
|
-
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
3413
|
+
this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _176 => _176.retryDelay]), () => ( DEFAULT_RETRY_DELAY6));
|
|
3414
|
+
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _177 => _177.timeout]), () => ( DEFAULT_TIMEOUT6));
|
|
3176
3415
|
}
|
|
3177
3416
|
getName() {
|
|
3178
3417
|
return "vertexai";
|
|
3179
3418
|
}
|
|
3419
|
+
getCapabilities() {
|
|
3420
|
+
return { nativeToolCalling: true };
|
|
3421
|
+
}
|
|
3180
3422
|
setModel(model) {
|
|
3181
3423
|
this.defaultModel = model;
|
|
3182
3424
|
}
|
|
@@ -3339,7 +3581,7 @@ var VertexAIProvider = class {
|
|
|
3339
3581
|
}
|
|
3340
3582
|
} catch (error) {
|
|
3341
3583
|
const err = error;
|
|
3342
|
-
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess',
|
|
3584
|
+
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess', _178 => _178.aborted])) {
|
|
3343
3585
|
throw new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
3344
3586
|
}
|
|
3345
3587
|
if (err.name === "AbortError") {
|
|
@@ -3360,31 +3602,24 @@ var VertexAIProvider = class {
|
|
|
3360
3602
|
if (isAnthropic) {
|
|
3361
3603
|
return this.parseAnthropicResponse(json);
|
|
3362
3604
|
}
|
|
3363
|
-
const message = _optionalChain([json, 'optionalAccess',
|
|
3364
|
-
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess',
|
|
3365
|
-
const finishReason = _optionalChain([json, 'optionalAccess',
|
|
3605
|
+
const message = _optionalChain([json, 'optionalAccess', _179 => _179.choices, 'optionalAccess', _180 => _180[0], 'optionalAccess', _181 => _181.message]);
|
|
3606
|
+
const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _182 => _182.content]), () => ( ""));
|
|
3607
|
+
const finishReason = _optionalChain([json, 'optionalAccess', _183 => _183.choices, 'optionalAccess', _184 => _184[0], 'optionalAccess', _185 => _185.finish_reason]);
|
|
3366
3608
|
let toolCalls;
|
|
3367
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
3609
|
+
if (_optionalChain([message, 'optionalAccess', _186 => _186.tool_calls]) && Array.isArray(message.tool_calls)) {
|
|
3368
3610
|
toolCalls = message.tool_calls.map((tc) => {
|
|
3369
|
-
const rawArgs = _optionalChain([tc, 'access',
|
|
3611
|
+
const rawArgs = _optionalChain([tc, 'access', _187 => _187.function, 'optionalAccess', _188 => _188.arguments]);
|
|
3370
3612
|
return {
|
|
3371
3613
|
id: tc.id,
|
|
3372
3614
|
type: "function",
|
|
3373
3615
|
function: {
|
|
3374
|
-
name: _nullishCoalesce(_optionalChain([tc, 'access',
|
|
3616
|
+
name: _nullishCoalesce(_optionalChain([tc, 'access', _189 => _189.function, 'optionalAccess', _190 => _190.name]), () => ( "")),
|
|
3375
3617
|
arguments: _nullishCoalesce(rawArgs, () => ( "{}"))
|
|
3376
3618
|
}
|
|
3377
3619
|
};
|
|
3378
3620
|
});
|
|
3379
3621
|
}
|
|
3380
|
-
|
|
3381
|
-
if (_optionalChain([json, 'optionalAccess', _183 => _183.usage])) {
|
|
3382
|
-
usage = {
|
|
3383
|
-
promptTokens: _nullishCoalesce(json.usage.prompt_tokens, () => ( 0)),
|
|
3384
|
-
completionTokens: _nullishCoalesce(json.usage.completion_tokens, () => ( 0)),
|
|
3385
|
-
totalTokens: _nullishCoalesce(json.usage.total_tokens, () => ( 0))
|
|
3386
|
-
};
|
|
3387
|
-
}
|
|
3622
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, _optionalChain([json, 'optionalAccess', _191 => _191.usage]));
|
|
3388
3623
|
return {
|
|
3389
3624
|
id: _nullishCoalesce(json.id, () => ( "vertexai-response")),
|
|
3390
3625
|
created: _nullishCoalesce(json.created, () => ( Date.now())),
|
|
@@ -3399,9 +3634,9 @@ var VertexAIProvider = class {
|
|
|
3399
3634
|
* Parse Anthropic API response format
|
|
3400
3635
|
*/
|
|
3401
3636
|
parseAnthropicResponse(json) {
|
|
3402
|
-
const contentBlocks = _nullishCoalesce(_optionalChain([json, 'optionalAccess',
|
|
3637
|
+
const contentBlocks = _nullishCoalesce(_optionalChain([json, 'optionalAccess', _192 => _192.content]), () => ( []));
|
|
3403
3638
|
const textBlock = contentBlocks.find((b) => b.type === "text");
|
|
3404
|
-
const text = _nullishCoalesce(_optionalChain([textBlock, 'optionalAccess',
|
|
3639
|
+
const text = _nullishCoalesce(_optionalChain([textBlock, 'optionalAccess', _193 => _193.text]), () => ( ""));
|
|
3405
3640
|
let toolCalls;
|
|
3406
3641
|
const toolUseBlocks = contentBlocks.filter((b) => b.type === "tool_use");
|
|
3407
3642
|
if (toolUseBlocks.length > 0) {
|
|
@@ -3414,15 +3649,8 @@ var VertexAIProvider = class {
|
|
|
3414
3649
|
}
|
|
3415
3650
|
}));
|
|
3416
3651
|
}
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
usage = {
|
|
3420
|
-
promptTokens: _nullishCoalesce(json.usage.input_tokens, () => ( 0)),
|
|
3421
|
-
completionTokens: _nullishCoalesce(json.usage.output_tokens, () => ( 0)),
|
|
3422
|
-
totalTokens: (_nullishCoalesce(json.usage.input_tokens, () => ( 0))) + (_nullishCoalesce(json.usage.output_tokens, () => ( 0)))
|
|
3423
|
-
};
|
|
3424
|
-
}
|
|
3425
|
-
const stopReason = _optionalChain([json, 'optionalAccess', _187 => _187.stop_reason]);
|
|
3652
|
+
const usage = _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, _optionalChain([json, 'optionalAccess', _194 => _194.usage]));
|
|
3653
|
+
const stopReason = _optionalChain([json, 'optionalAccess', _195 => _195.stop_reason]);
|
|
3426
3654
|
let finishReason;
|
|
3427
3655
|
if (stopReason === "end_turn" || stopReason === "stop_sequence") {
|
|
3428
3656
|
finishReason = "stop";
|
|
@@ -3446,7 +3674,7 @@ var VertexAIProvider = class {
|
|
|
3446
3674
|
let errorDetail = "";
|
|
3447
3675
|
try {
|
|
3448
3676
|
const body = await response.json();
|
|
3449
|
-
errorDetail = _optionalChain([body, 'optionalAccess',
|
|
3677
|
+
errorDetail = _optionalChain([body, 'optionalAccess', _196 => _196.error, 'optionalAccess', _197 => _197.message]) || _optionalChain([body, 'optionalAccess', _198 => _198.error]) || _optionalChain([body, 'optionalAccess', _199 => _199.message]) || "";
|
|
3450
3678
|
if (typeof errorDetail === "object") {
|
|
3451
3679
|
errorDetail = JSON.stringify(errorDetail);
|
|
3452
3680
|
}
|
|
@@ -3549,6 +3777,9 @@ var XAIProvider = class {
|
|
|
3549
3777
|
getName() {
|
|
3550
3778
|
return "xai";
|
|
3551
3779
|
}
|
|
3780
|
+
getCapabilities() {
|
|
3781
|
+
return { nativeToolCalling: true };
|
|
3782
|
+
}
|
|
3552
3783
|
setModel(model) {
|
|
3553
3784
|
this.model = model;
|
|
3554
3785
|
}
|
|
@@ -3562,7 +3793,7 @@ var XAIProvider = class {
|
|
|
3562
3793
|
const response = await fetch(`${this.baseUrl}/language-models`, { headers });
|
|
3563
3794
|
if (response.ok) {
|
|
3564
3795
|
const data = await response.json();
|
|
3565
|
-
if (_optionalChain([data, 'optionalAccess',
|
|
3796
|
+
if (_optionalChain([data, 'optionalAccess', _200 => _200.models]) && Array.isArray(data.models)) {
|
|
3566
3797
|
const ids = /* @__PURE__ */ new Set();
|
|
3567
3798
|
for (const m of data.models) {
|
|
3568
3799
|
if (m.id) ids.add(m.id);
|
|
@@ -3621,7 +3852,7 @@ var XAIProvider = class {
|
|
|
3621
3852
|
});
|
|
3622
3853
|
} catch (error) {
|
|
3623
3854
|
const err = error;
|
|
3624
|
-
if (err.name === "AbortError" && _optionalChain([request, 'access',
|
|
3855
|
+
if (err.name === "AbortError" && _optionalChain([request, 'access', _201 => _201.signal, 'optionalAccess', _202 => _202.aborted])) {
|
|
3625
3856
|
throw new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
3626
3857
|
}
|
|
3627
3858
|
if (err.name === "AbortError") {
|
|
@@ -3651,7 +3882,7 @@ var XAIProvider = class {
|
|
|
3651
3882
|
created: _nullishCoalesce(data.created_at, () => ( Math.floor(Date.now() / 1e3))),
|
|
3652
3883
|
content,
|
|
3653
3884
|
toolCalls,
|
|
3654
|
-
finishReason: toolCalls.length > 0 ? "tool_calls" : _optionalChain([data, 'access',
|
|
3885
|
+
finishReason: toolCalls.length > 0 ? "tool_calls" : _optionalChain([data, 'access', _203 => _203.incomplete_details, 'optionalAccess', _204 => _204.reason]) === "max_output_tokens" ? "length" : "stop",
|
|
3655
3886
|
usage,
|
|
3656
3887
|
raw: data
|
|
3657
3888
|
};
|
|
@@ -3670,7 +3901,7 @@ var XAIProvider = class {
|
|
|
3670
3901
|
// server-side tool we emit the server-side variant; everything else becomes a
|
|
3671
3902
|
// standard `function` tool.
|
|
3672
3903
|
mapToXAITools(tools) {
|
|
3673
|
-
if (!_optionalChain([tools, 'optionalAccess',
|
|
3904
|
+
if (!_optionalChain([tools, 'optionalAccess', _205 => _205.length])) return [];
|
|
3674
3905
|
return tools.map((tool) => {
|
|
3675
3906
|
const name = tool.name.toLowerCase();
|
|
3676
3907
|
if (name === "web_search" || name === "x_search" || name === "code_execution" || name === "code_interpreter") {
|
|
@@ -3701,7 +3932,7 @@ var XAIProvider = class {
|
|
|
3701
3932
|
});
|
|
3702
3933
|
continue;
|
|
3703
3934
|
}
|
|
3704
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
3935
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _206 => _206.tool_calls, 'optionalAccess', _207 => _207.length])) {
|
|
3705
3936
|
items.push({
|
|
3706
3937
|
type: "message",
|
|
3707
3938
|
role: "assistant",
|
|
@@ -3730,7 +3961,7 @@ var XAIProvider = class {
|
|
|
3730
3961
|
}
|
|
3731
3962
|
extractXAIToolCalls(output) {
|
|
3732
3963
|
if (!Array.isArray(output)) return [];
|
|
3733
|
-
return output.filter((entry) => _optionalChain([entry, 'optionalAccess',
|
|
3964
|
+
return output.filter((entry) => _optionalChain([entry, 'optionalAccess', _208 => _208.type]) === "function_call").map((toolCall, index) => ({
|
|
3734
3965
|
id: _nullishCoalesce(toolCall.call_id, () => ( `call_${index + 1}`)),
|
|
3735
3966
|
type: "function",
|
|
3736
3967
|
function: {
|
|
@@ -3746,9 +3977,9 @@ var XAIProvider = class {
|
|
|
3746
3977
|
if (!Array.isArray(data.output)) return "";
|
|
3747
3978
|
const parts = [];
|
|
3748
3979
|
for (const item of data.output) {
|
|
3749
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
3980
|
+
if (_optionalChain([item, 'optionalAccess', _209 => _209.type]) !== "message" || !Array.isArray(item.content)) continue;
|
|
3750
3981
|
for (const ci of item.content) {
|
|
3751
|
-
if (_optionalChain([ci, 'optionalAccess',
|
|
3982
|
+
if (_optionalChain([ci, 'optionalAccess', _210 => _210.type]) === "output_text" && typeof ci.text === "string") {
|
|
3752
3983
|
parts.push(ci.text);
|
|
3753
3984
|
}
|
|
3754
3985
|
}
|
|
@@ -3756,14 +3987,7 @@ var XAIProvider = class {
|
|
|
3756
3987
|
return parts.join("\n").trim();
|
|
3757
3988
|
}
|
|
3758
3989
|
mapXAIUsage(usage) {
|
|
3759
|
-
|
|
3760
|
-
const input = _nullishCoalesce(usage.input_tokens, () => ( 0));
|
|
3761
|
-
const output = _nullishCoalesce(usage.output_tokens, () => ( 0));
|
|
3762
|
-
return {
|
|
3763
|
-
promptTokens: input,
|
|
3764
|
-
completionTokens: output,
|
|
3765
|
-
totalTokens: _nullishCoalesce(usage.total_tokens, () => ( input + output))
|
|
3766
|
-
};
|
|
3990
|
+
return _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, usage);
|
|
3767
3991
|
}
|
|
3768
3992
|
async parseXAIStream(response) {
|
|
3769
3993
|
const text = await response.text();
|
|
@@ -3793,8 +4017,8 @@ var XAIProvider = class {
|
|
|
3793
4017
|
let errorDetail = "";
|
|
3794
4018
|
try {
|
|
3795
4019
|
const body = await response.json();
|
|
3796
|
-
const errObj = _optionalChain([body, 'optionalAccess',
|
|
3797
|
-
errorDetail = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([errObj, 'optionalAccess',
|
|
4020
|
+
const errObj = _optionalChain([body, 'optionalAccess', _211 => _211.error]);
|
|
4021
|
+
errorDetail = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([errObj, 'optionalAccess', _212 => _212.message]), () => ( _optionalChain([body, 'optionalAccess', _213 => _213.detail]))), () => ( _optionalChain([body, 'optionalAccess', _214 => _214.error]))), () => ( ""));
|
|
3798
4022
|
if (typeof errorDetail === "object") {
|
|
3799
4023
|
errorDetail = JSON.stringify(errorDetail);
|
|
3800
4024
|
}
|
|
@@ -3818,7 +4042,7 @@ function sanitizeMessages5(messages) {
|
|
|
3818
4042
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
3819
4043
|
sanitized.tool_call_id = msg.tool_call_id;
|
|
3820
4044
|
}
|
|
3821
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
4045
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _215 => _215.tool_calls, 'optionalAccess', _216 => _216.length])) {
|
|
3822
4046
|
sanitized.tool_calls = msg.tool_calls;
|
|
3823
4047
|
}
|
|
3824
4048
|
if (msg.name) {
|
|
@@ -3856,11 +4080,11 @@ var CerebrasClient = class {
|
|
|
3856
4080
|
this.baseUrl = _nullishCoalesce(settings.baseUrl, () => ( DEFAULT_BASE_URL3));
|
|
3857
4081
|
this.defaultModel = settings.model;
|
|
3858
4082
|
this.maxRetries = Math.min(
|
|
3859
|
-
_nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
4083
|
+
_nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _217 => _217.maxRetries]), () => ( DEFAULT_MAX_RETRIES7)),
|
|
3860
4084
|
MAX_ALLOWED_RETRIES7
|
|
3861
4085
|
);
|
|
3862
4086
|
this.retryDelay = DEFAULT_RETRY_DELAY7;
|
|
3863
|
-
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess',
|
|
4087
|
+
this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _218 => _218.timeout]), () => ( DEFAULT_TIMEOUT7));
|
|
3864
4088
|
}
|
|
3865
4089
|
setDefaultModel(model) {
|
|
3866
4090
|
this.defaultModel = model;
|
|
@@ -3950,9 +4174,9 @@ var CerebrasClient = class {
|
|
|
3950
4174
|
return this.handleStreamingResponse(response);
|
|
3951
4175
|
}
|
|
3952
4176
|
const data = await response.json();
|
|
3953
|
-
const choice = _optionalChain([data, 'access',
|
|
4177
|
+
const choice = _optionalChain([data, 'access', _219 => _219.choices, 'optionalAccess', _220 => _220[0]]);
|
|
3954
4178
|
let toolCalls;
|
|
3955
|
-
if (_optionalChain([choice, 'optionalAccess',
|
|
4179
|
+
if (_optionalChain([choice, 'optionalAccess', _221 => _221.message, 'optionalAccess', _222 => _222.tool_calls, 'optionalAccess', _223 => _223.length])) {
|
|
3956
4180
|
toolCalls = choice.message.tool_calls.map((tc) => ({
|
|
3957
4181
|
id: tc.id,
|
|
3958
4182
|
type: tc.type,
|
|
@@ -3970,11 +4194,11 @@ var CerebrasClient = class {
|
|
|
3970
4194
|
totalTokens: data.usage.total_tokens
|
|
3971
4195
|
};
|
|
3972
4196
|
}
|
|
3973
|
-
const finishReason = _optionalChain([toolCalls, 'optionalAccess',
|
|
4197
|
+
const finishReason = _optionalChain([toolCalls, 'optionalAccess', _224 => _224.length]) ? "tool_calls" : _optionalChain([choice, 'optionalAccess', _225 => _225.finish_reason]) === "stop" || _optionalChain([choice, 'optionalAccess', _226 => _226.finish_reason]) === "length" || _optionalChain([choice, 'optionalAccess', _227 => _227.finish_reason]) === "content_filter" ? choice.finish_reason : "stop";
|
|
3974
4198
|
return {
|
|
3975
4199
|
id: data.id || `cerebras-${Date.now()}`,
|
|
3976
4200
|
created: data.created || Math.floor(Date.now() / 1e3),
|
|
3977
|
-
content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess',
|
|
4201
|
+
content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess', _228 => _228.message, 'optionalAccess', _229 => _229.content]), () => ( "")),
|
|
3978
4202
|
toolCalls,
|
|
3979
4203
|
usage,
|
|
3980
4204
|
finishReason,
|
|
@@ -3982,7 +4206,7 @@ var CerebrasClient = class {
|
|
|
3982
4206
|
};
|
|
3983
4207
|
}
|
|
3984
4208
|
async handleStreamingResponse(response) {
|
|
3985
|
-
const reader = _optionalChain([response, 'access',
|
|
4209
|
+
const reader = _optionalChain([response, 'access', _230 => _230.body, 'optionalAccess', _231 => _231.getReader, 'call', _232 => _232()]);
|
|
3986
4210
|
if (!reader) {
|
|
3987
4211
|
throw new Error("No response body available for streaming");
|
|
3988
4212
|
}
|
|
@@ -4000,11 +4224,11 @@ var CerebrasClient = class {
|
|
|
4000
4224
|
if (data === "[DONE]") continue;
|
|
4001
4225
|
try {
|
|
4002
4226
|
const parsed = JSON.parse(data);
|
|
4003
|
-
const delta = _optionalChain([parsed, 'access',
|
|
4004
|
-
if (_optionalChain([delta, 'optionalAccess',
|
|
4227
|
+
const delta = _optionalChain([parsed, 'access', _233 => _233.choices, 'optionalAccess', _234 => _234[0], 'optionalAccess', _235 => _235.delta]);
|
|
4228
|
+
if (_optionalChain([delta, 'optionalAccess', _236 => _236.content])) {
|
|
4005
4229
|
content += delta.content;
|
|
4006
4230
|
}
|
|
4007
|
-
if (_optionalChain([parsed, 'access',
|
|
4231
|
+
if (_optionalChain([parsed, 'access', _237 => _237.choices, 'optionalAccess', _238 => _238[0], 'optionalAccess', _239 => _239.finish_reason])) {
|
|
4008
4232
|
finishReason = parsed.choices[0].finish_reason;
|
|
4009
4233
|
}
|
|
4010
4234
|
} catch (e43) {
|
|
@@ -4039,7 +4263,7 @@ var CerebrasClient = class {
|
|
|
4039
4263
|
let errorDetail = "";
|
|
4040
4264
|
try {
|
|
4041
4265
|
const errorData = await response.json();
|
|
4042
|
-
errorDetail = _optionalChain([errorData, 'access',
|
|
4266
|
+
errorDetail = _optionalChain([errorData, 'access', _240 => _240.error, 'optionalAccess', _241 => _241.message]) || JSON.stringify(errorData);
|
|
4043
4267
|
} catch (e44) {
|
|
4044
4268
|
try {
|
|
4045
4269
|
errorDetail = await response.text();
|
|
@@ -4076,6 +4300,9 @@ var CerebrasProvider = class {
|
|
|
4076
4300
|
getName() {
|
|
4077
4301
|
return "cerebras";
|
|
4078
4302
|
}
|
|
4303
|
+
getCapabilities() {
|
|
4304
|
+
return { nativeToolCalling: true };
|
|
4305
|
+
}
|
|
4079
4306
|
setModel(model) {
|
|
4080
4307
|
this.model = model;
|
|
4081
4308
|
this.client.setDefaultModel(model);
|
|
@@ -4117,6 +4344,9 @@ var DeepSeekProvider = class {
|
|
|
4117
4344
|
getName() {
|
|
4118
4345
|
return "deepseek";
|
|
4119
4346
|
}
|
|
4347
|
+
getCapabilities() {
|
|
4348
|
+
return { nativeToolCalling: true };
|
|
4349
|
+
}
|
|
4120
4350
|
setModel(model) {
|
|
4121
4351
|
this.model = model;
|
|
4122
4352
|
this.client.setDefaultModel(model);
|
|
@@ -4132,6 +4362,593 @@ var DeepSeekProvider = class {
|
|
|
4132
4362
|
}
|
|
4133
4363
|
};
|
|
4134
4364
|
|
|
4365
|
+
// src/providers/BedrockProvider.ts
|
|
4366
|
+
|
|
4367
|
+
|
|
4368
|
+
|
|
4369
|
+
var _clientbedrockruntime = require('@aws-sdk/client-bedrock-runtime');
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
|
|
4373
|
+
var _clientbedrock = require('@aws-sdk/client-bedrock');
|
|
4374
|
+
var _credentialproviders = require('@aws-sdk/credential-providers');
|
|
4375
|
+
var BEDROCK_DEFAULT_REGION = "us-east-1";
|
|
4376
|
+
var BEDROCK_DEFAULT_MODEL = "anthropic.claude-3-5-sonnet-20241022-v2:0";
|
|
4377
|
+
var BEDROCK_MODELS = [
|
|
4378
|
+
BEDROCK_DEFAULT_MODEL,
|
|
4379
|
+
"anthropic.claude-3-7-sonnet-20250219-v1:0",
|
|
4380
|
+
"anthropic.claude-sonnet-4-20250514-v1:0",
|
|
4381
|
+
"amazon.nova-pro-v1:0",
|
|
4382
|
+
"amazon.nova-lite-v1:0",
|
|
4383
|
+
"meta.llama3-1-70b-instruct-v1:0",
|
|
4384
|
+
"openai.gpt-oss-120b-1:0"
|
|
4385
|
+
];
|
|
4386
|
+
function resolveBedrockRegion(region) {
|
|
4387
|
+
return _optionalChain([region, 'optionalAccess', _242 => _242.trim, 'call', _243 => _243()]) || process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || BEDROCK_DEFAULT_REGION;
|
|
4388
|
+
}
|
|
4389
|
+
function getBedrockRuntimeEndpoint(region) {
|
|
4390
|
+
return `https://bedrock-runtime.${region}.amazonaws.com`;
|
|
4391
|
+
}
|
|
4392
|
+
function getBedrockOpenAIEndpoint(_mode, region) {
|
|
4393
|
+
return `${getBedrockRuntimeEndpoint(region)}/openai/v1`;
|
|
4394
|
+
}
|
|
4395
|
+
function resolveBedrockEndpoint(mode, region, configuredEndpoint) {
|
|
4396
|
+
if (_optionalChain([configuredEndpoint, 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()])) {
|
|
4397
|
+
return configuredEndpoint.replace(/\/+$/, "");
|
|
4398
|
+
}
|
|
4399
|
+
if (mode === "converse") {
|
|
4400
|
+
return getBedrockRuntimeEndpoint(region);
|
|
4401
|
+
}
|
|
4402
|
+
return getBedrockOpenAIEndpoint(mode, region);
|
|
4403
|
+
}
|
|
4404
|
+
function resolveBedrockAuthMode(mode, configured) {
|
|
4405
|
+
if (configured) return configured;
|
|
4406
|
+
return mode === "converse" ? "aws-credentials" : "bedrock-api-key";
|
|
4407
|
+
}
|
|
4408
|
+
function parseToolArguments(argumentsJson) {
|
|
4409
|
+
try {
|
|
4410
|
+
return JSON.parse(argumentsJson);
|
|
4411
|
+
} catch (e46) {
|
|
4412
|
+
return {};
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
function toTextContent(content) {
|
|
4416
|
+
return content ? [{ text: content }] : [];
|
|
4417
|
+
}
|
|
4418
|
+
function toToolUseBlocks(toolCalls) {
|
|
4419
|
+
return toolCalls.map((toolCall) => ({
|
|
4420
|
+
toolUse: {
|
|
4421
|
+
toolUseId: toolCall.id,
|
|
4422
|
+
name: toolCall.function.name,
|
|
4423
|
+
input: parseToolArguments(toolCall.function.arguments)
|
|
4424
|
+
}
|
|
4425
|
+
}));
|
|
4426
|
+
}
|
|
4427
|
+
function toConverseMessage(message) {
|
|
4428
|
+
if (message.role === "system") {
|
|
4429
|
+
return null;
|
|
4430
|
+
}
|
|
4431
|
+
if (message.role === "tool") {
|
|
4432
|
+
return {
|
|
4433
|
+
role: "user",
|
|
4434
|
+
content: [
|
|
4435
|
+
{
|
|
4436
|
+
toolResult: {
|
|
4437
|
+
toolUseId: _nullishCoalesce(_nullishCoalesce(message.tool_call_id, () => ( message.name)), () => ( "tool_result")),
|
|
4438
|
+
content: [{ text: message.content }]
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
]
|
|
4442
|
+
};
|
|
4443
|
+
}
|
|
4444
|
+
if (message.role === "assistant") {
|
|
4445
|
+
const content = [
|
|
4446
|
+
...toTextContent(message.content),
|
|
4447
|
+
..._optionalChain([message, 'access', _246 => _246.tool_calls, 'optionalAccess', _247 => _247.length]) ? toToolUseBlocks(message.tool_calls) : []
|
|
4448
|
+
];
|
|
4449
|
+
return {
|
|
4450
|
+
role: "assistant",
|
|
4451
|
+
content: content.length > 0 ? content : [{ text: "" }]
|
|
4452
|
+
};
|
|
4453
|
+
}
|
|
4454
|
+
return {
|
|
4455
|
+
role: "user",
|
|
4456
|
+
content: toTextContent(message.content)
|
|
4457
|
+
};
|
|
4458
|
+
}
|
|
4459
|
+
function toOpenAIMessage(message) {
|
|
4460
|
+
const mapped = {
|
|
4461
|
+
role: message.role,
|
|
4462
|
+
content: message.role === "assistant" && _optionalChain([message, 'access', _248 => _248.tool_calls, 'optionalAccess', _249 => _249.length]) ? message.content || null : message.content
|
|
4463
|
+
};
|
|
4464
|
+
if (message.name) mapped.name = message.name;
|
|
4465
|
+
if (message.role === "tool" && message.tool_call_id) {
|
|
4466
|
+
mapped.tool_call_id = message.tool_call_id;
|
|
4467
|
+
}
|
|
4468
|
+
if (message.role === "assistant" && _optionalChain([message, 'access', _250 => _250.tool_calls, 'optionalAccess', _251 => _251.length])) {
|
|
4469
|
+
mapped.tool_calls = message.tool_calls;
|
|
4470
|
+
}
|
|
4471
|
+
return mapped;
|
|
4472
|
+
}
|
|
4473
|
+
function toResponsesInputItem(message) {
|
|
4474
|
+
if (message.role === "tool" && message.tool_call_id) {
|
|
4475
|
+
return [
|
|
4476
|
+
{
|
|
4477
|
+
type: "function_call_output",
|
|
4478
|
+
call_id: message.tool_call_id,
|
|
4479
|
+
output: message.content
|
|
4480
|
+
}
|
|
4481
|
+
];
|
|
4482
|
+
}
|
|
4483
|
+
if (message.role === "assistant" && _optionalChain([message, 'access', _252 => _252.tool_calls, 'optionalAccess', _253 => _253.length])) {
|
|
4484
|
+
return message.tool_calls.map((toolCall) => ({
|
|
4485
|
+
type: "function_call",
|
|
4486
|
+
call_id: toolCall.id,
|
|
4487
|
+
name: toolCall.function.name,
|
|
4488
|
+
arguments: toolCall.function.arguments
|
|
4489
|
+
}));
|
|
4490
|
+
}
|
|
4491
|
+
if (message.role === "system") {
|
|
4492
|
+
return [];
|
|
4493
|
+
}
|
|
4494
|
+
const contentType = message.role === "assistant" ? "output_text" : "input_text";
|
|
4495
|
+
return [
|
|
4496
|
+
{
|
|
4497
|
+
role: message.role,
|
|
4498
|
+
content: [{ type: contentType, text: message.content }]
|
|
4499
|
+
}
|
|
4500
|
+
];
|
|
4501
|
+
}
|
|
4502
|
+
function toOpenAITools(tools) {
|
|
4503
|
+
return tools.map((tool) => ({
|
|
4504
|
+
type: "function",
|
|
4505
|
+
function: {
|
|
4506
|
+
name: tool.name,
|
|
4507
|
+
description: tool.description,
|
|
4508
|
+
parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
|
|
4509
|
+
}
|
|
4510
|
+
}));
|
|
4511
|
+
}
|
|
4512
|
+
function toResponsesTools(tools) {
|
|
4513
|
+
return tools.map((tool) => ({
|
|
4514
|
+
type: "function",
|
|
4515
|
+
name: tool.name,
|
|
4516
|
+
description: tool.description,
|
|
4517
|
+
parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
|
|
4518
|
+
}));
|
|
4519
|
+
}
|
|
4520
|
+
function toConverseTools(tools) {
|
|
4521
|
+
return tools.map((tool) => ({
|
|
4522
|
+
toolSpec: {
|
|
4523
|
+
name: tool.name,
|
|
4524
|
+
description: tool.description,
|
|
4525
|
+
inputSchema: {
|
|
4526
|
+
json: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
}));
|
|
4530
|
+
}
|
|
4531
|
+
function normalizeStopReason(stopReason) {
|
|
4532
|
+
if (stopReason === "tool_use" || stopReason === "tool_calls") {
|
|
4533
|
+
return "tool_calls";
|
|
4534
|
+
}
|
|
4535
|
+
if (stopReason === "max_tokens" || stopReason === "length") {
|
|
4536
|
+
return "length";
|
|
4537
|
+
}
|
|
4538
|
+
if (stopReason === "content_filter") {
|
|
4539
|
+
return "content_filter";
|
|
4540
|
+
}
|
|
4541
|
+
return "stop";
|
|
4542
|
+
}
|
|
4543
|
+
function toolCallsFromConverseBlocks(blocks) {
|
|
4544
|
+
return blocks.filter(
|
|
4545
|
+
(block) => "toolUse" in block && Boolean(block.toolUse)
|
|
4546
|
+
).map((block) => ({
|
|
4547
|
+
id: block.toolUse.toolUseId,
|
|
4548
|
+
type: "function",
|
|
4549
|
+
function: {
|
|
4550
|
+
name: block.toolUse.name,
|
|
4551
|
+
arguments: JSON.stringify(_nullishCoalesce(block.toolUse.input, () => ( {})))
|
|
4552
|
+
}
|
|
4553
|
+
}));
|
|
4554
|
+
}
|
|
4555
|
+
function textFromConverseBlocks(blocks) {
|
|
4556
|
+
return blocks.filter((block) => "text" in block).map((block) => block.text).join("");
|
|
4557
|
+
}
|
|
4558
|
+
function isBedrockAwsError(error) {
|
|
4559
|
+
return error instanceof Error;
|
|
4560
|
+
}
|
|
4561
|
+
function classifyBedrockError(error) {
|
|
4562
|
+
if (!isBedrockAwsError(error)) {
|
|
4563
|
+
return new (0, _chunk3OF56EMAcjs.ApiError)(String(error), "unknown", 0, true);
|
|
4564
|
+
}
|
|
4565
|
+
if (error.name === "AbortError") {
|
|
4566
|
+
return new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
4567
|
+
}
|
|
4568
|
+
const status = _nullishCoalesce(_optionalChain([error, 'access', _254 => _254["$metadata"], 'optionalAccess', _255 => _255.httpStatusCode]), () => ( 0));
|
|
4569
|
+
const message = error.message || error.name;
|
|
4570
|
+
const lower = `${error.name} ${message}`.toLowerCase();
|
|
4571
|
+
let code;
|
|
4572
|
+
if (lower.includes("credential") || lower.includes("signature") || lower.includes("unrecognizedclient") || lower.includes("expiredtoken")) {
|
|
4573
|
+
code = "auth_failed";
|
|
4574
|
+
} else if (lower.includes("accessdenied") || lower.includes("access denied") || lower.includes("not authorized") || lower.includes("model access")) {
|
|
4575
|
+
code = "access_denied";
|
|
4576
|
+
} else if (lower.includes("resourcenotfound") || lower.includes("model not found") || lower.includes("not found") || lower.includes("not available")) {
|
|
4577
|
+
code = "model_not_found";
|
|
4578
|
+
} else if (lower.includes("throttl") || lower.includes("quota") || lower.includes("toomanyrequests")) {
|
|
4579
|
+
code = "rate_limited";
|
|
4580
|
+
} else if (lower.includes("validation") || lower.includes("unsupported") || lower.includes("api mode")) {
|
|
4581
|
+
code = "invalid_request";
|
|
4582
|
+
} else if (lower.includes("network") || lower.includes("enotfound") || lower.includes("econn") || lower.includes("private endpoint")) {
|
|
4583
|
+
code = "network_error";
|
|
4584
|
+
}
|
|
4585
|
+
if (code) {
|
|
4586
|
+
const friendly = {
|
|
4587
|
+
auth_failed: "AWS Bedrock credentials were not found or were rejected. Configure AWS credentials, AWS_PROFILE, instance metadata, or choose Bedrock API key auth.",
|
|
4588
|
+
access_denied: "AWS Bedrock denied access. Enable model access in the AWS console and verify IAM permissions for this model.",
|
|
4589
|
+
model_not_found: "The selected Bedrock model is not available in this region. Check the model ID, inference profile, ARN, and region.",
|
|
4590
|
+
invalid_request: "Bedrock rejected the request. The selected model may not support this API mode or native tool use.",
|
|
4591
|
+
rate_limited: "AWS Bedrock throttled the request or quota was exceeded. Wait and retry, or request a quota increase.",
|
|
4592
|
+
network_error: "Unable to reach the AWS Bedrock endpoint. Check region, endpoint, private networking, and proxy settings.",
|
|
4593
|
+
timeout: "The AWS Bedrock request timed out.",
|
|
4594
|
+
cancelled: "Request cancelled.",
|
|
4595
|
+
context_overflow: "The conversation is too long for this Bedrock model.",
|
|
4596
|
+
payment_required: "AWS Bedrock billing or account setup is required.",
|
|
4597
|
+
server_error: "AWS Bedrock encountered a service error. Please try again later.",
|
|
4598
|
+
unknown: "AWS Bedrock returned an unexpected error."
|
|
4599
|
+
};
|
|
4600
|
+
return new (0, _chunk3OF56EMAcjs.ApiError)(`${friendly[code]}
|
|
4601
|
+
${message}`, code, status, code === "rate_limited" || code === "server_error", void 0, message);
|
|
4602
|
+
}
|
|
4603
|
+
return _chunk3OF56EMAcjs.classifyApiError.call(void 0, status, message);
|
|
4604
|
+
}
|
|
4605
|
+
async function readErrorBody(response) {
|
|
4606
|
+
try {
|
|
4607
|
+
return await response.text();
|
|
4608
|
+
} catch (e47) {
|
|
4609
|
+
return "";
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
var BedrockProvider = class {
|
|
4613
|
+
|
|
4614
|
+
|
|
4615
|
+
|
|
4616
|
+
|
|
4617
|
+
|
|
4618
|
+
|
|
4619
|
+
|
|
4620
|
+
|
|
4621
|
+
|
|
4622
|
+
constructor(config) {
|
|
4623
|
+
this.apiMode = _nullishCoalesce(config.apiMode, () => ( "converse"));
|
|
4624
|
+
this.authMode = resolveBedrockAuthMode(this.apiMode, config.authMode);
|
|
4625
|
+
this.region = resolveBedrockRegion(config.region);
|
|
4626
|
+
this.endpoint = resolveBedrockEndpoint(this.apiMode, this.region, config.endpoint);
|
|
4627
|
+
this.profile = config.profile;
|
|
4628
|
+
this.apiKey = config.apiKey;
|
|
4629
|
+
this.model = config.model || BEDROCK_DEFAULT_MODEL;
|
|
4630
|
+
}
|
|
4631
|
+
getName() {
|
|
4632
|
+
return "bedrock";
|
|
4633
|
+
}
|
|
4634
|
+
setModel(model) {
|
|
4635
|
+
this.model = model;
|
|
4636
|
+
}
|
|
4637
|
+
getCapabilities() {
|
|
4638
|
+
return { nativeToolCalling: true };
|
|
4639
|
+
}
|
|
4640
|
+
async listModels() {
|
|
4641
|
+
if (this.apiMode !== "converse") {
|
|
4642
|
+
return [...BEDROCK_MODELS];
|
|
4643
|
+
}
|
|
4644
|
+
try {
|
|
4645
|
+
const response = await this.getModelClient().send(
|
|
4646
|
+
new (0, _clientbedrock.ListFoundationModelsCommand)({})
|
|
4647
|
+
);
|
|
4648
|
+
const summaries = _nullishCoalesce(response.modelSummaries, () => ( []));
|
|
4649
|
+
const modelIds = summaries.map((summary) => summary.modelId).filter((modelId) => Boolean(modelId));
|
|
4650
|
+
return modelIds.length > 0 ? modelIds : [...BEDROCK_MODELS];
|
|
4651
|
+
} catch (e48) {
|
|
4652
|
+
return [...BEDROCK_MODELS];
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4655
|
+
async isAvailable() {
|
|
4656
|
+
if (this.authMode === "bedrock-api-key") {
|
|
4657
|
+
return Boolean(this.apiKey);
|
|
4658
|
+
}
|
|
4659
|
+
try {
|
|
4660
|
+
await this.listModels();
|
|
4661
|
+
return true;
|
|
4662
|
+
} catch (e49) {
|
|
4663
|
+
return false;
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
async complete(request) {
|
|
4667
|
+
if (!this.region) {
|
|
4668
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4669
|
+
"AWS Bedrock region is missing. Set bedrock.region, AWS_REGION, or AWS_DEFAULT_REGION.",
|
|
4670
|
+
"invalid_request",
|
|
4671
|
+
0,
|
|
4672
|
+
false
|
|
4673
|
+
);
|
|
4674
|
+
}
|
|
4675
|
+
if (this.apiMode === "converse") {
|
|
4676
|
+
return this.completeWithConverse(request);
|
|
4677
|
+
}
|
|
4678
|
+
return this.completeWithOpenAICompatible(request);
|
|
4679
|
+
}
|
|
4680
|
+
getCredentials() {
|
|
4681
|
+
if (this.profile) {
|
|
4682
|
+
return _credentialproviders.fromIni.call(void 0, { profile: this.profile });
|
|
4683
|
+
}
|
|
4684
|
+
return void 0;
|
|
4685
|
+
}
|
|
4686
|
+
getRuntimeClient() {
|
|
4687
|
+
if (!this.runtimeClient) {
|
|
4688
|
+
this.runtimeClient = new (0, _clientbedrockruntime.BedrockRuntimeClient)({
|
|
4689
|
+
region: this.region,
|
|
4690
|
+
endpoint: this.endpoint,
|
|
4691
|
+
credentials: this.getCredentials()
|
|
4692
|
+
});
|
|
4693
|
+
}
|
|
4694
|
+
return this.runtimeClient;
|
|
4695
|
+
}
|
|
4696
|
+
getModelClient() {
|
|
4697
|
+
if (!this.modelClient) {
|
|
4698
|
+
this.modelClient = new (0, _clientbedrock.BedrockClient)({
|
|
4699
|
+
region: this.region,
|
|
4700
|
+
credentials: this.getCredentials()
|
|
4701
|
+
});
|
|
4702
|
+
}
|
|
4703
|
+
return this.modelClient;
|
|
4704
|
+
}
|
|
4705
|
+
async completeWithConverse(request) {
|
|
4706
|
+
if (this.authMode === "bedrock-api-key") {
|
|
4707
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4708
|
+
"Bedrock Converse uses AWS credential-chain auth. Choose apiMode openai-chat/openai-responses to use Bedrock API keys.",
|
|
4709
|
+
"invalid_request",
|
|
4710
|
+
0,
|
|
4711
|
+
false
|
|
4712
|
+
);
|
|
4713
|
+
}
|
|
4714
|
+
const contentMessages = request.messages.map(toConverseMessage).filter((message) => message !== null);
|
|
4715
|
+
const system = request.messages.filter((message) => message.role === "system" && message.content).map((message) => ({ text: message.content }));
|
|
4716
|
+
const body = {
|
|
4717
|
+
modelId: _nullishCoalesce(request.model, () => ( this.model)),
|
|
4718
|
+
messages: contentMessages,
|
|
4719
|
+
inferenceConfig: {
|
|
4720
|
+
...request.maxTokens !== void 0 && { maxTokens: request.maxTokens },
|
|
4721
|
+
...request.temperature !== void 0 && { temperature: request.temperature }
|
|
4722
|
+
}
|
|
4723
|
+
};
|
|
4724
|
+
if (system.length > 0) {
|
|
4725
|
+
body.system = system;
|
|
4726
|
+
}
|
|
4727
|
+
if (_optionalChain([request, 'access', _256 => _256.tools, 'optionalAccess', _257 => _257.length])) {
|
|
4728
|
+
body.toolConfig = {
|
|
4729
|
+
tools: toConverseTools(request.tools),
|
|
4730
|
+
...request.toolChoice && request.toolChoice !== "auto" ? { toolChoice: this.toConverseToolChoice(request.toolChoice) } : {}
|
|
4731
|
+
};
|
|
4732
|
+
}
|
|
4733
|
+
try {
|
|
4734
|
+
const data = await this.getRuntimeClient().send(
|
|
4735
|
+
new (0, _clientbedrockruntime.ConverseCommand)(body)
|
|
4736
|
+
);
|
|
4737
|
+
const blocks = _nullishCoalesce(_optionalChain([data, 'access', _258 => _258.output, 'optionalAccess', _259 => _259.message, 'optionalAccess', _260 => _260.content]), () => ( []));
|
|
4738
|
+
const toolCalls = toolCallsFromConverseBlocks(blocks);
|
|
4739
|
+
return {
|
|
4740
|
+
id: `bedrock-${Date.now()}`,
|
|
4741
|
+
created: Math.floor(Date.now() / 1e3),
|
|
4742
|
+
content: textFromConverseBlocks(blocks),
|
|
4743
|
+
...toolCalls.length > 0 && { toolCalls },
|
|
4744
|
+
finishReason: normalizeStopReason(data.stopReason),
|
|
4745
|
+
usage: _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, data.usage),
|
|
4746
|
+
raw: data
|
|
4747
|
+
};
|
|
4748
|
+
} catch (error) {
|
|
4749
|
+
throw classifyBedrockError(error);
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
toConverseToolChoice(toolChoice) {
|
|
4753
|
+
if (!toolChoice || toolChoice === "auto") return void 0;
|
|
4754
|
+
if (toolChoice === "none") return { auto: {} };
|
|
4755
|
+
if (toolChoice === "required") return { any: {} };
|
|
4756
|
+
return { tool: { name: toolChoice.function.name } };
|
|
4757
|
+
}
|
|
4758
|
+
async completeWithOpenAICompatible(request) {
|
|
4759
|
+
if (this.authMode !== "bedrock-api-key") {
|
|
4760
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4761
|
+
"Bedrock OpenAI-compatible modes require authMode bedrock-api-key and bedrock.apiKey.",
|
|
4762
|
+
"auth_failed",
|
|
4763
|
+
0,
|
|
4764
|
+
false
|
|
4765
|
+
);
|
|
4766
|
+
}
|
|
4767
|
+
if (!this.apiKey) {
|
|
4768
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4769
|
+
"Bedrock API key is missing. Set bedrock.apiKey for OpenAI-compatible Bedrock modes.",
|
|
4770
|
+
"auth_failed",
|
|
4771
|
+
0,
|
|
4772
|
+
false
|
|
4773
|
+
);
|
|
4774
|
+
}
|
|
4775
|
+
if (this.apiMode === "openai-chat") {
|
|
4776
|
+
return this.completeWithOpenAIChat(request);
|
|
4777
|
+
}
|
|
4778
|
+
return this.completeWithOpenAIResponses(request);
|
|
4779
|
+
}
|
|
4780
|
+
async completeWithOpenAIChat(request) {
|
|
4781
|
+
const body = {
|
|
4782
|
+
model: _nullishCoalesce(request.model, () => ( this.model)),
|
|
4783
|
+
messages: request.messages.map(toOpenAIMessage),
|
|
4784
|
+
...request.temperature !== void 0 && { temperature: request.temperature },
|
|
4785
|
+
...request.maxTokens !== void 0 && { max_tokens: request.maxTokens }
|
|
4786
|
+
};
|
|
4787
|
+
if (_optionalChain([request, 'access', _261 => _261.tools, 'optionalAccess', _262 => _262.length])) {
|
|
4788
|
+
body.tools = toOpenAITools(request.tools);
|
|
4789
|
+
if (request.toolChoice) body.tool_choice = request.toolChoice;
|
|
4790
|
+
}
|
|
4791
|
+
const data = await this.fetchJson("/chat/completions", body, request.signal);
|
|
4792
|
+
const choice = _optionalChain([data, 'access', _263 => _263.choices, 'optionalAccess', _264 => _264[0]]);
|
|
4793
|
+
if (!_optionalChain([choice, 'optionalAccess', _265 => _265.message])) {
|
|
4794
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4795
|
+
"Malformed Bedrock OpenAI chat response: missing choice message.",
|
|
4796
|
+
"invalid_request",
|
|
4797
|
+
200,
|
|
4798
|
+
false,
|
|
4799
|
+
void 0,
|
|
4800
|
+
JSON.stringify(data)
|
|
4801
|
+
);
|
|
4802
|
+
}
|
|
4803
|
+
return {
|
|
4804
|
+
id: _nullishCoalesce(data.id, () => ( `bedrock-chat-${Date.now()}`)),
|
|
4805
|
+
created: _nullishCoalesce(data.created, () => ( Math.floor(Date.now() / 1e3))),
|
|
4806
|
+
content: _nullishCoalesce(choice.message.content, () => ( "")),
|
|
4807
|
+
..._optionalChain([choice, 'access', _266 => _266.message, 'access', _267 => _267.tool_calls, 'optionalAccess', _268 => _268.length]) && { toolCalls: choice.message.tool_calls },
|
|
4808
|
+
finishReason: normalizeStopReason(choice.finish_reason),
|
|
4809
|
+
usage: _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, data.usage),
|
|
4810
|
+
raw: data
|
|
4811
|
+
};
|
|
4812
|
+
}
|
|
4813
|
+
async completeWithOpenAIResponses(request) {
|
|
4814
|
+
const instructions = request.messages.filter((message) => message.role === "system").map((message) => message.content).join("\n\n");
|
|
4815
|
+
const body = {
|
|
4816
|
+
model: _nullishCoalesce(request.model, () => ( this.model)),
|
|
4817
|
+
input: request.messages.flatMap(toResponsesInputItem),
|
|
4818
|
+
...instructions && { instructions },
|
|
4819
|
+
...request.maxTokens !== void 0 && { max_output_tokens: request.maxTokens }
|
|
4820
|
+
};
|
|
4821
|
+
if (_optionalChain([request, 'access', _269 => _269.tools, 'optionalAccess', _270 => _270.length])) {
|
|
4822
|
+
body.tools = toResponsesTools(request.tools);
|
|
4823
|
+
if (request.toolChoice) body.tool_choice = request.toolChoice;
|
|
4824
|
+
}
|
|
4825
|
+
const data = await this.fetchJson("/responses", body, request.signal);
|
|
4826
|
+
const functionCalls = (_nullishCoalesce(data.output, () => ( []))).filter(
|
|
4827
|
+
(item) => item.type === "function_call" && typeof item.name === "string" && typeof item.arguments === "string"
|
|
4828
|
+
).map((item) => ({
|
|
4829
|
+
id: _nullishCoalesce(_nullishCoalesce(item.call_id, () => ( item.id)), () => ( `call_${Date.now()}`)),
|
|
4830
|
+
type: "function",
|
|
4831
|
+
function: {
|
|
4832
|
+
name: item.name,
|
|
4833
|
+
arguments: item.arguments
|
|
4834
|
+
}
|
|
4835
|
+
}));
|
|
4836
|
+
return {
|
|
4837
|
+
id: _nullishCoalesce(data.id, () => ( `bedrock-responses-${Date.now()}`)),
|
|
4838
|
+
created: _nullishCoalesce(data.created_at, () => ( Math.floor(Date.now() / 1e3))),
|
|
4839
|
+
content: _nullishCoalesce(data.output_text, () => ( "")),
|
|
4840
|
+
...functionCalls.length > 0 && { toolCalls: functionCalls },
|
|
4841
|
+
finishReason: functionCalls.length > 0 ? "tool_calls" : "stop",
|
|
4842
|
+
usage: _chunkGO6C2RARcjs.normalizeLLMUsage.call(void 0, data.usage),
|
|
4843
|
+
raw: data
|
|
4844
|
+
};
|
|
4845
|
+
}
|
|
4846
|
+
async fetchJson(path, body, signal) {
|
|
4847
|
+
let response;
|
|
4848
|
+
try {
|
|
4849
|
+
response = await fetch(`${this.endpoint}${path}`, {
|
|
4850
|
+
method: "POST",
|
|
4851
|
+
headers: {
|
|
4852
|
+
"Content-Type": "application/json",
|
|
4853
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
4854
|
+
},
|
|
4855
|
+
body: JSON.stringify(body),
|
|
4856
|
+
signal
|
|
4857
|
+
});
|
|
4858
|
+
} catch (error) {
|
|
4859
|
+
const err = error;
|
|
4860
|
+
if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess', _271 => _271.aborted])) {
|
|
4861
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)("Request cancelled.", "cancelled", 0, false);
|
|
4862
|
+
}
|
|
4863
|
+
if (err.name === "AbortError") {
|
|
4864
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)("The Bedrock request timed out.", "timeout", 0, true);
|
|
4865
|
+
}
|
|
4866
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4867
|
+
"Unable to connect to the Bedrock OpenAI-compatible endpoint. Check region, endpoint, private networking, and proxy settings.",
|
|
4868
|
+
"network_error",
|
|
4869
|
+
0,
|
|
4870
|
+
true,
|
|
4871
|
+
void 0,
|
|
4872
|
+
err.message
|
|
4873
|
+
);
|
|
4874
|
+
}
|
|
4875
|
+
if (!response.ok) {
|
|
4876
|
+
const errorBody = await readErrorBody(response);
|
|
4877
|
+
const classified = _chunk3OF56EMAcjs.classifyApiError.call(void 0, response.status, errorBody, response.headers);
|
|
4878
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4879
|
+
`AWS Bedrock request failed.
|
|
4880
|
+
${classified.message}`,
|
|
4881
|
+
classified.code,
|
|
4882
|
+
classified.httpStatus,
|
|
4883
|
+
classified.retryable,
|
|
4884
|
+
classified.retryAfterMs,
|
|
4885
|
+
classified.rawDetail
|
|
4886
|
+
);
|
|
4887
|
+
}
|
|
4888
|
+
try {
|
|
4889
|
+
return await response.json();
|
|
4890
|
+
} catch (error) {
|
|
4891
|
+
throw new (0, _chunk3OF56EMAcjs.ApiError)(
|
|
4892
|
+
"Malformed Bedrock response: response body was not valid JSON.",
|
|
4893
|
+
"invalid_request",
|
|
4894
|
+
response.status,
|
|
4895
|
+
false,
|
|
4896
|
+
void 0,
|
|
4897
|
+
error instanceof Error ? error.message : String(error)
|
|
4898
|
+
);
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
};
|
|
4902
|
+
|
|
4903
|
+
// src/providers/CustomOpenAICompatibleProvider.ts
|
|
4904
|
+
var CustomOpenAICompatibleProvider = class {
|
|
4905
|
+
|
|
4906
|
+
|
|
4907
|
+
|
|
4908
|
+
|
|
4909
|
+
|
|
4910
|
+
|
|
4911
|
+
constructor(config, networkSettings) {
|
|
4912
|
+
this.providerName = _chunkEK34UZPBcjs.toCustomProviderName.call(void 0, config.id);
|
|
4913
|
+
this.model = config.model;
|
|
4914
|
+
this.models = _nullishCoalesce(_optionalChain([config, 'access', _272 => _272.models, 'optionalAccess', _273 => _273.map, 'call', _274 => _274((entry) => entry.id)]), () => ( [config.model]));
|
|
4915
|
+
this.apiKeyRequired = config.apiKeyRequired !== false;
|
|
4916
|
+
this.apiKey = config.apiKey;
|
|
4917
|
+
this.client = new LLMGatewayClient(
|
|
4918
|
+
{
|
|
4919
|
+
apiKey: _nullishCoalesce(config.apiKey, () => ( "")),
|
|
4920
|
+
baseUrl: config.baseUrl,
|
|
4921
|
+
model: config.model
|
|
4922
|
+
},
|
|
4923
|
+
networkSettings,
|
|
4924
|
+
{
|
|
4925
|
+
serviceName: config.displayName,
|
|
4926
|
+
credentialName: `${config.displayName} API key`,
|
|
4927
|
+
accountName: `${config.displayName} account`
|
|
4928
|
+
}
|
|
4929
|
+
);
|
|
4930
|
+
}
|
|
4931
|
+
getName() {
|
|
4932
|
+
return this.providerName;
|
|
4933
|
+
}
|
|
4934
|
+
getCapabilities() {
|
|
4935
|
+
return { nativeToolCalling: true };
|
|
4936
|
+
}
|
|
4937
|
+
setModel(model) {
|
|
4938
|
+
this.model = model;
|
|
4939
|
+
this.client.setDefaultModel(model);
|
|
4940
|
+
}
|
|
4941
|
+
async listModels() {
|
|
4942
|
+
return this.models;
|
|
4943
|
+
}
|
|
4944
|
+
async isAvailable() {
|
|
4945
|
+
return !this.apiKeyRequired || Boolean(this.apiKey);
|
|
4946
|
+
}
|
|
4947
|
+
async complete(request) {
|
|
4948
|
+
return this.client.complete(request);
|
|
4949
|
+
}
|
|
4950
|
+
};
|
|
4951
|
+
|
|
4135
4952
|
// src/providers/ProviderFactory.ts
|
|
4136
4953
|
var ProviderNotConfiguredError = class extends Error {
|
|
4137
4954
|
constructor(providerName) {
|
|
@@ -4169,6 +4986,16 @@ var ProviderFactory = class {
|
|
|
4169
4986
|
*/
|
|
4170
4987
|
static create(config) {
|
|
4171
4988
|
const providerName = config.provider || "openrouter";
|
|
4989
|
+
if (_chunkEK34UZPBcjs.isCustomProviderName.call(void 0, providerName)) {
|
|
4990
|
+
const customProvider = _chunkEK34UZPBcjs.getCustomProviderConfig.call(void 0, config, providerName);
|
|
4991
|
+
if (!customProvider || customProvider.apiFormat !== "openai-compatible") {
|
|
4992
|
+
return new UnconfiguredProvider(providerName);
|
|
4993
|
+
}
|
|
4994
|
+
return new CustomOpenAICompatibleProvider(customProvider, config.network);
|
|
4995
|
+
}
|
|
4996
|
+
if (providerName === "bedrock" && !_chunk7TO3PDMVcjs.isAwsBedrockProviderEnabled.call(void 0, config)) {
|
|
4997
|
+
return new UnconfiguredProvider("bedrock");
|
|
4998
|
+
}
|
|
4172
4999
|
switch (providerName) {
|
|
4173
5000
|
case "ollama":
|
|
4174
5001
|
if (!config.ollama) {
|
|
@@ -4205,6 +5032,11 @@ var ProviderFactory = class {
|
|
|
4205
5032
|
return new UnconfiguredProvider("zai");
|
|
4206
5033
|
}
|
|
4207
5034
|
return new ZaiProvider(config.zai, config.network);
|
|
5035
|
+
case "sakana":
|
|
5036
|
+
if (!config.sakana) {
|
|
5037
|
+
return new UnconfiguredProvider("sakana");
|
|
5038
|
+
}
|
|
5039
|
+
return new SakanaProvider(config.sakana, config.network);
|
|
4208
5040
|
case "vertexai":
|
|
4209
5041
|
if (!config.vertexai) {
|
|
4210
5042
|
return new UnconfiguredProvider("vertexai");
|
|
@@ -4224,12 +5056,17 @@ var ProviderFactory = class {
|
|
|
4224
5056
|
if (!config.nvidia) {
|
|
4225
5057
|
return new UnconfiguredProvider("nvidia");
|
|
4226
5058
|
}
|
|
4227
|
-
return new (0,
|
|
5059
|
+
return new (0, _chunkGO6C2RARcjs.NVIDIAProvider)(config.nvidia, config.network);
|
|
4228
5060
|
case "deepseek":
|
|
4229
5061
|
if (!config.deepseek) {
|
|
4230
5062
|
return new UnconfiguredProvider("deepseek");
|
|
4231
5063
|
}
|
|
4232
5064
|
return new DeepSeekProvider(config.deepseek, config.network);
|
|
5065
|
+
case "bedrock":
|
|
5066
|
+
if (!config.bedrock) {
|
|
5067
|
+
return new UnconfiguredProvider("bedrock");
|
|
5068
|
+
}
|
|
5069
|
+
return new BedrockProvider(config.bedrock);
|
|
4233
5070
|
case "openrouter":
|
|
4234
5071
|
default:
|
|
4235
5072
|
if (!config.openrouter) {
|
|
@@ -4242,11 +5079,16 @@ var ProviderFactory = class {
|
|
|
4242
5079
|
* Get all available provider names.
|
|
4243
5080
|
* MLX is only included on Apple Silicon (macOS + arm64).
|
|
4244
5081
|
*/
|
|
4245
|
-
static getProviderNames() {
|
|
4246
|
-
const providers = ["zai", "xai", "vertexai", "nvidia", "openrouter", "openai", "ollama", "llmgateway", "llamacpp", "deepseek", "cerebras", "azure"];
|
|
5082
|
+
static getProviderNames(config) {
|
|
5083
|
+
const providers = ["zai", "xai", "vertexai", "sakana", "nvidia", "openrouter", "openai", "ollama", "llmgateway", "llamacpp", "deepseek", "cerebras", "azure"];
|
|
5084
|
+
if (_chunk7TO3PDMVcjs.isAwsBedrockProviderEnabled.call(void 0, config)) {
|
|
5085
|
+
providers.splice(providers.indexOf("azure"), 0, "bedrock");
|
|
5086
|
+
}
|
|
4247
5087
|
if (isMLXSupported()) {
|
|
4248
5088
|
providers.push("mlx");
|
|
4249
5089
|
}
|
|
5090
|
+
const customProviders = Object.values(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _275 => _275.customProviders]), () => ( {}))).filter((entry) => entry.disabled !== true).sort((a, b) => a.displayName.localeCompare(b.displayName)).map((entry) => _chunkEK34UZPBcjs.toCustomProviderName.call(void 0, entry.id));
|
|
5091
|
+
providers.push(...customProviders);
|
|
4250
5092
|
return providers;
|
|
4251
5093
|
}
|
|
4252
5094
|
/**
|
|
@@ -4254,8 +5096,14 @@ var ProviderFactory = class {
|
|
|
4254
5096
|
* Note: This checks if the name is a valid provider type, not if it's available on this platform.
|
|
4255
5097
|
* MLX is always a valid provider name, but may not be available on non-Apple Silicon systems.
|
|
4256
5098
|
*/
|
|
4257
|
-
static isValidProvider(name) {
|
|
4258
|
-
|
|
5099
|
+
static isValidProvider(name, config) {
|
|
5100
|
+
if (_chunkEK34UZPBcjs.isCustomProviderName.call(void 0, name)) {
|
|
5101
|
+
return _chunkEK34UZPBcjs.getCustomProviderConfig.call(void 0, config, name) !== void 0;
|
|
5102
|
+
}
|
|
5103
|
+
if (name === "bedrock" && !_chunk7TO3PDMVcjs.isAwsBedrockProviderEnabled.call(void 0, config)) {
|
|
5104
|
+
return false;
|
|
5105
|
+
}
|
|
5106
|
+
const allProviders = ["openrouter", "ollama", "openai", "llamacpp", "mlx", "llmgateway", "azure", "zai", "sakana", "vertexai", "xai", "cerebras", "nvidia", "deepseek", "bedrock"];
|
|
4259
5107
|
return allProviders.includes(name);
|
|
4260
5108
|
}
|
|
4261
5109
|
};
|
|
@@ -4279,7 +5127,14 @@ var ProviderFactory = class {
|
|
|
4279
5127
|
|
|
4280
5128
|
|
|
4281
5129
|
|
|
4282
|
-
|
|
5130
|
+
|
|
5131
|
+
|
|
5132
|
+
|
|
5133
|
+
|
|
5134
|
+
|
|
5135
|
+
|
|
5136
|
+
|
|
5137
|
+
exports.isChatGPTAuthExpired = isChatGPTAuthExpired; exports.authenticateOpenAIChatGPT = authenticateOpenAIChatGPT; exports.OPENAI_MODELS = OPENAI_MODELS; exports.getOpenRouterModelContextWindow = getOpenRouterModelContextWindow; exports.modelSupportsImages = modelSupportsImages; exports.ZAI_DEFAULT_BASE_URL = ZAI_DEFAULT_BASE_URL; exports.ZAI_MODELS = ZAI_MODELS; exports.SAKANA_DEFAULT_BASE_URL = SAKANA_DEFAULT_BASE_URL; exports.SAKANA_MODELS = SAKANA_MODELS; exports.isGcloudInstalled = isGcloudInstalled; exports.getGcloudProject = getGcloudProject; exports.getGcloudAccessToken = getGcloudAccessToken; exports.getGcloudAccount = getGcloudAccount; exports.VERTEX_AI_CODING_MODELS = VERTEX_AI_CODING_MODELS; exports.CEREBRAS_DEFAULT_BASE_URL = CEREBRAS_DEFAULT_BASE_URL; exports.CEREBRAS_MODELS = CEREBRAS_MODELS; exports.DEEPSEEK_DEFAULT_BASE_URL = DEEPSEEK_DEFAULT_BASE_URL; exports.DEEPSEEK_MODELS = DEEPSEEK_MODELS; exports.BEDROCK_DEFAULT_REGION = BEDROCK_DEFAULT_REGION; exports.BEDROCK_DEFAULT_MODEL = BEDROCK_DEFAULT_MODEL; exports.BEDROCK_MODELS = BEDROCK_MODELS; exports.resolveBedrockEndpoint = resolveBedrockEndpoint; exports.resolveBedrockAuthMode = resolveBedrockAuthMode; exports.ProviderNotConfiguredError = ProviderNotConfiguredError; exports.ProviderFactory = ProviderFactory;
|
|
4283
5138
|
/**
|
|
4284
5139
|
* @license
|
|
4285
5140
|
* Copyright 2025 Autohand AI LLC
|
|
@@ -4289,3 +5144,8 @@ exports.isChatGPTAuthExpired = isChatGPTAuthExpired; exports.authenticateOpenAIC
|
|
|
4289
5144
|
* Google Cloud CLI authentication utilities
|
|
4290
5145
|
* @license Apache-2.0
|
|
4291
5146
|
*/
|
|
5147
|
+
/**
|
|
5148
|
+
* @license
|
|
5149
|
+
* Copyright 2026 Autohand AI LLC
|
|
5150
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5151
|
+
*/
|