@mastra/core 1.86.0-alpha.9 → 1.87.0-alpha.0
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/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/voice/aisdk/speech.d.ts +1 -1
- package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/voice/aisdk/transcription.d.ts +1 -1
- package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/voice/composite-voice.d.ts +1 -1
- package/dist/agent/agent-legacy.d.ts +1 -1
- package/dist/agent/agent.d.ts +3 -3
- package/dist/agent/agent.types.d.ts +1 -1
- package/dist/agent/durable/constants.d.ts +2 -0
- package/dist/agent/durable/durable-agent.d.ts +3 -3
- package/dist/agent/durable/evented-execution.d.ts +7 -0
- package/dist/agent/durable/execution-engine.d.ts +1 -0
- package/dist/agent/durable/execution-fence.d.ts +2 -0
- package/dist/agent/durable/index.cjs +3 -1
- package/dist/agent/durable/index.d.ts +1 -1
- package/dist/agent/durable/index.js +2 -2
- package/dist/agent/durable/run-registry.d.ts +2 -0
- package/dist/agent/durable/segment-spans.d.ts +54 -1
- package/dist/agent/durable/stream-adapter.d.ts +1 -1
- package/dist/agent/durable/types.d.ts +12 -2
- package/dist/agent/durable/workflows/durable-loop-builder.d.ts +57 -2
- package/dist/agent/durable/workflows/finalize-run.d.ts +2 -0
- package/dist/agent/durable/workflows/shared/index.d.ts +1 -1
- package/dist/agent/durable/workflows/shared/reported-cost.d.ts +7 -0
- package/dist/agent/durable/workflows/shared/schemas.d.ts +16 -1
- package/dist/agent/durable/workflows/shared/tool-call-concurrency.d.ts +6 -0
- package/dist/agent/durable/workflows/steps/llm-execution.d.ts +5 -0
- package/dist/agent/durable/workflows/steps/llm-mapping.d.ts +6 -0
- package/dist/agent/durable/workflows/steps/tool-call.d.ts +20 -0
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/adapters/AIV4Adapter.d.ts +1 -1
- package/dist/agent/message-list/adapters/types.d.ts +1 -1
- package/dist/agent/message-list/cache/CacheKeyGenerator.d.ts +1 -1
- package/dist/agent/message-list/conversion/output-converter.d.ts +1 -1
- package/dist/agent/message-list/conversion/to-prompt.d.ts +1 -1
- package/dist/agent/message-list/conversion/utils.d.ts +1 -1
- package/dist/agent/message-list/detection/TypeDetector.d.ts +1 -1
- package/dist/agent/message-list/message-list.d.ts +2 -2
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts +1 -1
- package/dist/agent/message-list/prompt/convert-file.d.ts +1 -1
- package/dist/agent/message-list/prompt/data-content.d.ts +1 -1
- package/dist/agent/message-list/state/MessageStateManager.d.ts +1 -1
- package/dist/agent/message-list/state/types.d.ts +2 -2
- package/dist/agent/message-list/types.d.ts +9 -9
- package/dist/agent/message-list/utils/convert-messages.d.ts +3 -3
- package/dist/agent/message-list/utils/provider-compat.d.ts +1 -1
- package/dist/agent/request-context-snapshot.d.ts +3 -2
- package/dist/agent/signals.d.ts +1 -1
- package/dist/agent/streams/run-records.d.ts +9 -1
- package/dist/agent/types.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/run-scope-keys.d.ts +1 -1
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +1 -1
- package/dist/agent-controller/index.js +1 -1
- package/dist/agent-controller/session-run-engine.d.ts +5 -2
- package/dist/agent-controller/session.d.ts +2 -0
- package/dist/agent-controller/types.d.ts +23 -0
- package/dist/{agent-controller-SSlKzE6A.js → agent-controller-B8LoFdtu.js} +43 -13
- package/dist/{agent-controller-CrQ9OF80.cjs → agent-controller-DSnFynpa.cjs} +43 -13
- package/dist/auth/defaults/index.d.ts +2 -2
- package/dist/auth/defaults/session/cookie.d.ts +2 -2
- package/dist/auth/defaults/session/index.d.ts +2 -2
- package/dist/auth/defaults/session/memory.d.ts +2 -2
- package/dist/auth/ee/capabilities.d.ts +1 -1
- package/dist/auth/ee/defaults/index.d.ts +1 -1
- package/dist/auth/ee/defaults/rbac/index.d.ts +1 -1
- package/dist/auth/ee/defaults/rbac/static.d.ts +1 -1
- package/dist/auth/ee/defaults/roles.d.ts +1 -1
- package/dist/auth/ee/fga-check.d.ts +1 -1
- package/dist/auth/ee/index.d.ts +1 -1
- package/dist/auth/ee/interfaces/acl.d.ts +1 -1
- package/dist/auth/ee/interfaces/fga.d.ts +1 -1
- package/dist/auth/ee/interfaces/index.d.ts +1 -1
- package/dist/auth/ee/interfaces/permissions.generated.d.ts +1 -1
- package/dist/auth/ee/interfaces/rbac.d.ts +1 -1
- package/dist/auth/ee/interfaces/user.d.ts +1 -1
- package/dist/auth/ee/license.d.ts +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/interfaces/credentials.d.ts +1 -1
- package/dist/auth/interfaces/index.d.ts +2 -2
- package/dist/auth/interfaces/session.d.ts +1 -1
- package/dist/auth/interfaces/sso.d.ts +1 -1
- package/dist/auth/interfaces/user.d.ts +1 -1
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/background-tasks/manager.d.ts +4 -1
- package/dist/{background-tasks-BDrYBis-.cjs → background-tasks-Ci5h0dhj.cjs} +139 -51
- package/dist/{background-tasks-BnJfNLFo.js → background-tasks-IW7M4iD2.js} +139 -51
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/{builder-Cw8u3pPl.cjs → builder-14Uptu8y.cjs} +2 -2
- package/dist/{builder-Cl-0BWkh.js → builder-DI2c2xjy.js} +2 -2
- package/dist/bundler/index.d.ts +2 -2
- package/dist/cache/base.d.ts +40 -10
- package/dist/cache/index.cjs +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/capabilities/302ai.json +196 -196
- package/dist/capabilities/abliteratedllm.json +36 -36
- package/dist/capabilities/abliteration-ai.json +11 -11
- package/dist/capabilities/above.json +22 -22
- package/dist/capabilities/adaption.json +13 -13
- package/dist/capabilities/adzuki.json +28 -28
- package/dist/capabilities/agentrouter.json +9 -9
- package/dist/capabilities/agnes.json +4 -4
- package/dist/capabilities/ai-router.json +5 -5
- package/dist/capabilities/aiand.json +16 -16
- package/dist/capabilities/aigrow.json +14 -14
- package/dist/capabilities/aimlapi.json +146 -150
- package/dist/capabilities/aipg.json +2 -2
- package/dist/capabilities/aixy.json +9 -9
- package/dist/capabilities/aki-io.json +10 -10
- package/dist/capabilities/alibaba-cn.json +97 -97
- package/dist/capabilities/alibaba-coding-plan-cn.json +5 -5
- package/dist/capabilities/alibaba-coding-plan.json +5 -5
- package/dist/capabilities/alibaba-token-plan-cn.json +51 -51
- package/dist/capabilities/alibaba-token-plan.json +52 -52
- package/dist/capabilities/alibaba.json +69 -69
- package/dist/capabilities/ambient.json +15 -15
- package/dist/capabilities/amd.json +8 -8
- package/dist/capabilities/anthropic.json +49 -49
- package/dist/capabilities/anyapi.json +19 -19
- package/dist/capabilities/arcee.json +9 -9
- package/dist/capabilities/augure.json +4 -4
- package/dist/capabilities/auriko.json +21 -21
- package/dist/capabilities/bailing.json +4 -4
- package/dist/capabilities/baseten.json +28 -28
- package/dist/capabilities/bee.json +5 -5
- package/dist/capabilities/berget.json +4 -4
- package/dist/capabilities/bothub.json +14 -14
- package/dist/capabilities/boundless.json +39 -39
- package/dist/capabilities/bumo.json +42 -42
- package/dist/capabilities/byteplus.json +24 -24
- package/dist/capabilities/cheapaimodel.json +10 -10
- package/dist/capabilities/cheapest-token.json +29 -29
- package/dist/capabilities/chutes.json +10 -13
- package/dist/capabilities/cline-pass.json +37 -37
- package/dist/capabilities/cloudcode.json +10 -10
- package/dist/capabilities/cloudflare-workers-ai.json +12 -73
- package/dist/capabilities/commandcode.json +131 -131
- package/dist/capabilities/concentrate.json +272 -263
- package/dist/capabilities/cortecs.json +113 -113
- package/dist/capabilities/crossmodel.json +169 -169
- package/dist/capabilities/crusoe.json +10 -10
- package/dist/capabilities/daoxe.json +9 -9
- package/dist/capabilities/databricks.json +128 -128
- package/dist/capabilities/deepinfra.json +130 -67
- package/dist/capabilities/deepseek.json +4 -4
- package/dist/capabilities/digitalocean.json +112 -112
- package/dist/capabilities/dothoosh.json +29 -29
- package/dist/capabilities/doubleword.json +29 -29
- package/dist/capabilities/edenai.json +446 -453
- package/dist/capabilities/empiriolabs.json +164 -166
- package/dist/capabilities/engy.json +22 -22
- package/dist/capabilities/entrim.json +4 -4
- package/dist/capabilities/evroc.json +14 -14
- package/dist/capabilities/ezkielyna.json +10 -10
- package/dist/capabilities/fastrouter.json +79 -79
- package/dist/capabilities/fireworks-ai.json +92 -71
- package/dist/capabilities/freemodel.json +21 -21
- package/dist/capabilities/friendli.json +10 -10
- package/dist/capabilities/frogbot.json +87 -87
- package/dist/capabilities/gisoo.json +19 -19
- package/dist/capabilities/gmicloud.json +21 -21
- package/dist/capabilities/google.json +52 -52
- package/dist/capabilities/graphn.json +11 -11
- package/dist/capabilities/greenpt.json +35 -35
- package/dist/capabilities/groq.json +3 -3
- package/dist/capabilities/helicone.json +78 -78
- package/dist/capabilities/hostinger-router.json +13 -13
- package/dist/capabilities/hpc-ai.json +10 -10
- package/dist/capabilities/huawei-maas.json +17 -17
- package/dist/capabilities/hubris.json +25 -25
- package/dist/capabilities/huggingface.json +94 -84
- package/dist/capabilities/hyper.json +29 -29
- package/dist/capabilities/impossibl.json +148 -148
- package/dist/capabilities/inception.json +3 -3
- package/dist/capabilities/inceptron.json +6 -6
- package/dist/capabilities/inco.json +4 -4
- package/dist/capabilities/infer.json +10 -10
- package/dist/capabilities/inferall.json +5 -5
- package/dist/capabilities/inference-coop.json +15 -15
- package/dist/capabilities/inferenceapis.json +17 -17
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +12 -12
- package/dist/capabilities/infomaniak.json +2 -2
- package/dist/capabilities/io-net.json +2 -2
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +58 -58
- package/dist/capabilities/jad-ai.json +2 -2
- package/dist/capabilities/jalapeno.json +11 -11
- package/dist/capabilities/jiekou.json +62 -62
- package/dist/capabilities/jzstoken.json +47 -47
- package/dist/capabilities/keln.json +21 -21
- package/dist/capabilities/kenari.json +123 -123
- package/dist/capabilities/kilo.json +631 -621
- package/dist/capabilities/kimi-code-plan-cn.json +6 -6
- package/dist/capabilities/kimi-code-plan-global.json +6 -6
- package/dist/capabilities/kitani.json +4 -4
- package/dist/capabilities/klavo.json +21 -21
- package/dist/capabilities/korouter.json +33 -33
- package/dist/capabilities/kunavo.json +5 -5
- package/dist/capabilities/liquid.json +12 -12
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +903 -894
- package/dist/capabilities/llmgateway.json +344 -336
- package/dist/capabilities/llmtr.json +23 -23
- package/dist/capabilities/logits.json +2 -2
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +46 -46
- package/dist/capabilities/lyceum.json +14 -14
- package/dist/capabilities/melious.json +15 -15
- package/dist/capabilities/merge-gateway.json +292 -292
- package/dist/capabilities/meta.json +11 -11
- package/dist/capabilities/minimax-cn-coding-plan.json +2 -2
- package/dist/capabilities/minimax-cn.json +5 -5
- package/dist/capabilities/minimax-coding-plan.json +2 -2
- package/dist/capabilities/minimax.json +5 -5
- package/dist/capabilities/mistral.json +21 -21
- package/dist/capabilities/mixlayer.json +4 -4
- package/dist/capabilities/modal.json +14 -14
- package/dist/capabilities/model-oracle-ai.json +23 -23
- package/dist/capabilities/modelis.json +22 -22
- package/dist/capabilities/modelscope.json +2 -2
- package/dist/capabilities/modular.json +7 -7
- package/dist/capabilities/moneo.json +11 -11
- package/dist/capabilities/moonshotai-cn.json +6 -6
- package/dist/capabilities/moonshotai.json +6 -6
- package/dist/capabilities/morph.json +13 -13
- package/dist/capabilities/munito.json +2 -2
- package/dist/capabilities/nan.json +28 -28
- package/dist/capabilities/nano-gpt.json +599 -564
- package/dist/capabilities/nearai.json +96 -96
- package/dist/capabilities/nebius.json +32 -32
- package/dist/capabilities/neon.json +120 -120
- package/dist/capabilities/neuralwatt.json +37 -37
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +154 -154
- package/dist/capabilities/nvidia.json +28 -60
- package/dist/capabilities/oathbreaker.json +2 -2
- package/dist/capabilities/obscurify.json +20 -20
- package/dist/capabilities/oci.json +17 -8
- package/dist/capabilities/ofox.json +317 -317
- package/dist/capabilities/ollama-cloud.json +56 -56
- package/dist/capabilities/openai.json +78 -46
- package/dist/capabilities/opencode-go.json +86 -86
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +535 -519
- package/dist/capabilities/opper.json +27 -27
- package/dist/capabilities/orcarouter.json +217 -217
- package/dist/capabilities/outerlabs.json +31 -31
- package/dist/capabilities/ovhcloud.json +58 -4
- package/dist/capabilities/pareto.json +5 -5
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +62 -62
- package/dist/capabilities/phala.json +36 -36
- package/dist/capabilities/pioneer.json +27 -27
- package/dist/capabilities/poe.json +110 -110
- package/dist/capabilities/poolside.json +3 -3
- package/dist/capabilities/powerspring.json +11 -11
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +127 -111
- package/dist/capabilities/privatemode-ai.json +11 -11
- package/dist/capabilities/proxystacks.json +7 -7
- package/dist/capabilities/qiniu-ai.json +15 -15
- package/dist/capabilities/refuseless.json +9 -9
- package/dist/capabilities/regolo-ai.json +6 -6
- package/dist/capabilities/requesty.json +170 -170
- package/dist/capabilities/ruapi.json +20 -20
- package/dist/capabilities/runcrate.json +10 -10
- package/dist/capabilities/runinfra.json +16 -16
- package/dist/capabilities/sakana.json +6 -6
- package/dist/capabilities/sambanova.json +6 -6
- package/dist/capabilities/sandbase.json +11 -11
- package/dist/capabilities/sarvam.json +10 -10
- package/dist/capabilities/scaleway.json +14 -14
- package/dist/capabilities/scnet-token-plan.json +14 -14
- package/dist/capabilities/scx-ai.json +26 -26
- package/dist/capabilities/sensenova.json +12 -12
- package/dist/capabilities/siliconflow-cn.json +50 -50
- package/dist/capabilities/siliconflow.json +55 -55
- package/dist/capabilities/snowflake-cortex.json +19 -19
- package/dist/capabilities/sokkan.json +7 -7
- package/dist/capabilities/sparrowcodes.json +17 -17
- package/dist/capabilities/standardcompute.json +98 -98
- package/dist/capabilities/steadyrouter.json +38 -38
- package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
- package/dist/capabilities/stepfun-ai.json +5 -5
- package/dist/capabilities/stepfun-step-plan.json +5 -5
- package/dist/capabilities/stepfun.json +5 -5
- package/dist/capabilities/stepping-stone.json +17 -17
- package/dist/capabilities/subconscious.json +2 -2
- package/dist/capabilities/superbot-gg.json +4 -4
- package/dist/capabilities/synthetic.json +12 -12
- package/dist/capabilities/synthorai.json +22 -22
- package/dist/capabilities/teamorouter.json +24 -24
- package/dist/capabilities/teapot-router.json +12 -12
- package/dist/capabilities/tencent-token-plan.json +59 -35
- package/dist/capabilities/tencent-tokenhub.json +46 -46
- package/dist/capabilities/tensorx.json +47 -47
- package/dist/capabilities/tenstorrent.json +8 -8
- package/dist/capabilities/the-grid-ai.json +29 -29
- package/dist/capabilities/thinkingmachines.json +61 -61
- package/dist/capabilities/tinfoil.json +12 -12
- package/dist/capabilities/togetherai.json +62 -52
- package/dist/capabilities/tokengo.json +14 -14
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/trustedrouter.json +7 -7
- package/dist/capabilities/trustedtokens.json +15 -15
- package/dist/capabilities/umans-ai-coding-plan.json +16 -16
- package/dist/capabilities/umans-ai.json +13 -13
- package/dist/capabilities/uncensuredai.json +4 -4
- package/dist/capabilities/unrestricted.json +8 -8
- package/dist/capabilities/uplinkswitch.json +21 -21
- package/dist/capabilities/upstage.json +4 -4
- package/dist/capabilities/vancine.json +24 -24
- package/dist/capabilities/vercel.json +582 -582
- package/dist/capabilities/vivgrid.json +86 -86
- package/dist/capabilities/volcengine-coding-plan.json +23 -23
- package/dist/capabilities/volcengine.json +24 -24
- package/dist/capabilities/vultr.json +26 -26
- package/dist/capabilities/wafer.ai.json +16 -16
- package/dist/capabilities/wallaby.json +4 -4
- package/dist/capabilities/wally.json +11 -11
- package/dist/capabilities/wandb.json +21 -21
- package/dist/capabilities/watt.json +24 -24
- package/dist/capabilities/xai.json +6 -6
- package/dist/capabilities/xiaomi.json +2 -2
- package/dist/capabilities/xpersona.json +13 -13
- package/dist/capabilities/xxapi.json +28 -28
- package/dist/capabilities/zai-coding-plan.json +19 -19
- package/dist/capabilities/zai.json +26 -24
- package/dist/capabilities/zenifra.json +27 -27
- package/dist/capabilities/zenmux.json +172 -172
- package/dist/capabilities/zerogpu.json +8 -8
- package/dist/capabilities/zhipuai-coding-plan.json +7 -7
- package/dist/capabilities/zhipuai.json +23 -23
- package/dist/capabilities/zro.json +7 -7
- package/dist/channels/agent-channels.d.ts +2 -1
- package/dist/channels/formatting.d.ts +8 -0
- package/dist/channels/index.cjs +4 -2
- package/dist/channels/index.d.ts +1 -1
- package/dist/channels/index.js +3 -3
- package/dist/channels/types.d.ts +5 -3
- package/dist/{channels-Cz1y3W6u.js → channels-Wh32drgu.js} +1 -1
- package/dist/{channels-DQg4v_gm.cjs → channels-tVV_de9Q.cjs} +1 -1
- package/dist/coding-agent/index.cjs +1 -1
- package/dist/coding-agent/index.js +1 -1
- package/dist/datasets/index.cjs +2 -2
- package/dist/datasets/index.js +2 -2
- package/dist/deployer/index.d.ts +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +798 -798
- package/dist/docs/references/docs-agents-resumable-streams.md +15 -6
- package/dist/docs/references/docs-deployment-workers.md +3 -1
- package/dist/docs/references/docs-harness-background-tasks.md +4 -4
- package/dist/docs/references/docs-harness-durable-agents.md +39 -48
- package/dist/docs/references/docs-knowledge-importers.md +1 -1
- package/dist/docs/references/docs-mastra-platform-observability-overview.md +1 -1
- package/dist/docs/references/docs-sandbox-overview.md +1 -0
- package/dist/docs/references/docs-server-pubsub.md +1 -1
- package/dist/docs/references/docs-workflows-overview.md +67 -3
- package/dist/docs/references/integrations-agentic-ui-assistant-ui.md +2 -0
- package/dist/docs/references/integrations-frameworks-angular.md +39 -0
- package/dist/docs/references/integrations-frameworks-astro.md +5 -2
- package/dist/docs/references/integrations-frameworks-electron.md +40 -0
- package/dist/docs/references/integrations-frameworks-next-js.md +5 -2
- package/dist/docs/references/integrations-frameworks-nuxt.md +5 -2
- package/dist/docs/references/integrations-frameworks-sveltekit.md +5 -2
- package/dist/docs/references/integrations-frameworks-vite-react.md +40 -0
- package/dist/docs/references/integrations.md +3 -0
- package/dist/docs/references/reference-agent-controller-agent-controller-class.md +6 -0
- package/dist/docs/references/reference-agents-channels.md +1 -1
- package/dist/docs/references/reference-agents-durable-agent.md +3 -3
- package/dist/docs/references/reference-agents-generate.md +2 -0
- package/dist/docs/references/reference-configuration.md +1 -1
- package/dist/docs/references/reference-core-mastra-class.md +2 -0
- package/dist/docs/references/reference-knowledge-knowledge-class.md +1 -1
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +11 -5
- package/dist/docs/references/reference-pubsub-caching-pubsub.md +2 -2
- package/dist/docs/references/reference-pubsub-redis-streams.md +2 -2
- package/dist/docs/references/reference-pubsub-valkey-streams.md +2 -2
- package/dist/docs/references/reference-workers-overview.md +2 -0
- package/dist/docs/references/reference-workflows-workflow-methods-create-run.md +2 -0
- package/dist/docs/references/reference-workflows-workflow.md +2 -0
- package/dist/docs/references/reference.md +1 -0
- package/dist/error/index.cjs +2 -1
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +2 -2
- package/dist/error/provider-error.d.ts +2 -1
- package/dist/{error-BLwEXqOK.js → error-BC9Au-22.js} +13 -1
- package/dist/{error-BdEvO8za.cjs → error-L1V4uUbd.cjs} +18 -0
- package/dist/evals/index.cjs +1 -1
- package/dist/evals/index.js +1 -1
- package/dist/evals/run/index.d.ts +1 -1
- package/dist/evals/scoreTraces/index.cjs +1 -1
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/evals/types.d.ts +1 -1
- package/dist/events/caching-pubsub.d.ts +28 -0
- package/dist/events/index.cjs +4 -1
- package/dist/events/index.js +2 -2
- package/dist/events/topics.d.ts +55 -9
- package/dist/harness/index.cjs +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{inmemory-BDD0w8gx.js → inmemory-BK3zLwvM.js} +42 -12
- package/dist/{inmemory-fgR8sq-U.cjs → inmemory-Dc86VWGB.cjs} +42 -12
- package/dist/knowledge/changes.d.ts +17 -5
- package/dist/knowledge/importers/runner.d.ts +6 -0
- package/dist/knowledge/index.cjs +78 -16
- package/dist/knowledge/index.d.ts +2 -2
- package/dist/knowledge/index.js +78 -16
- package/dist/knowledge/search-snippet.d.ts +30 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.d.ts +2 -2
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/aisdk/v4/model.d.ts +9 -9
- package/dist/llm/model/base.types.d.ts +2 -2
- package/dist/llm/model/embedding-router.d.ts +1 -1
- package/dist/llm/model/model-settings.d.ts +1 -1
- package/dist/llm/model/model.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.types.d.ts +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +8011 -7996
- package/dist/llm/model/shared.types.d.ts +1 -1
- package/dist/{llm-B5A5cwJr.js → llm-B1zaFLYZ.js} +3 -3
- package/dist/{llm-8Av3mSjD.cjs → llm-BAiOsNAP.cjs} +3 -3
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/loop/loop-builder.d.ts +1 -1
- package/dist/loop/loop.d.ts +1 -1
- package/dist/loop/run-scope-keys.d.ts +1 -1
- package/dist/loop/shared/transcript-step.d.ts +1 -1
- package/dist/loop/types.d.ts +2 -2
- package/dist/loop/workflows/agentic-execution/background-task-check-step.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/build-messages-from-chunks.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/goal-step.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/is-task-complete-step.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-concurrency.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +1 -1
- package/dist/loop/workflows/schema.d.ts +2 -2
- package/dist/loop/workflows/stream.d.ts +1 -1
- package/dist/{manager-sv35JY-z.cjs → manager-BVX9nVrM.cjs} +2 -2
- package/dist/{manager-DfWQCJUK.js → manager-ChK9GdGz.js} +2 -2
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-CigBrT7X.js → mastra-CUGfgEpZ.js} +28 -18
- package/dist/{mastra-D4hvfuxX.cjs → mastra-HSmofHEJ.cjs} +28 -18
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/memory/memory.d.ts +1 -1
- package/dist/memory/types.d.ts +2 -2
- package/dist/{model-CYtXw861.js → model-C47BJRtR.js} +1 -1
- package/dist/{model-BK93CMtl.cjs → model-WahorgzJ.cjs} +1 -1
- package/dist/{netlify-CuI1ZrwR.js → netlify-CfDXkuLf.js} +2 -2
- package/dist/{netlify-BAnn3ouY.cjs → netlify-D99AnEhW.cjs} +2 -2
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/observability/index.cjs +1 -0
- package/dist/observability/index.d.ts +1 -1
- package/dist/observability/index.js +2 -2
- package/dist/{output-helpers-CedRCE17.js → output-helpers-CVzhy1Y0.js} +126 -56
- package/dist/{output-helpers-1Zu4Vt9C.cjs → output-helpers-DgsH4aTb.cjs} +143 -55
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.d.ts +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/processors/runner.d.ts +3 -1
- package/dist/processors/step-schema.d.ts +1 -1
- package/dist/{provider-registry-BwuI_IpT.cjs → provider-registry-CO1NVbO5.cjs} +22070 -22050
- package/dist/{provider-registry-CmQLzLF_.js → provider-registry-CR385GJ4.js} +22070 -22050
- package/dist/provider-registry.json +22239 -22226
- package/dist/{registry-generator-C17V4WfG.js → registry-generator-B3erRqYS.js} +1 -1
- package/dist/{registry-generator-C_0ae7Ce.cjs → registry-generator-Cvp34qcB.cjs} +1 -1
- package/dist/{rehydrate-PnaVawGX.js → rehydrate-CJBLrZxs.js} +2 -2
- package/dist/{rehydrate-CDQ4dOYj.cjs → rehydrate-Da4hNuaK.cjs} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-BwEcwYlU.js → run-registry-DdeEBsVW.js} +1639 -568
- package/dist/{run-registry-BmckDVBk.cjs → run-registry-TOOfO3hT.cjs} +1668 -567
- package/dist/server/auth.d.ts +3 -3
- package/dist/server/composite-auth.d.ts +1 -1
- package/dist/server/simple-auth.d.ts +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +1 -0
- package/dist/storage/domains/knowledge/base.d.ts +5 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +10 -2
- package/dist/storage/domains/knowledge/pages.d.ts +30 -0
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/storage/run-fencing.d.ts +5 -0
- package/dist/stream/RunOutput.d.ts +1 -1
- package/dist/stream/aisdk/v4/input.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/content.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts +1 -1
- package/dist/stream/aisdk/v5/compat/validation.d.ts +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +1 -1
- package/dist/stream/aisdk/v5/input.d.ts +1 -1
- package/dist/stream/aisdk/v5/output-helpers.d.ts +7 -7
- package/dist/stream/aisdk/v5/transform.d.ts +1 -1
- package/dist/stream/base/output.d.ts +4 -4
- package/dist/stream/base/schema.d.ts +1 -1
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +2 -2
- package/dist/{stream-D1y9GzoD.js → stream-C5PagEDs.js} +3 -3
- package/dist/{stream-0kdqBOOn.cjs → stream-DH7Qgz8l.cjs} +3 -3
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.d.ts +3 -3
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tool-loop-agent/utils.d.ts +1 -1
- package/dist/{tool-loop-agent-kWaZAT6Q.cjs → tool-loop-agent-CJTs4T8b.cjs} +3 -3
- package/dist/{tool-loop-agent-BdjWGVIb.js → tool-loop-agent-DVYJXlQJ.js} +3 -3
- package/dist/tools/builtin/web-search.d.ts +1 -1
- package/dist/tools/provider-tool-utils.d.ts +1 -1
- package/dist/tools/tool-builder/builder.d.ts +1 -1
- package/dist/tools/tool-title.d.ts +1 -1
- package/dist/tools/types.d.ts +1 -1
- package/dist/types/user.d.ts +1 -1
- package/dist/{utils-GHY3hmLx.js → utils-D8upuTwy.js} +1 -1
- package/dist/{utils-BKUCaZ12.cjs → utils-xJi_N6Tx.cjs} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-De92squ7.cjs → validate-6eZ8Wssn.cjs} +1 -1
- package/dist/{validate-CB-q-R2F.js → validate-DTkW3Vlp.js} +1 -1
- package/dist/vector/embed.d.ts +4 -4
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/vector.d.ts +4 -4
- package/dist/voice/aisdk/index.d.ts +1 -1
- package/dist/voice/aisdk/speech.d.ts +1 -1
- package/dist/voice/aisdk/transcription.d.ts +1 -1
- package/dist/voice/composite-voice.d.ts +1 -1
- package/dist/voice/default-voice.d.ts +1 -1
- package/dist/voice/index.d.ts +2 -2
- package/dist/voice/voice.d.ts +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-CAKvQj9_.cjs → worker-24ORi-wV.cjs} +2 -2
- package/dist/{worker-BbWPQuPR.cjs → worker-BO3u_WjZ.cjs} +2 -2
- package/dist/{worker-C3u_xzY2.js → worker-DbcFkKJO.js} +2 -2
- package/dist/{worker-Kwm8EKcj.js → worker-Dqubrnf8.js} +2 -2
- package/dist/{workflow-CSjXeNcR.cjs → workflow-D5Fc5ieC.cjs} +4 -4
- package/dist/{workflow-CVmI1Sw-.js → workflow-wXOf72fO.js} +4 -4
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workflows/run-ownership.d.ts +74 -8
- package/dist/workflows/types.d.ts +17 -1
- package/dist/workflows/workflow.d.ts +4 -0
- package/package.json +14 -14
- package/src/llm/model/provider-types.generated.d.ts +8011 -7996
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.98 → @internal_ai-sdk-v4@0.0.99}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.98 → @internal_ai-sdk-v4@0.0.99}/dist/test.d.ts +0 -0
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.98 → @internal_ai-sdk-v4@0.0.99}/package.json +0 -0
- /package/dist/_types/{@internal_ai-sdk-v5@0.0.98 → @internal_ai-sdk-v5@0.0.99}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_ai-sdk-v5@0.0.98 → @internal_ai-sdk-v5@0.0.99}/dist/test.d.ts +0 -0
- /package/dist/_types/{@internal_ai-sdk-v5@0.0.98 → @internal_ai-sdk-v5@0.0.99}/package.json +0 -0
- /package/dist/_types/{@internal_ai-v6@0.0.98 → @internal_ai-v6@0.0.99}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_ai-v6@0.0.98 → @internal_ai-v6@0.0.99}/package.json +0 -0
- /package/dist/_types/{@internal_ai-v7@0.0.98 → @internal_ai-v7@0.0.99}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_ai-v7@0.0.98 → @internal_ai-v7@0.0.99}/package.json +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/_types/@internal_core@0.1.4/dist/base/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/_types/@internal_core@0.1.4/dist/index-Diz1p9N7.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/capabilities.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/defaults/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/defaults/rbac/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/defaults/rbac/static.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/defaults/roles.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/fga-check.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/interfaces/acl.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/interfaces/fga.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/interfaces/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/interfaces/permissions.generated.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/interfaces/rbac.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/interfaces/user.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/ee/license.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/provider/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/session/cookie.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/session/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/session/memory.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/dist/types/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth@0.0.39 → @internal_auth@0.0.40}/package.json +0 -0
- /package/dist/_types/{@internal_deployer@0.0.4 → @internal_deployer@0.0.5}/dist/_types/@internal_core@0.1.4/dist/index-Diz1p9N7.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.4 → @internal_deployer@0.0.5}/dist/_types/@internal_core@0.1.4/dist/logger/index.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.4 → @internal_deployer@0.0.5}/dist/bundler.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.4 → @internal_deployer@0.0.5}/dist/deployer.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.4 → @internal_deployer@0.0.5}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.4 → @internal_deployer@0.0.5}/package.json +0 -0
- /package/dist/_types/{@internal_external-types@0.0.101 → @internal_external-types@0.0.102}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_external-types@0.0.101 → @internal_external-types@0.0.102}/package.json +0 -0
- /package/dist/_types/{@internal_voice@0.0.47/dist/_types/@internal_ai-sdk-v5@0.0.98 → @internal_voice@0.0.48/dist/_types/@internal_ai-sdk-v5@0.0.99}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/@internal_core@0.1.4/dist/base/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/@internal_core@0.1.4/dist/index-Diz1p9N7.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/@internal_core@0.1.4/dist/request-context/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/@internal_core@0.1.4/dist/types/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/ZodError.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/errors.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/external.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/helpers/enumUtil.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/helpers/errorUtil.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/helpers/parseUtil.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/helpers/partialUtil.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/helpers/typeAliases.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/helpers/util.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/locales/en.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/standard-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v3/types.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/checks.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/coerce.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/compat.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/deep-partial.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/errors.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/external.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/from-json-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/in-out.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/iso.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/parse.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/classic/schemas.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/api.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/checks.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/compile.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/core.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/doc.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/errors.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/json-schema-generator.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/json-schema-processors.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/json-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/memoizer.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/parse.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/regexes.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/registries.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/schemas.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/standard-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/to-json-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/util.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/core/versions.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/index.d.cts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ar.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/az.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/be.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/bg.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/bn.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ca.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ckb.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/cs.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/da.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/de.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/el.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/en.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/eo.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/es.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/fa.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/fi.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/fr-CA.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/fr.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/gu.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/he.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/hi.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/hr.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/hu.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/hy.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/id.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/is.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/it.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ja.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ka.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/kh.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/km.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/kn.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ko.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/lt.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/mk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ms.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ne.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/nl.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/nn.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/no.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ota.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/pl.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ps.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/pt-BR.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/pt.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ro.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ru.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/sk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/sl.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/sv.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ta.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/tg.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/th.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/tk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/tr.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ua.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/uk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/ur.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/uz.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/vi.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/yo.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/zh-CN.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/_types/zod@4.6.7/v4/locales/zh-TW.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/voice/aisdk/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/voice/default-voice.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/voice/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/dist/voice/voice.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.47 → @internal_voice@0.0.48}/package.json +0 -0
|
@@ -18,7 +18,12 @@ Resumable streams don't make the run itself durable. Reconnecting isn't crash re
|
|
|
18
18
|
| Plain agent with `durable: false` | Off, including registered agents |
|
|
19
19
|
| Explicit `createDurableAgent()` wrapper | Always published; pass `cache: false` to the factory to disable the replay cache, not transport history |
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Mastra resolves the stream transport and replay cache separately:
|
|
22
|
+
|
|
23
|
+
- **Transport:** For the plain loop and the default durable engine, Mastra uses the first configured option: the agent's `durable.pubsub`, the agent's top-level `pubsub`, or `mastra.pubsub`. Evented steps publish on `mastra.pubsub` so workers can publish to the same stream.
|
|
24
|
+
- **Replay cache:** Mastra uses the agent's `durable.cache`, then `mastra.serverCache`, then an in-memory cache. Evented runs use the shared Mastra cache when replay caching is enabled. If the transport is already a `CachingPubSub`, Mastra reuses its cache. Set `durable.cache: false` to skip adding a replay cache without changing the transport or its retained history.
|
|
25
|
+
|
|
26
|
+
For deployments with more than one process, see [PubSub setup for resumable streams](https://mastra.ai/docs/server/pubsub).
|
|
22
27
|
|
|
23
28
|
## Configure streams
|
|
24
29
|
|
|
@@ -48,7 +53,9 @@ export const supportAgent = new Agent({
|
|
|
48
53
|
|
|
49
54
|
`durable: true` turns streams on with these defaults, including for standalone agents.
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
To checkpoint execution as well as publish run frames, set `durable.executionEngine` to `'default'` or `'evented'` on the agent, or inherit the setting from `Mastra`. Without an engine setting, `durable: true` only enables stream publication.
|
|
57
|
+
|
|
58
|
+
To continue an in-flight run after a crash, configure [crash recovery](https://mastra.ai/docs/harness/durable-agents) separately.
|
|
52
59
|
|
|
53
60
|
Configure the wrapper's stream cache and transport through the factory's `cache`, `pubsub`, `shouldCache`, and `cleanupTimeoutMs` options.
|
|
54
61
|
|
|
@@ -72,15 +79,17 @@ To keep live observation but skip the replay cache, pass `durable: { cache: fals
|
|
|
72
79
|
|
|
73
80
|
### How long runs stay available
|
|
74
81
|
|
|
75
|
-
|
|
82
|
+
When a run finishes, the executing process schedules deletion of its events and ownership record after `cleanupTimeoutMs` (30 seconds by default). That's the fast path. Everything is also bounded by idle retention, refreshed on every append, so a process that restarts before the deletion timer fires can't leave a run's state behind indefinitely. A run parked on a tool approval or suspension isn't deleted, because resuming it continues on the same topic.
|
|
76
83
|
|
|
77
|
-
The
|
|
84
|
+
The retentions that apply:
|
|
78
85
|
|
|
79
|
-
-
|
|
86
|
+
- A run's replay cache requests a minimum 24-hour lifetime after the last append (`runLogTtlMs` on [`CachingPubSub`](https://mastra.ai/reference/pubsub/caching-pubsub)). Redis and Valkey Streams use a separate 24-hour transport default for run topics. These defaults match the run record's own 24-hour lifetime, deliberately: a run parked on a tool approval appends nothing while it waits, so its retention is never refreshed, and the events must outlive every moment the record still authorizes an `observe()` or resume. For thread streams, `threadStreamLogTtlMs` requests one hour in the cache while the transport independently defaults to one hour, enough for an idle thread's tail to survive a reconnect. Cache TTL overrides leave the transport defaults unchanged, though `streamIdleTtlMs` can shorten them. The replay cache's retention is stamped only when an event is appended. The transport's is also refreshed when a reader subscribes.
|
|
87
|
+
- A run's ownership record keeps a 24-hour lifetime, so a run parked overnight on an approval stays authorizable for observe and resume, and because its events share that lifetime, the approval request is still there to replay. The run log is a delivery buffer and messages live in storage: once both expire, `observe()` returns 404 rather than replaying, and a client fetches the conversation from storage.
|
|
88
|
+
- Topics that don't belong to a single run or thread, such as work queues and application feeds, keep the transport's own idle TTL, seven days by default for [Redis Streams](https://mastra.ai/reference/pubsub/redis-streams) and [Valkey Streams](https://mastra.ai/reference/pubsub/valkey-streams). They need it: a grouped consumer that was offline must still find its backlog. Configure `streamIdleTtlMs` to change it, or set it to `0` to disable transport expiry. Lowering it also lowers the retention on run topics.
|
|
80
89
|
- The in-memory cache holds 1,000 entries by default. Each run uses several entries (its event log, a counter and its ownership record), so heavy traffic evicts older runs sooner.
|
|
81
90
|
- The server's observe and abort routes return 404 when a run's ownership record is evicted or expires. Evicted run events can't be replayed.
|
|
82
91
|
|
|
83
|
-
Use a shared cache such as Redis, sized for your traffic, when runs must stay observable across servers or for long approval waits.
|
|
92
|
+
A run log recreated after its retention lapsed normally numbers above the indices it issued before. An attached observer then keeps receiving the new frames. Treat that as the common case rather than a guarantee: the built-in Redis, Valkey and in-memory caches derive the numbering from a clock, Convex numbers densely instead, and the fallback that detects a restarted log only recognizes one that restarts at zero. An observer attached across a log recreated below its cursor can miss new frames. Reattaching without the old offset can replay the entries still retained in the new log, while reusing that offset can skip them. Storage remains the source of truth for a run's messages. Use a shared cache such as Redis, sized for your traffic, when runs must stay observable across servers or for long approval waits.
|
|
84
93
|
|
|
85
94
|
## Follow a run
|
|
86
95
|
|
|
@@ -60,7 +60,9 @@ Extra scheduler instances add availability, not throughput. Each one polls stora
|
|
|
60
60
|
|
|
61
61
|
### Background task worker
|
|
62
62
|
|
|
63
|
-
Executes agent tool calls marked with `background: { enabled: true }
|
|
63
|
+
Executes agent tool calls marked with `background: { enabled: true }` without blocking the response stream.
|
|
64
|
+
|
|
65
|
+
A background tool call is bound to the agent run that made it, so it runs on the process that executes the agent loop. An API server with `MASTRA_WORKERS=false` doesn't hand its agents' tool calls to a dedicated background task worker: a durable agent runs the tool inline, and a regular agent returns a dispatch error as the tool result unless you pass `disableBackgroundTasks: true`. See [BackgroundTaskWorker](https://mastra.ai/reference/workers/overview).
|
|
64
66
|
|
|
65
67
|
The background task worker manages concurrency limits, task lifecycle, and result delivery through the PubSub bus.
|
|
66
68
|
|
|
@@ -496,7 +496,7 @@ Every Mastra process with background tasks enabled runs its own manager. You can
|
|
|
496
496
|
### Deployment requirements
|
|
497
497
|
|
|
498
498
|
- Every manager must use the same storage backend, and its `updateTask` must apply the write conditions atomically. Mastra's storage adapters do. In-memory storage is only shared within one process.
|
|
499
|
-
- `leaseExpiresAt` is a timestamp written with the owner's clock and compared against the clock of the manager that reads it. Keep server clocks synchronized, for example with Network Time Protocol (NTP), to well under `leaseDurationMs`. If a reader's clock runs ahead by more than the lease, it can recover a task whose owner is still alive. If it runs behind, recovery is delayed. The startup scan
|
|
499
|
+
- `leaseExpiresAt` is a timestamp written with the owner's clock and compared against the clock of the manager that reads it. Keep server clocks synchronized, for example with Network Time Protocol (NTP), to well under `leaseDurationMs`. If a reader's clock runs ahead by more than the lease, it can recover a task whose owner is still alive. If it runs behind, recovery is delayed. The startup scan and the periodic check recover a task as soon as its lease has expired by the reader's clock. Follow-up scans wait about one second past the expiry to absorb small differences.
|
|
500
500
|
- A longer [`leaseDurationMs`](https://mastra.ai/reference/configuration) delays recovery after a crash. A shorter one adds storage writes and makes it more likely that a stalled owner loses its lease while still running. The default is 30 seconds and the minimum is 3000 ms.
|
|
501
501
|
|
|
502
502
|
### Lease guarantees and repeated tool calls
|
|
@@ -519,17 +519,17 @@ Before a manager runs a task, it claims the task with a conditional write. The w
|
|
|
519
519
|
|
|
520
520
|
While the task runs, the owner renews the lease every `leaseDurationMs / 3`, with a minimum of one second. Each renewal is conditional on the task still being `running` under the same owner. The task's final writes, such as `completed`, `failed`, `timed_out`, or `suspended`, carry the same condition, so a manager that lost the task can't overwrite the result of the manager that replaced it.
|
|
521
521
|
|
|
522
|
-
The owner stops renewing when the task completes, fails, or suspends. On shutdown, the manager releases the leases it still holds, so other managers can recover those tasks without waiting for the lease to expire. A lease that isn't released, for example because the process crashed, expires on its own.
|
|
522
|
+
The owner stops renewing when the task completes, fails, or suspends. On shutdown, the manager releases the leases it still holds, so other managers can recover those tasks without waiting for the lease to expire. A running task with `maxRetries: 0` can't run again, so shutdown fails it with `Worker process terminated before task completed`, the same ending as a crash, rather than cancelling it. A lease that isn't released, for example because the process crashed, expires on its own.
|
|
523
523
|
|
|
524
524
|
### Recover a task from a dead owner
|
|
525
525
|
|
|
526
526
|
A manager treats a `running` task as abandoned only after its lease expires.
|
|
527
527
|
|
|
528
|
-
When `recoverStaleTasksOnStart` is `true`, the default, each manager that runs tasks scans for abandoned tasks on startup. If the scan finds a lease that hasn't expired yet, the manager scans again shortly after that lease expires, and repeats until no live lease is left.
|
|
528
|
+
When `recoverStaleTasksOnStart` is `true`, the default, each manager that runs tasks scans for abandoned tasks on startup. If the scan finds a lease that hasn't expired yet, the manager scans again shortly after that lease expires, and repeats until no live lease is left. After startup, the manager also checks for running tasks with an expired lease every `leaseDurationMs`, so a task whose worker dies later is recovered without a restart. Each check reads up to `globalConcurrency` running tasks (at least 100, at most 1,000), which normally covers all of them, so the task is recovered within about one `leaseDurationMs` after its lease expires. When more tasks are running than that, for example because other servers use a higher `globalConcurrency`, each further page of running tasks adds one `leaseDurationMs`. For each task the scan recovers:
|
|
529
529
|
|
|
530
530
|
- If the task's worker shut down gracefully, it returns to `pending` and is dispatched again without using a retry.
|
|
531
531
|
- If the worker died and the task's `retryCount` is below `maxRetries`, it uses a retry, returns to `pending`, and is dispatched again.
|
|
532
|
-
- Otherwise, it fails with `Worker process terminated before task completed`.
|
|
532
|
+
- Otherwise, it fails with `Worker process terminated before task completed`. The failure fires `task.failed` and `onTaskFailed` like any other failure.
|
|
533
533
|
|
|
534
534
|
Only a crash counts against `maxRetries`, so a task that keeps taking its worker down stops after its retries are used, while a deploy doesn't use one.
|
|
535
535
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
10
10
|
|
|
11
|
-
A durable agent
|
|
11
|
+
A durable agent runs the [agentic loop](https://mastra.ai/docs/agents/overview) inside a workflow. Clients can reconnect over [PubSub](https://mastra.ai/docs/server/pubsub) and replay retained stream events. With persistent storage and recovery configured, the agent can continue from a checkpoint after a process restart.
|
|
12
12
|
|
|
13
13
|
## When to use durable agents
|
|
14
14
|
|
|
@@ -23,46 +23,42 @@ For short-lived, request-scoped calls where the client stays connected, a regula
|
|
|
23
23
|
|
|
24
24
|
## Quickstart
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Set `durable.executionEngine` to `'default'` on your agent to run it in the current process. This example uses an `OPENAI_API_KEY` for the model:
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { Agent } from '@mastra/core/agent'
|
|
30
|
-
import { createDurableAgent } from '@mastra/core/agent/durable'
|
|
31
30
|
|
|
32
|
-
const
|
|
31
|
+
export const researcher = new Agent({
|
|
33
32
|
id: 'researcher',
|
|
34
33
|
name: 'Researcher',
|
|
35
34
|
instructions: 'You research topics thoroughly.',
|
|
36
35
|
model: 'openai/gpt-6.1-sol',
|
|
36
|
+
durable: { executionEngine: 'default' },
|
|
37
37
|
})
|
|
38
|
-
|
|
39
|
-
export const durableResearcher = createDurableAgent({ agent })
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
Register the
|
|
40
|
+
Register the agent with Mastra and call `stream()`:
|
|
43
41
|
|
|
44
42
|
```typescript
|
|
45
43
|
import { Mastra } from '@mastra/core'
|
|
46
|
-
import {
|
|
44
|
+
import { researcher } from './agents/researcher'
|
|
47
45
|
|
|
48
|
-
const mastra = new Mastra({
|
|
49
|
-
agents: {
|
|
46
|
+
export const mastra = new Mastra({
|
|
47
|
+
agents: { researcher },
|
|
50
48
|
})
|
|
51
49
|
|
|
52
|
-
const
|
|
53
|
-
'
|
|
54
|
-
)
|
|
50
|
+
const output = await mastra
|
|
51
|
+
.getAgent('researcher')
|
|
52
|
+
.stream('Research quantum computing advances in 2025')
|
|
55
53
|
|
|
56
54
|
for await (const chunk of output.fullStream) {
|
|
57
55
|
// Process each chunk as it arrives
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
// Release PubSub subscriptions and clear the run from the registry.
|
|
61
|
-
// If you skip this, an automatic cleanup timer fires after the stream ends.
|
|
62
|
-
cleanup()
|
|
63
57
|
```
|
|
64
58
|
|
|
65
|
-
The
|
|
59
|
+
The native `stream()` returns the model output directly. Use `output.runId` to [reconnect](#resumable-streams). With a wrapper, `stream()` returns a handle with the model output in `.output`. See the [wrapper example](https://mastra.ai/reference/agents/durable-agent).
|
|
60
|
+
|
|
61
|
+
To continue a run after a process restart, configure persistent storage and [crash recovery](#crash-recovery).
|
|
66
62
|
|
|
67
63
|
## How it works
|
|
68
64
|
|
|
@@ -76,32 +72,23 @@ A durable agent adds three layers on top of a regular agent:
|
|
|
76
72
|
|
|
77
73
|
## Execution variants
|
|
78
74
|
|
|
79
|
-
|
|
75
|
+
Choose the engine based on where the agent should run:
|
|
80
76
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
| `createDurableAgent()`
|
|
84
|
-
| `createEventedAgent()`
|
|
85
|
-
| `createInngestAgent()`
|
|
77
|
+
| Native agent setting | Wrapper equivalent | Best for |
|
|
78
|
+
| ------------------------------------ | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
79
|
+
| `durable.executionEngine: 'default'` | `createDurableAgent()` from `@mastra/core/agent/durable` | Local development and single-process servers. You get a stream you can await directly. |
|
|
80
|
+
| `durable.executionEngine: 'evented'` | `createEventedAgent()` from `@mastra/core/agent/durable` | Runs in the background, and you can follow the run through PubSub. It can run in one process or across multiple processes with a [supported PubSub backend and storage adapter](https://mastra.ai/docs/server/pubsub). |
|
|
81
|
+
| No native setting | `createInngestAgent()` from `@mastra/inngest` | On Inngest, with step memoization, retries, and a monitoring dashboard. |
|
|
86
82
|
|
|
87
|
-
|
|
83
|
+
To set a default for registered native agents, use `durable.executionEngine` on [Mastra](https://mastra.ai/reference/core/mastra-class). An explicit agent setting overrides it. The choice is fixed at registration or first execution. Wrapper factories select their own engine without changing the wrapped agent's selection.
|
|
88
84
|
|
|
89
|
-
|
|
85
|
+
Before switching engines, stop sending new runs to the old engine and let its active runs finish. Resolve suspended runs on the old engine too. Don't rely on the new engine to resume or recover them.
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
import { Agent } from '@mastra/core/agent'
|
|
95
|
-
import { createDurableAgent } from '@mastra/core/agent/durable'
|
|
87
|
+
Register a wrapper with `Mastra` the same way as a regular agent. The Core wrappers return `Agent` subclasses. `createInngestAgent()` returns a proxy that forwards `Agent` methods to the underlying agent. When `sendSignal()` or `sendNotificationSignal()` wakes an idle thread, the registered agent starts a run with its configured engine.
|
|
96
88
|
|
|
97
|
-
|
|
98
|
-
id: 'helper',
|
|
99
|
-
instructions: 'You are a helpful assistant.',
|
|
100
|
-
model: 'openai/gpt-6.1-sol',
|
|
101
|
-
})
|
|
89
|
+
### In-process with `createDurableAgent()`
|
|
102
90
|
|
|
103
|
-
|
|
104
|
-
```
|
|
91
|
+
For wrapper setup, see [`createDurableAgent()`](https://mastra.ai/reference/agents/durable-agent) in the API reference.
|
|
105
92
|
|
|
106
93
|
### Fire-and-forget with `createEventedAgent()`
|
|
107
94
|
|
|
@@ -124,7 +111,9 @@ In one process, an evented agent runs on the default PubSub backend with no extr
|
|
|
124
111
|
|
|
125
112
|
### Resumable streams for stored agents
|
|
126
113
|
|
|
127
|
-
|
|
114
|
+
Stored agents inherit the server's `Mastra.durable.executionEngine` default when registered, unless their `durable` field is `false`. Loading a specific `versionId` of an already registered stored agent creates a separate instance that doesn't inherit the engine default. When no engine default applies, `durable: true` enables resumable streams without checkpointing.
|
|
115
|
+
|
|
116
|
+
Enable the stored agent's `durable` setting with [`createStoredAgent()`](https://mastra.ai/reference/client-js/agents):
|
|
128
117
|
|
|
129
118
|
```typescript
|
|
130
119
|
await mastraClient.createStoredAgent({
|
|
@@ -136,7 +125,7 @@ await mastraClient.createStoredAgent({
|
|
|
136
125
|
})
|
|
137
126
|
```
|
|
138
127
|
|
|
139
|
-
`durable` also accepts `{ cleanupTimeoutMs }`.
|
|
128
|
+
`durable` also accepts `{ cleanupTimeoutMs }`. Stored agents inherit the server's replay cache and PubSub transport. To select an engine per agent, use a [code-defined agent](#quickstart).
|
|
140
129
|
|
|
141
130
|
### Inngest-powered with `createInngestAgent()`
|
|
142
131
|
|
|
@@ -162,10 +151,10 @@ Visit the [`createInngestAgent()` reference](https://mastra.ai/reference/agents/
|
|
|
162
151
|
|
|
163
152
|
## Resumable streams
|
|
164
153
|
|
|
165
|
-
Durable agents support resumable streams through PubSub and an event cache. When a client disconnects mid-stream, the cache continues storing events.
|
|
154
|
+
Durable agents support resumable streams through PubSub and an event cache. When a client disconnects mid-stream, the cache continues storing events. To reconnect, pass the run ID to `observe()` and read the stream from the returned handle's `.output`:
|
|
166
155
|
|
|
167
156
|
```typescript
|
|
168
|
-
const { output } = await
|
|
157
|
+
const { output } = await mastra.getAgent('researcher').observe(runId)
|
|
169
158
|
|
|
170
159
|
for await (const chunk of output.fullStream) {
|
|
171
160
|
// Chunks from the run, including any missed while disconnected
|
|
@@ -176,12 +165,12 @@ Calling `observe(runId)` without an offset is the supported general reconnect fl
|
|
|
176
165
|
|
|
177
166
|
The optional `offset` is a run-log position, which chunks report as `chunk.index`. To resume after a dropped connection, pass `index + 1` of the last chunk that has an `index`, or omit `offset` if nothing arrived. This works the same with `stream()` and `observe()`, over HTTP, and in `@mastra/client-js`. See [`observe(runId, options?)`](https://mastra.ai/reference/agents/durable-agent) for which chunks carry no index, structured output, and transport limits.
|
|
178
167
|
|
|
179
|
-
Replay isn't a permanent execution archive. Events remain available only until [cleanup](#cleanup) clears them or the cache removes them. A workflow snapshot can't reconstruct cleared stream events, and disabling
|
|
168
|
+
Replay isn't a permanent execution archive. Events remain available only until [cleanup](#cleanup) clears them or the cache removes them. A workflow snapshot can't reconstruct cleared stream events, and disabling the replay cache doesn't disable history retained by a transport such as Redis Streams.
|
|
180
169
|
|
|
181
170
|
Observing doesn't own the run. When the loop ends, or you leave it early with `break`, `return`, or an error, the observer unsubscribes and the run keeps going for anyone else watching it. To stop observing from outside the loop, for example when the client disconnects, call `detach()`:
|
|
182
171
|
|
|
183
172
|
```typescript
|
|
184
|
-
const { output, detach } = await
|
|
173
|
+
const { output, detach } = await mastra.getAgent('researcher').observe(runId)
|
|
185
174
|
|
|
186
175
|
request.signal.addEventListener('abort', detach, { once: true })
|
|
187
176
|
|
|
@@ -255,11 +244,11 @@ Background tasks have their own execution lease, stored on each task record, sep
|
|
|
255
244
|
|
|
256
245
|
## Cleanup
|
|
257
246
|
|
|
258
|
-
|
|
247
|
+
Call `cleanup()` from the process that started the run to release its resources and clear its cached stream events. Wrapper `stream()` and `observe()` handles expose `cleanup()`. On native durable stream output, use the optional `cleanup()` method on [`AgentStreamOutput`](https://mastra.ai/reference/agents/durable-agent).
|
|
259
248
|
|
|
260
249
|
When you don't call `cleanup()` yourself, Mastra calls it `cleanupTimeoutMs` after the run finishes, errors, or is aborted. The default is 30 seconds, so completed-run replay is limited to that window unless you configure a different value or call `cleanup()` sooner. Detaching an observer or reaching a plain `idleTimeoutMs` doesn't start this timer. Set `cleanupTimeoutMs: 0` to turn the timer off. The cache's own TTL and eviction still apply.
|
|
261
250
|
|
|
262
|
-
|
|
251
|
+
To stop watching a run from `observe()` without clearing it, call `detach()` or leave the loop.
|
|
263
252
|
|
|
264
253
|
## Tool approval
|
|
265
254
|
|
|
@@ -331,7 +320,7 @@ export const mastra = new Mastra({
|
|
|
331
320
|
})
|
|
332
321
|
```
|
|
333
322
|
|
|
334
|
-
|
|
323
|
+
At boot, Mastra recovers `running` runs for registered durable agents from their last persisted snapshots. If a stored agent loads after boot recovery, follow the [manual recovery](#manual-recovery) steps.
|
|
335
324
|
|
|
336
325
|
Recovery processes up to five agents concurrently, with up to five run waits per agent. Each wait covers both `recover()` setup and settlement of the whole recovered workflow and lasts at most 30 seconds. If it expires, the attempt continues in the background and frees a slot for another run. These limits bound waiting, not the number of live executions. Discovery and overridden custom recovery methods aren't bounded by this budget.
|
|
337
326
|
|
|
@@ -362,7 +351,9 @@ for (const run of recovered) {
|
|
|
362
351
|
await durableAgent.recoverActiveRuns({ runId: 'run-abc-123' })
|
|
363
352
|
```
|
|
364
353
|
|
|
365
|
-
|
|
354
|
+
To recover a stored agent that wasn't registered at boot, first load it with `await mastra.getEditor()?.agent.getById(agentId)` without a `versionId`. Once it loads, call `mastra.recoverAllDurableAgents()`.
|
|
355
|
+
|
|
356
|
+
`recoverActiveRuns()` reports `success`, `failed`, or `skipped` for each run. If a skipped run returns `retryAt`, schedule your own re-check when calling `recoverActiveRuns()` directly. `mastra.recoverAllDurableAgents()` schedules that re-check for you and counts timed-out attempts only as `skipped`.
|
|
366
357
|
|
|
367
358
|
Manual recovery reads the same `running` checkpoints as automatic recovery. For a `DurableAgent` using the default snapshot policy with `recovery.durableAgents` set to `'off'`, in-flight runs are only checkpointed at step boundaries reached after `mastra.shutdown()` starts. A run that crashes before then, or doesn't reach a step boundary during the drain, has no checkpoint, so `listActiveRuns()` and `recoverActiveRuns()` don't find it. See [snapshot persistence](#snapshot-persistence).
|
|
368
359
|
|
|
@@ -98,7 +98,7 @@ export class HelpDeskImporter extends KnowledgeImporter({
|
|
|
98
98
|
|
|
99
99
|
`htmlToMarkdown()` stands in for your own conversion. A few things the example relies on:
|
|
100
100
|
|
|
101
|
-
- **Await every `ctx.items` call.** Items are buffered and sent in batches, so a call can wait for the previous batch to land.
|
|
101
|
+
- **Await every `ctx.items` call.** Items are buffered and sent in batches, so a call can wait for the previous batch to land. A batch is sent when 200 items are waiting, when you call `ctx.state.set()`, when `import` returns, or once the oldest waiting item has waited 30 seconds, so items from a slow source still land during the run. A batch sent on the timer carries only items: the cursor moves only with `ctx.state.set()`. If the run ends early, the next run resends those items from the saved cursor, and writing the same `sourceId` again is safe. If the host can't take a batch (an item with an empty `sourceId`, say), the run fails there and saves no cursor after it, even if you catch the error.
|
|
102
102
|
- **`ctx.state.set()` saves the cursor with the items before it.** Call it after the items it covers, never before.
|
|
103
103
|
- **Use `ctx.fetch` and watch `ctx.signal`.** The signal fires when the run is canceled or reaches its time limit. `ctx.fetch` always uses that signal. If you pass your own `signal`, for example `AbortSignal.timeout()`, it's combined with the run's: either one aborts the fetch, so a run that's canceled or out of time never leaves a fetch running. `ctx.fetch` doesn't retry, so handle rate limits and server errors yourself, for example by waiting for the source's `Retry-After` header before trying again.
|
|
104
104
|
- **Throw `KnowledgeImporterSourceError` with the HTTP status** when the source fails. The run ends with a fixed error code, such as `source_auth_failed` for 401 or 403 and `source_rate_limited` for 429, and your error text stays in your own logs.
|
|
@@ -208,7 +208,7 @@ Platform adds these fields and grouping options:
|
|
|
208
208
|
| `aggregateTraces()` | Supports `groupBy: ['projectId']` and `countDistinct.projectId`. |
|
|
209
209
|
| `aggregateSpans()` | Supports `groupBy: ['projectId']`, but not `countDistinct.projectId`. |
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
All traces are retained for six months. This retention period is subject to change for all month-to-month plans. See [pricing](https://mastra.ai/pricing) for current plan limits.
|
|
212
212
|
|
|
213
213
|
### Other observability data
|
|
214
214
|
|
|
@@ -146,6 +146,7 @@ Use a remote or container sandbox when commands need a stronger boundary from th
|
|
|
146
146
|
- [Railway](https://mastra.ai/integrations/sandboxes/railway)
|
|
147
147
|
- [Fly.io Sprites](https://mastra.ai/integrations/sandboxes/sprites)
|
|
148
148
|
- [Vercel](https://mastra.ai/integrations/sandboxes/vercel)
|
|
149
|
+
- [WBX Sandbox](https://mastra.ai/integrations/sandboxes/wbx)
|
|
149
150
|
|
|
150
151
|
If Mastra doesn't support your sandbox provider, implement the [sandbox provider interface](https://mastra.ai/reference/workspace/sandbox) to add it.
|
|
151
152
|
|
|
@@ -107,7 +107,7 @@ export const mastra = new Mastra({
|
|
|
107
107
|
|
|
108
108
|
## Evented workflows and agents
|
|
109
109
|
|
|
110
|
-
Workflows on the [evented execution engine](https://mastra.ai/docs/workflows/scheduled-workflows) and agents
|
|
110
|
+
Workflows on the [evented execution engine](https://mastra.ai/docs/workflows/scheduled-workflows) and agents using [evented durable execution](https://mastra.ai/docs/harness/durable-agents) advance a run one event at a time. Any worker can take the next event, which lets several processes share one run. That only holds when the deployment has both of the following:
|
|
111
111
|
|
|
112
112
|
- **A PubSub backend that redelivers unacknowledged events**: When a worker stops in the middle of a step, the backend gives the step's event to another worker.
|
|
113
113
|
- **A storage adapter with workflow step guards**: The backend can deliver the same event more than once, and the step guard keeps a later delivery from saving the step's result a second time. A step can still run more than once, so [make steps with side effects idempotent](https://mastra.ai/docs/workflows/overview).
|
|
@@ -498,9 +498,11 @@ workflow.restartAllActiveWorkflowRuns()
|
|
|
498
498
|
|
|
499
499
|
Runs restart concurrently, up to `recovery.workflowConcurrency` at a time (default `5`). Set it to `1` in the Mastra config if your runs share side effects that must not run in parallel.
|
|
500
500
|
|
|
501
|
-
To exclude a workflow from automatic boot-time restarts triggered by `Mastra.restartAllActiveWorkflowRuns()`, set `autoRestartActiveRuns: false` in the workflow's `options`. This is useful for workflows with side effects that must not be re-driven by a blanket restart. Durable agent workflows set this automatically because their recovery is owned by the opt-in `recovery.durableAgents: 'auto'` path.
|
|
501
|
+
To exclude a workflow from automatic boot-time restarts triggered by `Mastra.restartAllActiveWorkflowRuns()`, set `autoRestartActiveRuns: false` in the workflow's `options`. This is useful for workflows with side effects that must not be re-driven by a blanket restart. Such a workflow's runs also hold no storage lease, so their saves aren't refused after another instance restarts them. Durable agent workflows set this automatically because their recovery is owned by the opt-in `recovery.durableAgents: 'auto'` path.
|
|
502
502
|
|
|
503
|
-
While a run executes, Mastra holds a storage lease on it and renews it in the background. `restart()` refuses to take over a run whose lease hasn't expired: it throws a `WORKFLOW_RESTART_RUN_OWNED` error and the sweep skips the run.
|
|
503
|
+
While a run executes, Mastra holds a storage lease on it and renews it in the background. `restart()` refuses to take over a run whose lease hasn't expired: it throws a `WORKFLOW_RESTART_RUN_OWNED` error and the sweep skips the run. `workflow.restartAllActiveWorkflowRuns()` skips such a run without a recheck, so call it after the lease expires if you need to recover that run. Storage adapters without run-ownership support keep the previous behavior and restart every active run.
|
|
504
|
+
|
|
505
|
+
If a process stops renewing its lease but keeps executing, for example because its event loop is blocked for longer than the lease TTL, recovery on another instance can take the run over. From then on, storage refuses the stalled process's saves to the run, and its `start()`, `resume()`, `restart()` or `timeTravel()` call rejects with a `STORAGE_RUN_FENCE_CONFLICT` error. Over HTTP, a request that waits for such a run gets a 409 with that `code`. A run started with `startAsync()` that was already dispatched only logs a warning, and on `stream()`, `resumeStream()` and `timeTravelStream()` the stream closes and its `result` rejects with the same error. The step it was running can still finish, so recovery can run that step a second time. Keep steps idempotent, as described below. To see the run as the instance that took it over drives it, read it with `getWorkflowRunById()`. This applies to default-engine runs that hold a lease, on storage adapters with run-ownership support. Other runs save as before.
|
|
504
506
|
|
|
505
507
|
`mastra.restartAllActiveWorkflowRuns()`, which the server calls on boot, restarts a default-engine run only once it stopped: no instance holds its lease, and neither the run nor its lease changed for `recovery.workflowGraceMs` (2 seconds by default). A run that's still running, or stopped more recently, is left to the [recovery loop](#recovery-loop).
|
|
506
508
|
|
|
@@ -520,7 +522,7 @@ For tools that agents call, see [make tools safe to repeat](https://mastra.ai/do
|
|
|
520
522
|
|
|
521
523
|
### Recovery loop
|
|
522
524
|
|
|
523
|
-
`mastra.startWorkers()` also starts a recovery loop on an instance that runs the orchestration worker. Every `recovery.workflowScanIntervalMs` (60 seconds by default, give or take a fifth), it restarts the default-engine runs that stopped, by the same rule as `restartAllActiveWorkflowRuns()`. A run whose instance crashed is restarted at the first pass after its lease expired (`
|
|
525
|
+
`mastra.startWorkers()` also starts a recovery loop on an instance that runs the orchestration worker. Every `recovery.workflowScanIntervalMs` (60 seconds by default, give or take a fifth), it restarts the default-engine runs that stopped, by the same rule as `restartAllActiveWorkflowRuns()`. A run whose instance crashed is restarted at the first pass after its lease expired (the workflow's `leaseTtlMs`, 15 seconds by default) and `recovery.workflowGraceMs` passed. When a pass finds a run in its grace period, the next pass runs once that period ends, but no sooner than a second later.
|
|
524
526
|
|
|
525
527
|
Instances that share a storage adapter elect one loop leader through a lease row in storage. Only the leader's loop lists runs. The loops of the other instances only try to take its place. The leader keeps the role until its `stopWorkers()` or `shutdown()` hands it back, or until its lease expires after a crash. With `restartAllActiveWorkflowRuns()` at boot, each instance still restarts its own stopped default-engine runs, whichever instance leads. Between boots, the loop recovers only the workflows the leader registers, so instances that register different workflows on one storage get loop recovery for the leader's workflows only and the others' runs at their next boot. A run the loop restarts executes on the leader.
|
|
526
528
|
|
|
@@ -532,6 +534,68 @@ export const mastra = new Mastra({
|
|
|
532
534
|
|
|
533
535
|
The loop never restarts evented runs. A broker that redelivers unacknowledged events recovers them, and on other pubsubs `restartAllActiveWorkflowRuns()` restarts them at boot. The loop also leaves workflows that set `autoRestartActiveRuns: false` alone, and an instance that registers no other default-engine workflow never claims the leader row. It doesn't run when `recovery.workflows` is `'off'`, on an instance started with `workers: false` or a `MASTRA_WORKERS` filter without `orchestration`, or on a storage adapter without run-ownership support. A process that calls `restartAllActiveWorkflowRuns()` but never `startWorkers()` runs no loop.
|
|
534
536
|
|
|
537
|
+
### Steps that block the event loop
|
|
538
|
+
|
|
539
|
+
A run's lease is renewed from the event loop of the process that runs it, every third of the lease. A step that blocks the event loop for longer than the lease (15 seconds by default) stops those renewals. Other instances then see the run as stopped: recovery restarts it elsewhere, and storage refuses the blocked process's result. If the step blocks every time, the next instance can lose the run the same way.
|
|
540
|
+
|
|
541
|
+
Keep the event loop free first. Move CPU-heavy or synchronous work to a worker thread, a child process or another service, or split it into chunks that yield between them:
|
|
542
|
+
|
|
543
|
+
```typescript
|
|
544
|
+
import { Worker } from 'node:worker_threads'
|
|
545
|
+
import { createStep } from '@mastra/core/workflows'
|
|
546
|
+
import { z } from 'zod'
|
|
547
|
+
|
|
548
|
+
export const render = createStep({
|
|
549
|
+
id: 'render',
|
|
550
|
+
inputSchema: z.object({ pages: z.number() }),
|
|
551
|
+
outputSchema: z.object({ pdf: z.string() }),
|
|
552
|
+
execute: async ({ inputData }) =>
|
|
553
|
+
new Promise<{ pdf: string }>((resolve, reject) => {
|
|
554
|
+
const worker = new Worker(new URL('./render-worker.js', import.meta.url), {
|
|
555
|
+
workerData: inputData,
|
|
556
|
+
})
|
|
557
|
+
worker.once('message', resolve)
|
|
558
|
+
worker.once('error', reject)
|
|
559
|
+
}),
|
|
560
|
+
})
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
The worker does the blocking work and sends the step's output back:
|
|
564
|
+
|
|
565
|
+
```javascript
|
|
566
|
+
import { parentPort, workerData } from 'node:worker_threads'
|
|
567
|
+
|
|
568
|
+
// Synchronous work here blocks this thread only, not the event loop that renews the lease.
|
|
569
|
+
const pdf = `report with ${workerData.pages} pages`
|
|
570
|
+
|
|
571
|
+
parentPort.postMessage({ pdf })
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
If the work has to block, split it into several steps that each block for well under half the lease, for example a third of it. On Postgres, two blocks can pass between renewals. Start each blocking step with `await new Promise(resolve => setImmediate(resolve))` too, because stores that don't wait on the network, such as the in-memory store or a local LibSQL file, give the renewal no other chance to run between steps.
|
|
575
|
+
|
|
576
|
+
Raise the lease only when neither is possible. Set `leaseTtlMs` on the workflow, or on one run. This example reuses the `render` step above:
|
|
577
|
+
|
|
578
|
+
```typescript
|
|
579
|
+
import { createWorkflow } from '@mastra/core/workflows'
|
|
580
|
+
import { z } from 'zod'
|
|
581
|
+
import { render } from './render'
|
|
582
|
+
|
|
583
|
+
const report = createWorkflow({
|
|
584
|
+
id: 'report',
|
|
585
|
+
inputSchema: z.object({ pages: z.number() }),
|
|
586
|
+
outputSchema: z.object({ pdf: z.string() }),
|
|
587
|
+
options: { leaseTtlMs: 60_000 },
|
|
588
|
+
})
|
|
589
|
+
.then(render)
|
|
590
|
+
.commit()
|
|
591
|
+
|
|
592
|
+
const run = await report.createRun({ leaseTtlMs: 120_000 })
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
A longer lease delays the recovery of an instance that crashed by the same amount. A run's own `leaseTtlMs` isn't saved with the run, so another instance that restarts it uses the workflow's.
|
|
596
|
+
|
|
597
|
+
When a restart takes over a run whose lease lapsed, it logs a warning and doubles the length of that lease, up to 8 times the run's `leaseTtlMs`. Doubling needs a storage adapter that reports when the lease last changed: the in-memory store, `@mastra/pg` and `@mastra/libsql` today. On other adapters with run-ownership support, the restart uses the base length. A process that went a whole lease without renewing, found by its next renewal or when the run ends, logs one warning per stall with how long that took. Either warning means a step can run again on another instance, so keep steps idempotent.
|
|
598
|
+
|
|
535
599
|
### Restarting an active workflow run with `restart()`
|
|
536
600
|
|
|
537
601
|
Use `restart()` to restart an active workflow run from the last active step. This will resume execution from the last active step, and the workflow will continue from there.
|
|
@@ -149,6 +149,8 @@ Run Mastra as a standalone server and connect your Next.js frontend (with Assist
|
|
|
149
149
|
|
|
150
150
|
Now, the Assistant UI frontend will send chat requests directly to your running Mastra server.
|
|
151
151
|
|
|
152
|
+
> **Note:** This setup doesn't save conversations in [Mastra memory](https://mastra.ai/docs/memory/overview). To save them, send a `memory` object with a `thread` ID for the conversation and a `resource` ID for the user with each request. Visit [Using Mastra Memory](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui) for an example.
|
|
153
|
+
|
|
152
154
|
6. You're ready to connect the pieces! Ensure both the Mastra server and the Assistant UI frontend are running. Start the Next.js development server:
|
|
153
155
|
|
|
154
156
|
```bash
|
|
@@ -164,6 +164,21 @@ import { Component, signal } from '@angular/core'
|
|
|
164
164
|
import { Chat } from '@ai-sdk/angular'
|
|
165
165
|
import { DefaultChatTransport } from 'ai'
|
|
166
166
|
|
|
167
|
+
// Replace with the signed-in user's ID from your auth provider
|
|
168
|
+
const RESOURCE_ID = 'example-user'
|
|
169
|
+
|
|
170
|
+
function getThreadId(): string {
|
|
171
|
+
const key = `mastra-thread-id:${RESOURCE_ID}`
|
|
172
|
+
let threadId = localStorage.getItem(key)
|
|
173
|
+
if (!threadId) {
|
|
174
|
+
threadId = crypto.randomUUID()
|
|
175
|
+
localStorage.setItem(key, threadId)
|
|
176
|
+
}
|
|
177
|
+
return threadId
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const THREAD_ID = getThreadId()
|
|
181
|
+
|
|
167
182
|
@Component({
|
|
168
183
|
selector: 'app-root',
|
|
169
184
|
imports: [JsonPipe],
|
|
@@ -268,6 +283,15 @@ export class App {
|
|
|
268
283
|
readonly chat = new Chat({
|
|
269
284
|
transport: new DefaultChatTransport({
|
|
270
285
|
api: 'http://localhost:4111/chat/weather-agent',
|
|
286
|
+
prepareSendMessagesRequest: ({ messages }) => ({
|
|
287
|
+
body: {
|
|
288
|
+
messages: [messages[messages.length - 1]],
|
|
289
|
+
memory: {
|
|
290
|
+
thread: THREAD_ID,
|
|
291
|
+
resource: RESOURCE_ID,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
}),
|
|
271
295
|
}),
|
|
272
296
|
})
|
|
273
297
|
|
|
@@ -293,6 +317,19 @@ It renders text parts as they arrive and shows tool calls in a collapsible `<det
|
|
|
293
317
|
|
|
294
318
|
> **Note:** Older Angular projects may name the root component file `app.component.ts` and its class `AppComponent`. If you're using an existing project, keep its file and class names so the imports in `src/main.ts` continue to work.
|
|
295
319
|
|
|
320
|
+
### Save the conversation in memory
|
|
321
|
+
|
|
322
|
+
The weather agent has [memory](https://mastra.ai/docs/memory/overview), but it only saves a conversation when a request names one. The `prepareSendMessagesRequest` function adds a `memory` object to every request:
|
|
323
|
+
|
|
324
|
+
- `thread` identifies the conversation. The component creates one ID and keeps it in `localStorage` under a key that includes the resource ID, so reloading the page continues the same conversation. Create a new ID to start a new conversation. Never reuse a thread ID for a different resource: Mastra rejects the request.
|
|
325
|
+
- `resource` identifies the user who owns the conversation. In a real app, take it from your authentication, such as the signed-in user's ID. Don't use one constant for every user in production, or all users share the same memory.
|
|
326
|
+
|
|
327
|
+
Mastra loads earlier messages from memory on the server. The transport only needs to send the newest message. Visit [Using Mastra Memory](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui) for details.
|
|
328
|
+
|
|
329
|
+
> **Note:** A request body is under the client's control. In production, set the resource ID on the server from the authenticated user instead, as described in [Reserved keys](https://mastra.ai/docs/server/request-context).
|
|
330
|
+
|
|
331
|
+
After a reload, the chat starts empty even though the agent remembers the conversation. To show earlier messages, fetch them from `GET http://localhost:4111/api/memory/threads/<thread>/messages?agentId=weather-agent`, read the `messages` array from the response, convert that array with [`toAISdkMessages()`](https://mastra.ai/reference/ai-sdk/to-ai-sdk-messages) using `{ version: 'v7' }` to match the installed AI SDK version, and pass the result to the `Chat` constructor as `messages`.
|
|
332
|
+
|
|
296
333
|
## Test your agent
|
|
297
334
|
|
|
298
335
|
To test your agent with the chat interface, run both the Mastra server and the Angular development server.
|
|
@@ -353,6 +390,8 @@ To test your agent with the chat interface, run both the Mastra server and the A
|
|
|
353
390
|
|
|
354
391
|
4. Try asking about the weather. If your API key is set up correctly, you'll get a response
|
|
355
392
|
|
|
393
|
+
5. Reload the page and ask which city you asked about. The agent answers from memory
|
|
394
|
+
|
|
356
395
|
## Next steps
|
|
357
396
|
|
|
358
397
|
From here, you can extend the project with your own tools and logic:
|
|
@@ -198,8 +198,9 @@ import { toAISdkV5Messages } from '@mastra/ai-sdk/ui'
|
|
|
198
198
|
import { createUIMessageStreamResponse } from 'ai'
|
|
199
199
|
import { mastra } from '@/mastra'
|
|
200
200
|
|
|
201
|
-
const THREAD_ID = '
|
|
202
|
-
|
|
201
|
+
const THREAD_ID = 'weather-chat'
|
|
202
|
+
// Replace with the signed-in user's ID from your auth provider
|
|
203
|
+
const RESOURCE_ID = 'example-user-id'
|
|
203
204
|
|
|
204
205
|
export const POST: APIRoute = async ({ request }) => {
|
|
205
206
|
const params = await request.json()
|
|
@@ -240,6 +241,8 @@ export const GET: APIRoute = async () => {
|
|
|
240
241
|
|
|
241
242
|
The `POST` route accepts a prompt and streams the agent's response back in AI SDK format, while the `GET` route fetches message history from memory so the UI can be hydrated when the client reloads.
|
|
242
243
|
|
|
244
|
+
The `THREAD_ID` identifies the conversation, and the `RESOURCE_ID` identifies the user who owns it. Both are constants here, so the app has a single shared conversation. In a real app, take the resource ID from your authentication, such as the signed-in user's ID, and create a thread ID per conversation. Don't use one resource ID for every user in production, or all users share the same memory. The `GET` route must use the same IDs as the `POST` route to load the right history.
|
|
245
|
+
|
|
243
246
|
## Create a chat component
|
|
244
247
|
|
|
245
248
|
Create `src/components/chat.tsx`:
|