@mastra/core 1.87.0-alpha.0 → 1.87.0-alpha.2
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/@ai-sdk_anthropic@3.0.137/dist/index.d.ts +2 -2
- package/dist/_types/@ai-sdk_google@3.0.140/dist/index.d.ts +2 -2
- package/dist/_types/@ai-sdk_openai@3.0.135/dist/index.d.ts +2 -2
- package/dist/a2a/index.cjs +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/agent/durable/index.cjs +2 -1
- package/dist/agent/durable/index.d.ts +1 -0
- package/dist/agent/durable/index.js +2 -2
- package/dist/agent/durable/run-registry.d.ts +12 -1
- package/dist/agent/durable/types.d.ts +2 -0
- package/dist/agent/durable/workflows/finalize-run.d.ts +2 -1
- package/dist/agent/index.cjs +3 -3
- package/dist/agent/index.js +3 -3
- package/dist/agent/message-list/index.cjs +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/thread-stream-runtime.d.ts +3 -1
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +1 -1
- package/dist/agent-controller/index.js +1 -1
- package/dist/{agent-controller-B8LoFdtu.js → agent-controller-Dc58ARqw.js} +6 -6
- package/dist/{agent-controller-DSnFynpa.cjs → agent-controller-v64JbuDa.cjs} +6 -6
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-Ci5h0dhj.cjs → background-tasks-DgiQNKh7.cjs} +1 -1
- package/dist/{background-tasks-IW7M4iD2.js → background-tasks-E-Jjxks4.js} +1 -1
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/{builder-14Uptu8y.cjs → builder-Dfp6Ckjr.cjs} +2 -2
- package/dist/{builder-DI2c2xjy.js → builder-Dh175HnQ.js} +2 -2
- package/dist/capabilities/302ai.json +197 -197
- package/dist/capabilities/abliteratedllm.json +27 -27
- package/dist/capabilities/abliteration-ai.json +10 -10
- package/dist/capabilities/above.json +22 -22
- package/dist/capabilities/adaption.json +12 -12
- package/dist/capabilities/adzuki.json +29 -29
- package/dist/capabilities/agentrouter.json +8 -8
- package/dist/capabilities/agnes.json +3 -3
- package/dist/capabilities/ai-router.json +5 -5
- package/dist/capabilities/aiand.json +23 -23
- package/dist/capabilities/aigrow.json +12 -12
- package/dist/capabilities/aimlapi.json +151 -152
- package/dist/capabilities/aixy.json +23 -23
- package/dist/capabilities/aki-io.json +14 -14
- package/dist/capabilities/alibaba-cn.json +92 -92
- package/dist/capabilities/alibaba-coding-plan-cn.json +5 -5
- package/dist/capabilities/alibaba-coding-plan.json +5 -5
- package/dist/capabilities/alibaba-token-plan-cn.json +53 -53
- package/dist/capabilities/alibaba-token-plan.json +51 -51
- package/dist/capabilities/alibaba.json +62 -62
- package/dist/capabilities/ambient.json +10 -10
- package/dist/capabilities/amd.json +8 -8
- package/dist/capabilities/anthropic.json +34 -34
- package/dist/capabilities/anyapi.json +18 -18
- package/dist/capabilities/apiko.json +4 -4
- package/dist/capabilities/arcee.json +6 -6
- package/dist/capabilities/augure.json +7 -7
- package/dist/capabilities/auriko.json +21 -21
- package/dist/capabilities/bailing.json +5 -5
- package/dist/capabilities/baseten.json +28 -28
- package/dist/capabilities/bee.json +2 -2
- package/dist/capabilities/berget.json +4 -4
- package/dist/capabilities/bothub.json +16 -16
- package/dist/capabilities/boundless.json +39 -39
- package/dist/capabilities/bumo.json +42 -42
- package/dist/capabilities/byteplus.json +29 -29
- package/dist/capabilities/cerebras.json +4 -4
- package/dist/capabilities/cheapaimodel.json +10 -10
- package/dist/capabilities/cheapest-token.json +29 -29
- package/dist/capabilities/chutes.json +5 -5
- package/dist/capabilities/cline-pass.json +39 -39
- package/dist/capabilities/cloudcode.json +8 -8
- package/dist/capabilities/cloudflare-workers-ai.json +18 -18
- package/dist/capabilities/commandcode.json +154 -154
- package/dist/capabilities/concentrate.json +269 -269
- package/dist/capabilities/cortecs.json +113 -113
- package/dist/capabilities/crossmodel.json +168 -168
- package/dist/capabilities/crusoe.json +9 -9
- package/dist/capabilities/daoxe.json +9 -9
- package/dist/capabilities/databricks.json +128 -128
- package/dist/capabilities/deepinfra.json +99 -99
- package/dist/capabilities/deepseek.json +4 -4
- package/dist/capabilities/digitalocean.json +117 -117
- package/dist/capabilities/dothoosh.json +30 -30
- package/dist/capabilities/doubleword.json +27 -27
- package/dist/capabilities/edenai.json +901 -1734
- package/dist/capabilities/empiriolabs.json +175 -175
- package/dist/capabilities/engy.json +21 -21
- package/dist/capabilities/evroc.json +13 -13
- package/dist/capabilities/ezkielyna.json +8 -8
- package/dist/capabilities/fastrouter.json +78 -78
- package/dist/capabilities/fireworks-ai.json +68 -68
- package/dist/capabilities/freemodel.json +21 -21
- package/dist/capabilities/frogbot.json +96 -96
- package/dist/capabilities/gisoo.json +17 -17
- package/dist/capabilities/gmicloud.json +12 -12
- package/dist/capabilities/google.json +51 -51
- package/dist/capabilities/graphn.json +16 -16
- package/dist/capabilities/greenpt.json +35 -35
- package/dist/capabilities/groq.json +2 -2
- package/dist/capabilities/helicone.json +85 -85
- package/dist/capabilities/hopper.json +2 -2
- package/dist/capabilities/hostinger-router.json +13 -13
- package/dist/capabilities/hpc-ai.json +4 -4
- package/dist/capabilities/huawei-maas.json +12 -12
- package/dist/capabilities/hubris.json +29 -29
- package/dist/capabilities/huggingface.json +89 -89
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +27 -27
- package/dist/capabilities/impossibl.json +149 -149
- package/dist/capabilities/inception.json +3 -3
- package/dist/capabilities/inco.json +4 -4
- package/dist/capabilities/infer.json +12 -12
- package/dist/capabilities/inferall.json +10 -10
- package/dist/capabilities/inference-coop.json +11 -11
- package/dist/capabilities/inferenceapis.json +17 -17
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +12 -12
- package/dist/capabilities/infomaniak.json +3 -3
- package/dist/capabilities/io-net.json +2 -2
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +44 -44
- package/dist/capabilities/jad-ai.json +2 -2
- package/dist/capabilities/jalapeno.json +11 -11
- package/dist/capabilities/jiekou.json +68 -68
- package/dist/capabilities/jzstoken.json +48 -48
- package/dist/capabilities/keln.json +20 -20
- package/dist/capabilities/kenari.json +125 -125
- package/dist/capabilities/kilo.json +623 -623
- 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 +2 -2
- package/dist/capabilities/klavo.json +18 -18
- package/dist/capabilities/korouter.json +30 -30
- package/dist/capabilities/kunavo.json +6 -6
- package/dist/capabilities/liquid.json +12 -12
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +916 -916
- package/dist/capabilities/llmgateway.json +339 -339
- package/dist/capabilities/llmtr.json +31 -31
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +51 -51
- package/dist/capabilities/lyceum.json +4 -4
- package/dist/capabilities/melious.json +12 -12
- package/dist/capabilities/merge-gateway.json +255 -254
- package/dist/capabilities/meta.json +7 -7
- package/dist/capabilities/minimax-cn-coding-plan.json +2 -2
- package/dist/capabilities/minimax-cn.json +5 -5
- package/dist/capabilities/minimax-coding-plan.json +2 -2
- package/dist/capabilities/minimax.json +5 -5
- package/dist/capabilities/mistral.json +18 -18
- package/dist/capabilities/mixlayer.json +5 -5
- package/dist/capabilities/modal.json +10 -10
- package/dist/capabilities/model-oracle-ai.json +21 -21
- package/dist/capabilities/modelis.json +19 -19
- package/dist/capabilities/modular.json +10 -10
- package/dist/capabilities/moneo.json +14 -14
- package/dist/capabilities/moonshotai-cn.json +5 -5
- package/dist/capabilities/moonshotai.json +5 -5
- package/dist/capabilities/morph.json +14 -14
- package/dist/capabilities/munito-eu.json +8 -8
- package/dist/capabilities/munito.json +9 -9
- package/dist/capabilities/nan.json +28 -28
- package/dist/capabilities/nano-gpt.json +586 -584
- package/dist/capabilities/nearai.json +87 -87
- package/dist/capabilities/nebius.json +26 -26
- package/dist/capabilities/neon.json +122 -122
- package/dist/capabilities/neuralwatt.json +45 -45
- package/dist/capabilities/nokeep.json +2 -2
- package/dist/capabilities/novita-ai.json +163 -163
- package/dist/capabilities/nvidia.json +22 -22
- package/dist/capabilities/oathbreaker.json +2 -2
- package/dist/capabilities/obscurify.json +25 -25
- package/dist/capabilities/oci.json +5 -5
- package/dist/capabilities/ofox.json +293 -293
- package/dist/capabilities/ollama-cloud.json +58 -58
- package/dist/capabilities/openai.json +55 -55
- package/dist/capabilities/opencode-go.json +86 -86
- package/dist/capabilities/openreason.json +4 -4
- package/dist/capabilities/openrouter.json +529 -535
- package/dist/capabilities/opper.json +27 -27
- package/dist/capabilities/orcarouter.json +192 -192
- package/dist/capabilities/outerlabs.json +31 -31
- package/dist/capabilities/ovhcloud.json +20 -20
- package/dist/capabilities/pareto.json +5 -5
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +64 -64
- package/dist/capabilities/perplexity.json +2 -2
- package/dist/capabilities/phala.json +22 -22
- package/dist/capabilities/pioneer.json +20 -20
- package/dist/capabilities/poe.json +113 -113
- package/dist/capabilities/poolside.json +3 -3
- package/dist/capabilities/powerspring.json +9 -9
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +110 -110
- package/dist/capabilities/privatemode-ai.json +12 -12
- package/dist/capabilities/proxystacks.json +7 -7
- package/dist/capabilities/qiniu-ai.json +14 -14
- package/dist/capabilities/refuseless.json +7 -7
- package/dist/capabilities/regolo-ai.json +8 -8
- package/dist/capabilities/requesty.json +172 -172
- package/dist/capabilities/ruapi.json +15 -15
- package/dist/capabilities/runcrate.json +6 -6
- package/dist/capabilities/runinfra.json +13 -13
- package/dist/capabilities/sakana.json +7 -7
- package/dist/capabilities/sambanova.json +9 -9
- package/dist/capabilities/sandbase.json +24 -24
- package/dist/capabilities/sarvam.json +12 -12
- package/dist/capabilities/scaleway.json +18 -18
- package/dist/capabilities/scnet-token-plan.json +9 -9
- package/dist/capabilities/scx-ai.json +30 -30
- package/dist/capabilities/sensenova.json +12 -12
- package/dist/capabilities/siliconflow-cn.json +45 -45
- package/dist/capabilities/siliconflow.json +53 -53
- package/dist/capabilities/snowflake-cortex.json +22 -22
- package/dist/capabilities/sokkan.json +7 -7
- package/dist/capabilities/sparrowcodes.json +19 -19
- package/dist/capabilities/standardcompute.json +89 -89
- package/dist/capabilities/steadyrouter.json +41 -41
- package/dist/capabilities/stepfun-ai-step-plan.json +5 -5
- package/dist/capabilities/stepfun-ai.json +5 -5
- package/dist/capabilities/stepfun-step-plan.json +5 -5
- package/dist/capabilities/stepfun.json +5 -5
- package/dist/capabilities/stepping-stone.json +11 -11
- package/dist/capabilities/subconscious.json +2 -2
- package/dist/capabilities/synthetic.json +10 -10
- package/dist/capabilities/synthorai.json +23 -23
- package/dist/capabilities/teamorouter.json +25 -25
- package/dist/capabilities/teapot-router.json +13 -13
- package/dist/capabilities/tencent-token-plan.json +40 -40
- package/dist/capabilities/tencent-tokenhub.json +45 -45
- package/dist/capabilities/tensorx.json +27 -27
- package/dist/capabilities/the-grid-ai.json +37 -37
- package/dist/capabilities/thinkingmachines.json +74 -74
- package/dist/capabilities/tinfoil.json +12 -12
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +53 -53
- package/dist/capabilities/tokengo.json +23 -23
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/trustedrouter.json +4 -4
- package/dist/capabilities/trustedtokens.json +12 -12
- package/dist/capabilities/umans-ai-coding-plan.json +14 -14
- package/dist/capabilities/umans-ai.json +10 -10
- package/dist/capabilities/unrestricted.json +8 -8
- package/dist/capabilities/uplinkswitch.json +23 -23
- package/dist/capabilities/upstage.json +7 -7
- package/dist/capabilities/vancine.json +26 -26
- package/dist/capabilities/vercel.json +576 -576
- package/dist/capabilities/vivgrid.json +85 -85
- package/dist/capabilities/volcengine-coding-plan.json +36 -27
- package/dist/capabilities/volcengine.json +27 -27
- package/dist/capabilities/vultr.json +31 -31
- package/dist/capabilities/wafer.ai.json +14 -14
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +11 -11
- package/dist/capabilities/wandb.json +11 -11
- package/dist/capabilities/watt.json +24 -24
- package/dist/capabilities/xai.json +6 -6
- package/dist/capabilities/xpersona.json +12 -12
- package/dist/capabilities/xxapi.json +29 -29
- package/dist/capabilities/zai-coding-plan.json +6 -6
- package/dist/capabilities/zai.json +32 -32
- package/dist/capabilities/zenifra.json +27 -27
- package/dist/capabilities/zenmux.json +186 -186
- package/dist/capabilities/zerogpu.json +14 -14
- package/dist/capabilities/zhipuai-coding-plan.json +8 -8
- package/dist/capabilities/zhipuai.json +31 -31
- package/dist/capabilities/zro.json +6 -6
- package/dist/channels/agent-channels.d.ts +7 -0
- package/dist/channels/attach-file-tool.d.ts +22 -0
- package/dist/channels/index.cjs +11 -2
- package/dist/channels/index.d.ts +10 -0
- package/dist/channels/index.js +3 -3
- package/dist/channels/reply-guidance-processor.d.ts +26 -0
- package/dist/channels/reply-mode.d.ts +66 -0
- package/dist/channels/reply-reminder-processor.d.ts +23 -0
- package/dist/channels/reply-tool.d.ts +43 -0
- package/dist/channels/thread-link-processor.d.ts +48 -0
- package/dist/channels/thread-lookup.d.ts +16 -0
- package/dist/channels/tool-announcement-processor.d.ts +29 -0
- package/dist/channels/types.d.ts +25 -0
- package/dist/{channels-Wh32drgu.js → channels-0AO7PMJF.js} +99 -2
- package/dist/{channels-tVV_de9Q.cjs → channels-BZL9RT2i.cjs} +122 -1
- package/dist/coding-agent/index.cjs +1 -1
- package/dist/coding-agent/index.js +1 -1
- package/dist/datasets/experiment/index.d.ts +1 -1
- package/dist/datasets/experiment/item.d.ts +4 -3
- package/dist/datasets/experiment/scorer.d.ts +34 -11
- package/dist/datasets/index.cjs +3 -2
- package/dist/datasets/index.js +3 -3
- package/dist/{dist-ByO0vuJJ-BjMue5_p.cjs → dist-CufwpBZM-CwERFaas.cjs} +4 -4
- package/dist/{dist-ByO0vuJJ-CCXLBnvJ.js → dist-CufwpBZM-DK14Qe0Z.js} +4 -4
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +743 -743
- package/dist/docs/references/docs-channels.md +43 -0
- package/dist/docs/references/docs-evals-experiments.md +13 -3
- package/dist/docs/references/reference-agents-durable-agent.md +2 -0
- package/dist/docs/references/reference-channels-thread-link.md +67 -0
- package/dist/docs/references/reference-workspace-factory-sandbox.md +2 -1
- package/dist/docs/references/reference.md +1 -0
- 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/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/host.d.ts +7 -1
- package/dist/knowledge/importers/runner.d.ts +12 -0
- package/dist/knowledge/importers/types.d.ts +2 -0
- package/dist/knowledge/index.cjs +82 -6
- package/dist/knowledge/index.js +82 -6
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +7397 -7534
- package/dist/{llm-B1zaFLYZ.js → llm-B46V7Mi7.js} +2 -2
- package/dist/{llm-BAiOsNAP.cjs → llm-B4AeSFvV.cjs} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-ChK9GdGz.js → manager-BRAvwB9b.js} +120 -70
- package/dist/{manager-BVX9nVrM.cjs → manager-BwDxA1Nn.cjs} +125 -69
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-CUGfgEpZ.js → mastra-CIx6qEq2.js} +16 -16
- package/dist/{mastra-HSmofHEJ.cjs → mastra-DBhdD172.cjs} +16 -16
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/{message-list-Cj0Sq_JP.cjs → message-list-DfN9mWeN.cjs} +121 -121
- package/dist/{message-list-KRbg-TnI.js → message-list-wI71UGxk.js} +1 -1
- package/dist/{model-C47BJRtR.js → model-CJMsDU8w.js} +1 -1
- package/dist/{model-WahorgzJ.cjs → model-CYhAa5qO.cjs} +1 -1
- package/dist/{netlify-D99AnEhW.cjs → netlify-Bw7Vd58y.cjs} +11 -11
- package/dist/{netlify-CfDXkuLf.js → netlify-C9aJA6Cv.js} +10 -10
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- 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-CO1NVbO5.cjs → provider-registry-Bn_7VvZ8.cjs} +22046 -22320
- package/dist/{provider-registry-CR385GJ4.js → provider-registry-DOfYSEju.js} +22046 -22320
- package/dist/provider-registry.json +22352 -22626
- package/dist/{registry-generator-Cvp34qcB.cjs → registry-generator-BnK5Npgr.cjs} +1 -1
- package/dist/{registry-generator-B3erRqYS.js → registry-generator-Cw594Ttt.js} +1 -1
- package/dist/{rehydrate-Da4hNuaK.cjs → rehydrate-BWnd_TEx.cjs} +2 -2
- package/dist/{rehydrate-CJBLrZxs.js → rehydrate-Dgqkw7Py.js} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-DdeEBsVW.js → run-registry-DhOKJtlb.js} +848 -186
- package/dist/{run-registry-TOOfO3hT.cjs → run-registry-lLRc7EE6.cjs} +883 -185
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-DH7Qgz8l.cjs → stream-BIDts1fZ.cjs} +2 -2
- package/dist/{stream-C5PagEDs.js → stream-C8HKG3qC.js} +2 -2
- 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-DVYJXlQJ.js → tool-loop-agent-DM5V_0XS.js} +4 -4
- package/dist/{tool-loop-agent-CJTs4T8b.cjs → tool-loop-agent-PEY5a1R6.cjs} +4 -4
- package/dist/{utils-xJi_N6Tx.cjs → utils-CxMSu_wc.cjs} +1 -1
- package/dist/{utils-D8upuTwy.js → utils-DcnKVK34.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-DTkW3Vlp.js → validate-Dn750ciE.js} +1 -1
- package/dist/{validate-6eZ8Wssn.cjs → validate-RVKgazCf.cjs} +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +2 -2
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-24ORi-wV.cjs → worker-CFPu9qwV.cjs} +2 -2
- package/dist/{worker-Dqubrnf8.js → worker-DJPAdazC.js} +2 -2
- package/dist/{worker-BO3u_WjZ.cjs → worker-Dx0ZHMGX.cjs} +2 -2
- package/dist/{worker-DbcFkKJO.js → worker-SDi9jbP5.js} +2 -2
- package/dist/{workflow-wXOf72fO.js → workflow-DkBqNn7X.js} +3 -3
- package/dist/{workflow-D5Fc5ieC.cjs → workflow-ZFOz_365.cjs} +3 -3
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/package.json +7 -7
- package/src/llm/model/provider-types.generated.d.ts +7397 -7534
- /package/dist/_types/{@ai-sdk_provider-utils@4.0.66 → @ai-sdk_provider-utils@4.0.67}/dist/index.d.ts +0 -0
- /package/dist/_types/{@ai-sdk_provider-utils@4.0.66 → @ai-sdk_provider-utils@4.0.67}/package.json +0 -0
|
@@ -4,14 +4,14 @@ import { t as MastraBase } from "./base-CKLWBhDo.js";
|
|
|
4
4
|
import { A as compactStopReasonContext, D as agentLoopTermination, O as executionFailureTermination, S as resolveObservabilityContext, b as wrapMastra, i as subtractReportedUsage, k as tripwireTermination, n as extractUsageMetrics, r as isUsageIncomplete, t as calculateObservedUsage, x as createObservabilityContext, y as unwrapMastraTracingProxy } from "./observability-D7RNOAPx.js";
|
|
5
5
|
import { a as MastraNonRetryableError, i as MastraError, n as ErrorDomain, o as getErrorFromUnknown, t as ErrorCategory } from "./error-oh2DLsP2.js";
|
|
6
6
|
import { a as classifyProviderError, l as describeProviderError, t as recordTerminalErrorMessage, u as readProviderErrorDetails } from "./error-BC9Au-22.js";
|
|
7
|
-
import { $ as resolveProcessorSpanAttributes, $t as computeModelOutputProviderMetadata, A as OUTPUT_STREAM_HOOK_DURATION_KEY_PREFIX, An as safeError, B as ProviderHistoryCompat, Bt as summarizeStepResult, C as markChunkOutputProcessed, Cn as isMastraTimeoutError, Ct as resolveTemplate, D as asJsonSchema, Dn as MastraModelInput, Dt as getStepResult, E as isStructuredOutputError, Et as validateTemplate, F as findOwnModelStepSpan, Ft as materializeState, G as REPROCESS_PART_KEY, Gt as patchState, Ht as applyStatePatch, It as materializeWorkflowRun, J as summarizeActiveToolsForSpan, Jt as isObservationalMemoryEnabled$1, K as takeHeldParts, L as isTrailingAssistantGuardContinuation, Lt as pickStateKeys, M as ProcessorState, Mn as createRunScopeKey, Mt as applyStateColumnsWrite, N as endOutputStreamSpanAtStepEnd, Nt as isStateCheckpointDue, O as getResponseFormat, On as safeClose, Ot as getStepResultAsync, P as endOutputStreamSpanOutsideStep, Pt as latestStepResults, Q as summarizeToolChoiceForSpan, Qt as commitToolResult, R as needsTrailingAssistantGuard, Rt as stateBaseOf, S as stampChunkProducedAt, Sn as guardStreamWithAbort, T as escapeUnescapedControlCharsInJsonStrings, Tn as settledOrElapsed, Tt as traverseMappingPath, Vt as unusedStateEntries, W as FLUSH_HELD_PARTS_KEY, Wt as diffStateAsJson, X as summarizeProcessorResultForSpan, Xt as parseMemoryRequestContext, Y as summarizeProcessorModelForSpan, Z as summarizeProcessorToolsForSpan, _ as reconcileBufferedStepTexts, _n as DEADLINE_SAVE_WAIT_MS, _t as collectMappingStepRefs, a as convertFullStreamChunkToMastra, an as withAgentWorkflowToolMarker, at as RunJournal, b as resolveProcessorWriterMessageId, bn as getAbortReason, bt as resolveStepOutputs, c as WorkflowRunOutput, cn as isProcessorWorkflow, ct as hydrateStepResults, d as MastraModelOutput, dn as resolveThreadIdFromArgs, dt as loadStepResults, en as hasToolResultProcessor, et as resolveProcessorSpanName, f as clearStepPartIndexes, fn as supportedLanguageModelSpecifications, ft as loadedStepResults, g as persistProcessorDataChunk, gn as DEADLINE_SAVE_CLAIM_HOLD_MS, gt as stubStepResult, h as findStepPartBoundaries, hn as applyStateSignal, ht as storageV2StepResultAccessors, in as snapshotToolResult, it as PROCESSOR_ABORT_SIGNAL, j as ProcessorRunner, jn as createRunScope, k as isSignalChunkExcluded, kn as safeEnqueue, kt as getSnapshotMemoryInfo, l as TripWire, ln as isSupportedLanguageModel, lt as isStepResultStub, m as findIterationOffsetInParts, mn as tryStreamWithJsonFallback, mt as residentStepResultsLoader, nn as readModelOutput, nt as PROCESSOR_LATE_SIGNAL_SINK, on as normalizeModelOutput, ot as buildStepResultAccessors, p as createDestructurableOutput, pn as tryGenerateWithJsonFallback, pt as residentStepResults, q as withoutHeldContent, rn as resolveModelOutputAfterToolResultProcessors, rt as createProcessorSendSignal, s as MastraAgentNetworkStream, sn as validationErrorModelOutput, st as getHydratedStepResult, tn as latestProcessedModelOutput, tt as toProcessorSpanPhase, u as getModelOutputForTripwire, un as resolveSuspendedToolRunId, ut as lazyStepResults, v as resolveMessageText, vn as MastraTimeoutError, vt as collectPredicateStepRefs, w as createOutputHandler, wn as raceAgainstAbort, wt as templateReadsState, x as getChunkProducedAt, xn as guardStreamUntilMatch, xt as stepRefId, y as resolveOutputMessageSkippingCompletionChecks, yn as createTimeoutAbortSignal, yt as predicateReadsState, z as removeTrailingAssistantGuardContinuations, zt as stateColumnsWrite } from "./stream-
|
|
7
|
+
import { $ as resolveProcessorSpanAttributes, $t as computeModelOutputProviderMetadata, A as OUTPUT_STREAM_HOOK_DURATION_KEY_PREFIX, An as safeError, B as ProviderHistoryCompat, Bt as summarizeStepResult, C as markChunkOutputProcessed, Cn as isMastraTimeoutError, Ct as resolveTemplate, D as asJsonSchema, Dn as MastraModelInput, Dt as getStepResult, E as isStructuredOutputError, Et as validateTemplate, F as findOwnModelStepSpan, Ft as materializeState, G as REPROCESS_PART_KEY, Gt as patchState, Ht as applyStatePatch, It as materializeWorkflowRun, J as summarizeActiveToolsForSpan, Jt as isObservationalMemoryEnabled$1, K as takeHeldParts, L as isTrailingAssistantGuardContinuation, Lt as pickStateKeys, M as ProcessorState, Mn as createRunScopeKey, Mt as applyStateColumnsWrite, N as endOutputStreamSpanAtStepEnd, Nt as isStateCheckpointDue, O as getResponseFormat, On as safeClose, Ot as getStepResultAsync, P as endOutputStreamSpanOutsideStep, Pt as latestStepResults, Q as summarizeToolChoiceForSpan, Qt as commitToolResult, R as needsTrailingAssistantGuard, Rt as stateBaseOf, S as stampChunkProducedAt, Sn as guardStreamWithAbort, T as escapeUnescapedControlCharsInJsonStrings, Tn as settledOrElapsed, Tt as traverseMappingPath, Vt as unusedStateEntries, W as FLUSH_HELD_PARTS_KEY, Wt as diffStateAsJson, X as summarizeProcessorResultForSpan, Xt as parseMemoryRequestContext, Y as summarizeProcessorModelForSpan, Z as summarizeProcessorToolsForSpan, _ as reconcileBufferedStepTexts, _n as DEADLINE_SAVE_WAIT_MS, _t as collectMappingStepRefs, a as convertFullStreamChunkToMastra, an as withAgentWorkflowToolMarker, at as RunJournal, b as resolveProcessorWriterMessageId, bn as getAbortReason, bt as resolveStepOutputs, c as WorkflowRunOutput, cn as isProcessorWorkflow, ct as hydrateStepResults, d as MastraModelOutput, dn as resolveThreadIdFromArgs, dt as loadStepResults, en as hasToolResultProcessor, et as resolveProcessorSpanName, f as clearStepPartIndexes, fn as supportedLanguageModelSpecifications, ft as loadedStepResults, g as persistProcessorDataChunk, gn as DEADLINE_SAVE_CLAIM_HOLD_MS, gt as stubStepResult, h as findStepPartBoundaries, hn as applyStateSignal, ht as storageV2StepResultAccessors, in as snapshotToolResult, it as PROCESSOR_ABORT_SIGNAL, j as ProcessorRunner, jn as createRunScope, k as isSignalChunkExcluded, kn as safeEnqueue, kt as getSnapshotMemoryInfo, l as TripWire, ln as isSupportedLanguageModel, lt as isStepResultStub, m as findIterationOffsetInParts, mn as tryStreamWithJsonFallback, mt as residentStepResultsLoader, nn as readModelOutput, nt as PROCESSOR_LATE_SIGNAL_SINK, on as normalizeModelOutput, ot as buildStepResultAccessors, p as createDestructurableOutput, pn as tryGenerateWithJsonFallback, pt as residentStepResults, q as withoutHeldContent, rn as resolveModelOutputAfterToolResultProcessors, rt as createProcessorSendSignal, s as MastraAgentNetworkStream, sn as validationErrorModelOutput, st as getHydratedStepResult, tn as latestProcessedModelOutput, tt as toProcessorSpanPhase, u as getModelOutputForTripwire, un as resolveSuspendedToolRunId, ut as lazyStepResults, v as resolveMessageText, vn as MastraTimeoutError, vt as collectPredicateStepRefs, w as createOutputHandler, wn as raceAgainstAbort, wt as templateReadsState, x as getChunkProducedAt, xn as guardStreamUntilMatch, xt as stepRefId, y as resolveOutputMessageSkippingCompletionChecks, yn as createTimeoutAbortSignal, yt as predicateReadsState, z as removeTrailingAssistantGuardContinuations, zt as stateColumnsWrite } from "./stream-C8HKG3qC.js";
|
|
8
8
|
import { c as MASTRA_THREAD_ID_KEY, d as isReservedRequestContextKey, f as mergeVersionOverrides$1, l as MASTRA_VERSIONS_KEY, n as MASTRA_AUTH_TOKEN_KEY, o as MASTRA_RESOURCE_ID_KEY, p as withoutLiveRequestKeys, r as MASTRA_INHERITED_MEMORY_KEY, s as MASTRA_SCOPES_KEY, t as MASTRA_CONTINUATION_TOOL_CALL_IDS_KEY, u as RequestContext } from "./request-context-COnZHt2-.js";
|
|
9
9
|
import { S as withAck, _ as serializeError$1, h as stripModelSnapshots, n as PublisherQueueLimitError, p as slimNestedAgentChunks, r as CachingPubSub, t as DefaultStepResult, u as isRunLocalTopic, v as EventEmitterPubSub, x as isLeaseProvider, y as NoopLeaseProvider } from "./output-helpers-CVzhy1Y0.js";
|
|
10
|
-
import { A as stableStringify$1, E as removeWorkingMemoryTags, P as embed$3, Z as preserveResponseItemIdsOnMerge, a as isTerminalToolInvocationState, c as withUnavailableAttachmentUrls, d as aiV5UIMessagesToAIV5ModelMessages, f as coreContentToString, i as isClientToolInvocationUpdate, l as isDownloadAssetsError, m as filterMessagesForPersistence, n as MessageList, ot as normalizeToolOutput, p as messagesAreEqual, r as advancesToolInvocationState, s as unavailableAttachmentPlaceholder, t as convertMessages, u as MessageMerger } from "./message-list-
|
|
10
|
+
import { A as stableStringify$1, E as removeWorkingMemoryTags, P as embed$3, Z as preserveResponseItemIdsOnMerge, a as isTerminalToolInvocationState, c as withUnavailableAttachmentUrls, d as aiV5UIMessagesToAIV5ModelMessages, f as coreContentToString, i as isClientToolInvocationUpdate, l as isDownloadAssetsError, m as filterMessagesForPersistence, n as MessageList, ot as normalizeToolOutput, p as messagesAreEqual, r as advancesToolInvocationState, s as unavailableAttachmentPlaceholder, t as convertMessages, u as MessageMerger } from "./message-list-wI71UGxk.js";
|
|
11
11
|
import { Bt as listScoresArgsSchema, Ft as listLogsArgsSchema, Lt as listMetricsArgsSchema, Nt as listFeedbackArgsSchema, t as EntityType } from "./storage-Cc50aQAp.js";
|
|
12
12
|
import { a as getOrCreateSpan, f as resolveCurrentSpan, l as getTimeToFirstChunkMs, n as executeWithContextSync, o as getResumeTracingContext, p as resolveExportedSpanId, s as getRootExportSpan, t as executeWithContext, u as getWorkflowResumeTracingContext } from "./utils-DU_pU5SK.js";
|
|
13
13
|
import { i as setSpanErrorOrigin, n as getSpanErrorOrigin } from "./error-count-BH-rJW7q.js";
|
|
14
|
-
import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-
|
|
14
|
+
import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-B46V7Mi7.js";
|
|
15
15
|
import { a as withToolPayloadTransformMetadata, i as transformToolPayloadForTargets, n as hasTransformedToolPayload, o as withToolPayloadTransformProviderMetadata, r as normalizeToolPayloadTransformPolicy, t as getTransformedToolPayload } from "./payload-transform-Dj3HUeD4.js";
|
|
16
16
|
import { boundedStringify, ensureSerializable, safeStringify } from "./utils/safe-stringify.js";
|
|
17
17
|
import { d as signalSpanAttributes, h as signalToXmlMarkup, l as mastraDBMessageToSignal, n as createSignal, o as isMastraSignalMessage, s as isTransientSignalMessage, u as resolveDeliveryAttributes } from "./signals-CqR_iWkg.js";
|
|
@@ -24,13 +24,13 @@ import { _ as getRequestContextInputValues, a as getModelFacingValidationError,
|
|
|
24
24
|
import { a as isApprovalExempt, c as isProviderDefinedTool, d as markAgentWorkflowTool, f as markApprovalExempt, l as isProviderTool, n as getNeedsApprovalFn, o as isBuiltBeforeApproval, r as getProviderToolName, s as isMastraTool, t as getBeforeApprovalFn } from "./toolchecks-DrsZdc3S.js";
|
|
25
25
|
import { a as waitDelay, i as getRetryAfterMs, n as DEFAULT_MAX_RETRY_AFTER_MS, r as clampDelayMs } from "./fetchWithRetry-DFSvpYDT.js";
|
|
26
26
|
import { i as hasFreeFormObject } from "./model-DS-b2R-R.js";
|
|
27
|
-
import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-
|
|
27
|
+
import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-DOfYSEju.js";
|
|
28
28
|
import { t as InMemoryServerCache } from "./inmemory-BK3zLwvM.js";
|
|
29
29
|
import { n as resolveDynamicArgument, t as getRequestUser } from "./dynamic-argument-BzPK3qPN.js";
|
|
30
|
-
import { t as MastraLLMV1 } from "./model-
|
|
31
|
-
import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-
|
|
30
|
+
import { t as MastraLLMV1 } from "./model-CJMsDU8w.js";
|
|
31
|
+
import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-DcnKVK34.js";
|
|
32
32
|
import { h as getWorkflowFGAResourceId, i as MastraFGAPermissions, y as requireFGA } from "./ee-iTj2bRDt-By_B9ngH.js";
|
|
33
|
-
import { a as resolveBackgroundConfig, o as createBackgroundTask, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-
|
|
33
|
+
import { a as resolveBackgroundConfig, o as createBackgroundTask, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-E-Jjxks4.js";
|
|
34
34
|
import { t as ToolStream } from "./stream-D9JOykz7.js";
|
|
35
35
|
import { MISSING, collectInvalidPredicatePaths, createPredicateEvaluator, derivePredicateLabel, normalizePredicatePath, walk } from "./predicate/index.js";
|
|
36
36
|
import { Classifier } from "./classifier/index.js";
|
|
@@ -12034,6 +12034,118 @@ function liveRequestEntries(runLevel) {
|
|
|
12034
12034
|
const kept = withoutLiveRequestKeys(live);
|
|
12035
12035
|
return Object.entries(live).filter(([key]) => !(key in kept));
|
|
12036
12036
|
}
|
|
12037
|
+
// src/agent/streams/constants.ts
|
|
12038
|
+
/**
|
|
12039
|
+
* Topics and event types of an agent's resumable run stream.
|
|
12040
|
+
*/
|
|
12041
|
+
/**
|
|
12042
|
+
* Generate the pubsub topic name for agent streaming events
|
|
12043
|
+
* @param runId - The unique run identifier
|
|
12044
|
+
* @returns The topic name for subscribing/publishing agent stream events
|
|
12045
|
+
*/
|
|
12046
|
+
const AGENT_STREAM_TOPIC = (runId) => `agent.stream.${runId}`;
|
|
12047
|
+
/**
|
|
12048
|
+
* Generate the pubsub topic name for agent control messages.
|
|
12049
|
+
*
|
|
12050
|
+
* Separate from {@link AGENT_STREAM_TOPIC} because control messages travel the
|
|
12051
|
+
* opposite direction: stream events flow worker -> consumer, control messages
|
|
12052
|
+
* flow caller -> worker. Keeping them apart means stream consumers never see
|
|
12053
|
+
* control traffic and vice versa.
|
|
12054
|
+
*
|
|
12055
|
+
* @param runId - The unique run identifier
|
|
12056
|
+
* @returns The topic name for publishing/subscribing agent control events
|
|
12057
|
+
*/
|
|
12058
|
+
const AGENT_CONTROL_TOPIC = (runId) => `agent.control.${runId}`;
|
|
12059
|
+
/**
|
|
12060
|
+
* Event type constants for agent control events
|
|
12061
|
+
*/
|
|
12062
|
+
const AgentControlEventTypes = {
|
|
12063
|
+
/**
|
|
12064
|
+
* Request that a run abort itself. Published by `abort()` in whichever
|
|
12065
|
+
* process the caller lives in; handled by whichever process is actually
|
|
12066
|
+
* executing the run's steps.
|
|
12067
|
+
*/
|
|
12068
|
+
ABORT_REQUEST: "abort-request" };
|
|
12069
|
+
/**
|
|
12070
|
+
* Event type constants for agent stream events
|
|
12071
|
+
*/
|
|
12072
|
+
const AgentStreamEventTypes = {
|
|
12073
|
+
/** Chunk of streaming data (text, tool call, etc.) */
|
|
12074
|
+
CHUNK: "chunk",
|
|
12075
|
+
/** Internal boundary preceding all output from an LLM execution step. */
|
|
12076
|
+
ITERATION_START: "iteration-start",
|
|
12077
|
+
/** Start of a new step in the agentic loop */
|
|
12078
|
+
STEP_START: "step-start",
|
|
12079
|
+
/** End of a step in the agentic loop */
|
|
12080
|
+
STEP_FINISH: "step-finish",
|
|
12081
|
+
/** Agent execution completed successfully */
|
|
12082
|
+
FINISH: "finish",
|
|
12083
|
+
/** Error occurred during execution */
|
|
12084
|
+
ERROR: "error",
|
|
12085
|
+
/** Workflow suspended (e.g., for tool approval) */
|
|
12086
|
+
SUSPENDED: "suspended",
|
|
12087
|
+
/** Execution aborted by abortSignal */
|
|
12088
|
+
ABORT: "abort",
|
|
12089
|
+
/** Single agentic-loop iteration completed (observability hook) */
|
|
12090
|
+
ITERATION_COMPLETE: "iteration-complete",
|
|
12091
|
+
/**
|
|
12092
|
+
* A new execution claimed the run. Carries no chunk: consumers only raise
|
|
12093
|
+
* their generation so events the superseded execution still publishes are
|
|
12094
|
+
* dropped.
|
|
12095
|
+
*/
|
|
12096
|
+
OWNERSHIP_CLAIMED: "ownership-claimed"
|
|
12097
|
+
};
|
|
12098
|
+
// src/agent/durable/constants.ts
|
|
12099
|
+
const DURABLE_STOP_WHEN_ERROR_ID = "DURABLE_AGENT_STOP_WHEN_FAILED";
|
|
12100
|
+
const REJECT_STREAM_ERROR = Symbol("mastra.durable.rejectStreamError");
|
|
12101
|
+
function markErrorForStreamRejection(error) {
|
|
12102
|
+
error[REJECT_STREAM_ERROR] = true;
|
|
12103
|
+
return error;
|
|
12104
|
+
}
|
|
12105
|
+
function shouldRejectStream(error) {
|
|
12106
|
+
return error[REJECT_STREAM_ERROR] === true;
|
|
12107
|
+
}
|
|
12108
|
+
/**
|
|
12109
|
+
* Default values for durable agent execution
|
|
12110
|
+
*/
|
|
12111
|
+
const DurableAgentDefaults = {
|
|
12112
|
+
/** Default maximum number of agentic loop iterations */
|
|
12113
|
+
MAX_STEPS: 5,
|
|
12114
|
+
/**
|
|
12115
|
+
* Default tool call concurrency.
|
|
12116
|
+
* Applied by `resolveDurableToolCallConcurrency` when a run doesn't
|
|
12117
|
+
* configure `toolCallConcurrency`. Approval / suspend-capable tool sets
|
|
12118
|
+
* always run sequentially (concurrency: 1) regardless of this value.
|
|
12119
|
+
*/
|
|
12120
|
+
TOOL_CALL_CONCURRENCY: 10
|
|
12121
|
+
};
|
|
12122
|
+
/**
|
|
12123
|
+
* Step IDs used in the durable agentic workflow
|
|
12124
|
+
*/
|
|
12125
|
+
const DurableStepIds = {
|
|
12126
|
+
/** LLM execution step */
|
|
12127
|
+
LLM_EXECUTION: "durable-llm-execution",
|
|
12128
|
+
/** Tool call step */
|
|
12129
|
+
TOOL_CALL: "durable-tool-call",
|
|
12130
|
+
/** LLM mapping step (combines results) */
|
|
12131
|
+
LLM_MAPPING: "durable-llm-mapping",
|
|
12132
|
+
/** Agentic execution workflow (one iteration) */
|
|
12133
|
+
AGENTIC_EXECUTION: "durable-agentic-execution",
|
|
12134
|
+
/** Full agentic loop workflow */
|
|
12135
|
+
AGENTIC_LOOP: "durable-agentic-loop",
|
|
12136
|
+
/** Scorer execution step */
|
|
12137
|
+
SCORER_EXECUTION: "durable-scorer-execution",
|
|
12138
|
+
/** isTaskComplete evaluation step */
|
|
12139
|
+
IS_TASK_COMPLETE: "durable-is-task-complete"
|
|
12140
|
+
};
|
|
12141
|
+
/** The loop's last step, which ends the run's spans when it succeeds. */
|
|
12142
|
+
const MAP_FINAL_OUTPUT_STEP_ID = "map-final-output";
|
|
12143
|
+
const RECOVER_ALREADY_IN_PROGRESS_ERROR_ID = "DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS";
|
|
12144
|
+
const RECOVER_SNAPSHOT_NOT_FOUND_ERROR_ID = "DURABLE_AGENT_RECOVER_SNAPSHOT_NOT_FOUND";
|
|
12145
|
+
const RECOVER_CHECKPOINT_NOT_AVAILABLE_ERROR_ID = "DURABLE_AGENT_RECOVER_CHECKPOINT_NOT_AVAILABLE";
|
|
12146
|
+
const RECOVER_RUN_SUSPENDED_ERROR_ID = "DURABLE_AGENT_RECOVER_RUN_SUSPENDED";
|
|
12147
|
+
const RECOVER_RUN_NOT_ACTIVE_ERROR_ID = "DURABLE_AGENT_RECOVER_RUN_NOT_ACTIVE";
|
|
12148
|
+
const RECOVER_SHUTDOWN_ERROR_ID = "DURABLE_AGENT_RECOVER_SHUTDOWN";
|
|
12037
12149
|
// src/agent/durable/execution-ownership-guard.ts
|
|
12038
12150
|
/** One step's observation of its immutable driver's claim. Never renews it. */
|
|
12039
12151
|
var ExecutionOwnershipGuard = class {
|
|
@@ -12151,67 +12263,6 @@ var ExecutionOwnershipGuard = class {
|
|
|
12151
12263
|
this.#unsubscribe?.();
|
|
12152
12264
|
}
|
|
12153
12265
|
};
|
|
12154
|
-
// src/agent/streams/constants.ts
|
|
12155
|
-
/**
|
|
12156
|
-
* Topics and event types of an agent's resumable run stream.
|
|
12157
|
-
*/
|
|
12158
|
-
/**
|
|
12159
|
-
* Generate the pubsub topic name for agent streaming events
|
|
12160
|
-
* @param runId - The unique run identifier
|
|
12161
|
-
* @returns The topic name for subscribing/publishing agent stream events
|
|
12162
|
-
*/
|
|
12163
|
-
const AGENT_STREAM_TOPIC = (runId) => `agent.stream.${runId}`;
|
|
12164
|
-
/**
|
|
12165
|
-
* Generate the pubsub topic name for agent control messages.
|
|
12166
|
-
*
|
|
12167
|
-
* Separate from {@link AGENT_STREAM_TOPIC} because control messages travel the
|
|
12168
|
-
* opposite direction: stream events flow worker -> consumer, control messages
|
|
12169
|
-
* flow caller -> worker. Keeping them apart means stream consumers never see
|
|
12170
|
-
* control traffic and vice versa.
|
|
12171
|
-
*
|
|
12172
|
-
* @param runId - The unique run identifier
|
|
12173
|
-
* @returns The topic name for publishing/subscribing agent control events
|
|
12174
|
-
*/
|
|
12175
|
-
const AGENT_CONTROL_TOPIC = (runId) => `agent.control.${runId}`;
|
|
12176
|
-
/**
|
|
12177
|
-
* Event type constants for agent control events
|
|
12178
|
-
*/
|
|
12179
|
-
const AgentControlEventTypes = {
|
|
12180
|
-
/**
|
|
12181
|
-
* Request that a run abort itself. Published by `abort()` in whichever
|
|
12182
|
-
* process the caller lives in; handled by whichever process is actually
|
|
12183
|
-
* executing the run's steps.
|
|
12184
|
-
*/
|
|
12185
|
-
ABORT_REQUEST: "abort-request" };
|
|
12186
|
-
/**
|
|
12187
|
-
* Event type constants for agent stream events
|
|
12188
|
-
*/
|
|
12189
|
-
const AgentStreamEventTypes = {
|
|
12190
|
-
/** Chunk of streaming data (text, tool call, etc.) */
|
|
12191
|
-
CHUNK: "chunk",
|
|
12192
|
-
/** Internal boundary preceding all output from an LLM execution step. */
|
|
12193
|
-
ITERATION_START: "iteration-start",
|
|
12194
|
-
/** Start of a new step in the agentic loop */
|
|
12195
|
-
STEP_START: "step-start",
|
|
12196
|
-
/** End of a step in the agentic loop */
|
|
12197
|
-
STEP_FINISH: "step-finish",
|
|
12198
|
-
/** Agent execution completed successfully */
|
|
12199
|
-
FINISH: "finish",
|
|
12200
|
-
/** Error occurred during execution */
|
|
12201
|
-
ERROR: "error",
|
|
12202
|
-
/** Workflow suspended (e.g., for tool approval) */
|
|
12203
|
-
SUSPENDED: "suspended",
|
|
12204
|
-
/** Execution aborted by abortSignal */
|
|
12205
|
-
ABORT: "abort",
|
|
12206
|
-
/** Single agentic-loop iteration completed (observability hook) */
|
|
12207
|
-
ITERATION_COMPLETE: "iteration-complete",
|
|
12208
|
-
/**
|
|
12209
|
-
* A new execution claimed the run. Carries no chunk: consumers only raise
|
|
12210
|
-
* their generation so events the superseded execution still publishes are
|
|
12211
|
-
* dropped.
|
|
12212
|
-
*/
|
|
12213
|
-
OWNERSHIP_CLAIMED: "ownership-claimed"
|
|
12214
|
-
};
|
|
12215
12266
|
// src/agent/streams/run-records.ts
|
|
12216
12267
|
/**
|
|
12217
12268
|
* Lifetime of a running or suspended run's record. Deliberately much longer
|
|
@@ -14223,26 +14274,97 @@ var ExecutionFence = class ExecutionFence {
|
|
|
14223
14274
|
if (!claim.agentId) return void 0;
|
|
14224
14275
|
const executionBackend = await resolveRemoteBackend(mastra, claim.agentId, runId, claim);
|
|
14225
14276
|
if (!executionBackend) return void 0;
|
|
14226
|
-
const
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14277
|
+
const details = {
|
|
14278
|
+
agentId: claim.agentId,
|
|
14279
|
+
runId,
|
|
14280
|
+
executionId: claim.executionId
|
|
14281
|
+
};
|
|
14282
|
+
const threadId = claim.threadId;
|
|
14283
|
+
const lease = threadId ? [
|
|
14284
|
+
mastra.pubsub,
|
|
14285
|
+
runId,
|
|
14286
|
+
threadId,
|
|
14287
|
+
claim.resourceId,
|
|
14288
|
+
claim.generation,
|
|
14289
|
+
claim.executionId
|
|
14290
|
+
] : void 0;
|
|
14291
|
+
let heartbeatRenewal;
|
|
14292
|
+
let participant;
|
|
14293
|
+
const verifyCurrent = async () => {
|
|
14294
|
+
await executionBackend.verify(claim, details);
|
|
14295
|
+
if (participant?.isLost()) throw new DurableExecutionFenceError(EXECUTION_UNVERIFIED_ERROR_ID, details);
|
|
14296
|
+
};
|
|
14297
|
+
const checkThread = async (threadLease, heartbeatWorker) => {
|
|
14298
|
+
const stopped = () => heartbeatWorker && (!heartbeatWorker.#heartbeat || heartbeatWorker.isLost());
|
|
14299
|
+
let timedOut = false;
|
|
14300
|
+
let timer;
|
|
14301
|
+
const check = async () => {
|
|
14302
|
+
let renewed;
|
|
14303
|
+
try {
|
|
14304
|
+
renewed = await agentThreadStreamRuntime.renewDurableThreadLease(...threadLease);
|
|
14305
|
+
} catch (error) {
|
|
14306
|
+
if (agentThreadStreamRuntime.isThreadLeaseBackendUnavailableToAll(mastra.pubsub, error)) return true;
|
|
14307
|
+
throw error;
|
|
14308
|
+
}
|
|
14309
|
+
if (renewed) return true;
|
|
14310
|
+
if (timedOut || stopped()) return void 0;
|
|
14311
|
+
await verifyCurrent();
|
|
14312
|
+
if (timedOut || stopped()) return void 0;
|
|
14313
|
+
let acquired;
|
|
14314
|
+
try {
|
|
14315
|
+
acquired = await agentThreadStreamRuntime.reclaimDurableThreadLease(...threadLease);
|
|
14316
|
+
} catch (error) {
|
|
14317
|
+
if (agentThreadStreamRuntime.isThreadLeaseBackendUnavailableToAll(mastra.pubsub, error)) return true;
|
|
14318
|
+
throw error;
|
|
14319
|
+
}
|
|
14320
|
+
if (acquired) try {
|
|
14321
|
+
await verifyCurrent();
|
|
14322
|
+
} catch (error) {
|
|
14323
|
+
if (error instanceof DurableExecutionFenceError && error.id === "DURABLE_AGENT_EXECUTION_SUPERSEDED") (async () => {
|
|
14324
|
+
const snapshot = await (await mastra.getStorage()?.getStore("workflows"))?.loadWorkflowSnapshot({
|
|
14325
|
+
workflowName: DurableStepIds.AGENTIC_LOOP,
|
|
14326
|
+
runId
|
|
14327
|
+
});
|
|
14328
|
+
if (!(snapshot?.status === "suspended" || snapshot?.status === "waiting") || await executionBackend.isSuperseded(claim)) await agentThreadStreamRuntime.releaseDurableThreadLease(...threadLease);
|
|
14329
|
+
})().catch(() => {});
|
|
14330
|
+
throw error;
|
|
14331
|
+
}
|
|
14332
|
+
else if (heartbeatWorker) {
|
|
14333
|
+
if (timedOut || stopped()) return void 0;
|
|
14334
|
+
const [pubsub, , threadId, resourceId] = threadLease;
|
|
14335
|
+
if (!await agentThreadStreamRuntime.isDurableThreadLeaseHeldByAnotherRun(pubsub, runId, threadId, resourceId)) return;
|
|
14336
|
+
}
|
|
14337
|
+
return acquired;
|
|
14338
|
+
};
|
|
14236
14339
|
try {
|
|
14237
|
-
return await
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14340
|
+
return await Promise.race([check(), new Promise((resolve) => {
|
|
14341
|
+
timer = setTimeout(() => {
|
|
14342
|
+
timedOut = true;
|
|
14343
|
+
resolve(void 0);
|
|
14344
|
+
}, EXECUTION_LEASE_RENEW_INTERVAL_MS);
|
|
14345
|
+
timer.unref?.();
|
|
14346
|
+
})]);
|
|
14347
|
+
} finally {
|
|
14348
|
+
clearTimeout(timer);
|
|
14242
14349
|
}
|
|
14243
14350
|
};
|
|
14244
14351
|
const backend = {
|
|
14245
14352
|
...executionBackend,
|
|
14353
|
+
verify: async () => {
|
|
14354
|
+
await verifyCurrent();
|
|
14355
|
+
if (!lease || claim.generation === void 0) return;
|
|
14356
|
+
for (;;) {
|
|
14357
|
+
const held = await checkThread(lease);
|
|
14358
|
+
await verifyCurrent();
|
|
14359
|
+
if (held === true) return;
|
|
14360
|
+
if (held === false) {
|
|
14361
|
+
ExecutionFence.releaseSharedClaim(mastra, runId, claim, "abandoned").catch(() => {});
|
|
14362
|
+
throw new DurableExecutionFenceError(EXECUTION_UNVERIFIED_ERROR_ID, details);
|
|
14363
|
+
}
|
|
14364
|
+
await sleep(VERIFY_RETRY_DELAY_MS);
|
|
14365
|
+
await verifyCurrent();
|
|
14366
|
+
}
|
|
14367
|
+
},
|
|
14246
14368
|
renew: async (current) => {
|
|
14247
14369
|
const result = await executionBackend.renew(current);
|
|
14248
14370
|
if (!result.renewed) {
|
|
@@ -14253,20 +14375,22 @@ var ExecutionFence = class ExecutionFence {
|
|
|
14253
14375
|
});
|
|
14254
14376
|
return result;
|
|
14255
14377
|
}
|
|
14256
|
-
if (
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14378
|
+
if (lease) {
|
|
14379
|
+
if (claim.generation === void 0) {
|
|
14380
|
+
if (!await agentThreadStreamRuntime.renewDurableThreadLease(...lease)) throw new DurableExecutionFenceError(EXECUTION_UNVERIFIED_ERROR_ID, details);
|
|
14381
|
+
} else if (participant && !heartbeatRenewal) {
|
|
14382
|
+
const worker = participant;
|
|
14383
|
+
heartbeatRenewal = checkThread(lease, worker).then(async (held) => {
|
|
14384
|
+
if (held !== false || !worker.#heartbeat || worker.isLost()) return;
|
|
14385
|
+
worker.#markLost(new DurableExecutionFenceError(EXECUTION_UNVERIFIED_ERROR_ID, details));
|
|
14386
|
+
await ExecutionFence.releaseSharedClaim(mastra, runId, claim, "abandoned");
|
|
14387
|
+
}).catch(() => {}).finally(() => heartbeatRenewal = void 0);
|
|
14388
|
+
}
|
|
14389
|
+
}
|
|
14261
14390
|
return result;
|
|
14262
14391
|
}
|
|
14263
14392
|
};
|
|
14264
14393
|
const startedAt = Date.now();
|
|
14265
|
-
const details = {
|
|
14266
|
-
agentId: claim.agentId,
|
|
14267
|
-
runId,
|
|
14268
|
-
executionId: claim.executionId
|
|
14269
|
-
};
|
|
14270
14394
|
let deadline;
|
|
14271
14395
|
try {
|
|
14272
14396
|
await Promise.race([(async () => {
|
|
@@ -14284,7 +14408,7 @@ var ExecutionFence = class ExecutionFence {
|
|
|
14284
14408
|
} finally {
|
|
14285
14409
|
if (deadline) clearTimeout(deadline);
|
|
14286
14410
|
}
|
|
14287
|
-
const fence = new ExecutionFence({
|
|
14411
|
+
const fence = participant = new ExecutionFence({
|
|
14288
14412
|
...details,
|
|
14289
14413
|
backend,
|
|
14290
14414
|
generation: claim.generation,
|
|
@@ -49155,6 +49279,488 @@ function channelLines(ctx, textHidden, tools) {
|
|
|
49155
49279
|
if (tools && "add_reaction" in tools) lines.push(`If you want to acknowledge a message without ${textHidden ? "posting" : "speaking"}, use the \`add_reaction\` tool to react with an emoji instead of replying with text.`);
|
|
49156
49280
|
return lines;
|
|
49157
49281
|
}
|
|
49282
|
+
// src/channels/thread-link-processor.ts
|
|
49283
|
+
/**
|
|
49284
|
+
* Request-context marker for a run that opened a new channel thread. `AgentChannels` sets it when
|
|
49285
|
+
* it creates the thread; a host that decides "new" itself can call {@link markNewChannelThread}.
|
|
49286
|
+
*/
|
|
49287
|
+
const NEW_CHANNEL_THREAD_KEY = "__mastra_new_channel_thread";
|
|
49288
|
+
function markNewChannelThread(requestContext) {
|
|
49289
|
+
requestContext.set(NEW_CHANNEL_THREAD_KEY, true);
|
|
49290
|
+
}
|
|
49291
|
+
/** Text-part id of the link delta; never collides with a model block id. */
|
|
49292
|
+
const LINK_PART_ID = "mastra-channel-thread-link";
|
|
49293
|
+
const EMITTED_SUFFIX_KEY = "mastra__channelThreadLinkSuffix";
|
|
49294
|
+
/**
|
|
49295
|
+
* Posts a link to the thread in the host's web UI right after the first reply of a new channel
|
|
49296
|
+
* thread, so the link closes the reply rather than leading it. The channel driver ends a post at
|
|
49297
|
+
* `text-end`, so the link shows as its own short message after the reply.
|
|
49298
|
+
*
|
|
49299
|
+
* "End of the reply" is not `text-end`: a reply with citations is several text blocks, each with
|
|
49300
|
+
* its own `text-end`. The reply ends at the first `tool-call` (an opener before tools run) or at
|
|
49301
|
+
* `step-finish` (a reply with no tools), whichever comes first after some text. A processor
|
|
49302
|
+
* returns one part, so on that chunk this returns a `text-delta` carrying the link and stashes the
|
|
49303
|
+
* chunk under `REPROCESS_PART_KEY`, which the runner re-drives through the chain right after.
|
|
49304
|
+
*
|
|
49305
|
+
* The link is a channel display detail. Saved to memory it would show the model its own link on
|
|
49306
|
+
* later turns (inviting it to fabricate links) and render a self-link in the web transcript, so
|
|
49307
|
+
* `processOutputStep` drops the link's text part before the message is saved.
|
|
49308
|
+
*
|
|
49309
|
+
* No-op unless the run opened a new thread, the reply text is shown, and `link` returns a URL.
|
|
49310
|
+
*/
|
|
49311
|
+
var ChannelThreadLinkProcessor = class {
|
|
49312
|
+
id = "channel-thread-link";
|
|
49313
|
+
#options;
|
|
49314
|
+
/** Pass options, or a function picking them per run (e.g. by the run's platform). */
|
|
49315
|
+
constructor(options) {
|
|
49316
|
+
this.#options = typeof options === "function" ? options : () => options;
|
|
49317
|
+
}
|
|
49318
|
+
async processOutputStream({ part, state, requestContext }) {
|
|
49319
|
+
if (state.linked || !linksThisRun(requestContext)) return part;
|
|
49320
|
+
if (part.type === "text-delta") {
|
|
49321
|
+
if (part.payload.text.trim()) state.textStarted = true;
|
|
49322
|
+
return part;
|
|
49323
|
+
}
|
|
49324
|
+
if (part.type !== "tool-call" && part.type !== "step-finish" || !state.textStarted) return part;
|
|
49325
|
+
state.linked = true;
|
|
49326
|
+
const suffix = this.#suffix(requestContext);
|
|
49327
|
+
if (!suffix) return part;
|
|
49328
|
+
requestContext.set(EMITTED_SUFFIX_KEY, suffix);
|
|
49329
|
+
state[REPROCESS_PART_KEY] = part;
|
|
49330
|
+
return {
|
|
49331
|
+
type: "text-delta",
|
|
49332
|
+
runId: part.runId,
|
|
49333
|
+
from: part.from,
|
|
49334
|
+
payload: {
|
|
49335
|
+
id: LINK_PART_ID,
|
|
49336
|
+
text: suffix
|
|
49337
|
+
}
|
|
49338
|
+
};
|
|
49339
|
+
}
|
|
49340
|
+
processOutputStep({ messageList, requestContext }) {
|
|
49341
|
+
const suffix = requestContext?.get(EMITTED_SUFFIX_KEY);
|
|
49342
|
+
if (!suffix) return messageList;
|
|
49343
|
+
for (const message of messageList.get.response.db()) {
|
|
49344
|
+
if (message.role !== "assistant") continue;
|
|
49345
|
+
const index = message.content.parts.findIndex((part) => part.type === "text" && part.text === suffix);
|
|
49346
|
+
if (index === -1) continue;
|
|
49347
|
+
message.content.parts.splice(index, 1);
|
|
49348
|
+
if (typeof message.content.content === "string" && message.content.content.endsWith(suffix)) message.content.content = message.content.content.slice(0, -suffix.length);
|
|
49349
|
+
return messageList;
|
|
49350
|
+
}
|
|
49351
|
+
return messageList;
|
|
49352
|
+
}
|
|
49353
|
+
#suffix(requestContext) {
|
|
49354
|
+
const options = this.#options(requestContext);
|
|
49355
|
+
if (!options) return void 0;
|
|
49356
|
+
const memory = parseMemoryRequestContext(requestContext);
|
|
49357
|
+
const link = options.link({
|
|
49358
|
+
requestContext,
|
|
49359
|
+
threadId: memory?.thread?.id,
|
|
49360
|
+
resourceId: memory?.resourceId
|
|
49361
|
+
});
|
|
49362
|
+
return link && `\n\n[${options.label ?? "Open thread \u2197"}](${link})`;
|
|
49363
|
+
}
|
|
49364
|
+
};
|
|
49365
|
+
function linksThisRun(requestContext) {
|
|
49366
|
+
if (!requestContext?.get("__mastra_new_channel_thread")) return false;
|
|
49367
|
+
return requestContext.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY)?.textDisplay !== "hidden";
|
|
49368
|
+
}
|
|
49369
|
+
// src/channels/reply-tool.ts
|
|
49370
|
+
const REPLY_TOOL_NAME = "reply_in_thread";
|
|
49371
|
+
/**
|
|
49372
|
+
* Which reply carries the session link: `claimed` while that reply is posting,
|
|
49373
|
+
* `posted` once it landed. Claimed before any await, so overlapping replies
|
|
49374
|
+
* can't both take it; a failed post hands it back to the next reply.
|
|
49375
|
+
*/
|
|
49376
|
+
const LINKED_KEY = "mastra__channelReplyLinked";
|
|
49377
|
+
const replyInput = z$1.object({ text: z$1.string().trim().min(1).max(12e3).describe("The message to post, in markdown.") }).strict();
|
|
49378
|
+
/** @internal */
|
|
49379
|
+
function createChannelReplyTool(requestContext, options) {
|
|
49380
|
+
const { resolveRender } = options;
|
|
49381
|
+
return { [REPLY_TOOL_NAME]: createTool({
|
|
49382
|
+
id: REPLY_TOOL_NAME,
|
|
49383
|
+
description: "Post a message in this chat thread. Nothing you write outside this tool reaches the thread, so use it for anything the people there should see: a short note that you are starting a longer job, a question you need answered, and the outcome when you finish. Post when you have something new; do not repeat yourself or post that nothing changed. To stay quiet, do not call it.",
|
|
49384
|
+
inputSchema: replyInput,
|
|
49385
|
+
execute: async (input, context) => {
|
|
49386
|
+
const link = claimFirstReplyLink(requestContext, options.link);
|
|
49387
|
+
const suffix = link ? `\n\n[${options.link?.label ?? "Open thread \u2197"}](${link})` : "";
|
|
49388
|
+
const toolCallId = context?.agent?.toolCallId;
|
|
49389
|
+
const streamed = toolCallId ? replyStreams(requestContext).get(toolCallId) : void 0;
|
|
49390
|
+
if (toolCallId) replyStreams(requestContext).delete(toolCallId);
|
|
49391
|
+
try {
|
|
49392
|
+
if (!streamed || !await streamed.finish(input.text, suffix)) {
|
|
49393
|
+
const render = await resolveRender(requestContext);
|
|
49394
|
+
if (!render) throw new Error("This session is no longer linked to a chat thread.");
|
|
49395
|
+
await render.chatThread.post({ markdown: `${input.text}${suffix}` });
|
|
49396
|
+
}
|
|
49397
|
+
} catch (error) {
|
|
49398
|
+
if (link) requestContext.set(LINKED_KEY, void 0);
|
|
49399
|
+
throw error;
|
|
49400
|
+
}
|
|
49401
|
+
if (link) requestContext.set(LINKED_KEY, "posted");
|
|
49402
|
+
return { posted: true };
|
|
49403
|
+
}
|
|
49404
|
+
}) };
|
|
49405
|
+
}
|
|
49406
|
+
/**
|
|
49407
|
+
* The session link the first reply of a new session ends with, claimed for
|
|
49408
|
+
* this reply. With reply text hidden, the session-link processor's text delta
|
|
49409
|
+
* never reaches the thread, so the tool carries the link instead.
|
|
49410
|
+
*/
|
|
49411
|
+
function claimFirstReplyLink(requestContext, link) {
|
|
49412
|
+
if (!link || !requestContext.get("__mastra_new_channel_thread") || requestContext.get(LINKED_KEY)) return;
|
|
49413
|
+
const memory = parseMemoryRequestContext(requestContext);
|
|
49414
|
+
const url = link.link({
|
|
49415
|
+
requestContext,
|
|
49416
|
+
threadId: memory?.thread?.id,
|
|
49417
|
+
resourceId: memory?.resourceId
|
|
49418
|
+
});
|
|
49419
|
+
if (url) requestContext.set(LINKED_KEY, "claimed");
|
|
49420
|
+
return url;
|
|
49421
|
+
}
|
|
49422
|
+
/** Live posts of `reply_in_thread` calls whose text is still streaming in, by tool call id. */
|
|
49423
|
+
const STREAMS_KEY = "mastra__channelReplyStreams";
|
|
49424
|
+
function replyStreams(requestContext) {
|
|
49425
|
+
let streams = requestContext.get(STREAMS_KEY);
|
|
49426
|
+
if (!streams) {
|
|
49427
|
+
streams = /* @__PURE__ */ new Map();
|
|
49428
|
+
requestContext.set(STREAMS_KEY, streams);
|
|
49429
|
+
}
|
|
49430
|
+
return streams;
|
|
49431
|
+
}
|
|
49432
|
+
/**
|
|
49433
|
+
* One streamed post, opened on the first visible text so an abandoned
|
|
49434
|
+
* call never leaves an empty message behind.
|
|
49435
|
+
*/
|
|
49436
|
+
function openReplyStream({ chatThread, logger }) {
|
|
49437
|
+
const queue = [];
|
|
49438
|
+
let sent = "";
|
|
49439
|
+
let closed = false;
|
|
49440
|
+
let wake;
|
|
49441
|
+
let done;
|
|
49442
|
+
async function* chunks() {
|
|
49443
|
+
while (true) {
|
|
49444
|
+
while (queue.length > 0) yield queue.shift();
|
|
49445
|
+
if (closed) return;
|
|
49446
|
+
await new Promise((resolve) => wake = resolve);
|
|
49447
|
+
}
|
|
49448
|
+
}
|
|
49449
|
+
const push = (text) => {
|
|
49450
|
+
if (!text) return;
|
|
49451
|
+
queue.push(text);
|
|
49452
|
+
done ??= chatThread.post(chunks()).then(() => true, (error) => {
|
|
49453
|
+
logger?.warn("[channels] streamed reply failed; posting it whole", { error });
|
|
49454
|
+
return false;
|
|
49455
|
+
});
|
|
49456
|
+
wake?.();
|
|
49457
|
+
};
|
|
49458
|
+
return {
|
|
49459
|
+
update(text) {
|
|
49460
|
+
const visible = text.trimStart();
|
|
49461
|
+
if (!visible.startsWith(sent)) return;
|
|
49462
|
+
push(visible.slice(sent.length));
|
|
49463
|
+
sent = visible;
|
|
49464
|
+
},
|
|
49465
|
+
async finish(text, suffix) {
|
|
49466
|
+
if (text.startsWith(sent)) push(text.slice(sent.length));
|
|
49467
|
+
if (!done) return false;
|
|
49468
|
+
push(suffix);
|
|
49469
|
+
closed = true;
|
|
49470
|
+
wake?.();
|
|
49471
|
+
return done;
|
|
49472
|
+
},
|
|
49473
|
+
async close() {
|
|
49474
|
+
closed = true;
|
|
49475
|
+
wake?.();
|
|
49476
|
+
return done ?? false;
|
|
49477
|
+
}
|
|
49478
|
+
};
|
|
49479
|
+
}
|
|
49480
|
+
/**
|
|
49481
|
+
* Streams a `reply_in_thread` call's `text` into the thread while the model is
|
|
49482
|
+
* still writing it, so a long reply appears as it is written instead of all at
|
|
49483
|
+
* once when the call completes. The tool finishes the post with the validated
|
|
49484
|
+
* text. Runs whose adapter doesn't stream, or that show reply text, are left
|
|
49485
|
+
* alone.
|
|
49486
|
+
*/
|
|
49487
|
+
var ChannelReplyStreamProcessor = class {
|
|
49488
|
+
id = "channel-reply-stream";
|
|
49489
|
+
#resolveRender;
|
|
49490
|
+
constructor(resolveRender) {
|
|
49491
|
+
this.#resolveRender = resolveRender;
|
|
49492
|
+
}
|
|
49493
|
+
async processOutputStream({ part, state, requestContext }) {
|
|
49494
|
+
if (!requestContext) return part;
|
|
49495
|
+
const args = state.args ??= {};
|
|
49496
|
+
if (part.type === "tool-call-input-streaming-start" && part.payload.toolName === "reply_in_thread") {
|
|
49497
|
+
const render = await this.#resolveRender(requestContext);
|
|
49498
|
+
if (render?.textDisplay !== "hidden" || !render.streaming?.enabled) return part;
|
|
49499
|
+
args[part.payload.toolCallId] = "";
|
|
49500
|
+
replyStreams(requestContext).set(part.payload.toolCallId, openReplyStream(render));
|
|
49501
|
+
} else if (part.type === "tool-call-delta" && part.payload.toolCallId in args) {
|
|
49502
|
+
const text = partialStringField(args[part.payload.toolCallId] += part.payload.argsTextDelta, "text");
|
|
49503
|
+
if (text !== void 0) replyStreams(requestContext).get(part.payload.toolCallId)?.update(text);
|
|
49504
|
+
} else if ((part.type === "tool-error" || part.type === "tool-result") && part.payload.toolCallId in args) {
|
|
49505
|
+
delete args[part.payload.toolCallId];
|
|
49506
|
+
await closeStream(requestContext, part.payload.toolCallId);
|
|
49507
|
+
} else if (RUN_END.has(part.type)) {
|
|
49508
|
+
for (const toolCallId of Object.keys(args)) await closeStream(requestContext, toolCallId);
|
|
49509
|
+
state.args = {};
|
|
49510
|
+
}
|
|
49511
|
+
return part;
|
|
49512
|
+
}
|
|
49513
|
+
};
|
|
49514
|
+
/** Chunks after which no `reply_in_thread` call of this run will still execute. */
|
|
49515
|
+
const RUN_END = /* @__PURE__ */ new Set([
|
|
49516
|
+
"finish",
|
|
49517
|
+
"abort",
|
|
49518
|
+
"error",
|
|
49519
|
+
"tripwire"
|
|
49520
|
+
]);
|
|
49521
|
+
/**
|
|
49522
|
+
* Ends a streamed post whose call will never reach `execute`, keeping the text
|
|
49523
|
+
* shown so far, so the platform isn't left with a message that never finishes.
|
|
49524
|
+
*/
|
|
49525
|
+
async function closeStream(requestContext, toolCallId) {
|
|
49526
|
+
const streams = replyStreams(requestContext);
|
|
49527
|
+
const stream = streams.get(toolCallId);
|
|
49528
|
+
if (!stream) return;
|
|
49529
|
+
streams.delete(toolCallId);
|
|
49530
|
+
await stream.close();
|
|
49531
|
+
}
|
|
49532
|
+
const ESCAPES = {
|
|
49533
|
+
"\"": "\"",
|
|
49534
|
+
"\\": "\\",
|
|
49535
|
+
"/": "/",
|
|
49536
|
+
b: "\b",
|
|
49537
|
+
f: "\f",
|
|
49538
|
+
n: "\n",
|
|
49539
|
+
r: "\r",
|
|
49540
|
+
t: " "
|
|
49541
|
+
};
|
|
49542
|
+
/** The decoded value of a top-level string field in JSON that may still be cut off mid-string. */
|
|
49543
|
+
function partialStringField(json, field) {
|
|
49544
|
+
const start = new RegExp(`"${field}"\\s*:\\s*"`).exec(json);
|
|
49545
|
+
if (!start) return void 0;
|
|
49546
|
+
let out = "";
|
|
49547
|
+
for (let i = start.index + start[0].length; i < json.length; i++) {
|
|
49548
|
+
const ch = json[i];
|
|
49549
|
+
if (ch === "\"") return out;
|
|
49550
|
+
if (ch !== "\\") {
|
|
49551
|
+
out += ch;
|
|
49552
|
+
continue;
|
|
49553
|
+
}
|
|
49554
|
+
const next = json[i + 1];
|
|
49555
|
+
if (next === void 0) return out;
|
|
49556
|
+
if (next === "u") {
|
|
49557
|
+
const hex = json.slice(i + 2, i + 6);
|
|
49558
|
+
if (hex.length < 4) return out;
|
|
49559
|
+
out += String.fromCharCode(parseInt(hex, 16));
|
|
49560
|
+
i += 5;
|
|
49561
|
+
} else {
|
|
49562
|
+
out += ESCAPES[next] ?? next;
|
|
49563
|
+
i += 1;
|
|
49564
|
+
}
|
|
49565
|
+
}
|
|
49566
|
+
return out;
|
|
49567
|
+
}
|
|
49568
|
+
// src/channels/reply-guidance-processor.ts
|
|
49569
|
+
const ID$1 = "channel-reply-guidance";
|
|
49570
|
+
/** Chat surfaces show what the agent writes as-is, so a bare id is a dead end for the reader. */
|
|
49571
|
+
const LINK_REFERENCES = "Write every pull request, issue, commit, ticket or other reference you mention in the thread as a markdown link to its page, with the id as plain link text, e.g. [#28467](https://github.com/<owner>/<repo>/pull/28467). Never leave one as a bare id or wrap it in code formatting. Build links from URLs your tools returned; don't guess a URL, and leave a reference unlinked only when you can't work out its URL.";
|
|
49572
|
+
/** Agents tend to write the way they report to other agents: names, ids and shorthand only they follow. */
|
|
49573
|
+
const WRITE_FOR_PEOPLE = [
|
|
49574
|
+
"Write for the people in the thread, not for another agent. A teammate who knows the product and programming, but has not read this code or this conversation, should follow your message on first read.",
|
|
49575
|
+
"Lead with the answer or the outcome and anything you need from them, in plain sentences. Keep it short: a few sentences answer most questions, and when there is more, offer it rather than writing it all out. Say what code does rather than naming the function, file, field, error class or tool that does it; name one only when they need it to find the code. Use the project\u2019s real terms, not invented analogies.",
|
|
49576
|
+
"Leave out tool names and run ids unless someone asks for them, and always leave out agent shorthand. When you pass on what another agent reported, say what it means for the people here in your own words; never paste its report."
|
|
49577
|
+
].join(" ");
|
|
49578
|
+
/**
|
|
49579
|
+
* Tells the agent how to speak in a chat channel: open a long job with one line that names it,
|
|
49580
|
+
* finish with the outcome, write for people, and link references. With `reply_in_thread` on the
|
|
49581
|
+
* run, that advice becomes advice on when to call it. A run outside the channel that can still
|
|
49582
|
+
* post there (a web prompt on a linked thread) gets a short note on when to. Runs with neither
|
|
49583
|
+
* get nothing.
|
|
49584
|
+
*/
|
|
49585
|
+
var ChannelReplyGuidanceProcessor = class {
|
|
49586
|
+
id = ID$1;
|
|
49587
|
+
#instructions;
|
|
49588
|
+
constructor(options = {}) {
|
|
49589
|
+
this.#instructions = options.instructions;
|
|
49590
|
+
}
|
|
49591
|
+
processInputStep({ messageList, requestContext, tools }) {
|
|
49592
|
+
const canReply = !!tools && "reply_in_thread" in tools;
|
|
49593
|
+
let content;
|
|
49594
|
+
if (!requestContext?.get("channel")) {
|
|
49595
|
+
if (!canReply) return void 0;
|
|
49596
|
+
content = [`Post to that thread with \`${REPLY_TOOL_NAME}\`. This request came from outside it, so don't post an opener or progress there; post the outcome when the people in the thread asked for this work or are waiting on it, or when you're asked to. Don't write a note about what you posted.`];
|
|
49597
|
+
} else if (canReply) content = [
|
|
49598
|
+
`Only messages you send with \`${REPLY_TOOL_NAME}\` reach this thread; your other text stays out of it. Don't write a note about what you posted. After a reply, either keep working or end your turn with an empty message; any text you write after posting is wasted.`,
|
|
49599
|
+
"When a request will take tools or more than a moment, post one short line first that says what you are about to do, then do the work and post the outcome when you finish \u2014 not a replay of the steps.",
|
|
49600
|
+
"Post again in between only when you need an answer or have news the people in the thread would want. When a message that doesn't mention you needs nothing from you, don't call it."
|
|
49601
|
+
];
|
|
49602
|
+
else content = ["When a request will take tools or more than a moment to answer, reply first with one short line that says what you are about to do \u2014 \"On it \u2014 <the task in a few words>.\" \u2014 then do the work; the opener posts as its own message before any progress is shown. Give direct answers and trivial replies without an opener.", "Finish with the outcome, not a replay of the steps."];
|
|
49603
|
+
const extra = typeof this.#instructions === "function" ? this.#instructions({ canReply }) : this.#instructions ?? [];
|
|
49604
|
+
messageList.addSystem({
|
|
49605
|
+
role: "system",
|
|
49606
|
+
content: [
|
|
49607
|
+
...content,
|
|
49608
|
+
...extra,
|
|
49609
|
+
LINK_REFERENCES,
|
|
49610
|
+
WRITE_FOR_PEOPLE
|
|
49611
|
+
].join("\n")
|
|
49612
|
+
}, ID$1);
|
|
49613
|
+
return { messageList };
|
|
49614
|
+
}
|
|
49615
|
+
};
|
|
49616
|
+
// src/channels/reply-reminder-processor.ts
|
|
49617
|
+
const ID = "channel-reply-reminder";
|
|
49618
|
+
/** How long a run may work without posting before it is nudged. */
|
|
49619
|
+
const REPLY_REMINDER_AFTER_MS = 3e5;
|
|
49620
|
+
/**
|
|
49621
|
+
* With reply text hidden, a long job can run silently for an hour while the
|
|
49622
|
+
* person who asked has no idea whether anything is happening. Once a run has
|
|
49623
|
+
* gone `afterMs` without calling `reply_in_thread`, this sends the agent one
|
|
49624
|
+
* signal suggesting a status update, then restarts the clock. Ignoring it is
|
|
49625
|
+
* how the agent stays quiet. A signal joins the end of the transcript, so the
|
|
49626
|
+
* cached prompt prefix is untouched. Only runs that have the reply tool are
|
|
49627
|
+
* touched.
|
|
49628
|
+
*/
|
|
49629
|
+
var ChannelReplyReminderProcessor = class {
|
|
49630
|
+
id = ID;
|
|
49631
|
+
#afterMs;
|
|
49632
|
+
#now;
|
|
49633
|
+
constructor({ afterMs = REPLY_REMINDER_AFTER_MS, now = Date.now } = {}) {
|
|
49634
|
+
this.#afterMs = afterMs;
|
|
49635
|
+
this.#now = now;
|
|
49636
|
+
}
|
|
49637
|
+
async processInputStep({ messageList, tools, state, sendSignal }) {
|
|
49638
|
+
if (!tools || !("reply_in_thread" in tools) || !sendSignal) return void 0;
|
|
49639
|
+
const reminder = state;
|
|
49640
|
+
const now = this.#now();
|
|
49641
|
+
reminder.quietSince ??= now;
|
|
49642
|
+
const seen = new Set(reminder.seenCalls ?? []);
|
|
49643
|
+
const calls = replyCalls(messageList.get.response.db());
|
|
49644
|
+
if (calls.some((id) => !seen.has(id))) reminder.quietSince = now;
|
|
49645
|
+
reminder.seenCalls = calls;
|
|
49646
|
+
const silentFor = now - reminder.quietSince;
|
|
49647
|
+
if (silentFor < this.#afterMs) return void 0;
|
|
49648
|
+
const minutes = Math.floor(silentFor / 6e4);
|
|
49649
|
+
await sendSignal({
|
|
49650
|
+
type: "reactive",
|
|
49651
|
+
contents: `It has been ${minutes} minute${minutes === 1 ? "" : "s"} since you last posted in this thread. If the people there would want to know where things stand, post a short status with \`${REPLY_TOOL_NAME}\`. Otherwise keep working.`
|
|
49652
|
+
});
|
|
49653
|
+
reminder.quietSince = now;
|
|
49654
|
+
}
|
|
49655
|
+
};
|
|
49656
|
+
/** Ids of the `reply_in_thread` calls this run has finished. */
|
|
49657
|
+
function replyCalls(messages) {
|
|
49658
|
+
const ids = [];
|
|
49659
|
+
for (const message of messages) {
|
|
49660
|
+
if (message.role !== "assistant") continue;
|
|
49661
|
+
for (const part of message.content.parts ?? []) {
|
|
49662
|
+
if (part.type !== "tool-invocation") continue;
|
|
49663
|
+
const { toolName, toolCallId, state } = part.toolInvocation;
|
|
49664
|
+
if (toolName === "reply_in_thread" && state === "result") ids.push(toolCallId);
|
|
49665
|
+
}
|
|
49666
|
+
}
|
|
49667
|
+
return ids;
|
|
49668
|
+
}
|
|
49669
|
+
// src/channels/reply-mode.ts
|
|
49670
|
+
/**
|
|
49671
|
+
* Slack renders the status inline next to the app name, and rejects a status
|
|
49672
|
+
* (sent as its loading message) of 51 characters or more. Other platforms get
|
|
49673
|
+
* the same cap; reply mode has only been tested on Slack.
|
|
49674
|
+
*/
|
|
49675
|
+
const MAX_STATUS_LENGTH = 50;
|
|
49676
|
+
/**
|
|
49677
|
+
* Turns a tool's `description` arg ("Listing the repo root") into a status
|
|
49678
|
+
* line that reads after the app name ("<App> is listing the repo root…").
|
|
49679
|
+
* Only the first line counts: issue/PR creators carry whole bodies there.
|
|
49680
|
+
*/
|
|
49681
|
+
function describeToolCall(args) {
|
|
49682
|
+
if (!args || typeof args !== "object") return void 0;
|
|
49683
|
+
const { description } = args;
|
|
49684
|
+
if (typeof description !== "string") return void 0;
|
|
49685
|
+
const line = description.split("\n").map((part) => part.replace(/\s+/g, " ").trim()).find(Boolean);
|
|
49686
|
+
if (!line) return void 0;
|
|
49687
|
+
const status = `is ${/^[A-Z][a-z]/.test(line) ? line.charAt(0).toLowerCase() + line.slice(1) : line}`;
|
|
49688
|
+
return status.length > MAX_STATUS_LENGTH ? `${status.slice(0, 49)}\u2026` : status;
|
|
49689
|
+
}
|
|
49690
|
+
/**
|
|
49691
|
+
* Progress as a status line rather than posts: "is thinking...", the current
|
|
49692
|
+
* tool's `description`, "is typing..." while a reply is written. With reply
|
|
49693
|
+
* text hidden, streamed text never reaches the thread, so it gets no status:
|
|
49694
|
+
* an "is typing..." set after the reply tool's post would sit on the thread
|
|
49695
|
+
* with nothing coming, and race the clear at the end of the run.
|
|
49696
|
+
*
|
|
49697
|
+
* @internal
|
|
49698
|
+
*/
|
|
49699
|
+
function channelReplyTypingStatus(textDisplay = "hidden") {
|
|
49700
|
+
return (chunk) => {
|
|
49701
|
+
switch (chunk.type) {
|
|
49702
|
+
case "reasoning-delta": return "is thinking...";
|
|
49703
|
+
case "text-delta": return textDisplay === "show" ? "is typing..." : void 0;
|
|
49704
|
+
case "tool-call-input-streaming-start": return chunk.payload.toolName === "reply_in_thread" ? "is typing..." : void 0;
|
|
49705
|
+
case "tool-call":
|
|
49706
|
+
if (chunk.payload.toolName === "reply_in_thread") return "is typing...";
|
|
49707
|
+
return describeToolCall(chunk.payload.args) ?? "is working...";
|
|
49708
|
+
default: return;
|
|
49709
|
+
}
|
|
49710
|
+
};
|
|
49711
|
+
}
|
|
49712
|
+
function threadLinkOptions(link) {
|
|
49713
|
+
if (!link) return void 0;
|
|
49714
|
+
return typeof link === "function" ? { link } : link;
|
|
49715
|
+
}
|
|
49716
|
+
/**
|
|
49717
|
+
* Installed by `AgentChannels` when an adapter sets `replyMode`. On runs whose chat
|
|
49718
|
+
* thread is on that adapter (including runs started elsewhere whose thread is linked
|
|
49719
|
+
* to it) it adds the `reply_in_thread` tool, the reply guidance prompt, and the
|
|
49720
|
+
* nudge after a quiet stretch. Other runs are untouched.
|
|
49721
|
+
*
|
|
49722
|
+
* @internal
|
|
49723
|
+
*/
|
|
49724
|
+
var ChannelReplyModeProcessor = class {
|
|
49725
|
+
id = "channel-reply-mode";
|
|
49726
|
+
#deps;
|
|
49727
|
+
constructor(deps) {
|
|
49728
|
+
this.#deps = deps;
|
|
49729
|
+
}
|
|
49730
|
+
async processInputStep(args) {
|
|
49731
|
+
const { requestContext, state } = args;
|
|
49732
|
+
const render = await this.#deps.resolveRender(requestContext, state);
|
|
49733
|
+
const adapter = render && this.#deps.adapter(render.platform);
|
|
49734
|
+
if (!requestContext || !render || !adapter?.replyMode) return void 0;
|
|
49735
|
+
const config = adapter.replyMode === "tool" ? {} : adapter.replyMode;
|
|
49736
|
+
if (render.textDisplay !== "hidden") {
|
|
49737
|
+
new ChannelReplyGuidanceProcessor({ instructions: config.instructions }).processInputStep(args);
|
|
49738
|
+
return { messageList: args.messageList };
|
|
49739
|
+
}
|
|
49740
|
+
const tools = {
|
|
49741
|
+
...args.tools,
|
|
49742
|
+
...createChannelReplyTool(requestContext, {
|
|
49743
|
+
resolveRender: async () => render,
|
|
49744
|
+
link: threadLinkOptions(adapter.threadLink)
|
|
49745
|
+
})
|
|
49746
|
+
};
|
|
49747
|
+
const withTools = {
|
|
49748
|
+
...args,
|
|
49749
|
+
tools
|
|
49750
|
+
};
|
|
49751
|
+
new ChannelReplyGuidanceProcessor({ instructions: config.instructions }).processInputStep(withTools);
|
|
49752
|
+
await new ChannelReplyReminderProcessor({
|
|
49753
|
+
afterMs: config.reminderAfterMs,
|
|
49754
|
+
now: this.#deps.now
|
|
49755
|
+
}).processInputStep(withTools);
|
|
49756
|
+
const activeTools = args.activeTools && !args.activeTools.includes("reply_in_thread") ? [...args.activeTools, REPLY_TOOL_NAME] : void 0;
|
|
49757
|
+
return {
|
|
49758
|
+
tools,
|
|
49759
|
+
messageList: args.messageList,
|
|
49760
|
+
...activeTools ? { activeTools } : {}
|
|
49761
|
+
};
|
|
49762
|
+
}
|
|
49763
|
+
};
|
|
49158
49764
|
// src/channels/state-adapter.ts
|
|
49159
49765
|
/**
|
|
49160
49766
|
* Chat SDK StateAdapter backed by Mastra storage.
|
|
@@ -49574,6 +50180,24 @@ function formatLegacyHistoryBlock(history, chatThread, platform) {
|
|
|
49574
50180
|
for (const msg of history.recent) lines.push(line(msg));
|
|
49575
50181
|
return lines.join("\n");
|
|
49576
50182
|
}
|
|
50183
|
+
// src/channels/thread-lookup.ts
|
|
50184
|
+
/**
|
|
50185
|
+
* The chat thread this run posts into, if any.
|
|
50186
|
+
*
|
|
50187
|
+
* A run started by a platform message has the render context on `requestContext`. A run
|
|
50188
|
+
* started elsewhere (web UI, schedule, signal wake) on a thread linked to a chat thread does
|
|
50189
|
+
* not, so rebuild it from the thread's persisted channel coordinates. The thread id comes from
|
|
50190
|
+
* the agent controller when there is one, else from the run's memory context. A forked
|
|
50191
|
+
* subagent's thread carries no channel metadata, so forks resolve nothing.
|
|
50192
|
+
*/
|
|
50193
|
+
async function resolveChannelRenderContext(requestContext, channels) {
|
|
50194
|
+
if (!requestContext) return void 0;
|
|
50195
|
+
const stashed = requestContext.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
50196
|
+
if (stashed) return stashed;
|
|
50197
|
+
const threadId = requestContext.get("controller")?.threadId ?? parseMemoryRequestContext(requestContext)?.thread?.id;
|
|
50198
|
+
if (!threadId) return void 0;
|
|
50199
|
+
return await channels?.()?.buildRenderContextForThread(threadId) ?? void 0;
|
|
50200
|
+
}
|
|
49577
50201
|
// src/channels/typing-status.ts
|
|
49578
50202
|
/**
|
|
49579
50203
|
* Built-in typing-status resolver. Used when `typingStatus: true` (the default)
|
|
@@ -49819,7 +50443,7 @@ var AgentChannels = class {
|
|
|
49819
50443
|
for (const [name, value] of Object.entries(config.adapters)) if (value && typeof value === "object" && "adapter" in value) {
|
|
49820
50444
|
const cfg = value;
|
|
49821
50445
|
adapters[name] = cfg.adapter;
|
|
49822
|
-
adapterConfigs[name] = cfg;
|
|
50446
|
+
adapterConfigs[name] = cfg.replyMode ? withReplyModeDefaults(cfg) : cfg;
|
|
49823
50447
|
} else {
|
|
49824
50448
|
adapters[name] = value;
|
|
49825
50449
|
adapterConfigs[name] = { adapter: value };
|
|
@@ -49840,6 +50464,7 @@ var AgentChannels = class {
|
|
|
49840
50464
|
this.channelConfig = config;
|
|
49841
50465
|
this.channelToolNames = new Set(Object.keys(this.getTools()));
|
|
49842
50466
|
if (this.generativeUIEnabled) this.channelToolNames.add(RENDER_CARD_TOOL_NAME);
|
|
50467
|
+
if (this.replyModeEnabled) this.channelToolNames.add(REPLY_TOOL_NAME);
|
|
49843
50468
|
}
|
|
49844
50469
|
/**
|
|
49845
50470
|
* Bind the owning agent used for webhook paths and stored-thread ownership.
|
|
@@ -50547,8 +51172,28 @@ var AgentChannels = class {
|
|
|
50547
51172
|
const processors = [];
|
|
50548
51173
|
if (this.channelConfig.threadContext?.addSystemMessage !== false && !has("chat-channel-context")) processors.push(new ChatChannelProcessor(this));
|
|
50549
51174
|
if (this.generativeUIEnabled && !has("chat-channel-generative-ui")) processors.push(new ChatChannelGenerativeUIProcessor(this));
|
|
51175
|
+
if (this.replyModeEnabled && !has(REPLY_MODE_PROCESSOR_ID)) processors.push(new ChannelReplyModeProcessor({
|
|
51176
|
+
resolveRender: (requestContext, state) => this.resolveRunRender(requestContext, state),
|
|
51177
|
+
adapter: (platform) => this.adapterConfigs[platform]
|
|
51178
|
+
}));
|
|
50550
51179
|
return processors;
|
|
50551
51180
|
}
|
|
51181
|
+
get replyModeEnabled() {
|
|
51182
|
+
return Object.values(this.adapterConfigs).some((cfg) => cfg.replyMode);
|
|
51183
|
+
}
|
|
51184
|
+
/**
|
|
51185
|
+
* The chat thread a run posts to: the one it came in on, else the one its
|
|
51186
|
+
* thread (the controller's, or memory's) is linked to. Cached on `state`
|
|
51187
|
+
* when given; `null` remembers a thread that isn't channel-backed.
|
|
51188
|
+
*/
|
|
51189
|
+
async resolveRunRender(requestContext, state) {
|
|
51190
|
+
const inbound = requestContext?.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
51191
|
+
if (inbound) return inbound;
|
|
51192
|
+
if (state && "render" in state) return state.render ?? void 0;
|
|
51193
|
+
const render = await resolveChannelRenderContext(requestContext, () => this);
|
|
51194
|
+
if (state) state.render = render ?? null;
|
|
51195
|
+
return render;
|
|
51196
|
+
}
|
|
50552
51197
|
/** Whether the Slack adapter opted into `generativeUI` (the only platform it supports). */
|
|
50553
51198
|
get generativeUIEnabled() {
|
|
50554
51199
|
return this.adapterConfigs.slack?.generativeUI === true;
|
|
@@ -50569,8 +51214,15 @@ var AgentChannels = class {
|
|
|
50569
51214
|
*/
|
|
50570
51215
|
close() {}
|
|
50571
51216
|
getOutputProcessors(configuredProcessors = []) {
|
|
50572
|
-
|
|
50573
|
-
|
|
51217
|
+
const has = (id) => configuredProcessors.some((p) => !isProcessorWorkflow(p) && p.id === id);
|
|
51218
|
+
const processors = [];
|
|
51219
|
+
if (Object.values(this.adapterConfigs).some((cfg) => cfg.threadLink) && !has(THREAD_LINK_PROCESSOR_ID)) processors.push(new ChannelThreadLinkProcessor((requestContext) => {
|
|
51220
|
+
const render = requestContext.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
51221
|
+
return render && threadLinkOptions(this.adapterConfigs[render.platform]?.threadLink);
|
|
51222
|
+
}));
|
|
51223
|
+
if (!has("chat-channel-render")) processors.push(new ChatChannelOutputProcessor(this));
|
|
51224
|
+
if (this.replyModeEnabled && !has(REPLY_STREAM_PROCESSOR_ID)) processors.push(new ChannelReplyStreamProcessor((requestContext) => this.resolveRunRender(requestContext)));
|
|
51225
|
+
return processors;
|
|
50574
51226
|
}
|
|
50575
51227
|
/**
|
|
50576
51228
|
* Returns generic channel tools (add_reaction, remove_reaction) that resolve
|
|
@@ -50845,6 +51497,7 @@ var AgentChannels = class {
|
|
|
50845
51497
|
defaultThreadId,
|
|
50846
51498
|
requestContext
|
|
50847
51499
|
}) : void 0,
|
|
51500
|
+
onCreate: () => markNewChannelThread(requestContext),
|
|
50848
51501
|
mastra
|
|
50849
51502
|
});
|
|
50850
51503
|
const threadResourceId = mastraThread.resourceId;
|
|
@@ -51749,7 +52402,7 @@ var AgentChannels = class {
|
|
|
51749
52402
|
/**
|
|
51750
52403
|
* Resolves an existing Mastra thread for the given external IDs, or creates one.
|
|
51751
52404
|
*/
|
|
51752
|
-
async getOrCreateThread({ externalThreadId, channelId, platform, resourceId, threadId, mastra }) {
|
|
52405
|
+
async getOrCreateThread({ externalThreadId, channelId, platform, resourceId, threadId, onCreate, mastra }) {
|
|
51753
52406
|
const { thread: existingThread, memoryStore, metadata } = await this.findThreadMapping({
|
|
51754
52407
|
externalThreadId,
|
|
51755
52408
|
channelId,
|
|
@@ -51757,6 +52410,7 @@ var AgentChannels = class {
|
|
|
51757
52410
|
mastra
|
|
51758
52411
|
});
|
|
51759
52412
|
if (existingThread) return existingThread;
|
|
52413
|
+
onCreate?.();
|
|
51760
52414
|
const resolvedResourceId = typeof resourceId === "function" ? await resourceId() : resourceId;
|
|
51761
52415
|
const defaultThreadId = crypto.randomUUID();
|
|
51762
52416
|
let resolvedThreadId = threadId ? await threadId(resolvedResourceId, defaultThreadId) : defaultThreadId;
|
|
@@ -51958,6 +52612,21 @@ async function storedAttachmentBytes(fs, dir, root = true) {
|
|
|
51958
52612
|
}
|
|
51959
52613
|
return total;
|
|
51960
52614
|
}
|
|
52615
|
+
const REPLY_MODE_PROCESSOR_ID = "channel-reply-mode";
|
|
52616
|
+
const REPLY_STREAM_PROCESSOR_ID = "channel-reply-stream";
|
|
52617
|
+
const THREAD_LINK_PROCESSOR_ID = "channel-thread-link";
|
|
52618
|
+
/** Reply mode keeps reply text and tool calls out of the thread and shows progress in the status, unless set. */
|
|
52619
|
+
function withReplyModeDefaults(cfg) {
|
|
52620
|
+
const legacyCards = "cards" in cfg && cfg.cards !== void 0;
|
|
52621
|
+
const set = Object.fromEntries(Object.entries(cfg).filter(([, value]) => value !== void 0));
|
|
52622
|
+
const textDisplay = cfg.textDisplay ?? "hidden";
|
|
52623
|
+
return {
|
|
52624
|
+
textDisplay,
|
|
52625
|
+
...legacyCards ? {} : { toolDisplay: "hidden" },
|
|
52626
|
+
typingStatus: channelReplyTypingStatus(textDisplay),
|
|
52627
|
+
...set
|
|
52628
|
+
};
|
|
52629
|
+
}
|
|
51961
52630
|
// src/knowledge/instructions.ts
|
|
51962
52631
|
function readInstructions(canEdit) {
|
|
51963
52632
|
return `Use the Knowledge tools for durable, shared knowledge. Pinned knowledge pages may already be in your context if <pinned-knowledge> tags are present in the visible conversation history: answer from their bodies without searching for or reading them again${canEdit ? ", and edit one straight from its body and the version shown, unless its body was cut off: then read it first, since a write replaces the whole body" : ""}. Read a pinned page with knowledge_read only when the answer depends on what its notes say, or on its child pages; a note count alone is no reason to read it. For anything else, search with knowledge_search before answering from Knowledge, and read a page with knowledge_read before relying on it. To see how a scope or section is organized, list it with knowledge_list and read pages by the refs it gives. Read a page whole first; when its body is too long, it comes back as its headings with line numbers and the first lines under each: read the section you need, or match the terms you are looking for. A result's more says what it left out: follow it only when what you need is not already in what you have read, and answer as soon as you have it. Cite the page or note you used. When nothing is found, say so plainly instead of guessing. When notes disagree, show both with their dates.`;
|
|
@@ -71353,57 +72022,6 @@ function armRunDeadline(controller, deadline) {
|
|
|
71353
72022
|
timer.unref?.();
|
|
71354
72023
|
return timer;
|
|
71355
72024
|
}
|
|
71356
|
-
// src/agent/durable/constants.ts
|
|
71357
|
-
const DURABLE_STOP_WHEN_ERROR_ID = "DURABLE_AGENT_STOP_WHEN_FAILED";
|
|
71358
|
-
const REJECT_STREAM_ERROR = Symbol("mastra.durable.rejectStreamError");
|
|
71359
|
-
function markErrorForStreamRejection(error) {
|
|
71360
|
-
error[REJECT_STREAM_ERROR] = true;
|
|
71361
|
-
return error;
|
|
71362
|
-
}
|
|
71363
|
-
function shouldRejectStream(error) {
|
|
71364
|
-
return error[REJECT_STREAM_ERROR] === true;
|
|
71365
|
-
}
|
|
71366
|
-
/**
|
|
71367
|
-
* Default values for durable agent execution
|
|
71368
|
-
*/
|
|
71369
|
-
const DurableAgentDefaults = {
|
|
71370
|
-
/** Default maximum number of agentic loop iterations */
|
|
71371
|
-
MAX_STEPS: 5,
|
|
71372
|
-
/**
|
|
71373
|
-
* Default tool call concurrency.
|
|
71374
|
-
* Applied by `resolveDurableToolCallConcurrency` when a run doesn't
|
|
71375
|
-
* configure `toolCallConcurrency`. Approval / suspend-capable tool sets
|
|
71376
|
-
* always run sequentially (concurrency: 1) regardless of this value.
|
|
71377
|
-
*/
|
|
71378
|
-
TOOL_CALL_CONCURRENCY: 10
|
|
71379
|
-
};
|
|
71380
|
-
/**
|
|
71381
|
-
* Step IDs used in the durable agentic workflow
|
|
71382
|
-
*/
|
|
71383
|
-
const DurableStepIds = {
|
|
71384
|
-
/** LLM execution step */
|
|
71385
|
-
LLM_EXECUTION: "durable-llm-execution",
|
|
71386
|
-
/** Tool call step */
|
|
71387
|
-
TOOL_CALL: "durable-tool-call",
|
|
71388
|
-
/** LLM mapping step (combines results) */
|
|
71389
|
-
LLM_MAPPING: "durable-llm-mapping",
|
|
71390
|
-
/** Agentic execution workflow (one iteration) */
|
|
71391
|
-
AGENTIC_EXECUTION: "durable-agentic-execution",
|
|
71392
|
-
/** Full agentic loop workflow */
|
|
71393
|
-
AGENTIC_LOOP: "durable-agentic-loop",
|
|
71394
|
-
/** Scorer execution step */
|
|
71395
|
-
SCORER_EXECUTION: "durable-scorer-execution",
|
|
71396
|
-
/** isTaskComplete evaluation step */
|
|
71397
|
-
IS_TASK_COMPLETE: "durable-is-task-complete"
|
|
71398
|
-
};
|
|
71399
|
-
/** The loop's last step, which ends the run's spans when it succeeds. */
|
|
71400
|
-
const MAP_FINAL_OUTPUT_STEP_ID = "map-final-output";
|
|
71401
|
-
const RECOVER_ALREADY_IN_PROGRESS_ERROR_ID = "DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS";
|
|
71402
|
-
const RECOVER_SNAPSHOT_NOT_FOUND_ERROR_ID = "DURABLE_AGENT_RECOVER_SNAPSHOT_NOT_FOUND";
|
|
71403
|
-
const RECOVER_CHECKPOINT_NOT_AVAILABLE_ERROR_ID = "DURABLE_AGENT_RECOVER_CHECKPOINT_NOT_AVAILABLE";
|
|
71404
|
-
const RECOVER_RUN_SUSPENDED_ERROR_ID = "DURABLE_AGENT_RECOVER_RUN_SUSPENDED";
|
|
71405
|
-
const RECOVER_RUN_NOT_ACTIVE_ERROR_ID = "DURABLE_AGENT_RECOVER_RUN_NOT_ACTIVE";
|
|
71406
|
-
const RECOVER_SHUTDOWN_ERROR_ID = "DURABLE_AGENT_RECOVER_SHUTDOWN";
|
|
71407
72025
|
// src/agent/durable/durable-stream-until-idle.ts
|
|
71408
72026
|
/**
|
|
71409
72027
|
* Run `DurableAgent.streamUntilIdle` (or `DurableAgent.stream({ untilIdle })`).
|
|
@@ -73699,7 +74317,7 @@ function runTranscriptRefs(params) {
|
|
|
73699
74317
|
async function runMemory(params, run) {
|
|
73700
74318
|
const entry = run.runId ? getRunRegistryEntry(run.runId, params.mastra) : void 0;
|
|
73701
74319
|
if (entry?.memory || !params.mastra || !run.agentId) return entry?.memory;
|
|
73702
|
-
return params.mastra.getAgentById(run.agentId).getMemory({ requestContext: restoreRequestContext(run.requestContextEntries, params.requestContext, getLiveRunRequestContext(entry)) });
|
|
74320
|
+
return params.mastra.getAgentById(run.agentId).getMemory({ requestContext: restoreRequestContext(run.requestContextEntries, params.requestContext, getLiveRunRequestContext(entry, run.runId, params.requestContext)) });
|
|
73703
74321
|
}
|
|
73704
74322
|
/** The most recent transcript in a snapshot: workflow state, else the last step output carrying one. */
|
|
73705
74323
|
function latestMessageListState(snapshot) {
|
|
@@ -73775,7 +74393,7 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
|
|
|
73775
74393
|
error
|
|
73776
74394
|
});
|
|
73777
74395
|
}
|
|
73778
|
-
const effectiveRequestContext = mergeRequestContextForFinalization(initData.requestContextEntries, requestContext, getLiveRunRequestContext(registryEntry));
|
|
74396
|
+
const effectiveRequestContext = mergeRequestContextForFinalization(initData.requestContextEntries, requestContext, getLiveRunRequestContext(registryEntry, runId, requestContext));
|
|
73779
74397
|
if (!effectiveRequestContext.has("MastraMemory") && durableState?.threadId) effectiveRequestContext.set("MastraMemory", {
|
|
73780
74398
|
thread: { id: durableState.threadId },
|
|
73781
74399
|
resourceId: durableState.resourceId,
|
|
@@ -74072,9 +74690,9 @@ function deadlineMessageListState(entry, fallback) {
|
|
|
74072
74690
|
* durable run. The run never reaches its finish step, so this runs over what the deadline saves
|
|
74073
74691
|
* (see `deadlineMessageListState`), as the default loop's deadline pass does.
|
|
74074
74692
|
*/
|
|
74075
|
-
async function runDurableDeadlineOutputPass({ runId, initData, messageListState, cutOffText, entry, mastra, tracingContext, logger }) {
|
|
74693
|
+
async function runDurableDeadlineOutputPass({ runId, initData, messageListState, cutOffText, entry, executionId, mastra, tracingContext, logger }) {
|
|
74076
74694
|
const durableState = initData.state;
|
|
74077
|
-
const requestContext = mergeRequestContextForFinalization(initData.requestContextEntries, void 0, getLiveRunRequestContext(entry));
|
|
74695
|
+
const requestContext = mergeRequestContextForFinalization(initData.requestContextEntries, void 0, getLiveRunRequestContext(entry, runId, void 0, executionId));
|
|
74078
74696
|
if (!requestContext.has("MastraMemory") && durableState?.threadId) requestContext.set("MastraMemory", {
|
|
74079
74697
|
thread: { id: durableState.threadId },
|
|
74080
74698
|
resourceId: durableState.resourceId,
|
|
@@ -76092,7 +76710,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
76092
76710
|
const typedInput = inputData;
|
|
76093
76711
|
const { agentId, messageId, options: execOptions } = typedInput;
|
|
76094
76712
|
const runId = typedInput.runId;
|
|
76095
|
-
const requestContext = getLiveRunRequestContext(getRunRegistryEntry(runId, mastra)) ?? params.requestContext;
|
|
76713
|
+
const requestContext = getLiveRunRequestContext(getRunRegistryEntry(runId, mastra), runId, params.requestContext) ?? params.requestContext;
|
|
76096
76714
|
const logger = mastra?.getLogger?.();
|
|
76097
76715
|
if (pubsub) await emitIterationStartEvent(pubsub, runId, inputData.stepIndex ?? 0);
|
|
76098
76716
|
const { messageList, tools, model: resolvedModel, modelList: resolvedModelList, inputProcessors: resolvedInputProcessors, llmRequestInputProcessors: resolvedLlmRequestInputProcessors, outputProcessors: resolvedOutputProcessors } = await resolveRuntimeDependencies({
|
|
@@ -78989,6 +79607,15 @@ async function flushMessagesBeforeSuspension({ saveQueueManager, messageList, me
|
|
|
78989
79607
|
return false;
|
|
78990
79608
|
}
|
|
78991
79609
|
}
|
|
79610
|
+
/**
|
|
79611
|
+
* Context for output processors on a tool result. A live context is reused only for the execution that
|
|
79612
|
+
* owns it. A context rebuilt from the run snapshot is returned as before; whether a rebuilt entry can
|
|
79613
|
+
* outlive a resume by another caller is tracked in COR-1660.
|
|
79614
|
+
*/
|
|
79615
|
+
function toolResultRequestContext(registryEntry, runId, stepRequestContext) {
|
|
79616
|
+
if (registryEntry?.requestContextRebuilt) return registryEntry.requestContext;
|
|
79617
|
+
return getLiveRunRequestContext(registryEntry, runId, stepRequestContext) ?? stepRequestContext;
|
|
79618
|
+
}
|
|
78992
79619
|
var DurableOutputProcessorError = class extends Error {
|
|
78993
79620
|
constructor(error) {
|
|
78994
79621
|
super(error instanceof Error ? error.message : String(error), { cause: error });
|
|
@@ -79010,7 +79637,7 @@ var DurableChunkPublishError = class extends Error {
|
|
|
79010
79637
|
* Thin glue over the shared per-chunk pipeline core; mirrors the regular
|
|
79011
79638
|
* agent's `processAndEnqueueChunk` in llm-mapping-step.ts.
|
|
79012
79639
|
*/
|
|
79013
|
-
async function processChunkThroughOutputProcessors(chunk, registryEntry, pubsub, runId, agentName, logger, messageList, observabilityContext, collectDataPart, onEmit) {
|
|
79640
|
+
async function processChunkThroughOutputProcessors(chunk, registryEntry, stepRequestContext, pubsub, runId, agentName, logger, messageList, observabilityContext, collectDataPart, onEmit) {
|
|
79014
79641
|
const runner = registryEntry?.outputProcessors?.length && registryEntry.processorStates ? new ProcessorRunner({
|
|
79015
79642
|
inputProcessors: [],
|
|
79016
79643
|
outputProcessors: registryEntry.outputProcessors,
|
|
@@ -79023,7 +79650,7 @@ async function processChunkThroughOutputProcessors(chunk, registryEntry, pubsub,
|
|
|
79023
79650
|
runner,
|
|
79024
79651
|
processorStates: registryEntry?.processorStates,
|
|
79025
79652
|
observabilityContext,
|
|
79026
|
-
requestContext: registryEntry
|
|
79653
|
+
requestContext: toolResultRequestContext(registryEntry, runId, stepRequestContext),
|
|
79027
79654
|
messageList,
|
|
79028
79655
|
streamWriter: pubsub ? { custom: async (data, writerOptions) => {
|
|
79029
79656
|
if (data.type.startsWith("data-") && !data.transient) collectDataPart?.({
|
|
@@ -79374,7 +80001,7 @@ function createDurableToolCallStep() {
|
|
|
79374
80001
|
}).add(invocation, "memory");
|
|
79375
80002
|
}
|
|
79376
80003
|
if (saveQueueManager && messagesToFlush && memory && state?.threadId && state.resourceId && !state.memoryConfig?.readOnly) {
|
|
79377
|
-
const authorizationRequestContext = restoreRequestContext(initData.requestContextEntries, requestContext, registryEntry
|
|
80004
|
+
const authorizationRequestContext = restoreRequestContext(initData.requestContextEntries, requestContext, getLiveRunRequestContext(registryEntry, runId, requestContext));
|
|
79378
80005
|
const authorizeMemory = (permission) => authorizeDurableMemory(getDurableMemoryAuthorizationChecks(registryEntry), {
|
|
79379
80006
|
mastra,
|
|
79380
80007
|
user: authorizationRequestContext.get("user"),
|
|
@@ -79418,10 +80045,10 @@ function createDurableToolCallStep() {
|
|
|
79418
80045
|
};
|
|
79419
80046
|
const registryRequireToolApproval = registryEntry?.requireToolApproval;
|
|
79420
80047
|
const effectiveRequireToolApproval = registryRequireToolApproval !== void 0 ? registryRequireToolApproval : agentOptions.requireToolApproval;
|
|
79421
|
-
const approvalRequestContext = restoreRequestContext(initData.requestContextEntries, requestContext, registryEntry
|
|
80048
|
+
const approvalRequestContext = restoreRequestContext(initData.requestContextEntries, requestContext, getLiveRunRequestContext(registryEntry, runId, requestContext));
|
|
79422
80049
|
const requiresApproval = await toolRequiresApproval(tool, effectiveRequireToolApproval, args, {
|
|
79423
80050
|
toolName,
|
|
79424
|
-
requestContext: Object.fromEntries([...approvalRequestContext.entries()].filter(([key]) => !INTERNAL_APPROVAL_KEYS.has(key))),
|
|
80051
|
+
requestContext: Object.fromEntries([...approvalRequestContext.entries()].filter(([key]) => key !== "__mastra_durableContextSegment" && !INTERNAL_APPROVAL_KEYS.has(key))),
|
|
79425
80052
|
workspace
|
|
79426
80053
|
});
|
|
79427
80054
|
const addToolMetadata = (opts) => {
|
|
@@ -79601,7 +80228,7 @@ function createDurableToolCallStep() {
|
|
|
79601
80228
|
toolTransform: tool?.transform,
|
|
79602
80229
|
tools: toolsForTransform,
|
|
79603
80230
|
logger
|
|
79604
|
-
}), registryEntry, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart);
|
|
80231
|
+
}), registryEntry, requestContext, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart);
|
|
79605
80232
|
} catch (emitError) {
|
|
79606
80233
|
if (emitError instanceof DurableOutputProcessorError) throw emitError;
|
|
79607
80234
|
logger?.warn?.(`[DurableAgent] Failed to emit tool-result chunk for ${toolName}: ${emitError}`);
|
|
@@ -79703,7 +80330,7 @@ function createDurableToolCallStep() {
|
|
|
79703
80330
|
policy: toolPayloadTransform,
|
|
79704
80331
|
tools: toolsForTransform,
|
|
79705
80332
|
logger
|
|
79706
|
-
}), registryEntry, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart);
|
|
80333
|
+
}), registryEntry, requestContext, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart);
|
|
79707
80334
|
} catch (emitError) {
|
|
79708
80335
|
if (emitError instanceof DurableOutputProcessorError) throw emitError;
|
|
79709
80336
|
logger?.warn?.(`[DurableAgent] Failed to emit tool-output-denied chunk for ${toolName}: ${emitError}`);
|
|
@@ -80143,7 +80770,7 @@ function createDurableToolCallStep() {
|
|
|
80143
80770
|
toolCallId: params.toolCallId,
|
|
80144
80771
|
toolName: params.toolName,
|
|
80145
80772
|
status: params.status === "failed" ? "failed" : "completed",
|
|
80146
|
-
requestContext: restoreRequestContext(initData.requestContextEntries, requestContext, registryEntry
|
|
80773
|
+
requestContext: restoreRequestContext(initData.requestContextEntries, requestContext, getLiveRunRequestContext(registryEntry, runId, requestContext))
|
|
80147
80774
|
});
|
|
80148
80775
|
} catch (error) {
|
|
80149
80776
|
resolveReconciliation({ error });
|
|
@@ -80442,7 +81069,7 @@ function createDurableToolCallStep() {
|
|
|
80442
81069
|
result,
|
|
80443
81070
|
modelOutput: readModelOutput(providerMetadata),
|
|
80444
81071
|
...processorObservabilityContext ?? {},
|
|
80445
|
-
requestContext: registryEntry
|
|
81072
|
+
requestContext: toolResultRequestContext(registryEntry, runId, requestContext),
|
|
80446
81073
|
retryCount: 0,
|
|
80447
81074
|
writer: pubsub ? { custom: async (data, writerOptions) => {
|
|
80448
81075
|
if (data.type.startsWith("data-") && !data.transient) collectProcessorDataPart({
|
|
@@ -80547,7 +81174,7 @@ function createDurableToolCallStep() {
|
|
|
80547
81174
|
logger
|
|
80548
81175
|
});
|
|
80549
81176
|
transformMetadata = resultChunk.metadata;
|
|
80550
|
-
await processChunkThroughOutputProcessors(resultChunk, registryEntry, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart, (chunk) => {
|
|
81177
|
+
await processChunkThroughOutputProcessors(resultChunk, registryEntry, requestContext, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart, (chunk) => {
|
|
80551
81178
|
if (chunk.type === "tool-result" && chunk.payload.toolCallId === toolCallId) resultEmitted = true;
|
|
80552
81179
|
});
|
|
80553
81180
|
} catch (emitError) {
|
|
@@ -80619,7 +81246,7 @@ function createDurableToolCallStep() {
|
|
|
80619
81246
|
logger
|
|
80620
81247
|
});
|
|
80621
81248
|
errorTransformMetadata = errorChunk.metadata;
|
|
80622
|
-
await processChunkThroughOutputProcessors(errorChunk, registryEntry, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart);
|
|
81249
|
+
await processChunkThroughOutputProcessors(errorChunk, registryEntry, requestContext, pubsub, runId, initData.agentId, logger, messageList, processorObservabilityContext, collectProcessorDataPart);
|
|
80623
81250
|
} catch (emitError) {
|
|
80624
81251
|
ownership?.throwIfLost();
|
|
80625
81252
|
if (emitError instanceof DurableOutputProcessorError) throw emitError;
|
|
@@ -81207,7 +81834,7 @@ function createDurableIsTaskCompleteStep(defaultMaxSteps = DurableAgentDefaults.
|
|
|
81207
81834
|
const restored = await restoreCompletionPolicy({
|
|
81208
81835
|
agent,
|
|
81209
81836
|
persisted: initData.options.isTaskComplete,
|
|
81210
|
-
requestContext: restoreRequestContext(initData.requestContextEntries,
|
|
81837
|
+
requestContext: restoreRequestContext(initData.requestContextEntries, params.requestContext, getLiveRunRequestContext(registryEntry, state.runId, params.requestContext)),
|
|
81211
81838
|
runId: state.runId,
|
|
81212
81839
|
logger: mastra?.getLogger?.()
|
|
81213
81840
|
});
|
|
@@ -81243,7 +81870,7 @@ function createDurableIsTaskCompleteStep(defaultMaxSteps = DurableAgentDefaults.
|
|
|
81243
81870
|
agentName: initData.agentName,
|
|
81244
81871
|
threadId: initData.state?.threadId,
|
|
81245
81872
|
resourceId: initData.state?.resourceId,
|
|
81246
|
-
customContext: restoreCustomContext(initData.requestContextEntries, registryEntry
|
|
81873
|
+
customContext: restoreCustomContext(initData.requestContextEntries, getLiveRunRequestContext(registryEntry, state.runId, params.requestContext) ?? params.requestContext),
|
|
81247
81874
|
generateId: () => mastra?.generateId?.(),
|
|
81248
81875
|
emitChunk: (chunk) => {
|
|
81249
81876
|
if (!pubsub) return;
|
|
@@ -81291,7 +81918,7 @@ function createDurableGoalStep() {
|
|
|
81291
81918
|
const registryEntry = getRunRegistryEntry(state.runId, mastra);
|
|
81292
81919
|
let goalConfig = registryEntry?.goal;
|
|
81293
81920
|
if (!goalConfig && initData.agentId) goalConfig = mastra?.getAgentById?.(initData.agentId)?.__getGoalConfig?.();
|
|
81294
|
-
const liveRunContext = getLiveRunRequestContext(registryEntry);
|
|
81921
|
+
const liveRunContext = getLiveRunRequestContext(registryEntry, state.runId, params.requestContext);
|
|
81295
81922
|
const currentRequestContext = liveRunContext ?? params.requestContext;
|
|
81296
81923
|
const requestContext = restoreRequestContext(initData.requestContextEntries, params.requestContext, liveRunContext);
|
|
81297
81924
|
const customContext = restoreCustomContext(initData.requestContextEntries, currentRequestContext);
|
|
@@ -83427,7 +84054,7 @@ async function prepareForDurableExecution(options) {
|
|
|
83427
84054
|
});
|
|
83428
84055
|
let tripwireData;
|
|
83429
84056
|
if (inputProcessors.length > 0) try {
|
|
83430
|
-
const { ProcessorRunner } = await import("./stream-
|
|
84057
|
+
const { ProcessorRunner } = await import("./stream-C8HKG3qC.js").then((n) => n.I);
|
|
83431
84058
|
await new ProcessorRunner({
|
|
83432
84059
|
inputProcessors,
|
|
83433
84060
|
outputProcessors,
|
|
@@ -93530,6 +94157,7 @@ var Agent = class Agent extends MastraBase {
|
|
|
93530
94157
|
initData: runInput,
|
|
93531
94158
|
...deadlineMessageListState(runInputEntry, runInput.messageListState),
|
|
93532
94159
|
entry: runInputEntry,
|
|
94160
|
+
executionId: fence.executionId,
|
|
93533
94161
|
mastra: this.#mastra,
|
|
93534
94162
|
tracingContext: deadlineSpan ? { currentSpan: deadlineSpan } : void 0,
|
|
93535
94163
|
logger: this.logger
|
|
@@ -94063,7 +94691,7 @@ var Agent = class Agent extends MastraBase {
|
|
|
94063
94691
|
const threadId = workflowInput.state?.threadId ?? memoryInfo?.threadId;
|
|
94064
94692
|
const resourceId = workflowInput.state?.resourceId ?? memoryInfo?.resourceId;
|
|
94065
94693
|
if (sharedExecution && pubsub && entry?.requestContext && executionFence && threadId) {
|
|
94066
|
-
await agentThreadStreamRuntime.claimDurableThreadLease(pubsub, runId, threadId, resourceId, executionFence.generation, executionFence.executionId);
|
|
94694
|
+
await agentThreadStreamRuntime.claimDurableThreadLease(pubsub, runId, threadId, resourceId, executionFence.generation, executionFence.executionId, true);
|
|
94067
94695
|
try {
|
|
94068
94696
|
await executionFence.verify();
|
|
94069
94697
|
} catch (error) {
|
|
@@ -94337,7 +94965,13 @@ var Agent = class Agent extends MastraBase {
|
|
|
94337
94965
|
messageListFollowsStream: () => !this.executionEngine.executesStepsLocally
|
|
94338
94966
|
});
|
|
94339
94967
|
streamCleanup = createdStreamCleanup;
|
|
94340
|
-
const
|
|
94968
|
+
const threadRegistration = agentThreadStreamRuntime.registerRun(this, output, options, this.getPubSub(), {
|
|
94969
|
+
continuation: methodType === "stream" && !closeOnSuspend ? "across-suspension" : void 0,
|
|
94970
|
+
generation: executionFence.generation,
|
|
94971
|
+
ownershipLost: () => executionFence.isLost(),
|
|
94972
|
+
stepOwner: () => getRunRegistryEntry(runId, this.#mastra)
|
|
94973
|
+
});
|
|
94974
|
+
const workflowExecution = executionFence.run(() => Promise.all([ready, threadRegistration]).then(async () => {
|
|
94341
94975
|
if (await this.redeliverDeadlineError(registryEntry, executionFence)) return;
|
|
94342
94976
|
await emitChunkEvent(fencePubSub(this.#executionStreamBus.forRun(this.__usesSharedRunLog()).pubsub, executionFence), runId, {
|
|
94343
94977
|
type: "start",
|
|
@@ -94378,12 +95012,7 @@ var Agent = class Agent extends MastraBase {
|
|
|
94378
95012
|
}).catch((error) => this.settleExecution(runId, executionFence, { error: this.executionEngine.workflowExecutionError(error, "Workflow execution failed") })));
|
|
94379
95013
|
const trackedEntry = getRunRegistryEntry(runId, this.#mastra);
|
|
94380
95014
|
if (trackedEntry) trackedEntry.workflowExecution = workflowExecution;
|
|
94381
|
-
await
|
|
94382
|
-
continuation: methodType === "stream" && !closeOnSuspend ? "across-suspension" : void 0,
|
|
94383
|
-
generation: executionFence.generation,
|
|
94384
|
-
ownershipLost: () => executionFence.isLost(),
|
|
94385
|
-
stepOwner: () => getRunRegistryEntry(runId, this.#mastra)
|
|
94386
|
-
});
|
|
95015
|
+
await threadRegistration;
|
|
94387
95016
|
const cleanup = () => {
|
|
94388
95017
|
if (methodType === "generate" || runCleanup.done || output.status !== "running") return performCleanup();
|
|
94389
95018
|
Promise.race([workflowExecution, executionFence.whenSettled]).then(() => this.#executionStreamBus.forRun(this.__usesSharedRunLog()).pubsub.flush()).then(() => waitForEventDelivery()).catch(() => {}).finally(performCleanup);
|
|
@@ -104240,7 +104869,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
104240
104869
|
return state.leaseOwners.get(runId) ?? threadLeaseOwner(runId, state.threadRunsById.get(runId)?.generation);
|
|
104241
104870
|
}
|
|
104242
104871
|
/** @internal Qualify a shared thread lease before dispatching this execution. */
|
|
104243
|
-
async claimDurableThreadLease(pubsub, runId, threadId, resourceId, generation, executionId) {
|
|
104872
|
+
async claimDurableThreadLease(pubsub, runId, threadId, resourceId, generation, executionId, workerFenced = false) {
|
|
104244
104873
|
const key = this.#threadKey(resourceId, threadId);
|
|
104245
104874
|
const owner = threadLeaseOwner(runId, generation, executionId);
|
|
104246
104875
|
let lease = await this.#acquireThreadLease(pubsub, key, runId, owner);
|
|
@@ -104258,7 +104887,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
104258
104887
|
if (!lease.acquired) throw new AgentThreadLeaseConflictError(runId, lease.owner ?? "another owner");
|
|
104259
104888
|
if (this.#getState(pubsub).leaseRenewalTimers.has(runId)) {
|
|
104260
104889
|
this.#stopLeaseRenewal(pubsub, runId);
|
|
104261
|
-
this.#startLeaseRenewal(pubsub, key, runId, owner);
|
|
104890
|
+
this.#startLeaseRenewal(pubsub, key, runId, owner, workerFenced);
|
|
104262
104891
|
}
|
|
104263
104892
|
}
|
|
104264
104893
|
/** @internal Renew only the captured execution's thread lease; never acquire or transfer it. */
|
|
@@ -104274,6 +104903,11 @@ var AgentThreadStreamRuntime = class {
|
|
|
104274
104903
|
const { acquired } = await this.#getLeaseProvider(pubsub).acquireLease(this.#threadKey(resourceId, threadId), threadLeaseOwner(runId, generation, executionId), AGENT_THREAD_LEASE_TTL_MS);
|
|
104275
104904
|
return acquired;
|
|
104276
104905
|
}
|
|
104906
|
+
/** @internal Missing ownership is not evidence that another run took the thread. */
|
|
104907
|
+
async isDurableThreadLeaseHeldByAnotherRun(pubsub, runId, threadId, resourceId) {
|
|
104908
|
+
const owner = await this.#getLeaseProvider(pubsub).getLeaseOwner(this.#threadKey(resourceId, threadId));
|
|
104909
|
+
return owner !== void 0 && threadLeaseRunId(owner) !== runId;
|
|
104910
|
+
}
|
|
104277
104911
|
/** @internal Whether `error` from the thread lease backend means it is refusing every client, not just this one. */
|
|
104278
104912
|
isThreadLeaseBackendUnavailableToAll(pubsub, error) {
|
|
104279
104913
|
return this.#getLeaseProvider(pubsub).isUnavailableToAll?.(error) === true;
|
|
@@ -104487,7 +105121,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
104487
105121
|
* that point, so once it passes a successor may own the thread and the
|
|
104488
105122
|
* run is aborted, even if the backend never answers.
|
|
104489
105123
|
*/
|
|
104490
|
-
#startLeaseRenewal(pubsub, key, runId, owner = this.#threadLeaseOwner(pubsub, runId)) {
|
|
105124
|
+
#startLeaseRenewal(pubsub, key, runId, owner = this.#threadLeaseOwner(pubsub, runId), workerFenced = false, confirmedSentAt = Date.now()) {
|
|
104491
105125
|
const state = this.#getState(pubsub);
|
|
104492
105126
|
if (state.leaseRenewalTimers.has(runId)) {
|
|
104493
105127
|
if (state.leaseOwners.get(runId) === owner) return;
|
|
@@ -104495,10 +105129,12 @@ var AgentThreadStreamRuntime = class {
|
|
|
104495
105129
|
}
|
|
104496
105130
|
const leaseProvider = this.#getLeaseProvider(pubsub);
|
|
104497
105131
|
const timer = setInterval(() => {
|
|
105132
|
+
if (workerFenced && state.pendingLeaseRenewals.has(runId)) return;
|
|
104498
105133
|
const sentAt = Date.now();
|
|
104499
105134
|
state.pendingLeaseRenewals.set(runId, (state.pendingLeaseRenewals.get(runId) ?? 0) + 1);
|
|
104500
105135
|
leaseProvider.renewLease(key, owner, AGENT_THREAD_LEASE_TTL_MS).then((renewed) => {
|
|
104501
105136
|
if (!renewed) {
|
|
105137
|
+
if (workerFenced) return;
|
|
104502
105138
|
if (state.leaseRenewalTimers.get(runId) !== timer) return;
|
|
104503
105139
|
const confirmed = state.leaseDeadlines.get(runId)?.confirmedSentAt;
|
|
104504
105140
|
(confirmed === void 0 || Date.now() >= confirmed + AGENT_THREAD_LEASE_TTL_MS ? this.#retakeLease(pubsub, key, runId, timer) : Promise.resolve(false)).then((kept) => {
|
|
@@ -104507,7 +105143,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
104507
105143
|
this.#abortLeaseLostRun(state, runId);
|
|
104508
105144
|
});
|
|
104509
105145
|
} else {
|
|
104510
|
-
if (state.leaseRenewalTimers.get(runId) === timer) this.#armLeaseDeadline(pubsub, key, runId, sentAt);
|
|
105146
|
+
if (!workerFenced && state.leaseRenewalTimers.get(runId) === timer) this.#armLeaseDeadline(pubsub, key, runId, sentAt);
|
|
104511
105147
|
if (state.sweptLeasedRunIds.has(runId)) state.sweptLeasedRunIds.set(runId, Date.now());
|
|
104512
105148
|
}
|
|
104513
105149
|
}).catch(() => {}).finally(() => {
|
|
@@ -104519,7 +105155,8 @@ var AgentThreadStreamRuntime = class {
|
|
|
104519
105155
|
if (typeof timer === "object" && timer && typeof timer.unref === "function") timer.unref();
|
|
104520
105156
|
state.leaseRenewalTimers.set(runId, timer);
|
|
104521
105157
|
state.leaseOwners.set(runId, owner);
|
|
104522
|
-
|
|
105158
|
+
if (workerFenced) return;
|
|
105159
|
+
this.#armLeaseDeadline(pubsub, key, runId, confirmedSentAt);
|
|
104523
105160
|
if (!this.#resolveLeaseProvider(pubsub).isFallback) {
|
|
104524
105161
|
const fence = this.#leaseFence(pubsub, key, runId, timer, owner);
|
|
104525
105162
|
state.leaseFences.set(runId, fence);
|
|
@@ -107239,7 +107876,14 @@ var AgentThreadStreamRuntime = class {
|
|
|
107239
107876
|
async #publishRunSuspended(pubsub, key, record) {
|
|
107240
107877
|
record.lifecycle = "suspended";
|
|
107241
107878
|
record.suspendedAt = Date.now();
|
|
107242
|
-
|
|
107879
|
+
const state = this.#getState(pubsub);
|
|
107880
|
+
const owner = state.leaseOwners.get(record.runId);
|
|
107881
|
+
if (owner && state.threadRunsById.get(record.runId) === record && !state.leaseDeadlines.has(record.runId)) {
|
|
107882
|
+
const resolvedPubSub = this.#getPubSub(pubsub);
|
|
107883
|
+
this.#stopLeaseRenewal(resolvedPubSub, record.runId);
|
|
107884
|
+
this.#startLeaseRenewal(resolvedPubSub, key, record.runId, owner, false, record.suspendedAt - AGENT_THREAD_LEASE_TTL_MS);
|
|
107885
|
+
}
|
|
107886
|
+
if (state.shutdownStreams.has(record.streamId)) return;
|
|
107243
107887
|
await this.#publishAndWait(pubsub, key, {
|
|
107244
107888
|
type: "run-suspended",
|
|
107245
107889
|
runId: record.runId,
|
|
@@ -109711,8 +110355,26 @@ function getRunRegistryEntry(runId, mastra) {
|
|
|
109711
110355
|
}
|
|
109712
110356
|
return unwrapMastraTracingProxy(entry.mastra) === unwrapMastraTracingProxy(mastra) ? entry : void 0;
|
|
109713
110357
|
}
|
|
109714
|
-
|
|
109715
|
-
|
|
110358
|
+
/**
|
|
110359
|
+
* Request-context key that identifies a run segment on engines whose steps carry no Core execution
|
|
110360
|
+
* claim (Inngest). The engine stores the same value on the registry entry it seeds for the segment.
|
|
110361
|
+
*/
|
|
110362
|
+
const DURABLE_CONTEXT_SEGMENT_KEY = "__mastra_durableContextSegment";
|
|
110363
|
+
/**
|
|
110364
|
+
* The registry's live request context, when it belongs to the execution running this step. Once
|
|
110365
|
+
* another process claims the run (for example an approval from another host), the context cached
|
|
110366
|
+
* here still belongs to the previous caller and must not be reused for the new execution.
|
|
110367
|
+
*/
|
|
110368
|
+
function getLiveRunRequestContext(entry, runId, stepContext, executionId) {
|
|
110369
|
+
const live = entry?.requestContext;
|
|
110370
|
+
if (!live || entry.requestContextRebuilt) return void 0;
|
|
110371
|
+
const expectedExecutionId = executionId ?? (runId ? getExecutionClaim(stepContext, runId)?.executionId : void 0);
|
|
110372
|
+
if (!expectedExecutionId) {
|
|
110373
|
+
const stepSegment = stepContext?.get(DURABLE_CONTEXT_SEGMENT_KEY);
|
|
110374
|
+
if (stepSegment === void 0) return live;
|
|
110375
|
+
return stepSegment === entry.requestContextSegment ? live : void 0;
|
|
110376
|
+
}
|
|
110377
|
+
return runId && getExecutionClaim(live, runId)?.executionId === expectedExecutionId ? live : void 0;
|
|
109716
110378
|
}
|
|
109717
110379
|
/**
|
|
109718
110380
|
* Publish an entry for `runId`, owned by `mastra`, unless the slot holds
|
|
@@ -110024,4 +110686,4 @@ var ExtendedRunRegistry = class extends RunRegistry {
|
|
|
110024
110686
|
this.#memoryInfo.clear();
|
|
110025
110687
|
}
|
|
110026
110688
|
};
|
|
110027
|
-
export { resolveDurableToolCallConcurrency as $, planSpanQuery as $a, getSingleStepEntryId as $c, createValidator as $i, resolveRunFence as $l, MessageHistory as $n, AgentsMDInjector as $o, MAX_NOTIFICATION_DELIVERY_ATTEMPTS as $r, AgentStreamBus as $s, validateModelTimeoutSettings as $t, assembleAgentFromFsEntry as A, TracePageError as Aa, repeatAfterSettled as Ac, MAX_KNOWLEDGE_PAGE_LINKS as Ai, ProcessorMessageSchema as Al, buildKnowledgeInstructions as An, chunkMessageText as Ao, createEmptyWorkflowSnapshot as Ar, PrefillErrorHandler as As, RUN_DEADLINE_KEY as At, createDurableGoalStep as B, threadQueryIdentitySchema as Ba, RESUME_SNAPSHOT_POLL_INTERVAL_MS as Bc, knowledgePositionBetween as Bi, TextPartSchema as Bl, formatToolApproval as Bn, augmentWithInit as Bo, SchedulesStorage as Br, createWorkflow$1 as Bs, getServerSideFallbackInfo as Bt, ScorerRunError as C, parseDuration as Ca, nestedRunStatusOf as Cc, KnowledgePageHasChildrenError as Ci, FilePartSchema as Cl, compileKnowledgeScopes as Cn, ObservabilityStorage as Co, FilesystemStore as Cr, isMalformedFunctionCallError as Cs, segmentEndedBySuspension as Ct, notScorable as D, transformRow as Da, validateScoringPredicate as Dc, MAX_KNOWLEDGE_PAGE_BODY_LINKS as Di, ProcessorInputPhaseSchema as Dl, strongerKnowledgeRole as Dn, DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS as Do, WorkflowsInMemory as Dr, StreamErrorRetryProcessor as Ds, DURABLE_STOP_WHEN_ERROR_ID as Dt, isNotScorable as E, storageMessageMatchesMetadataFilter as Ea, evaluateScoringPredicate as Ec, MAX_KNOWLEDGE_NOTE_TOKENS as Ei, MessagePartSchema as El, knowledgeScopeAddress as En, UniqueViolationError as Eo, MockStore as Er, FILE_UPLOAD_ERROR_CODES as Es, runResumeDurableStreamUntilIdle as Et, prepareForDurableExecution as F, tracePageResponseSchema as Fa, runWithConcurrency as Fc, assertKnowledgePageDescriptionWithinBound as Fi, ProcessorStepOutputSchema as Fl, ChatChannelProcessor as Fn, MastraMemory as Fo, InMemoryToolProviderConnectionsStorage as Fr, EventedRun as Fs, getScopeStreamSlot as Ft, serializeDurableOptions as G, SPAN_QUERY_MAX_CURSOR_BYTES as Ga, cleanStepResult as Gc, HarnessStorage as Gi, isWorkflowStepConflictError as Gl, createChannelTools as Gn, RESPONSE_CACHE_CONTEXT_KEY as Go, createNotificationSignal as Gr, diffResponseMessages as Gs, generateFinalResult as Gt, createDurableLLMMappingStep as H, threadQueryResponseSchema as Ha, abortableSleep as Hc, parseKnowledgePageRef as Hi, isAgentCompatible as Hl, DEFAULT_CHANNEL_TOOLS_SETTINGS as Hn, createBackgroundWorkSignalProcessor as Ho, InMemoryNotificationsStorage as Hr, StepExecutor as Hs, formatCompletionFeedback as Ht, applyReservedMemoryContextKeys as I, THREAD_QUERY_DEFAULT_LIMIT as Ia, createMappingStep as Ic, canonicalKnowledgeName as Ii, ProcessorStepSchema as Il, CHAT_CHANNEL_RENDER_CONTEXT_KEY as In, MemoryProcessor as Io, ToolProviderConnectionsStorage as Ir, EventedWorkflow as Is, untilIdleHandlesBackgroundTask as It, serializeToolsMetadata as J, SPAN_QUERY_ORDER_FIELDS as Ja, createTimeTravelExecutionParams as Jc, DatasetsInMemory as Ji, RunFenceConflictError as Jl, BaseProcessor as Jn, WorkspaceInstructionsProcessor as Jo, notificationSignalMetadata as Jr, emitErrorEvent as Js, runCompletionScorers as Jt, serializeDurableState as K, SPAN_QUERY_MAX_LIMIT as Ka, createDeprecationProxy as Kc, ExperimentsInMemory as Ki, RUN_FENCE_CONFLICT_ERROR_ID as Kl, resolveChannelToolsSettings as Kn, ResponseCache as Ko, createNotificationSummarySignal as Kr, emitAbortEvent as Ks, generateStructuredFinalResult as Kt, persistDurableRunInput as L, THREAD_QUERY_MAX_LIMIT as La, createStepFromAgent$1 as Lc, knowledgeLinkRefKey as Li, ReasoningPartSchema as Ll, renderBuiltInToolEvent as Ln, memoryDefaultOptions as Lo, ScoresInMemory as Lr, cloneStep as Ls, pruneAgentLoopSnapshot as Lt, AGENT_RESUME_CLAIM_STALE_MS as M, tracePageIdSchema as Ma, ExecutionEngine as Mc, MAX_KNOWLEDGE_PAGE_LIST_LIMIT as Mi, ProcessorOutputStepPhaseSchema as Ml, resolveWaitUntil as Mn, messageVectorId as Mo, mergeWorkflowStepResult as Mr, cloneWorkflow as Ms, readRunDeadline as Mt, Agent as N, tracePageNodeSchema as Na, createConcurrencyLimiter as Nc, MAX_KNOWLEDGE_PIN_LIST_DEPTH as Ni, ProcessorOutputStreamPhaseSchema as Nl, defaultTypingStatus as Nn, resolveMaxChunkChars as No, InMemoryWorkflowDefinitionsStorage as Nr, createEventedWorkflow as Ns, __registerMastraCtor as Nt, agentConfig as O, transformScoreRow as Oa, WORKFLOW_RUN_LEASE_TTL_MS as Oc, MAX_KNOWLEDGE_PAGE_DEPTH as Oi, ProcessorInputStepPhaseSchema as Ol, decodeKnowledgeScopeId as On, MESSAGE_EMBEDDING_CHARS_PER_TOKEN as Oo, cloneRunData as Or, isBadRequestError as Os, DurableAgentDefaults as Ot, normalizeResumeGenerateArgs as P, tracePageRequestSchema as Pa, normalizeConcurrency as Pc, assertKnowledgeNoteTextWithinBound as Pi, ProcessorStepInputSchema as Pl, MastraStateAdapter as Pn, upsertMessageVectors as Po, WorkflowDefinitionsStorage as Pr, createWorkflow as Ps, getRunStreamSlot as Pt, createDurableBackgroundTaskCheckStep as Q, parseSpanQueryRequest as Qa, getResumeLabelsByStepId as Qc, assertSupportedPatterns as Qi, matchesRunFence as Ql, WorkingMemory as Qn, ToolSearchProcessor as Qo, readNotificationRoutingRequirement as Qr, emitSuspendedEvent as Qs, loop as Qt, detachFullStreamOnEnd as R, encodeThreadQueryCursor as Ra, createStepFromClassifier as Rc, knowledgePagePath as Ri, SourcePartSchema as Rl, CONTINUE_RUN_ACTION_ID as Rn, filterSystemReminderMessages as Ro, ScoresStorage as Rr, cloneWorkflow$1 as Rs, DEFAULT_TOOL_DECLINE_REASON as Rt, MastraScorer as S, jsonValueEquals as Sa, nestedRunRecoveryAction as Sc, KnowledgePageDepthError as Si, isDurableAgentLike as Sl, KnowledgeDeclarationError as Sn, ObservabilityInMemory as So, createGitHubSourceControlProviderFromEnv as Sr, defaultStabilityErrorProcessors as Ss, liveSegmentSpan as St, filterRun as T, serializeDate as Ta, SCORING_PREDICATE_ROOTS as Tc, MAX_KNOWLEDGE_MOVE_PAGES as Ti, MessageContentSchema as Tl, knowledgeRunScopes as Tn, FactoryStorageDomain as To, InMemoryStore as Tr, FileUploadProcessor as Ts, runDurableStreamUntilIdle as Tt, createDurableToolCallStep as U, threadQueryRowSchema as Ua, applyStateDelta as Uc, KnowledgeInvalidCursorError as Ui, WorkflowStepConflictError as Ul, channelToolScopeResolver as Un, CyberRefusalHandler as Uo, NotificationsStorage as Ur, computeScheduleDefinitionHash as Us, formatStreamCompletionFeedback as Ut, createDurableIsTaskCompleteStep as V, threadQueryRequestSchema as Va, RESUME_SNAPSHOT_WAIT_STATUSES as Vc, knowledgeScopeReadable as Vi, ToolInvocationPartSchema as Vl, ChannelSessionRejectedError as Vn, getStorageSource as Vo, normalizeScheduleTarget as Vr, WorkflowEventProcessor as Vs, formatCheckFeedback as Vt, createWorkflowInput as W, SPAN_QUERY_MAX_COST_METRICS as Wa, assertTimeTravelGraphMatchesSnapshot as Wc, InMemoryHarness as Wi, assertWorkflowStepGuard as Wl, createChannelToolScope as Wn, DEFAULT_RESPONSE_CACHE_TTL_SECONDS as Wo, dispatchDueNotifications as Wr, __resetExecutionFencesForTests as Ws, formatValidationFeedback as Wt, MessagePartSpans as X, createSpanQueryPreview as Xa, defineStateAccessors as Xc, DatasetItemIdentityConflictError as Xi, currentRunGeneration as Xl, SemanticRecall as Xn, SkillsProcessor as Xo, notificationSummarySignalMetadata as Xr, emitStepFinishEvent as Xs, runStreamCompletionScorers as Xt, createDurableLLMExecutionStep as Y, buildSpanQueryResponse as Ya, defineLazyWriter as Yc, DatasetsStorage as Yi, coverNestedRun as Yl, MemoryInputFilter as Yn, SkillSearchProcessor as Yo, notificationSummaryContents as Yr, emitFinishEvent as Ys, runDefaultCompletionCheck as Yt, isSpanChunk as Z, encodeSpanQueryCursor as Za, getRestartStartIndex as Zc, SchemaValidator as Zi, isRunFenceConflictError as Zl, globalEmbeddingCache as Zn, formatSkillsCatalog as Zo, summarizeNotifications as Zr, emitStepStartEvent as Zs, runValidation as Zt, runEvals as _, ensureDate as _a, predicateToCondition as _c, assertKnowledgeSchemaCompatible as _i, assertDrainTimeout as _l, syncKnowledgePageBodyLinks as _n, buildUpdateSpanRecord as _o, knowledgeVisibleScopeKeys as _r, PIIDetector as _s, toolRequiresApproval as _t, endRunSpansWithError as a, ChannelsStorage as aa, AGENT_STREAM_TOPIC as ac, InMemoryKnowledgeStorage as ai, omitPriorSuspensionFields as al, addKnowledgeNote as an, spanQueryResponseSchema as ao, MAX_KNOWLEDGE_SCOPE_TAGS as ar, TokenLimiterProcessor as as, baseIterationStateSchema as at, validateAndSaveScore as b, getSqlType as ba, createNestedRunParentStatusLookup as bc, parseKnowledgeWikilinks as bi, hasDurableExecution as bl, knowledgeReadScopeFor as bn, serializeSpanAttributes as bo, StoreOperations as br, UnicodeNormalizer as bs, carrySegmentSpans as bt, globalRunRegistry as c, BackgroundTasksInMemory as ca, EventedExecutionEngine as cc, KnowledgeImportersStorage as ci, setLongTimeout as cl, removeKnowledgePage as cn, encodeTraceQueryDeltaCursor as co, assertKnowledgeRecordTextWithinBound as cr, advanceMemoryTokenBoundary as cs, modelListEntrySchema as ct, takeRunScorerInstances as d, resolveRetentionTargets as da, Run as dc, KnowledgeConflictError as di, validateStepResumeData as dl, KnowledgeSemanticIndex as dn, planTraceQuery as do, createKnowledgeNodeCursor as dr, normalizeMessageHistoryConfig as ds, loadRunStoredMessages as dt, getSchemaValidator as ea, publishAbortRequest as ec, defaultNotificationDeliveryDecision as ei, getStepIds as el, PINNED_READ_MEMO_KEY as en, resolveSpanQueryCost as eo, MemoryRunState as er, ToolCallFilter as es, buildStepRecord as et, runFencingNotSupportedError as eu, AgentThreadLeaseLostError as f, retentionCutoffMs as fa, Workflow as fc, KnowledgeNotFoundError$1 as fi, validateStepStateData as fl, embed$2 as fn, buildCreateSpanRecord as fo, expandKnowledgeScope as fr, BatchPartsProcessor as fs, rebuildRunToolsFromMastra as ft, describeNonSuccessFinishReason as g, createVectorErrorId as ga, mapVariable as gc, KnowledgeUnsupportedCapabilityError as gi, getEntryWorkflow as gl, reindexKnowledgeLinks as gn, buildScoreRecord as go, knowledgeSemanticIdempotencyKey as gr, LanguageDetector as gs, resolveTool$1 as gt, AGENTIC_LOOP_WORKFLOW_ID as h, createStoreErrorId as ha, isProcessor$1 as hc, KnowledgeTransactionDeadlineError as hi, getEntryId as hl, refreshKnowledgeLinksTo as hn, buildMetricRecord as ho, knowledgeSemanticDocumentId as hr, StructuredOutputProcessor as hs, resolveRuntimeDependencies as ht, deleteRunRegistryEntry as i, InMemoryChannelsStorage as ia, AGENT_CONTROL_TOPIC as ic, MemoryStorage as ii, omitPriorCompletionFields as il, knowledgeRunPrincipals as in, spanQueryRequestSchema as io, MAX_KNOWLEDGE_RECORD_TEXT_LENGTH as ir, SystemPromptScrubber as is, baseDurableAgenticInputSchema as it, MAX_FS_SUBAGENT_DEPTH as j, readTracePage as ja, runFenceConflictOf as jc, MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH as ji, ProcessorOutputResultPhaseSchema as jl, AgentChannels as jn, extractMessageEmbeddingText as jo, mergeStepResult as jr, getGoalActivityDurationMs as js, ensureRemoteAbortListener as jt, agentInstructions as k, validateStorageMetadataFilter as ka, renewWorkflowLease as kc, MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS as ki, ProcessorMessageContentSchema as kl, encodeKnowledgeScopeId as kn, buildMessageEmbeddingRows as ko, WorkflowsStorage as kr, isRetryableOpenAIResponsesStreamError as ks, DurableStepIds as kt, isDurableAgentExecutionDetached as l, BackgroundTasksStorage as la, getNestedWorkflow as lc, KNOWLEDGE_STORAGE_CONTRACT_VERSION as li, validateStepInput as ll, updateKnowledgeNote as ln, getTraceQueryDeltaWatermark as lo, assertKnowledgeScopeWithinCeiling as lr, getMemoryTokenBoundary as ls, executeDurableAgentScorers as lt, AGENTIC_EXECUTION_WORKFLOW_ID as m, createStorageErrorId as ma, createStep$1 as mc, KnowledgeStorage as mi, waitForSuspendedSnapshot as ml, knowledgeSubtree as mn, buildLogRecord as mo, knowledgeScopeKey as mr, ClassifierProcessor as ms, resolveModel as mt, RunRegistry as n, SchemaUpdateValidationError as na, subscribeToAbortRequests as nc, resolveNotificationDeliveryDecision as ni, isEntryFinished as nl, buildKnowledgePageTools as nn, spanQueryIdentityKey as no, MockMemory as nr, CostGuardProcessor as ns, createBaseIterationStateUpdate as nt, setRunFenceContext as nu, getActiveDurableAgentWorkflowExecutions as o, InMemoryBlobStore as oa, AgentControlEventTypes as oc, KnowledgeImporterBindingConflictError as oi, resolveForeachConcurrency as ol, moveKnowledgePage as on, spanQueryRowSchema as oo, assertKnowledgeCeilingRaised as or, groupLinkedToolMessages as os, durableAgenticOutputSchema as ot, agentThreadStreamRuntime as p, runRetentionBatches as pa, cloneStep$1 as pc, KnowledgeSchemaResetRequiredError as pi, validateStepSuspendData as pl, KnowledgeLinkRefreshIncompleteError as pn, buildFeedbackRecord as po, isKnowledgeScopeVisible as pr, ModelSelectionProcessor as ps, resolveInternalState as pt, serializeModelConfig as q, SPAN_QUERY_MAX_PREVIEW_CHARACTERS as qa, createRestartExecutionParams as qc, ExperimentsStorage as qi, RUN_FENCING_NOT_SUPPORTED_ERROR_ID as ql, toChatLogger as qn, buildResponseCacheKey as qo, notificationSignalAttributes as qr, emitChunkEvent as qs, runChecks as qt, abandonDurableAgentExecutions as r, SchemaValidationError as ra, createRunAbortController as rc, InMemoryMemory as ri, isSingleStepEntry as rl, KnowledgeRun as rn, spanQueryIdentitySchema as ro, MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH as rr, TokenCostControl as rs, accumulatedUsageSchema as rt, getRunRegistryEntry as s, BlobStore as sa, AgentStreamEventTypes as sc, KnowledgeImporterRunStateError as si, runCountDeprecationMessage as sl, removeKnowledgeNote as sn, encodeTraceQueryCursor as so, assertKnowledgeDescriptionWithinBound as sr, loadMessageHistory as ss, modelConfigSchema as st, ExtendedRunRegistry as t, UnsupportedSchemaPatternError as ta, requestAcknowledgedAbort as tc, resolveDeliveryFailureUpdate as ti, hydrateSerializedStepErrors as tl, knowledgeDeliveredPins as tn, spanQueryCostSchema as to, getMemoryRunState as tr, RegexFilterProcessor as ts, calculateAccumulatedUsage as tt, runOutsideRunFenceScope as tu, setRunRegistryEntry as u, executeRetentionPrune as ua, getStepEntry as uc, KNOWLEDGE_STORAGE_SCHEMA_VERSION as ui, validateStepRequestContext as ul, upsertKnowledgePage as un, planThreadQuery as uo, canonicalizeKnowledgeScope as ur, isAfterMemoryTokenBoundary as us, runDurableFinishSideEffects as ut, flushBeforeTraceRead as v, filterByDateRange as va, evaluatePredicate as vc, createKnowledgeUlid as vi, waitMs as vl, updateKnowledgeLinks as vn, getObjectOrNull as vo, parseKnowledgeNodeCursor as vr, PromptInjectionDetector as vs, resolveAgentById as vt, createScorer as w, safelyParseJSON as wa, DefaultExecutionEngine as wc, KnowledgePageKeyConflictError as wi, ImagePartSchema as wl, knowledgeMemoryScopes as wn, FactoryStorage as wo, FilesystemDB as wr, UnsupportedFileHandler as ws, segmentSpanData as wt, createClassifierScorer as x, hasErrorCode as xa, nestedRunParentOf as xc, KnowledgeMoveTooLargeError as xi, hasResumableStreams as xl, knowledgeRoleOn as xn, toEntityType as xo, GitHubSourceControlProvider as xr, STABILITY_ERROR_PROCESSOR_IDS as xs, endFailedSegmentSpans as xt, createOnScorerHook as y, getDefaultValue as ya, cancelNestedRun as yc, inspectKnowledgeSchema as yi, workflowTermination as yl, knowledgeAccessGrants as yn, getStringOrNull as yo, StoreOperationsInMemory as yr, ModerationProcessor as ys, createDurableAgentStream as yt, createDurableAgenticWorkflow as z, planThreadRowsQuery as za, createStepFromTool as zc, knowledgePinDepth as zi, StepStartPartSchema as zl, CONTINUE_RUN_MESSAGE as zn, isSystemReminderMessage as zo, InMemorySchedulesStorage as zr, createStep as zs, resolveDeclineReason as zt };
|
|
110689
|
+
export { createDurableBackgroundTaskCheckStep as $, createSpanQueryPreview as $a, createRestartExecutionParams as $c, DatasetItemIdentityConflictError as $i, RUN_FENCING_NOT_SUPPORTED_ERROR_ID as $l, SemanticRecall as $n, SkillsProcessor as $o, notificationSummarySignalMetadata as $r, emitStepFinishEvent as $s, knowledgeDeliveredPins as $t, agentInstructions as A, transformRow as Aa, DefaultExecutionEngine as Ac, MAX_KNOWLEDGE_PAGE_BODY_LINKS as Ai, ImagePartSchema as Al, resolveWaitUntil as An, DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS as Ao, WorkflowsInMemory as Ar, StreamErrorRetryProcessor as As, readRunDeadline as At, createDurableAgenticWorkflow as B, THREAD_QUERY_MAX_LIMIT as Ba, normalizeConcurrency as Bc, knowledgeLinkRefKey as Bi, ProcessorStepInputSchema as Bl, renderBuiltInToolEvent as Bn, memoryDefaultOptions as Bo, ScoresInMemory as Br, cloneStep as Bs, formatCompletionFeedback as Bt, MastraScorer as C, getSqlType as Ca, predicateToCondition as Cc, parseKnowledgeWikilinks as Ci, assertDrainTimeout as Cl, knowledgeRunScopes as Cn, serializeSpanAttributes as Co, StoreOperations as Cr, UnicodeNormalizer as Cs, liveSegmentSpan as Ct, isNotScorable as D, safelyParseJSON as Da, nestedRunParentOf as Dc, KnowledgePageKeyConflictError as Di, hasResumableStreams as Dl, encodeKnowledgeScopeId as Dn, FactoryStorage as Do, FilesystemDB as Dr, UnsupportedFileHandler as Ds, runResumeDurableStreamUntilIdle as Dt, filterRun as E, parseDuration as Ea, createNestedRunParentStatusLookup as Ec, KnowledgePageHasChildrenError as Ei, hasDurableExecution as El, decodeKnowledgeScopeId as En, ObservabilityStorage as Eo, FilesystemStore as Er, isMalformedFunctionCallError as Es, runDurableStreamUntilIdle as Et, normalizeResumeGenerateArgs as F, tracePageIdSchema as Fa, renewWorkflowLease as Fc, MAX_KNOWLEDGE_PAGE_LIST_LIMIT as Fi, ProcessorMessageContentSchema as Fl, ChannelThreadLinkProcessor as Fn, messageVectorId as Fo, mergeWorkflowStepResult as Fr, cloneWorkflow as Fs, pruneAgentLoopSnapshot as Ft, createWorkflowInput as G, threadQueryResponseSchema as Ga, createStepFromTool as Gc, parseKnowledgePageRef as Gi, StepStartPartSchema as Gl, DEFAULT_CHANNEL_TOOLS_SETTINGS as Gn, createBackgroundWorkSignalProcessor as Go, InMemoryNotificationsStorage as Gr, StepExecutor as Gs, runChecks as Gt, createDurableIsTaskCompleteStep as H, planThreadRowsQuery as Ha, createMappingStep as Hc, knowledgePinDepth as Hi, ProcessorStepSchema as Hl, CONTINUE_RUN_MESSAGE as Hn, isSystemReminderMessage as Ho, InMemorySchedulesStorage as Hr, createStep as Hs, formatValidationFeedback as Ht, prepareForDurableExecution as I, tracePageNodeSchema as Ia, repeatAfterSettled as Ic, MAX_KNOWLEDGE_PIN_LIST_DEPTH as Ii, ProcessorMessageSchema as Il, NEW_CHANNEL_THREAD_KEY as In, resolveMaxChunkChars as Io, InMemoryWorkflowDefinitionsStorage as Ir, createEventedWorkflow as Is, DEFAULT_TOOL_DECLINE_REASON as It, serializeModelConfig as J, SPAN_QUERY_MAX_CURSOR_BYTES as Ja, abortableSleep as Jc, HarnessStorage as Ji, isAgentCompatible as Jl, createChannelTools as Jn, RESPONSE_CACHE_CONTEXT_KEY as Jo, createNotificationSignal as Jr, diffResponseMessages as Js, runStreamCompletionScorers as Jt, serializeDurableOptions as K, threadQueryRowSchema as Ka, RESUME_SNAPSHOT_POLL_INTERVAL_MS as Kc, KnowledgeInvalidCursorError as Ki, TextPartSchema as Kl, channelToolScopeResolver as Kn, CyberRefusalHandler as Ko, NotificationsStorage as Kr, computeScheduleDefinitionHash as Ks, runCompletionScorers as Kt, applyReservedMemoryContextKeys as L, tracePageRequestSchema as La, runFenceConflictOf as Lc, assertKnowledgeNoteTextWithinBound as Li, ProcessorOutputResultPhaseSchema as Ll, markNewChannelThread as Ln, upsertMessageVectors as Lo, WorkflowDefinitionsStorage as Lr, createWorkflow as Ls, resolveDeclineReason as Lt, MAX_FS_SUBAGENT_DEPTH as M, validateStorageMetadataFilter as Ma, evaluateScoringPredicate as Mc, MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS as Mi, MessagePartSchema as Ml, resolveChannelRenderContext as Mn, buildMessageEmbeddingRows as Mo, WorkflowsStorage as Mr, isRetryableOpenAIResponsesStreamError as Ms, getRunStreamSlot as Mt, AGENT_RESUME_CLAIM_STALE_MS as N, TracePageError as Na, validateScoringPredicate as Nc, MAX_KNOWLEDGE_PAGE_LINKS as Ni, ProcessorInputPhaseSchema as Nl, MastraStateAdapter as Nn, chunkMessageText as No, createEmptyWorkflowSnapshot as Nr, PrefillErrorHandler as Ns, getScopeStreamSlot as Nt, notScorable as O, serializeDate as Oa, nestedRunRecoveryAction as Oc, MAX_KNOWLEDGE_MOVE_PAGES as Oi, isDurableAgentLike as Ol, buildKnowledgeInstructions as On, FactoryStorageDomain as Oo, InMemoryStore as Or, FileUploadProcessor as Os, RUN_DEADLINE_KEY as Ot, Agent as P, readTracePage as Pa, WORKFLOW_RUN_LEASE_TTL_MS as Pc, MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH as Pi, ProcessorInputStepPhaseSchema as Pl, REPLY_TOOL_NAME as Pn, extractMessageEmbeddingText as Po, mergeStepResult as Pr, getGoalActivityDurationMs as Ps, untilIdleHandlesBackgroundTask as Pt, isSpanChunk as Q, buildSpanQueryResponse as Qa, createDeprecationProxy as Qc, DatasetsStorage as Qi, RUN_FENCE_CONFLICT_ERROR_ID as Ql, MemoryInputFilter as Qn, SkillSearchProcessor as Qo, notificationSummaryContents as Qr, emitFinishEvent as Qs, PINNED_READ_MEMO_KEY as Qt, persistDurableRunInput as R, tracePageResponseSchema as Ra, ExecutionEngine as Rc, assertKnowledgePageDescriptionWithinBound as Ri, ProcessorOutputStepPhaseSchema as Rl, ChatChannelProcessor as Rn, MastraMemory as Ro, InMemoryToolProviderConnectionsStorage as Rr, EventedRun as Rs, getServerSideFallbackInfo as Rt, createClassifierScorer as S, getDefaultValue as Sa, mapVariable as Sc, inspectKnowledgeSchema as Si, getEntryWorkflow as Sl, knowledgeMemoryScopes as Sn, getStringOrNull as So, StoreOperationsInMemory as Sr, ModerationProcessor as Ss, endFailedSegmentSpans as St, createScorer as T, jsonValueEquals as Ta, cancelNestedRun as Tc, KnowledgePageDepthError as Ti, workflowTermination as Tl, strongerKnowledgeRole as Tn, ObservabilityInMemory as To, createGitHubSourceControlProviderFromEnv as Tr, defaultStabilityErrorProcessors as Ts, segmentSpanData as Tt, createDurableLLMMappingStep as U, threadQueryIdentitySchema as Ua, createStepFromAgent$1 as Uc, knowledgePositionBetween as Ui, ReasoningPartSchema as Ul, formatToolApproval as Un, augmentWithInit as Uo, SchedulesStorage as Ur, createWorkflow$1 as Us, generateFinalResult as Ut, createDurableGoalStep as V, encodeThreadQueryCursor as Va, runWithConcurrency as Vc, knowledgePagePath as Vi, ProcessorStepOutputSchema as Vl, CONTINUE_RUN_ACTION_ID as Vn, filterSystemReminderMessages as Vo, ScoresStorage as Vr, cloneWorkflow$1 as Vs, formatStreamCompletionFeedback as Vt, createDurableToolCallStep as W, threadQueryRequestSchema as Wa, createStepFromClassifier as Wc, knowledgeScopeReadable as Wi, SourcePartSchema as Wl, ChannelSessionRejectedError as Wn, getStorageSource as Wo, normalizeScheduleTarget as Wr, WorkflowEventProcessor as Ws, generateStructuredFinalResult as Wt, createDurableLLMExecutionStep as X, SPAN_QUERY_MAX_PREVIEW_CHARACTERS as Xa, assertTimeTravelGraphMatchesSnapshot as Xc, ExperimentsStorage as Xi, assertWorkflowStepGuard as Xl, toChatLogger as Xn, buildResponseCacheKey as Xo, notificationSignalAttributes as Xr, emitChunkEvent as Xs, loop as Xt, serializeToolsMetadata as Y, SPAN_QUERY_MAX_LIMIT as Ya, applyStateDelta as Yc, ExperimentsInMemory as Yi, WorkflowStepConflictError as Yl, resolveChannelToolsSettings as Yn, ResponseCache as Yo, createNotificationSummarySignal as Yr, emitAbortEvent as Ys, runValidation as Yt, MessagePartSpans as Z, SPAN_QUERY_ORDER_FIELDS as Za, cleanStepResult as Zc, DatasetsInMemory as Zi, isWorkflowStepConflictError as Zl, BaseProcessor as Zn, WorkspaceInstructionsProcessor as Zo, notificationSignalMetadata as Zr, emitErrorEvent as Zs, validateModelTimeoutSettings as Zt, describeNonSuccessFinishReason as _, createStorageErrorId as _a, Run as _c, KnowledgeStorage as _i, validateStepResumeData as _l, knowledgeAccessGrants as _n, buildLogRecord as _o, knowledgeScopeKey as _r, ClassifierProcessor as _s, resolveTool$1 as _t, deleteRunRegistryEntry as a, SchemaUpdateValidationError as aa, subscribeToAbortRequests as ac, resolveNotificationDeliveryDecision as ai, getSingleStepEntryId as al, removeKnowledgeNote as an, spanQueryIdentityKey as ao, MockMemory as ar, CostGuardProcessor as as, baseDurableAgenticInputSchema as at, resolveRunFence as au, createOnScorerHook as b, ensureDate as ba, createStep$1 as bc, assertKnowledgeSchemaCompatible as bi, waitForSuspendedSnapshot as bl, KnowledgeDeclarationError as bn, buildUpdateSpanRecord as bo, knowledgeVisibleScopeKeys as br, PIIDetector as bs, createDurableAgentStream as bt, getRunRegistryEntry as c, ChannelsStorage as ca, DurableAgentDefaults as cc, InMemoryKnowledgeStorage as ci, isEntryFinished as cl, upsertKnowledgePage as cn, spanQueryResponseSchema as co, MAX_KNOWLEDGE_SCOPE_TAGS as cr, TokenLimiterProcessor as cs, modelConfigSchema as ct, setRunFenceContext as cu, setRunRegistryEntry as d, BackgroundTasksInMemory as da, AGENT_STREAM_TOPIC as dc, KnowledgeImportersStorage as di, omitPriorSuspensionFields as dl, KnowledgeLinkRefreshIncompleteError as dn, encodeTraceQueryDeltaCursor as do, assertKnowledgeRecordTextWithinBound as dr, advanceMemoryTokenBoundary as ds, runDurableFinishSideEffects as dt, SchemaValidator as ea, emitStepStartEvent as ec, summarizeNotifications as ei, createTimeTravelExecutionParams as el, buildKnowledgePageTools as en, encodeSpanQueryCursor as eo, globalEmbeddingCache as er, formatSkillsCatalog as es, resolveDurableToolCallConcurrency as et, RunFenceConflictError as eu, takeRunScorerInstances as f, BackgroundTasksStorage as fa, AgentControlEventTypes as fc, KNOWLEDGE_STORAGE_CONTRACT_VERSION as fi, resolveForeachConcurrency as fl, knowledgeSubtree as fn, getTraceQueryDeltaWatermark as fo, assertKnowledgeScopeWithinCeiling as fr, getMemoryTokenBoundary as fs, loadRunStoredMessages as ft, AGENTIC_LOOP_WORKFLOW_ID as g, runRetentionBatches as ga, getStepEntry as gc, KnowledgeSchemaResetRequiredError as gi, validateStepRequestContext as gl, updateKnowledgeLinks as gn, buildFeedbackRecord as go, isKnowledgeScopeVisible as gr, ModelSelectionProcessor as gs, resolveRuntimeDependencies as gt, AGENTIC_EXECUTION_WORKFLOW_ID as h, retentionCutoffMs as ha, getNestedWorkflow as hc, KnowledgeNotFoundError$1 as hi, validateStepInput as hl, syncKnowledgePageBodyLinks as hn, buildCreateSpanRecord as ho, expandKnowledgeScope as hr, BatchPartsProcessor as hs, resolveModel as ht, abandonDurableAgentExecutions as i, UnsupportedSchemaPatternError as ia, requestAcknowledgedAbort as ic, resolveDeliveryFailureUpdate as ii, getResumeLabelsByStepId as il, moveKnowledgePage as in, spanQueryCostSchema as io, getMemoryRunState as ir, RegexFilterProcessor as is, accumulatedUsageSchema as it, matchesRunFence as iu, assembleAgentFromFsEntry as j, transformScoreRow as ja, SCORING_PREDICATE_ROOTS as jc, MAX_KNOWLEDGE_PAGE_DEPTH as ji, MessageContentSchema as jl, defaultTypingStatus as jn, MESSAGE_EMBEDDING_CHARS_PER_TOKEN as jo, cloneRunData as jr, isBadRequestError as js, __registerMastraCtor as jt, agentConfig as k, storageMessageMatchesMetadataFilter as ka, nestedRunStatusOf as kc, MAX_KNOWLEDGE_NOTE_TOKENS as ki, FilePartSchema as kl, AgentChannels as kn, UniqueViolationError as ko, MockStore as kr, FILE_UPLOAD_ERROR_CODES as ks, ensureRemoteAbortListener as kt, globalRunRegistry as l, InMemoryBlobStore as la, DurableStepIds as lc, KnowledgeImporterBindingConflictError as li, isSingleStepEntry as ll, KnowledgeSemanticIndex as ln, spanQueryRowSchema as lo, assertKnowledgeCeilingRaised as lr, groupLinkedToolMessages as ls, modelListEntrySchema as lt, agentThreadStreamRuntime as m, resolveRetentionTargets as ma, EventedExecutionEngine as mc, KnowledgeConflictError as mi, setLongTimeout as ml, reindexKnowledgeLinks as mn, planTraceQuery as mo, createKnowledgeNodeCursor as mr, normalizeMessageHistoryConfig as ms, resolveInternalState as mt, ExtendedRunRegistry as n, createValidator as na, AgentStreamBus as nc, MAX_NOTIFICATION_DELIVERY_ATTEMPTS as ni, defineStateAccessors as nl, knowledgeRunPrincipals as nn, planSpanQuery as no, MessageHistory as nr, AgentsMDInjector as ns, calculateAccumulatedUsage as nt, currentRunGeneration as nu, endRunSpansWithError as o, SchemaValidationError as oa, createRunAbortController as oc, InMemoryMemory as oi, getStepIds as ol, removeKnowledgePage as on, spanQueryIdentitySchema as oo, MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH as or, TokenCostControl as os, baseIterationStateSchema as ot, runFencingNotSupportedError as ou, AgentThreadLeaseLostError as p, executeRetentionPrune as pa, AgentStreamEventTypes as pc, KNOWLEDGE_STORAGE_SCHEMA_VERSION as pi, runCountDeprecationMessage as pl, refreshKnowledgeLinksTo as pn, planThreadQuery as po, canonicalizeKnowledgeScope as pr, isAfterMemoryTokenBoundary as ps, rebuildRunToolsFromMastra as pt, serializeDurableState as q, SPAN_QUERY_MAX_COST_METRICS as qa, RESUME_SNAPSHOT_WAIT_STATUSES as qc, InMemoryHarness as qi, ToolInvocationPartSchema as ql, createChannelToolScope as qn, DEFAULT_RESPONSE_CACHE_TTL_SECONDS as qo, dispatchDueNotifications as qr, __resetExecutionFencesForTests as qs, runDefaultCompletionCheck as qt, RunRegistry as r, getSchemaValidator as ra, publishAbortRequest as rc, defaultNotificationDeliveryDecision as ri, getRestartStartIndex as rl, addKnowledgeNote as rn, resolveSpanQueryCost as ro, MemoryRunState as rr, ToolCallFilter as rs, createBaseIterationStateUpdate as rt, isRunFenceConflictError as ru, getActiveDurableAgentWorkflowExecutions as s, InMemoryChannelsStorage as sa, DURABLE_STOP_WHEN_ERROR_ID as sc, MemoryStorage as si, hydrateSerializedStepErrors as sl, updateKnowledgeNote as sn, spanQueryRequestSchema as so, MAX_KNOWLEDGE_RECORD_TEXT_LENGTH as sr, SystemPromptScrubber as ss, durableAgenticOutputSchema as st, runOutsideRunFenceScope as su, DURABLE_CONTEXT_SEGMENT_KEY as t, assertSupportedPatterns as ta, emitSuspendedEvent as tc, readNotificationRoutingRequirement as ti, defineLazyWriter as tl, KnowledgeRun as tn, parseSpanQueryRequest as to, WorkingMemory as tr, ToolSearchProcessor as ts, buildStepRecord as tt, coverNestedRun as tu, isDurableAgentExecutionDetached as u, BlobStore as ua, AGENT_CONTROL_TOPIC as uc, KnowledgeImporterRunStateError as ui, omitPriorCompletionFields as ul, embed$2 as un, encodeTraceQueryCursor as uo, assertKnowledgeDescriptionWithinBound as ur, loadMessageHistory as us, executeDurableAgentScorers as ut, runEvals as v, createStoreErrorId as va, Workflow as vc, KnowledgeTransactionDeadlineError as vi, validateStepStateData as vl, knowledgeReadScopeFor as vn, buildMetricRecord as vo, knowledgeSemanticDocumentId as vr, StructuredOutputProcessor as vs, toolRequiresApproval as vt, ScorerRunError as w, hasErrorCode as wa, evaluatePredicate as wc, KnowledgeMoveTooLargeError as wi, waitMs as wl, knowledgeScopeAddress as wn, toEntityType as wo, GitHubSourceControlProvider as wr, STABILITY_ERROR_PROCESSOR_IDS as ws, segmentEndedBySuspension as wt, validateAndSaveScore as x, filterByDateRange as xa, isProcessor$1 as xc, createKnowledgeUlid as xi, getEntryId as xl, compileKnowledgeScopes as xn, getObjectOrNull as xo, parseKnowledgeNodeCursor as xr, PromptInjectionDetector as xs, carrySegmentSpans as xt, flushBeforeTraceRead as y, createVectorErrorId as ya, cloneStep$1 as yc, KnowledgeUnsupportedCapabilityError as yi, validateStepSuspendData as yl, knowledgeRoleOn as yn, buildScoreRecord as yo, knowledgeSemanticIdempotencyKey as yr, LanguageDetector as ys, resolveAgentById as yt, detachFullStreamOnEnd as z, THREAD_QUERY_DEFAULT_LIMIT as za, createConcurrencyLimiter as zc, canonicalKnowledgeName as zi, ProcessorOutputStreamPhaseSchema as zl, CHAT_CHANNEL_RENDER_CONTEXT_KEY as zn, MemoryProcessor as zo, ToolProviderConnectionsStorage as zr, EventedWorkflow as zs, formatCheckFeedback as zt };
|