@mastra/core 1.86.0-alpha.7 → 1.86.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent.d.ts +60 -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 -14
- package/dist/agent/durable/index.js +7 -14
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.js +2 -2
- 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-Cf3_IuY8.js → agent-controller-B7POPub5.js} +7 -7
- package/dist/{agent-controller-K5vHtqfO.cjs → agent-controller-DEPayioq.cjs} +7 -7
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-DqnQMfuf.cjs → background-tasks-7iftnRK_.cjs} +1 -1
- package/dist/{background-tasks-BgpX1P_s.js → background-tasks-Cv1ecD6S.js} +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-D8Osghdo.cjs → builder-DuJBbQDH.cjs} +2 -2
- package/dist/{builder-x295GDL6.js → builder-Gg-xnX_E.js} +2 -2
- package/dist/capabilities/302ai.json +194 -194
- package/dist/capabilities/abliteratedllm.json +32 -32
- package/dist/capabilities/abliteration-ai.json +11 -11
- package/dist/capabilities/above.json +12 -12
- package/dist/capabilities/adaption.json +13 -13
- package/dist/capabilities/adzuki.json +32 -32
- package/dist/capabilities/agentrouter.json +6 -6
- package/dist/capabilities/agnes.json +2 -2
- package/dist/capabilities/ai-router.json +5 -5
- package/dist/capabilities/aiand.json +23 -23
- package/dist/capabilities/aigrow.json +11 -11
- package/dist/capabilities/aimlapi.json +144 -144
- package/dist/capabilities/aixy.json +21 -21
- package/dist/capabilities/aki-io.json +15 -15
- package/dist/capabilities/alibaba-cn.json +79 -79
- package/dist/capabilities/alibaba-coding-plan-cn.json +2 -2
- package/dist/capabilities/alibaba-coding-plan.json +2 -2
- package/dist/capabilities/alibaba-token-plan-cn.json +52 -52
- package/dist/capabilities/alibaba-token-plan.json +53 -53
- package/dist/capabilities/alibaba.json +70 -70
- package/dist/capabilities/ambient.json +15 -15
- package/dist/capabilities/amd.json +9 -9
- package/dist/capabilities/anthropic.json +48 -48
- package/dist/capabilities/anyapi.json +12 -12
- package/dist/capabilities/apiko.json +4 -4
- package/dist/capabilities/arcee.json +10 -10
- package/dist/capabilities/augure.json +6 -6
- package/dist/capabilities/auriko.json +18 -18
- package/dist/capabilities/bailing.json +5 -5
- package/dist/capabilities/baseten.json +26 -26
- package/dist/capabilities/bee.json +4 -4
- package/dist/capabilities/berget.json +6 -6
- package/dist/capabilities/bothub.json +14 -14
- package/dist/capabilities/boundless.json +41 -41
- package/dist/capabilities/bumo.json +39 -39
- package/dist/capabilities/byteplus.json +34 -34
- package/dist/capabilities/cheapaimodel.json +7 -7
- package/dist/capabilities/cheapest-token.json +33 -33
- package/dist/capabilities/chutes.json +10 -10
- package/dist/capabilities/cline-pass.json +35 -35
- package/dist/capabilities/cloudcode.json +8 -8
- package/dist/capabilities/cloudferro-sherlock.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +31 -31
- package/dist/capabilities/commandcode.json +148 -148
- package/dist/capabilities/concentrate.json +277 -253
- package/dist/capabilities/cortecs.json +113 -113
- package/dist/capabilities/crossmodel.json +172 -172
- package/dist/capabilities/crusoe.json +9 -9
- package/dist/capabilities/daoxe.json +8 -8
- package/dist/capabilities/databricks.json +54 -54
- package/dist/capabilities/deepinfra.json +95 -86
- package/dist/capabilities/deepseek.json +3 -3
- package/dist/capabilities/digitalocean.json +117 -117
- package/dist/capabilities/dothoosh.json +35 -35
- package/dist/capabilities/doubleword.json +29 -29
- package/dist/capabilities/edenai.json +456 -456
- package/dist/capabilities/empiriolabs.json +174 -174
- package/dist/capabilities/engy.json +20 -20
- package/dist/capabilities/entrim.json +6 -6
- package/dist/capabilities/evroc.json +10 -10
- package/dist/capabilities/ezkielyna.json +10 -10
- package/dist/capabilities/fastrouter.json +77 -77
- package/dist/capabilities/fireworks-ai.json +60 -60
- package/dist/capabilities/freemodel.json +17 -17
- package/dist/capabilities/frogbot.json +93 -93
- package/dist/capabilities/gisoo.json +19 -19
- package/dist/capabilities/gmicloud.json +19 -19
- package/dist/capabilities/google.json +59 -59
- package/dist/capabilities/graphn.json +9 -9
- package/dist/capabilities/greenpt.json +34 -34
- package/dist/capabilities/groq.json +8 -8
- package/dist/capabilities/helicone.json +83 -83
- package/dist/capabilities/hopper.json +2 -2
- package/dist/capabilities/hostinger-router.json +9 -9
- package/dist/capabilities/hpc-ai.json +11 -11
- package/dist/capabilities/huawei-maas.json +13 -13
- package/dist/capabilities/hubris.json +33 -33
- package/dist/capabilities/huggingface.json +60 -51
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +27 -27
- package/dist/capabilities/impossibl.json +118 -118
- package/dist/capabilities/inception.json +3 -3
- package/dist/capabilities/inceptron.json +8 -8
- package/dist/capabilities/inco.json +4 -4
- package/dist/capabilities/infer.json +15 -15
- package/dist/capabilities/inferall.json +10 -10
- package/dist/capabilities/inference-coop.json +12 -12
- package/dist/capabilities/inferenceapis.json +20 -20
- package/dist/capabilities/inferris.json +4 -4
- package/dist/capabilities/infersia.json +8 -8
- package/dist/capabilities/inferx.json +3 -3
- package/dist/capabilities/infomaniak.json +4 -4
- package/dist/capabilities/io-net.json +4 -4
- package/dist/capabilities/iteracompute.json +63 -63
- package/dist/capabilities/jad-ai.json +3 -3
- package/dist/capabilities/jalapeno.json +11 -11
- package/dist/capabilities/jiekou.json +63 -63
- package/dist/capabilities/joingonka.json +4 -4
- package/dist/capabilities/jzstoken.json +52 -52
- package/dist/capabilities/keln.json +26 -26
- package/dist/capabilities/kenari.json +127 -127
- package/dist/capabilities/kilo.json +604 -628
- package/dist/capabilities/kimi-code-plan-cn.json +4 -4
- package/dist/capabilities/kimi-code-plan-global.json +4 -4
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +26 -26
- package/dist/capabilities/korouter.json +34 -34
- package/dist/capabilities/kunavo.json +4 -4
- package/dist/capabilities/liquid.json +10 -10
- package/dist/capabilities/lithosai.json +2 -2
- package/dist/capabilities/llmgateway-providers.json +934 -907
- package/dist/capabilities/llmgateway.json +339 -339
- package/dist/capabilities/llmtr.json +27 -27
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +53 -53
- package/dist/capabilities/lyceum.json +8 -8
- package/dist/capabilities/melious.json +13 -13
- package/dist/capabilities/merge-gateway.json +284 -284
- package/dist/capabilities/meta.json +11 -11
- package/dist/capabilities/minimax-cn-coding-plan.json +6 -6
- package/dist/capabilities/minimax-coding-plan.json +6 -6
- package/dist/capabilities/mistral.json +22 -22
- package/dist/capabilities/mixlayer.json +3 -3
- package/dist/capabilities/modal.json +13 -13
- package/dist/capabilities/model-oracle-ai.json +23 -23
- package/dist/capabilities/modelis.json +21 -21
- package/dist/capabilities/modelscope.json +2 -2
- package/dist/capabilities/modular.json +10 -10
- package/dist/capabilities/moneo.json +14 -14
- package/dist/capabilities/moonshotai-cn.json +7 -7
- package/dist/capabilities/moonshotai.json +7 -7
- package/dist/capabilities/morph.json +15 -15
- package/dist/capabilities/munito-eu.json +8 -8
- package/dist/capabilities/munito.json +10 -10
- package/dist/capabilities/nan.json +25 -25
- package/dist/capabilities/nano-gpt.json +570 -570
- package/dist/capabilities/nearai.json +87 -87
- package/dist/capabilities/nebius.json +41 -32
- package/dist/capabilities/neon.json +132 -132
- package/dist/capabilities/neuralwatt.json +38 -38
- package/dist/capabilities/novita-ai.json +153 -153
- package/dist/capabilities/nvidia.json +28 -28
- package/dist/capabilities/obscurify.json +33 -33
- package/dist/capabilities/oci.json +6 -6
- package/dist/capabilities/ofox.json +322 -322
- package/dist/capabilities/ollama-cloud.json +52 -52
- package/dist/capabilities/openai.json +47 -47
- package/dist/capabilities/opencode-go.json +79 -78
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +520 -530
- package/dist/capabilities/opper.json +30 -24
- package/dist/capabilities/orcarouter.json +227 -227
- package/dist/capabilities/outerlabs.json +28 -28
- package/dist/capabilities/ovhcloud.json +8 -8
- package/dist/capabilities/pareto.json +5 -5
- package/dist/capabilities/perplexity-agent.json +64 -64
- package/dist/capabilities/perplexity.json +2 -2
- package/dist/capabilities/phala.json +36 -36
- package/dist/capabilities/pioneer.json +30 -30
- package/dist/capabilities/poe.json +109 -109
- package/dist/capabilities/powerspring.json +10 -10
- package/dist/capabilities/primalabs.json +10 -10
- package/dist/capabilities/prime.json +116 -99
- package/dist/capabilities/privatemode-ai.json +10 -10
- package/dist/capabilities/proxystacks.json +7 -7
- package/dist/capabilities/qiniu-ai.json +12 -12
- package/dist/capabilities/refuseless.json +8 -8
- package/dist/capabilities/regolo-ai.json +8 -8
- package/dist/capabilities/requesty.json +172 -172
- package/dist/capabilities/ruapi.json +21 -21
- package/dist/capabilities/runcrate.json +15 -15
- package/dist/capabilities/runinfra.json +20 -20
- package/dist/capabilities/sakana.json +7 -7
- package/dist/capabilities/sambanova.json +4 -4
- package/dist/capabilities/sandbase.json +30 -30
- package/dist/capabilities/sarvam.json +5 -5
- package/dist/capabilities/scaleway.json +17 -17
- package/dist/capabilities/scnet-token-plan.json +8 -8
- package/dist/capabilities/scx-ai.json +26 -26
- package/dist/capabilities/sensenova.json +7 -7
- package/dist/capabilities/siliconflow-cn.json +45 -45
- package/dist/capabilities/siliconflow.json +59 -59
- package/dist/capabilities/snowflake-cortex.json +25 -25
- package/dist/capabilities/sokkan.json +9 -9
- package/dist/capabilities/sparrowcodes.json +23 -23
- package/dist/capabilities/standardcompute.json +103 -103
- package/dist/capabilities/steadyrouter.json +39 -39
- package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
- package/dist/capabilities/stepfun-ai.json +6 -6
- package/dist/capabilities/stepfun-step-plan.json +6 -6
- package/dist/capabilities/stepfun.json +6 -6
- package/dist/capabilities/stepping-stone.json +13 -13
- package/dist/capabilities/subconscious.json +2 -2
- package/dist/capabilities/synthetic.json +11 -11
- package/dist/capabilities/synthorai.json +27 -27
- package/dist/capabilities/teamorouter.json +30 -30
- package/dist/capabilities/teapot-router.json +13 -13
- package/dist/capabilities/tencent-token-plan.json +24 -24
- package/dist/capabilities/tencent-tokenhub.json +9 -9
- package/dist/capabilities/tensorx.json +45 -45
- package/dist/capabilities/tenstorrent.json +6 -6
- package/dist/capabilities/the-grid-ai.json +24 -24
- package/dist/capabilities/thinkingmachines.json +59 -59
- package/dist/capabilities/tinfoil.json +14 -14
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +53 -53
- package/dist/capabilities/tokengo.json +25 -25
- package/dist/capabilities/tokenify.json +10 -10
- package/dist/capabilities/trustedrouter.json +7 -7
- package/dist/capabilities/trustedtokens.json +16 -16
- package/dist/capabilities/umans-ai-coding-plan.json +15 -15
- package/dist/capabilities/umans-ai.json +8 -8
- package/dist/capabilities/uncensuredai.json +4 -4
- package/dist/capabilities/unrestricted.json +4 -4
- package/dist/capabilities/uplinkswitch.json +20 -20
- package/dist/capabilities/upstage.json +6 -6
- package/dist/capabilities/vancine.json +22 -22
- package/dist/capabilities/vercel.json +569 -577
- package/dist/capabilities/vivgrid.json +80 -80
- package/dist/capabilities/volcengine-coding-plan.json +26 -26
- package/dist/capabilities/volcengine.json +30 -30
- package/dist/capabilities/vultr.json +25 -25
- package/dist/capabilities/wafer.ai.json +18 -18
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +8 -8
- package/dist/capabilities/wandb.json +20 -20
- package/dist/capabilities/watt.json +20 -20
- package/dist/capabilities/xai.json +6 -6
- package/dist/capabilities/xiaomi.json +5 -5
- package/dist/capabilities/xpersona.json +12 -12
- package/dist/capabilities/xxapi.json +33 -33
- package/dist/capabilities/zai-coding-plan.json +9 -9
- package/dist/capabilities/zai.json +27 -27
- package/dist/capabilities/zenifra.json +23 -23
- package/dist/capabilities/zenmux.json +192 -192
- package/dist/capabilities/zerogpu.json +10 -10
- package/dist/capabilities/zhipuai-coding-plan.json +7 -7
- package/dist/capabilities/zhipuai.json +26 -26
- 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-BRVCOutx.js} +1 -1
- package/dist/{channels-q6qnuRNV.cjs → channels-MjTA9bFp.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 +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +790 -790
- 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-durable-agents.md +9 -5
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +1 -0
- package/dist/docs/references/docs-knowledge-load-your-content.md +1 -1
- package/dist/docs/references/docs-mastra-platform-observability-overview.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-workflows-overview.md +1 -1
- package/dist/docs/references/docs-workflows-scheduled-workflows.md +1 -1
- 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 +2 -0
- package/dist/docs/references/reference-agents-channels.md +116 -27
- package/dist/docs/references/reference-agents-durable-agent.md +2 -0
- 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 +2 -2
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +43 -20
- 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 +1 -1
- 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/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/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/index.cjs +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +8092 -8089
- package/dist/llm/model/shared.types.d.ts +31 -0
- package/dist/{llm-DnXK3Pmw.js → llm-Djd8Qzi0.js} +2 -2
- package/dist/{llm-CsQuqKPc.cjs → llm-DmUucguC.cjs} +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-CO_Xz2zR.js} +460 -94
- package/dist/{manager-DwFnIrI6.cjs → manager-D27PkIPo.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-B8i1UDZs.js → mastra-Ch00nEAJ.js} +31 -16
- package/dist/{mastra-Cn5NC6Es.cjs → mastra-qsVWpOTi.cjs} +31 -16
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/{model-CsOcWMUt.js → model-CW-mfGYA.js} +1 -1
- package/dist/{model-CNPfry_X.cjs → model-Do6DTJoj.cjs} +1 -1
- package/dist/{netlify-C-83Fxus.cjs → netlify-DU32SDT6.cjs} +1 -1
- package/dist/{netlify-C-OpNSGp.js → netlify-DZSAbdve.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/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/{provider-registry-RZ8EgSe8.js → provider-registry-deA0x-Gd.js} +22467 -22456
- package/dist/{provider-registry-9O-H9osy.cjs → provider-registry-zGezZVsL.cjs} +22467 -22456
- package/dist/provider-registry.json +22423 -22408
- package/dist/{registry-generator-DxCX-FiO.cjs → registry-generator-BkQ1AxZn.cjs} +1 -1
- package/dist/{registry-generator-e8sltJls.js → registry-generator-VvBfOKAD.js} +1 -1
- package/dist/{rehydrate-D3fPgJwp.js → rehydrate-BjLV643n.js} +2 -2
- package/dist/{rehydrate-B-wrAN7C.cjs → rehydrate-DDYFpQsV.cjs} +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-5Suldxz3.cjs} +519 -71
- package/dist/{run-registry-DC03XLeZ.js → run-registry-CGRPldLH.js} +519 -71
- package/dist/storage/domains/knowledge/base.d.ts +5 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/pages.d.ts +24 -7
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/stream/base/output.d.ts +42 -15
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +19 -0
- package/dist/{stream-CJUm6EAH.js → stream-Dpwx0whf.js} +1 -1
- package/dist/{stream-4aNIw_TQ.cjs → stream-Dvy_0o14.cjs} +1 -1
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-FEEwHfmg.js → tool-loop-agent-PbWrEj1k.js} +3 -3
- package/dist/{tool-loop-agent-Dn0QCB9n.cjs → tool-loop-agent-UxOv3FoK.cjs} +3 -3
- package/dist/tools/types.d.ts +27 -1
- package/dist/{utils-DY01hxVd.cjs → utils-BbMTlyBO.cjs} +1 -1
- package/dist/{utils-Bd_y1_a-.js → utils-BnNi1BYM.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-CX0yQo_q.js → validate-HSBcm96b.js} +1 -1
- package/dist/{validate-CuB_1Zd3.cjs → validate-Skps-cM3.cjs} +1 -1
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-GsGIxPMa.cjs → worker-BE-0DyKL.cjs} +2 -2
- package/dist/{worker-DSEfMPmq.js → worker-BKrKHZzU.js} +2 -2
- package/dist/{worker-CbaSmip-.cjs → worker-BNS5A3qP.cjs} +2 -2
- package/dist/{worker-B80xkcKG.js → worker-DehaD4qD.js} +2 -2
- package/dist/{workflow-CnBPXTpv.cjs → workflow-BjUTwaK9.cjs} +4 -4
- package/dist/{workflow-CZHY_C85.js → workflow-Bvw6yDjc.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/index.cjs +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/{workspace-D7TIleIt.js → workspace-C05xDH60.js} +160 -7
- package/dist/{workspace-D2drutNg.cjs → workspace-D1OzzlLw.cjs} +160 -7
- package/package.json +6 -6
- package/src/llm/model/provider-types.generated.d.ts +8092 -8089
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_run_registry = require("../../run-registry-
|
|
2
|
+
const require_run_registry = require("../../run-registry-5Suldxz3.cjs");
|
|
3
3
|
exports.EventedExecutionEngine = require_run_registry.EventedExecutionEngine;
|
|
4
4
|
exports.EventedRun = require_run_registry.EventedRun;
|
|
5
5
|
exports.EventedWorkflow = require_run_registry.EventedWorkflow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { $s as EventedExecutionEngine, Cs as EventedRun, ws as EventedWorkflow, As as StepExecutor, ks as WorkflowEventProcessor, Ts as cloneStep, Es as cloneWorkflow, Ds as createStep, Os as createWorkflow } from "../../run-registry-
|
|
1
|
+
export { $s as EventedExecutionEngine, Cs as EventedRun, ws as EventedWorkflow, As as StepExecutor, ks as WorkflowEventProcessor, Ts as cloneStep, Es as cloneWorkflow, Ds as createStep, Os as createWorkflow } from "../../run-registry-CGRPldLH.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Mastra } from '../../mastra/index.js';
|
|
2
|
+
import type { WorkflowsStorage } from '../../storage/domains/workflows/base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Evented runs spread over several processes need a pubsub that hands a stopped
|
|
5
|
+
* worker's event to another worker, and a store whose step guards let one
|
|
6
|
+
* delivery of a step commit. Logs once per Mastra instance when the pubsub
|
|
7
|
+
* reaches other processes and one of the two is missing.
|
|
8
|
+
*
|
|
9
|
+
* It judges the setup, not how many processes use it: Mastra can't count them.
|
|
10
|
+
* A pubsub that stays inside the process is left alone, since no other process
|
|
11
|
+
* can take part in its runs. `MASTRA_DISABLE_EVENTED_SETUP_WARNING=true`
|
|
12
|
+
* disables it for a shared transport used by one process.
|
|
13
|
+
*
|
|
14
|
+
* The message names no supported pubsub or store. The docs page it links to is
|
|
15
|
+
* the one place that lists them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function warnUnsupportedEventedSetup(mastra: Mastra, workflowsStore?: WorkflowsStorage): void;
|
|
18
|
+
//# sourceMappingURL=setup-warning.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { WorkflowRunStatus } from '../../types.js';
|
|
2
|
+
/** The statuses of a run that has not ended yet. */
|
|
3
|
+
export declare const UNENDED_RUN_STATUSES: WorkflowRunStatus[];
|
|
4
|
+
/** Whether a run stored with `status` has ended. */
|
|
5
|
+
export declare function isEndedRunStatus(status: string | undefined): boolean;
|
|
6
|
+
type EndedRunStatus = 'success' | 'failed' | 'canceled' | 'tripwire';
|
|
7
|
+
/** Whether the stored run `run` has ended. */
|
|
8
|
+
export declare function hasRunEnded<T extends {
|
|
9
|
+
status?: string;
|
|
10
|
+
}>(run: T | null | undefined): run is T & {
|
|
11
|
+
status: EndedRunStatus;
|
|
12
|
+
};
|
|
13
|
+
/** Whether `executionPath` points past the last entry of `stepGraph`: a step run there ends the run. */
|
|
14
|
+
export declare function isPastLastEntry(stepGraph: readonly unknown[], executionPath: number[] | undefined): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a step event is the one that ended the stored run `run`, which a worker still handles
|
|
17
|
+
* when the run has ended. Only a successful run has one: its worker stores the end before
|
|
18
|
+
* publishing it and may stop in between, and handling the event again publishes the end. The
|
|
19
|
+
* stored active path names it: the step end the run ended at, or the step run past the last entry.
|
|
20
|
+
* A failed run's end is stored by its own `workflow.fail`, which a redelivery of that event
|
|
21
|
+
* finishes.
|
|
22
|
+
*
|
|
23
|
+
* This can't tell an end that was stored and not published from one that was already handled, so
|
|
24
|
+
* a late copy of the event publishes the end again (and, for a nested run, hands it to the parent
|
|
25
|
+
* again).
|
|
26
|
+
*/
|
|
27
|
+
export declare function isRunEndingEvent(type: string, executionPath: number[] | undefined, run: {
|
|
28
|
+
status?: string;
|
|
29
|
+
activePaths?: number[];
|
|
30
|
+
}, stepGraph: readonly unknown[] | undefined): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether two execution paths name the same position in the step graph. A missing path matches
|
|
33
|
+
* only another missing path: a run stored without active paths was ended by an event without one.
|
|
34
|
+
*/
|
|
35
|
+
export declare function samePath(a: number[] | undefined, b: number[] | undefined): boolean;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=run-status.d.ts.map
|
|
@@ -98,6 +98,16 @@ export declare function createStep<TProcessorId extends string, TInput extends I
|
|
|
98
98
|
* This is a copy of first one, KEEP THIS IN SYNC!
|
|
99
99
|
*/
|
|
100
100
|
export declare function createStep<TStepId extends string, TStateSchema extends PublicSchema<any> | undefined, TInputSchema extends PublicSchema<any>, TOutputSchema extends PublicSchema<any>, TResumeSchema extends PublicSchema<any> | undefined = undefined, TSuspendSchema extends PublicSchema<any> | undefined = undefined>(params: StepParams<TStepId, TStateSchema, TInputSchema, TOutputSchema, TResumeSchema, TSuspendSchema>): Step<TStepId, TStateSchema extends PublicSchema<any> ? InferPublicSchema<TStateSchema> : unknown, InferPublicSchema<TInputSchema>, InferPublicSchema<TOutputSchema>, TResumeSchema extends PublicSchema<any> ? InferPublicSchema<TResumeSchema> : unknown, TSuspendSchema extends PublicSchema<any> ? InferPublicSchema<TSuspendSchema> : unknown, DefaultEngineType>;
|
|
101
|
+
/**
|
|
102
|
+
* Builds a workflow on the evented execution engine: each step is an event on
|
|
103
|
+
* the Mastra host's pubsub, so any worker can run the next one.
|
|
104
|
+
*
|
|
105
|
+
* In one process it runs on any pubsub, including the default one. Running it
|
|
106
|
+
* on several processes needs a pubsub that redelivers unacknowledged events and
|
|
107
|
+
* a workflows store with step guards.
|
|
108
|
+
*
|
|
109
|
+
* @see https://mastra.ai/docs/server/pubsub#evented-workflows-and-agents
|
|
110
|
+
*/
|
|
101
111
|
export declare function createWorkflow<TWorkflowId extends string = string, TInputSchema extends PublicSchema<any> = PublicSchema<any>, TOutputSchema extends PublicSchema<any> = PublicSchema<any>, TStateSchema extends PublicSchema<any> | undefined = undefined, TSteps extends Step<string, any, any, any, any, any, EventedEngineType>[] = Step<string, any, any, any, any, any, EventedEngineType>[], TRequestContextSchema extends PublicSchema<any> | undefined = undefined, TStorageVersion extends 1 | 2 = 1>(params: CreateWorkflowParams<TWorkflowId, TStateSchema, TInputSchema, TOutputSchema, TSteps, TRequestContextSchema, TStorageVersion>): EventedWorkflow<EventedEngineType, TSteps, TWorkflowId, InferSchemaOutput<TStateSchema>, InferPublicSchema<TInputSchema>, InferPublicSchema<TOutputSchema>, InferPublicSchema<TInputSchema>, TStorageVersion>;
|
|
102
112
|
export declare class EventedWorkflow<TEngineType = EventedEngineType, TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TWorkflowId extends string = string, TState = unknown, TInput = unknown, TOutput = unknown, TPrevSchema = TInput, TStorageVersion extends 1 | 2 = any> extends Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, unknown, TStorageVersion> {
|
|
103
113
|
constructor(params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, unknown, TStorageVersion>);
|
package/dist/workflows/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_run_registry = require("../run-registry-
|
|
3
|
-
const require_stream = require("../stream-
|
|
2
|
+
const require_run_registry = require("../run-registry-5Suldxz3.cjs");
|
|
3
|
+
const require_stream = require("../stream-Dvy_0o14.cjs");
|
|
4
4
|
const require_predicate_index = require("../predicate/index.cjs");
|
|
5
5
|
const require_schedules = require("../schedules-BZS8McF7.cjs");
|
|
6
6
|
const require_scheduler = require("../scheduler-D00X03jQ.cjs");
|
|
7
|
-
const require_validate = require("../validate-
|
|
8
|
-
const require_rehydrate = require("../rehydrate-
|
|
7
|
+
const require_validate = require("../validate-Skps-cM3.cjs");
|
|
8
|
+
const require_rehydrate = require("../rehydrate-DDYFpQsV.cjs");
|
|
9
9
|
// src/workflows/state-reader.ts
|
|
10
10
|
const getStep = (state, stepId) => state.steps?.[stepId];
|
|
11
11
|
const getFirstStepResult = (step) => {
|
package/dist/workflows/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $c as validateStepInput, Ac as RESUME_SNAPSHOT_POLL_INTERVAL_MS, Bc as defineStateAccessors, Dc as createStepFromAgent, Ec as createMappingStep, Fc as cleanStepResult, Gc as hydrateSerializedStepErrors, Hc as getResumeLabelsByStepId, Ic as createDeprecationProxy, Jc as omitPriorCompletionFields, Kc as isEntryFinished, Lc as createRestartExecutionParams, Mc as abortableSleep, Nc as applyStateDelta, Oc as createStepFromClassifier, Pc as assertTimeTravelGraphMatchesSnapshot, Qc as setLongTimeout, Rc as createTimeTravelExecutionParams, Sc as ExecutionEngine, Ss as createWorkflow, Uc as getSingleStepEntryId, Vc as getRestartStartIndex, Wc as getStepIds, Xc as resolveForeachConcurrency, Yc as omitPriorSuspensionFields, Zc as runCountDeprecationMessage, ac as createStep, al as getEntryId, bs as cloneWorkflow, cc as predicateToCondition, el as validateStepRequestContext, ic as cloneStep, il as waitForSuspendedSnapshot, jc as RESUME_SNAPSHOT_WAIT_STATUSES, js as computeScheduleDefinitionHash, kc as createStepFromTool, lc as evaluatePredicate, ll as workflowTermination, nc as Run, nl as validateStepStateData, oc as isProcessor, ol as getEntryWorkflow, qc as isSingleStepEntry, rc as Workflow, rl as validateStepSuspendData, sc as mapVariable, tl as validateStepResumeData, vc as DefaultExecutionEngine, xs as createEventedWorkflow, zc as defineLazyWriter } from "../run-registry-
|
|
2
|
-
import { St as getStepResultAsync, xt as getStepResult } from "../stream-
|
|
1
|
+
import { $c as validateStepInput, Ac as RESUME_SNAPSHOT_POLL_INTERVAL_MS, Bc as defineStateAccessors, Dc as createStepFromAgent, Ec as createMappingStep, Fc as cleanStepResult, Gc as hydrateSerializedStepErrors, Hc as getResumeLabelsByStepId, Ic as createDeprecationProxy, Jc as omitPriorCompletionFields, Kc as isEntryFinished, Lc as createRestartExecutionParams, Mc as abortableSleep, Nc as applyStateDelta, Oc as createStepFromClassifier, Pc as assertTimeTravelGraphMatchesSnapshot, Qc as setLongTimeout, Rc as createTimeTravelExecutionParams, Sc as ExecutionEngine, Ss as createWorkflow, Uc as getSingleStepEntryId, Vc as getRestartStartIndex, Wc as getStepIds, Xc as resolveForeachConcurrency, Yc as omitPriorSuspensionFields, Zc as runCountDeprecationMessage, ac as createStep, al as getEntryId, bs as cloneWorkflow, cc as predicateToCondition, el as validateStepRequestContext, ic as cloneStep, il as waitForSuspendedSnapshot, jc as RESUME_SNAPSHOT_WAIT_STATUSES, js as computeScheduleDefinitionHash, kc as createStepFromTool, lc as evaluatePredicate, ll as workflowTermination, nc as Run, nl as validateStepStateData, oc as isProcessor, ol as getEntryWorkflow, qc as isSingleStepEntry, rc as Workflow, rl as validateStepSuspendData, sc as mapVariable, tl as validateStepResumeData, vc as DefaultExecutionEngine, xs as createEventedWorkflow, zc as defineLazyWriter } from "../run-registry-CGRPldLH.js";
|
|
2
|
+
import { St as getStepResultAsync, xt as getStepResult } from "../stream-Dpwx0whf.js";
|
|
3
3
|
import { derivePredicateLabel, predicateSchema } from "../predicate/index.js";
|
|
4
4
|
import { _ as validateCron, h as computeNextFireAt } from "../schedules-DZfSx-7P.js";
|
|
5
5
|
import { n as WorkflowScheduler, t as Scheduler } from "../scheduler-B-VZUvv_.js";
|
|
6
|
-
import { a as jsonSchemaToZod, c as analyzeMapConfig, d as toJsonSchemaOrUndefined, f as validateWorkflowRefs, h as forEachSingleStepEntryWithPath, i as validateWorkflowSchemas, l as parseMapConfig, m as forEachSingleStepEntry, n as validateDynamicWorkflow, o as validateStorableJsonSchema, p as collectNestedWorkflowIds, r as validateWorkflowStructure, s as inferGraphSchemas, t as assertValidDynamicWorkflow, u as schemaCompatibility } from "../validate-
|
|
7
|
-
import { n as entryOptionFields, r as toStorableGraph, t as rehydrateWorkflow } from "../rehydrate-
|
|
6
|
+
import { a as jsonSchemaToZod, c as analyzeMapConfig, d as toJsonSchemaOrUndefined, f as validateWorkflowRefs, h as forEachSingleStepEntryWithPath, i as validateWorkflowSchemas, l as parseMapConfig, m as forEachSingleStepEntry, n as validateDynamicWorkflow, o as validateStorableJsonSchema, p as collectNestedWorkflowIds, r as validateWorkflowStructure, s as inferGraphSchemas, t as assertValidDynamicWorkflow, u as schemaCompatibility } from "../validate-HSBcm96b.js";
|
|
7
|
+
import { n as entryOptionFields, r as toStorableGraph, t as rehydrateWorkflow } from "../rehydrate-BjLV643n.js";
|
|
8
8
|
// src/workflows/state-reader.ts
|
|
9
9
|
const getStep = (state, stepId) => state.steps?.[stepId];
|
|
10
10
|
const getFirstStepResult = (step) => {
|
|
@@ -430,12 +430,17 @@ export declare class Workflow<TEngineType = DefaultEngineType, TSteps extends St
|
|
|
430
430
|
protected takeNestedRun(): {
|
|
431
431
|
/** The parent run's storage version, which a new nested run takes. */
|
|
432
432
|
storageVersion: 1 | 2;
|
|
433
|
-
/**
|
|
433
|
+
/**
|
|
434
|
+
* Set when execute() may start the nested run: on a start, and on a restart, which starts it
|
|
435
|
+
* when it wasn't stored before. Unset on a resume.
|
|
436
|
+
*/
|
|
434
437
|
start?: {
|
|
435
438
|
input: TInput;
|
|
436
439
|
state: TState;
|
|
437
440
|
inheritedState?: StateBase;
|
|
438
441
|
};
|
|
442
|
+
/** Set by createRun() when it saved the run's first snapshot: the run wasn't stored before. */
|
|
443
|
+
inserted?: boolean;
|
|
439
444
|
} | undefined;
|
|
440
445
|
/**
|
|
441
446
|
* Resolves the storage version a createRun() call uses, and reads the stored run that call
|
package/dist/workspace/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_workspace = require("../workspace-
|
|
2
|
+
const require_workspace = require("../workspace-D1OzzlLw.cjs");
|
|
3
3
|
const require_errors = require("../errors-D5kMB1FQ.cjs");
|
|
4
4
|
const require_workspace_skills = require("../workspace-skills-BcquhPDn.cjs");
|
|
5
5
|
exports.CompositeFilesystem = require_workspace.CompositeFilesystem;
|
package/dist/workspace/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as SandboxExecutionError, A as requireFilesystem, B as UnsupportedStdinCloseError, C as DEFAULT_TAIL_LINES, D as editFileTool, F as getRecommendedIsolation, G as validateSandboxFileMode, H as assertModesUnsupported, I as isIsolationAvailable, J as IsolationUnavailableError, K as MountManager, L as SandboxProcessManager, M as requireWorkspace, N as LocalSandbox, O as deleteFileTool, P as detectIsolation, Q as SandboxError, R as MastraSandbox, S as executeCommandTool, U as supportsComputer, V as MAX_SANDBOX_FILE_MODE, W as supportsNetworking, X as MountNotSupportedError, Y as MountError, Z as SandboxAbortError, _ as readFileTool, a as normalizeFactorySandboxSettings, at as LocalFilesystem, b as indexContentTool, c as formatSkillActivation, ct as callLifecycle, d as CompositeVersionedSkillSource, et as SandboxNotReadyError, f as VersionedSkillSource, g as searchTool, h as writeFileTool, i as isFactorySandbox, j as requireSandbox, k as applyPatchTool, l as collectSkillForPublish, lt as WORKSPACE_TOOLS, m as resolveToolConfig, n as FactorySandbox, nt as SandboxUnsupportedFeatureError, o as Workspace, ot as MastraFilesystem, p as createWorkspaceTools, q as FilesystemNotMountableError, r as describeFactorySandbox, s as createSkillTools, st as CompositeFilesystem, t as FACTORY_SANDBOX_BRAND, tt as SandboxTimeoutError, u as publishSkillFromSource, ut as WORKSPACE_TOOLS_PREFIX, v as mkdirTool, w as truncateOutput, x as fileStatTool, y as listFilesTool, z as ProcessHandle } from "../workspace-
|
|
1
|
+
import { $ as SandboxExecutionError, A as requireFilesystem, B as UnsupportedStdinCloseError, C as DEFAULT_TAIL_LINES, D as editFileTool, F as getRecommendedIsolation, G as validateSandboxFileMode, H as assertModesUnsupported, I as isIsolationAvailable, J as IsolationUnavailableError, K as MountManager, L as SandboxProcessManager, M as requireWorkspace, N as LocalSandbox, O as deleteFileTool, P as detectIsolation, Q as SandboxError, R as MastraSandbox, S as executeCommandTool, U as supportsComputer, V as MAX_SANDBOX_FILE_MODE, W as supportsNetworking, X as MountNotSupportedError, Y as MountError, Z as SandboxAbortError, _ as readFileTool, a as normalizeFactorySandboxSettings, at as LocalFilesystem, b as indexContentTool, c as formatSkillActivation, ct as callLifecycle, d as CompositeVersionedSkillSource, et as SandboxNotReadyError, f as VersionedSkillSource, g as searchTool, h as writeFileTool, i as isFactorySandbox, j as requireSandbox, k as applyPatchTool, l as collectSkillForPublish, lt as WORKSPACE_TOOLS, m as resolveToolConfig, n as FactorySandbox, nt as SandboxUnsupportedFeatureError, o as Workspace, ot as MastraFilesystem, p as createWorkspaceTools, q as FilesystemNotMountableError, r as describeFactorySandbox, s as createSkillTools, st as CompositeFilesystem, t as FACTORY_SANDBOX_BRAND, tt as SandboxTimeoutError, u as publishSkillFromSource, ut as WORKSPACE_TOOLS_PREFIX, v as mkdirTool, w as truncateOutput, x as fileStatTool, y as listFilesTool, z as ProcessHandle } from "../workspace-C05xDH60.js";
|
|
2
2
|
import { _ as WorkspaceError, a as FileReadRequiredError, b as WorkspaceReadOnlyError, c as FilesystemNotReadyError, d as PermissionError, f as SandboxFeatureNotSupportedError, g as UnsupportedGrepPatternError, h as StaleFileError, i as FileNotFoundError, l as IsDirectoryError, m as SearchNotAvailableError, n as DirectoryNotFoundError, o as FilesystemError, p as SandboxNotAvailableError, r as FileExistsError, s as FilesystemNotAvailableError, t as DirectoryNotEmptyError, u as NotDirectoryError, v as WorkspaceNotAvailableError, y as WorkspaceNotReadyError } from "../errors-CzFYpCHw.js";
|
|
3
3
|
import { b as getMimeType, f as createGlobMatcher, h as matchGlob, l as LocalSkillSource, m as isGlobPattern, p as extractGlobBase } from "../workspace-skills-38OY32_b.js";
|
|
4
4
|
export { CompositeFilesystem, CompositeVersionedSkillSource, DEFAULT_TAIL_LINES, DirectoryNotEmptyError, DirectoryNotFoundError, FACTORY_SANDBOX_BRAND, FactorySandbox, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, FilesystemNotMountableError, FilesystemNotReadyError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, LocalSkillSource, MAX_SANDBOX_FILE_MODE, MastraFilesystem, MastraSandbox, MountError, MountManager, MountNotSupportedError, NotDirectoryError, PermissionError, ProcessHandle, SandboxAbortError, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxProcessManager, SandboxTimeoutError, SandboxUnsupportedFeatureError, SearchNotAvailableError, StaleFileError, UnsupportedGrepPatternError, UnsupportedStdinCloseError, VersionedSkillSource, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotAvailableError, WorkspaceNotReadyError, WorkspaceReadOnlyError, applyPatchTool, assertModesUnsupported, callLifecycle, collectSkillForPublish, createGlobMatcher, createSkillTools, createWorkspaceTools, deleteFileTool, describeFactorySandbox, detectIsolation, editFileTool, executeCommandTool, extractGlobBase, fileStatTool, formatSkillActivation, getMimeType, getRecommendedIsolation, indexContentTool, isFactorySandbox, isGlobPattern, isIsolationAvailable, listFilesTool, matchGlob, mkdirTool, normalizeFactorySandboxSettings, publishSkillFromSource, readFileTool, requireFilesystem, requireSandbox, requireWorkspace, resolveToolConfig, searchTool, supportsComputer, supportsNetworking, truncateOutput, validateSandboxFileMode, writeFileTool };
|
|
@@ -6685,6 +6685,159 @@ function splitTail(output, tail) {
|
|
|
6685
6685
|
};
|
|
6686
6686
|
}
|
|
6687
6687
|
/**
|
|
6688
|
+
* tokenx is synchronous and allocates per word, so running it over a multi-MB
|
|
6689
|
+
* output blocks the event loop for seconds. Outputs up to this many chars per
|
|
6690
|
+
* token of budget are counted and cut exactly as before; longer ones never reach
|
|
6691
|
+
* tokenx whole (see `countTokensOver` and `sliceEdge`).
|
|
6692
|
+
*/
|
|
6693
|
+
const WINDOW_CHARS_PER_TOKEN = 32;
|
|
6694
|
+
/**
|
|
6695
|
+
* tokenx never gives a non-whitespace segment fewer than one token per this many
|
|
6696
|
+
* UTF-16 chars: 6 by default, and up to 4 code points (8 chars when astral) for
|
|
6697
|
+
* its language rules. So text with more non-whitespace chars than
|
|
6698
|
+
* `limit * MAX_CHARS_PER_TOKEN` is over `limit`.
|
|
6699
|
+
*/
|
|
6700
|
+
const MAX_CHARS_PER_TOKEN = 8;
|
|
6701
|
+
const WHITESPACE_RUN_RE = /\s+/g;
|
|
6702
|
+
const STRUCTURED_WHITESPACE_RE = /\n\s/;
|
|
6703
|
+
const WS = 0;
|
|
6704
|
+
const PUNCT = 1;
|
|
6705
|
+
const DIGIT = 2;
|
|
6706
|
+
const WORD = 3;
|
|
6707
|
+
const CHAR_CLASS = (/* @__PURE__ */ new Uint8Array(128)).fill(WORD);
|
|
6708
|
+
for (const c of " \n\r\v\f") CHAR_CLASS[c.charCodeAt(0)] = WS;
|
|
6709
|
+
for (const c of ".,!?;(){}[]<>:/\\|@#$%^&*+=`~_\"-") CHAR_CLASS[c.charCodeAt(0)] = PUNCT;
|
|
6710
|
+
for (let c = 48; c <= 57; c++) CHAR_CLASS[c] = DIGIT;
|
|
6711
|
+
/** Same set as the regex `\s`, which is what tokenx splits words on. */
|
|
6712
|
+
function isWhitespace(code) {
|
|
6713
|
+
return code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
|
|
6714
|
+
}
|
|
6715
|
+
function runTokens(kind, length, onlyDigits) {
|
|
6716
|
+
if (kind === WS) return 0;
|
|
6717
|
+
if (length <= 3) return 1;
|
|
6718
|
+
if (kind === PUNCT) return Math.ceil(length / 2);
|
|
6719
|
+
return onlyDigits ? Math.ceil(length / 3) : Math.ceil(length / 6);
|
|
6720
|
+
}
|
|
6721
|
+
/**
|
|
6722
|
+
* One pass over char codes with no allocations: an approximate token count
|
|
6723
|
+
* (tokenx's rules for ASCII text, used only for the "of ~N tokens" total) and
|
|
6724
|
+
* the number of non-whitespace chars.
|
|
6725
|
+
*/
|
|
6726
|
+
function scanTokens(text) {
|
|
6727
|
+
let approx = 0;
|
|
6728
|
+
let nonWhitespace = 0;
|
|
6729
|
+
let kind = -1;
|
|
6730
|
+
let length = 0;
|
|
6731
|
+
let onlyDigits = true;
|
|
6732
|
+
for (let i = 0; i < text.length; i++) {
|
|
6733
|
+
const code = text.charCodeAt(i);
|
|
6734
|
+
const cls = code < 128 ? CHAR_CLASS[code] : isWhitespace(code) ? WS : WORD;
|
|
6735
|
+
const runKind = cls === DIGIT ? WORD : cls;
|
|
6736
|
+
if (runKind !== kind) {
|
|
6737
|
+
if (length) approx += runTokens(kind, length, onlyDigits);
|
|
6738
|
+
kind = runKind;
|
|
6739
|
+
length = 0;
|
|
6740
|
+
onlyDigits = true;
|
|
6741
|
+
}
|
|
6742
|
+
length++;
|
|
6743
|
+
if (cls !== WS) nonWhitespace++;
|
|
6744
|
+
if (cls !== DIGIT) onlyDigits = false;
|
|
6745
|
+
}
|
|
6746
|
+
if (length) approx += runTokens(kind, length, onlyDigits);
|
|
6747
|
+
return {
|
|
6748
|
+
approx,
|
|
6749
|
+
nonWhitespace
|
|
6750
|
+
};
|
|
6751
|
+
}
|
|
6752
|
+
/**
|
|
6753
|
+
* Exact token count of `output` when it may fit `limit`, else an approximation.
|
|
6754
|
+
* Returns `undefined` when the output fits, so callers return it as is.
|
|
6755
|
+
*/
|
|
6756
|
+
function countTokensOver(output, limit) {
|
|
6757
|
+
if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) {
|
|
6758
|
+
const exact = estimateTokenCount(output);
|
|
6759
|
+
return exact <= limit ? void 0 : exact;
|
|
6760
|
+
}
|
|
6761
|
+
const { approx, nonWhitespace } = scanTokens(output);
|
|
6762
|
+
if (nonWhitespace > limit * MAX_CHARS_PER_TOKEN) return approx;
|
|
6763
|
+
const exact = estimateTokenCount(output.replace(WHITESPACE_RUN_RE, (run) => STRUCTURED_WHITESPACE_RE.test(run) ? "\n " : " "));
|
|
6764
|
+
return exact <= limit ? void 0 : exact;
|
|
6765
|
+
}
|
|
6766
|
+
/**
|
|
6767
|
+
* `budget` tokens from one end of `output`. Outputs within the overall `limit`'s
|
|
6768
|
+
* size cap are cut exactly as before, by `sliceByTokensSafe(output, 0, budget)`
|
|
6769
|
+
* (`'head'`) or `sliceByTokensSafe(output, -budget)` (`'tail'`). Longer ones hand
|
|
6770
|
+
* tokenx only a window at that end, measured as tokenx sees it: whitespace runs
|
|
6771
|
+
* are collapsed (see `countTokensOver`), so padding can't crowd real text out of
|
|
6772
|
+
* the window. The cut is mapped back to the original text, whitespace and all.
|
|
6773
|
+
*
|
|
6774
|
+
* For those longer outputs the cut is approximate: it fits `budget` by tokenx's
|
|
6775
|
+
* count of the kept text, but can land elsewhere than tokenizing the whole output
|
|
6776
|
+
* would. tokenx counts a segment by its whole length, so a window that ends inside
|
|
6777
|
+
* a long segment counts it differently (at a 2,000-token budget, 65,000 'a' then
|
|
6778
|
+
* 'é' keeps 12,000 chars here and 6,000 when the whole output is tokenized).
|
|
6779
|
+
*/
|
|
6780
|
+
function sliceEdge(output, budget, limit, side) {
|
|
6781
|
+
if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) return side === "head" ? sliceByTokensSafe(output, 0, budget) : sliceByTokensSafe(output, -budget);
|
|
6782
|
+
const target = Math.max(budget, 1) * WINDOW_CHARS_PER_TOKEN;
|
|
6783
|
+
let size = 0;
|
|
6784
|
+
let inWhitespace = false;
|
|
6785
|
+
let edge = side === "head" ? 0 : output.length;
|
|
6786
|
+
while (side === "head" ? edge < output.length : edge > 0) {
|
|
6787
|
+
const code = output.charCodeAt(side === "head" ? edge : edge - 1);
|
|
6788
|
+
const whitespace = code < 128 ? CHAR_CLASS[code] === WS : isWhitespace(code);
|
|
6789
|
+
const cost = whitespace ? inWhitespace ? 0 : 2 : 1;
|
|
6790
|
+
if (size + cost > target) break;
|
|
6791
|
+
size += cost;
|
|
6792
|
+
inWhitespace = whitespace;
|
|
6793
|
+
edge += side === "head" ? 1 : -1;
|
|
6794
|
+
}
|
|
6795
|
+
const window = side === "head" ? output.slice(0, edge) : output.slice(edge);
|
|
6796
|
+
const runs = [];
|
|
6797
|
+
let collapsed = "";
|
|
6798
|
+
let last = 0;
|
|
6799
|
+
for (const match of window.matchAll(WHITESPACE_RUN_RE)) {
|
|
6800
|
+
collapsed += window.slice(last, match.index);
|
|
6801
|
+
const replacement = STRUCTURED_WHITESPACE_RE.test(match[0]) ? "\n " : " ";
|
|
6802
|
+
runs.push({
|
|
6803
|
+
collapsedStart: collapsed.length,
|
|
6804
|
+
collapsedEnd: collapsed.length + replacement.length,
|
|
6805
|
+
start: match.index,
|
|
6806
|
+
end: match.index + match[0].length
|
|
6807
|
+
});
|
|
6808
|
+
collapsed += replacement;
|
|
6809
|
+
last = match.index + match[0].length;
|
|
6810
|
+
}
|
|
6811
|
+
collapsed += window.slice(last);
|
|
6812
|
+
const toWindowIndex = (index) => {
|
|
6813
|
+
let shift = 0;
|
|
6814
|
+
for (const run of runs) {
|
|
6815
|
+
if (index < run.collapsedStart) break;
|
|
6816
|
+
if (index <= run.collapsedEnd) return index === run.collapsedEnd ? run.end : run.start;
|
|
6817
|
+
shift = run.end - run.collapsedEnd;
|
|
6818
|
+
}
|
|
6819
|
+
return index + shift;
|
|
6820
|
+
};
|
|
6821
|
+
if (side === "head") return sliceSafe(window, 0, toWindowIndex(fitBudget(sliceByTokensSafe(collapsed, 0, budget), budget, side).length));
|
|
6822
|
+
const kept = fitBudget(sliceByTokensSafe(collapsed, -budget), budget, side);
|
|
6823
|
+
return sliceSafe(window, toWindowIndex(collapsed.length - kept.length));
|
|
6824
|
+
}
|
|
6825
|
+
/**
|
|
6826
|
+
* tokenx slices a segment by the chars-per-token of its language, picked from the
|
|
6827
|
+
* chars it contains, so a cut that drops the char that picked it (a lone 'ж' in a run
|
|
6828
|
+
* of CJK) can count several times over `budget` on its own. Recount the kept text,
|
|
6829
|
+
* which is no longer than the bounded input it was cut from, and cut it again until
|
|
6830
|
+
* it fits.
|
|
6831
|
+
*/
|
|
6832
|
+
function fitBudget(kept, budget, side) {
|
|
6833
|
+
for (let tokens = estimateTokenCount(kept); kept.length > 0 && tokens > budget; tokens = estimateTokenCount(kept)) {
|
|
6834
|
+
const next = side === "head" ? sliceByTokensSafe(kept, 0, budget) : sliceByTokensSafe(kept, -budget);
|
|
6835
|
+
const length = next.length < kept.length ? next.length : Math.floor(kept.length * budget / tokens);
|
|
6836
|
+
kept = side === "head" ? sliceSafe(kept, 0, length) : sliceSafe(kept, kept.length - length);
|
|
6837
|
+
}
|
|
6838
|
+
return kept;
|
|
6839
|
+
}
|
|
6840
|
+
/**
|
|
6688
6841
|
* Token-based output limit. Truncates output to fit within a token budget.
|
|
6689
6842
|
* Uses tokenx for fast token estimation and truncates at the token level
|
|
6690
6843
|
* (not line boundaries) to maximise use of the budget.
|
|
@@ -6697,9 +6850,9 @@ function splitTail(output, tail) {
|
|
|
6697
6850
|
*/
|
|
6698
6851
|
async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from = "start") {
|
|
6699
6852
|
if (!output) return output;
|
|
6700
|
-
const totalTokens =
|
|
6701
|
-
if (totalTokens
|
|
6702
|
-
const kept = from === "start" ?
|
|
6853
|
+
const totalTokens = countTokensOver(output, limit);
|
|
6854
|
+
if (totalTokens === void 0) return output;
|
|
6855
|
+
const kept = from === "start" ? sliceEdge(output, limit, limit, "tail") : sliceEdge(output, limit, limit, "head");
|
|
6703
6856
|
const position = from === "start" ? "last" : "first";
|
|
6704
6857
|
return from === "start" ? `[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]\n${kept}` : `${kept}\n[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]`;
|
|
6705
6858
|
}
|
|
@@ -6709,12 +6862,12 @@ async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from =
|
|
|
6709
6862
|
*/
|
|
6710
6863
|
function sandwich(output, limit, headRatio, firstLine) {
|
|
6711
6864
|
if (!output) return output;
|
|
6712
|
-
const totalTokens =
|
|
6713
|
-
if (totalTokens
|
|
6865
|
+
const totalTokens = countTokensOver(output, limit);
|
|
6866
|
+
if (totalTokens === void 0) return output;
|
|
6714
6867
|
const headBudget = Math.floor(limit * headRatio);
|
|
6715
6868
|
const tailBudget = limit - headBudget;
|
|
6716
|
-
let head = headBudget > 0 ?
|
|
6717
|
-
let tail = tailBudget > 0 ?
|
|
6869
|
+
let head = headBudget > 0 ? sliceEdge(output, headBudget, limit, "head") : "";
|
|
6870
|
+
let tail = tailBudget > 0 ? sliceEdge(output, tailBudget, limit, "tail") : "";
|
|
6718
6871
|
const headEnd = head.length;
|
|
6719
6872
|
let tailStart = output.length - tail.length;
|
|
6720
6873
|
head = head.replace(/\r?\n$/, "");
|
|
@@ -6690,6 +6690,159 @@ function splitTail(output, tail) {
|
|
|
6690
6690
|
};
|
|
6691
6691
|
}
|
|
6692
6692
|
/**
|
|
6693
|
+
* tokenx is synchronous and allocates per word, so running it over a multi-MB
|
|
6694
|
+
* output blocks the event loop for seconds. Outputs up to this many chars per
|
|
6695
|
+
* token of budget are counted and cut exactly as before; longer ones never reach
|
|
6696
|
+
* tokenx whole (see `countTokensOver` and `sliceEdge`).
|
|
6697
|
+
*/
|
|
6698
|
+
const WINDOW_CHARS_PER_TOKEN = 32;
|
|
6699
|
+
/**
|
|
6700
|
+
* tokenx never gives a non-whitespace segment fewer than one token per this many
|
|
6701
|
+
* UTF-16 chars: 6 by default, and up to 4 code points (8 chars when astral) for
|
|
6702
|
+
* its language rules. So text with more non-whitespace chars than
|
|
6703
|
+
* `limit * MAX_CHARS_PER_TOKEN` is over `limit`.
|
|
6704
|
+
*/
|
|
6705
|
+
const MAX_CHARS_PER_TOKEN = 8;
|
|
6706
|
+
const WHITESPACE_RUN_RE = /\s+/g;
|
|
6707
|
+
const STRUCTURED_WHITESPACE_RE = /\n\s/;
|
|
6708
|
+
const WS = 0;
|
|
6709
|
+
const PUNCT = 1;
|
|
6710
|
+
const DIGIT = 2;
|
|
6711
|
+
const WORD = 3;
|
|
6712
|
+
const CHAR_CLASS = (/* @__PURE__ */ new Uint8Array(128)).fill(WORD);
|
|
6713
|
+
for (const c of " \n\r\v\f") CHAR_CLASS[c.charCodeAt(0)] = WS;
|
|
6714
|
+
for (const c of ".,!?;(){}[]<>:/\\|@#$%^&*+=`~_\"-") CHAR_CLASS[c.charCodeAt(0)] = PUNCT;
|
|
6715
|
+
for (let c = 48; c <= 57; c++) CHAR_CLASS[c] = DIGIT;
|
|
6716
|
+
/** Same set as the regex `\s`, which is what tokenx splits words on. */
|
|
6717
|
+
function isWhitespace(code) {
|
|
6718
|
+
return code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
|
|
6719
|
+
}
|
|
6720
|
+
function runTokens(kind, length, onlyDigits) {
|
|
6721
|
+
if (kind === WS) return 0;
|
|
6722
|
+
if (length <= 3) return 1;
|
|
6723
|
+
if (kind === PUNCT) return Math.ceil(length / 2);
|
|
6724
|
+
return onlyDigits ? Math.ceil(length / 3) : Math.ceil(length / 6);
|
|
6725
|
+
}
|
|
6726
|
+
/**
|
|
6727
|
+
* One pass over char codes with no allocations: an approximate token count
|
|
6728
|
+
* (tokenx's rules for ASCII text, used only for the "of ~N tokens" total) and
|
|
6729
|
+
* the number of non-whitespace chars.
|
|
6730
|
+
*/
|
|
6731
|
+
function scanTokens(text) {
|
|
6732
|
+
let approx = 0;
|
|
6733
|
+
let nonWhitespace = 0;
|
|
6734
|
+
let kind = -1;
|
|
6735
|
+
let length = 0;
|
|
6736
|
+
let onlyDigits = true;
|
|
6737
|
+
for (let i = 0; i < text.length; i++) {
|
|
6738
|
+
const code = text.charCodeAt(i);
|
|
6739
|
+
const cls = code < 128 ? CHAR_CLASS[code] : isWhitespace(code) ? WS : WORD;
|
|
6740
|
+
const runKind = cls === DIGIT ? WORD : cls;
|
|
6741
|
+
if (runKind !== kind) {
|
|
6742
|
+
if (length) approx += runTokens(kind, length, onlyDigits);
|
|
6743
|
+
kind = runKind;
|
|
6744
|
+
length = 0;
|
|
6745
|
+
onlyDigits = true;
|
|
6746
|
+
}
|
|
6747
|
+
length++;
|
|
6748
|
+
if (cls !== WS) nonWhitespace++;
|
|
6749
|
+
if (cls !== DIGIT) onlyDigits = false;
|
|
6750
|
+
}
|
|
6751
|
+
if (length) approx += runTokens(kind, length, onlyDigits);
|
|
6752
|
+
return {
|
|
6753
|
+
approx,
|
|
6754
|
+
nonWhitespace
|
|
6755
|
+
};
|
|
6756
|
+
}
|
|
6757
|
+
/**
|
|
6758
|
+
* Exact token count of `output` when it may fit `limit`, else an approximation.
|
|
6759
|
+
* Returns `undefined` when the output fits, so callers return it as is.
|
|
6760
|
+
*/
|
|
6761
|
+
function countTokensOver(output, limit) {
|
|
6762
|
+
if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) {
|
|
6763
|
+
const exact = estimateTokenCount(output);
|
|
6764
|
+
return exact <= limit ? void 0 : exact;
|
|
6765
|
+
}
|
|
6766
|
+
const { approx, nonWhitespace } = scanTokens(output);
|
|
6767
|
+
if (nonWhitespace > limit * MAX_CHARS_PER_TOKEN) return approx;
|
|
6768
|
+
const exact = estimateTokenCount(output.replace(WHITESPACE_RUN_RE, (run) => STRUCTURED_WHITESPACE_RE.test(run) ? "\n " : " "));
|
|
6769
|
+
return exact <= limit ? void 0 : exact;
|
|
6770
|
+
}
|
|
6771
|
+
/**
|
|
6772
|
+
* `budget` tokens from one end of `output`. Outputs within the overall `limit`'s
|
|
6773
|
+
* size cap are cut exactly as before, by `sliceByTokensSafe(output, 0, budget)`
|
|
6774
|
+
* (`'head'`) or `sliceByTokensSafe(output, -budget)` (`'tail'`). Longer ones hand
|
|
6775
|
+
* tokenx only a window at that end, measured as tokenx sees it: whitespace runs
|
|
6776
|
+
* are collapsed (see `countTokensOver`), so padding can't crowd real text out of
|
|
6777
|
+
* the window. The cut is mapped back to the original text, whitespace and all.
|
|
6778
|
+
*
|
|
6779
|
+
* For those longer outputs the cut is approximate: it fits `budget` by tokenx's
|
|
6780
|
+
* count of the kept text, but can land elsewhere than tokenizing the whole output
|
|
6781
|
+
* would. tokenx counts a segment by its whole length, so a window that ends inside
|
|
6782
|
+
* a long segment counts it differently (at a 2,000-token budget, 65,000 'a' then
|
|
6783
|
+
* 'é' keeps 12,000 chars here and 6,000 when the whole output is tokenized).
|
|
6784
|
+
*/
|
|
6785
|
+
function sliceEdge(output, budget, limit, side) {
|
|
6786
|
+
if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) return side === "head" ? sliceByTokensSafe(output, 0, budget) : sliceByTokensSafe(output, -budget);
|
|
6787
|
+
const target = Math.max(budget, 1) * WINDOW_CHARS_PER_TOKEN;
|
|
6788
|
+
let size = 0;
|
|
6789
|
+
let inWhitespace = false;
|
|
6790
|
+
let edge = side === "head" ? 0 : output.length;
|
|
6791
|
+
while (side === "head" ? edge < output.length : edge > 0) {
|
|
6792
|
+
const code = output.charCodeAt(side === "head" ? edge : edge - 1);
|
|
6793
|
+
const whitespace = code < 128 ? CHAR_CLASS[code] === WS : isWhitespace(code);
|
|
6794
|
+
const cost = whitespace ? inWhitespace ? 0 : 2 : 1;
|
|
6795
|
+
if (size + cost > target) break;
|
|
6796
|
+
size += cost;
|
|
6797
|
+
inWhitespace = whitespace;
|
|
6798
|
+
edge += side === "head" ? 1 : -1;
|
|
6799
|
+
}
|
|
6800
|
+
const window = side === "head" ? output.slice(0, edge) : output.slice(edge);
|
|
6801
|
+
const runs = [];
|
|
6802
|
+
let collapsed = "";
|
|
6803
|
+
let last = 0;
|
|
6804
|
+
for (const match of window.matchAll(WHITESPACE_RUN_RE)) {
|
|
6805
|
+
collapsed += window.slice(last, match.index);
|
|
6806
|
+
const replacement = STRUCTURED_WHITESPACE_RE.test(match[0]) ? "\n " : " ";
|
|
6807
|
+
runs.push({
|
|
6808
|
+
collapsedStart: collapsed.length,
|
|
6809
|
+
collapsedEnd: collapsed.length + replacement.length,
|
|
6810
|
+
start: match.index,
|
|
6811
|
+
end: match.index + match[0].length
|
|
6812
|
+
});
|
|
6813
|
+
collapsed += replacement;
|
|
6814
|
+
last = match.index + match[0].length;
|
|
6815
|
+
}
|
|
6816
|
+
collapsed += window.slice(last);
|
|
6817
|
+
const toWindowIndex = (index) => {
|
|
6818
|
+
let shift = 0;
|
|
6819
|
+
for (const run of runs) {
|
|
6820
|
+
if (index < run.collapsedStart) break;
|
|
6821
|
+
if (index <= run.collapsedEnd) return index === run.collapsedEnd ? run.end : run.start;
|
|
6822
|
+
shift = run.end - run.collapsedEnd;
|
|
6823
|
+
}
|
|
6824
|
+
return index + shift;
|
|
6825
|
+
};
|
|
6826
|
+
if (side === "head") return sliceSafe(window, 0, toWindowIndex(fitBudget(sliceByTokensSafe(collapsed, 0, budget), budget, side).length));
|
|
6827
|
+
const kept = fitBudget(sliceByTokensSafe(collapsed, -budget), budget, side);
|
|
6828
|
+
return sliceSafe(window, toWindowIndex(collapsed.length - kept.length));
|
|
6829
|
+
}
|
|
6830
|
+
/**
|
|
6831
|
+
* tokenx slices a segment by the chars-per-token of its language, picked from the
|
|
6832
|
+
* chars it contains, so a cut that drops the char that picked it (a lone 'ж' in a run
|
|
6833
|
+
* of CJK) can count several times over `budget` on its own. Recount the kept text,
|
|
6834
|
+
* which is no longer than the bounded input it was cut from, and cut it again until
|
|
6835
|
+
* it fits.
|
|
6836
|
+
*/
|
|
6837
|
+
function fitBudget(kept, budget, side) {
|
|
6838
|
+
for (let tokens = estimateTokenCount(kept); kept.length > 0 && tokens > budget; tokens = estimateTokenCount(kept)) {
|
|
6839
|
+
const next = side === "head" ? sliceByTokensSafe(kept, 0, budget) : sliceByTokensSafe(kept, -budget);
|
|
6840
|
+
const length = next.length < kept.length ? next.length : Math.floor(kept.length * budget / tokens);
|
|
6841
|
+
kept = side === "head" ? sliceSafe(kept, 0, length) : sliceSafe(kept, kept.length - length);
|
|
6842
|
+
}
|
|
6843
|
+
return kept;
|
|
6844
|
+
}
|
|
6845
|
+
/**
|
|
6693
6846
|
* Token-based output limit. Truncates output to fit within a token budget.
|
|
6694
6847
|
* Uses tokenx for fast token estimation and truncates at the token level
|
|
6695
6848
|
* (not line boundaries) to maximise use of the budget.
|
|
@@ -6702,9 +6855,9 @@ function splitTail(output, tail) {
|
|
|
6702
6855
|
*/
|
|
6703
6856
|
async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from = "start") {
|
|
6704
6857
|
if (!output) return output;
|
|
6705
|
-
const totalTokens =
|
|
6706
|
-
if (totalTokens
|
|
6707
|
-
const kept = from === "start" ?
|
|
6858
|
+
const totalTokens = countTokensOver(output, limit);
|
|
6859
|
+
if (totalTokens === void 0) return output;
|
|
6860
|
+
const kept = from === "start" ? sliceEdge(output, limit, limit, "tail") : sliceEdge(output, limit, limit, "head");
|
|
6708
6861
|
const position = from === "start" ? "last" : "first";
|
|
6709
6862
|
return from === "start" ? `[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]\n${kept}` : `${kept}\n[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]`;
|
|
6710
6863
|
}
|
|
@@ -6714,12 +6867,12 @@ async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from =
|
|
|
6714
6867
|
*/
|
|
6715
6868
|
function sandwich(output, limit, headRatio, firstLine) {
|
|
6716
6869
|
if (!output) return output;
|
|
6717
|
-
const totalTokens =
|
|
6718
|
-
if (totalTokens
|
|
6870
|
+
const totalTokens = countTokensOver(output, limit);
|
|
6871
|
+
if (totalTokens === void 0) return output;
|
|
6719
6872
|
const headBudget = Math.floor(limit * headRatio);
|
|
6720
6873
|
const tailBudget = limit - headBudget;
|
|
6721
|
-
let head = headBudget > 0 ?
|
|
6722
|
-
let tail = tailBudget > 0 ?
|
|
6874
|
+
let head = headBudget > 0 ? sliceEdge(output, headBudget, limit, "head") : "";
|
|
6875
|
+
let tail = tailBudget > 0 ? sliceEdge(output, tailBudget, limit, "tail") : "";
|
|
6723
6876
|
const headEnd = head.length;
|
|
6724
6877
|
let tailStart = output.length - tail.length;
|
|
6725
6878
|
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.8",
|
|
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/
|
|
971
|
+
"@internal/ai-v7": "0.0.98",
|
|
972
972
|
"@internal/ai-v6": "0.0.98",
|
|
973
|
+
"@internal/auth": "0.0.39",
|
|
973
974
|
"@internal/core": "0.1.4",
|
|
974
975
|
"@internal/deployer": "0.0.4",
|
|
975
976
|
"@internal/external-types": "0.0.101",
|
|
976
|
-
"@internal/llm-recorder": "0.0.87",
|
|
977
|
-
"@internal/ai-v7": "0.0.98",
|
|
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"
|