maka-agent 0.2.0-dev.62.20260928 → 0.2.0-dev.67.20261002
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 +16 -16
- package/THIRD_PARTY_NOTICES.txt +29 -29
- package/dist/pi-tui-runner.js +26 -29
- package/dist/tui-copy-catalog.js +9 -9
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- 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/core/dist/settings.js +2 -2
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +53 -150
- 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 +23 -4
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +33 -3
- package/node_modules/@maka/runtime/dist/conversation-copy.js +6 -0
- 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/runtime-event-read-model.js +17 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +25 -40
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +82 -16
- package/node_modules/@maka/runtime/dist/stream-graph-projection.js +64 -0
- package/node_modules/@maka/runtime/dist/stream-graph-read-model.js +138 -20
- package/node_modules/@maka/runtime/dist/tool-availability.js +10 -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/candidate-entry.js +15 -0
- package/node_modules/@maka/runtime-host/dist/candidate-startup-failure.js +5 -0
- package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +1 -0
- package/node_modules/@maka/runtime-host/dist/client/startup-error.js +5 -0
- package/node_modules/@maka/runtime-host/dist/protocol/agent-graph.js +46 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +12 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-retirement.js +46 -10
- package/node_modules/@maka/runtime-host/dist/protocol/storage-usage.js +155 -0
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +20 -8
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +23 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +5 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +27 -6
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +2 -0
- 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-catalog-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +51 -16
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +112 -36
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +27 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-usage-coordinator.js +67 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-inspection-tool.js +208 -0
- package/node_modules/@maka/runtime-host/package.json +2 -2
- package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +3 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +0 -13
- package/node_modules/@maka/storage/dist/project-catalog.js +13 -20
- package/node_modules/@maka/storage/dist/session-store.js +9 -6
- package/node_modules/@maka/storage/dist/sqlite-file-set.js +22 -0
- package/node_modules/@maka/storage/dist/sqlite-long-term-memory-store.js +1 -3
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +10 -260
- package/node_modules/@maka/storage/dist/sqlite-session-catalog-query.js +1 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +18 -6
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +28 -6
- package/node_modules/@maka/storage/dist/storage-footprint.js +239 -0
- package/node_modules/@maka/storage/dist/storage-writer-composition.js +10 -1
- 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/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +297 -5
- package/node_modules/axios/dist/axios.js +728 -170
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/browser/axios.cjs +871 -188
- package/node_modules/axios/dist/esm/axios.js +871 -188
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/node/axios.cjs +1037 -225
- package/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/axios/lib/adapters/http.js +140 -67
- package/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/axios/lib/core/Axios.js +43 -20
- package/node_modules/axios/lib/core/AxiosError.js +33 -2
- package/node_modules/axios/lib/core/AxiosHeaders.js +124 -1
- package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/axios/lib/core/buildFullPath.js +41 -15
- package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/axios/lib/core/mergeConfig.js +19 -4
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +12 -1
- package/node_modules/axios/lib/helpers/combineURLs.js +11 -3
- package/node_modules/axios/lib/helpers/composeSignals.js +12 -1
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
- package/node_modules/axios/lib/helpers/formDataToJSON.js +11 -5
- package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +5 -3
- package/node_modules/axios/lib/helpers/progressEventReducer.js +4 -4
- package/node_modules/axios/lib/helpers/resolveConfig.js +5 -17
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +300 -5
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +17 -23
- package/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/axios/lib/utils.js +151 -18
- package/node_modules/axios/package.json +21 -19
- package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
- package/node_modules/brace-expansion/dist/esm/index.js +68 -24
- package/node_modules/brace-expansion/package.json +2 -1
- package/node_modules/fast-uri/index.js +10 -6
- package/node_modules/fast-uri/package.json +1 -1
- 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
|
@@ -17,23 +17,24 @@ import {
|
|
|
17
17
|
WORKFLOW_DESERIALIZE,
|
|
18
18
|
zodSchema as zodSchema3
|
|
19
19
|
} from "@ai-sdk/provider-utils";
|
|
20
|
-
import { z as
|
|
20
|
+
import { z as z4 } from "zod/v4";
|
|
21
21
|
|
|
22
22
|
// src/convert-google-usage.ts
|
|
23
23
|
import { createNullLanguageModelUsage } from "@ai-sdk/provider-utils";
|
|
24
24
|
function convertGoogleUsage(usage) {
|
|
25
|
-
var _a, _b, _c, _d;
|
|
26
25
|
if (usage == null) {
|
|
27
26
|
return createNullLanguageModelUsage();
|
|
28
27
|
}
|
|
29
|
-
const promptTokens =
|
|
30
|
-
const candidatesTokens =
|
|
31
|
-
const
|
|
32
|
-
const
|
|
28
|
+
const promptTokens = usage.promptTokenCount ?? 0;
|
|
29
|
+
const candidatesTokens = usage.candidatesTokenCount ?? 0;
|
|
30
|
+
const toolUsePromptTokens = usage.toolUsePromptTokenCount ?? 0;
|
|
31
|
+
const cachedContentTokens = usage.cachedContentTokenCount ?? 0;
|
|
32
|
+
const thoughtsTokens = usage.thoughtsTokenCount ?? 0;
|
|
33
|
+
const inputTokens = promptTokens + toolUsePromptTokens;
|
|
33
34
|
return {
|
|
34
35
|
inputTokens: {
|
|
35
|
-
total:
|
|
36
|
-
noCache:
|
|
36
|
+
total: inputTokens,
|
|
37
|
+
noCache: inputTokens - cachedContentTokens,
|
|
37
38
|
cacheRead: cachedContentTokens,
|
|
38
39
|
cacheWrite: void 0
|
|
39
40
|
},
|
|
@@ -46,298 +47,38 @@ function convertGoogleUsage(usage) {
|
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
// src/convert-json-schema-to-openapi-schema.ts
|
|
50
|
-
import {
|
|
51
|
-
UnsupportedFunctionalityError
|
|
52
|
-
} from "@ai-sdk/provider";
|
|
53
|
-
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
54
|
-
function isRecursiveJSONSchemaReferenceError(error) {
|
|
55
|
-
return UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
56
|
-
}
|
|
57
|
-
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
58
|
-
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
59
|
-
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
60
|
-
definitions: rootSchema == null ? void 0 : rootSchema.definitions,
|
|
61
|
-
dollarDefinitions: rootSchema == null ? void 0 : rootSchema.$defs,
|
|
62
|
-
resolvingReferences: /* @__PURE__ */ new Set()
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
66
|
-
if (jsonSchema == null) {
|
|
67
|
-
return void 0;
|
|
68
|
-
}
|
|
69
|
-
if (typeof jsonSchema === "boolean") {
|
|
70
|
-
return { type: "boolean", properties: {} };
|
|
71
|
-
}
|
|
72
|
-
if (jsonSchema.$ref != null) {
|
|
73
|
-
return convertJSONSchemaReference({
|
|
74
|
-
jsonSchema,
|
|
75
|
-
reference: jsonSchema.$ref,
|
|
76
|
-
isRoot,
|
|
77
|
-
referenceContext
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
if (isEmptyObjectSchema(jsonSchema)) {
|
|
81
|
-
if (isRoot) {
|
|
82
|
-
return void 0;
|
|
83
|
-
}
|
|
84
|
-
if (jsonSchema.description) {
|
|
85
|
-
return { type: "object", description: jsonSchema.description };
|
|
86
|
-
}
|
|
87
|
-
return { type: "object" };
|
|
88
|
-
}
|
|
89
|
-
const {
|
|
90
|
-
type,
|
|
91
|
-
description,
|
|
92
|
-
required,
|
|
93
|
-
properties,
|
|
94
|
-
items,
|
|
95
|
-
allOf,
|
|
96
|
-
anyOf,
|
|
97
|
-
oneOf,
|
|
98
|
-
format,
|
|
99
|
-
const: constValue,
|
|
100
|
-
minLength,
|
|
101
|
-
minItems,
|
|
102
|
-
maxItems,
|
|
103
|
-
enum: enumValues
|
|
104
|
-
} = jsonSchema;
|
|
105
|
-
const result = {};
|
|
106
|
-
if (description) result.description = description;
|
|
107
|
-
if (required) result.required = required;
|
|
108
|
-
if (format) result.format = format;
|
|
109
|
-
if (type) {
|
|
110
|
-
if (Array.isArray(type)) {
|
|
111
|
-
const hasNull = type.includes("null");
|
|
112
|
-
const nonNullTypes = type.filter((t) => t !== "null");
|
|
113
|
-
if (nonNullTypes.length === 0) {
|
|
114
|
-
result.type = "null";
|
|
115
|
-
} else {
|
|
116
|
-
result.anyOf = nonNullTypes.map((t) => ({ type: t }));
|
|
117
|
-
if (hasNull) {
|
|
118
|
-
result.nullable = true;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
result.type = type;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
|
|
126
|
-
if (values !== void 0) {
|
|
127
|
-
addEnumToSchema({ values, type, result });
|
|
128
|
-
}
|
|
129
|
-
if (properties != null) {
|
|
130
|
-
result.properties = Object.entries(properties).reduce(
|
|
131
|
-
(acc, [key, value]) => {
|
|
132
|
-
acc[key] = convertJSONSchemaDefinition(value, false, referenceContext);
|
|
133
|
-
return acc;
|
|
134
|
-
},
|
|
135
|
-
{}
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
if (items) {
|
|
139
|
-
result.items = Array.isArray(items) ? items.map(
|
|
140
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
141
|
-
) : convertJSONSchemaDefinition(items, false, referenceContext);
|
|
142
|
-
}
|
|
143
|
-
if (allOf) {
|
|
144
|
-
result.allOf = allOf.map(
|
|
145
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
if (anyOf) {
|
|
149
|
-
if (anyOf.some(
|
|
150
|
-
(schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"
|
|
151
|
-
)) {
|
|
152
|
-
const nonNullSchemas = anyOf.filter(
|
|
153
|
-
(schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
|
|
154
|
-
);
|
|
155
|
-
if (nonNullSchemas.length === 1) {
|
|
156
|
-
const converted = convertJSONSchemaDefinition(
|
|
157
|
-
nonNullSchemas[0],
|
|
158
|
-
false,
|
|
159
|
-
referenceContext
|
|
160
|
-
);
|
|
161
|
-
if (typeof converted === "object") {
|
|
162
|
-
result.nullable = true;
|
|
163
|
-
Object.assign(result, converted);
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
result.anyOf = nonNullSchemas.map(
|
|
167
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
168
|
-
);
|
|
169
|
-
result.nullable = true;
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
result.anyOf = anyOf.map(
|
|
173
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (oneOf) {
|
|
178
|
-
result.oneOf = oneOf.map(
|
|
179
|
-
(item) => convertJSONSchemaDefinition(item, false, referenceContext)
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
if (minLength !== void 0) {
|
|
183
|
-
result.minLength = minLength;
|
|
184
|
-
}
|
|
185
|
-
if (minItems !== void 0) {
|
|
186
|
-
result.minItems = minItems;
|
|
187
|
-
}
|
|
188
|
-
if (maxItems !== void 0) {
|
|
189
|
-
result.maxItems = maxItems;
|
|
190
|
-
}
|
|
191
|
-
return result;
|
|
192
|
-
}
|
|
193
|
-
function convertJSONSchemaReference({
|
|
194
|
-
jsonSchema,
|
|
195
|
-
reference,
|
|
196
|
-
isRoot,
|
|
197
|
-
referenceContext
|
|
198
|
-
}) {
|
|
199
|
-
const { definition, referenceKey } = getReferencedDefinition(
|
|
200
|
-
reference,
|
|
201
|
-
referenceContext
|
|
202
|
-
);
|
|
203
|
-
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
204
|
-
throw new UnsupportedFunctionalityError({
|
|
205
|
-
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
206
|
-
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
const resolvingReferences = new Set(referenceContext.resolvingReferences);
|
|
210
|
-
resolvingReferences.add(referenceKey);
|
|
211
|
-
const { $ref: _reference, ...siblingSchema } = jsonSchema;
|
|
212
|
-
const resolvedSchema = typeof definition === "boolean" ? definition ? siblingSchema : false : { ...definition, ...siblingSchema };
|
|
213
|
-
return convertJSONSchemaDefinition(resolvedSchema, isRoot, {
|
|
214
|
-
...referenceContext,
|
|
215
|
-
resolvingReferences
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
function getReferencedDefinition(reference, referenceContext) {
|
|
219
|
-
const definitionSources = [
|
|
220
|
-
{
|
|
221
|
-
prefix: "#/$defs/",
|
|
222
|
-
definitions: referenceContext.dollarDefinitions
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
prefix: "#/definitions/",
|
|
226
|
-
definitions: referenceContext.definitions
|
|
227
|
-
}
|
|
228
|
-
];
|
|
229
|
-
const source = definitionSources.find(
|
|
230
|
-
({ prefix }) => reference.startsWith(prefix)
|
|
231
|
-
);
|
|
232
|
-
const encodedDefinitionName = source ? reference.slice(source.prefix.length) : void 0;
|
|
233
|
-
if (source == null || encodedDefinitionName == null || encodedDefinitionName.length === 0 || encodedDefinitionName.includes("/")) {
|
|
234
|
-
throwUnsupportedReference(reference);
|
|
235
|
-
}
|
|
236
|
-
let decodedDefinitionName;
|
|
237
|
-
try {
|
|
238
|
-
decodedDefinitionName = decodeURIComponent(encodedDefinitionName);
|
|
239
|
-
} catch (e) {
|
|
240
|
-
throwUnsupportedReference(reference);
|
|
241
|
-
}
|
|
242
|
-
if (decodedDefinitionName.includes("/") || /~(?![01])/u.test(decodedDefinitionName) || source.definitions == null) {
|
|
243
|
-
throwUnsupportedReference(reference);
|
|
244
|
-
}
|
|
245
|
-
const definitionName = decodedDefinitionName.replace(
|
|
246
|
-
/~[01]/g,
|
|
247
|
-
(match) => match === "~1" ? "/" : "~"
|
|
248
|
-
);
|
|
249
|
-
if (!Object.prototype.hasOwnProperty.call(source.definitions, definitionName)) {
|
|
250
|
-
throwUnsupportedReference(reference);
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
definition: source.definitions[definitionName],
|
|
254
|
-
referenceKey: `${source.prefix}${definitionName}`
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
function throwUnsupportedReference(reference) {
|
|
258
|
-
throw new UnsupportedFunctionalityError({
|
|
259
|
-
functionality: `JSON Schema reference: ${reference}`,
|
|
260
|
-
message: "Google schema conversion only supports references to direct children of root-level $defs or definitions."
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
function addEnumToSchema({
|
|
264
|
-
values,
|
|
265
|
-
type,
|
|
266
|
-
result
|
|
267
|
-
}) {
|
|
268
|
-
const nullable = Array.isArray(type) && type.includes("null") || type === void 0 && values.includes(null);
|
|
269
|
-
const enumValues = nullable ? values.filter((value) => value !== null) : values;
|
|
270
|
-
if (values.length > 0 && values.every((value) => value === null)) {
|
|
271
|
-
const typeAllowsNull = type === void 0 || type === "null" || Array.isArray(type) && type.includes("null");
|
|
272
|
-
if (typeAllowsNull) {
|
|
273
|
-
result.type = "null";
|
|
274
|
-
if (Array.isArray(type)) {
|
|
275
|
-
delete result.anyOf;
|
|
276
|
-
}
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
const enumType = getEnumType({ values: enumValues, type });
|
|
281
|
-
if (enumType === void 0) {
|
|
282
|
-
throw new UnsupportedFunctionalityError({
|
|
283
|
-
functionality: "JSON Schema enum with mixed or unsupported values",
|
|
284
|
-
message: "Google does not support this JSON Schema enum. Enum values must share one supported primitive type and match the schema type."
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
result.type = enumType;
|
|
288
|
-
if (Array.isArray(type)) {
|
|
289
|
-
delete result.anyOf;
|
|
290
|
-
}
|
|
291
|
-
if (nullable) {
|
|
292
|
-
result.nullable = true;
|
|
293
|
-
}
|
|
294
|
-
if (enumType === "string") {
|
|
295
|
-
result.enum = enumValues;
|
|
296
|
-
} else {
|
|
297
|
-
result.format = "enum";
|
|
298
|
-
result.enum = enumValues.map(String);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function getEnumType({
|
|
302
|
-
values,
|
|
303
|
-
type
|
|
304
|
-
}) {
|
|
305
|
-
if (values.length === 0) {
|
|
306
|
-
return void 0;
|
|
307
|
-
}
|
|
308
|
-
const typeAllows = (enumType) => type === void 0 || type === enumType || Array.isArray(type) && type.includes(enumType);
|
|
309
|
-
if (typeAllows("string") && values.every((value) => typeof value === "string")) {
|
|
310
|
-
return "string";
|
|
311
|
-
}
|
|
312
|
-
if ((typeAllows("number") || typeAllows("integer")) && values.every((value) => typeof value === "number" && Number.isFinite(value))) {
|
|
313
|
-
if (typeAllows("number")) {
|
|
314
|
-
return "number";
|
|
315
|
-
}
|
|
316
|
-
if (values.every((value) => Number.isInteger(value))) {
|
|
317
|
-
return "integer";
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (typeAllows("boolean") && values.every((value) => typeof value === "boolean")) {
|
|
321
|
-
return "boolean";
|
|
322
|
-
}
|
|
323
|
-
return void 0;
|
|
324
|
-
}
|
|
325
|
-
function isEmptyObjectSchema(jsonSchema) {
|
|
326
|
-
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
50
|
// src/convert-to-google-messages.ts
|
|
330
51
|
import {
|
|
331
|
-
UnsupportedFunctionalityError
|
|
52
|
+
UnsupportedFunctionalityError
|
|
332
53
|
} from "@ai-sdk/provider";
|
|
333
54
|
import {
|
|
334
55
|
convertToBase64,
|
|
335
56
|
getTopLevelMediaType,
|
|
336
57
|
isFullMediaType,
|
|
58
|
+
isUrlSupported,
|
|
337
59
|
resolveFullMediaType,
|
|
338
60
|
resolveProviderReference,
|
|
339
61
|
secureJsonParse
|
|
340
62
|
} from "@ai-sdk/provider-utils";
|
|
63
|
+
|
|
64
|
+
// src/tool/code-execution.ts
|
|
65
|
+
import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
|
|
66
|
+
import { z } from "zod/v4";
|
|
67
|
+
var codeExecutionInputSchema = z.object({
|
|
68
|
+
language: z.string().describe("The programming language of the code."),
|
|
69
|
+
code: z.string().describe("The code to be executed.")
|
|
70
|
+
});
|
|
71
|
+
var codeExecutionOutputSchema = z.object({
|
|
72
|
+
outcome: z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
73
|
+
output: z.string().describe("The output from the code execution.")
|
|
74
|
+
});
|
|
75
|
+
var codeExecution = createProviderExecutedToolFactory({
|
|
76
|
+
id: "google.code_execution",
|
|
77
|
+
inputSchema: codeExecutionInputSchema,
|
|
78
|
+
outputSchema: codeExecutionOutputSchema
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// src/convert-to-google-messages.ts
|
|
341
82
|
var SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
|
|
342
83
|
var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
|
|
343
84
|
function parseBase64DataUrl(value) {
|
|
@@ -362,7 +103,21 @@ function convertUrlToolResultPart(url) {
|
|
|
362
103
|
}
|
|
363
104
|
};
|
|
364
105
|
}
|
|
365
|
-
function
|
|
106
|
+
function containsJSONSchemaReference(value) {
|
|
107
|
+
if (Array.isArray(value)) {
|
|
108
|
+
return value.some(containsJSONSchemaReference);
|
|
109
|
+
}
|
|
110
|
+
if (typeof value !== "object" || value === null) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return Object.entries(value).some(
|
|
114
|
+
([key, nestedValue]) => key === "$ref" || containsJSONSchemaReference(nestedValue)
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function serializeFunctionResponseContent(value) {
|
|
118
|
+
return containsJSONSchemaReference(value) ? JSON.stringify(value) : value;
|
|
119
|
+
}
|
|
120
|
+
function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true, supportedUrls = {}) {
|
|
366
121
|
const functionResponseParts = [];
|
|
367
122
|
const responseTextParts = [];
|
|
368
123
|
for (const contentPart of outputValue) {
|
|
@@ -380,11 +135,22 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId, include
|
|
|
380
135
|
}
|
|
381
136
|
});
|
|
382
137
|
} else if (contentPart.data.type === "url") {
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (
|
|
387
|
-
functionResponseParts.push(
|
|
138
|
+
const url = contentPart.data.url.toString();
|
|
139
|
+
const convertedUrlPart = convertUrlToolResultPart(url);
|
|
140
|
+
const supportedUrl = contentPart.data.url.protocol === "gs:" && contentPart.data.originalUrl != null ? contentPart.data.originalUrl : url;
|
|
141
|
+
if (convertedUrlPart != null) {
|
|
142
|
+
functionResponseParts.push(convertedUrlPart);
|
|
143
|
+
} else if (isFullMediaType(contentPart.mediaType) && isUrlSupported({
|
|
144
|
+
url: supportedUrl,
|
|
145
|
+
mediaType: contentPart.mediaType,
|
|
146
|
+
supportedUrls
|
|
147
|
+
})) {
|
|
148
|
+
functionResponseParts.push({
|
|
149
|
+
fileData: {
|
|
150
|
+
mimeType: contentPart.mediaType,
|
|
151
|
+
fileUri: supportedUrl
|
|
152
|
+
}
|
|
153
|
+
});
|
|
388
154
|
} else {
|
|
389
155
|
responseTextParts.push(JSON.stringify(contentPart));
|
|
390
156
|
}
|
|
@@ -452,17 +218,17 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, i
|
|
|
452
218
|
}
|
|
453
219
|
}
|
|
454
220
|
function convertToGoogleMessages(prompt, options) {
|
|
455
|
-
var _a, _b, _c, _d, _e, _f;
|
|
456
221
|
const systemInstructionParts = [];
|
|
457
222
|
const contents = [];
|
|
458
223
|
let systemMessagesAllowed = true;
|
|
459
|
-
const isGemmaModel =
|
|
460
|
-
const isGemini3Model =
|
|
461
|
-
const onWarning = options
|
|
462
|
-
const providerOptionsNames =
|
|
224
|
+
const isGemmaModel = options?.isGemmaModel ?? false;
|
|
225
|
+
const isGemini3Model = options?.isGemini3Model ?? false;
|
|
226
|
+
const onWarning = options?.onWarning;
|
|
227
|
+
const providerOptionsNames = options?.providerOptionsNames ?? ["google"];
|
|
463
228
|
const isVertexLike = !providerOptionsNames.includes("google");
|
|
464
|
-
const supportsFunctionResponseParts =
|
|
465
|
-
const includeFunctionCallIds =
|
|
229
|
+
const supportsFunctionResponseParts = options?.supportsFunctionResponseParts ?? true;
|
|
230
|
+
const includeFunctionCallIds = options?.includeFunctionCallIds ?? true;
|
|
231
|
+
const supportedFunctionResponseUrls = options?.supportedFunctionResponseUrls ?? {};
|
|
466
232
|
let sentinelInjected = false;
|
|
467
233
|
const missingSignatureToolNames = [];
|
|
468
234
|
const injectSkipSignature = (toolName) => {
|
|
@@ -471,21 +237,20 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
471
237
|
return SKIP_THOUGHT_SIGNATURE_VALIDATOR;
|
|
472
238
|
};
|
|
473
239
|
const readProviderOpts = (part) => {
|
|
474
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
475
240
|
for (const name of providerOptionsNames) {
|
|
476
|
-
const v =
|
|
241
|
+
const v = part.providerOptions?.[name];
|
|
477
242
|
if (v != null) return v;
|
|
478
243
|
}
|
|
479
244
|
if (isVertexLike) {
|
|
480
|
-
return
|
|
245
|
+
return part.providerOptions?.google;
|
|
481
246
|
}
|
|
482
|
-
return
|
|
247
|
+
return part.providerOptions?.googleVertex ?? part.providerOptions?.vertex;
|
|
483
248
|
};
|
|
484
249
|
for (const { role, content } of prompt) {
|
|
485
250
|
switch (role) {
|
|
486
251
|
case "system": {
|
|
487
252
|
if (!systemMessagesAllowed) {
|
|
488
|
-
throw new
|
|
253
|
+
throw new UnsupportedFunctionalityError({
|
|
489
254
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
490
255
|
});
|
|
491
256
|
}
|
|
@@ -507,14 +272,14 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
507
272
|
parts.push({
|
|
508
273
|
fileData: {
|
|
509
274
|
mimeType: resolveFullMediaType({ part }),
|
|
510
|
-
fileUri: part.data.url.toString()
|
|
275
|
+
fileUri: part.data.url.protocol === "gs:" && part.data.originalUrl != null ? part.data.originalUrl : part.data.url.toString()
|
|
511
276
|
}
|
|
512
277
|
});
|
|
513
278
|
break;
|
|
514
279
|
}
|
|
515
280
|
case "reference": {
|
|
516
281
|
if (isVertexLike) {
|
|
517
|
-
throw new
|
|
282
|
+
throw new UnsupportedFunctionalityError({
|
|
518
283
|
functionality: "file parts with provider references"
|
|
519
284
|
});
|
|
520
285
|
}
|
|
@@ -564,7 +329,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
564
329
|
role: "model",
|
|
565
330
|
parts: content.map((part) => {
|
|
566
331
|
const providerOpts = readProviderOpts(part);
|
|
567
|
-
const thoughtSignature =
|
|
332
|
+
const thoughtSignature = providerOpts?.thoughtSignature != null ? String(providerOpts.thoughtSignature) : void 0;
|
|
568
333
|
switch (part.type) {
|
|
569
334
|
case "text": {
|
|
570
335
|
return part.text.length === 0 ? void 0 : {
|
|
@@ -582,7 +347,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
582
347
|
case "reasoning-file": {
|
|
583
348
|
switch (part.data.type) {
|
|
584
349
|
case "url": {
|
|
585
|
-
throw new
|
|
350
|
+
throw new UnsupportedFunctionalityError({
|
|
586
351
|
functionality: "File data URLs in assistant messages are not supported"
|
|
587
352
|
});
|
|
588
353
|
}
|
|
@@ -602,13 +367,13 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
602
367
|
case "file": {
|
|
603
368
|
switch (part.data.type) {
|
|
604
369
|
case "url": {
|
|
605
|
-
throw new
|
|
370
|
+
throw new UnsupportedFunctionalityError({
|
|
606
371
|
functionality: "File data URLs in assistant messages are not supported"
|
|
607
372
|
});
|
|
608
373
|
}
|
|
609
374
|
case "reference": {
|
|
610
375
|
if (isVertexLike) {
|
|
611
|
-
throw new
|
|
376
|
+
throw new UnsupportedFunctionalityError({
|
|
612
377
|
functionality: "file parts with provider references"
|
|
613
378
|
});
|
|
614
379
|
}
|
|
@@ -620,7 +385,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
620
385
|
provider: "google"
|
|
621
386
|
})
|
|
622
387
|
},
|
|
623
|
-
...
|
|
388
|
+
...providerOpts?.thought === true ? { thought: true } : {},
|
|
624
389
|
thoughtSignature
|
|
625
390
|
};
|
|
626
391
|
}
|
|
@@ -632,7 +397,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
632
397
|
new TextEncoder().encode(part.data.text)
|
|
633
398
|
)
|
|
634
399
|
},
|
|
635
|
-
...
|
|
400
|
+
...providerOpts?.thought === true ? { thought: true } : {},
|
|
636
401
|
thoughtSignature
|
|
637
402
|
};
|
|
638
403
|
}
|
|
@@ -642,7 +407,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
642
407
|
mimeType: part.mediaType,
|
|
643
408
|
data: convertToBase64(part.data.data)
|
|
644
409
|
},
|
|
645
|
-
...
|
|
410
|
+
...providerOpts?.thought === true ? { thought: true } : {},
|
|
646
411
|
thoughtSignature
|
|
647
412
|
};
|
|
648
413
|
}
|
|
@@ -650,8 +415,15 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
650
415
|
break;
|
|
651
416
|
}
|
|
652
417
|
case "tool-call": {
|
|
653
|
-
|
|
654
|
-
|
|
418
|
+
if (part.providerExecuted === true && part.toolName === "code_execution") {
|
|
419
|
+
return {
|
|
420
|
+
executableCode: codeExecutionInputSchema.parse(
|
|
421
|
+
typeof part.input === "string" ? secureJsonParse(part.input) : part.input
|
|
422
|
+
)
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
const serverToolCallId = providerOpts?.serverToolCallId != null ? String(providerOpts.serverToolCallId) : void 0;
|
|
426
|
+
const serverToolType = providerOpts?.serverToolType != null ? String(providerOpts.serverToolType) : void 0;
|
|
655
427
|
const isServerToolCall = serverToolCallId != null && serverToolType != null;
|
|
656
428
|
const shouldSkipMissingSignatureMitigation = (
|
|
657
429
|
// Gemini 3 returns a single signature for a parallel
|
|
@@ -660,7 +432,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
660
432
|
// model response legitimately have no signature.
|
|
661
433
|
!isServerToolCall && thoughtSignature == null && modelResponseHasSignedFunctionCall
|
|
662
434
|
);
|
|
663
|
-
const effectiveThoughtSignature = thoughtSignature
|
|
435
|
+
const effectiveThoughtSignature = thoughtSignature ?? (isGemini3Model && !shouldSkipMissingSignatureMitigation ? injectSkipSignature(part.toolName) : void 0);
|
|
664
436
|
if (!isServerToolCall && thoughtSignature != null) {
|
|
665
437
|
modelResponseHasSignedFunctionCall = true;
|
|
666
438
|
}
|
|
@@ -684,8 +456,15 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
684
456
|
};
|
|
685
457
|
}
|
|
686
458
|
case "tool-result": {
|
|
687
|
-
|
|
688
|
-
|
|
459
|
+
if (part.toolName === "code_execution" && part.output.type === "json") {
|
|
460
|
+
return {
|
|
461
|
+
codeExecutionResult: codeExecutionOutputSchema.parse(
|
|
462
|
+
part.output.value
|
|
463
|
+
)
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
const serverToolCallId = providerOpts?.serverToolCallId != null ? String(providerOpts.serverToolCallId) : void 0;
|
|
467
|
+
const serverToolType = providerOpts?.serverToolType != null ? String(providerOpts.serverToolType) : void 0;
|
|
689
468
|
if (serverToolCallId && serverToolType) {
|
|
690
469
|
return {
|
|
691
470
|
toolResponse: {
|
|
@@ -711,10 +490,10 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
711
490
|
continue;
|
|
712
491
|
}
|
|
713
492
|
const partProviderOpts = readProviderOpts(part);
|
|
714
|
-
const serverToolCallId =
|
|
715
|
-
const serverToolType =
|
|
493
|
+
const serverToolCallId = partProviderOpts?.serverToolCallId != null ? String(partProviderOpts.serverToolCallId) : void 0;
|
|
494
|
+
const serverToolType = partProviderOpts?.serverToolType != null ? String(partProviderOpts.serverToolType) : void 0;
|
|
716
495
|
if (serverToolCallId && serverToolType) {
|
|
717
|
-
const serverThoughtSignature =
|
|
496
|
+
const serverThoughtSignature = partProviderOpts?.thoughtSignature != null ? String(partProviderOpts.thoughtSignature) : void 0;
|
|
718
497
|
if (contents.length > 0) {
|
|
719
498
|
const lastContent = contents[contents.length - 1];
|
|
720
499
|
if (lastContent.role === "model") {
|
|
@@ -738,7 +517,8 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
738
517
|
part.toolName,
|
|
739
518
|
output.value,
|
|
740
519
|
part.toolCallId,
|
|
741
|
-
includeFunctionCallIds
|
|
520
|
+
includeFunctionCallIds,
|
|
521
|
+
supportedFunctionResponseUrls
|
|
742
522
|
);
|
|
743
523
|
} else {
|
|
744
524
|
appendLegacyToolResultParts(
|
|
@@ -756,7 +536,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
756
536
|
name: part.toolName,
|
|
757
537
|
response: {
|
|
758
538
|
name: part.toolName,
|
|
759
|
-
content: output.type === "execution-denied" ?
|
|
539
|
+
content: output.type === "execution-denied" ? output.reason ?? "Tool call execution denied." : serializeFunctionResponseContent(output.value)
|
|
760
540
|
}
|
|
761
541
|
}
|
|
762
542
|
});
|
|
@@ -791,11 +571,13 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
791
571
|
import {
|
|
792
572
|
detectMediaType,
|
|
793
573
|
downloadBlob,
|
|
794
|
-
isFullMediaType as isFullMediaType2
|
|
574
|
+
isFullMediaType as isFullMediaType2,
|
|
575
|
+
isUrlSupported as isUrlSupported2
|
|
795
576
|
} from "@ai-sdk/provider-utils";
|
|
796
577
|
async function downloadToolResultFiles(prompt, {
|
|
797
578
|
abortSignal,
|
|
798
|
-
maxBytes
|
|
579
|
+
maxBytes,
|
|
580
|
+
supportedUrls = {}
|
|
799
581
|
}) {
|
|
800
582
|
const result = [];
|
|
801
583
|
for (const message of prompt) {
|
|
@@ -807,7 +589,8 @@ async function downloadToolResultFiles(prompt, {
|
|
|
807
589
|
...part,
|
|
808
590
|
output: await downloadToolResultOutput(part.output, {
|
|
809
591
|
abortSignal,
|
|
810
|
-
maxBytes
|
|
592
|
+
maxBytes,
|
|
593
|
+
supportedUrls
|
|
811
594
|
})
|
|
812
595
|
} : part
|
|
813
596
|
);
|
|
@@ -826,7 +609,8 @@ async function downloadToolResultFiles(prompt, {
|
|
|
826
609
|
...part,
|
|
827
610
|
output: await downloadToolResultOutput(part.output, {
|
|
828
611
|
abortSignal,
|
|
829
|
-
maxBytes
|
|
612
|
+
maxBytes,
|
|
613
|
+
supportedUrls
|
|
830
614
|
})
|
|
831
615
|
});
|
|
832
616
|
}
|
|
@@ -839,7 +623,8 @@ async function downloadToolResultFiles(prompt, {
|
|
|
839
623
|
}
|
|
840
624
|
async function downloadToolResultOutput(output, {
|
|
841
625
|
abortSignal,
|
|
842
|
-
maxBytes
|
|
626
|
+
maxBytes,
|
|
627
|
+
supportedUrls
|
|
843
628
|
}) {
|
|
844
629
|
if (output.type !== "content") {
|
|
845
630
|
return output;
|
|
@@ -850,6 +635,14 @@ async function downloadToolResultOutput(output, {
|
|
|
850
635
|
value.push(part);
|
|
851
636
|
continue;
|
|
852
637
|
}
|
|
638
|
+
if (isUrlSupported2({
|
|
639
|
+
url: part.data.url.toString(),
|
|
640
|
+
mediaType: part.mediaType,
|
|
641
|
+
supportedUrls
|
|
642
|
+
})) {
|
|
643
|
+
value.push(part);
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
853
646
|
const blob = await downloadBlob(part.data.url.toString(), {
|
|
854
647
|
abortSignal,
|
|
855
648
|
maxBytes
|
|
@@ -862,7 +655,7 @@ async function downloadToolResultOutput(output, {
|
|
|
862
655
|
value.push({
|
|
863
656
|
...part,
|
|
864
657
|
data: { type: "data", data },
|
|
865
|
-
mediaType: detectedMediaType
|
|
658
|
+
mediaType: detectedMediaType ?? (blob.type && !isFullMediaType2(part.mediaType) ? blob.type : part.mediaType)
|
|
866
659
|
});
|
|
867
660
|
}
|
|
868
661
|
return {
|
|
@@ -882,15 +675,15 @@ import {
|
|
|
882
675
|
lazySchema,
|
|
883
676
|
zodSchema
|
|
884
677
|
} from "@ai-sdk/provider-utils";
|
|
885
|
-
import { z } from "zod/v4";
|
|
678
|
+
import { z as z2 } from "zod/v4";
|
|
886
679
|
var googleErrorDataSchema = lazySchema(
|
|
887
680
|
() => zodSchema(
|
|
888
|
-
|
|
889
|
-
error:
|
|
890
|
-
code:
|
|
891
|
-
message:
|
|
892
|
-
status:
|
|
893
|
-
details:
|
|
681
|
+
z2.object({
|
|
682
|
+
error: z2.object({
|
|
683
|
+
code: z2.number().nullable(),
|
|
684
|
+
message: z2.string(),
|
|
685
|
+
status: z2.string(),
|
|
686
|
+
details: z2.array(z2.unknown()).nullish()
|
|
894
687
|
})
|
|
895
688
|
})
|
|
896
689
|
)
|
|
@@ -900,28 +693,66 @@ var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
900
693
|
errorToMessage: (data) => data.error.message
|
|
901
694
|
});
|
|
902
695
|
|
|
696
|
+
// src/sanitize-response-json-schema.ts
|
|
697
|
+
function sanitizeResponseJsonSchema(schema) {
|
|
698
|
+
const {
|
|
699
|
+
const: constValue,
|
|
700
|
+
properties,
|
|
701
|
+
items,
|
|
702
|
+
additionalProperties,
|
|
703
|
+
anyOf,
|
|
704
|
+
oneOf,
|
|
705
|
+
...result
|
|
706
|
+
} = schema;
|
|
707
|
+
return {
|
|
708
|
+
...result,
|
|
709
|
+
...constValue !== void 0 ? { enum: [constValue] } : {},
|
|
710
|
+
...properties != null ? { properties: sanitizeDefinitions(properties) } : {},
|
|
711
|
+
...items != null ? {
|
|
712
|
+
items: Array.isArray(items) ? items.map(sanitizeDefinition) : sanitizeDefinition(items)
|
|
713
|
+
} : {},
|
|
714
|
+
...additionalProperties != null ? {
|
|
715
|
+
additionalProperties: typeof additionalProperties === "boolean" ? additionalProperties : sanitizeDefinition(additionalProperties)
|
|
716
|
+
} : {},
|
|
717
|
+
...anyOf != null ? { anyOf: anyOf.map(sanitizeDefinition) } : {},
|
|
718
|
+
...oneOf != null ? { oneOf: oneOf.map(sanitizeDefinition) } : {},
|
|
719
|
+
...result.$defs != null ? { $defs: sanitizeDefinitions(result.$defs) } : {}
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function sanitizeDefinitions(definitions) {
|
|
723
|
+
return Object.fromEntries(
|
|
724
|
+
Object.entries(definitions).map(([name, definition]) => [
|
|
725
|
+
name,
|
|
726
|
+
sanitizeDefinition(definition)
|
|
727
|
+
])
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
function sanitizeDefinition(definition) {
|
|
731
|
+
return typeof definition === "boolean" ? definition : sanitizeResponseJsonSchema(definition);
|
|
732
|
+
}
|
|
733
|
+
|
|
903
734
|
// src/google-language-model-options.ts
|
|
904
735
|
import {
|
|
905
736
|
lazySchema as lazySchema2,
|
|
906
737
|
zodSchema as zodSchema2
|
|
907
738
|
} from "@ai-sdk/provider-utils";
|
|
908
|
-
import { z as
|
|
739
|
+
import { z as z3 } from "zod/v4";
|
|
909
740
|
var googleLanguageModelOptions = lazySchema2(
|
|
910
741
|
() => zodSchema2(
|
|
911
|
-
|
|
912
|
-
responseModalities:
|
|
913
|
-
thinkingConfig:
|
|
914
|
-
thinkingBudget:
|
|
915
|
-
includeThoughts:
|
|
742
|
+
z3.object({
|
|
743
|
+
responseModalities: z3.array(z3.enum(["TEXT", "IMAGE"])).optional(),
|
|
744
|
+
thinkingConfig: z3.object({
|
|
745
|
+
thinkingBudget: z3.number().optional(),
|
|
746
|
+
includeThoughts: z3.boolean().optional(),
|
|
916
747
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
917
|
-
thinkingLevel:
|
|
748
|
+
thinkingLevel: z3.enum(["minimal", "low", "medium", "high"]).optional()
|
|
918
749
|
}).optional(),
|
|
919
750
|
/**
|
|
920
751
|
* Optional.
|
|
921
752
|
* The name of the cached content used as context to serve the prediction.
|
|
922
753
|
* Format: cachedContents/{cachedContent}
|
|
923
754
|
*/
|
|
924
|
-
cachedContent:
|
|
755
|
+
cachedContent: z3.string().optional(),
|
|
925
756
|
/**
|
|
926
757
|
* Optional. Enable structured output. Default is true.
|
|
927
758
|
*
|
|
@@ -930,13 +761,13 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
930
761
|
* Google uses. You can use this to disable
|
|
931
762
|
* structured outputs if you need to.
|
|
932
763
|
*/
|
|
933
|
-
structuredOutputs:
|
|
764
|
+
structuredOutputs: z3.boolean().optional(),
|
|
934
765
|
/**
|
|
935
766
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
936
767
|
*/
|
|
937
|
-
safetySettings:
|
|
938
|
-
|
|
939
|
-
category:
|
|
768
|
+
safetySettings: z3.array(
|
|
769
|
+
z3.object({
|
|
770
|
+
category: z3.enum([
|
|
940
771
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
941
772
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
942
773
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -944,7 +775,7 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
944
775
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
945
776
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
946
777
|
]),
|
|
947
|
-
threshold:
|
|
778
|
+
threshold: z3.enum([
|
|
948
779
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
949
780
|
"BLOCK_LOW_AND_ABOVE",
|
|
950
781
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -954,7 +785,7 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
954
785
|
])
|
|
955
786
|
})
|
|
956
787
|
).optional(),
|
|
957
|
-
threshold:
|
|
788
|
+
threshold: z3.enum([
|
|
958
789
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
959
790
|
"BLOCK_LOW_AND_ABOVE",
|
|
960
791
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -967,19 +798,19 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
967
798
|
*
|
|
968
799
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
969
800
|
*/
|
|
970
|
-
audioTimestamp:
|
|
801
|
+
audioTimestamp: z3.boolean().optional(),
|
|
971
802
|
/**
|
|
972
803
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
973
804
|
*
|
|
974
805
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
975
806
|
*/
|
|
976
|
-
labels:
|
|
807
|
+
labels: z3.record(z3.string(), z3.string()).optional(),
|
|
977
808
|
/**
|
|
978
809
|
* Optional. If specified, the media resolution specified will be used.
|
|
979
810
|
*
|
|
980
811
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
981
812
|
*/
|
|
982
|
-
mediaResolution:
|
|
813
|
+
mediaResolution: z3.enum([
|
|
983
814
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
984
815
|
"MEDIA_RESOLUTION_LOW",
|
|
985
816
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -990,8 +821,8 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
990
821
|
*
|
|
991
822
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
992
823
|
*/
|
|
993
|
-
imageConfig:
|
|
994
|
-
aspectRatio:
|
|
824
|
+
imageConfig: z3.object({
|
|
825
|
+
aspectRatio: z3.enum([
|
|
995
826
|
"1:1",
|
|
996
827
|
"2:3",
|
|
997
828
|
"3:2",
|
|
@@ -1007,12 +838,12 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
1007
838
|
"1:4",
|
|
1008
839
|
"4:1"
|
|
1009
840
|
]).optional(),
|
|
1010
|
-
imageSize:
|
|
841
|
+
imageSize: z3.enum(["1K", "2K", "4K", "512"]).optional(),
|
|
1011
842
|
/**
|
|
1012
843
|
* Optional. Controls the generation of people in images.
|
|
1013
844
|
* Vertex AI only.
|
|
1014
845
|
*/
|
|
1015
|
-
personGeneration:
|
|
846
|
+
personGeneration: z3.enum([
|
|
1016
847
|
"PERSON_GENERATION_UNSPECIFIED",
|
|
1017
848
|
"ALLOW_ALL",
|
|
1018
849
|
"ALLOW_ADULT",
|
|
@@ -1026,7 +857,7 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
1026
857
|
*
|
|
1027
858
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
|
|
1028
859
|
*/
|
|
1029
|
-
prominentPeople:
|
|
860
|
+
prominentPeople: z3.enum([
|
|
1030
861
|
"PROMINENT_PEOPLE_UNSPECIFIED",
|
|
1031
862
|
"ALLOW_PROMINENT_PEOPLE",
|
|
1032
863
|
"BLOCK_PROMINENT_PEOPLE"
|
|
@@ -1035,9 +866,9 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
1035
866
|
* Optional. The image output format for generated images.
|
|
1036
867
|
* Vertex AI only.
|
|
1037
868
|
*/
|
|
1038
|
-
imageOutputOptions:
|
|
1039
|
-
mimeType:
|
|
1040
|
-
compressionQuality:
|
|
869
|
+
imageOutputOptions: z3.object({
|
|
870
|
+
mimeType: z3.enum(["image/jpeg", "image/png"]).optional(),
|
|
871
|
+
compressionQuality: z3.number().optional()
|
|
1041
872
|
}).optional()
|
|
1042
873
|
}).optional(),
|
|
1043
874
|
/**
|
|
@@ -1046,10 +877,10 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
1046
877
|
*
|
|
1047
878
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1048
879
|
*/
|
|
1049
|
-
retrievalConfig:
|
|
1050
|
-
latLng:
|
|
1051
|
-
latitude:
|
|
1052
|
-
longitude:
|
|
880
|
+
retrievalConfig: z3.object({
|
|
881
|
+
latLng: z3.object({
|
|
882
|
+
latitude: z3.number(),
|
|
883
|
+
longitude: z3.number()
|
|
1053
884
|
}).optional()
|
|
1054
885
|
}).optional(),
|
|
1055
886
|
/**
|
|
@@ -1062,12 +893,12 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
1062
893
|
*
|
|
1063
894
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
1064
895
|
*/
|
|
1065
|
-
streamFunctionCallArguments:
|
|
896
|
+
streamFunctionCallArguments: z3.boolean().optional(),
|
|
1066
897
|
/**
|
|
1067
898
|
* Optional. The service tier to use for the request. Sent as the
|
|
1068
899
|
* `serviceTier` body field. Gemini API only.
|
|
1069
900
|
*/
|
|
1070
|
-
serviceTier:
|
|
901
|
+
serviceTier: z3.enum(["standard", "flex", "priority"]).optional(),
|
|
1071
902
|
/**
|
|
1072
903
|
* Optional. Vertex AI only. Sent as the
|
|
1073
904
|
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
@@ -1078,7 +909,7 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
1078
909
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1079
910
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
1080
911
|
*/
|
|
1081
|
-
sharedRequestType:
|
|
912
|
+
sharedRequestType: z3.enum(["priority", "flex", "standard"]).optional(),
|
|
1082
913
|
/**
|
|
1083
914
|
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
1084
915
|
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
@@ -1086,7 +917,7 @@ var googleLanguageModelOptions = lazySchema2(
|
|
|
1086
917
|
*
|
|
1087
918
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1088
919
|
*/
|
|
1089
|
-
requestType:
|
|
920
|
+
requestType: z3.enum(["shared"]).optional()
|
|
1090
921
|
})
|
|
1091
922
|
)
|
|
1092
923
|
);
|
|
@@ -1114,7 +945,7 @@ function getGoogleModelCapabilities(modelId) {
|
|
|
1114
945
|
|
|
1115
946
|
// src/google-prepare-tools.ts
|
|
1116
947
|
import {
|
|
1117
|
-
UnsupportedFunctionalityError as
|
|
948
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1118
949
|
} from "@ai-sdk/provider";
|
|
1119
950
|
function prepareTools({
|
|
1120
951
|
tools,
|
|
@@ -1122,7 +953,7 @@ function prepareTools({
|
|
|
1122
953
|
modelId,
|
|
1123
954
|
isVertexProvider = false
|
|
1124
955
|
}) {
|
|
1125
|
-
tools =
|
|
956
|
+
tools = tools?.length ? tools : void 0;
|
|
1126
957
|
const toolWarnings = [];
|
|
1127
958
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
1128
959
|
if (tools == null) {
|
|
@@ -1344,32 +1175,18 @@ function prepareTools({
|
|
|
1344
1175
|
};
|
|
1345
1176
|
default: {
|
|
1346
1177
|
const _exhaustiveCheck = type;
|
|
1347
|
-
throw new
|
|
1178
|
+
throw new UnsupportedFunctionalityError2({
|
|
1348
1179
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1349
1180
|
});
|
|
1350
1181
|
}
|
|
1351
1182
|
}
|
|
1352
1183
|
}
|
|
1353
1184
|
function prepareFunctionDeclaration(tool) {
|
|
1354
|
-
|
|
1355
|
-
const declaration = {
|
|
1185
|
+
return {
|
|
1356
1186
|
name: tool.name,
|
|
1357
|
-
description:
|
|
1187
|
+
description: tool.description ?? "",
|
|
1188
|
+
parametersJsonSchema: tool.inputSchema
|
|
1358
1189
|
};
|
|
1359
|
-
try {
|
|
1360
|
-
return {
|
|
1361
|
-
...declaration,
|
|
1362
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1363
|
-
};
|
|
1364
|
-
} catch (error) {
|
|
1365
|
-
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1366
|
-
throw error;
|
|
1367
|
-
}
|
|
1368
|
-
return {
|
|
1369
|
-
...declaration,
|
|
1370
|
-
parametersJsonSchema: tool.inputSchema
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
1190
|
}
|
|
1374
1191
|
|
|
1375
1192
|
// src/google-json-accumulator.ts
|
|
@@ -1606,11 +1423,9 @@ function setNestedValue(obj, segments, value) {
|
|
|
1606
1423
|
defineOwnProperty(current, segments[segments.length - 1], value);
|
|
1607
1424
|
}
|
|
1608
1425
|
function resolvePartialArgValue(arg) {
|
|
1609
|
-
|
|
1610
|
-
const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
|
|
1426
|
+
const value = arg.stringValue ?? arg.numberValue ?? arg.boolValue;
|
|
1611
1427
|
if (value != null) return { value, json: JSON.stringify(value) };
|
|
1612
1428
|
if ("nullValue" in arg) return { value: null, json: "null" };
|
|
1613
|
-
return void 0;
|
|
1614
1429
|
}
|
|
1615
1430
|
|
|
1616
1431
|
// src/map-google-finish-reason.ts
|
|
@@ -1647,13 +1462,19 @@ var configurableSafetySettingCategories = [
|
|
|
1647
1462
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1648
1463
|
];
|
|
1649
1464
|
var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
1465
|
+
var googleCloudStorageFunctionResponseUrls = {
|
|
1466
|
+
"image/png": [/^gs:\/\/.*$/],
|
|
1467
|
+
"image/jpeg": [/^gs:\/\/.*$/],
|
|
1468
|
+
"image/webp": [/^gs:\/\/.*$/],
|
|
1469
|
+
"application/pdf": [/^gs:\/\/.*$/],
|
|
1470
|
+
"text/plain": [/^gs:\/\/.*$/]
|
|
1471
|
+
};
|
|
1650
1472
|
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
1651
1473
|
constructor(modelId, config) {
|
|
1652
1474
|
this.specificationVersion = "v4";
|
|
1653
|
-
var _a;
|
|
1654
1475
|
this.modelId = modelId;
|
|
1655
1476
|
this.config = config;
|
|
1656
|
-
this.generateId =
|
|
1477
|
+
this.generateId = config.generateId ?? generateId;
|
|
1657
1478
|
}
|
|
1658
1479
|
static [WORKFLOW_SERIALIZE](model) {
|
|
1659
1480
|
return serializeModelOptions({
|
|
@@ -1668,8 +1489,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1668
1489
|
return this.config.provider;
|
|
1669
1490
|
}
|
|
1670
1491
|
get supportedUrls() {
|
|
1671
|
-
|
|
1672
|
-
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
1492
|
+
return this.config.supportedUrls?.() ?? {};
|
|
1673
1493
|
}
|
|
1674
1494
|
static async prepareRequest({
|
|
1675
1495
|
modelId,
|
|
@@ -1693,7 +1513,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1693
1513
|
},
|
|
1694
1514
|
isStreaming = false
|
|
1695
1515
|
}) {
|
|
1696
|
-
var _a, _b, _c;
|
|
1697
1516
|
const warnings = [];
|
|
1698
1517
|
const providerOptionsNames = config.provider.includes(
|
|
1699
1518
|
"vertex"
|
|
@@ -1715,33 +1534,33 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1715
1534
|
});
|
|
1716
1535
|
}
|
|
1717
1536
|
const isVertexProvider = config.provider.startsWith("google.vertex.");
|
|
1718
|
-
if (
|
|
1537
|
+
if (tools?.some(
|
|
1719
1538
|
(tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
|
|
1720
|
-
)
|
|
1539
|
+
) && !isVertexProvider) {
|
|
1721
1540
|
warnings.push({
|
|
1722
1541
|
type: "other",
|
|
1723
1542
|
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}).`
|
|
1724
1543
|
});
|
|
1725
1544
|
}
|
|
1726
|
-
if (
|
|
1545
|
+
if (googleOptions?.streamFunctionCallArguments && !isVertexProvider) {
|
|
1727
1546
|
warnings.push({
|
|
1728
1547
|
type: "other",
|
|
1729
1548
|
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`
|
|
1730
1549
|
});
|
|
1731
1550
|
}
|
|
1732
|
-
if (
|
|
1551
|
+
if (googleOptions?.serviceTier && isVertexProvider) {
|
|
1733
1552
|
warnings.push({
|
|
1734
1553
|
type: "other",
|
|
1735
1554
|
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"
|
|
1736
1555
|
});
|
|
1737
1556
|
}
|
|
1738
|
-
if ((
|
|
1557
|
+
if ((googleOptions?.sharedRequestType || googleOptions?.requestType) && !isVertexProvider) {
|
|
1739
1558
|
warnings.push({
|
|
1740
1559
|
type: "other",
|
|
1741
1560
|
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${config.provider}).`
|
|
1742
1561
|
});
|
|
1743
1562
|
}
|
|
1744
|
-
const vertexPaygoHeaders = isVertexProvider && (
|
|
1563
|
+
const vertexPaygoHeaders = isVertexProvider && (googleOptions?.sharedRequestType || googleOptions?.requestType) ? {
|
|
1745
1564
|
...googleOptions.sharedRequestType && {
|
|
1746
1565
|
"X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
|
|
1747
1566
|
},
|
|
@@ -1749,8 +1568,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1749
1568
|
"X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
|
|
1750
1569
|
}
|
|
1751
1570
|
} : void 0;
|
|
1752
|
-
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions
|
|
1753
|
-
let imageConfig = googleOptions
|
|
1571
|
+
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions?.serviceTier;
|
|
1572
|
+
let imageConfig = googleOptions?.imageConfig;
|
|
1754
1573
|
if (imageConfig != null && !isVertexProvider) {
|
|
1755
1574
|
const {
|
|
1756
1575
|
personGeneration,
|
|
@@ -1786,9 +1605,11 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1786
1605
|
});
|
|
1787
1606
|
}
|
|
1788
1607
|
const { usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
1608
|
+
const supportedFunctionResponseUrls = usesGemini3Features && config.downloadToolResultFiles?.supportsGoogleCloudStorageUrls ? googleCloudStorageFunctionResponseUrls : void 0;
|
|
1789
1609
|
const promptWithDownloadedToolResultFiles = config.downloadToolResultFiles ? await downloadToolResultFiles(prompt, {
|
|
1790
1610
|
abortSignal,
|
|
1791
|
-
maxBytes: config.downloadToolResultFiles.maxBytes
|
|
1611
|
+
maxBytes: config.downloadToolResultFiles.maxBytes,
|
|
1612
|
+
supportedUrls: supportedFunctionResponseUrls
|
|
1792
1613
|
}) : prompt;
|
|
1793
1614
|
const { contents, systemInstruction } = convertToGoogleMessages(
|
|
1794
1615
|
promptWithDownloadedToolResultFiles,
|
|
@@ -1798,7 +1619,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1798
1619
|
onWarning: (warning) => warnings.push(warning),
|
|
1799
1620
|
providerOptionsNames,
|
|
1800
1621
|
supportsFunctionResponseParts: usesGemini3Features,
|
|
1801
|
-
includeFunctionCallIds: !isVertexProvider
|
|
1622
|
+
includeFunctionCallIds: !isVertexProvider,
|
|
1623
|
+
supportedFunctionResponseUrls
|
|
1802
1624
|
}
|
|
1803
1625
|
);
|
|
1804
1626
|
const {
|
|
@@ -1822,22 +1644,22 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1822
1644
|
modelId,
|
|
1823
1645
|
warnings
|
|
1824
1646
|
});
|
|
1825
|
-
const thinkingConfig =
|
|
1826
|
-
const streamFunctionCallArguments = isStreaming && isVertexProvider ?
|
|
1827
|
-
const safetyThreshold = googleOptions
|
|
1828
|
-
const safetySettings =
|
|
1647
|
+
const thinkingConfig = googleOptions?.thinkingConfig || resolvedThinking ? { ...resolvedThinking, ...googleOptions?.thinkingConfig } : void 0;
|
|
1648
|
+
const streamFunctionCallArguments = isStreaming && isVertexProvider ? googleOptions?.streamFunctionCallArguments ?? false : void 0;
|
|
1649
|
+
const safetyThreshold = googleOptions?.threshold;
|
|
1650
|
+
const safetySettings = googleOptions?.safetySettings ?? (safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
|
|
1829
1651
|
category,
|
|
1830
1652
|
threshold: safetyThreshold
|
|
1831
|
-
})) : void 0;
|
|
1832
|
-
const toolConfig = googleToolConfig || streamFunctionCallArguments ||
|
|
1653
|
+
})) : void 0);
|
|
1654
|
+
const toolConfig = googleToolConfig || streamFunctionCallArguments || googleOptions?.retrievalConfig ? {
|
|
1833
1655
|
...googleToolConfig,
|
|
1834
1656
|
...streamFunctionCallArguments && {
|
|
1835
1657
|
functionCallingConfig: {
|
|
1836
|
-
...googleToolConfig
|
|
1658
|
+
...googleToolConfig?.functionCallingConfig,
|
|
1837
1659
|
streamFunctionCallArguments: true
|
|
1838
1660
|
}
|
|
1839
1661
|
},
|
|
1840
|
-
...
|
|
1662
|
+
...googleOptions?.retrievalConfig && {
|
|
1841
1663
|
retrievalConfig: googleOptions.retrievalConfig
|
|
1842
1664
|
}
|
|
1843
1665
|
} : void 0;
|
|
@@ -1854,18 +1676,18 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1854
1676
|
stopSequences,
|
|
1855
1677
|
seed,
|
|
1856
1678
|
// response format:
|
|
1857
|
-
responseMimeType:
|
|
1858
|
-
|
|
1859
|
-
// so this is needed as an escape hatch:
|
|
1679
|
+
responseMimeType: responseFormat?.type === "json" ? "application/json" : void 0,
|
|
1680
|
+
responseJsonSchema: responseFormat?.type === "json" && responseFormat.schema != null && // Google does not support all JSON Schema features in
|
|
1681
|
+
// responseJsonSchema, so this is needed as an escape hatch:
|
|
1860
1682
|
// TODO convert into provider option
|
|
1861
|
-
(
|
|
1862
|
-
...
|
|
1683
|
+
(googleOptions?.structuredOutputs ?? true) ? sanitizeResponseJsonSchema(responseFormat.schema) : void 0,
|
|
1684
|
+
...googleOptions?.audioTimestamp && {
|
|
1863
1685
|
audioTimestamp: googleOptions.audioTimestamp
|
|
1864
1686
|
},
|
|
1865
1687
|
// provider options:
|
|
1866
|
-
responseModalities: googleOptions
|
|
1688
|
+
responseModalities: googleOptions?.responseModalities,
|
|
1867
1689
|
thinkingConfig,
|
|
1868
|
-
...
|
|
1690
|
+
...googleOptions?.mediaResolution && {
|
|
1869
1691
|
mediaResolution: googleOptions.mediaResolution
|
|
1870
1692
|
},
|
|
1871
1693
|
...imageConfig && { imageConfig }
|
|
@@ -1875,8 +1697,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1875
1697
|
safetySettings,
|
|
1876
1698
|
tools: googleTools2,
|
|
1877
1699
|
toolConfig,
|
|
1878
|
-
cachedContent: googleOptions
|
|
1879
|
-
labels: googleOptions
|
|
1700
|
+
cachedContent: googleOptions?.cachedContent,
|
|
1701
|
+
labels: googleOptions?.labels,
|
|
1880
1702
|
serviceTier: bodyServiceTier
|
|
1881
1703
|
},
|
|
1882
1704
|
warnings: [...warnings, ...toolWarnings],
|
|
@@ -1900,27 +1722,29 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1900
1722
|
providerOptionsNames,
|
|
1901
1723
|
toolNameMapping
|
|
1902
1724
|
}) {
|
|
1903
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1904
1725
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1905
1726
|
providerOptionsNames.map((name) => [name, payload])
|
|
1906
1727
|
);
|
|
1907
|
-
const candidate =
|
|
1908
|
-
const promptBlockReason =
|
|
1909
|
-
const
|
|
1910
|
-
|
|
1728
|
+
const candidate = response.candidates?.[0];
|
|
1729
|
+
const promptBlockReason = response.promptFeedback?.blockReason;
|
|
1730
|
+
const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
|
|
1731
|
+
promptBlockReason
|
|
1732
|
+
) ? promptBlockReason : void 0;
|
|
1733
|
+
const isPromptBlocked = candidate?.finishReason == null && confirmedPromptBlockReason != null;
|
|
1734
|
+
const rawFinishReason = candidate?.finishReason ?? confirmedPromptBlockReason;
|
|
1911
1735
|
const content = [];
|
|
1912
|
-
const parts =
|
|
1736
|
+
const parts = candidate?.content?.parts ?? [];
|
|
1913
1737
|
const usageMetadata = response.usageMetadata;
|
|
1914
1738
|
let lastCodeExecutionToolCallId;
|
|
1915
1739
|
let lastServerToolCallId;
|
|
1916
1740
|
for (const part of parts) {
|
|
1917
|
-
if ("executableCode" in part &&
|
|
1741
|
+
if ("executableCode" in part && part.executableCode?.code) {
|
|
1918
1742
|
const toolCallId = config.generateId();
|
|
1919
1743
|
lastCodeExecutionToolCallId = toolCallId;
|
|
1920
1744
|
content.push({
|
|
1921
1745
|
type: "tool-call",
|
|
1922
1746
|
toolCallId,
|
|
1923
|
-
toolName:
|
|
1747
|
+
toolName: toolNameMapping?.toCustomToolName("code_execution") ?? "code_execution",
|
|
1924
1748
|
input: JSON.stringify(part.executableCode),
|
|
1925
1749
|
providerExecuted: true
|
|
1926
1750
|
});
|
|
@@ -1929,10 +1753,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1929
1753
|
type: "tool-result",
|
|
1930
1754
|
// Results correspond to the most recent executable code part.
|
|
1931
1755
|
toolCallId: lastCodeExecutionToolCallId,
|
|
1932
|
-
toolName:
|
|
1756
|
+
toolName: toolNameMapping?.toCustomToolName("code_execution") ?? "code_execution",
|
|
1933
1757
|
result: {
|
|
1934
1758
|
outcome: part.codeExecutionResult.outcome,
|
|
1935
|
-
output:
|
|
1759
|
+
output: part.codeExecutionResult.output ?? ""
|
|
1936
1760
|
}
|
|
1937
1761
|
});
|
|
1938
1762
|
} else if ("text" in part && part.text != null) {
|
|
@@ -1956,7 +1780,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1956
1780
|
type: "tool-call",
|
|
1957
1781
|
toolCallId: part.functionCall.id || config.generateId(),
|
|
1958
1782
|
toolName: part.functionCall.name,
|
|
1959
|
-
input: JSON.stringify(
|
|
1783
|
+
input: JSON.stringify(part.functionCall.args ?? {}),
|
|
1960
1784
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1961
1785
|
thoughtSignature: part.thoughtSignature
|
|
1962
1786
|
}) : void 0
|
|
@@ -1979,7 +1803,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1979
1803
|
type: "tool-call",
|
|
1980
1804
|
toolCallId,
|
|
1981
1805
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1982
|
-
input: JSON.stringify(
|
|
1806
|
+
input: JSON.stringify(part.toolCall.args ?? {}),
|
|
1983
1807
|
providerExecuted: true,
|
|
1984
1808
|
dynamic: true,
|
|
1985
1809
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
@@ -1997,7 +1821,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1997
1821
|
type: "tool-result",
|
|
1998
1822
|
toolCallId: responseToolCallId,
|
|
1999
1823
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2000
|
-
result:
|
|
1824
|
+
result: part.toolResponse.response ?? {},
|
|
2001
1825
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
2002
1826
|
thoughtSignature: part.thoughtSignature,
|
|
2003
1827
|
serverToolCallId: responseToolCallId,
|
|
@@ -2010,10 +1834,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2010
1834
|
lastServerToolCallId = void 0;
|
|
2011
1835
|
}
|
|
2012
1836
|
}
|
|
2013
|
-
const sources =
|
|
2014
|
-
groundingMetadata: candidate
|
|
1837
|
+
const sources = extractSources({
|
|
1838
|
+
groundingMetadata: candidate?.groundingMetadata,
|
|
2015
1839
|
generateId: config.generateId
|
|
2016
|
-
})
|
|
1840
|
+
}) ?? [];
|
|
2017
1841
|
for (const source of sources) {
|
|
2018
1842
|
content.push(source);
|
|
2019
1843
|
}
|
|
@@ -2032,17 +1856,17 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2032
1856
|
usage: convertGoogleUsage(usageMetadata),
|
|
2033
1857
|
warnings,
|
|
2034
1858
|
providerMetadata: wrapProviderMetadata({
|
|
2035
|
-
promptFeedback:
|
|
2036
|
-
groundingMetadata:
|
|
2037
|
-
urlContextMetadata:
|
|
2038
|
-
safetyRatings:
|
|
2039
|
-
usageMetadata: usageMetadata
|
|
2040
|
-
finishMessage:
|
|
2041
|
-
serviceTier:
|
|
1859
|
+
promptFeedback: response.promptFeedback ?? null,
|
|
1860
|
+
groundingMetadata: candidate?.groundingMetadata ?? null,
|
|
1861
|
+
urlContextMetadata: candidate?.urlContextMetadata ?? null,
|
|
1862
|
+
safetyRatings: candidate?.safetyRatings ?? null,
|
|
1863
|
+
usageMetadata: usageMetadata ?? null,
|
|
1864
|
+
finishMessage: candidate?.finishMessage ?? null,
|
|
1865
|
+
serviceTier: usageMetadata?.serviceTier ?? null
|
|
2042
1866
|
}),
|
|
2043
1867
|
response: {
|
|
2044
1868
|
// TODO timestamp, model id
|
|
2045
|
-
id:
|
|
1869
|
+
id: response.responseId ?? void 0
|
|
2046
1870
|
}
|
|
2047
1871
|
};
|
|
2048
1872
|
}
|
|
@@ -2123,9 +1947,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2123
1947
|
raw: void 0
|
|
2124
1948
|
};
|
|
2125
1949
|
let usage = void 0;
|
|
2126
|
-
let
|
|
1950
|
+
let promptFeedback = null;
|
|
2127
1951
|
let lastGroundingMetadata = null;
|
|
2128
1952
|
let lastUrlContextMetadata = null;
|
|
1953
|
+
let lastSafetyRatings = null;
|
|
1954
|
+
let lastFinishMessage = null;
|
|
1955
|
+
let confirmedPromptBlockReason;
|
|
2129
1956
|
const generateId2 = this.config.generateId;
|
|
2130
1957
|
let hasToolCalls = false;
|
|
2131
1958
|
let hasEmittedResponseMetadata = false;
|
|
@@ -2171,7 +1998,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2171
1998
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2172
1999
|
},
|
|
2173
2000
|
transform(chunk, controller) {
|
|
2174
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2175
2001
|
if (options.includeRawChunks) {
|
|
2176
2002
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2177
2003
|
}
|
|
@@ -2191,33 +2017,35 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2191
2017
|
if (usageMetadata != null) {
|
|
2192
2018
|
usage = usageMetadata;
|
|
2193
2019
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2020
|
+
if (value.promptFeedback != null && confirmedPromptBlockReason == null) {
|
|
2021
|
+
promptFeedback = value.promptFeedback;
|
|
2022
|
+
if (isConfirmedPromptBlockReason(value.promptFeedback.blockReason)) {
|
|
2023
|
+
confirmedPromptBlockReason = value.promptFeedback.blockReason;
|
|
2198
2024
|
finishReason = {
|
|
2199
2025
|
unified: "content-filter",
|
|
2200
|
-
raw:
|
|
2026
|
+
raw: confirmedPromptBlockReason
|
|
2201
2027
|
};
|
|
2202
|
-
providerMetadata = wrapProviderMetadata({
|
|
2203
|
-
promptFeedback: (_c = value.promptFeedback) != null ? _c : null,
|
|
2204
|
-
groundingMetadata: lastGroundingMetadata,
|
|
2205
|
-
urlContextMetadata: lastUrlContextMetadata,
|
|
2206
|
-
safetyRatings: null,
|
|
2207
|
-
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2208
|
-
finishMessage: null,
|
|
2209
|
-
serviceTier: (_d = usage == null ? void 0 : usage.serviceTier) != null ? _d : null
|
|
2210
|
-
});
|
|
2211
2028
|
}
|
|
2212
|
-
return;
|
|
2213
2029
|
}
|
|
2214
|
-
const
|
|
2215
|
-
if (candidate
|
|
2216
|
-
|
|
2030
|
+
const candidate = value.candidates?.[0];
|
|
2031
|
+
if (candidate != null) {
|
|
2032
|
+
if (candidate.groundingMetadata != null) {
|
|
2033
|
+
lastGroundingMetadata = candidate.groundingMetadata;
|
|
2034
|
+
}
|
|
2035
|
+
if (candidate.urlContextMetadata != null) {
|
|
2036
|
+
lastUrlContextMetadata = candidate.urlContextMetadata;
|
|
2037
|
+
}
|
|
2038
|
+
if (candidate.safetyRatings != null) {
|
|
2039
|
+
lastSafetyRatings = candidate.safetyRatings;
|
|
2040
|
+
}
|
|
2041
|
+
if (candidate.finishMessage != null) {
|
|
2042
|
+
lastFinishMessage = candidate.finishMessage;
|
|
2043
|
+
}
|
|
2217
2044
|
}
|
|
2218
|
-
if (
|
|
2219
|
-
|
|
2045
|
+
if (confirmedPromptBlockReason != null || candidate == null) {
|
|
2046
|
+
return;
|
|
2220
2047
|
}
|
|
2048
|
+
const content = candidate.content;
|
|
2221
2049
|
const sources = extractSources({
|
|
2222
2050
|
groundingMetadata: candidate.groundingMetadata,
|
|
2223
2051
|
generateId: generateId2
|
|
@@ -2231,9 +2059,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2231
2059
|
}
|
|
2232
2060
|
}
|
|
2233
2061
|
if (content != null) {
|
|
2234
|
-
const parts =
|
|
2062
|
+
const parts = content.parts ?? [];
|
|
2235
2063
|
for (const part of parts) {
|
|
2236
|
-
if ("executableCode" in part &&
|
|
2064
|
+
if ("executableCode" in part && part.executableCode?.code) {
|
|
2237
2065
|
const toolCallId = generateId2();
|
|
2238
2066
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2239
2067
|
controller.enqueue({
|
|
@@ -2252,7 +2080,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2252
2080
|
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2253
2081
|
result: {
|
|
2254
2082
|
outcome: part.codeExecutionResult.outcome,
|
|
2255
|
-
output:
|
|
2083
|
+
output: part.codeExecutionResult.output ?? ""
|
|
2256
2084
|
}
|
|
2257
2085
|
});
|
|
2258
2086
|
}
|
|
@@ -2352,7 +2180,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2352
2180
|
type: "tool-call",
|
|
2353
2181
|
toolCallId,
|
|
2354
2182
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2355
|
-
input: JSON.stringify(
|
|
2183
|
+
input: JSON.stringify(part.toolCall.args ?? {}),
|
|
2356
2184
|
providerExecuted: true,
|
|
2357
2185
|
dynamic: true,
|
|
2358
2186
|
providerMetadata: serverMeta
|
|
@@ -2368,7 +2196,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2368
2196
|
type: "tool-result",
|
|
2369
2197
|
toolCallId: responseToolCallId,
|
|
2370
2198
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2371
|
-
result:
|
|
2199
|
+
result: part.toolResponse.response ?? {},
|
|
2372
2200
|
providerMetadata: serverMeta
|
|
2373
2201
|
});
|
|
2374
2202
|
lastServerToolCallId = void 0;
|
|
@@ -2435,7 +2263,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2435
2263
|
} else if (isCompleteCall) {
|
|
2436
2264
|
const toolCallId = part.functionCall.id || generateId2();
|
|
2437
2265
|
const toolName = part.functionCall.name;
|
|
2438
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify(
|
|
2266
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify(part.functionCall.args ?? {});
|
|
2439
2267
|
controller.enqueue({
|
|
2440
2268
|
type: "tool-input-start",
|
|
2441
2269
|
id: toolCallId,
|
|
@@ -2486,26 +2314,14 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2486
2314
|
}
|
|
2487
2315
|
}
|
|
2488
2316
|
}
|
|
2489
|
-
|
|
2490
|
-
const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
|
|
2491
|
-
const rawFinishReason = (_m = (_l = candidate.finishReason) != null ? _l : promptBlockReason) != null ? _m : void 0;
|
|
2492
|
-
if (rawFinishReason != null) {
|
|
2317
|
+
if (candidate.finishReason != null) {
|
|
2493
2318
|
finishReason = {
|
|
2494
|
-
unified:
|
|
2495
|
-
finishReason:
|
|
2319
|
+
unified: mapGoogleFinishReason({
|
|
2320
|
+
finishReason: candidate.finishReason,
|
|
2496
2321
|
hasToolCalls
|
|
2497
2322
|
}),
|
|
2498
|
-
raw:
|
|
2323
|
+
raw: candidate.finishReason
|
|
2499
2324
|
};
|
|
2500
|
-
providerMetadata = wrapProviderMetadata({
|
|
2501
|
-
promptFeedback: (_n = value.promptFeedback) != null ? _n : null,
|
|
2502
|
-
groundingMetadata: lastGroundingMetadata,
|
|
2503
|
-
urlContextMetadata: lastUrlContextMetadata,
|
|
2504
|
-
safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
|
|
2505
|
-
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2506
|
-
finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
|
|
2507
|
-
serviceTier: (_q = usage == null ? void 0 : usage.serviceTier) != null ? _q : null
|
|
2508
|
-
});
|
|
2509
2325
|
}
|
|
2510
2326
|
},
|
|
2511
2327
|
flush(controller) {
|
|
@@ -2525,7 +2341,15 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2525
2341
|
type: "finish",
|
|
2526
2342
|
finishReason,
|
|
2527
2343
|
usage: convertGoogleUsage(usage),
|
|
2528
|
-
providerMetadata
|
|
2344
|
+
providerMetadata: wrapProviderMetadata({
|
|
2345
|
+
promptFeedback,
|
|
2346
|
+
groundingMetadata: lastGroundingMetadata,
|
|
2347
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
2348
|
+
safetyRatings: lastSafetyRatings,
|
|
2349
|
+
usageMetadata: usage ?? null,
|
|
2350
|
+
finishMessage: lastFinishMessage,
|
|
2351
|
+
serviceTier: usage?.serviceTier ?? null
|
|
2352
|
+
})
|
|
2529
2353
|
});
|
|
2530
2354
|
}
|
|
2531
2355
|
})
|
|
@@ -2584,13 +2408,12 @@ function resolveGemini3ThinkingConfig({
|
|
|
2584
2408
|
return { thinkingLevel };
|
|
2585
2409
|
}
|
|
2586
2410
|
function getMinimumThinkingLevelForGemini3Model(modelId) {
|
|
2587
|
-
|
|
2588
|
-
const modelName = (_a = modelId.split("/").at(-1)) == null ? void 0 : _a.toLowerCase();
|
|
2411
|
+
const modelName = modelId.split("/").at(-1)?.toLowerCase();
|
|
2589
2412
|
if (modelName === "gemini-flash-latest") {
|
|
2590
2413
|
return "low";
|
|
2591
2414
|
}
|
|
2592
2415
|
const versionMatch = /^gemini-(\d+)\.(\d+)-flash(?:$|-(?!lite(?:-|$)))/.exec(
|
|
2593
|
-
modelName
|
|
2416
|
+
modelName ?? ""
|
|
2594
2417
|
);
|
|
2595
2418
|
if (versionMatch == null) {
|
|
2596
2419
|
return "minimal";
|
|
@@ -2623,8 +2446,7 @@ function extractSources({
|
|
|
2623
2446
|
groundingMetadata,
|
|
2624
2447
|
generateId: generateId2
|
|
2625
2448
|
}) {
|
|
2626
|
-
|
|
2627
|
-
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
2449
|
+
if (!groundingMetadata?.groundingChunks) {
|
|
2628
2450
|
return void 0;
|
|
2629
2451
|
}
|
|
2630
2452
|
const sources = [];
|
|
@@ -2635,7 +2457,7 @@ function extractSources({
|
|
|
2635
2457
|
sourceType: "url",
|
|
2636
2458
|
id: generateId2(),
|
|
2637
2459
|
url: chunk.web.uri,
|
|
2638
|
-
title:
|
|
2460
|
+
title: chunk.web.title ?? void 0
|
|
2639
2461
|
});
|
|
2640
2462
|
} else if (chunk.image != null) {
|
|
2641
2463
|
sources.push({
|
|
@@ -2645,7 +2467,7 @@ function extractSources({
|
|
|
2645
2467
|
// Google requires attribution to the source URI, not the actual image URI.
|
|
2646
2468
|
// TODO: add another type in v7 to allow both the image and source URL to be included separately
|
|
2647
2469
|
url: chunk.image.sourceUri,
|
|
2648
|
-
title:
|
|
2470
|
+
title: chunk.image.title ?? void 0
|
|
2649
2471
|
});
|
|
2650
2472
|
} else if (chunk.retrievedContext != null) {
|
|
2651
2473
|
const uri = chunk.retrievedContext.uri;
|
|
@@ -2656,10 +2478,10 @@ function extractSources({
|
|
|
2656
2478
|
sourceType: "url",
|
|
2657
2479
|
id: generateId2(),
|
|
2658
2480
|
url: uri,
|
|
2659
|
-
title:
|
|
2481
|
+
title: chunk.retrievedContext.title ?? void 0
|
|
2660
2482
|
});
|
|
2661
2483
|
} else if (uri) {
|
|
2662
|
-
const title =
|
|
2484
|
+
const title = chunk.retrievedContext.title ?? "Unknown Document";
|
|
2663
2485
|
let mediaType = "application/octet-stream";
|
|
2664
2486
|
let filename = void 0;
|
|
2665
2487
|
if (uri.endsWith(".pdf")) {
|
|
@@ -2689,7 +2511,7 @@ function extractSources({
|
|
|
2689
2511
|
filename
|
|
2690
2512
|
});
|
|
2691
2513
|
} else if (fileSearchStore) {
|
|
2692
|
-
const title =
|
|
2514
|
+
const title = chunk.retrievedContext.title ?? "Unknown Document";
|
|
2693
2515
|
sources.push({
|
|
2694
2516
|
type: "source",
|
|
2695
2517
|
sourceType: "document",
|
|
@@ -2706,208 +2528,214 @@ function extractSources({
|
|
|
2706
2528
|
sourceType: "url",
|
|
2707
2529
|
id: generateId2(),
|
|
2708
2530
|
url: chunk.maps.uri,
|
|
2709
|
-
title:
|
|
2531
|
+
title: chunk.maps.title ?? void 0
|
|
2710
2532
|
});
|
|
2711
2533
|
}
|
|
2712
2534
|
}
|
|
2713
2535
|
}
|
|
2714
2536
|
return sources.length > 0 ? sources : void 0;
|
|
2715
2537
|
}
|
|
2716
|
-
var getGroundingMetadataSchema = () =>
|
|
2717
|
-
webSearchQueries:
|
|
2718
|
-
imageSearchQueries:
|
|
2719
|
-
retrievalQueries:
|
|
2720
|
-
searchEntryPoint:
|
|
2721
|
-
groundingChunks:
|
|
2722
|
-
|
|
2723
|
-
web:
|
|
2724
|
-
image:
|
|
2725
|
-
sourceUri:
|
|
2726
|
-
imageUri:
|
|
2727
|
-
title:
|
|
2728
|
-
domain:
|
|
2538
|
+
var getGroundingMetadataSchema = () => z4.object({
|
|
2539
|
+
webSearchQueries: z4.array(z4.string()).nullish(),
|
|
2540
|
+
imageSearchQueries: z4.array(z4.string()).nullish(),
|
|
2541
|
+
retrievalQueries: z4.array(z4.string()).nullish(),
|
|
2542
|
+
searchEntryPoint: z4.object({ renderedContent: z4.string() }).nullish(),
|
|
2543
|
+
groundingChunks: z4.array(
|
|
2544
|
+
z4.object({
|
|
2545
|
+
web: z4.object({ uri: z4.string(), title: z4.string().nullish() }).nullish(),
|
|
2546
|
+
image: z4.object({
|
|
2547
|
+
sourceUri: z4.string(),
|
|
2548
|
+
imageUri: z4.string(),
|
|
2549
|
+
title: z4.string().nullish(),
|
|
2550
|
+
domain: z4.string().nullish()
|
|
2729
2551
|
}).nullish(),
|
|
2730
|
-
retrievedContext:
|
|
2731
|
-
uri:
|
|
2732
|
-
title:
|
|
2733
|
-
text:
|
|
2734
|
-
fileSearchStore:
|
|
2552
|
+
retrievedContext: z4.object({
|
|
2553
|
+
uri: z4.string().nullish(),
|
|
2554
|
+
title: z4.string().nullish(),
|
|
2555
|
+
text: z4.string().nullish(),
|
|
2556
|
+
fileSearchStore: z4.string().nullish()
|
|
2735
2557
|
}).nullish(),
|
|
2736
|
-
maps:
|
|
2737
|
-
uri:
|
|
2738
|
-
title:
|
|
2739
|
-
text:
|
|
2740
|
-
placeId:
|
|
2558
|
+
maps: z4.object({
|
|
2559
|
+
uri: z4.string().nullish(),
|
|
2560
|
+
title: z4.string().nullish(),
|
|
2561
|
+
text: z4.string().nullish(),
|
|
2562
|
+
placeId: z4.string().nullish()
|
|
2741
2563
|
}).nullish()
|
|
2742
2564
|
})
|
|
2743
2565
|
).nullish(),
|
|
2744
|
-
groundingSupports:
|
|
2745
|
-
|
|
2746
|
-
segment:
|
|
2747
|
-
startIndex:
|
|
2748
|
-
endIndex:
|
|
2749
|
-
text:
|
|
2566
|
+
groundingSupports: z4.array(
|
|
2567
|
+
z4.object({
|
|
2568
|
+
segment: z4.object({
|
|
2569
|
+
startIndex: z4.number().nullish(),
|
|
2570
|
+
endIndex: z4.number().nullish(),
|
|
2571
|
+
text: z4.string().nullish()
|
|
2750
2572
|
}).nullish(),
|
|
2751
|
-
segment_text:
|
|
2752
|
-
groundingChunkIndices:
|
|
2753
|
-
supportChunkIndices:
|
|
2754
|
-
confidenceScores:
|
|
2755
|
-
confidenceScore:
|
|
2573
|
+
segment_text: z4.string().nullish(),
|
|
2574
|
+
groundingChunkIndices: z4.array(z4.number()).nullish(),
|
|
2575
|
+
supportChunkIndices: z4.array(z4.number()).nullish(),
|
|
2576
|
+
confidenceScores: z4.array(z4.number()).nullish(),
|
|
2577
|
+
confidenceScore: z4.array(z4.number()).nullish()
|
|
2756
2578
|
})
|
|
2757
2579
|
).nullish(),
|
|
2758
|
-
retrievalMetadata:
|
|
2759
|
-
|
|
2760
|
-
webDynamicRetrievalScore:
|
|
2580
|
+
retrievalMetadata: z4.union([
|
|
2581
|
+
z4.object({
|
|
2582
|
+
webDynamicRetrievalScore: z4.number()
|
|
2761
2583
|
}),
|
|
2762
|
-
|
|
2584
|
+
z4.object({})
|
|
2763
2585
|
]).nullish()
|
|
2764
2586
|
});
|
|
2765
|
-
var partialArgSchema =
|
|
2766
|
-
jsonPath:
|
|
2767
|
-
stringValue:
|
|
2768
|
-
numberValue:
|
|
2769
|
-
boolValue:
|
|
2770
|
-
nullValue:
|
|
2771
|
-
willContinue:
|
|
2587
|
+
var partialArgSchema = z4.object({
|
|
2588
|
+
jsonPath: z4.string(),
|
|
2589
|
+
stringValue: z4.string().nullish(),
|
|
2590
|
+
numberValue: z4.number().nullish(),
|
|
2591
|
+
boolValue: z4.boolean().nullish(),
|
|
2592
|
+
nullValue: z4.unknown().nullish(),
|
|
2593
|
+
willContinue: z4.boolean().nullish()
|
|
2772
2594
|
});
|
|
2773
|
-
var getContentSchema = () =>
|
|
2774
|
-
parts:
|
|
2775
|
-
|
|
2595
|
+
var getContentSchema = () => z4.object({
|
|
2596
|
+
parts: z4.array(
|
|
2597
|
+
z4.union([
|
|
2776
2598
|
// note: order matters since text can be fully empty
|
|
2777
|
-
|
|
2778
|
-
functionCall:
|
|
2779
|
-
id:
|
|
2780
|
-
name:
|
|
2781
|
-
args:
|
|
2782
|
-
partialArgs:
|
|
2783
|
-
willContinue:
|
|
2599
|
+
z4.object({
|
|
2600
|
+
functionCall: z4.object({
|
|
2601
|
+
id: z4.string().nullish(),
|
|
2602
|
+
name: z4.string().nullish(),
|
|
2603
|
+
args: z4.unknown().nullish(),
|
|
2604
|
+
partialArgs: z4.array(partialArgSchema).nullish(),
|
|
2605
|
+
willContinue: z4.boolean().nullish()
|
|
2784
2606
|
}),
|
|
2785
|
-
thoughtSignature:
|
|
2607
|
+
thoughtSignature: z4.string().nullish()
|
|
2786
2608
|
}),
|
|
2787
|
-
|
|
2788
|
-
inlineData:
|
|
2789
|
-
mimeType:
|
|
2790
|
-
data:
|
|
2609
|
+
z4.object({
|
|
2610
|
+
inlineData: z4.object({
|
|
2611
|
+
mimeType: z4.string(),
|
|
2612
|
+
data: z4.string()
|
|
2791
2613
|
}),
|
|
2792
|
-
thought:
|
|
2793
|
-
thoughtSignature:
|
|
2614
|
+
thought: z4.boolean().nullish(),
|
|
2615
|
+
thoughtSignature: z4.string().nullish()
|
|
2794
2616
|
}),
|
|
2795
|
-
|
|
2796
|
-
toolCall:
|
|
2797
|
-
toolType:
|
|
2798
|
-
args:
|
|
2799
|
-
id:
|
|
2617
|
+
z4.object({
|
|
2618
|
+
toolCall: z4.object({
|
|
2619
|
+
toolType: z4.string(),
|
|
2620
|
+
args: z4.unknown().nullish(),
|
|
2621
|
+
id: z4.string()
|
|
2800
2622
|
}),
|
|
2801
|
-
thoughtSignature:
|
|
2623
|
+
thoughtSignature: z4.string().nullish()
|
|
2802
2624
|
}),
|
|
2803
|
-
|
|
2804
|
-
toolResponse:
|
|
2805
|
-
toolType:
|
|
2806
|
-
response:
|
|
2807
|
-
id:
|
|
2625
|
+
z4.object({
|
|
2626
|
+
toolResponse: z4.object({
|
|
2627
|
+
toolType: z4.string(),
|
|
2628
|
+
response: z4.unknown().nullish(),
|
|
2629
|
+
id: z4.string()
|
|
2808
2630
|
}),
|
|
2809
|
-
thoughtSignature:
|
|
2631
|
+
thoughtSignature: z4.string().nullish()
|
|
2810
2632
|
}),
|
|
2811
|
-
|
|
2812
|
-
executableCode:
|
|
2813
|
-
language:
|
|
2814
|
-
code:
|
|
2633
|
+
z4.object({
|
|
2634
|
+
executableCode: z4.object({
|
|
2635
|
+
language: z4.string(),
|
|
2636
|
+
code: z4.string()
|
|
2815
2637
|
}).nullish(),
|
|
2816
|
-
codeExecutionResult:
|
|
2817
|
-
outcome:
|
|
2818
|
-
output:
|
|
2638
|
+
codeExecutionResult: z4.object({
|
|
2639
|
+
outcome: z4.string(),
|
|
2640
|
+
output: z4.string().nullish()
|
|
2819
2641
|
}).nullish(),
|
|
2820
|
-
text:
|
|
2821
|
-
thought:
|
|
2822
|
-
thoughtSignature:
|
|
2642
|
+
text: z4.string().nullish(),
|
|
2643
|
+
thought: z4.boolean().nullish(),
|
|
2644
|
+
thoughtSignature: z4.string().nullish()
|
|
2823
2645
|
})
|
|
2824
2646
|
])
|
|
2825
2647
|
).nullish()
|
|
2826
2648
|
});
|
|
2827
|
-
var getSafetyRatingSchema = () =>
|
|
2828
|
-
category:
|
|
2829
|
-
probability:
|
|
2830
|
-
probabilityScore:
|
|
2831
|
-
severity:
|
|
2832
|
-
severityScore:
|
|
2833
|
-
blocked:
|
|
2649
|
+
var getSafetyRatingSchema = () => z4.object({
|
|
2650
|
+
category: z4.string().nullish(),
|
|
2651
|
+
probability: z4.string().nullish(),
|
|
2652
|
+
probabilityScore: z4.number().nullish(),
|
|
2653
|
+
severity: z4.string().nullish(),
|
|
2654
|
+
severityScore: z4.number().nullish(),
|
|
2655
|
+
blocked: z4.boolean().nullish()
|
|
2834
2656
|
});
|
|
2835
|
-
var tokenDetailsSchema =
|
|
2836
|
-
|
|
2837
|
-
modality:
|
|
2838
|
-
tokenCount:
|
|
2657
|
+
var tokenDetailsSchema = z4.array(
|
|
2658
|
+
z4.object({
|
|
2659
|
+
modality: z4.string(),
|
|
2660
|
+
tokenCount: z4.number()
|
|
2839
2661
|
}).loose()
|
|
2840
2662
|
).nullish();
|
|
2841
|
-
var usageSchema =
|
|
2842
|
-
cachedContentTokenCount:
|
|
2843
|
-
thoughtsTokenCount:
|
|
2844
|
-
promptTokenCount:
|
|
2845
|
-
candidatesTokenCount:
|
|
2846
|
-
toolUsePromptTokenCount:
|
|
2847
|
-
totalTokenCount:
|
|
2663
|
+
var usageSchema = z4.object({
|
|
2664
|
+
cachedContentTokenCount: z4.number().nullish(),
|
|
2665
|
+
thoughtsTokenCount: z4.number().nullish(),
|
|
2666
|
+
promptTokenCount: z4.number().nullish(),
|
|
2667
|
+
candidatesTokenCount: z4.number().nullish(),
|
|
2668
|
+
toolUsePromptTokenCount: z4.number().nullish(),
|
|
2669
|
+
totalTokenCount: z4.number().nullish(),
|
|
2848
2670
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2849
|
-
trafficType:
|
|
2850
|
-
serviceTier:
|
|
2671
|
+
trafficType: z4.string().nullish(),
|
|
2672
|
+
serviceTier: z4.string().nullish(),
|
|
2851
2673
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2852
2674
|
promptTokensDetails: tokenDetailsSchema,
|
|
2853
2675
|
cacheTokensDetails: tokenDetailsSchema,
|
|
2854
2676
|
candidatesTokensDetails: tokenDetailsSchema,
|
|
2855
2677
|
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
2856
2678
|
}).loose();
|
|
2857
|
-
var getUrlContextMetadataSchema = () =>
|
|
2858
|
-
urlMetadata:
|
|
2859
|
-
|
|
2860
|
-
retrievedUrl:
|
|
2861
|
-
urlRetrievalStatus:
|
|
2679
|
+
var getUrlContextMetadataSchema = () => z4.object({
|
|
2680
|
+
urlMetadata: z4.array(
|
|
2681
|
+
z4.object({
|
|
2682
|
+
retrievedUrl: z4.string(),
|
|
2683
|
+
urlRetrievalStatus: z4.string()
|
|
2862
2684
|
})
|
|
2863
2685
|
).nullish()
|
|
2864
2686
|
});
|
|
2865
2687
|
var responseSchema = lazySchema3(
|
|
2866
2688
|
() => zodSchema3(
|
|
2867
|
-
|
|
2868
|
-
responseId:
|
|
2869
|
-
candidates:
|
|
2870
|
-
|
|
2871
|
-
content: getContentSchema().nullish().or(
|
|
2872
|
-
finishReason:
|
|
2873
|
-
finishMessage:
|
|
2874
|
-
safetyRatings:
|
|
2689
|
+
z4.object({
|
|
2690
|
+
responseId: z4.string().nullish(),
|
|
2691
|
+
candidates: z4.array(
|
|
2692
|
+
z4.object({
|
|
2693
|
+
content: getContentSchema().nullish().or(z4.object({}).strict()),
|
|
2694
|
+
finishReason: z4.string().nullish(),
|
|
2695
|
+
finishMessage: z4.string().nullish(),
|
|
2696
|
+
safetyRatings: z4.array(getSafetyRatingSchema()).nullish(),
|
|
2875
2697
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2876
2698
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2877
2699
|
})
|
|
2878
2700
|
).nullish(),
|
|
2879
2701
|
usageMetadata: usageSchema.nullish(),
|
|
2880
|
-
promptFeedback:
|
|
2881
|
-
blockReason:
|
|
2882
|
-
safetyRatings:
|
|
2702
|
+
promptFeedback: z4.object({
|
|
2703
|
+
blockReason: z4.string().nullish(),
|
|
2704
|
+
safetyRatings: z4.array(getSafetyRatingSchema()).nullish()
|
|
2883
2705
|
}).nullish()
|
|
2884
2706
|
})
|
|
2885
2707
|
)
|
|
2886
2708
|
);
|
|
2887
2709
|
var chunkSchema = lazySchema3(
|
|
2888
2710
|
() => zodSchema3(
|
|
2889
|
-
|
|
2890
|
-
responseId:
|
|
2891
|
-
candidates:
|
|
2892
|
-
|
|
2711
|
+
z4.object({
|
|
2712
|
+
responseId: z4.string().nullish(),
|
|
2713
|
+
candidates: z4.array(
|
|
2714
|
+
z4.object({
|
|
2893
2715
|
content: getContentSchema().nullish(),
|
|
2894
|
-
finishReason:
|
|
2895
|
-
finishMessage:
|
|
2896
|
-
safetyRatings:
|
|
2716
|
+
finishReason: z4.string().nullish(),
|
|
2717
|
+
finishMessage: z4.string().nullish(),
|
|
2718
|
+
safetyRatings: z4.array(getSafetyRatingSchema()).nullish(),
|
|
2897
2719
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2898
2720
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2899
2721
|
})
|
|
2900
2722
|
).nullish(),
|
|
2901
2723
|
usageMetadata: usageSchema.nullish(),
|
|
2902
|
-
promptFeedback:
|
|
2903
|
-
blockReason:
|
|
2904
|
-
safetyRatings:
|
|
2724
|
+
promptFeedback: z4.object({
|
|
2725
|
+
blockReason: z4.string().nullish(),
|
|
2726
|
+
safetyRatings: z4.array(getSafetyRatingSchema()).nullish()
|
|
2905
2727
|
}).nullish()
|
|
2906
2728
|
})
|
|
2907
2729
|
)
|
|
2908
2730
|
);
|
|
2731
|
+
function isConfirmedPromptBlockReason(blockReason) {
|
|
2732
|
+
return blockReason != null && blockReason !== "" && blockReason !== "BLOCK_REASON_UNSPECIFIED" && blockReason !== "BLOCKED_REASON_UNSPECIFIED";
|
|
2733
|
+
}
|
|
2909
2734
|
|
|
2910
2735
|
// src/google-speech-model.ts
|
|
2736
|
+
import {
|
|
2737
|
+
InvalidArgumentError
|
|
2738
|
+
} from "@ai-sdk/provider";
|
|
2911
2739
|
import {
|
|
2912
2740
|
combineHeaders as combineHeaders2,
|
|
2913
2741
|
convertBase64ToUint8Array,
|
|
@@ -2922,18 +2750,18 @@ import {
|
|
|
2922
2750
|
|
|
2923
2751
|
// src/google-speech-api.ts
|
|
2924
2752
|
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
2925
|
-
import { z as
|
|
2753
|
+
import { z as z5 } from "zod/v4";
|
|
2926
2754
|
var googleSpeechResponseSchema = lazySchema4(
|
|
2927
2755
|
() => zodSchema4(
|
|
2928
|
-
|
|
2929
|
-
candidates:
|
|
2930
|
-
|
|
2931
|
-
content:
|
|
2932
|
-
parts:
|
|
2933
|
-
|
|
2934
|
-
inlineData:
|
|
2935
|
-
mimeType:
|
|
2936
|
-
data:
|
|
2756
|
+
z5.object({
|
|
2757
|
+
candidates: z5.array(
|
|
2758
|
+
z5.object({
|
|
2759
|
+
content: z5.object({
|
|
2760
|
+
parts: z5.array(
|
|
2761
|
+
z5.object({
|
|
2762
|
+
inlineData: z5.object({
|
|
2763
|
+
mimeType: z5.string().nullish(),
|
|
2764
|
+
data: z5.string().nullish()
|
|
2937
2765
|
}).nullish()
|
|
2938
2766
|
})
|
|
2939
2767
|
).nullish()
|
|
@@ -2944,32 +2772,82 @@ var googleSpeechResponseSchema = lazySchema4(
|
|
|
2944
2772
|
)
|
|
2945
2773
|
);
|
|
2946
2774
|
|
|
2775
|
+
// src/google-speech-input.ts
|
|
2776
|
+
function getGoogleSpeechInput({
|
|
2777
|
+
text,
|
|
2778
|
+
voice,
|
|
2779
|
+
providerOptions
|
|
2780
|
+
}) {
|
|
2781
|
+
const google = providerOptions?.google;
|
|
2782
|
+
const options = google != null && typeof google === "object" ? google : void 0;
|
|
2783
|
+
const turns = options && "turns" in options ? options.turns : void 0;
|
|
2784
|
+
const turnTexts = [];
|
|
2785
|
+
if (Array.isArray(turns) && turns.length > 0) {
|
|
2786
|
+
for (const turn of turns) {
|
|
2787
|
+
if (turn == null || typeof turn !== "object" || !("text" in turn) || typeof turn.text !== "string") {
|
|
2788
|
+
break;
|
|
2789
|
+
}
|
|
2790
|
+
turnTexts.push(turn.text);
|
|
2791
|
+
}
|
|
2792
|
+
if (turnTexts.length === turns.length) {
|
|
2793
|
+
text = turnTexts.join("");
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
const config = options && "multiSpeakerVoiceConfig" in options ? options.multiSpeakerVoiceConfig : void 0;
|
|
2797
|
+
const speakers = config != null && typeof config === "object" && "speakerVoiceConfigs" in config && Array.isArray(config.speakerVoiceConfigs) ? config.speakerVoiceConfigs : [];
|
|
2798
|
+
return {
|
|
2799
|
+
text,
|
|
2800
|
+
usesCustomVoice: voice?.startsWith("voice_") === true || voice?.startsWith("voicekey_") === true || speakers.some(
|
|
2801
|
+
(speaker) => speaker != null && typeof speaker === "object" && "voiceConfig" in speaker && speaker.voiceConfig != null && typeof speaker.voiceConfig === "object" && "voice" in speaker.voiceConfig
|
|
2802
|
+
)
|
|
2803
|
+
};
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2947
2806
|
// src/google-speech-model-options.ts
|
|
2948
2807
|
import {
|
|
2949
2808
|
lazySchema as lazySchema5,
|
|
2950
2809
|
zodSchema as zodSchema5
|
|
2951
2810
|
} from "@ai-sdk/provider-utils";
|
|
2952
|
-
import { z as
|
|
2953
|
-
var prebuiltVoiceConfigSchema =
|
|
2954
|
-
voiceName:
|
|
2811
|
+
import { z as z6 } from "zod/v4";
|
|
2812
|
+
var prebuiltVoiceConfigSchema = z6.object({
|
|
2813
|
+
voiceName: z6.string()
|
|
2955
2814
|
});
|
|
2956
|
-
var voiceConfigSchema =
|
|
2957
|
-
prebuiltVoiceConfig: prebuiltVoiceConfigSchema
|
|
2815
|
+
var voiceConfigSchema = z6.object({
|
|
2816
|
+
prebuiltVoiceConfig: prebuiltVoiceConfigSchema,
|
|
2817
|
+
voice: z6.never().optional()
|
|
2818
|
+
});
|
|
2819
|
+
var speechMetadataSchema = z6.object({
|
|
2820
|
+
speaker: z6.string().min(1).optional(),
|
|
2821
|
+
style: z6.string().optional()
|
|
2958
2822
|
});
|
|
2959
2823
|
var googleSpeechProviderOptionsSchema = lazySchema5(
|
|
2960
2824
|
() => zodSchema5(
|
|
2961
|
-
|
|
2825
|
+
z6.object({
|
|
2826
|
+
/** Turn-level directions for the top-level text, for Gemini 3.8 TTS. */
|
|
2827
|
+
speechMetadata: speechMetadataSchema.optional(),
|
|
2828
|
+
/**
|
|
2829
|
+
* Structured transcript for Gemini 3.8 TTS. Replaces the top-level text;
|
|
2830
|
+
* pass text: '' when using turns. Each multi-speaker turn must name a
|
|
2831
|
+
* configured speaker in speechMetadata. Per-turn styles override instructions.
|
|
2832
|
+
*/
|
|
2833
|
+
turns: z6.array(
|
|
2834
|
+
z6.object({
|
|
2835
|
+
text: z6.string(),
|
|
2836
|
+
speechMetadata: speechMetadataSchema.optional()
|
|
2837
|
+
})
|
|
2838
|
+
).min(1).optional(),
|
|
2962
2839
|
/**
|
|
2963
2840
|
* Multi-speaker configuration for dialogue audio. When provided, this
|
|
2964
2841
|
* overrides the top-level `voice`. The Gemini TTS API supports up to two
|
|
2965
|
-
* speakers
|
|
2842
|
+
* speakers. For Gemini 3.8, each turn's speechMetadata.speaker must match
|
|
2843
|
+
* a configured speaker; older models use speaker labels in the text.
|
|
2966
2844
|
*
|
|
2967
2845
|
* https://ai.google.dev/gemini-api/docs/speech-generation#multi-speaker
|
|
2968
2846
|
*/
|
|
2969
|
-
multiSpeakerVoiceConfig:
|
|
2970
|
-
speakerVoiceConfigs:
|
|
2971
|
-
|
|
2972
|
-
speaker:
|
|
2847
|
+
multiSpeakerVoiceConfig: z6.object({
|
|
2848
|
+
speakerVoiceConfigs: z6.array(
|
|
2849
|
+
z6.object({
|
|
2850
|
+
speaker: z6.string(),
|
|
2973
2851
|
voiceConfig: voiceConfigSchema
|
|
2974
2852
|
})
|
|
2975
2853
|
)
|
|
@@ -3028,10 +2906,22 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
3028
2906
|
schema: googleSpeechProviderOptionsSchema
|
|
3029
2907
|
});
|
|
3030
2908
|
}
|
|
3031
|
-
const
|
|
2909
|
+
const usesStructuredSpeech = !this.modelId.startsWith("gemini-2.5-") && !this.modelId.startsWith("gemini-3.1-");
|
|
2910
|
+
const input = getGoogleSpeechInput({
|
|
2911
|
+
text,
|
|
2912
|
+
voice,
|
|
2913
|
+
providerOptions: { google: googleOptions }
|
|
2914
|
+
});
|
|
2915
|
+
if (input.usesCustomVoice) {
|
|
2916
|
+
throw new InvalidArgumentError({
|
|
2917
|
+
argument: "voice",
|
|
2918
|
+
message: "Custom voices are not supported. Use a prebuilt voice instead."
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2921
|
+
const multiSpeakerVoiceConfig = googleOptions?.multiSpeakerVoiceConfig;
|
|
3032
2922
|
const speechConfig = multiSpeakerVoiceConfig ? { multiSpeakerVoiceConfig } : { voiceConfig: { prebuiltVoiceConfig: { voiceName: voice } } };
|
|
3033
2923
|
let promptText = text;
|
|
3034
|
-
if (instructions != null) {
|
|
2924
|
+
if (instructions != null && !usesStructuredSpeech) {
|
|
3035
2925
|
if (multiSpeakerVoiceConfig) {
|
|
3036
2926
|
warnings.push({
|
|
3037
2927
|
type: "unsupported",
|
|
@@ -3042,6 +2932,51 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
3042
2932
|
promptText = `${instructions}: ${text}`;
|
|
3043
2933
|
}
|
|
3044
2934
|
}
|
|
2935
|
+
let parts = [{ text: promptText }];
|
|
2936
|
+
if (usesStructuredSpeech) {
|
|
2937
|
+
if (googleOptions?.turns && googleOptions.speechMetadata) {
|
|
2938
|
+
throw new InvalidArgumentError({
|
|
2939
|
+
argument: "providerOptions",
|
|
2940
|
+
message: "Set speechMetadata on each turn when using turns."
|
|
2941
|
+
});
|
|
2942
|
+
}
|
|
2943
|
+
if (googleOptions?.turns && text !== "") {
|
|
2944
|
+
warnings.push({
|
|
2945
|
+
type: "unsupported",
|
|
2946
|
+
feature: "text",
|
|
2947
|
+
details: "Google TTS turns replace the top-level text."
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
parts = (googleOptions?.turns ?? [
|
|
2951
|
+
{ text, speechMetadata: googleOptions?.speechMetadata }
|
|
2952
|
+
]).map((part) => {
|
|
2953
|
+
const style = part.speechMetadata?.style ?? instructions;
|
|
2954
|
+
const speaker = part.speechMetadata?.speaker;
|
|
2955
|
+
if (multiSpeakerVoiceConfig && !multiSpeakerVoiceConfig.speakerVoiceConfigs.some(
|
|
2956
|
+
(config) => config.speaker === speaker
|
|
2957
|
+
)) {
|
|
2958
|
+
throw new InvalidArgumentError({
|
|
2959
|
+
argument: "speechMetadata.speaker",
|
|
2960
|
+
message: "Every multi-speaker turn must specify a speechMetadata.speaker matching a configured speaker."
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
return {
|
|
2964
|
+
text: part.text,
|
|
2965
|
+
...style != null || speaker != null ? { speechMetadata: { style, speaker } } : {}
|
|
2966
|
+
};
|
|
2967
|
+
});
|
|
2968
|
+
} else if (googleOptions?.turns || googleOptions?.speechMetadata) {
|
|
2969
|
+
throw new InvalidArgumentError({
|
|
2970
|
+
argument: "providerOptions",
|
|
2971
|
+
message: "Structured speech metadata and turns require Gemini 3.8 TTS."
|
|
2972
|
+
});
|
|
2973
|
+
}
|
|
2974
|
+
if (input.text.length === 0) {
|
|
2975
|
+
throw new InvalidArgumentError({
|
|
2976
|
+
argument: "text",
|
|
2977
|
+
message: "Speech input must contain a non-empty transcript."
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
3045
2980
|
if (speed != null) {
|
|
3046
2981
|
warnings.push({
|
|
3047
2982
|
type: "unsupported",
|
|
@@ -3056,10 +2991,20 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
3056
2991
|
details: "Google Gemini TTS models do not support the `language` option. Language is detected automatically from the input text."
|
|
3057
2992
|
});
|
|
3058
2993
|
}
|
|
2994
|
+
const formats = usesStructuredSpeech ? {
|
|
2995
|
+
wav: "AUDIO_WAV",
|
|
2996
|
+
"audio/wav": "AUDIO_WAV",
|
|
2997
|
+
pcm: "AUDIO_L16",
|
|
2998
|
+
"audio/l16": "AUDIO_L16",
|
|
2999
|
+
mulaw: "AUDIO_MULAW",
|
|
3000
|
+
"audio/mulaw": "AUDIO_MULAW",
|
|
3001
|
+
alaw: "AUDIO_ALAW",
|
|
3002
|
+
"audio/alaw": "AUDIO_ALAW"
|
|
3003
|
+
} : { wav: "AUDIO_WAV", pcm: "AUDIO_L16" };
|
|
3059
3004
|
let resolvedOutputFormat = "wav";
|
|
3060
|
-
if (outputFormat
|
|
3061
|
-
resolvedOutputFormat =
|
|
3062
|
-
} else if (outputFormat != null
|
|
3005
|
+
if (outputFormat != null && Object.prototype.hasOwnProperty.call(formats, outputFormat)) {
|
|
3006
|
+
resolvedOutputFormat = outputFormat;
|
|
3007
|
+
} else if (outputFormat != null) {
|
|
3063
3008
|
warnings.push({
|
|
3064
3009
|
type: "unsupported",
|
|
3065
3010
|
feature: "outputFormat",
|
|
@@ -3067,18 +3012,27 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
3067
3012
|
});
|
|
3068
3013
|
}
|
|
3069
3014
|
const requestBody = {
|
|
3070
|
-
contents: [{ role: "user", parts
|
|
3015
|
+
contents: [{ role: "user", parts }],
|
|
3071
3016
|
generationConfig: {
|
|
3072
3017
|
responseModalities: ["AUDIO"],
|
|
3073
|
-
speechConfig
|
|
3018
|
+
speechConfig,
|
|
3019
|
+
...usesStructuredSpeech && outputFormat != null ? {
|
|
3020
|
+
responseFormat: {
|
|
3021
|
+
audio: { mimeType: formats[resolvedOutputFormat] }
|
|
3022
|
+
}
|
|
3023
|
+
} : {}
|
|
3074
3024
|
}
|
|
3075
3025
|
};
|
|
3076
|
-
return {
|
|
3026
|
+
return {
|
|
3027
|
+
requestBody,
|
|
3028
|
+
warnings,
|
|
3029
|
+
outputFormat: formats[resolvedOutputFormat],
|
|
3030
|
+
usesStructuredSpeech
|
|
3031
|
+
};
|
|
3077
3032
|
}
|
|
3078
3033
|
async doGenerate(options) {
|
|
3079
|
-
|
|
3080
|
-
const
|
|
3081
|
-
const { requestBody, warnings, outputFormat } = await this.getArgs(options);
|
|
3034
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
3035
|
+
const { requestBody, warnings, outputFormat, usesStructuredSpeech } = await this.getArgs(options);
|
|
3082
3036
|
const {
|
|
3083
3037
|
value: response,
|
|
3084
3038
|
responseHeaders,
|
|
@@ -3099,11 +3053,11 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
3099
3053
|
});
|
|
3100
3054
|
let base64Audio;
|
|
3101
3055
|
let mimeType;
|
|
3102
|
-
for (const candidate of
|
|
3103
|
-
for (const part of
|
|
3104
|
-
if (
|
|
3056
|
+
for (const candidate of response.candidates ?? []) {
|
|
3057
|
+
for (const part of candidate.content?.parts ?? []) {
|
|
3058
|
+
if (part.inlineData?.data) {
|
|
3105
3059
|
base64Audio = part.inlineData.data;
|
|
3106
|
-
mimeType =
|
|
3060
|
+
mimeType = part.inlineData.mimeType ?? void 0;
|
|
3107
3061
|
break;
|
|
3108
3062
|
}
|
|
3109
3063
|
}
|
|
@@ -3111,10 +3065,11 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
3111
3065
|
break;
|
|
3112
3066
|
}
|
|
3113
3067
|
}
|
|
3114
|
-
const sampleRate =
|
|
3115
|
-
const
|
|
3116
|
-
const
|
|
3117
|
-
|
|
3068
|
+
const sampleRate = parseSampleRate(mimeType) ?? DEFAULT_SAMPLE_RATE;
|
|
3069
|
+
const bytes = base64Audio != null ? convertBase64ToUint8Array(base64Audio) : new Uint8Array(0);
|
|
3070
|
+
const isPcm = /^audio\/(?:l16|pcm)(?:;|$)/i.test(mimeType ?? "") || mimeType == null && !usesStructuredSpeech;
|
|
3071
|
+
const audio = outputFormat === "AUDIO_WAV" && isPcm && bytes.length > 0 ? addWavHeader(bytes, sampleRate) : bytes;
|
|
3072
|
+
if (outputFormat === "AUDIO_L16" && bytes.length > 0 && !usesStructuredSpeech) {
|
|
3118
3073
|
warnings.push({
|
|
3119
3074
|
type: "unsupported",
|
|
3120
3075
|
feature: "outputFormat",
|
|
@@ -3136,7 +3091,7 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
|
3136
3091
|
providerMetadata: {
|
|
3137
3092
|
google: {
|
|
3138
3093
|
sampleRate,
|
|
3139
|
-
mimeType: mimeType
|
|
3094
|
+
mimeType: mimeType ?? null
|
|
3140
3095
|
}
|
|
3141
3096
|
}
|
|
3142
3097
|
};
|
|
@@ -3180,21 +3135,6 @@ function writeAscii(view, offset, text) {
|
|
|
3180
3135
|
}
|
|
3181
3136
|
}
|
|
3182
3137
|
|
|
3183
|
-
// src/tool/code-execution.ts
|
|
3184
|
-
import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
|
|
3185
|
-
import { z as z6 } from "zod/v4";
|
|
3186
|
-
var codeExecution = createProviderExecutedToolFactory({
|
|
3187
|
-
id: "google.code_execution",
|
|
3188
|
-
inputSchema: z6.object({
|
|
3189
|
-
language: z6.string().describe("The programming language of the code."),
|
|
3190
|
-
code: z6.string().describe("The code to be executed.")
|
|
3191
|
-
}),
|
|
3192
|
-
outputSchema: z6.object({
|
|
3193
|
-
outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
3194
|
-
output: z6.string().describe("The output from the code execution.")
|
|
3195
|
-
})
|
|
3196
|
-
});
|
|
3197
|
-
|
|
3198
3138
|
// src/tool/enterprise-web-search.ts
|
|
3199
3139
|
import {
|
|
3200
3140
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
@@ -3381,37 +3321,36 @@ import {
|
|
|
3381
3321
|
// src/interactions/convert-google-interactions-usage.ts
|
|
3382
3322
|
import { createNullLanguageModelUsage as createNullLanguageModelUsage2 } from "@ai-sdk/provider-utils";
|
|
3383
3323
|
function convertGoogleInteractionsUsage(usage) {
|
|
3384
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3385
3324
|
if (usage == null) {
|
|
3386
3325
|
return createNullLanguageModelUsage2();
|
|
3387
3326
|
}
|
|
3388
|
-
const totalInput =
|
|
3389
|
-
const totalOutput =
|
|
3390
|
-
const totalThought =
|
|
3391
|
-
const totalCached =
|
|
3327
|
+
const totalInput = usage.total_input_tokens ?? 0;
|
|
3328
|
+
const totalOutput = usage.total_output_tokens ?? 0;
|
|
3329
|
+
const totalThought = usage.total_thought_tokens ?? 0;
|
|
3330
|
+
const totalCached = usage.total_cached_tokens ?? 0;
|
|
3392
3331
|
return {
|
|
3393
3332
|
inputTokens: {
|
|
3394
|
-
total:
|
|
3333
|
+
total: usage.total_input_tokens ?? void 0,
|
|
3395
3334
|
noCache: usage.total_input_tokens == null ? void 0 : totalInput - totalCached,
|
|
3396
|
-
cacheRead:
|
|
3335
|
+
cacheRead: usage.total_cached_tokens ?? void 0,
|
|
3397
3336
|
cacheWrite: void 0
|
|
3398
3337
|
},
|
|
3399
3338
|
outputTokens: {
|
|
3400
3339
|
total: usage.total_output_tokens == null && usage.total_thought_tokens == null ? void 0 : totalOutput + totalThought,
|
|
3401
|
-
text:
|
|
3402
|
-
reasoning:
|
|
3340
|
+
text: usage.total_output_tokens ?? void 0,
|
|
3341
|
+
reasoning: usage.total_thought_tokens ?? void 0
|
|
3403
3342
|
},
|
|
3404
3343
|
raw: usage
|
|
3405
3344
|
};
|
|
3406
3345
|
}
|
|
3407
3346
|
function getGoogleInteractionsOutputTokensByModality(usage) {
|
|
3408
|
-
const byModality = usage
|
|
3347
|
+
const byModality = usage?.output_tokens_by_modality;
|
|
3409
3348
|
if (byModality == null) {
|
|
3410
3349
|
return void 0;
|
|
3411
3350
|
}
|
|
3412
3351
|
const result = {};
|
|
3413
3352
|
for (const entry of byModality) {
|
|
3414
|
-
if (
|
|
3353
|
+
if (entry?.modality != null && entry.tokens != null) {
|
|
3415
3354
|
result[entry.modality] = entry.tokens;
|
|
3416
3355
|
}
|
|
3417
3356
|
}
|
|
@@ -3443,7 +3382,6 @@ function annotationToSource({
|
|
|
3443
3382
|
annotation,
|
|
3444
3383
|
generateId: generateId2
|
|
3445
3384
|
}) {
|
|
3446
|
-
var _a, _b, _c, _d, _e;
|
|
3447
3385
|
switch (annotation.type) {
|
|
3448
3386
|
case "url_citation": {
|
|
3449
3387
|
const urlCitation = annotation;
|
|
@@ -3460,7 +3398,7 @@ function annotationToSource({
|
|
|
3460
3398
|
}
|
|
3461
3399
|
case "file_citation": {
|
|
3462
3400
|
const fileCitation = annotation;
|
|
3463
|
-
const uri =
|
|
3401
|
+
const uri = fileCitation.url ?? fileCitation.document_uri ?? fileCitation.file_name;
|
|
3464
3402
|
if (uri == null || uri.length === 0) return void 0;
|
|
3465
3403
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3466
3404
|
return {
|
|
@@ -3471,14 +3409,14 @@ function annotationToSource({
|
|
|
3471
3409
|
...fileCitation.file_name != null ? { title: fileCitation.file_name } : {}
|
|
3472
3410
|
};
|
|
3473
3411
|
}
|
|
3474
|
-
const filename =
|
|
3412
|
+
const filename = fileCitation.file_name ?? basename(uri);
|
|
3475
3413
|
const mediaType = inferDocMediaType(uri);
|
|
3476
3414
|
return {
|
|
3477
3415
|
type: "source",
|
|
3478
3416
|
sourceType: "document",
|
|
3479
3417
|
id: generateId2(),
|
|
3480
3418
|
mediaType,
|
|
3481
|
-
title:
|
|
3419
|
+
title: fileCitation.file_name ?? filename ?? uri,
|
|
3482
3420
|
...filename != null ? { filename } : {}
|
|
3483
3421
|
};
|
|
3484
3422
|
}
|
|
@@ -3503,13 +3441,12 @@ function builtinToolResultToSources({
|
|
|
3503
3441
|
block,
|
|
3504
3442
|
generateId: generateId2
|
|
3505
3443
|
}) {
|
|
3506
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3507
3444
|
const sources = [];
|
|
3508
3445
|
switch (block.type) {
|
|
3509
3446
|
case "url_context_result": {
|
|
3510
|
-
const result =
|
|
3447
|
+
const result = block.result ?? [];
|
|
3511
3448
|
for (const entry of result) {
|
|
3512
|
-
if (
|
|
3449
|
+
if (entry?.url == null || entry.url.length === 0) continue;
|
|
3513
3450
|
if (entry.status != null && entry.status !== "success") continue;
|
|
3514
3451
|
sources.push({
|
|
3515
3452
|
type: "source",
|
|
@@ -3521,9 +3458,9 @@ function builtinToolResultToSources({
|
|
|
3521
3458
|
break;
|
|
3522
3459
|
}
|
|
3523
3460
|
case "google_search_result": {
|
|
3524
|
-
const result =
|
|
3461
|
+
const result = block.result ?? [];
|
|
3525
3462
|
for (const entry of result) {
|
|
3526
|
-
const url = entry
|
|
3463
|
+
const url = entry?.url;
|
|
3527
3464
|
if (url == null || url.length === 0) continue;
|
|
3528
3465
|
sources.push({
|
|
3529
3466
|
type: "source",
|
|
@@ -3536,9 +3473,9 @@ function builtinToolResultToSources({
|
|
|
3536
3473
|
break;
|
|
3537
3474
|
}
|
|
3538
3475
|
case "google_maps_result": {
|
|
3539
|
-
const result =
|
|
3476
|
+
const result = block.result ?? [];
|
|
3540
3477
|
for (const entry of result) {
|
|
3541
|
-
for (const place of
|
|
3478
|
+
for (const place of entry.places ?? []) {
|
|
3542
3479
|
if (place.url == null || place.url.length === 0) continue;
|
|
3543
3480
|
sources.push({
|
|
3544
3481
|
type: "source",
|
|
@@ -3552,11 +3489,11 @@ function builtinToolResultToSources({
|
|
|
3552
3489
|
break;
|
|
3553
3490
|
}
|
|
3554
3491
|
case "file_search_result": {
|
|
3555
|
-
const result =
|
|
3492
|
+
const result = block.result ?? [];
|
|
3556
3493
|
for (const raw of result) {
|
|
3557
3494
|
if (raw == null || typeof raw !== "object") continue;
|
|
3558
3495
|
const entry = raw;
|
|
3559
|
-
const uri =
|
|
3496
|
+
const uri = entry.url ?? entry.document_uri ?? entry.file_name;
|
|
3560
3497
|
if (uri == null || uri.length === 0) continue;
|
|
3561
3498
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3562
3499
|
sources.push({
|
|
@@ -3568,14 +3505,14 @@ function builtinToolResultToSources({
|
|
|
3568
3505
|
});
|
|
3569
3506
|
continue;
|
|
3570
3507
|
}
|
|
3571
|
-
const filename =
|
|
3508
|
+
const filename = entry.file_name ?? basename(uri);
|
|
3572
3509
|
const mediaType = inferDocMediaType(uri);
|
|
3573
3510
|
sources.push({
|
|
3574
3511
|
type: "source",
|
|
3575
3512
|
sourceType: "document",
|
|
3576
3513
|
id: generateId2(),
|
|
3577
3514
|
mediaType,
|
|
3578
|
-
title:
|
|
3515
|
+
title: entry.title ?? entry.file_name ?? filename ?? uri,
|
|
3579
3516
|
...filename != null ? { filename } : {}
|
|
3580
3517
|
});
|
|
3581
3518
|
}
|
|
@@ -3590,14 +3527,13 @@ function annotationsToSources({
|
|
|
3590
3527
|
annotations,
|
|
3591
3528
|
generateId: generateId2
|
|
3592
3529
|
}) {
|
|
3593
|
-
var _a;
|
|
3594
3530
|
if (annotations == null) return [];
|
|
3595
3531
|
const seen = /* @__PURE__ */ new Set();
|
|
3596
3532
|
const sources = [];
|
|
3597
3533
|
for (const annotation of annotations) {
|
|
3598
3534
|
const source = annotationToSource({ annotation, generateId: generateId2 });
|
|
3599
3535
|
if (source == null) continue;
|
|
3600
|
-
const key = source.sourceType === "url" ? `url:${source.url}` : `doc:${
|
|
3536
|
+
const key = source.sourceType === "url" ? `url:${source.url}` : `doc:${source.filename ?? source.title}`;
|
|
3601
3537
|
if (seen.has(key)) continue;
|
|
3602
3538
|
seen.add(key);
|
|
3603
3539
|
sources.push(source);
|
|
@@ -3664,15 +3600,13 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3664
3600
|
const openBlocks = /* @__PURE__ */ new Map();
|
|
3665
3601
|
const emittedSourceKeys = /* @__PURE__ */ new Set();
|
|
3666
3602
|
function sourceKey(source) {
|
|
3667
|
-
|
|
3668
|
-
return source.sourceType === "url" ? `url:${source.url}` : `doc:${(_a = source.filename) != null ? _a : source.title}`;
|
|
3603
|
+
return source.sourceType === "url" ? `url:${source.url}` : `doc:${source.filename ?? source.title}`;
|
|
3669
3604
|
}
|
|
3670
3605
|
return new TransformStream({
|
|
3671
3606
|
start(controller) {
|
|
3672
3607
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3673
3608
|
},
|
|
3674
3609
|
transform(chunk, controller) {
|
|
3675
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
3676
3610
|
if (includeRawChunks) {
|
|
3677
3611
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3678
3612
|
}
|
|
@@ -3687,8 +3621,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3687
3621
|
case "interaction.created": {
|
|
3688
3622
|
const event = value;
|
|
3689
3623
|
const interaction = event.interaction;
|
|
3690
|
-
interactionId =
|
|
3691
|
-
const created = interaction
|
|
3624
|
+
interactionId = interaction?.id != null && interaction.id.length > 0 ? interaction.id : void 0;
|
|
3625
|
+
const created = interaction?.created;
|
|
3692
3626
|
let timestamp;
|
|
3693
3627
|
if (typeof created === "string") {
|
|
3694
3628
|
const parsed = new Date(created);
|
|
@@ -3699,7 +3633,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3699
3633
|
controller.enqueue({
|
|
3700
3634
|
type: "response-metadata",
|
|
3701
3635
|
...interactionId != null ? { id: interactionId } : {},
|
|
3702
|
-
modelId: interaction
|
|
3636
|
+
modelId: interaction?.model,
|
|
3703
3637
|
...timestamp ? { timestamp } : {}
|
|
3704
3638
|
});
|
|
3705
3639
|
break;
|
|
@@ -3708,11 +3642,11 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3708
3642
|
const event = value;
|
|
3709
3643
|
const step = event.step;
|
|
3710
3644
|
const index = event.index;
|
|
3711
|
-
const blockId = `${interactionId
|
|
3712
|
-
const stepType = step
|
|
3645
|
+
const blockId = `${interactionId ?? "interaction"}:${index}`;
|
|
3646
|
+
const stepType = step?.type;
|
|
3713
3647
|
if (stepType === "model_output") {
|
|
3714
|
-
const initial =
|
|
3715
|
-
if (
|
|
3648
|
+
const initial = step?.content?.[0];
|
|
3649
|
+
if (initial?.type === "text") {
|
|
3716
3650
|
openBlocks.set(index, {
|
|
3717
3651
|
kind: "text",
|
|
3718
3652
|
id: blockId,
|
|
@@ -3729,7 +3663,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3729
3663
|
emittedSourceKeys.add(key);
|
|
3730
3664
|
controller.enqueue(source);
|
|
3731
3665
|
}
|
|
3732
|
-
} else if (
|
|
3666
|
+
} else if (initial?.type === "image") {
|
|
3733
3667
|
openBlocks.set(index, {
|
|
3734
3668
|
kind: "image",
|
|
3735
3669
|
id: blockId,
|
|
@@ -3744,16 +3678,16 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3744
3678
|
});
|
|
3745
3679
|
}
|
|
3746
3680
|
} else if (stepType === "thought") {
|
|
3747
|
-
const signature = step
|
|
3681
|
+
const signature = step?.signature;
|
|
3748
3682
|
openBlocks.set(index, {
|
|
3749
3683
|
kind: "reasoning",
|
|
3750
3684
|
id: blockId,
|
|
3751
3685
|
...signature != null ? { signature } : {}
|
|
3752
3686
|
});
|
|
3753
3687
|
controller.enqueue({ type: "reasoning-start", id: blockId });
|
|
3754
|
-
if (Array.isArray(step
|
|
3688
|
+
if (Array.isArray(step?.summary)) {
|
|
3755
3689
|
for (const item of step.summary) {
|
|
3756
|
-
if (
|
|
3690
|
+
if (item?.type === "text" && typeof item.text === "string") {
|
|
3757
3691
|
controller.enqueue({
|
|
3758
3692
|
type: "reasoning-delta",
|
|
3759
3693
|
id: blockId,
|
|
@@ -3764,12 +3698,12 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3764
3698
|
}
|
|
3765
3699
|
} else if (stepType === "processing_call" || stepType === "processing_result") {
|
|
3766
3700
|
const google = {};
|
|
3767
|
-
if (
|
|
3701
|
+
if (step?.signature != null) google.signature = step.signature;
|
|
3768
3702
|
if (interactionId != null) google.interactionId = interactionId;
|
|
3769
3703
|
if (stepType === "processing_call") {
|
|
3770
|
-
google.processingId =
|
|
3704
|
+
google.processingId = step?.id || blockId;
|
|
3771
3705
|
} else {
|
|
3772
|
-
google.processingCallId =
|
|
3706
|
+
google.processingCallId = step?.call_id || blockId;
|
|
3773
3707
|
}
|
|
3774
3708
|
openBlocks.set(index, {
|
|
3775
3709
|
kind: "custom",
|
|
@@ -3778,8 +3712,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3778
3712
|
google
|
|
3779
3713
|
});
|
|
3780
3714
|
} else if (stepType === "function_call") {
|
|
3781
|
-
const toolCallId =
|
|
3782
|
-
const toolName =
|
|
3715
|
+
const toolCallId = step?.id || blockId;
|
|
3716
|
+
const toolName = step?.name ?? "unknown";
|
|
3783
3717
|
hasFunctionCall = true;
|
|
3784
3718
|
const state = {
|
|
3785
3719
|
kind: "function_call",
|
|
@@ -3787,7 +3721,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3787
3721
|
toolCallId,
|
|
3788
3722
|
toolName,
|
|
3789
3723
|
argumentsAccum: "",
|
|
3790
|
-
...
|
|
3724
|
+
...step?.signature != null ? { signature: step.signature } : {}
|
|
3791
3725
|
};
|
|
3792
3726
|
openBlocks.set(index, state);
|
|
3793
3727
|
controller.enqueue({
|
|
@@ -3796,29 +3730,29 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3796
3730
|
toolName
|
|
3797
3731
|
});
|
|
3798
3732
|
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
3799
|
-
const toolName = stepType === "mcp_server_tool_call" ?
|
|
3800
|
-
const toolCallId =
|
|
3733
|
+
const toolName = stepType === "mcp_server_tool_call" ? step?.name ?? "mcp_server_tool" : builtinToolNameFromCallType(stepType);
|
|
3734
|
+
const toolCallId = step?.id || blockId;
|
|
3801
3735
|
const state = {
|
|
3802
3736
|
kind: "builtin_tool_call",
|
|
3803
3737
|
id: blockId,
|
|
3804
3738
|
blockType: stepType,
|
|
3805
3739
|
toolCallId,
|
|
3806
3740
|
toolName,
|
|
3807
|
-
arguments:
|
|
3741
|
+
arguments: step?.arguments ?? {},
|
|
3808
3742
|
callEmitted: false
|
|
3809
3743
|
};
|
|
3810
3744
|
openBlocks.set(index, state);
|
|
3811
3745
|
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
3812
|
-
const toolName = stepType === "mcp_server_tool_result" ?
|
|
3813
|
-
const callId =
|
|
3746
|
+
const toolName = stepType === "mcp_server_tool_result" ? step?.name ?? "mcp_server_tool" : builtinToolNameFromResultType(stepType);
|
|
3747
|
+
const callId = step?.call_id || blockId;
|
|
3814
3748
|
const state = {
|
|
3815
3749
|
kind: "builtin_tool_result",
|
|
3816
3750
|
id: blockId,
|
|
3817
3751
|
blockType: stepType,
|
|
3818
3752
|
callId,
|
|
3819
3753
|
toolName,
|
|
3820
|
-
result:
|
|
3821
|
-
...
|
|
3754
|
+
result: step?.result ?? null,
|
|
3755
|
+
...step?.is_error != null ? { isError: step.is_error } : {},
|
|
3822
3756
|
resultEmitted: false
|
|
3823
3757
|
};
|
|
3824
3758
|
openBlocks.set(index, state);
|
|
@@ -3831,7 +3765,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3831
3765
|
const event = value;
|
|
3832
3766
|
let open = openBlocks.get(event.index);
|
|
3833
3767
|
if (open == null) break;
|
|
3834
|
-
const dtype =
|
|
3768
|
+
const dtype = event.delta?.type;
|
|
3835
3769
|
if (open.kind === "pending_model_output") {
|
|
3836
3770
|
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
3837
3771
|
const promoted = {
|
|
@@ -3849,17 +3783,17 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3849
3783
|
const google = {};
|
|
3850
3784
|
if (interactionId != null) google.interactionId = interactionId;
|
|
3851
3785
|
const providerMetadata = Object.keys(google).length > 0 ? { google } : void 0;
|
|
3852
|
-
if (
|
|
3786
|
+
if (imageDelta?.data != null && imageDelta.data.length > 0) {
|
|
3853
3787
|
controller.enqueue({
|
|
3854
3788
|
type: "file",
|
|
3855
|
-
mediaType:
|
|
3789
|
+
mediaType: imageDelta.mime_type ?? "image/png",
|
|
3856
3790
|
data: { type: "data", data: imageDelta.data },
|
|
3857
3791
|
...providerMetadata ? { providerMetadata } : {}
|
|
3858
3792
|
});
|
|
3859
|
-
} else if (
|
|
3793
|
+
} else if (imageDelta?.uri != null && imageDelta.uri.length > 0) {
|
|
3860
3794
|
controller.enqueue({
|
|
3861
3795
|
type: "file",
|
|
3862
|
-
mediaType:
|
|
3796
|
+
mediaType: imageDelta.mime_type ?? "image/png",
|
|
3863
3797
|
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
3864
3798
|
...providerMetadata ? { providerMetadata } : {}
|
|
3865
3799
|
});
|
|
@@ -3875,17 +3809,17 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3875
3809
|
const google = {};
|
|
3876
3810
|
if (interactionId != null) google.interactionId = interactionId;
|
|
3877
3811
|
const providerMetadata = Object.keys(google).length > 0 ? { google } : void 0;
|
|
3878
|
-
if (
|
|
3812
|
+
if (videoDelta?.data != null && videoDelta.data.length > 0) {
|
|
3879
3813
|
controller.enqueue({
|
|
3880
3814
|
type: "file",
|
|
3881
|
-
mediaType:
|
|
3815
|
+
mediaType: videoDelta.mime_type ?? "video/mp4",
|
|
3882
3816
|
data: { type: "data", data: videoDelta.data },
|
|
3883
3817
|
...providerMetadata ? { providerMetadata } : {}
|
|
3884
3818
|
});
|
|
3885
|
-
} else if (
|
|
3819
|
+
} else if (videoDelta?.uri != null && videoDelta.uri.length > 0) {
|
|
3886
3820
|
controller.enqueue({
|
|
3887
3821
|
type: "file",
|
|
3888
|
-
mediaType:
|
|
3822
|
+
mediaType: videoDelta.mime_type ?? "video/mp4",
|
|
3889
3823
|
data: { type: "url", url: new URL(videoDelta.uri) },
|
|
3890
3824
|
...providerMetadata ? { providerMetadata } : {}
|
|
3891
3825
|
});
|
|
@@ -3893,7 +3827,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3893
3827
|
break;
|
|
3894
3828
|
}
|
|
3895
3829
|
const delta = event.delta;
|
|
3896
|
-
if (open.kind === "custom" && (
|
|
3830
|
+
if (open.kind === "custom" && (delta?.type === "processing_call" || delta?.type === "processing_result")) {
|
|
3897
3831
|
if (delta.signature != null)
|
|
3898
3832
|
open.google.signature = delta.signature;
|
|
3899
3833
|
if (delta.type === "processing_call" && delta.id != null && delta.id.length > 0) {
|
|
@@ -3902,8 +3836,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3902
3836
|
if (delta.type === "processing_result" && delta.call_id != null && delta.call_id.length > 0) {
|
|
3903
3837
|
open.google.processingCallId = delta.call_id;
|
|
3904
3838
|
}
|
|
3905
|
-
} else if (open.kind === "text" &&
|
|
3906
|
-
const text =
|
|
3839
|
+
} else if (open.kind === "text" && delta?.type === "text") {
|
|
3840
|
+
const text = delta.text ?? "";
|
|
3907
3841
|
if (text.length > 0) {
|
|
3908
3842
|
controller.enqueue({
|
|
3909
3843
|
type: "text-delta",
|
|
@@ -3911,7 +3845,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3911
3845
|
delta: text
|
|
3912
3846
|
});
|
|
3913
3847
|
}
|
|
3914
|
-
} else if (open.kind === "text" && (
|
|
3848
|
+
} else if (open.kind === "text" && (delta?.type === "text_annotation" || delta?.type === "text_annotation_delta")) {
|
|
3915
3849
|
const sources = annotationsToSources({
|
|
3916
3850
|
annotations: delta.annotations,
|
|
3917
3851
|
generateId: generateId2
|
|
@@ -3923,27 +3857,27 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3923
3857
|
open.emittedSourceKeys.add(key);
|
|
3924
3858
|
controller.enqueue(source);
|
|
3925
3859
|
}
|
|
3926
|
-
} else if (open.kind === "image" &&
|
|
3860
|
+
} else if (open.kind === "image" && delta?.type === "image") {
|
|
3927
3861
|
if (delta.data != null) open.data = delta.data;
|
|
3928
3862
|
if (delta.mime_type != null) open.mimeType = delta.mime_type;
|
|
3929
3863
|
if (delta.uri != null) open.uri = delta.uri;
|
|
3930
3864
|
} else if (open.kind === "reasoning") {
|
|
3931
|
-
if (
|
|
3865
|
+
if (delta?.type === "thought_summary") {
|
|
3932
3866
|
const item = delta.content;
|
|
3933
|
-
if (
|
|
3867
|
+
if (item?.type === "text" && typeof item.text === "string") {
|
|
3934
3868
|
controller.enqueue({
|
|
3935
3869
|
type: "reasoning-delta",
|
|
3936
3870
|
id: open.id,
|
|
3937
3871
|
delta: item.text
|
|
3938
3872
|
});
|
|
3939
3873
|
}
|
|
3940
|
-
} else if (
|
|
3874
|
+
} else if (delta?.type === "thought_signature") {
|
|
3941
3875
|
const signature = delta.signature;
|
|
3942
3876
|
if (signature != null) {
|
|
3943
3877
|
open.signature = signature;
|
|
3944
3878
|
}
|
|
3945
3879
|
}
|
|
3946
|
-
} else if (open.kind === "function_call" &&
|
|
3880
|
+
} else if (open.kind === "function_call" && delta?.type === "arguments_delta") {
|
|
3947
3881
|
const slice = typeof delta.arguments === "string" ? delta.arguments : "";
|
|
3948
3882
|
if (slice.length > 0) {
|
|
3949
3883
|
open.argumentsAccum += slice;
|
|
@@ -3960,7 +3894,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3960
3894
|
open.signature = delta.signature;
|
|
3961
3895
|
}
|
|
3962
3896
|
hasFunctionCall = true;
|
|
3963
|
-
} else if (open.kind === "builtin_tool_call" &&
|
|
3897
|
+
} else if (open.kind === "builtin_tool_call" && delta?.type === open.blockType) {
|
|
3964
3898
|
if (delta.id != null && delta.id.length > 0) {
|
|
3965
3899
|
open.toolCallId = delta.id;
|
|
3966
3900
|
}
|
|
@@ -3970,7 +3904,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3970
3904
|
if (delta.name != null && open.blockType === "mcp_server_tool_call") {
|
|
3971
3905
|
open.toolName = delta.name;
|
|
3972
3906
|
}
|
|
3973
|
-
} else if (open.kind === "builtin_tool_result" &&
|
|
3907
|
+
} else if (open.kind === "builtin_tool_result" && delta?.type === open.blockType) {
|
|
3974
3908
|
if (delta.call_id != null && delta.call_id.length > 0) {
|
|
3975
3909
|
open.callId = delta.call_id;
|
|
3976
3910
|
}
|
|
@@ -4010,14 +3944,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4010
3944
|
if (open.data != null && open.data.length > 0) {
|
|
4011
3945
|
controller.enqueue({
|
|
4012
3946
|
type: "file",
|
|
4013
|
-
mediaType:
|
|
3947
|
+
mediaType: open.mimeType ?? "image/png",
|
|
4014
3948
|
data: { type: "data", data: open.data },
|
|
4015
3949
|
...providerMetadata ? { providerMetadata } : {}
|
|
4016
3950
|
});
|
|
4017
3951
|
} else if (open.uri != null && open.uri.length > 0) {
|
|
4018
3952
|
controller.enqueue({
|
|
4019
3953
|
type: "file",
|
|
4020
|
-
mediaType:
|
|
3954
|
+
mediaType: open.mimeType ?? "image/png",
|
|
4021
3955
|
data: { type: "url", url: new URL(open.uri) },
|
|
4022
3956
|
...providerMetadata ? { providerMetadata } : {}
|
|
4023
3957
|
});
|
|
@@ -4050,7 +3984,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4050
3984
|
type: "tool-call",
|
|
4051
3985
|
toolCallId: open.toolCallId,
|
|
4052
3986
|
toolName: open.toolName,
|
|
4053
|
-
input: JSON.stringify(
|
|
3987
|
+
input: JSON.stringify(open.arguments ?? {}),
|
|
4054
3988
|
providerExecuted: true
|
|
4055
3989
|
});
|
|
4056
3990
|
open.callEmitted = true;
|
|
@@ -4059,7 +3993,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4059
3993
|
type: "tool-result",
|
|
4060
3994
|
toolCallId: open.callId,
|
|
4061
3995
|
toolName: open.toolName,
|
|
4062
|
-
result:
|
|
3996
|
+
result: open.result ?? null
|
|
4063
3997
|
});
|
|
4064
3998
|
open.resultEmitted = true;
|
|
4065
3999
|
const sources = builtinToolResultToSources({
|
|
@@ -4096,16 +4030,16 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4096
4030
|
case "interaction.completed": {
|
|
4097
4031
|
const event = value;
|
|
4098
4032
|
const interaction = event.interaction;
|
|
4099
|
-
if (
|
|
4033
|
+
if (interaction?.id != null && interaction.id.length > 0) {
|
|
4100
4034
|
interactionId = interaction.id;
|
|
4101
4035
|
}
|
|
4102
|
-
if (
|
|
4036
|
+
if (interaction?.status != null) {
|
|
4103
4037
|
finishStatus = interaction.status;
|
|
4104
4038
|
}
|
|
4105
|
-
if (
|
|
4039
|
+
if (interaction?.usage != null) {
|
|
4106
4040
|
usage = interaction.usage;
|
|
4107
4041
|
}
|
|
4108
|
-
if (
|
|
4042
|
+
if (interaction?.service_tier != null) {
|
|
4109
4043
|
serviceTier = interaction.service_tier;
|
|
4110
4044
|
}
|
|
4111
4045
|
break;
|
|
@@ -4116,9 +4050,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4116
4050
|
controller.enqueue({
|
|
4117
4051
|
type: "error",
|
|
4118
4052
|
error: createProviderStreamError({
|
|
4119
|
-
message:
|
|
4053
|
+
message: event.error?.message ?? "Unknown interaction error",
|
|
4120
4054
|
type: event.event_type,
|
|
4121
|
-
code:
|
|
4055
|
+
code: event.error?.code ?? void 0,
|
|
4122
4056
|
data: event
|
|
4123
4057
|
})
|
|
4124
4058
|
});
|
|
@@ -4169,7 +4103,6 @@ function convertToGoogleInteractionsInput({
|
|
|
4169
4103
|
store,
|
|
4170
4104
|
mediaResolution
|
|
4171
4105
|
}) {
|
|
4172
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4173
4106
|
const warnings = [];
|
|
4174
4107
|
const incoherentCombo = previousInteractionId != null && store === false;
|
|
4175
4108
|
const shouldCompact = previousInteractionId != null && store !== false;
|
|
@@ -4226,7 +4159,7 @@ function convertToGoogleInteractionsInput({
|
|
|
4226
4159
|
pendingModelOutput.push({ type: "text", text: part.text });
|
|
4227
4160
|
} else if (part.type === "reasoning") {
|
|
4228
4161
|
flushModelOutput();
|
|
4229
|
-
const signature =
|
|
4162
|
+
const signature = part.providerOptions?.google?.signature;
|
|
4230
4163
|
steps.push({
|
|
4231
4164
|
type: "thought",
|
|
4232
4165
|
...signature != null ? { signature } : {},
|
|
@@ -4243,15 +4176,15 @@ function convertToGoogleInteractionsInput({
|
|
|
4243
4176
|
}
|
|
4244
4177
|
} else if (part.type === "custom") {
|
|
4245
4178
|
flushModelOutput();
|
|
4246
|
-
const google =
|
|
4247
|
-
const signature = typeof
|
|
4248
|
-
if (part.kind === "google.processing_call" && typeof
|
|
4179
|
+
const google = part.providerOptions?.google;
|
|
4180
|
+
const signature = typeof google?.signature === "string" ? google.signature : void 0;
|
|
4181
|
+
if (part.kind === "google.processing_call" && typeof google?.processingId === "string") {
|
|
4249
4182
|
steps.push({
|
|
4250
4183
|
type: "processing_call",
|
|
4251
4184
|
id: google.processingId,
|
|
4252
4185
|
...signature != null ? { signature } : {}
|
|
4253
4186
|
});
|
|
4254
|
-
} else if (part.kind === "google.processing_result" && typeof
|
|
4187
|
+
} else if (part.kind === "google.processing_result" && typeof google?.processingCallId === "string") {
|
|
4255
4188
|
steps.push({
|
|
4256
4189
|
type: "processing_result",
|
|
4257
4190
|
call_id: google.processingCallId,
|
|
@@ -4265,8 +4198,8 @@ function convertToGoogleInteractionsInput({
|
|
|
4265
4198
|
}
|
|
4266
4199
|
} else if (part.type === "tool-call") {
|
|
4267
4200
|
flushModelOutput();
|
|
4268
|
-
const signature =
|
|
4269
|
-
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) :
|
|
4201
|
+
const signature = part.providerOptions?.google?.signature;
|
|
4202
|
+
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : part.input ?? {};
|
|
4270
4203
|
steps.push({
|
|
4271
4204
|
type: "function_call",
|
|
4272
4205
|
id: part.toolCallId,
|
|
@@ -4298,7 +4231,7 @@ function convertToGoogleInteractionsInput({
|
|
|
4298
4231
|
toolCallId: part.toolCallId,
|
|
4299
4232
|
toolName: part.toolName,
|
|
4300
4233
|
output: part.output,
|
|
4301
|
-
signature:
|
|
4234
|
+
signature: part.providerOptions?.google?.signature,
|
|
4302
4235
|
warnings
|
|
4303
4236
|
});
|
|
4304
4237
|
content.push(block);
|
|
@@ -4391,8 +4324,7 @@ function getVideoProcessingField({
|
|
|
4391
4324
|
part,
|
|
4392
4325
|
warnings
|
|
4393
4326
|
}) {
|
|
4394
|
-
|
|
4395
|
-
const processing = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.processing;
|
|
4327
|
+
const processing = part.providerOptions?.google?.processing;
|
|
4396
4328
|
if (processing == null) {
|
|
4397
4329
|
return {};
|
|
4398
4330
|
}
|
|
@@ -4404,8 +4336,8 @@ function getVideoProcessingField({
|
|
|
4404
4336
|
return {
|
|
4405
4337
|
processing: {
|
|
4406
4338
|
type: "static",
|
|
4407
|
-
...typeof config.startOffset === "number" ? { start_offset: config.startOffset } : {},
|
|
4408
|
-
...typeof config.endOffset === "number" ? { end_offset: config.endOffset } : {},
|
|
4339
|
+
...typeof config.startOffset === "number" ? { start_offset: `${config.startOffset}s` } : {},
|
|
4340
|
+
...typeof config.endOffset === "number" ? { end_offset: `${config.endOffset}s` } : {},
|
|
4409
4341
|
...typeof config.fps === "number" ? { fps: config.fps } : {}
|
|
4410
4342
|
}
|
|
4411
4343
|
};
|
|
@@ -4425,8 +4357,7 @@ function compactPromptForPreviousInteraction({
|
|
|
4425
4357
|
for (const message of prompt) {
|
|
4426
4358
|
if (message.role === "assistant") {
|
|
4427
4359
|
const matchesLinkedInteraction = message.content.some((part) => {
|
|
4428
|
-
|
|
4429
|
-
const partInteractionId = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.interactionId;
|
|
4360
|
+
const partInteractionId = part.providerOptions?.google?.interactionId;
|
|
4430
4361
|
return partInteractionId === previousInteractionId;
|
|
4431
4362
|
});
|
|
4432
4363
|
if (matchesLinkedInteraction) {
|
|
@@ -4467,7 +4398,7 @@ function safeParseToolArgs(input) {
|
|
|
4467
4398
|
return parsed;
|
|
4468
4399
|
}
|
|
4469
4400
|
return { value: parsed };
|
|
4470
|
-
} catch
|
|
4401
|
+
} catch {
|
|
4471
4402
|
return { value: input };
|
|
4472
4403
|
}
|
|
4473
4404
|
}
|
|
@@ -4478,7 +4409,6 @@ function convertToolResultPart({
|
|
|
4478
4409
|
signature,
|
|
4479
4410
|
warnings
|
|
4480
4411
|
}) {
|
|
4481
|
-
var _a;
|
|
4482
4412
|
const base = {
|
|
4483
4413
|
type: "function_result",
|
|
4484
4414
|
call_id: toolCallId,
|
|
@@ -4498,7 +4428,7 @@ function convertToolResultPart({
|
|
|
4498
4428
|
return {
|
|
4499
4429
|
...base,
|
|
4500
4430
|
is_error: true,
|
|
4501
|
-
result:
|
|
4431
|
+
result: output.reason ?? "Tool execution denied by user."
|
|
4502
4432
|
};
|
|
4503
4433
|
case "content": {
|
|
4504
4434
|
const blocks = [];
|
|
@@ -5189,7 +5119,6 @@ function parseGoogleInteractionsOutputs({
|
|
|
5189
5119
|
generateId: generateId2,
|
|
5190
5120
|
interactionId
|
|
5191
5121
|
}) {
|
|
5192
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5193
5122
|
const content = [];
|
|
5194
5123
|
let hasFunctionCall = false;
|
|
5195
5124
|
if (steps == null) {
|
|
@@ -5204,12 +5133,12 @@ function parseGoogleInteractionsOutputs({
|
|
|
5204
5133
|
break;
|
|
5205
5134
|
}
|
|
5206
5135
|
case "model_output": {
|
|
5207
|
-
const blocks =
|
|
5136
|
+
const blocks = step.content ?? [];
|
|
5208
5137
|
for (const block of blocks) {
|
|
5209
5138
|
if (block == null || typeof block !== "object") continue;
|
|
5210
5139
|
const blockType = block.type;
|
|
5211
5140
|
if (blockType === "text") {
|
|
5212
|
-
const text =
|
|
5141
|
+
const text = block.text ?? "";
|
|
5213
5142
|
const annotations = block.annotations;
|
|
5214
5143
|
content.push({
|
|
5215
5144
|
type: "text",
|
|
@@ -5225,14 +5154,14 @@ function parseGoogleInteractionsOutputs({
|
|
|
5225
5154
|
if (image.data != null && image.data.length > 0) {
|
|
5226
5155
|
content.push({
|
|
5227
5156
|
type: "file",
|
|
5228
|
-
mediaType:
|
|
5157
|
+
mediaType: image.mime_type ?? "image/png",
|
|
5229
5158
|
data: { type: "data", data: image.data },
|
|
5230
5159
|
...googleProviderMetadata({ interactionId })
|
|
5231
5160
|
});
|
|
5232
5161
|
} else if (image.uri != null && image.uri.length > 0) {
|
|
5233
5162
|
content.push({
|
|
5234
5163
|
type: "file",
|
|
5235
|
-
mediaType:
|
|
5164
|
+
mediaType: image.mime_type ?? "image/png",
|
|
5236
5165
|
data: { type: "url", url: new URL(image.uri) },
|
|
5237
5166
|
...googleProviderMetadata({ interactionId })
|
|
5238
5167
|
});
|
|
@@ -5242,14 +5171,14 @@ function parseGoogleInteractionsOutputs({
|
|
|
5242
5171
|
if (video.data != null && video.data.length > 0) {
|
|
5243
5172
|
content.push({
|
|
5244
5173
|
type: "file",
|
|
5245
|
-
mediaType:
|
|
5174
|
+
mediaType: video.mime_type ?? "video/mp4",
|
|
5246
5175
|
data: { type: "data", data: video.data },
|
|
5247
5176
|
...googleProviderMetadata({ interactionId })
|
|
5248
5177
|
});
|
|
5249
5178
|
} else if (video.uri != null && video.uri.length > 0) {
|
|
5250
5179
|
content.push({
|
|
5251
5180
|
type: "file",
|
|
5252
|
-
mediaType:
|
|
5181
|
+
mediaType: video.mime_type ?? "video/mp4",
|
|
5253
5182
|
data: { type: "url", url: new URL(video.uri) },
|
|
5254
5183
|
...googleProviderMetadata({ interactionId })
|
|
5255
5184
|
});
|
|
@@ -5262,7 +5191,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5262
5191
|
const thought = step;
|
|
5263
5192
|
const summary = Array.isArray(thought.summary) ? thought.summary : [];
|
|
5264
5193
|
const text = summary.filter(
|
|
5265
|
-
(item) =>
|
|
5194
|
+
(item) => item?.type === "text" && typeof item.text === "string"
|
|
5266
5195
|
).map((item) => item.text).join("\n");
|
|
5267
5196
|
content.push({
|
|
5268
5197
|
type: "reasoning",
|
|
@@ -5309,7 +5238,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5309
5238
|
type: "tool-call",
|
|
5310
5239
|
toolCallId: call.id,
|
|
5311
5240
|
toolName: call.name,
|
|
5312
|
-
input: JSON.stringify(
|
|
5241
|
+
input: JSON.stringify(call.arguments ?? {}),
|
|
5313
5242
|
...googleProviderMetadata({
|
|
5314
5243
|
signature: call.signature,
|
|
5315
5244
|
interactionId
|
|
@@ -5320,8 +5249,8 @@ function parseGoogleInteractionsOutputs({
|
|
|
5320
5249
|
default: {
|
|
5321
5250
|
if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
|
|
5322
5251
|
const call = step;
|
|
5323
|
-
const toolName = type === "mcp_server_tool_call" ?
|
|
5324
|
-
const input = JSON.stringify(
|
|
5252
|
+
const toolName = type === "mcp_server_tool_call" ? call.name ?? "mcp_server_tool" : builtinToolNameFromCallType2(type);
|
|
5253
|
+
const input = JSON.stringify(call.arguments ?? {});
|
|
5325
5254
|
content.push({
|
|
5326
5255
|
type: "tool-call",
|
|
5327
5256
|
toolCallId: call.id || generateId2(),
|
|
@@ -5331,12 +5260,12 @@ function parseGoogleInteractionsOutputs({
|
|
|
5331
5260
|
});
|
|
5332
5261
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
5333
5262
|
const result = step;
|
|
5334
|
-
const toolName = type === "mcp_server_tool_result" ?
|
|
5263
|
+
const toolName = type === "mcp_server_tool_result" ? result.name ?? "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
5335
5264
|
content.push({
|
|
5336
5265
|
type: "tool-result",
|
|
5337
5266
|
toolCallId: result.call_id || generateId2(),
|
|
5338
5267
|
toolName,
|
|
5339
|
-
result:
|
|
5268
|
+
result: result.result ?? null
|
|
5340
5269
|
});
|
|
5341
5270
|
const sources = builtinToolResultToSources({
|
|
5342
5271
|
block: step,
|
|
@@ -5389,9 +5318,9 @@ async function cancelGoogleInteraction({
|
|
|
5389
5318
|
});
|
|
5390
5319
|
try {
|
|
5391
5320
|
await response.text();
|
|
5392
|
-
} catch
|
|
5321
|
+
} catch {
|
|
5393
5322
|
}
|
|
5394
|
-
} catch
|
|
5323
|
+
} catch {
|
|
5395
5324
|
}
|
|
5396
5325
|
}
|
|
5397
5326
|
|
|
@@ -5424,7 +5353,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5424
5353
|
const cancelOnServer = () => cancelGoogleInteraction({ baseURL, interactionId, headers, fetch });
|
|
5425
5354
|
try {
|
|
5426
5355
|
while (true) {
|
|
5427
|
-
if (abortSignal
|
|
5356
|
+
if (abortSignal?.aborted) {
|
|
5428
5357
|
await cancelOnServer();
|
|
5429
5358
|
throw new DOMException("Polling was aborted", "AbortError");
|
|
5430
5359
|
}
|
|
@@ -5467,9 +5396,8 @@ function prepareGoogleInteractionsTools({
|
|
|
5467
5396
|
tools,
|
|
5468
5397
|
toolChoice
|
|
5469
5398
|
}) {
|
|
5470
|
-
var _a, _b, _c, _d;
|
|
5471
5399
|
const toolWarnings = [];
|
|
5472
|
-
const normalized =
|
|
5400
|
+
const normalized = tools?.length ? tools : void 0;
|
|
5473
5401
|
if (normalized == null) {
|
|
5474
5402
|
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
5475
5403
|
}
|
|
@@ -5479,13 +5407,13 @@ function prepareGoogleInteractionsTools({
|
|
|
5479
5407
|
interactionsTools.push({
|
|
5480
5408
|
type: "function",
|
|
5481
5409
|
name: tool.name,
|
|
5482
|
-
description:
|
|
5410
|
+
description: tool.description ?? "",
|
|
5483
5411
|
parameters: tool.inputSchema
|
|
5484
5412
|
});
|
|
5485
5413
|
continue;
|
|
5486
5414
|
}
|
|
5487
5415
|
if (tool.type === "provider") {
|
|
5488
|
-
const args =
|
|
5416
|
+
const args = tool.args ?? {};
|
|
5489
5417
|
switch (tool.id) {
|
|
5490
5418
|
case "google.google_search": {
|
|
5491
5419
|
const searchTypesArg = args.searchTypes;
|
|
@@ -5535,7 +5463,7 @@ function prepareGoogleInteractionsTools({
|
|
|
5535
5463
|
case "google.computer_use": {
|
|
5536
5464
|
interactionsTools.push({
|
|
5537
5465
|
type: "computer_use",
|
|
5538
|
-
environment:
|
|
5466
|
+
environment: args.environment ?? "browser",
|
|
5539
5467
|
...args.excludedPredefinedFunctions != null ? {
|
|
5540
5468
|
excludedPredefinedFunctions: args.excludedPredefinedFunctions
|
|
5541
5469
|
} : {}
|
|
@@ -5553,7 +5481,7 @@ function prepareGoogleInteractionsTools({
|
|
|
5553
5481
|
break;
|
|
5554
5482
|
}
|
|
5555
5483
|
case "google.retrieval": {
|
|
5556
|
-
const vertexAiSearchConfig =
|
|
5484
|
+
const vertexAiSearchConfig = args.vertexAiSearchConfig ?? void 0;
|
|
5557
5485
|
interactionsTools.push({
|
|
5558
5486
|
type: "retrieval",
|
|
5559
5487
|
...args.retrievalTypes != null ? {
|
|
@@ -5757,7 +5685,7 @@ function streamGoogleInteractionEvents({
|
|
|
5757
5685
|
if (abortSignal != null) {
|
|
5758
5686
|
abortSignal.removeEventListener("abort", upstreamAbortHandler);
|
|
5759
5687
|
}
|
|
5760
|
-
currentReader
|
|
5688
|
+
currentReader?.cancel().catch(() => {
|
|
5761
5689
|
});
|
|
5762
5690
|
currentReader = void 0;
|
|
5763
5691
|
if (effectiveSignal.aborted && !complete) {
|
|
@@ -5772,7 +5700,7 @@ function streamGoogleInteractionEvents({
|
|
|
5772
5700
|
},
|
|
5773
5701
|
cancel() {
|
|
5774
5702
|
internalAbort.abort();
|
|
5775
|
-
currentReader
|
|
5703
|
+
currentReader?.cancel().catch(() => {
|
|
5776
5704
|
});
|
|
5777
5705
|
currentReader = void 0;
|
|
5778
5706
|
}
|
|
@@ -5789,7 +5717,6 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
5789
5717
|
}) {
|
|
5790
5718
|
return new ReadableStream({
|
|
5791
5719
|
start(controller) {
|
|
5792
|
-
var _a, _b, _c;
|
|
5793
5720
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5794
5721
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
5795
5722
|
let timestamp;
|
|
@@ -5803,19 +5730,19 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
5803
5730
|
controller.enqueue({
|
|
5804
5731
|
type: "response-metadata",
|
|
5805
5732
|
...interactionId != null ? { id: interactionId } : {},
|
|
5806
|
-
modelId:
|
|
5733
|
+
modelId: response.model ?? void 0,
|
|
5807
5734
|
...timestamp ? { timestamp } : {}
|
|
5808
5735
|
});
|
|
5809
5736
|
if (includeRawChunks) {
|
|
5810
5737
|
controller.enqueue({ type: "raw", rawValue: response });
|
|
5811
5738
|
}
|
|
5812
5739
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
5813
|
-
steps:
|
|
5740
|
+
steps: response.steps ?? null,
|
|
5814
5741
|
generateId: generateId2,
|
|
5815
5742
|
interactionId
|
|
5816
5743
|
});
|
|
5817
5744
|
let blockCounter = 0;
|
|
5818
|
-
const nextBlockId = () => `${interactionId
|
|
5745
|
+
const nextBlockId = () => `${interactionId ?? "agent"}:${blockCounter++}`;
|
|
5819
5746
|
for (const part of content) {
|
|
5820
5747
|
switch (part.type) {
|
|
5821
5748
|
case "text": {
|
|
@@ -5895,7 +5822,7 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
5895
5822
|
break;
|
|
5896
5823
|
}
|
|
5897
5824
|
}
|
|
5898
|
-
const serviceTier =
|
|
5825
|
+
const serviceTier = response.service_tier ?? headerServiceTier;
|
|
5899
5826
|
const finishReason = {
|
|
5900
5827
|
unified: mapGoogleInteractionsFinishReason({
|
|
5901
5828
|
status: response.status,
|
|
@@ -5970,7 +5897,6 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5970
5897
|
};
|
|
5971
5898
|
}
|
|
5972
5899
|
async getArgs(options) {
|
|
5973
|
-
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;
|
|
5974
5900
|
const warnings = [];
|
|
5975
5901
|
const googleOptions = await parseProviderOptions3({
|
|
5976
5902
|
provider: "google",
|
|
@@ -6005,7 +5931,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6005
5931
|
warnings.push(...prepared.toolWarnings);
|
|
6006
5932
|
}
|
|
6007
5933
|
const responseFormatEntries = [];
|
|
6008
|
-
if (
|
|
5934
|
+
if (options.responseFormat?.type === "json") {
|
|
6009
5935
|
if (isAgent) {
|
|
6010
5936
|
warnings.push({
|
|
6011
5937
|
type: "other",
|
|
@@ -6020,41 +5946,41 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6020
5946
|
responseFormatEntries.push(entry);
|
|
6021
5947
|
}
|
|
6022
5948
|
}
|
|
6023
|
-
if (
|
|
5949
|
+
if (googleOptions?.responseFormat != null) {
|
|
6024
5950
|
for (const entry of googleOptions.responseFormat) {
|
|
6025
5951
|
if (entry.type === "text") {
|
|
6026
5952
|
responseFormatEntries.push(
|
|
6027
5953
|
pruneUndefined({
|
|
6028
5954
|
type: "text",
|
|
6029
|
-
mime_type:
|
|
6030
|
-
schema:
|
|
5955
|
+
mime_type: entry.mimeType ?? void 0,
|
|
5956
|
+
schema: entry.schema ?? void 0
|
|
6031
5957
|
})
|
|
6032
5958
|
);
|
|
6033
5959
|
} else if (entry.type === "image") {
|
|
6034
5960
|
responseFormatEntries.push(
|
|
6035
5961
|
pruneUndefined({
|
|
6036
5962
|
type: "image",
|
|
6037
|
-
mime_type:
|
|
6038
|
-
aspect_ratio:
|
|
6039
|
-
image_size:
|
|
5963
|
+
mime_type: entry.mimeType ?? void 0,
|
|
5964
|
+
aspect_ratio: entry.aspectRatio ?? void 0,
|
|
5965
|
+
image_size: entry.imageSize ?? void 0
|
|
6040
5966
|
})
|
|
6041
5967
|
);
|
|
6042
5968
|
} else if (entry.type === "audio") {
|
|
6043
5969
|
responseFormatEntries.push(
|
|
6044
5970
|
pruneUndefined({
|
|
6045
5971
|
type: "audio",
|
|
6046
|
-
mime_type:
|
|
5972
|
+
mime_type: entry.mimeType ?? void 0
|
|
6047
5973
|
})
|
|
6048
5974
|
);
|
|
6049
5975
|
} else if (entry.type === "video") {
|
|
6050
5976
|
responseFormatEntries.push(
|
|
6051
5977
|
pruneUndefined({
|
|
6052
5978
|
type: "video",
|
|
6053
|
-
aspect_ratio:
|
|
6054
|
-
resolution:
|
|
6055
|
-
duration:
|
|
6056
|
-
delivery:
|
|
6057
|
-
gcs_uri:
|
|
5979
|
+
aspect_ratio: entry.aspectRatio ?? void 0,
|
|
5980
|
+
resolution: entry.resolution ?? void 0,
|
|
5981
|
+
duration: entry.duration ?? void 0,
|
|
5982
|
+
delivery: entry.delivery ?? void 0,
|
|
5983
|
+
gcs_uri: entry.gcsUri ?? void 0
|
|
6058
5984
|
})
|
|
6059
5985
|
);
|
|
6060
5986
|
}
|
|
@@ -6066,13 +5992,13 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6066
5992
|
warnings: convWarnings
|
|
6067
5993
|
} = convertToGoogleInteractionsInput({
|
|
6068
5994
|
prompt: options.prompt,
|
|
6069
|
-
previousInteractionId:
|
|
6070
|
-
store:
|
|
6071
|
-
mediaResolution:
|
|
5995
|
+
previousInteractionId: googleOptions?.previousInteractionId ?? void 0,
|
|
5996
|
+
store: googleOptions?.store ?? void 0,
|
|
5997
|
+
mediaResolution: googleOptions?.mediaResolution ?? void 0
|
|
6072
5998
|
});
|
|
6073
5999
|
warnings.push(...convWarnings);
|
|
6074
6000
|
let systemInstruction = convertedSystemInstruction;
|
|
6075
|
-
const optionSystemInstruction =
|
|
6001
|
+
const optionSystemInstruction = googleOptions?.systemInstruction ?? void 0;
|
|
6076
6002
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
6077
6003
|
warnings.push({
|
|
6078
6004
|
type: "other",
|
|
@@ -6097,12 +6023,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6097
6023
|
}
|
|
6098
6024
|
if (options.maxOutputTokens != null)
|
|
6099
6025
|
droppedFields.push("maxOutputTokens");
|
|
6100
|
-
if (
|
|
6026
|
+
if (googleOptions?.thinkingLevel != null)
|
|
6101
6027
|
droppedFields.push("thinkingLevel");
|
|
6102
|
-
if (
|
|
6028
|
+
if (googleOptions?.thinkingSummaries != null) {
|
|
6103
6029
|
droppedFields.push("thinkingSummaries");
|
|
6104
6030
|
}
|
|
6105
|
-
if (
|
|
6031
|
+
if (googleOptions?.imageConfig != null) droppedFields.push("imageConfig");
|
|
6106
6032
|
if (droppedFields.length > 0) {
|
|
6107
6033
|
warnings.push({
|
|
6108
6034
|
type: "other",
|
|
@@ -6112,17 +6038,17 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6112
6038
|
generationConfig = void 0;
|
|
6113
6039
|
} else {
|
|
6114
6040
|
generationConfig = pruneUndefined({
|
|
6115
|
-
temperature:
|
|
6116
|
-
top_p:
|
|
6117
|
-
top_k:
|
|
6118
|
-
seed:
|
|
6041
|
+
temperature: options.temperature ?? void 0,
|
|
6042
|
+
top_p: options.topP ?? void 0,
|
|
6043
|
+
top_k: options.topK ?? void 0,
|
|
6044
|
+
seed: options.seed ?? void 0,
|
|
6119
6045
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
6120
|
-
max_output_tokens:
|
|
6121
|
-
thinking_level:
|
|
6122
|
-
thinking_summaries:
|
|
6046
|
+
max_output_tokens: options.maxOutputTokens ?? void 0,
|
|
6047
|
+
thinking_level: googleOptions?.thinkingLevel ?? void 0,
|
|
6048
|
+
thinking_summaries: googleOptions?.thinkingSummaries ?? void 0,
|
|
6123
6049
|
tool_choice: toolChoiceForBody
|
|
6124
6050
|
});
|
|
6125
|
-
if (
|
|
6051
|
+
if (googleOptions?.imageConfig != null) {
|
|
6126
6052
|
const alreadyHasImageEntry = responseFormatEntries.some(
|
|
6127
6053
|
(entry) => entry.type === "image"
|
|
6128
6054
|
);
|
|
@@ -6141,21 +6067,21 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6141
6067
|
}
|
|
6142
6068
|
}
|
|
6143
6069
|
let agentConfig;
|
|
6144
|
-
if (isAgent &&
|
|
6070
|
+
if (isAgent && googleOptions?.agentConfig != null) {
|
|
6145
6071
|
const agentConfigOptions = googleOptions.agentConfig;
|
|
6146
6072
|
if (agentConfigOptions.type === "deep-research") {
|
|
6147
6073
|
agentConfig = pruneUndefined({
|
|
6148
6074
|
type: "deep-research",
|
|
6149
|
-
thinking_summaries:
|
|
6150
|
-
visualization:
|
|
6151
|
-
collaborative_planning:
|
|
6075
|
+
thinking_summaries: agentConfigOptions.thinkingSummaries ?? void 0,
|
|
6076
|
+
visualization: agentConfigOptions.visualization ?? void 0,
|
|
6077
|
+
collaborative_planning: agentConfigOptions.collaborativePlanning ?? void 0
|
|
6152
6078
|
});
|
|
6153
6079
|
} else if (agentConfigOptions.type === "dynamic") {
|
|
6154
6080
|
agentConfig = { type: "dynamic" };
|
|
6155
6081
|
}
|
|
6156
6082
|
}
|
|
6157
6083
|
let environment;
|
|
6158
|
-
if (
|
|
6084
|
+
if (googleOptions?.environment != null) {
|
|
6159
6085
|
if (!isAgent) {
|
|
6160
6086
|
warnings.push({
|
|
6161
6087
|
type: "other",
|
|
@@ -6165,8 +6091,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6165
6091
|
environment = googleOptions.environment;
|
|
6166
6092
|
} else {
|
|
6167
6093
|
const environmentOptions = googleOptions.environment;
|
|
6168
|
-
const sources =
|
|
6169
|
-
var _a2;
|
|
6094
|
+
const sources = environmentOptions.sources?.map((source) => {
|
|
6170
6095
|
if (source.type === "inline") {
|
|
6171
6096
|
return {
|
|
6172
6097
|
type: "inline",
|
|
@@ -6177,7 +6102,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6177
6102
|
return pruneUndefined({
|
|
6178
6103
|
type: source.type,
|
|
6179
6104
|
source: source.source,
|
|
6180
|
-
target:
|
|
6105
|
+
target: source.target ?? void 0
|
|
6181
6106
|
});
|
|
6182
6107
|
});
|
|
6183
6108
|
let network;
|
|
@@ -6186,13 +6111,10 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6186
6111
|
} else if (environmentOptions.network != null) {
|
|
6187
6112
|
network = {
|
|
6188
6113
|
allowlist: environmentOptions.network.allowlist.map(
|
|
6189
|
-
(entry) => {
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
transform: (_a2 = entry.transform) != null ? _a2 : void 0
|
|
6194
|
-
});
|
|
6195
|
-
}
|
|
6114
|
+
(entry) => pruneUndefined({
|
|
6115
|
+
domain: entry.domain,
|
|
6116
|
+
transform: entry.transform ?? void 0
|
|
6117
|
+
})
|
|
6196
6118
|
)
|
|
6197
6119
|
};
|
|
6198
6120
|
}
|
|
@@ -6209,25 +6131,24 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6209
6131
|
system_instruction: systemInstruction,
|
|
6210
6132
|
tools: toolsForBody,
|
|
6211
6133
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
6212
|
-
response_modalities:
|
|
6213
|
-
previous_interaction_id:
|
|
6214
|
-
service_tier:
|
|
6215
|
-
store:
|
|
6134
|
+
response_modalities: googleOptions?.responseModalities != null ? googleOptions.responseModalities : void 0,
|
|
6135
|
+
previous_interaction_id: googleOptions?.previousInteractionId ?? void 0,
|
|
6136
|
+
service_tier: googleOptions?.serviceTier ?? void 0,
|
|
6137
|
+
store: googleOptions?.store ?? void 0,
|
|
6216
6138
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
6217
6139
|
agent_config: agentConfig,
|
|
6218
6140
|
environment,
|
|
6219
|
-
background:
|
|
6141
|
+
background: googleOptions?.background ?? void 0
|
|
6220
6142
|
});
|
|
6221
6143
|
return {
|
|
6222
6144
|
args,
|
|
6223
6145
|
warnings,
|
|
6224
6146
|
isAgent,
|
|
6225
|
-
isBackground:
|
|
6226
|
-
pollingTimeoutMs:
|
|
6147
|
+
isBackground: googleOptions?.background === true,
|
|
6148
|
+
pollingTimeoutMs: googleOptions?.pollingTimeoutMs ?? void 0
|
|
6227
6149
|
};
|
|
6228
6150
|
}
|
|
6229
6151
|
async doGenerate(options) {
|
|
6230
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6231
6152
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6232
6153
|
const url = `${this.config.baseURL}/interactions`;
|
|
6233
6154
|
const mergedHeaders = combineHeaders4(
|
|
@@ -6261,12 +6182,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6261
6182
|
});
|
|
6262
6183
|
response = polled.response;
|
|
6263
6184
|
rawResponse = polled.rawResponse;
|
|
6264
|
-
responseHeaders =
|
|
6185
|
+
responseHeaders = polled.responseHeaders ?? responseHeaders;
|
|
6265
6186
|
}
|
|
6266
6187
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
6267
6188
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
6268
|
-
steps:
|
|
6269
|
-
generateId:
|
|
6189
|
+
steps: response.steps ?? null,
|
|
6190
|
+
generateId: this.config.generateId ?? defaultGenerateId,
|
|
6270
6191
|
interactionId
|
|
6271
6192
|
});
|
|
6272
6193
|
const finishReason = {
|
|
@@ -6276,7 +6197,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6276
6197
|
}),
|
|
6277
6198
|
raw: response.status
|
|
6278
6199
|
};
|
|
6279
|
-
const serviceTier =
|
|
6200
|
+
const serviceTier = response.service_tier ?? responseHeaders?.["x-gemini-service-tier"] ?? void 0;
|
|
6280
6201
|
const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(
|
|
6281
6202
|
response.usage
|
|
6282
6203
|
);
|
|
@@ -6306,12 +6227,11 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6306
6227
|
body: rawResponse,
|
|
6307
6228
|
...interactionId != null ? { id: interactionId } : {},
|
|
6308
6229
|
...timestamp ? { timestamp } : {},
|
|
6309
|
-
modelId:
|
|
6230
|
+
modelId: response.model ?? void 0
|
|
6310
6231
|
}
|
|
6311
6232
|
};
|
|
6312
6233
|
}
|
|
6313
6234
|
async doStream(options) {
|
|
6314
|
-
var _a;
|
|
6315
6235
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6316
6236
|
const url = `${this.config.baseURL}/interactions`;
|
|
6317
6237
|
const mergedHeaders = combineHeaders4(
|
|
@@ -6340,10 +6260,10 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6340
6260
|
abortSignal: options.abortSignal,
|
|
6341
6261
|
fetch: this.config.fetch
|
|
6342
6262
|
});
|
|
6343
|
-
const headerServiceTier = responseHeaders
|
|
6263
|
+
const headerServiceTier = responseHeaders?.["x-gemini-service-tier"];
|
|
6344
6264
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
6345
6265
|
warnings,
|
|
6346
|
-
generateId:
|
|
6266
|
+
generateId: this.config.generateId ?? defaultGenerateId,
|
|
6347
6267
|
includeRawChunks: options.includeRawChunks,
|
|
6348
6268
|
serviceTier: headerServiceTier
|
|
6349
6269
|
});
|
|
@@ -6379,7 +6299,6 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6379
6299
|
options,
|
|
6380
6300
|
pollingTimeoutMs
|
|
6381
6301
|
}) {
|
|
6382
|
-
var _a, _b;
|
|
6383
6302
|
const postResult = await postJsonToApi3({
|
|
6384
6303
|
url,
|
|
6385
6304
|
headers: mergedHeaders,
|
|
@@ -6398,12 +6317,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6398
6317
|
"google.interactions: background POST response did not include an interaction id; cannot stream the result."
|
|
6399
6318
|
);
|
|
6400
6319
|
}
|
|
6401
|
-
const headerServiceTier = postHeaders
|
|
6320
|
+
const headerServiceTier = postHeaders?.["x-gemini-service-tier"];
|
|
6402
6321
|
if (isTerminalStatus(postResponse.status)) {
|
|
6403
6322
|
const synthesized = synthesizeGoogleInteractionsAgentStream({
|
|
6404
6323
|
response: postResponse,
|
|
6405
6324
|
warnings,
|
|
6406
|
-
generateId:
|
|
6325
|
+
generateId: this.config.generateId ?? defaultGenerateId,
|
|
6407
6326
|
includeRawChunks: options.includeRawChunks,
|
|
6408
6327
|
headerServiceTier
|
|
6409
6328
|
});
|
|
@@ -6423,7 +6342,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6423
6342
|
});
|
|
6424
6343
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
6425
6344
|
warnings,
|
|
6426
|
-
generateId:
|
|
6345
|
+
generateId: this.config.generateId ?? defaultGenerateId,
|
|
6427
6346
|
includeRawChunks: options.includeRawChunks,
|
|
6428
6347
|
serviceTier: headerServiceTier
|
|
6429
6348
|
});
|
|
@@ -6446,6 +6365,7 @@ export {
|
|
|
6446
6365
|
GoogleInteractionsLanguageModel,
|
|
6447
6366
|
GoogleLanguageModel,
|
|
6448
6367
|
GoogleSpeechModel,
|
|
6368
|
+
getGoogleSpeechInput,
|
|
6449
6369
|
getGroundingMetadataSchema,
|
|
6450
6370
|
getUrlContextMetadataSchema,
|
|
6451
6371
|
googleTools,
|