@mastra/core 1.0.0-beta.13 → 1.0.0-beta.15
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 +477 -0
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +2 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +6 -7
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +17 -9
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +1 -1
- 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.map +1 -1
- package/dist/agent/trip-wire.d.ts +2 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +4 -1
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/bundler/types.d.ts +1 -0
- package/dist/bundler/types.d.ts.map +1 -1
- package/dist/chunk-2AU5ZHBL.js +79 -0
- package/dist/chunk-2AU5ZHBL.js.map +1 -0
- package/dist/{chunk-7HEAVZRS.cjs → chunk-2OOMJRXZ.cjs} +15 -15
- package/dist/{chunk-7HEAVZRS.cjs.map → chunk-2OOMJRXZ.cjs.map} +1 -1
- package/dist/chunk-37YWZMBX.js +27 -0
- package/dist/chunk-37YWZMBX.js.map +1 -0
- package/dist/{chunk-VETAQUW3.js → chunk-3HDRO3GG.js} +790 -1206
- package/dist/chunk-3HDRO3GG.js.map +1 -0
- package/dist/{chunk-MRRFTNF4.js → chunk-4DFWV4IR.js} +3 -4
- package/dist/chunk-4DFWV4IR.js.map +1 -0
- package/dist/{chunk-373OC54J.js → chunk-4HP7CS6L.js} +7 -6
- package/dist/chunk-4HP7CS6L.js.map +1 -0
- package/dist/{chunk-62Q7K656.js → chunk-4J4M2Q5R.js} +125 -121
- package/dist/chunk-4J4M2Q5R.js.map +1 -0
- package/dist/{chunk-HWMMIRIF.cjs → chunk-4U7ZLI36.cjs} +3 -2
- package/dist/chunk-4U7ZLI36.cjs.map +1 -0
- package/dist/{chunk-Z55SJVEC.cjs → chunk-6HJFCSJ4.cjs} +7 -6
- package/dist/chunk-6HJFCSJ4.cjs.map +1 -0
- package/dist/{chunk-Y7MZ5LJT.cjs → chunk-AAX7ZOM7.cjs} +101 -102
- package/dist/chunk-AAX7ZOM7.cjs.map +1 -0
- package/dist/{chunk-WPTTKULS.js → chunk-AR5CF3IN.js} +4 -4
- package/dist/{chunk-WPTTKULS.js.map → chunk-AR5CF3IN.js.map} +1 -1
- package/dist/{chunk-5VZGJTPR.js → chunk-BAZHNX5P.js} +57 -11
- package/dist/chunk-BAZHNX5P.js.map +1 -0
- package/dist/{chunk-MLKE7HRS.cjs → chunk-BC2VKOH4.cjs} +43 -21
- package/dist/chunk-BC2VKOH4.cjs.map +1 -0
- package/dist/{chunk-2IU4RGU5.js → chunk-BCUKD2XG.js} +59 -19
- package/dist/chunk-BCUKD2XG.js.map +1 -0
- package/dist/{chunk-WYGUWVTF.js → chunk-CBQ6WDUJ.js} +9 -9
- package/dist/chunk-CBQ6WDUJ.js.map +1 -0
- package/dist/chunk-CBVHOGXX.cjs +674 -0
- package/dist/chunk-CBVHOGXX.cjs.map +1 -0
- package/dist/{chunk-PJAK4U6R.cjs → chunk-CBY37FTP.cjs} +28 -28
- package/dist/chunk-CBY37FTP.cjs.map +1 -0
- package/dist/{chunk-BQDZIQ3G.js → chunk-D2IFWD7A.js} +365 -137
- package/dist/chunk-D2IFWD7A.js.map +1 -0
- package/dist/{chunk-R5AJGM55.cjs → chunk-DDK3URK2.cjs} +987 -519
- package/dist/chunk-DDK3URK2.cjs.map +1 -0
- package/dist/chunk-DRJTNGI4.cjs +263 -0
- package/dist/chunk-DRJTNGI4.cjs.map +1 -0
- package/dist/{chunk-X6IBA7FP.cjs → chunk-EMLEZXTQ.cjs} +22 -120
- package/dist/chunk-EMLEZXTQ.cjs.map +1 -0
- package/dist/{chunk-OWIEOL55.cjs → chunk-F75EQ574.cjs} +695 -254
- package/dist/chunk-F75EQ574.cjs.map +1 -0
- package/dist/{chunk-YPLZDWG7.js → chunk-FJEVLHJT.js} +3 -2
- package/dist/chunk-FJEVLHJT.js.map +1 -0
- package/dist/chunk-GVAPYQRO.cjs +252 -0
- package/dist/chunk-GVAPYQRO.cjs.map +1 -0
- package/dist/{chunk-MXBVP7HX.cjs → chunk-GXMJ5URG.cjs} +227 -181
- package/dist/chunk-GXMJ5URG.cjs.map +1 -0
- package/dist/chunk-H2NHG7QL.cjs +32 -0
- package/dist/chunk-H2NHG7QL.cjs.map +1 -0
- package/dist/chunk-HAYBGFPA.js +259 -0
- package/dist/chunk-HAYBGFPA.js.map +1 -0
- package/dist/{chunk-GIWC35YQ.js → chunk-IHISDRFV.js} +299 -49
- package/dist/chunk-IHISDRFV.js.map +1 -0
- package/dist/{chunk-VEPP75C4.cjs → chunk-IRTICXRZ.cjs} +101 -61
- package/dist/chunk-IRTICXRZ.cjs.map +1 -0
- package/dist/{chunk-ARAQIW6E.js → chunk-K66U47VL.js} +617 -188
- package/dist/chunk-K66U47VL.js.map +1 -0
- package/dist/{chunk-LGB4VNZI.cjs → chunk-LOV5NNGK.cjs} +811 -1235
- package/dist/chunk-LOV5NNGK.cjs.map +1 -0
- package/dist/{chunk-E5BQRAJK.js → chunk-NGWTSHNA.js} +823 -362
- package/dist/chunk-NGWTSHNA.js.map +1 -0
- package/dist/{chunk-72YCRTEX.cjs → chunk-O2CAMK4A.cjs} +13 -2
- package/dist/chunk-O2CAMK4A.cjs.map +1 -0
- package/dist/{chunk-4BC5FUAO.js → chunk-O7M7DR4E.js} +6 -5
- package/dist/chunk-O7M7DR4E.js.map +1 -0
- package/dist/chunk-OTIGV7CL.js +10215 -0
- package/dist/chunk-OTIGV7CL.js.map +1 -0
- package/dist/{chunk-WYWRMIQC.js → chunk-QXL3F3T2.js} +9 -105
- package/dist/chunk-QXL3F3T2.js.map +1 -0
- package/dist/{chunk-U4CSOY6T.cjs → chunk-RA2CHJCY.cjs} +399 -171
- package/dist/chunk-RA2CHJCY.cjs.map +1 -0
- package/dist/chunk-RMV5HJM7.cjs +10237 -0
- package/dist/chunk-RMV5HJM7.cjs.map +1 -0
- package/dist/{chunk-AGHLXC4I.cjs → chunk-S23TNDXG.cjs} +300 -50
- package/dist/chunk-S23TNDXG.cjs.map +1 -0
- package/dist/{chunk-H4VUIOWU.cjs → chunk-SSB4AVHU.cjs} +20 -19
- package/dist/chunk-SSB4AVHU.cjs.map +1 -0
- package/dist/chunk-ST7NBF4H.cjs +84 -0
- package/dist/chunk-ST7NBF4H.cjs.map +1 -0
- package/dist/{chunk-SZYSDJTN.cjs → chunk-T2LVULCK.cjs} +142 -137
- package/dist/chunk-T2LVULCK.cjs.map +1 -0
- package/dist/chunk-VE6HQ7H6.js +250 -0
- package/dist/chunk-VE6HQ7H6.js.map +1 -0
- package/dist/{chunk-RCJLMMTO.js → chunk-XJB7J4UT.js} +30 -8
- package/dist/chunk-XJB7J4UT.js.map +1 -0
- package/dist/chunk-YV43YEZ6.js +598 -0
- package/dist/chunk-YV43YEZ6.js.map +1 -0
- package/dist/{chunk-Y36Y5MTD.js → chunk-ZGIVAQRI.js} +13 -3
- package/dist/chunk-ZGIVAQRI.js.map +1 -0
- package/dist/error/index.cjs +6 -6
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/evals/index.cjs +49 -9
- package/dist/evals/index.js +2 -2
- package/dist/evals/run/index.d.ts.map +1 -1
- package/dist/evals/scoreTraces/index.cjs +70 -22
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +63 -15
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/evals/scoreTraces/utils.d.ts.map +1 -1
- package/dist/evals/types.d.ts +568 -116
- package/dist/evals/types.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 +21 -21
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/aisdk/generate-to-stream.d.ts +20 -0
- package/dist/llm/model/aisdk/generate-to-stream.d.ts.map +1 -0
- package/dist/llm/model/aisdk/v5/model.d.ts +4 -0
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
- package/dist/llm/model/aisdk/v6/model.d.ts +43 -0
- package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -0
- package/dist/llm/model/embedding-router.d.ts +1 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-options.d.ts +2 -1
- package/dist/llm/model/provider-options.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +126 -17
- package/dist/llm/model/resolve-model.d.ts +2 -2
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/llm/model/shared.types.d.ts +18 -7
- package/dist/llm/model/shared.types.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +8 -8
- package/dist/loop/network/index.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/MastraLanguageModelV3Mock.d.ts +29 -0
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts.map +1 -0
- package/dist/loop/test-utils/fullStream.d.ts +2 -1
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/resultObject.d.ts +2 -1
- package/dist/loop/test-utils/resultObject.d.ts.map +1 -1
- package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
- package/dist/loop/test-utils/utils-v3.d.ts +55 -0
- package/dist/loop/test-utils/utils-v3.d.ts.map +1 -0
- package/dist/loop/types.d.ts +10 -8
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +36 -36
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +25 -25
- 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 +12 -12
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +36 -36
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/run-state.d.ts +2 -2
- package/dist/loop/workflows/run-state.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +12 -12
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +7 -2
- package/dist/mastra/index.d.ts.map +1 -1
- 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 +26 -6
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +9 -8
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/mock.d.ts +2 -1
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +3 -4
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/working-memory-utils.d.ts +20 -0
- package/dist/memory/working-memory-utils.d.ts.map +1 -0
- package/dist/models-dev-26XLUKVK.cjs +12 -0
- package/dist/{models-dev-D3EKFGAO.cjs.map → models-dev-26XLUKVK.cjs.map} +1 -1
- package/dist/models-dev-HUFLQFPB.js +3 -0
- package/dist/{models-dev-EO22XOXQ.js.map → models-dev-HUFLQFPB.js.map} +1 -1
- package/dist/netlify-CUYK2MZ2.cjs +12 -0
- package/dist/{netlify-WE42TZIT.cjs.map → netlify-CUYK2MZ2.cjs.map} +1 -1
- package/dist/netlify-J4QPOROO.js +3 -0
- package/dist/{netlify-AE4LNCAI.js.map → netlify-J4QPOROO.js.map} +1 -1
- package/dist/observability/index.cjs +14 -10
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +32 -19
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.d.ts +9 -7
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/message-history.d.ts +7 -1
- package/dist/processors/memory/message-history.d.ts.map +1 -1
- package/dist/processors/processors/language-detector.d.ts.map +1 -1
- package/dist/processors/processors/moderation.d.ts.map +1 -1
- package/dist/processors/processors/pii-detector.d.ts.map +1 -1
- package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +5 -2
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +2 -0
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +26 -26
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-6CIGRQVZ.js +3 -0
- package/dist/{provider-registry-6LF3NGC5.js.map → provider-registry-6CIGRQVZ.js.map} +1 -1
- package/dist/provider-registry-7O7FJ4BS.cjs +40 -0
- package/dist/{provider-registry-73FKMXJV.cjs.map → provider-registry-7O7FJ4BS.cjs.map} +1 -1
- package/dist/provider-registry.json +295 -45
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.cjs.map +1 -1
- package/dist/relevance/index.js +2 -2
- package/dist/relevance/index.js.map +1 -1
- package/dist/server/index.cjs +5 -5
- package/dist/server/index.js +1 -1
- package/dist/storage/base.d.ts +40 -292
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +60 -0
- package/dist/storage/constants.cjs.map +1 -0
- package/dist/storage/constants.d.ts +6 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +3 -0
- package/dist/storage/constants.js.map +1 -0
- package/dist/storage/domains/agents/base.d.ts +2 -2
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts +5 -4
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/base.d.ts +20 -0
- package/dist/storage/domains/base.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +57 -0
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -0
- package/dist/storage/domains/memory/base.d.ts +2 -2
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +5 -13
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/base.d.ts +24 -29
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +1 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/inmemory.d.ts +46 -35
- package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +2365 -0
- package/dist/storage/domains/observability/types.d.ts.map +1 -0
- package/dist/storage/domains/scores/base.d.ts +9 -20
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +11 -22
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/shared.d.ts +76 -0
- package/dist/storage/domains/shared.d.ts.map +1 -0
- package/dist/storage/domains/workflows/base.d.ts +4 -2
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +10 -9
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +272 -59
- package/dist/storage/index.js +2 -1
- package/dist/storage/mock.d.ts +28 -174
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +39 -44
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/utils.d.ts +5 -0
- package/dist/storage/utils.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +4 -4
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +2 -2
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +7 -5
- package/dist/stream/base/output.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 +32 -21
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/token-6GSAFR2W-LTZ7QQUP.js +61 -0
- package/dist/token-6GSAFR2W-LTZ7QQUP.js.map +1 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs +63 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js +8 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js.map +1 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs +10 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs.map +1 -0
- package/dist/tool-loop-agent/index.cjs +20 -0
- package/dist/tool-loop-agent/index.cjs.map +1 -0
- package/dist/tool-loop-agent/index.d.ts +36 -0
- package/dist/tool-loop-agent/index.d.ts.map +1 -0
- package/dist/tool-loop-agent/index.js +3 -0
- package/dist/tool-loop-agent/index.js.map +1 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts +30 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +1 -0
- package/dist/tool-loop-agent/utils.d.ts +17 -0
- package/dist/tool-loop-agent/utils.d.ts.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.map +1 -1
- package/dist/tools/toolchecks.d.ts +1 -1
- package/dist/tools/toolchecks.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils/zod-utils.d.ts +34 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils.cjs +39 -22
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -1
- package/dist/vector/embed.d.ts +1 -0
- package/dist/vector/embed.d.ts.map +1 -1
- package/dist/vector/index.cjs +18 -5
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +9 -2
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +26 -3
- package/dist/vector/vector.d.ts.map +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/default.d.ts +2 -0
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +1 -0
- 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 +5 -0
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +20 -4
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +10 -2
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +1 -0
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +4 -0
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/entry.d.ts +3 -2
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +1 -0
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/types.d.ts +23 -3
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +1 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +26 -9
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +20 -12
- package/src/llm/model/provider-types.generated.d.ts +126 -17
- package/storage/constants.d.ts +1 -0
- package/tool-loop-agent.d.ts +1 -0
- package/dist/chunk-2IU4RGU5.js.map +0 -1
- package/dist/chunk-373OC54J.js.map +0 -1
- package/dist/chunk-4BC5FUAO.js.map +0 -1
- package/dist/chunk-5VZGJTPR.js.map +0 -1
- package/dist/chunk-62Q7K656.js.map +0 -1
- package/dist/chunk-72YCRTEX.cjs.map +0 -1
- package/dist/chunk-ADADLFDR.js +0 -42
- package/dist/chunk-ADADLFDR.js.map +0 -1
- package/dist/chunk-AGHLXC4I.cjs.map +0 -1
- package/dist/chunk-ARAQIW6E.js.map +0 -1
- package/dist/chunk-BQDZIQ3G.js.map +0 -1
- package/dist/chunk-E5BQRAJK.js.map +0 -1
- package/dist/chunk-GIWC35YQ.js.map +0 -1
- package/dist/chunk-H4VUIOWU.cjs.map +0 -1
- package/dist/chunk-HWMMIRIF.cjs.map +0 -1
- package/dist/chunk-IXZ2T2QX.cjs +0 -448
- package/dist/chunk-IXZ2T2QX.cjs.map +0 -1
- package/dist/chunk-LGB4VNZI.cjs.map +0 -1
- package/dist/chunk-MLKE7HRS.cjs.map +0 -1
- package/dist/chunk-MRRFTNF4.js.map +0 -1
- package/dist/chunk-MXBVP7HX.cjs.map +0 -1
- package/dist/chunk-OWIEOL55.cjs.map +0 -1
- package/dist/chunk-PJAK4U6R.cjs.map +0 -1
- package/dist/chunk-R5AJGM55.cjs.map +0 -1
- package/dist/chunk-RCJLMMTO.js.map +0 -1
- package/dist/chunk-SZYSDJTN.cjs.map +0 -1
- package/dist/chunk-T2VLUFGG.cjs +0 -47
- package/dist/chunk-T2VLUFGG.cjs.map +0 -1
- package/dist/chunk-U4CSOY6T.cjs.map +0 -1
- package/dist/chunk-UBSPZTQX.js +0 -434
- package/dist/chunk-UBSPZTQX.js.map +0 -1
- package/dist/chunk-VEPP75C4.cjs.map +0 -1
- package/dist/chunk-VETAQUW3.js.map +0 -1
- package/dist/chunk-WYGUWVTF.js.map +0 -1
- package/dist/chunk-WYWRMIQC.js.map +0 -1
- package/dist/chunk-X6IBA7FP.cjs.map +0 -1
- package/dist/chunk-Y36Y5MTD.js.map +0 -1
- package/dist/chunk-Y7MZ5LJT.cjs.map +0 -1
- package/dist/chunk-YPLZDWG7.js.map +0 -1
- package/dist/chunk-Z55SJVEC.cjs.map +0 -1
- package/dist/llm/model/is-v2-model.d.ts +0 -3
- package/dist/llm/model/is-v2-model.d.ts.map +0 -1
- package/dist/models-dev-D3EKFGAO.cjs +0 -12
- package/dist/models-dev-EO22XOXQ.js +0 -3
- package/dist/netlify-AE4LNCAI.js +0 -3
- package/dist/netlify-WE42TZIT.cjs +0 -12
- package/dist/provider-registry-6LF3NGC5.js +0 -3
- package/dist/provider-registry-73FKMXJV.cjs +0 -40
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkIXZ2T2QX_cjs = require('./chunk-IXZ2T2QX.cjs');
|
|
4
3
|
var z4 = require('zod/v4');
|
|
5
4
|
var v3 = require('zod/v3');
|
|
6
5
|
|
|
@@ -24,6 +23,436 @@ function _interopNamespace(e) {
|
|
|
24
23
|
|
|
25
24
|
var z4__namespace = /*#__PURE__*/_interopNamespace(z4);
|
|
26
25
|
|
|
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 name8 = "AI_LoadSettingError";
|
|
218
|
+
var marker9 = `vercel.ai.error.${name8}`;
|
|
219
|
+
var symbol9 = Symbol.for(marker9);
|
|
220
|
+
var _a9;
|
|
221
|
+
var LoadSettingError = class extends AISDKError {
|
|
222
|
+
// used in isInstance
|
|
223
|
+
constructor({ message }) {
|
|
224
|
+
super({ name: name8, message });
|
|
225
|
+
this[_a9] = true;
|
|
226
|
+
}
|
|
227
|
+
static isInstance(error) {
|
|
228
|
+
return AISDKError.hasMarker(error, marker9);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
_a9 = symbol9;
|
|
232
|
+
var name10 = "AI_NoSuchModelError";
|
|
233
|
+
var marker11 = `vercel.ai.error.${name10}`;
|
|
234
|
+
var symbol11 = Symbol.for(marker11);
|
|
235
|
+
var _a11;
|
|
236
|
+
var NoSuchModelError = class extends AISDKError {
|
|
237
|
+
constructor({
|
|
238
|
+
errorName = name10,
|
|
239
|
+
modelId,
|
|
240
|
+
modelType,
|
|
241
|
+
message = `No such ${modelType}: ${modelId}`
|
|
242
|
+
}) {
|
|
243
|
+
super({ name: errorName, message });
|
|
244
|
+
this[_a11] = true;
|
|
245
|
+
this.modelId = modelId;
|
|
246
|
+
this.modelType = modelType;
|
|
247
|
+
}
|
|
248
|
+
static isInstance(error) {
|
|
249
|
+
return AISDKError.hasMarker(error, marker11);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
_a11 = symbol11;
|
|
253
|
+
var name11 = "AI_TooManyEmbeddingValuesForCallError";
|
|
254
|
+
var marker12 = `vercel.ai.error.${name11}`;
|
|
255
|
+
var symbol12 = Symbol.for(marker12);
|
|
256
|
+
var _a12;
|
|
257
|
+
var TooManyEmbeddingValuesForCallError = class extends AISDKError {
|
|
258
|
+
constructor(options) {
|
|
259
|
+
super({
|
|
260
|
+
name: name11,
|
|
261
|
+
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.`
|
|
262
|
+
});
|
|
263
|
+
this[_a12] = true;
|
|
264
|
+
this.provider = options.provider;
|
|
265
|
+
this.modelId = options.modelId;
|
|
266
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
267
|
+
this.values = options.values;
|
|
268
|
+
}
|
|
269
|
+
static isInstance(error) {
|
|
270
|
+
return AISDKError.hasMarker(error, marker12);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
_a12 = symbol12;
|
|
274
|
+
var name12 = "AI_TypeValidationError";
|
|
275
|
+
var marker13 = `vercel.ai.error.${name12}`;
|
|
276
|
+
var symbol13 = Symbol.for(marker13);
|
|
277
|
+
var _a13;
|
|
278
|
+
var _TypeValidationError = class _TypeValidationError2 extends AISDKError {
|
|
279
|
+
constructor({ value, cause }) {
|
|
280
|
+
super({
|
|
281
|
+
name: name12,
|
|
282
|
+
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
283
|
+
Error message: ${getErrorMessage(cause)}`,
|
|
284
|
+
cause
|
|
285
|
+
});
|
|
286
|
+
this[_a13] = true;
|
|
287
|
+
this.value = value;
|
|
288
|
+
}
|
|
289
|
+
static isInstance(error) {
|
|
290
|
+
return AISDKError.hasMarker(error, marker13);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Wraps an error into a TypeValidationError.
|
|
294
|
+
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
295
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
296
|
+
*
|
|
297
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
298
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
299
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
300
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
301
|
+
*/
|
|
302
|
+
static wrap({
|
|
303
|
+
value,
|
|
304
|
+
cause
|
|
305
|
+
}) {
|
|
306
|
+
return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
_a13 = symbol13;
|
|
310
|
+
var TypeValidationError = _TypeValidationError;
|
|
311
|
+
var name13 = "AI_UnsupportedFunctionalityError";
|
|
312
|
+
var marker14 = `vercel.ai.error.${name13}`;
|
|
313
|
+
var symbol14 = Symbol.for(marker14);
|
|
314
|
+
var _a14;
|
|
315
|
+
var UnsupportedFunctionalityError = class extends AISDKError {
|
|
316
|
+
constructor({
|
|
317
|
+
functionality,
|
|
318
|
+
message = `'${functionality}' functionality not supported.`
|
|
319
|
+
}) {
|
|
320
|
+
super({ name: name13, message });
|
|
321
|
+
this[_a14] = true;
|
|
322
|
+
this.functionality = functionality;
|
|
323
|
+
}
|
|
324
|
+
static isInstance(error) {
|
|
325
|
+
return AISDKError.hasMarker(error, marker14);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
_a14 = symbol14;
|
|
329
|
+
|
|
330
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/index.js
|
|
331
|
+
var ParseError = class extends Error {
|
|
332
|
+
constructor(message, options) {
|
|
333
|
+
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
function noop(_arg) {
|
|
337
|
+
}
|
|
338
|
+
function createParser(callbacks) {
|
|
339
|
+
if (typeof callbacks == "function")
|
|
340
|
+
throw new TypeError(
|
|
341
|
+
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
342
|
+
);
|
|
343
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
344
|
+
let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
|
|
345
|
+
function feed(newChunk) {
|
|
346
|
+
const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
|
|
347
|
+
for (const line of complete)
|
|
348
|
+
parseLine(line);
|
|
349
|
+
incompleteLine = incomplete, isFirstChunk = false;
|
|
350
|
+
}
|
|
351
|
+
function parseLine(line) {
|
|
352
|
+
if (line === "") {
|
|
353
|
+
dispatchEvent();
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (line.startsWith(":")) {
|
|
357
|
+
onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const fieldSeparatorIndex = line.indexOf(":");
|
|
361
|
+
if (fieldSeparatorIndex !== -1) {
|
|
362
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
363
|
+
processField(field, value, line);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
processField(line, "", line);
|
|
367
|
+
}
|
|
368
|
+
function processField(field, value, line) {
|
|
369
|
+
switch (field) {
|
|
370
|
+
case "event":
|
|
371
|
+
eventType = value;
|
|
372
|
+
break;
|
|
373
|
+
case "data":
|
|
374
|
+
data = `${data}${value}
|
|
375
|
+
`;
|
|
376
|
+
break;
|
|
377
|
+
case "id":
|
|
378
|
+
id = value.includes("\0") ? void 0 : value;
|
|
379
|
+
break;
|
|
380
|
+
case "retry":
|
|
381
|
+
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
382
|
+
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
383
|
+
type: "invalid-retry",
|
|
384
|
+
value,
|
|
385
|
+
line
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
break;
|
|
389
|
+
default:
|
|
390
|
+
onError(
|
|
391
|
+
new ParseError(
|
|
392
|
+
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
393
|
+
{ type: "unknown-field", field, value, line }
|
|
394
|
+
)
|
|
395
|
+
);
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function dispatchEvent() {
|
|
400
|
+
data.length > 0 && onEvent({
|
|
401
|
+
id,
|
|
402
|
+
event: eventType || void 0,
|
|
403
|
+
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
|
|
404
|
+
// then remove the last character from the data buffer.
|
|
405
|
+
data: data.endsWith(`
|
|
406
|
+
`) ? data.slice(0, -1) : data
|
|
407
|
+
}), id = void 0, data = "", eventType = "";
|
|
408
|
+
}
|
|
409
|
+
function reset(options = {}) {
|
|
410
|
+
incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
|
|
411
|
+
}
|
|
412
|
+
return { feed, reset };
|
|
413
|
+
}
|
|
414
|
+
function splitLines(chunk) {
|
|
415
|
+
const lines = [];
|
|
416
|
+
let incompleteLine = "", searchIndex = 0;
|
|
417
|
+
for (; searchIndex < chunk.length; ) {
|
|
418
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
419
|
+
`, searchIndex);
|
|
420
|
+
let lineEnd = -1;
|
|
421
|
+
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) {
|
|
422
|
+
incompleteLine = chunk.slice(searchIndex);
|
|
423
|
+
break;
|
|
424
|
+
} else {
|
|
425
|
+
const line = chunk.slice(searchIndex, lineEnd);
|
|
426
|
+
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
427
|
+
` && searchIndex++;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return [lines, incompleteLine];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/stream.js
|
|
434
|
+
var EventSourceParserStream = class extends TransformStream {
|
|
435
|
+
constructor({ onError, onRetry, onComment } = {}) {
|
|
436
|
+
let parser;
|
|
437
|
+
super({
|
|
438
|
+
start(controller) {
|
|
439
|
+
parser = createParser({
|
|
440
|
+
onEvent: (event) => {
|
|
441
|
+
controller.enqueue(event);
|
|
442
|
+
},
|
|
443
|
+
onError(error) {
|
|
444
|
+
onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
|
|
445
|
+
},
|
|
446
|
+
onRetry,
|
|
447
|
+
onComment
|
|
448
|
+
});
|
|
449
|
+
},
|
|
450
|
+
transform(chunk) {
|
|
451
|
+
parser.feed(chunk);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
};
|
|
27
456
|
function combineHeaders(...headers) {
|
|
28
457
|
return headers.reduce(
|
|
29
458
|
(combinedHeaders, currentHeaders) => ({
|
|
@@ -54,7 +483,7 @@ var createIdGenerator = ({
|
|
|
54
483
|
return generator;
|
|
55
484
|
}
|
|
56
485
|
if (alphabet.includes(separator)) {
|
|
57
|
-
throw new
|
|
486
|
+
throw new InvalidArgumentError({
|
|
58
487
|
argument: "separator",
|
|
59
488
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
60
489
|
});
|
|
@@ -78,7 +507,7 @@ function handleFetchError({
|
|
|
78
507
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
79
508
|
const cause = error.cause;
|
|
80
509
|
if (cause != null) {
|
|
81
|
-
return new
|
|
510
|
+
return new APICallError({
|
|
82
511
|
message: `Cannot connect to API: ${cause.message}`,
|
|
83
512
|
cause,
|
|
84
513
|
url,
|
|
@@ -91,11 +520,11 @@ function handleFetchError({
|
|
|
91
520
|
return error;
|
|
92
521
|
}
|
|
93
522
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
94
|
-
var
|
|
523
|
+
var _a15, _b, _c;
|
|
95
524
|
if (globalThisAny.window) {
|
|
96
525
|
return `runtime/browser`;
|
|
97
526
|
}
|
|
98
|
-
if ((
|
|
527
|
+
if ((_a15 = globalThisAny.navigator) == null ? void 0 : _a15.userAgent) {
|
|
99
528
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
100
529
|
}
|
|
101
530
|
if ((_c = (_b = globalThisAny.process) == null ? void 0 : _b.versions) == null ? void 0 : _c.node) {
|
|
@@ -161,8 +590,8 @@ function injectJsonInstructionIntoMessages({
|
|
|
161
590
|
schemaPrefix,
|
|
162
591
|
schemaSuffix
|
|
163
592
|
}) {
|
|
164
|
-
var
|
|
165
|
-
const systemMessage = ((
|
|
593
|
+
var _a15, _b;
|
|
594
|
+
const systemMessage = ((_a15 = messages[0]) == null ? void 0 : _a15.role) === "system" ? { ...messages[0] } : { role: "system", content: "" };
|
|
166
595
|
systemMessage.content = injectJsonInstruction({
|
|
167
596
|
prompt: systemMessage.content,
|
|
168
597
|
schema,
|
|
@@ -184,23 +613,23 @@ function loadApiKey({
|
|
|
184
613
|
return apiKey;
|
|
185
614
|
}
|
|
186
615
|
if (apiKey != null) {
|
|
187
|
-
throw new
|
|
616
|
+
throw new LoadAPIKeyError({
|
|
188
617
|
message: `${description} API key must be a string.`
|
|
189
618
|
});
|
|
190
619
|
}
|
|
191
620
|
if (typeof process === "undefined") {
|
|
192
|
-
throw new
|
|
621
|
+
throw new LoadAPIKeyError({
|
|
193
622
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
194
623
|
});
|
|
195
624
|
}
|
|
196
625
|
apiKey = process.env[environmentVariableName];
|
|
197
626
|
if (apiKey == null) {
|
|
198
|
-
throw new
|
|
627
|
+
throw new LoadAPIKeyError({
|
|
199
628
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
200
629
|
});
|
|
201
630
|
}
|
|
202
631
|
if (typeof apiKey !== "string") {
|
|
203
|
-
throw new
|
|
632
|
+
throw new LoadAPIKeyError({
|
|
204
633
|
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
205
634
|
});
|
|
206
635
|
}
|
|
@@ -232,38 +661,38 @@ function loadSetting({
|
|
|
232
661
|
return settingValue;
|
|
233
662
|
}
|
|
234
663
|
if (settingValue != null) {
|
|
235
|
-
throw new
|
|
664
|
+
throw new LoadSettingError({
|
|
236
665
|
message: `${description} setting must be a string.`
|
|
237
666
|
});
|
|
238
667
|
}
|
|
239
668
|
if (typeof process === "undefined") {
|
|
240
|
-
throw new
|
|
669
|
+
throw new LoadSettingError({
|
|
241
670
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables is not supported in this environment.`
|
|
242
671
|
});
|
|
243
672
|
}
|
|
244
673
|
settingValue = process.env[environmentVariableName];
|
|
245
674
|
if (settingValue == null) {
|
|
246
|
-
throw new
|
|
675
|
+
throw new LoadSettingError({
|
|
247
676
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter or the ${environmentVariableName} environment variable.`
|
|
248
677
|
});
|
|
249
678
|
}
|
|
250
679
|
if (typeof settingValue !== "string") {
|
|
251
|
-
throw new
|
|
680
|
+
throw new LoadSettingError({
|
|
252
681
|
message: `${description} setting must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
253
682
|
});
|
|
254
683
|
}
|
|
255
684
|
return settingValue;
|
|
256
685
|
}
|
|
257
686
|
function mediaTypeToExtension(mediaType) {
|
|
258
|
-
var
|
|
687
|
+
var _a15;
|
|
259
688
|
const [_type, subtype = ""] = mediaType.toLowerCase().split("/");
|
|
260
|
-
return (
|
|
689
|
+
return (_a15 = {
|
|
261
690
|
mpeg: "mp3",
|
|
262
691
|
"x-wav": "wav",
|
|
263
692
|
opus: "ogg",
|
|
264
693
|
mp4: "m4a",
|
|
265
694
|
"x-m4a": "m4a"
|
|
266
|
-
}[subtype]) != null ?
|
|
695
|
+
}[subtype]) != null ? _a15 : subtype;
|
|
267
696
|
}
|
|
268
697
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
269
698
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
@@ -336,7 +765,7 @@ function standardSchemaValidator(standardSchema) {
|
|
|
336
765
|
const result = await standardSchema["~standard"].validate(value);
|
|
337
766
|
return result.issues == null ? { success: true, value: result.value } : {
|
|
338
767
|
success: false,
|
|
339
|
-
error: new
|
|
768
|
+
error: new TypeValidationError({
|
|
340
769
|
value,
|
|
341
770
|
cause: result.issues
|
|
342
771
|
})
|
|
@@ -349,7 +778,7 @@ async function validateTypes({
|
|
|
349
778
|
}) {
|
|
350
779
|
const result = await safeValidateTypes({ value, schema });
|
|
351
780
|
if (!result.success) {
|
|
352
|
-
throw
|
|
781
|
+
throw TypeValidationError.wrap({ value, cause: result.error });
|
|
353
782
|
}
|
|
354
783
|
return result.value;
|
|
355
784
|
}
|
|
@@ -368,13 +797,13 @@ async function safeValidateTypes({
|
|
|
368
797
|
}
|
|
369
798
|
return {
|
|
370
799
|
success: false,
|
|
371
|
-
error:
|
|
800
|
+
error: TypeValidationError.wrap({ value, cause: result.error }),
|
|
372
801
|
rawValue: value
|
|
373
802
|
};
|
|
374
803
|
} catch (error) {
|
|
375
804
|
return {
|
|
376
805
|
success: false,
|
|
377
|
-
error:
|
|
806
|
+
error: TypeValidationError.wrap({ value, cause: error }),
|
|
378
807
|
rawValue: value
|
|
379
808
|
};
|
|
380
809
|
}
|
|
@@ -390,10 +819,10 @@ async function parseJSON({
|
|
|
390
819
|
}
|
|
391
820
|
return validateTypes({ value, schema });
|
|
392
821
|
} catch (error) {
|
|
393
|
-
if (
|
|
822
|
+
if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
|
|
394
823
|
throw error;
|
|
395
824
|
}
|
|
396
|
-
throw new
|
|
825
|
+
throw new JSONParseError({ text, cause: error });
|
|
397
826
|
}
|
|
398
827
|
}
|
|
399
828
|
async function safeParseJSON({
|
|
@@ -409,7 +838,7 @@ async function safeParseJSON({
|
|
|
409
838
|
} catch (error) {
|
|
410
839
|
return {
|
|
411
840
|
success: false,
|
|
412
|
-
error:
|
|
841
|
+
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text, cause: error }),
|
|
413
842
|
rawValue: void 0
|
|
414
843
|
};
|
|
415
844
|
}
|
|
@@ -426,7 +855,7 @@ function parseJsonEventStream({
|
|
|
426
855
|
stream,
|
|
427
856
|
schema
|
|
428
857
|
}) {
|
|
429
|
-
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
858
|
+
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
|
|
430
859
|
new TransformStream({
|
|
431
860
|
async transform({ data }, controller) {
|
|
432
861
|
if (data === "[DONE]") {
|
|
@@ -450,7 +879,7 @@ async function parseProviderOptions({
|
|
|
450
879
|
schema
|
|
451
880
|
});
|
|
452
881
|
if (!parsedProviderOptions.success) {
|
|
453
|
-
throw new
|
|
882
|
+
throw new InvalidArgumentError({
|
|
454
883
|
argument: "providerOptions",
|
|
455
884
|
message: `invalid ${provider} provider options`,
|
|
456
885
|
cause: parsedProviderOptions.error
|
|
@@ -532,10 +961,10 @@ var postToApi = async ({
|
|
|
532
961
|
requestBodyValues: body.values
|
|
533
962
|
});
|
|
534
963
|
} catch (error) {
|
|
535
|
-
if (isAbortError(error) ||
|
|
964
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
536
965
|
throw error;
|
|
537
966
|
}
|
|
538
|
-
throw new
|
|
967
|
+
throw new APICallError({
|
|
539
968
|
message: "Failed to process error response",
|
|
540
969
|
cause: error,
|
|
541
970
|
statusCode: response.status,
|
|
@@ -554,11 +983,11 @@ var postToApi = async ({
|
|
|
554
983
|
});
|
|
555
984
|
} catch (error) {
|
|
556
985
|
if (error instanceof Error) {
|
|
557
|
-
if (isAbortError(error) ||
|
|
986
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
558
987
|
throw error;
|
|
559
988
|
}
|
|
560
989
|
}
|
|
561
|
-
throw new
|
|
990
|
+
throw new APICallError({
|
|
562
991
|
message: "Failed to process successful response",
|
|
563
992
|
cause: error,
|
|
564
993
|
statusCode: response.status,
|
|
@@ -576,7 +1005,7 @@ function tool(tool2) {
|
|
|
576
1005
|
}
|
|
577
1006
|
function createProviderDefinedToolFactory({
|
|
578
1007
|
id,
|
|
579
|
-
name,
|
|
1008
|
+
name: name14,
|
|
580
1009
|
inputSchema
|
|
581
1010
|
}) {
|
|
582
1011
|
return ({
|
|
@@ -590,7 +1019,7 @@ function createProviderDefinedToolFactory({
|
|
|
590
1019
|
}) => tool({
|
|
591
1020
|
type: "provider-defined",
|
|
592
1021
|
id,
|
|
593
|
-
name,
|
|
1022
|
+
name: name14,
|
|
594
1023
|
args,
|
|
595
1024
|
inputSchema,
|
|
596
1025
|
outputSchema,
|
|
@@ -603,7 +1032,7 @@ function createProviderDefinedToolFactory({
|
|
|
603
1032
|
}
|
|
604
1033
|
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
605
1034
|
id,
|
|
606
|
-
name,
|
|
1035
|
+
name: name14,
|
|
607
1036
|
inputSchema,
|
|
608
1037
|
outputSchema
|
|
609
1038
|
}) {
|
|
@@ -617,7 +1046,7 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
617
1046
|
}) => tool({
|
|
618
1047
|
type: "provider-defined",
|
|
619
1048
|
id,
|
|
620
|
-
name,
|
|
1049
|
+
name: name14,
|
|
621
1050
|
args,
|
|
622
1051
|
inputSchema,
|
|
623
1052
|
outputSchema,
|
|
@@ -644,7 +1073,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
644
1073
|
if (responseBody.trim() === "") {
|
|
645
1074
|
return {
|
|
646
1075
|
responseHeaders,
|
|
647
|
-
value: new
|
|
1076
|
+
value: new APICallError({
|
|
648
1077
|
message: response.statusText,
|
|
649
1078
|
url,
|
|
650
1079
|
requestBodyValues,
|
|
@@ -662,7 +1091,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
662
1091
|
});
|
|
663
1092
|
return {
|
|
664
1093
|
responseHeaders,
|
|
665
|
-
value: new
|
|
1094
|
+
value: new APICallError({
|
|
666
1095
|
message: errorToMessage(parsedError),
|
|
667
1096
|
url,
|
|
668
1097
|
requestBodyValues,
|
|
@@ -676,7 +1105,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
676
1105
|
} catch (parseError) {
|
|
677
1106
|
return {
|
|
678
1107
|
responseHeaders,
|
|
679
|
-
value: new
|
|
1108
|
+
value: new APICallError({
|
|
680
1109
|
message: response.statusText,
|
|
681
1110
|
url,
|
|
682
1111
|
requestBodyValues,
|
|
@@ -691,7 +1120,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
691
1120
|
var createEventSourceResponseHandler = (chunkSchema2) => async ({ response }) => {
|
|
692
1121
|
const responseHeaders = extractResponseHeaders(response);
|
|
693
1122
|
if (response.body == null) {
|
|
694
|
-
throw new
|
|
1123
|
+
throw new EmptyResponseBodyError({});
|
|
695
1124
|
}
|
|
696
1125
|
return {
|
|
697
1126
|
responseHeaders,
|
|
@@ -709,7 +1138,7 @@ var createJsonResponseHandler = (responseSchema2) => async ({ response, url, req
|
|
|
709
1138
|
});
|
|
710
1139
|
const responseHeaders = extractResponseHeaders(response);
|
|
711
1140
|
if (!parsedResult.success) {
|
|
712
|
-
throw new
|
|
1141
|
+
throw new APICallError({
|
|
713
1142
|
message: "Invalid JSON response",
|
|
714
1143
|
cause: parsedResult.error,
|
|
715
1144
|
statusCode: response.status,
|
|
@@ -728,7 +1157,7 @@ var createJsonResponseHandler = (responseSchema2) => async ({ response, url, req
|
|
|
728
1157
|
var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
|
|
729
1158
|
const responseHeaders = extractResponseHeaders(response);
|
|
730
1159
|
if (!response.body) {
|
|
731
|
-
throw new
|
|
1160
|
+
throw new APICallError({
|
|
732
1161
|
message: "Response body is empty",
|
|
733
1162
|
url,
|
|
734
1163
|
requestBodyValues,
|
|
@@ -744,7 +1173,7 @@ var createBinaryResponseHandler = () => async ({ response, url, requestBodyValue
|
|
|
744
1173
|
value: new Uint8Array(buffer)
|
|
745
1174
|
};
|
|
746
1175
|
} catch (error) {
|
|
747
|
-
throw new
|
|
1176
|
+
throw new APICallError({
|
|
748
1177
|
message: "Failed to read response as array buffer",
|
|
749
1178
|
url,
|
|
750
1179
|
requestBodyValues,
|
|
@@ -797,11 +1226,11 @@ function parseAnyDef() {
|
|
|
797
1226
|
return {};
|
|
798
1227
|
}
|
|
799
1228
|
function parseArrayDef(def, refs) {
|
|
800
|
-
var
|
|
1229
|
+
var _a15, _b, _c;
|
|
801
1230
|
const res = {
|
|
802
1231
|
type: "array"
|
|
803
1232
|
};
|
|
804
|
-
if (((
|
|
1233
|
+
if (((_a15 = def.type) == null ? void 0 : _a15._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
805
1234
|
res.items = parseDef(def.type._def, {
|
|
806
1235
|
...refs,
|
|
807
1236
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -1160,8 +1589,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
1160
1589
|
return result;
|
|
1161
1590
|
}
|
|
1162
1591
|
function addFormat(schema, value, message, refs) {
|
|
1163
|
-
var
|
|
1164
|
-
if (schema.format || ((
|
|
1592
|
+
var _a15;
|
|
1593
|
+
if (schema.format || ((_a15 = schema.anyOf) == null ? void 0 : _a15.some((x) => x.format))) {
|
|
1165
1594
|
if (!schema.anyOf) {
|
|
1166
1595
|
schema.anyOf = [];
|
|
1167
1596
|
}
|
|
@@ -1180,8 +1609,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
1180
1609
|
}
|
|
1181
1610
|
}
|
|
1182
1611
|
function addPattern(schema, regex, message, refs) {
|
|
1183
|
-
var
|
|
1184
|
-
if (schema.pattern || ((
|
|
1612
|
+
var _a15;
|
|
1613
|
+
if (schema.pattern || ((_a15 = schema.allOf) == null ? void 0 : _a15.some((x) => x.pattern))) {
|
|
1185
1614
|
if (!schema.allOf) {
|
|
1186
1615
|
schema.allOf = [];
|
|
1187
1616
|
}
|
|
@@ -1200,7 +1629,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
1200
1629
|
}
|
|
1201
1630
|
}
|
|
1202
1631
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
1203
|
-
var
|
|
1632
|
+
var _a15;
|
|
1204
1633
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
1205
1634
|
return regex.source;
|
|
1206
1635
|
}
|
|
@@ -1230,7 +1659,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1230
1659
|
pattern += source[i];
|
|
1231
1660
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
1232
1661
|
inCharRange = false;
|
|
1233
|
-
} else if (source[i + 1] === "-" && ((
|
|
1662
|
+
} else if (source[i + 1] === "-" && ((_a15 = source[i + 2]) == null ? void 0 : _a15.match(/[a-z]/))) {
|
|
1234
1663
|
pattern += source[i];
|
|
1235
1664
|
inCharRange = true;
|
|
1236
1665
|
} else {
|
|
@@ -1272,13 +1701,13 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1272
1701
|
return pattern;
|
|
1273
1702
|
}
|
|
1274
1703
|
function parseRecordDef(def, refs) {
|
|
1275
|
-
var
|
|
1704
|
+
var _a15, _b, _c, _d, _e, _f;
|
|
1276
1705
|
const schema = {
|
|
1277
1706
|
type: "object",
|
|
1278
|
-
additionalProperties: (
|
|
1707
|
+
additionalProperties: (_a15 = parseDef(def.valueType._def, {
|
|
1279
1708
|
...refs,
|
|
1280
1709
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1281
|
-
})) != null ?
|
|
1710
|
+
})) != null ? _a15 : refs.allowedAdditionalProperties
|
|
1282
1711
|
};
|
|
1283
1712
|
if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
1284
1713
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
@@ -1535,8 +1964,8 @@ function safeIsOptional(schema) {
|
|
|
1535
1964
|
}
|
|
1536
1965
|
}
|
|
1537
1966
|
var parseOptionalDef = (def, refs) => {
|
|
1538
|
-
var
|
|
1539
|
-
if (refs.currentPath.toString() === ((
|
|
1967
|
+
var _a15;
|
|
1968
|
+
if (refs.currentPath.toString() === ((_a15 = refs.propertyPath) == null ? void 0 : _a15.toString())) {
|
|
1540
1969
|
return parseDef(def.innerType._def, refs);
|
|
1541
1970
|
}
|
|
1542
1971
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -1706,10 +2135,10 @@ var selectParser = (def, typeName, refs) => {
|
|
|
1706
2135
|
}
|
|
1707
2136
|
};
|
|
1708
2137
|
function parseDef(def, refs, forceResolution = false) {
|
|
1709
|
-
var
|
|
2138
|
+
var _a15;
|
|
1710
2139
|
const seenItem = refs.seen.get(def);
|
|
1711
2140
|
if (refs.override) {
|
|
1712
|
-
const overrideResult = (
|
|
2141
|
+
const overrideResult = (_a15 = refs.override) == null ? void 0 : _a15.call(
|
|
1713
2142
|
refs,
|
|
1714
2143
|
def,
|
|
1715
2144
|
refs,
|
|
@@ -1775,11 +2204,11 @@ var getRefs = (options) => {
|
|
|
1775
2204
|
currentPath,
|
|
1776
2205
|
propertyPath: void 0,
|
|
1777
2206
|
seen: new Map(
|
|
1778
|
-
Object.entries(_options.definitions).map(([
|
|
2207
|
+
Object.entries(_options.definitions).map(([name14, def]) => [
|
|
1779
2208
|
def._def,
|
|
1780
2209
|
{
|
|
1781
2210
|
def: def._def,
|
|
1782
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
2211
|
+
path: [..._options.basePath, _options.definitionPath, name14],
|
|
1783
2212
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
1784
2213
|
jsonSchema: void 0
|
|
1785
2214
|
}
|
|
@@ -1788,50 +2217,50 @@ var getRefs = (options) => {
|
|
|
1788
2217
|
};
|
|
1789
2218
|
};
|
|
1790
2219
|
var zodToJsonSchema = (schema, options) => {
|
|
1791
|
-
var
|
|
2220
|
+
var _a15;
|
|
1792
2221
|
const refs = getRefs(options);
|
|
1793
2222
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
1794
|
-
(acc, [
|
|
1795
|
-
var
|
|
2223
|
+
(acc, [name22, schema2]) => {
|
|
2224
|
+
var _a22;
|
|
1796
2225
|
return {
|
|
1797
2226
|
...acc,
|
|
1798
|
-
[
|
|
2227
|
+
[name22]: (_a22 = parseDef(
|
|
1799
2228
|
schema2._def,
|
|
1800
2229
|
{
|
|
1801
2230
|
...refs,
|
|
1802
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
2231
|
+
currentPath: [...refs.basePath, refs.definitionPath, name22]
|
|
1803
2232
|
},
|
|
1804
2233
|
true
|
|
1805
|
-
)) != null ?
|
|
2234
|
+
)) != null ? _a22 : parseAnyDef()
|
|
1806
2235
|
};
|
|
1807
2236
|
},
|
|
1808
2237
|
{}
|
|
1809
2238
|
) : void 0;
|
|
1810
|
-
const
|
|
1811
|
-
const main = (
|
|
2239
|
+
const name14 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
2240
|
+
const main = (_a15 = parseDef(
|
|
1812
2241
|
schema._def,
|
|
1813
|
-
|
|
2242
|
+
name14 === void 0 ? refs : {
|
|
1814
2243
|
...refs,
|
|
1815
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
2244
|
+
currentPath: [...refs.basePath, refs.definitionPath, name14]
|
|
1816
2245
|
},
|
|
1817
2246
|
false
|
|
1818
|
-
)) != null ?
|
|
2247
|
+
)) != null ? _a15 : parseAnyDef();
|
|
1819
2248
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
1820
2249
|
if (title !== void 0) {
|
|
1821
2250
|
main.title = title;
|
|
1822
2251
|
}
|
|
1823
|
-
const combined =
|
|
2252
|
+
const combined = name14 === void 0 ? definitions ? {
|
|
1824
2253
|
...main,
|
|
1825
2254
|
[refs.definitionPath]: definitions
|
|
1826
2255
|
} : main : {
|
|
1827
2256
|
$ref: [
|
|
1828
2257
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1829
2258
|
refs.definitionPath,
|
|
1830
|
-
|
|
2259
|
+
name14
|
|
1831
2260
|
].join("/"),
|
|
1832
2261
|
[refs.definitionPath]: {
|
|
1833
2262
|
...definitions,
|
|
1834
|
-
[
|
|
2263
|
+
[name14]: main
|
|
1835
2264
|
}
|
|
1836
2265
|
};
|
|
1837
2266
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -1839,8 +2268,8 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
1839
2268
|
};
|
|
1840
2269
|
var zod_to_json_schema_default = zodToJsonSchema;
|
|
1841
2270
|
function zod3Schema(zodSchema2, options) {
|
|
1842
|
-
var
|
|
1843
|
-
const useReferences = (
|
|
2271
|
+
var _a15;
|
|
2272
|
+
const useReferences = (_a15 = options == null ? void 0 : options.useReferences) != null ? _a15 : false;
|
|
1844
2273
|
return jsonSchema(
|
|
1845
2274
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1846
2275
|
() => zod_to_json_schema_default(zodSchema2, {
|
|
@@ -1855,8 +2284,8 @@ function zod3Schema(zodSchema2, options) {
|
|
|
1855
2284
|
);
|
|
1856
2285
|
}
|
|
1857
2286
|
function zod4Schema(zodSchema2, options) {
|
|
1858
|
-
var
|
|
1859
|
-
const useReferences = (
|
|
2287
|
+
var _a15;
|
|
2288
|
+
const useReferences = (_a15 = options == null ? void 0 : options.useReferences) != null ? _a15 : false;
|
|
1860
2289
|
return jsonSchema(
|
|
1861
2290
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1862
2291
|
() => z4__namespace.toJSONSchema(zodSchema2, {
|
|
@@ -1929,8 +2358,8 @@ function withoutTrailingSlash(url) {
|
|
|
1929
2358
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
1930
2359
|
}
|
|
1931
2360
|
function getOpenAIMetadata(message) {
|
|
1932
|
-
var
|
|
1933
|
-
return (_b = (
|
|
2361
|
+
var _a15, _b;
|
|
2362
|
+
return (_b = (_a15 = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a15.openaiCompatible) != null ? _b : {};
|
|
1934
2363
|
}
|
|
1935
2364
|
function convertToOpenAICompatibleChatMessages(prompt) {
|
|
1936
2365
|
const messages = [];
|
|
@@ -1969,7 +2398,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
1969
2398
|
...partMetadata
|
|
1970
2399
|
};
|
|
1971
2400
|
} else {
|
|
1972
|
-
throw new
|
|
2401
|
+
throw new UnsupportedFunctionalityError({
|
|
1973
2402
|
functionality: `file part media type ${part.mediaType}`
|
|
1974
2403
|
});
|
|
1975
2404
|
}
|
|
@@ -2145,7 +2574,7 @@ function prepareTools({
|
|
|
2145
2574
|
};
|
|
2146
2575
|
default: {
|
|
2147
2576
|
const _exhaustiveCheck = type;
|
|
2148
|
-
throw new
|
|
2577
|
+
throw new UnsupportedFunctionalityError({
|
|
2149
2578
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
2150
2579
|
});
|
|
2151
2580
|
}
|
|
@@ -2155,10 +2584,10 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2155
2584
|
// type inferred via constructor
|
|
2156
2585
|
constructor(modelId, config) {
|
|
2157
2586
|
this.specificationVersion = "v2";
|
|
2158
|
-
var
|
|
2587
|
+
var _a15, _b;
|
|
2159
2588
|
this.modelId = modelId;
|
|
2160
2589
|
this.config = config;
|
|
2161
|
-
const errorStructure = (
|
|
2590
|
+
const errorStructure = (_a15 = config.errorStructure) != null ? _a15 : defaultOpenAICompatibleErrorStructure;
|
|
2162
2591
|
this.chunkSchema = createOpenAICompatibleChatChunkSchema(
|
|
2163
2592
|
errorStructure.errorSchema
|
|
2164
2593
|
);
|
|
@@ -2172,8 +2601,8 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2172
2601
|
return this.config.provider.split(".")[0].trim();
|
|
2173
2602
|
}
|
|
2174
2603
|
get supportedUrls() {
|
|
2175
|
-
var
|
|
2176
|
-
return (_c = (_b = (
|
|
2604
|
+
var _a15, _b, _c;
|
|
2605
|
+
return (_c = (_b = (_a15 = this.config).supportedUrls) == null ? void 0 : _b.call(_a15)) != null ? _c : {};
|
|
2177
2606
|
}
|
|
2178
2607
|
async getArgs({
|
|
2179
2608
|
prompt,
|
|
@@ -2190,14 +2619,14 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2190
2619
|
toolChoice,
|
|
2191
2620
|
tools
|
|
2192
2621
|
}) {
|
|
2193
|
-
var
|
|
2622
|
+
var _a15, _b, _c, _d;
|
|
2194
2623
|
const warnings = [];
|
|
2195
2624
|
const compatibleOptions = Object.assign(
|
|
2196
|
-
(
|
|
2625
|
+
(_a15 = await parseProviderOptions({
|
|
2197
2626
|
provider: "openai-compatible",
|
|
2198
2627
|
providerOptions,
|
|
2199
2628
|
schema: openaiCompatibleProviderOptions
|
|
2200
|
-
})) != null ?
|
|
2629
|
+
})) != null ? _a15 : {},
|
|
2201
2630
|
(_b = await parseProviderOptions({
|
|
2202
2631
|
provider: this.providerOptionsName,
|
|
2203
2632
|
providerOptions,
|
|
@@ -2263,7 +2692,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2263
2692
|
};
|
|
2264
2693
|
}
|
|
2265
2694
|
async doGenerate(options) {
|
|
2266
|
-
var
|
|
2695
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2267
2696
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
2268
2697
|
const body = JSON.stringify(args);
|
|
2269
2698
|
const {
|
|
@@ -2290,7 +2719,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2290
2719
|
if (text != null && text.length > 0) {
|
|
2291
2720
|
content.push({ type: "text", text });
|
|
2292
2721
|
}
|
|
2293
|
-
const reasoning = (
|
|
2722
|
+
const reasoning = (_a15 = choice.message.reasoning_content) != null ? _a15 : choice.message.reasoning;
|
|
2294
2723
|
if (reasoning != null && reasoning.length > 0) {
|
|
2295
2724
|
content.push({
|
|
2296
2725
|
type: "reasoning",
|
|
@@ -2341,7 +2770,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2341
2770
|
};
|
|
2342
2771
|
}
|
|
2343
2772
|
async doStream(options) {
|
|
2344
|
-
var
|
|
2773
|
+
var _a15;
|
|
2345
2774
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
2346
2775
|
const body = {
|
|
2347
2776
|
...args,
|
|
@@ -2349,7 +2778,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2349
2778
|
// only include stream_options when in strict compatibility mode:
|
|
2350
2779
|
stream_options: this.config.includeUsage ? { include_usage: true } : void 0
|
|
2351
2780
|
};
|
|
2352
|
-
const metadataExtractor = (
|
|
2781
|
+
const metadataExtractor = (_a15 = this.config.metadataExtractor) == null ? void 0 : _a15.createStreamExtractor();
|
|
2353
2782
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
2354
2783
|
url: this.config.url({
|
|
2355
2784
|
path: "/chat/completions",
|
|
@@ -2391,7 +2820,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2391
2820
|
},
|
|
2392
2821
|
// TODO we lost type safety on Chunk, most likely due to the error schema. MUST FIX
|
|
2393
2822
|
transform(chunk, controller) {
|
|
2394
|
-
var
|
|
2823
|
+
var _a22, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2395
2824
|
if (options.includeRawChunks) {
|
|
2396
2825
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2397
2826
|
}
|
|
@@ -2448,7 +2877,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2448
2877
|
return;
|
|
2449
2878
|
}
|
|
2450
2879
|
const delta = choice.delta;
|
|
2451
|
-
const reasoningContent = (
|
|
2880
|
+
const reasoningContent = (_a22 = delta.reasoning_content) != null ? _a22 : delta.reasoning;
|
|
2452
2881
|
if (reasoningContent) {
|
|
2453
2882
|
if (!isActiveReasoning) {
|
|
2454
2883
|
controller.enqueue({
|
|
@@ -2479,13 +2908,13 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2479
2908
|
const index = toolCallDelta.index;
|
|
2480
2909
|
if (toolCalls[index] == null) {
|
|
2481
2910
|
if (toolCallDelta.id == null) {
|
|
2482
|
-
throw new
|
|
2911
|
+
throw new InvalidResponseDataError({
|
|
2483
2912
|
data: toolCallDelta,
|
|
2484
2913
|
message: `Expected 'id' to be a string.`
|
|
2485
2914
|
});
|
|
2486
2915
|
}
|
|
2487
2916
|
if (((_b = toolCallDelta.function) == null ? void 0 : _b.name) == null) {
|
|
2488
|
-
throw new
|
|
2917
|
+
throw new InvalidResponseDataError({
|
|
2489
2918
|
data: toolCallDelta,
|
|
2490
2919
|
message: `Expected 'function.name' to be a string.`
|
|
2491
2920
|
});
|
|
@@ -2558,7 +2987,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2558
2987
|
}
|
|
2559
2988
|
},
|
|
2560
2989
|
flush(controller) {
|
|
2561
|
-
var
|
|
2990
|
+
var _a22, _b, _c, _d, _e, _f;
|
|
2562
2991
|
if (isActiveReasoning) {
|
|
2563
2992
|
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
2564
2993
|
}
|
|
@@ -2574,7 +3003,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
2574
3003
|
});
|
|
2575
3004
|
controller.enqueue({
|
|
2576
3005
|
type: "tool-call",
|
|
2577
|
-
toolCallId: (
|
|
3006
|
+
toolCallId: (_a22 = toolCall.id) != null ? _a22 : generateId(),
|
|
2578
3007
|
toolName: toolCall.function.name,
|
|
2579
3008
|
input: toolCall.function.arguments
|
|
2580
3009
|
});
|
|
@@ -2695,7 +3124,7 @@ function convertToOpenAICompatibleCompletionPrompt({
|
|
|
2695
3124
|
for (const { role, content } of prompt) {
|
|
2696
3125
|
switch (role) {
|
|
2697
3126
|
case "system": {
|
|
2698
|
-
throw new
|
|
3127
|
+
throw new InvalidPromptError({
|
|
2699
3128
|
message: "Unexpected system message in prompt: ${content}",
|
|
2700
3129
|
prompt
|
|
2701
3130
|
});
|
|
@@ -2721,7 +3150,7 @@ ${userMessage}
|
|
|
2721
3150
|
return part.text;
|
|
2722
3151
|
}
|
|
2723
3152
|
case "tool-call": {
|
|
2724
|
-
throw new
|
|
3153
|
+
throw new UnsupportedFunctionalityError({
|
|
2725
3154
|
functionality: "tool-call messages"
|
|
2726
3155
|
});
|
|
2727
3156
|
}
|
|
@@ -2734,7 +3163,7 @@ ${assistantMessage}
|
|
|
2734
3163
|
break;
|
|
2735
3164
|
}
|
|
2736
3165
|
case "tool": {
|
|
2737
|
-
throw new
|
|
3166
|
+
throw new UnsupportedFunctionalityError({
|
|
2738
3167
|
functionality: "tool messages"
|
|
2739
3168
|
});
|
|
2740
3169
|
}
|
|
@@ -2804,10 +3233,10 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
2804
3233
|
// type inferred via constructor
|
|
2805
3234
|
constructor(modelId, config) {
|
|
2806
3235
|
this.specificationVersion = "v2";
|
|
2807
|
-
var
|
|
3236
|
+
var _a15;
|
|
2808
3237
|
this.modelId = modelId;
|
|
2809
3238
|
this.config = config;
|
|
2810
|
-
const errorStructure = (
|
|
3239
|
+
const errorStructure = (_a15 = config.errorStructure) != null ? _a15 : defaultOpenAICompatibleErrorStructure;
|
|
2811
3240
|
this.chunkSchema = createOpenAICompatibleCompletionChunkSchema(
|
|
2812
3241
|
errorStructure.errorSchema
|
|
2813
3242
|
);
|
|
@@ -2820,8 +3249,8 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
2820
3249
|
return this.config.provider.split(".")[0].trim();
|
|
2821
3250
|
}
|
|
2822
3251
|
get supportedUrls() {
|
|
2823
|
-
var
|
|
2824
|
-
return (_c = (_b = (
|
|
3252
|
+
var _a15, _b, _c;
|
|
3253
|
+
return (_c = (_b = (_a15 = this.config).supportedUrls) == null ? void 0 : _b.call(_a15)) != null ? _c : {};
|
|
2825
3254
|
}
|
|
2826
3255
|
async getArgs({
|
|
2827
3256
|
prompt,
|
|
@@ -2838,13 +3267,13 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
2838
3267
|
tools,
|
|
2839
3268
|
toolChoice
|
|
2840
3269
|
}) {
|
|
2841
|
-
var
|
|
3270
|
+
var _a15;
|
|
2842
3271
|
const warnings = [];
|
|
2843
|
-
const completionOptions = (
|
|
3272
|
+
const completionOptions = (_a15 = await parseProviderOptions({
|
|
2844
3273
|
provider: this.providerOptionsName,
|
|
2845
3274
|
providerOptions,
|
|
2846
3275
|
schema: openaiCompatibleCompletionProviderOptions
|
|
2847
|
-
})) != null ?
|
|
3276
|
+
})) != null ? _a15 : {};
|
|
2848
3277
|
if (topK != null) {
|
|
2849
3278
|
warnings.push({ type: "unsupported-setting", setting: "topK" });
|
|
2850
3279
|
}
|
|
@@ -2889,7 +3318,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
2889
3318
|
};
|
|
2890
3319
|
}
|
|
2891
3320
|
async doGenerate(options) {
|
|
2892
|
-
var
|
|
3321
|
+
var _a15, _b, _c, _d, _e, _f;
|
|
2893
3322
|
const { args, warnings } = await this.getArgs(options);
|
|
2894
3323
|
const {
|
|
2895
3324
|
responseHeaders,
|
|
@@ -2917,7 +3346,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
2917
3346
|
return {
|
|
2918
3347
|
content,
|
|
2919
3348
|
usage: {
|
|
2920
|
-
inputTokens: (_b = (
|
|
3349
|
+
inputTokens: (_b = (_a15 = response.usage) == null ? void 0 : _a15.prompt_tokens) != null ? _b : void 0,
|
|
2921
3350
|
outputTokens: (_d = (_c = response.usage) == null ? void 0 : _c.completion_tokens) != null ? _d : void 0,
|
|
2922
3351
|
totalTokens: (_f = (_e = response.usage) == null ? void 0 : _e.total_tokens) != null ? _f : void 0
|
|
2923
3352
|
},
|
|
@@ -2967,7 +3396,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
2967
3396
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2968
3397
|
},
|
|
2969
3398
|
transform(chunk, controller) {
|
|
2970
|
-
var
|
|
3399
|
+
var _a15, _b, _c;
|
|
2971
3400
|
if (options.includeRawChunks) {
|
|
2972
3401
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2973
3402
|
}
|
|
@@ -2994,7 +3423,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
|
|
|
2994
3423
|
});
|
|
2995
3424
|
}
|
|
2996
3425
|
if (value.usage != null) {
|
|
2997
|
-
usage.inputTokens = (
|
|
3426
|
+
usage.inputTokens = (_a15 = value.usage.prompt_tokens) != null ? _a15 : void 0;
|
|
2998
3427
|
usage.outputTokens = (_b = value.usage.completion_tokens) != null ? _b : void 0;
|
|
2999
3428
|
usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : void 0;
|
|
3000
3429
|
}
|
|
@@ -3084,12 +3513,12 @@ var OpenAICompatibleEmbeddingModel = class {
|
|
|
3084
3513
|
return this.config.provider;
|
|
3085
3514
|
}
|
|
3086
3515
|
get maxEmbeddingsPerCall() {
|
|
3087
|
-
var
|
|
3088
|
-
return (
|
|
3516
|
+
var _a15;
|
|
3517
|
+
return (_a15 = this.config.maxEmbeddingsPerCall) != null ? _a15 : 2048;
|
|
3089
3518
|
}
|
|
3090
3519
|
get supportsParallelCalls() {
|
|
3091
|
-
var
|
|
3092
|
-
return (
|
|
3520
|
+
var _a15;
|
|
3521
|
+
return (_a15 = this.config.supportsParallelCalls) != null ? _a15 : true;
|
|
3093
3522
|
}
|
|
3094
3523
|
get providerOptionsName() {
|
|
3095
3524
|
return this.config.provider.split(".")[0].trim();
|
|
@@ -3100,13 +3529,13 @@ var OpenAICompatibleEmbeddingModel = class {
|
|
|
3100
3529
|
abortSignal,
|
|
3101
3530
|
providerOptions
|
|
3102
3531
|
}) {
|
|
3103
|
-
var
|
|
3532
|
+
var _a15, _b, _c;
|
|
3104
3533
|
const compatibleOptions = Object.assign(
|
|
3105
|
-
(
|
|
3534
|
+
(_a15 = await parseProviderOptions({
|
|
3106
3535
|
provider: "openai-compatible",
|
|
3107
3536
|
providerOptions,
|
|
3108
3537
|
schema: openaiCompatibleEmbeddingProviderOptions
|
|
3109
|
-
})) != null ?
|
|
3538
|
+
})) != null ? _a15 : {},
|
|
3110
3539
|
(_b = await parseProviderOptions({
|
|
3111
3540
|
provider: this.providerOptionsName,
|
|
3112
3541
|
providerOptions,
|
|
@@ -3114,7 +3543,7 @@ var OpenAICompatibleEmbeddingModel = class {
|
|
|
3114
3543
|
})) != null ? _b : {}
|
|
3115
3544
|
);
|
|
3116
3545
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
3117
|
-
throw new
|
|
3546
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
3118
3547
|
provider: this.provider,
|
|
3119
3548
|
modelId: this.modelId,
|
|
3120
3549
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -3180,7 +3609,7 @@ var OpenAICompatibleImageModel = class {
|
|
|
3180
3609
|
headers,
|
|
3181
3610
|
abortSignal
|
|
3182
3611
|
}) {
|
|
3183
|
-
var
|
|
3612
|
+
var _a15, _b, _c, _d, _e;
|
|
3184
3613
|
const warnings = [];
|
|
3185
3614
|
if (aspectRatio != null) {
|
|
3186
3615
|
warnings.push({
|
|
@@ -3192,7 +3621,7 @@ var OpenAICompatibleImageModel = class {
|
|
|
3192
3621
|
if (seed != null) {
|
|
3193
3622
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
3194
3623
|
}
|
|
3195
|
-
const currentDate = (_c = (_b = (
|
|
3624
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3196
3625
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
3197
3626
|
url: this.config.url({
|
|
3198
3627
|
path: "/images/generations",
|
|
@@ -3824,9 +4253,9 @@ var anthropicProviderOptions = z4.z.object({
|
|
|
3824
4253
|
});
|
|
3825
4254
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
3826
4255
|
function getCacheControl(providerMetadata) {
|
|
3827
|
-
var
|
|
4256
|
+
var _a15;
|
|
3828
4257
|
const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
3829
|
-
const cacheControlValue = (
|
|
4258
|
+
const cacheControlValue = (_a15 = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a15 : anthropic2 == null ? void 0 : anthropic2.cache_control;
|
|
3830
4259
|
return cacheControlValue;
|
|
3831
4260
|
}
|
|
3832
4261
|
var CacheControlValidator = class {
|
|
@@ -4218,7 +4647,7 @@ async function prepareTools2({
|
|
|
4218
4647
|
};
|
|
4219
4648
|
default: {
|
|
4220
4649
|
const _exhaustiveCheck = type;
|
|
4221
|
-
throw new
|
|
4650
|
+
throw new UnsupportedFunctionalityError({
|
|
4222
4651
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
4223
4652
|
});
|
|
4224
4653
|
}
|
|
@@ -4343,11 +4772,11 @@ function convertToString(data) {
|
|
|
4343
4772
|
return new TextDecoder().decode(data);
|
|
4344
4773
|
}
|
|
4345
4774
|
if (data instanceof URL) {
|
|
4346
|
-
throw new
|
|
4775
|
+
throw new UnsupportedFunctionalityError({
|
|
4347
4776
|
functionality: "URL-based text documents are not supported for citations"
|
|
4348
4777
|
});
|
|
4349
4778
|
}
|
|
4350
|
-
throw new
|
|
4779
|
+
throw new UnsupportedFunctionalityError({
|
|
4351
4780
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
4352
4781
|
});
|
|
4353
4782
|
}
|
|
@@ -4357,20 +4786,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4357
4786
|
warnings,
|
|
4358
4787
|
cacheControlValidator
|
|
4359
4788
|
}) {
|
|
4360
|
-
var
|
|
4789
|
+
var _a15, _b, _c, _d, _e;
|
|
4361
4790
|
const betas = /* @__PURE__ */ new Set();
|
|
4362
4791
|
const blocks = groupIntoBlocks(prompt);
|
|
4363
4792
|
const validator2 = cacheControlValidator || new CacheControlValidator();
|
|
4364
4793
|
let system = void 0;
|
|
4365
4794
|
const messages = [];
|
|
4366
4795
|
async function shouldEnableCitations(providerMetadata) {
|
|
4367
|
-
var
|
|
4796
|
+
var _a22, _b2;
|
|
4368
4797
|
const anthropicOptions = await parseProviderOptions({
|
|
4369
4798
|
provider: "anthropic",
|
|
4370
4799
|
providerOptions: providerMetadata,
|
|
4371
4800
|
schema: anthropicFilePartProviderOptions
|
|
4372
4801
|
});
|
|
4373
|
-
return (_b2 = (
|
|
4802
|
+
return (_b2 = (_a22 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a22.enabled) != null ? _b2 : false;
|
|
4374
4803
|
}
|
|
4375
4804
|
async function getDocumentMetadata(providerMetadata) {
|
|
4376
4805
|
const anthropicOptions = await parseProviderOptions({
|
|
@@ -4390,7 +4819,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4390
4819
|
switch (type) {
|
|
4391
4820
|
case "system": {
|
|
4392
4821
|
if (system != null) {
|
|
4393
|
-
throw new
|
|
4822
|
+
throw new UnsupportedFunctionalityError({
|
|
4394
4823
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
4395
4824
|
});
|
|
4396
4825
|
}
|
|
@@ -4413,10 +4842,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4413
4842
|
for (let j = 0; j < content.length; j++) {
|
|
4414
4843
|
const part = content[j];
|
|
4415
4844
|
const isLastPart = j === content.length - 1;
|
|
4416
|
-
const cacheControl = (
|
|
4845
|
+
const cacheControl = (_a15 = validator2.getCacheControl(part.providerOptions, {
|
|
4417
4846
|
type: "user message part",
|
|
4418
4847
|
canCache: true
|
|
4419
|
-
})) != null ?
|
|
4848
|
+
})) != null ? _a15 : isLastPart ? validator2.getCacheControl(message.providerOptions, {
|
|
4420
4849
|
type: "user message",
|
|
4421
4850
|
canCache: true
|
|
4422
4851
|
}) : void 0;
|
|
@@ -4493,7 +4922,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4493
4922
|
cache_control: cacheControl
|
|
4494
4923
|
});
|
|
4495
4924
|
} else {
|
|
4496
|
-
throw new
|
|
4925
|
+
throw new UnsupportedFunctionalityError({
|
|
4497
4926
|
functionality: `media type: ${part.mediaType}`
|
|
4498
4927
|
});
|
|
4499
4928
|
}
|
|
@@ -4547,7 +4976,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
4547
4976
|
}
|
|
4548
4977
|
};
|
|
4549
4978
|
}
|
|
4550
|
-
throw new
|
|
4979
|
+
throw new UnsupportedFunctionalityError({
|
|
4551
4980
|
functionality: `media type: ${contentPart.mediaType}`
|
|
4552
4981
|
});
|
|
4553
4982
|
}
|
|
@@ -4902,7 +5331,7 @@ function mapAnthropicStopReason({
|
|
|
4902
5331
|
}
|
|
4903
5332
|
}
|
|
4904
5333
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
4905
|
-
var
|
|
5334
|
+
var _a15;
|
|
4906
5335
|
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
4907
5336
|
return;
|
|
4908
5337
|
}
|
|
@@ -4915,7 +5344,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
4915
5344
|
sourceType: "document",
|
|
4916
5345
|
id: generateId3(),
|
|
4917
5346
|
mediaType: documentInfo.mediaType,
|
|
4918
|
-
title: (
|
|
5347
|
+
title: (_a15 = citation.document_title) != null ? _a15 : documentInfo.title,
|
|
4919
5348
|
filename: documentInfo.filename,
|
|
4920
5349
|
providerMetadata: {
|
|
4921
5350
|
anthropic: citation.type === "page_location" ? {
|
|
@@ -4933,10 +5362,10 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
4933
5362
|
var AnthropicMessagesLanguageModel = class {
|
|
4934
5363
|
constructor(modelId, config) {
|
|
4935
5364
|
this.specificationVersion = "v2";
|
|
4936
|
-
var
|
|
5365
|
+
var _a15;
|
|
4937
5366
|
this.modelId = modelId;
|
|
4938
5367
|
this.config = config;
|
|
4939
|
-
this.generateId = (
|
|
5368
|
+
this.generateId = (_a15 = config.generateId) != null ? _a15 : generateId;
|
|
4940
5369
|
}
|
|
4941
5370
|
supportsUrl(url) {
|
|
4942
5371
|
return url.protocol === "https:";
|
|
@@ -4945,8 +5374,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4945
5374
|
return this.config.provider;
|
|
4946
5375
|
}
|
|
4947
5376
|
get supportedUrls() {
|
|
4948
|
-
var
|
|
4949
|
-
return (_c = (_b = (
|
|
5377
|
+
var _a15, _b, _c;
|
|
5378
|
+
return (_c = (_b = (_a15 = this.config).supportedUrls) == null ? void 0 : _b.call(_a15)) != null ? _c : {};
|
|
4950
5379
|
}
|
|
4951
5380
|
async getArgs({
|
|
4952
5381
|
prompt,
|
|
@@ -4963,7 +5392,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4963
5392
|
toolChoice,
|
|
4964
5393
|
providerOptions
|
|
4965
5394
|
}) {
|
|
4966
|
-
var
|
|
5395
|
+
var _a15, _b, _c, _d;
|
|
4967
5396
|
const warnings = [];
|
|
4968
5397
|
if (frequencyPenalty != null) {
|
|
4969
5398
|
warnings.push({
|
|
@@ -5027,7 +5456,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5027
5456
|
const cacheControlValidator = new CacheControlValidator();
|
|
5028
5457
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
5029
5458
|
prompt,
|
|
5030
|
-
sendReasoning: (
|
|
5459
|
+
sendReasoning: (_a15 = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a15 : true,
|
|
5031
5460
|
warnings,
|
|
5032
5461
|
cacheControlValidator
|
|
5033
5462
|
});
|
|
@@ -5065,7 +5494,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5065
5494
|
};
|
|
5066
5495
|
if (isThinking) {
|
|
5067
5496
|
if (thinkingBudget == null) {
|
|
5068
|
-
throw new
|
|
5497
|
+
throw new UnsupportedFunctionalityError({
|
|
5069
5498
|
functionality: "thinking requires a budget"
|
|
5070
5499
|
});
|
|
5071
5500
|
}
|
|
@@ -5159,38 +5588,38 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5159
5588
|
);
|
|
5160
5589
|
}
|
|
5161
5590
|
buildRequestUrl(isStreaming) {
|
|
5162
|
-
var
|
|
5163
|
-
return (_c = (_b = (
|
|
5591
|
+
var _a15, _b, _c;
|
|
5592
|
+
return (_c = (_b = (_a15 = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a15, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
|
|
5164
5593
|
}
|
|
5165
5594
|
transformRequestBody(args) {
|
|
5166
|
-
var
|
|
5167
|
-
return (_c = (_b = (
|
|
5595
|
+
var _a15, _b, _c;
|
|
5596
|
+
return (_c = (_b = (_a15 = this.config).transformRequestBody) == null ? void 0 : _b.call(_a15, args)) != null ? _c : args;
|
|
5168
5597
|
}
|
|
5169
5598
|
extractCitationDocuments(prompt) {
|
|
5170
5599
|
const isCitationPart = (part) => {
|
|
5171
|
-
var
|
|
5600
|
+
var _a15, _b;
|
|
5172
5601
|
if (part.type !== "file") {
|
|
5173
5602
|
return false;
|
|
5174
5603
|
}
|
|
5175
5604
|
if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
|
|
5176
5605
|
return false;
|
|
5177
5606
|
}
|
|
5178
|
-
const anthropic2 = (
|
|
5607
|
+
const anthropic2 = (_a15 = part.providerOptions) == null ? void 0 : _a15.anthropic;
|
|
5179
5608
|
const citationsConfig = anthropic2 == null ? void 0 : anthropic2.citations;
|
|
5180
5609
|
return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
|
|
5181
5610
|
};
|
|
5182
5611
|
return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
|
|
5183
|
-
var
|
|
5612
|
+
var _a15;
|
|
5184
5613
|
const filePart = part;
|
|
5185
5614
|
return {
|
|
5186
|
-
title: (
|
|
5615
|
+
title: (_a15 = filePart.filename) != null ? _a15 : "Untitled Document",
|
|
5187
5616
|
filename: filePart.filename,
|
|
5188
5617
|
mediaType: filePart.mediaType
|
|
5189
5618
|
};
|
|
5190
5619
|
});
|
|
5191
5620
|
}
|
|
5192
5621
|
async doGenerate(options) {
|
|
5193
|
-
var
|
|
5622
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h;
|
|
5194
5623
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
5195
5624
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
5196
5625
|
const {
|
|
@@ -5333,11 +5762,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5333
5762
|
toolCallId: part.tool_use_id,
|
|
5334
5763
|
toolName: "web_search",
|
|
5335
5764
|
result: part.content.map((result) => {
|
|
5336
|
-
var
|
|
5765
|
+
var _a22;
|
|
5337
5766
|
return {
|
|
5338
5767
|
url: result.url,
|
|
5339
5768
|
title: result.title,
|
|
5340
|
-
pageAge: (
|
|
5769
|
+
pageAge: (_a22 = result.page_age) != null ? _a22 : null,
|
|
5341
5770
|
encryptedContent: result.encrypted_content,
|
|
5342
5771
|
type: result.type
|
|
5343
5772
|
};
|
|
@@ -5353,7 +5782,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5353
5782
|
title: result.title,
|
|
5354
5783
|
providerMetadata: {
|
|
5355
5784
|
anthropic: {
|
|
5356
|
-
pageAge: (
|
|
5785
|
+
pageAge: (_a15 = result.page_age) != null ? _a15 : null
|
|
5357
5786
|
}
|
|
5358
5787
|
}
|
|
5359
5788
|
});
|
|
@@ -5490,7 +5919,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5490
5919
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5491
5920
|
},
|
|
5492
5921
|
transform(chunk, controller) {
|
|
5493
|
-
var
|
|
5922
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5494
5923
|
if (options.includeRawChunks) {
|
|
5495
5924
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5496
5925
|
}
|
|
@@ -5629,11 +6058,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5629
6058
|
toolCallId: part.tool_use_id,
|
|
5630
6059
|
toolName: "web_search",
|
|
5631
6060
|
result: part.content.map((result) => {
|
|
5632
|
-
var
|
|
6061
|
+
var _a22;
|
|
5633
6062
|
return {
|
|
5634
6063
|
url: result.url,
|
|
5635
6064
|
title: result.title,
|
|
5636
|
-
pageAge: (
|
|
6065
|
+
pageAge: (_a22 = result.page_age) != null ? _a22 : null,
|
|
5637
6066
|
encryptedContent: result.encrypted_content,
|
|
5638
6067
|
type: result.type
|
|
5639
6068
|
};
|
|
@@ -5649,7 +6078,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5649
6078
|
title: result.title,
|
|
5650
6079
|
providerMetadata: {
|
|
5651
6080
|
anthropic: {
|
|
5652
|
-
pageAge: (
|
|
6081
|
+
pageAge: (_a15 = result.page_age) != null ? _a15 : null
|
|
5653
6082
|
}
|
|
5654
6083
|
}
|
|
5655
6084
|
});
|
|
@@ -6266,13 +6695,13 @@ var anthropicTools = {
|
|
|
6266
6695
|
webSearch_20250305
|
|
6267
6696
|
};
|
|
6268
6697
|
function createAnthropic(options = {}) {
|
|
6269
|
-
var
|
|
6270
|
-
const baseURL = (
|
|
6698
|
+
var _a15, _b;
|
|
6699
|
+
const baseURL = (_a15 = withoutTrailingSlash(
|
|
6271
6700
|
loadOptionalSetting({
|
|
6272
6701
|
settingValue: options.baseURL,
|
|
6273
6702
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
6274
6703
|
})
|
|
6275
|
-
)) != null ?
|
|
6704
|
+
)) != null ? _a15 : "https://api.anthropic.com/v1";
|
|
6276
6705
|
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
6277
6706
|
const getHeaders = () => withUserAgentSuffix(
|
|
6278
6707
|
{
|
|
@@ -6287,13 +6716,13 @@ function createAnthropic(options = {}) {
|
|
|
6287
6716
|
`ai-sdk/anthropic/${VERSION3}`
|
|
6288
6717
|
);
|
|
6289
6718
|
const createChatModel = (modelId) => {
|
|
6290
|
-
var
|
|
6719
|
+
var _a22;
|
|
6291
6720
|
return new AnthropicMessagesLanguageModel(modelId, {
|
|
6292
6721
|
provider: providerName,
|
|
6293
6722
|
baseURL,
|
|
6294
6723
|
headers: getHeaders,
|
|
6295
6724
|
fetch: options.fetch,
|
|
6296
|
-
generateId: (
|
|
6725
|
+
generateId: (_a22 = options.generateId) != null ? _a22 : generateId,
|
|
6297
6726
|
supportedUrls: () => ({
|
|
6298
6727
|
"image/*": [/^https?:\/\/.*$/]
|
|
6299
6728
|
})
|
|
@@ -6311,10 +6740,10 @@ function createAnthropic(options = {}) {
|
|
|
6311
6740
|
provider.chat = createChatModel;
|
|
6312
6741
|
provider.messages = createChatModel;
|
|
6313
6742
|
provider.textEmbeddingModel = (modelId) => {
|
|
6314
|
-
throw new
|
|
6743
|
+
throw new NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
6315
6744
|
};
|
|
6316
6745
|
provider.imageModel = (modelId) => {
|
|
6317
|
-
throw new
|
|
6746
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
6318
6747
|
};
|
|
6319
6748
|
provider.tools = anthropicTools;
|
|
6320
6749
|
return provider;
|
|
@@ -6392,7 +6821,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
6392
6821
|
schema: googleGenerativeAIEmbeddingProviderOptions
|
|
6393
6822
|
});
|
|
6394
6823
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
6395
|
-
throw new
|
|
6824
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
6396
6825
|
provider: this.provider,
|
|
6397
6826
|
modelId: this.modelId,
|
|
6398
6827
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -6568,16 +6997,16 @@ function isEmptyObjectSchema(jsonSchema2) {
|
|
|
6568
6997
|
return jsonSchema2 != null && typeof jsonSchema2 === "object" && jsonSchema2.type === "object" && (jsonSchema2.properties == null || Object.keys(jsonSchema2.properties).length === 0) && !jsonSchema2.additionalProperties;
|
|
6569
6998
|
}
|
|
6570
6999
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
6571
|
-
var
|
|
7000
|
+
var _a15;
|
|
6572
7001
|
const systemInstructionParts = [];
|
|
6573
7002
|
const contents = [];
|
|
6574
7003
|
let systemMessagesAllowed = true;
|
|
6575
|
-
const isGemmaModel = (
|
|
7004
|
+
const isGemmaModel = (_a15 = options == null ? void 0 : options.isGemmaModel) != null ? _a15 : false;
|
|
6576
7005
|
for (const { role, content } of prompt) {
|
|
6577
7006
|
switch (role) {
|
|
6578
7007
|
case "system": {
|
|
6579
7008
|
if (!systemMessagesAllowed) {
|
|
6580
|
-
throw new
|
|
7009
|
+
throw new UnsupportedFunctionalityError({
|
|
6581
7010
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
6582
7011
|
});
|
|
6583
7012
|
}
|
|
@@ -6620,8 +7049,8 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
6620
7049
|
contents.push({
|
|
6621
7050
|
role: "model",
|
|
6622
7051
|
parts: content.map((part) => {
|
|
6623
|
-
var
|
|
6624
|
-
const thoughtSignature = ((_b = (
|
|
7052
|
+
var _a22, _b, _c;
|
|
7053
|
+
const thoughtSignature = ((_b = (_a22 = part.providerOptions) == null ? void 0 : _a22.google) == null ? void 0 : _b.thoughtSignature) != null ? String((_c = part.providerOptions.google) == null ? void 0 : _c.thoughtSignature) : void 0;
|
|
6625
7054
|
switch (part.type) {
|
|
6626
7055
|
case "text": {
|
|
6627
7056
|
return part.text.length === 0 ? void 0 : {
|
|
@@ -6638,12 +7067,12 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
6638
7067
|
}
|
|
6639
7068
|
case "file": {
|
|
6640
7069
|
if (part.mediaType !== "image/png") {
|
|
6641
|
-
throw new
|
|
7070
|
+
throw new UnsupportedFunctionalityError({
|
|
6642
7071
|
functionality: "Only PNG images are supported in assistant messages"
|
|
6643
7072
|
});
|
|
6644
7073
|
}
|
|
6645
7074
|
if (part.data instanceof URL) {
|
|
6646
|
-
throw new
|
|
7075
|
+
throw new UnsupportedFunctionalityError({
|
|
6647
7076
|
functionality: "File data URLs in assistant messages are not supported"
|
|
6648
7077
|
});
|
|
6649
7078
|
}
|
|
@@ -6844,7 +7273,7 @@ function prepareTools3({
|
|
|
6844
7273
|
toolChoice,
|
|
6845
7274
|
modelId
|
|
6846
7275
|
}) {
|
|
6847
|
-
var
|
|
7276
|
+
var _a15;
|
|
6848
7277
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
6849
7278
|
const toolWarnings = [];
|
|
6850
7279
|
const isLatest = [
|
|
@@ -6963,7 +7392,7 @@ function prepareTools3({
|
|
|
6963
7392
|
case "function":
|
|
6964
7393
|
functionDeclarations.push({
|
|
6965
7394
|
name: tool2.name,
|
|
6966
|
-
description: (
|
|
7395
|
+
description: (_a15 = tool2.description) != null ? _a15 : "",
|
|
6967
7396
|
parameters: convertJSONSchemaToOpenAPISchema(tool2.inputSchema)
|
|
6968
7397
|
});
|
|
6969
7398
|
break;
|
|
@@ -7012,7 +7441,7 @@ function prepareTools3({
|
|
|
7012
7441
|
};
|
|
7013
7442
|
default: {
|
|
7014
7443
|
const _exhaustiveCheck = type;
|
|
7015
|
-
throw new
|
|
7444
|
+
throw new UnsupportedFunctionalityError({
|
|
7016
7445
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
7017
7446
|
});
|
|
7018
7447
|
}
|
|
@@ -7046,17 +7475,17 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
7046
7475
|
var GoogleGenerativeAILanguageModel = class {
|
|
7047
7476
|
constructor(modelId, config) {
|
|
7048
7477
|
this.specificationVersion = "v2";
|
|
7049
|
-
var
|
|
7478
|
+
var _a15;
|
|
7050
7479
|
this.modelId = modelId;
|
|
7051
7480
|
this.config = config;
|
|
7052
|
-
this.generateId = (
|
|
7481
|
+
this.generateId = (_a15 = config.generateId) != null ? _a15 : generateId;
|
|
7053
7482
|
}
|
|
7054
7483
|
get provider() {
|
|
7055
7484
|
return this.config.provider;
|
|
7056
7485
|
}
|
|
7057
7486
|
get supportedUrls() {
|
|
7058
|
-
var
|
|
7059
|
-
return (_c = (_b = (
|
|
7487
|
+
var _a15, _b, _c;
|
|
7488
|
+
return (_c = (_b = (_a15 = this.config).supportedUrls) == null ? void 0 : _b.call(_a15)) != null ? _c : {};
|
|
7060
7489
|
}
|
|
7061
7490
|
async getArgs({
|
|
7062
7491
|
prompt,
|
|
@@ -7073,7 +7502,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7073
7502
|
toolChoice,
|
|
7074
7503
|
providerOptions
|
|
7075
7504
|
}) {
|
|
7076
|
-
var
|
|
7505
|
+
var _a15;
|
|
7077
7506
|
const warnings = [];
|
|
7078
7507
|
const googleOptions = await parseProviderOptions({
|
|
7079
7508
|
provider: "google",
|
|
@@ -7119,7 +7548,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7119
7548
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
7120
7549
|
// so this is needed as an escape hatch:
|
|
7121
7550
|
// TODO convert into provider option
|
|
7122
|
-
((
|
|
7551
|
+
((_a15 = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a15 : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
7123
7552
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
7124
7553
|
audioTimestamp: googleOptions.audioTimestamp
|
|
7125
7554
|
},
|
|
@@ -7145,7 +7574,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7145
7574
|
};
|
|
7146
7575
|
}
|
|
7147
7576
|
async doGenerate(options) {
|
|
7148
|
-
var
|
|
7577
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
7149
7578
|
const { args, warnings } = await this.getArgs(options);
|
|
7150
7579
|
const body = JSON.stringify(args);
|
|
7151
7580
|
const mergedHeaders = combineHeaders(
|
|
@@ -7169,7 +7598,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7169
7598
|
});
|
|
7170
7599
|
const candidate = response.candidates[0];
|
|
7171
7600
|
const content = [];
|
|
7172
|
-
const parts = (_b = (
|
|
7601
|
+
const parts = (_b = (_a15 = candidate.content) == null ? void 0 : _a15.parts) != null ? _b : [];
|
|
7173
7602
|
const usageMetadata = response.usageMetadata;
|
|
7174
7603
|
let lastCodeExecutionToolCallId;
|
|
7175
7604
|
for (const part of parts) {
|
|
@@ -7295,7 +7724,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7295
7724
|
controller.enqueue({ type: "stream-start", warnings });
|
|
7296
7725
|
},
|
|
7297
7726
|
transform(chunk, controller) {
|
|
7298
|
-
var
|
|
7727
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
7299
7728
|
if (options.includeRawChunks) {
|
|
7300
7729
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
7301
7730
|
}
|
|
@@ -7306,7 +7735,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7306
7735
|
const value = chunk.value;
|
|
7307
7736
|
const usageMetadata = value.usageMetadata;
|
|
7308
7737
|
if (usageMetadata != null) {
|
|
7309
|
-
usage.inputTokens = (
|
|
7738
|
+
usage.inputTokens = (_a15 = usageMetadata.promptTokenCount) != null ? _a15 : void 0;
|
|
7310
7739
|
usage.outputTokens = (_b = usageMetadata.candidatesTokenCount) != null ? _b : void 0;
|
|
7311
7740
|
usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
|
|
7312
7741
|
usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
|
|
@@ -7531,7 +7960,7 @@ function extractSources({
|
|
|
7531
7960
|
groundingMetadata,
|
|
7532
7961
|
generateId: generateId3
|
|
7533
7962
|
}) {
|
|
7534
|
-
var
|
|
7963
|
+
var _a15, _b, _c;
|
|
7535
7964
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
7536
7965
|
return void 0;
|
|
7537
7966
|
}
|
|
@@ -7543,7 +7972,7 @@ function extractSources({
|
|
|
7543
7972
|
sourceType: "url",
|
|
7544
7973
|
id: generateId3(),
|
|
7545
7974
|
url: chunk.web.uri,
|
|
7546
|
-
title: (
|
|
7975
|
+
title: (_a15 = chunk.web.title) != null ? _a15 : void 0
|
|
7547
7976
|
});
|
|
7548
7977
|
} else if (chunk.retrievedContext != null) {
|
|
7549
7978
|
const uri = chunk.retrievedContext.uri;
|
|
@@ -7831,14 +8260,14 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
7831
8260
|
this.specificationVersion = "v2";
|
|
7832
8261
|
}
|
|
7833
8262
|
get maxImagesPerCall() {
|
|
7834
|
-
var
|
|
7835
|
-
return (
|
|
8263
|
+
var _a15;
|
|
8264
|
+
return (_a15 = this.settings.maxImagesPerCall) != null ? _a15 : 4;
|
|
7836
8265
|
}
|
|
7837
8266
|
get provider() {
|
|
7838
8267
|
return this.config.provider;
|
|
7839
8268
|
}
|
|
7840
8269
|
async doGenerate(options) {
|
|
7841
|
-
var
|
|
8270
|
+
var _a15, _b, _c;
|
|
7842
8271
|
const {
|
|
7843
8272
|
prompt,
|
|
7844
8273
|
n = 1,
|
|
@@ -7869,7 +8298,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
7869
8298
|
providerOptions,
|
|
7870
8299
|
schema: googleImageProviderOptionsSchema
|
|
7871
8300
|
});
|
|
7872
|
-
const currentDate = (_c = (_b = (
|
|
8301
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
7873
8302
|
const parameters = {
|
|
7874
8303
|
sampleCount: n
|
|
7875
8304
|
};
|
|
@@ -7930,8 +8359,8 @@ var googleImageProviderOptionsSchema = lazySchema(
|
|
|
7930
8359
|
)
|
|
7931
8360
|
);
|
|
7932
8361
|
function createGoogleGenerativeAI(options = {}) {
|
|
7933
|
-
var
|
|
7934
|
-
const baseURL = (
|
|
8362
|
+
var _a15, _b;
|
|
8363
|
+
const baseURL = (_a15 = withoutTrailingSlash(options.baseURL)) != null ? _a15 : "https://generativelanguage.googleapis.com/v1beta";
|
|
7935
8364
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
7936
8365
|
const getHeaders = () => withUserAgentSuffix(
|
|
7937
8366
|
{
|
|
@@ -7945,12 +8374,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
7945
8374
|
`ai-sdk/google/${VERSION4}`
|
|
7946
8375
|
);
|
|
7947
8376
|
const createChatModel = (modelId) => {
|
|
7948
|
-
var
|
|
8377
|
+
var _a22;
|
|
7949
8378
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
|
7950
8379
|
provider: providerName,
|
|
7951
8380
|
baseURL,
|
|
7952
8381
|
headers: getHeaders,
|
|
7953
|
-
generateId: (
|
|
8382
|
+
generateId: (_a22 = options.generateId) != null ? _a22 : generateId,
|
|
7954
8383
|
supportedUrls: () => ({
|
|
7955
8384
|
"*": [
|
|
7956
8385
|
// Google Generative Language "files" endpoint
|
|
@@ -8055,7 +8484,7 @@ function convertToOpenAIChatMessages({
|
|
|
8055
8484
|
messages.push({
|
|
8056
8485
|
role: "user",
|
|
8057
8486
|
content: content.map((part, index) => {
|
|
8058
|
-
var
|
|
8487
|
+
var _a15, _b, _c;
|
|
8059
8488
|
switch (part.type) {
|
|
8060
8489
|
case "text": {
|
|
8061
8490
|
return { type: "text", text: part.text };
|
|
@@ -8068,12 +8497,12 @@ function convertToOpenAIChatMessages({
|
|
|
8068
8497
|
image_url: {
|
|
8069
8498
|
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
8070
8499
|
// OpenAI specific extension: image detail
|
|
8071
|
-
detail: (_b = (
|
|
8500
|
+
detail: (_b = (_a15 = part.providerOptions) == null ? void 0 : _a15.openai) == null ? void 0 : _b.imageDetail
|
|
8072
8501
|
}
|
|
8073
8502
|
};
|
|
8074
8503
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
8075
8504
|
if (part.data instanceof URL) {
|
|
8076
|
-
throw new
|
|
8505
|
+
throw new UnsupportedFunctionalityError({
|
|
8077
8506
|
functionality: "audio file parts with URLs"
|
|
8078
8507
|
});
|
|
8079
8508
|
}
|
|
@@ -8098,14 +8527,14 @@ function convertToOpenAIChatMessages({
|
|
|
8098
8527
|
};
|
|
8099
8528
|
}
|
|
8100
8529
|
default: {
|
|
8101
|
-
throw new
|
|
8530
|
+
throw new UnsupportedFunctionalityError({
|
|
8102
8531
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
8103
8532
|
});
|
|
8104
8533
|
}
|
|
8105
8534
|
}
|
|
8106
8535
|
} else if (part.mediaType === "application/pdf") {
|
|
8107
8536
|
if (part.data instanceof URL) {
|
|
8108
|
-
throw new
|
|
8537
|
+
throw new UnsupportedFunctionalityError({
|
|
8109
8538
|
functionality: "PDF file parts with URLs"
|
|
8110
8539
|
});
|
|
8111
8540
|
}
|
|
@@ -8117,7 +8546,7 @@ function convertToOpenAIChatMessages({
|
|
|
8117
8546
|
}
|
|
8118
8547
|
};
|
|
8119
8548
|
} else {
|
|
8120
|
-
throw new
|
|
8549
|
+
throw new UnsupportedFunctionalityError({
|
|
8121
8550
|
functionality: `file part media type ${part.mediaType}`
|
|
8122
8551
|
});
|
|
8123
8552
|
}
|
|
@@ -8501,7 +8930,7 @@ function prepareChatTools({
|
|
|
8501
8930
|
};
|
|
8502
8931
|
default: {
|
|
8503
8932
|
const _exhaustiveCheck = type;
|
|
8504
|
-
throw new
|
|
8933
|
+
throw new UnsupportedFunctionalityError({
|
|
8505
8934
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
8506
8935
|
});
|
|
8507
8936
|
}
|
|
@@ -8534,13 +8963,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
8534
8963
|
toolChoice,
|
|
8535
8964
|
providerOptions
|
|
8536
8965
|
}) {
|
|
8537
|
-
var
|
|
8966
|
+
var _a15, _b, _c, _d;
|
|
8538
8967
|
const warnings = [];
|
|
8539
|
-
const openaiOptions = (
|
|
8968
|
+
const openaiOptions = (_a15 = await parseProviderOptions({
|
|
8540
8969
|
provider: "openai",
|
|
8541
8970
|
providerOptions,
|
|
8542
8971
|
schema: openaiChatLanguageModelOptions
|
|
8543
|
-
})) != null ?
|
|
8972
|
+
})) != null ? _a15 : {};
|
|
8544
8973
|
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
8545
8974
|
if (topK != null) {
|
|
8546
8975
|
warnings.push({
|
|
@@ -8710,7 +9139,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8710
9139
|
};
|
|
8711
9140
|
}
|
|
8712
9141
|
async doGenerate(options) {
|
|
8713
|
-
var
|
|
9142
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8714
9143
|
const { args: body, warnings } = await this.getArgs(options);
|
|
8715
9144
|
const {
|
|
8716
9145
|
responseHeaders,
|
|
@@ -8736,7 +9165,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8736
9165
|
if (text != null && text.length > 0) {
|
|
8737
9166
|
content.push({ type: "text", text });
|
|
8738
9167
|
}
|
|
8739
|
-
for (const toolCall of (
|
|
9168
|
+
for (const toolCall of (_a15 = choice.message.tool_calls) != null ? _a15 : []) {
|
|
8740
9169
|
content.push({
|
|
8741
9170
|
type: "tool-call",
|
|
8742
9171
|
toolCallId: (_b = toolCall.id) != null ? _b : generateId(),
|
|
@@ -8825,7 +9254,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8825
9254
|
controller.enqueue({ type: "stream-start", warnings });
|
|
8826
9255
|
},
|
|
8827
9256
|
transform(chunk, controller) {
|
|
8828
|
-
var
|
|
9257
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
8829
9258
|
if (options.includeRawChunks) {
|
|
8830
9259
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
8831
9260
|
}
|
|
@@ -8851,7 +9280,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8851
9280
|
}
|
|
8852
9281
|
}
|
|
8853
9282
|
if (value.usage != null) {
|
|
8854
|
-
usage.inputTokens = (
|
|
9283
|
+
usage.inputTokens = (_a15 = value.usage.prompt_tokens) != null ? _a15 : void 0;
|
|
8855
9284
|
usage.outputTokens = (_b = value.usage.completion_tokens) != null ? _b : void 0;
|
|
8856
9285
|
usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : void 0;
|
|
8857
9286
|
usage.reasoningTokens = (_e = (_d = value.usage.completion_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
|
|
@@ -8890,19 +9319,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
8890
9319
|
const index = toolCallDelta.index;
|
|
8891
9320
|
if (toolCalls[index] == null) {
|
|
8892
9321
|
if (toolCallDelta.type !== "function") {
|
|
8893
|
-
throw new
|
|
9322
|
+
throw new InvalidResponseDataError({
|
|
8894
9323
|
data: toolCallDelta,
|
|
8895
9324
|
message: `Expected 'function' type.`
|
|
8896
9325
|
});
|
|
8897
9326
|
}
|
|
8898
9327
|
if (toolCallDelta.id == null) {
|
|
8899
|
-
throw new
|
|
9328
|
+
throw new InvalidResponseDataError({
|
|
8900
9329
|
data: toolCallDelta,
|
|
8901
9330
|
message: `Expected 'id' to be a string.`
|
|
8902
9331
|
});
|
|
8903
9332
|
}
|
|
8904
9333
|
if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
|
|
8905
|
-
throw new
|
|
9334
|
+
throw new InvalidResponseDataError({
|
|
8906
9335
|
data: toolCallDelta,
|
|
8907
9336
|
message: `Expected 'function.name' to be a string.`
|
|
8908
9337
|
});
|
|
@@ -9013,11 +9442,11 @@ function supportsPriorityProcessing(modelId) {
|
|
|
9013
9442
|
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");
|
|
9014
9443
|
}
|
|
9015
9444
|
function getSystemMessageMode(modelId) {
|
|
9016
|
-
var
|
|
9445
|
+
var _a15, _b;
|
|
9017
9446
|
if (!isReasoningModel(modelId)) {
|
|
9018
9447
|
return "system";
|
|
9019
9448
|
}
|
|
9020
|
-
return (_b = (
|
|
9449
|
+
return (_b = (_a15 = reasoningModels[modelId]) == null ? void 0 : _a15.systemMessageMode) != null ? _b : "developer";
|
|
9021
9450
|
}
|
|
9022
9451
|
var reasoningModels = {
|
|
9023
9452
|
o3: {
|
|
@@ -9054,7 +9483,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
9054
9483
|
for (const { role, content } of prompt) {
|
|
9055
9484
|
switch (role) {
|
|
9056
9485
|
case "system": {
|
|
9057
|
-
throw new
|
|
9486
|
+
throw new InvalidPromptError({
|
|
9058
9487
|
message: "Unexpected system message in prompt: ${content}",
|
|
9059
9488
|
prompt
|
|
9060
9489
|
});
|
|
@@ -9080,7 +9509,7 @@ ${userMessage}
|
|
|
9080
9509
|
return part.text;
|
|
9081
9510
|
}
|
|
9082
9511
|
case "tool-call": {
|
|
9083
|
-
throw new
|
|
9512
|
+
throw new UnsupportedFunctionalityError({
|
|
9084
9513
|
functionality: "tool-call messages"
|
|
9085
9514
|
});
|
|
9086
9515
|
}
|
|
@@ -9093,7 +9522,7 @@ ${assistantMessage}
|
|
|
9093
9522
|
break;
|
|
9094
9523
|
}
|
|
9095
9524
|
case "tool": {
|
|
9096
|
-
throw new
|
|
9525
|
+
throw new UnsupportedFunctionalityError({
|
|
9097
9526
|
functionality: "tool messages"
|
|
9098
9527
|
});
|
|
9099
9528
|
}
|
|
@@ -9322,7 +9751,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
9322
9751
|
};
|
|
9323
9752
|
}
|
|
9324
9753
|
async doGenerate(options) {
|
|
9325
|
-
var
|
|
9754
|
+
var _a15, _b, _c;
|
|
9326
9755
|
const { args, warnings } = await this.getArgs(options);
|
|
9327
9756
|
const {
|
|
9328
9757
|
responseHeaders,
|
|
@@ -9350,7 +9779,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
9350
9779
|
return {
|
|
9351
9780
|
content: [{ type: "text", text: choice.text }],
|
|
9352
9781
|
usage: {
|
|
9353
|
-
inputTokens: (
|
|
9782
|
+
inputTokens: (_a15 = response.usage) == null ? void 0 : _a15.prompt_tokens,
|
|
9354
9783
|
outputTokens: (_b = response.usage) == null ? void 0 : _b.completion_tokens,
|
|
9355
9784
|
totalTokens: (_c = response.usage) == null ? void 0 : _c.total_tokens
|
|
9356
9785
|
},
|
|
@@ -9504,20 +9933,20 @@ var OpenAIEmbeddingModel = class {
|
|
|
9504
9933
|
abortSignal,
|
|
9505
9934
|
providerOptions
|
|
9506
9935
|
}) {
|
|
9507
|
-
var
|
|
9936
|
+
var _a15;
|
|
9508
9937
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
9509
|
-
throw new
|
|
9938
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
9510
9939
|
provider: this.provider,
|
|
9511
9940
|
modelId: this.modelId,
|
|
9512
9941
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
9513
9942
|
values
|
|
9514
9943
|
});
|
|
9515
9944
|
}
|
|
9516
|
-
const openaiOptions = (
|
|
9945
|
+
const openaiOptions = (_a15 = await parseProviderOptions({
|
|
9517
9946
|
provider: "openai",
|
|
9518
9947
|
providerOptions,
|
|
9519
9948
|
schema: openaiEmbeddingProviderOptions
|
|
9520
|
-
})) != null ?
|
|
9949
|
+
})) != null ? _a15 : {};
|
|
9521
9950
|
const {
|
|
9522
9951
|
responseHeaders,
|
|
9523
9952
|
value: response,
|
|
@@ -9578,8 +10007,8 @@ var OpenAIImageModel = class {
|
|
|
9578
10007
|
this.specificationVersion = "v2";
|
|
9579
10008
|
}
|
|
9580
10009
|
get maxImagesPerCall() {
|
|
9581
|
-
var
|
|
9582
|
-
return (
|
|
10010
|
+
var _a15;
|
|
10011
|
+
return (_a15 = modelMaxImagesPerCall[this.modelId]) != null ? _a15 : 1;
|
|
9583
10012
|
}
|
|
9584
10013
|
get provider() {
|
|
9585
10014
|
return this.config.provider;
|
|
@@ -9594,7 +10023,7 @@ var OpenAIImageModel = class {
|
|
|
9594
10023
|
headers,
|
|
9595
10024
|
abortSignal
|
|
9596
10025
|
}) {
|
|
9597
|
-
var
|
|
10026
|
+
var _a15, _b, _c, _d;
|
|
9598
10027
|
const warnings = [];
|
|
9599
10028
|
if (aspectRatio != null) {
|
|
9600
10029
|
warnings.push({
|
|
@@ -9606,7 +10035,7 @@ var OpenAIImageModel = class {
|
|
|
9606
10035
|
if (seed != null) {
|
|
9607
10036
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
9608
10037
|
}
|
|
9609
|
-
const currentDate = (_c = (_b = (
|
|
10038
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
9610
10039
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
9611
10040
|
url: this.config.url({
|
|
9612
10041
|
path: "/images/generations",
|
|
@@ -9966,7 +10395,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
9966
10395
|
store,
|
|
9967
10396
|
hasLocalShellTool = false
|
|
9968
10397
|
}) {
|
|
9969
|
-
var
|
|
10398
|
+
var _a15, _b, _c, _d;
|
|
9970
10399
|
const input = [];
|
|
9971
10400
|
const warnings = [];
|
|
9972
10401
|
for (const { role, content } of prompt) {
|
|
@@ -10001,7 +10430,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10001
10430
|
input.push({
|
|
10002
10431
|
role: "user",
|
|
10003
10432
|
content: content.map((part, index) => {
|
|
10004
|
-
var
|
|
10433
|
+
var _a22, _b2, _c2;
|
|
10005
10434
|
switch (part.type) {
|
|
10006
10435
|
case "text": {
|
|
10007
10436
|
return { type: "input_text", text: part.text };
|
|
@@ -10014,7 +10443,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10014
10443
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
10015
10444
|
image_url: `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
10016
10445
|
},
|
|
10017
|
-
detail: (_b2 = (
|
|
10446
|
+
detail: (_b2 = (_a22 = part.providerOptions) == null ? void 0 : _a22.openai) == null ? void 0 : _b2.imageDetail
|
|
10018
10447
|
};
|
|
10019
10448
|
} else if (part.mediaType === "application/pdf") {
|
|
10020
10449
|
if (part.data instanceof URL) {
|
|
@@ -10031,7 +10460,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10031
10460
|
}
|
|
10032
10461
|
};
|
|
10033
10462
|
} else {
|
|
10034
|
-
throw new
|
|
10463
|
+
throw new UnsupportedFunctionalityError({
|
|
10035
10464
|
functionality: `file part media type ${part.mediaType}`
|
|
10036
10465
|
});
|
|
10037
10466
|
}
|
|
@@ -10046,7 +10475,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10046
10475
|
for (const part of content) {
|
|
10047
10476
|
switch (part.type) {
|
|
10048
10477
|
case "text": {
|
|
10049
|
-
const id = (_b = (
|
|
10478
|
+
const id = (_b = (_a15 = part.providerOptions) == null ? void 0 : _a15.openai) == null ? void 0 : _b.itemId;
|
|
10050
10479
|
if (store && id != null) {
|
|
10051
10480
|
input.push({ type: "item_reference", id });
|
|
10052
10481
|
break;
|
|
@@ -10885,7 +11314,7 @@ async function prepareResponsesTools({
|
|
|
10885
11314
|
};
|
|
10886
11315
|
default: {
|
|
10887
11316
|
const _exhaustiveCheck = type;
|
|
10888
|
-
throw new
|
|
11317
|
+
throw new UnsupportedFunctionalityError({
|
|
10889
11318
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
10890
11319
|
});
|
|
10891
11320
|
}
|
|
@@ -10919,7 +11348,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
10919
11348
|
toolChoice,
|
|
10920
11349
|
responseFormat
|
|
10921
11350
|
}) {
|
|
10922
|
-
var
|
|
11351
|
+
var _a15, _b, _c, _d;
|
|
10923
11352
|
const warnings = [];
|
|
10924
11353
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
10925
11354
|
if (topK != null) {
|
|
@@ -10959,7 +11388,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
10959
11388
|
prompt,
|
|
10960
11389
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
10961
11390
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
10962
|
-
store: (
|
|
11391
|
+
store: (_a15 = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a15 : true,
|
|
10963
11392
|
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
10964
11393
|
});
|
|
10965
11394
|
warnings.push(...inputWarnings);
|
|
@@ -11114,7 +11543,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11114
11543
|
};
|
|
11115
11544
|
}
|
|
11116
11545
|
async doGenerate(options) {
|
|
11117
|
-
var
|
|
11546
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
11118
11547
|
const {
|
|
11119
11548
|
args: body,
|
|
11120
11549
|
warnings,
|
|
@@ -11140,7 +11569,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11140
11569
|
fetch: this.config.fetch
|
|
11141
11570
|
});
|
|
11142
11571
|
if (response.error) {
|
|
11143
|
-
throw new
|
|
11572
|
+
throw new APICallError({
|
|
11144
11573
|
message: response.error.message,
|
|
11145
11574
|
url,
|
|
11146
11575
|
requestBodyValues: body,
|
|
@@ -11166,7 +11595,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11166
11595
|
providerMetadata: {
|
|
11167
11596
|
openai: {
|
|
11168
11597
|
itemId: part.id,
|
|
11169
|
-
reasoningEncryptedContent: (
|
|
11598
|
+
reasoningEncryptedContent: (_a15 = part.encrypted_content) != null ? _a15 : null
|
|
11170
11599
|
}
|
|
11171
11600
|
}
|
|
11172
11601
|
});
|
|
@@ -11435,7 +11864,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11435
11864
|
controller.enqueue({ type: "stream-start", warnings });
|
|
11436
11865
|
},
|
|
11437
11866
|
transform(chunk, controller) {
|
|
11438
|
-
var
|
|
11867
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
11439
11868
|
if (options.includeRawChunks) {
|
|
11440
11869
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
11441
11870
|
}
|
|
@@ -11545,7 +11974,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11545
11974
|
providerMetadata: {
|
|
11546
11975
|
openai: {
|
|
11547
11976
|
itemId: value.item.id,
|
|
11548
|
-
reasoningEncryptedContent: (
|
|
11977
|
+
reasoningEncryptedContent: (_a15 = value.item.encrypted_content) != null ? _a15 : null
|
|
11549
11978
|
}
|
|
11550
11979
|
}
|
|
11551
11980
|
});
|
|
@@ -11923,11 +12352,11 @@ function getResponsesModelConfig(modelId) {
|
|
|
11923
12352
|
};
|
|
11924
12353
|
}
|
|
11925
12354
|
function mapWebSearchOutput(action) {
|
|
11926
|
-
var
|
|
12355
|
+
var _a15;
|
|
11927
12356
|
switch (action.type) {
|
|
11928
12357
|
case "search":
|
|
11929
12358
|
return {
|
|
11930
|
-
action: { type: "search", query: (
|
|
12359
|
+
action: { type: "search", query: (_a15 = action.query) != null ? _a15 : void 0 },
|
|
11931
12360
|
// include sources when provided by the Responses API (behind include flag)
|
|
11932
12361
|
...action.sources != null && { sources: action.sources }
|
|
11933
12362
|
};
|
|
@@ -12012,8 +12441,8 @@ var OpenAISpeechModel = class {
|
|
|
12012
12441
|
};
|
|
12013
12442
|
}
|
|
12014
12443
|
async doGenerate(options) {
|
|
12015
|
-
var
|
|
12016
|
-
const currentDate = (_c = (_b = (
|
|
12444
|
+
var _a15, _b, _c;
|
|
12445
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
12017
12446
|
const { requestBody, warnings } = await this.getArgs(options);
|
|
12018
12447
|
const {
|
|
12019
12448
|
value: audio,
|
|
@@ -12224,8 +12653,8 @@ var OpenAITranscriptionModel = class {
|
|
|
12224
12653
|
};
|
|
12225
12654
|
}
|
|
12226
12655
|
async doGenerate(options) {
|
|
12227
|
-
var
|
|
12228
|
-
const currentDate = (_c = (_b = (
|
|
12656
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h;
|
|
12657
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
12229
12658
|
const { formData, warnings } = await this.getArgs(options);
|
|
12230
12659
|
const {
|
|
12231
12660
|
value: response,
|
|
@@ -12271,13 +12700,13 @@ var OpenAITranscriptionModel = class {
|
|
|
12271
12700
|
};
|
|
12272
12701
|
var VERSION5 = "2.0.69" ;
|
|
12273
12702
|
function createOpenAI(options = {}) {
|
|
12274
|
-
var
|
|
12275
|
-
const baseURL = (
|
|
12703
|
+
var _a15, _b;
|
|
12704
|
+
const baseURL = (_a15 = withoutTrailingSlash(
|
|
12276
12705
|
loadOptionalSetting({
|
|
12277
12706
|
settingValue: options.baseURL,
|
|
12278
12707
|
environmentVariableName: "OPENAI_BASE_URL"
|
|
12279
12708
|
})
|
|
12280
|
-
)) != null ?
|
|
12709
|
+
)) != null ? _a15 : "https://api.openai.com/v1";
|
|
12281
12710
|
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
12282
12711
|
const getHeaders = () => withUserAgentSuffix(
|
|
12283
12712
|
{
|
|
@@ -12366,8 +12795,20 @@ function createOpenAI(options = {}) {
|
|
|
12366
12795
|
}
|
|
12367
12796
|
createOpenAI();
|
|
12368
12797
|
|
|
12798
|
+
exports.APICallError = APICallError;
|
|
12799
|
+
exports.EmptyResponseBodyError = EmptyResponseBodyError;
|
|
12800
|
+
exports.EventSourceParserStream = EventSourceParserStream;
|
|
12801
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
12802
|
+
exports.InvalidPromptError = InvalidPromptError;
|
|
12803
|
+
exports.InvalidResponseDataError = InvalidResponseDataError;
|
|
12804
|
+
exports.JSONParseError = JSONParseError;
|
|
12805
|
+
exports.LoadAPIKeyError = LoadAPIKeyError;
|
|
12369
12806
|
exports.MastraModelGateway = MastraModelGateway;
|
|
12807
|
+
exports.NoSuchModelError = NoSuchModelError;
|
|
12370
12808
|
exports.OpenAICompatibleImageModel = OpenAICompatibleImageModel;
|
|
12809
|
+
exports.TooManyEmbeddingValuesForCallError = TooManyEmbeddingValuesForCallError;
|
|
12810
|
+
exports.TypeValidationError = TypeValidationError;
|
|
12811
|
+
exports.UnsupportedFunctionalityError = UnsupportedFunctionalityError;
|
|
12371
12812
|
exports.combineHeaders = combineHeaders;
|
|
12372
12813
|
exports.convertBase64ToUint8Array = convertBase64ToUint8Array;
|
|
12373
12814
|
exports.convertToBase64 = convertToBase64;
|
|
@@ -12395,5 +12836,5 @@ exports.validateTypes = validateTypes;
|
|
|
12395
12836
|
exports.withUserAgentSuffix = withUserAgentSuffix;
|
|
12396
12837
|
exports.withoutTrailingSlash = withoutTrailingSlash;
|
|
12397
12838
|
exports.zodSchema = zodSchema;
|
|
12398
|
-
//# sourceMappingURL=chunk-
|
|
12399
|
-
//# sourceMappingURL=chunk-
|
|
12839
|
+
//# sourceMappingURL=chunk-F75EQ574.cjs.map
|
|
12840
|
+
//# sourceMappingURL=chunk-F75EQ574.cjs.map
|