@mastra/core 1.86.0-alpha.7 → 1.86.0-alpha.8
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/agent/agent.d.ts +60 -1
- package/dist/agent/agent.types.d.ts +30 -2
- package/dist/agent/durable/create-evented-agent.d.ts +6 -0
- package/dist/agent/durable/durable-agent.d.ts +1 -15
- package/dist/agent/durable/index.cjs +7 -14
- package/dist/agent/durable/index.js +7 -14
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.js +2 -2
- package/dist/agent/types.d.ts +25 -0
- 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-Cf3_IuY8.js → agent-controller-B7POPub5.js} +7 -7
- package/dist/{agent-controller-K5vHtqfO.cjs → agent-controller-DEPayioq.cjs} +7 -7
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-DqnQMfuf.cjs → background-tasks-7iftnRK_.cjs} +1 -1
- package/dist/{background-tasks-BgpX1P_s.js → background-tasks-Cv1ecD6S.js} +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-D8Osghdo.cjs → builder-DuJBbQDH.cjs} +2 -2
- package/dist/{builder-x295GDL6.js → builder-Gg-xnX_E.js} +2 -2
- package/dist/capabilities/302ai.json +194 -194
- package/dist/capabilities/abliteratedllm.json +32 -32
- package/dist/capabilities/abliteration-ai.json +11 -11
- package/dist/capabilities/above.json +12 -12
- package/dist/capabilities/adaption.json +13 -13
- package/dist/capabilities/adzuki.json +32 -32
- package/dist/capabilities/agentrouter.json +6 -6
- package/dist/capabilities/agnes.json +2 -2
- package/dist/capabilities/ai-router.json +5 -5
- package/dist/capabilities/aiand.json +23 -23
- package/dist/capabilities/aigrow.json +11 -11
- package/dist/capabilities/aimlapi.json +144 -144
- package/dist/capabilities/aixy.json +21 -21
- package/dist/capabilities/aki-io.json +15 -15
- package/dist/capabilities/alibaba-cn.json +79 -79
- package/dist/capabilities/alibaba-coding-plan-cn.json +2 -2
- package/dist/capabilities/alibaba-coding-plan.json +2 -2
- package/dist/capabilities/alibaba-token-plan-cn.json +52 -52
- package/dist/capabilities/alibaba-token-plan.json +53 -53
- package/dist/capabilities/alibaba.json +70 -70
- package/dist/capabilities/ambient.json +15 -15
- package/dist/capabilities/amd.json +9 -9
- package/dist/capabilities/anthropic.json +48 -48
- package/dist/capabilities/anyapi.json +12 -12
- package/dist/capabilities/apiko.json +4 -4
- package/dist/capabilities/arcee.json +10 -10
- package/dist/capabilities/augure.json +6 -6
- package/dist/capabilities/auriko.json +18 -18
- package/dist/capabilities/bailing.json +5 -5
- package/dist/capabilities/baseten.json +26 -26
- package/dist/capabilities/bee.json +4 -4
- package/dist/capabilities/berget.json +6 -6
- package/dist/capabilities/bothub.json +14 -14
- package/dist/capabilities/boundless.json +41 -41
- package/dist/capabilities/bumo.json +39 -39
- package/dist/capabilities/byteplus.json +34 -34
- package/dist/capabilities/cheapaimodel.json +7 -7
- package/dist/capabilities/cheapest-token.json +33 -33
- package/dist/capabilities/chutes.json +10 -10
- package/dist/capabilities/cline-pass.json +35 -35
- package/dist/capabilities/cloudcode.json +8 -8
- package/dist/capabilities/cloudferro-sherlock.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +31 -31
- package/dist/capabilities/commandcode.json +148 -148
- package/dist/capabilities/concentrate.json +277 -253
- package/dist/capabilities/cortecs.json +113 -113
- package/dist/capabilities/crossmodel.json +172 -172
- package/dist/capabilities/crusoe.json +9 -9
- package/dist/capabilities/daoxe.json +8 -8
- package/dist/capabilities/databricks.json +54 -54
- package/dist/capabilities/deepinfra.json +95 -86
- package/dist/capabilities/deepseek.json +3 -3
- package/dist/capabilities/digitalocean.json +117 -117
- package/dist/capabilities/dothoosh.json +35 -35
- package/dist/capabilities/doubleword.json +29 -29
- package/dist/capabilities/edenai.json +456 -456
- package/dist/capabilities/empiriolabs.json +174 -174
- package/dist/capabilities/engy.json +20 -20
- package/dist/capabilities/entrim.json +6 -6
- package/dist/capabilities/evroc.json +10 -10
- package/dist/capabilities/ezkielyna.json +10 -10
- package/dist/capabilities/fastrouter.json +77 -77
- package/dist/capabilities/fireworks-ai.json +60 -60
- package/dist/capabilities/freemodel.json +17 -17
- package/dist/capabilities/frogbot.json +93 -93
- package/dist/capabilities/gisoo.json +19 -19
- package/dist/capabilities/gmicloud.json +19 -19
- package/dist/capabilities/google.json +59 -59
- package/dist/capabilities/graphn.json +9 -9
- package/dist/capabilities/greenpt.json +34 -34
- package/dist/capabilities/groq.json +8 -8
- package/dist/capabilities/helicone.json +83 -83
- package/dist/capabilities/hopper.json +2 -2
- package/dist/capabilities/hostinger-router.json +9 -9
- package/dist/capabilities/hpc-ai.json +11 -11
- package/dist/capabilities/huawei-maas.json +13 -13
- package/dist/capabilities/hubris.json +33 -33
- package/dist/capabilities/huggingface.json +60 -51
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +27 -27
- package/dist/capabilities/impossibl.json +118 -118
- package/dist/capabilities/inception.json +3 -3
- package/dist/capabilities/inceptron.json +8 -8
- package/dist/capabilities/inco.json +4 -4
- package/dist/capabilities/infer.json +15 -15
- package/dist/capabilities/inferall.json +10 -10
- package/dist/capabilities/inference-coop.json +12 -12
- package/dist/capabilities/inferenceapis.json +20 -20
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +8 -8
- package/dist/capabilities/inferx.json +3 -3
- package/dist/capabilities/infomaniak.json +4 -4
- package/dist/capabilities/io-net.json +4 -4
- package/dist/capabilities/iteracompute.json +63 -63
- package/dist/capabilities/jad-ai.json +3 -3
- package/dist/capabilities/jalapeno.json +11 -11
- package/dist/capabilities/jiekou.json +63 -63
- package/dist/capabilities/joingonka.json +4 -4
- package/dist/capabilities/jzstoken.json +52 -52
- package/dist/capabilities/keln.json +26 -26
- package/dist/capabilities/kenari.json +127 -127
- package/dist/capabilities/kilo.json +604 -628
- package/dist/capabilities/kimi-code-plan-cn.json +4 -4
- package/dist/capabilities/kimi-code-plan-global.json +4 -4
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +26 -26
- package/dist/capabilities/korouter.json +34 -34
- package/dist/capabilities/kunavo.json +4 -4
- package/dist/capabilities/liquid.json +10 -10
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +934 -907
- package/dist/capabilities/llmgateway.json +339 -339
- package/dist/capabilities/llmtr.json +27 -27
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +53 -53
- package/dist/capabilities/lyceum.json +8 -8
- package/dist/capabilities/melious.json +13 -13
- package/dist/capabilities/merge-gateway.json +284 -284
- package/dist/capabilities/meta.json +11 -11
- package/dist/capabilities/minimax-cn-coding-plan.json +6 -6
- package/dist/capabilities/minimax-coding-plan.json +6 -6
- package/dist/capabilities/mistral.json +22 -22
- package/dist/capabilities/mixlayer.json +3 -3
- package/dist/capabilities/modal.json +13 -13
- package/dist/capabilities/model-oracle-ai.json +23 -23
- package/dist/capabilities/modelis.json +21 -21
- package/dist/capabilities/modelscope.json +2 -2
- package/dist/capabilities/modular.json +10 -10
- package/dist/capabilities/moneo.json +14 -14
- package/dist/capabilities/moonshotai-cn.json +7 -7
- package/dist/capabilities/moonshotai.json +7 -7
- package/dist/capabilities/morph.json +15 -15
- package/dist/capabilities/munito-eu.json +8 -8
- package/dist/capabilities/munito.json +10 -10
- package/dist/capabilities/nan.json +25 -25
- package/dist/capabilities/nano-gpt.json +570 -570
- package/dist/capabilities/nearai.json +87 -87
- package/dist/capabilities/nebius.json +41 -32
- package/dist/capabilities/neon.json +132 -132
- package/dist/capabilities/neuralwatt.json +38 -38
- package/dist/capabilities/novita-ai.json +153 -153
- package/dist/capabilities/nvidia.json +28 -28
- package/dist/capabilities/obscurify.json +33 -33
- package/dist/capabilities/oci.json +6 -6
- package/dist/capabilities/ofox.json +322 -322
- package/dist/capabilities/ollama-cloud.json +52 -52
- package/dist/capabilities/openai.json +47 -47
- package/dist/capabilities/opencode-go.json +79 -78
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +520 -530
- package/dist/capabilities/opper.json +30 -24
- package/dist/capabilities/orcarouter.json +227 -227
- package/dist/capabilities/outerlabs.json +28 -28
- package/dist/capabilities/ovhcloud.json +8 -8
- package/dist/capabilities/pareto.json +5 -5
- package/dist/capabilities/perplexity-agent.json +64 -64
- package/dist/capabilities/perplexity.json +2 -2
- package/dist/capabilities/phala.json +36 -36
- package/dist/capabilities/pioneer.json +30 -30
- package/dist/capabilities/poe.json +109 -109
- package/dist/capabilities/powerspring.json +10 -10
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +116 -99
- package/dist/capabilities/privatemode-ai.json +10 -10
- package/dist/capabilities/proxystacks.json +7 -7
- package/dist/capabilities/qiniu-ai.json +12 -12
- package/dist/capabilities/refuseless.json +8 -8
- package/dist/capabilities/regolo-ai.json +8 -8
- package/dist/capabilities/requesty.json +172 -172
- package/dist/capabilities/ruapi.json +21 -21
- package/dist/capabilities/runcrate.json +15 -15
- package/dist/capabilities/runinfra.json +20 -20
- package/dist/capabilities/sakana.json +7 -7
- package/dist/capabilities/sambanova.json +4 -4
- package/dist/capabilities/sandbase.json +30 -30
- package/dist/capabilities/sarvam.json +5 -5
- package/dist/capabilities/scaleway.json +17 -17
- package/dist/capabilities/scnet-token-plan.json +8 -8
- package/dist/capabilities/scx-ai.json +26 -26
- package/dist/capabilities/sensenova.json +7 -7
- package/dist/capabilities/siliconflow-cn.json +45 -45
- package/dist/capabilities/siliconflow.json +59 -59
- package/dist/capabilities/snowflake-cortex.json +25 -25
- package/dist/capabilities/sokkan.json +9 -9
- package/dist/capabilities/sparrowcodes.json +23 -23
- package/dist/capabilities/standardcompute.json +103 -103
- package/dist/capabilities/steadyrouter.json +39 -39
- 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 +13 -13
- package/dist/capabilities/subconscious.json +2 -2
- package/dist/capabilities/synthetic.json +11 -11
- package/dist/capabilities/synthorai.json +27 -27
- package/dist/capabilities/teamorouter.json +30 -30
- package/dist/capabilities/teapot-router.json +13 -13
- package/dist/capabilities/tencent-token-plan.json +24 -24
- package/dist/capabilities/tencent-tokenhub.json +9 -9
- package/dist/capabilities/tensorx.json +45 -45
- package/dist/capabilities/tenstorrent.json +6 -6
- package/dist/capabilities/the-grid-ai.json +24 -24
- package/dist/capabilities/thinkingmachines.json +59 -59
- package/dist/capabilities/tinfoil.json +14 -14
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +53 -53
- package/dist/capabilities/tokengo.json +25 -25
- package/dist/capabilities/tokenify.json +10 -10
- package/dist/capabilities/trustedrouter.json +7 -7
- package/dist/capabilities/trustedtokens.json +16 -16
- package/dist/capabilities/umans-ai-coding-plan.json +15 -15
- package/dist/capabilities/umans-ai.json +8 -8
- package/dist/capabilities/uncensuredai.json +4 -4
- package/dist/capabilities/unrestricted.json +4 -4
- package/dist/capabilities/uplinkswitch.json +20 -20
- package/dist/capabilities/upstage.json +6 -6
- package/dist/capabilities/vancine.json +22 -22
- package/dist/capabilities/vercel.json +569 -577
- package/dist/capabilities/vivgrid.json +80 -80
- package/dist/capabilities/volcengine-coding-plan.json +26 -26
- package/dist/capabilities/volcengine.json +30 -30
- package/dist/capabilities/vultr.json +25 -25
- package/dist/capabilities/wafer.ai.json +18 -18
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +8 -8
- 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.json +5 -5
- package/dist/capabilities/xpersona.json +12 -12
- package/dist/capabilities/xxapi.json +33 -33
- package/dist/capabilities/zai-coding-plan.json +9 -9
- package/dist/capabilities/zai.json +27 -27
- package/dist/capabilities/zenifra.json +23 -23
- package/dist/capabilities/zenmux.json +192 -192
- package/dist/capabilities/zerogpu.json +10 -10
- package/dist/capabilities/zhipuai-coding-plan.json +7 -7
- package/dist/capabilities/zhipuai.json +26 -26
- package/dist/capabilities/zro.json +6 -6
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-Dx4jiXeK.js → channels-BRVCOutx.js} +1 -1
- package/dist/{channels-q6qnuRNV.cjs → channels-MjTA9bFp.cjs} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/datasets/dataset.d.ts +13 -6
- package/dist/datasets/experiment/durable.d.ts +16 -0
- package/dist/datasets/experiment/index.d.ts +2 -1
- package/dist/datasets/experiment/item.d.ts +26 -4
- package/dist/datasets/experiment/retries.d.ts +18 -0
- package/dist/datasets/experiment/types.d.ts +18 -0
- package/dist/datasets/experiment/workflow-id.d.ts +7 -0
- package/dist/datasets/experiment/workflow.d.ts +74 -0
- package/dist/datasets/index.cjs +3 -2
- package/dist/datasets/index.d.ts +2 -1
- package/dist/datasets/index.js +3 -3
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +790 -790
- package/dist/docs/references/docs-deployment-workers.md +1 -1
- package/dist/docs/references/docs-evals-experiments.md +29 -1
- package/dist/docs/references/docs-harness-durable-agents.md +9 -5
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +1 -0
- package/dist/docs/references/docs-knowledge-load-your-content.md +1 -1
- package/dist/docs/references/docs-mastra-platform-observability-overview.md +1 -1
- package/dist/docs/references/docs-server-pubsub.md +51 -8
- package/dist/docs/references/docs-signals-running-across-processes.md +2 -0
- package/dist/docs/references/docs-workflows-overview.md +1 -1
- package/dist/docs/references/docs-workflows-scheduled-workflows.md +1 -1
- package/dist/docs/references/integrations-channels-slack.md +4 -2
- package/dist/docs/references/integrations.md +6 -0
- package/dist/docs/references/reference-agents-agent.md +2 -0
- package/dist/docs/references/reference-agents-channels.md +116 -27
- package/dist/docs/references/reference-agents-durable-agent.md +2 -0
- package/dist/docs/references/reference-datasets-runExperimentItem.md +13 -1
- package/dist/docs/references/reference-datasets-startExperimentAsync.md +3 -1
- package/dist/docs/references/reference-editor-mastra-editor.md +3 -1
- package/dist/docs/references/reference-knowledge-knowledge-class.md +2 -2
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +43 -20
- package/dist/docs/references/reference-processors-moderation-processor.md +2 -2
- package/dist/docs/references/reference-pubsub-base.md +5 -1
- package/dist/docs/references/reference-pubsub-event-emitter.md +2 -0
- package/dist/docs/references/reference-pubsub-redis-streams.md +1 -1
- package/dist/docs/references/reference-pubsub-unix-socket-pubsub.md +2 -0
- package/dist/docs/references/reference-streaming-ChunkType.md +1 -1
- package/dist/docs/references/reference-workers-overview.md +1 -1
- package/dist/docs/references/reference-workflows-run-methods-start.md +23 -0
- package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +4 -0
- package/dist/docs/references/reference-workflows-run.md +1 -1
- package/dist/evals/index.cjs +1 -1
- package/dist/evals/index.js +1 -1
- package/dist/evals/scoreTraces/index.cjs +1 -1
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/events/caching-pubsub.d.ts +1 -0
- package/dist/events/event-emitter/index.d.ts +12 -5
- package/dist/events/index.cjs +15 -1
- package/dist/events/index.js +15 -1
- package/dist/events/pubsub.d.ts +29 -0
- package/dist/events/reach.d.ts +11 -0
- package/dist/events/unix-socket-pubsub.d.ts +14 -0
- 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/index.cjs +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +8092 -8089
- package/dist/llm/model/shared.types.d.ts +31 -0
- package/dist/{llm-DnXK3Pmw.js → llm-Djd8Qzi0.js} +2 -2
- package/dist/{llm-CsQuqKPc.cjs → llm-DmUucguC.cjs} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +2 -2
- package/dist/{manager-BsghM-UL.js → manager-CO_Xz2zR.js} +460 -94
- package/dist/{manager-DwFnIrI6.cjs → manager-D27PkIPo.cjs} +476 -92
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.d.ts +13 -0
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-B8i1UDZs.js → mastra-Ch00nEAJ.js} +31 -16
- package/dist/{mastra-Cn5NC6Es.cjs → mastra-qsVWpOTi.cjs} +31 -16
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/{model-CsOcWMUt.js → model-CW-mfGYA.js} +1 -1
- package/dist/{model-CNPfry_X.cjs → model-Do6DTJoj.cjs} +1 -1
- package/dist/{netlify-C-83Fxus.cjs → netlify-DU32SDT6.cjs} +1 -1
- package/dist/{netlify-C-OpNSGp.js → netlify-DZSAbdve.js} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/{output-helpers-JL-HeCbT.cjs → output-helpers-1Zu4Vt9C.cjs} +68 -25
- package/dist/{output-helpers-D4II19No.js → output-helpers-CedRCE17.js} +69 -26
- 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-RZ8EgSe8.js → provider-registry-deA0x-Gd.js} +22467 -22456
- package/dist/{provider-registry-9O-H9osy.cjs → provider-registry-zGezZVsL.cjs} +22467 -22456
- package/dist/provider-registry.json +22423 -22408
- package/dist/{registry-generator-DxCX-FiO.cjs → registry-generator-BkQ1AxZn.cjs} +1 -1
- package/dist/{registry-generator-e8sltJls.js → registry-generator-VvBfOKAD.js} +1 -1
- package/dist/{rehydrate-D3fPgJwp.js → rehydrate-BjLV643n.js} +2 -2
- package/dist/{rehydrate-B-wrAN7C.cjs → rehydrate-DDYFpQsV.cjs} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-5_LQBGn_.cjs → run-registry-5Suldxz3.cjs} +519 -71
- package/dist/{run-registry-DC03XLeZ.js → run-registry-CGRPldLH.js} +519 -71
- 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.d.ts +24 -7
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/stream/base/output.d.ts +42 -15
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +19 -0
- package/dist/{stream-CJUm6EAH.js → stream-Dpwx0whf.js} +1 -1
- package/dist/{stream-4aNIw_TQ.cjs → stream-Dvy_0o14.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-FEEwHfmg.js → tool-loop-agent-PbWrEj1k.js} +3 -3
- package/dist/{tool-loop-agent-Dn0QCB9n.cjs → tool-loop-agent-UxOv3FoK.cjs} +3 -3
- package/dist/tools/types.d.ts +27 -1
- package/dist/{utils-DY01hxVd.cjs → utils-BbMTlyBO.cjs} +1 -1
- package/dist/{utils-Bd_y1_a-.js → utils-BnNi1BYM.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-CX0yQo_q.js → validate-HSBcm96b.js} +1 -1
- package/dist/{validate-CuB_1Zd3.cjs → validate-Skps-cM3.cjs} +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.js +1 -1
- package/dist/{worker-GsGIxPMa.cjs → worker-BE-0DyKL.cjs} +2 -2
- package/dist/{worker-DSEfMPmq.js → worker-BKrKHZzU.js} +2 -2
- package/dist/{worker-CbaSmip-.cjs → worker-BNS5A3qP.cjs} +2 -2
- package/dist/{worker-B80xkcKG.js → worker-DehaD4qD.js} +2 -2
- package/dist/{workflow-CnBPXTpv.cjs → workflow-BjUTwaK9.cjs} +4 -4
- package/dist/{workflow-CZHY_C85.js → workflow-Bvw6yDjc.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 +18 -0
- package/dist/workflows/evented/workflow-event-processor/run-status.d.ts +37 -0
- package/dist/workflows/evented/workflow.d.ts +10 -0
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workflows/workflow.d.ts +6 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/{workspace-D7TIleIt.js → workspace-C05xDH60.js} +160 -7
- package/dist/{workspace-D2drutNg.cjs → workspace-D1OzzlLw.cjs} +160 -7
- package/package.json +6 -6
- package/src/llm/model/provider-types.generated.d.ts +8092 -8089
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BrhgMLW6.cjs");
|
|
2
2
|
const require_logger = require("./logger-CvzZYuJd.cjs");
|
|
3
3
|
const require_base = require("./base-BIzR1D3_.cjs");
|
|
4
|
-
const require_output_helpers = require("./output-helpers-JL-HeCbT.cjs");
|
|
5
4
|
const require_observability = require("./observability-B0R_D1PZ.cjs");
|
|
6
5
|
const require_error = require("./error-D90lJ6M7.cjs");
|
|
7
6
|
const require_error$1 = require("./error-BRQf2ku0.cjs");
|
|
8
|
-
const require_stream = require("./stream-
|
|
7
|
+
const require_stream = require("./stream-Dvy_0o14.cjs");
|
|
9
8
|
const require_request_context = require("./request-context-D9RXYCy8.cjs");
|
|
9
|
+
const require_output_helpers = require("./output-helpers-1Zu4Vt9C.cjs");
|
|
10
10
|
const require_message_list = require("./message-list-DPXPXvin.cjs");
|
|
11
11
|
const require_storage = require("./storage-CfG0I2aF.cjs");
|
|
12
12
|
const require_utils = require("./utils-D-eNsgDM.cjs");
|
|
13
13
|
const require_error_count = require("./error-count-DeDpeWU2.cjs");
|
|
14
|
-
const require_llm = require("./llm-
|
|
14
|
+
const require_llm = require("./llm-DmUucguC.cjs");
|
|
15
15
|
const require_payload_transform = require("./payload-transform-CWgnsO9w.cjs");
|
|
16
16
|
const require_utils_safe_stringify = require("./utils/safe-stringify.cjs");
|
|
17
17
|
const require_signals = require("./signals-CWxAMEmE.cjs");
|
|
@@ -23,13 +23,13 @@ const require_tool = require("./tool-CYlT2UA-.cjs");
|
|
|
23
23
|
const require_toolchecks = require("./toolchecks-MFU48cit.cjs");
|
|
24
24
|
const require_fetchWithRetry = require("./fetchWithRetry-f5k4p7_1.cjs");
|
|
25
25
|
const require_model = require("./model-jBymoqGa.cjs");
|
|
26
|
-
const require_provider_registry = require("./provider-registry-
|
|
26
|
+
const require_provider_registry = require("./provider-registry-zGezZVsL.cjs");
|
|
27
27
|
const require_inmemory = require("./inmemory-fgR8sq-U.cjs");
|
|
28
28
|
const require_dynamic_argument = require("./dynamic-argument-CUc1BBOS.cjs");
|
|
29
|
-
const require_model$1 = require("./model-
|
|
30
|
-
const require_utils$1 = require("./utils-
|
|
29
|
+
const require_model$1 = require("./model-Do6DTJoj.cjs");
|
|
30
|
+
const require_utils$1 = require("./utils-BbMTlyBO.cjs");
|
|
31
31
|
const require_ee_iTj2bRDt = require("./ee-iTj2bRDt-D3-QLGDF.cjs");
|
|
32
|
-
const require_background_tasks = require("./background-tasks-
|
|
32
|
+
const require_background_tasks = require("./background-tasks-7iftnRK_.cjs");
|
|
33
33
|
const require_stream$1 = require("./stream-BGbj9jAU.cjs");
|
|
34
34
|
const require_predicate_index = require("./predicate/index.cjs");
|
|
35
35
|
const require_classifier_index = require("./classifier/index.cjs");
|
|
@@ -41,7 +41,7 @@ const require_state_processor = require("./state-processor-kRNZ38Nf.cjs");
|
|
|
41
41
|
const require_constants = require("./constants-B9ZDvXZ4.cjs");
|
|
42
42
|
const require_signal_provider = require("./signal-provider-BFAvh_AJ.cjs");
|
|
43
43
|
const require_slugify = require("./slugify-B_WzG9IY.cjs");
|
|
44
|
-
const require_workspace = require("./workspace-
|
|
44
|
+
const require_workspace = require("./workspace-D1OzzlLw.cjs");
|
|
45
45
|
const require_tools = require("./tools-CGF5Ik6j.cjs");
|
|
46
46
|
const require_workspace_skills = require("./workspace-skills-BcquhPDn.cjs");
|
|
47
47
|
const require_filesystem_versioned = require("./filesystem-versioned-DZGyPbNC.cjs");
|
|
@@ -58,9 +58,9 @@ const require_filesystem$5 = require("./filesystem-CUAgLugE.cjs");
|
|
|
58
58
|
const require_agent_skills_resolver = require("./agent-skills-resolver-BMoCDoaK.cjs");
|
|
59
59
|
const require_voice = require("./voice-Cuev6Md3.cjs");
|
|
60
60
|
let _isaacs_ttlcache = require("@isaacs/ttlcache");
|
|
61
|
+
let zod_v4 = require("zod/v4");
|
|
61
62
|
let events = require("events");
|
|
62
63
|
events = require_rolldown_runtime.__toESM(events, 1);
|
|
63
|
-
let zod_v4 = require("zod/v4");
|
|
64
64
|
let stream_web = require("stream/web");
|
|
65
65
|
let _ai_sdk_provider_utils_v6 = require("@ai-sdk/provider-utils-v6");
|
|
66
66
|
let zod = require("zod");
|
|
@@ -81,6 +81,18 @@ xxhash_wasm = require_rolldown_runtime.__toESM(xxhash_wasm, 1);
|
|
|
81
81
|
let re2js = require("re2js");
|
|
82
82
|
let lru_cache = require("lru-cache");
|
|
83
83
|
let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
|
|
84
|
+
// src/events/reach.ts
|
|
85
|
+
/**
|
|
86
|
+
* Whether events published on `pubsub` can reach a subscriber in another
|
|
87
|
+
* process, read from the transport under any decorator.
|
|
88
|
+
*
|
|
89
|
+
* Only an explicit `false` counts as no. A pubsub built against a copy of
|
|
90
|
+
* `@mastra/core` that predates `deliversAcrossProcesses` has no such getter, and
|
|
91
|
+
* must keep being treated as a shared transport.
|
|
92
|
+
*/
|
|
93
|
+
function reachesOtherProcesses(pubsub) {
|
|
94
|
+
return pubsub.__rawBus().deliversAcrossProcesses !== false;
|
|
95
|
+
}
|
|
84
96
|
// src/storage/run-fencing.ts
|
|
85
97
|
const RUN_FENCE_CONFLICT_ERROR_ID = "STORAGE_RUN_FENCE_CONFLICT";
|
|
86
98
|
const RUN_FENCING_NOT_SUPPORTED_ERROR_ID = "STORAGE_RUN_FENCING_NOT_SUPPORTED";
|
|
@@ -1665,6 +1677,37 @@ const assertTimeTravelGraphMatchesSnapshot = (params) => {
|
|
|
1665
1677
|
}
|
|
1666
1678
|
if (missingStepIds.length > 0) throw new Error(`Cannot time travel to step '${targetStepId}': step(s) ${missingStepIds.map((id) => `'${id}'`).join(", ")} precede the target in the current execution graph but were not recorded in the snapshot. Either the workflow definition changed since the run was recorded (renamed steps, or unnamed .map() steps whose generated ids changed across processes), or the recorded run never reached these steps (it failed, was canceled, or was suspended before them). Steps recorded in the snapshot: ${reportedIdsSuffix}. The stored snapshot has not been modified.`);
|
|
1667
1679
|
};
|
|
1680
|
+
const nestedRunIdentity = (stored, isForeach) => {
|
|
1681
|
+
const metadata = stored?.metadata;
|
|
1682
|
+
const foreachNestedRunIds = metadata?.foreachNestedRunIds && typeof metadata.foreachNestedRunIds === "object" ? metadata.foreachNestedRunIds : void 0;
|
|
1683
|
+
const keepNestedRunId = !isForeach || !foreachNestedRunIds && Array.isArray(stored?.payload) && stored.payload.length === 1;
|
|
1684
|
+
const identity = require_utils$1.removeUndefinedValues({
|
|
1685
|
+
nestedRunId: keepNestedRunId && typeof metadata?.nestedRunId === "string" ? metadata.nestedRunId : void 0,
|
|
1686
|
+
foreachNestedRunIds
|
|
1687
|
+
});
|
|
1688
|
+
return Object.keys(identity).length > 0 ? identity : void 0;
|
|
1689
|
+
};
|
|
1690
|
+
const withSettledForeachRecords = (suspendPayload, output) => {
|
|
1691
|
+
const records = suspendPayload?.__workflow_meta?.foreachOutput;
|
|
1692
|
+
if (!Array.isArray(records) || !Array.isArray(output)) return suspendPayload;
|
|
1693
|
+
let changed = false;
|
|
1694
|
+
const foreachOutput = output.map((slot, index) => {
|
|
1695
|
+
const record = records[index];
|
|
1696
|
+
if (record || slot === null || slot === void 0 || slot?.status === "suspended") return record ?? null;
|
|
1697
|
+
changed = true;
|
|
1698
|
+
return {
|
|
1699
|
+
status: "success",
|
|
1700
|
+
output: slot
|
|
1701
|
+
};
|
|
1702
|
+
});
|
|
1703
|
+
return changed ? {
|
|
1704
|
+
...suspendPayload,
|
|
1705
|
+
__workflow_meta: {
|
|
1706
|
+
...suspendPayload.__workflow_meta,
|
|
1707
|
+
foreachOutput
|
|
1708
|
+
}
|
|
1709
|
+
} : suspendPayload;
|
|
1710
|
+
};
|
|
1668
1711
|
const createTimeTravelExecutionParams = (params) => {
|
|
1669
1712
|
const { steps, inputData, resumeData, context, nestedStepsContext, snapshot, initialState, graph, perStep } = params;
|
|
1670
1713
|
const firstStepId = steps[0];
|
|
@@ -1726,12 +1769,13 @@ const createTimeTravelExecutionParams = (params) => {
|
|
|
1726
1769
|
payload: isFirstEntryTarget ? firstEntryInput : context?.[stepId]?.payload ?? stepPayload ?? snapshotContext[stepId]?.payload ?? {},
|
|
1727
1770
|
output: isCompleteStatus ? context?.[stepId]?.output ?? stepOutput ?? snapshotContext[stepId]?.output ?? {} : void 0,
|
|
1728
1771
|
resumePayload: stepContext?.resumePayload,
|
|
1729
|
-
suspendPayload: stepContext?.suspendPayload,
|
|
1772
|
+
suspendPayload: withSettledForeachRecords(stepContext?.suspendPayload, stepContext?.output),
|
|
1730
1773
|
suspendOutput: stepContext?.suspendOutput,
|
|
1731
1774
|
startedAt: stepContext?.startedAt ?? Date.now(),
|
|
1732
1775
|
endedAt: isCompleteStatus ? stepContext?.endedAt ?? Date.now() : void 0,
|
|
1733
1776
|
suspendedAt: stepContext?.suspendedAt,
|
|
1734
|
-
resumedAt: stepContext?.resumedAt
|
|
1777
|
+
resumedAt: stepContext?.resumedAt,
|
|
1778
|
+
metadata: nestedRunIdentity(snapshotContext[stepId], entry.type === "foreach")
|
|
1735
1779
|
};
|
|
1736
1780
|
if ((perStep ? executionPath.length : currentExecPathLength) > 0 && !steps?.includes(stepId) && !context?.[stepId] && (!snapshotContext[stepId] || snapshotContext[stepId] && snapshotContext[stepId].status !== "suspended")) result = void 0;
|
|
1737
1781
|
if (result) {
|
|
@@ -8865,6 +8909,7 @@ var Workflow = class Workflow extends require_base.MastraBase {
|
|
|
8865
8909
|
snapshot: initialSnapshot,
|
|
8866
8910
|
workflowStatus: "pending"
|
|
8867
8911
|
}) : initialSnapshot, options?.resourceId, { stateBase: nestedRunStart?.inheritedState?.ref });
|
|
8912
|
+
if (nestedRun) nestedRun.inserted = true;
|
|
8868
8913
|
}
|
|
8869
8914
|
run.inheritedState = nestedRunStart?.inheritedState;
|
|
8870
8915
|
return run;
|
|
@@ -8924,19 +8969,20 @@ var Workflow = class Workflow extends require_base.MastraBase {
|
|
|
8924
8969
|
const nestedPubsub = useSharedPubsub ? pubsub : void 0;
|
|
8925
8970
|
let startState = state;
|
|
8926
8971
|
let startedFrom;
|
|
8927
|
-
if (!
|
|
8972
|
+
if (!isResume) {
|
|
8928
8973
|
startedFrom = toJsonState(state);
|
|
8929
8974
|
if (startedFrom) startState = copyState(state);
|
|
8930
8975
|
}
|
|
8931
8976
|
const inheritedState = !restart && !isResume ? await parentState?.(startState) : void 0;
|
|
8932
8977
|
this.#nestedRun = {
|
|
8933
8978
|
storageVersion: parentState ? 2 : 1,
|
|
8934
|
-
start: !
|
|
8979
|
+
start: !isResume ? {
|
|
8935
8980
|
input: inputData,
|
|
8936
8981
|
state: startState,
|
|
8937
8982
|
inheritedState
|
|
8938
8983
|
} : void 0
|
|
8939
8984
|
};
|
|
8985
|
+
const nestedRunHandoff = this.#nestedRun;
|
|
8940
8986
|
const run = isResume ? await this.createRun({
|
|
8941
8987
|
runId: resume.runId,
|
|
8942
8988
|
resourceId,
|
|
@@ -8977,6 +9023,7 @@ var Workflow = class Workflow extends require_base.MastraBase {
|
|
|
8977
9023
|
try {
|
|
8978
9024
|
let restartNested = !!restart;
|
|
8979
9025
|
let resumeNested = isResume;
|
|
9026
|
+
let storedPending = false;
|
|
8980
9027
|
if ((restart || isResume) && !isTimeTravel) {
|
|
8981
9028
|
const nestedSnapshot = await run.runStorage.loadHeader();
|
|
8982
9029
|
let nestedStatus = nestedSnapshot?.status;
|
|
@@ -8994,7 +9041,8 @@ var Workflow = class Workflow extends require_base.MastraBase {
|
|
|
8994
9041
|
else if (restart && nestedStatus === "suspended") {
|
|
8995
9042
|
restartNested = false;
|
|
8996
9043
|
resumeNested = true;
|
|
8997
|
-
}
|
|
9044
|
+
} else if (restart && !isResume && (!nestedSnapshot || nestedRunHandoff.inserted)) restartNested = false;
|
|
9045
|
+
storedPending = nestedStatus === "pending" && !nestedRunHandoff.inserted;
|
|
8998
9046
|
}
|
|
8999
9047
|
if (isTimeTravel) {
|
|
9000
9048
|
res = await run.timeTravel({
|
|
@@ -9017,6 +9065,7 @@ var Workflow = class Workflow extends require_base.MastraBase {
|
|
|
9017
9065
|
handBackBase = startedFrom;
|
|
9018
9066
|
} else if (restartNested) {
|
|
9019
9067
|
handBackBase = await run.runStorage.loadDriveStartState();
|
|
9068
|
+
if (!handBackBase && storedPending) handBackBase = toJsonState((await run.runStorage.loadFull())?.value);
|
|
9020
9069
|
res = await run.restart({
|
|
9021
9070
|
requestContext,
|
|
9022
9071
|
actor,
|
|
@@ -11331,6 +11380,34 @@ var EventedExecutionEngine = class extends ExecutionEngine {
|
|
|
11331
11380
|
return result;
|
|
11332
11381
|
}
|
|
11333
11382
|
};
|
|
11383
|
+
// src/workflows/evented/setup-warning.ts
|
|
11384
|
+
const DOCS_URL = "https://mastra.ai/docs/server/pubsub#evented-workflows-and-agents";
|
|
11385
|
+
const warnedHosts = /* @__PURE__ */ new WeakSet();
|
|
11386
|
+
/**
|
|
11387
|
+
* Evented runs spread over several processes need a pubsub that hands a stopped
|
|
11388
|
+
* worker's event to another worker, and a store whose step guards let one
|
|
11389
|
+
* delivery of a step commit. Logs once per Mastra instance when the pubsub
|
|
11390
|
+
* reaches other processes and one of the two is missing.
|
|
11391
|
+
*
|
|
11392
|
+
* It judges the setup, not how many processes use it: Mastra can't count them.
|
|
11393
|
+
* A pubsub that stays inside the process is left alone, since no other process
|
|
11394
|
+
* can take part in its runs. `MASTRA_DISABLE_EVENTED_SETUP_WARNING=true`
|
|
11395
|
+
* disables it for a shared transport used by one process.
|
|
11396
|
+
*
|
|
11397
|
+
* The message names no supported pubsub or store. The docs page it links to is
|
|
11398
|
+
* the one place that lists them.
|
|
11399
|
+
*/
|
|
11400
|
+
function warnUnsupportedEventedSetup(mastra, workflowsStore) {
|
|
11401
|
+
if (warnedHosts.has(mastra) || process.env.MASTRA_DISABLE_EVENTED_SETUP_WARNING === "true") return;
|
|
11402
|
+
if (!reachesOtherProcesses(mastra.pubsub)) return;
|
|
11403
|
+
const pubsub = mastra.pubsub.__rawBus();
|
|
11404
|
+
let missing;
|
|
11405
|
+
if (!pubsub.redeliversUnacked) missing = `${pubsub.constructor.name} doesn't redeliver unacknowledged events`;
|
|
11406
|
+
else if (workflowsStore && !workflowsStore.supportsWorkflowStepGuards()) missing = `the workflows store has no step guards`;
|
|
11407
|
+
if (!missing) return;
|
|
11408
|
+
warnedHosts.add(mastra);
|
|
11409
|
+
mastra.getLogger()?.warn(`Evented workflows and agents aren't supported on several processes with this setup: ${missing}. See ${DOCS_URL}`);
|
|
11410
|
+
}
|
|
11334
11411
|
// src/agent/scopes.ts
|
|
11335
11412
|
/**
|
|
11336
11413
|
* Scope types Memory reads as the run's identity. Every other scope type is
|
|
@@ -14920,7 +14997,7 @@ var StepExecutor = class extends require_base.MastraBase {
|
|
|
14920
14997
|
const cache = this.mastra?.serverCache;
|
|
14921
14998
|
if (inner instanceof require_output_helpers.CachingPubSub) this.#stepPubsub = inner;
|
|
14922
14999
|
else if (cache) {
|
|
14923
|
-
const processLocalLogs = cache instanceof require_inmemory.InMemoryServerCache &&
|
|
15000
|
+
const processLocalLogs = cache instanceof require_inmemory.InMemoryServerCache && reachesOtherProcesses(inner);
|
|
14924
15001
|
this.#stepPubsub = new require_output_helpers.CachingPubSub(inner, cache, {
|
|
14925
15002
|
shouldCache: (topic) => !require_output_helpers.isRunLocalTopic(topic),
|
|
14926
15003
|
extendExistingLogsOnly: processLocalLogs,
|
|
@@ -15198,7 +15275,7 @@ var StepExecutor = class extends require_base.MastraBase {
|
|
|
15198
15275
|
}),
|
|
15199
15276
|
error: errorInstance
|
|
15200
15277
|
} });
|
|
15201
|
-
if (isExecutionFenceError(error) && this.mastra &&
|
|
15278
|
+
if (isExecutionFenceError(error) && this.mastra && reachesOtherProcesses(this.mastra.pubsub)) {
|
|
15202
15279
|
if (isStorageFencedExecution(requestContext, runId, params.parentWorkflow)) throw error;
|
|
15203
15280
|
}
|
|
15204
15281
|
const mastraError = new require_error.MastraError({
|
|
@@ -15429,6 +15506,58 @@ var StepExecutor = class extends require_base.MastraBase {
|
|
|
15429
15506
|
}
|
|
15430
15507
|
}
|
|
15431
15508
|
};
|
|
15509
|
+
// src/workflows/evented/workflow-event-processor/run-status.ts
|
|
15510
|
+
const ENDED_RUN_STATUSES = /* @__PURE__ */ new Set([
|
|
15511
|
+
"success",
|
|
15512
|
+
"failed",
|
|
15513
|
+
"canceled",
|
|
15514
|
+
"tripwire"
|
|
15515
|
+
]);
|
|
15516
|
+
/** The statuses of a run that has not ended yet. */
|
|
15517
|
+
const UNENDED_RUN_STATUSES = [
|
|
15518
|
+
"running",
|
|
15519
|
+
"waiting",
|
|
15520
|
+
"suspended",
|
|
15521
|
+
"pending",
|
|
15522
|
+
"paused",
|
|
15523
|
+
"bailed",
|
|
15524
|
+
"skipped"
|
|
15525
|
+
];
|
|
15526
|
+
/** Whether a run stored with `status` has ended. */
|
|
15527
|
+
function isEndedRunStatus(status) {
|
|
15528
|
+
return ENDED_RUN_STATUSES.has(status);
|
|
15529
|
+
}
|
|
15530
|
+
/** Whether the stored run `run` has ended. */
|
|
15531
|
+
function hasRunEnded(run) {
|
|
15532
|
+
return !!run && isEndedRunStatus(run.status);
|
|
15533
|
+
}
|
|
15534
|
+
/** Whether `executionPath` points past the last entry of `stepGraph`: a step run there ends the run. */
|
|
15535
|
+
function isPastLastEntry(stepGraph, executionPath) {
|
|
15536
|
+
return (executionPath?.[0] ?? -1) >= stepGraph.length;
|
|
15537
|
+
}
|
|
15538
|
+
/**
|
|
15539
|
+
* Whether a step event is the one that ended the stored run `run`, which a worker still handles
|
|
15540
|
+
* when the run has ended. Only a successful run has one: its worker stores the end before
|
|
15541
|
+
* publishing it and may stop in between, and handling the event again publishes the end. The
|
|
15542
|
+
* stored active path names it: the step end the run ended at, or the step run past the last entry.
|
|
15543
|
+
* A failed run's end is stored by its own `workflow.fail`, which a redelivery of that event
|
|
15544
|
+
* finishes.
|
|
15545
|
+
*
|
|
15546
|
+
* This can't tell an end that was stored and not published from one that was already handled, so
|
|
15547
|
+
* a late copy of the event publishes the end again (and, for a nested run, hands it to the parent
|
|
15548
|
+
* again).
|
|
15549
|
+
*/
|
|
15550
|
+
function isRunEndingEvent(type, executionPath, run, stepGraph) {
|
|
15551
|
+
return run.status === "success" && samePath(run.activePaths, executionPath) && (type === "workflow.step.end" || !!stepGraph && isPastLastEntry(stepGraph, executionPath));
|
|
15552
|
+
}
|
|
15553
|
+
/**
|
|
15554
|
+
* Whether two execution paths name the same position in the step graph. A missing path matches
|
|
15555
|
+
* only another missing path: a run stored without active paths was ended by an event without one.
|
|
15556
|
+
*/
|
|
15557
|
+
function samePath(a, b) {
|
|
15558
|
+
if (!a || !b) return a === b;
|
|
15559
|
+
return a.length === b.length && a.every((index, depth) => index === b[depth]);
|
|
15560
|
+
}
|
|
15432
15561
|
// src/workflows/evented/workflow-event-processor/finished-occurrence.ts
|
|
15433
15562
|
const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
15434
15563
|
"success",
|
|
@@ -15447,10 +15576,6 @@ const BRANCH_SETTLED_STATUSES = /* @__PURE__ */ new Set([
|
|
|
15447
15576
|
"skipped",
|
|
15448
15577
|
"suspended"
|
|
15449
15578
|
]);
|
|
15450
|
-
/** Whether two execution paths name the same position in the step graph. */
|
|
15451
|
-
function samePath(a, b) {
|
|
15452
|
-
return !!a && a.length === b.length && a.every((index, depth) => index === b[depth]);
|
|
15453
|
-
}
|
|
15454
15579
|
/** The record of one foreach item, kept in the foreach step's resume metadata. */
|
|
15455
15580
|
function foreachItem(result, index) {
|
|
15456
15581
|
if (index === void 0) return;
|
|
@@ -16412,6 +16537,18 @@ function routeStepRun(stepGraph, { executionPath, restart }) {
|
|
|
16412
16537
|
}
|
|
16413
16538
|
}
|
|
16414
16539
|
// src/workflows/evented/workflow-event-processor/sleep.ts
|
|
16540
|
+
/**
|
|
16541
|
+
* Records the sleep as the run's active step. Returns false when the run ended after the sleep
|
|
16542
|
+
* was dispatched: the write is refused, so the ended run is not reopened, and the sleep stops.
|
|
16543
|
+
*/
|
|
16544
|
+
async function markSleepRunning(runStorage, executionPath, activeStepsPath) {
|
|
16545
|
+
return !!await runStorage.updateHeader({
|
|
16546
|
+
status: "running",
|
|
16547
|
+
activePaths: executionPath,
|
|
16548
|
+
activeStepsPath,
|
|
16549
|
+
expectedStatus: UNENDED_RUN_STATUSES
|
|
16550
|
+
}) || !hasRunEnded(await runStorage.loadHeader());
|
|
16551
|
+
}
|
|
16415
16552
|
async function processWorkflowWaitForEvent(workflowData, { pubsub, eventName, currentState }) {
|
|
16416
16553
|
const executionPath = currentState?.waitingPaths[eventName];
|
|
16417
16554
|
if (!executionPath) return;
|
|
@@ -16464,14 +16601,10 @@ async function processWorkflowSleep({ workflow, workflowId, runId, executionPath
|
|
|
16464
16601
|
},
|
|
16465
16602
|
requestContext: withoutAuthToken(requestContext ?? {})
|
|
16466
16603
|
});
|
|
16467
|
-
await runStorage
|
|
16468
|
-
|
|
16469
|
-
|
|
16470
|
-
|
|
16471
|
-
...activeStepsPath,
|
|
16472
|
-
[step.id]: executionPath
|
|
16473
|
-
}
|
|
16474
|
-
});
|
|
16604
|
+
if (!await markSleepRunning(runStorage, executionPath, {
|
|
16605
|
+
...activeStepsPath,
|
|
16606
|
+
[step.id]: executionPath
|
|
16607
|
+
})) return;
|
|
16475
16608
|
const reqContext = new require_request_context.RequestContext(Object.entries(requestContext ?? {}));
|
|
16476
16609
|
setLongTimeout(async () => {
|
|
16477
16610
|
if (emitStepEvents) {
|
|
@@ -16545,14 +16678,10 @@ async function processWorkflowSleepUntil({ workflow, workflowId, runId, executio
|
|
|
16545
16678
|
},
|
|
16546
16679
|
requestContext: withoutAuthToken(requestContext ?? {})
|
|
16547
16680
|
});
|
|
16548
|
-
await runStorage
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
|
|
16552
|
-
...activeStepsPath,
|
|
16553
|
-
[step.id]: executionPath
|
|
16554
|
-
}
|
|
16555
|
-
});
|
|
16681
|
+
if (!await markSleepRunning(runStorage, executionPath, {
|
|
16682
|
+
...activeStepsPath,
|
|
16683
|
+
[step.id]: executionPath
|
|
16684
|
+
})) return;
|
|
16556
16685
|
const reqContext = new require_request_context.RequestContext(Object.entries(requestContext ?? {}));
|
|
16557
16686
|
const duration = await stepExecutor.resolveSleepUntil({
|
|
16558
16687
|
workflowId,
|
|
@@ -17480,12 +17609,12 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
17480
17609
|
stepResults: stepResults ?? {},
|
|
17481
17610
|
workflowStatus: finalStatus
|
|
17482
17611
|
}) ?? true;
|
|
17483
|
-
if (shouldPersist
|
|
17612
|
+
if (shouldPersist && !await this.#writeRunEnd("endWorkflow", args, runStorage, {
|
|
17484
17613
|
status: finalStatus,
|
|
17485
17614
|
result: normalizedPrevResult,
|
|
17486
17615
|
activePaths: executionPath,
|
|
17487
17616
|
activeStepsPath
|
|
17488
|
-
});
|
|
17617
|
+
})) return;
|
|
17489
17618
|
this.endRunSpans(args, finalStatus);
|
|
17490
17619
|
if (finalStatus === "paused") await this.#pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
17491
17620
|
type: "watch",
|
|
@@ -17519,6 +17648,35 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
17519
17648
|
}
|
|
17520
17649
|
});
|
|
17521
17650
|
}
|
|
17651
|
+
/**
|
|
17652
|
+
* Stores a run's end only while the run has not ended, so a late or second end can't replace
|
|
17653
|
+
* the first one. Returns true when the end is to be published: it was stored, the run is not
|
|
17654
|
+
* stored (as before), or the run already ended the same way at the same path, which is this end
|
|
17655
|
+
* handled again after its worker stopped before publishing it. Returns false, after logging, for
|
|
17656
|
+
* any other refusal: the run ended another way, or it was reopened (time travel writes `running`
|
|
17657
|
+
* on an ended run) between the write and the read, and an old end must not replace it.
|
|
17658
|
+
*/
|
|
17659
|
+
async #writeRunEnd(handler, { workflowId, runId, executionPath, eventId }, runStorage, end) {
|
|
17660
|
+
const expectedStatus = end.status === "canceled" ? [...UNENDED_RUN_STATUSES, "canceled"] : UNENDED_RUN_STATUSES;
|
|
17661
|
+
if (await runStorage.updateHeader({
|
|
17662
|
+
...end,
|
|
17663
|
+
expectedStatus
|
|
17664
|
+
})) return true;
|
|
17665
|
+
const stored = await runStorage.loadHeader();
|
|
17666
|
+
if (!stored) return true;
|
|
17667
|
+
if (hasRunEnded(stored) && stored.status === end.status && samePath(stored.activePaths, executionPath)) return true;
|
|
17668
|
+
this.mastra.getLogger()?.warn("Dropping a workflow end: the run already ended or was reopened", {
|
|
17669
|
+
handler,
|
|
17670
|
+
workflowId,
|
|
17671
|
+
runId,
|
|
17672
|
+
eventId,
|
|
17673
|
+
executionPath,
|
|
17674
|
+
status: end.status,
|
|
17675
|
+
storedStatus: stored.status,
|
|
17676
|
+
storedActivePaths: stored.activePaths
|
|
17677
|
+
});
|
|
17678
|
+
return false;
|
|
17679
|
+
}
|
|
17522
17680
|
async publishFinishEvent(event) {
|
|
17523
17681
|
for (;;) try {
|
|
17524
17682
|
await this.#pubsub.publish("workflows-finish", event);
|
|
@@ -17655,6 +17813,17 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
17655
17813
|
const step = liveParentWorkflow?.stepGraph?.[parentWorkflow.executionPath[0]];
|
|
17656
17814
|
if (liveParentWorkflow && step?.type === "loop") {
|
|
17657
17815
|
const parentStorage = this.#runStorage(parentWorkflow.workflowId, parentWorkflow.runId);
|
|
17816
|
+
const parentHeader = await parentStorage.loadHeader();
|
|
17817
|
+
if (hasRunEnded(parentHeader)) {
|
|
17818
|
+
this.mastra.getLogger()?.warn("Dropping a nested loop iteration end: the parent run already ended", {
|
|
17819
|
+
workflowId: parentWorkflow.workflowId,
|
|
17820
|
+
runId: parentWorkflow.runId,
|
|
17821
|
+
nestedRunId,
|
|
17822
|
+
executionPath: parentWorkflow.executionPath,
|
|
17823
|
+
storedStatus: parentHeader.status
|
|
17824
|
+
});
|
|
17825
|
+
return;
|
|
17826
|
+
}
|
|
17658
17827
|
const loopStepResults = {
|
|
17659
17828
|
...parentWorkflow.stepResults ?? (await parentStorage.loadFull())?.context,
|
|
17660
17829
|
__state: state
|
|
@@ -17790,21 +17959,19 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
17790
17959
|
workflowStatus: "failed"
|
|
17791
17960
|
}) ?? true;
|
|
17792
17961
|
const ownershipLost = workflow?.options?.isOwnershipLostError?.(prevResult?.error);
|
|
17793
|
-
if (ownershipLost) {} else if (shouldPersist
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
});
|
|
17807
|
-
}
|
|
17962
|
+
if (ownershipLost) {} else if (shouldPersist && !await this.#writeRunEnd("processWorkflowFail", args, runStorage, {
|
|
17963
|
+
status: "failed",
|
|
17964
|
+
error: prevResult.error,
|
|
17965
|
+
activePaths: executionPath,
|
|
17966
|
+
activeStepsPath
|
|
17967
|
+
})) return;
|
|
17968
|
+
else if (shouldPersist && currentStorageVersion() === 2) await this.pruneAndRepersistSnapshot({
|
|
17969
|
+
workflow,
|
|
17970
|
+
workflowId,
|
|
17971
|
+
runId,
|
|
17972
|
+
finished: true,
|
|
17973
|
+
fence: await this.currentRunFence(runId)
|
|
17974
|
+
});
|
|
17808
17975
|
if (parentWorkflow) await this.#pubsub.publish("workflows", {
|
|
17809
17976
|
type: "workflow.step.end",
|
|
17810
17977
|
runId: parentWorkflow.runId,
|
|
@@ -17908,7 +18075,7 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
17908
18075
|
restart
|
|
17909
18076
|
});
|
|
17910
18077
|
if (!rawStep || route.kind === "missing") {
|
|
17911
|
-
if (executionPath
|
|
18078
|
+
if (isPastLastEntry(stepGraph, executionPath)) return this.endWorkflow({
|
|
17912
18079
|
workflow,
|
|
17913
18080
|
parentWorkflow,
|
|
17914
18081
|
workflowId,
|
|
@@ -18493,12 +18660,7 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
18493
18660
|
workflowName: workflowId,
|
|
18494
18661
|
runId
|
|
18495
18662
|
});
|
|
18496
|
-
if (snapshot
|
|
18497
|
-
"success",
|
|
18498
|
-
"failed",
|
|
18499
|
-
"canceled",
|
|
18500
|
-
"tripwire"
|
|
18501
|
-
].includes(snapshot.status)) return true;
|
|
18663
|
+
if (hasRunEnded(snapshot)) return true;
|
|
18502
18664
|
if (snapshot?.status === "suspended" && snapshot.context[leafId]?.status === "suspended") return true;
|
|
18503
18665
|
if (guardStart) try {
|
|
18504
18666
|
assertWorkflowStepGuard({
|
|
@@ -18536,7 +18698,8 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
18536
18698
|
nestedRunId = stepResults[leafId]?.suspendPayload?.__workflow_meta?.runId;
|
|
18537
18699
|
} else if (timeTravel && timeTravel.steps?.length > 1 && timeTravel.steps[0] === leafId) {
|
|
18538
18700
|
nestedDispatch = "time-travel";
|
|
18539
|
-
|
|
18701
|
+
const recordedMetadata = stepResults[leafId]?.metadata;
|
|
18702
|
+
nestedRunId = (step.type === "foreach" ? recordedMetadata?.foreachNestedRunIds?.[executionPath[1]] ?? (recordedMetadata?.foreachNestedRunIds || executionPath[1] !== 0 ? void 0 : recordedMetadata?.nestedRunId) : recordedMetadata?.nestedRunId) ?? globalThis.crypto.randomUUID();
|
|
18540
18703
|
} else if (restart && !!restart.activeStepsPath?.[leafId]) {
|
|
18541
18704
|
nestedDispatch = "restart";
|
|
18542
18705
|
nestedRunId = (step.type === "foreach" ? stepResults[leafId]?.metadata?.foreachNestedRunIds?.[executionPath[1]] : void 0) ?? stepResults[leafId]?.metadata?.nestedRunId ?? globalThis.crypto.randomUUID();
|
|
@@ -18665,12 +18828,23 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
18665
18828
|
};
|
|
18666
18829
|
return step.type === "loop" ? this.#processLoop(continuation, step, completedResult, args.eventId) : this.processWorkflowStepEnd(continuation);
|
|
18667
18830
|
}
|
|
18668
|
-
await runStorage.updateHeader({
|
|
18831
|
+
const stored = await runStorage.updateHeader({
|
|
18669
18832
|
status: "running",
|
|
18670
18833
|
activePaths: executionPath,
|
|
18671
18834
|
activeStepsPath,
|
|
18672
18835
|
expectedStatus: "running"
|
|
18673
|
-
});
|
|
18836
|
+
}) ? void 0 : await runStorage.loadHeader();
|
|
18837
|
+
if (hasRunEnded(stored) && stored.status !== "canceled") {
|
|
18838
|
+
this.mastra.getLogger()?.warn("Not running a step: the run already ended", {
|
|
18839
|
+
type: "workflow.step.run",
|
|
18840
|
+
workflowId,
|
|
18841
|
+
runId,
|
|
18842
|
+
eventId: args.eventId,
|
|
18843
|
+
executionPath,
|
|
18844
|
+
storedStatus: stored.status
|
|
18845
|
+
});
|
|
18846
|
+
return;
|
|
18847
|
+
}
|
|
18674
18848
|
}
|
|
18675
18849
|
if (step.type === "foreach" && workflowsStore && authorizedEventId) {
|
|
18676
18850
|
const storedResult = (await runStorage.loadSteps([leafId]))[leafId] ?? stepResults[leafId];
|
|
@@ -20274,7 +20448,7 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
20274
20448
|
* should drop the event (or return 4xx for HTTP push).
|
|
20275
20449
|
*/
|
|
20276
20450
|
async handle(event) {
|
|
20277
|
-
if (this.mastra.pubsub
|
|
20451
|
+
if (!reachesOtherProcesses(this.mastra.pubsub)) return this.#handleDelivery(event);
|
|
20278
20452
|
if (!isStorageFencedExecution(new require_request_context.RequestContext(Object.entries(event.data?.requestContext ?? {})), event.runId, event.data?.parentWorkflow)) return this.#handleDelivery(event);
|
|
20279
20453
|
try {
|
|
20280
20454
|
if (await retrySettledDurableExecution(this.mastra, event)) return { ok: true };
|
|
@@ -20608,6 +20782,19 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
|
|
|
20608
20782
|
return;
|
|
20609
20783
|
}
|
|
20610
20784
|
const workflow = this.#resolveLiveWorkflow(workflowData);
|
|
20785
|
+
if ((type === "workflow.step.end" || type === "workflow.step.run") && hasRunEnded(currentState) && !isRunEndingEvent(type, workflowData.executionPath, currentState, workflow?.stepGraph)) {
|
|
20786
|
+
this.mastra.getLogger()?.warn("Dropping a step event: the run already ended", {
|
|
20787
|
+
type,
|
|
20788
|
+
workflowId: workflowData.workflowId,
|
|
20789
|
+
runId: workflowData.runId,
|
|
20790
|
+
eventId: event.id,
|
|
20791
|
+
executionPath: workflowData.executionPath,
|
|
20792
|
+
storedStatus: currentState.status,
|
|
20793
|
+
storedActivePaths: currentState.activePaths,
|
|
20794
|
+
deliveryAttempt: event.deliveryAttempt
|
|
20795
|
+
});
|
|
20796
|
+
return;
|
|
20797
|
+
}
|
|
20611
20798
|
if (!workflow) {
|
|
20612
20799
|
if (type === "workflow.fail" || type === "workflow.end" || type === "workflow.cancel") {} else return this.errorWorkflow(workflowData, new require_error.MastraError({
|
|
20613
20800
|
id: "MASTRA_WORKFLOW",
|
|
@@ -21599,6 +21786,16 @@ function createStepFromProcessor(processor) {
|
|
|
21599
21786
|
component: "PROCESSOR"
|
|
21600
21787
|
};
|
|
21601
21788
|
}
|
|
21789
|
+
/**
|
|
21790
|
+
* Builds a workflow on the evented execution engine: each step is an event on
|
|
21791
|
+
* the Mastra host's pubsub, so any worker can run the next one.
|
|
21792
|
+
*
|
|
21793
|
+
* In one process it runs on any pubsub, including the default one. Running it
|
|
21794
|
+
* on several processes needs a pubsub that redelivers unacknowledged events and
|
|
21795
|
+
* a workflows store with step guards.
|
|
21796
|
+
*
|
|
21797
|
+
* @see https://mastra.ai/docs/server/pubsub#evented-workflows-and-agents
|
|
21798
|
+
*/
|
|
21602
21799
|
function createWorkflow$1(params) {
|
|
21603
21800
|
const eventProcessor = new WorkflowEventProcessor({ mastra: params.mastra });
|
|
21604
21801
|
const executionEngine = new EventedExecutionEngine({
|
|
@@ -21655,6 +21852,7 @@ var EventedWorkflow = class extends Workflow {
|
|
|
21655
21852
|
}
|
|
21656
21853
|
});
|
|
21657
21854
|
}
|
|
21855
|
+
if (!this.isInternal) warnUnsupportedEventedSetup(this.mastra, workflowsStore);
|
|
21658
21856
|
const cachedRun = this.runs.get(runIdToUse);
|
|
21659
21857
|
const shouldPersistSnapshot = this.options?.shouldPersistSnapshot?.({
|
|
21660
21858
|
workflowStatus: cachedRun?.workflowRunStatus ?? "pending",
|
|
@@ -37835,10 +38033,19 @@ var DatasetsInMemory = class extends DatasetsStorage {
|
|
|
37835
38033
|
field: "createdAt",
|
|
37836
38034
|
direction: "DESC"
|
|
37837
38035
|
});
|
|
37838
|
-
items.sort(require_filesystem_versioned.compareByField(orderBy.field, orderBy.direction));
|
|
37839
38036
|
const { page, perPage: perPageInput } = args.pagination;
|
|
37840
38037
|
const perPage = require_filesystem_versioned.normalizePerPage(perPageInput, 100);
|
|
37841
38038
|
const { offset: start, perPage: perPageForResponse } = require_filesystem_versioned.calculatePagination(page, perPageInput, perPage);
|
|
38039
|
+
if (perPage === 0) return {
|
|
38040
|
+
items: [],
|
|
38041
|
+
pagination: {
|
|
38042
|
+
total: items.length,
|
|
38043
|
+
page,
|
|
38044
|
+
perPage: perPageForResponse,
|
|
38045
|
+
hasMore: items.length > 0
|
|
38046
|
+
}
|
|
38047
|
+
};
|
|
38048
|
+
items.sort(require_filesystem_versioned.compareByField(orderBy.field, orderBy.direction));
|
|
37842
38049
|
const end = perPageInput === false ? items.length : start + perPage;
|
|
37843
38050
|
return {
|
|
37844
38051
|
items: items.slice(start, end),
|
|
@@ -39625,6 +39832,7 @@ var InMemoryKnowledgePageStore = class {
|
|
|
39625
39832
|
}))].slice(0, limit);
|
|
39626
39833
|
}
|
|
39627
39834
|
async listPageActivity(input) {
|
|
39835
|
+
if (input.before !== void 0 && input.cursor !== void 0) throw new RangeError("Knowledge activity takes either a cursor or a before position, not both");
|
|
39628
39836
|
const { items, nextCursor } = paginate(this.#activity.filter((event) => {
|
|
39629
39837
|
const page = this.#pages.get(event.pageId);
|
|
39630
39838
|
if (!page || !this.#pageReadable(page, input.read)) return false;
|
|
@@ -39634,6 +39842,9 @@ var InMemoryKnowledgePageStore = class {
|
|
|
39634
39842
|
const note = this.#notes.get(event.noteId);
|
|
39635
39843
|
if (!note || !this.#noteVisible(note, input.read)) return false;
|
|
39636
39844
|
}
|
|
39845
|
+
if (input.since !== void 0 && event.createdAt.getTime() < input.since.getTime()) return false;
|
|
39846
|
+
if (input.until !== void 0 && event.createdAt.getTime() >= input.until.getTime()) return false;
|
|
39847
|
+
if (input.before !== void 0 && newestFirst(event, input.before) <= 0) return false;
|
|
39637
39848
|
return true;
|
|
39638
39849
|
}).sort(newestFirst), input.cursor, input.limit);
|
|
39639
39850
|
return {
|
|
@@ -39827,7 +40038,8 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
|
|
|
39827
40038
|
schemaVersion: 4,
|
|
39828
40039
|
supportsSchemaInspection: true,
|
|
39829
40040
|
supportsExplicitReset: true,
|
|
39830
|
-
supportsPinKinds: true
|
|
40041
|
+
supportsPinKinds: true,
|
|
40042
|
+
supportsActivityDateRange: true
|
|
39831
40043
|
};
|
|
39832
40044
|
}
|
|
39833
40045
|
async inspectSchema() {
|
|
@@ -62540,6 +62752,237 @@ function pinTool(host, onChange) {
|
|
|
62540
62752
|
}
|
|
62541
62753
|
});
|
|
62542
62754
|
}
|
|
62755
|
+
const ACTIVITY_DEFAULT_LIMIT = 25;
|
|
62756
|
+
const ACTIVITY_MAX_LIMIT = 100;
|
|
62757
|
+
const ACTIVITY_MAX_BATCHES = 8;
|
|
62758
|
+
const ACTIVITY_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
62759
|
+
const ACTIVITY_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(\.\d{1,3})?)?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
62760
|
+
/**
|
|
62761
|
+
* `2026-07-01` (UTC midnight) or a date-time with an explicit zone (`Z` or `±hh:mm`). A date-time
|
|
62762
|
+
* without a zone would be read in the host's zone, and an impossible date (`2026-02-30`) would be
|
|
62763
|
+
* rolled over by `Date`, so both are refused.
|
|
62764
|
+
*/
|
|
62765
|
+
function activityDate(name, value) {
|
|
62766
|
+
const trimmed = value.trim();
|
|
62767
|
+
const refuse = () => {
|
|
62768
|
+
throw new Error(`${name} must be a date like "2026-07-01" or a date-time with a zone like "2026-07-01T09:30:00Z" or "2026-07-01T09:30:00+02:00"; got "${value}".`);
|
|
62769
|
+
};
|
|
62770
|
+
const dateOnly = ACTIVITY_DATE.exec(trimmed);
|
|
62771
|
+
const dateTime = dateOnly ? void 0 : ACTIVITY_DATE_TIME.exec(trimmed);
|
|
62772
|
+
const match = dateOnly ?? dateTime ?? refuse();
|
|
62773
|
+
const [year, month, day, hour = 0, minute = 0, second = 0] = [
|
|
62774
|
+
1,
|
|
62775
|
+
2,
|
|
62776
|
+
3,
|
|
62777
|
+
4,
|
|
62778
|
+
5,
|
|
62779
|
+
6
|
|
62780
|
+
].map((index) => match[index] === void 0 ? void 0 : Number(match[index]));
|
|
62781
|
+
const wall = /* @__PURE__ */ new Date(0);
|
|
62782
|
+
wall.setUTCFullYear(year, month - 1, day);
|
|
62783
|
+
wall.setUTCHours(hour, minute, second, 0);
|
|
62784
|
+
if (wall.getUTCFullYear() !== year || wall.getUTCMonth() !== month - 1 || wall.getUTCDate() !== day || wall.getUTCHours() !== hour || wall.getUTCMinutes() !== minute || wall.getUTCSeconds() !== second) refuse();
|
|
62785
|
+
if (dateTime?.[9] !== void 0) {
|
|
62786
|
+
const offsetHours = Number(dateTime[10]);
|
|
62787
|
+
const offsetMinutes = Number(dateTime[11]);
|
|
62788
|
+
if (offsetMinutes > 59 || offsetHours > 14 || offsetHours === 14 && offsetMinutes > 0) refuse();
|
|
62789
|
+
}
|
|
62790
|
+
const date = new Date(dateOnly ? `${trimmed}T00:00:00.000Z` : trimmed);
|
|
62791
|
+
if (Number.isNaN(date.getTime())) refuse();
|
|
62792
|
+
const utcYear = date.getUTCFullYear();
|
|
62793
|
+
if (utcYear < 1 || utcYear > 9999) refuse();
|
|
62794
|
+
return date;
|
|
62795
|
+
}
|
|
62796
|
+
async function activityBinding(parts) {
|
|
62797
|
+
const bytes = new TextEncoder().encode(JSON.stringify(parts.map((part) => part ?? null)));
|
|
62798
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
62799
|
+
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
62800
|
+
}
|
|
62801
|
+
function encodeActivityCursor(cursor) {
|
|
62802
|
+
return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
|
|
62803
|
+
}
|
|
62804
|
+
function decodeActivityCursor(value) {
|
|
62805
|
+
try {
|
|
62806
|
+
const cursor = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
|
|
62807
|
+
if (cursor?.v === 1 && Array.isArray(cursor.before) && typeof cursor.before[0] === "string" && typeof cursor.before[1] === "string" && !Number.isNaN(new Date(cursor.before[0]).getTime()) && typeof cursor.bind === "string") return cursor;
|
|
62808
|
+
} catch {}
|
|
62809
|
+
throw new Error("knowledge_activity: that cursor did not come from knowledge_activity.");
|
|
62810
|
+
}
|
|
62811
|
+
function activityTool(host) {
|
|
62812
|
+
const maxTokens = maxTokensOf(host);
|
|
62813
|
+
return require_tool.createTool({
|
|
62814
|
+
id: "knowledge_activity",
|
|
62815
|
+
description: `What changed in Knowledge over a period: page creates, edits, moves, merges and deletes, and notes added, restamped, removed or restored, newest first, with who made each change. Give \`since\` and/or \`until\` (a date like 2026-07-01, or a date-time with a zone like 2026-07-01T09:30:00Z; at least one); \`from\` narrows it to one page or scope. A note entry shows the note's current text (marked \`current\`), not its text when the change happened; a removed note shows no text. One result holds at most \`limit\` changes and about ${maxTokens.toLocaleString("en-US")} tokens of them; when it stops early, \`more\` is true and \`cursor\` continues (pass the same since, until and from).`,
|
|
62816
|
+
inputSchema: {
|
|
62817
|
+
type: "object",
|
|
62818
|
+
properties: {
|
|
62819
|
+
since: {
|
|
62820
|
+
type: "string",
|
|
62821
|
+
minLength: 1,
|
|
62822
|
+
description: "Changes at or after this time, e.g. \"2026-07-01\" (UTC midnight), \"2026-07-01T09:30:00Z\" or \"2026-07-01T09:30:00+02:00\". A date-time needs a zone."
|
|
62823
|
+
},
|
|
62824
|
+
until: {
|
|
62825
|
+
type: "string",
|
|
62826
|
+
minLength: 1,
|
|
62827
|
+
description: "Changes before this time, same formats as since."
|
|
62828
|
+
},
|
|
62829
|
+
from: {
|
|
62830
|
+
type: "string",
|
|
62831
|
+
minLength: 1,
|
|
62832
|
+
description: `Only changes to this page or scope. ${pageRefDescription}`
|
|
62833
|
+
},
|
|
62834
|
+
limit: {
|
|
62835
|
+
type: "integer",
|
|
62836
|
+
minimum: 1,
|
|
62837
|
+
maximum: ACTIVITY_MAX_LIMIT,
|
|
62838
|
+
description: `Maximum changes. Defaults to ${ACTIVITY_DEFAULT_LIMIT}.`
|
|
62839
|
+
},
|
|
62840
|
+
cursor: {
|
|
62841
|
+
type: "string",
|
|
62842
|
+
minLength: 1,
|
|
62843
|
+
description: "The previous result's cursor, for the changes after it (pass the same since, until and from)."
|
|
62844
|
+
}
|
|
62845
|
+
},
|
|
62846
|
+
additionalProperties: false
|
|
62847
|
+
},
|
|
62848
|
+
execute: async (input, context) => {
|
|
62849
|
+
const args = input;
|
|
62850
|
+
if (args.since === void 0 && args.until === void 0) throw new Error("knowledge_activity needs since or until, e.g. since: \"2026-07-01\".");
|
|
62851
|
+
const since = args.since === void 0 ? void 0 : activityDate("since", args.since);
|
|
62852
|
+
const until = args.until === void 0 ? void 0 : activityDate("until", args.until);
|
|
62853
|
+
if (since && until && since.getTime() >= until.getTime()) throw new Error("knowledge_activity: since must be earlier than until.");
|
|
62854
|
+
const limit = Math.min(Math.max(args.limit ?? ACTIVITY_DEFAULT_LIMIT, 1), ACTIVITY_MAX_LIMIT);
|
|
62855
|
+
if (!(await host.getStorage()).getCapabilities().supportsActivityDateRange) throw new KnowledgeUnsupportedCapabilityError("listPageActivity date range");
|
|
62856
|
+
const cursor = args.cursor === void 0 ? void 0 : decodeActivityCursor(args.cursor);
|
|
62857
|
+
const run = await start(host, context);
|
|
62858
|
+
const origin = args.from ? await run.pageOrCloseMatches(args.from) : void 0;
|
|
62859
|
+
const filter = origin ? origin.isScope ? { scopeId: origin.id } : { pageId: origin.id } : {};
|
|
62860
|
+
const bind = await activityBinding([
|
|
62861
|
+
since?.toISOString(),
|
|
62862
|
+
until?.toISOString(),
|
|
62863
|
+
"scopeId" in filter ? filter.scopeId : void 0,
|
|
62864
|
+
"pageId" in filter ? filter.pageId : void 0
|
|
62865
|
+
]);
|
|
62866
|
+
if (cursor && cursor.bind !== bind) throw new Error("knowledge_activity: this cursor came from a call with different since, until or from. Pass the same ones as the call that returned it.");
|
|
62867
|
+
const entries = [];
|
|
62868
|
+
let used = 0;
|
|
62869
|
+
let position = cursor ? {
|
|
62870
|
+
createdAt: new Date(cursor.before[0]),
|
|
62871
|
+
id: cursor.before[1]
|
|
62872
|
+
} : void 0;
|
|
62873
|
+
let more = false;
|
|
62874
|
+
let stopped = false;
|
|
62875
|
+
let batches = 0;
|
|
62876
|
+
while (!stopped && entries.length < limit && batches < ACTIVITY_MAX_BATCHES) {
|
|
62877
|
+
batches++;
|
|
62878
|
+
const startedAt = position;
|
|
62879
|
+
const batch = await run.storage.listPageActivity({
|
|
62880
|
+
read: run.read,
|
|
62881
|
+
...filter,
|
|
62882
|
+
...since ? { since } : {},
|
|
62883
|
+
...until ? { until } : {},
|
|
62884
|
+
...position ? { before: position } : {},
|
|
62885
|
+
limit: limit - entries.length
|
|
62886
|
+
});
|
|
62887
|
+
more = batch.nextCursor !== void 0;
|
|
62888
|
+
const pages = /* @__PURE__ */ new Map();
|
|
62889
|
+
const notes = /* @__PURE__ */ new Map();
|
|
62890
|
+
for (const event of batch.events) {
|
|
62891
|
+
if (!pages.has(event.pageId)) {
|
|
62892
|
+
const page = await run.storage.getPage({
|
|
62893
|
+
id: event.pageId,
|
|
62894
|
+
read: run.read
|
|
62895
|
+
});
|
|
62896
|
+
if (page) pages.set(page.id, page);
|
|
62897
|
+
}
|
|
62898
|
+
if (event.noteId && !notes.has(event.noteId)) {
|
|
62899
|
+
const note = await run.storage.getNote({
|
|
62900
|
+
id: event.noteId,
|
|
62901
|
+
read: run.read,
|
|
62902
|
+
includeDeleted: true
|
|
62903
|
+
});
|
|
62904
|
+
if (note) notes.set(note.id, note);
|
|
62905
|
+
}
|
|
62906
|
+
}
|
|
62907
|
+
const { refs } = await pageRefs(run, [...pages.values()]);
|
|
62908
|
+
for (const event of batch.events) {
|
|
62909
|
+
const page = pages.get(event.pageId);
|
|
62910
|
+
const note = event.noteId ? notes.get(event.noteId) : void 0;
|
|
62911
|
+
if (!page || event.noteId && !note) {
|
|
62912
|
+
position = {
|
|
62913
|
+
createdAt: event.createdAt,
|
|
62914
|
+
id: event.id
|
|
62915
|
+
};
|
|
62916
|
+
continue;
|
|
62917
|
+
}
|
|
62918
|
+
const entry = {
|
|
62919
|
+
at: event.createdAt.toISOString(),
|
|
62920
|
+
action: event.action,
|
|
62921
|
+
page: {
|
|
62922
|
+
ref: refs.get(page.id) ?? page.id,
|
|
62923
|
+
name: page.name,
|
|
62924
|
+
...page.deletedAt ? { deleted: true } : {}
|
|
62925
|
+
},
|
|
62926
|
+
author: event.provenance.author,
|
|
62927
|
+
...note ? { note: note.deletedAt ? {
|
|
62928
|
+
ref: note.id,
|
|
62929
|
+
removed: true
|
|
62930
|
+
} : {
|
|
62931
|
+
ref: note.id,
|
|
62932
|
+
text: note.text,
|
|
62933
|
+
current: true
|
|
62934
|
+
} } : {}
|
|
62935
|
+
};
|
|
62936
|
+
let size = require_workspace.estimateTokenCount(JSON.stringify(entry));
|
|
62937
|
+
if (entries.length > 0 && used + size > maxTokens) {
|
|
62938
|
+
stopped = true;
|
|
62939
|
+
break;
|
|
62940
|
+
}
|
|
62941
|
+
if (entries.length === 0 && size > maxTokens && entry.note && "text" in entry.note) {
|
|
62942
|
+
const full = entry.note.text;
|
|
62943
|
+
let keep = full.length;
|
|
62944
|
+
while (keep > 0 && size > maxTokens) {
|
|
62945
|
+
keep = Math.floor(keep * .8);
|
|
62946
|
+
entry.note = {
|
|
62947
|
+
ref: entry.note.ref,
|
|
62948
|
+
text: full.slice(0, keep),
|
|
62949
|
+
current: true,
|
|
62950
|
+
truncated: true
|
|
62951
|
+
};
|
|
62952
|
+
size = require_workspace.estimateTokenCount(JSON.stringify(entry));
|
|
62953
|
+
}
|
|
62954
|
+
}
|
|
62955
|
+
entries.push(entry);
|
|
62956
|
+
used += size;
|
|
62957
|
+
position = {
|
|
62958
|
+
createdAt: event.createdAt,
|
|
62959
|
+
id: event.id
|
|
62960
|
+
};
|
|
62961
|
+
if (entries.length >= limit) break;
|
|
62962
|
+
}
|
|
62963
|
+
if (!more) break;
|
|
62964
|
+
if (position === startedAt) throw new Error("knowledge_activity: the store returned a continuation without any changes; stopping.");
|
|
62965
|
+
if (!stopped && entries.length >= limit) break;
|
|
62966
|
+
}
|
|
62967
|
+
const hasMore = stopped || more;
|
|
62968
|
+
return {
|
|
62969
|
+
...origin ? { from: {
|
|
62970
|
+
ref: (await pageRefs(run, [origin])).refs.get(origin.id) ?? origin.id,
|
|
62971
|
+
name: origin.name
|
|
62972
|
+
} } : {},
|
|
62973
|
+
changes: entries,
|
|
62974
|
+
...hasMore && position ? {
|
|
62975
|
+
more: true,
|
|
62976
|
+
cursor: encodeActivityCursor({
|
|
62977
|
+
v: 1,
|
|
62978
|
+
before: [position.createdAt.toISOString(), position.id],
|
|
62979
|
+
bind
|
|
62980
|
+
})
|
|
62981
|
+
} : {}
|
|
62982
|
+
};
|
|
62983
|
+
}
|
|
62984
|
+
});
|
|
62985
|
+
}
|
|
62543
62986
|
/** The schema-4 Knowledge tools. @internal */
|
|
62544
62987
|
function buildKnowledgePageTools(host, groups, onPinChange) {
|
|
62545
62988
|
const tools = {};
|
|
@@ -62547,6 +62990,7 @@ function buildKnowledgePageTools(host, groups, onPinChange) {
|
|
|
62547
62990
|
tools.knowledge_list = listTool(host);
|
|
62548
62991
|
tools.knowledge_search = searchTool(host);
|
|
62549
62992
|
tools.knowledge_read = readTool(host);
|
|
62993
|
+
tools.knowledge_activity = activityTool(host);
|
|
62550
62994
|
}
|
|
62551
62995
|
if (groups.write) {
|
|
62552
62996
|
tools.knowledge_page = pageTool(host);
|
|
@@ -80914,7 +81358,11 @@ var EventedAgentExecutionEngine = class extends DefaultAgentExecutionEngine {
|
|
|
80914
81358
|
}
|
|
80915
81359
|
prepareExecution(pubsub, fence, workflowEngine, logger, guardrailLogger) {
|
|
80916
81360
|
const engine = this.resolveWorkflowEngine(workflowEngine, logger);
|
|
80917
|
-
const sharedTransport = engine === "evented" && pubsub !== void 0 &&
|
|
81361
|
+
const sharedTransport = engine === "evented" && pubsub !== void 0 && reachesOtherProcesses(pubsub);
|
|
81362
|
+
if (sharedTransport && this.mastra) {
|
|
81363
|
+
const mastra = this.mastra;
|
|
81364
|
+
Promise.resolve(mastra.getStorage()?.getStore("workflows")).catch(() => void 0).then((store) => warnUnsupportedEventedSetup(mastra, store)).catch(() => {});
|
|
81365
|
+
}
|
|
80918
81366
|
const sharedExecution = sharedTransport && fence?.generation !== void 0;
|
|
80919
81367
|
if (sharedTransport && !sharedExecution && !this.#warnedUnfencedSharedExecution) {
|
|
80920
81368
|
this.#warnedUnfencedSharedExecution = true;
|
|
@@ -81360,7 +81808,7 @@ async function prepareForDurableExecution(options) {
|
|
|
81360
81808
|
});
|
|
81361
81809
|
let tripwireData;
|
|
81362
81810
|
if (inputProcessors.length > 0) try {
|
|
81363
|
-
const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-
|
|
81811
|
+
const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-Dvy_0o14.cjs")).then((n) => n.runner_exports);
|
|
81364
81812
|
await new ProcessorRunner({
|
|
81365
81813
|
inputProcessors,
|
|
81366
81814
|
outputProcessors,
|
|
@@ -93232,7 +93680,7 @@ var Agent = class Agent extends require_base.MastraBase {
|
|
|
93232
93680
|
*
|
|
93233
93681
|
* @internal
|
|
93234
93682
|
*/
|
|
93235
|
-
async
|
|
93683
|
+
async __subscribeToRunStream(runId, options, onEvent) {
|
|
93236
93684
|
const pubsub = this.#executionStreamBus.forRun(this.__usesSharedRunLog()).pubsub;
|
|
93237
93685
|
const replayFloor = await this.#readReplayFloor(runId, options.offset);
|
|
93238
93686
|
const keepGeneration = createRunGenerationFilter(replayFloor);
|
|
@@ -102129,7 +102577,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
102129
102577
|
* `generation` only to name the owner a new acquisition takes.
|
|
102130
102578
|
*/
|
|
102131
102579
|
#threadLeaseOwner(pubsub, runId, generation) {
|
|
102132
|
-
if (this.#getPubSub(pubsub)
|
|
102580
|
+
if (!reachesOtherProcesses(this.#getPubSub(pubsub))) return threadLeaseOwner(runId);
|
|
102133
102581
|
if (generation !== void 0) return threadLeaseOwner(runId, generation);
|
|
102134
102582
|
const state = this.#getState(pubsub);
|
|
102135
102583
|
return state.leaseOwners.get(runId) ?? threadLeaseOwner(runId, state.threadRunsById.get(runId)?.generation);
|
|
@@ -107636,7 +108084,7 @@ function getActiveDurableAgentWorkflowExecutions(mastra) {
|
|
|
107636
108084
|
* execution behind a broker, which another process may be executing.
|
|
107637
108085
|
*/
|
|
107638
108086
|
function detachesOnShutdown(mastra, entry) {
|
|
107639
|
-
return !!entry.eventedExecution &&
|
|
108087
|
+
return !!entry.eventedExecution && reachesOtherProcesses(mastra.pubsub);
|
|
107640
108088
|
}
|
|
107641
108089
|
function isDurableAgentExecutionDetached(mastra, runId) {
|
|
107642
108090
|
const entry = globalRunRegistry.has(runId) ? globalRunRegistry.get(runId) : void 0;
|