@mastra/core 1.0.0-beta.2 → 1.0.0-beta.4
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 +206 -0
- package/dist/agent/agent-legacy.d.ts +2 -2
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +1 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +3 -2
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +9 -9
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +5 -0
- 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/convert-file.d.ts +1 -1
- package/dist/agent/message-list/prompt/convert-file.d.ts.map +1 -1
- package/dist/agent/message-list/prompt/download-assets.d.ts.map +1 -1
- package/dist/agent/types.d.ts +1 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +2 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +3 -1
- 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 +2 -1
- 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 +2 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/{chunk-YCVEJ3UN.cjs → chunk-2NVBZKZI.cjs} +988 -233
- package/dist/chunk-2NVBZKZI.cjs.map +1 -0
- package/dist/{chunk-SNPVZPLB.js → chunk-2OTDXX73.js} +6 -5
- package/dist/chunk-2OTDXX73.js.map +1 -0
- package/dist/chunk-3PSWNGBF.js +3 -0
- package/dist/{chunk-ZV5CC35D.js.map → chunk-3PSWNGBF.js.map} +1 -1
- package/dist/{chunk-ZGHTOYHW.js → chunk-3RW5EMSB.js} +155 -24
- package/dist/chunk-3RW5EMSB.js.map +1 -0
- package/dist/chunk-3W5RQCCY.cjs +440 -0
- package/dist/chunk-3W5RQCCY.cjs.map +1 -0
- package/dist/{chunk-ET6UOTTU.cjs → chunk-4IKJAKCD.cjs} +40 -4
- package/dist/chunk-4IKJAKCD.cjs.map +1 -0
- package/dist/{chunk-2ZVKF4HP.cjs → chunk-4RXG622P.cjs} +184 -285
- package/dist/chunk-4RXG622P.cjs.map +1 -0
- package/dist/{chunk-22443P6A.cjs → chunk-5WXEYDFI.cjs} +173 -42
- package/dist/chunk-5WXEYDFI.cjs.map +1 -0
- package/dist/{chunk-ZWNI5IWX.cjs → chunk-CYVNOIXS.cjs} +13 -12
- package/dist/chunk-CYVNOIXS.cjs.map +1 -0
- package/dist/{chunk-4CDL2QJT.js → chunk-D6EDHNGV.js} +53 -16
- package/dist/chunk-D6EDHNGV.js.map +1 -0
- package/dist/chunk-FVNT7VTO.js +436 -0
- package/dist/chunk-FVNT7VTO.js.map +1 -0
- package/dist/{chunk-WM6CK2F3.cjs → chunk-HBJPYQRN.cjs} +57 -19
- package/dist/chunk-HBJPYQRN.cjs.map +1 -0
- package/dist/{chunk-HDJFSJCK.js → chunk-IHJDOC3A.js} +35 -587
- package/dist/chunk-IHJDOC3A.js.map +1 -0
- package/dist/{chunk-QUKUN6NR.cjs → chunk-ISMGVGUM.cjs} +105 -5
- package/dist/chunk-ISMGVGUM.cjs.map +1 -0
- package/dist/{chunk-JYYQQEBH.cjs → chunk-IWB65P37.cjs} +241 -4
- package/dist/chunk-IWB65P37.cjs.map +1 -0
- package/dist/{chunk-MV7KHWUT.js → chunk-IWQDBVJK.js} +25 -4
- package/dist/chunk-IWQDBVJK.js.map +1 -0
- package/dist/{chunk-XEVG546F.js → chunk-JXESKY4A.js} +3 -3
- package/dist/{chunk-XEVG546F.js.map → chunk-JXESKY4A.js.map} +1 -1
- package/dist/{chunk-7AHYOMHJ.js → chunk-KEURQGCQ.js} +40 -5
- package/dist/chunk-KEURQGCQ.js.map +1 -0
- package/dist/{chunk-JPGVRWWL.js → chunk-MDKPL2R2.js} +470 -124
- package/dist/chunk-MDKPL2R2.js.map +1 -0
- package/dist/{chunk-UIZSWUKP.js → chunk-NZAXAFI3.js} +104 -6
- package/dist/chunk-NZAXAFI3.js.map +1 -0
- package/dist/{chunk-VOY2RXOC.cjs → chunk-O6NA3Z43.cjs} +6 -6
- package/dist/{chunk-VOY2RXOC.cjs.map → chunk-O6NA3Z43.cjs.map} +1 -1
- package/dist/chunk-PE3V7GUL.cjs +4 -0
- package/dist/{chunk-LJFJTTZQ.cjs.map → chunk-PE3V7GUL.cjs.map} +1 -1
- package/dist/{chunk-I4CXL4SR.js → chunk-RXDJL5QT.js} +5 -4
- package/dist/chunk-RXDJL5QT.js.map +1 -0
- package/dist/{chunk-LWBQ4P4N.cjs → chunk-S6OEQHEI.cjs} +62 -614
- package/dist/chunk-S6OEQHEI.cjs.map +1 -0
- package/dist/{chunk-7PO6SEJF.js → chunk-U7VECK2G.js} +240 -3
- package/dist/chunk-U7VECK2G.js.map +1 -0
- package/dist/{chunk-ECFXGXWO.cjs → chunk-VSM3NLUX.cjs} +312 -210
- package/dist/chunk-VSM3NLUX.cjs.map +1 -0
- package/dist/{chunk-IQO7ANVS.cjs → chunk-VZC4BWWH.cjs} +10 -9
- package/dist/chunk-VZC4BWWH.cjs.map +1 -0
- package/dist/{chunk-JV2KH24V.js → chunk-W3DD3XP5.js} +312 -210
- package/dist/chunk-W3DD3XP5.js.map +1 -0
- package/dist/{chunk-GGYKYORQ.cjs → chunk-WQSGX6XA.cjs} +27 -6
- package/dist/chunk-WQSGX6XA.cjs.map +1 -0
- package/dist/{chunk-W7UH2PWL.js → chunk-WTYNK7Q4.js} +179 -282
- package/dist/chunk-WTYNK7Q4.js.map +1 -0
- package/dist/{chunk-7CBEP2ZQ.js → chunk-XXBWX7DT.js} +949 -197
- package/dist/chunk-XXBWX7DT.js.map +1 -0
- package/dist/{chunk-CB575O6L.cjs → chunk-ZCVTH3CH.cjs} +470 -130
- package/dist/chunk-ZCVTH3CH.cjs.map +1 -0
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/index.cjs +4 -4
- package/dist/evals/index.js +1 -1
- package/dist/evals/scoreTraces/index.cjs +5 -4
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +3 -2
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.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 +26 -10
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +5 -1
- package/dist/llm/model/aisdk/v5/model.d.ts +47 -0
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -0
- package/dist/llm/model/gateways/base.d.ts +8 -0
- package/dist/llm/model/gateways/base.d.ts.map +1 -1
- package/dist/llm/model/gateways/models-dev.d.ts +1 -0
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/gateways/netlify.d.ts +2 -1
- package/dist/llm/model/gateways/netlify.d.ts.map +1 -1
- package/dist/llm/model/is-v2-model.d.ts +3 -0
- package/dist/llm/model/is-v2-model.d.ts.map +1 -0
- package/dist/llm/model/model-method-from-agent.d.ts +4 -0
- package/dist/llm/model/model-method-from-agent.d.ts.map +1 -0
- package/dist/llm/model/model.loop.d.ts +2 -2
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +2 -0
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-registry.d.ts +11 -1
- package/dist/llm/model/provider-registry.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +56 -7
- package/dist/llm/model/registry-generator.d.ts.map +1 -1
- package/dist/llm/model/resolve-model.d.ts +1 -1
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/llm/model/router.d.ts +12 -5
- package/dist/llm/model/router.d.ts.map +1 -1
- package/dist/llm/model/shared.types.d.ts +10 -4
- 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.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +37 -0
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -0
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/generateText.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -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/textStream.d.ts.map +1 -1
- package/dist/loop/test-utils/toUIMessageStream.d.ts.map +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/test-utils/utils.d.ts +1 -1
- package/dist/loop/test-utils/utils.d.ts.map +1 -1
- package/dist/loop/types.d.ts +8 -3
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +12 -12
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +9 -9
- 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 +4 -4
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +13 -12
- 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 +4 -4
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +127 -3
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +8 -8
- package/dist/memory/index.js +4 -4
- package/dist/models-dev-6PRLJKVZ.js +3 -0
- package/dist/{models-dev-DNBKXHT4.js.map → models-dev-6PRLJKVZ.js.map} +1 -1
- package/dist/models-dev-WHMI5G6Y.cjs +12 -0
- package/dist/{models-dev-YBEEQIX6.cjs.map → models-dev-WHMI5G6Y.cjs.map} +1 -1
- package/dist/netlify-46I3SNNV.cjs +12 -0
- package/dist/{netlify-GWNGSIRZ.cjs.map → netlify-46I3SNNV.cjs.map} +1 -1
- package/dist/netlify-EBQ6YUC6.js +3 -0
- package/dist/{netlify-7G2L5VSH.js.map → netlify-EBQ6YUC6.js.map} +1 -1
- package/dist/processors/index.cjs +11 -11
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-HDG6UMUC.js +3 -0
- package/dist/provider-registry-HDG6UMUC.js.map +1 -0
- package/dist/provider-registry-RP2W4B24.cjs +40 -0
- package/dist/provider-registry-RP2W4B24.cjs.map +1 -0
- package/dist/provider-registry.json +140 -18
- package/dist/{registry-generator-MK63POJO.cjs → registry-generator-JPCV47SC.cjs} +6 -4
- package/dist/registry-generator-JPCV47SC.cjs.map +1 -0
- package/dist/{registry-generator-H4YNODDH.js → registry-generator-XD4FPZTU.js} +6 -4
- package/dist/registry-generator-XD4FPZTU.js.map +1 -0
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +1 -1
- package/dist/server/auth.d.ts +11 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/index.cjs +12 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +12 -1
- package/dist/server/index.js.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +29 -29
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +2 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts +1 -1
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +6 -3
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/base/input.d.ts +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +4 -3
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +68 -31
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.d.ts +4 -2
- package/dist/test-utils/llm-mock.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.js +67 -30
- package/dist/test-utils/llm-mock.js.map +1 -1
- 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/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +1 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +12 -0
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils.cjs +25 -21
- package/dist/utils.d.ts +4 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/voice/aisdk/index.d.ts +3 -0
- package/dist/voice/aisdk/index.d.ts.map +1 -0
- package/dist/voice/aisdk/speech.d.ts +23 -0
- package/dist/voice/aisdk/speech.d.ts.map +1 -0
- package/dist/voice/aisdk/transcription.d.ts +22 -0
- package/dist/voice/aisdk/transcription.d.ts.map +1 -0
- package/dist/voice/composite-voice.d.ts +4 -3
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +12 -4
- package/dist/voice/index.d.ts +1 -0
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +24 -8
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +3 -1
- 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/workflow-event-processor/index.d.ts +5 -4
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts +1 -1
- 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 +2 -1
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +4 -2
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/index.cjs +28 -16
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +1 -0
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +54 -2
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +20 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +108 -40
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +19 -27
- package/src/llm/model/provider-types.generated.d.ts +56 -7
- package/dist/chunk-22443P6A.cjs.map +0 -1
- package/dist/chunk-2ZVKF4HP.cjs.map +0 -1
- package/dist/chunk-4CDL2QJT.js.map +0 -1
- package/dist/chunk-7AHYOMHJ.js.map +0 -1
- package/dist/chunk-7CBEP2ZQ.js.map +0 -1
- package/dist/chunk-7PO6SEJF.js.map +0 -1
- package/dist/chunk-CB575O6L.cjs.map +0 -1
- package/dist/chunk-ECFXGXWO.cjs.map +0 -1
- package/dist/chunk-ET6UOTTU.cjs.map +0 -1
- package/dist/chunk-GGYKYORQ.cjs.map +0 -1
- package/dist/chunk-HDJFSJCK.js.map +0 -1
- package/dist/chunk-I4CXL4SR.js.map +0 -1
- package/dist/chunk-IQO7ANVS.cjs.map +0 -1
- package/dist/chunk-JPGVRWWL.js.map +0 -1
- package/dist/chunk-JV2KH24V.js.map +0 -1
- package/dist/chunk-JYYQQEBH.cjs.map +0 -1
- package/dist/chunk-LJFJTTZQ.cjs +0 -4
- package/dist/chunk-LWBQ4P4N.cjs.map +0 -1
- package/dist/chunk-MV7KHWUT.js.map +0 -1
- package/dist/chunk-QUKUN6NR.cjs.map +0 -1
- package/dist/chunk-SNPVZPLB.js.map +0 -1
- package/dist/chunk-UIZSWUKP.js.map +0 -1
- package/dist/chunk-W7UH2PWL.js.map +0 -1
- package/dist/chunk-WM6CK2F3.cjs.map +0 -1
- package/dist/chunk-YCVEJ3UN.cjs.map +0 -1
- package/dist/chunk-ZGHTOYHW.js.map +0 -1
- package/dist/chunk-ZV5CC35D.js +0 -3
- package/dist/chunk-ZWNI5IWX.cjs.map +0 -1
- package/dist/models-dev-DNBKXHT4.js +0 -3
- package/dist/models-dev-YBEEQIX6.cjs +0 -12
- package/dist/netlify-7G2L5VSH.js +0 -3
- package/dist/netlify-GWNGSIRZ.cjs +0 -12
- package/dist/registry-generator-H4YNODDH.js.map +0 -1
- package/dist/registry-generator-MK63POJO.cjs.map +0 -1
|
@@ -520,24 +520,74 @@ function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
|
520
520
|
}
|
|
521
521
|
return "runtime/unknown";
|
|
522
522
|
}
|
|
523
|
-
function
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
523
|
+
function normalizeHeaders(headers) {
|
|
524
|
+
if (headers == null) {
|
|
525
|
+
return {};
|
|
526
|
+
}
|
|
527
|
+
const normalized = {};
|
|
528
|
+
if (headers instanceof Headers) {
|
|
529
|
+
headers.forEach((value, key) => {
|
|
530
|
+
normalized[key.toLowerCase()] = value;
|
|
531
|
+
});
|
|
532
|
+
} else {
|
|
533
|
+
if (!Array.isArray(headers)) {
|
|
534
|
+
headers = Object.entries(headers);
|
|
535
|
+
}
|
|
536
|
+
for (const [key, value] of headers) {
|
|
537
|
+
if (value != null) {
|
|
538
|
+
normalized[key.toLowerCase()] = value;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return normalized;
|
|
527
543
|
}
|
|
528
544
|
function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
529
|
-
const
|
|
530
|
-
headers != null ? headers : {}
|
|
531
|
-
);
|
|
532
|
-
const normalizedHeaders = new Headers(cleanedHeaders);
|
|
545
|
+
const normalizedHeaders = new Headers(normalizeHeaders(headers));
|
|
533
546
|
const currentUserAgentHeader = normalizedHeaders.get("user-agent") || "";
|
|
534
547
|
normalizedHeaders.set(
|
|
535
548
|
"user-agent",
|
|
536
549
|
[currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" ")
|
|
537
550
|
);
|
|
538
|
-
return Object.fromEntries(normalizedHeaders);
|
|
551
|
+
return Object.fromEntries(normalizedHeaders.entries());
|
|
552
|
+
}
|
|
553
|
+
var VERSION = "3.0.17" ;
|
|
554
|
+
var DEFAULT_SCHEMA_PREFIX = "JSON schema:";
|
|
555
|
+
var DEFAULT_SCHEMA_SUFFIX = "You MUST answer with a JSON object that matches the JSON schema above.";
|
|
556
|
+
var DEFAULT_GENERIC_SUFFIX = "You MUST answer with JSON.";
|
|
557
|
+
function injectJsonInstruction({
|
|
558
|
+
prompt,
|
|
559
|
+
schema,
|
|
560
|
+
schemaPrefix = schema != null ? DEFAULT_SCHEMA_PREFIX : void 0,
|
|
561
|
+
schemaSuffix = schema != null ? DEFAULT_SCHEMA_SUFFIX : DEFAULT_GENERIC_SUFFIX
|
|
562
|
+
}) {
|
|
563
|
+
return [
|
|
564
|
+
prompt != null && prompt.length > 0 ? prompt : void 0,
|
|
565
|
+
prompt != null && prompt.length > 0 ? "" : void 0,
|
|
566
|
+
// add a newline if prompt is not null
|
|
567
|
+
schemaPrefix,
|
|
568
|
+
schema != null ? JSON.stringify(schema) : void 0,
|
|
569
|
+
schemaSuffix
|
|
570
|
+
].filter((line) => line != null).join("\n");
|
|
571
|
+
}
|
|
572
|
+
function injectJsonInstructionIntoMessages({
|
|
573
|
+
messages,
|
|
574
|
+
schema,
|
|
575
|
+
schemaPrefix,
|
|
576
|
+
schemaSuffix
|
|
577
|
+
}) {
|
|
578
|
+
var _a15, _b;
|
|
579
|
+
const systemMessage = ((_a15 = messages[0]) == null ? void 0 : _a15.role) === "system" ? { ...messages[0] } : { role: "system", content: "" };
|
|
580
|
+
systemMessage.content = injectJsonInstruction({
|
|
581
|
+
prompt: systemMessage.content,
|
|
582
|
+
schema,
|
|
583
|
+
schemaPrefix,
|
|
584
|
+
schemaSuffix
|
|
585
|
+
});
|
|
586
|
+
return [
|
|
587
|
+
systemMessage,
|
|
588
|
+
...((_b = messages[0]) == null ? void 0 : _b.role) === "system" ? messages.slice(1) : messages
|
|
589
|
+
];
|
|
539
590
|
}
|
|
540
|
-
var VERSION = "3.0.12" ;
|
|
541
591
|
function loadApiKey({
|
|
542
592
|
apiKey,
|
|
543
593
|
environmentVariableName,
|
|
@@ -633,7 +683,11 @@ function filter(obj) {
|
|
|
633
683
|
}
|
|
634
684
|
function secureJsonParse(text) {
|
|
635
685
|
const { stackTraceLimit } = Error;
|
|
636
|
-
|
|
686
|
+
try {
|
|
687
|
+
Error.stackTraceLimit = 0;
|
|
688
|
+
} catch (e) {
|
|
689
|
+
return _parse(text);
|
|
690
|
+
}
|
|
637
691
|
try {
|
|
638
692
|
return _parse(text);
|
|
639
693
|
} finally {
|
|
@@ -3558,7 +3612,7 @@ var OpenAICompatibleImageModel = class {
|
|
|
3558
3612
|
var openaiCompatibleImageResponseSchema = z4.z.object({
|
|
3559
3613
|
data: z4.z.array(z4.z.object({ b64_json: z4.z.string() }))
|
|
3560
3614
|
});
|
|
3561
|
-
var VERSION2 = "1.0.
|
|
3615
|
+
var VERSION2 = "1.0.27" ;
|
|
3562
3616
|
function createOpenAICompatible(options) {
|
|
3563
3617
|
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
3564
3618
|
const providerName = options.name;
|
|
@@ -3604,8 +3658,14 @@ function createOpenAICompatible(options) {
|
|
|
3604
3658
|
|
|
3605
3659
|
// src/llm/model/gateways/base.ts
|
|
3606
3660
|
var MastraModelGateway = class {
|
|
3661
|
+
/**
|
|
3662
|
+
* Get the gateway ID
|
|
3663
|
+
*/
|
|
3664
|
+
getId() {
|
|
3665
|
+
return this.id;
|
|
3666
|
+
}
|
|
3607
3667
|
};
|
|
3608
|
-
var VERSION3 = "2.0.
|
|
3668
|
+
var VERSION3 = "2.0.45" ;
|
|
3609
3669
|
var anthropicErrorDataSchema = lazySchema(
|
|
3610
3670
|
() => zodSchema(
|
|
3611
3671
|
z4.z.object({
|
|
@@ -3807,7 +3867,18 @@ var anthropicMessagesResponseSchema = lazySchema(
|
|
|
3807
3867
|
output_tokens: z4.z.number(),
|
|
3808
3868
|
cache_creation_input_tokens: z4.z.number().nullish(),
|
|
3809
3869
|
cache_read_input_tokens: z4.z.number().nullish()
|
|
3810
|
-
})
|
|
3870
|
+
}),
|
|
3871
|
+
container: z4.z.object({
|
|
3872
|
+
expires_at: z4.z.string(),
|
|
3873
|
+
id: z4.z.string(),
|
|
3874
|
+
skills: z4.z.array(
|
|
3875
|
+
z4.z.object({
|
|
3876
|
+
type: z4.z.union([z4.z.literal("anthropic"), z4.z.literal("custom")]),
|
|
3877
|
+
skill_id: z4.z.string(),
|
|
3878
|
+
version: z4.z.string()
|
|
3879
|
+
})
|
|
3880
|
+
).nullish()
|
|
3881
|
+
}).nullish()
|
|
3811
3882
|
})
|
|
3812
3883
|
)
|
|
3813
3884
|
);
|
|
@@ -4037,7 +4108,21 @@ var anthropicMessagesChunkSchema = lazySchema(
|
|
|
4037
4108
|
type: z4.z.literal("message_delta"),
|
|
4038
4109
|
delta: z4.z.object({
|
|
4039
4110
|
stop_reason: z4.z.string().nullish(),
|
|
4040
|
-
stop_sequence: z4.z.string().nullish()
|
|
4111
|
+
stop_sequence: z4.z.string().nullish(),
|
|
4112
|
+
container: z4.z.object({
|
|
4113
|
+
expires_at: z4.z.string(),
|
|
4114
|
+
id: z4.z.string(),
|
|
4115
|
+
skills: z4.z.array(
|
|
4116
|
+
z4.z.object({
|
|
4117
|
+
type: z4.z.union([
|
|
4118
|
+
z4.z.literal("anthropic"),
|
|
4119
|
+
z4.z.literal("custom")
|
|
4120
|
+
]),
|
|
4121
|
+
skill_id: z4.z.string(),
|
|
4122
|
+
version: z4.z.string()
|
|
4123
|
+
})
|
|
4124
|
+
).nullish()
|
|
4125
|
+
}).nullish()
|
|
4041
4126
|
}),
|
|
4042
4127
|
usage: z4.z.looseObject({
|
|
4043
4128
|
output_tokens: z4.z.number(),
|
|
@@ -5280,6 +5365,21 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5280
5365
|
setting: "seed"
|
|
5281
5366
|
});
|
|
5282
5367
|
}
|
|
5368
|
+
if (temperature != null && temperature > 1) {
|
|
5369
|
+
warnings.push({
|
|
5370
|
+
type: "unsupported-setting",
|
|
5371
|
+
setting: "temperature",
|
|
5372
|
+
details: `${temperature} exceeds anthropic maximum of 1.0. clamped to 1.0`
|
|
5373
|
+
});
|
|
5374
|
+
temperature = 1;
|
|
5375
|
+
} else if (temperature != null && temperature < 0) {
|
|
5376
|
+
warnings.push({
|
|
5377
|
+
type: "unsupported-setting",
|
|
5378
|
+
setting: "temperature",
|
|
5379
|
+
details: `${temperature} is below anthropic minimum of 0. clamped to 0`
|
|
5380
|
+
});
|
|
5381
|
+
temperature = 0;
|
|
5382
|
+
}
|
|
5283
5383
|
if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
|
|
5284
5384
|
if (responseFormat.schema == null) {
|
|
5285
5385
|
warnings.push({
|
|
@@ -5315,7 +5415,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5315
5415
|
});
|
|
5316
5416
|
const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
|
|
5317
5417
|
const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
|
|
5318
|
-
const maxOutputTokensForModel = getMaxOutputTokensForModel(this.modelId);
|
|
5418
|
+
const { maxOutputTokens: maxOutputTokensForModel, knownModel } = getMaxOutputTokensForModel(this.modelId);
|
|
5319
5419
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
5320
5420
|
const baseArgs = {
|
|
5321
5421
|
// model id:
|
|
@@ -5377,7 +5477,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5377
5477
|
}
|
|
5378
5478
|
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
5379
5479
|
}
|
|
5380
|
-
if (baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
5480
|
+
if (knownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
5381
5481
|
if (maxOutputTokens != null) {
|
|
5382
5482
|
warnings.push({
|
|
5383
5483
|
type: "unsupported-setting",
|
|
@@ -5472,7 +5572,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5472
5572
|
});
|
|
5473
5573
|
}
|
|
5474
5574
|
async doGenerate(options) {
|
|
5475
|
-
var _a15, _b, _c, _d, _e, _f;
|
|
5575
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h;
|
|
5476
5576
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
5477
5577
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
5478
5578
|
const {
|
|
@@ -5723,7 +5823,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5723
5823
|
anthropic: {
|
|
5724
5824
|
usage: response.usage,
|
|
5725
5825
|
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
|
|
5726
|
-
stopSequence: (_f = response.stop_sequence) != null ? _f : null
|
|
5826
|
+
stopSequence: (_f = response.stop_sequence) != null ? _f : null,
|
|
5827
|
+
container: response.container ? {
|
|
5828
|
+
expiresAt: response.container.expires_at,
|
|
5829
|
+
id: response.container.id,
|
|
5830
|
+
skills: (_h = (_g = response.container.skills) == null ? void 0 : _g.map((skill) => ({
|
|
5831
|
+
type: skill.type,
|
|
5832
|
+
skillId: skill.skill_id,
|
|
5833
|
+
version: skill.version
|
|
5834
|
+
}))) != null ? _h : null
|
|
5835
|
+
} : null
|
|
5727
5836
|
}
|
|
5728
5837
|
}
|
|
5729
5838
|
};
|
|
@@ -5753,6 +5862,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5753
5862
|
let rawUsage = void 0;
|
|
5754
5863
|
let cacheCreationInputTokens = null;
|
|
5755
5864
|
let stopSequence = null;
|
|
5865
|
+
let container = null;
|
|
5756
5866
|
let blockType = void 0;
|
|
5757
5867
|
const generateId3 = this.generateId;
|
|
5758
5868
|
return {
|
|
@@ -5762,7 +5872,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5762
5872
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5763
5873
|
},
|
|
5764
5874
|
transform(chunk, controller) {
|
|
5765
|
-
var _a15, _b, _c, _d, _e, _f, _g, _h;
|
|
5875
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5766
5876
|
if (options.includeRawChunks) {
|
|
5767
5877
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5768
5878
|
}
|
|
@@ -5875,7 +5985,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5875
5985
|
data: part.content.content.source.data
|
|
5876
5986
|
}
|
|
5877
5987
|
}
|
|
5878
|
-
}
|
|
5988
|
+
},
|
|
5989
|
+
providerExecuted: true
|
|
5879
5990
|
});
|
|
5880
5991
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
5881
5992
|
controller.enqueue({
|
|
@@ -6143,6 +6254,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
6143
6254
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
6144
6255
|
});
|
|
6145
6256
|
stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
|
|
6257
|
+
container = value.delta.container != null ? {
|
|
6258
|
+
expiresAt: value.delta.container.expires_at,
|
|
6259
|
+
id: value.delta.container.id,
|
|
6260
|
+
skills: (_j = (_i = value.delta.container.skills) == null ? void 0 : _i.map((skill) => ({
|
|
6261
|
+
type: skill.type,
|
|
6262
|
+
skillId: skill.skill_id,
|
|
6263
|
+
version: skill.version
|
|
6264
|
+
}))) != null ? _j : null
|
|
6265
|
+
} : null;
|
|
6146
6266
|
rawUsage = {
|
|
6147
6267
|
...rawUsage,
|
|
6148
6268
|
...value.usage
|
|
@@ -6158,7 +6278,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
6158
6278
|
anthropic: {
|
|
6159
6279
|
usage: rawUsage != null ? rawUsage : null,
|
|
6160
6280
|
cacheCreationInputTokens,
|
|
6161
|
-
stopSequence
|
|
6281
|
+
stopSequence,
|
|
6282
|
+
container
|
|
6162
6283
|
}
|
|
6163
6284
|
}
|
|
6164
6285
|
});
|
|
@@ -6183,13 +6304,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
6183
6304
|
};
|
|
6184
6305
|
function getMaxOutputTokensForModel(modelId) {
|
|
6185
6306
|
if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
|
|
6186
|
-
return 64e3;
|
|
6307
|
+
return { maxOutputTokens: 64e3, knownModel: true };
|
|
6187
6308
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
6188
|
-
return 32e3;
|
|
6309
|
+
return { maxOutputTokens: 32e3, knownModel: true };
|
|
6189
6310
|
} else if (modelId.includes("claude-3-5-haiku")) {
|
|
6190
|
-
return 8192;
|
|
6311
|
+
return { maxOutputTokens: 8192, knownModel: true };
|
|
6312
|
+
} else if (modelId.includes("claude-3-haiku")) {
|
|
6313
|
+
return { maxOutputTokens: 4096, knownModel: true };
|
|
6191
6314
|
} else {
|
|
6192
|
-
return 4096;
|
|
6315
|
+
return { maxOutputTokens: 4096, knownModel: false };
|
|
6193
6316
|
}
|
|
6194
6317
|
}
|
|
6195
6318
|
var bash_20241022InputSchema = lazySchema(
|
|
@@ -6525,8 +6648,14 @@ var anthropicTools = {
|
|
|
6525
6648
|
webSearch_20250305
|
|
6526
6649
|
};
|
|
6527
6650
|
function createAnthropic(options = {}) {
|
|
6528
|
-
var _a15;
|
|
6529
|
-
const baseURL = (_a15 = withoutTrailingSlash(
|
|
6651
|
+
var _a15, _b;
|
|
6652
|
+
const baseURL = (_a15 = withoutTrailingSlash(
|
|
6653
|
+
loadOptionalSetting({
|
|
6654
|
+
settingValue: options.baseURL,
|
|
6655
|
+
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
6656
|
+
})
|
|
6657
|
+
)) != null ? _a15 : "https://api.anthropic.com/v1";
|
|
6658
|
+
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
6530
6659
|
const getHeaders = () => withUserAgentSuffix(
|
|
6531
6660
|
{
|
|
6532
6661
|
"anthropic-version": "2023-06-01",
|
|
@@ -6542,7 +6671,7 @@ function createAnthropic(options = {}) {
|
|
|
6542
6671
|
const createChatModel = (modelId) => {
|
|
6543
6672
|
var _a22;
|
|
6544
6673
|
return new AnthropicMessagesLanguageModel(modelId, {
|
|
6545
|
-
provider:
|
|
6674
|
+
provider: providerName,
|
|
6546
6675
|
baseURL,
|
|
6547
6676
|
headers: getHeaders,
|
|
6548
6677
|
fetch: options.fetch,
|
|
@@ -6573,7 +6702,7 @@ function createAnthropic(options = {}) {
|
|
|
6573
6702
|
return provider;
|
|
6574
6703
|
}
|
|
6575
6704
|
createAnthropic();
|
|
6576
|
-
var VERSION4 = "2.0.
|
|
6705
|
+
var VERSION4 = "2.0.39" ;
|
|
6577
6706
|
var googleErrorDataSchema = lazySchema(
|
|
6578
6707
|
() => zodSchema(
|
|
6579
6708
|
z4.z.object({
|
|
@@ -6873,19 +7002,20 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
6873
7002
|
contents.push({
|
|
6874
7003
|
role: "model",
|
|
6875
7004
|
parts: content.map((part) => {
|
|
6876
|
-
var _a22, _b, _c
|
|
7005
|
+
var _a22, _b, _c;
|
|
7006
|
+
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;
|
|
6877
7007
|
switch (part.type) {
|
|
6878
7008
|
case "text": {
|
|
6879
7009
|
return part.text.length === 0 ? void 0 : {
|
|
6880
7010
|
text: part.text,
|
|
6881
|
-
thoughtSignature
|
|
7011
|
+
thoughtSignature
|
|
6882
7012
|
};
|
|
6883
7013
|
}
|
|
6884
7014
|
case "reasoning": {
|
|
6885
7015
|
return part.text.length === 0 ? void 0 : {
|
|
6886
7016
|
text: part.text,
|
|
6887
7017
|
thought: true,
|
|
6888
|
-
thoughtSignature
|
|
7018
|
+
thoughtSignature
|
|
6889
7019
|
};
|
|
6890
7020
|
}
|
|
6891
7021
|
case "file": {
|
|
@@ -6912,7 +7042,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
6912
7042
|
name: part.toolName,
|
|
6913
7043
|
args: part.input
|
|
6914
7044
|
},
|
|
6915
|
-
thoughtSignature
|
|
7045
|
+
thoughtSignature
|
|
6916
7046
|
};
|
|
6917
7047
|
}
|
|
6918
7048
|
}
|
|
@@ -6995,7 +7125,9 @@ var googleGenerativeAIProviderOptions = lazySchema(
|
|
|
6995
7125
|
responseModalities: z4.z.array(z4.z.enum(["TEXT", "IMAGE"])).optional(),
|
|
6996
7126
|
thinkingConfig: z4.z.object({
|
|
6997
7127
|
thinkingBudget: z4.z.number().optional(),
|
|
6998
|
-
includeThoughts: z4.z.boolean().optional()
|
|
7128
|
+
includeThoughts: z4.z.boolean().optional(),
|
|
7129
|
+
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
7130
|
+
thinkingLevel: z4.z.enum(["low", "medium", "high"]).optional()
|
|
6999
7131
|
}).optional(),
|
|
7000
7132
|
/**
|
|
7001
7133
|
* Optional.
|
|
@@ -7096,8 +7228,14 @@ function prepareTools3({
|
|
|
7096
7228
|
var _a15;
|
|
7097
7229
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
7098
7230
|
const toolWarnings = [];
|
|
7099
|
-
const
|
|
7231
|
+
const isLatest = [
|
|
7232
|
+
"gemini-flash-latest",
|
|
7233
|
+
"gemini-flash-lite-latest",
|
|
7234
|
+
"gemini-pro-latest"
|
|
7235
|
+
].some((id) => id === modelId);
|
|
7236
|
+
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
|
|
7100
7237
|
const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
|
|
7238
|
+
const supportsFileSearch = modelId.includes("gemini-2.5");
|
|
7101
7239
|
if (tools == null) {
|
|
7102
7240
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
|
7103
7241
|
}
|
|
@@ -7106,10 +7244,11 @@ function prepareTools3({
|
|
|
7106
7244
|
(tool2) => tool2.type === "provider-defined"
|
|
7107
7245
|
);
|
|
7108
7246
|
if (hasFunctionTools && hasProviderDefinedTools) {
|
|
7247
|
+
const functionTools = tools.filter((tool2) => tool2.type === "function");
|
|
7109
7248
|
toolWarnings.push({
|
|
7110
7249
|
type: "unsupported-tool",
|
|
7111
7250
|
tool: tools.find((tool2) => tool2.type === "function"),
|
|
7112
|
-
details:
|
|
7251
|
+
details: `Cannot mix function tools with provider-defined tools in the same request. Falling back to provider-defined tools only. The following function tools will be ignored: ${functionTools.map((t) => t.name).join(", ")}. Please use either function tools or provider-defined tools, but not both.`
|
|
7113
7252
|
});
|
|
7114
7253
|
}
|
|
7115
7254
|
if (hasProviderDefinedTools) {
|
|
@@ -7120,7 +7259,7 @@ function prepareTools3({
|
|
|
7120
7259
|
providerDefinedTools.forEach((tool2) => {
|
|
7121
7260
|
switch (tool2.id) {
|
|
7122
7261
|
case "google.google_search":
|
|
7123
|
-
if (
|
|
7262
|
+
if (isGemini2orNewer) {
|
|
7124
7263
|
googleTools2.push({ googleSearch: {} });
|
|
7125
7264
|
} else if (supportsDynamicRetrieval) {
|
|
7126
7265
|
googleTools2.push({
|
|
@@ -7136,7 +7275,7 @@ function prepareTools3({
|
|
|
7136
7275
|
}
|
|
7137
7276
|
break;
|
|
7138
7277
|
case "google.url_context":
|
|
7139
|
-
if (
|
|
7278
|
+
if (isGemini2orNewer) {
|
|
7140
7279
|
googleTools2.push({ urlContext: {} });
|
|
7141
7280
|
} else {
|
|
7142
7281
|
toolWarnings.push({
|
|
@@ -7147,7 +7286,7 @@ function prepareTools3({
|
|
|
7147
7286
|
}
|
|
7148
7287
|
break;
|
|
7149
7288
|
case "google.code_execution":
|
|
7150
|
-
if (
|
|
7289
|
+
if (isGemini2orNewer) {
|
|
7151
7290
|
googleTools2.push({ codeExecution: {} });
|
|
7152
7291
|
} else {
|
|
7153
7292
|
toolWarnings.push({
|
|
@@ -7157,6 +7296,37 @@ function prepareTools3({
|
|
|
7157
7296
|
});
|
|
7158
7297
|
}
|
|
7159
7298
|
break;
|
|
7299
|
+
case "google.file_search":
|
|
7300
|
+
if (supportsFileSearch) {
|
|
7301
|
+
googleTools2.push({ fileSearch: { ...tool2.args } });
|
|
7302
|
+
} else {
|
|
7303
|
+
toolWarnings.push({
|
|
7304
|
+
type: "unsupported-tool",
|
|
7305
|
+
tool: tool2,
|
|
7306
|
+
details: "The file search tool is only supported with Gemini 2.5 models."
|
|
7307
|
+
});
|
|
7308
|
+
}
|
|
7309
|
+
break;
|
|
7310
|
+
case "google.vertex_rag_store":
|
|
7311
|
+
if (isGemini2orNewer) {
|
|
7312
|
+
googleTools2.push({
|
|
7313
|
+
retrieval: {
|
|
7314
|
+
vertex_rag_store: {
|
|
7315
|
+
rag_resources: {
|
|
7316
|
+
rag_corpus: tool2.args.ragCorpus
|
|
7317
|
+
},
|
|
7318
|
+
similarity_top_k: tool2.args.topK
|
|
7319
|
+
}
|
|
7320
|
+
}
|
|
7321
|
+
});
|
|
7322
|
+
} else {
|
|
7323
|
+
toolWarnings.push({
|
|
7324
|
+
type: "unsupported-tool",
|
|
7325
|
+
tool: tool2,
|
|
7326
|
+
details: "The RAG store tool is not supported with other Gemini models than Gemini 2."
|
|
7327
|
+
});
|
|
7328
|
+
}
|
|
7329
|
+
break;
|
|
7160
7330
|
default:
|
|
7161
7331
|
toolWarnings.push({ type: "unsupported-tool", tool: tool2 });
|
|
7162
7332
|
break;
|
|
@@ -7284,17 +7454,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7284
7454
|
toolChoice,
|
|
7285
7455
|
providerOptions
|
|
7286
7456
|
}) {
|
|
7287
|
-
var _a15
|
|
7457
|
+
var _a15;
|
|
7288
7458
|
const warnings = [];
|
|
7289
7459
|
const googleOptions = await parseProviderOptions({
|
|
7290
7460
|
provider: "google",
|
|
7291
7461
|
providerOptions,
|
|
7292
7462
|
schema: googleGenerativeAIProviderOptions
|
|
7293
7463
|
});
|
|
7294
|
-
if ((
|
|
7464
|
+
if ((tools == null ? void 0 : tools.some(
|
|
7465
|
+
(tool2) => tool2.type === "provider-defined" && tool2.id === "google.vertex_rag_store"
|
|
7466
|
+
)) && !this.config.provider.startsWith("google.vertex.")) {
|
|
7295
7467
|
warnings.push({
|
|
7296
7468
|
type: "other",
|
|
7297
|
-
message: `The '
|
|
7469
|
+
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
|
|
7298
7470
|
});
|
|
7299
7471
|
}
|
|
7300
7472
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
@@ -7328,7 +7500,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
7328
7500
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
7329
7501
|
// so this is needed as an escape hatch:
|
|
7330
7502
|
// TODO convert into provider option
|
|
7331
|
-
((
|
|
7503
|
+
((_a15 = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a15 : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
7332
7504
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
7333
7505
|
audioTimestamp: googleOptions.audioTimestamp
|
|
7334
7506
|
},
|
|
@@ -7740,16 +7912,64 @@ function extractSources({
|
|
|
7740
7912
|
groundingMetadata,
|
|
7741
7913
|
generateId: generateId3
|
|
7742
7914
|
}) {
|
|
7743
|
-
var _a15;
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7915
|
+
var _a15, _b, _c;
|
|
7916
|
+
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
7917
|
+
return void 0;
|
|
7918
|
+
}
|
|
7919
|
+
const sources = [];
|
|
7920
|
+
for (const chunk of groundingMetadata.groundingChunks) {
|
|
7921
|
+
if (chunk.web != null) {
|
|
7922
|
+
sources.push({
|
|
7923
|
+
type: "source",
|
|
7924
|
+
sourceType: "url",
|
|
7925
|
+
id: generateId3(),
|
|
7926
|
+
url: chunk.web.uri,
|
|
7927
|
+
title: (_a15 = chunk.web.title) != null ? _a15 : void 0
|
|
7928
|
+
});
|
|
7929
|
+
} else if (chunk.retrievedContext != null) {
|
|
7930
|
+
const uri = chunk.retrievedContext.uri;
|
|
7931
|
+
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
7932
|
+
sources.push({
|
|
7933
|
+
type: "source",
|
|
7934
|
+
sourceType: "url",
|
|
7935
|
+
id: generateId3(),
|
|
7936
|
+
url: uri,
|
|
7937
|
+
title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
|
|
7938
|
+
});
|
|
7939
|
+
} else {
|
|
7940
|
+
const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
|
|
7941
|
+
let mediaType = "application/octet-stream";
|
|
7942
|
+
let filename = void 0;
|
|
7943
|
+
if (uri.endsWith(".pdf")) {
|
|
7944
|
+
mediaType = "application/pdf";
|
|
7945
|
+
filename = uri.split("/").pop();
|
|
7946
|
+
} else if (uri.endsWith(".txt")) {
|
|
7947
|
+
mediaType = "text/plain";
|
|
7948
|
+
filename = uri.split("/").pop();
|
|
7949
|
+
} else if (uri.endsWith(".docx")) {
|
|
7950
|
+
mediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
7951
|
+
filename = uri.split("/").pop();
|
|
7952
|
+
} else if (uri.endsWith(".doc")) {
|
|
7953
|
+
mediaType = "application/msword";
|
|
7954
|
+
filename = uri.split("/").pop();
|
|
7955
|
+
} else if (uri.match(/\.(md|markdown)$/)) {
|
|
7956
|
+
mediaType = "text/markdown";
|
|
7957
|
+
filename = uri.split("/").pop();
|
|
7958
|
+
} else {
|
|
7959
|
+
filename = uri.split("/").pop();
|
|
7960
|
+
}
|
|
7961
|
+
sources.push({
|
|
7962
|
+
type: "source",
|
|
7963
|
+
sourceType: "document",
|
|
7964
|
+
id: generateId3(),
|
|
7965
|
+
mediaType,
|
|
7966
|
+
title,
|
|
7967
|
+
filename
|
|
7968
|
+
});
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
}
|
|
7972
|
+
return sources.length > 0 ? sources : void 0;
|
|
7753
7973
|
}
|
|
7754
7974
|
var getGroundingMetadataSchema = () => z4.z.object({
|
|
7755
7975
|
webSearchQueries: z4.z.array(z4.z.string()).nullish(),
|
|
@@ -7757,8 +7977,12 @@ var getGroundingMetadataSchema = () => z4.z.object({
|
|
|
7757
7977
|
searchEntryPoint: z4.z.object({ renderedContent: z4.z.string() }).nullish(),
|
|
7758
7978
|
groundingChunks: z4.z.array(
|
|
7759
7979
|
z4.z.object({
|
|
7760
|
-
web: z4.z.object({ uri: z4.z.string(), title: z4.z.string() }).nullish(),
|
|
7761
|
-
retrievedContext: z4.z.object({
|
|
7980
|
+
web: z4.z.object({ uri: z4.z.string(), title: z4.z.string().nullish() }).nullish(),
|
|
7981
|
+
retrievedContext: z4.z.object({
|
|
7982
|
+
uri: z4.z.string(),
|
|
7983
|
+
title: z4.z.string().nullish(),
|
|
7984
|
+
text: z4.z.string().nullish()
|
|
7985
|
+
}).nullish()
|
|
7762
7986
|
})
|
|
7763
7987
|
).nullish(),
|
|
7764
7988
|
groundingSupports: z4.z.array(
|
|
@@ -7828,7 +8052,9 @@ var usageSchema2 = z4.z.object({
|
|
|
7828
8052
|
thoughtsTokenCount: z4.z.number().nullish(),
|
|
7829
8053
|
promptTokenCount: z4.z.number().nullish(),
|
|
7830
8054
|
candidatesTokenCount: z4.z.number().nullish(),
|
|
7831
|
-
totalTokenCount: z4.z.number().nullish()
|
|
8055
|
+
totalTokenCount: z4.z.number().nullish(),
|
|
8056
|
+
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
8057
|
+
trafficType: z4.z.string().nullish()
|
|
7832
8058
|
});
|
|
7833
8059
|
var getUrlContextMetadataSchema = () => z4.z.object({
|
|
7834
8060
|
urlMetadata: z4.z.array(
|
|
@@ -7890,6 +8116,30 @@ var codeExecution = createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
7890
8116
|
output: z4.z.string().describe("The output from the code execution.")
|
|
7891
8117
|
})
|
|
7892
8118
|
});
|
|
8119
|
+
var fileSearchArgsBaseSchema = z4.z.object({
|
|
8120
|
+
/** The names of the file_search_stores to retrieve from.
|
|
8121
|
+
* Example: `fileSearchStores/my-file-search-store-123`
|
|
8122
|
+
*/
|
|
8123
|
+
fileSearchStoreNames: z4.z.array(z4.z.string()).describe(
|
|
8124
|
+
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
8125
|
+
),
|
|
8126
|
+
/** The number of file search retrieval chunks to retrieve. */
|
|
8127
|
+
topK: z4.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
8128
|
+
/** Metadata filter to apply to the file search retrieval documents.
|
|
8129
|
+
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
8130
|
+
*/
|
|
8131
|
+
metadataFilter: z4.z.string().describe(
|
|
8132
|
+
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
8133
|
+
).optional()
|
|
8134
|
+
}).passthrough();
|
|
8135
|
+
var fileSearchArgsSchema = lazySchema(
|
|
8136
|
+
() => zodSchema(fileSearchArgsBaseSchema)
|
|
8137
|
+
);
|
|
8138
|
+
var fileSearch = createProviderDefinedToolFactory({
|
|
8139
|
+
id: "google.file_search",
|
|
8140
|
+
name: "file_search",
|
|
8141
|
+
inputSchema: fileSearchArgsSchema
|
|
8142
|
+
});
|
|
7893
8143
|
var googleSearch = createProviderDefinedToolFactory({
|
|
7894
8144
|
id: "google.google_search",
|
|
7895
8145
|
name: "google_search",
|
|
@@ -7907,6 +8157,14 @@ var urlContext = createProviderDefinedToolFactory({
|
|
|
7907
8157
|
name: "url_context",
|
|
7908
8158
|
inputSchema: lazySchema(() => zodSchema(z4.z.object({})))
|
|
7909
8159
|
});
|
|
8160
|
+
var vertexRagStore = createProviderDefinedToolFactory({
|
|
8161
|
+
id: "google.vertex_rag_store",
|
|
8162
|
+
name: "vertex_rag_store",
|
|
8163
|
+
inputSchema: z4.z.object({
|
|
8164
|
+
ragCorpus: z4.z.string(),
|
|
8165
|
+
topK: z4.z.number().optional()
|
|
8166
|
+
})
|
|
8167
|
+
});
|
|
7910
8168
|
var googleTools = {
|
|
7911
8169
|
/**
|
|
7912
8170
|
* Creates a Google search tool that gives Google direct access to real-time web content.
|
|
@@ -7918,6 +8176,17 @@ var googleTools = {
|
|
|
7918
8176
|
* Must have name "url_context".
|
|
7919
8177
|
*/
|
|
7920
8178
|
urlContext,
|
|
8179
|
+
/**
|
|
8180
|
+
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
8181
|
+
* Must have name "file_search".
|
|
8182
|
+
*
|
|
8183
|
+
* @param fileSearchStoreNames - Fully-qualified File Search store resource names.
|
|
8184
|
+
* @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
|
|
8185
|
+
* @param topK - Optional result limit for the number of chunks returned from File Search.
|
|
8186
|
+
*
|
|
8187
|
+
* @see https://ai.google.dev/gemini-api/docs/file-search
|
|
8188
|
+
*/
|
|
8189
|
+
fileSearch,
|
|
7921
8190
|
/**
|
|
7922
8191
|
* A tool that enables the model to generate and run Python code.
|
|
7923
8192
|
* Must have name "code_execution".
|
|
@@ -7928,7 +8197,12 @@ var googleTools = {
|
|
|
7928
8197
|
* @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
|
|
7929
8198
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
|
|
7930
8199
|
*/
|
|
7931
|
-
codeExecution
|
|
8200
|
+
codeExecution,
|
|
8201
|
+
/**
|
|
8202
|
+
* Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
|
|
8203
|
+
* Must have name "vertex_rag_store".
|
|
8204
|
+
*/
|
|
8205
|
+
vertexRagStore
|
|
7932
8206
|
};
|
|
7933
8207
|
var GoogleGenerativeAIImageModel = class {
|
|
7934
8208
|
constructor(modelId, settings, config) {
|
|
@@ -8037,8 +8311,9 @@ var googleImageProviderOptionsSchema = lazySchema(
|
|
|
8037
8311
|
)
|
|
8038
8312
|
);
|
|
8039
8313
|
function createGoogleGenerativeAI(options = {}) {
|
|
8040
|
-
var _a15;
|
|
8314
|
+
var _a15, _b;
|
|
8041
8315
|
const baseURL = (_a15 = withoutTrailingSlash(options.baseURL)) != null ? _a15 : "https://generativelanguage.googleapis.com/v1beta";
|
|
8316
|
+
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
8042
8317
|
const getHeaders = () => withUserAgentSuffix(
|
|
8043
8318
|
{
|
|
8044
8319
|
"x-goog-api-key": loadApiKey({
|
|
@@ -8053,7 +8328,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
8053
8328
|
const createChatModel = (modelId) => {
|
|
8054
8329
|
var _a22;
|
|
8055
8330
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
|
8056
|
-
provider:
|
|
8331
|
+
provider: providerName,
|
|
8057
8332
|
baseURL,
|
|
8058
8333
|
headers: getHeaders,
|
|
8059
8334
|
generateId: (_a22 = options.generateId) != null ? _a22 : generateId,
|
|
@@ -8073,13 +8348,13 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
8073
8348
|
});
|
|
8074
8349
|
};
|
|
8075
8350
|
const createEmbeddingModel = (modelId) => new GoogleGenerativeAIEmbeddingModel(modelId, {
|
|
8076
|
-
provider:
|
|
8351
|
+
provider: providerName,
|
|
8077
8352
|
baseURL,
|
|
8078
8353
|
headers: getHeaders,
|
|
8079
8354
|
fetch: options.fetch
|
|
8080
8355
|
});
|
|
8081
8356
|
const createImageModel = (modelId, settings = {}) => new GoogleGenerativeAIImageModel(modelId, settings, {
|
|
8082
|
-
provider:
|
|
8357
|
+
provider: providerName,
|
|
8083
8358
|
baseURL,
|
|
8084
8359
|
headers: getHeaders,
|
|
8085
8360
|
fetch: options.fetch
|
|
@@ -8301,7 +8576,7 @@ function getResponseMetadata3({
|
|
|
8301
8576
|
return {
|
|
8302
8577
|
id: id != null ? id : void 0,
|
|
8303
8578
|
modelId: model != null ? model : void 0,
|
|
8304
|
-
timestamp: created
|
|
8579
|
+
timestamp: created ? new Date(created * 1e3) : void 0
|
|
8305
8580
|
};
|
|
8306
8581
|
}
|
|
8307
8582
|
function mapOpenAIFinishReason(finishReason) {
|
|
@@ -8485,7 +8760,7 @@ var openaiChatLanguageModelOptions = lazyValidator(
|
|
|
8485
8760
|
/**
|
|
8486
8761
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
8487
8762
|
*/
|
|
8488
|
-
reasoningEffort: z4.z.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
8763
|
+
reasoningEffort: z4.z.enum(["none", "minimal", "low", "medium", "high"]).optional(),
|
|
8489
8764
|
/**
|
|
8490
8765
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
8491
8766
|
*/
|
|
@@ -8535,6 +8810,15 @@ var openaiChatLanguageModelOptions = lazyValidator(
|
|
|
8535
8810
|
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
8536
8811
|
*/
|
|
8537
8812
|
promptCacheKey: z4.z.string().optional(),
|
|
8813
|
+
/**
|
|
8814
|
+
* The retention policy for the prompt cache.
|
|
8815
|
+
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
8816
|
+
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
8817
|
+
* Currently only available for 5.1 series models.
|
|
8818
|
+
*
|
|
8819
|
+
* @default 'in_memory'
|
|
8820
|
+
*/
|
|
8821
|
+
promptCacheRetention: z4.z.enum(["in_memory", "24h"]).optional(),
|
|
8538
8822
|
/**
|
|
8539
8823
|
* A stable identifier used to help detect users of your application
|
|
8540
8824
|
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
@@ -8696,6 +8980,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8696
8980
|
reasoning_effort: openaiOptions.reasoningEffort,
|
|
8697
8981
|
service_tier: openaiOptions.serviceTier,
|
|
8698
8982
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
8983
|
+
prompt_cache_retention: openaiOptions.promptCacheRetention,
|
|
8699
8984
|
safety_identifier: openaiOptions.safetyIdentifier,
|
|
8700
8985
|
// messages:
|
|
8701
8986
|
messages
|
|
@@ -8911,7 +9196,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8911
9196
|
outputTokens: void 0,
|
|
8912
9197
|
totalTokens: void 0
|
|
8913
9198
|
};
|
|
8914
|
-
let
|
|
9199
|
+
let metadataExtracted = false;
|
|
8915
9200
|
let isActiveText = false;
|
|
8916
9201
|
const providerMetadata = { openai: {} };
|
|
8917
9202
|
return {
|
|
@@ -8936,12 +9221,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
8936
9221
|
controller.enqueue({ type: "error", error: value.error });
|
|
8937
9222
|
return;
|
|
8938
9223
|
}
|
|
8939
|
-
if (
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
9224
|
+
if (!metadataExtracted) {
|
|
9225
|
+
const metadata = getResponseMetadata3(value);
|
|
9226
|
+
if (Object.values(metadata).some(Boolean)) {
|
|
9227
|
+
metadataExtracted = true;
|
|
9228
|
+
controller.enqueue({
|
|
9229
|
+
type: "response-metadata",
|
|
9230
|
+
...getResponseMetadata3(value)
|
|
9231
|
+
});
|
|
9232
|
+
}
|
|
8945
9233
|
}
|
|
8946
9234
|
if (value.usage != null) {
|
|
8947
9235
|
usage.inputTokens = (_a15 = value.usage.prompt_tokens) != null ? _a15 : void 0;
|
|
@@ -9113,18 +9401,6 @@ function getSystemMessageMode(modelId) {
|
|
|
9113
9401
|
return (_b = (_a15 = reasoningModels[modelId]) == null ? void 0 : _a15.systemMessageMode) != null ? _b : "developer";
|
|
9114
9402
|
}
|
|
9115
9403
|
var reasoningModels = {
|
|
9116
|
-
"o1-mini": {
|
|
9117
|
-
systemMessageMode: "remove"
|
|
9118
|
-
},
|
|
9119
|
-
"o1-mini-2024-09-12": {
|
|
9120
|
-
systemMessageMode: "remove"
|
|
9121
|
-
},
|
|
9122
|
-
"o1-preview": {
|
|
9123
|
-
systemMessageMode: "remove"
|
|
9124
|
-
},
|
|
9125
|
-
"o1-preview-2024-09-12": {
|
|
9126
|
-
systemMessageMode: "remove"
|
|
9127
|
-
},
|
|
9128
9404
|
o3: {
|
|
9129
9405
|
systemMessageMode: "developer"
|
|
9130
9406
|
},
|
|
@@ -9660,7 +9936,7 @@ var openaiImageResponseSchema = lazyValidator(
|
|
|
9660
9936
|
data: z4.z.array(
|
|
9661
9937
|
z4.z.object({
|
|
9662
9938
|
b64_json: z4.z.string(),
|
|
9663
|
-
revised_prompt: z4.z.string().
|
|
9939
|
+
revised_prompt: z4.z.string().nullish()
|
|
9664
9940
|
})
|
|
9665
9941
|
)
|
|
9666
9942
|
})
|
|
@@ -9805,7 +10081,7 @@ var compoundFilterSchema = z4.z.object({
|
|
|
9805
10081
|
z4.z.union([comparisonFilterSchema, z4.z.lazy(() => compoundFilterSchema)])
|
|
9806
10082
|
)
|
|
9807
10083
|
});
|
|
9808
|
-
var
|
|
10084
|
+
var fileSearchArgsSchema2 = lazySchema(
|
|
9809
10085
|
() => zodSchema(
|
|
9810
10086
|
z4.z.object({
|
|
9811
10087
|
vectorStoreIds: z4.z.array(z4.z.string()),
|
|
@@ -9834,7 +10110,7 @@ var fileSearchOutputSchema = lazySchema(
|
|
|
9834
10110
|
})
|
|
9835
10111
|
)
|
|
9836
10112
|
);
|
|
9837
|
-
var
|
|
10113
|
+
var fileSearch2 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
9838
10114
|
id: "openai.file_search",
|
|
9839
10115
|
name: "file_search",
|
|
9840
10116
|
inputSchema: z4.z.object({}),
|
|
@@ -9928,7 +10204,13 @@ var webSearchOutputSchema = lazySchema(
|
|
|
9928
10204
|
url: z4.z.string(),
|
|
9929
10205
|
pattern: z4.z.string()
|
|
9930
10206
|
})
|
|
9931
|
-
])
|
|
10207
|
+
]),
|
|
10208
|
+
sources: z4.z.array(
|
|
10209
|
+
z4.z.discriminatedUnion("type", [
|
|
10210
|
+
z4.z.object({ type: z4.z.literal("url"), url: z4.z.string() }),
|
|
10211
|
+
z4.z.object({ type: z4.z.literal("api"), name: z4.z.string() })
|
|
10212
|
+
])
|
|
10213
|
+
).optional()
|
|
9932
10214
|
})
|
|
9933
10215
|
)
|
|
9934
10216
|
);
|
|
@@ -10006,7 +10288,7 @@ var openaiTools = {
|
|
|
10006
10288
|
* @param ranking - The ranking options to use for the file search.
|
|
10007
10289
|
* @param filters - The filters to use for the file search.
|
|
10008
10290
|
*/
|
|
10009
|
-
fileSearch,
|
|
10291
|
+
fileSearch: fileSearch2,
|
|
10010
10292
|
/**
|
|
10011
10293
|
* The image generation tool allows you to generate images using a text prompt,
|
|
10012
10294
|
* and optionally image inputs. It leverages the GPT Image model,
|
|
@@ -10486,7 +10768,13 @@ var openaiResponsesChunkSchema = lazyValidator(
|
|
|
10486
10768
|
action: z4.z.discriminatedUnion("type", [
|
|
10487
10769
|
z4.z.object({
|
|
10488
10770
|
type: z4.z.literal("search"),
|
|
10489
|
-
query: z4.z.string().nullish()
|
|
10771
|
+
query: z4.z.string().nullish(),
|
|
10772
|
+
sources: z4.z.array(
|
|
10773
|
+
z4.z.discriminatedUnion("type", [
|
|
10774
|
+
z4.z.object({ type: z4.z.literal("url"), url: z4.z.string() }),
|
|
10775
|
+
z4.z.object({ type: z4.z.literal("api"), name: z4.z.string() })
|
|
10776
|
+
])
|
|
10777
|
+
).nullish()
|
|
10490
10778
|
}),
|
|
10491
10779
|
z4.z.object({
|
|
10492
10780
|
type: z4.z.literal("open_page"),
|
|
@@ -10594,10 +10882,13 @@ var openaiResponsesChunkSchema = lazyValidator(
|
|
|
10594
10882
|
}),
|
|
10595
10883
|
z4.z.object({
|
|
10596
10884
|
type: z4.z.literal("error"),
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10885
|
+
sequence_number: z4.z.number(),
|
|
10886
|
+
error: z4.z.object({
|
|
10887
|
+
type: z4.z.string(),
|
|
10888
|
+
code: z4.z.string(),
|
|
10889
|
+
message: z4.z.string(),
|
|
10890
|
+
param: z4.z.string().nullish()
|
|
10891
|
+
})
|
|
10601
10892
|
}),
|
|
10602
10893
|
z4.z.object({ type: z4.z.string() }).loose().transform((value) => ({
|
|
10603
10894
|
type: "unknown_chunk",
|
|
@@ -10610,13 +10901,15 @@ var openaiResponsesChunkSchema = lazyValidator(
|
|
|
10610
10901
|
var openaiResponsesResponseSchema = lazyValidator(
|
|
10611
10902
|
() => zodSchema(
|
|
10612
10903
|
z4.z.object({
|
|
10613
|
-
id: z4.z.string(),
|
|
10614
|
-
created_at: z4.z.number(),
|
|
10904
|
+
id: z4.z.string().optional(),
|
|
10905
|
+
created_at: z4.z.number().optional(),
|
|
10615
10906
|
error: z4.z.object({
|
|
10616
|
-
|
|
10617
|
-
|
|
10907
|
+
message: z4.z.string(),
|
|
10908
|
+
type: z4.z.string(),
|
|
10909
|
+
param: z4.z.string().nullish(),
|
|
10910
|
+
code: z4.z.string()
|
|
10618
10911
|
}).nullish(),
|
|
10619
|
-
model: z4.z.string(),
|
|
10912
|
+
model: z4.z.string().optional(),
|
|
10620
10913
|
output: z4.z.array(
|
|
10621
10914
|
z4.z.discriminatedUnion("type", [
|
|
10622
10915
|
z4.z.object({
|
|
@@ -10658,7 +10951,18 @@ var openaiResponsesResponseSchema = lazyValidator(
|
|
|
10658
10951
|
quote: z4.z.string().nullish()
|
|
10659
10952
|
}),
|
|
10660
10953
|
z4.z.object({
|
|
10661
|
-
type: z4.z.literal("container_file_citation")
|
|
10954
|
+
type: z4.z.literal("container_file_citation"),
|
|
10955
|
+
container_id: z4.z.string(),
|
|
10956
|
+
file_id: z4.z.string(),
|
|
10957
|
+
filename: z4.z.string().nullish(),
|
|
10958
|
+
start_index: z4.z.number().nullish(),
|
|
10959
|
+
end_index: z4.z.number().nullish(),
|
|
10960
|
+
index: z4.z.number().nullish()
|
|
10961
|
+
}),
|
|
10962
|
+
z4.z.object({
|
|
10963
|
+
type: z4.z.literal("file_path"),
|
|
10964
|
+
file_id: z4.z.string(),
|
|
10965
|
+
index: z4.z.number().nullish()
|
|
10662
10966
|
})
|
|
10663
10967
|
])
|
|
10664
10968
|
)
|
|
@@ -10672,7 +10976,13 @@ var openaiResponsesResponseSchema = lazyValidator(
|
|
|
10672
10976
|
action: z4.z.discriminatedUnion("type", [
|
|
10673
10977
|
z4.z.object({
|
|
10674
10978
|
type: z4.z.literal("search"),
|
|
10675
|
-
query: z4.z.string().nullish()
|
|
10979
|
+
query: z4.z.string().nullish(),
|
|
10980
|
+
sources: z4.z.array(
|
|
10981
|
+
z4.z.discriminatedUnion("type", [
|
|
10982
|
+
z4.z.object({ type: z4.z.literal("url"), url: z4.z.string() }),
|
|
10983
|
+
z4.z.object({ type: z4.z.literal("api"), name: z4.z.string() })
|
|
10984
|
+
])
|
|
10985
|
+
).nullish()
|
|
10676
10986
|
}),
|
|
10677
10987
|
z4.z.object({
|
|
10678
10988
|
type: z4.z.literal("open_page"),
|
|
@@ -10691,7 +11001,10 @@ var openaiResponsesResponseSchema = lazyValidator(
|
|
|
10691
11001
|
queries: z4.z.array(z4.z.string()),
|
|
10692
11002
|
results: z4.z.array(
|
|
10693
11003
|
z4.z.object({
|
|
10694
|
-
attributes: z4.z.record(
|
|
11004
|
+
attributes: z4.z.record(
|
|
11005
|
+
z4.z.string(),
|
|
11006
|
+
z4.z.union([z4.z.string(), z4.z.number(), z4.z.boolean()])
|
|
11007
|
+
),
|
|
10695
11008
|
file_id: z4.z.string(),
|
|
10696
11009
|
filename: z4.z.string(),
|
|
10697
11010
|
score: z4.z.number(),
|
|
@@ -10753,7 +11066,7 @@ var openaiResponsesResponseSchema = lazyValidator(
|
|
|
10753
11066
|
)
|
|
10754
11067
|
})
|
|
10755
11068
|
])
|
|
10756
|
-
),
|
|
11069
|
+
).optional(),
|
|
10757
11070
|
service_tier: z4.z.string().nullish(),
|
|
10758
11071
|
incomplete_details: z4.z.object({ reason: z4.z.string() }).nullish(),
|
|
10759
11072
|
usage: z4.z.object({
|
|
@@ -10761,7 +11074,7 @@ var openaiResponsesResponseSchema = lazyValidator(
|
|
|
10761
11074
|
input_tokens_details: z4.z.object({ cached_tokens: z4.z.number().nullish() }).nullish(),
|
|
10762
11075
|
output_tokens: z4.z.number(),
|
|
10763
11076
|
output_tokens_details: z4.z.object({ reasoning_tokens: z4.z.number().nullish() }).nullish()
|
|
10764
|
-
})
|
|
11077
|
+
}).optional()
|
|
10765
11078
|
})
|
|
10766
11079
|
)
|
|
10767
11080
|
);
|
|
@@ -10769,6 +11082,7 @@ var TOP_LOGPROBS_MAX = 20;
|
|
|
10769
11082
|
var openaiResponsesProviderOptionsSchema = lazyValidator(
|
|
10770
11083
|
() => zodSchema(
|
|
10771
11084
|
z4.z.object({
|
|
11085
|
+
conversation: z4.z.string().nullish(),
|
|
10772
11086
|
include: z4.z.array(
|
|
10773
11087
|
z4.z.enum([
|
|
10774
11088
|
"reasoning.encrypted_content",
|
|
@@ -10801,6 +11115,15 @@ var openaiResponsesProviderOptionsSchema = lazyValidator(
|
|
|
10801
11115
|
parallelToolCalls: z4.z.boolean().nullish(),
|
|
10802
11116
|
previousResponseId: z4.z.string().nullish(),
|
|
10803
11117
|
promptCacheKey: z4.z.string().nullish(),
|
|
11118
|
+
/**
|
|
11119
|
+
* The retention policy for the prompt cache.
|
|
11120
|
+
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
11121
|
+
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
11122
|
+
* Currently only available for 5.1 series models.
|
|
11123
|
+
*
|
|
11124
|
+
* @default 'in_memory'
|
|
11125
|
+
*/
|
|
11126
|
+
promptCacheRetention: z4.z.enum(["in_memory", "24h"]).nullish(),
|
|
10804
11127
|
reasoningEffort: z4.z.string().nullish(),
|
|
10805
11128
|
reasoningSummary: z4.z.string().nullish(),
|
|
10806
11129
|
safetyIdentifier: z4.z.string().nullish(),
|
|
@@ -10840,7 +11163,7 @@ async function prepareResponsesTools({
|
|
|
10840
11163
|
case "openai.file_search": {
|
|
10841
11164
|
const args = await validateTypes({
|
|
10842
11165
|
value: tool2.args,
|
|
10843
|
-
schema:
|
|
11166
|
+
schema: fileSearchArgsSchema2
|
|
10844
11167
|
});
|
|
10845
11168
|
openaiTools2.push({
|
|
10846
11169
|
type: "file_search",
|
|
@@ -11006,6 +11329,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11006
11329
|
providerOptions,
|
|
11007
11330
|
schema: openaiResponsesProviderOptionsSchema
|
|
11008
11331
|
});
|
|
11332
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
11333
|
+
warnings.push({
|
|
11334
|
+
type: "unsupported-setting",
|
|
11335
|
+
setting: "conversation",
|
|
11336
|
+
details: "conversation and previousResponseId cannot be used together"
|
|
11337
|
+
});
|
|
11338
|
+
}
|
|
11009
11339
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
11010
11340
|
prompt,
|
|
11011
11341
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
@@ -11068,6 +11398,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11068
11398
|
}
|
|
11069
11399
|
},
|
|
11070
11400
|
// provider options:
|
|
11401
|
+
conversation: openaiOptions == null ? void 0 : openaiOptions.conversation,
|
|
11071
11402
|
max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
|
|
11072
11403
|
metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
|
|
11073
11404
|
parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
|
|
@@ -11078,6 +11409,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11078
11409
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
11079
11410
|
include,
|
|
11080
11411
|
prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
|
|
11412
|
+
prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
|
|
11081
11413
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
11082
11414
|
top_logprobs: topLogprobs,
|
|
11083
11415
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
@@ -11287,7 +11619,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11287
11619
|
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId(),
|
|
11288
11620
|
mediaType: "text/plain",
|
|
11289
11621
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
11290
|
-
filename: (_l = annotation.filename) != null ? _l : annotation.file_id
|
|
11622
|
+
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
11623
|
+
...annotation.file_id ? {
|
|
11624
|
+
providerMetadata: {
|
|
11625
|
+
openai: {
|
|
11626
|
+
fileId: annotation.file_id
|
|
11627
|
+
}
|
|
11628
|
+
}
|
|
11629
|
+
} : {}
|
|
11291
11630
|
});
|
|
11292
11631
|
}
|
|
11293
11632
|
}
|
|
@@ -11397,7 +11736,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11397
11736
|
}
|
|
11398
11737
|
}
|
|
11399
11738
|
const providerMetadata = {
|
|
11400
|
-
openai: {
|
|
11739
|
+
openai: {
|
|
11740
|
+
...response.id != null ? { responseId: response.id } : {}
|
|
11741
|
+
}
|
|
11401
11742
|
};
|
|
11402
11743
|
if (logprobs.length > 0) {
|
|
11403
11744
|
providerMetadata.openai.logprobs = logprobs;
|
|
@@ -11405,6 +11746,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11405
11746
|
if (typeof response.service_tier === "string") {
|
|
11406
11747
|
providerMetadata.openai.serviceTier = response.service_tier;
|
|
11407
11748
|
}
|
|
11749
|
+
const usage = response.usage;
|
|
11408
11750
|
return {
|
|
11409
11751
|
content,
|
|
11410
11752
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -11412,11 +11754,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11412
11754
|
hasFunctionCall
|
|
11413
11755
|
}),
|
|
11414
11756
|
usage: {
|
|
11415
|
-
inputTokens:
|
|
11416
|
-
outputTokens:
|
|
11417
|
-
totalTokens:
|
|
11418
|
-
reasoningTokens: (_q = (_p =
|
|
11419
|
-
cachedInputTokens: (_s = (_r =
|
|
11757
|
+
inputTokens: usage.input_tokens,
|
|
11758
|
+
outputTokens: usage.output_tokens,
|
|
11759
|
+
totalTokens: usage.input_tokens + usage.output_tokens,
|
|
11760
|
+
reasoningTokens: (_q = (_p = usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
|
|
11761
|
+
cachedInputTokens: (_s = (_r = usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
|
|
11420
11762
|
},
|
|
11421
11763
|
request: { body },
|
|
11422
11764
|
response: {
|
|
@@ -11865,7 +12207,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11865
12207
|
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId(),
|
|
11866
12208
|
mediaType: "text/plain",
|
|
11867
12209
|
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
11868
|
-
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
12210
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
|
|
12211
|
+
...value.annotation.file_id ? {
|
|
12212
|
+
providerMetadata: {
|
|
12213
|
+
openai: {
|
|
12214
|
+
fileId: value.annotation.file_id
|
|
12215
|
+
}
|
|
12216
|
+
}
|
|
12217
|
+
} : {}
|
|
11869
12218
|
});
|
|
11870
12219
|
}
|
|
11871
12220
|
} else if (isErrorChunk(value)) {
|
|
@@ -11943,13 +12292,6 @@ function getResponsesModelConfig(modelId) {
|
|
|
11943
12292
|
};
|
|
11944
12293
|
}
|
|
11945
12294
|
if (modelId.startsWith("o") || modelId.startsWith("gpt-5") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
11946
|
-
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
11947
|
-
return {
|
|
11948
|
-
...defaults,
|
|
11949
|
-
isReasoningModel: true,
|
|
11950
|
-
systemMessageMode: "remove"
|
|
11951
|
-
};
|
|
11952
|
-
}
|
|
11953
12295
|
return {
|
|
11954
12296
|
...defaults,
|
|
11955
12297
|
isReasoningModel: true,
|
|
@@ -11965,7 +12307,11 @@ function mapWebSearchOutput(action) {
|
|
|
11965
12307
|
var _a15;
|
|
11966
12308
|
switch (action.type) {
|
|
11967
12309
|
case "search":
|
|
11968
|
-
return {
|
|
12310
|
+
return {
|
|
12311
|
+
action: { type: "search", query: (_a15 = action.query) != null ? _a15 : void 0 },
|
|
12312
|
+
// include sources when provided by the Responses API (behind include flag)
|
|
12313
|
+
...action.sources != null && { sources: action.sources }
|
|
12314
|
+
};
|
|
11969
12315
|
case "open_page":
|
|
11970
12316
|
return { action: { type: "openPage", url: action.url } };
|
|
11971
12317
|
case "find":
|
|
@@ -12304,7 +12650,7 @@ var OpenAITranscriptionModel = class {
|
|
|
12304
12650
|
};
|
|
12305
12651
|
}
|
|
12306
12652
|
};
|
|
12307
|
-
var VERSION5 = "2.0.
|
|
12653
|
+
var VERSION5 = "2.0.69" ;
|
|
12308
12654
|
function createOpenAI(options = {}) {
|
|
12309
12655
|
var _a15, _b;
|
|
12310
12656
|
const baseURL = (_a15 = withoutTrailingSlash(
|
|
@@ -12401,17 +12747,10 @@ function createOpenAI(options = {}) {
|
|
|
12401
12747
|
}
|
|
12402
12748
|
createOpenAI();
|
|
12403
12749
|
|
|
12404
|
-
exports.APICallError = APICallError;
|
|
12405
|
-
exports.EmptyResponseBodyError = EmptyResponseBodyError;
|
|
12406
|
-
exports.EventSourceParserStream = EventSourceParserStream;
|
|
12407
|
-
exports.InvalidArgumentError = InvalidArgumentError;
|
|
12408
|
-
exports.JSONParseError = JSONParseError;
|
|
12409
|
-
exports.LoadAPIKeyError = LoadAPIKeyError;
|
|
12410
12750
|
exports.MastraModelGateway = MastraModelGateway;
|
|
12411
12751
|
exports.NoSuchModelError = NoSuchModelError;
|
|
12412
12752
|
exports.OpenAICompatibleImageModel = OpenAICompatibleImageModel;
|
|
12413
12753
|
exports.TooManyEmbeddingValuesForCallError = TooManyEmbeddingValuesForCallError;
|
|
12414
|
-
exports.TypeValidationError = TypeValidationError;
|
|
12415
12754
|
exports.UnsupportedFunctionalityError = UnsupportedFunctionalityError;
|
|
12416
12755
|
exports.combineHeaders = combineHeaders;
|
|
12417
12756
|
exports.convertToBase64 = convertToBase64;
|
|
@@ -12423,10 +12762,11 @@ exports.createJsonResponseHandler = createJsonResponseHandler;
|
|
|
12423
12762
|
exports.createOpenAI = createOpenAI;
|
|
12424
12763
|
exports.createOpenAICompatible = createOpenAICompatible;
|
|
12425
12764
|
exports.generateId = generateId;
|
|
12765
|
+
exports.injectJsonInstructionIntoMessages = injectJsonInstructionIntoMessages;
|
|
12426
12766
|
exports.loadApiKey = loadApiKey;
|
|
12427
12767
|
exports.parseProviderOptions = parseProviderOptions;
|
|
12428
12768
|
exports.postJsonToApi = postJsonToApi;
|
|
12429
12769
|
exports.withUserAgentSuffix = withUserAgentSuffix;
|
|
12430
12770
|
exports.withoutTrailingSlash = withoutTrailingSlash;
|
|
12431
|
-
//# sourceMappingURL=chunk-
|
|
12432
|
-
//# sourceMappingURL=chunk-
|
|
12771
|
+
//# sourceMappingURL=chunk-ZCVTH3CH.cjs.map
|
|
12772
|
+
//# sourceMappingURL=chunk-ZCVTH3CH.cjs.map
|