@mastra/core 1.86.0-alpha.7 → 1.86.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/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +363 -0
- package/dist/a2a/index.cjs +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/agent/agent.d.ts +72 -1
- package/dist/agent/agent.types.d.ts +30 -2
- package/dist/agent/durable/create-evented-agent.d.ts +6 -0
- package/dist/agent/durable/durable-agent.d.ts +1 -15
- package/dist/agent/durable/index.cjs +7 -26
- package/dist/agent/durable/index.js +7 -26
- package/dist/agent/durable/preparation.d.ts +2 -0
- package/dist/agent/durable/utils/resolve-runtime.d.ts +9 -0
- package/dist/agent/durable/workflows/durable-loop-builder.d.ts +4 -0
- package/dist/agent/durable/workflows/finalize-run.d.ts +3 -1
- package/dist/agent/durable/workflows/steps/llm-execution.d.ts +1 -0
- package/dist/agent/index.cjs +3 -3
- package/dist/agent/index.js +3 -3
- package/dist/agent/message-list/index.cjs +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts +11 -0
- package/dist/agent/message-list/utils/provider-compat.d.ts +1 -0
- package/dist/agent/request-context-snapshot.d.ts +1 -1
- package/dist/agent/streams/types.d.ts +10 -0
- package/dist/agent/thread-stream-runtime.d.ts +5 -0
- package/dist/agent/types.d.ts +25 -0
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +1 -1
- package/dist/agent-controller/index.js +1 -1
- package/dist/{agent-controller-K5vHtqfO.cjs → agent-controller-CrQ9OF80.cjs} +8 -8
- package/dist/{agent-controller-Cf3_IuY8.js → agent-controller-SSlKzE6A.js} +8 -8
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-DqnQMfuf.cjs → background-tasks-BDrYBis-.cjs} +5 -3
- package/dist/{background-tasks-BgpX1P_s.js → background-tasks-BnJfNLFo.js} +5 -3
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-x295GDL6.js → builder-Cl-0BWkh.js} +2 -2
- package/dist/{builder-D8Osghdo.cjs → builder-Cw8u3pPl.cjs} +2 -2
- package/dist/capabilities/302ai.json +192 -192
- package/dist/capabilities/abliteratedllm.json +34 -34
- package/dist/capabilities/abliteration-ai.json +11 -11
- package/dist/capabilities/above.json +17 -17
- package/dist/capabilities/adaption.json +12 -12
- package/dist/capabilities/adzuki.json +30 -30
- package/dist/capabilities/agentrouter.json +10 -10
- package/dist/capabilities/agnes.json +4 -4
- package/dist/capabilities/ai-router.json +9 -9
- package/dist/capabilities/aiand.json +19 -11
- package/dist/capabilities/aigrow.json +11 -11
- package/dist/capabilities/aimlapi.json +146 -149
- package/dist/capabilities/aipg.json +2 -2
- package/dist/capabilities/aixy.json +14 -14
- package/dist/capabilities/aki-io.json +11 -11
- package/dist/capabilities/alibaba-cn.json +128 -109
- package/dist/capabilities/alibaba-coding-plan-cn.json +7 -19
- package/dist/capabilities/alibaba-coding-plan.json +7 -19
- package/dist/capabilities/alibaba-token-plan-cn.json +49 -67
- package/dist/capabilities/alibaba-token-plan.json +51 -69
- package/dist/capabilities/alibaba.json +71 -118
- package/dist/capabilities/ambient.json +14 -14
- package/dist/capabilities/amd.json +11 -11
- package/dist/capabilities/anthropic.json +48 -48
- package/dist/capabilities/anyapi.json +18 -18
- package/dist/capabilities/apiko.json +2 -2
- package/dist/capabilities/arcee.json +10 -10
- package/dist/capabilities/augure.json +6 -6
- package/dist/capabilities/auriko.json +20 -20
- package/dist/capabilities/bailing.json +5 -5
- package/dist/capabilities/baseten.json +46 -16
- package/dist/capabilities/bee.json +5 -5
- package/dist/capabilities/berget.json +4 -4
- package/dist/capabilities/bothub.json +16 -16
- package/dist/capabilities/boundless.json +36 -36
- package/dist/capabilities/bumo.json +40 -40
- package/dist/capabilities/byteplus.json +32 -32
- package/dist/capabilities/cerebras.json +4 -4
- package/dist/capabilities/cheapaimodel.json +5 -5
- package/dist/capabilities/cheapest-token.json +24 -24
- package/dist/capabilities/chutes.json +9 -9
- package/dist/capabilities/cline-pass.json +37 -37
- package/dist/capabilities/cloudcode.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +24 -24
- package/dist/capabilities/commandcode.json +152 -152
- package/dist/capabilities/concentrate.json +290 -266
- package/dist/capabilities/cortecs.json +105 -105
- package/dist/capabilities/crossmodel.json +160 -160
- package/dist/capabilities/crusoe.json +10 -10
- package/dist/capabilities/daoxe.json +7 -7
- package/dist/capabilities/databricks.json +318 -62
- package/dist/capabilities/deepinfra.json +73 -129
- package/dist/capabilities/deepseek.json +2 -2
- package/dist/capabilities/digitalocean.json +114 -114
- package/dist/capabilities/dothoosh.json +28 -28
- package/dist/capabilities/doubleword.json +24 -24
- package/dist/capabilities/edenai.json +458 -458
- package/dist/capabilities/empiriolabs.json +166 -166
- package/dist/capabilities/engy.json +20 -20
- package/dist/capabilities/evroc.json +8 -8
- package/dist/capabilities/ezkielyna.json +8 -8
- package/dist/capabilities/fastrouter.json +85 -85
- package/dist/capabilities/fireworks-ai.json +107 -44
- package/dist/capabilities/freemodel.json +23 -23
- package/dist/capabilities/friendli.json +9 -9
- package/dist/capabilities/frogbot.json +94 -94
- package/dist/capabilities/gisoo.json +16 -16
- package/dist/capabilities/gmicloud.json +17 -17
- package/dist/capabilities/google.json +57 -57
- package/dist/capabilities/graphn.json +10 -10
- package/dist/capabilities/greenpt.json +36 -36
- package/dist/capabilities/groq.json +2 -2
- package/dist/capabilities/helicone.json +68 -68
- package/dist/capabilities/hopper.json +2 -2
- package/dist/capabilities/hostinger-router.json +12 -12
- package/dist/capabilities/hpc-ai.json +13 -13
- package/dist/capabilities/huawei-maas.json +17 -17
- package/dist/capabilities/hubris.json +30 -30
- package/dist/capabilities/huggingface.json +193 -37
- package/dist/capabilities/hyper.json +23 -23
- package/dist/capabilities/impossibl.json +140 -140
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +4 -4
- package/dist/capabilities/inco.json +3 -3
- package/dist/capabilities/infer.json +15 -15
- package/dist/capabilities/inferall.json +10 -10
- package/dist/capabilities/inference-coop.json +9 -9
- package/dist/capabilities/inferenceapis.json +9 -9
- package/dist/capabilities/inferris.json +3 -3
- package/dist/capabilities/infersia.json +2 -2
- package/dist/capabilities/inferx.json +3 -3
- package/dist/capabilities/infomaniak.json +4 -4
- package/dist/capabilities/io-net.json +2 -2
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +60 -60
- package/dist/capabilities/jad-ai.json +3 -3
- package/dist/capabilities/jalapeno.json +12 -12
- package/dist/capabilities/jiekou.json +63 -63
- package/dist/capabilities/jzstoken.json +50 -50
- package/dist/capabilities/keln.json +14 -21
- package/dist/capabilities/kenari.json +123 -120
- package/dist/capabilities/kilo.json +622 -647
- package/dist/capabilities/kimi-code-plan-cn.json +5 -5
- package/dist/capabilities/kimi-code-plan-global.json +5 -5
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +18 -18
- package/dist/capabilities/korouter.json +29 -29
- package/dist/capabilities/kunavo.json +10 -10
- package/dist/capabilities/liquid.json +11 -11
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +932 -905
- package/dist/capabilities/llmgateway.json +336 -336
- package/dist/capabilities/llmtr.json +22 -22
- package/dist/capabilities/logits.json +2 -2
- package/dist/capabilities/longcat.json +2 -7
- package/dist/capabilities/lowrouter.json +54 -54
- package/dist/capabilities/lyceum.json +12 -12
- package/dist/capabilities/melious.json +13 -13
- package/dist/capabilities/merge-gateway.json +260 -260
- package/dist/capabilities/meta.json +7 -7
- package/dist/capabilities/mistral.json +20 -20
- package/dist/capabilities/mixlayer.json +4 -4
- package/dist/capabilities/modal.json +10 -10
- package/dist/capabilities/model-oracle-ai.json +25 -25
- package/dist/capabilities/modelis.json +20 -20
- package/dist/capabilities/modular.json +6 -6
- package/dist/capabilities/moneo.json +16 -16
- package/dist/capabilities/moonshotai-cn.json +7 -7
- package/dist/capabilities/moonshotai.json +7 -7
- package/dist/capabilities/morph.json +11 -11
- package/dist/capabilities/munito-eu.json +6 -6
- package/dist/capabilities/munito.json +6 -6
- package/dist/capabilities/nan.json +27 -27
- package/dist/capabilities/nano-gpt.json +578 -578
- package/dist/capabilities/nearai.json +84 -84
- package/dist/capabilities/nebius.json +37 -28
- package/dist/capabilities/neon.json +126 -126
- package/dist/capabilities/neuralwatt.json +41 -41
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +154 -154
- package/dist/capabilities/nvidia.json +35 -35
- package/dist/capabilities/oathbreaker.json +2 -2
- package/dist/capabilities/obscurify.json +32 -32
- package/dist/capabilities/oci.json +7 -7
- package/dist/capabilities/ofox.json +357 -357
- package/dist/capabilities/ollama-cloud.json +56 -56
- package/dist/capabilities/openai.json +51 -51
- package/dist/capabilities/opencode-go.json +85 -84
- package/dist/capabilities/openrouter.json +542 -567
- package/dist/capabilities/opper.json +30 -24
- package/dist/capabilities/orcarouter.json +236 -236
- package/dist/capabilities/outerlabs.json +32 -32
- package/dist/capabilities/ovhcloud.json +7 -7
- package/dist/capabilities/pareto.json +6 -6
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +61 -61
- package/dist/capabilities/phala.json +34 -34
- package/dist/capabilities/pioneer.json +30 -30
- package/dist/capabilities/poe.json +136 -136
- package/dist/capabilities/powerspring.json +13 -13
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +124 -107
- package/dist/capabilities/privatemode-ai.json +14 -14
- package/dist/capabilities/proxystacks.json +6 -6
- package/dist/capabilities/qiniu-ai.json +16 -16
- package/dist/capabilities/refuseless.json +6 -6
- package/dist/capabilities/regolo-ai.json +6 -6
- package/dist/capabilities/requesty.json +172 -172
- package/dist/capabilities/ruapi.json +17 -17
- package/dist/capabilities/runcrate.json +5 -5
- package/dist/capabilities/runinfra.json +13 -13
- package/dist/capabilities/sakana.json +6 -6
- package/dist/capabilities/sambanova.json +9 -9
- package/dist/capabilities/sandbase.json +27 -27
- package/dist/capabilities/sarvam.json +12 -12
- package/dist/capabilities/scaleway.json +14 -14
- package/dist/capabilities/scnet-token-plan.json +9 -9
- package/dist/capabilities/scx-ai.json +26 -26
- package/dist/capabilities/sensenova.json +12 -12
- package/dist/capabilities/siliconflow-cn.json +49 -49
- package/dist/capabilities/siliconflow.json +46 -46
- package/dist/capabilities/snowflake-cortex.json +20 -20
- package/dist/capabilities/sokkan.json +7 -7
- package/dist/capabilities/sparrowcodes.json +25 -25
- package/dist/capabilities/standardcompute.json +102 -102
- package/dist/capabilities/steadyrouter.json +40 -40
- package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
- package/dist/capabilities/stepfun-ai.json +15 -8
- package/dist/capabilities/stepfun-step-plan.json +15 -8
- package/dist/capabilities/stepfun.json +15 -8
- package/dist/capabilities/stepping-stone.json +16 -16
- package/dist/capabilities/synthetic.json +13 -13
- package/dist/capabilities/synthorai.json +19 -19
- package/dist/capabilities/teamorouter.json +24 -24
- package/dist/capabilities/teapot-router.json +13 -13
- package/dist/capabilities/tencent-coding-plan.json +1 -23
- package/dist/capabilities/tencent-token-plan.json +60 -23
- package/dist/capabilities/tencent-tokenhub.json +182 -7
- package/dist/capabilities/tensorx.json +50 -50
- package/dist/capabilities/tenstorrent.json +6 -6
- package/dist/capabilities/the-grid-ai.json +28 -28
- package/dist/capabilities/thinkingmachines.json +72 -55
- package/dist/capabilities/tinfoil.json +13 -13
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +54 -83
- package/dist/capabilities/tokengo.json +25 -25
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/trustedrouter.json +4 -4
- package/dist/capabilities/trustedtokens.json +17 -17
- package/dist/capabilities/umans-ai-coding-plan.json +13 -13
- package/dist/capabilities/umans-ai.json +10 -10
- package/dist/capabilities/unrestricted.json +6 -6
- package/dist/capabilities/uplinkswitch.json +21 -21
- package/dist/capabilities/upstage.json +4 -4
- package/dist/capabilities/vancine.json +23 -23
- package/dist/capabilities/vercel.json +540 -527
- package/dist/capabilities/vivgrid.json +80 -80
- package/dist/capabilities/volcengine-coding-plan.json +24 -54
- package/dist/capabilities/volcengine.json +55 -60
- package/dist/capabilities/vultr.json +24 -24
- package/dist/capabilities/wafer.ai.json +19 -19
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +11 -11
- package/dist/capabilities/wandb.json +21 -21
- package/dist/capabilities/watt.json +24 -24
- package/dist/capabilities/xai.json +7 -7
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -12
- package/dist/capabilities/xiaomi-token-plan-cn.json +2 -12
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -12
- package/dist/capabilities/xiaomi.json +3 -25
- package/dist/capabilities/xpersona.json +13 -13
- package/dist/capabilities/xxapi.json +31 -31
- package/dist/capabilities/zai-coding-plan.json +18 -18
- package/dist/capabilities/zai.json +49 -26
- package/dist/capabilities/zenifra.json +26 -26
- package/dist/capabilities/zenmux.json +205 -205
- package/dist/capabilities/zerogpu.json +11 -11
- package/dist/capabilities/zhipuai-coding-plan.json +6 -6
- package/dist/capabilities/zhipuai.json +39 -24
- package/dist/capabilities/zro.json +6 -6
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-Dx4jiXeK.js → channels-Cz1y3W6u.js} +1 -1
- package/dist/{channels-q6qnuRNV.cjs → channels-DQg4v_gm.cjs} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/datasets/dataset.d.ts +13 -6
- package/dist/datasets/experiment/durable.d.ts +16 -0
- package/dist/datasets/experiment/index.d.ts +2 -1
- package/dist/datasets/experiment/item.d.ts +26 -4
- package/dist/datasets/experiment/retries.d.ts +18 -0
- package/dist/datasets/experiment/types.d.ts +18 -0
- package/dist/datasets/experiment/workflow-id.d.ts +7 -0
- package/dist/datasets/experiment/workflow.d.ts +74 -0
- package/dist/datasets/index.cjs +3 -2
- package/dist/datasets/index.d.ts +2 -1
- package/dist/datasets/index.js +3 -3
- package/dist/docs/SKILL.md +4 -3
- package/dist/docs/assets/SOURCE_MAP.json +928 -903
- package/dist/docs/references/docs-deployment-workers.md +1 -1
- package/dist/docs/references/docs-evals-experiments.md +29 -1
- package/dist/docs/references/docs-harness-background-tasks.md +4 -1
- package/dist/docs/references/docs-harness-durable-agents.md +9 -5
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +1 -0
- package/dist/docs/references/docs-knowledge-importers.md +195 -0
- package/dist/docs/references/docs-knowledge-load-your-content.md +2 -2
- package/dist/docs/references/docs-knowledge-overview.md +1 -1
- package/dist/docs/references/docs-mastra-platform-observability-overview.md +1 -1
- package/dist/docs/references/docs-sandbox-filesystem.md +1 -1
- package/dist/docs/references/docs-server-pubsub.md +51 -8
- package/dist/docs/references/docs-signals-running-across-processes.md +2 -0
- package/dist/docs/references/docs-signals-thread-streams.md +1 -1
- package/dist/docs/references/docs-studio-auth.md +54 -7
- package/dist/docs/references/docs-workflows-overview.md +1 -1
- package/dist/docs/references/docs-workflows-scheduled-workflows.md +1 -1
- package/dist/docs/references/integrations-auth-clerk.md +48 -4
- package/dist/docs/references/integrations-channels-slack.md +4 -2
- package/dist/docs/references/integrations.md +6 -0
- package/dist/docs/references/reference-agents-agent.md +3 -1
- package/dist/docs/references/reference-agents-channels.md +116 -27
- package/dist/docs/references/reference-agents-durable-agent.md +12 -4
- package/dist/docs/references/reference-auth-clerk.md +21 -1
- package/dist/docs/references/reference-datasets-runExperimentItem.md +13 -1
- package/dist/docs/references/reference-datasets-startExperimentAsync.md +3 -1
- package/dist/docs/references/reference-editor-mastra-editor.md +3 -1
- package/dist/docs/references/reference-knowledge-knowledge-class.md +13 -6
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +43 -20
- package/dist/docs/references/reference-memory-observational-memory.md +2 -2
- package/dist/docs/references/reference-processors-moderation-processor.md +2 -2
- package/dist/docs/references/reference-pubsub-base.md +5 -1
- package/dist/docs/references/reference-pubsub-event-emitter.md +2 -0
- package/dist/docs/references/reference-pubsub-redis-streams.md +1 -1
- package/dist/docs/references/reference-pubsub-unix-socket-pubsub.md +2 -0
- package/dist/docs/references/reference-streaming-ChunkType.md +3 -3
- package/dist/docs/references/reference-workers-overview.md +1 -1
- package/dist/docs/references/reference-workflows-run-methods-start.md +23 -0
- package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +4 -0
- package/dist/docs/references/reference-workflows-run.md +1 -1
- package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
- package/dist/error/index.cjs +1 -1
- package/dist/error/index.js +1 -1
- package/dist/{error-C9d_24w-.js → error-BLwEXqOK.js} +2 -2
- package/dist/{error-BRQf2ku0.cjs → error-BdEvO8za.cjs} +2 -2
- package/dist/evals/index.cjs +1 -1
- package/dist/evals/index.js +1 -1
- package/dist/evals/scoreTraces/index.cjs +1 -1
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/events/caching-pubsub.d.ts +1 -0
- package/dist/events/event-emitter/index.d.ts +12 -5
- package/dist/events/index.cjs +15 -1
- package/dist/events/index.js +15 -1
- package/dist/events/pubsub.d.ts +29 -0
- package/dist/events/reach.d.ts +11 -0
- package/dist/events/unix-socket-pubsub.d.ts +14 -0
- package/dist/features/index.cjs +1 -0
- package/dist/features/index.js +1 -0
- package/dist/{filesystem-B5X-5G0x.js → filesystem-B8ad6kAW.js} +1 -1
- package/dist/{filesystem-BDSpwBke.cjs → filesystem-BB5YWXH-.cjs} +1 -1
- package/dist/{filesystem-DzM9pcQ8.js → filesystem-BDHUxbHn.js} +1 -1
- package/dist/{filesystem-B0AZrbj8.cjs → filesystem-BP5yz5LG.cjs} +1 -1
- package/dist/{filesystem-BsdkC311.js → filesystem-B_afSgYk.js} +1 -1
- package/dist/{filesystem-C-cyJfi1.cjs → filesystem-BaOJOc-V.cjs} +1 -1
- package/dist/{filesystem-B3s0WRud.js → filesystem-BhYgU8qg.js} +1 -1
- package/dist/{filesystem-DzfqVTO_.js → filesystem-CLBVmR5j.js} +1 -1
- package/dist/{filesystem-CEbD_77-.cjs → filesystem-Cgxc2a_-.cjs} +1 -1
- package/dist/{filesystem-Cv79mHRk.js → filesystem-ClBOBoDc.js} +1 -1
- package/dist/{filesystem-DsCQiBl2.cjs → filesystem-DVVecqZt.cjs} +1 -1
- package/dist/{filesystem-CUAgLugE.cjs → filesystem-Fpsu7e24.cjs} +1 -1
- package/dist/{filesystem-versioned-Bijb_p9l.js → filesystem-versioned-BL1ojJLo.js} +1 -1
- package/dist/{filesystem-versioned-DZGyPbNC.cjs → filesystem-versioned-BavRtYWJ.cjs} +1 -1
- package/dist/harness/index.cjs +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/config.d.ts +10 -0
- package/dist/knowledge/host-writes.d.ts +10 -0
- package/dist/knowledge/importers/conformance.d.ts +25 -0
- package/dist/knowledge/importers/define.d.ts +204 -0
- package/dist/knowledge/importers/host.d.ts +143 -0
- package/dist/knowledge/importers/index.d.ts +12 -0
- package/dist/knowledge/importers/local-host.d.ts +106 -0
- package/dist/knowledge/importers/manifest.d.ts +25 -0
- package/dist/knowledge/importers/runner.d.ts +61 -0
- package/dist/knowledge/importers/sink.d.ts +105 -0
- package/dist/knowledge/importers/types.d.ts +144 -0
- package/dist/knowledge/index.cjs +2715 -8
- package/dist/knowledge/index.d.ts +54 -4
- package/dist/knowledge/index.js +2692 -9
- package/dist/knowledge/instructions.d.ts +1 -1
- package/dist/knowledge/links.d.ts +8 -0
- package/dist/knowledge/pinned-state-processor.d.ts +5 -0
- package/dist/knowledge/pinned.d.ts +4 -1
- package/dist/knowledge/scope-runtime.d.ts +10 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +7812 -7831
- package/dist/llm/model/shared.types.d.ts +31 -0
- package/dist/{llm-CsQuqKPc.cjs → llm-8Av3mSjD.cjs} +2 -2
- package/dist/{llm-DnXK3Pmw.js → llm-B5A5cwJr.js} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +2 -2
- package/dist/{manager-BsghM-UL.js → manager-DfWQCJUK.js} +460 -94
- package/dist/{manager-DwFnIrI6.cjs → manager-sv35JY-z.cjs} +476 -92
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.d.ts +13 -0
- package/dist/mastra/index.js +1 -1
- package/dist/mastra/resolve-agent.d.ts +3 -1
- package/dist/{mastra-B8i1UDZs.js → mastra-CigBrT7X.js} +32 -23
- package/dist/{mastra-Cn5NC6Es.cjs → mastra-D4hvfuxX.cjs} +34 -25
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/{message-list-DPXPXvin.cjs → message-list-Cj0Sq_JP.cjs} +63 -8
- package/dist/{message-list-DEuRl82K.js → message-list-KRbg-TnI.js} +63 -8
- package/dist/{model-CNPfry_X.cjs → model-BK93CMtl.cjs} +1 -1
- package/dist/{model-CsOcWMUt.js → model-CYtXw861.js} +1 -1
- package/dist/{netlify-C-83Fxus.cjs → netlify-BAnn3ouY.cjs} +1 -1
- package/dist/{netlify-C-OpNSGp.js → netlify-CuI1ZrwR.js} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/{output-helpers-JL-HeCbT.cjs → output-helpers-1Zu4Vt9C.cjs} +68 -25
- package/dist/{output-helpers-D4II19No.js → output-helpers-CedRCE17.js} +69 -26
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/abort-signal-scope.d.ts +6 -0
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/{provider-registry-9O-H9osy.cjs → provider-registry-BwuI_IpT.cjs} +21690 -21811
- package/dist/{provider-registry-RZ8EgSe8.js → provider-registry-CmQLzLF_.js} +21690 -21811
- package/dist/provider-registry.json +22113 -22215
- package/dist/{registry-generator-e8sltJls.js → registry-generator-C17V4WfG.js} +1 -1
- package/dist/{registry-generator-DxCX-FiO.cjs → registry-generator-C_0ae7Ce.cjs} +1 -1
- package/dist/{rehydrate-B-wrAN7C.cjs → rehydrate-CDQ4dOYj.cjs} +2 -2
- package/dist/{rehydrate-D3fPgJwp.js → rehydrate-PnaVawGX.js} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-5_LQBGn_.cjs → run-registry-BmckDVBk.cjs} +1698 -497
- package/dist/{run-registry-DC03XLeZ.js → run-registry-BwEcwYlU.js} +1614 -467
- package/dist/{source-DDwx-87N.cjs → source-BVOi8Xhp.cjs} +1 -1
- package/dist/{source-Did_2XQc.js → source-fNa6u1kH.js} +1 -1
- package/dist/storage/domains/agents/index.cjs +1 -1
- package/dist/storage/domains/agents/index.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +72 -0
- package/dist/storage/domains/knowledge/importers-inmemory.d.ts +146 -0
- package/dist/storage/domains/knowledge/importers.d.ts +287 -0
- package/dist/storage/domains/knowledge/index.d.ts +1 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +12 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +12 -1
- package/dist/storage/domains/knowledge/pages.d.ts +25 -7
- package/dist/storage/domains/mcp-clients/index.cjs +1 -1
- package/dist/storage/domains/mcp-clients/index.js +1 -1
- package/dist/storage/domains/mcp-servers/index.cjs +1 -1
- package/dist/storage/domains/mcp-servers/index.js +1 -1
- package/dist/storage/domains/prompt-blocks/index.cjs +1 -1
- package/dist/storage/domains/prompt-blocks/index.js +1 -1
- package/dist/storage/domains/scorer-definitions/index.cjs +1 -1
- package/dist/storage/domains/scorer-definitions/index.js +1 -1
- package/dist/storage/domains/skills/index.cjs +1 -1
- package/dist/storage/domains/skills/index.js +1 -1
- package/dist/storage/domains/workspaces/index.cjs +1 -1
- package/dist/storage/domains/workspaces/index.js +1 -1
- package/dist/storage/index.cjs +15 -10
- package/dist/storage/index.js +11 -11
- package/dist/stream/base/output.d.ts +59 -15
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +24 -2
- package/dist/{stream-4aNIw_TQ.cjs → stream-0kdqBOOn.cjs} +64 -9
- package/dist/{stream-CJUm6EAH.js → stream-D1y9GzoD.js} +29 -10
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-FEEwHfmg.js → tool-loop-agent-BdjWGVIb.js} +4 -4
- package/dist/{tool-loop-agent-Dn0QCB9n.cjs → tool-loop-agent-kWaZAT6Q.cjs} +4 -4
- package/dist/tools/types.d.ts +27 -1
- package/dist/{utils-DY01hxVd.cjs → utils-BKUCaZ12.cjs} +1 -1
- package/dist/{utils-Bd_y1_a-.js → utils-GHY3hmLx.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-CX0yQo_q.js → validate-CB-q-R2F.js} +1 -1
- package/dist/{validate-CuB_1Zd3.cjs → validate-De92squ7.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-CbaSmip-.cjs → worker-BbWPQuPR.cjs} +2 -2
- package/dist/{worker-B80xkcKG.js → worker-C3u_xzY2.js} +2 -2
- package/dist/{worker-GsGIxPMa.cjs → worker-CAKvQj9_.cjs} +2 -2
- package/dist/{worker-DSEfMPmq.js → worker-Kwm8EKcj.js} +2 -2
- package/dist/{workflow-CnBPXTpv.cjs → workflow-CSjXeNcR.cjs} +4 -4
- package/dist/{workflow-CZHY_C85.js → workflow-CVmI1Sw-.js} +4 -4
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/setup-warning.d.ts +18 -0
- package/dist/workflows/evented/workflow-event-processor/run-status.d.ts +37 -0
- package/dist/workflows/evented/workflow.d.ts +10 -0
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workflows/workflow.d.ts +6 -1
- package/dist/workspace/filesystem/filesystem.d.ts +5 -0
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +16 -7
- package/dist/workspace/sandbox/native-sandbox/types.d.ts +11 -1
- package/dist/{workspace-D7TIleIt.js → workspace-DY2Nxiyi.js} +235 -34
- package/dist/{workspace-D2drutNg.cjs → workspace-X2RHJZU9.cjs} +235 -34
- package/package.json +7 -7
- package/src/llm/model/provider-types.generated.d.ts +7812 -7831
|
@@ -3839,6 +3839,7 @@ function generateSeatbeltProfile(workspacePath, config) {
|
|
|
3839
3839
|
]) if (config.readOnly) lines.push(`(allow file-write* (require-all (subpath ${escapePath(tempPath)}) (require-not (subpath ${escapePath(canonicalWorkspacePath)}))))`);
|
|
3840
3840
|
else lines.push(`(allow file-write* (subpath ${escapePath(tempPath)}))`);
|
|
3841
3841
|
for (const p of config.readWritePaths ?? []) lines.push(`(allow file-write* (subpath ${escapePath(canonicalizePath(p))}))`);
|
|
3842
|
+
for (const p of config.denyWritePaths ?? []) lines.push(`(deny file-write* (subpath ${escapePath(canonicalizePath(p))}))`);
|
|
3842
3843
|
lines.push("");
|
|
3843
3844
|
lines.push("; Network");
|
|
3844
3845
|
if (config.allowNetwork) lines.push("(allow network*)");
|
|
@@ -3933,6 +3934,7 @@ function buildBwrapCommand(command, workspacePath, config) {
|
|
|
3933
3934
|
if (config.readOnly) bwrapArgs.push("--ro-bind", workspacePath, workspacePath);
|
|
3934
3935
|
else bwrapArgs.push("--bind", workspacePath, workspacePath);
|
|
3935
3936
|
for (const path of config.readWritePaths ?? []) bwrapArgs.push("--bind", path, path);
|
|
3937
|
+
for (const path of config.denyWritePaths ?? []) bwrapArgs.push("--ro-bind", path, path);
|
|
3936
3938
|
bwrapArgs.push("--dev", "/dev");
|
|
3937
3939
|
bwrapArgs.push("--chdir", workspacePath);
|
|
3938
3940
|
bwrapArgs.push("--die-with-parent");
|
|
@@ -4057,9 +4059,11 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
|
|
|
4057
4059
|
_activeMountPaths = /* @__PURE__ */ new Set();
|
|
4058
4060
|
/** Snapshot of `readWritePaths` from ctor; entries here are never removed on unmount. */
|
|
4059
4061
|
_initialReadWritePaths;
|
|
4060
|
-
/**
|
|
4062
|
+
/** Snapshot of `denyWritePaths` from ctor; entries here are never removed on unmount. */
|
|
4063
|
+
_initialDenyWritePaths;
|
|
4064
|
+
/** Refcount for isolation paths added by mounts, keyed by `<list>:<path>`. */
|
|
4061
4065
|
_mountIsolationRefCount = /* @__PURE__ */ new Map();
|
|
4062
|
-
/** Normalized mount path → canonical isolation path
|
|
4066
|
+
/** Normalized mount path → canonical isolation path and the list it was added to. */
|
|
4063
4067
|
_mountPathToIsolationPath = /* @__PURE__ */ new Map();
|
|
4064
4068
|
/** Named checkpoint to seed from on start and persist to on snapshot. */
|
|
4065
4069
|
_checkpointName;
|
|
@@ -4099,9 +4103,11 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
|
|
|
4099
4103
|
this._nativeSandboxConfig = {
|
|
4100
4104
|
...options.nativeSandbox,
|
|
4101
4105
|
readWritePaths: [...options.nativeSandbox?.readWritePaths ?? []],
|
|
4102
|
-
readOnlyPaths: [...options.nativeSandbox?.readOnlyPaths ?? []]
|
|
4106
|
+
readOnlyPaths: [...options.nativeSandbox?.readOnlyPaths ?? []],
|
|
4107
|
+
denyWritePaths: [...options.nativeSandbox?.denyWritePaths ?? []]
|
|
4103
4108
|
};
|
|
4104
4109
|
this._initialReadWritePaths = new Set(this._nativeSandboxConfig.readWritePaths ?? []);
|
|
4110
|
+
this._initialDenyWritePaths = new Set(this._nativeSandboxConfig.denyWritePaths ?? []);
|
|
4105
4111
|
this.isolation = requestedIsolation;
|
|
4106
4112
|
this._instructionsOverride = options.instructions;
|
|
4107
4113
|
this._checkpointName = options.checkpointName;
|
|
@@ -4129,7 +4135,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
|
|
|
4129
4135
|
nativeSandbox: {
|
|
4130
4136
|
...this._nativeSandboxConfig,
|
|
4131
4137
|
readWritePaths: [...this._initialReadWritePaths],
|
|
4132
|
-
readOnlyPaths: [...this._nativeSandboxConfig.readOnlyPaths ?? []]
|
|
4138
|
+
readOnlyPaths: [...this._nativeSandboxConfig.readOnlyPaths ?? []],
|
|
4139
|
+
denyWritePaths: [...this._initialDenyWritePaths]
|
|
4133
4140
|
},
|
|
4134
4141
|
...this._instructionsOverride !== void 0 && { instructions: this._instructionsOverride },
|
|
4135
4142
|
...(options.checkpointName ?? this._checkpointName) !== void 0 && { checkpointName: options.checkpointName ?? this._checkpointName },
|
|
@@ -4367,7 +4374,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
|
|
|
4367
4374
|
isolationConfig: this.isolation !== "none" ? {
|
|
4368
4375
|
allowNetwork: this._nativeSandboxConfig.allowNetwork ?? false,
|
|
4369
4376
|
readOnlyPaths: this._nativeSandboxConfig.readOnlyPaths,
|
|
4370
|
-
readWritePaths: this._nativeSandboxConfig.readWritePaths
|
|
4377
|
+
readWritePaths: this._nativeSandboxConfig.readWritePaths,
|
|
4378
|
+
denyWritePaths: this._nativeSandboxConfig.denyWritePaths
|
|
4371
4379
|
} : void 0
|
|
4372
4380
|
}
|
|
4373
4381
|
};
|
|
@@ -4438,7 +4446,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
|
|
|
4438
4446
|
config
|
|
4439
4447
|
});
|
|
4440
4448
|
this._activeMountPaths.add(mountPath);
|
|
4441
|
-
this.addMountPathToIsolation(mountPath, hostPath);
|
|
4449
|
+
const isolationError = this.addMountPathToIsolation(mountPath, hostPath, filesystem.readOnly === true);
|
|
4450
|
+
if (isolationError) return this.failMountIsolation(filesystem, mountPath, config, isolationError);
|
|
4442
4451
|
return {
|
|
4443
4452
|
success: true,
|
|
4444
4453
|
mountPath
|
|
@@ -4549,7 +4558,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
|
|
|
4549
4558
|
});
|
|
4550
4559
|
this._activeMountPaths.add(mountPath);
|
|
4551
4560
|
await this.writeMarkerFile(mountPath, hostPath);
|
|
4552
|
-
this.addMountPathToIsolation(mountPath, hostPath);
|
|
4561
|
+
const isolationError = this.addMountPathToIsolation(mountPath, hostPath, filesystem.readOnly === true);
|
|
4562
|
+
if (isolationError) return this.failMountIsolation(filesystem, mountPath, config, isolationError);
|
|
4553
4563
|
this.logger.debug("Mounted", {
|
|
4554
4564
|
mountPath,
|
|
4555
4565
|
hostPath
|
|
@@ -4662,53 +4672,91 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
|
|
|
4662
4672
|
}
|
|
4663
4673
|
}
|
|
4664
4674
|
/**
|
|
4665
|
-
* Dynamically add a mount path to the sandbox isolation
|
|
4675
|
+
* Dynamically add a mount path to the sandbox isolation config.
|
|
4666
4676
|
*
|
|
4667
|
-
* -
|
|
4668
|
-
*
|
|
4677
|
+
* Read-write mounts go to `readWritePaths`; mounts whose filesystem is
|
|
4678
|
+
* `readOnly` go to `denyWritePaths` so subprocesses can read but never write
|
|
4679
|
+
* them, matching what file tools enforce. Both backends read the config on
|
|
4680
|
+
* every wrapCommand() call, so the change takes effect immediately.
|
|
4669
4681
|
*
|
|
4670
4682
|
* Local mounts are symlinks under `workingDirectory`. Bubblewrap cannot
|
|
4671
4683
|
* `--bind` a symlink (it fails with "Unable to mount source on destination"),
|
|
4672
4684
|
* so we store the canonical path (`realpath`) of the mount point — the same
|
|
4673
4685
|
* directory the symlink refers to.
|
|
4686
|
+
*
|
|
4687
|
+
* Returns an error when a read-only mount can't be resolved: a write denial on
|
|
4688
|
+
* the unresolved symlink wouldn't cover the directory writes actually land in.
|
|
4674
4689
|
*/
|
|
4675
|
-
addMountPathToIsolation(mountPath, hostPath) {
|
|
4690
|
+
addMountPathToIsolation(mountPath, hostPath, readOnly) {
|
|
4676
4691
|
if (this.isolation === "none") return;
|
|
4677
4692
|
const normMount = normalizeMountPath(mountPath);
|
|
4678
|
-
|
|
4693
|
+
const list = readOnly ? "denyWritePaths" : "readWritePaths";
|
|
4694
|
+
const existing = this._mountPathToIsolationPath.get(normMount);
|
|
4695
|
+
if (existing?.list === list) return;
|
|
4696
|
+
if (existing) this.removeMountIsolationForPath(normMount);
|
|
4679
4697
|
let isolationPath = hostPath;
|
|
4680
4698
|
try {
|
|
4681
4699
|
isolationPath = (0, fs.realpathSync)(hostPath);
|
|
4682
|
-
} catch {
|
|
4683
|
-
|
|
4700
|
+
} catch {
|
|
4701
|
+
if (readOnly) return `Cannot mount read-only filesystem at ${hostPath}: its source could not be resolved, so writes to it can't be denied to sandboxed commands.`;
|
|
4702
|
+
this.logger.warn("Could not resolve mount path for isolation; using unresolved path", { hostPath });
|
|
4703
|
+
}
|
|
4704
|
+
if (!this._nativeSandboxConfig[list]) this._nativeSandboxConfig = {
|
|
4684
4705
|
...this._nativeSandboxConfig,
|
|
4685
|
-
|
|
4706
|
+
[list]: []
|
|
4686
4707
|
};
|
|
4687
|
-
const paths = this._nativeSandboxConfig
|
|
4708
|
+
const paths = this._nativeSandboxConfig[list];
|
|
4688
4709
|
if (!paths.includes(isolationPath)) paths.push(isolationPath);
|
|
4689
|
-
if (!
|
|
4690
|
-
|
|
4710
|
+
if (!(readOnly ? this._initialDenyWritePaths : this._initialReadWritePaths).has(isolationPath)) {
|
|
4711
|
+
const key = `${list}:${isolationPath}`;
|
|
4712
|
+
this._mountIsolationRefCount.set(key, (this._mountIsolationRefCount.get(key) ?? 0) + 1);
|
|
4713
|
+
}
|
|
4714
|
+
this._mountPathToIsolationPath.set(normMount, {
|
|
4715
|
+
path: isolationPath,
|
|
4716
|
+
list
|
|
4717
|
+
});
|
|
4718
|
+
}
|
|
4719
|
+
/** Undo a mount whose isolation couldn't be applied and record it as failed. */
|
|
4720
|
+
async failMountIsolation(filesystem, mountPath, config, error) {
|
|
4721
|
+
this.logger.error("Could not apply mount isolation", {
|
|
4722
|
+
mountPath,
|
|
4723
|
+
error
|
|
4724
|
+
});
|
|
4725
|
+
await this.unmount(mountPath);
|
|
4726
|
+
this.mounts.set(mountPath, {
|
|
4727
|
+
filesystem,
|
|
4728
|
+
state: "error",
|
|
4729
|
+
config,
|
|
4730
|
+
error
|
|
4731
|
+
});
|
|
4732
|
+
return {
|
|
4733
|
+
success: false,
|
|
4734
|
+
mountPath,
|
|
4735
|
+
error
|
|
4736
|
+
};
|
|
4691
4737
|
}
|
|
4692
4738
|
/**
|
|
4693
|
-
* Reverse {@link addMountPathToIsolation}: drop refcounted paths from the
|
|
4694
|
-
* while preserving user-provided
|
|
4739
|
+
* Reverse {@link addMountPathToIsolation}: drop refcounted paths from the isolation
|
|
4740
|
+
* config on unmount while preserving user-provided paths from construction.
|
|
4695
4741
|
*/
|
|
4696
4742
|
removeMountIsolationForPath(mountPath) {
|
|
4697
4743
|
if (this.isolation === "none") return;
|
|
4698
4744
|
const normMount = normalizeMountPath(mountPath);
|
|
4699
|
-
const
|
|
4700
|
-
if (
|
|
4745
|
+
const entry = this._mountPathToIsolationPath.get(normMount);
|
|
4746
|
+
if (entry === void 0) return;
|
|
4701
4747
|
this._mountPathToIsolationPath.delete(normMount);
|
|
4702
|
-
|
|
4703
|
-
|
|
4748
|
+
const { path: isolationPath, list } = entry;
|
|
4749
|
+
if ((list === "denyWritePaths" ? this._initialDenyWritePaths : this._initialReadWritePaths).has(isolationPath)) return;
|
|
4750
|
+
const key = `${list}:${isolationPath}`;
|
|
4751
|
+
const next = (this._mountIsolationRefCount.get(key) ?? 0) - 1;
|
|
4704
4752
|
if (next <= 0) {
|
|
4705
|
-
this._mountIsolationRefCount.delete(
|
|
4706
|
-
const paths = this._nativeSandboxConfig
|
|
4753
|
+
this._mountIsolationRefCount.delete(key);
|
|
4754
|
+
const paths = this._nativeSandboxConfig[list];
|
|
4707
4755
|
if (paths) {
|
|
4708
4756
|
const idx = paths.indexOf(isolationPath);
|
|
4709
4757
|
if (idx !== -1) paths.splice(idx, 1);
|
|
4710
4758
|
}
|
|
4711
|
-
} else this._mountIsolationRefCount.set(
|
|
4759
|
+
} else this._mountIsolationRefCount.set(key, next);
|
|
4712
4760
|
}
|
|
4713
4761
|
/**
|
|
4714
4762
|
* Resolve a virtual mount path to a host filesystem path.
|
|
@@ -6690,6 +6738,159 @@ function splitTail(output, tail) {
|
|
|
6690
6738
|
};
|
|
6691
6739
|
}
|
|
6692
6740
|
/**
|
|
6741
|
+
* tokenx is synchronous and allocates per word, so running it over a multi-MB
|
|
6742
|
+
* output blocks the event loop for seconds. Outputs up to this many chars per
|
|
6743
|
+
* token of budget are counted and cut exactly as before; longer ones never reach
|
|
6744
|
+
* tokenx whole (see `countTokensOver` and `sliceEdge`).
|
|
6745
|
+
*/
|
|
6746
|
+
const WINDOW_CHARS_PER_TOKEN = 32;
|
|
6747
|
+
/**
|
|
6748
|
+
* tokenx never gives a non-whitespace segment fewer than one token per this many
|
|
6749
|
+
* UTF-16 chars: 6 by default, and up to 4 code points (8 chars when astral) for
|
|
6750
|
+
* its language rules. So text with more non-whitespace chars than
|
|
6751
|
+
* `limit * MAX_CHARS_PER_TOKEN` is over `limit`.
|
|
6752
|
+
*/
|
|
6753
|
+
const MAX_CHARS_PER_TOKEN = 8;
|
|
6754
|
+
const WHITESPACE_RUN_RE = /\s+/g;
|
|
6755
|
+
const STRUCTURED_WHITESPACE_RE = /\n\s/;
|
|
6756
|
+
const WS = 0;
|
|
6757
|
+
const PUNCT = 1;
|
|
6758
|
+
const DIGIT = 2;
|
|
6759
|
+
const WORD = 3;
|
|
6760
|
+
const CHAR_CLASS = (/* @__PURE__ */ new Uint8Array(128)).fill(WORD);
|
|
6761
|
+
for (const c of " \n\r\v\f") CHAR_CLASS[c.charCodeAt(0)] = WS;
|
|
6762
|
+
for (const c of ".,!?;(){}[]<>:/\\|@#$%^&*+=`~_\"-") CHAR_CLASS[c.charCodeAt(0)] = PUNCT;
|
|
6763
|
+
for (let c = 48; c <= 57; c++) CHAR_CLASS[c] = DIGIT;
|
|
6764
|
+
/** Same set as the regex `\s`, which is what tokenx splits words on. */
|
|
6765
|
+
function isWhitespace(code) {
|
|
6766
|
+
return code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
|
|
6767
|
+
}
|
|
6768
|
+
function runTokens(kind, length, onlyDigits) {
|
|
6769
|
+
if (kind === WS) return 0;
|
|
6770
|
+
if (length <= 3) return 1;
|
|
6771
|
+
if (kind === PUNCT) return Math.ceil(length / 2);
|
|
6772
|
+
return onlyDigits ? Math.ceil(length / 3) : Math.ceil(length / 6);
|
|
6773
|
+
}
|
|
6774
|
+
/**
|
|
6775
|
+
* One pass over char codes with no allocations: an approximate token count
|
|
6776
|
+
* (tokenx's rules for ASCII text, used only for the "of ~N tokens" total) and
|
|
6777
|
+
* the number of non-whitespace chars.
|
|
6778
|
+
*/
|
|
6779
|
+
function scanTokens(text) {
|
|
6780
|
+
let approx = 0;
|
|
6781
|
+
let nonWhitespace = 0;
|
|
6782
|
+
let kind = -1;
|
|
6783
|
+
let length = 0;
|
|
6784
|
+
let onlyDigits = true;
|
|
6785
|
+
for (let i = 0; i < text.length; i++) {
|
|
6786
|
+
const code = text.charCodeAt(i);
|
|
6787
|
+
const cls = code < 128 ? CHAR_CLASS[code] : isWhitespace(code) ? WS : WORD;
|
|
6788
|
+
const runKind = cls === DIGIT ? WORD : cls;
|
|
6789
|
+
if (runKind !== kind) {
|
|
6790
|
+
if (length) approx += runTokens(kind, length, onlyDigits);
|
|
6791
|
+
kind = runKind;
|
|
6792
|
+
length = 0;
|
|
6793
|
+
onlyDigits = true;
|
|
6794
|
+
}
|
|
6795
|
+
length++;
|
|
6796
|
+
if (cls !== WS) nonWhitespace++;
|
|
6797
|
+
if (cls !== DIGIT) onlyDigits = false;
|
|
6798
|
+
}
|
|
6799
|
+
if (length) approx += runTokens(kind, length, onlyDigits);
|
|
6800
|
+
return {
|
|
6801
|
+
approx,
|
|
6802
|
+
nonWhitespace
|
|
6803
|
+
};
|
|
6804
|
+
}
|
|
6805
|
+
/**
|
|
6806
|
+
* Exact token count of `output` when it may fit `limit`, else an approximation.
|
|
6807
|
+
* Returns `undefined` when the output fits, so callers return it as is.
|
|
6808
|
+
*/
|
|
6809
|
+
function countTokensOver(output, limit) {
|
|
6810
|
+
if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) {
|
|
6811
|
+
const exact = estimateTokenCount(output);
|
|
6812
|
+
return exact <= limit ? void 0 : exact;
|
|
6813
|
+
}
|
|
6814
|
+
const { approx, nonWhitespace } = scanTokens(output);
|
|
6815
|
+
if (nonWhitespace > limit * MAX_CHARS_PER_TOKEN) return approx;
|
|
6816
|
+
const exact = estimateTokenCount(output.replace(WHITESPACE_RUN_RE, (run) => STRUCTURED_WHITESPACE_RE.test(run) ? "\n " : " "));
|
|
6817
|
+
return exact <= limit ? void 0 : exact;
|
|
6818
|
+
}
|
|
6819
|
+
/**
|
|
6820
|
+
* `budget` tokens from one end of `output`. Outputs within the overall `limit`'s
|
|
6821
|
+
* size cap are cut exactly as before, by `sliceByTokensSafe(output, 0, budget)`
|
|
6822
|
+
* (`'head'`) or `sliceByTokensSafe(output, -budget)` (`'tail'`). Longer ones hand
|
|
6823
|
+
* tokenx only a window at that end, measured as tokenx sees it: whitespace runs
|
|
6824
|
+
* are collapsed (see `countTokensOver`), so padding can't crowd real text out of
|
|
6825
|
+
* the window. The cut is mapped back to the original text, whitespace and all.
|
|
6826
|
+
*
|
|
6827
|
+
* For those longer outputs the cut is approximate: it fits `budget` by tokenx's
|
|
6828
|
+
* count of the kept text, but can land elsewhere than tokenizing the whole output
|
|
6829
|
+
* would. tokenx counts a segment by its whole length, so a window that ends inside
|
|
6830
|
+
* a long segment counts it differently (at a 2,000-token budget, 65,000 'a' then
|
|
6831
|
+
* 'é' keeps 12,000 chars here and 6,000 when the whole output is tokenized).
|
|
6832
|
+
*/
|
|
6833
|
+
function sliceEdge(output, budget, limit, side) {
|
|
6834
|
+
if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) return side === "head" ? sliceByTokensSafe(output, 0, budget) : sliceByTokensSafe(output, -budget);
|
|
6835
|
+
const target = Math.max(budget, 1) * WINDOW_CHARS_PER_TOKEN;
|
|
6836
|
+
let size = 0;
|
|
6837
|
+
let inWhitespace = false;
|
|
6838
|
+
let edge = side === "head" ? 0 : output.length;
|
|
6839
|
+
while (side === "head" ? edge < output.length : edge > 0) {
|
|
6840
|
+
const code = output.charCodeAt(side === "head" ? edge : edge - 1);
|
|
6841
|
+
const whitespace = code < 128 ? CHAR_CLASS[code] === WS : isWhitespace(code);
|
|
6842
|
+
const cost = whitespace ? inWhitespace ? 0 : 2 : 1;
|
|
6843
|
+
if (size + cost > target) break;
|
|
6844
|
+
size += cost;
|
|
6845
|
+
inWhitespace = whitespace;
|
|
6846
|
+
edge += side === "head" ? 1 : -1;
|
|
6847
|
+
}
|
|
6848
|
+
const window = side === "head" ? output.slice(0, edge) : output.slice(edge);
|
|
6849
|
+
const runs = [];
|
|
6850
|
+
let collapsed = "";
|
|
6851
|
+
let last = 0;
|
|
6852
|
+
for (const match of window.matchAll(WHITESPACE_RUN_RE)) {
|
|
6853
|
+
collapsed += window.slice(last, match.index);
|
|
6854
|
+
const replacement = STRUCTURED_WHITESPACE_RE.test(match[0]) ? "\n " : " ";
|
|
6855
|
+
runs.push({
|
|
6856
|
+
collapsedStart: collapsed.length,
|
|
6857
|
+
collapsedEnd: collapsed.length + replacement.length,
|
|
6858
|
+
start: match.index,
|
|
6859
|
+
end: match.index + match[0].length
|
|
6860
|
+
});
|
|
6861
|
+
collapsed += replacement;
|
|
6862
|
+
last = match.index + match[0].length;
|
|
6863
|
+
}
|
|
6864
|
+
collapsed += window.slice(last);
|
|
6865
|
+
const toWindowIndex = (index) => {
|
|
6866
|
+
let shift = 0;
|
|
6867
|
+
for (const run of runs) {
|
|
6868
|
+
if (index < run.collapsedStart) break;
|
|
6869
|
+
if (index <= run.collapsedEnd) return index === run.collapsedEnd ? run.end : run.start;
|
|
6870
|
+
shift = run.end - run.collapsedEnd;
|
|
6871
|
+
}
|
|
6872
|
+
return index + shift;
|
|
6873
|
+
};
|
|
6874
|
+
if (side === "head") return sliceSafe(window, 0, toWindowIndex(fitBudget(sliceByTokensSafe(collapsed, 0, budget), budget, side).length));
|
|
6875
|
+
const kept = fitBudget(sliceByTokensSafe(collapsed, -budget), budget, side);
|
|
6876
|
+
return sliceSafe(window, toWindowIndex(collapsed.length - kept.length));
|
|
6877
|
+
}
|
|
6878
|
+
/**
|
|
6879
|
+
* tokenx slices a segment by the chars-per-token of its language, picked from the
|
|
6880
|
+
* chars it contains, so a cut that drops the char that picked it (a lone 'ж' in a run
|
|
6881
|
+
* of CJK) can count several times over `budget` on its own. Recount the kept text,
|
|
6882
|
+
* which is no longer than the bounded input it was cut from, and cut it again until
|
|
6883
|
+
* it fits.
|
|
6884
|
+
*/
|
|
6885
|
+
function fitBudget(kept, budget, side) {
|
|
6886
|
+
for (let tokens = estimateTokenCount(kept); kept.length > 0 && tokens > budget; tokens = estimateTokenCount(kept)) {
|
|
6887
|
+
const next = side === "head" ? sliceByTokensSafe(kept, 0, budget) : sliceByTokensSafe(kept, -budget);
|
|
6888
|
+
const length = next.length < kept.length ? next.length : Math.floor(kept.length * budget / tokens);
|
|
6889
|
+
kept = side === "head" ? sliceSafe(kept, 0, length) : sliceSafe(kept, kept.length - length);
|
|
6890
|
+
}
|
|
6891
|
+
return kept;
|
|
6892
|
+
}
|
|
6893
|
+
/**
|
|
6693
6894
|
* Token-based output limit. Truncates output to fit within a token budget.
|
|
6694
6895
|
* Uses tokenx for fast token estimation and truncates at the token level
|
|
6695
6896
|
* (not line boundaries) to maximise use of the budget.
|
|
@@ -6702,9 +6903,9 @@ function splitTail(output, tail) {
|
|
|
6702
6903
|
*/
|
|
6703
6904
|
async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from = "start") {
|
|
6704
6905
|
if (!output) return output;
|
|
6705
|
-
const totalTokens =
|
|
6706
|
-
if (totalTokens
|
|
6707
|
-
const kept = from === "start" ?
|
|
6906
|
+
const totalTokens = countTokensOver(output, limit);
|
|
6907
|
+
if (totalTokens === void 0) return output;
|
|
6908
|
+
const kept = from === "start" ? sliceEdge(output, limit, limit, "tail") : sliceEdge(output, limit, limit, "head");
|
|
6708
6909
|
const position = from === "start" ? "last" : "first";
|
|
6709
6910
|
return from === "start" ? `[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]\n${kept}` : `${kept}\n[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]`;
|
|
6710
6911
|
}
|
|
@@ -6714,12 +6915,12 @@ async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from =
|
|
|
6714
6915
|
*/
|
|
6715
6916
|
function sandwich(output, limit, headRatio, firstLine) {
|
|
6716
6917
|
if (!output) return output;
|
|
6717
|
-
const totalTokens =
|
|
6718
|
-
if (totalTokens
|
|
6918
|
+
const totalTokens = countTokensOver(output, limit);
|
|
6919
|
+
if (totalTokens === void 0) return output;
|
|
6719
6920
|
const headBudget = Math.floor(limit * headRatio);
|
|
6720
6921
|
const tailBudget = limit - headBudget;
|
|
6721
|
-
let head = headBudget > 0 ?
|
|
6722
|
-
let tail = tailBudget > 0 ?
|
|
6922
|
+
let head = headBudget > 0 ? sliceEdge(output, headBudget, limit, "head") : "";
|
|
6923
|
+
let tail = tailBudget > 0 ? sliceEdge(output, tailBudget, limit, "tail") : "";
|
|
6723
6924
|
const headEnd = head.length;
|
|
6724
6925
|
let tailStart = output.length - tail.length;
|
|
6725
6926
|
head = head.replace(/\r?\n$/, "");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/core",
|
|
3
|
-
"version": "1.86.0-alpha.
|
|
3
|
+
"version": "1.86.0-alpha.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -968,17 +968,17 @@
|
|
|
968
968
|
"zod-v3": "npm:zod@3.25.76",
|
|
969
969
|
"@internal/ai-sdk-v4": "0.0.98",
|
|
970
970
|
"@internal/ai-sdk-v5": "0.0.98",
|
|
971
|
-
"@internal/auth": "0.0.39",
|
|
972
971
|
"@internal/ai-v6": "0.0.98",
|
|
972
|
+
"@internal/ai-v7": "0.0.98",
|
|
973
|
+
"@internal/auth": "0.0.39",
|
|
973
974
|
"@internal/core": "0.1.4",
|
|
974
|
-
"@internal/deployer": "0.0.4",
|
|
975
975
|
"@internal/external-types": "0.0.101",
|
|
976
|
-
"@internal/
|
|
977
|
-
"@internal/ai-v7": "0.0.98",
|
|
976
|
+
"@internal/deployer": "0.0.4",
|
|
978
977
|
"@internal/lint": "0.0.151",
|
|
979
|
-
"@internal/
|
|
978
|
+
"@internal/llm-recorder": "0.0.87",
|
|
980
979
|
"@internal/test-utils": "0.0.87",
|
|
981
|
-
"@internal/types-builder": "0.0.126"
|
|
980
|
+
"@internal/types-builder": "0.0.126",
|
|
981
|
+
"@internal/voice": "0.0.47"
|
|
982
982
|
},
|
|
983
983
|
"engines": {
|
|
984
984
|
"node": ">=22.13.0"
|