@mastra/core 1.0.0-beta.11 → 1.0.0-beta.13
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 +173 -0
- package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +7549 -0
- package/dist/_types/@internal_ai-sdk-v4/dist/test.d.ts +65 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +8396 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/test.d.ts +1708 -0
- package/dist/_types/@internal_external-types/dist/index.d.ts +858 -0
- package/dist/agent/agent-legacy.d.ts +1 -1
- package/dist/agent/agent.d.ts +1 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +5 -1
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +9 -9
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +4 -3
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts +1 -1
- package/dist/agent/message-list/prompt/invalid-content-error.d.ts +1 -1
- package/dist/agent/message-list/types.d.ts +3 -3
- package/dist/agent/message-list/types.d.ts.map +1 -1
- package/dist/agent/message-list/utils/ai-v4-v5/core-model-message.d.ts +1 -1
- package/dist/agent/message-list/utils/ai-v4-v5/ui-message.d.ts +1 -1
- package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts +2 -2
- package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts.map +1 -1
- package/dist/agent/message-list/utils/convert-messages.d.ts +2 -2
- package/dist/agent/message-list/utils/convert-messages.d.ts.map +1 -1
- package/dist/agent/types.d.ts +3 -3
- package/dist/agent/utils.d.ts +3 -3
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +2 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/bundler/types.d.ts +14 -1
- package/dist/bundler/types.d.ts.map +1 -1
- package/dist/{chunk-U3XOLEPX.js → chunk-2IU4RGU5.js} +6 -32
- package/dist/chunk-2IU4RGU5.js.map +1 -0
- package/dist/chunk-2SQB3WBT.js +4574 -0
- package/dist/chunk-2SQB3WBT.js.map +1 -0
- package/dist/{chunk-THZTRBFS.js → chunk-373OC54J.js} +8 -8
- package/dist/chunk-373OC54J.js.map +1 -0
- package/dist/{chunk-F2GAJSBI.js → chunk-4BC5FUAO.js} +8 -6
- package/dist/{chunk-F2GAJSBI.js.map → chunk-4BC5FUAO.js.map} +1 -1
- package/dist/chunk-55VPMN3N.js +250 -0
- package/dist/chunk-55VPMN3N.js.map +1 -0
- package/dist/{chunk-QM5SRDJX.js → chunk-5PTZG26U.js} +66 -84
- package/dist/chunk-5PTZG26U.js.map +1 -0
- package/dist/chunk-5VZGJTPR.js +4837 -0
- package/dist/chunk-5VZGJTPR.js.map +1 -0
- package/dist/{chunk-C36YRTZ6.js → chunk-62Q7K656.js} +6 -7
- package/dist/chunk-62Q7K656.js.map +1 -0
- package/dist/chunk-6PMMP3FR.js +7 -0
- package/dist/chunk-6PMMP3FR.js.map +1 -0
- package/dist/{chunk-DZUJEN5N.cjs → chunk-6SZKM6EC.cjs} +10 -3
- package/dist/{chunk-DZUJEN5N.cjs.map → chunk-6SZKM6EC.cjs.map} +1 -1
- package/dist/{chunk-5WRI5ZAA.js → chunk-7D4SUZUM.js} +10 -4
- package/dist/{chunk-5WRI5ZAA.js.map → chunk-7D4SUZUM.js.map} +1 -1
- package/dist/{chunk-YWMMBIOM.cjs → chunk-7HEAVZRS.cjs} +15 -15
- package/dist/{chunk-YWMMBIOM.cjs.map → chunk-7HEAVZRS.cjs.map} +1 -1
- package/dist/{chunk-BUKY6CTR.cjs → chunk-AGHLXC4I.cjs} +106 -36
- package/dist/chunk-AGHLXC4I.cjs.map +1 -0
- package/dist/{chunk-PK2A5WBG.js → chunk-ARAQIW6E.js} +222 -604
- package/dist/chunk-ARAQIW6E.js.map +1 -0
- package/dist/{chunk-US2U7ECW.js → chunk-BQDZIQ3G.js} +156 -90
- package/dist/chunk-BQDZIQ3G.js.map +1 -0
- package/dist/chunk-D22XABFZ.js +79 -0
- package/dist/chunk-D22XABFZ.js.map +1 -0
- package/dist/{chunk-2ULLRN4Y.js → chunk-E5BQRAJK.js} +943 -626
- package/dist/chunk-E5BQRAJK.js.map +1 -0
- package/dist/chunk-FST2G2FQ.cjs +84 -0
- package/dist/chunk-FST2G2FQ.cjs.map +1 -0
- package/dist/chunk-FVQTJUBD.cjs +2120 -0
- package/dist/chunk-FVQTJUBD.cjs.map +1 -0
- package/dist/chunk-G6E6V2Z4.js +2070 -0
- package/dist/chunk-G6E6V2Z4.js.map +1 -0
- package/dist/{chunk-7P6BNIJH.js → chunk-GIWC35YQ.js} +105 -35
- package/dist/chunk-GIWC35YQ.js.map +1 -0
- package/dist/{chunk-4JKEUSCC.cjs → chunk-H4VUIOWU.cjs} +22 -20
- package/dist/chunk-H4VUIOWU.cjs.map +1 -0
- package/dist/{chunk-TWH4PTDG.cjs → chunk-HWMMIRIF.cjs} +32 -27
- package/dist/chunk-HWMMIRIF.cjs.map +1 -0
- package/dist/chunk-IXZ2T2QX.cjs +448 -0
- package/dist/chunk-IXZ2T2QX.cjs.map +1 -0
- package/dist/chunk-L3NKIMF5.cjs +10 -0
- package/dist/chunk-L3NKIMF5.cjs.map +1 -0
- package/dist/chunk-L4JCRWDY.cjs +252 -0
- package/dist/chunk-L4JCRWDY.cjs.map +1 -0
- package/dist/{chunk-BJXKH4LG.cjs → chunk-LGB4VNZI.cjs} +43 -78
- package/dist/chunk-LGB4VNZI.cjs.map +1 -0
- package/dist/{chunk-PG5H6QIO.cjs → chunk-MLKE7HRS.cjs} +41 -21
- package/dist/chunk-MLKE7HRS.cjs.map +1 -0
- package/dist/{chunk-OEIVMCWX.js → chunk-MRRFTNF4.js} +2537 -84
- package/dist/chunk-MRRFTNF4.js.map +1 -0
- package/dist/chunk-MXBVP7HX.cjs +4842 -0
- package/dist/chunk-MXBVP7HX.cjs.map +1 -0
- package/dist/chunk-NESKUIRE.cjs +4586 -0
- package/dist/chunk-NESKUIRE.cjs.map +1 -0
- package/dist/{chunk-SVLMF4UZ.cjs → chunk-NIOEY3N3.cjs} +66 -85
- package/dist/chunk-NIOEY3N3.cjs.map +1 -0
- package/dist/{chunk-CZEJQSWB.cjs → chunk-OWIEOL55.cjs} +295 -677
- package/dist/chunk-OWIEOL55.cjs.map +1 -0
- package/dist/{chunk-WTSZBHIZ.cjs → chunk-PJAK4U6R.cjs} +24 -24
- package/dist/{chunk-WTSZBHIZ.cjs.map → chunk-PJAK4U6R.cjs.map} +1 -1
- package/dist/{chunk-52RSUALV.cjs → chunk-R5AJGM55.cjs} +1314 -995
- package/dist/chunk-R5AJGM55.cjs.map +1 -0
- package/dist/{chunk-IVV5TOMD.js → chunk-RCJLMMTO.js} +32 -12
- package/dist/chunk-RCJLMMTO.js.map +1 -0
- package/dist/{chunk-S73Z3PBJ.cjs → chunk-SZYSDJTN.cjs} +27 -28
- package/dist/chunk-SZYSDJTN.cjs.map +1 -0
- package/dist/{chunk-YC6PJEPH.cjs → chunk-U4CSOY6T.cjs} +188 -122
- package/dist/chunk-U4CSOY6T.cjs.map +1 -0
- package/dist/chunk-UBSPZTQX.js +434 -0
- package/dist/chunk-UBSPZTQX.js.map +1 -0
- package/dist/{chunk-SCUWP4II.cjs → chunk-VEPP75C4.cjs} +47 -74
- package/dist/chunk-VEPP75C4.cjs.map +1 -0
- package/dist/{chunk-JIGDJK2O.js → chunk-VETAQUW3.js} +4 -39
- package/dist/chunk-VETAQUW3.js.map +1 -0
- package/dist/{chunk-Z57R5WS4.js → chunk-WPTTKULS.js} +4 -4
- package/dist/{chunk-Z57R5WS4.js.map → chunk-WPTTKULS.js.map} +1 -1
- package/dist/{chunk-O2BJW7YA.js → chunk-WYGUWVTF.js} +5 -5
- package/dist/{chunk-O2BJW7YA.js.map → chunk-WYGUWVTF.js.map} +1 -1
- package/dist/{chunk-SXNQRJQD.js → chunk-WYWRMIQC.js} +127 -22
- package/dist/chunk-WYWRMIQC.js.map +1 -0
- package/dist/{chunk-5Q6WAYEY.cjs → chunk-X6IBA7FP.cjs} +137 -50
- package/dist/chunk-X6IBA7FP.cjs.map +1 -0
- package/dist/{chunk-MRFUISXC.cjs → chunk-Y7MZ5LJT.cjs} +2632 -179
- package/dist/chunk-Y7MZ5LJT.cjs.map +1 -0
- package/dist/{chunk-JJ5O45LH.js → chunk-YPLZDWG7.js} +32 -27
- package/dist/chunk-YPLZDWG7.js.map +1 -0
- package/dist/{chunk-MGCGWPQJ.cjs → chunk-Z55SJVEC.cjs} +8 -8
- package/dist/chunk-Z55SJVEC.cjs.map +1 -0
- package/dist/error/index.cjs +6 -6
- package/dist/error/index.d.ts +26 -20
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/error/utils.d.ts +19 -5
- package/dist/error/utils.d.ts.map +1 -1
- package/dist/evals/index.cjs +4 -4
- package/dist/evals/index.js +1 -1
- package/dist/evals/run/index.d.ts +1 -1
- package/dist/evals/scoreTraces/index.cjs +8 -8
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/evals/types.d.ts +1 -1
- package/dist/events/event-emitter.d.ts +6 -1
- package/dist/events/event-emitter.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +15 -15
- package/dist/llm/index.d.ts +2 -2
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/aisdk/v5/model.d.ts +1 -1
- package/dist/llm/model/base.types.d.ts +2 -2
- package/dist/llm/model/model.d.ts +1 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +2 -2
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +1 -1
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +51 -11
- package/dist/llm/model/shared.types.d.ts +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts +2 -2
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/test-utils/streamObject.d.ts +1 -1
- package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/types.d.ts +3 -1
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +13 -13
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +10 -10
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +5 -5
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +22 -21
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +13 -13
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +6 -6
- package/dist/loop/workflows/schema.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts +2 -2
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.js +1 -1
- package/dist/memory/index.cjs +6 -6
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +1 -1
- package/dist/memory/types.d.ts +3 -3
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-D3EKFGAO.cjs +12 -0
- package/dist/{models-dev-EO3SUIY2.cjs.map → models-dev-D3EKFGAO.cjs.map} +1 -1
- package/dist/models-dev-EO22XOXQ.js +3 -0
- package/dist/{models-dev-23RN2WHG.js.map → models-dev-EO22XOXQ.js.map} +1 -1
- package/dist/netlify-AE4LNCAI.js +3 -0
- package/dist/{netlify-GXJ5D5DD.js.map → netlify-AE4LNCAI.js.map} +1 -1
- package/dist/netlify-WE42TZIT.cjs +12 -0
- package/dist/{netlify-KJLY3GFS.cjs.map → netlify-WE42TZIT.cjs.map} +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.d.ts +2 -2
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/step-schema.d.ts +1267 -1267
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-6LF3NGC5.js +3 -0
- package/dist/{provider-registry-F67Y6OF2.js.map → provider-registry-6LF3NGC5.js.map} +1 -1
- package/dist/provider-registry-73FKMXJV.cjs +40 -0
- package/dist/{provider-registry-3TG2KUD2.cjs.map → provider-registry-73FKMXJV.cjs.map} +1 -1
- package/dist/provider-registry.json +100 -30
- package/dist/{registry-generator-UMTNPBJX.js → registry-generator-AVQXI3GX.js} +2 -2
- package/dist/{registry-generator-UMTNPBJX.js.map → registry-generator-AVQXI3GX.js.map} +1 -1
- package/dist/{registry-generator-34SC4TAU.cjs → registry-generator-KOFNIIWJ.cjs} +2 -2
- package/dist/{registry-generator-34SC4TAU.cjs.map → registry-generator-KOFNIIWJ.cjs.map} +1 -1
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +5 -5
- package/dist/server/index.js +1 -1
- package/dist/storage/base.d.ts +2 -10
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/base.d.ts +2 -8
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +2 -8
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +38 -38
- package/dist/storage/index.js +1 -1
- package/dist/storage/mock.d.ts +2 -8
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +9 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts +1 -1
- package/dist/stream/aisdk/v4/input.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/content.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/content.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/validation.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/validation.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +2 -2
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/input.d.ts +1 -1
- package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output-helpers.d.ts +12 -27
- package/dist/stream/aisdk/v5/output-helpers.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +41 -91
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/input.d.ts +1 -1
- package/dist/stream/base/output.d.ts +9 -31
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/base/schema.d.ts +2 -2
- package/dist/stream/base/schema.d.ts.map +1 -1
- package/dist/stream/index.cjs +12 -12
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +3 -2
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +14587 -14
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.d.ts +3 -3
- package/dist/test-utils/llm-mock.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.js +14577 -4
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/token-6GSAFR2W-SGVIXFCP.cjs +63 -0
- package/dist/token-6GSAFR2W-SGVIXFCP.cjs.map +1 -0
- package/dist/token-6GSAFR2W-SPYPLMBM.js +61 -0
- package/dist/token-6GSAFR2W-SPYPLMBM.js.map +1 -0
- package/dist/token-util-NEHG7TUY-7GMW5FXI.cjs +10 -0
- package/dist/token-util-NEHG7TUY-7GMW5FXI.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-JRJTGTAB.js +8 -0
- package/dist/token-util-NEHG7TUY-JRJTGTAB.js.map +1 -0
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts +2 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/embed.d.ts +2 -2
- package/dist/vector/embed.d.ts.map +1 -1
- package/dist/vector/index.cjs +11 -11
- package/dist/vector/index.js +3 -3
- package/dist/vector/vector.d.ts +1 -1
- package/dist/voice/aisdk/speech.d.ts +1 -1
- package/dist/voice/aisdk/speech.d.ts.map +1 -1
- package/dist/voice/aisdk/transcription.d.ts +1 -1
- package/dist/voice/aisdk/transcription.d.ts.map +1 -1
- package/dist/voice/composite-voice.d.ts +1 -1
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/constants.cjs +4 -4
- package/dist/workflows/constants.d.ts +1 -1
- package/dist/workflows/constants.d.ts.map +1 -1
- package/dist/workflows/constants.js +1 -1
- package/dist/workflows/default.d.ts +9 -16
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +3 -2
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +15 -0
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +25 -2
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +6 -5
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/entry.d.ts +5 -3
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/handlers/sleep.d.ts +4 -3
- package/dist/workflows/handlers/sleep.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +5 -3
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +26 -22
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +5 -4
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +66 -14
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +11 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +26 -8
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +12 -11
- package/src/llm/model/provider-types.generated.d.ts +51 -11
- package/dist/agent/__tests__/mock-model.d.ts +0 -8
- package/dist/agent/__tests__/mock-model.d.ts.map +0 -1
- package/dist/agent/agent-types.test-d.d.ts +0 -2
- package/dist/agent/agent-types.test-d.d.ts.map +0 -1
- package/dist/ai-sdk.types.d.ts +0 -4705
- package/dist/chunk-2ULLRN4Y.js.map +0 -1
- package/dist/chunk-3E3ILV6T.cjs +0 -518
- package/dist/chunk-3E3ILV6T.cjs.map +0 -1
- package/dist/chunk-4JKEUSCC.cjs.map +0 -1
- package/dist/chunk-52RSUALV.cjs.map +0 -1
- package/dist/chunk-5PAEYE3Q.js +0 -513
- package/dist/chunk-5PAEYE3Q.js.map +0 -1
- package/dist/chunk-5Q6WAYEY.cjs.map +0 -1
- package/dist/chunk-7P6BNIJH.js.map +0 -1
- package/dist/chunk-ABJOUEVA.cjs +0 -10
- package/dist/chunk-ABJOUEVA.cjs.map +0 -1
- package/dist/chunk-BJXKH4LG.cjs.map +0 -1
- package/dist/chunk-BUKY6CTR.cjs.map +0 -1
- package/dist/chunk-C36YRTZ6.js.map +0 -1
- package/dist/chunk-CZEJQSWB.cjs.map +0 -1
- package/dist/chunk-IVV5TOMD.js.map +0 -1
- package/dist/chunk-JIGDJK2O.js.map +0 -1
- package/dist/chunk-JJ5O45LH.js.map +0 -1
- package/dist/chunk-MGCGWPQJ.cjs.map +0 -1
- package/dist/chunk-MRFUISXC.cjs.map +0 -1
- package/dist/chunk-NLNKQD2T.js +0 -7
- package/dist/chunk-NLNKQD2T.js.map +0 -1
- package/dist/chunk-OEIVMCWX.js.map +0 -1
- package/dist/chunk-PG5H6QIO.cjs.map +0 -1
- package/dist/chunk-PK2A5WBG.js.map +0 -1
- package/dist/chunk-QM5SRDJX.js.map +0 -1
- package/dist/chunk-S73Z3PBJ.cjs.map +0 -1
- package/dist/chunk-SCUWP4II.cjs.map +0 -1
- package/dist/chunk-SVLMF4UZ.cjs.map +0 -1
- package/dist/chunk-SXNQRJQD.js.map +0 -1
- package/dist/chunk-THZTRBFS.js.map +0 -1
- package/dist/chunk-TWH4PTDG.cjs.map +0 -1
- package/dist/chunk-U3XOLEPX.js.map +0 -1
- package/dist/chunk-US2U7ECW.js.map +0 -1
- package/dist/chunk-YC6PJEPH.cjs.map +0 -1
- package/dist/models-dev-23RN2WHG.js +0 -3
- package/dist/models-dev-EO3SUIY2.cjs +0 -12
- package/dist/netlify-GXJ5D5DD.js +0 -3
- package/dist/netlify-KJLY3GFS.cjs +0 -12
- package/dist/provider-registry-3TG2KUD2.cjs +0 -40
- package/dist/provider-registry-F67Y6OF2.js +0 -3
- package/dist/tools/tool-stream-types.test-d.d.ts +0 -2
- package/dist/tools/tool-stream-types.test-d.d.ts.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkIXZ2T2QX_cjs = require('./chunk-IXZ2T2QX.cjs');
|
|
3
4
|
var z4 = require('zod/v4');
|
|
4
5
|
var v3 = require('zod/v3');
|
|
5
6
|
|
|
@@ -23,421 +24,6 @@ function _interopNamespace(e) {
|
|
|
23
24
|
|
|
24
25
|
var z4__namespace = /*#__PURE__*/_interopNamespace(z4);
|
|
25
26
|
|
|
26
|
-
// ../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
27
|
-
var marker = "vercel.ai.error";
|
|
28
|
-
var symbol = Symbol.for(marker);
|
|
29
|
-
var _a;
|
|
30
|
-
var _AISDKError = class _AISDKError2 extends Error {
|
|
31
|
-
/**
|
|
32
|
-
* Creates an AI SDK Error.
|
|
33
|
-
*
|
|
34
|
-
* @param {Object} params - The parameters for creating the error.
|
|
35
|
-
* @param {string} params.name - The name of the error.
|
|
36
|
-
* @param {string} params.message - The error message.
|
|
37
|
-
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
38
|
-
*/
|
|
39
|
-
constructor({
|
|
40
|
-
name: name14,
|
|
41
|
-
message,
|
|
42
|
-
cause
|
|
43
|
-
}) {
|
|
44
|
-
super(message);
|
|
45
|
-
this[_a] = true;
|
|
46
|
-
this.name = name14;
|
|
47
|
-
this.cause = cause;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Checks if the given error is an AI SDK Error.
|
|
51
|
-
* @param {unknown} error - The error to check.
|
|
52
|
-
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
53
|
-
*/
|
|
54
|
-
static isInstance(error) {
|
|
55
|
-
return _AISDKError2.hasMarker(error, marker);
|
|
56
|
-
}
|
|
57
|
-
static hasMarker(error, marker15) {
|
|
58
|
-
const markerSymbol = Symbol.for(marker15);
|
|
59
|
-
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
_a = symbol;
|
|
63
|
-
var AISDKError = _AISDKError;
|
|
64
|
-
var name = "AI_APICallError";
|
|
65
|
-
var marker2 = `vercel.ai.error.${name}`;
|
|
66
|
-
var symbol2 = Symbol.for(marker2);
|
|
67
|
-
var _a2;
|
|
68
|
-
var APICallError = class extends AISDKError {
|
|
69
|
-
constructor({
|
|
70
|
-
message,
|
|
71
|
-
url,
|
|
72
|
-
requestBodyValues,
|
|
73
|
-
statusCode,
|
|
74
|
-
responseHeaders,
|
|
75
|
-
responseBody,
|
|
76
|
-
cause,
|
|
77
|
-
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
|
78
|
-
statusCode === 409 || // conflict
|
|
79
|
-
statusCode === 429 || // too many requests
|
|
80
|
-
statusCode >= 500),
|
|
81
|
-
// server error
|
|
82
|
-
data
|
|
83
|
-
}) {
|
|
84
|
-
super({ name, message, cause });
|
|
85
|
-
this[_a2] = true;
|
|
86
|
-
this.url = url;
|
|
87
|
-
this.requestBodyValues = requestBodyValues;
|
|
88
|
-
this.statusCode = statusCode;
|
|
89
|
-
this.responseHeaders = responseHeaders;
|
|
90
|
-
this.responseBody = responseBody;
|
|
91
|
-
this.isRetryable = isRetryable;
|
|
92
|
-
this.data = data;
|
|
93
|
-
}
|
|
94
|
-
static isInstance(error) {
|
|
95
|
-
return AISDKError.hasMarker(error, marker2);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
_a2 = symbol2;
|
|
99
|
-
var name2 = "AI_EmptyResponseBodyError";
|
|
100
|
-
var marker3 = `vercel.ai.error.${name2}`;
|
|
101
|
-
var symbol3 = Symbol.for(marker3);
|
|
102
|
-
var _a3;
|
|
103
|
-
var EmptyResponseBodyError = class extends AISDKError {
|
|
104
|
-
// used in isInstance
|
|
105
|
-
constructor({ message = "Empty response body" } = {}) {
|
|
106
|
-
super({ name: name2, message });
|
|
107
|
-
this[_a3] = true;
|
|
108
|
-
}
|
|
109
|
-
static isInstance(error) {
|
|
110
|
-
return AISDKError.hasMarker(error, marker3);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
_a3 = symbol3;
|
|
114
|
-
function getErrorMessage(error) {
|
|
115
|
-
if (error == null) {
|
|
116
|
-
return "unknown error";
|
|
117
|
-
}
|
|
118
|
-
if (typeof error === "string") {
|
|
119
|
-
return error;
|
|
120
|
-
}
|
|
121
|
-
if (error instanceof Error) {
|
|
122
|
-
return error.message;
|
|
123
|
-
}
|
|
124
|
-
return JSON.stringify(error);
|
|
125
|
-
}
|
|
126
|
-
var name3 = "AI_InvalidArgumentError";
|
|
127
|
-
var marker4 = `vercel.ai.error.${name3}`;
|
|
128
|
-
var symbol4 = Symbol.for(marker4);
|
|
129
|
-
var _a4;
|
|
130
|
-
var InvalidArgumentError = class extends AISDKError {
|
|
131
|
-
constructor({
|
|
132
|
-
message,
|
|
133
|
-
cause,
|
|
134
|
-
argument
|
|
135
|
-
}) {
|
|
136
|
-
super({ name: name3, message, cause });
|
|
137
|
-
this[_a4] = true;
|
|
138
|
-
this.argument = argument;
|
|
139
|
-
}
|
|
140
|
-
static isInstance(error) {
|
|
141
|
-
return AISDKError.hasMarker(error, marker4);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
_a4 = symbol4;
|
|
145
|
-
var name4 = "AI_InvalidPromptError";
|
|
146
|
-
var marker5 = `vercel.ai.error.${name4}`;
|
|
147
|
-
var symbol5 = Symbol.for(marker5);
|
|
148
|
-
var _a5;
|
|
149
|
-
var InvalidPromptError = class extends AISDKError {
|
|
150
|
-
constructor({
|
|
151
|
-
prompt,
|
|
152
|
-
message,
|
|
153
|
-
cause
|
|
154
|
-
}) {
|
|
155
|
-
super({ name: name4, message: `Invalid prompt: ${message}`, cause });
|
|
156
|
-
this[_a5] = true;
|
|
157
|
-
this.prompt = prompt;
|
|
158
|
-
}
|
|
159
|
-
static isInstance(error) {
|
|
160
|
-
return AISDKError.hasMarker(error, marker5);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
_a5 = symbol5;
|
|
164
|
-
var name5 = "AI_InvalidResponseDataError";
|
|
165
|
-
var marker6 = `vercel.ai.error.${name5}`;
|
|
166
|
-
var symbol6 = Symbol.for(marker6);
|
|
167
|
-
var _a6;
|
|
168
|
-
var InvalidResponseDataError = class extends AISDKError {
|
|
169
|
-
constructor({
|
|
170
|
-
data,
|
|
171
|
-
message = `Invalid response data: ${JSON.stringify(data)}.`
|
|
172
|
-
}) {
|
|
173
|
-
super({ name: name5, message });
|
|
174
|
-
this[_a6] = true;
|
|
175
|
-
this.data = data;
|
|
176
|
-
}
|
|
177
|
-
static isInstance(error) {
|
|
178
|
-
return AISDKError.hasMarker(error, marker6);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
_a6 = symbol6;
|
|
182
|
-
var name6 = "AI_JSONParseError";
|
|
183
|
-
var marker7 = `vercel.ai.error.${name6}`;
|
|
184
|
-
var symbol7 = Symbol.for(marker7);
|
|
185
|
-
var _a7;
|
|
186
|
-
var JSONParseError = class extends AISDKError {
|
|
187
|
-
constructor({ text, cause }) {
|
|
188
|
-
super({
|
|
189
|
-
name: name6,
|
|
190
|
-
message: `JSON parsing failed: Text: ${text}.
|
|
191
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
192
|
-
cause
|
|
193
|
-
});
|
|
194
|
-
this[_a7] = true;
|
|
195
|
-
this.text = text;
|
|
196
|
-
}
|
|
197
|
-
static isInstance(error) {
|
|
198
|
-
return AISDKError.hasMarker(error, marker7);
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
_a7 = symbol7;
|
|
202
|
-
var name7 = "AI_LoadAPIKeyError";
|
|
203
|
-
var marker8 = `vercel.ai.error.${name7}`;
|
|
204
|
-
var symbol8 = Symbol.for(marker8);
|
|
205
|
-
var _a8;
|
|
206
|
-
var LoadAPIKeyError = class extends AISDKError {
|
|
207
|
-
// used in isInstance
|
|
208
|
-
constructor({ message }) {
|
|
209
|
-
super({ name: name7, message });
|
|
210
|
-
this[_a8] = true;
|
|
211
|
-
}
|
|
212
|
-
static isInstance(error) {
|
|
213
|
-
return AISDKError.hasMarker(error, marker8);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
_a8 = symbol8;
|
|
217
|
-
var name10 = "AI_NoSuchModelError";
|
|
218
|
-
var marker11 = `vercel.ai.error.${name10}`;
|
|
219
|
-
var symbol11 = Symbol.for(marker11);
|
|
220
|
-
var _a11;
|
|
221
|
-
var NoSuchModelError = class extends AISDKError {
|
|
222
|
-
constructor({
|
|
223
|
-
errorName = name10,
|
|
224
|
-
modelId,
|
|
225
|
-
modelType,
|
|
226
|
-
message = `No such ${modelType}: ${modelId}`
|
|
227
|
-
}) {
|
|
228
|
-
super({ name: errorName, message });
|
|
229
|
-
this[_a11] = true;
|
|
230
|
-
this.modelId = modelId;
|
|
231
|
-
this.modelType = modelType;
|
|
232
|
-
}
|
|
233
|
-
static isInstance(error) {
|
|
234
|
-
return AISDKError.hasMarker(error, marker11);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
_a11 = symbol11;
|
|
238
|
-
var name11 = "AI_TooManyEmbeddingValuesForCallError";
|
|
239
|
-
var marker12 = `vercel.ai.error.${name11}`;
|
|
240
|
-
var symbol12 = Symbol.for(marker12);
|
|
241
|
-
var _a12;
|
|
242
|
-
var TooManyEmbeddingValuesForCallError = class extends AISDKError {
|
|
243
|
-
constructor(options) {
|
|
244
|
-
super({
|
|
245
|
-
name: name11,
|
|
246
|
-
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
247
|
-
});
|
|
248
|
-
this[_a12] = true;
|
|
249
|
-
this.provider = options.provider;
|
|
250
|
-
this.modelId = options.modelId;
|
|
251
|
-
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
252
|
-
this.values = options.values;
|
|
253
|
-
}
|
|
254
|
-
static isInstance(error) {
|
|
255
|
-
return AISDKError.hasMarker(error, marker12);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
_a12 = symbol12;
|
|
259
|
-
var name12 = "AI_TypeValidationError";
|
|
260
|
-
var marker13 = `vercel.ai.error.${name12}`;
|
|
261
|
-
var symbol13 = Symbol.for(marker13);
|
|
262
|
-
var _a13;
|
|
263
|
-
var _TypeValidationError = class _TypeValidationError2 extends AISDKError {
|
|
264
|
-
constructor({ value, cause }) {
|
|
265
|
-
super({
|
|
266
|
-
name: name12,
|
|
267
|
-
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
268
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
269
|
-
cause
|
|
270
|
-
});
|
|
271
|
-
this[_a13] = true;
|
|
272
|
-
this.value = value;
|
|
273
|
-
}
|
|
274
|
-
static isInstance(error) {
|
|
275
|
-
return AISDKError.hasMarker(error, marker13);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Wraps an error into a TypeValidationError.
|
|
279
|
-
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
280
|
-
* Otherwise, it creates a new TypeValidationError.
|
|
281
|
-
*
|
|
282
|
-
* @param {Object} params - The parameters for wrapping the error.
|
|
283
|
-
* @param {unknown} params.value - The value that failed validation.
|
|
284
|
-
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
285
|
-
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
286
|
-
*/
|
|
287
|
-
static wrap({
|
|
288
|
-
value,
|
|
289
|
-
cause
|
|
290
|
-
}) {
|
|
291
|
-
return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
_a13 = symbol13;
|
|
295
|
-
var TypeValidationError = _TypeValidationError;
|
|
296
|
-
var name13 = "AI_UnsupportedFunctionalityError";
|
|
297
|
-
var marker14 = `vercel.ai.error.${name13}`;
|
|
298
|
-
var symbol14 = Symbol.for(marker14);
|
|
299
|
-
var _a14;
|
|
300
|
-
var UnsupportedFunctionalityError = class extends AISDKError {
|
|
301
|
-
constructor({
|
|
302
|
-
functionality,
|
|
303
|
-
message = `'${functionality}' functionality not supported.`
|
|
304
|
-
}) {
|
|
305
|
-
super({ name: name13, message });
|
|
306
|
-
this[_a14] = true;
|
|
307
|
-
this.functionality = functionality;
|
|
308
|
-
}
|
|
309
|
-
static isInstance(error) {
|
|
310
|
-
return AISDKError.hasMarker(error, marker14);
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
_a14 = symbol14;
|
|
314
|
-
|
|
315
|
-
// ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/index.js
|
|
316
|
-
var ParseError = class extends Error {
|
|
317
|
-
constructor(message, options) {
|
|
318
|
-
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
function noop(_arg) {
|
|
322
|
-
}
|
|
323
|
-
function createParser(callbacks) {
|
|
324
|
-
if (typeof callbacks == "function")
|
|
325
|
-
throw new TypeError(
|
|
326
|
-
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
327
|
-
);
|
|
328
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
329
|
-
let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
|
|
330
|
-
function feed(newChunk) {
|
|
331
|
-
const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
|
|
332
|
-
for (const line of complete)
|
|
333
|
-
parseLine(line);
|
|
334
|
-
incompleteLine = incomplete, isFirstChunk = false;
|
|
335
|
-
}
|
|
336
|
-
function parseLine(line) {
|
|
337
|
-
if (line === "") {
|
|
338
|
-
dispatchEvent();
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
if (line.startsWith(":")) {
|
|
342
|
-
onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const fieldSeparatorIndex = line.indexOf(":");
|
|
346
|
-
if (fieldSeparatorIndex !== -1) {
|
|
347
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
348
|
-
processField(field, value, line);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
processField(line, "", line);
|
|
352
|
-
}
|
|
353
|
-
function processField(field, value, line) {
|
|
354
|
-
switch (field) {
|
|
355
|
-
case "event":
|
|
356
|
-
eventType = value;
|
|
357
|
-
break;
|
|
358
|
-
case "data":
|
|
359
|
-
data = `${data}${value}
|
|
360
|
-
`;
|
|
361
|
-
break;
|
|
362
|
-
case "id":
|
|
363
|
-
id = value.includes("\0") ? void 0 : value;
|
|
364
|
-
break;
|
|
365
|
-
case "retry":
|
|
366
|
-
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
367
|
-
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
368
|
-
type: "invalid-retry",
|
|
369
|
-
value,
|
|
370
|
-
line
|
|
371
|
-
})
|
|
372
|
-
);
|
|
373
|
-
break;
|
|
374
|
-
default:
|
|
375
|
-
onError(
|
|
376
|
-
new ParseError(
|
|
377
|
-
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
378
|
-
{ type: "unknown-field", field, value, line }
|
|
379
|
-
)
|
|
380
|
-
);
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
function dispatchEvent() {
|
|
385
|
-
data.length > 0 && onEvent({
|
|
386
|
-
id,
|
|
387
|
-
event: eventType || void 0,
|
|
388
|
-
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
|
|
389
|
-
// then remove the last character from the data buffer.
|
|
390
|
-
data: data.endsWith(`
|
|
391
|
-
`) ? data.slice(0, -1) : data
|
|
392
|
-
}), id = void 0, data = "", eventType = "";
|
|
393
|
-
}
|
|
394
|
-
function reset(options = {}) {
|
|
395
|
-
incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
|
|
396
|
-
}
|
|
397
|
-
return { feed, reset };
|
|
398
|
-
}
|
|
399
|
-
function splitLines(chunk) {
|
|
400
|
-
const lines = [];
|
|
401
|
-
let incompleteLine = "", searchIndex = 0;
|
|
402
|
-
for (; searchIndex < chunk.length; ) {
|
|
403
|
-
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
404
|
-
`, searchIndex);
|
|
405
|
-
let lineEnd = -1;
|
|
406
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
407
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
408
|
-
break;
|
|
409
|
-
} else {
|
|
410
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
411
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
412
|
-
` && searchIndex++;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
return [lines, incompleteLine];
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/stream.js
|
|
419
|
-
var EventSourceParserStream = class extends TransformStream {
|
|
420
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
421
|
-
let parser;
|
|
422
|
-
super({
|
|
423
|
-
start(controller) {
|
|
424
|
-
parser = createParser({
|
|
425
|
-
onEvent: (event) => {
|
|
426
|
-
controller.enqueue(event);
|
|
427
|
-
},
|
|
428
|
-
onError(error) {
|
|
429
|
-
onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
|
|
430
|
-
},
|
|
431
|
-
onRetry,
|
|
432
|
-
onComment
|
|
433
|
-
});
|
|
434
|
-
},
|
|
435
|
-
transform(chunk) {
|
|
436
|
-
parser.feed(chunk);
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
27
|
function combineHeaders(...headers) {
|
|
442
28
|
return headers.reduce(
|
|
443
29
|
(combinedHeaders, currentHeaders) => ({
|
|
@@ -468,7 +54,7 @@ var createIdGenerator = ({
|
|
|
468
54
|
return generator;
|
|
469
55
|
}
|
|
470
56
|
if (alphabet.includes(separator)) {
|
|
471
|
-
throw new InvalidArgumentError({
|
|
57
|
+
throw new chunkIXZ2T2QX_cjs.InvalidArgumentError({
|
|
472
58
|
argument: "separator",
|
|
473
59
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
474
60
|
});
|
|
@@ -492,7 +78,7 @@ function handleFetchError({
|
|
|
492
78
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
493
79
|
const cause = error.cause;
|
|
494
80
|
if (cause != null) {
|
|
495
|
-
return new APICallError({
|
|
81
|
+
return new chunkIXZ2T2QX_cjs.APICallError({
|
|
496
82
|
message: `Cannot connect to API: ${cause.message}`,
|
|
497
83
|
cause,
|
|
498
84
|
url,
|
|
@@ -505,11 +91,11 @@ function handleFetchError({
|
|
|
505
91
|
return error;
|
|
506
92
|
}
|
|
507
93
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
508
|
-
var
|
|
94
|
+
var _a, _b, _c;
|
|
509
95
|
if (globalThisAny.window) {
|
|
510
96
|
return `runtime/browser`;
|
|
511
97
|
}
|
|
512
|
-
if ((
|
|
98
|
+
if ((_a = globalThisAny.navigator) == null ? void 0 : _a.userAgent) {
|
|
513
99
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
514
100
|
}
|
|
515
101
|
if ((_c = (_b = globalThisAny.process) == null ? void 0 : _b.versions) == null ? void 0 : _c.node) {
|
|
@@ -575,8 +161,8 @@ function injectJsonInstructionIntoMessages({
|
|
|
575
161
|
schemaPrefix,
|
|
576
162
|
schemaSuffix
|
|
577
163
|
}) {
|
|
578
|
-
var
|
|
579
|
-
const systemMessage = ((
|
|
164
|
+
var _a, _b;
|
|
165
|
+
const systemMessage = ((_a = messages[0]) == null ? void 0 : _a.role) === "system" ? { ...messages[0] } : { role: "system", content: "" };
|
|
580
166
|
systemMessage.content = injectJsonInstruction({
|
|
581
167
|
prompt: systemMessage.content,
|
|
582
168
|
schema,
|
|
@@ -598,23 +184,23 @@ function loadApiKey({
|
|
|
598
184
|
return apiKey;
|
|
599
185
|
}
|
|
600
186
|
if (apiKey != null) {
|
|
601
|
-
throw new LoadAPIKeyError({
|
|
187
|
+
throw new chunkIXZ2T2QX_cjs.LoadAPIKeyError({
|
|
602
188
|
message: `${description} API key must be a string.`
|
|
603
189
|
});
|
|
604
190
|
}
|
|
605
191
|
if (typeof process === "undefined") {
|
|
606
|
-
throw new LoadAPIKeyError({
|
|
192
|
+
throw new chunkIXZ2T2QX_cjs.LoadAPIKeyError({
|
|
607
193
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
608
194
|
});
|
|
609
195
|
}
|
|
610
196
|
apiKey = process.env[environmentVariableName];
|
|
611
197
|
if (apiKey == null) {
|
|
612
|
-
throw new LoadAPIKeyError({
|
|
198
|
+
throw new chunkIXZ2T2QX_cjs.LoadAPIKeyError({
|
|
613
199
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
614
200
|
});
|
|
615
201
|
}
|
|
616
202
|
if (typeof apiKey !== "string") {
|
|
617
|
-
throw new LoadAPIKeyError({
|
|
203
|
+
throw new chunkIXZ2T2QX_cjs.LoadAPIKeyError({
|
|
618
204
|
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
619
205
|
});
|
|
620
206
|
}
|
|
@@ -636,16 +222,48 @@ function loadOptionalSetting({
|
|
|
636
222
|
}
|
|
637
223
|
return settingValue;
|
|
638
224
|
}
|
|
225
|
+
function loadSetting({
|
|
226
|
+
settingValue,
|
|
227
|
+
environmentVariableName,
|
|
228
|
+
settingName,
|
|
229
|
+
description
|
|
230
|
+
}) {
|
|
231
|
+
if (typeof settingValue === "string") {
|
|
232
|
+
return settingValue;
|
|
233
|
+
}
|
|
234
|
+
if (settingValue != null) {
|
|
235
|
+
throw new chunkIXZ2T2QX_cjs.LoadSettingError({
|
|
236
|
+
message: `${description} setting must be a string.`
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (typeof process === "undefined") {
|
|
240
|
+
throw new chunkIXZ2T2QX_cjs.LoadSettingError({
|
|
241
|
+
message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables is not supported in this environment.`
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
settingValue = process.env[environmentVariableName];
|
|
245
|
+
if (settingValue == null) {
|
|
246
|
+
throw new chunkIXZ2T2QX_cjs.LoadSettingError({
|
|
247
|
+
message: `${description} setting is missing. Pass it using the '${settingName}' parameter or the ${environmentVariableName} environment variable.`
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (typeof settingValue !== "string") {
|
|
251
|
+
throw new chunkIXZ2T2QX_cjs.LoadSettingError({
|
|
252
|
+
message: `${description} setting must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return settingValue;
|
|
256
|
+
}
|
|
639
257
|
function mediaTypeToExtension(mediaType) {
|
|
640
|
-
var
|
|
258
|
+
var _a;
|
|
641
259
|
const [_type, subtype = ""] = mediaType.toLowerCase().split("/");
|
|
642
|
-
return (
|
|
260
|
+
return (_a = {
|
|
643
261
|
mpeg: "mp3",
|
|
644
262
|
"x-wav": "wav",
|
|
645
263
|
opus: "ogg",
|
|
646
264
|
mp4: "m4a",
|
|
647
265
|
"x-m4a": "m4a"
|
|
648
|
-
}[subtype]) != null ?
|
|
266
|
+
}[subtype]) != null ? _a : subtype;
|
|
649
267
|
}
|
|
650
268
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
651
269
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
@@ -718,7 +336,7 @@ function standardSchemaValidator(standardSchema) {
|
|
|
718
336
|
const result = await standardSchema["~standard"].validate(value);
|
|
719
337
|
return result.issues == null ? { success: true, value: result.value } : {
|
|
720
338
|
success: false,
|
|
721
|
-
error: new TypeValidationError({
|
|
339
|
+
error: new chunkIXZ2T2QX_cjs.TypeValidationError({
|
|
722
340
|
value,
|
|
723
341
|
cause: result.issues
|
|
724
342
|
})
|
|
@@ -731,7 +349,7 @@ async function validateTypes({
|
|
|
731
349
|
}) {
|
|
732
350
|
const result = await safeValidateTypes({ value, schema });
|
|
733
351
|
if (!result.success) {
|
|
734
|
-
throw TypeValidationError.wrap({ value, cause: result.error });
|
|
352
|
+
throw chunkIXZ2T2QX_cjs.TypeValidationError.wrap({ value, cause: result.error });
|
|
735
353
|
}
|
|
736
354
|
return result.value;
|
|
737
355
|
}
|
|
@@ -750,13 +368,13 @@ async function safeValidateTypes({
|
|
|
750
368
|
}
|
|
751
369
|
return {
|
|
752
370
|
success: false,
|
|
753
|
-
error: TypeValidationError.wrap({ value, cause: result.error }),
|
|
371
|
+
error: chunkIXZ2T2QX_cjs.TypeValidationError.wrap({ value, cause: result.error }),
|
|
754
372
|
rawValue: value
|
|
755
373
|
};
|
|
756
374
|
} catch (error) {
|
|
757
375
|
return {
|
|
758
376
|
success: false,
|
|
759
|
-
error: TypeValidationError.wrap({ value, cause: error }),
|
|
377
|
+
error: chunkIXZ2T2QX_cjs.TypeValidationError.wrap({ value, cause: error }),
|
|
760
378
|
rawValue: value
|
|
761
379
|
};
|
|
762
380
|
}
|
|
@@ -772,10 +390,10 @@ async function parseJSON({
|
|
|
772
390
|
}
|
|
773
391
|
return validateTypes({ value, schema });
|
|
774
392
|
} catch (error) {
|
|
775
|
-
if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
|
|
393
|
+
if (chunkIXZ2T2QX_cjs.JSONParseError.isInstance(error) || chunkIXZ2T2QX_cjs.TypeValidationError.isInstance(error)) {
|
|
776
394
|
throw error;
|
|
777
395
|
}
|
|
778
|
-
throw new JSONParseError({ text, cause: error });
|
|
396
|
+
throw new chunkIXZ2T2QX_cjs.JSONParseError({ text, cause: error });
|
|
779
397
|
}
|
|
780
398
|
}
|
|
781
399
|
async function safeParseJSON({
|
|
@@ -791,7 +409,7 @@ async function safeParseJSON({
|
|
|
791
409
|
} catch (error) {
|
|
792
410
|
return {
|
|
793
411
|
success: false,
|
|
794
|
-
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text, cause: error }),
|
|
412
|
+
error: chunkIXZ2T2QX_cjs.JSONParseError.isInstance(error) ? error : new chunkIXZ2T2QX_cjs.JSONParseError({ text, cause: error }),
|
|
795
413
|
rawValue: void 0
|
|
796
414
|
};
|
|
797
415
|
}
|
|
@@ -808,7 +426,7 @@ function parseJsonEventStream({
|
|
|
808
426
|
stream,
|
|
809
427
|
schema
|
|
810
428
|
}) {
|
|
811
|
-
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
|
|
429
|
+
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new chunkIXZ2T2QX_cjs.EventSourceParserStream()).pipeThrough(
|
|
812
430
|
new TransformStream({
|
|
813
431
|
async transform({ data }, controller) {
|
|
814
432
|
if (data === "[DONE]") {
|
|
@@ -832,7 +450,7 @@ async function parseProviderOptions({
|
|
|
832
450
|
schema
|
|
833
451
|
});
|
|
834
452
|
if (!parsedProviderOptions.success) {
|
|
835
|
-
throw new InvalidArgumentError({
|
|
453
|
+
throw new chunkIXZ2T2QX_cjs.InvalidArgumentError({
|
|
836
454
|
argument: "providerOptions",
|
|
837
455
|
message: `invalid ${provider} provider options`,
|
|
838
456
|
cause: parsedProviderOptions.error
|
|
@@ -914,10 +532,10 @@ var postToApi = async ({
|
|
|
914
532
|
requestBodyValues: body.values
|
|
915
533
|
});
|
|
916
534
|
} catch (error) {
|
|
917
|
-
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
535
|
+
if (isAbortError(error) || chunkIXZ2T2QX_cjs.APICallError.isInstance(error)) {
|
|
918
536
|
throw error;
|
|
919
537
|
}
|
|
920
|
-
throw new APICallError({
|
|
538
|
+
throw new chunkIXZ2T2QX_cjs.APICallError({
|
|
921
539
|
message: "Failed to process error response",
|
|
922
540
|
cause: error,
|
|
923
541
|
statusCode: response.status,
|
|
@@ -936,11 +554,11 @@ var postToApi = async ({
|
|
|
936
554
|
});
|
|
937
555
|
} catch (error) {
|
|
938
556
|
if (error instanceof Error) {
|
|
939
|
-
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
557
|
+
if (isAbortError(error) || chunkIXZ2T2QX_cjs.APICallError.isInstance(error)) {
|
|
940
558
|
throw error;
|
|
941
559
|
}
|
|
942
560
|
}
|
|
943
|
-
throw new APICallError({
|
|
561
|
+
throw new chunkIXZ2T2QX_cjs.APICallError({
|
|
944
562
|
message: "Failed to process successful response",
|
|
945
563
|
cause: error,
|
|
946
564
|
statusCode: response.status,
|
|
@@ -958,7 +576,7 @@ function tool(tool2) {
|
|
|
958
576
|
}
|
|
959
577
|
function createProviderDefinedToolFactory({
|
|
960
578
|
id,
|
|
961
|
-
name
|
|
579
|
+
name,
|
|
962
580
|
inputSchema
|
|
963
581
|
}) {
|
|
964
582
|
return ({
|
|
@@ -972,7 +590,7 @@ function createProviderDefinedToolFactory({
|
|
|
972
590
|
}) => tool({
|
|
973
591
|
type: "provider-defined",
|
|
974
592
|
id,
|
|
975
|
-
name
|
|
593
|
+
name,
|
|
976
594
|
args,
|
|
977
595
|
inputSchema,
|
|
978
596
|
outputSchema,
|
|
@@ -985,7 +603,7 @@ function createProviderDefinedToolFactory({
|
|
|
985
603
|
}
|
|
986
604
|
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
987
605
|
id,
|
|
988
|
-
name
|
|
606
|
+
name,
|
|
989
607
|
inputSchema,
|
|
990
608
|
outputSchema
|
|
991
609
|
}) {
|
|
@@ -999,7 +617,7 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
999
617
|
}) => tool({
|
|
1000
618
|
type: "provider-defined",
|
|
1001
619
|
id,
|
|
1002
|
-
name
|
|
620
|
+
name,
|
|
1003
621
|
args,
|
|
1004
622
|
inputSchema,
|
|
1005
623
|
outputSchema,
|
|
@@ -1026,7 +644,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
1026
644
|
if (responseBody.trim() === "") {
|
|
1027
645
|
return {
|
|
1028
646
|
responseHeaders,
|
|
1029
|
-
value: new APICallError({
|
|
647
|
+
value: new chunkIXZ2T2QX_cjs.APICallError({
|
|
1030
648
|
message: response.statusText,
|
|
1031
649
|
url,
|
|
1032
650
|
requestBodyValues,
|
|
@@ -1044,7 +662,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
1044
662
|
});
|
|
1045
663
|
return {
|
|
1046
664
|
responseHeaders,
|
|
1047
|
-
value: new APICallError({
|
|
665
|
+
value: new chunkIXZ2T2QX_cjs.APICallError({
|
|
1048
666
|
message: errorToMessage(parsedError),
|
|
1049
667
|
url,
|
|
1050
668
|
requestBodyValues,
|
|
@@ -1058,7 +676,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
1058
676
|
} catch (parseError) {
|
|
1059
677
|
return {
|
|
1060
678
|
responseHeaders,
|
|
1061
|
-
value: new APICallError({
|
|
679
|
+
value: new chunkIXZ2T2QX_cjs.APICallError({
|
|
1062
680
|
message: response.statusText,
|
|
1063
681
|
url,
|
|
1064
682
|
requestBodyValues,
|
|
@@ -1073,7 +691,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
1073
691
|
var createEventSourceResponseHandler = (chunkSchema2) => async ({ response }) => {
|
|
1074
692
|
const responseHeaders = extractResponseHeaders(response);
|
|
1075
693
|
if (response.body == null) {
|
|
1076
|
-
throw new EmptyResponseBodyError({});
|
|
694
|
+
throw new chunkIXZ2T2QX_cjs.EmptyResponseBodyError({});
|
|
1077
695
|
}
|
|
1078
696
|
return {
|
|
1079
697
|
responseHeaders,
|
|
@@ -1091,7 +709,7 @@ var createJsonResponseHandler = (responseSchema2) => async ({ response, url, req
|
|
|
1091
709
|
});
|
|
1092
710
|
const responseHeaders = extractResponseHeaders(response);
|
|
1093
711
|
if (!parsedResult.success) {
|
|
1094
|
-
throw new APICallError({
|
|
712
|
+
throw new chunkIXZ2T2QX_cjs.APICallError({
|
|
1095
713
|
message: "Invalid JSON response",
|
|
1096
714
|
cause: parsedResult.error,
|
|
1097
715
|
statusCode: response.status,
|
|
@@ -1110,7 +728,7 @@ var createJsonResponseHandler = (responseSchema2) => async ({ response, url, req
|
|
|
1110
728
|
var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
|
|
1111
729
|
const responseHeaders = extractResponseHeaders(response);
|
|
1112
730
|
if (!response.body) {
|
|
1113
|
-
throw new APICallError({
|
|
731
|
+
throw new chunkIXZ2T2QX_cjs.APICallError({
|
|
1114
732
|
message: "Response body is empty",
|
|
1115
733
|
url,
|
|
1116
734
|
requestBodyValues,
|
|
@@ -1126,7 +744,7 @@ var createBinaryResponseHandler = () => async ({ response, url, requestBodyValue
|
|
|
1126
744
|
value: new Uint8Array(buffer)
|
|
1127
745
|
};
|
|
1128
746
|
} catch (error) {
|
|
1129
|
-
throw new APICallError({
|
|
747
|
+
throw new chunkIXZ2T2QX_cjs.APICallError({
|
|
1130
748
|
message: "Failed to read response as array buffer",
|
|
1131
749
|
url,
|
|
1132
750
|
requestBodyValues,
|
|
@@ -1179,11 +797,11 @@ function parseAnyDef() {
|
|
|
1179
797
|
return {};
|
|
1180
798
|
}
|
|
1181
799
|
function parseArrayDef(def, refs) {
|
|
1182
|
-
var
|
|
800
|
+
var _a, _b, _c;
|
|
1183
801
|
const res = {
|
|
1184
802
|
type: "array"
|
|
1185
803
|
};
|
|
1186
|
-
if (((
|
|
804
|
+
if (((_a = def.type) == null ? void 0 : _a._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
1187
805
|
res.items = parseDef(def.type._def, {
|
|
1188
806
|
...refs,
|
|
1189
807
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -1542,8 +1160,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
1542
1160
|
return result;
|
|
1543
1161
|
}
|
|
1544
1162
|
function addFormat(schema, value, message, refs) {
|
|
1545
|
-
var
|
|
1546
|
-
if (schema.format || ((
|
|
1163
|
+
var _a;
|
|
1164
|
+
if (schema.format || ((_a = schema.anyOf) == null ? void 0 : _a.some((x) => x.format))) {
|
|
1547
1165
|
if (!schema.anyOf) {
|
|
1548
1166
|
schema.anyOf = [];
|
|
1549
1167
|
}
|
|
@@ -1562,8 +1180,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
1562
1180
|
}
|
|
1563
1181
|
}
|
|
1564
1182
|
function addPattern(schema, regex, message, refs) {
|
|
1565
|
-
var
|
|
1566
|
-
if (schema.pattern || ((
|
|
1183
|
+
var _a;
|
|
1184
|
+
if (schema.pattern || ((_a = schema.allOf) == null ? void 0 : _a.some((x) => x.pattern))) {
|
|
1567
1185
|
if (!schema.allOf) {
|
|
1568
1186
|
schema.allOf = [];
|
|
1569
1187
|
}
|
|
@@ -1582,7 +1200,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
1582
1200
|
}
|
|
1583
1201
|
}
|
|
1584
1202
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
1585
|
-
var
|
|
1203
|
+
var _a;
|
|
1586
1204
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
1587
1205
|
return regex.source;
|
|
1588
1206
|
}
|
|
@@ -1612,7 +1230,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1612
1230
|
pattern += source[i];
|
|
1613
1231
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
1614
1232
|
inCharRange = false;
|
|
1615
|
-
} else if (source[i + 1] === "-" && ((
|
|
1233
|
+
} else if (source[i + 1] === "-" && ((_a = source[i + 2]) == null ? void 0 : _a.match(/[a-z]/))) {
|
|
1616
1234
|
pattern += source[i];
|
|
1617
1235
|
inCharRange = true;
|
|
1618
1236
|
} else {
|
|
@@ -1654,13 +1272,13 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1654
1272
|
return pattern;
|
|
1655
1273
|
}
|
|
1656
1274
|
function parseRecordDef(def, refs) {
|
|
1657
|
-
var
|
|
1275
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1658
1276
|
const schema = {
|
|
1659
1277
|
type: "object",
|
|
1660
|
-
additionalProperties: (
|
|
1278
|
+
additionalProperties: (_a = parseDef(def.valueType._def, {
|
|
1661
1279
|
...refs,
|
|
1662
1280
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1663
|
-
})) != null ?
|
|
1281
|
+
})) != null ? _a : refs.allowedAdditionalProperties
|
|
1664
1282
|
};
|
|
1665
1283
|
if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
1666
1284
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
@@ -1917,8 +1535,8 @@ function safeIsOptional(schema) {
|
|
|
1917
1535
|
}
|
|
1918
1536
|
}
|
|
1919
1537
|
var parseOptionalDef = (def, refs) => {
|
|
1920
|
-
var
|
|
1921
|
-
if (refs.currentPath.toString() === ((
|
|
1538
|
+
var _a;
|
|
1539
|
+
if (refs.currentPath.toString() === ((_a = refs.propertyPath) == null ? void 0 : _a.toString())) {
|
|
1922
1540
|
return parseDef(def.innerType._def, refs);
|
|
1923
1541
|
}
|
|
1924
1542
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -2088,10 +1706,10 @@ var selectParser = (def, typeName, refs) => {
|
|
|
2088
1706
|
}
|
|
2089
1707
|
};
|
|
2090
1708
|
function parseDef(def, refs, forceResolution = false) {
|
|
2091
|
-
var
|
|
1709
|
+
var _a;
|
|
2092
1710
|
const seenItem = refs.seen.get(def);
|
|
2093
1711
|
if (refs.override) {
|
|
2094
|
-
const overrideResult = (
|
|
1712
|
+
const overrideResult = (_a = refs.override) == null ? void 0 : _a.call(
|
|
2095
1713
|
refs,
|
|
2096
1714
|
def,
|
|
2097
1715
|
refs,
|
|
@@ -2157,11 +1775,11 @@ var getRefs = (options) => {
|
|
|
2157
1775
|
currentPath,
|
|
2158
1776
|
propertyPath: void 0,
|
|
2159
1777
|
seen: new Map(
|
|
2160
|
-
Object.entries(_options.definitions).map(([
|
|
1778
|
+
Object.entries(_options.definitions).map(([name, def]) => [
|
|
2161
1779
|
def._def,
|
|
2162
1780
|
{
|
|
2163
1781
|
def: def._def,
|
|
2164
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
1782
|
+
path: [..._options.basePath, _options.definitionPath, name],
|
|
2165
1783
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
2166
1784
|
jsonSchema: void 0
|
|
2167
1785
|
}
|
|
@@ -2170,50 +1788,50 @@ var getRefs = (options) => {
|
|
|
2170
1788
|
};
|
|
2171
1789
|
};
|
|
2172
1790
|
var zodToJsonSchema = (schema, options) => {
|
|
2173
|
-
var
|
|
1791
|
+
var _a;
|
|
2174
1792
|
const refs = getRefs(options);
|
|
2175
1793
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
2176
|
-
(acc, [
|
|
2177
|
-
var
|
|
1794
|
+
(acc, [name2, schema2]) => {
|
|
1795
|
+
var _a2;
|
|
2178
1796
|
return {
|
|
2179
1797
|
...acc,
|
|
2180
|
-
[
|
|
1798
|
+
[name2]: (_a2 = parseDef(
|
|
2181
1799
|
schema2._def,
|
|
2182
1800
|
{
|
|
2183
1801
|
...refs,
|
|
2184
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1802
|
+
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
2185
1803
|
},
|
|
2186
1804
|
true
|
|
2187
|
-
)) != null ?
|
|
1805
|
+
)) != null ? _a2 : parseAnyDef()
|
|
2188
1806
|
};
|
|
2189
1807
|
},
|
|
2190
1808
|
{}
|
|
2191
1809
|
) : void 0;
|
|
2192
|
-
const
|
|
2193
|
-
const main = (
|
|
1810
|
+
const name = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
1811
|
+
const main = (_a = parseDef(
|
|
2194
1812
|
schema._def,
|
|
2195
|
-
|
|
1813
|
+
name === void 0 ? refs : {
|
|
2196
1814
|
...refs,
|
|
2197
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1815
|
+
currentPath: [...refs.basePath, refs.definitionPath, name]
|
|
2198
1816
|
},
|
|
2199
1817
|
false
|
|
2200
|
-
)) != null ?
|
|
1818
|
+
)) != null ? _a : parseAnyDef();
|
|
2201
1819
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
2202
1820
|
if (title !== void 0) {
|
|
2203
1821
|
main.title = title;
|
|
2204
1822
|
}
|
|
2205
|
-
const combined =
|
|
1823
|
+
const combined = name === void 0 ? definitions ? {
|
|
2206
1824
|
...main,
|
|
2207
1825
|
[refs.definitionPath]: definitions
|
|
2208
1826
|
} : main : {
|
|
2209
1827
|
$ref: [
|
|
2210
1828
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
2211
1829
|
refs.definitionPath,
|
|
2212
|
-
|
|
1830
|
+
name
|
|
2213
1831
|
].join("/"),
|
|
2214
1832
|
[refs.definitionPath]: {
|
|
2215
1833
|
...definitions,
|
|
2216
|
-
[
|
|
1834
|
+
[name]: main
|
|
2217
1835
|
}
|
|
2218
1836
|
};
|
|
2219
1837
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -2221,8 +1839,8 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
2221
1839
|
};
|
|
2222
1840
|
var zod_to_json_schema_default = zodToJsonSchema;
|
|
2223
1841
|
function zod3Schema(zodSchema2, options) {
|
|
2224
|
-
var
|
|
2225
|
-
const useReferences = (
|
|
1842
|
+
var _a;
|
|
1843
|
+
const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
|
|
2226
1844
|
return jsonSchema(
|
|
2227
1845
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
2228
1846
|
() => zod_to_json_schema_default(zodSchema2, {
|
|
@@ -2237,8 +1855,8 @@ function zod3Schema(zodSchema2, options) {
|
|
|
2237
1855
|
);
|
|
2238
1856
|
}
|
|
2239
1857
|
function zod4Schema(zodSchema2, options) {
|
|
2240
|
-
var
|
|
2241
|
-
const useReferences = (
|
|
1858
|
+
var _a;
|
|
1859
|
+
const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
|
|
2242
1860
|
return jsonSchema(
|
|
2243
1861
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
2244
1862
|
() => z4__namespace.toJSONSchema(zodSchema2, {
|
|
@@ -2259,9 +1877,9 @@ function isZod4Schema(zodSchema2) {
|
|
|
2259
1877
|
}
|
|
2260
1878
|
function zodSchema(zodSchema2, options) {
|
|
2261
1879
|
if (isZod4Schema(zodSchema2)) {
|
|
2262
|
-
return zod4Schema(zodSchema2);
|
|
1880
|
+
return zod4Schema(zodSchema2, options);
|
|
2263
1881
|
} else {
|
|
2264
|
-
return zod3Schema(zodSchema2);
|
|
1882
|
+
return zod3Schema(zodSchema2, options);
|
|
2265
1883
|
}
|
|
2266
1884
|
}
|
|
2267
1885
|
var schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
@@ -2311,8 +1929,8 @@ function withoutTrailingSlash(url) {
|
|
|
2311
1929
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
2312
1930
|
}
|
|
2313
1931
|
function getOpenAIMetadata(message) {
|
|
2314
|
-
var
|
|
2315
|
-
return (_b = (
|
|
1932
|
+
var _a, _b;
|
|
1933
|
+
return (_b = (_a = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a.openaiCompatible) != null ? _b : {};
|
|
2316
1934
|
}
|
|
2317
1935
|
function convertToOpenAICompatibleChatMessages(prompt) {
|
|
2318
1936
|
const messages = [];
|
|
@@ -2351,7 +1969,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
2351
1969
|
...partMetadata
|
|
2352
1970
|
};
|
|
2353
1971
|
} else {
|
|
2354
|
-
throw new UnsupportedFunctionalityError({
|
|
1972
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
2355
1973
|
functionality: `file part media type ${part.mediaType}`
|
|
2356
1974
|
});
|
|
2357
1975
|
}
|
|
@@ -2527,7 +2145,7 @@ function prepareTools({
|
|
|
2527
2145
|
};
|
|
2528
2146
|
default: {
|
|
2529
2147
|
const _exhaustiveCheck = type;
|
|
2530
|
-
throw new UnsupportedFunctionalityError({
|
|
2148
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
2531
2149
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
2532
2150
|
});
|
|
2533
2151
|
}
|
|
@@ -2537,10 +2155,10 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2537
2155
|
// type inferred via constructor
|
|
2538
2156
|
constructor(modelId, config) {
|
|
2539
2157
|
this.specificationVersion = "v2";
|
|
2540
|
-
var
|
|
2158
|
+
var _a, _b;
|
|
2541
2159
|
this.modelId = modelId;
|
|
2542
2160
|
this.config = config;
|
|
2543
|
-
const errorStructure = (
|
|
2161
|
+
const errorStructure = (_a = config.errorStructure) != null ? _a : defaultOpenAICompatibleErrorStructure;
|
|
2544
2162
|
this.chunkSchema = createOpenAICompatibleChatChunkSchema(
|
|
2545
2163
|
errorStructure.errorSchema
|
|
2546
2164
|
);
|
|
@@ -2554,8 +2172,8 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2554
2172
|
return this.config.provider.split(".")[0].trim();
|
|
2555
2173
|
}
|
|
2556
2174
|
get supportedUrls() {
|
|
2557
|
-
var
|
|
2558
|
-
return (_c = (_b = (
|
|
2175
|
+
var _a, _b, _c;
|
|
2176
|
+
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
2559
2177
|
}
|
|
2560
2178
|
async getArgs({
|
|
2561
2179
|
prompt,
|
|
@@ -2572,14 +2190,14 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2572
2190
|
toolChoice,
|
|
2573
2191
|
tools
|
|
2574
2192
|
}) {
|
|
2575
|
-
var
|
|
2193
|
+
var _a, _b, _c, _d;
|
|
2576
2194
|
const warnings = [];
|
|
2577
2195
|
const compatibleOptions = Object.assign(
|
|
2578
|
-
(
|
|
2196
|
+
(_a = await parseProviderOptions({
|
|
2579
2197
|
provider: "openai-compatible",
|
|
2580
2198
|
providerOptions,
|
|
2581
2199
|
schema: openaiCompatibleProviderOptions
|
|
2582
|
-
})) != null ?
|
|
2200
|
+
})) != null ? _a : {},
|
|
2583
2201
|
(_b = await parseProviderOptions({
|
|
2584
2202
|
provider: this.providerOptionsName,
|
|
2585
2203
|
providerOptions,
|
|
@@ -2645,7 +2263,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2645
2263
|
};
|
|
2646
2264
|
}
|
|
2647
2265
|
async doGenerate(options) {
|
|
2648
|
-
var
|
|
2266
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2649
2267
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
2650
2268
|
const body = JSON.stringify(args);
|
|
2651
2269
|
const {
|
|
@@ -2672,7 +2290,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2672
2290
|
if (text != null && text.length > 0) {
|
|
2673
2291
|
content.push({ type: "text", text });
|
|
2674
2292
|
}
|
|
2675
|
-
const reasoning = (
|
|
2293
|
+
const reasoning = (_a = choice.message.reasoning_content) != null ? _a : choice.message.reasoning;
|
|
2676
2294
|
if (reasoning != null && reasoning.length > 0) {
|
|
2677
2295
|
content.push({
|
|
2678
2296
|
type: "reasoning",
|
|
@@ -2723,7 +2341,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2723
2341
|
};
|
|
2724
2342
|
}
|
|
2725
2343
|
async doStream(options) {
|
|
2726
|
-
var
|
|
2344
|
+
var _a;
|
|
2727
2345
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
2728
2346
|
const body = {
|
|
2729
2347
|
...args,
|
|
@@ -2731,7 +2349,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2731
2349
|
// only include stream_options when in strict compatibility mode:
|
|
2732
2350
|
stream_options: this.config.includeUsage ? { include_usage: true } : void 0
|
|
2733
2351
|
};
|
|
2734
|
-
const metadataExtractor = (
|
|
2352
|
+
const metadataExtractor = (_a = this.config.metadataExtractor) == null ? void 0 : _a.createStreamExtractor();
|
|
2735
2353
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
2736
2354
|
url: this.config.url({
|
|
2737
2355
|
path: "/chat/completions",
|
|
@@ -2773,7 +2391,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2773
2391
|
},
|
|
2774
2392
|
// TODO we lost type safety on Chunk, most likely due to the error schema. MUST FIX
|
|
2775
2393
|
transform(chunk, controller) {
|
|
2776
|
-
var
|
|
2394
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2777
2395
|
if (options.includeRawChunks) {
|
|
2778
2396
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2779
2397
|
}
|
|
@@ -2830,7 +2448,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2830
2448
|
return;
|
|
2831
2449
|
}
|
|
2832
2450
|
const delta = choice.delta;
|
|
2833
|
-
const reasoningContent = (
|
|
2451
|
+
const reasoningContent = (_a2 = delta.reasoning_content) != null ? _a2 : delta.reasoning;
|
|
2834
2452
|
if (reasoningContent) {
|
|
2835
2453
|
if (!isActiveReasoning) {
|
|
2836
2454
|
controller.enqueue({
|
|
@@ -2861,13 +2479,13 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2861
2479
|
const index = toolCallDelta.index;
|
|
2862
2480
|
if (toolCalls[index] == null) {
|
|
2863
2481
|
if (toolCallDelta.id == null) {
|
|
2864
|
-
throw new InvalidResponseDataError({
|
|
2482
|
+
throw new chunkIXZ2T2QX_cjs.InvalidResponseDataError({
|
|
2865
2483
|
data: toolCallDelta,
|
|
2866
2484
|
message: `Expected 'id' to be a string.`
|
|
2867
2485
|
});
|
|
2868
2486
|
}
|
|
2869
2487
|
if (((_b = toolCallDelta.function) == null ? void 0 : _b.name) == null) {
|
|
2870
|
-
throw new InvalidResponseDataError({
|
|
2488
|
+
throw new chunkIXZ2T2QX_cjs.InvalidResponseDataError({
|
|
2871
2489
|
data: toolCallDelta,
|
|
2872
2490
|
message: `Expected 'function.name' to be a string.`
|
|
2873
2491
|
});
|
|
@@ -2940,7 +2558,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2940
2558
|
}
|
|
2941
2559
|
},
|
|
2942
2560
|
flush(controller) {
|
|
2943
|
-
var
|
|
2561
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
2944
2562
|
if (isActiveReasoning) {
|
|
2945
2563
|
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
2946
2564
|
}
|
|
@@ -2956,7 +2574,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2956
2574
|
});
|
|
2957
2575
|
controller.enqueue({
|
|
2958
2576
|
type: "tool-call",
|
|
2959
|
-
toolCallId: (
|
|
2577
|
+
toolCallId: (_a2 = toolCall.id) != null ? _a2 : generateId(),
|
|
2960
2578
|
toolName: toolCall.function.name,
|
|
2961
2579
|
input: toolCall.function.arguments
|
|
2962
2580
|
});
|
|
@@ -3077,7 +2695,7 @@ function convertToOpenAICompatibleCompletionPrompt({
|
|
|
3077
2695
|
for (const { role, content } of prompt) {
|
|
3078
2696
|
switch (role) {
|
|
3079
2697
|
case "system": {
|
|
3080
|
-
throw new InvalidPromptError({
|
|
2698
|
+
throw new chunkIXZ2T2QX_cjs.InvalidPromptError({
|
|
3081
2699
|
message: "Unexpected system message in prompt: ${content}",
|
|
3082
2700
|
prompt
|
|
3083
2701
|
});
|
|
@@ -3103,7 +2721,7 @@ ${userMessage}
|
|
|
3103
2721
|
return part.text;
|
|
3104
2722
|
}
|
|
3105
2723
|
case "tool-call": {
|
|
3106
|
-
throw new UnsupportedFunctionalityError({
|
|
2724
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
3107
2725
|
functionality: "tool-call messages"
|
|
3108
2726
|
});
|
|
3109
2727
|
}
|
|
@@ -3116,7 +2734,7 @@ ${assistantMessage}
|
|
|
3116
2734
|
break;
|
|
3117
2735
|
}
|
|
3118
2736
|
case "tool": {
|
|
3119
|
-
throw new UnsupportedFunctionalityError({
|
|
2737
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
3120
2738
|
functionality: "tool messages"
|
|
3121
2739
|
});
|
|
3122
2740
|
}
|
|
@@ -3186,10 +2804,10 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
3186
2804
|
// type inferred via constructor
|
|
3187
2805
|
constructor(modelId, config) {
|
|
3188
2806
|
this.specificationVersion = "v2";
|
|
3189
|
-
var
|
|
2807
|
+
var _a;
|
|
3190
2808
|
this.modelId = modelId;
|
|
3191
2809
|
this.config = config;
|
|
3192
|
-
const errorStructure = (
|
|
2810
|
+
const errorStructure = (_a = config.errorStructure) != null ? _a : defaultOpenAICompatibleErrorStructure;
|
|
3193
2811
|
this.chunkSchema = createOpenAICompatibleCompletionChunkSchema(
|
|
3194
2812
|
errorStructure.errorSchema
|
|
3195
2813
|
);
|
|
@@ -3202,8 +2820,8 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
3202
2820
|
return this.config.provider.split(".")[0].trim();
|
|
3203
2821
|
}
|
|
3204
2822
|
get supportedUrls() {
|
|
3205
|
-
var
|
|
3206
|
-
return (_c = (_b = (
|
|
2823
|
+
var _a, _b, _c;
|
|
2824
|
+
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
3207
2825
|
}
|
|
3208
2826
|
async getArgs({
|
|
3209
2827
|
prompt,
|
|
@@ -3220,13 +2838,13 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
3220
2838
|
tools,
|
|
3221
2839
|
toolChoice
|
|
3222
2840
|
}) {
|
|
3223
|
-
var
|
|
2841
|
+
var _a;
|
|
3224
2842
|
const warnings = [];
|
|
3225
|
-
const completionOptions = (
|
|
2843
|
+
const completionOptions = (_a = await parseProviderOptions({
|
|
3226
2844
|
provider: this.providerOptionsName,
|
|
3227
2845
|
providerOptions,
|
|
3228
2846
|
schema: openaiCompatibleCompletionProviderOptions
|
|
3229
|
-
})) != null ?
|
|
2847
|
+
})) != null ? _a : {};
|
|
3230
2848
|
if (topK != null) {
|
|
3231
2849
|
warnings.push({ type: "unsupported-setting", setting: "topK" });
|
|
3232
2850
|
}
|
|
@@ -3271,7 +2889,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
3271
2889
|
};
|
|
3272
2890
|
}
|
|
3273
2891
|
async doGenerate(options) {
|
|
3274
|
-
var
|
|
2892
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3275
2893
|
const { args, warnings } = await this.getArgs(options);
|
|
3276
2894
|
const {
|
|
3277
2895
|
responseHeaders,
|
|
@@ -3299,7 +2917,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
3299
2917
|
return {
|
|
3300
2918
|
content,
|
|
3301
2919
|
usage: {
|
|
3302
|
-
inputTokens: (_b = (
|
|
2920
|
+
inputTokens: (_b = (_a = response.usage) == null ? void 0 : _a.prompt_tokens) != null ? _b : void 0,
|
|
3303
2921
|
outputTokens: (_d = (_c = response.usage) == null ? void 0 : _c.completion_tokens) != null ? _d : void 0,
|
|
3304
2922
|
totalTokens: (_f = (_e = response.usage) == null ? void 0 : _e.total_tokens) != null ? _f : void 0
|
|
3305
2923
|
},
|
|
@@ -3349,7 +2967,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
3349
2967
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3350
2968
|
},
|
|
3351
2969
|
transform(chunk, controller) {
|
|
3352
|
-
var
|
|
2970
|
+
var _a, _b, _c;
|
|
3353
2971
|
if (options.includeRawChunks) {
|
|
3354
2972
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3355
2973
|
}
|
|
@@ -3376,7 +2994,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
3376
2994
|
});
|
|
3377
2995
|
}
|
|
3378
2996
|
if (value.usage != null) {
|
|
3379
|
-
usage.inputTokens = (
|
|
2997
|
+
usage.inputTokens = (_a = value.usage.prompt_tokens) != null ? _a : void 0;
|
|
3380
2998
|
usage.outputTokens = (_b = value.usage.completion_tokens) != null ? _b : void 0;
|
|
3381
2999
|
usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : void 0;
|
|
3382
3000
|
}
|
|
@@ -3466,12 +3084,12 @@ var OpenAICompatibleEmbeddingModel = class {
|
|
|
3466
3084
|
return this.config.provider;
|
|
3467
3085
|
}
|
|
3468
3086
|
get maxEmbeddingsPerCall() {
|
|
3469
|
-
var
|
|
3470
|
-
return (
|
|
3087
|
+
var _a;
|
|
3088
|
+
return (_a = this.config.maxEmbeddingsPerCall) != null ? _a : 2048;
|
|
3471
3089
|
}
|
|
3472
3090
|
get supportsParallelCalls() {
|
|
3473
|
-
var
|
|
3474
|
-
return (
|
|
3091
|
+
var _a;
|
|
3092
|
+
return (_a = this.config.supportsParallelCalls) != null ? _a : true;
|
|
3475
3093
|
}
|
|
3476
3094
|
get providerOptionsName() {
|
|
3477
3095
|
return this.config.provider.split(".")[0].trim();
|
|
@@ -3482,13 +3100,13 @@ var OpenAICompatibleEmbeddingModel = class {
|
|
|
3482
3100
|
abortSignal,
|
|
3483
3101
|
providerOptions
|
|
3484
3102
|
}) {
|
|
3485
|
-
var
|
|
3103
|
+
var _a, _b, _c;
|
|
3486
3104
|
const compatibleOptions = Object.assign(
|
|
3487
|
-
(
|
|
3105
|
+
(_a = await parseProviderOptions({
|
|
3488
3106
|
provider: "openai-compatible",
|
|
3489
3107
|
providerOptions,
|
|
3490
3108
|
schema: openaiCompatibleEmbeddingProviderOptions
|
|
3491
|
-
})) != null ?
|
|
3109
|
+
})) != null ? _a : {},
|
|
3492
3110
|
(_b = await parseProviderOptions({
|
|
3493
3111
|
provider: this.providerOptionsName,
|
|
3494
3112
|
providerOptions,
|
|
@@ -3496,7 +3114,7 @@ var OpenAICompatibleEmbeddingModel = class {
|
|
|
3496
3114
|
})) != null ? _b : {}
|
|
3497
3115
|
);
|
|
3498
3116
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
3499
|
-
throw new TooManyEmbeddingValuesForCallError({
|
|
3117
|
+
throw new chunkIXZ2T2QX_cjs.TooManyEmbeddingValuesForCallError({
|
|
3500
3118
|
provider: this.provider,
|
|
3501
3119
|
modelId: this.modelId,
|
|
3502
3120
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -3562,7 +3180,7 @@ var OpenAICompatibleImageModel = class {
|
|
|
3562
3180
|
headers,
|
|
3563
3181
|
abortSignal
|
|
3564
3182
|
}) {
|
|
3565
|
-
var
|
|
3183
|
+
var _a, _b, _c, _d, _e;
|
|
3566
3184
|
const warnings = [];
|
|
3567
3185
|
if (aspectRatio != null) {
|
|
3568
3186
|
warnings.push({
|
|
@@ -3574,7 +3192,7 @@ var OpenAICompatibleImageModel = class {
|
|
|
3574
3192
|
if (seed != null) {
|
|
3575
3193
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
3576
3194
|
}
|
|
3577
|
-
const currentDate = (_c = (_b = (
|
|
3195
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3578
3196
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
3579
3197
|
url: this.config.url({
|
|
3580
3198
|
path: "/images/generations",
|
|
@@ -4206,9 +3824,9 @@ var anthropicProviderOptions = z4.z.object({
|
|
|
4206
3824
|
});
|
|
4207
3825
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
4208
3826
|
function getCacheControl(providerMetadata) {
|
|
4209
|
-
var
|
|
3827
|
+
var _a;
|
|
4210
3828
|
const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
4211
|
-
const cacheControlValue = (
|
|
3829
|
+
const cacheControlValue = (_a = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a : anthropic2 == null ? void 0 : anthropic2.cache_control;
|
|
4212
3830
|
return cacheControlValue;
|
|
4213
3831
|
}
|
|
4214
3832
|
var CacheControlValidator = class {
|
|
@@ -4600,7 +4218,7 @@ async function prepareTools2({
|
|
|
4600
4218
|
};
|
|
4601
4219
|
default: {
|
|
4602
4220
|
const _exhaustiveCheck = type;
|
|
4603
|
-
throw new UnsupportedFunctionalityError({
|
|
4221
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
4604
4222
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
4605
4223
|
});
|
|
4606
4224
|
}
|
|
@@ -4725,11 +4343,11 @@ function convertToString(data) {
|
|
|
4725
4343
|
return new TextDecoder().decode(data);
|
|
4726
4344
|
}
|
|
4727
4345
|
if (data instanceof URL) {
|
|
4728
|
-
throw new UnsupportedFunctionalityError({
|
|
4346
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
4729
4347
|
functionality: "URL-based text documents are not supported for citations"
|
|
4730
4348
|
});
|
|
4731
4349
|
}
|
|
4732
|
-
throw new UnsupportedFunctionalityError({
|
|
4350
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
4733
4351
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
4734
4352
|
});
|
|
4735
4353
|
}
|
|
@@ -4739,20 +4357,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4739
4357
|
warnings,
|
|
4740
4358
|
cacheControlValidator
|
|
4741
4359
|
}) {
|
|
4742
|
-
var
|
|
4360
|
+
var _a, _b, _c, _d, _e;
|
|
4743
4361
|
const betas = /* @__PURE__ */ new Set();
|
|
4744
4362
|
const blocks = groupIntoBlocks(prompt);
|
|
4745
4363
|
const validator2 = cacheControlValidator || new CacheControlValidator();
|
|
4746
4364
|
let system = void 0;
|
|
4747
4365
|
const messages = [];
|
|
4748
4366
|
async function shouldEnableCitations(providerMetadata) {
|
|
4749
|
-
var
|
|
4367
|
+
var _a2, _b2;
|
|
4750
4368
|
const anthropicOptions = await parseProviderOptions({
|
|
4751
4369
|
provider: "anthropic",
|
|
4752
4370
|
providerOptions: providerMetadata,
|
|
4753
4371
|
schema: anthropicFilePartProviderOptions
|
|
4754
4372
|
});
|
|
4755
|
-
return (_b2 = (
|
|
4373
|
+
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
4756
4374
|
}
|
|
4757
4375
|
async function getDocumentMetadata(providerMetadata) {
|
|
4758
4376
|
const anthropicOptions = await parseProviderOptions({
|
|
@@ -4772,7 +4390,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4772
4390
|
switch (type) {
|
|
4773
4391
|
case "system": {
|
|
4774
4392
|
if (system != null) {
|
|
4775
|
-
throw new UnsupportedFunctionalityError({
|
|
4393
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
4776
4394
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
4777
4395
|
});
|
|
4778
4396
|
}
|
|
@@ -4795,10 +4413,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4795
4413
|
for (let j = 0; j < content.length; j++) {
|
|
4796
4414
|
const part = content[j];
|
|
4797
4415
|
const isLastPart = j === content.length - 1;
|
|
4798
|
-
const cacheControl = (
|
|
4416
|
+
const cacheControl = (_a = validator2.getCacheControl(part.providerOptions, {
|
|
4799
4417
|
type: "user message part",
|
|
4800
4418
|
canCache: true
|
|
4801
|
-
})) != null ?
|
|
4419
|
+
})) != null ? _a : isLastPart ? validator2.getCacheControl(message.providerOptions, {
|
|
4802
4420
|
type: "user message",
|
|
4803
4421
|
canCache: true
|
|
4804
4422
|
}) : void 0;
|
|
@@ -4875,7 +4493,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4875
4493
|
cache_control: cacheControl
|
|
4876
4494
|
});
|
|
4877
4495
|
} else {
|
|
4878
|
-
throw new UnsupportedFunctionalityError({
|
|
4496
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
4879
4497
|
functionality: `media type: ${part.mediaType}`
|
|
4880
4498
|
});
|
|
4881
4499
|
}
|
|
@@ -4929,7 +4547,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4929
4547
|
}
|
|
4930
4548
|
};
|
|
4931
4549
|
}
|
|
4932
|
-
throw new UnsupportedFunctionalityError({
|
|
4550
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
4933
4551
|
functionality: `media type: ${contentPart.mediaType}`
|
|
4934
4552
|
});
|
|
4935
4553
|
}
|
|
@@ -5284,7 +4902,7 @@ function mapAnthropicStopReason({
|
|
|
5284
4902
|
}
|
|
5285
4903
|
}
|
|
5286
4904
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
5287
|
-
var
|
|
4905
|
+
var _a;
|
|
5288
4906
|
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
5289
4907
|
return;
|
|
5290
4908
|
}
|
|
@@ -5297,7 +4915,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
5297
4915
|
sourceType: "document",
|
|
5298
4916
|
id: generateId3(),
|
|
5299
4917
|
mediaType: documentInfo.mediaType,
|
|
5300
|
-
title: (
|
|
4918
|
+
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
5301
4919
|
filename: documentInfo.filename,
|
|
5302
4920
|
providerMetadata: {
|
|
5303
4921
|
anthropic: citation.type === "page_location" ? {
|
|
@@ -5315,10 +4933,10 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
5315
4933
|
var AnthropicMessagesLanguageModel = class {
|
|
5316
4934
|
constructor(modelId, config) {
|
|
5317
4935
|
this.specificationVersion = "v2";
|
|
5318
|
-
var
|
|
4936
|
+
var _a;
|
|
5319
4937
|
this.modelId = modelId;
|
|
5320
4938
|
this.config = config;
|
|
5321
|
-
this.generateId = (
|
|
4939
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
5322
4940
|
}
|
|
5323
4941
|
supportsUrl(url) {
|
|
5324
4942
|
return url.protocol === "https:";
|
|
@@ -5327,8 +4945,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5327
4945
|
return this.config.provider;
|
|
5328
4946
|
}
|
|
5329
4947
|
get supportedUrls() {
|
|
5330
|
-
var
|
|
5331
|
-
return (_c = (_b = (
|
|
4948
|
+
var _a, _b, _c;
|
|
4949
|
+
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
5332
4950
|
}
|
|
5333
4951
|
async getArgs({
|
|
5334
4952
|
prompt,
|
|
@@ -5345,7 +4963,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5345
4963
|
toolChoice,
|
|
5346
4964
|
providerOptions
|
|
5347
4965
|
}) {
|
|
5348
|
-
var
|
|
4966
|
+
var _a, _b, _c, _d;
|
|
5349
4967
|
const warnings = [];
|
|
5350
4968
|
if (frequencyPenalty != null) {
|
|
5351
4969
|
warnings.push({
|
|
@@ -5409,7 +5027,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5409
5027
|
const cacheControlValidator = new CacheControlValidator();
|
|
5410
5028
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
5411
5029
|
prompt,
|
|
5412
|
-
sendReasoning: (
|
|
5030
|
+
sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
|
|
5413
5031
|
warnings,
|
|
5414
5032
|
cacheControlValidator
|
|
5415
5033
|
});
|
|
@@ -5447,7 +5065,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5447
5065
|
};
|
|
5448
5066
|
if (isThinking) {
|
|
5449
5067
|
if (thinkingBudget == null) {
|
|
5450
|
-
throw new UnsupportedFunctionalityError({
|
|
5068
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
5451
5069
|
functionality: "thinking requires a budget"
|
|
5452
5070
|
});
|
|
5453
5071
|
}
|
|
@@ -5541,38 +5159,38 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5541
5159
|
);
|
|
5542
5160
|
}
|
|
5543
5161
|
buildRequestUrl(isStreaming) {
|
|
5544
|
-
var
|
|
5545
|
-
return (_c = (_b = (
|
|
5162
|
+
var _a, _b, _c;
|
|
5163
|
+
return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
|
|
5546
5164
|
}
|
|
5547
5165
|
transformRequestBody(args) {
|
|
5548
|
-
var
|
|
5549
|
-
return (_c = (_b = (
|
|
5166
|
+
var _a, _b, _c;
|
|
5167
|
+
return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
|
|
5550
5168
|
}
|
|
5551
5169
|
extractCitationDocuments(prompt) {
|
|
5552
5170
|
const isCitationPart = (part) => {
|
|
5553
|
-
var
|
|
5171
|
+
var _a, _b;
|
|
5554
5172
|
if (part.type !== "file") {
|
|
5555
5173
|
return false;
|
|
5556
5174
|
}
|
|
5557
5175
|
if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
|
|
5558
5176
|
return false;
|
|
5559
5177
|
}
|
|
5560
|
-
const anthropic2 = (
|
|
5178
|
+
const anthropic2 = (_a = part.providerOptions) == null ? void 0 : _a.anthropic;
|
|
5561
5179
|
const citationsConfig = anthropic2 == null ? void 0 : anthropic2.citations;
|
|
5562
5180
|
return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
|
|
5563
5181
|
};
|
|
5564
5182
|
return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
|
|
5565
|
-
var
|
|
5183
|
+
var _a;
|
|
5566
5184
|
const filePart = part;
|
|
5567
5185
|
return {
|
|
5568
|
-
title: (
|
|
5186
|
+
title: (_a = filePart.filename) != null ? _a : "Untitled Document",
|
|
5569
5187
|
filename: filePart.filename,
|
|
5570
5188
|
mediaType: filePart.mediaType
|
|
5571
5189
|
};
|
|
5572
5190
|
});
|
|
5573
5191
|
}
|
|
5574
5192
|
async doGenerate(options) {
|
|
5575
|
-
var
|
|
5193
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5576
5194
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
5577
5195
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
5578
5196
|
const {
|
|
@@ -5715,11 +5333,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5715
5333
|
toolCallId: part.tool_use_id,
|
|
5716
5334
|
toolName: "web_search",
|
|
5717
5335
|
result: part.content.map((result) => {
|
|
5718
|
-
var
|
|
5336
|
+
var _a2;
|
|
5719
5337
|
return {
|
|
5720
5338
|
url: result.url,
|
|
5721
5339
|
title: result.title,
|
|
5722
|
-
pageAge: (
|
|
5340
|
+
pageAge: (_a2 = result.page_age) != null ? _a2 : null,
|
|
5723
5341
|
encryptedContent: result.encrypted_content,
|
|
5724
5342
|
type: result.type
|
|
5725
5343
|
};
|
|
@@ -5735,7 +5353,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5735
5353
|
title: result.title,
|
|
5736
5354
|
providerMetadata: {
|
|
5737
5355
|
anthropic: {
|
|
5738
|
-
pageAge: (
|
|
5356
|
+
pageAge: (_a = result.page_age) != null ? _a : null
|
|
5739
5357
|
}
|
|
5740
5358
|
}
|
|
5741
5359
|
});
|
|
@@ -5872,7 +5490,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5872
5490
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5873
5491
|
},
|
|
5874
5492
|
transform(chunk, controller) {
|
|
5875
|
-
var
|
|
5493
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5876
5494
|
if (options.includeRawChunks) {
|
|
5877
5495
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5878
5496
|
}
|
|
@@ -6011,11 +5629,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
6011
5629
|
toolCallId: part.tool_use_id,
|
|
6012
5630
|
toolName: "web_search",
|
|
6013
5631
|
result: part.content.map((result) => {
|
|
6014
|
-
var
|
|
5632
|
+
var _a2;
|
|
6015
5633
|
return {
|
|
6016
5634
|
url: result.url,
|
|
6017
5635
|
title: result.title,
|
|
6018
|
-
pageAge: (
|
|
5636
|
+
pageAge: (_a2 = result.page_age) != null ? _a2 : null,
|
|
6019
5637
|
encryptedContent: result.encrypted_content,
|
|
6020
5638
|
type: result.type
|
|
6021
5639
|
};
|
|
@@ -6031,7 +5649,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
6031
5649
|
title: result.title,
|
|
6032
5650
|
providerMetadata: {
|
|
6033
5651
|
anthropic: {
|
|
6034
|
-
pageAge: (
|
|
5652
|
+
pageAge: (_a = result.page_age) != null ? _a : null
|
|
6035
5653
|
}
|
|
6036
5654
|
}
|
|
6037
5655
|
});
|
|
@@ -6648,13 +6266,13 @@ var anthropicTools = {
|
|
|
6648
6266
|
webSearch_20250305
|
|
6649
6267
|
};
|
|
6650
6268
|
function createAnthropic(options = {}) {
|
|
6651
|
-
var
|
|
6652
|
-
const baseURL = (
|
|
6269
|
+
var _a, _b;
|
|
6270
|
+
const baseURL = (_a = withoutTrailingSlash(
|
|
6653
6271
|
loadOptionalSetting({
|
|
6654
6272
|
settingValue: options.baseURL,
|
|
6655
6273
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
6656
6274
|
})
|
|
6657
|
-
)) != null ?
|
|
6275
|
+
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
6658
6276
|
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
6659
6277
|
const getHeaders = () => withUserAgentSuffix(
|
|
6660
6278
|
{
|
|
@@ -6669,13 +6287,13 @@ function createAnthropic(options = {}) {
|
|
|
6669
6287
|
`ai-sdk/anthropic/${VERSION3}`
|
|
6670
6288
|
);
|
|
6671
6289
|
const createChatModel = (modelId) => {
|
|
6672
|
-
var
|
|
6290
|
+
var _a2;
|
|
6673
6291
|
return new AnthropicMessagesLanguageModel(modelId, {
|
|
6674
6292
|
provider: providerName,
|
|
6675
6293
|
baseURL,
|
|
6676
6294
|
headers: getHeaders,
|
|
6677
6295
|
fetch: options.fetch,
|
|
6678
|
-
generateId: (
|
|
6296
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : generateId,
|
|
6679
6297
|
supportedUrls: () => ({
|
|
6680
6298
|
"image/*": [/^https?:\/\/.*$/]
|
|
6681
6299
|
})
|
|
@@ -6693,10 +6311,10 @@ function createAnthropic(options = {}) {
|
|
|
6693
6311
|
provider.chat = createChatModel;
|
|
6694
6312
|
provider.messages = createChatModel;
|
|
6695
6313
|
provider.textEmbeddingModel = (modelId) => {
|
|
6696
|
-
throw new NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
6314
|
+
throw new chunkIXZ2T2QX_cjs.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
6697
6315
|
};
|
|
6698
6316
|
provider.imageModel = (modelId) => {
|
|
6699
|
-
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
6317
|
+
throw new chunkIXZ2T2QX_cjs.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
6700
6318
|
};
|
|
6701
6319
|
provider.tools = anthropicTools;
|
|
6702
6320
|
return provider;
|
|
@@ -6774,7 +6392,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
6774
6392
|
schema: googleGenerativeAIEmbeddingProviderOptions
|
|
6775
6393
|
});
|
|
6776
6394
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
6777
|
-
throw new TooManyEmbeddingValuesForCallError({
|
|
6395
|
+
throw new chunkIXZ2T2QX_cjs.TooManyEmbeddingValuesForCallError({
|
|
6778
6396
|
provider: this.provider,
|
|
6779
6397
|
modelId: this.modelId,
|
|
6780
6398
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -6950,16 +6568,16 @@ function isEmptyObjectSchema(jsonSchema2) {
|
|
|
6950
6568
|
return jsonSchema2 != null && typeof jsonSchema2 === "object" && jsonSchema2.type === "object" && (jsonSchema2.properties == null || Object.keys(jsonSchema2.properties).length === 0) && !jsonSchema2.additionalProperties;
|
|
6951
6569
|
}
|
|
6952
6570
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
6953
|
-
var
|
|
6571
|
+
var _a;
|
|
6954
6572
|
const systemInstructionParts = [];
|
|
6955
6573
|
const contents = [];
|
|
6956
6574
|
let systemMessagesAllowed = true;
|
|
6957
|
-
const isGemmaModel = (
|
|
6575
|
+
const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
|
|
6958
6576
|
for (const { role, content } of prompt) {
|
|
6959
6577
|
switch (role) {
|
|
6960
6578
|
case "system": {
|
|
6961
6579
|
if (!systemMessagesAllowed) {
|
|
6962
|
-
throw new UnsupportedFunctionalityError({
|
|
6580
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
6963
6581
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
6964
6582
|
});
|
|
6965
6583
|
}
|
|
@@ -7002,8 +6620,8 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
7002
6620
|
contents.push({
|
|
7003
6621
|
role: "model",
|
|
7004
6622
|
parts: content.map((part) => {
|
|
7005
|
-
var
|
|
7006
|
-
const thoughtSignature = ((_b = (
|
|
6623
|
+
var _a2, _b, _c;
|
|
6624
|
+
const thoughtSignature = ((_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature) != null ? String((_c = part.providerOptions.google) == null ? void 0 : _c.thoughtSignature) : void 0;
|
|
7007
6625
|
switch (part.type) {
|
|
7008
6626
|
case "text": {
|
|
7009
6627
|
return part.text.length === 0 ? void 0 : {
|
|
@@ -7020,12 +6638,12 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
7020
6638
|
}
|
|
7021
6639
|
case "file": {
|
|
7022
6640
|
if (part.mediaType !== "image/png") {
|
|
7023
|
-
throw new UnsupportedFunctionalityError({
|
|
6641
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
7024
6642
|
functionality: "Only PNG images are supported in assistant messages"
|
|
7025
6643
|
});
|
|
7026
6644
|
}
|
|
7027
6645
|
if (part.data instanceof URL) {
|
|
7028
|
-
throw new UnsupportedFunctionalityError({
|
|
6646
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
7029
6647
|
functionality: "File data URLs in assistant messages are not supported"
|
|
7030
6648
|
});
|
|
7031
6649
|
}
|
|
@@ -7226,7 +6844,7 @@ function prepareTools3({
|
|
|
7226
6844
|
toolChoice,
|
|
7227
6845
|
modelId
|
|
7228
6846
|
}) {
|
|
7229
|
-
var
|
|
6847
|
+
var _a;
|
|
7230
6848
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
7231
6849
|
const toolWarnings = [];
|
|
7232
6850
|
const isLatest = [
|
|
@@ -7345,7 +6963,7 @@ function prepareTools3({
|
|
|
7345
6963
|
case "function":
|
|
7346
6964
|
functionDeclarations.push({
|
|
7347
6965
|
name: tool2.name,
|
|
7348
|
-
description: (
|
|
6966
|
+
description: (_a = tool2.description) != null ? _a : "",
|
|
7349
6967
|
parameters: convertJSONSchemaToOpenAPISchema(tool2.inputSchema)
|
|
7350
6968
|
});
|
|
7351
6969
|
break;
|
|
@@ -7394,7 +7012,7 @@ function prepareTools3({
|
|
|
7394
7012
|
};
|
|
7395
7013
|
default: {
|
|
7396
7014
|
const _exhaustiveCheck = type;
|
|
7397
|
-
throw new UnsupportedFunctionalityError({
|
|
7015
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
7398
7016
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
7399
7017
|
});
|
|
7400
7018
|
}
|
|
@@ -7428,17 +7046,17 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
7428
7046
|
var GoogleGenerativeAILanguageModel = class {
|
|
7429
7047
|
constructor(modelId, config) {
|
|
7430
7048
|
this.specificationVersion = "v2";
|
|
7431
|
-
var
|
|
7049
|
+
var _a;
|
|
7432
7050
|
this.modelId = modelId;
|
|
7433
7051
|
this.config = config;
|
|
7434
|
-
this.generateId = (
|
|
7052
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
7435
7053
|
}
|
|
7436
7054
|
get provider() {
|
|
7437
7055
|
return this.config.provider;
|
|
7438
7056
|
}
|
|
7439
7057
|
get supportedUrls() {
|
|
7440
|
-
var
|
|
7441
|
-
return (_c = (_b = (
|
|
7058
|
+
var _a, _b, _c;
|
|
7059
|
+
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
7442
7060
|
}
|
|
7443
7061
|
async getArgs({
|
|
7444
7062
|
prompt,
|
|
@@ -7455,7 +7073,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7455
7073
|
toolChoice,
|
|
7456
7074
|
providerOptions
|
|
7457
7075
|
}) {
|
|
7458
|
-
var
|
|
7076
|
+
var _a;
|
|
7459
7077
|
const warnings = [];
|
|
7460
7078
|
const googleOptions = await parseProviderOptions({
|
|
7461
7079
|
provider: "google",
|
|
@@ -7501,7 +7119,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7501
7119
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
7502
7120
|
// so this is needed as an escape hatch:
|
|
7503
7121
|
// TODO convert into provider option
|
|
7504
|
-
((
|
|
7122
|
+
((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
7505
7123
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
7506
7124
|
audioTimestamp: googleOptions.audioTimestamp
|
|
7507
7125
|
},
|
|
@@ -7527,7 +7145,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7527
7145
|
};
|
|
7528
7146
|
}
|
|
7529
7147
|
async doGenerate(options) {
|
|
7530
|
-
var
|
|
7148
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
7531
7149
|
const { args, warnings } = await this.getArgs(options);
|
|
7532
7150
|
const body = JSON.stringify(args);
|
|
7533
7151
|
const mergedHeaders = combineHeaders(
|
|
@@ -7551,7 +7169,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7551
7169
|
});
|
|
7552
7170
|
const candidate = response.candidates[0];
|
|
7553
7171
|
const content = [];
|
|
7554
|
-
const parts = (_b = (
|
|
7172
|
+
const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
|
|
7555
7173
|
const usageMetadata = response.usageMetadata;
|
|
7556
7174
|
let lastCodeExecutionToolCallId;
|
|
7557
7175
|
for (const part of parts) {
|
|
@@ -7677,7 +7295,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7677
7295
|
controller.enqueue({ type: "stream-start", warnings });
|
|
7678
7296
|
},
|
|
7679
7297
|
transform(chunk, controller) {
|
|
7680
|
-
var
|
|
7298
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
7681
7299
|
if (options.includeRawChunks) {
|
|
7682
7300
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
7683
7301
|
}
|
|
@@ -7688,7 +7306,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7688
7306
|
const value = chunk.value;
|
|
7689
7307
|
const usageMetadata = value.usageMetadata;
|
|
7690
7308
|
if (usageMetadata != null) {
|
|
7691
|
-
usage.inputTokens = (
|
|
7309
|
+
usage.inputTokens = (_a = usageMetadata.promptTokenCount) != null ? _a : void 0;
|
|
7692
7310
|
usage.outputTokens = (_b = usageMetadata.candidatesTokenCount) != null ? _b : void 0;
|
|
7693
7311
|
usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
|
|
7694
7312
|
usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
|
|
@@ -7913,7 +7531,7 @@ function extractSources({
|
|
|
7913
7531
|
groundingMetadata,
|
|
7914
7532
|
generateId: generateId3
|
|
7915
7533
|
}) {
|
|
7916
|
-
var
|
|
7534
|
+
var _a, _b, _c;
|
|
7917
7535
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
7918
7536
|
return void 0;
|
|
7919
7537
|
}
|
|
@@ -7925,7 +7543,7 @@ function extractSources({
|
|
|
7925
7543
|
sourceType: "url",
|
|
7926
7544
|
id: generateId3(),
|
|
7927
7545
|
url: chunk.web.uri,
|
|
7928
|
-
title: (
|
|
7546
|
+
title: (_a = chunk.web.title) != null ? _a : void 0
|
|
7929
7547
|
});
|
|
7930
7548
|
} else if (chunk.retrievedContext != null) {
|
|
7931
7549
|
const uri = chunk.retrievedContext.uri;
|
|
@@ -8213,14 +7831,14 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
8213
7831
|
this.specificationVersion = "v2";
|
|
8214
7832
|
}
|
|
8215
7833
|
get maxImagesPerCall() {
|
|
8216
|
-
var
|
|
8217
|
-
return (
|
|
7834
|
+
var _a;
|
|
7835
|
+
return (_a = this.settings.maxImagesPerCall) != null ? _a : 4;
|
|
8218
7836
|
}
|
|
8219
7837
|
get provider() {
|
|
8220
7838
|
return this.config.provider;
|
|
8221
7839
|
}
|
|
8222
7840
|
async doGenerate(options) {
|
|
8223
|
-
var
|
|
7841
|
+
var _a, _b, _c;
|
|
8224
7842
|
const {
|
|
8225
7843
|
prompt,
|
|
8226
7844
|
n = 1,
|
|
@@ -8251,7 +7869,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
8251
7869
|
providerOptions,
|
|
8252
7870
|
schema: googleImageProviderOptionsSchema
|
|
8253
7871
|
});
|
|
8254
|
-
const currentDate = (_c = (_b = (
|
|
7872
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
8255
7873
|
const parameters = {
|
|
8256
7874
|
sampleCount: n
|
|
8257
7875
|
};
|
|
@@ -8312,8 +7930,8 @@ var googleImageProviderOptionsSchema = lazySchema(
|
|
|
8312
7930
|
)
|
|
8313
7931
|
);
|
|
8314
7932
|
function createGoogleGenerativeAI(options = {}) {
|
|
8315
|
-
var
|
|
8316
|
-
const baseURL = (
|
|
7933
|
+
var _a, _b;
|
|
7934
|
+
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
8317
7935
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
8318
7936
|
const getHeaders = () => withUserAgentSuffix(
|
|
8319
7937
|
{
|
|
@@ -8327,12 +7945,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
8327
7945
|
`ai-sdk/google/${VERSION4}`
|
|
8328
7946
|
);
|
|
8329
7947
|
const createChatModel = (modelId) => {
|
|
8330
|
-
var
|
|
7948
|
+
var _a2;
|
|
8331
7949
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
|
8332
7950
|
provider: providerName,
|
|
8333
7951
|
baseURL,
|
|
8334
7952
|
headers: getHeaders,
|
|
8335
|
-
generateId: (
|
|
7953
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : generateId,
|
|
8336
7954
|
supportedUrls: () => ({
|
|
8337
7955
|
"*": [
|
|
8338
7956
|
// Google Generative Language "files" endpoint
|
|
@@ -8437,7 +8055,7 @@ function convertToOpenAIChatMessages({
|
|
|
8437
8055
|
messages.push({
|
|
8438
8056
|
role: "user",
|
|
8439
8057
|
content: content.map((part, index) => {
|
|
8440
|
-
var
|
|
8058
|
+
var _a, _b, _c;
|
|
8441
8059
|
switch (part.type) {
|
|
8442
8060
|
case "text": {
|
|
8443
8061
|
return { type: "text", text: part.text };
|
|
@@ -8450,12 +8068,12 @@ function convertToOpenAIChatMessages({
|
|
|
8450
8068
|
image_url: {
|
|
8451
8069
|
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
8452
8070
|
// OpenAI specific extension: image detail
|
|
8453
|
-
detail: (_b = (
|
|
8071
|
+
detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
|
|
8454
8072
|
}
|
|
8455
8073
|
};
|
|
8456
8074
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
8457
8075
|
if (part.data instanceof URL) {
|
|
8458
|
-
throw new UnsupportedFunctionalityError({
|
|
8076
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
8459
8077
|
functionality: "audio file parts with URLs"
|
|
8460
8078
|
});
|
|
8461
8079
|
}
|
|
@@ -8480,14 +8098,14 @@ function convertToOpenAIChatMessages({
|
|
|
8480
8098
|
};
|
|
8481
8099
|
}
|
|
8482
8100
|
default: {
|
|
8483
|
-
throw new UnsupportedFunctionalityError({
|
|
8101
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
8484
8102
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
8485
8103
|
});
|
|
8486
8104
|
}
|
|
8487
8105
|
}
|
|
8488
8106
|
} else if (part.mediaType === "application/pdf") {
|
|
8489
8107
|
if (part.data instanceof URL) {
|
|
8490
|
-
throw new UnsupportedFunctionalityError({
|
|
8108
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
8491
8109
|
functionality: "PDF file parts with URLs"
|
|
8492
8110
|
});
|
|
8493
8111
|
}
|
|
@@ -8499,7 +8117,7 @@ function convertToOpenAIChatMessages({
|
|
|
8499
8117
|
}
|
|
8500
8118
|
};
|
|
8501
8119
|
} else {
|
|
8502
|
-
throw new UnsupportedFunctionalityError({
|
|
8120
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
8503
8121
|
functionality: `file part media type ${part.mediaType}`
|
|
8504
8122
|
});
|
|
8505
8123
|
}
|
|
@@ -8883,7 +8501,7 @@ function prepareChatTools({
|
|
|
8883
8501
|
};
|
|
8884
8502
|
default: {
|
|
8885
8503
|
const _exhaustiveCheck = type;
|
|
8886
|
-
throw new UnsupportedFunctionalityError({
|
|
8504
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
8887
8505
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
8888
8506
|
});
|
|
8889
8507
|
}
|
|
@@ -8916,13 +8534,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
8916
8534
|
toolChoice,
|
|
8917
8535
|
providerOptions
|
|
8918
8536
|
}) {
|
|
8919
|
-
var
|
|
8537
|
+
var _a, _b, _c, _d;
|
|
8920
8538
|
const warnings = [];
|
|
8921
|
-
const openaiOptions = (
|
|
8539
|
+
const openaiOptions = (_a = await parseProviderOptions({
|
|
8922
8540
|
provider: "openai",
|
|
8923
8541
|
providerOptions,
|
|
8924
8542
|
schema: openaiChatLanguageModelOptions
|
|
8925
|
-
})) != null ?
|
|
8543
|
+
})) != null ? _a : {};
|
|
8926
8544
|
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
8927
8545
|
if (topK != null) {
|
|
8928
8546
|
warnings.push({
|
|
@@ -9092,7 +8710,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
9092
8710
|
};
|
|
9093
8711
|
}
|
|
9094
8712
|
async doGenerate(options) {
|
|
9095
|
-
var
|
|
8713
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
9096
8714
|
const { args: body, warnings } = await this.getArgs(options);
|
|
9097
8715
|
const {
|
|
9098
8716
|
responseHeaders,
|
|
@@ -9118,7 +8736,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
9118
8736
|
if (text != null && text.length > 0) {
|
|
9119
8737
|
content.push({ type: "text", text });
|
|
9120
8738
|
}
|
|
9121
|
-
for (const toolCall of (
|
|
8739
|
+
for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
|
|
9122
8740
|
content.push({
|
|
9123
8741
|
type: "tool-call",
|
|
9124
8742
|
toolCallId: (_b = toolCall.id) != null ? _b : generateId(),
|
|
@@ -9207,7 +8825,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
9207
8825
|
controller.enqueue({ type: "stream-start", warnings });
|
|
9208
8826
|
},
|
|
9209
8827
|
transform(chunk, controller) {
|
|
9210
|
-
var
|
|
8828
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
9211
8829
|
if (options.includeRawChunks) {
|
|
9212
8830
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
9213
8831
|
}
|
|
@@ -9233,7 +8851,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
9233
8851
|
}
|
|
9234
8852
|
}
|
|
9235
8853
|
if (value.usage != null) {
|
|
9236
|
-
usage.inputTokens = (
|
|
8854
|
+
usage.inputTokens = (_a = value.usage.prompt_tokens) != null ? _a : void 0;
|
|
9237
8855
|
usage.outputTokens = (_b = value.usage.completion_tokens) != null ? _b : void 0;
|
|
9238
8856
|
usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : void 0;
|
|
9239
8857
|
usage.reasoningTokens = (_e = (_d = value.usage.completion_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
|
|
@@ -9272,19 +8890,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
9272
8890
|
const index = toolCallDelta.index;
|
|
9273
8891
|
if (toolCalls[index] == null) {
|
|
9274
8892
|
if (toolCallDelta.type !== "function") {
|
|
9275
|
-
throw new InvalidResponseDataError({
|
|
8893
|
+
throw new chunkIXZ2T2QX_cjs.InvalidResponseDataError({
|
|
9276
8894
|
data: toolCallDelta,
|
|
9277
8895
|
message: `Expected 'function' type.`
|
|
9278
8896
|
});
|
|
9279
8897
|
}
|
|
9280
8898
|
if (toolCallDelta.id == null) {
|
|
9281
|
-
throw new InvalidResponseDataError({
|
|
8899
|
+
throw new chunkIXZ2T2QX_cjs.InvalidResponseDataError({
|
|
9282
8900
|
data: toolCallDelta,
|
|
9283
8901
|
message: `Expected 'id' to be a string.`
|
|
9284
8902
|
});
|
|
9285
8903
|
}
|
|
9286
8904
|
if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
|
|
9287
|
-
throw new InvalidResponseDataError({
|
|
8905
|
+
throw new chunkIXZ2T2QX_cjs.InvalidResponseDataError({
|
|
9288
8906
|
data: toolCallDelta,
|
|
9289
8907
|
message: `Expected 'function.name' to be a string.`
|
|
9290
8908
|
});
|
|
@@ -9395,11 +9013,11 @@ function supportsPriorityProcessing(modelId) {
|
|
|
9395
9013
|
return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
9396
9014
|
}
|
|
9397
9015
|
function getSystemMessageMode(modelId) {
|
|
9398
|
-
var
|
|
9016
|
+
var _a, _b;
|
|
9399
9017
|
if (!isReasoningModel(modelId)) {
|
|
9400
9018
|
return "system";
|
|
9401
9019
|
}
|
|
9402
|
-
return (_b = (
|
|
9020
|
+
return (_b = (_a = reasoningModels[modelId]) == null ? void 0 : _a.systemMessageMode) != null ? _b : "developer";
|
|
9403
9021
|
}
|
|
9404
9022
|
var reasoningModels = {
|
|
9405
9023
|
o3: {
|
|
@@ -9436,7 +9054,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
9436
9054
|
for (const { role, content } of prompt) {
|
|
9437
9055
|
switch (role) {
|
|
9438
9056
|
case "system": {
|
|
9439
|
-
throw new InvalidPromptError({
|
|
9057
|
+
throw new chunkIXZ2T2QX_cjs.InvalidPromptError({
|
|
9440
9058
|
message: "Unexpected system message in prompt: ${content}",
|
|
9441
9059
|
prompt
|
|
9442
9060
|
});
|
|
@@ -9462,7 +9080,7 @@ ${userMessage}
|
|
|
9462
9080
|
return part.text;
|
|
9463
9081
|
}
|
|
9464
9082
|
case "tool-call": {
|
|
9465
|
-
throw new UnsupportedFunctionalityError({
|
|
9083
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
9466
9084
|
functionality: "tool-call messages"
|
|
9467
9085
|
});
|
|
9468
9086
|
}
|
|
@@ -9475,7 +9093,7 @@ ${assistantMessage}
|
|
|
9475
9093
|
break;
|
|
9476
9094
|
}
|
|
9477
9095
|
case "tool": {
|
|
9478
|
-
throw new UnsupportedFunctionalityError({
|
|
9096
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
9479
9097
|
functionality: "tool messages"
|
|
9480
9098
|
});
|
|
9481
9099
|
}
|
|
@@ -9704,7 +9322,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
9704
9322
|
};
|
|
9705
9323
|
}
|
|
9706
9324
|
async doGenerate(options) {
|
|
9707
|
-
var
|
|
9325
|
+
var _a, _b, _c;
|
|
9708
9326
|
const { args, warnings } = await this.getArgs(options);
|
|
9709
9327
|
const {
|
|
9710
9328
|
responseHeaders,
|
|
@@ -9732,7 +9350,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
9732
9350
|
return {
|
|
9733
9351
|
content: [{ type: "text", text: choice.text }],
|
|
9734
9352
|
usage: {
|
|
9735
|
-
inputTokens: (
|
|
9353
|
+
inputTokens: (_a = response.usage) == null ? void 0 : _a.prompt_tokens,
|
|
9736
9354
|
outputTokens: (_b = response.usage) == null ? void 0 : _b.completion_tokens,
|
|
9737
9355
|
totalTokens: (_c = response.usage) == null ? void 0 : _c.total_tokens
|
|
9738
9356
|
},
|
|
@@ -9886,20 +9504,20 @@ var OpenAIEmbeddingModel = class {
|
|
|
9886
9504
|
abortSignal,
|
|
9887
9505
|
providerOptions
|
|
9888
9506
|
}) {
|
|
9889
|
-
var
|
|
9507
|
+
var _a;
|
|
9890
9508
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
9891
|
-
throw new TooManyEmbeddingValuesForCallError({
|
|
9509
|
+
throw new chunkIXZ2T2QX_cjs.TooManyEmbeddingValuesForCallError({
|
|
9892
9510
|
provider: this.provider,
|
|
9893
9511
|
modelId: this.modelId,
|
|
9894
9512
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
9895
9513
|
values
|
|
9896
9514
|
});
|
|
9897
9515
|
}
|
|
9898
|
-
const openaiOptions = (
|
|
9516
|
+
const openaiOptions = (_a = await parseProviderOptions({
|
|
9899
9517
|
provider: "openai",
|
|
9900
9518
|
providerOptions,
|
|
9901
9519
|
schema: openaiEmbeddingProviderOptions
|
|
9902
|
-
})) != null ?
|
|
9520
|
+
})) != null ? _a : {};
|
|
9903
9521
|
const {
|
|
9904
9522
|
responseHeaders,
|
|
9905
9523
|
value: response,
|
|
@@ -9960,8 +9578,8 @@ var OpenAIImageModel = class {
|
|
|
9960
9578
|
this.specificationVersion = "v2";
|
|
9961
9579
|
}
|
|
9962
9580
|
get maxImagesPerCall() {
|
|
9963
|
-
var
|
|
9964
|
-
return (
|
|
9581
|
+
var _a;
|
|
9582
|
+
return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
|
|
9965
9583
|
}
|
|
9966
9584
|
get provider() {
|
|
9967
9585
|
return this.config.provider;
|
|
@@ -9976,7 +9594,7 @@ var OpenAIImageModel = class {
|
|
|
9976
9594
|
headers,
|
|
9977
9595
|
abortSignal
|
|
9978
9596
|
}) {
|
|
9979
|
-
var
|
|
9597
|
+
var _a, _b, _c, _d;
|
|
9980
9598
|
const warnings = [];
|
|
9981
9599
|
if (aspectRatio != null) {
|
|
9982
9600
|
warnings.push({
|
|
@@ -9988,7 +9606,7 @@ var OpenAIImageModel = class {
|
|
|
9988
9606
|
if (seed != null) {
|
|
9989
9607
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
9990
9608
|
}
|
|
9991
|
-
const currentDate = (_c = (_b = (
|
|
9609
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
9992
9610
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
9993
9611
|
url: this.config.url({
|
|
9994
9612
|
path: "/images/generations",
|
|
@@ -10348,7 +9966,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10348
9966
|
store,
|
|
10349
9967
|
hasLocalShellTool = false
|
|
10350
9968
|
}) {
|
|
10351
|
-
var
|
|
9969
|
+
var _a, _b, _c, _d;
|
|
10352
9970
|
const input = [];
|
|
10353
9971
|
const warnings = [];
|
|
10354
9972
|
for (const { role, content } of prompt) {
|
|
@@ -10383,7 +10001,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10383
10001
|
input.push({
|
|
10384
10002
|
role: "user",
|
|
10385
10003
|
content: content.map((part, index) => {
|
|
10386
|
-
var
|
|
10004
|
+
var _a2, _b2, _c2;
|
|
10387
10005
|
switch (part.type) {
|
|
10388
10006
|
case "text": {
|
|
10389
10007
|
return { type: "input_text", text: part.text };
|
|
@@ -10396,7 +10014,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10396
10014
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
10397
10015
|
image_url: `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
10398
10016
|
},
|
|
10399
|
-
detail: (_b2 = (
|
|
10017
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
10400
10018
|
};
|
|
10401
10019
|
} else if (part.mediaType === "application/pdf") {
|
|
10402
10020
|
if (part.data instanceof URL) {
|
|
@@ -10413,7 +10031,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10413
10031
|
}
|
|
10414
10032
|
};
|
|
10415
10033
|
} else {
|
|
10416
|
-
throw new UnsupportedFunctionalityError({
|
|
10034
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
10417
10035
|
functionality: `file part media type ${part.mediaType}`
|
|
10418
10036
|
});
|
|
10419
10037
|
}
|
|
@@ -10428,7 +10046,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10428
10046
|
for (const part of content) {
|
|
10429
10047
|
switch (part.type) {
|
|
10430
10048
|
case "text": {
|
|
10431
|
-
const id = (_b = (
|
|
10049
|
+
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
|
|
10432
10050
|
if (store && id != null) {
|
|
10433
10051
|
input.push({ type: "item_reference", id });
|
|
10434
10052
|
break;
|
|
@@ -11267,7 +10885,7 @@ async function prepareResponsesTools({
|
|
|
11267
10885
|
};
|
|
11268
10886
|
default: {
|
|
11269
10887
|
const _exhaustiveCheck = type;
|
|
11270
|
-
throw new UnsupportedFunctionalityError({
|
|
10888
|
+
throw new chunkIXZ2T2QX_cjs.UnsupportedFunctionalityError({
|
|
11271
10889
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
11272
10890
|
});
|
|
11273
10891
|
}
|
|
@@ -11301,7 +10919,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11301
10919
|
toolChoice,
|
|
11302
10920
|
responseFormat
|
|
11303
10921
|
}) {
|
|
11304
|
-
var
|
|
10922
|
+
var _a, _b, _c, _d;
|
|
11305
10923
|
const warnings = [];
|
|
11306
10924
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
11307
10925
|
if (topK != null) {
|
|
@@ -11341,7 +10959,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11341
10959
|
prompt,
|
|
11342
10960
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
11343
10961
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
11344
|
-
store: (
|
|
10962
|
+
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
|
|
11345
10963
|
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
11346
10964
|
});
|
|
11347
10965
|
warnings.push(...inputWarnings);
|
|
@@ -11496,7 +11114,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11496
11114
|
};
|
|
11497
11115
|
}
|
|
11498
11116
|
async doGenerate(options) {
|
|
11499
|
-
var
|
|
11117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
11500
11118
|
const {
|
|
11501
11119
|
args: body,
|
|
11502
11120
|
warnings,
|
|
@@ -11522,7 +11140,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11522
11140
|
fetch: this.config.fetch
|
|
11523
11141
|
});
|
|
11524
11142
|
if (response.error) {
|
|
11525
|
-
throw new APICallError({
|
|
11143
|
+
throw new chunkIXZ2T2QX_cjs.APICallError({
|
|
11526
11144
|
message: response.error.message,
|
|
11527
11145
|
url,
|
|
11528
11146
|
requestBodyValues: body,
|
|
@@ -11548,7 +11166,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11548
11166
|
providerMetadata: {
|
|
11549
11167
|
openai: {
|
|
11550
11168
|
itemId: part.id,
|
|
11551
|
-
reasoningEncryptedContent: (
|
|
11169
|
+
reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
|
|
11552
11170
|
}
|
|
11553
11171
|
}
|
|
11554
11172
|
});
|
|
@@ -11817,7 +11435,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11817
11435
|
controller.enqueue({ type: "stream-start", warnings });
|
|
11818
11436
|
},
|
|
11819
11437
|
transform(chunk, controller) {
|
|
11820
|
-
var
|
|
11438
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
11821
11439
|
if (options.includeRawChunks) {
|
|
11822
11440
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
11823
11441
|
}
|
|
@@ -11927,7 +11545,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11927
11545
|
providerMetadata: {
|
|
11928
11546
|
openai: {
|
|
11929
11547
|
itemId: value.item.id,
|
|
11930
|
-
reasoningEncryptedContent: (
|
|
11548
|
+
reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
|
|
11931
11549
|
}
|
|
11932
11550
|
}
|
|
11933
11551
|
});
|
|
@@ -12305,11 +11923,11 @@ function getResponsesModelConfig(modelId) {
|
|
|
12305
11923
|
};
|
|
12306
11924
|
}
|
|
12307
11925
|
function mapWebSearchOutput(action) {
|
|
12308
|
-
var
|
|
11926
|
+
var _a;
|
|
12309
11927
|
switch (action.type) {
|
|
12310
11928
|
case "search":
|
|
12311
11929
|
return {
|
|
12312
|
-
action: { type: "search", query: (
|
|
11930
|
+
action: { type: "search", query: (_a = action.query) != null ? _a : void 0 },
|
|
12313
11931
|
// include sources when provided by the Responses API (behind include flag)
|
|
12314
11932
|
...action.sources != null && { sources: action.sources }
|
|
12315
11933
|
};
|
|
@@ -12394,8 +12012,8 @@ var OpenAISpeechModel = class {
|
|
|
12394
12012
|
};
|
|
12395
12013
|
}
|
|
12396
12014
|
async doGenerate(options) {
|
|
12397
|
-
var
|
|
12398
|
-
const currentDate = (_c = (_b = (
|
|
12015
|
+
var _a, _b, _c;
|
|
12016
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
12399
12017
|
const { requestBody, warnings } = await this.getArgs(options);
|
|
12400
12018
|
const {
|
|
12401
12019
|
value: audio,
|
|
@@ -12606,8 +12224,8 @@ var OpenAITranscriptionModel = class {
|
|
|
12606
12224
|
};
|
|
12607
12225
|
}
|
|
12608
12226
|
async doGenerate(options) {
|
|
12609
|
-
var
|
|
12610
|
-
const currentDate = (_c = (_b = (
|
|
12227
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
12228
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
12611
12229
|
const { formData, warnings } = await this.getArgs(options);
|
|
12612
12230
|
const {
|
|
12613
12231
|
value: response,
|
|
@@ -12653,13 +12271,13 @@ var OpenAITranscriptionModel = class {
|
|
|
12653
12271
|
};
|
|
12654
12272
|
var VERSION5 = "2.0.69" ;
|
|
12655
12273
|
function createOpenAI(options = {}) {
|
|
12656
|
-
var
|
|
12657
|
-
const baseURL = (
|
|
12274
|
+
var _a, _b;
|
|
12275
|
+
const baseURL = (_a = withoutTrailingSlash(
|
|
12658
12276
|
loadOptionalSetting({
|
|
12659
12277
|
settingValue: options.baseURL,
|
|
12660
12278
|
environmentVariableName: "OPENAI_BASE_URL"
|
|
12661
12279
|
})
|
|
12662
|
-
)) != null ?
|
|
12280
|
+
)) != null ? _a : "https://api.openai.com/v1";
|
|
12663
12281
|
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
12664
12282
|
const getHeaders = () => withUserAgentSuffix(
|
|
12665
12283
|
{
|
|
@@ -12748,34 +12366,34 @@ function createOpenAI(options = {}) {
|
|
|
12748
12366
|
}
|
|
12749
12367
|
createOpenAI();
|
|
12750
12368
|
|
|
12751
|
-
exports.APICallError = APICallError;
|
|
12752
|
-
exports.EmptyResponseBodyError = EmptyResponseBodyError;
|
|
12753
|
-
exports.EventSourceParserStream = EventSourceParserStream;
|
|
12754
|
-
exports.InvalidArgumentError = InvalidArgumentError;
|
|
12755
|
-
exports.InvalidResponseDataError = InvalidResponseDataError;
|
|
12756
|
-
exports.JSONParseError = JSONParseError;
|
|
12757
|
-
exports.LoadAPIKeyError = LoadAPIKeyError;
|
|
12758
12369
|
exports.MastraModelGateway = MastraModelGateway;
|
|
12759
|
-
exports.NoSuchModelError = NoSuchModelError;
|
|
12760
12370
|
exports.OpenAICompatibleImageModel = OpenAICompatibleImageModel;
|
|
12761
|
-
exports.TooManyEmbeddingValuesForCallError = TooManyEmbeddingValuesForCallError;
|
|
12762
|
-
exports.TypeValidationError = TypeValidationError;
|
|
12763
|
-
exports.UnsupportedFunctionalityError = UnsupportedFunctionalityError;
|
|
12764
12371
|
exports.combineHeaders = combineHeaders;
|
|
12372
|
+
exports.convertBase64ToUint8Array = convertBase64ToUint8Array;
|
|
12765
12373
|
exports.convertToBase64 = convertToBase64;
|
|
12766
12374
|
exports.createAnthropic = createAnthropic;
|
|
12375
|
+
exports.createBinaryResponseHandler = createBinaryResponseHandler;
|
|
12767
12376
|
exports.createEventSourceResponseHandler = createEventSourceResponseHandler;
|
|
12768
12377
|
exports.createGoogleGenerativeAI = createGoogleGenerativeAI;
|
|
12769
12378
|
exports.createJsonErrorResponseHandler = createJsonErrorResponseHandler;
|
|
12770
12379
|
exports.createJsonResponseHandler = createJsonResponseHandler;
|
|
12771
12380
|
exports.createOpenAI = createOpenAI;
|
|
12772
12381
|
exports.createOpenAICompatible = createOpenAICompatible;
|
|
12382
|
+
exports.createProviderDefinedToolFactoryWithOutputSchema = createProviderDefinedToolFactoryWithOutputSchema;
|
|
12773
12383
|
exports.generateId = generateId;
|
|
12774
12384
|
exports.injectJsonInstructionIntoMessages = injectJsonInstructionIntoMessages;
|
|
12385
|
+
exports.isParsableJson = isParsableJson;
|
|
12386
|
+
exports.lazySchema = lazySchema;
|
|
12387
|
+
exports.lazyValidator = lazyValidator;
|
|
12775
12388
|
exports.loadApiKey = loadApiKey;
|
|
12389
|
+
exports.loadSetting = loadSetting;
|
|
12390
|
+
exports.mediaTypeToExtension = mediaTypeToExtension;
|
|
12776
12391
|
exports.parseProviderOptions = parseProviderOptions;
|
|
12392
|
+
exports.postFormDataToApi = postFormDataToApi;
|
|
12777
12393
|
exports.postJsonToApi = postJsonToApi;
|
|
12394
|
+
exports.validateTypes = validateTypes;
|
|
12778
12395
|
exports.withUserAgentSuffix = withUserAgentSuffix;
|
|
12779
12396
|
exports.withoutTrailingSlash = withoutTrailingSlash;
|
|
12780
|
-
|
|
12781
|
-
//# sourceMappingURL=chunk-
|
|
12397
|
+
exports.zodSchema = zodSchema;
|
|
12398
|
+
//# sourceMappingURL=chunk-OWIEOL55.cjs.map
|
|
12399
|
+
//# sourceMappingURL=chunk-OWIEOL55.cjs.map
|