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