maka-agent 0.2.0-dev.62.20260928 → 0.2.0-dev.64.20260929
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/LICENSE +15 -15
- package/THIRD_PARTY_NOTICES.txt +26 -26
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/dual-version-agent.js +12 -12
- package/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js +52 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.js +5 -4
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/guards.gen.js +7 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/zod.gen.js +51 -8
- package/node_modules/@agentclientprotocol/sdk/package.json +2 -2
- package/node_modules/@agentclientprotocol/sdk/schema/schema.json +90 -2
- package/node_modules/@agentclientprotocol/sdk/schema/v2/schema.unstable.json +103 -12
- package/node_modules/@ai-sdk/anthropic/CHANGELOG.md +140 -0
- package/node_modules/@ai-sdk/anthropic/README.md +1 -1
- package/node_modules/@ai-sdk/anthropic/dist/index.js +1622 -868
- package/node_modules/@ai-sdk/anthropic/dist/internal/index.js +1516 -763
- package/node_modules/@ai-sdk/anthropic/docs/05-anthropic.mdx +483 -62
- package/node_modules/@ai-sdk/anthropic/package.json +4 -4
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/approval-continuation.js +0 -1
- package/node_modules/@ai-sdk/code-mode/dist/code-mode-tool.js +59 -0
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/errors.js +0 -8
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/interrupt-continuation.js +0 -2
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/tool-prompt.js +43 -15
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/package.json +3 -3
- package/node_modules/@ai-sdk/cohere/CHANGELOG.md +99 -0
- package/node_modules/@ai-sdk/cohere/README.md +1 -1
- package/node_modules/@ai-sdk/cohere/dist/index.js +35 -49
- package/node_modules/@ai-sdk/cohere/docs/25-cohere.mdx +11 -9
- package/node_modules/@ai-sdk/cohere/package.json +4 -4
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/gateway/CHANGELOG.md +183 -0
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/gateway/README.md +1 -1
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/gateway/dist/index.js +587 -245
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/gateway/docs/00-ai-gateway.mdx +235 -30
- package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/gateway/package.json +4 -4
- package/node_modules/@ai-sdk/google/CHANGELOG.md +180 -0
- package/node_modules/@ai-sdk/google/README.md +1 -1
- package/node_modules/@ai-sdk/google/dist/index.js +1147 -1130
- package/node_modules/@ai-sdk/google/dist/internal/index.js +809 -889
- package/node_modules/@ai-sdk/google/docs/15-google.mdx +224 -41
- package/node_modules/@ai-sdk/google/package.json +4 -4
- package/node_modules/@ai-sdk/open-responses/CHANGELOG.md +109 -0
- package/node_modules/@ai-sdk/open-responses/dist/index.js +419 -183
- package/node_modules/@ai-sdk/open-responses/docs/06-open-responses.mdx +121 -6
- package/node_modules/@ai-sdk/open-responses/package.json +4 -4
- package/node_modules/@ai-sdk/openai/CHANGELOG.md +147 -0
- package/node_modules/@ai-sdk/openai/README.md +27 -2
- package/node_modules/@ai-sdk/openai/dist/index.js +2445 -1828
- package/node_modules/@ai-sdk/openai/dist/internal/index.js +2170 -2041
- package/node_modules/@ai-sdk/openai/docs/03-openai.mdx +311 -102
- package/node_modules/@ai-sdk/openai/package.json +4 -4
- package/node_modules/@ai-sdk/openai-compatible/CHANGELOG.md +110 -0
- package/node_modules/@ai-sdk/openai-compatible/dist/index.js +120 -130
- package/node_modules/@ai-sdk/openai-compatible/dist/internal/index.js +22 -14
- package/node_modules/@ai-sdk/openai-compatible/docs/index.mdx +2 -0
- package/node_modules/@ai-sdk/openai-compatible/package.json +4 -4
- package/node_modules/@ai-sdk/{anthropic/node_modules/@ai-sdk/provider → provider}/CHANGELOG.md +47 -0
- package/node_modules/@ai-sdk/{cohere/node_modules/@ai-sdk/provider → provider}/dist/index.js +127 -102
- package/node_modules/@ai-sdk/{anthropic/node_modules/@ai-sdk/provider → provider}/package.json +1 -1
- package/node_modules/@ai-sdk/provider-utils/CHANGELOG.md +99 -0
- package/node_modules/@ai-sdk/provider-utils/dist/experimental-evaluation/index.js +1618 -0
- package/node_modules/@ai-sdk/provider-utils/dist/index.js +470 -268
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +3 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Dispatcher.md +1 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/balanced-pool.js +4 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +23 -8
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +84 -19
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +21 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/retry-handler.js +109 -23
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/cache.js +20 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +338 -46
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/connection.js +19 -9
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
- package/node_modules/@ai-sdk/provider-utils/package.json +7 -2
- package/node_modules/@earendil-works/pi-tui/README.md +8 -2
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +18 -11
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +7 -6
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +23 -22
- package/node_modules/@earendil-works/pi-tui/dist/index.js +2 -0
- package/node_modules/@earendil-works/pi-tui/dist/latex.js +109 -16
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +3 -44
- package/node_modules/@earendil-works/pi-tui/dist/native-platform.js +42 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +2 -20
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +25 -6
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +4 -0
- package/node_modules/@earendil-works/pi-tui/native/clipboard.h +170 -0
- package/node_modules/@earendil-works/pi-tui/native/darwin/README.md +8 -6
- package/node_modules/@earendil-works/pi-tui/native/darwin/build.sh +12 -5
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/{darwin-modifiers.node → darwin-platform.node} +0 -0
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/{darwin-modifiers.node → darwin-platform.node} +0 -0
- package/node_modules/@earendil-works/pi-tui/native/darwin/src/darwin-platform.m +93 -0
- package/node_modules/@earendil-works/pi-tui/native/linux/README.md +23 -0
- package/node_modules/@earendil-works/pi-tui/native/linux/build.sh +65 -0
- package/node_modules/@earendil-works/pi-tui/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/linux/src/clipboard-worker.h +70 -0
- package/node_modules/@earendil-works/pi-tui/native/linux/src/linux-platform-x11.c +274 -0
- package/node_modules/@earendil-works/pi-tui/native/napi.h +89 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/README.md +16 -7
- package/node_modules/@earendil-works/pi-tui/native/win32/build.mjs +7 -4
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/src/win32-platform.c +241 -0
- package/node_modules/@earendil-works/pi-tui/package.json +11 -4
- package/node_modules/@larksuiteoapi/node-sdk/README.md +20 -0
- package/node_modules/@larksuiteoapi/node-sdk/README.zh.md +20 -0
- package/node_modules/@larksuiteoapi/node-sdk/es/index.js +33 -1
- package/node_modules/@larksuiteoapi/node-sdk/lib/index.js +33 -1
- package/node_modules/@larksuiteoapi/node-sdk/package.json +1 -1
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +17 -0
- package/node_modules/@maka/acp-executor-plugin/package.json +1 -1
- package/node_modules/@maka/core/dist/model-web-search.js +2 -3
- package/node_modules/@maka/core/dist/relative-time.js +19 -20
- package/node_modules/@maka/eval/harbor/egress_filter.py +64 -47
- package/node_modules/@maka/eval/harbor/eval_framework.py +3 -3
- package/node_modules/@maka/eval/harbor/run_trial.py +2 -2
- package/node_modules/@maka/eval/node_modules/undici/README.md +10 -1
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Agent.md +8 -8
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +25 -0
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Fetch.md +10 -0
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Pool.md +5 -6
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +10 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/api/readable.js +1 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +0 -39
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +6 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +90 -7
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +5 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +72 -13
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +4 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +236 -69
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cache/cache.js +17 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/index.js +19 -7
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +3 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +22 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/data-url.js +6 -6
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata.js +30 -36
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +34 -31
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +46 -25
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/request.js +74 -79
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/response.js +43 -44
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/util.js +7 -7
- package/node_modules/@maka/eval/node_modules/undici/lib/web/infra/index.js +16 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/web/webidl/index.js +2 -14
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/connection.js +33 -12
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/events.js +43 -26
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +2 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/websocket.js +44 -41
- package/node_modules/@maka/eval/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/mcp/package.json +1 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +15 -3
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +33 -3
- package/node_modules/@maka/runtime/dist/deepseek-web-search-codec.js +71 -0
- package/node_modules/@maka/runtime/dist/history-compaction.js +11 -4
- package/node_modules/@maka/runtime/dist/model-adapter.js +9 -5
- package/node_modules/@maka/runtime/dist/model-factory.js +4 -0
- package/node_modules/@maka/runtime/dist/plugin-agent-service.js +5 -13
- package/node_modules/@maka/runtime/dist/plugin-attachment-service.js +5 -13
- package/node_modules/@maka/runtime/dist/plugin-composition-loader.js +26 -36
- package/node_modules/@maka/runtime/dist/plugin-data-services.js +9 -26
- package/node_modules/@maka/runtime/dist/plugin-fs-service.js +5 -13
- package/node_modules/@maka/runtime/dist/plugin-goal-service.js +5 -13
- package/node_modules/@maka/runtime/dist/plugin-internals.js +78 -0
- package/node_modules/@maka/runtime/dist/plugin-llm-service.js +5 -13
- package/node_modules/@maka/runtime/dist/plugin-runtime.js +4 -32
- package/node_modules/@maka/runtime/dist/plugin-session-query-service.js +5 -13
- package/node_modules/@maka/runtime/dist/plugin-shell-service.js +5 -13
- package/node_modules/@maka/runtime/dist/plugin-web-service.js +5 -13
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +3 -3
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +161 -104
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +3 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Dispatcher.md +1 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/balanced-pool.js +4 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +23 -8
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +84 -19
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +21 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/retry-handler.js +109 -23
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/cache.js +20 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +338 -46
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/connection.js +19 -9
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/undici/README.md +10 -1
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Agent.md +8 -8
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +25 -0
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Fetch.md +10 -0
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Pool.md +5 -6
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +10 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/api/readable.js +1 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +0 -39
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +6 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +90 -7
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +5 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +72 -13
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +4 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +236 -69
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cache/cache.js +17 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/index.js +19 -7
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +3 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +22 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/data-url.js +6 -6
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata.js +30 -36
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +34 -31
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +46 -25
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/request.js +74 -79
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/response.js +43 -44
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/util.js +7 -7
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/infra/index.js +16 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/webidl/index.js +2 -14
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/connection.js +33 -12
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/events.js +43 -26
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +2 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/websocket.js +44 -41
- package/node_modules/@maka/runtime/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/runtime/package.json +11 -11
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +3 -7
- package/node_modules/@maka/runtime-host/dist/candidate-cli.js +7 -7
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +20 -8
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +107 -63
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +1 -3
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +51 -16
- package/node_modules/@maka/runtime-host/package.json +2 -2
- package/node_modules/@maka/storage/dist/project-catalog.js +13 -20
- package/node_modules/@modelcontextprotocol/client/dist/index-BCtJi0p5.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-CEk3qkZM.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +375 -60
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +369 -61
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/{src-NAgB4Mp8.cjs → src-D0qEN74R.cjs} +111 -38
- package/node_modules/@modelcontextprotocol/client/dist/{src-D_zzAWoS.mjs → src-DDAAhLnO.mjs} +106 -33
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +8 -2
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +8 -2
- package/node_modules/@modelcontextprotocol/{core/dist/auth-hYtaIUZm.d.cts.map → client/node_modules/@modelcontextprotocol/core/dist/auth--n_Yzytt.d.cts.map} +1 -1
- package/node_modules/@modelcontextprotocol/{core/dist/auth-CfDMXiII.cjs → client/node_modules/@modelcontextprotocol/core/dist/auth-4-zilcqg.cjs} +3 -2
- package/node_modules/@modelcontextprotocol/{core/dist/auth-CUe6YdwF.mjs → client/node_modules/@modelcontextprotocol/core/dist/auth-CGP0BDVq.mjs} +3 -2
- package/node_modules/@modelcontextprotocol/{core/dist/auth-BWdKR39I.d.mts.map → client/node_modules/@modelcontextprotocol/core/dist/auth-YUQV3RRv.d.mts.map} +1 -1
- package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/dist/index.cjs +1 -1
- package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/dist/index.mjs +1 -1
- package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/dist/internal.cjs +1 -1
- package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/dist/internal.mjs +1 -1
- package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/package.json +1 -1
- package/node_modules/@modelcontextprotocol/client/package.json +4 -4
- package/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/node/package.json +2 -17
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/CHANGELOG.md +311 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/README.md +6 -6
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/dist/index.js +4830 -1974
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/dist/internal/index.js +694 -332
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/00-introduction/index.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-foundations/02-providers-and-models.mdx +5 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-foundations/03-prompts.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-foundations/04-tools.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-foundations/06-provider-options.mdx +11 -11
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/00-choosing-a-provider.mdx +4 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/02-nextjs-app-router.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/03-nextjs-pages-router.mdx +4 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/04-svelte.mdx +7 -7
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/05-nuxt.mdx +8 -8
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/06-nodejs.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/07-expo.mdx +10 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/08-tanstack-start.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/09-coding-agents.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/02-building-agents.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/03-workflows.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/04-loop-control.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/05-configuring-call-options.mdx +4 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/06-memory.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/06-policy-tool-approvals.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/06-tool-approvals.mdx +16 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/07-workflow-agent.mdx +12 -12
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/08-terminal-ui.mdx +14 -10
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/05-generating-text.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +6 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/16-mcp-tools.mdx +31 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/17-mcp-apps.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/18-code-mode.mdx +50 -0
- package/node_modules/ai/docs/03-ai-sdk-core/19-tool-search.mdx +82 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/20-prompt-engineering.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/26-reasoning.mdx +15 -14
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/31-reranking.mdx +12 -10
- package/node_modules/ai/docs/03-ai-sdk-core/32-evaluation.mdx +287 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/35-image-generation.mdx +40 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/36-realtime.mdx +41 -18
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/36-transcription.mdx +1 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/37-speech.mdx +8 -6
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/39-file-uploads.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/40-middleware.mdx +92 -7
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/41-skill-uploads.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/42-batch.mdx +2 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/45-provider-management.mdx +31 -21
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/55-testing.mdx +75 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/60-telemetry.mdx +57 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/65-devtools.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +132 -7
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/index.mdx +6 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/01-overview.mdx +3 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +151 -112
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/03-tools.mdx +47 -22
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/04-skills.mdx +0 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/06-workflow-utilities.mdx +43 -9
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/07-ui.mdx +33 -30
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/08-terminal-ui.mdx +8 -6
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/01-overview.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/02-chatbot.mdx +47 -21
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +46 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +11 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +10 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/05-completion.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/08-object-generation.mdx +4 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/21-error-handling.mdx +28 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/21-transport.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +5 -5
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/06-loading-state.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/02-stopping-streams.mdx +8 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/04-caching.mdx +2 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/11-secure-url-fetching.mdx +47 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +13 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +16 -7
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +5 -5
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +3 -3
- package/node_modules/ai/docs/07-reference/01-ai-sdk-core/14-evaluate.mdx +74 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +4 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/20-start-batch.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/20-tool.mdx +7 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +7 -0
- package/node_modules/ai/docs/07-reference/01-ai-sdk-core/23-tool-search.mdx +76 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +30 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +12 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +19 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +22 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +17 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/index.mdx +6 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/01-use-chat.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/03-use-object.mdx +4 -1
- package/node_modules/ai/docs/07-reference/02-ai-sdk-ui/05-use-realtime.mdx +563 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +12 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +9 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +2 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/02-create-ai.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/03-create-streamable-ui.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +8 -8
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/04-ai-sdk-workflow/02-workflow-chat-transport.mdx +4 -4
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-api-call-error.mdx +4 -0
- package/node_modules/ai/docs/07-reference/05-ai-sdk-errors/ai-evaluation-unsupported-question-type-error.mdx +31 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-such-model-error.mdx +4 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-such-provider-error.mdx +4 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-ui-message-stream-error.mdx +6 -2
- package/node_modules/ai/docs/07-reference/05-ai-sdk-errors/index.mdx +138 -0
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/06-ai-sdk-tui/01-run-agent-tui.mdx +13 -9
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/29-migration-guide-4-0.mdx +5 -5
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/37-migration-guide-3-3.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +3 -3
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +1 -1
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +2 -2
- package/node_modules/{@maka/runtime/node_modules/ai → ai}/package.json +13 -13
- package/node_modules/image-dimensions/cli.js +18 -3
- package/node_modules/image-dimensions/index.js +7 -5
- package/node_modules/image-dimensions/package.json +4 -1
- package/node_modules/image-dimensions/readme.md +2 -1
- package/node_modules/image-dimensions/types/avif.js +2 -24
- package/node_modules/image-dimensions/types/heic.js +2 -24
- package/node_modules/image-dimensions/types/jpeg.js +28 -7
- package/node_modules/image-dimensions/types/png.js +13 -2
- package/node_modules/image-dimensions/types/webp.js +20 -36
- package/node_modules/image-dimensions/utilities.js +184 -60
- package/node_modules/ip-address/README.md +145 -135
- package/node_modules/ip-address/dist/common.js +48 -0
- package/node_modules/ip-address/dist/ipv4.js +117 -11
- package/node_modules/ip-address/dist/ipv6.js +162 -48
- package/node_modules/ip-address/dist/v4/constants.js +40 -1
- package/node_modules/ip-address/dist/v6/constants.js +47 -1
- package/node_modules/ip-address/package.json +1 -1
- package/node_modules/marked/README.md +1 -0
- package/node_modules/marked/lib/marked.esm.js +30 -29
- package/node_modules/marked/lib/marked.umd.js +30 -29
- package/node_modules/marked/man/marked.1 +1 -1
- package/node_modules/marked/package.json +11 -11
- package/node_modules/systeminformation/lib/battery.js +32 -11
- package/node_modules/systeminformation/lib/cpu.js +23 -23
- package/node_modules/systeminformation/lib/filesystem.js +14 -8
- package/node_modules/systeminformation/lib/memory.js +3 -5
- package/node_modules/systeminformation/lib/network.js +8 -2
- package/node_modules/systeminformation/lib/osinfo.js +17 -3
- package/node_modules/systeminformation/lib/util.js +7 -0
- package/node_modules/systeminformation/package.json +1 -1
- package/node_modules/undici/README.md +10 -1
- package/node_modules/undici/docs/docs/api/Agent.md +8 -8
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
- package/node_modules/undici/docs/docs/api/Errors.md +25 -0
- package/node_modules/undici/docs/docs/api/Fetch.md +10 -0
- package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
- package/node_modules/undici/docs/docs/api/Pool.md +5 -6
- package/node_modules/undici/docs/docs/index.md +10 -1
- package/node_modules/undici/lib/api/readable.js +1 -2
- package/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/undici/lib/core/util.js +0 -39
- package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
- package/node_modules/undici/lib/dispatcher/client.js +6 -1
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
- package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
- package/node_modules/undici/lib/dispatcher/pool.js +90 -7
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
- package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
- package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
- package/node_modules/undici/lib/handler/retry-handler.js +72 -13
- package/node_modules/undici/lib/interceptor/cache.js +4 -1
- package/node_modules/undici/lib/interceptor/decompress.js +236 -69
- package/node_modules/undici/lib/web/cache/cache.js +17 -8
- package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
- package/node_modules/undici/lib/web/cookies/index.js +19 -7
- package/node_modules/undici/lib/web/cookies/util.js +3 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
- package/node_modules/undici/lib/web/fetch/body.js +22 -15
- package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
- package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
- package/node_modules/undici/lib/web/fetch/headers.js +34 -31
- package/node_modules/undici/lib/web/fetch/index.js +46 -25
- package/node_modules/undici/lib/web/fetch/request.js +74 -79
- package/node_modules/undici/lib/web/fetch/response.js +43 -44
- package/node_modules/undici/lib/web/fetch/util.js +7 -7
- package/node_modules/undici/lib/web/infra/index.js +16 -1
- package/node_modules/undici/lib/web/webidl/index.js +2 -14
- package/node_modules/undici/lib/web/websocket/connection.js +33 -12
- package/node_modules/undici/lib/web/websocket/events.js +43 -26
- package/node_modules/undici/lib/web/websocket/receiver.js +2 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
- package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
- package/node_modules/undici/package.json +1 -1
- package/package.json +4 -4
- package/node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider/dist/index.js +0 -426
- package/node_modules/@ai-sdk/cohere/node_modules/@ai-sdk/provider/CHANGELOG.md +0 -1262
- package/node_modules/@ai-sdk/cohere/node_modules/@ai-sdk/provider/README.md +0 -1
- package/node_modules/@ai-sdk/cohere/node_modules/@ai-sdk/provider/package.json +0 -63
- package/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider/CHANGELOG.md +0 -1262
- package/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider/README.md +0 -1
- package/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider/dist/index.js +0 -426
- package/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider/package.json +0 -63
- package/node_modules/@ai-sdk/open-responses/node_modules/@ai-sdk/provider/CHANGELOG.md +0 -1262
- package/node_modules/@ai-sdk/open-responses/node_modules/@ai-sdk/provider/README.md +0 -1
- package/node_modules/@ai-sdk/open-responses/node_modules/@ai-sdk/provider/dist/index.js +0 -426
- package/node_modules/@ai-sdk/open-responses/node_modules/@ai-sdk/provider/package.json +0 -63
- package/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/CHANGELOG.md +0 -1262
- package/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/LICENSE +0 -13
- package/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/README.md +0 -1
- package/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/dist/index.js +0 -426
- package/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/package.json +0 -63
- package/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider/CHANGELOG.md +0 -1262
- package/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider/LICENSE +0 -13
- package/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider/README.md +0 -1
- package/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider/dist/index.js +0 -426
- package/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider/package.json +0 -63
- package/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/CHANGELOG.md +0 -1262
- package/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/LICENSE +0 -13
- package/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/README.md +0 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.js +0 -426
- package/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +0 -63
- package/node_modules/@earendil-works/pi-tui/native/darwin/src/darwin-modifiers.c +0 -70
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/src/win32-console-mode.c +0 -119
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/code-mode/LICENSE +0 -13
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/code-mode/dist/code-mode-tool.js +0 -40
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/gateway/LICENSE +0 -13
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/provider/CHANGELOG.md +0 -1262
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/provider/LICENSE +0 -13
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/provider/README.md +0 -1
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/provider/dist/index.js +0 -426
- package/node_modules/@maka/runtime/node_modules/@ai-sdk/provider/package.json +0 -63
- package/node_modules/@maka/runtime/node_modules/ai/LICENSE +0 -13
- package/node_modules/@maka/runtime/node_modules/ai/docs/07-reference/02-ai-sdk-ui/05-use-realtime.mdx +0 -247
- package/node_modules/@maka/runtime/node_modules/ai/docs/07-reference/05-ai-sdk-errors/index.mdx +0 -43
- package/node_modules/@modelcontextprotocol/client/dist/index-CHhhk6PQ.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-D4xIIEF6.d.mts.map +0 -1
- /package/node_modules/@ai-sdk/{anthropic/node_modules/@ai-sdk/provider → code-mode}/LICENSE +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/README.md +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/approval.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/continuation-capability.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/direct-tool-call.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/host-interrupt.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/index.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/run-code-mode.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/tool-invocation.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/types.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/dist/utils/serialization.js +0 -0
- /package/node_modules/{@maka/runtime/node_modules/@ai-sdk → @ai-sdk}/code-mode/src/tsconfig.json +0 -0
- /package/node_modules/@ai-sdk/{cohere/node_modules/@ai-sdk/provider → gateway}/LICENSE +0 -0
- /package/node_modules/@ai-sdk/{google/node_modules/@ai-sdk/provider → provider}/LICENSE +0 -0
- /package/node_modules/@ai-sdk/{anthropic/node_modules/@ai-sdk/provider → provider}/README.md +0 -0
- /package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/LICENSE +0 -0
- /package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/README.md +0 -0
- /package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/dist/internal.d.cts.map +0 -0
- /package/node_modules/@modelcontextprotocol/{core → client/node_modules/@modelcontextprotocol/core}/dist/internal.d.mts.map +0 -0
- /package/node_modules/{@ai-sdk/open-responses/node_modules/@ai-sdk/provider → ai}/LICENSE +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-foundations/01-overview.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-foundations/05-streaming.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-foundations/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/01-navigating-the-library.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/02-getting-started/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/01-overview.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/06-subagents.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-agents/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/01-overview.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/10-generating-structured-data.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/17-runtime-and-tool-context.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/25-settings.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/30-embeddings.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/36-translation.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/38-video-generation.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-core/50-error-handling.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/03-ai-sdk-harnesses/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/04-generative-user-interfaces.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/20-streaming-data.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/24-reading-ui-message-streams.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/25-message-metadata.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/50-stream-protocol.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/04-ai-sdk-ui/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/01-overview.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/03-saving-and-restoring-states.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/05-streaming-values.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/08-error-handling.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/09-authentication.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/05-ai-sdk-rsc/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/01-prompt-engineering.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/03-backpressure.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/05-multiple-streamables.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/06-rate-limiting.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/07-rendering-ui-with-language-models.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/08-model-as-router.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/09-multistep-interfaces.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/09-sequential-generations.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/10-vercel-deployment-guide.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/06-advanced/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/05-embed.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/06-embed-many.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/10-generate-image.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/11-stream-transcribe.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/11-stream-translate.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/13-generate-video.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/14-upload-file.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/14-upload-skill.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/15-agent.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/17-create-agent-ui-stream.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/18-pipe-agent-ui-stream-to-response.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/21-get-batch-status.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/22-get-batch-results.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/23-cancel-batch.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/23-get-realtime-tool-definitions.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/24-list-batches.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/24-mcp-apps.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/24-mcp-stdio-transport.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/25-json-schema.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/26-zod-schema.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/27-valibot-schema.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/28-output.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/29-filter-active-tools.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/31-ui-message.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/34-sandbox.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/50-cosine-similarity.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/65-language-model-v2-middleware.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/66-extract-reasoning-middleware.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/67-simulate-streaming-middleware.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/68-default-instructions-middleware.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/68-default-settings-middleware.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/69-add-tool-input-examples-middleware.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/70-extract-json-middleware.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/70-is-step-count.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/71-has-tool-call.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/72-loop-finished.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/75-simulate-readable-stream.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/90-generate-id.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/91-create-id-generator.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/01-ai-sdk-core/92-default-generated-file.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/32-prune-messages.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/41-create-ui-message-stream-response.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/43-read-ui-message-stream.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/46-infer-ui-tools.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/47-infer-ui-tool.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/48-mcp-app-renderer.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/02-ai-sdk-ui/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/04-create-streamable-value.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/05-read-streamable-value.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/06-get-ai-state.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/07-get-mutable-ai-state.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/08-use-ai-state.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/09-use-actions.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/10-use-ui-state.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/11-use-streamable-value.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/20-render.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/03-ai-sdk-rsc/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/04-ai-sdk-workflow/03-generate-video.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/04-ai-sdk-workflow/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-download-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-empty-response-body-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-argument-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-data-content-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-message-role-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-prompt-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-response-data-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-approval-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-approval-signature-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-input-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-json-parse-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-load-api-key-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-load-setting-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-message-conversion-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-content-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-image-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-object-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-output-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-speech-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-such-provider-reference-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-such-tool-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-transcript-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-translation-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-no-video-generated-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-retry-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-stream-provider-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-too-many-embedding-values-for-call-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-tool-call-not-found-for-approval-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-tool-call-repair-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-tool-choice-violation-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-type-validation-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/05-ai-sdk-errors/ai-unsupported-functionality-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/06-ai-sdk-tui/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/07-reference/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/00-versioning.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/23-migration-guide-7-0.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/24-migration-guide-6-0.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/25-migration-guide-5-0-data.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/26-migration-guide-5-0.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/27-migration-guide-4-2.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/28-migration-guide-4-1.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/36-migration-guide-3-4.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/38-migration-guide-3-2.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/39-migration-guide-3-1.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/08-migration-guides/index.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/01-azure-stream-slow.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/03-server-actions-in-client-components.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/04-strange-stream-output.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/05-streamable-ui-errors.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/06-streaming-not-working-when-deployed.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/06-streaming-not-working-when-proxied.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/06-timeout-on-vercel.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/07-unclosed-streams.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/08-use-chat-failed-to-parse-stream.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/09-client-stream-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/10-use-chat-tools-no-response.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/12-typescript-performance-zod.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/14-stream-abort-handling.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/14-tool-calling-with-structured-outputs.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/15-abort-breaks-resumable-streams.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/15-stream-text-not-working.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/16-streaming-status-delay.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/18-ontoolcall-type-narrowing.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/19-unsupported-model-version.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/20-no-object-generated-content-filter.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/21-missing-tool-results-error.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/30-model-is-not-assignable-to-type.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/40-typescript-cannot-find-namespace-jsx.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/60-jest-cannot-find-module-ai-rsc.mdx +0 -0
- /package/node_modules/{@maka/runtime/node_modules/ai → ai}/docs/09-troubleshooting/index.mdx +0 -0
|
@@ -5,9 +5,10 @@ import {
|
|
|
5
5
|
withoutTrailingSlash,
|
|
6
6
|
withUserAgentSuffix as withUserAgentSuffix2
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
|
+
import { Experimental_EvaluationLanguageModel as EvaluationLanguageModel } from "@ai-sdk/provider-utils/experimental-evaluation";
|
|
8
9
|
|
|
9
10
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
11
|
+
var VERSION = true ? "4.0.85" : "0.0.0-test";
|
|
11
12
|
|
|
12
13
|
// src/google-embedding-model.ts
|
|
13
14
|
import {
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
import {
|
|
17
18
|
combineHeaders,
|
|
18
19
|
createJsonResponseHandler,
|
|
20
|
+
EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
|
|
19
21
|
lazySchema as lazySchema3,
|
|
20
22
|
parseProviderOptions,
|
|
21
23
|
postJsonToApi,
|
|
@@ -117,15 +119,33 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
117
119
|
);
|
|
118
120
|
|
|
119
121
|
// src/google-embedding-model.ts
|
|
122
|
+
var _a;
|
|
120
123
|
var GoogleEmbeddingModel = class _GoogleEmbeddingModel {
|
|
121
124
|
constructor(modelId, config) {
|
|
122
125
|
this.specificationVersion = "v4";
|
|
123
126
|
this.maxEmbeddingsPerCall = 100;
|
|
124
127
|
this.supportsParallelCalls = true;
|
|
128
|
+
this[_a] = ({ providerOptions, values, startIndex, endIndex }) => {
|
|
129
|
+
const multimodalContent = providerOptions?.google?.content;
|
|
130
|
+
if (!Array.isArray(multimodalContent)) {
|
|
131
|
+
return providerOptions;
|
|
132
|
+
}
|
|
133
|
+
validateMultimodalContentLength({
|
|
134
|
+
multimodalContent,
|
|
135
|
+
values
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
...providerOptions,
|
|
139
|
+
google: {
|
|
140
|
+
...providerOptions?.google,
|
|
141
|
+
content: multimodalContent.slice(startIndex, endIndex)
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
};
|
|
125
145
|
this.modelId = modelId;
|
|
126
146
|
this.config = config;
|
|
127
147
|
}
|
|
128
|
-
static [WORKFLOW_SERIALIZE](model) {
|
|
148
|
+
static [(_a = EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, WORKFLOW_SERIALIZE)](model) {
|
|
129
149
|
return serializeModelOptions({
|
|
130
150
|
modelId: model.modelId,
|
|
131
151
|
config: model.config
|
|
@@ -160,14 +180,10 @@ var GoogleEmbeddingModel = class _GoogleEmbeddingModel {
|
|
|
160
180
|
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
161
181
|
headers
|
|
162
182
|
);
|
|
163
|
-
const multimodalContent = googleOptions
|
|
164
|
-
|
|
165
|
-
throw new Error(
|
|
166
|
-
`The number of multimodal content entries (${multimodalContent.length}) must match the number of values (${values.length}).`
|
|
167
|
-
);
|
|
168
|
-
}
|
|
183
|
+
const multimodalContent = googleOptions?.content;
|
|
184
|
+
validateMultimodalContentLength({ multimodalContent, values });
|
|
169
185
|
if (values.length === 1) {
|
|
170
|
-
const valueParts = multimodalContent
|
|
186
|
+
const valueParts = multimodalContent?.[0];
|
|
171
187
|
const textPart = values[0] ? [{ text: values[0] }] : [];
|
|
172
188
|
const parts = valueParts != null ? [...textPart, ...valueParts] : [{ text: values[0] }];
|
|
173
189
|
const {
|
|
@@ -182,8 +198,8 @@ var GoogleEmbeddingModel = class _GoogleEmbeddingModel {
|
|
|
182
198
|
content: {
|
|
183
199
|
parts
|
|
184
200
|
},
|
|
185
|
-
outputDimensionality: googleOptions
|
|
186
|
-
taskType: googleOptions
|
|
201
|
+
outputDimensionality: googleOptions?.outputDimensionality,
|
|
202
|
+
taskType: googleOptions?.taskType
|
|
187
203
|
},
|
|
188
204
|
failedResponseHandler: googleFailedResponseHandler,
|
|
189
205
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -208,7 +224,7 @@ var GoogleEmbeddingModel = class _GoogleEmbeddingModel {
|
|
|
208
224
|
headers: mergedHeaders,
|
|
209
225
|
body: {
|
|
210
226
|
requests: values.map((value, index) => {
|
|
211
|
-
const valueParts = multimodalContent
|
|
227
|
+
const valueParts = multimodalContent?.[index];
|
|
212
228
|
const textPart = value ? [{ text: value }] : [];
|
|
213
229
|
return {
|
|
214
230
|
model: `models/${this.modelId}`,
|
|
@@ -216,8 +232,8 @@ var GoogleEmbeddingModel = class _GoogleEmbeddingModel {
|
|
|
216
232
|
role: "user",
|
|
217
233
|
parts: valueParts != null ? [...textPart, ...valueParts] : [{ text: value }]
|
|
218
234
|
},
|
|
219
|
-
outputDimensionality: googleOptions
|
|
220
|
-
taskType: googleOptions
|
|
235
|
+
outputDimensionality: googleOptions?.outputDimensionality,
|
|
236
|
+
taskType: googleOptions?.taskType
|
|
221
237
|
};
|
|
222
238
|
})
|
|
223
239
|
},
|
|
@@ -250,12 +266,22 @@ var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
|
|
|
250
266
|
})
|
|
251
267
|
)
|
|
252
268
|
);
|
|
269
|
+
function validateMultimodalContentLength({
|
|
270
|
+
multimodalContent,
|
|
271
|
+
values
|
|
272
|
+
}) {
|
|
273
|
+
if (multimodalContent != null && multimodalContent.length !== values.length) {
|
|
274
|
+
throw new Error(
|
|
275
|
+
`The number of multimodal content entries (${multimodalContent.length}) must match the number of values (${values.length}).`
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
253
279
|
|
|
254
280
|
// src/google-batch.ts
|
|
255
281
|
import {
|
|
256
282
|
InvalidArgumentError,
|
|
257
283
|
InvalidResponseDataError,
|
|
258
|
-
UnsupportedFunctionalityError as
|
|
284
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
259
285
|
} from "@ai-sdk/provider";
|
|
260
286
|
import {
|
|
261
287
|
combineHeaders as combineHeaders3,
|
|
@@ -274,7 +300,7 @@ import {
|
|
|
274
300
|
zodSchema as zodSchema8,
|
|
275
301
|
convertToBase64 as convertToBase642
|
|
276
302
|
} from "@ai-sdk/provider-utils";
|
|
277
|
-
import { z as
|
|
303
|
+
import { z as z9 } from "zod/v4";
|
|
278
304
|
|
|
279
305
|
// src/get-model-path.ts
|
|
280
306
|
function getModelPath(modelId) {
|
|
@@ -300,23 +326,24 @@ import {
|
|
|
300
326
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
|
|
301
327
|
zodSchema as zodSchema5
|
|
302
328
|
} from "@ai-sdk/provider-utils";
|
|
303
|
-
import { z as
|
|
329
|
+
import { z as z6 } from "zod/v4";
|
|
304
330
|
|
|
305
331
|
// src/convert-google-usage.ts
|
|
306
332
|
import { createNullLanguageModelUsage } from "@ai-sdk/provider-utils";
|
|
307
333
|
function convertGoogleUsage(usage) {
|
|
308
|
-
var _a, _b, _c, _d;
|
|
309
334
|
if (usage == null) {
|
|
310
335
|
return createNullLanguageModelUsage();
|
|
311
336
|
}
|
|
312
|
-
const promptTokens =
|
|
313
|
-
const candidatesTokens =
|
|
314
|
-
const
|
|
315
|
-
const
|
|
337
|
+
const promptTokens = usage.promptTokenCount ?? 0;
|
|
338
|
+
const candidatesTokens = usage.candidatesTokenCount ?? 0;
|
|
339
|
+
const toolUsePromptTokens = usage.toolUsePromptTokenCount ?? 0;
|
|
340
|
+
const cachedContentTokens = usage.cachedContentTokenCount ?? 0;
|
|
341
|
+
const thoughtsTokens = usage.thoughtsTokenCount ?? 0;
|
|
342
|
+
const inputTokens = promptTokens + toolUsePromptTokens;
|
|
316
343
|
return {
|
|
317
344
|
inputTokens: {
|
|
318
|
-
total:
|
|
319
|
-
noCache:
|
|
345
|
+
total: inputTokens,
|
|
346
|
+
noCache: inputTokens - cachedContentTokens,
|
|
320
347
|
cacheRead: cachedContentTokens,
|
|
321
348
|
cacheWrite: void 0
|
|
322
349
|
},
|
|
@@ -329,298 +356,38 @@ function convertGoogleUsage(usage) {
|
|
|
329
356
|
};
|
|
330
357
|
}
|
|
331
358
|
|
|
332
|
-
// src/convert-json-schema-to-openapi-schema.ts
|
|
333
|
-
import {
|
|
334
|
-
UnsupportedFunctionalityError
|
|
335
|
-
} from "@ai-sdk/provider";
|
|
336
|
-
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
337
|
-
function isRecursiveJSONSchemaReferenceError(error) {
|
|
338
|
-
return UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
339
|
-
}
|
|
340
|
-
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
341
|
-
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
342
|
-
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
343
|
-
definitions: rootSchema == null ? void 0 : rootSchema.definitions,
|
|
344
|
-
dollarDefinitions: rootSchema == null ? void 0 : rootSchema.$defs,
|
|
345
|
-
resolvingReferences: /* @__PURE__ */ new Set()
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
349
|
-
if (jsonSchema == null) {
|
|
350
|
-
return void 0;
|
|
351
|
-
}
|
|
352
|
-
if (typeof jsonSchema === "boolean") {
|
|
353
|
-
return { type: "boolean", properties: {} };
|
|
354
|
-
}
|
|
355
|
-
if (jsonSchema.$ref != null) {
|
|
356
|
-
return convertJSONSchemaReference({
|
|
357
|
-
jsonSchema,
|
|
358
|
-
reference: jsonSchema.$ref,
|
|
359
|
-
isRoot,
|
|
360
|
-
referenceContext
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
if (isEmptyObjectSchema(jsonSchema)) {
|
|
364
|
-
if (isRoot) {
|
|
365
|
-
return void 0;
|
|
366
|
-
}
|
|
367
|
-
if (jsonSchema.description) {
|
|
368
|
-
return { type: "object", description: jsonSchema.description };
|
|
369
|
-
}
|
|
370
|
-
return { type: "object" };
|
|
371
|
-
}
|
|
372
|
-
const {
|
|
373
|
-
type,
|
|
374
|
-
description,
|
|
375
|
-
required,
|
|
376
|
-
properties,
|
|
377
|
-
items,
|
|
378
|
-
allOf,
|
|
379
|
-
anyOf,
|
|
380
|
-
oneOf,
|
|
381
|
-
format,
|
|
382
|
-
const: constValue,
|
|
383
|
-
minLength,
|
|
384
|
-
minItems,
|
|
385
|
-
maxItems,
|
|
386
|
-
enum: enumValues
|
|
387
|
-
} = jsonSchema;
|
|
388
|
-
const result = {};
|
|
389
|
-
if (description) result.description = description;
|
|
390
|
-
if (required) result.required = required;
|
|
391
|
-
if (format) result.format = format;
|
|
392
|
-
if (type) {
|
|
393
|
-
if (Array.isArray(type)) {
|
|
394
|
-
const hasNull = type.includes("null");
|
|
395
|
-
const nonNullTypes = type.filter((t) => t !== "null");
|
|
396
|
-
if (nonNullTypes.length === 0) {
|
|
397
|
-
result.type = "null";
|
|
398
|
-
} else {
|
|
399
|
-
result.anyOf = nonNullTypes.map((t) => ({ type: t }));
|
|
400
|
-
if (hasNull) {
|
|
401
|
-
result.nullable = true;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
} else {
|
|
405
|
-
result.type = type;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
|
|
409
|
-
if (values !== void 0) {
|
|
410
|
-
addEnumToSchema({ values, type, result });
|
|
411
|
-
}
|
|
412
|
-
if (properties != null) {
|
|
413
|
-
result.properties = Object.entries(properties).reduce(
|
|
414
|
-
(acc, [key, value]) => {
|
|
415
|
-
acc[key] = convertJSONSchemaDefinition(value, false, referenceContext);
|
|
416
|
-
return acc;
|
|
417
|
-
},
|
|
418
|
-
{}
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
if (items) {
|
|
422
|
-
result.items = Array.isArray(items) ? items.map(
|
|
423
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
424
|
-
) : convertJSONSchemaDefinition(items, false, referenceContext);
|
|
425
|
-
}
|
|
426
|
-
if (allOf) {
|
|
427
|
-
result.allOf = allOf.map(
|
|
428
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
if (anyOf) {
|
|
432
|
-
if (anyOf.some(
|
|
433
|
-
(schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"
|
|
434
|
-
)) {
|
|
435
|
-
const nonNullSchemas = anyOf.filter(
|
|
436
|
-
(schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
|
|
437
|
-
);
|
|
438
|
-
if (nonNullSchemas.length === 1) {
|
|
439
|
-
const converted = convertJSONSchemaDefinition(
|
|
440
|
-
nonNullSchemas[0],
|
|
441
|
-
false,
|
|
442
|
-
referenceContext
|
|
443
|
-
);
|
|
444
|
-
if (typeof converted === "object") {
|
|
445
|
-
result.nullable = true;
|
|
446
|
-
Object.assign(result, converted);
|
|
447
|
-
}
|
|
448
|
-
} else {
|
|
449
|
-
result.anyOf = nonNullSchemas.map(
|
|
450
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
451
|
-
);
|
|
452
|
-
result.nullable = true;
|
|
453
|
-
}
|
|
454
|
-
} else {
|
|
455
|
-
result.anyOf = anyOf.map(
|
|
456
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
if (oneOf) {
|
|
461
|
-
result.oneOf = oneOf.map(
|
|
462
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
if (minLength !== void 0) {
|
|
466
|
-
result.minLength = minLength;
|
|
467
|
-
}
|
|
468
|
-
if (minItems !== void 0) {
|
|
469
|
-
result.minItems = minItems;
|
|
470
|
-
}
|
|
471
|
-
if (maxItems !== void 0) {
|
|
472
|
-
result.maxItems = maxItems;
|
|
473
|
-
}
|
|
474
|
-
return result;
|
|
475
|
-
}
|
|
476
|
-
function convertJSONSchemaReference({
|
|
477
|
-
jsonSchema,
|
|
478
|
-
reference,
|
|
479
|
-
isRoot,
|
|
480
|
-
referenceContext
|
|
481
|
-
}) {
|
|
482
|
-
const { definition, referenceKey } = getReferencedDefinition(
|
|
483
|
-
reference,
|
|
484
|
-
referenceContext
|
|
485
|
-
);
|
|
486
|
-
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
487
|
-
throw new UnsupportedFunctionalityError({
|
|
488
|
-
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
489
|
-
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
const resolvingReferences = new Set(referenceContext.resolvingReferences);
|
|
493
|
-
resolvingReferences.add(referenceKey);
|
|
494
|
-
const { $ref: _reference, ...siblingSchema } = jsonSchema;
|
|
495
|
-
const resolvedSchema = typeof definition === "boolean" ? definition ? siblingSchema : false : { ...definition, ...siblingSchema };
|
|
496
|
-
return convertJSONSchemaDefinition(resolvedSchema, isRoot, {
|
|
497
|
-
...referenceContext,
|
|
498
|
-
resolvingReferences
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
function getReferencedDefinition(reference, referenceContext) {
|
|
502
|
-
const definitionSources = [
|
|
503
|
-
{
|
|
504
|
-
prefix: "#/$defs/",
|
|
505
|
-
definitions: referenceContext.dollarDefinitions
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
prefix: "#/definitions/",
|
|
509
|
-
definitions: referenceContext.definitions
|
|
510
|
-
}
|
|
511
|
-
];
|
|
512
|
-
const source = definitionSources.find(
|
|
513
|
-
({ prefix }) => reference.startsWith(prefix)
|
|
514
|
-
);
|
|
515
|
-
const encodedDefinitionName = source ? reference.slice(source.prefix.length) : void 0;
|
|
516
|
-
if (source == null || encodedDefinitionName == null || encodedDefinitionName.length === 0 || encodedDefinitionName.includes("/")) {
|
|
517
|
-
throwUnsupportedReference(reference);
|
|
518
|
-
}
|
|
519
|
-
let decodedDefinitionName;
|
|
520
|
-
try {
|
|
521
|
-
decodedDefinitionName = decodeURIComponent(encodedDefinitionName);
|
|
522
|
-
} catch (e) {
|
|
523
|
-
throwUnsupportedReference(reference);
|
|
524
|
-
}
|
|
525
|
-
if (decodedDefinitionName.includes("/") || /~(?![01])/u.test(decodedDefinitionName) || source.definitions == null) {
|
|
526
|
-
throwUnsupportedReference(reference);
|
|
527
|
-
}
|
|
528
|
-
const definitionName = decodedDefinitionName.replace(
|
|
529
|
-
/~[01]/g,
|
|
530
|
-
(match) => match === "~1" ? "/" : "~"
|
|
531
|
-
);
|
|
532
|
-
if (!Object.prototype.hasOwnProperty.call(source.definitions, definitionName)) {
|
|
533
|
-
throwUnsupportedReference(reference);
|
|
534
|
-
}
|
|
535
|
-
return {
|
|
536
|
-
definition: source.definitions[definitionName],
|
|
537
|
-
referenceKey: `${source.prefix}${definitionName}`
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
function throwUnsupportedReference(reference) {
|
|
541
|
-
throw new UnsupportedFunctionalityError({
|
|
542
|
-
functionality: `JSON Schema reference: ${reference}`,
|
|
543
|
-
message: "Google schema conversion only supports references to direct children of root-level $defs or definitions."
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
function addEnumToSchema({
|
|
547
|
-
values,
|
|
548
|
-
type,
|
|
549
|
-
result
|
|
550
|
-
}) {
|
|
551
|
-
const nullable = Array.isArray(type) && type.includes("null") || type === void 0 && values.includes(null);
|
|
552
|
-
const enumValues = nullable ? values.filter((value) => value !== null) : values;
|
|
553
|
-
if (values.length > 0 && values.every((value) => value === null)) {
|
|
554
|
-
const typeAllowsNull = type === void 0 || type === "null" || Array.isArray(type) && type.includes("null");
|
|
555
|
-
if (typeAllowsNull) {
|
|
556
|
-
result.type = "null";
|
|
557
|
-
if (Array.isArray(type)) {
|
|
558
|
-
delete result.anyOf;
|
|
559
|
-
}
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
const enumType = getEnumType({ values: enumValues, type });
|
|
564
|
-
if (enumType === void 0) {
|
|
565
|
-
throw new UnsupportedFunctionalityError({
|
|
566
|
-
functionality: "JSON Schema enum with mixed or unsupported values",
|
|
567
|
-
message: "Google does not support this JSON Schema enum. Enum values must share one supported primitive type and match the schema type."
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
result.type = enumType;
|
|
571
|
-
if (Array.isArray(type)) {
|
|
572
|
-
delete result.anyOf;
|
|
573
|
-
}
|
|
574
|
-
if (nullable) {
|
|
575
|
-
result.nullable = true;
|
|
576
|
-
}
|
|
577
|
-
if (enumType === "string") {
|
|
578
|
-
result.enum = enumValues;
|
|
579
|
-
} else {
|
|
580
|
-
result.format = "enum";
|
|
581
|
-
result.enum = enumValues.map(String);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
function getEnumType({
|
|
585
|
-
values,
|
|
586
|
-
type
|
|
587
|
-
}) {
|
|
588
|
-
if (values.length === 0) {
|
|
589
|
-
return void 0;
|
|
590
|
-
}
|
|
591
|
-
const typeAllows = (enumType) => type === void 0 || type === enumType || Array.isArray(type) && type.includes(enumType);
|
|
592
|
-
if (typeAllows("string") && values.every((value) => typeof value === "string")) {
|
|
593
|
-
return "string";
|
|
594
|
-
}
|
|
595
|
-
if ((typeAllows("number") || typeAllows("integer")) && values.every((value) => typeof value === "number" && Number.isFinite(value))) {
|
|
596
|
-
if (typeAllows("number")) {
|
|
597
|
-
return "number";
|
|
598
|
-
}
|
|
599
|
-
if (values.every((value) => Number.isInteger(value))) {
|
|
600
|
-
return "integer";
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
if (typeAllows("boolean") && values.every((value) => typeof value === "boolean")) {
|
|
604
|
-
return "boolean";
|
|
605
|
-
}
|
|
606
|
-
return void 0;
|
|
607
|
-
}
|
|
608
|
-
function isEmptyObjectSchema(jsonSchema) {
|
|
609
|
-
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
359
|
// src/convert-to-google-messages.ts
|
|
613
360
|
import {
|
|
614
|
-
UnsupportedFunctionalityError
|
|
361
|
+
UnsupportedFunctionalityError
|
|
615
362
|
} from "@ai-sdk/provider";
|
|
616
363
|
import {
|
|
617
364
|
convertToBase64,
|
|
618
365
|
getTopLevelMediaType,
|
|
619
366
|
isFullMediaType,
|
|
367
|
+
isUrlSupported,
|
|
620
368
|
resolveFullMediaType,
|
|
621
369
|
resolveProviderReference,
|
|
622
370
|
secureJsonParse
|
|
623
371
|
} from "@ai-sdk/provider-utils";
|
|
372
|
+
|
|
373
|
+
// src/tool/code-execution.ts
|
|
374
|
+
import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
|
|
375
|
+
import { z as z4 } from "zod/v4";
|
|
376
|
+
var codeExecutionInputSchema = z4.object({
|
|
377
|
+
language: z4.string().describe("The programming language of the code."),
|
|
378
|
+
code: z4.string().describe("The code to be executed.")
|
|
379
|
+
});
|
|
380
|
+
var codeExecutionOutputSchema = z4.object({
|
|
381
|
+
outcome: z4.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
382
|
+
output: z4.string().describe("The output from the code execution.")
|
|
383
|
+
});
|
|
384
|
+
var codeExecution = createProviderExecutedToolFactory({
|
|
385
|
+
id: "google.code_execution",
|
|
386
|
+
inputSchema: codeExecutionInputSchema,
|
|
387
|
+
outputSchema: codeExecutionOutputSchema
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// src/convert-to-google-messages.ts
|
|
624
391
|
var SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
|
|
625
392
|
var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
|
|
626
393
|
function parseBase64DataUrl(value) {
|
|
@@ -645,7 +412,21 @@ function convertUrlToolResultPart(url) {
|
|
|
645
412
|
}
|
|
646
413
|
};
|
|
647
414
|
}
|
|
648
|
-
function
|
|
415
|
+
function containsJSONSchemaReference(value) {
|
|
416
|
+
if (Array.isArray(value)) {
|
|
417
|
+
return value.some(containsJSONSchemaReference);
|
|
418
|
+
}
|
|
419
|
+
if (typeof value !== "object" || value === null) {
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
return Object.entries(value).some(
|
|
423
|
+
([key, nestedValue]) => key === "$ref" || containsJSONSchemaReference(nestedValue)
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
function serializeFunctionResponseContent(value) {
|
|
427
|
+
return containsJSONSchemaReference(value) ? JSON.stringify(value) : value;
|
|
428
|
+
}
|
|
429
|
+
function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true, supportedUrls = {}) {
|
|
649
430
|
const functionResponseParts = [];
|
|
650
431
|
const responseTextParts = [];
|
|
651
432
|
for (const contentPart of outputValue) {
|
|
@@ -663,11 +444,22 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId, include
|
|
|
663
444
|
}
|
|
664
445
|
});
|
|
665
446
|
} else if (contentPart.data.type === "url") {
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
if (
|
|
670
|
-
functionResponseParts.push(
|
|
447
|
+
const url = contentPart.data.url.toString();
|
|
448
|
+
const convertedUrlPart = convertUrlToolResultPart(url);
|
|
449
|
+
const supportedUrl = contentPart.data.url.protocol === "gs:" && contentPart.data.originalUrl != null ? contentPart.data.originalUrl : url;
|
|
450
|
+
if (convertedUrlPart != null) {
|
|
451
|
+
functionResponseParts.push(convertedUrlPart);
|
|
452
|
+
} else if (isFullMediaType(contentPart.mediaType) && isUrlSupported({
|
|
453
|
+
url: supportedUrl,
|
|
454
|
+
mediaType: contentPart.mediaType,
|
|
455
|
+
supportedUrls
|
|
456
|
+
})) {
|
|
457
|
+
functionResponseParts.push({
|
|
458
|
+
fileData: {
|
|
459
|
+
mimeType: contentPart.mediaType,
|
|
460
|
+
fileUri: supportedUrl
|
|
461
|
+
}
|
|
462
|
+
});
|
|
671
463
|
} else {
|
|
672
464
|
responseTextParts.push(JSON.stringify(contentPart));
|
|
673
465
|
}
|
|
@@ -735,17 +527,17 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, i
|
|
|
735
527
|
}
|
|
736
528
|
}
|
|
737
529
|
function convertToGoogleMessages(prompt, options) {
|
|
738
|
-
var _a, _b, _c, _d, _e, _f;
|
|
739
530
|
const systemInstructionParts = [];
|
|
740
531
|
const contents = [];
|
|
741
532
|
let systemMessagesAllowed = true;
|
|
742
|
-
const isGemmaModel =
|
|
743
|
-
const isGemini3Model =
|
|
744
|
-
const onWarning = options
|
|
745
|
-
const providerOptionsNames =
|
|
533
|
+
const isGemmaModel = options?.isGemmaModel ?? false;
|
|
534
|
+
const isGemini3Model = options?.isGemini3Model ?? false;
|
|
535
|
+
const onWarning = options?.onWarning;
|
|
536
|
+
const providerOptionsNames = options?.providerOptionsNames ?? ["google"];
|
|
746
537
|
const isVertexLike = !providerOptionsNames.includes("google");
|
|
747
|
-
const supportsFunctionResponseParts =
|
|
748
|
-
const includeFunctionCallIds =
|
|
538
|
+
const supportsFunctionResponseParts = options?.supportsFunctionResponseParts ?? true;
|
|
539
|
+
const includeFunctionCallIds = options?.includeFunctionCallIds ?? true;
|
|
540
|
+
const supportedFunctionResponseUrls = options?.supportedFunctionResponseUrls ?? {};
|
|
749
541
|
let sentinelInjected = false;
|
|
750
542
|
const missingSignatureToolNames = [];
|
|
751
543
|
const injectSkipSignature = (toolName) => {
|
|
@@ -754,21 +546,20 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
754
546
|
return SKIP_THOUGHT_SIGNATURE_VALIDATOR;
|
|
755
547
|
};
|
|
756
548
|
const readProviderOpts = (part) => {
|
|
757
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
758
549
|
for (const name of providerOptionsNames) {
|
|
759
|
-
const v =
|
|
550
|
+
const v = part.providerOptions?.[name];
|
|
760
551
|
if (v != null) return v;
|
|
761
552
|
}
|
|
762
553
|
if (isVertexLike) {
|
|
763
|
-
return
|
|
554
|
+
return part.providerOptions?.google;
|
|
764
555
|
}
|
|
765
|
-
return
|
|
556
|
+
return part.providerOptions?.googleVertex ?? part.providerOptions?.vertex;
|
|
766
557
|
};
|
|
767
558
|
for (const { role, content } of prompt) {
|
|
768
559
|
switch (role) {
|
|
769
560
|
case "system": {
|
|
770
561
|
if (!systemMessagesAllowed) {
|
|
771
|
-
throw new
|
|
562
|
+
throw new UnsupportedFunctionalityError({
|
|
772
563
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
773
564
|
});
|
|
774
565
|
}
|
|
@@ -790,14 +581,14 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
790
581
|
parts.push({
|
|
791
582
|
fileData: {
|
|
792
583
|
mimeType: resolveFullMediaType({ part }),
|
|
793
|
-
fileUri: part.data.url.toString()
|
|
584
|
+
fileUri: part.data.url.protocol === "gs:" && part.data.originalUrl != null ? part.data.originalUrl : part.data.url.toString()
|
|
794
585
|
}
|
|
795
586
|
});
|
|
796
587
|
break;
|
|
797
588
|
}
|
|
798
589
|
case "reference": {
|
|
799
590
|
if (isVertexLike) {
|
|
800
|
-
throw new
|
|
591
|
+
throw new UnsupportedFunctionalityError({
|
|
801
592
|
functionality: "file parts with provider references"
|
|
802
593
|
});
|
|
803
594
|
}
|
|
@@ -847,7 +638,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
847
638
|
role: "model",
|
|
848
639
|
parts: content.map((part) => {
|
|
849
640
|
const providerOpts = readProviderOpts(part);
|
|
850
|
-
const thoughtSignature =
|
|
641
|
+
const thoughtSignature = providerOpts?.thoughtSignature != null ? String(providerOpts.thoughtSignature) : void 0;
|
|
851
642
|
switch (part.type) {
|
|
852
643
|
case "text": {
|
|
853
644
|
return part.text.length === 0 ? void 0 : {
|
|
@@ -865,7 +656,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
865
656
|
case "reasoning-file": {
|
|
866
657
|
switch (part.data.type) {
|
|
867
658
|
case "url": {
|
|
868
|
-
throw new
|
|
659
|
+
throw new UnsupportedFunctionalityError({
|
|
869
660
|
functionality: "File data URLs in assistant messages are not supported"
|
|
870
661
|
});
|
|
871
662
|
}
|
|
@@ -885,13 +676,13 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
885
676
|
case "file": {
|
|
886
677
|
switch (part.data.type) {
|
|
887
678
|
case "url": {
|
|
888
|
-
throw new
|
|
679
|
+
throw new UnsupportedFunctionalityError({
|
|
889
680
|
functionality: "File data URLs in assistant messages are not supported"
|
|
890
681
|
});
|
|
891
682
|
}
|
|
892
683
|
case "reference": {
|
|
893
684
|
if (isVertexLike) {
|
|
894
|
-
throw new
|
|
685
|
+
throw new UnsupportedFunctionalityError({
|
|
895
686
|
functionality: "file parts with provider references"
|
|
896
687
|
});
|
|
897
688
|
}
|
|
@@ -903,7 +694,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
903
694
|
provider: "google"
|
|
904
695
|
})
|
|
905
696
|
},
|
|
906
|
-
...
|
|
697
|
+
...providerOpts?.thought === true ? { thought: true } : {},
|
|
907
698
|
thoughtSignature
|
|
908
699
|
};
|
|
909
700
|
}
|
|
@@ -915,7 +706,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
915
706
|
new TextEncoder().encode(part.data.text)
|
|
916
707
|
)
|
|
917
708
|
},
|
|
918
|
-
...
|
|
709
|
+
...providerOpts?.thought === true ? { thought: true } : {},
|
|
919
710
|
thoughtSignature
|
|
920
711
|
};
|
|
921
712
|
}
|
|
@@ -925,7 +716,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
925
716
|
mimeType: part.mediaType,
|
|
926
717
|
data: convertToBase64(part.data.data)
|
|
927
718
|
},
|
|
928
|
-
...
|
|
719
|
+
...providerOpts?.thought === true ? { thought: true } : {},
|
|
929
720
|
thoughtSignature
|
|
930
721
|
};
|
|
931
722
|
}
|
|
@@ -933,8 +724,15 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
933
724
|
break;
|
|
934
725
|
}
|
|
935
726
|
case "tool-call": {
|
|
936
|
-
|
|
937
|
-
|
|
727
|
+
if (part.providerExecuted === true && part.toolName === "code_execution") {
|
|
728
|
+
return {
|
|
729
|
+
executableCode: codeExecutionInputSchema.parse(
|
|
730
|
+
typeof part.input === "string" ? secureJsonParse(part.input) : part.input
|
|
731
|
+
)
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
const serverToolCallId = providerOpts?.serverToolCallId != null ? String(providerOpts.serverToolCallId) : void 0;
|
|
735
|
+
const serverToolType = providerOpts?.serverToolType != null ? String(providerOpts.serverToolType) : void 0;
|
|
938
736
|
const isServerToolCall = serverToolCallId != null && serverToolType != null;
|
|
939
737
|
const shouldSkipMissingSignatureMitigation = (
|
|
940
738
|
// Gemini 3 returns a single signature for a parallel
|
|
@@ -943,7 +741,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
943
741
|
// model response legitimately have no signature.
|
|
944
742
|
!isServerToolCall && thoughtSignature == null && modelResponseHasSignedFunctionCall
|
|
945
743
|
);
|
|
946
|
-
const effectiveThoughtSignature = thoughtSignature
|
|
744
|
+
const effectiveThoughtSignature = thoughtSignature ?? (isGemini3Model && !shouldSkipMissingSignatureMitigation ? injectSkipSignature(part.toolName) : void 0);
|
|
947
745
|
if (!isServerToolCall && thoughtSignature != null) {
|
|
948
746
|
modelResponseHasSignedFunctionCall = true;
|
|
949
747
|
}
|
|
@@ -967,8 +765,15 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
967
765
|
};
|
|
968
766
|
}
|
|
969
767
|
case "tool-result": {
|
|
970
|
-
|
|
971
|
-
|
|
768
|
+
if (part.toolName === "code_execution" && part.output.type === "json") {
|
|
769
|
+
return {
|
|
770
|
+
codeExecutionResult: codeExecutionOutputSchema.parse(
|
|
771
|
+
part.output.value
|
|
772
|
+
)
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
const serverToolCallId = providerOpts?.serverToolCallId != null ? String(providerOpts.serverToolCallId) : void 0;
|
|
776
|
+
const serverToolType = providerOpts?.serverToolType != null ? String(providerOpts.serverToolType) : void 0;
|
|
972
777
|
if (serverToolCallId && serverToolType) {
|
|
973
778
|
return {
|
|
974
779
|
toolResponse: {
|
|
@@ -994,10 +799,10 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
994
799
|
continue;
|
|
995
800
|
}
|
|
996
801
|
const partProviderOpts = readProviderOpts(part);
|
|
997
|
-
const serverToolCallId =
|
|
998
|
-
const serverToolType =
|
|
802
|
+
const serverToolCallId = partProviderOpts?.serverToolCallId != null ? String(partProviderOpts.serverToolCallId) : void 0;
|
|
803
|
+
const serverToolType = partProviderOpts?.serverToolType != null ? String(partProviderOpts.serverToolType) : void 0;
|
|
999
804
|
if (serverToolCallId && serverToolType) {
|
|
1000
|
-
const serverThoughtSignature =
|
|
805
|
+
const serverThoughtSignature = partProviderOpts?.thoughtSignature != null ? String(partProviderOpts.thoughtSignature) : void 0;
|
|
1001
806
|
if (contents.length > 0) {
|
|
1002
807
|
const lastContent = contents[contents.length - 1];
|
|
1003
808
|
if (lastContent.role === "model") {
|
|
@@ -1021,7 +826,8 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
1021
826
|
part.toolName,
|
|
1022
827
|
output.value,
|
|
1023
828
|
part.toolCallId,
|
|
1024
|
-
includeFunctionCallIds
|
|
829
|
+
includeFunctionCallIds,
|
|
830
|
+
supportedFunctionResponseUrls
|
|
1025
831
|
);
|
|
1026
832
|
} else {
|
|
1027
833
|
appendLegacyToolResultParts(
|
|
@@ -1039,7 +845,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
1039
845
|
name: part.toolName,
|
|
1040
846
|
response: {
|
|
1041
847
|
name: part.toolName,
|
|
1042
|
-
content: output.type === "execution-denied" ?
|
|
848
|
+
content: output.type === "execution-denied" ? output.reason ?? "Tool call execution denied." : serializeFunctionResponseContent(output.value)
|
|
1043
849
|
}
|
|
1044
850
|
}
|
|
1045
851
|
});
|
|
@@ -1074,11 +880,13 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
1074
880
|
import {
|
|
1075
881
|
detectMediaType,
|
|
1076
882
|
downloadBlob,
|
|
1077
|
-
isFullMediaType as isFullMediaType2
|
|
883
|
+
isFullMediaType as isFullMediaType2,
|
|
884
|
+
isUrlSupported as isUrlSupported2
|
|
1078
885
|
} from "@ai-sdk/provider-utils";
|
|
1079
886
|
async function downloadToolResultFiles(prompt, {
|
|
1080
887
|
abortSignal,
|
|
1081
|
-
maxBytes
|
|
888
|
+
maxBytes,
|
|
889
|
+
supportedUrls = {}
|
|
1082
890
|
}) {
|
|
1083
891
|
const result = [];
|
|
1084
892
|
for (const message of prompt) {
|
|
@@ -1090,7 +898,8 @@ async function downloadToolResultFiles(prompt, {
|
|
|
1090
898
|
...part,
|
|
1091
899
|
output: await downloadToolResultOutput(part.output, {
|
|
1092
900
|
abortSignal,
|
|
1093
|
-
maxBytes
|
|
901
|
+
maxBytes,
|
|
902
|
+
supportedUrls
|
|
1094
903
|
})
|
|
1095
904
|
} : part
|
|
1096
905
|
);
|
|
@@ -1109,7 +918,8 @@ async function downloadToolResultFiles(prompt, {
|
|
|
1109
918
|
...part,
|
|
1110
919
|
output: await downloadToolResultOutput(part.output, {
|
|
1111
920
|
abortSignal,
|
|
1112
|
-
maxBytes
|
|
921
|
+
maxBytes,
|
|
922
|
+
supportedUrls
|
|
1113
923
|
})
|
|
1114
924
|
});
|
|
1115
925
|
}
|
|
@@ -1122,7 +932,8 @@ async function downloadToolResultFiles(prompt, {
|
|
|
1122
932
|
}
|
|
1123
933
|
async function downloadToolResultOutput(output, {
|
|
1124
934
|
abortSignal,
|
|
1125
|
-
maxBytes
|
|
935
|
+
maxBytes,
|
|
936
|
+
supportedUrls
|
|
1126
937
|
}) {
|
|
1127
938
|
if (output.type !== "content") {
|
|
1128
939
|
return output;
|
|
@@ -1133,6 +944,14 @@ async function downloadToolResultOutput(output, {
|
|
|
1133
944
|
value.push(part);
|
|
1134
945
|
continue;
|
|
1135
946
|
}
|
|
947
|
+
if (isUrlSupported2({
|
|
948
|
+
url: part.data.url.toString(),
|
|
949
|
+
mediaType: part.mediaType,
|
|
950
|
+
supportedUrls
|
|
951
|
+
})) {
|
|
952
|
+
value.push(part);
|
|
953
|
+
continue;
|
|
954
|
+
}
|
|
1136
955
|
const blob = await downloadBlob(part.data.url.toString(), {
|
|
1137
956
|
abortSignal,
|
|
1138
957
|
maxBytes
|
|
@@ -1145,7 +964,7 @@ async function downloadToolResultOutput(output, {
|
|
|
1145
964
|
value.push({
|
|
1146
965
|
...part,
|
|
1147
966
|
data: { type: "data", data },
|
|
1148
|
-
mediaType: detectedMediaType
|
|
967
|
+
mediaType: detectedMediaType ?? (blob.type && !isFullMediaType2(part.mediaType) ? blob.type : part.mediaType)
|
|
1149
968
|
});
|
|
1150
969
|
}
|
|
1151
970
|
return {
|
|
@@ -1154,28 +973,66 @@ async function downloadToolResultOutput(output, {
|
|
|
1154
973
|
};
|
|
1155
974
|
}
|
|
1156
975
|
|
|
976
|
+
// src/sanitize-response-json-schema.ts
|
|
977
|
+
function sanitizeResponseJsonSchema(schema) {
|
|
978
|
+
const {
|
|
979
|
+
const: constValue,
|
|
980
|
+
properties,
|
|
981
|
+
items,
|
|
982
|
+
additionalProperties,
|
|
983
|
+
anyOf,
|
|
984
|
+
oneOf,
|
|
985
|
+
...result
|
|
986
|
+
} = schema;
|
|
987
|
+
return {
|
|
988
|
+
...result,
|
|
989
|
+
...constValue !== void 0 ? { enum: [constValue] } : {},
|
|
990
|
+
...properties != null ? { properties: sanitizeDefinitions(properties) } : {},
|
|
991
|
+
...items != null ? {
|
|
992
|
+
items: Array.isArray(items) ? items.map(sanitizeDefinition) : sanitizeDefinition(items)
|
|
993
|
+
} : {},
|
|
994
|
+
...additionalProperties != null ? {
|
|
995
|
+
additionalProperties: typeof additionalProperties === "boolean" ? additionalProperties : sanitizeDefinition(additionalProperties)
|
|
996
|
+
} : {},
|
|
997
|
+
...anyOf != null ? { anyOf: anyOf.map(sanitizeDefinition) } : {},
|
|
998
|
+
...oneOf != null ? { oneOf: oneOf.map(sanitizeDefinition) } : {},
|
|
999
|
+
...result.$defs != null ? { $defs: sanitizeDefinitions(result.$defs) } : {}
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
function sanitizeDefinitions(definitions) {
|
|
1003
|
+
return Object.fromEntries(
|
|
1004
|
+
Object.entries(definitions).map(([name, definition]) => [
|
|
1005
|
+
name,
|
|
1006
|
+
sanitizeDefinition(definition)
|
|
1007
|
+
])
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
function sanitizeDefinition(definition) {
|
|
1011
|
+
return typeof definition === "boolean" ? definition : sanitizeResponseJsonSchema(definition);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1157
1014
|
// src/google-language-model-options.ts
|
|
1158
1015
|
import {
|
|
1159
1016
|
lazySchema as lazySchema4,
|
|
1160
1017
|
zodSchema as zodSchema4
|
|
1161
1018
|
} from "@ai-sdk/provider-utils";
|
|
1162
|
-
import { z as
|
|
1019
|
+
import { z as z5 } from "zod/v4";
|
|
1163
1020
|
var googleLanguageModelOptions = lazySchema4(
|
|
1164
1021
|
() => zodSchema4(
|
|
1165
|
-
|
|
1166
|
-
responseModalities:
|
|
1167
|
-
thinkingConfig:
|
|
1168
|
-
thinkingBudget:
|
|
1169
|
-
includeThoughts:
|
|
1022
|
+
z5.object({
|
|
1023
|
+
responseModalities: z5.array(z5.enum(["TEXT", "IMAGE"])).optional(),
|
|
1024
|
+
thinkingConfig: z5.object({
|
|
1025
|
+
thinkingBudget: z5.number().optional(),
|
|
1026
|
+
includeThoughts: z5.boolean().optional(),
|
|
1170
1027
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
1171
|
-
thinkingLevel:
|
|
1028
|
+
thinkingLevel: z5.enum(["minimal", "low", "medium", "high"]).optional()
|
|
1172
1029
|
}).optional(),
|
|
1173
1030
|
/**
|
|
1174
1031
|
* Optional.
|
|
1175
1032
|
* The name of the cached content used as context to serve the prediction.
|
|
1176
1033
|
* Format: cachedContents/{cachedContent}
|
|
1177
1034
|
*/
|
|
1178
|
-
cachedContent:
|
|
1035
|
+
cachedContent: z5.string().optional(),
|
|
1179
1036
|
/**
|
|
1180
1037
|
* Optional. Enable structured output. Default is true.
|
|
1181
1038
|
*
|
|
@@ -1184,13 +1041,13 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1184
1041
|
* Google uses. You can use this to disable
|
|
1185
1042
|
* structured outputs if you need to.
|
|
1186
1043
|
*/
|
|
1187
|
-
structuredOutputs:
|
|
1044
|
+
structuredOutputs: z5.boolean().optional(),
|
|
1188
1045
|
/**
|
|
1189
1046
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
1190
1047
|
*/
|
|
1191
|
-
safetySettings:
|
|
1192
|
-
|
|
1193
|
-
category:
|
|
1048
|
+
safetySettings: z5.array(
|
|
1049
|
+
z5.object({
|
|
1050
|
+
category: z5.enum([
|
|
1194
1051
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
1195
1052
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
1196
1053
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -1198,7 +1055,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1198
1055
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
1199
1056
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
1200
1057
|
]),
|
|
1201
|
-
threshold:
|
|
1058
|
+
threshold: z5.enum([
|
|
1202
1059
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
1203
1060
|
"BLOCK_LOW_AND_ABOVE",
|
|
1204
1061
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -1208,7 +1065,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1208
1065
|
])
|
|
1209
1066
|
})
|
|
1210
1067
|
).optional(),
|
|
1211
|
-
threshold:
|
|
1068
|
+
threshold: z5.enum([
|
|
1212
1069
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
1213
1070
|
"BLOCK_LOW_AND_ABOVE",
|
|
1214
1071
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -1221,19 +1078,19 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1221
1078
|
*
|
|
1222
1079
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
1223
1080
|
*/
|
|
1224
|
-
audioTimestamp:
|
|
1081
|
+
audioTimestamp: z5.boolean().optional(),
|
|
1225
1082
|
/**
|
|
1226
1083
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
1227
1084
|
*
|
|
1228
1085
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
1229
1086
|
*/
|
|
1230
|
-
labels:
|
|
1087
|
+
labels: z5.record(z5.string(), z5.string()).optional(),
|
|
1231
1088
|
/**
|
|
1232
1089
|
* Optional. If specified, the media resolution specified will be used.
|
|
1233
1090
|
*
|
|
1234
1091
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
1235
1092
|
*/
|
|
1236
|
-
mediaResolution:
|
|
1093
|
+
mediaResolution: z5.enum([
|
|
1237
1094
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
1238
1095
|
"MEDIA_RESOLUTION_LOW",
|
|
1239
1096
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -1244,8 +1101,8 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1244
1101
|
*
|
|
1245
1102
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
1246
1103
|
*/
|
|
1247
|
-
imageConfig:
|
|
1248
|
-
aspectRatio:
|
|
1104
|
+
imageConfig: z5.object({
|
|
1105
|
+
aspectRatio: z5.enum([
|
|
1249
1106
|
"1:1",
|
|
1250
1107
|
"2:3",
|
|
1251
1108
|
"3:2",
|
|
@@ -1261,12 +1118,12 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1261
1118
|
"1:4",
|
|
1262
1119
|
"4:1"
|
|
1263
1120
|
]).optional(),
|
|
1264
|
-
imageSize:
|
|
1121
|
+
imageSize: z5.enum(["1K", "2K", "4K", "512"]).optional(),
|
|
1265
1122
|
/**
|
|
1266
1123
|
* Optional. Controls the generation of people in images.
|
|
1267
1124
|
* Vertex AI only.
|
|
1268
1125
|
*/
|
|
1269
|
-
personGeneration:
|
|
1126
|
+
personGeneration: z5.enum([
|
|
1270
1127
|
"PERSON_GENERATION_UNSPECIFIED",
|
|
1271
1128
|
"ALLOW_ALL",
|
|
1272
1129
|
"ALLOW_ADULT",
|
|
@@ -1280,7 +1137,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1280
1137
|
*
|
|
1281
1138
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
|
|
1282
1139
|
*/
|
|
1283
|
-
prominentPeople:
|
|
1140
|
+
prominentPeople: z5.enum([
|
|
1284
1141
|
"PROMINENT_PEOPLE_UNSPECIFIED",
|
|
1285
1142
|
"ALLOW_PROMINENT_PEOPLE",
|
|
1286
1143
|
"BLOCK_PROMINENT_PEOPLE"
|
|
@@ -1289,9 +1146,9 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1289
1146
|
* Optional. The image output format for generated images.
|
|
1290
1147
|
* Vertex AI only.
|
|
1291
1148
|
*/
|
|
1292
|
-
imageOutputOptions:
|
|
1293
|
-
mimeType:
|
|
1294
|
-
compressionQuality:
|
|
1149
|
+
imageOutputOptions: z5.object({
|
|
1150
|
+
mimeType: z5.enum(["image/jpeg", "image/png"]).optional(),
|
|
1151
|
+
compressionQuality: z5.number().optional()
|
|
1295
1152
|
}).optional()
|
|
1296
1153
|
}).optional(),
|
|
1297
1154
|
/**
|
|
@@ -1300,10 +1157,10 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1300
1157
|
*
|
|
1301
1158
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1302
1159
|
*/
|
|
1303
|
-
retrievalConfig:
|
|
1304
|
-
latLng:
|
|
1305
|
-
latitude:
|
|
1306
|
-
longitude:
|
|
1160
|
+
retrievalConfig: z5.object({
|
|
1161
|
+
latLng: z5.object({
|
|
1162
|
+
latitude: z5.number(),
|
|
1163
|
+
longitude: z5.number()
|
|
1307
1164
|
}).optional()
|
|
1308
1165
|
}).optional(),
|
|
1309
1166
|
/**
|
|
@@ -1316,12 +1173,12 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1316
1173
|
*
|
|
1317
1174
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
1318
1175
|
*/
|
|
1319
|
-
streamFunctionCallArguments:
|
|
1176
|
+
streamFunctionCallArguments: z5.boolean().optional(),
|
|
1320
1177
|
/**
|
|
1321
1178
|
* Optional. The service tier to use for the request. Sent as the
|
|
1322
1179
|
* `serviceTier` body field. Gemini API only.
|
|
1323
1180
|
*/
|
|
1324
|
-
serviceTier:
|
|
1181
|
+
serviceTier: z5.enum(["standard", "flex", "priority"]).optional(),
|
|
1325
1182
|
/**
|
|
1326
1183
|
* Optional. Vertex AI only. Sent as the
|
|
1327
1184
|
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
@@ -1332,7 +1189,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1332
1189
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1333
1190
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
1334
1191
|
*/
|
|
1335
|
-
sharedRequestType:
|
|
1192
|
+
sharedRequestType: z5.enum(["priority", "flex", "standard"]).optional(),
|
|
1336
1193
|
/**
|
|
1337
1194
|
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
1338
1195
|
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
@@ -1340,7 +1197,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1340
1197
|
*
|
|
1341
1198
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1342
1199
|
*/
|
|
1343
|
-
requestType:
|
|
1200
|
+
requestType: z5.enum(["shared"]).optional()
|
|
1344
1201
|
})
|
|
1345
1202
|
)
|
|
1346
1203
|
);
|
|
@@ -1368,7 +1225,7 @@ function getGoogleModelCapabilities(modelId) {
|
|
|
1368
1225
|
|
|
1369
1226
|
// src/google-prepare-tools.ts
|
|
1370
1227
|
import {
|
|
1371
|
-
UnsupportedFunctionalityError as
|
|
1228
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1372
1229
|
} from "@ai-sdk/provider";
|
|
1373
1230
|
function prepareTools({
|
|
1374
1231
|
tools,
|
|
@@ -1376,7 +1233,7 @@ function prepareTools({
|
|
|
1376
1233
|
modelId,
|
|
1377
1234
|
isVertexProvider = false
|
|
1378
1235
|
}) {
|
|
1379
|
-
tools =
|
|
1236
|
+
tools = tools?.length ? tools : void 0;
|
|
1380
1237
|
const toolWarnings = [];
|
|
1381
1238
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
1382
1239
|
if (tools == null) {
|
|
@@ -1598,32 +1455,18 @@ function prepareTools({
|
|
|
1598
1455
|
};
|
|
1599
1456
|
default: {
|
|
1600
1457
|
const _exhaustiveCheck = type;
|
|
1601
|
-
throw new
|
|
1458
|
+
throw new UnsupportedFunctionalityError2({
|
|
1602
1459
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1603
1460
|
});
|
|
1604
1461
|
}
|
|
1605
1462
|
}
|
|
1606
1463
|
}
|
|
1607
1464
|
function prepareFunctionDeclaration(tool) {
|
|
1608
|
-
|
|
1609
|
-
const declaration = {
|
|
1465
|
+
return {
|
|
1610
1466
|
name: tool.name,
|
|
1611
|
-
description:
|
|
1467
|
+
description: tool.description ?? "",
|
|
1468
|
+
parametersJsonSchema: tool.inputSchema
|
|
1612
1469
|
};
|
|
1613
|
-
try {
|
|
1614
|
-
return {
|
|
1615
|
-
...declaration,
|
|
1616
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1617
|
-
};
|
|
1618
|
-
} catch (error) {
|
|
1619
|
-
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1620
|
-
throw error;
|
|
1621
|
-
}
|
|
1622
|
-
return {
|
|
1623
|
-
...declaration,
|
|
1624
|
-
parametersJsonSchema: tool.inputSchema
|
|
1625
|
-
};
|
|
1626
|
-
}
|
|
1627
1470
|
}
|
|
1628
1471
|
|
|
1629
1472
|
// src/google-json-accumulator.ts
|
|
@@ -1860,11 +1703,9 @@ function setNestedValue(obj, segments, value) {
|
|
|
1860
1703
|
defineOwnProperty(current, segments[segments.length - 1], value);
|
|
1861
1704
|
}
|
|
1862
1705
|
function resolvePartialArgValue(arg) {
|
|
1863
|
-
|
|
1864
|
-
const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
|
|
1706
|
+
const value = arg.stringValue ?? arg.numberValue ?? arg.boolValue;
|
|
1865
1707
|
if (value != null) return { value, json: JSON.stringify(value) };
|
|
1866
1708
|
if ("nullValue" in arg) return { value: null, json: "null" };
|
|
1867
|
-
return void 0;
|
|
1868
1709
|
}
|
|
1869
1710
|
|
|
1870
1711
|
// src/map-google-finish-reason.ts
|
|
@@ -1901,13 +1742,19 @@ var configurableSafetySettingCategories = [
|
|
|
1901
1742
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1902
1743
|
];
|
|
1903
1744
|
var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
1745
|
+
var googleCloudStorageFunctionResponseUrls = {
|
|
1746
|
+
"image/png": [/^gs:\/\/.*$/],
|
|
1747
|
+
"image/jpeg": [/^gs:\/\/.*$/],
|
|
1748
|
+
"image/webp": [/^gs:\/\/.*$/],
|
|
1749
|
+
"application/pdf": [/^gs:\/\/.*$/],
|
|
1750
|
+
"text/plain": [/^gs:\/\/.*$/]
|
|
1751
|
+
};
|
|
1904
1752
|
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
1905
1753
|
constructor(modelId, config) {
|
|
1906
1754
|
this.specificationVersion = "v4";
|
|
1907
|
-
var _a;
|
|
1908
1755
|
this.modelId = modelId;
|
|
1909
1756
|
this.config = config;
|
|
1910
|
-
this.generateId =
|
|
1757
|
+
this.generateId = config.generateId ?? generateId;
|
|
1911
1758
|
}
|
|
1912
1759
|
static [WORKFLOW_SERIALIZE2](model) {
|
|
1913
1760
|
return serializeModelOptions2({
|
|
@@ -1922,8 +1769,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1922
1769
|
return this.config.provider;
|
|
1923
1770
|
}
|
|
1924
1771
|
get supportedUrls() {
|
|
1925
|
-
|
|
1926
|
-
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
1772
|
+
return this.config.supportedUrls?.() ?? {};
|
|
1927
1773
|
}
|
|
1928
1774
|
static async prepareRequest({
|
|
1929
1775
|
modelId,
|
|
@@ -1947,7 +1793,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1947
1793
|
},
|
|
1948
1794
|
isStreaming = false
|
|
1949
1795
|
}) {
|
|
1950
|
-
var _a, _b, _c;
|
|
1951
1796
|
const warnings = [];
|
|
1952
1797
|
const providerOptionsNames = config.provider.includes(
|
|
1953
1798
|
"vertex"
|
|
@@ -1969,33 +1814,33 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1969
1814
|
});
|
|
1970
1815
|
}
|
|
1971
1816
|
const isVertexProvider = config.provider.startsWith("google.vertex.");
|
|
1972
|
-
if (
|
|
1817
|
+
if (tools?.some(
|
|
1973
1818
|
(tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
|
|
1974
|
-
)
|
|
1819
|
+
) && !isVertexProvider) {
|
|
1975
1820
|
warnings.push({
|
|
1976
1821
|
type: "other",
|
|
1977
1822
|
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${config.provider}).`
|
|
1978
1823
|
});
|
|
1979
1824
|
}
|
|
1980
|
-
if (
|
|
1825
|
+
if (googleOptions?.streamFunctionCallArguments && !isVertexProvider) {
|
|
1981
1826
|
warnings.push({
|
|
1982
1827
|
type: "other",
|
|
1983
1828
|
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
|
|
1984
1829
|
});
|
|
1985
1830
|
}
|
|
1986
|
-
if (
|
|
1831
|
+
if (googleOptions?.serviceTier && isVertexProvider) {
|
|
1987
1832
|
warnings.push({
|
|
1988
1833
|
type: "other",
|
|
1989
1834
|
message: "'serviceTier' is a Gemini API option and is not supported on Vertex AI. Use 'sharedRequestType' (and optionally 'requestType') instead. See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo"
|
|
1990
1835
|
});
|
|
1991
1836
|
}
|
|
1992
|
-
if ((
|
|
1837
|
+
if ((googleOptions?.sharedRequestType || googleOptions?.requestType) && !isVertexProvider) {
|
|
1993
1838
|
warnings.push({
|
|
1994
1839
|
type: "other",
|
|
1995
1840
|
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${config.provider}).`
|
|
1996
1841
|
});
|
|
1997
1842
|
}
|
|
1998
|
-
const vertexPaygoHeaders = isVertexProvider && (
|
|
1843
|
+
const vertexPaygoHeaders = isVertexProvider && (googleOptions?.sharedRequestType || googleOptions?.requestType) ? {
|
|
1999
1844
|
...googleOptions.sharedRequestType && {
|
|
2000
1845
|
"X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
|
|
2001
1846
|
},
|
|
@@ -2003,8 +1848,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2003
1848
|
"X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
|
|
2004
1849
|
}
|
|
2005
1850
|
} : void 0;
|
|
2006
|
-
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions
|
|
2007
|
-
let imageConfig = googleOptions
|
|
1851
|
+
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions?.serviceTier;
|
|
1852
|
+
let imageConfig = googleOptions?.imageConfig;
|
|
2008
1853
|
if (imageConfig != null && !isVertexProvider) {
|
|
2009
1854
|
const {
|
|
2010
1855
|
personGeneration,
|
|
@@ -2040,9 +1885,11 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2040
1885
|
});
|
|
2041
1886
|
}
|
|
2042
1887
|
const { usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
1888
|
+
const supportedFunctionResponseUrls = usesGemini3Features && config.downloadToolResultFiles?.supportsGoogleCloudStorageUrls ? googleCloudStorageFunctionResponseUrls : void 0;
|
|
2043
1889
|
const promptWithDownloadedToolResultFiles = config.downloadToolResultFiles ? await downloadToolResultFiles(prompt, {
|
|
2044
1890
|
abortSignal,
|
|
2045
|
-
maxBytes: config.downloadToolResultFiles.maxBytes
|
|
1891
|
+
maxBytes: config.downloadToolResultFiles.maxBytes,
|
|
1892
|
+
supportedUrls: supportedFunctionResponseUrls
|
|
2046
1893
|
}) : prompt;
|
|
2047
1894
|
const { contents, systemInstruction } = convertToGoogleMessages(
|
|
2048
1895
|
promptWithDownloadedToolResultFiles,
|
|
@@ -2052,7 +1899,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2052
1899
|
onWarning: (warning) => warnings.push(warning),
|
|
2053
1900
|
providerOptionsNames,
|
|
2054
1901
|
supportsFunctionResponseParts: usesGemini3Features,
|
|
2055
|
-
includeFunctionCallIds: !isVertexProvider
|
|
1902
|
+
includeFunctionCallIds: !isVertexProvider,
|
|
1903
|
+
supportedFunctionResponseUrls
|
|
2056
1904
|
}
|
|
2057
1905
|
);
|
|
2058
1906
|
const {
|
|
@@ -2076,22 +1924,22 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2076
1924
|
modelId,
|
|
2077
1925
|
warnings
|
|
2078
1926
|
});
|
|
2079
|
-
const thinkingConfig =
|
|
2080
|
-
const streamFunctionCallArguments = isStreaming && isVertexProvider ?
|
|
2081
|
-
const safetyThreshold = googleOptions
|
|
2082
|
-
const safetySettings =
|
|
1927
|
+
const thinkingConfig = googleOptions?.thinkingConfig || resolvedThinking ? { ...resolvedThinking, ...googleOptions?.thinkingConfig } : void 0;
|
|
1928
|
+
const streamFunctionCallArguments = isStreaming && isVertexProvider ? googleOptions?.streamFunctionCallArguments ?? false : void 0;
|
|
1929
|
+
const safetyThreshold = googleOptions?.threshold;
|
|
1930
|
+
const safetySettings = googleOptions?.safetySettings ?? (safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
|
|
2083
1931
|
category,
|
|
2084
1932
|
threshold: safetyThreshold
|
|
2085
|
-
})) : void 0;
|
|
2086
|
-
const toolConfig = googleToolConfig || streamFunctionCallArguments ||
|
|
1933
|
+
})) : void 0);
|
|
1934
|
+
const toolConfig = googleToolConfig || streamFunctionCallArguments || googleOptions?.retrievalConfig ? {
|
|
2087
1935
|
...googleToolConfig,
|
|
2088
1936
|
...streamFunctionCallArguments && {
|
|
2089
1937
|
functionCallingConfig: {
|
|
2090
|
-
...googleToolConfig
|
|
1938
|
+
...googleToolConfig?.functionCallingConfig,
|
|
2091
1939
|
streamFunctionCallArguments: true
|
|
2092
1940
|
}
|
|
2093
1941
|
},
|
|
2094
|
-
...
|
|
1942
|
+
...googleOptions?.retrievalConfig && {
|
|
2095
1943
|
retrievalConfig: googleOptions.retrievalConfig
|
|
2096
1944
|
}
|
|
2097
1945
|
} : void 0;
|
|
@@ -2108,18 +1956,18 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2108
1956
|
stopSequences,
|
|
2109
1957
|
seed,
|
|
2110
1958
|
// response format:
|
|
2111
|
-
responseMimeType:
|
|
2112
|
-
|
|
2113
|
-
// so this is needed as an escape hatch:
|
|
1959
|
+
responseMimeType: responseFormat?.type === "json" ? "application/json" : void 0,
|
|
1960
|
+
responseJsonSchema: responseFormat?.type === "json" && responseFormat.schema != null && // Google does not support all JSON Schema features in
|
|
1961
|
+
// responseJsonSchema, so this is needed as an escape hatch:
|
|
2114
1962
|
// TODO convert into provider option
|
|
2115
|
-
(
|
|
2116
|
-
...
|
|
1963
|
+
(googleOptions?.structuredOutputs ?? true) ? sanitizeResponseJsonSchema(responseFormat.schema) : void 0,
|
|
1964
|
+
...googleOptions?.audioTimestamp && {
|
|
2117
1965
|
audioTimestamp: googleOptions.audioTimestamp
|
|
2118
1966
|
},
|
|
2119
1967
|
// provider options:
|
|
2120
|
-
responseModalities: googleOptions
|
|
1968
|
+
responseModalities: googleOptions?.responseModalities,
|
|
2121
1969
|
thinkingConfig,
|
|
2122
|
-
...
|
|
1970
|
+
...googleOptions?.mediaResolution && {
|
|
2123
1971
|
mediaResolution: googleOptions.mediaResolution
|
|
2124
1972
|
},
|
|
2125
1973
|
...imageConfig && { imageConfig }
|
|
@@ -2129,8 +1977,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2129
1977
|
safetySettings,
|
|
2130
1978
|
tools: googleTools2,
|
|
2131
1979
|
toolConfig,
|
|
2132
|
-
cachedContent: googleOptions
|
|
2133
|
-
labels: googleOptions
|
|
1980
|
+
cachedContent: googleOptions?.cachedContent,
|
|
1981
|
+
labels: googleOptions?.labels,
|
|
2134
1982
|
serviceTier: bodyServiceTier
|
|
2135
1983
|
},
|
|
2136
1984
|
warnings: [...warnings, ...toolWarnings],
|
|
@@ -2154,27 +2002,29 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2154
2002
|
providerOptionsNames,
|
|
2155
2003
|
toolNameMapping
|
|
2156
2004
|
}) {
|
|
2157
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2158
2005
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
2159
2006
|
providerOptionsNames.map((name) => [name, payload])
|
|
2160
2007
|
);
|
|
2161
|
-
const candidate =
|
|
2162
|
-
const promptBlockReason =
|
|
2163
|
-
const
|
|
2164
|
-
|
|
2008
|
+
const candidate = response.candidates?.[0];
|
|
2009
|
+
const promptBlockReason = response.promptFeedback?.blockReason;
|
|
2010
|
+
const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
|
|
2011
|
+
promptBlockReason
|
|
2012
|
+
) ? promptBlockReason : void 0;
|
|
2013
|
+
const isPromptBlocked = candidate?.finishReason == null && confirmedPromptBlockReason != null;
|
|
2014
|
+
const rawFinishReason = candidate?.finishReason ?? confirmedPromptBlockReason;
|
|
2165
2015
|
const content = [];
|
|
2166
|
-
const parts =
|
|
2016
|
+
const parts = candidate?.content?.parts ?? [];
|
|
2167
2017
|
const usageMetadata = response.usageMetadata;
|
|
2168
2018
|
let lastCodeExecutionToolCallId;
|
|
2169
2019
|
let lastServerToolCallId;
|
|
2170
2020
|
for (const part of parts) {
|
|
2171
|
-
if ("executableCode" in part &&
|
|
2021
|
+
if ("executableCode" in part && part.executableCode?.code) {
|
|
2172
2022
|
const toolCallId = config.generateId();
|
|
2173
2023
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2174
2024
|
content.push({
|
|
2175
2025
|
type: "tool-call",
|
|
2176
2026
|
toolCallId,
|
|
2177
|
-
toolName:
|
|
2027
|
+
toolName: toolNameMapping?.toCustomToolName("code_execution") ?? "code_execution",
|
|
2178
2028
|
input: JSON.stringify(part.executableCode),
|
|
2179
2029
|
providerExecuted: true
|
|
2180
2030
|
});
|
|
@@ -2183,10 +2033,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2183
2033
|
type: "tool-result",
|
|
2184
2034
|
// Results correspond to the most recent executable code part.
|
|
2185
2035
|
toolCallId: lastCodeExecutionToolCallId,
|
|
2186
|
-
toolName:
|
|
2036
|
+
toolName: toolNameMapping?.toCustomToolName("code_execution") ?? "code_execution",
|
|
2187
2037
|
result: {
|
|
2188
2038
|
outcome: part.codeExecutionResult.outcome,
|
|
2189
|
-
output:
|
|
2039
|
+
output: part.codeExecutionResult.output ?? ""
|
|
2190
2040
|
}
|
|
2191
2041
|
});
|
|
2192
2042
|
} else if ("text" in part && part.text != null) {
|
|
@@ -2210,7 +2060,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2210
2060
|
type: "tool-call",
|
|
2211
2061
|
toolCallId: part.functionCall.id || config.generateId(),
|
|
2212
2062
|
toolName: part.functionCall.name,
|
|
2213
|
-
input: JSON.stringify(
|
|
2063
|
+
input: JSON.stringify(part.functionCall.args ?? {}),
|
|
2214
2064
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
2215
2065
|
thoughtSignature: part.thoughtSignature
|
|
2216
2066
|
}) : void 0
|
|
@@ -2233,7 +2083,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2233
2083
|
type: "tool-call",
|
|
2234
2084
|
toolCallId,
|
|
2235
2085
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2236
|
-
input: JSON.stringify(
|
|
2086
|
+
input: JSON.stringify(part.toolCall.args ?? {}),
|
|
2237
2087
|
providerExecuted: true,
|
|
2238
2088
|
dynamic: true,
|
|
2239
2089
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
@@ -2251,7 +2101,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2251
2101
|
type: "tool-result",
|
|
2252
2102
|
toolCallId: responseToolCallId,
|
|
2253
2103
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2254
|
-
result:
|
|
2104
|
+
result: part.toolResponse.response ?? {},
|
|
2255
2105
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
2256
2106
|
thoughtSignature: part.thoughtSignature,
|
|
2257
2107
|
serverToolCallId: responseToolCallId,
|
|
@@ -2264,10 +2114,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2264
2114
|
lastServerToolCallId = void 0;
|
|
2265
2115
|
}
|
|
2266
2116
|
}
|
|
2267
|
-
const sources =
|
|
2268
|
-
groundingMetadata: candidate
|
|
2117
|
+
const sources = extractSources({
|
|
2118
|
+
groundingMetadata: candidate?.groundingMetadata,
|
|
2269
2119
|
generateId: config.generateId
|
|
2270
|
-
})
|
|
2120
|
+
}) ?? [];
|
|
2271
2121
|
for (const source of sources) {
|
|
2272
2122
|
content.push(source);
|
|
2273
2123
|
}
|
|
@@ -2286,17 +2136,17 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2286
2136
|
usage: convertGoogleUsage(usageMetadata),
|
|
2287
2137
|
warnings,
|
|
2288
2138
|
providerMetadata: wrapProviderMetadata({
|
|
2289
|
-
promptFeedback:
|
|
2290
|
-
groundingMetadata:
|
|
2291
|
-
urlContextMetadata:
|
|
2292
|
-
safetyRatings:
|
|
2293
|
-
usageMetadata: usageMetadata
|
|
2294
|
-
finishMessage:
|
|
2295
|
-
serviceTier:
|
|
2139
|
+
promptFeedback: response.promptFeedback ?? null,
|
|
2140
|
+
groundingMetadata: candidate?.groundingMetadata ?? null,
|
|
2141
|
+
urlContextMetadata: candidate?.urlContextMetadata ?? null,
|
|
2142
|
+
safetyRatings: candidate?.safetyRatings ?? null,
|
|
2143
|
+
usageMetadata: usageMetadata ?? null,
|
|
2144
|
+
finishMessage: candidate?.finishMessage ?? null,
|
|
2145
|
+
serviceTier: usageMetadata?.serviceTier ?? null
|
|
2296
2146
|
}),
|
|
2297
2147
|
response: {
|
|
2298
2148
|
// TODO timestamp, model id
|
|
2299
|
-
id:
|
|
2149
|
+
id: response.responseId ?? void 0
|
|
2300
2150
|
}
|
|
2301
2151
|
};
|
|
2302
2152
|
}
|
|
@@ -2377,9 +2227,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2377
2227
|
raw: void 0
|
|
2378
2228
|
};
|
|
2379
2229
|
let usage = void 0;
|
|
2380
|
-
let
|
|
2230
|
+
let promptFeedback = null;
|
|
2381
2231
|
let lastGroundingMetadata = null;
|
|
2382
2232
|
let lastUrlContextMetadata = null;
|
|
2233
|
+
let lastSafetyRatings = null;
|
|
2234
|
+
let lastFinishMessage = null;
|
|
2235
|
+
let confirmedPromptBlockReason;
|
|
2383
2236
|
const generateId4 = this.config.generateId;
|
|
2384
2237
|
let hasToolCalls = false;
|
|
2385
2238
|
let hasEmittedResponseMetadata = false;
|
|
@@ -2425,7 +2278,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2425
2278
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2426
2279
|
},
|
|
2427
2280
|
transform(chunk, controller) {
|
|
2428
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2429
2281
|
if (options.includeRawChunks) {
|
|
2430
2282
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2431
2283
|
}
|
|
@@ -2445,33 +2297,35 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2445
2297
|
if (usageMetadata != null) {
|
|
2446
2298
|
usage = usageMetadata;
|
|
2447
2299
|
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2300
|
+
if (value.promptFeedback != null && confirmedPromptBlockReason == null) {
|
|
2301
|
+
promptFeedback = value.promptFeedback;
|
|
2302
|
+
if (isConfirmedPromptBlockReason(value.promptFeedback.blockReason)) {
|
|
2303
|
+
confirmedPromptBlockReason = value.promptFeedback.blockReason;
|
|
2452
2304
|
finishReason = {
|
|
2453
2305
|
unified: "content-filter",
|
|
2454
|
-
raw:
|
|
2306
|
+
raw: confirmedPromptBlockReason
|
|
2455
2307
|
};
|
|
2456
|
-
providerMetadata = wrapProviderMetadata({
|
|
2457
|
-
promptFeedback: (_c = value.promptFeedback) != null ? _c : null,
|
|
2458
|
-
groundingMetadata: lastGroundingMetadata,
|
|
2459
|
-
urlContextMetadata: lastUrlContextMetadata,
|
|
2460
|
-
safetyRatings: null,
|
|
2461
|
-
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2462
|
-
finishMessage: null,
|
|
2463
|
-
serviceTier: (_d = usage == null ? void 0 : usage.serviceTier) != null ? _d : null
|
|
2464
|
-
});
|
|
2465
2308
|
}
|
|
2466
|
-
return;
|
|
2467
2309
|
}
|
|
2468
|
-
const
|
|
2469
|
-
if (candidate
|
|
2470
|
-
|
|
2310
|
+
const candidate = value.candidates?.[0];
|
|
2311
|
+
if (candidate != null) {
|
|
2312
|
+
if (candidate.groundingMetadata != null) {
|
|
2313
|
+
lastGroundingMetadata = candidate.groundingMetadata;
|
|
2314
|
+
}
|
|
2315
|
+
if (candidate.urlContextMetadata != null) {
|
|
2316
|
+
lastUrlContextMetadata = candidate.urlContextMetadata;
|
|
2317
|
+
}
|
|
2318
|
+
if (candidate.safetyRatings != null) {
|
|
2319
|
+
lastSafetyRatings = candidate.safetyRatings;
|
|
2320
|
+
}
|
|
2321
|
+
if (candidate.finishMessage != null) {
|
|
2322
|
+
lastFinishMessage = candidate.finishMessage;
|
|
2323
|
+
}
|
|
2471
2324
|
}
|
|
2472
|
-
if (
|
|
2473
|
-
|
|
2325
|
+
if (confirmedPromptBlockReason != null || candidate == null) {
|
|
2326
|
+
return;
|
|
2474
2327
|
}
|
|
2328
|
+
const content = candidate.content;
|
|
2475
2329
|
const sources = extractSources({
|
|
2476
2330
|
groundingMetadata: candidate.groundingMetadata,
|
|
2477
2331
|
generateId: generateId4
|
|
@@ -2485,9 +2339,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2485
2339
|
}
|
|
2486
2340
|
}
|
|
2487
2341
|
if (content != null) {
|
|
2488
|
-
const parts =
|
|
2342
|
+
const parts = content.parts ?? [];
|
|
2489
2343
|
for (const part of parts) {
|
|
2490
|
-
if ("executableCode" in part &&
|
|
2344
|
+
if ("executableCode" in part && part.executableCode?.code) {
|
|
2491
2345
|
const toolCallId = generateId4();
|
|
2492
2346
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2493
2347
|
controller.enqueue({
|
|
@@ -2506,7 +2360,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2506
2360
|
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2507
2361
|
result: {
|
|
2508
2362
|
outcome: part.codeExecutionResult.outcome,
|
|
2509
|
-
output:
|
|
2363
|
+
output: part.codeExecutionResult.output ?? ""
|
|
2510
2364
|
}
|
|
2511
2365
|
});
|
|
2512
2366
|
}
|
|
@@ -2606,7 +2460,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2606
2460
|
type: "tool-call",
|
|
2607
2461
|
toolCallId,
|
|
2608
2462
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2609
|
-
input: JSON.stringify(
|
|
2463
|
+
input: JSON.stringify(part.toolCall.args ?? {}),
|
|
2610
2464
|
providerExecuted: true,
|
|
2611
2465
|
dynamic: true,
|
|
2612
2466
|
providerMetadata: serverMeta
|
|
@@ -2622,7 +2476,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2622
2476
|
type: "tool-result",
|
|
2623
2477
|
toolCallId: responseToolCallId,
|
|
2624
2478
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2625
|
-
result:
|
|
2479
|
+
result: part.toolResponse.response ?? {},
|
|
2626
2480
|
providerMetadata: serverMeta
|
|
2627
2481
|
});
|
|
2628
2482
|
lastServerToolCallId = void 0;
|
|
@@ -2689,7 +2543,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2689
2543
|
} else if (isCompleteCall) {
|
|
2690
2544
|
const toolCallId = part.functionCall.id || generateId4();
|
|
2691
2545
|
const toolName = part.functionCall.name;
|
|
2692
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify(
|
|
2546
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify(part.functionCall.args ?? {});
|
|
2693
2547
|
controller.enqueue({
|
|
2694
2548
|
type: "tool-input-start",
|
|
2695
2549
|
id: toolCallId,
|
|
@@ -2740,26 +2594,14 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2740
2594
|
}
|
|
2741
2595
|
}
|
|
2742
2596
|
}
|
|
2743
|
-
|
|
2744
|
-
const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
|
|
2745
|
-
const rawFinishReason = (_m = (_l = candidate.finishReason) != null ? _l : promptBlockReason) != null ? _m : void 0;
|
|
2746
|
-
if (rawFinishReason != null) {
|
|
2597
|
+
if (candidate.finishReason != null) {
|
|
2747
2598
|
finishReason = {
|
|
2748
|
-
unified:
|
|
2749
|
-
finishReason:
|
|
2599
|
+
unified: mapGoogleFinishReason({
|
|
2600
|
+
finishReason: candidate.finishReason,
|
|
2750
2601
|
hasToolCalls
|
|
2751
2602
|
}),
|
|
2752
|
-
raw:
|
|
2603
|
+
raw: candidate.finishReason
|
|
2753
2604
|
};
|
|
2754
|
-
providerMetadata = wrapProviderMetadata({
|
|
2755
|
-
promptFeedback: (_n = value.promptFeedback) != null ? _n : null,
|
|
2756
|
-
groundingMetadata: lastGroundingMetadata,
|
|
2757
|
-
urlContextMetadata: lastUrlContextMetadata,
|
|
2758
|
-
safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
|
|
2759
|
-
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2760
|
-
finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
|
|
2761
|
-
serviceTier: (_q = usage == null ? void 0 : usage.serviceTier) != null ? _q : null
|
|
2762
|
-
});
|
|
2763
2605
|
}
|
|
2764
2606
|
},
|
|
2765
2607
|
flush(controller) {
|
|
@@ -2779,7 +2621,15 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2779
2621
|
type: "finish",
|
|
2780
2622
|
finishReason,
|
|
2781
2623
|
usage: convertGoogleUsage(usage),
|
|
2782
|
-
providerMetadata
|
|
2624
|
+
providerMetadata: wrapProviderMetadata({
|
|
2625
|
+
promptFeedback,
|
|
2626
|
+
groundingMetadata: lastGroundingMetadata,
|
|
2627
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
2628
|
+
safetyRatings: lastSafetyRatings,
|
|
2629
|
+
usageMetadata: usage ?? null,
|
|
2630
|
+
finishMessage: lastFinishMessage,
|
|
2631
|
+
serviceTier: usage?.serviceTier ?? null
|
|
2632
|
+
})
|
|
2783
2633
|
});
|
|
2784
2634
|
}
|
|
2785
2635
|
})
|
|
@@ -2838,13 +2688,12 @@ function resolveGemini3ThinkingConfig({
|
|
|
2838
2688
|
return { thinkingLevel };
|
|
2839
2689
|
}
|
|
2840
2690
|
function getMinimumThinkingLevelForGemini3Model(modelId) {
|
|
2841
|
-
|
|
2842
|
-
const modelName = (_a = modelId.split("/").at(-1)) == null ? void 0 : _a.toLowerCase();
|
|
2691
|
+
const modelName = modelId.split("/").at(-1)?.toLowerCase();
|
|
2843
2692
|
if (modelName === "gemini-flash-latest") {
|
|
2844
2693
|
return "low";
|
|
2845
2694
|
}
|
|
2846
2695
|
const versionMatch = /^gemini-(\d+)\.(\d+)-flash(?:$|-(?!lite(?:-|$)))/.exec(
|
|
2847
|
-
modelName
|
|
2696
|
+
modelName ?? ""
|
|
2848
2697
|
);
|
|
2849
2698
|
if (versionMatch == null) {
|
|
2850
2699
|
return "minimal";
|
|
@@ -2877,8 +2726,7 @@ function extractSources({
|
|
|
2877
2726
|
groundingMetadata,
|
|
2878
2727
|
generateId: generateId4
|
|
2879
2728
|
}) {
|
|
2880
|
-
|
|
2881
|
-
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
2729
|
+
if (!groundingMetadata?.groundingChunks) {
|
|
2882
2730
|
return void 0;
|
|
2883
2731
|
}
|
|
2884
2732
|
const sources = [];
|
|
@@ -2889,7 +2737,7 @@ function extractSources({
|
|
|
2889
2737
|
sourceType: "url",
|
|
2890
2738
|
id: generateId4(),
|
|
2891
2739
|
url: chunk.web.uri,
|
|
2892
|
-
title:
|
|
2740
|
+
title: chunk.web.title ?? void 0
|
|
2893
2741
|
});
|
|
2894
2742
|
} else if (chunk.image != null) {
|
|
2895
2743
|
sources.push({
|
|
@@ -2899,7 +2747,7 @@ function extractSources({
|
|
|
2899
2747
|
// Google requires attribution to the source URI, not the actual image URI.
|
|
2900
2748
|
// TODO: add another type in v7 to allow both the image and source URL to be included separately
|
|
2901
2749
|
url: chunk.image.sourceUri,
|
|
2902
|
-
title:
|
|
2750
|
+
title: chunk.image.title ?? void 0
|
|
2903
2751
|
});
|
|
2904
2752
|
} else if (chunk.retrievedContext != null) {
|
|
2905
2753
|
const uri = chunk.retrievedContext.uri;
|
|
@@ -2910,10 +2758,10 @@ function extractSources({
|
|
|
2910
2758
|
sourceType: "url",
|
|
2911
2759
|
id: generateId4(),
|
|
2912
2760
|
url: uri,
|
|
2913
|
-
title:
|
|
2761
|
+
title: chunk.retrievedContext.title ?? void 0
|
|
2914
2762
|
});
|
|
2915
2763
|
} else if (uri) {
|
|
2916
|
-
const title =
|
|
2764
|
+
const title = chunk.retrievedContext.title ?? "Unknown Document";
|
|
2917
2765
|
let mediaType = "application/octet-stream";
|
|
2918
2766
|
let filename = void 0;
|
|
2919
2767
|
if (uri.endsWith(".pdf")) {
|
|
@@ -2943,7 +2791,7 @@ function extractSources({
|
|
|
2943
2791
|
filename
|
|
2944
2792
|
});
|
|
2945
2793
|
} else if (fileSearchStore) {
|
|
2946
|
-
const title =
|
|
2794
|
+
const title = chunk.retrievedContext.title ?? "Unknown Document";
|
|
2947
2795
|
sources.push({
|
|
2948
2796
|
type: "source",
|
|
2949
2797
|
sourceType: "document",
|
|
@@ -2960,238 +2808,241 @@ function extractSources({
|
|
|
2960
2808
|
sourceType: "url",
|
|
2961
2809
|
id: generateId4(),
|
|
2962
2810
|
url: chunk.maps.uri,
|
|
2963
|
-
title:
|
|
2811
|
+
title: chunk.maps.title ?? void 0
|
|
2964
2812
|
});
|
|
2965
2813
|
}
|
|
2966
2814
|
}
|
|
2967
2815
|
}
|
|
2968
2816
|
return sources.length > 0 ? sources : void 0;
|
|
2969
2817
|
}
|
|
2970
|
-
var getGroundingMetadataSchema = () =>
|
|
2971
|
-
webSearchQueries:
|
|
2972
|
-
imageSearchQueries:
|
|
2973
|
-
retrievalQueries:
|
|
2974
|
-
searchEntryPoint:
|
|
2975
|
-
groundingChunks:
|
|
2976
|
-
|
|
2977
|
-
web:
|
|
2978
|
-
image:
|
|
2979
|
-
sourceUri:
|
|
2980
|
-
imageUri:
|
|
2981
|
-
title:
|
|
2982
|
-
domain:
|
|
2818
|
+
var getGroundingMetadataSchema = () => z6.object({
|
|
2819
|
+
webSearchQueries: z6.array(z6.string()).nullish(),
|
|
2820
|
+
imageSearchQueries: z6.array(z6.string()).nullish(),
|
|
2821
|
+
retrievalQueries: z6.array(z6.string()).nullish(),
|
|
2822
|
+
searchEntryPoint: z6.object({ renderedContent: z6.string() }).nullish(),
|
|
2823
|
+
groundingChunks: z6.array(
|
|
2824
|
+
z6.object({
|
|
2825
|
+
web: z6.object({ uri: z6.string(), title: z6.string().nullish() }).nullish(),
|
|
2826
|
+
image: z6.object({
|
|
2827
|
+
sourceUri: z6.string(),
|
|
2828
|
+
imageUri: z6.string(),
|
|
2829
|
+
title: z6.string().nullish(),
|
|
2830
|
+
domain: z6.string().nullish()
|
|
2983
2831
|
}).nullish(),
|
|
2984
|
-
retrievedContext:
|
|
2985
|
-
uri:
|
|
2986
|
-
title:
|
|
2987
|
-
text:
|
|
2988
|
-
fileSearchStore:
|
|
2832
|
+
retrievedContext: z6.object({
|
|
2833
|
+
uri: z6.string().nullish(),
|
|
2834
|
+
title: z6.string().nullish(),
|
|
2835
|
+
text: z6.string().nullish(),
|
|
2836
|
+
fileSearchStore: z6.string().nullish()
|
|
2989
2837
|
}).nullish(),
|
|
2990
|
-
maps:
|
|
2991
|
-
uri:
|
|
2992
|
-
title:
|
|
2993
|
-
text:
|
|
2994
|
-
placeId:
|
|
2838
|
+
maps: z6.object({
|
|
2839
|
+
uri: z6.string().nullish(),
|
|
2840
|
+
title: z6.string().nullish(),
|
|
2841
|
+
text: z6.string().nullish(),
|
|
2842
|
+
placeId: z6.string().nullish()
|
|
2995
2843
|
}).nullish()
|
|
2996
2844
|
})
|
|
2997
2845
|
).nullish(),
|
|
2998
|
-
groundingSupports:
|
|
2999
|
-
|
|
3000
|
-
segment:
|
|
3001
|
-
startIndex:
|
|
3002
|
-
endIndex:
|
|
3003
|
-
text:
|
|
2846
|
+
groundingSupports: z6.array(
|
|
2847
|
+
z6.object({
|
|
2848
|
+
segment: z6.object({
|
|
2849
|
+
startIndex: z6.number().nullish(),
|
|
2850
|
+
endIndex: z6.number().nullish(),
|
|
2851
|
+
text: z6.string().nullish()
|
|
3004
2852
|
}).nullish(),
|
|
3005
|
-
segment_text:
|
|
3006
|
-
groundingChunkIndices:
|
|
3007
|
-
supportChunkIndices:
|
|
3008
|
-
confidenceScores:
|
|
3009
|
-
confidenceScore:
|
|
2853
|
+
segment_text: z6.string().nullish(),
|
|
2854
|
+
groundingChunkIndices: z6.array(z6.number()).nullish(),
|
|
2855
|
+
supportChunkIndices: z6.array(z6.number()).nullish(),
|
|
2856
|
+
confidenceScores: z6.array(z6.number()).nullish(),
|
|
2857
|
+
confidenceScore: z6.array(z6.number()).nullish()
|
|
3010
2858
|
})
|
|
3011
2859
|
).nullish(),
|
|
3012
|
-
retrievalMetadata:
|
|
3013
|
-
|
|
3014
|
-
webDynamicRetrievalScore:
|
|
2860
|
+
retrievalMetadata: z6.union([
|
|
2861
|
+
z6.object({
|
|
2862
|
+
webDynamicRetrievalScore: z6.number()
|
|
3015
2863
|
}),
|
|
3016
|
-
|
|
2864
|
+
z6.object({})
|
|
3017
2865
|
]).nullish()
|
|
3018
2866
|
});
|
|
3019
|
-
var partialArgSchema =
|
|
3020
|
-
jsonPath:
|
|
3021
|
-
stringValue:
|
|
3022
|
-
numberValue:
|
|
3023
|
-
boolValue:
|
|
3024
|
-
nullValue:
|
|
3025
|
-
willContinue:
|
|
2867
|
+
var partialArgSchema = z6.object({
|
|
2868
|
+
jsonPath: z6.string(),
|
|
2869
|
+
stringValue: z6.string().nullish(),
|
|
2870
|
+
numberValue: z6.number().nullish(),
|
|
2871
|
+
boolValue: z6.boolean().nullish(),
|
|
2872
|
+
nullValue: z6.unknown().nullish(),
|
|
2873
|
+
willContinue: z6.boolean().nullish()
|
|
3026
2874
|
});
|
|
3027
|
-
var getContentSchema = () =>
|
|
3028
|
-
parts:
|
|
3029
|
-
|
|
2875
|
+
var getContentSchema = () => z6.object({
|
|
2876
|
+
parts: z6.array(
|
|
2877
|
+
z6.union([
|
|
3030
2878
|
// note: order matters since text can be fully empty
|
|
3031
|
-
|
|
3032
|
-
functionCall:
|
|
3033
|
-
id:
|
|
3034
|
-
name:
|
|
3035
|
-
args:
|
|
3036
|
-
partialArgs:
|
|
3037
|
-
willContinue:
|
|
2879
|
+
z6.object({
|
|
2880
|
+
functionCall: z6.object({
|
|
2881
|
+
id: z6.string().nullish(),
|
|
2882
|
+
name: z6.string().nullish(),
|
|
2883
|
+
args: z6.unknown().nullish(),
|
|
2884
|
+
partialArgs: z6.array(partialArgSchema).nullish(),
|
|
2885
|
+
willContinue: z6.boolean().nullish()
|
|
3038
2886
|
}),
|
|
3039
|
-
thoughtSignature:
|
|
2887
|
+
thoughtSignature: z6.string().nullish()
|
|
3040
2888
|
}),
|
|
3041
|
-
|
|
3042
|
-
inlineData:
|
|
3043
|
-
mimeType:
|
|
3044
|
-
data:
|
|
2889
|
+
z6.object({
|
|
2890
|
+
inlineData: z6.object({
|
|
2891
|
+
mimeType: z6.string(),
|
|
2892
|
+
data: z6.string()
|
|
3045
2893
|
}),
|
|
3046
|
-
thought:
|
|
3047
|
-
thoughtSignature:
|
|
2894
|
+
thought: z6.boolean().nullish(),
|
|
2895
|
+
thoughtSignature: z6.string().nullish()
|
|
3048
2896
|
}),
|
|
3049
|
-
|
|
3050
|
-
toolCall:
|
|
3051
|
-
toolType:
|
|
3052
|
-
args:
|
|
3053
|
-
id:
|
|
2897
|
+
z6.object({
|
|
2898
|
+
toolCall: z6.object({
|
|
2899
|
+
toolType: z6.string(),
|
|
2900
|
+
args: z6.unknown().nullish(),
|
|
2901
|
+
id: z6.string()
|
|
3054
2902
|
}),
|
|
3055
|
-
thoughtSignature:
|
|
2903
|
+
thoughtSignature: z6.string().nullish()
|
|
3056
2904
|
}),
|
|
3057
|
-
|
|
3058
|
-
toolResponse:
|
|
3059
|
-
toolType:
|
|
3060
|
-
response:
|
|
3061
|
-
id:
|
|
2905
|
+
z6.object({
|
|
2906
|
+
toolResponse: z6.object({
|
|
2907
|
+
toolType: z6.string(),
|
|
2908
|
+
response: z6.unknown().nullish(),
|
|
2909
|
+
id: z6.string()
|
|
3062
2910
|
}),
|
|
3063
|
-
thoughtSignature:
|
|
2911
|
+
thoughtSignature: z6.string().nullish()
|
|
3064
2912
|
}),
|
|
3065
|
-
|
|
3066
|
-
executableCode:
|
|
3067
|
-
language:
|
|
3068
|
-
code:
|
|
2913
|
+
z6.object({
|
|
2914
|
+
executableCode: z6.object({
|
|
2915
|
+
language: z6.string(),
|
|
2916
|
+
code: z6.string()
|
|
3069
2917
|
}).nullish(),
|
|
3070
|
-
codeExecutionResult:
|
|
3071
|
-
outcome:
|
|
3072
|
-
output:
|
|
2918
|
+
codeExecutionResult: z6.object({
|
|
2919
|
+
outcome: z6.string(),
|
|
2920
|
+
output: z6.string().nullish()
|
|
3073
2921
|
}).nullish(),
|
|
3074
|
-
text:
|
|
3075
|
-
thought:
|
|
3076
|
-
thoughtSignature:
|
|
2922
|
+
text: z6.string().nullish(),
|
|
2923
|
+
thought: z6.boolean().nullish(),
|
|
2924
|
+
thoughtSignature: z6.string().nullish()
|
|
3077
2925
|
})
|
|
3078
2926
|
])
|
|
3079
2927
|
).nullish()
|
|
3080
2928
|
});
|
|
3081
|
-
var getSafetyRatingSchema = () =>
|
|
3082
|
-
category:
|
|
3083
|
-
probability:
|
|
3084
|
-
probabilityScore:
|
|
3085
|
-
severity:
|
|
3086
|
-
severityScore:
|
|
3087
|
-
blocked:
|
|
2929
|
+
var getSafetyRatingSchema = () => z6.object({
|
|
2930
|
+
category: z6.string().nullish(),
|
|
2931
|
+
probability: z6.string().nullish(),
|
|
2932
|
+
probabilityScore: z6.number().nullish(),
|
|
2933
|
+
severity: z6.string().nullish(),
|
|
2934
|
+
severityScore: z6.number().nullish(),
|
|
2935
|
+
blocked: z6.boolean().nullish()
|
|
3088
2936
|
});
|
|
3089
|
-
var tokenDetailsSchema =
|
|
3090
|
-
|
|
3091
|
-
modality:
|
|
3092
|
-
tokenCount:
|
|
2937
|
+
var tokenDetailsSchema = z6.array(
|
|
2938
|
+
z6.object({
|
|
2939
|
+
modality: z6.string(),
|
|
2940
|
+
tokenCount: z6.number()
|
|
3093
2941
|
}).loose()
|
|
3094
2942
|
).nullish();
|
|
3095
|
-
var usageSchema =
|
|
3096
|
-
cachedContentTokenCount:
|
|
3097
|
-
thoughtsTokenCount:
|
|
3098
|
-
promptTokenCount:
|
|
3099
|
-
candidatesTokenCount:
|
|
3100
|
-
toolUsePromptTokenCount:
|
|
3101
|
-
totalTokenCount:
|
|
2943
|
+
var usageSchema = z6.object({
|
|
2944
|
+
cachedContentTokenCount: z6.number().nullish(),
|
|
2945
|
+
thoughtsTokenCount: z6.number().nullish(),
|
|
2946
|
+
promptTokenCount: z6.number().nullish(),
|
|
2947
|
+
candidatesTokenCount: z6.number().nullish(),
|
|
2948
|
+
toolUsePromptTokenCount: z6.number().nullish(),
|
|
2949
|
+
totalTokenCount: z6.number().nullish(),
|
|
3102
2950
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
3103
|
-
trafficType:
|
|
3104
|
-
serviceTier:
|
|
2951
|
+
trafficType: z6.string().nullish(),
|
|
2952
|
+
serviceTier: z6.string().nullish(),
|
|
3105
2953
|
// https://ai.google.dev/api/generate-content#Modality
|
|
3106
2954
|
promptTokensDetails: tokenDetailsSchema,
|
|
3107
2955
|
cacheTokensDetails: tokenDetailsSchema,
|
|
3108
2956
|
candidatesTokensDetails: tokenDetailsSchema,
|
|
3109
2957
|
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
3110
2958
|
}).loose();
|
|
3111
|
-
var getUrlContextMetadataSchema = () =>
|
|
3112
|
-
urlMetadata:
|
|
3113
|
-
|
|
3114
|
-
retrievedUrl:
|
|
3115
|
-
urlRetrievalStatus:
|
|
2959
|
+
var getUrlContextMetadataSchema = () => z6.object({
|
|
2960
|
+
urlMetadata: z6.array(
|
|
2961
|
+
z6.object({
|
|
2962
|
+
retrievedUrl: z6.string(),
|
|
2963
|
+
urlRetrievalStatus: z6.string()
|
|
3116
2964
|
})
|
|
3117
2965
|
).nullish()
|
|
3118
2966
|
});
|
|
3119
2967
|
var responseSchema = lazySchema5(
|
|
3120
2968
|
() => zodSchema5(
|
|
3121
|
-
|
|
3122
|
-
responseId:
|
|
3123
|
-
candidates:
|
|
3124
|
-
|
|
3125
|
-
content: getContentSchema().nullish().or(
|
|
3126
|
-
finishReason:
|
|
3127
|
-
finishMessage:
|
|
3128
|
-
safetyRatings:
|
|
2969
|
+
z6.object({
|
|
2970
|
+
responseId: z6.string().nullish(),
|
|
2971
|
+
candidates: z6.array(
|
|
2972
|
+
z6.object({
|
|
2973
|
+
content: getContentSchema().nullish().or(z6.object({}).strict()),
|
|
2974
|
+
finishReason: z6.string().nullish(),
|
|
2975
|
+
finishMessage: z6.string().nullish(),
|
|
2976
|
+
safetyRatings: z6.array(getSafetyRatingSchema()).nullish(),
|
|
3129
2977
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
3130
2978
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
3131
2979
|
})
|
|
3132
2980
|
).nullish(),
|
|
3133
2981
|
usageMetadata: usageSchema.nullish(),
|
|
3134
|
-
promptFeedback:
|
|
3135
|
-
blockReason:
|
|
3136
|
-
safetyRatings:
|
|
2982
|
+
promptFeedback: z6.object({
|
|
2983
|
+
blockReason: z6.string().nullish(),
|
|
2984
|
+
safetyRatings: z6.array(getSafetyRatingSchema()).nullish()
|
|
3137
2985
|
}).nullish()
|
|
3138
2986
|
})
|
|
3139
2987
|
)
|
|
3140
2988
|
);
|
|
3141
2989
|
var chunkSchema = lazySchema5(
|
|
3142
2990
|
() => zodSchema5(
|
|
3143
|
-
|
|
3144
|
-
responseId:
|
|
3145
|
-
candidates:
|
|
3146
|
-
|
|
2991
|
+
z6.object({
|
|
2992
|
+
responseId: z6.string().nullish(),
|
|
2993
|
+
candidates: z6.array(
|
|
2994
|
+
z6.object({
|
|
3147
2995
|
content: getContentSchema().nullish(),
|
|
3148
|
-
finishReason:
|
|
3149
|
-
finishMessage:
|
|
3150
|
-
safetyRatings:
|
|
2996
|
+
finishReason: z6.string().nullish(),
|
|
2997
|
+
finishMessage: z6.string().nullish(),
|
|
2998
|
+
safetyRatings: z6.array(getSafetyRatingSchema()).nullish(),
|
|
3151
2999
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
3152
3000
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
3153
3001
|
})
|
|
3154
3002
|
).nullish(),
|
|
3155
3003
|
usageMetadata: usageSchema.nullish(),
|
|
3156
|
-
promptFeedback:
|
|
3157
|
-
blockReason:
|
|
3158
|
-
safetyRatings:
|
|
3004
|
+
promptFeedback: z6.object({
|
|
3005
|
+
blockReason: z6.string().nullish(),
|
|
3006
|
+
safetyRatings: z6.array(getSafetyRatingSchema()).nullish()
|
|
3159
3007
|
}).nullish()
|
|
3160
3008
|
})
|
|
3161
3009
|
)
|
|
3162
3010
|
);
|
|
3011
|
+
function isConfirmedPromptBlockReason(blockReason) {
|
|
3012
|
+
return blockReason != null && blockReason !== "" && blockReason !== "BLOCK_REASON_UNSPECIFIED" && blockReason !== "BLOCKED_REASON_UNSPECIFIED";
|
|
3013
|
+
}
|
|
3163
3014
|
|
|
3164
3015
|
// src/google-image-model-options.ts
|
|
3165
3016
|
import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
3166
|
-
import { z as
|
|
3017
|
+
import { z as z8 } from "zod/v4";
|
|
3167
3018
|
|
|
3168
3019
|
// src/tool/google-search.ts
|
|
3169
3020
|
import {
|
|
3170
|
-
createProviderExecutedToolFactory,
|
|
3021
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
3171
3022
|
lazySchema as lazySchema6,
|
|
3172
3023
|
zodSchema as zodSchema6
|
|
3173
3024
|
} from "@ai-sdk/provider-utils";
|
|
3174
|
-
import { z as
|
|
3175
|
-
var googleSearchToolArgsBaseSchema =
|
|
3176
|
-
searchTypes:
|
|
3177
|
-
webSearch:
|
|
3178
|
-
imageSearch:
|
|
3025
|
+
import { z as z7 } from "zod/v4";
|
|
3026
|
+
var googleSearchToolArgsBaseSchema = z7.looseObject({
|
|
3027
|
+
searchTypes: z7.object({
|
|
3028
|
+
webSearch: z7.object({}).optional(),
|
|
3029
|
+
imageSearch: z7.object({}).optional()
|
|
3179
3030
|
}).optional(),
|
|
3180
|
-
timeRangeFilter:
|
|
3181
|
-
startTime:
|
|
3182
|
-
endTime:
|
|
3031
|
+
timeRangeFilter: z7.object({
|
|
3032
|
+
startTime: z7.string(),
|
|
3033
|
+
endTime: z7.string()
|
|
3183
3034
|
}).optional()
|
|
3184
3035
|
});
|
|
3185
|
-
var googleSearch =
|
|
3036
|
+
var googleSearch = createProviderExecutedToolFactory2({
|
|
3186
3037
|
id: "google.google_search",
|
|
3187
|
-
inputSchema: lazySchema6(() => zodSchema6(
|
|
3188
|
-
outputSchema: lazySchema6(() => zodSchema6(
|
|
3038
|
+
inputSchema: lazySchema6(() => zodSchema6(z7.object({}))),
|
|
3039
|
+
outputSchema: lazySchema6(() => zodSchema6(z7.object({})))
|
|
3189
3040
|
});
|
|
3190
3041
|
|
|
3191
3042
|
// src/google-image-model-options.ts
|
|
3192
3043
|
var googleImageModelOptionsSchema = lazySchema7(
|
|
3193
3044
|
() => zodSchema7(
|
|
3194
|
-
|
|
3045
|
+
z8.object({
|
|
3195
3046
|
/**
|
|
3196
3047
|
* Enable Google Search grounding for Gemini image models. The value is
|
|
3197
3048
|
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
@@ -3214,47 +3065,47 @@ function assertSupportedBatchRequests(requests) {
|
|
|
3214
3065
|
for (const request of requests) {
|
|
3215
3066
|
const requestType = request.type;
|
|
3216
3067
|
if (requestType !== "text" && requestType !== "image") {
|
|
3217
|
-
throw new
|
|
3068
|
+
throw new UnsupportedFunctionalityError3({
|
|
3218
3069
|
functionality: `batch request type: ${requestType}`,
|
|
3219
3070
|
message: `The Google Batch API does not support batch requests with type "${requestType}".`
|
|
3220
3071
|
});
|
|
3221
3072
|
}
|
|
3222
3073
|
}
|
|
3223
3074
|
}
|
|
3224
|
-
var googleRpcStatusSchema =
|
|
3225
|
-
code:
|
|
3226
|
-
message:
|
|
3227
|
-
status:
|
|
3075
|
+
var googleRpcStatusSchema = z9.object({
|
|
3076
|
+
code: z9.union([z9.number(), z9.string()]).nullish(),
|
|
3077
|
+
message: z9.string().nullish(),
|
|
3078
|
+
status: z9.string().nullish()
|
|
3228
3079
|
});
|
|
3229
|
-
var googleBatchStatsSchema =
|
|
3230
|
-
requestCount:
|
|
3231
|
-
successfulRequestCount:
|
|
3232
|
-
failedRequestCount:
|
|
3233
|
-
pendingRequestCount:
|
|
3080
|
+
var googleBatchStatsSchema = z9.object({
|
|
3081
|
+
requestCount: z9.union([z9.string(), z9.number()]).nullish(),
|
|
3082
|
+
successfulRequestCount: z9.union([z9.string(), z9.number()]).nullish(),
|
|
3083
|
+
failedRequestCount: z9.union([z9.string(), z9.number()]).nullish(),
|
|
3084
|
+
pendingRequestCount: z9.union([z9.string(), z9.number()]).nullish()
|
|
3234
3085
|
});
|
|
3235
|
-
var googleBatchOutputSchema =
|
|
3236
|
-
responsesFile:
|
|
3237
|
-
inlinedResponses:
|
|
3238
|
-
inlinedResponses:
|
|
3239
|
-
|
|
3240
|
-
metadata:
|
|
3241
|
-
key:
|
|
3086
|
+
var googleBatchOutputSchema = z9.object({
|
|
3087
|
+
responsesFile: z9.string().nullish(),
|
|
3088
|
+
inlinedResponses: z9.object({
|
|
3089
|
+
inlinedResponses: z9.array(
|
|
3090
|
+
z9.object({
|
|
3091
|
+
metadata: z9.object({
|
|
3092
|
+
key: z9.string()
|
|
3242
3093
|
}),
|
|
3243
|
-
response:
|
|
3094
|
+
response: z9.unknown().nullish(),
|
|
3244
3095
|
error: googleRpcStatusSchema.nullish()
|
|
3245
3096
|
})
|
|
3246
3097
|
)
|
|
3247
3098
|
}).nullish()
|
|
3248
3099
|
});
|
|
3249
|
-
var googleBatchOperationZodSchema = () =>
|
|
3250
|
-
name:
|
|
3251
|
-
metadata:
|
|
3252
|
-
state:
|
|
3253
|
-
createTime:
|
|
3100
|
+
var googleBatchOperationZodSchema = () => z9.object({
|
|
3101
|
+
name: z9.string(),
|
|
3102
|
+
metadata: z9.object({
|
|
3103
|
+
state: z9.string().nullish(),
|
|
3104
|
+
createTime: z9.string().nullish(),
|
|
3254
3105
|
batchStats: googleBatchStatsSchema.nullish(),
|
|
3255
3106
|
output: googleBatchOutputSchema.nullish()
|
|
3256
3107
|
}).nullish(),
|
|
3257
|
-
done:
|
|
3108
|
+
done: z9.boolean().nullish(),
|
|
3258
3109
|
error: googleRpcStatusSchema.nullish(),
|
|
3259
3110
|
response: googleBatchOutputSchema.nullish()
|
|
3260
3111
|
});
|
|
@@ -3263,40 +3114,40 @@ var googleBatchOperationSchema = lazySchema8(
|
|
|
3263
3114
|
);
|
|
3264
3115
|
var googleBatchListResponseSchema = lazySchema8(
|
|
3265
3116
|
() => zodSchema8(
|
|
3266
|
-
|
|
3267
|
-
operations:
|
|
3268
|
-
nextPageToken:
|
|
3117
|
+
z9.object({
|
|
3118
|
+
operations: z9.array(googleBatchOperationZodSchema()).nullish(),
|
|
3119
|
+
nextPageToken: z9.string().nullish()
|
|
3269
3120
|
})
|
|
3270
3121
|
)
|
|
3271
3122
|
);
|
|
3272
3123
|
var googleBatchCancelResponseSchema = lazySchema8(
|
|
3273
|
-
() => zodSchema8(
|
|
3124
|
+
() => zodSchema8(z9.object({}))
|
|
3274
3125
|
);
|
|
3275
3126
|
var googleFileUploadResponseSchema = lazySchema8(
|
|
3276
3127
|
() => zodSchema8(
|
|
3277
|
-
|
|
3278
|
-
file:
|
|
3279
|
-
name:
|
|
3280
|
-
expirationTime:
|
|
3128
|
+
z9.object({
|
|
3129
|
+
file: z9.object({
|
|
3130
|
+
name: z9.string(),
|
|
3131
|
+
expirationTime: z9.string().nullish()
|
|
3281
3132
|
})
|
|
3282
3133
|
})
|
|
3283
3134
|
)
|
|
3284
3135
|
);
|
|
3285
3136
|
var googleBatchResultLineSchema = lazySchema8(
|
|
3286
3137
|
() => zodSchema8(
|
|
3287
|
-
|
|
3288
|
-
key:
|
|
3289
|
-
response:
|
|
3138
|
+
z9.object({
|
|
3139
|
+
key: z9.string(),
|
|
3140
|
+
response: z9.unknown().nullish(),
|
|
3290
3141
|
error: googleRpcStatusSchema.nullish()
|
|
3291
3142
|
})
|
|
3292
3143
|
)
|
|
3293
3144
|
);
|
|
3294
3145
|
var googleBatchResponsePreviewSchema = lazySchema8(
|
|
3295
3146
|
() => zodSchema8(
|
|
3296
|
-
|
|
3297
|
-
candidates:
|
|
3298
|
-
promptFeedback:
|
|
3299
|
-
blockReason:
|
|
3147
|
+
z9.object({
|
|
3148
|
+
candidates: z9.array(z9.unknown()).nullish(),
|
|
3149
|
+
promptFeedback: z9.object({
|
|
3150
|
+
blockReason: z9.string().nullish()
|
|
3300
3151
|
}).nullish()
|
|
3301
3152
|
})
|
|
3302
3153
|
)
|
|
@@ -3304,11 +3155,10 @@ var googleBatchResponsePreviewSchema = lazySchema8(
|
|
|
3304
3155
|
var GoogleBatch = class {
|
|
3305
3156
|
constructor(options) {
|
|
3306
3157
|
this.specificationVersion = "v4";
|
|
3307
|
-
var _a;
|
|
3308
3158
|
this.provider = options.provider;
|
|
3309
3159
|
this.batchConfig = options.config;
|
|
3310
3160
|
this.supportedUrls = options.supportedUrls;
|
|
3311
|
-
this.batchGenerateId =
|
|
3161
|
+
this.batchGenerateId = options.config.generateId ?? generateId2;
|
|
3312
3162
|
}
|
|
3313
3163
|
async doStartBatch(options) {
|
|
3314
3164
|
assertSupportedBatchRequests(options.requests);
|
|
@@ -3503,7 +3353,6 @@ var GoogleBatch = class {
|
|
|
3503
3353
|
return {};
|
|
3504
3354
|
}
|
|
3505
3355
|
async doListBatches(options) {
|
|
3506
|
-
var _a;
|
|
3507
3356
|
const url = new URL(`${this.batchConfig.baseURL}/batches`);
|
|
3508
3357
|
if (options.limit != null) {
|
|
3509
3358
|
url.searchParams.set("pageSize", String(options.limit));
|
|
@@ -3523,7 +3372,7 @@ var GoogleBatch = class {
|
|
|
3523
3372
|
validateUrl: false
|
|
3524
3373
|
});
|
|
3525
3374
|
return {
|
|
3526
|
-
batches: (
|
|
3375
|
+
batches: (page.operations ?? []).map((operation) => ({
|
|
3527
3376
|
batchId: operation.name,
|
|
3528
3377
|
...convertGoogleBatchStatus(operation)
|
|
3529
3378
|
})),
|
|
@@ -3531,7 +3380,6 @@ var GoogleBatch = class {
|
|
|
3531
3380
|
};
|
|
3532
3381
|
}
|
|
3533
3382
|
async doGetBatchResults(options) {
|
|
3534
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3535
3383
|
const operation = await this.retrieveBatch(options);
|
|
3536
3384
|
const batchStatus = convertGoogleBatchStatus(operation);
|
|
3537
3385
|
if (batchStatus.status === "pending") {
|
|
@@ -3540,7 +3388,7 @@ var GoogleBatch = class {
|
|
|
3540
3388
|
message: `Google batch "${options.batchId}" is not complete.`
|
|
3541
3389
|
});
|
|
3542
3390
|
}
|
|
3543
|
-
const inlinedResponses =
|
|
3391
|
+
const inlinedResponses = operation.metadata?.output?.inlinedResponses?.inlinedResponses ?? operation.response?.inlinedResponses?.inlinedResponses;
|
|
3544
3392
|
if (inlinedResponses != null) {
|
|
3545
3393
|
return convertAsyncIteratorToReadableStream(
|
|
3546
3394
|
this.iterateBatchResults(
|
|
@@ -3552,7 +3400,7 @@ var GoogleBatch = class {
|
|
|
3552
3400
|
)
|
|
3553
3401
|
);
|
|
3554
3402
|
}
|
|
3555
|
-
const responsesFile =
|
|
3403
|
+
const responsesFile = operation.metadata?.output?.responsesFile ?? operation.response?.responsesFile;
|
|
3556
3404
|
if (responsesFile == null) {
|
|
3557
3405
|
if (batchStatus.status === "completed") {
|
|
3558
3406
|
throw new InvalidResponseDataError({
|
|
@@ -3597,7 +3445,6 @@ var GoogleBatch = class {
|
|
|
3597
3445
|
return operation;
|
|
3598
3446
|
}
|
|
3599
3447
|
async *iterateBatchResults(results) {
|
|
3600
|
-
var _a, _b, _c;
|
|
3601
3448
|
for await (const line of results) {
|
|
3602
3449
|
if (line.error != null) {
|
|
3603
3450
|
const error = convertGoogleRpcError(
|
|
@@ -3625,8 +3472,8 @@ var GoogleBatch = class {
|
|
|
3625
3472
|
schema: googleBatchResponsePreviewSchema
|
|
3626
3473
|
});
|
|
3627
3474
|
if (preview.success && (preview.value.candidates == null || preview.value.candidates.length === 0)) {
|
|
3628
|
-
const promptFeedback =
|
|
3629
|
-
const blockReason =
|
|
3475
|
+
const promptFeedback = preview.value.promptFeedback ?? void 0;
|
|
3476
|
+
const blockReason = promptFeedback?.blockReason ?? void 0;
|
|
3630
3477
|
yield {
|
|
3631
3478
|
type: "text",
|
|
3632
3479
|
id: line.key,
|
|
@@ -3640,7 +3487,7 @@ var GoogleBatch = class {
|
|
|
3640
3487
|
providerMetadata: {
|
|
3641
3488
|
google: {
|
|
3642
3489
|
promptFeedback: {
|
|
3643
|
-
blockReason:
|
|
3490
|
+
blockReason: promptFeedback.blockReason ?? null
|
|
3644
3491
|
}
|
|
3645
3492
|
}
|
|
3646
3493
|
}
|
|
@@ -3699,16 +3546,15 @@ var GoogleBatch = class {
|
|
|
3699
3546
|
}
|
|
3700
3547
|
}
|
|
3701
3548
|
async prepareImageRequest(request) {
|
|
3702
|
-
var _a;
|
|
3703
3549
|
const { prompt, n, size, aspectRatio, seed, files, mask, providerOptions } = request.options;
|
|
3704
3550
|
const warnings = [];
|
|
3705
3551
|
if (mask != null) {
|
|
3706
|
-
throw new
|
|
3552
|
+
throw new UnsupportedFunctionalityError3({
|
|
3707
3553
|
functionality: "mask-based image editing in Google batches"
|
|
3708
3554
|
});
|
|
3709
3555
|
}
|
|
3710
3556
|
if (n > 1) {
|
|
3711
|
-
throw new
|
|
3557
|
+
throw new UnsupportedFunctionalityError3({
|
|
3712
3558
|
functionality: "multiple images per Google batch request"
|
|
3713
3559
|
});
|
|
3714
3560
|
}
|
|
@@ -3721,7 +3567,7 @@ var GoogleBatch = class {
|
|
|
3721
3567
|
}
|
|
3722
3568
|
const userContent = [];
|
|
3723
3569
|
if (prompt != null) userContent.push({ type: "text", text: prompt });
|
|
3724
|
-
for (const file of files
|
|
3570
|
+
for (const file of files ?? []) {
|
|
3725
3571
|
userContent.push(
|
|
3726
3572
|
file.type === "url" ? {
|
|
3727
3573
|
type: "file",
|
|
@@ -3743,11 +3589,11 @@ var GoogleBatch = class {
|
|
|
3743
3589
|
responseModalities: _responseModalities,
|
|
3744
3590
|
imageConfig: userImageConfig,
|
|
3745
3591
|
...passthroughGoogleOptions
|
|
3746
|
-
} =
|
|
3592
|
+
} = await parseProviderOptions3({
|
|
3747
3593
|
provider: "google",
|
|
3748
3594
|
providerOptions,
|
|
3749
3595
|
schema: googleLanguageModelOptions
|
|
3750
|
-
})
|
|
3596
|
+
}) ?? {};
|
|
3751
3597
|
const preparedGoogleOptions = await parseProviderOptions3({
|
|
3752
3598
|
provider: "google",
|
|
3753
3599
|
providerOptions: {
|
|
@@ -3769,9 +3615,9 @@ var GoogleBatch = class {
|
|
|
3769
3615
|
prompt: [{ role: "user", content: userContent }],
|
|
3770
3616
|
seed,
|
|
3771
3617
|
providerOptions: {
|
|
3772
|
-
google: preparedGoogleOptions
|
|
3618
|
+
google: preparedGoogleOptions ?? { responseModalities: ["IMAGE"] }
|
|
3773
3619
|
},
|
|
3774
|
-
tools:
|
|
3620
|
+
tools: googleImageOptions?.googleSearch != null ? [
|
|
3775
3621
|
{
|
|
3776
3622
|
type: "provider",
|
|
3777
3623
|
id: "google.google_search",
|
|
@@ -3794,17 +3640,16 @@ var GoogleBatch = class {
|
|
|
3794
3640
|
}
|
|
3795
3641
|
};
|
|
3796
3642
|
function convertGoogleBatchStatus(operation) {
|
|
3797
|
-
|
|
3798
|
-
const rawStatus = (_b = (_a = operation.metadata) == null ? void 0 : _a.state) != null ? _b : void 0;
|
|
3643
|
+
const rawStatus = operation.metadata?.state ?? void 0;
|
|
3799
3644
|
const requestCounts = convertGoogleRequestCounts(
|
|
3800
|
-
|
|
3645
|
+
operation.metadata?.batchStats
|
|
3801
3646
|
);
|
|
3802
|
-
const createdAt =
|
|
3647
|
+
const createdAt = operation.metadata?.createTime ?? void 0;
|
|
3803
3648
|
const error = operation.error != null ? convertGoogleRpcError(operation.error, "Google batch failed.") : void 0;
|
|
3804
3649
|
return {
|
|
3805
3650
|
status: mapGoogleBatchStatus({
|
|
3806
3651
|
rawStatus,
|
|
3807
|
-
done:
|
|
3652
|
+
done: operation.done ?? void 0,
|
|
3808
3653
|
hasError: error != null
|
|
3809
3654
|
}),
|
|
3810
3655
|
...rawStatus != null ? { rawStatus } : {},
|
|
@@ -3840,11 +3685,10 @@ function mapGoogleBatchStatus({
|
|
|
3840
3685
|
}
|
|
3841
3686
|
}
|
|
3842
3687
|
function convertGoogleRequestCounts(counts) {
|
|
3843
|
-
|
|
3844
|
-
const
|
|
3845
|
-
const
|
|
3846
|
-
const
|
|
3847
|
-
const pending = parseCount((_c = counts == null ? void 0 : counts.pendingRequestCount) != null ? _c : 0);
|
|
3688
|
+
const total = parseCount(counts?.requestCount);
|
|
3689
|
+
const completed = parseCount(counts?.successfulRequestCount ?? 0);
|
|
3690
|
+
const failed = parseCount(counts?.failedRequestCount ?? 0);
|
|
3691
|
+
const pending = parseCount(counts?.pendingRequestCount ?? 0);
|
|
3848
3692
|
return normalizeBatchRequestCounts({
|
|
3849
3693
|
total,
|
|
3850
3694
|
pending,
|
|
@@ -3857,9 +3701,8 @@ function parseCount(value) {
|
|
|
3857
3701
|
return typeof count === "number" && Number.isSafeInteger(count) && count >= 0 ? count : void 0;
|
|
3858
3702
|
}
|
|
3859
3703
|
function convertGoogleRpcError(error, fallbackMessage) {
|
|
3860
|
-
var _a;
|
|
3861
3704
|
return {
|
|
3862
|
-
message:
|
|
3705
|
+
message: error.message ?? fallbackMessage,
|
|
3863
3706
|
...error.status != null ? { type: error.status } : {},
|
|
3864
3707
|
...error.code != null ? { code: String(error.code) } : {}
|
|
3865
3708
|
};
|
|
@@ -3877,8 +3720,7 @@ var googleUploadUrlResponseHandler = async ({
|
|
|
3877
3720
|
return { value: uploadUrl };
|
|
3878
3721
|
};
|
|
3879
3722
|
function getGoogleBatchModelId(requests) {
|
|
3880
|
-
|
|
3881
|
-
const modelId = (_a = requests[0]) == null ? void 0 : _a.modelId;
|
|
3723
|
+
const modelId = requests[0]?.modelId;
|
|
3882
3724
|
if (modelId == null) {
|
|
3883
3725
|
throw new InvalidArgumentError({
|
|
3884
3726
|
argument: "requests",
|
|
@@ -3896,12 +3738,11 @@ function getGoogleBatchModelId(requests) {
|
|
|
3896
3738
|
return modelId;
|
|
3897
3739
|
}
|
|
3898
3740
|
function convertGoogleImageBatchResult(result) {
|
|
3899
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3900
3741
|
const images = result.content.flatMap(
|
|
3901
3742
|
(part) => part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data" ? [convertToBase642(part.data.data)] : []
|
|
3902
3743
|
);
|
|
3903
3744
|
if (images.length === 0) return void 0;
|
|
3904
|
-
const googleMetadata =
|
|
3745
|
+
const googleMetadata = result.providerMetadata?.google ?? {};
|
|
3905
3746
|
return {
|
|
3906
3747
|
images,
|
|
3907
3748
|
warnings: result.warnings,
|
|
@@ -3910,32 +3751,17 @@ function convertGoogleImageBatchResult(result) {
|
|
|
3910
3751
|
},
|
|
3911
3752
|
response: {
|
|
3912
3753
|
timestamp: /* @__PURE__ */ new Date(),
|
|
3913
|
-
modelId:
|
|
3914
|
-
headers:
|
|
3754
|
+
modelId: result.response?.modelId ?? "",
|
|
3755
|
+
headers: result.response?.headers
|
|
3915
3756
|
},
|
|
3916
3757
|
usage: {
|
|
3917
3758
|
inputTokens: result.usage.inputTokens.total,
|
|
3918
3759
|
outputTokens: result.usage.outputTokens.total,
|
|
3919
|
-
totalTokens: (
|
|
3760
|
+
totalTokens: (result.usage.inputTokens.total ?? 0) + (result.usage.outputTokens.total ?? 0)
|
|
3920
3761
|
}
|
|
3921
3762
|
};
|
|
3922
3763
|
}
|
|
3923
3764
|
|
|
3924
|
-
// src/tool/code-execution.ts
|
|
3925
|
-
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
3926
|
-
import { z as z9 } from "zod/v4";
|
|
3927
|
-
var codeExecution = createProviderExecutedToolFactory2({
|
|
3928
|
-
id: "google.code_execution",
|
|
3929
|
-
inputSchema: z9.object({
|
|
3930
|
-
language: z9.string().describe("The programming language of the code."),
|
|
3931
|
-
code: z9.string().describe("The code to be executed.")
|
|
3932
|
-
}),
|
|
3933
|
-
outputSchema: z9.object({
|
|
3934
|
-
outcome: z9.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
3935
|
-
output: z9.string().describe("The output from the code execution.")
|
|
3936
|
-
})
|
|
3937
|
-
});
|
|
3938
|
-
|
|
3939
3765
|
// src/tool/enterprise-web-search.ts
|
|
3940
3766
|
import {
|
|
3941
3767
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
@@ -4086,6 +3912,11 @@ import {
|
|
|
4086
3912
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
4087
3913
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
|
|
4088
3914
|
} from "@ai-sdk/provider-utils";
|
|
3915
|
+
var googleImageModelsWithFileInputSupport = /* @__PURE__ */ new Set([
|
|
3916
|
+
"gemini-2.5-flash-image",
|
|
3917
|
+
"gemini-3-pro-image-preview",
|
|
3918
|
+
"gemini-3.1-flash-image-preview"
|
|
3919
|
+
]);
|
|
4089
3920
|
var GoogleImageModel = class _GoogleImageModel {
|
|
4090
3921
|
constructor(modelId, settings, config) {
|
|
4091
3922
|
this.modelId = modelId;
|
|
@@ -4106,13 +3937,18 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
4106
3937
|
if (this.settings.maxImagesPerCall != null) {
|
|
4107
3938
|
return this.settings.maxImagesPerCall;
|
|
4108
3939
|
}
|
|
4109
|
-
return
|
|
3940
|
+
return 1;
|
|
3941
|
+
}
|
|
3942
|
+
get supportsFileInputs() {
|
|
3943
|
+
return googleImageModelsWithFileInputSupport.has(this.modelId) ? true : void 0;
|
|
3944
|
+
}
|
|
3945
|
+
get supportsMaskInputs() {
|
|
3946
|
+
return this.supportsFileInputs === true ? false : void 0;
|
|
4110
3947
|
}
|
|
4111
3948
|
get provider() {
|
|
4112
3949
|
return this.config.provider;
|
|
4113
3950
|
}
|
|
4114
3951
|
async doGenerate(options) {
|
|
4115
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4116
3952
|
if (!this.modelId.startsWith("gemini-")) {
|
|
4117
3953
|
throw new Error(
|
|
4118
3954
|
"Google image models other than Gemini are no longer supported. Use a model ID that starts with `gemini-`."
|
|
@@ -4120,7 +3956,6 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
4120
3956
|
}
|
|
4121
3957
|
const {
|
|
4122
3958
|
prompt,
|
|
4123
|
-
n,
|
|
4124
3959
|
size,
|
|
4125
3960
|
aspectRatio,
|
|
4126
3961
|
seed,
|
|
@@ -4136,11 +3971,6 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
4136
3971
|
"Gemini image models do not support mask-based image editing."
|
|
4137
3972
|
);
|
|
4138
3973
|
}
|
|
4139
|
-
if (n != null && n > 1) {
|
|
4140
|
-
throw new Error(
|
|
4141
|
-
"Gemini image models do not support generating a set number of images per call. Use n=1 or omit the n parameter."
|
|
4142
|
-
);
|
|
4143
|
-
}
|
|
4144
3974
|
if (size != null) {
|
|
4145
3975
|
warnings.push({
|
|
4146
3976
|
type: "unsupported",
|
|
@@ -4185,13 +4015,13 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
4185
4015
|
responseModalities: _strippedResponseModalities,
|
|
4186
4016
|
imageConfig: userImageConfig,
|
|
4187
4017
|
...passthroughGoogleOptions
|
|
4188
|
-
} =
|
|
4018
|
+
} = providerOptions?.google ?? {};
|
|
4189
4019
|
const languageModel = new GoogleLanguageModel(this.modelId, {
|
|
4190
4020
|
provider: this.config.provider,
|
|
4191
4021
|
baseURL: this.config.baseURL,
|
|
4192
|
-
headers:
|
|
4022
|
+
headers: this.config.headers ?? {},
|
|
4193
4023
|
fetch: this.config.fetch,
|
|
4194
|
-
generateId:
|
|
4024
|
+
generateId: this.config.generateId ?? defaultGenerateId
|
|
4195
4025
|
});
|
|
4196
4026
|
const result = await languageModel.doGenerate({
|
|
4197
4027
|
prompt: languageModelPrompt,
|
|
@@ -4208,7 +4038,7 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
4208
4038
|
} : void 0
|
|
4209
4039
|
}
|
|
4210
4040
|
},
|
|
4211
|
-
tools:
|
|
4041
|
+
tools: googleImageOptions?.googleSearch != null ? [
|
|
4212
4042
|
{
|
|
4213
4043
|
type: "provider",
|
|
4214
4044
|
id: "google.google_search",
|
|
@@ -4219,14 +4049,14 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
4219
4049
|
headers,
|
|
4220
4050
|
abortSignal
|
|
4221
4051
|
});
|
|
4222
|
-
const currentDate =
|
|
4052
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
4223
4053
|
const images = [];
|
|
4224
4054
|
for (const part of result.content) {
|
|
4225
4055
|
if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
|
|
4226
4056
|
images.push(convertToBase643(part.data.data));
|
|
4227
4057
|
}
|
|
4228
4058
|
}
|
|
4229
|
-
const languageModelGoogleMetadata =
|
|
4059
|
+
const languageModelGoogleMetadata = result.providerMetadata?.google ?? {};
|
|
4230
4060
|
return {
|
|
4231
4061
|
images,
|
|
4232
4062
|
...result.finishReason.unified === "content-filter" ? { isRetryable: false } : {},
|
|
@@ -4234,18 +4064,19 @@ var GoogleImageModel = class _GoogleImageModel {
|
|
|
4234
4064
|
providerMetadata: {
|
|
4235
4065
|
google: {
|
|
4236
4066
|
...languageModelGoogleMetadata,
|
|
4067
|
+
finishReason: result.finishReason.raw ?? null,
|
|
4237
4068
|
images: images.map(() => ({}))
|
|
4238
4069
|
}
|
|
4239
4070
|
},
|
|
4240
4071
|
response: {
|
|
4241
4072
|
timestamp: currentDate,
|
|
4242
4073
|
modelId: this.modelId,
|
|
4243
|
-
headers:
|
|
4074
|
+
headers: result.response?.headers
|
|
4244
4075
|
},
|
|
4245
4076
|
usage: result.usage ? {
|
|
4246
4077
|
inputTokens: result.usage.inputTokens.total,
|
|
4247
4078
|
outputTokens: result.usage.outputTokens.total,
|
|
4248
|
-
totalTokens: (
|
|
4079
|
+
totalTokens: (result.usage.inputTokens.total ?? 0) + (result.usage.outputTokens.total ?? 0)
|
|
4249
4080
|
} : void 0
|
|
4250
4081
|
};
|
|
4251
4082
|
}
|
|
@@ -4279,7 +4110,6 @@ var GoogleFiles = class {
|
|
|
4279
4110
|
return this.config.provider;
|
|
4280
4111
|
}
|
|
4281
4112
|
async uploadFile(options) {
|
|
4282
|
-
var _a, _b, _c, _d;
|
|
4283
4113
|
const googleOptions = await parseProviderOptions5({
|
|
4284
4114
|
provider: "google",
|
|
4285
4115
|
providerOptions: options.providerOptions,
|
|
@@ -4289,14 +4119,14 @@ var GoogleFiles = class {
|
|
|
4289
4119
|
this.config.headers(),
|
|
4290
4120
|
options.headers
|
|
4291
4121
|
);
|
|
4292
|
-
const fetchFn =
|
|
4122
|
+
const fetchFn = this.config.fetch ?? globalThis.fetch;
|
|
4293
4123
|
const warnings = [];
|
|
4294
4124
|
if (options.filename != null) {
|
|
4295
4125
|
warnings.push({ type: "unsupported", feature: "filename" });
|
|
4296
4126
|
}
|
|
4297
4127
|
const fileBytes = convertInlineFileDataToUint8Array(options.data);
|
|
4298
4128
|
const mediaType = options.mediaType;
|
|
4299
|
-
const displayName = googleOptions
|
|
4129
|
+
const displayName = googleOptions?.displayName;
|
|
4300
4130
|
const baseOrigin = this.config.baseURL.replace(/\/v1beta$/, "");
|
|
4301
4131
|
const initResponse = await fetchFn(`${baseOrigin}/upload/v1beta/files`, {
|
|
4302
4132
|
method: "POST",
|
|
@@ -4347,8 +4177,8 @@ var GoogleFiles = class {
|
|
|
4347
4177
|
}
|
|
4348
4178
|
const uploadResult = await uploadResponse.json();
|
|
4349
4179
|
let file = uploadResult.file;
|
|
4350
|
-
const pollIntervalMs =
|
|
4351
|
-
const pollTimeoutMs =
|
|
4180
|
+
const pollIntervalMs = googleOptions?.pollIntervalMs ?? 2e3;
|
|
4181
|
+
const pollTimeoutMs = googleOptions?.pollTimeoutMs ?? 3e5;
|
|
4352
4182
|
const startTime = Date.now();
|
|
4353
4183
|
while (file.state === "PROCESSING") {
|
|
4354
4184
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
@@ -4382,7 +4212,7 @@ var GoogleFiles = class {
|
|
|
4382
4212
|
return {
|
|
4383
4213
|
warnings,
|
|
4384
4214
|
providerReference: { google: file.uri },
|
|
4385
|
-
mediaType:
|
|
4215
|
+
mediaType: file.mimeType ?? options.mediaType,
|
|
4386
4216
|
providerMetadata: {
|
|
4387
4217
|
google: {
|
|
4388
4218
|
name: file.name,
|
|
@@ -4470,16 +4300,13 @@ var googleVideoModelOptionsSchema = lazySchema15(
|
|
|
4470
4300
|
|
|
4471
4301
|
// src/google-video-model.ts
|
|
4472
4302
|
function getFirstFrameImage(options) {
|
|
4473
|
-
|
|
4474
|
-
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
4303
|
+
return options.frameImages?.find((frame) => frame.frameType === "first_frame")?.image;
|
|
4475
4304
|
}
|
|
4476
4305
|
function resolveStartImage(options) {
|
|
4477
|
-
|
|
4478
|
-
return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
|
|
4306
|
+
return getFirstFrameImage(options) ?? options.image;
|
|
4479
4307
|
}
|
|
4480
4308
|
function getLastFrameImage(options) {
|
|
4481
|
-
|
|
4482
|
-
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "last_frame")) == null ? void 0 : _b.image;
|
|
4309
|
+
return options.frameImages?.find((frame) => frame.frameType === "last_frame")?.image;
|
|
4483
4310
|
}
|
|
4484
4311
|
function getInputReferences(options) {
|
|
4485
4312
|
if (options.frameImages != null && options.frameImages.length > 0) {
|
|
@@ -4577,7 +4404,7 @@ var GoogleVideoModel = class {
|
|
|
4577
4404
|
const converted = convertInputReferenceImage(reference, warnings);
|
|
4578
4405
|
return converted != null ? [converted] : [];
|
|
4579
4406
|
});
|
|
4580
|
-
} else if (
|
|
4407
|
+
} else if (googleOptions?.referenceImages != null) {
|
|
4581
4408
|
instance.referenceImages = googleOptions.referenceImages.map(
|
|
4582
4409
|
(refImg) => convertProviderReferenceImage(refImg)
|
|
4583
4410
|
);
|
|
@@ -4625,9 +4452,8 @@ var GoogleVideoModel = class {
|
|
|
4625
4452
|
return { instances, parameters, warnings, googleOptions };
|
|
4626
4453
|
}
|
|
4627
4454
|
async buildCompletedResult(finalOperation, responseHeaders, warnings, currentDate) {
|
|
4628
|
-
var _a, _b;
|
|
4629
4455
|
const response = finalOperation.response;
|
|
4630
|
-
if (!
|
|
4456
|
+
if (!response?.generateVideoResponse?.generatedSamples || response.generateVideoResponse.generatedSamples.length === 0) {
|
|
4631
4457
|
throw new AISDKError2({
|
|
4632
4458
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
4633
4459
|
message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
|
|
@@ -4636,9 +4462,9 @@ var GoogleVideoModel = class {
|
|
|
4636
4462
|
const videos = [];
|
|
4637
4463
|
const videoMetadata = [];
|
|
4638
4464
|
const resolvedHeaders = await resolve4(this.config.headers);
|
|
4639
|
-
const apiKey = resolvedHeaders
|
|
4465
|
+
const apiKey = resolvedHeaders?.["x-goog-api-key"];
|
|
4640
4466
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
4641
|
-
if (
|
|
4467
|
+
if (generatedSample.video?.uri) {
|
|
4642
4468
|
const urlWithAuth = apiKey && isSameOrigin(generatedSample.video.uri, this.config.baseURL) ? `${generatedSample.video.uri}${generatedSample.video.uri.includes("?") ? "&" : "?"}key=${apiKey}` : generatedSample.video.uri;
|
|
4643
4469
|
videos.push({
|
|
4644
4470
|
type: "url",
|
|
@@ -4673,8 +4499,7 @@ var GoogleVideoModel = class {
|
|
|
4673
4499
|
};
|
|
4674
4500
|
}
|
|
4675
4501
|
async doStart(options) {
|
|
4676
|
-
|
|
4677
|
-
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
4502
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
4678
4503
|
const { instances, parameters, warnings } = await this.buildRequest(options);
|
|
4679
4504
|
const { value: operation, responseHeaders } = await postJsonToApi4({
|
|
4680
4505
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
@@ -4711,8 +4536,7 @@ var GoogleVideoModel = class {
|
|
|
4711
4536
|
};
|
|
4712
4537
|
}
|
|
4713
4538
|
async doStatus(options) {
|
|
4714
|
-
|
|
4715
|
-
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
4539
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
4716
4540
|
const { operationName } = options.operation;
|
|
4717
4541
|
const { value: statusOperation, responseHeaders } = await getFromApi3({
|
|
4718
4542
|
url: `${this.config.baseURL}/${operationName}`,
|
|
@@ -4779,6 +4603,9 @@ var googleOperationSchema = z17.object({
|
|
|
4779
4603
|
});
|
|
4780
4604
|
|
|
4781
4605
|
// src/google-speech-model.ts
|
|
4606
|
+
import {
|
|
4607
|
+
InvalidArgumentError as InvalidArgumentError2
|
|
4608
|
+
} from "@ai-sdk/provider";
|
|
4782
4609
|
import {
|
|
4783
4610
|
combineHeaders as combineHeaders6,
|
|
4784
4611
|
convertBase64ToUint8Array,
|
|
@@ -4815,6 +4642,37 @@ var googleSpeechResponseSchema = lazySchema16(
|
|
|
4815
4642
|
)
|
|
4816
4643
|
);
|
|
4817
4644
|
|
|
4645
|
+
// src/google-speech-input.ts
|
|
4646
|
+
function getGoogleSpeechInput({
|
|
4647
|
+
text,
|
|
4648
|
+
voice,
|
|
4649
|
+
providerOptions
|
|
4650
|
+
}) {
|
|
4651
|
+
const google2 = providerOptions?.google;
|
|
4652
|
+
const options = google2 != null && typeof google2 === "object" ? google2 : void 0;
|
|
4653
|
+
const turns = options && "turns" in options ? options.turns : void 0;
|
|
4654
|
+
const turnTexts = [];
|
|
4655
|
+
if (Array.isArray(turns) && turns.length > 0) {
|
|
4656
|
+
for (const turn of turns) {
|
|
4657
|
+
if (turn == null || typeof turn !== "object" || !("text" in turn) || typeof turn.text !== "string") {
|
|
4658
|
+
break;
|
|
4659
|
+
}
|
|
4660
|
+
turnTexts.push(turn.text);
|
|
4661
|
+
}
|
|
4662
|
+
if (turnTexts.length === turns.length) {
|
|
4663
|
+
text = turnTexts.join("");
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
const config = options && "multiSpeakerVoiceConfig" in options ? options.multiSpeakerVoiceConfig : void 0;
|
|
4667
|
+
const speakers = config != null && typeof config === "object" && "speakerVoiceConfigs" in config && Array.isArray(config.speakerVoiceConfigs) ? config.speakerVoiceConfigs : [];
|
|
4668
|
+
return {
|
|
4669
|
+
text,
|
|
4670
|
+
usesCustomVoice: voice?.startsWith("voice_") === true || voice?.startsWith("voicekey_") === true || speakers.some(
|
|
4671
|
+
(speaker) => speaker != null && typeof speaker === "object" && "voiceConfig" in speaker && speaker.voiceConfig != null && typeof speaker.voiceConfig === "object" && "voice" in speaker.voiceConfig
|
|
4672
|
+
)
|
|
4673
|
+
};
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4818
4676
|
// src/google-speech-model-options.ts
|
|
4819
4677
|
import {
|
|
4820
4678
|
lazySchema as lazySchema17,
|
|
@@ -4825,15 +4683,34 @@ var prebuiltVoiceConfigSchema = z19.object({
|
|
|
4825
4683
|
voiceName: z19.string()
|
|
4826
4684
|
});
|
|
4827
4685
|
var voiceConfigSchema = z19.object({
|
|
4828
|
-
prebuiltVoiceConfig: prebuiltVoiceConfigSchema
|
|
4686
|
+
prebuiltVoiceConfig: prebuiltVoiceConfigSchema,
|
|
4687
|
+
voice: z19.never().optional()
|
|
4688
|
+
});
|
|
4689
|
+
var speechMetadataSchema = z19.object({
|
|
4690
|
+
speaker: z19.string().min(1).optional(),
|
|
4691
|
+
style: z19.string().optional()
|
|
4829
4692
|
});
|
|
4830
4693
|
var googleSpeechProviderOptionsSchema = lazySchema17(
|
|
4831
4694
|
() => zodSchema17(
|
|
4832
4695
|
z19.object({
|
|
4696
|
+
/** Turn-level directions for the top-level text, for Gemini 3.8 TTS. */
|
|
4697
|
+
speechMetadata: speechMetadataSchema.optional(),
|
|
4698
|
+
/**
|
|
4699
|
+
* Structured transcript for Gemini 3.8 TTS. Replaces the top-level text;
|
|
4700
|
+
* pass text: '' when using turns. Each multi-speaker turn must name a
|
|
4701
|
+
* configured speaker in speechMetadata. Per-turn styles override instructions.
|
|
4702
|
+
*/
|
|
4703
|
+
turns: z19.array(
|
|
4704
|
+
z19.object({
|
|
4705
|
+
text: z19.string(),
|
|
4706
|
+
speechMetadata: speechMetadataSchema.optional()
|
|
4707
|
+
})
|
|
4708
|
+
).min(1).optional(),
|
|
4833
4709
|
/**
|
|
4834
4710
|
* Multi-speaker configuration for dialogue audio. When provided, this
|
|
4835
4711
|
* overrides the top-level `voice`. The Gemini TTS API supports up to two
|
|
4836
|
-
* speakers
|
|
4712
|
+
* speakers. For Gemini 3.8, each turn's speechMetadata.speaker must match
|
|
4713
|
+
* a configured speaker; older models use speaker labels in the text.
|
|
4837
4714
|
*
|
|
4838
4715
|
* https://ai.google.dev/gemini-api/docs/speech-generation#multi-speaker
|
|
4839
4716
|
*/
|
|
@@ -4899,10 +4776,22 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4899
4776
|
schema: googleSpeechProviderOptionsSchema
|
|
4900
4777
|
});
|
|
4901
4778
|
}
|
|
4902
|
-
const
|
|
4779
|
+
const usesStructuredSpeech = !this.modelId.startsWith("gemini-2.5-") && !this.modelId.startsWith("gemini-3.1-");
|
|
4780
|
+
const input = getGoogleSpeechInput({
|
|
4781
|
+
text,
|
|
4782
|
+
voice,
|
|
4783
|
+
providerOptions: { google: googleOptions }
|
|
4784
|
+
});
|
|
4785
|
+
if (input.usesCustomVoice) {
|
|
4786
|
+
throw new InvalidArgumentError2({
|
|
4787
|
+
argument: "voice",
|
|
4788
|
+
message: "Custom voices are not supported. Use a prebuilt voice instead."
|
|
4789
|
+
});
|
|
4790
|
+
}
|
|
4791
|
+
const multiSpeakerVoiceConfig = googleOptions?.multiSpeakerVoiceConfig;
|
|
4903
4792
|
const speechConfig = multiSpeakerVoiceConfig ? { multiSpeakerVoiceConfig } : { voiceConfig: { prebuiltVoiceConfig: { voiceName: voice } } };
|
|
4904
4793
|
let promptText = text;
|
|
4905
|
-
if (instructions != null) {
|
|
4794
|
+
if (instructions != null && !usesStructuredSpeech) {
|
|
4906
4795
|
if (multiSpeakerVoiceConfig) {
|
|
4907
4796
|
warnings.push({
|
|
4908
4797
|
type: "unsupported",
|
|
@@ -4913,6 +4802,51 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4913
4802
|
promptText = `${instructions}: ${text}`;
|
|
4914
4803
|
}
|
|
4915
4804
|
}
|
|
4805
|
+
let parts = [{ text: promptText }];
|
|
4806
|
+
if (usesStructuredSpeech) {
|
|
4807
|
+
if (googleOptions?.turns && googleOptions.speechMetadata) {
|
|
4808
|
+
throw new InvalidArgumentError2({
|
|
4809
|
+
argument: "providerOptions",
|
|
4810
|
+
message: "Set speechMetadata on each turn when using turns."
|
|
4811
|
+
});
|
|
4812
|
+
}
|
|
4813
|
+
if (googleOptions?.turns && text !== "") {
|
|
4814
|
+
warnings.push({
|
|
4815
|
+
type: "unsupported",
|
|
4816
|
+
feature: "text",
|
|
4817
|
+
details: "Google TTS turns replace the top-level text."
|
|
4818
|
+
});
|
|
4819
|
+
}
|
|
4820
|
+
parts = (googleOptions?.turns ?? [
|
|
4821
|
+
{ text, speechMetadata: googleOptions?.speechMetadata }
|
|
4822
|
+
]).map((part) => {
|
|
4823
|
+
const style = part.speechMetadata?.style ?? instructions;
|
|
4824
|
+
const speaker = part.speechMetadata?.speaker;
|
|
4825
|
+
if (multiSpeakerVoiceConfig && !multiSpeakerVoiceConfig.speakerVoiceConfigs.some(
|
|
4826
|
+
(config) => config.speaker === speaker
|
|
4827
|
+
)) {
|
|
4828
|
+
throw new InvalidArgumentError2({
|
|
4829
|
+
argument: "speechMetadata.speaker",
|
|
4830
|
+
message: "Every multi-speaker turn must specify a speechMetadata.speaker matching a configured speaker."
|
|
4831
|
+
});
|
|
4832
|
+
}
|
|
4833
|
+
return {
|
|
4834
|
+
text: part.text,
|
|
4835
|
+
...style != null || speaker != null ? { speechMetadata: { style, speaker } } : {}
|
|
4836
|
+
};
|
|
4837
|
+
});
|
|
4838
|
+
} else if (googleOptions?.turns || googleOptions?.speechMetadata) {
|
|
4839
|
+
throw new InvalidArgumentError2({
|
|
4840
|
+
argument: "providerOptions",
|
|
4841
|
+
message: "Structured speech metadata and turns require Gemini 3.8 TTS."
|
|
4842
|
+
});
|
|
4843
|
+
}
|
|
4844
|
+
if (input.text.length === 0) {
|
|
4845
|
+
throw new InvalidArgumentError2({
|
|
4846
|
+
argument: "text",
|
|
4847
|
+
message: "Speech input must contain a non-empty transcript."
|
|
4848
|
+
});
|
|
4849
|
+
}
|
|
4916
4850
|
if (speed != null) {
|
|
4917
4851
|
warnings.push({
|
|
4918
4852
|
type: "unsupported",
|
|
@@ -4927,10 +4861,20 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4927
4861
|
details: "Google Gemini TTS models do not support the `language` option. Language is detected automatically from the input text."
|
|
4928
4862
|
});
|
|
4929
4863
|
}
|
|
4864
|
+
const formats = usesStructuredSpeech ? {
|
|
4865
|
+
wav: "AUDIO_WAV",
|
|
4866
|
+
"audio/wav": "AUDIO_WAV",
|
|
4867
|
+
pcm: "AUDIO_L16",
|
|
4868
|
+
"audio/l16": "AUDIO_L16",
|
|
4869
|
+
mulaw: "AUDIO_MULAW",
|
|
4870
|
+
"audio/mulaw": "AUDIO_MULAW",
|
|
4871
|
+
alaw: "AUDIO_ALAW",
|
|
4872
|
+
"audio/alaw": "AUDIO_ALAW"
|
|
4873
|
+
} : { wav: "AUDIO_WAV", pcm: "AUDIO_L16" };
|
|
4930
4874
|
let resolvedOutputFormat = "wav";
|
|
4931
|
-
if (outputFormat
|
|
4932
|
-
resolvedOutputFormat =
|
|
4933
|
-
} else if (outputFormat != null
|
|
4875
|
+
if (outputFormat != null && Object.prototype.hasOwnProperty.call(formats, outputFormat)) {
|
|
4876
|
+
resolvedOutputFormat = outputFormat;
|
|
4877
|
+
} else if (outputFormat != null) {
|
|
4934
4878
|
warnings.push({
|
|
4935
4879
|
type: "unsupported",
|
|
4936
4880
|
feature: "outputFormat",
|
|
@@ -4938,18 +4882,27 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4938
4882
|
});
|
|
4939
4883
|
}
|
|
4940
4884
|
const requestBody = {
|
|
4941
|
-
contents: [{ role: "user", parts
|
|
4885
|
+
contents: [{ role: "user", parts }],
|
|
4942
4886
|
generationConfig: {
|
|
4943
4887
|
responseModalities: ["AUDIO"],
|
|
4944
|
-
speechConfig
|
|
4888
|
+
speechConfig,
|
|
4889
|
+
...usesStructuredSpeech && outputFormat != null ? {
|
|
4890
|
+
responseFormat: {
|
|
4891
|
+
audio: { mimeType: formats[resolvedOutputFormat] }
|
|
4892
|
+
}
|
|
4893
|
+
} : {}
|
|
4945
4894
|
}
|
|
4946
4895
|
};
|
|
4947
|
-
return {
|
|
4896
|
+
return {
|
|
4897
|
+
requestBody,
|
|
4898
|
+
warnings,
|
|
4899
|
+
outputFormat: formats[resolvedOutputFormat],
|
|
4900
|
+
usesStructuredSpeech
|
|
4901
|
+
};
|
|
4948
4902
|
}
|
|
4949
4903
|
async doGenerate(options) {
|
|
4950
|
-
|
|
4951
|
-
const
|
|
4952
|
-
const { requestBody, warnings, outputFormat } = await this.getArgs(options);
|
|
4904
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
4905
|
+
const { requestBody, warnings, outputFormat, usesStructuredSpeech } = await this.getArgs(options);
|
|
4953
4906
|
const {
|
|
4954
4907
|
value: response,
|
|
4955
4908
|
responseHeaders,
|
|
@@ -4970,11 +4923,11 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4970
4923
|
});
|
|
4971
4924
|
let base64Audio;
|
|
4972
4925
|
let mimeType;
|
|
4973
|
-
for (const candidate of
|
|
4974
|
-
for (const part of
|
|
4975
|
-
if (
|
|
4926
|
+
for (const candidate of response.candidates ?? []) {
|
|
4927
|
+
for (const part of candidate.content?.parts ?? []) {
|
|
4928
|
+
if (part.inlineData?.data) {
|
|
4976
4929
|
base64Audio = part.inlineData.data;
|
|
4977
|
-
mimeType =
|
|
4930
|
+
mimeType = part.inlineData.mimeType ?? void 0;
|
|
4978
4931
|
break;
|
|
4979
4932
|
}
|
|
4980
4933
|
}
|
|
@@ -4982,10 +4935,11 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
4982
4935
|
break;
|
|
4983
4936
|
}
|
|
4984
4937
|
}
|
|
4985
|
-
const sampleRate =
|
|
4986
|
-
const
|
|
4987
|
-
const
|
|
4988
|
-
|
|
4938
|
+
const sampleRate = parseSampleRate(mimeType) ?? DEFAULT_SAMPLE_RATE;
|
|
4939
|
+
const bytes = base64Audio != null ? convertBase64ToUint8Array(base64Audio) : new Uint8Array(0);
|
|
4940
|
+
const isPcm = /^audio\/(?:l16|pcm)(?:;|$)/i.test(mimeType ?? "") || mimeType == null && !usesStructuredSpeech;
|
|
4941
|
+
const audio = outputFormat === "AUDIO_WAV" && isPcm && bytes.length > 0 ? addWavHeader(bytes, sampleRate) : bytes;
|
|
4942
|
+
if (outputFormat === "AUDIO_L16" && bytes.length > 0 && !usesStructuredSpeech) {
|
|
4989
4943
|
warnings.push({
|
|
4990
4944
|
type: "unsupported",
|
|
4991
4945
|
feature: "outputFormat",
|
|
@@ -5007,7 +4961,7 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
5007
4961
|
providerMetadata: {
|
|
5008
4962
|
google: {
|
|
5009
4963
|
sampleRate,
|
|
5010
|
-
mimeType: mimeType
|
|
4964
|
+
mimeType: mimeType ?? null
|
|
5011
4965
|
}
|
|
5012
4966
|
}
|
|
5013
4967
|
};
|
|
@@ -5073,37 +5027,36 @@ import {
|
|
|
5073
5027
|
// src/interactions/convert-google-interactions-usage.ts
|
|
5074
5028
|
import { createNullLanguageModelUsage as createNullLanguageModelUsage2 } from "@ai-sdk/provider-utils";
|
|
5075
5029
|
function convertGoogleInteractionsUsage(usage) {
|
|
5076
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5077
5030
|
if (usage == null) {
|
|
5078
5031
|
return createNullLanguageModelUsage2();
|
|
5079
5032
|
}
|
|
5080
|
-
const totalInput =
|
|
5081
|
-
const totalOutput =
|
|
5082
|
-
const totalThought =
|
|
5083
|
-
const totalCached =
|
|
5033
|
+
const totalInput = usage.total_input_tokens ?? 0;
|
|
5034
|
+
const totalOutput = usage.total_output_tokens ?? 0;
|
|
5035
|
+
const totalThought = usage.total_thought_tokens ?? 0;
|
|
5036
|
+
const totalCached = usage.total_cached_tokens ?? 0;
|
|
5084
5037
|
return {
|
|
5085
5038
|
inputTokens: {
|
|
5086
|
-
total:
|
|
5039
|
+
total: usage.total_input_tokens ?? void 0,
|
|
5087
5040
|
noCache: usage.total_input_tokens == null ? void 0 : totalInput - totalCached,
|
|
5088
|
-
cacheRead:
|
|
5041
|
+
cacheRead: usage.total_cached_tokens ?? void 0,
|
|
5089
5042
|
cacheWrite: void 0
|
|
5090
5043
|
},
|
|
5091
5044
|
outputTokens: {
|
|
5092
5045
|
total: usage.total_output_tokens == null && usage.total_thought_tokens == null ? void 0 : totalOutput + totalThought,
|
|
5093
|
-
text:
|
|
5094
|
-
reasoning:
|
|
5046
|
+
text: usage.total_output_tokens ?? void 0,
|
|
5047
|
+
reasoning: usage.total_thought_tokens ?? void 0
|
|
5095
5048
|
},
|
|
5096
5049
|
raw: usage
|
|
5097
5050
|
};
|
|
5098
5051
|
}
|
|
5099
5052
|
function getGoogleInteractionsOutputTokensByModality(usage) {
|
|
5100
|
-
const byModality = usage
|
|
5053
|
+
const byModality = usage?.output_tokens_by_modality;
|
|
5101
5054
|
if (byModality == null) {
|
|
5102
5055
|
return void 0;
|
|
5103
5056
|
}
|
|
5104
5057
|
const result = {};
|
|
5105
5058
|
for (const entry of byModality) {
|
|
5106
|
-
if (
|
|
5059
|
+
if (entry?.modality != null && entry.tokens != null) {
|
|
5107
5060
|
result[entry.modality] = entry.tokens;
|
|
5108
5061
|
}
|
|
5109
5062
|
}
|
|
@@ -5135,7 +5088,6 @@ function annotationToSource({
|
|
|
5135
5088
|
annotation,
|
|
5136
5089
|
generateId: generateId4
|
|
5137
5090
|
}) {
|
|
5138
|
-
var _a, _b, _c, _d, _e;
|
|
5139
5091
|
switch (annotation.type) {
|
|
5140
5092
|
case "url_citation": {
|
|
5141
5093
|
const urlCitation = annotation;
|
|
@@ -5152,7 +5104,7 @@ function annotationToSource({
|
|
|
5152
5104
|
}
|
|
5153
5105
|
case "file_citation": {
|
|
5154
5106
|
const fileCitation = annotation;
|
|
5155
|
-
const uri =
|
|
5107
|
+
const uri = fileCitation.url ?? fileCitation.document_uri ?? fileCitation.file_name;
|
|
5156
5108
|
if (uri == null || uri.length === 0) return void 0;
|
|
5157
5109
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
5158
5110
|
return {
|
|
@@ -5163,14 +5115,14 @@ function annotationToSource({
|
|
|
5163
5115
|
...fileCitation.file_name != null ? { title: fileCitation.file_name } : {}
|
|
5164
5116
|
};
|
|
5165
5117
|
}
|
|
5166
|
-
const filename =
|
|
5118
|
+
const filename = fileCitation.file_name ?? basename(uri);
|
|
5167
5119
|
const mediaType = inferDocMediaType(uri);
|
|
5168
5120
|
return {
|
|
5169
5121
|
type: "source",
|
|
5170
5122
|
sourceType: "document",
|
|
5171
5123
|
id: generateId4(),
|
|
5172
5124
|
mediaType,
|
|
5173
|
-
title:
|
|
5125
|
+
title: fileCitation.file_name ?? filename ?? uri,
|
|
5174
5126
|
...filename != null ? { filename } : {}
|
|
5175
5127
|
};
|
|
5176
5128
|
}
|
|
@@ -5195,13 +5147,12 @@ function builtinToolResultToSources({
|
|
|
5195
5147
|
block,
|
|
5196
5148
|
generateId: generateId4
|
|
5197
5149
|
}) {
|
|
5198
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5199
5150
|
const sources = [];
|
|
5200
5151
|
switch (block.type) {
|
|
5201
5152
|
case "url_context_result": {
|
|
5202
|
-
const result =
|
|
5153
|
+
const result = block.result ?? [];
|
|
5203
5154
|
for (const entry of result) {
|
|
5204
|
-
if (
|
|
5155
|
+
if (entry?.url == null || entry.url.length === 0) continue;
|
|
5205
5156
|
if (entry.status != null && entry.status !== "success") continue;
|
|
5206
5157
|
sources.push({
|
|
5207
5158
|
type: "source",
|
|
@@ -5213,9 +5164,9 @@ function builtinToolResultToSources({
|
|
|
5213
5164
|
break;
|
|
5214
5165
|
}
|
|
5215
5166
|
case "google_search_result": {
|
|
5216
|
-
const result =
|
|
5167
|
+
const result = block.result ?? [];
|
|
5217
5168
|
for (const entry of result) {
|
|
5218
|
-
const url = entry
|
|
5169
|
+
const url = entry?.url;
|
|
5219
5170
|
if (url == null || url.length === 0) continue;
|
|
5220
5171
|
sources.push({
|
|
5221
5172
|
type: "source",
|
|
@@ -5228,9 +5179,9 @@ function builtinToolResultToSources({
|
|
|
5228
5179
|
break;
|
|
5229
5180
|
}
|
|
5230
5181
|
case "google_maps_result": {
|
|
5231
|
-
const result =
|
|
5182
|
+
const result = block.result ?? [];
|
|
5232
5183
|
for (const entry of result) {
|
|
5233
|
-
for (const place of
|
|
5184
|
+
for (const place of entry.places ?? []) {
|
|
5234
5185
|
if (place.url == null || place.url.length === 0) continue;
|
|
5235
5186
|
sources.push({
|
|
5236
5187
|
type: "source",
|
|
@@ -5244,11 +5195,11 @@ function builtinToolResultToSources({
|
|
|
5244
5195
|
break;
|
|
5245
5196
|
}
|
|
5246
5197
|
case "file_search_result": {
|
|
5247
|
-
const result =
|
|
5198
|
+
const result = block.result ?? [];
|
|
5248
5199
|
for (const raw of result) {
|
|
5249
5200
|
if (raw == null || typeof raw !== "object") continue;
|
|
5250
5201
|
const entry = raw;
|
|
5251
|
-
const uri =
|
|
5202
|
+
const uri = entry.url ?? entry.document_uri ?? entry.file_name;
|
|
5252
5203
|
if (uri == null || uri.length === 0) continue;
|
|
5253
5204
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
5254
5205
|
sources.push({
|
|
@@ -5260,14 +5211,14 @@ function builtinToolResultToSources({
|
|
|
5260
5211
|
});
|
|
5261
5212
|
continue;
|
|
5262
5213
|
}
|
|
5263
|
-
const filename =
|
|
5214
|
+
const filename = entry.file_name ?? basename(uri);
|
|
5264
5215
|
const mediaType = inferDocMediaType(uri);
|
|
5265
5216
|
sources.push({
|
|
5266
5217
|
type: "source",
|
|
5267
5218
|
sourceType: "document",
|
|
5268
5219
|
id: generateId4(),
|
|
5269
5220
|
mediaType,
|
|
5270
|
-
title:
|
|
5221
|
+
title: entry.title ?? entry.file_name ?? filename ?? uri,
|
|
5271
5222
|
...filename != null ? { filename } : {}
|
|
5272
5223
|
});
|
|
5273
5224
|
}
|
|
@@ -5282,14 +5233,13 @@ function annotationsToSources({
|
|
|
5282
5233
|
annotations,
|
|
5283
5234
|
generateId: generateId4
|
|
5284
5235
|
}) {
|
|
5285
|
-
var _a;
|
|
5286
5236
|
if (annotations == null) return [];
|
|
5287
5237
|
const seen = /* @__PURE__ */ new Set();
|
|
5288
5238
|
const sources = [];
|
|
5289
5239
|
for (const annotation of annotations) {
|
|
5290
5240
|
const source = annotationToSource({ annotation, generateId: generateId4 });
|
|
5291
5241
|
if (source == null) continue;
|
|
5292
|
-
const key = source.sourceType === "url" ? `url:${source.url}` : `doc:${
|
|
5242
|
+
const key = source.sourceType === "url" ? `url:${source.url}` : `doc:${source.filename ?? source.title}`;
|
|
5293
5243
|
if (seen.has(key)) continue;
|
|
5294
5244
|
seen.add(key);
|
|
5295
5245
|
sources.push(source);
|
|
@@ -5356,15 +5306,13 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5356
5306
|
const openBlocks = /* @__PURE__ */ new Map();
|
|
5357
5307
|
const emittedSourceKeys = /* @__PURE__ */ new Set();
|
|
5358
5308
|
function sourceKey(source) {
|
|
5359
|
-
|
|
5360
|
-
return source.sourceType === "url" ? `url:${source.url}` : `doc:${(_a = source.filename) != null ? _a : source.title}`;
|
|
5309
|
+
return source.sourceType === "url" ? `url:${source.url}` : `doc:${source.filename ?? source.title}`;
|
|
5361
5310
|
}
|
|
5362
5311
|
return new TransformStream({
|
|
5363
5312
|
start(controller) {
|
|
5364
5313
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5365
5314
|
},
|
|
5366
5315
|
transform(chunk, controller) {
|
|
5367
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
5368
5316
|
if (includeRawChunks) {
|
|
5369
5317
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5370
5318
|
}
|
|
@@ -5379,8 +5327,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5379
5327
|
case "interaction.created": {
|
|
5380
5328
|
const event = value;
|
|
5381
5329
|
const interaction = event.interaction;
|
|
5382
|
-
interactionId =
|
|
5383
|
-
const created = interaction
|
|
5330
|
+
interactionId = interaction?.id != null && interaction.id.length > 0 ? interaction.id : void 0;
|
|
5331
|
+
const created = interaction?.created;
|
|
5384
5332
|
let timestamp;
|
|
5385
5333
|
if (typeof created === "string") {
|
|
5386
5334
|
const parsed = new Date(created);
|
|
@@ -5391,7 +5339,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5391
5339
|
controller.enqueue({
|
|
5392
5340
|
type: "response-metadata",
|
|
5393
5341
|
...interactionId != null ? { id: interactionId } : {},
|
|
5394
|
-
modelId: interaction
|
|
5342
|
+
modelId: interaction?.model,
|
|
5395
5343
|
...timestamp ? { timestamp } : {}
|
|
5396
5344
|
});
|
|
5397
5345
|
break;
|
|
@@ -5400,11 +5348,11 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5400
5348
|
const event = value;
|
|
5401
5349
|
const step = event.step;
|
|
5402
5350
|
const index = event.index;
|
|
5403
|
-
const blockId = `${interactionId
|
|
5404
|
-
const stepType = step
|
|
5351
|
+
const blockId = `${interactionId ?? "interaction"}:${index}`;
|
|
5352
|
+
const stepType = step?.type;
|
|
5405
5353
|
if (stepType === "model_output") {
|
|
5406
|
-
const initial =
|
|
5407
|
-
if (
|
|
5354
|
+
const initial = step?.content?.[0];
|
|
5355
|
+
if (initial?.type === "text") {
|
|
5408
5356
|
openBlocks.set(index, {
|
|
5409
5357
|
kind: "text",
|
|
5410
5358
|
id: blockId,
|
|
@@ -5421,7 +5369,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5421
5369
|
emittedSourceKeys.add(key);
|
|
5422
5370
|
controller.enqueue(source);
|
|
5423
5371
|
}
|
|
5424
|
-
} else if (
|
|
5372
|
+
} else if (initial?.type === "image") {
|
|
5425
5373
|
openBlocks.set(index, {
|
|
5426
5374
|
kind: "image",
|
|
5427
5375
|
id: blockId,
|
|
@@ -5436,16 +5384,16 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5436
5384
|
});
|
|
5437
5385
|
}
|
|
5438
5386
|
} else if (stepType === "thought") {
|
|
5439
|
-
const signature = step
|
|
5387
|
+
const signature = step?.signature;
|
|
5440
5388
|
openBlocks.set(index, {
|
|
5441
5389
|
kind: "reasoning",
|
|
5442
5390
|
id: blockId,
|
|
5443
5391
|
...signature != null ? { signature } : {}
|
|
5444
5392
|
});
|
|
5445
5393
|
controller.enqueue({ type: "reasoning-start", id: blockId });
|
|
5446
|
-
if (Array.isArray(step
|
|
5394
|
+
if (Array.isArray(step?.summary)) {
|
|
5447
5395
|
for (const item of step.summary) {
|
|
5448
|
-
if (
|
|
5396
|
+
if (item?.type === "text" && typeof item.text === "string") {
|
|
5449
5397
|
controller.enqueue({
|
|
5450
5398
|
type: "reasoning-delta",
|
|
5451
5399
|
id: blockId,
|
|
@@ -5456,12 +5404,12 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5456
5404
|
}
|
|
5457
5405
|
} else if (stepType === "processing_call" || stepType === "processing_result") {
|
|
5458
5406
|
const google2 = {};
|
|
5459
|
-
if (
|
|
5407
|
+
if (step?.signature != null) google2.signature = step.signature;
|
|
5460
5408
|
if (interactionId != null) google2.interactionId = interactionId;
|
|
5461
5409
|
if (stepType === "processing_call") {
|
|
5462
|
-
google2.processingId =
|
|
5410
|
+
google2.processingId = step?.id || blockId;
|
|
5463
5411
|
} else {
|
|
5464
|
-
google2.processingCallId =
|
|
5412
|
+
google2.processingCallId = step?.call_id || blockId;
|
|
5465
5413
|
}
|
|
5466
5414
|
openBlocks.set(index, {
|
|
5467
5415
|
kind: "custom",
|
|
@@ -5470,8 +5418,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5470
5418
|
google: google2
|
|
5471
5419
|
});
|
|
5472
5420
|
} else if (stepType === "function_call") {
|
|
5473
|
-
const toolCallId =
|
|
5474
|
-
const toolName =
|
|
5421
|
+
const toolCallId = step?.id || blockId;
|
|
5422
|
+
const toolName = step?.name ?? "unknown";
|
|
5475
5423
|
hasFunctionCall = true;
|
|
5476
5424
|
const state = {
|
|
5477
5425
|
kind: "function_call",
|
|
@@ -5479,7 +5427,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5479
5427
|
toolCallId,
|
|
5480
5428
|
toolName,
|
|
5481
5429
|
argumentsAccum: "",
|
|
5482
|
-
...
|
|
5430
|
+
...step?.signature != null ? { signature: step.signature } : {}
|
|
5483
5431
|
};
|
|
5484
5432
|
openBlocks.set(index, state);
|
|
5485
5433
|
controller.enqueue({
|
|
@@ -5488,29 +5436,29 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5488
5436
|
toolName
|
|
5489
5437
|
});
|
|
5490
5438
|
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
5491
|
-
const toolName = stepType === "mcp_server_tool_call" ?
|
|
5492
|
-
const toolCallId =
|
|
5439
|
+
const toolName = stepType === "mcp_server_tool_call" ? step?.name ?? "mcp_server_tool" : builtinToolNameFromCallType(stepType);
|
|
5440
|
+
const toolCallId = step?.id || blockId;
|
|
5493
5441
|
const state = {
|
|
5494
5442
|
kind: "builtin_tool_call",
|
|
5495
5443
|
id: blockId,
|
|
5496
5444
|
blockType: stepType,
|
|
5497
5445
|
toolCallId,
|
|
5498
5446
|
toolName,
|
|
5499
|
-
arguments:
|
|
5447
|
+
arguments: step?.arguments ?? {},
|
|
5500
5448
|
callEmitted: false
|
|
5501
5449
|
};
|
|
5502
5450
|
openBlocks.set(index, state);
|
|
5503
5451
|
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
5504
|
-
const toolName = stepType === "mcp_server_tool_result" ?
|
|
5505
|
-
const callId =
|
|
5452
|
+
const toolName = stepType === "mcp_server_tool_result" ? step?.name ?? "mcp_server_tool" : builtinToolNameFromResultType(stepType);
|
|
5453
|
+
const callId = step?.call_id || blockId;
|
|
5506
5454
|
const state = {
|
|
5507
5455
|
kind: "builtin_tool_result",
|
|
5508
5456
|
id: blockId,
|
|
5509
5457
|
blockType: stepType,
|
|
5510
5458
|
callId,
|
|
5511
5459
|
toolName,
|
|
5512
|
-
result:
|
|
5513
|
-
...
|
|
5460
|
+
result: step?.result ?? null,
|
|
5461
|
+
...step?.is_error != null ? { isError: step.is_error } : {},
|
|
5514
5462
|
resultEmitted: false
|
|
5515
5463
|
};
|
|
5516
5464
|
openBlocks.set(index, state);
|
|
@@ -5523,7 +5471,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5523
5471
|
const event = value;
|
|
5524
5472
|
let open = openBlocks.get(event.index);
|
|
5525
5473
|
if (open == null) break;
|
|
5526
|
-
const dtype =
|
|
5474
|
+
const dtype = event.delta?.type;
|
|
5527
5475
|
if (open.kind === "pending_model_output") {
|
|
5528
5476
|
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
5529
5477
|
const promoted = {
|
|
@@ -5541,17 +5489,17 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5541
5489
|
const google2 = {};
|
|
5542
5490
|
if (interactionId != null) google2.interactionId = interactionId;
|
|
5543
5491
|
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
5544
|
-
if (
|
|
5492
|
+
if (imageDelta?.data != null && imageDelta.data.length > 0) {
|
|
5545
5493
|
controller.enqueue({
|
|
5546
5494
|
type: "file",
|
|
5547
|
-
mediaType:
|
|
5495
|
+
mediaType: imageDelta.mime_type ?? "image/png",
|
|
5548
5496
|
data: { type: "data", data: imageDelta.data },
|
|
5549
5497
|
...providerMetadata ? { providerMetadata } : {}
|
|
5550
5498
|
});
|
|
5551
|
-
} else if (
|
|
5499
|
+
} else if (imageDelta?.uri != null && imageDelta.uri.length > 0) {
|
|
5552
5500
|
controller.enqueue({
|
|
5553
5501
|
type: "file",
|
|
5554
|
-
mediaType:
|
|
5502
|
+
mediaType: imageDelta.mime_type ?? "image/png",
|
|
5555
5503
|
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
5556
5504
|
...providerMetadata ? { providerMetadata } : {}
|
|
5557
5505
|
});
|
|
@@ -5567,17 +5515,17 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5567
5515
|
const google2 = {};
|
|
5568
5516
|
if (interactionId != null) google2.interactionId = interactionId;
|
|
5569
5517
|
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
5570
|
-
if (
|
|
5518
|
+
if (videoDelta?.data != null && videoDelta.data.length > 0) {
|
|
5571
5519
|
controller.enqueue({
|
|
5572
5520
|
type: "file",
|
|
5573
|
-
mediaType:
|
|
5521
|
+
mediaType: videoDelta.mime_type ?? "video/mp4",
|
|
5574
5522
|
data: { type: "data", data: videoDelta.data },
|
|
5575
5523
|
...providerMetadata ? { providerMetadata } : {}
|
|
5576
5524
|
});
|
|
5577
|
-
} else if (
|
|
5525
|
+
} else if (videoDelta?.uri != null && videoDelta.uri.length > 0) {
|
|
5578
5526
|
controller.enqueue({
|
|
5579
5527
|
type: "file",
|
|
5580
|
-
mediaType:
|
|
5528
|
+
mediaType: videoDelta.mime_type ?? "video/mp4",
|
|
5581
5529
|
data: { type: "url", url: new URL(videoDelta.uri) },
|
|
5582
5530
|
...providerMetadata ? { providerMetadata } : {}
|
|
5583
5531
|
});
|
|
@@ -5585,7 +5533,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5585
5533
|
break;
|
|
5586
5534
|
}
|
|
5587
5535
|
const delta = event.delta;
|
|
5588
|
-
if (open.kind === "custom" && (
|
|
5536
|
+
if (open.kind === "custom" && (delta?.type === "processing_call" || delta?.type === "processing_result")) {
|
|
5589
5537
|
if (delta.signature != null)
|
|
5590
5538
|
open.google.signature = delta.signature;
|
|
5591
5539
|
if (delta.type === "processing_call" && delta.id != null && delta.id.length > 0) {
|
|
@@ -5594,8 +5542,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5594
5542
|
if (delta.type === "processing_result" && delta.call_id != null && delta.call_id.length > 0) {
|
|
5595
5543
|
open.google.processingCallId = delta.call_id;
|
|
5596
5544
|
}
|
|
5597
|
-
} else if (open.kind === "text" &&
|
|
5598
|
-
const text =
|
|
5545
|
+
} else if (open.kind === "text" && delta?.type === "text") {
|
|
5546
|
+
const text = delta.text ?? "";
|
|
5599
5547
|
if (text.length > 0) {
|
|
5600
5548
|
controller.enqueue({
|
|
5601
5549
|
type: "text-delta",
|
|
@@ -5603,7 +5551,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5603
5551
|
delta: text
|
|
5604
5552
|
});
|
|
5605
5553
|
}
|
|
5606
|
-
} else if (open.kind === "text" && (
|
|
5554
|
+
} else if (open.kind === "text" && (delta?.type === "text_annotation" || delta?.type === "text_annotation_delta")) {
|
|
5607
5555
|
const sources = annotationsToSources({
|
|
5608
5556
|
annotations: delta.annotations,
|
|
5609
5557
|
generateId: generateId4
|
|
@@ -5615,27 +5563,27 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5615
5563
|
open.emittedSourceKeys.add(key);
|
|
5616
5564
|
controller.enqueue(source);
|
|
5617
5565
|
}
|
|
5618
|
-
} else if (open.kind === "image" &&
|
|
5566
|
+
} else if (open.kind === "image" && delta?.type === "image") {
|
|
5619
5567
|
if (delta.data != null) open.data = delta.data;
|
|
5620
5568
|
if (delta.mime_type != null) open.mimeType = delta.mime_type;
|
|
5621
5569
|
if (delta.uri != null) open.uri = delta.uri;
|
|
5622
5570
|
} else if (open.kind === "reasoning") {
|
|
5623
|
-
if (
|
|
5571
|
+
if (delta?.type === "thought_summary") {
|
|
5624
5572
|
const item = delta.content;
|
|
5625
|
-
if (
|
|
5573
|
+
if (item?.type === "text" && typeof item.text === "string") {
|
|
5626
5574
|
controller.enqueue({
|
|
5627
5575
|
type: "reasoning-delta",
|
|
5628
5576
|
id: open.id,
|
|
5629
5577
|
delta: item.text
|
|
5630
5578
|
});
|
|
5631
5579
|
}
|
|
5632
|
-
} else if (
|
|
5580
|
+
} else if (delta?.type === "thought_signature") {
|
|
5633
5581
|
const signature = delta.signature;
|
|
5634
5582
|
if (signature != null) {
|
|
5635
5583
|
open.signature = signature;
|
|
5636
5584
|
}
|
|
5637
5585
|
}
|
|
5638
|
-
} else if (open.kind === "function_call" &&
|
|
5586
|
+
} else if (open.kind === "function_call" && delta?.type === "arguments_delta") {
|
|
5639
5587
|
const slice = typeof delta.arguments === "string" ? delta.arguments : "";
|
|
5640
5588
|
if (slice.length > 0) {
|
|
5641
5589
|
open.argumentsAccum += slice;
|
|
@@ -5652,7 +5600,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5652
5600
|
open.signature = delta.signature;
|
|
5653
5601
|
}
|
|
5654
5602
|
hasFunctionCall = true;
|
|
5655
|
-
} else if (open.kind === "builtin_tool_call" &&
|
|
5603
|
+
} else if (open.kind === "builtin_tool_call" && delta?.type === open.blockType) {
|
|
5656
5604
|
if (delta.id != null && delta.id.length > 0) {
|
|
5657
5605
|
open.toolCallId = delta.id;
|
|
5658
5606
|
}
|
|
@@ -5662,7 +5610,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5662
5610
|
if (delta.name != null && open.blockType === "mcp_server_tool_call") {
|
|
5663
5611
|
open.toolName = delta.name;
|
|
5664
5612
|
}
|
|
5665
|
-
} else if (open.kind === "builtin_tool_result" &&
|
|
5613
|
+
} else if (open.kind === "builtin_tool_result" && delta?.type === open.blockType) {
|
|
5666
5614
|
if (delta.call_id != null && delta.call_id.length > 0) {
|
|
5667
5615
|
open.callId = delta.call_id;
|
|
5668
5616
|
}
|
|
@@ -5702,14 +5650,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5702
5650
|
if (open.data != null && open.data.length > 0) {
|
|
5703
5651
|
controller.enqueue({
|
|
5704
5652
|
type: "file",
|
|
5705
|
-
mediaType:
|
|
5653
|
+
mediaType: open.mimeType ?? "image/png",
|
|
5706
5654
|
data: { type: "data", data: open.data },
|
|
5707
5655
|
...providerMetadata ? { providerMetadata } : {}
|
|
5708
5656
|
});
|
|
5709
5657
|
} else if (open.uri != null && open.uri.length > 0) {
|
|
5710
5658
|
controller.enqueue({
|
|
5711
5659
|
type: "file",
|
|
5712
|
-
mediaType:
|
|
5660
|
+
mediaType: open.mimeType ?? "image/png",
|
|
5713
5661
|
data: { type: "url", url: new URL(open.uri) },
|
|
5714
5662
|
...providerMetadata ? { providerMetadata } : {}
|
|
5715
5663
|
});
|
|
@@ -5742,7 +5690,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5742
5690
|
type: "tool-call",
|
|
5743
5691
|
toolCallId: open.toolCallId,
|
|
5744
5692
|
toolName: open.toolName,
|
|
5745
|
-
input: JSON.stringify(
|
|
5693
|
+
input: JSON.stringify(open.arguments ?? {}),
|
|
5746
5694
|
providerExecuted: true
|
|
5747
5695
|
});
|
|
5748
5696
|
open.callEmitted = true;
|
|
@@ -5751,7 +5699,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5751
5699
|
type: "tool-result",
|
|
5752
5700
|
toolCallId: open.callId,
|
|
5753
5701
|
toolName: open.toolName,
|
|
5754
|
-
result:
|
|
5702
|
+
result: open.result ?? null
|
|
5755
5703
|
});
|
|
5756
5704
|
open.resultEmitted = true;
|
|
5757
5705
|
const sources = builtinToolResultToSources({
|
|
@@ -5788,16 +5736,16 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5788
5736
|
case "interaction.completed": {
|
|
5789
5737
|
const event = value;
|
|
5790
5738
|
const interaction = event.interaction;
|
|
5791
|
-
if (
|
|
5739
|
+
if (interaction?.id != null && interaction.id.length > 0) {
|
|
5792
5740
|
interactionId = interaction.id;
|
|
5793
5741
|
}
|
|
5794
|
-
if (
|
|
5742
|
+
if (interaction?.status != null) {
|
|
5795
5743
|
finishStatus = interaction.status;
|
|
5796
5744
|
}
|
|
5797
|
-
if (
|
|
5745
|
+
if (interaction?.usage != null) {
|
|
5798
5746
|
usage = interaction.usage;
|
|
5799
5747
|
}
|
|
5800
|
-
if (
|
|
5748
|
+
if (interaction?.service_tier != null) {
|
|
5801
5749
|
serviceTier = interaction.service_tier;
|
|
5802
5750
|
}
|
|
5803
5751
|
break;
|
|
@@ -5808,9 +5756,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5808
5756
|
controller.enqueue({
|
|
5809
5757
|
type: "error",
|
|
5810
5758
|
error: createProviderStreamError({
|
|
5811
|
-
message:
|
|
5759
|
+
message: event.error?.message ?? "Unknown interaction error",
|
|
5812
5760
|
type: event.event_type,
|
|
5813
|
-
code:
|
|
5761
|
+
code: event.error?.code ?? void 0,
|
|
5814
5762
|
data: event
|
|
5815
5763
|
})
|
|
5816
5764
|
});
|
|
@@ -5861,7 +5809,6 @@ function convertToGoogleInteractionsInput({
|
|
|
5861
5809
|
store,
|
|
5862
5810
|
mediaResolution
|
|
5863
5811
|
}) {
|
|
5864
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5865
5812
|
const warnings = [];
|
|
5866
5813
|
const incoherentCombo = previousInteractionId != null && store === false;
|
|
5867
5814
|
const shouldCompact = previousInteractionId != null && store !== false;
|
|
@@ -5918,7 +5865,7 @@ function convertToGoogleInteractionsInput({
|
|
|
5918
5865
|
pendingModelOutput.push({ type: "text", text: part.text });
|
|
5919
5866
|
} else if (part.type === "reasoning") {
|
|
5920
5867
|
flushModelOutput();
|
|
5921
|
-
const signature =
|
|
5868
|
+
const signature = part.providerOptions?.google?.signature;
|
|
5922
5869
|
steps.push({
|
|
5923
5870
|
type: "thought",
|
|
5924
5871
|
...signature != null ? { signature } : {},
|
|
@@ -5935,15 +5882,15 @@ function convertToGoogleInteractionsInput({
|
|
|
5935
5882
|
}
|
|
5936
5883
|
} else if (part.type === "custom") {
|
|
5937
5884
|
flushModelOutput();
|
|
5938
|
-
const google2 =
|
|
5939
|
-
const signature = typeof
|
|
5940
|
-
if (part.kind === "google.processing_call" && typeof
|
|
5885
|
+
const google2 = part.providerOptions?.google;
|
|
5886
|
+
const signature = typeof google2?.signature === "string" ? google2.signature : void 0;
|
|
5887
|
+
if (part.kind === "google.processing_call" && typeof google2?.processingId === "string") {
|
|
5941
5888
|
steps.push({
|
|
5942
5889
|
type: "processing_call",
|
|
5943
5890
|
id: google2.processingId,
|
|
5944
5891
|
...signature != null ? { signature } : {}
|
|
5945
5892
|
});
|
|
5946
|
-
} else if (part.kind === "google.processing_result" && typeof
|
|
5893
|
+
} else if (part.kind === "google.processing_result" && typeof google2?.processingCallId === "string") {
|
|
5947
5894
|
steps.push({
|
|
5948
5895
|
type: "processing_result",
|
|
5949
5896
|
call_id: google2.processingCallId,
|
|
@@ -5957,8 +5904,8 @@ function convertToGoogleInteractionsInput({
|
|
|
5957
5904
|
}
|
|
5958
5905
|
} else if (part.type === "tool-call") {
|
|
5959
5906
|
flushModelOutput();
|
|
5960
|
-
const signature =
|
|
5961
|
-
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) :
|
|
5907
|
+
const signature = part.providerOptions?.google?.signature;
|
|
5908
|
+
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : part.input ?? {};
|
|
5962
5909
|
steps.push({
|
|
5963
5910
|
type: "function_call",
|
|
5964
5911
|
id: part.toolCallId,
|
|
@@ -5990,7 +5937,7 @@ function convertToGoogleInteractionsInput({
|
|
|
5990
5937
|
toolCallId: part.toolCallId,
|
|
5991
5938
|
toolName: part.toolName,
|
|
5992
5939
|
output: part.output,
|
|
5993
|
-
signature:
|
|
5940
|
+
signature: part.providerOptions?.google?.signature,
|
|
5994
5941
|
warnings
|
|
5995
5942
|
});
|
|
5996
5943
|
content.push(block);
|
|
@@ -6083,8 +6030,7 @@ function getVideoProcessingField({
|
|
|
6083
6030
|
part,
|
|
6084
6031
|
warnings
|
|
6085
6032
|
}) {
|
|
6086
|
-
|
|
6087
|
-
const processing = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.processing;
|
|
6033
|
+
const processing = part.providerOptions?.google?.processing;
|
|
6088
6034
|
if (processing == null) {
|
|
6089
6035
|
return {};
|
|
6090
6036
|
}
|
|
@@ -6096,8 +6042,8 @@ function getVideoProcessingField({
|
|
|
6096
6042
|
return {
|
|
6097
6043
|
processing: {
|
|
6098
6044
|
type: "static",
|
|
6099
|
-
...typeof config.startOffset === "number" ? { start_offset: config.startOffset } : {},
|
|
6100
|
-
...typeof config.endOffset === "number" ? { end_offset: config.endOffset } : {},
|
|
6045
|
+
...typeof config.startOffset === "number" ? { start_offset: `${config.startOffset}s` } : {},
|
|
6046
|
+
...typeof config.endOffset === "number" ? { end_offset: `${config.endOffset}s` } : {},
|
|
6101
6047
|
...typeof config.fps === "number" ? { fps: config.fps } : {}
|
|
6102
6048
|
}
|
|
6103
6049
|
};
|
|
@@ -6117,8 +6063,7 @@ function compactPromptForPreviousInteraction({
|
|
|
6117
6063
|
for (const message of prompt) {
|
|
6118
6064
|
if (message.role === "assistant") {
|
|
6119
6065
|
const matchesLinkedInteraction = message.content.some((part) => {
|
|
6120
|
-
|
|
6121
|
-
const partInteractionId = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.interactionId;
|
|
6066
|
+
const partInteractionId = part.providerOptions?.google?.interactionId;
|
|
6122
6067
|
return partInteractionId === previousInteractionId;
|
|
6123
6068
|
});
|
|
6124
6069
|
if (matchesLinkedInteraction) {
|
|
@@ -6159,7 +6104,7 @@ function safeParseToolArgs(input) {
|
|
|
6159
6104
|
return parsed;
|
|
6160
6105
|
}
|
|
6161
6106
|
return { value: parsed };
|
|
6162
|
-
} catch
|
|
6107
|
+
} catch {
|
|
6163
6108
|
return { value: input };
|
|
6164
6109
|
}
|
|
6165
6110
|
}
|
|
@@ -6170,7 +6115,6 @@ function convertToolResultPart({
|
|
|
6170
6115
|
signature,
|
|
6171
6116
|
warnings
|
|
6172
6117
|
}) {
|
|
6173
|
-
var _a;
|
|
6174
6118
|
const base = {
|
|
6175
6119
|
type: "function_result",
|
|
6176
6120
|
call_id: toolCallId,
|
|
@@ -6190,7 +6134,7 @@ function convertToolResultPart({
|
|
|
6190
6134
|
return {
|
|
6191
6135
|
...base,
|
|
6192
6136
|
is_error: true,
|
|
6193
|
-
result:
|
|
6137
|
+
result: output.reason ?? "Tool execution denied by user."
|
|
6194
6138
|
};
|
|
6195
6139
|
case "content": {
|
|
6196
6140
|
const blocks = [];
|
|
@@ -6881,7 +6825,6 @@ function parseGoogleInteractionsOutputs({
|
|
|
6881
6825
|
generateId: generateId4,
|
|
6882
6826
|
interactionId
|
|
6883
6827
|
}) {
|
|
6884
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6885
6828
|
const content = [];
|
|
6886
6829
|
let hasFunctionCall = false;
|
|
6887
6830
|
if (steps == null) {
|
|
@@ -6896,12 +6839,12 @@ function parseGoogleInteractionsOutputs({
|
|
|
6896
6839
|
break;
|
|
6897
6840
|
}
|
|
6898
6841
|
case "model_output": {
|
|
6899
|
-
const blocks =
|
|
6842
|
+
const blocks = step.content ?? [];
|
|
6900
6843
|
for (const block of blocks) {
|
|
6901
6844
|
if (block == null || typeof block !== "object") continue;
|
|
6902
6845
|
const blockType = block.type;
|
|
6903
6846
|
if (blockType === "text") {
|
|
6904
|
-
const text =
|
|
6847
|
+
const text = block.text ?? "";
|
|
6905
6848
|
const annotations = block.annotations;
|
|
6906
6849
|
content.push({
|
|
6907
6850
|
type: "text",
|
|
@@ -6917,14 +6860,14 @@ function parseGoogleInteractionsOutputs({
|
|
|
6917
6860
|
if (image.data != null && image.data.length > 0) {
|
|
6918
6861
|
content.push({
|
|
6919
6862
|
type: "file",
|
|
6920
|
-
mediaType:
|
|
6863
|
+
mediaType: image.mime_type ?? "image/png",
|
|
6921
6864
|
data: { type: "data", data: image.data },
|
|
6922
6865
|
...googleProviderMetadata({ interactionId })
|
|
6923
6866
|
});
|
|
6924
6867
|
} else if (image.uri != null && image.uri.length > 0) {
|
|
6925
6868
|
content.push({
|
|
6926
6869
|
type: "file",
|
|
6927
|
-
mediaType:
|
|
6870
|
+
mediaType: image.mime_type ?? "image/png",
|
|
6928
6871
|
data: { type: "url", url: new URL(image.uri) },
|
|
6929
6872
|
...googleProviderMetadata({ interactionId })
|
|
6930
6873
|
});
|
|
@@ -6934,14 +6877,14 @@ function parseGoogleInteractionsOutputs({
|
|
|
6934
6877
|
if (video.data != null && video.data.length > 0) {
|
|
6935
6878
|
content.push({
|
|
6936
6879
|
type: "file",
|
|
6937
|
-
mediaType:
|
|
6880
|
+
mediaType: video.mime_type ?? "video/mp4",
|
|
6938
6881
|
data: { type: "data", data: video.data },
|
|
6939
6882
|
...googleProviderMetadata({ interactionId })
|
|
6940
6883
|
});
|
|
6941
6884
|
} else if (video.uri != null && video.uri.length > 0) {
|
|
6942
6885
|
content.push({
|
|
6943
6886
|
type: "file",
|
|
6944
|
-
mediaType:
|
|
6887
|
+
mediaType: video.mime_type ?? "video/mp4",
|
|
6945
6888
|
data: { type: "url", url: new URL(video.uri) },
|
|
6946
6889
|
...googleProviderMetadata({ interactionId })
|
|
6947
6890
|
});
|
|
@@ -6954,7 +6897,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
6954
6897
|
const thought = step;
|
|
6955
6898
|
const summary = Array.isArray(thought.summary) ? thought.summary : [];
|
|
6956
6899
|
const text = summary.filter(
|
|
6957
|
-
(item) =>
|
|
6900
|
+
(item) => item?.type === "text" && typeof item.text === "string"
|
|
6958
6901
|
).map((item) => item.text).join("\n");
|
|
6959
6902
|
content.push({
|
|
6960
6903
|
type: "reasoning",
|
|
@@ -7001,7 +6944,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
7001
6944
|
type: "tool-call",
|
|
7002
6945
|
toolCallId: call.id,
|
|
7003
6946
|
toolName: call.name,
|
|
7004
|
-
input: JSON.stringify(
|
|
6947
|
+
input: JSON.stringify(call.arguments ?? {}),
|
|
7005
6948
|
...googleProviderMetadata({
|
|
7006
6949
|
signature: call.signature,
|
|
7007
6950
|
interactionId
|
|
@@ -7012,8 +6955,8 @@ function parseGoogleInteractionsOutputs({
|
|
|
7012
6955
|
default: {
|
|
7013
6956
|
if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
|
|
7014
6957
|
const call = step;
|
|
7015
|
-
const toolName = type === "mcp_server_tool_call" ?
|
|
7016
|
-
const input = JSON.stringify(
|
|
6958
|
+
const toolName = type === "mcp_server_tool_call" ? call.name ?? "mcp_server_tool" : builtinToolNameFromCallType2(type);
|
|
6959
|
+
const input = JSON.stringify(call.arguments ?? {});
|
|
7017
6960
|
content.push({
|
|
7018
6961
|
type: "tool-call",
|
|
7019
6962
|
toolCallId: call.id || generateId4(),
|
|
@@ -7023,12 +6966,12 @@ function parseGoogleInteractionsOutputs({
|
|
|
7023
6966
|
});
|
|
7024
6967
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
7025
6968
|
const result = step;
|
|
7026
|
-
const toolName = type === "mcp_server_tool_result" ?
|
|
6969
|
+
const toolName = type === "mcp_server_tool_result" ? result.name ?? "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
7027
6970
|
content.push({
|
|
7028
6971
|
type: "tool-result",
|
|
7029
6972
|
toolCallId: result.call_id || generateId4(),
|
|
7030
6973
|
toolName,
|
|
7031
|
-
result:
|
|
6974
|
+
result: result.result ?? null
|
|
7032
6975
|
});
|
|
7033
6976
|
const sources = builtinToolResultToSources({
|
|
7034
6977
|
block: step,
|
|
@@ -7081,9 +7024,9 @@ async function cancelGoogleInteraction({
|
|
|
7081
7024
|
});
|
|
7082
7025
|
try {
|
|
7083
7026
|
await response.text();
|
|
7084
|
-
} catch
|
|
7027
|
+
} catch {
|
|
7085
7028
|
}
|
|
7086
|
-
} catch
|
|
7029
|
+
} catch {
|
|
7087
7030
|
}
|
|
7088
7031
|
}
|
|
7089
7032
|
|
|
@@ -7116,7 +7059,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
7116
7059
|
const cancelOnServer = () => cancelGoogleInteraction({ baseURL, interactionId, headers, fetch: fetch2 });
|
|
7117
7060
|
try {
|
|
7118
7061
|
while (true) {
|
|
7119
|
-
if (abortSignal
|
|
7062
|
+
if (abortSignal?.aborted) {
|
|
7120
7063
|
await cancelOnServer();
|
|
7121
7064
|
throw new DOMException("Polling was aborted", "AbortError");
|
|
7122
7065
|
}
|
|
@@ -7159,9 +7102,8 @@ function prepareGoogleInteractionsTools({
|
|
|
7159
7102
|
tools,
|
|
7160
7103
|
toolChoice
|
|
7161
7104
|
}) {
|
|
7162
|
-
var _a, _b, _c, _d;
|
|
7163
7105
|
const toolWarnings = [];
|
|
7164
|
-
const normalized =
|
|
7106
|
+
const normalized = tools?.length ? tools : void 0;
|
|
7165
7107
|
if (normalized == null) {
|
|
7166
7108
|
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
7167
7109
|
}
|
|
@@ -7171,13 +7113,13 @@ function prepareGoogleInteractionsTools({
|
|
|
7171
7113
|
interactionsTools.push({
|
|
7172
7114
|
type: "function",
|
|
7173
7115
|
name: tool.name,
|
|
7174
|
-
description:
|
|
7116
|
+
description: tool.description ?? "",
|
|
7175
7117
|
parameters: tool.inputSchema
|
|
7176
7118
|
});
|
|
7177
7119
|
continue;
|
|
7178
7120
|
}
|
|
7179
7121
|
if (tool.type === "provider") {
|
|
7180
|
-
const args =
|
|
7122
|
+
const args = tool.args ?? {};
|
|
7181
7123
|
switch (tool.id) {
|
|
7182
7124
|
case "google.google_search": {
|
|
7183
7125
|
const searchTypesArg = args.searchTypes;
|
|
@@ -7227,7 +7169,7 @@ function prepareGoogleInteractionsTools({
|
|
|
7227
7169
|
case "google.computer_use": {
|
|
7228
7170
|
interactionsTools.push({
|
|
7229
7171
|
type: "computer_use",
|
|
7230
|
-
environment:
|
|
7172
|
+
environment: args.environment ?? "browser",
|
|
7231
7173
|
...args.excludedPredefinedFunctions != null ? {
|
|
7232
7174
|
excludedPredefinedFunctions: args.excludedPredefinedFunctions
|
|
7233
7175
|
} : {}
|
|
@@ -7245,7 +7187,7 @@ function prepareGoogleInteractionsTools({
|
|
|
7245
7187
|
break;
|
|
7246
7188
|
}
|
|
7247
7189
|
case "google.retrieval": {
|
|
7248
|
-
const vertexAiSearchConfig =
|
|
7190
|
+
const vertexAiSearchConfig = args.vertexAiSearchConfig ?? void 0;
|
|
7249
7191
|
interactionsTools.push({
|
|
7250
7192
|
type: "retrieval",
|
|
7251
7193
|
...args.retrievalTypes != null ? {
|
|
@@ -7449,7 +7391,7 @@ function streamGoogleInteractionEvents({
|
|
|
7449
7391
|
if (abortSignal != null) {
|
|
7450
7392
|
abortSignal.removeEventListener("abort", upstreamAbortHandler);
|
|
7451
7393
|
}
|
|
7452
|
-
currentReader
|
|
7394
|
+
currentReader?.cancel().catch(() => {
|
|
7453
7395
|
});
|
|
7454
7396
|
currentReader = void 0;
|
|
7455
7397
|
if (effectiveSignal.aborted && !complete) {
|
|
@@ -7464,7 +7406,7 @@ function streamGoogleInteractionEvents({
|
|
|
7464
7406
|
},
|
|
7465
7407
|
cancel() {
|
|
7466
7408
|
internalAbort.abort();
|
|
7467
|
-
currentReader
|
|
7409
|
+
currentReader?.cancel().catch(() => {
|
|
7468
7410
|
});
|
|
7469
7411
|
currentReader = void 0;
|
|
7470
7412
|
}
|
|
@@ -7481,7 +7423,6 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
7481
7423
|
}) {
|
|
7482
7424
|
return new ReadableStream({
|
|
7483
7425
|
start(controller) {
|
|
7484
|
-
var _a, _b, _c;
|
|
7485
7426
|
controller.enqueue({ type: "stream-start", warnings });
|
|
7486
7427
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
7487
7428
|
let timestamp;
|
|
@@ -7495,19 +7436,19 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
7495
7436
|
controller.enqueue({
|
|
7496
7437
|
type: "response-metadata",
|
|
7497
7438
|
...interactionId != null ? { id: interactionId } : {},
|
|
7498
|
-
modelId:
|
|
7439
|
+
modelId: response.model ?? void 0,
|
|
7499
7440
|
...timestamp ? { timestamp } : {}
|
|
7500
7441
|
});
|
|
7501
7442
|
if (includeRawChunks) {
|
|
7502
7443
|
controller.enqueue({ type: "raw", rawValue: response });
|
|
7503
7444
|
}
|
|
7504
7445
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
7505
|
-
steps:
|
|
7446
|
+
steps: response.steps ?? null,
|
|
7506
7447
|
generateId: generateId4,
|
|
7507
7448
|
interactionId
|
|
7508
7449
|
});
|
|
7509
7450
|
let blockCounter = 0;
|
|
7510
|
-
const nextBlockId = () => `${interactionId
|
|
7451
|
+
const nextBlockId = () => `${interactionId ?? "agent"}:${blockCounter++}`;
|
|
7511
7452
|
for (const part of content) {
|
|
7512
7453
|
switch (part.type) {
|
|
7513
7454
|
case "text": {
|
|
@@ -7587,7 +7528,7 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
7587
7528
|
break;
|
|
7588
7529
|
}
|
|
7589
7530
|
}
|
|
7590
|
-
const serviceTier =
|
|
7531
|
+
const serviceTier = response.service_tier ?? headerServiceTier;
|
|
7591
7532
|
const finishReason = {
|
|
7592
7533
|
unified: mapGoogleInteractionsFinishReason({
|
|
7593
7534
|
status: response.status,
|
|
@@ -7662,7 +7603,6 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7662
7603
|
};
|
|
7663
7604
|
}
|
|
7664
7605
|
async getArgs(options) {
|
|
7665
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
7666
7606
|
const warnings = [];
|
|
7667
7607
|
const googleOptions = await parseProviderOptions8({
|
|
7668
7608
|
provider: "google",
|
|
@@ -7697,7 +7637,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7697
7637
|
warnings.push(...prepared.toolWarnings);
|
|
7698
7638
|
}
|
|
7699
7639
|
const responseFormatEntries = [];
|
|
7700
|
-
if (
|
|
7640
|
+
if (options.responseFormat?.type === "json") {
|
|
7701
7641
|
if (isAgent) {
|
|
7702
7642
|
warnings.push({
|
|
7703
7643
|
type: "other",
|
|
@@ -7712,41 +7652,41 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7712
7652
|
responseFormatEntries.push(entry);
|
|
7713
7653
|
}
|
|
7714
7654
|
}
|
|
7715
|
-
if (
|
|
7655
|
+
if (googleOptions?.responseFormat != null) {
|
|
7716
7656
|
for (const entry of googleOptions.responseFormat) {
|
|
7717
7657
|
if (entry.type === "text") {
|
|
7718
7658
|
responseFormatEntries.push(
|
|
7719
7659
|
pruneUndefined({
|
|
7720
7660
|
type: "text",
|
|
7721
|
-
mime_type:
|
|
7722
|
-
schema:
|
|
7661
|
+
mime_type: entry.mimeType ?? void 0,
|
|
7662
|
+
schema: entry.schema ?? void 0
|
|
7723
7663
|
})
|
|
7724
7664
|
);
|
|
7725
7665
|
} else if (entry.type === "image") {
|
|
7726
7666
|
responseFormatEntries.push(
|
|
7727
7667
|
pruneUndefined({
|
|
7728
7668
|
type: "image",
|
|
7729
|
-
mime_type:
|
|
7730
|
-
aspect_ratio:
|
|
7731
|
-
image_size:
|
|
7669
|
+
mime_type: entry.mimeType ?? void 0,
|
|
7670
|
+
aspect_ratio: entry.aspectRatio ?? void 0,
|
|
7671
|
+
image_size: entry.imageSize ?? void 0
|
|
7732
7672
|
})
|
|
7733
7673
|
);
|
|
7734
7674
|
} else if (entry.type === "audio") {
|
|
7735
7675
|
responseFormatEntries.push(
|
|
7736
7676
|
pruneUndefined({
|
|
7737
7677
|
type: "audio",
|
|
7738
|
-
mime_type:
|
|
7678
|
+
mime_type: entry.mimeType ?? void 0
|
|
7739
7679
|
})
|
|
7740
7680
|
);
|
|
7741
7681
|
} else if (entry.type === "video") {
|
|
7742
7682
|
responseFormatEntries.push(
|
|
7743
7683
|
pruneUndefined({
|
|
7744
7684
|
type: "video",
|
|
7745
|
-
aspect_ratio:
|
|
7746
|
-
resolution:
|
|
7747
|
-
duration:
|
|
7748
|
-
delivery:
|
|
7749
|
-
gcs_uri:
|
|
7685
|
+
aspect_ratio: entry.aspectRatio ?? void 0,
|
|
7686
|
+
resolution: entry.resolution ?? void 0,
|
|
7687
|
+
duration: entry.duration ?? void 0,
|
|
7688
|
+
delivery: entry.delivery ?? void 0,
|
|
7689
|
+
gcs_uri: entry.gcsUri ?? void 0
|
|
7750
7690
|
})
|
|
7751
7691
|
);
|
|
7752
7692
|
}
|
|
@@ -7758,13 +7698,13 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7758
7698
|
warnings: convWarnings
|
|
7759
7699
|
} = convertToGoogleInteractionsInput({
|
|
7760
7700
|
prompt: options.prompt,
|
|
7761
|
-
previousInteractionId:
|
|
7762
|
-
store:
|
|
7763
|
-
mediaResolution:
|
|
7701
|
+
previousInteractionId: googleOptions?.previousInteractionId ?? void 0,
|
|
7702
|
+
store: googleOptions?.store ?? void 0,
|
|
7703
|
+
mediaResolution: googleOptions?.mediaResolution ?? void 0
|
|
7764
7704
|
});
|
|
7765
7705
|
warnings.push(...convWarnings);
|
|
7766
7706
|
let systemInstruction = convertedSystemInstruction;
|
|
7767
|
-
const optionSystemInstruction =
|
|
7707
|
+
const optionSystemInstruction = googleOptions?.systemInstruction ?? void 0;
|
|
7768
7708
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
7769
7709
|
warnings.push({
|
|
7770
7710
|
type: "other",
|
|
@@ -7789,12 +7729,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7789
7729
|
}
|
|
7790
7730
|
if (options.maxOutputTokens != null)
|
|
7791
7731
|
droppedFields.push("maxOutputTokens");
|
|
7792
|
-
if (
|
|
7732
|
+
if (googleOptions?.thinkingLevel != null)
|
|
7793
7733
|
droppedFields.push("thinkingLevel");
|
|
7794
|
-
if (
|
|
7734
|
+
if (googleOptions?.thinkingSummaries != null) {
|
|
7795
7735
|
droppedFields.push("thinkingSummaries");
|
|
7796
7736
|
}
|
|
7797
|
-
if (
|
|
7737
|
+
if (googleOptions?.imageConfig != null) droppedFields.push("imageConfig");
|
|
7798
7738
|
if (droppedFields.length > 0) {
|
|
7799
7739
|
warnings.push({
|
|
7800
7740
|
type: "other",
|
|
@@ -7804,17 +7744,17 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7804
7744
|
generationConfig = void 0;
|
|
7805
7745
|
} else {
|
|
7806
7746
|
generationConfig = pruneUndefined({
|
|
7807
|
-
temperature:
|
|
7808
|
-
top_p:
|
|
7809
|
-
top_k:
|
|
7810
|
-
seed:
|
|
7747
|
+
temperature: options.temperature ?? void 0,
|
|
7748
|
+
top_p: options.topP ?? void 0,
|
|
7749
|
+
top_k: options.topK ?? void 0,
|
|
7750
|
+
seed: options.seed ?? void 0,
|
|
7811
7751
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
7812
|
-
max_output_tokens:
|
|
7813
|
-
thinking_level:
|
|
7814
|
-
thinking_summaries:
|
|
7752
|
+
max_output_tokens: options.maxOutputTokens ?? void 0,
|
|
7753
|
+
thinking_level: googleOptions?.thinkingLevel ?? void 0,
|
|
7754
|
+
thinking_summaries: googleOptions?.thinkingSummaries ?? void 0,
|
|
7815
7755
|
tool_choice: toolChoiceForBody
|
|
7816
7756
|
});
|
|
7817
|
-
if (
|
|
7757
|
+
if (googleOptions?.imageConfig != null) {
|
|
7818
7758
|
const alreadyHasImageEntry = responseFormatEntries.some(
|
|
7819
7759
|
(entry) => entry.type === "image"
|
|
7820
7760
|
);
|
|
@@ -7833,21 +7773,21 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7833
7773
|
}
|
|
7834
7774
|
}
|
|
7835
7775
|
let agentConfig;
|
|
7836
|
-
if (isAgent &&
|
|
7776
|
+
if (isAgent && googleOptions?.agentConfig != null) {
|
|
7837
7777
|
const agentConfigOptions = googleOptions.agentConfig;
|
|
7838
7778
|
if (agentConfigOptions.type === "deep-research") {
|
|
7839
7779
|
agentConfig = pruneUndefined({
|
|
7840
7780
|
type: "deep-research",
|
|
7841
|
-
thinking_summaries:
|
|
7842
|
-
visualization:
|
|
7843
|
-
collaborative_planning:
|
|
7781
|
+
thinking_summaries: agentConfigOptions.thinkingSummaries ?? void 0,
|
|
7782
|
+
visualization: agentConfigOptions.visualization ?? void 0,
|
|
7783
|
+
collaborative_planning: agentConfigOptions.collaborativePlanning ?? void 0
|
|
7844
7784
|
});
|
|
7845
7785
|
} else if (agentConfigOptions.type === "dynamic") {
|
|
7846
7786
|
agentConfig = { type: "dynamic" };
|
|
7847
7787
|
}
|
|
7848
7788
|
}
|
|
7849
7789
|
let environment;
|
|
7850
|
-
if (
|
|
7790
|
+
if (googleOptions?.environment != null) {
|
|
7851
7791
|
if (!isAgent) {
|
|
7852
7792
|
warnings.push({
|
|
7853
7793
|
type: "other",
|
|
@@ -7857,8 +7797,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7857
7797
|
environment = googleOptions.environment;
|
|
7858
7798
|
} else {
|
|
7859
7799
|
const environmentOptions = googleOptions.environment;
|
|
7860
|
-
const sources =
|
|
7861
|
-
var _a2;
|
|
7800
|
+
const sources = environmentOptions.sources?.map((source) => {
|
|
7862
7801
|
if (source.type === "inline") {
|
|
7863
7802
|
return {
|
|
7864
7803
|
type: "inline",
|
|
@@ -7869,7 +7808,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7869
7808
|
return pruneUndefined({
|
|
7870
7809
|
type: source.type,
|
|
7871
7810
|
source: source.source,
|
|
7872
|
-
target:
|
|
7811
|
+
target: source.target ?? void 0
|
|
7873
7812
|
});
|
|
7874
7813
|
});
|
|
7875
7814
|
let network;
|
|
@@ -7878,13 +7817,10 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7878
7817
|
} else if (environmentOptions.network != null) {
|
|
7879
7818
|
network = {
|
|
7880
7819
|
allowlist: environmentOptions.network.allowlist.map(
|
|
7881
|
-
(entry) => {
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
transform: (_a2 = entry.transform) != null ? _a2 : void 0
|
|
7886
|
-
});
|
|
7887
|
-
}
|
|
7820
|
+
(entry) => pruneUndefined({
|
|
7821
|
+
domain: entry.domain,
|
|
7822
|
+
transform: entry.transform ?? void 0
|
|
7823
|
+
})
|
|
7888
7824
|
)
|
|
7889
7825
|
};
|
|
7890
7826
|
}
|
|
@@ -7901,25 +7837,24 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7901
7837
|
system_instruction: systemInstruction,
|
|
7902
7838
|
tools: toolsForBody,
|
|
7903
7839
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
7904
|
-
response_modalities:
|
|
7905
|
-
previous_interaction_id:
|
|
7906
|
-
service_tier:
|
|
7907
|
-
store:
|
|
7840
|
+
response_modalities: googleOptions?.responseModalities != null ? googleOptions.responseModalities : void 0,
|
|
7841
|
+
previous_interaction_id: googleOptions?.previousInteractionId ?? void 0,
|
|
7842
|
+
service_tier: googleOptions?.serviceTier ?? void 0,
|
|
7843
|
+
store: googleOptions?.store ?? void 0,
|
|
7908
7844
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
7909
7845
|
agent_config: agentConfig,
|
|
7910
7846
|
environment,
|
|
7911
|
-
background:
|
|
7847
|
+
background: googleOptions?.background ?? void 0
|
|
7912
7848
|
});
|
|
7913
7849
|
return {
|
|
7914
7850
|
args,
|
|
7915
7851
|
warnings,
|
|
7916
7852
|
isAgent,
|
|
7917
|
-
isBackground:
|
|
7918
|
-
pollingTimeoutMs:
|
|
7853
|
+
isBackground: googleOptions?.background === true,
|
|
7854
|
+
pollingTimeoutMs: googleOptions?.pollingTimeoutMs ?? void 0
|
|
7919
7855
|
};
|
|
7920
7856
|
}
|
|
7921
7857
|
async doGenerate(options) {
|
|
7922
|
-
var _a, _b, _c, _d, _e, _f;
|
|
7923
7858
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
7924
7859
|
const url = `${this.config.baseURL}/interactions`;
|
|
7925
7860
|
const mergedHeaders = combineHeaders8(
|
|
@@ -7953,12 +7888,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7953
7888
|
});
|
|
7954
7889
|
response = polled.response;
|
|
7955
7890
|
rawResponse = polled.rawResponse;
|
|
7956
|
-
responseHeaders =
|
|
7891
|
+
responseHeaders = polled.responseHeaders ?? responseHeaders;
|
|
7957
7892
|
}
|
|
7958
7893
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
7959
7894
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
7960
|
-
steps:
|
|
7961
|
-
generateId:
|
|
7895
|
+
steps: response.steps ?? null,
|
|
7896
|
+
generateId: this.config.generateId ?? defaultGenerateId2,
|
|
7962
7897
|
interactionId
|
|
7963
7898
|
});
|
|
7964
7899
|
const finishReason = {
|
|
@@ -7968,7 +7903,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7968
7903
|
}),
|
|
7969
7904
|
raw: response.status
|
|
7970
7905
|
};
|
|
7971
|
-
const serviceTier =
|
|
7906
|
+
const serviceTier = response.service_tier ?? responseHeaders?.["x-gemini-service-tier"] ?? void 0;
|
|
7972
7907
|
const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(
|
|
7973
7908
|
response.usage
|
|
7974
7909
|
);
|
|
@@ -7998,12 +7933,11 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
7998
7933
|
body: rawResponse,
|
|
7999
7934
|
...interactionId != null ? { id: interactionId } : {},
|
|
8000
7935
|
...timestamp ? { timestamp } : {},
|
|
8001
|
-
modelId:
|
|
7936
|
+
modelId: response.model ?? void 0
|
|
8002
7937
|
}
|
|
8003
7938
|
};
|
|
8004
7939
|
}
|
|
8005
7940
|
async doStream(options) {
|
|
8006
|
-
var _a;
|
|
8007
7941
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
8008
7942
|
const url = `${this.config.baseURL}/interactions`;
|
|
8009
7943
|
const mergedHeaders = combineHeaders8(
|
|
@@ -8032,10 +7966,10 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
8032
7966
|
abortSignal: options.abortSignal,
|
|
8033
7967
|
fetch: this.config.fetch
|
|
8034
7968
|
});
|
|
8035
|
-
const headerServiceTier = responseHeaders
|
|
7969
|
+
const headerServiceTier = responseHeaders?.["x-gemini-service-tier"];
|
|
8036
7970
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
8037
7971
|
warnings,
|
|
8038
|
-
generateId:
|
|
7972
|
+
generateId: this.config.generateId ?? defaultGenerateId2,
|
|
8039
7973
|
includeRawChunks: options.includeRawChunks,
|
|
8040
7974
|
serviceTier: headerServiceTier
|
|
8041
7975
|
});
|
|
@@ -8071,7 +8005,6 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
8071
8005
|
options,
|
|
8072
8006
|
pollingTimeoutMs
|
|
8073
8007
|
}) {
|
|
8074
|
-
var _a, _b;
|
|
8075
8008
|
const postResult = await postJsonToApi6({
|
|
8076
8009
|
url,
|
|
8077
8010
|
headers: mergedHeaders,
|
|
@@ -8090,12 +8023,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
8090
8023
|
"google.interactions: background POST response did not include an interaction id; cannot stream the result."
|
|
8091
8024
|
);
|
|
8092
8025
|
}
|
|
8093
|
-
const headerServiceTier = postHeaders
|
|
8026
|
+
const headerServiceTier = postHeaders?.["x-gemini-service-tier"];
|
|
8094
8027
|
if (isTerminalStatus(postResponse.status)) {
|
|
8095
8028
|
const synthesized = synthesizeGoogleInteractionsAgentStream({
|
|
8096
8029
|
response: postResponse,
|
|
8097
8030
|
warnings,
|
|
8098
|
-
generateId:
|
|
8031
|
+
generateId: this.config.generateId ?? defaultGenerateId2,
|
|
8099
8032
|
includeRawChunks: options.includeRawChunks,
|
|
8100
8033
|
headerServiceTier
|
|
8101
8034
|
});
|
|
@@ -8115,7 +8048,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
8115
8048
|
});
|
|
8116
8049
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
8117
8050
|
warnings,
|
|
8118
|
-
generateId:
|
|
8051
|
+
generateId: this.config.generateId ?? defaultGenerateId2,
|
|
8119
8052
|
includeRawChunks: options.includeRawChunks,
|
|
8120
8053
|
serviceTier: headerServiceTier
|
|
8121
8054
|
});
|
|
@@ -8158,6 +8091,10 @@ import { isRecord, safeParseJSON } from "@ai-sdk/provider-utils";
|
|
|
8158
8091
|
var GoogleRealtimeEventMapper = class {
|
|
8159
8092
|
constructor() {
|
|
8160
8093
|
this.turnCounter = 0;
|
|
8094
|
+
this.inputTranscriptionCounter = 0;
|
|
8095
|
+
this.inputTranscriptionBuffer = "";
|
|
8096
|
+
this.inputTranscriptionBoundary = "none";
|
|
8097
|
+
this.preserveInputTranscriptionAcrossTurnComplete = false;
|
|
8161
8098
|
this.hasAudio = false;
|
|
8162
8099
|
this.hasText = false;
|
|
8163
8100
|
this.hasTranscript = false;
|
|
@@ -8171,12 +8108,11 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8171
8108
|
return `google-item-${this.turnCounter}`;
|
|
8172
8109
|
}
|
|
8173
8110
|
/**
|
|
8174
|
-
* Rolls over to the next turn lazily,
|
|
8175
|
-
* arrives. `turnComplete` merely marks the current turn closed
|
|
8176
|
-
*
|
|
8177
|
-
*
|
|
8178
|
-
*
|
|
8179
|
-
* ordering relative to `turnComplete`.
|
|
8111
|
+
* Rolls over to the next turn lazily, once model content for the next turn
|
|
8112
|
+
* arrives. `turnComplete` merely marks the current turn closed.
|
|
8113
|
+
* This keeps an output transcript that arrives shortly after `turnComplete`
|
|
8114
|
+
* attached to the turn it belongs to, since Google delivers transcription
|
|
8115
|
+
* independently with no guaranteed ordering relative to `turnComplete`.
|
|
8180
8116
|
*/
|
|
8181
8117
|
beginTurnIfClosed() {
|
|
8182
8118
|
if (!this.turnClosed) return;
|
|
@@ -8185,19 +8121,59 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8185
8121
|
this.hasText = false;
|
|
8186
8122
|
this.hasTranscript = false;
|
|
8187
8123
|
this.turnClosed = false;
|
|
8124
|
+
this.preserveInputTranscriptionAcrossTurnComplete = false;
|
|
8125
|
+
}
|
|
8126
|
+
// Google streams input transcription as a sequence of non-accumulating
|
|
8127
|
+
// fragments for a single user utterance (e.g. "The quick brown fox",
|
|
8128
|
+
// " jumps over the", " lazy dog."). Concatenate consecutive fragments into
|
|
8129
|
+
// one running transcript under a stable synthetic id so the realtime reducer
|
|
8130
|
+
// (which overwrites the message for a given id) surfaces them as a single
|
|
8131
|
+
// coherent user message rather than one message per fragment. Google's
|
|
8132
|
+
// `finished` signal is the authoritative utterance boundary. For older
|
|
8133
|
+
// payloads without that signal, response boundaries remain a fallback.
|
|
8134
|
+
//
|
|
8135
|
+
// Input transcriptions can arrive independently of response turn events, so
|
|
8136
|
+
// their synthetic IDs use a sequence independent of `turnCounter`.
|
|
8137
|
+
accumulateInputTranscription({
|
|
8138
|
+
text,
|
|
8139
|
+
finished
|
|
8140
|
+
}) {
|
|
8141
|
+
if (!text) {
|
|
8142
|
+
if (finished === true) {
|
|
8143
|
+
this.finishInputTranscription();
|
|
8144
|
+
}
|
|
8145
|
+
return void 0;
|
|
8146
|
+
}
|
|
8147
|
+
const hasFinishedSignal = finished != null;
|
|
8148
|
+
if (this.inputTranscriptionBuffer !== "" && (this.inputTranscriptionBoundary === "interrupted" || this.inputTranscriptionBoundary === "turn-complete" && !hasFinishedSignal)) {
|
|
8149
|
+
this.finishInputTranscription();
|
|
8150
|
+
}
|
|
8151
|
+
this.inputTranscriptionBoundary = "none";
|
|
8152
|
+
this.inputTranscriptionBuffer += text;
|
|
8153
|
+
const result = {
|
|
8154
|
+
itemId: `google-input-${this.inputTranscriptionCounter}`,
|
|
8155
|
+
transcript: this.inputTranscriptionBuffer
|
|
8156
|
+
};
|
|
8157
|
+
if (finished === true) {
|
|
8158
|
+
this.finishInputTranscription();
|
|
8159
|
+
}
|
|
8160
|
+
return result;
|
|
8161
|
+
}
|
|
8162
|
+
finishInputTranscription() {
|
|
8163
|
+
if (this.inputTranscriptionBuffer === "") return;
|
|
8164
|
+
this.inputTranscriptionCounter++;
|
|
8165
|
+
this.inputTranscriptionBuffer = "";
|
|
8188
8166
|
}
|
|
8189
8167
|
parseServerEvent(raw) {
|
|
8190
|
-
var _a, _b;
|
|
8191
8168
|
const data = raw;
|
|
8192
8169
|
if (data.setupComplete != null) {
|
|
8193
8170
|
return { type: "session-created", raw };
|
|
8194
8171
|
}
|
|
8195
8172
|
if (data.toolCall != null) {
|
|
8196
8173
|
this.beginTurnIfClosed();
|
|
8197
|
-
const functionCalls =
|
|
8174
|
+
const functionCalls = data.toolCall.functionCalls ?? [];
|
|
8198
8175
|
return functionCalls.flatMap((functionCall) => {
|
|
8199
|
-
|
|
8200
|
-
const args = JSON.stringify((_a2 = functionCall.args) != null ? _a2 : {});
|
|
8176
|
+
const args = JSON.stringify(functionCall.args ?? {});
|
|
8201
8177
|
return [
|
|
8202
8178
|
{
|
|
8203
8179
|
type: "function-call-arguments-delta",
|
|
@@ -8243,29 +8219,35 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8243
8219
|
if (data.serverContent != null) {
|
|
8244
8220
|
return this.parseServerContent(data.serverContent, raw);
|
|
8245
8221
|
}
|
|
8246
|
-
if (
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8222
|
+
if (data.inputTranscription != null) {
|
|
8223
|
+
const transcription = this.accumulateInputTranscription(
|
|
8224
|
+
data.inputTranscription
|
|
8225
|
+
);
|
|
8226
|
+
if (transcription != null) {
|
|
8227
|
+
return {
|
|
8228
|
+
type: "input-transcription-completed",
|
|
8229
|
+
...transcription,
|
|
8230
|
+
raw
|
|
8231
|
+
};
|
|
8232
|
+
}
|
|
8253
8233
|
}
|
|
8254
8234
|
return { type: "custom", rawType: String(Object.keys(data)[0]), raw };
|
|
8255
8235
|
}
|
|
8256
8236
|
parseServerContent(serverContent, raw) {
|
|
8257
|
-
var _a, _b, _c, _d;
|
|
8258
8237
|
const events = [];
|
|
8259
8238
|
if (serverContent.interrupted) {
|
|
8239
|
+
this.inputTranscriptionBoundary = "interrupted";
|
|
8240
|
+
this.preserveInputTranscriptionAcrossTurnComplete = true;
|
|
8241
|
+
this.turnClosed = true;
|
|
8260
8242
|
events.push({
|
|
8261
8243
|
type: "speech-started",
|
|
8262
8244
|
raw
|
|
8263
8245
|
});
|
|
8264
8246
|
}
|
|
8265
|
-
if (
|
|
8247
|
+
if (serverContent.modelTurn?.parts) {
|
|
8266
8248
|
this.beginTurnIfClosed();
|
|
8267
8249
|
for (const part of serverContent.modelTurn.parts) {
|
|
8268
|
-
if (
|
|
8250
|
+
if (part.inlineData?.data) {
|
|
8269
8251
|
this.hasAudio = true;
|
|
8270
8252
|
events.push({
|
|
8271
8253
|
type: "audio-delta",
|
|
@@ -8287,7 +8269,7 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8287
8269
|
}
|
|
8288
8270
|
}
|
|
8289
8271
|
}
|
|
8290
|
-
if (
|
|
8272
|
+
if (serverContent.outputTranscription?.text) {
|
|
8291
8273
|
this.hasTranscript = true;
|
|
8292
8274
|
events.push({
|
|
8293
8275
|
type: "audio-transcript-delta",
|
|
@@ -8297,18 +8279,36 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8297
8279
|
raw
|
|
8298
8280
|
});
|
|
8299
8281
|
}
|
|
8300
|
-
if (
|
|
8282
|
+
if (serverContent.inputTranscription != null) {
|
|
8283
|
+
const transcription = this.accumulateInputTranscription(
|
|
8284
|
+
serverContent.inputTranscription
|
|
8285
|
+
);
|
|
8286
|
+
if (transcription != null) {
|
|
8287
|
+
events.push({
|
|
8288
|
+
type: "input-transcription-completed",
|
|
8289
|
+
...transcription,
|
|
8290
|
+
raw
|
|
8291
|
+
});
|
|
8292
|
+
}
|
|
8293
|
+
}
|
|
8294
|
+
if (serverContent.generationComplete) {
|
|
8301
8295
|
events.push({
|
|
8302
|
-
type: "
|
|
8303
|
-
|
|
8304
|
-
transcript: serverContent.inputTranscription.text,
|
|
8296
|
+
type: "custom",
|
|
8297
|
+
rawType: "generationComplete",
|
|
8305
8298
|
raw
|
|
8306
8299
|
});
|
|
8307
8300
|
}
|
|
8308
|
-
if (serverContent.
|
|
8301
|
+
if (serverContent.interactionStatus != null) {
|
|
8309
8302
|
events.push({
|
|
8310
8303
|
type: "custom",
|
|
8311
|
-
rawType: "
|
|
8304
|
+
rawType: "interactionStatus",
|
|
8305
|
+
raw
|
|
8306
|
+
});
|
|
8307
|
+
}
|
|
8308
|
+
if (serverContent.waitingForInput) {
|
|
8309
|
+
events.push({
|
|
8310
|
+
type: "custom",
|
|
8311
|
+
rawType: "waitingForInput",
|
|
8312
8312
|
raw
|
|
8313
8313
|
});
|
|
8314
8314
|
}
|
|
@@ -8344,6 +8344,13 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8344
8344
|
raw
|
|
8345
8345
|
});
|
|
8346
8346
|
this.turnClosed = true;
|
|
8347
|
+
if (this.preserveInputTranscriptionAcrossTurnComplete) {
|
|
8348
|
+
this.preserveInputTranscriptionAcrossTurnComplete = false;
|
|
8349
|
+
} else {
|
|
8350
|
+
if (this.inputTranscriptionBoundary !== "interrupted") {
|
|
8351
|
+
this.inputTranscriptionBoundary = "turn-complete";
|
|
8352
|
+
}
|
|
8353
|
+
}
|
|
8347
8354
|
}
|
|
8348
8355
|
if (events.length === 0) {
|
|
8349
8356
|
return { type: "custom", rawType: "serverContent", raw };
|
|
@@ -8351,10 +8358,9 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8351
8358
|
return events.length === 1 ? events[0] : events;
|
|
8352
8359
|
}
|
|
8353
8360
|
serializeClientEvent(event, modelId) {
|
|
8354
|
-
var _a;
|
|
8355
8361
|
switch (event.type) {
|
|
8356
8362
|
case "session-update":
|
|
8357
|
-
if (
|
|
8363
|
+
if (event.config.inputAudioFormat?.rate != null) {
|
|
8358
8364
|
this.inputAudioRate = event.config.inputAudioFormat.rate;
|
|
8359
8365
|
}
|
|
8360
8366
|
return {
|
|
@@ -8400,9 +8406,16 @@ var GoogleRealtimeEventMapper = class {
|
|
|
8400
8406
|
return null;
|
|
8401
8407
|
}
|
|
8402
8408
|
};
|
|
8409
|
+
function toFunctionResponseStruct(value) {
|
|
8410
|
+
const isStruct = typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8411
|
+
return isStruct ? value : { output: value };
|
|
8412
|
+
}
|
|
8403
8413
|
async function serializeFunctionCallOutput(item) {
|
|
8404
8414
|
const parseResult = await safeParseJSON({ text: item.output });
|
|
8405
|
-
const response = parseResult.success ? parseResult.value :
|
|
8415
|
+
const response = parseResult.success ? toFunctionResponseStruct(parseResult.value) : (
|
|
8416
|
+
// Preserve non-JSON output in the required object wrapper.
|
|
8417
|
+
{ output: item.output }
|
|
8418
|
+
);
|
|
8406
8419
|
return {
|
|
8407
8420
|
toolResponse: {
|
|
8408
8421
|
functionResponses: [
|
|
@@ -8415,19 +8428,25 @@ async function serializeFunctionCallOutput(item) {
|
|
|
8415
8428
|
}
|
|
8416
8429
|
};
|
|
8417
8430
|
}
|
|
8431
|
+
function isThinkingLiveModel(modelId) {
|
|
8432
|
+
const modelName = modelId.split("/").at(-1)?.toLowerCase() ?? "";
|
|
8433
|
+
return /^gemini-\d+\.\d+-live\b.*thinking/.test(modelName);
|
|
8434
|
+
}
|
|
8418
8435
|
function buildGoogleSessionConfig(config, modelId) {
|
|
8419
8436
|
const setup = {
|
|
8420
8437
|
model: getModelPath(modelId)
|
|
8421
8438
|
};
|
|
8439
|
+
const { google: google2, ...restProviderOptions } = config?.providerOptions ?? {};
|
|
8440
|
+
const googleOptions = isRecord(google2) ? google2 : void 0;
|
|
8422
8441
|
const generationConfig = {};
|
|
8423
|
-
if (
|
|
8442
|
+
if (config?.outputModalities != null) {
|
|
8424
8443
|
generationConfig.responseModalities = config.outputModalities.map(
|
|
8425
8444
|
(m) => m.toUpperCase()
|
|
8426
8445
|
);
|
|
8427
8446
|
} else {
|
|
8428
8447
|
generationConfig.responseModalities = ["AUDIO"];
|
|
8429
8448
|
}
|
|
8430
|
-
if (
|
|
8449
|
+
if (config?.voice != null) {
|
|
8431
8450
|
generationConfig.speechConfig = {
|
|
8432
8451
|
voiceConfig: {
|
|
8433
8452
|
prebuiltVoiceConfig: {
|
|
@@ -8437,41 +8456,50 @@ function buildGoogleSessionConfig(config, modelId) {
|
|
|
8437
8456
|
};
|
|
8438
8457
|
}
|
|
8439
8458
|
setup.generationConfig = generationConfig;
|
|
8440
|
-
if (
|
|
8459
|
+
if (config?.instructions != null) {
|
|
8441
8460
|
setup.systemInstruction = {
|
|
8442
8461
|
parts: [{ text: config.instructions }]
|
|
8443
8462
|
};
|
|
8444
8463
|
}
|
|
8445
|
-
if (
|
|
8464
|
+
if (config?.tools != null && config.tools.length > 0) {
|
|
8446
8465
|
setup.tools = [
|
|
8447
8466
|
{
|
|
8448
8467
|
functionDeclarations: config.tools.map((tool) => ({
|
|
8449
8468
|
name: tool.name,
|
|
8450
8469
|
description: tool.description,
|
|
8451
|
-
|
|
8470
|
+
parametersJsonSchema: tool.parameters,
|
|
8471
|
+
...googleOptions?.defaultToolBehavior != null ? { behavior: googleOptions.defaultToolBehavior } : {}
|
|
8452
8472
|
}))
|
|
8453
8473
|
}
|
|
8454
8474
|
];
|
|
8455
8475
|
}
|
|
8456
|
-
if (
|
|
8476
|
+
if (config?.inputAudioTranscription != null) {
|
|
8457
8477
|
setup.inputAudioTranscription = {};
|
|
8458
8478
|
}
|
|
8459
|
-
if (
|
|
8479
|
+
if (config?.outputAudioTranscription != null) {
|
|
8460
8480
|
setup.outputAudioTranscription = {};
|
|
8461
8481
|
}
|
|
8462
|
-
|
|
8482
|
+
const rawGenerationConfig = restProviderOptions.generationConfig;
|
|
8483
|
+
const explicitThinkingConfig = googleOptions?.thinkingConfig ?? (isRecord(rawGenerationConfig) && isRecord(rawGenerationConfig.thinkingConfig) ? rawGenerationConfig.thinkingConfig : void 0);
|
|
8484
|
+
const thinkingConfig = isThinkingLiveModel(modelId) && explicitThinkingConfig?.thinkingLevel == null && explicitThinkingConfig?.thinkingBudget == null ? { ...explicitThinkingConfig, thinkingLevel: "low" } : googleOptions?.thinkingConfig;
|
|
8485
|
+
const applyThinkingConfig = () => {
|
|
8486
|
+
if (thinkingConfig == null) return;
|
|
8487
|
+
const target = isRecord(setup.generationConfig) ? setup.generationConfig : generationConfig;
|
|
8488
|
+
setup.generationConfig = { ...target, thinkingConfig };
|
|
8489
|
+
};
|
|
8490
|
+
if (config?.providerOptions == null) {
|
|
8491
|
+
applyThinkingConfig();
|
|
8463
8492
|
return setup;
|
|
8464
8493
|
}
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
const googleOptions = isRecord(google2) ? google2 : void 0;
|
|
8468
|
-
if ((googleOptions == null ? void 0 : googleOptions.translationConfig) != null) {
|
|
8494
|
+
Object.assign(setup, restProviderOptions);
|
|
8495
|
+
if (googleOptions?.translationConfig != null) {
|
|
8469
8496
|
const target = isRecord(setup.generationConfig) ? setup.generationConfig : generationConfig;
|
|
8470
8497
|
setup.generationConfig = {
|
|
8471
8498
|
...target,
|
|
8472
8499
|
translationConfig: googleOptions.translationConfig
|
|
8473
8500
|
};
|
|
8474
8501
|
}
|
|
8502
|
+
applyThinkingConfig();
|
|
8475
8503
|
return setup;
|
|
8476
8504
|
}
|
|
8477
8505
|
|
|
@@ -8494,8 +8522,7 @@ var GoogleRealtimeModel = class {
|
|
|
8494
8522
|
this.config = config;
|
|
8495
8523
|
}
|
|
8496
8524
|
async doCreateClientSecret(options) {
|
|
8497
|
-
|
|
8498
|
-
const fetchFn = (_a = this.config.fetch) != null ? _a : fetch;
|
|
8525
|
+
const fetchFn = this.config.fetch ?? fetch;
|
|
8499
8526
|
const headers = this.config.headers();
|
|
8500
8527
|
const apiKey = headers["x-goog-api-key"];
|
|
8501
8528
|
if (!apiKey) {
|
|
@@ -8504,7 +8531,7 @@ var GoogleRealtimeModel = class {
|
|
|
8504
8531
|
);
|
|
8505
8532
|
}
|
|
8506
8533
|
const now = Date.now();
|
|
8507
|
-
const openWindowMs = (
|
|
8534
|
+
const openWindowMs = (options.expiresAfterSeconds ?? 60) * 1e3;
|
|
8508
8535
|
const newSessionExpireTime = new Date(now + openWindowMs).toISOString();
|
|
8509
8536
|
const expireTime = new Date(
|
|
8510
8537
|
now + openWindowMs + 30 * 60 * 1e3
|
|
@@ -8560,7 +8587,7 @@ var GoogleRealtimeModel = class {
|
|
|
8560
8587
|
|
|
8561
8588
|
// src/transcription/google-transcription-model.ts
|
|
8562
8589
|
import {
|
|
8563
|
-
InvalidArgumentError as
|
|
8590
|
+
InvalidArgumentError as InvalidArgumentError3
|
|
8564
8591
|
} from "@ai-sdk/provider";
|
|
8565
8592
|
import {
|
|
8566
8593
|
combineHeaders as combineHeaders9,
|
|
@@ -8648,14 +8675,13 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8648
8675
|
});
|
|
8649
8676
|
}
|
|
8650
8677
|
async doGenerate(options) {
|
|
8651
|
-
var _a, _b, _c, _d, _e, _f;
|
|
8652
8678
|
if (isLiveTranscriptionModelId(this.modelId)) {
|
|
8653
|
-
throw new
|
|
8679
|
+
throw new InvalidArgumentError3({
|
|
8654
8680
|
argument: "modelId",
|
|
8655
8681
|
message: `Model '${this.modelId}' only supports streaming transcription. Use experimental_streamTranscribe, or a unary model such as 'gemini-3.5-transcribe'.`
|
|
8656
8682
|
});
|
|
8657
8683
|
}
|
|
8658
|
-
const currentDate =
|
|
8684
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
8659
8685
|
const warnings = [];
|
|
8660
8686
|
const googleOptions = await this.parseOptions(options.providerOptions);
|
|
8661
8687
|
const transcriptionConfig = buildTranscriptionConfig(googleOptions);
|
|
@@ -8690,11 +8716,11 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8690
8716
|
});
|
|
8691
8717
|
let text = "";
|
|
8692
8718
|
const segments = [];
|
|
8693
|
-
for (const step of
|
|
8694
|
-
for (const content of
|
|
8719
|
+
for (const step of response.steps ?? []) {
|
|
8720
|
+
for (const content of step.content ?? []) {
|
|
8695
8721
|
if (content.type !== "text" || content.text == null) continue;
|
|
8696
8722
|
text += content.text;
|
|
8697
|
-
for (const annotation of
|
|
8723
|
+
for (const annotation of content.annotations ?? []) {
|
|
8698
8724
|
if (annotation.type !== "word_info") continue;
|
|
8699
8725
|
const startSecond = parseOffsetSeconds(annotation.start_offset);
|
|
8700
8726
|
const endSecond = parseOffsetSeconds(annotation.end_offset);
|
|
@@ -8725,14 +8751,13 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8725
8751
|
};
|
|
8726
8752
|
}
|
|
8727
8753
|
async doStream(options) {
|
|
8728
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
8729
8754
|
if (!isLiveTranscriptionModelId(this.modelId)) {
|
|
8730
|
-
throw new
|
|
8755
|
+
throw new InvalidArgumentError3({
|
|
8731
8756
|
argument: "modelId",
|
|
8732
8757
|
message: `Model '${this.modelId}' does not support streaming transcription. Use a live model such as 'gemini-3.5-transcribe-live'.`
|
|
8733
8758
|
});
|
|
8734
8759
|
}
|
|
8735
|
-
const currentDate =
|
|
8760
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
8736
8761
|
const warnings = [];
|
|
8737
8762
|
const googleOptions = await this.parseOptions(options.providerOptions);
|
|
8738
8763
|
validateLiveInputAudioFormat(options.inputAudioFormat);
|
|
@@ -8758,7 +8783,7 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8758
8783
|
);
|
|
8759
8784
|
const setup = {
|
|
8760
8785
|
model: getModelPath(this.modelId),
|
|
8761
|
-
inputAudioTranscription:
|
|
8786
|
+
inputAudioTranscription: buildAudioTranscriptionConfig(googleOptions) ?? {}
|
|
8762
8787
|
};
|
|
8763
8788
|
return {
|
|
8764
8789
|
request: { body: setup },
|
|
@@ -8771,8 +8796,8 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
|
|
|
8771
8796
|
url: getLiveWebSocketURL(this.config.baseURL, apiKey),
|
|
8772
8797
|
headers: webSocketHeaders,
|
|
8773
8798
|
setup,
|
|
8774
|
-
inputAudioRate:
|
|
8775
|
-
finishGraceMs:
|
|
8799
|
+
inputAudioRate: options.inputAudioFormat.rate ?? 16e3,
|
|
8800
|
+
finishGraceMs: this.config._internal?.finishGraceMs ?? defaultFinishGraceMs,
|
|
8776
8801
|
warnings,
|
|
8777
8802
|
audio: options.audio,
|
|
8778
8803
|
abortSignal: options.abortSignal,
|
|
@@ -8836,7 +8861,7 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8836
8861
|
void audio.cancel().catch(() => {
|
|
8837
8862
|
});
|
|
8838
8863
|
}
|
|
8839
|
-
connection
|
|
8864
|
+
connection?.close(closeCode);
|
|
8840
8865
|
};
|
|
8841
8866
|
const finishWithError = (error) => {
|
|
8842
8867
|
if (finished) return;
|
|
@@ -8917,7 +8942,6 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8917
8942
|
void setupComplete.then(() => finished ? void 0 : sendAudio(socket)).catch(finishWithError);
|
|
8918
8943
|
},
|
|
8919
8944
|
onMessageText: async (text) => {
|
|
8920
|
-
var _a, _b;
|
|
8921
8945
|
if (finished) return;
|
|
8922
8946
|
const parsed = await safeParseJSON2({ text });
|
|
8923
8947
|
if (!parsed.success) return;
|
|
@@ -8933,13 +8957,13 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8933
8957
|
}
|
|
8934
8958
|
if (message.error != null) {
|
|
8935
8959
|
finishWithError(
|
|
8936
|
-
new Error(
|
|
8960
|
+
new Error(message.error.message ?? "Google Live API error")
|
|
8937
8961
|
);
|
|
8938
8962
|
return;
|
|
8939
8963
|
}
|
|
8940
8964
|
const serverContent = message.serverContent;
|
|
8941
|
-
const interim = serverContent
|
|
8942
|
-
if (interim
|
|
8965
|
+
const interim = serverContent?.interimInputTranscription;
|
|
8966
|
+
if (interim?.text) {
|
|
8943
8967
|
schedulePendingFinish();
|
|
8944
8968
|
latestInterim = interim.text;
|
|
8945
8969
|
controller.enqueue({
|
|
@@ -8948,7 +8972,7 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8948
8972
|
text: interim.text
|
|
8949
8973
|
});
|
|
8950
8974
|
}
|
|
8951
|
-
const transcription =
|
|
8975
|
+
const transcription = serverContent?.inputTranscription ?? message.inputTranscription;
|
|
8952
8976
|
if (transcription != null) {
|
|
8953
8977
|
if (transcription.languageCode != null) {
|
|
8954
8978
|
language = transcription.languageCode;
|
|
@@ -8967,11 +8991,11 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8967
8991
|
completeSegment();
|
|
8968
8992
|
}
|
|
8969
8993
|
}
|
|
8970
|
-
if (serverContent
|
|
8994
|
+
if (serverContent?.turnComplete) {
|
|
8971
8995
|
completeSegment();
|
|
8972
8996
|
}
|
|
8973
|
-
const interactionStatus = serverContent
|
|
8974
|
-
if (audioEnded && (interactionStatus === "IDLE" || interactionStatus === "REQUIRES_ACTION" ||
|
|
8997
|
+
const interactionStatus = serverContent?.interactionStatus;
|
|
8998
|
+
if (audioEnded && (interactionStatus === "IDLE" || interactionStatus === "REQUIRES_ACTION" || serverContent?.turnComplete === true && interactionStatus == null)) {
|
|
8975
8999
|
finish();
|
|
8976
9000
|
}
|
|
8977
9001
|
},
|
|
@@ -8986,7 +9010,7 @@ function createGoogleLiveTranscriptionStream({
|
|
|
8986
9010
|
}
|
|
8987
9011
|
finishWithError(
|
|
8988
9012
|
new Error(
|
|
8989
|
-
`Google Live transcription WebSocket closed unexpectedly before finishing (code ${code
|
|
9013
|
+
`Google Live transcription WebSocket closed unexpectedly before finishing (code ${code ?? "unknown"}${reason ? `, reason: ${reason}` : ""}).`
|
|
8990
9014
|
)
|
|
8991
9015
|
);
|
|
8992
9016
|
}
|
|
@@ -9020,7 +9044,6 @@ function buildAudioTranscriptionConfig(options) {
|
|
|
9020
9044
|
return Object.keys(config).length > 0 ? config : void 0;
|
|
9021
9045
|
}
|
|
9022
9046
|
function buildTranscriptionConfig(options) {
|
|
9023
|
-
var _a;
|
|
9024
9047
|
if (options == null) return void 0;
|
|
9025
9048
|
const config = {};
|
|
9026
9049
|
if (options.languageCodes != null) {
|
|
@@ -9031,7 +9054,7 @@ function buildTranscriptionConfig(options) {
|
|
|
9031
9054
|
}
|
|
9032
9055
|
if (options.mode != null || options.diarization === true || options.wordTimestamp === true) {
|
|
9033
9056
|
config.mode = {
|
|
9034
|
-
type: (
|
|
9057
|
+
type: (options.mode ?? "VERBATIM").toLowerCase(),
|
|
9035
9058
|
...options.diarization === true ? { diarization_mode: "speaker" } : {},
|
|
9036
9059
|
...options.wordTimestamp === true ? { timestamp_granularities: ["word"] } : {}
|
|
9037
9060
|
};
|
|
@@ -9045,7 +9068,7 @@ function parseOffsetSeconds(offset) {
|
|
|
9045
9068
|
}
|
|
9046
9069
|
function validateLiveInputAudioFormat(inputAudioFormat) {
|
|
9047
9070
|
if (inputAudioFormat.type !== "audio/pcm" || inputAudioFormat.rate != null && inputAudioFormat.rate !== 16e3) {
|
|
9048
|
-
throw new
|
|
9071
|
+
throw new InvalidArgumentError3({
|
|
9049
9072
|
argument: "inputAudioFormat",
|
|
9050
9073
|
message: "The Gemini Live transcription API only supports 16kHz 16-bit PCM input audio."
|
|
9051
9074
|
});
|
|
@@ -9077,7 +9100,7 @@ var googleInteractionsTranscriptionResponseSchema = z23.object({
|
|
|
9077
9100
|
|
|
9078
9101
|
// src/speech-translation/google-speech-translation-model.ts
|
|
9079
9102
|
import {
|
|
9080
|
-
InvalidArgumentError as
|
|
9103
|
+
InvalidArgumentError as InvalidArgumentError4
|
|
9081
9104
|
} from "@ai-sdk/provider";
|
|
9082
9105
|
import {
|
|
9083
9106
|
connectToWebSocket as connectToWebSocket2,
|
|
@@ -9139,14 +9162,13 @@ var GoogleSpeechTranslationModel = class _GoogleSpeechTranslationModel {
|
|
|
9139
9162
|
return this.config.provider;
|
|
9140
9163
|
}
|
|
9141
9164
|
async doStream(options) {
|
|
9142
|
-
var _a, _b, _c, _d, _e, _f;
|
|
9143
9165
|
if (options.targetLanguage == null) {
|
|
9144
|
-
throw new
|
|
9166
|
+
throw new InvalidArgumentError4({
|
|
9145
9167
|
argument: "targetLanguage",
|
|
9146
9168
|
message: `targetLanguage is required for translation model '${this.modelId}'.`
|
|
9147
9169
|
});
|
|
9148
9170
|
}
|
|
9149
|
-
const currentDate =
|
|
9171
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
9150
9172
|
const googleOptions = await parseProviderOptions10({
|
|
9151
9173
|
provider: "google",
|
|
9152
9174
|
providerOptions: options.providerOptions,
|
|
@@ -9201,8 +9223,8 @@ var GoogleSpeechTranslationModel = class _GoogleSpeechTranslationModel {
|
|
|
9201
9223
|
url: getLiveWebSocketURL2(this.config.baseURL, apiKey),
|
|
9202
9224
|
headers: webSocketHeaders,
|
|
9203
9225
|
setup,
|
|
9204
|
-
inputAudioRate:
|
|
9205
|
-
finishGraceMs:
|
|
9226
|
+
inputAudioRate: options.inputAudioFormat.rate ?? 16e3,
|
|
9227
|
+
finishGraceMs: this.config._internal?.finishGraceMs ?? defaultFinishGraceMs2,
|
|
9206
9228
|
warnings,
|
|
9207
9229
|
audio: options.audio,
|
|
9208
9230
|
abortSignal: options.abortSignal,
|
|
@@ -9273,7 +9295,7 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9273
9295
|
void audio.cancel().catch(() => {
|
|
9274
9296
|
});
|
|
9275
9297
|
}
|
|
9276
|
-
connection
|
|
9298
|
+
connection?.close(closeCode);
|
|
9277
9299
|
};
|
|
9278
9300
|
const finishWithError = (error) => {
|
|
9279
9301
|
if (finished) return;
|
|
@@ -9362,7 +9384,6 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9362
9384
|
void setupComplete.then(() => finished ? void 0 : sendAudio(socket)).catch(finishWithError);
|
|
9363
9385
|
},
|
|
9364
9386
|
onMessageText: async (text) => {
|
|
9365
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
9366
9387
|
if (finished) return;
|
|
9367
9388
|
const parsed = await safeParseJSON3({ text });
|
|
9368
9389
|
if (!parsed.success) return;
|
|
@@ -9378,11 +9399,11 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9378
9399
|
}
|
|
9379
9400
|
if (message.error != null) {
|
|
9380
9401
|
finishWithError(
|
|
9381
|
-
new Error(
|
|
9402
|
+
new Error(message.error.message ?? "Google Live API error")
|
|
9382
9403
|
);
|
|
9383
9404
|
return;
|
|
9384
9405
|
}
|
|
9385
|
-
const inputTranscriptionText =
|
|
9406
|
+
const inputTranscriptionText = message.serverContent?.inputTranscription?.text ?? message.inputTranscription?.text;
|
|
9386
9407
|
if (inputTranscriptionText) {
|
|
9387
9408
|
onTurnActivity();
|
|
9388
9409
|
sourceTurnBuffer += inputTranscriptionText;
|
|
@@ -9396,8 +9417,8 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9396
9417
|
if (serverContent == null) {
|
|
9397
9418
|
return;
|
|
9398
9419
|
}
|
|
9399
|
-
for (const part of
|
|
9400
|
-
if (
|
|
9420
|
+
for (const part of serverContent.modelTurn?.parts ?? []) {
|
|
9421
|
+
if (part.inlineData?.data) {
|
|
9401
9422
|
controller.enqueue({
|
|
9402
9423
|
type: "audio",
|
|
9403
9424
|
id: itemId(),
|
|
@@ -9417,7 +9438,7 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9417
9438
|
}
|
|
9418
9439
|
}
|
|
9419
9440
|
}
|
|
9420
|
-
if (
|
|
9441
|
+
if (serverContent.outputTranscription?.text) {
|
|
9421
9442
|
onTurnActivity();
|
|
9422
9443
|
translationTurnBuffer += serverContent.outputTranscription.text;
|
|
9423
9444
|
controller.enqueue({
|
|
@@ -9446,7 +9467,7 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9446
9467
|
}
|
|
9447
9468
|
finishWithError(
|
|
9448
9469
|
new Error(
|
|
9449
|
-
`Google Live translation WebSocket closed unexpectedly before finishing (code ${code
|
|
9470
|
+
`Google Live translation WebSocket closed unexpectedly before finishing (code ${code ?? "unknown"}${reason ? `, reason: ${reason}` : ""}).`
|
|
9450
9471
|
)
|
|
9451
9472
|
);
|
|
9452
9473
|
}
|
|
@@ -9460,17 +9481,16 @@ function createGoogleLiveSpeechTranslationStream({
|
|
|
9460
9481
|
});
|
|
9461
9482
|
}
|
|
9462
9483
|
function accumulateGoogleLiveUsage(usage, usageMetadata) {
|
|
9463
|
-
|
|
9464
|
-
let
|
|
9465
|
-
|
|
9466
|
-
for (const detail of (_a = usageMetadata.promptTokensDetails) != null ? _a : []) {
|
|
9484
|
+
let inputAudioTokens = usage?.inputAudioTokens;
|
|
9485
|
+
let outputAudioTokens = usage?.outputAudioTokens;
|
|
9486
|
+
for (const detail of usageMetadata.promptTokensDetails ?? []) {
|
|
9467
9487
|
if (detail.modality === "AUDIO" && detail.tokenCount != null) {
|
|
9468
|
-
inputAudioTokens = (inputAudioTokens
|
|
9488
|
+
inputAudioTokens = (inputAudioTokens ?? 0) + detail.tokenCount;
|
|
9469
9489
|
}
|
|
9470
9490
|
}
|
|
9471
|
-
for (const detail of
|
|
9491
|
+
for (const detail of usageMetadata.responseTokensDetails ?? []) {
|
|
9472
9492
|
if (detail.modality === "AUDIO" && detail.tokenCount != null) {
|
|
9473
|
-
outputAudioTokens = (outputAudioTokens
|
|
9493
|
+
outputAudioTokens = (outputAudioTokens ?? 0) + detail.tokenCount;
|
|
9474
9494
|
}
|
|
9475
9495
|
}
|
|
9476
9496
|
if (inputAudioTokens == null && outputAudioTokens == null) {
|
|
@@ -9486,7 +9506,7 @@ function getPcm16SilenceDurationMs(audio) {
|
|
|
9486
9506
|
let bytes;
|
|
9487
9507
|
try {
|
|
9488
9508
|
bytes = convertBase64ToUint8Array2(audio);
|
|
9489
|
-
} catch
|
|
9509
|
+
} catch {
|
|
9490
9510
|
return void 0;
|
|
9491
9511
|
}
|
|
9492
9512
|
if (bytes.byteLength < 2) {
|
|
@@ -9512,7 +9532,7 @@ function buildGoogleLiveSpeechTranslationSetup({
|
|
|
9512
9532
|
responseModalities: ["AUDIO"],
|
|
9513
9533
|
translationConfig: {
|
|
9514
9534
|
targetLanguageCode: targetLanguage,
|
|
9515
|
-
...
|
|
9535
|
+
...providerOptions?.echoTargetLanguage != null ? { echoTargetLanguage: providerOptions.echoTargetLanguage } : {}
|
|
9516
9536
|
}
|
|
9517
9537
|
},
|
|
9518
9538
|
inputAudioTranscription: {},
|
|
@@ -9521,7 +9541,7 @@ function buildGoogleLiveSpeechTranslationSetup({
|
|
|
9521
9541
|
}
|
|
9522
9542
|
function validateGoogleSpeechTranslationInputAudioFormat(inputAudioFormat) {
|
|
9523
9543
|
if (inputAudioFormat.type !== "audio/pcm" || inputAudioFormat.rate != null && inputAudioFormat.rate !== 16e3) {
|
|
9524
|
-
throw new
|
|
9544
|
+
throw new InvalidArgumentError4({
|
|
9525
9545
|
argument: "inputAudioFormat",
|
|
9526
9546
|
message: "The Gemini Live translation API only supports 16kHz 16-bit PCM input audio."
|
|
9527
9547
|
});
|
|
@@ -9560,9 +9580,8 @@ function supportsExternalFileUrls(modelId) {
|
|
|
9560
9580
|
return /(^|\/)gemini-/.test(modelId) && !/(^|\/)gemini-2\.0/.test(modelId);
|
|
9561
9581
|
}
|
|
9562
9582
|
function createGoogle(options = {}) {
|
|
9563
|
-
|
|
9564
|
-
const
|
|
9565
|
-
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
9583
|
+
const baseURL = withoutTrailingSlash(options.baseURL) ?? DEFAULT_BASE_URL;
|
|
9584
|
+
const providerName = options.name ?? "google.generative-ai";
|
|
9566
9585
|
const getHeaders = () => withUserAgentSuffix2(
|
|
9567
9586
|
{
|
|
9568
9587
|
"x-goog-api-key": loadApiKey({
|
|
@@ -9572,7 +9591,7 @@ function createGoogle(options = {}) {
|
|
|
9572
9591
|
}),
|
|
9573
9592
|
...options.headers
|
|
9574
9593
|
},
|
|
9575
|
-
`ai-sdk
|
|
9594
|
+
`ai-sdk-google/${VERSION}`
|
|
9576
9595
|
);
|
|
9577
9596
|
const getSupportedUrls = (modelId, includeExternalUrls = modelId == null || supportsExternalFileUrls(modelId)) => ({
|
|
9578
9597
|
"*": [
|
|
@@ -9594,7 +9613,7 @@ function createGoogle(options = {}) {
|
|
|
9594
9613
|
provider: providerName,
|
|
9595
9614
|
baseURL,
|
|
9596
9615
|
headers: getHeaders,
|
|
9597
|
-
generateId:
|
|
9616
|
+
generateId: options.generateId ?? generateId3,
|
|
9598
9617
|
fetch: options.fetch
|
|
9599
9618
|
};
|
|
9600
9619
|
const createChatModel = (modelId) => new GoogleLanguageModel(modelId, {
|
|
@@ -9626,16 +9645,13 @@ function createGoogle(options = {}) {
|
|
|
9626
9645
|
headers: getHeaders,
|
|
9627
9646
|
fetch: options.fetch
|
|
9628
9647
|
});
|
|
9629
|
-
const createVideoModel = (modelId) => {
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
generateId: (_a2 = options.generateId) != null ? _a2 : generateId3
|
|
9637
|
-
});
|
|
9638
|
-
};
|
|
9648
|
+
const createVideoModel = (modelId) => new GoogleVideoModel(modelId, {
|
|
9649
|
+
provider: providerName,
|
|
9650
|
+
baseURL,
|
|
9651
|
+
headers: getHeaders,
|
|
9652
|
+
fetch: options.fetch,
|
|
9653
|
+
generateId: options.generateId ?? generateId3
|
|
9654
|
+
});
|
|
9639
9655
|
const createRealtimeModel = (modelId) => new GoogleRealtimeModel(modelId, {
|
|
9640
9656
|
provider: `${providerName}.realtime`,
|
|
9641
9657
|
baseURL,
|
|
@@ -9678,19 +9694,16 @@ function createGoogle(options = {}) {
|
|
|
9678
9694
|
}
|
|
9679
9695
|
}
|
|
9680
9696
|
);
|
|
9681
|
-
const createInteractionsModel = (modelIdOrAgent) =>
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
}
|
|
9692
|
-
);
|
|
9693
|
-
};
|
|
9697
|
+
const createInteractionsModel = (modelIdOrAgent) => new GoogleInteractionsLanguageModel(
|
|
9698
|
+
modelIdOrAgent,
|
|
9699
|
+
{
|
|
9700
|
+
provider: `${providerName}.interactions`,
|
|
9701
|
+
baseURL,
|
|
9702
|
+
headers: getHeaders,
|
|
9703
|
+
generateId: options.generateId ?? generateId3,
|
|
9704
|
+
fetch: options.fetch
|
|
9705
|
+
}
|
|
9706
|
+
);
|
|
9694
9707
|
const provider = function(modelId) {
|
|
9695
9708
|
if (new.target) {
|
|
9696
9709
|
throw new Error(
|
|
@@ -9703,6 +9716,10 @@ function createGoogle(options = {}) {
|
|
|
9703
9716
|
provider.languageModel = createChatModel;
|
|
9704
9717
|
provider.chat = createChatModel;
|
|
9705
9718
|
provider.generativeAI = createChatModel;
|
|
9719
|
+
provider.evaluationModel = (modelId) => new EvaluationLanguageModel({
|
|
9720
|
+
model: createChatModel(modelId),
|
|
9721
|
+
provider: `${providerName.replace(/\.generative-ai$/, "")}.evaluation`
|
|
9722
|
+
});
|
|
9706
9723
|
provider.experimental_batch = createBatch;
|
|
9707
9724
|
provider.embedding = createEmbeddingModel;
|
|
9708
9725
|
provider.embeddingModel = createEmbeddingModel;
|