@mastra/core 1.0.0-beta.14 → 1.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +307 -0
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +1 -1
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/{chunk-TDM43G4I.cjs → chunk-2OOMJRXZ.cjs} +9 -9
- package/dist/{chunk-TDM43G4I.cjs.map → chunk-2OOMJRXZ.cjs.map} +1 -1
- package/dist/chunk-37YWZMBX.js +27 -0
- package/dist/chunk-37YWZMBX.js.map +1 -0
- package/dist/{chunk-GBQXIVL6.js → chunk-3HDRO3GG.js} +790 -1206
- package/dist/chunk-3HDRO3GG.js.map +1 -0
- package/dist/{chunk-VZJOEGQA.js → chunk-4DFWV4IR.js} +2 -2
- package/dist/chunk-4DFWV4IR.js.map +1 -0
- package/dist/{chunk-373OC54J.js → chunk-4HP7CS6L.js} +7 -6
- package/dist/chunk-4HP7CS6L.js.map +1 -0
- package/dist/{chunk-4CMIJQF6.js → chunk-4J4M2Q5R.js} +14 -14
- package/dist/chunk-4J4M2Q5R.js.map +1 -0
- package/dist/{chunk-HWMMIRIF.cjs → chunk-4U7ZLI36.cjs} +3 -2
- package/dist/chunk-4U7ZLI36.cjs.map +1 -0
- package/dist/{chunk-Z55SJVEC.cjs → chunk-6HJFCSJ4.cjs} +7 -6
- package/dist/chunk-6HJFCSJ4.cjs.map +1 -0
- package/dist/{chunk-EGHGFLL3.cjs → chunk-AAX7ZOM7.cjs} +2 -2
- package/dist/chunk-AAX7ZOM7.cjs.map +1 -0
- package/dist/{chunk-SLBWA2F3.js → chunk-AR5CF3IN.js} +3 -3
- package/dist/{chunk-SLBWA2F3.js.map → chunk-AR5CF3IN.js.map} +1 -1
- package/dist/{chunk-QDVYP2T7.js → chunk-BAZHNX5P.js} +8 -8
- package/dist/{chunk-QDVYP2T7.js.map → chunk-BAZHNX5P.js.map} +1 -1
- package/dist/{chunk-O3ULBGV6.cjs → chunk-BC2VKOH4.cjs} +43 -21
- package/dist/chunk-BC2VKOH4.cjs.map +1 -0
- package/dist/{chunk-5UQ5TB6J.js → chunk-BCUKD2XG.js} +59 -19
- package/dist/chunk-BCUKD2XG.js.map +1 -0
- package/dist/{chunk-67LM2UCT.js → chunk-CBQ6WDUJ.js} +5 -5
- package/dist/{chunk-67LM2UCT.js.map → chunk-CBQ6WDUJ.js.map} +1 -1
- package/dist/chunk-CBVHOGXX.cjs +674 -0
- package/dist/chunk-CBVHOGXX.cjs.map +1 -0
- package/dist/{chunk-O5BQBZEF.cjs → chunk-CBY37FTP.cjs} +28 -28
- package/dist/{chunk-O5BQBZEF.cjs.map → chunk-CBY37FTP.cjs.map} +1 -1
- package/dist/{chunk-3IP3DZ7G.js → chunk-D2IFWD7A.js} +285 -124
- package/dist/chunk-D2IFWD7A.js.map +1 -0
- package/dist/{chunk-JAGQZZ43.cjs → chunk-DDK3URK2.cjs} +636 -313
- package/dist/chunk-DDK3URK2.cjs.map +1 -0
- package/dist/chunk-DRJTNGI4.cjs +263 -0
- package/dist/chunk-DRJTNGI4.cjs.map +1 -0
- package/dist/{chunk-72E3YF6A.cjs → chunk-EMLEZXTQ.cjs} +15 -12
- package/dist/chunk-EMLEZXTQ.cjs.map +1 -0
- package/dist/{chunk-YPLZDWG7.js → chunk-FJEVLHJT.js} +3 -2
- package/dist/chunk-FJEVLHJT.js.map +1 -0
- package/dist/{chunk-53SZJCBX.cjs → chunk-GXMJ5URG.cjs} +25 -25
- package/dist/{chunk-53SZJCBX.cjs.map → chunk-GXMJ5URG.cjs.map} +1 -1
- package/dist/chunk-H2NHG7QL.cjs +32 -0
- package/dist/chunk-H2NHG7QL.cjs.map +1 -0
- package/dist/chunk-HAYBGFPA.js +259 -0
- package/dist/chunk-HAYBGFPA.js.map +1 -0
- package/dist/{chunk-AYBJ5GAD.js → chunk-IHISDRFV.js} +124 -50
- package/dist/chunk-IHISDRFV.js.map +1 -0
- package/dist/{chunk-DBW6S25C.cjs → chunk-IRTICXRZ.cjs} +101 -61
- package/dist/chunk-IRTICXRZ.cjs.map +1 -0
- package/dist/{chunk-ETWAR2YE.cjs → chunk-LOV5NNGK.cjs} +811 -1235
- package/dist/chunk-LOV5NNGK.cjs.map +1 -0
- package/dist/{chunk-QF4MHFSU.js → chunk-NGWTSHNA.js} +470 -152
- package/dist/chunk-NGWTSHNA.js.map +1 -0
- package/dist/{chunk-72YCRTEX.cjs → chunk-O2CAMK4A.cjs} +13 -2
- package/dist/chunk-O2CAMK4A.cjs.map +1 -0
- package/dist/{chunk-GELVUDUY.js → chunk-O7M7DR4E.js} +3 -3
- package/dist/{chunk-GELVUDUY.js.map → chunk-O7M7DR4E.js.map} +1 -1
- package/dist/chunk-OTIGV7CL.js +10215 -0
- package/dist/chunk-OTIGV7CL.js.map +1 -0
- package/dist/{chunk-4AT6YQKZ.js → chunk-QXL3F3T2.js} +7 -4
- package/dist/chunk-QXL3F3T2.js.map +1 -0
- package/dist/{chunk-6CG7IY57.cjs → chunk-RA2CHJCY.cjs} +319 -158
- package/dist/chunk-RA2CHJCY.cjs.map +1 -0
- package/dist/chunk-RMV5HJM7.cjs +10237 -0
- package/dist/chunk-RMV5HJM7.cjs.map +1 -0
- package/dist/{chunk-FPDJ4XN6.cjs → chunk-S23TNDXG.cjs} +125 -51
- package/dist/chunk-S23TNDXG.cjs.map +1 -0
- package/dist/{chunk-OOUFPYSX.cjs → chunk-SSB4AVHU.cjs} +17 -17
- package/dist/{chunk-OOUFPYSX.cjs.map → chunk-SSB4AVHU.cjs.map} +1 -1
- package/dist/{chunk-TRUNX3AX.cjs → chunk-T2LVULCK.cjs} +31 -31
- package/dist/chunk-T2LVULCK.cjs.map +1 -0
- package/dist/{chunk-LDXKZYOV.js → chunk-XJB7J4UT.js} +30 -8
- package/dist/chunk-XJB7J4UT.js.map +1 -0
- package/dist/chunk-YV43YEZ6.js +598 -0
- package/dist/chunk-YV43YEZ6.js.map +1 -0
- package/dist/{chunk-Y36Y5MTD.js → chunk-ZGIVAQRI.js} +13 -3
- package/dist/chunk-ZGIVAQRI.js.map +1 -0
- package/dist/error/index.cjs +6 -6
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/evals/index.cjs +49 -9
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +70 -22
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +63 -15
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/evals/scoreTraces/utils.d.ts.map +1 -1
- package/dist/evals/types.d.ts +568 -116
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +20 -20
- package/dist/llm/index.js +4 -4
- package/dist/llm/model/aisdk/v6/model.d.ts +1 -9
- package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
- package/dist/llm/model/embedding-router.d.ts +1 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-options.d.ts +2 -1
- package/dist/llm/model/provider-options.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +42 -17
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +6 -6
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts +1 -9
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts.map +1 -1
- package/dist/loop/types.d.ts +5 -2
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +7 -2
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.js +1 -1
- package/dist/memory/index.cjs +26 -6
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +9 -8
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/mock.d.ts +2 -1
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +3 -4
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/working-memory-utils.d.ts +20 -0
- package/dist/memory/working-memory-utils.d.ts.map +1 -0
- package/dist/models-dev-26XLUKVK.cjs +12 -0
- package/dist/{models-dev-PPS7X4JM.cjs.map → models-dev-26XLUKVK.cjs.map} +1 -1
- package/dist/models-dev-HUFLQFPB.js +3 -0
- package/dist/{models-dev-E3WWI7VA.js.map → models-dev-HUFLQFPB.js.map} +1 -1
- package/dist/netlify-CUYK2MZ2.cjs +12 -0
- package/dist/{netlify-VZFM5UH3.cjs.map → netlify-CUYK2MZ2.cjs.map} +1 -1
- package/dist/netlify-J4QPOROO.js +3 -0
- package/dist/{netlify-TY656UYF.js.map → netlify-J4QPOROO.js.map} +1 -1
- package/dist/observability/index.cjs +14 -10
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +32 -19
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/message-history.d.ts +7 -1
- package/dist/processors/memory/message-history.d.ts.map +1 -1
- package/dist/processors/processors/language-detector.d.ts.map +1 -1
- package/dist/processors/processors/moderation.d.ts.map +1 -1
- package/dist/processors/processors/pii-detector.d.ts.map +1 -1
- package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +5 -2
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +2 -0
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/provider-registry-6CIGRQVZ.js +3 -0
- package/dist/{provider-registry-NXVD764B.js.map → provider-registry-6CIGRQVZ.js.map} +1 -1
- package/dist/provider-registry-7O7FJ4BS.cjs +40 -0
- package/dist/{provider-registry-ZIWSEUQE.cjs.map → provider-registry-7O7FJ4BS.cjs.map} +1 -1
- package/dist/provider-registry.json +120 -46
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +5 -5
- package/dist/server/index.js +1 -1
- package/dist/storage/base.d.ts +40 -292
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +60 -0
- package/dist/storage/constants.cjs.map +1 -0
- package/dist/storage/constants.d.ts +6 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +3 -0
- package/dist/storage/constants.js.map +1 -0
- package/dist/storage/domains/agents/base.d.ts +2 -2
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts +5 -4
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/base.d.ts +20 -0
- package/dist/storage/domains/base.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +57 -0
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -0
- package/dist/storage/domains/memory/base.d.ts +2 -2
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +5 -13
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/base.d.ts +24 -29
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +1 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/inmemory.d.ts +46 -35
- package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +2365 -0
- package/dist/storage/domains/observability/types.d.ts.map +1 -0
- package/dist/storage/domains/scores/base.d.ts +9 -20
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +11 -22
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/shared.d.ts +76 -0
- package/dist/storage/domains/shared.d.ts.map +1 -0
- package/dist/storage/domains/workflows/base.d.ts +4 -2
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +10 -9
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +272 -59
- package/dist/storage/index.js +2 -1
- package/dist/storage/mock.d.ts +28 -174
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +39 -44
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/utils.d.ts +5 -0
- package/dist/storage/utils.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +12 -12
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +3 -0
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +20 -0
- package/dist/tool-loop-agent/index.cjs.map +1 -0
- package/dist/tool-loop-agent/index.d.ts +36 -0
- package/dist/tool-loop-agent/index.d.ts.map +1 -0
- package/dist/tool-loop-agent/index.js +3 -0
- package/dist/tool-loop-agent/index.js.map +1 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts +30 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +1 -0
- package/dist/tool-loop-agent/utils.d.ts +17 -0
- package/dist/tool-loop-agent/utils.d.ts.map +1 -0
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/toolchecks.d.ts +1 -1
- package/dist/tools/toolchecks.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils/zod-utils.d.ts +34 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils.cjs +39 -22
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -1
- package/dist/vector/index.cjs +12 -5299
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +3 -5274
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +13 -3
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +2 -0
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +1 -0
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +1 -0
- package/dist/workflows/evented/step-executor.d.ts.map +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 +2 -2
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +5 -2
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +1 -0
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +4 -0
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/entry.d.ts +3 -2
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +1 -0
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/types.d.ts +23 -3
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +1 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +22 -8
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +16 -6
- package/src/llm/model/provider-types.generated.d.ts +42 -17
- package/storage/constants.d.ts +1 -0
- package/tool-loop-agent.d.ts +1 -0
- package/dist/chunk-373OC54J.js.map +0 -1
- package/dist/chunk-3IP3DZ7G.js.map +0 -1
- package/dist/chunk-4AT6YQKZ.js.map +0 -1
- package/dist/chunk-4CMIJQF6.js.map +0 -1
- package/dist/chunk-5UQ5TB6J.js.map +0 -1
- package/dist/chunk-6CG7IY57.cjs.map +0 -1
- package/dist/chunk-72E3YF6A.cjs.map +0 -1
- package/dist/chunk-72YCRTEX.cjs.map +0 -1
- package/dist/chunk-ADADLFDR.js +0 -42
- package/dist/chunk-ADADLFDR.js.map +0 -1
- package/dist/chunk-AYBJ5GAD.js.map +0 -1
- package/dist/chunk-DBW6S25C.cjs.map +0 -1
- package/dist/chunk-EGHGFLL3.cjs.map +0 -1
- package/dist/chunk-ETWAR2YE.cjs.map +0 -1
- package/dist/chunk-FPDJ4XN6.cjs.map +0 -1
- package/dist/chunk-GBQXIVL6.js.map +0 -1
- package/dist/chunk-HWMMIRIF.cjs.map +0 -1
- package/dist/chunk-JAGQZZ43.cjs.map +0 -1
- package/dist/chunk-LDXKZYOV.js.map +0 -1
- package/dist/chunk-O3ULBGV6.cjs.map +0 -1
- package/dist/chunk-QF4MHFSU.js.map +0 -1
- package/dist/chunk-T2VLUFGG.cjs +0 -47
- package/dist/chunk-T2VLUFGG.cjs.map +0 -1
- package/dist/chunk-TRUNX3AX.cjs.map +0 -1
- package/dist/chunk-VZJOEGQA.js.map +0 -1
- package/dist/chunk-Y36Y5MTD.js.map +0 -1
- package/dist/chunk-YPLZDWG7.js.map +0 -1
- package/dist/chunk-Z55SJVEC.cjs.map +0 -1
- package/dist/models-dev-E3WWI7VA.js +0 -3
- package/dist/models-dev-PPS7X4JM.cjs +0 -12
- package/dist/netlify-TY656UYF.js +0 -3
- package/dist/netlify-VZFM5UH3.cjs +0 -12
- package/dist/provider-registry-NXVD764B.js +0 -3
- package/dist/provider-registry-ZIWSEUQE.cjs +0 -40
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSSB4AVHU_cjs = require('./chunk-SSB4AVHU.cjs');
|
|
4
4
|
var chunkL3NKIMF5_cjs = require('./chunk-L3NKIMF5.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunkLOV5NNGK_cjs = require('./chunk-LOV5NNGK.cjs');
|
|
6
|
+
var chunkEMLEZXTQ_cjs = require('./chunk-EMLEZXTQ.cjs');
|
|
7
7
|
var chunkNESKUIRE_cjs = require('./chunk-NESKUIRE.cjs');
|
|
8
8
|
var chunkFVQTJUBD_cjs = require('./chunk-FVQTJUBD.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var chunkGXMJ5URG_cjs = require('./chunk-GXMJ5URG.cjs');
|
|
10
|
+
var chunkT2LVULCK_cjs = require('./chunk-T2LVULCK.cjs');
|
|
11
11
|
var chunk4D4KB75Y_cjs = require('./chunk-4D4KB75Y.cjs');
|
|
12
12
|
var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
13
|
+
var chunkBC2VKOH4_cjs = require('./chunk-BC2VKOH4.cjs');
|
|
14
|
+
var chunkO2CAMK4A_cjs = require('./chunk-O2CAMK4A.cjs');
|
|
15
|
+
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
16
16
|
var chunkKJBMTK5B_cjs = require('./chunk-KJBMTK5B.cjs');
|
|
17
|
-
var
|
|
17
|
+
var chunk6HJFCSJ4_cjs = require('./chunk-6HJFCSJ4.cjs');
|
|
18
18
|
var chunkUVHSM2GU_cjs = require('./chunk-UVHSM2GU.cjs');
|
|
19
19
|
var chunk4WQYXT2I_cjs = require('./chunk-4WQYXT2I.cjs');
|
|
20
20
|
var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
|
|
@@ -559,7 +559,7 @@ var StructuredOutputProcessor = class {
|
|
|
559
559
|
providerOptions;
|
|
560
560
|
constructor(options) {
|
|
561
561
|
if (!options.schema) {
|
|
562
|
-
throw new
|
|
562
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
563
563
|
id: "STRUCTURED_OUTPUT_PROCESSOR_SCHEMA_REQUIRED",
|
|
564
564
|
domain: "AGENT" /* AGENT */,
|
|
565
565
|
category: "USER" /* USER */,
|
|
@@ -567,7 +567,7 @@ var StructuredOutputProcessor = class {
|
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
569
|
if (!options.model) {
|
|
570
|
-
throw new
|
|
570
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
571
571
|
id: "STRUCTURED_OUTPUT_PROCESSOR_MODEL_REQUIRED",
|
|
572
572
|
domain: "AGENT" /* AGENT */,
|
|
573
573
|
category: "USER" /* USER */,
|
|
@@ -764,7 +764,7 @@ var isSupportedLanguageModel = (model) => {
|
|
|
764
764
|
};
|
|
765
765
|
async function tryGenerateWithJsonFallback(agent, prompt, options) {
|
|
766
766
|
if (!options.structuredOutput?.schema) {
|
|
767
|
-
throw new
|
|
767
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
768
768
|
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
769
769
|
domain: "AGENT" /* AGENT */,
|
|
770
770
|
category: "USER" /* USER */,
|
|
@@ -783,7 +783,7 @@ async function tryGenerateWithJsonFallback(agent, prompt, options) {
|
|
|
783
783
|
}
|
|
784
784
|
async function tryStreamWithJsonFallback(agent, prompt, options) {
|
|
785
785
|
if (!options.structuredOutput?.schema) {
|
|
786
|
-
throw new
|
|
786
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
787
787
|
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
788
788
|
domain: "AGENT" /* AGENT */,
|
|
789
789
|
category: "USER" /* USER */,
|
|
@@ -794,7 +794,7 @@ async function tryStreamWithJsonFallback(agent, prompt, options) {
|
|
|
794
794
|
const result = await agent.stream(prompt, options);
|
|
795
795
|
const object = await result.object;
|
|
796
796
|
if (!object) {
|
|
797
|
-
throw new
|
|
797
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
798
798
|
id: "STRUCTURED_OUTPUT_OBJECT_UNDEFINED",
|
|
799
799
|
domain: "AGENT" /* AGENT */,
|
|
800
800
|
category: "USER" /* USER */,
|
|
@@ -833,8 +833,9 @@ var ProcessorState = class {
|
|
|
833
833
|
this.span = parentSpan?.createChildSpan({
|
|
834
834
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
835
835
|
name: `output processor: ${processorName}`,
|
|
836
|
+
entityType: "output_processor" /* OUTPUT_PROCESSOR */,
|
|
837
|
+
entityName: processorName,
|
|
836
838
|
attributes: {
|
|
837
|
-
processorName,
|
|
838
839
|
processorType: "output",
|
|
839
840
|
processorIndex: processorIndex ?? 0
|
|
840
841
|
},
|
|
@@ -900,7 +901,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
900
901
|
);
|
|
901
902
|
}
|
|
902
903
|
if (result.status !== "success") {
|
|
903
|
-
throw new
|
|
904
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
904
905
|
category: "USER",
|
|
905
906
|
domain: "AGENT",
|
|
906
907
|
id: "PROCESSOR_WORKFLOW_FAILED",
|
|
@@ -912,7 +913,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
912
913
|
return input;
|
|
913
914
|
}
|
|
914
915
|
if (!("phase" in output) || !("messages" in output || "part" in output || "messageList" in output)) {
|
|
915
|
-
throw new
|
|
916
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
916
917
|
category: "USER",
|
|
917
918
|
domain: "AGENT",
|
|
918
919
|
id: "PROCESSOR_WORKFLOW_INVALID_OUTPUT",
|
|
@@ -933,8 +934,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
933
934
|
const processorSpan2 = parentSpan2?.createChildSpan({
|
|
934
935
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
935
936
|
name: `output processor workflow: ${processorOrWorkflow.id}`,
|
|
937
|
+
entityType: "output_processor" /* OUTPUT_PROCESSOR */,
|
|
938
|
+
entityId: processorOrWorkflow.id,
|
|
939
|
+
entityName: processorOrWorkflow.name,
|
|
936
940
|
attributes: {
|
|
937
|
-
processorName: processorOrWorkflow.id,
|
|
938
941
|
processorType: "output",
|
|
939
942
|
processorIndex: index
|
|
940
943
|
},
|
|
@@ -975,8 +978,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
975
978
|
const processorSpan = parentSpan?.createChildSpan({
|
|
976
979
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
977
980
|
name: `output processor: ${processor.id}`,
|
|
981
|
+
entityType: "output_processor" /* OUTPUT_PROCESSOR */,
|
|
982
|
+
entityId: processor.id,
|
|
983
|
+
entityName: processor.name,
|
|
978
984
|
attributes: {
|
|
979
|
-
processorName: processor.name ?? processor.id,
|
|
980
985
|
processorType: "output",
|
|
981
986
|
processorIndex: index
|
|
982
987
|
},
|
|
@@ -992,9 +997,9 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
992
997
|
retryCount
|
|
993
998
|
});
|
|
994
999
|
const mutations = messageList.stopRecording();
|
|
995
|
-
if (result instanceof
|
|
1000
|
+
if (result instanceof chunkEMLEZXTQ_cjs.MessageList) {
|
|
996
1001
|
if (result !== messageList) {
|
|
997
|
-
throw new
|
|
1002
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
998
1003
|
category: "USER",
|
|
999
1004
|
domain: "AGENT",
|
|
1000
1005
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -1211,8 +1216,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1211
1216
|
const processorSpan2 = parentSpan2?.createChildSpan({
|
|
1212
1217
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
1213
1218
|
name: `input processor workflow: ${processorOrWorkflow.id}`,
|
|
1219
|
+
entityType: "input_processor" /* INPUT_PROCESSOR */,
|
|
1220
|
+
entityId: processorOrWorkflow.id,
|
|
1221
|
+
entityName: processorOrWorkflow.name,
|
|
1214
1222
|
attributes: {
|
|
1215
|
-
processorName: processorOrWorkflow.id,
|
|
1216
1223
|
processorType: "input",
|
|
1217
1224
|
processorIndex: index
|
|
1218
1225
|
},
|
|
@@ -1255,8 +1262,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1255
1262
|
const processorSpan = parentSpan?.createChildSpan({
|
|
1256
1263
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
1257
1264
|
name: `input processor: ${processor.id}`,
|
|
1265
|
+
entityType: "input_processor" /* INPUT_PROCESSOR */,
|
|
1266
|
+
entityId: processor.id,
|
|
1267
|
+
entityName: processor.name,
|
|
1258
1268
|
attributes: {
|
|
1259
|
-
processorName: processor.name ?? processor.id,
|
|
1260
1269
|
processorType: "input",
|
|
1261
1270
|
processorIndex: index
|
|
1262
1271
|
},
|
|
@@ -1274,9 +1283,9 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1274
1283
|
retryCount
|
|
1275
1284
|
});
|
|
1276
1285
|
let mutations;
|
|
1277
|
-
if (result instanceof
|
|
1286
|
+
if (result instanceof chunkEMLEZXTQ_cjs.MessageList) {
|
|
1278
1287
|
if (result !== messageList) {
|
|
1279
|
-
throw new
|
|
1288
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1280
1289
|
category: "USER",
|
|
1281
1290
|
domain: "AGENT",
|
|
1282
1291
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -1379,8 +1388,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1379
1388
|
const processorSpan2 = parentSpan?.createChildSpan({
|
|
1380
1389
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
1381
1390
|
name: `input step processor workflow: ${processorOrWorkflow.id}`,
|
|
1391
|
+
entityType: "input_processor" /* INPUT_PROCESSOR */,
|
|
1392
|
+
entityId: processorOrWorkflow.id,
|
|
1393
|
+
entityName: processorOrWorkflow.name,
|
|
1382
1394
|
attributes: {
|
|
1383
|
-
processorName: processorOrWorkflow.id,
|
|
1384
1395
|
processorType: "input",
|
|
1385
1396
|
processorIndex: index
|
|
1386
1397
|
},
|
|
@@ -1439,8 +1450,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1439
1450
|
const processorSpan = currentSpan?.createChildSpan({
|
|
1440
1451
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
1441
1452
|
name: `input step processor: ${processor.id}`,
|
|
1453
|
+
entityType: "input_processor" /* INPUT_PROCESSOR */,
|
|
1454
|
+
entityId: processor.id,
|
|
1455
|
+
entityName: processor.name,
|
|
1442
1456
|
attributes: {
|
|
1443
|
-
processorName: processor.name ?? processor.id,
|
|
1444
1457
|
processorType: "input",
|
|
1445
1458
|
processorIndex: index
|
|
1446
1459
|
},
|
|
@@ -1533,6 +1546,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1533
1546
|
*/
|
|
1534
1547
|
async runProcessOutputStep(args) {
|
|
1535
1548
|
const {
|
|
1549
|
+
steps,
|
|
1536
1550
|
messageList,
|
|
1537
1551
|
stepNumber,
|
|
1538
1552
|
finishReason,
|
|
@@ -1552,8 +1566,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1552
1566
|
const processorSpan2 = parentSpan2?.createChildSpan({
|
|
1553
1567
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
1554
1568
|
name: `output step processor workflow: ${processorOrWorkflow.id}`,
|
|
1569
|
+
entityType: "output_processor" /* OUTPUT_PROCESSOR */,
|
|
1570
|
+
entityId: processorOrWorkflow.id,
|
|
1571
|
+
entityName: processorOrWorkflow.name,
|
|
1555
1572
|
attributes: {
|
|
1556
|
-
processorName: processorOrWorkflow.id,
|
|
1557
1573
|
processorType: "output",
|
|
1558
1574
|
processorIndex: index
|
|
1559
1575
|
},
|
|
@@ -1572,6 +1588,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1572
1588
|
toolCalls,
|
|
1573
1589
|
text,
|
|
1574
1590
|
systemMessages: currentSystemMessages2,
|
|
1591
|
+
steps,
|
|
1575
1592
|
retryCount
|
|
1576
1593
|
},
|
|
1577
1594
|
tracingContext,
|
|
@@ -1600,8 +1617,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1600
1617
|
const processorSpan = parentSpan?.createChildSpan({
|
|
1601
1618
|
type: "processor_run" /* PROCESSOR_RUN */,
|
|
1602
1619
|
name: `output step processor: ${processor.id}`,
|
|
1620
|
+
entityType: "output_processor" /* OUTPUT_PROCESSOR */,
|
|
1621
|
+
entityId: processor.id,
|
|
1622
|
+
entityName: processor.name,
|
|
1603
1623
|
attributes: {
|
|
1604
|
-
processorName: processor.name ?? processor.id,
|
|
1605
1624
|
processorType: "output",
|
|
1606
1625
|
processorIndex: index
|
|
1607
1626
|
},
|
|
@@ -1618,15 +1637,16 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1618
1637
|
toolCalls,
|
|
1619
1638
|
text,
|
|
1620
1639
|
systemMessages: currentSystemMessages,
|
|
1640
|
+
steps,
|
|
1621
1641
|
abort,
|
|
1622
1642
|
tracingContext: { currentSpan: processorSpan },
|
|
1623
1643
|
requestContext,
|
|
1624
1644
|
retryCount
|
|
1625
1645
|
});
|
|
1626
1646
|
const mutations = messageList.stopRecording();
|
|
1627
|
-
if (result instanceof
|
|
1647
|
+
if (result instanceof chunkEMLEZXTQ_cjs.MessageList) {
|
|
1628
1648
|
if (result !== messageList) {
|
|
1629
|
-
throw new
|
|
1649
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1630
1650
|
category: "USER",
|
|
1631
1651
|
domain: "AGENT",
|
|
1632
1652
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -1694,9 +1714,9 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1694
1714
|
processor,
|
|
1695
1715
|
stepNumber
|
|
1696
1716
|
}) {
|
|
1697
|
-
if (result instanceof
|
|
1717
|
+
if (result instanceof chunkEMLEZXTQ_cjs.MessageList) {
|
|
1698
1718
|
if (result !== messageList) {
|
|
1699
|
-
throw new
|
|
1719
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1700
1720
|
category: "USER",
|
|
1701
1721
|
domain: "AGENT",
|
|
1702
1722
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -1712,7 +1732,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1712
1732
|
};
|
|
1713
1733
|
} else if (result) {
|
|
1714
1734
|
if (result.messageList && result.messageList !== messageList) {
|
|
1715
|
-
throw new
|
|
1735
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1716
1736
|
category: "USER",
|
|
1717
1737
|
domain: "AGENT",
|
|
1718
1738
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -1720,7 +1740,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1720
1740
|
});
|
|
1721
1741
|
}
|
|
1722
1742
|
if (result.messages && result.messageList) {
|
|
1723
|
-
throw new
|
|
1743
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1724
1744
|
category: "USER",
|
|
1725
1745
|
domain: "AGENT",
|
|
1726
1746
|
id: "PROCESSOR_RETURNED_MESSAGES_AND_MESSAGE_LIST",
|
|
@@ -1729,10 +1749,10 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1729
1749
|
}
|
|
1730
1750
|
const { model: _model, ...rest } = result;
|
|
1731
1751
|
if (result.model) {
|
|
1732
|
-
const resolvedModel = await
|
|
1752
|
+
const resolvedModel = await chunkGXMJ5URG_cjs.resolveModelConfig(result.model);
|
|
1733
1753
|
const isSupported = isSupportedLanguageModel(resolvedModel);
|
|
1734
1754
|
if (!isSupported) {
|
|
1735
|
-
throw new
|
|
1755
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1736
1756
|
category: "USER",
|
|
1737
1757
|
domain: "AGENT",
|
|
1738
1758
|
id: "PROCESSOR_RETURNED_UNSUPPORTED_MODEL",
|
|
@@ -1932,7 +1952,7 @@ function convertFullStreamChunkToMastra(value, ctx) {
|
|
|
1932
1952
|
from: "AGENT" /* AGENT */,
|
|
1933
1953
|
payload: {
|
|
1934
1954
|
stepResult: {
|
|
1935
|
-
reason: value.finishReason
|
|
1955
|
+
reason: normalizeFinishReason(value.finishReason)
|
|
1936
1956
|
},
|
|
1937
1957
|
output: {
|
|
1938
1958
|
// Normalize usage to handle both V2 (flat) and V3 (nested) formats
|
|
@@ -2040,7 +2060,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
2040
2060
|
if (mode === "generate") {
|
|
2041
2061
|
return {
|
|
2042
2062
|
type: "file",
|
|
2043
|
-
file: new
|
|
2063
|
+
file: new chunkEMLEZXTQ_cjs.DefaultGeneratedFile({
|
|
2044
2064
|
data: chunk.payload.data,
|
|
2045
2065
|
mediaType: chunk.payload.mimeType
|
|
2046
2066
|
})
|
|
@@ -2048,7 +2068,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
2048
2068
|
}
|
|
2049
2069
|
return {
|
|
2050
2070
|
type: "file",
|
|
2051
|
-
file: new
|
|
2071
|
+
file: new chunkEMLEZXTQ_cjs.DefaultGeneratedFileWithType({
|
|
2052
2072
|
data: chunk.payload.data,
|
|
2053
2073
|
mediaType: chunk.payload.mimeType
|
|
2054
2074
|
})
|
|
@@ -2200,6 +2220,21 @@ function normalizeUsage(usage) {
|
|
|
2200
2220
|
raw: usage
|
|
2201
2221
|
};
|
|
2202
2222
|
}
|
|
2223
|
+
function isV3FinishReason(finishReason) {
|
|
2224
|
+
return typeof finishReason === "object" && finishReason !== null && "unified" in finishReason;
|
|
2225
|
+
}
|
|
2226
|
+
function normalizeFinishReason(finishReason) {
|
|
2227
|
+
if (!finishReason) {
|
|
2228
|
+
return "other";
|
|
2229
|
+
}
|
|
2230
|
+
if (finishReason === "tripwire" || finishReason === "retry") {
|
|
2231
|
+
return finishReason;
|
|
2232
|
+
}
|
|
2233
|
+
if (isV3FinishReason(finishReason)) {
|
|
2234
|
+
return finishReason.unified;
|
|
2235
|
+
}
|
|
2236
|
+
return finishReason === "unknown" ? "other" : finishReason;
|
|
2237
|
+
}
|
|
2203
2238
|
|
|
2204
2239
|
// src/stream/aisdk/v5/output.ts
|
|
2205
2240
|
var AISDKV5OutputStream = class {
|
|
@@ -2641,7 +2676,7 @@ var BaseFormatHandler = class {
|
|
|
2641
2676
|
} else {
|
|
2642
2677
|
return {
|
|
2643
2678
|
success: false,
|
|
2644
|
-
error: new
|
|
2679
|
+
error: new chunk4U7ZLI36_cjs.MastraError(
|
|
2645
2680
|
{
|
|
2646
2681
|
domain: "AGENT" /* AGENT */,
|
|
2647
2682
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -3528,7 +3563,7 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3528
3563
|
);
|
|
3529
3564
|
const responseMessages = self.messageList.get.response.aiV4.core();
|
|
3530
3565
|
const lastResponseMessage = responseMessages[responseMessages.length - 1];
|
|
3531
|
-
const outputText = lastResponseMessage ?
|
|
3566
|
+
const outputText = lastResponseMessage ? chunkEMLEZXTQ_cjs.MessageList.coreContentToString(lastResponseMessage.content) : "";
|
|
3532
3567
|
if (lastStep && outputText && outputText !== originalText) {
|
|
3533
3568
|
lastStep.text = outputText;
|
|
3534
3569
|
}
|
|
@@ -3563,7 +3598,7 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3563
3598
|
text: ""
|
|
3564
3599
|
});
|
|
3565
3600
|
} else {
|
|
3566
|
-
self.#error =
|
|
3601
|
+
self.#error = chunk4U7ZLI36_cjs.getErrorFromUnknown(error2, {
|
|
3567
3602
|
fallbackMessage: "Unknown error in stream"
|
|
3568
3603
|
});
|
|
3569
3604
|
self.resolvePromises({
|
|
@@ -3640,7 +3675,7 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3640
3675
|
}
|
|
3641
3676
|
break;
|
|
3642
3677
|
case "error":
|
|
3643
|
-
const error =
|
|
3678
|
+
const error = chunk4U7ZLI36_cjs.getErrorFromUnknown(chunk.payload.error, {
|
|
3644
3679
|
fallbackMessage: "Unknown error chunk in stream"
|
|
3645
3680
|
});
|
|
3646
3681
|
self.#error = error;
|
|
@@ -3707,7 +3742,7 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3707
3742
|
}
|
|
3708
3743
|
resolvePromise(key, value) {
|
|
3709
3744
|
if (!(key in this.#delayedPromises)) {
|
|
3710
|
-
throw new
|
|
3745
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
3711
3746
|
id: "MASTRA_MODEL_OUTPUT_INVALID_PROMISE_KEY",
|
|
3712
3747
|
domain: "LLM" /* LLM */,
|
|
3713
3748
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -4372,6 +4407,8 @@ var WorkflowRunOutput = class {
|
|
|
4372
4407
|
} else {
|
|
4373
4408
|
self.#status = "failed";
|
|
4374
4409
|
}
|
|
4410
|
+
} else if (chunk.type === "workflow-paused") {
|
|
4411
|
+
self.#status = "paused";
|
|
4375
4412
|
}
|
|
4376
4413
|
},
|
|
4377
4414
|
close() {
|
|
@@ -4507,6 +4544,8 @@ var WorkflowRunOutput = class {
|
|
|
4507
4544
|
} else {
|
|
4508
4545
|
self.#status = "failed";
|
|
4509
4546
|
}
|
|
4547
|
+
} else if (chunk.type === "workflow-paused") {
|
|
4548
|
+
self.#status = "paused";
|
|
4510
4549
|
}
|
|
4511
4550
|
},
|
|
4512
4551
|
close() {
|
|
@@ -5091,7 +5130,7 @@ async function validateStepInput({
|
|
|
5091
5130
|
if (!validatedInput.success) {
|
|
5092
5131
|
const errors = getZodErrors(validatedInput.error);
|
|
5093
5132
|
const errorMessages = errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n");
|
|
5094
|
-
validationError = new
|
|
5133
|
+
validationError = new chunk4U7ZLI36_cjs.MastraError(
|
|
5095
5134
|
{
|
|
5096
5135
|
id: "WORKFLOW_STEP_INPUT_VALIDATION_FAILED",
|
|
5097
5136
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -5119,7 +5158,7 @@ async function validateStepResumeData({ resumeData, step }) {
|
|
|
5119
5158
|
if (!validatedResumeData.success) {
|
|
5120
5159
|
const errors = getZodErrors(validatedResumeData.error);
|
|
5121
5160
|
const errorMessages = errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n");
|
|
5122
|
-
validationError = new
|
|
5161
|
+
validationError = new chunk4U7ZLI36_cjs.MastraError(
|
|
5123
5162
|
{
|
|
5124
5163
|
id: "WORKFLOW_STEP_RESUME_DATA_VALIDATION_FAILED",
|
|
5125
5164
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -5150,7 +5189,7 @@ async function validateStepSuspendData({
|
|
|
5150
5189
|
if (!validatedSuspendData.success) {
|
|
5151
5190
|
const errors = getZodErrors(validatedSuspendData.error);
|
|
5152
5191
|
const errorMessages = errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n");
|
|
5153
|
-
validationError = new
|
|
5192
|
+
validationError = new chunk4U7ZLI36_cjs.MastraError(
|
|
5154
5193
|
{
|
|
5155
5194
|
id: "WORKFLOW_STEP_SUSPEND_DATA_VALIDATION_FAILED",
|
|
5156
5195
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -5231,7 +5270,7 @@ var getStepIds = (entry) => {
|
|
|
5231
5270
|
return [];
|
|
5232
5271
|
};
|
|
5233
5272
|
var createTimeTravelExecutionParams = (params) => {
|
|
5234
|
-
const { steps, inputData, resumeData, context, nestedStepsContext, snapshot, initialState, graph } = params;
|
|
5273
|
+
const { steps, inputData, resumeData, context, nestedStepsContext, snapshot, initialState, graph, perStep } = params;
|
|
5235
5274
|
const firstStepId = steps[0];
|
|
5236
5275
|
let executionPath = [];
|
|
5237
5276
|
const stepResults = {};
|
|
@@ -5298,11 +5337,12 @@ var createTimeTravelExecutionParams = (params) => {
|
|
|
5298
5337
|
suspendedAt: stepContext?.suspendedAt,
|
|
5299
5338
|
resumedAt: stepContext?.resumedAt
|
|
5300
5339
|
};
|
|
5301
|
-
|
|
5340
|
+
const execPathLengthToUse = perStep ? executionPath.length : currentExecPathLength;
|
|
5341
|
+
if (execPathLengthToUse > 0 && !steps?.includes(stepId) && !context?.[stepId] && (!snapshotContext[stepId] || snapshotContext[stepId] && snapshotContext[stepId].status !== "suspended")) {
|
|
5302
5342
|
result = void 0;
|
|
5303
5343
|
}
|
|
5304
5344
|
if (result) {
|
|
5305
|
-
const formattedResult =
|
|
5345
|
+
const formattedResult = chunkBC2VKOH4_cjs.removeUndefinedValues(result);
|
|
5306
5346
|
stepResults[stepId] = formattedResult;
|
|
5307
5347
|
}
|
|
5308
5348
|
});
|
|
@@ -5327,7 +5367,7 @@ function hydrateSerializedStepErrors(steps) {
|
|
|
5327
5367
|
if (steps) {
|
|
5328
5368
|
for (const step of Object.values(steps)) {
|
|
5329
5369
|
if (step.status === "failed" && "error" in step && step.error) {
|
|
5330
|
-
step.error =
|
|
5370
|
+
step.error = chunk4U7ZLI36_cjs.getErrorFromUnknown(step.error, { serializeStack: false });
|
|
5331
5371
|
}
|
|
5332
5372
|
}
|
|
5333
5373
|
}
|
|
@@ -5353,7 +5393,8 @@ async function executeParallel(engine, params) {
|
|
|
5353
5393
|
abortController,
|
|
5354
5394
|
requestContext,
|
|
5355
5395
|
outputWriter,
|
|
5356
|
-
disableScorers
|
|
5396
|
+
disableScorers,
|
|
5397
|
+
perStep
|
|
5357
5398
|
} = params;
|
|
5358
5399
|
const parallelSpan = tracingContext.currentSpan?.createChildSpan({
|
|
5359
5400
|
type: "workflow_parallel" /* WORKFLOW_PARALLEL */,
|
|
@@ -5375,7 +5416,7 @@ async function executeParallel(engine, params) {
|
|
|
5375
5416
|
makeStepRunning = timeTravel.steps[0] === step.step.id;
|
|
5376
5417
|
}
|
|
5377
5418
|
if (!makeStepRunning) {
|
|
5378
|
-
|
|
5419
|
+
break;
|
|
5379
5420
|
}
|
|
5380
5421
|
const startTime = resume?.steps[0] === step.step.id ? void 0 : Date.now();
|
|
5381
5422
|
const resumeTime = resume?.steps[0] === step.step.id ? Date.now() : void 0;
|
|
@@ -5387,6 +5428,9 @@ async function executeParallel(engine, params) {
|
|
|
5387
5428
|
...resumeTime ? { resumedAt: resumeTime } : {}
|
|
5388
5429
|
};
|
|
5389
5430
|
executionContext.activeStepsPath[step.step.id] = [...executionContext.executionPath, stepIndex];
|
|
5431
|
+
if (perStep) {
|
|
5432
|
+
break;
|
|
5433
|
+
}
|
|
5390
5434
|
}
|
|
5391
5435
|
if (timeTravel && timeTravel.executionPath.length > 0) {
|
|
5392
5436
|
timeTravel.executionPath.shift();
|
|
@@ -5398,6 +5442,9 @@ async function executeParallel(engine, params) {
|
|
|
5398
5442
|
if (currStepResult && currStepResult.status !== "running") {
|
|
5399
5443
|
return currStepResult;
|
|
5400
5444
|
}
|
|
5445
|
+
if (!currStepResult && (perStep || timeTravel)) {
|
|
5446
|
+
return {};
|
|
5447
|
+
}
|
|
5401
5448
|
const stepExecResult = await engine.executeStep({
|
|
5402
5449
|
workflowId,
|
|
5403
5450
|
runId,
|
|
@@ -5426,7 +5473,8 @@ async function executeParallel(engine, params) {
|
|
|
5426
5473
|
abortController,
|
|
5427
5474
|
requestContext,
|
|
5428
5475
|
outputWriter,
|
|
5429
|
-
disableScorers
|
|
5476
|
+
disableScorers,
|
|
5477
|
+
perStep
|
|
5430
5478
|
});
|
|
5431
5479
|
engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
|
|
5432
5480
|
Object.assign(stepResults, stepExecResult.stepResults);
|
|
@@ -5487,7 +5535,8 @@ async function executeConditional(engine, params) {
|
|
|
5487
5535
|
abortController,
|
|
5488
5536
|
requestContext,
|
|
5489
5537
|
outputWriter,
|
|
5490
|
-
disableScorers
|
|
5538
|
+
disableScorers,
|
|
5539
|
+
perStep
|
|
5491
5540
|
} = params;
|
|
5492
5541
|
const conditionalSpan = tracingContext.currentSpan?.createChildSpan({
|
|
5493
5542
|
type: "workflow_conditional" /* WORKFLOW_CONDITIONAL */,
|
|
@@ -5560,8 +5609,8 @@ async function executeConditional(engine, params) {
|
|
|
5560
5609
|
});
|
|
5561
5610
|
return result;
|
|
5562
5611
|
} catch (e) {
|
|
5563
|
-
const errorInstance =
|
|
5564
|
-
const mastraError = new
|
|
5612
|
+
const errorInstance = chunk4U7ZLI36_cjs.getErrorFromUnknown(e, { serializeStack: false });
|
|
5613
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
5565
5614
|
{
|
|
5566
5615
|
id: "WORKFLOW_CONDITION_EVALUATION_FAILED",
|
|
5567
5616
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -5582,7 +5631,18 @@ async function executeConditional(engine, params) {
|
|
|
5582
5631
|
}
|
|
5583
5632
|
})
|
|
5584
5633
|
)).filter((index) => index !== null);
|
|
5585
|
-
|
|
5634
|
+
let stepsToRun = entry.steps.filter((_, index) => truthyIndexes.includes(index));
|
|
5635
|
+
if (perStep || timeTravel && timeTravel.executionPath.length > 0) {
|
|
5636
|
+
const possibleStepsToRun = stepsToRun.filter((s) => {
|
|
5637
|
+
const currStepResult = stepResults[s.step.id];
|
|
5638
|
+
if (timeTravel && timeTravel.executionPath.length > 0) {
|
|
5639
|
+
return timeTravel.steps[0] === s.step.id;
|
|
5640
|
+
}
|
|
5641
|
+
return !currStepResult;
|
|
5642
|
+
});
|
|
5643
|
+
const possibleStepToRun = possibleStepsToRun?.[0];
|
|
5644
|
+
stepsToRun = possibleStepToRun ? [possibleStepToRun] : stepsToRun;
|
|
5645
|
+
}
|
|
5586
5646
|
conditionalSpan?.update({
|
|
5587
5647
|
attributes: {
|
|
5588
5648
|
truthyIndexes,
|
|
@@ -5629,7 +5689,8 @@ async function executeConditional(engine, params) {
|
|
|
5629
5689
|
abortController,
|
|
5630
5690
|
requestContext,
|
|
5631
5691
|
outputWriter,
|
|
5632
|
-
disableScorers
|
|
5692
|
+
disableScorers,
|
|
5693
|
+
perStep
|
|
5633
5694
|
});
|
|
5634
5695
|
engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
|
|
5635
5696
|
Object.assign(stepResults, stepExecResult.stepResults);
|
|
@@ -5691,7 +5752,8 @@ async function executeLoop(engine, params) {
|
|
|
5691
5752
|
requestContext,
|
|
5692
5753
|
outputWriter,
|
|
5693
5754
|
disableScorers,
|
|
5694
|
-
serializedStepGraph
|
|
5755
|
+
serializedStepGraph,
|
|
5756
|
+
perStep
|
|
5695
5757
|
} = params;
|
|
5696
5758
|
const { step, condition } = entry;
|
|
5697
5759
|
const loopSpan = tracingContext.currentSpan?.createChildSpan({
|
|
@@ -5732,7 +5794,8 @@ async function executeLoop(engine, params) {
|
|
|
5732
5794
|
outputWriter,
|
|
5733
5795
|
disableScorers,
|
|
5734
5796
|
serializedStepGraph,
|
|
5735
|
-
iterationCount: iteration + 1
|
|
5797
|
+
iterationCount: iteration + 1,
|
|
5798
|
+
perStep
|
|
5736
5799
|
});
|
|
5737
5800
|
engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
|
|
5738
5801
|
Object.assign(stepResults, stepExecResult.stepResults);
|
|
@@ -5753,7 +5816,7 @@ async function executeLoop(engine, params) {
|
|
|
5753
5816
|
const evalSpan = loopSpan?.createChildSpan({
|
|
5754
5817
|
type: "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */,
|
|
5755
5818
|
name: `condition: '${entry.loopType}'`,
|
|
5756
|
-
input:
|
|
5819
|
+
input: chunkBC2VKOH4_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
|
|
5757
5820
|
attributes: {
|
|
5758
5821
|
conditionIndex: iteration
|
|
5759
5822
|
},
|
|
@@ -5832,7 +5895,8 @@ async function executeForeach(engine, params) {
|
|
|
5832
5895
|
requestContext,
|
|
5833
5896
|
outputWriter,
|
|
5834
5897
|
disableScorers,
|
|
5835
|
-
serializedStepGraph
|
|
5898
|
+
serializedStepGraph,
|
|
5899
|
+
perStep
|
|
5836
5900
|
} = params;
|
|
5837
5901
|
const { step, opts } = entry;
|
|
5838
5902
|
const results = [];
|
|
@@ -5909,7 +5973,8 @@ async function executeForeach(engine, params) {
|
|
|
5909
5973
|
skipEmits: true,
|
|
5910
5974
|
outputWriter,
|
|
5911
5975
|
disableScorers,
|
|
5912
|
-
serializedStepGraph
|
|
5976
|
+
serializedStepGraph,
|
|
5977
|
+
perStep
|
|
5913
5978
|
});
|
|
5914
5979
|
engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
|
|
5915
5980
|
Object.assign(stepResults, stepExecResult.stepResults);
|
|
@@ -6051,7 +6116,8 @@ async function persistStepUpdate(engine, params) {
|
|
|
6051
6116
|
requestContext.forEach((value, key) => {
|
|
6052
6117
|
requestContextObj[key] = value;
|
|
6053
6118
|
});
|
|
6054
|
-
await engine.mastra?.getStorage()?.
|
|
6119
|
+
const workflowsStore = await engine.mastra?.getStorage()?.getStore("workflows");
|
|
6120
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
6055
6121
|
workflowName: workflowId,
|
|
6056
6122
|
runId,
|
|
6057
6123
|
resourceId,
|
|
@@ -6093,7 +6159,8 @@ async function executeEntry(engine, params) {
|
|
|
6093
6159
|
abortController,
|
|
6094
6160
|
requestContext,
|
|
6095
6161
|
outputWriter,
|
|
6096
|
-
disableScorers
|
|
6162
|
+
disableScorers,
|
|
6163
|
+
perStep
|
|
6097
6164
|
} = params;
|
|
6098
6165
|
const prevOutput = engine.getStepOutput(stepResults, prevStep);
|
|
6099
6166
|
let execResults;
|
|
@@ -6117,7 +6184,8 @@ async function executeEntry(engine, params) {
|
|
|
6117
6184
|
requestContext,
|
|
6118
6185
|
outputWriter,
|
|
6119
6186
|
disableScorers,
|
|
6120
|
-
serializedStepGraph
|
|
6187
|
+
serializedStepGraph,
|
|
6188
|
+
perStep
|
|
6121
6189
|
});
|
|
6122
6190
|
execResults = stepExecResult.result;
|
|
6123
6191
|
engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
|
|
@@ -6149,7 +6217,8 @@ async function executeEntry(engine, params) {
|
|
|
6149
6217
|
abortController,
|
|
6150
6218
|
requestContext,
|
|
6151
6219
|
outputWriter,
|
|
6152
|
-
disableScorers
|
|
6220
|
+
disableScorers,
|
|
6221
|
+
perStep
|
|
6153
6222
|
});
|
|
6154
6223
|
engine.applyMutableContext(executionContext, resumedStepResult.mutableContext);
|
|
6155
6224
|
Object.assign(stepResults, resumedStepResult.stepResults);
|
|
@@ -6219,7 +6288,8 @@ async function executeEntry(engine, params) {
|
|
|
6219
6288
|
abortController,
|
|
6220
6289
|
requestContext,
|
|
6221
6290
|
outputWriter,
|
|
6222
|
-
disableScorers
|
|
6291
|
+
disableScorers,
|
|
6292
|
+
perStep
|
|
6223
6293
|
});
|
|
6224
6294
|
} else if (entry.type === "conditional") {
|
|
6225
6295
|
execResults = await engine.executeConditional({
|
|
@@ -6238,7 +6308,8 @@ async function executeEntry(engine, params) {
|
|
|
6238
6308
|
abortController,
|
|
6239
6309
|
requestContext,
|
|
6240
6310
|
outputWriter,
|
|
6241
|
-
disableScorers
|
|
6311
|
+
disableScorers,
|
|
6312
|
+
perStep
|
|
6242
6313
|
});
|
|
6243
6314
|
} else if (entry.type === "loop") {
|
|
6244
6315
|
execResults = await engine.executeLoop({
|
|
@@ -6258,7 +6329,8 @@ async function executeEntry(engine, params) {
|
|
|
6258
6329
|
requestContext,
|
|
6259
6330
|
outputWriter,
|
|
6260
6331
|
disableScorers,
|
|
6261
|
-
serializedStepGraph
|
|
6332
|
+
serializedStepGraph,
|
|
6333
|
+
perStep
|
|
6262
6334
|
});
|
|
6263
6335
|
} else if (entry.type === "foreach") {
|
|
6264
6336
|
execResults = await engine.executeForeach({
|
|
@@ -6278,7 +6350,8 @@ async function executeEntry(engine, params) {
|
|
|
6278
6350
|
requestContext,
|
|
6279
6351
|
outputWriter,
|
|
6280
6352
|
disableScorers,
|
|
6281
|
-
serializedStepGraph
|
|
6353
|
+
serializedStepGraph,
|
|
6354
|
+
perStep
|
|
6282
6355
|
});
|
|
6283
6356
|
} else if (entry.type === "sleep") {
|
|
6284
6357
|
const startedAt = Date.now();
|
|
@@ -6690,7 +6763,8 @@ async function executeStep(engine, params) {
|
|
|
6690
6763
|
disableScorers,
|
|
6691
6764
|
serializedStepGraph,
|
|
6692
6765
|
tracingContext,
|
|
6693
|
-
iterationCount
|
|
6766
|
+
iterationCount,
|
|
6767
|
+
perStep
|
|
6694
6768
|
} = params;
|
|
6695
6769
|
const stepCallId = crypto2.randomUUID();
|
|
6696
6770
|
const { inputData, validationError } = await validateStepInput({
|
|
@@ -6732,10 +6806,9 @@ async function executeStep(engine, params) {
|
|
|
6732
6806
|
const stepSpan = tracingContext.currentSpan?.createChildSpan({
|
|
6733
6807
|
name: `workflow step: '${step.id}'`,
|
|
6734
6808
|
type: "workflow_step" /* WORKFLOW_STEP */,
|
|
6809
|
+
entityType: "workflow_step" /* WORKFLOW_STEP */,
|
|
6810
|
+
entityId: step.id,
|
|
6735
6811
|
input: inputData,
|
|
6736
|
-
attributes: {
|
|
6737
|
-
stepId: step.id
|
|
6738
|
-
},
|
|
6739
6812
|
tracingPolicy: engine.options?.tracingPolicy
|
|
6740
6813
|
});
|
|
6741
6814
|
const operationId = `workflow.${workflowId}.run.${runId}.step.${step.id}.running_ev`;
|
|
@@ -6777,7 +6850,8 @@ async function executeStep(engine, params) {
|
|
|
6777
6850
|
requestContext,
|
|
6778
6851
|
tracingContext,
|
|
6779
6852
|
outputWriter,
|
|
6780
|
-
stepSpan
|
|
6853
|
+
stepSpan,
|
|
6854
|
+
perStep
|
|
6781
6855
|
});
|
|
6782
6856
|
if (workflowResult !== null) {
|
|
6783
6857
|
const stepResult2 = { ...stepInfo, ...workflowResult };
|
|
@@ -6823,7 +6897,7 @@ async function executeStep(engine, params) {
|
|
|
6823
6897
|
runId,
|
|
6824
6898
|
resourceId,
|
|
6825
6899
|
workflowId,
|
|
6826
|
-
mastra: engine.mastra ?
|
|
6900
|
+
mastra: engine.mastra ? chunkO2CAMK4A_cjs.wrapMastra(engine.mastra, { currentSpan: stepSpan }) : void 0,
|
|
6827
6901
|
requestContext,
|
|
6828
6902
|
inputData,
|
|
6829
6903
|
state: executionContext.state,
|
|
@@ -6909,12 +6983,15 @@ async function executeStep(engine, params) {
|
|
|
6909
6983
|
outputWriter,
|
|
6910
6984
|
// Disable scorers must be explicitly set to false they are on by default
|
|
6911
6985
|
scorers: disableScorers === false ? void 0 : step.scorers,
|
|
6912
|
-
validateInputs: engine.options?.validateInputs
|
|
6986
|
+
validateInputs: engine.options?.validateInputs,
|
|
6987
|
+
perStep
|
|
6913
6988
|
});
|
|
6914
6989
|
if (engine.requiresDurableContextSerialization()) {
|
|
6915
6990
|
contextMutations.requestContextUpdate = engine.serializeRequestContext(requestContext);
|
|
6916
6991
|
}
|
|
6917
|
-
|
|
6992
|
+
const isNestedWorkflowStep = step.component === "WORKFLOW";
|
|
6993
|
+
const nestedWflowStepPaused = isNestedWorkflowStep && perStep;
|
|
6994
|
+
return { output, suspended, bailed, contextMutations, nestedWflowStepPaused };
|
|
6918
6995
|
},
|
|
6919
6996
|
{ retries, delay: delay2, stepSpan, workflowId, runId }
|
|
6920
6997
|
);
|
|
@@ -6953,6 +7030,8 @@ async function executeStep(engine, params) {
|
|
|
6953
7030
|
};
|
|
6954
7031
|
} else if (durableResult.bailed) {
|
|
6955
7032
|
execResults = { status: "bailed", output: durableResult.bailed.payload, endedAt: Date.now() };
|
|
7033
|
+
} else if (durableResult.nestedWflowStepPaused) {
|
|
7034
|
+
execResults = { status: "paused" };
|
|
6956
7035
|
} else {
|
|
6957
7036
|
execResults = { status: "success", output: durableResult.output, endedAt: Date.now() };
|
|
6958
7037
|
}
|
|
@@ -6998,8 +7077,8 @@ async function runScorersForStep(params) {
|
|
|
6998
7077
|
requestContext
|
|
6999
7078
|
});
|
|
7000
7079
|
} catch (e) {
|
|
7001
|
-
const errorInstance =
|
|
7002
|
-
const mastraError = new
|
|
7080
|
+
const errorInstance = chunk4U7ZLI36_cjs.getErrorFromUnknown(e, { serializeStack: false });
|
|
7081
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
7003
7082
|
{
|
|
7004
7083
|
id: "WORKFLOW_FAILED_TO_FETCH_SCORERS",
|
|
7005
7084
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -7217,11 +7296,11 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
7217
7296
|
return { ok: true, result };
|
|
7218
7297
|
} catch (e) {
|
|
7219
7298
|
if (i === params.retries) {
|
|
7220
|
-
const errorInstance =
|
|
7299
|
+
const errorInstance = chunk4U7ZLI36_cjs.getErrorFromUnknown(e, {
|
|
7221
7300
|
serializeStack: false,
|
|
7222
7301
|
fallbackMessage: "Unknown step execution error"
|
|
7223
7302
|
});
|
|
7224
|
-
const mastraError = new
|
|
7303
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
7225
7304
|
{
|
|
7226
7305
|
id: "WORKFLOW_STEP_INVOKE_FAILED",
|
|
7227
7306
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -7263,7 +7342,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
7263
7342
|
formatResultError(error, lastOutput) {
|
|
7264
7343
|
const outputError = lastOutput?.error;
|
|
7265
7344
|
const errorSource = error || outputError;
|
|
7266
|
-
const errorInstance =
|
|
7345
|
+
const errorInstance = chunk4U7ZLI36_cjs.getErrorFromUnknown(errorSource, {
|
|
7267
7346
|
serializeStack: false,
|
|
7268
7347
|
fallbackMessage: "Unknown workflow error"
|
|
7269
7348
|
});
|
|
@@ -7376,13 +7455,14 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
7376
7455
|
workflowSpan,
|
|
7377
7456
|
disableScorers,
|
|
7378
7457
|
restart,
|
|
7379
|
-
timeTravel
|
|
7458
|
+
timeTravel,
|
|
7459
|
+
perStep
|
|
7380
7460
|
} = params;
|
|
7381
7461
|
const { attempts = 0, delay: delay2 = 0 } = retryConfig ?? {};
|
|
7382
7462
|
const steps = graph.steps;
|
|
7383
7463
|
this.retryCounts.clear();
|
|
7384
7464
|
if (steps.length === 0) {
|
|
7385
|
-
const empty_graph_error = new
|
|
7465
|
+
const empty_graph_error = new chunk4U7ZLI36_cjs.MastraError({
|
|
7386
7466
|
id: "WORKFLOW_EXECUTE_EMPTY_GRAPH",
|
|
7387
7467
|
text: "Workflow must have at least one step",
|
|
7388
7468
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -7440,7 +7520,8 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
7440
7520
|
pubsub: params.pubsub,
|
|
7441
7521
|
requestContext: currentRequestContext,
|
|
7442
7522
|
outputWriter: params.outputWriter,
|
|
7443
|
-
disableScorers
|
|
7523
|
+
disableScorers,
|
|
7524
|
+
perStep
|
|
7444
7525
|
});
|
|
7445
7526
|
this.applyMutableContext(executionContext, lastOutput.mutableContext);
|
|
7446
7527
|
lastState = lastOutput.mutableContext.state;
|
|
@@ -7479,13 +7560,47 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
7479
7560
|
}
|
|
7480
7561
|
});
|
|
7481
7562
|
}
|
|
7482
|
-
|
|
7563
|
+
if (lastOutput.result.status !== "paused") {
|
|
7564
|
+
await this.invokeLifecycleCallbacks(result2);
|
|
7565
|
+
}
|
|
7566
|
+
if (lastOutput.result.status === "paused") {
|
|
7567
|
+
await params.pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
7568
|
+
type: "watch",
|
|
7569
|
+
runId,
|
|
7570
|
+
data: { type: "workflow-paused", payload: {} }
|
|
7571
|
+
});
|
|
7572
|
+
}
|
|
7483
7573
|
return {
|
|
7484
7574
|
...result2,
|
|
7485
7575
|
...lastOutput.result.status === "suspended" && params.outputOptions?.includeResumeLabels ? { resumeLabels: lastOutput.mutableContext.resumeLabels } : {},
|
|
7486
7576
|
...params.outputOptions?.includeState ? { state: lastState } : {}
|
|
7487
7577
|
};
|
|
7488
7578
|
}
|
|
7579
|
+
if (perStep) {
|
|
7580
|
+
const result2 = await this.fmtReturnValue(params.pubsub, stepResults, lastOutput.result);
|
|
7581
|
+
await this.persistStepUpdate({
|
|
7582
|
+
workflowId,
|
|
7583
|
+
runId,
|
|
7584
|
+
resourceId,
|
|
7585
|
+
stepResults: lastOutput.stepResults,
|
|
7586
|
+
serializedStepGraph: params.serializedStepGraph,
|
|
7587
|
+
executionContext: lastExecutionContext,
|
|
7588
|
+
workflowStatus: "paused",
|
|
7589
|
+
requestContext: currentRequestContext
|
|
7590
|
+
});
|
|
7591
|
+
await params.pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
7592
|
+
type: "watch",
|
|
7593
|
+
runId,
|
|
7594
|
+
data: { type: "workflow-paused", payload: {} }
|
|
7595
|
+
});
|
|
7596
|
+
workflowSpan?.end({
|
|
7597
|
+
attributes: {
|
|
7598
|
+
status: "paused"
|
|
7599
|
+
}
|
|
7600
|
+
});
|
|
7601
|
+
delete result2.result;
|
|
7602
|
+
return { ...result2, status: "paused", ...params.outputOptions?.includeState ? { state: lastState } : {} };
|
|
7603
|
+
}
|
|
7489
7604
|
}
|
|
7490
7605
|
const result = await this.fmtReturnValue(params.pubsub, stepResults, lastOutput.result);
|
|
7491
7606
|
await this.persistStepUpdate({
|
|
@@ -7694,7 +7809,7 @@ function createStep(params, agentOptions) {
|
|
|
7694
7809
|
component: params.component
|
|
7695
7810
|
};
|
|
7696
7811
|
}
|
|
7697
|
-
if (params instanceof
|
|
7812
|
+
if (params instanceof chunk6HJFCSJ4_cjs.Tool) {
|
|
7698
7813
|
if (!params.inputSchema || !params.outputSchema) {
|
|
7699
7814
|
throw new Error("Tool must have input and output schemas defined");
|
|
7700
7815
|
}
|
|
@@ -7788,7 +7903,7 @@ function createStep(params, agentOptions) {
|
|
|
7788
7903
|
phase,
|
|
7789
7904
|
// Auto-create MessageList from messages if not provided
|
|
7790
7905
|
// This enables running processor workflows from the UI where messageList can't be serialized
|
|
7791
|
-
messageList: messageList ?? (Array.isArray(messages) ? new
|
|
7906
|
+
messageList: messageList ?? (Array.isArray(messages) ? new chunkEMLEZXTQ_cjs.MessageList().add(messages, "input").addSystem(systemMessages ?? []) : void 0),
|
|
7792
7907
|
stepNumber,
|
|
7793
7908
|
systemMessages,
|
|
7794
7909
|
streamParts,
|
|
@@ -7811,7 +7926,7 @@ function createStep(params, agentOptions) {
|
|
|
7811
7926
|
case "input": {
|
|
7812
7927
|
if (processor.processInput) {
|
|
7813
7928
|
if (!passThrough.messageList) {
|
|
7814
|
-
throw new
|
|
7929
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
7815
7930
|
category: "USER" /* USER */,
|
|
7816
7931
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
7817
7932
|
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
@@ -7841,9 +7956,9 @@ function createStep(params, agentOptions) {
|
|
|
7841
7956
|
}
|
|
7842
7957
|
}
|
|
7843
7958
|
};
|
|
7844
|
-
if (result instanceof
|
|
7959
|
+
if (result instanceof chunkEMLEZXTQ_cjs.MessageList) {
|
|
7845
7960
|
if (result !== passThrough.messageList) {
|
|
7846
|
-
throw new
|
|
7961
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
7847
7962
|
category: "USER" /* USER */,
|
|
7848
7963
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
7849
7964
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -7875,7 +7990,7 @@ function createStep(params, agentOptions) {
|
|
|
7875
7990
|
case "inputStep": {
|
|
7876
7991
|
if (processor.processInputStep) {
|
|
7877
7992
|
if (!passThrough.messageList) {
|
|
7878
|
-
throw new
|
|
7993
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
7879
7994
|
category: "USER" /* USER */,
|
|
7880
7995
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
7881
7996
|
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
@@ -7937,7 +8052,7 @@ function createStep(params, agentOptions) {
|
|
|
7937
8052
|
case "outputResult": {
|
|
7938
8053
|
if (processor.processOutputResult) {
|
|
7939
8054
|
if (!passThrough.messageList) {
|
|
7940
|
-
throw new
|
|
8055
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
7941
8056
|
category: "USER" /* USER */,
|
|
7942
8057
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
7943
8058
|
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
@@ -7966,9 +8081,9 @@ function createStep(params, agentOptions) {
|
|
|
7966
8081
|
}
|
|
7967
8082
|
}
|
|
7968
8083
|
};
|
|
7969
|
-
if (result instanceof
|
|
8084
|
+
if (result instanceof chunkEMLEZXTQ_cjs.MessageList) {
|
|
7970
8085
|
if (result !== passThrough.messageList) {
|
|
7971
|
-
throw new
|
|
8086
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
7972
8087
|
category: "USER" /* USER */,
|
|
7973
8088
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
7974
8089
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -8000,7 +8115,7 @@ function createStep(params, agentOptions) {
|
|
|
8000
8115
|
case "outputStep": {
|
|
8001
8116
|
if (processor.processOutputStep) {
|
|
8002
8117
|
if (!passThrough.messageList) {
|
|
8003
|
-
throw new
|
|
8118
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
8004
8119
|
category: "USER" /* USER */,
|
|
8005
8120
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
8006
8121
|
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
@@ -8017,7 +8132,8 @@ function createStep(params, agentOptions) {
|
|
|
8017
8132
|
finishReason,
|
|
8018
8133
|
toolCalls,
|
|
8019
8134
|
text,
|
|
8020
|
-
systemMessages: systemMessages ?? []
|
|
8135
|
+
systemMessages: systemMessages ?? [],
|
|
8136
|
+
steps: steps ?? []
|
|
8021
8137
|
});
|
|
8022
8138
|
const applyMessages = (msgs) => {
|
|
8023
8139
|
const deletedIds = idsBeforeProcessing.filter((i) => !msgs.some((m) => m.id === i));
|
|
@@ -8034,9 +8150,9 @@ function createStep(params, agentOptions) {
|
|
|
8034
8150
|
}
|
|
8035
8151
|
}
|
|
8036
8152
|
};
|
|
8037
|
-
if (result instanceof
|
|
8153
|
+
if (result instanceof chunkEMLEZXTQ_cjs.MessageList) {
|
|
8038
8154
|
if (result !== passThrough.messageList) {
|
|
8039
|
-
throw new
|
|
8155
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
8040
8156
|
category: "USER" /* USER */,
|
|
8041
8157
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
8042
8158
|
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
@@ -8101,7 +8217,7 @@ function cloneStep(step, opts) {
|
|
|
8101
8217
|
};
|
|
8102
8218
|
}
|
|
8103
8219
|
function isProcessor(obj) {
|
|
8104
|
-
return obj !== null && typeof obj === "object" && "id" in obj && typeof obj.id === "string" && !(obj instanceof Agent) && !(obj instanceof
|
|
8220
|
+
return obj !== null && typeof obj === "object" && "id" in obj && typeof obj.id === "string" && !(obj instanceof Agent) && !(obj instanceof chunk6HJFCSJ4_cjs.Tool) && (typeof obj.processInput === "function" || typeof obj.processInputStep === "function" || typeof obj.processOutputStream === "function" || typeof obj.processOutputResult === "function" || typeof obj.processOutputStep === "function");
|
|
8105
8221
|
}
|
|
8106
8222
|
function createWorkflow(params) {
|
|
8107
8223
|
return new Workflow(params);
|
|
@@ -8272,7 +8388,7 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8272
8388
|
* @deprecated waitForEvent has been removed. Please use suspend/resume instead.
|
|
8273
8389
|
*/
|
|
8274
8390
|
waitForEvent(_event, _step, _opts) {
|
|
8275
|
-
throw new
|
|
8391
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
8276
8392
|
id: "WORKFLOW_WAIT_FOR_EVENT_REMOVED",
|
|
8277
8393
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
8278
8394
|
category: "USER" /* USER */,
|
|
@@ -8283,8 +8399,8 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8283
8399
|
if (typeof mappingConfig === "function") {
|
|
8284
8400
|
const mappingStep2 = createStep({
|
|
8285
8401
|
id: stepOptions?.id || `mapping_${this.#mastra?.generateId() || crypto2.randomUUID()}`,
|
|
8286
|
-
inputSchema: z8.z.
|
|
8287
|
-
outputSchema: z8.z.
|
|
8402
|
+
inputSchema: z8.z.any(),
|
|
8403
|
+
outputSchema: z8.z.any(),
|
|
8288
8404
|
execute: mappingConfig
|
|
8289
8405
|
});
|
|
8290
8406
|
this.stepFlow.push({ type: "step", step: mappingStep2 });
|
|
@@ -8340,7 +8456,15 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8340
8456
|
result[key] = requestContext.get(m.requestContextPath);
|
|
8341
8457
|
continue;
|
|
8342
8458
|
}
|
|
8343
|
-
const stepResult = m.initData ? getInitData() : getStepResult2(
|
|
8459
|
+
const stepResult = m.initData ? getInitData() : getStepResult2(
|
|
8460
|
+
Array.isArray(m.step) ? m.step.find((s) => {
|
|
8461
|
+
const result2 = getStepResult2(s);
|
|
8462
|
+
if (typeof result2 === "object" && result2 !== null) {
|
|
8463
|
+
return Object.keys(result2).length > 0;
|
|
8464
|
+
}
|
|
8465
|
+
return result2;
|
|
8466
|
+
}) : m.step
|
|
8467
|
+
);
|
|
8344
8468
|
if (m.path === ".") {
|
|
8345
8469
|
result[key] = stepResult;
|
|
8346
8470
|
continue;
|
|
@@ -8558,7 +8682,8 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8558
8682
|
run.workflowRunStatus = workflowSnapshotInStorage.status;
|
|
8559
8683
|
}
|
|
8560
8684
|
if (!workflowSnapshotInStorage && shouldPersistSnapshot) {
|
|
8561
|
-
await this.mastra?.getStorage()?.
|
|
8685
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
8686
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
8562
8687
|
workflowName: this.id,
|
|
8563
8688
|
runId: runIdToUse,
|
|
8564
8689
|
resourceId: options?.resourceId,
|
|
@@ -8623,7 +8748,8 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8623
8748
|
retryCount,
|
|
8624
8749
|
tracingContext,
|
|
8625
8750
|
outputWriter,
|
|
8626
|
-
validateInputs
|
|
8751
|
+
validateInputs,
|
|
8752
|
+
perStep
|
|
8627
8753
|
}) {
|
|
8628
8754
|
this.__registerMastra(mastra);
|
|
8629
8755
|
const effectiveValidateInputs = validateInputs ?? this.#options.validateInputs ?? true;
|
|
@@ -8671,7 +8797,8 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8671
8797
|
requestContext,
|
|
8672
8798
|
tracingContext,
|
|
8673
8799
|
outputWriter,
|
|
8674
|
-
outputOptions: { includeState: true, includeResumeLabels: true }
|
|
8800
|
+
outputOptions: { includeState: true, includeResumeLabels: true },
|
|
8801
|
+
perStep
|
|
8675
8802
|
});
|
|
8676
8803
|
} else if (restart) {
|
|
8677
8804
|
res = await run.restart({ requestContext, tracingContext, outputWriter });
|
|
@@ -8683,7 +8810,8 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8683
8810
|
tracingContext,
|
|
8684
8811
|
outputWriter,
|
|
8685
8812
|
outputOptions: { includeState: true, includeResumeLabels: true },
|
|
8686
|
-
label: resume.label
|
|
8813
|
+
label: resume.label,
|
|
8814
|
+
perStep
|
|
8687
8815
|
});
|
|
8688
8816
|
} else {
|
|
8689
8817
|
res = await run.start({
|
|
@@ -8692,7 +8820,8 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8692
8820
|
tracingContext,
|
|
8693
8821
|
outputWriter,
|
|
8694
8822
|
initialState: state,
|
|
8695
|
-
outputOptions: { includeState: true, includeResumeLabels: true }
|
|
8823
|
+
outputOptions: { includeState: true, includeResumeLabels: true },
|
|
8824
|
+
perStep
|
|
8696
8825
|
});
|
|
8697
8826
|
}
|
|
8698
8827
|
unwatch();
|
|
@@ -8728,7 +8857,12 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8728
8857
|
this.logger.debug("Cannot get workflow runs. Mastra storage is not initialized");
|
|
8729
8858
|
return { runs: [], total: 0 };
|
|
8730
8859
|
}
|
|
8731
|
-
|
|
8860
|
+
const workflowsStore = await storage.getStore("workflows");
|
|
8861
|
+
if (!workflowsStore) {
|
|
8862
|
+
this.logger.debug("Cannot get workflow runs. Workflows storage domain is not available");
|
|
8863
|
+
return { runs: [], total: 0 };
|
|
8864
|
+
}
|
|
8865
|
+
return workflowsStore.listWorkflowRuns({ workflowName: this.id, ...args ?? {} });
|
|
8732
8866
|
}
|
|
8733
8867
|
async listActiveWorkflowRuns() {
|
|
8734
8868
|
const runningRuns = await this.listWorkflowRuns({ status: "running" });
|
|
@@ -8765,7 +8899,12 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8765
8899
|
this.logger.debug("Cannot get workflow runs from storage. Mastra storage is not initialized");
|
|
8766
8900
|
return this.#runs.get(runId) ? { ...this.#runs.get(runId), workflowName: this.id } : null;
|
|
8767
8901
|
}
|
|
8768
|
-
const
|
|
8902
|
+
const workflowsStore = await storage.getStore("workflows");
|
|
8903
|
+
if (!workflowsStore) {
|
|
8904
|
+
this.logger.debug("Cannot get workflow runs. Workflows storage domain is not available");
|
|
8905
|
+
return this.#runs.get(runId) ? { ...this.#runs.get(runId), workflowName: this.id } : null;
|
|
8906
|
+
}
|
|
8907
|
+
const run = await workflowsStore.getWorkflowRunById({ runId, workflowName: this.id });
|
|
8769
8908
|
return run ?? (this.#runs.get(runId) ? { ...this.#runs.get(runId), workflowName: this.id } : null);
|
|
8770
8909
|
}
|
|
8771
8910
|
async deleteWorkflowRunById(runId) {
|
|
@@ -8774,7 +8913,12 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8774
8913
|
this.logger.debug("Cannot delete workflow run by ID. Mastra storage is not initialized");
|
|
8775
8914
|
return;
|
|
8776
8915
|
}
|
|
8777
|
-
await storage.
|
|
8916
|
+
const workflowsStore = await storage.getStore("workflows");
|
|
8917
|
+
if (!workflowsStore) {
|
|
8918
|
+
this.logger.debug("Cannot delete workflow run. Workflows storage domain is not available");
|
|
8919
|
+
return;
|
|
8920
|
+
}
|
|
8921
|
+
await workflowsStore.deleteWorkflowRunById({ runId, workflowName: this.id });
|
|
8778
8922
|
this.#runs.delete(runId);
|
|
8779
8923
|
}
|
|
8780
8924
|
async getWorkflowRunSteps({ runId, workflowId }) {
|
|
@@ -8783,7 +8927,12 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8783
8927
|
this.logger.debug("Cannot get workflow run steps. Mastra storage is not initialized");
|
|
8784
8928
|
return {};
|
|
8785
8929
|
}
|
|
8786
|
-
const
|
|
8930
|
+
const workflowsStore = await storage.getStore("workflows");
|
|
8931
|
+
if (!workflowsStore) {
|
|
8932
|
+
this.logger.debug("Cannot get workflow run steps. Workflows storage domain is not available");
|
|
8933
|
+
return {};
|
|
8934
|
+
}
|
|
8935
|
+
const run = await workflowsStore.getWorkflowRunById({ runId, workflowName: workflowId });
|
|
8787
8936
|
let snapshot = run?.snapshot;
|
|
8788
8937
|
if (!snapshot) {
|
|
8789
8938
|
return {};
|
|
@@ -8825,7 +8974,12 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8825
8974
|
this.logger.debug("Cannot get workflow run execution result. Mastra storage is not initialized");
|
|
8826
8975
|
return null;
|
|
8827
8976
|
}
|
|
8828
|
-
const
|
|
8977
|
+
const workflowsStore = await storage.getStore("workflows");
|
|
8978
|
+
if (!workflowsStore) {
|
|
8979
|
+
this.logger.debug("Cannot get workflow run execution result. Workflows storage domain is not available");
|
|
8980
|
+
return null;
|
|
8981
|
+
}
|
|
8982
|
+
const run = await workflowsStore.getWorkflowRunById({ runId, workflowName: this.id });
|
|
8829
8983
|
let snapshot = run?.snapshot;
|
|
8830
8984
|
if (!snapshot) {
|
|
8831
8985
|
return null;
|
|
@@ -8984,7 +9138,8 @@ var Run = class {
|
|
|
8984
9138
|
this.abortController.abort();
|
|
8985
9139
|
this.workflowRunStatus = "canceled";
|
|
8986
9140
|
try {
|
|
8987
|
-
await this.mastra?.getStorage()?.
|
|
9141
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
9142
|
+
await workflowsStore?.updateWorkflowState({
|
|
8988
9143
|
workflowName: this.workflowId,
|
|
8989
9144
|
runId: this.runId,
|
|
8990
9145
|
opts: {
|
|
@@ -9062,15 +9217,15 @@ var Run = class {
|
|
|
9062
9217
|
tracingContext,
|
|
9063
9218
|
tracingOptions,
|
|
9064
9219
|
format,
|
|
9065
|
-
outputOptions
|
|
9220
|
+
outputOptions,
|
|
9221
|
+
perStep
|
|
9066
9222
|
}) {
|
|
9067
|
-
const workflowSpan =
|
|
9223
|
+
const workflowSpan = chunkO2CAMK4A_cjs.getOrCreateSpan({
|
|
9068
9224
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
9069
9225
|
name: `workflow run: '${this.workflowId}'`,
|
|
9226
|
+
entityType: "workflow_run" /* WORKFLOW_RUN */,
|
|
9227
|
+
entityId: this.workflowId,
|
|
9070
9228
|
input: inputData,
|
|
9071
|
-
attributes: {
|
|
9072
|
-
workflowId: this.workflowId
|
|
9073
|
-
},
|
|
9074
9229
|
metadata: {
|
|
9075
9230
|
resourceId: this.resourceId,
|
|
9076
9231
|
runId: this.runId
|
|
@@ -9100,7 +9255,8 @@ var Run = class {
|
|
|
9100
9255
|
outputWriter,
|
|
9101
9256
|
workflowSpan,
|
|
9102
9257
|
format,
|
|
9103
|
-
outputOptions
|
|
9258
|
+
outputOptions,
|
|
9259
|
+
perStep
|
|
9104
9260
|
});
|
|
9105
9261
|
if (result.status !== "suspended") {
|
|
9106
9262
|
this.cleanup?.();
|
|
@@ -9267,9 +9423,10 @@ var Run = class {
|
|
|
9267
9423
|
}
|
|
9268
9424
|
async streamAsync({
|
|
9269
9425
|
inputData,
|
|
9270
|
-
requestContext
|
|
9426
|
+
requestContext,
|
|
9427
|
+
perStep
|
|
9271
9428
|
} = {}) {
|
|
9272
|
-
return this.stream({ inputData, requestContext });
|
|
9429
|
+
return this.stream({ inputData, requestContext, perStep });
|
|
9273
9430
|
}
|
|
9274
9431
|
/**
|
|
9275
9432
|
* Starts the workflow execution with the provided input as a stream
|
|
@@ -9283,7 +9440,8 @@ var Run = class {
|
|
|
9283
9440
|
tracingOptions,
|
|
9284
9441
|
closeOnSuspend = true,
|
|
9285
9442
|
initialState,
|
|
9286
|
-
outputOptions
|
|
9443
|
+
outputOptions,
|
|
9444
|
+
perStep
|
|
9287
9445
|
} = {}) {
|
|
9288
9446
|
if (this.closeStreamAction && this.streamOutput) {
|
|
9289
9447
|
return this.streamOutput;
|
|
@@ -9338,7 +9496,8 @@ var Run = class {
|
|
|
9338
9496
|
runId: self.runId,
|
|
9339
9497
|
data: chunk
|
|
9340
9498
|
});
|
|
9341
|
-
}
|
|
9499
|
+
},
|
|
9500
|
+
perStep
|
|
9342
9501
|
});
|
|
9343
9502
|
let executionResults;
|
|
9344
9503
|
try {
|
|
@@ -9380,7 +9539,8 @@ var Run = class {
|
|
|
9380
9539
|
requestContext,
|
|
9381
9540
|
tracingContext,
|
|
9382
9541
|
tracingOptions,
|
|
9383
|
-
outputOptions
|
|
9542
|
+
outputOptions,
|
|
9543
|
+
perStep
|
|
9384
9544
|
} = {}) {
|
|
9385
9545
|
return this.resumeStreamVNext({
|
|
9386
9546
|
resumeData,
|
|
@@ -9388,7 +9548,8 @@ var Run = class {
|
|
|
9388
9548
|
requestContext,
|
|
9389
9549
|
tracingContext,
|
|
9390
9550
|
tracingOptions,
|
|
9391
|
-
outputOptions
|
|
9551
|
+
outputOptions,
|
|
9552
|
+
perStep
|
|
9392
9553
|
});
|
|
9393
9554
|
}
|
|
9394
9555
|
/**
|
|
@@ -9403,7 +9564,8 @@ var Run = class {
|
|
|
9403
9564
|
tracingContext,
|
|
9404
9565
|
tracingOptions,
|
|
9405
9566
|
forEachIndex,
|
|
9406
|
-
outputOptions
|
|
9567
|
+
outputOptions,
|
|
9568
|
+
perStep
|
|
9407
9569
|
} = {}) {
|
|
9408
9570
|
this.closeStreamAction = async () => {
|
|
9409
9571
|
};
|
|
@@ -9453,7 +9615,8 @@ var Run = class {
|
|
|
9453
9615
|
},
|
|
9454
9616
|
isVNext: true,
|
|
9455
9617
|
forEachIndex,
|
|
9456
|
-
outputOptions
|
|
9618
|
+
outputOptions,
|
|
9619
|
+
perStep
|
|
9457
9620
|
});
|
|
9458
9621
|
self.executionResults = executionResultsPromise;
|
|
9459
9622
|
let executionResults;
|
|
@@ -9524,7 +9687,8 @@ var Run = class {
|
|
|
9524
9687
|
return this._restart(args);
|
|
9525
9688
|
}
|
|
9526
9689
|
async _resume(params) {
|
|
9527
|
-
const
|
|
9690
|
+
const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
|
|
9691
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
9528
9692
|
workflowName: this.workflowId,
|
|
9529
9693
|
runId: this.runId
|
|
9530
9694
|
});
|
|
@@ -9596,13 +9760,12 @@ var Run = class {
|
|
|
9596
9760
|
requestContextToUse.set(key, value);
|
|
9597
9761
|
}
|
|
9598
9762
|
});
|
|
9599
|
-
const workflowSpan =
|
|
9763
|
+
const workflowSpan = chunkO2CAMK4A_cjs.getOrCreateSpan({
|
|
9600
9764
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
9601
9765
|
name: `workflow run: '${this.workflowId}'`,
|
|
9766
|
+
entityType: "workflow_run" /* WORKFLOW_RUN */,
|
|
9767
|
+
entityId: this.workflowId,
|
|
9602
9768
|
input: resumeDataToUse,
|
|
9603
|
-
attributes: {
|
|
9604
|
-
workflowId: this.workflowId
|
|
9605
|
-
},
|
|
9606
9769
|
metadata: {
|
|
9607
9770
|
resourceId: this.resourceId,
|
|
9608
9771
|
runId: this.runId
|
|
@@ -9637,7 +9800,8 @@ var Run = class {
|
|
|
9637
9800
|
abortController: this.abortController,
|
|
9638
9801
|
workflowSpan,
|
|
9639
9802
|
outputOptions: params.outputOptions,
|
|
9640
|
-
outputWriter: params.outputWriter
|
|
9803
|
+
outputWriter: params.outputWriter,
|
|
9804
|
+
perStep: params.perStep
|
|
9641
9805
|
}).then((result) => {
|
|
9642
9806
|
if (!params.isVNext && result.status !== "suspended") {
|
|
9643
9807
|
this.closeStreamAction?.().catch(() => {
|
|
@@ -9661,7 +9825,8 @@ var Run = class {
|
|
|
9661
9825
|
if (this.workflowEngineType !== "default") {
|
|
9662
9826
|
throw new Error(`restart() is not supported on ${this.workflowEngineType} workflows`);
|
|
9663
9827
|
}
|
|
9664
|
-
const
|
|
9828
|
+
const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
|
|
9829
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
9665
9830
|
workflowName: this.workflowId,
|
|
9666
9831
|
runId: this.runId
|
|
9667
9832
|
});
|
|
@@ -9707,12 +9872,11 @@ var Run = class {
|
|
|
9707
9872
|
requestContextToUse.set(key, value);
|
|
9708
9873
|
}
|
|
9709
9874
|
}
|
|
9710
|
-
const workflowSpan =
|
|
9875
|
+
const workflowSpan = chunkO2CAMK4A_cjs.getOrCreateSpan({
|
|
9711
9876
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
9712
9877
|
name: `workflow run: '${this.workflowId}'`,
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
},
|
|
9878
|
+
entityType: "workflow_run" /* WORKFLOW_RUN */,
|
|
9879
|
+
entityId: this.workflowId,
|
|
9716
9880
|
metadata: {
|
|
9717
9881
|
resourceId: this.resourceId,
|
|
9718
9882
|
runId: this.runId
|
|
@@ -9756,12 +9920,14 @@ var Run = class {
|
|
|
9756
9920
|
outputWriter,
|
|
9757
9921
|
tracingContext,
|
|
9758
9922
|
tracingOptions,
|
|
9759
|
-
outputOptions
|
|
9923
|
+
outputOptions,
|
|
9924
|
+
perStep
|
|
9760
9925
|
}) {
|
|
9761
9926
|
if (!stepParam || Array.isArray(stepParam) && stepParam.length === 0) {
|
|
9762
9927
|
throw new Error("Step is required and must be a valid step or array of steps");
|
|
9763
9928
|
}
|
|
9764
|
-
const
|
|
9929
|
+
const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
|
|
9930
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
9765
9931
|
workflowName: this.workflowId,
|
|
9766
9932
|
runId: this.runId
|
|
9767
9933
|
});
|
|
@@ -9791,7 +9957,8 @@ var Run = class {
|
|
|
9791
9957
|
nestedStepsContext,
|
|
9792
9958
|
snapshot,
|
|
9793
9959
|
initialState,
|
|
9794
|
-
graph: this.executionGraph
|
|
9960
|
+
graph: this.executionGraph,
|
|
9961
|
+
perStep
|
|
9795
9962
|
});
|
|
9796
9963
|
const requestContextToUse = requestContext ?? new chunkUVHSM2GU_cjs.RequestContext();
|
|
9797
9964
|
for (const [key, value] of Object.entries(snapshot.requestContext ?? {})) {
|
|
@@ -9799,13 +9966,12 @@ var Run = class {
|
|
|
9799
9966
|
requestContextToUse.set(key, value);
|
|
9800
9967
|
}
|
|
9801
9968
|
}
|
|
9802
|
-
const workflowSpan =
|
|
9969
|
+
const workflowSpan = chunkO2CAMK4A_cjs.getOrCreateSpan({
|
|
9803
9970
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
9804
9971
|
name: `workflow run: '${this.workflowId}'`,
|
|
9805
9972
|
input: inputData,
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
},
|
|
9973
|
+
entityType: "workflow_run" /* WORKFLOW_RUN */,
|
|
9974
|
+
entityId: this.workflowId,
|
|
9809
9975
|
metadata: {
|
|
9810
9976
|
resourceId: this.resourceId,
|
|
9811
9977
|
runId: this.runId
|
|
@@ -9831,7 +9997,8 @@ var Run = class {
|
|
|
9831
9997
|
abortController: this.abortController,
|
|
9832
9998
|
outputWriter,
|
|
9833
9999
|
workflowSpan,
|
|
9834
|
-
outputOptions
|
|
10000
|
+
outputOptions,
|
|
10001
|
+
perStep
|
|
9835
10002
|
});
|
|
9836
10003
|
if (result.status !== "suspended") {
|
|
9837
10004
|
this.cleanup?.();
|
|
@@ -9852,7 +10019,8 @@ var Run = class {
|
|
|
9852
10019
|
requestContext,
|
|
9853
10020
|
tracingContext,
|
|
9854
10021
|
tracingOptions,
|
|
9855
|
-
outputOptions
|
|
10022
|
+
outputOptions,
|
|
10023
|
+
perStep
|
|
9856
10024
|
}) {
|
|
9857
10025
|
this.closeStreamAction = async () => {
|
|
9858
10026
|
};
|
|
@@ -9893,7 +10061,8 @@ var Run = class {
|
|
|
9893
10061
|
outputWriter: async (chunk) => {
|
|
9894
10062
|
void controller.enqueue(chunk);
|
|
9895
10063
|
},
|
|
9896
|
-
outputOptions
|
|
10064
|
+
outputOptions,
|
|
10065
|
+
perStep
|
|
9897
10066
|
});
|
|
9898
10067
|
self.executionResults = executionResultsPromise;
|
|
9899
10068
|
let executionResults;
|
|
@@ -10498,7 +10667,8 @@ async function processOutputStream({
|
|
|
10498
10667
|
messageList.add(message, "response");
|
|
10499
10668
|
runState.setState({
|
|
10500
10669
|
isReasoning: false,
|
|
10501
|
-
reasoningDeltas: []
|
|
10670
|
+
reasoningDeltas: [],
|
|
10671
|
+
providerOptions: void 0
|
|
10502
10672
|
});
|
|
10503
10673
|
if (isControllerOpen(controller)) {
|
|
10504
10674
|
controller.enqueue(chunk);
|
|
@@ -10582,7 +10752,7 @@ async function processOutputStream({
|
|
|
10582
10752
|
reason: "error"
|
|
10583
10753
|
}
|
|
10584
10754
|
});
|
|
10585
|
-
const error =
|
|
10755
|
+
const error = chunk4U7ZLI36_cjs.getErrorFromUnknown(chunk.payload.error, {
|
|
10586
10756
|
fallbackMessage: "Unknown error in agent stream"
|
|
10587
10757
|
});
|
|
10588
10758
|
controller.enqueue({ ...chunk, payload: { ...chunk.payload, error } });
|
|
@@ -10632,6 +10802,9 @@ function executeStreamWithFallbackModels(models) {
|
|
|
10632
10802
|
done = true;
|
|
10633
10803
|
break;
|
|
10634
10804
|
} catch (err) {
|
|
10805
|
+
if (err instanceof TripWire) {
|
|
10806
|
+
throw err;
|
|
10807
|
+
}
|
|
10635
10808
|
attempt++;
|
|
10636
10809
|
console.error(`Error executing model ${modelConfig.model.modelId}, attempt ${attempt}====`, err);
|
|
10637
10810
|
if (attempt > maxRetries) {
|
|
@@ -10735,6 +10908,45 @@ function createLLMExecutionStep({
|
|
|
10735
10908
|
});
|
|
10736
10909
|
Object.assign(currentStep, processInputStepResult);
|
|
10737
10910
|
} catch (error) {
|
|
10911
|
+
if (error instanceof TripWire) {
|
|
10912
|
+
if (isControllerOpen(controller)) {
|
|
10913
|
+
controller.enqueue({
|
|
10914
|
+
type: "tripwire",
|
|
10915
|
+
runId,
|
|
10916
|
+
from: "AGENT" /* AGENT */,
|
|
10917
|
+
payload: {
|
|
10918
|
+
reason: error.message,
|
|
10919
|
+
retry: error.options?.retry,
|
|
10920
|
+
metadata: error.options?.metadata,
|
|
10921
|
+
processorId: error.processorId
|
|
10922
|
+
}
|
|
10923
|
+
});
|
|
10924
|
+
}
|
|
10925
|
+
const runState3 = new AgenticRunState({
|
|
10926
|
+
_internal,
|
|
10927
|
+
model
|
|
10928
|
+
});
|
|
10929
|
+
return {
|
|
10930
|
+
callBail: true,
|
|
10931
|
+
outputStream: new MastraModelOutput({
|
|
10932
|
+
model: {
|
|
10933
|
+
modelId: model.modelId,
|
|
10934
|
+
provider: model.provider,
|
|
10935
|
+
version: model.specificationVersion
|
|
10936
|
+
},
|
|
10937
|
+
stream: new web.ReadableStream({
|
|
10938
|
+
start(c) {
|
|
10939
|
+
c.close();
|
|
10940
|
+
}
|
|
10941
|
+
}),
|
|
10942
|
+
messageList,
|
|
10943
|
+
messageId,
|
|
10944
|
+
options: { runId }
|
|
10945
|
+
}),
|
|
10946
|
+
runState: runState3,
|
|
10947
|
+
stepTools: tools
|
|
10948
|
+
};
|
|
10949
|
+
}
|
|
10738
10950
|
console.error("Error in processInputStep processors:", error);
|
|
10739
10951
|
throw error;
|
|
10740
10952
|
}
|
|
@@ -10768,7 +10980,8 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
10768
10980
|
resumeData can not be an empty object nor null/undefined.
|
|
10769
10981
|
When you find that and call that tool, add the resumeData to the tool call arguments/input.
|
|
10770
10982
|
Also, add the runId of the suspended tool as suspendedToolRunId to the tool call arguments/input.
|
|
10771
|
-
If the suspendedTool.type is 'approval', resumeData will be an object that contains 'approved' which can either be true or false depending on the user's message
|
|
10983
|
+
If the suspendedTool.type is 'approval', resumeData will be an object that contains 'approved' which can either be true or false depending on the user's message. If you can't construct resumeData from the message for approval type, set approved to true and add resumeData: { approved: true } to the tool call arguments/input.
|
|
10984
|
+
`;
|
|
10772
10985
|
}
|
|
10773
10986
|
return message;
|
|
10774
10987
|
});
|
|
@@ -10776,7 +10989,7 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
10776
10989
|
}
|
|
10777
10990
|
}
|
|
10778
10991
|
if (isSupportedLanguageModel(currentStep.model)) {
|
|
10779
|
-
modelResult =
|
|
10992
|
+
modelResult = chunkO2CAMK4A_cjs.executeWithContextSync({
|
|
10780
10993
|
span: modelSpanTracker?.getTracingContext()?.currentSpan,
|
|
10781
10994
|
fn: () => execute({
|
|
10782
10995
|
runId,
|
|
@@ -10982,6 +11195,7 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
10982
11195
|
}));
|
|
10983
11196
|
const currentRetryCount = inputData.processorRetryCount || 0;
|
|
10984
11197
|
await processorRunner.runProcessOutputStep({
|
|
11198
|
+
steps: inputData.output?.steps ?? [],
|
|
10985
11199
|
messages: messageList.get.all.db(),
|
|
10986
11200
|
messageList,
|
|
10987
11201
|
stepNumber,
|
|
@@ -11391,7 +11605,17 @@ function createToolCallStep({
|
|
|
11391
11605
|
}
|
|
11392
11606
|
const resumeData = resumeDataFromArgs ?? workflowResumeData;
|
|
11393
11607
|
const isResumeToolCall = !!resumeDataFromArgs;
|
|
11394
|
-
|
|
11608
|
+
let toolRequiresApproval = requireToolApproval || tool2.requireApproval;
|
|
11609
|
+
if (tool2.needsApprovalFn) {
|
|
11610
|
+
try {
|
|
11611
|
+
const needsApprovalResult = await tool2.needsApprovalFn(args);
|
|
11612
|
+
toolRequiresApproval = needsApprovalResult;
|
|
11613
|
+
} catch (error) {
|
|
11614
|
+
console.error(`Error evaluating needsApprovalFn for tool ${inputData.toolName}:`, error);
|
|
11615
|
+
toolRequiresApproval = true;
|
|
11616
|
+
}
|
|
11617
|
+
}
|
|
11618
|
+
if (toolRequiresApproval) {
|
|
11395
11619
|
if (!resumeData) {
|
|
11396
11620
|
controller.enqueue({
|
|
11397
11621
|
type: "tool-call-approval",
|
|
@@ -11654,11 +11878,10 @@ function createAgenticLoopWorkflow(params) {
|
|
|
11654
11878
|
};
|
|
11655
11879
|
accumulatedSteps.push(currentStep);
|
|
11656
11880
|
if (rest.stopWhen && typedInputData.stepResult?.isContinued && accumulatedSteps.length > 0) {
|
|
11881
|
+
const steps = accumulatedSteps;
|
|
11657
11882
|
const conditions = await Promise.all(
|
|
11658
11883
|
(Array.isArray(rest.stopWhen) ? rest.stopWhen : [rest.stopWhen]).map((condition) => {
|
|
11659
|
-
return condition({
|
|
11660
|
-
steps: accumulatedSteps
|
|
11661
|
-
});
|
|
11884
|
+
return condition({ steps });
|
|
11662
11885
|
})
|
|
11663
11886
|
);
|
|
11664
11887
|
const hasStopped = conditions.some((condition) => condition);
|
|
@@ -11801,7 +12024,7 @@ function workflowLoopStream({
|
|
|
11801
12024
|
});
|
|
11802
12025
|
if (executionResult.status !== "success") {
|
|
11803
12026
|
if (executionResult.status === "failed") {
|
|
11804
|
-
const error =
|
|
12027
|
+
const error = chunk4U7ZLI36_cjs.getErrorFromUnknown(executionResult.error, {
|
|
11805
12028
|
fallbackMessage: "Unknown error in agent workflow stream"
|
|
11806
12029
|
});
|
|
11807
12030
|
controller.enqueue({
|
|
@@ -11862,7 +12085,7 @@ function loop({
|
|
|
11862
12085
|
level: "debug"
|
|
11863
12086
|
});
|
|
11864
12087
|
if (models.length === 0 || !models[0]) {
|
|
11865
|
-
const mastraError = new
|
|
12088
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
11866
12089
|
id: "LOOP_MODELS_EMPTY",
|
|
11867
12090
|
domain: "LLM" /* LLM */,
|
|
11868
12091
|
category: "USER" /* USER */
|
|
@@ -11979,7 +12202,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
11979
12202
|
}
|
|
11980
12203
|
}
|
|
11981
12204
|
if (models.length === 0 || !models[0]) {
|
|
11982
|
-
const mastraError = new
|
|
12205
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
11983
12206
|
id: "LLM_LOOP_MODELS_EMPTY",
|
|
11984
12207
|
domain: "LLM" /* LLM */,
|
|
11985
12208
|
category: "USER" /* USER */
|
|
@@ -12104,8 +12327,6 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
12104
12327
|
messages: [...messageList.getSystemMessages(), ...messages]
|
|
12105
12328
|
},
|
|
12106
12329
|
attributes: {
|
|
12107
|
-
agentId,
|
|
12108
|
-
agentName,
|
|
12109
12330
|
model: firstModel.modelId,
|
|
12110
12331
|
provider: firstModel.provider,
|
|
12111
12332
|
streaming: true,
|
|
@@ -12153,7 +12374,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
12153
12374
|
try {
|
|
12154
12375
|
await options?.onStepFinish?.({ ...props, runId });
|
|
12155
12376
|
} catch (e) {
|
|
12156
|
-
const mastraError = new
|
|
12377
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
12157
12378
|
{
|
|
12158
12379
|
id: "LLM_STREAM_ON_STEP_FINISH_CALLBACK_EXECUTION_FAILED",
|
|
12159
12380
|
domain: "LLM" /* LLM */,
|
|
@@ -12187,7 +12408,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
12187
12408
|
const remainingTokens = parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"] ?? "", 10);
|
|
12188
12409
|
if (!isNaN(remainingTokens) && remainingTokens > 0 && remainingTokens < 2e3) {
|
|
12189
12410
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
12190
|
-
await
|
|
12411
|
+
await chunkBC2VKOH4_cjs.delay(10 * 1e3);
|
|
12191
12412
|
}
|
|
12192
12413
|
},
|
|
12193
12414
|
onFinish: async (props) => {
|
|
@@ -12212,7 +12433,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
12212
12433
|
try {
|
|
12213
12434
|
await options?.onFinish?.({ ...props, runId });
|
|
12214
12435
|
} catch (e) {
|
|
12215
|
-
const mastraError = new
|
|
12436
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
12216
12437
|
{
|
|
12217
12438
|
id: "LLM_STREAM_ON_FINISH_CALLBACK_EXECUTION_FAILED",
|
|
12218
12439
|
domain: "LLM" /* LLM */,
|
|
@@ -12250,7 +12471,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
12250
12471
|
};
|
|
12251
12472
|
return loop(loopOptions);
|
|
12252
12473
|
} catch (e) {
|
|
12253
|
-
const mastraError = new
|
|
12474
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
12254
12475
|
{
|
|
12255
12476
|
id: "LLM_STREAM_TEXT_AI_SDK_EXECUTION_FAILED",
|
|
12256
12477
|
domain: "LLM" /* LLM */,
|
|
@@ -12397,7 +12618,7 @@ async function prepareMemoryStep({
|
|
|
12397
12618
|
);
|
|
12398
12619
|
}
|
|
12399
12620
|
} else {
|
|
12400
|
-
const messageList = new
|
|
12621
|
+
const messageList = new chunkEMLEZXTQ_cjs.MessageList({
|
|
12401
12622
|
threadId: thread?.id,
|
|
12402
12623
|
resourceId: thread?.resourceId
|
|
12403
12624
|
});
|
|
@@ -12753,7 +12974,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
12753
12974
|
const agentsMap = await agent.listAgents({ requestContext });
|
|
12754
12975
|
const agentForStep = agentsMap[inputData.primitiveId];
|
|
12755
12976
|
if (!agentForStep) {
|
|
12756
|
-
const mastraError = new
|
|
12977
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
12757
12978
|
id: "AGENT_NETWORK_AGENT_EXECUTION_STEP_INVALID_TASK_INPUT",
|
|
12758
12979
|
domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
|
|
12759
12980
|
category: "USER" /* USER */,
|
|
@@ -12880,7 +13101,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
12880
13101
|
const workflowId = inputData.primitiveId;
|
|
12881
13102
|
const wf = workflowsMap[workflowId];
|
|
12882
13103
|
if (!wf) {
|
|
12883
|
-
const mastraError = new
|
|
13104
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
12884
13105
|
id: "AGENT_NETWORK_WORKFLOW_EXECUTION_STEP_INVALID_TASK_INPUT",
|
|
12885
13106
|
domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
|
|
12886
13107
|
category: "USER" /* USER */,
|
|
@@ -12892,7 +13113,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
12892
13113
|
try {
|
|
12893
13114
|
input = JSON.parse(inputData.prompt);
|
|
12894
13115
|
} catch (e) {
|
|
12895
|
-
const mastraError = new
|
|
13116
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
12896
13117
|
{
|
|
12897
13118
|
id: "WORKFLOW_EXECUTION_STEP_INVALID_TASK_INPUT",
|
|
12898
13119
|
domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
|
|
@@ -13017,7 +13238,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
13017
13238
|
const toolsMap = { ...agentTools, ...memoryTools };
|
|
13018
13239
|
let tool2 = toolsMap[inputData.primitiveId];
|
|
13019
13240
|
if (!tool2) {
|
|
13020
|
-
const mastraError = new
|
|
13241
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
13021
13242
|
id: "AGENT_NETWORK_TOOL_EXECUTION_STEP_INVALID_TASK_INPUT",
|
|
13022
13243
|
domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
|
|
13023
13244
|
category: "USER" /* USER */,
|
|
@@ -13026,7 +13247,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
13026
13247
|
throw mastraError;
|
|
13027
13248
|
}
|
|
13028
13249
|
if (!tool2.execute) {
|
|
13029
|
-
const mastraError = new
|
|
13250
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
13030
13251
|
id: "AGENT_NETWORK_TOOL_EXECUTION_STEP_INVALID_TASK_INPUT",
|
|
13031
13252
|
domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
|
|
13032
13253
|
category: "USER" /* USER */,
|
|
@@ -13039,7 +13260,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
13039
13260
|
try {
|
|
13040
13261
|
inputDataToUse = JSON.parse(inputData.prompt);
|
|
13041
13262
|
} catch (e) {
|
|
13042
|
-
const mastraError = new
|
|
13263
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
13043
13264
|
{
|
|
13044
13265
|
id: "AGENT_NETWORK_TOOL_EXECUTION_STEP_INVALID_TASK_INPUT",
|
|
13045
13266
|
domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
|
|
@@ -13264,7 +13485,7 @@ async function networkLoop({
|
|
|
13264
13485
|
}) {
|
|
13265
13486
|
const memoryToUse = await routingAgent.getMemory({ requestContext });
|
|
13266
13487
|
if (!memoryToUse) {
|
|
13267
|
-
throw new
|
|
13488
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
13268
13489
|
id: "AGENT_NETWORK_MEMORY_REQUIRED",
|
|
13269
13490
|
domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
|
|
13270
13491
|
category: "USER" /* USER */,
|
|
@@ -13397,15 +13618,16 @@ var AgentLegacyHandler = class {
|
|
|
13397
13618
|
if (process.env.NODE_ENV !== "test") {
|
|
13398
13619
|
this.capabilities.logger.debug(`[Agents:${this.capabilities.name}] - Starting generation`, { runId });
|
|
13399
13620
|
}
|
|
13400
|
-
const agentSpan =
|
|
13621
|
+
const agentSpan = chunkO2CAMK4A_cjs.getOrCreateSpan({
|
|
13401
13622
|
type: "agent_run" /* AGENT_RUN */,
|
|
13402
13623
|
name: `agent run: '${this.capabilities.id}'`,
|
|
13624
|
+
entityType: "agent" /* AGENT */,
|
|
13625
|
+
entityId: this.capabilities.id,
|
|
13626
|
+
entityName: this.capabilities.name,
|
|
13403
13627
|
input: {
|
|
13404
13628
|
messages
|
|
13405
13629
|
},
|
|
13406
13630
|
attributes: {
|
|
13407
|
-
agentId: this.capabilities.id,
|
|
13408
|
-
agentName: this.capabilities.name,
|
|
13409
13631
|
instructions: this.capabilities.convertInstructionsToString(instructions),
|
|
13410
13632
|
availableTools: [
|
|
13411
13633
|
...toolsets ? Object.keys(toolsets) : [],
|
|
@@ -13451,7 +13673,7 @@ var AgentLegacyHandler = class {
|
|
|
13451
13673
|
methodType: methodType === "generate" ? "generateLegacy" : "streamLegacy",
|
|
13452
13674
|
memoryConfig
|
|
13453
13675
|
});
|
|
13454
|
-
let messageList = new
|
|
13676
|
+
let messageList = new chunkEMLEZXTQ_cjs.MessageList({
|
|
13455
13677
|
threadId,
|
|
13456
13678
|
resourceId,
|
|
13457
13679
|
generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
|
|
@@ -13476,7 +13698,7 @@ var AgentLegacyHandler = class {
|
|
|
13476
13698
|
};
|
|
13477
13699
|
}
|
|
13478
13700
|
if (!threadId || !resourceId) {
|
|
13479
|
-
const mastraError = new
|
|
13701
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
13480
13702
|
id: "AGENT_MEMORY_MISSING_RESOURCE_ID",
|
|
13481
13703
|
domain: "AGENT" /* AGENT */,
|
|
13482
13704
|
category: "USER" /* USER */,
|
|
@@ -13582,7 +13804,7 @@ var AgentLegacyHandler = class {
|
|
|
13582
13804
|
result: resToLog,
|
|
13583
13805
|
threadId
|
|
13584
13806
|
});
|
|
13585
|
-
const messageListResponses = new
|
|
13807
|
+
const messageListResponses = new chunkEMLEZXTQ_cjs.MessageList({
|
|
13586
13808
|
threadId,
|
|
13587
13809
|
resourceId,
|
|
13588
13810
|
generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
|
|
@@ -13652,11 +13874,11 @@ var AgentLegacyHandler = class {
|
|
|
13652
13874
|
await Promise.all(promises);
|
|
13653
13875
|
}
|
|
13654
13876
|
} catch (e) {
|
|
13655
|
-
if (e instanceof
|
|
13877
|
+
if (e instanceof chunk4U7ZLI36_cjs.MastraError) {
|
|
13656
13878
|
agentSpan?.error({ error: e });
|
|
13657
13879
|
throw e;
|
|
13658
13880
|
}
|
|
13659
|
-
const mastraError = new
|
|
13881
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
13660
13882
|
{
|
|
13661
13883
|
id: "AGENT_MEMORY_PERSIST_RESPONSE_MESSAGES_FAILED",
|
|
13662
13884
|
domain: "AGENT" /* AGENT */,
|
|
@@ -13858,7 +14080,7 @@ var AgentLegacyHandler = class {
|
|
|
13858
14080
|
*/
|
|
13859
14081
|
async generateLegacy(messages, generateOptions = {}) {
|
|
13860
14082
|
if ("structuredOutput" in generateOptions && generateOptions.structuredOutput) {
|
|
13861
|
-
throw new
|
|
14083
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
13862
14084
|
id: "AGENT_GENERATE_LEGACY_STRUCTURED_OUTPUT_NOT_SUPPORTED",
|
|
13863
14085
|
domain: "AGENT" /* AGENT */,
|
|
13864
14086
|
category: "USER" /* USER */,
|
|
@@ -13880,7 +14102,7 @@ var AgentLegacyHandler = class {
|
|
|
13880
14102
|
this.capabilities.logger.error("V2 models are not supported for generateLegacy. Please use generate instead.", {
|
|
13881
14103
|
modelId: llm.getModel().modelId
|
|
13882
14104
|
});
|
|
13883
|
-
throw new
|
|
14105
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
13884
14106
|
id: "AGENT_GENERATE_V2_MODEL_NOT_SUPPORTED",
|
|
13885
14107
|
domain: "AGENT" /* AGENT */,
|
|
13886
14108
|
category: "USER" /* USER */,
|
|
@@ -14100,7 +14322,7 @@ var AgentLegacyHandler = class {
|
|
|
14100
14322
|
this.capabilities.logger.error("V2 models are not supported for streamLegacy. Please use stream instead.", {
|
|
14101
14323
|
modelId: llm.getModel().modelId
|
|
14102
14324
|
});
|
|
14103
|
-
throw new
|
|
14325
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
14104
14326
|
id: "AGENT_STREAM_V2_MODEL_NOT_SUPPORTED",
|
|
14105
14327
|
domain: "AGENT" /* AGENT */,
|
|
14106
14328
|
category: "USER" /* USER */,
|
|
@@ -14384,7 +14606,7 @@ function getModelMethodFromAgentMethod(methodType) {
|
|
|
14384
14606
|
} else if (methodType === "stream" || methodType === "streamLegacy") {
|
|
14385
14607
|
return "stream";
|
|
14386
14608
|
} else {
|
|
14387
|
-
throw new
|
|
14609
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
14388
14610
|
id: "INVALID_METHOD_TYPE",
|
|
14389
14611
|
domain: "AGENT" /* AGENT */,
|
|
14390
14612
|
category: "USER" /* USER */
|
|
@@ -14447,7 +14669,7 @@ function createMapResultsStep({
|
|
|
14447
14669
|
if (result.tripwire) {
|
|
14448
14670
|
const agentModel = await capabilities.getModel({ requestContext: result.requestContext });
|
|
14449
14671
|
if (!isSupportedLanguageModel(agentModel)) {
|
|
14450
|
-
throw new
|
|
14672
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
14451
14673
|
id: "MAP_RESULTS_STEP_UNSUPPORTED_MODEL",
|
|
14452
14674
|
domain: "AGENT" /* AGENT */,
|
|
14453
14675
|
category: "USER" /* USER */,
|
|
@@ -14583,7 +14805,7 @@ var prepareToolsStepOutputSchema = z8.z.object({
|
|
|
14583
14805
|
var prepareMemoryStepOutputSchema = z8.z.object({
|
|
14584
14806
|
threadExists: z8.z.boolean(),
|
|
14585
14807
|
thread: storageThreadSchema.optional(),
|
|
14586
|
-
messageList: z8.z.instanceof(
|
|
14808
|
+
messageList: z8.z.instanceof(chunkEMLEZXTQ_cjs.MessageList),
|
|
14587
14809
|
/** Tripwire data when input processor triggered abort */
|
|
14588
14810
|
tripwire: z8.z.object({
|
|
14589
14811
|
reason: z8.z.string(),
|
|
@@ -14621,7 +14843,7 @@ function createPrepareMemoryStep({
|
|
|
14621
14843
|
outputSchema: prepareMemoryStepOutputSchema,
|
|
14622
14844
|
execute: async ({ tracingContext }) => {
|
|
14623
14845
|
const thread = threadFromArgs;
|
|
14624
|
-
const messageList = new
|
|
14846
|
+
const messageList = new chunkEMLEZXTQ_cjs.MessageList({
|
|
14625
14847
|
threadId: thread?.id,
|
|
14626
14848
|
resourceId,
|
|
14627
14849
|
generateMessageId: capabilities.generateMessageId,
|
|
@@ -14647,7 +14869,7 @@ function createPrepareMemoryStep({
|
|
|
14647
14869
|
};
|
|
14648
14870
|
}
|
|
14649
14871
|
if (!thread?.id || !resourceId) {
|
|
14650
|
-
const mastraError = new
|
|
14872
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
14651
14873
|
id: "AGENT_MEMORY_MISSING_RESOURCE_ID",
|
|
14652
14874
|
domain: "AGENT" /* AGENT */,
|
|
14653
14875
|
category: "USER" /* USER */,
|
|
@@ -14971,7 +15193,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
14971
15193
|
this.#description = config.description;
|
|
14972
15194
|
this.#options = config.options;
|
|
14973
15195
|
if (!config.model) {
|
|
14974
|
-
const mastraError = new
|
|
15196
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
14975
15197
|
id: "AGENT_CONSTRUCTOR_MODEL_REQUIRED",
|
|
14976
15198
|
domain: "AGENT" /* AGENT */,
|
|
14977
15199
|
category: "USER" /* USER */,
|
|
@@ -14986,7 +15208,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
14986
15208
|
}
|
|
14987
15209
|
if (Array.isArray(config.model)) {
|
|
14988
15210
|
if (config.model.length === 0) {
|
|
14989
|
-
const mastraError = new
|
|
15211
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
14990
15212
|
id: "AGENT_CONSTRUCTOR_MODEL_ARRAY_EMPTY",
|
|
14991
15213
|
domain: "AGENT" /* AGENT */,
|
|
14992
15214
|
category: "USER" /* USER */,
|
|
@@ -15038,7 +15260,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15038
15260
|
this.#voice?.addInstructions(config.instructions);
|
|
15039
15261
|
}
|
|
15040
15262
|
} else {
|
|
15041
|
-
this.#voice = new
|
|
15263
|
+
this.#voice = new chunkSSB4AVHU_cjs.DefaultVoice();
|
|
15042
15264
|
}
|
|
15043
15265
|
if (config.inputProcessors) {
|
|
15044
15266
|
this.#inputProcessors = config.inputProcessors;
|
|
@@ -15068,7 +15290,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15068
15290
|
const agentsToUse = this.#agents ? typeof this.#agents === "function" ? this.#agents({ requestContext }) : this.#agents : {};
|
|
15069
15291
|
return resolveMaybePromise(agentsToUse, (agents) => {
|
|
15070
15292
|
if (!agents) {
|
|
15071
|
-
const mastraError = new
|
|
15293
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15072
15294
|
id: "AGENT_GET_AGENTS_FUNCTION_EMPTY_RETURN",
|
|
15073
15295
|
domain: "AGENT" /* AGENT */,
|
|
15074
15296
|
category: "USER" /* USER */,
|
|
@@ -15151,7 +15373,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15151
15373
|
async listResolvedOutputProcessors(requestContext) {
|
|
15152
15374
|
const configuredProcessors = this.#outputProcessors ? typeof this.#outputProcessors === "function" ? await this.#outputProcessors({ requestContext: requestContext || new chunkUVHSM2GU_cjs.RequestContext() }) : this.#outputProcessors : [];
|
|
15153
15375
|
const memory = await this.getMemory({ requestContext: requestContext || new chunkUVHSM2GU_cjs.RequestContext() });
|
|
15154
|
-
const memoryProcessors = memory ? memory.getOutputProcessors(configuredProcessors, requestContext) : [];
|
|
15376
|
+
const memoryProcessors = memory ? await memory.getOutputProcessors(configuredProcessors, requestContext) : [];
|
|
15155
15377
|
const allProcessors = [...configuredProcessors, ...memoryProcessors];
|
|
15156
15378
|
return this.combineProcessorsIntoWorkflow(allProcessors, `${this.id}-output-processor`);
|
|
15157
15379
|
}
|
|
@@ -15163,7 +15385,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15163
15385
|
async listResolvedInputProcessors(requestContext) {
|
|
15164
15386
|
const configuredProcessors = this.#inputProcessors ? typeof this.#inputProcessors === "function" ? await this.#inputProcessors({ requestContext: requestContext || new chunkUVHSM2GU_cjs.RequestContext() }) : this.#inputProcessors : [];
|
|
15165
15387
|
const memory = await this.getMemory({ requestContext: requestContext || new chunkUVHSM2GU_cjs.RequestContext() });
|
|
15166
|
-
const memoryProcessors = memory ? memory.getInputProcessors(configuredProcessors, requestContext) : [];
|
|
15388
|
+
const memoryProcessors = memory ? await memory.getInputProcessors(configuredProcessors, requestContext) : [];
|
|
15167
15389
|
const allProcessors = [...memoryProcessors, ...configuredProcessors];
|
|
15168
15390
|
return this.combineProcessorsIntoWorkflow(allProcessors, `${this.id}-input-processor`);
|
|
15169
15391
|
}
|
|
@@ -15242,7 +15464,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15242
15464
|
const result = this.#memory({ requestContext, mastra: this.#mastra });
|
|
15243
15465
|
resolvedMemory = await Promise.resolve(result);
|
|
15244
15466
|
if (!resolvedMemory) {
|
|
15245
|
-
const mastraError = new
|
|
15467
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15246
15468
|
id: "AGENT_GET_MEMORY_FUNCTION_EMPTY_RETURN",
|
|
15247
15469
|
domain: "AGENT" /* AGENT */,
|
|
15248
15470
|
category: "USER" /* USER */,
|
|
@@ -15269,7 +15491,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15269
15491
|
}
|
|
15270
15492
|
get voice() {
|
|
15271
15493
|
if (typeof this.#instructions === "function") {
|
|
15272
|
-
const mastraError = new
|
|
15494
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15273
15495
|
id: "AGENT_VOICE_INCOMPATIBLE_WITH_FUNCTION_INSTRUCTIONS",
|
|
15274
15496
|
domain: "AGENT" /* AGENT */,
|
|
15275
15497
|
category: "USER" /* USER */,
|
|
@@ -15319,7 +15541,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15319
15541
|
const result = this.#scorers({ requestContext, mastra: this.#mastra });
|
|
15320
15542
|
return resolveMaybePromise(result, (scorers) => {
|
|
15321
15543
|
if (!scorers) {
|
|
15322
|
-
const mastraError = new
|
|
15544
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15323
15545
|
id: "AGENT_GET_SCORERS_FUNCTION_EMPTY_RETURN",
|
|
15324
15546
|
domain: "AGENT" /* AGENT */,
|
|
15325
15547
|
category: "USER" /* USER */,
|
|
@@ -15353,7 +15575,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15353
15575
|
voice?.addInstructions(this.#convertInstructionsToString(instructions));
|
|
15354
15576
|
return voice;
|
|
15355
15577
|
} else {
|
|
15356
|
-
return new
|
|
15578
|
+
return new chunkSSB4AVHU_cjs.DefaultVoice();
|
|
15357
15579
|
}
|
|
15358
15580
|
}
|
|
15359
15581
|
/**
|
|
@@ -15371,7 +15593,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15371
15593
|
const result = this.#instructions({ requestContext, mastra: this.#mastra });
|
|
15372
15594
|
return resolveMaybePromise(result, (instructions) => {
|
|
15373
15595
|
if (!instructions) {
|
|
15374
|
-
const mastraError = new
|
|
15596
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15375
15597
|
id: "AGENT_GET_INSTRUCTIONS_FUNCTION_EMPTY_RETURN",
|
|
15376
15598
|
domain: "AGENT" /* AGENT */,
|
|
15377
15599
|
category: "USER" /* USER */,
|
|
@@ -15476,7 +15698,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15476
15698
|
const result = this.#defaultGenerateOptionsLegacy({ requestContext, mastra: this.#mastra });
|
|
15477
15699
|
return resolveMaybePromise(result, (options) => {
|
|
15478
15700
|
if (!options) {
|
|
15479
|
-
const mastraError = new
|
|
15701
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15480
15702
|
id: "AGENT_GET_DEFAULT_GENERATE_OPTIONS_FUNCTION_EMPTY_RETURN",
|
|
15481
15703
|
domain: "AGENT" /* AGENT */,
|
|
15482
15704
|
category: "USER" /* USER */,
|
|
@@ -15511,7 +15733,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15511
15733
|
const result = this.#defaultStreamOptionsLegacy({ requestContext, mastra: this.#mastra });
|
|
15512
15734
|
return resolveMaybePromise(result, (options) => {
|
|
15513
15735
|
if (!options) {
|
|
15514
|
-
const mastraError = new
|
|
15736
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15515
15737
|
id: "AGENT_GET_DEFAULT_STREAM_OPTIONS_FUNCTION_EMPTY_RETURN",
|
|
15516
15738
|
domain: "AGENT" /* AGENT */,
|
|
15517
15739
|
category: "USER" /* USER */,
|
|
@@ -15546,7 +15768,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15546
15768
|
const result = this.#defaultOptions({ requestContext, mastra: this.#mastra });
|
|
15547
15769
|
return resolveMaybePromise(result, (options) => {
|
|
15548
15770
|
if (!options) {
|
|
15549
|
-
const mastraError = new
|
|
15771
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15550
15772
|
id: "AGENT_GET_DEFAULT_OPTIONS_FUNCTION_EMPTY_RETURN",
|
|
15551
15773
|
domain: "AGENT" /* AGENT */,
|
|
15552
15774
|
category: "USER" /* USER */,
|
|
@@ -15574,12 +15796,12 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15574
15796
|
*/
|
|
15575
15797
|
listTools({ requestContext = new chunkUVHSM2GU_cjs.RequestContext() } = {}) {
|
|
15576
15798
|
if (typeof this.#tools !== "function") {
|
|
15577
|
-
return
|
|
15799
|
+
return chunkBC2VKOH4_cjs.ensureToolProperties(this.#tools);
|
|
15578
15800
|
}
|
|
15579
15801
|
const result = this.#tools({ requestContext, mastra: this.#mastra });
|
|
15580
15802
|
return resolveMaybePromise(result, (tools) => {
|
|
15581
15803
|
if (!tools) {
|
|
15582
|
-
const mastraError = new
|
|
15804
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15583
15805
|
id: "AGENT_GET_TOOLS_FUNCTION_EMPTY_RETURN",
|
|
15584
15806
|
domain: "AGENT" /* AGENT */,
|
|
15585
15807
|
category: "USER" /* USER */,
|
|
@@ -15592,7 +15814,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15592
15814
|
this.logger.error(mastraError.toString());
|
|
15593
15815
|
throw mastraError;
|
|
15594
15816
|
}
|
|
15595
|
-
return
|
|
15817
|
+
return chunkBC2VKOH4_cjs.ensureToolProperties(tools);
|
|
15596
15818
|
});
|
|
15597
15819
|
}
|
|
15598
15820
|
/**
|
|
@@ -15624,7 +15846,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15624
15846
|
});
|
|
15625
15847
|
});
|
|
15626
15848
|
} else {
|
|
15627
|
-
llm = new
|
|
15849
|
+
llm = new chunkT2LVULCK_cjs.MastraLLMV1({
|
|
15628
15850
|
model: resolvedModel,
|
|
15629
15851
|
mastra: this.#mastra,
|
|
15630
15852
|
options: { tracingPolicy: this.#options?.tracingPolicy }
|
|
@@ -15649,9 +15871,9 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15649
15871
|
*/
|
|
15650
15872
|
async resolveModelConfig(modelConfig, requestContext) {
|
|
15651
15873
|
try {
|
|
15652
|
-
return await
|
|
15874
|
+
return await chunkGXMJ5URG_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
|
|
15653
15875
|
} catch (error) {
|
|
15654
|
-
const mastraError = new
|
|
15876
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15655
15877
|
id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
|
|
15656
15878
|
domain: "AGENT" /* AGENT */,
|
|
15657
15879
|
category: "USER" /* USER */,
|
|
@@ -15685,7 +15907,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15685
15907
|
} = {}) {
|
|
15686
15908
|
if (!Array.isArray(modelConfig)) return this.resolveModelConfig(modelConfig, requestContext);
|
|
15687
15909
|
if (modelConfig.length === 0 || !modelConfig[0]) {
|
|
15688
|
-
const mastraError = new
|
|
15910
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
15689
15911
|
id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
|
|
15690
15912
|
domain: "AGENT" /* AGENT */,
|
|
15691
15913
|
category: "USER" /* USER */,
|
|
@@ -15809,7 +16031,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15809
16031
|
mastra.addTool(tool2, toolKey);
|
|
15810
16032
|
}
|
|
15811
16033
|
} catch (error) {
|
|
15812
|
-
if (error instanceof
|
|
16034
|
+
if (error instanceof chunk4U7ZLI36_cjs.MastraError && error.id !== "MASTRA_ADD_TOOL_DUPLICATE_KEY") {
|
|
15813
16035
|
throw error;
|
|
15814
16036
|
}
|
|
15815
16037
|
}
|
|
@@ -15820,7 +16042,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15820
16042
|
try {
|
|
15821
16043
|
mastra.addProcessor(processor);
|
|
15822
16044
|
} catch (error) {
|
|
15823
|
-
if (error instanceof
|
|
16045
|
+
if (error instanceof chunk4U7ZLI36_cjs.MastraError && error.id !== "MASTRA_ADD_PROCESSOR_DUPLICATE_KEY") {
|
|
15824
16046
|
throw error;
|
|
15825
16047
|
}
|
|
15826
16048
|
}
|
|
@@ -15831,7 +16053,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15831
16053
|
try {
|
|
15832
16054
|
mastra.addProcessor(processor);
|
|
15833
16055
|
} catch (error) {
|
|
15834
|
-
if (error instanceof
|
|
16056
|
+
if (error instanceof chunk4U7ZLI36_cjs.MastraError && error.id !== "MASTRA_ADD_PROCESSOR_DUPLICATE_KEY") {
|
|
15835
16057
|
throw error;
|
|
15836
16058
|
}
|
|
15837
16059
|
}
|
|
@@ -15855,7 +16077,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15855
16077
|
instructions
|
|
15856
16078
|
}) {
|
|
15857
16079
|
const llm = await this.getLLM({ requestContext, model });
|
|
15858
|
-
const normMessage = new
|
|
16080
|
+
const normMessage = new chunkEMLEZXTQ_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
|
|
15859
16081
|
if (!normMessage) {
|
|
15860
16082
|
throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
|
|
15861
16083
|
}
|
|
@@ -15878,7 +16100,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15878
16100
|
const systemInstructions = await this.resolveTitleInstructions(requestContext, instructions);
|
|
15879
16101
|
let text = "";
|
|
15880
16102
|
if (isSupportedLanguageModel(llm.getModel())) {
|
|
15881
|
-
const messageList = new
|
|
16103
|
+
const messageList = new chunkEMLEZXTQ_cjs.MessageList().add(
|
|
15882
16104
|
[
|
|
15883
16105
|
{
|
|
15884
16106
|
role: "system",
|
|
@@ -15931,7 +16153,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15931
16153
|
async genTitle(userMessage, requestContext, tracingContext, model, instructions) {
|
|
15932
16154
|
try {
|
|
15933
16155
|
if (userMessage) {
|
|
15934
|
-
const normMessage = new
|
|
16156
|
+
const normMessage = new chunkEMLEZXTQ_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
|
|
15935
16157
|
if (normMessage) {
|
|
15936
16158
|
return await this.generateTitleFromUserMessage({
|
|
15937
16159
|
message: normMessage,
|
|
@@ -15996,7 +16218,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15996
16218
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
15997
16219
|
requireApproval: toolObj.requireApproval
|
|
15998
16220
|
};
|
|
15999
|
-
const convertedToCoreTool =
|
|
16221
|
+
const convertedToCoreTool = chunkBC2VKOH4_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
|
|
16000
16222
|
convertedMemoryTools[toolName] = convertedToCoreTool;
|
|
16001
16223
|
}
|
|
16002
16224
|
}
|
|
@@ -16029,7 +16251,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16029
16251
|
processorId: error.processorId
|
|
16030
16252
|
};
|
|
16031
16253
|
} else {
|
|
16032
|
-
throw new
|
|
16254
|
+
throw new chunk4U7ZLI36_cjs.MastraError(
|
|
16033
16255
|
{
|
|
16034
16256
|
id: "AGENT_INPUT_PROCESSOR_ERROR",
|
|
16035
16257
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16151,7 +16373,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16151
16373
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
16152
16374
|
requireApproval: tool2.requireApproval
|
|
16153
16375
|
};
|
|
16154
|
-
return [k,
|
|
16376
|
+
return [k, chunkBC2VKOH4_cjs.makeCoreTool(tool2, options, void 0, autoResumeSuspendedTools)];
|
|
16155
16377
|
})
|
|
16156
16378
|
);
|
|
16157
16379
|
const assignedToolEntriesConverted = Object.fromEntries(
|
|
@@ -16201,7 +16423,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16201
16423
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
16202
16424
|
requireApproval: toolObj.requireApproval
|
|
16203
16425
|
};
|
|
16204
|
-
const convertedToCoreTool =
|
|
16426
|
+
const convertedToCoreTool = chunkBC2VKOH4_cjs.makeCoreTool(toolObj, options, "toolset", autoResumeSuspendedTools);
|
|
16205
16427
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
16206
16428
|
}
|
|
16207
16429
|
}
|
|
@@ -16246,7 +16468,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16246
16468
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
16247
16469
|
requireApproval: tool2.requireApproval
|
|
16248
16470
|
};
|
|
16249
|
-
const convertedToCoreTool =
|
|
16471
|
+
const convertedToCoreTool = chunkBC2VKOH4_cjs.makeCoreTool(rest, options, "client-tool", autoResumeSuspendedTools);
|
|
16250
16472
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
16251
16473
|
}
|
|
16252
16474
|
}
|
|
@@ -16284,7 +16506,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16284
16506
|
subAgentResourceId: z8.z.string().describe("The resource ID of the agent").optional()
|
|
16285
16507
|
});
|
|
16286
16508
|
const modelVersion = (await agent.getModel({ requestContext })).specificationVersion;
|
|
16287
|
-
const toolObj =
|
|
16509
|
+
const toolObj = chunk6HJFCSJ4_cjs.createTool({
|
|
16288
16510
|
id: `agent-${agentName}`,
|
|
16289
16511
|
description: agent.getDescription() || `Agent: ${agentName}`,
|
|
16290
16512
|
inputSchema: agentInputSchema,
|
|
@@ -16380,7 +16602,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16380
16602
|
}
|
|
16381
16603
|
return result;
|
|
16382
16604
|
} catch (err) {
|
|
16383
|
-
const mastraError = new
|
|
16605
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
16384
16606
|
{
|
|
16385
16607
|
id: "AGENT_AGENT_TOOL_EXECUTION_FAILED",
|
|
16386
16608
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16416,7 +16638,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16416
16638
|
tracingContext,
|
|
16417
16639
|
tracingPolicy: this.#options?.tracingPolicy
|
|
16418
16640
|
};
|
|
16419
|
-
convertedAgentTools[`agent-${agentName}`] =
|
|
16641
|
+
convertedAgentTools[`agent-${agentName}`] = chunkBC2VKOH4_cjs.makeCoreTool(
|
|
16420
16642
|
toolObj,
|
|
16421
16643
|
options,
|
|
16422
16644
|
void 0,
|
|
@@ -16447,7 +16669,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16447
16669
|
inputData: workflow.inputSchema,
|
|
16448
16670
|
...workflow.stateSchema ? { initialState: workflow.stateSchema } : {}
|
|
16449
16671
|
});
|
|
16450
|
-
const toolObj =
|
|
16672
|
+
const toolObj = chunk6HJFCSJ4_cjs.createTool({
|
|
16451
16673
|
id: `workflow-${workflowName}`,
|
|
16452
16674
|
description: workflow.description || `Workflow: ${workflowName}`,
|
|
16453
16675
|
inputSchema: extendedInputSchema,
|
|
@@ -16560,7 +16782,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16560
16782
|
};
|
|
16561
16783
|
}
|
|
16562
16784
|
} catch (err) {
|
|
16563
|
-
const mastraError = new
|
|
16785
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
16564
16786
|
{
|
|
16565
16787
|
id: "AGENT_WORKFLOW_TOOL_EXECUTION_FAILED",
|
|
16566
16788
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16595,7 +16817,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16595
16817
|
tracingContext,
|
|
16596
16818
|
tracingPolicy: this.#options?.tracingPolicy
|
|
16597
16819
|
};
|
|
16598
|
-
convertedWorkflowTools[`workflow-${workflowName}`] =
|
|
16820
|
+
convertedWorkflowTools[`workflow-${workflowName}`] = chunkBC2VKOH4_cjs.makeCoreTool(
|
|
16599
16821
|
toolObj,
|
|
16600
16822
|
options,
|
|
16601
16823
|
void 0,
|
|
@@ -16625,7 +16847,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16625
16847
|
let mastraProxy = void 0;
|
|
16626
16848
|
const logger = this.logger;
|
|
16627
16849
|
if (this.#mastra) {
|
|
16628
|
-
mastraProxy =
|
|
16850
|
+
mastraProxy = chunkBC2VKOH4_cjs.createMastraProxy({ mastra: this.#mastra, logger });
|
|
16629
16851
|
}
|
|
16630
16852
|
const assignedTools = await this.listAssignedTools({
|
|
16631
16853
|
runId,
|
|
@@ -16709,7 +16931,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16709
16931
|
}
|
|
16710
16932
|
newKey = newKey.slice(0, 63);
|
|
16711
16933
|
if (tools[newKey]) {
|
|
16712
|
-
const mastraError = new
|
|
16934
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
16713
16935
|
id: "AGENT_TOOL_NAME_COLLISION",
|
|
16714
16936
|
domain: "AGENT" /* AGENT */,
|
|
16715
16937
|
category: "USER" /* USER */,
|
|
@@ -16813,7 +17035,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16813
17035
|
if (typeof scorerObject.scorer === "string") {
|
|
16814
17036
|
try {
|
|
16815
17037
|
if (!this.#mastra) {
|
|
16816
|
-
throw new
|
|
17038
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
16817
17039
|
id: "AGENT_GENEREATE_SCORER_NOT_FOUND",
|
|
16818
17040
|
domain: "AGENT" /* AGENT */,
|
|
16819
17041
|
category: "USER" /* USER */,
|
|
@@ -16830,7 +17052,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16830
17052
|
}
|
|
16831
17053
|
}
|
|
16832
17054
|
if (Object.keys(result).length === 0 && Object.keys(overrideScorers).length > 0) {
|
|
16833
|
-
throw new
|
|
17055
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
16834
17056
|
id: "AGENT_GENEREATE_SCORER_NOT_FOUND",
|
|
16835
17057
|
domain: "AGENT" /* AGENT */,
|
|
16836
17058
|
category: "USER" /* USER */,
|
|
@@ -16851,7 +17073,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16851
17073
|
requestContext
|
|
16852
17074
|
);
|
|
16853
17075
|
if (!isSupportedLanguageModel(resolvedModel)) {
|
|
16854
|
-
const mastraError = new
|
|
17076
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
16855
17077
|
id: "AGENT_PREPARE_MODELS_INCOMPATIBLE_WITH_MODEL_ARRAY_V1",
|
|
16856
17078
|
domain: "AGENT" /* AGENT */,
|
|
16857
17079
|
category: "USER" /* USER */,
|
|
@@ -16865,7 +17087,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16865
17087
|
throw mastraError;
|
|
16866
17088
|
}
|
|
16867
17089
|
let headers;
|
|
16868
|
-
if (resolvedModel instanceof
|
|
17090
|
+
if (resolvedModel instanceof chunkGXMJ5URG_cjs.ModelRouterLanguageModel) {
|
|
16869
17091
|
headers = resolvedModel.config?.headers;
|
|
16870
17092
|
}
|
|
16871
17093
|
return [
|
|
@@ -16882,7 +17104,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16882
17104
|
this.model.map(async (modelConfig) => {
|
|
16883
17105
|
const model2 = await this.resolveModelConfig(modelConfig.model, requestContext);
|
|
16884
17106
|
if (!isSupportedLanguageModel(model2)) {
|
|
16885
|
-
const mastraError = new
|
|
17107
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
16886
17108
|
id: "AGENT_PREPARE_MODELS_INCOMPATIBLE_WITH_MODEL_ARRAY_V1",
|
|
16887
17109
|
domain: "AGENT" /* AGENT */,
|
|
16888
17110
|
category: "USER" /* USER */,
|
|
@@ -16897,7 +17119,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16897
17119
|
}
|
|
16898
17120
|
const modelId = modelConfig.id || model2.modelId;
|
|
16899
17121
|
if (!modelId) {
|
|
16900
|
-
const mastraError = new
|
|
17122
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError({
|
|
16901
17123
|
id: "AGENT_PREPARE_MODELS_MISSING_MODEL_ID",
|
|
16902
17124
|
domain: "AGENT" /* AGENT */,
|
|
16903
17125
|
category: "USER" /* USER */,
|
|
@@ -16911,7 +17133,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16911
17133
|
throw mastraError;
|
|
16912
17134
|
}
|
|
16913
17135
|
let headers;
|
|
16914
|
-
if (model2 instanceof
|
|
17136
|
+
if (model2 instanceof chunkGXMJ5URG_cjs.ModelRouterLanguageModel) {
|
|
16915
17137
|
headers = model2.config?.headers;
|
|
16916
17138
|
}
|
|
16917
17139
|
return {
|
|
@@ -16971,7 +17193,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16971
17193
|
const targetProvider = structuredOutputModel.provider;
|
|
16972
17194
|
const targetModelId = structuredOutputModel.modelId;
|
|
16973
17195
|
if (targetProvider.includes("openai") || targetModelId.includes("openai")) {
|
|
16974
|
-
if (
|
|
17196
|
+
if (chunkBC2VKOH4_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
|
|
16975
17197
|
const modelInfo = {
|
|
16976
17198
|
provider: targetProvider,
|
|
16977
17199
|
modelId: targetModelId,
|
|
@@ -16990,13 +17212,14 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16990
17212
|
}
|
|
16991
17213
|
const runId = options.runId || this.#mastra?.generateId() || crypto2.randomUUID();
|
|
16992
17214
|
const instructions = options.instructions || await this.getInstructions({ requestContext });
|
|
16993
|
-
const agentSpan =
|
|
17215
|
+
const agentSpan = chunkO2CAMK4A_cjs.getOrCreateSpan({
|
|
16994
17216
|
type: "agent_run" /* AGENT_RUN */,
|
|
16995
17217
|
name: `agent run: '${this.id}'`,
|
|
17218
|
+
entityType: "agent" /* AGENT */,
|
|
17219
|
+
entityId: this.id,
|
|
17220
|
+
entityName: this.name,
|
|
16996
17221
|
input: options.messages,
|
|
16997
17222
|
attributes: {
|
|
16998
|
-
agentId: this.id,
|
|
16999
|
-
agentName: this.name,
|
|
17000
17223
|
conversationId: threadFromArgs?.id,
|
|
17001
17224
|
instructions: this.#convertInstructionsToString(instructions)
|
|
17002
17225
|
},
|
|
@@ -17166,10 +17389,10 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17166
17389
|
}
|
|
17167
17390
|
}
|
|
17168
17391
|
} catch (e) {
|
|
17169
|
-
if (e instanceof
|
|
17392
|
+
if (e instanceof chunk4U7ZLI36_cjs.MastraError) {
|
|
17170
17393
|
throw e;
|
|
17171
17394
|
}
|
|
17172
|
-
const mastraError = new
|
|
17395
|
+
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
17173
17396
|
{
|
|
17174
17397
|
id: "AGENT_MEMORY_PERSIST_RESPONSE_MESSAGES_FAILED",
|
|
17175
17398
|
domain: "AGENT" /* AGENT */,
|
|
@@ -17283,7 +17506,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17283
17506
|
if (!isSupportedLanguageModel(modelInfo)) {
|
|
17284
17507
|
const modelId = modelInfo.modelId || "unknown";
|
|
17285
17508
|
const provider = modelInfo.provider || "unknown";
|
|
17286
|
-
throw new
|
|
17509
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
17287
17510
|
id: "AGENT_GENERATE_V1_MODEL_NOT_SUPPORTED",
|
|
17288
17511
|
domain: "AGENT" /* AGENT */,
|
|
17289
17512
|
category: "USER" /* USER */,
|
|
@@ -17306,7 +17529,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17306
17529
|
const result = await this.#execute(executeOptions);
|
|
17307
17530
|
if (result.status !== "success") {
|
|
17308
17531
|
if (result.status === "failed") {
|
|
17309
|
-
throw new
|
|
17532
|
+
throw new chunk4U7ZLI36_cjs.MastraError(
|
|
17310
17533
|
{
|
|
17311
17534
|
id: "AGENT_GENERATE_FAILED",
|
|
17312
17535
|
domain: "AGENT" /* AGENT */,
|
|
@@ -17316,7 +17539,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17316
17539
|
result.error
|
|
17317
17540
|
);
|
|
17318
17541
|
}
|
|
17319
|
-
throw new
|
|
17542
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
17320
17543
|
id: "AGENT_GENERATE_UNKNOWN_ERROR",
|
|
17321
17544
|
domain: "AGENT" /* AGENT */,
|
|
17322
17545
|
category: "USER" /* USER */,
|
|
@@ -17345,7 +17568,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17345
17568
|
if (!isSupportedLanguageModel(modelInfo)) {
|
|
17346
17569
|
const modelId = modelInfo.modelId || "unknown";
|
|
17347
17570
|
const provider = modelInfo.provider || "unknown";
|
|
17348
|
-
throw new
|
|
17571
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
17349
17572
|
id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
|
|
17350
17573
|
domain: "AGENT" /* AGENT */,
|
|
17351
17574
|
category: "USER" /* USER */,
|
|
@@ -17368,7 +17591,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17368
17591
|
const result = await this.#execute(executeOptions);
|
|
17369
17592
|
if (result.status !== "success") {
|
|
17370
17593
|
if (result.status === "failed") {
|
|
17371
|
-
throw new
|
|
17594
|
+
throw new chunk4U7ZLI36_cjs.MastraError(
|
|
17372
17595
|
{
|
|
17373
17596
|
id: "AGENT_STREAM_FAILED",
|
|
17374
17597
|
domain: "AGENT" /* AGENT */,
|
|
@@ -17378,7 +17601,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17378
17601
|
result.error
|
|
17379
17602
|
);
|
|
17380
17603
|
}
|
|
17381
|
-
throw new
|
|
17604
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
17382
17605
|
id: "AGENT_STREAM_UNKNOWN_ERROR",
|
|
17383
17606
|
domain: "AGENT" /* AGENT */,
|
|
17384
17607
|
category: "USER" /* USER */,
|
|
@@ -17412,14 +17635,15 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17412
17635
|
requestContext: mergedStreamOptions.requestContext
|
|
17413
17636
|
});
|
|
17414
17637
|
if (!isSupportedLanguageModel(llm.getModel())) {
|
|
17415
|
-
throw new
|
|
17638
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
17416
17639
|
id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
|
|
17417
17640
|
domain: "AGENT" /* AGENT */,
|
|
17418
17641
|
category: "USER" /* USER */,
|
|
17419
17642
|
text: "V1 models are not supported for stream. Please use streamLegacy instead."
|
|
17420
17643
|
});
|
|
17421
17644
|
}
|
|
17422
|
-
const
|
|
17645
|
+
const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
|
|
17646
|
+
const existingSnapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
17423
17647
|
workflowName: "agentic-loop",
|
|
17424
17648
|
runId: streamOptions?.runId ?? ""
|
|
17425
17649
|
});
|
|
@@ -17434,7 +17658,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17434
17658
|
});
|
|
17435
17659
|
if (result.status !== "success") {
|
|
17436
17660
|
if (result.status === "failed") {
|
|
17437
|
-
throw new
|
|
17661
|
+
throw new chunk4U7ZLI36_cjs.MastraError(
|
|
17438
17662
|
{
|
|
17439
17663
|
id: "AGENT_STREAM_FAILED",
|
|
17440
17664
|
domain: "AGENT" /* AGENT */,
|
|
@@ -17444,7 +17668,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17444
17668
|
result.error
|
|
17445
17669
|
);
|
|
17446
17670
|
}
|
|
17447
|
-
throw new
|
|
17671
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
17448
17672
|
id: "AGENT_STREAM_UNKNOWN_ERROR",
|
|
17449
17673
|
domain: "AGENT" /* AGENT */,
|
|
17450
17674
|
category: "USER" /* USER */,
|
|
@@ -19487,6 +19711,50 @@ var ToolCallFilter = class {
|
|
|
19487
19711
|
}
|
|
19488
19712
|
};
|
|
19489
19713
|
|
|
19714
|
+
// src/memory/working-memory-utils.ts
|
|
19715
|
+
var WORKING_MEMORY_START_TAG = "<working_memory>";
|
|
19716
|
+
var WORKING_MEMORY_END_TAG = "</working_memory>";
|
|
19717
|
+
function extractWorkingMemoryTags(text) {
|
|
19718
|
+
const results = [];
|
|
19719
|
+
let pos = 0;
|
|
19720
|
+
while (pos < text.length) {
|
|
19721
|
+
const start = text.indexOf(WORKING_MEMORY_START_TAG, pos);
|
|
19722
|
+
if (start === -1) break;
|
|
19723
|
+
const end = text.indexOf(WORKING_MEMORY_END_TAG, start + WORKING_MEMORY_START_TAG.length);
|
|
19724
|
+
if (end === -1) break;
|
|
19725
|
+
results.push(text.substring(start, end + WORKING_MEMORY_END_TAG.length));
|
|
19726
|
+
pos = end + WORKING_MEMORY_END_TAG.length;
|
|
19727
|
+
}
|
|
19728
|
+
return results.length > 0 ? results : null;
|
|
19729
|
+
}
|
|
19730
|
+
function removeWorkingMemoryTags(text) {
|
|
19731
|
+
let result = "";
|
|
19732
|
+
let pos = 0;
|
|
19733
|
+
while (pos < text.length) {
|
|
19734
|
+
const start = text.indexOf(WORKING_MEMORY_START_TAG, pos);
|
|
19735
|
+
if (start === -1) {
|
|
19736
|
+
result += text.substring(pos);
|
|
19737
|
+
break;
|
|
19738
|
+
}
|
|
19739
|
+
result += text.substring(pos, start);
|
|
19740
|
+
const end = text.indexOf(WORKING_MEMORY_END_TAG, start + WORKING_MEMORY_START_TAG.length);
|
|
19741
|
+
if (end === -1) {
|
|
19742
|
+
result += text.substring(start);
|
|
19743
|
+
break;
|
|
19744
|
+
}
|
|
19745
|
+
pos = end + WORKING_MEMORY_END_TAG.length;
|
|
19746
|
+
}
|
|
19747
|
+
return result;
|
|
19748
|
+
}
|
|
19749
|
+
function extractWorkingMemoryContent(text) {
|
|
19750
|
+
const start = text.indexOf(WORKING_MEMORY_START_TAG);
|
|
19751
|
+
if (start === -1) return null;
|
|
19752
|
+
const contentStart = start + WORKING_MEMORY_START_TAG.length;
|
|
19753
|
+
const end = text.indexOf(WORKING_MEMORY_END_TAG, contentStart);
|
|
19754
|
+
if (end === -1) return null;
|
|
19755
|
+
return text.substring(contentStart, end);
|
|
19756
|
+
}
|
|
19757
|
+
|
|
19490
19758
|
// src/processors/memory/message-history.ts
|
|
19491
19759
|
var MessageHistory = class {
|
|
19492
19760
|
id = "message-history";
|
|
@@ -19529,25 +19797,43 @@ var MessageHistory = class {
|
|
|
19529
19797
|
}
|
|
19530
19798
|
return messageList;
|
|
19531
19799
|
}
|
|
19532
|
-
|
|
19800
|
+
/**
|
|
19801
|
+
* Filters messages before persisting to storage:
|
|
19802
|
+
* 1. Removes incomplete tool calls (state === 'call' or 'partial-call')
|
|
19803
|
+
* 2. Removes updateWorkingMemory tool invocations (hide args from message history)
|
|
19804
|
+
* 3. Strips <working_memory> tags from text content
|
|
19805
|
+
*/
|
|
19806
|
+
filterMessagesForPersistence(messages) {
|
|
19533
19807
|
return messages.map((m) => {
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
|
|
19538
|
-
|
|
19539
|
-
|
|
19540
|
-
|
|
19541
|
-
|
|
19542
|
-
|
|
19543
|
-
|
|
19544
|
-
|
|
19808
|
+
const newMessage = { ...m };
|
|
19809
|
+
if (m.content && typeof m.content === "object" && !Array.isArray(m.content)) {
|
|
19810
|
+
newMessage.content = { ...m.content };
|
|
19811
|
+
}
|
|
19812
|
+
if (typeof newMessage.content?.content === "string" && newMessage.content.content.length > 0) {
|
|
19813
|
+
newMessage.content.content = removeWorkingMemoryTags(newMessage.content.content).trim();
|
|
19814
|
+
}
|
|
19815
|
+
if (Array.isArray(newMessage.content?.parts)) {
|
|
19816
|
+
newMessage.content.parts = newMessage.content.parts.map((p) => {
|
|
19817
|
+
if (p.type === `tool-invocation` && (p.toolInvocation.state === `call` || p.toolInvocation.state === `partial-call`)) {
|
|
19818
|
+
return null;
|
|
19545
19819
|
}
|
|
19546
|
-
|
|
19547
|
-
|
|
19548
|
-
|
|
19820
|
+
if (p.type === `tool-invocation` && p.toolInvocation.toolName === `updateWorkingMemory`) {
|
|
19821
|
+
return null;
|
|
19822
|
+
}
|
|
19823
|
+
if (p.type === `text`) {
|
|
19824
|
+
const text = typeof p.text === "string" ? p.text : "";
|
|
19825
|
+
return {
|
|
19826
|
+
...p,
|
|
19827
|
+
text: removeWorkingMemoryTags(text).trim()
|
|
19828
|
+
};
|
|
19829
|
+
}
|
|
19830
|
+
return p;
|
|
19831
|
+
}).filter((p) => Boolean(p));
|
|
19832
|
+
if (newMessage.content.parts.length === 0) {
|
|
19833
|
+
return null;
|
|
19834
|
+
}
|
|
19549
19835
|
}
|
|
19550
|
-
return
|
|
19836
|
+
return newMessage;
|
|
19551
19837
|
}).filter((m) => Boolean(m));
|
|
19552
19838
|
}
|
|
19553
19839
|
async processOutputResult(args) {
|
|
@@ -19564,7 +19850,7 @@ var MessageHistory = class {
|
|
|
19564
19850
|
if (messagesToSave.length === 0) {
|
|
19565
19851
|
return messageList;
|
|
19566
19852
|
}
|
|
19567
|
-
const filtered = this.
|
|
19853
|
+
const filtered = this.filterMessagesForPersistence(messagesToSave);
|
|
19568
19854
|
await this.storage.saveMessages({ messages: filtered });
|
|
19569
19855
|
const thread = await this.storage.getThreadById({ threadId });
|
|
19570
19856
|
if (thread) {
|
|
@@ -19828,7 +20114,7 @@ var SemanticRecall = class {
|
|
|
19828
20114
|
*/
|
|
19829
20115
|
formatCrossThreadMessages(messages, currentThreadId) {
|
|
19830
20116
|
let result = ``;
|
|
19831
|
-
const v1Messages = new
|
|
20117
|
+
const v1Messages = new chunkEMLEZXTQ_cjs.MessageList().add(messages, "memory").get.all.v1();
|
|
19832
20118
|
let lastYmd = null;
|
|
19833
20119
|
for (const msg of v1Messages) {
|
|
19834
20120
|
const date = msg.createdAt;
|
|
@@ -20178,6 +20464,7 @@ var MastraMemory = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
20178
20464
|
_storage;
|
|
20179
20465
|
vector;
|
|
20180
20466
|
embedder;
|
|
20467
|
+
embedderOptions;
|
|
20181
20468
|
threadConfig = { ...memoryDefaultOptions };
|
|
20182
20469
|
#mastra;
|
|
20183
20470
|
constructor(config) {
|
|
@@ -20233,7 +20520,7 @@ https://mastra.ai/en/docs/memory/semantic-recall`
|
|
|
20233
20520
|
);
|
|
20234
20521
|
}
|
|
20235
20522
|
if (typeof config.embedder === "string") {
|
|
20236
|
-
this.embedder = new
|
|
20523
|
+
this.embedder = new chunkGXMJ5URG_cjs.ModelRouterEmbeddingModel(config.embedder);
|
|
20237
20524
|
} else {
|
|
20238
20525
|
this.embedder = config.embedder;
|
|
20239
20526
|
}
|
|
@@ -20268,7 +20555,11 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20268
20555
|
this.vector = vector;
|
|
20269
20556
|
}
|
|
20270
20557
|
setEmbedder(embedder) {
|
|
20271
|
-
|
|
20558
|
+
if (typeof embedder === "string") {
|
|
20559
|
+
this.embedder = new chunkGXMJ5URG_cjs.ModelRouterEmbeddingModel(embedder);
|
|
20560
|
+
} else {
|
|
20561
|
+
this.embedder = embedder;
|
|
20562
|
+
}
|
|
20272
20563
|
}
|
|
20273
20564
|
/**
|
|
20274
20565
|
* Get a system message to inject into the conversation.
|
|
@@ -20329,7 +20620,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20329
20620
|
"The threads.generateTitle option has been moved. Use the top-level generateTitle option instead."
|
|
20330
20621
|
);
|
|
20331
20622
|
}
|
|
20332
|
-
const mergedConfig =
|
|
20623
|
+
const mergedConfig = chunkBC2VKOH4_cjs.deepMerge(this.threadConfig, config || {});
|
|
20333
20624
|
if (typeof config?.workingMemory === "object" && config.workingMemory?.schema && typeof mergedConfig.workingMemory === "object") {
|
|
20334
20625
|
mergedConfig.workingMemory.schema = config.workingMemory.schema;
|
|
20335
20626
|
}
|
|
@@ -20390,15 +20681,16 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20390
20681
|
* @param configuredProcessors - Processors already configured by the user (for deduplication)
|
|
20391
20682
|
* @returns Array of input processors configured for this memory instance
|
|
20392
20683
|
*/
|
|
20393
|
-
getInputProcessors(configuredProcessors = [], context) {
|
|
20684
|
+
async getInputProcessors(configuredProcessors = [], context) {
|
|
20685
|
+
const memoryStore = await this.storage.getStore("memory");
|
|
20394
20686
|
const processors = [];
|
|
20395
20687
|
const memoryContext = context?.get("MastraMemory");
|
|
20396
20688
|
const runtimeMemoryConfig = memoryContext?.memoryConfig;
|
|
20397
20689
|
const effectiveConfig = runtimeMemoryConfig ? this.getMergedThreadConfig(runtimeMemoryConfig) : this.threadConfig;
|
|
20398
20690
|
const isWorkingMemoryEnabled = typeof effectiveConfig.workingMemory === "object" && effectiveConfig.workingMemory.enabled !== false;
|
|
20399
20691
|
if (isWorkingMemoryEnabled) {
|
|
20400
|
-
if (!
|
|
20401
|
-
throw new
|
|
20692
|
+
if (!memoryStore)
|
|
20693
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20402
20694
|
category: "USER",
|
|
20403
20695
|
domain: "STORAGE" /* STORAGE */,
|
|
20404
20696
|
id: "WORKING_MEMORY_MISSING_STORAGE_ADAPTER",
|
|
@@ -20415,7 +20707,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20415
20707
|
}
|
|
20416
20708
|
processors.push(
|
|
20417
20709
|
new WorkingMemory({
|
|
20418
|
-
storage:
|
|
20710
|
+
storage: memoryStore,
|
|
20419
20711
|
template,
|
|
20420
20712
|
scope: typeof effectiveConfig.workingMemory === "object" ? effectiveConfig.workingMemory.scope : void 0,
|
|
20421
20713
|
useVNext: typeof effectiveConfig.workingMemory === "object" && "version" in effectiveConfig.workingMemory && effectiveConfig.workingMemory.version === "vnext",
|
|
@@ -20426,8 +20718,8 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20426
20718
|
}
|
|
20427
20719
|
const lastMessages = effectiveConfig.lastMessages;
|
|
20428
20720
|
if (lastMessages) {
|
|
20429
|
-
if (!
|
|
20430
|
-
throw new
|
|
20721
|
+
if (!memoryStore)
|
|
20722
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20431
20723
|
category: "USER",
|
|
20432
20724
|
domain: "STORAGE" /* STORAGE */,
|
|
20433
20725
|
id: "MESSAGE_HISTORY_MISSING_STORAGE_ADAPTER",
|
|
@@ -20437,29 +20729,29 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20437
20729
|
if (!hasMessageHistory) {
|
|
20438
20730
|
processors.push(
|
|
20439
20731
|
new MessageHistory({
|
|
20440
|
-
storage:
|
|
20732
|
+
storage: memoryStore,
|
|
20441
20733
|
lastMessages: typeof lastMessages === "number" ? lastMessages : void 0
|
|
20442
20734
|
})
|
|
20443
20735
|
);
|
|
20444
20736
|
}
|
|
20445
20737
|
}
|
|
20446
20738
|
if (effectiveConfig.semanticRecall) {
|
|
20447
|
-
if (!
|
|
20448
|
-
throw new
|
|
20739
|
+
if (!memoryStore)
|
|
20740
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20449
20741
|
category: "USER",
|
|
20450
20742
|
domain: "STORAGE" /* STORAGE */,
|
|
20451
20743
|
id: "SEMANTIC_RECALL_MISSING_STORAGE_ADAPTER",
|
|
20452
20744
|
text: "Using Mastra Memory semantic recall requires a storage adapter but no attached adapter was detected."
|
|
20453
20745
|
});
|
|
20454
20746
|
if (!this.vector)
|
|
20455
|
-
throw new
|
|
20747
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20456
20748
|
category: "USER",
|
|
20457
20749
|
domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
|
|
20458
20750
|
id: "SEMANTIC_RECALL_MISSING_VECTOR_ADAPTER",
|
|
20459
20751
|
text: "Using Mastra Memory semantic recall requires a vector adapter but no attached adapter was detected."
|
|
20460
20752
|
});
|
|
20461
20753
|
if (!this.embedder)
|
|
20462
|
-
throw new
|
|
20754
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20463
20755
|
category: "USER",
|
|
20464
20756
|
domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
|
|
20465
20757
|
id: "SEMANTIC_RECALL_MISSING_EMBEDDER",
|
|
@@ -20471,7 +20763,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20471
20763
|
const indexName = this.getEmbeddingIndexName();
|
|
20472
20764
|
processors.push(
|
|
20473
20765
|
new SemanticRecall({
|
|
20474
|
-
storage:
|
|
20766
|
+
storage: memoryStore,
|
|
20475
20767
|
vector: this.vector,
|
|
20476
20768
|
embedder: this.embedder,
|
|
20477
20769
|
indexName,
|
|
@@ -20488,7 +20780,8 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20488
20780
|
* @param configuredProcessors - Processors already configured by the user (for deduplication)
|
|
20489
20781
|
* @returns Array of output processors configured for this memory instance
|
|
20490
20782
|
*/
|
|
20491
|
-
getOutputProcessors(configuredProcessors = [], context) {
|
|
20783
|
+
async getOutputProcessors(configuredProcessors = [], context) {
|
|
20784
|
+
const memoryStore = await this.storage.getStore("memory");
|
|
20492
20785
|
const processors = [];
|
|
20493
20786
|
const memoryContext = context?.get("MastraMemory");
|
|
20494
20787
|
const runtimeMemoryConfig = memoryContext?.memoryConfig;
|
|
@@ -20497,22 +20790,22 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20497
20790
|
return [];
|
|
20498
20791
|
}
|
|
20499
20792
|
if (effectiveConfig.semanticRecall) {
|
|
20500
|
-
if (!
|
|
20501
|
-
throw new
|
|
20793
|
+
if (!memoryStore)
|
|
20794
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20502
20795
|
category: "USER",
|
|
20503
20796
|
domain: "STORAGE" /* STORAGE */,
|
|
20504
20797
|
id: "SEMANTIC_RECALL_MISSING_STORAGE_ADAPTER",
|
|
20505
20798
|
text: "Using Mastra Memory semantic recall requires a storage adapter but no attached adapter was detected."
|
|
20506
20799
|
});
|
|
20507
20800
|
if (!this.vector)
|
|
20508
|
-
throw new
|
|
20801
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20509
20802
|
category: "USER",
|
|
20510
20803
|
domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
|
|
20511
20804
|
id: "SEMANTIC_RECALL_MISSING_VECTOR_ADAPTER",
|
|
20512
20805
|
text: "Using Mastra Memory semantic recall requires a vector adapter but no attached adapter was detected."
|
|
20513
20806
|
});
|
|
20514
20807
|
if (!this.embedder)
|
|
20515
|
-
throw new
|
|
20808
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20516
20809
|
category: "USER",
|
|
20517
20810
|
domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
|
|
20518
20811
|
id: "SEMANTIC_RECALL_MISSING_EMBEDDER",
|
|
@@ -20524,7 +20817,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20524
20817
|
const indexName = this.getEmbeddingIndexName();
|
|
20525
20818
|
processors.push(
|
|
20526
20819
|
new SemanticRecall({
|
|
20527
|
-
storage:
|
|
20820
|
+
storage: memoryStore,
|
|
20528
20821
|
vector: this.vector,
|
|
20529
20822
|
embedder: this.embedder,
|
|
20530
20823
|
indexName,
|
|
@@ -20535,8 +20828,8 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20535
20828
|
}
|
|
20536
20829
|
const lastMessages = effectiveConfig.lastMessages;
|
|
20537
20830
|
if (lastMessages) {
|
|
20538
|
-
if (!
|
|
20539
|
-
throw new
|
|
20831
|
+
if (!memoryStore)
|
|
20832
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20540
20833
|
category: "USER",
|
|
20541
20834
|
domain: "STORAGE" /* STORAGE */,
|
|
20542
20835
|
id: "MESSAGE_HISTORY_MISSING_STORAGE_ADAPTER",
|
|
@@ -20546,7 +20839,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20546
20839
|
if (!hasMessageHistory) {
|
|
20547
20840
|
processors.push(
|
|
20548
20841
|
new MessageHistory({
|
|
20549
|
-
storage:
|
|
20842
|
+
storage: memoryStore,
|
|
20550
20843
|
lastMessages: typeof lastMessages === "number" ? lastMessages : void 0
|
|
20551
20844
|
})
|
|
20552
20845
|
);
|
|
@@ -20565,7 +20858,7 @@ var MockMemory = class extends MastraMemory {
|
|
|
20565
20858
|
} = {}) {
|
|
20566
20859
|
super({
|
|
20567
20860
|
name: "mock",
|
|
20568
|
-
storage: storage || new
|
|
20861
|
+
storage: storage || new chunkLOV5NNGK_cjs.InMemoryStore(),
|
|
20569
20862
|
options: {
|
|
20570
20863
|
workingMemory: enableWorkingMemory ? { enabled: true, template: workingMemoryTemplate } : void 0,
|
|
20571
20864
|
lastMessages: enableMessageHistory ? 10 : void 0
|
|
@@ -20573,22 +20866,39 @@ var MockMemory = class extends MastraMemory {
|
|
|
20573
20866
|
});
|
|
20574
20867
|
this._hasOwnStorage = true;
|
|
20575
20868
|
}
|
|
20869
|
+
async getMemoryStore() {
|
|
20870
|
+
const store = await this.storage.getStore("memory");
|
|
20871
|
+
if (!store) {
|
|
20872
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
20873
|
+
id: "MASTRA_MEMORY_STORAGE_NOT_AVAILABLE",
|
|
20874
|
+
domain: "MASTRA_MEMORY" /* MASTRA_MEMORY */,
|
|
20875
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
20876
|
+
text: "Memory storage is not supported by this storage adapter"
|
|
20877
|
+
});
|
|
20878
|
+
}
|
|
20879
|
+
return store;
|
|
20880
|
+
}
|
|
20576
20881
|
async getThreadById({ threadId }) {
|
|
20577
|
-
|
|
20882
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20883
|
+
return memoryStorage.getThreadById({ threadId });
|
|
20578
20884
|
}
|
|
20579
20885
|
async saveThread({ thread }) {
|
|
20580
|
-
|
|
20886
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20887
|
+
return memoryStorage.saveThread({ thread });
|
|
20581
20888
|
}
|
|
20582
20889
|
async saveMessages({
|
|
20583
20890
|
messages
|
|
20584
20891
|
}) {
|
|
20585
|
-
|
|
20892
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20893
|
+
return memoryStorage.saveMessages({ messages });
|
|
20586
20894
|
}
|
|
20587
20895
|
async listThreadsByResourceId(args) {
|
|
20588
|
-
|
|
20896
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20897
|
+
return memoryStorage.listThreadsByResourceId(args);
|
|
20589
20898
|
}
|
|
20590
20899
|
async recall(args) {
|
|
20591
|
-
const
|
|
20900
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20901
|
+
const result = await memoryStorage.listMessages({
|
|
20592
20902
|
threadId: args.threadId,
|
|
20593
20903
|
resourceId: args.resourceId,
|
|
20594
20904
|
perPage: args.perPage,
|
|
@@ -20600,11 +20910,13 @@ var MockMemory = class extends MastraMemory {
|
|
|
20600
20910
|
return result;
|
|
20601
20911
|
}
|
|
20602
20912
|
async deleteThread(threadId) {
|
|
20603
|
-
|
|
20913
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20914
|
+
return memoryStorage.deleteThread({ threadId });
|
|
20604
20915
|
}
|
|
20605
20916
|
async deleteMessages(messageIds) {
|
|
20917
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20606
20918
|
const ids = Array.isArray(messageIds) ? messageIds?.map((item) => typeof item === "string" ? item : item.id) : [messageIds];
|
|
20607
|
-
return
|
|
20919
|
+
return memoryStorage.deleteMessages(ids);
|
|
20608
20920
|
}
|
|
20609
20921
|
async getWorkingMemory({
|
|
20610
20922
|
threadId,
|
|
@@ -20621,12 +20933,17 @@ var MockMemory = class extends MastraMemory {
|
|
|
20621
20933
|
if (!id) {
|
|
20622
20934
|
return null;
|
|
20623
20935
|
}
|
|
20624
|
-
const
|
|
20936
|
+
const memoryStorage = await this.getMemoryStore();
|
|
20937
|
+
const resource = await memoryStorage.getResourceById({ resourceId: id });
|
|
20625
20938
|
return resource?.workingMemory || null;
|
|
20626
20939
|
}
|
|
20627
20940
|
listTools(_config) {
|
|
20941
|
+
const mergedConfig = this.getMergedThreadConfig(_config);
|
|
20942
|
+
if (!mergedConfig.workingMemory?.enabled) {
|
|
20943
|
+
return {};
|
|
20944
|
+
}
|
|
20628
20945
|
return {
|
|
20629
|
-
updateWorkingMemory:
|
|
20946
|
+
updateWorkingMemory: chunk6HJFCSJ4_cjs.createTool({
|
|
20630
20947
|
id: "update-working-memory",
|
|
20631
20948
|
description: `Update the working memory with new information. Any data not included will be overwritten.`,
|
|
20632
20949
|
inputSchema: z8__default.default.object({ memory: z8__default.default.string() }),
|
|
@@ -20709,7 +21026,8 @@ var MockMemory = class extends MastraMemory {
|
|
|
20709
21026
|
if (!id) {
|
|
20710
21027
|
throw new Error(`Cannot update working memory: ${scope} ID is required`);
|
|
20711
21028
|
}
|
|
20712
|
-
await this.
|
|
21029
|
+
const memoryStorage = await this.getMemoryStore();
|
|
21030
|
+
await memoryStorage.updateResource({
|
|
20713
21031
|
resourceId: id,
|
|
20714
21032
|
workingMemory
|
|
20715
21033
|
});
|
|
@@ -20784,6 +21102,8 @@ exports.ToolCallFilter = ToolCallFilter;
|
|
|
20784
21102
|
exports.ToolInvocationPartSchema = ToolInvocationPartSchema;
|
|
20785
21103
|
exports.TripWire = TripWire;
|
|
20786
21104
|
exports.UnicodeNormalizer = UnicodeNormalizer;
|
|
21105
|
+
exports.WORKING_MEMORY_END_TAG = WORKING_MEMORY_END_TAG;
|
|
21106
|
+
exports.WORKING_MEMORY_START_TAG = WORKING_MEMORY_START_TAG;
|
|
20787
21107
|
exports.Workflow = Workflow;
|
|
20788
21108
|
exports.WorkflowRunOutput = WorkflowRunOutput;
|
|
20789
21109
|
exports.WorkingMemory = WorkingMemory;
|
|
@@ -20797,6 +21117,8 @@ exports.createDeprecationProxy = createDeprecationProxy;
|
|
|
20797
21117
|
exports.createStep = createStep;
|
|
20798
21118
|
exports.createTimeTravelExecutionParams = createTimeTravelExecutionParams;
|
|
20799
21119
|
exports.createWorkflow = createWorkflow;
|
|
21120
|
+
exports.extractWorkingMemoryContent = extractWorkingMemoryContent;
|
|
21121
|
+
exports.extractWorkingMemoryTags = extractWorkingMemoryTags;
|
|
20800
21122
|
exports.getResumeLabelsByStepId = getResumeLabelsByStepId;
|
|
20801
21123
|
exports.getStepIds = getStepIds;
|
|
20802
21124
|
exports.getStepResult = getStepResult;
|
|
@@ -20809,6 +21131,7 @@ exports.loop = loop;
|
|
|
20809
21131
|
exports.mapVariable = mapVariable;
|
|
20810
21132
|
exports.memoryDefaultOptions = memoryDefaultOptions;
|
|
20811
21133
|
exports.parseMemoryRequestContext = parseMemoryRequestContext;
|
|
21134
|
+
exports.removeWorkingMemoryTags = removeWorkingMemoryTags;
|
|
20812
21135
|
exports.resolveThreadIdFromArgs = resolveThreadIdFromArgs;
|
|
20813
21136
|
exports.runCountDeprecationMessage = runCountDeprecationMessage;
|
|
20814
21137
|
exports.supportedLanguageModelSpecifications = supportedLanguageModelSpecifications;
|
|
@@ -20818,5 +21141,5 @@ exports.validateStepInput = validateStepInput;
|
|
|
20818
21141
|
exports.validateStepResumeData = validateStepResumeData;
|
|
20819
21142
|
exports.validateStepStateData = validateStepStateData;
|
|
20820
21143
|
exports.validateStepSuspendData = validateStepSuspendData;
|
|
20821
|
-
//# sourceMappingURL=chunk-
|
|
20822
|
-
//# sourceMappingURL=chunk-
|
|
21144
|
+
//# sourceMappingURL=chunk-DDK3URK2.cjs.map
|
|
21145
|
+
//# sourceMappingURL=chunk-DDK3URK2.cjs.map
|