@mastra/core 1.0.0-beta.13 → 1.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +477 -0
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +2 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +6 -7
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +17 -9
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +1 -1
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +2 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +4 -1
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/bundler/types.d.ts +1 -0
- package/dist/bundler/types.d.ts.map +1 -1
- package/dist/chunk-2AU5ZHBL.js +79 -0
- package/dist/chunk-2AU5ZHBL.js.map +1 -0
- package/dist/{chunk-7HEAVZRS.cjs → chunk-2OOMJRXZ.cjs} +15 -15
- package/dist/{chunk-7HEAVZRS.cjs.map → chunk-2OOMJRXZ.cjs.map} +1 -1
- package/dist/chunk-37YWZMBX.js +27 -0
- package/dist/chunk-37YWZMBX.js.map +1 -0
- package/dist/{chunk-VETAQUW3.js → chunk-3HDRO3GG.js} +790 -1206
- package/dist/chunk-3HDRO3GG.js.map +1 -0
- package/dist/{chunk-MRRFTNF4.js → chunk-4DFWV4IR.js} +3 -4
- package/dist/chunk-4DFWV4IR.js.map +1 -0
- package/dist/{chunk-373OC54J.js → chunk-4HP7CS6L.js} +7 -6
- package/dist/chunk-4HP7CS6L.js.map +1 -0
- package/dist/{chunk-62Q7K656.js → chunk-4J4M2Q5R.js} +125 -121
- package/dist/chunk-4J4M2Q5R.js.map +1 -0
- package/dist/{chunk-HWMMIRIF.cjs → chunk-4U7ZLI36.cjs} +3 -2
- package/dist/chunk-4U7ZLI36.cjs.map +1 -0
- package/dist/{chunk-Z55SJVEC.cjs → chunk-6HJFCSJ4.cjs} +7 -6
- package/dist/chunk-6HJFCSJ4.cjs.map +1 -0
- package/dist/{chunk-Y7MZ5LJT.cjs → chunk-AAX7ZOM7.cjs} +101 -102
- package/dist/chunk-AAX7ZOM7.cjs.map +1 -0
- package/dist/{chunk-WPTTKULS.js → chunk-AR5CF3IN.js} +4 -4
- package/dist/{chunk-WPTTKULS.js.map → chunk-AR5CF3IN.js.map} +1 -1
- package/dist/{chunk-5VZGJTPR.js → chunk-BAZHNX5P.js} +57 -11
- package/dist/chunk-BAZHNX5P.js.map +1 -0
- package/dist/{chunk-MLKE7HRS.cjs → chunk-BC2VKOH4.cjs} +43 -21
- package/dist/chunk-BC2VKOH4.cjs.map +1 -0
- package/dist/{chunk-2IU4RGU5.js → chunk-BCUKD2XG.js} +59 -19
- package/dist/chunk-BCUKD2XG.js.map +1 -0
- package/dist/{chunk-WYGUWVTF.js → chunk-CBQ6WDUJ.js} +9 -9
- package/dist/chunk-CBQ6WDUJ.js.map +1 -0
- package/dist/chunk-CBVHOGXX.cjs +674 -0
- package/dist/chunk-CBVHOGXX.cjs.map +1 -0
- package/dist/{chunk-PJAK4U6R.cjs → chunk-CBY37FTP.cjs} +28 -28
- package/dist/chunk-CBY37FTP.cjs.map +1 -0
- package/dist/{chunk-BQDZIQ3G.js → chunk-D2IFWD7A.js} +365 -137
- package/dist/chunk-D2IFWD7A.js.map +1 -0
- package/dist/{chunk-R5AJGM55.cjs → chunk-DDK3URK2.cjs} +987 -519
- package/dist/chunk-DDK3URK2.cjs.map +1 -0
- package/dist/chunk-DRJTNGI4.cjs +263 -0
- package/dist/chunk-DRJTNGI4.cjs.map +1 -0
- package/dist/{chunk-X6IBA7FP.cjs → chunk-EMLEZXTQ.cjs} +22 -120
- package/dist/chunk-EMLEZXTQ.cjs.map +1 -0
- package/dist/{chunk-OWIEOL55.cjs → chunk-F75EQ574.cjs} +695 -254
- package/dist/chunk-F75EQ574.cjs.map +1 -0
- package/dist/{chunk-YPLZDWG7.js → chunk-FJEVLHJT.js} +3 -2
- package/dist/chunk-FJEVLHJT.js.map +1 -0
- package/dist/chunk-GVAPYQRO.cjs +252 -0
- package/dist/chunk-GVAPYQRO.cjs.map +1 -0
- package/dist/{chunk-MXBVP7HX.cjs → chunk-GXMJ5URG.cjs} +227 -181
- package/dist/chunk-GXMJ5URG.cjs.map +1 -0
- package/dist/chunk-H2NHG7QL.cjs +32 -0
- package/dist/chunk-H2NHG7QL.cjs.map +1 -0
- package/dist/chunk-HAYBGFPA.js +259 -0
- package/dist/chunk-HAYBGFPA.js.map +1 -0
- package/dist/{chunk-GIWC35YQ.js → chunk-IHISDRFV.js} +299 -49
- package/dist/chunk-IHISDRFV.js.map +1 -0
- package/dist/{chunk-VEPP75C4.cjs → chunk-IRTICXRZ.cjs} +101 -61
- package/dist/chunk-IRTICXRZ.cjs.map +1 -0
- package/dist/{chunk-ARAQIW6E.js → chunk-K66U47VL.js} +617 -188
- package/dist/chunk-K66U47VL.js.map +1 -0
- package/dist/{chunk-LGB4VNZI.cjs → chunk-LOV5NNGK.cjs} +811 -1235
- package/dist/chunk-LOV5NNGK.cjs.map +1 -0
- package/dist/{chunk-E5BQRAJK.js → chunk-NGWTSHNA.js} +823 -362
- package/dist/chunk-NGWTSHNA.js.map +1 -0
- package/dist/{chunk-72YCRTEX.cjs → chunk-O2CAMK4A.cjs} +13 -2
- package/dist/chunk-O2CAMK4A.cjs.map +1 -0
- package/dist/{chunk-4BC5FUAO.js → chunk-O7M7DR4E.js} +6 -5
- package/dist/chunk-O7M7DR4E.js.map +1 -0
- package/dist/chunk-OTIGV7CL.js +10215 -0
- package/dist/chunk-OTIGV7CL.js.map +1 -0
- package/dist/{chunk-WYWRMIQC.js → chunk-QXL3F3T2.js} +9 -105
- package/dist/chunk-QXL3F3T2.js.map +1 -0
- package/dist/{chunk-U4CSOY6T.cjs → chunk-RA2CHJCY.cjs} +399 -171
- package/dist/chunk-RA2CHJCY.cjs.map +1 -0
- package/dist/chunk-RMV5HJM7.cjs +10237 -0
- package/dist/chunk-RMV5HJM7.cjs.map +1 -0
- package/dist/{chunk-AGHLXC4I.cjs → chunk-S23TNDXG.cjs} +300 -50
- package/dist/chunk-S23TNDXG.cjs.map +1 -0
- package/dist/{chunk-H4VUIOWU.cjs → chunk-SSB4AVHU.cjs} +20 -19
- package/dist/chunk-SSB4AVHU.cjs.map +1 -0
- package/dist/chunk-ST7NBF4H.cjs +84 -0
- package/dist/chunk-ST7NBF4H.cjs.map +1 -0
- package/dist/{chunk-SZYSDJTN.cjs → chunk-T2LVULCK.cjs} +142 -137
- package/dist/chunk-T2LVULCK.cjs.map +1 -0
- package/dist/chunk-VE6HQ7H6.js +250 -0
- package/dist/chunk-VE6HQ7H6.js.map +1 -0
- package/dist/{chunk-RCJLMMTO.js → chunk-XJB7J4UT.js} +30 -8
- package/dist/chunk-XJB7J4UT.js.map +1 -0
- package/dist/chunk-YV43YEZ6.js +598 -0
- package/dist/chunk-YV43YEZ6.js.map +1 -0
- package/dist/{chunk-Y36Y5MTD.js → chunk-ZGIVAQRI.js} +13 -3
- package/dist/chunk-ZGIVAQRI.js.map +1 -0
- package/dist/error/index.cjs +6 -6
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/evals/index.cjs +49 -9
- package/dist/evals/index.js +2 -2
- package/dist/evals/run/index.d.ts.map +1 -1
- package/dist/evals/scoreTraces/index.cjs +70 -22
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +63 -15
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/evals/scoreTraces/utils.d.ts.map +1 -1
- package/dist/evals/types.d.ts +568 -116
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +21 -21
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/aisdk/generate-to-stream.d.ts +20 -0
- package/dist/llm/model/aisdk/generate-to-stream.d.ts.map +1 -0
- package/dist/llm/model/aisdk/v5/model.d.ts +4 -0
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
- package/dist/llm/model/aisdk/v6/model.d.ts +43 -0
- package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -0
- package/dist/llm/model/embedding-router.d.ts +1 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-options.d.ts +2 -1
- package/dist/llm/model/provider-options.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +126 -17
- package/dist/llm/model/resolve-model.d.ts +2 -2
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/llm/model/shared.types.d.ts +18 -7
- package/dist/llm/model/shared.types.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +8 -8
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts +29 -0
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts.map +1 -0
- package/dist/loop/test-utils/fullStream.d.ts +2 -1
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/resultObject.d.ts +2 -1
- package/dist/loop/test-utils/resultObject.d.ts.map +1 -1
- package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
- package/dist/loop/test-utils/utils-v3.d.ts +55 -0
- package/dist/loop/test-utils/utils-v3.d.ts.map +1 -0
- package/dist/loop/types.d.ts +10 -8
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +36 -36
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +25 -25
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +12 -12
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +36 -36
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/run-state.d.ts +2 -2
- package/dist/loop/workflows/run-state.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +12 -12
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +7 -2
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.js +1 -1
- package/dist/memory/index.cjs +26 -6
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +9 -8
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/mock.d.ts +2 -1
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +3 -4
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/working-memory-utils.d.ts +20 -0
- package/dist/memory/working-memory-utils.d.ts.map +1 -0
- package/dist/models-dev-26XLUKVK.cjs +12 -0
- package/dist/{models-dev-D3EKFGAO.cjs.map → models-dev-26XLUKVK.cjs.map} +1 -1
- package/dist/models-dev-HUFLQFPB.js +3 -0
- package/dist/{models-dev-EO22XOXQ.js.map → models-dev-HUFLQFPB.js.map} +1 -1
- package/dist/netlify-CUYK2MZ2.cjs +12 -0
- package/dist/{netlify-WE42TZIT.cjs.map → netlify-CUYK2MZ2.cjs.map} +1 -1
- package/dist/netlify-J4QPOROO.js +3 -0
- package/dist/{netlify-AE4LNCAI.js.map → netlify-J4QPOROO.js.map} +1 -1
- package/dist/observability/index.cjs +14 -10
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +32 -19
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.d.ts +9 -7
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/message-history.d.ts +7 -1
- package/dist/processors/memory/message-history.d.ts.map +1 -1
- package/dist/processors/processors/language-detector.d.ts.map +1 -1
- package/dist/processors/processors/moderation.d.ts.map +1 -1
- package/dist/processors/processors/pii-detector.d.ts.map +1 -1
- package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +5 -2
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +2 -0
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +26 -26
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-6CIGRQVZ.js +3 -0
- package/dist/{provider-registry-6LF3NGC5.js.map → provider-registry-6CIGRQVZ.js.map} +1 -1
- package/dist/provider-registry-7O7FJ4BS.cjs +40 -0
- package/dist/{provider-registry-73FKMXJV.cjs.map → provider-registry-7O7FJ4BS.cjs.map} +1 -1
- package/dist/provider-registry.json +295 -45
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.cjs.map +1 -1
- package/dist/relevance/index.js +2 -2
- package/dist/relevance/index.js.map +1 -1
- package/dist/server/index.cjs +5 -5
- package/dist/server/index.js +1 -1
- package/dist/storage/base.d.ts +40 -292
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +60 -0
- package/dist/storage/constants.cjs.map +1 -0
- package/dist/storage/constants.d.ts +6 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +3 -0
- package/dist/storage/constants.js.map +1 -0
- package/dist/storage/domains/agents/base.d.ts +2 -2
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts +5 -4
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/base.d.ts +20 -0
- package/dist/storage/domains/base.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +57 -0
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -0
- package/dist/storage/domains/memory/base.d.ts +2 -2
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +5 -13
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/base.d.ts +24 -29
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +1 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/inmemory.d.ts +46 -35
- package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +2365 -0
- package/dist/storage/domains/observability/types.d.ts.map +1 -0
- package/dist/storage/domains/scores/base.d.ts +9 -20
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +11 -22
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/shared.d.ts +76 -0
- package/dist/storage/domains/shared.d.ts.map +1 -0
- package/dist/storage/domains/workflows/base.d.ts +4 -2
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +10 -9
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +272 -59
- package/dist/storage/index.js +2 -1
- package/dist/storage/mock.d.ts +28 -174
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +39 -44
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/utils.d.ts +5 -0
- package/dist/storage/utils.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +4 -4
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +2 -2
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +7 -5
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +12 -12
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +32 -21
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/token-6GSAFR2W-LTZ7QQUP.js +61 -0
- package/dist/token-6GSAFR2W-LTZ7QQUP.js.map +1 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs +63 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js +8 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js.map +1 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs +10 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs.map +1 -0
- package/dist/tool-loop-agent/index.cjs +20 -0
- package/dist/tool-loop-agent/index.cjs.map +1 -0
- package/dist/tool-loop-agent/index.d.ts +36 -0
- package/dist/tool-loop-agent/index.d.ts.map +1 -0
- package/dist/tool-loop-agent/index.js +3 -0
- package/dist/tool-loop-agent/index.js.map +1 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts +30 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +1 -0
- package/dist/tool-loop-agent/utils.d.ts +17 -0
- package/dist/tool-loop-agent/utils.d.ts.map +1 -0
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/toolchecks.d.ts +1 -1
- package/dist/tools/toolchecks.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils/zod-utils.d.ts +34 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils.cjs +39 -22
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -1
- package/dist/vector/embed.d.ts +1 -0
- package/dist/vector/embed.d.ts.map +1 -1
- package/dist/vector/index.cjs +18 -5
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +9 -2
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +26 -3
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +2 -0
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +1 -0
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +5 -0
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +20 -4
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +10 -2
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +1 -0
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +4 -0
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/entry.d.ts +3 -2
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +1 -0
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/types.d.ts +23 -3
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +1 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +26 -9
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +20 -12
- package/src/llm/model/provider-types.generated.d.ts +126 -17
- package/storage/constants.d.ts +1 -0
- package/tool-loop-agent.d.ts +1 -0
- package/dist/chunk-2IU4RGU5.js.map +0 -1
- package/dist/chunk-373OC54J.js.map +0 -1
- package/dist/chunk-4BC5FUAO.js.map +0 -1
- package/dist/chunk-5VZGJTPR.js.map +0 -1
- package/dist/chunk-62Q7K656.js.map +0 -1
- package/dist/chunk-72YCRTEX.cjs.map +0 -1
- package/dist/chunk-ADADLFDR.js +0 -42
- package/dist/chunk-ADADLFDR.js.map +0 -1
- package/dist/chunk-AGHLXC4I.cjs.map +0 -1
- package/dist/chunk-ARAQIW6E.js.map +0 -1
- package/dist/chunk-BQDZIQ3G.js.map +0 -1
- package/dist/chunk-E5BQRAJK.js.map +0 -1
- package/dist/chunk-GIWC35YQ.js.map +0 -1
- package/dist/chunk-H4VUIOWU.cjs.map +0 -1
- package/dist/chunk-HWMMIRIF.cjs.map +0 -1
- package/dist/chunk-IXZ2T2QX.cjs +0 -448
- package/dist/chunk-IXZ2T2QX.cjs.map +0 -1
- package/dist/chunk-LGB4VNZI.cjs.map +0 -1
- package/dist/chunk-MLKE7HRS.cjs.map +0 -1
- package/dist/chunk-MRRFTNF4.js.map +0 -1
- package/dist/chunk-MXBVP7HX.cjs.map +0 -1
- package/dist/chunk-OWIEOL55.cjs.map +0 -1
- package/dist/chunk-PJAK4U6R.cjs.map +0 -1
- package/dist/chunk-R5AJGM55.cjs.map +0 -1
- package/dist/chunk-RCJLMMTO.js.map +0 -1
- package/dist/chunk-SZYSDJTN.cjs.map +0 -1
- package/dist/chunk-T2VLUFGG.cjs +0 -47
- package/dist/chunk-T2VLUFGG.cjs.map +0 -1
- package/dist/chunk-U4CSOY6T.cjs.map +0 -1
- package/dist/chunk-UBSPZTQX.js +0 -434
- package/dist/chunk-UBSPZTQX.js.map +0 -1
- package/dist/chunk-VEPP75C4.cjs.map +0 -1
- package/dist/chunk-VETAQUW3.js.map +0 -1
- package/dist/chunk-WYGUWVTF.js.map +0 -1
- package/dist/chunk-WYWRMIQC.js.map +0 -1
- package/dist/chunk-X6IBA7FP.cjs.map +0 -1
- package/dist/chunk-Y36Y5MTD.js.map +0 -1
- package/dist/chunk-Y7MZ5LJT.cjs.map +0 -1
- package/dist/chunk-YPLZDWG7.js.map +0 -1
- package/dist/chunk-Z55SJVEC.cjs.map +0 -1
- package/dist/llm/model/is-v2-model.d.ts +0 -3
- package/dist/llm/model/is-v2-model.d.ts.map +0 -1
- package/dist/models-dev-D3EKFGAO.cjs +0 -12
- package/dist/models-dev-EO22XOXQ.js +0 -3
- package/dist/netlify-AE4LNCAI.js +0 -3
- package/dist/netlify-WE42TZIT.cjs +0 -12
- package/dist/provider-registry-6LF3NGC5.js +0 -3
- package/dist/provider-registry-73FKMXJV.cjs +0 -40
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDDK3URK2_cjs = require('./chunk-DDK3URK2.cjs');
|
|
4
4
|
var chunkL3NKIMF5_cjs = require('./chunk-L3NKIMF5.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
6
|
+
var chunk6HJFCSJ4_cjs = require('./chunk-6HJFCSJ4.cjs');
|
|
6
7
|
var chunkUVHSM2GU_cjs = require('./chunk-UVHSM2GU.cjs');
|
|
7
|
-
var chunkHWMMIRIF_cjs = require('./chunk-HWMMIRIF.cjs');
|
|
8
8
|
var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
|
|
9
9
|
var chunkAF74UXR5_cjs = require('./chunk-AF74UXR5.cjs');
|
|
10
10
|
var EventEmitter = require('events');
|
|
@@ -26,12 +26,12 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
26
26
|
this.mastra = mastra;
|
|
27
27
|
}
|
|
28
28
|
async execute(params) {
|
|
29
|
-
const { step, stepResults, runId, requestContext, retryCount = 0 } = params;
|
|
30
|
-
const abortController = new AbortController();
|
|
29
|
+
const { step, stepResults, runId, requestContext, retryCount = 0, perStep } = params;
|
|
30
|
+
const abortController = params.abortController ?? new AbortController();
|
|
31
31
|
let suspended;
|
|
32
32
|
let bailed;
|
|
33
33
|
const startedAt = Date.now();
|
|
34
|
-
const { inputData, validationError } = await
|
|
34
|
+
const { inputData, validationError } = await chunkDDK3URK2_cjs.validateStepInput({
|
|
35
35
|
prevOutput: typeof params.foreachIdx === "number" ? params.input?.[params.foreachIdx] : params.input,
|
|
36
36
|
step,
|
|
37
37
|
validateInputs: params.validateInputs ?? true
|
|
@@ -55,8 +55,8 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
55
55
|
if (validationError) {
|
|
56
56
|
throw validationError;
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
58
|
+
const stepOutput = await step.execute(
|
|
59
|
+
chunkDDK3URK2_cjs.createDeprecationProxy(
|
|
60
60
|
{
|
|
61
61
|
workflowId: params.workflowId,
|
|
62
62
|
runId,
|
|
@@ -71,9 +71,9 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
71
71
|
resumeData: params.resumeData,
|
|
72
72
|
suspendData: suspendDataToUse,
|
|
73
73
|
getInitData: () => stepResults?.input,
|
|
74
|
-
getStepResult:
|
|
74
|
+
getStepResult: chunkDDK3URK2_cjs.getStepResult.bind(this, stepResults),
|
|
75
75
|
suspend: async (suspendPayload) => {
|
|
76
|
-
const { suspendData, validationError: validationError2 } = await
|
|
76
|
+
const { suspendData, validationError: validationError2 } = await chunkDDK3URK2_cjs.validateStepSuspendData({
|
|
77
77
|
suspendData: suspendPayload,
|
|
78
78
|
step,
|
|
79
79
|
validateInputs: params.validateInputs ?? true
|
|
@@ -91,7 +91,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
91
91
|
abort: () => {
|
|
92
92
|
abortController?.abort();
|
|
93
93
|
},
|
|
94
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
94
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkDDK3URK2_cjs.EventEmitterPubSub(params.emitter),
|
|
95
95
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
96
96
|
// TODO
|
|
97
97
|
engine: {},
|
|
@@ -101,11 +101,13 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
paramName: "runCount",
|
|
104
|
-
deprecationMessage:
|
|
104
|
+
deprecationMessage: chunkDDK3URK2_cjs.runCountDeprecationMessage,
|
|
105
105
|
logger: this.logger
|
|
106
106
|
}
|
|
107
107
|
)
|
|
108
108
|
);
|
|
109
|
+
const isNestedWorkflowStep = step.component === "WORKFLOW";
|
|
110
|
+
const nestedWflowStepPaused = isNestedWorkflowStep && perStep;
|
|
109
111
|
const endedAt = Date.now();
|
|
110
112
|
let finalResult;
|
|
111
113
|
if (suspended) {
|
|
@@ -113,7 +115,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
113
115
|
...stepInfo,
|
|
114
116
|
status: "suspended",
|
|
115
117
|
suspendedAt: endedAt,
|
|
116
|
-
...
|
|
118
|
+
...stepOutput ? { suspendOutput: stepOutput } : {}
|
|
117
119
|
};
|
|
118
120
|
if (suspended.payload) {
|
|
119
121
|
finalResult.suspendPayload = suspended.payload;
|
|
@@ -126,18 +128,23 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
126
128
|
endedAt,
|
|
127
129
|
output: bailed.payload
|
|
128
130
|
};
|
|
131
|
+
} else if (nestedWflowStepPaused) {
|
|
132
|
+
finalResult = {
|
|
133
|
+
...stepInfo,
|
|
134
|
+
status: "paused"
|
|
135
|
+
};
|
|
129
136
|
} else {
|
|
130
137
|
finalResult = {
|
|
131
138
|
...stepInfo,
|
|
132
139
|
status: "success",
|
|
133
140
|
endedAt,
|
|
134
|
-
output:
|
|
141
|
+
output: stepOutput
|
|
135
142
|
};
|
|
136
143
|
}
|
|
137
144
|
return finalResult;
|
|
138
145
|
} catch (error) {
|
|
139
146
|
const endedAt = Date.now();
|
|
140
|
-
const errorInstance =
|
|
147
|
+
const errorInstance = chunk4U7ZLI36_cjs.getErrorFromUnknown(error, {
|
|
141
148
|
serializeStack: false,
|
|
142
149
|
fallbackMessage: "Unknown step execution error"
|
|
143
150
|
});
|
|
@@ -151,7 +158,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
151
158
|
}
|
|
152
159
|
async evaluateConditions(params) {
|
|
153
160
|
const { step, stepResults, runId, requestContext, retryCount = 0 } = params;
|
|
154
|
-
const abortController = new AbortController();
|
|
161
|
+
const abortController = params.abortController ?? new AbortController();
|
|
155
162
|
const ee = new EventEmitter__default.default();
|
|
156
163
|
const results = await Promise.all(
|
|
157
164
|
step.conditions.map((condition) => {
|
|
@@ -199,7 +206,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
199
206
|
iterationCount
|
|
200
207
|
}) {
|
|
201
208
|
return condition(
|
|
202
|
-
|
|
209
|
+
chunkDDK3URK2_cjs.createDeprecationProxy(
|
|
203
210
|
{
|
|
204
211
|
workflowId,
|
|
205
212
|
runId,
|
|
@@ -210,7 +217,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
210
217
|
retryCount,
|
|
211
218
|
resumeData,
|
|
212
219
|
getInitData: () => stepResults?.input,
|
|
213
|
-
getStepResult:
|
|
220
|
+
getStepResult: chunkDDK3URK2_cjs.getStepResult.bind(this, stepResults),
|
|
214
221
|
bail: (_result) => {
|
|
215
222
|
throw new Error("Not implemented");
|
|
216
223
|
},
|
|
@@ -219,7 +226,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
219
226
|
abort: () => {
|
|
220
227
|
abortController?.abort();
|
|
221
228
|
},
|
|
222
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
229
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkDDK3URK2_cjs.EventEmitterPubSub(emitter),
|
|
223
230
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
224
231
|
// TODO
|
|
225
232
|
engine: {},
|
|
@@ -230,7 +237,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
230
237
|
},
|
|
231
238
|
{
|
|
232
239
|
paramName: "runCount",
|
|
233
|
-
deprecationMessage:
|
|
240
|
+
deprecationMessage: chunkDDK3URK2_cjs.runCountDeprecationMessage,
|
|
234
241
|
logger: this.logger
|
|
235
242
|
}
|
|
236
243
|
)
|
|
@@ -238,7 +245,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
238
245
|
}
|
|
239
246
|
async resolveSleep(params) {
|
|
240
247
|
const { step, stepResults, runId, requestContext, retryCount = 0 } = params;
|
|
241
|
-
const abortController = new AbortController();
|
|
248
|
+
const abortController = params.abortController ?? new AbortController();
|
|
242
249
|
const ee = new EventEmitter__default.default();
|
|
243
250
|
if (step.duration) {
|
|
244
251
|
return step.duration;
|
|
@@ -248,7 +255,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
248
255
|
}
|
|
249
256
|
try {
|
|
250
257
|
return await step.fn(
|
|
251
|
-
|
|
258
|
+
chunkDDK3URK2_cjs.createDeprecationProxy(
|
|
252
259
|
{
|
|
253
260
|
workflowId: params.workflowId,
|
|
254
261
|
runId,
|
|
@@ -262,7 +269,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
262
269
|
retryCount,
|
|
263
270
|
resumeData: params.resumeData,
|
|
264
271
|
getInitData: () => stepResults?.input,
|
|
265
|
-
getStepResult:
|
|
272
|
+
getStepResult: chunkDDK3URK2_cjs.getStepResult.bind(this, stepResults),
|
|
266
273
|
suspend: async (_suspendPayload) => {
|
|
267
274
|
throw new Error("Not implemented");
|
|
268
275
|
},
|
|
@@ -274,7 +281,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
274
281
|
},
|
|
275
282
|
// TODO
|
|
276
283
|
writer: void 0,
|
|
277
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
284
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkDDK3URK2_cjs.EventEmitterPubSub(ee),
|
|
278
285
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
279
286
|
// TODO
|
|
280
287
|
engine: {},
|
|
@@ -284,7 +291,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
284
291
|
},
|
|
285
292
|
{
|
|
286
293
|
paramName: "runCount",
|
|
287
|
-
deprecationMessage:
|
|
294
|
+
deprecationMessage: chunkDDK3URK2_cjs.runCountDeprecationMessage,
|
|
288
295
|
logger: this.logger
|
|
289
296
|
}
|
|
290
297
|
)
|
|
@@ -296,7 +303,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
296
303
|
}
|
|
297
304
|
async resolveSleepUntil(params) {
|
|
298
305
|
const { step, stepResults, runId, requestContext, retryCount = 0 } = params;
|
|
299
|
-
const abortController = new AbortController();
|
|
306
|
+
const abortController = params.abortController ?? new AbortController();
|
|
300
307
|
const ee = new EventEmitter__default.default();
|
|
301
308
|
if (step.date) {
|
|
302
309
|
return step.date.getTime() - Date.now();
|
|
@@ -306,7 +313,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
306
313
|
}
|
|
307
314
|
try {
|
|
308
315
|
const result = await step.fn(
|
|
309
|
-
|
|
316
|
+
chunkDDK3URK2_cjs.createDeprecationProxy(
|
|
310
317
|
{
|
|
311
318
|
workflowId: params.workflowId,
|
|
312
319
|
runId,
|
|
@@ -320,7 +327,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
320
327
|
retryCount,
|
|
321
328
|
resumeData: params.resumeData,
|
|
322
329
|
getInitData: () => stepResults?.input,
|
|
323
|
-
getStepResult:
|
|
330
|
+
getStepResult: chunkDDK3URK2_cjs.getStepResult.bind(this, stepResults),
|
|
324
331
|
suspend: async (_suspendPayload) => {
|
|
325
332
|
throw new Error("Not implemented");
|
|
326
333
|
},
|
|
@@ -332,7 +339,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
332
339
|
},
|
|
333
340
|
// TODO
|
|
334
341
|
writer: void 0,
|
|
335
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
342
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkDDK3URK2_cjs.EventEmitterPubSub(ee),
|
|
336
343
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
337
344
|
// TODO
|
|
338
345
|
engine: {},
|
|
@@ -342,7 +349,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
342
349
|
},
|
|
343
350
|
{
|
|
344
351
|
paramName: "runCount",
|
|
345
|
-
deprecationMessage:
|
|
352
|
+
deprecationMessage: chunkDDK3URK2_cjs.runCountDeprecationMessage,
|
|
346
353
|
logger: this.logger
|
|
347
354
|
}
|
|
348
355
|
)
|
|
@@ -376,7 +383,8 @@ async function processWorkflowLoop({
|
|
|
376
383
|
resumeData,
|
|
377
384
|
parentWorkflow,
|
|
378
385
|
requestContext,
|
|
379
|
-
retryCount = 0
|
|
386
|
+
retryCount = 0,
|
|
387
|
+
perStep
|
|
380
388
|
}, {
|
|
381
389
|
pubsub,
|
|
382
390
|
stepExecutor,
|
|
@@ -416,7 +424,8 @@ async function processWorkflowLoop({
|
|
|
416
424
|
prevResult: stepResult,
|
|
417
425
|
resumeData,
|
|
418
426
|
activeSteps,
|
|
419
|
-
requestContext
|
|
427
|
+
requestContext,
|
|
428
|
+
perStep
|
|
420
429
|
}
|
|
421
430
|
});
|
|
422
431
|
} else {
|
|
@@ -434,7 +443,8 @@ async function processWorkflowLoop({
|
|
|
434
443
|
resumeData,
|
|
435
444
|
activeSteps,
|
|
436
445
|
requestContext,
|
|
437
|
-
retryCount
|
|
446
|
+
retryCount,
|
|
447
|
+
perStep
|
|
438
448
|
}
|
|
439
449
|
});
|
|
440
450
|
}
|
|
@@ -454,7 +464,8 @@ async function processWorkflowLoop({
|
|
|
454
464
|
resumeData,
|
|
455
465
|
activeSteps,
|
|
456
466
|
requestContext,
|
|
457
|
-
retryCount
|
|
467
|
+
retryCount,
|
|
468
|
+
perStep
|
|
458
469
|
}
|
|
459
470
|
});
|
|
460
471
|
} else {
|
|
@@ -471,7 +482,8 @@ async function processWorkflowLoop({
|
|
|
471
482
|
prevResult: stepResult,
|
|
472
483
|
resumeData,
|
|
473
484
|
activeSteps,
|
|
474
|
-
requestContext
|
|
485
|
+
requestContext,
|
|
486
|
+
perStep
|
|
475
487
|
}
|
|
476
488
|
});
|
|
477
489
|
}
|
|
@@ -488,7 +500,8 @@ async function processWorkflowForEach({
|
|
|
488
500
|
timeTravel,
|
|
489
501
|
resumeData,
|
|
490
502
|
parentWorkflow,
|
|
491
|
-
requestContext
|
|
503
|
+
requestContext,
|
|
504
|
+
perStep
|
|
492
505
|
}, {
|
|
493
506
|
pubsub,
|
|
494
507
|
mastra,
|
|
@@ -512,22 +525,24 @@ async function processWorkflowForEach({
|
|
|
512
525
|
prevResult: currentResult,
|
|
513
526
|
resumeData,
|
|
514
527
|
activeSteps,
|
|
515
|
-
requestContext
|
|
528
|
+
requestContext,
|
|
529
|
+
perStep
|
|
516
530
|
}
|
|
517
531
|
});
|
|
518
532
|
return;
|
|
519
533
|
} else if (idx >= targetLen) {
|
|
520
534
|
return;
|
|
521
535
|
}
|
|
536
|
+
const workflowsStore = await mastra.getStorage()?.getStore("workflows");
|
|
522
537
|
if (executionPath.length === 1 && idx === 0) {
|
|
523
538
|
const concurrency = Math.min(step.opts.concurrency ?? 1, targetLen);
|
|
524
539
|
const dummyResult = Array.from({ length: concurrency }, () => null);
|
|
525
|
-
await
|
|
540
|
+
await workflowsStore?.updateWorkflowResults({
|
|
526
541
|
workflowName: workflowId,
|
|
527
542
|
runId,
|
|
528
543
|
stepId: step.step.id,
|
|
529
544
|
result: {
|
|
530
|
-
status: "
|
|
545
|
+
status: "success",
|
|
531
546
|
output: dummyResult,
|
|
532
547
|
startedAt: Date.now(),
|
|
533
548
|
payload: prevResult?.output
|
|
@@ -549,19 +564,20 @@ async function processWorkflowForEach({
|
|
|
549
564
|
prevResult,
|
|
550
565
|
resumeData,
|
|
551
566
|
activeSteps,
|
|
552
|
-
requestContext
|
|
567
|
+
requestContext,
|
|
568
|
+
perStep
|
|
553
569
|
}
|
|
554
570
|
});
|
|
555
571
|
}
|
|
556
572
|
return;
|
|
557
573
|
}
|
|
558
574
|
currentResult.output.push(null);
|
|
559
|
-
await
|
|
575
|
+
await workflowsStore?.updateWorkflowResults({
|
|
560
576
|
workflowName: workflowId,
|
|
561
577
|
runId,
|
|
562
578
|
stepId: step.step.id,
|
|
563
579
|
result: {
|
|
564
|
-
status: "
|
|
580
|
+
status: "success",
|
|
565
581
|
output: currentResult.output,
|
|
566
582
|
startedAt: Date.now(),
|
|
567
583
|
payload: prevResult?.output
|
|
@@ -582,7 +598,8 @@ async function processWorkflowForEach({
|
|
|
582
598
|
prevResult,
|
|
583
599
|
resumeData,
|
|
584
600
|
activeSteps,
|
|
585
|
-
requestContext
|
|
601
|
+
requestContext,
|
|
602
|
+
perStep
|
|
586
603
|
}
|
|
587
604
|
});
|
|
588
605
|
}
|
|
@@ -597,7 +614,8 @@ async function processWorkflowParallel({
|
|
|
597
614
|
prevResult,
|
|
598
615
|
resumeData,
|
|
599
616
|
parentWorkflow,
|
|
600
|
-
requestContext
|
|
617
|
+
requestContext,
|
|
618
|
+
perStep
|
|
601
619
|
}, {
|
|
602
620
|
pubsub,
|
|
603
621
|
step
|
|
@@ -606,10 +624,13 @@ async function processWorkflowParallel({
|
|
|
606
624
|
const nestedStep = step.steps[i];
|
|
607
625
|
if (nestedStep?.type === "step") {
|
|
608
626
|
activeSteps[nestedStep.step.id] = true;
|
|
627
|
+
if (perStep) {
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
609
630
|
}
|
|
610
631
|
}
|
|
611
632
|
await Promise.all(
|
|
612
|
-
step.steps.map(async (_step, idx) => {
|
|
633
|
+
step.steps?.filter((step2) => activeSteps[step2.step.id]).map(async (_step, idx) => {
|
|
613
634
|
return pubsub.publish("workflows", {
|
|
614
635
|
type: "workflow.step.run",
|
|
615
636
|
runId,
|
|
@@ -624,7 +645,8 @@ async function processWorkflowParallel({
|
|
|
624
645
|
timeTravel,
|
|
625
646
|
parentWorkflow,
|
|
626
647
|
activeSteps,
|
|
627
|
-
requestContext
|
|
648
|
+
requestContext,
|
|
649
|
+
perStep
|
|
628
650
|
}
|
|
629
651
|
});
|
|
630
652
|
})
|
|
@@ -641,7 +663,8 @@ async function processWorkflowConditional({
|
|
|
641
663
|
prevResult,
|
|
642
664
|
resumeData,
|
|
643
665
|
parentWorkflow,
|
|
644
|
-
requestContext
|
|
666
|
+
requestContext,
|
|
667
|
+
perStep
|
|
645
668
|
}, {
|
|
646
669
|
pubsub,
|
|
647
670
|
stepExecutor,
|
|
@@ -665,49 +688,79 @@ async function processWorkflowConditional({
|
|
|
665
688
|
for (let i = 0; i < idxs.length; i++) {
|
|
666
689
|
truthyIdxs[idxs[i]] = true;
|
|
667
690
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
691
|
+
let onlyStepToRun;
|
|
692
|
+
if (perStep) {
|
|
693
|
+
const stepsToRun = step.steps.filter((_, idx) => truthyIdxs[idx]);
|
|
694
|
+
onlyStepToRun = stepsToRun[0];
|
|
695
|
+
}
|
|
696
|
+
if (onlyStepToRun) {
|
|
697
|
+
activeSteps[onlyStepToRun.step.id] = true;
|
|
698
|
+
const stepIndex = step.steps.findIndex((step2) => step2.step.id === onlyStepToRun.step.id);
|
|
699
|
+
await pubsub.publish("workflows", {
|
|
700
|
+
type: "workflow.step.run",
|
|
701
|
+
runId,
|
|
702
|
+
data: {
|
|
703
|
+
workflowId,
|
|
704
|
+
runId,
|
|
705
|
+
executionPath: executionPath.concat([stepIndex]),
|
|
706
|
+
resumeSteps,
|
|
707
|
+
stepResults,
|
|
708
|
+
timeTravel,
|
|
709
|
+
prevResult,
|
|
710
|
+
resumeData,
|
|
711
|
+
parentWorkflow,
|
|
712
|
+
activeSteps,
|
|
713
|
+
requestContext,
|
|
714
|
+
perStep
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
} else {
|
|
718
|
+
await Promise.all(
|
|
719
|
+
step.steps.map(async (step2, idx) => {
|
|
720
|
+
if (truthyIdxs[idx]) {
|
|
721
|
+
if (step2?.type === "step") {
|
|
722
|
+
activeSteps[step2.step.id] = true;
|
|
689
723
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
return pubsub.publish("workflows", {
|
|
693
|
-
type: "workflow.step.end",
|
|
694
|
-
runId,
|
|
695
|
-
data: {
|
|
696
|
-
workflowId,
|
|
724
|
+
return pubsub.publish("workflows", {
|
|
725
|
+
type: "workflow.step.run",
|
|
697
726
|
runId,
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
727
|
+
data: {
|
|
728
|
+
workflowId,
|
|
729
|
+
runId,
|
|
730
|
+
executionPath: executionPath.concat([idx]),
|
|
731
|
+
resumeSteps,
|
|
732
|
+
stepResults,
|
|
733
|
+
timeTravel,
|
|
734
|
+
prevResult,
|
|
735
|
+
resumeData,
|
|
736
|
+
parentWorkflow,
|
|
737
|
+
activeSteps,
|
|
738
|
+
requestContext,
|
|
739
|
+
perStep
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
} else {
|
|
743
|
+
return pubsub.publish("workflows", {
|
|
744
|
+
type: "workflow.step.end",
|
|
745
|
+
runId,
|
|
746
|
+
data: {
|
|
747
|
+
workflowId,
|
|
748
|
+
runId,
|
|
749
|
+
executionPath: executionPath.concat([idx]),
|
|
750
|
+
resumeSteps,
|
|
751
|
+
stepResults,
|
|
752
|
+
prevResult: { status: "skipped" },
|
|
753
|
+
resumeData,
|
|
754
|
+
parentWorkflow,
|
|
755
|
+
activeSteps,
|
|
756
|
+
requestContext,
|
|
757
|
+
perStep
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
})
|
|
762
|
+
);
|
|
763
|
+
}
|
|
711
764
|
}
|
|
712
765
|
async function processWorkflowWaitForEvent(workflowData, {
|
|
713
766
|
pubsub,
|
|
@@ -736,7 +789,8 @@ async function processWorkflowWaitForEvent(workflowData, {
|
|
|
736
789
|
stepResults: currentState?.context,
|
|
737
790
|
prevResult,
|
|
738
791
|
activeSteps: [],
|
|
739
|
-
requestContext: currentState?.requestContext
|
|
792
|
+
requestContext: currentState?.requestContext,
|
|
793
|
+
perStep: workflowData.perStep
|
|
740
794
|
}
|
|
741
795
|
});
|
|
742
796
|
}
|
|
@@ -751,7 +805,8 @@ async function processWorkflowSleep({
|
|
|
751
805
|
prevResult,
|
|
752
806
|
resumeData,
|
|
753
807
|
parentWorkflow,
|
|
754
|
-
requestContext
|
|
808
|
+
requestContext,
|
|
809
|
+
perStep
|
|
755
810
|
}, {
|
|
756
811
|
pubsub,
|
|
757
812
|
stepExecutor,
|
|
@@ -825,7 +880,8 @@ async function processWorkflowSleep({
|
|
|
825
880
|
resumeData,
|
|
826
881
|
parentWorkflow,
|
|
827
882
|
activeSteps,
|
|
828
|
-
requestContext
|
|
883
|
+
requestContext,
|
|
884
|
+
perStep
|
|
829
885
|
}
|
|
830
886
|
});
|
|
831
887
|
},
|
|
@@ -843,7 +899,8 @@ async function processWorkflowSleepUntil({
|
|
|
843
899
|
prevResult,
|
|
844
900
|
resumeData,
|
|
845
901
|
parentWorkflow,
|
|
846
|
-
requestContext
|
|
902
|
+
requestContext,
|
|
903
|
+
perStep
|
|
847
904
|
}, {
|
|
848
905
|
pubsub,
|
|
849
906
|
stepExecutor,
|
|
@@ -917,7 +974,8 @@ async function processWorkflowSleepUntil({
|
|
|
917
974
|
resumeData,
|
|
918
975
|
parentWorkflow,
|
|
919
976
|
activeSteps,
|
|
920
|
-
requestContext
|
|
977
|
+
requestContext,
|
|
978
|
+
perStep
|
|
921
979
|
}
|
|
922
980
|
});
|
|
923
981
|
},
|
|
@@ -928,10 +986,52 @@ async function processWorkflowSleepUntil({
|
|
|
928
986
|
// src/workflows/evented/workflow-event-processor/index.ts
|
|
929
987
|
var WorkflowEventProcessor = class extends EventProcessor {
|
|
930
988
|
stepExecutor;
|
|
989
|
+
// Map of runId -> AbortController for active workflow runs
|
|
990
|
+
abortControllers = /* @__PURE__ */ new Map();
|
|
991
|
+
// Map of child runId -> parent runId for tracking nested workflows
|
|
992
|
+
parentChildRelationships = /* @__PURE__ */ new Map();
|
|
931
993
|
constructor({ mastra }) {
|
|
932
994
|
super({ mastra });
|
|
933
995
|
this.stepExecutor = new StepExecutor({ mastra });
|
|
934
996
|
}
|
|
997
|
+
/**
|
|
998
|
+
* Get or create an AbortController for a workflow run
|
|
999
|
+
*/
|
|
1000
|
+
getOrCreateAbortController(runId) {
|
|
1001
|
+
let controller = this.abortControllers.get(runId);
|
|
1002
|
+
if (!controller) {
|
|
1003
|
+
controller = new AbortController();
|
|
1004
|
+
this.abortControllers.set(runId, controller);
|
|
1005
|
+
}
|
|
1006
|
+
return controller;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Cancel a workflow run and all its nested child workflows
|
|
1010
|
+
*/
|
|
1011
|
+
cancelRunAndChildren(runId) {
|
|
1012
|
+
const controller = this.abortControllers.get(runId);
|
|
1013
|
+
if (controller) {
|
|
1014
|
+
controller.abort();
|
|
1015
|
+
}
|
|
1016
|
+
for (const [childRunId, parentRunId] of this.parentChildRelationships.entries()) {
|
|
1017
|
+
if (parentRunId === runId) {
|
|
1018
|
+
this.cancelRunAndChildren(childRunId);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Clean up abort controller and relationships when a workflow completes.
|
|
1024
|
+
* Also cleans up any orphaned child entries that reference this run as parent.
|
|
1025
|
+
*/
|
|
1026
|
+
cleanupRun(runId) {
|
|
1027
|
+
this.abortControllers.delete(runId);
|
|
1028
|
+
this.parentChildRelationships.delete(runId);
|
|
1029
|
+
for (const [childRunId, parentRunId] of this.parentChildRelationships.entries()) {
|
|
1030
|
+
if (parentRunId === runId) {
|
|
1031
|
+
this.parentChildRelationships.delete(childRunId);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
935
1035
|
__registerMastra(mastra) {
|
|
936
1036
|
super.__registerMastra(mastra);
|
|
937
1037
|
this.stepExecutor.__registerMastra(mastra);
|
|
@@ -954,7 +1054,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
954
1054
|
executionPath: [],
|
|
955
1055
|
resumeSteps,
|
|
956
1056
|
stepResults,
|
|
957
|
-
prevResult: { status: "failed", error:
|
|
1057
|
+
prevResult: { status: "failed", error: chunk4U7ZLI36_cjs.getErrorFromUnknown(e).toJSON() },
|
|
958
1058
|
requestContext,
|
|
959
1059
|
resumeData,
|
|
960
1060
|
activeSteps: {},
|
|
@@ -963,11 +1063,15 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
963
1063
|
});
|
|
964
1064
|
}
|
|
965
1065
|
async processWorkflowCancel({ workflowId, runId }) {
|
|
966
|
-
|
|
967
|
-
const
|
|
1066
|
+
this.cancelRunAndChildren(runId);
|
|
1067
|
+
const workflowsStore = await this.mastra.getStorage()?.getStore("workflows");
|
|
1068
|
+
const currentState = await workflowsStore?.loadWorkflowSnapshot({
|
|
968
1069
|
workflowName: workflowId,
|
|
969
1070
|
runId
|
|
970
1071
|
});
|
|
1072
|
+
if (!currentState) {
|
|
1073
|
+
this.mastra.getLogger()?.warn("Canceling workflow without loaded state", { workflowId, runId });
|
|
1074
|
+
}
|
|
971
1075
|
await this.endWorkflow(
|
|
972
1076
|
{
|
|
973
1077
|
workflow: void 0,
|
|
@@ -996,11 +1100,17 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
996
1100
|
timeTravel,
|
|
997
1101
|
executionPath,
|
|
998
1102
|
stepResults,
|
|
999
|
-
requestContext
|
|
1103
|
+
requestContext,
|
|
1104
|
+
perStep
|
|
1000
1105
|
}) {
|
|
1001
|
-
|
|
1106
|
+
this.getOrCreateAbortController(runId);
|
|
1107
|
+
if (parentWorkflow?.runId) {
|
|
1108
|
+
this.parentChildRelationships.set(runId, parentWorkflow.runId);
|
|
1109
|
+
}
|
|
1110
|
+
const workflowsStore = await this.mastra.getStorage()?.getStore("workflows");
|
|
1111
|
+
const existingRun = await workflowsStore?.getWorkflowRunById({ runId, workflowName: workflow.id });
|
|
1002
1112
|
const resourceId = existingRun?.resourceId;
|
|
1003
|
-
await
|
|
1113
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
1004
1114
|
workflowName: workflow.id,
|
|
1005
1115
|
runId,
|
|
1006
1116
|
resourceId,
|
|
@@ -1036,20 +1146,32 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1036
1146
|
timeTravel,
|
|
1037
1147
|
requestContext,
|
|
1038
1148
|
resumeData,
|
|
1039
|
-
activeSteps: {}
|
|
1149
|
+
activeSteps: {},
|
|
1150
|
+
perStep
|
|
1040
1151
|
}
|
|
1041
1152
|
});
|
|
1042
1153
|
}
|
|
1043
1154
|
async endWorkflow(args, status = "success") {
|
|
1044
|
-
const { workflowId, runId, prevResult } = args;
|
|
1045
|
-
await this.mastra.getStorage()?.
|
|
1155
|
+
const { workflowId, runId, prevResult, perStep } = args;
|
|
1156
|
+
const workflowsStore = await this.mastra.getStorage()?.getStore("workflows");
|
|
1157
|
+
await workflowsStore?.updateWorkflowState({
|
|
1046
1158
|
workflowName: workflowId,
|
|
1047
1159
|
runId,
|
|
1048
1160
|
opts: {
|
|
1049
|
-
status,
|
|
1161
|
+
status: perStep && status === "success" ? "paused" : status,
|
|
1050
1162
|
result: prevResult
|
|
1051
1163
|
}
|
|
1052
1164
|
});
|
|
1165
|
+
if (perStep) {
|
|
1166
|
+
await this.mastra.pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
1167
|
+
type: "watch",
|
|
1168
|
+
runId,
|
|
1169
|
+
data: {
|
|
1170
|
+
type: "workflow-paused",
|
|
1171
|
+
payload: {}
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1053
1175
|
await this.mastra.pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
1054
1176
|
type: "watch",
|
|
1055
1177
|
runId,
|
|
@@ -1067,7 +1189,18 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1067
1189
|
});
|
|
1068
1190
|
}
|
|
1069
1191
|
async processWorkflowEnd(args) {
|
|
1070
|
-
const {
|
|
1192
|
+
const {
|
|
1193
|
+
resumeSteps,
|
|
1194
|
+
prevResult,
|
|
1195
|
+
resumeData,
|
|
1196
|
+
parentWorkflow,
|
|
1197
|
+
activeSteps,
|
|
1198
|
+
requestContext,
|
|
1199
|
+
runId,
|
|
1200
|
+
timeTravel,
|
|
1201
|
+
perStep
|
|
1202
|
+
} = args;
|
|
1203
|
+
this.cleanupRun(runId);
|
|
1071
1204
|
if (parentWorkflow) {
|
|
1072
1205
|
await this.mastra.pubsub.publish("workflows", {
|
|
1073
1206
|
type: "workflow.step.end",
|
|
@@ -1084,7 +1217,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1084
1217
|
parentWorkflow: parentWorkflow.parentWorkflow,
|
|
1085
1218
|
parentContext: parentWorkflow,
|
|
1086
1219
|
requestContext,
|
|
1087
|
-
timeTravel
|
|
1220
|
+
timeTravel,
|
|
1221
|
+
perStep
|
|
1088
1222
|
}
|
|
1089
1223
|
});
|
|
1090
1224
|
}
|
|
@@ -1143,7 +1277,9 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1143
1277
|
requestContext,
|
|
1144
1278
|
timeTravel
|
|
1145
1279
|
} = args;
|
|
1146
|
-
|
|
1280
|
+
this.cleanupRun(runId);
|
|
1281
|
+
const workflowsStore = await this.mastra.getStorage()?.getStore("workflows");
|
|
1282
|
+
await workflowsStore?.updateWorkflowState({
|
|
1147
1283
|
workflowName: workflowId,
|
|
1148
1284
|
runId,
|
|
1149
1285
|
opts: {
|
|
@@ -1190,7 +1326,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1190
1326
|
resumeData,
|
|
1191
1327
|
parentWorkflow,
|
|
1192
1328
|
requestContext,
|
|
1193
|
-
retryCount = 0
|
|
1329
|
+
retryCount = 0,
|
|
1330
|
+
perStep
|
|
1194
1331
|
}) {
|
|
1195
1332
|
let stepGraph = workflow.stepGraph;
|
|
1196
1333
|
if (!executionPath?.length) {
|
|
@@ -1207,7 +1344,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1207
1344
|
parentWorkflow,
|
|
1208
1345
|
requestContext
|
|
1209
1346
|
},
|
|
1210
|
-
new
|
|
1347
|
+
new chunk4U7ZLI36_cjs.MastraError({
|
|
1211
1348
|
id: "MASTRA_WORKFLOW",
|
|
1212
1349
|
text: `Execution path is empty: ${JSON.stringify(executionPath)}`,
|
|
1213
1350
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -1230,7 +1367,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1230
1367
|
parentWorkflow,
|
|
1231
1368
|
requestContext
|
|
1232
1369
|
},
|
|
1233
|
-
new
|
|
1370
|
+
new chunk4U7ZLI36_cjs.MastraError({
|
|
1234
1371
|
id: "MASTRA_WORKFLOW",
|
|
1235
1372
|
text: `Step not found in step graph: ${JSON.stringify(executionPath)}`,
|
|
1236
1373
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -1253,7 +1390,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1253
1390
|
prevResult,
|
|
1254
1391
|
resumeData,
|
|
1255
1392
|
parentWorkflow,
|
|
1256
|
-
requestContext
|
|
1393
|
+
requestContext,
|
|
1394
|
+
perStep
|
|
1257
1395
|
},
|
|
1258
1396
|
{
|
|
1259
1397
|
pubsub: this.mastra.pubsub,
|
|
@@ -1273,7 +1411,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1273
1411
|
prevResult,
|
|
1274
1412
|
resumeData,
|
|
1275
1413
|
parentWorkflow,
|
|
1276
|
-
requestContext
|
|
1414
|
+
requestContext,
|
|
1415
|
+
perStep
|
|
1277
1416
|
},
|
|
1278
1417
|
{
|
|
1279
1418
|
pubsub: this.mastra.pubsub,
|
|
@@ -1294,7 +1433,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1294
1433
|
prevResult,
|
|
1295
1434
|
resumeData,
|
|
1296
1435
|
parentWorkflow,
|
|
1297
|
-
requestContext
|
|
1436
|
+
requestContext,
|
|
1437
|
+
perStep
|
|
1298
1438
|
},
|
|
1299
1439
|
{
|
|
1300
1440
|
pubsub: this.mastra.pubsub,
|
|
@@ -1315,7 +1455,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1315
1455
|
prevResult,
|
|
1316
1456
|
resumeData,
|
|
1317
1457
|
parentWorkflow,
|
|
1318
|
-
requestContext
|
|
1458
|
+
requestContext,
|
|
1459
|
+
perStep
|
|
1319
1460
|
},
|
|
1320
1461
|
{
|
|
1321
1462
|
pubsub: this.mastra.pubsub,
|
|
@@ -1336,7 +1477,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1336
1477
|
prevResult,
|
|
1337
1478
|
resumeData,
|
|
1338
1479
|
parentWorkflow,
|
|
1339
|
-
requestContext
|
|
1480
|
+
requestContext,
|
|
1481
|
+
perStep
|
|
1340
1482
|
},
|
|
1341
1483
|
{
|
|
1342
1484
|
pubsub: this.mastra.pubsub,
|
|
@@ -1359,7 +1501,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1359
1501
|
parentWorkflow,
|
|
1360
1502
|
requestContext
|
|
1361
1503
|
},
|
|
1362
|
-
new
|
|
1504
|
+
new chunk4U7ZLI36_cjs.MastraError({
|
|
1363
1505
|
id: "MASTRA_WORKFLOW",
|
|
1364
1506
|
text: `Step is not executable: ${step?.type} -- ${JSON.stringify(executionPath)}`,
|
|
1365
1507
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -1368,6 +1510,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1368
1510
|
);
|
|
1369
1511
|
}
|
|
1370
1512
|
activeSteps[step.step.id] = true;
|
|
1513
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
1371
1514
|
if (step.step instanceof EventedWorkflow) {
|
|
1372
1515
|
if (resumeSteps?.length > 1) {
|
|
1373
1516
|
const stepData = stepResults[step.step.id];
|
|
@@ -1386,7 +1529,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1386
1529
|
parentWorkflow,
|
|
1387
1530
|
requestContext
|
|
1388
1531
|
},
|
|
1389
|
-
new
|
|
1532
|
+
new chunk4U7ZLI36_cjs.MastraError({
|
|
1390
1533
|
id: "MASTRA_WORKFLOW",
|
|
1391
1534
|
text: `Nested workflow run id not found: ${JSON.stringify(stepResults)}`,
|
|
1392
1535
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -1394,7 +1537,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1394
1537
|
})
|
|
1395
1538
|
);
|
|
1396
1539
|
}
|
|
1397
|
-
const snapshot = await
|
|
1540
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
1398
1541
|
workflowName: step.step.id,
|
|
1399
1542
|
runId: nestedRunId
|
|
1400
1543
|
});
|
|
@@ -1422,22 +1565,24 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1422
1565
|
prevResult,
|
|
1423
1566
|
resumeData,
|
|
1424
1567
|
activeSteps,
|
|
1425
|
-
requestContext
|
|
1568
|
+
requestContext,
|
|
1569
|
+
perStep
|
|
1426
1570
|
}
|
|
1427
1571
|
});
|
|
1428
1572
|
} else if (timeTravel && timeTravel.steps?.length > 1 && timeTravel.steps[0] === step.step.id) {
|
|
1429
|
-
const snapshot = await
|
|
1573
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
1430
1574
|
workflowName: step.step.id,
|
|
1431
1575
|
runId
|
|
1432
1576
|
}) ?? { context: {} };
|
|
1433
|
-
const timeTravelParams =
|
|
1577
|
+
const timeTravelParams = chunkDDK3URK2_cjs.createTimeTravelExecutionParams({
|
|
1434
1578
|
steps: timeTravel.steps.slice(1),
|
|
1435
1579
|
inputData: timeTravel.inputData,
|
|
1436
1580
|
resumeData: timeTravel.resumeData,
|
|
1437
1581
|
context: timeTravel.nestedStepResults?.[step.step.id] ?? {},
|
|
1438
1582
|
nestedStepsContext: timeTravel.nestedStepResults ?? {},
|
|
1439
1583
|
snapshot,
|
|
1440
|
-
graph: step.step.buildExecutionGraph()
|
|
1584
|
+
graph: step.step.buildExecutionGraph(),
|
|
1585
|
+
perStep
|
|
1441
1586
|
});
|
|
1442
1587
|
const nestedPrevStep = getStep(step.step, timeTravelParams.executionPath);
|
|
1443
1588
|
const nestedPrevResult = timeTravelParams.stepResults[nestedPrevStep?.id ?? "input"];
|
|
@@ -1463,7 +1608,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1463
1608
|
prevResult: { status: "success", output: nestedPrevResult?.payload },
|
|
1464
1609
|
timeTravel: timeTravelParams,
|
|
1465
1610
|
activeSteps,
|
|
1466
|
-
requestContext
|
|
1611
|
+
requestContext,
|
|
1612
|
+
perStep
|
|
1467
1613
|
}
|
|
1468
1614
|
});
|
|
1469
1615
|
} else {
|
|
@@ -1488,7 +1634,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1488
1634
|
prevResult,
|
|
1489
1635
|
resumeData,
|
|
1490
1636
|
activeSteps,
|
|
1491
|
-
requestContext
|
|
1637
|
+
requestContext,
|
|
1638
|
+
perStep
|
|
1492
1639
|
}
|
|
1493
1640
|
});
|
|
1494
1641
|
}
|
|
@@ -1521,7 +1668,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1521
1668
|
for (const [key, value] of Object.entries(requestContext)) {
|
|
1522
1669
|
rc.set(key, value);
|
|
1523
1670
|
}
|
|
1524
|
-
const { resumeData: timeTravelResumeData, validationError: timeTravelResumeValidationError } = await
|
|
1671
|
+
const { resumeData: timeTravelResumeData, validationError: timeTravelResumeValidationError } = await chunkDDK3URK2_cjs.validateStepResumeData({
|
|
1525
1672
|
resumeData: timeTravel?.stepResults[step.step.id]?.status === "suspended" ? timeTravel?.resumeData : void 0,
|
|
1526
1673
|
step: step.step
|
|
1527
1674
|
});
|
|
@@ -1536,6 +1683,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1536
1683
|
} else if (resumeSteps?.length > 0 && resumeSteps?.[0] === step.step.id) {
|
|
1537
1684
|
resumeDataToUse = resumeData;
|
|
1538
1685
|
}
|
|
1686
|
+
const abortController = this.getOrCreateAbortController(runId);
|
|
1539
1687
|
const stepResult = await this.stepExecutor.execute({
|
|
1540
1688
|
workflowId,
|
|
1541
1689
|
step: step.step,
|
|
@@ -1549,7 +1697,9 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1549
1697
|
resumeData: resumeDataToUse,
|
|
1550
1698
|
retryCount,
|
|
1551
1699
|
foreachIdx: step.type === "foreach" ? executionPath[1] : void 0,
|
|
1552
|
-
validateInputs: workflow.options.validateInputs
|
|
1700
|
+
validateInputs: workflow.options.validateInputs,
|
|
1701
|
+
abortController,
|
|
1702
|
+
perStep
|
|
1553
1703
|
});
|
|
1554
1704
|
requestContext = Object.fromEntries(rc.entries());
|
|
1555
1705
|
if (stepResult.status === "bailed") {
|
|
@@ -1568,7 +1718,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1568
1718
|
},
|
|
1569
1719
|
prevResult: stepResult,
|
|
1570
1720
|
activeSteps,
|
|
1571
|
-
requestContext
|
|
1721
|
+
requestContext,
|
|
1722
|
+
perStep
|
|
1572
1723
|
});
|
|
1573
1724
|
return;
|
|
1574
1725
|
}
|
|
@@ -1646,7 +1797,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1646
1797
|
stepResults,
|
|
1647
1798
|
prevResult: stepResult,
|
|
1648
1799
|
activeSteps,
|
|
1649
|
-
requestContext
|
|
1800
|
+
requestContext,
|
|
1801
|
+
perStep
|
|
1650
1802
|
}
|
|
1651
1803
|
});
|
|
1652
1804
|
}
|
|
@@ -1663,7 +1815,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1663
1815
|
stepResults,
|
|
1664
1816
|
activeSteps,
|
|
1665
1817
|
parentContext,
|
|
1666
|
-
requestContext
|
|
1818
|
+
requestContext,
|
|
1819
|
+
perStep
|
|
1667
1820
|
}) {
|
|
1668
1821
|
let step = workflow.stepGraph[executionPath[0]];
|
|
1669
1822
|
if ((step?.type === "parallel" || step?.type === "conditional") && executionPath.length > 1) {
|
|
@@ -1681,7 +1834,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1681
1834
|
activeSteps,
|
|
1682
1835
|
requestContext
|
|
1683
1836
|
},
|
|
1684
|
-
new
|
|
1837
|
+
new chunk4U7ZLI36_cjs.MastraError({
|
|
1685
1838
|
id: "MASTRA_WORKFLOW",
|
|
1686
1839
|
text: `Step not found: ${JSON.stringify(executionPath)}`,
|
|
1687
1840
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -1689,8 +1842,9 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1689
1842
|
})
|
|
1690
1843
|
);
|
|
1691
1844
|
}
|
|
1845
|
+
const workflowsStore = await this.mastra.getStorage()?.getStore("workflows");
|
|
1692
1846
|
if (step.type === "foreach") {
|
|
1693
|
-
const snapshot = await
|
|
1847
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
1694
1848
|
workflowName: workflowId,
|
|
1695
1849
|
runId
|
|
1696
1850
|
});
|
|
@@ -1705,7 +1859,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1705
1859
|
newResult = { ...prevResult, output: [prevResult.output] };
|
|
1706
1860
|
}
|
|
1707
1861
|
}
|
|
1708
|
-
const newStepResults = await
|
|
1862
|
+
const newStepResults = await workflowsStore?.updateWorkflowResults({
|
|
1709
1863
|
workflowName: workflow.id,
|
|
1710
1864
|
runId,
|
|
1711
1865
|
stepId: step.step.id,
|
|
@@ -1724,7 +1878,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1724
1878
|
payload: parentContext.input?.output ?? {}
|
|
1725
1879
|
};
|
|
1726
1880
|
}
|
|
1727
|
-
const newStepResults = await
|
|
1881
|
+
const newStepResults = await workflowsStore?.updateWorkflowResults({
|
|
1728
1882
|
workflowName: workflow.id,
|
|
1729
1883
|
runId,
|
|
1730
1884
|
stepId: step.step.id,
|
|
@@ -1760,7 +1914,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1760
1914
|
if (suspendedStep) {
|
|
1761
1915
|
suspendedPaths[suspendedStep.id] = executionPath;
|
|
1762
1916
|
}
|
|
1763
|
-
await
|
|
1917
|
+
await workflowsStore?.updateWorkflowState({
|
|
1764
1918
|
workflowName: workflowId,
|
|
1765
1919
|
runId,
|
|
1766
1920
|
opts: {
|
|
@@ -1827,7 +1981,38 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1827
1981
|
}
|
|
1828
1982
|
}
|
|
1829
1983
|
step = workflow.stepGraph[executionPath[0]];
|
|
1830
|
-
if (
|
|
1984
|
+
if (perStep) {
|
|
1985
|
+
if (parentWorkflow && executionPath[0] < workflow.stepGraph.length - 1) {
|
|
1986
|
+
const { endedAt, output, status, ...nestedPrevResult } = prevResult;
|
|
1987
|
+
await this.endWorkflow({
|
|
1988
|
+
workflow,
|
|
1989
|
+
parentWorkflow,
|
|
1990
|
+
workflowId,
|
|
1991
|
+
runId,
|
|
1992
|
+
executionPath,
|
|
1993
|
+
resumeSteps,
|
|
1994
|
+
stepResults,
|
|
1995
|
+
prevResult: { ...nestedPrevResult, status: "paused" },
|
|
1996
|
+
activeSteps,
|
|
1997
|
+
requestContext,
|
|
1998
|
+
perStep
|
|
1999
|
+
});
|
|
2000
|
+
} else {
|
|
2001
|
+
await this.endWorkflow({
|
|
2002
|
+
workflow,
|
|
2003
|
+
parentWorkflow,
|
|
2004
|
+
workflowId,
|
|
2005
|
+
runId,
|
|
2006
|
+
executionPath,
|
|
2007
|
+
resumeSteps,
|
|
2008
|
+
stepResults,
|
|
2009
|
+
prevResult,
|
|
2010
|
+
activeSteps,
|
|
2011
|
+
requestContext,
|
|
2012
|
+
perStep
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
} else if ((step?.type === "parallel" || step?.type === "conditional") && executionPath.length > 1) {
|
|
1831
2016
|
let skippedCount = 0;
|
|
1832
2017
|
const allResults = step.steps.reduce(
|
|
1833
2018
|
(acc, step2) => {
|
|
@@ -1916,7 +2101,8 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1916
2101
|
workflowId,
|
|
1917
2102
|
runId
|
|
1918
2103
|
}) {
|
|
1919
|
-
const
|
|
2104
|
+
const workflowsStore = await this.mastra.getStorage()?.getStore("workflows");
|
|
2105
|
+
const snapshot = await workflowsStore?.loadWorkflowSnapshot({
|
|
1920
2106
|
workflowName: workflowId,
|
|
1921
2107
|
runId
|
|
1922
2108
|
});
|
|
@@ -1957,7 +2143,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1957
2143
|
if (!workflow) {
|
|
1958
2144
|
return this.errorWorkflow(
|
|
1959
2145
|
workflowData,
|
|
1960
|
-
new
|
|
2146
|
+
new chunk4U7ZLI36_cjs.MastraError({
|
|
1961
2147
|
id: "MASTRA_WORKFLOW",
|
|
1962
2148
|
text: `Workflow not found: ${workflowData.workflowId}`,
|
|
1963
2149
|
domain: "MASTRA_WORKFLOW" /* MASTRA_WORKFLOW */,
|
|
@@ -2038,7 +2224,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
2038
2224
|
|
|
2039
2225
|
// src/workflows/evented/workflow.ts
|
|
2040
2226
|
function cloneWorkflow(workflow, opts) {
|
|
2041
|
-
const wf = new
|
|
2227
|
+
const wf = new chunkDDK3URK2_cjs.Workflow({
|
|
2042
2228
|
id: opts.id,
|
|
2043
2229
|
inputSchema: workflow.inputSchema,
|
|
2044
2230
|
outputSchema: workflow.outputSchema,
|
|
@@ -2069,7 +2255,7 @@ function isAgent(params) {
|
|
|
2069
2255
|
return params?.component === "AGENT";
|
|
2070
2256
|
}
|
|
2071
2257
|
function isTool(params) {
|
|
2072
|
-
return params instanceof
|
|
2258
|
+
return params instanceof chunk6HJFCSJ4_cjs.Tool;
|
|
2073
2259
|
}
|
|
2074
2260
|
function createStep(params) {
|
|
2075
2261
|
if (isAgent(params)) {
|
|
@@ -2206,7 +2392,7 @@ function createWorkflow(params) {
|
|
|
2206
2392
|
executionEngine
|
|
2207
2393
|
});
|
|
2208
2394
|
}
|
|
2209
|
-
var EventedWorkflow = class extends
|
|
2395
|
+
var EventedWorkflow = class extends chunkDDK3URK2_cjs.Workflow {
|
|
2210
2396
|
constructor(params) {
|
|
2211
2397
|
super(params);
|
|
2212
2398
|
this.engineType = "evented";
|
|
@@ -2236,9 +2422,12 @@ var EventedWorkflow = class extends chunkR5AJGM55_cjs.Workflow {
|
|
|
2236
2422
|
workflowStatus: run.workflowRunStatus,
|
|
2237
2423
|
stepResults: {}
|
|
2238
2424
|
});
|
|
2239
|
-
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse,
|
|
2425
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, {
|
|
2426
|
+
withNestedWorkflows: false
|
|
2427
|
+
});
|
|
2240
2428
|
if (!workflowSnapshotInStorage && shouldPersistSnapshot) {
|
|
2241
|
-
await this.mastra?.getStorage()?.
|
|
2429
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
2430
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
2242
2431
|
workflowName: this.id,
|
|
2243
2432
|
runId: runIdToUse,
|
|
2244
2433
|
resourceId: options?.resourceId,
|
|
@@ -2263,15 +2452,35 @@ var EventedWorkflow = class extends chunkR5AJGM55_cjs.Workflow {
|
|
|
2263
2452
|
return run;
|
|
2264
2453
|
}
|
|
2265
2454
|
};
|
|
2266
|
-
var EventedRun = class extends
|
|
2455
|
+
var EventedRun = class extends chunkDDK3URK2_cjs.Run {
|
|
2267
2456
|
constructor(params) {
|
|
2268
2457
|
super(params);
|
|
2269
2458
|
this.serializedStepGraph = params.serializedStepGraph;
|
|
2270
2459
|
}
|
|
2460
|
+
/**
|
|
2461
|
+
* Set up abort signal handler to publish workflow.cancel event when abortController.abort() is called.
|
|
2462
|
+
* This ensures consistent cancellation behavior whether abort() is called directly or via cancel().
|
|
2463
|
+
*/
|
|
2464
|
+
setupAbortHandler() {
|
|
2465
|
+
const abortHandler = () => {
|
|
2466
|
+
this.mastra?.pubsub.publish("workflows", {
|
|
2467
|
+
type: "workflow.cancel",
|
|
2468
|
+
runId: this.runId,
|
|
2469
|
+
data: {
|
|
2470
|
+
workflowId: this.workflowId,
|
|
2471
|
+
runId: this.runId
|
|
2472
|
+
}
|
|
2473
|
+
}).catch((err) => {
|
|
2474
|
+
console.error(`Failed to publish workflow.cancel for runId ${this.runId}:`, err);
|
|
2475
|
+
});
|
|
2476
|
+
};
|
|
2477
|
+
this.abortController.signal.addEventListener("abort", abortHandler, { once: true });
|
|
2478
|
+
}
|
|
2271
2479
|
async start({
|
|
2272
2480
|
inputData,
|
|
2273
2481
|
initialState,
|
|
2274
|
-
requestContext
|
|
2482
|
+
requestContext,
|
|
2483
|
+
perStep
|
|
2275
2484
|
}) {
|
|
2276
2485
|
if (this.serializedStepGraph.length === 0) {
|
|
2277
2486
|
throw new Error(
|
|
@@ -2282,7 +2491,8 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2282
2491
|
throw new Error("Uncommitted step flow changes detected. Call .commit() to register the steps.");
|
|
2283
2492
|
}
|
|
2284
2493
|
requestContext = requestContext ?? new chunkUVHSM2GU_cjs.RequestContext();
|
|
2285
|
-
await this.mastra?.getStorage()?.
|
|
2494
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
2495
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
2286
2496
|
workflowName: this.workflowId,
|
|
2287
2497
|
runId: this.runId,
|
|
2288
2498
|
resourceId: this.resourceId,
|
|
@@ -2306,6 +2516,7 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2306
2516
|
if (!this.mastra?.pubsub) {
|
|
2307
2517
|
throw new Error("Mastra instance with pubsub is required for workflow execution");
|
|
2308
2518
|
}
|
|
2519
|
+
this.setupAbortHandler();
|
|
2309
2520
|
const result = await this.executionEngine.execute({
|
|
2310
2521
|
workflowId: this.workflowId,
|
|
2311
2522
|
runId: this.runId,
|
|
@@ -2316,7 +2527,8 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2316
2527
|
pubsub: this.mastra.pubsub,
|
|
2317
2528
|
retryConfig: this.retryConfig,
|
|
2318
2529
|
requestContext,
|
|
2319
|
-
abortController: this.abortController
|
|
2530
|
+
abortController: this.abortController,
|
|
2531
|
+
perStep
|
|
2320
2532
|
});
|
|
2321
2533
|
if (result.status !== "suspended") {
|
|
2322
2534
|
this.cleanup?.();
|
|
@@ -2331,7 +2543,8 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2331
2543
|
async startAsync({
|
|
2332
2544
|
inputData,
|
|
2333
2545
|
initialState,
|
|
2334
|
-
requestContext
|
|
2546
|
+
requestContext,
|
|
2547
|
+
perStep
|
|
2335
2548
|
}) {
|
|
2336
2549
|
if (this.serializedStepGraph.length === 0) {
|
|
2337
2550
|
throw new Error(
|
|
@@ -2342,7 +2555,8 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2342
2555
|
throw new Error("Uncommitted step flow changes detected. Call .commit() to register the steps.");
|
|
2343
2556
|
}
|
|
2344
2557
|
requestContext = requestContext ?? new chunkUVHSM2GU_cjs.RequestContext();
|
|
2345
|
-
await this.mastra?.getStorage()?.
|
|
2558
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
2559
|
+
await workflowsStore?.persistWorkflowSnapshot({
|
|
2346
2560
|
workflowName: this.workflowId,
|
|
2347
2561
|
runId: this.runId,
|
|
2348
2562
|
resourceId: this.resourceId,
|
|
@@ -2374,7 +2588,8 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2374
2588
|
runId: this.runId,
|
|
2375
2589
|
prevResult: { status: "success", output: inputDataToUse },
|
|
2376
2590
|
requestContext: Object.fromEntries(requestContext.entries()),
|
|
2377
|
-
initialState: initialStateToUse
|
|
2591
|
+
initialState: initialStateToUse,
|
|
2592
|
+
perStep
|
|
2378
2593
|
}
|
|
2379
2594
|
});
|
|
2380
2595
|
return { runId: this.runId };
|
|
@@ -2392,21 +2607,28 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2392
2607
|
if (steps.length === 0) {
|
|
2393
2608
|
throw new Error("No steps provided to resume");
|
|
2394
2609
|
}
|
|
2395
|
-
const
|
|
2610
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
2611
|
+
if (!workflowsStore) {
|
|
2612
|
+
throw new Error("Cannot resume workflow: workflows store is required");
|
|
2613
|
+
}
|
|
2614
|
+
const snapshot = await workflowsStore.loadWorkflowSnapshot({
|
|
2396
2615
|
workflowName: this.workflowId,
|
|
2397
2616
|
runId: this.runId
|
|
2398
2617
|
});
|
|
2399
|
-
|
|
2618
|
+
if (!snapshot) {
|
|
2619
|
+
throw new Error(`Cannot resume workflow: no snapshot found for runId ${this.runId}`);
|
|
2620
|
+
}
|
|
2621
|
+
const resumePath = snapshot.suspendedPaths?.[steps[0]];
|
|
2400
2622
|
if (!resumePath) {
|
|
2401
2623
|
throw new Error(
|
|
2402
|
-
`No resume path found for step ${JSON.stringify(steps)}, currently suspended paths are ${JSON.stringify(snapshot
|
|
2624
|
+
`No resume path found for step ${JSON.stringify(steps)}, currently suspended paths are ${JSON.stringify(snapshot.suspendedPaths)}`
|
|
2403
2625
|
);
|
|
2404
2626
|
}
|
|
2405
2627
|
console.dir(
|
|
2406
|
-
{ resume: { requestContextObj: snapshot
|
|
2628
|
+
{ resume: { requestContextObj: snapshot.requestContext, requestContext: params.requestContext } },
|
|
2407
2629
|
{ depth: null }
|
|
2408
2630
|
);
|
|
2409
|
-
const requestContextObj = snapshot
|
|
2631
|
+
const requestContextObj = snapshot.requestContext ?? {};
|
|
2410
2632
|
const requestContext = new chunkUVHSM2GU_cjs.RequestContext();
|
|
2411
2633
|
for (const [key, value] of Object.entries(requestContextObj)) {
|
|
2412
2634
|
requestContext.set(key, value);
|
|
@@ -2421,6 +2643,7 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2421
2643
|
if (!this.mastra?.pubsub) {
|
|
2422
2644
|
throw new Error("Mastra instance with pubsub is required for workflow execution");
|
|
2423
2645
|
}
|
|
2646
|
+
this.setupAbortHandler();
|
|
2424
2647
|
const executionResultPromise = this.executionEngine.execute({
|
|
2425
2648
|
workflowId: this.workflowId,
|
|
2426
2649
|
runId: this.runId,
|
|
@@ -2435,7 +2658,8 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2435
2658
|
},
|
|
2436
2659
|
pubsub: this.mastra.pubsub,
|
|
2437
2660
|
requestContext,
|
|
2438
|
-
abortController: this.abortController
|
|
2661
|
+
abortController: this.abortController,
|
|
2662
|
+
perStep: params.perStep
|
|
2439
2663
|
}).then((result) => {
|
|
2440
2664
|
if (result.status !== "suspended") {
|
|
2441
2665
|
this.closeStreamAction?.().catch(() => {
|
|
@@ -2477,21 +2701,15 @@ var EventedRun = class extends chunkR5AJGM55_cjs.Run {
|
|
|
2477
2701
|
};
|
|
2478
2702
|
}
|
|
2479
2703
|
async cancel() {
|
|
2480
|
-
await this.mastra?.getStorage()?.
|
|
2704
|
+
const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
|
|
2705
|
+
await workflowsStore?.updateWorkflowState({
|
|
2481
2706
|
workflowName: this.workflowId,
|
|
2482
2707
|
runId: this.runId,
|
|
2483
2708
|
opts: {
|
|
2484
2709
|
status: "canceled"
|
|
2485
2710
|
}
|
|
2486
2711
|
});
|
|
2487
|
-
|
|
2488
|
-
type: "workflow.cancel",
|
|
2489
|
-
runId: this.runId,
|
|
2490
|
-
data: {
|
|
2491
|
-
workflowId: this.workflowId,
|
|
2492
|
-
runId: this.runId
|
|
2493
|
-
}
|
|
2494
|
-
});
|
|
2712
|
+
this.abortController.abort();
|
|
2495
2713
|
}
|
|
2496
2714
|
};
|
|
2497
2715
|
|
|
@@ -2539,7 +2757,7 @@ function isExecutableStep(step) {
|
|
|
2539
2757
|
}
|
|
2540
2758
|
|
|
2541
2759
|
// src/workflows/evented/execution-engine.ts
|
|
2542
|
-
var EventedExecutionEngine = class extends
|
|
2760
|
+
var EventedExecutionEngine = class extends chunkDDK3URK2_cjs.ExecutionEngine {
|
|
2543
2761
|
eventProcessor;
|
|
2544
2762
|
constructor({
|
|
2545
2763
|
mastra,
|
|
@@ -2579,7 +2797,8 @@ var EventedExecutionEngine = class extends chunkR5AJGM55_cjs.ExecutionEngine {
|
|
|
2579
2797
|
prevResult: { status: "success", output: prevResult?.payload },
|
|
2580
2798
|
resumeData: params.resume.resumePayload,
|
|
2581
2799
|
requestContext: Object.fromEntries(params.requestContext.entries()),
|
|
2582
|
-
format: params.format
|
|
2800
|
+
format: params.format,
|
|
2801
|
+
perStep: params.perStep
|
|
2583
2802
|
}
|
|
2584
2803
|
});
|
|
2585
2804
|
} else if (params.timeTravel) {
|
|
@@ -2596,7 +2815,8 @@ var EventedExecutionEngine = class extends chunkR5AJGM55_cjs.ExecutionEngine {
|
|
|
2596
2815
|
timeTravel: params.timeTravel,
|
|
2597
2816
|
prevResult: { status: "success", output: prevResult?.payload },
|
|
2598
2817
|
requestContext: Object.fromEntries(params.requestContext.entries()),
|
|
2599
|
-
format: params.format
|
|
2818
|
+
format: params.format,
|
|
2819
|
+
perStep: params.perStep
|
|
2600
2820
|
}
|
|
2601
2821
|
});
|
|
2602
2822
|
} else {
|
|
@@ -2608,7 +2828,8 @@ var EventedExecutionEngine = class extends chunkR5AJGM55_cjs.ExecutionEngine {
|
|
|
2608
2828
|
runId: params.runId,
|
|
2609
2829
|
prevResult: { status: "success", output: params.input },
|
|
2610
2830
|
requestContext: Object.fromEntries(params.requestContext.entries()),
|
|
2611
|
-
format: params.format
|
|
2831
|
+
format: params.format,
|
|
2832
|
+
perStep: params.perStep
|
|
2612
2833
|
}
|
|
2613
2834
|
});
|
|
2614
2835
|
}
|
|
@@ -2622,7 +2843,7 @@ var EventedExecutionEngine = class extends chunkR5AJGM55_cjs.ExecutionEngine {
|
|
|
2622
2843
|
await ack?.();
|
|
2623
2844
|
await pubsub.unsubscribe("workflows-finish", finishCb);
|
|
2624
2845
|
if (event.type === "workflow.fail" && event.data.stepResults) {
|
|
2625
|
-
event.data.stepResults =
|
|
2846
|
+
event.data.stepResults = chunkDDK3URK2_cjs.hydrateSerializedStepErrors(event.data.stepResults);
|
|
2626
2847
|
}
|
|
2627
2848
|
resolve(event.data);
|
|
2628
2849
|
return;
|
|
@@ -2646,6 +2867,11 @@ var EventedExecutionEngine = class extends chunkR5AJGM55_cjs.ExecutionEngine {
|
|
|
2646
2867
|
status: "suspended",
|
|
2647
2868
|
steps: resultData.stepResults
|
|
2648
2869
|
};
|
|
2870
|
+
} else if (resultData.prevResult.status === "paused" || params.perStep) {
|
|
2871
|
+
callbackArg = {
|
|
2872
|
+
status: "paused",
|
|
2873
|
+
steps: resultData.stepResults
|
|
2874
|
+
};
|
|
2649
2875
|
} else {
|
|
2650
2876
|
callbackArg = {
|
|
2651
2877
|
status: resultData.prevResult.status,
|
|
@@ -2653,7 +2879,9 @@ var EventedExecutionEngine = class extends chunkR5AJGM55_cjs.ExecutionEngine {
|
|
|
2653
2879
|
steps: resultData.stepResults
|
|
2654
2880
|
};
|
|
2655
2881
|
}
|
|
2656
|
-
|
|
2882
|
+
if (callbackArg.status !== "paused") {
|
|
2883
|
+
await this.invokeLifecycleCallbacks(callbackArg);
|
|
2884
|
+
}
|
|
2657
2885
|
let result;
|
|
2658
2886
|
if (resultData.prevResult.status === "suspended") {
|
|
2659
2887
|
const suspendedSteps = Object.entries(resultData.stepResults).map(([_stepId, stepResult]) => {
|
|
@@ -2682,5 +2910,5 @@ exports.cloneStep = cloneStep;
|
|
|
2682
2910
|
exports.cloneWorkflow = cloneWorkflow;
|
|
2683
2911
|
exports.createStep = createStep;
|
|
2684
2912
|
exports.createWorkflow = createWorkflow;
|
|
2685
|
-
//# sourceMappingURL=chunk-
|
|
2686
|
-
//# sourceMappingURL=chunk-
|
|
2913
|
+
//# sourceMappingURL=chunk-RA2CHJCY.cjs.map
|
|
2914
|
+
//# sourceMappingURL=chunk-RA2CHJCY.cjs.map
|