@mastra/core 1.0.0-beta.21 → 1.0.0-beta.22
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 +356 -0
- package/dist/action/index.d.ts +7 -7
- package/dist/action/index.d.ts.map +1 -1
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +100 -18
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +22 -18
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/adapters/AIV4Adapter.d.ts.map +1 -1
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts +2 -1
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +1 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/types.d.ts +9 -10
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +7 -42
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +6 -118
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +7 -11
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +4 -68
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +3 -45
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +10 -10
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +2 -8
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/{chunk-HJXEZSNI.js → chunk-3XY64RAM.js} +5 -5
- package/dist/{chunk-HJXEZSNI.js.map → chunk-3XY64RAM.js.map} +1 -1
- package/dist/{chunk-XSJNTLM7.js → chunk-453NPBJ7.js} +479 -47
- package/dist/chunk-453NPBJ7.js.map +1 -0
- package/dist/{chunk-3CZ42NBZ.js → chunk-5UVSKF5L.js} +17 -14
- package/dist/chunk-5UVSKF5L.js.map +1 -0
- package/dist/{chunk-XKDVT3ZH.cjs → chunk-67ZKOPA4.cjs} +480 -48
- package/dist/chunk-67ZKOPA4.cjs.map +1 -0
- package/dist/{chunk-YLP5IWH2.js → chunk-7IYWOBLG.js} +4 -4
- package/dist/{chunk-YLP5IWH2.js.map → chunk-7IYWOBLG.js.map} +1 -1
- package/dist/{chunk-3RCMDLCG.cjs → chunk-ALQFYWAR.cjs} +12 -12
- package/dist/{chunk-3RCMDLCG.cjs.map → chunk-ALQFYWAR.cjs.map} +1 -1
- package/dist/{chunk-PC3FBUWH.js → chunk-C4CIC3LZ.js} +2 -2
- package/dist/chunk-C4CIC3LZ.js.map +1 -0
- package/dist/{chunk-7JGQWNV5.js → chunk-CPLRD2VP.js} +3 -3
- package/dist/{chunk-7JGQWNV5.js.map → chunk-CPLRD2VP.js.map} +1 -1
- package/dist/{chunk-AHN7K3VE.js → chunk-CQ2E577C.js} +5 -5
- package/dist/chunk-CQ2E577C.js.map +1 -0
- package/dist/{chunk-A4MCHA5L.cjs → chunk-CVLIEFWM.cjs} +100 -819
- package/dist/chunk-CVLIEFWM.cjs.map +1 -0
- package/dist/{chunk-XBZWAUZ3.js → chunk-IFPQ2MLB.js} +25 -12
- package/dist/chunk-IFPQ2MLB.js.map +1 -0
- package/dist/{chunk-DVJZZAZA.cjs → chunk-IHD36QFA.cjs} +7 -7
- package/dist/{chunk-DVJZZAZA.cjs.map → chunk-IHD36QFA.cjs.map} +1 -1
- package/dist/{chunk-WMJEP45F.cjs → chunk-J4KVR4DZ.cjs} +25 -18
- package/dist/chunk-J4KVR4DZ.cjs.map +1 -0
- package/dist/{chunk-3RFSIHFR.js → chunk-K2LPTKSY.js} +4 -720
- package/dist/chunk-K2LPTKSY.js.map +1 -0
- package/dist/{chunk-FY3PYSMK.cjs → chunk-KHO4KFXW.cjs} +5 -5
- package/dist/{chunk-FY3PYSMK.cjs.map → chunk-KHO4KFXW.cjs.map} +1 -1
- package/dist/{chunk-W7R7GPNN.cjs → chunk-MGPIVG2O.cjs} +9 -9
- package/dist/chunk-MGPIVG2O.cjs.map +1 -0
- package/dist/{chunk-KGE3KAM7.js → chunk-N3PAHTKU.js} +23 -3
- package/dist/chunk-N3PAHTKU.js.map +1 -0
- package/dist/{chunk-O4H44CMA.js → chunk-N7TDP7ZE.js} +586 -117
- package/dist/chunk-N7TDP7ZE.js.map +1 -0
- package/dist/{chunk-I5GMA5UM.cjs → chunk-NPIYNC5A.cjs} +9 -9
- package/dist/{chunk-I5GMA5UM.cjs.map → chunk-NPIYNC5A.cjs.map} +1 -1
- package/dist/{chunk-AW7FISLD.cjs → chunk-OZ75PBBK.cjs} +27 -7
- package/dist/chunk-OZ75PBBK.cjs.map +1 -0
- package/dist/{chunk-JMAPJWVG.cjs → chunk-OZCUIZRA.cjs} +2021 -1426
- package/dist/chunk-OZCUIZRA.cjs.map +1 -0
- package/dist/{chunk-6OPEMI2Q.cjs → chunk-PM3UIIBK.cjs} +2 -3
- package/dist/{chunk-6OPEMI2Q.cjs.map → chunk-PM3UIIBK.cjs.map} +1 -1
- package/dist/{chunk-CISH55FP.js → chunk-PSIJ6OSV.js} +16 -9
- package/dist/chunk-PSIJ6OSV.js.map +1 -0
- package/dist/{chunk-UOZ3GJY2.cjs → chunk-PTK74KG4.cjs} +2 -2
- package/dist/chunk-PTK74KG4.cjs.map +1 -0
- package/dist/{chunk-O5IPTMEH.cjs → chunk-Q5QQDMSD.cjs} +32 -29
- package/dist/chunk-Q5QQDMSD.cjs.map +1 -0
- package/dist/{chunk-UVHSM2GU.cjs → chunk-SMM2C4KH.cjs} +6 -4
- package/dist/chunk-SMM2C4KH.cjs.map +1 -0
- package/dist/{chunk-UXLQEGIN.cjs → chunk-SVPXZEU7.cjs} +35 -22
- package/dist/chunk-SVPXZEU7.cjs.map +1 -0
- package/dist/{chunk-SOSXN7X4.cjs → chunk-TU6MNGBB.cjs} +619 -151
- package/dist/chunk-TU6MNGBB.cjs.map +1 -0
- package/dist/{chunk-EK7E4ETB.js → chunk-TX5GUG5Q.js} +3 -3
- package/dist/{chunk-EK7E4ETB.js.map → chunk-TX5GUG5Q.js.map} +1 -1
- package/dist/{chunk-SQ7T6FWC.cjs → chunk-UAH236P2.cjs} +13 -13
- package/dist/{chunk-SQ7T6FWC.cjs.map → chunk-UAH236P2.cjs.map} +1 -1
- package/dist/{chunk-AIJ6HPJG.js → chunk-UL7TJCKA.js} +4 -4
- package/dist/{chunk-AIJ6HPJG.js.map → chunk-UL7TJCKA.js.map} +1 -1
- package/dist/{chunk-IC2MIQBW.js → chunk-UVOQLIWL.js} +1922 -1326
- package/dist/chunk-UVOQLIWL.js.map +1 -0
- package/dist/{chunk-IMLORTHO.js → chunk-WANKWENG.js} +5 -5
- package/dist/{chunk-IMLORTHO.js.map → chunk-WANKWENG.js.map} +1 -1
- package/dist/{chunk-ICU4Z5MO.cjs → chunk-X7DR353F.cjs} +8 -8
- package/dist/{chunk-ICU4Z5MO.cjs.map → chunk-X7DR353F.cjs.map} +1 -1
- package/dist/{chunk-6TBWJV35.js → chunk-Y22QMA7S.js} +6 -4
- package/dist/chunk-Y22QMA7S.js.map +1 -0
- package/dist/{chunk-FT7DFPAL.js → chunk-YYNZEEOO.js} +5 -5
- package/dist/{chunk-FT7DFPAL.js.map → chunk-YYNZEEOO.js.map} +1 -1
- package/dist/di/index.cjs +4 -4
- package/dist/di/index.js +1 -1
- package/dist/docs/README.md +6 -5
- package/dist/docs/SKILL.md +6 -5
- package/dist/docs/SOURCE_MAP.json +288 -293
- package/dist/docs/agents/01-overview.md +2 -2
- package/dist/docs/agents/02-using-tools.md +5 -0
- package/dist/docs/agents/04-structured-output.md +24 -4
- package/dist/docs/agents/06-processors.md +65 -1
- package/dist/docs/agents/08-agent-approval.md +5 -6
- package/dist/docs/agents/09-network-approval.md +274 -0
- package/dist/docs/agents/{10-reference.md → 11-reference.md} +1 -1
- package/dist/docs/ai-sdk/01-reference.md +1 -1
- package/dist/docs/cli/01-reference.md +1 -1
- package/dist/docs/client-js/01-reference.md +10 -5
- package/dist/docs/configuration.mdx/01-reference.md +750 -0
- package/dist/docs/core/01-reference.md +9 -35
- package/dist/docs/deployer/01-reference.md +19 -6
- package/dist/docs/evals/01-overview.md +5 -5
- package/dist/docs/evals/02-custom-scorers.md +49 -6
- package/dist/docs/evals/04-reference.md +10 -4
- package/dist/docs/mcp/01-overview.md +26 -16
- package/dist/docs/mcp/02-publishing-mcp-server.md +2 -2
- package/dist/docs/memory/01-overview.md +2 -2
- package/dist/docs/memory/02-storage.md +59 -25
- package/dist/docs/memory/03-working-memory.md +10 -6
- package/dist/docs/memory/04-semantic-recall.md +2 -4
- package/dist/docs/memory/05-memory-processors.md +2 -3
- package/dist/docs/memory/06-reference.md +2 -4
- package/dist/docs/observability/01-overview.md +1 -1
- package/dist/docs/observability/02-logging.md +4 -5
- package/dist/docs/observability/03-overview.md +69 -13
- package/dist/docs/observability/09-datadog.md +169 -0
- package/dist/docs/observability/10-laminar.md +95 -0
- package/dist/docs/observability/{11-otel.md → 13-otel.md} +12 -7
- package/dist/docs/observability/{13-reference.md → 15-reference.md} +125 -1
- package/dist/docs/processors/01-reference.md +23 -0
- package/dist/docs/rag/01-overview.md +1 -1
- package/dist/docs/rag/02-chunking-and-embedding.md +0 -1
- package/dist/docs/rag/03-vector-databases.md +10 -5
- package/dist/docs/rag/04-retrieval.md +5 -6
- package/dist/docs/rag/06-reference.md +4 -5
- package/dist/docs/server/01-mastra-server.md +32 -49
- package/dist/docs/server/02-custom-adapters.md +5 -2
- package/dist/docs/server/04-request-context.md +50 -11
- package/dist/docs/server/05-custom-api-routes.md +1 -1
- package/dist/docs/server/06-mastra-client.md +2 -2
- package/dist/docs/storage/01-reference.md +99 -23
- package/dist/docs/streaming/04-reference.md +6 -1
- package/dist/docs/tools/01-reference.md +380 -25
- package/dist/docs/tools-mcp/01-mcp-overview.md +10 -2
- package/dist/docs/tools-mcp/02-overview.md +4 -4
- package/dist/docs/vectors/01-reference.md +24 -11
- package/dist/docs/voice/01-overview.md +2 -2
- package/dist/docs/voice/05-reference.md +2 -2
- package/dist/docs/workflows/01-overview.md +5 -5
- package/dist/docs/workflows/04-agents-and-tools.md +4 -6
- package/dist/docs/workflows/06-suspend-and-resume.md +5 -7
- package/dist/docs/workflows/11-reference.md +1 -91
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts +4 -67
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +9 -9
- package/dist/llm/index.js +2 -2
- package/dist/llm/model/model.loop.d.ts +1 -2
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +1 -2
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +224 -18
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts +1 -2
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts +21 -80
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/network/run-command-tool.d.ts +14 -11
- package/dist/loop/network/run-command-tool.d.ts.map +1 -1
- package/dist/loop/network/validation.d.ts +3 -4
- package/dist/loop/network/validation.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/types.d.ts +4 -5
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +31 -804
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +22 -539
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +13 -294
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +2 -41
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +32 -805
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +90 -91
- package/dist/loop/workflows/schema.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts +1 -2
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +28 -9
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +11 -11
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +4 -2
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/observability/index.cjs +11 -11
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +45 -7
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +38 -38
- package/dist/processors/index.d.ts +3 -3
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/semantic-recall.d.ts +2 -0
- package/dist/processors/memory/semantic-recall.d.ts.map +1 -1
- package/dist/processors/processors/structured-output.d.ts +2 -2
- package/dist/processors/processors/structured-output.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +16 -10
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +4 -4
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +66 -67
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-C3IAGLLU.js +3 -0
- package/dist/{provider-registry-6DWM3X3I.js.map → provider-registry-C3IAGLLU.js.map} +1 -1
- package/dist/provider-registry-YH4FCTT2.cjs +40 -0
- package/dist/{provider-registry-DCECMUCQ.cjs.map → provider-registry-YH4FCTT2.cjs.map} +1 -1
- package/dist/provider-registry.json +477 -45
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/request-context/index.cjs +4 -4
- package/dist/request-context/index.d.ts +10 -9
- package/dist/request-context/index.d.ts.map +1 -1
- package/dist/request-context/index.js +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/storage/constants.cjs +14 -14
- package/dist/storage/constants.d.ts +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/observability/types.d.ts +90 -90
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +93 -93
- package/dist/storage/index.js +2 -2
- package/dist/stream/MastraAgentNetworkStream.d.ts +8 -12
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +2 -3
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts +2 -3
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/output-format-handlers.d.ts +2 -2
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +76 -50
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/base/schema.d.ts +7 -2
- package/dist/stream/base/schema.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -15
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +72 -26
- 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 +4 -4
- package/dist/tool-loop-agent/index.d.ts +1 -1
- package/dist/tool-loop-agent/index.d.ts.map +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tool-loop-agent/tool-loop-processor.d.ts +1 -2
- package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/tool.d.ts +27 -14
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +76 -20
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/ui-types.d.ts +3 -4
- package/dist/tools/ui-types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +4 -4
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/types/dynamic-argument.d.ts +61 -1
- package/dist/types/dynamic-argument.d.ts.map +1 -1
- package/dist/types/zod-compat.d.ts +3 -11
- package/dist/types/zod-compat.d.ts.map +1 -1
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +114 -2
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/utils.d.ts +1 -1
- package/dist/workflows/evented/workflow.d.ts +74 -21
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +2 -2
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/sleep.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +1 -1
- 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/step.d.ts +28 -24
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +91 -54
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +165 -118
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +224 -18
- package/dist/chunk-3CZ42NBZ.js.map +0 -1
- package/dist/chunk-3RFSIHFR.js.map +0 -1
- package/dist/chunk-6TBWJV35.js.map +0 -1
- package/dist/chunk-A4MCHA5L.cjs.map +0 -1
- package/dist/chunk-AHN7K3VE.js.map +0 -1
- package/dist/chunk-AW7FISLD.cjs.map +0 -1
- package/dist/chunk-CISH55FP.js.map +0 -1
- package/dist/chunk-IC2MIQBW.js.map +0 -1
- package/dist/chunk-JMAPJWVG.cjs.map +0 -1
- package/dist/chunk-KGE3KAM7.js.map +0 -1
- package/dist/chunk-O4H44CMA.js.map +0 -1
- package/dist/chunk-O5IPTMEH.cjs.map +0 -1
- package/dist/chunk-PC3FBUWH.js.map +0 -1
- package/dist/chunk-SOSXN7X4.cjs.map +0 -1
- package/dist/chunk-UOZ3GJY2.cjs.map +0 -1
- package/dist/chunk-UVHSM2GU.cjs.map +0 -1
- package/dist/chunk-UXLQEGIN.cjs.map +0 -1
- package/dist/chunk-W7R7GPNN.cjs.map +0 -1
- package/dist/chunk-WMJEP45F.cjs.map +0 -1
- package/dist/chunk-XBZWAUZ3.js.map +0 -1
- package/dist/chunk-XKDVT3ZH.cjs.map +0 -1
- package/dist/chunk-XSJNTLM7.js.map +0 -1
- package/dist/provider-registry-6DWM3X3I.js +0 -3
- package/dist/provider-registry-DCECMUCQ.cjs +0 -40
- package/dist/stream/aisdk/v5/output.d.ts +0 -121
- package/dist/stream/aisdk/v5/output.d.ts.map +0 -1
- /package/dist/docs/agents/{09-adding-voice.md → 10-adding-voice.md} +0 -0
- /package/dist/docs/observability/{09-langfuse.md → 11-langfuse.md} +0 -0
- /package/dist/docs/observability/{10-langsmith.md → 12-langsmith.md} +0 -0
- /package/dist/docs/observability/{12-posthog.md → 14-posthog.md} +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { validateStepInput, createDeprecationProxy, EventEmitterPubSub, getStepResult, validateStepSuspendData, runCountDeprecationMessage, createTimeTravelExecutionParams, validateStepResumeData, Workflow,
|
|
1
|
+
import { validateStepInput, createDeprecationProxy, EventEmitterPubSub, getStepResult, validateStepSuspendData, runCountDeprecationMessage, createTimeTravelExecutionParams, validateStepResumeData, Workflow, ProcessorStepOutputSchema, ProcessorStepSchema, Run, ExecutionEngine, hydrateSerializedStepErrors, Agent, TripWire, ProcessorRunner } from './chunk-UVOQLIWL.js';
|
|
2
2
|
import { STREAM_FORMAT_SYMBOL, PUBSUB_SYMBOL } from './chunk-YEQB4VUA.js';
|
|
3
|
+
import { MessageList } from './chunk-PSIJ6OSV.js';
|
|
3
4
|
import { getErrorFromUnknown, MastraError } from './chunk-FJEVLHJT.js';
|
|
4
|
-
import { Tool } from './chunk-
|
|
5
|
-
import { RequestContext } from './chunk-
|
|
5
|
+
import { Tool } from './chunk-N3PAHTKU.js';
|
|
6
|
+
import { RequestContext } from './chunk-Y22QMA7S.js';
|
|
6
7
|
import { MastraBase } from './chunk-LSHPJWM5.js';
|
|
7
8
|
import { RegisteredLogger } from './chunk-NRUZYMHE.js';
|
|
8
9
|
import EventEmitter from 'events';
|
|
9
10
|
import { randomUUID } from 'crypto';
|
|
10
|
-
import z from 'zod';
|
|
11
|
+
import { z } from 'zod/v3';
|
|
11
12
|
|
|
12
13
|
var StepExecutor = class extends MastraBase {
|
|
13
14
|
mastra;
|
|
@@ -2245,116 +2246,120 @@ function cloneStep(step, opts) {
|
|
|
2245
2246
|
component: step.component
|
|
2246
2247
|
};
|
|
2247
2248
|
}
|
|
2249
|
+
function isAgent(input) {
|
|
2250
|
+
return input instanceof Agent;
|
|
2251
|
+
}
|
|
2252
|
+
function isToolStep(input) {
|
|
2253
|
+
return input instanceof Tool;
|
|
2254
|
+
}
|
|
2255
|
+
function isStepParams(input) {
|
|
2256
|
+
return input !== null && typeof input === "object" && "id" in input && "execute" in input && !(input instanceof Agent) && !(input instanceof Tool);
|
|
2257
|
+
}
|
|
2258
|
+
function isProcessor(obj) {
|
|
2259
|
+
return obj !== null && typeof obj === "object" && "id" in obj && typeof obj.id === "string" && !(obj instanceof Agent) && !(obj instanceof Tool) && (typeof obj.processInput === "function" || typeof obj.processInputStep === "function" || typeof obj.processOutputStream === "function" || typeof obj.processOutputResult === "function" || typeof obj.processOutputStep === "function");
|
|
2260
|
+
}
|
|
2248
2261
|
function createStep(params, agentOrToolOptions) {
|
|
2249
|
-
if (params
|
|
2250
|
-
return
|
|
2251
|
-
id: params.id,
|
|
2252
|
-
description: params.getDescription(),
|
|
2253
|
-
// @ts-ignore
|
|
2254
|
-
inputSchema: z.object({
|
|
2255
|
-
prompt: z.string()
|
|
2256
|
-
// resourceId: z.string().optional(),
|
|
2257
|
-
// threadId: z.string().optional(),
|
|
2258
|
-
}),
|
|
2259
|
-
// @ts-ignore
|
|
2260
|
-
outputSchema: z.object({
|
|
2261
|
-
text: z.string()
|
|
2262
|
-
}),
|
|
2263
|
-
retries: agentOrToolOptions?.retries,
|
|
2264
|
-
scorers: agentOrToolOptions?.scorers,
|
|
2265
|
-
execute: async ({ inputData, runId, [PUBSUB_SYMBOL]: pubsub, requestContext, abortSignal, abort }) => {
|
|
2266
|
-
let streamPromise = {};
|
|
2267
|
-
streamPromise.promise = new Promise((resolve, reject) => {
|
|
2268
|
-
streamPromise.resolve = resolve;
|
|
2269
|
-
streamPromise.reject = reject;
|
|
2270
|
-
});
|
|
2271
|
-
const { fullStream } = await params.streamLegacy(inputData.prompt, {
|
|
2272
|
-
// resourceId: inputData.resourceId,
|
|
2273
|
-
// threadId: inputData.threadId,
|
|
2274
|
-
requestContext,
|
|
2275
|
-
onFinish: (result) => {
|
|
2276
|
-
streamPromise.resolve(result.text);
|
|
2277
|
-
},
|
|
2278
|
-
abortSignal
|
|
2279
|
-
});
|
|
2280
|
-
if (abortSignal.aborted) {
|
|
2281
|
-
return abort();
|
|
2282
|
-
}
|
|
2283
|
-
const toolData = {
|
|
2284
|
-
name: params.name,
|
|
2285
|
-
args: inputData
|
|
2286
|
-
};
|
|
2287
|
-
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
2288
|
-
type: "watch",
|
|
2289
|
-
runId,
|
|
2290
|
-
data: { type: "tool-call-streaming-start", ...toolData ?? {} }
|
|
2291
|
-
});
|
|
2292
|
-
for await (const chunk of fullStream) {
|
|
2293
|
-
if (chunk.type === "text-delta") {
|
|
2294
|
-
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
2295
|
-
type: "watch",
|
|
2296
|
-
runId,
|
|
2297
|
-
data: { type: "tool-call-delta", ...toolData ?? {}, argsTextDelta: chunk.textDelta }
|
|
2298
|
-
});
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
2302
|
-
type: "watch",
|
|
2303
|
-
runId,
|
|
2304
|
-
data: { type: "tool-call-streaming-finish", ...toolData ?? {} }
|
|
2305
|
-
});
|
|
2306
|
-
return {
|
|
2307
|
-
text: await streamPromise.promise
|
|
2308
|
-
};
|
|
2309
|
-
},
|
|
2310
|
-
component: params.component
|
|
2311
|
-
};
|
|
2262
|
+
if (isAgent(params)) {
|
|
2263
|
+
return createStepFromAgent(params, agentOrToolOptions);
|
|
2312
2264
|
}
|
|
2313
|
-
if (params
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
return
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2265
|
+
if (isToolStep(params)) {
|
|
2266
|
+
return createStepFromTool(params, agentOrToolOptions);
|
|
2267
|
+
}
|
|
2268
|
+
if (isProcessor(params)) {
|
|
2269
|
+
return createStepFromProcessor(params);
|
|
2270
|
+
}
|
|
2271
|
+
if (isStepParams(params)) {
|
|
2272
|
+
return createStepFromParams(params);
|
|
2273
|
+
}
|
|
2274
|
+
throw new Error("Invalid input: expected StepParams, Agent, ToolStep, or Processor");
|
|
2275
|
+
}
|
|
2276
|
+
function createStepFromParams(params) {
|
|
2277
|
+
return {
|
|
2278
|
+
id: params.id,
|
|
2279
|
+
description: params.description,
|
|
2280
|
+
inputSchema: params.inputSchema,
|
|
2281
|
+
stateSchema: params.stateSchema,
|
|
2282
|
+
outputSchema: params.outputSchema,
|
|
2283
|
+
resumeSchema: params.resumeSchema,
|
|
2284
|
+
suspendSchema: params.suspendSchema,
|
|
2285
|
+
scorers: params.scorers,
|
|
2286
|
+
retries: params.retries,
|
|
2287
|
+
execute: params.execute.bind(params)
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
function createStepFromAgent(params, agentOrToolOptions) {
|
|
2291
|
+
const options = agentOrToolOptions ?? {};
|
|
2292
|
+
const outputSchema = options?.structuredOutput?.schema ?? z.object({ text: z.string() });
|
|
2293
|
+
const { retries, scorers, ...agentOptions } = options ?? {};
|
|
2294
|
+
return {
|
|
2295
|
+
id: params.id,
|
|
2296
|
+
description: params.getDescription(),
|
|
2297
|
+
inputSchema: z.object({
|
|
2298
|
+
prompt: z.string()
|
|
2299
|
+
}),
|
|
2300
|
+
outputSchema,
|
|
2301
|
+
retries,
|
|
2302
|
+
scorers,
|
|
2303
|
+
execute: async ({
|
|
2304
|
+
inputData,
|
|
2305
|
+
runId,
|
|
2306
|
+
[PUBSUB_SYMBOL]: pubsub,
|
|
2307
|
+
requestContext,
|
|
2308
|
+
tracingContext,
|
|
2309
|
+
abortSignal,
|
|
2310
|
+
abort
|
|
2311
|
+
}) => {
|
|
2312
|
+
let streamPromise = {};
|
|
2313
|
+
streamPromise.promise = new Promise((resolve, reject) => {
|
|
2314
|
+
streamPromise.resolve = resolve;
|
|
2315
|
+
streamPromise.reject = reject;
|
|
2316
|
+
});
|
|
2317
|
+
const { fullStream } = await params.streamLegacy(inputData.prompt, {
|
|
2318
|
+
...agentOptions ?? {},
|
|
2319
|
+
tracingContext,
|
|
2329
2320
|
requestContext,
|
|
2330
|
-
|
|
2331
|
-
|
|
2321
|
+
onFinish: (result) => {
|
|
2322
|
+
streamPromise.resolve(result.text);
|
|
2323
|
+
},
|
|
2324
|
+
abortSignal
|
|
2325
|
+
});
|
|
2326
|
+
if (abortSignal.aborted) {
|
|
2327
|
+
return abort();
|
|
2328
|
+
}
|
|
2329
|
+
const toolData = {
|
|
2330
|
+
name: params.name,
|
|
2331
|
+
args: inputData
|
|
2332
|
+
};
|
|
2333
|
+
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
2334
|
+
type: "watch",
|
|
2332
2335
|
runId,
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
}
|
|
2340
|
-
const context = {
|
|
2341
|
-
mastra,
|
|
2342
|
-
requestContext,
|
|
2343
|
-
tracingContext: { currentSpan: void 0 },
|
|
2344
|
-
// TODO: Pass proper tracing context when evented workflows support tracing
|
|
2345
|
-
workflow: {
|
|
2336
|
+
data: { type: "tool-call-streaming-start", ...toolData ?? {} }
|
|
2337
|
+
});
|
|
2338
|
+
for await (const chunk of fullStream) {
|
|
2339
|
+
if (chunk.type === "text-delta") {
|
|
2340
|
+
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
2341
|
+
type: "watch",
|
|
2346
2342
|
runId,
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
}
|
|
2356
|
-
|
|
2357
|
-
|
|
2343
|
+
data: { type: "tool-call-delta", ...toolData ?? {}, argsTextDelta: chunk.textDelta }
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
2348
|
+
type: "watch",
|
|
2349
|
+
runId,
|
|
2350
|
+
data: { type: "tool-call-streaming-finish", ...toolData ?? {} }
|
|
2351
|
+
});
|
|
2352
|
+
return {
|
|
2353
|
+
text: await streamPromise.promise
|
|
2354
|
+
};
|
|
2355
|
+
},
|
|
2356
|
+
component: params.component
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2359
|
+
function createStepFromTool(params, agentOrToolOptions) {
|
|
2360
|
+
const toolOpts = agentOrToolOptions;
|
|
2361
|
+
if (!params.inputSchema || !params.outputSchema) {
|
|
2362
|
+
throw new Error("Tool must have input and output schemas defined");
|
|
2358
2363
|
}
|
|
2359
2364
|
return {
|
|
2360
2365
|
id: params.id,
|
|
@@ -2363,9 +2368,473 @@ function createStep(params, agentOrToolOptions) {
|
|
|
2363
2368
|
outputSchema: params.outputSchema,
|
|
2364
2369
|
resumeSchema: params.resumeSchema,
|
|
2365
2370
|
suspendSchema: params.suspendSchema,
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2371
|
+
retries: toolOpts?.retries,
|
|
2372
|
+
scorers: toolOpts?.scorers,
|
|
2373
|
+
execute: async ({ inputData, mastra, requestContext, suspend, resumeData, runId, workflowId, state, setState }) => {
|
|
2374
|
+
if (!params.execute) {
|
|
2375
|
+
throw new Error(`Tool ${params.id} does not have an execute function`);
|
|
2376
|
+
}
|
|
2377
|
+
const context = {
|
|
2378
|
+
mastra,
|
|
2379
|
+
requestContext,
|
|
2380
|
+
tracingContext: { currentSpan: void 0 },
|
|
2381
|
+
// TODO: Pass proper tracing context when evented workflows support tracing
|
|
2382
|
+
workflow: {
|
|
2383
|
+
runId,
|
|
2384
|
+
workflowId,
|
|
2385
|
+
state,
|
|
2386
|
+
setState,
|
|
2387
|
+
suspend,
|
|
2388
|
+
resumeData
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
return params.execute(inputData, context);
|
|
2392
|
+
},
|
|
2393
|
+
component: "TOOL"
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
function createStepFromProcessor(processor) {
|
|
2397
|
+
const getProcessorEntityType = (phase) => {
|
|
2398
|
+
switch (phase) {
|
|
2399
|
+
case "input":
|
|
2400
|
+
return "input_processor" /* INPUT_PROCESSOR */;
|
|
2401
|
+
case "inputStep":
|
|
2402
|
+
return "input_step_processor" /* INPUT_STEP_PROCESSOR */;
|
|
2403
|
+
case "outputStream":
|
|
2404
|
+
case "outputResult":
|
|
2405
|
+
return "output_processor" /* OUTPUT_PROCESSOR */;
|
|
2406
|
+
case "outputStep":
|
|
2407
|
+
return "output_step_processor" /* OUTPUT_STEP_PROCESSOR */;
|
|
2408
|
+
default:
|
|
2409
|
+
return "output_processor" /* OUTPUT_PROCESSOR */;
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
const getSpanNamePrefix = (phase) => {
|
|
2413
|
+
switch (phase) {
|
|
2414
|
+
case "input":
|
|
2415
|
+
return "input processor";
|
|
2416
|
+
case "inputStep":
|
|
2417
|
+
return "input step processor";
|
|
2418
|
+
case "outputStream":
|
|
2419
|
+
return "output stream processor";
|
|
2420
|
+
case "outputResult":
|
|
2421
|
+
return "output processor";
|
|
2422
|
+
case "outputStep":
|
|
2423
|
+
return "output step processor";
|
|
2424
|
+
default:
|
|
2425
|
+
return "processor";
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
const hasPhaseMethod = (phase) => {
|
|
2429
|
+
switch (phase) {
|
|
2430
|
+
case "input":
|
|
2431
|
+
return !!processor.processInput;
|
|
2432
|
+
case "inputStep":
|
|
2433
|
+
return !!processor.processInputStep;
|
|
2434
|
+
case "outputStream":
|
|
2435
|
+
return !!processor.processOutputStream;
|
|
2436
|
+
case "outputResult":
|
|
2437
|
+
return !!processor.processOutputResult;
|
|
2438
|
+
case "outputStep":
|
|
2439
|
+
return !!processor.processOutputStep;
|
|
2440
|
+
default:
|
|
2441
|
+
return false;
|
|
2442
|
+
}
|
|
2443
|
+
};
|
|
2444
|
+
return {
|
|
2445
|
+
id: `processor:${processor.id}`,
|
|
2446
|
+
description: processor.name ?? `Processor ${processor.id}`,
|
|
2447
|
+
inputSchema: ProcessorStepSchema,
|
|
2448
|
+
outputSchema: ProcessorStepOutputSchema,
|
|
2449
|
+
execute: async ({ inputData, requestContext, tracingContext }) => {
|
|
2450
|
+
const input = inputData;
|
|
2451
|
+
const {
|
|
2452
|
+
phase,
|
|
2453
|
+
messages,
|
|
2454
|
+
messageList,
|
|
2455
|
+
stepNumber,
|
|
2456
|
+
systemMessages,
|
|
2457
|
+
part,
|
|
2458
|
+
streamParts,
|
|
2459
|
+
state,
|
|
2460
|
+
finishReason,
|
|
2461
|
+
toolCalls,
|
|
2462
|
+
text,
|
|
2463
|
+
retryCount,
|
|
2464
|
+
// inputStep phase fields for model/tools configuration
|
|
2465
|
+
model,
|
|
2466
|
+
tools,
|
|
2467
|
+
toolChoice,
|
|
2468
|
+
activeTools,
|
|
2469
|
+
providerOptions,
|
|
2470
|
+
modelSettings,
|
|
2471
|
+
structuredOutput,
|
|
2472
|
+
steps
|
|
2473
|
+
} = input;
|
|
2474
|
+
const abort = (reason, options) => {
|
|
2475
|
+
throw new TripWire(reason || `Tripwire triggered by ${processor.id}`, options, processor.id);
|
|
2476
|
+
};
|
|
2477
|
+
if (!hasPhaseMethod(phase)) {
|
|
2478
|
+
return input;
|
|
2479
|
+
}
|
|
2480
|
+
const currentSpan = tracingContext?.currentSpan;
|
|
2481
|
+
const parentSpan = phase === "inputStep" || phase === "outputStep" ? currentSpan?.findParent("model_step" /* MODEL_STEP */) || currentSpan : currentSpan?.findParent("agent_run" /* AGENT_RUN */) || currentSpan;
|
|
2482
|
+
const processorSpan = phase !== "outputStream" ? parentSpan?.createChildSpan({
|
|
2483
|
+
type: "processor_run" /* PROCESSOR_RUN */,
|
|
2484
|
+
name: `${getSpanNamePrefix(phase)}: ${processor.id}`,
|
|
2485
|
+
entityType: getProcessorEntityType(phase),
|
|
2486
|
+
entityId: processor.id,
|
|
2487
|
+
entityName: processor.name ?? processor.id,
|
|
2488
|
+
input: { phase, messageCount: messages?.length },
|
|
2489
|
+
attributes: {
|
|
2490
|
+
processorExecutor: "workflow",
|
|
2491
|
+
// Read processorIndex from processor (set in combineProcessorsIntoWorkflow)
|
|
2492
|
+
processorIndex: processor.processorIndex
|
|
2493
|
+
}
|
|
2494
|
+
}) : void 0;
|
|
2495
|
+
const processorTracingContext = processorSpan ? { currentSpan: processorSpan } : tracingContext;
|
|
2496
|
+
const baseContext = {
|
|
2497
|
+
abort,
|
|
2498
|
+
retryCount: retryCount ?? 0,
|
|
2499
|
+
requestContext,
|
|
2500
|
+
tracingContext: processorTracingContext
|
|
2501
|
+
};
|
|
2502
|
+
const passThrough = {
|
|
2503
|
+
phase,
|
|
2504
|
+
// Auto-create MessageList from messages if not provided
|
|
2505
|
+
// This enables running processor workflows from the UI where messageList can't be serialized
|
|
2506
|
+
messageList: messageList ?? (Array.isArray(messages) ? new MessageList().add(messages, "input").addSystem(systemMessages ?? []) : void 0),
|
|
2507
|
+
stepNumber,
|
|
2508
|
+
systemMessages,
|
|
2509
|
+
streamParts,
|
|
2510
|
+
state,
|
|
2511
|
+
finishReason,
|
|
2512
|
+
toolCalls,
|
|
2513
|
+
text,
|
|
2514
|
+
retryCount,
|
|
2515
|
+
// inputStep phase fields for model/tools configuration
|
|
2516
|
+
model,
|
|
2517
|
+
tools,
|
|
2518
|
+
toolChoice,
|
|
2519
|
+
activeTools,
|
|
2520
|
+
providerOptions,
|
|
2521
|
+
modelSettings,
|
|
2522
|
+
structuredOutput,
|
|
2523
|
+
steps
|
|
2524
|
+
};
|
|
2525
|
+
const executePhaseWithSpan = async (fn) => {
|
|
2526
|
+
try {
|
|
2527
|
+
const result = await fn();
|
|
2528
|
+
processorSpan?.end({ output: result });
|
|
2529
|
+
return result;
|
|
2530
|
+
} catch (error) {
|
|
2531
|
+
if (error instanceof TripWire) {
|
|
2532
|
+
processorSpan?.end({ output: { tripwire: error.message } });
|
|
2533
|
+
} else {
|
|
2534
|
+
processorSpan?.error({ error, endSpan: true });
|
|
2535
|
+
}
|
|
2536
|
+
throw error;
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
return executePhaseWithSpan(async () => {
|
|
2540
|
+
switch (phase) {
|
|
2541
|
+
case "input": {
|
|
2542
|
+
if (processor.processInput) {
|
|
2543
|
+
if (!passThrough.messageList) {
|
|
2544
|
+
throw new MastraError({
|
|
2545
|
+
category: "USER" /* USER */,
|
|
2546
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
2547
|
+
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
2548
|
+
text: `Processor ${processor.id} requires messageList or messages for processInput phase`
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
const idsBeforeProcessing = messages.map((m) => m.id);
|
|
2552
|
+
const check = passThrough.messageList.makeMessageSourceChecker();
|
|
2553
|
+
const result = await processor.processInput({
|
|
2554
|
+
...baseContext,
|
|
2555
|
+
messages,
|
|
2556
|
+
messageList: passThrough.messageList,
|
|
2557
|
+
systemMessages: systemMessages ?? []
|
|
2558
|
+
});
|
|
2559
|
+
if (result instanceof MessageList) {
|
|
2560
|
+
if (result !== passThrough.messageList) {
|
|
2561
|
+
throw new MastraError({
|
|
2562
|
+
category: "USER" /* USER */,
|
|
2563
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
2564
|
+
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
2565
|
+
text: `Processor ${processor.id} returned a MessageList instance other than the one passed in. Use the messageList argument instead.`
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
return {
|
|
2569
|
+
...passThrough,
|
|
2570
|
+
messages: result.get.all.db(),
|
|
2571
|
+
systemMessages: result.getAllSystemMessages()
|
|
2572
|
+
};
|
|
2573
|
+
} else if (Array.isArray(result)) {
|
|
2574
|
+
ProcessorRunner.applyMessagesToMessageList(
|
|
2575
|
+
result,
|
|
2576
|
+
passThrough.messageList,
|
|
2577
|
+
idsBeforeProcessing,
|
|
2578
|
+
check,
|
|
2579
|
+
"input"
|
|
2580
|
+
);
|
|
2581
|
+
return { ...passThrough, messages: result };
|
|
2582
|
+
} else if (result && "messages" in result && "systemMessages" in result) {
|
|
2583
|
+
const typedResult = result;
|
|
2584
|
+
ProcessorRunner.applyMessagesToMessageList(
|
|
2585
|
+
typedResult.messages,
|
|
2586
|
+
passThrough.messageList,
|
|
2587
|
+
idsBeforeProcessing,
|
|
2588
|
+
check,
|
|
2589
|
+
"input"
|
|
2590
|
+
);
|
|
2591
|
+
passThrough.messageList.replaceAllSystemMessages(typedResult.systemMessages);
|
|
2592
|
+
return {
|
|
2593
|
+
...passThrough,
|
|
2594
|
+
messages: typedResult.messages,
|
|
2595
|
+
systemMessages: typedResult.systemMessages
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
return { ...passThrough, messages };
|
|
2599
|
+
}
|
|
2600
|
+
return { ...passThrough, messages };
|
|
2601
|
+
}
|
|
2602
|
+
case "inputStep": {
|
|
2603
|
+
if (processor.processInputStep) {
|
|
2604
|
+
if (!passThrough.messageList) {
|
|
2605
|
+
throw new MastraError({
|
|
2606
|
+
category: "USER" /* USER */,
|
|
2607
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
2608
|
+
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
2609
|
+
text: `Processor ${processor.id} requires messageList or messages for processInputStep phase`
|
|
2610
|
+
});
|
|
2611
|
+
}
|
|
2612
|
+
const idsBeforeProcessing = messages.map((m) => m.id);
|
|
2613
|
+
const check = passThrough.messageList.makeMessageSourceChecker();
|
|
2614
|
+
const result = await processor.processInputStep({
|
|
2615
|
+
...baseContext,
|
|
2616
|
+
messages,
|
|
2617
|
+
messageList: passThrough.messageList,
|
|
2618
|
+
stepNumber: stepNumber ?? 0,
|
|
2619
|
+
systemMessages: systemMessages ?? [],
|
|
2620
|
+
// Pass model/tools configuration fields - types match ProcessInputStepArgs
|
|
2621
|
+
model,
|
|
2622
|
+
tools,
|
|
2623
|
+
toolChoice,
|
|
2624
|
+
activeTools,
|
|
2625
|
+
providerOptions,
|
|
2626
|
+
modelSettings,
|
|
2627
|
+
structuredOutput,
|
|
2628
|
+
steps: steps ?? []
|
|
2629
|
+
});
|
|
2630
|
+
const validatedResult = await ProcessorRunner.validateAndFormatProcessInputStepResult(result, {
|
|
2631
|
+
messageList: passThrough.messageList,
|
|
2632
|
+
processor,
|
|
2633
|
+
stepNumber: stepNumber ?? 0
|
|
2634
|
+
});
|
|
2635
|
+
if (validatedResult.messages) {
|
|
2636
|
+
ProcessorRunner.applyMessagesToMessageList(
|
|
2637
|
+
validatedResult.messages,
|
|
2638
|
+
passThrough.messageList,
|
|
2639
|
+
idsBeforeProcessing,
|
|
2640
|
+
check
|
|
2641
|
+
);
|
|
2642
|
+
}
|
|
2643
|
+
if (validatedResult.systemMessages) {
|
|
2644
|
+
passThrough.messageList.replaceAllSystemMessages(validatedResult.systemMessages);
|
|
2645
|
+
}
|
|
2646
|
+
return { ...passThrough, messages, ...validatedResult };
|
|
2647
|
+
}
|
|
2648
|
+
return { ...passThrough, messages };
|
|
2649
|
+
}
|
|
2650
|
+
case "outputStream": {
|
|
2651
|
+
if (processor.processOutputStream) {
|
|
2652
|
+
const spanKey = `__outputStreamSpan_${processor.id}`;
|
|
2653
|
+
const mutableState = state ?? {};
|
|
2654
|
+
let processorSpan2 = mutableState[spanKey];
|
|
2655
|
+
if (!processorSpan2 && parentSpan) {
|
|
2656
|
+
processorSpan2 = parentSpan.createChildSpan({
|
|
2657
|
+
type: "processor_run" /* PROCESSOR_RUN */,
|
|
2658
|
+
name: `output stream processor: ${processor.id}`,
|
|
2659
|
+
entityType: "output_processor" /* OUTPUT_PROCESSOR */,
|
|
2660
|
+
entityId: processor.id,
|
|
2661
|
+
entityName: processor.name ?? processor.id,
|
|
2662
|
+
input: { phase, streamParts: [] },
|
|
2663
|
+
attributes: {
|
|
2664
|
+
processorExecutor: "workflow",
|
|
2665
|
+
processorIndex: processor.processorIndex
|
|
2666
|
+
}
|
|
2667
|
+
});
|
|
2668
|
+
mutableState[spanKey] = processorSpan2;
|
|
2669
|
+
}
|
|
2670
|
+
if (processorSpan2) {
|
|
2671
|
+
processorSpan2.input = {
|
|
2672
|
+
phase,
|
|
2673
|
+
streamParts: streamParts ?? [],
|
|
2674
|
+
totalChunks: (streamParts ?? []).length
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2677
|
+
const processorTracingContext2 = processorSpan2 ? { currentSpan: processorSpan2 } : baseContext.tracingContext;
|
|
2678
|
+
let result;
|
|
2679
|
+
try {
|
|
2680
|
+
result = await processor.processOutputStream({
|
|
2681
|
+
...baseContext,
|
|
2682
|
+
tracingContext: processorTracingContext2,
|
|
2683
|
+
part,
|
|
2684
|
+
streamParts: streamParts ?? [],
|
|
2685
|
+
state: mutableState,
|
|
2686
|
+
messageList: passThrough.messageList
|
|
2687
|
+
// Optional for stream processing
|
|
2688
|
+
});
|
|
2689
|
+
if (part && part.type === "finish") {
|
|
2690
|
+
processorSpan2?.end({ output: result });
|
|
2691
|
+
delete mutableState[spanKey];
|
|
2692
|
+
}
|
|
2693
|
+
} catch (error) {
|
|
2694
|
+
if (error instanceof TripWire) {
|
|
2695
|
+
processorSpan2?.end({ output: { tripwire: error.message } });
|
|
2696
|
+
} else {
|
|
2697
|
+
processorSpan2?.error({ error, endSpan: true });
|
|
2698
|
+
}
|
|
2699
|
+
delete mutableState[spanKey];
|
|
2700
|
+
throw error;
|
|
2701
|
+
}
|
|
2702
|
+
return { ...passThrough, state: mutableState, part: result };
|
|
2703
|
+
}
|
|
2704
|
+
return { ...passThrough, part };
|
|
2705
|
+
}
|
|
2706
|
+
case "outputResult": {
|
|
2707
|
+
if (processor.processOutputResult) {
|
|
2708
|
+
if (!passThrough.messageList) {
|
|
2709
|
+
throw new MastraError({
|
|
2710
|
+
category: "USER" /* USER */,
|
|
2711
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
2712
|
+
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
2713
|
+
text: `Processor ${processor.id} requires messageList or messages for processOutputResult phase`
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
const idsBeforeProcessing = messages.map((m) => m.id);
|
|
2717
|
+
const check = passThrough.messageList.makeMessageSourceChecker();
|
|
2718
|
+
const result = await processor.processOutputResult({
|
|
2719
|
+
...baseContext,
|
|
2720
|
+
messages,
|
|
2721
|
+
messageList: passThrough.messageList
|
|
2722
|
+
});
|
|
2723
|
+
if (result instanceof MessageList) {
|
|
2724
|
+
if (result !== passThrough.messageList) {
|
|
2725
|
+
throw new MastraError({
|
|
2726
|
+
category: "USER" /* USER */,
|
|
2727
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
2728
|
+
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
2729
|
+
text: `Processor ${processor.id} returned a MessageList instance other than the one passed in. Use the messageList argument instead.`
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
return {
|
|
2733
|
+
...passThrough,
|
|
2734
|
+
messages: result.get.all.db(),
|
|
2735
|
+
systemMessages: result.getAllSystemMessages()
|
|
2736
|
+
};
|
|
2737
|
+
} else if (Array.isArray(result)) {
|
|
2738
|
+
ProcessorRunner.applyMessagesToMessageList(
|
|
2739
|
+
result,
|
|
2740
|
+
passThrough.messageList,
|
|
2741
|
+
idsBeforeProcessing,
|
|
2742
|
+
check,
|
|
2743
|
+
"response"
|
|
2744
|
+
);
|
|
2745
|
+
return { ...passThrough, messages: result };
|
|
2746
|
+
} else if (result && "messages" in result && "systemMessages" in result) {
|
|
2747
|
+
const typedResult = result;
|
|
2748
|
+
ProcessorRunner.applyMessagesToMessageList(
|
|
2749
|
+
typedResult.messages,
|
|
2750
|
+
passThrough.messageList,
|
|
2751
|
+
idsBeforeProcessing,
|
|
2752
|
+
check,
|
|
2753
|
+
"response"
|
|
2754
|
+
);
|
|
2755
|
+
passThrough.messageList.replaceAllSystemMessages(typedResult.systemMessages);
|
|
2756
|
+
return {
|
|
2757
|
+
...passThrough,
|
|
2758
|
+
messages: typedResult.messages,
|
|
2759
|
+
systemMessages: typedResult.systemMessages
|
|
2760
|
+
};
|
|
2761
|
+
}
|
|
2762
|
+
return { ...passThrough, messages };
|
|
2763
|
+
}
|
|
2764
|
+
return { ...passThrough, messages };
|
|
2765
|
+
}
|
|
2766
|
+
case "outputStep": {
|
|
2767
|
+
if (processor.processOutputStep) {
|
|
2768
|
+
if (!passThrough.messageList) {
|
|
2769
|
+
throw new MastraError({
|
|
2770
|
+
category: "USER" /* USER */,
|
|
2771
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
2772
|
+
id: "PROCESSOR_MISSING_MESSAGE_LIST",
|
|
2773
|
+
text: `Processor ${processor.id} requires messageList or messages for processOutputStep phase`
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
const idsBeforeProcessing = messages.map((m) => m.id);
|
|
2777
|
+
const check = passThrough.messageList.makeMessageSourceChecker();
|
|
2778
|
+
const result = await processor.processOutputStep({
|
|
2779
|
+
...baseContext,
|
|
2780
|
+
messages,
|
|
2781
|
+
messageList: passThrough.messageList,
|
|
2782
|
+
stepNumber: stepNumber ?? 0,
|
|
2783
|
+
finishReason,
|
|
2784
|
+
toolCalls,
|
|
2785
|
+
text,
|
|
2786
|
+
systemMessages: systemMessages ?? [],
|
|
2787
|
+
steps: steps ?? []
|
|
2788
|
+
});
|
|
2789
|
+
if (result instanceof MessageList) {
|
|
2790
|
+
if (result !== passThrough.messageList) {
|
|
2791
|
+
throw new MastraError({
|
|
2792
|
+
category: "USER" /* USER */,
|
|
2793
|
+
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
2794
|
+
id: "PROCESSOR_RETURNED_EXTERNAL_MESSAGE_LIST",
|
|
2795
|
+
text: `Processor ${processor.id} returned a MessageList instance other than the one passed in. Use the messageList argument instead.`
|
|
2796
|
+
});
|
|
2797
|
+
}
|
|
2798
|
+
return {
|
|
2799
|
+
...passThrough,
|
|
2800
|
+
messages: result.get.all.db(),
|
|
2801
|
+
systemMessages: result.getAllSystemMessages()
|
|
2802
|
+
};
|
|
2803
|
+
} else if (Array.isArray(result)) {
|
|
2804
|
+
ProcessorRunner.applyMessagesToMessageList(
|
|
2805
|
+
result,
|
|
2806
|
+
passThrough.messageList,
|
|
2807
|
+
idsBeforeProcessing,
|
|
2808
|
+
check,
|
|
2809
|
+
"response"
|
|
2810
|
+
);
|
|
2811
|
+
return { ...passThrough, messages: result };
|
|
2812
|
+
} else if (result && "messages" in result && "systemMessages" in result) {
|
|
2813
|
+
const typedResult = result;
|
|
2814
|
+
ProcessorRunner.applyMessagesToMessageList(
|
|
2815
|
+
typedResult.messages,
|
|
2816
|
+
passThrough.messageList,
|
|
2817
|
+
idsBeforeProcessing,
|
|
2818
|
+
check,
|
|
2819
|
+
"response"
|
|
2820
|
+
);
|
|
2821
|
+
passThrough.messageList.replaceAllSystemMessages(typedResult.systemMessages);
|
|
2822
|
+
return {
|
|
2823
|
+
...passThrough,
|
|
2824
|
+
messages: typedResult.messages,
|
|
2825
|
+
systemMessages: typedResult.systemMessages
|
|
2826
|
+
};
|
|
2827
|
+
}
|
|
2828
|
+
return { ...passThrough, messages };
|
|
2829
|
+
}
|
|
2830
|
+
return { ...passThrough, messages };
|
|
2831
|
+
}
|
|
2832
|
+
default:
|
|
2833
|
+
return { ...passThrough, messages };
|
|
2834
|
+
}
|
|
2835
|
+
});
|
|
2836
|
+
},
|
|
2837
|
+
component: "PROCESSOR"
|
|
2369
2838
|
};
|
|
2370
2839
|
}
|
|
2371
2840
|
function createWorkflow(params) {
|
|
@@ -2506,7 +2975,7 @@ var EventedRun = class extends Run {
|
|
|
2506
2975
|
timestamp: Date.now()
|
|
2507
2976
|
}
|
|
2508
2977
|
});
|
|
2509
|
-
const inputDataToUse = await this._validateInput(inputData);
|
|
2978
|
+
const inputDataToUse = await this._validateInput(inputData ?? {});
|
|
2510
2979
|
const initialStateToUse = await this._validateInitialState(initialState ?? {});
|
|
2511
2980
|
if (!this.mastra?.pubsub) {
|
|
2512
2981
|
throw new Error("Mastra instance with pubsub is required for workflow execution");
|
|
@@ -2570,7 +3039,7 @@ var EventedRun = class extends Run {
|
|
|
2570
3039
|
timestamp: Date.now()
|
|
2571
3040
|
}
|
|
2572
3041
|
});
|
|
2573
|
-
const inputDataToUse = await this._validateInput(inputData);
|
|
3042
|
+
const inputDataToUse = await this._validateInput(inputData ?? {});
|
|
2574
3043
|
const initialStateToUse = await this._validateInitialState(initialState ?? {});
|
|
2575
3044
|
if (!this.mastra?.pubsub) {
|
|
2576
3045
|
throw new Error("Mastra instance with pubsub is required for workflow execution");
|
|
@@ -2644,7 +3113,7 @@ var EventedRun = class extends Run {
|
|
|
2644
3113
|
runId: this.runId,
|
|
2645
3114
|
graph: this.executionGraph,
|
|
2646
3115
|
serializedStepGraph: this.serializedStepGraph,
|
|
2647
|
-
input:
|
|
3116
|
+
input: snapshot?.context?.input,
|
|
2648
3117
|
resume: {
|
|
2649
3118
|
steps,
|
|
2650
3119
|
stepResults: snapshot?.context,
|
|
@@ -2909,5 +3378,5 @@ var EventedExecutionEngine = class extends ExecutionEngine {
|
|
|
2909
3378
|
};
|
|
2910
3379
|
|
|
2911
3380
|
export { EventedExecutionEngine, EventedRun, EventedWorkflow, StepExecutor, WorkflowEventProcessor, cloneStep, cloneWorkflow, createStep, createWorkflow };
|
|
2912
|
-
//# sourceMappingURL=chunk-
|
|
2913
|
-
//# sourceMappingURL=chunk-
|
|
3381
|
+
//# sourceMappingURL=chunk-N7TDP7ZE.js.map
|
|
3382
|
+
//# sourceMappingURL=chunk-N7TDP7ZE.js.map
|