@mastra/core 1.87.0-alpha.1 → 1.87.0-alpha.11
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_openai@4.0.106/dist/index.d.ts +2034 -0
- package/dist/_types/@ai-sdk_openai@4.0.106/package.json +1 -0
- package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +49 -0
- package/dist/a2a/index.cjs +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/agent/agent.d.ts +3 -1
- package/dist/agent/durable/index.cjs +1 -1
- package/dist/agent/durable/index.js +1 -1
- package/dist/agent/durable/run-message-refs.d.ts +3 -2
- package/dist/agent/index.cjs +5 -4
- package/dist/agent/index.d.ts +2 -0
- package/dist/agent/index.js +5 -5
- package/dist/agent/merge-persona.d.ts +15 -0
- package/dist/agent/message-list/adapters/AIV5Adapter.d.ts +15 -1
- package/dist/agent/message-list/index.cjs +2 -2
- package/dist/agent/message-list/index.js +2 -2
- package/dist/agent/message-list/state/types.d.ts +5 -1
- package/dist/agent/message-list/types.d.ts +1 -1
- package/dist/agent/message-list/utils/provider-compat.d.ts +9 -1
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/agent-controller.d.ts +6 -0
- package/dist/agent-controller/index.cjs +2 -2
- package/dist/agent-controller/index.js +2 -2
- package/dist/agent-controller/session.d.ts +11 -1
- package/dist/agent-controller/worker-run-binding.d.ts +15 -0
- package/dist/{agent-controller-C1bK0CXm.js → agent-controller-BrRzZy4-.js} +66 -15
- package/dist/{agent-controller-BTIxiD1u.cjs → agent-controller-DKI-d-np.cjs} +66 -15
- package/dist/background-tasks/index.cjs +2 -1
- package/dist/background-tasks/index.d.ts +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/background-tasks/resolve-config.d.ts +30 -1
- package/dist/background-tasks/system-prompt.d.ts +8 -2
- package/dist/background-tasks/types.d.ts +47 -1
- package/dist/{background-tasks-BbVsBghi.js → background-tasks-CDP3Pgeu.js} +156 -33
- package/dist/{background-tasks-CVl6e0Jo.cjs → background-tasks-CDgdfRmB.cjs} +167 -32
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-BRJPSTig.cjs → builder-Bs4CtyqT.cjs} +2 -2
- package/dist/{builder-C8XzrtBQ.js → builder-DuT0Iqb5.js} +2 -2
- package/dist/capabilities/302ai.json +199 -199
- package/dist/capabilities/abliteratedllm.json +43 -34
- package/dist/capabilities/abliteration-ai.json +7 -7
- package/dist/capabilities/above.json +19 -19
- package/dist/capabilities/adaption.json +15 -15
- package/dist/capabilities/adzuki.json +27 -27
- package/dist/capabilities/agentrouter.json +13 -13
- package/dist/capabilities/agnes.json +3 -3
- package/dist/capabilities/ai-router.json +6 -6
- package/dist/capabilities/aiand.json +21 -21
- package/dist/capabilities/aigrow.json +12 -12
- package/dist/capabilities/aimlapi.json +143 -146
- package/dist/capabilities/aipg.json +2 -2
- package/dist/capabilities/aixy.json +22 -22
- package/dist/capabilities/aki-io.json +16 -16
- package/dist/capabilities/alibaba-cn.json +108 -102
- 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 +52 -52
- package/dist/capabilities/alibaba-token-plan.json +53 -53
- package/dist/capabilities/alibaba.json +98 -64
- package/dist/capabilities/ambient.json +17 -10
- package/dist/capabilities/amd.json +9 -9
- package/dist/capabilities/anthropic.json +45 -45
- package/dist/capabilities/anyapi.json +47 -47
- package/dist/capabilities/apiko.json +2 -2
- package/dist/capabilities/arcee.json +11 -11
- package/dist/capabilities/augure.json +6 -6
- package/dist/capabilities/auriko.json +20 -20
- package/dist/capabilities/bailing.json +4 -4
- package/dist/capabilities/baseten.json +33 -33
- package/dist/capabilities/bee.json +5 -5
- package/dist/capabilities/berget.json +20 -7
- package/dist/capabilities/bothub.json +14 -14
- package/dist/capabilities/boundless.json +37 -37
- package/dist/capabilities/bumo.json +42 -42
- package/dist/capabilities/byteplus.json +28 -28
- package/dist/capabilities/cerebras.json +4 -4
- package/dist/capabilities/cheapaimodel.json +7 -7
- package/dist/capabilities/cheapest-token.json +30 -30
- package/dist/capabilities/chutes.json +4 -4
- package/dist/capabilities/clarifai.json +2 -2
- package/dist/capabilities/claudinio.json +10 -1
- package/dist/capabilities/cline-pass.json +42 -42
- package/dist/capabilities/cloudcode.json +9 -16
- package/dist/capabilities/cloudferro-sherlock.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +14 -14
- package/dist/capabilities/commandcode.json +140 -140
- package/dist/capabilities/concentrate.json +289 -298
- package/dist/capabilities/cortecs.json +105 -105
- package/dist/capabilities/crossmodel.json +197 -197
- package/dist/capabilities/crusoe.json +38 -9
- package/dist/capabilities/daoxe.json +8 -8
- package/dist/capabilities/databricks.json +125 -125
- package/dist/capabilities/deepinfra.json +109 -94
- package/dist/capabilities/deepseek.json +4 -4
- package/dist/capabilities/digitalocean.json +112 -112
- package/dist/capabilities/dothoosh.json +34 -34
- package/dist/capabilities/doubleword.json +24 -24
- package/dist/capabilities/edenai.json +280 -292
- package/dist/capabilities/empiriolabs.json +168 -168
- package/dist/capabilities/engy.json +21 -21
- package/dist/capabilities/entrim.json +8 -8
- package/dist/capabilities/evroc.json +12 -12
- package/dist/capabilities/ezkielyna.json +8 -8
- package/dist/capabilities/fastrouter.json +87 -87
- package/dist/capabilities/fireworks-ai.json +130 -69
- package/dist/capabilities/fortytwo.json +9 -3
- package/dist/capabilities/freemodel.json +14 -14
- package/dist/capabilities/friendli.json +2 -2
- package/dist/capabilities/frogbot.json +96 -96
- package/dist/capabilities/gisoo.json +17 -17
- package/dist/capabilities/gmicloud.json +24 -24
- package/dist/capabilities/google.json +54 -54
- 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 +94 -94
- package/dist/capabilities/hetzner.json +35 -3
- package/dist/capabilities/hostinger-router.json +14 -14
- package/dist/capabilities/hpc-ai.json +11 -11
- package/dist/capabilities/huawei-maas.json +14 -14
- package/dist/capabilities/hubris.json +30 -30
- package/dist/capabilities/huggingface.json +113 -155
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +25 -33
- package/dist/capabilities/impossibl.json +155 -155
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +8 -8
- package/dist/capabilities/inco.json +5 -5
- package/dist/capabilities/infer.json +20 -20
- package/dist/capabilities/inferall.json +14 -14
- package/dist/capabilities/inference-coop.json +9 -9
- package/dist/capabilities/inferenceapis.json +20 -20
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +11 -11
- package/dist/capabilities/infomaniak.json +4 -4
- package/dist/capabilities/io-net.json +4 -4
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +59 -59
- package/dist/capabilities/jad-ai.json +3 -3
- package/dist/capabilities/jalapeno.json +10 -10
- package/dist/capabilities/jiekou.json +60 -60
- package/dist/capabilities/joingonka.json +4 -4
- package/dist/capabilities/jzstoken.json +58 -59
- package/dist/capabilities/keln.json +18 -18
- package/dist/capabilities/kenari.json +119 -127
- package/dist/capabilities/kilo.json +609 -613
- package/dist/capabilities/kimi-code-plan-cn.json +5 -5
- package/dist/capabilities/kimi-code-plan-global.json +5 -5
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +20 -20
- package/dist/capabilities/korouter.json +32 -32
- package/dist/capabilities/kunavo.json +8 -8
- package/dist/capabilities/liquid.json +12 -12
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +947 -878
- package/dist/capabilities/llmgateway.json +336 -335
- package/dist/capabilities/llmtr.json +26 -26
- package/dist/capabilities/logits.json +2 -2
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +65 -65
- package/dist/capabilities/lyceum.json +19 -11
- package/dist/capabilities/melious.json +14 -14
- package/dist/capabilities/merge-gateway.json +264 -263
- package/dist/capabilities/meta.json +13 -13
- package/dist/capabilities/minimax-cn-coding-plan.json +2 -2
- package/dist/capabilities/minimax-cn.json +5 -5
- package/dist/capabilities/minimax-coding-plan.json +2 -2
- package/dist/capabilities/minimax.json +5 -5
- package/dist/capabilities/mistral.json +21 -21
- package/dist/capabilities/mixlayer.json +3 -3
- package/dist/capabilities/modal.json +10 -10
- package/dist/capabilities/model-oracle-ai.json +26 -26
- package/dist/capabilities/modelis.json +17 -17
- package/dist/capabilities/modelscope.json +2 -2
- package/dist/capabilities/modular.json +30 -8
- package/dist/capabilities/moneo.json +12 -12
- package/dist/capabilities/moonshotai-cn.json +2 -2
- package/dist/capabilities/moonshotai.json +2 -2
- package/dist/capabilities/morph.json +17 -17
- package/dist/capabilities/munito-eu.json +6 -6
- package/dist/capabilities/munito.json +6 -6
- package/dist/capabilities/nan.json +29 -29
- package/dist/capabilities/nano-gpt.json +606 -593
- package/dist/capabilities/nearai.json +112 -112
- package/dist/capabilities/nebius.json +30 -30
- package/dist/capabilities/neon.json +136 -136
- package/dist/capabilities/neuralwatt.json +43 -43
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +136 -136
- package/dist/capabilities/nvidia.json +52 -35
- package/dist/capabilities/oathbreaker.json +24 -1
- package/dist/capabilities/obscurify.json +29 -29
- package/dist/capabilities/oci.json +7 -7
- package/dist/capabilities/ofox.json +315 -315
- package/dist/capabilities/ollama-cloud.json +53 -53
- package/dist/capabilities/openai.json +53 -53
- package/dist/capabilities/opencode-go.json +88 -88
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +528 -519
- package/dist/capabilities/opper.json +29 -29
- package/dist/capabilities/orcarouter.json +214 -214
- package/dist/capabilities/outerlabs.json +33 -33
- package/dist/capabilities/ovhcloud.json +20 -20
- package/dist/capabilities/pareto.json +6 -6
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +55 -55
- package/dist/capabilities/perplexity.json +2 -2
- package/dist/capabilities/phala.json +26 -26
- package/dist/capabilities/pioneer.json +31 -31
- package/dist/capabilities/poe.json +136 -136
- package/dist/capabilities/poolside.json +2 -2
- package/dist/capabilities/powerspring.json +12 -12
- package/dist/capabilities/primalabs.json +9 -9
- package/dist/capabilities/prime.json +121 -111
- package/dist/capabilities/privatemode-ai.json +5 -5
- package/dist/capabilities/proxystacks.json +7 -7
- package/dist/capabilities/qiniu-ai.json +16 -16
- package/dist/capabilities/refuseless.json +9 -9
- package/dist/capabilities/regolo-ai.json +11 -11
- package/dist/capabilities/requesty.json +451 -177
- package/dist/capabilities/ruapi.json +35 -19
- package/dist/capabilities/runcrate.json +13 -13
- package/dist/capabilities/runinfra.json +18 -18
- package/dist/capabilities/sakana.json +7 -7
- package/dist/capabilities/sambanova.json +6 -6
- package/dist/capabilities/sandbase.json +25 -25
- package/dist/capabilities/sarvam.json +7 -7
- package/dist/capabilities/scaleway.json +19 -19
- package/dist/capabilities/scnet-token-plan.json +10 -10
- package/dist/capabilities/scx-ai.json +30 -30
- package/dist/capabilities/sensenova.json +12 -12
- package/dist/capabilities/siliconflow-cn.json +60 -60
- package/dist/capabilities/siliconflow.json +62 -62
- package/dist/capabilities/snowflake-cortex.json +21 -21
- package/dist/capabilities/sokkan.json +7 -7
- package/dist/capabilities/sparrowcodes.json +19 -19
- package/dist/capabilities/standardcompute.json +106 -106
- package/dist/capabilities/steadyrouter.json +37 -37
- package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
- package/dist/capabilities/stepfun-ai.json +6 -6
- package/dist/capabilities/stepfun-step-plan.json +6 -6
- package/dist/capabilities/stepfun.json +6 -6
- package/dist/capabilities/stepping-stone.json +17 -17
- package/dist/capabilities/superbot-gg.json +4 -4
- package/dist/capabilities/synthetic.json +13 -13
- package/dist/capabilities/synthorai.json +24 -24
- package/dist/capabilities/teamorouter.json +23 -23
- package/dist/capabilities/teapot-router.json +11 -11
- package/dist/capabilities/tencent-token-plan-intl.json +126 -0
- package/dist/capabilities/tencent-token-plan.json +44 -44
- package/dist/capabilities/tencent-tokenhub.json +58 -43
- package/dist/capabilities/tensorx.json +40 -40
- package/dist/capabilities/tenstorrent.json +8 -8
- package/dist/capabilities/the-grid-ai.json +35 -35
- package/dist/capabilities/thinkingmachines.json +76 -76
- package/dist/capabilities/tinfoil.json +13 -13
- package/dist/capabilities/toapis.json +3 -3
- package/dist/capabilities/togetherai.json +54 -54
- package/dist/capabilities/tokengo.json +25 -25
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/tokenwatt.json +10 -2
- package/dist/capabilities/trustedrouter.json +7 -7
- package/dist/capabilities/trustedtokens.json +18 -18
- package/dist/capabilities/umans-ai-coding-plan.json +13 -13
- package/dist/capabilities/umans-ai.json +14 -14
- package/dist/capabilities/uncensuredai.json +5 -5
- package/dist/capabilities/unrestricted.json +8 -8
- package/dist/capabilities/uplinkswitch.json +22 -22
- package/dist/capabilities/upstage.json +6 -6
- package/dist/capabilities/vancine.json +23 -23
- package/dist/capabilities/vercel.json +543 -540
- package/dist/capabilities/vivgrid.json +88 -79
- package/dist/capabilities/volcengine-coding-plan.json +26 -26
- package/dist/capabilities/volcengine.json +26 -25
- package/dist/capabilities/vultr.json +32 -32
- package/dist/capabilities/wafer.ai.json +16 -16
- package/dist/capabilities/wallaby.json +2 -2
- package/dist/capabilities/wally.json +11 -11
- package/dist/capabilities/wandb.json +17 -17
- package/dist/capabilities/watt.json +25 -25
- package/dist/capabilities/xai.json +6 -6
- package/dist/capabilities/xiaomi.json +2 -2
- package/dist/capabilities/xpersona.json +13 -13
- package/dist/capabilities/xxapi.json +26 -26
- package/dist/capabilities/zai-coding-plan.json +15 -15
- package/dist/capabilities/zai.json +32 -32
- package/dist/capabilities/zenifra.json +26 -26
- package/dist/capabilities/zenmux.json +208 -208
- package/dist/capabilities/zerogpu.json +13 -13
- package/dist/capabilities/zhipuai-coding-plan.json +4 -4
- package/dist/capabilities/zhipuai.json +31 -31
- package/dist/capabilities/zro.json +7 -7
- package/dist/channels/agent-channels.d.ts +22 -0
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/channels/output-processor.d.ts +12 -0
- package/dist/channels/state-adapter.d.ts +3 -1
- package/dist/channels/stream-helpers.d.ts +17 -0
- package/dist/{channels-Cl-pRrWB.cjs → channels-Bkd_v8M1.cjs} +1 -1
- package/dist/{channels-DegTNzaq.js → channels-CkRMEIQ6.js} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/{constants-B9ZDvXZ4.cjs → constants-Bou0hEgY.cjs} +4 -0
- package/dist/{constants-BmdTvEYN.js → constants-CFWgIaqA.js} +4 -0
- package/dist/datasets/experiment/scorer.d.ts +16 -5
- package/dist/datasets/index.cjs +2 -2
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1070 -1055
- package/dist/docs/references/docs-agents-code-mode.md +36 -0
- package/dist/docs/references/docs-agents-networks.md +1 -1
- package/dist/docs/references/docs-agents-tools.md +6 -0
- package/dist/docs/references/docs-auth-simple-auth.md +8 -8
- package/dist/docs/references/docs-browser.md +3 -1
- package/dist/docs/references/docs-evals-custom-scorers.md +1 -1
- package/dist/docs/references/docs-harness-background-tasks.md +38 -0
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +2 -0
- package/dist/docs/references/docs-mastra-platform-observability-overview.md +3 -189
- package/dist/docs/references/docs-memory-message-history.md +25 -0
- package/dist/docs/references/docs-sandbox-lsp.md +5 -6
- package/dist/docs/references/docs-sandbox-overview.md +20 -0
- package/dist/docs/references/docs-sandbox-skills.md +2 -0
- package/dist/docs/references/docs-signals-sending-signals.md +1 -1
- package/dist/docs/references/integrations.md +1 -0
- package/dist/docs/references/reference-agent-controller-session.md +30 -2
- package/dist/docs/references/reference-agents-generate.md +1 -1
- package/dist/docs/references/reference-agents-network.md +1 -1
- package/dist/docs/references/reference-configuration.md +8 -8
- package/dist/docs/references/reference-core-getWorkspaceById.md +37 -0
- package/dist/docs/references/reference-evals-create-scorer.md +5 -5
- package/dist/docs/references/reference-evals-run-evals.md +1 -1
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +3 -3
- package/dist/docs/references/reference-manual-install.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +8 -0
- package/dist/docs/references/reference-observability-tracing-interfaces.md +10 -6
- package/dist/docs/references/reference-processors-processor-interface.md +3 -2
- package/dist/docs/references/reference-processors-system-prompt-scrubber.md +1 -1
- package/dist/docs/references/reference-processors-tool-search-processor.md +3 -3
- package/dist/docs/references/reference-pubsub-base.md +5 -3
- package/dist/docs/references/reference-pubsub-caching-pubsub.md +3 -1
- package/dist/docs/references/reference-storage-overview.md +1 -1
- package/dist/docs/references/reference-storage-retention.md +20 -20
- package/dist/docs/references/reference-tools-create-code-mode.md +22 -0
- package/dist/docs/references/reference-tools-vector-query-tool.md +8 -0
- package/dist/docs/references/reference-voice-overview.md +11 -26
- package/dist/docs/references/reference-voice-speech-to-speech.md +1 -1
- package/dist/docs/references/reference-voice-voice.listen.md +1 -0
- package/dist/docs/references/reference-voice-voice.speak.md +1 -3
- package/dist/docs/references/reference-workspace-factory-sandbox.md +6 -6
- package/dist/docs/references/reference-workspace-sandbox.md +14 -0
- package/dist/docs/references/reference.md +1 -0
- package/dist/evals/index.cjs +2 -2
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +2 -2
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/harness/index.cjs +2 -2
- package/dist/harness/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/agent-scopes.d.ts +17 -0
- package/dist/knowledge/declarations.d.ts +2 -0
- package/dist/knowledge/held-scopes-state-processor.d.ts +50 -0
- package/dist/knowledge/importers/host.d.ts +7 -1
- package/dist/knowledge/importers/overlay.d.ts +138 -0
- package/dist/knowledge/importers/runner.d.ts +12 -0
- package/dist/knowledge/importers/sink.d.ts +6 -0
- package/dist/knowledge/importers/types.d.ts +9 -0
- package/dist/knowledge/index.cjs +1611 -167
- package/dist/knowledge/index.d.ts +12 -2
- package/dist/knowledge/index.js +1610 -168
- package/dist/knowledge/links.d.ts +27 -0
- package/dist/knowledge/page-tools.d.ts +23 -0
- package/dist/knowledge/pinned-state-processor.d.ts +2 -2
- package/dist/knowledge/run.d.ts +5 -0
- package/dist/knowledge/scope-runtime.d.ts +6 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/base.types.d.ts +3 -1
- package/dist/llm/model/mastra-gateway-provider-tools.d.ts +9 -6
- package/dist/llm/model/model.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.types.d.ts +3 -1
- package/dist/llm/model/provider-options.d.ts +4 -3
- package/dist/llm/model/provider-types.generated.d.ts +8161 -8082
- package/dist/{llm-BKxlS9Kk.cjs → llm-DAw2eouV.cjs} +38 -78
- package/dist/{llm-CMkzIFAk.js → llm-DFT5EKp4.js} +38 -78
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-C-eQXmRq.js → manager-DiDnvKLM.js} +106 -35
- package/dist/{manager-CasaT35Q.cjs → manager-hxzEe4U5.cjs} +106 -35
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-C7Tj4U8c.cjs → mastra-1diaq68N.cjs} +17 -17
- package/dist/{mastra-5EEmN3Ok.js → mastra-BPaPxG5t.js} +17 -17
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/{message-list-wI71UGxk.js → message-list-BGm1DCiG.js} +230 -129
- package/dist/{message-list-DfN9mWeN.cjs → message-list-vR3uLAHL.cjs} +230 -129
- package/dist/{model-DCLUL-8a.js → model-CUBZjm0T.js} +4 -3
- package/dist/{model-9HA-W0tg.cjs → model-DSMHJM3c.cjs} +4 -3
- package/dist/{netlify-Cq3H-A9I.cjs → netlify-C21T9ozJ.cjs} +41364 -30461
- package/dist/{netlify-DaWURNSU.js → netlify-D1BKjns0.js} +41361 -30464
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +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/processors/processors/tool-search.d.ts +2 -2
- package/dist/processors/runner.d.ts +12 -0
- package/dist/{provider-registry-DWixjFX7.js → provider-registry-BAlFFX5o.js} +21911 -21671
- package/dist/{provider-registry-a649fS5r.cjs → provider-registry-ChojUVJa.cjs} +21910 -21670
- package/dist/provider-registry.json +21947 -21767
- package/dist/{registry-generator-BYJC7p8M.js → registry-generator-BbWSH6W4.js} +1 -1
- package/dist/{registry-generator-BuKC7UKd.cjs → registry-generator-CAUL9Hek.cjs} +1 -1
- package/dist/{rehydrate-DR2_WAz2.cjs → rehydrate-0xSq47n9.cjs} +2 -2
- package/dist/{rehydrate-DPhmASM6.js → rehydrate-CzUnNFU6.js} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-oUNF6szW.cjs → run-registry-CrTsH9iL.cjs} +1158 -125
- package/dist/{run-registry-D3X7XvUL.js → run-registry-DJT02z_9.js} +1092 -125
- package/dist/storage/constants.cjs +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +101 -1
- package/dist/storage/domains/knowledge/importers-inmemory.d.ts +10 -0
- package/dist/storage/domains/knowledge/importers.d.ts +39 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +8 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +35 -1
- package/dist/storage/domains/knowledge/pages.d.ts +74 -0
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +3 -3
- package/dist/storage/types.d.ts +14 -0
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-DoZ6F41o.js → stream-CG9OooRx.js} +37 -14
- package/dist/{stream-DQC1vpvl.cjs → stream-CMKRczs4.cjs} +37 -14
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/{to-prompt-B9eZo2U5.cjs → to-prompt-CG-LyaBY.cjs} +9 -0
- package/dist/{to-prompt-BsDtVXrf.js → to-prompt-CMlVGYxC.js} +9 -0
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-Cy4NDOMS.cjs → tool-loop-agent-14o3Z1qo.cjs} +4 -4
- package/dist/{tool-loop-agent-C9YkvDRd.js → tool-loop-agent-Bi6z_q7o.js} +4 -4
- package/dist/tools/code-mode/index.d.ts +2 -0
- package/dist/tools/code-mode/log-collector.d.ts +49 -0
- package/dist/tools/code-mode/types.d.ts +71 -0
- package/dist/tools/index.cjs +3 -1
- package/dist/tools/index.js +2 -2
- package/dist/{tools-CGF5Ik6j.cjs → tools-BEYxowf0.cjs} +429 -61
- package/dist/{tools-CDfyMpzN.js → tools-tPy2FwMI.js} +418 -62
- package/dist/{utils-Bs2IYyOb.cjs → utils-DkvbP8EA.cjs} +7 -6
- package/dist/{utils-9JyiKu5r.js → utils-Fag7YDBU.js} +7 -6
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-BE3mVxVy.cjs → validate-Bhrlve2E.cjs} +1 -1
- package/dist/{validate-8j0phWFV.js → validate-DLER0nlQ.js} +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/workers/orchestration-worker.d.ts +1 -0
- package/dist/{worker-DwdgU6E9.cjs → worker-0gczpztM.cjs} +2 -2
- package/dist/{worker-BiK1kfMa.cjs → worker-BwJyrFQN.cjs} +10 -4
- package/dist/{worker-BfWFqSH2.js → worker-D-em3hyS.js} +5 -5
- package/dist/{worker-DIRdEwih.js → worker-leYV1Y91.js} +2 -2
- package/dist/{workflow-CxQMcTbT.cjs → workflow-DWdcEcxw.cjs} +3 -3
- package/dist/{workflow-ni-keg2i.js → workflow-FikHVwog.js} +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/dist/workflows/step.d.ts +2 -0
- package/dist/workflows/workflow.d.ts +2 -0
- package/dist/workspace/index.cjs +3 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +2 -2
- package/dist/workspace/lsp/manager.d.ts +19 -4
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +17 -0
- package/dist/workspace/sandbox/teardown-context.d.ts +74 -0
- package/dist/workspace/tools/index.d.ts +1 -0
- package/dist/workspace/tools/media.d.ts +20 -1
- package/dist/workspace/tools/recreate-sandbox.d.ts +24 -0
- package/dist/{workspace-X2RHJZU9.cjs → workspace-C8Zo5_qK.cjs} +387 -109
- package/dist/{workspace-DY2Nxiyi.js → workspace-DOAil8mG.js} +376 -110
- package/package.json +6 -6
- package/src/llm/model/provider-types.generated.d.ts +8161 -8082
|
@@ -4,18 +4,18 @@ 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-CG9OooRx.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-BGm1DCiG.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-DFT5EKp4.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";
|
|
18
|
-
import { h as resolveFilePartMediaTypeAndData, m as parseDataUri, o as categorizeFileData } from "./to-prompt-
|
|
18
|
+
import { h as resolveFilePartMediaTypeAndData, m as parseDataUri, o as categorizeFileData } from "./to-prompt-CMlVGYxC.js";
|
|
19
19
|
import { c as parsePartialJson, h as tool$1, m as generateId$1, p as asSchema$1, r as embed$4, u as APICallError$1 } from "./dist-TPVqg8oV.js";
|
|
20
20
|
import { n as embed$5 } from "./dist-D3cKCUe-.js";
|
|
21
21
|
import { t as deepEqual$3 } from "./deep-equal-d1xU02ag.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-BAlFFX5o.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-CUBZjm0T.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-Fag7YDBU.js";
|
|
32
32
|
import { h as getWorkflowFGAResourceId, i as MastraFGAPermissions, y as requireFGA } from "./ee-iTj2bRDt-By_B9ngH.js";
|
|
33
|
-
import {
|
|
33
|
+
import { c as createBackgroundTask, o as resolveBackgroundConfig, s as sanitizeToolArguments, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-CDP3Pgeu.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";
|
|
@@ -39,11 +39,11 @@ import { HAND_BACK_STATE_SYMBOL, PARENT_STATE_SYMBOL, PUBSUB_SYMBOL, STREAM_FORM
|
|
|
39
39
|
import { i as executeHook } from "./hooks-Bth8Cjpj.js";
|
|
40
40
|
import { o as assertValidScheduleDefinition, v as validateScheduleTiming } from "./schedules-DZfSx-7P.js";
|
|
41
41
|
import { A as writeObjective, D as readObjective, O as resolveEffectiveGoalSettings, T as formatGoalBudgetPausedReason, _ as clearCachedGoalObjective, b as GOAL_SCORER_ID, g as cacheGoalObjective, k as resolveGoalStore, w as clearObjective, x as GOAL_SCORE_WAITING } from "./state-processor-B9kxpM53.js";
|
|
42
|
-
import { An as computeTraceStatus, Cr as extractTrajectory, Dr as saveScorePayloadSchema, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Nn as extractBranchSpans, Pn as getBranchArgsSchema, Qn as listTracesArgsSchema, Sr as withBufferedReflectionVerified, Tr as extractWorkflowTrajectory, Yn as listBranchesArgsSchema, _r as isAppendOnlySince, ar as spanRecordSchema, br as maxObservationCursor, cr as toTraceSpans, gn as BRANCH_SPAN_TYPE_SET, gr as compareObservationalMemoryHeadOrder, hr as assertActiveObservationsApplied, or as toLightSpanRecord, pn as matchesExpectedWorkflowStatus, qn as isPreviewTruncated, sr as toTraceSpan, vn as TraceStatus, vr as isBufferedChunkCoveredByCursor, wr as extractTrajectoryFromTrace, xr as planReflectionGenerationText, yr as isBufferedReflectionUnchangedSince } from "./constants-
|
|
42
|
+
import { An as computeTraceStatus, Cr as extractTrajectory, Dr as saveScorePayloadSchema, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Nn as extractBranchSpans, Pn as getBranchArgsSchema, Qn as listTracesArgsSchema, Sr as withBufferedReflectionVerified, Tr as extractWorkflowTrajectory, Yn as listBranchesArgsSchema, _r as isAppendOnlySince, ar as spanRecordSchema, br as maxObservationCursor, cr as toTraceSpans, gn as BRANCH_SPAN_TYPE_SET, gr as compareObservationalMemoryHeadOrder, hr as assertActiveObservationsApplied, or as toLightSpanRecord, pn as matchesExpectedWorkflowStatus, qn as isPreviewTruncated, sr as toTraceSpan, vn as TraceStatus, vr as isBufferedChunkCoveredByCursor, wr as extractTrajectoryFromTrace, xr as planReflectionGenerationText, yr as isBufferedReflectionUnchangedSince } from "./constants-CFWgIaqA.js";
|
|
43
43
|
import { t as GoalSignalProvider } from "./signal-provider-BslnAjWG.js";
|
|
44
44
|
import { t as slugify } from "./slugify-BUNmb-Ga.js";
|
|
45
|
-
import {
|
|
46
|
-
import { i as normalizeWebSearchProvider, n as createWebSearchProviderTool, r as isWebSearchTool } from "./tools-
|
|
45
|
+
import { F as LocalSandbox, at as evaluateReadRecord, c as Workspace, dt as WORKSPACE_TOOLS, g as resolveToolConfig, gt as shellQuote, h as createWorkspaceTools, ht as sliceByTokens, l as createSkillTools, lt as CompositeFilesystem, mt as estimateTokenCount, ot as normalizeReadTrackerPath, pt as sliceByTokensSafe, st as LocalFilesystem } from "./workspace-DOAil8mG.js";
|
|
46
|
+
import { i as normalizeWebSearchProvider, n as createWebSearchProviderTool, r as isWebSearchTool } from "./tools-tPy2FwMI.js";
|
|
47
47
|
import { D as BM25Index, O as tokenize } from "./workspace-skills-38OY32_b.js";
|
|
48
48
|
import { f as calculatePagination, g as InMemoryThreadStateStorage, h as resolveListOrderBy, m as normalizePerPage, p as compareByField, s as StorageDomain, u as MastraCompositeStore } from "./filesystem-versioned-BL1ojJLo.js";
|
|
49
49
|
import { coreFeatures } from "./features/index.js";
|
|
@@ -65,11 +65,11 @@ import { ReadableStream as ReadableStream$1, TransformStream as TransformStream$
|
|
|
65
65
|
import { injectJsonInstructionIntoMessages, isAbortError } from "@ai-sdk/provider-utils-v6";
|
|
66
66
|
import { z as z$1 } from "zod";
|
|
67
67
|
import { createHash, randomUUID } from "crypto";
|
|
68
|
+
import { config, toJSONSchema } from "zod/v4/core";
|
|
69
|
+
import en from "zod/v4/locales/en.js";
|
|
68
70
|
import { prepareJsonSchemaForOpenAIStrictMode, wrapSchemaWithNullTransform } from "@mastra/schema-compat";
|
|
69
71
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
70
72
|
import { dirname, extname, isAbsolute, join, normalize, posix, relative, resolve, sep, win32 } from "path";
|
|
71
|
-
import { config, toJSONSchema } from "zod/v4/core";
|
|
72
|
-
import en from "zod/v4/locales/en.js";
|
|
73
73
|
import { jsonSchemaToZod } from "@mastra/schema-compat/json-to-zod";
|
|
74
74
|
import { AsyncLocalStorage } from "async_hooks";
|
|
75
75
|
import fastq from "fastq";
|
|
@@ -7613,6 +7613,7 @@ function createStepFromProcessor$1(processor) {
|
|
|
7613
7613
|
};
|
|
7614
7614
|
const step = {
|
|
7615
7615
|
id: `processor:${processor.id}`,
|
|
7616
|
+
processorId: processor.id,
|
|
7616
7617
|
description: processor.name ?? `Processor ${processor.id}`,
|
|
7617
7618
|
inputSchema: toStandardSchema(ProcessorStepInputSchema),
|
|
7618
7619
|
outputSchema: toStandardSchema(ProcessorStepOutputSchema),
|
|
@@ -8258,7 +8259,8 @@ function cloneStep$1(step, opts) {
|
|
|
8258
8259
|
retries: step.retries,
|
|
8259
8260
|
scorers: step.scorers,
|
|
8260
8261
|
component: step.component,
|
|
8261
|
-
metadata: step.metadata
|
|
8262
|
+
metadata: step.metadata,
|
|
8263
|
+
processorId: step.processorId
|
|
8262
8264
|
};
|
|
8263
8265
|
}
|
|
8264
8266
|
/**
|
|
@@ -11708,6 +11710,21 @@ function warnUnsupportedEventedSetup(mastra, workflowsStore) {
|
|
|
11708
11710
|
warnedHosts.add(mastra);
|
|
11709
11711
|
mastra.getLogger()?.warn(`Evented workflows and agents aren't supported on several processes with this setup: ${missing}. See ${DOCS_URL}`);
|
|
11710
11712
|
}
|
|
11713
|
+
// src/agent-controller/worker-run-binding.ts
|
|
11714
|
+
const CONTROLLER_RUN_BINDING_KEY = "mastra__controllerRunBinding";
|
|
11715
|
+
const controllerRunBindingSchema = z.object({
|
|
11716
|
+
controllerId: z.string().min(1),
|
|
11717
|
+
agentId: z.string().min(1),
|
|
11718
|
+
sessionId: z.string().min(1),
|
|
11719
|
+
ownerId: z.string(),
|
|
11720
|
+
resourceId: z.string().min(1),
|
|
11721
|
+
threadId: z.string().min(1),
|
|
11722
|
+
modeId: z.string().min(1)
|
|
11723
|
+
});
|
|
11724
|
+
const restoredWorkerControllerContexts = /* @__PURE__ */ new WeakSet();
|
|
11725
|
+
function isRestoredWorkerControllerContext(value) {
|
|
11726
|
+
return typeof value === "object" && value !== null && restoredWorkerControllerContexts.has(value);
|
|
11727
|
+
}
|
|
11711
11728
|
// src/agent/scopes.ts
|
|
11712
11729
|
/**
|
|
11713
11730
|
* Scope types Memory reads as the run's identity. Every other scope type is
|
|
@@ -11996,6 +12013,7 @@ function snapshotRequestContextEntries(requestContext, onEntryOmitted) {
|
|
|
11996
12013
|
if (key === "mastra__versions") continue;
|
|
11997
12014
|
if (key === "mastra__durableExecutions") continue;
|
|
11998
12015
|
if (key === "mastra__durableSegments") continue;
|
|
12016
|
+
if (key === "__mastra_chat_channel_render") continue;
|
|
11999
12017
|
const json = boundedStringify(value);
|
|
12000
12018
|
if (json === void 0) {
|
|
12001
12019
|
onEntryOmitted?.();
|
|
@@ -12022,6 +12040,8 @@ function restoreRequestContext(entries, runLevel, liveRunContext) {
|
|
|
12022
12040
|
if (liveRunContext) return liveRunContext;
|
|
12023
12041
|
if (entries) {
|
|
12024
12042
|
const restored = new RequestContext([...Object.entries(withoutLiveRequestKeys(entries)), ...liveRequestEntries(runLevel)]);
|
|
12043
|
+
const controller = runLevel?.get("controller");
|
|
12044
|
+
if (isRestoredWorkerControllerContext(controller)) restored.set("controller", controller);
|
|
12025
12045
|
restoreRunAgentScopes(restored);
|
|
12026
12046
|
return restored;
|
|
12027
12047
|
}
|
|
@@ -15485,7 +15505,8 @@ var StepExecutor = class extends MastraBase {
|
|
|
15485
15505
|
return storageV2StepResultAccessors((step) => getHydratedStepResult(stepResults, step, hydrate));
|
|
15486
15506
|
}
|
|
15487
15507
|
async execute(params) {
|
|
15488
|
-
const { entry, stepResults, runId,
|
|
15508
|
+
const { entry, stepResults, runId, retryCount = 0, perStep } = params;
|
|
15509
|
+
let { requestContext } = params;
|
|
15489
15510
|
const stepId = getEntryId(entry);
|
|
15490
15511
|
const errorAttemptId = `${runId}:${stepId}:${params.foreachIdx ?? ""}:attempt:${retryCount}`;
|
|
15491
15512
|
const schemas = getEntrySchemas(entry, this.mastra);
|
|
@@ -15541,6 +15562,18 @@ var StepExecutor = class extends MastraBase {
|
|
|
15541
15562
|
const stepTracingContext = workflowStepSpan ? { currentSpan: workflowStepSpan } : params.tracingContext ?? {};
|
|
15542
15563
|
try {
|
|
15543
15564
|
if (validationError) throw validationError;
|
|
15565
|
+
if (params.workflowId === DurableStepIds.AGENTIC_LOOP || params.workflowId === DurableStepIds.AGENTIC_EXECUTION) {
|
|
15566
|
+
const live = requestContext.get("controller");
|
|
15567
|
+
const initial = stepResults.input;
|
|
15568
|
+
const binding = initial?.requestContextEntries?.[CONTROLLER_RUN_BINDING_KEY];
|
|
15569
|
+
if (initial && binding !== void 0 && typeof live?.getState !== "function") {
|
|
15570
|
+
const parsed = controllerRunBindingSchema.parse(binding);
|
|
15571
|
+
if (initial.agentId !== parsed.agentId || initial.state?.threadId !== parsed.threadId || initial.state.resourceId !== parsed.resourceId) throw new Error("Controller binding does not match this durable run");
|
|
15572
|
+
const controller = this.mastra?.getAgentControllerById(parsed.controllerId);
|
|
15573
|
+
if (!controller) throw new Error("Controller is not registered on this worker");
|
|
15574
|
+
requestContext = await controller.__restoreWorkerRequestContext(requestContext, parsed, abortController.signal, initial.runId);
|
|
15575
|
+
}
|
|
15576
|
+
}
|
|
15544
15577
|
const callId = globalThis.crypto.randomUUID();
|
|
15545
15578
|
const outputWriter = this.createOutputWriter(runId);
|
|
15546
15579
|
const stepOutput = await executeWithContext({
|
|
@@ -21337,7 +21370,8 @@ function cloneStep(step, opts) {
|
|
|
21337
21370
|
retries: step.retries,
|
|
21338
21371
|
scorers: step.scorers,
|
|
21339
21372
|
metadata: step.metadata,
|
|
21340
|
-
component: step.component
|
|
21373
|
+
component: step.component,
|
|
21374
|
+
processorId: step.processorId
|
|
21341
21375
|
};
|
|
21342
21376
|
}
|
|
21343
21377
|
function isToolStep(input) {
|
|
@@ -21597,6 +21631,7 @@ function createStepFromProcessor(processor) {
|
|
|
21597
21631
|
};
|
|
21598
21632
|
return {
|
|
21599
21633
|
id: `processor:${processor.id}`,
|
|
21634
|
+
processorId: processor.id,
|
|
21600
21635
|
description: processor.name ?? `Processor ${processor.id}`,
|
|
21601
21636
|
inputSchema: toStandardSchema(ProcessorStepSchema),
|
|
21602
21637
|
outputSchema: toStandardSchema(ProcessorStepOutputSchema),
|
|
@@ -27746,12 +27781,14 @@ async function partitionMessages(messagesDescending, limits, tokenCounter, initi
|
|
|
27746
27781
|
if (maxTokens !== void 0 && !tokenCounter) throw new Error("A token counter is required to load token-limited message history");
|
|
27747
27782
|
let messageCount = 0;
|
|
27748
27783
|
let tokenCount = initialTokens;
|
|
27784
|
+
let loadedTokens = initialTokens;
|
|
27749
27785
|
let reachedLimit = false;
|
|
27750
27786
|
let overflowReason;
|
|
27751
27787
|
const retainedIds = /* @__PURE__ */ new Set();
|
|
27752
27788
|
for (const group of groupLinkedToolMessages(messagesDescending)) {
|
|
27753
27789
|
let groupTokens = 0;
|
|
27754
27790
|
if (tokenCounter) for (const message of group) groupTokens += await tokenCounter.countMessage(message);
|
|
27791
|
+
loadedTokens += groupTokens;
|
|
27755
27792
|
const exceedsMessageLimit = limits.maxMessages !== void 0 && messageCount + group.length > limits.maxMessages;
|
|
27756
27793
|
const exceedsTokenLimit = maxTokens !== void 0 && tokenCount + groupTokens > maxTokens;
|
|
27757
27794
|
if (reachedLimit || exceedsMessageLimit || exceedsTokenLimit) {
|
|
@@ -27766,7 +27803,8 @@ async function partitionMessages(messagesDescending, limits, tokenCounter, initi
|
|
|
27766
27803
|
return {
|
|
27767
27804
|
messages: messagesDescending.filter((message) => retainedIds.has(message.id)).reverse(),
|
|
27768
27805
|
overflow: messagesDescending.filter((message) => !retainedIds.has(message.id)).reverse(),
|
|
27769
|
-
overflowReason
|
|
27806
|
+
overflowReason,
|
|
27807
|
+
loadedTokens
|
|
27770
27808
|
};
|
|
27771
27809
|
}
|
|
27772
27810
|
function laterDate(left, right) {
|
|
@@ -27828,15 +27866,15 @@ async function loadMessageHistory(args) {
|
|
|
27828
27866
|
const newestOverflow = partitioned.overflow.at(-1);
|
|
27829
27867
|
if (newestOverflow) cutoffTimestamp = newestOverflow.createdAt.getTime();
|
|
27830
27868
|
const oldestTimestamp = result.messages.at(-1)?.createdAt.getTime();
|
|
27831
|
-
const crossedCutoff = cutoffTimestamp !== void 0 && oldestTimestamp !== void 0 && oldestTimestamp < cutoffTimestamp;
|
|
27869
|
+
const crossedCutoff = cutoffTimestamp !== void 0 && oldestTimestamp !== void 0 && oldestTimestamp < cutoffTimestamp && (!args.includeOverflow || partitioned.overflowReason !== "tokens" || partitioned.loadedTokens > (args.maxTokens ?? 0));
|
|
27832
27870
|
const reachedBoundary = args.boundary !== void 0 && oldestTimestamp !== void 0 && oldestTimestamp < new Date(args.boundary.createdAt).getTime();
|
|
27833
|
-
if (!result.hasMore || crossedCutoff || reachedBoundary || result.messages.length === 0) return
|
|
27871
|
+
if (!result.hasMore || crossedCutoff || reachedBoundary || result.messages.length === 0) return {
|
|
27834
27872
|
messages: partitioned.messages,
|
|
27835
|
-
overflow: []
|
|
27873
|
+
overflow: args.includeOverflow && partitioned.overflowReason === "tokens" ? partitioned.overflow : []
|
|
27836
27874
|
};
|
|
27837
|
-
if (oldestTimestamp === void 0) return
|
|
27875
|
+
if (oldestTimestamp === void 0) return {
|
|
27838
27876
|
messages: partitioned.messages,
|
|
27839
|
-
overflow: []
|
|
27877
|
+
overflow: args.includeOverflow && partitioned.overflowReason === "tokens" ? partitioned.overflow : []
|
|
27840
27878
|
};
|
|
27841
27879
|
if (end?.getTime() === oldestTimestamp && added === 0) page++;
|
|
27842
27880
|
else {
|
|
@@ -30331,19 +30369,24 @@ var ToolSearchProcessor = class {
|
|
|
30331
30369
|
});
|
|
30332
30370
|
}
|
|
30333
30371
|
async processInputStep(args) {
|
|
30334
|
-
const { tools, messageList } = args;
|
|
30372
|
+
const { tools, messageList, activeTools } = args;
|
|
30335
30373
|
const catalog = this.catalogForStep(tools);
|
|
30336
30374
|
const storeContext = this.makeStoreContext(args);
|
|
30337
30375
|
const loadedToolNames = await this.store.getLoadedNames(storeContext);
|
|
30338
30376
|
const autoLoad = this.searchConfig.autoLoad;
|
|
30339
|
-
|
|
30340
|
-
|
|
30377
|
+
const searchAvailable = !activeTools || activeTools.includes("search_tools");
|
|
30378
|
+
const loadAvailable = !autoLoad && (!activeTools || activeTools.includes("load_tool"));
|
|
30379
|
+
const instructionParts = [];
|
|
30380
|
+
if (searchAvailable) instructionParts.push(autoLoad ? "To discover available tools, call search_tools with a keyword query. Matching tools are loaded automatically and become available on your next turn \u2014 there is no separate load step. After searching, use the tool directly." : "To discover available tools, call search_tools with a keyword query.");
|
|
30381
|
+
if (loadAvailable) instructionParts.push("To add one or more tools to the conversation, call load_tool with a toolName or toolNames array. Tools must be loaded before they can be used.");
|
|
30382
|
+
if (instructionParts.length > 0) messageList.addSystem(instructionParts.join(" "));
|
|
30383
|
+
if (this.injectCatalog && (autoLoad ? searchAvailable : loadAvailable)) {
|
|
30341
30384
|
const catalogList = await this.formatCatalog(catalog, args.requestContext);
|
|
30342
|
-
if (catalogList) messageList.addSystem((autoLoad ? "The following tools are available. Call search_tools with a keyword to load one \u2014 matching tools are loaded automatically and become available on your next turn." : "The following tools are available to load. Call load_tool with a toolName or toolNames array to add one or more before using them \u2014 no search step is required. search_tools is also available if you need to rediscover tools by keyword.") + "\n\nAvailable tools:\n" + catalogList);
|
|
30385
|
+
if (catalogList) messageList.addSystem((autoLoad ? "The following tools are available. Call search_tools with a keyword to load one \u2014 matching tools are loaded automatically and become available on your next turn." : "The following tools are available to load. Call load_tool with a toolName or toolNames array to add one or more before using them \u2014 no search step is required." + (searchAvailable ? " search_tools is also available if you need to rediscover tools by keyword." : "")) + "\n\nAvailable tools:\n" + catalogList);
|
|
30343
30386
|
}
|
|
30344
30387
|
const searchTool = createTool({
|
|
30345
30388
|
id: "search_tools",
|
|
30346
|
-
description: autoLoad ? "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools, which are loaded automatically and become available on your next turn \u2014 no separate load step is required." : "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools with their names and descriptions. After finding a useful tool, use load_tool to make it available.",
|
|
30389
|
+
description: autoLoad ? "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools, which are loaded automatically and become available on your next turn \u2014 no separate load step is required." : "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools with their names and descriptions." + (loadAvailable ? " After finding a useful tool, use load_tool to make it available." : ""),
|
|
30347
30390
|
inputSchema: z.object({ query: z.string().describe("Search keywords (e.g., \"weather\", \"github issue\", \"database query\")") }),
|
|
30348
30391
|
outputSchema: z.object({
|
|
30349
30392
|
results: z.array(z.object({
|
|
@@ -30373,13 +30416,13 @@ var ToolSearchProcessor = class {
|
|
|
30373
30416
|
}
|
|
30374
30417
|
return {
|
|
30375
30418
|
results,
|
|
30376
|
-
message: `Found ${results.length} tool(s). Use load_tool with an exact toolName or a toolNames array to make them available.`
|
|
30419
|
+
message: loadAvailable ? `Found ${results.length} tool(s). Use load_tool with an exact toolName or a toolNames array to make them available.` : `Found ${results.length} tool(s): ${results.map((r) => r.name).join(", ")}.`
|
|
30377
30420
|
};
|
|
30378
30421
|
}
|
|
30379
30422
|
});
|
|
30380
30423
|
const loadTool = createTool({
|
|
30381
30424
|
id: "load_tool",
|
|
30382
|
-
description: "Load one or more tools into your context. Call this after finding tools with search_tools. Once loaded, tools will be available for use. Pass a single toolName or an array of toolNames to load multiple tools at once.",
|
|
30425
|
+
description: "Load one or more tools into your context. " + (searchAvailable ? "Call this after finding tools with search_tools. " : "") + "Once loaded, tools will be available for use. Pass a single toolName or an array of toolNames to load multiple tools at once.",
|
|
30383
30426
|
inputSchema: z.object({
|
|
30384
30427
|
toolName: z.string().optional().describe("The exact name of a tool to load (from search results)"),
|
|
30385
30428
|
toolNames: z.array(z.string()).optional().describe("Array of exact tool names to load in one call (from search results)")
|
|
@@ -30436,7 +30479,7 @@ var ToolSearchProcessor = class {
|
|
|
30436
30479
|
const suggestions = await this.getSuggestedToolNames(catalog, name, args.requestContext);
|
|
30437
30480
|
let message = `Tool "${name}" not found.`;
|
|
30438
30481
|
if (suggestions.length > 0) message += ` Did you mean: ${suggestions.slice(0, 3).join(", ")}?`;
|
|
30439
|
-
else message += " Use search_tools to find available tools.";
|
|
30482
|
+
else if (searchAvailable) message += " Use search_tools to find available tools.";
|
|
30440
30483
|
return {
|
|
30441
30484
|
success: false,
|
|
30442
30485
|
message,
|
|
@@ -30470,8 +30513,8 @@ var ToolSearchProcessor = class {
|
|
|
30470
30513
|
});
|
|
30471
30514
|
const loadedTools = await this.getLoadedTools(catalog, loadedToolNames, args.requestContext);
|
|
30472
30515
|
return { tools: {
|
|
30473
|
-
search_tools: searchTool,
|
|
30474
|
-
...
|
|
30516
|
+
...searchAvailable ? { search_tools: searchTool } : {},
|
|
30517
|
+
...loadAvailable ? { load_tool: loadTool } : {},
|
|
30475
30518
|
...this.includeResolvedTools ? unsearchableResolvedTools(tools) : tools ?? {},
|
|
30476
30519
|
...loadedTools
|
|
30477
30520
|
} };
|
|
@@ -30833,7 +30876,7 @@ var SkillSearchProcessor = class {
|
|
|
30833
30876
|
return this.cleanupStaleState();
|
|
30834
30877
|
}
|
|
30835
30878
|
async processInputStep(args) {
|
|
30836
|
-
const { tools, messageList } = args;
|
|
30879
|
+
const { tools, messageList, activeTools } = args;
|
|
30837
30880
|
const threadId = this.getThreadId(args);
|
|
30838
30881
|
const threadState = this.getThreadState(threadId);
|
|
30839
30882
|
const configuredSkills = this.skills;
|
|
@@ -30843,10 +30886,18 @@ var SkillSearchProcessor = class {
|
|
|
30843
30886
|
if (this.blockingRefresh) await skills.maybeRefresh({ requestContext: args.requestContext })?.catch(this.warnRefreshFailed);
|
|
30844
30887
|
else skills.maybeRefresh({ requestContext: args.requestContext })?.catch(this.warnRefreshFailed);
|
|
30845
30888
|
}
|
|
30846
|
-
|
|
30889
|
+
const searchAvailable = !activeTools || activeTools.includes("search_skills");
|
|
30890
|
+
const loadAvailable = !activeTools || activeTools.includes("load_skill");
|
|
30891
|
+
const instructionParts = [];
|
|
30892
|
+
if (searchAvailable) instructionParts.push("To discover available skills, call search_skills with a keyword query.");
|
|
30893
|
+
if (loadAvailable) instructionParts.push("To load a skill's instructions, call load_skill with the skill name.");
|
|
30894
|
+
if (instructionParts.length > 0) {
|
|
30895
|
+
instructionParts.push("Loaded skills provide context and instructions for the conversation.");
|
|
30896
|
+
messageList.addSystem(instructionParts.join(" "));
|
|
30897
|
+
}
|
|
30847
30898
|
const searchSkillTool = createTool({
|
|
30848
30899
|
id: "search_skills",
|
|
30849
|
-
description: "Search for available skills by keyword. Returns a list of matching skills with their names and descriptions. After finding a useful skill, use load_skill to load its instructions.",
|
|
30900
|
+
description: "Search for available skills by keyword. Returns a list of matching skills with their names and descriptions." + (loadAvailable ? " After finding a useful skill, use load_skill to load its instructions." : ""),
|
|
30850
30901
|
inputSchema: z.object({ query: z.string().trim().min(1, "Query is required").describe("Search keywords (e.g., \"api design\", \"testing\", \"deployment\")") }),
|
|
30851
30902
|
outputSchema: z.object({
|
|
30852
30903
|
results: z.array(z.object({
|
|
@@ -30883,13 +30934,13 @@ var SkillSearchProcessor = class {
|
|
|
30883
30934
|
});
|
|
30884
30935
|
return {
|
|
30885
30936
|
results,
|
|
30886
|
-
message: `Found ${results.length} skill(s). Use load_skill with the exact skill name to load its instructions.`
|
|
30937
|
+
message: loadAvailable ? `Found ${results.length} skill(s). Use load_skill with the exact skill name to load its instructions.` : `Found ${results.length} skill(s): ${results.map((r) => r.name).join(", ")}.`
|
|
30887
30938
|
};
|
|
30888
30939
|
}
|
|
30889
30940
|
});
|
|
30890
30941
|
const loadSkillTool = createTool({
|
|
30891
30942
|
id: "load_skill",
|
|
30892
|
-
description: "Load a skill's full instructions into the conversation. Call this after finding a skill with search_skills. The skill's instructions will be available as context.",
|
|
30943
|
+
description: "Load a skill's full instructions into the conversation. " + (searchAvailable ? "Call this after finding a skill with search_skills. " : "") + "The skill's instructions will be available as context.",
|
|
30893
30944
|
inputSchema: z.object({ skillName: z.string().describe("The exact name of the skill to load (from search results)") }),
|
|
30894
30945
|
outputSchema: z.object({
|
|
30895
30946
|
success: z.boolean(),
|
|
@@ -30907,7 +30958,7 @@ var SkillSearchProcessor = class {
|
|
|
30907
30958
|
const suggestions = (await skills.list()).filter((s) => s.name.toLowerCase().includes(skillName.toLowerCase()) || skillName.toLowerCase().includes(s.name.toLowerCase())).slice(0, 3);
|
|
30908
30959
|
let message = `Skill "${skillName}" not found.`;
|
|
30909
30960
|
if (suggestions.length > 0) message += ` Did you mean: ${suggestions.map((s) => s.name).join(", ")}?`;
|
|
30910
|
-
else message += " Use search_skills to find available skills.";
|
|
30961
|
+
else if (searchAvailable) message += " Use search_skills to find available skills.";
|
|
30911
30962
|
return {
|
|
30912
30963
|
success: false,
|
|
30913
30964
|
message
|
|
@@ -30923,8 +30974,8 @@ var SkillSearchProcessor = class {
|
|
|
30923
30974
|
});
|
|
30924
30975
|
for (const [skillName, instructions] of threadState.skills) messageList.addSystem(`[Skill: ${skillName}]\n\n${instructions}`);
|
|
30925
30976
|
const metaTools = {
|
|
30926
|
-
search_skills: searchSkillTool,
|
|
30927
|
-
load_skill: loadSkillTool
|
|
30977
|
+
...searchAvailable ? { search_skills: searchSkillTool } : {},
|
|
30978
|
+
...loadAvailable ? { load_skill: loadSkillTool } : {}
|
|
30928
30979
|
};
|
|
30929
30980
|
if (tools) {
|
|
30930
30981
|
for (const key of Object.keys(tools)) if (key in metaTools) console.warn(`[SkillSearchProcessor] User tool "${key}" conflicts with meta-tool and will be shadowed.`);
|
|
@@ -38723,6 +38774,7 @@ var ExperimentsInMemory = class extends ExperimentsStorage {
|
|
|
38723
38774
|
targetType: input.targetType ?? null,
|
|
38724
38775
|
targetId: input.targetId ?? null,
|
|
38725
38776
|
scorerIds: input.scorerIds ?? null,
|
|
38777
|
+
scorerVersions: input.scorerVersions ?? null,
|
|
38726
38778
|
name: input.name,
|
|
38727
38779
|
description: input.description,
|
|
38728
38780
|
metadata: input.metadata,
|
|
@@ -39144,6 +39196,29 @@ function knowledgePageKeyProblem(key) {
|
|
|
39144
39196
|
if (!key) return "Knowledge page key must not be empty";
|
|
39145
39197
|
if (/[/#%]/.test(key)) return `Knowledge page key "${key}" must not contain "/", "#" or "%"`;
|
|
39146
39198
|
}
|
|
39199
|
+
const isRowWrite = (write) => write.op === "create" || write.op === "update" || write.op === "move" || write.op === "delete";
|
|
39200
|
+
/**
|
|
39201
|
+
* Throws unless the batch holds `applyPageWrites`' first rule: at most one create, one move and one
|
|
39202
|
+
* delete per page, no create, update or move of a page the batch deletes, and at most one write
|
|
39203
|
+
* per note (stores apply note removals before additions, so two writes of one note can't keep
|
|
39204
|
+
* input order).
|
|
39205
|
+
*/
|
|
39206
|
+
function assertKnowledgePageWritesBatchable(writes) {
|
|
39207
|
+
const rows = /* @__PURE__ */ new Map();
|
|
39208
|
+
const notes = /* @__PURE__ */ new Map();
|
|
39209
|
+
for (const write of writes) {
|
|
39210
|
+
if (isRowWrite(write)) rows.set(write.id, [...rows.get(write.id) ?? [], write.op]);
|
|
39211
|
+
if ((write.op === "add-note" || write.op === "remove-note") && write.id !== void 0) {
|
|
39212
|
+
const seen = notes.get(write.id);
|
|
39213
|
+
if (seen !== void 0) throw new Error(`Knowledge page writes can't apply ${seen}, ${write.op} to note ${write.id} in one batch`);
|
|
39214
|
+
notes.set(write.id, write.op);
|
|
39215
|
+
}
|
|
39216
|
+
}
|
|
39217
|
+
for (const [id, ops] of rows) {
|
|
39218
|
+
const count = (op) => ops.filter((o) => o === op).length;
|
|
39219
|
+
if (count("create") > 1 || count("move") > 1 || count("delete") > 1 || count("delete") === 1 && ops.length > 1) throw new Error(`Knowledge page writes can't apply ${ops.join(", ")} to page ${id} in one batch`);
|
|
39220
|
+
}
|
|
39221
|
+
}
|
|
39147
39222
|
// src/storage/domains/knowledge/pages.ts
|
|
39148
39223
|
/**
|
|
39149
39224
|
* Knowledge storage contract, schema 4: pages, notes, stamps, mentions, body links and pins.
|
|
@@ -39629,6 +39704,31 @@ var KnowledgeStorage = class extends StorageDomain {
|
|
|
39629
39704
|
getPages(_input) {
|
|
39630
39705
|
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPages"));
|
|
39631
39706
|
}
|
|
39707
|
+
/**
|
|
39708
|
+
* The page `parentId` and its ancestors, nearest first: for each row what {@link getPage} would
|
|
39709
|
+
* return with the same `read`, deleted rows included. Stops after the first scope page, before
|
|
39710
|
+
* the first row `getPage` would return null for, or after {@link MAX_KNOWLEDGE_PAGE_DEPTH} + 1
|
|
39711
|
+
* rows. Lets a caller holding a page walk its parents in one call instead of one per level.
|
|
39712
|
+
*
|
|
39713
|
+
* The base class reads one {@link getPage} per level; adapters that can read the chain in one
|
|
39714
|
+
* query override it.
|
|
39715
|
+
*
|
|
39716
|
+
* @experimental
|
|
39717
|
+
*/
|
|
39718
|
+
async getPageParents(input) {
|
|
39719
|
+
const parents = [];
|
|
39720
|
+
let id = input.parentId;
|
|
39721
|
+
while (id && parents.length <= 10) {
|
|
39722
|
+
const page = await this.getPage({
|
|
39723
|
+
id,
|
|
39724
|
+
read: input.read
|
|
39725
|
+
});
|
|
39726
|
+
if (!page) break;
|
|
39727
|
+
parents.push(page);
|
|
39728
|
+
id = page.isScope ? null : page.parentId;
|
|
39729
|
+
}
|
|
39730
|
+
return parents;
|
|
39731
|
+
}
|
|
39632
39732
|
getPageByPath(_input) {
|
|
39633
39733
|
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPageByPath"));
|
|
39634
39734
|
}
|
|
@@ -39946,10 +40046,20 @@ var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage
|
|
|
39946
40046
|
const node = this.#s.nodes.get(key(bindingId, sourceId));
|
|
39947
40047
|
return node ? structuredClone(node) : null;
|
|
39948
40048
|
}
|
|
40049
|
+
async getNodes(bindingId, sourceIds) {
|
|
40050
|
+
return [...new Set(sourceIds)].flatMap((sourceId) => {
|
|
40051
|
+
const node = this.#s.nodes.get(key(bindingId, sourceId));
|
|
40052
|
+
return node ? [structuredClone(node)] : [];
|
|
40053
|
+
});
|
|
40054
|
+
}
|
|
39949
40055
|
async getNodeByPage(pageId) {
|
|
39950
40056
|
const node = [...this.#s.nodes.values()].find((n) => n.pageId === pageId);
|
|
39951
40057
|
return node ? structuredClone(node) : null;
|
|
39952
40058
|
}
|
|
40059
|
+
async getNodesByPages(pageIds) {
|
|
40060
|
+
const pages = new Set(pageIds);
|
|
40061
|
+
return [...this.#s.nodes.values()].filter((n) => pages.has(n.pageId)).map((n) => structuredClone(n));
|
|
40062
|
+
}
|
|
39953
40063
|
async saveNode(node) {
|
|
39954
40064
|
const owner = [...this.#s.nodes.values()].find((n) => n.pageId === node.pageId);
|
|
39955
40065
|
if (owner && (owner.bindingId !== node.bindingId || owner.sourceId !== node.sourceId)) throw new Error(`Knowledge page ${node.pageId} is already mapped to another imported node`);
|
|
@@ -39961,6 +40071,22 @@ var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage
|
|
|
39961
40071
|
async deleteNode(bindingId, sourceId) {
|
|
39962
40072
|
this.#s.nodes.delete(key(bindingId, sourceId));
|
|
39963
40073
|
}
|
|
40074
|
+
async writeNodes(input) {
|
|
40075
|
+
const next = new Map(this.#s.nodes);
|
|
40076
|
+
for (const d of input.deletes) next.delete(key(d.bindingId, d.sourceId));
|
|
40077
|
+
const updatedAt = /* @__PURE__ */ new Date();
|
|
40078
|
+
for (const node of input.saves) next.set(key(node.bindingId, node.sourceId), structuredClone({
|
|
40079
|
+
...node,
|
|
40080
|
+
updatedAt
|
|
40081
|
+
}));
|
|
40082
|
+
const byPage = /* @__PURE__ */ new Map();
|
|
40083
|
+
for (const [k, node] of next) {
|
|
40084
|
+
const other = byPage.get(node.pageId);
|
|
40085
|
+
if (other !== void 0 && other !== k) throw new Error(`Knowledge page ${node.pageId} is already mapped to another imported node`);
|
|
40086
|
+
byPage.set(node.pageId, k);
|
|
40087
|
+
}
|
|
40088
|
+
this.#s.nodes = next;
|
|
40089
|
+
}
|
|
39964
40090
|
async listNodes(bindingId, options = {}) {
|
|
39965
40091
|
const limit = options.limit ?? 500;
|
|
39966
40092
|
const nodes = [...this.#s.nodes.values()].filter((n) => n.bindingId === bindingId && (options.after === void 0 || byteOrder(n.sourceId, options.after) > 0) && (!options.unsettled || n.unsettled)).sort((a, b) => byteOrder(a.sourceId, b.sourceId));
|
|
@@ -40013,6 +40139,9 @@ var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage
|
|
|
40013
40139
|
change: structuredClone(change)
|
|
40014
40140
|
});
|
|
40015
40141
|
}
|
|
40142
|
+
async recordRunChanges(changes) {
|
|
40143
|
+
for (const change of changes) await this.recordRunChange(change);
|
|
40144
|
+
}
|
|
40016
40145
|
async listRunChanges(runId, options = {}) {
|
|
40017
40146
|
const limit = options.limit ?? 500;
|
|
40018
40147
|
const after = options.after === void 0 ? 0 : Number(options.after);
|
|
@@ -40336,6 +40465,15 @@ var InMemoryKnowledgePageStore = class {
|
|
|
40336
40465
|
const page = this.#pages.get(input.id);
|
|
40337
40466
|
return page && this.#pageReadable(page, input.read) ? clone$1(page) : null;
|
|
40338
40467
|
}
|
|
40468
|
+
async getPageParents(input) {
|
|
40469
|
+
const parents = [];
|
|
40470
|
+
let page = this.#pages.get(input.parentId);
|
|
40471
|
+
while (page && this.#pageReadable(page, input.read) && parents.length <= 10) {
|
|
40472
|
+
parents.push(clone$1(page));
|
|
40473
|
+
page = page.isScope || !page.parentId ? void 0 : this.#pages.get(page.parentId);
|
|
40474
|
+
}
|
|
40475
|
+
return parents;
|
|
40476
|
+
}
|
|
40339
40477
|
async getPages(input) {
|
|
40340
40478
|
return [...new Set(input.ids)].map((id) => this.#pages.get(id)).filter((page) => !!page && !page.deletedAt && this.#pageReadable(page, input.read)).map(clone$1);
|
|
40341
40479
|
}
|
|
@@ -40349,10 +40487,53 @@ var InMemoryKnowledgePageStore = class {
|
|
|
40349
40487
|
}
|
|
40350
40488
|
return page && this.#pageReadable(page, input.read) ? clone$1(page) : null;
|
|
40351
40489
|
}
|
|
40490
|
+
async getPageChains(input) {
|
|
40491
|
+
const ids = [...new Set(input.ids)];
|
|
40492
|
+
const chains = await Promise.all(ids.map((id) => this.getPageParents({
|
|
40493
|
+
parentId: id,
|
|
40494
|
+
read: input.read
|
|
40495
|
+
})));
|
|
40496
|
+
return Object.fromEntries(ids.map((id, i) => [id, chains[i]]));
|
|
40497
|
+
}
|
|
40498
|
+
async getPagesByPaths(input) {
|
|
40499
|
+
return Promise.all(input.paths.map((path) => this.getPageByPath({
|
|
40500
|
+
scopeId: input.scopeId,
|
|
40501
|
+
path,
|
|
40502
|
+
read: input.read
|
|
40503
|
+
})));
|
|
40504
|
+
}
|
|
40505
|
+
async getLastChildPositions(input) {
|
|
40506
|
+
return Object.fromEntries([...new Set(input.parentIds)].map((id) => [id, this.#children(id).sort(byPosition).at(-1)?.position ?? null]));
|
|
40507
|
+
}
|
|
40508
|
+
async getPageSubtrees(input) {
|
|
40509
|
+
const out = Object.fromEntries(input.rootIds.map((id) => [id, null]));
|
|
40510
|
+
for (const rootId of new Set(input.rootIds)) {
|
|
40511
|
+
const pages = [];
|
|
40512
|
+
for (let i = -1; i < pages.length && pages.length <= input.limit; i++) {
|
|
40513
|
+
const parentId = i < 0 ? rootId : pages[i].id;
|
|
40514
|
+
pages.push(...this.#children(parentId).filter((page) => !page.isScope));
|
|
40515
|
+
}
|
|
40516
|
+
out[rootId] = pages.length > input.limit ? null : pages.map(clone$1);
|
|
40517
|
+
}
|
|
40518
|
+
return out;
|
|
40519
|
+
}
|
|
40520
|
+
async listNotesByPages(input) {
|
|
40521
|
+
const notes = Object.fromEntries([...new Set(input.pageIds)].map((id) => [id, []]));
|
|
40522
|
+
for (const note of [...this.#notes.values()].sort(oldestFirst)) if (Object.hasOwn(notes, note.pageId) && !note.deletedAt && this.#noteVisible(note, input.read)) notes[note.pageId].push(clone$1(note));
|
|
40523
|
+
return notes;
|
|
40524
|
+
}
|
|
40352
40525
|
async findPagesByName(input) {
|
|
40353
40526
|
const name = canonicalKnowledgeName(input.name);
|
|
40354
40527
|
return [...this.#pages.values()].filter((page) => !page.deletedAt && canonicalKnowledgeName(page.name) === name && (input.scopeId === void 0 || page.scopeId === input.scopeId) && this.#pageReadable(page, input.read)).sort(newestFirst).slice(0, pageSize(input.limit)).map(clone$1);
|
|
40355
40528
|
}
|
|
40529
|
+
async findPagesByNames(input) {
|
|
40530
|
+
const names = [...new Set(input.names)];
|
|
40531
|
+
const found = await Promise.all(names.map((name) => this.findPagesByName({
|
|
40532
|
+
...input,
|
|
40533
|
+
name
|
|
40534
|
+
})));
|
|
40535
|
+
return Object.fromEntries(names.map((name, i) => [name, found[i]]));
|
|
40536
|
+
}
|
|
40356
40537
|
async listChildPages(input) {
|
|
40357
40538
|
const { items, nextCursor } = paginate(this.#children(input.parentId).filter((page) => !page.isScope && this.#pageReadable(page, input.read)).sort(byPosition), input.cursor, input.limit);
|
|
40358
40539
|
return {
|
|
@@ -40448,6 +40629,63 @@ var InMemoryKnowledgePageStore = class {
|
|
|
40448
40629
|
...nextCursor ? { nextCursor } : {}
|
|
40449
40630
|
};
|
|
40450
40631
|
}
|
|
40632
|
+
/** The single writes, one by one in input order; all undone if one fails. */
|
|
40633
|
+
async applyPageWrites(input) {
|
|
40634
|
+
assertKnowledgePageWritesBatchable(input.writes);
|
|
40635
|
+
const before = this.snapshot();
|
|
40636
|
+
try {
|
|
40637
|
+
for (const write of input.writes) switch (write.op) {
|
|
40638
|
+
case "create": {
|
|
40639
|
+
const { op: _op, scopeId: _scope, depth: _depth, ...create } = write;
|
|
40640
|
+
await this.createPage(create);
|
|
40641
|
+
break;
|
|
40642
|
+
}
|
|
40643
|
+
case "update": {
|
|
40644
|
+
const { op: _op, scopeId: _scope, ...update } = write;
|
|
40645
|
+
await this.updatePage(update);
|
|
40646
|
+
break;
|
|
40647
|
+
}
|
|
40648
|
+
case "move": {
|
|
40649
|
+
const { op: _op, scopeId: _scope, fromScopeId: _from, depth: _depth, ...move } = write;
|
|
40650
|
+
await this.movePage(move);
|
|
40651
|
+
break;
|
|
40652
|
+
}
|
|
40653
|
+
case "delete":
|
|
40654
|
+
await this.deletePage({
|
|
40655
|
+
id: write.id,
|
|
40656
|
+
expectedVersion: write.expectedVersion,
|
|
40657
|
+
deletedBy: write.deletedBy
|
|
40658
|
+
});
|
|
40659
|
+
break;
|
|
40660
|
+
case "add-note": {
|
|
40661
|
+
const { op: _op, scopeId: _scope, ...note } = write;
|
|
40662
|
+
await this.addNote(note);
|
|
40663
|
+
break;
|
|
40664
|
+
}
|
|
40665
|
+
case "remove-note": {
|
|
40666
|
+
const note = await this.getNote({
|
|
40667
|
+
id: write.id,
|
|
40668
|
+
read: "all",
|
|
40669
|
+
includeDeleted: true
|
|
40670
|
+
});
|
|
40671
|
+
if (note && note.pageId !== write.pageId) throw new KnowledgeConflictError(write.id);
|
|
40672
|
+
await this.removeNote({
|
|
40673
|
+
id: write.id,
|
|
40674
|
+
deletedBy: write.deletedBy,
|
|
40675
|
+
provenance: write.provenance
|
|
40676
|
+
});
|
|
40677
|
+
break;
|
|
40678
|
+
}
|
|
40679
|
+
case "replace-links": await this.replacePageBodyLinks({
|
|
40680
|
+
pageId: write.pageId,
|
|
40681
|
+
links: write.links
|
|
40682
|
+
});
|
|
40683
|
+
}
|
|
40684
|
+
} catch (error) {
|
|
40685
|
+
this.restore(before);
|
|
40686
|
+
throw error;
|
|
40687
|
+
}
|
|
40688
|
+
}
|
|
40451
40689
|
async createPage(input) {
|
|
40452
40690
|
const parent = this.#livePage(input.parentId);
|
|
40453
40691
|
const scopeId = parent.isScope ? parent.id : parent.scopeId;
|
|
@@ -40843,6 +41081,27 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
|
|
|
40843
41081
|
getPage(input) {
|
|
40844
41082
|
return this.#pageStore.getPage(input);
|
|
40845
41083
|
}
|
|
41084
|
+
getPageParents(input) {
|
|
41085
|
+
return this.#pageStore.getPageParents(input);
|
|
41086
|
+
}
|
|
41087
|
+
getPageChains(input) {
|
|
41088
|
+
return this.#pageStore.getPageChains(input);
|
|
41089
|
+
}
|
|
41090
|
+
getPagesByPaths(input) {
|
|
41091
|
+
return this.#pageStore.getPagesByPaths(input);
|
|
41092
|
+
}
|
|
41093
|
+
getLastChildPositions(input) {
|
|
41094
|
+
return this.#pageStore.getLastChildPositions(input);
|
|
41095
|
+
}
|
|
41096
|
+
getPageSubtrees(input) {
|
|
41097
|
+
return this.#pageStore.getPageSubtrees(input);
|
|
41098
|
+
}
|
|
41099
|
+
listNotesByPages(input) {
|
|
41100
|
+
return this.#pageStore.listNotesByPages(input);
|
|
41101
|
+
}
|
|
41102
|
+
applyPageWrites(input) {
|
|
41103
|
+
return this.#pageStore.applyPageWrites(input);
|
|
41104
|
+
}
|
|
40846
41105
|
listScopeDeclarations() {
|
|
40847
41106
|
return this.#pageStore.listScopeDeclarations();
|
|
40848
41107
|
}
|
|
@@ -40855,6 +41114,9 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
|
|
|
40855
41114
|
getPageByPath(input) {
|
|
40856
41115
|
return this.#pageStore.getPageByPath(input);
|
|
40857
41116
|
}
|
|
41117
|
+
findPagesByNames(input) {
|
|
41118
|
+
return this.#pageStore.findPagesByNames(input);
|
|
41119
|
+
}
|
|
40858
41120
|
findPagesByName(input) {
|
|
40859
41121
|
return this.#pageStore.findPagesByName(input);
|
|
40860
41122
|
}
|
|
@@ -47884,6 +48146,32 @@ function chunkToFallbackMessage(chunk) {
|
|
|
47884
48146
|
if (chunk.type === "plan_update") return chunk.title && chunk.title.length > 0 ? chunk.title : null;
|
|
47885
48147
|
return null;
|
|
47886
48148
|
}
|
|
48149
|
+
/** Whitespace plus the meaningful joiners ZWNJ (U+200C) and ZWJ (U+200D). */
|
|
48150
|
+
const EDGE_PADDING = /[\s\u200C\u200D]/;
|
|
48151
|
+
/**
|
|
48152
|
+
* Sanitize a buffered channel reply before posting.
|
|
48153
|
+
*
|
|
48154
|
+
* Zero-width space (U+200B) and the byte-order mark (U+FEFF) are invisible
|
|
48155
|
+
* padding and are removed everywhere. Whitespace and the joiners ZWNJ
|
|
48156
|
+
* (U+200C) / ZWJ (U+200D) are trimmed only at the edges, so internal joiners
|
|
48157
|
+
* in compound emoji (🏄🏼♂️, 👨👩👧) and scripts such as Persian (میخواهم)
|
|
48158
|
+
* survive — the bug behind #31205. Invisible-only input collapses to '' so
|
|
48159
|
+
* callers skip posting it entirely.
|
|
48160
|
+
*
|
|
48161
|
+
* The edge trim is a single-pass scan rather than
|
|
48162
|
+
* `.replace(/^[\s\u200C\u200D]+|[\s\u200C\u200D]+$/g, '')`: that anchored
|
|
48163
|
+
* alternation backtracks quadratically over a long interior run of the class
|
|
48164
|
+
* (a 300k-character run of model-controlled output took ~80s), while this
|
|
48165
|
+
* scan is O(n).
|
|
48166
|
+
*/
|
|
48167
|
+
function cleanBufferedText(input) {
|
|
48168
|
+
const stripped = input.replace(/[\u200B\uFEFF]/g, "");
|
|
48169
|
+
let start = 0;
|
|
48170
|
+
let end = stripped.length;
|
|
48171
|
+
while (start < end && EDGE_PADDING.test(stripped.charAt(start))) start++;
|
|
48172
|
+
while (end > start && EDGE_PADDING.test(stripped.charAt(end - 1))) end--;
|
|
48173
|
+
return start === 0 && end === stripped.length ? stripped : stripped.slice(start, end);
|
|
48174
|
+
}
|
|
47887
48175
|
// src/channels/chat-driver-static.ts
|
|
47888
48176
|
/**
|
|
47889
48177
|
* Static (non-streaming) driver: consumes `AgentChunkType<any>` chunks and
|
|
@@ -47928,7 +48216,7 @@ async function runStaticDriver({ stream, chatThread, adapter, toolDisplay, toolD
|
|
|
47928
48216
|
let textBuffer = "";
|
|
47929
48217
|
const toolMessageIds = /* @__PURE__ */ new Map();
|
|
47930
48218
|
const flushText = async () => {
|
|
47931
|
-
const cleaned = textBuffer
|
|
48219
|
+
const cleaned = cleanBufferedText(textBuffer);
|
|
47932
48220
|
if (cleaned) try {
|
|
47933
48221
|
await chatThread.post(textFormat === "plain" ? cleaned : { markdown: cleaned });
|
|
47934
48222
|
} catch (e) {
|
|
@@ -48263,7 +48551,7 @@ async function runStreamingDriver({ stream, chatThread, adapter, toolDisplay, to
|
|
|
48263
48551
|
if (closed) break;
|
|
48264
48552
|
await waitForNext();
|
|
48265
48553
|
}
|
|
48266
|
-
const cleaned = fallback
|
|
48554
|
+
const cleaned = cleanBufferedText(fallback);
|
|
48267
48555
|
if (cleaned) try {
|
|
48268
48556
|
await chatThread.post(textFormat === "plain" ? cleaned : { markdown: cleaned });
|
|
48269
48557
|
} catch (postErr) {
|
|
@@ -48746,6 +49034,20 @@ const TEXT_CHUNK_TYPES = /* @__PURE__ */ new Set([
|
|
|
48746
49034
|
/** Key the processor reads off `requestContext` to locate its render deps. */
|
|
48747
49035
|
const CHAT_CHANNEL_RENDER_CONTEXT_KEY = "__mastra_chat_channel_render";
|
|
48748
49036
|
/**
|
|
49037
|
+
* Whether a `requestContext` entry is a live render context rather than the
|
|
49038
|
+
* method-less husk a JSON snapshot round-trip leaves behind (issue #31310).
|
|
49039
|
+
* `wrapStream` is the first method the session calls, so its presence is the
|
|
49040
|
+
* signal that the object is usable.
|
|
49041
|
+
*
|
|
49042
|
+
* Every reader that treats a stashed render context as a live object (the
|
|
49043
|
+
* output processor, `resolveChannelRenderContext`, `AgentChannels.resolveRunRender`
|
|
49044
|
+
* and the generative-UI processor) guards with this, so a husk on a replica's
|
|
49045
|
+
* restored `requestContext` always falls through to a rebuild from the thread.
|
|
49046
|
+
*/
|
|
49047
|
+
function isUsableRenderContext(value) {
|
|
49048
|
+
return typeof value === "object" && value !== null && typeof value.wrapStream === "function";
|
|
49049
|
+
}
|
|
49050
|
+
/**
|
|
48749
49051
|
* Single-producer / single-consumer async queue. The processor pushes chunks
|
|
48750
49052
|
* synchronously from `processOutputStream`; the driver consumes them via the
|
|
48751
49053
|
* async iterable. `close()` ends the iteration after pending items are drained.
|
|
@@ -48879,7 +49181,7 @@ var ChatChannelOutputProcessor = class {
|
|
|
48879
49181
|
async #resolveRenderContext(state, requestContext) {
|
|
48880
49182
|
if (state.render !== void 0) return state.render;
|
|
48881
49183
|
const fromRequest = requestContext?.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
48882
|
-
if (fromRequest) {
|
|
49184
|
+
if (isUsableRenderContext(fromRequest)) {
|
|
48883
49185
|
state.render = fromRequest;
|
|
48884
49186
|
return fromRequest;
|
|
48885
49187
|
}
|
|
@@ -49052,7 +49354,7 @@ var ChatChannelGenerativeUIProcessor = class {
|
|
|
49052
49354
|
}
|
|
49053
49355
|
async #resolve(requestContext, state) {
|
|
49054
49356
|
const inbound = requestContext?.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
49055
|
-
if (inbound) return inbound;
|
|
49357
|
+
if (isUsableRenderContext(inbound)) return inbound;
|
|
49056
49358
|
if (state && "render" in state) return state.render ?? void 0;
|
|
49057
49359
|
const threadId = parseMemoryRequestContext(requestContext)?.thread?.id;
|
|
49058
49360
|
const render = threadId && this.#channels ? await this.#channels.buildRenderContextForThread(threadId) : null;
|
|
@@ -49206,6 +49508,8 @@ async function headContentType(url, logger) {
|
|
|
49206
49508
|
}
|
|
49207
49509
|
}
|
|
49208
49510
|
// src/channels/processor.ts
|
|
49511
|
+
/** Per-run `state` key caching a thread's display mode recovered without a render context. */
|
|
49512
|
+
const RECOVERED_DISPLAY_KEY = "threadTextHidden";
|
|
49209
49513
|
/**
|
|
49210
49514
|
* Input processor that injects channel context (platform, bot identity, DM vs.
|
|
49211
49515
|
* public-channel guidance) into the agent's system prompt on every step.
|
|
@@ -49239,19 +49543,37 @@ var ChatChannelProcessor = class {
|
|
|
49239
49543
|
}
|
|
49240
49544
|
async #resolve(requestContext, state) {
|
|
49241
49545
|
const channel = requestContext?.get("channel");
|
|
49242
|
-
if (channel)
|
|
49243
|
-
|
|
49244
|
-
|
|
49245
|
-
|
|
49546
|
+
if (channel) {
|
|
49547
|
+
const render = requestContext?.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
49548
|
+
return {
|
|
49549
|
+
channel,
|
|
49550
|
+
textHidden: isUsableRenderContext(render) ? render.textDisplay === "hidden" : await this.#recoverTextHidden(requestContext, state)
|
|
49551
|
+
};
|
|
49552
|
+
}
|
|
49246
49553
|
if (state && "thread" in state) return state.thread ?? void 0;
|
|
49554
|
+
const resolved = await this.#resolveThread(requestContext);
|
|
49555
|
+
if (state) state.thread = resolved;
|
|
49556
|
+
return resolved ?? void 0;
|
|
49557
|
+
}
|
|
49558
|
+
/** The channel-backed context of the run's memory thread, or `null` when it has none. */
|
|
49559
|
+
async #resolveThread(requestContext) {
|
|
49247
49560
|
const threadId = parseMemoryRequestContext(requestContext)?.thread?.id;
|
|
49248
49561
|
const found = threadId && this.#channels ? await this.#channels.buildChannelContextForThread(threadId) : null;
|
|
49249
|
-
|
|
49562
|
+
return found ? {
|
|
49250
49563
|
channel: found.channel,
|
|
49251
49564
|
textHidden: found.render.textDisplay === "hidden"
|
|
49252
49565
|
} : null;
|
|
49253
|
-
|
|
49254
|
-
|
|
49566
|
+
}
|
|
49567
|
+
/**
|
|
49568
|
+
* Display mode of a channel-backed thread whose render context is no longer on the
|
|
49569
|
+
* restored request context. Cached per run like the thread lookup above, so later
|
|
49570
|
+
* steps of the same run read the thread once.
|
|
49571
|
+
*/
|
|
49572
|
+
async #recoverTextHidden(requestContext, state) {
|
|
49573
|
+
if (state && RECOVERED_DISPLAY_KEY in state) return state[RECOVERED_DISPLAY_KEY] === true;
|
|
49574
|
+
const textHidden = (await this.#resolveThread(requestContext))?.textHidden ?? false;
|
|
49575
|
+
if (state) state[RECOVERED_DISPLAY_KEY] = textHidden;
|
|
49576
|
+
return textHidden;
|
|
49255
49577
|
}
|
|
49256
49578
|
};
|
|
49257
49579
|
function channelLines(ctx, textHidden, tools) {
|
|
@@ -49774,15 +50096,17 @@ var ChannelReplyModeProcessor = class {
|
|
|
49774
50096
|
var MastraStateAdapter = class {
|
|
49775
50097
|
memoryStore;
|
|
49776
50098
|
getOwnerId;
|
|
50099
|
+
logger;
|
|
49777
50100
|
connected = false;
|
|
49778
50101
|
connectPromise = null;
|
|
49779
50102
|
cache = /* @__PURE__ */ new Map();
|
|
49780
50103
|
locks = /* @__PURE__ */ new Map();
|
|
49781
50104
|
lists = /* @__PURE__ */ new Map();
|
|
49782
50105
|
queues = /* @__PURE__ */ new Map();
|
|
49783
|
-
constructor(memoryStore, getOwnerId) {
|
|
50106
|
+
constructor(memoryStore, getOwnerId, logger) {
|
|
49784
50107
|
this.memoryStore = memoryStore;
|
|
49785
50108
|
this.getOwnerId = getOwnerId;
|
|
50109
|
+
this.logger = logger;
|
|
49786
50110
|
}
|
|
49787
50111
|
async connect() {
|
|
49788
50112
|
if (this.connected) return;
|
|
@@ -49801,7 +50125,10 @@ var MastraStateAdapter = class {
|
|
|
49801
50125
|
}
|
|
49802
50126
|
async subscribe(threadId) {
|
|
49803
50127
|
const thread = await this.findThreadByExternalId(threadId);
|
|
49804
|
-
if (!thread)
|
|
50128
|
+
if (!thread) {
|
|
50129
|
+
this.logger?.warn(`subscribe(${threadId}) ignored: no Mastra thread is mapped to this chat thread. Use AgentChannels.subscribeThread() for threads the bot started itself.`);
|
|
50130
|
+
return;
|
|
50131
|
+
}
|
|
49805
50132
|
await this.memoryStore.patchThread({
|
|
49806
50133
|
id: thread.id,
|
|
49807
50134
|
metadata: {
|
|
@@ -50193,7 +50520,7 @@ function formatLegacyHistoryBlock(history, chatThread, platform) {
|
|
|
50193
50520
|
async function resolveChannelRenderContext(requestContext, channels) {
|
|
50194
50521
|
if (!requestContext) return void 0;
|
|
50195
50522
|
const stashed = requestContext.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
50196
|
-
if (stashed) return stashed;
|
|
50523
|
+
if (isUsableRenderContext(stashed)) return stashed;
|
|
50197
50524
|
const threadId = requestContext.get("controller")?.threadId ?? parseMemoryRequestContext(requestContext)?.thread?.id;
|
|
50198
50525
|
if (!threadId) return void 0;
|
|
50199
50526
|
return await channels?.()?.buildRenderContextForThread(threadId) ?? void 0;
|
|
@@ -50637,7 +50964,7 @@ var AgentChannels = class {
|
|
|
50637
50964
|
const storage = mastra.getStorage();
|
|
50638
50965
|
const memoryStore = storage ? await storage.getStore("memory") : void 0;
|
|
50639
50966
|
if (!memoryStore) throw new Error("Channels require storage to be configured on the Mastra instance. Configure a storage provider like LibSQLStore.");
|
|
50640
|
-
this.stateAdapter = new MastraStateAdapter(memoryStore, () => this.getOwnerId());
|
|
50967
|
+
this.stateAdapter = new MastraStateAdapter(memoryStore, () => this.getOwnerId(), this.logger);
|
|
50641
50968
|
this.log("info", "Using MastraStateAdapter (subscriptions persist across restarts)");
|
|
50642
50969
|
}
|
|
50643
50970
|
const { Chat, Message: ChatMessage, ThreadImpl } = await getChatModule();
|
|
@@ -50865,25 +51192,30 @@ var AgentChannels = class {
|
|
|
50865
51192
|
runId = stashed.runId;
|
|
50866
51193
|
toolName = stashed.toolName;
|
|
50867
51194
|
toolArgs = stashed.args;
|
|
50868
|
-
}
|
|
51195
|
+
}
|
|
51196
|
+
if (!requesterId) {
|
|
50869
51197
|
const { result: lookup } = await this.lookupPersistedApproval({
|
|
50870
51198
|
mastra,
|
|
50871
51199
|
card,
|
|
50872
51200
|
platform
|
|
50873
51201
|
});
|
|
50874
|
-
if (
|
|
50875
|
-
|
|
50876
|
-
|
|
51202
|
+
if (!stashed?.runId) {
|
|
51203
|
+
if (lookup.status === "answered") {
|
|
51204
|
+
this.log("info", "Tool approval already answered", actionEventContext);
|
|
51205
|
+
return;
|
|
51206
|
+
}
|
|
51207
|
+
if (lookup.status === "pending") {
|
|
51208
|
+
runId = lookup.runId;
|
|
51209
|
+
toolName = lookup.toolName;
|
|
51210
|
+
toolArgs = lookup.args;
|
|
51211
|
+
}
|
|
50877
51212
|
}
|
|
50878
51213
|
if (lookup.status === "pending") {
|
|
50879
|
-
|
|
50880
|
-
toolName = lookup.toolName;
|
|
50881
|
-
toolArgs = lookup.args;
|
|
50882
|
-
if (adapterConfig?.toolApprovers !== "anyone" && !requesterId && lookup.authors.length > 1) {
|
|
51214
|
+
if (adapterConfig?.toolApprovers !== "anyone" && lookup.authors.length > 1) {
|
|
50883
51215
|
this.log("info", "Ignoring tool approval action: requester is ambiguous", actionEventContext);
|
|
50884
51216
|
return;
|
|
50885
51217
|
}
|
|
50886
|
-
requesterId
|
|
51218
|
+
requesterId = lookup.authors[0];
|
|
50887
51219
|
}
|
|
50888
51220
|
}
|
|
50889
51221
|
if (!runId) {
|
|
@@ -51188,7 +51520,7 @@ var AgentChannels = class {
|
|
|
51188
51520
|
*/
|
|
51189
51521
|
async resolveRunRender(requestContext, state) {
|
|
51190
51522
|
const inbound = requestContext?.get(CHAT_CHANNEL_RENDER_CONTEXT_KEY);
|
|
51191
|
-
if (inbound) return inbound;
|
|
51523
|
+
if (isUsableRenderContext(inbound)) return inbound;
|
|
51192
51524
|
if (state && "render" in state) return state.render ?? void 0;
|
|
51193
51525
|
const render = await resolveChannelRenderContext(requestContext, () => this);
|
|
51194
51526
|
if (state) state.render = render ?? null;
|
|
@@ -51217,8 +51549,8 @@ var AgentChannels = class {
|
|
|
51217
51549
|
const has = (id) => configuredProcessors.some((p) => !isProcessorWorkflow(p) && p.id === id);
|
|
51218
51550
|
const processors = [];
|
|
51219
51551
|
if (Object.values(this.adapterConfigs).some((cfg) => cfg.threadLink) && !has(THREAD_LINK_PROCESSOR_ID)) processors.push(new ChannelThreadLinkProcessor((requestContext) => {
|
|
51220
|
-
const
|
|
51221
|
-
return
|
|
51552
|
+
const platform = requestContext.get("channel")?.platform ?? requestContext.get("__mastra_chat_channel_render")?.platform;
|
|
51553
|
+
return platform ? threadLinkOptions(this.adapterConfigs[platform]?.threadLink) : void 0;
|
|
51222
51554
|
}));
|
|
51223
51555
|
if (!has("chat-channel-render")) processors.push(new ChatChannelOutputProcessor(this));
|
|
51224
51556
|
if (this.replyModeEnabled && !has(REPLY_STREAM_PROCESSOR_ID)) processors.push(new ChannelReplyStreamProcessor((requestContext) => this.resolveRunRender(requestContext)));
|
|
@@ -52400,6 +52732,36 @@ var AgentChannels = class {
|
|
|
52400
52732
|
};
|
|
52401
52733
|
}
|
|
52402
52734
|
/**
|
|
52735
|
+
* Map a chat thread to a Mastra thread (creating the mapping if needed) and
|
|
52736
|
+
* subscribe to it, so follow-up replies reach the agent without a mention.
|
|
52737
|
+
*
|
|
52738
|
+
* Use this for threads the bot started itself, e.g. a scheduled digest posted
|
|
52739
|
+
* to Slack. Inbound messages create the mapping automatically, but a thread
|
|
52740
|
+
* the bot opened has none until someone mentions it. An existing mapping is
|
|
52741
|
+
* reused and keeps its original owner.
|
|
52742
|
+
*
|
|
52743
|
+
* @example
|
|
52744
|
+
* ```ts
|
|
52745
|
+
* const sent = await channel.post('Daily digest');
|
|
52746
|
+
* await agent.getChannels()!.subscribeThread({ thread: sent.thread, resourceId: 'digest-bot' });
|
|
52747
|
+
* ```
|
|
52748
|
+
*/
|
|
52749
|
+
async subscribeThread({ thread, resourceId, threadId }) {
|
|
52750
|
+
const mastra = this.getMastra();
|
|
52751
|
+
if (!mastra) throw new Error("subscribeThread requires the agent to be registered with a Mastra instance.");
|
|
52752
|
+
await this.initialize(mastra);
|
|
52753
|
+
const mastraThread = await this.getOrCreateThread({
|
|
52754
|
+
externalThreadId: thread.id,
|
|
52755
|
+
channelId: thread.channelId,
|
|
52756
|
+
platform: thread.adapter.name,
|
|
52757
|
+
resourceId,
|
|
52758
|
+
threadId: threadId ? () => threadId : void 0,
|
|
52759
|
+
mastra
|
|
52760
|
+
});
|
|
52761
|
+
await this.stateAdapter.subscribe(thread.id);
|
|
52762
|
+
return mastraThread;
|
|
52763
|
+
}
|
|
52764
|
+
/**
|
|
52403
52765
|
* Resolves an existing Mastra thread for the given external IDs, or creates one.
|
|
52404
52766
|
*/
|
|
52405
52767
|
async getOrCreateThread({ externalThreadId, channelId, platform, resourceId, threadId, onCreate, mastra }) {
|
|
@@ -52627,6 +52989,132 @@ function withReplyModeDefaults(cfg) {
|
|
|
52627
52989
|
...set
|
|
52628
52990
|
};
|
|
52629
52991
|
}
|
|
52992
|
+
// src/knowledge/held-scopes-state-processor.ts
|
|
52993
|
+
const HELD_SCOPES_STATE_ID = "knowledge-scopes";
|
|
52994
|
+
const HELD_SCOPES_SNAPSHOT_TAG = "knowledge-scopes";
|
|
52995
|
+
const HELD_SCOPES_DELTA_TAG = "knowledge-scopes-update";
|
|
52996
|
+
function lp$1(value) {
|
|
52997
|
+
return `${value.length}:${value}`;
|
|
52998
|
+
}
|
|
52999
|
+
function fingerprint$1(scope) {
|
|
53000
|
+
return `${lp$1(scope.address)}${lp$1(scope.role)}`;
|
|
53001
|
+
}
|
|
53002
|
+
function cacheKey(scopes) {
|
|
53003
|
+
return `scopes:${scopes.map(fingerprint$1).join("|")}`;
|
|
53004
|
+
}
|
|
53005
|
+
function scopesFromSnapshot(snapshot) {
|
|
53006
|
+
const value = (snapshot?.metadata)?.value?.scopes;
|
|
53007
|
+
return Array.isArray(value) ? value : [];
|
|
53008
|
+
}
|
|
53009
|
+
function opsFromDelta(delta) {
|
|
53010
|
+
const ops = delta.metadata?.delta?.ops;
|
|
53011
|
+
return Array.isArray(ops) ? ops : [];
|
|
53012
|
+
}
|
|
53013
|
+
function applyOps(scopes, ops) {
|
|
53014
|
+
const next = scopes.slice();
|
|
53015
|
+
for (const op of ops) {
|
|
53016
|
+
const address = op.op === "remove" ? op.address : op.scope.address;
|
|
53017
|
+
const idx = next.findIndex((scope) => scope.address === address);
|
|
53018
|
+
if (op.op === "remove") {
|
|
53019
|
+
if (idx >= 0) next.splice(idx, 1);
|
|
53020
|
+
} else if (idx >= 0) next[idx] = op.scope;
|
|
53021
|
+
else next.push(op.scope);
|
|
53022
|
+
}
|
|
53023
|
+
return next;
|
|
53024
|
+
}
|
|
53025
|
+
function diffScopes(prior, current) {
|
|
53026
|
+
const ops = [];
|
|
53027
|
+
const before = new Map(prior.map((scope) => [scope.address, fingerprint$1(scope)]));
|
|
53028
|
+
const currentAddresses = new Set(current.map((scope) => scope.address));
|
|
53029
|
+
for (const scope of prior) if (!currentAddresses.has(scope.address)) ops.push({
|
|
53030
|
+
op: "remove",
|
|
53031
|
+
address: scope.address
|
|
53032
|
+
});
|
|
53033
|
+
for (const scope of current) {
|
|
53034
|
+
const was = before.get(scope.address);
|
|
53035
|
+
if (was === void 0) ops.push({
|
|
53036
|
+
op: "add",
|
|
53037
|
+
scope
|
|
53038
|
+
});
|
|
53039
|
+
else if (was !== fingerprint$1(scope)) ops.push({
|
|
53040
|
+
op: "change",
|
|
53041
|
+
scope
|
|
53042
|
+
});
|
|
53043
|
+
}
|
|
53044
|
+
return ops;
|
|
53045
|
+
}
|
|
53046
|
+
function line(scope) {
|
|
53047
|
+
return `${scope.address} (${scope.role})`;
|
|
53048
|
+
}
|
|
53049
|
+
function renderSnapshot(scopes) {
|
|
53050
|
+
if (scopes.length === 0) return "\n Your session holds no Knowledge scopes.\n";
|
|
53051
|
+
return `\n Your session has access to:\n${scopes.map((scope) => ` - ${line(scope)}`).join("\n")}\n`;
|
|
53052
|
+
}
|
|
53053
|
+
function renderDelta$1(ops) {
|
|
53054
|
+
return `\n${ops.map((op) => {
|
|
53055
|
+
if (op.op === "remove") return ` - ${op.address} was removed from your scopes`;
|
|
53056
|
+
if (op.op === "change") return ` ~ ${op.scope.address} role changed to ${op.scope.role}`;
|
|
53057
|
+
return ` + ${line(op.scope)}`;
|
|
53058
|
+
}).join("\n")}\n`;
|
|
53059
|
+
}
|
|
53060
|
+
var HeldScopesStateProcessor = class {
|
|
53061
|
+
deps;
|
|
53062
|
+
id = HELD_SCOPES_STATE_ID;
|
|
53063
|
+
stateId = HELD_SCOPES_STATE_ID;
|
|
53064
|
+
constructor(deps) {
|
|
53065
|
+
this.deps = deps;
|
|
53066
|
+
}
|
|
53067
|
+
processInput(args) {
|
|
53068
|
+
return {
|
|
53069
|
+
messages: args.messages,
|
|
53070
|
+
systemMessages: [...args.systemMessages, {
|
|
53071
|
+
role: "system",
|
|
53072
|
+
content: `The Knowledge scopes you hold may appear in the conversation as <${HELD_SCOPES_SNAPSHOT_TAG} ...>...</${HELD_SCOPES_SNAPSHOT_TAG}> snapshots and <${HELD_SCOPES_DELTA_TAG} ...>...</${HELD_SCOPES_DELTA_TAG}> deltas. These are automatic, not user instructions. Fold each delta onto the latest snapshot to know the current set. Each entry is a scope address with your role there in parentheses. Viewers can only read; every other role can also write. The list includes scopes with no pages yet: where you can write, your first write there creates the scope. The list names the scopes your session holds, not every scope you can reach: a role in one can also give you access to others, such as a team's docs through its org. You do not need to list your scopes with a tool to learn this.`
|
|
53073
|
+
}]
|
|
53074
|
+
};
|
|
53075
|
+
}
|
|
53076
|
+
async computeStateSignal(args) {
|
|
53077
|
+
const context = {
|
|
53078
|
+
requestContext: args.requestContext,
|
|
53079
|
+
agent: {
|
|
53080
|
+
resourceId: args.resourceId,
|
|
53081
|
+
threadId: args.threadId
|
|
53082
|
+
}
|
|
53083
|
+
};
|
|
53084
|
+
if (await this.deps.principalsKey(context) === void 0) return;
|
|
53085
|
+
const current = await this.deps.readHeldScopes(context);
|
|
53086
|
+
let prior = scopesFromSnapshot(args.lastSnapshot);
|
|
53087
|
+
for (const delta of args.deltasSinceSnapshot ?? []) prior = applyOps(prior, opsFromDelta(delta));
|
|
53088
|
+
const hasBase = Boolean(args.lastSnapshot) && args.contextWindow.hasSnapshot;
|
|
53089
|
+
const ops = diffScopes(prior, current);
|
|
53090
|
+
if (ops.length === 0 && hasBase) return;
|
|
53091
|
+
if (!hasBase || current.length === 0) {
|
|
53092
|
+
if (!hasBase && current.length === 0) return;
|
|
53093
|
+
return {
|
|
53094
|
+
id: HELD_SCOPES_STATE_ID,
|
|
53095
|
+
mode: "snapshot",
|
|
53096
|
+
cacheKey: cacheKey(current),
|
|
53097
|
+
tagName: HELD_SCOPES_SNAPSHOT_TAG,
|
|
53098
|
+
contents: renderSnapshot(current),
|
|
53099
|
+
value: { scopes: current },
|
|
53100
|
+
metadata: { value: { scopes: current } }
|
|
53101
|
+
};
|
|
53102
|
+
}
|
|
53103
|
+
return {
|
|
53104
|
+
id: HELD_SCOPES_STATE_ID,
|
|
53105
|
+
mode: "delta",
|
|
53106
|
+
cacheKey: cacheKey(current),
|
|
53107
|
+
tagName: HELD_SCOPES_DELTA_TAG,
|
|
53108
|
+
contents: renderDelta$1(ops),
|
|
53109
|
+
value: { scopes: current },
|
|
53110
|
+
delta: { ops },
|
|
53111
|
+
metadata: {
|
|
53112
|
+
value: { scopes: current },
|
|
53113
|
+
delta: { ops }
|
|
53114
|
+
}
|
|
53115
|
+
};
|
|
53116
|
+
}
|
|
53117
|
+
};
|
|
52630
53118
|
// src/knowledge/instructions.ts
|
|
52631
53119
|
function readInstructions(canEdit) {
|
|
52632
53120
|
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.`;
|
|
@@ -52917,6 +53405,16 @@ function compileKnowledgeScopes(declarations) {
|
|
|
52917
53405
|
const concreteEntries = [];
|
|
52918
53406
|
for (const [key, declaration] of Object.entries(declarations)) {
|
|
52919
53407
|
const pattern = parsePattern(key, "Knowledge scope key");
|
|
53408
|
+
if (declaration.mint !== void 0) {
|
|
53409
|
+
if (declaration.mint !== "run-identity" || pattern.type !== "agent" || pattern.params.length === 0) throw new KnowledgeDeclarationError(`Knowledge scope "${key}" can mint only an agent pattern with mint: 'run-identity'.`);
|
|
53410
|
+
for (const param of pattern.params) if (![
|
|
53411
|
+
"agentId",
|
|
53412
|
+
"orgId",
|
|
53413
|
+
"resourceId",
|
|
53414
|
+
"role",
|
|
53415
|
+
"teamId"
|
|
53416
|
+
].includes(param)) throw new KnowledgeDeclarationError(`Knowledge scope "${key}" cannot mint unknown parameter $${param}.`);
|
|
53417
|
+
}
|
|
52920
53418
|
if (pattern.params.length === 0) {
|
|
52921
53419
|
concreteEntries.push([key, declaration]);
|
|
52922
53420
|
continue;
|
|
@@ -53380,22 +53878,28 @@ async function syncKnowledgePageBodyLinks(storage, page, resolver = new BodyLink
|
|
|
53380
53878
|
}
|
|
53381
53879
|
/** The ref keys a page answers to now: its id, name, scope address and `scope#key/key` path. */
|
|
53382
53880
|
async function pageRefKeys(storage, page) {
|
|
53881
|
+
return refKeysOf(page, !page.isScope && page.key && page.parentId ? await storage.getPageParents({
|
|
53882
|
+
parentId: page.parentId,
|
|
53883
|
+
read: "all"
|
|
53884
|
+
}) : []);
|
|
53885
|
+
}
|
|
53886
|
+
/** {@link pageRefKeys} from the page's parents as `getPageParents` gives them. */
|
|
53887
|
+
function refKeysOf(page, parents) {
|
|
53383
53888
|
const keys = [knowledgeLinkRefKey(page.id), knowledgeLinkRefKey(page.name)];
|
|
53384
53889
|
if (page.isScope) {
|
|
53385
53890
|
if (page.address) keys.push(knowledgeLinkRefKey(page.address));
|
|
53386
53891
|
return keys;
|
|
53387
53892
|
}
|
|
53893
|
+
if (!page.key || !page.parentId) return keys;
|
|
53388
53894
|
const path = [];
|
|
53389
|
-
|
|
53390
|
-
|
|
53895
|
+
for (const current of [page, ...parents]) {
|
|
53896
|
+
if (current.isScope) {
|
|
53897
|
+
if (current.address) keys.push(knowledgeLinkRefKey(`${current.address}#${path.join("/")}`));
|
|
53898
|
+
return keys;
|
|
53899
|
+
}
|
|
53391
53900
|
if (!current.key || !current.parentId) return keys;
|
|
53392
53901
|
path.unshift(current.key);
|
|
53393
|
-
current = await storage.getPage({
|
|
53394
|
-
id: current.parentId,
|
|
53395
|
-
read: "all"
|
|
53396
|
-
});
|
|
53397
53902
|
}
|
|
53398
|
-
if (current?.address) keys.push(knowledgeLinkRefKey(`${current.address}#${path.join("/")}`));
|
|
53399
53903
|
return keys;
|
|
53400
53904
|
}
|
|
53401
53905
|
/** The page and its live ordinary descendants, at most {@link MAX_KNOWLEDGE_MOVE_PAGES} + 1. */
|
|
@@ -53537,6 +54041,203 @@ async function reindexKnowledgeLinks(storage) {
|
|
|
53537
54041
|
} while (cursor);
|
|
53538
54042
|
return count;
|
|
53539
54043
|
}
|
|
54044
|
+
/**
|
|
54045
|
+
* A batched link repair that would stop at a cap the op-by-op refreshes enforce one write at a time
|
|
54046
|
+
* (linking pages, namesakes, refs looked up, subtree size): the caller saves op by op instead, so the
|
|
54047
|
+
* caps apply exactly as they do there.
|
|
54048
|
+
*/
|
|
54049
|
+
var KnowledgeLinkRepairUnsupportedError = class extends Error {
|
|
54050
|
+
reason;
|
|
54051
|
+
constructor(reason) {
|
|
54052
|
+
super(`batched link repair: ${reason}`);
|
|
54053
|
+
this.reason = reason;
|
|
54054
|
+
this.name = "KnowledgeLinkRepairUnsupportedError";
|
|
54055
|
+
}
|
|
54056
|
+
};
|
|
54057
|
+
/** True when the store has every set-based read and write {@link repairKnowledgeLinks} uses. */
|
|
54058
|
+
function canRepairKnowledgeLinksInBatch(storage) {
|
|
54059
|
+
return !!(storage.getPageChains && storage.getPagesByPaths && storage.getPageSubtrees && storage.findPagesByNames && storage.applyPageWrites);
|
|
54060
|
+
}
|
|
54061
|
+
/**
|
|
54062
|
+
* Every {@link syncKnowledgePageBodyLinks} and {@link refreshKnowledgeLinksTo} of a flush, run once
|
|
54063
|
+
* over the store as the flush left it, in a fixed number of statements: each page's links come out
|
|
54064
|
+
* as they do when the calls run one after another after the writes. Throws
|
|
54065
|
+
* {@link KnowledgeLinkRepairUnsupportedError}, having written nothing, when a cap could bite.
|
|
54066
|
+
*/
|
|
54067
|
+
async function repairKnowledgeLinks(storage, repair) {
|
|
54068
|
+
const synced = new Map(repair.synced.map((page) => [page.id, page]));
|
|
54069
|
+
if (!synced.size && !repair.refreshed.length) return;
|
|
54070
|
+
const roots = repair.refreshed.filter((item) => item.withDescendants).map((item) => item.page.id);
|
|
54071
|
+
const subtrees = roots.length ? await storage.getPageSubtrees({
|
|
54072
|
+
rootIds: [...new Set(roots)],
|
|
54073
|
+
limit: 500
|
|
54074
|
+
}) : {};
|
|
54075
|
+
const affected = [];
|
|
54076
|
+
for (const { page, withDescendants } of repair.refreshed) {
|
|
54077
|
+
affected.push(page);
|
|
54078
|
+
if (!withDescendants) continue;
|
|
54079
|
+
const under = subtrees[page.id];
|
|
54080
|
+
if (!under) throw new KnowledgeLinkRepairUnsupportedError("a moved subtree past the move limit");
|
|
54081
|
+
affected.push(...under);
|
|
54082
|
+
}
|
|
54083
|
+
const parentIds = affected.flatMap((page) => !page.isScope && page.key && page.parentId ? [page.parentId] : []);
|
|
54084
|
+
const chains = parentIds.length ? await storage.getPageChains({
|
|
54085
|
+
ids: [...new Set(parentIds)],
|
|
54086
|
+
read: "all"
|
|
54087
|
+
}) : {};
|
|
54088
|
+
const refs = /* @__PURE__ */ new Set();
|
|
54089
|
+
const targets = new Set(affected.map((page) => page.id));
|
|
54090
|
+
const names = /* @__PURE__ */ new Set();
|
|
54091
|
+
for (const page of affected) {
|
|
54092
|
+
const parents = !page.isScope && page.key && page.parentId ? chains[page.parentId] ?? [] : [];
|
|
54093
|
+
for (const key of refKeysOf(page, parents)) refs.add(key);
|
|
54094
|
+
if (!page.deletedAt) names.add(page.name);
|
|
54095
|
+
}
|
|
54096
|
+
if (names.size) {
|
|
54097
|
+
const namesakes = await storage.findPagesByNames({
|
|
54098
|
+
names: [...names],
|
|
54099
|
+
read: "all",
|
|
54100
|
+
limit: 100
|
|
54101
|
+
});
|
|
54102
|
+
for (const found of Object.values(namesakes)) {
|
|
54103
|
+
if (found.length > MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES) throw new KnowledgeLinkRepairUnsupportedError("a name past the namesake limit");
|
|
54104
|
+
for (const namesake of found) targets.add(namesake.id);
|
|
54105
|
+
}
|
|
54106
|
+
}
|
|
54107
|
+
const sources = affected.length ? await storage.listPageBodyLinkSources({
|
|
54108
|
+
refs: [...refs],
|
|
54109
|
+
toPageIds: [...targets]
|
|
54110
|
+
}) : [];
|
|
54111
|
+
if (sources.length > 100) throw new KnowledgeLinkRepairUnsupportedError("linking pages past the refresh limit");
|
|
54112
|
+
const unread = sources.filter((id) => !synced.has(id));
|
|
54113
|
+
const live = new Map((unread.length ? await storage.getPages({
|
|
54114
|
+
ids: unread,
|
|
54115
|
+
read: "all"
|
|
54116
|
+
}) : []).map((page) => [page.id, page]));
|
|
54117
|
+
const rewrite = /* @__PURE__ */ new Map();
|
|
54118
|
+
for (const id of unread) rewrite.set(id, live.get(id) ?? null);
|
|
54119
|
+
for (const [id, page] of synced) rewrite.set(id, page);
|
|
54120
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
54121
|
+
const lookups = [];
|
|
54122
|
+
const refreshing = new Set(sources);
|
|
54123
|
+
let looked = 0;
|
|
54124
|
+
for (const [id, page] of rewrite) {
|
|
54125
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
54126
|
+
if (page && !page.deletedAt) for (const [ref, count] of knowledgeBodyLinkRefs(page.body)) {
|
|
54127
|
+
const key = knowledgeLinkRefKey(ref);
|
|
54128
|
+
if (key.length > 512) continue;
|
|
54129
|
+
const entry = byKey.get(key);
|
|
54130
|
+
if (entry) entry.count += count;
|
|
54131
|
+
else byKey.set(key, {
|
|
54132
|
+
ref,
|
|
54133
|
+
count
|
|
54134
|
+
});
|
|
54135
|
+
}
|
|
54136
|
+
const entries = [...byKey];
|
|
54137
|
+
wanted.set(id, entries);
|
|
54138
|
+
if (page) for (const [, { ref }] of entries) lookups.push({
|
|
54139
|
+
ref,
|
|
54140
|
+
home: page.scopeId
|
|
54141
|
+
});
|
|
54142
|
+
if (refreshing.has(id)) looked += new Set(entries.map(([, { ref }]) => ref)).size;
|
|
54143
|
+
}
|
|
54144
|
+
if (looked >= 1e3) throw new KnowledgeLinkRepairUnsupportedError("refs looked up past the refresh limit");
|
|
54145
|
+
const resolved = await resolveKnowledgeBodyLinks(storage, lookups);
|
|
54146
|
+
await storage.applyPageWrites({ writes: [...wanted].map(([pageId, entries]) => {
|
|
54147
|
+
const home = rewrite.get(pageId)?.scopeId;
|
|
54148
|
+
return {
|
|
54149
|
+
op: "replace-links",
|
|
54150
|
+
pageId,
|
|
54151
|
+
links: entries.map(([key, { ref, count }]) => ({
|
|
54152
|
+
ref: key,
|
|
54153
|
+
toPageId: home === void 0 ? null : resolved.get(`${home}\u0000${ref}`) ?? null,
|
|
54154
|
+
count
|
|
54155
|
+
}))
|
|
54156
|
+
};
|
|
54157
|
+
}) });
|
|
54158
|
+
}
|
|
54159
|
+
/** What {@link BodyLinkResolver} answers for each `(home, ref)`, keyed `home\0ref`, in a fixed number of reads. */
|
|
54160
|
+
async function resolveKnowledgeBodyLinks(storage, lookups) {
|
|
54161
|
+
const answers = /* @__PURE__ */ new Map();
|
|
54162
|
+
if (!lookups.length) return answers;
|
|
54163
|
+
const keyOf = (home, ref) => `${home}\u0000${ref}`;
|
|
54164
|
+
const byId = new Set((await storage.getPages({
|
|
54165
|
+
ids: [...new Set(lookups.map((item) => item.ref))],
|
|
54166
|
+
read: "all"
|
|
54167
|
+
})).map((page) => page.id));
|
|
54168
|
+
const remaining = lookups.filter(({ ref, home }) => {
|
|
54169
|
+
if (!byId.has(ref)) return true;
|
|
54170
|
+
answers.set(keyOf(home, ref), ref);
|
|
54171
|
+
return false;
|
|
54172
|
+
});
|
|
54173
|
+
const paths = /* @__PURE__ */ new Map();
|
|
54174
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
54175
|
+
for (const { ref } of remaining) if (ref.indexOf("#") > 0) {
|
|
54176
|
+
const parsed = parseKnowledgePageRef(ref);
|
|
54177
|
+
paths.set(ref, parsed);
|
|
54178
|
+
if (parsed) addresses.add(parsed.scope);
|
|
54179
|
+
} else addresses.add(ref);
|
|
54180
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
54181
|
+
if (addresses.size) {
|
|
54182
|
+
for (const scope of await storage.getScopesByAddress([...addresses])) if (!scope.deletedAt && scope.address) scopes.set(scope.address, scope.id);
|
|
54183
|
+
}
|
|
54184
|
+
const pathsByScope = /* @__PURE__ */ new Map();
|
|
54185
|
+
for (const [ref, parsed] of paths) {
|
|
54186
|
+
const scopeId = parsed && scopes.get(parsed.scope);
|
|
54187
|
+
if (!scopeId) continue;
|
|
54188
|
+
if (!pathsByScope.has(scopeId)) pathsByScope.set(scopeId, /* @__PURE__ */ new Map());
|
|
54189
|
+
pathsByScope.get(scopeId).set(ref, parsed.path);
|
|
54190
|
+
}
|
|
54191
|
+
const pathAnswers = /* @__PURE__ */ new Map();
|
|
54192
|
+
for (const [scopeId, refs] of pathsByScope) {
|
|
54193
|
+
const found = await storage.getPagesByPaths({
|
|
54194
|
+
scopeId,
|
|
54195
|
+
paths: [...refs.values()],
|
|
54196
|
+
read: "all"
|
|
54197
|
+
});
|
|
54198
|
+
[...refs.keys()].forEach((ref, i) => pathAnswers.set(ref, found[i]?.id ?? null));
|
|
54199
|
+
}
|
|
54200
|
+
const namesByHome = /* @__PURE__ */ new Map();
|
|
54201
|
+
for (const { ref, home } of remaining) {
|
|
54202
|
+
if (paths.has(ref)) {
|
|
54203
|
+
answers.set(keyOf(home, ref), pathAnswers.get(ref) ?? null);
|
|
54204
|
+
continue;
|
|
54205
|
+
}
|
|
54206
|
+
const scopeId = scopes.get(ref);
|
|
54207
|
+
if (scopeId) {
|
|
54208
|
+
answers.set(keyOf(home, ref), scopeId);
|
|
54209
|
+
continue;
|
|
54210
|
+
}
|
|
54211
|
+
if (!namesByHome.has(home)) namesByHome.set(home, /* @__PURE__ */ new Set());
|
|
54212
|
+
namesByHome.get(home).add(ref);
|
|
54213
|
+
}
|
|
54214
|
+
const anywhere = /* @__PURE__ */ new Map();
|
|
54215
|
+
for (const [home, names] of namesByHome) {
|
|
54216
|
+
const found = await storage.findPagesByNames({
|
|
54217
|
+
names: [...names],
|
|
54218
|
+
read: "all",
|
|
54219
|
+
scopeId: home,
|
|
54220
|
+
limit: 2
|
|
54221
|
+
});
|
|
54222
|
+
for (const name of names) {
|
|
54223
|
+
const inHome = found[name] ?? [];
|
|
54224
|
+
if (inHome.length) answers.set(keyOf(home, name), inHome.length === 1 ? inHome[0].id : null);
|
|
54225
|
+
else anywhere.set(name, [...anywhere.get(name) ?? [], home]);
|
|
54226
|
+
}
|
|
54227
|
+
}
|
|
54228
|
+
if (anywhere.size) {
|
|
54229
|
+
const found = await storage.findPagesByNames({
|
|
54230
|
+
names: [...anywhere.keys()],
|
|
54231
|
+
read: "all",
|
|
54232
|
+
limit: 2
|
|
54233
|
+
});
|
|
54234
|
+
for (const [name, homes] of anywhere) {
|
|
54235
|
+
const pages = found[name] ?? [];
|
|
54236
|
+
for (const home of homes) answers.set(keyOf(home, name), pages.length === 1 ? pages[0].id : null);
|
|
54237
|
+
}
|
|
54238
|
+
}
|
|
54239
|
+
return answers;
|
|
54240
|
+
}
|
|
53540
54241
|
// ../_vendored/ai_v7/dist/dist-C-C3A1Ts.js
|
|
53541
54242
|
/**
|
|
53542
54243
|
* Symbol used for identifying AI SDK Error instances.
|
|
@@ -62888,6 +63589,94 @@ async function removeKnowledgeNote(host, input) {
|
|
|
62888
63589
|
await embed$1(host, (index) => index.remove([`note:${note.id}`]), UNEMBED_FAILED$1);
|
|
62889
63590
|
return removed;
|
|
62890
63591
|
}
|
|
63592
|
+
// src/knowledge/agent-scopes.ts
|
|
63593
|
+
/** Agent identity declarations. Identities grant nothing until an access rule names them. @experimental */
|
|
63594
|
+
function knowledgeAgentScopes() {
|
|
63595
|
+
return Object.fromEntries([
|
|
63596
|
+
"agent:$agentId",
|
|
63597
|
+
"agent:$agentId:org:$orgId",
|
|
63598
|
+
"agent:$agentId:user:$resourceId",
|
|
63599
|
+
"agent:persona:role:$role",
|
|
63600
|
+
"agent:persona:role:$role:org:$orgId",
|
|
63601
|
+
"agent:persona:role:$role:user:$resourceId",
|
|
63602
|
+
"agent:persona:team:$teamId"
|
|
63603
|
+
].map((key) => [key, {
|
|
63604
|
+
mint: "run-identity",
|
|
63605
|
+
access: []
|
|
63606
|
+
}]));
|
|
63607
|
+
}
|
|
63608
|
+
/**
|
|
63609
|
+
* {@link knowledgeAgentScopes} plus a read-only persona convention: each agent reads and pins its own
|
|
63610
|
+
* `#persona` page, and every agent of a role or team reads and pins that scope's `#rules` page. The
|
|
63611
|
+
* `:edit` forms give editor on one role or team scope and are never minted; host code passes them.
|
|
63612
|
+
* @experimental
|
|
63613
|
+
*/
|
|
63614
|
+
function knowledgePersonaScopes() {
|
|
63615
|
+
const scopes = knowledgeAgentScopes();
|
|
63616
|
+
for (const [key, page, name, edit] of [
|
|
63617
|
+
[
|
|
63618
|
+
"agent:$agentId",
|
|
63619
|
+
"persona",
|
|
63620
|
+
"Persona",
|
|
63621
|
+
false
|
|
63622
|
+
],
|
|
63623
|
+
[
|
|
63624
|
+
"agent:persona:role:$role",
|
|
63625
|
+
"rules",
|
|
63626
|
+
"Role rules",
|
|
63627
|
+
true
|
|
63628
|
+
],
|
|
63629
|
+
[
|
|
63630
|
+
"agent:persona:team:$teamId",
|
|
63631
|
+
"rules",
|
|
63632
|
+
"Team rules",
|
|
63633
|
+
true
|
|
63634
|
+
]
|
|
63635
|
+
]) {
|
|
63636
|
+
scopes[key] = {
|
|
63637
|
+
...scopes[key],
|
|
63638
|
+
access: [{
|
|
63639
|
+
principal: "self",
|
|
63640
|
+
role: "viewer"
|
|
63641
|
+
}, ...edit ? [{
|
|
63642
|
+
principal: `${key}:edit`,
|
|
63643
|
+
role: "editor"
|
|
63644
|
+
}] : []],
|
|
63645
|
+
pages: [{
|
|
63646
|
+
key: page,
|
|
63647
|
+
name
|
|
63648
|
+
}],
|
|
63649
|
+
pinnedContext: [`${key}#${page}`]
|
|
63650
|
+
};
|
|
63651
|
+
if (edit) scopes[`${key}:edit`] = { access: [] };
|
|
63652
|
+
}
|
|
63653
|
+
return scopes;
|
|
63654
|
+
}
|
|
63655
|
+
/** @internal */
|
|
63656
|
+
function mintKnowledgeAgentScopes(compiled, scopes, agent) {
|
|
63657
|
+
const params = {};
|
|
63658
|
+
if (agent?.agentId) params.agentId = agent.agentId;
|
|
63659
|
+
if (agent?.resourceId) params.resourceId = agent.resourceId;
|
|
63660
|
+
const persona = agent?.persona;
|
|
63661
|
+
if (persona && typeof persona === "object") for (const [field, param] of [["role", "role"], ["teamId", "teamId"]]) {
|
|
63662
|
+
const value = persona[field];
|
|
63663
|
+
if (typeof value === "string" && value.length > 0) params[param] = value;
|
|
63664
|
+
}
|
|
63665
|
+
const orgs = scopes.filter((scope) => /^org:[^:]+$/.test(scope)).map((scope) => decodeKnowledgeScopeValue(scope.slice(4))).filter((value) => value !== null);
|
|
63666
|
+
const minted = [];
|
|
63667
|
+
for (const declaration of compiled.declarations.values()) {
|
|
63668
|
+
if (declaration.declaration.mint !== "run-identity") continue;
|
|
63669
|
+
const bindings = declaration.pattern.params.includes("orgId") ? orgs.map((orgId) => ({
|
|
63670
|
+
...params,
|
|
63671
|
+
orgId
|
|
63672
|
+
})) : [params];
|
|
63673
|
+
for (const binding of bindings) {
|
|
63674
|
+
const address = bindKnowledgePattern(declaration.pattern, binding);
|
|
63675
|
+
if (address) minted.push(address);
|
|
63676
|
+
}
|
|
63677
|
+
}
|
|
63678
|
+
return minted;
|
|
63679
|
+
}
|
|
62891
63680
|
// src/knowledge/run.ts
|
|
62892
63681
|
/** A page reference the run can't resolve; identical for missing and unreadable pages. */
|
|
62893
63682
|
var KnowledgeNotFoundError = class extends Error {
|
|
@@ -62896,6 +63685,13 @@ var KnowledgeNotFoundError = class extends Error {
|
|
|
62896
63685
|
this.name = "KnowledgeNotFoundError";
|
|
62897
63686
|
}
|
|
62898
63687
|
};
|
|
63688
|
+
/** A run with no scopes and no Memory identity: it has no Knowledge view. @internal */
|
|
63689
|
+
var KnowledgeRunScopesError = class extends Error {
|
|
63690
|
+
constructor() {
|
|
63691
|
+
super("Knowledge tools need run scopes: give the agent or the call `scopes`, or run it with Memory.");
|
|
63692
|
+
this.name = "KnowledgeRunScopesError";
|
|
63693
|
+
}
|
|
63694
|
+
};
|
|
62899
63695
|
const NAME_CANDIDATES = 5;
|
|
62900
63696
|
const CLOSE_MATCHES = 3;
|
|
62901
63697
|
/**
|
|
@@ -63047,9 +63843,15 @@ function knowledgeRunPrincipals(runtime, context) {
|
|
|
63047
63843
|
const memory = [];
|
|
63048
63844
|
if (context?.agent?.resourceId) memory.push(knowledgeScopeAddress("resource:$resourceId", { resourceId: context.agent.resourceId }));
|
|
63049
63845
|
if (context?.agent?.threadId) memory.push(knowledgeScopeAddress("thread:$threadId", { threadId: context.agent.threadId }));
|
|
63050
|
-
if (raw.length === 0 && memory.length === 0) throw new
|
|
63846
|
+
if (raw.length === 0 && memory.length === 0) throw new KnowledgeRunScopesError();
|
|
63051
63847
|
for (const address of memory) if (!runtime.compiled.match(address)) throw new KnowledgeDeclarationError(`Knowledge run scope "${address}" does not match a declared scope type. Declare it in Knowledge \`scopes\` (for Memory's resource:/thread: scopes, spread \`...knowledgeMemoryScopes()\`).`);
|
|
63052
|
-
|
|
63848
|
+
const scopes = knowledgeRunScopes(runtime.compiled, raw);
|
|
63849
|
+
const minted = mintKnowledgeAgentScopes(runtime.compiled, scopes, context?.agent);
|
|
63850
|
+
return [.../* @__PURE__ */ new Set([
|
|
63851
|
+
...scopes,
|
|
63852
|
+
...memory,
|
|
63853
|
+
...minted
|
|
63854
|
+
])];
|
|
63053
63855
|
}
|
|
63054
63856
|
/** Longest heading line a hit shows ahead of its excerpt; a longer one is cut with `…`. */
|
|
63055
63857
|
const HEADING_CHARS = 120;
|
|
@@ -63423,6 +64225,30 @@ async function noteSummaries(run, notes, cache = /* @__PURE__ */ new Map()) {
|
|
|
63423
64225
|
for (const note of notes) summaries.push(noteSummary(note, await noteMentions(run, note, cache)));
|
|
63424
64226
|
return summaries;
|
|
63425
64227
|
}
|
|
64228
|
+
/**
|
|
64229
|
+
* Every scope the run holds, in principal order, with its role and what it can do there. A held scope
|
|
64230
|
+
* gets its page on the first write, so before that its role comes from the declarations and the parent
|
|
64231
|
+
* that write would link it under: without it a model sees no scopes on its first turn and concludes it
|
|
64232
|
+
* has nowhere to write. A stored scope it can't read keeps only its address.
|
|
64233
|
+
*/
|
|
64234
|
+
async function heldScopes(run) {
|
|
64235
|
+
const stored = await run.storage.getScopesByAddress(run.principals);
|
|
64236
|
+
return Promise.all(run.principals.map(async (address) => {
|
|
64237
|
+
const found = stored.find((scope) => scope.address === address);
|
|
64238
|
+
const page = found && knowledgeScopeReadable(found, run.read) ? found : void 0;
|
|
64239
|
+
const role = found ? await run.roleOn(found) : knowledgeRoleOn(run.runtime.compiled, run.principals, {
|
|
64240
|
+
address,
|
|
64241
|
+
parentAddress: run.runtime.firstWriteParentAddress(address, run.principals)
|
|
64242
|
+
});
|
|
64243
|
+
const can = !role ? "none" : knowledgeRoleAtLeast(role, "contributor") ? "write" : "read";
|
|
64244
|
+
return {
|
|
64245
|
+
address,
|
|
64246
|
+
...page ? { page } : {},
|
|
64247
|
+
role,
|
|
64248
|
+
can
|
|
64249
|
+
};
|
|
64250
|
+
}));
|
|
64251
|
+
}
|
|
63426
64252
|
/** Scope pages for addresses the run names; each must be readable. */
|
|
63427
64253
|
async function readableScopes(run, addresses) {
|
|
63428
64254
|
const page = addresses.find((address) => address.includes("#"));
|
|
@@ -63459,11 +64285,13 @@ async function visibleNote(run, id) {
|
|
|
63459
64285
|
page
|
|
63460
64286
|
};
|
|
63461
64287
|
}
|
|
63462
|
-
/**
|
|
64288
|
+
/** Shared persona audiences need editor authority even when the run holds them. */
|
|
63463
64289
|
async function requireAudienceAuthority(run, audience) {
|
|
63464
64290
|
for (const address of audience) {
|
|
63465
|
-
|
|
63466
|
-
|
|
64291
|
+
const match = run.runtime.compiled.match(address);
|
|
64292
|
+
const sharedPersona = match?.compiled.declaration.mint === "run-identity" && match.compiled.pattern.params.some((param) => param === "role" || param === "teamId");
|
|
64293
|
+
if (run.principals.includes(address) && !sharedPersona) continue;
|
|
64294
|
+
if (!match) throw new Error(`Pin audience "${address}" does not match a declared scope type.`);
|
|
63467
64295
|
const [scope] = await run.storage.getScopesByAddress([address]);
|
|
63468
64296
|
if (!knowledgeRoleAtLeast(scope ? await run.roleOn(scope) : knowledgeRoleOn(run.runtime.compiled, run.principals, { address }), "editor")) throw new Error(`Pinning for "${address}" needs holding it or editor on it; this run has neither.`);
|
|
63469
64297
|
}
|
|
@@ -63703,7 +64531,7 @@ function bodyView(body, input) {
|
|
|
63703
64531
|
function readTool(host, canEdit) {
|
|
63704
64532
|
return createTool({
|
|
63705
64533
|
id: "knowledge_read",
|
|
63706
|
-
description: `Read a page: its body, its notes, its child pages and the notes on other pages that mention it. Read a scope address (org:acme) to browse that scope. Without \`page\`, lists
|
|
64534
|
+
description: `Read a page: its body, its notes, its child pages and the notes on other pages that mention it. Read a scope address (org:acme) to browse that scope. Without \`page\`, lists every scope this run holds, with its role and whether it can read or write there, including scopes with no page this run can read yet (\`empty\`). When a page's notes, or the notes mentioning it, come to more than ${KNOWLEDGE_READ_INLINE_TOKENS.toLocaleString("en-US")} tokens, a whole read leaves them out and counts them in \`more\`; read them on their own with \`notes\` or \`mentionedIn\`. A body returns at most ${maxTokensOf(host).toLocaleString("en-US")} tokens at a time. A body that fits comes whole as \`body\`; a longer one comes as numbered \`lines\` (\`12\u2502text\`) with the \`range\` they cover, and \`more\` says where to read on; a first read of a long page shows every heading with its line number and the first lines under it, so you can pick the part to read. For a long page, ask for its \`outline\` of headings with their line numbers, read one \`section\`, or \`match\` terms to see only the lines that contain them, with \`context\` lines around each. Those part reads return just that part of the body.` + (canEdit ? " To edit part of a long body, pass the `range` a read gave you to knowledge_page." : ""),
|
|
63707
64535
|
inputSchema: {
|
|
63708
64536
|
type: "object",
|
|
63709
64537
|
properties: {
|
|
@@ -63785,10 +64613,13 @@ function readTool(host, canEdit) {
|
|
|
63785
64613
|
if (outline && from) throw new Error("knowledge_read: an outline covers the whole body; pass it without from.");
|
|
63786
64614
|
const run = await start(host, context);
|
|
63787
64615
|
const limit = limitOf(requested);
|
|
63788
|
-
if (!ref) return { scopes: (await
|
|
63789
|
-
address
|
|
63790
|
-
name:
|
|
63791
|
-
...
|
|
64616
|
+
if (!ref) return { scopes: (await heldScopes(run)).map(({ address, page, role, can }) => ({
|
|
64617
|
+
address,
|
|
64618
|
+
name: page?.name ?? address,
|
|
64619
|
+
...page?.description ? { description: page.description } : {},
|
|
64620
|
+
...role ? { role } : {},
|
|
64621
|
+
can,
|
|
64622
|
+
...page ? {} : { empty: true }
|
|
63792
64623
|
})) };
|
|
63793
64624
|
const page = await run.pageOrCloseMatches(ref);
|
|
63794
64625
|
if (outline || section || match || from) {
|
|
@@ -64002,12 +64833,13 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
|
|
|
64002
64833
|
let scopes = [];
|
|
64003
64834
|
if (!origin) {
|
|
64004
64835
|
if (cursor?.startsWith("p")) throw new Error("knowledge_list: a page cursor needs the `from` it came from.");
|
|
64005
|
-
|
|
64006
|
-
|
|
64007
|
-
|
|
64836
|
+
scopes = (await heldScopes(run)).map((held) => ({
|
|
64837
|
+
...held.page ? { page: held.page } : {},
|
|
64838
|
+
held
|
|
64839
|
+
}));
|
|
64008
64840
|
} else {
|
|
64009
64841
|
originRef = (await pageRefs(run, [origin])).refs.get(origin.id) ?? origin.id;
|
|
64010
|
-
if (origin.isScope && !cursor?.startsWith("p")) scopes = await childScopes(origin.id);
|
|
64842
|
+
if (origin.isScope && !cursor?.startsWith("p")) scopes = (await childScopes(origin.id)).map((page) => ({ page }));
|
|
64011
64843
|
}
|
|
64012
64844
|
const shownScopes = scopes.slice(scopeOffset, scopeOffset + limit);
|
|
64013
64845
|
let roots = shownScopes;
|
|
@@ -64017,7 +64849,7 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
|
|
|
64017
64849
|
const room = limit - shownScopes.length;
|
|
64018
64850
|
if (room > 0) {
|
|
64019
64851
|
const pages = await childPages(origin.id, room, pageCursor);
|
|
64020
|
-
roots = [...shownScopes, ...pages.pages];
|
|
64852
|
+
roots = [...shownScopes, ...pages.pages.map((page) => ({ page }))];
|
|
64021
64853
|
if (pages.nextCursor) nextCursor = `p${pages.nextCursor}`;
|
|
64022
64854
|
} else if ((await run.storage.countChildPages({
|
|
64023
64855
|
parentIds: [origin.id],
|
|
@@ -64031,10 +64863,19 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
|
|
|
64031
64863
|
children: 0,
|
|
64032
64864
|
below: []
|
|
64033
64865
|
});
|
|
64034
|
-
const top = roots.map((
|
|
64866
|
+
const top = roots.map(({ page, held }) => page ? {
|
|
64867
|
+
...nodeOf(page, origin && originRef ? childRef(origin, originRef, page) : page.address ?? page.id, 1),
|
|
64868
|
+
...held ? { held } : {}
|
|
64869
|
+
} : {
|
|
64870
|
+
held,
|
|
64871
|
+
ref: held.address,
|
|
64872
|
+
depth: 1,
|
|
64873
|
+
children: 0,
|
|
64874
|
+
below: []
|
|
64875
|
+
});
|
|
64035
64876
|
let budget = Math.max(limit - top.length, 0);
|
|
64036
64877
|
let truncated = false;
|
|
64037
|
-
let level = top;
|
|
64878
|
+
let level = top.filter((node) => node.page);
|
|
64038
64879
|
for (let current = 1; current <= depth && level.length; current++) {
|
|
64039
64880
|
const parentIds = level.map((node) => node.page.id);
|
|
64040
64881
|
const scopeParents = level.filter((node) => node.page.isScope).map((node) => node.page.id);
|
|
@@ -64058,22 +64899,30 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
|
|
|
64058
64899
|
budget -= scopes.length;
|
|
64059
64900
|
const pages = budget > 0 ? (await childPages(node.page.id, budget)).pages : [];
|
|
64060
64901
|
budget -= pages.length;
|
|
64061
|
-
|
|
64062
|
-
|
|
64063
|
-
|
|
64902
|
+
const below = [...scopes, ...pages].map((child) => ({
|
|
64903
|
+
...nodeOf(child, childRef(node.page, node.ref, child), current + 1),
|
|
64904
|
+
page: child
|
|
64905
|
+
}));
|
|
64906
|
+
node.below = below;
|
|
64907
|
+
if (below.length < node.children) truncated = true;
|
|
64908
|
+
nextLevel.push(...below);
|
|
64064
64909
|
}
|
|
64065
64910
|
level = nextLevel;
|
|
64066
64911
|
}
|
|
64067
64912
|
const entries = [];
|
|
64068
64913
|
const flatten = (nodes) => {
|
|
64069
64914
|
for (const node of nodes) {
|
|
64915
|
+
const { page, held } = node;
|
|
64070
64916
|
entries.push({
|
|
64071
64917
|
ref: node.ref,
|
|
64072
|
-
name: node.
|
|
64073
|
-
...descriptions &&
|
|
64918
|
+
name: page?.name ?? node.ref,
|
|
64919
|
+
...descriptions && page?.description ? { description: page.description } : {},
|
|
64074
64920
|
depth: node.depth,
|
|
64075
64921
|
children: node.children,
|
|
64076
|
-
|
|
64922
|
+
...!page || page.isScope ? { scope: true } : {},
|
|
64923
|
+
...held?.role ? { role: held.role } : {},
|
|
64924
|
+
...held ? { can: held.can } : {},
|
|
64925
|
+
...page ? {} : { empty: true }
|
|
64077
64926
|
});
|
|
64078
64927
|
flatten(node.below);
|
|
64079
64928
|
}
|
|
@@ -64090,7 +64939,7 @@ function listTool(host) {
|
|
|
64090
64939
|
const maxTokens = maxTokensOf(host);
|
|
64091
64940
|
return createTool({
|
|
64092
64941
|
id: "knowledge_list",
|
|
64093
|
-
description: `List the page tree under a starting point: each child with its ref (pass it to knowledge_read or knowledge_list), name and how many children it has. Pass \`descriptions: true\` to include page descriptions too. Without \`from\`, lists
|
|
64942
|
+
description: `List the page tree under a starting point: each child with its ref (pass it to knowledge_read or knowledge_list), name and how many children it has. Pass \`descriptions: true\` to include page descriptions too. Without \`from\`, lists every scope this run holds, with its role and whether it can read or write there, including scopes with no page this run can read yet (\`empty\`). Use it to find your way around a scope before searching or reading. One result holds at most \`limit\` entries and about ${maxTokens.toLocaleString("en-US")} tokens of them; when it stops early, \`more\` says how many entries were left out and gives the \`cursor\` to list the rest (pass the same \`from\`).`,
|
|
64094
64943
|
inputSchema: {
|
|
64095
64944
|
type: "object",
|
|
64096
64945
|
properties: {
|
|
@@ -65262,12 +66111,8 @@ var PinnedStateProcessor = class {
|
|
|
65262
66111
|
threadId: args.threadId
|
|
65263
66112
|
}
|
|
65264
66113
|
};
|
|
65265
|
-
|
|
65266
|
-
|
|
65267
|
-
key = this.deps.principalsKey(context);
|
|
65268
|
-
} catch {
|
|
65269
|
-
return;
|
|
65270
|
-
}
|
|
66114
|
+
const key = await this.deps.principalsKey(context);
|
|
66115
|
+
if (key === void 0) return void 0;
|
|
65271
66116
|
if (memo && memo.key === key && stepNumber > memo.atStep) return memo.entries;
|
|
65272
66117
|
const entries = await this.deps.readPins(context);
|
|
65273
66118
|
args.requestContext?.set?.(MEMO_KEY, {
|
|
@@ -67187,7 +68032,7 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
67187
68032
|
content: messages
|
|
67188
68033
|
}];
|
|
67189
68034
|
}
|
|
67190
|
-
stream({ resumeContext, runId, stopWhen, maxSteps, tools = {}, modelSettings, toolChoice = "auto", threadId, resourceId, structuredOutput, options, inputProcessors, llmRequestInputProcessors, outputProcessors, errorProcessors, hasConfiguredErrorProcessors, returnScorerData, providerOptions, messageList, requireToolApproval, toolCallConcurrency, eagerToolExecution, streamPublisher, _internal, onTracingTripwire, onTracingTerminalError, tracingScope = createRunScope(), agentId, agentVersionId, resolvedScopes, agentName, toolCallId, requestContext, actor, mcp, methodType, includeRawChunks, experimentalTransform, hideSignals, autoResumeSuspendedTools, maxProcessorRetries, processorStates, activeTools, isTaskComplete, goal, onIterationComplete, workspace, agentRunSpan, agent, ...rest }) {
|
|
68035
|
+
stream({ resumeContext, runId, stopWhen, maxSteps, tools = {}, modelSettings, toolChoice = "auto", threadId, resourceId, structuredOutput, options, inputProcessors, llmRequestInputProcessors, outputProcessors, errorProcessors, hasConfiguredErrorProcessors, returnScorerData, providerOptions, messageList, requireToolApproval, toolCallConcurrency, eagerToolExecution, streamPublisher, _internal, onTracingTripwire, onTracingTerminalError, tracingScope = createRunScope(), agentId, agentVersionId, resolvedScopes, agentName, toolCallId, requestContext, actor, mcp, methodType, includeRawChunks, experimentalTransform, hideSignals, autoResumeSuspendedTools, maxProcessorRetries, processorStates, activeTools, isTaskComplete, goal, onIterationComplete, workspace, agentRunSpan, agent, resultType, ...rest }) {
|
|
67191
68036
|
const observabilityContext = resolveObservabilityContext(rest);
|
|
67192
68037
|
let stopWhenToUse;
|
|
67193
68038
|
if (maxSteps && typeof maxSteps === "number") {
|
|
@@ -67213,7 +68058,8 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
67213
68058
|
provider: firstModel.provider,
|
|
67214
68059
|
streaming: true,
|
|
67215
68060
|
parameters: modelSettings,
|
|
67216
|
-
...toolDefinitions ? { tools: toolDefinitions } : {}
|
|
68061
|
+
...toolDefinitions ? { tools: toolDefinitions } : {},
|
|
68062
|
+
...resultType ? { resultType } : {}
|
|
67217
68063
|
},
|
|
67218
68064
|
metadata: {
|
|
67219
68065
|
runId,
|
|
@@ -73565,8 +74411,9 @@ function releaseRunMessageRefs(runId) {
|
|
|
73565
74411
|
/**
|
|
73566
74412
|
* A `SaveQueueManager` `onSaved` callback that records the rows a run saved,
|
|
73567
74413
|
* so its persisted transcript references them instead of repeating them. Only
|
|
73568
|
-
* runs that store refs hold an entry (the
|
|
73569
|
-
* for other runs, or landing after the
|
|
74414
|
+
* runs that store refs hold an entry (created before the run saves its input,
|
|
74415
|
+
* else by the transcript store), so saves for other runs, or landing after the
|
|
74416
|
+
* run released its entry, are not kept.
|
|
73570
74417
|
*/
|
|
73571
74418
|
function recordRunSavedMessages(runId) {
|
|
73572
74419
|
return (rows) => {
|
|
@@ -73588,6 +74435,15 @@ function recordRunSavedMessages(runId) {
|
|
|
73588
74435
|
};
|
|
73589
74436
|
}
|
|
73590
74437
|
// src/agent/durable/utils/resolve-runtime.ts
|
|
74438
|
+
async function restoreWorkerToolsets(mastra, context, names) {
|
|
74439
|
+
const controller = context.get("controller");
|
|
74440
|
+
if (!isRestoredWorkerControllerContext(controller) || !names?.length) return;
|
|
74441
|
+
const toolsets = await mastra.getAgentControllerById(controller.controllerId)?.__restoreWorkerToolsets(context);
|
|
74442
|
+
if (!toolsets) return;
|
|
74443
|
+
const allowed = new Set(names);
|
|
74444
|
+
for (const [key, tools] of Object.entries(toolsets)) if (tools) toolsets[key] = Object.fromEntries(Object.entries(tools).filter(([name]) => allowed.has(name)));
|
|
74445
|
+
return toolsets;
|
|
74446
|
+
}
|
|
73591
74447
|
/**
|
|
73592
74448
|
* Build a SaveQueueManager for a run's memory, or `undefined` when no memory
|
|
73593
74449
|
* is configured. Shared by `resolveRuntimeDependencies` and
|
|
@@ -73750,6 +74606,7 @@ async function resolveRuntimeDependencies(options) {
|
|
|
73750
74606
|
backgroundTasks = resolveBackgroundTasks(mastra, agent, input.options);
|
|
73751
74607
|
tools = await agent.getToolsForExecution({
|
|
73752
74608
|
runId,
|
|
74609
|
+
toolsets: await restoreWorkerToolsets(mastra, resolveRequestContext, input.options?.toolsetToolNames),
|
|
73753
74610
|
threadId: input.state.threadId,
|
|
73754
74611
|
resourceId: input.state.resourceId,
|
|
73755
74612
|
requestContext: resolveRequestContext,
|
|
@@ -73871,6 +74728,7 @@ async function rebuildRunToolsFromMastra(options) {
|
|
|
73871
74728
|
const backgroundTasks = resolveBackgroundTasks(mastra, agent, execOptions);
|
|
73872
74729
|
const tools = await agent.getToolsForExecution({
|
|
73873
74730
|
runId,
|
|
74731
|
+
toolsets: await restoreWorkerToolsets(mastra, resolveRequestContext, execOptions?.toolsetToolNames),
|
|
73874
74732
|
threadId: state.threadId,
|
|
73875
74733
|
resourceId: state.resourceId,
|
|
73876
74734
|
requestContext: resolveRequestContext,
|
|
@@ -74340,7 +75198,11 @@ function mergeRequestContextForFinalization(entries, fallback, liveRunContext) {
|
|
|
74340
75198
|
if (liveRunContext) return liveRunContext;
|
|
74341
75199
|
if (!entries) return fallback ?? new RequestContext();
|
|
74342
75200
|
const restored = new RequestContext(fallback?.entries());
|
|
74343
|
-
|
|
75201
|
+
const controller = fallback?.get("controller");
|
|
75202
|
+
for (const [key, value] of Object.entries(withoutLiveRequestKeys(entries))) {
|
|
75203
|
+
if (key === "controller" && isRestoredWorkerControllerContext(controller)) continue;
|
|
75204
|
+
restored.set(key, value);
|
|
75205
|
+
}
|
|
74344
75206
|
restoreRunAgentScopes(restored);
|
|
74345
75207
|
return restored;
|
|
74346
75208
|
}
|
|
@@ -74381,6 +75243,7 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
|
|
|
74381
75243
|
...initData,
|
|
74382
75244
|
messageListState
|
|
74383
75245
|
},
|
|
75246
|
+
requestContext,
|
|
74384
75247
|
logger: effectiveLogger
|
|
74385
75248
|
});
|
|
74386
75249
|
rebuiltSaveQueueManager = resolved.saveQueueManager;
|
|
@@ -76385,6 +77248,15 @@ function buildMessagesFromChunks({ chunks, messageId, responseModelMetadata, too
|
|
|
76385
77248
|
});
|
|
76386
77249
|
break;
|
|
76387
77250
|
}
|
|
77251
|
+
case "custom": {
|
|
77252
|
+
const p = chunk.payload;
|
|
77253
|
+
parts.push({
|
|
77254
|
+
type: "custom",
|
|
77255
|
+
kind: p.kind,
|
|
77256
|
+
...p.providerMetadata ? { providerMetadata: p.providerMetadata } : {}
|
|
77257
|
+
});
|
|
77258
|
+
break;
|
|
77259
|
+
}
|
|
76388
77260
|
case "tool-call": {
|
|
76389
77261
|
const p = chunk.payload;
|
|
76390
77262
|
const toolDef = tools?.[p.toolName] || findProviderToolByName(tools, p.toolName);
|
|
@@ -79924,6 +80796,12 @@ function createDurableToolCallStep() {
|
|
|
79924
80796
|
error
|
|
79925
80797
|
};
|
|
79926
80798
|
}
|
|
80799
|
+
if (typeof args === "object" && args !== null) args = sanitizeToolArguments({
|
|
80800
|
+
args,
|
|
80801
|
+
toolName,
|
|
80802
|
+
toolConfig: tool?.backgroundConfig,
|
|
80803
|
+
agentConfig: registryEntry?.backgroundTasksConfig
|
|
80804
|
+
});
|
|
79927
80805
|
const saveQueueManager = registryEntry?.saveQueueManager ?? rebuiltSaveQueueManager;
|
|
79928
80806
|
const memory = registryEntry?.memory ?? rebuiltMemory;
|
|
79929
80807
|
const workspace = registryEntry?.workspace ?? rebuiltWorkspace;
|
|
@@ -83719,15 +84597,21 @@ async function persistDurableRunInput(runId, workflowInput, mastra, beforeSave)
|
|
|
83719
84597
|
await beforeSave();
|
|
83720
84598
|
}
|
|
83721
84599
|
const inputCopy = entry.messageList.clone();
|
|
83722
|
-
|
|
83723
|
-
|
|
83724
|
-
|
|
83725
|
-
|
|
83726
|
-
|
|
83727
|
-
|
|
83728
|
-
|
|
83729
|
-
|
|
83730
|
-
|
|
84600
|
+
if (state.fixedMemory) getRunMessageRefs(runId);
|
|
84601
|
+
try {
|
|
84602
|
+
await entry.saveQueueManager.flushMessages(inputCopy, state.threadId, state.memoryConfig, {
|
|
84603
|
+
throwOnError: true,
|
|
84604
|
+
beforePersist: () => assertExecutionOwned({
|
|
84605
|
+
runId,
|
|
84606
|
+
agentId: workflowInput.agentId,
|
|
84607
|
+
mastra,
|
|
84608
|
+
requestContext
|
|
84609
|
+
})
|
|
84610
|
+
});
|
|
84611
|
+
} catch (error) {
|
|
84612
|
+
if (state.fixedMemory) releaseRunMessageRefs(runId);
|
|
84613
|
+
throw error;
|
|
84614
|
+
}
|
|
83731
84615
|
const embedded = entry.messageList.getEmbeddedMessages();
|
|
83732
84616
|
for (const [messageId, textHash] of inputCopy.getEmbeddedMessages()) embedded.set(messageId, textHash);
|
|
83733
84617
|
}
|
|
@@ -84054,7 +84938,7 @@ async function prepareForDurableExecution(options) {
|
|
|
84054
84938
|
});
|
|
84055
84939
|
let tripwireData;
|
|
84056
84940
|
if (inputProcessors.length > 0) try {
|
|
84057
|
-
const { ProcessorRunner } = await import("./stream-
|
|
84941
|
+
const { ProcessorRunner } = await import("./stream-CG9OooRx.js").then((n) => n.I);
|
|
84058
84942
|
await new ProcessorRunner({
|
|
84059
84943
|
inputProcessors,
|
|
84060
84944
|
outputProcessors,
|
|
@@ -86814,6 +87698,11 @@ var Agent = class Agent extends MastraBase {
|
|
|
86814
87698
|
const processors = [];
|
|
86815
87699
|
const instructions = knowledge.getInstructions();
|
|
86816
87700
|
if (instructions && !configuredIds.has("knowledge-instructions-processor")) processors.push(new KnowledgeInstructionsProcessor(instructions));
|
|
87701
|
+
const toolGroups = knowledge.__toolGroups;
|
|
87702
|
+
if (hasMemory && (toolGroups.read || toolGroups.write) && !hasConfiguredProcessor(configuredProcessors, (processor) => processor.id === "knowledge-scopes")) processors.push(new HeldScopesStateProcessor({
|
|
87703
|
+
principalsKey: (context) => knowledge.__principalsKey(context),
|
|
87704
|
+
readHeldScopes: (context) => knowledge.__heldScopes(context)
|
|
87705
|
+
}));
|
|
86817
87706
|
if (knowledge.pinnedContextEnabled && !configuredIds.has("knowledge")) {
|
|
86818
87707
|
if (!hasMemory) {
|
|
86819
87708
|
if (!this.#warnedPinsWithoutMemory) {
|
|
@@ -86822,9 +87711,26 @@ var Agent = class Agent extends MastraBase {
|
|
|
86822
87711
|
}
|
|
86823
87712
|
return processors;
|
|
86824
87713
|
}
|
|
87714
|
+
const contexts = /* @__PURE__ */ new WeakMap();
|
|
87715
|
+
const pinContext = (context) => {
|
|
87716
|
+
let resolved = contexts.get(context);
|
|
87717
|
+
if (!resolved) {
|
|
87718
|
+
const requestContext = context.requestContext instanceof RequestContext ? context.requestContext : void 0;
|
|
87719
|
+
resolved = this.resolveKnowledgePersona(knowledge, requestContext).then((persona) => ({
|
|
87720
|
+
...context,
|
|
87721
|
+
agent: {
|
|
87722
|
+
...context.agent,
|
|
87723
|
+
agentId: this.id,
|
|
87724
|
+
persona
|
|
87725
|
+
}
|
|
87726
|
+
}));
|
|
87727
|
+
contexts.set(context, resolved);
|
|
87728
|
+
}
|
|
87729
|
+
return resolved;
|
|
87730
|
+
};
|
|
86825
87731
|
processors.push(new PinnedStateProcessor({
|
|
86826
|
-
principalsKey: (context) => knowledge.__principalsKey(context),
|
|
86827
|
-
readPins: (context) => knowledge.__deliveredPins(context),
|
|
87732
|
+
principalsKey: async (context) => knowledge.__principalsKey(await pinContext(context)),
|
|
87733
|
+
readPins: async (context) => knowledge.__deliveredPins(await pinContext(context)),
|
|
86828
87734
|
...knowledge.__toolGroups
|
|
86829
87735
|
}));
|
|
86830
87736
|
}
|
|
@@ -87781,7 +88687,8 @@ var Agent = class Agent extends MastraBase {
|
|
|
87781
88687
|
}
|
|
87782
88688
|
/**
|
|
87783
88689
|
* Gets the metadata for this agent, resolving function-based metadata if necessary.
|
|
87784
|
-
* Metadata is a classification bag for clients
|
|
88690
|
+
* Metadata is a classification bag for clients. The agent runtime reads only `metadata.persona`, to mint
|
|
88691
|
+
* Knowledge persona scopes; it reads nothing else in metadata.
|
|
87785
88692
|
*
|
|
87786
88693
|
* @example
|
|
87787
88694
|
* ```typescript
|
|
@@ -88519,11 +89426,13 @@ var Agent = class Agent extends MastraBase {
|
|
|
88519
89426
|
...observabilityContext,
|
|
88520
89427
|
messageList,
|
|
88521
89428
|
agentId: this.id,
|
|
88522
|
-
agentName: this.name
|
|
89429
|
+
agentName: this.name,
|
|
89430
|
+
resultType: "title_generation"
|
|
88523
89431
|
}).text;
|
|
88524
89432
|
} else text = (await llm.__text({
|
|
88525
89433
|
requestContext,
|
|
88526
89434
|
...observabilityContext,
|
|
89435
|
+
resultType: "title_generation",
|
|
88527
89436
|
messages: [{
|
|
88528
89437
|
role: "system",
|
|
88529
89438
|
content: systemInstructions
|
|
@@ -88670,10 +89579,34 @@ var Agent = class Agent extends MastraBase {
|
|
|
88670
89579
|
backgroundConfig: tool.background,
|
|
88671
89580
|
agentBackgroundConfig: this.#backgroundTasks
|
|
88672
89581
|
};
|
|
88673
|
-
|
|
89582
|
+
const execute = tool.execute;
|
|
89583
|
+
const agentTool = execute ? {
|
|
89584
|
+
...tool,
|
|
89585
|
+
execute: async (input, context) => {
|
|
89586
|
+
const persona = await this.resolveKnowledgePersona(knowledge, requestContext);
|
|
89587
|
+
const runContext = {
|
|
89588
|
+
...context,
|
|
89589
|
+
agent: context?.agent ? {
|
|
89590
|
+
...context.agent,
|
|
89591
|
+
agentId: this.id,
|
|
89592
|
+
persona
|
|
89593
|
+
} : void 0
|
|
89594
|
+
};
|
|
89595
|
+
return execute(input, runContext);
|
|
89596
|
+
}
|
|
89597
|
+
} : tool;
|
|
89598
|
+
converted[toolName] = makeCoreTool(agentTool, options, void 0, autoResumeSuspendedTools, backgroundTaskEnabled);
|
|
88674
89599
|
}
|
|
88675
89600
|
return converted;
|
|
88676
89601
|
}
|
|
89602
|
+
async resolveKnowledgePersona(knowledge, requestContext) {
|
|
89603
|
+
if (!await knowledge.__needsAgentPersona()) return void 0;
|
|
89604
|
+
try {
|
|
89605
|
+
return (await this.getMetadata({ requestContext }))?.persona;
|
|
89606
|
+
} catch {
|
|
89607
|
+
return;
|
|
89608
|
+
}
|
|
89609
|
+
}
|
|
88677
89610
|
/**
|
|
88678
89611
|
* Lists workspace tools if a workspace is configured.
|
|
88679
89612
|
* @internal
|
|
@@ -96414,6 +97347,29 @@ var Agent = class Agent extends MastraBase {
|
|
|
96414
97347
|
};
|
|
96415
97348
|
}
|
|
96416
97349
|
};
|
|
97350
|
+
// src/agent/merge-persona.ts
|
|
97351
|
+
function merge(metadata, persona) {
|
|
97352
|
+
const code = metadata?.persona;
|
|
97353
|
+
const base = code && typeof code === "object" && !Array.isArray(code) ? code : {};
|
|
97354
|
+
const set = Object.fromEntries(Object.entries(persona).filter(([, value]) => value !== void 0));
|
|
97355
|
+
return {
|
|
97356
|
+
...metadata,
|
|
97357
|
+
persona: {
|
|
97358
|
+
...base,
|
|
97359
|
+
...set
|
|
97360
|
+
}
|
|
97361
|
+
};
|
|
97362
|
+
}
|
|
97363
|
+
/**
|
|
97364
|
+
* Overrides an Agent's `metadata.persona` field by field: a field `persona` sets wins, a field it leaves
|
|
97365
|
+
* unset keeps the code's value, and keys outside `persona` stay as they are. Function-form metadata is
|
|
97366
|
+
* wrapped so the override applies to whatever it resolves to.
|
|
97367
|
+
* @experimental
|
|
97368
|
+
*/
|
|
97369
|
+
function mergeAgentPersona(metadata, persona) {
|
|
97370
|
+
if (typeof metadata !== "function") return merge(metadata, persona);
|
|
97371
|
+
return async (context) => merge(await metadata(context), persona);
|
|
97372
|
+
}
|
|
96417
97373
|
// ../_internal-core/dist/fs-routing/index.js
|
|
96418
97374
|
/**
|
|
96419
97375
|
* Maximum nesting depth for declared subagents. A top-level agent is depth 0;
|
|
@@ -103080,6 +104036,12 @@ function createToolCallStep({ tools, messageList, options, outputWriter, control
|
|
|
103080
104036
|
args = argsFromInput;
|
|
103081
104037
|
resumeDataFromArgs = resumeDataFromInput;
|
|
103082
104038
|
}
|
|
104039
|
+
if (typeof args === "object" && args !== null) args = sanitizeToolArguments({
|
|
104040
|
+
args,
|
|
104041
|
+
toolName: inputData.toolName,
|
|
104042
|
+
toolConfig: tool?.backgroundConfig,
|
|
104043
|
+
agentConfig: readScoped(scopeCtx, AGENT_BACKGROUND_CONFIG_KEY, "agentBackgroundConfig")
|
|
104044
|
+
});
|
|
103083
104045
|
const resumeData = resumeDataFromArgs ?? workflowResumeData;
|
|
103084
104046
|
const isResumeToolCall = resumeDataFromArgs != null;
|
|
103085
104047
|
const approvalVerdicts = readScoped(scopeCtx, TOOL_APPROVAL_VERDICTS_KEY, "toolApprovalVerdicts");
|
|
@@ -107910,6 +108872,11 @@ var AgentThreadStreamRuntime = class {
|
|
|
107910
108872
|
record.lifecycle = "completed";
|
|
107911
108873
|
this.#clearSuspendedRun(state, record.runId);
|
|
107912
108874
|
state.threadRunsByStreamId.delete(record.streamId);
|
|
108875
|
+
if (state.threadRunsById.get(record.runId) === record) for (const [streamId, other] of state.threadRunsByStreamId) {
|
|
108876
|
+
if (other.runId !== record.runId || other.lifecycle !== "suspended") continue;
|
|
108877
|
+
state.threadRunsByStreamId.delete(streamId);
|
|
108878
|
+
state.watchedThreadStreamIds.delete(streamId);
|
|
108879
|
+
}
|
|
107913
108880
|
if (state.threadRunsById.get(record.runId) === record) {
|
|
107914
108881
|
state.threadRunsById.delete(record.runId);
|
|
107915
108882
|
state.threadKeysByRunId.delete(record.runId);
|
|
@@ -110686,4 +111653,4 @@ var ExtendedRunRegistry = class extends RunRegistry {
|
|
|
110686
111653
|
this.#memoryInfo.clear();
|
|
110687
111654
|
}
|
|
110688
111655
|
};
|
|
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 };
|
|
111656
|
+
export { isSpanChunk as $, threadQueryRequestSchema as $a, createMappingStep as $c, parseKnowledgePageRef as $i, ProcessorStepSchema as $l, DEFAULT_CHANNEL_TOOLS_SETTINGS as $n, getStorageSource as $o, InMemoryNotificationsStorage as $r, WorkflowEventProcessor as $s, PINNED_READ_MEMO_KEY as $t, agentInstructions as A, filterByDateRange as Aa, cloneStep$1 as Ac, inspectKnowledgeSchema as Ai, validateStepSuspendData as Al, knowledgeMemoryScopes as An, getObjectOrNull as Ao, StoreOperationsInMemory as Ar, PromptInjectionDetector as As, ensureRemoteAbortListener as At, detachFullStreamOnEnd as B, transformScoreRow as Ba, nestedRunStatusOf as Bc, MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS as Bi, FilePartSchema as Bl, resolveChannelRenderContext as Bn, MESSAGE_EMBEDDING_CHARS_PER_TOKEN as Bo, WorkflowsStorage as Br, isBadRequestError as Bs, formatCheckFeedback as Bt, MastraScorer as C, resolveRetentionTargets as Ca, CONTROLLER_RUN_BINDING_KEY as Cc, KnowledgeNotFoundError$1 as Ci, resolveForeachConcurrency as Cl, syncKnowledgePageBodyLinks as Cn, planTraceQuery as Co, expandKnowledgeScope as Cr, normalizeMessageHistoryConfig as Cs, endFailedSegmentSpans as Ct, isNotScorable as D, createStoreErrorId as Da, getStepEntry as Dc, KnowledgeUnsupportedCapabilityError as Di, validateStepRequestContext as Dl, knowledgeRoleOn as Dn, buildMetricRecord as Do, knowledgeSemanticIdempotencyKey as Dr, StructuredOutputProcessor as Ds, runDurableStreamUntilIdle as Dt, filterRun as E, createStorageErrorId as Ea, getNestedWorkflow as Ec, KnowledgeTransactionDeadlineError as Ei, validateStepInput as El, knowledgeReadScopeFor as En, buildLogRecord as Eo, knowledgeSemanticDocumentId as Er, ClassifierProcessor as Es, segmentSpanData as Et, Agent as F, parseDuration as Fa, evaluatePredicate as Fc, KnowledgePageKeyConflictError as Fi, waitMs as Fl, encodeKnowledgeScopeId as Fn, ObservabilityStorage as Fo, FilesystemDB as Fr, isMalformedFunctionCallError as Fs, untilIdleHandlesBackgroundTask as Ft, createDurableToolCallStep as G, tracePageNodeSchema as Ga, WORKFLOW_RUN_LEASE_TTL_MS as Gc, assertKnowledgeNoteTextWithinBound as Gi, ProcessorInputStepPhaseSchema as Gl, markNewChannelThread as Gn, resolveMaxChunkChars as Go, WorkflowDefinitionsStorage as Gr, createEventedWorkflow as Gs, generateStructuredFinalResult as Gt, createDurableGoalStep as H, TracePageError as Ha, SCORING_PREDICATE_ROOTS as Hc, MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH as Hi, MessageContentSchema as Hl, REPLY_TOOL_NAME as Hn, chunkMessageText as Ho, mergeStepResult as Hr, PrefillErrorHandler as Hs, formatStreamCompletionFeedback as Ht, normalizeResumeGenerateArgs as I, safelyParseJSON as Ia, cancelNestedRun as Ic, MAX_KNOWLEDGE_MOVE_PAGES as Ii, workflowTermination as Il, buildKnowledgeInstructions as In, FactoryStorage as Io, InMemoryStore as Ir, UnsupportedFileHandler as Is, pruneAgentLoopSnapshot as It, serializeDurableState as J, THREAD_QUERY_DEFAULT_LIMIT as Ja, runFenceConflictOf as Jc, knowledgeLinkRefKey as Ji, ProcessorOutputResultPhaseSchema as Jl, renderBuiltInToolEvent as Jn, MemoryProcessor as Jo, ScoresInMemory as Jr, EventedWorkflow as Js, runDefaultCompletionCheck as Jt, createWorkflowInput as K, tracePageRequestSchema as Ka, renewWorkflowLease as Kc, assertKnowledgePageDescriptionWithinBound as Ki, ProcessorMessageContentSchema as Kl, ChatChannelProcessor as Kn, upsertMessageVectors as Ko, InMemoryToolProviderConnectionsStorage as Kr, createWorkflow as Ks, runChecks as Kt, prepareForDurableExecution as L, serializeDate as La, createNestedRunParentStatusLookup as Lc, MAX_KNOWLEDGE_NOTE_TOKENS as Li, hasDurableExecution as Ll, AgentChannels as Ln, FactoryStorageDomain as Lo, MockStore as Lr, FileUploadProcessor as Ls, DEFAULT_TOOL_DECLINE_REASON as Lt, MAX_FS_SUBAGENT_DEPTH as M, getSqlType as Ma, isProcessor$1 as Mc, KnowledgeMoveTooLargeError as Mi, getEntryId as Ml, knowledgeScopeAddress as Mn, serializeSpanAttributes as Mo, GitHubSourceControlProvider as Mr, UnicodeNormalizer as Ms, __registerMastraCtor as Mt, mergeAgentPersona as N, hasErrorCode as Na, mapVariable as Nc, KnowledgePageDepthError as Ni, getEntryWorkflow as Nl, strongerKnowledgeRole as Nn, toEntityType as No, createGitHubSourceControlProviderFromEnv as Nr, STABILITY_ERROR_PROCESSOR_IDS as Ns, getRunStreamSlot as Nt, notScorable as O, createVectorErrorId as Oa, Run as Oc, assertKnowledgeSchemaCompatible as Oi, validateStepResumeData as Ol, KnowledgeDeclarationError as On, buildScoreRecord as Oo, knowledgeVisibleScopeKeys as Or, LanguageDetector as Os, runResumeDurableStreamUntilIdle as Ot, AGENT_RESUME_CLAIM_STALE_MS as P, jsonValueEquals as Pa, predicateToCondition as Pc, KnowledgePageHasChildrenError as Pi, assertDrainTimeout as Pl, decodeKnowledgeScopeId as Pn, ObservabilityInMemory as Po, FilesystemStore as Pr, defaultStabilityErrorProcessors as Ps, getScopeStreamSlot as Pt, MessagePartSpans as Q, threadQueryIdentitySchema as Qa, runWithConcurrency as Qc, knowledgeScopeReadable as Qi, ProcessorStepOutputSchema as Ql, ChannelSessionRejectedError as Qn, augmentWithInit as Qo, normalizeScheduleTarget as Qr, createWorkflow$1 as Qs, validateModelTimeoutSettings as Qt, applyReservedMemoryContextKeys as R, storageMessageMatchesMetadataFilter as Ra, nestedRunParentOf as Rc, MAX_KNOWLEDGE_PAGE_BODY_LINKS as Ri, hasResumableStreams as Rl, resolveWaitUntil as Rn, UniqueViolationError as Ro, WorkflowsInMemory as Rr, FILE_UPLOAD_ERROR_CODES as Rs, resolveDeclineReason as Rt, createClassifierScorer as S, executeRetentionPrune as Sa, AgentStreamEventTypes as Sc, KnowledgeConflictError as Si, omitPriorSuspensionFields as Sl, repairKnowledgeLinks as Sn, planThreadQuery as So, createKnowledgeNodeCursor as Sr, isAfterMemoryTokenBoundary as Ss, carrySegmentSpans as St, createScorer as T, runRetentionBatches as Ta, EventedExecutionEngine as Tc, KnowledgeStorage as Ti, setLongTimeout as Tl, knowledgeAccessGrants as Tn, buildFeedbackRecord as To, knowledgeScopeKey as Tr, ModelSelectionProcessor as Ts, segmentEndedBySuspension as Tt, createDurableIsTaskCompleteStep as U, readTracePage as Ua, evaluateScoringPredicate as Uc, MAX_KNOWLEDGE_PAGE_LIST_LIMIT as Ui, MessagePartSchema as Ul, ChannelThreadLinkProcessor as Un, extractMessageEmbeddingText as Uo, mergeWorkflowStepResult as Ur, getGoalActivityDurationMs as Us, formatValidationFeedback as Ut, createDurableAgenticWorkflow as V, validateStorageMetadataFilter as Va, DefaultExecutionEngine as Vc, MAX_KNOWLEDGE_PAGE_LINKS as Vi, ImagePartSchema as Vl, MastraStateAdapter as Vn, buildMessageEmbeddingRows as Vo, createEmptyWorkflowSnapshot as Vr, isRetryableOpenAIResponsesStreamError as Vs, formatCompletionFeedback as Vt, createDurableLLMMappingStep as W, tracePageIdSchema as Wa, validateScoringPredicate as Wc, MAX_KNOWLEDGE_PIN_LIST_DEPTH as Wi, ProcessorInputPhaseSchema as Wl, NEW_CHANNEL_THREAD_KEY as Wn, messageVectorId as Wo, InMemoryWorkflowDefinitionsStorage as Wr, cloneWorkflow as Ws, generateFinalResult as Wt, serializeToolsMetadata as X, encodeThreadQueryCursor as Xa, createConcurrencyLimiter as Xc, knowledgePinDepth as Xi, ProcessorOutputStreamPhaseSchema as Xl, CONTINUE_RUN_MESSAGE as Xn, filterSystemReminderMessages as Xo, InMemorySchedulesStorage as Xr, cloneWorkflow$1 as Xs, runValidation as Xt, serializeModelConfig as Y, THREAD_QUERY_MAX_LIMIT as Ya, ExecutionEngine as Yc, knowledgePagePath as Yi, ProcessorOutputStepPhaseSchema as Yl, CONTINUE_RUN_ACTION_ID as Yn, memoryDefaultOptions as Yo, ScoresStorage as Yr, cloneStep as Ys, runStreamCompletionScorers as Yt, createDurableLLMExecutionStep as Z, planThreadRowsQuery as Za, normalizeConcurrency as Zc, knowledgePositionBetween as Zi, ProcessorStepInputSchema as Zl, formatToolApproval as Zn, isSystemReminderMessage as Zo, SchedulesStorage as Zr, createStep as Zs, loop as Zt, describeNonSuccessFinishReason as _, ChannelsStorage as _a, DurableAgentDefaults as _c, KnowledgeImporterBindingConflictError as _i, getStepIds as _l, KnowledgeLinkRepairUnsupportedError as _n, spanQueryResponseSchema as _o, assertKnowledgeCeilingRaised as _r, TokenLimiterProcessor as _s, resolveRuntimeDependencies as _t, runFencingNotSupportedError as _u, deleteRunRegistryEntry as a, ExperimentsStorage as aa, emitChunkEvent as ac, notificationSignalMetadata as ai, abortableSleep as al, knowledgeRunPrincipals as an, SPAN_QUERY_MAX_PREVIEW_CHARACTERS as ao, BaseProcessor as ar, buildResponseCacheKey as as, accumulatedUsageSchema as at, isAgentCompatible as au, createOnScorerHook as b, BackgroundTasksInMemory as ba, AGENT_STREAM_TOPIC as bc, KNOWLEDGE_STORAGE_CONTRACT_VERSION as bi, isSingleStepEntry as bl, refreshKnowledgeLinksTo as bn, encodeTraceQueryDeltaCursor as bo, assertKnowledgeScopeWithinCeiling as br, advanceMemoryTokenBoundary as bs, resolveAgentById as bt, getRunRegistryEntry as c, DatasetItemIdentityConflictError as ca, emitStepFinishEvent as cc, summarizeNotifications as ci, cleanStepResult as cl, addKnowledgeNote as cn, createSpanQueryPreview as co, globalEmbeddingCache as cr, SkillsProcessor as cs, durableAgenticOutputSchema as ct, isWorkflowStepConflictError as cu, setRunRegistryEntry as d, createValidator as da, AgentStreamBus as dc, defaultNotificationDeliveryDecision as di, createTimeTravelExecutionParams as dl, removeKnowledgePage as dn, planSpanQuery as do, MemoryRunState as dr, AgentsMDInjector as ds, executeDurableAgentScorers as dt, RunFenceConflictError as du, KnowledgeInvalidCursorError as ea, StepExecutor as ec, NotificationsStorage as ei, createStepFromAgent$1 as el, knowledgeDeliveredPins as en, threadQueryResponseSchema as eo, channelToolScopeResolver as er, createBackgroundWorkSignalProcessor as es, createDurableBackgroundTaskCheckStep as et, ReasoningPartSchema as eu, takeRunScorerInstances as f, getSchemaValidator as fa, publishAbortRequest as fc, resolveDeliveryFailureUpdate as fi, defineLazyWriter as fl, updateKnowledgeNote as fn, resolveSpanQueryCost as fo, getMemoryRunState as fr, ToolCallFilter as fs, runDurableFinishSideEffects as ft, coverNestedRun as fu, AGENTIC_LOOP_WORKFLOW_ID as g, InMemoryChannelsStorage as ga, DURABLE_STOP_WHEN_ERROR_ID as gc, InMemoryKnowledgeStorage as gi, getSingleStepEntryId as gl, KnowledgeLinkRefreshIncompleteError as gn, spanQueryRequestSchema as go, MAX_KNOWLEDGE_SCOPE_TAGS as gr, SystemPromptScrubber as gs, resolveModel as gt, resolveRunFence as gu, AGENTIC_EXECUTION_WORKFLOW_ID as h, SchemaValidationError as ha, createRunAbortController as hc, MemoryStorage as hi, getResumeLabelsByStepId as hl, embed$2 as hn, spanQueryIdentitySchema as ho, MAX_KNOWLEDGE_RECORD_TEXT_LENGTH as hr, TokenCostControl as hs, resolveInternalState as ht, matchesRunFence as hu, abandonDurableAgentExecutions as i, ExperimentsInMemory as ia, emitAbortEvent as ic, notificationSignalAttributes as ii, RESUME_SNAPSHOT_WAIT_STATUSES as il, KnowledgeRunScopesError as in, SPAN_QUERY_MAX_LIMIT as io, toChatLogger as ir, ResponseCache as is, createBaseIterationStateUpdate as it, ToolInvocationPartSchema as iu, assembleAgentFromFsEntry as j, getDefaultValue as ja, createStep$1 as jc, parseKnowledgeWikilinks as ji, waitForSuspendedSnapshot as jl, knowledgeRunScopes as jn, getStringOrNull as jo, StoreOperations as jr, ModerationProcessor as js, readRunDeadline as jt, agentConfig as k, ensureDate as ka, Workflow as kc, createKnowledgeUlid as ki, validateStepStateData as kl, compileKnowledgeScopes as kn, buildUpdateSpanRecord as ko, parseKnowledgeNodeCursor as kr, PIIDetector as ks, RUN_DEADLINE_KEY as kt, globalRunRegistry as l, SchemaValidator as la, emitStepStartEvent as lc, readNotificationRoutingRequirement as li, createDeprecationProxy as ll, moveKnowledgePage as ln, encodeSpanQueryCursor as lo, WorkingMemory as lr, formatSkillsCatalog as ls, modelConfigSchema as lt, RUN_FENCE_CONFLICT_ERROR_ID as lu, agentThreadStreamRuntime as m, SchemaUpdateValidationError as ma, subscribeToAbortRequests as mc, InMemoryMemory as mi, getRestartStartIndex as ml, KnowledgeSemanticIndex as mn, spanQueryIdentityKey as mo, MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH as mr, CostGuardProcessor as ms, rebuildRunToolsFromMastra as mt, isRunFenceConflictError as mu, ExtendedRunRegistry as n, InMemoryHarness as na, __resetExecutionFencesForTests as nc, createNotificationSignal as ni, createStepFromTool as nl, heldScopes as nn, SPAN_QUERY_MAX_COST_METRICS as no, createChannelTools as nr, DEFAULT_RESPONSE_CACHE_TTL_SECONDS as ns, buildStepRecord as nt, StepStartPartSchema as nu, endRunSpansWithError as o, DatasetsInMemory as oa, emitErrorEvent as oc, notificationSummaryContents as oi, applyStateDelta as ol, knowledgeAgentScopes as on, SPAN_QUERY_ORDER_FIELDS as oo, MemoryInputFilter as or, WorkspaceInstructionsProcessor as os, baseDurableAgenticInputSchema as ot, WorkflowStepConflictError as ou, AgentThreadLeaseLostError as p, UnsupportedSchemaPatternError as pa, requestAcknowledgedAbort as pc, resolveNotificationDeliveryDecision as pi, defineStateAccessors as pl, upsertKnowledgePage as pn, spanQueryCostSchema as po, MockMemory as pr, RegexFilterProcessor as ps, loadRunStoredMessages as pt, currentRunGeneration as pu, serializeDurableOptions as q, tracePageResponseSchema as qa, repeatAfterSettled as qc, canonicalKnowledgeName as qi, ProcessorMessageSchema as ql, CHAT_CHANNEL_RENDER_CONTEXT_KEY as qn, MastraMemory as qo, ToolProviderConnectionsStorage as qr, EventedRun as qs, runCompletionScorers as qt, RunRegistry as r, HarnessStorage as ra, diffResponseMessages as rc, createNotificationSummarySignal as ri, RESUME_SNAPSHOT_POLL_INTERVAL_MS as rl, KnowledgeRun as rn, SPAN_QUERY_MAX_CURSOR_BYTES as ro, resolveChannelToolsSettings as rr, RESPONSE_CACHE_CONTEXT_KEY as rs, calculateAccumulatedUsage as rt, TextPartSchema as ru, getActiveDurableAgentWorkflowExecutions as s, DatasetsStorage as sa, emitFinishEvent as sc, notificationSummarySignalMetadata as si, assertTimeTravelGraphMatchesSnapshot as sl, knowledgePersonaScopes as sn, buildSpanQueryResponse as so, SemanticRecall as sr, SkillSearchProcessor as ss, baseIterationStateSchema as st, assertWorkflowStepGuard as su, DURABLE_CONTEXT_SEGMENT_KEY as t, knowledgePageKeyProblem as ta, computeScheduleDefinitionHash as tc, dispatchDueNotifications as ti, createStepFromClassifier as tl, buildKnowledgePageTools as tn, threadQueryRowSchema as to, createChannelToolScope as tr, CyberRefusalHandler as ts, resolveDurableToolCallConcurrency as tt, SourcePartSchema as tu, isDurableAgentExecutionDetached as u, assertSupportedPatterns as ua, emitSuspendedEvent as uc, MAX_NOTIFICATION_DELIVERY_ATTEMPTS as ui, createRestartExecutionParams as ul, removeKnowledgeNote as un, parseSpanQueryRequest as uo, MessageHistory as ur, ToolSearchProcessor as us, modelListEntrySchema as ut, RUN_FENCING_NOT_SUPPORTED_ERROR_ID as uu, runEvals as v, InMemoryBlobStore as va, DurableStepIds as vc, KnowledgeImporterRunStateError as vi, hydrateSerializedStepErrors as vl, canRepairKnowledgeLinksInBatch as vn, spanQueryRowSchema as vo, assertKnowledgeDescriptionWithinBound as vr, groupLinkedToolMessages as vs, resolveTool$1 as vt, runOutsideRunFenceScope as vu, ScorerRunError as w, retentionCutoffMs as wa, restoredWorkerControllerContexts as wc, KnowledgeSchemaResetRequiredError as wi, runCountDeprecationMessage as wl, updateKnowledgeLinks as wn, buildCreateSpanRecord as wo, isKnowledgeScopeVisible as wr, BatchPartsProcessor as ws, liveSegmentSpan as wt, validateAndSaveScore as x, BackgroundTasksStorage as xa, AgentControlEventTypes as xc, KNOWLEDGE_STORAGE_SCHEMA_VERSION as xi, omitPriorCompletionFields as xl, reindexKnowledgeLinks as xn, getTraceQueryDeltaWatermark as xo, canonicalizeKnowledgeScope as xr, getMemoryTokenBoundary as xs, createDurableAgentStream as xt, flushBeforeTraceRead as y, BlobStore as ya, AGENT_CONTROL_TOPIC as yc, KnowledgeImportersStorage as yi, isEntryFinished as yl, knowledgeSubtree as yn, encodeTraceQueryCursor as yo, assertKnowledgeRecordTextWithinBound as yr, loadMessageHistory as ys, toolRequiresApproval as yt, setRunFenceContext as yu, persistDurableRunInput as z, transformRow as za, nestedRunRecoveryAction as zc, MAX_KNOWLEDGE_PAGE_DEPTH as zi, isDurableAgentLike as zl, defaultTypingStatus as zn, DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS as zo, cloneRunData as zr, StreamErrorRetryProcessor as zs, getServerSideFallbackInfo as zt };
|