@mastra/core 1.87.0 → 1.88.0-alpha.1
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_ai-v6@0.0.100/dist/index.d.ts +97 -2049
- package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +17 -1
- package/dist/agent/agent.d.ts +10 -2
- package/dist/agent/durable/create-evented-agent.d.ts +2 -1
- package/dist/agent/durable/execution-engine.d.ts +4 -2
- package/dist/agent/durable/index.cjs +3 -2
- package/dist/agent/durable/index.js +3 -2
- package/dist/agent/durable/segment-spans.d.ts +7 -0
- package/dist/agent/durable/stored-signal-drain.d.ts +1 -1
- package/dist/agent/durable/types.d.ts +6 -0
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.js +2 -2
- package/dist/agent/request-context-snapshot.d.ts +5 -0
- package/dist/agent/thread-stream-runtime.d.ts +26 -4
- 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/model-catalog-cache.d.ts +9 -5
- package/dist/agent-controller/session.d.ts +17 -0
- package/dist/{agent-controller-DckvJ7bq.cjs → agent-controller-C-WK9bMA.cjs} +67 -57
- package/dist/{agent-controller-vUU_atR-.js → agent-controller-Wxbc6702.js} +67 -57
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-HAzB0JtC.js → background-tasks-DSMkHpbu.js} +1 -1
- package/dist/{background-tasks-By_1e9Gf.cjs → background-tasks-DcKNctMR.cjs} +1 -1
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/{builder-Dx8GMhFn.cjs → builder-CybmqbZt.cjs} +2 -2
- package/dist/{builder-CmtDqFLe.js → builder-PXwZnGYe.js} +2 -2
- package/dist/capabilities/302ai.json +197 -197
- package/dist/capabilities/abliteratedllm.json +35 -35
- package/dist/capabilities/abliteration-ai.json +10 -10
- package/dist/capabilities/above.json +19 -19
- package/dist/capabilities/adaption.json +15 -15
- package/dist/capabilities/adzuki.json +19 -19
- package/dist/capabilities/agentrouter.json +6 -6
- package/dist/capabilities/agnes.json +4 -4
- package/dist/capabilities/ai-router.json +8 -8
- package/dist/capabilities/aiand.json +25 -17
- package/dist/capabilities/aigrow.json +14 -14
- package/dist/capabilities/aimlapi.json +153 -153
- package/dist/capabilities/aixy.json +20 -20
- package/dist/capabilities/aki-io.json +11 -11
- package/dist/capabilities/alibaba-cn.json +93 -93
- package/dist/capabilities/alibaba-coding-plan-cn.json +4 -4
- package/dist/capabilities/alibaba-coding-plan.json +4 -4
- package/dist/capabilities/alibaba-token-plan-cn.json +47 -47
- package/dist/capabilities/alibaba-token-plan.json +49 -49
- package/dist/capabilities/alibaba.json +72 -72
- package/dist/capabilities/ambient.json +9 -9
- package/dist/capabilities/amd-tokenlab.json +5 -5
- package/dist/capabilities/amd.json +11 -11
- package/dist/capabilities/anthropic.json +40 -40
- package/dist/capabilities/anyapi.json +48 -48
- package/dist/capabilities/apiko.json +5 -5
- package/dist/capabilities/arcee.json +10 -10
- package/dist/capabilities/augure.json +5 -5
- package/dist/capabilities/auriko.json +18 -18
- package/dist/capabilities/bailing.json +4 -4
- package/dist/capabilities/baseten.json +41 -32
- package/dist/capabilities/bee.json +4 -4
- package/dist/capabilities/bothub.json +10 -10
- package/dist/capabilities/boundless.json +33 -33
- package/dist/capabilities/bumo.json +48 -48
- package/dist/capabilities/byteplus.json +35 -35
- package/dist/capabilities/cerebras.json +4 -4
- package/dist/capabilities/cheapaimodel.json +3 -3
- package/dist/capabilities/cheapest-token.json +28 -28
- package/dist/capabilities/chutes.json +43 -41
- package/dist/capabilities/cline-pass.json +33 -33
- package/dist/capabilities/cloudcode.json +7 -7
- package/dist/capabilities/cloudferro-sherlock.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +18 -18
- package/dist/capabilities/commandcode.json +147 -147
- package/dist/capabilities/concentrate.json +288 -279
- package/dist/capabilities/cortecs.json +108 -108
- package/dist/capabilities/crossmodel.json +157 -157
- package/dist/capabilities/crusoe.json +16 -16
- package/dist/capabilities/daoxe.json +9 -9
- package/dist/capabilities/databricks.json +131 -123
- package/dist/capabilities/deepinfra.json +95 -95
- package/dist/capabilities/deepseek.json +2 -2
- package/dist/capabilities/digitalocean.json +114 -115
- package/dist/capabilities/dothoosh.json +32 -32
- package/dist/capabilities/doubleword.json +26 -26
- package/dist/capabilities/edenai.json +298 -280
- package/dist/capabilities/empiriolabs.json +164 -164
- package/dist/capabilities/engy.json +23 -17
- package/dist/capabilities/entrim.json +4 -4
- package/dist/capabilities/evroc.json +17 -17
- package/dist/capabilities/ezkielyna.json +8 -8
- package/dist/capabilities/fastrouter.json +94 -94
- package/dist/capabilities/fireworks-ai.json +106 -95
- package/dist/capabilities/freemodel.json +9 -9
- package/dist/capabilities/friendli.json +31 -10
- package/dist/capabilities/frogbot.json +100 -100
- package/dist/capabilities/gisoo.json +18 -18
- package/dist/capabilities/gmicloud.json +19 -19
- package/dist/capabilities/google.json +59 -59
- package/dist/capabilities/graphn.json +10 -10
- package/dist/capabilities/greenpt.json +31 -31
- package/dist/capabilities/groq.json +5 -5
- package/dist/capabilities/helicone.json +87 -87
- package/dist/capabilities/hostinger-router.json +5 -5
- package/dist/capabilities/hpc-ai.json +9 -9
- package/dist/capabilities/huawei-maas.json +11 -11
- package/dist/capabilities/hubris.json +31 -31
- package/dist/capabilities/huggingface.json +95 -85
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +23 -23
- package/dist/capabilities/impossibl.json +157 -157
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +4 -4
- package/dist/capabilities/inco.json +2 -2
- package/dist/capabilities/infer.json +11 -11
- package/dist/capabilities/inferall.json +8 -8
- package/dist/capabilities/inference-coop.json +6 -6
- package/dist/capabilities/inferenceapis.json +25 -25
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +12 -12
- package/dist/capabilities/inferx.json +2 -2
- package/dist/capabilities/io-net.json +5 -5
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +43 -43
- package/dist/capabilities/jalapeno.json +10 -10
- package/dist/capabilities/jiekou.json +34 -34
- package/dist/capabilities/jzstoken.json +43 -43
- package/dist/capabilities/keln.json +21 -21
- package/dist/capabilities/kenari.json +120 -135
- package/dist/capabilities/kilo.json +671 -630
- package/dist/capabilities/kimchi.json +16 -16
- package/dist/capabilities/kimi-code-plan-cn.json +7 -7
- package/dist/capabilities/kimi-code-plan-global.json +7 -7
- package/dist/capabilities/kitani.json +2 -2
- package/dist/capabilities/klavo.json +25 -25
- package/dist/capabilities/korouter.json +31 -31
- package/dist/capabilities/kunavo.json +9 -9
- package/dist/capabilities/liquid.json +10 -10
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +944 -906
- package/dist/capabilities/llmgateway.json +359 -348
- package/dist/capabilities/llmtr.json +25 -25
- package/dist/capabilities/logits.json +2 -2
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +64 -64
- package/dist/capabilities/lyceum.json +14 -14
- package/dist/capabilities/melious.json +10 -10
- package/dist/capabilities/merge-gateway.json +268 -260
- package/dist/capabilities/meta.json +10 -10
- package/dist/capabilities/minimax-cn-coding-plan.json +5 -5
- package/dist/capabilities/minimax-cn.json +5 -5
- package/dist/capabilities/minimax-coding-plan.json +5 -5
- package/dist/capabilities/minimax.json +5 -5
- package/dist/capabilities/mistral.json +23 -15
- package/dist/capabilities/mixlayer.json +5 -5
- package/dist/capabilities/modal.json +11 -11
- package/dist/capabilities/model-oracle-ai.json +22 -22
- package/dist/capabilities/modelis.json +21 -21
- package/dist/capabilities/modelscope.json +2 -2
- package/dist/capabilities/modular.json +15 -15
- package/dist/capabilities/moneo.json +7 -7
- package/dist/capabilities/moonshotai-cn.json +6 -6
- package/dist/capabilities/moonshotai.json +6 -6
- package/dist/capabilities/morph.json +19 -19
- package/dist/capabilities/munito-eu.json +4 -4
- package/dist/capabilities/munito.json +5 -5
- package/dist/capabilities/nan.json +21 -21
- package/dist/capabilities/nano-gpt.json +594 -598
- package/dist/capabilities/nearai.json +121 -121
- package/dist/capabilities/nebius.json +42 -34
- package/dist/capabilities/neon.json +125 -125
- package/dist/capabilities/neuralwatt.json +41 -41
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +136 -136
- package/dist/capabilities/nvidia.json +29 -29
- package/dist/capabilities/oathbreaker.json +4 -4
- package/dist/capabilities/obscurify.json +24 -24
- package/dist/capabilities/oci.json +7 -7
- package/dist/capabilities/ofox.json +251 -251
- package/dist/capabilities/ollama-cloud.json +57 -57
- package/dist/capabilities/openai.json +56 -59
- package/dist/capabilities/opencode-go.json +93 -84
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +534 -532
- package/dist/capabilities/opper.json +31 -31
- package/dist/capabilities/orcarouter.json +292 -276
- package/dist/capabilities/outerlabs.json +32 -32
- package/dist/capabilities/ovhcloud.json +23 -23
- package/dist/capabilities/perplexity-agent.json +64 -64
- package/dist/capabilities/phala.json +31 -31
- package/dist/capabilities/poe.json +139 -139
- package/dist/capabilities/poolside.json +2 -2
- package/dist/capabilities/powerspring.json +8 -8
- package/dist/capabilities/primalabs.json +8 -8
- package/dist/capabilities/prime.json +133 -125
- package/dist/capabilities/privatemode-ai.json +4 -4
- package/dist/capabilities/proxystacks.json +3 -3
- package/dist/capabilities/qiniu-ai.json +14 -14
- package/dist/capabilities/refuseless.json +6 -6
- package/dist/capabilities/regolo-ai.json +8 -8
- package/dist/capabilities/requesty.json +201 -201
- package/dist/capabilities/ruapi.json +24 -24
- package/dist/capabilities/runcrate.json +8 -8
- package/dist/capabilities/runinfra.json +13 -13
- package/dist/capabilities/sakana.json +2 -2
- package/dist/capabilities/sandbase.json +23 -23
- package/dist/capabilities/sarvam.json +11 -11
- package/dist/capabilities/scaleway.json +15 -15
- package/dist/capabilities/scnet-token-plan.json +13 -13
- package/dist/capabilities/scx-ai.json +23 -23
- package/dist/capabilities/sensenova.json +13 -13
- package/dist/capabilities/siliconflow-cn.json +46 -46
- package/dist/capabilities/siliconflow.json +57 -57
- package/dist/capabilities/snowflake-cortex.json +21 -21
- package/dist/capabilities/sokkan.json +6 -6
- package/dist/capabilities/sparrowcodes.json +19 -19
- package/dist/capabilities/standardcompute.json +69 -69
- package/dist/capabilities/steadyrouter.json +40 -40
- package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
- package/dist/capabilities/stepfun-ai.json +6 -6
- package/dist/capabilities/stepfun-step-plan.json +6 -6
- package/dist/capabilities/stepfun.json +6 -6
- package/dist/capabilities/stepping-stone.json +21 -21
- package/dist/capabilities/superbot-gg.json +4 -4
- package/dist/capabilities/synthetic.json +10 -10
- package/dist/capabilities/synthorai.json +24 -24
- package/dist/capabilities/teamorouter.json +14 -14
- package/dist/capabilities/teapot-router.json +4 -4
- package/dist/capabilities/tencent-token-plan-intl.json +16 -16
- package/dist/capabilities/tencent-token-plan.json +35 -35
- package/dist/capabilities/tencent-tokenhub.json +44 -44
- package/dist/capabilities/tensorx.json +49 -49
- package/dist/capabilities/the-grid-ai.json +28 -28
- package/dist/capabilities/thinkingmachines.json +76 -76
- package/dist/capabilities/tinfoil.json +9 -9
- package/dist/capabilities/togetherai.json +55 -55
- package/dist/capabilities/tokengo.json +24 -24
- package/dist/capabilities/tokenharbor.json +214 -214
- package/dist/capabilities/tokenify.json +8 -8
- package/dist/capabilities/trustedrouter.json +6 -6
- package/dist/capabilities/trustedtokens.json +19 -19
- package/dist/capabilities/umans-ai-coding-plan.json +11 -11
- package/dist/capabilities/umans-ai.json +11 -11
- package/dist/capabilities/uncensuredai.json +5 -5
- package/dist/capabilities/unrestricted.json +6 -6
- package/dist/capabilities/uplinkswitch.json +18 -18
- package/dist/capabilities/upstage.json +2 -2
- package/dist/capabilities/vancine.json +12 -12
- package/dist/capabilities/vercel.json +562 -549
- package/dist/capabilities/verda.json +4 -4
- package/dist/capabilities/vivgrid.json +62 -62
- package/dist/capabilities/volcengine-coding-plan.json +24 -24
- package/dist/capabilities/volcengine.json +31 -31
- package/dist/capabilities/vultr.json +18 -18
- package/dist/capabilities/wafer.ai.json +18 -18
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +9 -9
- package/dist/capabilities/wandb.json +20 -20
- package/dist/capabilities/watt.json +20 -20
- package/dist/capabilities/xai.json +6 -6
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
- package/dist/capabilities/xiaomi.json +3 -3
- package/dist/capabilities/xpersona.json +13 -13
- package/dist/capabilities/xxapi.json +27 -27
- package/dist/capabilities/zai-coding-plan.json +15 -15
- package/dist/capabilities/zai.json +29 -29
- package/dist/capabilities/zenifra.json +22 -22
- package/dist/capabilities/zenmux.json +185 -185
- package/dist/capabilities/zerogpu.json +14 -14
- package/dist/capabilities/zhipuai-coding-plan.json +3 -3
- package/dist/capabilities/zhipuai.json +27 -27
- package/dist/capabilities/zro.json +4 -4
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-DChC1kXm.js → channels-Cxy4jW11.js} +1 -1
- package/dist/{channels-BamLzaJG.cjs → channels-DNOI029U.cjs} +1 -1
- package/dist/coding-agent/index.cjs +1 -1
- package/dist/coding-agent/index.js +1 -1
- package/dist/{constants-Dro9fuhk.js → constants-C2Q-ZI5d.js} +6 -0
- package/dist/{constants-B2FVV_2e.cjs → constants-DPHwzvan.cjs} +6 -0
- package/dist/datasets/index.cjs +2 -2
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1158 -1153
- package/dist/docs/references/docs-agents-human-in-the-loop.md +1 -1
- package/dist/docs/references/docs-agents-resumable-streams.md +3 -3
- package/dist/docs/references/docs-channels.md +50 -3
- package/dist/docs/references/docs-deployment-workers.md +10 -4
- package/dist/docs/references/docs-develop.md +2 -0
- package/dist/docs/references/docs-evals-experiments.md +2 -0
- package/dist/docs/references/docs-guides-build-an-eval-loop.md +5 -1
- package/dist/docs/references/docs-guides-overview.md +2 -1
- package/dist/docs/references/docs-harness-durable-agents.md +17 -15
- package/dist/docs/references/docs-knowledge-importers.md +11 -1
- package/dist/docs/references/docs-knowledge-scopes-and-access.md +26 -0
- package/dist/docs/references/docs-memory-message-history.md +24 -16
- package/dist/docs/references/docs-memory-overview.md +21 -17
- package/dist/docs/references/docs-sandbox-overview.md +12 -10
- package/dist/docs/references/docs-server-mcp.md +68 -0
- package/dist/docs/references/docs-server-pubsub.md +25 -16
- package/dist/docs/references/docs-signals-running-across-processes.md +9 -3
- package/dist/docs/references/docs-signals-sending-signals.md +1 -1
- package/dist/docs/references/docs-workflows-control-flow.md +20 -0
- package/dist/docs/references/docs-workflows-overview.md +3 -3
- package/dist/docs/references/integrations-observability-arthur.md +1 -1
- package/dist/docs/references/reference-agent-controller-agent-controller-class.md +1 -1
- package/dist/docs/references/reference-agent-controller-session.md +9 -0
- package/dist/docs/references/reference-agents-agent.md +3 -1
- package/dist/docs/references/reference-agents-durable-agent.md +3 -3
- package/dist/docs/references/reference-configuration.md +60 -0
- package/dist/docs/references/reference-knowledge-knowledge-class.md +1 -1
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +1 -1
- package/dist/docs/references/reference-observability-tracing-bridges-datadog.md +12 -11
- package/dist/docs/references/reference-processors-processor-interface.md +1 -1
- package/dist/docs/references/reference-pubsub-base.md +1 -1
- package/dist/docs/references/reference-pubsub-caching-pubsub.md +1 -1
- package/dist/docs/references/reference-pubsub-google-cloud-pubsub.md +13 -7
- package/dist/docs/references/reference-pubsub-lease-provider.md +4 -0
- package/dist/docs/references/reference-pubsub-redis-streams.md +18 -9
- package/dist/docs/references/reference-pubsub-valkey-streams.md +25 -7
- package/dist/docs/references/reference-storage-overview.md +1 -1
- package/dist/docs/references/reference-voice-overview.md +0 -27
- package/dist/docs/references/reference-workflows-step.md +1 -1
- package/dist/docs/references/reference-workspace-workspace-class.md +3 -1
- package/dist/evals/index.cjs +2 -2
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +2 -2
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/events/caching-pubsub.d.ts +3 -11
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/pubsub.d.ts +2 -1
- package/dist/{execution-fence-BBKnrhWR.cjs → execution-fence-C1nozqra.cjs} +1118 -309
- package/dist/{execution-fence--VdnD7p4.js → execution-fence-pJB0qqFJ.js} +1107 -310
- 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/knowledge/importers/local-host.d.ts +2 -1
- package/dist/knowledge/importers/sink.d.ts +6 -0
- package/dist/knowledge/importers/types.d.ts +5 -0
- package/dist/knowledge/index.cjs +105 -20
- package/dist/knowledge/index.js +105 -21
- package/dist/knowledge/links.d.ts +19 -6
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/gateways/mastra.d.ts +19 -0
- package/dist/llm/model/gateways/refreshing-cache.d.ts +52 -0
- package/dist/llm/model/provider-types.generated.d.ts +7574 -7544
- package/dist/llm/reasoning/account-switch.d.ts +50 -0
- package/dist/llm/reasoning/index.cjs +65 -0
- package/dist/llm/reasoning/index.d.ts +1 -0
- package/dist/llm/reasoning/index.js +61 -1
- package/dist/{llm-DknPJDW6.cjs → llm-VhPqyULU.cjs} +2 -2
- package/dist/{llm-ccA_1Q-H.js → llm-_z1lIfCN.js} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/loop/suspended-run-auto-resume.d.ts +15 -0
- package/dist/loop/workflows/agentic-execution/background-task-check-step.d.ts +4 -0
- package/dist/loop/workflows/agentic-execution/goal-step.d.ts +4 -0
- package/dist/loop/workflows/agentic-execution/is-task-complete-step.d.ts +4 -0
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +4 -0
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +2 -0
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +1 -1
- package/dist/loop/workflows/schema.d.ts +13 -0
- package/dist/{manager-D9F0i7O2.cjs → manager-BT70SgFz.cjs} +3 -3
- package/dist/{manager-DWX6-Cx4.js → manager-C3Kx39p_.js} +3 -3
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.d.ts +35 -11
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-BzWL4xI8.cjs → mastra-CQGD2RoN.cjs} +108 -20
- package/dist/{mastra-oUDN81l8.js → mastra-fJ0iKYGP.js} +108 -20
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/{model-BnD7SPlA.cjs → model-D9NDbf-e.cjs} +1 -1
- package/dist/{model-BwxfS6T_.js → model-DmBDBf-q.js} +1 -1
- package/dist/{netlify-CS0VDbb9.cjs → netlify-DNaNhels.cjs} +1 -1
- package/dist/{netlify-DcY9gHCJ.js → netlify-_yV5Nwud.js} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/{output-helpers-k2-48ssH.js → output-helpers-D-qplq22.js} +13 -15
- package/dist/{output-helpers-By5FbLpp.cjs → output-helpers-D4O_oFne.cjs} +12 -14
- 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.js +2 -2
- package/dist/{provider-registry-BvbEoScB.js → provider-registry-C4tv__fr.js} +22203 -21980
- package/dist/{provider-registry-OggbU6OE.cjs → provider-registry-_BUQuSKb.cjs} +21869 -21628
- package/dist/provider-registry.json +22243 -22188
- package/dist/{registry-generator-BFOQQHyt.js → registry-generator-CenhQnEi.js} +1 -1
- package/dist/{registry-generator-CDaf48a6.cjs → registry-generator-D7lsLJC-.cjs} +1 -1
- package/dist/{rehydrate-CFoKaNlm.js → rehydrate-CuWN_5No.js} +2 -2
- package/dist/{rehydrate-QeS0NjGw.cjs → rehydrate-SpC_gJCY.cjs} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{scheduler-0ShtMM1I.js → scheduler-D1qdie5k.js} +4 -2
- package/dist/{scheduler-CMjK0LoQ.cjs → scheduler-DE5lcHJA.cjs} +4 -2
- package/dist/server/index.d.ts +1 -1
- package/dist/server/types.d.ts +57 -0
- package/dist/storage/constants.cjs +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +11 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +4 -0
- package/dist/storage/domains/knowledge/pages.d.ts +1 -1
- package/dist/storage/domains/memory/base.d.ts +6 -1
- package/dist/storage/domains/observability/tracing.d.ts +12 -0
- package/dist/storage/index.cjs +4 -3
- package/dist/storage/index.js +4 -4
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-D2rv1Ut1.js → stream-BfSwqzPi.js} +1 -1
- package/dist/{stream-CNqAlDJF.cjs → stream-CW3d1Xg6.cjs} +1 -1
- package/dist/test-utils/llm-mock.cjs +1 -1
- 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-CFsOjueT.js → tool-loop-agent-B4_o4-Me.js} +3 -3
- package/dist/{tool-loop-agent-Dusqj7-j.cjs → tool-loop-agent-JN_oKyfY.cjs} +3 -3
- package/dist/{utils-CIuOHPoS.cjs → utils-Bq606mC8.cjs} +1 -1
- package/dist/{utils-DLnCt6E9.js → utils-CnpMuTyD.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-1zReLtWc.cjs → validate-CFv6HWXx.cjs} +1 -1
- package/dist/{validate-ShLcQTA5.js → validate-Db2C7Sj_.js} +1 -1
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/worker/workers/orchestration-worker.d.ts +13 -0
- package/dist/{worker-BPNrwCFs.cjs → worker-CNIBQPQy.cjs} +117 -32
- package/dist/{worker-CQ8rTJwQ.cjs → worker-IZeSOZjg.cjs} +2 -2
- package/dist/{worker-CKcQcPl8.js → worker-UXFAgWOK.js} +2 -2
- package/dist/{worker-ngt-F1Iv.js → worker-X0fAJfcx.js} +117 -32
- package/dist/{workflow-B_e5wMmz.cjs → workflow-CMLLlVDc.cjs} +4 -4
- package/dist/{workflow-XDIVRsu4.js → workflow-DfXq2p2f.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/evented/setup-warning.d.ts +20 -0
- package/dist/workflows/index.cjs +5 -5
- package/dist/workflows/index.js +5 -5
- package/dist/workflows/scheduler/types.d.ts +3 -0
- package/package.json +8 -8
- package/src/llm/model/provider-types.generated.d.ts +7574 -7544
|
@@ -537,7 +537,7 @@ For automatic tool resumption to work:
|
|
|
537
537
|
| Manual (`resumeStream()`) | Programmatic control, webhooks, button clicks, external triggers |
|
|
538
538
|
| Automatic (`autoResumeSuspendedTools`) | Conversational flows where users provide resume data in natural language |
|
|
539
539
|
|
|
540
|
-
Both approaches work with the same tool definitions. Automatic resumption triggers only when suspended tools exist in the message history and the user sends a new message on the same thread.
|
|
540
|
+
Both approaches work with the same tool definitions. Automatic resumption triggers only when suspended tools exist in the message history and the user sends a new message on the same thread. A message sent with `sendMessage()` or queued with `queueMessage()` while the tool is suspended starts that turn. A tool waiting for approval keeps both waiting until it's approved or declined.
|
|
541
541
|
|
|
542
542
|
## Resuming after a restart
|
|
543
543
|
|
|
@@ -23,7 +23,7 @@ Mastra resolves the stream transport and replay cache separately:
|
|
|
23
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
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
25
|
|
|
26
|
-
|
|
26
|
+
The replay cache numbers each run's events and holds the run's ownership record. With more than one process, set up a PubSub backend and a server cache that every process shares in the same step, as in [distributed deployments](https://mastra.ai/docs/server/pubsub). With the default in-memory cache, only the process that started a run can serve it to the observe and abort routes, and evented steps that run on another process publish events that an offset can't skip.
|
|
27
27
|
|
|
28
28
|
## Configure streams
|
|
29
29
|
|
|
@@ -46,7 +46,7 @@ export const supportAgent = new Agent({
|
|
|
46
46
|
|
|
47
47
|
| Option | Default | Description |
|
|
48
48
|
| ------------------ | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
-
| `pubsub` | `mastra.pubsub` | Bus the run is published on. Use a shared bus to follow runs across processes.
|
|
49
|
+
| `pubsub` | `mastra.pubsub` | Bus the run is published on. Use a shared bus and a shared cache to follow runs across processes. |
|
|
50
50
|
| `cache` | `mastra.serverCache`, else an in-memory cache | Replay cache. Pass `false` to disable this cache. Transports such as Redis Streams can still replay retained history. |
|
|
51
51
|
| `shouldCache` | Every topic | Return `false` for a topic to skip caching it. |
|
|
52
52
|
| `cleanupTimeoutMs` | `30000` | How long after it finishes a run is cleared. `0` turns off this timer only. The cache's own expiry and eviction still apply. |
|
|
@@ -141,7 +141,7 @@ When several servers share a PubSub and cache, such as Redis, a run started on o
|
|
|
141
141
|
- Each run writes an ownership record (agent, run, resource and thread) to the cache before its first event. The server's observe and abort routes check the caller against that record, so tenant and thread checks hold on every server.
|
|
142
142
|
- An unknown, expired or evicted record returns 404. If the cache can't be read, the routes return 503 rather than skipping the check.
|
|
143
143
|
- With `durable: { cache: false }` the record is kept in `mastra.serverCache`, so ownership still works across servers. Replay then depends on the PubSub: one that keeps history, like Redis Streams, replays it, and an in-process bus delivers only live events.
|
|
144
|
-
- With the default in-memory cache
|
|
144
|
+
- With the default in-memory cache, each server keeps its own records, so only the server that started a run can observe or stop it through these routes, even when the PubSub is shared.
|
|
145
145
|
|
|
146
146
|
## Related
|
|
147
147
|
|
|
@@ -184,7 +184,7 @@ Set `toolDisplay: 'text'` on an adapter to render tool calls as plain text inste
|
|
|
184
184
|
|
|
185
185
|
### Custom action handling
|
|
186
186
|
|
|
187
|
-
Use `handlers.onAction` to handle button clicks and select changes from cards you post yourself. The handler is called with the Chat SDK action event and the default handler, plus the same `ctx` the other channel handlers receive. Values you set on `ctx.requestContext` before delegating carry through to the resumed tool call. The default handler processes the built-in Approve and Deny buttons and ignores every other action ID, so call it for events you don't handle to keep tool approval working:
|
|
187
|
+
Use `handlers.onAction` to handle button clicks and select changes from cards you post yourself. The handler is called with the Chat SDK action event and the default handler, plus the same `ctx` the other channel handlers receive. Values you set on `ctx.requestContext` before delegating carry through to the resumed tool call. The default handler processes the built-in Approve and Deny buttons and the Continue button (`CONTINUE_RUN_ACTION_ID`), and ignores every other action ID, so call it for events you don't handle to keep tool approval and run continuation working:
|
|
188
188
|
|
|
189
189
|
```typescript
|
|
190
190
|
channels: {
|
|
@@ -294,6 +294,22 @@ Messages that come in over a channel carry a `platform` attribute (for example `
|
|
|
294
294
|
|
|
295
295
|
Replies on those runs go through the same adapter path as replies to a message. Mastra remembers the last person who wrote in the thread, so adapters that need a recipient, like Slack's native streaming, work the same way.
|
|
296
296
|
|
|
297
|
+
### Subscribe to threads the bot started
|
|
298
|
+
|
|
299
|
+
A thread the bot opened itself, such as a scheduled digest, has no Mastra thread until someone mentions the bot in it. Call `subscribeThread()` after posting to create that mapping and subscribe to the thread, so replies reach the agent without a mention. An existing mapping is reused and keeps its original owner.
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
const channels = agent.getChannels()!
|
|
303
|
+
const sent = await channels.sdk!.channel('slack:C123ABC').post('Daily digest is ready.')
|
|
304
|
+
|
|
305
|
+
await channels.subscribeThread({
|
|
306
|
+
thread: channels.sdk!.thread(sent.threadId),
|
|
307
|
+
resourceId: 'digest-bot',
|
|
308
|
+
})
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
`resourceId` owns the Mastra thread if a new one is created. Pass `threadId` to choose its ID, otherwise Mastra generates one.
|
|
312
|
+
|
|
297
313
|
## Multi-user awareness
|
|
298
314
|
|
|
299
315
|
In group conversations, Mastra prefixes each message with the sender's name and platform ID so the agent can distinguish between speakers:
|
|
@@ -360,6 +376,31 @@ channels: {
|
|
|
360
376
|
},
|
|
361
377
|
```
|
|
362
378
|
|
|
379
|
+
To let people continue a stopped run from the chat, return a card with a `CONTINUE_RUN_ACTION_ID` button from `formatError`. Pressing the button sends `Continue.` to the agent from the person who pressed it, through `onSubscribedMessage`, the same way a reply in the thread would:
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
import { CONTINUE_RUN_ACTION_ID } from '@mastra/core/channels'
|
|
383
|
+
import { Actions, Button, Card, CardText } from 'chat'
|
|
384
|
+
|
|
385
|
+
channels: {
|
|
386
|
+
adapters: {
|
|
387
|
+
slack: {
|
|
388
|
+
adapter: createSlackAdapter(),
|
|
389
|
+
formatError: error =>
|
|
390
|
+
Card({
|
|
391
|
+
title: 'Run stopped',
|
|
392
|
+
children: [
|
|
393
|
+
CardText(error.message),
|
|
394
|
+
Actions([Button({ id: CONTINUE_RUN_ACTION_ID, label: 'Continue' })]),
|
|
395
|
+
],
|
|
396
|
+
}),
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
The button does nothing when `onSubscribedMessage` or `onAction` is set to `false`.
|
|
403
|
+
|
|
363
404
|
Platform retries sometimes deliver an event more than once. Adapters use channel state for deduplication, which [storage](https://mastra.ai/docs/storage) can preserve across restarts. Because this protection is best effort, custom-handler side effects should be idempotent so duplicate delivery can't repeat work such as ticket creation.
|
|
364
405
|
|
|
365
406
|
### Batched messages
|
|
@@ -474,11 +515,13 @@ The default in-memory pub/sub can't cross instance boundaries, so on serverless
|
|
|
474
515
|
|
|
475
516
|
Without a shared pub/sub, that instance can't reach the active run and starts its own, leaving the original run untouched and the thread processed twice.
|
|
476
517
|
|
|
477
|
-
Configure a shared pub/sub backed by Redis Streams on the `Mastra` instance so leases and signals coordinate across instances:
|
|
518
|
+
Configure a shared pub/sub backed by Redis Streams on the `Mastra` instance so leases and signals coordinate across instances, and a server cache on the same Redis so every instance reads the same agent run streams:
|
|
478
519
|
|
|
479
520
|
```typescript
|
|
480
521
|
import { Mastra } from '@mastra/core'
|
|
522
|
+
import { RedisServerCache } from '@mastra/redis'
|
|
481
523
|
import { RedisStreamsPubSub } from '@mastra/redis-streams'
|
|
524
|
+
import { Redis } from 'ioredis'
|
|
482
525
|
import { yourAgent } from './agents/your-agent'
|
|
483
526
|
|
|
484
527
|
export const mastra = new Mastra({
|
|
@@ -487,10 +530,14 @@ export const mastra = new Mastra({
|
|
|
487
530
|
url: process.env.REDIS_URL,
|
|
488
531
|
keyPrefix: 'mastra:my-app',
|
|
489
532
|
}),
|
|
533
|
+
cache: new RedisServerCache(
|
|
534
|
+
{ client: new Redis(process.env.REDIS_URL!) },
|
|
535
|
+
{ keyPrefix: 'mastra:my-app:cache:' },
|
|
536
|
+
),
|
|
490
537
|
})
|
|
491
538
|
```
|
|
492
539
|
|
|
493
|
-
Vercel's managed Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
|
|
540
|
+
Replicas of one deployment use the same `keyPrefix` values, and another deployment on the same Redis needs its own on both the pubsub and the cache. Vercel's managed Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
|
|
494
541
|
|
|
495
542
|
## Other adapters
|
|
496
543
|
|
|
@@ -85,18 +85,20 @@ The server generated by `mastra build` starts these workers automatically. If yo
|
|
|
85
85
|
|
|
86
86
|
This setup needs no external infrastructure beyond your storage adapter. It doesn't survive process crashes, and you can't scale individual components.
|
|
87
87
|
|
|
88
|
-
> **Warning:** The in-memory PubSub delivers events only inside the process that published them. Running several Mastra instances on one storage with it isn't supported for evented workflows or agents. Each instance restarts the others' active evented workflow runs when it boots. A multi-instance deployment needs a PubSub backend that redelivers unacknowledged events
|
|
88
|
+
> **Warning:** The in-memory PubSub delivers events only inside the process that published them. Running several Mastra instances on one storage with it isn't supported for evented workflows or agents. Each instance restarts the others' active evented workflow runs when it boots. A multi-instance deployment needs a PubSub backend that redelivers unacknowledged events, a storage adapter with workflow step guards, and, for evented agents, a server cache that every instance shares. See [evented workflows and agents](https://mastra.ai/docs/server/pubsub).
|
|
89
89
|
|
|
90
90
|
### Split processes
|
|
91
91
|
|
|
92
|
-
To run workers in their own processes, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
|
|
92
|
+
To run workers in their own processes, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend with a server cache that every process shares, and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
|
|
93
93
|
|
|
94
94
|
**Redis Streams + PostgreSQL**:
|
|
95
95
|
|
|
96
96
|
```typescript
|
|
97
97
|
import { Mastra } from '@mastra/core/mastra'
|
|
98
98
|
import { RedisStreamsPubSub } from '@mastra/redis-streams'
|
|
99
|
+
import { RedisServerCache } from '@mastra/redis'
|
|
99
100
|
import { PostgresStore } from '@mastra/pg'
|
|
101
|
+
import { Redis } from 'ioredis'
|
|
100
102
|
|
|
101
103
|
export const mastra = new Mastra({
|
|
102
104
|
storage: new PostgresStore({
|
|
@@ -105,6 +107,7 @@ export const mastra = new Mastra({
|
|
|
105
107
|
pubsub: new RedisStreamsPubSub({
|
|
106
108
|
url: process.env.REDIS_URL!,
|
|
107
109
|
}),
|
|
110
|
+
cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
|
|
108
111
|
})
|
|
109
112
|
```
|
|
110
113
|
|
|
@@ -114,6 +117,8 @@ export const mastra = new Mastra({
|
|
|
114
117
|
import { Mastra } from '@mastra/core/mastra'
|
|
115
118
|
import { GoogleCloudPubSub } from '@mastra/google-cloud-pubsub'
|
|
116
119
|
import { LibSQLStore } from '@mastra/libsql'
|
|
120
|
+
import { RedisServerCache } from '@mastra/redis'
|
|
121
|
+
import { Redis } from 'ioredis'
|
|
117
122
|
|
|
118
123
|
export const mastra = new Mastra({
|
|
119
124
|
storage: new LibSQLStore({
|
|
@@ -122,14 +127,15 @@ export const mastra = new Mastra({
|
|
|
122
127
|
pubsub: new GoogleCloudPubSub({
|
|
123
128
|
projectId: process.env.GCP_PROJECT_ID!,
|
|
124
129
|
}),
|
|
130
|
+
cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
|
|
125
131
|
})
|
|
126
132
|
```
|
|
127
133
|
|
|
128
|
-
Any [supported storage backend](https://mastra.ai/reference/workers/overview) works. Swap the storage adapter for your preferred database.
|
|
134
|
+
Any [supported storage backend](https://mastra.ai/reference/workers/overview) works. Swap the storage adapter for your preferred database. Google Cloud Pub/Sub has no matching server cache, so the second example can use any cache that every process shares: `RedisServerCache` from `@mastra/redis` as shown, `ValkeyServerCache` from `@mastra/valkey`, or `ConvexServerCache` from `@mastra/convex`.
|
|
129
135
|
|
|
130
136
|
Run the same build artifact in multiple containers, each with a different [`MASTRA_WORKERS`](https://mastra.ai/reference/workers/overview) value to control which worker starts in each process.
|
|
131
137
|
|
|
132
|
-
Split deployments require a distributed PubSub backend ([`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), [`ValkeyStreamsPubSub`](https://mastra.ai/reference/pubsub/valkey-streams), or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)), a shared [storage backend](https://mastra.ai/reference/workers/overview), and network connectivity between the orchestration worker and the API. Messages sent to a running evented agent reach a run on a worker only when the agent's memory uses [storage that shares pending signals across processes](https://mastra.ai/docs/server/pubsub).
|
|
138
|
+
Split deployments require a distributed PubSub backend ([`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), [`ValkeyStreamsPubSub`](https://mastra.ai/reference/pubsub/valkey-streams), or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)), a shared [storage backend](https://mastra.ai/reference/workers/overview), a shared server cache, and network connectivity between the orchestration worker and the API. The cache holds each agent run's numbered stream events and ownership record, so a client can observe and reconnect to a run through any process. Messages sent to a running evented agent reach a run on a worker only when the agent's memory uses [storage that shares pending signals across processes](https://mastra.ai/docs/server/pubsub).
|
|
133
139
|
|
|
134
140
|
### Select workers
|
|
135
141
|
|
|
@@ -100,6 +100,8 @@ yarn dlx skills update mastra
|
|
|
100
100
|
bun x skills update mastra
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
From version 1.87, the `@mastra/core` package includes the `mastra` skill, so tools that sync skills from installed packages, such as [`skills`](https://github.com/vercel-labs/skills#sync-skills-from-npm-packages) and [pnpm](https://pnpm.io/agent-skills), can use it.
|
|
104
|
+
|
|
103
105
|
> **Note:** When you create a project with [create mastra](https://mastra.ai/docs), the command automatically installs the Mastra skills so your coding agent can discover and use them.
|
|
104
106
|
|
|
105
107
|
### Mastra CLI
|
|
@@ -246,6 +246,8 @@ Omitting `scorerIds` from an update preserves its current value. Each item versi
|
|
|
246
246
|
|
|
247
247
|
Mastra resolves scorer IDs the same way at every level by checking registered scorers first and then asking the Editor to load a stored scorer, so stored scorers work even in a durable run's worker that never loaded them. Mastra doesn't resolve IDs from lower-priority sources that the precedence rules ignore.
|
|
248
248
|
|
|
249
|
+
When an Editor is configured, creating an experiment pins the current version of every stored scorer it can use, at the experiment, dataset, and item level. Each item is scored with the pinned version, even if someone edits the scorer while the experiment runs. Scorers registered in code aren't versioned, so they aren't pinned.
|
|
250
|
+
|
|
249
251
|
An unknown ID in the experiment's `scorers` option rejects `startExperiment()`, `startExperimentAsync()`, or `createExperiment()` with the `EXPERIMENT_SCORER_NOT_FOUND` code before Mastra creates the experiment. The server returns a `400` response for this error.
|
|
250
252
|
|
|
251
253
|
If an item's scorer can't be found once the experiment is running, that item fails with the `EXPERIMENT_ITEM_SCORER_NOT_FOUND` code. This happens for a stale item-level or dataset-level ID, or for a scorer deleted after the experiment started. Mastra skips target execution without retrying that item, while the rest of the experiment continues.
|
|
@@ -392,4 +392,8 @@ const toneOfVoice = createRubricScorer({
|
|
|
392
392
|
|
|
393
393
|
### Limit response length
|
|
394
394
|
|
|
395
|
-
Use `checks.matches(/^[\s\S]{1,1000}$/)` to require an answer between 1 and 1,000 characters. Choose a limit appropriate to the task. See [Text checks](https://mastra.ai/docs/evals/quick-checks).
|
|
395
|
+
Use `checks.matches(/^[\s\S]{1,1000}$/)` to require an answer between 1 and 1,000 characters. Choose a limit appropriate to the task. See [Text checks](https://mastra.ai/docs/evals/quick-checks).
|
|
396
|
+
|
|
397
|
+
### Test stateful agents
|
|
398
|
+
|
|
399
|
+
When an agent has memory, context stored during one test case can leak into the next. See [Testing stateful agents](https://mastra.ai/docs/guides/testing-stateful-agents) to isolate threads and resources, seed known memory, and check what the agent stores.
|
|
@@ -12,4 +12,5 @@ These guides explain how Mastra's features work together when building AI applic
|
|
|
12
12
|
- [Authentication and identity](https://mastra.ai/docs/guides/authentication-identity)
|
|
13
13
|
- [MCP authentication](https://mastra.ai/docs/guides/mcp-authentication-authorization)
|
|
14
14
|
- [Streaming](https://mastra.ai/docs/guides/streaming)
|
|
15
|
-
- [Build an eval loop](https://mastra.ai/docs/guides/build-an-eval-loop)
|
|
15
|
+
- [Build an eval loop](https://mastra.ai/docs/guides/build-an-eval-loop)
|
|
16
|
+
- [Testing stateful agents](https://mastra.ai/docs/guides/testing-stateful-agents)
|
|
@@ -68,17 +68,17 @@ A durable agent adds three layers on top of a regular agent:
|
|
|
68
68
|
|
|
69
69
|
2. **PubSub streaming**: The loop publishes chunks to a PubSub topic keyed by the run ID. The caller subscribes to that topic and pipes the chunks into a `ReadableStream`, while the cache replays any chunks missed during a disconnect.
|
|
70
70
|
|
|
71
|
-
3. **Cache layer**:
|
|
71
|
+
3. **Cache layer**: The server cache stores and numbers published events so that a late subscriber can catch up. It's in-memory by default. A deployment with several processes uses one they all share, such as Redis.
|
|
72
72
|
|
|
73
73
|
## Execution variants
|
|
74
74
|
|
|
75
75
|
Choose the engine based on where the agent should run:
|
|
76
76
|
|
|
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
|
|
81
|
-
| No native setting | `createInngestAgent()` from `@mastra/inngest` | On Inngest, with step memoization, retries, and a monitoring dashboard.
|
|
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, storage adapter, and server cache](https://mastra.ai/docs/server/pubsub). |
|
|
81
|
+
| No native setting | `createInngestAgent()` from `@mastra/inngest` | On Inngest, with step memoization, retries, and a monitoring dashboard. |
|
|
82
82
|
|
|
83
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.
|
|
84
84
|
|
|
@@ -107,7 +107,7 @@ const agent = new Agent({
|
|
|
107
107
|
export const eventedWriter = createEventedAgent({ agent })
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
In one process, an evented agent runs on the default PubSub backend with no extra setup, which is how you try it locally. To run its steps on several processes, such as dedicated [workers](https://mastra.ai/docs/deployment/workers), configure a PubSub backend that redelivers unacknowledged events
|
|
110
|
+
In one process, an evented agent runs on the default PubSub backend with no extra setup, which is how you try it locally. To run its steps on several processes, such as dedicated [workers](https://mastra.ai/docs/deployment/workers), configure a PubSub backend that redelivers unacknowledged events, a storage adapter with workflow step guards, and a server cache that every process shares. `EventEmitterPubSub` and `UnixSocketPubSub` don't qualify. Messages sent to a running evented agent reach a run on another process only when the agent's memory uses [storage that shares pending signals across processes](https://mastra.ai/docs/server/pubsub). See [evented workflows and agents](https://mastra.ai/docs/server/pubsub) for the supported backends and adapters.
|
|
111
111
|
|
|
112
112
|
### Resumable streams for stored agents
|
|
113
113
|
|
|
@@ -183,21 +183,24 @@ for await (const chunk of output.fullStream) {
|
|
|
183
183
|
|
|
184
184
|
If you pass `idleTimeoutMs` and no chunks arrive for that long, Mastra checks `isAlive` when you provide it. If `isAlive` returns `true` or throws, the timer restarts and the stream stays open. Otherwise the stream ends with an error chunk and detaches the observer. The run itself is only cleaned up when `isAlive` returns `false`.
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
A registered durable agent uses the server cache of its `Mastra` instance, `InMemoryServerCache` by default, so resumable streams work within a single process. For reconnects across processes or replicas, set the PubSub backend and a server cache on `Mastra` in the same step, and share run storage between every process. The cache holds the events a reconnect replays and each run's ownership record. A shared transport delivers live events but can't recover events held only in another process's cache. A Redis cache also keeps retained events across process restarts:
|
|
187
187
|
|
|
188
188
|
```typescript
|
|
189
|
-
import {
|
|
189
|
+
import { Mastra } from '@mastra/core'
|
|
190
190
|
import { RedisServerCache } from '@mastra/redis'
|
|
191
|
+
import { RedisStreamsPubSub } from '@mastra/redis-streams'
|
|
191
192
|
import Redis from 'ioredis'
|
|
193
|
+
import { durableAgent } from './agents/durable-agent'
|
|
192
194
|
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
cache,
|
|
195
|
+
export const mastra = new Mastra({
|
|
196
|
+
agents: { durableAgent },
|
|
197
|
+
pubsub: new RedisStreamsPubSub({ url: process.env.REDIS_URL! }),
|
|
198
|
+
cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
|
|
198
199
|
})
|
|
199
200
|
```
|
|
200
201
|
|
|
202
|
+
`createDurableAgent()` also accepts its own `cache`. Evented agents use the `Mastra` cache for run events even when given one, because their steps publish from whichever process runs them.
|
|
203
|
+
|
|
201
204
|
`createInngestAgent()` doesn't enable caching by default. Pass a `cache` option or register the agent with a `Mastra` instance that has a `serverCache` configured to enable resumable streams.
|
|
202
205
|
|
|
203
206
|
For cached topics, each published event is recorded in the cache before it's delivered live, so publish latency is bounded by the round-trip to the cache. If the cache write fails, the event is still delivered live but can't be replayed. `@mastra/redis` and `@mastra/valkey` record each event in a single round-trip using a Lua script. `@mastra/redis` falls back to separate commands when the client has no `evalScript` or when Redis Cluster rejects the multi-key script. Per-run workflow watch events (`workflow.events.v2.*`) are never cached. If the cache is remote (for example, in another region) and you don't need to resume a topic, use `shouldCache` to publish that topic straight through:
|
|
@@ -205,7 +208,6 @@ For cached topics, each published event is recorded in the cache before it's del
|
|
|
205
208
|
```typescript
|
|
206
209
|
export const durableAgent = createDurableAgent({
|
|
207
210
|
agent,
|
|
208
|
-
cache,
|
|
209
211
|
// Skip the replay cache for the per-chunk stream topic; other topics stay resumable.
|
|
210
212
|
shouldCache: topic => !topic.startsWith('agent.stream.'),
|
|
211
213
|
})
|
|
@@ -195,6 +195,14 @@ The first run prints `succeeded` with every article counted as `created`. Run it
|
|
|
195
195
|
|
|
196
196
|
Knowledge doesn't schedule runs. Call `run()` from your own scheduler, such as a cron job or a scheduled workflow. Only one run of a binding goes at a time. A second call while one is going returns `skipped`.
|
|
197
197
|
|
|
198
|
+
By default a flush holds up to `bufferSize` items, whatever their size. When your host limits request size, set `maxFlushBytes` so a batch of large items is sent in parts instead of failing at the same items on every run:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
await knowledge.importers!.run('acme-help-desk', { maxFlushBytes: 8 * 1024 * 1024 })
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The limit counts the request encoded as JSON. A host can also send its own limit when a run starts, and the runner keeps under the lower of the two. An item or saved cursor too big for a request on its own ends the run with the error code `flush_too_large`, before anything more is sent.
|
|
205
|
+
|
|
198
206
|
### Read the run result
|
|
199
207
|
|
|
200
208
|
A finished run has an `outcome` of `succeeded`, `failed` or `canceled`, and `counts` of what changed. `succeeded` means the run processed everything your importer sent. It doesn't mean the source and Knowledge are in sync: items can still be refused. Check `counts.refused`, and `refused` for each refused item's `sourceId` and reason. When a run fails, `error.code` says why and `error.retryable` says whether running it again may help. When a run returns `status: 'unfinished'`, it ended but the runner couldn't confirm that Knowledge recorded its result, for example because a reply was lost. Errors from Knowledge that retrying can't fix are thrown from `run()`.
|
|
@@ -207,7 +215,9 @@ Use `ctx.reportBacklog()` in your importer when it stops early on purpose, for e
|
|
|
207
215
|
|
|
208
216
|
When a page already sits at the binding's target, it becomes the importer's folder: its body and the pages under it are kept, and items are added under it. Folders are shared: if that page is another binding's folder or item, it stays that too, and both bindings keep writing and removing their own items under it. When the source removes an item whose page is another binding's folder, the page is kept as a stub, so that binding's folder keeps its ID. When an item's place is already taken by a page, your importer takes that page over, whoever wrote it. The page keeps its ID and anything nested under it, and the item's title and description replace its own. Its body replaces the page's body when the item sends one. A declare sends none. The page keeps its body until an upsert sends one. Unless the page was another importer's item, the body it had before the import is kept in a note on the page. From then on the importer updates it like a page it created. When the source removes the item, the page is never deleted: it gets that saved body back, or becomes a stub when no body was saved. Each takeover saves the body the page has at that moment and replaces the note an earlier takeover left, so edits made after a removal are what the next removal gives back. A page whose body is empty at that moment keeps no note, and its next removal leaves a stub. That includes the item coming back from the source after a removal. If someone deletes the note, the page becomes a stub instead, until a later takeover saves a new one.
|
|
209
217
|
|
|
210
|
-
Importers write where they're configured. When an item of your importer takes over a page another binding imported as an item, that binding stops tracking it, and its next run writes its item again. When two bindings write the same page, the one that ran last owns it. When a binding moves its pages, pages other bindings imported under them move too, and those bindings' links to them are fixed on their next run, even one that sends nothing. Each run takes the page back and rewrites it, so give bindings separate targets unless you want that. When someone moves an imported page elsewhere in the same scope, it stays where they put it and keeps getting the item's updates. If the source then removes the item, the page is deleted where they put it. When someone moves it into another scope, it stays there as an ordinary page and the
|
|
218
|
+
Importers write where they're configured. When an item of your importer takes over a page another binding imported as an item, that binding stops tracking it, and its next run writes its item again. When two bindings write the same page, the one that ran last owns it. When a binding moves its pages, pages other bindings imported under them move too, and those bindings' links to them are fixed on their next run, even one that sends nothing. Each run takes the page back and rewrites it, so give bindings separate targets unless you want that. When someone moves an imported page elsewhere in the same scope, it stays where they put it and keeps getting the item's updates. If the source then removes the item, the page is deleted where they put it. When someone moves it into another scope, it stays there as an ordinary page, and the item is written again at the target the next time your importer sends it. People can add their own pages under imported pages. Those move along with their parent.
|
|
219
|
+
|
|
220
|
+
When someone merges an imported page into another page, the importer leaves it alone. It keeps tracking the item, but later upserts of that item are skipped and counted in `counts.merged`, removing the item does nothing, and the page it was merged into is never touched. A new child of that item goes under its `fallbackParent` page when one exists, otherwise in the importer's folder, and it stays there. Existing children move under the page it was merged into. When that page is in the same scope, they keep getting their items' updates. When it's in another scope, they stay there as ordinary pages. Their items return to the importer's folder only when the source sends them again, which an incremental importer may not do.
|
|
211
221
|
|
|
212
222
|
An item is refused when it can't be written, for example when someone changes the page at the same moment. A binding whose folder was deleted still removes the items it tracks. Its next write makes the folder again. Refused items are counted in `counts.refused`, and the run result lists them in `refused`, each with its `sourceId` and a `reason`. The list holds the first 100. Send the item again. An importer that reads from a cursor may already have saved a cursor past the refused item, so a normal next run doesn't always send it. Reset that cursor, or have your importer send the item again some other way.
|
|
213
223
|
|
|
@@ -148,6 +148,32 @@ export const faq = new Agent({
|
|
|
148
148
|
|
|
149
149
|
The function must return every `resource:` and `thread:` scope it receives. Memory uses them to identify the user and thread. The run fails if one is missing.
|
|
150
150
|
|
|
151
|
+
### Agent identities
|
|
152
|
+
|
|
153
|
+
Spread `knowledgeAgentScopes()` into your `scopes` to give each agent run an identity of its own. A run of an agent then also holds `agent:<agentId>`. With an `org:` scope it holds `agent:<agentId>:org:<orgId>`, and with a Memory resource it holds `agent:<agentId>:user:<resourceId>`. When the agent's `metadata.persona` has a `role` or `teamId`, the run also holds `agent:persona:role:<role>` or `agent:persona:team:<teamId>` scopes:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { Knowledge, knowledgeAgentScopes, knowledgeMemoryScopes } from '@mastra/core/knowledge'
|
|
157
|
+
|
|
158
|
+
const knowledge = new Knowledge({
|
|
159
|
+
storage,
|
|
160
|
+
scopes: { ...knowledgeMemoryScopes(), ...knowledgeAgentScopes() },
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
export const support = new Agent({
|
|
164
|
+
id: 'support',
|
|
165
|
+
name: 'Support',
|
|
166
|
+
instructions: 'You help customers with billing questions.',
|
|
167
|
+
model: 'openai/gpt-6.2-sol',
|
|
168
|
+
metadata: { persona: { role: 'support', teamId: 'billing' } },
|
|
169
|
+
knowledge,
|
|
170
|
+
})
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
These identities grant nothing on their own. Name them in an access rule, for example `{ principal: 'agent:support:org:$orgId', role: 'viewer' }`, to give that agent access to a scope within the run's organization. `agent:support` binds no organization, so a rule naming it on a per-organization scope such as `team:$orgId:$teamId` grants access in every organization. Use it only for access you mean to share across organizations.
|
|
174
|
+
|
|
175
|
+
`knowledgePersonaScopes()` adds a read-only convention on top: each agent reads its own `#persona` page, and every agent of a role or team reads that scope's `#rules` page, pinned into its context. To let one agent edit those rules, pass `agent:persona:role:<role>:edit` or `agent:persona:team:<teamId>:edit` in that run's scopes.
|
|
176
|
+
|
|
151
177
|
## How access is decided
|
|
152
178
|
|
|
153
179
|
Each time a tool runs, Knowledge works out which scopes the run can reach and with which role:
|
|
@@ -47,21 +47,7 @@ yarn add @mastra/memory@latest @mastra/libsql@latest
|
|
|
47
47
|
bun add @mastra/memory@latest @mastra/libsql@latest
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
import { Mastra } from '@mastra/core'
|
|
54
|
-
import { LibSQLStore } from '@mastra/libsql'
|
|
55
|
-
|
|
56
|
-
export const mastra = new Mastra({
|
|
57
|
-
storage: new LibSQLStore({
|
|
58
|
-
id: 'mastra-storage',
|
|
59
|
-
url: 'file:./mastra.db',
|
|
60
|
-
}),
|
|
61
|
-
})
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Instantiate a [`Memory`](https://mastra.ai/reference/memory/memory-class) instance in your agent:
|
|
50
|
+
Create an agent with a [`Memory`](https://mastra.ai/reference/memory/memory-class) instance. Set `OPENAI_API_KEY` to run this example or choose a model from another [configured provider](https://mastra.ai/models/environment-variables).
|
|
65
51
|
|
|
66
52
|
```typescript
|
|
67
53
|
import { Memory } from '@mastra/memory'
|
|
@@ -69,6 +55,9 @@ import { Agent } from '@mastra/core/agent'
|
|
|
69
55
|
|
|
70
56
|
export const agent = new Agent({
|
|
71
57
|
id: 'test-agent',
|
|
58
|
+
name: 'Test Agent',
|
|
59
|
+
instructions: 'Help the user and remember details they share.',
|
|
60
|
+
model: 'openai/gpt-6.2-sol',
|
|
72
61
|
memory: new Memory({
|
|
73
62
|
options: {
|
|
74
63
|
lastMessages: 10,
|
|
@@ -77,7 +66,23 @@ export const agent = new Agent({
|
|
|
77
66
|
})
|
|
78
67
|
```
|
|
79
68
|
|
|
80
|
-
|
|
69
|
+
Register the agent on your Mastra instance and configure a storage adapter to persist conversations:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { Mastra } from '@mastra/core'
|
|
73
|
+
import { LibSQLStore } from '@mastra/libsql'
|
|
74
|
+
import { agent } from './agents/test-agent'
|
|
75
|
+
|
|
76
|
+
export const mastra = new Mastra({
|
|
77
|
+
agents: { agent },
|
|
78
|
+
storage: new LibSQLStore({
|
|
79
|
+
id: 'mastra-storage',
|
|
80
|
+
url: 'file:./mastra.db',
|
|
81
|
+
}),
|
|
82
|
+
})
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Get the registered agent with `mastra.getAgent("agent")`. When you call it with a thread and resource, Mastra saves the messages to the database:
|
|
81
86
|
|
|
82
87
|
**.generate()**:
|
|
83
88
|
|
|
@@ -143,6 +148,9 @@ import { Memory } from '@mastra/memory'
|
|
|
143
148
|
|
|
144
149
|
export const agent = new Agent({
|
|
145
150
|
id: 'test-agent',
|
|
151
|
+
name: 'Test Agent',
|
|
152
|
+
instructions: 'Help the user and remember details they share.',
|
|
153
|
+
model: 'openai/gpt-6.2-sol',
|
|
146
154
|
memory: new Memory({
|
|
147
155
|
options: {
|
|
148
156
|
messageHistory: { maxTokens: 8_000, atMaxRemoveTokens: 2_000 },
|
|
@@ -80,23 +80,7 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
|
|
|
80
80
|
|
|
81
81
|
For more details on available providers and how storage works in Mastra, visit the [storage](https://mastra.ai/docs/storage) documentation.
|
|
82
82
|
|
|
83
|
-
3.
|
|
84
|
-
|
|
85
|
-
**For AI agents:** Important: Add `id` to `LibSQLStore`.
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
import { Mastra } from '@mastra/core'
|
|
89
|
-
import { LibSQLStore } from '@mastra/libsql'
|
|
90
|
-
|
|
91
|
-
export const mastra = new Mastra({
|
|
92
|
-
storage: new LibSQLStore({
|
|
93
|
-
id: 'mastra-storage',
|
|
94
|
-
url: ':memory:',
|
|
95
|
-
}),
|
|
96
|
-
})
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
4. Create a `Memory` instance and pass it to the agent's `memory` option.
|
|
83
|
+
3. Create an agent with a `Memory` instance. Set `OPENAI_API_KEY` to run this example or choose a model from another [configured provider](https://mastra.ai/models/environment-variables).
|
|
100
84
|
|
|
101
85
|
```typescript
|
|
102
86
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -105,6 +89,8 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
|
|
|
105
89
|
export const memoryAgent = new Agent({
|
|
106
90
|
id: 'memory-agent',
|
|
107
91
|
name: 'Memory Agent',
|
|
92
|
+
instructions: 'Help the user and remember details they share.',
|
|
93
|
+
model: 'openai/gpt-6.2-sol',
|
|
108
94
|
memory: new Memory({
|
|
109
95
|
options: {
|
|
110
96
|
lastMessages: 20,
|
|
@@ -115,6 +101,24 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
|
|
|
115
101
|
|
|
116
102
|
Visit [Memory Class](https://mastra.ai/reference/memory/memory-class) for a full list of configuration options.
|
|
117
103
|
|
|
104
|
+
4. Register the agent and configure storage on your Mastra instance.
|
|
105
|
+
|
|
106
|
+
**For AI agents:** Important: Add `id` to `LibSQLStore`.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { Mastra } from '@mastra/core'
|
|
110
|
+
import { LibSQLStore } from '@mastra/libsql'
|
|
111
|
+
import { memoryAgent } from './agents/memory-agent'
|
|
112
|
+
|
|
113
|
+
export const mastra = new Mastra({
|
|
114
|
+
agents: { memoryAgent },
|
|
115
|
+
storage: new LibSQLStore({
|
|
116
|
+
id: 'mastra-storage',
|
|
117
|
+
url: ':memory:',
|
|
118
|
+
}),
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
118
122
|
5. Call your agent, for example in [Studio](https://mastra.ai/docs/studio/overview). Inside Studio, start a new chat with your agent and take a look at the right sidebar. It'll now display memory details.
|
|
119
123
|
|
|
120
124
|
## Message history
|
|
@@ -49,13 +49,15 @@ A static sandbox is shared across every request and memory thread that uses the
|
|
|
49
49
|
|
|
50
50
|
Agents receive tools for the capabilities supported by the sandbox backend:
|
|
51
51
|
|
|
52
|
-
| Tool
|
|
53
|
-
|
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
52
|
+
| Tool | Does |
|
|
53
|
+
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| `mastra_workspace_execute_command` | Runs a shell command and returns stdout, stderr, and the exit code. Supports `background: true` when the backend can spawn long-running processes. |
|
|
55
|
+
| `mastra_workspace_get_process_output` | Gets stdout, stderr, and status for a background process. Supports `tail` to limit output and `waitSeconds` (1 to 300) to wait for the process to exit. If the process is still running when the wait ends, the tool returns the output so far and says how long it waited. For a static sandbox, this tool and `mastra_workspace_kill_process` are only added when the backend supports background processes. Workspaces that resolve their sandbox per request always include both tools, because capabilities aren't known until the sandbox resolves. |
|
|
56
|
+
| `mastra_workspace_kill_process` | Stops a background process and returns its recent output. |
|
|
57
57
|
|
|
58
|
-
Configured capabilities determine which tools are available.
|
|
58
|
+
Configured capabilities determine which tools are available. Use the IDs in the table or their corresponding `WORKSPACE_TOOLS.SANDBOX` constants as keys in `tools`. Mastra ignores unrecognized keys such as `execute_command`.
|
|
59
|
+
|
|
60
|
+
The following example disables the shell tool.
|
|
59
61
|
|
|
60
62
|
```typescript
|
|
61
63
|
import { LocalSandbox, Workspace, WORKSPACE_TOOLS } from '@mastra/core/workspace'
|
|
@@ -261,7 +263,7 @@ Because a [resolver-backed sandbox](#sandboxes-per-user-or-thread) isn't known u
|
|
|
261
263
|
|
|
262
264
|
## Background processes
|
|
263
265
|
|
|
264
|
-
When agents start background processes through `
|
|
266
|
+
When agents start background processes through `mastra_workspace_execute_command`, you can receive lifecycle callbacks for stdout, stderr, and process exit. Configure these through the `backgroundProcesses` option on its `WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND` entry:
|
|
265
267
|
|
|
266
268
|
```typescript
|
|
267
269
|
import { Workspace, LocalSandbox, WORKSPACE_TOOLS } from '@mastra/core/workspace'
|
|
@@ -280,13 +282,13 @@ const workspace = new Workspace({
|
|
|
280
282
|
})
|
|
281
283
|
```
|
|
282
284
|
|
|
283
|
-
These callbacks fire for all background processes started by the agent through `
|
|
285
|
+
These callbacks fire for all background processes started by the agent through `mastra_workspace_execute_command`.
|
|
284
286
|
|
|
285
|
-
Each callback receives the process `pid` and, when available, the `toolCallId`, `agentId`, `threadId`, `resourceId`, and `runId` of the call that started it, so you can route an exit notice back to the right conversation. `onExit` also gets `killedByAbort`, which is `true` when the abort signal fired (the run's signal by default) and stopped the process, and `false` when it exited on its own or was stopped with `
|
|
287
|
+
Each callback receives the process `pid` and, when available, the `toolCallId`, `agentId`, `threadId`, `resourceId`, and `runId` of the call that started it, so you can route an exit notice back to the right conversation. `onExit` also gets `killedByAbort`, which is `true` when the abort signal fired (the run's signal by default) and stopped the process, and `false` when it exited on its own or was stopped with `mastra_workspace_kill_process`.
|
|
286
288
|
|
|
287
289
|
By default, background processes inherit the agent's abort signal and stop when the agent disconnects. Set `abortSignal` to a custom signal, or use `null` or `false` when the process should continue after the request ends.
|
|
288
290
|
|
|
289
|
-
The `timeout` input of `
|
|
291
|
+
The `timeout` input of `mastra_workspace_execute_command` also applies to background commands: the process is stopped after that many seconds. A `timeout` of `0` sets no timer in `LocalSandbox`. When `timeout` is omitted, the sandbox provider decides. `LocalSandbox` sets no timer for background commands, while `E2BSandbox` uses the `timeout` option it was created with, which defaults to 300 seconds. That option is in milliseconds, unlike the `mastra_workspace_execute_command` `timeout`, so a 60-second default needs `new E2BSandbox({ timeout: 60000 })`. The tool description tells agents to omit `timeout` for dev servers and other commands meant to keep running.
|
|
290
292
|
|
|
291
293
|
For the full `SandboxProcessManager` API, including programmatic process spawning, output, and standard input, see the [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager).
|
|
292
294
|
|