@mastra/server 0.0.0-toolOptionTypes-20250917085558 → 0.0.0-top-level-fix-20251211111608
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/CHANGELOG.md +1684 -3
- package/README.md +2 -2
- package/dist/{chunk-PPYGWINI.cjs → chunk-2PLXW4ZX.cjs} +74 -74
- package/dist/{chunk-PPYGWINI.cjs.map → chunk-2PLXW4ZX.cjs.map} +1 -1
- package/dist/chunk-3SFLFUKY.js +116 -0
- package/dist/chunk-3SFLFUKY.js.map +1 -0
- package/dist/chunk-3XI22UQR.cjs +148 -0
- package/dist/chunk-3XI22UQR.cjs.map +1 -0
- package/dist/chunk-4W2SM6CG.js +294 -0
- package/dist/chunk-4W2SM6CG.js.map +1 -0
- package/dist/chunk-5W4RPVTK.cjs +49 -0
- package/dist/chunk-5W4RPVTK.cjs.map +1 -0
- package/dist/{chunk-7NADHFD2.cjs → chunk-64ITUOXI.cjs} +2 -2
- package/dist/chunk-64ITUOXI.cjs.map +1 -0
- package/dist/{chunk-MMROOK5J.js → chunk-6QWQZI4Q.js} +2 -2
- package/dist/{chunk-7NADHFD2.cjs.map → chunk-6QWQZI4Q.js.map} +1 -1
- package/dist/{chunk-3THIIWWW.cjs → chunk-7O3KPUJ4.cjs} +230 -34
- package/dist/chunk-7O3KPUJ4.cjs.map +1 -0
- package/dist/chunk-C3UIIRAT.cjs +920 -0
- package/dist/chunk-C3UIIRAT.cjs.map +1 -0
- package/dist/chunk-CDRVS35Y.js +23226 -0
- package/dist/chunk-CDRVS35Y.js.map +1 -0
- package/dist/chunk-DRUNNM4C.js +328 -0
- package/dist/chunk-DRUNNM4C.js.map +1 -0
- package/dist/chunk-EBWTF2DH.cjs +810 -0
- package/dist/chunk-EBWTF2DH.cjs.map +1 -0
- package/dist/chunk-ER3QM7DD.js +46 -0
- package/dist/chunk-ER3QM7DD.js.map +1 -0
- package/dist/chunk-FPCGLPLJ.cjs +297 -0
- package/dist/chunk-FPCGLPLJ.cjs.map +1 -0
- package/dist/chunk-FYY54HZC.js +310 -0
- package/dist/chunk-FYY54HZC.js.map +1 -0
- package/dist/chunk-GFF2I6UD.js +354 -0
- package/dist/chunk-GFF2I6UD.js.map +1 -0
- package/dist/chunk-GN2LFMET.cjs +23268 -0
- package/dist/chunk-GN2LFMET.cjs.map +1 -0
- package/dist/chunk-H2RMXG2Q.cjs +167 -0
- package/dist/chunk-H2RMXG2Q.cjs.map +1 -0
- package/dist/chunk-HAJOEDNB.js +274 -0
- package/dist/chunk-HAJOEDNB.js.map +1 -0
- package/dist/chunk-HT4LP3BO.js +75 -0
- package/dist/chunk-HT4LP3BO.js.map +1 -0
- package/dist/chunk-I6LR6CPC.cjs +125 -0
- package/dist/chunk-I6LR6CPC.cjs.map +1 -0
- package/dist/chunk-IEYXQTUW.cjs +284 -0
- package/dist/chunk-IEYXQTUW.cjs.map +1 -0
- package/dist/chunk-K3ELPJS3.js +1063 -0
- package/dist/chunk-K3ELPJS3.js.map +1 -0
- package/dist/{chunk-5QUKZCEF.js → chunk-KEXR53KI.js} +224 -34
- package/dist/chunk-KEXR53KI.js.map +1 -0
- package/dist/{chunk-SIGXR3JT.cjs → chunk-LPM6BBAX.cjs} +5 -5
- package/dist/{chunk-SIGXR3JT.cjs.map → chunk-LPM6BBAX.cjs.map} +1 -1
- package/dist/chunk-MCYD5LW7.cjs +90 -0
- package/dist/chunk-MCYD5LW7.cjs.map +1 -0
- package/dist/chunk-MQLS6Z7A.js +891 -0
- package/dist/chunk-MQLS6Z7A.js.map +1 -0
- package/dist/{chunk-EMMSS5I5.cjs → chunk-O7I5CWRX.cjs} +10 -3
- package/dist/{chunk-EMMSS5I5.cjs.map → chunk-O7I5CWRX.cjs.map} +1 -1
- package/dist/{chunk-G3PMV62Z.js → chunk-PR4QN5HX.js} +10 -4
- package/dist/{chunk-G3PMV62Z.js.map → chunk-PR4QN5HX.js.map} +1 -1
- package/dist/chunk-PUFCKXFW.cjs +312 -0
- package/dist/chunk-PUFCKXFW.cjs.map +1 -0
- package/dist/{chunk-NG5IVLEZ.js → chunk-RQK4FQUD.js} +3 -3
- package/dist/{chunk-NG5IVLEZ.js.map → chunk-RQK4FQUD.js.map} +1 -1
- package/dist/chunk-S3TIWWQL.cjs +322 -0
- package/dist/chunk-S3TIWWQL.cjs.map +1 -0
- package/dist/chunk-SXVANU23.js +164 -0
- package/dist/chunk-SXVANU23.js.map +1 -0
- package/dist/chunk-TGIVGCBJ.cjs +211 -0
- package/dist/chunk-TGIVGCBJ.cjs.map +1 -0
- package/dist/chunk-TYZ6ZISQ.cjs +368 -0
- package/dist/chunk-TYZ6ZISQ.cjs.map +1 -0
- package/dist/{chunk-CY4TP3FK.js → chunk-UXGQZUYZ.js} +3 -3
- package/dist/{chunk-CY4TP3FK.js.map → chunk-UXGQZUYZ.js.map} +1 -1
- package/dist/chunk-UY2D2LVC.cjs +205 -0
- package/dist/chunk-UY2D2LVC.cjs.map +1 -0
- package/dist/chunk-V272B7RM.cjs +255 -0
- package/dist/chunk-V272B7RM.cjs.map +1 -0
- package/dist/{chunk-RE4RPXT2.cjs → chunk-V5WWQN7P.cjs} +4 -4
- package/dist/{chunk-RE4RPXT2.cjs.map → chunk-V5WWQN7P.cjs.map} +1 -1
- package/dist/chunk-VIDXWHJQ.js +204 -0
- package/dist/chunk-VIDXWHJQ.js.map +1 -0
- package/dist/chunk-W36USBM5.js +196 -0
- package/dist/chunk-W36USBM5.js.map +1 -0
- package/dist/chunk-WBLT2HL3.js +144 -0
- package/dist/chunk-WBLT2HL3.js.map +1 -0
- package/dist/chunk-WE4USCF3.js +226 -0
- package/dist/chunk-WE4USCF3.js.map +1 -0
- package/dist/chunk-X43DWDXB.cjs +346 -0
- package/dist/chunk-X43DWDXB.cjs.map +1 -0
- package/dist/chunk-X4QMPCTP.cjs +259 -0
- package/dist/chunk-X4QMPCTP.cjs.map +1 -0
- package/dist/chunk-XQPJ63ZD.cjs +48 -0
- package/dist/chunk-XQPJ63ZD.cjs.map +1 -0
- package/dist/chunk-XW2HXQDO.js +302 -0
- package/dist/chunk-XW2HXQDO.js.map +1 -0
- package/dist/chunk-XWGAT2DA.js +44 -0
- package/dist/chunk-XWGAT2DA.js.map +1 -0
- package/dist/chunk-YHNJY33C.js +786 -0
- package/dist/chunk-YHNJY33C.js.map +1 -0
- package/dist/chunk-YP34EWWK.js +253 -0
- package/dist/chunk-YP34EWWK.js.map +1 -0
- package/dist/chunk-ZN5R6OZB.cjs +1107 -0
- package/dist/chunk-ZN5R6OZB.cjs.map +1 -0
- package/dist/{chunk-6GMFZ5LK.js → chunk-ZULZ2752.js} +3 -3
- package/dist/{chunk-6GMFZ5LK.js.map → chunk-ZULZ2752.js.map} +1 -1
- package/dist/{chunk-IGFMAZZ5.cjs → dist-4MVGNSRL.cjs} +20 -20
- package/dist/dist-4MVGNSRL.cjs.map +1 -0
- package/dist/{chunk-TVSIG4JE.cjs → dist-FZYCV3VB.cjs} +26 -26
- package/dist/dist-FZYCV3VB.cjs.map +1 -0
- package/dist/{chunk-5DP5XZH6.cjs → dist-G2BYZJOC.cjs} +28 -28
- package/dist/dist-G2BYZJOC.cjs.map +1 -0
- package/dist/dist-P4MXBQ3U.cjs +16 -0
- package/dist/{dist-3A5DXB37.cjs.map → dist-P4MXBQ3U.cjs.map} +1 -1
- package/dist/{chunk-FQNT7PI4.js → dist-PQZUVLPC.js} +3 -3
- package/dist/dist-PQZUVLPC.js.map +1 -0
- package/dist/{chunk-P7CIEIJ3.js → dist-R7WYX6LC.js} +3 -3
- package/dist/dist-R7WYX6LC.js.map +1 -0
- package/dist/{chunk-HJQKWRKQ.cjs → dist-RFMYFILX.cjs} +30 -30
- package/dist/dist-RFMYFILX.cjs.map +1 -0
- package/dist/{chunk-LYPU75T6.js → dist-X7XR3M3Z.js} +3 -3
- package/dist/dist-X7XR3M3Z.js.map +1 -0
- package/dist/{chunk-66YYHFGF.js → dist-XVBSOGFK.js} +3 -3
- package/dist/dist-XVBSOGFK.js.map +1 -0
- package/dist/dist-YREX2TJT.js +3 -0
- package/dist/{dist-26HWEQY6.js.map → dist-YREX2TJT.js.map} +1 -1
- package/dist/server/auth/defaults.d.ts +3 -0
- package/dist/server/auth/defaults.d.ts.map +1 -0
- package/dist/server/auth/helpers.d.ts +14 -0
- package/dist/server/auth/helpers.d.ts.map +1 -0
- package/dist/server/auth/index.cjs +137 -0
- package/dist/server/auth/index.cjs.map +1 -0
- package/dist/server/auth/index.d.ts +3 -0
- package/dist/server/auth/index.d.ts.map +1 -0
- package/dist/server/auth/index.js +127 -0
- package/dist/server/auth/index.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +15 -7
- package/dist/server/handlers/a2a.d.ts +492 -10
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +43 -31
- package/dist/server/handlers/agent-builder.d.ts +599 -77
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +61 -29
- package/dist/server/handlers/agents.d.ts +3329 -129
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/logs.cjs +7 -7
- package/dist/server/handlers/logs.d.ts +135 -27
- package/dist/server/handlers/logs.d.ts.map +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/mcp.cjs +40 -0
- package/dist/server/handlers/mcp.cjs.map +1 -0
- package/dist/server/handlers/mcp.d.ts +110 -0
- package/dist/server/handlers/mcp.d.ts.map +1 -0
- package/dist/server/handlers/mcp.js +3 -0
- package/dist/server/handlers/mcp.js.map +1 -0
- package/dist/server/handlers/memory.cjs +63 -31
- package/dist/server/handlers/memory.d.ts +934 -103
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +29 -5
- package/dist/server/handlers/observability.d.ts +142 -9
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/scores.cjs +13 -13
- package/dist/server/handlers/scores.d.ts +112 -40
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +28 -0
- package/dist/server/handlers/stored-agents.cjs.map +1 -0
- package/dist/server/handlers/stored-agents.d.ts +289 -0
- package/dist/server/handlers/stored-agents.d.ts.map +1 -0
- package/dist/server/handlers/stored-agents.js +3 -0
- package/dist/server/handlers/stored-agents.js.map +1 -0
- package/dist/server/handlers/test-utils.cjs +15 -0
- package/dist/server/handlers/test-utils.cjs.map +1 -0
- package/dist/server/handlers/test-utils.d.ts +6 -0
- package/dist/server/handlers/test-utils.d.ts.map +1 -0
- package/dist/server/handlers/test-utils.js +13 -0
- package/dist/server/handlers/test-utils.js.map +1 -0
- package/dist/server/handlers/tools.cjs +11 -11
- package/dist/server/handlers/tools.d.ts +69 -23
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +11 -3
- package/dist/server/handlers/utils.d.ts +5 -0
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +31 -7
- package/dist/server/handlers/vector.d.ts +93 -9
- package/dist/server/handlers/vector.d.ts.map +1 -1
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +21 -9
- package/dist/server/handlers/voice.d.ts +81 -40
- package/dist/server/handlers/voice.d.ts.map +1 -1
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +75 -31
- package/dist/server/handlers/workflows.d.ts +925 -60
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +26 -36
- package/dist/server/handlers.d.ts +1 -3
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +12 -14
- package/dist/server/http-exception.d.ts +0 -5
- package/dist/server/http-exception.d.ts.map +1 -1
- package/dist/server/schemas/a2a.d.ts +786 -0
- package/dist/server/schemas/a2a.d.ts.map +1 -0
- package/dist/server/schemas/agent-builder.d.ts +204 -0
- package/dist/server/schemas/agent-builder.d.ts.map +1 -0
- package/dist/server/schemas/agents.d.ts +1375 -0
- package/dist/server/schemas/agents.d.ts.map +1 -0
- package/dist/server/schemas/common.d.ts +179 -0
- package/dist/server/schemas/common.d.ts.map +1 -0
- package/dist/server/schemas/logs.d.ts +124 -0
- package/dist/server/schemas/logs.d.ts.map +1 -0
- package/dist/server/schemas/mcp.d.ts +299 -0
- package/dist/server/schemas/mcp.d.ts.map +1 -0
- package/dist/server/schemas/memory.d.ts +998 -0
- package/dist/server/schemas/memory.d.ts.map +1 -0
- package/dist/server/schemas/observability.d.ts +402 -0
- package/dist/server/schemas/observability.d.ts.map +1 -0
- package/dist/server/schemas/scores.d.ts +259 -0
- package/dist/server/schemas/scores.d.ts.map +1 -0
- package/dist/server/schemas/stored-agents.d.ts +792 -0
- package/dist/server/schemas/stored-agents.d.ts.map +1 -0
- package/dist/server/schemas/vectors.d.ts +107 -0
- package/dist/server/schemas/vectors.d.ts.map +1 -0
- package/dist/server/schemas/workflows.d.ts +608 -0
- package/dist/server/schemas/workflows.d.ts.map +1 -0
- package/dist/server/server-adapter/index.cjs +481 -0
- package/dist/server/server-adapter/index.cjs.map +1 -0
- package/dist/server/server-adapter/index.d.ts +91 -0
- package/dist/server/server-adapter/index.d.ts.map +1 -0
- package/dist/server/server-adapter/index.js +466 -0
- package/dist/server/server-adapter/index.js.map +1 -0
- package/dist/server/server-adapter/openapi-utils.d.ts +59 -0
- package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -0
- package/dist/server/server-adapter/redact.d.ts +26 -0
- package/dist/server/server-adapter/redact.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/a2a.d.ts +3 -0
- package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/agent-builder.d.ts +3 -0
- package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/agents.d.ts +3 -0
- package/dist/server/server-adapter/routes/agents.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/index.d.ts +50 -0
- package/dist/server/server-adapter/routes/index.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/legacy.d.ts +7 -0
- package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/logs.d.ts +3 -0
- package/dist/server/server-adapter/routes/logs.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/mcp.d.ts +9 -0
- package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/memory.d.ts +3 -0
- package/dist/server/server-adapter/routes/memory.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/observability.d.ts +3 -0
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/route-builder.d.ts +52 -0
- package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/scorers.d.ts +3 -0
- package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/stored-agents.d.ts +8 -0
- package/dist/server/server-adapter/routes/stored-agents.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/stream-types.d.ts +10 -0
- package/dist/server/server-adapter/routes/stream-types.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/tools.d.ts +3 -0
- package/dist/server/server-adapter/routes/tools.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/vectors.d.ts +3 -0
- package/dist/server/server-adapter/routes/vectors.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/workflows.d.ts +3 -0
- package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -0
- package/dist/server/utils.d.ts +5 -2
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/token-GVZ7HRD7.js +62 -0
- package/dist/token-GVZ7HRD7.js.map +1 -0
- package/dist/token-JGA3ZWAN.js +61 -0
- package/dist/token-JGA3ZWAN.js.map +1 -0
- package/dist/token-VFONFWVS.cjs +64 -0
- package/dist/token-VFONFWVS.cjs.map +1 -0
- package/dist/token-ZOD6YIQ3.cjs +63 -0
- package/dist/token-ZOD6YIQ3.cjs.map +1 -0
- package/dist/token-util-7R2ZFIXO.js +7 -0
- package/dist/token-util-7R2ZFIXO.js.map +1 -0
- package/dist/token-util-BLJZJDBZ.cjs +9 -0
- package/dist/token-util-BLJZJDBZ.cjs.map +1 -0
- package/dist/token-util-VGZUWSNR.cjs +9 -0
- package/dist/token-util-VGZUWSNR.cjs.map +1 -0
- package/dist/token-util-VKTPZLSE.js +7 -0
- package/dist/token-util-VKTPZLSE.js.map +1 -0
- package/package.json +39 -19
- package/dist/chunk-3THIIWWW.cjs.map +0 -1
- package/dist/chunk-4QCXUEAT.js +0 -25
- package/dist/chunk-4QCXUEAT.js.map +0 -1
- package/dist/chunk-4RRMWXQ2.js +0 -3522
- package/dist/chunk-4RRMWXQ2.js.map +0 -1
- package/dist/chunk-5DP5XZH6.cjs.map +0 -1
- package/dist/chunk-5QUKZCEF.js.map +0 -1
- package/dist/chunk-5VTTUNVK.cjs +0 -540
- package/dist/chunk-5VTTUNVK.cjs.map +0 -1
- package/dist/chunk-66YYHFGF.js.map +0 -1
- package/dist/chunk-6LUKYSWE.cjs +0 -610
- package/dist/chunk-6LUKYSWE.cjs.map +0 -1
- package/dist/chunk-743UIDHI.cjs +0 -2013
- package/dist/chunk-743UIDHI.cjs.map +0 -1
- package/dist/chunk-7QEJ5QG5.js +0 -151
- package/dist/chunk-7QEJ5QG5.js.map +0 -1
- package/dist/chunk-A3AL7EWJ.js +0 -83
- package/dist/chunk-A3AL7EWJ.js.map +0 -1
- package/dist/chunk-AK2FXLLB.cjs +0 -849
- package/dist/chunk-AK2FXLLB.cjs.map +0 -1
- package/dist/chunk-B2V3PUB7.js +0 -591
- package/dist/chunk-B2V3PUB7.js.map +0 -1
- package/dist/chunk-EMNGA4R4.js +0 -845
- package/dist/chunk-EMNGA4R4.js.map +0 -1
- package/dist/chunk-FALVL2VV.cjs +0 -3525
- package/dist/chunk-FALVL2VV.cjs.map +0 -1
- package/dist/chunk-FQNT7PI4.js.map +0 -1
- package/dist/chunk-G4PUALCE.cjs +0 -28
- package/dist/chunk-G4PUALCE.cjs.map +0 -1
- package/dist/chunk-GUI3CROV.cjs +0 -159
- package/dist/chunk-GUI3CROV.cjs.map +0 -1
- package/dist/chunk-HJQKWRKQ.cjs.map +0 -1
- package/dist/chunk-HVBBFCDH.cjs +0 -2321
- package/dist/chunk-HVBBFCDH.cjs.map +0 -1
- package/dist/chunk-HZJRQ5L3.cjs +0 -1411
- package/dist/chunk-HZJRQ5L3.cjs.map +0 -1
- package/dist/chunk-IGFMAZZ5.cjs.map +0 -1
- package/dist/chunk-IOQGI4ML.js +0 -931
- package/dist/chunk-IOQGI4ML.js.map +0 -1
- package/dist/chunk-IQ4NTMIJ.cjs +0 -15753
- package/dist/chunk-IQ4NTMIJ.cjs.map +0 -1
- package/dist/chunk-IY34NOLA.cjs +0 -150
- package/dist/chunk-IY34NOLA.cjs.map +0 -1
- package/dist/chunk-J7BPKKOG.cjs +0 -163
- package/dist/chunk-J7BPKKOG.cjs.map +0 -1
- package/dist/chunk-JRDEOHAJ.js +0 -122
- package/dist/chunk-JRDEOHAJ.js.map +0 -1
- package/dist/chunk-KNGXRN26.cjs +0 -335
- package/dist/chunk-KNGXRN26.cjs.map +0 -1
- package/dist/chunk-KV6VHX4V.js +0 -160
- package/dist/chunk-KV6VHX4V.js.map +0 -1
- package/dist/chunk-L265APUD.cjs +0 -69
- package/dist/chunk-L265APUD.cjs.map +0 -1
- package/dist/chunk-LYPU75T6.js.map +0 -1
- package/dist/chunk-MMROOK5J.js.map +0 -1
- package/dist/chunk-N7F33WAD.js +0 -2290
- package/dist/chunk-N7F33WAD.js.map +0 -1
- package/dist/chunk-NLWACBE7.cjs +0 -128
- package/dist/chunk-NLWACBE7.cjs.map +0 -1
- package/dist/chunk-OGW6HHVI.js +0 -1408
- package/dist/chunk-OGW6HHVI.js.map +0 -1
- package/dist/chunk-OZLRIVC4.cjs +0 -588
- package/dist/chunk-OZLRIVC4.cjs.map +0 -1
- package/dist/chunk-P7CIEIJ3.js.map +0 -1
- package/dist/chunk-P7RBMCBE.cjs +0 -934
- package/dist/chunk-P7RBMCBE.cjs.map +0 -1
- package/dist/chunk-PWTXZZTR.cjs +0 -165
- package/dist/chunk-PWTXZZTR.cjs.map +0 -1
- package/dist/chunk-R7NOGUZG.js +0 -65
- package/dist/chunk-R7NOGUZG.js.map +0 -1
- package/dist/chunk-RCHEPTZZ.js +0 -2006
- package/dist/chunk-RCHEPTZZ.js.map +0 -1
- package/dist/chunk-SPLSYTYW.cjs +0 -88
- package/dist/chunk-SPLSYTYW.cjs.map +0 -1
- package/dist/chunk-SQY4T6EJ.js +0 -571
- package/dist/chunk-SQY4T6EJ.js.map +0 -1
- package/dist/chunk-SYRRSBGL.js +0 -156
- package/dist/chunk-SYRRSBGL.js.map +0 -1
- package/dist/chunk-T3TIA3O6.cjs +0 -131
- package/dist/chunk-T3TIA3O6.cjs.map +0 -1
- package/dist/chunk-TTHEEIZ3.js +0 -323
- package/dist/chunk-TTHEEIZ3.js.map +0 -1
- package/dist/chunk-TVSIG4JE.cjs.map +0 -1
- package/dist/chunk-U46VIX2V.js +0 -144
- package/dist/chunk-U46VIX2V.js.map +0 -1
- package/dist/chunk-WHN4VX55.js +0 -123
- package/dist/chunk-WHN4VX55.js.map +0 -1
- package/dist/chunk-YRMJCAH4.js +0 -15717
- package/dist/chunk-YRMJCAH4.js.map +0 -1
- package/dist/chunk-ZSAOHEZK.js +0 -524
- package/dist/chunk-ZSAOHEZK.js.map +0 -1
- package/dist/dist-26HWEQY6.js +0 -3
- package/dist/dist-3A5DXB37.cjs +0 -20
- package/dist/dist-3SJKQJGY.cjs +0 -16
- package/dist/dist-3SJKQJGY.cjs.map +0 -1
- package/dist/dist-4ZQSPE5K.js +0 -3
- package/dist/dist-4ZQSPE5K.js.map +0 -1
- package/dist/dist-5W5QNRTD.js +0 -3
- package/dist/dist-5W5QNRTD.js.map +0 -1
- package/dist/dist-653SRMPL.js +0 -3
- package/dist/dist-653SRMPL.js.map +0 -1
- package/dist/dist-6U6EFC5C.cjs +0 -16
- package/dist/dist-6U6EFC5C.cjs.map +0 -1
- package/dist/dist-7IHNNYMF.cjs +0 -16
- package/dist/dist-7IHNNYMF.cjs.map +0 -1
- package/dist/dist-B5IPRF6W.js +0 -3
- package/dist/dist-B5IPRF6W.js.map +0 -1
- package/dist/dist-EOMYFT4Y.cjs +0 -16
- package/dist/dist-EOMYFT4Y.cjs.map +0 -1
- package/dist/dist-EZZMMMNT.cjs +0 -16
- package/dist/dist-EZZMMMNT.cjs.map +0 -1
- package/dist/dist-F2ET4MNO.cjs +0 -16
- package/dist/dist-F2ET4MNO.cjs.map +0 -1
- package/dist/dist-H64VX6DE.js +0 -3
- package/dist/dist-H64VX6DE.js.map +0 -1
- package/dist/dist-HY7RMLJQ.cjs +0 -16
- package/dist/dist-HY7RMLJQ.cjs.map +0 -1
- package/dist/dist-M6S4P3FJ.js +0 -3
- package/dist/dist-M6S4P3FJ.js.map +0 -1
- package/dist/dist-NR7QSCQT.js +0 -3
- package/dist/dist-NR7QSCQT.js.map +0 -1
- package/dist/dist-QLFMCMCX.js +0 -3
- package/dist/dist-QLFMCMCX.js.map +0 -1
- package/dist/dist-UY46BFRP.js +0 -3
- package/dist/dist-UY46BFRP.js.map +0 -1
- package/dist/dist-WCQDRTIV.cjs +0 -16
- package/dist/dist-WCQDRTIV.cjs.map +0 -1
- package/dist/dist-WKYB3LTJ.cjs +0 -16
- package/dist/dist-WKYB3LTJ.cjs.map +0 -1
- package/dist/server/handlers/legacyWorkflows.cjs +0 -48
- package/dist/server/handlers/legacyWorkflows.cjs.map +0 -1
- package/dist/server/handlers/legacyWorkflows.d.ts +0 -59
- package/dist/server/handlers/legacyWorkflows.d.ts.map +0 -1
- package/dist/server/handlers/legacyWorkflows.js +0 -3
- package/dist/server/handlers/legacyWorkflows.js.map +0 -1
- package/dist/server/handlers/network.cjs +0 -24
- package/dist/server/handlers/network.cjs.map +0 -1
- package/dist/server/handlers/network.d.ts +0 -50
- package/dist/server/handlers/network.d.ts.map +0 -1
- package/dist/server/handlers/network.js +0 -3
- package/dist/server/handlers/network.js.map +0 -1
- package/dist/server/handlers/telemetry.cjs +0 -20
- package/dist/server/handlers/telemetry.cjs.map +0 -1
- package/dist/server/handlers/telemetry.d.ts +0 -33
- package/dist/server/handlers/telemetry.d.ts.map +0 -1
- package/dist/server/handlers/telemetry.js +0 -3
- package/dist/server/handlers/telemetry.js.map +0 -1
- package/dist/server/handlers/vNextNetwork.cjs +0 -220
- package/dist/server/handlers/vNextNetwork.cjs.map +0 -1
- package/dist/server/handlers/vNextNetwork.d.ts +0 -179
- package/dist/server/handlers/vNextNetwork.d.ts.map +0 -1
- package/dist/server/handlers/vNextNetwork.js +0 -213
- package/dist/server/handlers/vNextNetwork.js.map +0 -1
package/dist/chunk-HZJRQ5L3.cjs
DELETED
|
@@ -1,1411 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkHVBBFCDH_cjs = require('./chunk-HVBBFCDH.cjs');
|
|
4
|
-
var v4 = require('zod/v4');
|
|
5
|
-
|
|
6
|
-
var googleErrorDataSchema = v4.z.object({
|
|
7
|
-
error: v4.z.object({
|
|
8
|
-
code: v4.z.number().nullable(),
|
|
9
|
-
message: v4.z.string(),
|
|
10
|
-
status: v4.z.string()
|
|
11
|
-
})
|
|
12
|
-
});
|
|
13
|
-
var googleFailedResponseHandler = chunkHVBBFCDH_cjs.createJsonErrorResponseHandler({
|
|
14
|
-
errorSchema: googleErrorDataSchema,
|
|
15
|
-
errorToMessage: (data) => data.error.message
|
|
16
|
-
});
|
|
17
|
-
var googleGenerativeAIEmbeddingProviderOptions = v4.z.object({
|
|
18
|
-
/**
|
|
19
|
-
* Optional. Optional reduced dimension for the output embedding.
|
|
20
|
-
* If set, excessive values in the output embedding are truncated from the end.
|
|
21
|
-
*/
|
|
22
|
-
outputDimensionality: v4.z.number().optional(),
|
|
23
|
-
/**
|
|
24
|
-
* Optional. Specifies the task type for generating embeddings.
|
|
25
|
-
* Supported task types:
|
|
26
|
-
* - SEMANTIC_SIMILARITY: Optimized for text similarity.
|
|
27
|
-
* - CLASSIFICATION: Optimized for text classification.
|
|
28
|
-
* - CLUSTERING: Optimized for clustering texts based on similarity.
|
|
29
|
-
* - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
|
|
30
|
-
* - RETRIEVAL_QUERY: Optimized for query-based retrieval.
|
|
31
|
-
* - QUESTION_ANSWERING: Optimized for answering questions.
|
|
32
|
-
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
33
|
-
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
34
|
-
*/
|
|
35
|
-
taskType: v4.z.enum([
|
|
36
|
-
"SEMANTIC_SIMILARITY",
|
|
37
|
-
"CLASSIFICATION",
|
|
38
|
-
"CLUSTERING",
|
|
39
|
-
"RETRIEVAL_DOCUMENT",
|
|
40
|
-
"RETRIEVAL_QUERY",
|
|
41
|
-
"QUESTION_ANSWERING",
|
|
42
|
-
"FACT_VERIFICATION",
|
|
43
|
-
"CODE_RETRIEVAL_QUERY"
|
|
44
|
-
]).optional()
|
|
45
|
-
});
|
|
46
|
-
var GoogleGenerativeAIEmbeddingModel = class {
|
|
47
|
-
constructor(modelId, config) {
|
|
48
|
-
this.specificationVersion = "v2";
|
|
49
|
-
this.maxEmbeddingsPerCall = 2048;
|
|
50
|
-
this.supportsParallelCalls = true;
|
|
51
|
-
this.modelId = modelId;
|
|
52
|
-
this.config = config;
|
|
53
|
-
}
|
|
54
|
-
get provider() {
|
|
55
|
-
return this.config.provider;
|
|
56
|
-
}
|
|
57
|
-
async doEmbed({
|
|
58
|
-
values,
|
|
59
|
-
headers,
|
|
60
|
-
abortSignal,
|
|
61
|
-
providerOptions
|
|
62
|
-
}) {
|
|
63
|
-
const googleOptions = await chunkHVBBFCDH_cjs.parseProviderOptions({
|
|
64
|
-
provider: "google",
|
|
65
|
-
providerOptions,
|
|
66
|
-
schema: googleGenerativeAIEmbeddingProviderOptions
|
|
67
|
-
});
|
|
68
|
-
if (values.length > this.maxEmbeddingsPerCall) {
|
|
69
|
-
throw new chunkHVBBFCDH_cjs.TooManyEmbeddingValuesForCallError({
|
|
70
|
-
provider: this.provider,
|
|
71
|
-
modelId: this.modelId,
|
|
72
|
-
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
73
|
-
values
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
const mergedHeaders = chunkHVBBFCDH_cjs.combineHeaders(
|
|
77
|
-
await chunkHVBBFCDH_cjs.resolve(this.config.headers),
|
|
78
|
-
headers
|
|
79
|
-
);
|
|
80
|
-
if (values.length === 1) {
|
|
81
|
-
const {
|
|
82
|
-
responseHeaders: responseHeaders2,
|
|
83
|
-
value: response2,
|
|
84
|
-
rawValue: rawValue2
|
|
85
|
-
} = await chunkHVBBFCDH_cjs.postJsonToApi({
|
|
86
|
-
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
87
|
-
headers: mergedHeaders,
|
|
88
|
-
body: {
|
|
89
|
-
model: `models/${this.modelId}`,
|
|
90
|
-
content: {
|
|
91
|
-
parts: [{ text: values[0] }]
|
|
92
|
-
},
|
|
93
|
-
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
94
|
-
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
95
|
-
},
|
|
96
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
97
|
-
successfulResponseHandler: chunkHVBBFCDH_cjs.createJsonResponseHandler(
|
|
98
|
-
googleGenerativeAISingleEmbeddingResponseSchema
|
|
99
|
-
),
|
|
100
|
-
abortSignal,
|
|
101
|
-
fetch: this.config.fetch
|
|
102
|
-
});
|
|
103
|
-
return {
|
|
104
|
-
embeddings: [response2.embedding.values],
|
|
105
|
-
usage: void 0,
|
|
106
|
-
response: { headers: responseHeaders2, body: rawValue2 }
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
const {
|
|
110
|
-
responseHeaders,
|
|
111
|
-
value: response,
|
|
112
|
-
rawValue
|
|
113
|
-
} = await chunkHVBBFCDH_cjs.postJsonToApi({
|
|
114
|
-
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
115
|
-
headers: mergedHeaders,
|
|
116
|
-
body: {
|
|
117
|
-
requests: values.map((value) => ({
|
|
118
|
-
model: `models/${this.modelId}`,
|
|
119
|
-
content: { role: "user", parts: [{ text: value }] },
|
|
120
|
-
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
121
|
-
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
122
|
-
}))
|
|
123
|
-
},
|
|
124
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
125
|
-
successfulResponseHandler: chunkHVBBFCDH_cjs.createJsonResponseHandler(
|
|
126
|
-
googleGenerativeAITextEmbeddingResponseSchema
|
|
127
|
-
),
|
|
128
|
-
abortSignal,
|
|
129
|
-
fetch: this.config.fetch
|
|
130
|
-
});
|
|
131
|
-
return {
|
|
132
|
-
embeddings: response.embeddings.map((item) => item.values),
|
|
133
|
-
usage: void 0,
|
|
134
|
-
response: { headers: responseHeaders, body: rawValue }
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
var googleGenerativeAITextEmbeddingResponseSchema = v4.z.object({
|
|
139
|
-
embeddings: v4.z.array(v4.z.object({ values: v4.z.array(v4.z.number()) }))
|
|
140
|
-
});
|
|
141
|
-
var googleGenerativeAISingleEmbeddingResponseSchema = v4.z.object({
|
|
142
|
-
embedding: v4.z.object({ values: v4.z.array(v4.z.number()) })
|
|
143
|
-
});
|
|
144
|
-
function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
145
|
-
if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
|
|
146
|
-
return void 0;
|
|
147
|
-
}
|
|
148
|
-
if (typeof jsonSchema === "boolean") {
|
|
149
|
-
return { type: "boolean", properties: {} };
|
|
150
|
-
}
|
|
151
|
-
const {
|
|
152
|
-
type,
|
|
153
|
-
description,
|
|
154
|
-
required,
|
|
155
|
-
properties,
|
|
156
|
-
items,
|
|
157
|
-
allOf,
|
|
158
|
-
anyOf,
|
|
159
|
-
oneOf,
|
|
160
|
-
format,
|
|
161
|
-
const: constValue,
|
|
162
|
-
minLength,
|
|
163
|
-
enum: enumValues
|
|
164
|
-
} = jsonSchema;
|
|
165
|
-
const result = {};
|
|
166
|
-
if (description)
|
|
167
|
-
result.description = description;
|
|
168
|
-
if (required)
|
|
169
|
-
result.required = required;
|
|
170
|
-
if (format)
|
|
171
|
-
result.format = format;
|
|
172
|
-
if (constValue !== void 0) {
|
|
173
|
-
result.enum = [constValue];
|
|
174
|
-
}
|
|
175
|
-
if (type) {
|
|
176
|
-
if (Array.isArray(type)) {
|
|
177
|
-
if (type.includes("null")) {
|
|
178
|
-
result.type = type.filter((t) => t !== "null")[0];
|
|
179
|
-
result.nullable = true;
|
|
180
|
-
} else {
|
|
181
|
-
result.type = type;
|
|
182
|
-
}
|
|
183
|
-
} else if (type === "null") {
|
|
184
|
-
result.type = "null";
|
|
185
|
-
} else {
|
|
186
|
-
result.type = type;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (enumValues !== void 0) {
|
|
190
|
-
result.enum = enumValues;
|
|
191
|
-
}
|
|
192
|
-
if (properties != null) {
|
|
193
|
-
result.properties = Object.entries(properties).reduce(
|
|
194
|
-
(acc, [key, value]) => {
|
|
195
|
-
acc[key] = convertJSONSchemaToOpenAPISchema(value);
|
|
196
|
-
return acc;
|
|
197
|
-
},
|
|
198
|
-
{}
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
if (items) {
|
|
202
|
-
result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
|
|
203
|
-
}
|
|
204
|
-
if (allOf) {
|
|
205
|
-
result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
|
|
206
|
-
}
|
|
207
|
-
if (anyOf) {
|
|
208
|
-
if (anyOf.some(
|
|
209
|
-
(schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"
|
|
210
|
-
)) {
|
|
211
|
-
const nonNullSchemas = anyOf.filter(
|
|
212
|
-
(schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
|
|
213
|
-
);
|
|
214
|
-
if (nonNullSchemas.length === 1) {
|
|
215
|
-
const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
|
|
216
|
-
if (typeof converted === "object") {
|
|
217
|
-
result.nullable = true;
|
|
218
|
-
Object.assign(result, converted);
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
221
|
-
result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
|
|
222
|
-
result.nullable = true;
|
|
223
|
-
}
|
|
224
|
-
} else {
|
|
225
|
-
result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (oneOf) {
|
|
229
|
-
result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
|
|
230
|
-
}
|
|
231
|
-
if (minLength !== void 0) {
|
|
232
|
-
result.minLength = minLength;
|
|
233
|
-
}
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
236
|
-
function isEmptyObjectSchema(jsonSchema) {
|
|
237
|
-
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
238
|
-
}
|
|
239
|
-
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
240
|
-
var _a;
|
|
241
|
-
const systemInstructionParts = [];
|
|
242
|
-
const contents = [];
|
|
243
|
-
let systemMessagesAllowed = true;
|
|
244
|
-
const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
|
|
245
|
-
for (const { role, content } of prompt) {
|
|
246
|
-
switch (role) {
|
|
247
|
-
case "system": {
|
|
248
|
-
if (!systemMessagesAllowed) {
|
|
249
|
-
throw new chunkHVBBFCDH_cjs.UnsupportedFunctionalityError({
|
|
250
|
-
functionality: "system messages are only supported at the beginning of the conversation"
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
systemInstructionParts.push({ text: content });
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
case "user": {
|
|
257
|
-
systemMessagesAllowed = false;
|
|
258
|
-
const parts = [];
|
|
259
|
-
for (const part of content) {
|
|
260
|
-
switch (part.type) {
|
|
261
|
-
case "text": {
|
|
262
|
-
parts.push({ text: part.text });
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
case "file": {
|
|
266
|
-
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
267
|
-
parts.push(
|
|
268
|
-
part.data instanceof URL ? {
|
|
269
|
-
fileData: {
|
|
270
|
-
mimeType: mediaType,
|
|
271
|
-
fileUri: part.data.toString()
|
|
272
|
-
}
|
|
273
|
-
} : {
|
|
274
|
-
inlineData: {
|
|
275
|
-
mimeType: mediaType,
|
|
276
|
-
data: chunkHVBBFCDH_cjs.convertToBase64(part.data)
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
);
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
contents.push({ role: "user", parts });
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
case "assistant": {
|
|
288
|
-
systemMessagesAllowed = false;
|
|
289
|
-
contents.push({
|
|
290
|
-
role: "model",
|
|
291
|
-
parts: content.map((part) => {
|
|
292
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
293
|
-
switch (part.type) {
|
|
294
|
-
case "text": {
|
|
295
|
-
return part.text.length === 0 ? void 0 : {
|
|
296
|
-
text: part.text,
|
|
297
|
-
thoughtSignature: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
case "reasoning": {
|
|
301
|
-
return part.text.length === 0 ? void 0 : {
|
|
302
|
-
text: part.text,
|
|
303
|
-
thought: true,
|
|
304
|
-
thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
case "file": {
|
|
308
|
-
if (part.mediaType !== "image/png") {
|
|
309
|
-
throw new chunkHVBBFCDH_cjs.UnsupportedFunctionalityError({
|
|
310
|
-
functionality: "Only PNG images are supported in assistant messages"
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
if (part.data instanceof URL) {
|
|
314
|
-
throw new chunkHVBBFCDH_cjs.UnsupportedFunctionalityError({
|
|
315
|
-
functionality: "File data URLs in assistant messages are not supported"
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
return {
|
|
319
|
-
inlineData: {
|
|
320
|
-
mimeType: part.mediaType,
|
|
321
|
-
data: chunkHVBBFCDH_cjs.convertToBase64(part.data)
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
case "tool-call": {
|
|
326
|
-
return {
|
|
327
|
-
functionCall: {
|
|
328
|
-
name: part.toolName,
|
|
329
|
-
args: part.input
|
|
330
|
-
},
|
|
331
|
-
thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}).filter((part) => part !== void 0)
|
|
336
|
-
});
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
case "tool": {
|
|
340
|
-
systemMessagesAllowed = false;
|
|
341
|
-
contents.push({
|
|
342
|
-
role: "user",
|
|
343
|
-
parts: content.map((part) => ({
|
|
344
|
-
functionResponse: {
|
|
345
|
-
name: part.toolName,
|
|
346
|
-
response: {
|
|
347
|
-
name: part.toolName,
|
|
348
|
-
content: part.output.value
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}))
|
|
352
|
-
});
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (isGemmaModel && systemInstructionParts.length > 0 && contents.length > 0 && contents[0].role === "user") {
|
|
358
|
-
const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
|
|
359
|
-
contents[0].parts.unshift({ text: systemText + "\n\n" });
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
|
|
363
|
-
contents
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
function getModelPath(modelId) {
|
|
367
|
-
return modelId.includes("/") ? modelId : `models/${modelId}`;
|
|
368
|
-
}
|
|
369
|
-
var googleGenerativeAIProviderOptions = v4.z.object({
|
|
370
|
-
responseModalities: v4.z.array(v4.z.enum(["TEXT", "IMAGE"])).optional(),
|
|
371
|
-
thinkingConfig: v4.z.object({
|
|
372
|
-
thinkingBudget: v4.z.number().optional(),
|
|
373
|
-
includeThoughts: v4.z.boolean().optional()
|
|
374
|
-
}).optional(),
|
|
375
|
-
/**
|
|
376
|
-
Optional.
|
|
377
|
-
The name of the cached content used as context to serve the prediction.
|
|
378
|
-
Format: cachedContents/{cachedContent}
|
|
379
|
-
*/
|
|
380
|
-
cachedContent: v4.z.string().optional(),
|
|
381
|
-
/**
|
|
382
|
-
* Optional. Enable structured output. Default is true.
|
|
383
|
-
*
|
|
384
|
-
* This is useful when the JSON Schema contains elements that are
|
|
385
|
-
* not supported by the OpenAPI schema version that
|
|
386
|
-
* Google Generative AI uses. You can use this to disable
|
|
387
|
-
* structured outputs if you need to.
|
|
388
|
-
*/
|
|
389
|
-
structuredOutputs: v4.z.boolean().optional(),
|
|
390
|
-
/**
|
|
391
|
-
Optional. A list of unique safety settings for blocking unsafe content.
|
|
392
|
-
*/
|
|
393
|
-
safetySettings: v4.z.array(
|
|
394
|
-
v4.z.object({
|
|
395
|
-
category: v4.z.enum([
|
|
396
|
-
"HARM_CATEGORY_UNSPECIFIED",
|
|
397
|
-
"HARM_CATEGORY_HATE_SPEECH",
|
|
398
|
-
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
399
|
-
"HARM_CATEGORY_HARASSMENT",
|
|
400
|
-
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
401
|
-
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
402
|
-
]),
|
|
403
|
-
threshold: v4.z.enum([
|
|
404
|
-
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
405
|
-
"BLOCK_LOW_AND_ABOVE",
|
|
406
|
-
"BLOCK_MEDIUM_AND_ABOVE",
|
|
407
|
-
"BLOCK_ONLY_HIGH",
|
|
408
|
-
"BLOCK_NONE",
|
|
409
|
-
"OFF"
|
|
410
|
-
])
|
|
411
|
-
})
|
|
412
|
-
).optional(),
|
|
413
|
-
threshold: v4.z.enum([
|
|
414
|
-
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
415
|
-
"BLOCK_LOW_AND_ABOVE",
|
|
416
|
-
"BLOCK_MEDIUM_AND_ABOVE",
|
|
417
|
-
"BLOCK_ONLY_HIGH",
|
|
418
|
-
"BLOCK_NONE",
|
|
419
|
-
"OFF"
|
|
420
|
-
]).optional(),
|
|
421
|
-
/**
|
|
422
|
-
* Optional. Enables timestamp understanding for audio-only files.
|
|
423
|
-
*
|
|
424
|
-
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
425
|
-
*/
|
|
426
|
-
audioTimestamp: v4.z.boolean().optional(),
|
|
427
|
-
/**
|
|
428
|
-
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
429
|
-
*
|
|
430
|
-
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
431
|
-
*/
|
|
432
|
-
labels: v4.z.record(v4.z.string(), v4.z.string()).optional()
|
|
433
|
-
});
|
|
434
|
-
function prepareTools({
|
|
435
|
-
tools,
|
|
436
|
-
toolChoice,
|
|
437
|
-
modelId
|
|
438
|
-
}) {
|
|
439
|
-
var _a;
|
|
440
|
-
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
441
|
-
const toolWarnings = [];
|
|
442
|
-
const isGemini2 = modelId.includes("gemini-2");
|
|
443
|
-
const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
|
|
444
|
-
if (tools == null) {
|
|
445
|
-
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
446
|
-
}
|
|
447
|
-
const hasFunctionTools = tools.some((tool) => tool.type === "function");
|
|
448
|
-
const hasProviderDefinedTools = tools.some(
|
|
449
|
-
(tool) => tool.type === "provider-defined"
|
|
450
|
-
);
|
|
451
|
-
if (hasFunctionTools && hasProviderDefinedTools) {
|
|
452
|
-
toolWarnings.push({
|
|
453
|
-
type: "unsupported-tool",
|
|
454
|
-
tool: tools.find((tool) => tool.type === "function"),
|
|
455
|
-
details: "Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both."
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
if (hasProviderDefinedTools) {
|
|
459
|
-
const googleTools2 = {};
|
|
460
|
-
const providerDefinedTools = tools.filter(
|
|
461
|
-
(tool) => tool.type === "provider-defined"
|
|
462
|
-
);
|
|
463
|
-
providerDefinedTools.forEach((tool) => {
|
|
464
|
-
switch (tool.id) {
|
|
465
|
-
case "google.google_search":
|
|
466
|
-
if (isGemini2) {
|
|
467
|
-
googleTools2.googleSearch = {};
|
|
468
|
-
} else if (supportsDynamicRetrieval) {
|
|
469
|
-
googleTools2.googleSearchRetrieval = {
|
|
470
|
-
dynamicRetrievalConfig: {
|
|
471
|
-
mode: tool.args.mode,
|
|
472
|
-
dynamicThreshold: tool.args.dynamicThreshold
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
} else {
|
|
476
|
-
googleTools2.googleSearchRetrieval = {};
|
|
477
|
-
}
|
|
478
|
-
break;
|
|
479
|
-
case "google.url_context":
|
|
480
|
-
if (isGemini2) {
|
|
481
|
-
googleTools2.urlContext = {};
|
|
482
|
-
} else {
|
|
483
|
-
toolWarnings.push({
|
|
484
|
-
type: "unsupported-tool",
|
|
485
|
-
tool,
|
|
486
|
-
details: "The URL context tool is not supported with other Gemini models than Gemini 2."
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
case "google.code_execution":
|
|
491
|
-
if (isGemini2) {
|
|
492
|
-
googleTools2.codeExecution = {};
|
|
493
|
-
} else {
|
|
494
|
-
toolWarnings.push({
|
|
495
|
-
type: "unsupported-tool",
|
|
496
|
-
tool,
|
|
497
|
-
details: "The code execution tools is not supported with other Gemini models than Gemini 2."
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
break;
|
|
501
|
-
default:
|
|
502
|
-
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
return {
|
|
507
|
-
tools: Object.keys(googleTools2).length > 0 ? googleTools2 : void 0,
|
|
508
|
-
toolConfig: void 0,
|
|
509
|
-
toolWarnings
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
const functionDeclarations = [];
|
|
513
|
-
for (const tool of tools) {
|
|
514
|
-
switch (tool.type) {
|
|
515
|
-
case "function":
|
|
516
|
-
functionDeclarations.push({
|
|
517
|
-
name: tool.name,
|
|
518
|
-
description: (_a = tool.description) != null ? _a : "",
|
|
519
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
520
|
-
});
|
|
521
|
-
break;
|
|
522
|
-
default:
|
|
523
|
-
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
if (toolChoice == null) {
|
|
528
|
-
return {
|
|
529
|
-
tools: { functionDeclarations },
|
|
530
|
-
toolConfig: void 0,
|
|
531
|
-
toolWarnings
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
const type = toolChoice.type;
|
|
535
|
-
switch (type) {
|
|
536
|
-
case "auto":
|
|
537
|
-
return {
|
|
538
|
-
tools: { functionDeclarations },
|
|
539
|
-
toolConfig: { functionCallingConfig: { mode: "AUTO" } },
|
|
540
|
-
toolWarnings
|
|
541
|
-
};
|
|
542
|
-
case "none":
|
|
543
|
-
return {
|
|
544
|
-
tools: { functionDeclarations },
|
|
545
|
-
toolConfig: { functionCallingConfig: { mode: "NONE" } },
|
|
546
|
-
toolWarnings
|
|
547
|
-
};
|
|
548
|
-
case "required":
|
|
549
|
-
return {
|
|
550
|
-
tools: { functionDeclarations },
|
|
551
|
-
toolConfig: { functionCallingConfig: { mode: "ANY" } },
|
|
552
|
-
toolWarnings
|
|
553
|
-
};
|
|
554
|
-
case "tool":
|
|
555
|
-
return {
|
|
556
|
-
tools: { functionDeclarations },
|
|
557
|
-
toolConfig: {
|
|
558
|
-
functionCallingConfig: {
|
|
559
|
-
mode: "ANY",
|
|
560
|
-
allowedFunctionNames: [toolChoice.toolName]
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
toolWarnings
|
|
564
|
-
};
|
|
565
|
-
default: {
|
|
566
|
-
const _exhaustiveCheck = type;
|
|
567
|
-
throw new chunkHVBBFCDH_cjs.UnsupportedFunctionalityError({
|
|
568
|
-
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
function mapGoogleGenerativeAIFinishReason({
|
|
574
|
-
finishReason,
|
|
575
|
-
hasToolCalls
|
|
576
|
-
}) {
|
|
577
|
-
switch (finishReason) {
|
|
578
|
-
case "STOP":
|
|
579
|
-
return hasToolCalls ? "tool-calls" : "stop";
|
|
580
|
-
case "MAX_TOKENS":
|
|
581
|
-
return "length";
|
|
582
|
-
case "IMAGE_SAFETY":
|
|
583
|
-
case "RECITATION":
|
|
584
|
-
case "SAFETY":
|
|
585
|
-
case "BLOCKLIST":
|
|
586
|
-
case "PROHIBITED_CONTENT":
|
|
587
|
-
case "SPII":
|
|
588
|
-
return "content-filter";
|
|
589
|
-
case "FINISH_REASON_UNSPECIFIED":
|
|
590
|
-
case "OTHER":
|
|
591
|
-
return "other";
|
|
592
|
-
case "MALFORMED_FUNCTION_CALL":
|
|
593
|
-
return "error";
|
|
594
|
-
default:
|
|
595
|
-
return "unknown";
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
var groundingChunkSchema = v4.z.object({
|
|
599
|
-
web: v4.z.object({ uri: v4.z.string(), title: v4.z.string() }).nullish(),
|
|
600
|
-
retrievedContext: v4.z.object({ uri: v4.z.string(), title: v4.z.string() }).nullish()
|
|
601
|
-
});
|
|
602
|
-
var groundingMetadataSchema = v4.z.object({
|
|
603
|
-
webSearchQueries: v4.z.array(v4.z.string()).nullish(),
|
|
604
|
-
retrievalQueries: v4.z.array(v4.z.string()).nullish(),
|
|
605
|
-
searchEntryPoint: v4.z.object({ renderedContent: v4.z.string() }).nullish(),
|
|
606
|
-
groundingChunks: v4.z.array(groundingChunkSchema).nullish(),
|
|
607
|
-
groundingSupports: v4.z.array(
|
|
608
|
-
v4.z.object({
|
|
609
|
-
segment: v4.z.object({
|
|
610
|
-
startIndex: v4.z.number().nullish(),
|
|
611
|
-
endIndex: v4.z.number().nullish(),
|
|
612
|
-
text: v4.z.string().nullish()
|
|
613
|
-
}),
|
|
614
|
-
segment_text: v4.z.string().nullish(),
|
|
615
|
-
groundingChunkIndices: v4.z.array(v4.z.number()).nullish(),
|
|
616
|
-
supportChunkIndices: v4.z.array(v4.z.number()).nullish(),
|
|
617
|
-
confidenceScores: v4.z.array(v4.z.number()).nullish(),
|
|
618
|
-
confidenceScore: v4.z.array(v4.z.number()).nullish()
|
|
619
|
-
})
|
|
620
|
-
).nullish(),
|
|
621
|
-
retrievalMetadata: v4.z.union([
|
|
622
|
-
v4.z.object({
|
|
623
|
-
webDynamicRetrievalScore: v4.z.number()
|
|
624
|
-
}),
|
|
625
|
-
v4.z.object({})
|
|
626
|
-
]).nullish()
|
|
627
|
-
});
|
|
628
|
-
var googleSearch = chunkHVBBFCDH_cjs.createProviderDefinedToolFactory({
|
|
629
|
-
id: "google.google_search",
|
|
630
|
-
name: "google_search",
|
|
631
|
-
inputSchema: v4.z.object({
|
|
632
|
-
mode: v4.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
633
|
-
dynamicThreshold: v4.z.number().default(1)
|
|
634
|
-
})
|
|
635
|
-
});
|
|
636
|
-
var urlMetadataSchema = v4.z.object({
|
|
637
|
-
retrievedUrl: v4.z.string(),
|
|
638
|
-
urlRetrievalStatus: v4.z.string()
|
|
639
|
-
});
|
|
640
|
-
var urlContextMetadataSchema = v4.z.object({
|
|
641
|
-
urlMetadata: v4.z.array(urlMetadataSchema)
|
|
642
|
-
});
|
|
643
|
-
var urlContext = chunkHVBBFCDH_cjs.createProviderDefinedToolFactory({
|
|
644
|
-
id: "google.url_context",
|
|
645
|
-
name: "url_context",
|
|
646
|
-
inputSchema: v4.z.object({})
|
|
647
|
-
});
|
|
648
|
-
var GoogleGenerativeAILanguageModel = class {
|
|
649
|
-
constructor(modelId, config) {
|
|
650
|
-
this.specificationVersion = "v2";
|
|
651
|
-
var _a;
|
|
652
|
-
this.modelId = modelId;
|
|
653
|
-
this.config = config;
|
|
654
|
-
this.generateId = (_a = config.generateId) != null ? _a : chunkHVBBFCDH_cjs.generateId;
|
|
655
|
-
}
|
|
656
|
-
get provider() {
|
|
657
|
-
return this.config.provider;
|
|
658
|
-
}
|
|
659
|
-
get supportedUrls() {
|
|
660
|
-
var _a, _b, _c;
|
|
661
|
-
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
662
|
-
}
|
|
663
|
-
async getArgs({
|
|
664
|
-
prompt,
|
|
665
|
-
maxOutputTokens,
|
|
666
|
-
temperature,
|
|
667
|
-
topP,
|
|
668
|
-
topK,
|
|
669
|
-
frequencyPenalty,
|
|
670
|
-
presencePenalty,
|
|
671
|
-
stopSequences,
|
|
672
|
-
responseFormat,
|
|
673
|
-
seed,
|
|
674
|
-
tools,
|
|
675
|
-
toolChoice,
|
|
676
|
-
providerOptions
|
|
677
|
-
}) {
|
|
678
|
-
var _a, _b;
|
|
679
|
-
const warnings = [];
|
|
680
|
-
const googleOptions = await chunkHVBBFCDH_cjs.parseProviderOptions({
|
|
681
|
-
provider: "google",
|
|
682
|
-
providerOptions,
|
|
683
|
-
schema: googleGenerativeAIProviderOptions
|
|
684
|
-
});
|
|
685
|
-
if (((_a = googleOptions == null ? void 0 : googleOptions.thinkingConfig) == null ? void 0 : _a.includeThoughts) === true && !this.config.provider.startsWith("google.vertex.")) {
|
|
686
|
-
warnings.push({
|
|
687
|
-
type: "other",
|
|
688
|
-
message: `The 'includeThoughts' option is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
692
|
-
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
693
|
-
prompt,
|
|
694
|
-
{ isGemmaModel }
|
|
695
|
-
);
|
|
696
|
-
const {
|
|
697
|
-
tools: googleTools2,
|
|
698
|
-
toolConfig: googleToolConfig,
|
|
699
|
-
toolWarnings
|
|
700
|
-
} = prepareTools({
|
|
701
|
-
tools,
|
|
702
|
-
toolChoice,
|
|
703
|
-
modelId: this.modelId
|
|
704
|
-
});
|
|
705
|
-
return {
|
|
706
|
-
args: {
|
|
707
|
-
generationConfig: {
|
|
708
|
-
// standardized settings:
|
|
709
|
-
maxOutputTokens,
|
|
710
|
-
temperature,
|
|
711
|
-
topK,
|
|
712
|
-
topP,
|
|
713
|
-
frequencyPenalty,
|
|
714
|
-
presencePenalty,
|
|
715
|
-
stopSequences,
|
|
716
|
-
seed,
|
|
717
|
-
// response format:
|
|
718
|
-
responseMimeType: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? "application/json" : void 0,
|
|
719
|
-
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
720
|
-
// so this is needed as an escape hatch:
|
|
721
|
-
// TODO convert into provider option
|
|
722
|
-
((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
723
|
-
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
724
|
-
audioTimestamp: googleOptions.audioTimestamp
|
|
725
|
-
},
|
|
726
|
-
// provider options:
|
|
727
|
-
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
|
728
|
-
thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
|
|
729
|
-
},
|
|
730
|
-
contents,
|
|
731
|
-
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
732
|
-
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
|
733
|
-
tools: googleTools2,
|
|
734
|
-
toolConfig: googleToolConfig,
|
|
735
|
-
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
736
|
-
labels: googleOptions == null ? void 0 : googleOptions.labels
|
|
737
|
-
},
|
|
738
|
-
warnings: [...warnings, ...toolWarnings]
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
async doGenerate(options) {
|
|
742
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
743
|
-
const { args, warnings } = await this.getArgs(options);
|
|
744
|
-
const body = JSON.stringify(args);
|
|
745
|
-
const mergedHeaders = chunkHVBBFCDH_cjs.combineHeaders(
|
|
746
|
-
await chunkHVBBFCDH_cjs.resolve(this.config.headers),
|
|
747
|
-
options.headers
|
|
748
|
-
);
|
|
749
|
-
const {
|
|
750
|
-
responseHeaders,
|
|
751
|
-
value: response,
|
|
752
|
-
rawValue: rawResponse
|
|
753
|
-
} = await chunkHVBBFCDH_cjs.postJsonToApi({
|
|
754
|
-
url: `${this.config.baseURL}/${getModelPath(
|
|
755
|
-
this.modelId
|
|
756
|
-
)}:generateContent`,
|
|
757
|
-
headers: mergedHeaders,
|
|
758
|
-
body: args,
|
|
759
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
760
|
-
successfulResponseHandler: chunkHVBBFCDH_cjs.createJsonResponseHandler(responseSchema),
|
|
761
|
-
abortSignal: options.abortSignal,
|
|
762
|
-
fetch: this.config.fetch
|
|
763
|
-
});
|
|
764
|
-
const candidate = response.candidates[0];
|
|
765
|
-
const content = [];
|
|
766
|
-
const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
|
|
767
|
-
const usageMetadata = response.usageMetadata;
|
|
768
|
-
let lastCodeExecutionToolCallId;
|
|
769
|
-
for (const part of parts) {
|
|
770
|
-
if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
|
|
771
|
-
const toolCallId = this.config.generateId();
|
|
772
|
-
lastCodeExecutionToolCallId = toolCallId;
|
|
773
|
-
content.push({
|
|
774
|
-
type: "tool-call",
|
|
775
|
-
toolCallId,
|
|
776
|
-
toolName: "code_execution",
|
|
777
|
-
input: JSON.stringify(part.executableCode),
|
|
778
|
-
providerExecuted: true
|
|
779
|
-
});
|
|
780
|
-
} else if ("codeExecutionResult" in part && part.codeExecutionResult) {
|
|
781
|
-
content.push({
|
|
782
|
-
type: "tool-result",
|
|
783
|
-
// Assumes a result directly follows its corresponding call part.
|
|
784
|
-
toolCallId: lastCodeExecutionToolCallId,
|
|
785
|
-
toolName: "code_execution",
|
|
786
|
-
result: {
|
|
787
|
-
outcome: part.codeExecutionResult.outcome,
|
|
788
|
-
output: part.codeExecutionResult.output
|
|
789
|
-
},
|
|
790
|
-
providerExecuted: true
|
|
791
|
-
});
|
|
792
|
-
lastCodeExecutionToolCallId = void 0;
|
|
793
|
-
} else if ("text" in part && part.text != null && part.text.length > 0) {
|
|
794
|
-
content.push({
|
|
795
|
-
type: part.thought === true ? "reasoning" : "text",
|
|
796
|
-
text: part.text,
|
|
797
|
-
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
798
|
-
});
|
|
799
|
-
} else if ("functionCall" in part) {
|
|
800
|
-
content.push({
|
|
801
|
-
type: "tool-call",
|
|
802
|
-
toolCallId: this.config.generateId(),
|
|
803
|
-
toolName: part.functionCall.name,
|
|
804
|
-
input: JSON.stringify(part.functionCall.args),
|
|
805
|
-
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
806
|
-
});
|
|
807
|
-
} else if ("inlineData" in part) {
|
|
808
|
-
content.push({
|
|
809
|
-
type: "file",
|
|
810
|
-
data: part.inlineData.data,
|
|
811
|
-
mediaType: part.inlineData.mimeType
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
const sources = (_d = extractSources({
|
|
816
|
-
groundingMetadata: candidate.groundingMetadata,
|
|
817
|
-
generateId: this.config.generateId
|
|
818
|
-
})) != null ? _d : [];
|
|
819
|
-
for (const source of sources) {
|
|
820
|
-
content.push(source);
|
|
821
|
-
}
|
|
822
|
-
return {
|
|
823
|
-
content,
|
|
824
|
-
finishReason: mapGoogleGenerativeAIFinishReason({
|
|
825
|
-
finishReason: candidate.finishReason,
|
|
826
|
-
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
827
|
-
}),
|
|
828
|
-
usage: {
|
|
829
|
-
inputTokens: (_e = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _e : void 0,
|
|
830
|
-
outputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _f : void 0,
|
|
831
|
-
totalTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _g : void 0,
|
|
832
|
-
reasoningTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _h : void 0,
|
|
833
|
-
cachedInputTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _i : void 0
|
|
834
|
-
},
|
|
835
|
-
warnings,
|
|
836
|
-
providerMetadata: {
|
|
837
|
-
google: {
|
|
838
|
-
groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
|
|
839
|
-
urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
|
|
840
|
-
safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
|
|
841
|
-
usageMetadata: usageMetadata != null ? usageMetadata : null
|
|
842
|
-
}
|
|
843
|
-
},
|
|
844
|
-
request: { body },
|
|
845
|
-
response: {
|
|
846
|
-
// TODO timestamp, model id, id
|
|
847
|
-
headers: responseHeaders,
|
|
848
|
-
body: rawResponse
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
async doStream(options) {
|
|
853
|
-
const { args, warnings } = await this.getArgs(options);
|
|
854
|
-
const body = JSON.stringify(args);
|
|
855
|
-
const headers = chunkHVBBFCDH_cjs.combineHeaders(
|
|
856
|
-
await chunkHVBBFCDH_cjs.resolve(this.config.headers),
|
|
857
|
-
options.headers
|
|
858
|
-
);
|
|
859
|
-
const { responseHeaders, value: response } = await chunkHVBBFCDH_cjs.postJsonToApi({
|
|
860
|
-
url: `${this.config.baseURL}/${getModelPath(
|
|
861
|
-
this.modelId
|
|
862
|
-
)}:streamGenerateContent?alt=sse`,
|
|
863
|
-
headers,
|
|
864
|
-
body: args,
|
|
865
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
866
|
-
successfulResponseHandler: chunkHVBBFCDH_cjs.createEventSourceResponseHandler(chunkSchema),
|
|
867
|
-
abortSignal: options.abortSignal,
|
|
868
|
-
fetch: this.config.fetch
|
|
869
|
-
});
|
|
870
|
-
let finishReason = "unknown";
|
|
871
|
-
const usage = {
|
|
872
|
-
inputTokens: void 0,
|
|
873
|
-
outputTokens: void 0,
|
|
874
|
-
totalTokens: void 0
|
|
875
|
-
};
|
|
876
|
-
let providerMetadata = void 0;
|
|
877
|
-
const generateId3 = this.config.generateId;
|
|
878
|
-
let hasToolCalls = false;
|
|
879
|
-
let currentTextBlockId = null;
|
|
880
|
-
let currentReasoningBlockId = null;
|
|
881
|
-
let blockCounter = 0;
|
|
882
|
-
const emittedSourceUrls = /* @__PURE__ */ new Set();
|
|
883
|
-
let lastCodeExecutionToolCallId;
|
|
884
|
-
return {
|
|
885
|
-
stream: response.pipeThrough(
|
|
886
|
-
new TransformStream({
|
|
887
|
-
start(controller) {
|
|
888
|
-
controller.enqueue({ type: "stream-start", warnings });
|
|
889
|
-
},
|
|
890
|
-
transform(chunk, controller) {
|
|
891
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
892
|
-
if (options.includeRawChunks) {
|
|
893
|
-
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
894
|
-
}
|
|
895
|
-
if (!chunk.success) {
|
|
896
|
-
controller.enqueue({ type: "error", error: chunk.error });
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
const value = chunk.value;
|
|
900
|
-
const usageMetadata = value.usageMetadata;
|
|
901
|
-
if (usageMetadata != null) {
|
|
902
|
-
usage.inputTokens = (_a = usageMetadata.promptTokenCount) != null ? _a : void 0;
|
|
903
|
-
usage.outputTokens = (_b = usageMetadata.candidatesTokenCount) != null ? _b : void 0;
|
|
904
|
-
usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
|
|
905
|
-
usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
|
|
906
|
-
usage.cachedInputTokens = (_e = usageMetadata.cachedContentTokenCount) != null ? _e : void 0;
|
|
907
|
-
}
|
|
908
|
-
const candidate = (_f = value.candidates) == null ? void 0 : _f[0];
|
|
909
|
-
if (candidate == null) {
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
const content = candidate.content;
|
|
913
|
-
const sources = extractSources({
|
|
914
|
-
groundingMetadata: candidate.groundingMetadata,
|
|
915
|
-
generateId: generateId3
|
|
916
|
-
});
|
|
917
|
-
if (sources != null) {
|
|
918
|
-
for (const source of sources) {
|
|
919
|
-
if (source.sourceType === "url" && !emittedSourceUrls.has(source.url)) {
|
|
920
|
-
emittedSourceUrls.add(source.url);
|
|
921
|
-
controller.enqueue(source);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
if (content != null) {
|
|
926
|
-
const parts = (_g = content.parts) != null ? _g : [];
|
|
927
|
-
for (const part of parts) {
|
|
928
|
-
if ("executableCode" in part && ((_h = part.executableCode) == null ? void 0 : _h.code)) {
|
|
929
|
-
const toolCallId = generateId3();
|
|
930
|
-
lastCodeExecutionToolCallId = toolCallId;
|
|
931
|
-
controller.enqueue({
|
|
932
|
-
type: "tool-call",
|
|
933
|
-
toolCallId,
|
|
934
|
-
toolName: "code_execution",
|
|
935
|
-
input: JSON.stringify(part.executableCode),
|
|
936
|
-
providerExecuted: true
|
|
937
|
-
});
|
|
938
|
-
hasToolCalls = true;
|
|
939
|
-
} else if ("codeExecutionResult" in part && part.codeExecutionResult) {
|
|
940
|
-
const toolCallId = lastCodeExecutionToolCallId;
|
|
941
|
-
if (toolCallId) {
|
|
942
|
-
controller.enqueue({
|
|
943
|
-
type: "tool-result",
|
|
944
|
-
toolCallId,
|
|
945
|
-
toolName: "code_execution",
|
|
946
|
-
result: {
|
|
947
|
-
outcome: part.codeExecutionResult.outcome,
|
|
948
|
-
output: part.codeExecutionResult.output
|
|
949
|
-
},
|
|
950
|
-
providerExecuted: true
|
|
951
|
-
});
|
|
952
|
-
lastCodeExecutionToolCallId = void 0;
|
|
953
|
-
}
|
|
954
|
-
} else if ("text" in part && part.text != null && part.text.length > 0) {
|
|
955
|
-
if (part.thought === true) {
|
|
956
|
-
if (currentTextBlockId !== null) {
|
|
957
|
-
controller.enqueue({
|
|
958
|
-
type: "text-end",
|
|
959
|
-
id: currentTextBlockId
|
|
960
|
-
});
|
|
961
|
-
currentTextBlockId = null;
|
|
962
|
-
}
|
|
963
|
-
if (currentReasoningBlockId === null) {
|
|
964
|
-
currentReasoningBlockId = String(blockCounter++);
|
|
965
|
-
controller.enqueue({
|
|
966
|
-
type: "reasoning-start",
|
|
967
|
-
id: currentReasoningBlockId,
|
|
968
|
-
providerMetadata: part.thoughtSignature ? {
|
|
969
|
-
google: {
|
|
970
|
-
thoughtSignature: part.thoughtSignature
|
|
971
|
-
}
|
|
972
|
-
} : void 0
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
controller.enqueue({
|
|
976
|
-
type: "reasoning-delta",
|
|
977
|
-
id: currentReasoningBlockId,
|
|
978
|
-
delta: part.text,
|
|
979
|
-
providerMetadata: part.thoughtSignature ? {
|
|
980
|
-
google: { thoughtSignature: part.thoughtSignature }
|
|
981
|
-
} : void 0
|
|
982
|
-
});
|
|
983
|
-
} else {
|
|
984
|
-
if (currentReasoningBlockId !== null) {
|
|
985
|
-
controller.enqueue({
|
|
986
|
-
type: "reasoning-end",
|
|
987
|
-
id: currentReasoningBlockId
|
|
988
|
-
});
|
|
989
|
-
currentReasoningBlockId = null;
|
|
990
|
-
}
|
|
991
|
-
if (currentTextBlockId === null) {
|
|
992
|
-
currentTextBlockId = String(blockCounter++);
|
|
993
|
-
controller.enqueue({
|
|
994
|
-
type: "text-start",
|
|
995
|
-
id: currentTextBlockId,
|
|
996
|
-
providerMetadata: part.thoughtSignature ? {
|
|
997
|
-
google: {
|
|
998
|
-
thoughtSignature: part.thoughtSignature
|
|
999
|
-
}
|
|
1000
|
-
} : void 0
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
controller.enqueue({
|
|
1004
|
-
type: "text-delta",
|
|
1005
|
-
id: currentTextBlockId,
|
|
1006
|
-
delta: part.text,
|
|
1007
|
-
providerMetadata: part.thoughtSignature ? {
|
|
1008
|
-
google: { thoughtSignature: part.thoughtSignature }
|
|
1009
|
-
} : void 0
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
const inlineDataParts = getInlineDataParts(content.parts);
|
|
1015
|
-
if (inlineDataParts != null) {
|
|
1016
|
-
for (const part of inlineDataParts) {
|
|
1017
|
-
controller.enqueue({
|
|
1018
|
-
type: "file",
|
|
1019
|
-
mediaType: part.inlineData.mimeType,
|
|
1020
|
-
data: part.inlineData.data
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
const toolCallDeltas = getToolCallsFromParts({
|
|
1025
|
-
parts: content.parts,
|
|
1026
|
-
generateId: generateId3
|
|
1027
|
-
});
|
|
1028
|
-
if (toolCallDeltas != null) {
|
|
1029
|
-
for (const toolCall of toolCallDeltas) {
|
|
1030
|
-
controller.enqueue({
|
|
1031
|
-
type: "tool-input-start",
|
|
1032
|
-
id: toolCall.toolCallId,
|
|
1033
|
-
toolName: toolCall.toolName,
|
|
1034
|
-
providerMetadata: toolCall.providerMetadata
|
|
1035
|
-
});
|
|
1036
|
-
controller.enqueue({
|
|
1037
|
-
type: "tool-input-delta",
|
|
1038
|
-
id: toolCall.toolCallId,
|
|
1039
|
-
delta: toolCall.args,
|
|
1040
|
-
providerMetadata: toolCall.providerMetadata
|
|
1041
|
-
});
|
|
1042
|
-
controller.enqueue({
|
|
1043
|
-
type: "tool-input-end",
|
|
1044
|
-
id: toolCall.toolCallId,
|
|
1045
|
-
providerMetadata: toolCall.providerMetadata
|
|
1046
|
-
});
|
|
1047
|
-
controller.enqueue({
|
|
1048
|
-
type: "tool-call",
|
|
1049
|
-
toolCallId: toolCall.toolCallId,
|
|
1050
|
-
toolName: toolCall.toolName,
|
|
1051
|
-
input: toolCall.args,
|
|
1052
|
-
providerMetadata: toolCall.providerMetadata
|
|
1053
|
-
});
|
|
1054
|
-
hasToolCalls = true;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
if (candidate.finishReason != null) {
|
|
1059
|
-
finishReason = mapGoogleGenerativeAIFinishReason({
|
|
1060
|
-
finishReason: candidate.finishReason,
|
|
1061
|
-
hasToolCalls
|
|
1062
|
-
});
|
|
1063
|
-
providerMetadata = {
|
|
1064
|
-
google: {
|
|
1065
|
-
groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
|
|
1066
|
-
urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
|
|
1067
|
-
safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
if (usageMetadata != null) {
|
|
1071
|
-
providerMetadata.google.usageMetadata = usageMetadata;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
},
|
|
1075
|
-
flush(controller) {
|
|
1076
|
-
if (currentTextBlockId !== null) {
|
|
1077
|
-
controller.enqueue({
|
|
1078
|
-
type: "text-end",
|
|
1079
|
-
id: currentTextBlockId
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
if (currentReasoningBlockId !== null) {
|
|
1083
|
-
controller.enqueue({
|
|
1084
|
-
type: "reasoning-end",
|
|
1085
|
-
id: currentReasoningBlockId
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
controller.enqueue({
|
|
1089
|
-
type: "finish",
|
|
1090
|
-
finishReason,
|
|
1091
|
-
usage,
|
|
1092
|
-
providerMetadata
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
})
|
|
1096
|
-
),
|
|
1097
|
-
response: { headers: responseHeaders },
|
|
1098
|
-
request: { body }
|
|
1099
|
-
};
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
1102
|
-
function getToolCallsFromParts({
|
|
1103
|
-
parts,
|
|
1104
|
-
generateId: generateId3
|
|
1105
|
-
}) {
|
|
1106
|
-
const functionCallParts = parts == null ? void 0 : parts.filter(
|
|
1107
|
-
(part) => "functionCall" in part
|
|
1108
|
-
);
|
|
1109
|
-
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
|
|
1110
|
-
type: "tool-call",
|
|
1111
|
-
toolCallId: generateId3(),
|
|
1112
|
-
toolName: part.functionCall.name,
|
|
1113
|
-
args: JSON.stringify(part.functionCall.args),
|
|
1114
|
-
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
1115
|
-
}));
|
|
1116
|
-
}
|
|
1117
|
-
function getInlineDataParts(parts) {
|
|
1118
|
-
return parts == null ? void 0 : parts.filter(
|
|
1119
|
-
(part) => "inlineData" in part
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
|
-
function extractSources({
|
|
1123
|
-
groundingMetadata,
|
|
1124
|
-
generateId: generateId3
|
|
1125
|
-
}) {
|
|
1126
|
-
var _a;
|
|
1127
|
-
return (_a = groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks) == null ? void 0 : _a.filter(
|
|
1128
|
-
(chunk) => chunk.web != null
|
|
1129
|
-
).map((chunk) => ({
|
|
1130
|
-
type: "source",
|
|
1131
|
-
sourceType: "url",
|
|
1132
|
-
id: generateId3(),
|
|
1133
|
-
url: chunk.web.uri,
|
|
1134
|
-
title: chunk.web.title
|
|
1135
|
-
}));
|
|
1136
|
-
}
|
|
1137
|
-
var contentSchema = v4.z.object({
|
|
1138
|
-
parts: v4.z.array(
|
|
1139
|
-
v4.z.union([
|
|
1140
|
-
// note: order matters since text can be fully empty
|
|
1141
|
-
v4.z.object({
|
|
1142
|
-
functionCall: v4.z.object({
|
|
1143
|
-
name: v4.z.string(),
|
|
1144
|
-
args: v4.z.unknown()
|
|
1145
|
-
}),
|
|
1146
|
-
thoughtSignature: v4.z.string().nullish()
|
|
1147
|
-
}),
|
|
1148
|
-
v4.z.object({
|
|
1149
|
-
inlineData: v4.z.object({
|
|
1150
|
-
mimeType: v4.z.string(),
|
|
1151
|
-
data: v4.z.string()
|
|
1152
|
-
})
|
|
1153
|
-
}),
|
|
1154
|
-
v4.z.object({
|
|
1155
|
-
executableCode: v4.z.object({
|
|
1156
|
-
language: v4.z.string(),
|
|
1157
|
-
code: v4.z.string()
|
|
1158
|
-
}).nullish(),
|
|
1159
|
-
codeExecutionResult: v4.z.object({
|
|
1160
|
-
outcome: v4.z.string(),
|
|
1161
|
-
output: v4.z.string()
|
|
1162
|
-
}).nullish(),
|
|
1163
|
-
text: v4.z.string().nullish(),
|
|
1164
|
-
thought: v4.z.boolean().nullish(),
|
|
1165
|
-
thoughtSignature: v4.z.string().nullish()
|
|
1166
|
-
})
|
|
1167
|
-
])
|
|
1168
|
-
).nullish()
|
|
1169
|
-
});
|
|
1170
|
-
var safetyRatingSchema = v4.z.object({
|
|
1171
|
-
category: v4.z.string().nullish(),
|
|
1172
|
-
probability: v4.z.string().nullish(),
|
|
1173
|
-
probabilityScore: v4.z.number().nullish(),
|
|
1174
|
-
severity: v4.z.string().nullish(),
|
|
1175
|
-
severityScore: v4.z.number().nullish(),
|
|
1176
|
-
blocked: v4.z.boolean().nullish()
|
|
1177
|
-
});
|
|
1178
|
-
var usageSchema = v4.z.object({
|
|
1179
|
-
cachedContentTokenCount: v4.z.number().nullish(),
|
|
1180
|
-
thoughtsTokenCount: v4.z.number().nullish(),
|
|
1181
|
-
promptTokenCount: v4.z.number().nullish(),
|
|
1182
|
-
candidatesTokenCount: v4.z.number().nullish(),
|
|
1183
|
-
totalTokenCount: v4.z.number().nullish()
|
|
1184
|
-
});
|
|
1185
|
-
var responseSchema = v4.z.object({
|
|
1186
|
-
candidates: v4.z.array(
|
|
1187
|
-
v4.z.object({
|
|
1188
|
-
content: contentSchema.nullish().or(v4.z.object({}).strict()),
|
|
1189
|
-
finishReason: v4.z.string().nullish(),
|
|
1190
|
-
safetyRatings: v4.z.array(safetyRatingSchema).nullish(),
|
|
1191
|
-
groundingMetadata: groundingMetadataSchema.nullish(),
|
|
1192
|
-
urlContextMetadata: urlContextMetadataSchema.nullish()
|
|
1193
|
-
})
|
|
1194
|
-
),
|
|
1195
|
-
usageMetadata: usageSchema.nullish()
|
|
1196
|
-
});
|
|
1197
|
-
var chunkSchema = v4.z.object({
|
|
1198
|
-
candidates: v4.z.array(
|
|
1199
|
-
v4.z.object({
|
|
1200
|
-
content: contentSchema.nullish(),
|
|
1201
|
-
finishReason: v4.z.string().nullish(),
|
|
1202
|
-
safetyRatings: v4.z.array(safetyRatingSchema).nullish(),
|
|
1203
|
-
groundingMetadata: groundingMetadataSchema.nullish(),
|
|
1204
|
-
urlContextMetadata: urlContextMetadataSchema.nullish()
|
|
1205
|
-
})
|
|
1206
|
-
).nullish(),
|
|
1207
|
-
usageMetadata: usageSchema.nullish()
|
|
1208
|
-
});
|
|
1209
|
-
var codeExecution = chunkHVBBFCDH_cjs.createProviderDefinedToolFactoryWithOutputSchema({
|
|
1210
|
-
id: "google.code_execution",
|
|
1211
|
-
name: "code_execution",
|
|
1212
|
-
inputSchema: v4.z.object({
|
|
1213
|
-
language: v4.z.string().describe("The programming language of the code."),
|
|
1214
|
-
code: v4.z.string().describe("The code to be executed.")
|
|
1215
|
-
}),
|
|
1216
|
-
outputSchema: v4.z.object({
|
|
1217
|
-
outcome: v4.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
1218
|
-
output: v4.z.string().describe("The output from the code execution.")
|
|
1219
|
-
})
|
|
1220
|
-
});
|
|
1221
|
-
var googleTools = {
|
|
1222
|
-
/**
|
|
1223
|
-
* Creates a Google search tool that gives Google direct access to real-time web content.
|
|
1224
|
-
* Must have name "google_search".
|
|
1225
|
-
*/
|
|
1226
|
-
googleSearch,
|
|
1227
|
-
/**
|
|
1228
|
-
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
1229
|
-
* Must have name "url_context".
|
|
1230
|
-
*/
|
|
1231
|
-
urlContext,
|
|
1232
|
-
/**
|
|
1233
|
-
* A tool that enables the model to generate and run Python code.
|
|
1234
|
-
* Must have name "code_execution".
|
|
1235
|
-
*
|
|
1236
|
-
* @note Ensure the selected model supports Code Execution.
|
|
1237
|
-
* Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
|
|
1238
|
-
*
|
|
1239
|
-
* @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
|
|
1240
|
-
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
|
|
1241
|
-
*/
|
|
1242
|
-
codeExecution
|
|
1243
|
-
};
|
|
1244
|
-
var GoogleGenerativeAIImageModel = class {
|
|
1245
|
-
constructor(modelId, settings, config) {
|
|
1246
|
-
this.modelId = modelId;
|
|
1247
|
-
this.settings = settings;
|
|
1248
|
-
this.config = config;
|
|
1249
|
-
this.specificationVersion = "v2";
|
|
1250
|
-
}
|
|
1251
|
-
get maxImagesPerCall() {
|
|
1252
|
-
var _a;
|
|
1253
|
-
return (_a = this.settings.maxImagesPerCall) != null ? _a : 4;
|
|
1254
|
-
}
|
|
1255
|
-
get provider() {
|
|
1256
|
-
return this.config.provider;
|
|
1257
|
-
}
|
|
1258
|
-
async doGenerate(options) {
|
|
1259
|
-
var _a, _b, _c;
|
|
1260
|
-
const {
|
|
1261
|
-
prompt,
|
|
1262
|
-
n = 1,
|
|
1263
|
-
size = "1024x1024",
|
|
1264
|
-
aspectRatio = "1:1",
|
|
1265
|
-
seed,
|
|
1266
|
-
providerOptions,
|
|
1267
|
-
headers,
|
|
1268
|
-
abortSignal
|
|
1269
|
-
} = options;
|
|
1270
|
-
const warnings = [];
|
|
1271
|
-
if (size != null) {
|
|
1272
|
-
warnings.push({
|
|
1273
|
-
type: "unsupported-setting",
|
|
1274
|
-
setting: "size",
|
|
1275
|
-
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
if (seed != null) {
|
|
1279
|
-
warnings.push({
|
|
1280
|
-
type: "unsupported-setting",
|
|
1281
|
-
setting: "seed",
|
|
1282
|
-
details: "This model does not support the `seed` option through this provider."
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
const googleOptions = await chunkHVBBFCDH_cjs.parseProviderOptions({
|
|
1286
|
-
provider: "google",
|
|
1287
|
-
providerOptions,
|
|
1288
|
-
schema: googleImageProviderOptionsSchema
|
|
1289
|
-
});
|
|
1290
|
-
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1291
|
-
const parameters = {
|
|
1292
|
-
sampleCount: n
|
|
1293
|
-
};
|
|
1294
|
-
if (aspectRatio != null) {
|
|
1295
|
-
parameters.aspectRatio = aspectRatio;
|
|
1296
|
-
}
|
|
1297
|
-
if (googleOptions) {
|
|
1298
|
-
Object.assign(parameters, googleOptions);
|
|
1299
|
-
}
|
|
1300
|
-
const body = {
|
|
1301
|
-
instances: [{ prompt }],
|
|
1302
|
-
parameters
|
|
1303
|
-
};
|
|
1304
|
-
const { responseHeaders, value: response } = await chunkHVBBFCDH_cjs.postJsonToApi({
|
|
1305
|
-
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
1306
|
-
headers: chunkHVBBFCDH_cjs.combineHeaders(await chunkHVBBFCDH_cjs.resolve(this.config.headers), headers),
|
|
1307
|
-
body,
|
|
1308
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
1309
|
-
successfulResponseHandler: chunkHVBBFCDH_cjs.createJsonResponseHandler(
|
|
1310
|
-
googleImageResponseSchema
|
|
1311
|
-
),
|
|
1312
|
-
abortSignal,
|
|
1313
|
-
fetch: this.config.fetch
|
|
1314
|
-
});
|
|
1315
|
-
return {
|
|
1316
|
-
images: response.predictions.map(
|
|
1317
|
-
(p) => p.bytesBase64Encoded
|
|
1318
|
-
),
|
|
1319
|
-
warnings: warnings != null ? warnings : [],
|
|
1320
|
-
providerMetadata: {
|
|
1321
|
-
google: {
|
|
1322
|
-
images: response.predictions.map((prediction) => ({
|
|
1323
|
-
// Add any prediction-specific metadata here
|
|
1324
|
-
}))
|
|
1325
|
-
}
|
|
1326
|
-
},
|
|
1327
|
-
response: {
|
|
1328
|
-
timestamp: currentDate,
|
|
1329
|
-
modelId: this.modelId,
|
|
1330
|
-
headers: responseHeaders
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
}
|
|
1334
|
-
};
|
|
1335
|
-
var googleImageResponseSchema = v4.z.object({
|
|
1336
|
-
predictions: v4.z.array(v4.z.object({ bytesBase64Encoded: v4.z.string() })).default([])
|
|
1337
|
-
});
|
|
1338
|
-
var googleImageProviderOptionsSchema = v4.z.object({
|
|
1339
|
-
personGeneration: v4.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
1340
|
-
aspectRatio: v4.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
1341
|
-
});
|
|
1342
|
-
function createGoogleGenerativeAI(options = {}) {
|
|
1343
|
-
var _a;
|
|
1344
|
-
const baseURL = (_a = chunkHVBBFCDH_cjs.withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
1345
|
-
const getHeaders = () => ({
|
|
1346
|
-
"x-goog-api-key": chunkHVBBFCDH_cjs.loadApiKey({
|
|
1347
|
-
apiKey: options.apiKey,
|
|
1348
|
-
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
1349
|
-
description: "Google Generative AI"
|
|
1350
|
-
}),
|
|
1351
|
-
...options.headers
|
|
1352
|
-
});
|
|
1353
|
-
const createChatModel = (modelId) => {
|
|
1354
|
-
var _a2;
|
|
1355
|
-
return new GoogleGenerativeAILanguageModel(modelId, {
|
|
1356
|
-
provider: "google.generative-ai",
|
|
1357
|
-
baseURL,
|
|
1358
|
-
headers: getHeaders,
|
|
1359
|
-
generateId: (_a2 = options.generateId) != null ? _a2 : chunkHVBBFCDH_cjs.generateId,
|
|
1360
|
-
supportedUrls: () => ({
|
|
1361
|
-
"*": [
|
|
1362
|
-
// Google Generative Language "files" endpoint
|
|
1363
|
-
// e.g. https://generativelanguage.googleapis.com/v1beta/files/...
|
|
1364
|
-
new RegExp(`^${baseURL}/files/.*$`),
|
|
1365
|
-
// YouTube URLs (public or unlisted videos)
|
|
1366
|
-
new RegExp(
|
|
1367
|
-
`^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
|
|
1368
|
-
),
|
|
1369
|
-
new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
|
|
1370
|
-
]
|
|
1371
|
-
}),
|
|
1372
|
-
fetch: options.fetch
|
|
1373
|
-
});
|
|
1374
|
-
};
|
|
1375
|
-
const createEmbeddingModel = (modelId) => new GoogleGenerativeAIEmbeddingModel(modelId, {
|
|
1376
|
-
provider: "google.generative-ai",
|
|
1377
|
-
baseURL,
|
|
1378
|
-
headers: getHeaders,
|
|
1379
|
-
fetch: options.fetch
|
|
1380
|
-
});
|
|
1381
|
-
const createImageModel = (modelId, settings = {}) => new GoogleGenerativeAIImageModel(modelId, settings, {
|
|
1382
|
-
provider: "google.generative-ai",
|
|
1383
|
-
baseURL,
|
|
1384
|
-
headers: getHeaders,
|
|
1385
|
-
fetch: options.fetch
|
|
1386
|
-
});
|
|
1387
|
-
const provider = function(modelId) {
|
|
1388
|
-
if (new.target) {
|
|
1389
|
-
throw new Error(
|
|
1390
|
-
"The Google Generative AI model function cannot be called with the new keyword."
|
|
1391
|
-
);
|
|
1392
|
-
}
|
|
1393
|
-
return createChatModel(modelId);
|
|
1394
|
-
};
|
|
1395
|
-
provider.languageModel = createChatModel;
|
|
1396
|
-
provider.chat = createChatModel;
|
|
1397
|
-
provider.generativeAI = createChatModel;
|
|
1398
|
-
provider.embedding = createEmbeddingModel;
|
|
1399
|
-
provider.textEmbedding = createEmbeddingModel;
|
|
1400
|
-
provider.textEmbeddingModel = createEmbeddingModel;
|
|
1401
|
-
provider.image = createImageModel;
|
|
1402
|
-
provider.imageModel = createImageModel;
|
|
1403
|
-
provider.tools = googleTools;
|
|
1404
|
-
return provider;
|
|
1405
|
-
}
|
|
1406
|
-
var google = createGoogleGenerativeAI();
|
|
1407
|
-
|
|
1408
|
-
exports.createGoogleGenerativeAI = createGoogleGenerativeAI;
|
|
1409
|
-
exports.google = google;
|
|
1410
|
-
//# sourceMappingURL=chunk-HZJRQ5L3.cjs.map
|
|
1411
|
-
//# sourceMappingURL=chunk-HZJRQ5L3.cjs.map
|