@mastra/core 1.87.0-alpha.0 → 1.87.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/@ai-sdk_anthropic@3.0.137/dist/index.d.ts +2 -2
- package/dist/_types/@ai-sdk_google@3.0.140/dist/index.d.ts +2 -2
- package/dist/_types/@ai-sdk_openai@3.0.135/dist/index.d.ts +2 -2
- package/dist/_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/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 +2 -1
- package/dist/agent/durable/index.d.ts +1 -0
- package/dist/agent/durable/index.js +2 -2
- package/dist/agent/durable/run-message-refs.d.ts +3 -2
- package/dist/agent/durable/run-registry.d.ts +12 -1
- package/dist/agent/durable/types.d.ts +2 -0
- package/dist/agent/durable/workflows/finalize-run.d.ts +2 -1
- package/dist/agent/index.cjs +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/thread-stream-runtime.d.ts +3 -1
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/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/worker-run-binding.d.ts +15 -0
- package/dist/{agent-controller-B8LoFdtu.js → agent-controller--gKWI81G.js} +50 -8
- package/dist/{agent-controller-DSnFynpa.cjs → agent-controller-BolLBwDm.cjs} +50 -8
- 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-IW7M4iD2.js → background-tasks-CgzXjBfE.js} +156 -33
- package/dist/{background-tasks-Ci5h0dhj.cjs → background-tasks-DYtlijQ1.cjs} +167 -32
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-14Uptu8y.cjs → builder-Dz-g-9CZ.cjs} +2 -2
- package/dist/{builder-DI2c2xjy.js → builder-emNPaIaC.js} +2 -2
- package/dist/capabilities/302ai.json +202 -202
- package/dist/capabilities/abliteratedllm.json +36 -27
- package/dist/capabilities/abliteration-ai.json +12 -12
- package/dist/capabilities/above.json +14 -14
- package/dist/capabilities/adaption.json +9 -9
- package/dist/capabilities/adzuki.json +26 -26
- package/dist/capabilities/agentrouter.json +4 -4
- package/dist/capabilities/agnes.json +2 -2
- package/dist/capabilities/ai-router.json +5 -5
- package/dist/capabilities/aiand.json +11 -11
- package/dist/capabilities/aigrow.json +14 -14
- package/dist/capabilities/aimlapi.json +154 -158
- package/dist/capabilities/aixy.json +21 -21
- package/dist/capabilities/aki-io.json +14 -14
- package/dist/capabilities/alibaba-cn.json +107 -101
- package/dist/capabilities/alibaba-coding-plan-cn.json +3 -3
- package/dist/capabilities/alibaba-coding-plan.json +3 -3
- package/dist/capabilities/alibaba-token-plan-cn.json +53 -53
- package/dist/capabilities/alibaba-token-plan.json +53 -53
- package/dist/capabilities/alibaba.json +99 -65
- package/dist/capabilities/ambient.json +14 -7
- package/dist/capabilities/amd.json +8 -8
- package/dist/capabilities/anthropic.json +47 -47
- package/dist/capabilities/anyapi.json +19 -19
- package/dist/capabilities/apiko.json +2 -2
- package/dist/capabilities/arcee.json +4 -4
- package/dist/capabilities/augure.json +5 -5
- package/dist/capabilities/auriko.json +22 -22
- package/dist/capabilities/bailing.json +3 -3
- package/dist/capabilities/baseten.json +25 -25
- package/dist/capabilities/bee.json +5 -5
- package/dist/capabilities/berget.json +14 -1
- package/dist/capabilities/bothub.json +17 -17
- package/dist/capabilities/boundless.json +31 -31
- package/dist/capabilities/bumo.json +40 -40
- package/dist/capabilities/byteplus.json +29 -29
- package/dist/capabilities/cheapaimodel.json +9 -9
- package/dist/capabilities/cheapest-token.json +30 -30
- package/dist/capabilities/chutes.json +9 -9
- package/dist/capabilities/claudinio.json +10 -1
- package/dist/capabilities/cline-pass.json +40 -40
- package/dist/capabilities/cloudcode.json +8 -15
- package/dist/capabilities/cloudflare-workers-ai.json +8 -8
- package/dist/capabilities/commandcode.json +145 -145
- package/dist/capabilities/concentrate.json +272 -289
- package/dist/capabilities/cortecs.json +110 -110
- package/dist/capabilities/crossmodel.json +182 -182
- package/dist/capabilities/crusoe.json +37 -8
- package/dist/capabilities/daoxe.json +8 -8
- package/dist/capabilities/databricks.json +130 -130
- package/dist/capabilities/deepinfra.json +92 -83
- package/dist/capabilities/digitalocean.json +112 -112
- package/dist/capabilities/dothoosh.json +31 -31
- package/dist/capabilities/doubleword.json +22 -22
- package/dist/capabilities/edenai.json +898 -1743
- package/dist/capabilities/empiriolabs.json +168 -168
- package/dist/capabilities/engy.json +19 -19
- package/dist/capabilities/entrim.json +2 -2
- package/dist/capabilities/evroc.json +12 -12
- package/dist/capabilities/ezkielyna.json +11 -11
- package/dist/capabilities/fastrouter.json +82 -82
- package/dist/capabilities/fireworks-ai.json +125 -64
- package/dist/capabilities/fortytwo.json +9 -3
- package/dist/capabilities/freemodel.json +19 -19
- 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 +23 -23
- package/dist/capabilities/google.json +50 -50
- package/dist/capabilities/graphn.json +13 -13
- package/dist/capabilities/greenpt.json +35 -35
- package/dist/capabilities/groq.json +3 -3
- package/dist/capabilities/helicone.json +84 -84
- package/dist/capabilities/hetzner.json +35 -3
- package/dist/capabilities/hostinger-router.json +15 -15
- package/dist/capabilities/hpc-ai.json +12 -12
- package/dist/capabilities/huawei-maas.json +14 -14
- package/dist/capabilities/hubris.json +33 -33
- package/dist/capabilities/huggingface.json +108 -158
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +20 -28
- package/dist/capabilities/impossibl.json +152 -152
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +6 -6
- package/dist/capabilities/inco.json +5 -5
- package/dist/capabilities/infer.json +20 -20
- package/dist/capabilities/inferall.json +10 -10
- package/dist/capabilities/inference-coop.json +15 -15
- package/dist/capabilities/inferenceapis.json +11 -11
- package/dist/capabilities/inferris.json +3 -3
- package/dist/capabilities/infersia.json +11 -11
- package/dist/capabilities/infomaniak.json +2 -2
- package/dist/capabilities/iteracompute.json +48 -48
- package/dist/capabilities/jad-ai.json +2 -2
- package/dist/capabilities/jalapeno.json +12 -12
- package/dist/capabilities/jiekou.json +58 -58
- package/dist/capabilities/jzstoken.json +53 -54
- package/dist/capabilities/keln.json +13 -13
- package/dist/capabilities/kenari.json +119 -127
- package/dist/capabilities/kilo.json +643 -647
- 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 +14 -14
- package/dist/capabilities/korouter.json +34 -34
- package/dist/capabilities/kunavo.json +7 -7
- package/dist/capabilities/liquid.json +11 -11
- package/dist/capabilities/lithosai.json +3 -3
- package/dist/capabilities/llmgateway-providers.json +949 -880
- package/dist/capabilities/llmgateway.json +344 -343
- package/dist/capabilities/llmtr.json +29 -29
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +53 -53
- package/dist/capabilities/lyceum.json +17 -9
- package/dist/capabilities/melious.json +14 -14
- package/dist/capabilities/merge-gateway.json +303 -301
- package/dist/capabilities/meta.json +9 -9
- package/dist/capabilities/mistral.json +20 -20
- package/dist/capabilities/mixlayer.json +2 -2
- package/dist/capabilities/modal.json +10 -10
- package/dist/capabilities/model-oracle-ai.json +23 -23
- package/dist/capabilities/modelis.json +22 -22
- package/dist/capabilities/modular.json +31 -9
- package/dist/capabilities/moneo.json +13 -13
- package/dist/capabilities/moonshotai-cn.json +6 -6
- package/dist/capabilities/moonshotai.json +6 -6
- package/dist/capabilities/morph.json +15 -15
- package/dist/capabilities/munito.json +2 -2
- package/dist/capabilities/nan.json +24 -24
- package/dist/capabilities/nano-gpt.json +595 -580
- package/dist/capabilities/nearai.json +101 -101
- package/dist/capabilities/nebius.json +26 -26
- package/dist/capabilities/neon.json +125 -125
- package/dist/capabilities/neuralwatt.json +43 -43
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +123 -123
- package/dist/capabilities/nvidia.json +39 -22
- package/dist/capabilities/oathbreaker.json +26 -3
- package/dist/capabilities/obscurify.json +22 -22
- package/dist/capabilities/oci.json +5 -5
- package/dist/capabilities/ofox.json +327 -327
- package/dist/capabilities/ollama-cloud.json +58 -58
- package/dist/capabilities/openai.json +57 -57
- package/dist/capabilities/opencode-go.json +90 -90
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +561 -557
- package/dist/capabilities/opper.json +30 -30
- package/dist/capabilities/orcarouter.json +238 -238
- package/dist/capabilities/outerlabs.json +29 -29
- package/dist/capabilities/ovhcloud.json +20 -20
- package/dist/capabilities/pareto.json +4 -4
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +63 -63
- package/dist/capabilities/phala.json +22 -22
- package/dist/capabilities/pioneer.json +26 -26
- package/dist/capabilities/poe.json +134 -134
- package/dist/capabilities/poolside.json +3 -3
- package/dist/capabilities/powerspring.json +8 -8
- package/dist/capabilities/primalabs.json +8 -8
- package/dist/capabilities/prime.json +133 -123
- package/dist/capabilities/privatemode-ai.json +13 -13
- package/dist/capabilities/proxystacks.json +6 -6
- package/dist/capabilities/qiniu-ai.json +15 -15
- package/dist/capabilities/refuseless.json +6 -6
- package/dist/capabilities/regolo-ai.json +9 -9
- package/dist/capabilities/requesty.json +386 -171
- package/dist/capabilities/ruapi.json +29 -13
- package/dist/capabilities/runcrate.json +8 -8
- package/dist/capabilities/runinfra.json +9 -9
- package/dist/capabilities/sakana.json +3 -3
- package/dist/capabilities/sambanova.json +5 -5
- package/dist/capabilities/sandbase.json +17 -17
- package/dist/capabilities/sarvam.json +14 -14
- package/dist/capabilities/scaleway.json +13 -13
- package/dist/capabilities/scnet-token-plan.json +12 -12
- package/dist/capabilities/scx-ai.json +22 -22
- package/dist/capabilities/sensenova.json +10 -10
- package/dist/capabilities/siliconflow-cn.json +49 -49
- package/dist/capabilities/siliconflow.json +54 -54
- package/dist/capabilities/snowflake-cortex.json +17 -17
- package/dist/capabilities/sokkan.json +5 -5
- package/dist/capabilities/sparrowcodes.json +23 -23
- package/dist/capabilities/standardcompute.json +94 -94
- package/dist/capabilities/steadyrouter.json +40 -40
- package/dist/capabilities/stepfun-ai-step-plan.json +5 -5
- package/dist/capabilities/stepfun-ai.json +5 -5
- package/dist/capabilities/stepfun-step-plan.json +5 -5
- package/dist/capabilities/stepfun.json +5 -5
- package/dist/capabilities/stepping-stone.json +9 -9
- package/dist/capabilities/subconscious.json +2 -2
- package/dist/capabilities/synthetic.json +10 -10
- package/dist/capabilities/synthorai.json +22 -22
- package/dist/capabilities/teamorouter.json +23 -23
- package/dist/capabilities/teapot-router.json +12 -12
- package/dist/capabilities/tencent-token-plan-intl.json +126 -0
- package/dist/capabilities/tencent-token-plan.json +35 -35
- package/dist/capabilities/tencent-tokenhub.json +51 -36
- package/dist/capabilities/tensorx.json +44 -44
- package/dist/capabilities/tenstorrent.json +6 -6
- package/dist/capabilities/the-grid-ai.json +32 -32
- package/dist/capabilities/thinkingmachines.json +48 -48
- package/dist/capabilities/tinfoil.json +11 -11
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +40 -40
- 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 +6 -6
- package/dist/capabilities/trustedtokens.json +13 -13
- package/dist/capabilities/umans-ai-coding-plan.json +14 -14
- package/dist/capabilities/umans-ai.json +12 -12
- package/dist/capabilities/uncensuredai.json +2 -2
- package/dist/capabilities/unrestricted.json +8 -8
- package/dist/capabilities/uplinkswitch.json +18 -18
- package/dist/capabilities/upstage.json +6 -6
- package/dist/capabilities/vancine.json +18 -18
- package/dist/capabilities/vercel.json +590 -587
- package/dist/capabilities/vivgrid.json +87 -78
- package/dist/capabilities/volcengine-coding-plan.json +32 -23
- package/dist/capabilities/volcengine.json +31 -30
- package/dist/capabilities/vultr.json +26 -26
- package/dist/capabilities/wafer.ai.json +18 -18
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +10 -10
- package/dist/capabilities/wandb.json +10 -10
- package/dist/capabilities/watt.json +26 -26
- package/dist/capabilities/xai.json +4 -4
- 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 +13 -13
- package/dist/capabilities/xxapi.json +28 -28
- package/dist/capabilities/zai-coding-plan.json +18 -18
- package/dist/capabilities/zai.json +30 -30
- package/dist/capabilities/zenifra.json +30 -30
- package/dist/capabilities/zenmux.json +205 -205
- package/dist/capabilities/zerogpu.json +11 -11
- package/dist/capabilities/zhipuai-coding-plan.json +2 -2
- package/dist/capabilities/zhipuai.json +30 -30
- package/dist/capabilities/zro.json +4 -4
- package/dist/channels/agent-channels.d.ts +29 -0
- package/dist/channels/attach-file-tool.d.ts +22 -0
- package/dist/channels/index.cjs +11 -2
- package/dist/channels/index.d.ts +10 -0
- package/dist/channels/index.js +3 -3
- package/dist/channels/output-processor.d.ts +12 -0
- package/dist/channels/reply-guidance-processor.d.ts +26 -0
- package/dist/channels/reply-mode.d.ts +66 -0
- package/dist/channels/reply-reminder-processor.d.ts +23 -0
- package/dist/channels/reply-tool.d.ts +43 -0
- package/dist/channels/state-adapter.d.ts +3 -1
- package/dist/channels/stream-helpers.d.ts +17 -0
- package/dist/channels/thread-link-processor.d.ts +48 -0
- package/dist/channels/thread-lookup.d.ts +16 -0
- package/dist/channels/tool-announcement-processor.d.ts +29 -0
- package/dist/channels/types.d.ts +25 -0
- package/dist/{channels-tVV_de9Q.cjs → channels-BVnDIsZS.cjs} +122 -1
- package/dist/{channels-Wh32drgu.js → channels-CndspFXP.js} +99 -2
- 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/index.d.ts +1 -1
- package/dist/datasets/experiment/item.d.ts +4 -3
- package/dist/datasets/experiment/scorer.d.ts +45 -11
- package/dist/datasets/index.cjs +3 -2
- package/dist/datasets/index.js +3 -3
- package/dist/{dist-ByO0vuJJ-BjMue5_p.cjs → dist-CufwpBZM-CwERFaas.cjs} +4 -4
- package/dist/{dist-ByO0vuJJ-CCXLBnvJ.js → dist-CufwpBZM-DK14Qe0Z.js} +4 -4
- package/dist/docs/SKILL.md +3 -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-channels.md +43 -0
- package/dist/docs/references/docs-evals-custom-scorers.md +1 -1
- package/dist/docs/references/docs-evals-experiments.md +13 -3
- 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 +1 -1
- package/dist/docs/references/reference-agents-durable-agent.md +2 -0
- 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-channels-thread-link.md +67 -0
- 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 +8 -7
- package/dist/docs/references/reference-workspace-sandbox.md +14 -0
- package/dist/docs/references/reference.md +2 -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/runner.d.ts +12 -0
- package/dist/knowledge/importers/types.d.ts +4 -0
- package/dist/knowledge/index.cjs +209 -38
- package/dist/knowledge/index.d.ts +12 -2
- package/dist/knowledge/index.js +208 -39
- 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 +7091 -7163
- package/dist/{llm-BAiOsNAP.cjs → llm-B1semiTO.cjs} +38 -78
- package/dist/{llm-B1zaFLYZ.js → llm-CytL7cpw.js} +38 -78
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-BVX9nVrM.cjs → manager-BwyfS4ha.cjs} +220 -93
- package/dist/{manager-ChK9GdGz.js → manager-DnTzA9GL.js} +215 -94
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-CUGfgEpZ.js → mastra-DTkZPpch.js} +17 -17
- package/dist/{mastra-HSmofHEJ.cjs → mastra-Dj35Lj_J.cjs} +17 -17
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/{message-list-KRbg-TnI.js → message-list-BGm1DCiG.js} +231 -130
- package/dist/{message-list-Cj0Sq_JP.cjs → message-list-vR3uLAHL.cjs} +351 -250
- package/dist/{model-C47BJRtR.js → model-DyQ07rPH.js} +4 -3
- package/dist/{model-WahorgzJ.cjs → model-eDfetuno.cjs} +4 -3
- package/dist/{netlify-D99AnEhW.cjs → netlify-BC4v7Ufv.cjs} +41377 -30474
- package/dist/{netlify-CfDXkuLf.js → netlify-BUvdxfHe.js} +41373 -30476
- 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-CO1NVbO5.cjs → provider-registry-Bn01gq9y.cjs} +22180 -22242
- package/dist/{provider-registry-CR385GJ4.js → provider-registry-CP_5SNiw.js} +22181 -22243
- package/dist/provider-registry.json +22417 -22539
- package/dist/{registry-generator-B3erRqYS.js → registry-generator-CDPyxbzt.js} +1 -1
- package/dist/{registry-generator-Cvp34qcB.cjs → registry-generator-CNFKGRFQ.cjs} +1 -1
- package/dist/{rehydrate-CJBLrZxs.js → rehydrate-CnGNY2zq.js} +2 -2
- package/dist/{rehydrate-Da4hNuaK.cjs → rehydrate-DExpzlNS.cjs} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-DdeEBsVW.js → run-registry-BL_kKvFE.js} +1559 -298
- package/dist/{run-registry-TOOfO3hT.cjs → run-registry-CibQoN6K.cjs} +1637 -298
- package/dist/storage/constants.cjs +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +16 -1
- package/dist/storage/domains/knowledge/importers-inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/importers.d.ts +8 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +5 -1
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +3 -3
- package/dist/storage/types.d.ts +8 -0
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-C5PagEDs.js → stream-1DGoEkG2.js} +37 -14
- package/dist/{stream-DH7Qgz8l.cjs → stream-D_7tMaJe.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-DVYJXlQJ.js → tool-loop-agent-BXya_RYj.js} +4 -4
- package/dist/{tool-loop-agent-CJTs4T8b.cjs → tool-loop-agent-CLB1r3X3.cjs} +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-xJi_N6Tx.cjs → utils-B-KOMA_Q.cjs} +7 -6
- package/dist/{utils-D8upuTwy.js → utils-C55ZdVaj.js} +7 -6
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-DTkW3Vlp.js → validate-BDfYr72F.js} +1 -1
- package/dist/{validate-6eZ8Wssn.cjs → validate-CmZhnsmX.cjs} +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +2 -2
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/worker/workers/orchestration-worker.d.ts +1 -0
- package/dist/{worker-DbcFkKJO.js → worker-BG1rw_dg.js} +5 -5
- package/dist/{worker-24ORi-wV.cjs → worker-BoybIUTI.cjs} +10 -4
- package/dist/{worker-Dqubrnf8.js → worker-CuK2RaC0.js} +2 -2
- package/dist/{worker-BO3u_WjZ.cjs → worker-D2B-x7Le.cjs} +2 -2
- package/dist/{workflow-wXOf72fO.js → workflow-Bt09PcH1.js} +3 -3
- package/dist/{workflow-D5Fc5ieC.cjs → workflow-CTKqeRXU.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/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 +8 -8
- package/src/llm/model/provider-types.generated.d.ts +7091 -7163
- /package/dist/_types/{@ai-sdk_provider-utils@4.0.66 → @ai-sdk_provider-utils@4.0.67}/dist/index.d.ts +0 -0
- /package/dist/_types/{@ai-sdk_provider-utils@4.0.66 → @ai-sdk_provider-utils@4.0.67}/package.json +0 -0
package/dist/knowledge/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as MastraBase } from "../base-CKLWBhDo.js";
|
|
2
|
-
import { Ai as
|
|
2
|
+
import { $t as PINNED_READ_MEMO_KEY, Ai as KnowledgePageDepthError, An as strongerKnowledgeRole, Bi as MAX_KNOWLEDGE_PAGE_LIST_LIMIT, Ci as KnowledgeTransactionDeadlineError, Cn as knowledgeReadScopeFor, Cr as knowledgeSemanticDocumentId, Di as inspectKnowledgeSchema, Dn as knowledgeMemoryScopes, Ei as createKnowledgeUlid, En as compileKnowledgeScopes, Er as parseKnowledgeNodeCursor, Fi as MAX_KNOWLEDGE_PAGE_BODY_LINKS, Gi as knowledgeLinkRefKey, Hi as assertKnowledgeNoteTextWithinBound, Ii as MAX_KNOWLEDGE_PAGE_DEPTH, Ji as knowledgePositionBetween, Jo as augmentWithInit, Ki as knowledgePagePath, Li as MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS, Mi as KnowledgePageKeyConflictError, Mn as encodeKnowledgeScopeId, Ni as MAX_KNOWLEDGE_MOVE_PAGES, Nn as buildKnowledgeInstructions, Oi as parseKnowledgeWikilinks, On as knowledgeRunScopes, Pi as MAX_KNOWLEDGE_NOTE_TOKENS, Ri as MAX_KNOWLEDGE_PAGE_LINKS, Si as KnowledgeStorage, Sn as knowledgeAccessGrants, Sr as knowledgeScopeKey, Ti as assertKnowledgeSchemaCompatible, Tn as KnowledgeDeclarationError, Tr as knowledgeVisibleScopeKeys, Ui as assertKnowledgePageDescriptionWithinBound, Vi as MAX_KNOWLEDGE_PIN_LIST_DEPTH, Wi as canonicalKnowledgeName, Xi as parseKnowledgePageRef, Yi as knowledgeScopeReadable, Yo as getStorageSource, Zi as KnowledgeInvalidCursorError, _i as KNOWLEDGE_STORAGE_CONTRACT_VERSION, _n as knowledgeSubtree, _r as assertKnowledgeScopeWithinCeiling, an as knowledgeRunPrincipals, bi as KnowledgeNotFoundError, bn as syncKnowledgePageBodyLinks, br as expandKnowledgeScope, cn as addKnowledgeNote, dn as removeKnowledgePage, dr as MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH, en as knowledgeDeliveredPins, fn as updateKnowledgeNote, fr as MAX_KNOWLEDGE_RECORD_TEXT_LENGTH, gi as KnowledgeImportersStorage, gn as KnowledgeLinkRefreshIncompleteError, gr as assertKnowledgeRecordTextWithinBound, hi as KnowledgeImporterRunStateError, hr as assertKnowledgeDescriptionWithinBound, in as KnowledgeRunScopesError, ji as KnowledgePageHasChildrenError, jn as decodeKnowledgeScopeId, ki as KnowledgeMoveTooLargeError, kn as knowledgeScopeAddress, ln as moveKnowledgePage, mi as KnowledgeImporterBindingConflictError, mn as KnowledgeSemanticIndex, mr as assertKnowledgeCeilingRaised, nn as heldScopes, on as knowledgeAgentScopes, pi as InMemoryKnowledgeStorage, pn as upsertKnowledgePage, pr as MAX_KNOWLEDGE_SCOPE_TAGS, qi as knowledgePinDepth, rn as KnowledgeRun, sn as knowledgePersonaScopes, tn as buildKnowledgePageTools, un as removeKnowledgeNote, vi as KNOWLEDGE_STORAGE_SCHEMA_VERSION, vn as refreshKnowledgeLinksTo, vr as canonicalizeKnowledgeScope, wi as KnowledgeUnsupportedCapabilityError, wn as knowledgeRoleOn, wr as knowledgeSemanticIdempotencyKey, xi as KnowledgeSchemaResetRequiredError, xn as updateKnowledgeLinks, xr as isKnowledgeScopeVisible, yi as KnowledgeConflictError, yn as reindexKnowledgeLinks, yr as createKnowledgeNodeCursor, zi as MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH } from "../run-registry-BL_kKvFE.js";
|
|
3
3
|
import { standardSchemaToJSONSchema, toStandardSchema } from "../schema/index.js";
|
|
4
4
|
import { i as createStandardSchemaIssuesError } from "../tool-Z3bykc1m.js";
|
|
5
5
|
import { randomUUID } from "crypto";
|
|
@@ -173,6 +173,7 @@ const KNOWLEDGE_IMPORTER_ERROR_CODES = [
|
|
|
173
173
|
"credential_missing",
|
|
174
174
|
"importer_missing_from_deploy",
|
|
175
175
|
"importer_error",
|
|
176
|
+
"flush_too_large",
|
|
176
177
|
"stopped",
|
|
177
178
|
"lease_expired",
|
|
178
179
|
"deadline_exceeded"
|
|
@@ -670,17 +671,22 @@ function sourceError(error) {
|
|
|
670
671
|
* @experimental
|
|
671
672
|
*/
|
|
672
673
|
async function runKnowledgeImport(options) {
|
|
673
|
-
const { host, budgetMs = 15e5, graceMs = 18e4, maxPasses = 200, bufferSize = 200, flushAfterMs = 3e4, heartbeatMs = 3e4, maxRetries = 8, hostCallTimeoutMs = 6e4, retryDelayMs = (attempt) => Math.min(250 * 2 ** attempt, 1e4) } = options;
|
|
674
|
+
const { host, budgetMs = 15e5, graceMs = 18e4, maxPasses = 200, bufferSize = 200, maxFlushBytes: ownMaxFlushBytes = Infinity, flushAfterMs = 3e4, heartbeatMs = 3e4, maxRetries = 8, hostCallTimeoutMs = 6e4, retryDelayMs = (attempt) => Math.min(250 * 2 ** attempt, 1e4) } = options;
|
|
674
675
|
if (!Number.isFinite(flushAfterMs) || flushAfterMs <= 0 || flushAfterMs > 2 ** 31 - 1) throw new TypeError(`flushAfterMs must be a positive number of milliseconds up to 2147483647, got ${flushAfterMs}`);
|
|
676
|
+
if (ownMaxFlushBytes !== Infinity && !(Number.isInteger(ownMaxFlushBytes) && ownMaxFlushBytes > 0)) throw new TypeError(`maxFlushBytes must be a positive whole number of bytes, got ${ownMaxFlushBytes}`);
|
|
675
677
|
const started = await within(host.startRun(options.bindingId, options.start), hostCallTimeoutMs, () => new KnowledgeImporterHostError("host call timed out"));
|
|
676
678
|
if (started.status === "skipped") return started;
|
|
677
679
|
const { runId, generation } = started;
|
|
680
|
+
const hostMaxFlushBytes = started.maxFlushBytes;
|
|
681
|
+
const maxFlushBytes = typeof hostMaxFlushBytes === "number" && Number.isInteger(hostMaxFlushBytes) && hostMaxFlushBytes > 0 ? Math.min(ownMaxFlushBytes, hostMaxFlushBytes) : ownMaxFlushBytes;
|
|
678
682
|
const startedAt = Date.now();
|
|
679
683
|
let lastSeq = started.lastSeq;
|
|
680
684
|
/** A flush sent but never acknowledged: it may have committed. */
|
|
681
685
|
let unsettledSeq;
|
|
682
686
|
let state = { ...started.state };
|
|
683
687
|
let buffer = [];
|
|
688
|
+
/** Encoded bytes of the ops in `buffer`, without the commas between them. */
|
|
689
|
+
let bufferBytes = 0;
|
|
684
690
|
let stop;
|
|
685
691
|
/** Armed while the buffer holds ops; sends them once the oldest has waited `flushAfterMs`. */
|
|
686
692
|
let flushTimer;
|
|
@@ -731,6 +737,7 @@ async function runKnowledgeImport(options) {
|
|
|
731
737
|
disarm();
|
|
732
738
|
const ops = buffer;
|
|
733
739
|
buffer = [];
|
|
740
|
+
bufferBytes = 0;
|
|
734
741
|
const next = flushing.then(async () => {
|
|
735
742
|
if (stop) throw stop;
|
|
736
743
|
if (ops.length === 0 && !staged && !settle) return;
|
|
@@ -755,6 +762,11 @@ async function runKnowledgeImport(options) {
|
|
|
755
762
|
digest,
|
|
756
763
|
...body
|
|
757
764
|
};
|
|
765
|
+
if (maxFlushBytes !== Infinity && encodedBytes(request) > maxFlushBytes) {
|
|
766
|
+
flushFailure = { code: "flush_too_large" };
|
|
767
|
+
halt("flush");
|
|
768
|
+
throw stop;
|
|
769
|
+
}
|
|
758
770
|
unsettledSeq = seq;
|
|
759
771
|
try {
|
|
760
772
|
const receipt = await withRetries(() => host.flush(request), "mutation");
|
|
@@ -779,14 +791,70 @@ async function runKnowledgeImport(options) {
|
|
|
779
791
|
flushing = next.catch(() => {});
|
|
780
792
|
return next;
|
|
781
793
|
}
|
|
782
|
-
|
|
794
|
+
/** The request around the ops, at the longest `seq` it can have; `ops` empty, no `state`. */
|
|
795
|
+
const envelopeBytes = encodedBytes({
|
|
796
|
+
runId,
|
|
797
|
+
generation,
|
|
798
|
+
seq: Number.MAX_SAFE_INTEGER,
|
|
799
|
+
digest: "0".repeat(64),
|
|
800
|
+
ops: []
|
|
801
|
+
});
|
|
802
|
+
/**
|
|
803
|
+
* The envelope at the shortest `seq` the next request can have. A request's `seq` is only known
|
|
804
|
+
* when it is sent, so splitting plans for the longest; refusing what can never fit uses the
|
|
805
|
+
* shortest, and the request as sent is measured again before it goes.
|
|
806
|
+
*/
|
|
807
|
+
const shortestEnvelopeBytes = () => envelopeBytes - String(Number.MAX_SAFE_INTEGER).length + String(lastSeq + 1).length;
|
|
808
|
+
/** Bytes of a request holding the buffer plus `extra` more ops' bytes over `more` ops, and a state. */
|
|
809
|
+
const requestBytes = (extra, more, stateBytes) => {
|
|
810
|
+
const count = buffer.length + more;
|
|
811
|
+
const commas = Math.max(count - 1, 0);
|
|
812
|
+
const state = stateBytes === void 0 ? 0 : 9 + stateBytes;
|
|
813
|
+
return envelopeBytes + bufferBytes + extra + commas + state;
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* Measures what the importer hands over and returns a copy decoded from that encoding, so a value
|
|
817
|
+
* the importer changes after handing it over can't outgrow its measured size. Anything
|
|
818
|
+
* unencodable or too big ends the run here.
|
|
819
|
+
*/
|
|
820
|
+
const measure = (value, alone) => {
|
|
821
|
+
let json;
|
|
822
|
+
let bytes;
|
|
823
|
+
try {
|
|
824
|
+
json = JSON.stringify(value);
|
|
825
|
+
bytes = new TextEncoder().encode(json).byteLength;
|
|
826
|
+
} catch (error) {
|
|
827
|
+
flushFailure = { code: "importer_error" };
|
|
828
|
+
halt("flush");
|
|
829
|
+
throw error;
|
|
830
|
+
}
|
|
831
|
+
if (alone(bytes) > maxFlushBytes) {
|
|
832
|
+
flushFailure = { code: "flush_too_large" };
|
|
833
|
+
halt("flush");
|
|
834
|
+
throw stop;
|
|
835
|
+
}
|
|
836
|
+
return {
|
|
837
|
+
bytes,
|
|
838
|
+
copy: JSON.parse(json)
|
|
839
|
+
};
|
|
840
|
+
};
|
|
841
|
+
const push = async (handed) => {
|
|
783
842
|
if (stop) throw stop;
|
|
843
|
+
let op = handed;
|
|
844
|
+
let sending;
|
|
845
|
+
if (maxFlushBytes !== Infinity) {
|
|
846
|
+
const { bytes, copy } = measure(handed, (opBytes) => shortestEnvelopeBytes() + opBytes);
|
|
847
|
+
op = copy;
|
|
848
|
+
if (buffer.length > 0 && requestBytes(bytes, 1) > maxFlushBytes) sending = flush();
|
|
849
|
+
bufferBytes += bytes;
|
|
850
|
+
}
|
|
784
851
|
buffer.push(op);
|
|
785
|
-
if (buffer.length
|
|
786
|
-
else if (!flushTimer) {
|
|
852
|
+
if (!flushTimer && buffer.length < bufferSize) {
|
|
787
853
|
flushTimer = setTimeout(() => flush().catch(() => {}), flushAfterMs);
|
|
788
854
|
flushTimer.unref?.();
|
|
789
855
|
}
|
|
856
|
+
if (sending) await sending;
|
|
857
|
+
if (buffer.length >= bufferSize) await flush();
|
|
790
858
|
};
|
|
791
859
|
const finish = async (request) => {
|
|
792
860
|
const result = await finishRun(host, {
|
|
@@ -850,7 +918,12 @@ async function runKnowledgeImport(options) {
|
|
|
850
918
|
get: async (key) => state[key],
|
|
851
919
|
set: async (key, value) => {
|
|
852
920
|
if (stop) throw stop;
|
|
853
|
-
|
|
921
|
+
const staged = { [key]: value };
|
|
922
|
+
if (maxFlushBytes !== Infinity) {
|
|
923
|
+
const { bytes } = measure(staged, (stateBytes) => shortestEnvelopeBytes() + 9 + stateBytes);
|
|
924
|
+
if (requestBytes(0, 0, bytes) > maxFlushBytes) flush().catch(() => {});
|
|
925
|
+
}
|
|
926
|
+
await flush(staged);
|
|
854
927
|
}
|
|
855
928
|
},
|
|
856
929
|
items: {
|
|
@@ -956,6 +1029,9 @@ async function finishRun(host, request, lastSeq, unsettledSeq, withRetries) {
|
|
|
956
1029
|
lastSeq
|
|
957
1030
|
};
|
|
958
1031
|
}
|
|
1032
|
+
function encodedBytes(value) {
|
|
1033
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
1034
|
+
}
|
|
959
1035
|
// src/knowledge/importers/sink.ts
|
|
960
1036
|
/**
|
|
961
1037
|
* Applies one flush's ops to pages and the node map, on a transaction view. Pages are found by id
|
|
@@ -1116,7 +1192,8 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1116
1192
|
unchanged: 0,
|
|
1117
1193
|
moved: 0,
|
|
1118
1194
|
removed: 0,
|
|
1119
|
-
stubbed: 0
|
|
1195
|
+
stubbed: 0,
|
|
1196
|
+
merged: 0
|
|
1120
1197
|
},
|
|
1121
1198
|
refused: [],
|
|
1122
1199
|
changes: [],
|
|
@@ -1136,20 +1213,24 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1136
1213
|
const keyPath = async (page) => {
|
|
1137
1214
|
const keys = [];
|
|
1138
1215
|
const ids = [];
|
|
1139
|
-
|
|
1140
|
-
|
|
1216
|
+
if (page.isScope) return page.id === scope.id ? {
|
|
1217
|
+
keys,
|
|
1218
|
+
ids
|
|
1219
|
+
} : null;
|
|
1220
|
+
const parents = page.parentId ? await storage.getPageParents({
|
|
1221
|
+
parentId: page.parentId,
|
|
1222
|
+
read: "all"
|
|
1223
|
+
}) : [];
|
|
1224
|
+
for (const at of [page, ...parents]) {
|
|
1225
|
+
if (at.isScope) return at.id === scope.id ? {
|
|
1226
|
+
keys,
|
|
1227
|
+
ids
|
|
1228
|
+
} : null;
|
|
1141
1229
|
if (!live(at) || at.key === void 0) return null;
|
|
1142
1230
|
keys.unshift(at.key);
|
|
1143
1231
|
ids.unshift(at.id);
|
|
1144
|
-
at = at.parentId ? await storage.getPage({
|
|
1145
|
-
id: at.parentId,
|
|
1146
|
-
read: "all"
|
|
1147
|
-
}) : null;
|
|
1148
1232
|
}
|
|
1149
|
-
return
|
|
1150
|
-
keys,
|
|
1151
|
-
ids
|
|
1152
|
-
} : null;
|
|
1233
|
+
return null;
|
|
1153
1234
|
};
|
|
1154
1235
|
const sameKeys = (a, b) => a.length === b.length && a.every((key, i) => key === b[i]);
|
|
1155
1236
|
/**
|
|
@@ -1296,12 +1377,13 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1296
1377
|
};
|
|
1297
1378
|
};
|
|
1298
1379
|
const nodeOf = async (sourceId) => sourceId ? importers.getNode(binding.id, sourceId) : null;
|
|
1299
|
-
const
|
|
1380
|
+
const stateOf = async (node) => {
|
|
1300
1381
|
const page = await storage.getPage({
|
|
1301
1382
|
id: node.pageId,
|
|
1302
1383
|
read: "all"
|
|
1303
1384
|
});
|
|
1304
|
-
|
|
1385
|
+
if (page?.mergedInto) return "merged";
|
|
1386
|
+
return !page || !!page.deletedAt || page.scopeId !== scope.id ? "gone" : "live";
|
|
1305
1387
|
};
|
|
1306
1388
|
/**
|
|
1307
1389
|
* Drops the node of a page that is gone, so its item is written again as new. Pages that linked to
|
|
@@ -1357,11 +1439,10 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1357
1439
|
};
|
|
1358
1440
|
const liveNodeOf = async (sourceId) => {
|
|
1359
1441
|
const node = await nodeOf(sourceId);
|
|
1360
|
-
return node &&
|
|
1442
|
+
return node && await stateOf(node) === "live" ? node : null;
|
|
1361
1443
|
};
|
|
1362
1444
|
const ref = (keys) => `${target.scope}#${keys.join("/")}`;
|
|
1363
|
-
const linkLine = async (link) => {
|
|
1364
|
-
const node = await importers.getNode(binding.id, link.sourceId);
|
|
1445
|
+
const linkLine = async (link, node) => {
|
|
1365
1446
|
const page = node ? await storage.getPage({
|
|
1366
1447
|
id: node.pageId,
|
|
1367
1448
|
read: "all"
|
|
@@ -1372,11 +1453,30 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1372
1453
|
const renderLinks = async (links) => {
|
|
1373
1454
|
const lines = [];
|
|
1374
1455
|
const unresolved = [];
|
|
1456
|
+
const getNodes = async (sourceIds) => {
|
|
1457
|
+
if (!sourceIds.length) return [];
|
|
1458
|
+
if (importers.getNodes) return importers.getNodes(binding.id, sourceIds);
|
|
1459
|
+
const nodes = [];
|
|
1460
|
+
for (const sourceId of new Set(sourceIds)) {
|
|
1461
|
+
const node = await importers.getNode(binding.id, sourceId);
|
|
1462
|
+
if (node) nodes.push(node);
|
|
1463
|
+
}
|
|
1464
|
+
return nodes;
|
|
1465
|
+
};
|
|
1466
|
+
const read = async (sourceIds) => new Map((await getNodes(sourceIds)).map((node) => [node.sourceId, node]));
|
|
1467
|
+
const before = await read(links.map((link) => link.sourceId));
|
|
1468
|
+
const rendered = [];
|
|
1375
1469
|
for (const link of links) {
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
|
|
1470
|
+
const node = before.get(link.sourceId);
|
|
1471
|
+
rendered.push({
|
|
1472
|
+
link,
|
|
1473
|
+
line: await linkLine(link, node),
|
|
1474
|
+
pageId: node?.pageId
|
|
1475
|
+
});
|
|
1379
1476
|
}
|
|
1477
|
+
const after = await read(rendered.filter((each) => each.line).map((each) => each.link.sourceId));
|
|
1478
|
+
for (const { link, line, pageId } of rendered) if (line && after.get(link.sourceId)?.pageId === pageId) lines.push(line);
|
|
1479
|
+
else unresolved.push(encodeLink(link));
|
|
1380
1480
|
return {
|
|
1381
1481
|
section: linkSection(lines),
|
|
1382
1482
|
unresolved
|
|
@@ -1518,12 +1618,17 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1518
1618
|
};
|
|
1519
1619
|
const write = async (item, hasBody) => {
|
|
1520
1620
|
let existing = await importers.getNode(binding.id, item.sourceId);
|
|
1521
|
-
|
|
1621
|
+
const state = existing ? await stateOf(existing) : null;
|
|
1622
|
+
if (state === "merged") return null;
|
|
1623
|
+
if (existing && state === "gone") {
|
|
1522
1624
|
await forget(existing);
|
|
1523
1625
|
existing = null;
|
|
1524
1626
|
}
|
|
1525
|
-
const
|
|
1526
|
-
const
|
|
1627
|
+
const parentRecord = await nodeOf(item.parent);
|
|
1628
|
+
const parentState = parentRecord ? await stateOf(parentRecord) : null;
|
|
1629
|
+
const sourceParent = parentState === "live" ? parentRecord : null;
|
|
1630
|
+
const parentMerged = parentState === "merged";
|
|
1631
|
+
const misplaced = !!item.parent && !sourceParent && !parentMerged;
|
|
1527
1632
|
const parentNode = sourceParent ?? await liveNodeOf(item.fallbackParent);
|
|
1528
1633
|
const destination = parentNode ? await owned(parentNode.pageId, parentNode.sourceId) : anchor;
|
|
1529
1634
|
if (existing && destination.page.id === existing.pageId) throw new KnowledgeImportRefusalError("invalid");
|
|
@@ -1577,7 +1682,7 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1577
1682
|
const current = await owned(existing.pageId, item.sourceId);
|
|
1578
1683
|
page = current.page;
|
|
1579
1684
|
if (existing.stub && existing.adopted && !REMOVED_BODIES.has(page.body ?? "")) await keepBody(page.id, page.body ?? "");
|
|
1580
|
-
if (!current.outside && page.parentId !== destination.page.id) {
|
|
1685
|
+
if (!current.outside && !parentMerged && page.parentId !== destination.page.id) {
|
|
1581
1686
|
if (destination.keys.length > current.keys.length && sameKeys(destination.keys.slice(0, current.keys.length), current.keys)) throw new KnowledgeImportRefusalError("invalid");
|
|
1582
1687
|
({page, relinked} = await moveOwned(item.sourceId, page, destination));
|
|
1583
1688
|
moved = true;
|
|
@@ -1657,7 +1762,9 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1657
1762
|
if (op.op === "remove") {
|
|
1658
1763
|
const node = await importers.getNode(binding.id, sourceId);
|
|
1659
1764
|
if (!node) return;
|
|
1660
|
-
|
|
1765
|
+
const state = await stateOf(node);
|
|
1766
|
+
if (state === "merged") return;
|
|
1767
|
+
if (state === "gone") {
|
|
1661
1768
|
await forget(node);
|
|
1662
1769
|
result.applied = true;
|
|
1663
1770
|
return;
|
|
@@ -1729,7 +1836,12 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1729
1836
|
result.applied = true;
|
|
1730
1837
|
return;
|
|
1731
1838
|
}
|
|
1732
|
-
const
|
|
1839
|
+
const written = await write(op.item, op.op === "upsert");
|
|
1840
|
+
if (!written) {
|
|
1841
|
+
result.counts.merged++;
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
const { page, change, moved, relinked } = written;
|
|
1733
1845
|
recordRelinked(relinked, embeds);
|
|
1734
1846
|
if (change === "unchanged") {
|
|
1735
1847
|
result.counts.unchanged++;
|
|
@@ -1848,12 +1960,24 @@ async function applyKnowledgeImportFlush(input) {
|
|
|
1848
1960
|
moved: false,
|
|
1849
1961
|
relinked: false
|
|
1850
1962
|
};
|
|
1963
|
+
if (await stateOf(node) === "merged") {
|
|
1964
|
+
await importers.saveNode({
|
|
1965
|
+
...node,
|
|
1966
|
+
unsettled: false
|
|
1967
|
+
});
|
|
1968
|
+
return {
|
|
1969
|
+
moved: false,
|
|
1970
|
+
relinked: false
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1851
1973
|
const current = await owned(node.pageId, sourceId);
|
|
1852
1974
|
let { page, keys } = current;
|
|
1853
1975
|
let moved = false;
|
|
1854
1976
|
let relinked = false;
|
|
1855
|
-
const
|
|
1856
|
-
|
|
1977
|
+
const sourceParent = current.outside ? null : await nodeOf(node.parentSourceId);
|
|
1978
|
+
const parentMerged = !!sourceParent && await stateOf(sourceParent) === "merged";
|
|
1979
|
+
const parent = parentMerged ? null : sourceParent;
|
|
1980
|
+
let misplaced = !current.outside && !!node.parentSourceId && !parent && !parentMerged;
|
|
1857
1981
|
if (parent && canMove) {
|
|
1858
1982
|
const destination = await owned(parent.pageId, parent.sourceId);
|
|
1859
1983
|
if (page.parentId !== destination.page.id) {
|
|
@@ -2254,6 +2378,14 @@ function hostError(error) {
|
|
|
2254
2378
|
failure.cause = error;
|
|
2255
2379
|
return failure;
|
|
2256
2380
|
}
|
|
2381
|
+
/** A committed receipt as replayed; receipts written before the `merged` count existed read it as 0. */
|
|
2382
|
+
const storedReceipt = (receipt) => {
|
|
2383
|
+
const stored = receipt;
|
|
2384
|
+
return {
|
|
2385
|
+
...stored,
|
|
2386
|
+
merged: stored.merged ?? 0
|
|
2387
|
+
};
|
|
2388
|
+
};
|
|
2257
2389
|
const receiptCounts = (counts) => ({
|
|
2258
2390
|
created: counts.created ?? 0,
|
|
2259
2391
|
updated: counts.updated ?? 0,
|
|
@@ -2261,6 +2393,7 @@ const receiptCounts = (counts) => ({
|
|
|
2261
2393
|
moved: counts.moved ?? 0,
|
|
2262
2394
|
removed: counts.removed ?? 0,
|
|
2263
2395
|
stubbed: counts.stubbed ?? 0,
|
|
2396
|
+
merged: counts.merged ?? 0,
|
|
2264
2397
|
refused: counts.refused ?? 0
|
|
2265
2398
|
});
|
|
2266
2399
|
const runReceipt = (run) => {
|
|
@@ -2515,7 +2648,7 @@ function createLocalKnowledgeImporterHost(writer, options) {
|
|
|
2515
2648
|
});
|
|
2516
2649
|
if (replayed) {
|
|
2517
2650
|
if (replayed.digest !== digest) throw conflict("digest_mismatch", "This seq was committed with other content.");
|
|
2518
|
-
return replayed.receipt;
|
|
2651
|
+
return storedReceipt(replayed.receipt);
|
|
2519
2652
|
}
|
|
2520
2653
|
const [peek, peekRun] = await Promise.all([rootImporters.readWriterGuard(), rootImporters.getRun(flush.runId)]).catch((error) => {
|
|
2521
2654
|
throw hostError(error);
|
|
@@ -2540,7 +2673,7 @@ function createLocalKnowledgeImporterHost(writer, options) {
|
|
|
2540
2673
|
const stored = await importers.getFlush(flush.runId, flush.generation, flush.seq);
|
|
2541
2674
|
if (stored) {
|
|
2542
2675
|
if (stored.digest !== digest) throw conflict("digest_mismatch", "This seq was committed with other content.");
|
|
2543
|
-
return stored.receipt;
|
|
2676
|
+
return storedReceipt(stored.receipt);
|
|
2544
2677
|
}
|
|
2545
2678
|
if (!run || run.status !== "running") throw conflict("run_not_active", "The run is not running.");
|
|
2546
2679
|
if (run.generation !== flush.generation || guard.generation !== flush.generation) throw conflict("stale_generation", "The run belongs to an older writer generation.");
|
|
@@ -3323,6 +3456,19 @@ var KnowledgeScopeRuntime = class {
|
|
|
3323
3456
|
};
|
|
3324
3457
|
for (const address of addresses) await this.#materialize(address, principals, provenance, [], run);
|
|
3325
3458
|
}
|
|
3459
|
+
/**
|
|
3460
|
+
* The parent address a first write would place a not-yet-created scope under, as `#materialize`
|
|
3461
|
+
* chooses it: a template child's own parent, or the one held `belongsTo` candidate. Undefined when
|
|
3462
|
+
* the scope would stay unlinked.
|
|
3463
|
+
*/
|
|
3464
|
+
firstWriteParentAddress(address, principals) {
|
|
3465
|
+
const match = this.compiled.match(address);
|
|
3466
|
+
if (!match) return void 0;
|
|
3467
|
+
if (match.compiled.child) return address.slice(0, address.lastIndexOf("/"));
|
|
3468
|
+
if (!match.compiled.belongsTo) return void 0;
|
|
3469
|
+
const candidates = this.#belongsToCandidates(match, this.#held(principals));
|
|
3470
|
+
return candidates.length === 1 && candidates[0] !== address ? candidates[0] : void 0;
|
|
3471
|
+
}
|
|
3326
3472
|
/** The run's distinct principals grouped by declaration key, matched once. */
|
|
3327
3473
|
#held(principals) {
|
|
3328
3474
|
const held = /* @__PURE__ */ new Map();
|
|
@@ -4268,9 +4414,24 @@ var Knowledge = class extends MastraBase {
|
|
|
4268
4414
|
write
|
|
4269
4415
|
};
|
|
4270
4416
|
}
|
|
4271
|
-
/**
|
|
4272
|
-
|
|
4273
|
-
|
|
4417
|
+
/** Whether the resolved mint declarations need metadata.persona. @internal */
|
|
4418
|
+
async __needsAgentPersona() {
|
|
4419
|
+
await this.#runtime.resolve();
|
|
4420
|
+
return [...this.#runtime.compiled.declarations.values()].some((declaration) => declaration.declaration.mint === "run-identity" && declaration.pattern.params.some((param) => param === "role" || param === "teamId"));
|
|
4421
|
+
}
|
|
4422
|
+
/**
|
|
4423
|
+
* The run's principals as a stable key, or `undefined` when the run has no Knowledge view (no scopes,
|
|
4424
|
+
* or an undeclared scope). Loads the store's declarations first, so a scope only the store declares
|
|
4425
|
+
* counts; a failure loading them rejects. @internal
|
|
4426
|
+
*/
|
|
4427
|
+
async __principalsKey(context) {
|
|
4428
|
+
await this.#runtime.resolve();
|
|
4429
|
+
try {
|
|
4430
|
+
return knowledgeRunPrincipals(this.#runtime, context).sort().join("\n");
|
|
4431
|
+
} catch (error) {
|
|
4432
|
+
if (error instanceof KnowledgeRunScopesError || error instanceof KnowledgeDeclarationError) return void 0;
|
|
4433
|
+
throw error;
|
|
4434
|
+
}
|
|
4274
4435
|
}
|
|
4275
4436
|
/**
|
|
4276
4437
|
* The pinned pages a host-run caller with these principals receives, rendered as an agent run
|
|
@@ -4297,6 +4458,14 @@ var Knowledge = class extends MastraBase {
|
|
|
4297
4458
|
const run = await KnowledgeRun.start(this.#runtime, await this.getStorage(), context);
|
|
4298
4459
|
return knowledgeDeliveredPins(run, budget, this.#groups().read);
|
|
4299
4460
|
}
|
|
4461
|
+
/** The scopes a run holds a role on this turn, with that role. @internal */
|
|
4462
|
+
async __heldScopes(context) {
|
|
4463
|
+
const run = await KnowledgeRun.start(this.#runtime, await this.getStorage(), context);
|
|
4464
|
+
return (await heldScopes(run)).flatMap(({ address, role }) => role ? [{
|
|
4465
|
+
address,
|
|
4466
|
+
role
|
|
4467
|
+
}] : []);
|
|
4468
|
+
}
|
|
4300
4469
|
/** @internal */
|
|
4301
4470
|
__registerMastra(_mastra) {}
|
|
4302
4471
|
/** @internal */
|
|
@@ -4413,4 +4582,4 @@ var Knowledge = class extends MastraBase {
|
|
|
4413
4582
|
function createKnowledgeImporterHost(knowledge, options) {
|
|
4414
4583
|
return createLocalKnowledgeImporterHost(hostWriterOf(knowledge), options);
|
|
4415
4584
|
}
|
|
4416
|
-
export { DEFAULT_KNOWLEDGE_PAGE_GRAPH_LIMITS, InMemoryKnowledgeStorage, KNOWLEDGE_IMPORTER_ERROR_CODES, REMOVED_PARENT_BODY as KNOWLEDGE_IMPORT_REMOVED_PARENT_BODY, KNOWLEDGE_STORAGE_CONTRACT_VERSION, KNOWLEDGE_STORAGE_SCHEMA_VERSION, Knowledge, KnowledgeConflictError, KnowledgeDeclarationError, KnowledgeImporter, KnowledgeImporterBase, KnowledgeImporterBindingConflictError, KnowledgeImporterCredentialsError, KnowledgeImporterDefinitionError, KnowledgeImporterHostConflictError, KnowledgeImporterHostError, KnowledgeImporterRunStateError, KnowledgeImporterSettingsError, KnowledgeImporterSourceError, KnowledgeImportersStorage, KnowledgeInvalidCursorError, KnowledgeMoveTooLargeError, KnowledgeNotFoundError, KnowledgePageDepthError, KnowledgePageHasChildrenError, KnowledgePageKeyConflictError, KnowledgeSchemaResetRequiredError, KnowledgeStorage, KnowledgeTransactionDeadlineError, KnowledgeUnsupportedCapabilityError, MAX_KNOWLEDGE_EXPLORER_PAGE_LINKS, MAX_KNOWLEDGE_LINK_COUNT_PAGES, MAX_KNOWLEDGE_MOVE_PAGES, MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH, MAX_KNOWLEDGE_NOTE_TOKENS, MAX_KNOWLEDGE_PAGE_BODY_LINKS, MAX_KNOWLEDGE_PAGE_DEPTH, MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS, MAX_KNOWLEDGE_PAGE_LINKS, MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH, MAX_KNOWLEDGE_PAGE_LIST_LIMIT, MAX_KNOWLEDGE_PIN_LIST_DEPTH, MAX_KNOWLEDGE_RECORD_TEXT_LENGTH, MAX_KNOWLEDGE_SCOPE_TAGS, assertKnowledgeCeilingRaised, assertKnowledgeDescriptionWithinBound, assertKnowledgeNoteTextWithinBound, assertKnowledgePageDescriptionWithinBound, assertKnowledgeRecordTextWithinBound, assertKnowledgeSchemaCompatible, assertKnowledgeScopeWithinCeiling, canonicalJson, canonicalKnowledgeName, canonicalizeKnowledgeScope, createKnowledgeImporterHost, createKnowledgeNodeCursor, createKnowledgeUlid, decodeKnowledgeScopeId, encodeKnowledgeScopeId, expandKnowledgeScope, importerHostConformance, inspectKnowledgeSchema, isKnowledgeScopeVisible, knowledgeImportKey, knowledgeImporterFlushDigest, knowledgeImporterRegistry, knowledgeLinkRefKey, knowledgeMemoryScopes, knowledgePagePath, knowledgePinDepth, knowledgePositionBetween, knowledgeScopeAddress, knowledgeScopeKey, knowledgeScopeReadable, knowledgeSemanticDocumentId, knowledgeSemanticIdempotencyKey, knowledgeVisibleScopeKeys, listKnowledgeTreeChildren, normalizeKnowledgeImporterFinish, parseKnowledgeImporterFlushBody, parseKnowledgeNodeCursor, parseKnowledgePageRef, parseKnowledgeWikilinks, readKnowledgePage, readKnowledgePageActivity, readKnowledgePageGraph, readKnowledgePageLinkCounts, readKnowledgePageLinks, readKnowledgeScopeGrants, runKnowledgeImport, searchKnowledgeExplorerPages };
|
|
4585
|
+
export { DEFAULT_KNOWLEDGE_PAGE_GRAPH_LIMITS, InMemoryKnowledgeStorage, KNOWLEDGE_IMPORTER_ERROR_CODES, REMOVED_PARENT_BODY as KNOWLEDGE_IMPORT_REMOVED_PARENT_BODY, KNOWLEDGE_STORAGE_CONTRACT_VERSION, KNOWLEDGE_STORAGE_SCHEMA_VERSION, Knowledge, KnowledgeConflictError, KnowledgeDeclarationError, KnowledgeImporter, KnowledgeImporterBase, KnowledgeImporterBindingConflictError, KnowledgeImporterCredentialsError, KnowledgeImporterDefinitionError, KnowledgeImporterHostConflictError, KnowledgeImporterHostError, KnowledgeImporterRunStateError, KnowledgeImporterSettingsError, KnowledgeImporterSourceError, KnowledgeImportersStorage, KnowledgeInvalidCursorError, KnowledgeMoveTooLargeError, KnowledgeNotFoundError, KnowledgePageDepthError, KnowledgePageHasChildrenError, KnowledgePageKeyConflictError, KnowledgeSchemaResetRequiredError, KnowledgeStorage, KnowledgeTransactionDeadlineError, KnowledgeUnsupportedCapabilityError, MAX_KNOWLEDGE_EXPLORER_PAGE_LINKS, MAX_KNOWLEDGE_LINK_COUNT_PAGES, MAX_KNOWLEDGE_MOVE_PAGES, MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH, MAX_KNOWLEDGE_NOTE_TOKENS, MAX_KNOWLEDGE_PAGE_BODY_LINKS, MAX_KNOWLEDGE_PAGE_DEPTH, MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS, MAX_KNOWLEDGE_PAGE_LINKS, MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH, MAX_KNOWLEDGE_PAGE_LIST_LIMIT, MAX_KNOWLEDGE_PIN_LIST_DEPTH, MAX_KNOWLEDGE_RECORD_TEXT_LENGTH, MAX_KNOWLEDGE_SCOPE_TAGS, assertKnowledgeCeilingRaised, assertKnowledgeDescriptionWithinBound, assertKnowledgeNoteTextWithinBound, assertKnowledgePageDescriptionWithinBound, assertKnowledgeRecordTextWithinBound, assertKnowledgeSchemaCompatible, assertKnowledgeScopeWithinCeiling, canonicalJson, canonicalKnowledgeName, canonicalizeKnowledgeScope, createKnowledgeImporterHost, createKnowledgeNodeCursor, createKnowledgeUlid, decodeKnowledgeScopeId, encodeKnowledgeScopeId, expandKnowledgeScope, importerHostConformance, inspectKnowledgeSchema, isKnowledgeScopeVisible, knowledgeAgentScopes, knowledgeImportKey, knowledgeImporterFlushDigest, knowledgeImporterRegistry, knowledgeLinkRefKey, knowledgeMemoryScopes, knowledgePagePath, knowledgePersonaScopes, knowledgePinDepth, knowledgePositionBetween, knowledgeScopeAddress, knowledgeScopeKey, knowledgeScopeReadable, knowledgeSemanticDocumentId, knowledgeSemanticIdempotencyKey, knowledgeVisibleScopeKeys, listKnowledgeTreeChildren, normalizeKnowledgeImporterFinish, parseKnowledgeImporterFlushBody, parseKnowledgeNodeCursor, parseKnowledgePageRef, parseKnowledgeWikilinks, readKnowledgePage, readKnowledgePageActivity, readKnowledgePageGraph, readKnowledgePageLinkCounts, readKnowledgePageLinks, readKnowledgeScopeGrants, runKnowledgeImport, searchKnowledgeExplorerPages };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KnowledgePage, KnowledgeStorage } from '../storage/domains/knowledge/index.js';
|
|
2
2
|
import type { ToolAction } from '../tools/index.js';
|
|
3
|
+
import type { KnowledgeRole } from './declarations.js';
|
|
3
4
|
import { KnowledgeRun } from './run.js';
|
|
4
5
|
import type { KnowledgeScopeRuntime } from './scope-runtime.js';
|
|
5
6
|
import type { KnowledgeSemanticIndex } from './semantic.js';
|
|
@@ -24,6 +25,22 @@ export interface KnowledgePageToolGroups {
|
|
|
24
25
|
pins: boolean;
|
|
25
26
|
}
|
|
26
27
|
type Tools = Record<string, ToolAction<any, any, any>>;
|
|
28
|
+
/** What a run can do in a scope it holds: contributors and up can write, viewers only read. */
|
|
29
|
+
type HeldScopeAccess = 'write' | 'read' | 'none';
|
|
30
|
+
/** A scope the run holds, whether or not it has a scope page yet. */
|
|
31
|
+
type HeldScope = {
|
|
32
|
+
address: string;
|
|
33
|
+
page?: KnowledgePage;
|
|
34
|
+
role: KnowledgeRole | null;
|
|
35
|
+
can: HeldScopeAccess;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Every scope the run holds, in principal order, with its role and what it can do there. A held scope
|
|
39
|
+
* gets its page on the first write, so before that its role comes from the declarations and the parent
|
|
40
|
+
* that write would link it under: without it a model sees no scopes on its first turn and concludes it
|
|
41
|
+
* has nowhere to write. A stored scope it can't read keeps only its address.
|
|
42
|
+
*/
|
|
43
|
+
export declare function heldScopes(run: KnowledgeRun): Promise<HeldScope[]>;
|
|
27
44
|
/** One entry of a `knowledge_list` result. */
|
|
28
45
|
export interface ListEntry {
|
|
29
46
|
ref: string;
|
|
@@ -34,6 +51,12 @@ export interface ListEntry {
|
|
|
34
51
|
/** Readable child pages, plus readable child scopes for a scope. */
|
|
35
52
|
children: number;
|
|
36
53
|
scope?: true;
|
|
54
|
+
/** Held scopes only (a listing without `from`): the run's role there, if any. */
|
|
55
|
+
role?: KnowledgeRole;
|
|
56
|
+
/** Held scopes only: what the run can do there. */
|
|
57
|
+
can?: HeldScopeAccess;
|
|
58
|
+
/** Held scopes only: no page there this run can read yet. */
|
|
59
|
+
empty?: true;
|
|
37
60
|
}
|
|
38
61
|
/** What {@link listKnowledgeTree} found: the entries in tree order, and where the listing stopped. */
|
|
39
62
|
export interface KnowledgeTreeListing {
|
|
@@ -34,8 +34,8 @@ export declare function applyPinOps(pins: PinEntry[], ops: PinDeltaOp[]): PinEnt
|
|
|
34
34
|
export declare function effectivePriorPins(args: ComputeStateSignalArgs): PinEntry[];
|
|
35
35
|
export declare function diffPins(prior: PinEntry[], current: PinEntry[]): PinDeltaOp[];
|
|
36
36
|
export interface PinnedStateProcessorDeps {
|
|
37
|
-
/** A key identifying the run's principals, for the per-turn memo
|
|
38
|
-
principalsKey(context: KnowledgeRunContext): string;
|
|
37
|
+
/** A key identifying the run's principals, for the per-turn memo; `undefined` when the run has no Knowledge view, so it gets no pins. */
|
|
38
|
+
principalsKey(context: KnowledgeRunContext): Promise<string | undefined> | string | undefined;
|
|
39
39
|
/** The pins the run receives. */
|
|
40
40
|
readPins(context: KnowledgeRunContext): Promise<PinEntry[]>;
|
|
41
41
|
/** Whether the agent has `knowledge_search`, `knowledge_read` and `knowledge_list`; when `false` the guidance, the overflow suffix and pin descriptions name no read tool. Defaults to `true`. */
|
package/dist/knowledge/run.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type KnowledgeRunContext = {
|
|
|
7
7
|
threadId?: string;
|
|
8
8
|
resourceId?: string;
|
|
9
9
|
agentId?: string;
|
|
10
|
+
persona?: unknown;
|
|
10
11
|
};
|
|
11
12
|
requestContext?: {
|
|
12
13
|
get(key: string): unknown;
|
|
@@ -16,6 +17,10 @@ export type KnowledgeRunContext = {
|
|
|
16
17
|
export declare class KnowledgeNotFoundError extends Error {
|
|
17
18
|
constructor(ref: string, closeMatches?: string[]);
|
|
18
19
|
}
|
|
20
|
+
/** A run with no scopes and no Memory identity: it has no Knowledge view. @internal */
|
|
21
|
+
export declare class KnowledgeRunScopesError extends Error {
|
|
22
|
+
constructor();
|
|
23
|
+
}
|
|
19
24
|
/**
|
|
20
25
|
* One call's view of Knowledge: the run's principals, its read scope and its provenance. Built per
|
|
21
26
|
* tool call from the run's own scopes, so access always follows the current declarations.
|
|
@@ -77,5 +77,11 @@ export declare class KnowledgeScopeRuntime {
|
|
|
77
77
|
* `belongsTo` link, has its child scopes and declares no template pages; warnings fire as before.
|
|
78
78
|
*/
|
|
79
79
|
materializeScopes(addresses: readonly string[], principals: readonly string[], provenance: KnowledgeProvenance): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* The parent address a first write would place a not-yet-created scope under, as `#materialize`
|
|
82
|
+
* chooses it: a template child's own parent, or the one held `belongsTo` candidate. Undefined when
|
|
83
|
+
* the scope would stay unlinked.
|
|
84
|
+
*/
|
|
85
|
+
firstWriteParentAddress(address: string, principals: readonly string[]): string | undefined;
|
|
80
86
|
}
|
|
81
87
|
//# sourceMappingURL=scope-runtime.d.ts.map
|
package/dist/llm/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_llm = require("../llm-
|
|
3
|
-
const require_netlify = require("../netlify-
|
|
4
|
-
const require_provider_registry = require("../provider-registry-
|
|
2
|
+
const require_llm = require("../llm-B1semiTO.cjs");
|
|
3
|
+
const require_netlify = require("../netlify-BC4v7Ufv.cjs");
|
|
4
|
+
const require_provider_registry = require("../provider-registry-Bn01gq9y.cjs");
|
|
5
5
|
exports.AzureOpenAIGateway = require_llm.AzureOpenAIGateway;
|
|
6
6
|
exports.EMBEDDING_MODELS = require_llm.EMBEDDING_MODELS;
|
|
7
7
|
exports.GATEWAY_AUTH_HEADER = require_netlify.GATEWAY_AUTH_HEADER;
|
package/dist/llm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ModelRouterLanguageModel, c as AzureOpenAIGateway, i as resolveModelConfig, l as defaultGateways, n as ModelRouterEmbeddingModel, r as resolveModelAuth, t as EMBEDDING_MODELS } from "../llm-
|
|
2
|
-
import {
|
|
3
|
-
import { c as modelSupportsStructuredOutput, f as MastraGateway, i as getProviderConfig, l as modelSupportsTemperature, n as PROVIDER_REGISTRY, r as getModelReasoningOptions, s as modelSupportsAttachments, t as GatewayRegistry, u as parseModelString } from "../provider-registry-
|
|
1
|
+
import { a as ModelRouterLanguageModel, c as AzureOpenAIGateway, i as resolveModelConfig, l as defaultGateways, n as ModelRouterEmbeddingModel, r as resolveModelAuth, t as EMBEDDING_MODELS } from "../llm-CytL7cpw.js";
|
|
2
|
+
import { l as GATEWAY_AUTH_HEADER, m as getGatewayId, p as findGatewayForModel, r as ModelsDevGateway, t as NetlifyGateway, y as MastraModelGateway } from "../netlify-BUvdxfHe.js";
|
|
3
|
+
import { c as modelSupportsStructuredOutput, f as MastraGateway, i as getProviderConfig, l as modelSupportsTemperature, n as PROVIDER_REGISTRY, r as getModelReasoningOptions, s as modelSupportsAttachments, t as GatewayRegistry, u as parseModelString } from "../provider-registry-CP_5SNiw.js";
|
|
4
4
|
export { AzureOpenAIGateway, EMBEDDING_MODELS, GATEWAY_AUTH_HEADER, GatewayRegistry, MastraGateway, MastraModelGateway, ModelRouterEmbeddingModel, ModelRouterLanguageModel, ModelsDevGateway, NetlifyGateway, PROVIDER_REGISTRY, defaultGateways, findGatewayForModel, getGatewayId, getModelReasoningOptions, getProviderConfig, modelSupportsAttachments, modelSupportsStructuredOutput, modelSupportsTemperature, parseModelString, resolveModelAuth, resolveModelConfig };
|
|
@@ -2,7 +2,7 @@ import type { UIMessage, CoreMessage, GenerateTextResult as OriginalGenerateText
|
|
|
2
2
|
import type { JSONSchema7 } from 'json-schema';
|
|
3
3
|
import type { MessageList } from '../../agent/types.js';
|
|
4
4
|
import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '../../evals/index.js';
|
|
5
|
-
import type { ObservabilityContext, TracingProperties } from '../../observability/index.js';
|
|
5
|
+
import type { ModelGenerationAttributes, ObservabilityContext, TracingProperties } from '../../observability/index.js';
|
|
6
6
|
import type { OutputProcessorOrWorkflow } from '../../processors/index.js';
|
|
7
7
|
import type { RequestContext } from '../../request-context/index.js';
|
|
8
8
|
import type { ZodSchema } from '../../schema/index.js';
|
|
@@ -59,6 +59,8 @@ type GenerateTextOptions<Tools extends ToolSet, Output extends ZodSchema | JSONS
|
|
|
59
59
|
export type GenerateTextWithMessagesArgs<Tools extends ToolSet, Output extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
60
60
|
messages: UIMessage[] | CoreMessage[];
|
|
61
61
|
output?: never;
|
|
62
|
+
/** What this call produces, when it is not part of the conversation. Recorded on the MODEL_GENERATION span. */
|
|
63
|
+
resultType?: ModelGenerationAttributes['resultType'];
|
|
62
64
|
} & GenerateTextOptions<Tools, Output>;
|
|
63
65
|
export type GenerateTextResult<Tools extends ToolSet, Output extends ZodSchema | JSONSchema7 | undefined = undefined> = Omit<OriginalGenerateTextResult<Tools, inferOutput<Output>>, 'experimental_output'> & {
|
|
64
66
|
object?: Output extends undefined ? never : inferOutput<Output>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
type GatewayTool = {
|
|
2
|
+
type: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
args?: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
6
|
/**
|
|
7
7
|
* The Mastra gateway's chat endpoint only runs `openrouter:*` server tools. Another provider's
|
|
8
8
|
* native tool is rejected with a 400 (OpenAI, xAI models) or dropped without an error (Anthropic,
|
|
@@ -11,5 +11,8 @@ export declare function isOpenRouterModel(model: {
|
|
|
11
11
|
* A native web search tool with no arguments is swapped for the gateway's web search, which works
|
|
12
12
|
* for every tool-calling model. Any other native tool fails here with an actionable message.
|
|
13
13
|
*/
|
|
14
|
-
export declare function prepareToolsForMastraGateway
|
|
14
|
+
export declare function prepareToolsForMastraGateway<T extends {
|
|
15
|
+
tools?: GatewayTool[];
|
|
16
|
+
}>(options: T, routerId: string): T;
|
|
17
|
+
export {};
|
|
15
18
|
//# sourceMappingURL=mastra-gateway-provider-tools.d.ts.map
|
|
@@ -19,7 +19,7 @@ export declare class MastraLLMV1 extends MastraBase {
|
|
|
19
19
|
getModelId(): string;
|
|
20
20
|
getModel(): LanguageModel;
|
|
21
21
|
private _applySchemaCompat;
|
|
22
|
-
__text<Tools extends ToolSet, Z extends ZodSchema | JSONSchema7 | undefined>({ runId, messages, maxSteps, tools, temperature, toolChoice, onStepFinish, experimental_output, threadId, resourceId, requestContext, ...rest }: GenerateTextWithMessagesArgs<Tools, Z>): Promise<GenerateTextResult<Tools, Z>>;
|
|
22
|
+
__text<Tools extends ToolSet, Z extends ZodSchema | JSONSchema7 | undefined>({ runId, messages, maxSteps, tools, temperature, toolChoice, onStepFinish, experimental_output, threadId, resourceId, requestContext, resultType, ...rest }: GenerateTextWithMessagesArgs<Tools, Z>): Promise<GenerateTextResult<Tools, Z>>;
|
|
23
23
|
__textObject<Z extends ZodSchema | JSONSchema7>({ messages, structuredOutput, runId, threadId, resourceId, requestContext, ...rest }: GenerateObjectWithMessagesArgs<Z>): Promise<GenerateObjectResult<Z>>;
|
|
24
24
|
__stream<Tools extends ToolSet, Z extends ZodSchema | JSONSchema7 | undefined = undefined>({ messages, onStepFinish, onFinish, maxSteps, tools, runId, temperature, toolChoice, experimental_output, threadId, resourceId, requestContext, ...rest }: StreamTextWithMessagesArgs<Tools, Z>): StreamTextResult<Tools, Z>;
|
|
25
25
|
__streamObject<T extends ZodSchema | JSONSchema7>({ messages, runId, requestContext, threadId, resourceId, onFinish, structuredOutput, ...rest }: StreamObjectWithMessagesArgs<T>): StreamObjectResult<T>;
|