@mastra/core 1.87.0-alpha.7 → 1.87.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent.d.ts +3 -1
- package/dist/agent/durable/index.cjs +1 -1
- package/dist/agent/durable/index.js +1 -1
- package/dist/agent/index.cjs +3 -2
- package/dist/agent/index.d.ts +2 -0
- package/dist/agent/index.js +3 -3
- package/dist/agent/merge-persona.d.ts +15 -0
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +2 -2
- package/dist/agent-controller/index.js +2 -2
- package/dist/{agent-controller-QGBVBDRi.cjs → agent-controller-ZCQy7cOG.cjs} +7 -7
- package/dist/{agent-controller-GM-2_7C2.js → agent-controller-fazk0U_b.js} +7 -7
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-C-3AqSKL.cjs → background-tasks-B63welNM.cjs} +1 -1
- package/dist/{background-tasks-lHCVpHbm.js → background-tasks-DlLB_pJR.js} +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-C9UYOrxv.js → builder-D82iR2oQ.js} +2 -2
- package/dist/{builder-mGGr3IhH.cjs → builder-DCaL4xmU.cjs} +2 -2
- package/dist/capabilities/302ai.json +196 -196
- package/dist/capabilities/abliteratedllm.json +43 -34
- package/dist/capabilities/abliteration-ai.json +9 -9
- package/dist/capabilities/above.json +18 -18
- package/dist/capabilities/adaption.json +12 -12
- package/dist/capabilities/adzuki.json +28 -28
- package/dist/capabilities/agentrouter.json +10 -10
- package/dist/capabilities/agnes.json +2 -2
- package/dist/capabilities/ai-router.json +6 -6
- package/dist/capabilities/aiand.json +20 -20
- package/dist/capabilities/aigrow.json +10 -10
- package/dist/capabilities/aimlapi.json +143 -143
- package/dist/capabilities/aipg.json +2 -2
- package/dist/capabilities/aixy.json +23 -23
- package/dist/capabilities/aki-io.json +14 -14
- package/dist/capabilities/alibaba-cn.json +100 -94
- package/dist/capabilities/alibaba-coding-plan-cn.json +4 -4
- package/dist/capabilities/alibaba-coding-plan.json +4 -4
- package/dist/capabilities/alibaba-token-plan-cn.json +47 -47
- package/dist/capabilities/alibaba-token-plan.json +47 -47
- package/dist/capabilities/alibaba.json +63 -63
- package/dist/capabilities/ambient.json +14 -14
- package/dist/capabilities/amd.json +10 -10
- package/dist/capabilities/anthropic.json +42 -42
- package/dist/capabilities/anyapi.json +47 -47
- package/dist/capabilities/arcee.json +10 -10
- package/dist/capabilities/augure.json +5 -5
- package/dist/capabilities/auriko.json +21 -21
- package/dist/capabilities/bailing.json +4 -4
- package/dist/capabilities/baseten.json +34 -34
- package/dist/capabilities/bee.json +3 -3
- package/dist/capabilities/berget.json +18 -5
- package/dist/capabilities/bothub.json +15 -15
- package/dist/capabilities/boundless.json +35 -35
- package/dist/capabilities/bumo.json +43 -43
- package/dist/capabilities/byteplus.json +29 -29
- package/dist/capabilities/cheapaimodel.json +6 -6
- package/dist/capabilities/cheapest-token.json +28 -28
- package/dist/capabilities/chutes.json +9 -9
- package/dist/capabilities/clarifai.json +2 -2
- package/dist/capabilities/claudinio.json +10 -1
- package/dist/capabilities/cline-pass.json +40 -40
- package/dist/capabilities/cloudcode.json +10 -17
- package/dist/capabilities/cloudferro-sherlock.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +20 -20
- package/dist/capabilities/commandcode.json +148 -148
- package/dist/capabilities/concentrate.json +268 -268
- package/dist/capabilities/cortecs.json +104 -104
- package/dist/capabilities/crossmodel.json +172 -172
- package/dist/capabilities/crusoe.json +35 -6
- package/dist/capabilities/daoxe.json +8 -8
- package/dist/capabilities/databricks.json +126 -126
- package/dist/capabilities/deepinfra.json +105 -105
- package/dist/capabilities/deepseek.json +4 -4
- package/dist/capabilities/digitalocean.json +115 -115
- package/dist/capabilities/dothoosh.json +32 -32
- package/dist/capabilities/doubleword.json +26 -26
- package/dist/capabilities/edenai.json +281 -277
- package/dist/capabilities/empiriolabs.json +164 -164
- package/dist/capabilities/engy.json +10 -10
- package/dist/capabilities/entrim.json +5 -5
- package/dist/capabilities/evroc.json +13 -13
- package/dist/capabilities/ezkielyna.json +8 -8
- package/dist/capabilities/fastrouter.json +88 -88
- package/dist/capabilities/fireworks-ai.json +92 -92
- package/dist/capabilities/fortytwo.json +9 -3
- package/dist/capabilities/freemodel.json +18 -18
- package/dist/capabilities/friendli.json +8 -8
- package/dist/capabilities/frogbot.json +100 -100
- package/dist/capabilities/gisoo.json +20 -20
- package/dist/capabilities/gmicloud.json +16 -16
- package/dist/capabilities/google.json +48 -48
- package/dist/capabilities/graphn.json +13 -13
- package/dist/capabilities/greenpt.json +37 -37
- package/dist/capabilities/groq.json +2 -2
- package/dist/capabilities/helicone.json +78 -78
- 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 +31 -31
- package/dist/capabilities/huggingface.json +84 -174
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +19 -19
- package/dist/capabilities/impossibl.json +171 -171
- package/dist/capabilities/inception.json +3 -3
- package/dist/capabilities/inceptron.json +4 -4
- package/dist/capabilities/inco.json +4 -4
- package/dist/capabilities/infer.json +19 -19
- package/dist/capabilities/inferall.json +11 -11
- package/dist/capabilities/inference-coop.json +15 -15
- package/dist/capabilities/inferenceapis.json +24 -24
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +13 -13
- package/dist/capabilities/inferx.json +2 -2
- package/dist/capabilities/infomaniak.json +2 -2
- package/dist/capabilities/io-net.json +4 -4
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +56 -56
- package/dist/capabilities/jad-ai.json +3 -3
- package/dist/capabilities/jalapeno.json +10 -10
- package/dist/capabilities/jiekou.json +64 -64
- package/dist/capabilities/jzstoken.json +50 -51
- package/dist/capabilities/keln.json +22 -22
- package/dist/capabilities/kenari.json +123 -123
- package/dist/capabilities/kilo.json +601 -601
- package/dist/capabilities/kimi-code-plan-cn.json +6 -6
- package/dist/capabilities/kimi-code-plan-global.json +6 -6
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +22 -22
- package/dist/capabilities/korouter.json +34 -34
- package/dist/capabilities/kunavo.json +7 -7
- package/dist/capabilities/liquid.json +12 -12
- package/dist/capabilities/llmgateway-providers.json +934 -934
- package/dist/capabilities/llmgateway.json +334 -334
- package/dist/capabilities/llmtr.json +34 -34
- package/dist/capabilities/lowrouter.json +58 -58
- package/dist/capabilities/lyceum.json +18 -10
- package/dist/capabilities/melious.json +17 -17
- package/dist/capabilities/merge-gateway.json +255 -254
- package/dist/capabilities/meta.json +10 -10
- package/dist/capabilities/minimax-cn-coding-plan.json +5 -5
- package/dist/capabilities/minimax-cn.json +5 -5
- package/dist/capabilities/minimax-coding-plan.json +5 -5
- package/dist/capabilities/minimax.json +5 -5
- package/dist/capabilities/mistral.json +22 -22
- package/dist/capabilities/mixlayer.json +2 -2
- package/dist/capabilities/modal.json +12 -12
- 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 +11 -11
- package/dist/capabilities/moonshotai-cn.json +6 -6
- package/dist/capabilities/moonshotai.json +6 -6
- package/dist/capabilities/morph.json +18 -18
- package/dist/capabilities/munito-eu.json +6 -6
- package/dist/capabilities/munito.json +8 -8
- package/dist/capabilities/nan.json +23 -23
- package/dist/capabilities/nano-gpt.json +565 -571
- package/dist/capabilities/nearai.json +93 -93
- package/dist/capabilities/nebius.json +32 -32
- package/dist/capabilities/neon.json +129 -129
- package/dist/capabilities/neuralwatt.json +42 -42
- package/dist/capabilities/nokeep.json +5 -5
- package/dist/capabilities/novita-ai.json +135 -135
- package/dist/capabilities/nvidia.json +49 -32
- package/dist/capabilities/oathbreaker.json +26 -3
- package/dist/capabilities/obscurify.json +27 -27
- package/dist/capabilities/oci.json +6 -6
- package/dist/capabilities/ofox.json +302 -302
- package/dist/capabilities/ollama-cloud.json +59 -59
- package/dist/capabilities/openai.json +58 -58
- package/dist/capabilities/opencode-go.json +78 -78
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +526 -526
- package/dist/capabilities/opper.json +27 -27
- package/dist/capabilities/orcarouter.json +243 -243
- package/dist/capabilities/outerlabs.json +32 -32
- package/dist/capabilities/ovhcloud.json +21 -21
- package/dist/capabilities/pareto.json +6 -6
- package/dist/capabilities/perplexity-agent.json +57 -57
- package/dist/capabilities/perplexity.json +2 -2
- package/dist/capabilities/phala.json +34 -34
- package/dist/capabilities/pioneer.json +34 -34
- package/dist/capabilities/poe.json +129 -129
- package/dist/capabilities/poolside.json +3 -3
- package/dist/capabilities/powerspring.json +12 -12
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +113 -113
- package/dist/capabilities/privatemode-ai.json +14 -14
- package/dist/capabilities/proxystacks.json +7 -7
- package/dist/capabilities/qiniu-ai.json +14 -14
- package/dist/capabilities/refuseless.json +6 -6
- package/dist/capabilities/regolo-ai.json +10 -10
- package/dist/capabilities/requesty.json +371 -167
- package/dist/capabilities/ruapi.json +33 -17
- package/dist/capabilities/runcrate.json +10 -10
- package/dist/capabilities/runinfra.json +14 -14
- package/dist/capabilities/sakana.json +7 -7
- package/dist/capabilities/sambanova.json +9 -9
- package/dist/capabilities/sandbase.json +18 -18
- package/dist/capabilities/sarvam.json +11 -11
- package/dist/capabilities/scaleway.json +19 -19
- package/dist/capabilities/scnet-token-plan.json +11 -11
- package/dist/capabilities/scx-ai.json +27 -27
- package/dist/capabilities/sensenova.json +13 -13
- package/dist/capabilities/siliconflow-cn.json +55 -55
- package/dist/capabilities/siliconflow.json +63 -63
- package/dist/capabilities/snowflake-cortex.json +25 -25
- package/dist/capabilities/sokkan.json +2 -2
- package/dist/capabilities/sparrowcodes.json +22 -22
- package/dist/capabilities/standardcompute.json +97 -97
- package/dist/capabilities/steadyrouter.json +36 -36
- package/dist/capabilities/stepfun-ai-step-plan.json +4 -4
- package/dist/capabilities/stepfun-ai.json +4 -4
- package/dist/capabilities/stepfun-step-plan.json +4 -4
- package/dist/capabilities/stepfun.json +4 -4
- package/dist/capabilities/stepping-stone.json +19 -19
- package/dist/capabilities/superbot-gg.json +4 -4
- package/dist/capabilities/synthetic.json +9 -9
- package/dist/capabilities/synthorai.json +26 -26
- package/dist/capabilities/teamorouter.json +16 -16
- package/dist/capabilities/teapot-router.json +14 -14
- package/dist/capabilities/tencent-token-plan-intl.json +21 -21
- package/dist/capabilities/tencent-token-plan.json +42 -42
- package/dist/capabilities/tencent-tokenhub.json +49 -49
- package/dist/capabilities/tensorx.json +48 -48
- package/dist/capabilities/tenstorrent.json +8 -8
- package/dist/capabilities/the-grid-ai.json +34 -34
- package/dist/capabilities/thinkingmachines.json +78 -78
- package/dist/capabilities/tinfoil.json +13 -13
- package/dist/capabilities/togetherai.json +44 -44
- 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 +19 -19
- package/dist/capabilities/umans-ai-coding-plan.json +14 -14
- package/dist/capabilities/umans-ai.json +10 -10
- package/dist/capabilities/unrestricted.json +6 -6
- package/dist/capabilities/uplinkswitch.json +20 -20
- package/dist/capabilities/upstage.json +6 -6
- package/dist/capabilities/vancine.json +25 -25
- package/dist/capabilities/vercel.json +552 -551
- package/dist/capabilities/vivgrid.json +74 -65
- package/dist/capabilities/volcengine-coding-plan.json +27 -27
- package/dist/capabilities/volcengine.json +29 -28
- package/dist/capabilities/vultr.json +25 -25
- package/dist/capabilities/wafer.ai.json +17 -17
- package/dist/capabilities/wallaby.json +4 -4
- package/dist/capabilities/wally.json +14 -14
- package/dist/capabilities/wandb.json +19 -19
- package/dist/capabilities/watt.json +25 -25
- package/dist/capabilities/xai.json +6 -6
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
- package/dist/capabilities/xiaomi.json +2 -2
- package/dist/capabilities/xpersona.json +12 -12
- package/dist/capabilities/xxapi.json +27 -27
- package/dist/capabilities/zai-coding-plan.json +12 -12
- package/dist/capabilities/zai.json +32 -32
- package/dist/capabilities/zenifra.json +27 -27
- package/dist/capabilities/zenmux.json +190 -190
- package/dist/capabilities/zerogpu.json +14 -14
- package/dist/capabilities/zhipuai-coding-plan.json +8 -8
- package/dist/capabilities/zhipuai.json +31 -31
- package/dist/capabilities/zro.json +6 -6
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-dBz-1Oy7.cjs → channels-BXZbY7TL.cjs} +1 -1
- package/dist/{channels-CyJ0PpSg.js → channels-Bs8wDPDl.js} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/datasets/index.cjs +2 -2
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +722 -707
- package/dist/docs/references/docs-agents-code-mode.md +20 -0
- package/dist/docs/references/docs-browser.md +3 -1
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +2 -0
- package/dist/docs/references/integrations.md +1 -0
- package/dist/docs/references/reference-processors-tool-search-processor.md +3 -3
- package/dist/docs/references/reference-tools-create-code-mode.md +22 -0
- package/dist/evals/index.cjs +1 -1
- package/dist/evals/index.js +1 -1
- package/dist/evals/scoreTraces/index.cjs +1 -1
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/index.cjs +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/types.d.ts +2 -0
- package/dist/knowledge/index.cjs +65 -15
- package/dist/knowledge/index.d.ts +6 -0
- package/dist/knowledge/index.js +64 -16
- package/dist/knowledge/page-tools.d.ts +14 -0
- package/dist/knowledge/run.d.ts +1 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +8041 -8014
- package/dist/{llm-Du8yTHDN.js → llm-9xmy8HlF.js} +2 -2
- package/dist/{llm-BiSuGioB.cjs → llm-ypGNjEom.cjs} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-CiKAT1GP.js → manager-B-QrBhhd.js} +2 -2
- package/dist/{manager-Bd8By72w.cjs → manager-CYXV5_vY.cjs} +2 -2
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-GjJdwKF7.js → mastra-DPSwJ5ae.js} +16 -16
- package/dist/{mastra-BD1Hqrb2.cjs → mastra-zszeli0N.cjs} +16 -16
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/{model-Bvfq1yB9.js → model-UYJb8Zel.js} +1 -1
- package/dist/{model-CI05YYPx.cjs → model-WLujr8OR.cjs} +1 -1
- package/dist/{netlify-DQ-v2Run.js → netlify-DTWAZGpA.js} +1 -1
- package/dist/{netlify-DkSS4nuo.cjs → netlify-wZafLKoe.cjs} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/processors/processors/tool-search.d.ts +2 -2
- package/dist/{provider-registry-K3a83H9-.cjs → provider-registry-BvpUdOiq.cjs} +21504 -21437
- package/dist/{provider-registry-D7D3C2RI.js → provider-registry-COT79RLh.js} +21504 -21437
- package/dist/provider-registry.json +22003 -21942
- package/dist/{registry-generator-BgHaZqDZ.js → registry-generator-BKjTPD6B.js} +1 -1
- package/dist/{registry-generator-RfPwMlUl.cjs → registry-generator-Dn1Tuacv.cjs} +1 -1
- package/dist/{rehydrate-C4-5kM6Z.js → rehydrate-BK1v65H7.js} +2 -2
- package/dist/{rehydrate-DwfzaTOg.cjs → rehydrate-C0xrJUBu.cjs} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-Bj_lW9M3.js → run-registry-DKiudqVU.js} +351 -36
- package/dist/{run-registry-BJa47sa2.cjs → run-registry-DX_EyboB.cjs} +374 -35
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-DaIpS6ky.js → stream-B4LzC6Sz.js} +1 -1
- package/dist/{stream-CWE0h7Yc.cjs → stream-BmtBm_-L.cjs} +1 -1
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-BGBhn5xS.cjs → tool-loop-agent-BIbw3quM.cjs} +3 -3
- package/dist/{tool-loop-agent-B12lpXBl.js → tool-loop-agent-CR2AgmkF.js} +3 -3
- 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-n9lqzDNe.cjs → tools-BEYxowf0.cjs} +316 -30
- package/dist/{tools-DDfA_ES4.js → tools-tPy2FwMI.js} +305 -31
- package/dist/{utils-dueX8ECq.js → utils-BnG4bq6k.js} +1 -1
- package/dist/{utils-CPOlvXFL.cjs → utils-D2Bj0C2E.cjs} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-DdirQd9u.cjs → validate-BxgKlbt7.cjs} +1 -1
- package/dist/{validate-x3wcpuT8.js → validate-DHEGALaE.js} +1 -1
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-CfMtR2cV.js → worker-1lHN6hT1.js} +2 -2
- package/dist/{worker-CPZ3HqQn.cjs → worker-BRKHC9hv.cjs} +2 -2
- package/dist/{worker-NYiueScR.js → worker-C-xoXGOt.js} +2 -2
- package/dist/{worker-GrFJJ7Y0.cjs → worker-DYBrWSDX.cjs} +2 -2
- package/dist/{workflow-BgAes9PI.js → workflow-79JneaJP.js} +3 -3
- package/dist/{workflow-BNUED985.cjs → workflow-DGRDgyhs.cjs} +3 -3
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/teardown-context.d.ts +74 -0
- package/dist/{workspace-Pv3J8K0c.cjs → workspace-C8Zo5_qK.cjs} +106 -5
- package/dist/{workspace-BK9ltbSa.js → workspace-DOAil8mG.js} +106 -5
- package/package.json +7 -7
- package/src/llm/model/provider-types.generated.d.ts +8041 -8014
|
@@ -132,6 +132,26 @@ const agent = new Agent({
|
|
|
132
132
|
|
|
133
133
|
The generated code for `sales_code` can't call an inventory tool, and the reverse holds too. Use this for least-privilege scoping and to keep each tool's prompt surface small.
|
|
134
134
|
|
|
135
|
+
## Execution limits
|
|
136
|
+
|
|
137
|
+
Code mode runs model-authored code, so you can bound what a single program may consume. Every limit is opt-in and set on `createCodeMode()`:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const { tool, instructions } = createCodeMode({
|
|
141
|
+
tools: { getTopProducts, getProductRatings },
|
|
142
|
+
sandbox: new LocalSandbox(),
|
|
143
|
+
timeout: 30_000, // wall-clock limit for the whole program
|
|
144
|
+
maxCalls: 25, // cap the number of external_* calls
|
|
145
|
+
maxConcurrentCalls: 5, // run at most 5 at a time; the rest queue
|
|
146
|
+
maxResultBytes: 256_000, // cap each nested tool result
|
|
147
|
+
maxLogLines: 200, // bound captured console logs
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`maxCalls` and `maxResultBytes` fail the whole run with a `CodeModeLimitError` when exceeded, even if the program catches the rejection. `maxConcurrentCalls` queues extra calls instead of failing, so a `Promise.all` fan-out still completes. `maxLogBytes` and `maxLogLines` truncate the captured logs and the program still succeeds. The [`createCodeMode()` reference](https://mastra.ai/reference/tools/create-code-mode) has the full behavior.
|
|
152
|
+
|
|
153
|
+
For multi-tenant hosts, pair these with the runtime budgets of the in-process transports, such as the QuickJS `maxInterruptTicks` and `shouldInterrupt` options. See [Execution limits](https://mastra.ai/reference/tools/quickjs-transport) in the transport reference.
|
|
154
|
+
|
|
135
155
|
## Connected tools
|
|
136
156
|
|
|
137
157
|
To orchestrate the tools of providers connected in Mastra Platform, use [`tools().codeMode()`](https://mastra.ai/reference/connect/tools) from `@mastra/connect`. It builds the code tool and instructions from the current connections on each request, and keeps tools that need approval as direct agent tools.
|
|
@@ -9,11 +9,12 @@ Browser support lets agents navigate websites, interact with page elements, fill
|
|
|
9
9
|
- **SDK providers** wrap a browser automation library and give the agent browser tools directly.
|
|
10
10
|
- **CLI providers** launch a browser that the agent controls through command-line tools.
|
|
11
11
|
|
|
12
|
-
Mastra includes
|
|
12
|
+
Mastra includes four SDK providers and one CLI provider:
|
|
13
13
|
|
|
14
14
|
- [**AgentBrowser**](https://mastra.ai/integrations/browsers/agent-browser): An SDK provider built on Playwright that finds page elements through accessibility information. Use it for general web automation and scraping.
|
|
15
15
|
- [**Stagehand**](https://mastra.ai/integrations/browsers/stagehand): An SDK provider built on the Stagehand library from Browserbase. It uses AI to find page elements. Use it for complex interactions where describing an element in natural language works better than a fixed selector.
|
|
16
16
|
- [**FirecrawlBrowser**](https://mastra.ai/integrations/browsers/firecrawl): An SDK provider that runs AgentBrowser tools in hosted Firecrawl Browser Sandbox sessions. Use it to avoid running browsers on your own infrastructure.
|
|
17
|
+
- [**PlatformBrowser**](https://mastra.ai/integrations/browsers/mastra-platform): An SDK provider that runs AgentBrowser tools in hosted browsers from Mastra Platform. Use it for agents deployed on Mastra Platform.
|
|
17
18
|
- [**BrowserViewer**](https://mastra.ai/integrations/browsers/browser-viewer): A CLI provider that launches Chrome and passes its Chrome DevTools Protocol (CDP) URL to CLI tools such as agent-browser, browser-use, and browse. Use it for workspace agents that control browsers through shell commands.
|
|
18
19
|
|
|
19
20
|
## When to use a browser
|
|
@@ -215,6 +216,7 @@ Recordings use Motion-JPEG AVI and don't require `ffmpeg`. The default maximum d
|
|
|
215
216
|
- [AgentBrowser](https://mastra.ai/integrations/browsers/agent-browser)
|
|
216
217
|
- [Stagehand](https://mastra.ai/integrations/browsers/stagehand)
|
|
217
218
|
- [Firecrawl](https://mastra.ai/integrations/browsers/firecrawl)
|
|
219
|
+
- [Mastra Platform](https://mastra.ai/integrations/browsers/mastra-platform)
|
|
218
220
|
- [BrowserViewer](https://mastra.ai/integrations/browsers/browser-viewer)
|
|
219
221
|
- [MastraBrowser reference](https://mastra.ai/reference/browser/mastra-browser)
|
|
220
222
|
- 📹 [Mastra browser capabilities workshop](https://www.youtube.com/watch?v=E9KFsZEnQO8\&t=5s)
|
|
@@ -55,6 +55,8 @@ export const supportAgent = new Agent({
|
|
|
55
55
|
|
|
56
56
|
To change these instructions, see [Tool instructions](https://mastra.ai/reference/knowledge/tool-instructions).
|
|
57
57
|
|
|
58
|
+
When the agent has Memory and its `knowledge` option turns on read or write tools, it also learns which scopes it holds before it calls a tool. Knowledge with no tools turned on doesn't send this list, and neither do tools you add yourself with `createTools()`. Each turn's context lists each scope the run holds and has a role on, with that role. A role in one scope can also grant access to others, such as a team's docs through its org. Those aren't listed. Viewers can read, and contributors, editors and owners can also write. Scopes with no pages yet are listed too. This list is a [state signal](https://mastra.ai/docs/signals/state-signals): the first turn gets the full list, and later turns get only what changed, such as a scope added, a role changed, or a scope removed. If the full list has left the context window, the next turn gets it again, even when nothing changed. A run that holds no scopes gets no list on its first turn, and isn't sent an empty list after an earlier one leaves the context window.
|
|
59
|
+
|
|
58
60
|
### Add the tools yourself
|
|
59
61
|
|
|
60
62
|
You can also add the tools to the agent's `tools`, next to its other tools. Use [`createTools()`](https://mastra.ai/reference/knowledge/knowledge-class) for the tools and [`getInstructions()`](https://mastra.ai/reference/knowledge/knowledge-class) for their instructions. Pass the same options to both:
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
- [Bright Data](https://mastra.ai/integrations/tools/brightdata)
|
|
136
136
|
- [Exa](https://mastra.ai/integrations/tools/exa)
|
|
137
137
|
- [Firecrawl](https://mastra.ai/integrations/tools/firecrawl)
|
|
138
|
+
- [Mastra Platform](https://mastra.ai/integrations/browsers/mastra-platform)
|
|
138
139
|
- [GitLab](https://mastra.ai/integrations/tools/gitlab)
|
|
139
140
|
- [Parallel](https://mastra.ai/integrations/tools/parallel)
|
|
140
141
|
- [Perplexity](https://mastra.ai/integrations/tools/perplexity)
|
|
@@ -31,7 +31,7 @@ const toolSearch = new ToolSearchProcessor({
|
|
|
31
31
|
|
|
32
32
|
**options.tools** (`Record<string, Tool>`): All tools that can be searched and loaded dynamically. These tools are not immediately available to the agent — they must be discovered via search and loaded on demand.
|
|
33
33
|
|
|
34
|
-
**options.includeResolvedTools** (`boolean`): Also make the tools the agent resolved for this request (MCP tools requiring the caller's credentials, or anything returned by a dynamic tools function) searchable, and withhold them from the prompt until the agent loads them.
|
|
34
|
+
**options.includeResolvedTools** (`boolean`): Also make the tools the agent resolved for this request (MCP tools requiring the caller's credentials, or anything returned by a dynamic tools function) searchable, and withhold them from the prompt until the agent loads them. This option never withholds the meta-tools — which meta-tools appear is controlled by search.autoLoad and the activeTools allowlist. Request-resolved tools are indexed per request, so each request searches and loads its own tool instances.
|
|
35
35
|
|
|
36
36
|
**options.search** (`{ topK?: number; minScore?: number; autoLoad?: boolean }`): Configuration for the search behavior.
|
|
37
37
|
|
|
@@ -124,7 +124,7 @@ The `phase` value describes where the filter is being applied:
|
|
|
124
124
|
- `load`: Blocks `load_tool` from loading disallowed tools.
|
|
125
125
|
- `active`: Hides already-loaded tools from the current request if they're no longer allowed.
|
|
126
126
|
|
|
127
|
-
If the hook throws or rejects, `ToolSearchProcessor` treats the tool as disallowed for that request. The hook may run for every matching search candidate, so keep async policy checks cheap or cached. The `search_tools` meta-tool is
|
|
127
|
+
If the hook throws or rejects, `ToolSearchProcessor` treats the tool as disallowed for that request. The hook may run for every matching search candidate, so keep async policy checks cheap or cached. The `search_tools` meta-tool is available unless you exclude it through `activeTools`. `load_tool` is available unless `search.autoLoad` is enabled or you exclude it through `activeTools`. When the processor runs with a meta-tool excluded from `activeTools`, it withholds that meta-tool and omits it from the system instructions, tool descriptions, search results, and not-found messages. This reflects the `activeTools` the processor sees when it runs. A `prepareStep` that narrows `activeTools` later in the step can't retract instructions or descriptions the processor already added. Tools passed directly through the agent or `processInputStep` remain available unless you filter them outside `ToolSearchProcessor`, or enable `includeResolvedTools`.
|
|
128
128
|
|
|
129
129
|
## Searching request-resolved tools
|
|
130
130
|
|
|
@@ -154,7 +154,7 @@ const agent = new Agent({
|
|
|
154
154
|
|
|
155
155
|
Each request is indexed on its own, so a tool loaded by one caller never resolves to another caller's instance of the same tool name.
|
|
156
156
|
|
|
157
|
-
This option applies to every tool resolved for the request, including memory, workspace, skill, and browser tools.
|
|
157
|
+
This option applies to every tool resolved for the request, including memory, workspace, skill, and browser tools. It withholds the resolved tools from the prompt, but it never withholds the meta-tools. `search.autoLoad` and `activeTools` still control which meta-tools appear. Only the resolved tools the agent hasn't loaded are withheld, so a tool loaded earlier remains eligible for the returned tool map alongside the meta-tools. That eligibility is still subject to the filter's `active` phase, which hides an already-loaded tool whose policy no longer allows it, and to the step's final `activeTools` allowlist. Any tool the agent relies on implicitly must be found through search before it can be called, unless it knows the tool name and `load_tool` is available. `load_tool` looks up a supplied name without consulting `injectCatalog`, so `injectCatalog` is required only for catalog-based direct loading: it puts the catalog in the system prompt so the agent can pick a name it hasn't seen. Catalog-based direct loading requires `injectCatalog` enabled, `search.autoLoad: false`, and a `load_tool` that `activeTools` doesn't exclude. With `search.autoLoad: true`, `load_tool` isn't exposed and `search_tools` activates matching tools.
|
|
158
158
|
|
|
159
159
|
## Extended usage example
|
|
160
160
|
|
|
@@ -64,8 +64,30 @@ export const shopAgent = new Agent({
|
|
|
64
64
|
|
|
65
65
|
**config.id** (`string`): The generated tool id.
|
|
66
66
|
|
|
67
|
+
**config.maxCalls** (`number`): Maximum number of external\_\* calls a single program may attempt. Exceeding it fails the whole run with a CodeModeLimitError, even when the program catches the rejection. Must be a positive integer. Unset by default.
|
|
68
|
+
|
|
69
|
+
**config.maxConcurrentCalls** (`number`): Maximum number of external\_\* calls allowed to run at once. Additional calls queue in arrival order instead of failing. Must be a positive integer. Unset by default.
|
|
70
|
+
|
|
71
|
+
**config.maxResultBytes** (`number`): Maximum UTF-8 byte size of each nested tool result. A larger result fails the whole run with a CodeModeLimitError, even when the program catches the rejection. Applies to each nested tool result, not the program's final return value. Must be a non-negative integer. Unset by default.
|
|
72
|
+
|
|
73
|
+
**config.maxLogBytes** (`number`): Maximum UTF-8 bytes of captured console logs. Each retained line costs at least one byte, so a finite cap also bounds the line count. Overflow truncates the logs and the program still succeeds. 0 captures no logs. Must be a non-negative integer. Unset by default.
|
|
74
|
+
|
|
75
|
+
**config.maxLogLines** (`number`): Maximum number of captured console log lines. Overflow truncates the logs and the program still succeeds. 0 captures no logs. Must be a non-negative integer. Unset by default.
|
|
76
|
+
|
|
67
77
|
**transport** (`CodeModeTransport`): Optional transport implementation used to run the generated code in the sandbox. The default transport uses stdio JSON-RPC over the workspace sandbox process API. Transports that declare requiresSandbox: false (such as IsolatedVmCodeModeTransport and QuickJsCodeModeTransport) run without a sandbox.
|
|
68
78
|
|
|
79
|
+
## Execution limits
|
|
80
|
+
|
|
81
|
+
All five execution limits are opt-in. When unset, call counts, concurrency, result size, and captured logs are unlimited. Set them to bound what model-authored code can consume:
|
|
82
|
+
|
|
83
|
+
- `maxCalls` and `maxResultBytes` fail the whole run with a `CodeModeLimitError` when exceeded, even if the program catches the individual rejection. Use them to cap how many tools a program can reach and how much data each nested result can carry.
|
|
84
|
+
- `maxConcurrentCalls` queues calls in arrival order instead of failing, so a program that fans out with `Promise.all` still completes, with less host-side pressure at once.
|
|
85
|
+
- `maxLogBytes` and `maxLogLines` truncate the captured logs instead of failing. The program still succeeds, and `logs` in the result stays within the cap. Each retained line costs at least one byte, so a byte cap also bounds the line count.
|
|
86
|
+
|
|
87
|
+
The limits layer on top of `timeout` and, for in-process transports, their own runtime budgets such as the QuickJS `maxInterruptTicks`. For multi-tenant deployments, set explicit call, concurrency, result, log, and timeout budgets rather than relying on defaults.
|
|
88
|
+
|
|
89
|
+
When the calling tool's abort signal fires, the run is cancelled and any in-flight `external_*` calls are aborted.
|
|
90
|
+
|
|
69
91
|
## Returns
|
|
70
92
|
|
|
71
93
|
Returns a `CodeModeResult` object.
|
package/dist/evals/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_run_registry = require("../run-registry-
|
|
2
|
+
const require_run_registry = require("../run-registry-DX_EyboB.cjs");
|
|
3
3
|
const require_constants = require("../constants-Bou0hEgY.cjs");
|
|
4
4
|
const require_collect_tool_mocks = require("../collect-tool-mocks-k9fM6oDl.cjs");
|
|
5
5
|
exports.MastraScorer = require_run_registry.MastraScorer;
|
package/dist/evals/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as MastraScorer, D as isNotScorable, E as filterRun,
|
|
1
|
+
import { Bc as validateScoringPredicate, C as MastraScorer, D as isNotScorable, E as filterRun, O as notScorable, Rc as SCORING_PREDICATE_ROOTS, S as createClassifierScorer, T as createScorer, v as runEvals, w as ScorerRunError, zc as evaluateScoringPredicate } from "../run-registry-DKiudqVU.js";
|
|
2
2
|
import { Ar as scoringEntityTypeSchema, Cr as extractTrajectory, Dr as saveScorePayloadSchema, Er as listScoresResponseSchema, Fr as scoringInputWithExtractStepResultAndScoreAndReasonSchema, Ir as scoringInputWithExtractStepResultSchema, Lr as scoringPromptsSchema, Mr as scoringHookInputSchema, Nr as scoringInputSchema, Or as scoreResultSchema, Pr as scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, Rr as scoringSourceSchema, Tr as extractWorkflowTrajectory, jr as scoringExtractStepResultSchema, kr as scoreRowDataSchema, wr as extractTrajectoryFromTrace, zr as scoringValueSchema } from "../constants-CFWgIaqA.js";
|
|
3
3
|
import { t as collectToolMocks } from "../collect-tool-mocks-3s2BN8o7.js";
|
|
4
4
|
export { MastraScorer, SCORING_PREDICATE_ROOTS, ScorerRunError, collectToolMocks, createClassifierScorer, createScorer, evaluateScoringPredicate, extractTrajectory, extractTrajectoryFromTrace, extractWorkflowTrajectory, filterRun, isNotScorable, listScoresResponseSchema, notScorable, runEvals, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema, validateScoringPredicate };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_error = require("../../error-D90lJ6M7.cjs");
|
|
3
3
|
const require_utils = require("../../utils-D-eNsgDM.cjs");
|
|
4
|
-
const require_run_registry = require("../../run-registry-
|
|
4
|
+
const require_run_registry = require("../../run-registry-DX_EyboB.cjs");
|
|
5
5
|
const require_constants = require("../../constants-Bou0hEgY.cjs");
|
|
6
6
|
let zod_v4 = require("zod/v4");
|
|
7
7
|
// src/evals/scoreTraces/scoreTraces.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "../../error-oh2DLsP2.js";
|
|
2
2
|
import { i as getEntityTypeForSpan } from "../../utils-DU_pU5SK.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Js as createWorkflow, qs as createStep } from "../../run-registry-DKiudqVU.js";
|
|
4
4
|
import { Dr as saveScorePayloadSchema } from "../../constants-CFWgIaqA.js";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
// src/evals/scoreTraces/scoreTraces.ts
|
package/dist/harness/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_state_processor = require("../state-processor-kRNZ38Nf.cjs");
|
|
3
|
-
const require_tools = require("../tools-
|
|
4
|
-
const require_agent_controller = require("../agent-controller-
|
|
3
|
+
const require_tools = require("../tools-BEYxowf0.cjs");
|
|
4
|
+
const require_agent_controller = require("../agent-controller-ZCQy7cOG.cjs");
|
|
5
5
|
// src/harness/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Backwards-compatibility entrypoint.
|
package/dist/harness/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { f as taskCheckTool, h as taskWriteTool, m as taskUpdateTool, o as assignTaskIds, p as taskCompleteTool } from "../state-processor-B9kxpM53.js";
|
|
2
|
-
import { s as askUserTool, t as submitPlanTool } from "../tools-
|
|
3
|
-
import { a as Session, c as defaultDisplayState, l as defaultOMProgressState, n as parseSubagentMeta, t as AgentController } from "../agent-controller-
|
|
2
|
+
import { s as askUserTool, t as submitPlanTool } from "../tools-tPy2FwMI.js";
|
|
3
|
+
import { a as Session, c as defaultDisplayState, l as defaultOMProgressState, n as parseSubagentMeta, t as AgentController } from "../agent-controller-fazk0U_b.js";
|
|
4
4
|
// src/harness/index.ts
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated Backwards-compatibility entrypoint.
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Mastra } from "./mastra-
|
|
1
|
+
export { t as Mastra } from "./mastra-DPSwJ5ae.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { KnowledgeScopeDeclarations, CompiledKnowledgeScopes } from './declarations.js';
|
|
2
|
+
/** Agent identity declarations. Identities grant nothing until an access rule names them. @experimental */
|
|
3
|
+
export declare function knowledgeAgentScopes(): KnowledgeScopeDeclarations;
|
|
4
|
+
/**
|
|
5
|
+
* {@link knowledgeAgentScopes} plus a read-only persona convention: each agent reads and pins its own
|
|
6
|
+
* `#persona` page, and every agent of a role or team reads and pins that scope's `#rules` page. The
|
|
7
|
+
* `:edit` forms give editor on one role or team scope and are never minted; host code passes them.
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
export declare function knowledgePersonaScopes(): KnowledgeScopeDeclarations;
|
|
11
|
+
/** @internal */
|
|
12
|
+
export declare function mintKnowledgeAgentScopes(compiled: CompiledKnowledgeScopes, scopes: readonly string[], agent: {
|
|
13
|
+
agentId?: string;
|
|
14
|
+
resourceId?: string;
|
|
15
|
+
persona?: unknown;
|
|
16
|
+
} | undefined): string[];
|
|
17
|
+
//# sourceMappingURL=agent-scopes.d.ts.map
|
|
@@ -31,6 +31,8 @@ export interface KnowledgeScopeDeclaration {
|
|
|
31
31
|
/** A short name for the scope type in UIs, e.g. `Organization`. Not shown to the model. */
|
|
32
32
|
displayLabel?: string;
|
|
33
33
|
access?: KnowledgeAccessRule[];
|
|
34
|
+
/** Opts this agent pattern into binding identities from the running Agent. */
|
|
35
|
+
mint?: 'run-identity';
|
|
34
36
|
/** Tree placement only; grants nothing. A scope pattern, e.g. `org:$orgId`. */
|
|
35
37
|
belongsTo?: string;
|
|
36
38
|
/** Child scopes created with this scope, at `<address>/<name>`. */
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HeldScopesStateProcessor
|
|
3
|
+
*
|
|
4
|
+
* Projects the scopes a run holds onto the agent state-signal lane, the same way
|
|
5
|
+
* PinnedStateProcessor projects pins: a full snapshot when none is in the visible
|
|
6
|
+
* context, a delta of only this turn's changes otherwise, and nothing when the set
|
|
7
|
+
* is unchanged and its snapshot is still visible.
|
|
8
|
+
*
|
|
9
|
+
* Each entry is a held scope keyed by its address, with the run's role there. A
|
|
10
|
+
* held address with no role grants nothing, so it is left out, and losing a role
|
|
11
|
+
* reads as losing access. Scopes with no pages yet are included: a model that only
|
|
12
|
+
* saw scopes with pages concluded on its first turn that it had nowhere to write.
|
|
13
|
+
*/
|
|
14
|
+
import type { ComputeStateSignalArgs, ComputeStateSignalResult, Processor, ProcessInputArgs, ProcessInputResult } from '../processors/index.js';
|
|
15
|
+
import type { KnowledgeRole } from './declarations.js';
|
|
16
|
+
import type { KnowledgeRunContext } from './run.js';
|
|
17
|
+
export declare const HELD_SCOPES_STATE_ID = "knowledge-scopes";
|
|
18
|
+
export declare const HELD_SCOPES_SNAPSHOT_TAG = "knowledge-scopes";
|
|
19
|
+
export declare const HELD_SCOPES_DELTA_TAG = "knowledge-scopes-update";
|
|
20
|
+
/** A scope the run holds a role on, as the model sees it. */
|
|
21
|
+
export interface HeldScopeEntry {
|
|
22
|
+
address: string;
|
|
23
|
+
role: KnowledgeRole;
|
|
24
|
+
}
|
|
25
|
+
export type HeldScopeDeltaOp = {
|
|
26
|
+
op: 'add';
|
|
27
|
+
scope: HeldScopeEntry;
|
|
28
|
+
} | {
|
|
29
|
+
op: 'change';
|
|
30
|
+
scope: HeldScopeEntry;
|
|
31
|
+
} | {
|
|
32
|
+
op: 'remove';
|
|
33
|
+
address: string;
|
|
34
|
+
};
|
|
35
|
+
export interface HeldScopesStateProcessorDeps {
|
|
36
|
+
/** The run's principals as a key, or `undefined` when it has no Knowledge view; rejects when the
|
|
37
|
+
* store's declarations cannot be read. */
|
|
38
|
+
principalsKey(context: KnowledgeRunContext): Promise<string | undefined>;
|
|
39
|
+
/** The scopes the run holds, in principal order. */
|
|
40
|
+
readHeldScopes(context: KnowledgeRunContext): Promise<HeldScopeEntry[]>;
|
|
41
|
+
}
|
|
42
|
+
export declare class HeldScopesStateProcessor implements Processor<typeof HELD_SCOPES_STATE_ID> {
|
|
43
|
+
private readonly deps;
|
|
44
|
+
readonly id = "knowledge-scopes";
|
|
45
|
+
readonly stateId = "knowledge-scopes";
|
|
46
|
+
constructor(deps: HeldScopesStateProcessorDeps);
|
|
47
|
+
processInput(args: ProcessInputArgs): ProcessInputResult;
|
|
48
|
+
computeStateSignal(args: ComputeStateSignalArgs): Promise<ComputeStateSignalResult>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=held-scopes-state-processor.d.ts.map
|
|
@@ -64,6 +64,8 @@ export interface KnowledgeImportCounts {
|
|
|
64
64
|
moved: number;
|
|
65
65
|
removed: number;
|
|
66
66
|
stubbed: number;
|
|
67
|
+
/** Upserts skipped because someone merged the item's page into another page. */
|
|
68
|
+
merged: number;
|
|
67
69
|
refused: number;
|
|
68
70
|
}
|
|
69
71
|
/** What a host applied for one flush. A replay of the same flush returns the stored receipt. */
|
package/dist/knowledge/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_base = require("../base-BIzR1D3_.cjs");
|
|
3
|
-
const require_run_registry = require("../run-registry-
|
|
3
|
+
const require_run_registry = require("../run-registry-DX_EyboB.cjs");
|
|
4
4
|
const require_tool = require("../tool-CYlT2UA-.cjs");
|
|
5
5
|
let crypto = require("crypto");
|
|
6
6
|
let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
|
|
@@ -1193,7 +1193,8 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1193
1193
|
unchanged: 0,
|
|
1194
1194
|
moved: 0,
|
|
1195
1195
|
removed: 0,
|
|
1196
|
-
stubbed: 0
|
|
1196
|
+
stubbed: 0,
|
|
1197
|
+
merged: 0
|
|
1197
1198
|
},
|
|
1198
1199
|
refused: [],
|
|
1199
1200
|
changes: [],
|
|
@@ -1377,12 +1378,13 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1377
1378
|
};
|
|
1378
1379
|
};
|
|
1379
1380
|
const nodeOf = async (sourceId) => sourceId ? importers.getNode(binding.id, sourceId) : null;
|
|
1380
|
-
const
|
|
1381
|
+
const stateOf = async (node) => {
|
|
1381
1382
|
const page = await storage.getPage({
|
|
1382
1383
|
id: node.pageId,
|
|
1383
1384
|
read: "all"
|
|
1384
1385
|
});
|
|
1385
|
-
|
|
1386
|
+
if (page?.mergedInto) return "merged";
|
|
1387
|
+
return !page || !!page.deletedAt || page.scopeId !== scope.id ? "gone" : "live";
|
|
1386
1388
|
};
|
|
1387
1389
|
/**
|
|
1388
1390
|
* Drops the node of a page that is gone, so its item is written again as new. Pages that linked to
|
|
@@ -1438,7 +1440,7 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1438
1440
|
};
|
|
1439
1441
|
const liveNodeOf = async (sourceId) => {
|
|
1440
1442
|
const node = await nodeOf(sourceId);
|
|
1441
|
-
return node &&
|
|
1443
|
+
return node && await stateOf(node) === "live" ? node : null;
|
|
1442
1444
|
};
|
|
1443
1445
|
const ref = (keys) => `${target.scope}#${keys.join("/")}`;
|
|
1444
1446
|
const linkLine = async (link, node) => {
|
|
@@ -1617,12 +1619,17 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1617
1619
|
};
|
|
1618
1620
|
const write = async (item, hasBody) => {
|
|
1619
1621
|
let existing = await importers.getNode(binding.id, item.sourceId);
|
|
1620
|
-
|
|
1622
|
+
const state = existing ? await stateOf(existing) : null;
|
|
1623
|
+
if (state === "merged") return null;
|
|
1624
|
+
if (existing && state === "gone") {
|
|
1621
1625
|
await forget(existing);
|
|
1622
1626
|
existing = null;
|
|
1623
1627
|
}
|
|
1624
|
-
const
|
|
1625
|
-
const
|
|
1628
|
+
const parentRecord = await nodeOf(item.parent);
|
|
1629
|
+
const parentState = parentRecord ? await stateOf(parentRecord) : null;
|
|
1630
|
+
const sourceParent = parentState === "live" ? parentRecord : null;
|
|
1631
|
+
const parentMerged = parentState === "merged";
|
|
1632
|
+
const misplaced = !!item.parent && !sourceParent && !parentMerged;
|
|
1626
1633
|
const parentNode = sourceParent ?? await liveNodeOf(item.fallbackParent);
|
|
1627
1634
|
const destination = parentNode ? await owned(parentNode.pageId, parentNode.sourceId) : anchor;
|
|
1628
1635
|
if (existing && destination.page.id === existing.pageId) throw new KnowledgeImportRefusalError("invalid");
|
|
@@ -1676,7 +1683,7 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1676
1683
|
const current = await owned(existing.pageId, item.sourceId);
|
|
1677
1684
|
page = current.page;
|
|
1678
1685
|
if (existing.stub && existing.adopted && !REMOVED_BODIES.has(page.body ?? "")) await keepBody(page.id, page.body ?? "");
|
|
1679
|
-
if (!current.outside && page.parentId !== destination.page.id) {
|
|
1686
|
+
if (!current.outside && !parentMerged && page.parentId !== destination.page.id) {
|
|
1680
1687
|
if (destination.keys.length > current.keys.length && sameKeys(destination.keys.slice(0, current.keys.length), current.keys)) throw new KnowledgeImportRefusalError("invalid");
|
|
1681
1688
|
({page, relinked} = await moveOwned(item.sourceId, page, destination));
|
|
1682
1689
|
moved = true;
|
|
@@ -1756,7 +1763,9 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1756
1763
|
if (op.op === "remove") {
|
|
1757
1764
|
const node = await importers.getNode(binding.id, sourceId);
|
|
1758
1765
|
if (!node) return;
|
|
1759
|
-
|
|
1766
|
+
const state = await stateOf(node);
|
|
1767
|
+
if (state === "merged") return;
|
|
1768
|
+
if (state === "gone") {
|
|
1760
1769
|
await forget(node);
|
|
1761
1770
|
result.applied = true;
|
|
1762
1771
|
return;
|
|
@@ -1828,7 +1837,12 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1828
1837
|
result.applied = true;
|
|
1829
1838
|
return;
|
|
1830
1839
|
}
|
|
1831
|
-
const
|
|
1840
|
+
const written = await write(op.item, op.op === "upsert");
|
|
1841
|
+
if (!written) {
|
|
1842
|
+
result.counts.merged++;
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
const { page, change, moved, relinked } = written;
|
|
1832
1846
|
recordRelinked(relinked, embeds);
|
|
1833
1847
|
if (change === "unchanged") {
|
|
1834
1848
|
result.counts.unchanged++;
|
|
@@ -1947,12 +1961,24 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1947
1961
|
moved: false,
|
|
1948
1962
|
relinked: false
|
|
1949
1963
|
};
|
|
1964
|
+
if (await stateOf(node) === "merged") {
|
|
1965
|
+
await importers.saveNode({
|
|
1966
|
+
...node,
|
|
1967
|
+
unsettled: false
|
|
1968
|
+
});
|
|
1969
|
+
return {
|
|
1970
|
+
moved: false,
|
|
1971
|
+
relinked: false
|
|
1972
|
+
};
|
|
1973
|
+
}
|
|
1950
1974
|
const current = await owned(node.pageId, sourceId);
|
|
1951
1975
|
let { page, keys } = current;
|
|
1952
1976
|
let moved = false;
|
|
1953
1977
|
let relinked = false;
|
|
1954
|
-
const
|
|
1955
|
-
|
|
1978
|
+
const sourceParent = current.outside ? null : await nodeOf(node.parentSourceId);
|
|
1979
|
+
const parentMerged = !!sourceParent && await stateOf(sourceParent) === "merged";
|
|
1980
|
+
const parent = parentMerged ? null : sourceParent;
|
|
1981
|
+
let misplaced = !current.outside && !!node.parentSourceId && !parent && !parentMerged;
|
|
1956
1982
|
if (parent && canMove) {
|
|
1957
1983
|
const destination = await owned(parent.pageId, parent.sourceId);
|
|
1958
1984
|
if (page.parentId !== destination.page.id) {
|
|
@@ -2353,6 +2379,14 @@ function hostError(error) {
|
|
|
2353
2379
|
failure.cause = error;
|
|
2354
2380
|
return failure;
|
|
2355
2381
|
}
|
|
2382
|
+
/** A committed receipt as replayed; receipts written before the `merged` count existed read it as 0. */
|
|
2383
|
+
const storedReceipt = (receipt) => {
|
|
2384
|
+
const stored = receipt;
|
|
2385
|
+
return {
|
|
2386
|
+
...stored,
|
|
2387
|
+
merged: stored.merged ?? 0
|
|
2388
|
+
};
|
|
2389
|
+
};
|
|
2356
2390
|
const receiptCounts = (counts) => ({
|
|
2357
2391
|
created: counts.created ?? 0,
|
|
2358
2392
|
updated: counts.updated ?? 0,
|
|
@@ -2360,6 +2394,7 @@ const receiptCounts = (counts) => ({
|
|
|
2360
2394
|
moved: counts.moved ?? 0,
|
|
2361
2395
|
removed: counts.removed ?? 0,
|
|
2362
2396
|
stubbed: counts.stubbed ?? 0,
|
|
2397
|
+
merged: counts.merged ?? 0,
|
|
2363
2398
|
refused: counts.refused ?? 0
|
|
2364
2399
|
});
|
|
2365
2400
|
const runReceipt = (run) => {
|
|
@@ -2614,7 +2649,7 @@ function createLocalKnowledgeImporterHost(writer, options) {
|
|
|
2614
2649
|
});
|
|
2615
2650
|
if (replayed) {
|
|
2616
2651
|
if (replayed.digest !== digest) throw conflict("digest_mismatch", "This seq was committed with other content.");
|
|
2617
|
-
return replayed.receipt;
|
|
2652
|
+
return storedReceipt(replayed.receipt);
|
|
2618
2653
|
}
|
|
2619
2654
|
const [peek, peekRun] = await Promise.all([rootImporters.readWriterGuard(), rootImporters.getRun(flush.runId)]).catch((error) => {
|
|
2620
2655
|
throw hostError(error);
|
|
@@ -2639,7 +2674,7 @@ function createLocalKnowledgeImporterHost(writer, options) {
|
|
|
2639
2674
|
const stored = await importers.getFlush(flush.runId, flush.generation, flush.seq);
|
|
2640
2675
|
if (stored) {
|
|
2641
2676
|
if (stored.digest !== digest) throw conflict("digest_mismatch", "This seq was committed with other content.");
|
|
2642
|
-
return stored.receipt;
|
|
2677
|
+
return storedReceipt(stored.receipt);
|
|
2643
2678
|
}
|
|
2644
2679
|
if (!run || run.status !== "running") throw conflict("run_not_active", "The run is not running.");
|
|
2645
2680
|
if (run.generation !== flush.generation || guard.generation !== flush.generation) throw conflict("stale_generation", "The run belongs to an older writer generation.");
|
|
@@ -4380,6 +4415,11 @@ var Knowledge = class extends require_base.MastraBase {
|
|
|
4380
4415
|
write
|
|
4381
4416
|
};
|
|
4382
4417
|
}
|
|
4418
|
+
/** Whether the resolved mint declarations need metadata.persona. @internal */
|
|
4419
|
+
async __needsAgentPersona() {
|
|
4420
|
+
await this.#runtime.resolve();
|
|
4421
|
+
return [...this.#runtime.compiled.declarations.values()].some((declaration) => declaration.declaration.mint === "run-identity" && declaration.pattern.params.some((param) => param === "role" || param === "teamId"));
|
|
4422
|
+
}
|
|
4383
4423
|
/**
|
|
4384
4424
|
* The run's principals as a stable key, or `undefined` when the run has no Knowledge view (no scopes,
|
|
4385
4425
|
* or an undeclared scope). Loads the store's declarations first, so a scope only the store declares
|
|
@@ -4419,6 +4459,14 @@ var Knowledge = class extends require_base.MastraBase {
|
|
|
4419
4459
|
const run = await require_run_registry.KnowledgeRun.start(this.#runtime, await this.getStorage(), context);
|
|
4420
4460
|
return require_run_registry.knowledgeDeliveredPins(run, budget, this.#groups().read);
|
|
4421
4461
|
}
|
|
4462
|
+
/** The scopes a run holds a role on this turn, with that role. @internal */
|
|
4463
|
+
async __heldScopes(context) {
|
|
4464
|
+
const run = await require_run_registry.KnowledgeRun.start(this.#runtime, await this.getStorage(), context);
|
|
4465
|
+
return (await require_run_registry.heldScopes(run)).flatMap(({ address, role }) => role ? [{
|
|
4466
|
+
address,
|
|
4467
|
+
role
|
|
4468
|
+
}] : []);
|
|
4469
|
+
}
|
|
4422
4470
|
/** @internal */
|
|
4423
4471
|
__registerMastra(_mastra) {}
|
|
4424
4472
|
/** @internal */
|
|
@@ -4598,12 +4646,14 @@ exports.expandKnowledgeScope = require_run_registry.expandKnowledgeScope;
|
|
|
4598
4646
|
exports.importerHostConformance = importerHostConformance;
|
|
4599
4647
|
exports.inspectKnowledgeSchema = require_run_registry.inspectKnowledgeSchema;
|
|
4600
4648
|
exports.isKnowledgeScopeVisible = require_run_registry.isKnowledgeScopeVisible;
|
|
4649
|
+
exports.knowledgeAgentScopes = require_run_registry.knowledgeAgentScopes;
|
|
4601
4650
|
exports.knowledgeImportKey = knowledgeImportKey;
|
|
4602
4651
|
exports.knowledgeImporterFlushDigest = knowledgeImporterFlushDigest;
|
|
4603
4652
|
exports.knowledgeImporterRegistry = knowledgeImporterRegistry;
|
|
4604
4653
|
exports.knowledgeLinkRefKey = require_run_registry.knowledgeLinkRefKey;
|
|
4605
4654
|
exports.knowledgeMemoryScopes = require_run_registry.knowledgeMemoryScopes;
|
|
4606
4655
|
exports.knowledgePagePath = require_run_registry.knowledgePagePath;
|
|
4656
|
+
exports.knowledgePersonaScopes = require_run_registry.knowledgePersonaScopes;
|
|
4607
4657
|
exports.knowledgePinDepth = require_run_registry.knowledgePinDepth;
|
|
4608
4658
|
exports.knowledgePositionBetween = require_run_registry.knowledgePositionBetween;
|
|
4609
4659
|
exports.knowledgeScopeAddress = require_run_registry.knowledgeScopeAddress;
|
|
@@ -7,6 +7,7 @@ import type { ToolAction } from '../tools/index.js';
|
|
|
7
7
|
import type { KnowledgeChangeListener } from './changes.js';
|
|
8
8
|
import type { KnowledgeConfig } from './config.js';
|
|
9
9
|
import type { KnowledgeRole, KnowledgeScopeDeclarationInfo } from './declarations.js';
|
|
10
|
+
import type { HeldScopeEntry } from './held-scopes-state-processor.js';
|
|
10
11
|
import type { KnowledgeAddNoteInput, KnowledgeMovePageInput, KnowledgeRemovePageInput, KnowledgeUpdateNoteInput, KnowledgeUpsertPageInput, KnowledgeUpsertPageResult } from './host-writes.js';
|
|
11
12
|
import type { KnowledgeImporterHost, RunKnowledgeImportOptions, RunKnowledgeImportResult } from './importers/index.js';
|
|
12
13
|
import type { KnowledgeImporterServiceHost, LocalKnowledgeImporterHostOptions } from './importers/local-host.js';
|
|
@@ -197,6 +198,8 @@ export declare class Knowledge extends MastraBase {
|
|
|
197
198
|
read: boolean;
|
|
198
199
|
write: boolean;
|
|
199
200
|
};
|
|
201
|
+
/** Whether the resolved mint declarations need metadata.persona. @internal */
|
|
202
|
+
__needsAgentPersona(): Promise<boolean>;
|
|
200
203
|
/**
|
|
201
204
|
* The run's principals as a stable key, or `undefined` when the run has no Knowledge view (no scopes,
|
|
202
205
|
* or an undeclared scope). Loads the store's declarations first, so a scope only the store declares
|
|
@@ -215,6 +218,8 @@ export declare class Knowledge extends MastraBase {
|
|
|
215
218
|
}): Promise<PinEntry[]>;
|
|
216
219
|
/** The pinned pages a run receives this turn. @internal */
|
|
217
220
|
__deliveredPins(context: KnowledgeRunContext): Promise<PinEntry[]>;
|
|
221
|
+
/** The scopes a run holds a role on this turn, with that role. @internal */
|
|
222
|
+
__heldScopes(context: KnowledgeRunContext): Promise<HeldScopeEntry[]>;
|
|
218
223
|
/** @internal */
|
|
219
224
|
__registerMastra(_mastra: Mastra): void;
|
|
220
225
|
/** @internal */
|
|
@@ -254,6 +259,7 @@ export { DEFAULT_KNOWLEDGE_PAGE_GRAPH_LIMITS, listKnowledgeTreeChildren, MAX_KNO
|
|
|
254
259
|
export type { KnowledgeGraphScopeGrant, KnowledgePageGraph, KnowledgePageGraphEdge, KnowledgePageGraphLimits, KnowledgePageLinks, KnowledgePageView, KnowledgeTreeChildren, KnowledgeTreePage, } from './explorer-pages.js';
|
|
255
260
|
export type { KnowledgeConfig } from './config.js';
|
|
256
261
|
export type { PinEntry as KnowledgePinnedEntry } from './pinned.js';
|
|
262
|
+
export { knowledgeAgentScopes, knowledgePersonaScopes } from './agent-scopes.js';
|
|
257
263
|
export { knowledgeScopeAddress, knowledgeMemoryScopes, KnowledgeDeclarationError } from './declarations.js';
|
|
258
264
|
export { decodeKnowledgeScopeId, encodeKnowledgeScopeId } from './scope-address.js';
|
|
259
265
|
export type { KnowledgePageTemplate, KnowledgePinnedList, KnowledgeScopeDeclaration, KnowledgeScopeDeclarationInfo, KnowledgeScopeDeclarations, KnowledgeAccessRule, KnowledgeRole, } from './declarations.js';
|