@mastra/core 1.87.0-alpha.0 → 1.87.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/@ai-sdk_anthropic@3.0.137/dist/index.d.ts +2 -2
- package/dist/_types/@ai-sdk_google@3.0.140/dist/index.d.ts +2 -2
- package/dist/_types/@ai-sdk_openai@3.0.135/dist/index.d.ts +2 -2
- package/dist/_types/@ai-sdk_openai@4.0.106/dist/index.d.ts +2034 -0
- package/dist/_types/@ai-sdk_openai@4.0.106/package.json +1 -0
- package/dist/a2a/index.cjs +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/agent/agent.d.ts +3 -1
- package/dist/agent/durable/index.cjs +2 -1
- package/dist/agent/durable/index.d.ts +1 -0
- package/dist/agent/durable/index.js +2 -2
- package/dist/agent/durable/run-message-refs.d.ts +3 -2
- package/dist/agent/durable/run-registry.d.ts +12 -1
- package/dist/agent/durable/types.d.ts +2 -0
- package/dist/agent/durable/workflows/finalize-run.d.ts +2 -1
- package/dist/agent/index.cjs +5 -4
- package/dist/agent/index.d.ts +2 -0
- package/dist/agent/index.js +5 -5
- package/dist/agent/merge-persona.d.ts +15 -0
- package/dist/agent/message-list/adapters/AIV5Adapter.d.ts +15 -1
- package/dist/agent/message-list/index.cjs +2 -2
- package/dist/agent/message-list/index.js +2 -2
- package/dist/agent/message-list/state/types.d.ts +5 -1
- package/dist/agent/message-list/types.d.ts +1 -1
- package/dist/agent/message-list/utils/provider-compat.d.ts +9 -1
- package/dist/agent/thread-stream-runtime.d.ts +3 -1
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/agent-controller.d.ts +6 -0
- package/dist/agent-controller/index.cjs +2 -2
- package/dist/agent-controller/index.js +2 -2
- package/dist/agent-controller/worker-run-binding.d.ts +15 -0
- package/dist/{agent-controller-B8LoFdtu.js → agent-controller--gKWI81G.js} +50 -8
- package/dist/{agent-controller-DSnFynpa.cjs → agent-controller-BolLBwDm.cjs} +50 -8
- package/dist/background-tasks/index.cjs +2 -1
- package/dist/background-tasks/index.d.ts +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/background-tasks/resolve-config.d.ts +30 -1
- package/dist/background-tasks/system-prompt.d.ts +8 -2
- package/dist/background-tasks/types.d.ts +47 -1
- package/dist/{background-tasks-IW7M4iD2.js → background-tasks-CgzXjBfE.js} +156 -33
- package/dist/{background-tasks-Ci5h0dhj.cjs → background-tasks-DYtlijQ1.cjs} +167 -32
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-14Uptu8y.cjs → builder-Dz-g-9CZ.cjs} +2 -2
- package/dist/{builder-DI2c2xjy.js → builder-emNPaIaC.js} +2 -2
- package/dist/capabilities/302ai.json +202 -202
- package/dist/capabilities/abliteratedllm.json +36 -27
- package/dist/capabilities/abliteration-ai.json +12 -12
- package/dist/capabilities/above.json +14 -14
- package/dist/capabilities/adaption.json +9 -9
- package/dist/capabilities/adzuki.json +26 -26
- package/dist/capabilities/agentrouter.json +4 -4
- package/dist/capabilities/agnes.json +2 -2
- package/dist/capabilities/ai-router.json +5 -5
- package/dist/capabilities/aiand.json +11 -11
- package/dist/capabilities/aigrow.json +14 -14
- package/dist/capabilities/aimlapi.json +154 -158
- package/dist/capabilities/aixy.json +21 -21
- package/dist/capabilities/aki-io.json +14 -14
- package/dist/capabilities/alibaba-cn.json +107 -101
- package/dist/capabilities/alibaba-coding-plan-cn.json +3 -3
- package/dist/capabilities/alibaba-coding-plan.json +3 -3
- package/dist/capabilities/alibaba-token-plan-cn.json +53 -53
- package/dist/capabilities/alibaba-token-plan.json +53 -53
- package/dist/capabilities/alibaba.json +99 -65
- package/dist/capabilities/ambient.json +14 -7
- package/dist/capabilities/amd.json +8 -8
- package/dist/capabilities/anthropic.json +47 -47
- package/dist/capabilities/anyapi.json +19 -19
- package/dist/capabilities/apiko.json +2 -2
- package/dist/capabilities/arcee.json +4 -4
- package/dist/capabilities/augure.json +5 -5
- package/dist/capabilities/auriko.json +22 -22
- package/dist/capabilities/bailing.json +3 -3
- package/dist/capabilities/baseten.json +25 -25
- package/dist/capabilities/bee.json +5 -5
- package/dist/capabilities/berget.json +14 -1
- package/dist/capabilities/bothub.json +17 -17
- package/dist/capabilities/boundless.json +31 -31
- package/dist/capabilities/bumo.json +40 -40
- package/dist/capabilities/byteplus.json +29 -29
- package/dist/capabilities/cheapaimodel.json +9 -9
- package/dist/capabilities/cheapest-token.json +30 -30
- package/dist/capabilities/chutes.json +9 -9
- package/dist/capabilities/claudinio.json +10 -1
- package/dist/capabilities/cline-pass.json +40 -40
- package/dist/capabilities/cloudcode.json +8 -15
- package/dist/capabilities/cloudflare-workers-ai.json +8 -8
- package/dist/capabilities/commandcode.json +145 -145
- package/dist/capabilities/concentrate.json +272 -289
- package/dist/capabilities/cortecs.json +110 -110
- package/dist/capabilities/crossmodel.json +182 -182
- package/dist/capabilities/crusoe.json +37 -8
- package/dist/capabilities/daoxe.json +8 -8
- package/dist/capabilities/databricks.json +130 -130
- package/dist/capabilities/deepinfra.json +92 -83
- package/dist/capabilities/digitalocean.json +112 -112
- package/dist/capabilities/dothoosh.json +31 -31
- package/dist/capabilities/doubleword.json +22 -22
- package/dist/capabilities/edenai.json +898 -1743
- package/dist/capabilities/empiriolabs.json +168 -168
- package/dist/capabilities/engy.json +19 -19
- package/dist/capabilities/entrim.json +2 -2
- package/dist/capabilities/evroc.json +12 -12
- package/dist/capabilities/ezkielyna.json +11 -11
- package/dist/capabilities/fastrouter.json +82 -82
- package/dist/capabilities/fireworks-ai.json +125 -64
- package/dist/capabilities/fortytwo.json +9 -3
- package/dist/capabilities/freemodel.json +19 -19
- package/dist/capabilities/friendli.json +8 -8
- package/dist/capabilities/frogbot.json +100 -100
- package/dist/capabilities/gisoo.json +20 -20
- package/dist/capabilities/gmicloud.json +23 -23
- package/dist/capabilities/google.json +50 -50
- package/dist/capabilities/graphn.json +13 -13
- package/dist/capabilities/greenpt.json +35 -35
- package/dist/capabilities/groq.json +3 -3
- package/dist/capabilities/helicone.json +84 -84
- package/dist/capabilities/hetzner.json +35 -3
- package/dist/capabilities/hostinger-router.json +15 -15
- package/dist/capabilities/hpc-ai.json +12 -12
- package/dist/capabilities/huawei-maas.json +14 -14
- package/dist/capabilities/hubris.json +33 -33
- package/dist/capabilities/huggingface.json +108 -158
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +20 -28
- package/dist/capabilities/impossibl.json +152 -152
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +6 -6
- package/dist/capabilities/inco.json +5 -5
- package/dist/capabilities/infer.json +20 -20
- package/dist/capabilities/inferall.json +10 -10
- package/dist/capabilities/inference-coop.json +15 -15
- package/dist/capabilities/inferenceapis.json +11 -11
- package/dist/capabilities/inferris.json +3 -3
- package/dist/capabilities/infersia.json +11 -11
- package/dist/capabilities/infomaniak.json +2 -2
- package/dist/capabilities/iteracompute.json +48 -48
- package/dist/capabilities/jad-ai.json +2 -2
- package/dist/capabilities/jalapeno.json +12 -12
- package/dist/capabilities/jiekou.json +58 -58
- package/dist/capabilities/jzstoken.json +53 -54
- package/dist/capabilities/keln.json +13 -13
- package/dist/capabilities/kenari.json +119 -127
- package/dist/capabilities/kilo.json +643 -647
- package/dist/capabilities/kimi-code-plan-cn.json +6 -6
- package/dist/capabilities/kimi-code-plan-global.json +6 -6
- package/dist/capabilities/kitani.json +6 -6
- package/dist/capabilities/klavo.json +14 -14
- package/dist/capabilities/korouter.json +34 -34
- package/dist/capabilities/kunavo.json +7 -7
- package/dist/capabilities/liquid.json +11 -11
- package/dist/capabilities/lithosai.json +3 -3
- package/dist/capabilities/llmgateway-providers.json +949 -880
- package/dist/capabilities/llmgateway.json +344 -343
- package/dist/capabilities/llmtr.json +29 -29
- package/dist/capabilities/longcat.json +2 -2
- package/dist/capabilities/lowrouter.json +53 -53
- package/dist/capabilities/lyceum.json +17 -9
- package/dist/capabilities/melious.json +14 -14
- package/dist/capabilities/merge-gateway.json +303 -301
- package/dist/capabilities/meta.json +9 -9
- package/dist/capabilities/mistral.json +20 -20
- package/dist/capabilities/mixlayer.json +2 -2
- package/dist/capabilities/modal.json +10 -10
- package/dist/capabilities/model-oracle-ai.json +23 -23
- package/dist/capabilities/modelis.json +22 -22
- package/dist/capabilities/modular.json +31 -9
- package/dist/capabilities/moneo.json +13 -13
- package/dist/capabilities/moonshotai-cn.json +6 -6
- package/dist/capabilities/moonshotai.json +6 -6
- package/dist/capabilities/morph.json +15 -15
- package/dist/capabilities/munito.json +2 -2
- package/dist/capabilities/nan.json +24 -24
- package/dist/capabilities/nano-gpt.json +595 -580
- package/dist/capabilities/nearai.json +101 -101
- package/dist/capabilities/nebius.json +26 -26
- package/dist/capabilities/neon.json +125 -125
- package/dist/capabilities/neuralwatt.json +43 -43
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +123 -123
- package/dist/capabilities/nvidia.json +39 -22
- package/dist/capabilities/oathbreaker.json +26 -3
- package/dist/capabilities/obscurify.json +22 -22
- package/dist/capabilities/oci.json +5 -5
- package/dist/capabilities/ofox.json +327 -327
- package/dist/capabilities/ollama-cloud.json +58 -58
- package/dist/capabilities/openai.json +57 -57
- package/dist/capabilities/opencode-go.json +90 -90
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +561 -557
- package/dist/capabilities/opper.json +30 -30
- package/dist/capabilities/orcarouter.json +238 -238
- package/dist/capabilities/outerlabs.json +29 -29
- package/dist/capabilities/ovhcloud.json +20 -20
- package/dist/capabilities/pareto.json +4 -4
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +63 -63
- package/dist/capabilities/phala.json +22 -22
- package/dist/capabilities/pioneer.json +26 -26
- package/dist/capabilities/poe.json +134 -134
- package/dist/capabilities/poolside.json +3 -3
- package/dist/capabilities/powerspring.json +8 -8
- package/dist/capabilities/primalabs.json +8 -8
- package/dist/capabilities/prime.json +133 -123
- package/dist/capabilities/privatemode-ai.json +13 -13
- package/dist/capabilities/proxystacks.json +6 -6
- package/dist/capabilities/qiniu-ai.json +15 -15
- package/dist/capabilities/refuseless.json +6 -6
- package/dist/capabilities/regolo-ai.json +9 -9
- package/dist/capabilities/requesty.json +386 -171
- package/dist/capabilities/ruapi.json +29 -13
- package/dist/capabilities/runcrate.json +8 -8
- package/dist/capabilities/runinfra.json +9 -9
- package/dist/capabilities/sakana.json +3 -3
- package/dist/capabilities/sambanova.json +5 -5
- package/dist/capabilities/sandbase.json +17 -17
- package/dist/capabilities/sarvam.json +14 -14
- package/dist/capabilities/scaleway.json +13 -13
- package/dist/capabilities/scnet-token-plan.json +12 -12
- package/dist/capabilities/scx-ai.json +22 -22
- package/dist/capabilities/sensenova.json +10 -10
- package/dist/capabilities/siliconflow-cn.json +49 -49
- package/dist/capabilities/siliconflow.json +54 -54
- package/dist/capabilities/snowflake-cortex.json +17 -17
- package/dist/capabilities/sokkan.json +5 -5
- package/dist/capabilities/sparrowcodes.json +23 -23
- package/dist/capabilities/standardcompute.json +94 -94
- package/dist/capabilities/steadyrouter.json +40 -40
- package/dist/capabilities/stepfun-ai-step-plan.json +5 -5
- package/dist/capabilities/stepfun-ai.json +5 -5
- package/dist/capabilities/stepfun-step-plan.json +5 -5
- package/dist/capabilities/stepfun.json +5 -5
- package/dist/capabilities/stepping-stone.json +9 -9
- package/dist/capabilities/subconscious.json +2 -2
- package/dist/capabilities/synthetic.json +10 -10
- package/dist/capabilities/synthorai.json +22 -22
- package/dist/capabilities/teamorouter.json +23 -23
- package/dist/capabilities/teapot-router.json +12 -12
- package/dist/capabilities/tencent-token-plan-intl.json +126 -0
- package/dist/capabilities/tencent-token-plan.json +35 -35
- package/dist/capabilities/tencent-tokenhub.json +51 -36
- package/dist/capabilities/tensorx.json +44 -44
- package/dist/capabilities/tenstorrent.json +6 -6
- package/dist/capabilities/the-grid-ai.json +32 -32
- package/dist/capabilities/thinkingmachines.json +48 -48
- package/dist/capabilities/tinfoil.json +11 -11
- package/dist/capabilities/toapis.json +2 -2
- package/dist/capabilities/togetherai.json +40 -40
- package/dist/capabilities/tokengo.json +25 -25
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/tokenwatt.json +10 -2
- package/dist/capabilities/trustedrouter.json +6 -6
- package/dist/capabilities/trustedtokens.json +13 -13
- package/dist/capabilities/umans-ai-coding-plan.json +14 -14
- package/dist/capabilities/umans-ai.json +12 -12
- package/dist/capabilities/uncensuredai.json +2 -2
- package/dist/capabilities/unrestricted.json +8 -8
- package/dist/capabilities/uplinkswitch.json +18 -18
- package/dist/capabilities/upstage.json +6 -6
- package/dist/capabilities/vancine.json +18 -18
- package/dist/capabilities/vercel.json +590 -587
- package/dist/capabilities/vivgrid.json +87 -78
- package/dist/capabilities/volcengine-coding-plan.json +32 -23
- package/dist/capabilities/volcengine.json +31 -30
- package/dist/capabilities/vultr.json +26 -26
- package/dist/capabilities/wafer.ai.json +18 -18
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +10 -10
- package/dist/capabilities/wandb.json +10 -10
- package/dist/capabilities/watt.json +26 -26
- package/dist/capabilities/xai.json +4 -4
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
- package/dist/capabilities/xiaomi.json +2 -2
- package/dist/capabilities/xpersona.json +13 -13
- package/dist/capabilities/xxapi.json +28 -28
- package/dist/capabilities/zai-coding-plan.json +18 -18
- package/dist/capabilities/zai.json +30 -30
- package/dist/capabilities/zenifra.json +30 -30
- package/dist/capabilities/zenmux.json +205 -205
- package/dist/capabilities/zerogpu.json +11 -11
- package/dist/capabilities/zhipuai-coding-plan.json +2 -2
- package/dist/capabilities/zhipuai.json +30 -30
- package/dist/capabilities/zro.json +4 -4
- package/dist/channels/agent-channels.d.ts +29 -0
- package/dist/channels/attach-file-tool.d.ts +22 -0
- package/dist/channels/index.cjs +11 -2
- package/dist/channels/index.d.ts +10 -0
- package/dist/channels/index.js +3 -3
- package/dist/channels/output-processor.d.ts +12 -0
- package/dist/channels/reply-guidance-processor.d.ts +26 -0
- package/dist/channels/reply-mode.d.ts +66 -0
- package/dist/channels/reply-reminder-processor.d.ts +23 -0
- package/dist/channels/reply-tool.d.ts +43 -0
- package/dist/channels/state-adapter.d.ts +3 -1
- package/dist/channels/stream-helpers.d.ts +17 -0
- package/dist/channels/thread-link-processor.d.ts +48 -0
- package/dist/channels/thread-lookup.d.ts +16 -0
- package/dist/channels/tool-announcement-processor.d.ts +29 -0
- package/dist/channels/types.d.ts +25 -0
- package/dist/{channels-tVV_de9Q.cjs → channels-BVnDIsZS.cjs} +122 -1
- package/dist/{channels-Wh32drgu.js → channels-CndspFXP.js} +99 -2
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/{constants-B9ZDvXZ4.cjs → constants-Bou0hEgY.cjs} +4 -0
- package/dist/{constants-BmdTvEYN.js → constants-CFWgIaqA.js} +4 -0
- package/dist/datasets/experiment/index.d.ts +1 -1
- package/dist/datasets/experiment/item.d.ts +4 -3
- package/dist/datasets/experiment/scorer.d.ts +45 -11
- package/dist/datasets/index.cjs +3 -2
- package/dist/datasets/index.js +3 -3
- package/dist/{dist-ByO0vuJJ-BjMue5_p.cjs → dist-CufwpBZM-CwERFaas.cjs} +4 -4
- package/dist/{dist-ByO0vuJJ-CCXLBnvJ.js → dist-CufwpBZM-DK14Qe0Z.js} +4 -4
- package/dist/docs/SKILL.md +3 -1
- package/dist/docs/assets/SOURCE_MAP.json +1070 -1055
- package/dist/docs/references/docs-agents-code-mode.md +36 -0
- package/dist/docs/references/docs-agents-networks.md +1 -1
- package/dist/docs/references/docs-agents-tools.md +6 -0
- package/dist/docs/references/docs-auth-simple-auth.md +8 -8
- package/dist/docs/references/docs-browser.md +3 -1
- package/dist/docs/references/docs-channels.md +43 -0
- package/dist/docs/references/docs-evals-custom-scorers.md +1 -1
- package/dist/docs/references/docs-evals-experiments.md +13 -3
- package/dist/docs/references/docs-harness-background-tasks.md +38 -0
- package/dist/docs/references/docs-knowledge-agents-and-tools.md +2 -0
- package/dist/docs/references/docs-mastra-platform-observability-overview.md +3 -189
- package/dist/docs/references/docs-memory-message-history.md +25 -0
- package/dist/docs/references/docs-sandbox-lsp.md +5 -6
- package/dist/docs/references/docs-sandbox-overview.md +20 -0
- package/dist/docs/references/docs-sandbox-skills.md +2 -0
- package/dist/docs/references/docs-signals-sending-signals.md +1 -1
- package/dist/docs/references/integrations.md +1 -0
- package/dist/docs/references/reference-agent-controller-session.md +1 -1
- package/dist/docs/references/reference-agents-durable-agent.md +2 -0
- package/dist/docs/references/reference-agents-generate.md +1 -1
- package/dist/docs/references/reference-agents-network.md +1 -1
- package/dist/docs/references/reference-channels-thread-link.md +67 -0
- package/dist/docs/references/reference-configuration.md +8 -8
- package/dist/docs/references/reference-core-getWorkspaceById.md +37 -0
- package/dist/docs/references/reference-evals-create-scorer.md +5 -5
- package/dist/docs/references/reference-evals-run-evals.md +1 -1
- package/dist/docs/references/reference-knowledge-knowledge-tools.md +3 -3
- package/dist/docs/references/reference-manual-install.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +8 -0
- package/dist/docs/references/reference-observability-tracing-interfaces.md +10 -6
- package/dist/docs/references/reference-processors-processor-interface.md +3 -2
- package/dist/docs/references/reference-processors-system-prompt-scrubber.md +1 -1
- package/dist/docs/references/reference-processors-tool-search-processor.md +3 -3
- package/dist/docs/references/reference-pubsub-base.md +5 -3
- package/dist/docs/references/reference-pubsub-caching-pubsub.md +3 -1
- package/dist/docs/references/reference-storage-overview.md +1 -1
- package/dist/docs/references/reference-storage-retention.md +20 -20
- package/dist/docs/references/reference-tools-create-code-mode.md +22 -0
- package/dist/docs/references/reference-tools-vector-query-tool.md +8 -0
- package/dist/docs/references/reference-voice-overview.md +11 -26
- package/dist/docs/references/reference-voice-speech-to-speech.md +1 -1
- package/dist/docs/references/reference-voice-voice.listen.md +1 -0
- package/dist/docs/references/reference-voice-voice.speak.md +1 -3
- package/dist/docs/references/reference-workspace-factory-sandbox.md +8 -7
- package/dist/docs/references/reference-workspace-sandbox.md +14 -0
- package/dist/docs/references/reference.md +2 -0
- package/dist/evals/index.cjs +2 -2
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +2 -2
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/harness/index.cjs +2 -2
- package/dist/harness/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/agent-scopes.d.ts +17 -0
- package/dist/knowledge/declarations.d.ts +2 -0
- package/dist/knowledge/held-scopes-state-processor.d.ts +50 -0
- package/dist/knowledge/importers/host.d.ts +7 -1
- package/dist/knowledge/importers/runner.d.ts +12 -0
- package/dist/knowledge/importers/types.d.ts +4 -0
- package/dist/knowledge/index.cjs +209 -38
- package/dist/knowledge/index.d.ts +12 -2
- package/dist/knowledge/index.js +208 -39
- package/dist/knowledge/page-tools.d.ts +23 -0
- package/dist/knowledge/pinned-state-processor.d.ts +2 -2
- package/dist/knowledge/run.d.ts +5 -0
- package/dist/knowledge/scope-runtime.d.ts +6 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/base.types.d.ts +3 -1
- package/dist/llm/model/mastra-gateway-provider-tools.d.ts +9 -6
- package/dist/llm/model/model.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.types.d.ts +3 -1
- package/dist/llm/model/provider-options.d.ts +4 -3
- package/dist/llm/model/provider-types.generated.d.ts +7091 -7163
- package/dist/{llm-BAiOsNAP.cjs → llm-B1semiTO.cjs} +38 -78
- package/dist/{llm-B1zaFLYZ.js → llm-CytL7cpw.js} +38 -78
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-BVX9nVrM.cjs → manager-BwyfS4ha.cjs} +220 -93
- package/dist/{manager-ChK9GdGz.js → manager-DnTzA9GL.js} +215 -94
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-CUGfgEpZ.js → mastra-DTkZPpch.js} +17 -17
- package/dist/{mastra-HSmofHEJ.cjs → mastra-Dj35Lj_J.cjs} +17 -17
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/{message-list-KRbg-TnI.js → message-list-BGm1DCiG.js} +231 -130
- package/dist/{message-list-Cj0Sq_JP.cjs → message-list-vR3uLAHL.cjs} +351 -250
- package/dist/{model-C47BJRtR.js → model-DyQ07rPH.js} +4 -3
- package/dist/{model-WahorgzJ.cjs → model-eDfetuno.cjs} +4 -3
- package/dist/{netlify-D99AnEhW.cjs → netlify-BC4v7Ufv.cjs} +41377 -30474
- package/dist/{netlify-CfDXkuLf.js → netlify-BUvdxfHe.js} +41373 -30476
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +1 -1
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/processors/processors/tool-search.d.ts +2 -2
- package/dist/processors/runner.d.ts +12 -0
- package/dist/{provider-registry-CO1NVbO5.cjs → provider-registry-Bn01gq9y.cjs} +22180 -22242
- package/dist/{provider-registry-CR385GJ4.js → provider-registry-CP_5SNiw.js} +22181 -22243
- package/dist/provider-registry.json +22417 -22539
- package/dist/{registry-generator-B3erRqYS.js → registry-generator-CDPyxbzt.js} +1 -1
- package/dist/{registry-generator-Cvp34qcB.cjs → registry-generator-CNFKGRFQ.cjs} +1 -1
- package/dist/{rehydrate-CJBLrZxs.js → rehydrate-CnGNY2zq.js} +2 -2
- package/dist/{rehydrate-Da4hNuaK.cjs → rehydrate-DExpzlNS.cjs} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-DdeEBsVW.js → run-registry-BL_kKvFE.js} +1559 -298
- package/dist/{run-registry-TOOfO3hT.cjs → run-registry-CibQoN6K.cjs} +1637 -298
- package/dist/storage/constants.cjs +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +16 -1
- package/dist/storage/domains/knowledge/importers-inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/importers.d.ts +8 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +5 -1
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +3 -3
- package/dist/storage/types.d.ts +8 -0
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-C5PagEDs.js → stream-1DGoEkG2.js} +37 -14
- package/dist/{stream-DH7Qgz8l.cjs → stream-D_7tMaJe.cjs} +37 -14
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/{to-prompt-B9eZo2U5.cjs → to-prompt-CG-LyaBY.cjs} +9 -0
- package/dist/{to-prompt-BsDtVXrf.js → to-prompt-CMlVGYxC.js} +9 -0
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-DVYJXlQJ.js → tool-loop-agent-BXya_RYj.js} +4 -4
- package/dist/{tool-loop-agent-CJTs4T8b.cjs → tool-loop-agent-CLB1r3X3.cjs} +4 -4
- package/dist/tools/code-mode/index.d.ts +2 -0
- package/dist/tools/code-mode/log-collector.d.ts +49 -0
- package/dist/tools/code-mode/types.d.ts +71 -0
- package/dist/tools/index.cjs +3 -1
- package/dist/tools/index.js +2 -2
- package/dist/{tools-CGF5Ik6j.cjs → tools-BEYxowf0.cjs} +429 -61
- package/dist/{tools-CDfyMpzN.js → tools-tPy2FwMI.js} +418 -62
- package/dist/{utils-xJi_N6Tx.cjs → utils-B-KOMA_Q.cjs} +7 -6
- package/dist/{utils-D8upuTwy.js → utils-C55ZdVaj.js} +7 -6
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-DTkW3Vlp.js → validate-BDfYr72F.js} +1 -1
- package/dist/{validate-6eZ8Wssn.cjs → validate-CmZhnsmX.cjs} +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +2 -2
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/worker/workers/orchestration-worker.d.ts +1 -0
- package/dist/{worker-DbcFkKJO.js → worker-BG1rw_dg.js} +5 -5
- package/dist/{worker-24ORi-wV.cjs → worker-BoybIUTI.cjs} +10 -4
- package/dist/{worker-Dqubrnf8.js → worker-CuK2RaC0.js} +2 -2
- package/dist/{worker-BO3u_WjZ.cjs → worker-D2B-x7Le.cjs} +2 -2
- package/dist/{workflow-wXOf72fO.js → workflow-Bt09PcH1.js} +3 -3
- package/dist/{workflow-D5Fc5ieC.cjs → workflow-CTKqeRXU.cjs} +3 -3
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workflows/step.d.ts +2 -0
- package/dist/workflows/workflow.d.ts +2 -0
- package/dist/workspace/index.cjs +3 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +2 -2
- package/dist/workspace/lsp/manager.d.ts +19 -4
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +17 -0
- package/dist/workspace/sandbox/teardown-context.d.ts +74 -0
- package/dist/workspace/tools/index.d.ts +1 -0
- package/dist/workspace/tools/media.d.ts +20 -1
- package/dist/workspace/tools/recreate-sandbox.d.ts +24 -0
- package/dist/{workspace-X2RHJZU9.cjs → workspace-C8Zo5_qK.cjs} +387 -109
- package/dist/{workspace-DY2Nxiyi.js → workspace-DOAil8mG.js} +376 -110
- package/package.json +8 -8
- package/src/llm/model/provider-types.generated.d.ts +7091 -7163
- /package/dist/_types/{@ai-sdk_provider-utils@4.0.66 → @ai-sdk_provider-utils@4.0.67}/dist/index.d.ts +0 -0
- /package/dist/_types/{@ai-sdk_provider-utils@4.0.66 → @ai-sdk_provider-utils@4.0.67}/package.json +0 -0
|
@@ -4,9 +4,9 @@ const require_payload_transform = require("./payload-transform-CWgnsO9w.cjs");
|
|
|
4
4
|
const require_utils_safe_stringify = require("./utils/safe-stringify.cjs");
|
|
5
5
|
const require_signals = require("./signals-CWxAMEmE.cjs");
|
|
6
6
|
const require_data_content = require("./data-content-CtK4VoHI.cjs");
|
|
7
|
-
const require_to_prompt = require("./to-prompt-
|
|
7
|
+
const require_to_prompt = require("./to-prompt-CG-LyaBY.cjs");
|
|
8
8
|
const require_dist = require("./dist-P2rjrlmj.cjs");
|
|
9
|
-
const
|
|
9
|
+
const require_dist_CufwpBZM = require("./dist-CufwpBZM-CwERFaas.cjs");
|
|
10
10
|
const require_dist$1 = require("./dist-CXeCeeW7.cjs");
|
|
11
11
|
const require_deep_equal = require("./deep-equal-TMDmByBC.cjs");
|
|
12
12
|
const require_file = require("./file-BEndQUN1.cjs");
|
|
@@ -444,7 +444,10 @@ function getResponseProviderItemKeys(providerMetadata) {
|
|
|
444
444
|
}
|
|
445
445
|
// src/agent/message-list/utils/provider-compat.ts
|
|
446
446
|
/**
|
|
447
|
-
* Removes provider-
|
|
447
|
+
* Removes provider-owned parts that the target provider cannot consume.
|
|
448
|
+
*
|
|
449
|
+
* Provider-executed tool payloads are removed when a different provider produced them.
|
|
450
|
+
* OpenAI Responses compaction state is removed unless the target supports that input shape.
|
|
448
451
|
*
|
|
449
452
|
* A provider-executed tool result is the provider's own payload, in the provider's
|
|
450
453
|
* own shape, and each provider validates it against its own schema on the way back
|
|
@@ -493,9 +496,10 @@ function dropCrossProviderExecutedParts(messages, dbMessages, targetProvider, lo
|
|
|
493
496
|
});
|
|
494
497
|
}
|
|
495
498
|
}
|
|
496
|
-
|
|
499
|
+
const targetSupportsOpenAICompaction = targetProvider === "openai" || targetProvider === "openai.responses";
|
|
497
500
|
const isForeign = (part) => {
|
|
498
501
|
const candidate = part;
|
|
502
|
+
if (candidate.type === "custom" && candidate.kind === "openai.compaction") return !targetSupportsOpenAICompaction;
|
|
499
503
|
return (candidate.type === "tool-call" || candidate.type === "tool-result") && typeof candidate.toolCallId === "string" && foreign.has(candidate.toolCallId);
|
|
500
504
|
};
|
|
501
505
|
const warned = /* @__PURE__ */ new Set();
|
|
@@ -513,7 +517,8 @@ function dropCrossProviderExecutedParts(messages, dbMessages, targetProvider, lo
|
|
|
513
517
|
...message,
|
|
514
518
|
content: message.content.filter((part) => {
|
|
515
519
|
if (!isForeign(part)) return true;
|
|
516
|
-
|
|
520
|
+
const toolCallId = part.toolCallId;
|
|
521
|
+
if (typeof toolCallId === "string" && foreign.has(toolCallId)) warnOnce(toolCallId);
|
|
517
522
|
return false;
|
|
518
523
|
})
|
|
519
524
|
};
|
|
@@ -521,6 +526,41 @@ function dropCrossProviderExecutedParts(messages, dbMessages, targetProvider, lo
|
|
|
521
526
|
return dropped ? result : messages;
|
|
522
527
|
}
|
|
523
528
|
/**
|
|
529
|
+
* Builds the efficient OpenAI Responses continuation input from the latest
|
|
530
|
+
* compaction checkpoint while leaving the persisted Mastra history untouched.
|
|
531
|
+
*/
|
|
532
|
+
function pruneOpenAICompactionHistory(messages, targetProvider) {
|
|
533
|
+
if (targetProvider !== "openai" && targetProvider !== "openai.responses") return messages;
|
|
534
|
+
let checkpointMessageIndex = -1;
|
|
535
|
+
let checkpointPartIndex = -1;
|
|
536
|
+
for (let messageIndex = messages.length - 1; messageIndex >= 0; messageIndex--) {
|
|
537
|
+
const message = messages[messageIndex];
|
|
538
|
+
if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
539
|
+
for (let partIndex = message.content.length - 1; partIndex >= 0; partIndex--) {
|
|
540
|
+
const part = message.content[partIndex];
|
|
541
|
+
if (part.type === "custom" && part.kind === "openai.compaction") {
|
|
542
|
+
checkpointMessageIndex = messageIndex;
|
|
543
|
+
checkpointPartIndex = partIndex;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (checkpointMessageIndex !== -1) break;
|
|
548
|
+
}
|
|
549
|
+
if (checkpointMessageIndex === -1) return messages;
|
|
550
|
+
const checkpointMessage = messages[checkpointMessageIndex];
|
|
551
|
+
const checkpointContent = Array.isArray(checkpointMessage.content) ? checkpointMessage.content.slice(checkpointPartIndex) : checkpointMessage.content;
|
|
552
|
+
const systemMessagesBeforeCheckpoint = messages.slice(0, checkpointMessageIndex).filter((message) => message.role === "system");
|
|
553
|
+
const continuationMessages = messages.slice(checkpointMessageIndex + 1);
|
|
554
|
+
return [
|
|
555
|
+
...systemMessagesBeforeCheckpoint,
|
|
556
|
+
{
|
|
557
|
+
...checkpointMessage,
|
|
558
|
+
content: checkpointContent
|
|
559
|
+
},
|
|
560
|
+
...continuationMessages
|
|
561
|
+
];
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
524
564
|
* Ensures model messages are compatible with Anthropic API requirements.
|
|
525
565
|
*
|
|
526
566
|
* Anthropic API requires tool-result parts to include an 'input' field
|
|
@@ -1982,7 +2022,7 @@ var name = "AI_InvalidArgumentError";
|
|
|
1982
2022
|
var marker = `vercel.ai.error.${name}`;
|
|
1983
2023
|
var symbol = Symbol.for(marker);
|
|
1984
2024
|
var _a;
|
|
1985
|
-
var InvalidArgumentError = class extends
|
|
2025
|
+
var InvalidArgumentError = class extends require_dist_CufwpBZM.AISDKError {
|
|
1986
2026
|
constructor({ parameter, value, message }) {
|
|
1987
2027
|
super({
|
|
1988
2028
|
name,
|
|
@@ -1993,7 +2033,7 @@ var InvalidArgumentError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
1993
2033
|
this.value = value;
|
|
1994
2034
|
}
|
|
1995
2035
|
static isInstance(error) {
|
|
1996
|
-
return
|
|
2036
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker);
|
|
1997
2037
|
}
|
|
1998
2038
|
};
|
|
1999
2039
|
_a = symbol;
|
|
@@ -2001,7 +2041,7 @@ var name3 = "AI_InvalidToolApprovalError";
|
|
|
2001
2041
|
var marker3 = `vercel.ai.error.${name3}`;
|
|
2002
2042
|
var symbol3 = Symbol.for(marker3);
|
|
2003
2043
|
var _a3;
|
|
2004
|
-
var InvalidToolApprovalError = class extends
|
|
2044
|
+
var InvalidToolApprovalError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2005
2045
|
constructor({ approvalId }) {
|
|
2006
2046
|
super({
|
|
2007
2047
|
name: name3,
|
|
@@ -2011,7 +2051,7 @@ var InvalidToolApprovalError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2011
2051
|
this.approvalId = approvalId;
|
|
2012
2052
|
}
|
|
2013
2053
|
static isInstance(error) {
|
|
2014
|
-
return
|
|
2054
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker3);
|
|
2015
2055
|
}
|
|
2016
2056
|
};
|
|
2017
2057
|
_a3 = symbol3;
|
|
@@ -2019,7 +2059,7 @@ var name4 = "AI_InvalidToolApprovalSignatureError";
|
|
|
2019
2059
|
var marker4 = `vercel.ai.error.${name4}`;
|
|
2020
2060
|
var symbol4 = Symbol.for(marker4);
|
|
2021
2061
|
var _a4;
|
|
2022
|
-
var InvalidToolApprovalSignatureError = class extends
|
|
2062
|
+
var InvalidToolApprovalSignatureError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2023
2063
|
constructor({ approvalId, toolCallId, reason }) {
|
|
2024
2064
|
super({
|
|
2025
2065
|
name: name4,
|
|
@@ -2030,7 +2070,7 @@ var InvalidToolApprovalSignatureError = class extends require_dist_ByO0vuJJ.AISD
|
|
|
2030
2070
|
this.toolCallId = toolCallId;
|
|
2031
2071
|
}
|
|
2032
2072
|
static isInstance(error) {
|
|
2033
|
-
return
|
|
2073
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker4);
|
|
2034
2074
|
}
|
|
2035
2075
|
};
|
|
2036
2076
|
_a4 = symbol4;
|
|
@@ -2038,8 +2078,8 @@ var name5 = "AI_InvalidToolInputError";
|
|
|
2038
2078
|
var marker5 = `vercel.ai.error.${name5}`;
|
|
2039
2079
|
var symbol5 = Symbol.for(marker5);
|
|
2040
2080
|
var _a5;
|
|
2041
|
-
var InvalidToolInputError = class extends
|
|
2042
|
-
constructor({ toolInput, toolName, cause, message = `Invalid input for tool ${toolName}: ${
|
|
2081
|
+
var InvalidToolInputError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2082
|
+
constructor({ toolInput, toolName, cause, message = `Invalid input for tool ${toolName}: ${require_dist_CufwpBZM.getErrorMessage$1(cause)}` }) {
|
|
2043
2083
|
super({
|
|
2044
2084
|
name: name5,
|
|
2045
2085
|
message,
|
|
@@ -2050,7 +2090,7 @@ var InvalidToolInputError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2050
2090
|
this.toolName = toolName;
|
|
2051
2091
|
}
|
|
2052
2092
|
static isInstance(error) {
|
|
2053
|
-
return
|
|
2093
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker5);
|
|
2054
2094
|
}
|
|
2055
2095
|
};
|
|
2056
2096
|
_a5 = symbol5;
|
|
@@ -2058,7 +2098,7 @@ var name6 = "AI_ToolCallNotFoundForApprovalError";
|
|
|
2058
2098
|
var marker6 = `vercel.ai.error.${name6}`;
|
|
2059
2099
|
var symbol6 = Symbol.for(marker6);
|
|
2060
2100
|
var _a6;
|
|
2061
|
-
var ToolCallNotFoundForApprovalError = class extends
|
|
2101
|
+
var ToolCallNotFoundForApprovalError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2062
2102
|
constructor({ toolCallId, approvalId }) {
|
|
2063
2103
|
super({
|
|
2064
2104
|
name: name6,
|
|
@@ -2069,7 +2109,7 @@ var ToolCallNotFoundForApprovalError = class extends require_dist_ByO0vuJJ.AISDK
|
|
|
2069
2109
|
this.approvalId = approvalId;
|
|
2070
2110
|
}
|
|
2071
2111
|
static isInstance(error) {
|
|
2072
|
-
return
|
|
2112
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker6);
|
|
2073
2113
|
}
|
|
2074
2114
|
};
|
|
2075
2115
|
_a6 = symbol6;
|
|
@@ -2077,7 +2117,7 @@ var name7 = "AI_MissingToolResultsError";
|
|
|
2077
2117
|
var marker7 = `vercel.ai.error.${name7}`;
|
|
2078
2118
|
var symbol7 = Symbol.for(marker7);
|
|
2079
2119
|
var _a7;
|
|
2080
|
-
var MissingToolResultsError = class extends
|
|
2120
|
+
var MissingToolResultsError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2081
2121
|
constructor({ toolCallIds }) {
|
|
2082
2122
|
super({
|
|
2083
2123
|
name: name7,
|
|
@@ -2087,7 +2127,7 @@ var MissingToolResultsError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2087
2127
|
this.toolCallIds = toolCallIds;
|
|
2088
2128
|
}
|
|
2089
2129
|
static isInstance(error) {
|
|
2090
|
-
return
|
|
2130
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker7);
|
|
2091
2131
|
}
|
|
2092
2132
|
};
|
|
2093
2133
|
_a7 = symbol7;
|
|
@@ -2095,7 +2135,7 @@ var name9 = "AI_NoObjectGeneratedError";
|
|
|
2095
2135
|
var marker9 = `vercel.ai.error.${name9}`;
|
|
2096
2136
|
var symbol9 = Symbol.for(marker9);
|
|
2097
2137
|
var _a9;
|
|
2098
|
-
var NoObjectGeneratedError = class extends
|
|
2138
|
+
var NoObjectGeneratedError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2099
2139
|
constructor({ message = "No object generated.", cause, text: text2, response, usage, finishReason }) {
|
|
2100
2140
|
super({
|
|
2101
2141
|
name: name9,
|
|
@@ -2109,7 +2149,7 @@ var NoObjectGeneratedError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2109
2149
|
this.finishReason = finishReason;
|
|
2110
2150
|
}
|
|
2111
2151
|
static isInstance(error) {
|
|
2112
|
-
return
|
|
2152
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker9);
|
|
2113
2153
|
}
|
|
2114
2154
|
};
|
|
2115
2155
|
_a9 = symbol9;
|
|
@@ -2117,7 +2157,7 @@ var name10 = "AI_NoOutputGeneratedError";
|
|
|
2117
2157
|
var marker10 = `vercel.ai.error.${name10}`;
|
|
2118
2158
|
var symbol10 = Symbol.for(marker10);
|
|
2119
2159
|
var _a10;
|
|
2120
|
-
var NoOutputGeneratedError = class extends
|
|
2160
|
+
var NoOutputGeneratedError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2121
2161
|
constructor({ message = "No output generated.", cause } = {}) {
|
|
2122
2162
|
super({
|
|
2123
2163
|
name: name10,
|
|
@@ -2127,7 +2167,7 @@ var NoOutputGeneratedError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2127
2167
|
this[_a10] = true;
|
|
2128
2168
|
}
|
|
2129
2169
|
static isInstance(error) {
|
|
2130
|
-
return
|
|
2170
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker10);
|
|
2131
2171
|
}
|
|
2132
2172
|
};
|
|
2133
2173
|
_a10 = symbol10;
|
|
@@ -2135,7 +2175,7 @@ var name14 = "AI_NoSuchToolError";
|
|
|
2135
2175
|
var marker14 = `vercel.ai.error.${name14}`;
|
|
2136
2176
|
var symbol14 = Symbol.for(marker14);
|
|
2137
2177
|
var _a14;
|
|
2138
|
-
var NoSuchToolError = class extends
|
|
2178
|
+
var NoSuchToolError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2139
2179
|
constructor({ toolName, availableTools = void 0, message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}` }) {
|
|
2140
2180
|
super({
|
|
2141
2181
|
name: name14,
|
|
@@ -2146,7 +2186,7 @@ var NoSuchToolError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2146
2186
|
this.availableTools = availableTools;
|
|
2147
2187
|
}
|
|
2148
2188
|
static isInstance(error) {
|
|
2149
|
-
return
|
|
2189
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker14);
|
|
2150
2190
|
}
|
|
2151
2191
|
};
|
|
2152
2192
|
_a14 = symbol14;
|
|
@@ -2154,7 +2194,7 @@ var name15 = "AI_ToolChoiceViolationError";
|
|
|
2154
2194
|
var marker15 = `vercel.ai.error.${name15}`;
|
|
2155
2195
|
var symbol15 = Symbol.for(marker15);
|
|
2156
2196
|
var _a15;
|
|
2157
|
-
var ToolChoiceViolationError = class extends
|
|
2197
|
+
var ToolChoiceViolationError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2158
2198
|
constructor({ toolChoice, finishReason, provider, modelId, content, message = toolChoice.type === "none" ? "Model response contained a tool call even though tool choice was none." : toolChoice.type === "required" ? "Model response did not contain a tool call even though tool choice was required." : `Model response did not contain a call to the required tool '${toolChoice.toolName}'.` }) {
|
|
2159
2199
|
super({
|
|
2160
2200
|
name: name15,
|
|
@@ -2168,7 +2208,7 @@ var ToolChoiceViolationError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2168
2208
|
this.content = content;
|
|
2169
2209
|
}
|
|
2170
2210
|
static isInstance(error) {
|
|
2171
|
-
return
|
|
2211
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker15);
|
|
2172
2212
|
}
|
|
2173
2213
|
};
|
|
2174
2214
|
_a15 = symbol15;
|
|
@@ -2176,8 +2216,8 @@ var name16 = "AI_ToolCallRepairError";
|
|
|
2176
2216
|
var marker16 = `vercel.ai.error.${name16}`;
|
|
2177
2217
|
var symbol16 = Symbol.for(marker16);
|
|
2178
2218
|
var _a16;
|
|
2179
|
-
var ToolCallRepairError = class extends
|
|
2180
|
-
constructor({ cause, originalError, message = `Error repairing tool call: ${
|
|
2219
|
+
var ToolCallRepairError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2220
|
+
constructor({ cause, originalError, message = `Error repairing tool call: ${require_dist_CufwpBZM.getErrorMessage$1(cause)}` }) {
|
|
2181
2221
|
super({
|
|
2182
2222
|
name: name16,
|
|
2183
2223
|
message,
|
|
@@ -2187,11 +2227,11 @@ var ToolCallRepairError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2187
2227
|
this.originalError = originalError;
|
|
2188
2228
|
}
|
|
2189
2229
|
static isInstance(error) {
|
|
2190
|
-
return
|
|
2230
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker16);
|
|
2191
2231
|
}
|
|
2192
2232
|
};
|
|
2193
2233
|
_a16 = symbol16;
|
|
2194
|
-
var UnsupportedModelVersionError = class extends
|
|
2234
|
+
var UnsupportedModelVersionError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2195
2235
|
constructor(options) {
|
|
2196
2236
|
super({
|
|
2197
2237
|
name: "AI_UnsupportedModelVersionError",
|
|
@@ -2206,7 +2246,7 @@ var name17 = "AI_UIMessageStreamError";
|
|
|
2206
2246
|
var marker17 = `vercel.ai.error.${name17}`;
|
|
2207
2247
|
var symbol17 = Symbol.for(marker17);
|
|
2208
2248
|
var _a17;
|
|
2209
|
-
var UIMessageStreamError = class extends
|
|
2249
|
+
var UIMessageStreamError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2210
2250
|
constructor({ chunkType, chunkId, message }) {
|
|
2211
2251
|
super({
|
|
2212
2252
|
name: name17,
|
|
@@ -2217,7 +2257,7 @@ var UIMessageStreamError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2217
2257
|
this.chunkId = chunkId;
|
|
2218
2258
|
}
|
|
2219
2259
|
static isInstance(error) {
|
|
2220
|
-
return
|
|
2260
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker17);
|
|
2221
2261
|
}
|
|
2222
2262
|
};
|
|
2223
2263
|
_a17 = symbol17;
|
|
@@ -2225,7 +2265,7 @@ var name18 = "AI_InvalidDataContentError";
|
|
|
2225
2265
|
var marker18 = `vercel.ai.error.${name18}`;
|
|
2226
2266
|
var symbol18 = Symbol.for(marker18);
|
|
2227
2267
|
var _a18;
|
|
2228
|
-
var InvalidDataContentError = class extends
|
|
2268
|
+
var InvalidDataContentError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2229
2269
|
constructor({ content, cause, message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.` }) {
|
|
2230
2270
|
super({
|
|
2231
2271
|
name: name18,
|
|
@@ -2236,7 +2276,7 @@ var InvalidDataContentError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2236
2276
|
this.content = content;
|
|
2237
2277
|
}
|
|
2238
2278
|
static isInstance(error) {
|
|
2239
|
-
return
|
|
2279
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker18);
|
|
2240
2280
|
}
|
|
2241
2281
|
};
|
|
2242
2282
|
_a18 = symbol18;
|
|
@@ -2244,7 +2284,7 @@ var name19 = "AI_InvalidMessageRoleError";
|
|
|
2244
2284
|
var marker19 = `vercel.ai.error.${name19}`;
|
|
2245
2285
|
var symbol19 = Symbol.for(marker19);
|
|
2246
2286
|
var _a19;
|
|
2247
|
-
var InvalidMessageRoleError = class extends
|
|
2287
|
+
var InvalidMessageRoleError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2248
2288
|
constructor({ role, message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".` }) {
|
|
2249
2289
|
super({
|
|
2250
2290
|
name: name19,
|
|
@@ -2254,7 +2294,7 @@ var InvalidMessageRoleError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2254
2294
|
this.role = role;
|
|
2255
2295
|
}
|
|
2256
2296
|
static isInstance(error) {
|
|
2257
|
-
return
|
|
2297
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker19);
|
|
2258
2298
|
}
|
|
2259
2299
|
};
|
|
2260
2300
|
_a19 = symbol19;
|
|
@@ -2262,7 +2302,7 @@ var name21 = "AI_RetryError";
|
|
|
2262
2302
|
var marker21 = `vercel.ai.error.${name21}`;
|
|
2263
2303
|
var symbol21 = Symbol.for(marker21);
|
|
2264
2304
|
var _a21;
|
|
2265
|
-
var RetryError = class extends
|
|
2305
|
+
var RetryError = class extends require_dist_CufwpBZM.AISDKError {
|
|
2266
2306
|
constructor({ message, reason, errors }) {
|
|
2267
2307
|
super({
|
|
2268
2308
|
name: name21,
|
|
@@ -2274,7 +2314,7 @@ var RetryError = class extends require_dist_ByO0vuJJ.AISDKError {
|
|
|
2274
2314
|
this.lastError = errors[errors.length - 1];
|
|
2275
2315
|
}
|
|
2276
2316
|
static isInstance(error) {
|
|
2277
|
-
return
|
|
2317
|
+
return require_dist_CufwpBZM.AISDKError.hasMarker(error, marker21);
|
|
2278
2318
|
}
|
|
2279
2319
|
};
|
|
2280
2320
|
_a21 = symbol21;
|
|
@@ -2442,7 +2482,7 @@ function resolveEmbeddingModel(model) {
|
|
|
2442
2482
|
}
|
|
2443
2483
|
function getGlobalProvider() {
|
|
2444
2484
|
var _a23;
|
|
2445
|
-
return (_a23 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a23 :
|
|
2485
|
+
return (_a23 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a23 : require_dist_CufwpBZM.gateway;
|
|
2446
2486
|
}
|
|
2447
2487
|
function getTotalTimeoutMs(timeout) {
|
|
2448
2488
|
if (timeout == null) return;
|
|
@@ -2558,7 +2598,7 @@ var ID3_SCAN_BYTES = 131084;
|
|
|
2558
2598
|
function decodePrefix(data, maxBytes) {
|
|
2559
2599
|
if (typeof data !== "string") return data.length > maxBytes ? data.subarray(0, maxBytes) : data;
|
|
2560
2600
|
const maxChars = Math.ceil(maxBytes / 3) * 4;
|
|
2561
|
-
const bytes =
|
|
2601
|
+
const bytes = require_dist_CufwpBZM.convertBase64ToUint8Array(data.substring(0, Math.min(data.length, maxChars)));
|
|
2562
2602
|
return bytes.length > maxBytes ? bytes.subarray(0, maxBytes) : bytes;
|
|
2563
2603
|
}
|
|
2564
2604
|
function hasID3(bytes) {
|
|
@@ -2578,31 +2618,31 @@ var download = async ({ url, maxBytes, abortSignal }) => {
|
|
|
2578
2618
|
var _a23;
|
|
2579
2619
|
const urlText = url.toString();
|
|
2580
2620
|
try {
|
|
2581
|
-
const headers =
|
|
2582
|
-
const response = await
|
|
2621
|
+
const headers = require_dist_CufwpBZM.withUserAgentSuffix({}, `ai-sdk/${VERSION}`, require_dist_CufwpBZM.getRuntimeEnvironmentUserAgent());
|
|
2622
|
+
const response = await require_dist_CufwpBZM.fetchWithValidatedRedirects({
|
|
2583
2623
|
url: urlText,
|
|
2584
2624
|
headers,
|
|
2585
2625
|
abortSignal
|
|
2586
2626
|
});
|
|
2587
2627
|
if (!response.ok) {
|
|
2588
|
-
await
|
|
2589
|
-
throw new
|
|
2628
|
+
await require_dist_CufwpBZM.cancelResponseBody(response);
|
|
2629
|
+
throw new require_dist_CufwpBZM.DownloadError({
|
|
2590
2630
|
url: urlText,
|
|
2591
2631
|
statusCode: response.status,
|
|
2592
2632
|
statusText: response.statusText
|
|
2593
2633
|
});
|
|
2594
2634
|
}
|
|
2595
2635
|
return {
|
|
2596
|
-
data: await
|
|
2636
|
+
data: await require_dist_CufwpBZM.readResponseWithSizeLimit({
|
|
2597
2637
|
response,
|
|
2598
2638
|
url: urlText,
|
|
2599
|
-
maxBytes: maxBytes != null ? maxBytes :
|
|
2639
|
+
maxBytes: maxBytes != null ? maxBytes : require_dist_CufwpBZM.DEFAULT_MAX_DOWNLOAD_SIZE
|
|
2600
2640
|
}),
|
|
2601
2641
|
mediaType: (_a23 = response.headers.get("content-type")) != null ? _a23 : void 0
|
|
2602
2642
|
};
|
|
2603
2643
|
} catch (error) {
|
|
2604
|
-
if (
|
|
2605
|
-
throw new
|
|
2644
|
+
if (require_dist_CufwpBZM.DownloadError.isInstance(error)) throw error;
|
|
2645
|
+
throw new require_dist_CufwpBZM.DownloadError({
|
|
2606
2646
|
url: urlText,
|
|
2607
2647
|
cause: error
|
|
2608
2648
|
});
|
|
@@ -2647,8 +2687,8 @@ function splitDataUrl(dataUrl) {
|
|
|
2647
2687
|
}
|
|
2648
2688
|
var dataContentSchema = zod_v4.z.union([
|
|
2649
2689
|
zod_v4.z.string(),
|
|
2650
|
-
zod_v4.z.custom(
|
|
2651
|
-
zod_v4.z.custom(
|
|
2690
|
+
zod_v4.z.custom(require_dist_CufwpBZM.isUint8Array, { message: "Must be a Uint8Array" }),
|
|
2691
|
+
zod_v4.z.custom(require_dist_CufwpBZM.isArrayBuffer, { message: "Must be an ArrayBuffer" }),
|
|
2652
2692
|
zod_v4.z.custom((value) => {
|
|
2653
2693
|
var _a23, _b;
|
|
2654
2694
|
return (_b = (_a23 = globalThis.Buffer) == null ? void 0 : _a23.isBuffer(value)) != null ? _b : false;
|
|
@@ -2656,11 +2696,11 @@ var dataContentSchema = zod_v4.z.union([
|
|
|
2656
2696
|
]);
|
|
2657
2697
|
function convertToLanguageModelV3DataContent(content) {
|
|
2658
2698
|
let originalUrl;
|
|
2659
|
-
if (
|
|
2699
|
+
if (require_dist_CufwpBZM.isUint8Array(content)) return {
|
|
2660
2700
|
data: convertDataContentToUint8Array(content),
|
|
2661
2701
|
mediaType: void 0
|
|
2662
2702
|
};
|
|
2663
|
-
if (
|
|
2703
|
+
if (require_dist_CufwpBZM.isArrayBuffer(content)) return {
|
|
2664
2704
|
data: new Uint8Array(content),
|
|
2665
2705
|
mediaType: void 0
|
|
2666
2706
|
};
|
|
@@ -2671,7 +2711,7 @@ function convertToLanguageModelV3DataContent(content) {
|
|
|
2671
2711
|
} catch (error) {}
|
|
2672
2712
|
if (content instanceof URL && content.protocol === "data:") {
|
|
2673
2713
|
const { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(content.toString());
|
|
2674
|
-
if (dataUrlMediaType == null || base64Content == null) throw new
|
|
2714
|
+
if (dataUrlMediaType == null || base64Content == null) throw new require_dist_CufwpBZM.AISDKError({
|
|
2675
2715
|
name: "InvalidDataContentError",
|
|
2676
2716
|
message: `Invalid data URL format in content ${content.toString()}`
|
|
2677
2717
|
});
|
|
@@ -2688,16 +2728,16 @@ function convertToLanguageModelV3DataContent(content) {
|
|
|
2688
2728
|
}
|
|
2689
2729
|
function convertDataContentToBase64String(content) {
|
|
2690
2730
|
if (typeof content === "string") return content;
|
|
2691
|
-
return
|
|
2731
|
+
return require_dist_CufwpBZM.convertUint8ArrayToBase64(convertDataContentToUint8Array(content));
|
|
2692
2732
|
}
|
|
2693
2733
|
function convertDataContentToUint8Array(content) {
|
|
2694
|
-
if (
|
|
2734
|
+
if (require_dist_CufwpBZM.isUint8Array(content)) {
|
|
2695
2735
|
if (content instanceof Uint8Array) return content;
|
|
2696
2736
|
const { buffer, byteOffset, byteLength } = content;
|
|
2697
2737
|
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
2698
2738
|
}
|
|
2699
2739
|
if (typeof content === "string") try {
|
|
2700
|
-
return
|
|
2740
|
+
return require_dist_CufwpBZM.convertBase64ToUint8Array(content);
|
|
2701
2741
|
} catch (error) {
|
|
2702
2742
|
throw new InvalidDataContentError({
|
|
2703
2743
|
message: "Invalid data content. Content string is not a base64-encoded media.",
|
|
@@ -2705,7 +2745,7 @@ function convertDataContentToUint8Array(content) {
|
|
|
2705
2745
|
cause: error
|
|
2706
2746
|
});
|
|
2707
2747
|
}
|
|
2708
|
-
if (
|
|
2748
|
+
if (require_dist_CufwpBZM.isArrayBuffer(content)) return new Uint8Array(content);
|
|
2709
2749
|
throw new InvalidDataContentError({ content });
|
|
2710
2750
|
}
|
|
2711
2751
|
async function convertToLanguageModelPrompt({ prompt, supportedUrls, download: download2, abortSignal }) {
|
|
@@ -2885,7 +2925,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
2885
2925
|
};
|
|
2886
2926
|
}).filter((part) => part.data instanceof URL).map((part) => ({
|
|
2887
2927
|
url: part.data,
|
|
2888
|
-
isUrlSupportedByModel: part.mediaType != null &&
|
|
2928
|
+
isUrlSupportedByModel: part.mediaType != null && require_dist_CufwpBZM.isUrlSupported({
|
|
2889
2929
|
url: part.data.toString(),
|
|
2890
2930
|
mediaType: part.mediaType,
|
|
2891
2931
|
supportedUrls
|
|
@@ -2994,7 +3034,7 @@ function mapToolResultOutput({ output, downloadedAssets }) {
|
|
|
2994
3034
|
async function createToolModelOutput({ toolCallId, input, output, tool: tool2, errorMode }) {
|
|
2995
3035
|
if (errorMode === "text") return {
|
|
2996
3036
|
type: "error-text",
|
|
2997
|
-
value:
|
|
3037
|
+
value: require_dist_CufwpBZM.getErrorMessage$1(output)
|
|
2998
3038
|
};
|
|
2999
3039
|
else if (errorMode === "json") return {
|
|
3000
3040
|
type: "error-json",
|
|
@@ -3102,7 +3142,7 @@ async function prepareToolsAndToolChoice({ tools, toolChoice, activeTools }) {
|
|
|
3102
3142
|
type: "function",
|
|
3103
3143
|
name: name23,
|
|
3104
3144
|
description: tool2.description,
|
|
3105
|
-
inputSchema: await
|
|
3145
|
+
inputSchema: await require_dist_CufwpBZM.asSchema(tool2.inputSchema).jsonSchema,
|
|
3106
3146
|
...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},
|
|
3107
3147
|
providerOptions: tool2.providerOptions,
|
|
3108
3148
|
...tool2.strict != null ? { strict: tool2.strict } : {}
|
|
@@ -3305,15 +3345,15 @@ var modelMessageSchema = zod_v4.z.union([
|
|
|
3305
3345
|
toolModelMessageSchema
|
|
3306
3346
|
]);
|
|
3307
3347
|
async function standardizePrompt({ allowSystemInMessages, system, prompt, messages }) {
|
|
3308
|
-
if (prompt == null && messages == null) throw new
|
|
3348
|
+
if (prompt == null && messages == null) throw new require_dist_CufwpBZM.InvalidPromptError({
|
|
3309
3349
|
prompt,
|
|
3310
3350
|
message: "prompt or messages must be defined"
|
|
3311
3351
|
});
|
|
3312
|
-
if (prompt != null && messages != null) throw new
|
|
3352
|
+
if (prompt != null && messages != null) throw new require_dist_CufwpBZM.InvalidPromptError({
|
|
3313
3353
|
prompt,
|
|
3314
3354
|
message: "prompt and messages cannot be defined at the same time"
|
|
3315
3355
|
});
|
|
3316
|
-
if (typeof system !== "string" && !asArray(system).every((message) => message.role === "system")) throw new
|
|
3356
|
+
if (typeof system !== "string" && !asArray(system).every((message) => message.role === "system")) throw new require_dist_CufwpBZM.InvalidPromptError({
|
|
3317
3357
|
prompt,
|
|
3318
3358
|
message: "system must be a string, SystemModelMessage, or array of SystemModelMessage"
|
|
3319
3359
|
});
|
|
@@ -3322,26 +3362,26 @@ async function standardizePrompt({ allowSystemInMessages, system, prompt, messag
|
|
|
3322
3362
|
content: prompt
|
|
3323
3363
|
}];
|
|
3324
3364
|
else if (prompt != null && Array.isArray(prompt)) messages = prompt;
|
|
3325
|
-
else if (messages == null) throw new
|
|
3365
|
+
else if (messages == null) throw new require_dist_CufwpBZM.InvalidPromptError({
|
|
3326
3366
|
prompt,
|
|
3327
3367
|
message: "prompt or messages must be defined"
|
|
3328
3368
|
});
|
|
3329
|
-
if (messages.length === 0) throw new
|
|
3369
|
+
if (messages.length === 0) throw new require_dist_CufwpBZM.InvalidPromptError({
|
|
3330
3370
|
prompt,
|
|
3331
3371
|
message: "messages must not be empty"
|
|
3332
3372
|
});
|
|
3333
3373
|
if (messages.some((message) => message.role === "system")) {
|
|
3334
|
-
if (allowSystemInMessages === false) throw new
|
|
3374
|
+
if (allowSystemInMessages === false) throw new require_dist_CufwpBZM.InvalidPromptError({
|
|
3335
3375
|
prompt,
|
|
3336
3376
|
message: "System messages are not allowed in the prompt or messages fields. Use the system option instead."
|
|
3337
3377
|
});
|
|
3338
3378
|
if (allowSystemInMessages === void 0) console.warn("AI SDK Warning: System messages in the prompt or messages fields can be a security risk because they may enable prompt injection attacks. Use the system option instead when possible. Set allowSystemInMessages to true to suppress this warning, or false to throw an error.");
|
|
3339
3379
|
}
|
|
3340
|
-
const validationResult = await
|
|
3380
|
+
const validationResult = await require_dist_CufwpBZM.safeValidateTypes({
|
|
3341
3381
|
value: messages,
|
|
3342
3382
|
schema: zod_v4.z.array(modelMessageSchema)
|
|
3343
3383
|
});
|
|
3344
|
-
if (!validationResult.success) throw new
|
|
3384
|
+
if (!validationResult.success) throw new require_dist_CufwpBZM.InvalidPromptError({
|
|
3345
3385
|
prompt,
|
|
3346
3386
|
message: "The messages do not match the ModelMessage[] schema.",
|
|
3347
3387
|
cause: validationResult.error
|
|
@@ -3352,10 +3392,10 @@ async function standardizePrompt({ allowSystemInMessages, system, prompt, messag
|
|
|
3352
3392
|
};
|
|
3353
3393
|
}
|
|
3354
3394
|
function wrapGatewayError(error) {
|
|
3355
|
-
if (!
|
|
3395
|
+
if (!require_dist_CufwpBZM.GatewayAuthenticationError.isInstance(error)) return error;
|
|
3356
3396
|
const isProductionEnv = (process == null ? void 0 : "production") === "production";
|
|
3357
3397
|
const moreInfoURL = "https://ai-sdk.dev/unauthenticated-ai-gateway";
|
|
3358
|
-
if (isProductionEnv) return new
|
|
3398
|
+
if (isProductionEnv) return new require_dist_CufwpBZM.AISDKError({
|
|
3359
3399
|
name: "GatewayError",
|
|
3360
3400
|
message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
|
|
3361
3401
|
});
|
|
@@ -3625,7 +3665,7 @@ function addTokenCounts(tokenCount1, tokenCount2) {
|
|
|
3625
3665
|
return tokenCount1 == null && tokenCount2 == null ? void 0 : (tokenCount1 != null ? tokenCount1 : 0) + (tokenCount2 != null ? tokenCount2 : 0);
|
|
3626
3666
|
}
|
|
3627
3667
|
function getRetryDelayInMs({ error, exponentialBackoffDelay }) {
|
|
3628
|
-
const headers =
|
|
3668
|
+
const headers = require_dist_CufwpBZM.APICallError.isInstance(error) ? error.responseHeaders : require_dist_CufwpBZM.APICallError.isInstance(error.cause) ? error.cause.responseHeaders : void 0;
|
|
3629
3669
|
if (!headers) return exponentialBackoffDelay;
|
|
3630
3670
|
let ms;
|
|
3631
3671
|
const retryAfterMs = headers["retry-after-ms"];
|
|
@@ -3642,12 +3682,12 @@ function getRetryDelayInMs({ error, exponentialBackoffDelay }) {
|
|
|
3642
3682
|
if (ms != null && !Number.isNaN(ms) && 0 <= ms && (ms < 6e4 || ms < exponentialBackoffDelay)) return ms;
|
|
3643
3683
|
return exponentialBackoffDelay;
|
|
3644
3684
|
}
|
|
3645
|
-
var retryWithExponentialBackoffRespectingRetryHeaders = ({ maxRetries = 2, initialDelayInMs = 2e3, backoffFactor = 2, abortSignal, additionalRetryableError } = {}) =>
|
|
3685
|
+
var retryWithExponentialBackoffRespectingRetryHeaders = ({ maxRetries = 2, initialDelayInMs = 2e3, backoffFactor = 2, abortSignal, additionalRetryableError } = {}) => require_dist_CufwpBZM.retryWithExponentialBackoff({
|
|
3646
3686
|
maxRetries,
|
|
3647
3687
|
initialDelayInMs,
|
|
3648
3688
|
backoffFactor,
|
|
3649
3689
|
abortSignal,
|
|
3650
|
-
shouldRetry: async (error) => error instanceof Error && (
|
|
3690
|
+
shouldRetry: async (error) => error instanceof Error && (require_dist_CufwpBZM.APICallError.isInstance(error) && error.isRetryable === true || require_dist_CufwpBZM.GatewayError.isInstance(error) && error.isRetryable === true) || additionalRetryableError != null && await additionalRetryableError(error),
|
|
3651
3691
|
getDelayInMs: ({ error, exponentialBackoffDelay }) => getRetryDelayInMs({
|
|
3652
3692
|
error,
|
|
3653
3693
|
exponentialBackoffDelay
|
|
@@ -3774,7 +3814,7 @@ async function executeToolCall({ toolCall, tools, tracer, telemetry, messages, a
|
|
|
3774
3814
|
});
|
|
3775
3815
|
const startTime = now();
|
|
3776
3816
|
try {
|
|
3777
|
-
const stream =
|
|
3817
|
+
const stream = require_dist_CufwpBZM.executeTool({
|
|
3778
3818
|
execute: tool2.execute.bind(tool2),
|
|
3779
3819
|
input,
|
|
3780
3820
|
options: {
|
|
@@ -3863,11 +3903,11 @@ var DefaultGeneratedFile = class {
|
|
|
3863
3903
|
this.mediaType = mediaType;
|
|
3864
3904
|
}
|
|
3865
3905
|
get base64() {
|
|
3866
|
-
if (this.base64Data == null) this.base64Data =
|
|
3906
|
+
if (this.base64Data == null) this.base64Data = require_dist_CufwpBZM.convertUint8ArrayToBase64(this.uint8ArrayData);
|
|
3867
3907
|
return this.base64Data;
|
|
3868
3908
|
}
|
|
3869
3909
|
get uint8Array() {
|
|
3870
|
-
if (this.uint8ArrayData == null) this.uint8ArrayData =
|
|
3910
|
+
if (this.uint8ArrayData == null) this.uint8ArrayData = require_dist_CufwpBZM.convertBase64ToUint8Array(this.base64Data);
|
|
3871
3911
|
return this.uint8ArrayData;
|
|
3872
3912
|
}
|
|
3873
3913
|
};
|
|
@@ -3897,10 +3937,10 @@ function canonicalJSON(value) {
|
|
|
3897
3937
|
return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonicalJSON(value[k])}`).join(",")}}`;
|
|
3898
3938
|
}
|
|
3899
3939
|
function toBase64url(bytes) {
|
|
3900
|
-
return
|
|
3940
|
+
return require_dist_CufwpBZM.convertUint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
3901
3941
|
}
|
|
3902
3942
|
function fromBase64url(str) {
|
|
3903
|
-
return
|
|
3943
|
+
return require_dist_CufwpBZM.convertBase64ToUint8Array(str);
|
|
3904
3944
|
}
|
|
3905
3945
|
async function importKey(secret) {
|
|
3906
3946
|
const keyData = typeof secret === "string" ? encoder.encode(secret) : secret;
|
|
@@ -3991,9 +4031,9 @@ async function validateApprovedToolApprovals({ approvedToolApprovals, tools, mes
|
|
|
3991
4031
|
}
|
|
3992
4032
|
if (tool2 != null && typeof tool2.execute === "function" && tool2.inputSchema != null) {
|
|
3993
4033
|
const hasInputSchemaInput = Object.prototype.hasOwnProperty.call(approvalRequest, "inputSchemaInput");
|
|
3994
|
-
const validation = await
|
|
4034
|
+
const validation = await require_dist_CufwpBZM.safeValidateTypes({
|
|
3995
4035
|
value: hasInputSchemaInput ? approvalRequest.inputSchemaInput : toolCall.input,
|
|
3996
|
-
schema:
|
|
4036
|
+
schema: require_dist_CufwpBZM.asSchema(tool2.inputSchema)
|
|
3997
4037
|
});
|
|
3998
4038
|
let validationError;
|
|
3999
4039
|
if (!validation.success) validationError = validation.error;
|
|
@@ -4294,12 +4334,12 @@ async function parsePartialJson(jsonText) {
|
|
|
4294
4334
|
value: void 0,
|
|
4295
4335
|
state: "undefined-input"
|
|
4296
4336
|
};
|
|
4297
|
-
let result = await
|
|
4337
|
+
let result = await require_dist_CufwpBZM.safeParseJSON({ text: jsonText });
|
|
4298
4338
|
if (result.success) return {
|
|
4299
4339
|
value: result.value,
|
|
4300
4340
|
state: "successful-parse"
|
|
4301
4341
|
};
|
|
4302
|
-
result = await
|
|
4342
|
+
result = await require_dist_CufwpBZM.safeParseJSON({ text: fixJson(jsonText) });
|
|
4303
4343
|
if (result.success) return {
|
|
4304
4344
|
value: result.value,
|
|
4305
4345
|
state: "repaired-parse"
|
|
@@ -4321,17 +4361,17 @@ var text = () => ({
|
|
|
4321
4361
|
createElementStreamTransform() {}
|
|
4322
4362
|
});
|
|
4323
4363
|
var object = ({ schema: inputSchema, name: name23, description }) => {
|
|
4324
|
-
const schema =
|
|
4364
|
+
const schema = require_dist_CufwpBZM.asSchema(inputSchema);
|
|
4325
4365
|
return {
|
|
4326
4366
|
name: "object",
|
|
4327
|
-
responseFormat:
|
|
4367
|
+
responseFormat: require_dist_CufwpBZM.resolve(schema.jsonSchema).then((jsonSchema2) => ({
|
|
4328
4368
|
type: "json",
|
|
4329
4369
|
schema: jsonSchema2,
|
|
4330
4370
|
...name23 != null && { name: name23 },
|
|
4331
4371
|
...description != null && { description }
|
|
4332
4372
|
})),
|
|
4333
4373
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
4334
|
-
const parseResult = await
|
|
4374
|
+
const parseResult = await require_dist_CufwpBZM.safeParseJSON({ text: text2 });
|
|
4335
4375
|
if (!parseResult.success) throw new NoObjectGeneratedError({
|
|
4336
4376
|
message: "No object generated: could not parse the response.",
|
|
4337
4377
|
cause: parseResult.error,
|
|
@@ -4340,7 +4380,7 @@ var object = ({ schema: inputSchema, name: name23, description }) => {
|
|
|
4340
4380
|
usage: context2.usage,
|
|
4341
4381
|
finishReason: context2.finishReason
|
|
4342
4382
|
});
|
|
4343
|
-
const validationResult = await
|
|
4383
|
+
const validationResult = await require_dist_CufwpBZM.safeValidateTypes({
|
|
4344
4384
|
value: parseResult.value,
|
|
4345
4385
|
schema
|
|
4346
4386
|
});
|
|
@@ -4367,10 +4407,10 @@ var object = ({ schema: inputSchema, name: name23, description }) => {
|
|
|
4367
4407
|
};
|
|
4368
4408
|
};
|
|
4369
4409
|
var array = ({ element: inputElementSchema, name: name23, description }) => {
|
|
4370
|
-
const elementSchema =
|
|
4410
|
+
const elementSchema = require_dist_CufwpBZM.asSchema(inputElementSchema);
|
|
4371
4411
|
return {
|
|
4372
4412
|
name: "array",
|
|
4373
|
-
responseFormat:
|
|
4413
|
+
responseFormat: require_dist_CufwpBZM.resolve(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
4374
4414
|
const { $schema, ...itemSchema } = jsonSchema2;
|
|
4375
4415
|
return {
|
|
4376
4416
|
type: "json",
|
|
@@ -4389,7 +4429,7 @@ var array = ({ element: inputElementSchema, name: name23, description }) => {
|
|
|
4389
4429
|
};
|
|
4390
4430
|
}),
|
|
4391
4431
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
4392
|
-
const parseResult = await
|
|
4432
|
+
const parseResult = await require_dist_CufwpBZM.safeParseJSON({ text: text2 });
|
|
4393
4433
|
if (!parseResult.success) throw new NoObjectGeneratedError({
|
|
4394
4434
|
message: "No object generated: could not parse the response.",
|
|
4395
4435
|
cause: parseResult.error,
|
|
@@ -4401,7 +4441,7 @@ var array = ({ element: inputElementSchema, name: name23, description }) => {
|
|
|
4401
4441
|
const outerValue = parseResult.value;
|
|
4402
4442
|
if (outerValue == null || typeof outerValue !== "object" || !("elements" in outerValue) || !Array.isArray(outerValue.elements)) throw new NoObjectGeneratedError({
|
|
4403
4443
|
message: "No object generated: response did not match schema.",
|
|
4404
|
-
cause: new
|
|
4444
|
+
cause: new require_dist_CufwpBZM.TypeValidationError({
|
|
4405
4445
|
value: outerValue,
|
|
4406
4446
|
cause: "response must be an object with an elements array"
|
|
4407
4447
|
}),
|
|
@@ -4412,7 +4452,7 @@ var array = ({ element: inputElementSchema, name: name23, description }) => {
|
|
|
4412
4452
|
});
|
|
4413
4453
|
const validatedElements = [];
|
|
4414
4454
|
for (const element of outerValue.elements) {
|
|
4415
|
-
const validationResult = await
|
|
4455
|
+
const validationResult = await require_dist_CufwpBZM.safeValidateTypes({
|
|
4416
4456
|
value: element,
|
|
4417
4457
|
schema: elementSchema
|
|
4418
4458
|
});
|
|
@@ -4440,7 +4480,7 @@ var array = ({ element: inputElementSchema, name: name23, description }) => {
|
|
|
4440
4480
|
const rawElements = result.state === "repaired-parse" && outerValue.elements.length > 0 ? outerValue.elements.slice(0, -1) : outerValue.elements;
|
|
4441
4481
|
const parsedElements = [];
|
|
4442
4482
|
for (const rawElement of rawElements) {
|
|
4443
|
-
const validationResult = await
|
|
4483
|
+
const validationResult = await require_dist_CufwpBZM.safeValidateTypes({
|
|
4444
4484
|
value: rawElement,
|
|
4445
4485
|
schema: elementSchema
|
|
4446
4486
|
});
|
|
@@ -4477,7 +4517,7 @@ var choice = ({ options: choiceOptions, name: name23, description }) => {
|
|
|
4477
4517
|
...description != null && { description }
|
|
4478
4518
|
}),
|
|
4479
4519
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
4480
|
-
const parseResult = await
|
|
4520
|
+
const parseResult = await require_dist_CufwpBZM.safeParseJSON({ text: text2 });
|
|
4481
4521
|
if (!parseResult.success) throw new NoObjectGeneratedError({
|
|
4482
4522
|
message: "No object generated: could not parse the response.",
|
|
4483
4523
|
cause: parseResult.error,
|
|
@@ -4489,7 +4529,7 @@ var choice = ({ options: choiceOptions, name: name23, description }) => {
|
|
|
4489
4529
|
const outerValue = parseResult.value;
|
|
4490
4530
|
if (outerValue == null || typeof outerValue !== "object" || !("result" in outerValue) || typeof outerValue.result !== "string" || !choiceOptions.includes(outerValue.result)) throw new NoObjectGeneratedError({
|
|
4491
4531
|
message: "No object generated: response did not match schema.",
|
|
4492
|
-
cause: new
|
|
4532
|
+
cause: new require_dist_CufwpBZM.TypeValidationError({
|
|
4493
4533
|
value: outerValue,
|
|
4494
4534
|
cause: "response must be an object that contains a choice value."
|
|
4495
4535
|
}),
|
|
@@ -4527,7 +4567,7 @@ var json = ({ name: name23, description } = {}) => {
|
|
|
4527
4567
|
...description != null && { description }
|
|
4528
4568
|
}),
|
|
4529
4569
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
4530
|
-
const parseResult = await
|
|
4570
|
+
const parseResult = await require_dist_CufwpBZM.safeParseJSON({ text: text2 });
|
|
4531
4571
|
if (!parseResult.success) throw new NoObjectGeneratedError({
|
|
4532
4572
|
message: "No object generated: could not parse the response.",
|
|
4533
4573
|
cause: parseResult.error,
|
|
@@ -4578,7 +4618,7 @@ async function parseToolCall({ toolCall, tools, repairToolCall, system, messages
|
|
|
4578
4618
|
tools,
|
|
4579
4619
|
inputSchema: async ({ toolName }) => {
|
|
4580
4620
|
const { inputSchema } = tools[toolName];
|
|
4581
|
-
return await
|
|
4621
|
+
return await require_dist_CufwpBZM.asSchema(inputSchema).jsonSchema;
|
|
4582
4622
|
},
|
|
4583
4623
|
system,
|
|
4584
4624
|
messages,
|
|
@@ -4597,7 +4637,7 @@ async function parseToolCall({ toolCall, tools, repairToolCall, system, messages
|
|
|
4597
4637
|
});
|
|
4598
4638
|
}
|
|
4599
4639
|
} catch (error) {
|
|
4600
|
-
const parsedInput = await
|
|
4640
|
+
const parsedInput = await require_dist_CufwpBZM.safeParseJSON({ text: toolCall.input });
|
|
4601
4641
|
const input = parsedInput.success ? parsedInput.value : toolCall.input;
|
|
4602
4642
|
const tool2 = tools == null ? void 0 : tools[toolCall.toolName];
|
|
4603
4643
|
return {
|
|
@@ -4619,7 +4659,7 @@ async function parseProviderExecutedDynamicToolCall(toolCall) {
|
|
|
4619
4659
|
const parseResult = toolCall.input.trim() === "" ? {
|
|
4620
4660
|
success: true,
|
|
4621
4661
|
value: {}
|
|
4622
|
-
} : await
|
|
4662
|
+
} : await require_dist_CufwpBZM.safeParseJSON({ text: toolCall.input });
|
|
4623
4663
|
if (parseResult.success === false) throw new InvalidToolInputError({
|
|
4624
4664
|
toolName: toolCall.toolName,
|
|
4625
4665
|
toolInput: toolCall.input,
|
|
@@ -4645,11 +4685,11 @@ async function doParseToolCall({ toolCall, tools }) {
|
|
|
4645
4685
|
availableTools: Object.keys(tools)
|
|
4646
4686
|
});
|
|
4647
4687
|
}
|
|
4648
|
-
const schema =
|
|
4649
|
-
const parseResult = toolCall.input.trim() === "" ? await
|
|
4688
|
+
const schema = require_dist_CufwpBZM.asSchema(tool2.inputSchema);
|
|
4689
|
+
const parseResult = toolCall.input.trim() === "" ? await require_dist_CufwpBZM.safeValidateTypes({
|
|
4650
4690
|
value: {},
|
|
4651
4691
|
schema
|
|
4652
|
-
}) : await
|
|
4692
|
+
}) : await require_dist_CufwpBZM.safeParseJSON({
|
|
4653
4693
|
text: toolCall.input,
|
|
4654
4694
|
schema
|
|
4655
4695
|
});
|
|
@@ -4897,7 +4937,7 @@ function mergeAbortSignals(...signals) {
|
|
|
4897
4937
|
}
|
|
4898
4938
|
return controller.signal;
|
|
4899
4939
|
}
|
|
4900
|
-
var originalGenerateId =
|
|
4940
|
+
var originalGenerateId = require_dist_CufwpBZM.createIdGenerator({
|
|
4901
4941
|
prefix: "aitxt",
|
|
4902
4942
|
size: 24
|
|
4903
4943
|
});
|
|
@@ -4914,7 +4954,7 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
4914
4954
|
abortSignal: mergedAbortSignal
|
|
4915
4955
|
});
|
|
4916
4956
|
const callSettings = prepareCallSettings(settings);
|
|
4917
|
-
const headersWithUserAgent =
|
|
4957
|
+
const headersWithUserAgent = require_dist_CufwpBZM.withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);
|
|
4918
4958
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
|
4919
4959
|
model,
|
|
4920
4960
|
telemetry,
|
|
@@ -5281,7 +5321,7 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
5281
5321
|
toolCallId: toolCall.toolCallId,
|
|
5282
5322
|
toolName: toolCall.toolName,
|
|
5283
5323
|
input: toolCall.input,
|
|
5284
|
-
error:
|
|
5324
|
+
error: require_dist_CufwpBZM.getErrorMessage(toolCall.error),
|
|
5285
5325
|
dynamic: true
|
|
5286
5326
|
});
|
|
5287
5327
|
clientToolCalls = stepToolCalls.filter((toolCall) => !toolCall.providerExecuted);
|
|
@@ -5780,7 +5820,7 @@ function getResponseUIMessageId({ originalMessages, responseMessageId }) {
|
|
|
5780
5820
|
return (lastMessage == null ? void 0 : lastMessage.role) === "assistant" ? lastMessage.id : typeof responseMessageId === "function" ? responseMessageId() : responseMessageId;
|
|
5781
5821
|
}
|
|
5782
5822
|
var toolMetadataSchema = zod_v4.z.record(zod_v4.z.string(), jsonValueSchema.optional());
|
|
5783
|
-
|
|
5823
|
+
require_dist_CufwpBZM.lazySchema(() => require_dist_CufwpBZM.zodSchema(zod_v4.z.union([
|
|
5784
5824
|
zod_v4.z.looseObject({
|
|
5785
5825
|
type: zod_v4.z.literal("text-start"),
|
|
5786
5826
|
id: zod_v4.z.string(),
|
|
@@ -6113,7 +6153,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
6113
6153
|
async function updateMessageMetadata(metadata) {
|
|
6114
6154
|
if (metadata != null) {
|
|
6115
6155
|
const mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;
|
|
6116
|
-
if (messageMetadataSchema != null) await
|
|
6156
|
+
if (messageMetadataSchema != null) await require_dist_CufwpBZM.validateTypes({
|
|
6117
6157
|
value: mergedMetadata,
|
|
6118
6158
|
schema: messageMetadataSchema,
|
|
6119
6159
|
context: {
|
|
@@ -6458,7 +6498,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
6458
6498
|
if ((dataPartSchemas == null ? void 0 : dataPartSchemas[chunk.type]) != null) {
|
|
6459
6499
|
const partIdx = state.message.parts.findIndex((p) => "id" in p && "data" in p && p.id === chunk.id && p.type === chunk.type);
|
|
6460
6500
|
const actualPartIdx = partIdx >= 0 ? partIdx : state.message.parts.length;
|
|
6461
|
-
await
|
|
6501
|
+
await require_dist_CufwpBZM.validateTypes({
|
|
6462
6502
|
value: chunk.data,
|
|
6463
6503
|
schema: dataPartSchemas[chunk.type],
|
|
6464
6504
|
context: {
|
|
@@ -6981,7 +7021,7 @@ function runToolsTransformation({ tools, toolChoice, generatorStream, tracer, te
|
|
|
6981
7021
|
toolCallId: toolCall.toolCallId,
|
|
6982
7022
|
toolName: toolCall.toolName,
|
|
6983
7023
|
input: toolCall.input,
|
|
6984
|
-
error:
|
|
7024
|
+
error: require_dist_CufwpBZM.getErrorMessage(toolCall.error),
|
|
6985
7025
|
dynamic: true,
|
|
6986
7026
|
title: toolCall.title,
|
|
6987
7027
|
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
@@ -7078,7 +7118,7 @@ function runToolsTransformation({ tools, toolChoice, generatorStream, tracer, te
|
|
|
7078
7118
|
}))]);
|
|
7079
7119
|
} });
|
|
7080
7120
|
}
|
|
7081
|
-
var originalGenerateId2 =
|
|
7121
|
+
var originalGenerateId2 = require_dist_CufwpBZM.createIdGenerator({
|
|
7082
7122
|
prefix: "aitxt",
|
|
7083
7123
|
size: 24
|
|
7084
7124
|
});
|
|
@@ -7243,10 +7283,10 @@ function createOutputTransformStream(output) {
|
|
|
7243
7283
|
}
|
|
7244
7284
|
var DefaultStreamTextResult = class {
|
|
7245
7285
|
constructor({ model, telemetry, headers, settings, maxRetries: maxRetriesArg, abortSignal, stepTimeoutMs, stepAbortController, chunkTimeoutMs, chunkAbortController, system, prompt, messages, allowSystemInMessages, tools, toolChoice, transforms, activeTools, repairToolCall, stopConditions, output, providerOptions, prepareStep, includeRawChunks, now: now2, generateId: generateId2, timeout, stopWhen, originalAbortSignal, onChunk, onError, onFinish, onAbort, onStepFinish, onStart, onStepStart, onToolCallStart, onToolCallFinish, experimental_context, experimental_toolApprovalSecret, download: download2, include }) {
|
|
7246
|
-
this._totalUsage = new
|
|
7247
|
-
this._finishReason = new
|
|
7248
|
-
this._rawFinishReason = new
|
|
7249
|
-
this._steps = new
|
|
7286
|
+
this._totalUsage = new require_dist_CufwpBZM.DelayedPromise();
|
|
7287
|
+
this._finishReason = new require_dist_CufwpBZM.DelayedPromise();
|
|
7288
|
+
this._rawFinishReason = new require_dist_CufwpBZM.DelayedPromise();
|
|
7289
|
+
this._steps = new require_dist_CufwpBZM.DelayedPromise();
|
|
7250
7290
|
this.outputSpecification = output;
|
|
7251
7291
|
this.includeRawChunks = includeRawChunks;
|
|
7252
7292
|
this.tools = tools;
|
|
@@ -7541,7 +7581,7 @@ var DefaultStreamTextResult = class {
|
|
|
7541
7581
|
onAbort?.({ steps: recordedSteps });
|
|
7542
7582
|
controller.enqueue({
|
|
7543
7583
|
type: "abort",
|
|
7544
|
-
...(abortSignal == null ? void 0 : abortSignal.reason) !== void 0 ? { reason:
|
|
7584
|
+
...(abortSignal == null ? void 0 : abortSignal.reason) !== void 0 ? { reason: require_dist_CufwpBZM.getErrorMessage$1(abortSignal.reason) } : {}
|
|
7545
7585
|
});
|
|
7546
7586
|
controller.close();
|
|
7547
7587
|
}
|
|
@@ -7557,7 +7597,7 @@ var DefaultStreamTextResult = class {
|
|
|
7557
7597
|
}
|
|
7558
7598
|
controller.enqueue(value);
|
|
7559
7599
|
} catch (error) {
|
|
7560
|
-
if (
|
|
7600
|
+
if (require_dist_CufwpBZM.isAbortError(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) abort();
|
|
7561
7601
|
else controller.error(error);
|
|
7562
7602
|
}
|
|
7563
7603
|
},
|
|
@@ -7687,7 +7727,7 @@ var DefaultStreamTextResult = class {
|
|
|
7687
7727
|
toolCallId: toolApproval.toolCall.toolCallId,
|
|
7688
7728
|
toolName: toolApproval.toolCall.toolName,
|
|
7689
7729
|
input: toolApproval.toolCall.input,
|
|
7690
|
-
error:
|
|
7730
|
+
error: require_dist_CufwpBZM.getErrorMessage$1(toolApproval.error),
|
|
7691
7731
|
title: toolApproval.toolCall.title,
|
|
7692
7732
|
...toolApproval.toolCall.dynamic === true ? { dynamic: true } : {},
|
|
7693
7733
|
...toolApproval.toolCall.toolMetadata != null ? { toolMetadata: toolApproval.toolCall.toolMetadata } : {}
|
|
@@ -7796,7 +7836,7 @@ var DefaultStreamTextResult = class {
|
|
|
7796
7836
|
}
|
|
7797
7837
|
abortSignal?.addEventListener("abort", cleanupStepTimeouts, { once: true });
|
|
7798
7838
|
try {
|
|
7799
|
-
stepFinish = new
|
|
7839
|
+
stepFinish = new require_dist_CufwpBZM.DelayedPromise();
|
|
7800
7840
|
const stepInputMessages = [...initialMessages, ...responseMessages];
|
|
7801
7841
|
const prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({
|
|
7802
7842
|
model,
|
|
@@ -8345,7 +8385,7 @@ var DefaultStreamTextResult = class {
|
|
|
8345
8385
|
get elementStream() {
|
|
8346
8386
|
var _a23, _b, _c;
|
|
8347
8387
|
const transform = (_a23 = this.outputSpecification) == null ? void 0 : _a23.createElementStreamTransform();
|
|
8348
|
-
if (transform == null) throw new
|
|
8388
|
+
if (transform == null) throw new require_dist_CufwpBZM.UnsupportedFunctionalityError({ functionality: `element streams in ${(_c = (_b = this.outputSpecification) == null ? void 0 : _b.name) != null ? _c : "text"} mode` });
|
|
8349
8389
|
return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
|
|
8350
8390
|
}
|
|
8351
8391
|
getOutputPromise() {
|
|
@@ -8701,7 +8741,7 @@ var ToolLoopAgent = class {
|
|
|
8701
8741
|
async prepareCall(options) {
|
|
8702
8742
|
var _a23, _b, _c, _d;
|
|
8703
8743
|
if (this.settings.callOptionsSchema != null && options.options !== void 0) {
|
|
8704
|
-
const validatedOptions = await
|
|
8744
|
+
const validatedOptions = await require_dist_CufwpBZM.validateTypes({
|
|
8705
8745
|
value: options.options,
|
|
8706
8746
|
schema: this.settings.callOptionsSchema,
|
|
8707
8747
|
context: { field: "options" }
|
|
@@ -8761,7 +8801,7 @@ var ToolLoopAgent = class {
|
|
|
8761
8801
|
}
|
|
8762
8802
|
};
|
|
8763
8803
|
var toolMetadataSchema2 = zod_v4.z.record(zod_v4.z.string(), jsonValueSchema.optional());
|
|
8764
|
-
|
|
8804
|
+
require_dist_CufwpBZM.lazySchema(() => {
|
|
8765
8805
|
const approvalRequestedSchema = zod_v4.z.object({
|
|
8766
8806
|
id: zod_v4.z.string(),
|
|
8767
8807
|
approved: zod_v4.z.never().optional(),
|
|
@@ -8776,7 +8816,7 @@ require_dist_ByO0vuJJ.lazySchema(() => {
|
|
|
8776
8816
|
});
|
|
8777
8817
|
const approvalGrantedSchema = approvalRespondedSchema.extend({ approved: zod_v4.z.literal(true) });
|
|
8778
8818
|
const approvalDeniedSchema = approvalRespondedSchema.extend({ approved: zod_v4.z.literal(false) });
|
|
8779
|
-
return
|
|
8819
|
+
return require_dist_CufwpBZM.zodSchema(zod_v4.z.array(zod_v4.z.object({
|
|
8780
8820
|
id: zod_v4.z.string(),
|
|
8781
8821
|
role: zod_v4.z.enum([
|
|
8782
8822
|
"system",
|
|
@@ -9039,7 +9079,7 @@ async function embed({ model: modelArg, value, providerOptions, maxRetries: maxR
|
|
|
9039
9079
|
maxRetries: maxRetriesArg,
|
|
9040
9080
|
abortSignal
|
|
9041
9081
|
});
|
|
9042
|
-
const headersWithUserAgent =
|
|
9082
|
+
const headersWithUserAgent = require_dist_CufwpBZM.withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);
|
|
9043
9083
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
|
9044
9084
|
model,
|
|
9045
9085
|
telemetry,
|
|
@@ -9093,7 +9133,7 @@ async function embed({ model: modelArg, value, providerOptions, maxRetries: maxR
|
|
|
9093
9133
|
"ai.usage.tokens": usage2.tokens
|
|
9094
9134
|
}
|
|
9095
9135
|
}));
|
|
9096
|
-
if (embedding2 == null) throw new
|
|
9136
|
+
if (embedding2 == null) throw new require_dist_CufwpBZM.InvalidResponseDataError({
|
|
9097
9137
|
data: modelResponse.embeddings,
|
|
9098
9138
|
message: "No embedding generated."
|
|
9099
9139
|
});
|
|
@@ -9140,12 +9180,12 @@ var DefaultEmbedResult = class {
|
|
|
9140
9180
|
}
|
|
9141
9181
|
};
|
|
9142
9182
|
new TextEncoder();
|
|
9143
|
-
|
|
9183
|
+
require_dist_CufwpBZM.createIdGenerator({
|
|
9144
9184
|
prefix: "aiobj",
|
|
9145
9185
|
size: 24
|
|
9146
9186
|
});
|
|
9147
9187
|
var { atob } = globalThis;
|
|
9148
|
-
|
|
9188
|
+
require_dist_CufwpBZM.createIdGenerator({
|
|
9149
9189
|
prefix: "aiobj",
|
|
9150
9190
|
size: 24
|
|
9151
9191
|
});
|
|
@@ -9173,6 +9213,11 @@ function hasReplayableReasoningMetadata(providerOptions) {
|
|
|
9173
9213
|
return Object.values(providerOptions ?? {}).some((value) => !!value && typeof value === "object" && REPLAYABLE_REASONING_KEYS.some((key) => key in value));
|
|
9174
9214
|
}
|
|
9175
9215
|
// src/agent/message-list/adapters/AIV5Adapter.ts
|
|
9216
|
+
function getProviderCustomModelPart(part) {
|
|
9217
|
+
if (!part || typeof part !== "object") return void 0;
|
|
9218
|
+
if (!("type" in part) || part.type !== "custom" || !("kind" in part) || typeof part.kind !== "string" || part.kind.length === 0) return;
|
|
9219
|
+
return part;
|
|
9220
|
+
}
|
|
9176
9221
|
/**
|
|
9177
9222
|
* Compact malformed entries and filter out empty text parts from message parts arrays.
|
|
9178
9223
|
* Empty text blocks are not allowed by Anthropic's API and cause request failures.
|
|
@@ -9475,7 +9520,10 @@ var AIV5Adapter = class {
|
|
|
9475
9520
|
...part,
|
|
9476
9521
|
data: transformToolStateDataForDisplay(part.data, part.type === "data-tool-call-suspended" ? "suspend" : "approval", transformToolPayloads)
|
|
9477
9522
|
});
|
|
9478
|
-
else if (part.type === "
|
|
9523
|
+
else if (part.type === "custom") {
|
|
9524
|
+
parts.push(part);
|
|
9525
|
+
hasNonToolReasoningParts = true;
|
|
9526
|
+
} else if (part.type === "error") {
|
|
9479
9527
|
parts.push(part);
|
|
9480
9528
|
hasNonToolReasoningParts = true;
|
|
9481
9529
|
} else {
|
|
@@ -9573,6 +9621,12 @@ var AIV5Adapter = class {
|
|
|
9573
9621
|
let content = void 0;
|
|
9574
9622
|
if (textParts.length > 0) content = textParts.map((p) => p.text).join("");
|
|
9575
9623
|
const filteredV2Parts = filterEmptyTextParts(parts.map((p) => {
|
|
9624
|
+
const providerCustomPart = getProviderCustomModelPart(p);
|
|
9625
|
+
if (providerCustomPart) return {
|
|
9626
|
+
type: "custom",
|
|
9627
|
+
kind: providerCustomPart.kind,
|
|
9628
|
+
providerMetadata: providerCustomPart.providerMetadata
|
|
9629
|
+
};
|
|
9576
9630
|
if (require_dist.isToolUIPart(p)) {
|
|
9577
9631
|
const toolName = getToolName(p);
|
|
9578
9632
|
const callProviderMetadata = "callProviderMetadata" in p ? p.callProviderMetadata : void 0;
|
|
@@ -9761,141 +9815,149 @@ var AIV5Adapter = class {
|
|
|
9761
9815
|
const toolInvocations = [];
|
|
9762
9816
|
const reasoningParts = [];
|
|
9763
9817
|
const experimental_attachments = [];
|
|
9764
|
-
for (const part of content)
|
|
9765
|
-
const
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
textPart.providerMetadata = part.providerOptions;
|
|
9771
|
-
textPart.createdAt = getMastraCreatedAt(part.providerOptions);
|
|
9772
|
-
}
|
|
9773
|
-
mastraDBParts.push(textPart);
|
|
9774
|
-
} else if (part.type === "tool-call") {
|
|
9775
|
-
const toolCallPart = part;
|
|
9776
|
-
const toolInvocationPart = {
|
|
9777
|
-
type: "tool-invocation",
|
|
9778
|
-
toolInvocation: {
|
|
9779
|
-
toolCallId: toolCallPart.toolCallId,
|
|
9780
|
-
toolName: require_to_prompt.sanitizeToolName(toolCallPart.toolName),
|
|
9781
|
-
args: toolCallPart.input,
|
|
9782
|
-
state: "call"
|
|
9783
|
-
}
|
|
9784
|
-
};
|
|
9785
|
-
if (part.providerOptions) {
|
|
9786
|
-
toolInvocationPart.providerMetadata = part.providerOptions;
|
|
9787
|
-
toolInvocationPart.createdAt = getMastraCreatedAt(part.providerOptions);
|
|
9788
|
-
}
|
|
9789
|
-
const toolCallProviderExecuted = part.providerExecuted;
|
|
9790
|
-
if (toolCallProviderExecuted !== void 0) toolInvocationPart.providerExecuted = toolCallProviderExecuted;
|
|
9791
|
-
mastraDBParts.push(toolInvocationPart);
|
|
9792
|
-
toolInvocations.push({
|
|
9793
|
-
toolCallId: toolCallPart.toolCallId,
|
|
9794
|
-
toolName: require_to_prompt.sanitizeToolName(toolCallPart.toolName),
|
|
9795
|
-
args: toolCallPart.input,
|
|
9796
|
-
state: "call"
|
|
9797
|
-
});
|
|
9798
|
-
} else if (part.type === "tool-result") {
|
|
9799
|
-
const toolResultPart = part;
|
|
9800
|
-
const matchingCall = toolInvocations.find((inv) => inv.toolCallId === toolResultPart.toolCallId);
|
|
9801
|
-
const matchingV2Part = mastraDBParts.find((p) => p.type === "tool-invocation" && "toolInvocation" in p && p.toolInvocation.toolCallId === toolResultPart.toolCallId);
|
|
9802
|
-
const updateMatchingCallInvocationResult = (toolResultPart, matchingCall) => {
|
|
9803
|
-
const normalized = normalizeToolOutput(toolResultPart.output);
|
|
9804
|
-
matchingCall.state = normalized.isError ? "output-error" : "result";
|
|
9805
|
-
matchingCall.result = normalized.output;
|
|
9806
|
-
if (normalized.isError) matchingCall.errorText = typeof normalized.output === "string" ? normalized.output : JSON.stringify(normalized.output);
|
|
9807
|
-
};
|
|
9808
|
-
const recoveredArgs = context.dbMessages ? findToolCallArgs(context.dbMessages, toolResultPart.toolCallId) : void 0;
|
|
9809
|
-
const fallbackArgs = recoveredArgs && Object.keys(recoveredArgs).length > 0 ? recoveredArgs : toolResultPart.input ?? {};
|
|
9810
|
-
if (matchingCall) updateMatchingCallInvocationResult(toolResultPart, matchingCall);
|
|
9811
|
-
else {
|
|
9812
|
-
const call = {
|
|
9813
|
-
state: "call",
|
|
9814
|
-
toolCallId: toolResultPart.toolCallId,
|
|
9815
|
-
toolName: require_to_prompt.sanitizeToolName(toolResultPart.toolName),
|
|
9816
|
-
args: fallbackArgs
|
|
9818
|
+
for (const part of content) {
|
|
9819
|
+
const providerCustomPart = getProviderCustomModelPart(part);
|
|
9820
|
+
if (part.type === "text") {
|
|
9821
|
+
const textPart = {
|
|
9822
|
+
type: "text",
|
|
9823
|
+
text: part.text
|
|
9817
9824
|
};
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
const resultProviderExecuted = toolResultPart.providerExecuted;
|
|
9822
|
-
if (matchingV2Part && matchingV2Part.type === "tool-invocation") {
|
|
9823
|
-
updateMatchingCallInvocationResult(toolResultPart, matchingV2Part.toolInvocation);
|
|
9824
|
-
if (resultProviderExecuted !== void 0) matchingV2Part.providerExecuted = resultProviderExecuted;
|
|
9825
|
-
if (toolResultPart.providerOptions) {
|
|
9826
|
-
matchingV2Part.providerMetadata = preserveResponseItemIdsOnMerge(matchingV2Part.providerMetadata, toolResultPart.providerOptions, toolResultPart.providerOptions);
|
|
9827
|
-
matchingV2Part.createdAt = getMastraCreatedAt(toolResultPart.providerOptions) ?? matchingV2Part.createdAt;
|
|
9825
|
+
if (part.providerOptions) {
|
|
9826
|
+
textPart.providerMetadata = part.providerOptions;
|
|
9827
|
+
textPart.createdAt = getMastraCreatedAt(part.providerOptions);
|
|
9828
9828
|
}
|
|
9829
|
-
|
|
9829
|
+
mastraDBParts.push(textPart);
|
|
9830
|
+
} else if (part.type === "tool-call") {
|
|
9831
|
+
const toolCallPart = part;
|
|
9830
9832
|
const toolInvocationPart = {
|
|
9831
9833
|
type: "tool-invocation",
|
|
9832
9834
|
toolInvocation: {
|
|
9833
|
-
toolCallId:
|
|
9834
|
-
toolName: require_to_prompt.sanitizeToolName(
|
|
9835
|
-
args:
|
|
9835
|
+
toolCallId: toolCallPart.toolCallId,
|
|
9836
|
+
toolName: require_to_prompt.sanitizeToolName(toolCallPart.toolName),
|
|
9837
|
+
args: toolCallPart.input,
|
|
9836
9838
|
state: "call"
|
|
9837
9839
|
}
|
|
9838
9840
|
};
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
toolInvocationPart.providerMetadata = toolResultPart.providerOptions;
|
|
9843
|
-
toolInvocationPart.createdAt = getMastraCreatedAt(toolResultPart.providerOptions);
|
|
9841
|
+
if (part.providerOptions) {
|
|
9842
|
+
toolInvocationPart.providerMetadata = part.providerOptions;
|
|
9843
|
+
toolInvocationPart.createdAt = getMastraCreatedAt(part.providerOptions);
|
|
9844
9844
|
}
|
|
9845
|
+
const toolCallProviderExecuted = part.providerExecuted;
|
|
9846
|
+
if (toolCallProviderExecuted !== void 0) toolInvocationPart.providerExecuted = toolCallProviderExecuted;
|
|
9845
9847
|
mastraDBParts.push(toolInvocationPart);
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
|
|
9862
|
-
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9848
|
+
toolInvocations.push({
|
|
9849
|
+
toolCallId: toolCallPart.toolCallId,
|
|
9850
|
+
toolName: require_to_prompt.sanitizeToolName(toolCallPart.toolName),
|
|
9851
|
+
args: toolCallPart.input,
|
|
9852
|
+
state: "call"
|
|
9853
|
+
});
|
|
9854
|
+
} else if (part.type === "tool-result") {
|
|
9855
|
+
const toolResultPart = part;
|
|
9856
|
+
const matchingCall = toolInvocations.find((inv) => inv.toolCallId === toolResultPart.toolCallId);
|
|
9857
|
+
const matchingV2Part = mastraDBParts.find((p) => p.type === "tool-invocation" && "toolInvocation" in p && p.toolInvocation.toolCallId === toolResultPart.toolCallId);
|
|
9858
|
+
const updateMatchingCallInvocationResult = (toolResultPart, matchingCall) => {
|
|
9859
|
+
const normalized = normalizeToolOutput(toolResultPart.output);
|
|
9860
|
+
matchingCall.state = normalized.isError ? "output-error" : "result";
|
|
9861
|
+
matchingCall.result = normalized.output;
|
|
9862
|
+
if (normalized.isError) matchingCall.errorText = typeof normalized.output === "string" ? normalized.output : JSON.stringify(normalized.output);
|
|
9863
|
+
};
|
|
9864
|
+
const recoveredArgs = context.dbMessages ? findToolCallArgs(context.dbMessages, toolResultPart.toolCallId) : void 0;
|
|
9865
|
+
const fallbackArgs = recoveredArgs && Object.keys(recoveredArgs).length > 0 ? recoveredArgs : toolResultPart.input ?? {};
|
|
9866
|
+
if (matchingCall) updateMatchingCallInvocationResult(toolResultPart, matchingCall);
|
|
9867
|
+
else {
|
|
9868
|
+
const call = {
|
|
9869
|
+
state: "call",
|
|
9870
|
+
toolCallId: toolResultPart.toolCallId,
|
|
9871
|
+
toolName: require_to_prompt.sanitizeToolName(toolResultPart.toolName),
|
|
9872
|
+
args: fallbackArgs
|
|
9873
|
+
};
|
|
9874
|
+
updateMatchingCallInvocationResult(toolResultPart, call);
|
|
9875
|
+
toolInvocations.push(call);
|
|
9876
|
+
}
|
|
9877
|
+
const resultProviderExecuted = toolResultPart.providerExecuted;
|
|
9878
|
+
if (matchingV2Part && matchingV2Part.type === "tool-invocation") {
|
|
9879
|
+
updateMatchingCallInvocationResult(toolResultPart, matchingV2Part.toolInvocation);
|
|
9880
|
+
if (resultProviderExecuted !== void 0) matchingV2Part.providerExecuted = resultProviderExecuted;
|
|
9881
|
+
if (toolResultPart.providerOptions) {
|
|
9882
|
+
matchingV2Part.providerMetadata = preserveResponseItemIdsOnMerge(matchingV2Part.providerMetadata, toolResultPart.providerOptions, toolResultPart.providerOptions);
|
|
9883
|
+
matchingV2Part.createdAt = getMastraCreatedAt(toolResultPart.providerOptions) ?? matchingV2Part.createdAt;
|
|
9884
|
+
}
|
|
9885
|
+
} else {
|
|
9886
|
+
const toolInvocationPart = {
|
|
9887
|
+
type: "tool-invocation",
|
|
9888
|
+
toolInvocation: {
|
|
9889
|
+
toolCallId: toolResultPart.toolCallId,
|
|
9890
|
+
toolName: require_to_prompt.sanitizeToolName(toolResultPart.toolName),
|
|
9891
|
+
args: fallbackArgs,
|
|
9892
|
+
state: "call"
|
|
9893
|
+
}
|
|
9894
|
+
};
|
|
9895
|
+
updateMatchingCallInvocationResult(toolResultPart, toolInvocationPart.toolInvocation);
|
|
9896
|
+
if (resultProviderExecuted !== void 0) toolInvocationPart.providerExecuted = resultProviderExecuted;
|
|
9897
|
+
if (toolResultPart.providerOptions) {
|
|
9898
|
+
toolInvocationPart.providerMetadata = toolResultPart.providerOptions;
|
|
9899
|
+
toolInvocationPart.createdAt = getMastraCreatedAt(toolResultPart.providerOptions);
|
|
9900
|
+
}
|
|
9901
|
+
mastraDBParts.push(toolInvocationPart);
|
|
9902
|
+
}
|
|
9903
|
+
} else if (part.type === "reasoning") {
|
|
9904
|
+
const v2ReasoningPart = {
|
|
9905
|
+
type: "reasoning",
|
|
9906
|
+
reasoning: part.text,
|
|
9907
|
+
details: [{
|
|
9908
|
+
type: "text",
|
|
9909
|
+
text: part.text
|
|
9910
|
+
}]
|
|
9911
|
+
};
|
|
9912
|
+
if (part.providerOptions) {
|
|
9913
|
+
v2ReasoningPart.providerMetadata = part.providerOptions;
|
|
9914
|
+
v2ReasoningPart.createdAt = getMastraCreatedAt(part.providerOptions);
|
|
9915
|
+
}
|
|
9916
|
+
mastraDBParts.push(v2ReasoningPart);
|
|
9917
|
+
reasoningParts.push(part.text);
|
|
9918
|
+
} else if (providerCustomPart) mastraDBParts.push({
|
|
9919
|
+
type: "custom",
|
|
9920
|
+
kind: providerCustomPart.kind,
|
|
9921
|
+
providerMetadata: providerCustomPart.providerMetadata ?? providerCustomPart.providerOptions
|
|
9879
9922
|
});
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9923
|
+
else if (part.type === "image") {
|
|
9924
|
+
const imagePart = part;
|
|
9925
|
+
const mimeType = imagePart.mediaType || "image/jpeg";
|
|
9926
|
+
const imageData = this.getDataStringFromAIV5DataPart(imagePart);
|
|
9927
|
+
const imageFilePart = {
|
|
9928
|
+
type: "file",
|
|
9929
|
+
data: imageData,
|
|
9930
|
+
mimeType
|
|
9931
|
+
};
|
|
9932
|
+
if (part.providerOptions) {
|
|
9933
|
+
imageFilePart.providerMetadata = part.providerOptions;
|
|
9934
|
+
imageFilePart.createdAt = getMastraCreatedAt(part.providerOptions);
|
|
9935
|
+
}
|
|
9936
|
+
mastraDBParts.push(imageFilePart);
|
|
9937
|
+
experimental_attachments.push({
|
|
9938
|
+
url: imageData,
|
|
9939
|
+
contentType: mimeType
|
|
9940
|
+
});
|
|
9941
|
+
} else if (part.type === "file") {
|
|
9942
|
+
const filePart = part;
|
|
9943
|
+
const mimeType = filePart.mediaType || "application/octet-stream";
|
|
9944
|
+
const fileData = this.getDataStringFromAIV5DataPart(filePart);
|
|
9945
|
+
const v2FilePart = {
|
|
9946
|
+
type: "file",
|
|
9947
|
+
data: fileData,
|
|
9948
|
+
mimeType
|
|
9949
|
+
};
|
|
9950
|
+
if (part.providerOptions) {
|
|
9951
|
+
v2FilePart.providerMetadata = part.providerOptions;
|
|
9952
|
+
v2FilePart.createdAt = getMastraCreatedAt(part.providerOptions);
|
|
9953
|
+
}
|
|
9954
|
+
if (filePart.filename) v2FilePart.filename = filePart.filename;
|
|
9955
|
+
mastraDBParts.push(v2FilePart);
|
|
9956
|
+
experimental_attachments.push({
|
|
9957
|
+
url: fileData,
|
|
9958
|
+
contentType: mimeType
|
|
9959
|
+
});
|
|
9892
9960
|
}
|
|
9893
|
-
if (filePart.filename) v2FilePart.filename = filePart.filename;
|
|
9894
|
-
mastraDBParts.push(v2FilePart);
|
|
9895
|
-
experimental_attachments.push({
|
|
9896
|
-
url: fileData,
|
|
9897
|
-
contentType: mimeType
|
|
9898
|
-
});
|
|
9899
9961
|
}
|
|
9900
9962
|
const filteredMastraDBParts = filterEmptyTextParts(mastraDBParts);
|
|
9901
9963
|
const contentString = filteredMastraDBParts.filter((p) => p.type === "text").map((p) => p.text).join("\n");
|
|
@@ -11624,6 +11686,44 @@ function isUnforwardableReasoningOnlyMessage(message) {
|
|
|
11624
11686
|
if (message.role !== "assistant" || !Array.isArray(message.content) || message.content.length === 0) return false;
|
|
11625
11687
|
return message.content.every((part) => part.type === "reasoning" && !hasReplayableReasoningMetadata(part.providerOptions));
|
|
11626
11688
|
}
|
|
11689
|
+
function getProviderCustomUIPart(part) {
|
|
11690
|
+
if (!part || typeof part !== "object") return void 0;
|
|
11691
|
+
if (!("type" in part) || part.type !== "custom" || !("kind" in part) || typeof part.kind !== "string" || part.kind.length === 0) return;
|
|
11692
|
+
return part;
|
|
11693
|
+
}
|
|
11694
|
+
function convertUIMessageWithProviderCustomParts(uiMsg) {
|
|
11695
|
+
const produced = [];
|
|
11696
|
+
let regularParts = [];
|
|
11697
|
+
const flushRegularParts = () => {
|
|
11698
|
+
if (regularParts.length === 0) return;
|
|
11699
|
+
produced.push(...require_dist.convertToModelMessages([{
|
|
11700
|
+
...uiMsg,
|
|
11701
|
+
parts: regularParts
|
|
11702
|
+
}]));
|
|
11703
|
+
regularParts = [];
|
|
11704
|
+
};
|
|
11705
|
+
for (const part of uiMsg.parts) {
|
|
11706
|
+
const customPart = getProviderCustomUIPart(part);
|
|
11707
|
+
if (!customPart) {
|
|
11708
|
+
regularParts.push(part);
|
|
11709
|
+
continue;
|
|
11710
|
+
}
|
|
11711
|
+
flushRegularParts();
|
|
11712
|
+
if (uiMsg.role === "assistant") {
|
|
11713
|
+
const message = {
|
|
11714
|
+
role: "assistant",
|
|
11715
|
+
content: [{
|
|
11716
|
+
type: "custom",
|
|
11717
|
+
kind: customPart.kind,
|
|
11718
|
+
...customPart.providerMetadata ? { providerOptions: customPart.providerMetadata } : {}
|
|
11719
|
+
}]
|
|
11720
|
+
};
|
|
11721
|
+
produced.push(message);
|
|
11722
|
+
}
|
|
11723
|
+
}
|
|
11724
|
+
flushRegularParts();
|
|
11725
|
+
return produced;
|
|
11726
|
+
}
|
|
11627
11727
|
/**
|
|
11628
11728
|
* Converts AIV5 UI messages to AIV5 Model messages.
|
|
11629
11729
|
* Handles sanitization, step-start insertion, provider options restoration, and Anthropic compatibility.
|
|
@@ -11637,7 +11737,7 @@ function aiV5UIMessagesToAIV5ModelMessages(messages, dbMessages, mode = "respons
|
|
|
11637
11737
|
const converted = [];
|
|
11638
11738
|
const dbMessagesById = new Map(dbMessages.map((message) => [message.id, message]));
|
|
11639
11739
|
for (const uiMsg of preprocessed) {
|
|
11640
|
-
const produced = applyProviderToolErrorOutputs(
|
|
11740
|
+
const produced = applyProviderToolErrorOutputs(convertUIMessageWithProviderCustomParts(uiMsg), dbMessagesById.get(uiMsg.id));
|
|
11641
11741
|
if (produced.length === 0) continue;
|
|
11642
11742
|
const providerMetadata = uiMsg.metadata && typeof uiMsg.metadata === "object" && "providerMetadata" in uiMsg.metadata ? uiMsg.metadata.providerMetadata : void 0;
|
|
11643
11743
|
if (providerMetadata) {
|
|
@@ -13921,6 +14021,7 @@ var MessageList = class MessageList {
|
|
|
13921
14021
|
return message;
|
|
13922
14022
|
});
|
|
13923
14023
|
messages = dropCrossProviderExecutedParts(messages, this.messages, options.targetProvider, this.logger);
|
|
14024
|
+
messages = pruneOpenAICompactionHistory(messages, options.targetProvider);
|
|
13924
14025
|
return messages.filter((message) => message != null).map(require_to_prompt.aiV5ModelMessageToV2PromptMessage).filter((message) => message.role === "system" || typeof message.content === "string" || message.content.length > 0);
|
|
13925
14026
|
}
|
|
13926
14027
|
},
|