@mastra/core 1.0.0-beta.11 → 1.0.0-beta.14
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 +343 -0
- package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +7549 -0
- package/dist/_types/@internal_ai-sdk-v4/dist/test.d.ts +65 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +8396 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/test.d.ts +1708 -0
- package/dist/_types/@internal_external-types/dist/index.d.ts +858 -0
- package/dist/agent/agent-legacy.d.ts +1 -1
- package/dist/agent/agent.d.ts +3 -3
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +11 -8
- 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 +4 -3
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts +1 -1
- package/dist/agent/message-list/prompt/invalid-content-error.d.ts +1 -1
- package/dist/agent/message-list/types.d.ts +3 -3
- package/dist/agent/message-list/types.d.ts.map +1 -1
- package/dist/agent/message-list/utils/ai-v4-v5/core-model-message.d.ts +1 -1
- package/dist/agent/message-list/utils/ai-v4-v5/ui-message.d.ts +1 -1
- package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts +2 -2
- package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts.map +1 -1
- package/dist/agent/message-list/utils/convert-messages.d.ts +2 -2
- package/dist/agent/message-list/utils/convert-messages.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +2 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/types.d.ts +3 -3
- package/dist/agent/utils.d.ts +7 -4
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +4 -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/agent/workflows/prepare-stream/stream-step.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/bundler/types.d.ts +15 -1
- 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-2SQB3WBT.js +4574 -0
- package/dist/chunk-2SQB3WBT.js.map +1 -0
- package/dist/{chunk-THZTRBFS.js → chunk-373OC54J.js} +8 -8
- package/dist/chunk-373OC54J.js.map +1 -0
- package/dist/{chunk-US2U7ECW.js → chunk-3IP3DZ7G.js} +234 -101
- package/dist/chunk-3IP3DZ7G.js.map +1 -0
- package/dist/{chunk-SXNQRJQD.js → chunk-4AT6YQKZ.js} +26 -20
- package/dist/chunk-4AT6YQKZ.js.map +1 -0
- package/dist/{chunk-C36YRTZ6.js → chunk-4CMIJQF6.js} +117 -114
- package/dist/chunk-4CMIJQF6.js.map +1 -0
- package/dist/chunk-53SZJCBX.cjs +4888 -0
- package/dist/chunk-53SZJCBX.cjs.map +1 -0
- package/dist/chunk-55VPMN3N.js +250 -0
- package/dist/chunk-55VPMN3N.js.map +1 -0
- package/dist/{chunk-QM5SRDJX.js → chunk-5PTZG26U.js} +66 -84
- package/dist/chunk-5PTZG26U.js.map +1 -0
- package/dist/{chunk-U3XOLEPX.js → chunk-5UQ5TB6J.js} +6 -32
- package/dist/chunk-5UQ5TB6J.js.map +1 -0
- package/dist/{chunk-O2BJW7YA.js → chunk-67LM2UCT.js} +9 -9
- package/dist/chunk-67LM2UCT.js.map +1 -0
- package/dist/{chunk-YC6PJEPH.cjs → chunk-6CG7IY57.cjs} +266 -133
- package/dist/chunk-6CG7IY57.cjs.map +1 -0
- package/dist/chunk-6PMMP3FR.js +7 -0
- package/dist/chunk-6PMMP3FR.js.map +1 -0
- package/dist/{chunk-DZUJEN5N.cjs → chunk-6SZKM6EC.cjs} +10 -3
- package/dist/{chunk-DZUJEN5N.cjs.map → chunk-6SZKM6EC.cjs.map} +1 -1
- package/dist/{chunk-5Q6WAYEY.cjs → chunk-72E3YF6A.cjs} +35 -49
- package/dist/chunk-72E3YF6A.cjs.map +1 -0
- package/dist/{chunk-5WRI5ZAA.js → chunk-7D4SUZUM.js} +10 -4
- package/dist/{chunk-5WRI5ZAA.js.map → chunk-7D4SUZUM.js.map} +1 -1
- package/dist/{chunk-7P6BNIJH.js → chunk-AYBJ5GAD.js} +281 -35
- package/dist/chunk-AYBJ5GAD.js.map +1 -0
- package/dist/chunk-D22XABFZ.js +79 -0
- package/dist/chunk-D22XABFZ.js.map +1 -0
- package/dist/{chunk-SCUWP4II.cjs → chunk-DBW6S25C.cjs} +47 -74
- package/dist/chunk-DBW6S25C.cjs.map +1 -0
- package/dist/{chunk-MRFUISXC.cjs → chunk-EGHGFLL3.cjs} +2631 -179
- package/dist/chunk-EGHGFLL3.cjs.map +1 -0
- package/dist/{chunk-BJXKH4LG.cjs → chunk-ETWAR2YE.cjs} +43 -78
- package/dist/chunk-ETWAR2YE.cjs.map +1 -0
- package/dist/{chunk-CZEJQSWB.cjs → chunk-F75EQ574.cjs} +65 -6
- package/dist/chunk-F75EQ574.cjs.map +1 -0
- package/dist/{chunk-BUKY6CTR.cjs → chunk-FPDJ4XN6.cjs} +282 -36
- package/dist/chunk-FPDJ4XN6.cjs.map +1 -0
- package/dist/chunk-FST2G2FQ.cjs +84 -0
- package/dist/chunk-FST2G2FQ.cjs.map +1 -0
- package/dist/chunk-FVQTJUBD.cjs +2120 -0
- package/dist/chunk-FVQTJUBD.cjs.map +1 -0
- package/dist/chunk-G6E6V2Z4.js +2070 -0
- package/dist/chunk-G6E6V2Z4.js.map +1 -0
- package/dist/{chunk-JIGDJK2O.js → chunk-GBQXIVL6.js} +4 -39
- package/dist/chunk-GBQXIVL6.js.map +1 -0
- package/dist/{chunk-F2GAJSBI.js → chunk-GELVUDUY.js} +11 -8
- package/dist/chunk-GELVUDUY.js.map +1 -0
- package/dist/chunk-GVAPYQRO.cjs +252 -0
- package/dist/chunk-GVAPYQRO.cjs.map +1 -0
- package/dist/{chunk-TWH4PTDG.cjs → chunk-HWMMIRIF.cjs} +32 -27
- package/dist/chunk-HWMMIRIF.cjs.map +1 -0
- package/dist/{chunk-52RSUALV.cjs → chunk-JAGQZZ43.cjs} +1660 -1196
- package/dist/chunk-JAGQZZ43.cjs.map +1 -0
- package/dist/{chunk-PK2A5WBG.js → chunk-K66U47VL.js} +54 -7
- package/dist/chunk-K66U47VL.js.map +1 -0
- package/dist/chunk-L3NKIMF5.cjs +10 -0
- package/dist/chunk-L3NKIMF5.cjs.map +1 -0
- package/dist/chunk-L4JCRWDY.cjs +252 -0
- package/dist/chunk-L4JCRWDY.cjs.map +1 -0
- package/dist/{chunk-IVV5TOMD.js → chunk-LDXKZYOV.js} +31 -11
- package/dist/chunk-LDXKZYOV.js.map +1 -0
- package/dist/chunk-NESKUIRE.cjs +4586 -0
- package/dist/chunk-NESKUIRE.cjs.map +1 -0
- package/dist/{chunk-SVLMF4UZ.cjs → chunk-NIOEY3N3.cjs} +66 -85
- package/dist/chunk-NIOEY3N3.cjs.map +1 -0
- package/dist/{chunk-PG5H6QIO.cjs → chunk-O3ULBGV6.cjs} +40 -20
- package/dist/chunk-O3ULBGV6.cjs.map +1 -0
- package/dist/{chunk-WTSZBHIZ.cjs → chunk-O5BQBZEF.cjs} +28 -28
- package/dist/chunk-O5BQBZEF.cjs.map +1 -0
- package/dist/{chunk-4JKEUSCC.cjs → chunk-OOUFPYSX.cjs} +25 -22
- package/dist/chunk-OOUFPYSX.cjs.map +1 -0
- package/dist/chunk-QDVYP2T7.js +4883 -0
- package/dist/chunk-QDVYP2T7.js.map +1 -0
- package/dist/{chunk-2ULLRN4Y.js → chunk-QF4MHFSU.js} +1294 -834
- package/dist/chunk-QF4MHFSU.js.map +1 -0
- package/dist/{chunk-Z57R5WS4.js → chunk-SLBWA2F3.js} +4 -4
- package/dist/{chunk-Z57R5WS4.js.map → chunk-SLBWA2F3.js.map} +1 -1
- package/dist/chunk-ST7NBF4H.cjs +84 -0
- package/dist/chunk-ST7NBF4H.cjs.map +1 -0
- package/dist/{chunk-YWMMBIOM.cjs → chunk-TDM43G4I.cjs} +15 -15
- package/dist/{chunk-YWMMBIOM.cjs.map → chunk-TDM43G4I.cjs.map} +1 -1
- package/dist/{chunk-S73Z3PBJ.cjs → chunk-TRUNX3AX.cjs} +138 -134
- package/dist/chunk-TRUNX3AX.cjs.map +1 -0
- package/dist/chunk-VE6HQ7H6.js +250 -0
- package/dist/chunk-VE6HQ7H6.js.map +1 -0
- package/dist/{chunk-OEIVMCWX.js → chunk-VZJOEGQA.js} +2536 -84
- package/dist/chunk-VZJOEGQA.js.map +1 -0
- package/dist/{chunk-JJ5O45LH.js → chunk-YPLZDWG7.js} +32 -27
- package/dist/chunk-YPLZDWG7.js.map +1 -0
- package/dist/{chunk-MGCGWPQJ.cjs → chunk-Z55SJVEC.cjs} +8 -8
- package/dist/chunk-Z55SJVEC.cjs.map +1 -0
- package/dist/error/index.cjs +6 -6
- package/dist/error/index.d.ts +26 -20
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/error/utils.d.ts +19 -5
- package/dist/error/utils.d.ts.map +1 -1
- package/dist/evals/index.cjs +4 -4
- package/dist/evals/index.js +1 -1
- package/dist/evals/run/index.d.ts +1 -1
- package/dist/evals/run/index.d.ts.map +1 -1
- package/dist/evals/scoreTraces/index.cjs +8 -8
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/evals/types.d.ts +1 -1
- package/dist/events/event-emitter.d.ts +6 -1
- package/dist/events/event-emitter.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +15 -15
- package/dist/llm/index.d.ts +2 -2
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/aisdk/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 +5 -1
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
- package/dist/llm/model/aisdk/v6/model.d.ts +51 -0
- package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -0
- package/dist/llm/model/base.types.d.ts +2 -2
- package/dist/llm/model/model.d.ts +1 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +3 -3
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +1 -1
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +135 -11
- 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 +19 -8
- 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/loop.d.ts +2 -2
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts +2 -2
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +2 -2
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts +37 -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/options.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 +1 -1
- package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/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 +8 -7
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +49 -49
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +34 -34
- 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 +17 -17
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +22 -21
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +49 -49
- 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 +18 -18
- package/dist/loop/workflows/schema.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts +2 -2
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.js +1 -1
- package/dist/memory/index.cjs +6 -6
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +1 -1
- package/dist/memory/types.d.ts +3 -3
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-E3WWI7VA.js +3 -0
- package/dist/{models-dev-23RN2WHG.js.map → models-dev-E3WWI7VA.js.map} +1 -1
- package/dist/models-dev-PPS7X4JM.cjs +12 -0
- package/dist/{models-dev-EO3SUIY2.cjs.map → models-dev-PPS7X4JM.cjs.map} +1 -1
- package/dist/netlify-TY656UYF.js +3 -0
- package/dist/{netlify-GXJ5D5DD.js.map → netlify-TY656UYF.js.map} +1 -1
- package/dist/netlify-VZFM5UH3.cjs +12 -0
- package/dist/{netlify-KJLY3GFS.cjs.map → netlify-VZFM5UH3.cjs.map} +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.d.ts +9 -9
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +1293 -1293
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-NXVD764B.js +3 -0
- package/dist/{provider-registry-F67Y6OF2.js.map → provider-registry-NXVD764B.js.map} +1 -1
- package/dist/provider-registry-ZIWSEUQE.cjs +40 -0
- package/dist/{provider-registry-3TG2KUD2.cjs.map → provider-registry-ZIWSEUQE.cjs.map} +1 -1
- package/dist/provider-registry.json +276 -30
- package/dist/{registry-generator-UMTNPBJX.js → registry-generator-AVQXI3GX.js} +2 -2
- package/dist/{registry-generator-UMTNPBJX.js.map → registry-generator-AVQXI3GX.js.map} +1 -1
- package/dist/{registry-generator-34SC4TAU.cjs → registry-generator-KOFNIIWJ.cjs} +2 -2
- package/dist/{registry-generator-34SC4TAU.cjs.map → registry-generator-KOFNIIWJ.cjs.map} +1 -1
- package/dist/relevance/index.cjs +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 +2 -10
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/base.d.ts +2 -8
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +2 -8
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +38 -38
- package/dist/storage/index.js +1 -1
- package/dist/storage/mock.d.ts +2 -8
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +9 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts +1 -1
- package/dist/stream/aisdk/v4/input.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/content.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/content.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/validation.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/validation.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +6 -6
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/input.d.ts +1 -1
- package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output-helpers.d.ts +12 -27
- package/dist/stream/aisdk/v5/output-helpers.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +41 -91
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/input.d.ts +1 -1
- package/dist/stream/base/output.d.ts +16 -36
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/base/schema.d.ts +2 -2
- package/dist/stream/base/schema.d.ts.map +1 -1
- package/dist/stream/index.cjs +12 -12
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +32 -23
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +14587 -14
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.d.ts +3 -3
- package/dist/test-utils/llm-mock.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.js +14577 -4
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/token-6GSAFR2W-LTZ7QQUP.js +61 -0
- package/dist/token-6GSAFR2W-LTZ7QQUP.js.map +1 -0
- package/dist/token-6GSAFR2W-SGVIXFCP.cjs +63 -0
- package/dist/token-6GSAFR2W-SGVIXFCP.cjs.map +1 -0
- package/dist/token-6GSAFR2W-SPYPLMBM.js +61 -0
- package/dist/token-6GSAFR2W-SPYPLMBM.js.map +1 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs +63 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-7GMW5FXI.cjs +10 -0
- package/dist/token-util-NEHG7TUY-7GMW5FXI.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-JRJTGTAB.js +8 -0
- package/dist/token-util-NEHG7TUY-JRJTGTAB.js.map +1 -0
- package/dist/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/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts +2 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +5 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/embed.d.ts +3 -2
- package/dist/vector/embed.d.ts.map +1 -1
- package/dist/vector/index.cjs +5316 -16
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +5282 -4
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +15 -2
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/voice/aisdk/speech.d.ts +1 -1
- package/dist/voice/aisdk/speech.d.ts.map +1 -1
- package/dist/voice/aisdk/transcription.d.ts +1 -1
- package/dist/voice/aisdk/transcription.d.ts.map +1 -1
- package/dist/voice/composite-voice.d.ts +1 -1
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/constants.cjs +4 -4
- package/dist/workflows/constants.d.ts +1 -1
- package/dist/workflows/constants.d.ts.map +1 -1
- package/dist/workflows/constants.js +1 -1
- package/dist/workflows/default.d.ts +9 -16
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +3 -2
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +5 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +16 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +20 -0
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +25 -2
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +6 -5
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/entry.d.ts +5 -3
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/handlers/sleep.d.ts +4 -3
- package/dist/workflows/handlers/sleep.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +5 -3
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +26 -22
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +5 -4
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +66 -14
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +11 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +30 -9
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +13 -14
- package/src/llm/model/provider-types.generated.d.ts +135 -11
- package/dist/agent/__tests__/mock-model.d.ts +0 -8
- package/dist/agent/__tests__/mock-model.d.ts.map +0 -1
- package/dist/agent/agent-types.test-d.d.ts +0 -2
- package/dist/agent/agent-types.test-d.d.ts.map +0 -1
- package/dist/ai-sdk.types.d.ts +0 -4705
- package/dist/chunk-2ULLRN4Y.js.map +0 -1
- package/dist/chunk-3E3ILV6T.cjs +0 -518
- package/dist/chunk-3E3ILV6T.cjs.map +0 -1
- package/dist/chunk-4JKEUSCC.cjs.map +0 -1
- package/dist/chunk-52RSUALV.cjs.map +0 -1
- package/dist/chunk-5PAEYE3Q.js +0 -513
- package/dist/chunk-5PAEYE3Q.js.map +0 -1
- package/dist/chunk-5Q6WAYEY.cjs.map +0 -1
- package/dist/chunk-7P6BNIJH.js.map +0 -1
- package/dist/chunk-ABJOUEVA.cjs +0 -10
- package/dist/chunk-ABJOUEVA.cjs.map +0 -1
- package/dist/chunk-BJXKH4LG.cjs.map +0 -1
- package/dist/chunk-BUKY6CTR.cjs.map +0 -1
- package/dist/chunk-C36YRTZ6.js.map +0 -1
- package/dist/chunk-CZEJQSWB.cjs.map +0 -1
- package/dist/chunk-F2GAJSBI.js.map +0 -1
- package/dist/chunk-IVV5TOMD.js.map +0 -1
- package/dist/chunk-JIGDJK2O.js.map +0 -1
- package/dist/chunk-JJ5O45LH.js.map +0 -1
- package/dist/chunk-MGCGWPQJ.cjs.map +0 -1
- package/dist/chunk-MRFUISXC.cjs.map +0 -1
- package/dist/chunk-NLNKQD2T.js +0 -7
- package/dist/chunk-NLNKQD2T.js.map +0 -1
- package/dist/chunk-O2BJW7YA.js.map +0 -1
- package/dist/chunk-OEIVMCWX.js.map +0 -1
- package/dist/chunk-PG5H6QIO.cjs.map +0 -1
- package/dist/chunk-PK2A5WBG.js.map +0 -1
- package/dist/chunk-QM5SRDJX.js.map +0 -1
- package/dist/chunk-S73Z3PBJ.cjs.map +0 -1
- package/dist/chunk-SCUWP4II.cjs.map +0 -1
- package/dist/chunk-SVLMF4UZ.cjs.map +0 -1
- package/dist/chunk-SXNQRJQD.js.map +0 -1
- package/dist/chunk-THZTRBFS.js.map +0 -1
- package/dist/chunk-TWH4PTDG.cjs.map +0 -1
- package/dist/chunk-U3XOLEPX.js.map +0 -1
- package/dist/chunk-US2U7ECW.js.map +0 -1
- package/dist/chunk-WTSZBHIZ.cjs.map +0 -1
- package/dist/chunk-YC6PJEPH.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-23RN2WHG.js +0 -3
- package/dist/models-dev-EO3SUIY2.cjs +0 -12
- package/dist/netlify-GXJ5D5DD.js +0 -3
- package/dist/netlify-KJLY3GFS.cjs +0 -12
- package/dist/provider-registry-3TG2KUD2.cjs +0 -40
- package/dist/provider-registry-F67Y6OF2.js +0 -3
- package/dist/tools/tool-stream-types.test-d.d.ts +0 -2
- package/dist/tools/tool-stream-types.test-d.d.ts.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk72YCRTEX_cjs = require('./chunk-72YCRTEX.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkHWMMIRIF_cjs = require('./chunk-HWMMIRIF.cjs');
|
|
5
5
|
var chunkKJBMTK5B_cjs = require('./chunk-KJBMTK5B.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkZ55SJVEC_cjs = require('./chunk-Z55SJVEC.cjs');
|
|
7
7
|
var chunkUVHSM2GU_cjs = require('./chunk-UVHSM2GU.cjs');
|
|
8
8
|
var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
|
|
9
9
|
var crypto = require('crypto');
|
|
@@ -20,10 +20,25 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
20
20
|
this.originalTool = input.originalTool;
|
|
21
21
|
this.options = input.options;
|
|
22
22
|
this.logType = input.logType;
|
|
23
|
+
if (!chunkZ55SJVEC_cjs.isVercelTool(this.originalTool) && input.autoResumeSuspendedTools) {
|
|
24
|
+
let schema = this.originalTool.inputSchema;
|
|
25
|
+
if (typeof schema === "function") {
|
|
26
|
+
schema = schema();
|
|
27
|
+
}
|
|
28
|
+
if (!schema) {
|
|
29
|
+
schema = zod.z.object({});
|
|
30
|
+
}
|
|
31
|
+
if (schema instanceof zod.z.ZodObject) {
|
|
32
|
+
this.originalTool.inputSchema = schema.extend({
|
|
33
|
+
suspendedToolRunId: zod.z.string().describe("The runId of the suspended tool").optional(),
|
|
34
|
+
resumeData: zod.z.any().describe("The resumeData object created from the resumeSchema of suspended tool").optional()
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
}
|
|
24
39
|
// Helper to get parameters based on tool type
|
|
25
40
|
getParameters = () => {
|
|
26
|
-
if (
|
|
41
|
+
if (chunkZ55SJVEC_cjs.isVercelTool(this.originalTool)) {
|
|
27
42
|
let schema2 = this.originalTool.parameters ?? ("inputSchema" in this.originalTool ? this.originalTool.inputSchema : void 0) ?? zod.z.object({});
|
|
28
43
|
if (typeof schema2 === "function") {
|
|
29
44
|
schema2 = schema2();
|
|
@@ -151,13 +166,14 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
151
166
|
try {
|
|
152
167
|
let result;
|
|
153
168
|
let suspendData = null;
|
|
154
|
-
if (
|
|
169
|
+
if (chunkZ55SJVEC_cjs.isVercelTool(tool)) {
|
|
155
170
|
result = await chunk72YCRTEX_cjs.executeWithContext({
|
|
156
171
|
span: toolSpan,
|
|
157
172
|
fn: async () => tool?.execute?.(args, execOptions)
|
|
158
173
|
});
|
|
159
174
|
} else {
|
|
160
175
|
const wrappedMastra = options.mastra ? chunk72YCRTEX_cjs.wrapMastra(options.mastra, { currentSpan: toolSpan }) : options.mastra;
|
|
176
|
+
const resumeSchema = this.getResumeSchema();
|
|
161
177
|
const baseContext = {
|
|
162
178
|
threadId: options.threadId,
|
|
163
179
|
resourceId: options.resourceId,
|
|
@@ -176,9 +192,13 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
176
192
|
),
|
|
177
193
|
tracingContext: { currentSpan: toolSpan },
|
|
178
194
|
abortSignal: execOptions.abortSignal,
|
|
179
|
-
suspend: (args2) => {
|
|
195
|
+
suspend: (args2, suspendOptions) => {
|
|
180
196
|
suspendData = args2;
|
|
181
|
-
|
|
197
|
+
const newSuspendOptions = {
|
|
198
|
+
...suspendOptions ?? {},
|
|
199
|
+
resumeSchema: suspendOptions?.resumeSchema ?? resumeSchema
|
|
200
|
+
};
|
|
201
|
+
return execOptions.suspend?.(args2, newSuspendOptions);
|
|
182
202
|
},
|
|
183
203
|
resumeData: execOptions.resumeData
|
|
184
204
|
};
|
|
@@ -222,8 +242,7 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
222
242
|
}
|
|
223
243
|
const resumeData = execOptions.resumeData;
|
|
224
244
|
if (resumeData) {
|
|
225
|
-
const
|
|
226
|
-
const resumeValidation = chunkMGCGWPQJ_cjs.validateToolInput(resumeSchema, resumeData, options.name);
|
|
245
|
+
const resumeValidation = chunkZ55SJVEC_cjs.validateToolInput(resumeSchema, resumeData, options.name);
|
|
227
246
|
if (resumeValidation.error) {
|
|
228
247
|
logger?.warn(resumeValidation.error.message);
|
|
229
248
|
toolSpan?.end({ output: resumeValidation.error });
|
|
@@ -234,7 +253,7 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
234
253
|
}
|
|
235
254
|
if (suspendData) {
|
|
236
255
|
const suspendSchema = this.getSuspendSchema();
|
|
237
|
-
const suspendValidation =
|
|
256
|
+
const suspendValidation = chunkZ55SJVEC_cjs.validateToolSuspendData(suspendSchema, suspendData, options.name);
|
|
238
257
|
if (suspendValidation.error) {
|
|
239
258
|
logger?.warn(suspendValidation.error.message);
|
|
240
259
|
toolSpan?.end({ output: suspendValidation.error });
|
|
@@ -246,9 +265,9 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
246
265
|
toolSpan?.end({ output: result });
|
|
247
266
|
return result;
|
|
248
267
|
}
|
|
249
|
-
if (
|
|
268
|
+
if (chunkZ55SJVEC_cjs.isVercelTool(tool)) {
|
|
250
269
|
const outputSchema = this.getOutputSchema();
|
|
251
|
-
const outputValidation =
|
|
270
|
+
const outputValidation = chunkZ55SJVEC_cjs.validateToolOutput(outputSchema, result, options.name, false);
|
|
252
271
|
if (outputValidation.error) {
|
|
253
272
|
logger?.warn(outputValidation.error.message);
|
|
254
273
|
toolSpan?.end({ output: outputValidation.error });
|
|
@@ -268,7 +287,7 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
268
287
|
try {
|
|
269
288
|
logger2.debug(start, { ...rest, model: logModelObject, args });
|
|
270
289
|
const parameters = processedSchema || this.getParameters();
|
|
271
|
-
const { data, error: error2 } =
|
|
290
|
+
const { data, error: error2 } = chunkZ55SJVEC_cjs.validateToolInput(parameters, args, options.name);
|
|
272
291
|
if (error2) {
|
|
273
292
|
logger2.warn(error2.message);
|
|
274
293
|
return error2;
|
|
@@ -285,7 +304,7 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
285
304
|
});
|
|
286
305
|
});
|
|
287
306
|
} catch (err) {
|
|
288
|
-
const mastraError = new
|
|
307
|
+
const mastraError = new chunkHWMMIRIF_cjs.MastraError(
|
|
289
308
|
{
|
|
290
309
|
id: "TOOL_EXECUTION_FAILED",
|
|
291
310
|
domain: "TOOL" /* TOOL */,
|
|
@@ -387,6 +406,7 @@ var CoreToolBuilder = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
387
406
|
type: "function",
|
|
388
407
|
description: this.originalTool.description,
|
|
389
408
|
requireApproval: this.options.requireApproval,
|
|
409
|
+
hasSuspendSchema: !!this.getSuspendSchema(),
|
|
390
410
|
execute: this.originalTool.execute ? this.createExecute(
|
|
391
411
|
this.originalTool,
|
|
392
412
|
{ ...this.options, description: this.originalTool.description },
|
|
@@ -539,7 +559,7 @@ function ensureToolProperties(tools) {
|
|
|
539
559
|
const toolsWithProperties = Object.keys(tools).reduce((acc, key) => {
|
|
540
560
|
const tool = tools?.[key];
|
|
541
561
|
if (tool) {
|
|
542
|
-
if (
|
|
562
|
+
if (chunkZ55SJVEC_cjs.isVercelTool(tool)) {
|
|
543
563
|
acc[key] = setVercelToolProperties(tool);
|
|
544
564
|
} else {
|
|
545
565
|
acc[key] = tool;
|
|
@@ -556,11 +576,11 @@ function convertVercelToolParameters(tool) {
|
|
|
556
576
|
}
|
|
557
577
|
return isZodType(schema) ? schema : resolveSerializedZodOutput(jsonToZod.jsonSchemaToZod(schema));
|
|
558
578
|
}
|
|
559
|
-
function makeCoreTool(originalTool, options, logType) {
|
|
560
|
-
return new CoreToolBuilder({ originalTool, options, logType }).build();
|
|
579
|
+
function makeCoreTool(originalTool, options, logType, autoResumeSuspendedTools) {
|
|
580
|
+
return new CoreToolBuilder({ originalTool, options, logType, autoResumeSuspendedTools }).build();
|
|
561
581
|
}
|
|
562
|
-
function makeCoreToolV5(originalTool, options, logType) {
|
|
563
|
-
return new CoreToolBuilder({ originalTool, options, logType }).buildV5();
|
|
582
|
+
function makeCoreToolV5(originalTool, options, logType, autoResumeSuspendedTools) {
|
|
583
|
+
return new CoreToolBuilder({ originalTool, options, logType, autoResumeSuspendedTools }).buildV5();
|
|
564
584
|
}
|
|
565
585
|
function createMastraProxy({ mastra, logger }) {
|
|
566
586
|
return new Proxy(mastra, {
|
|
@@ -752,5 +772,5 @@ exports.removeUndefinedValues = removeUndefinedValues;
|
|
|
752
772
|
exports.resolveSerializedZodOutput = resolveSerializedZodOutput;
|
|
753
773
|
exports.selectFields = selectFields;
|
|
754
774
|
exports.setNestedValue = setNestedValue;
|
|
755
|
-
//# sourceMappingURL=chunk-
|
|
756
|
-
//# sourceMappingURL=chunk-
|
|
775
|
+
//# sourceMappingURL=chunk-O3ULBGV6.cjs.map
|
|
776
|
+
//# sourceMappingURL=chunk-O3ULBGV6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tools/tool-builder/builder.ts","../src/utils.ts"],"names":["MastraBase","isVercelTool","z","schema","convertZodSchemaToAISDKSchema","executeWithContext","wrapMastra","RequestContext","ToolStream","args","resumeData","validateToolInput","validateToolSuspendData","validateToolOutput","error","logger","MastraError","OpenAIReasoningSchemaCompatLayer","OpenAISchemaCompatLayer","GoogleSchemaCompatLayer","AnthropicSchemaCompatLayer","DeepSeekSchemaCompatLayer","MetaSchemaCompatLayer","applyCompatLayer","createHash","jsonSchemaToZod","delay"],"mappings":";;;;;;;;;;;;;AAyCO,IAAM,eAAA,GAAN,cAA8BA,4BAAA,CAAW;AAAA,EACtC,YAAA;AAAA,E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-types';\nimport {\n OpenAIReasoningSchemaCompatLayer,\n OpenAISchemaCompatLayer,\n GoogleSchemaCompatLayer,\n AnthropicSchemaCompatLayer,\n DeepSeekSchemaCompatLayer,\n MetaSchemaCompatLayer,\n applyCompatLayer,\n convertZodSchemaToAISDKSchema,\n} from '@mastra/schema-compat';\nimport { z } from 'zod';\nimport { MastraBase } from '../../base';\nimport { ErrorCategory, MastraError, ErrorDomain } from '../../error';\nimport { SpanType, wrapMastra, executeWithContext } from '../../observability';\nimport { RequestContext } from '../../request-context';\nimport { isVercelTool } from '../../tools/toolchecks';\nimport type { ToolOptions } from '../../utils';\nimport type { SuspendOptions } from '../../workflows';\nimport { ToolStream } from '../stream';\nimport type { CoreTool, MastraToolInvocationOptions, ToolAction, VercelTool, VercelToolV5 } from '../types';\nimport { validateToolInput, validateToolOutput, validateToolSuspendData } from '../validation';\n\n/**\n * Types that can be converted to Mastra tools.\n * Includes provider-defined tools from external packages via ProviderDefinedTool.\n */\nexport type ToolToConvert = VercelTool | ToolAction<any, any, any> | VercelToolV5 | ProviderDefinedTool;\nexport type LogType = 'tool' | 'toolset' | 'client-tool';\n\ninterface LogOptions {\n agentName?: string;\n toolName: string;\n type?: 'tool' | 'toolset' | 'client-tool';\n}\n\ninterface LogMessageOptions {\n start: string;\n error: string;\n}\n\nexport class CoreToolBuilder extends MastraBase {\n private originalTool: ToolToConvert;\n private options: ToolOptions;\n private logType?: LogType;\n\n constructor(input: {\n originalTool: ToolToConvert;\n options: ToolOptions;\n logType?: LogType;\n autoResumeSuspendedTools?: boolean;\n }) {\n super({ name: 'CoreToolBuilder' });\n this.originalTool = input.originalTool;\n this.options = input.options;\n this.logType = input.logType;\n if (!isVercelTool(this.originalTool) && input.autoResumeSuspendedTools) {\n let schema = this.originalTool.inputSchema;\n if (typeof schema === 'function') {\n schema = schema();\n }\n if (!schema) {\n schema = z.object({});\n }\n if (schema instanceof z.ZodObject) {\n this.originalTool.inputSchema = schema.extend({\n suspendedToolRunId: z.string().describe('The runId of the suspended tool').optional(),\n resumeData: z\n .any()\n .describe('The resumeData object created from the resumeSchema of suspended tool')\n .optional(),\n });\n }\n }\n }\n\n // Helper to get parameters based on tool type\n private getParameters = () => {\n if (isVercelTool(this.originalTool)) {\n // Handle both 'parameters' (v4) and 'inputSchema' (v5) properties\n // Also handle case where the schema is a function that returns a schema\n let schema =\n this.originalTool.parameters ??\n ('inputSchema' in this.originalTool ? (this.originalTool as any).inputSchema : undefined) ??\n z.object({});\n\n // If schema is a function, call it to get the actual schema\n if (typeof schema === 'function') {\n schema = schema();\n }\n\n return schema;\n }\n\n // For Mastra tools, inputSchema might also be a function\n let schema = this.originalTool.inputSchema;\n\n // If schema is a function, call it to get the actual schema\n if (typeof schema === 'function') {\n schema = schema();\n }\n\n return schema;\n };\n\n private getOutputSchema = () => {\n if ('outputSchema' in this.originalTool) {\n let schema = this.originalTool.outputSchema;\n\n // If schema is a function, call it to get the actual schema\n if (typeof schema === 'function') {\n schema = schema();\n }\n\n return schema;\n }\n return null;\n };\n\n private getResumeSchema = () => {\n if ('resumeSchema' in this.originalTool) {\n let schema = this.originalTool.resumeSchema;\n\n // If schema is a function, call it to get the actual schema\n if (typeof schema === 'function') {\n schema = schema();\n }\n\n return schema;\n }\n return null;\n };\n\n private getSuspendSchema = () => {\n if ('suspendSchema' in this.originalTool) {\n let schema = this.originalTool.suspendSchema;\n\n // If schema is a function, call it to get the actual schema\n if (typeof schema === 'function') {\n schema = schema();\n }\n\n return schema;\n }\n return null;\n };\n\n // For provider-defined tools, we need to include all required properties\n private buildProviderTool(tool: ToolToConvert): (CoreTool & { id: `${string}.${string}` }) | undefined {\n if (\n 'type' in tool &&\n tool.type === 'provider-defined' &&\n 'id' in tool &&\n typeof tool.id === 'string' &&\n tool.id.includes('.')\n ) {\n // Get schema directly from provider-defined tool (v4 uses parameters, v5 uses inputSchema)\n let parameters: unknown =\n 'parameters' in tool ? tool.parameters : 'inputSchema' in tool ? (tool as any).inputSchema : undefined;\n\n // If schema is a function, call it to get the actual schema\n if (typeof parameters === 'function') {\n parameters = parameters();\n }\n\n // Get output schema directly from provider-defined tool\n let outputSchema: unknown = 'outputSchema' in tool ? (tool as any).outputSchema : undefined;\n\n // If schema is a function, call it to get the actual schema\n if (typeof outputSchema === 'function') {\n outputSchema = outputSchema();\n }\n\n // Convert parameters to AI SDK Schema format\n let processedParameters;\n if (parameters !== undefined && parameters !== null) {\n if (typeof parameters === 'object' && 'jsonSchema' in parameters) {\n // Already in AI SDK Schema format\n processedParameters = parameters;\n } else {\n // Convert Zod schema to AI SDK Schema\n processedParameters = convertZodSchemaToAISDKSchema(parameters as z.ZodType);\n }\n }\n\n // Convert output schema to AI SDK Schema format if present\n let processedOutputSchema;\n if (outputSchema !== undefined && outputSchema !== null) {\n if (typeof outputSchema === 'object' && 'jsonSchema' in outputSchema) {\n // Already in AI SDK Schema format\n processedOutputSchema = outputSchema;\n } else {\n // Convert Zod schema to AI SDK Schema\n processedOutputSchema = convertZodSchemaToAISDKSchema(outputSchema as z.ZodType);\n }\n }\n\n return {\n ...(processedOutputSchema ? { outputSchema: processedOutputSchema } : {}),\n type: 'provider-defined' as const,\n id: tool.id as `${string}.${string}`,\n args: ('args' in this.originalTool ? this.originalTool.args : {}) as Record<string, unknown>,\n description: tool.description,\n parameters: processedParameters,\n execute: this.originalTool.execute\n ? this.createExecute(\n this.originalTool,\n { ...this.options, description: this.originalTool.description },\n this.logType,\n )\n : undefined,\n } as unknown as (CoreTool & { id: `${string}.${string}` }) | undefined;\n }\n\n return undefined;\n }\n\n private createLogMessageOptions({ agentName, toolName, type }: LogOptions): LogMessageOptions {\n // If no agent name, use default format\n if (!agentName) {\n return {\n start: `Executing tool ${toolName}`,\n error: `Failed tool execution`,\n };\n }\n\n const prefix = `[Agent:${agentName}]`;\n const toolType = type === 'toolset' ? 'toolset' : 'tool';\n\n return {\n start: `${prefix} - Executing ${toolType} ${toolName}`,\n error: `${prefix} - Failed ${toolType} execution`,\n };\n }\n\n private createExecute(\n tool: ToolToConvert,\n options: ToolOptions,\n logType?: 'tool' | 'toolset' | 'client-tool',\n processedSchema?: z.ZodTypeAny,\n ) {\n // dont't add memory or mastra to logging\n const { logger, mastra: _mastra, memory: _memory, requestContext, model, ...rest } = options;\n const logModelObject = {\n modelId: model?.modelId,\n provider: model?.provider,\n specificationVersion: model?.specificationVersion,\n };\n\n const { start, error } = this.createLogMessageOptions({\n agentName: options.agentName,\n toolName: options.name,\n type: logType,\n });\n\n const execFunction = async (args: unknown, execOptions: MastraToolInvocationOptions) => {\n // Prefer execution-time tracingContext (passed at runtime for VNext methods)\n // Fall back to build-time context for Legacy methods (AI SDK v4 doesn't support passing custom options)\n const tracingContext = execOptions.tracingContext || options.tracingContext;\n\n // Create tool span if we have a current span available\n const toolSpan = tracingContext?.currentSpan?.createChildSpan({\n type: SpanType.TOOL_CALL,\n name: `tool: '${options.name}'`,\n input: args,\n attributes: {\n toolId: options.name,\n toolDescription: options.description,\n toolType: logType || 'tool',\n },\n tracingPolicy: options.tracingPolicy,\n });\n\n try {\n let result;\n let suspendData = null;\n\n if (isVercelTool(tool)) {\n // Handle Vercel tools (AI SDK tools)\n result = await executeWithContext({\n span: toolSpan,\n fn: async () => tool?.execute?.(args, execOptions as ToolExecutionOptions),\n });\n } else {\n // Handle Mastra tools - wrap mastra instance with tracing context for context propagation\n\n /**\n * MASTRA INSTANCE TYPES IN TOOL EXECUTION:\n *\n * Full Mastra & MastraPrimitives (has getAgent, getWorkflow, etc.):\n * - Auto-generated workflow tools from agent.listWorkflows()\n * - These get this.#mastra directly and can be wrapped\n *\n * MastraPrimitives only (limited interface):\n * - Memory tools (from memory.listTools())\n * - Assigned tools (agent.tools)\n * - Toolset tools (from toolsets)\n * - Client tools (passed as tools in generate/stream options)\n * - These get mastraProxy and have limited functionality\n *\n * TODO: Consider providing full Mastra instance to more tool types for enhanced functionality\n */\n // Wrap mastra with tracing context - wrapMastra will handle whether it's a full instance or primitives\n const wrappedMastra = options.mastra ? wrapMastra(options.mastra, { currentSpan: toolSpan }) : options.mastra;\n\n const resumeSchema = this.getResumeSchema();\n // Pass raw args as first parameter, context as second\n // Properly structure context based on execution source\n const baseContext = {\n threadId: options.threadId,\n resourceId: options.resourceId,\n mastra: wrappedMastra,\n memory: options.memory,\n runId: options.runId,\n requestContext: options.requestContext ?? new RequestContext(),\n writer: new ToolStream(\n {\n prefix: 'tool',\n callId: execOptions.toolCallId,\n name: options.name,\n runId: options.runId!,\n },\n options.outputWriter || execOptions.outputWriter,\n ),\n tracingContext: { currentSpan: toolSpan },\n abortSignal: execOptions.abortSignal,\n suspend: (args: any, suspendOptions?: SuspendOptions) => {\n suspendData = args;\n const newSuspendOptions = {\n ...(suspendOptions ?? {}),\n resumeSchema: suspendOptions?.resumeSchema ?? resumeSchema,\n };\n return execOptions.suspend?.(args, newSuspendOptions);\n },\n resumeData: execOptions.resumeData,\n };\n\n // Check if this is agent execution\n // Agent execution takes precedence over workflow execution because agents may\n // use workflows internally for their agentic loop\n // Note: AI SDK v4 doesn't pass toolCallId/messages, so we also check for agentName and threadId\n const isAgentExecution =\n (execOptions.toolCallId && execOptions.messages) ||\n (options.agentName && options.threadId && !options.workflowId);\n\n // Check if this is workflow execution (has workflow properties in options)\n // Only consider it workflow execution if it's NOT agent execution\n const isWorkflowExecution = !isAgentExecution && (options.workflow || options.workflowId);\n\n let toolContext;\n if (isAgentExecution) {\n // Nest agent-specific properties under 'agent' key\n // Do NOT include workflow context even if workflow properties exist\n // (agents use workflows internally but tools should see agent context)\n const { suspend, resumeData, threadId, resourceId, ...restBaseContext } = baseContext;\n toolContext = {\n ...restBaseContext,\n agent: {\n toolCallId: execOptions.toolCallId || '',\n messages: execOptions.messages || [],\n suspend,\n resumeData,\n threadId,\n resourceId,\n outputWriter: execOptions.outputWriter,\n },\n };\n } else if (isWorkflowExecution) {\n // Nest workflow-specific properties under 'workflow' key\n const { suspend, resumeData, ...restBaseContext } = baseContext;\n toolContext = {\n ...restBaseContext,\n workflow: options.workflow || {\n runId: options.runId,\n workflowId: options.workflowId,\n state: options.state,\n setState: options.setState,\n suspend,\n resumeData,\n },\n };\n } else if (execOptions.mcp) {\n // MCP execution context\n toolContext = {\n ...baseContext,\n mcp: execOptions.mcp,\n };\n } else {\n // Direct execution or unknown context\n toolContext = baseContext;\n }\n\n const resumeData = execOptions.resumeData;\n\n if (resumeData) {\n const resumeValidation = validateToolInput(resumeSchema, resumeData, options.name);\n if (resumeValidation.error) {\n logger?.warn(resumeValidation.error.message);\n toolSpan?.end({ output: resumeValidation.error });\n return resumeValidation.error as any;\n }\n }\n\n result = await executeWithContext({ span: toolSpan, fn: async () => tool?.execute?.(args, toolContext) });\n }\n\n if (suspendData) {\n const suspendSchema = this.getSuspendSchema();\n const suspendValidation = validateToolSuspendData(suspendSchema, suspendData, options.name);\n if (suspendValidation.error) {\n logger?.warn(suspendValidation.error.message);\n toolSpan?.end({ output: suspendValidation.error });\n return suspendValidation.error as any;\n }\n }\n\n // Skip validation if suspend was called without a result\n const shouldSkipValidation = typeof result === 'undefined' && !!suspendData;\n if (shouldSkipValidation) {\n toolSpan?.end({ output: result });\n return result;\n }\n\n // Validate output for Vercel/AI SDK tools which don't have built-in validation\n // Mastra tools handle their own validation in Tool.execute() which properly\n // applies Zod transforms (e.g., .transform(), .pipe()) to the output\n if (isVercelTool(tool)) {\n const outputSchema = this.getOutputSchema();\n const outputValidation = validateToolOutput(outputSchema, result, options.name, false);\n if (outputValidation.error) {\n logger?.warn(outputValidation.error.message);\n toolSpan?.end({ output: outputValidation.error });\n return outputValidation.error;\n }\n result = outputValidation.data;\n }\n\n // Return result (validated for Vercel tools, already validated for Mastra tools)\n toolSpan?.end({ output: result });\n return result;\n } catch (error) {\n toolSpan?.error({ error: error as Error });\n throw error;\n }\n };\n\n return async (args: unknown, execOptions?: MastraToolInvocationOptions) => {\n let logger = options.logger || this.logger;\n try {\n logger.debug(start, { ...rest, model: logModelObject, args });\n\n // Validate input parameters if schema exists\n // Use the processed schema for validation if available, otherwise fall back to original\n const parameters = processedSchema || this.getParameters();\n const { data, error } = validateToolInput(parameters, args, options.name);\n if (error) {\n logger.warn(error.message);\n return error;\n }\n // Use validated/transformed data\n args = data;\n\n // there is a small delay in stream output so we add an immediate to ensure the stream is ready\n return await new Promise((resolve, reject) => {\n setImmediate(async () => {\n try {\n const result = await execFunction(args, execOptions!);\n resolve(result);\n } catch (err) {\n reject(err);\n }\n });\n });\n } catch (err) {\n const mastraError = new MastraError(\n {\n id: 'TOOL_EXECUTION_FAILED',\n domain: ErrorDomain.TOOL,\n category: ErrorCategory.USER,\n details: {\n errorMessage: String(error),\n argsJson: JSON.stringify(args),\n model: model?.modelId ?? '',\n },\n },\n err,\n );\n logger.trackException(mastraError);\n logger.error(error, { ...rest, model: logModelObject, error: mastraError, args });\n return mastraError;\n }\n };\n }\n\n buildV5() {\n const builtTool = this.build();\n\n if (!builtTool.parameters) {\n throw new Error('Tool parameters are required');\n }\n\n const base = {\n ...builtTool,\n inputSchema: builtTool.parameters,\n onInputStart: 'onInputStart' in this.originalTool ? this.originalTool.onInputStart : undefined,\n onInputDelta: 'onInputDelta' in this.originalTool ? this.originalTool.onInputDelta : undefined,\n onInputAvailable: 'onInputAvailable' in this.originalTool ? this.originalTool.onInputAvailable : undefined,\n onOutput: 'onOutput' in this.originalTool ? this.originalTool.onOutput : undefined,\n };\n\n // For provider-defined tools, exclude execute and add name as per v5 spec\n if (builtTool.type === 'provider-defined') {\n const { execute, parameters, ...rest } = base;\n const name = builtTool.id.split('.')[1] || builtTool.id;\n return {\n ...rest,\n type: builtTool.type,\n id: builtTool.id,\n name,\n args: builtTool.args,\n } as VercelToolV5;\n }\n\n return base as VercelToolV5;\n }\n\n build(): CoreTool {\n const providerTool = this.buildProviderTool(this.originalTool);\n if (providerTool) {\n return providerTool;\n }\n\n const model = this.options.model;\n\n const schemaCompatLayers = [];\n\n if (model) {\n // Respect the model's own capability flag; do not disable it based solely on specificationVersion.\n const supportsStructuredOutputs =\n 'supportsStructuredOutputs' in model ? (model.supportsStructuredOutputs ?? false) : false;\n\n const modelInfo = {\n modelId: model.modelId,\n supportsStructuredOutputs,\n provider: model.provider,\n };\n\n schemaCompatLayers.push(\n new OpenAIReasoningSchemaCompatLayer(modelInfo),\n new OpenAISchemaCompatLayer(modelInfo),\n new GoogleSchemaCompatLayer(modelInfo),\n new AnthropicSchemaCompatLayer(modelInfo),\n new DeepSeekSchemaCompatLayer(modelInfo),\n new MetaSchemaCompatLayer(modelInfo),\n );\n }\n\n // Apply schema compatibility to get both the transformed Zod schema (for validation)\n // and the AI SDK Schema (for the LLM)\n let processedZodSchema: z.ZodTypeAny | undefined;\n let processedSchema;\n\n const originalSchema = this.getParameters();\n\n // Find the first applicable compatibility layer\n const applicableLayer = schemaCompatLayers.find(layer => layer.shouldApply());\n\n if (applicableLayer && originalSchema) {\n // Get the transformed Zod schema (with constraints removed/modified)\n processedZodSchema = applicableLayer.processZodType(originalSchema);\n // Convert to AI SDK Schema for the LLM\n processedSchema = applyCompatLayer({\n schema: originalSchema,\n compatLayers: schemaCompatLayers,\n mode: 'aiSdkSchema',\n });\n } else if (originalSchema) {\n // No compatibility layer applies, use original schema\n processedZodSchema = originalSchema;\n processedSchema = applyCompatLayer({\n schema: originalSchema,\n compatLayers: schemaCompatLayers,\n mode: 'aiSdkSchema',\n });\n } else {\n // No schema to process, set to undefined\n processedZodSchema = undefined;\n processedSchema = undefined;\n }\n\n let processedOutputSchema;\n\n if (this.getOutputSchema()) {\n // Don't add any compat layers to outputSchema since it's never sent to the LLM\n processedOutputSchema = applyCompatLayer({\n schema: this.getOutputSchema(),\n compatLayers: [],\n mode: 'aiSdkSchema',\n });\n }\n\n const definition = {\n type: 'function' as const,\n description: this.originalTool.description,\n requireApproval: this.options.requireApproval,\n hasSuspendSchema: !!this.getSuspendSchema(),\n execute: this.originalTool.execute\n ? this.createExecute(\n this.originalTool,\n { ...this.options, description: this.originalTool.description },\n this.logType,\n processedZodSchema, // Pass the processed Zod schema for validation\n )\n : undefined,\n };\n\n return {\n ...definition,\n id: 'id' in this.originalTool ? this.originalTool.id : undefined,\n parameters: processedSchema ?? z.object({}),\n outputSchema: processedOutputSchema,\n providerOptions: 'providerOptions' in this.originalTool ? this.originalTool.providerOptions : undefined,\n } as unknown as CoreTool;\n }\n}\n","import { createHash } from 'node:crypto';\nimport type { CoreMessage } from '@internal/ai-sdk-v4';\nimport { jsonSchemaToZod } from '@mastra/schema-compat/json-to-zod';\nimport { z } from 'zod';\nimport type { MastraPrimitives } from './action';\nimport type { ToolsInput } from './agent';\nimport type { MastraLanguageModel, MastraLegacyLanguageModel } from './llm/model/shared.types';\nimport type { IMastraLogger } from './logger';\nimport type { Mastra } from './mastra';\nimport type { AiMessageType, MastraMemory } from './memory';\nimport type { TracingContext, TracingPolicy } from './observability';\nimport type { RequestContext } from './request-context';\nimport type { CoreTool, VercelTool, VercelToolV5 } from './tools';\nimport { CoreToolBuilder } from './tools/tool-builder/builder';\nimport type { ToolToConvert } from './tools/tool-builder/builder';\nimport { isVercelTool } from './tools/toolchecks';\nimport type { OutputWriter } from './workflows/types';\n\nexport const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));\n\n/**\n * Deep merges two objects, recursively merging nested objects and arrays\n */\nexport function deepMerge<T extends object = object>(target: T, source: Partial<T>): T {\n const output = { ...target };\n\n if (!source) return output;\n\n Object.keys(source).forEach(key => {\n const targetValue = output[key as keyof T];\n const sourceValue = source[key as keyof T];\n\n if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {\n (output as any)[key] = sourceValue;\n } else if (\n sourceValue instanceof Object &&\n targetValue instanceof Object &&\n !Array.isArray(sourceValue) &&\n !Array.isArray(targetValue)\n ) {\n (output as any)[key] = deepMerge(targetValue, sourceValue as T);\n } else if (sourceValue !== undefined) {\n (output as any)[key] = sourceValue;\n }\n });\n\n return output;\n}\n\nexport function generateEmptyFromSchema(schema: string) {\n try {\n const parsedSchema = JSON.parse(schema);\n if (!parsedSchema || parsedSchema.type !== 'object' || !parsedSchema.properties) return {};\n const obj: Record<string, any> = {};\n const TYPE_DEFAULTS = {\n string: '',\n array: [],\n object: {},\n number: 0,\n integer: 0,\n boolean: false,\n };\n for (const [key, prop] of Object.entries<any>(parsedSchema.properties)) {\n obj[key] = TYPE_DEFAULTS[prop.type as keyof typeof TYPE_DEFAULTS] ?? null;\n }\n return obj;\n } catch {\n return {};\n }\n}\n\nexport interface TagMaskOptions {\n /** Called when masking begins */\n onStart?: () => void;\n /** Called when masking ends */\n onEnd?: () => void;\n /** Called for each chunk that is masked */\n onMask?: (chunk: string) => void;\n}\n\n/**\n * Transforms a stream by masking content between XML tags.\n * @param stream Input stream to transform\n * @param tag Tag name to mask between (e.g. for <foo>...</foo>, use 'foo')\n * @param options Optional configuration for masking behavior\n */\nexport async function* maskStreamTags(\n stream: AsyncIterable<string>,\n tag: string,\n options: TagMaskOptions = {},\n): AsyncIterable<string> {\n const { onStart, onEnd, onMask } = options;\n const openTag = `<${tag}>`;\n const closeTag = `</${tag}>`;\n\n let buffer = '';\n let fullContent = '';\n let isMasking = false;\n let isBuffering = false;\n\n // used for checking in chunks that include tags or partial tags + some other non-tag text\n // eg: \"o <tag_name\" or \"name> w\", can trim before-start to get \"<tag_name\" or after-end to get \"name>\"\n const trimOutsideDelimiter = (text: string, delimiter: string, trim: 'before-start' | 'after-end') => {\n if (!text.includes(delimiter)) {\n return text;\n }\n\n const parts = text.split(delimiter);\n\n if (trim === `before-start`) {\n return `${delimiter}${parts[1]}`;\n }\n\n return `${parts[0]}${delimiter}`;\n };\n\n // Helper to check if text starts with pattern (ignoring whitespace)\n // When checking partial tags: startsWith(buffer, openTag) checks if buffer could be start of tag\n // When checking full tags: startsWith(chunk, openTag) checks if chunk starts with full tag\n const startsWith = (text: string, pattern: string) => {\n // check start of opening tag\n if (pattern.includes(openTag.substring(0, 3))) {\n // our pattern for checking the start is always based on xml-like tags\n // if the pattern looks like our opening tag and the pattern also includes\n // some other chunked text before it, we just wanted to check the xml part of the pattern\n pattern = trimOutsideDelimiter(pattern, `<`, `before-start`);\n }\n\n return text.trim().startsWith(pattern.trim());\n };\n\n for await (const chunk of stream) {\n fullContent += chunk;\n\n if (isBuffering) buffer += chunk;\n\n const chunkHasTag = startsWith(chunk, openTag);\n const bufferHasTag = !chunkHasTag && isBuffering && startsWith(openTag, buffer);\n\n let toYieldBeforeMaskedStartTag = ``;\n // Check if we should start masking chunks\n if (!isMasking && (chunkHasTag || bufferHasTag)) {\n isMasking = true;\n isBuffering = false;\n\n // check if the buffered text includes text before the start tag. ex \"o <tag_name\", \"o\" should be yielded and not masked\n const taggedTextToMask = trimOutsideDelimiter(buffer, `<`, `before-start`);\n if (taggedTextToMask !== buffer.trim()) {\n toYieldBeforeMaskedStartTag = buffer.replace(taggedTextToMask, ``);\n }\n\n buffer = '';\n onStart?.();\n }\n\n // Check if we should start buffering (looks like part of the opening tag but it's not the full <tag> yet eg <ta - could be <table> but we don't know yet)\n if (!isMasking && !isBuffering && startsWith(openTag, chunk) && chunk.trim() !== '') {\n isBuffering = true;\n buffer += chunk;\n continue;\n }\n\n // We're buffering, need to check again if our buffer has deviated from the opening <tag> eg <tag2>\n if (isBuffering && buffer && !startsWith(openTag, buffer)) {\n yield buffer;\n buffer = '';\n isBuffering = false;\n continue;\n }\n\n // Check if we should stop masking chunks (since the content includes the closing </tag>)\n if (isMasking && fullContent.includes(closeTag)) {\n onMask?.(chunk);\n onEnd?.();\n isMasking = false;\n const lastFullContent = fullContent;\n fullContent = ``; // reset to handle streams with multiple full tags that have text inbetween\n\n // check to see if we have a partial chunk outside the close tag. if we do we need to yield it so it isn't swallowed with the masked text\n const textUntilEndTag = trimOutsideDelimiter(lastFullContent, closeTag, 'after-end');\n if (textUntilEndTag !== lastFullContent) {\n yield lastFullContent.replace(textUntilEndTag, ``);\n }\n\n continue;\n }\n\n // We're currently masking chunks inside a <tag>\n if (isMasking) {\n onMask?.(chunk);\n // in the case that there was a chunk that included a tag to mask and some other text, ex \"o <tag_name\" we need to still yield the\n // text before the tag (\"o \") so it's not swallowed with the masked text\n if (toYieldBeforeMaskedStartTag) {\n yield toYieldBeforeMaskedStartTag;\n }\n continue;\n }\n\n // default yield the chunk\n yield chunk;\n }\n}\n\n/**\n * Resolve serialized zod output - This function takes the string output ot the `jsonSchemaToZod` function\n * and instantiates the zod object correctly.\n *\n * @param schema - serialized zod object\n * @returns resolved zod object\n */\nexport function resolveSerializedZodOutput(schema: string): z.ZodType {\n // Creates and immediately executes a new function that takes 'z' as a parameter\n // The function body is a string that returns the serialized zod schema\n // When executed with the 'z' parameter, it reconstructs the zod schema in the current context\n return Function('z', `\"use strict\";return (${schema});`)(z);\n}\n\nexport interface ToolOptions {\n name: string;\n runId?: string;\n threadId?: string;\n resourceId?: string;\n logger?: IMastraLogger;\n description?: string;\n mastra?: (Mastra & MastraPrimitives) | MastraPrimitives;\n requestContext: RequestContext;\n /** Build-time tracing context (fallback for Legacy methods that can't pass request context) */\n tracingContext?: TracingContext;\n tracingPolicy?: TracingPolicy;\n memory?: MastraMemory;\n agentName?: string;\n model?: MastraLanguageModel | MastraLegacyLanguageModel;\n /**\n * Optional async writer used to stream tool output chunks back to the caller. Tools should treat this as fire-and-forget I/O.\n */\n outputWriter?: OutputWriter;\n requireApproval?: boolean;\n // Workflow-specific properties\n workflow?: any;\n workflowId?: string;\n state?: any;\n setState?: (state: any) => void;\n}\n\n/**\n * Checks if a value is a Zod type\n * @param value - The value to check\n * @returns True if the value is a Zod type, false otherwise\n */\nexport function isZodType(value: unknown): value is z.ZodType {\n // Check if it's a Zod schema by looking for common Zod properties and methods\n return (\n typeof value === 'object' &&\n value !== null &&\n '_def' in value &&\n 'parse' in value &&\n typeof (value as any).parse === 'function' &&\n 'safeParse' in value &&\n typeof (value as any).safeParse === 'function'\n );\n}\n\n// Helper function to create a deterministic hash\nfunction createDeterministicId(input: string): string {\n return createHash('sha256').update(input).digest('hex').slice(0, 8); // Take first 8 characters for a shorter but still unique ID\n}\n\n/**\n * Sets the properties for a Vercel Tool, including an ID and inputSchema\n * @param tool - The tool to set the properties for\n * @returns The tool with the properties set\n */\nfunction setVercelToolProperties(tool: VercelTool) {\n // Check if the tool already has inputSchema (v5 format)\n // If it does, use it directly (it might be a function)\n // Otherwise, convert the parameters to inputSchema\n const inputSchema = 'inputSchema' in tool ? tool.inputSchema : convertVercelToolParameters(tool);\n\n const toolId = !('id' in tool)\n ? tool.description\n ? `tool-${createDeterministicId(tool.description)}`\n : `tool-${Math.random().toString(36).substring(2, 9)}`\n : tool.id;\n\n return {\n ...tool,\n id: toolId,\n inputSchema,\n };\n}\n\n/**\n * Ensures a tool has an ID and inputSchema by generating one if not present\n * @param tool - The tool to ensure has an ID and inputSchema\n * @returns The tool with an ID and inputSchema\n */\nexport function ensureToolProperties(tools: ToolsInput): ToolsInput {\n const toolsWithProperties = Object.keys(tools).reduce<ToolsInput>((acc, key) => {\n const tool = tools?.[key];\n if (tool) {\n if (isVercelTool(tool)) {\n acc[key] = setVercelToolProperties(tool) as VercelTool;\n } else {\n acc[key] = tool;\n }\n }\n return acc;\n }, {});\n\n return toolsWithProperties;\n}\n\nfunction convertVercelToolParameters(tool: VercelTool): z.ZodType {\n // If the tool is a Vercel Tool, check if the parameters are already a zod object\n // If not, convert the parameters to a zod object using jsonSchemaToZod\n // Handle case where parameters (or inputSchema in v5) is a function that returns a schema\n let schema = tool.parameters ?? z.object({});\n\n // If schema is a function, call it to get the actual schema\n if (typeof schema === 'function') {\n schema = schema();\n }\n\n return isZodType(schema) ? schema : resolveSerializedZodOutput(jsonSchemaToZod(schema));\n}\n\n/**\n * Converts a Vercel Tool or Mastra Tool into a CoreTool format\n * @param originalTool - The tool to convert (either VercelTool or ToolAction)\n * @param options - Tool options including Mastra-specific settings\n * @param logType - Type of tool to log (tool or toolset)\n * @returns A CoreTool that can be used by the system\n */\nexport function makeCoreTool(\n originalTool: ToolToConvert,\n options: ToolOptions,\n logType?: 'tool' | 'toolset' | 'client-tool',\n autoResumeSuspendedTools?: boolean,\n): CoreTool {\n return new CoreToolBuilder({ originalTool, options, logType, autoResumeSuspendedTools }).build();\n}\n\nexport function makeCoreToolV5(\n originalTool: ToolToConvert,\n options: ToolOptions,\n logType?: 'tool' | 'toolset' | 'client-tool',\n autoResumeSuspendedTools?: boolean,\n): VercelToolV5 {\n return new CoreToolBuilder({ originalTool, options, logType, autoResumeSuspendedTools }).buildV5();\n}\n\n/**\n * Creates a proxy for a Mastra instance to handle deprecated properties\n * @param mastra - The Mastra instance to proxy\n * @param logger - The logger to use for warnings\n * @returns A proxy for the Mastra instance\n */\nexport function createMastraProxy({ mastra, logger }: { mastra: Mastra; logger: IMastraLogger }) {\n return new Proxy(mastra, {\n get(target, prop) {\n const hasProp = Reflect.has(target, prop);\n\n if (hasProp) {\n const value = Reflect.get(target, prop);\n const isFunction = typeof value === 'function';\n if (isFunction) {\n return value.bind(target);\n }\n return value;\n }\n\n if (prop === 'logger') {\n logger.warn(`Please use 'getLogger' instead, logger is deprecated`);\n return Reflect.apply(target.getLogger, target, []);\n }\n\n if (prop === 'storage') {\n logger.warn(`Please use 'getStorage' instead, storage is deprecated`);\n return Reflect.get(target, 'storage');\n }\n\n if (prop === 'agents') {\n logger.warn(`Please use 'listAgents' instead, agents is deprecated`);\n return Reflect.apply(target.listAgents, target, []);\n }\n\n if (prop === 'tts') {\n logger.warn(`Please use 'getTTS' instead, tts is deprecated`);\n return Reflect.apply(target.getTTS, target, []);\n }\n\n if (prop === 'vectors') {\n logger.warn(`Please use 'getVectors' instead, vectors is deprecated`);\n return Reflect.apply(target.getVectors, target, []);\n }\n\n if (prop === 'memory') {\n logger.warn(`Please use 'getMemory' instead, memory is deprecated`);\n return Reflect.get(target, 'memory');\n }\n\n return Reflect.get(target, prop);\n },\n });\n}\n\nexport function checkEvalStorageFields(traceObject: any, logger?: IMastraLogger) {\n const missingFields = [];\n if (!traceObject.input) missingFields.push('input');\n if (!traceObject.output) missingFields.push('output');\n if (!traceObject.agentName) missingFields.push('agent_name');\n if (!traceObject.metricName) missingFields.push('metric_name');\n if (!traceObject.instructions) missingFields.push('instructions');\n if (!traceObject.globalRunId) missingFields.push('global_run_id');\n if (!traceObject.runId) missingFields.push('run_id');\n\n if (missingFields.length > 0) {\n if (logger) {\n logger.warn('Skipping evaluation storage due to missing required fields', {\n missingFields,\n runId: traceObject.runId,\n agentName: traceObject.agentName,\n });\n } else {\n console.warn('Skipping evaluation storage due to missing required fields', {\n missingFields,\n runId: traceObject.runId,\n agentName: traceObject.agentName,\n });\n }\n return false;\n }\n\n return true;\n}\n\n// lifted from https://github.com/vercel/ai/blob/main/packages/ai/core/prompt/detect-prompt-type.ts#L27\nfunction detectSingleMessageCharacteristics(\n message: any,\n): 'has-ui-specific-parts' | 'has-core-specific-parts' | 'message' | 'other' {\n if (\n typeof message === 'object' &&\n message !== null &&\n (message.role === 'function' || // UI-only role\n message.role === 'data' || // UI-only role\n 'toolInvocations' in message || // UI-specific field\n 'parts' in message || // UI-specific field\n 'experimental_attachments' in message)\n ) {\n return 'has-ui-specific-parts';\n } else if (\n typeof message === 'object' &&\n message !== null &&\n 'content' in message &&\n (Array.isArray(message.content) || // Core messages can have array content\n 'experimental_providerMetadata' in message ||\n 'providerOptions' in message)\n ) {\n return 'has-core-specific-parts';\n } else if (\n typeof message === 'object' &&\n message !== null &&\n 'role' in message &&\n 'content' in message &&\n typeof message.content === 'string' &&\n ['system', 'user', 'assistant', 'tool'].includes(message.role)\n ) {\n return 'message';\n } else {\n return 'other';\n }\n}\n\nexport function isUiMessage(message: CoreMessage | AiMessageType): message is AiMessageType {\n return detectSingleMessageCharacteristics(message) === `has-ui-specific-parts`;\n}\nexport function isCoreMessage(message: CoreMessage | AiMessageType): message is CoreMessage {\n return [`has-core-specific-parts`, `message`].includes(detectSingleMessageCharacteristics(message));\n}\n\n/** Represents a validated SQL identifier (e.g., table or column name). */\ntype SqlIdentifier = string & { __brand: 'SqlIdentifier' };\n/** Represents a validated dot-separated SQL field key. */\ntype FieldKey = string & { __brand: 'FieldKey' };\n\nconst SQL_IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\n\n/**\n * Parses and returns a valid SQL identifier (such as a table or column name).\n * The identifier must:\n * - Start with a letter (a-z, A-Z) or underscore (_)\n * - Contain only letters, numbers, or underscores\n * - Be at most 63 characters long\n *\n * @param name - The identifier string to parse.\n * @param kind - Optional label for error messages (e.g., 'table name').\n * @returns The validated identifier as a branded type.\n * @throws {Error} If the identifier does not conform to SQL naming rules.\n *\n * @example\n * const id = parseSqlIdentifier('my_table'); // Ok\n * parseSqlIdentifier('123table'); // Throws error\n */\nexport function parseSqlIdentifier(name: string, kind = 'identifier'): SqlIdentifier {\n if (!SQL_IDENTIFIER_PATTERN.test(name) || name.length > 63) {\n throw new Error(\n `Invalid ${kind}: ${name}. Must start with a letter or underscore, contain only letters, numbers, or underscores, and be at most 63 characters long.`,\n );\n }\n return name as SqlIdentifier;\n}\n\n/**\n * Parses and returns a valid dot-separated SQL field key (e.g., 'user.profile.name').\n * Each segment must:\n * - Start with a letter (a-z, A-Z) or underscore (_)\n * - Contain only letters, numbers, or underscores\n * - Be at most 63 characters long\n *\n * @param key - The dot-separated field key string to parse.\n * @returns The validated field key as a branded type.\n * @throws {Error} If any segment of the key is invalid.\n *\n * @example\n * const key = parseFieldKey('user_profile.name'); // Ok\n * parseFieldKey('user..name'); // Throws error\n * parseFieldKey('user.123name'); // Throws error\n */\nexport function parseFieldKey(key: string): FieldKey {\n if (!key) throw new Error('Field key cannot be empty');\n const segments = key.split('.');\n for (const segment of segments) {\n if (!SQL_IDENTIFIER_PATTERN.test(segment) || segment.length > 63) {\n throw new Error(`Invalid field key segment: ${segment} in ${key}`);\n }\n }\n return key as FieldKey;\n}\n\n/**\n * Performs a fetch request with automatic retries using exponential backoff\n * @param url The URL to fetch from\n * @param options Standard fetch options\n * @param maxRetries Maximum number of retry attempts\n * @param validateResponse Optional function to validate the response beyond HTTP status\n * @returns The fetch Response if successful\n */\nexport async function fetchWithRetry(\n url: string,\n options: RequestInit = {},\n maxRetries: number = 3,\n): Promise<Response> {\n let retryCount = 0;\n let lastError: Error | null = null;\n\n while (retryCount < maxRetries) {\n try {\n const response = await fetch(url, options);\n\n if (!response.ok) {\n throw new Error(`Request failed with status: ${response.status} ${response.statusText}`);\n }\n\n return response;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n retryCount++;\n\n if (retryCount >= maxRetries) {\n break;\n }\n\n const delay = Math.min(1000 * Math.pow(2, retryCount) * 1000, 10000);\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n throw lastError || new Error('Request failed after multiple retry attempts');\n}\n\n/**\n * Removes specific keys from an object.\n * @param obj - The original object\n * @param keysToOmit - Keys to exclude from the returned object\n * @returns A new object with the specified keys removed\n */\nexport function omitKeys<T extends Record<string, any>>(obj: T, keysToOmit: string[]): Partial<T> {\n return Object.fromEntries(Object.entries(obj).filter(([key]) => !keysToOmit.includes(key))) as Partial<T>;\n}\n\n/**\n * Selectively extracts specific fields from an object using dot notation.\n * Does not error if fields don't exist - simply omits them from the result.\n * @param obj - The source object to extract fields from\n * @param fields - Array of field paths (supports dot notation like 'output.text')\n * @returns New object containing only the specified fields\n */\nexport function selectFields(obj: any, fields: string[]): any {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n const result: any = {};\n\n for (const field of fields) {\n const value = getNestedValue(obj, field);\n if (value !== undefined) {\n setNestedValue(result, field, value);\n }\n }\n\n return result;\n}\n\n/**\n * Gets a nested value from an object using dot notation\n * @param obj - Source object\n * @param path - Dot notation path (e.g., 'output.text')\n * @returns The value at the path, or undefined if not found\n */\nexport function getNestedValue(obj: any, path: string): any {\n return path.split('.').reduce((current, key) => {\n return current && typeof current === 'object' ? current[key] : undefined;\n }, obj);\n}\n\n/**\n * Sets a nested value in an object using dot notation\n * @param obj - Target object\n * @param path - Dot notation path (e.g., 'output.text')\n * @param value - Value to set\n */\nexport function setNestedValue(obj: any, path: string, value: any): void {\n const keys = path.split('.');\n const lastKey = keys.pop();\n if (!lastKey) {\n return;\n }\n\n const target = keys.reduce((current, key) => {\n if (!current[key] || typeof current[key] !== 'object') {\n current[key] = {};\n }\n return current[key];\n }, obj);\n\n target[lastKey] = value;\n}\n\nexport const removeUndefinedValues = (obj: Record<string, any>) => {\n return Object.fromEntries(Object.entries(obj).filter(([_, value]) => value !== undefined));\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkJAGQZZ43_cjs = require('./chunk-JAGQZZ43.cjs');
|
|
4
|
+
var chunk53SZJCBX_cjs = require('./chunk-53SZJCBX.cjs');
|
|
5
|
+
var chunkHWMMIRIF_cjs = require('./chunk-HWMMIRIF.cjs');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
13
13
|
this.originalPromptObjects = originalPromptObjects;
|
|
14
14
|
this.#mastra = mastra;
|
|
15
15
|
if (!this.config.id) {
|
|
16
|
-
throw new
|
|
16
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
17
17
|
id: "MASTR_SCORER_FAILED_TO_CREATE_MISSING_ID",
|
|
18
18
|
domain: "SCORER" /* SCORER */,
|
|
19
19
|
category: "USER" /* USER */,
|
|
@@ -130,7 +130,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
130
130
|
}
|
|
131
131
|
async run(input) {
|
|
132
132
|
if (!this.hasGenerateScore) {
|
|
133
|
-
throw new
|
|
133
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
134
134
|
id: "MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE",
|
|
135
135
|
domain: "SCORER" /* SCORER */,
|
|
136
136
|
category: "USER" /* USER */,
|
|
@@ -156,7 +156,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
156
156
|
tracingContext
|
|
157
157
|
});
|
|
158
158
|
if (workflowResult.status === "failed") {
|
|
159
|
-
throw new
|
|
159
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
160
160
|
id: "MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED",
|
|
161
161
|
domain: "SCORER" /* SCORER */,
|
|
162
162
|
category: "USER" /* USER */,
|
|
@@ -185,7 +185,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
185
185
|
}
|
|
186
186
|
toMastraWorkflow() {
|
|
187
187
|
const workflowSteps = this.steps.map((scorerStep) => {
|
|
188
|
-
return
|
|
188
|
+
return chunkJAGQZZ43_cjs.createStep({
|
|
189
189
|
id: scorerStep.name,
|
|
190
190
|
description: `Scorer step: ${scorerStep.name}`,
|
|
191
191
|
inputSchema: zod.z.any(),
|
|
@@ -218,7 +218,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
});
|
|
221
|
-
const workflow =
|
|
221
|
+
const workflow = chunkJAGQZZ43_cjs.createWorkflow({
|
|
222
222
|
id: `scorer-${this.config.id ?? this.config.name}`,
|
|
223
223
|
description: this.config.description,
|
|
224
224
|
inputSchema: zod.z.object({
|
|
@@ -269,7 +269,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
269
269
|
const modelConfig = originalStep.judge?.model ?? this.config.judge?.model;
|
|
270
270
|
const instructions = originalStep.judge?.instructions ?? this.config.judge?.instructions;
|
|
271
271
|
if (!modelConfig || !instructions) {
|
|
272
|
-
throw new
|
|
272
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
273
273
|
id: "MASTR_SCORER_FAILED_TO_RUN_MISSING_MODEL_OR_INSTRUCTIONS",
|
|
274
274
|
domain: "SCORER" /* SCORER */,
|
|
275
275
|
category: "USER" /* USER */,
|
|
@@ -280,8 +280,8 @@ var MastraScorer = class _MastraScorer {
|
|
|
280
280
|
}
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
|
-
const resolvedModel = await
|
|
284
|
-
const judge = new
|
|
283
|
+
const resolvedModel = await chunk53SZJCBX_cjs.resolveModelConfig(modelConfig, void 0, this.#mastra);
|
|
284
|
+
const judge = new chunkJAGQZZ43_cjs.Agent({
|
|
285
285
|
id: "judge",
|
|
286
286
|
name: "judge",
|
|
287
287
|
model: resolvedModel,
|
|
@@ -291,8 +291,8 @@ var MastraScorer = class _MastraScorer {
|
|
|
291
291
|
if (scorerStep.name === "generateScore") {
|
|
292
292
|
const schema = zod.z.object({ score: zod.z.number() });
|
|
293
293
|
let result;
|
|
294
|
-
if (resolvedModel
|
|
295
|
-
result = await
|
|
294
|
+
if (chunkJAGQZZ43_cjs.isSupportedLanguageModel(resolvedModel)) {
|
|
295
|
+
result = await chunkJAGQZZ43_cjs.tryGenerateWithJsonFallback(judge, prompt, {
|
|
296
296
|
structuredOutput: {
|
|
297
297
|
schema
|
|
298
298
|
},
|
|
@@ -307,7 +307,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
307
307
|
return { result: result.object.score, prompt };
|
|
308
308
|
} else if (scorerStep.name === "generateReason") {
|
|
309
309
|
let result;
|
|
310
|
-
if (resolvedModel
|
|
310
|
+
if (chunkJAGQZZ43_cjs.isSupportedLanguageModel(resolvedModel)) {
|
|
311
311
|
result = await judge.generate(prompt, { tracingContext });
|
|
312
312
|
} else {
|
|
313
313
|
result = await judge.generateLegacy(prompt, { tracingContext });
|
|
@@ -316,8 +316,8 @@ var MastraScorer = class _MastraScorer {
|
|
|
316
316
|
} else {
|
|
317
317
|
const promptStep = originalStep;
|
|
318
318
|
let result;
|
|
319
|
-
if (resolvedModel
|
|
320
|
-
result = await
|
|
319
|
+
if (chunkJAGQZZ43_cjs.isSupportedLanguageModel(resolvedModel)) {
|
|
320
|
+
result = await chunkJAGQZZ43_cjs.tryGenerateWithJsonFallback(judge, prompt, {
|
|
321
321
|
structuredOutput: {
|
|
322
322
|
schema: promptStep.outputSchema
|
|
323
323
|
},
|
|
@@ -482,14 +482,14 @@ async function runEvals(config) {
|
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
function isWorkflow(target) {
|
|
485
|
-
return target instanceof
|
|
485
|
+
return target instanceof chunkJAGQZZ43_cjs.Workflow;
|
|
486
486
|
}
|
|
487
487
|
function isWorkflowScorerConfig(scorers) {
|
|
488
488
|
return typeof scorers === "object" && !Array.isArray(scorers) && ("workflow" in scorers || "steps" in scorers);
|
|
489
489
|
}
|
|
490
490
|
function validateEvalsInputs(data, scorers, target) {
|
|
491
491
|
if (data.length === 0) {
|
|
492
|
-
throw new
|
|
492
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
493
493
|
domain: "SCORER",
|
|
494
494
|
id: "RUN_EXPERIMENT_FAILED_NO_DATA_PROVIDED",
|
|
495
495
|
category: "USER",
|
|
@@ -499,7 +499,7 @@ function validateEvalsInputs(data, scorers, target) {
|
|
|
499
499
|
for (let i = 0; i < data.length; i++) {
|
|
500
500
|
const item = data[i];
|
|
501
501
|
if (!item || typeof item !== "object" || !("input" in item)) {
|
|
502
|
-
throw new
|
|
502
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
503
503
|
domain: "SCORER",
|
|
504
504
|
id: "INVALID_DATA_ITEM",
|
|
505
505
|
category: "USER",
|
|
@@ -509,7 +509,7 @@ function validateEvalsInputs(data, scorers, target) {
|
|
|
509
509
|
}
|
|
510
510
|
if (Array.isArray(scorers)) {
|
|
511
511
|
if (scorers.length === 0) {
|
|
512
|
-
throw new
|
|
512
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
513
513
|
domain: "SCORER",
|
|
514
514
|
id: "NO_SCORERS_PROVIDED",
|
|
515
515
|
category: "USER",
|
|
@@ -519,7 +519,7 @@ function validateEvalsInputs(data, scorers, target) {
|
|
|
519
519
|
} else if (isWorkflow(target) && isWorkflowScorerConfig(scorers)) {
|
|
520
520
|
const hasScorers = scorers.workflow && scorers.workflow.length > 0 || scorers.steps && Object.keys(scorers.steps).length > 0;
|
|
521
521
|
if (!hasScorers) {
|
|
522
|
-
throw new
|
|
522
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
523
523
|
domain: "SCORER",
|
|
524
524
|
id: "NO_SCORERS_PROVIDED",
|
|
525
525
|
category: "USER",
|
|
@@ -527,7 +527,7 @@ function validateEvalsInputs(data, scorers, target) {
|
|
|
527
527
|
});
|
|
528
528
|
}
|
|
529
529
|
} else if (!isWorkflow(target) && !Array.isArray(scorers)) {
|
|
530
|
-
throw new
|
|
530
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
531
531
|
domain: "SCORER",
|
|
532
532
|
id: "INVALID_AGENT_SCORERS",
|
|
533
533
|
category: "USER",
|
|
@@ -543,7 +543,7 @@ async function executeTarget(target, item) {
|
|
|
543
543
|
return await executeAgent(target, item);
|
|
544
544
|
}
|
|
545
545
|
} catch (error) {
|
|
546
|
-
throw new
|
|
546
|
+
throw new chunkHWMMIRIF_cjs.MastraError(
|
|
547
547
|
{
|
|
548
548
|
domain: "SCORER",
|
|
549
549
|
id: "RUN_EXPERIMENT_TARGET_FAILED_TO_GENERATE_RESULT",
|
|
@@ -573,7 +573,7 @@ async function executeWorkflow(target, item) {
|
|
|
573
573
|
}
|
|
574
574
|
async function executeAgent(agent, item) {
|
|
575
575
|
const model = await agent.getModel();
|
|
576
|
-
if (model
|
|
576
|
+
if (chunkJAGQZZ43_cjs.isSupportedLanguageModel(model)) {
|
|
577
577
|
return await agent.generate(item.input, {
|
|
578
578
|
scorers: {},
|
|
579
579
|
returnScorerData: true,
|
|
@@ -601,7 +601,7 @@ async function runScorers(scorers, targetResult, item) {
|
|
|
601
601
|
});
|
|
602
602
|
scorerResults[scorer.id] = score;
|
|
603
603
|
} catch (error) {
|
|
604
|
-
throw new
|
|
604
|
+
throw new chunkHWMMIRIF_cjs.MastraError(
|
|
605
605
|
{
|
|
606
606
|
domain: "SCORER",
|
|
607
607
|
id: "RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_RESULT",
|
|
@@ -650,7 +650,7 @@ async function runScorers(scorers, targetResult, item) {
|
|
|
650
650
|
});
|
|
651
651
|
stepResults[scorer.id] = score;
|
|
652
652
|
} catch (error) {
|
|
653
|
-
throw new
|
|
653
|
+
throw new chunkHWMMIRIF_cjs.MastraError(
|
|
654
654
|
{
|
|
655
655
|
domain: "SCORER",
|
|
656
656
|
id: "RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT",
|
|
@@ -681,5 +681,5 @@ async function runScorers(scorers, targetResult, item) {
|
|
|
681
681
|
exports.MastraScorer = MastraScorer;
|
|
682
682
|
exports.createScorer = createScorer;
|
|
683
683
|
exports.runEvals = runEvals;
|
|
684
|
-
//# sourceMappingURL=chunk-
|
|
685
|
-
//# sourceMappingURL=chunk-
|
|
684
|
+
//# sourceMappingURL=chunk-O5BQBZEF.cjs.map
|
|
685
|
+
//# sourceMappingURL=chunk-O5BQBZEF.cjs.map
|