Leon4gr45 commited on
Commit
505d993
·
verified ·
1 Parent(s): a72140d

Upload folder using huggingface_hub (part 9)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/.bin/eslint +21 -0
  2. node_modules/.bin/fxparser +21 -0
  3. node_modules/.bin/nanoid +21 -0
  4. node_modules/.bin/next +21 -0
  5. node_modules/.bin/tailwind +21 -0
  6. node_modules/.bin/tailwindcss +21 -0
  7. node_modules/.bin/tsc +21 -0
  8. node_modules/.bin/tsserver +21 -0
  9. node_modules/.modules.yaml +1657 -0
  10. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/CHANGELOG.md +1378 -0
  11. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/LICENSE +13 -0
  12. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/README.md +35 -0
  13. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.d.mts +204 -0
  14. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.d.ts +204 -0
  15. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.js +1955 -0
  16. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.js.map +0 -0
  17. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs +1937 -0
  18. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs.map +0 -0
  19. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.d.mts +229 -0
  20. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.d.ts +229 -0
  21. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.js +1905 -0
  22. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.js.map +0 -0
  23. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs +1880 -0
  24. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs.map +0 -0
  25. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/internal.d.ts +1 -0
  26. node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/package.json +72 -0
  27. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/CHANGELOG.md +409 -0
  28. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/LICENSE +13 -0
  29. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/README.md +36 -0
  30. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.d.mts +239 -0
  31. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.d.ts +239 -0
  32. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.js +804 -0
  33. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.js.map +1 -0
  34. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs +789 -0
  35. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs.map +1 -0
  36. node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/package.json +66 -0
  37. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/CHANGELOG.md +1584 -0
  38. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/LICENSE +13 -0
  39. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/README.md +35 -0
  40. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.d.mts +243 -0
  41. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.d.ts +243 -0
  42. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.js +1492 -0
  43. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.js.map +1 -0
  44. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.mjs +1494 -0
  45. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.mjs.map +1 -0
  46. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.d.mts +73 -0
  47. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.d.ts +73 -0
  48. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.js +1185 -0
  49. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.js.map +1 -0
  50. node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.mjs +1168 -0
node_modules/.bin/eslint ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/eslint@9.32.0_jiti@2.5.1/node_modules/eslint/node_modules:/app/node_modules/.pnpm/eslint@9.32.0_jiti@2.5.1/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/eslint@9.32.0_jiti@2.5.1/node_modules/eslint/node_modules:/app/node_modules/.pnpm/eslint@9.32.0_jiti@2.5.1/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../eslint/bin/eslint.js" "$@"
19
+ else
20
+ exec node "$basedir/../eslint/bin/eslint.js" "$@"
21
+ fi
node_modules/.bin/fxparser ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/fast-xml-parser@5.3.6/node_modules/fast-xml-parser/node_modules:/app/node_modules/.pnpm/fast-xml-parser@5.3.6/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/fast-xml-parser@5.3.6/node_modules/fast-xml-parser/node_modules:/app/node_modules/.pnpm/fast-xml-parser@5.3.6/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../fast-xml-parser/src/cli/cli.js" "$@"
19
+ else
20
+ exec node "$basedir/../fast-xml-parser/src/cli/cli.js" "$@"
21
+ fi
node_modules/.bin/nanoid ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/nanoid@5.1.5/node_modules/nanoid/node_modules:/app/node_modules/.pnpm/nanoid@5.1.5/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/nanoid@5.1.5/node_modules/nanoid/node_modules:/app/node_modules/.pnpm/nanoid@5.1.5/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../nanoid/bin/nanoid.js" "$@"
19
+ else
20
+ exec node "$basedir/../nanoid/bin/nanoid.js" "$@"
21
+ fi
node_modules/.bin/next ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/next@15.4.3_@opentelemetry+api@1.9.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/node_modules:/app/node_modules/.pnpm/next@15.4.3_@opentelemetry+api@1.9.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/next@15.4.3_@opentelemetry+api@1.9.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/node_modules:/app/node_modules/.pnpm/next@15.4.3_@opentelemetry+api@1.9.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../next/dist/bin/next" "$@"
19
+ else
20
+ exec node "$basedir/../next/dist/bin/next" "$@"
21
+ fi
node_modules/.bin/tailwind ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules/tailwindcss/node_modules:/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules/tailwindcss/node_modules:/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../tailwindcss/lib/cli.js" "$@"
19
+ else
20
+ exec node "$basedir/../tailwindcss/lib/cli.js" "$@"
21
+ fi
node_modules/.bin/tailwindcss ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules/tailwindcss/node_modules:/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules/tailwindcss/node_modules:/app/node_modules/.pnpm/tailwindcss@3.4.17/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../tailwindcss/lib/cli.js" "$@"
19
+ else
20
+ exec node "$basedir/../tailwindcss/lib/cli.js" "$@"
21
+ fi
node_modules/.bin/tsc ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/node_modules:/app/node_modules/.pnpm/typescript@5.9.2/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/node_modules:/app/node_modules/.pnpm/typescript@5.9.2/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsc" "$@"
21
+ fi
node_modules/.bin/tsserver ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/app/node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/node_modules:/app/node_modules/.pnpm/typescript@5.9.2/node_modules:/app/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/app/node_modules/.pnpm/typescript@5.9.2/node_modules/typescript/node_modules:/app/node_modules/.pnpm/typescript@5.9.2/node_modules:/app/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsserver" "$@"
21
+ fi
node_modules/.modules.yaml ADDED
@@ -0,0 +1,1657 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "hoistedDependencies": {
3
+ "@ai-sdk/provider@2.0.0": {
4
+ "@ai-sdk/provider": "private"
5
+ },
6
+ "@ai-sdk/provider-utils@3.0.1(zod@3.25.76)": {
7
+ "@ai-sdk/provider-utils": "private"
8
+ },
9
+ "e2b@2.1.3": {
10
+ "e2b": "private"
11
+ },
12
+ "ajv@6.12.6": {
13
+ "ajv": "private"
14
+ },
15
+ "debug@4.4.1": {
16
+ "debug": "private"
17
+ },
18
+ "espree@10.4.0": {
19
+ "espree": "private"
20
+ },
21
+ "globals@14.0.0": {
22
+ "globals": "private"
23
+ },
24
+ "ignore@5.3.2": {
25
+ "ignore": "private"
26
+ },
27
+ "import-fresh@3.3.1": {
28
+ "import-fresh": "private"
29
+ },
30
+ "js-yaml@4.1.0": {
31
+ "js-yaml": "private"
32
+ },
33
+ "minimatch@3.1.2": {
34
+ "minimatch": "private"
35
+ },
36
+ "strip-json-comments@3.1.1": {
37
+ "strip-json-comments": "private"
38
+ },
39
+ "typescript-event-target@1.1.1": {
40
+ "typescript-event-target": "private"
41
+ },
42
+ "zod-to-json-schema@3.24.6(zod@3.25.76)": {
43
+ "zod-to-json-schema": "private"
44
+ },
45
+ "@radix-ui/primitive@1.1.3": {
46
+ "@radix-ui/primitive": "private"
47
+ },
48
+ "@radix-ui/react-collection@1.1.7(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
49
+ "@radix-ui/react-collection": "private"
50
+ },
51
+ "@radix-ui/react-compose-refs@1.1.2(@types/react@19.1.9)(react@19.1.0)": {
52
+ "@radix-ui/react-compose-refs": "private"
53
+ },
54
+ "@radix-ui/react-context@1.1.2(@types/react@19.1.9)(react@19.1.0)": {
55
+ "@radix-ui/react-context": "private"
56
+ },
57
+ "@radix-ui/react-direction@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
58
+ "@radix-ui/react-direction": "private"
59
+ },
60
+ "@radix-ui/react-id@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
61
+ "@radix-ui/react-id": "private"
62
+ },
63
+ "@radix-ui/react-primitive@2.1.3(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
64
+ "@radix-ui/react-primitive": "private"
65
+ },
66
+ "@radix-ui/react-use-controllable-state@1.2.2(@types/react@19.1.9)(react@19.1.0)": {
67
+ "@radix-ui/react-use-controllable-state": "private"
68
+ },
69
+ "@radix-ui/react-use-callback-ref@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
70
+ "@radix-ui/react-use-callback-ref": "private"
71
+ },
72
+ "@radix-ui/react-use-is-hydrated@0.1.0(@types/react@19.1.9)(react@19.1.0)": {
73
+ "@radix-ui/react-use-is-hydrated": "private"
74
+ },
75
+ "@radix-ui/react-use-layout-effect@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
76
+ "@radix-ui/react-use-layout-effect": "private"
77
+ },
78
+ "@radix-ui/react-presence@1.1.5(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
79
+ "@radix-ui/react-presence": "private"
80
+ },
81
+ "@radix-ui/react-use-previous@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
82
+ "@radix-ui/react-use-previous": "private"
83
+ },
84
+ "@radix-ui/react-use-size@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
85
+ "@radix-ui/react-use-size": "private"
86
+ },
87
+ "@radix-ui/react-menu@2.1.16(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
88
+ "@radix-ui/react-menu": "private"
89
+ },
90
+ "@radix-ui/react-dismissable-layer@1.1.11(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
91
+ "@radix-ui/react-dismissable-layer": "private"
92
+ },
93
+ "@radix-ui/react-focus-guards@1.1.3(@types/react@19.1.9)(react@19.1.0)": {
94
+ "@radix-ui/react-focus-guards": "private"
95
+ },
96
+ "@radix-ui/react-focus-scope@1.1.7(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
97
+ "@radix-ui/react-focus-scope": "private"
98
+ },
99
+ "@radix-ui/react-portal@1.1.9(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
100
+ "@radix-ui/react-portal": "private"
101
+ },
102
+ "aria-hidden@1.2.6": {
103
+ "aria-hidden": "private"
104
+ },
105
+ "react-remove-scroll@2.7.1(@types/react@19.1.9)(react@19.1.0)": {
106
+ "react-remove-scroll": "private"
107
+ },
108
+ "@radix-ui/react-popper@1.2.8(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
109
+ "@radix-ui/react-popper": "private"
110
+ },
111
+ "@radix-ui/react-roving-focus@1.1.11(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
112
+ "@radix-ui/react-roving-focus": "private"
113
+ },
114
+ "@radix-ui/react-visually-hidden@1.2.3(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
115
+ "@radix-ui/react-visually-hidden": "private"
116
+ },
117
+ "@radix-ui/number@1.1.1": {
118
+ "@radix-ui/number": "private"
119
+ },
120
+ "@tabler/icons@3.34.1": {
121
+ "@tabler/icons": "private"
122
+ },
123
+ "lodash.castarray@4.4.0": {
124
+ "lodash.castarray": "private"
125
+ },
126
+ "lodash.isplainobject@4.0.6": {
127
+ "lodash.isplainobject": "private"
128
+ },
129
+ "lodash.merge@4.6.2": {
130
+ "lodash.merge": "private"
131
+ },
132
+ "postcss-selector-parser@6.0.10": {
133
+ "postcss-selector-parser": "private"
134
+ },
135
+ "@types/lodash@4.17.20": {
136
+ "@types/lodash": "private"
137
+ },
138
+ "undici-types@6.21.0": {
139
+ "undici-types": "private"
140
+ },
141
+ "csstype@3.1.3": {
142
+ "csstype": "private"
143
+ },
144
+ "@vercel/oidc@2.0.2": {
145
+ "@vercel/oidc": "private"
146
+ },
147
+ "async-retry@1.3.3": {
148
+ "async-retry": "private"
149
+ },
150
+ "jsonlines@0.1.1": {
151
+ "jsonlines": "private"
152
+ },
153
+ "ms@2.1.3": {
154
+ "ms": "private"
155
+ },
156
+ "tar-stream@3.1.7": {
157
+ "tar-stream": "private"
158
+ },
159
+ "@ai-sdk/gateway@1.0.4(zod@3.25.76)": {
160
+ "@ai-sdk/gateway": "private"
161
+ },
162
+ "@opentelemetry/api@1.9.0": {
163
+ "@opentelemetry/api": "private"
164
+ },
165
+ "browserslist@4.25.1": {
166
+ "browserslist": "private"
167
+ },
168
+ "caniuse-lite@1.0.30001731": {
169
+ "caniuse-lite": "private"
170
+ },
171
+ "fraction.js@4.3.7": {
172
+ "fraction.js": "private"
173
+ },
174
+ "normalize-range@0.1.2": {
175
+ "normalize-range": "private"
176
+ },
177
+ "picocolors@1.1.1": {
178
+ "picocolors": "private"
179
+ },
180
+ "postcss-value-parser@4.2.0": {
181
+ "postcss-value-parser": "private"
182
+ },
183
+ "follow-redirects@1.15.11": {
184
+ "follow-redirects": "private"
185
+ },
186
+ "form-data@4.0.5": {
187
+ "form-data": "private"
188
+ },
189
+ "proxy-from-env@1.1.0": {
190
+ "proxy-from-env": "private"
191
+ },
192
+ "toggle-selection@1.0.6": {
193
+ "toggle-selection": "private"
194
+ },
195
+ "object-assign@4.1.1": {
196
+ "object-assign": "private"
197
+ },
198
+ "vary@1.1.2": {
199
+ "vary": "private"
200
+ },
201
+ "@next/eslint-plugin-next@15.4.3": {
202
+ "@next/eslint-plugin-next": "private"
203
+ },
204
+ "@rushstack/eslint-patch@1.12.0": {
205
+ "@rushstack/eslint-patch": "private"
206
+ },
207
+ "@typescript-eslint/eslint-plugin@8.39.0(@typescript-eslint/parser@8.39.0(eslint@9.32.0(jiti@2.5.1))(typescript@5.9.2))(eslint@9.32.0(jiti@2.5.1))(typescript@5.9.2)": {
208
+ "@typescript-eslint/eslint-plugin": "private"
209
+ },
210
+ "@typescript-eslint/parser@8.39.0(eslint@9.32.0(jiti@2.5.1))(typescript@5.9.2)": {
211
+ "@typescript-eslint/parser": "private"
212
+ },
213
+ "eslint-import-resolver-node@0.3.9": {
214
+ "eslint-import-resolver-node": "private"
215
+ },
216
+ "eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.32.0(jiti@2.5.1))": {
217
+ "eslint-import-resolver-typescript": "private"
218
+ },
219
+ "eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.39.0(eslint@9.32.0(jiti@2.5.1))(typescript@5.9.2))(eslint-import-resolver-typescript@3.10.1)(eslint@9.32.0(jiti@2.5.1))": {
220
+ "eslint-plugin-import": "private"
221
+ },
222
+ "eslint-plugin-jsx-a11y@6.10.2(eslint@9.32.0(jiti@2.5.1))": {
223
+ "eslint-plugin-jsx-a11y": "private"
224
+ },
225
+ "eslint-plugin-react@7.37.5(eslint@9.32.0(jiti@2.5.1))": {
226
+ "eslint-plugin-react": "private"
227
+ },
228
+ "eslint-plugin-react-hooks@5.2.0(eslint@9.32.0(jiti@2.5.1))": {
229
+ "eslint-plugin-react-hooks": "private"
230
+ },
231
+ "@eslint-community/eslint-utils@4.7.0(eslint@9.32.0(jiti@2.5.1))": {
232
+ "@eslint-community/eslint-utils": "private"
233
+ },
234
+ "@eslint-community/regexpp@4.12.1": {
235
+ "@eslint-community/regexpp": "private"
236
+ },
237
+ "@eslint/config-array@0.21.0": {
238
+ "@eslint/config-array": "private"
239
+ },
240
+ "@eslint/config-helpers@0.3.0": {
241
+ "@eslint/config-helpers": "private"
242
+ },
243
+ "@eslint/core@0.15.1": {
244
+ "@eslint/core": "private"
245
+ },
246
+ "@eslint/js@9.32.0": {
247
+ "@eslint/js": "private"
248
+ },
249
+ "@eslint/plugin-kit@0.3.4": {
250
+ "@eslint/plugin-kit": "private"
251
+ },
252
+ "@humanfs/node@0.16.6": {
253
+ "@humanfs/node": "private"
254
+ },
255
+ "@humanwhocodes/module-importer@1.0.1": {
256
+ "@humanwhocodes/module-importer": "private"
257
+ },
258
+ "@humanwhocodes/retry@0.4.3": {
259
+ "@humanwhocodes/retry": "private"
260
+ },
261
+ "@types/estree@1.0.8": {
262
+ "@types/estree": "private"
263
+ },
264
+ "@types/json-schema@7.0.15": {
265
+ "@types/json-schema": "private"
266
+ },
267
+ "chalk@4.1.2": {
268
+ "chalk": "private"
269
+ },
270
+ "cross-spawn@7.0.6": {
271
+ "cross-spawn": "private"
272
+ },
273
+ "escape-string-regexp@4.0.0": {
274
+ "escape-string-regexp": "private"
275
+ },
276
+ "eslint-scope@8.4.0": {
277
+ "eslint-scope": "private"
278
+ },
279
+ "eslint-visitor-keys@4.2.1": {
280
+ "eslint-visitor-keys": "private"
281
+ },
282
+ "esquery@1.6.0": {
283
+ "esquery": "private"
284
+ },
285
+ "esutils@2.0.3": {
286
+ "esutils": "private"
287
+ },
288
+ "fast-deep-equal@3.1.3": {
289
+ "fast-deep-equal": "private"
290
+ },
291
+ "file-entry-cache@8.0.0": {
292
+ "file-entry-cache": "private"
293
+ },
294
+ "find-up@5.0.0": {
295
+ "find-up": "private"
296
+ },
297
+ "glob-parent@6.0.2": {
298
+ "glob-parent": "private"
299
+ },
300
+ "imurmurhash@0.1.4": {
301
+ "imurmurhash": "private"
302
+ },
303
+ "is-glob@4.0.3": {
304
+ "is-glob": "private"
305
+ },
306
+ "json-stable-stringify-without-jsonify@1.0.1": {
307
+ "json-stable-stringify-without-jsonify": "private"
308
+ },
309
+ "natural-compare@1.4.0": {
310
+ "natural-compare": "private"
311
+ },
312
+ "optionator@0.9.4": {
313
+ "optionator": "private"
314
+ },
315
+ "jiti@2.5.1": {
316
+ "jiti": "private"
317
+ },
318
+ "strnum@2.1.2": {
319
+ "strnum": "private"
320
+ },
321
+ "motion-dom@12.23.12": {
322
+ "motion-dom": "private"
323
+ },
324
+ "motion-utils@12.23.6": {
325
+ "motion-utils": "private"
326
+ },
327
+ "tslib@2.8.1": {
328
+ "tslib": "private"
329
+ },
330
+ "@types/node-fetch@2.6.13": {
331
+ "@types/node-fetch": "private"
332
+ },
333
+ "abort-controller@3.0.0": {
334
+ "abort-controller": "private"
335
+ },
336
+ "agentkeepalive@4.6.0": {
337
+ "agentkeepalive": "private"
338
+ },
339
+ "form-data-encoder@1.7.2": {
340
+ "form-data-encoder": "private"
341
+ },
342
+ "formdata-node@4.4.1": {
343
+ "formdata-node": "private"
344
+ },
345
+ "node-fetch@2.7.0": {
346
+ "node-fetch": "private"
347
+ },
348
+ "@next/env@15.4.3": {
349
+ "@next/env": "private"
350
+ },
351
+ "@swc/helpers@0.5.15": {
352
+ "@swc/helpers": "private"
353
+ },
354
+ "styled-jsx@5.1.6(react@19.1.0)": {
355
+ "styled-jsx": "private"
356
+ },
357
+ "@next/swc-linux-x64-gnu@15.4.3": {
358
+ "@next/swc-linux-x64-gnu": "private"
359
+ },
360
+ "@next/swc-linux-x64-musl@15.4.3": {
361
+ "@next/swc-linux-x64-musl": "private"
362
+ },
363
+ "sharp@0.34.3": {
364
+ "sharp": "private"
365
+ },
366
+ "@octokit/app@16.1.2": {
367
+ "@octokit/app": "private"
368
+ },
369
+ "@octokit/core@7.0.6": {
370
+ "@octokit/core": "private"
371
+ },
372
+ "@octokit/oauth-app@8.0.3": {
373
+ "@octokit/oauth-app": "private"
374
+ },
375
+ "@octokit/plugin-paginate-graphql@6.0.0(@octokit/core@7.0.6)": {
376
+ "@octokit/plugin-paginate-graphql": "private"
377
+ },
378
+ "@octokit/plugin-paginate-rest@14.0.0(@octokit/core@7.0.6)": {
379
+ "@octokit/plugin-paginate-rest": "private"
380
+ },
381
+ "@octokit/plugin-rest-endpoint-methods@17.0.0(@octokit/core@7.0.6)": {
382
+ "@octokit/plugin-rest-endpoint-methods": "private"
383
+ },
384
+ "@octokit/plugin-retry@8.0.3(@octokit/core@7.0.6)": {
385
+ "@octokit/plugin-retry": "private"
386
+ },
387
+ "@octokit/plugin-throttling@11.0.3(@octokit/core@7.0.6)": {
388
+ "@octokit/plugin-throttling": "private"
389
+ },
390
+ "@octokit/request-error@7.1.0": {
391
+ "@octokit/request-error": "private"
392
+ },
393
+ "@octokit/types@16.0.0": {
394
+ "@octokit/types": "private"
395
+ },
396
+ "@octokit/webhooks@14.2.0": {
397
+ "@octokit/webhooks": "private"
398
+ },
399
+ "@pixi/colord@2.9.6": {
400
+ "@pixi/colord": "private"
401
+ },
402
+ "@types/css-font-loading-module@0.0.12": {
403
+ "@types/css-font-loading-module": "private"
404
+ },
405
+ "@types/earcut@3.0.0": {
406
+ "@types/earcut": "private"
407
+ },
408
+ "@webgpu/types@0.1.64": {
409
+ "@webgpu/types": "private"
410
+ },
411
+ "@xmldom/xmldom@0.8.11": {
412
+ "@xmldom/xmldom": "private"
413
+ },
414
+ "earcut@3.0.2": {
415
+ "earcut": "private"
416
+ },
417
+ "eventemitter3@5.0.1": {
418
+ "eventemitter3": "private"
419
+ },
420
+ "gifuct-js@2.1.2": {
421
+ "gifuct-js": "private"
422
+ },
423
+ "ismobilejs@1.1.1": {
424
+ "ismobilejs": "private"
425
+ },
426
+ "parse-svg-path@0.1.2": {
427
+ "parse-svg-path": "private"
428
+ },
429
+ "tiny-lru@11.4.5": {
430
+ "tiny-lru": "private"
431
+ },
432
+ "read-cache@1.0.0": {
433
+ "read-cache": "private"
434
+ },
435
+ "resolve@1.22.10": {
436
+ "resolve": "private"
437
+ },
438
+ "@csstools/selector-resolve-nested@3.1.0(postcss-selector-parser@7.1.0)": {
439
+ "@csstools/selector-resolve-nested": "private"
440
+ },
441
+ "@csstools/selector-specificity@5.0.0(postcss-selector-parser@7.1.0)": {
442
+ "@csstools/selector-specificity": "private"
443
+ },
444
+ "source-map-js@1.2.1": {
445
+ "source-map-js": "private"
446
+ },
447
+ "scheduler@0.26.0": {
448
+ "scheduler": "private"
449
+ },
450
+ "@babel/runtime@7.28.2": {
451
+ "@babel/runtime": "private"
452
+ },
453
+ "highlight.js@10.7.3": {
454
+ "highlight.js": "private"
455
+ },
456
+ "highlightjs-vue@1.0.0": {
457
+ "highlightjs-vue": "private"
458
+ },
459
+ "lowlight@1.20.0": {
460
+ "lowlight": "private"
461
+ },
462
+ "prismjs@1.30.0": {
463
+ "prismjs": "private"
464
+ },
465
+ "refractor@3.6.0": {
466
+ "refractor": "private"
467
+ },
468
+ "@alloc/quick-lru@5.2.0": {
469
+ "@alloc/quick-lru": "private"
470
+ },
471
+ "arg@5.0.2": {
472
+ "arg": "private"
473
+ },
474
+ "chokidar@3.6.0": {
475
+ "chokidar": "private"
476
+ },
477
+ "didyoumean@1.2.2": {
478
+ "didyoumean": "private"
479
+ },
480
+ "dlv@1.1.3": {
481
+ "dlv": "private"
482
+ },
483
+ "fast-glob@3.3.3": {
484
+ "fast-glob": "private"
485
+ },
486
+ "lilconfig@3.1.3": {
487
+ "lilconfig": "private"
488
+ },
489
+ "micromatch@4.0.8": {
490
+ "micromatch": "private"
491
+ },
492
+ "normalize-path@3.0.0": {
493
+ "normalize-path": "private"
494
+ },
495
+ "object-hash@3.0.0": {
496
+ "object-hash": "private"
497
+ },
498
+ "postcss-js@4.0.1(postcss@8.5.6)": {
499
+ "postcss-js": "private"
500
+ },
501
+ "postcss-load-config@4.0.2(postcss@8.5.6)": {
502
+ "postcss-load-config": "private"
503
+ },
504
+ "postcss-nested@6.2.0(postcss@8.5.6)": {
505
+ "postcss-nested": "private"
506
+ },
507
+ "sucrase@3.35.0": {
508
+ "sucrase": "private"
509
+ },
510
+ "lodash.debounce@4.0.8": {
511
+ "lodash.debounce": "private"
512
+ },
513
+ "@standard-schema/spec@1.0.0": {
514
+ "@standard-schema/spec": "private"
515
+ },
516
+ "eventsource-parser@3.0.3": {
517
+ "eventsource-parser": "private"
518
+ },
519
+ "json-schema@0.4.0": {
520
+ "json-schema": "private"
521
+ },
522
+ "@eslint/object-schema@2.1.6": {
523
+ "@eslint/object-schema": "private"
524
+ },
525
+ "levn@0.4.1": {
526
+ "levn": "private"
527
+ },
528
+ "@humanfs/core@0.19.1": {
529
+ "@humanfs/core": "private"
530
+ },
531
+ "@octokit/auth-app@8.2.0": {
532
+ "@octokit/auth-app": "private"
533
+ },
534
+ "@octokit/auth-unauthenticated@7.0.3": {
535
+ "@octokit/auth-unauthenticated": "private"
536
+ },
537
+ "@octokit/auth-token@6.0.0": {
538
+ "@octokit/auth-token": "private"
539
+ },
540
+ "@octokit/graphql@9.0.3": {
541
+ "@octokit/graphql": "private"
542
+ },
543
+ "@octokit/request@10.0.7": {
544
+ "@octokit/request": "private"
545
+ },
546
+ "before-after-hook@4.0.0": {
547
+ "before-after-hook": "private"
548
+ },
549
+ "universal-user-agent@7.0.3": {
550
+ "universal-user-agent": "private"
551
+ },
552
+ "@octokit/auth-oauth-app@9.0.3": {
553
+ "@octokit/auth-oauth-app": "private"
554
+ },
555
+ "@octokit/auth-oauth-user@6.0.2": {
556
+ "@octokit/auth-oauth-user": "private"
557
+ },
558
+ "@octokit/oauth-authorization-url@8.0.0": {
559
+ "@octokit/oauth-authorization-url": "private"
560
+ },
561
+ "@octokit/oauth-methods@6.0.2": {
562
+ "@octokit/oauth-methods": "private"
563
+ },
564
+ "@types/aws-lambda@8.10.160": {
565
+ "@types/aws-lambda": "private"
566
+ },
567
+ "bottleneck@2.19.5": {
568
+ "bottleneck": "private"
569
+ },
570
+ "@octokit/openapi-types@27.0.0": {
571
+ "@octokit/openapi-types": "private"
572
+ },
573
+ "@octokit/openapi-webhooks-types@12.1.0": {
574
+ "@octokit/openapi-webhooks-types": "private"
575
+ },
576
+ "@octokit/webhooks-methods@6.0.0": {
577
+ "@octokit/webhooks-methods": "private"
578
+ },
579
+ "@radix-ui/react-use-escape-keydown@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
580
+ "@radix-ui/react-use-escape-keydown": "private"
581
+ },
582
+ "@floating-ui/react-dom@2.1.6(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
583
+ "@floating-ui/react-dom": "private"
584
+ },
585
+ "@radix-ui/react-arrow@1.1.7(@types/react-dom@19.1.7(@types/react@19.1.9))(@types/react@19.1.9)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)": {
586
+ "@radix-ui/react-arrow": "private"
587
+ },
588
+ "@radix-ui/react-use-rect@1.1.1(@types/react@19.1.9)(react@19.1.0)": {
589
+ "@radix-ui/react-use-rect": "private"
590
+ },
591
+ "@radix-ui/rect@1.1.1": {
592
+ "@radix-ui/rect": "private"
593
+ },
594
+ "@radix-ui/react-use-effect-event@0.0.2(@types/react@19.1.9)(react@19.1.0)": {
595
+ "@radix-ui/react-use-effect-event": "private"
596
+ },
597
+ "use-sync-external-store@1.5.0(react@19.1.0)": {
598
+ "use-sync-external-store": "private"
599
+ },
600
+ "@typescript-eslint/scope-manager@8.39.0": {
601
+ "@typescript-eslint/scope-manager": "private"
602
+ },
603
+ "@typescript-eslint/type-utils@8.39.0(eslint@9.32.0(jiti@2.5.1))(typescript@5.9.2)": {
604
+ "@typescript-eslint/type-utils": "private"
605
+ },
606
+ "@typescript-eslint/utils@8.39.0(eslint@9.32.0(jiti@2.5.1))(typescript@5.9.2)": {
607
+ "@typescript-eslint/utils": "private"
608
+ },
609
+ "@typescript-eslint/visitor-keys@8.39.0": {
610
+ "@typescript-eslint/visitor-keys": "private"
611
+ },
612
+ "graphemer@1.4.0": {
613
+ "graphemer": "private"
614
+ },
615
+ "ts-api-utils@2.1.0(typescript@5.9.2)": {
616
+ "ts-api-utils": "private"
617
+ },
618
+ "@typescript-eslint/types@8.39.0": {
619
+ "@typescript-eslint/types": "private"
620
+ },
621
+ "@typescript-eslint/typescript-estree@8.39.0(typescript@5.9.2)": {
622
+ "@typescript-eslint/typescript-estree": "private"
623
+ },
624
+ "@types/ms@2.1.0": {
625
+ "@types/ms": "private"
626
+ },
627
+ "event-target-shim@5.0.1": {
628
+ "event-target-shim": "private"
629
+ },
630
+ "humanize-ms@1.2.1": {
631
+ "humanize-ms": "private"
632
+ },
633
+ "fast-json-stable-stringify@2.1.0": {
634
+ "fast-json-stable-stringify": "private"
635
+ },
636
+ "json-schema-traverse@0.4.1": {
637
+ "json-schema-traverse": "private"
638
+ },
639
+ "uri-js@4.4.1": {
640
+ "uri-js": "private"
641
+ },
642
+ "retry@0.13.1": {
643
+ "retry": "private"
644
+ },
645
+ "electron-to-chromium@1.5.199": {
646
+ "electron-to-chromium": "private"
647
+ },
648
+ "node-releases@2.0.19": {
649
+ "node-releases": "private"
650
+ },
651
+ "update-browserslist-db@1.1.3(browserslist@4.25.1)": {
652
+ "update-browserslist-db": "private"
653
+ },
654
+ "ansi-styles@4.3.0": {
655
+ "ansi-styles": "private"
656
+ },
657
+ "supports-color@7.2.0": {
658
+ "supports-color": "private"
659
+ },
660
+ "anymatch@3.1.3": {
661
+ "anymatch": "private"
662
+ },
663
+ "braces@3.0.3": {
664
+ "braces": "private"
665
+ },
666
+ "is-binary-path@2.1.0": {
667
+ "is-binary-path": "private"
668
+ },
669
+ "readdirp@3.6.0": {
670
+ "readdirp": "private"
671
+ },
672
+ "path-key@3.1.1": {
673
+ "path-key": "private"
674
+ },
675
+ "shebang-command@2.0.0": {
676
+ "shebang-command": "private"
677
+ },
678
+ "which@2.0.2": {
679
+ "which": "private"
680
+ },
681
+ "@bufbuild/protobuf@2.7.0": {
682
+ "@bufbuild/protobuf": "private"
683
+ },
684
+ "@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.7.0)": {
685
+ "@connectrpc/connect": "private"
686
+ },
687
+ "@connectrpc/connect-web@2.0.0-rc.3(@bufbuild/protobuf@2.7.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.7.0))": {
688
+ "@connectrpc/connect-web": "private"
689
+ },
690
+ "compare-versions@6.1.1": {
691
+ "compare-versions": "private"
692
+ },
693
+ "dockerfile-ast@0.7.1": {
694
+ "dockerfile-ast": "private"
695
+ },
696
+ "glob@11.0.3": {
697
+ "glob": "private"
698
+ },
699
+ "openapi-fetch@0.9.8": {
700
+ "openapi-fetch": "private"
701
+ },
702
+ "platform@1.3.6": {
703
+ "platform": "private"
704
+ },
705
+ "tar@7.4.3": {
706
+ "tar": "private"
707
+ },
708
+ "is-core-module@2.16.1": {
709
+ "is-core-module": "private"
710
+ },
711
+ "@nolyfill/is-core-module@1.0.39": {
712
+ "@nolyfill/is-core-module": "private"
713
+ },
714
+ "get-tsconfig@4.10.1": {
715
+ "get-tsconfig": "private"
716
+ },
717
+ "is-bun-module@2.0.0": {
718
+ "is-bun-module": "private"
719
+ },
720
+ "stable-hash@0.0.5": {
721
+ "stable-hash": "private"
722
+ },
723
+ "tinyglobby@0.2.14": {
724
+ "tinyglobby": "private"
725
+ },
726
+ "unrs-resolver@1.11.1": {
727
+ "unrs-resolver": "private"
728
+ },
729
+ "@rtsao/scc@1.1.0": {
730
+ "@rtsao/scc": "private"
731
+ },
732
+ "array-includes@3.1.9": {
733
+ "array-includes": "private"
734
+ },
735
+ "array.prototype.findlastindex@1.2.6": {
736
+ "array.prototype.findlastindex": "private"
737
+ },
738
+ "array.prototype.flat@1.3.3": {
739
+ "array.prototype.flat": "private"
740
+ },
741
+ "array.prototype.flatmap@1.3.3": {
742
+ "array.prototype.flatmap": "private"
743
+ },
744
+ "doctrine@2.1.0": {
745
+ "doctrine": "private"
746
+ },
747
+ "eslint-module-utils@2.12.1(@typescript-eslint/parser@8.39.0(eslint@9.32.0(jiti@2.5.1))(typescript@5.9.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1)(eslint@9.32.0(jiti@2.5.1))": {
748
+ "eslint-module-utils": "private"
749
+ },
750
+ "hasown@2.0.2": {
751
+ "hasown": "private"
752
+ },
753
+ "object.fromentries@2.0.8": {
754
+ "object.fromentries": "private"
755
+ },
756
+ "object.groupby@1.0.3": {
757
+ "object.groupby": "private"
758
+ },
759
+ "object.values@1.2.1": {
760
+ "object.values": "private"
761
+ },
762
+ "semver@6.3.1": {
763
+ "semver": "private"
764
+ },
765
+ "string.prototype.trimend@1.0.9": {
766
+ "string.prototype.trimend": "private"
767
+ },
768
+ "tsconfig-paths@3.15.0": {
769
+ "tsconfig-paths": "private"
770
+ },
771
+ "aria-query@5.3.2": {
772
+ "aria-query": "private"
773
+ },
774
+ "ast-types-flow@0.0.8": {
775
+ "ast-types-flow": "private"
776
+ },
777
+ "axe-core@4.10.3": {
778
+ "axe-core": "private"
779
+ },
780
+ "axobject-query@4.1.0": {
781
+ "axobject-query": "private"
782
+ },
783
+ "damerau-levenshtein@1.0.8": {
784
+ "damerau-levenshtein": "private"
785
+ },
786
+ "emoji-regex@9.2.2": {
787
+ "emoji-regex": "private"
788
+ },
789
+ "jsx-ast-utils@3.3.5": {
790
+ "jsx-ast-utils": "private"
791
+ },
792
+ "language-tags@1.0.9": {
793
+ "language-tags": "private"
794
+ },
795
+ "safe-regex-test@1.1.0": {
796
+ "safe-regex-test": "private"
797
+ },
798
+ "string.prototype.includes@2.0.1": {
799
+ "string.prototype.includes": "private"
800
+ },
801
+ "array.prototype.findlast@1.2.5": {
802
+ "array.prototype.findlast": "private"
803
+ },
804
+ "array.prototype.tosorted@1.1.4": {
805
+ "array.prototype.tosorted": "private"
806
+ },
807
+ "es-iterator-helpers@1.2.1": {
808
+ "es-iterator-helpers": "private"
809
+ },
810
+ "estraverse@5.3.0": {
811
+ "estraverse": "private"
812
+ },
813
+ "object.entries@1.1.9": {
814
+ "object.entries": "private"
815
+ },
816
+ "prop-types@15.8.1": {
817
+ "prop-types": "private"
818
+ },
819
+ "string.prototype.matchall@4.0.12": {
820
+ "string.prototype.matchall": "private"
821
+ },
822
+ "string.prototype.repeat@1.0.0": {
823
+ "string.prototype.repeat": "private"
824
+ },
825
+ "esrecurse@4.3.0": {
826
+ "esrecurse": "private"
827
+ },
828
+ "acorn@8.15.0": {
829
+ "acorn": "private"
830
+ },
831
+ "acorn-jsx@5.3.2(acorn@8.15.0)": {
832
+ "acorn-jsx": "private"
833
+ },
834
+ "@nodelib/fs.stat@2.0.5": {
835
+ "@nodelib/fs.stat": "private"
836
+ },
837
+ "@nodelib/fs.walk@1.2.8": {
838
+ "@nodelib/fs.walk": "private"
839
+ },
840
+ "merge2@1.4.1": {
841
+ "merge2": "private"
842
+ },
843
+ "flat-cache@4.0.1": {
844
+ "flat-cache": "private"
845
+ },
846
+ "locate-path@6.0.0": {
847
+ "locate-path": "private"
848
+ },
849
+ "path-exists@4.0.0": {
850
+ "path-exists": "private"
851
+ },
852
+ "asynckit@0.4.0": {
853
+ "asynckit": "private"
854
+ },
855
+ "combined-stream@1.0.8": {
856
+ "combined-stream": "private"
857
+ },
858
+ "es-set-tostringtag@2.1.0": {
859
+ "es-set-tostringtag": "private"
860
+ },
861
+ "mime-types@2.1.35": {
862
+ "mime-types": "private"
863
+ },
864
+ "node-domexception@1.0.0": {
865
+ "node-domexception": "private"
866
+ },
867
+ "web-streams-polyfill@4.0.0-beta.3": {
868
+ "web-streams-polyfill": "private"
869
+ },
870
+ "js-binary-schema-parser@2.0.3": {
871
+ "js-binary-schema-parser": "private"
872
+ },
873
+ "parent-module@1.0.1": {
874
+ "parent-module": "private"
875
+ },
876
+ "resolve-from@4.0.0": {
877
+ "resolve-from": "private"
878
+ },
879
+ "is-extglob@2.1.1": {
880
+ "is-extglob": "private"
881
+ },
882
+ "argparse@2.0.1": {
883
+ "argparse": "private"
884
+ },
885
+ "fault@1.0.4": {
886
+ "fault": "private"
887
+ },
888
+ "picomatch@2.3.1": {
889
+ "picomatch": "private"
890
+ },
891
+ "brace-expansion@1.1.12": {
892
+ "brace-expansion": "private"
893
+ },
894
+ "whatwg-url@5.0.0": {
895
+ "whatwg-url": "private"
896
+ },
897
+ "deep-is@0.1.4": {
898
+ "deep-is": "private"
899
+ },
900
+ "fast-levenshtein@2.0.6": {
901
+ "fast-levenshtein": "private"
902
+ },
903
+ "prelude-ls@1.2.1": {
904
+ "prelude-ls": "private"
905
+ },
906
+ "type-check@0.4.0": {
907
+ "type-check": "private"
908
+ },
909
+ "word-wrap@1.2.5": {
910
+ "word-wrap": "private"
911
+ },
912
+ "camelcase-css@2.0.1": {
913
+ "camelcase-css": "private"
914
+ },
915
+ "yaml@2.8.1": {
916
+ "yaml": "private"
917
+ },
918
+ "cssesc@3.0.0": {
919
+ "cssesc": "private"
920
+ },
921
+ "util-deprecate@1.0.2": {
922
+ "util-deprecate": "private"
923
+ },
924
+ "react-remove-scroll-bar@2.3.8(@types/react@19.1.9)(react@19.1.0)": {
925
+ "react-remove-scroll-bar": "private"
926
+ },
927
+ "react-style-singleton@2.2.3(@types/react@19.1.9)(react@19.1.0)": {
928
+ "react-style-singleton": "private"
929
+ },
930
+ "use-callback-ref@1.3.3(@types/react@19.1.9)(react@19.1.0)": {
931
+ "use-callback-ref": "private"
932
+ },
933
+ "use-sidecar@1.1.3(@types/react@19.1.9)(react@19.1.0)": {
934
+ "use-sidecar": "private"
935
+ },
936
+ "pify@2.3.0": {
937
+ "pify": "private"
938
+ },
939
+ "hastscript@6.0.0": {
940
+ "hastscript": "private"
941
+ },
942
+ "parse-entities@2.0.0": {
943
+ "parse-entities": "private"
944
+ },
945
+ "path-parse@1.0.7": {
946
+ "path-parse": "private"
947
+ },
948
+ "supports-preserve-symlinks-flag@1.0.0": {
949
+ "supports-preserve-symlinks-flag": "private"
950
+ },
951
+ "color@4.2.3": {
952
+ "color": "private"
953
+ },
954
+ "detect-libc@2.0.4": {
955
+ "detect-libc": "private"
956
+ },
957
+ "@img/sharp-libvips-linux-x64@1.2.0": {
958
+ "@img/sharp-libvips-linux-x64": "private"
959
+ },
960
+ "@img/sharp-libvips-linuxmusl-x64@1.2.0": {
961
+ "@img/sharp-libvips-linuxmusl-x64": "private"
962
+ },
963
+ "@img/sharp-linux-x64@0.34.3": {
964
+ "@img/sharp-linux-x64": "private"
965
+ },
966
+ "@img/sharp-linuxmusl-x64@0.34.3": {
967
+ "@img/sharp-linuxmusl-x64": "private"
968
+ },
969
+ "client-only@0.0.1": {
970
+ "client-only": "private"
971
+ },
972
+ "@jridgewell/gen-mapping@0.3.12": {
973
+ "@jridgewell/gen-mapping": "private"
974
+ },
975
+ "commander@4.1.1": {
976
+ "commander": "private"
977
+ },
978
+ "lines-and-columns@1.2.4": {
979
+ "lines-and-columns": "private"
980
+ },
981
+ "mz@2.7.0": {
982
+ "mz": "private"
983
+ },
984
+ "pirates@4.0.7": {
985
+ "pirates": "private"
986
+ },
987
+ "ts-interface-checker@0.1.13": {
988
+ "ts-interface-checker": "private"
989
+ },
990
+ "b4a@1.6.7": {
991
+ "b4a": "private"
992
+ },
993
+ "fast-fifo@1.3.2": {
994
+ "fast-fifo": "private"
995
+ },
996
+ "streamx@2.22.1": {
997
+ "streamx": "private"
998
+ },
999
+ "@floating-ui/dom@1.7.4": {
1000
+ "@floating-ui/dom": "private"
1001
+ },
1002
+ "@jridgewell/sourcemap-codec@1.5.4": {
1003
+ "@jridgewell/sourcemap-codec": "private"
1004
+ },
1005
+ "@jridgewell/trace-mapping@0.3.29": {
1006
+ "@jridgewell/trace-mapping": "private"
1007
+ },
1008
+ "toad-cache@3.7.0": {
1009
+ "toad-cache": "private"
1010
+ },
1011
+ "universal-github-app-jwt@2.2.2": {
1012
+ "universal-github-app-jwt": "private"
1013
+ },
1014
+ "@octokit/auth-oauth-device@8.0.3": {
1015
+ "@octokit/auth-oauth-device": "private"
1016
+ },
1017
+ "@octokit/endpoint@11.0.2": {
1018
+ "@octokit/endpoint": "private"
1019
+ },
1020
+ "fast-content-type-parse@3.0.0": {
1021
+ "fast-content-type-parse": "private"
1022
+ },
1023
+ "@typescript-eslint/project-service@8.39.0(typescript@5.9.2)": {
1024
+ "@typescript-eslint/project-service": "private"
1025
+ },
1026
+ "@typescript-eslint/tsconfig-utils@8.39.0(typescript@5.9.2)": {
1027
+ "@typescript-eslint/tsconfig-utils": "private"
1028
+ },
1029
+ "color-convert@2.0.1": {
1030
+ "color-convert": "private"
1031
+ },
1032
+ "call-bind@1.0.8": {
1033
+ "call-bind": "private"
1034
+ },
1035
+ "call-bound@1.0.4": {
1036
+ "call-bound": "private"
1037
+ },
1038
+ "define-properties@1.2.1": {
1039
+ "define-properties": "private"
1040
+ },
1041
+ "es-abstract@1.24.0": {
1042
+ "es-abstract": "private"
1043
+ },
1044
+ "es-object-atoms@1.1.1": {
1045
+ "es-object-atoms": "private"
1046
+ },
1047
+ "get-intrinsic@1.3.0": {
1048
+ "get-intrinsic": "private"
1049
+ },
1050
+ "is-string@1.1.1": {
1051
+ "is-string": "private"
1052
+ },
1053
+ "math-intrinsics@1.1.0": {
1054
+ "math-intrinsics": "private"
1055
+ },
1056
+ "es-errors@1.3.0": {
1057
+ "es-errors": "private"
1058
+ },
1059
+ "es-shim-unscopables@1.1.0": {
1060
+ "es-shim-unscopables": "private"
1061
+ },
1062
+ "balanced-match@1.0.2": {
1063
+ "balanced-match": "private"
1064
+ },
1065
+ "concat-map@0.0.1": {
1066
+ "concat-map": "private"
1067
+ },
1068
+ "fill-range@7.1.1": {
1069
+ "fill-range": "private"
1070
+ },
1071
+ "color-string@1.9.1": {
1072
+ "color-string": "private"
1073
+ },
1074
+ "delayed-stream@1.0.0": {
1075
+ "delayed-stream": "private"
1076
+ },
1077
+ "vscode-languageserver-textdocument@1.0.12": {
1078
+ "vscode-languageserver-textdocument": "private"
1079
+ },
1080
+ "vscode-languageserver-types@3.17.5": {
1081
+ "vscode-languageserver-types": "private"
1082
+ },
1083
+ "function-bind@1.1.2": {
1084
+ "function-bind": "private"
1085
+ },
1086
+ "globalthis@1.0.4": {
1087
+ "globalthis": "private"
1088
+ },
1089
+ "gopd@1.2.0": {
1090
+ "gopd": "private"
1091
+ },
1092
+ "has-property-descriptors@1.0.2": {
1093
+ "has-property-descriptors": "private"
1094
+ },
1095
+ "has-proto@1.2.0": {
1096
+ "has-proto": "private"
1097
+ },
1098
+ "has-symbols@1.1.0": {
1099
+ "has-symbols": "private"
1100
+ },
1101
+ "internal-slot@1.1.0": {
1102
+ "internal-slot": "private"
1103
+ },
1104
+ "iterator.prototype@1.1.5": {
1105
+ "iterator.prototype": "private"
1106
+ },
1107
+ "safe-array-concat@1.1.3": {
1108
+ "safe-array-concat": "private"
1109
+ },
1110
+ "format@0.2.2": {
1111
+ "format": "private"
1112
+ },
1113
+ "flatted@3.3.3": {
1114
+ "flatted": "private"
1115
+ },
1116
+ "keyv@4.5.4": {
1117
+ "keyv": "private"
1118
+ },
1119
+ "resolve-pkg-maps@1.0.0": {
1120
+ "resolve-pkg-maps": "private"
1121
+ },
1122
+ "foreground-child@3.3.1": {
1123
+ "foreground-child": "private"
1124
+ },
1125
+ "jackspeak@3.4.3": {
1126
+ "jackspeak": "private"
1127
+ },
1128
+ "minipass@7.1.2": {
1129
+ "minipass": "private"
1130
+ },
1131
+ "package-json-from-dist@1.0.1": {
1132
+ "package-json-from-dist": "private"
1133
+ },
1134
+ "path-scurry@1.11.1": {
1135
+ "path-scurry": "private"
1136
+ },
1137
+ "@types/hast@2.3.10": {
1138
+ "@types/hast": "private"
1139
+ },
1140
+ "comma-separated-tokens@1.0.8": {
1141
+ "comma-separated-tokens": "private"
1142
+ },
1143
+ "hast-util-parse-selector@2.2.5": {
1144
+ "hast-util-parse-selector": "private"
1145
+ },
1146
+ "property-information@5.6.0": {
1147
+ "property-information": "private"
1148
+ },
1149
+ "space-separated-tokens@1.1.5": {
1150
+ "space-separated-tokens": "private"
1151
+ },
1152
+ "binary-extensions@2.3.0": {
1153
+ "binary-extensions": "private"
1154
+ },
1155
+ "object.assign@4.1.7": {
1156
+ "object.assign": "private"
1157
+ },
1158
+ "language-subtag-registry@0.3.23": {
1159
+ "language-subtag-registry": "private"
1160
+ },
1161
+ "p-locate@5.0.0": {
1162
+ "p-locate": "private"
1163
+ },
1164
+ "mime-db@1.52.0": {
1165
+ "mime-db": "private"
1166
+ },
1167
+ "any-promise@1.3.0": {
1168
+ "any-promise": "private"
1169
+ },
1170
+ "thenify-all@1.6.0": {
1171
+ "thenify-all": "private"
1172
+ },
1173
+ "openapi-typescript-helpers@0.0.8": {
1174
+ "openapi-typescript-helpers": "private"
1175
+ },
1176
+ "callsites@3.1.0": {
1177
+ "callsites": "private"
1178
+ },
1179
+ "character-entities@1.2.4": {
1180
+ "character-entities": "private"
1181
+ },
1182
+ "character-entities-legacy@1.1.4": {
1183
+ "character-entities-legacy": "private"
1184
+ },
1185
+ "character-reference-invalid@1.1.4": {
1186
+ "character-reference-invalid": "private"
1187
+ },
1188
+ "is-alphanumerical@1.0.4": {
1189
+ "is-alphanumerical": "private"
1190
+ },
1191
+ "is-decimal@1.0.4": {
1192
+ "is-decimal": "private"
1193
+ },
1194
+ "is-hexadecimal@1.0.4": {
1195
+ "is-hexadecimal": "private"
1196
+ },
1197
+ "loose-envify@1.4.0": {
1198
+ "loose-envify": "private"
1199
+ },
1200
+ "react-is@16.13.1": {
1201
+ "react-is": "private"
1202
+ },
1203
+ "get-nonce@1.0.1": {
1204
+ "get-nonce": "private"
1205
+ },
1206
+ "is-regex@1.2.1": {
1207
+ "is-regex": "private"
1208
+ },
1209
+ "shebang-regex@3.0.0": {
1210
+ "shebang-regex": "private"
1211
+ },
1212
+ "text-decoder@1.2.3": {
1213
+ "text-decoder": "private"
1214
+ },
1215
+ "bare-events@2.6.1": {
1216
+ "bare-events": "private"
1217
+ },
1218
+ "regexp.prototype.flags@1.5.4": {
1219
+ "regexp.prototype.flags": "private"
1220
+ },
1221
+ "set-function-name@2.0.2": {
1222
+ "set-function-name": "private"
1223
+ },
1224
+ "side-channel@1.1.0": {
1225
+ "side-channel": "private"
1226
+ },
1227
+ "has-flag@4.0.0": {
1228
+ "has-flag": "private"
1229
+ },
1230
+ "@isaacs/fs-minipass@4.0.1": {
1231
+ "@isaacs/fs-minipass": "private"
1232
+ },
1233
+ "chownr@3.0.0": {
1234
+ "chownr": "private"
1235
+ },
1236
+ "minizlib@3.0.2": {
1237
+ "minizlib": "private"
1238
+ },
1239
+ "mkdirp@3.0.1": {
1240
+ "mkdirp": "private"
1241
+ },
1242
+ "yallist@5.0.0": {
1243
+ "yallist": "private"
1244
+ },
1245
+ "fdir@6.4.6(picomatch@4.0.3)": {
1246
+ "fdir": "private"
1247
+ },
1248
+ "@types/json5@0.0.29": {
1249
+ "@types/json5": "private"
1250
+ },
1251
+ "json5@1.0.2": {
1252
+ "json5": "private"
1253
+ },
1254
+ "minimist@1.2.8": {
1255
+ "minimist": "private"
1256
+ },
1257
+ "strip-bom@3.0.0": {
1258
+ "strip-bom": "private"
1259
+ },
1260
+ "napi-postinstall@0.3.2": {
1261
+ "napi-postinstall": "private"
1262
+ },
1263
+ "@unrs/resolver-binding-linux-x64-gnu@1.11.1": {
1264
+ "@unrs/resolver-binding-linux-x64-gnu": "private"
1265
+ },
1266
+ "@unrs/resolver-binding-linux-x64-musl@1.11.1": {
1267
+ "@unrs/resolver-binding-linux-x64-musl": "private"
1268
+ },
1269
+ "escalade@3.2.0": {
1270
+ "escalade": "private"
1271
+ },
1272
+ "punycode@2.3.1": {
1273
+ "punycode": "private"
1274
+ },
1275
+ "detect-node-es@1.1.0": {
1276
+ "detect-node-es": "private"
1277
+ },
1278
+ "tr46@0.0.3": {
1279
+ "tr46": "private"
1280
+ },
1281
+ "webidl-conversions@3.0.1": {
1282
+ "webidl-conversions": "private"
1283
+ },
1284
+ "isexe@2.0.0": {
1285
+ "isexe": "private"
1286
+ },
1287
+ "@floating-ui/core@1.7.3": {
1288
+ "@floating-ui/core": "private"
1289
+ },
1290
+ "@floating-ui/utils@0.2.10": {
1291
+ "@floating-ui/utils": "private"
1292
+ },
1293
+ "@jridgewell/resolve-uri@3.1.2": {
1294
+ "@jridgewell/resolve-uri": "private"
1295
+ },
1296
+ "@nodelib/fs.scandir@2.1.5": {
1297
+ "@nodelib/fs.scandir": "private"
1298
+ },
1299
+ "fastq@1.19.1": {
1300
+ "fastq": "private"
1301
+ },
1302
+ "@types/unist@2.0.11": {
1303
+ "@types/unist": "private"
1304
+ },
1305
+ "call-bind-apply-helpers@1.0.2": {
1306
+ "call-bind-apply-helpers": "private"
1307
+ },
1308
+ "es-define-property@1.0.1": {
1309
+ "es-define-property": "private"
1310
+ },
1311
+ "set-function-length@1.2.2": {
1312
+ "set-function-length": "private"
1313
+ },
1314
+ "color-name@1.1.4": {
1315
+ "color-name": "private"
1316
+ },
1317
+ "simple-swizzle@0.2.2": {
1318
+ "simple-swizzle": "private"
1319
+ },
1320
+ "define-data-property@1.1.4": {
1321
+ "define-data-property": "private"
1322
+ },
1323
+ "object-keys@1.1.1": {
1324
+ "object-keys": "private"
1325
+ },
1326
+ "array-buffer-byte-length@1.0.2": {
1327
+ "array-buffer-byte-length": "private"
1328
+ },
1329
+ "arraybuffer.prototype.slice@1.0.4": {
1330
+ "arraybuffer.prototype.slice": "private"
1331
+ },
1332
+ "available-typed-arrays@1.0.7": {
1333
+ "available-typed-arrays": "private"
1334
+ },
1335
+ "data-view-buffer@1.0.2": {
1336
+ "data-view-buffer": "private"
1337
+ },
1338
+ "data-view-byte-length@1.0.2": {
1339
+ "data-view-byte-length": "private"
1340
+ },
1341
+ "data-view-byte-offset@1.0.1": {
1342
+ "data-view-byte-offset": "private"
1343
+ },
1344
+ "es-to-primitive@1.3.0": {
1345
+ "es-to-primitive": "private"
1346
+ },
1347
+ "function.prototype.name@1.1.8": {
1348
+ "function.prototype.name": "private"
1349
+ },
1350
+ "get-proto@1.0.1": {
1351
+ "get-proto": "private"
1352
+ },
1353
+ "get-symbol-description@1.1.0": {
1354
+ "get-symbol-description": "private"
1355
+ },
1356
+ "is-array-buffer@3.0.5": {
1357
+ "is-array-buffer": "private"
1358
+ },
1359
+ "is-callable@1.2.7": {
1360
+ "is-callable": "private"
1361
+ },
1362
+ "is-data-view@1.0.2": {
1363
+ "is-data-view": "private"
1364
+ },
1365
+ "is-negative-zero@2.0.3": {
1366
+ "is-negative-zero": "private"
1367
+ },
1368
+ "is-set@2.0.3": {
1369
+ "is-set": "private"
1370
+ },
1371
+ "is-shared-array-buffer@1.0.4": {
1372
+ "is-shared-array-buffer": "private"
1373
+ },
1374
+ "is-typed-array@1.1.15": {
1375
+ "is-typed-array": "private"
1376
+ },
1377
+ "is-weakref@1.1.1": {
1378
+ "is-weakref": "private"
1379
+ },
1380
+ "object-inspect@1.13.4": {
1381
+ "object-inspect": "private"
1382
+ },
1383
+ "own-keys@1.0.1": {
1384
+ "own-keys": "private"
1385
+ },
1386
+ "safe-push-apply@1.0.0": {
1387
+ "safe-push-apply": "private"
1388
+ },
1389
+ "set-proto@1.0.0": {
1390
+ "set-proto": "private"
1391
+ },
1392
+ "stop-iteration-iterator@1.1.0": {
1393
+ "stop-iteration-iterator": "private"
1394
+ },
1395
+ "string.prototype.trim@1.2.10": {
1396
+ "string.prototype.trim": "private"
1397
+ },
1398
+ "string.prototype.trimstart@1.0.8": {
1399
+ "string.prototype.trimstart": "private"
1400
+ },
1401
+ "typed-array-buffer@1.0.3": {
1402
+ "typed-array-buffer": "private"
1403
+ },
1404
+ "typed-array-byte-length@1.0.3": {
1405
+ "typed-array-byte-length": "private"
1406
+ },
1407
+ "typed-array-byte-offset@1.0.4": {
1408
+ "typed-array-byte-offset": "private"
1409
+ },
1410
+ "typed-array-length@1.0.7": {
1411
+ "typed-array-length": "private"
1412
+ },
1413
+ "unbox-primitive@1.1.0": {
1414
+ "unbox-primitive": "private"
1415
+ },
1416
+ "which-typed-array@1.1.19": {
1417
+ "which-typed-array": "private"
1418
+ },
1419
+ "to-regex-range@5.0.1": {
1420
+ "to-regex-range": "private"
1421
+ },
1422
+ "signal-exit@4.1.0": {
1423
+ "signal-exit": "private"
1424
+ },
1425
+ "is-alphabetical@1.0.4": {
1426
+ "is-alphabetical": "private"
1427
+ },
1428
+ "has-tostringtag@1.0.2": {
1429
+ "has-tostringtag": "private"
1430
+ },
1431
+ "@isaacs/cliui@8.0.2": {
1432
+ "@isaacs/cliui": "private"
1433
+ },
1434
+ "@pkgjs/parseargs@0.11.0": {
1435
+ "@pkgjs/parseargs": "private"
1436
+ },
1437
+ "json-buffer@3.0.1": {
1438
+ "json-buffer": "private"
1439
+ },
1440
+ "js-tokens@4.0.0": {
1441
+ "js-tokens": "private"
1442
+ },
1443
+ "@isaacs/brace-expansion@5.0.0": {
1444
+ "@isaacs/brace-expansion": "private"
1445
+ },
1446
+ "p-limit@3.1.0": {
1447
+ "p-limit": "private"
1448
+ },
1449
+ "lru-cache@10.4.3": {
1450
+ "lru-cache": "private"
1451
+ },
1452
+ "xtend@4.0.2": {
1453
+ "xtend": "private"
1454
+ },
1455
+ "thenify@3.3.1": {
1456
+ "thenify": "private"
1457
+ },
1458
+ "@isaacs/balanced-match@4.0.1": {
1459
+ "@isaacs/balanced-match": "private"
1460
+ },
1461
+ "string-width@5.1.2": {
1462
+ "string-width": "private"
1463
+ },
1464
+ "string-width@4.2.3": {
1465
+ "string-width-cjs": "private"
1466
+ },
1467
+ "strip-ansi@7.1.2": {
1468
+ "strip-ansi": "private"
1469
+ },
1470
+ "strip-ansi@6.0.1": {
1471
+ "strip-ansi-cjs": "private"
1472
+ },
1473
+ "wrap-ansi@8.1.0": {
1474
+ "wrap-ansi": "private"
1475
+ },
1476
+ "wrap-ansi@7.0.0": {
1477
+ "wrap-ansi-cjs": "private"
1478
+ },
1479
+ "run-parallel@1.2.0": {
1480
+ "run-parallel": "private"
1481
+ },
1482
+ "possible-typed-array-names@1.1.0": {
1483
+ "possible-typed-array-names": "private"
1484
+ },
1485
+ "is-date-object@1.1.0": {
1486
+ "is-date-object": "private"
1487
+ },
1488
+ "is-symbol@1.1.1": {
1489
+ "is-symbol": "private"
1490
+ },
1491
+ "reusify@1.1.0": {
1492
+ "reusify": "private"
1493
+ },
1494
+ "functions-have-names@1.2.3": {
1495
+ "functions-have-names": "private"
1496
+ },
1497
+ "dunder-proto@1.0.1": {
1498
+ "dunder-proto": "private"
1499
+ },
1500
+ "yocto-queue@0.1.0": {
1501
+ "yocto-queue": "private"
1502
+ },
1503
+ "isarray@2.0.5": {
1504
+ "isarray": "private"
1505
+ },
1506
+ "is-arrayish@0.3.2": {
1507
+ "is-arrayish": "private"
1508
+ },
1509
+ "is-number@7.0.0": {
1510
+ "is-number": "private"
1511
+ },
1512
+ "for-each@0.3.5": {
1513
+ "for-each": "private"
1514
+ },
1515
+ "reflect.getprototypeof@1.0.10": {
1516
+ "reflect.getprototypeof": "private"
1517
+ },
1518
+ "has-bigints@1.1.0": {
1519
+ "has-bigints": "private"
1520
+ },
1521
+ "which-boxed-primitive@1.1.1": {
1522
+ "which-boxed-primitive": "private"
1523
+ },
1524
+ "which-builtin-type@1.2.1": {
1525
+ "which-builtin-type": "private"
1526
+ },
1527
+ "queue-microtask@1.2.3": {
1528
+ "queue-microtask": "private"
1529
+ },
1530
+ "side-channel-list@1.0.0": {
1531
+ "side-channel-list": "private"
1532
+ },
1533
+ "side-channel-map@1.0.1": {
1534
+ "side-channel-map": "private"
1535
+ },
1536
+ "side-channel-weakmap@1.0.2": {
1537
+ "side-channel-weakmap": "private"
1538
+ },
1539
+ "is-fullwidth-code-point@3.0.0": {
1540
+ "is-fullwidth-code-point": "private"
1541
+ },
1542
+ "eastasianwidth@0.2.0": {
1543
+ "eastasianwidth": "private"
1544
+ },
1545
+ "ansi-regex@5.0.1": {
1546
+ "ansi-regex": "private"
1547
+ },
1548
+ "is-bigint@1.1.0": {
1549
+ "is-bigint": "private"
1550
+ },
1551
+ "is-boolean-object@1.2.2": {
1552
+ "is-boolean-object": "private"
1553
+ },
1554
+ "is-number-object@1.1.1": {
1555
+ "is-number-object": "private"
1556
+ },
1557
+ "is-async-function@2.1.1": {
1558
+ "is-async-function": "private"
1559
+ },
1560
+ "is-finalizationregistry@1.1.1": {
1561
+ "is-finalizationregistry": "private"
1562
+ },
1563
+ "is-generator-function@1.1.0": {
1564
+ "is-generator-function": "private"
1565
+ },
1566
+ "which-collection@1.0.2": {
1567
+ "which-collection": "private"
1568
+ },
1569
+ "async-function@1.0.0": {
1570
+ "async-function": "private"
1571
+ },
1572
+ "is-map@2.0.3": {
1573
+ "is-map": "private"
1574
+ },
1575
+ "is-weakmap@2.0.2": {
1576
+ "is-weakmap": "private"
1577
+ },
1578
+ "is-weakset@2.0.4": {
1579
+ "is-weakset": "private"
1580
+ }
1581
+ },
1582
+ "hoistPattern": [
1583
+ "*"
1584
+ ],
1585
+ "included": {
1586
+ "dependencies": true,
1587
+ "devDependencies": true,
1588
+ "optionalDependencies": true
1589
+ },
1590
+ "injectedDeps": {},
1591
+ "ignoredBuilds": [
1592
+ "unrs-resolver@1.11.1",
1593
+ "sharp@0.34.3"
1594
+ ],
1595
+ "layoutVersion": 5,
1596
+ "nodeLinker": "isolated",
1597
+ "packageManager": "pnpm@10.30.3",
1598
+ "pendingBuilds": [],
1599
+ "publicHoistPattern": [],
1600
+ "prunedAt": "Mon, 06 Jul 2026 22:03:10 GMT",
1601
+ "registries": {
1602
+ "default": "https://registry.npmjs.org/",
1603
+ "@jsr": "https://npm.jsr.io/"
1604
+ },
1605
+ "skipped": [
1606
+ "@emnapi/core@1.4.5",
1607
+ "@emnapi/runtime@1.4.5",
1608
+ "@emnapi/wasi-threads@1.0.4",
1609
+ "@img/sharp-darwin-arm64@0.34.3",
1610
+ "@img/sharp-darwin-x64@0.34.3",
1611
+ "@img/sharp-libvips-darwin-arm64@1.2.0",
1612
+ "@img/sharp-libvips-darwin-x64@1.2.0",
1613
+ "@img/sharp-libvips-linux-arm64@1.2.0",
1614
+ "@img/sharp-libvips-linux-arm@1.2.0",
1615
+ "@img/sharp-libvips-linux-ppc64@1.2.0",
1616
+ "@img/sharp-libvips-linux-s390x@1.2.0",
1617
+ "@img/sharp-libvips-linuxmusl-arm64@1.2.0",
1618
+ "@img/sharp-linux-arm64@0.34.3",
1619
+ "@img/sharp-linux-arm@0.34.3",
1620
+ "@img/sharp-linux-ppc64@0.34.3",
1621
+ "@img/sharp-linux-s390x@0.34.3",
1622
+ "@img/sharp-linuxmusl-arm64@0.34.3",
1623
+ "@img/sharp-wasm32@0.34.3",
1624
+ "@img/sharp-win32-arm64@0.34.3",
1625
+ "@img/sharp-win32-ia32@0.34.3",
1626
+ "@img/sharp-win32-x64@0.34.3",
1627
+ "@napi-rs/wasm-runtime@0.2.12",
1628
+ "@next/swc-darwin-arm64@15.4.3",
1629
+ "@next/swc-darwin-x64@15.4.3",
1630
+ "@next/swc-linux-arm64-gnu@15.4.3",
1631
+ "@next/swc-linux-arm64-musl@15.4.3",
1632
+ "@next/swc-win32-arm64-msvc@15.4.3",
1633
+ "@next/swc-win32-x64-msvc@15.4.3",
1634
+ "@tybys/wasm-util@0.10.0",
1635
+ "@unrs/resolver-binding-android-arm-eabi@1.11.1",
1636
+ "@unrs/resolver-binding-android-arm64@1.11.1",
1637
+ "@unrs/resolver-binding-darwin-arm64@1.11.1",
1638
+ "@unrs/resolver-binding-darwin-x64@1.11.1",
1639
+ "@unrs/resolver-binding-freebsd-x64@1.11.1",
1640
+ "@unrs/resolver-binding-linux-arm-gnueabihf@1.11.1",
1641
+ "@unrs/resolver-binding-linux-arm-musleabihf@1.11.1",
1642
+ "@unrs/resolver-binding-linux-arm64-gnu@1.11.1",
1643
+ "@unrs/resolver-binding-linux-arm64-musl@1.11.1",
1644
+ "@unrs/resolver-binding-linux-ppc64-gnu@1.11.1",
1645
+ "@unrs/resolver-binding-linux-riscv64-gnu@1.11.1",
1646
+ "@unrs/resolver-binding-linux-riscv64-musl@1.11.1",
1647
+ "@unrs/resolver-binding-linux-s390x-gnu@1.11.1",
1648
+ "@unrs/resolver-binding-wasm32-wasi@1.11.1",
1649
+ "@unrs/resolver-binding-win32-arm64-msvc@1.11.1",
1650
+ "@unrs/resolver-binding-win32-ia32-msvc@1.11.1",
1651
+ "@unrs/resolver-binding-win32-x64-msvc@1.11.1",
1652
+ "fsevents@2.3.3"
1653
+ ],
1654
+ "storeDir": "/home/jules/.local/share/pnpm/store/v10",
1655
+ "virtualStoreDir": ".pnpm",
1656
+ "virtualStoreDirMaxLength": 120
1657
+ }
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/CHANGELOG.md ADDED
@@ -0,0 +1,1378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @ai-sdk/anthropic
2
+
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [90d212f]
8
+ - @ai-sdk/provider-utils@3.0.1
9
+
10
+ ## 2.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - d5f588f: AI SDK 5
15
+
16
+ ### Patch Changes
17
+
18
+ - ad66c0e: feat (provider/anthropic): json response schema support via tool calls
19
+ - 8f2854f: feat (provider/anthropic): send web search tool calls
20
+ - 5d959e7: refactor: updated openai + anthropic tool use server side
21
+ - 8dfcb11: feat(anthropic/citation): text support for citations
22
+ - 9f73965: feat (provider/anthropic): parse websearch tool args
23
+ - e2aceaf: feat: add raw chunk support
24
+ - fdff8a4: fix(provider/anthropic): correct Claude 4 model ID format
25
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
26
+ - 4f26d59: feat(provider/anthropic): add disable parallel tool use option
27
+ - 25f3454: feat(provider/anthropic): add PDF citation support with document sources for streamText
28
+ - a85c85f: fix (provider/anthropic): streaming json output
29
+ - 5c9eec4: chore(providers/anthropic): switch to providerOptions
30
+ - 2e13791: feat(anthropic): add server-side web search support
31
+ - 66962ed: fix(packages): export node10 compatible types
32
+ - 075711d: fix (provider/anthropic): return stop finish reason for json output with tool
33
+ - 269683f: Add raw Anthropic usage information to provider metadata
34
+ - d601ed9: fix (provider/anthropic): send tool call id in tool-input-start chunk
35
+ - b9ddcdd: feat(anthropic): add text_editor_20250429 tool for Claude 4 models
36
+ - 91715e5: fix (provider/google-vertex): fix anthropic support for image urls in messages
37
+ - ca8aac6: feat (providers/anthropic): add claude v4 models
38
+ - 61ab528: Add support for URL-based PDF documents in the Anthropic provider
39
+ - 84577c8: fix (providers/anthropic): remove fine grained tool streaming beta
40
+ - d1a034f: feature: using Zod 4 for internal stuff
41
+ - 6392f60: fix(anthropic): resolve web search API validation errors with partial location + provider output
42
+ - 205077b: fix: improve Zod compatibility
43
+ - ee5a9c0: feat: streamText onChunk raw chunk support
44
+ - f418dd7: Added anthropic provider defined tool support to amazon bedrock
45
+ - 362b048: add web search tool support
46
+ - 399e056: fix: anthropic computer tool
47
+ - 0b678b2: feat (provider/anthropic): enable streaming tool calls
48
+ - f10304b: feat(tool-calling): don't require the user to have to pass parameters
49
+ - a753b3a: feat (provider/anthropic): cache control for tools
50
+ - Updated dependencies [a571d6e]
51
+ - Updated dependencies [742b7be]
52
+ - Updated dependencies [e7fcc86]
53
+ - Updated dependencies [7cddb72]
54
+ - Updated dependencies [ccce59b]
55
+ - Updated dependencies [e2b9e4b]
56
+ - Updated dependencies [95857aa]
57
+ - Updated dependencies [45c1ea2]
58
+ - Updated dependencies [6f6bb89]
59
+ - Updated dependencies [060370c]
60
+ - Updated dependencies [dc714f3]
61
+ - Updated dependencies [b5da06a]
62
+ - Updated dependencies [d1a1aa1]
63
+ - Updated dependencies [63f9e9b]
64
+ - Updated dependencies [5d142ab]
65
+ - Updated dependencies [d5f588f]
66
+ - Updated dependencies [e025824]
67
+ - Updated dependencies [0571b98]
68
+ - Updated dependencies [b6b43c7]
69
+ - Updated dependencies [4fef487]
70
+ - Updated dependencies [48d257a]
71
+ - Updated dependencies [0c0c0b3]
72
+ - Updated dependencies [0d2c085]
73
+ - Updated dependencies [40acf9b]
74
+ - Updated dependencies [9222aeb]
75
+ - Updated dependencies [e2aceaf]
76
+ - Updated dependencies [411e483]
77
+ - Updated dependencies [8ba77a7]
78
+ - Updated dependencies [7b3ae3f]
79
+ - Updated dependencies [a166433]
80
+ - Updated dependencies [26735b5]
81
+ - Updated dependencies [443d8ec]
82
+ - Updated dependencies [a8c8bd5]
83
+ - Updated dependencies [abf9a79]
84
+ - Updated dependencies [14c9410]
85
+ - Updated dependencies [e86be6f]
86
+ - Updated dependencies [9bf7291]
87
+ - Updated dependencies [2e13791]
88
+ - Updated dependencies [9f95b35]
89
+ - Updated dependencies [66962ed]
90
+ - Updated dependencies [0d06df6]
91
+ - Updated dependencies [472524a]
92
+ - Updated dependencies [dd3ff01]
93
+ - Updated dependencies [d9c98f4]
94
+ - Updated dependencies [05d2819]
95
+ - Updated dependencies [9301f86]
96
+ - Updated dependencies [0a87932]
97
+ - Updated dependencies [c4a2fec]
98
+ - Updated dependencies [957b739]
99
+ - Updated dependencies [79457bd]
100
+ - Updated dependencies [a3f768e]
101
+ - Updated dependencies [7435eb5]
102
+ - Updated dependencies [8aa9e20]
103
+ - Updated dependencies [4617fab]
104
+ - Updated dependencies [ac34802]
105
+ - Updated dependencies [0054544]
106
+ - Updated dependencies [cb68df0]
107
+ - Updated dependencies [ad80501]
108
+ - Updated dependencies [68ecf2f]
109
+ - Updated dependencies [9e9c809]
110
+ - Updated dependencies [32831c6]
111
+ - Updated dependencies [6dc848c]
112
+ - Updated dependencies [6b98118]
113
+ - Updated dependencies [d0f9495]
114
+ - Updated dependencies [63d791d]
115
+ - Updated dependencies [87b828f]
116
+ - Updated dependencies [3f2f00c]
117
+ - Updated dependencies [bfdca8d]
118
+ - Updated dependencies [0ff02bb]
119
+ - Updated dependencies [7979f7f]
120
+ - Updated dependencies [39a4fab]
121
+ - Updated dependencies [44f4aba]
122
+ - Updated dependencies [9bd5ab5]
123
+ - Updated dependencies [57edfcb]
124
+ - Updated dependencies [faf8446]
125
+ - Updated dependencies [7ea4132]
126
+ - Updated dependencies [d1a034f]
127
+ - Updated dependencies [5c56081]
128
+ - Updated dependencies [fd65bc6]
129
+ - Updated dependencies [023ba40]
130
+ - Updated dependencies [ea7a7c9]
131
+ - Updated dependencies [26535e0]
132
+ - Updated dependencies [e030615]
133
+ - Updated dependencies [5e57fae]
134
+ - Updated dependencies [393138b]
135
+ - Updated dependencies [c57e248]
136
+ - Updated dependencies [88a8ee5]
137
+ - Updated dependencies [41fa418]
138
+ - Updated dependencies [205077b]
139
+ - Updated dependencies [71f938d]
140
+ - Updated dependencies [3795467]
141
+ - Updated dependencies [28a5ed5]
142
+ - Updated dependencies [7182d14]
143
+ - Updated dependencies [c1e6647]
144
+ - Updated dependencies [1766ede]
145
+ - Updated dependencies [811dff3]
146
+ - Updated dependencies [f10304b]
147
+ - Updated dependencies [dd5fd43]
148
+ - Updated dependencies [33f4a6a]
149
+ - Updated dependencies [383cbfa]
150
+ - Updated dependencies [27deb4d]
151
+ - Updated dependencies [c4df419]
152
+ - @ai-sdk/provider-utils@3.0.0
153
+ - @ai-sdk/provider@2.0.0
154
+
155
+ ## 2.0.0-beta.13
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies [88a8ee5]
160
+ - @ai-sdk/provider-utils@3.0.0-beta.10
161
+
162
+ ## 2.0.0-beta.12
163
+
164
+ ### Patch Changes
165
+
166
+ - f418dd7: Added anthropic provider defined tool support to amazon bedrock
167
+ - Updated dependencies [27deb4d]
168
+ - @ai-sdk/provider@2.0.0-beta.2
169
+ - @ai-sdk/provider-utils@3.0.0-beta.9
170
+
171
+ ## 2.0.0-beta.11
172
+
173
+ ### Patch Changes
174
+
175
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
176
+ - Updated dependencies [dd5fd43]
177
+ - @ai-sdk/provider-utils@3.0.0-beta.8
178
+
179
+ ## 2.0.0-beta.10
180
+
181
+ ### Patch Changes
182
+
183
+ - 269683f: Add raw Anthropic usage information to provider metadata
184
+ - Updated dependencies [e7fcc86]
185
+ - @ai-sdk/provider-utils@3.0.0-beta.7
186
+
187
+ ## 2.0.0-beta.9
188
+
189
+ ### Patch Changes
190
+
191
+ - 4f26d59: feat(provider/anthropic): add disable parallel tool use option
192
+ - a753b3a: feat (provider/anthropic): cache control for tools
193
+ - Updated dependencies [ac34802]
194
+ - @ai-sdk/provider-utils@3.0.0-beta.6
195
+
196
+ ## 2.0.0-beta.8
197
+
198
+ ### Patch Changes
199
+
200
+ - Updated dependencies [57edfcb]
201
+ - Updated dependencies [383cbfa]
202
+ - @ai-sdk/provider-utils@3.0.0-beta.5
203
+
204
+ ## 2.0.0-beta.7
205
+
206
+ ### Patch Changes
207
+
208
+ - 205077b: fix: improve Zod compatibility
209
+ - Updated dependencies [205077b]
210
+ - @ai-sdk/provider-utils@3.0.0-beta.4
211
+
212
+ ## 2.0.0-beta.6
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [05d2819]
217
+ - @ai-sdk/provider-utils@3.0.0-beta.3
218
+
219
+ ## 2.0.0-beta.5
220
+
221
+ ### Patch Changes
222
+
223
+ - b9ddcdd: feat(anthropic): add text_editor_20250429 tool for Claude 4 models
224
+
225
+ ## 2.0.0-beta.4
226
+
227
+ ### Patch Changes
228
+
229
+ - fdff8a4: fix(provider/anthropic): correct Claude 4 model ID format
230
+ - 84577c8: fix (providers/anthropic): remove fine grained tool streaming beta
231
+
232
+ ## 2.0.0-beta.3
233
+
234
+ ### Patch Changes
235
+
236
+ - a85c85f: fix (provider/anthropic): streaming json output
237
+ - d1a034f: feature: using Zod 4 for internal stuff
238
+ - 0b678b2: feat (provider/anthropic): enable streaming tool calls
239
+ - Updated dependencies [0571b98]
240
+ - Updated dependencies [39a4fab]
241
+ - Updated dependencies [d1a034f]
242
+ - @ai-sdk/provider-utils@3.0.0-beta.2
243
+
244
+ ## 2.0.0-beta.2
245
+
246
+ ### Patch Changes
247
+
248
+ - d601ed9: fix (provider/anthropic): send tool call id in tool-input-start chunk
249
+
250
+ ## 2.0.0-beta.1
251
+
252
+ ### Patch Changes
253
+
254
+ - 8f2854f: feat (provider/anthropic): send web search tool calls
255
+ - 5d959e7: refactor: updated openai + anthropic tool use server side
256
+ - 9f73965: feat (provider/anthropic): parse websearch tool args
257
+ - 399e056: fix: anthropic computer tool
258
+ - Updated dependencies [742b7be]
259
+ - Updated dependencies [7cddb72]
260
+ - Updated dependencies [ccce59b]
261
+ - Updated dependencies [e2b9e4b]
262
+ - Updated dependencies [45c1ea2]
263
+ - Updated dependencies [e025824]
264
+ - Updated dependencies [0d06df6]
265
+ - Updated dependencies [472524a]
266
+ - Updated dependencies [dd3ff01]
267
+ - Updated dependencies [7435eb5]
268
+ - Updated dependencies [cb68df0]
269
+ - Updated dependencies [bfdca8d]
270
+ - Updated dependencies [44f4aba]
271
+ - Updated dependencies [023ba40]
272
+ - Updated dependencies [5e57fae]
273
+ - Updated dependencies [71f938d]
274
+ - Updated dependencies [28a5ed5]
275
+ - @ai-sdk/provider@2.0.0-beta.1
276
+ - @ai-sdk/provider-utils@3.0.0-beta.1
277
+
278
+ ## 2.0.0-alpha.15
279
+
280
+ ### Patch Changes
281
+
282
+ - Updated dependencies [48d257a]
283
+ - Updated dependencies [8ba77a7]
284
+ - @ai-sdk/provider@2.0.0-alpha.15
285
+ - @ai-sdk/provider-utils@3.0.0-alpha.15
286
+
287
+ ## 2.0.0-alpha.14
288
+
289
+ ### Patch Changes
290
+
291
+ - 2e13791: feat(anthropic): add server-side web search support
292
+ - 6392f60: fix(anthropic): resolve web search API validation errors with partial location + provider output
293
+ - Updated dependencies [b5da06a]
294
+ - Updated dependencies [63f9e9b]
295
+ - Updated dependencies [2e13791]
296
+ - @ai-sdk/provider@2.0.0-alpha.14
297
+ - @ai-sdk/provider-utils@3.0.0-alpha.14
298
+
299
+ ## 2.0.0-alpha.13
300
+
301
+ ### Patch Changes
302
+
303
+ - 8dfcb11: feat(anthropic/citation): text support for citations
304
+ - ee5a9c0: feat: streamText onChunk raw chunk support
305
+ - Updated dependencies [68ecf2f]
306
+ - @ai-sdk/provider@2.0.0-alpha.13
307
+ - @ai-sdk/provider-utils@3.0.0-alpha.13
308
+
309
+ ## 2.0.0-alpha.12
310
+
311
+ ### Patch Changes
312
+
313
+ - e2aceaf: feat: add raw chunk support
314
+ - Updated dependencies [e2aceaf]
315
+ - @ai-sdk/provider@2.0.0-alpha.12
316
+ - @ai-sdk/provider-utils@3.0.0-alpha.12
317
+
318
+ ## 2.0.0-alpha.11
319
+
320
+ ### Patch Changes
321
+
322
+ - 25f3454: feat(provider/anthropic): add PDF citation support with document sources for streamText
323
+ - Updated dependencies [c1e6647]
324
+ - @ai-sdk/provider@2.0.0-alpha.11
325
+ - @ai-sdk/provider-utils@3.0.0-alpha.11
326
+
327
+ ## 2.0.0-alpha.10
328
+
329
+ ### Patch Changes
330
+
331
+ - Updated dependencies [c4df419]
332
+ - @ai-sdk/provider@2.0.0-alpha.10
333
+ - @ai-sdk/provider-utils@3.0.0-alpha.10
334
+
335
+ ## 2.0.0-alpha.9
336
+
337
+ ### Patch Changes
338
+
339
+ - 362b048: add web search tool support
340
+ - Updated dependencies [811dff3]
341
+ - @ai-sdk/provider@2.0.0-alpha.9
342
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
343
+
344
+ ## 2.0.0-alpha.8
345
+
346
+ ### Patch Changes
347
+
348
+ - ad66c0e: feat (provider/anthropic): json response schema support via tool calls
349
+ - 075711d: fix (provider/anthropic): return stop finish reason for json output with tool
350
+ - Updated dependencies [4fef487]
351
+ - Updated dependencies [9222aeb]
352
+ - @ai-sdk/provider-utils@3.0.0-alpha.8
353
+ - @ai-sdk/provider@2.0.0-alpha.8
354
+
355
+ ## 2.0.0-alpha.7
356
+
357
+ ### Patch Changes
358
+
359
+ - Updated dependencies [5c56081]
360
+ - @ai-sdk/provider@2.0.0-alpha.7
361
+ - @ai-sdk/provider-utils@3.0.0-alpha.7
362
+
363
+ ## 2.0.0-alpha.6
364
+
365
+ ### Patch Changes
366
+
367
+ - Updated dependencies [0d2c085]
368
+ - @ai-sdk/provider@2.0.0-alpha.6
369
+ - @ai-sdk/provider-utils@3.0.0-alpha.6
370
+
371
+ ## 2.0.0-alpha.4
372
+
373
+ ### Patch Changes
374
+
375
+ - ca8aac6: feat (providers/anthropic): add claude v4 models
376
+ - Updated dependencies [dc714f3]
377
+ - @ai-sdk/provider@2.0.0-alpha.4
378
+ - @ai-sdk/provider-utils@3.0.0-alpha.4
379
+
380
+ ## 2.0.0-alpha.3
381
+
382
+ ### Patch Changes
383
+
384
+ - Updated dependencies [6b98118]
385
+ - @ai-sdk/provider@2.0.0-alpha.3
386
+ - @ai-sdk/provider-utils@3.0.0-alpha.3
387
+
388
+ ## 2.0.0-alpha.2
389
+
390
+ ### Patch Changes
391
+
392
+ - Updated dependencies [26535e0]
393
+ - @ai-sdk/provider@2.0.0-alpha.2
394
+ - @ai-sdk/provider-utils@3.0.0-alpha.2
395
+
396
+ ## 2.0.0-alpha.1
397
+
398
+ ### Patch Changes
399
+
400
+ - Updated dependencies [3f2f00c]
401
+ - @ai-sdk/provider@2.0.0-alpha.1
402
+ - @ai-sdk/provider-utils@3.0.0-alpha.1
403
+
404
+ ## 2.0.0-canary.19
405
+
406
+ ### Patch Changes
407
+
408
+ - Updated dependencies [faf8446]
409
+ - @ai-sdk/provider-utils@3.0.0-canary.19
410
+
411
+ ## 2.0.0-canary.18
412
+
413
+ ### Patch Changes
414
+
415
+ - Updated dependencies [40acf9b]
416
+ - @ai-sdk/provider-utils@3.0.0-canary.18
417
+
418
+ ## 2.0.0-canary.17
419
+
420
+ ### Patch Changes
421
+
422
+ - Updated dependencies [ea7a7c9]
423
+ - @ai-sdk/provider-utils@3.0.0-canary.17
424
+
425
+ ## 2.0.0-canary.16
426
+
427
+ ### Patch Changes
428
+
429
+ - Updated dependencies [87b828f]
430
+ - @ai-sdk/provider-utils@3.0.0-canary.16
431
+
432
+ ## 2.0.0-canary.15
433
+
434
+ ### Patch Changes
435
+
436
+ - Updated dependencies [a571d6e]
437
+ - Updated dependencies [a8c8bd5]
438
+ - Updated dependencies [7979f7f]
439
+ - Updated dependencies [41fa418]
440
+ - @ai-sdk/provider-utils@3.0.0-canary.15
441
+ - @ai-sdk/provider@2.0.0-canary.14
442
+
443
+ ## 2.0.0-canary.14
444
+
445
+ ### Patch Changes
446
+
447
+ - Updated dependencies [957b739]
448
+ - Updated dependencies [9bd5ab5]
449
+ - @ai-sdk/provider-utils@3.0.0-canary.14
450
+ - @ai-sdk/provider@2.0.0-canary.13
451
+
452
+ ## 2.0.0-canary.13
453
+
454
+ ### Patch Changes
455
+
456
+ - Updated dependencies [7b3ae3f]
457
+ - Updated dependencies [0ff02bb]
458
+ - @ai-sdk/provider@2.0.0-canary.12
459
+ - @ai-sdk/provider-utils@3.0.0-canary.13
460
+
461
+ ## 2.0.0-canary.12
462
+
463
+ ### Patch Changes
464
+
465
+ - 5c9eec4: chore(providers/anthropic): switch to providerOptions
466
+ - Updated dependencies [9bf7291]
467
+ - Updated dependencies [4617fab]
468
+ - Updated dependencies [e030615]
469
+ - @ai-sdk/provider@2.0.0-canary.11
470
+ - @ai-sdk/provider-utils@3.0.0-canary.12
471
+
472
+ ## 2.0.0-canary.11
473
+
474
+ ### Patch Changes
475
+
476
+ - 66962ed: fix(packages): export node10 compatible types
477
+ - Updated dependencies [66962ed]
478
+ - Updated dependencies [9301f86]
479
+ - Updated dependencies [a3f768e]
480
+ - @ai-sdk/provider-utils@3.0.0-canary.11
481
+ - @ai-sdk/provider@2.0.0-canary.10
482
+
483
+ ## 2.0.0-canary.10
484
+
485
+ ### Patch Changes
486
+
487
+ - Updated dependencies [e86be6f]
488
+ - @ai-sdk/provider@2.0.0-canary.9
489
+ - @ai-sdk/provider-utils@3.0.0-canary.10
490
+
491
+ ## 2.0.0-canary.9
492
+
493
+ ### Patch Changes
494
+
495
+ - Updated dependencies [95857aa]
496
+ - Updated dependencies [7ea4132]
497
+ - @ai-sdk/provider@2.0.0-canary.8
498
+ - @ai-sdk/provider-utils@3.0.0-canary.9
499
+
500
+ ## 2.0.0-canary.8
501
+
502
+ ### Patch Changes
503
+
504
+ - Updated dependencies [5d142ab]
505
+ - Updated dependencies [b6b43c7]
506
+ - Updated dependencies [8aa9e20]
507
+ - Updated dependencies [3795467]
508
+ - @ai-sdk/provider-utils@3.0.0-canary.8
509
+ - @ai-sdk/provider@2.0.0-canary.7
510
+
511
+ ## 2.0.0-canary.7
512
+
513
+ ### Patch Changes
514
+
515
+ - Updated dependencies [26735b5]
516
+ - Updated dependencies [443d8ec]
517
+ - Updated dependencies [14c9410]
518
+ - Updated dependencies [d9c98f4]
519
+ - Updated dependencies [c4a2fec]
520
+ - Updated dependencies [0054544]
521
+ - Updated dependencies [9e9c809]
522
+ - Updated dependencies [32831c6]
523
+ - Updated dependencies [d0f9495]
524
+ - Updated dependencies [fd65bc6]
525
+ - Updated dependencies [393138b]
526
+ - Updated dependencies [7182d14]
527
+ - @ai-sdk/provider@2.0.0-canary.6
528
+ - @ai-sdk/provider-utils@3.0.0-canary.7
529
+
530
+ ## 2.0.0-canary.6
531
+
532
+ ### Patch Changes
533
+
534
+ - f10304b: feat(tool-calling): don't require the user to have to pass parameters
535
+ - Updated dependencies [411e483]
536
+ - Updated dependencies [79457bd]
537
+ - Updated dependencies [ad80501]
538
+ - Updated dependencies [1766ede]
539
+ - Updated dependencies [f10304b]
540
+ - @ai-sdk/provider@2.0.0-canary.5
541
+ - @ai-sdk/provider-utils@3.0.0-canary.6
542
+
543
+ ## 2.0.0-canary.5
544
+
545
+ ### Patch Changes
546
+
547
+ - Updated dependencies [6f6bb89]
548
+ - @ai-sdk/provider@2.0.0-canary.4
549
+ - @ai-sdk/provider-utils@3.0.0-canary.5
550
+
551
+ ## 2.0.0-canary.4
552
+
553
+ ### Patch Changes
554
+
555
+ - Updated dependencies [d1a1aa1]
556
+ - @ai-sdk/provider@2.0.0-canary.3
557
+ - @ai-sdk/provider-utils@3.0.0-canary.4
558
+
559
+ ## 2.0.0-canary.3
560
+
561
+ ### Patch Changes
562
+
563
+ - 61ab528: Add support for URL-based PDF documents in the Anthropic provider
564
+ - Updated dependencies [a166433]
565
+ - Updated dependencies [abf9a79]
566
+ - Updated dependencies [9f95b35]
567
+ - Updated dependencies [0a87932]
568
+ - Updated dependencies [6dc848c]
569
+ - @ai-sdk/provider-utils@3.0.0-canary.3
570
+ - @ai-sdk/provider@2.0.0-canary.2
571
+
572
+ ## 2.0.0-canary.2
573
+
574
+ ### Patch Changes
575
+
576
+ - Updated dependencies [c57e248]
577
+ - Updated dependencies [33f4a6a]
578
+ - @ai-sdk/provider@2.0.0-canary.1
579
+ - @ai-sdk/provider-utils@3.0.0-canary.2
580
+
581
+ ## 2.0.0-canary.1
582
+
583
+ ### Patch Changes
584
+
585
+ - Updated dependencies [060370c]
586
+ - Updated dependencies [0c0c0b3]
587
+ - Updated dependencies [63d791d]
588
+ - @ai-sdk/provider-utils@3.0.0-canary.1
589
+
590
+ ## 2.0.0-canary.0
591
+
592
+ ### Major Changes
593
+
594
+ - d5f588f: AI SDK 5
595
+
596
+ ### Patch Changes
597
+
598
+ - 91715e5: fix (provider/google-vertex): fix anthropic support for image urls in messages
599
+ - Updated dependencies [d5f588f]
600
+ - @ai-sdk/provider-utils@3.0.0-canary.0
601
+ - @ai-sdk/provider@2.0.0-canary.0
602
+
603
+ ## 1.2.4
604
+
605
+ ### Patch Changes
606
+
607
+ - Updated dependencies [28be004]
608
+ - @ai-sdk/provider-utils@2.2.3
609
+
610
+ ## 1.2.3
611
+
612
+ ### Patch Changes
613
+
614
+ - Updated dependencies [b01120e]
615
+ - @ai-sdk/provider-utils@2.2.2
616
+
617
+ ## 1.2.2
618
+
619
+ ### Patch Changes
620
+
621
+ - aeaa92b: feat (provider/anthropic): expose type for validating Anthropic responses provider options
622
+
623
+ ## 1.2.1
624
+
625
+ ### Patch Changes
626
+
627
+ - Updated dependencies [f10f0fa]
628
+ - @ai-sdk/provider-utils@2.2.1
629
+
630
+ ## 1.2.0
631
+
632
+ ### Minor Changes
633
+
634
+ - 5bc638d: AI SDK 4.2
635
+
636
+ ### Patch Changes
637
+
638
+ - Updated dependencies [5bc638d]
639
+ - @ai-sdk/provider@1.1.0
640
+ - @ai-sdk/provider-utils@2.2.0
641
+
642
+ ## 1.1.19
643
+
644
+ ### Patch Changes
645
+
646
+ - Updated dependencies [d0c4659]
647
+ - @ai-sdk/provider-utils@2.1.15
648
+
649
+ ## 1.1.18
650
+
651
+ ### Patch Changes
652
+
653
+ - Updated dependencies [0bd5bc6]
654
+ - @ai-sdk/provider@1.0.12
655
+ - @ai-sdk/provider-utils@2.1.14
656
+
657
+ ## 1.1.17
658
+
659
+ ### Patch Changes
660
+
661
+ - Updated dependencies [2e1101a]
662
+ - @ai-sdk/provider@1.0.11
663
+ - @ai-sdk/provider-utils@2.1.13
664
+
665
+ ## 1.1.16
666
+
667
+ ### Patch Changes
668
+
669
+ - Updated dependencies [1531959]
670
+ - @ai-sdk/provider-utils@2.1.12
671
+
672
+ ## 1.1.15
673
+
674
+ ### Patch Changes
675
+
676
+ - e1d3d42: feat (ai): expose raw response body in generateText and generateObject
677
+ - Updated dependencies [e1d3d42]
678
+ - @ai-sdk/provider@1.0.10
679
+ - @ai-sdk/provider-utils@2.1.11
680
+
681
+ ## 1.1.14
682
+
683
+ ### Patch Changes
684
+
685
+ - 0e8b66c: feat (provider/anthropic): support image urls
686
+
687
+ ## 1.1.13
688
+
689
+ ### Patch Changes
690
+
691
+ - 3004b14: feat(provider/anthropic): add bash_20250124 and text_editor_20250124 tools
692
+
693
+ ## 1.1.12
694
+
695
+ ### Patch Changes
696
+
697
+ - b3e5a15: fix (provider/anthropic): add model setting to allow omitting reasoning content from model requests
698
+
699
+ ## 1.1.11
700
+
701
+ ### Patch Changes
702
+
703
+ - 00276ae: feat (provider/anthropic): update types for Anthropic computer_20250124 tool
704
+ - a4f8714: feat (provider/anthropic): update beta flag for sonnet-3-7 when using new computer-use tool
705
+
706
+ ## 1.1.10
707
+
708
+ ### Patch Changes
709
+
710
+ - ddf9740: feat (ai): add anthropic reasoning
711
+ - Updated dependencies [ddf9740]
712
+ - @ai-sdk/provider@1.0.9
713
+ - @ai-sdk/provider-utils@2.1.10
714
+
715
+ ## 1.1.9
716
+
717
+ ### Patch Changes
718
+
719
+ - Updated dependencies [2761f06]
720
+ - @ai-sdk/provider@1.0.8
721
+ - @ai-sdk/provider-utils@2.1.9
722
+
723
+ ## 1.1.8
724
+
725
+ ### Patch Changes
726
+
727
+ - Updated dependencies [2e898b4]
728
+ - @ai-sdk/provider-utils@2.1.8
729
+
730
+ ## 1.1.7
731
+
732
+ ### Patch Changes
733
+
734
+ - Updated dependencies [3ff4ef8]
735
+ - @ai-sdk/provider-utils@2.1.7
736
+
737
+ ## 1.1.6
738
+
739
+ ### Patch Changes
740
+
741
+ - Updated dependencies [d89c3b9]
742
+ - @ai-sdk/provider@1.0.7
743
+ - @ai-sdk/provider-utils@2.1.6
744
+
745
+ ## 1.1.5
746
+
747
+ ### Patch Changes
748
+
749
+ - Updated dependencies [3a602ca]
750
+ - @ai-sdk/provider-utils@2.1.5
751
+
752
+ ## 1.1.4
753
+
754
+ ### Patch Changes
755
+
756
+ - Updated dependencies [066206e]
757
+ - @ai-sdk/provider-utils@2.1.4
758
+
759
+ ## 1.1.3
760
+
761
+ ### Patch Changes
762
+
763
+ - Updated dependencies [39e5c1f]
764
+ - @ai-sdk/provider-utils@2.1.3
765
+
766
+ ## 1.1.2
767
+
768
+ ### Patch Changes
769
+
770
+ - Updated dependencies [ed012d2]
771
+ - Updated dependencies [3a58a2e]
772
+ - @ai-sdk/provider-utils@2.1.2
773
+ - @ai-sdk/provider@1.0.6
774
+
775
+ ## 1.1.1
776
+
777
+ ### Patch Changes
778
+
779
+ - 858f934: feat (provider/anthropic): default cache-control on and mark model setting deprecated
780
+ - b284e2c: feat (provider/google-vertex): support prompt caching for Anthropic Claude models
781
+ - Updated dependencies [e7a9ec9]
782
+ - Updated dependencies [0a699f1]
783
+ - @ai-sdk/provider-utils@2.1.1
784
+ - @ai-sdk/provider@1.0.5
785
+
786
+ ## 1.1.0
787
+
788
+ ### Minor Changes
789
+
790
+ - 62ba5ad: release: AI SDK 4.1
791
+
792
+ ### Patch Changes
793
+
794
+ - Updated dependencies [62ba5ad]
795
+ - @ai-sdk/provider-utils@2.1.0
796
+
797
+ ## 1.0.9
798
+
799
+ ### Patch Changes
800
+
801
+ - Updated dependencies [00114c5]
802
+ - @ai-sdk/provider-utils@2.0.8
803
+
804
+ ## 1.0.8
805
+
806
+ ### Patch Changes
807
+
808
+ - Updated dependencies [90fb95a]
809
+ - Updated dependencies [e6dfef4]
810
+ - Updated dependencies [6636db6]
811
+ - @ai-sdk/provider-utils@2.0.7
812
+
813
+ ## 1.0.7
814
+
815
+ ### Patch Changes
816
+
817
+ - Updated dependencies [19a2ce7]
818
+ - Updated dependencies [19a2ce7]
819
+ - Updated dependencies [6337688]
820
+ - @ai-sdk/provider@1.0.4
821
+ - @ai-sdk/provider-utils@2.0.6
822
+
823
+ ## 1.0.6
824
+
825
+ ### Patch Changes
826
+
827
+ - 5ed5e45: chore (config): Use ts-library.json tsconfig for no-UI libs.
828
+ - Updated dependencies [5ed5e45]
829
+ - @ai-sdk/provider-utils@2.0.5
830
+ - @ai-sdk/provider@1.0.3
831
+
832
+ ## 1.0.5
833
+
834
+ ### Patch Changes
835
+
836
+ - Updated dependencies [09a9cab]
837
+ - @ai-sdk/provider@1.0.2
838
+ - @ai-sdk/provider-utils@2.0.4
839
+
840
+ ## 1.0.4
841
+
842
+ ### Patch Changes
843
+
844
+ - bcd892e: feat (provider/google-vertex): Add support for Anthropic models.
845
+
846
+ ## 1.0.3
847
+
848
+ ### Patch Changes
849
+
850
+ - Updated dependencies [0984f0b]
851
+ - @ai-sdk/provider-utils@2.0.3
852
+
853
+ ## 1.0.2
854
+
855
+ ### Patch Changes
856
+
857
+ - Updated dependencies [b446ae5]
858
+ - @ai-sdk/provider@1.0.1
859
+ - @ai-sdk/provider-utils@2.0.2
860
+
861
+ ## 1.0.1
862
+
863
+ ### Patch Changes
864
+
865
+ - Updated dependencies [c3ab5de]
866
+ - @ai-sdk/provider-utils@2.0.1
867
+
868
+ ## 1.0.0
869
+
870
+ ### Major Changes
871
+
872
+ - 66060f7: chore (release): bump major version to 4.0
873
+ - 0d3d3f5: chore (providers): remove baseUrl option
874
+ - 8ad0504: chore (provider/anthropic): remove Anthropic facade
875
+ - 2f6e8c0: chore (provider/anthropic): remove topK model setting
876
+
877
+ ### Patch Changes
878
+
879
+ - Updated dependencies [b469a7e]
880
+ - Updated dependencies [dce4158]
881
+ - Updated dependencies [c0ddc24]
882
+ - Updated dependencies [b1da952]
883
+ - Updated dependencies [dce4158]
884
+ - Updated dependencies [8426f55]
885
+ - Updated dependencies [db46ce5]
886
+ - @ai-sdk/provider-utils@2.0.0
887
+ - @ai-sdk/provider@1.0.0
888
+
889
+ ## 1.0.0-canary.4
890
+
891
+ ### Major Changes
892
+
893
+ - 2f6e8c0: chore (provider/anthropic): remove topK model setting
894
+
895
+ ## 1.0.0-canary.3
896
+
897
+ ### Patch Changes
898
+
899
+ - Updated dependencies [8426f55]
900
+ - @ai-sdk/provider-utils@2.0.0-canary.3
901
+
902
+ ## 1.0.0-canary.2
903
+
904
+ ### Patch Changes
905
+
906
+ - Updated dependencies [dce4158]
907
+ - Updated dependencies [dce4158]
908
+ - @ai-sdk/provider-utils@2.0.0-canary.2
909
+
910
+ ## 1.0.0-canary.1
911
+
912
+ ### Major Changes
913
+
914
+ - 0d3d3f5: chore (providers): remove baseUrl option
915
+ - 8ad0504: chore (provider/anthropic): remove Anthropic facade
916
+
917
+ ### Patch Changes
918
+
919
+ - Updated dependencies [b1da952]
920
+ - @ai-sdk/provider-utils@2.0.0-canary.1
921
+
922
+ ## 1.0.0-canary.0
923
+
924
+ ### Major Changes
925
+
926
+ - 66060f7: chore (release): bump major version to 4.0
927
+
928
+ ### Patch Changes
929
+
930
+ - Updated dependencies [b469a7e]
931
+ - Updated dependencies [c0ddc24]
932
+ - Updated dependencies [db46ce5]
933
+ - @ai-sdk/provider-utils@2.0.0-canary.0
934
+ - @ai-sdk/provider@1.0.0-canary.0
935
+
936
+ ## 0.0.56
937
+
938
+ ### Patch Changes
939
+
940
+ - e6042b1: feat (provider/anthropic): add haiku 3.5 model ids
941
+
942
+ ## 0.0.55
943
+
944
+ ### Patch Changes
945
+
946
+ - ac380e3: fix (provider/anthropic): continuation mode with 3+ steps
947
+
948
+ ## 0.0.54
949
+
950
+ ### Patch Changes
951
+
952
+ - 4d2e53b: feat (provider/anthropic): pdf support
953
+ - c8afcb5: feat (provider/anthropic): allow using computer use and cache control at the same time
954
+
955
+ ## 0.0.53
956
+
957
+ ### Patch Changes
958
+
959
+ - 3b1b69a: feat (provider/anthropic): add computer use tools
960
+ - 3b1b69a: feat: provider-defined tools
961
+ - 8c222cd: feat (provider/anthropic): update model ids
962
+ - 811a317: feat (ai/core): multi-part tool results (incl. images)
963
+ - Updated dependencies [aa98cdb]
964
+ - Updated dependencies [1486128]
965
+ - Updated dependencies [7b937c5]
966
+ - Updated dependencies [3b1b69a]
967
+ - Updated dependencies [811a317]
968
+ - @ai-sdk/provider-utils@1.0.22
969
+ - @ai-sdk/provider@0.0.26
970
+
971
+ ## 0.0.52
972
+
973
+ ### Patch Changes
974
+
975
+ - b9b0d7b: feat (ai): access raw request body
976
+ - Updated dependencies [b9b0d7b]
977
+ - @ai-sdk/provider@0.0.25
978
+ - @ai-sdk/provider-utils@1.0.21
979
+
980
+ ## 0.0.51
981
+
982
+ ### Patch Changes
983
+
984
+ - Updated dependencies [d595d0d]
985
+ - @ai-sdk/provider@0.0.24
986
+ - @ai-sdk/provider-utils@1.0.20
987
+
988
+ ## 0.0.50
989
+
990
+ ### Patch Changes
991
+
992
+ - Updated dependencies [273f696]
993
+ - @ai-sdk/provider-utils@1.0.19
994
+
995
+ ## 0.0.49
996
+
997
+ ### Patch Changes
998
+
999
+ - 03313cd: feat (ai): expose response id, response model, response timestamp in telemetry and api
1000
+ - 3be7c1c: fix (provider/anthropic): support prompt caching on assistant messages
1001
+ - Updated dependencies [03313cd]
1002
+ - Updated dependencies [3be7c1c]
1003
+ - @ai-sdk/provider-utils@1.0.18
1004
+ - @ai-sdk/provider@0.0.23
1005
+
1006
+ ## 0.0.48
1007
+
1008
+ ### Patch Changes
1009
+
1010
+ - 26515cb: feat (ai/provider): introduce ProviderV1 specification
1011
+ - Updated dependencies [26515cb]
1012
+ - @ai-sdk/provider@0.0.22
1013
+ - @ai-sdk/provider-utils@1.0.17
1014
+
1015
+ ## 0.0.47
1016
+
1017
+ ### Patch Changes
1018
+
1019
+ - Updated dependencies [09f895f]
1020
+ - @ai-sdk/provider-utils@1.0.16
1021
+
1022
+ ## 0.0.46
1023
+
1024
+ ### Patch Changes
1025
+
1026
+ - Updated dependencies [d67fa9c]
1027
+ - @ai-sdk/provider-utils@1.0.15
1028
+
1029
+ ## 0.0.45
1030
+
1031
+ ### Patch Changes
1032
+
1033
+ - 95a53a3: chore (provider/anthropic): remove tool calls beta header
1034
+
1035
+ ## 0.0.44
1036
+
1037
+ ### Patch Changes
1038
+
1039
+ - Updated dependencies [f2c025e]
1040
+ - @ai-sdk/provider@0.0.21
1041
+ - @ai-sdk/provider-utils@1.0.14
1042
+
1043
+ ## 0.0.43
1044
+
1045
+ ### Patch Changes
1046
+
1047
+ - 6ac355e: feat (provider/anthropic): add cache control support
1048
+ - Updated dependencies [6ac355e]
1049
+ - @ai-sdk/provider@0.0.20
1050
+ - @ai-sdk/provider-utils@1.0.13
1051
+
1052
+ ## 0.0.42
1053
+
1054
+ ### Patch Changes
1055
+
1056
+ - dd712ac: fix: use FetchFunction type to prevent self-reference
1057
+ - Updated dependencies [dd712ac]
1058
+ - @ai-sdk/provider-utils@1.0.12
1059
+
1060
+ ## 0.0.41
1061
+
1062
+ ### Patch Changes
1063
+
1064
+ - 89b18ca: fix (ai/provider): send finish reason 'unknown' by default
1065
+ - Updated dependencies [dd4a0f5]
1066
+ - @ai-sdk/provider@0.0.19
1067
+ - @ai-sdk/provider-utils@1.0.11
1068
+
1069
+ ## 0.0.40
1070
+
1071
+ ### Patch Changes
1072
+
1073
+ - Updated dependencies [4bd27a9]
1074
+ - Updated dependencies [845754b]
1075
+ - @ai-sdk/provider-utils@1.0.10
1076
+ - @ai-sdk/provider@0.0.18
1077
+
1078
+ ## 0.0.39
1079
+
1080
+ ### Patch Changes
1081
+
1082
+ - Updated dependencies [029af4c]
1083
+ - @ai-sdk/provider@0.0.17
1084
+ - @ai-sdk/provider-utils@1.0.9
1085
+
1086
+ ## 0.0.38
1087
+
1088
+ ### Patch Changes
1089
+
1090
+ - Updated dependencies [d58517b]
1091
+ - @ai-sdk/provider@0.0.16
1092
+ - @ai-sdk/provider-utils@1.0.8
1093
+
1094
+ ## 0.0.37
1095
+
1096
+ ### Patch Changes
1097
+
1098
+ - Updated dependencies [96aed25]
1099
+ - @ai-sdk/provider@0.0.15
1100
+ - @ai-sdk/provider-utils@1.0.7
1101
+
1102
+ ## 0.0.36
1103
+
1104
+ ### Patch Changes
1105
+
1106
+ - Updated dependencies [9614584]
1107
+ - Updated dependencies [0762a22]
1108
+ - @ai-sdk/provider-utils@1.0.6
1109
+
1110
+ ## 0.0.35
1111
+
1112
+ ### Patch Changes
1113
+
1114
+ - fe2128f0: feat (provider/anthropic): combine sequential assistant messages into one
1115
+
1116
+ ## 0.0.34
1117
+
1118
+ ### Patch Changes
1119
+
1120
+ - 7d0fd5a8: fix (provider/anthropic): handle error stream chunks
1121
+
1122
+ ## 0.0.33
1123
+
1124
+ ### Patch Changes
1125
+
1126
+ - a8d1c9e9: feat (ai/core): parallel image download
1127
+ - Updated dependencies [a8d1c9e9]
1128
+ - @ai-sdk/provider-utils@1.0.5
1129
+ - @ai-sdk/provider@0.0.14
1130
+
1131
+ ## 0.0.32
1132
+
1133
+ ### Patch Changes
1134
+
1135
+ - Updated dependencies [4f88248f]
1136
+ - @ai-sdk/provider-utils@1.0.4
1137
+
1138
+ ## 0.0.31
1139
+
1140
+ ### Patch Changes
1141
+
1142
+ - 2b9da0f0: feat (core): support stopSequences setting.
1143
+ - a5b58845: feat (core): support topK setting
1144
+ - 4aa8deb3: feat (provider): support responseFormat setting in provider api
1145
+ - 13b27ec6: chore (ai/core): remove grammar mode
1146
+ - Updated dependencies [2b9da0f0]
1147
+ - Updated dependencies [a5b58845]
1148
+ - Updated dependencies [4aa8deb3]
1149
+ - Updated dependencies [13b27ec6]
1150
+ - @ai-sdk/provider@0.0.13
1151
+ - @ai-sdk/provider-utils@1.0.3
1152
+
1153
+ ## 0.0.30
1154
+
1155
+ ### Patch Changes
1156
+
1157
+ - 4c6b80f7: chore (provider/anthropic): improve object-tool mode
1158
+
1159
+ ## 0.0.29
1160
+
1161
+ ### Patch Changes
1162
+
1163
+ - Updated dependencies [b7290943]
1164
+ - @ai-sdk/provider@0.0.12
1165
+ - @ai-sdk/provider-utils@1.0.2
1166
+
1167
+ ## 0.0.28
1168
+
1169
+ ### Patch Changes
1170
+
1171
+ - Updated dependencies [d481729f]
1172
+ - @ai-sdk/provider-utils@1.0.1
1173
+
1174
+ ## 0.0.27
1175
+
1176
+ ### Patch Changes
1177
+
1178
+ - 7e86b45e: fix (provider/anthropic): automatically trim trailing whitespace on pre-filled assistant responses
1179
+
1180
+ ## 0.0.26
1181
+
1182
+ ### Patch Changes
1183
+
1184
+ - 5edc6110: feat (ai/core): add custom request header support
1185
+ - Updated dependencies [5edc6110]
1186
+ - Updated dependencies [5edc6110]
1187
+ - Updated dependencies [5edc6110]
1188
+ - @ai-sdk/provider@0.0.11
1189
+ - @ai-sdk/provider-utils@1.0.0
1190
+
1191
+ ## 0.0.25
1192
+
1193
+ ### Patch Changes
1194
+
1195
+ - 91dc4296: chore (@ai-sdk/anthropic): remove anthropic-beta header
1196
+
1197
+ ## 0.0.24
1198
+
1199
+ ### Patch Changes
1200
+
1201
+ - 04800838: fix (@ai-sdk/anthropic): combine tool and user messages, combine system messages
1202
+
1203
+ ## 0.0.23
1204
+
1205
+ ### Patch Changes
1206
+
1207
+ - Updated dependencies [02f6a088]
1208
+ - @ai-sdk/provider-utils@0.0.16
1209
+
1210
+ ## 0.0.22
1211
+
1212
+ ### Patch Changes
1213
+
1214
+ - 0a22b05b: feat (@ai-sdk/anthropic): add claude-3.5-sonnet model
1215
+
1216
+ ## 0.0.21
1217
+
1218
+ ### Patch Changes
1219
+
1220
+ - Updated dependencies [85712895]
1221
+ - Updated dependencies [85712895]
1222
+ - @ai-sdk/provider-utils@0.0.15
1223
+
1224
+ ## 0.0.20
1225
+
1226
+ ### Patch Changes
1227
+
1228
+ - 4728c37f: feat (core): add text embedding model support to provider registry
1229
+ - 7910ae84: feat (providers): support custom fetch implementations
1230
+ - Updated dependencies [7910ae84]
1231
+ - @ai-sdk/provider-utils@0.0.14
1232
+
1233
+ ## 0.0.19
1234
+
1235
+ ### Patch Changes
1236
+
1237
+ - Updated dependencies [102ca22f]
1238
+ - @ai-sdk/provider@0.0.10
1239
+ - @ai-sdk/provider-utils@0.0.13
1240
+
1241
+ ## 0.0.18
1242
+
1243
+ ### Patch Changes
1244
+
1245
+ - 09295e2e: feat (@ai-sdk/anthropic): automatically download image URLs
1246
+ - Updated dependencies [09295e2e]
1247
+ - Updated dependencies [09295e2e]
1248
+ - Updated dependencies [043a5de2]
1249
+ - @ai-sdk/provider@0.0.9
1250
+ - @ai-sdk/provider-utils@0.0.12
1251
+
1252
+ ## 0.0.17
1253
+
1254
+ ### Patch Changes
1255
+
1256
+ - f39c0dd2: feat (provider): implement toolChoice support
1257
+ - Updated dependencies [f39c0dd2]
1258
+ - @ai-sdk/provider@0.0.8
1259
+ - @ai-sdk/provider-utils@0.0.11
1260
+
1261
+ ## 0.0.16
1262
+
1263
+ ### Patch Changes
1264
+
1265
+ - 24683b72: fix (providers): Zod is required dependency
1266
+ - Updated dependencies [8e780288]
1267
+ - @ai-sdk/provider@0.0.7
1268
+ - @ai-sdk/provider-utils@0.0.10
1269
+
1270
+ ## 0.0.15
1271
+
1272
+ ### Patch Changes
1273
+
1274
+ - Updated dependencies [6a50ac4]
1275
+ - Updated dependencies [6a50ac4]
1276
+ - @ai-sdk/provider@0.0.6
1277
+ - @ai-sdk/provider-utils@0.0.9
1278
+
1279
+ ## 0.0.14
1280
+
1281
+ ### Patch Changes
1282
+
1283
+ - 06e3934: feat (provider/anthropic): streaming tool calls
1284
+
1285
+ ## 0.0.13
1286
+
1287
+ ### Patch Changes
1288
+
1289
+ - Updated dependencies [0f6bc4e]
1290
+ - @ai-sdk/provider@0.0.5
1291
+ - @ai-sdk/provider-utils@0.0.8
1292
+
1293
+ ## 0.0.12
1294
+
1295
+ ### Patch Changes
1296
+
1297
+ - Updated dependencies [325ca55]
1298
+ - @ai-sdk/provider@0.0.4
1299
+ - @ai-sdk/provider-utils@0.0.7
1300
+
1301
+ ## 0.0.11
1302
+
1303
+ ### Patch Changes
1304
+
1305
+ - 5b01c13: feat (ai/core): add system message support in messages list
1306
+
1307
+ ## 0.0.10
1308
+
1309
+ ### Patch Changes
1310
+
1311
+ - Updated dependencies [276f22b]
1312
+ - @ai-sdk/provider-utils@0.0.6
1313
+
1314
+ ## 0.0.9
1315
+
1316
+ ### Patch Changes
1317
+
1318
+ - Updated dependencies [41d5736]
1319
+ - @ai-sdk/provider@0.0.3
1320
+ - @ai-sdk/provider-utils@0.0.5
1321
+
1322
+ ## 0.0.8
1323
+
1324
+ ### Patch Changes
1325
+
1326
+ - Updated dependencies [56ef84a]
1327
+ - @ai-sdk/provider-utils@0.0.4
1328
+
1329
+ ## 0.0.7
1330
+
1331
+ ### Patch Changes
1332
+
1333
+ - 25f3350: ai/core: add support for getting raw response headers.
1334
+ - Updated dependencies [d6431ae]
1335
+ - Updated dependencies [25f3350]
1336
+ - @ai-sdk/provider@0.0.2
1337
+ - @ai-sdk/provider-utils@0.0.3
1338
+
1339
+ ## 0.0.6
1340
+
1341
+ ### Patch Changes
1342
+
1343
+ - eb150a6: ai/core: remove scaling of setting values (breaking change). If you were using the temperature, frequency penalty, or presence penalty settings, you need to update the providers and adjust the setting values.
1344
+ - Updated dependencies [eb150a6]
1345
+ - @ai-sdk/provider-utils@0.0.2
1346
+ - @ai-sdk/provider@0.0.1
1347
+
1348
+ ## 0.0.5
1349
+
1350
+ ### Patch Changes
1351
+
1352
+ - c6fc35b: Add custom header support.
1353
+
1354
+ ## 0.0.4
1355
+
1356
+ ### Patch Changes
1357
+
1358
+ - ab60b18: Simplified model construction by directly calling provider functions. Add create... functions to create provider instances.
1359
+
1360
+ ## 0.0.3
1361
+
1362
+ ### Patch Changes
1363
+
1364
+ - 587240b: Standardize providers to offer .chat() method
1365
+
1366
+ ## 0.0.2
1367
+
1368
+ ### Patch Changes
1369
+
1370
+ - 2bff460: Fix build for release.
1371
+
1372
+ ## 0.0.1
1373
+
1374
+ ### Patch Changes
1375
+
1376
+ - 7b8791d: Rename baseUrl to baseURL. Automatically remove trailing slashes.
1377
+ - Updated dependencies [7b8791d]
1378
+ - @ai-sdk/provider-utils@0.0.1
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/LICENSE ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/README.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI SDK - Anthropic Provider
2
+
3
+ The **[Anthropic provider](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_post).
4
+
5
+ ## Setup
6
+
7
+ The Anthropic provider is available in the `@ai-sdk/anthropic` module. You can install it with
8
+
9
+ ```
10
+ npm i @ai-sdk/anthropic
11
+ ```
12
+
13
+ ## Provider Instance
14
+
15
+ You can import the default provider instance `anthropic` from `@ai-sdk/anthropic`:
16
+
17
+ ```ts
18
+ import { anthropic } from '@ai-sdk/anthropic';
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```ts
24
+ import { anthropic } from '@ai-sdk/anthropic';
25
+ import { generateText } from 'ai';
26
+
27
+ const { text } = await generateText({
28
+ model: anthropic('claude-3-haiku-20240307'),
29
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
30
+ });
31
+ ```
32
+
33
+ ## Documentation
34
+
35
+ Please check out the **[Anthropic provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic)** for more information.
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.d.mts ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { z } from 'zod/v4';
2
+ import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
+ import { FetchFunction } from '@ai-sdk/provider-utils';
5
+
6
+ type AnthropicMessagesModelId = 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
7
+ declare const anthropicProviderOptions: z.ZodObject<{
8
+ sendReasoning: z.ZodOptional<z.ZodBoolean>;
9
+ thinking: z.ZodOptional<z.ZodObject<{
10
+ type: z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
11
+ budgetTokens: z.ZodOptional<z.ZodNumber>;
12
+ }, z.core.$strip>>;
13
+ disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strip>;
15
+ type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
16
+
17
+ declare const anthropicTools: {
18
+ /**
19
+ * Creates a tool for running a bash command. Must have name "bash".
20
+ *
21
+ * Image results are supported.
22
+ *
23
+ * @param execute - The function to execute the tool. Optional.
24
+ */
25
+ bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
26
+ command: string;
27
+ restart?: boolean;
28
+ }, {}>;
29
+ /**
30
+ * Creates a tool for running a bash command. Must have name "bash".
31
+ *
32
+ * Image results are supported.
33
+ *
34
+ * @param execute - The function to execute the tool. Optional.
35
+ */
36
+ bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
37
+ command: string;
38
+ restart?: boolean;
39
+ }, {}>;
40
+ /**
41
+ * Creates a tool for editing text. Must have name "str_replace_editor".
42
+ */
43
+ textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
44
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
45
+ path: string;
46
+ file_text?: string;
47
+ insert_line?: number;
48
+ new_str?: string;
49
+ old_str?: string;
50
+ view_range?: number[];
51
+ }, {}>;
52
+ /**
53
+ * Creates a tool for editing text. Must have name "str_replace_editor".
54
+ */
55
+ textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
56
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
57
+ path: string;
58
+ file_text?: string;
59
+ insert_line?: number;
60
+ new_str?: string;
61
+ old_str?: string;
62
+ view_range?: number[];
63
+ }, {}>;
64
+ /**
65
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
66
+ * Note: This version does not support the "undo_edit" command.
67
+ */
68
+ textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
69
+ command: "view" | "create" | "str_replace" | "insert";
70
+ path: string;
71
+ file_text?: string;
72
+ insert_line?: number;
73
+ new_str?: string;
74
+ old_str?: string;
75
+ view_range?: number[];
76
+ }, {}>;
77
+ /**
78
+ * Creates a tool for executing actions on a computer. Must have name "computer".
79
+ *
80
+ * Image results are supported.
81
+ *
82
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
83
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
84
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
85
+ */
86
+ computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
87
+ action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
88
+ coordinate?: number[];
89
+ text?: string;
90
+ }, {
91
+ displayWidthPx: number;
92
+ displayHeightPx: number;
93
+ displayNumber?: number;
94
+ }>;
95
+ /**
96
+ * Creates a tool for executing actions on a computer. Must have name "computer".
97
+ *
98
+ * Image results are supported.
99
+ *
100
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
101
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
102
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
103
+ * @param execute - The function to execute the tool. Optional.
104
+ */
105
+ computer_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
106
+ action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
107
+ coordinate?: [number, number];
108
+ duration?: number;
109
+ scroll_amount?: number;
110
+ scroll_direction?: "up" | "down" | "left" | "right";
111
+ start_coordinate?: [number, number];
112
+ text?: string;
113
+ }, {
114
+ displayWidthPx: number;
115
+ displayHeightPx: number;
116
+ displayNumber?: number;
117
+ }>;
118
+ /**
119
+ * Creates a web search tool that gives Claude direct access to real-time web content.
120
+ * Must have name "web_search".
121
+ *
122
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
123
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
124
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
125
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
126
+ */
127
+ webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
128
+ query: string;
129
+ }, {
130
+ url: string;
131
+ title: string;
132
+ pageAge: string | null;
133
+ encryptedContent: string;
134
+ type: string;
135
+ }[], {
136
+ maxUses?: number;
137
+ allowedDomains?: string[];
138
+ blockedDomains?: string[];
139
+ userLocation?: {
140
+ type: "approximate";
141
+ city?: string;
142
+ region?: string;
143
+ country?: string;
144
+ timezone?: string;
145
+ };
146
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
147
+ query: string;
148
+ }, {
149
+ url: string;
150
+ title: string;
151
+ pageAge: string | null;
152
+ encryptedContent: string;
153
+ type: string;
154
+ }[]>;
155
+ };
156
+
157
+ interface AnthropicProvider extends ProviderV2 {
158
+ /**
159
+ Creates a model for text generation.
160
+ */
161
+ (modelId: AnthropicMessagesModelId): LanguageModelV2;
162
+ /**
163
+ Creates a model for text generation.
164
+ */
165
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV2;
166
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV2;
167
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV2;
168
+ /**
169
+ Anthropic-specific computer use tool.
170
+ */
171
+ tools: typeof anthropicTools;
172
+ }
173
+ interface AnthropicProviderSettings {
174
+ /**
175
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
176
+ The default prefix is `https://api.anthropic.com/v1`.
177
+ */
178
+ baseURL?: string;
179
+ /**
180
+ API key that is being send using the `x-api-key` header.
181
+ It defaults to the `ANTHROPIC_API_KEY` environment variable.
182
+ */
183
+ apiKey?: string;
184
+ /**
185
+ Custom headers to include in the requests.
186
+ */
187
+ headers?: Record<string, string>;
188
+ /**
189
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
190
+ or to provide a custom fetch implementation for e.g. testing.
191
+ */
192
+ fetch?: FetchFunction;
193
+ generateId?: () => string;
194
+ }
195
+ /**
196
+ Create an Anthropic provider instance.
197
+ */
198
+ declare function createAnthropic(options?: AnthropicProviderSettings): AnthropicProvider;
199
+ /**
200
+ Default Anthropic provider instance.
201
+ */
202
+ declare const anthropic: AnthropicProvider;
203
+
204
+ export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, anthropic, createAnthropic };
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.d.ts ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { z } from 'zod/v4';
2
+ import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
+ import { FetchFunction } from '@ai-sdk/provider-utils';
5
+
6
+ type AnthropicMessagesModelId = 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
7
+ declare const anthropicProviderOptions: z.ZodObject<{
8
+ sendReasoning: z.ZodOptional<z.ZodBoolean>;
9
+ thinking: z.ZodOptional<z.ZodObject<{
10
+ type: z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
11
+ budgetTokens: z.ZodOptional<z.ZodNumber>;
12
+ }, z.core.$strip>>;
13
+ disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strip>;
15
+ type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
16
+
17
+ declare const anthropicTools: {
18
+ /**
19
+ * Creates a tool for running a bash command. Must have name "bash".
20
+ *
21
+ * Image results are supported.
22
+ *
23
+ * @param execute - The function to execute the tool. Optional.
24
+ */
25
+ bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
26
+ command: string;
27
+ restart?: boolean;
28
+ }, {}>;
29
+ /**
30
+ * Creates a tool for running a bash command. Must have name "bash".
31
+ *
32
+ * Image results are supported.
33
+ *
34
+ * @param execute - The function to execute the tool. Optional.
35
+ */
36
+ bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
37
+ command: string;
38
+ restart?: boolean;
39
+ }, {}>;
40
+ /**
41
+ * Creates a tool for editing text. Must have name "str_replace_editor".
42
+ */
43
+ textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
44
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
45
+ path: string;
46
+ file_text?: string;
47
+ insert_line?: number;
48
+ new_str?: string;
49
+ old_str?: string;
50
+ view_range?: number[];
51
+ }, {}>;
52
+ /**
53
+ * Creates a tool for editing text. Must have name "str_replace_editor".
54
+ */
55
+ textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
56
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
57
+ path: string;
58
+ file_text?: string;
59
+ insert_line?: number;
60
+ new_str?: string;
61
+ old_str?: string;
62
+ view_range?: number[];
63
+ }, {}>;
64
+ /**
65
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
66
+ * Note: This version does not support the "undo_edit" command.
67
+ */
68
+ textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
69
+ command: "view" | "create" | "str_replace" | "insert";
70
+ path: string;
71
+ file_text?: string;
72
+ insert_line?: number;
73
+ new_str?: string;
74
+ old_str?: string;
75
+ view_range?: number[];
76
+ }, {}>;
77
+ /**
78
+ * Creates a tool for executing actions on a computer. Must have name "computer".
79
+ *
80
+ * Image results are supported.
81
+ *
82
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
83
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
84
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
85
+ */
86
+ computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
87
+ action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
88
+ coordinate?: number[];
89
+ text?: string;
90
+ }, {
91
+ displayWidthPx: number;
92
+ displayHeightPx: number;
93
+ displayNumber?: number;
94
+ }>;
95
+ /**
96
+ * Creates a tool for executing actions on a computer. Must have name "computer".
97
+ *
98
+ * Image results are supported.
99
+ *
100
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
101
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
102
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
103
+ * @param execute - The function to execute the tool. Optional.
104
+ */
105
+ computer_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
106
+ action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
107
+ coordinate?: [number, number];
108
+ duration?: number;
109
+ scroll_amount?: number;
110
+ scroll_direction?: "up" | "down" | "left" | "right";
111
+ start_coordinate?: [number, number];
112
+ text?: string;
113
+ }, {
114
+ displayWidthPx: number;
115
+ displayHeightPx: number;
116
+ displayNumber?: number;
117
+ }>;
118
+ /**
119
+ * Creates a web search tool that gives Claude direct access to real-time web content.
120
+ * Must have name "web_search".
121
+ *
122
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
123
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
124
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
125
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
126
+ */
127
+ webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
128
+ query: string;
129
+ }, {
130
+ url: string;
131
+ title: string;
132
+ pageAge: string | null;
133
+ encryptedContent: string;
134
+ type: string;
135
+ }[], {
136
+ maxUses?: number;
137
+ allowedDomains?: string[];
138
+ blockedDomains?: string[];
139
+ userLocation?: {
140
+ type: "approximate";
141
+ city?: string;
142
+ region?: string;
143
+ country?: string;
144
+ timezone?: string;
145
+ };
146
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
147
+ query: string;
148
+ }, {
149
+ url: string;
150
+ title: string;
151
+ pageAge: string | null;
152
+ encryptedContent: string;
153
+ type: string;
154
+ }[]>;
155
+ };
156
+
157
+ interface AnthropicProvider extends ProviderV2 {
158
+ /**
159
+ Creates a model for text generation.
160
+ */
161
+ (modelId: AnthropicMessagesModelId): LanguageModelV2;
162
+ /**
163
+ Creates a model for text generation.
164
+ */
165
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV2;
166
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV2;
167
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV2;
168
+ /**
169
+ Anthropic-specific computer use tool.
170
+ */
171
+ tools: typeof anthropicTools;
172
+ }
173
+ interface AnthropicProviderSettings {
174
+ /**
175
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
176
+ The default prefix is `https://api.anthropic.com/v1`.
177
+ */
178
+ baseURL?: string;
179
+ /**
180
+ API key that is being send using the `x-api-key` header.
181
+ It defaults to the `ANTHROPIC_API_KEY` environment variable.
182
+ */
183
+ apiKey?: string;
184
+ /**
185
+ Custom headers to include in the requests.
186
+ */
187
+ headers?: Record<string, string>;
188
+ /**
189
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
190
+ or to provide a custom fetch implementation for e.g. testing.
191
+ */
192
+ fetch?: FetchFunction;
193
+ generateId?: () => string;
194
+ }
195
+ /**
196
+ Create an Anthropic provider instance.
197
+ */
198
+ declare function createAnthropic(options?: AnthropicProviderSettings): AnthropicProvider;
199
+ /**
200
+ Default Anthropic provider instance.
201
+ */
202
+ declare const anthropic: AnthropicProvider;
203
+
204
+ export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, anthropic, createAnthropic };
node_mod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ertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ anthropic: () => anthropic,
34
+ createAnthropic: () => createAnthropic
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+
38
+ // src/anthropic-provider.ts
39
+ var import_provider4 = require("@ai-sdk/provider");
40
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
41
+
42
+ // src/anthropic-messages-language-model.ts
43
+ var import_provider3 = require("@ai-sdk/provider");
44
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
45
+ var import_v44 = require("zod/v4");
46
+
47
+ // src/anthropic-error.ts
48
+ var import_provider_utils = require("@ai-sdk/provider-utils");
49
+ var import_v4 = require("zod/v4");
50
+ var anthropicErrorDataSchema = import_v4.z.object({
51
+ type: import_v4.z.literal("error"),
52
+ error: import_v4.z.object({
53
+ type: import_v4.z.string(),
54
+ message: import_v4.z.string()
55
+ })
56
+ });
57
+ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
58
+ errorSchema: anthropicErrorDataSchema,
59
+ errorToMessage: (data) => data.error.message
60
+ });
61
+
62
+ // src/anthropic-messages-options.ts
63
+ var import_v42 = require("zod/v4");
64
+ var anthropicFilePartProviderOptions = import_v42.z.object({
65
+ /**
66
+ * Citation configuration for this document.
67
+ * When enabled, this document will generate citations in the response.
68
+ */
69
+ citations: import_v42.z.object({
70
+ /**
71
+ * Enable citations for this document
72
+ */
73
+ enabled: import_v42.z.boolean()
74
+ }).optional(),
75
+ /**
76
+ * Custom title for the document.
77
+ * If not provided, the filename will be used.
78
+ */
79
+ title: import_v42.z.string().optional(),
80
+ /**
81
+ * Context about the document that will be passed to the model
82
+ * but not used towards cited content.
83
+ * Useful for storing document metadata as text or stringified JSON.
84
+ */
85
+ context: import_v42.z.string().optional()
86
+ });
87
+ var anthropicProviderOptions = import_v42.z.object({
88
+ sendReasoning: import_v42.z.boolean().optional(),
89
+ thinking: import_v42.z.object({
90
+ type: import_v42.z.union([import_v42.z.literal("enabled"), import_v42.z.literal("disabled")]),
91
+ budgetTokens: import_v42.z.number().optional()
92
+ }).optional(),
93
+ /**
94
+ * Whether to disable parallel function calling during tool use. Default is false.
95
+ * When set to true, Claude will use at most one tool per response.
96
+ */
97
+ disableParallelToolUse: import_v42.z.boolean().optional()
98
+ });
99
+
100
+ // src/anthropic-prepare-tools.ts
101
+ var import_provider = require("@ai-sdk/provider");
102
+
103
+ // src/get-cache-control.ts
104
+ function getCacheControl(providerMetadata) {
105
+ var _a;
106
+ const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
107
+ const cacheControlValue = (_a = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a : anthropic2 == null ? void 0 : anthropic2.cache_control;
108
+ return cacheControlValue;
109
+ }
110
+
111
+ // src/tool/web-search_20250305.ts
112
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
113
+ var import_v43 = require("zod/v4");
114
+ var webSearch_20250305ArgsSchema = import_v43.z.object({
115
+ /**
116
+ * Maximum number of web searches Claude can perform during the conversation.
117
+ */
118
+ maxUses: import_v43.z.number().optional(),
119
+ /**
120
+ * Optional list of domains that Claude is allowed to search.
121
+ */
122
+ allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
123
+ /**
124
+ * Optional list of domains that Claude should avoid when searching.
125
+ */
126
+ blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
127
+ /**
128
+ * Optional user location information to provide geographically relevant search results.
129
+ */
130
+ userLocation: import_v43.z.object({
131
+ type: import_v43.z.literal("approximate"),
132
+ city: import_v43.z.string().optional(),
133
+ region: import_v43.z.string().optional(),
134
+ country: import_v43.z.string().optional(),
135
+ timezone: import_v43.z.string().optional()
136
+ }).optional()
137
+ });
138
+ var webSearch_20250305OutputSchema = import_v43.z.array(
139
+ import_v43.z.object({
140
+ url: import_v43.z.string(),
141
+ title: import_v43.z.string(),
142
+ pageAge: import_v43.z.string().nullable(),
143
+ encryptedContent: import_v43.z.string(),
144
+ type: import_v43.z.string()
145
+ })
146
+ );
147
+ var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
148
+ id: "anthropic.web_search_20250305",
149
+ name: "web_search",
150
+ inputSchema: import_v43.z.object({
151
+ query: import_v43.z.string()
152
+ }),
153
+ outputSchema: webSearch_20250305OutputSchema
154
+ });
155
+ var webSearch_20250305 = (args = {}) => {
156
+ return factory(args);
157
+ };
158
+
159
+ // src/anthropic-prepare-tools.ts
160
+ function isWebSearchTool(tool) {
161
+ return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
162
+ }
163
+ function prepareTools({
164
+ tools,
165
+ toolChoice,
166
+ disableParallelToolUse
167
+ }) {
168
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
169
+ const toolWarnings = [];
170
+ const betas = /* @__PURE__ */ new Set();
171
+ if (tools == null) {
172
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
173
+ }
174
+ const anthropicTools2 = [];
175
+ for (const tool of tools) {
176
+ if (isWebSearchTool(tool)) {
177
+ anthropicTools2.push(tool);
178
+ continue;
179
+ }
180
+ switch (tool.type) {
181
+ case "function":
182
+ const cacheControl = getCacheControl(tool.providerOptions);
183
+ anthropicTools2.push({
184
+ name: tool.name,
185
+ description: tool.description,
186
+ input_schema: tool.inputSchema,
187
+ cache_control: cacheControl
188
+ });
189
+ break;
190
+ case "provider-defined":
191
+ switch (tool.id) {
192
+ case "anthropic.computer_20250124":
193
+ betas.add("computer-use-2025-01-24");
194
+ anthropicTools2.push({
195
+ name: "computer",
196
+ type: "computer_20250124",
197
+ display_width_px: tool.args.displayWidthPx,
198
+ display_height_px: tool.args.displayHeightPx,
199
+ display_number: tool.args.displayNumber
200
+ });
201
+ break;
202
+ case "anthropic.computer_20241022":
203
+ betas.add("computer-use-2024-10-22");
204
+ anthropicTools2.push({
205
+ name: "computer",
206
+ type: "computer_20241022",
207
+ display_width_px: tool.args.displayWidthPx,
208
+ display_height_px: tool.args.displayHeightPx,
209
+ display_number: tool.args.displayNumber
210
+ });
211
+ break;
212
+ case "anthropic.text_editor_20250124":
213
+ betas.add("computer-use-2025-01-24");
214
+ anthropicTools2.push({
215
+ name: "str_replace_editor",
216
+ type: "text_editor_20250124"
217
+ });
218
+ break;
219
+ case "anthropic.text_editor_20241022":
220
+ betas.add("computer-use-2024-10-22");
221
+ anthropicTools2.push({
222
+ name: "str_replace_editor",
223
+ type: "text_editor_20241022"
224
+ });
225
+ break;
226
+ case "anthropic.text_editor_20250429":
227
+ betas.add("computer-use-2025-01-24");
228
+ anthropicTools2.push({
229
+ name: "str_replace_based_edit_tool",
230
+ type: "text_editor_20250429"
231
+ });
232
+ break;
233
+ case "anthropic.bash_20250124":
234
+ betas.add("computer-use-2025-01-24");
235
+ anthropicTools2.push({
236
+ name: "bash",
237
+ type: "bash_20250124"
238
+ });
239
+ break;
240
+ case "anthropic.bash_20241022":
241
+ betas.add("computer-use-2024-10-22");
242
+ anthropicTools2.push({
243
+ name: "bash",
244
+ type: "bash_20241022"
245
+ });
246
+ break;
247
+ case "anthropic.web_search_20250305": {
248
+ const args = webSearch_20250305ArgsSchema.parse(tool.args);
249
+ anthropicTools2.push({
250
+ type: "web_search_20250305",
251
+ name: "web_search",
252
+ max_uses: args.maxUses,
253
+ allowed_domains: args.allowedDomains,
254
+ blocked_domains: args.blockedDomains,
255
+ user_location: args.userLocation
256
+ });
257
+ break;
258
+ }
259
+ default:
260
+ toolWarnings.push({ type: "unsupported-tool", tool });
261
+ break;
262
+ }
263
+ break;
264
+ default:
265
+ toolWarnings.push({ type: "unsupported-tool", tool });
266
+ break;
267
+ }
268
+ }
269
+ if (toolChoice == null) {
270
+ return {
271
+ tools: anthropicTools2,
272
+ toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
273
+ toolWarnings,
274
+ betas
275
+ };
276
+ }
277
+ const type = toolChoice.type;
278
+ switch (type) {
279
+ case "auto":
280
+ return {
281
+ tools: anthropicTools2,
282
+ toolChoice: {
283
+ type: "auto",
284
+ disable_parallel_tool_use: disableParallelToolUse
285
+ },
286
+ toolWarnings,
287
+ betas
288
+ };
289
+ case "required":
290
+ return {
291
+ tools: anthropicTools2,
292
+ toolChoice: {
293
+ type: "any",
294
+ disable_parallel_tool_use: disableParallelToolUse
295
+ },
296
+ toolWarnings,
297
+ betas
298
+ };
299
+ case "none":
300
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
301
+ case "tool":
302
+ return {
303
+ tools: anthropicTools2,
304
+ toolChoice: {
305
+ type: "tool",
306
+ name: toolChoice.toolName,
307
+ disable_parallel_tool_use: disableParallelToolUse
308
+ },
309
+ toolWarnings,
310
+ betas
311
+ };
312
+ default: {
313
+ const _exhaustiveCheck = type;
314
+ throw new import_provider.UnsupportedFunctionalityError({
315
+ functionality: `tool choice type: ${_exhaustiveCheck}`
316
+ });
317
+ }
318
+ }
319
+ }
320
+
321
+ // src/convert-to-anthropic-messages-prompt.ts
322
+ var import_provider2 = require("@ai-sdk/provider");
323
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
324
+ function convertToString(data) {
325
+ if (typeof data === "string") {
326
+ return Buffer.from(data, "base64").toString("utf-8");
327
+ }
328
+ if (data instanceof Uint8Array) {
329
+ return new TextDecoder().decode(data);
330
+ }
331
+ if (data instanceof URL) {
332
+ throw new import_provider2.UnsupportedFunctionalityError({
333
+ functionality: "URL-based text documents are not supported for citations"
334
+ });
335
+ }
336
+ throw new import_provider2.UnsupportedFunctionalityError({
337
+ functionality: `unsupported data type for text documents: ${typeof data}`
338
+ });
339
+ }
340
+ async function convertToAnthropicMessagesPrompt({
341
+ prompt,
342
+ sendReasoning,
343
+ warnings
344
+ }) {
345
+ var _a, _b, _c, _d, _e;
346
+ const betas = /* @__PURE__ */ new Set();
347
+ const blocks = groupIntoBlocks(prompt);
348
+ let system = void 0;
349
+ const messages = [];
350
+ async function shouldEnableCitations(providerMetadata) {
351
+ var _a2, _b2;
352
+ const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
353
+ provider: "anthropic",
354
+ providerOptions: providerMetadata,
355
+ schema: anthropicFilePartProviderOptions
356
+ });
357
+ return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
358
+ }
359
+ async function getDocumentMetadata(providerMetadata) {
360
+ const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
361
+ provider: "anthropic",
362
+ providerOptions: providerMetadata,
363
+ schema: anthropicFilePartProviderOptions
364
+ });
365
+ return {
366
+ title: anthropicOptions == null ? void 0 : anthropicOptions.title,
367
+ context: anthropicOptions == null ? void 0 : anthropicOptions.context
368
+ };
369
+ }
370
+ for (let i = 0; i < blocks.length; i++) {
371
+ const block = blocks[i];
372
+ const isLastBlock = i === blocks.length - 1;
373
+ const type = block.type;
374
+ switch (type) {
375
+ case "system": {
376
+ if (system != null) {
377
+ throw new import_provider2.UnsupportedFunctionalityError({
378
+ functionality: "Multiple system messages that are separated by user/assistant messages"
379
+ });
380
+ }
381
+ system = block.messages.map(({ content, providerOptions }) => ({
382
+ type: "text",
383
+ text: content,
384
+ cache_control: getCacheControl(providerOptions)
385
+ }));
386
+ break;
387
+ }
388
+ case "user": {
389
+ const anthropicContent = [];
390
+ for (const message of block.messages) {
391
+ const { role, content } = message;
392
+ switch (role) {
393
+ case "user": {
394
+ for (let j = 0; j < content.length; j++) {
395
+ const part = content[j];
396
+ const isLastPart = j === content.length - 1;
397
+ const cacheControl = (_a = getCacheControl(part.providerOptions)) != null ? _a : isLastPart ? getCacheControl(message.providerOptions) : void 0;
398
+ switch (part.type) {
399
+ case "text": {
400
+ anthropicContent.push({
401
+ type: "text",
402
+ text: part.text,
403
+ cache_control: cacheControl
404
+ });
405
+ break;
406
+ }
407
+ case "file": {
408
+ if (part.mediaType.startsWith("image/")) {
409
+ anthropicContent.push({
410
+ type: "image",
411
+ source: part.data instanceof URL ? {
412
+ type: "url",
413
+ url: part.data.toString()
414
+ } : {
415
+ type: "base64",
416
+ media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
417
+ data: (0, import_provider_utils3.convertToBase64)(part.data)
418
+ },
419
+ cache_control: cacheControl
420
+ });
421
+ } else if (part.mediaType === "application/pdf") {
422
+ betas.add("pdfs-2024-09-25");
423
+ const enableCitations = await shouldEnableCitations(
424
+ part.providerOptions
425
+ );
426
+ const metadata = await getDocumentMetadata(
427
+ part.providerOptions
428
+ );
429
+ anthropicContent.push({
430
+ type: "document",
431
+ source: part.data instanceof URL ? {
432
+ type: "url",
433
+ url: part.data.toString()
434
+ } : {
435
+ type: "base64",
436
+ media_type: "application/pdf",
437
+ data: (0, import_provider_utils3.convertToBase64)(part.data)
438
+ },
439
+ title: (_b = metadata.title) != null ? _b : part.filename,
440
+ ...metadata.context && { context: metadata.context },
441
+ ...enableCitations && {
442
+ citations: { enabled: true }
443
+ },
444
+ cache_control: cacheControl
445
+ });
446
+ } else if (part.mediaType === "text/plain") {
447
+ const enableCitations = await shouldEnableCitations(
448
+ part.providerOptions
449
+ );
450
+ const metadata = await getDocumentMetadata(
451
+ part.providerOptions
452
+ );
453
+ anthropicContent.push({
454
+ type: "document",
455
+ source: part.data instanceof URL ? {
456
+ type: "url",
457
+ url: part.data.toString()
458
+ } : {
459
+ type: "text",
460
+ media_type: "text/plain",
461
+ data: convertToString(part.data)
462
+ },
463
+ title: (_c = metadata.title) != null ? _c : part.filename,
464
+ ...metadata.context && { context: metadata.context },
465
+ ...enableCitations && {
466
+ citations: { enabled: true }
467
+ },
468
+ cache_control: cacheControl
469
+ });
470
+ } else {
471
+ throw new import_provider2.UnsupportedFunctionalityError({
472
+ functionality: `media type: ${part.mediaType}`
473
+ });
474
+ }
475
+ break;
476
+ }
477
+ }
478
+ }
479
+ break;
480
+ }
481
+ case "tool": {
482
+ for (let i2 = 0; i2 < content.length; i2++) {
483
+ const part = content[i2];
484
+ const isLastPart = i2 === content.length - 1;
485
+ const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
486
+ const output = part.output;
487
+ let contentValue;
488
+ switch (output.type) {
489
+ case "content":
490
+ contentValue = output.value.map((contentPart) => {
491
+ switch (contentPart.type) {
492
+ case "text":
493
+ return {
494
+ type: "text",
495
+ text: contentPart.text,
496
+ cache_control: void 0
497
+ };
498
+ case "media": {
499
+ if (contentPart.mediaType.startsWith("image/")) {
500
+ return {
501
+ type: "image",
502
+ source: {
503
+ type: "base64",
504
+ media_type: contentPart.mediaType,
505
+ data: contentPart.data
506
+ },
507
+ cache_control: void 0
508
+ };
509
+ }
510
+ throw new import_provider2.UnsupportedFunctionalityError({
511
+ functionality: `media type: ${contentPart.mediaType}`
512
+ });
513
+ }
514
+ }
515
+ });
516
+ break;
517
+ case "text":
518
+ case "error-text":
519
+ contentValue = output.value;
520
+ break;
521
+ case "json":
522
+ case "error-json":
523
+ default:
524
+ contentValue = JSON.stringify(output.value);
525
+ break;
526
+ }
527
+ anthropicContent.push({
528
+ type: "tool_result",
529
+ tool_use_id: part.toolCallId,
530
+ content: contentValue,
531
+ is_error: output.type === "error-text" || output.type === "error-json" ? true : void 0,
532
+ cache_control: cacheControl
533
+ });
534
+ }
535
+ break;
536
+ }
537
+ default: {
538
+ const _exhaustiveCheck = role;
539
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
540
+ }
541
+ }
542
+ }
543
+ messages.push({ role: "user", content: anthropicContent });
544
+ break;
545
+ }
546
+ case "assistant": {
547
+ const anthropicContent = [];
548
+ for (let j = 0; j < block.messages.length; j++) {
549
+ const message = block.messages[j];
550
+ const isLastMessage = j === block.messages.length - 1;
551
+ const { content } = message;
552
+ for (let k = 0; k < content.length; k++) {
553
+ const part = content[k];
554
+ const isLastContentPart = k === content.length - 1;
555
+ const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
556
+ switch (part.type) {
557
+ case "text": {
558
+ anthropicContent.push({
559
+ type: "text",
560
+ text: (
561
+ // trim the last text part if it's the last message in the block
562
+ // because Anthropic does not allow trailing whitespace
563
+ // in pre-filled assistant responses
564
+ isLastBlock && isLastMessage && isLastContentPart ? part.text.trim() : part.text
565
+ ),
566
+ cache_control: cacheControl
567
+ });
568
+ break;
569
+ }
570
+ case "reasoning": {
571
+ if (sendReasoning) {
572
+ const reasoningMetadata = await (0, import_provider_utils3.parseProviderOptions)({
573
+ provider: "anthropic",
574
+ providerOptions: part.providerOptions,
575
+ schema: anthropicReasoningMetadataSchema
576
+ });
577
+ if (reasoningMetadata != null) {
578
+ if (reasoningMetadata.signature != null) {
579
+ anthropicContent.push({
580
+ type: "thinking",
581
+ thinking: part.text,
582
+ signature: reasoningMetadata.signature,
583
+ cache_control: cacheControl
584
+ });
585
+ } else if (reasoningMetadata.redactedData != null) {
586
+ anthropicContent.push({
587
+ type: "redacted_thinking",
588
+ data: reasoningMetadata.redactedData,
589
+ cache_control: cacheControl
590
+ });
591
+ } else {
592
+ warnings.push({
593
+ type: "other",
594
+ message: "unsupported reasoning metadata"
595
+ });
596
+ }
597
+ } else {
598
+ warnings.push({
599
+ type: "other",
600
+ message: "unsupported reasoning metadata"
601
+ });
602
+ }
603
+ } else {
604
+ warnings.push({
605
+ type: "other",
606
+ message: "sending reasoning content is disabled for this model"
607
+ });
608
+ }
609
+ break;
610
+ }
611
+ case "tool-call": {
612
+ if (part.providerExecuted) {
613
+ if (part.toolName === "web_search") {
614
+ anthropicContent.push({
615
+ type: "server_tool_use",
616
+ id: part.toolCallId,
617
+ name: "web_search",
618
+ input: part.input,
619
+ cache_control: cacheControl
620
+ });
621
+ break;
622
+ }
623
+ warnings.push({
624
+ type: "other",
625
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
626
+ });
627
+ break;
628
+ }
629
+ anthropicContent.push({
630
+ type: "tool_use",
631
+ id: part.toolCallId,
632
+ name: part.toolName,
633
+ input: part.input,
634
+ cache_control: cacheControl
635
+ });
636
+ break;
637
+ }
638
+ case "tool-result": {
639
+ if (part.toolName === "web_search") {
640
+ const output = part.output;
641
+ if (output.type !== "json") {
642
+ warnings.push({
643
+ type: "other",
644
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
645
+ });
646
+ break;
647
+ }
648
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
649
+ output.value
650
+ );
651
+ anthropicContent.push({
652
+ type: "web_search_tool_result",
653
+ tool_use_id: part.toolCallId,
654
+ content: webSearchOutput.map((result) => ({
655
+ url: result.url,
656
+ title: result.title,
657
+ page_age: result.pageAge,
658
+ encrypted_content: result.encryptedContent,
659
+ type: result.type
660
+ })),
661
+ cache_control: cacheControl
662
+ });
663
+ break;
664
+ }
665
+ warnings.push({
666
+ type: "other",
667
+ message: `provider executed tool result for tool ${part.toolName} is not supported`
668
+ });
669
+ break;
670
+ }
671
+ }
672
+ }
673
+ }
674
+ messages.push({ role: "assistant", content: anthropicContent });
675
+ break;
676
+ }
677
+ default: {
678
+ const _exhaustiveCheck = type;
679
+ throw new Error(`content type: ${_exhaustiveCheck}`);
680
+ }
681
+ }
682
+ }
683
+ return {
684
+ prompt: { system, messages },
685
+ betas
686
+ };
687
+ }
688
+ function groupIntoBlocks(prompt) {
689
+ const blocks = [];
690
+ let currentBlock = void 0;
691
+ for (const message of prompt) {
692
+ const { role } = message;
693
+ switch (role) {
694
+ case "system": {
695
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "system") {
696
+ currentBlock = { type: "system", messages: [] };
697
+ blocks.push(currentBlock);
698
+ }
699
+ currentBlock.messages.push(message);
700
+ break;
701
+ }
702
+ case "assistant": {
703
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "assistant") {
704
+ currentBlock = { type: "assistant", messages: [] };
705
+ blocks.push(currentBlock);
706
+ }
707
+ currentBlock.messages.push(message);
708
+ break;
709
+ }
710
+ case "user": {
711
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
712
+ currentBlock = { type: "user", messages: [] };
713
+ blocks.push(currentBlock);
714
+ }
715
+ currentBlock.messages.push(message);
716
+ break;
717
+ }
718
+ case "tool": {
719
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
720
+ currentBlock = { type: "user", messages: [] };
721
+ blocks.push(currentBlock);
722
+ }
723
+ currentBlock.messages.push(message);
724
+ break;
725
+ }
726
+ default: {
727
+ const _exhaustiveCheck = role;
728
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
729
+ }
730
+ }
731
+ }
732
+ return blocks;
733
+ }
734
+
735
+ // src/map-anthropic-stop-reason.ts
736
+ function mapAnthropicStopReason({
737
+ finishReason,
738
+ isJsonResponseFromTool
739
+ }) {
740
+ switch (finishReason) {
741
+ case "end_turn":
742
+ case "stop_sequence":
743
+ return "stop";
744
+ case "tool_use":
745
+ return isJsonResponseFromTool ? "stop" : "tool-calls";
746
+ case "max_tokens":
747
+ return "length";
748
+ default:
749
+ return "unknown";
750
+ }
751
+ }
752
+
753
+ // src/anthropic-messages-language-model.ts
754
+ var citationSchemas = {
755
+ webSearchResult: import_v44.z.object({
756
+ type: import_v44.z.literal("web_search_result_location"),
757
+ cited_text: import_v44.z.string(),
758
+ url: import_v44.z.string(),
759
+ title: import_v44.z.string(),
760
+ encrypted_index: import_v44.z.string()
761
+ }),
762
+ pageLocation: import_v44.z.object({
763
+ type: import_v44.z.literal("page_location"),
764
+ cited_text: import_v44.z.string(),
765
+ document_index: import_v44.z.number(),
766
+ document_title: import_v44.z.string().nullable(),
767
+ start_page_number: import_v44.z.number(),
768
+ end_page_number: import_v44.z.number()
769
+ }),
770
+ charLocation: import_v44.z.object({
771
+ type: import_v44.z.literal("char_location"),
772
+ cited_text: import_v44.z.string(),
773
+ document_index: import_v44.z.number(),
774
+ document_title: import_v44.z.string().nullable(),
775
+ start_char_index: import_v44.z.number(),
776
+ end_char_index: import_v44.z.number()
777
+ })
778
+ };
779
+ var citationSchema = import_v44.z.discriminatedUnion("type", [
780
+ citationSchemas.webSearchResult,
781
+ citationSchemas.pageLocation,
782
+ citationSchemas.charLocation
783
+ ]);
784
+ var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
785
+ citationSchemas.pageLocation,
786
+ citationSchemas.charLocation
787
+ ]);
788
+ function processCitation(citation, citationDocuments, generateId3, onSource) {
789
+ if (citation.type === "page_location" || citation.type === "char_location") {
790
+ const source = createCitationSource(
791
+ citation,
792
+ citationDocuments,
793
+ generateId3
794
+ );
795
+ if (source) {
796
+ onSource(source);
797
+ }
798
+ }
799
+ }
800
+ function createCitationSource(citation, citationDocuments, generateId3) {
801
+ var _a;
802
+ const documentInfo = citationDocuments[citation.document_index];
803
+ if (!documentInfo) {
804
+ return null;
805
+ }
806
+ const providerMetadata = citation.type === "page_location" ? {
807
+ citedText: citation.cited_text,
808
+ startPageNumber: citation.start_page_number,
809
+ endPageNumber: citation.end_page_number
810
+ } : {
811
+ citedText: citation.cited_text,
812
+ startCharIndex: citation.start_char_index,
813
+ endCharIndex: citation.end_char_index
814
+ };
815
+ return {
816
+ type: "source",
817
+ sourceType: "document",
818
+ id: generateId3(),
819
+ mediaType: documentInfo.mediaType,
820
+ title: (_a = citation.document_title) != null ? _a : documentInfo.title,
821
+ filename: documentInfo.filename,
822
+ providerMetadata: {
823
+ anthropic: providerMetadata
824
+ }
825
+ };
826
+ }
827
+ var AnthropicMessagesLanguageModel = class {
828
+ constructor(modelId, config) {
829
+ this.specificationVersion = "v2";
830
+ var _a;
831
+ this.modelId = modelId;
832
+ this.config = config;
833
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
834
+ }
835
+ supportsUrl(url) {
836
+ return url.protocol === "https:";
837
+ }
838
+ get provider() {
839
+ return this.config.provider;
840
+ }
841
+ get supportedUrls() {
842
+ var _a, _b, _c;
843
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
844
+ }
845
+ async getArgs({
846
+ prompt,
847
+ maxOutputTokens = 4096,
848
+ // 4096: max model output tokens TODO update default in v5
849
+ temperature,
850
+ topP,
851
+ topK,
852
+ frequencyPenalty,
853
+ presencePenalty,
854
+ stopSequences,
855
+ responseFormat,
856
+ seed,
857
+ tools,
858
+ toolChoice,
859
+ providerOptions
860
+ }) {
861
+ var _a, _b, _c;
862
+ const warnings = [];
863
+ if (frequencyPenalty != null) {
864
+ warnings.push({
865
+ type: "unsupported-setting",
866
+ setting: "frequencyPenalty"
867
+ });
868
+ }
869
+ if (presencePenalty != null) {
870
+ warnings.push({
871
+ type: "unsupported-setting",
872
+ setting: "presencePenalty"
873
+ });
874
+ }
875
+ if (seed != null) {
876
+ warnings.push({
877
+ type: "unsupported-setting",
878
+ setting: "seed"
879
+ });
880
+ }
881
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
882
+ if (responseFormat.schema == null) {
883
+ warnings.push({
884
+ type: "unsupported-setting",
885
+ setting: "responseFormat",
886
+ details: "JSON response format requires a schema. The response format is ignored."
887
+ });
888
+ } else if (tools != null) {
889
+ warnings.push({
890
+ type: "unsupported-setting",
891
+ setting: "tools",
892
+ details: "JSON response format does not support tools. The provided tools are ignored."
893
+ });
894
+ }
895
+ }
896
+ const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null ? {
897
+ type: "function",
898
+ name: "json",
899
+ description: "Respond with a JSON object.",
900
+ inputSchema: responseFormat.schema
901
+ } : void 0;
902
+ const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
903
+ provider: "anthropic",
904
+ providerOptions,
905
+ schema: anthropicProviderOptions
906
+ });
907
+ const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
908
+ prompt,
909
+ sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
910
+ warnings
911
+ });
912
+ const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
913
+ const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
914
+ const baseArgs = {
915
+ // model id:
916
+ model: this.modelId,
917
+ // standardized settings:
918
+ max_tokens: maxOutputTokens,
919
+ temperature,
920
+ top_k: topK,
921
+ top_p: topP,
922
+ stop_sequences: stopSequences,
923
+ // provider specific settings:
924
+ ...isThinking && {
925
+ thinking: { type: "enabled", budget_tokens: thinkingBudget }
926
+ },
927
+ // prompt:
928
+ system: messagesPrompt.system,
929
+ messages: messagesPrompt.messages
930
+ };
931
+ if (isThinking) {
932
+ if (thinkingBudget == null) {
933
+ throw new import_provider3.UnsupportedFunctionalityError({
934
+ functionality: "thinking requires a budget"
935
+ });
936
+ }
937
+ if (baseArgs.temperature != null) {
938
+ baseArgs.temperature = void 0;
939
+ warnings.push({
940
+ type: "unsupported-setting",
941
+ setting: "temperature",
942
+ details: "temperature is not supported when thinking is enabled"
943
+ });
944
+ }
945
+ if (topK != null) {
946
+ baseArgs.top_k = void 0;
947
+ warnings.push({
948
+ type: "unsupported-setting",
949
+ setting: "topK",
950
+ details: "topK is not supported when thinking is enabled"
951
+ });
952
+ }
953
+ if (topP != null) {
954
+ baseArgs.top_p = void 0;
955
+ warnings.push({
956
+ type: "unsupported-setting",
957
+ setting: "topP",
958
+ details: "topP is not supported when thinking is enabled"
959
+ });
960
+ }
961
+ baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
962
+ }
963
+ const {
964
+ tools: anthropicTools2,
965
+ toolChoice: anthropicToolChoice,
966
+ toolWarnings,
967
+ betas: toolsBetas
968
+ } = prepareTools(
969
+ jsonResponseTool != null ? {
970
+ tools: [jsonResponseTool],
971
+ toolChoice: { type: "tool", toolName: jsonResponseTool.name },
972
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
973
+ } : {
974
+ tools: tools != null ? tools : [],
975
+ toolChoice,
976
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
977
+ }
978
+ );
979
+ return {
980
+ args: {
981
+ ...baseArgs,
982
+ tools: anthropicTools2,
983
+ tool_choice: anthropicToolChoice
984
+ },
985
+ warnings: [...warnings, ...toolWarnings],
986
+ betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
987
+ usesJsonResponseTool: jsonResponseTool != null
988
+ };
989
+ }
990
+ async getHeaders({
991
+ betas,
992
+ headers
993
+ }) {
994
+ return (0, import_provider_utils4.combineHeaders)(
995
+ await (0, import_provider_utils4.resolve)(this.config.headers),
996
+ betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
997
+ headers
998
+ );
999
+ }
1000
+ buildRequestUrl(isStreaming) {
1001
+ var _a, _b, _c;
1002
+ return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
1003
+ }
1004
+ transformRequestBody(args) {
1005
+ var _a, _b, _c;
1006
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
1007
+ }
1008
+ extractCitationDocuments(prompt) {
1009
+ const isCitationPart = (part) => {
1010
+ var _a, _b;
1011
+ if (part.type !== "file") {
1012
+ return false;
1013
+ }
1014
+ if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
1015
+ return false;
1016
+ }
1017
+ const anthropic2 = (_a = part.providerOptions) == null ? void 0 : _a.anthropic;
1018
+ const citationsConfig = anthropic2 == null ? void 0 : anthropic2.citations;
1019
+ return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
1020
+ };
1021
+ return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
1022
+ var _a;
1023
+ const filePart = part;
1024
+ return {
1025
+ title: (_a = filePart.filename) != null ? _a : "Untitled Document",
1026
+ filename: filePart.filename,
1027
+ mediaType: filePart.mediaType
1028
+ };
1029
+ });
1030
+ }
1031
+ async doGenerate(options) {
1032
+ var _a, _b, _c, _d, _e;
1033
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1034
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1035
+ const {
1036
+ responseHeaders,
1037
+ value: response,
1038
+ rawValue: rawResponse
1039
+ } = await (0, import_provider_utils4.postJsonToApi)({
1040
+ url: this.buildRequestUrl(false),
1041
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1042
+ body: this.transformRequestBody(args),
1043
+ failedResponseHandler: anthropicFailedResponseHandler,
1044
+ successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1045
+ anthropicMessagesResponseSchema
1046
+ ),
1047
+ abortSignal: options.abortSignal,
1048
+ fetch: this.config.fetch
1049
+ });
1050
+ const content = [];
1051
+ for (const part of response.content) {
1052
+ switch (part.type) {
1053
+ case "text": {
1054
+ if (!usesJsonResponseTool) {
1055
+ content.push({ type: "text", text: part.text });
1056
+ if (part.citations) {
1057
+ for (const citation of part.citations) {
1058
+ processCitation(
1059
+ citation,
1060
+ citationDocuments,
1061
+ this.generateId,
1062
+ (source) => content.push(source)
1063
+ );
1064
+ }
1065
+ }
1066
+ }
1067
+ break;
1068
+ }
1069
+ case "thinking": {
1070
+ content.push({
1071
+ type: "reasoning",
1072
+ text: part.thinking,
1073
+ providerMetadata: {
1074
+ anthropic: {
1075
+ signature: part.signature
1076
+ }
1077
+ }
1078
+ });
1079
+ break;
1080
+ }
1081
+ case "redacted_thinking": {
1082
+ content.push({
1083
+ type: "reasoning",
1084
+ text: "",
1085
+ providerMetadata: {
1086
+ anthropic: {
1087
+ redactedData: part.data
1088
+ }
1089
+ }
1090
+ });
1091
+ break;
1092
+ }
1093
+ case "tool_use": {
1094
+ content.push(
1095
+ // when a json response tool is used, the tool call becomes the text:
1096
+ usesJsonResponseTool ? {
1097
+ type: "text",
1098
+ text: JSON.stringify(part.input)
1099
+ } : {
1100
+ type: "tool-call",
1101
+ toolCallId: part.id,
1102
+ toolName: part.name,
1103
+ input: JSON.stringify(part.input)
1104
+ }
1105
+ );
1106
+ break;
1107
+ }
1108
+ case "server_tool_use": {
1109
+ if (part.name === "web_search") {
1110
+ content.push({
1111
+ type: "tool-call",
1112
+ toolCallId: part.id,
1113
+ toolName: part.name,
1114
+ input: JSON.stringify(part.input),
1115
+ providerExecuted: true
1116
+ });
1117
+ }
1118
+ break;
1119
+ }
1120
+ case "web_search_tool_result": {
1121
+ if (Array.isArray(part.content)) {
1122
+ content.push({
1123
+ type: "tool-result",
1124
+ toolCallId: part.tool_use_id,
1125
+ toolName: "web_search",
1126
+ result: part.content.map((result) => {
1127
+ var _a2;
1128
+ return {
1129
+ url: result.url,
1130
+ title: result.title,
1131
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1132
+ encryptedContent: result.encrypted_content,
1133
+ type: result.type
1134
+ };
1135
+ }),
1136
+ providerExecuted: true
1137
+ });
1138
+ for (const result of part.content) {
1139
+ content.push({
1140
+ type: "source",
1141
+ sourceType: "url",
1142
+ id: this.generateId(),
1143
+ url: result.url,
1144
+ title: result.title,
1145
+ providerMetadata: {
1146
+ anthropic: {
1147
+ pageAge: (_a = result.page_age) != null ? _a : null
1148
+ }
1149
+ }
1150
+ });
1151
+ }
1152
+ } else {
1153
+ content.push({
1154
+ type: "tool-result",
1155
+ toolCallId: part.tool_use_id,
1156
+ toolName: "web_search",
1157
+ isError: true,
1158
+ result: {
1159
+ type: "web_search_tool_result_error",
1160
+ errorCode: part.content.error_code
1161
+ },
1162
+ providerExecuted: true
1163
+ });
1164
+ }
1165
+ break;
1166
+ }
1167
+ }
1168
+ }
1169
+ return {
1170
+ content,
1171
+ finishReason: mapAnthropicStopReason({
1172
+ finishReason: response.stop_reason,
1173
+ isJsonResponseFromTool: usesJsonResponseTool
1174
+ }),
1175
+ usage: {
1176
+ inputTokens: response.usage.input_tokens,
1177
+ outputTokens: response.usage.output_tokens,
1178
+ totalTokens: response.usage.input_tokens + response.usage.output_tokens,
1179
+ cachedInputTokens: (_b = response.usage.cache_read_input_tokens) != null ? _b : void 0
1180
+ },
1181
+ request: { body: args },
1182
+ response: {
1183
+ id: (_c = response.id) != null ? _c : void 0,
1184
+ modelId: (_d = response.model) != null ? _d : void 0,
1185
+ headers: responseHeaders,
1186
+ body: rawResponse
1187
+ },
1188
+ warnings,
1189
+ providerMetadata: {
1190
+ anthropic: {
1191
+ usage: response.usage,
1192
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1193
+ }
1194
+ }
1195
+ };
1196
+ }
1197
+ async doStream(options) {
1198
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1199
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1200
+ const body = { ...args, stream: true };
1201
+ const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1202
+ url: this.buildRequestUrl(true),
1203
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1204
+ body: this.transformRequestBody(body),
1205
+ failedResponseHandler: anthropicFailedResponseHandler,
1206
+ successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
1207
+ anthropicMessagesChunkSchema
1208
+ ),
1209
+ abortSignal: options.abortSignal,
1210
+ fetch: this.config.fetch
1211
+ });
1212
+ let finishReason = "unknown";
1213
+ const usage = {
1214
+ inputTokens: void 0,
1215
+ outputTokens: void 0,
1216
+ totalTokens: void 0
1217
+ };
1218
+ const contentBlocks = {};
1219
+ let providerMetadata = void 0;
1220
+ let blockType = void 0;
1221
+ const generateId3 = this.generateId;
1222
+ return {
1223
+ stream: response.pipeThrough(
1224
+ new TransformStream({
1225
+ start(controller) {
1226
+ controller.enqueue({ type: "stream-start", warnings });
1227
+ },
1228
+ transform(chunk, controller) {
1229
+ var _a, _b, _c, _d, _e, _f, _g;
1230
+ if (options.includeRawChunks) {
1231
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1232
+ }
1233
+ if (!chunk.success) {
1234
+ controller.enqueue({ type: "error", error: chunk.error });
1235
+ return;
1236
+ }
1237
+ const value = chunk.value;
1238
+ switch (value.type) {
1239
+ case "ping": {
1240
+ return;
1241
+ }
1242
+ case "content_block_start": {
1243
+ const contentBlockType = value.content_block.type;
1244
+ blockType = contentBlockType;
1245
+ switch (contentBlockType) {
1246
+ case "text": {
1247
+ contentBlocks[value.index] = { type: "text" };
1248
+ controller.enqueue({
1249
+ type: "text-start",
1250
+ id: String(value.index)
1251
+ });
1252
+ return;
1253
+ }
1254
+ case "thinking": {
1255
+ contentBlocks[value.index] = { type: "reasoning" };
1256
+ controller.enqueue({
1257
+ type: "reasoning-start",
1258
+ id: String(value.index)
1259
+ });
1260
+ return;
1261
+ }
1262
+ case "redacted_thinking": {
1263
+ contentBlocks[value.index] = { type: "reasoning" };
1264
+ controller.enqueue({
1265
+ type: "reasoning-start",
1266
+ id: String(value.index),
1267
+ providerMetadata: {
1268
+ anthropic: {
1269
+ redactedData: value.content_block.data
1270
+ }
1271
+ }
1272
+ });
1273
+ return;
1274
+ }
1275
+ case "tool_use": {
1276
+ contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
1277
+ type: "tool-call",
1278
+ toolCallId: value.content_block.id,
1279
+ toolName: value.content_block.name,
1280
+ input: ""
1281
+ };
1282
+ controller.enqueue(
1283
+ usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
1284
+ type: "tool-input-start",
1285
+ id: value.content_block.id,
1286
+ toolName: value.content_block.name
1287
+ }
1288
+ );
1289
+ return;
1290
+ }
1291
+ case "server_tool_use": {
1292
+ if (value.content_block.name === "web_search") {
1293
+ contentBlocks[value.index] = {
1294
+ type: "tool-call",
1295
+ toolCallId: value.content_block.id,
1296
+ toolName: value.content_block.name,
1297
+ input: "",
1298
+ providerExecuted: true
1299
+ };
1300
+ controller.enqueue({
1301
+ type: "tool-input-start",
1302
+ id: value.content_block.id,
1303
+ toolName: value.content_block.name,
1304
+ providerExecuted: true
1305
+ });
1306
+ }
1307
+ return;
1308
+ }
1309
+ case "web_search_tool_result": {
1310
+ const part = value.content_block;
1311
+ if (Array.isArray(part.content)) {
1312
+ controller.enqueue({
1313
+ type: "tool-result",
1314
+ toolCallId: part.tool_use_id,
1315
+ toolName: "web_search",
1316
+ result: part.content.map((result) => {
1317
+ var _a2;
1318
+ return {
1319
+ url: result.url,
1320
+ title: result.title,
1321
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1322
+ encryptedContent: result.encrypted_content,
1323
+ type: result.type
1324
+ };
1325
+ }),
1326
+ providerExecuted: true
1327
+ });
1328
+ for (const result of part.content) {
1329
+ controller.enqueue({
1330
+ type: "source",
1331
+ sourceType: "url",
1332
+ id: generateId3(),
1333
+ url: result.url,
1334
+ title: result.title,
1335
+ providerMetadata: {
1336
+ anthropic: {
1337
+ pageAge: (_a = result.page_age) != null ? _a : null
1338
+ }
1339
+ }
1340
+ });
1341
+ }
1342
+ } else {
1343
+ controller.enqueue({
1344
+ type: "tool-result",
1345
+ toolCallId: part.tool_use_id,
1346
+ toolName: "web_search",
1347
+ isError: true,
1348
+ result: {
1349
+ type: "web_search_tool_result_error",
1350
+ errorCode: part.content.error_code
1351
+ },
1352
+ providerExecuted: true
1353
+ });
1354
+ }
1355
+ return;
1356
+ }
1357
+ default: {
1358
+ const _exhaustiveCheck = contentBlockType;
1359
+ throw new Error(
1360
+ `Unsupported content block type: ${_exhaustiveCheck}`
1361
+ );
1362
+ }
1363
+ }
1364
+ }
1365
+ case "content_block_stop": {
1366
+ if (contentBlocks[value.index] != null) {
1367
+ const contentBlock = contentBlocks[value.index];
1368
+ switch (contentBlock.type) {
1369
+ case "text": {
1370
+ controller.enqueue({
1371
+ type: "text-end",
1372
+ id: String(value.index)
1373
+ });
1374
+ break;
1375
+ }
1376
+ case "reasoning": {
1377
+ controller.enqueue({
1378
+ type: "reasoning-end",
1379
+ id: String(value.index)
1380
+ });
1381
+ break;
1382
+ }
1383
+ case "tool-call":
1384
+ if (!usesJsonResponseTool) {
1385
+ controller.enqueue({
1386
+ type: "tool-input-end",
1387
+ id: contentBlock.toolCallId
1388
+ });
1389
+ controller.enqueue(contentBlock);
1390
+ }
1391
+ break;
1392
+ }
1393
+ delete contentBlocks[value.index];
1394
+ }
1395
+ blockType = void 0;
1396
+ return;
1397
+ }
1398
+ case "content_block_delta": {
1399
+ const deltaType = value.delta.type;
1400
+ switch (deltaType) {
1401
+ case "text_delta": {
1402
+ if (usesJsonResponseTool) {
1403
+ return;
1404
+ }
1405
+ controller.enqueue({
1406
+ type: "text-delta",
1407
+ id: String(value.index),
1408
+ delta: value.delta.text
1409
+ });
1410
+ return;
1411
+ }
1412
+ case "thinking_delta": {
1413
+ controller.enqueue({
1414
+ type: "reasoning-delta",
1415
+ id: String(value.index),
1416
+ delta: value.delta.thinking
1417
+ });
1418
+ return;
1419
+ }
1420
+ case "signature_delta": {
1421
+ if (blockType === "thinking") {
1422
+ controller.enqueue({
1423
+ type: "reasoning-delta",
1424
+ id: String(value.index),
1425
+ delta: "",
1426
+ providerMetadata: {
1427
+ anthropic: {
1428
+ signature: value.delta.signature
1429
+ }
1430
+ }
1431
+ });
1432
+ }
1433
+ return;
1434
+ }
1435
+ case "input_json_delta": {
1436
+ const contentBlock = contentBlocks[value.index];
1437
+ const delta = value.delta.partial_json;
1438
+ if (usesJsonResponseTool) {
1439
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
1440
+ return;
1441
+ }
1442
+ controller.enqueue({
1443
+ type: "text-delta",
1444
+ id: String(value.index),
1445
+ delta
1446
+ });
1447
+ } else {
1448
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
1449
+ return;
1450
+ }
1451
+ controller.enqueue({
1452
+ type: "tool-input-delta",
1453
+ id: contentBlock.toolCallId,
1454
+ delta
1455
+ });
1456
+ contentBlock.input += delta;
1457
+ }
1458
+ return;
1459
+ }
1460
+ case "citations_delta": {
1461
+ const citation = value.delta.citation;
1462
+ processCitation(
1463
+ citation,
1464
+ citationDocuments,
1465
+ generateId3,
1466
+ (source) => controller.enqueue(source)
1467
+ );
1468
+ return;
1469
+ }
1470
+ default: {
1471
+ const _exhaustiveCheck = deltaType;
1472
+ throw new Error(
1473
+ `Unsupported delta type: ${_exhaustiveCheck}`
1474
+ );
1475
+ }
1476
+ }
1477
+ }
1478
+ case "message_start": {
1479
+ usage.inputTokens = value.message.usage.input_tokens;
1480
+ usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
1481
+ providerMetadata = {
1482
+ anthropic: {
1483
+ usage: value.message.usage,
1484
+ cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
1485
+ }
1486
+ };
1487
+ controller.enqueue({
1488
+ type: "response-metadata",
1489
+ id: (_d = value.message.id) != null ? _d : void 0,
1490
+ modelId: (_e = value.message.model) != null ? _e : void 0
1491
+ });
1492
+ return;
1493
+ }
1494
+ case "message_delta": {
1495
+ usage.outputTokens = value.usage.output_tokens;
1496
+ usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
1497
+ finishReason = mapAnthropicStopReason({
1498
+ finishReason: value.delta.stop_reason,
1499
+ isJsonResponseFromTool: usesJsonResponseTool
1500
+ });
1501
+ return;
1502
+ }
1503
+ case "message_stop": {
1504
+ controller.enqueue({
1505
+ type: "finish",
1506
+ finishReason,
1507
+ usage,
1508
+ providerMetadata
1509
+ });
1510
+ return;
1511
+ }
1512
+ case "error": {
1513
+ controller.enqueue({ type: "error", error: value.error });
1514
+ return;
1515
+ }
1516
+ default: {
1517
+ const _exhaustiveCheck = value;
1518
+ throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
1519
+ }
1520
+ }
1521
+ }
1522
+ })
1523
+ ),
1524
+ request: { body },
1525
+ response: { headers: responseHeaders }
1526
+ };
1527
+ }
1528
+ };
1529
+ var anthropicMessagesResponseSchema = import_v44.z.object({
1530
+ type: import_v44.z.literal("message"),
1531
+ id: import_v44.z.string().nullish(),
1532
+ model: import_v44.z.string().nullish(),
1533
+ content: import_v44.z.array(
1534
+ import_v44.z.discriminatedUnion("type", [
1535
+ import_v44.z.object({
1536
+ type: import_v44.z.literal("text"),
1537
+ text: import_v44.z.string(),
1538
+ citations: import_v44.z.array(citationSchema).optional()
1539
+ }),
1540
+ import_v44.z.object({
1541
+ type: import_v44.z.literal("thinking"),
1542
+ thinking: import_v44.z.string(),
1543
+ signature: import_v44.z.string()
1544
+ }),
1545
+ import_v44.z.object({
1546
+ type: import_v44.z.literal("redacted_thinking"),
1547
+ data: import_v44.z.string()
1548
+ }),
1549
+ import_v44.z.object({
1550
+ type: import_v44.z.literal("tool_use"),
1551
+ id: import_v44.z.string(),
1552
+ name: import_v44.z.string(),
1553
+ input: import_v44.z.unknown()
1554
+ }),
1555
+ import_v44.z.object({
1556
+ type: import_v44.z.literal("server_tool_use"),
1557
+ id: import_v44.z.string(),
1558
+ name: import_v44.z.string(),
1559
+ input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1560
+ }),
1561
+ import_v44.z.object({
1562
+ type: import_v44.z.literal("web_search_tool_result"),
1563
+ tool_use_id: import_v44.z.string(),
1564
+ content: import_v44.z.union([
1565
+ import_v44.z.array(
1566
+ import_v44.z.object({
1567
+ type: import_v44.z.literal("web_search_result"),
1568
+ url: import_v44.z.string(),
1569
+ title: import_v44.z.string(),
1570
+ encrypted_content: import_v44.z.string(),
1571
+ page_age: import_v44.z.string().nullish()
1572
+ })
1573
+ ),
1574
+ import_v44.z.object({
1575
+ type: import_v44.z.literal("web_search_tool_result_error"),
1576
+ error_code: import_v44.z.string()
1577
+ })
1578
+ ])
1579
+ })
1580
+ ])
1581
+ ),
1582
+ stop_reason: import_v44.z.string().nullish(),
1583
+ usage: import_v44.z.looseObject({
1584
+ input_tokens: import_v44.z.number(),
1585
+ output_tokens: import_v44.z.number(),
1586
+ cache_creation_input_tokens: import_v44.z.number().nullish(),
1587
+ cache_read_input_tokens: import_v44.z.number().nullish()
1588
+ })
1589
+ });
1590
+ var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
1591
+ import_v44.z.object({
1592
+ type: import_v44.z.literal("message_start"),
1593
+ message: import_v44.z.object({
1594
+ id: import_v44.z.string().nullish(),
1595
+ model: import_v44.z.string().nullish(),
1596
+ usage: import_v44.z.looseObject({
1597
+ input_tokens: import_v44.z.number(),
1598
+ output_tokens: import_v44.z.number(),
1599
+ cache_creation_input_tokens: import_v44.z.number().nullish(),
1600
+ cache_read_input_tokens: import_v44.z.number().nullish()
1601
+ })
1602
+ })
1603
+ }),
1604
+ import_v44.z.object({
1605
+ type: import_v44.z.literal("content_block_start"),
1606
+ index: import_v44.z.number(),
1607
+ content_block: import_v44.z.discriminatedUnion("type", [
1608
+ import_v44.z.object({
1609
+ type: import_v44.z.literal("text"),
1610
+ text: import_v44.z.string()
1611
+ }),
1612
+ import_v44.z.object({
1613
+ type: import_v44.z.literal("thinking"),
1614
+ thinking: import_v44.z.string()
1615
+ }),
1616
+ import_v44.z.object({
1617
+ type: import_v44.z.literal("tool_use"),
1618
+ id: import_v44.z.string(),
1619
+ name: import_v44.z.string()
1620
+ }),
1621
+ import_v44.z.object({
1622
+ type: import_v44.z.literal("redacted_thinking"),
1623
+ data: import_v44.z.string()
1624
+ }),
1625
+ import_v44.z.object({
1626
+ type: import_v44.z.literal("server_tool_use"),
1627
+ id: import_v44.z.string(),
1628
+ name: import_v44.z.string(),
1629
+ input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1630
+ }),
1631
+ import_v44.z.object({
1632
+ type: import_v44.z.literal("web_search_tool_result"),
1633
+ tool_use_id: import_v44.z.string(),
1634
+ content: import_v44.z.union([
1635
+ import_v44.z.array(
1636
+ import_v44.z.object({
1637
+ type: import_v44.z.literal("web_search_result"),
1638
+ url: import_v44.z.string(),
1639
+ title: import_v44.z.string(),
1640
+ encrypted_content: import_v44.z.string(),
1641
+ page_age: import_v44.z.string().nullish()
1642
+ })
1643
+ ),
1644
+ import_v44.z.object({
1645
+ type: import_v44.z.literal("web_search_tool_result_error"),
1646
+ error_code: import_v44.z.string()
1647
+ })
1648
+ ])
1649
+ })
1650
+ ])
1651
+ }),
1652
+ import_v44.z.object({
1653
+ type: import_v44.z.literal("content_block_delta"),
1654
+ index: import_v44.z.number(),
1655
+ delta: import_v44.z.discriminatedUnion("type", [
1656
+ import_v44.z.object({
1657
+ type: import_v44.z.literal("input_json_delta"),
1658
+ partial_json: import_v44.z.string()
1659
+ }),
1660
+ import_v44.z.object({
1661
+ type: import_v44.z.literal("text_delta"),
1662
+ text: import_v44.z.string()
1663
+ }),
1664
+ import_v44.z.object({
1665
+ type: import_v44.z.literal("thinking_delta"),
1666
+ thinking: import_v44.z.string()
1667
+ }),
1668
+ import_v44.z.object({
1669
+ type: import_v44.z.literal("signature_delta"),
1670
+ signature: import_v44.z.string()
1671
+ }),
1672
+ import_v44.z.object({
1673
+ type: import_v44.z.literal("citations_delta"),
1674
+ citation: citationSchema
1675
+ })
1676
+ ])
1677
+ }),
1678
+ import_v44.z.object({
1679
+ type: import_v44.z.literal("content_block_stop"),
1680
+ index: import_v44.z.number()
1681
+ }),
1682
+ import_v44.z.object({
1683
+ type: import_v44.z.literal("error"),
1684
+ error: import_v44.z.object({
1685
+ type: import_v44.z.string(),
1686
+ message: import_v44.z.string()
1687
+ })
1688
+ }),
1689
+ import_v44.z.object({
1690
+ type: import_v44.z.literal("message_delta"),
1691
+ delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
1692
+ usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
1693
+ }),
1694
+ import_v44.z.object({
1695
+ type: import_v44.z.literal("message_stop")
1696
+ }),
1697
+ import_v44.z.object({
1698
+ type: import_v44.z.literal("ping")
1699
+ })
1700
+ ]);
1701
+ var anthropicReasoningMetadataSchema = import_v44.z.object({
1702
+ signature: import_v44.z.string().optional(),
1703
+ redactedData: import_v44.z.string().optional()
1704
+ });
1705
+
1706
+ // src/tool/bash_20241022.ts
1707
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
1708
+ var import_v45 = __toESM(require("zod/v4"));
1709
+ var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
1710
+ id: "anthropic.bash_20241022",
1711
+ name: "bash",
1712
+ inputSchema: import_v45.default.object({
1713
+ command: import_v45.default.string(),
1714
+ restart: import_v45.default.boolean().optional()
1715
+ })
1716
+ });
1717
+
1718
+ // src/tool/bash_20250124.ts
1719
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1720
+ var import_v46 = __toESM(require("zod/v4"));
1721
+ var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1722
+ id: "anthropic.bash_20250124",
1723
+ name: "bash",
1724
+ inputSchema: import_v46.default.object({
1725
+ command: import_v46.default.string(),
1726
+ restart: import_v46.default.boolean().optional()
1727
+ })
1728
+ });
1729
+
1730
+ // src/tool/computer_20241022.ts
1731
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1732
+ var import_v47 = require("zod/v4");
1733
+ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1734
+ id: "anthropic.computer_20241022",
1735
+ name: "computer",
1736
+ inputSchema: import_v47.z.object({
1737
+ action: import_v47.z.enum([
1738
+ "key",
1739
+ "type",
1740
+ "mouse_move",
1741
+ "left_click",
1742
+ "left_click_drag",
1743
+ "right_click",
1744
+ "middle_click",
1745
+ "double_click",
1746
+ "screenshot",
1747
+ "cursor_position"
1748
+ ]),
1749
+ coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
1750
+ text: import_v47.z.string().optional()
1751
+ })
1752
+ });
1753
+
1754
+ // src/tool/computer_20250124.ts
1755
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1756
+ var import_v48 = require("zod/v4");
1757
+ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1758
+ id: "anthropic.computer_20250124",
1759
+ name: "computer",
1760
+ inputSchema: import_v48.z.object({
1761
+ action: import_v48.z.enum([
1762
+ "key",
1763
+ "hold_key",
1764
+ "type",
1765
+ "cursor_position",
1766
+ "mouse_move",
1767
+ "left_mouse_down",
1768
+ "left_mouse_up",
1769
+ "left_click",
1770
+ "left_click_drag",
1771
+ "right_click",
1772
+ "middle_click",
1773
+ "double_click",
1774
+ "triple_click",
1775
+ "scroll",
1776
+ "wait",
1777
+ "screenshot"
1778
+ ]),
1779
+ coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1780
+ duration: import_v48.z.number().optional(),
1781
+ scroll_amount: import_v48.z.number().optional(),
1782
+ scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
1783
+ start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1784
+ text: import_v48.z.string().optional()
1785
+ })
1786
+ });
1787
+
1788
+ // src/tool/text-editor_20241022.ts
1789
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1790
+ var import_v49 = require("zod/v4");
1791
+ var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1792
+ id: "anthropic.text_editor_20241022",
1793
+ name: "str_replace_editor",
1794
+ inputSchema: import_v49.z.object({
1795
+ command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1796
+ path: import_v49.z.string(),
1797
+ file_text: import_v49.z.string().optional(),
1798
+ insert_line: import_v49.z.number().int().optional(),
1799
+ new_str: import_v49.z.string().optional(),
1800
+ old_str: import_v49.z.string().optional(),
1801
+ view_range: import_v49.z.array(import_v49.z.number().int()).optional()
1802
+ })
1803
+ });
1804
+
1805
+ // src/tool/text-editor_20250124.ts
1806
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1807
+ var import_v410 = require("zod/v4");
1808
+ var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1809
+ id: "anthropic.text_editor_20250124",
1810
+ name: "str_replace_editor",
1811
+ inputSchema: import_v410.z.object({
1812
+ command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1813
+ path: import_v410.z.string(),
1814
+ file_text: import_v410.z.string().optional(),
1815
+ insert_line: import_v410.z.number().int().optional(),
1816
+ new_str: import_v410.z.string().optional(),
1817
+ old_str: import_v410.z.string().optional(),
1818
+ view_range: import_v410.z.array(import_v410.z.number().int()).optional()
1819
+ })
1820
+ });
1821
+
1822
+ // src/tool/text-editor_20250429.ts
1823
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1824
+ var import_v411 = require("zod/v4");
1825
+ var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1826
+ id: "anthropic.text_editor_20250429",
1827
+ name: "str_replace_based_edit_tool",
1828
+ inputSchema: import_v411.z.object({
1829
+ command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
1830
+ path: import_v411.z.string(),
1831
+ file_text: import_v411.z.string().optional(),
1832
+ insert_line: import_v411.z.number().int().optional(),
1833
+ new_str: import_v411.z.string().optional(),
1834
+ old_str: import_v411.z.string().optional(),
1835
+ view_range: import_v411.z.array(import_v411.z.number().int()).optional()
1836
+ })
1837
+ });
1838
+
1839
+ // src/anthropic-tools.ts
1840
+ var anthropicTools = {
1841
+ /**
1842
+ * Creates a tool for running a bash command. Must have name "bash".
1843
+ *
1844
+ * Image results are supported.
1845
+ *
1846
+ * @param execute - The function to execute the tool. Optional.
1847
+ */
1848
+ bash_20241022,
1849
+ /**
1850
+ * Creates a tool for running a bash command. Must have name "bash".
1851
+ *
1852
+ * Image results are supported.
1853
+ *
1854
+ * @param execute - The function to execute the tool. Optional.
1855
+ */
1856
+ bash_20250124,
1857
+ /**
1858
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1859
+ */
1860
+ textEditor_20241022,
1861
+ /**
1862
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1863
+ */
1864
+ textEditor_20250124,
1865
+ /**
1866
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
1867
+ * Note: This version does not support the "undo_edit" command.
1868
+ */
1869
+ textEditor_20250429,
1870
+ /**
1871
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1872
+ *
1873
+ * Image results are supported.
1874
+ *
1875
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1876
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1877
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1878
+ */
1879
+ computer_20241022,
1880
+ /**
1881
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1882
+ *
1883
+ * Image results are supported.
1884
+ *
1885
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1886
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1887
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1888
+ * @param execute - The function to execute the tool. Optional.
1889
+ */
1890
+ computer_20250124,
1891
+ /**
1892
+ * Creates a web search tool that gives Claude direct access to real-time web content.
1893
+ * Must have name "web_search".
1894
+ *
1895
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
1896
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
1897
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
1898
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
1899
+ */
1900
+ webSearch_20250305
1901
+ };
1902
+
1903
+ // src/anthropic-provider.ts
1904
+ function createAnthropic(options = {}) {
1905
+ var _a;
1906
+ const baseURL = (_a = (0, import_provider_utils12.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
1907
+ const getHeaders = () => ({
1908
+ "anthropic-version": "2023-06-01",
1909
+ "x-api-key": (0, import_provider_utils12.loadApiKey)({
1910
+ apiKey: options.apiKey,
1911
+ environmentVariableName: "ANTHROPIC_API_KEY",
1912
+ description: "Anthropic"
1913
+ }),
1914
+ ...options.headers
1915
+ });
1916
+ const createChatModel = (modelId) => {
1917
+ var _a2;
1918
+ return new AnthropicMessagesLanguageModel(modelId, {
1919
+ provider: "anthropic.messages",
1920
+ baseURL,
1921
+ headers: getHeaders,
1922
+ fetch: options.fetch,
1923
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils12.generateId,
1924
+ supportedUrls: () => ({
1925
+ "image/*": [/^https?:\/\/.*$/]
1926
+ })
1927
+ });
1928
+ };
1929
+ const provider = function(modelId) {
1930
+ if (new.target) {
1931
+ throw new Error(
1932
+ "The Anthropic model function cannot be called with the new keyword."
1933
+ );
1934
+ }
1935
+ return createChatModel(modelId);
1936
+ };
1937
+ provider.languageModel = createChatModel;
1938
+ provider.chat = createChatModel;
1939
+ provider.messages = createChatModel;
1940
+ provider.textEmbeddingModel = (modelId) => {
1941
+ throw new import_provider4.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
1942
+ };
1943
+ provider.imageModel = (modelId) => {
1944
+ throw new import_provider4.NoSuchModelError({ modelId, modelType: "imageModel" });
1945
+ };
1946
+ provider.tools = anthropicTools;
1947
+ return provider;
1948
+ }
1949
+ var anthropic = createAnthropic();
1950
+ // Annotate the CommonJS export names for ESM import in node:
1951
+ 0 && (module.exports = {
1952
+ anthropic,
1953
+ createAnthropic
1954
+ });
1955
+ //# sourceMappingURL=index.js.map
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.js.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs ADDED
@@ -0,0 +1,1937 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/anthropic-provider.ts
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ generateId as generateId2,
7
+ loadApiKey,
8
+ withoutTrailingSlash
9
+ } from "@ai-sdk/provider-utils";
10
+
11
+ // src/anthropic-messages-language-model.ts
12
+ import {
13
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError3
14
+ } from "@ai-sdk/provider";
15
+ import {
16
+ combineHeaders,
17
+ createEventSourceResponseHandler,
18
+ createJsonResponseHandler,
19
+ generateId,
20
+ parseProviderOptions as parseProviderOptions2,
21
+ postJsonToApi,
22
+ resolve
23
+ } from "@ai-sdk/provider-utils";
24
+ import { z as z4 } from "zod/v4";
25
+
26
+ // src/anthropic-error.ts
27
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
28
+ import { z } from "zod/v4";
29
+ var anthropicErrorDataSchema = z.object({
30
+ type: z.literal("error"),
31
+ error: z.object({
32
+ type: z.string(),
33
+ message: z.string()
34
+ })
35
+ });
36
+ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
37
+ errorSchema: anthropicErrorDataSchema,
38
+ errorToMessage: (data) => data.error.message
39
+ });
40
+
41
+ // src/anthropic-messages-options.ts
42
+ import { z as z2 } from "zod/v4";
43
+ var anthropicFilePartProviderOptions = z2.object({
44
+ /**
45
+ * Citation configuration for this document.
46
+ * When enabled, this document will generate citations in the response.
47
+ */
48
+ citations: z2.object({
49
+ /**
50
+ * Enable citations for this document
51
+ */
52
+ enabled: z2.boolean()
53
+ }).optional(),
54
+ /**
55
+ * Custom title for the document.
56
+ * If not provided, the filename will be used.
57
+ */
58
+ title: z2.string().optional(),
59
+ /**
60
+ * Context about the document that will be passed to the model
61
+ * but not used towards cited content.
62
+ * Useful for storing document metadata as text or stringified JSON.
63
+ */
64
+ context: z2.string().optional()
65
+ });
66
+ var anthropicProviderOptions = z2.object({
67
+ sendReasoning: z2.boolean().optional(),
68
+ thinking: z2.object({
69
+ type: z2.union([z2.literal("enabled"), z2.literal("disabled")]),
70
+ budgetTokens: z2.number().optional()
71
+ }).optional(),
72
+ /**
73
+ * Whether to disable parallel function calling during tool use. Default is false.
74
+ * When set to true, Claude will use at most one tool per response.
75
+ */
76
+ disableParallelToolUse: z2.boolean().optional()
77
+ });
78
+
79
+ // src/anthropic-prepare-tools.ts
80
+ import {
81
+ UnsupportedFunctionalityError
82
+ } from "@ai-sdk/provider";
83
+
84
+ // src/get-cache-control.ts
85
+ function getCacheControl(providerMetadata) {
86
+ var _a;
87
+ const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
88
+ const cacheControlValue = (_a = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a : anthropic2 == null ? void 0 : anthropic2.cache_control;
89
+ return cacheControlValue;
90
+ }
91
+
92
+ // src/tool/web-search_20250305.ts
93
+ import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
94
+ import { z as z3 } from "zod/v4";
95
+ var webSearch_20250305ArgsSchema = z3.object({
96
+ /**
97
+ * Maximum number of web searches Claude can perform during the conversation.
98
+ */
99
+ maxUses: z3.number().optional(),
100
+ /**
101
+ * Optional list of domains that Claude is allowed to search.
102
+ */
103
+ allowedDomains: z3.array(z3.string()).optional(),
104
+ /**
105
+ * Optional list of domains that Claude should avoid when searching.
106
+ */
107
+ blockedDomains: z3.array(z3.string()).optional(),
108
+ /**
109
+ * Optional user location information to provide geographically relevant search results.
110
+ */
111
+ userLocation: z3.object({
112
+ type: z3.literal("approximate"),
113
+ city: z3.string().optional(),
114
+ region: z3.string().optional(),
115
+ country: z3.string().optional(),
116
+ timezone: z3.string().optional()
117
+ }).optional()
118
+ });
119
+ var webSearch_20250305OutputSchema = z3.array(
120
+ z3.object({
121
+ url: z3.string(),
122
+ title: z3.string(),
123
+ pageAge: z3.string().nullable(),
124
+ encryptedContent: z3.string(),
125
+ type: z3.string()
126
+ })
127
+ );
128
+ var factory = createProviderDefinedToolFactoryWithOutputSchema({
129
+ id: "anthropic.web_search_20250305",
130
+ name: "web_search",
131
+ inputSchema: z3.object({
132
+ query: z3.string()
133
+ }),
134
+ outputSchema: webSearch_20250305OutputSchema
135
+ });
136
+ var webSearch_20250305 = (args = {}) => {
137
+ return factory(args);
138
+ };
139
+
140
+ // src/anthropic-prepare-tools.ts
141
+ function isWebSearchTool(tool) {
142
+ return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
143
+ }
144
+ function prepareTools({
145
+ tools,
146
+ toolChoice,
147
+ disableParallelToolUse
148
+ }) {
149
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
150
+ const toolWarnings = [];
151
+ const betas = /* @__PURE__ */ new Set();
152
+ if (tools == null) {
153
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
154
+ }
155
+ const anthropicTools2 = [];
156
+ for (const tool of tools) {
157
+ if (isWebSearchTool(tool)) {
158
+ anthropicTools2.push(tool);
159
+ continue;
160
+ }
161
+ switch (tool.type) {
162
+ case "function":
163
+ const cacheControl = getCacheControl(tool.providerOptions);
164
+ anthropicTools2.push({
165
+ name: tool.name,
166
+ description: tool.description,
167
+ input_schema: tool.inputSchema,
168
+ cache_control: cacheControl
169
+ });
170
+ break;
171
+ case "provider-defined":
172
+ switch (tool.id) {
173
+ case "anthropic.computer_20250124":
174
+ betas.add("computer-use-2025-01-24");
175
+ anthropicTools2.push({
176
+ name: "computer",
177
+ type: "computer_20250124",
178
+ display_width_px: tool.args.displayWidthPx,
179
+ display_height_px: tool.args.displayHeightPx,
180
+ display_number: tool.args.displayNumber
181
+ });
182
+ break;
183
+ case "anthropic.computer_20241022":
184
+ betas.add("computer-use-2024-10-22");
185
+ anthropicTools2.push({
186
+ name: "computer",
187
+ type: "computer_20241022",
188
+ display_width_px: tool.args.displayWidthPx,
189
+ display_height_px: tool.args.displayHeightPx,
190
+ display_number: tool.args.displayNumber
191
+ });
192
+ break;
193
+ case "anthropic.text_editor_20250124":
194
+ betas.add("computer-use-2025-01-24");
195
+ anthropicTools2.push({
196
+ name: "str_replace_editor",
197
+ type: "text_editor_20250124"
198
+ });
199
+ break;
200
+ case "anthropic.text_editor_20241022":
201
+ betas.add("computer-use-2024-10-22");
202
+ anthropicTools2.push({
203
+ name: "str_replace_editor",
204
+ type: "text_editor_20241022"
205
+ });
206
+ break;
207
+ case "anthropic.text_editor_20250429":
208
+ betas.add("computer-use-2025-01-24");
209
+ anthropicTools2.push({
210
+ name: "str_replace_based_edit_tool",
211
+ type: "text_editor_20250429"
212
+ });
213
+ break;
214
+ case "anthropic.bash_20250124":
215
+ betas.add("computer-use-2025-01-24");
216
+ anthropicTools2.push({
217
+ name: "bash",
218
+ type: "bash_20250124"
219
+ });
220
+ break;
221
+ case "anthropic.bash_20241022":
222
+ betas.add("computer-use-2024-10-22");
223
+ anthropicTools2.push({
224
+ name: "bash",
225
+ type: "bash_20241022"
226
+ });
227
+ break;
228
+ case "anthropic.web_search_20250305": {
229
+ const args = webSearch_20250305ArgsSchema.parse(tool.args);
230
+ anthropicTools2.push({
231
+ type: "web_search_20250305",
232
+ name: "web_search",
233
+ max_uses: args.maxUses,
234
+ allowed_domains: args.allowedDomains,
235
+ blocked_domains: args.blockedDomains,
236
+ user_location: args.userLocation
237
+ });
238
+ break;
239
+ }
240
+ default:
241
+ toolWarnings.push({ type: "unsupported-tool", tool });
242
+ break;
243
+ }
244
+ break;
245
+ default:
246
+ toolWarnings.push({ type: "unsupported-tool", tool });
247
+ break;
248
+ }
249
+ }
250
+ if (toolChoice == null) {
251
+ return {
252
+ tools: anthropicTools2,
253
+ toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
254
+ toolWarnings,
255
+ betas
256
+ };
257
+ }
258
+ const type = toolChoice.type;
259
+ switch (type) {
260
+ case "auto":
261
+ return {
262
+ tools: anthropicTools2,
263
+ toolChoice: {
264
+ type: "auto",
265
+ disable_parallel_tool_use: disableParallelToolUse
266
+ },
267
+ toolWarnings,
268
+ betas
269
+ };
270
+ case "required":
271
+ return {
272
+ tools: anthropicTools2,
273
+ toolChoice: {
274
+ type: "any",
275
+ disable_parallel_tool_use: disableParallelToolUse
276
+ },
277
+ toolWarnings,
278
+ betas
279
+ };
280
+ case "none":
281
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
282
+ case "tool":
283
+ return {
284
+ tools: anthropicTools2,
285
+ toolChoice: {
286
+ type: "tool",
287
+ name: toolChoice.toolName,
288
+ disable_parallel_tool_use: disableParallelToolUse
289
+ },
290
+ toolWarnings,
291
+ betas
292
+ };
293
+ default: {
294
+ const _exhaustiveCheck = type;
295
+ throw new UnsupportedFunctionalityError({
296
+ functionality: `tool choice type: ${_exhaustiveCheck}`
297
+ });
298
+ }
299
+ }
300
+ }
301
+
302
+ // src/convert-to-anthropic-messages-prompt.ts
303
+ import {
304
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
305
+ } from "@ai-sdk/provider";
306
+ import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
307
+ function convertToString(data) {
308
+ if (typeof data === "string") {
309
+ return Buffer.from(data, "base64").toString("utf-8");
310
+ }
311
+ if (data instanceof Uint8Array) {
312
+ return new TextDecoder().decode(data);
313
+ }
314
+ if (data instanceof URL) {
315
+ throw new UnsupportedFunctionalityError2({
316
+ functionality: "URL-based text documents are not supported for citations"
317
+ });
318
+ }
319
+ throw new UnsupportedFunctionalityError2({
320
+ functionality: `unsupported data type for text documents: ${typeof data}`
321
+ });
322
+ }
323
+ async function convertToAnthropicMessagesPrompt({
324
+ prompt,
325
+ sendReasoning,
326
+ warnings
327
+ }) {
328
+ var _a, _b, _c, _d, _e;
329
+ const betas = /* @__PURE__ */ new Set();
330
+ const blocks = groupIntoBlocks(prompt);
331
+ let system = void 0;
332
+ const messages = [];
333
+ async function shouldEnableCitations(providerMetadata) {
334
+ var _a2, _b2;
335
+ const anthropicOptions = await parseProviderOptions({
336
+ provider: "anthropic",
337
+ providerOptions: providerMetadata,
338
+ schema: anthropicFilePartProviderOptions
339
+ });
340
+ return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
341
+ }
342
+ async function getDocumentMetadata(providerMetadata) {
343
+ const anthropicOptions = await parseProviderOptions({
344
+ provider: "anthropic",
345
+ providerOptions: providerMetadata,
346
+ schema: anthropicFilePartProviderOptions
347
+ });
348
+ return {
349
+ title: anthropicOptions == null ? void 0 : anthropicOptions.title,
350
+ context: anthropicOptions == null ? void 0 : anthropicOptions.context
351
+ };
352
+ }
353
+ for (let i = 0; i < blocks.length; i++) {
354
+ const block = blocks[i];
355
+ const isLastBlock = i === blocks.length - 1;
356
+ const type = block.type;
357
+ switch (type) {
358
+ case "system": {
359
+ if (system != null) {
360
+ throw new UnsupportedFunctionalityError2({
361
+ functionality: "Multiple system messages that are separated by user/assistant messages"
362
+ });
363
+ }
364
+ system = block.messages.map(({ content, providerOptions }) => ({
365
+ type: "text",
366
+ text: content,
367
+ cache_control: getCacheControl(providerOptions)
368
+ }));
369
+ break;
370
+ }
371
+ case "user": {
372
+ const anthropicContent = [];
373
+ for (const message of block.messages) {
374
+ const { role, content } = message;
375
+ switch (role) {
376
+ case "user": {
377
+ for (let j = 0; j < content.length; j++) {
378
+ const part = content[j];
379
+ const isLastPart = j === content.length - 1;
380
+ const cacheControl = (_a = getCacheControl(part.providerOptions)) != null ? _a : isLastPart ? getCacheControl(message.providerOptions) : void 0;
381
+ switch (part.type) {
382
+ case "text": {
383
+ anthropicContent.push({
384
+ type: "text",
385
+ text: part.text,
386
+ cache_control: cacheControl
387
+ });
388
+ break;
389
+ }
390
+ case "file": {
391
+ if (part.mediaType.startsWith("image/")) {
392
+ anthropicContent.push({
393
+ type: "image",
394
+ source: part.data instanceof URL ? {
395
+ type: "url",
396
+ url: part.data.toString()
397
+ } : {
398
+ type: "base64",
399
+ media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
400
+ data: convertToBase64(part.data)
401
+ },
402
+ cache_control: cacheControl
403
+ });
404
+ } else if (part.mediaType === "application/pdf") {
405
+ betas.add("pdfs-2024-09-25");
406
+ const enableCitations = await shouldEnableCitations(
407
+ part.providerOptions
408
+ );
409
+ const metadata = await getDocumentMetadata(
410
+ part.providerOptions
411
+ );
412
+ anthropicContent.push({
413
+ type: "document",
414
+ source: part.data instanceof URL ? {
415
+ type: "url",
416
+ url: part.data.toString()
417
+ } : {
418
+ type: "base64",
419
+ media_type: "application/pdf",
420
+ data: convertToBase64(part.data)
421
+ },
422
+ title: (_b = metadata.title) != null ? _b : part.filename,
423
+ ...metadata.context && { context: metadata.context },
424
+ ...enableCitations && {
425
+ citations: { enabled: true }
426
+ },
427
+ cache_control: cacheControl
428
+ });
429
+ } else if (part.mediaType === "text/plain") {
430
+ const enableCitations = await shouldEnableCitations(
431
+ part.providerOptions
432
+ );
433
+ const metadata = await getDocumentMetadata(
434
+ part.providerOptions
435
+ );
436
+ anthropicContent.push({
437
+ type: "document",
438
+ source: part.data instanceof URL ? {
439
+ type: "url",
440
+ url: part.data.toString()
441
+ } : {
442
+ type: "text",
443
+ media_type: "text/plain",
444
+ data: convertToString(part.data)
445
+ },
446
+ title: (_c = metadata.title) != null ? _c : part.filename,
447
+ ...metadata.context && { context: metadata.context },
448
+ ...enableCitations && {
449
+ citations: { enabled: true }
450
+ },
451
+ cache_control: cacheControl
452
+ });
453
+ } else {
454
+ throw new UnsupportedFunctionalityError2({
455
+ functionality: `media type: ${part.mediaType}`
456
+ });
457
+ }
458
+ break;
459
+ }
460
+ }
461
+ }
462
+ break;
463
+ }
464
+ case "tool": {
465
+ for (let i2 = 0; i2 < content.length; i2++) {
466
+ const part = content[i2];
467
+ const isLastPart = i2 === content.length - 1;
468
+ const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
469
+ const output = part.output;
470
+ let contentValue;
471
+ switch (output.type) {
472
+ case "content":
473
+ contentValue = output.value.map((contentPart) => {
474
+ switch (contentPart.type) {
475
+ case "text":
476
+ return {
477
+ type: "text",
478
+ text: contentPart.text,
479
+ cache_control: void 0
480
+ };
481
+ case "media": {
482
+ if (contentPart.mediaType.startsWith("image/")) {
483
+ return {
484
+ type: "image",
485
+ source: {
486
+ type: "base64",
487
+ media_type: contentPart.mediaType,
488
+ data: contentPart.data
489
+ },
490
+ cache_control: void 0
491
+ };
492
+ }
493
+ throw new UnsupportedFunctionalityError2({
494
+ functionality: `media type: ${contentPart.mediaType}`
495
+ });
496
+ }
497
+ }
498
+ });
499
+ break;
500
+ case "text":
501
+ case "error-text":
502
+ contentValue = output.value;
503
+ break;
504
+ case "json":
505
+ case "error-json":
506
+ default:
507
+ contentValue = JSON.stringify(output.value);
508
+ break;
509
+ }
510
+ anthropicContent.push({
511
+ type: "tool_result",
512
+ tool_use_id: part.toolCallId,
513
+ content: contentValue,
514
+ is_error: output.type === "error-text" || output.type === "error-json" ? true : void 0,
515
+ cache_control: cacheControl
516
+ });
517
+ }
518
+ break;
519
+ }
520
+ default: {
521
+ const _exhaustiveCheck = role;
522
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
523
+ }
524
+ }
525
+ }
526
+ messages.push({ role: "user", content: anthropicContent });
527
+ break;
528
+ }
529
+ case "assistant": {
530
+ const anthropicContent = [];
531
+ for (let j = 0; j < block.messages.length; j++) {
532
+ const message = block.messages[j];
533
+ const isLastMessage = j === block.messages.length - 1;
534
+ const { content } = message;
535
+ for (let k = 0; k < content.length; k++) {
536
+ const part = content[k];
537
+ const isLastContentPart = k === content.length - 1;
538
+ const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
539
+ switch (part.type) {
540
+ case "text": {
541
+ anthropicContent.push({
542
+ type: "text",
543
+ text: (
544
+ // trim the last text part if it's the last message in the block
545
+ // because Anthropic does not allow trailing whitespace
546
+ // in pre-filled assistant responses
547
+ isLastBlock && isLastMessage && isLastContentPart ? part.text.trim() : part.text
548
+ ),
549
+ cache_control: cacheControl
550
+ });
551
+ break;
552
+ }
553
+ case "reasoning": {
554
+ if (sendReasoning) {
555
+ const reasoningMetadata = await parseProviderOptions({
556
+ provider: "anthropic",
557
+ providerOptions: part.providerOptions,
558
+ schema: anthropicReasoningMetadataSchema
559
+ });
560
+ if (reasoningMetadata != null) {
561
+ if (reasoningMetadata.signature != null) {
562
+ anthropicContent.push({
563
+ type: "thinking",
564
+ thinking: part.text,
565
+ signature: reasoningMetadata.signature,
566
+ cache_control: cacheControl
567
+ });
568
+ } else if (reasoningMetadata.redactedData != null) {
569
+ anthropicContent.push({
570
+ type: "redacted_thinking",
571
+ data: reasoningMetadata.redactedData,
572
+ cache_control: cacheControl
573
+ });
574
+ } else {
575
+ warnings.push({
576
+ type: "other",
577
+ message: "unsupported reasoning metadata"
578
+ });
579
+ }
580
+ } else {
581
+ warnings.push({
582
+ type: "other",
583
+ message: "unsupported reasoning metadata"
584
+ });
585
+ }
586
+ } else {
587
+ warnings.push({
588
+ type: "other",
589
+ message: "sending reasoning content is disabled for this model"
590
+ });
591
+ }
592
+ break;
593
+ }
594
+ case "tool-call": {
595
+ if (part.providerExecuted) {
596
+ if (part.toolName === "web_search") {
597
+ anthropicContent.push({
598
+ type: "server_tool_use",
599
+ id: part.toolCallId,
600
+ name: "web_search",
601
+ input: part.input,
602
+ cache_control: cacheControl
603
+ });
604
+ break;
605
+ }
606
+ warnings.push({
607
+ type: "other",
608
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
609
+ });
610
+ break;
611
+ }
612
+ anthropicContent.push({
613
+ type: "tool_use",
614
+ id: part.toolCallId,
615
+ name: part.toolName,
616
+ input: part.input,
617
+ cache_control: cacheControl
618
+ });
619
+ break;
620
+ }
621
+ case "tool-result": {
622
+ if (part.toolName === "web_search") {
623
+ const output = part.output;
624
+ if (output.type !== "json") {
625
+ warnings.push({
626
+ type: "other",
627
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
628
+ });
629
+ break;
630
+ }
631
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
632
+ output.value
633
+ );
634
+ anthropicContent.push({
635
+ type: "web_search_tool_result",
636
+ tool_use_id: part.toolCallId,
637
+ content: webSearchOutput.map((result) => ({
638
+ url: result.url,
639
+ title: result.title,
640
+ page_age: result.pageAge,
641
+ encrypted_content: result.encryptedContent,
642
+ type: result.type
643
+ })),
644
+ cache_control: cacheControl
645
+ });
646
+ break;
647
+ }
648
+ warnings.push({
649
+ type: "other",
650
+ message: `provider executed tool result for tool ${part.toolName} is not supported`
651
+ });
652
+ break;
653
+ }
654
+ }
655
+ }
656
+ }
657
+ messages.push({ role: "assistant", content: anthropicContent });
658
+ break;
659
+ }
660
+ default: {
661
+ const _exhaustiveCheck = type;
662
+ throw new Error(`content type: ${_exhaustiveCheck}`);
663
+ }
664
+ }
665
+ }
666
+ return {
667
+ prompt: { system, messages },
668
+ betas
669
+ };
670
+ }
671
+ function groupIntoBlocks(prompt) {
672
+ const blocks = [];
673
+ let currentBlock = void 0;
674
+ for (const message of prompt) {
675
+ const { role } = message;
676
+ switch (role) {
677
+ case "system": {
678
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "system") {
679
+ currentBlock = { type: "system", messages: [] };
680
+ blocks.push(currentBlock);
681
+ }
682
+ currentBlock.messages.push(message);
683
+ break;
684
+ }
685
+ case "assistant": {
686
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "assistant") {
687
+ currentBlock = { type: "assistant", messages: [] };
688
+ blocks.push(currentBlock);
689
+ }
690
+ currentBlock.messages.push(message);
691
+ break;
692
+ }
693
+ case "user": {
694
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
695
+ currentBlock = { type: "user", messages: [] };
696
+ blocks.push(currentBlock);
697
+ }
698
+ currentBlock.messages.push(message);
699
+ break;
700
+ }
701
+ case "tool": {
702
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
703
+ currentBlock = { type: "user", messages: [] };
704
+ blocks.push(currentBlock);
705
+ }
706
+ currentBlock.messages.push(message);
707
+ break;
708
+ }
709
+ default: {
710
+ const _exhaustiveCheck = role;
711
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
712
+ }
713
+ }
714
+ }
715
+ return blocks;
716
+ }
717
+
718
+ // src/map-anthropic-stop-reason.ts
719
+ function mapAnthropicStopReason({
720
+ finishReason,
721
+ isJsonResponseFromTool
722
+ }) {
723
+ switch (finishReason) {
724
+ case "end_turn":
725
+ case "stop_sequence":
726
+ return "stop";
727
+ case "tool_use":
728
+ return isJsonResponseFromTool ? "stop" : "tool-calls";
729
+ case "max_tokens":
730
+ return "length";
731
+ default:
732
+ return "unknown";
733
+ }
734
+ }
735
+
736
+ // src/anthropic-messages-language-model.ts
737
+ var citationSchemas = {
738
+ webSearchResult: z4.object({
739
+ type: z4.literal("web_search_result_location"),
740
+ cited_text: z4.string(),
741
+ url: z4.string(),
742
+ title: z4.string(),
743
+ encrypted_index: z4.string()
744
+ }),
745
+ pageLocation: z4.object({
746
+ type: z4.literal("page_location"),
747
+ cited_text: z4.string(),
748
+ document_index: z4.number(),
749
+ document_title: z4.string().nullable(),
750
+ start_page_number: z4.number(),
751
+ end_page_number: z4.number()
752
+ }),
753
+ charLocation: z4.object({
754
+ type: z4.literal("char_location"),
755
+ cited_text: z4.string(),
756
+ document_index: z4.number(),
757
+ document_title: z4.string().nullable(),
758
+ start_char_index: z4.number(),
759
+ end_char_index: z4.number()
760
+ })
761
+ };
762
+ var citationSchema = z4.discriminatedUnion("type", [
763
+ citationSchemas.webSearchResult,
764
+ citationSchemas.pageLocation,
765
+ citationSchemas.charLocation
766
+ ]);
767
+ var documentCitationSchema = z4.discriminatedUnion("type", [
768
+ citationSchemas.pageLocation,
769
+ citationSchemas.charLocation
770
+ ]);
771
+ function processCitation(citation, citationDocuments, generateId3, onSource) {
772
+ if (citation.type === "page_location" || citation.type === "char_location") {
773
+ const source = createCitationSource(
774
+ citation,
775
+ citationDocuments,
776
+ generateId3
777
+ );
778
+ if (source) {
779
+ onSource(source);
780
+ }
781
+ }
782
+ }
783
+ function createCitationSource(citation, citationDocuments, generateId3) {
784
+ var _a;
785
+ const documentInfo = citationDocuments[citation.document_index];
786
+ if (!documentInfo) {
787
+ return null;
788
+ }
789
+ const providerMetadata = citation.type === "page_location" ? {
790
+ citedText: citation.cited_text,
791
+ startPageNumber: citation.start_page_number,
792
+ endPageNumber: citation.end_page_number
793
+ } : {
794
+ citedText: citation.cited_text,
795
+ startCharIndex: citation.start_char_index,
796
+ endCharIndex: citation.end_char_index
797
+ };
798
+ return {
799
+ type: "source",
800
+ sourceType: "document",
801
+ id: generateId3(),
802
+ mediaType: documentInfo.mediaType,
803
+ title: (_a = citation.document_title) != null ? _a : documentInfo.title,
804
+ filename: documentInfo.filename,
805
+ providerMetadata: {
806
+ anthropic: providerMetadata
807
+ }
808
+ };
809
+ }
810
+ var AnthropicMessagesLanguageModel = class {
811
+ constructor(modelId, config) {
812
+ this.specificationVersion = "v2";
813
+ var _a;
814
+ this.modelId = modelId;
815
+ this.config = config;
816
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
817
+ }
818
+ supportsUrl(url) {
819
+ return url.protocol === "https:";
820
+ }
821
+ get provider() {
822
+ return this.config.provider;
823
+ }
824
+ get supportedUrls() {
825
+ var _a, _b, _c;
826
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
827
+ }
828
+ async getArgs({
829
+ prompt,
830
+ maxOutputTokens = 4096,
831
+ // 4096: max model output tokens TODO update default in v5
832
+ temperature,
833
+ topP,
834
+ topK,
835
+ frequencyPenalty,
836
+ presencePenalty,
837
+ stopSequences,
838
+ responseFormat,
839
+ seed,
840
+ tools,
841
+ toolChoice,
842
+ providerOptions
843
+ }) {
844
+ var _a, _b, _c;
845
+ const warnings = [];
846
+ if (frequencyPenalty != null) {
847
+ warnings.push({
848
+ type: "unsupported-setting",
849
+ setting: "frequencyPenalty"
850
+ });
851
+ }
852
+ if (presencePenalty != null) {
853
+ warnings.push({
854
+ type: "unsupported-setting",
855
+ setting: "presencePenalty"
856
+ });
857
+ }
858
+ if (seed != null) {
859
+ warnings.push({
860
+ type: "unsupported-setting",
861
+ setting: "seed"
862
+ });
863
+ }
864
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
865
+ if (responseFormat.schema == null) {
866
+ warnings.push({
867
+ type: "unsupported-setting",
868
+ setting: "responseFormat",
869
+ details: "JSON response format requires a schema. The response format is ignored."
870
+ });
871
+ } else if (tools != null) {
872
+ warnings.push({
873
+ type: "unsupported-setting",
874
+ setting: "tools",
875
+ details: "JSON response format does not support tools. The provided tools are ignored."
876
+ });
877
+ }
878
+ }
879
+ const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null ? {
880
+ type: "function",
881
+ name: "json",
882
+ description: "Respond with a JSON object.",
883
+ inputSchema: responseFormat.schema
884
+ } : void 0;
885
+ const anthropicOptions = await parseProviderOptions2({
886
+ provider: "anthropic",
887
+ providerOptions,
888
+ schema: anthropicProviderOptions
889
+ });
890
+ const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
891
+ prompt,
892
+ sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
893
+ warnings
894
+ });
895
+ const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
896
+ const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
897
+ const baseArgs = {
898
+ // model id:
899
+ model: this.modelId,
900
+ // standardized settings:
901
+ max_tokens: maxOutputTokens,
902
+ temperature,
903
+ top_k: topK,
904
+ top_p: topP,
905
+ stop_sequences: stopSequences,
906
+ // provider specific settings:
907
+ ...isThinking && {
908
+ thinking: { type: "enabled", budget_tokens: thinkingBudget }
909
+ },
910
+ // prompt:
911
+ system: messagesPrompt.system,
912
+ messages: messagesPrompt.messages
913
+ };
914
+ if (isThinking) {
915
+ if (thinkingBudget == null) {
916
+ throw new UnsupportedFunctionalityError3({
917
+ functionality: "thinking requires a budget"
918
+ });
919
+ }
920
+ if (baseArgs.temperature != null) {
921
+ baseArgs.temperature = void 0;
922
+ warnings.push({
923
+ type: "unsupported-setting",
924
+ setting: "temperature",
925
+ details: "temperature is not supported when thinking is enabled"
926
+ });
927
+ }
928
+ if (topK != null) {
929
+ baseArgs.top_k = void 0;
930
+ warnings.push({
931
+ type: "unsupported-setting",
932
+ setting: "topK",
933
+ details: "topK is not supported when thinking is enabled"
934
+ });
935
+ }
936
+ if (topP != null) {
937
+ baseArgs.top_p = void 0;
938
+ warnings.push({
939
+ type: "unsupported-setting",
940
+ setting: "topP",
941
+ details: "topP is not supported when thinking is enabled"
942
+ });
943
+ }
944
+ baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
945
+ }
946
+ const {
947
+ tools: anthropicTools2,
948
+ toolChoice: anthropicToolChoice,
949
+ toolWarnings,
950
+ betas: toolsBetas
951
+ } = prepareTools(
952
+ jsonResponseTool != null ? {
953
+ tools: [jsonResponseTool],
954
+ toolChoice: { type: "tool", toolName: jsonResponseTool.name },
955
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
956
+ } : {
957
+ tools: tools != null ? tools : [],
958
+ toolChoice,
959
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
960
+ }
961
+ );
962
+ return {
963
+ args: {
964
+ ...baseArgs,
965
+ tools: anthropicTools2,
966
+ tool_choice: anthropicToolChoice
967
+ },
968
+ warnings: [...warnings, ...toolWarnings],
969
+ betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
970
+ usesJsonResponseTool: jsonResponseTool != null
971
+ };
972
+ }
973
+ async getHeaders({
974
+ betas,
975
+ headers
976
+ }) {
977
+ return combineHeaders(
978
+ await resolve(this.config.headers),
979
+ betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
980
+ headers
981
+ );
982
+ }
983
+ buildRequestUrl(isStreaming) {
984
+ var _a, _b, _c;
985
+ return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
986
+ }
987
+ transformRequestBody(args) {
988
+ var _a, _b, _c;
989
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
990
+ }
991
+ extractCitationDocuments(prompt) {
992
+ const isCitationPart = (part) => {
993
+ var _a, _b;
994
+ if (part.type !== "file") {
995
+ return false;
996
+ }
997
+ if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
998
+ return false;
999
+ }
1000
+ const anthropic2 = (_a = part.providerOptions) == null ? void 0 : _a.anthropic;
1001
+ const citationsConfig = anthropic2 == null ? void 0 : anthropic2.citations;
1002
+ return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
1003
+ };
1004
+ return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
1005
+ var _a;
1006
+ const filePart = part;
1007
+ return {
1008
+ title: (_a = filePart.filename) != null ? _a : "Untitled Document",
1009
+ filename: filePart.filename,
1010
+ mediaType: filePart.mediaType
1011
+ };
1012
+ });
1013
+ }
1014
+ async doGenerate(options) {
1015
+ var _a, _b, _c, _d, _e;
1016
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1017
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1018
+ const {
1019
+ responseHeaders,
1020
+ value: response,
1021
+ rawValue: rawResponse
1022
+ } = await postJsonToApi({
1023
+ url: this.buildRequestUrl(false),
1024
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1025
+ body: this.transformRequestBody(args),
1026
+ failedResponseHandler: anthropicFailedResponseHandler,
1027
+ successfulResponseHandler: createJsonResponseHandler(
1028
+ anthropicMessagesResponseSchema
1029
+ ),
1030
+ abortSignal: options.abortSignal,
1031
+ fetch: this.config.fetch
1032
+ });
1033
+ const content = [];
1034
+ for (const part of response.content) {
1035
+ switch (part.type) {
1036
+ case "text": {
1037
+ if (!usesJsonResponseTool) {
1038
+ content.push({ type: "text", text: part.text });
1039
+ if (part.citations) {
1040
+ for (const citation of part.citations) {
1041
+ processCitation(
1042
+ citation,
1043
+ citationDocuments,
1044
+ this.generateId,
1045
+ (source) => content.push(source)
1046
+ );
1047
+ }
1048
+ }
1049
+ }
1050
+ break;
1051
+ }
1052
+ case "thinking": {
1053
+ content.push({
1054
+ type: "reasoning",
1055
+ text: part.thinking,
1056
+ providerMetadata: {
1057
+ anthropic: {
1058
+ signature: part.signature
1059
+ }
1060
+ }
1061
+ });
1062
+ break;
1063
+ }
1064
+ case "redacted_thinking": {
1065
+ content.push({
1066
+ type: "reasoning",
1067
+ text: "",
1068
+ providerMetadata: {
1069
+ anthropic: {
1070
+ redactedData: part.data
1071
+ }
1072
+ }
1073
+ });
1074
+ break;
1075
+ }
1076
+ case "tool_use": {
1077
+ content.push(
1078
+ // when a json response tool is used, the tool call becomes the text:
1079
+ usesJsonResponseTool ? {
1080
+ type: "text",
1081
+ text: JSON.stringify(part.input)
1082
+ } : {
1083
+ type: "tool-call",
1084
+ toolCallId: part.id,
1085
+ toolName: part.name,
1086
+ input: JSON.stringify(part.input)
1087
+ }
1088
+ );
1089
+ break;
1090
+ }
1091
+ case "server_tool_use": {
1092
+ if (part.name === "web_search") {
1093
+ content.push({
1094
+ type: "tool-call",
1095
+ toolCallId: part.id,
1096
+ toolName: part.name,
1097
+ input: JSON.stringify(part.input),
1098
+ providerExecuted: true
1099
+ });
1100
+ }
1101
+ break;
1102
+ }
1103
+ case "web_search_tool_result": {
1104
+ if (Array.isArray(part.content)) {
1105
+ content.push({
1106
+ type: "tool-result",
1107
+ toolCallId: part.tool_use_id,
1108
+ toolName: "web_search",
1109
+ result: part.content.map((result) => {
1110
+ var _a2;
1111
+ return {
1112
+ url: result.url,
1113
+ title: result.title,
1114
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1115
+ encryptedContent: result.encrypted_content,
1116
+ type: result.type
1117
+ };
1118
+ }),
1119
+ providerExecuted: true
1120
+ });
1121
+ for (const result of part.content) {
1122
+ content.push({
1123
+ type: "source",
1124
+ sourceType: "url",
1125
+ id: this.generateId(),
1126
+ url: result.url,
1127
+ title: result.title,
1128
+ providerMetadata: {
1129
+ anthropic: {
1130
+ pageAge: (_a = result.page_age) != null ? _a : null
1131
+ }
1132
+ }
1133
+ });
1134
+ }
1135
+ } else {
1136
+ content.push({
1137
+ type: "tool-result",
1138
+ toolCallId: part.tool_use_id,
1139
+ toolName: "web_search",
1140
+ isError: true,
1141
+ result: {
1142
+ type: "web_search_tool_result_error",
1143
+ errorCode: part.content.error_code
1144
+ },
1145
+ providerExecuted: true
1146
+ });
1147
+ }
1148
+ break;
1149
+ }
1150
+ }
1151
+ }
1152
+ return {
1153
+ content,
1154
+ finishReason: mapAnthropicStopReason({
1155
+ finishReason: response.stop_reason,
1156
+ isJsonResponseFromTool: usesJsonResponseTool
1157
+ }),
1158
+ usage: {
1159
+ inputTokens: response.usage.input_tokens,
1160
+ outputTokens: response.usage.output_tokens,
1161
+ totalTokens: response.usage.input_tokens + response.usage.output_tokens,
1162
+ cachedInputTokens: (_b = response.usage.cache_read_input_tokens) != null ? _b : void 0
1163
+ },
1164
+ request: { body: args },
1165
+ response: {
1166
+ id: (_c = response.id) != null ? _c : void 0,
1167
+ modelId: (_d = response.model) != null ? _d : void 0,
1168
+ headers: responseHeaders,
1169
+ body: rawResponse
1170
+ },
1171
+ warnings,
1172
+ providerMetadata: {
1173
+ anthropic: {
1174
+ usage: response.usage,
1175
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1176
+ }
1177
+ }
1178
+ };
1179
+ }
1180
+ async doStream(options) {
1181
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1182
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1183
+ const body = { ...args, stream: true };
1184
+ const { responseHeaders, value: response } = await postJsonToApi({
1185
+ url: this.buildRequestUrl(true),
1186
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1187
+ body: this.transformRequestBody(body),
1188
+ failedResponseHandler: anthropicFailedResponseHandler,
1189
+ successfulResponseHandler: createEventSourceResponseHandler(
1190
+ anthropicMessagesChunkSchema
1191
+ ),
1192
+ abortSignal: options.abortSignal,
1193
+ fetch: this.config.fetch
1194
+ });
1195
+ let finishReason = "unknown";
1196
+ const usage = {
1197
+ inputTokens: void 0,
1198
+ outputTokens: void 0,
1199
+ totalTokens: void 0
1200
+ };
1201
+ const contentBlocks = {};
1202
+ let providerMetadata = void 0;
1203
+ let blockType = void 0;
1204
+ const generateId3 = this.generateId;
1205
+ return {
1206
+ stream: response.pipeThrough(
1207
+ new TransformStream({
1208
+ start(controller) {
1209
+ controller.enqueue({ type: "stream-start", warnings });
1210
+ },
1211
+ transform(chunk, controller) {
1212
+ var _a, _b, _c, _d, _e, _f, _g;
1213
+ if (options.includeRawChunks) {
1214
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1215
+ }
1216
+ if (!chunk.success) {
1217
+ controller.enqueue({ type: "error", error: chunk.error });
1218
+ return;
1219
+ }
1220
+ const value = chunk.value;
1221
+ switch (value.type) {
1222
+ case "ping": {
1223
+ return;
1224
+ }
1225
+ case "content_block_start": {
1226
+ const contentBlockType = value.content_block.type;
1227
+ blockType = contentBlockType;
1228
+ switch (contentBlockType) {
1229
+ case "text": {
1230
+ contentBlocks[value.index] = { type: "text" };
1231
+ controller.enqueue({
1232
+ type: "text-start",
1233
+ id: String(value.index)
1234
+ });
1235
+ return;
1236
+ }
1237
+ case "thinking": {
1238
+ contentBlocks[value.index] = { type: "reasoning" };
1239
+ controller.enqueue({
1240
+ type: "reasoning-start",
1241
+ id: String(value.index)
1242
+ });
1243
+ return;
1244
+ }
1245
+ case "redacted_thinking": {
1246
+ contentBlocks[value.index] = { type: "reasoning" };
1247
+ controller.enqueue({
1248
+ type: "reasoning-start",
1249
+ id: String(value.index),
1250
+ providerMetadata: {
1251
+ anthropic: {
1252
+ redactedData: value.content_block.data
1253
+ }
1254
+ }
1255
+ });
1256
+ return;
1257
+ }
1258
+ case "tool_use": {
1259
+ contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
1260
+ type: "tool-call",
1261
+ toolCallId: value.content_block.id,
1262
+ toolName: value.content_block.name,
1263
+ input: ""
1264
+ };
1265
+ controller.enqueue(
1266
+ usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
1267
+ type: "tool-input-start",
1268
+ id: value.content_block.id,
1269
+ toolName: value.content_block.name
1270
+ }
1271
+ );
1272
+ return;
1273
+ }
1274
+ case "server_tool_use": {
1275
+ if (value.content_block.name === "web_search") {
1276
+ contentBlocks[value.index] = {
1277
+ type: "tool-call",
1278
+ toolCallId: value.content_block.id,
1279
+ toolName: value.content_block.name,
1280
+ input: "",
1281
+ providerExecuted: true
1282
+ };
1283
+ controller.enqueue({
1284
+ type: "tool-input-start",
1285
+ id: value.content_block.id,
1286
+ toolName: value.content_block.name,
1287
+ providerExecuted: true
1288
+ });
1289
+ }
1290
+ return;
1291
+ }
1292
+ case "web_search_tool_result": {
1293
+ const part = value.content_block;
1294
+ if (Array.isArray(part.content)) {
1295
+ controller.enqueue({
1296
+ type: "tool-result",
1297
+ toolCallId: part.tool_use_id,
1298
+ toolName: "web_search",
1299
+ result: part.content.map((result) => {
1300
+ var _a2;
1301
+ return {
1302
+ url: result.url,
1303
+ title: result.title,
1304
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1305
+ encryptedContent: result.encrypted_content,
1306
+ type: result.type
1307
+ };
1308
+ }),
1309
+ providerExecuted: true
1310
+ });
1311
+ for (const result of part.content) {
1312
+ controller.enqueue({
1313
+ type: "source",
1314
+ sourceType: "url",
1315
+ id: generateId3(),
1316
+ url: result.url,
1317
+ title: result.title,
1318
+ providerMetadata: {
1319
+ anthropic: {
1320
+ pageAge: (_a = result.page_age) != null ? _a : null
1321
+ }
1322
+ }
1323
+ });
1324
+ }
1325
+ } else {
1326
+ controller.enqueue({
1327
+ type: "tool-result",
1328
+ toolCallId: part.tool_use_id,
1329
+ toolName: "web_search",
1330
+ isError: true,
1331
+ result: {
1332
+ type: "web_search_tool_result_error",
1333
+ errorCode: part.content.error_code
1334
+ },
1335
+ providerExecuted: true
1336
+ });
1337
+ }
1338
+ return;
1339
+ }
1340
+ default: {
1341
+ const _exhaustiveCheck = contentBlockType;
1342
+ throw new Error(
1343
+ `Unsupported content block type: ${_exhaustiveCheck}`
1344
+ );
1345
+ }
1346
+ }
1347
+ }
1348
+ case "content_block_stop": {
1349
+ if (contentBlocks[value.index] != null) {
1350
+ const contentBlock = contentBlocks[value.index];
1351
+ switch (contentBlock.type) {
1352
+ case "text": {
1353
+ controller.enqueue({
1354
+ type: "text-end",
1355
+ id: String(value.index)
1356
+ });
1357
+ break;
1358
+ }
1359
+ case "reasoning": {
1360
+ controller.enqueue({
1361
+ type: "reasoning-end",
1362
+ id: String(value.index)
1363
+ });
1364
+ break;
1365
+ }
1366
+ case "tool-call":
1367
+ if (!usesJsonResponseTool) {
1368
+ controller.enqueue({
1369
+ type: "tool-input-end",
1370
+ id: contentBlock.toolCallId
1371
+ });
1372
+ controller.enqueue(contentBlock);
1373
+ }
1374
+ break;
1375
+ }
1376
+ delete contentBlocks[value.index];
1377
+ }
1378
+ blockType = void 0;
1379
+ return;
1380
+ }
1381
+ case "content_block_delta": {
1382
+ const deltaType = value.delta.type;
1383
+ switch (deltaType) {
1384
+ case "text_delta": {
1385
+ if (usesJsonResponseTool) {
1386
+ return;
1387
+ }
1388
+ controller.enqueue({
1389
+ type: "text-delta",
1390
+ id: String(value.index),
1391
+ delta: value.delta.text
1392
+ });
1393
+ return;
1394
+ }
1395
+ case "thinking_delta": {
1396
+ controller.enqueue({
1397
+ type: "reasoning-delta",
1398
+ id: String(value.index),
1399
+ delta: value.delta.thinking
1400
+ });
1401
+ return;
1402
+ }
1403
+ case "signature_delta": {
1404
+ if (blockType === "thinking") {
1405
+ controller.enqueue({
1406
+ type: "reasoning-delta",
1407
+ id: String(value.index),
1408
+ delta: "",
1409
+ providerMetadata: {
1410
+ anthropic: {
1411
+ signature: value.delta.signature
1412
+ }
1413
+ }
1414
+ });
1415
+ }
1416
+ return;
1417
+ }
1418
+ case "input_json_delta": {
1419
+ const contentBlock = contentBlocks[value.index];
1420
+ const delta = value.delta.partial_json;
1421
+ if (usesJsonResponseTool) {
1422
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
1423
+ return;
1424
+ }
1425
+ controller.enqueue({
1426
+ type: "text-delta",
1427
+ id: String(value.index),
1428
+ delta
1429
+ });
1430
+ } else {
1431
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
1432
+ return;
1433
+ }
1434
+ controller.enqueue({
1435
+ type: "tool-input-delta",
1436
+ id: contentBlock.toolCallId,
1437
+ delta
1438
+ });
1439
+ contentBlock.input += delta;
1440
+ }
1441
+ return;
1442
+ }
1443
+ case "citations_delta": {
1444
+ const citation = value.delta.citation;
1445
+ processCitation(
1446
+ citation,
1447
+ citationDocuments,
1448
+ generateId3,
1449
+ (source) => controller.enqueue(source)
1450
+ );
1451
+ return;
1452
+ }
1453
+ default: {
1454
+ const _exhaustiveCheck = deltaType;
1455
+ throw new Error(
1456
+ `Unsupported delta type: ${_exhaustiveCheck}`
1457
+ );
1458
+ }
1459
+ }
1460
+ }
1461
+ case "message_start": {
1462
+ usage.inputTokens = value.message.usage.input_tokens;
1463
+ usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
1464
+ providerMetadata = {
1465
+ anthropic: {
1466
+ usage: value.message.usage,
1467
+ cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
1468
+ }
1469
+ };
1470
+ controller.enqueue({
1471
+ type: "response-metadata",
1472
+ id: (_d = value.message.id) != null ? _d : void 0,
1473
+ modelId: (_e = value.message.model) != null ? _e : void 0
1474
+ });
1475
+ return;
1476
+ }
1477
+ case "message_delta": {
1478
+ usage.outputTokens = value.usage.output_tokens;
1479
+ usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
1480
+ finishReason = mapAnthropicStopReason({
1481
+ finishReason: value.delta.stop_reason,
1482
+ isJsonResponseFromTool: usesJsonResponseTool
1483
+ });
1484
+ return;
1485
+ }
1486
+ case "message_stop": {
1487
+ controller.enqueue({
1488
+ type: "finish",
1489
+ finishReason,
1490
+ usage,
1491
+ providerMetadata
1492
+ });
1493
+ return;
1494
+ }
1495
+ case "error": {
1496
+ controller.enqueue({ type: "error", error: value.error });
1497
+ return;
1498
+ }
1499
+ default: {
1500
+ const _exhaustiveCheck = value;
1501
+ throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
1502
+ }
1503
+ }
1504
+ }
1505
+ })
1506
+ ),
1507
+ request: { body },
1508
+ response: { headers: responseHeaders }
1509
+ };
1510
+ }
1511
+ };
1512
+ var anthropicMessagesResponseSchema = z4.object({
1513
+ type: z4.literal("message"),
1514
+ id: z4.string().nullish(),
1515
+ model: z4.string().nullish(),
1516
+ content: z4.array(
1517
+ z4.discriminatedUnion("type", [
1518
+ z4.object({
1519
+ type: z4.literal("text"),
1520
+ text: z4.string(),
1521
+ citations: z4.array(citationSchema).optional()
1522
+ }),
1523
+ z4.object({
1524
+ type: z4.literal("thinking"),
1525
+ thinking: z4.string(),
1526
+ signature: z4.string()
1527
+ }),
1528
+ z4.object({
1529
+ type: z4.literal("redacted_thinking"),
1530
+ data: z4.string()
1531
+ }),
1532
+ z4.object({
1533
+ type: z4.literal("tool_use"),
1534
+ id: z4.string(),
1535
+ name: z4.string(),
1536
+ input: z4.unknown()
1537
+ }),
1538
+ z4.object({
1539
+ type: z4.literal("server_tool_use"),
1540
+ id: z4.string(),
1541
+ name: z4.string(),
1542
+ input: z4.record(z4.string(), z4.unknown()).nullish()
1543
+ }),
1544
+ z4.object({
1545
+ type: z4.literal("web_search_tool_result"),
1546
+ tool_use_id: z4.string(),
1547
+ content: z4.union([
1548
+ z4.array(
1549
+ z4.object({
1550
+ type: z4.literal("web_search_result"),
1551
+ url: z4.string(),
1552
+ title: z4.string(),
1553
+ encrypted_content: z4.string(),
1554
+ page_age: z4.string().nullish()
1555
+ })
1556
+ ),
1557
+ z4.object({
1558
+ type: z4.literal("web_search_tool_result_error"),
1559
+ error_code: z4.string()
1560
+ })
1561
+ ])
1562
+ })
1563
+ ])
1564
+ ),
1565
+ stop_reason: z4.string().nullish(),
1566
+ usage: z4.looseObject({
1567
+ input_tokens: z4.number(),
1568
+ output_tokens: z4.number(),
1569
+ cache_creation_input_tokens: z4.number().nullish(),
1570
+ cache_read_input_tokens: z4.number().nullish()
1571
+ })
1572
+ });
1573
+ var anthropicMessagesChunkSchema = z4.discriminatedUnion("type", [
1574
+ z4.object({
1575
+ type: z4.literal("message_start"),
1576
+ message: z4.object({
1577
+ id: z4.string().nullish(),
1578
+ model: z4.string().nullish(),
1579
+ usage: z4.looseObject({
1580
+ input_tokens: z4.number(),
1581
+ output_tokens: z4.number(),
1582
+ cache_creation_input_tokens: z4.number().nullish(),
1583
+ cache_read_input_tokens: z4.number().nullish()
1584
+ })
1585
+ })
1586
+ }),
1587
+ z4.object({
1588
+ type: z4.literal("content_block_start"),
1589
+ index: z4.number(),
1590
+ content_block: z4.discriminatedUnion("type", [
1591
+ z4.object({
1592
+ type: z4.literal("text"),
1593
+ text: z4.string()
1594
+ }),
1595
+ z4.object({
1596
+ type: z4.literal("thinking"),
1597
+ thinking: z4.string()
1598
+ }),
1599
+ z4.object({
1600
+ type: z4.literal("tool_use"),
1601
+ id: z4.string(),
1602
+ name: z4.string()
1603
+ }),
1604
+ z4.object({
1605
+ type: z4.literal("redacted_thinking"),
1606
+ data: z4.string()
1607
+ }),
1608
+ z4.object({
1609
+ type: z4.literal("server_tool_use"),
1610
+ id: z4.string(),
1611
+ name: z4.string(),
1612
+ input: z4.record(z4.string(), z4.unknown()).nullish()
1613
+ }),
1614
+ z4.object({
1615
+ type: z4.literal("web_search_tool_result"),
1616
+ tool_use_id: z4.string(),
1617
+ content: z4.union([
1618
+ z4.array(
1619
+ z4.object({
1620
+ type: z4.literal("web_search_result"),
1621
+ url: z4.string(),
1622
+ title: z4.string(),
1623
+ encrypted_content: z4.string(),
1624
+ page_age: z4.string().nullish()
1625
+ })
1626
+ ),
1627
+ z4.object({
1628
+ type: z4.literal("web_search_tool_result_error"),
1629
+ error_code: z4.string()
1630
+ })
1631
+ ])
1632
+ })
1633
+ ])
1634
+ }),
1635
+ z4.object({
1636
+ type: z4.literal("content_block_delta"),
1637
+ index: z4.number(),
1638
+ delta: z4.discriminatedUnion("type", [
1639
+ z4.object({
1640
+ type: z4.literal("input_json_delta"),
1641
+ partial_json: z4.string()
1642
+ }),
1643
+ z4.object({
1644
+ type: z4.literal("text_delta"),
1645
+ text: z4.string()
1646
+ }),
1647
+ z4.object({
1648
+ type: z4.literal("thinking_delta"),
1649
+ thinking: z4.string()
1650
+ }),
1651
+ z4.object({
1652
+ type: z4.literal("signature_delta"),
1653
+ signature: z4.string()
1654
+ }),
1655
+ z4.object({
1656
+ type: z4.literal("citations_delta"),
1657
+ citation: citationSchema
1658
+ })
1659
+ ])
1660
+ }),
1661
+ z4.object({
1662
+ type: z4.literal("content_block_stop"),
1663
+ index: z4.number()
1664
+ }),
1665
+ z4.object({
1666
+ type: z4.literal("error"),
1667
+ error: z4.object({
1668
+ type: z4.string(),
1669
+ message: z4.string()
1670
+ })
1671
+ }),
1672
+ z4.object({
1673
+ type: z4.literal("message_delta"),
1674
+ delta: z4.object({ stop_reason: z4.string().nullish() }),
1675
+ usage: z4.object({ output_tokens: z4.number() })
1676
+ }),
1677
+ z4.object({
1678
+ type: z4.literal("message_stop")
1679
+ }),
1680
+ z4.object({
1681
+ type: z4.literal("ping")
1682
+ })
1683
+ ]);
1684
+ var anthropicReasoningMetadataSchema = z4.object({
1685
+ signature: z4.string().optional(),
1686
+ redactedData: z4.string().optional()
1687
+ });
1688
+
1689
+ // src/tool/bash_20241022.ts
1690
+ import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
1691
+ import z5 from "zod/v4";
1692
+ var bash_20241022 = createProviderDefinedToolFactory({
1693
+ id: "anthropic.bash_20241022",
1694
+ name: "bash",
1695
+ inputSchema: z5.object({
1696
+ command: z5.string(),
1697
+ restart: z5.boolean().optional()
1698
+ })
1699
+ });
1700
+
1701
+ // src/tool/bash_20250124.ts
1702
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
1703
+ import z6 from "zod/v4";
1704
+ var bash_20250124 = createProviderDefinedToolFactory2({
1705
+ id: "anthropic.bash_20250124",
1706
+ name: "bash",
1707
+ inputSchema: z6.object({
1708
+ command: z6.string(),
1709
+ restart: z6.boolean().optional()
1710
+ })
1711
+ });
1712
+
1713
+ // src/tool/computer_20241022.ts
1714
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
1715
+ import { z as z7 } from "zod/v4";
1716
+ var computer_20241022 = createProviderDefinedToolFactory3({
1717
+ id: "anthropic.computer_20241022",
1718
+ name: "computer",
1719
+ inputSchema: z7.object({
1720
+ action: z7.enum([
1721
+ "key",
1722
+ "type",
1723
+ "mouse_move",
1724
+ "left_click",
1725
+ "left_click_drag",
1726
+ "right_click",
1727
+ "middle_click",
1728
+ "double_click",
1729
+ "screenshot",
1730
+ "cursor_position"
1731
+ ]),
1732
+ coordinate: z7.array(z7.number().int()).optional(),
1733
+ text: z7.string().optional()
1734
+ })
1735
+ });
1736
+
1737
+ // src/tool/computer_20250124.ts
1738
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
1739
+ import { z as z8 } from "zod/v4";
1740
+ var computer_20250124 = createProviderDefinedToolFactory4({
1741
+ id: "anthropic.computer_20250124",
1742
+ name: "computer",
1743
+ inputSchema: z8.object({
1744
+ action: z8.enum([
1745
+ "key",
1746
+ "hold_key",
1747
+ "type",
1748
+ "cursor_position",
1749
+ "mouse_move",
1750
+ "left_mouse_down",
1751
+ "left_mouse_up",
1752
+ "left_click",
1753
+ "left_click_drag",
1754
+ "right_click",
1755
+ "middle_click",
1756
+ "double_click",
1757
+ "triple_click",
1758
+ "scroll",
1759
+ "wait",
1760
+ "screenshot"
1761
+ ]),
1762
+ coordinate: z8.tuple([z8.number().int(), z8.number().int()]).optional(),
1763
+ duration: z8.number().optional(),
1764
+ scroll_amount: z8.number().optional(),
1765
+ scroll_direction: z8.enum(["up", "down", "left", "right"]).optional(),
1766
+ start_coordinate: z8.tuple([z8.number().int(), z8.number().int()]).optional(),
1767
+ text: z8.string().optional()
1768
+ })
1769
+ });
1770
+
1771
+ // src/tool/text-editor_20241022.ts
1772
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
1773
+ import { z as z9 } from "zod/v4";
1774
+ var textEditor_20241022 = createProviderDefinedToolFactory5({
1775
+ id: "anthropic.text_editor_20241022",
1776
+ name: "str_replace_editor",
1777
+ inputSchema: z9.object({
1778
+ command: z9.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1779
+ path: z9.string(),
1780
+ file_text: z9.string().optional(),
1781
+ insert_line: z9.number().int().optional(),
1782
+ new_str: z9.string().optional(),
1783
+ old_str: z9.string().optional(),
1784
+ view_range: z9.array(z9.number().int()).optional()
1785
+ })
1786
+ });
1787
+
1788
+ // src/tool/text-editor_20250124.ts
1789
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
1790
+ import { z as z10 } from "zod/v4";
1791
+ var textEditor_20250124 = createProviderDefinedToolFactory6({
1792
+ id: "anthropic.text_editor_20250124",
1793
+ name: "str_replace_editor",
1794
+ inputSchema: z10.object({
1795
+ command: z10.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1796
+ path: z10.string(),
1797
+ file_text: z10.string().optional(),
1798
+ insert_line: z10.number().int().optional(),
1799
+ new_str: z10.string().optional(),
1800
+ old_str: z10.string().optional(),
1801
+ view_range: z10.array(z10.number().int()).optional()
1802
+ })
1803
+ });
1804
+
1805
+ // src/tool/text-editor_20250429.ts
1806
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
1807
+ import { z as z11 } from "zod/v4";
1808
+ var textEditor_20250429 = createProviderDefinedToolFactory7({
1809
+ id: "anthropic.text_editor_20250429",
1810
+ name: "str_replace_based_edit_tool",
1811
+ inputSchema: z11.object({
1812
+ command: z11.enum(["view", "create", "str_replace", "insert"]),
1813
+ path: z11.string(),
1814
+ file_text: z11.string().optional(),
1815
+ insert_line: z11.number().int().optional(),
1816
+ new_str: z11.string().optional(),
1817
+ old_str: z11.string().optional(),
1818
+ view_range: z11.array(z11.number().int()).optional()
1819
+ })
1820
+ });
1821
+
1822
+ // src/anthropic-tools.ts
1823
+ var anthropicTools = {
1824
+ /**
1825
+ * Creates a tool for running a bash command. Must have name "bash".
1826
+ *
1827
+ * Image results are supported.
1828
+ *
1829
+ * @param execute - The function to execute the tool. Optional.
1830
+ */
1831
+ bash_20241022,
1832
+ /**
1833
+ * Creates a tool for running a bash command. Must have name "bash".
1834
+ *
1835
+ * Image results are supported.
1836
+ *
1837
+ * @param execute - The function to execute the tool. Optional.
1838
+ */
1839
+ bash_20250124,
1840
+ /**
1841
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1842
+ */
1843
+ textEditor_20241022,
1844
+ /**
1845
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1846
+ */
1847
+ textEditor_20250124,
1848
+ /**
1849
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
1850
+ * Note: This version does not support the "undo_edit" command.
1851
+ */
1852
+ textEditor_20250429,
1853
+ /**
1854
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1855
+ *
1856
+ * Image results are supported.
1857
+ *
1858
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1859
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1860
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1861
+ */
1862
+ computer_20241022,
1863
+ /**
1864
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1865
+ *
1866
+ * Image results are supported.
1867
+ *
1868
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1869
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1870
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1871
+ * @param execute - The function to execute the tool. Optional.
1872
+ */
1873
+ computer_20250124,
1874
+ /**
1875
+ * Creates a web search tool that gives Claude direct access to real-time web content.
1876
+ * Must have name "web_search".
1877
+ *
1878
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
1879
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
1880
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
1881
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
1882
+ */
1883
+ webSearch_20250305
1884
+ };
1885
+
1886
+ // src/anthropic-provider.ts
1887
+ function createAnthropic(options = {}) {
1888
+ var _a;
1889
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
1890
+ const getHeaders = () => ({
1891
+ "anthropic-version": "2023-06-01",
1892
+ "x-api-key": loadApiKey({
1893
+ apiKey: options.apiKey,
1894
+ environmentVariableName: "ANTHROPIC_API_KEY",
1895
+ description: "Anthropic"
1896
+ }),
1897
+ ...options.headers
1898
+ });
1899
+ const createChatModel = (modelId) => {
1900
+ var _a2;
1901
+ return new AnthropicMessagesLanguageModel(modelId, {
1902
+ provider: "anthropic.messages",
1903
+ baseURL,
1904
+ headers: getHeaders,
1905
+ fetch: options.fetch,
1906
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
1907
+ supportedUrls: () => ({
1908
+ "image/*": [/^https?:\/\/.*$/]
1909
+ })
1910
+ });
1911
+ };
1912
+ const provider = function(modelId) {
1913
+ if (new.target) {
1914
+ throw new Error(
1915
+ "The Anthropic model function cannot be called with the new keyword."
1916
+ );
1917
+ }
1918
+ return createChatModel(modelId);
1919
+ };
1920
+ provider.languageModel = createChatModel;
1921
+ provider.chat = createChatModel;
1922
+ provider.messages = createChatModel;
1923
+ provider.textEmbeddingModel = (modelId) => {
1924
+ throw new NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
1925
+ };
1926
+ provider.imageModel = (modelId) => {
1927
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
1928
+ };
1929
+ provider.tools = anthropicTools;
1930
+ return provider;
1931
+ }
1932
+ var anthropic = createAnthropic();
1933
+ export {
1934
+ anthropic,
1935
+ createAnthropic
1936
+ };
1937
+ //# sourceMappingURL=index.mjs.map
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.d.mts ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { LanguageModelV2, JSONSchema7, LanguageModelV2CallOptions, LanguageModelV2CallWarning } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
+
5
+ type AnthropicMessagesModelId = 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
6
+
7
+ type AnthropicMessagesConfig = {
8
+ provider: string;
9
+ baseURL: string;
10
+ headers: Resolvable<Record<string, string | undefined>>;
11
+ fetch?: FetchFunction;
12
+ buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
+ transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
14
+ supportedUrls?: () => LanguageModelV2['supportedUrls'];
15
+ generateId?: () => string;
16
+ };
17
+ declare class AnthropicMessagesLanguageModel implements LanguageModelV2 {
18
+ readonly specificationVersion = "v2";
19
+ readonly modelId: AnthropicMessagesModelId;
20
+ private readonly config;
21
+ private readonly generateId;
22
+ constructor(modelId: AnthropicMessagesModelId, config: AnthropicMessagesConfig);
23
+ supportsUrl(url: URL): boolean;
24
+ get provider(): string;
25
+ get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
26
+ private getArgs;
27
+ private getHeaders;
28
+ private buildRequestUrl;
29
+ private transformRequestBody;
30
+ private extractCitationDocuments;
31
+ doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
32
+ doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
33
+ }
34
+
35
+ declare const anthropicTools: {
36
+ /**
37
+ * Creates a tool for running a bash command. Must have name "bash".
38
+ *
39
+ * Image results are supported.
40
+ *
41
+ * @param execute - The function to execute the tool. Optional.
42
+ */
43
+ bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
44
+ command: string;
45
+ restart?: boolean;
46
+ }, {}>;
47
+ /**
48
+ * Creates a tool for running a bash command. Must have name "bash".
49
+ *
50
+ * Image results are supported.
51
+ *
52
+ * @param execute - The function to execute the tool. Optional.
53
+ */
54
+ bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
55
+ command: string;
56
+ restart?: boolean;
57
+ }, {}>;
58
+ /**
59
+ * Creates a tool for editing text. Must have name "str_replace_editor".
60
+ */
61
+ textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
62
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
63
+ path: string;
64
+ file_text?: string;
65
+ insert_line?: number;
66
+ new_str?: string;
67
+ old_str?: string;
68
+ view_range?: number[];
69
+ }, {}>;
70
+ /**
71
+ * Creates a tool for editing text. Must have name "str_replace_editor".
72
+ */
73
+ textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
74
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
75
+ path: string;
76
+ file_text?: string;
77
+ insert_line?: number;
78
+ new_str?: string;
79
+ old_str?: string;
80
+ view_range?: number[];
81
+ }, {}>;
82
+ /**
83
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
84
+ * Note: This version does not support the "undo_edit" command.
85
+ */
86
+ textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
87
+ command: "view" | "create" | "str_replace" | "insert";
88
+ path: string;
89
+ file_text?: string;
90
+ insert_line?: number;
91
+ new_str?: string;
92
+ old_str?: string;
93
+ view_range?: number[];
94
+ }, {}>;
95
+ /**
96
+ * Creates a tool for executing actions on a computer. Must have name "computer".
97
+ *
98
+ * Image results are supported.
99
+ *
100
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
101
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
102
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
103
+ */
104
+ computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
105
+ action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
106
+ coordinate?: number[];
107
+ text?: string;
108
+ }, {
109
+ displayWidthPx: number;
110
+ displayHeightPx: number;
111
+ displayNumber?: number;
112
+ }>;
113
+ /**
114
+ * Creates a tool for executing actions on a computer. Must have name "computer".
115
+ *
116
+ * Image results are supported.
117
+ *
118
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
119
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
120
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
121
+ * @param execute - The function to execute the tool. Optional.
122
+ */
123
+ computer_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
124
+ action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
125
+ coordinate?: [number, number];
126
+ duration?: number;
127
+ scroll_amount?: number;
128
+ scroll_direction?: "up" | "down" | "left" | "right";
129
+ start_coordinate?: [number, number];
130
+ text?: string;
131
+ }, {
132
+ displayWidthPx: number;
133
+ displayHeightPx: number;
134
+ displayNumber?: number;
135
+ }>;
136
+ /**
137
+ * Creates a web search tool that gives Claude direct access to real-time web content.
138
+ * Must have name "web_search".
139
+ *
140
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
141
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
142
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
143
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
144
+ */
145
+ webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
146
+ query: string;
147
+ }, {
148
+ url: string;
149
+ title: string;
150
+ pageAge: string | null;
151
+ encryptedContent: string;
152
+ type: string;
153
+ }[], {
154
+ maxUses?: number;
155
+ allowedDomains?: string[];
156
+ blockedDomains?: string[];
157
+ userLocation?: {
158
+ type: "approximate";
159
+ city?: string;
160
+ region?: string;
161
+ country?: string;
162
+ timezone?: string;
163
+ };
164
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
165
+ query: string;
166
+ }, {
167
+ url: string;
168
+ title: string;
169
+ pageAge: string | null;
170
+ encryptedContent: string;
171
+ type: string;
172
+ }[]>;
173
+ };
174
+
175
+ type AnthropicCacheControl = {
176
+ type: 'ephemeral';
177
+ };
178
+ type AnthropicTool = {
179
+ name: string;
180
+ description: string | undefined;
181
+ input_schema: JSONSchema7;
182
+ cache_control: AnthropicCacheControl | undefined;
183
+ } | {
184
+ name: string;
185
+ type: 'computer_20250124' | 'computer_20241022';
186
+ display_width_px: number;
187
+ display_height_px: number;
188
+ display_number: number;
189
+ } | {
190
+ name: string;
191
+ type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
192
+ } | {
193
+ name: string;
194
+ type: 'bash_20250124' | 'bash_20241022';
195
+ } | {
196
+ type: 'web_search_20250305';
197
+ name: string;
198
+ max_uses?: number;
199
+ allowed_domains?: string[];
200
+ blocked_domains?: string[];
201
+ user_location?: {
202
+ type: 'approximate';
203
+ city?: string;
204
+ region?: string;
205
+ country?: string;
206
+ timezone?: string;
207
+ };
208
+ };
209
+ type AnthropicToolChoice = {
210
+ type: 'auto' | 'any';
211
+ disable_parallel_tool_use?: boolean;
212
+ } | {
213
+ type: 'tool';
214
+ name: string;
215
+ disable_parallel_tool_use?: boolean;
216
+ };
217
+
218
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, }: {
219
+ tools: LanguageModelV2CallOptions['tools'];
220
+ toolChoice?: LanguageModelV2CallOptions['toolChoice'];
221
+ disableParallelToolUse?: boolean;
222
+ }): {
223
+ tools: Array<AnthropicTool> | undefined;
224
+ toolChoice: AnthropicToolChoice | undefined;
225
+ toolWarnings: LanguageModelV2CallWarning[];
226
+ betas: Set<string>;
227
+ };
228
+
229
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.d.ts ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { LanguageModelV2, JSONSchema7, LanguageModelV2CallOptions, LanguageModelV2CallWarning } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
+
5
+ type AnthropicMessagesModelId = 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
6
+
7
+ type AnthropicMessagesConfig = {
8
+ provider: string;
9
+ baseURL: string;
10
+ headers: Resolvable<Record<string, string | undefined>>;
11
+ fetch?: FetchFunction;
12
+ buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
+ transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
14
+ supportedUrls?: () => LanguageModelV2['supportedUrls'];
15
+ generateId?: () => string;
16
+ };
17
+ declare class AnthropicMessagesLanguageModel implements LanguageModelV2 {
18
+ readonly specificationVersion = "v2";
19
+ readonly modelId: AnthropicMessagesModelId;
20
+ private readonly config;
21
+ private readonly generateId;
22
+ constructor(modelId: AnthropicMessagesModelId, config: AnthropicMessagesConfig);
23
+ supportsUrl(url: URL): boolean;
24
+ get provider(): string;
25
+ get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
26
+ private getArgs;
27
+ private getHeaders;
28
+ private buildRequestUrl;
29
+ private transformRequestBody;
30
+ private extractCitationDocuments;
31
+ doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
32
+ doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
33
+ }
34
+
35
+ declare const anthropicTools: {
36
+ /**
37
+ * Creates a tool for running a bash command. Must have name "bash".
38
+ *
39
+ * Image results are supported.
40
+ *
41
+ * @param execute - The function to execute the tool. Optional.
42
+ */
43
+ bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
44
+ command: string;
45
+ restart?: boolean;
46
+ }, {}>;
47
+ /**
48
+ * Creates a tool for running a bash command. Must have name "bash".
49
+ *
50
+ * Image results are supported.
51
+ *
52
+ * @param execute - The function to execute the tool. Optional.
53
+ */
54
+ bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
55
+ command: string;
56
+ restart?: boolean;
57
+ }, {}>;
58
+ /**
59
+ * Creates a tool for editing text. Must have name "str_replace_editor".
60
+ */
61
+ textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
62
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
63
+ path: string;
64
+ file_text?: string;
65
+ insert_line?: number;
66
+ new_str?: string;
67
+ old_str?: string;
68
+ view_range?: number[];
69
+ }, {}>;
70
+ /**
71
+ * Creates a tool for editing text. Must have name "str_replace_editor".
72
+ */
73
+ textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
74
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
75
+ path: string;
76
+ file_text?: string;
77
+ insert_line?: number;
78
+ new_str?: string;
79
+ old_str?: string;
80
+ view_range?: number[];
81
+ }, {}>;
82
+ /**
83
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
84
+ * Note: This version does not support the "undo_edit" command.
85
+ */
86
+ textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
87
+ command: "view" | "create" | "str_replace" | "insert";
88
+ path: string;
89
+ file_text?: string;
90
+ insert_line?: number;
91
+ new_str?: string;
92
+ old_str?: string;
93
+ view_range?: number[];
94
+ }, {}>;
95
+ /**
96
+ * Creates a tool for executing actions on a computer. Must have name "computer".
97
+ *
98
+ * Image results are supported.
99
+ *
100
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
101
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
102
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
103
+ */
104
+ computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
105
+ action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
106
+ coordinate?: number[];
107
+ text?: string;
108
+ }, {
109
+ displayWidthPx: number;
110
+ displayHeightPx: number;
111
+ displayNumber?: number;
112
+ }>;
113
+ /**
114
+ * Creates a tool for executing actions on a computer. Must have name "computer".
115
+ *
116
+ * Image results are supported.
117
+ *
118
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
119
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
120
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
121
+ * @param execute - The function to execute the tool. Optional.
122
+ */
123
+ computer_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
124
+ action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
125
+ coordinate?: [number, number];
126
+ duration?: number;
127
+ scroll_amount?: number;
128
+ scroll_direction?: "up" | "down" | "left" | "right";
129
+ start_coordinate?: [number, number];
130
+ text?: string;
131
+ }, {
132
+ displayWidthPx: number;
133
+ displayHeightPx: number;
134
+ displayNumber?: number;
135
+ }>;
136
+ /**
137
+ * Creates a web search tool that gives Claude direct access to real-time web content.
138
+ * Must have name "web_search".
139
+ *
140
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
141
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
142
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
143
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
144
+ */
145
+ webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
146
+ query: string;
147
+ }, {
148
+ url: string;
149
+ title: string;
150
+ pageAge: string | null;
151
+ encryptedContent: string;
152
+ type: string;
153
+ }[], {
154
+ maxUses?: number;
155
+ allowedDomains?: string[];
156
+ blockedDomains?: string[];
157
+ userLocation?: {
158
+ type: "approximate";
159
+ city?: string;
160
+ region?: string;
161
+ country?: string;
162
+ timezone?: string;
163
+ };
164
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
165
+ query: string;
166
+ }, {
167
+ url: string;
168
+ title: string;
169
+ pageAge: string | null;
170
+ encryptedContent: string;
171
+ type: string;
172
+ }[]>;
173
+ };
174
+
175
+ type AnthropicCacheControl = {
176
+ type: 'ephemeral';
177
+ };
178
+ type AnthropicTool = {
179
+ name: string;
180
+ description: string | undefined;
181
+ input_schema: JSONSchema7;
182
+ cache_control: AnthropicCacheControl | undefined;
183
+ } | {
184
+ name: string;
185
+ type: 'computer_20250124' | 'computer_20241022';
186
+ display_width_px: number;
187
+ display_height_px: number;
188
+ display_number: number;
189
+ } | {
190
+ name: string;
191
+ type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
192
+ } | {
193
+ name: string;
194
+ type: 'bash_20250124' | 'bash_20241022';
195
+ } | {
196
+ type: 'web_search_20250305';
197
+ name: string;
198
+ max_uses?: number;
199
+ allowed_domains?: string[];
200
+ blocked_domains?: string[];
201
+ user_location?: {
202
+ type: 'approximate';
203
+ city?: string;
204
+ region?: string;
205
+ country?: string;
206
+ timezone?: string;
207
+ };
208
+ };
209
+ type AnthropicToolChoice = {
210
+ type: 'auto' | 'any';
211
+ disable_parallel_tool_use?: boolean;
212
+ } | {
213
+ type: 'tool';
214
+ name: string;
215
+ disable_parallel_tool_use?: boolean;
216
+ };
217
+
218
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, }: {
219
+ tools: LanguageModelV2CallOptions['tools'];
220
+ toolChoice?: LanguageModelV2CallOptions['toolChoice'];
221
+ disableParallelToolUse?: boolean;
222
+ }): {
223
+ tools: Array<AnthropicTool> | undefined;
224
+ toolChoice: AnthropicToolChoice | undefined;
225
+ toolWarnings: LanguageModelV2CallWarning[];
226
+ betas: Set<string>;
227
+ };
228
+
229
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.js ADDED
@@ -0,0 +1,1905 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/internal/index.ts
31
+ var internal_exports = {};
32
+ __export(internal_exports, {
33
+ AnthropicMessagesLanguageModel: () => AnthropicMessagesLanguageModel,
34
+ anthropicTools: () => anthropicTools,
35
+ prepareTools: () => prepareTools
36
+ });
37
+ module.exports = __toCommonJS(internal_exports);
38
+
39
+ // src/anthropic-messages-language-model.ts
40
+ var import_provider3 = require("@ai-sdk/provider");
41
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
42
+ var import_v44 = require("zod/v4");
43
+
44
+ // src/anthropic-error.ts
45
+ var import_provider_utils = require("@ai-sdk/provider-utils");
46
+ var import_v4 = require("zod/v4");
47
+ var anthropicErrorDataSchema = import_v4.z.object({
48
+ type: import_v4.z.literal("error"),
49
+ error: import_v4.z.object({
50
+ type: import_v4.z.string(),
51
+ message: import_v4.z.string()
52
+ })
53
+ });
54
+ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
55
+ errorSchema: anthropicErrorDataSchema,
56
+ errorToMessage: (data) => data.error.message
57
+ });
58
+
59
+ // src/anthropic-messages-options.ts
60
+ var import_v42 = require("zod/v4");
61
+ var anthropicFilePartProviderOptions = import_v42.z.object({
62
+ /**
63
+ * Citation configuration for this document.
64
+ * When enabled, this document will generate citations in the response.
65
+ */
66
+ citations: import_v42.z.object({
67
+ /**
68
+ * Enable citations for this document
69
+ */
70
+ enabled: import_v42.z.boolean()
71
+ }).optional(),
72
+ /**
73
+ * Custom title for the document.
74
+ * If not provided, the filename will be used.
75
+ */
76
+ title: import_v42.z.string().optional(),
77
+ /**
78
+ * Context about the document that will be passed to the model
79
+ * but not used towards cited content.
80
+ * Useful for storing document metadata as text or stringified JSON.
81
+ */
82
+ context: import_v42.z.string().optional()
83
+ });
84
+ var anthropicProviderOptions = import_v42.z.object({
85
+ sendReasoning: import_v42.z.boolean().optional(),
86
+ thinking: import_v42.z.object({
87
+ type: import_v42.z.union([import_v42.z.literal("enabled"), import_v42.z.literal("disabled")]),
88
+ budgetTokens: import_v42.z.number().optional()
89
+ }).optional(),
90
+ /**
91
+ * Whether to disable parallel function calling during tool use. Default is false.
92
+ * When set to true, Claude will use at most one tool per response.
93
+ */
94
+ disableParallelToolUse: import_v42.z.boolean().optional()
95
+ });
96
+
97
+ // src/anthropic-prepare-tools.ts
98
+ var import_provider = require("@ai-sdk/provider");
99
+
100
+ // src/get-cache-control.ts
101
+ function getCacheControl(providerMetadata) {
102
+ var _a;
103
+ const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
104
+ const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
105
+ return cacheControlValue;
106
+ }
107
+
108
+ // src/tool/web-search_20250305.ts
109
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
110
+ var import_v43 = require("zod/v4");
111
+ var webSearch_20250305ArgsSchema = import_v43.z.object({
112
+ /**
113
+ * Maximum number of web searches Claude can perform during the conversation.
114
+ */
115
+ maxUses: import_v43.z.number().optional(),
116
+ /**
117
+ * Optional list of domains that Claude is allowed to search.
118
+ */
119
+ allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
120
+ /**
121
+ * Optional list of domains that Claude should avoid when searching.
122
+ */
123
+ blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
124
+ /**
125
+ * Optional user location information to provide geographically relevant search results.
126
+ */
127
+ userLocation: import_v43.z.object({
128
+ type: import_v43.z.literal("approximate"),
129
+ city: import_v43.z.string().optional(),
130
+ region: import_v43.z.string().optional(),
131
+ country: import_v43.z.string().optional(),
132
+ timezone: import_v43.z.string().optional()
133
+ }).optional()
134
+ });
135
+ var webSearch_20250305OutputSchema = import_v43.z.array(
136
+ import_v43.z.object({
137
+ url: import_v43.z.string(),
138
+ title: import_v43.z.string(),
139
+ pageAge: import_v43.z.string().nullable(),
140
+ encryptedContent: import_v43.z.string(),
141
+ type: import_v43.z.string()
142
+ })
143
+ );
144
+ var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
145
+ id: "anthropic.web_search_20250305",
146
+ name: "web_search",
147
+ inputSchema: import_v43.z.object({
148
+ query: import_v43.z.string()
149
+ }),
150
+ outputSchema: webSearch_20250305OutputSchema
151
+ });
152
+ var webSearch_20250305 = (args = {}) => {
153
+ return factory(args);
154
+ };
155
+
156
+ // src/anthropic-prepare-tools.ts
157
+ function isWebSearchTool(tool) {
158
+ return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
159
+ }
160
+ function prepareTools({
161
+ tools,
162
+ toolChoice,
163
+ disableParallelToolUse
164
+ }) {
165
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
166
+ const toolWarnings = [];
167
+ const betas = /* @__PURE__ */ new Set();
168
+ if (tools == null) {
169
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
170
+ }
171
+ const anthropicTools2 = [];
172
+ for (const tool of tools) {
173
+ if (isWebSearchTool(tool)) {
174
+ anthropicTools2.push(tool);
175
+ continue;
176
+ }
177
+ switch (tool.type) {
178
+ case "function":
179
+ const cacheControl = getCacheControl(tool.providerOptions);
180
+ anthropicTools2.push({
181
+ name: tool.name,
182
+ description: tool.description,
183
+ input_schema: tool.inputSchema,
184
+ cache_control: cacheControl
185
+ });
186
+ break;
187
+ case "provider-defined":
188
+ switch (tool.id) {
189
+ case "anthropic.computer_20250124":
190
+ betas.add("computer-use-2025-01-24");
191
+ anthropicTools2.push({
192
+ name: "computer",
193
+ type: "computer_20250124",
194
+ display_width_px: tool.args.displayWidthPx,
195
+ display_height_px: tool.args.displayHeightPx,
196
+ display_number: tool.args.displayNumber
197
+ });
198
+ break;
199
+ case "anthropic.computer_20241022":
200
+ betas.add("computer-use-2024-10-22");
201
+ anthropicTools2.push({
202
+ name: "computer",
203
+ type: "computer_20241022",
204
+ display_width_px: tool.args.displayWidthPx,
205
+ display_height_px: tool.args.displayHeightPx,
206
+ display_number: tool.args.displayNumber
207
+ });
208
+ break;
209
+ case "anthropic.text_editor_20250124":
210
+ betas.add("computer-use-2025-01-24");
211
+ anthropicTools2.push({
212
+ name: "str_replace_editor",
213
+ type: "text_editor_20250124"
214
+ });
215
+ break;
216
+ case "anthropic.text_editor_20241022":
217
+ betas.add("computer-use-2024-10-22");
218
+ anthropicTools2.push({
219
+ name: "str_replace_editor",
220
+ type: "text_editor_20241022"
221
+ });
222
+ break;
223
+ case "anthropic.text_editor_20250429":
224
+ betas.add("computer-use-2025-01-24");
225
+ anthropicTools2.push({
226
+ name: "str_replace_based_edit_tool",
227
+ type: "text_editor_20250429"
228
+ });
229
+ break;
230
+ case "anthropic.bash_20250124":
231
+ betas.add("computer-use-2025-01-24");
232
+ anthropicTools2.push({
233
+ name: "bash",
234
+ type: "bash_20250124"
235
+ });
236
+ break;
237
+ case "anthropic.bash_20241022":
238
+ betas.add("computer-use-2024-10-22");
239
+ anthropicTools2.push({
240
+ name: "bash",
241
+ type: "bash_20241022"
242
+ });
243
+ break;
244
+ case "anthropic.web_search_20250305": {
245
+ const args = webSearch_20250305ArgsSchema.parse(tool.args);
246
+ anthropicTools2.push({
247
+ type: "web_search_20250305",
248
+ name: "web_search",
249
+ max_uses: args.maxUses,
250
+ allowed_domains: args.allowedDomains,
251
+ blocked_domains: args.blockedDomains,
252
+ user_location: args.userLocation
253
+ });
254
+ break;
255
+ }
256
+ default:
257
+ toolWarnings.push({ type: "unsupported-tool", tool });
258
+ break;
259
+ }
260
+ break;
261
+ default:
262
+ toolWarnings.push({ type: "unsupported-tool", tool });
263
+ break;
264
+ }
265
+ }
266
+ if (toolChoice == null) {
267
+ return {
268
+ tools: anthropicTools2,
269
+ toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
270
+ toolWarnings,
271
+ betas
272
+ };
273
+ }
274
+ const type = toolChoice.type;
275
+ switch (type) {
276
+ case "auto":
277
+ return {
278
+ tools: anthropicTools2,
279
+ toolChoice: {
280
+ type: "auto",
281
+ disable_parallel_tool_use: disableParallelToolUse
282
+ },
283
+ toolWarnings,
284
+ betas
285
+ };
286
+ case "required":
287
+ return {
288
+ tools: anthropicTools2,
289
+ toolChoice: {
290
+ type: "any",
291
+ disable_parallel_tool_use: disableParallelToolUse
292
+ },
293
+ toolWarnings,
294
+ betas
295
+ };
296
+ case "none":
297
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
298
+ case "tool":
299
+ return {
300
+ tools: anthropicTools2,
301
+ toolChoice: {
302
+ type: "tool",
303
+ name: toolChoice.toolName,
304
+ disable_parallel_tool_use: disableParallelToolUse
305
+ },
306
+ toolWarnings,
307
+ betas
308
+ };
309
+ default: {
310
+ const _exhaustiveCheck = type;
311
+ throw new import_provider.UnsupportedFunctionalityError({
312
+ functionality: `tool choice type: ${_exhaustiveCheck}`
313
+ });
314
+ }
315
+ }
316
+ }
317
+
318
+ // src/convert-to-anthropic-messages-prompt.ts
319
+ var import_provider2 = require("@ai-sdk/provider");
320
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
321
+ function convertToString(data) {
322
+ if (typeof data === "string") {
323
+ return Buffer.from(data, "base64").toString("utf-8");
324
+ }
325
+ if (data instanceof Uint8Array) {
326
+ return new TextDecoder().decode(data);
327
+ }
328
+ if (data instanceof URL) {
329
+ throw new import_provider2.UnsupportedFunctionalityError({
330
+ functionality: "URL-based text documents are not supported for citations"
331
+ });
332
+ }
333
+ throw new import_provider2.UnsupportedFunctionalityError({
334
+ functionality: `unsupported data type for text documents: ${typeof data}`
335
+ });
336
+ }
337
+ async function convertToAnthropicMessagesPrompt({
338
+ prompt,
339
+ sendReasoning,
340
+ warnings
341
+ }) {
342
+ var _a, _b, _c, _d, _e;
343
+ const betas = /* @__PURE__ */ new Set();
344
+ const blocks = groupIntoBlocks(prompt);
345
+ let system = void 0;
346
+ const messages = [];
347
+ async function shouldEnableCitations(providerMetadata) {
348
+ var _a2, _b2;
349
+ const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
350
+ provider: "anthropic",
351
+ providerOptions: providerMetadata,
352
+ schema: anthropicFilePartProviderOptions
353
+ });
354
+ return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
355
+ }
356
+ async function getDocumentMetadata(providerMetadata) {
357
+ const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
358
+ provider: "anthropic",
359
+ providerOptions: providerMetadata,
360
+ schema: anthropicFilePartProviderOptions
361
+ });
362
+ return {
363
+ title: anthropicOptions == null ? void 0 : anthropicOptions.title,
364
+ context: anthropicOptions == null ? void 0 : anthropicOptions.context
365
+ };
366
+ }
367
+ for (let i = 0; i < blocks.length; i++) {
368
+ const block = blocks[i];
369
+ const isLastBlock = i === blocks.length - 1;
370
+ const type = block.type;
371
+ switch (type) {
372
+ case "system": {
373
+ if (system != null) {
374
+ throw new import_provider2.UnsupportedFunctionalityError({
375
+ functionality: "Multiple system messages that are separated by user/assistant messages"
376
+ });
377
+ }
378
+ system = block.messages.map(({ content, providerOptions }) => ({
379
+ type: "text",
380
+ text: content,
381
+ cache_control: getCacheControl(providerOptions)
382
+ }));
383
+ break;
384
+ }
385
+ case "user": {
386
+ const anthropicContent = [];
387
+ for (const message of block.messages) {
388
+ const { role, content } = message;
389
+ switch (role) {
390
+ case "user": {
391
+ for (let j = 0; j < content.length; j++) {
392
+ const part = content[j];
393
+ const isLastPart = j === content.length - 1;
394
+ const cacheControl = (_a = getCacheControl(part.providerOptions)) != null ? _a : isLastPart ? getCacheControl(message.providerOptions) : void 0;
395
+ switch (part.type) {
396
+ case "text": {
397
+ anthropicContent.push({
398
+ type: "text",
399
+ text: part.text,
400
+ cache_control: cacheControl
401
+ });
402
+ break;
403
+ }
404
+ case "file": {
405
+ if (part.mediaType.startsWith("image/")) {
406
+ anthropicContent.push({
407
+ type: "image",
408
+ source: part.data instanceof URL ? {
409
+ type: "url",
410
+ url: part.data.toString()
411
+ } : {
412
+ type: "base64",
413
+ media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
414
+ data: (0, import_provider_utils3.convertToBase64)(part.data)
415
+ },
416
+ cache_control: cacheControl
417
+ });
418
+ } else if (part.mediaType === "application/pdf") {
419
+ betas.add("pdfs-2024-09-25");
420
+ const enableCitations = await shouldEnableCitations(
421
+ part.providerOptions
422
+ );
423
+ const metadata = await getDocumentMetadata(
424
+ part.providerOptions
425
+ );
426
+ anthropicContent.push({
427
+ type: "document",
428
+ source: part.data instanceof URL ? {
429
+ type: "url",
430
+ url: part.data.toString()
431
+ } : {
432
+ type: "base64",
433
+ media_type: "application/pdf",
434
+ data: (0, import_provider_utils3.convertToBase64)(part.data)
435
+ },
436
+ title: (_b = metadata.title) != null ? _b : part.filename,
437
+ ...metadata.context && { context: metadata.context },
438
+ ...enableCitations && {
439
+ citations: { enabled: true }
440
+ },
441
+ cache_control: cacheControl
442
+ });
443
+ } else if (part.mediaType === "text/plain") {
444
+ const enableCitations = await shouldEnableCitations(
445
+ part.providerOptions
446
+ );
447
+ const metadata = await getDocumentMetadata(
448
+ part.providerOptions
449
+ );
450
+ anthropicContent.push({
451
+ type: "document",
452
+ source: part.data instanceof URL ? {
453
+ type: "url",
454
+ url: part.data.toString()
455
+ } : {
456
+ type: "text",
457
+ media_type: "text/plain",
458
+ data: convertToString(part.data)
459
+ },
460
+ title: (_c = metadata.title) != null ? _c : part.filename,
461
+ ...metadata.context && { context: metadata.context },
462
+ ...enableCitations && {
463
+ citations: { enabled: true }
464
+ },
465
+ cache_control: cacheControl
466
+ });
467
+ } else {
468
+ throw new import_provider2.UnsupportedFunctionalityError({
469
+ functionality: `media type: ${part.mediaType}`
470
+ });
471
+ }
472
+ break;
473
+ }
474
+ }
475
+ }
476
+ break;
477
+ }
478
+ case "tool": {
479
+ for (let i2 = 0; i2 < content.length; i2++) {
480
+ const part = content[i2];
481
+ const isLastPart = i2 === content.length - 1;
482
+ const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
483
+ const output = part.output;
484
+ let contentValue;
485
+ switch (output.type) {
486
+ case "content":
487
+ contentValue = output.value.map((contentPart) => {
488
+ switch (contentPart.type) {
489
+ case "text":
490
+ return {
491
+ type: "text",
492
+ text: contentPart.text,
493
+ cache_control: void 0
494
+ };
495
+ case "media": {
496
+ if (contentPart.mediaType.startsWith("image/")) {
497
+ return {
498
+ type: "image",
499
+ source: {
500
+ type: "base64",
501
+ media_type: contentPart.mediaType,
502
+ data: contentPart.data
503
+ },
504
+ cache_control: void 0
505
+ };
506
+ }
507
+ throw new import_provider2.UnsupportedFunctionalityError({
508
+ functionality: `media type: ${contentPart.mediaType}`
509
+ });
510
+ }
511
+ }
512
+ });
513
+ break;
514
+ case "text":
515
+ case "error-text":
516
+ contentValue = output.value;
517
+ break;
518
+ case "json":
519
+ case "error-json":
520
+ default:
521
+ contentValue = JSON.stringify(output.value);
522
+ break;
523
+ }
524
+ anthropicContent.push({
525
+ type: "tool_result",
526
+ tool_use_id: part.toolCallId,
527
+ content: contentValue,
528
+ is_error: output.type === "error-text" || output.type === "error-json" ? true : void 0,
529
+ cache_control: cacheControl
530
+ });
531
+ }
532
+ break;
533
+ }
534
+ default: {
535
+ const _exhaustiveCheck = role;
536
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
537
+ }
538
+ }
539
+ }
540
+ messages.push({ role: "user", content: anthropicContent });
541
+ break;
542
+ }
543
+ case "assistant": {
544
+ const anthropicContent = [];
545
+ for (let j = 0; j < block.messages.length; j++) {
546
+ const message = block.messages[j];
547
+ const isLastMessage = j === block.messages.length - 1;
548
+ const { content } = message;
549
+ for (let k = 0; k < content.length; k++) {
550
+ const part = content[k];
551
+ const isLastContentPart = k === content.length - 1;
552
+ const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
553
+ switch (part.type) {
554
+ case "text": {
555
+ anthropicContent.push({
556
+ type: "text",
557
+ text: (
558
+ // trim the last text part if it's the last message in the block
559
+ // because Anthropic does not allow trailing whitespace
560
+ // in pre-filled assistant responses
561
+ isLastBlock && isLastMessage && isLastContentPart ? part.text.trim() : part.text
562
+ ),
563
+ cache_control: cacheControl
564
+ });
565
+ break;
566
+ }
567
+ case "reasoning": {
568
+ if (sendReasoning) {
569
+ const reasoningMetadata = await (0, import_provider_utils3.parseProviderOptions)({
570
+ provider: "anthropic",
571
+ providerOptions: part.providerOptions,
572
+ schema: anthropicReasoningMetadataSchema
573
+ });
574
+ if (reasoningMetadata != null) {
575
+ if (reasoningMetadata.signature != null) {
576
+ anthropicContent.push({
577
+ type: "thinking",
578
+ thinking: part.text,
579
+ signature: reasoningMetadata.signature,
580
+ cache_control: cacheControl
581
+ });
582
+ } else if (reasoningMetadata.redactedData != null) {
583
+ anthropicContent.push({
584
+ type: "redacted_thinking",
585
+ data: reasoningMetadata.redactedData,
586
+ cache_control: cacheControl
587
+ });
588
+ } else {
589
+ warnings.push({
590
+ type: "other",
591
+ message: "unsupported reasoning metadata"
592
+ });
593
+ }
594
+ } else {
595
+ warnings.push({
596
+ type: "other",
597
+ message: "unsupported reasoning metadata"
598
+ });
599
+ }
600
+ } else {
601
+ warnings.push({
602
+ type: "other",
603
+ message: "sending reasoning content is disabled for this model"
604
+ });
605
+ }
606
+ break;
607
+ }
608
+ case "tool-call": {
609
+ if (part.providerExecuted) {
610
+ if (part.toolName === "web_search") {
611
+ anthropicContent.push({
612
+ type: "server_tool_use",
613
+ id: part.toolCallId,
614
+ name: "web_search",
615
+ input: part.input,
616
+ cache_control: cacheControl
617
+ });
618
+ break;
619
+ }
620
+ warnings.push({
621
+ type: "other",
622
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
623
+ });
624
+ break;
625
+ }
626
+ anthropicContent.push({
627
+ type: "tool_use",
628
+ id: part.toolCallId,
629
+ name: part.toolName,
630
+ input: part.input,
631
+ cache_control: cacheControl
632
+ });
633
+ break;
634
+ }
635
+ case "tool-result": {
636
+ if (part.toolName === "web_search") {
637
+ const output = part.output;
638
+ if (output.type !== "json") {
639
+ warnings.push({
640
+ type: "other",
641
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
642
+ });
643
+ break;
644
+ }
645
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
646
+ output.value
647
+ );
648
+ anthropicContent.push({
649
+ type: "web_search_tool_result",
650
+ tool_use_id: part.toolCallId,
651
+ content: webSearchOutput.map((result) => ({
652
+ url: result.url,
653
+ title: result.title,
654
+ page_age: result.pageAge,
655
+ encrypted_content: result.encryptedContent,
656
+ type: result.type
657
+ })),
658
+ cache_control: cacheControl
659
+ });
660
+ break;
661
+ }
662
+ warnings.push({
663
+ type: "other",
664
+ message: `provider executed tool result for tool ${part.toolName} is not supported`
665
+ });
666
+ break;
667
+ }
668
+ }
669
+ }
670
+ }
671
+ messages.push({ role: "assistant", content: anthropicContent });
672
+ break;
673
+ }
674
+ default: {
675
+ const _exhaustiveCheck = type;
676
+ throw new Error(`content type: ${_exhaustiveCheck}`);
677
+ }
678
+ }
679
+ }
680
+ return {
681
+ prompt: { system, messages },
682
+ betas
683
+ };
684
+ }
685
+ function groupIntoBlocks(prompt) {
686
+ const blocks = [];
687
+ let currentBlock = void 0;
688
+ for (const message of prompt) {
689
+ const { role } = message;
690
+ switch (role) {
691
+ case "system": {
692
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "system") {
693
+ currentBlock = { type: "system", messages: [] };
694
+ blocks.push(currentBlock);
695
+ }
696
+ currentBlock.messages.push(message);
697
+ break;
698
+ }
699
+ case "assistant": {
700
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "assistant") {
701
+ currentBlock = { type: "assistant", messages: [] };
702
+ blocks.push(currentBlock);
703
+ }
704
+ currentBlock.messages.push(message);
705
+ break;
706
+ }
707
+ case "user": {
708
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
709
+ currentBlock = { type: "user", messages: [] };
710
+ blocks.push(currentBlock);
711
+ }
712
+ currentBlock.messages.push(message);
713
+ break;
714
+ }
715
+ case "tool": {
716
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
717
+ currentBlock = { type: "user", messages: [] };
718
+ blocks.push(currentBlock);
719
+ }
720
+ currentBlock.messages.push(message);
721
+ break;
722
+ }
723
+ default: {
724
+ const _exhaustiveCheck = role;
725
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
726
+ }
727
+ }
728
+ }
729
+ return blocks;
730
+ }
731
+
732
+ // src/map-anthropic-stop-reason.ts
733
+ function mapAnthropicStopReason({
734
+ finishReason,
735
+ isJsonResponseFromTool
736
+ }) {
737
+ switch (finishReason) {
738
+ case "end_turn":
739
+ case "stop_sequence":
740
+ return "stop";
741
+ case "tool_use":
742
+ return isJsonResponseFromTool ? "stop" : "tool-calls";
743
+ case "max_tokens":
744
+ return "length";
745
+ default:
746
+ return "unknown";
747
+ }
748
+ }
749
+
750
+ // src/anthropic-messages-language-model.ts
751
+ var citationSchemas = {
752
+ webSearchResult: import_v44.z.object({
753
+ type: import_v44.z.literal("web_search_result_location"),
754
+ cited_text: import_v44.z.string(),
755
+ url: import_v44.z.string(),
756
+ title: import_v44.z.string(),
757
+ encrypted_index: import_v44.z.string()
758
+ }),
759
+ pageLocation: import_v44.z.object({
760
+ type: import_v44.z.literal("page_location"),
761
+ cited_text: import_v44.z.string(),
762
+ document_index: import_v44.z.number(),
763
+ document_title: import_v44.z.string().nullable(),
764
+ start_page_number: import_v44.z.number(),
765
+ end_page_number: import_v44.z.number()
766
+ }),
767
+ charLocation: import_v44.z.object({
768
+ type: import_v44.z.literal("char_location"),
769
+ cited_text: import_v44.z.string(),
770
+ document_index: import_v44.z.number(),
771
+ document_title: import_v44.z.string().nullable(),
772
+ start_char_index: import_v44.z.number(),
773
+ end_char_index: import_v44.z.number()
774
+ })
775
+ };
776
+ var citationSchema = import_v44.z.discriminatedUnion("type", [
777
+ citationSchemas.webSearchResult,
778
+ citationSchemas.pageLocation,
779
+ citationSchemas.charLocation
780
+ ]);
781
+ var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
782
+ citationSchemas.pageLocation,
783
+ citationSchemas.charLocation
784
+ ]);
785
+ function processCitation(citation, citationDocuments, generateId2, onSource) {
786
+ if (citation.type === "page_location" || citation.type === "char_location") {
787
+ const source = createCitationSource(
788
+ citation,
789
+ citationDocuments,
790
+ generateId2
791
+ );
792
+ if (source) {
793
+ onSource(source);
794
+ }
795
+ }
796
+ }
797
+ function createCitationSource(citation, citationDocuments, generateId2) {
798
+ var _a;
799
+ const documentInfo = citationDocuments[citation.document_index];
800
+ if (!documentInfo) {
801
+ return null;
802
+ }
803
+ const providerMetadata = citation.type === "page_location" ? {
804
+ citedText: citation.cited_text,
805
+ startPageNumber: citation.start_page_number,
806
+ endPageNumber: citation.end_page_number
807
+ } : {
808
+ citedText: citation.cited_text,
809
+ startCharIndex: citation.start_char_index,
810
+ endCharIndex: citation.end_char_index
811
+ };
812
+ return {
813
+ type: "source",
814
+ sourceType: "document",
815
+ id: generateId2(),
816
+ mediaType: documentInfo.mediaType,
817
+ title: (_a = citation.document_title) != null ? _a : documentInfo.title,
818
+ filename: documentInfo.filename,
819
+ providerMetadata: {
820
+ anthropic: providerMetadata
821
+ }
822
+ };
823
+ }
824
+ var AnthropicMessagesLanguageModel = class {
825
+ constructor(modelId, config) {
826
+ this.specificationVersion = "v2";
827
+ var _a;
828
+ this.modelId = modelId;
829
+ this.config = config;
830
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
831
+ }
832
+ supportsUrl(url) {
833
+ return url.protocol === "https:";
834
+ }
835
+ get provider() {
836
+ return this.config.provider;
837
+ }
838
+ get supportedUrls() {
839
+ var _a, _b, _c;
840
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
841
+ }
842
+ async getArgs({
843
+ prompt,
844
+ maxOutputTokens = 4096,
845
+ // 4096: max model output tokens TODO update default in v5
846
+ temperature,
847
+ topP,
848
+ topK,
849
+ frequencyPenalty,
850
+ presencePenalty,
851
+ stopSequences,
852
+ responseFormat,
853
+ seed,
854
+ tools,
855
+ toolChoice,
856
+ providerOptions
857
+ }) {
858
+ var _a, _b, _c;
859
+ const warnings = [];
860
+ if (frequencyPenalty != null) {
861
+ warnings.push({
862
+ type: "unsupported-setting",
863
+ setting: "frequencyPenalty"
864
+ });
865
+ }
866
+ if (presencePenalty != null) {
867
+ warnings.push({
868
+ type: "unsupported-setting",
869
+ setting: "presencePenalty"
870
+ });
871
+ }
872
+ if (seed != null) {
873
+ warnings.push({
874
+ type: "unsupported-setting",
875
+ setting: "seed"
876
+ });
877
+ }
878
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
879
+ if (responseFormat.schema == null) {
880
+ warnings.push({
881
+ type: "unsupported-setting",
882
+ setting: "responseFormat",
883
+ details: "JSON response format requires a schema. The response format is ignored."
884
+ });
885
+ } else if (tools != null) {
886
+ warnings.push({
887
+ type: "unsupported-setting",
888
+ setting: "tools",
889
+ details: "JSON response format does not support tools. The provided tools are ignored."
890
+ });
891
+ }
892
+ }
893
+ const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null ? {
894
+ type: "function",
895
+ name: "json",
896
+ description: "Respond with a JSON object.",
897
+ inputSchema: responseFormat.schema
898
+ } : void 0;
899
+ const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
900
+ provider: "anthropic",
901
+ providerOptions,
902
+ schema: anthropicProviderOptions
903
+ });
904
+ const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
905
+ prompt,
906
+ sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
907
+ warnings
908
+ });
909
+ const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
910
+ const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
911
+ const baseArgs = {
912
+ // model id:
913
+ model: this.modelId,
914
+ // standardized settings:
915
+ max_tokens: maxOutputTokens,
916
+ temperature,
917
+ top_k: topK,
918
+ top_p: topP,
919
+ stop_sequences: stopSequences,
920
+ // provider specific settings:
921
+ ...isThinking && {
922
+ thinking: { type: "enabled", budget_tokens: thinkingBudget }
923
+ },
924
+ // prompt:
925
+ system: messagesPrompt.system,
926
+ messages: messagesPrompt.messages
927
+ };
928
+ if (isThinking) {
929
+ if (thinkingBudget == null) {
930
+ throw new import_provider3.UnsupportedFunctionalityError({
931
+ functionality: "thinking requires a budget"
932
+ });
933
+ }
934
+ if (baseArgs.temperature != null) {
935
+ baseArgs.temperature = void 0;
936
+ warnings.push({
937
+ type: "unsupported-setting",
938
+ setting: "temperature",
939
+ details: "temperature is not supported when thinking is enabled"
940
+ });
941
+ }
942
+ if (topK != null) {
943
+ baseArgs.top_k = void 0;
944
+ warnings.push({
945
+ type: "unsupported-setting",
946
+ setting: "topK",
947
+ details: "topK is not supported when thinking is enabled"
948
+ });
949
+ }
950
+ if (topP != null) {
951
+ baseArgs.top_p = void 0;
952
+ warnings.push({
953
+ type: "unsupported-setting",
954
+ setting: "topP",
955
+ details: "topP is not supported when thinking is enabled"
956
+ });
957
+ }
958
+ baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
959
+ }
960
+ const {
961
+ tools: anthropicTools2,
962
+ toolChoice: anthropicToolChoice,
963
+ toolWarnings,
964
+ betas: toolsBetas
965
+ } = prepareTools(
966
+ jsonResponseTool != null ? {
967
+ tools: [jsonResponseTool],
968
+ toolChoice: { type: "tool", toolName: jsonResponseTool.name },
969
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
970
+ } : {
971
+ tools: tools != null ? tools : [],
972
+ toolChoice,
973
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
974
+ }
975
+ );
976
+ return {
977
+ args: {
978
+ ...baseArgs,
979
+ tools: anthropicTools2,
980
+ tool_choice: anthropicToolChoice
981
+ },
982
+ warnings: [...warnings, ...toolWarnings],
983
+ betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
984
+ usesJsonResponseTool: jsonResponseTool != null
985
+ };
986
+ }
987
+ async getHeaders({
988
+ betas,
989
+ headers
990
+ }) {
991
+ return (0, import_provider_utils4.combineHeaders)(
992
+ await (0, import_provider_utils4.resolve)(this.config.headers),
993
+ betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
994
+ headers
995
+ );
996
+ }
997
+ buildRequestUrl(isStreaming) {
998
+ var _a, _b, _c;
999
+ return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
1000
+ }
1001
+ transformRequestBody(args) {
1002
+ var _a, _b, _c;
1003
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
1004
+ }
1005
+ extractCitationDocuments(prompt) {
1006
+ const isCitationPart = (part) => {
1007
+ var _a, _b;
1008
+ if (part.type !== "file") {
1009
+ return false;
1010
+ }
1011
+ if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
1012
+ return false;
1013
+ }
1014
+ const anthropic = (_a = part.providerOptions) == null ? void 0 : _a.anthropic;
1015
+ const citationsConfig = anthropic == null ? void 0 : anthropic.citations;
1016
+ return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
1017
+ };
1018
+ return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
1019
+ var _a;
1020
+ const filePart = part;
1021
+ return {
1022
+ title: (_a = filePart.filename) != null ? _a : "Untitled Document",
1023
+ filename: filePart.filename,
1024
+ mediaType: filePart.mediaType
1025
+ };
1026
+ });
1027
+ }
1028
+ async doGenerate(options) {
1029
+ var _a, _b, _c, _d, _e;
1030
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1031
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1032
+ const {
1033
+ responseHeaders,
1034
+ value: response,
1035
+ rawValue: rawResponse
1036
+ } = await (0, import_provider_utils4.postJsonToApi)({
1037
+ url: this.buildRequestUrl(false),
1038
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1039
+ body: this.transformRequestBody(args),
1040
+ failedResponseHandler: anthropicFailedResponseHandler,
1041
+ successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1042
+ anthropicMessagesResponseSchema
1043
+ ),
1044
+ abortSignal: options.abortSignal,
1045
+ fetch: this.config.fetch
1046
+ });
1047
+ const content = [];
1048
+ for (const part of response.content) {
1049
+ switch (part.type) {
1050
+ case "text": {
1051
+ if (!usesJsonResponseTool) {
1052
+ content.push({ type: "text", text: part.text });
1053
+ if (part.citations) {
1054
+ for (const citation of part.citations) {
1055
+ processCitation(
1056
+ citation,
1057
+ citationDocuments,
1058
+ this.generateId,
1059
+ (source) => content.push(source)
1060
+ );
1061
+ }
1062
+ }
1063
+ }
1064
+ break;
1065
+ }
1066
+ case "thinking": {
1067
+ content.push({
1068
+ type: "reasoning",
1069
+ text: part.thinking,
1070
+ providerMetadata: {
1071
+ anthropic: {
1072
+ signature: part.signature
1073
+ }
1074
+ }
1075
+ });
1076
+ break;
1077
+ }
1078
+ case "redacted_thinking": {
1079
+ content.push({
1080
+ type: "reasoning",
1081
+ text: "",
1082
+ providerMetadata: {
1083
+ anthropic: {
1084
+ redactedData: part.data
1085
+ }
1086
+ }
1087
+ });
1088
+ break;
1089
+ }
1090
+ case "tool_use": {
1091
+ content.push(
1092
+ // when a json response tool is used, the tool call becomes the text:
1093
+ usesJsonResponseTool ? {
1094
+ type: "text",
1095
+ text: JSON.stringify(part.input)
1096
+ } : {
1097
+ type: "tool-call",
1098
+ toolCallId: part.id,
1099
+ toolName: part.name,
1100
+ input: JSON.stringify(part.input)
1101
+ }
1102
+ );
1103
+ break;
1104
+ }
1105
+ case "server_tool_use": {
1106
+ if (part.name === "web_search") {
1107
+ content.push({
1108
+ type: "tool-call",
1109
+ toolCallId: part.id,
1110
+ toolName: part.name,
1111
+ input: JSON.stringify(part.input),
1112
+ providerExecuted: true
1113
+ });
1114
+ }
1115
+ break;
1116
+ }
1117
+ case "web_search_tool_result": {
1118
+ if (Array.isArray(part.content)) {
1119
+ content.push({
1120
+ type: "tool-result",
1121
+ toolCallId: part.tool_use_id,
1122
+ toolName: "web_search",
1123
+ result: part.content.map((result) => {
1124
+ var _a2;
1125
+ return {
1126
+ url: result.url,
1127
+ title: result.title,
1128
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1129
+ encryptedContent: result.encrypted_content,
1130
+ type: result.type
1131
+ };
1132
+ }),
1133
+ providerExecuted: true
1134
+ });
1135
+ for (const result of part.content) {
1136
+ content.push({
1137
+ type: "source",
1138
+ sourceType: "url",
1139
+ id: this.generateId(),
1140
+ url: result.url,
1141
+ title: result.title,
1142
+ providerMetadata: {
1143
+ anthropic: {
1144
+ pageAge: (_a = result.page_age) != null ? _a : null
1145
+ }
1146
+ }
1147
+ });
1148
+ }
1149
+ } else {
1150
+ content.push({
1151
+ type: "tool-result",
1152
+ toolCallId: part.tool_use_id,
1153
+ toolName: "web_search",
1154
+ isError: true,
1155
+ result: {
1156
+ type: "web_search_tool_result_error",
1157
+ errorCode: part.content.error_code
1158
+ },
1159
+ providerExecuted: true
1160
+ });
1161
+ }
1162
+ break;
1163
+ }
1164
+ }
1165
+ }
1166
+ return {
1167
+ content,
1168
+ finishReason: mapAnthropicStopReason({
1169
+ finishReason: response.stop_reason,
1170
+ isJsonResponseFromTool: usesJsonResponseTool
1171
+ }),
1172
+ usage: {
1173
+ inputTokens: response.usage.input_tokens,
1174
+ outputTokens: response.usage.output_tokens,
1175
+ totalTokens: response.usage.input_tokens + response.usage.output_tokens,
1176
+ cachedInputTokens: (_b = response.usage.cache_read_input_tokens) != null ? _b : void 0
1177
+ },
1178
+ request: { body: args },
1179
+ response: {
1180
+ id: (_c = response.id) != null ? _c : void 0,
1181
+ modelId: (_d = response.model) != null ? _d : void 0,
1182
+ headers: responseHeaders,
1183
+ body: rawResponse
1184
+ },
1185
+ warnings,
1186
+ providerMetadata: {
1187
+ anthropic: {
1188
+ usage: response.usage,
1189
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1190
+ }
1191
+ }
1192
+ };
1193
+ }
1194
+ async doStream(options) {
1195
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1196
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1197
+ const body = { ...args, stream: true };
1198
+ const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1199
+ url: this.buildRequestUrl(true),
1200
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1201
+ body: this.transformRequestBody(body),
1202
+ failedResponseHandler: anthropicFailedResponseHandler,
1203
+ successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
1204
+ anthropicMessagesChunkSchema
1205
+ ),
1206
+ abortSignal: options.abortSignal,
1207
+ fetch: this.config.fetch
1208
+ });
1209
+ let finishReason = "unknown";
1210
+ const usage = {
1211
+ inputTokens: void 0,
1212
+ outputTokens: void 0,
1213
+ totalTokens: void 0
1214
+ };
1215
+ const contentBlocks = {};
1216
+ let providerMetadata = void 0;
1217
+ let blockType = void 0;
1218
+ const generateId2 = this.generateId;
1219
+ return {
1220
+ stream: response.pipeThrough(
1221
+ new TransformStream({
1222
+ start(controller) {
1223
+ controller.enqueue({ type: "stream-start", warnings });
1224
+ },
1225
+ transform(chunk, controller) {
1226
+ var _a, _b, _c, _d, _e, _f, _g;
1227
+ if (options.includeRawChunks) {
1228
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1229
+ }
1230
+ if (!chunk.success) {
1231
+ controller.enqueue({ type: "error", error: chunk.error });
1232
+ return;
1233
+ }
1234
+ const value = chunk.value;
1235
+ switch (value.type) {
1236
+ case "ping": {
1237
+ return;
1238
+ }
1239
+ case "content_block_start": {
1240
+ const contentBlockType = value.content_block.type;
1241
+ blockType = contentBlockType;
1242
+ switch (contentBlockType) {
1243
+ case "text": {
1244
+ contentBlocks[value.index] = { type: "text" };
1245
+ controller.enqueue({
1246
+ type: "text-start",
1247
+ id: String(value.index)
1248
+ });
1249
+ return;
1250
+ }
1251
+ case "thinking": {
1252
+ contentBlocks[value.index] = { type: "reasoning" };
1253
+ controller.enqueue({
1254
+ type: "reasoning-start",
1255
+ id: String(value.index)
1256
+ });
1257
+ return;
1258
+ }
1259
+ case "redacted_thinking": {
1260
+ contentBlocks[value.index] = { type: "reasoning" };
1261
+ controller.enqueue({
1262
+ type: "reasoning-start",
1263
+ id: String(value.index),
1264
+ providerMetadata: {
1265
+ anthropic: {
1266
+ redactedData: value.content_block.data
1267
+ }
1268
+ }
1269
+ });
1270
+ return;
1271
+ }
1272
+ case "tool_use": {
1273
+ contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
1274
+ type: "tool-call",
1275
+ toolCallId: value.content_block.id,
1276
+ toolName: value.content_block.name,
1277
+ input: ""
1278
+ };
1279
+ controller.enqueue(
1280
+ usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
1281
+ type: "tool-input-start",
1282
+ id: value.content_block.id,
1283
+ toolName: value.content_block.name
1284
+ }
1285
+ );
1286
+ return;
1287
+ }
1288
+ case "server_tool_use": {
1289
+ if (value.content_block.name === "web_search") {
1290
+ contentBlocks[value.index] = {
1291
+ type: "tool-call",
1292
+ toolCallId: value.content_block.id,
1293
+ toolName: value.content_block.name,
1294
+ input: "",
1295
+ providerExecuted: true
1296
+ };
1297
+ controller.enqueue({
1298
+ type: "tool-input-start",
1299
+ id: value.content_block.id,
1300
+ toolName: value.content_block.name,
1301
+ providerExecuted: true
1302
+ });
1303
+ }
1304
+ return;
1305
+ }
1306
+ case "web_search_tool_result": {
1307
+ const part = value.content_block;
1308
+ if (Array.isArray(part.content)) {
1309
+ controller.enqueue({
1310
+ type: "tool-result",
1311
+ toolCallId: part.tool_use_id,
1312
+ toolName: "web_search",
1313
+ result: part.content.map((result) => {
1314
+ var _a2;
1315
+ return {
1316
+ url: result.url,
1317
+ title: result.title,
1318
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1319
+ encryptedContent: result.encrypted_content,
1320
+ type: result.type
1321
+ };
1322
+ }),
1323
+ providerExecuted: true
1324
+ });
1325
+ for (const result of part.content) {
1326
+ controller.enqueue({
1327
+ type: "source",
1328
+ sourceType: "url",
1329
+ id: generateId2(),
1330
+ url: result.url,
1331
+ title: result.title,
1332
+ providerMetadata: {
1333
+ anthropic: {
1334
+ pageAge: (_a = result.page_age) != null ? _a : null
1335
+ }
1336
+ }
1337
+ });
1338
+ }
1339
+ } else {
1340
+ controller.enqueue({
1341
+ type: "tool-result",
1342
+ toolCallId: part.tool_use_id,
1343
+ toolName: "web_search",
1344
+ isError: true,
1345
+ result: {
1346
+ type: "web_search_tool_result_error",
1347
+ errorCode: part.content.error_code
1348
+ },
1349
+ providerExecuted: true
1350
+ });
1351
+ }
1352
+ return;
1353
+ }
1354
+ default: {
1355
+ const _exhaustiveCheck = contentBlockType;
1356
+ throw new Error(
1357
+ `Unsupported content block type: ${_exhaustiveCheck}`
1358
+ );
1359
+ }
1360
+ }
1361
+ }
1362
+ case "content_block_stop": {
1363
+ if (contentBlocks[value.index] != null) {
1364
+ const contentBlock = contentBlocks[value.index];
1365
+ switch (contentBlock.type) {
1366
+ case "text": {
1367
+ controller.enqueue({
1368
+ type: "text-end",
1369
+ id: String(value.index)
1370
+ });
1371
+ break;
1372
+ }
1373
+ case "reasoning": {
1374
+ controller.enqueue({
1375
+ type: "reasoning-end",
1376
+ id: String(value.index)
1377
+ });
1378
+ break;
1379
+ }
1380
+ case "tool-call":
1381
+ if (!usesJsonResponseTool) {
1382
+ controller.enqueue({
1383
+ type: "tool-input-end",
1384
+ id: contentBlock.toolCallId
1385
+ });
1386
+ controller.enqueue(contentBlock);
1387
+ }
1388
+ break;
1389
+ }
1390
+ delete contentBlocks[value.index];
1391
+ }
1392
+ blockType = void 0;
1393
+ return;
1394
+ }
1395
+ case "content_block_delta": {
1396
+ const deltaType = value.delta.type;
1397
+ switch (deltaType) {
1398
+ case "text_delta": {
1399
+ if (usesJsonResponseTool) {
1400
+ return;
1401
+ }
1402
+ controller.enqueue({
1403
+ type: "text-delta",
1404
+ id: String(value.index),
1405
+ delta: value.delta.text
1406
+ });
1407
+ return;
1408
+ }
1409
+ case "thinking_delta": {
1410
+ controller.enqueue({
1411
+ type: "reasoning-delta",
1412
+ id: String(value.index),
1413
+ delta: value.delta.thinking
1414
+ });
1415
+ return;
1416
+ }
1417
+ case "signature_delta": {
1418
+ if (blockType === "thinking") {
1419
+ controller.enqueue({
1420
+ type: "reasoning-delta",
1421
+ id: String(value.index),
1422
+ delta: "",
1423
+ providerMetadata: {
1424
+ anthropic: {
1425
+ signature: value.delta.signature
1426
+ }
1427
+ }
1428
+ });
1429
+ }
1430
+ return;
1431
+ }
1432
+ case "input_json_delta": {
1433
+ const contentBlock = contentBlocks[value.index];
1434
+ const delta = value.delta.partial_json;
1435
+ if (usesJsonResponseTool) {
1436
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
1437
+ return;
1438
+ }
1439
+ controller.enqueue({
1440
+ type: "text-delta",
1441
+ id: String(value.index),
1442
+ delta
1443
+ });
1444
+ } else {
1445
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
1446
+ return;
1447
+ }
1448
+ controller.enqueue({
1449
+ type: "tool-input-delta",
1450
+ id: contentBlock.toolCallId,
1451
+ delta
1452
+ });
1453
+ contentBlock.input += delta;
1454
+ }
1455
+ return;
1456
+ }
1457
+ case "citations_delta": {
1458
+ const citation = value.delta.citation;
1459
+ processCitation(
1460
+ citation,
1461
+ citationDocuments,
1462
+ generateId2,
1463
+ (source) => controller.enqueue(source)
1464
+ );
1465
+ return;
1466
+ }
1467
+ default: {
1468
+ const _exhaustiveCheck = deltaType;
1469
+ throw new Error(
1470
+ `Unsupported delta type: ${_exhaustiveCheck}`
1471
+ );
1472
+ }
1473
+ }
1474
+ }
1475
+ case "message_start": {
1476
+ usage.inputTokens = value.message.usage.input_tokens;
1477
+ usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
1478
+ providerMetadata = {
1479
+ anthropic: {
1480
+ usage: value.message.usage,
1481
+ cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
1482
+ }
1483
+ };
1484
+ controller.enqueue({
1485
+ type: "response-metadata",
1486
+ id: (_d = value.message.id) != null ? _d : void 0,
1487
+ modelId: (_e = value.message.model) != null ? _e : void 0
1488
+ });
1489
+ return;
1490
+ }
1491
+ case "message_delta": {
1492
+ usage.outputTokens = value.usage.output_tokens;
1493
+ usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
1494
+ finishReason = mapAnthropicStopReason({
1495
+ finishReason: value.delta.stop_reason,
1496
+ isJsonResponseFromTool: usesJsonResponseTool
1497
+ });
1498
+ return;
1499
+ }
1500
+ case "message_stop": {
1501
+ controller.enqueue({
1502
+ type: "finish",
1503
+ finishReason,
1504
+ usage,
1505
+ providerMetadata
1506
+ });
1507
+ return;
1508
+ }
1509
+ case "error": {
1510
+ controller.enqueue({ type: "error", error: value.error });
1511
+ return;
1512
+ }
1513
+ default: {
1514
+ const _exhaustiveCheck = value;
1515
+ throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
1516
+ }
1517
+ }
1518
+ }
1519
+ })
1520
+ ),
1521
+ request: { body },
1522
+ response: { headers: responseHeaders }
1523
+ };
1524
+ }
1525
+ };
1526
+ var anthropicMessagesResponseSchema = import_v44.z.object({
1527
+ type: import_v44.z.literal("message"),
1528
+ id: import_v44.z.string().nullish(),
1529
+ model: import_v44.z.string().nullish(),
1530
+ content: import_v44.z.array(
1531
+ import_v44.z.discriminatedUnion("type", [
1532
+ import_v44.z.object({
1533
+ type: import_v44.z.literal("text"),
1534
+ text: import_v44.z.string(),
1535
+ citations: import_v44.z.array(citationSchema).optional()
1536
+ }),
1537
+ import_v44.z.object({
1538
+ type: import_v44.z.literal("thinking"),
1539
+ thinking: import_v44.z.string(),
1540
+ signature: import_v44.z.string()
1541
+ }),
1542
+ import_v44.z.object({
1543
+ type: import_v44.z.literal("redacted_thinking"),
1544
+ data: import_v44.z.string()
1545
+ }),
1546
+ import_v44.z.object({
1547
+ type: import_v44.z.literal("tool_use"),
1548
+ id: import_v44.z.string(),
1549
+ name: import_v44.z.string(),
1550
+ input: import_v44.z.unknown()
1551
+ }),
1552
+ import_v44.z.object({
1553
+ type: import_v44.z.literal("server_tool_use"),
1554
+ id: import_v44.z.string(),
1555
+ name: import_v44.z.string(),
1556
+ input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1557
+ }),
1558
+ import_v44.z.object({
1559
+ type: import_v44.z.literal("web_search_tool_result"),
1560
+ tool_use_id: import_v44.z.string(),
1561
+ content: import_v44.z.union([
1562
+ import_v44.z.array(
1563
+ import_v44.z.object({
1564
+ type: import_v44.z.literal("web_search_result"),
1565
+ url: import_v44.z.string(),
1566
+ title: import_v44.z.string(),
1567
+ encrypted_content: import_v44.z.string(),
1568
+ page_age: import_v44.z.string().nullish()
1569
+ })
1570
+ ),
1571
+ import_v44.z.object({
1572
+ type: import_v44.z.literal("web_search_tool_result_error"),
1573
+ error_code: import_v44.z.string()
1574
+ })
1575
+ ])
1576
+ })
1577
+ ])
1578
+ ),
1579
+ stop_reason: import_v44.z.string().nullish(),
1580
+ usage: import_v44.z.looseObject({
1581
+ input_tokens: import_v44.z.number(),
1582
+ output_tokens: import_v44.z.number(),
1583
+ cache_creation_input_tokens: import_v44.z.number().nullish(),
1584
+ cache_read_input_tokens: import_v44.z.number().nullish()
1585
+ })
1586
+ });
1587
+ var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
1588
+ import_v44.z.object({
1589
+ type: import_v44.z.literal("message_start"),
1590
+ message: import_v44.z.object({
1591
+ id: import_v44.z.string().nullish(),
1592
+ model: import_v44.z.string().nullish(),
1593
+ usage: import_v44.z.looseObject({
1594
+ input_tokens: import_v44.z.number(),
1595
+ output_tokens: import_v44.z.number(),
1596
+ cache_creation_input_tokens: import_v44.z.number().nullish(),
1597
+ cache_read_input_tokens: import_v44.z.number().nullish()
1598
+ })
1599
+ })
1600
+ }),
1601
+ import_v44.z.object({
1602
+ type: import_v44.z.literal("content_block_start"),
1603
+ index: import_v44.z.number(),
1604
+ content_block: import_v44.z.discriminatedUnion("type", [
1605
+ import_v44.z.object({
1606
+ type: import_v44.z.literal("text"),
1607
+ text: import_v44.z.string()
1608
+ }),
1609
+ import_v44.z.object({
1610
+ type: import_v44.z.literal("thinking"),
1611
+ thinking: import_v44.z.string()
1612
+ }),
1613
+ import_v44.z.object({
1614
+ type: import_v44.z.literal("tool_use"),
1615
+ id: import_v44.z.string(),
1616
+ name: import_v44.z.string()
1617
+ }),
1618
+ import_v44.z.object({
1619
+ type: import_v44.z.literal("redacted_thinking"),
1620
+ data: import_v44.z.string()
1621
+ }),
1622
+ import_v44.z.object({
1623
+ type: import_v44.z.literal("server_tool_use"),
1624
+ id: import_v44.z.string(),
1625
+ name: import_v44.z.string(),
1626
+ input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1627
+ }),
1628
+ import_v44.z.object({
1629
+ type: import_v44.z.literal("web_search_tool_result"),
1630
+ tool_use_id: import_v44.z.string(),
1631
+ content: import_v44.z.union([
1632
+ import_v44.z.array(
1633
+ import_v44.z.object({
1634
+ type: import_v44.z.literal("web_search_result"),
1635
+ url: import_v44.z.string(),
1636
+ title: import_v44.z.string(),
1637
+ encrypted_content: import_v44.z.string(),
1638
+ page_age: import_v44.z.string().nullish()
1639
+ })
1640
+ ),
1641
+ import_v44.z.object({
1642
+ type: import_v44.z.literal("web_search_tool_result_error"),
1643
+ error_code: import_v44.z.string()
1644
+ })
1645
+ ])
1646
+ })
1647
+ ])
1648
+ }),
1649
+ import_v44.z.object({
1650
+ type: import_v44.z.literal("content_block_delta"),
1651
+ index: import_v44.z.number(),
1652
+ delta: import_v44.z.discriminatedUnion("type", [
1653
+ import_v44.z.object({
1654
+ type: import_v44.z.literal("input_json_delta"),
1655
+ partial_json: import_v44.z.string()
1656
+ }),
1657
+ import_v44.z.object({
1658
+ type: import_v44.z.literal("text_delta"),
1659
+ text: import_v44.z.string()
1660
+ }),
1661
+ import_v44.z.object({
1662
+ type: import_v44.z.literal("thinking_delta"),
1663
+ thinking: import_v44.z.string()
1664
+ }),
1665
+ import_v44.z.object({
1666
+ type: import_v44.z.literal("signature_delta"),
1667
+ signature: import_v44.z.string()
1668
+ }),
1669
+ import_v44.z.object({
1670
+ type: import_v44.z.literal("citations_delta"),
1671
+ citation: citationSchema
1672
+ })
1673
+ ])
1674
+ }),
1675
+ import_v44.z.object({
1676
+ type: import_v44.z.literal("content_block_stop"),
1677
+ index: import_v44.z.number()
1678
+ }),
1679
+ import_v44.z.object({
1680
+ type: import_v44.z.literal("error"),
1681
+ error: import_v44.z.object({
1682
+ type: import_v44.z.string(),
1683
+ message: import_v44.z.string()
1684
+ })
1685
+ }),
1686
+ import_v44.z.object({
1687
+ type: import_v44.z.literal("message_delta"),
1688
+ delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
1689
+ usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
1690
+ }),
1691
+ import_v44.z.object({
1692
+ type: import_v44.z.literal("message_stop")
1693
+ }),
1694
+ import_v44.z.object({
1695
+ type: import_v44.z.literal("ping")
1696
+ })
1697
+ ]);
1698
+ var anthropicReasoningMetadataSchema = import_v44.z.object({
1699
+ signature: import_v44.z.string().optional(),
1700
+ redactedData: import_v44.z.string().optional()
1701
+ });
1702
+
1703
+ // src/tool/bash_20241022.ts
1704
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
1705
+ var import_v45 = __toESM(require("zod/v4"));
1706
+ var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
1707
+ id: "anthropic.bash_20241022",
1708
+ name: "bash",
1709
+ inputSchema: import_v45.default.object({
1710
+ command: import_v45.default.string(),
1711
+ restart: import_v45.default.boolean().optional()
1712
+ })
1713
+ });
1714
+
1715
+ // src/tool/bash_20250124.ts
1716
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1717
+ var import_v46 = __toESM(require("zod/v4"));
1718
+ var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1719
+ id: "anthropic.bash_20250124",
1720
+ name: "bash",
1721
+ inputSchema: import_v46.default.object({
1722
+ command: import_v46.default.string(),
1723
+ restart: import_v46.default.boolean().optional()
1724
+ })
1725
+ });
1726
+
1727
+ // src/tool/computer_20241022.ts
1728
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1729
+ var import_v47 = require("zod/v4");
1730
+ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1731
+ id: "anthropic.computer_20241022",
1732
+ name: "computer",
1733
+ inputSchema: import_v47.z.object({
1734
+ action: import_v47.z.enum([
1735
+ "key",
1736
+ "type",
1737
+ "mouse_move",
1738
+ "left_click",
1739
+ "left_click_drag",
1740
+ "right_click",
1741
+ "middle_click",
1742
+ "double_click",
1743
+ "screenshot",
1744
+ "cursor_position"
1745
+ ]),
1746
+ coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
1747
+ text: import_v47.z.string().optional()
1748
+ })
1749
+ });
1750
+
1751
+ // src/tool/computer_20250124.ts
1752
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1753
+ var import_v48 = require("zod/v4");
1754
+ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1755
+ id: "anthropic.computer_20250124",
1756
+ name: "computer",
1757
+ inputSchema: import_v48.z.object({
1758
+ action: import_v48.z.enum([
1759
+ "key",
1760
+ "hold_key",
1761
+ "type",
1762
+ "cursor_position",
1763
+ "mouse_move",
1764
+ "left_mouse_down",
1765
+ "left_mouse_up",
1766
+ "left_click",
1767
+ "left_click_drag",
1768
+ "right_click",
1769
+ "middle_click",
1770
+ "double_click",
1771
+ "triple_click",
1772
+ "scroll",
1773
+ "wait",
1774
+ "screenshot"
1775
+ ]),
1776
+ coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1777
+ duration: import_v48.z.number().optional(),
1778
+ scroll_amount: import_v48.z.number().optional(),
1779
+ scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
1780
+ start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1781
+ text: import_v48.z.string().optional()
1782
+ })
1783
+ });
1784
+
1785
+ // src/tool/text-editor_20241022.ts
1786
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1787
+ var import_v49 = require("zod/v4");
1788
+ var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1789
+ id: "anthropic.text_editor_20241022",
1790
+ name: "str_replace_editor",
1791
+ inputSchema: import_v49.z.object({
1792
+ command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1793
+ path: import_v49.z.string(),
1794
+ file_text: import_v49.z.string().optional(),
1795
+ insert_line: import_v49.z.number().int().optional(),
1796
+ new_str: import_v49.z.string().optional(),
1797
+ old_str: import_v49.z.string().optional(),
1798
+ view_range: import_v49.z.array(import_v49.z.number().int()).optional()
1799
+ })
1800
+ });
1801
+
1802
+ // src/tool/text-editor_20250124.ts
1803
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1804
+ var import_v410 = require("zod/v4");
1805
+ var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1806
+ id: "anthropic.text_editor_20250124",
1807
+ name: "str_replace_editor",
1808
+ inputSchema: import_v410.z.object({
1809
+ command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1810
+ path: import_v410.z.string(),
1811
+ file_text: import_v410.z.string().optional(),
1812
+ insert_line: import_v410.z.number().int().optional(),
1813
+ new_str: import_v410.z.string().optional(),
1814
+ old_str: import_v410.z.string().optional(),
1815
+ view_range: import_v410.z.array(import_v410.z.number().int()).optional()
1816
+ })
1817
+ });
1818
+
1819
+ // src/tool/text-editor_20250429.ts
1820
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1821
+ var import_v411 = require("zod/v4");
1822
+ var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1823
+ id: "anthropic.text_editor_20250429",
1824
+ name: "str_replace_based_edit_tool",
1825
+ inputSchema: import_v411.z.object({
1826
+ command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
1827
+ path: import_v411.z.string(),
1828
+ file_text: import_v411.z.string().optional(),
1829
+ insert_line: import_v411.z.number().int().optional(),
1830
+ new_str: import_v411.z.string().optional(),
1831
+ old_str: import_v411.z.string().optional(),
1832
+ view_range: import_v411.z.array(import_v411.z.number().int()).optional()
1833
+ })
1834
+ });
1835
+
1836
+ // src/anthropic-tools.ts
1837
+ var anthropicTools = {
1838
+ /**
1839
+ * Creates a tool for running a bash command. Must have name "bash".
1840
+ *
1841
+ * Image results are supported.
1842
+ *
1843
+ * @param execute - The function to execute the tool. Optional.
1844
+ */
1845
+ bash_20241022,
1846
+ /**
1847
+ * Creates a tool for running a bash command. Must have name "bash".
1848
+ *
1849
+ * Image results are supported.
1850
+ *
1851
+ * @param execute - The function to execute the tool. Optional.
1852
+ */
1853
+ bash_20250124,
1854
+ /**
1855
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1856
+ */
1857
+ textEditor_20241022,
1858
+ /**
1859
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1860
+ */
1861
+ textEditor_20250124,
1862
+ /**
1863
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
1864
+ * Note: This version does not support the "undo_edit" command.
1865
+ */
1866
+ textEditor_20250429,
1867
+ /**
1868
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1869
+ *
1870
+ * Image results are supported.
1871
+ *
1872
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1873
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1874
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1875
+ */
1876
+ computer_20241022,
1877
+ /**
1878
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1879
+ *
1880
+ * Image results are supported.
1881
+ *
1882
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1883
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1884
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1885
+ * @param execute - The function to execute the tool. Optional.
1886
+ */
1887
+ computer_20250124,
1888
+ /**
1889
+ * Creates a web search tool that gives Claude direct access to real-time web content.
1890
+ * Must have name "web_search".
1891
+ *
1892
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
1893
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
1894
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
1895
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
1896
+ */
1897
+ webSearch_20250305
1898
+ };
1899
+ // Annotate the CommonJS export names for ESM import in node:
1900
+ 0 && (module.exports = {
1901
+ AnthropicMessagesLanguageModel,
1902
+ anthropicTools,
1903
+ prepareTools
1904
+ });
1905
+ //# sourceMappingURL=index.js.map
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.js.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs ADDED
@@ -0,0 +1,1880 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/anthropic-messages-language-model.ts
2
+ import {
3
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError3
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ combineHeaders,
7
+ createEventSourceResponseHandler,
8
+ createJsonResponseHandler,
9
+ generateId,
10
+ parseProviderOptions as parseProviderOptions2,
11
+ postJsonToApi,
12
+ resolve
13
+ } from "@ai-sdk/provider-utils";
14
+ import { z as z4 } from "zod/v4";
15
+
16
+ // src/anthropic-error.ts
17
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
18
+ import { z } from "zod/v4";
19
+ var anthropicErrorDataSchema = z.object({
20
+ type: z.literal("error"),
21
+ error: z.object({
22
+ type: z.string(),
23
+ message: z.string()
24
+ })
25
+ });
26
+ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
27
+ errorSchema: anthropicErrorDataSchema,
28
+ errorToMessage: (data) => data.error.message
29
+ });
30
+
31
+ // src/anthropic-messages-options.ts
32
+ import { z as z2 } from "zod/v4";
33
+ var anthropicFilePartProviderOptions = z2.object({
34
+ /**
35
+ * Citation configuration for this document.
36
+ * When enabled, this document will generate citations in the response.
37
+ */
38
+ citations: z2.object({
39
+ /**
40
+ * Enable citations for this document
41
+ */
42
+ enabled: z2.boolean()
43
+ }).optional(),
44
+ /**
45
+ * Custom title for the document.
46
+ * If not provided, the filename will be used.
47
+ */
48
+ title: z2.string().optional(),
49
+ /**
50
+ * Context about the document that will be passed to the model
51
+ * but not used towards cited content.
52
+ * Useful for storing document metadata as text or stringified JSON.
53
+ */
54
+ context: z2.string().optional()
55
+ });
56
+ var anthropicProviderOptions = z2.object({
57
+ sendReasoning: z2.boolean().optional(),
58
+ thinking: z2.object({
59
+ type: z2.union([z2.literal("enabled"), z2.literal("disabled")]),
60
+ budgetTokens: z2.number().optional()
61
+ }).optional(),
62
+ /**
63
+ * Whether to disable parallel function calling during tool use. Default is false.
64
+ * When set to true, Claude will use at most one tool per response.
65
+ */
66
+ disableParallelToolUse: z2.boolean().optional()
67
+ });
68
+
69
+ // src/anthropic-prepare-tools.ts
70
+ import {
71
+ UnsupportedFunctionalityError
72
+ } from "@ai-sdk/provider";
73
+
74
+ // src/get-cache-control.ts
75
+ function getCacheControl(providerMetadata) {
76
+ var _a;
77
+ const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
78
+ const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
79
+ return cacheControlValue;
80
+ }
81
+
82
+ // src/tool/web-search_20250305.ts
83
+ import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
84
+ import { z as z3 } from "zod/v4";
85
+ var webSearch_20250305ArgsSchema = z3.object({
86
+ /**
87
+ * Maximum number of web searches Claude can perform during the conversation.
88
+ */
89
+ maxUses: z3.number().optional(),
90
+ /**
91
+ * Optional list of domains that Claude is allowed to search.
92
+ */
93
+ allowedDomains: z3.array(z3.string()).optional(),
94
+ /**
95
+ * Optional list of domains that Claude should avoid when searching.
96
+ */
97
+ blockedDomains: z3.array(z3.string()).optional(),
98
+ /**
99
+ * Optional user location information to provide geographically relevant search results.
100
+ */
101
+ userLocation: z3.object({
102
+ type: z3.literal("approximate"),
103
+ city: z3.string().optional(),
104
+ region: z3.string().optional(),
105
+ country: z3.string().optional(),
106
+ timezone: z3.string().optional()
107
+ }).optional()
108
+ });
109
+ var webSearch_20250305OutputSchema = z3.array(
110
+ z3.object({
111
+ url: z3.string(),
112
+ title: z3.string(),
113
+ pageAge: z3.string().nullable(),
114
+ encryptedContent: z3.string(),
115
+ type: z3.string()
116
+ })
117
+ );
118
+ var factory = createProviderDefinedToolFactoryWithOutputSchema({
119
+ id: "anthropic.web_search_20250305",
120
+ name: "web_search",
121
+ inputSchema: z3.object({
122
+ query: z3.string()
123
+ }),
124
+ outputSchema: webSearch_20250305OutputSchema
125
+ });
126
+ var webSearch_20250305 = (args = {}) => {
127
+ return factory(args);
128
+ };
129
+
130
+ // src/anthropic-prepare-tools.ts
131
+ function isWebSearchTool(tool) {
132
+ return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
133
+ }
134
+ function prepareTools({
135
+ tools,
136
+ toolChoice,
137
+ disableParallelToolUse
138
+ }) {
139
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
140
+ const toolWarnings = [];
141
+ const betas = /* @__PURE__ */ new Set();
142
+ if (tools == null) {
143
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
144
+ }
145
+ const anthropicTools2 = [];
146
+ for (const tool of tools) {
147
+ if (isWebSearchTool(tool)) {
148
+ anthropicTools2.push(tool);
149
+ continue;
150
+ }
151
+ switch (tool.type) {
152
+ case "function":
153
+ const cacheControl = getCacheControl(tool.providerOptions);
154
+ anthropicTools2.push({
155
+ name: tool.name,
156
+ description: tool.description,
157
+ input_schema: tool.inputSchema,
158
+ cache_control: cacheControl
159
+ });
160
+ break;
161
+ case "provider-defined":
162
+ switch (tool.id) {
163
+ case "anthropic.computer_20250124":
164
+ betas.add("computer-use-2025-01-24");
165
+ anthropicTools2.push({
166
+ name: "computer",
167
+ type: "computer_20250124",
168
+ display_width_px: tool.args.displayWidthPx,
169
+ display_height_px: tool.args.displayHeightPx,
170
+ display_number: tool.args.displayNumber
171
+ });
172
+ break;
173
+ case "anthropic.computer_20241022":
174
+ betas.add("computer-use-2024-10-22");
175
+ anthropicTools2.push({
176
+ name: "computer",
177
+ type: "computer_20241022",
178
+ display_width_px: tool.args.displayWidthPx,
179
+ display_height_px: tool.args.displayHeightPx,
180
+ display_number: tool.args.displayNumber
181
+ });
182
+ break;
183
+ case "anthropic.text_editor_20250124":
184
+ betas.add("computer-use-2025-01-24");
185
+ anthropicTools2.push({
186
+ name: "str_replace_editor",
187
+ type: "text_editor_20250124"
188
+ });
189
+ break;
190
+ case "anthropic.text_editor_20241022":
191
+ betas.add("computer-use-2024-10-22");
192
+ anthropicTools2.push({
193
+ name: "str_replace_editor",
194
+ type: "text_editor_20241022"
195
+ });
196
+ break;
197
+ case "anthropic.text_editor_20250429":
198
+ betas.add("computer-use-2025-01-24");
199
+ anthropicTools2.push({
200
+ name: "str_replace_based_edit_tool",
201
+ type: "text_editor_20250429"
202
+ });
203
+ break;
204
+ case "anthropic.bash_20250124":
205
+ betas.add("computer-use-2025-01-24");
206
+ anthropicTools2.push({
207
+ name: "bash",
208
+ type: "bash_20250124"
209
+ });
210
+ break;
211
+ case "anthropic.bash_20241022":
212
+ betas.add("computer-use-2024-10-22");
213
+ anthropicTools2.push({
214
+ name: "bash",
215
+ type: "bash_20241022"
216
+ });
217
+ break;
218
+ case "anthropic.web_search_20250305": {
219
+ const args = webSearch_20250305ArgsSchema.parse(tool.args);
220
+ anthropicTools2.push({
221
+ type: "web_search_20250305",
222
+ name: "web_search",
223
+ max_uses: args.maxUses,
224
+ allowed_domains: args.allowedDomains,
225
+ blocked_domains: args.blockedDomains,
226
+ user_location: args.userLocation
227
+ });
228
+ break;
229
+ }
230
+ default:
231
+ toolWarnings.push({ type: "unsupported-tool", tool });
232
+ break;
233
+ }
234
+ break;
235
+ default:
236
+ toolWarnings.push({ type: "unsupported-tool", tool });
237
+ break;
238
+ }
239
+ }
240
+ if (toolChoice == null) {
241
+ return {
242
+ tools: anthropicTools2,
243
+ toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
244
+ toolWarnings,
245
+ betas
246
+ };
247
+ }
248
+ const type = toolChoice.type;
249
+ switch (type) {
250
+ case "auto":
251
+ return {
252
+ tools: anthropicTools2,
253
+ toolChoice: {
254
+ type: "auto",
255
+ disable_parallel_tool_use: disableParallelToolUse
256
+ },
257
+ toolWarnings,
258
+ betas
259
+ };
260
+ case "required":
261
+ return {
262
+ tools: anthropicTools2,
263
+ toolChoice: {
264
+ type: "any",
265
+ disable_parallel_tool_use: disableParallelToolUse
266
+ },
267
+ toolWarnings,
268
+ betas
269
+ };
270
+ case "none":
271
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
272
+ case "tool":
273
+ return {
274
+ tools: anthropicTools2,
275
+ toolChoice: {
276
+ type: "tool",
277
+ name: toolChoice.toolName,
278
+ disable_parallel_tool_use: disableParallelToolUse
279
+ },
280
+ toolWarnings,
281
+ betas
282
+ };
283
+ default: {
284
+ const _exhaustiveCheck = type;
285
+ throw new UnsupportedFunctionalityError({
286
+ functionality: `tool choice type: ${_exhaustiveCheck}`
287
+ });
288
+ }
289
+ }
290
+ }
291
+
292
+ // src/convert-to-anthropic-messages-prompt.ts
293
+ import {
294
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
295
+ } from "@ai-sdk/provider";
296
+ import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
297
+ function convertToString(data) {
298
+ if (typeof data === "string") {
299
+ return Buffer.from(data, "base64").toString("utf-8");
300
+ }
301
+ if (data instanceof Uint8Array) {
302
+ return new TextDecoder().decode(data);
303
+ }
304
+ if (data instanceof URL) {
305
+ throw new UnsupportedFunctionalityError2({
306
+ functionality: "URL-based text documents are not supported for citations"
307
+ });
308
+ }
309
+ throw new UnsupportedFunctionalityError2({
310
+ functionality: `unsupported data type for text documents: ${typeof data}`
311
+ });
312
+ }
313
+ async function convertToAnthropicMessagesPrompt({
314
+ prompt,
315
+ sendReasoning,
316
+ warnings
317
+ }) {
318
+ var _a, _b, _c, _d, _e;
319
+ const betas = /* @__PURE__ */ new Set();
320
+ const blocks = groupIntoBlocks(prompt);
321
+ let system = void 0;
322
+ const messages = [];
323
+ async function shouldEnableCitations(providerMetadata) {
324
+ var _a2, _b2;
325
+ const anthropicOptions = await parseProviderOptions({
326
+ provider: "anthropic",
327
+ providerOptions: providerMetadata,
328
+ schema: anthropicFilePartProviderOptions
329
+ });
330
+ return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
331
+ }
332
+ async function getDocumentMetadata(providerMetadata) {
333
+ const anthropicOptions = await parseProviderOptions({
334
+ provider: "anthropic",
335
+ providerOptions: providerMetadata,
336
+ schema: anthropicFilePartProviderOptions
337
+ });
338
+ return {
339
+ title: anthropicOptions == null ? void 0 : anthropicOptions.title,
340
+ context: anthropicOptions == null ? void 0 : anthropicOptions.context
341
+ };
342
+ }
343
+ for (let i = 0; i < blocks.length; i++) {
344
+ const block = blocks[i];
345
+ const isLastBlock = i === blocks.length - 1;
346
+ const type = block.type;
347
+ switch (type) {
348
+ case "system": {
349
+ if (system != null) {
350
+ throw new UnsupportedFunctionalityError2({
351
+ functionality: "Multiple system messages that are separated by user/assistant messages"
352
+ });
353
+ }
354
+ system = block.messages.map(({ content, providerOptions }) => ({
355
+ type: "text",
356
+ text: content,
357
+ cache_control: getCacheControl(providerOptions)
358
+ }));
359
+ break;
360
+ }
361
+ case "user": {
362
+ const anthropicContent = [];
363
+ for (const message of block.messages) {
364
+ const { role, content } = message;
365
+ switch (role) {
366
+ case "user": {
367
+ for (let j = 0; j < content.length; j++) {
368
+ const part = content[j];
369
+ const isLastPart = j === content.length - 1;
370
+ const cacheControl = (_a = getCacheControl(part.providerOptions)) != null ? _a : isLastPart ? getCacheControl(message.providerOptions) : void 0;
371
+ switch (part.type) {
372
+ case "text": {
373
+ anthropicContent.push({
374
+ type: "text",
375
+ text: part.text,
376
+ cache_control: cacheControl
377
+ });
378
+ break;
379
+ }
380
+ case "file": {
381
+ if (part.mediaType.startsWith("image/")) {
382
+ anthropicContent.push({
383
+ type: "image",
384
+ source: part.data instanceof URL ? {
385
+ type: "url",
386
+ url: part.data.toString()
387
+ } : {
388
+ type: "base64",
389
+ media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
390
+ data: convertToBase64(part.data)
391
+ },
392
+ cache_control: cacheControl
393
+ });
394
+ } else if (part.mediaType === "application/pdf") {
395
+ betas.add("pdfs-2024-09-25");
396
+ const enableCitations = await shouldEnableCitations(
397
+ part.providerOptions
398
+ );
399
+ const metadata = await getDocumentMetadata(
400
+ part.providerOptions
401
+ );
402
+ anthropicContent.push({
403
+ type: "document",
404
+ source: part.data instanceof URL ? {
405
+ type: "url",
406
+ url: part.data.toString()
407
+ } : {
408
+ type: "base64",
409
+ media_type: "application/pdf",
410
+ data: convertToBase64(part.data)
411
+ },
412
+ title: (_b = metadata.title) != null ? _b : part.filename,
413
+ ...metadata.context && { context: metadata.context },
414
+ ...enableCitations && {
415
+ citations: { enabled: true }
416
+ },
417
+ cache_control: cacheControl
418
+ });
419
+ } else if (part.mediaType === "text/plain") {
420
+ const enableCitations = await shouldEnableCitations(
421
+ part.providerOptions
422
+ );
423
+ const metadata = await getDocumentMetadata(
424
+ part.providerOptions
425
+ );
426
+ anthropicContent.push({
427
+ type: "document",
428
+ source: part.data instanceof URL ? {
429
+ type: "url",
430
+ url: part.data.toString()
431
+ } : {
432
+ type: "text",
433
+ media_type: "text/plain",
434
+ data: convertToString(part.data)
435
+ },
436
+ title: (_c = metadata.title) != null ? _c : part.filename,
437
+ ...metadata.context && { context: metadata.context },
438
+ ...enableCitations && {
439
+ citations: { enabled: true }
440
+ },
441
+ cache_control: cacheControl
442
+ });
443
+ } else {
444
+ throw new UnsupportedFunctionalityError2({
445
+ functionality: `media type: ${part.mediaType}`
446
+ });
447
+ }
448
+ break;
449
+ }
450
+ }
451
+ }
452
+ break;
453
+ }
454
+ case "tool": {
455
+ for (let i2 = 0; i2 < content.length; i2++) {
456
+ const part = content[i2];
457
+ const isLastPart = i2 === content.length - 1;
458
+ const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
459
+ const output = part.output;
460
+ let contentValue;
461
+ switch (output.type) {
462
+ case "content":
463
+ contentValue = output.value.map((contentPart) => {
464
+ switch (contentPart.type) {
465
+ case "text":
466
+ return {
467
+ type: "text",
468
+ text: contentPart.text,
469
+ cache_control: void 0
470
+ };
471
+ case "media": {
472
+ if (contentPart.mediaType.startsWith("image/")) {
473
+ return {
474
+ type: "image",
475
+ source: {
476
+ type: "base64",
477
+ media_type: contentPart.mediaType,
478
+ data: contentPart.data
479
+ },
480
+ cache_control: void 0
481
+ };
482
+ }
483
+ throw new UnsupportedFunctionalityError2({
484
+ functionality: `media type: ${contentPart.mediaType}`
485
+ });
486
+ }
487
+ }
488
+ });
489
+ break;
490
+ case "text":
491
+ case "error-text":
492
+ contentValue = output.value;
493
+ break;
494
+ case "json":
495
+ case "error-json":
496
+ default:
497
+ contentValue = JSON.stringify(output.value);
498
+ break;
499
+ }
500
+ anthropicContent.push({
501
+ type: "tool_result",
502
+ tool_use_id: part.toolCallId,
503
+ content: contentValue,
504
+ is_error: output.type === "error-text" || output.type === "error-json" ? true : void 0,
505
+ cache_control: cacheControl
506
+ });
507
+ }
508
+ break;
509
+ }
510
+ default: {
511
+ const _exhaustiveCheck = role;
512
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
513
+ }
514
+ }
515
+ }
516
+ messages.push({ role: "user", content: anthropicContent });
517
+ break;
518
+ }
519
+ case "assistant": {
520
+ const anthropicContent = [];
521
+ for (let j = 0; j < block.messages.length; j++) {
522
+ const message = block.messages[j];
523
+ const isLastMessage = j === block.messages.length - 1;
524
+ const { content } = message;
525
+ for (let k = 0; k < content.length; k++) {
526
+ const part = content[k];
527
+ const isLastContentPart = k === content.length - 1;
528
+ const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
529
+ switch (part.type) {
530
+ case "text": {
531
+ anthropicContent.push({
532
+ type: "text",
533
+ text: (
534
+ // trim the last text part if it's the last message in the block
535
+ // because Anthropic does not allow trailing whitespace
536
+ // in pre-filled assistant responses
537
+ isLastBlock && isLastMessage && isLastContentPart ? part.text.trim() : part.text
538
+ ),
539
+ cache_control: cacheControl
540
+ });
541
+ break;
542
+ }
543
+ case "reasoning": {
544
+ if (sendReasoning) {
545
+ const reasoningMetadata = await parseProviderOptions({
546
+ provider: "anthropic",
547
+ providerOptions: part.providerOptions,
548
+ schema: anthropicReasoningMetadataSchema
549
+ });
550
+ if (reasoningMetadata != null) {
551
+ if (reasoningMetadata.signature != null) {
552
+ anthropicContent.push({
553
+ type: "thinking",
554
+ thinking: part.text,
555
+ signature: reasoningMetadata.signature,
556
+ cache_control: cacheControl
557
+ });
558
+ } else if (reasoningMetadata.redactedData != null) {
559
+ anthropicContent.push({
560
+ type: "redacted_thinking",
561
+ data: reasoningMetadata.redactedData,
562
+ cache_control: cacheControl
563
+ });
564
+ } else {
565
+ warnings.push({
566
+ type: "other",
567
+ message: "unsupported reasoning metadata"
568
+ });
569
+ }
570
+ } else {
571
+ warnings.push({
572
+ type: "other",
573
+ message: "unsupported reasoning metadata"
574
+ });
575
+ }
576
+ } else {
577
+ warnings.push({
578
+ type: "other",
579
+ message: "sending reasoning content is disabled for this model"
580
+ });
581
+ }
582
+ break;
583
+ }
584
+ case "tool-call": {
585
+ if (part.providerExecuted) {
586
+ if (part.toolName === "web_search") {
587
+ anthropicContent.push({
588
+ type: "server_tool_use",
589
+ id: part.toolCallId,
590
+ name: "web_search",
591
+ input: part.input,
592
+ cache_control: cacheControl
593
+ });
594
+ break;
595
+ }
596
+ warnings.push({
597
+ type: "other",
598
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
599
+ });
600
+ break;
601
+ }
602
+ anthropicContent.push({
603
+ type: "tool_use",
604
+ id: part.toolCallId,
605
+ name: part.toolName,
606
+ input: part.input,
607
+ cache_control: cacheControl
608
+ });
609
+ break;
610
+ }
611
+ case "tool-result": {
612
+ if (part.toolName === "web_search") {
613
+ const output = part.output;
614
+ if (output.type !== "json") {
615
+ warnings.push({
616
+ type: "other",
617
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
618
+ });
619
+ break;
620
+ }
621
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
622
+ output.value
623
+ );
624
+ anthropicContent.push({
625
+ type: "web_search_tool_result",
626
+ tool_use_id: part.toolCallId,
627
+ content: webSearchOutput.map((result) => ({
628
+ url: result.url,
629
+ title: result.title,
630
+ page_age: result.pageAge,
631
+ encrypted_content: result.encryptedContent,
632
+ type: result.type
633
+ })),
634
+ cache_control: cacheControl
635
+ });
636
+ break;
637
+ }
638
+ warnings.push({
639
+ type: "other",
640
+ message: `provider executed tool result for tool ${part.toolName} is not supported`
641
+ });
642
+ break;
643
+ }
644
+ }
645
+ }
646
+ }
647
+ messages.push({ role: "assistant", content: anthropicContent });
648
+ break;
649
+ }
650
+ default: {
651
+ const _exhaustiveCheck = type;
652
+ throw new Error(`content type: ${_exhaustiveCheck}`);
653
+ }
654
+ }
655
+ }
656
+ return {
657
+ prompt: { system, messages },
658
+ betas
659
+ };
660
+ }
661
+ function groupIntoBlocks(prompt) {
662
+ const blocks = [];
663
+ let currentBlock = void 0;
664
+ for (const message of prompt) {
665
+ const { role } = message;
666
+ switch (role) {
667
+ case "system": {
668
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "system") {
669
+ currentBlock = { type: "system", messages: [] };
670
+ blocks.push(currentBlock);
671
+ }
672
+ currentBlock.messages.push(message);
673
+ break;
674
+ }
675
+ case "assistant": {
676
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "assistant") {
677
+ currentBlock = { type: "assistant", messages: [] };
678
+ blocks.push(currentBlock);
679
+ }
680
+ currentBlock.messages.push(message);
681
+ break;
682
+ }
683
+ case "user": {
684
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
685
+ currentBlock = { type: "user", messages: [] };
686
+ blocks.push(currentBlock);
687
+ }
688
+ currentBlock.messages.push(message);
689
+ break;
690
+ }
691
+ case "tool": {
692
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
693
+ currentBlock = { type: "user", messages: [] };
694
+ blocks.push(currentBlock);
695
+ }
696
+ currentBlock.messages.push(message);
697
+ break;
698
+ }
699
+ default: {
700
+ const _exhaustiveCheck = role;
701
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
702
+ }
703
+ }
704
+ }
705
+ return blocks;
706
+ }
707
+
708
+ // src/map-anthropic-stop-reason.ts
709
+ function mapAnthropicStopReason({
710
+ finishReason,
711
+ isJsonResponseFromTool
712
+ }) {
713
+ switch (finishReason) {
714
+ case "end_turn":
715
+ case "stop_sequence":
716
+ return "stop";
717
+ case "tool_use":
718
+ return isJsonResponseFromTool ? "stop" : "tool-calls";
719
+ case "max_tokens":
720
+ return "length";
721
+ default:
722
+ return "unknown";
723
+ }
724
+ }
725
+
726
+ // src/anthropic-messages-language-model.ts
727
+ var citationSchemas = {
728
+ webSearchResult: z4.object({
729
+ type: z4.literal("web_search_result_location"),
730
+ cited_text: z4.string(),
731
+ url: z4.string(),
732
+ title: z4.string(),
733
+ encrypted_index: z4.string()
734
+ }),
735
+ pageLocation: z4.object({
736
+ type: z4.literal("page_location"),
737
+ cited_text: z4.string(),
738
+ document_index: z4.number(),
739
+ document_title: z4.string().nullable(),
740
+ start_page_number: z4.number(),
741
+ end_page_number: z4.number()
742
+ }),
743
+ charLocation: z4.object({
744
+ type: z4.literal("char_location"),
745
+ cited_text: z4.string(),
746
+ document_index: z4.number(),
747
+ document_title: z4.string().nullable(),
748
+ start_char_index: z4.number(),
749
+ end_char_index: z4.number()
750
+ })
751
+ };
752
+ var citationSchema = z4.discriminatedUnion("type", [
753
+ citationSchemas.webSearchResult,
754
+ citationSchemas.pageLocation,
755
+ citationSchemas.charLocation
756
+ ]);
757
+ var documentCitationSchema = z4.discriminatedUnion("type", [
758
+ citationSchemas.pageLocation,
759
+ citationSchemas.charLocation
760
+ ]);
761
+ function processCitation(citation, citationDocuments, generateId2, onSource) {
762
+ if (citation.type === "page_location" || citation.type === "char_location") {
763
+ const source = createCitationSource(
764
+ citation,
765
+ citationDocuments,
766
+ generateId2
767
+ );
768
+ if (source) {
769
+ onSource(source);
770
+ }
771
+ }
772
+ }
773
+ function createCitationSource(citation, citationDocuments, generateId2) {
774
+ var _a;
775
+ const documentInfo = citationDocuments[citation.document_index];
776
+ if (!documentInfo) {
777
+ return null;
778
+ }
779
+ const providerMetadata = citation.type === "page_location" ? {
780
+ citedText: citation.cited_text,
781
+ startPageNumber: citation.start_page_number,
782
+ endPageNumber: citation.end_page_number
783
+ } : {
784
+ citedText: citation.cited_text,
785
+ startCharIndex: citation.start_char_index,
786
+ endCharIndex: citation.end_char_index
787
+ };
788
+ return {
789
+ type: "source",
790
+ sourceType: "document",
791
+ id: generateId2(),
792
+ mediaType: documentInfo.mediaType,
793
+ title: (_a = citation.document_title) != null ? _a : documentInfo.title,
794
+ filename: documentInfo.filename,
795
+ providerMetadata: {
796
+ anthropic: providerMetadata
797
+ }
798
+ };
799
+ }
800
+ var AnthropicMessagesLanguageModel = class {
801
+ constructor(modelId, config) {
802
+ this.specificationVersion = "v2";
803
+ var _a;
804
+ this.modelId = modelId;
805
+ this.config = config;
806
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
807
+ }
808
+ supportsUrl(url) {
809
+ return url.protocol === "https:";
810
+ }
811
+ get provider() {
812
+ return this.config.provider;
813
+ }
814
+ get supportedUrls() {
815
+ var _a, _b, _c;
816
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
817
+ }
818
+ async getArgs({
819
+ prompt,
820
+ maxOutputTokens = 4096,
821
+ // 4096: max model output tokens TODO update default in v5
822
+ temperature,
823
+ topP,
824
+ topK,
825
+ frequencyPenalty,
826
+ presencePenalty,
827
+ stopSequences,
828
+ responseFormat,
829
+ seed,
830
+ tools,
831
+ toolChoice,
832
+ providerOptions
833
+ }) {
834
+ var _a, _b, _c;
835
+ const warnings = [];
836
+ if (frequencyPenalty != null) {
837
+ warnings.push({
838
+ type: "unsupported-setting",
839
+ setting: "frequencyPenalty"
840
+ });
841
+ }
842
+ if (presencePenalty != null) {
843
+ warnings.push({
844
+ type: "unsupported-setting",
845
+ setting: "presencePenalty"
846
+ });
847
+ }
848
+ if (seed != null) {
849
+ warnings.push({
850
+ type: "unsupported-setting",
851
+ setting: "seed"
852
+ });
853
+ }
854
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
855
+ if (responseFormat.schema == null) {
856
+ warnings.push({
857
+ type: "unsupported-setting",
858
+ setting: "responseFormat",
859
+ details: "JSON response format requires a schema. The response format is ignored."
860
+ });
861
+ } else if (tools != null) {
862
+ warnings.push({
863
+ type: "unsupported-setting",
864
+ setting: "tools",
865
+ details: "JSON response format does not support tools. The provided tools are ignored."
866
+ });
867
+ }
868
+ }
869
+ const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null ? {
870
+ type: "function",
871
+ name: "json",
872
+ description: "Respond with a JSON object.",
873
+ inputSchema: responseFormat.schema
874
+ } : void 0;
875
+ const anthropicOptions = await parseProviderOptions2({
876
+ provider: "anthropic",
877
+ providerOptions,
878
+ schema: anthropicProviderOptions
879
+ });
880
+ const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
881
+ prompt,
882
+ sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
883
+ warnings
884
+ });
885
+ const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
886
+ const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
887
+ const baseArgs = {
888
+ // model id:
889
+ model: this.modelId,
890
+ // standardized settings:
891
+ max_tokens: maxOutputTokens,
892
+ temperature,
893
+ top_k: topK,
894
+ top_p: topP,
895
+ stop_sequences: stopSequences,
896
+ // provider specific settings:
897
+ ...isThinking && {
898
+ thinking: { type: "enabled", budget_tokens: thinkingBudget }
899
+ },
900
+ // prompt:
901
+ system: messagesPrompt.system,
902
+ messages: messagesPrompt.messages
903
+ };
904
+ if (isThinking) {
905
+ if (thinkingBudget == null) {
906
+ throw new UnsupportedFunctionalityError3({
907
+ functionality: "thinking requires a budget"
908
+ });
909
+ }
910
+ if (baseArgs.temperature != null) {
911
+ baseArgs.temperature = void 0;
912
+ warnings.push({
913
+ type: "unsupported-setting",
914
+ setting: "temperature",
915
+ details: "temperature is not supported when thinking is enabled"
916
+ });
917
+ }
918
+ if (topK != null) {
919
+ baseArgs.top_k = void 0;
920
+ warnings.push({
921
+ type: "unsupported-setting",
922
+ setting: "topK",
923
+ details: "topK is not supported when thinking is enabled"
924
+ });
925
+ }
926
+ if (topP != null) {
927
+ baseArgs.top_p = void 0;
928
+ warnings.push({
929
+ type: "unsupported-setting",
930
+ setting: "topP",
931
+ details: "topP is not supported when thinking is enabled"
932
+ });
933
+ }
934
+ baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
935
+ }
936
+ const {
937
+ tools: anthropicTools2,
938
+ toolChoice: anthropicToolChoice,
939
+ toolWarnings,
940
+ betas: toolsBetas
941
+ } = prepareTools(
942
+ jsonResponseTool != null ? {
943
+ tools: [jsonResponseTool],
944
+ toolChoice: { type: "tool", toolName: jsonResponseTool.name },
945
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
946
+ } : {
947
+ tools: tools != null ? tools : [],
948
+ toolChoice,
949
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
950
+ }
951
+ );
952
+ return {
953
+ args: {
954
+ ...baseArgs,
955
+ tools: anthropicTools2,
956
+ tool_choice: anthropicToolChoice
957
+ },
958
+ warnings: [...warnings, ...toolWarnings],
959
+ betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
960
+ usesJsonResponseTool: jsonResponseTool != null
961
+ };
962
+ }
963
+ async getHeaders({
964
+ betas,
965
+ headers
966
+ }) {
967
+ return combineHeaders(
968
+ await resolve(this.config.headers),
969
+ betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
970
+ headers
971
+ );
972
+ }
973
+ buildRequestUrl(isStreaming) {
974
+ var _a, _b, _c;
975
+ return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
976
+ }
977
+ transformRequestBody(args) {
978
+ var _a, _b, _c;
979
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
980
+ }
981
+ extractCitationDocuments(prompt) {
982
+ const isCitationPart = (part) => {
983
+ var _a, _b;
984
+ if (part.type !== "file") {
985
+ return false;
986
+ }
987
+ if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
988
+ return false;
989
+ }
990
+ const anthropic = (_a = part.providerOptions) == null ? void 0 : _a.anthropic;
991
+ const citationsConfig = anthropic == null ? void 0 : anthropic.citations;
992
+ return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
993
+ };
994
+ return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
995
+ var _a;
996
+ const filePart = part;
997
+ return {
998
+ title: (_a = filePart.filename) != null ? _a : "Untitled Document",
999
+ filename: filePart.filename,
1000
+ mediaType: filePart.mediaType
1001
+ };
1002
+ });
1003
+ }
1004
+ async doGenerate(options) {
1005
+ var _a, _b, _c, _d, _e;
1006
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1007
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1008
+ const {
1009
+ responseHeaders,
1010
+ value: response,
1011
+ rawValue: rawResponse
1012
+ } = await postJsonToApi({
1013
+ url: this.buildRequestUrl(false),
1014
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1015
+ body: this.transformRequestBody(args),
1016
+ failedResponseHandler: anthropicFailedResponseHandler,
1017
+ successfulResponseHandler: createJsonResponseHandler(
1018
+ anthropicMessagesResponseSchema
1019
+ ),
1020
+ abortSignal: options.abortSignal,
1021
+ fetch: this.config.fetch
1022
+ });
1023
+ const content = [];
1024
+ for (const part of response.content) {
1025
+ switch (part.type) {
1026
+ case "text": {
1027
+ if (!usesJsonResponseTool) {
1028
+ content.push({ type: "text", text: part.text });
1029
+ if (part.citations) {
1030
+ for (const citation of part.citations) {
1031
+ processCitation(
1032
+ citation,
1033
+ citationDocuments,
1034
+ this.generateId,
1035
+ (source) => content.push(source)
1036
+ );
1037
+ }
1038
+ }
1039
+ }
1040
+ break;
1041
+ }
1042
+ case "thinking": {
1043
+ content.push({
1044
+ type: "reasoning",
1045
+ text: part.thinking,
1046
+ providerMetadata: {
1047
+ anthropic: {
1048
+ signature: part.signature
1049
+ }
1050
+ }
1051
+ });
1052
+ break;
1053
+ }
1054
+ case "redacted_thinking": {
1055
+ content.push({
1056
+ type: "reasoning",
1057
+ text: "",
1058
+ providerMetadata: {
1059
+ anthropic: {
1060
+ redactedData: part.data
1061
+ }
1062
+ }
1063
+ });
1064
+ break;
1065
+ }
1066
+ case "tool_use": {
1067
+ content.push(
1068
+ // when a json response tool is used, the tool call becomes the text:
1069
+ usesJsonResponseTool ? {
1070
+ type: "text",
1071
+ text: JSON.stringify(part.input)
1072
+ } : {
1073
+ type: "tool-call",
1074
+ toolCallId: part.id,
1075
+ toolName: part.name,
1076
+ input: JSON.stringify(part.input)
1077
+ }
1078
+ );
1079
+ break;
1080
+ }
1081
+ case "server_tool_use": {
1082
+ if (part.name === "web_search") {
1083
+ content.push({
1084
+ type: "tool-call",
1085
+ toolCallId: part.id,
1086
+ toolName: part.name,
1087
+ input: JSON.stringify(part.input),
1088
+ providerExecuted: true
1089
+ });
1090
+ }
1091
+ break;
1092
+ }
1093
+ case "web_search_tool_result": {
1094
+ if (Array.isArray(part.content)) {
1095
+ content.push({
1096
+ type: "tool-result",
1097
+ toolCallId: part.tool_use_id,
1098
+ toolName: "web_search",
1099
+ result: part.content.map((result) => {
1100
+ var _a2;
1101
+ return {
1102
+ url: result.url,
1103
+ title: result.title,
1104
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1105
+ encryptedContent: result.encrypted_content,
1106
+ type: result.type
1107
+ };
1108
+ }),
1109
+ providerExecuted: true
1110
+ });
1111
+ for (const result of part.content) {
1112
+ content.push({
1113
+ type: "source",
1114
+ sourceType: "url",
1115
+ id: this.generateId(),
1116
+ url: result.url,
1117
+ title: result.title,
1118
+ providerMetadata: {
1119
+ anthropic: {
1120
+ pageAge: (_a = result.page_age) != null ? _a : null
1121
+ }
1122
+ }
1123
+ });
1124
+ }
1125
+ } else {
1126
+ content.push({
1127
+ type: "tool-result",
1128
+ toolCallId: part.tool_use_id,
1129
+ toolName: "web_search",
1130
+ isError: true,
1131
+ result: {
1132
+ type: "web_search_tool_result_error",
1133
+ errorCode: part.content.error_code
1134
+ },
1135
+ providerExecuted: true
1136
+ });
1137
+ }
1138
+ break;
1139
+ }
1140
+ }
1141
+ }
1142
+ return {
1143
+ content,
1144
+ finishReason: mapAnthropicStopReason({
1145
+ finishReason: response.stop_reason,
1146
+ isJsonResponseFromTool: usesJsonResponseTool
1147
+ }),
1148
+ usage: {
1149
+ inputTokens: response.usage.input_tokens,
1150
+ outputTokens: response.usage.output_tokens,
1151
+ totalTokens: response.usage.input_tokens + response.usage.output_tokens,
1152
+ cachedInputTokens: (_b = response.usage.cache_read_input_tokens) != null ? _b : void 0
1153
+ },
1154
+ request: { body: args },
1155
+ response: {
1156
+ id: (_c = response.id) != null ? _c : void 0,
1157
+ modelId: (_d = response.model) != null ? _d : void 0,
1158
+ headers: responseHeaders,
1159
+ body: rawResponse
1160
+ },
1161
+ warnings,
1162
+ providerMetadata: {
1163
+ anthropic: {
1164
+ usage: response.usage,
1165
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1166
+ }
1167
+ }
1168
+ };
1169
+ }
1170
+ async doStream(options) {
1171
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1172
+ const citationDocuments = this.extractCitationDocuments(options.prompt);
1173
+ const body = { ...args, stream: true };
1174
+ const { responseHeaders, value: response } = await postJsonToApi({
1175
+ url: this.buildRequestUrl(true),
1176
+ headers: await this.getHeaders({ betas, headers: options.headers }),
1177
+ body: this.transformRequestBody(body),
1178
+ failedResponseHandler: anthropicFailedResponseHandler,
1179
+ successfulResponseHandler: createEventSourceResponseHandler(
1180
+ anthropicMessagesChunkSchema
1181
+ ),
1182
+ abortSignal: options.abortSignal,
1183
+ fetch: this.config.fetch
1184
+ });
1185
+ let finishReason = "unknown";
1186
+ const usage = {
1187
+ inputTokens: void 0,
1188
+ outputTokens: void 0,
1189
+ totalTokens: void 0
1190
+ };
1191
+ const contentBlocks = {};
1192
+ let providerMetadata = void 0;
1193
+ let blockType = void 0;
1194
+ const generateId2 = this.generateId;
1195
+ return {
1196
+ stream: response.pipeThrough(
1197
+ new TransformStream({
1198
+ start(controller) {
1199
+ controller.enqueue({ type: "stream-start", warnings });
1200
+ },
1201
+ transform(chunk, controller) {
1202
+ var _a, _b, _c, _d, _e, _f, _g;
1203
+ if (options.includeRawChunks) {
1204
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1205
+ }
1206
+ if (!chunk.success) {
1207
+ controller.enqueue({ type: "error", error: chunk.error });
1208
+ return;
1209
+ }
1210
+ const value = chunk.value;
1211
+ switch (value.type) {
1212
+ case "ping": {
1213
+ return;
1214
+ }
1215
+ case "content_block_start": {
1216
+ const contentBlockType = value.content_block.type;
1217
+ blockType = contentBlockType;
1218
+ switch (contentBlockType) {
1219
+ case "text": {
1220
+ contentBlocks[value.index] = { type: "text" };
1221
+ controller.enqueue({
1222
+ type: "text-start",
1223
+ id: String(value.index)
1224
+ });
1225
+ return;
1226
+ }
1227
+ case "thinking": {
1228
+ contentBlocks[value.index] = { type: "reasoning" };
1229
+ controller.enqueue({
1230
+ type: "reasoning-start",
1231
+ id: String(value.index)
1232
+ });
1233
+ return;
1234
+ }
1235
+ case "redacted_thinking": {
1236
+ contentBlocks[value.index] = { type: "reasoning" };
1237
+ controller.enqueue({
1238
+ type: "reasoning-start",
1239
+ id: String(value.index),
1240
+ providerMetadata: {
1241
+ anthropic: {
1242
+ redactedData: value.content_block.data
1243
+ }
1244
+ }
1245
+ });
1246
+ return;
1247
+ }
1248
+ case "tool_use": {
1249
+ contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
1250
+ type: "tool-call",
1251
+ toolCallId: value.content_block.id,
1252
+ toolName: value.content_block.name,
1253
+ input: ""
1254
+ };
1255
+ controller.enqueue(
1256
+ usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
1257
+ type: "tool-input-start",
1258
+ id: value.content_block.id,
1259
+ toolName: value.content_block.name
1260
+ }
1261
+ );
1262
+ return;
1263
+ }
1264
+ case "server_tool_use": {
1265
+ if (value.content_block.name === "web_search") {
1266
+ contentBlocks[value.index] = {
1267
+ type: "tool-call",
1268
+ toolCallId: value.content_block.id,
1269
+ toolName: value.content_block.name,
1270
+ input: "",
1271
+ providerExecuted: true
1272
+ };
1273
+ controller.enqueue({
1274
+ type: "tool-input-start",
1275
+ id: value.content_block.id,
1276
+ toolName: value.content_block.name,
1277
+ providerExecuted: true
1278
+ });
1279
+ }
1280
+ return;
1281
+ }
1282
+ case "web_search_tool_result": {
1283
+ const part = value.content_block;
1284
+ if (Array.isArray(part.content)) {
1285
+ controller.enqueue({
1286
+ type: "tool-result",
1287
+ toolCallId: part.tool_use_id,
1288
+ toolName: "web_search",
1289
+ result: part.content.map((result) => {
1290
+ var _a2;
1291
+ return {
1292
+ url: result.url,
1293
+ title: result.title,
1294
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null,
1295
+ encryptedContent: result.encrypted_content,
1296
+ type: result.type
1297
+ };
1298
+ }),
1299
+ providerExecuted: true
1300
+ });
1301
+ for (const result of part.content) {
1302
+ controller.enqueue({
1303
+ type: "source",
1304
+ sourceType: "url",
1305
+ id: generateId2(),
1306
+ url: result.url,
1307
+ title: result.title,
1308
+ providerMetadata: {
1309
+ anthropic: {
1310
+ pageAge: (_a = result.page_age) != null ? _a : null
1311
+ }
1312
+ }
1313
+ });
1314
+ }
1315
+ } else {
1316
+ controller.enqueue({
1317
+ type: "tool-result",
1318
+ toolCallId: part.tool_use_id,
1319
+ toolName: "web_search",
1320
+ isError: true,
1321
+ result: {
1322
+ type: "web_search_tool_result_error",
1323
+ errorCode: part.content.error_code
1324
+ },
1325
+ providerExecuted: true
1326
+ });
1327
+ }
1328
+ return;
1329
+ }
1330
+ default: {
1331
+ const _exhaustiveCheck = contentBlockType;
1332
+ throw new Error(
1333
+ `Unsupported content block type: ${_exhaustiveCheck}`
1334
+ );
1335
+ }
1336
+ }
1337
+ }
1338
+ case "content_block_stop": {
1339
+ if (contentBlocks[value.index] != null) {
1340
+ const contentBlock = contentBlocks[value.index];
1341
+ switch (contentBlock.type) {
1342
+ case "text": {
1343
+ controller.enqueue({
1344
+ type: "text-end",
1345
+ id: String(value.index)
1346
+ });
1347
+ break;
1348
+ }
1349
+ case "reasoning": {
1350
+ controller.enqueue({
1351
+ type: "reasoning-end",
1352
+ id: String(value.index)
1353
+ });
1354
+ break;
1355
+ }
1356
+ case "tool-call":
1357
+ if (!usesJsonResponseTool) {
1358
+ controller.enqueue({
1359
+ type: "tool-input-end",
1360
+ id: contentBlock.toolCallId
1361
+ });
1362
+ controller.enqueue(contentBlock);
1363
+ }
1364
+ break;
1365
+ }
1366
+ delete contentBlocks[value.index];
1367
+ }
1368
+ blockType = void 0;
1369
+ return;
1370
+ }
1371
+ case "content_block_delta": {
1372
+ const deltaType = value.delta.type;
1373
+ switch (deltaType) {
1374
+ case "text_delta": {
1375
+ if (usesJsonResponseTool) {
1376
+ return;
1377
+ }
1378
+ controller.enqueue({
1379
+ type: "text-delta",
1380
+ id: String(value.index),
1381
+ delta: value.delta.text
1382
+ });
1383
+ return;
1384
+ }
1385
+ case "thinking_delta": {
1386
+ controller.enqueue({
1387
+ type: "reasoning-delta",
1388
+ id: String(value.index),
1389
+ delta: value.delta.thinking
1390
+ });
1391
+ return;
1392
+ }
1393
+ case "signature_delta": {
1394
+ if (blockType === "thinking") {
1395
+ controller.enqueue({
1396
+ type: "reasoning-delta",
1397
+ id: String(value.index),
1398
+ delta: "",
1399
+ providerMetadata: {
1400
+ anthropic: {
1401
+ signature: value.delta.signature
1402
+ }
1403
+ }
1404
+ });
1405
+ }
1406
+ return;
1407
+ }
1408
+ case "input_json_delta": {
1409
+ const contentBlock = contentBlocks[value.index];
1410
+ const delta = value.delta.partial_json;
1411
+ if (usesJsonResponseTool) {
1412
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
1413
+ return;
1414
+ }
1415
+ controller.enqueue({
1416
+ type: "text-delta",
1417
+ id: String(value.index),
1418
+ delta
1419
+ });
1420
+ } else {
1421
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
1422
+ return;
1423
+ }
1424
+ controller.enqueue({
1425
+ type: "tool-input-delta",
1426
+ id: contentBlock.toolCallId,
1427
+ delta
1428
+ });
1429
+ contentBlock.input += delta;
1430
+ }
1431
+ return;
1432
+ }
1433
+ case "citations_delta": {
1434
+ const citation = value.delta.citation;
1435
+ processCitation(
1436
+ citation,
1437
+ citationDocuments,
1438
+ generateId2,
1439
+ (source) => controller.enqueue(source)
1440
+ );
1441
+ return;
1442
+ }
1443
+ default: {
1444
+ const _exhaustiveCheck = deltaType;
1445
+ throw new Error(
1446
+ `Unsupported delta type: ${_exhaustiveCheck}`
1447
+ );
1448
+ }
1449
+ }
1450
+ }
1451
+ case "message_start": {
1452
+ usage.inputTokens = value.message.usage.input_tokens;
1453
+ usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
1454
+ providerMetadata = {
1455
+ anthropic: {
1456
+ usage: value.message.usage,
1457
+ cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
1458
+ }
1459
+ };
1460
+ controller.enqueue({
1461
+ type: "response-metadata",
1462
+ id: (_d = value.message.id) != null ? _d : void 0,
1463
+ modelId: (_e = value.message.model) != null ? _e : void 0
1464
+ });
1465
+ return;
1466
+ }
1467
+ case "message_delta": {
1468
+ usage.outputTokens = value.usage.output_tokens;
1469
+ usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
1470
+ finishReason = mapAnthropicStopReason({
1471
+ finishReason: value.delta.stop_reason,
1472
+ isJsonResponseFromTool: usesJsonResponseTool
1473
+ });
1474
+ return;
1475
+ }
1476
+ case "message_stop": {
1477
+ controller.enqueue({
1478
+ type: "finish",
1479
+ finishReason,
1480
+ usage,
1481
+ providerMetadata
1482
+ });
1483
+ return;
1484
+ }
1485
+ case "error": {
1486
+ controller.enqueue({ type: "error", error: value.error });
1487
+ return;
1488
+ }
1489
+ default: {
1490
+ const _exhaustiveCheck = value;
1491
+ throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
1492
+ }
1493
+ }
1494
+ }
1495
+ })
1496
+ ),
1497
+ request: { body },
1498
+ response: { headers: responseHeaders }
1499
+ };
1500
+ }
1501
+ };
1502
+ var anthropicMessagesResponseSchema = z4.object({
1503
+ type: z4.literal("message"),
1504
+ id: z4.string().nullish(),
1505
+ model: z4.string().nullish(),
1506
+ content: z4.array(
1507
+ z4.discriminatedUnion("type", [
1508
+ z4.object({
1509
+ type: z4.literal("text"),
1510
+ text: z4.string(),
1511
+ citations: z4.array(citationSchema).optional()
1512
+ }),
1513
+ z4.object({
1514
+ type: z4.literal("thinking"),
1515
+ thinking: z4.string(),
1516
+ signature: z4.string()
1517
+ }),
1518
+ z4.object({
1519
+ type: z4.literal("redacted_thinking"),
1520
+ data: z4.string()
1521
+ }),
1522
+ z4.object({
1523
+ type: z4.literal("tool_use"),
1524
+ id: z4.string(),
1525
+ name: z4.string(),
1526
+ input: z4.unknown()
1527
+ }),
1528
+ z4.object({
1529
+ type: z4.literal("server_tool_use"),
1530
+ id: z4.string(),
1531
+ name: z4.string(),
1532
+ input: z4.record(z4.string(), z4.unknown()).nullish()
1533
+ }),
1534
+ z4.object({
1535
+ type: z4.literal("web_search_tool_result"),
1536
+ tool_use_id: z4.string(),
1537
+ content: z4.union([
1538
+ z4.array(
1539
+ z4.object({
1540
+ type: z4.literal("web_search_result"),
1541
+ url: z4.string(),
1542
+ title: z4.string(),
1543
+ encrypted_content: z4.string(),
1544
+ page_age: z4.string().nullish()
1545
+ })
1546
+ ),
1547
+ z4.object({
1548
+ type: z4.literal("web_search_tool_result_error"),
1549
+ error_code: z4.string()
1550
+ })
1551
+ ])
1552
+ })
1553
+ ])
1554
+ ),
1555
+ stop_reason: z4.string().nullish(),
1556
+ usage: z4.looseObject({
1557
+ input_tokens: z4.number(),
1558
+ output_tokens: z4.number(),
1559
+ cache_creation_input_tokens: z4.number().nullish(),
1560
+ cache_read_input_tokens: z4.number().nullish()
1561
+ })
1562
+ });
1563
+ var anthropicMessagesChunkSchema = z4.discriminatedUnion("type", [
1564
+ z4.object({
1565
+ type: z4.literal("message_start"),
1566
+ message: z4.object({
1567
+ id: z4.string().nullish(),
1568
+ model: z4.string().nullish(),
1569
+ usage: z4.looseObject({
1570
+ input_tokens: z4.number(),
1571
+ output_tokens: z4.number(),
1572
+ cache_creation_input_tokens: z4.number().nullish(),
1573
+ cache_read_input_tokens: z4.number().nullish()
1574
+ })
1575
+ })
1576
+ }),
1577
+ z4.object({
1578
+ type: z4.literal("content_block_start"),
1579
+ index: z4.number(),
1580
+ content_block: z4.discriminatedUnion("type", [
1581
+ z4.object({
1582
+ type: z4.literal("text"),
1583
+ text: z4.string()
1584
+ }),
1585
+ z4.object({
1586
+ type: z4.literal("thinking"),
1587
+ thinking: z4.string()
1588
+ }),
1589
+ z4.object({
1590
+ type: z4.literal("tool_use"),
1591
+ id: z4.string(),
1592
+ name: z4.string()
1593
+ }),
1594
+ z4.object({
1595
+ type: z4.literal("redacted_thinking"),
1596
+ data: z4.string()
1597
+ }),
1598
+ z4.object({
1599
+ type: z4.literal("server_tool_use"),
1600
+ id: z4.string(),
1601
+ name: z4.string(),
1602
+ input: z4.record(z4.string(), z4.unknown()).nullish()
1603
+ }),
1604
+ z4.object({
1605
+ type: z4.literal("web_search_tool_result"),
1606
+ tool_use_id: z4.string(),
1607
+ content: z4.union([
1608
+ z4.array(
1609
+ z4.object({
1610
+ type: z4.literal("web_search_result"),
1611
+ url: z4.string(),
1612
+ title: z4.string(),
1613
+ encrypted_content: z4.string(),
1614
+ page_age: z4.string().nullish()
1615
+ })
1616
+ ),
1617
+ z4.object({
1618
+ type: z4.literal("web_search_tool_result_error"),
1619
+ error_code: z4.string()
1620
+ })
1621
+ ])
1622
+ })
1623
+ ])
1624
+ }),
1625
+ z4.object({
1626
+ type: z4.literal("content_block_delta"),
1627
+ index: z4.number(),
1628
+ delta: z4.discriminatedUnion("type", [
1629
+ z4.object({
1630
+ type: z4.literal("input_json_delta"),
1631
+ partial_json: z4.string()
1632
+ }),
1633
+ z4.object({
1634
+ type: z4.literal("text_delta"),
1635
+ text: z4.string()
1636
+ }),
1637
+ z4.object({
1638
+ type: z4.literal("thinking_delta"),
1639
+ thinking: z4.string()
1640
+ }),
1641
+ z4.object({
1642
+ type: z4.literal("signature_delta"),
1643
+ signature: z4.string()
1644
+ }),
1645
+ z4.object({
1646
+ type: z4.literal("citations_delta"),
1647
+ citation: citationSchema
1648
+ })
1649
+ ])
1650
+ }),
1651
+ z4.object({
1652
+ type: z4.literal("content_block_stop"),
1653
+ index: z4.number()
1654
+ }),
1655
+ z4.object({
1656
+ type: z4.literal("error"),
1657
+ error: z4.object({
1658
+ type: z4.string(),
1659
+ message: z4.string()
1660
+ })
1661
+ }),
1662
+ z4.object({
1663
+ type: z4.literal("message_delta"),
1664
+ delta: z4.object({ stop_reason: z4.string().nullish() }),
1665
+ usage: z4.object({ output_tokens: z4.number() })
1666
+ }),
1667
+ z4.object({
1668
+ type: z4.literal("message_stop")
1669
+ }),
1670
+ z4.object({
1671
+ type: z4.literal("ping")
1672
+ })
1673
+ ]);
1674
+ var anthropicReasoningMetadataSchema = z4.object({
1675
+ signature: z4.string().optional(),
1676
+ redactedData: z4.string().optional()
1677
+ });
1678
+
1679
+ // src/tool/bash_20241022.ts
1680
+ import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
1681
+ import z5 from "zod/v4";
1682
+ var bash_20241022 = createProviderDefinedToolFactory({
1683
+ id: "anthropic.bash_20241022",
1684
+ name: "bash",
1685
+ inputSchema: z5.object({
1686
+ command: z5.string(),
1687
+ restart: z5.boolean().optional()
1688
+ })
1689
+ });
1690
+
1691
+ // src/tool/bash_20250124.ts
1692
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
1693
+ import z6 from "zod/v4";
1694
+ var bash_20250124 = createProviderDefinedToolFactory2({
1695
+ id: "anthropic.bash_20250124",
1696
+ name: "bash",
1697
+ inputSchema: z6.object({
1698
+ command: z6.string(),
1699
+ restart: z6.boolean().optional()
1700
+ })
1701
+ });
1702
+
1703
+ // src/tool/computer_20241022.ts
1704
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
1705
+ import { z as z7 } from "zod/v4";
1706
+ var computer_20241022 = createProviderDefinedToolFactory3({
1707
+ id: "anthropic.computer_20241022",
1708
+ name: "computer",
1709
+ inputSchema: z7.object({
1710
+ action: z7.enum([
1711
+ "key",
1712
+ "type",
1713
+ "mouse_move",
1714
+ "left_click",
1715
+ "left_click_drag",
1716
+ "right_click",
1717
+ "middle_click",
1718
+ "double_click",
1719
+ "screenshot",
1720
+ "cursor_position"
1721
+ ]),
1722
+ coordinate: z7.array(z7.number().int()).optional(),
1723
+ text: z7.string().optional()
1724
+ })
1725
+ });
1726
+
1727
+ // src/tool/computer_20250124.ts
1728
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
1729
+ import { z as z8 } from "zod/v4";
1730
+ var computer_20250124 = createProviderDefinedToolFactory4({
1731
+ id: "anthropic.computer_20250124",
1732
+ name: "computer",
1733
+ inputSchema: z8.object({
1734
+ action: z8.enum([
1735
+ "key",
1736
+ "hold_key",
1737
+ "type",
1738
+ "cursor_position",
1739
+ "mouse_move",
1740
+ "left_mouse_down",
1741
+ "left_mouse_up",
1742
+ "left_click",
1743
+ "left_click_drag",
1744
+ "right_click",
1745
+ "middle_click",
1746
+ "double_click",
1747
+ "triple_click",
1748
+ "scroll",
1749
+ "wait",
1750
+ "screenshot"
1751
+ ]),
1752
+ coordinate: z8.tuple([z8.number().int(), z8.number().int()]).optional(),
1753
+ duration: z8.number().optional(),
1754
+ scroll_amount: z8.number().optional(),
1755
+ scroll_direction: z8.enum(["up", "down", "left", "right"]).optional(),
1756
+ start_coordinate: z8.tuple([z8.number().int(), z8.number().int()]).optional(),
1757
+ text: z8.string().optional()
1758
+ })
1759
+ });
1760
+
1761
+ // src/tool/text-editor_20241022.ts
1762
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
1763
+ import { z as z9 } from "zod/v4";
1764
+ var textEditor_20241022 = createProviderDefinedToolFactory5({
1765
+ id: "anthropic.text_editor_20241022",
1766
+ name: "str_replace_editor",
1767
+ inputSchema: z9.object({
1768
+ command: z9.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1769
+ path: z9.string(),
1770
+ file_text: z9.string().optional(),
1771
+ insert_line: z9.number().int().optional(),
1772
+ new_str: z9.string().optional(),
1773
+ old_str: z9.string().optional(),
1774
+ view_range: z9.array(z9.number().int()).optional()
1775
+ })
1776
+ });
1777
+
1778
+ // src/tool/text-editor_20250124.ts
1779
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
1780
+ import { z as z10 } from "zod/v4";
1781
+ var textEditor_20250124 = createProviderDefinedToolFactory6({
1782
+ id: "anthropic.text_editor_20250124",
1783
+ name: "str_replace_editor",
1784
+ inputSchema: z10.object({
1785
+ command: z10.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1786
+ path: z10.string(),
1787
+ file_text: z10.string().optional(),
1788
+ insert_line: z10.number().int().optional(),
1789
+ new_str: z10.string().optional(),
1790
+ old_str: z10.string().optional(),
1791
+ view_range: z10.array(z10.number().int()).optional()
1792
+ })
1793
+ });
1794
+
1795
+ // src/tool/text-editor_20250429.ts
1796
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
1797
+ import { z as z11 } from "zod/v4";
1798
+ var textEditor_20250429 = createProviderDefinedToolFactory7({
1799
+ id: "anthropic.text_editor_20250429",
1800
+ name: "str_replace_based_edit_tool",
1801
+ inputSchema: z11.object({
1802
+ command: z11.enum(["view", "create", "str_replace", "insert"]),
1803
+ path: z11.string(),
1804
+ file_text: z11.string().optional(),
1805
+ insert_line: z11.number().int().optional(),
1806
+ new_str: z11.string().optional(),
1807
+ old_str: z11.string().optional(),
1808
+ view_range: z11.array(z11.number().int()).optional()
1809
+ })
1810
+ });
1811
+
1812
+ // src/anthropic-tools.ts
1813
+ var anthropicTools = {
1814
+ /**
1815
+ * Creates a tool for running a bash command. Must have name "bash".
1816
+ *
1817
+ * Image results are supported.
1818
+ *
1819
+ * @param execute - The function to execute the tool. Optional.
1820
+ */
1821
+ bash_20241022,
1822
+ /**
1823
+ * Creates a tool for running a bash command. Must have name "bash".
1824
+ *
1825
+ * Image results are supported.
1826
+ *
1827
+ * @param execute - The function to execute the tool. Optional.
1828
+ */
1829
+ bash_20250124,
1830
+ /**
1831
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1832
+ */
1833
+ textEditor_20241022,
1834
+ /**
1835
+ * Creates a tool for editing text. Must have name "str_replace_editor".
1836
+ */
1837
+ textEditor_20250124,
1838
+ /**
1839
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
1840
+ * Note: This version does not support the "undo_edit" command.
1841
+ */
1842
+ textEditor_20250429,
1843
+ /**
1844
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1845
+ *
1846
+ * Image results are supported.
1847
+ *
1848
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1849
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1850
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1851
+ */
1852
+ computer_20241022,
1853
+ /**
1854
+ * Creates a tool for executing actions on a computer. Must have name "computer".
1855
+ *
1856
+ * Image results are supported.
1857
+ *
1858
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
1859
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
1860
+ * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
1861
+ * @param execute - The function to execute the tool. Optional.
1862
+ */
1863
+ computer_20250124,
1864
+ /**
1865
+ * Creates a web search tool that gives Claude direct access to real-time web content.
1866
+ * Must have name "web_search".
1867
+ *
1868
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
1869
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
1870
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
1871
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
1872
+ */
1873
+ webSearch_20250305
1874
+ };
1875
+ export {
1876
+ AnthropicMessagesLanguageModel,
1877
+ anthropicTools,
1878
+ prepareTools
1879
+ };
1880
+ //# sourceMappingURL=index.mjs.map
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/internal.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from './dist/internal';
node_modules/.pnpm/@ai-sdk+anthropic@2.0.1_zod@3.25.76/node_modules/@ai-sdk/anthropic/package.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@ai-sdk/anthropic",
3
+ "version": "2.0.1",
4
+ "license": "Apache-2.0",
5
+ "sideEffects": false,
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist/**/*",
11
+ "CHANGELOG.md",
12
+ "internal.d.ts"
13
+ ],
14
+ "exports": {
15
+ "./package.json": "./package.json",
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.js"
20
+ },
21
+ "./internal": {
22
+ "types": "./dist/internal/index.d.ts",
23
+ "import": "./dist/internal/index.mjs",
24
+ "module": "./dist/internal/index.mjs",
25
+ "require": "./dist/internal/index.js"
26
+ }
27
+ },
28
+ "dependencies": {
29
+ "@ai-sdk/provider": "2.0.0",
30
+ "@ai-sdk/provider-utils": "3.0.1"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "20.17.24",
34
+ "tsup": "^8",
35
+ "typescript": "5.8.3",
36
+ "zod": "3.25.76",
37
+ "@vercel/ai-tsconfig": "0.0.0"
38
+ },
39
+ "peerDependencies": {
40
+ "zod": "^3.25.76 || ^4"
41
+ },
42
+ "engines": {
43
+ "node": ">=18"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "homepage": "https://ai-sdk.dev/docs",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/vercel/ai.git"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/vercel/ai/issues"
55
+ },
56
+ "keywords": [
57
+ "ai"
58
+ ],
59
+ "scripts": {
60
+ "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
61
+ "build:watch": "pnpm clean && tsup --watch --tsconfig tsconfig.build.json",
62
+ "clean": "rm -rf dist *.tsbuildinfo",
63
+ "lint": "eslint \"./**/*.ts*\"",
64
+ "type-check": "tsc --build",
65
+ "prettier-check": "prettier --check \"./**/*.ts*\"",
66
+ "test": "pnpm test:node && pnpm test:edge",
67
+ "test:update": "pnpm test:node -u",
68
+ "test:watch": "vitest --config vitest.node.config.js",
69
+ "test:edge": "vitest --config vitest.edge.config.js --run",
70
+ "test:node": "vitest --config vitest.node.config.js --run"
71
+ }
72
+ }
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/CHANGELOG.md ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @ai-sdk/gateway
2
+
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 35f93ce: feat (provider/gateway): add new model ids
8
+
9
+ ## 1.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 893aed6: feat (provider/gateway): add anthropic claude 4.1 opus model id
14
+
15
+ ## 1.0.2
16
+
17
+ ### Patch Changes
18
+
19
+ - 444df49: feat (provider/gateway): update model ids
20
+
21
+ ## 1.0.1
22
+
23
+ ### Patch Changes
24
+
25
+ - 028fb9c: refactor(provider/gateway): Cleanup old gateway-embedding-options file
26
+ - 6331826: feat(provider/gateway): Hide Cohere embedding models with no pricing info
27
+ - Updated dependencies [90d212f]
28
+ - @ai-sdk/provider-utils@3.0.1
29
+
30
+ ## 1.0.0
31
+
32
+ ### Patch Changes
33
+
34
+ - 9e16bfd: feat (provider/gateway): update model ids
35
+ - 0477a13: feat (provider/gateway): Add OpenAI embedding support
36
+ - 26b6dd0: feat (providers/gateway): include deployment and request id
37
+ - 30ab1de: feat (provider/gateway): add grok-4 model id
38
+ - e2aceaf: feat: add raw chunk support
39
+ - 97fedf9: feat (providers/gateway): include description and pricing info in model list
40
+ - c91586a: chore (providers/gateway): update language model ids
41
+ - 3cbcbb7: feat (providers/gateway): share common gateway error transform logic
42
+ - fedb55e: feat (provider/gateway): add z.ai and glm-4.5 models
43
+ - 6c2c708: feat (providers/gateway): initial gateway provider
44
+ - 721775e: feat(provider/gateway): Generate new Gateway embedding model settings file
45
+ - 70ebead: feat (provider/gateway): add qwen3 coder model id
46
+ - f3639fa: feat (providers/gateway): improve oidc api key client auth flow
47
+ - 8bd3624: feat (provider/gateway): update model ids to include vercel
48
+ - c145d62: feat (providers/gateway): add createGateway shorthand alias for createGatewayProvider
49
+ - f77bc38: chore (providers/gateway): update language model ids
50
+ - 989ac75: chore (providers/gateway): update chat model ids
51
+ - 7742ba3: feat (providers/gateway): add gateway error types with error detail
52
+ - c190907: fix (provider/gateway): use zod v4
53
+ - d1a034f: feature: using Zod 4 for internal stuff
54
+ - d454e4b: fix (providers/gateway): fix timestamp error when streaming objects
55
+ - cf1e00e: feat (provider/gateway): add devstral model id
56
+ - cc21603: feat (provider/gateway): Add AI Gateway provider options (ordering)
57
+ - 205077b: fix: improve Zod compatibility
58
+ - e001ea1: fix (provider/gateway): remove unnecessary 'x-' prefix on auth method header
59
+ - 27deb4d: feat (provider/gateway): Add providerMetadata to embeddings response
60
+ - Updated dependencies [a571d6e]
61
+ - Updated dependencies [742b7be]
62
+ - Updated dependencies [e7fcc86]
63
+ - Updated dependencies [7cddb72]
64
+ - Updated dependencies [ccce59b]
65
+ - Updated dependencies [e2b9e4b]
66
+ - Updated dependencies [95857aa]
67
+ - Updated dependencies [45c1ea2]
68
+ - Updated dependencies [6f6bb89]
69
+ - Updated dependencies [060370c]
70
+ - Updated dependencies [dc714f3]
71
+ - Updated dependencies [b5da06a]
72
+ - Updated dependencies [d1a1aa1]
73
+ - Updated dependencies [63f9e9b]
74
+ - Updated dependencies [5d142ab]
75
+ - Updated dependencies [d5f588f]
76
+ - Updated dependencies [e025824]
77
+ - Updated dependencies [0571b98]
78
+ - Updated dependencies [b6b43c7]
79
+ - Updated dependencies [4fef487]
80
+ - Updated dependencies [48d257a]
81
+ - Updated dependencies [0c0c0b3]
82
+ - Updated dependencies [0d2c085]
83
+ - Updated dependencies [40acf9b]
84
+ - Updated dependencies [9222aeb]
85
+ - Updated dependencies [e2aceaf]
86
+ - Updated dependencies [411e483]
87
+ - Updated dependencies [8ba77a7]
88
+ - Updated dependencies [7b3ae3f]
89
+ - Updated dependencies [a166433]
90
+ - Updated dependencies [26735b5]
91
+ - Updated dependencies [443d8ec]
92
+ - Updated dependencies [a8c8bd5]
93
+ - Updated dependencies [abf9a79]
94
+ - Updated dependencies [14c9410]
95
+ - Updated dependencies [e86be6f]
96
+ - Updated dependencies [9bf7291]
97
+ - Updated dependencies [2e13791]
98
+ - Updated dependencies [9f95b35]
99
+ - Updated dependencies [66962ed]
100
+ - Updated dependencies [0d06df6]
101
+ - Updated dependencies [472524a]
102
+ - Updated dependencies [dd3ff01]
103
+ - Updated dependencies [d9c98f4]
104
+ - Updated dependencies [05d2819]
105
+ - Updated dependencies [9301f86]
106
+ - Updated dependencies [0a87932]
107
+ - Updated dependencies [c4a2fec]
108
+ - Updated dependencies [957b739]
109
+ - Updated dependencies [79457bd]
110
+ - Updated dependencies [a3f768e]
111
+ - Updated dependencies [7435eb5]
112
+ - Updated dependencies [8aa9e20]
113
+ - Updated dependencies [4617fab]
114
+ - Updated dependencies [ac34802]
115
+ - Updated dependencies [0054544]
116
+ - Updated dependencies [cb68df0]
117
+ - Updated dependencies [ad80501]
118
+ - Updated dependencies [68ecf2f]
119
+ - Updated dependencies [9e9c809]
120
+ - Updated dependencies [32831c6]
121
+ - Updated dependencies [6dc848c]
122
+ - Updated dependencies [6b98118]
123
+ - Updated dependencies [d0f9495]
124
+ - Updated dependencies [63d791d]
125
+ - Updated dependencies [87b828f]
126
+ - Updated dependencies [3f2f00c]
127
+ - Updated dependencies [bfdca8d]
128
+ - Updated dependencies [0ff02bb]
129
+ - Updated dependencies [7979f7f]
130
+ - Updated dependencies [39a4fab]
131
+ - Updated dependencies [44f4aba]
132
+ - Updated dependencies [9bd5ab5]
133
+ - Updated dependencies [57edfcb]
134
+ - Updated dependencies [faf8446]
135
+ - Updated dependencies [7ea4132]
136
+ - Updated dependencies [d1a034f]
137
+ - Updated dependencies [5c56081]
138
+ - Updated dependencies [fd65bc6]
139
+ - Updated dependencies [023ba40]
140
+ - Updated dependencies [ea7a7c9]
141
+ - Updated dependencies [26535e0]
142
+ - Updated dependencies [e030615]
143
+ - Updated dependencies [5e57fae]
144
+ - Updated dependencies [393138b]
145
+ - Updated dependencies [c57e248]
146
+ - Updated dependencies [88a8ee5]
147
+ - Updated dependencies [41fa418]
148
+ - Updated dependencies [205077b]
149
+ - Updated dependencies [71f938d]
150
+ - Updated dependencies [3795467]
151
+ - Updated dependencies [28a5ed5]
152
+ - Updated dependencies [7182d14]
153
+ - Updated dependencies [c1e6647]
154
+ - Updated dependencies [1766ede]
155
+ - Updated dependencies [811dff3]
156
+ - Updated dependencies [f10304b]
157
+ - Updated dependencies [dd5fd43]
158
+ - Updated dependencies [33f4a6a]
159
+ - Updated dependencies [383cbfa]
160
+ - Updated dependencies [27deb4d]
161
+ - Updated dependencies [c4df419]
162
+ - @ai-sdk/provider-utils@3.0.0
163
+ - @ai-sdk/provider@2.0.0
164
+
165
+ ## 1.0.0-beta.19
166
+
167
+ ### Patch Changes
168
+
169
+ - 721775e: feat(provider/gateway): Generate new Gateway embedding model settings file
170
+ - Updated dependencies [88a8ee5]
171
+ - @ai-sdk/provider-utils@3.0.0-beta.10
172
+
173
+ ## 1.0.0-beta.18
174
+
175
+ ### Patch Changes
176
+
177
+ - 27deb4d: feat (provider/gateway): Add providerMetadata to embeddings response
178
+ - Updated dependencies [27deb4d]
179
+ - @ai-sdk/provider@2.0.0-beta.2
180
+ - @ai-sdk/provider-utils@3.0.0-beta.9
181
+
182
+ ## 1.0.0-beta.17
183
+
184
+ ### Patch Changes
185
+
186
+ - Updated dependencies [dd5fd43]
187
+ - @ai-sdk/provider-utils@3.0.0-beta.8
188
+
189
+ ## 1.0.0-beta.16
190
+
191
+ ### Patch Changes
192
+
193
+ - fedb55e: feat (provider/gateway): add z.ai and glm-4.5 models
194
+
195
+ ## 1.0.0-beta.15
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies [e7fcc86]
200
+ - @ai-sdk/provider-utils@3.0.0-beta.7
201
+
202
+ ## 1.0.0-beta.14
203
+
204
+ ### Patch Changes
205
+
206
+ - Updated dependencies [ac34802]
207
+ - @ai-sdk/provider-utils@3.0.0-beta.6
208
+
209
+ ## 1.0.0-beta.13
210
+
211
+ ### Patch Changes
212
+
213
+ - 0477a13: feat (provider/gateway): Add OpenAI embedding support
214
+ - cf1e00e: feat (provider/gateway): add devstral model id
215
+ - cc21603: feat (provider/gateway): Add AI Gateway provider options (ordering)
216
+
217
+ ## 1.0.0-beta.12
218
+
219
+ ### Patch Changes
220
+
221
+ - 70ebead: feat (provider/gateway): add qwen3 coder model id
222
+
223
+ ## 1.0.0-beta.11
224
+
225
+ ### Patch Changes
226
+
227
+ - 8bd3624: feat (provider/gateway): update model ids to include vercel
228
+ - e001ea1: fix (provider/gateway): remove unnecessary 'x-' prefix on auth method header
229
+
230
+ ## 1.0.0-beta.10
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies [57edfcb]
235
+ - Updated dependencies [383cbfa]
236
+ - @ai-sdk/provider-utils@3.0.0-beta.5
237
+
238
+ ## 1.0.0-beta.9
239
+
240
+ ### Patch Changes
241
+
242
+ - 205077b: fix: improve Zod compatibility
243
+ - Updated dependencies [205077b]
244
+ - @ai-sdk/provider-utils@3.0.0-beta.4
245
+
246
+ ## 1.0.0-beta.8
247
+
248
+ ### Patch Changes
249
+
250
+ - Updated dependencies [05d2819]
251
+ - @ai-sdk/provider-utils@3.0.0-beta.3
252
+
253
+ ## 1.0.0-beta.7
254
+
255
+ ### Patch Changes
256
+
257
+ - c190907: fix (provider/gateway): use zod v4
258
+
259
+ ## 1.0.0-beta.6
260
+
261
+ ### Patch Changes
262
+
263
+ - 9e16bfd: feat (provider/gateway): update model ids
264
+
265
+ ## 1.0.0-beta.5
266
+
267
+ ### Patch Changes
268
+
269
+ - 30ab1de: feat (provider/gateway): add grok-4 model id
270
+
271
+ ## 1.0.0-beta.4
272
+
273
+ ### Patch Changes
274
+
275
+ - 97fedf9: feat (providers/gateway): include description and pricing info in model list
276
+
277
+ ## 1.0.0-beta.3
278
+
279
+ ### Patch Changes
280
+
281
+ - f3639fa: feat (providers/gateway): improve oidc api key client auth flow
282
+ - d454e4b: fix (providers/gateway): fix timestamp error when streaming objects
283
+
284
+ ## 1.0.0-beta.2
285
+
286
+ ### Patch Changes
287
+
288
+ - c91586a: chore (providers/gateway): update language model ids
289
+ - d1a034f: feature: using Zod 4 for internal stuff
290
+ - Updated dependencies [0571b98]
291
+ - Updated dependencies [39a4fab]
292
+ - Updated dependencies [d1a034f]
293
+ - @ai-sdk/provider-utils@3.0.0-beta.2
294
+
295
+ ## 1.0.0-beta.1
296
+
297
+ ### Patch Changes
298
+
299
+ - f77bc38: chore (providers/gateway): update language model ids
300
+ - Updated dependencies [742b7be]
301
+ - Updated dependencies [7cddb72]
302
+ - Updated dependencies [ccce59b]
303
+ - Updated dependencies [e2b9e4b]
304
+ - Updated dependencies [45c1ea2]
305
+ - Updated dependencies [e025824]
306
+ - Updated dependencies [0d06df6]
307
+ - Updated dependencies [472524a]
308
+ - Updated dependencies [dd3ff01]
309
+ - Updated dependencies [7435eb5]
310
+ - Updated dependencies [cb68df0]
311
+ - Updated dependencies [bfdca8d]
312
+ - Updated dependencies [44f4aba]
313
+ - Updated dependencies [023ba40]
314
+ - Updated dependencies [5e57fae]
315
+ - Updated dependencies [71f938d]
316
+ - Updated dependencies [28a5ed5]
317
+ - @ai-sdk/provider@2.0.0-beta.1
318
+ - @ai-sdk/provider-utils@3.0.0-beta.1
319
+
320
+ ## 1.0.0-alpha.15
321
+
322
+ ### Patch Changes
323
+
324
+ - c145d62: feat (providers/gateway): add createGateway shorthand alias for createGatewayProvider
325
+ - Updated dependencies [48d257a]
326
+ - Updated dependencies [8ba77a7]
327
+ - @ai-sdk/provider@2.0.0-alpha.15
328
+ - @ai-sdk/provider-utils@3.0.0-alpha.15
329
+
330
+ ## 1.0.0-alpha.14
331
+
332
+ ### Patch Changes
333
+
334
+ - Updated dependencies [b5da06a]
335
+ - Updated dependencies [63f9e9b]
336
+ - Updated dependencies [2e13791]
337
+ - @ai-sdk/provider@2.0.0-alpha.14
338
+ - @ai-sdk/provider-utils@3.0.0-alpha.14
339
+
340
+ ## 1.0.0-alpha.13
341
+
342
+ ### Patch Changes
343
+
344
+ - Updated dependencies [68ecf2f]
345
+ - @ai-sdk/provider@2.0.0-alpha.13
346
+ - @ai-sdk/provider-utils@3.0.0-alpha.13
347
+
348
+ ## 1.0.0-alpha.12
349
+
350
+ ### Patch Changes
351
+
352
+ - e2aceaf: feat: add raw chunk support
353
+ - Updated dependencies [e2aceaf]
354
+ - @ai-sdk/provider@2.0.0-alpha.12
355
+ - @ai-sdk/provider-utils@3.0.0-alpha.12
356
+
357
+ ## 1.0.0-alpha.11
358
+
359
+ ### Patch Changes
360
+
361
+ - Updated dependencies [c1e6647]
362
+ - @ai-sdk/provider@2.0.0-alpha.11
363
+ - @ai-sdk/provider-utils@3.0.0-alpha.11
364
+
365
+ ## 1.0.0-alpha.10
366
+
367
+ ### Patch Changes
368
+
369
+ - Updated dependencies [c4df419]
370
+ - @ai-sdk/provider@2.0.0-alpha.10
371
+ - @ai-sdk/provider-utils@3.0.0-alpha.10
372
+
373
+ ## 1.0.0-alpha.9
374
+
375
+ ### Patch Changes
376
+
377
+ - 26b6dd0: feat (providers/gateway): include deployment and request id
378
+ - Updated dependencies [811dff3]
379
+ - @ai-sdk/provider@2.0.0-alpha.9
380
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
381
+
382
+ ## 1.0.0-alpha.8
383
+
384
+ ### Patch Changes
385
+
386
+ - 3cbcbb7: feat (providers/gateway): share common gateway error transform logic
387
+ - 989ac75: chore (providers/gateway): update chat model ids
388
+ - 7742ba3: feat (providers/gateway): add gateway error types with error detail
389
+ - Updated dependencies [4fef487]
390
+ - Updated dependencies [9222aeb]
391
+ - @ai-sdk/provider-utils@3.0.0-alpha.8
392
+ - @ai-sdk/provider@2.0.0-alpha.8
393
+
394
+ ## 1.0.0-alpha.7
395
+
396
+ ### Patch Changes
397
+
398
+ - Updated dependencies [5c56081]
399
+ - @ai-sdk/provider@2.0.0-alpha.7
400
+ - @ai-sdk/provider-utils@3.0.0-alpha.7
401
+
402
+ ## 1.0.0-alpha.6
403
+
404
+ ### Patch Changes
405
+
406
+ - 6c2c708: feat (providers/gateway): initial gateway provider
407
+ - Updated dependencies [0d2c085]
408
+ - @ai-sdk/provider@2.0.0-alpha.6
409
+ - @ai-sdk/provider-utils@3.0.0-alpha.6
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/LICENSE ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI SDK - Gateway Provider
2
+
3
+ The Gateway provider for the [AI SDK](https://ai-sdk.dev/docs) allows the use of a wide variety of AI models and providers.
4
+
5
+ ## Setup
6
+
7
+ The Gateway provider is available in the `@ai-sdk/gateway` module. You can install it with
8
+
9
+ ```bash
10
+ npm i @ai-sdk/gateway
11
+ ```
12
+
13
+ ## Provider Instance
14
+
15
+ You can import the default provider instance `gateway` from `@ai-sdk/gateway`:
16
+
17
+ ```ts
18
+ import { gateway } from '@ai-sdk/gateway';
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```ts
24
+ import { gateway } from '@ai-sdk/gateway';
25
+ import { generateText } from 'ai';
26
+
27
+ const { text } = await generateText({
28
+ model: gateway('xai/grok-3-beta'),
29
+ prompt:
30
+ 'Tell me about the history of the San Francisco Mission-style burrito.',
31
+ });
32
+ ```
33
+
34
+ ## Documentation
35
+
36
+ Please check out the [AI SDK documentation](https://ai-sdk.dev/docs) for more information.
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.d.mts ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { LanguageModelV2, ProviderV2, EmbeddingModelV2 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { z, ZodError } from 'zod/v4';
4
+
5
+ type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-coder' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-4-opus' | 'anthropic/claude-4-sonnet' | 'anthropic/claude-4.1-opus' | 'cohere/command-a' | 'cohere/command-r' | 'cohere/command-r-plus' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-r1-distill-llama-70b' | 'deepseek/deepseek-v3' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-pro' | 'google/gemma-2-9b' | 'inception/mercury-coder-small' | 'meta/llama-3-70b' | 'meta/llama-3-8b' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'mistral/codestral' | 'mistral/devstral-small' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large' | 'mistral/mistral-saba-24b' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-5' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | (string & {});
6
+
7
+ interface GatewayLanguageModelEntry {
8
+ /**
9
+ * The model id used by the remote provider in model settings and for specifying the
10
+ * intended model for text generation.
11
+ */
12
+ id: string;
13
+ /**
14
+ * The display name of the model for presentation in user-facing contexts.
15
+ */
16
+ name: string;
17
+ /**
18
+ * Optional description of the model.
19
+ */
20
+ description?: string | null;
21
+ /**
22
+ * Optional pricing information for the model.
23
+ */
24
+ pricing?: {
25
+ /**
26
+ * Cost per input token in USD.
27
+ */
28
+ input: string;
29
+ /**
30
+ * Cost per output token in USD.
31
+ */
32
+ output: string;
33
+ } | null;
34
+ /**
35
+ * Additional AI SDK language model specifications for the model.
36
+ */
37
+ specification: GatewayLanguageModelSpecification;
38
+ }
39
+ type GatewayLanguageModelSpecification = Pick<LanguageModelV2, 'specificationVersion' | 'provider' | 'modelId'>;
40
+
41
+ interface GatewayFetchMetadataResponse {
42
+ models: GatewayLanguageModelEntry[];
43
+ }
44
+
45
+ type GatewayEmbeddingModelId = 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | (string & {});
46
+
47
+ interface GatewayProvider extends ProviderV2 {
48
+ (modelId: GatewayModelId): LanguageModelV2;
49
+ /**
50
+ Creates a model for text generation.
51
+ */
52
+ languageModel(modelId: GatewayModelId): LanguageModelV2;
53
+ /**
54
+ Returns available providers and models for use with the remote provider.
55
+ */
56
+ getAvailableModels(): Promise<GatewayFetchMetadataResponse>;
57
+ /**
58
+ Creates a model for generating text embeddings.
59
+ */
60
+ textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV2<string>;
61
+ }
62
+ interface GatewayProviderSettings {
63
+ /**
64
+ The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.
65
+ */
66
+ baseURL?: string;
67
+ /**
68
+ API key that is being sent using the `Authorization` header.
69
+ */
70
+ apiKey?: string;
71
+ /**
72
+ Custom headers to include in the requests.
73
+ */
74
+ headers?: Record<string, string>;
75
+ /**
76
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
77
+ or to provide a custom fetch implementation for e.g. testing.
78
+ */
79
+ fetch?: FetchFunction;
80
+ /**
81
+ How frequently to refresh the metadata cache in milliseconds.
82
+ */
83
+ metadataCacheRefreshMillis?: number;
84
+ }
85
+ /**
86
+ Create a remote provider instance.
87
+ */
88
+ declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
89
+ declare const gateway: GatewayProvider;
90
+
91
+ declare const gatewayProviderOptions: z.ZodObject<{
92
+ order: z.ZodOptional<z.ZodArray<z.ZodString>>;
93
+ }, z.core.$strip>;
94
+ type GatewayProviderOptions = z.infer<typeof gatewayProviderOptions>;
95
+
96
+ declare const symbol$6: unique symbol;
97
+ declare abstract class GatewayError extends Error {
98
+ private readonly [symbol$6];
99
+ abstract readonly name: string;
100
+ abstract readonly type: string;
101
+ readonly statusCode: number;
102
+ readonly cause?: unknown;
103
+ constructor({ message, statusCode, cause, }: {
104
+ message: string;
105
+ statusCode?: number;
106
+ cause?: unknown;
107
+ });
108
+ /**
109
+ * Checks if the given error is a Gateway Error.
110
+ * @param {unknown} error - The error to check.
111
+ * @returns {boolean} True if the error is a Gateway Error, false otherwise.
112
+ */
113
+ static isInstance(error: unknown): error is GatewayError;
114
+ static hasMarker(error: unknown): error is GatewayError;
115
+ }
116
+
117
+ declare const gatewayErrorResponseSchema: z.ZodObject<{
118
+ error: z.ZodObject<{
119
+ message: z.ZodString;
120
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
121
+ param: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
122
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
123
+ }, z.core.$strip>;
124
+ }, z.core.$strip>;
125
+ type GatewayErrorResponse = z.infer<typeof gatewayErrorResponseSchema>;
126
+
127
+ declare const symbol$5: unique symbol;
128
+ /**
129
+ * Authentication failed - invalid API key or OIDC token
130
+ */
131
+ declare class GatewayAuthenticationError extends GatewayError {
132
+ private readonly [symbol$5];
133
+ readonly name = "GatewayAuthenticationError";
134
+ readonly type = "authentication_error";
135
+ constructor({ message, statusCode, cause, }?: {
136
+ message?: string;
137
+ statusCode?: number;
138
+ cause?: unknown;
139
+ });
140
+ static isInstance(error: unknown): error is GatewayAuthenticationError;
141
+ /**
142
+ * Creates a contextual error message when authentication fails
143
+ */
144
+ static createContextualError({ apiKeyProvided, oidcTokenProvided, message, statusCode, cause, }: {
145
+ apiKeyProvided: boolean;
146
+ oidcTokenProvided: boolean;
147
+ message?: string;
148
+ statusCode?: number;
149
+ cause?: unknown;
150
+ }): GatewayAuthenticationError;
151
+ }
152
+
153
+ declare const symbol$4: unique symbol;
154
+ /**
155
+ * Internal server error from the Gateway
156
+ */
157
+ declare class GatewayInternalServerError extends GatewayError {
158
+ private readonly [symbol$4];
159
+ readonly name = "GatewayInternalServerError";
160
+ readonly type = "internal_server_error";
161
+ constructor({ message, statusCode, cause, }?: {
162
+ message?: string;
163
+ statusCode?: number;
164
+ cause?: unknown;
165
+ });
166
+ static isInstance(error: unknown): error is GatewayInternalServerError;
167
+ }
168
+
169
+ declare const symbol$3: unique symbol;
170
+ /**
171
+ * Invalid request - missing headers, malformed data, etc.
172
+ */
173
+ declare class GatewayInvalidRequestError extends GatewayError {
174
+ private readonly [symbol$3];
175
+ readonly name = "GatewayInvalidRequestError";
176
+ readonly type = "invalid_request_error";
177
+ constructor({ message, statusCode, cause, }?: {
178
+ message?: string;
179
+ statusCode?: number;
180
+ cause?: unknown;
181
+ });
182
+ static isInstance(error: unknown): error is GatewayInvalidRequestError;
183
+ }
184
+
185
+ declare const symbol$2: unique symbol;
186
+ /**
187
+ * Model not found or not available
188
+ */
189
+ declare class GatewayModelNotFoundError extends GatewayError {
190
+ private readonly [symbol$2];
191
+ readonly name = "GatewayModelNotFoundError";
192
+ readonly type = "model_not_found";
193
+ readonly modelId?: string;
194
+ constructor({ message, statusCode, modelId, cause, }?: {
195
+ message?: string;
196
+ statusCode?: number;
197
+ modelId?: string;
198
+ cause?: unknown;
199
+ });
200
+ static isInstance(error: unknown): error is GatewayModelNotFoundError;
201
+ }
202
+
203
+ declare const symbol$1: unique symbol;
204
+ /**
205
+ * Rate limit exceeded.
206
+ */
207
+ declare class GatewayRateLimitError extends GatewayError {
208
+ private readonly [symbol$1];
209
+ readonly name = "GatewayRateLimitError";
210
+ readonly type = "rate_limit_exceeded";
211
+ constructor({ message, statusCode, cause, }?: {
212
+ message?: string;
213
+ statusCode?: number;
214
+ cause?: unknown;
215
+ });
216
+ static isInstance(error: unknown): error is GatewayRateLimitError;
217
+ }
218
+
219
+ declare const symbol: unique symbol;
220
+ /**
221
+ * Gateway response parsing error
222
+ */
223
+ declare class GatewayResponseError extends GatewayError {
224
+ private readonly [symbol];
225
+ readonly name = "GatewayResponseError";
226
+ readonly type = "response_error";
227
+ readonly response?: unknown;
228
+ readonly validationError?: ZodError;
229
+ constructor({ message, statusCode, response, validationError, cause, }?: {
230
+ message?: string;
231
+ statusCode?: number;
232
+ response?: unknown;
233
+ validationError?: ZodError;
234
+ cause?: unknown;
235
+ });
236
+ static isInstance(error: unknown): error is GatewayResponseError;
237
+ }
238
+
239
+ export { GatewayAuthenticationError, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, createGatewayProvider as createGateway, createGatewayProvider, gateway };
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.d.ts ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { LanguageModelV2, ProviderV2, EmbeddingModelV2 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { z, ZodError } from 'zod/v4';
4
+
5
+ type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-coder' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-4-opus' | 'anthropic/claude-4-sonnet' | 'anthropic/claude-4.1-opus' | 'cohere/command-a' | 'cohere/command-r' | 'cohere/command-r-plus' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-r1-distill-llama-70b' | 'deepseek/deepseek-v3' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-pro' | 'google/gemma-2-9b' | 'inception/mercury-coder-small' | 'meta/llama-3-70b' | 'meta/llama-3-8b' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'mistral/codestral' | 'mistral/devstral-small' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large' | 'mistral/mistral-saba-24b' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-5' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | (string & {});
6
+
7
+ interface GatewayLanguageModelEntry {
8
+ /**
9
+ * The model id used by the remote provider in model settings and for specifying the
10
+ * intended model for text generation.
11
+ */
12
+ id: string;
13
+ /**
14
+ * The display name of the model for presentation in user-facing contexts.
15
+ */
16
+ name: string;
17
+ /**
18
+ * Optional description of the model.
19
+ */
20
+ description?: string | null;
21
+ /**
22
+ * Optional pricing information for the model.
23
+ */
24
+ pricing?: {
25
+ /**
26
+ * Cost per input token in USD.
27
+ */
28
+ input: string;
29
+ /**
30
+ * Cost per output token in USD.
31
+ */
32
+ output: string;
33
+ } | null;
34
+ /**
35
+ * Additional AI SDK language model specifications for the model.
36
+ */
37
+ specification: GatewayLanguageModelSpecification;
38
+ }
39
+ type GatewayLanguageModelSpecification = Pick<LanguageModelV2, 'specificationVersion' | 'provider' | 'modelId'>;
40
+
41
+ interface GatewayFetchMetadataResponse {
42
+ models: GatewayLanguageModelEntry[];
43
+ }
44
+
45
+ type GatewayEmbeddingModelId = 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | (string & {});
46
+
47
+ interface GatewayProvider extends ProviderV2 {
48
+ (modelId: GatewayModelId): LanguageModelV2;
49
+ /**
50
+ Creates a model for text generation.
51
+ */
52
+ languageModel(modelId: GatewayModelId): LanguageModelV2;
53
+ /**
54
+ Returns available providers and models for use with the remote provider.
55
+ */
56
+ getAvailableModels(): Promise<GatewayFetchMetadataResponse>;
57
+ /**
58
+ Creates a model for generating text embeddings.
59
+ */
60
+ textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV2<string>;
61
+ }
62
+ interface GatewayProviderSettings {
63
+ /**
64
+ The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.
65
+ */
66
+ baseURL?: string;
67
+ /**
68
+ API key that is being sent using the `Authorization` header.
69
+ */
70
+ apiKey?: string;
71
+ /**
72
+ Custom headers to include in the requests.
73
+ */
74
+ headers?: Record<string, string>;
75
+ /**
76
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
77
+ or to provide a custom fetch implementation for e.g. testing.
78
+ */
79
+ fetch?: FetchFunction;
80
+ /**
81
+ How frequently to refresh the metadata cache in milliseconds.
82
+ */
83
+ metadataCacheRefreshMillis?: number;
84
+ }
85
+ /**
86
+ Create a remote provider instance.
87
+ */
88
+ declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
89
+ declare const gateway: GatewayProvider;
90
+
91
+ declare const gatewayProviderOptions: z.ZodObject<{
92
+ order: z.ZodOptional<z.ZodArray<z.ZodString>>;
93
+ }, z.core.$strip>;
94
+ type GatewayProviderOptions = z.infer<typeof gatewayProviderOptions>;
95
+
96
+ declare const symbol$6: unique symbol;
97
+ declare abstract class GatewayError extends Error {
98
+ private readonly [symbol$6];
99
+ abstract readonly name: string;
100
+ abstract readonly type: string;
101
+ readonly statusCode: number;
102
+ readonly cause?: unknown;
103
+ constructor({ message, statusCode, cause, }: {
104
+ message: string;
105
+ statusCode?: number;
106
+ cause?: unknown;
107
+ });
108
+ /**
109
+ * Checks if the given error is a Gateway Error.
110
+ * @param {unknown} error - The error to check.
111
+ * @returns {boolean} True if the error is a Gateway Error, false otherwise.
112
+ */
113
+ static isInstance(error: unknown): error is GatewayError;
114
+ static hasMarker(error: unknown): error is GatewayError;
115
+ }
116
+
117
+ declare const gatewayErrorResponseSchema: z.ZodObject<{
118
+ error: z.ZodObject<{
119
+ message: z.ZodString;
120
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
121
+ param: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
122
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
123
+ }, z.core.$strip>;
124
+ }, z.core.$strip>;
125
+ type GatewayErrorResponse = z.infer<typeof gatewayErrorResponseSchema>;
126
+
127
+ declare const symbol$5: unique symbol;
128
+ /**
129
+ * Authentication failed - invalid API key or OIDC token
130
+ */
131
+ declare class GatewayAuthenticationError extends GatewayError {
132
+ private readonly [symbol$5];
133
+ readonly name = "GatewayAuthenticationError";
134
+ readonly type = "authentication_error";
135
+ constructor({ message, statusCode, cause, }?: {
136
+ message?: string;
137
+ statusCode?: number;
138
+ cause?: unknown;
139
+ });
140
+ static isInstance(error: unknown): error is GatewayAuthenticationError;
141
+ /**
142
+ * Creates a contextual error message when authentication fails
143
+ */
144
+ static createContextualError({ apiKeyProvided, oidcTokenProvided, message, statusCode, cause, }: {
145
+ apiKeyProvided: boolean;
146
+ oidcTokenProvided: boolean;
147
+ message?: string;
148
+ statusCode?: number;
149
+ cause?: unknown;
150
+ }): GatewayAuthenticationError;
151
+ }
152
+
153
+ declare const symbol$4: unique symbol;
154
+ /**
155
+ * Internal server error from the Gateway
156
+ */
157
+ declare class GatewayInternalServerError extends GatewayError {
158
+ private readonly [symbol$4];
159
+ readonly name = "GatewayInternalServerError";
160
+ readonly type = "internal_server_error";
161
+ constructor({ message, statusCode, cause, }?: {
162
+ message?: string;
163
+ statusCode?: number;
164
+ cause?: unknown;
165
+ });
166
+ static isInstance(error: unknown): error is GatewayInternalServerError;
167
+ }
168
+
169
+ declare const symbol$3: unique symbol;
170
+ /**
171
+ * Invalid request - missing headers, malformed data, etc.
172
+ */
173
+ declare class GatewayInvalidRequestError extends GatewayError {
174
+ private readonly [symbol$3];
175
+ readonly name = "GatewayInvalidRequestError";
176
+ readonly type = "invalid_request_error";
177
+ constructor({ message, statusCode, cause, }?: {
178
+ message?: string;
179
+ statusCode?: number;
180
+ cause?: unknown;
181
+ });
182
+ static isInstance(error: unknown): error is GatewayInvalidRequestError;
183
+ }
184
+
185
+ declare const symbol$2: unique symbol;
186
+ /**
187
+ * Model not found or not available
188
+ */
189
+ declare class GatewayModelNotFoundError extends GatewayError {
190
+ private readonly [symbol$2];
191
+ readonly name = "GatewayModelNotFoundError";
192
+ readonly type = "model_not_found";
193
+ readonly modelId?: string;
194
+ constructor({ message, statusCode, modelId, cause, }?: {
195
+ message?: string;
196
+ statusCode?: number;
197
+ modelId?: string;
198
+ cause?: unknown;
199
+ });
200
+ static isInstance(error: unknown): error is GatewayModelNotFoundError;
201
+ }
202
+
203
+ declare const symbol$1: unique symbol;
204
+ /**
205
+ * Rate limit exceeded.
206
+ */
207
+ declare class GatewayRateLimitError extends GatewayError {
208
+ private readonly [symbol$1];
209
+ readonly name = "GatewayRateLimitError";
210
+ readonly type = "rate_limit_exceeded";
211
+ constructor({ message, statusCode, cause, }?: {
212
+ message?: string;
213
+ statusCode?: number;
214
+ cause?: unknown;
215
+ });
216
+ static isInstance(error: unknown): error is GatewayRateLimitError;
217
+ }
218
+
219
+ declare const symbol: unique symbol;
220
+ /**
221
+ * Gateway response parsing error
222
+ */
223
+ declare class GatewayResponseError extends GatewayError {
224
+ private readonly [symbol];
225
+ readonly name = "GatewayResponseError";
226
+ readonly type = "response_error";
227
+ readonly response?: unknown;
228
+ readonly validationError?: ZodError;
229
+ constructor({ message, statusCode, response, validationError, cause, }?: {
230
+ message?: string;
231
+ statusCode?: number;
232
+ response?: unknown;
233
+ validationError?: ZodError;
234
+ cause?: unknown;
235
+ });
236
+ static isInstance(error: unknown): error is GatewayResponseError;
237
+ }
238
+
239
+ export { GatewayAuthenticationError, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, createGatewayProvider as createGateway, createGatewayProvider, gateway };
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.js ADDED
@@ -0,0 +1,804 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name7 in all)
8
+ __defProp(target, name7, { get: all[name7], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ GatewayAuthenticationError: () => GatewayAuthenticationError,
24
+ GatewayError: () => GatewayError,
25
+ GatewayInternalServerError: () => GatewayInternalServerError,
26
+ GatewayInvalidRequestError: () => GatewayInvalidRequestError,
27
+ GatewayModelNotFoundError: () => GatewayModelNotFoundError,
28
+ GatewayRateLimitError: () => GatewayRateLimitError,
29
+ GatewayResponseError: () => GatewayResponseError,
30
+ createGateway: () => createGatewayProvider,
31
+ createGatewayProvider: () => createGatewayProvider,
32
+ gateway: () => gateway
33
+ });
34
+ module.exports = __toCommonJS(src_exports);
35
+
36
+ // src/gateway-provider.ts
37
+ var import_provider2 = require("@ai-sdk/provider");
38
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
39
+
40
+ // src/errors/as-gateway-error.ts
41
+ var import_provider = require("@ai-sdk/provider");
42
+
43
+ // src/errors/create-gateway-error.ts
44
+ var import_v42 = require("zod/v4");
45
+
46
+ // src/errors/gateway-error.ts
47
+ var marker = "vercel.ai.gateway.error";
48
+ var symbol = Symbol.for(marker);
49
+ var _a, _b;
50
+ var GatewayError = class _GatewayError extends (_b = Error, _a = symbol, _b) {
51
+ constructor({
52
+ message,
53
+ statusCode = 500,
54
+ cause
55
+ }) {
56
+ super(message);
57
+ this[_a] = true;
58
+ this.statusCode = statusCode;
59
+ this.cause = cause;
60
+ }
61
+ /**
62
+ * Checks if the given error is a Gateway Error.
63
+ * @param {unknown} error - The error to check.
64
+ * @returns {boolean} True if the error is a Gateway Error, false otherwise.
65
+ */
66
+ static isInstance(error) {
67
+ return _GatewayError.hasMarker(error);
68
+ }
69
+ static hasMarker(error) {
70
+ return typeof error === "object" && error !== null && symbol in error && error[symbol] === true;
71
+ }
72
+ };
73
+
74
+ // src/errors/gateway-authentication-error.ts
75
+ var name = "GatewayAuthenticationError";
76
+ var marker2 = `vercel.ai.gateway.error.${name}`;
77
+ var symbol2 = Symbol.for(marker2);
78
+ var _a2, _b2;
79
+ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2 = GatewayError, _a2 = symbol2, _b2) {
80
+ constructor({
81
+ message = "Authentication failed",
82
+ statusCode = 401,
83
+ cause
84
+ } = {}) {
85
+ super({ message, statusCode, cause });
86
+ this[_a2] = true;
87
+ // used in isInstance
88
+ this.name = name;
89
+ this.type = "authentication_error";
90
+ }
91
+ static isInstance(error) {
92
+ return GatewayError.hasMarker(error) && symbol2 in error;
93
+ }
94
+ /**
95
+ * Creates a contextual error message when authentication fails
96
+ */
97
+ static createContextualError({
98
+ apiKeyProvided,
99
+ oidcTokenProvided,
100
+ message = "Authentication failed",
101
+ statusCode = 401,
102
+ cause
103
+ }) {
104
+ let contextualMessage;
105
+ if (apiKeyProvided) {
106
+ contextualMessage = `AI Gateway authentication failed: Invalid API key provided.
107
+
108
+ The token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;
109
+ } else if (oidcTokenProvided) {
110
+ contextualMessage = `AI Gateway authentication failed: Invalid OIDC token provided.
111
+
112
+ The token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.
113
+ - make sure your Vercel project settings have OIDC enabled
114
+ - if running locally with 'vercel dev', the token is automatically obtained and refreshed
115
+ - if running locally with your own dev server, run 'vercel env pull' to fetch the token
116
+ - in production/preview, the token is automatically obtained and refreshed
117
+
118
+ Alternative: Provide an API key via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;
119
+ } else {
120
+ contextualMessage = `AI Gateway authentication failed: No authentication provided.
121
+
122
+ Provide either an API key or OIDC token.
123
+
124
+ API key instructions:
125
+
126
+ The token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
127
+
128
+ OIDC token instructions:
129
+
130
+ The token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.
131
+ - make sure your Vercel project settings have OIDC enabled
132
+ - if running locally with 'vercel dev', the token is automatically obtained and refreshed
133
+ - if running locally with your own dev server, run 'vercel env pull' to fetch the token
134
+ - in production/preview, the token is automatically obtained and refreshed`;
135
+ }
136
+ return new _GatewayAuthenticationError({
137
+ message: contextualMessage,
138
+ statusCode,
139
+ cause
140
+ });
141
+ }
142
+ };
143
+
144
+ // src/errors/gateway-invalid-request-error.ts
145
+ var name2 = "GatewayInvalidRequestError";
146
+ var marker3 = `vercel.ai.gateway.error.${name2}`;
147
+ var symbol3 = Symbol.for(marker3);
148
+ var _a3, _b3;
149
+ var GatewayInvalidRequestError = class extends (_b3 = GatewayError, _a3 = symbol3, _b3) {
150
+ constructor({
151
+ message = "Invalid request",
152
+ statusCode = 400,
153
+ cause
154
+ } = {}) {
155
+ super({ message, statusCode, cause });
156
+ this[_a3] = true;
157
+ // used in isInstance
158
+ this.name = name2;
159
+ this.type = "invalid_request_error";
160
+ }
161
+ static isInstance(error) {
162
+ return GatewayError.hasMarker(error) && symbol3 in error;
163
+ }
164
+ };
165
+
166
+ // src/errors/gateway-rate-limit-error.ts
167
+ var name3 = "GatewayRateLimitError";
168
+ var marker4 = `vercel.ai.gateway.error.${name3}`;
169
+ var symbol4 = Symbol.for(marker4);
170
+ var _a4, _b4;
171
+ var GatewayRateLimitError = class extends (_b4 = GatewayError, _a4 = symbol4, _b4) {
172
+ constructor({
173
+ message = "Rate limit exceeded",
174
+ statusCode = 429,
175
+ cause
176
+ } = {}) {
177
+ super({ message, statusCode, cause });
178
+ this[_a4] = true;
179
+ // used in isInstance
180
+ this.name = name3;
181
+ this.type = "rate_limit_exceeded";
182
+ }
183
+ static isInstance(error) {
184
+ return GatewayError.hasMarker(error) && symbol4 in error;
185
+ }
186
+ };
187
+
188
+ // src/errors/gateway-model-not-found-error.ts
189
+ var import_v4 = require("zod/v4");
190
+ var name4 = "GatewayModelNotFoundError";
191
+ var marker5 = `vercel.ai.gateway.error.${name4}`;
192
+ var symbol5 = Symbol.for(marker5);
193
+ var modelNotFoundParamSchema = import_v4.z.object({
194
+ modelId: import_v4.z.string()
195
+ });
196
+ var _a5, _b5;
197
+ var GatewayModelNotFoundError = class extends (_b5 = GatewayError, _a5 = symbol5, _b5) {
198
+ constructor({
199
+ message = "Model not found",
200
+ statusCode = 404,
201
+ modelId,
202
+ cause
203
+ } = {}) {
204
+ super({ message, statusCode, cause });
205
+ this[_a5] = true;
206
+ // used in isInstance
207
+ this.name = name4;
208
+ this.type = "model_not_found";
209
+ this.modelId = modelId;
210
+ }
211
+ static isInstance(error) {
212
+ return GatewayError.hasMarker(error) && symbol5 in error;
213
+ }
214
+ };
215
+
216
+ // src/errors/gateway-internal-server-error.ts
217
+ var name5 = "GatewayInternalServerError";
218
+ var marker6 = `vercel.ai.gateway.error.${name5}`;
219
+ var symbol6 = Symbol.for(marker6);
220
+ var _a6, _b6;
221
+ var GatewayInternalServerError = class extends (_b6 = GatewayError, _a6 = symbol6, _b6) {
222
+ constructor({
223
+ message = "Internal server error",
224
+ statusCode = 500,
225
+ cause
226
+ } = {}) {
227
+ super({ message, statusCode, cause });
228
+ this[_a6] = true;
229
+ // used in isInstance
230
+ this.name = name5;
231
+ this.type = "internal_server_error";
232
+ }
233
+ static isInstance(error) {
234
+ return GatewayError.hasMarker(error) && symbol6 in error;
235
+ }
236
+ };
237
+
238
+ // src/errors/gateway-response-error.ts
239
+ var name6 = "GatewayResponseError";
240
+ var marker7 = `vercel.ai.gateway.error.${name6}`;
241
+ var symbol7 = Symbol.for(marker7);
242
+ var _a7, _b7;
243
+ var GatewayResponseError = class extends (_b7 = GatewayError, _a7 = symbol7, _b7) {
244
+ constructor({
245
+ message = "Invalid response from Gateway",
246
+ statusCode = 502,
247
+ response,
248
+ validationError,
249
+ cause
250
+ } = {}) {
251
+ super({ message, statusCode, cause });
252
+ this[_a7] = true;
253
+ // used in isInstance
254
+ this.name = name6;
255
+ this.type = "response_error";
256
+ this.response = response;
257
+ this.validationError = validationError;
258
+ }
259
+ static isInstance(error) {
260
+ return GatewayError.hasMarker(error) && symbol7 in error;
261
+ }
262
+ };
263
+
264
+ // src/errors/create-gateway-error.ts
265
+ function createGatewayErrorFromResponse({
266
+ response,
267
+ statusCode,
268
+ defaultMessage = "Gateway request failed",
269
+ cause,
270
+ authMethod
271
+ }) {
272
+ const parseResult = gatewayErrorResponseSchema.safeParse(response);
273
+ if (!parseResult.success) {
274
+ return new GatewayResponseError({
275
+ message: `Invalid error response format: ${defaultMessage}`,
276
+ statusCode,
277
+ response,
278
+ validationError: parseResult.error,
279
+ cause
280
+ });
281
+ }
282
+ const validatedResponse = parseResult.data;
283
+ const errorType = validatedResponse.error.type;
284
+ const message = validatedResponse.error.message;
285
+ switch (errorType) {
286
+ case "authentication_error":
287
+ return GatewayAuthenticationError.createContextualError({
288
+ apiKeyProvided: authMethod === "api-key",
289
+ oidcTokenProvided: authMethod === "oidc",
290
+ statusCode,
291
+ cause
292
+ });
293
+ case "invalid_request_error":
294
+ return new GatewayInvalidRequestError({ message, statusCode, cause });
295
+ case "rate_limit_exceeded":
296
+ return new GatewayRateLimitError({ message, statusCode, cause });
297
+ case "model_not_found": {
298
+ const modelResult = modelNotFoundParamSchema.safeParse(
299
+ validatedResponse.error.param
300
+ );
301
+ return new GatewayModelNotFoundError({
302
+ message,
303
+ statusCode,
304
+ modelId: modelResult.success ? modelResult.data.modelId : void 0,
305
+ cause
306
+ });
307
+ }
308
+ case "internal_server_error":
309
+ return new GatewayInternalServerError({ message, statusCode, cause });
310
+ default:
311
+ return new GatewayInternalServerError({ message, statusCode, cause });
312
+ }
313
+ }
314
+ var gatewayErrorResponseSchema = import_v42.z.object({
315
+ error: import_v42.z.object({
316
+ message: import_v42.z.string(),
317
+ type: import_v42.z.string().nullish(),
318
+ param: import_v42.z.unknown().nullish(),
319
+ code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
320
+ })
321
+ });
322
+
323
+ // src/errors/as-gateway-error.ts
324
+ function asGatewayError(error, authMethod) {
325
+ var _a8;
326
+ if (GatewayError.isInstance(error)) {
327
+ return error;
328
+ }
329
+ if (import_provider.APICallError.isInstance(error)) {
330
+ return createGatewayErrorFromResponse({
331
+ response: extractApiCallResponse(error),
332
+ statusCode: (_a8 = error.statusCode) != null ? _a8 : 500,
333
+ defaultMessage: "Gateway request failed",
334
+ cause: error,
335
+ authMethod
336
+ });
337
+ }
338
+ return createGatewayErrorFromResponse({
339
+ response: {},
340
+ statusCode: 500,
341
+ defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
342
+ cause: error,
343
+ authMethod
344
+ });
345
+ }
346
+
347
+ // src/errors/extract-api-call-response.ts
348
+ function extractApiCallResponse(error) {
349
+ if (error.data !== void 0) {
350
+ return error.data;
351
+ }
352
+ if (error.responseBody != null) {
353
+ try {
354
+ return JSON.parse(error.responseBody);
355
+ } catch (e) {
356
+ return error.responseBody;
357
+ }
358
+ }
359
+ return {};
360
+ }
361
+
362
+ // src/errors/parse-auth-method.ts
363
+ var import_v43 = require("zod/v4");
364
+ var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
365
+ function parseAuthMethod(headers) {
366
+ const result = gatewayAuthMethodSchema.safeParse(
367
+ headers[GATEWAY_AUTH_METHOD_HEADER]
368
+ );
369
+ return result.success ? result.data : void 0;
370
+ }
371
+ var gatewayAuthMethodSchema = import_v43.z.union([
372
+ import_v43.z.literal("api-key"),
373
+ import_v43.z.literal("oidc")
374
+ ]);
375
+
376
+ // src/gateway-fetch-metadata.ts
377
+ var import_provider_utils = require("@ai-sdk/provider-utils");
378
+ var import_v44 = require("zod/v4");
379
+ var GatewayFetchMetadata = class {
380
+ constructor(config) {
381
+ this.config = config;
382
+ }
383
+ async getAvailableModels() {
384
+ try {
385
+ const { value } = await (0, import_provider_utils.getFromApi)({
386
+ url: `${this.config.baseURL}/config`,
387
+ headers: await (0, import_provider_utils.resolve)(this.config.headers()),
388
+ successfulResponseHandler: (0, import_provider_utils.createJsonResponseHandler)(
389
+ gatewayFetchMetadataSchema
390
+ ),
391
+ failedResponseHandler: (0, import_provider_utils.createJsonErrorResponseHandler)({
392
+ errorSchema: import_v44.z.any(),
393
+ errorToMessage: (data) => data
394
+ }),
395
+ fetch: this.config.fetch
396
+ });
397
+ return value;
398
+ } catch (error) {
399
+ throw asGatewayError(error);
400
+ }
401
+ }
402
+ };
403
+ var gatewayLanguageModelSpecificationSchema = import_v44.z.object({
404
+ specificationVersion: import_v44.z.literal("v2"),
405
+ provider: import_v44.z.string(),
406
+ modelId: import_v44.z.string()
407
+ });
408
+ var gatewayLanguageModelPricingSchema = import_v44.z.object({
409
+ input: import_v44.z.string(),
410
+ output: import_v44.z.string()
411
+ });
412
+ var gatewayLanguageModelEntrySchema = import_v44.z.object({
413
+ id: import_v44.z.string(),
414
+ name: import_v44.z.string(),
415
+ description: import_v44.z.string().nullish(),
416
+ pricing: gatewayLanguageModelPricingSchema.nullish(),
417
+ specification: gatewayLanguageModelSpecificationSchema
418
+ });
419
+ var gatewayFetchMetadataSchema = import_v44.z.object({
420
+ models: import_v44.z.array(gatewayLanguageModelEntrySchema)
421
+ });
422
+
423
+ // src/gateway-language-model.ts
424
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
425
+ var import_v45 = require("zod/v4");
426
+ var GatewayLanguageModel = class {
427
+ constructor(modelId, config) {
428
+ this.modelId = modelId;
429
+ this.config = config;
430
+ this.specificationVersion = "v2";
431
+ this.supportedUrls = { "*/*": [/.*/] };
432
+ }
433
+ get provider() {
434
+ return this.config.provider;
435
+ }
436
+ async getArgs(options) {
437
+ const { abortSignal: _abortSignal, ...optionsWithoutSignal } = options;
438
+ return {
439
+ args: this.maybeEncodeFileParts(optionsWithoutSignal),
440
+ warnings: []
441
+ };
442
+ }
443
+ async doGenerate(options) {
444
+ const { args, warnings } = await this.getArgs(options);
445
+ const { abortSignal } = options;
446
+ const resolvedHeaders = await (0, import_provider_utils2.resolve)(this.config.headers());
447
+ try {
448
+ const {
449
+ responseHeaders,
450
+ value: responseBody,
451
+ rawValue: rawResponse
452
+ } = await (0, import_provider_utils2.postJsonToApi)({
453
+ url: this.getUrl(),
454
+ headers: (0, import_provider_utils2.combineHeaders)(
455
+ resolvedHeaders,
456
+ options.headers,
457
+ this.getModelConfigHeaders(this.modelId, false),
458
+ await (0, import_provider_utils2.resolve)(this.config.o11yHeaders)
459
+ ),
460
+ body: args,
461
+ successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(import_v45.z.any()),
462
+ failedResponseHandler: (0, import_provider_utils2.createJsonErrorResponseHandler)({
463
+ errorSchema: import_v45.z.any(),
464
+ errorToMessage: (data) => data
465
+ }),
466
+ ...abortSignal && { abortSignal },
467
+ fetch: this.config.fetch
468
+ });
469
+ return {
470
+ ...responseBody,
471
+ request: { body: args },
472
+ response: { headers: responseHeaders, body: rawResponse },
473
+ warnings
474
+ };
475
+ } catch (error) {
476
+ throw asGatewayError(error, parseAuthMethod(resolvedHeaders));
477
+ }
478
+ }
479
+ async doStream(options) {
480
+ const { args, warnings } = await this.getArgs(options);
481
+ const { abortSignal } = options;
482
+ const resolvedHeaders = await (0, import_provider_utils2.resolve)(this.config.headers());
483
+ try {
484
+ const { value: response, responseHeaders } = await (0, import_provider_utils2.postJsonToApi)({
485
+ url: this.getUrl(),
486
+ headers: (0, import_provider_utils2.combineHeaders)(
487
+ resolvedHeaders,
488
+ options.headers,
489
+ this.getModelConfigHeaders(this.modelId, true),
490
+ await (0, import_provider_utils2.resolve)(this.config.o11yHeaders)
491
+ ),
492
+ body: args,
493
+ successfulResponseHandler: (0, import_provider_utils2.createEventSourceResponseHandler)(import_v45.z.any()),
494
+ failedResponseHandler: (0, import_provider_utils2.createJsonErrorResponseHandler)({
495
+ errorSchema: import_v45.z.any(),
496
+ errorToMessage: (data) => data
497
+ }),
498
+ ...abortSignal && { abortSignal },
499
+ fetch: this.config.fetch
500
+ });
501
+ return {
502
+ stream: response.pipeThrough(
503
+ new TransformStream({
504
+ start(controller) {
505
+ if (warnings.length > 0) {
506
+ controller.enqueue({ type: "stream-start", warnings });
507
+ }
508
+ },
509
+ transform(chunk, controller) {
510
+ if (chunk.success) {
511
+ const streamPart = chunk.value;
512
+ if (streamPart.type === "raw" && !options.includeRawChunks) {
513
+ return;
514
+ }
515
+ if (streamPart.type === "response-metadata" && streamPart.timestamp && typeof streamPart.timestamp === "string") {
516
+ streamPart.timestamp = new Date(streamPart.timestamp);
517
+ }
518
+ controller.enqueue(streamPart);
519
+ } else {
520
+ controller.error(
521
+ chunk.error
522
+ );
523
+ }
524
+ }
525
+ })
526
+ ),
527
+ request: { body: args },
528
+ response: { headers: responseHeaders }
529
+ };
530
+ } catch (error) {
531
+ throw asGatewayError(error, parseAuthMethod(resolvedHeaders));
532
+ }
533
+ }
534
+ isFilePart(part) {
535
+ return part && typeof part === "object" && "type" in part && part.type === "file";
536
+ }
537
+ /**
538
+ * Encodes file parts in the prompt to base64. Mutates the passed options
539
+ * instance directly to avoid copying the file data.
540
+ * @param options - The options to encode.
541
+ * @returns The options with the file parts encoded.
542
+ */
543
+ maybeEncodeFileParts(options) {
544
+ for (const message of options.prompt) {
545
+ for (const part of message.content) {
546
+ if (this.isFilePart(part)) {
547
+ const filePart = part;
548
+ if (filePart.data instanceof Uint8Array) {
549
+ const buffer = Uint8Array.from(filePart.data);
550
+ const base64Data = Buffer.from(buffer).toString("base64");
551
+ filePart.data = new URL(
552
+ `data:${filePart.mediaType || "application/octet-stream"};base64,${base64Data}`
553
+ );
554
+ }
555
+ }
556
+ }
557
+ }
558
+ return options;
559
+ }
560
+ getUrl() {
561
+ return `${this.config.baseURL}/language-model`;
562
+ }
563
+ getModelConfigHeaders(modelId, streaming) {
564
+ return {
565
+ "ai-language-model-specification-version": "2",
566
+ "ai-language-model-id": modelId,
567
+ "ai-language-model-streaming": String(streaming)
568
+ };
569
+ }
570
+ };
571
+
572
+ // src/gateway-embedding-model.ts
573
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
574
+ var import_v46 = require("zod/v4");
575
+ var GatewayEmbeddingModel = class {
576
+ constructor(modelId, config) {
577
+ this.modelId = modelId;
578
+ this.config = config;
579
+ this.specificationVersion = "v2";
580
+ this.maxEmbeddingsPerCall = 2048;
581
+ this.supportsParallelCalls = true;
582
+ }
583
+ get provider() {
584
+ return this.config.provider;
585
+ }
586
+ async doEmbed({
587
+ values,
588
+ headers,
589
+ abortSignal,
590
+ providerOptions
591
+ }) {
592
+ var _a8;
593
+ const resolvedHeaders = await (0, import_provider_utils3.resolve)(this.config.headers());
594
+ try {
595
+ const {
596
+ responseHeaders,
597
+ value: responseBody,
598
+ rawValue
599
+ } = await (0, import_provider_utils3.postJsonToApi)({
600
+ url: this.getUrl(),
601
+ headers: (0, import_provider_utils3.combineHeaders)(
602
+ resolvedHeaders,
603
+ headers != null ? headers : {},
604
+ this.getModelConfigHeaders(),
605
+ await (0, import_provider_utils3.resolve)(this.config.o11yHeaders)
606
+ ),
607
+ body: {
608
+ input: values.length === 1 ? values[0] : values,
609
+ ...providerOptions != null ? providerOptions : {}
610
+ },
611
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
612
+ gatewayEmbeddingResponseSchema
613
+ ),
614
+ failedResponseHandler: (0, import_provider_utils3.createJsonErrorResponseHandler)({
615
+ errorSchema: import_v46.z.any(),
616
+ errorToMessage: (data) => data
617
+ }),
618
+ ...abortSignal && { abortSignal },
619
+ fetch: this.config.fetch
620
+ });
621
+ return {
622
+ embeddings: responseBody.embeddings,
623
+ usage: (_a8 = responseBody.usage) != null ? _a8 : void 0,
624
+ providerMetadata: responseBody.providerMetadata,
625
+ response: { headers: responseHeaders, body: rawValue }
626
+ };
627
+ } catch (error) {
628
+ throw asGatewayError(error, parseAuthMethod(resolvedHeaders));
629
+ }
630
+ }
631
+ getUrl() {
632
+ return `${this.config.baseURL}/embedding-model`;
633
+ }
634
+ getModelConfigHeaders() {
635
+ return {
636
+ "ai-embedding-model-specification-version": "2",
637
+ "ai-model-id": this.modelId
638
+ };
639
+ }
640
+ };
641
+ var gatewayEmbeddingResponseSchema = import_v46.z.object({
642
+ embeddings: import_v46.z.array(import_v46.z.array(import_v46.z.number())),
643
+ usage: import_v46.z.object({ tokens: import_v46.z.number() }).nullish(),
644
+ providerMetadata: import_v46.z.record(import_v46.z.string(), import_v46.z.record(import_v46.z.string(), import_v46.z.unknown())).optional()
645
+ });
646
+
647
+ // src/vercel-environment.ts
648
+ async function getVercelOidcToken() {
649
+ var _a8, _b8;
650
+ const token = (_b8 = (_a8 = getContext().headers) == null ? void 0 : _a8["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
651
+ if (!token) {
652
+ throw new GatewayAuthenticationError({
653
+ message: "OIDC token not available",
654
+ statusCode: 401
655
+ });
656
+ }
657
+ return token;
658
+ }
659
+ async function getVercelRequestId() {
660
+ var _a8;
661
+ return (_a8 = getContext().headers) == null ? void 0 : _a8["x-vercel-id"];
662
+ }
663
+ var SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
664
+ function getContext() {
665
+ var _a8, _b8, _c;
666
+ const fromSymbol = globalThis;
667
+ return (_c = (_b8 = (_a8 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a8.get) == null ? void 0 : _b8.call(_a8)) != null ? _c : {};
668
+ }
669
+
670
+ // src/gateway-provider.ts
671
+ var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
672
+ function createGatewayProvider(options = {}) {
673
+ var _a8, _b8;
674
+ let pendingMetadata = null;
675
+ let metadataCache = null;
676
+ const cacheRefreshMillis = (_a8 = options.metadataCacheRefreshMillis) != null ? _a8 : 1e3 * 60 * 5;
677
+ let lastFetchTime = 0;
678
+ const baseURL = (_b8 = (0, import_provider_utils4.withoutTrailingSlash)(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
679
+ const getHeaders = async () => {
680
+ const auth = await getGatewayAuthToken(options);
681
+ if (auth) {
682
+ return {
683
+ Authorization: `Bearer ${auth.token}`,
684
+ "ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
685
+ [GATEWAY_AUTH_METHOD_HEADER]: auth.authMethod,
686
+ ...options.headers
687
+ };
688
+ }
689
+ throw GatewayAuthenticationError.createContextualError({
690
+ apiKeyProvided: false,
691
+ oidcTokenProvided: false,
692
+ statusCode: 401
693
+ });
694
+ };
695
+ const createO11yHeaders = () => {
696
+ const deploymentId = (0, import_provider_utils4.loadOptionalSetting)({
697
+ settingValue: void 0,
698
+ environmentVariableName: "VERCEL_DEPLOYMENT_ID"
699
+ });
700
+ const environment = (0, import_provider_utils4.loadOptionalSetting)({
701
+ settingValue: void 0,
702
+ environmentVariableName: "VERCEL_ENV"
703
+ });
704
+ const region = (0, import_provider_utils4.loadOptionalSetting)({
705
+ settingValue: void 0,
706
+ environmentVariableName: "VERCEL_REGION"
707
+ });
708
+ return async () => {
709
+ const requestId = await getVercelRequestId();
710
+ return {
711
+ ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
712
+ ...environment && { "ai-o11y-environment": environment },
713
+ ...region && { "ai-o11y-region": region },
714
+ ...requestId && { "ai-o11y-request-id": requestId }
715
+ };
716
+ };
717
+ };
718
+ const createLanguageModel = (modelId) => {
719
+ return new GatewayLanguageModel(modelId, {
720
+ provider: "gateway",
721
+ baseURL,
722
+ headers: getHeaders,
723
+ fetch: options.fetch,
724
+ o11yHeaders: createO11yHeaders()
725
+ });
726
+ };
727
+ const getAvailableModels = async () => {
728
+ var _a9, _b9, _c;
729
+ const now = (_c = (_b9 = (_a9 = options._internal) == null ? void 0 : _a9.currentDate) == null ? void 0 : _b9.call(_a9).getTime()) != null ? _c : Date.now();
730
+ if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
731
+ lastFetchTime = now;
732
+ pendingMetadata = new GatewayFetchMetadata({
733
+ baseURL,
734
+ headers: getHeaders,
735
+ fetch: options.fetch
736
+ }).getAvailableModels().then((metadata) => {
737
+ metadataCache = metadata;
738
+ return metadata;
739
+ }).catch(async (error) => {
740
+ throw asGatewayError(error, parseAuthMethod(await getHeaders()));
741
+ });
742
+ }
743
+ return metadataCache ? Promise.resolve(metadataCache) : pendingMetadata;
744
+ };
745
+ const provider = function(modelId) {
746
+ if (new.target) {
747
+ throw new Error(
748
+ "The Gateway Provider model function cannot be called with the new keyword."
749
+ );
750
+ }
751
+ return createLanguageModel(modelId);
752
+ };
753
+ provider.getAvailableModels = getAvailableModels;
754
+ provider.imageModel = (modelId) => {
755
+ throw new import_provider2.NoSuchModelError({ modelId, modelType: "imageModel" });
756
+ };
757
+ provider.languageModel = createLanguageModel;
758
+ provider.textEmbeddingModel = (modelId) => {
759
+ return new GatewayEmbeddingModel(modelId, {
760
+ provider: "gateway",
761
+ baseURL,
762
+ headers: getHeaders,
763
+ fetch: options.fetch,
764
+ o11yHeaders: createO11yHeaders()
765
+ });
766
+ };
767
+ return provider;
768
+ }
769
+ var gateway = createGatewayProvider();
770
+ async function getGatewayAuthToken(options) {
771
+ const apiKey = (0, import_provider_utils4.loadOptionalSetting)({
772
+ settingValue: options.apiKey,
773
+ environmentVariableName: "AI_GATEWAY_API_KEY"
774
+ });
775
+ if (apiKey) {
776
+ return {
777
+ token: apiKey,
778
+ authMethod: "api-key"
779
+ };
780
+ }
781
+ try {
782
+ const oidcToken = await getVercelOidcToken();
783
+ return {
784
+ token: oidcToken,
785
+ authMethod: "oidc"
786
+ };
787
+ } catch (e) {
788
+ return null;
789
+ }
790
+ }
791
+ // Annotate the CommonJS export names for ESM import in node:
792
+ 0 && (module.exports = {
793
+ GatewayAuthenticationError,
794
+ GatewayError,
795
+ GatewayInternalServerError,
796
+ GatewayInvalidRequestError,
797
+ GatewayModelNotFoundError,
798
+ GatewayRateLimitError,
799
+ GatewayResponseError,
800
+ createGateway,
801
+ createGatewayProvider,
802
+ gateway
803
+ });
804
+ //# sourceMappingURL=index.js.map
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../src/index.ts","../src/gateway-provider.ts","../src/errors/as-gateway-error.ts","../src/errors/create-gateway-error.ts","../src/errors/gateway-error.ts","../src/errors/gateway-authentication-error.ts","../src/errors/gateway-invalid-request-error.ts","../src/errors/gateway-rate-limit-error.ts","../src/errors/gateway-model-not-found-error.ts","../src/errors/gateway-internal-server-error.ts","../src/errors/gateway-response-error.ts","../src/errors/extract-api-call-response.ts","../src/errors/parse-auth-method.ts","../src/gateway-fetch-metadata.ts","../src/gateway-language-model.ts","../src/gateway-embedding-model.ts","../src/vercel-environment.ts"],"sourcesContent":["export type { GatewayModelId } from './gateway-language-model-settings';\nexport type {\n GatewayLanguageModelEntry,\n GatewayLanguageModelSpecification,\n} from './gateway-model-entry';\nexport {\n createGatewayProvider,\n createGatewayProvider as createGateway,\n gateway,\n} from './gateway-provider';\nexport type {\n GatewayProvider,\n GatewayProviderSettings,\n} from './gateway-provider';\nexport type { GatewayProviderOptions } from './gateway-provider-options';\nexport {\n GatewayError,\n GatewayAuthenticationError,\n GatewayInvalidRequestError,\n GatewayRateLimitError,\n GatewayModelNotFoundError,\n GatewayInternalServerError,\n GatewayResponseError,\n} from './errors';\nexport type { GatewayErrorResponse } from './errors';\n","import { NoSuchModelError } from '@ai-sdk/provider';\nimport {\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { asGatewayError, GatewayAuthenticationError } from './errors';\nimport {\n GATEWAY_AUTH_METHOD_HEADER,\n parseAuthMethod,\n} from './errors/parse-auth-method';\nimport {\n GatewayFetchMetadata,\n type GatewayFetchMetadataResponse,\n} from './gateway-fetch-metadata';\nimport { GatewayLanguageModel } from './gateway-language-model';\nimport { GatewayEmbeddingModel } from './gateway-embedding-model';\nimport type { GatewayEmbeddingModelId } from './gateway-embedding-model-settings';\nimport { getVercelOidcToken, getVercelRequestId } from './vercel-environment';\nimport type { GatewayModelId } from './gateway-language-model-settings';\nimport type {\n LanguageModelV2,\n EmbeddingModelV2,\n ProviderV2,\n} from '@ai-sdk/provider';\n\nexport interface GatewayProvider extends ProviderV2 {\n (modelId: GatewayModelId): LanguageModelV2;\n\n /**\nCreates a model for text generation.\n*/\n languageModel(modelId: GatewayModelId): LanguageModelV2;\n\n /**\nReturns available providers and models for use with the remote provider.\n */\n getAvailableModels(): Promise<GatewayFetchMetadataResponse>;\n\n /**\nCreates a model for generating text embeddings.\n*/\n textEmbeddingModel(\n modelId: GatewayEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n}\n\nexport interface GatewayProviderSettings {\n /**\nThe base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.\n */\n baseURL?: string;\n\n /**\nAPI key that is being sent using the `Authorization` header.\n */\n apiKey?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\nHow frequently to refresh the metadata cache in milliseconds.\n */\n metadataCacheRefreshMillis?: number;\n\n /**\n * @internal For testing purposes only\n */\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nconst AI_GATEWAY_PROTOCOL_VERSION = '0.0.1';\n\n/**\nCreate a remote provider instance.\n */\nexport function createGatewayProvider(\n options: GatewayProviderSettings = {},\n): GatewayProvider {\n let pendingMetadata: Promise<GatewayFetchMetadataResponse> | null = null;\n let metadataCache: GatewayFetchMetadataResponse | null = null;\n const cacheRefreshMillis =\n options.metadataCacheRefreshMillis ?? 1000 * 60 * 5;\n let lastFetchTime = 0;\n\n const baseURL =\n withoutTrailingSlash(options.baseURL) ??\n 'https://ai-gateway.vercel.sh/v1/ai';\n\n const getHeaders = async () => {\n const auth = await getGatewayAuthToken(options);\n if (auth) {\n return {\n Authorization: `Bearer ${auth.token}`,\n 'ai-gateway-protocol-version': AI_GATEWAY_PROTOCOL_VERSION,\n [GATEWAY_AUTH_METHOD_HEADER]: auth.authMethod,\n ...options.headers,\n };\n }\n\n throw GatewayAuthenticationError.createContextualError({\n apiKeyProvided: false,\n oidcTokenProvided: false,\n statusCode: 401,\n });\n };\n\n const createO11yHeaders = () => {\n const deploymentId = loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'VERCEL_DEPLOYMENT_ID',\n });\n const environment = loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'VERCEL_ENV',\n });\n const region = loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'VERCEL_REGION',\n });\n\n return async () => {\n const requestId = await getVercelRequestId();\n return {\n ...(deploymentId && { 'ai-o11y-deployment-id': deploymentId }),\n ...(environment && { 'ai-o11y-environment': environment }),\n ...(region && { 'ai-o11y-region': region }),\n ...(requestId && { 'ai-o11y-request-id': requestId }),\n };\n };\n };\n\n const createLanguageModel = (modelId: GatewayModelId) => {\n return new GatewayLanguageModel(modelId, {\n provider: 'gateway',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n o11yHeaders: createO11yHeaders(),\n });\n };\n\n const getAvailableModels = async () => {\n const now = options._internal?.currentDate?.().getTime() ?? Date.now();\n if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {\n lastFetchTime = now;\n\n pendingMetadata = new GatewayFetchMetadata({\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n })\n .getAvailableModels()\n .then(metadata => {\n metadataCache = metadata;\n return metadata;\n })\n .catch(async (error: unknown) => {\n throw asGatewayError(error, parseAuthMethod(await getHeaders()));\n });\n }\n\n return metadataCache ? Promise.resolve(metadataCache) : pendingMetadata;\n };\n\n const provider = function (modelId: GatewayModelId) {\n if (new.target) {\n throw new Error(\n 'The Gateway Provider model function cannot be called with the new keyword.',\n );\n }\n\n return createLanguageModel(modelId);\n };\n\n provider.getAvailableModels = getAvailableModels;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.languageModel = createLanguageModel;\n provider.textEmbeddingModel = (modelId: GatewayEmbeddingModelId) => {\n return new GatewayEmbeddingModel(modelId, {\n provider: 'gateway',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n o11yHeaders: createO11yHeaders(),\n });\n };\n\n return provider;\n}\n\nexport const gateway = createGatewayProvider();\n\nexport async function getGatewayAuthToken(\n options: GatewayProviderSettings,\n): Promise<{\n token: string;\n authMethod: 'api-key' | 'oidc';\n} | null> {\n const apiKey = loadOptionalSetting({\n settingValue: options.apiKey,\n environmentVariableName: 'AI_GATEWAY_API_KEY',\n });\n\n if (apiKey) {\n return {\n token: apiKey,\n authMethod: 'api-key',\n };\n }\n\n try {\n const oidcToken = await getVercelOidcToken();\n return {\n token: oidcToken,\n authMethod: 'oidc',\n };\n } catch {\n return null;\n }\n}\n","import { APICallError } from '@ai-sdk/provider';\nimport { extractApiCallResponse, GatewayError } from '.';\nimport { createGatewayErrorFromResponse } from './create-gateway-error';\n\nexport function asGatewayError(\n error: unknown,\n authMethod?: 'api-key' | 'oidc',\n) {\n if (GatewayError.isInstance(error)) {\n return error;\n }\n\n if (APICallError.isInstance(error)) {\n return createGatewayErrorFromResponse({\n response: extractApiCallResponse(error),\n statusCode: error.statusCode ?? 500,\n defaultMessage: 'Gateway request failed',\n cause: error,\n authMethod,\n });\n }\n\n return createGatewayErrorFromResponse({\n response: {},\n statusCode: 500,\n defaultMessage:\n error instanceof Error\n ? `Gateway request failed: ${error.message}`\n : 'Unknown Gateway error',\n cause: error,\n authMethod,\n });\n}\n","import { z } from 'zod/v4';\nimport type { GatewayError } from './gateway-error';\nimport { GatewayAuthenticationError } from './gateway-authentication-error';\nimport { GatewayInvalidRequestError } from './gateway-invalid-request-error';\nimport { GatewayRateLimitError } from './gateway-rate-limit-error';\nimport {\n GatewayModelNotFoundError,\n modelNotFoundParamSchema,\n} from './gateway-model-not-found-error';\nimport { GatewayInternalServerError } from './gateway-internal-server-error';\nimport { GatewayResponseError } from './gateway-response-error';\n\nexport function createGatewayErrorFromResponse({\n response,\n statusCode,\n defaultMessage = 'Gateway request failed',\n cause,\n authMethod,\n}: {\n response: unknown;\n statusCode: number;\n defaultMessage?: string;\n cause?: unknown;\n authMethod?: 'api-key' | 'oidc';\n}): GatewayError {\n const parseResult = gatewayErrorResponseSchema.safeParse(response);\n if (!parseResult.success) {\n return new GatewayResponseError({\n message: `Invalid error response format: ${defaultMessage}`,\n statusCode,\n response,\n validationError: parseResult.error,\n cause,\n });\n }\n\n const validatedResponse: GatewayErrorResponse = parseResult.data;\n const errorType = validatedResponse.error.type;\n const message = validatedResponse.error.message;\n\n switch (errorType) {\n case 'authentication_error':\n return GatewayAuthenticationError.createContextualError({\n apiKeyProvided: authMethod === 'api-key',\n oidcTokenProvided: authMethod === 'oidc',\n statusCode,\n cause,\n });\n case 'invalid_request_error':\n return new GatewayInvalidRequestError({ message, statusCode, cause });\n case 'rate_limit_exceeded':\n return new GatewayRateLimitError({ message, statusCode, cause });\n case 'model_not_found': {\n const modelResult = modelNotFoundParamSchema.safeParse(\n validatedResponse.error.param,\n );\n return new GatewayModelNotFoundError({\n message,\n statusCode,\n modelId: modelResult.success ? modelResult.data.modelId : undefined,\n cause,\n });\n }\n case 'internal_server_error':\n return new GatewayInternalServerError({ message, statusCode, cause });\n default:\n return new GatewayInternalServerError({ message, statusCode, cause });\n }\n}\n\nconst gatewayErrorResponseSchema = z.object({\n error: z.object({\n message: z.string(),\n type: z.string().nullish(),\n param: z.unknown().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n});\n\nexport type GatewayErrorResponse = z.infer<typeof gatewayErrorResponseSchema>;\n","const marker = 'vercel.ai.gateway.error';\nconst symbol = Symbol.for(marker);\n\nexport abstract class GatewayError extends Error {\n private readonly [symbol] = true; // used in isInstance\n\n abstract readonly name: string;\n abstract readonly type: string;\n readonly statusCode: number;\n readonly cause?: unknown;\n\n constructor({\n message,\n statusCode = 500,\n cause,\n }: {\n message: string;\n statusCode?: number;\n cause?: unknown;\n }) {\n super(message);\n this.statusCode = statusCode;\n this.cause = cause;\n }\n\n /**\n * Checks if the given error is a Gateway Error.\n * @param {unknown} error - The error to check.\n * @returns {boolean} True if the error is a Gateway Error, false otherwise.\n */\n static isInstance(error: unknown): error is GatewayError {\n return GatewayError.hasMarker(error);\n }\n\n static hasMarker(error: unknown): error is GatewayError {\n return (\n typeof error === 'object' &&\n error !== null &&\n symbol in error &&\n (error as any)[symbol] === true\n );\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayAuthenticationError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Authentication failed - invalid API key or OIDC token\n */\nexport class GatewayAuthenticationError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'authentication_error';\n\n constructor({\n message = 'Authentication failed',\n statusCode = 401,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayAuthenticationError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n\n /**\n * Creates a contextual error message when authentication fails\n */\n static createContextualError({\n apiKeyProvided,\n oidcTokenProvided,\n message = 'Authentication failed',\n statusCode = 401,\n cause,\n }: {\n apiKeyProvided: boolean;\n oidcTokenProvided: boolean;\n message?: string;\n statusCode?: number;\n cause?: unknown;\n }): GatewayAuthenticationError {\n let contextualMessage: string;\n\n if (apiKeyProvided) {\n contextualMessage = `AI Gateway authentication failed: Invalid API key provided.\n\nThe token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;\n } else if (oidcTokenProvided) {\n contextualMessage = `AI Gateway authentication failed: Invalid OIDC token provided.\n\nThe token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.\n- make sure your Vercel project settings have OIDC enabled\n- if running locally with 'vercel dev', the token is automatically obtained and refreshed\n- if running locally with your own dev server, run 'vercel env pull' to fetch the token\n- in production/preview, the token is automatically obtained and refreshed\n\nAlternative: Provide an API key via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;\n } else {\n contextualMessage = `AI Gateway authentication failed: No authentication provided.\n\nProvide either an API key or OIDC token.\n\nAPI key instructions:\n\nThe token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.\n\nOIDC token instructions:\n\nThe token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.\n- make sure your Vercel project settings have OIDC enabled\n- if running locally with 'vercel dev', the token is automatically obtained and refreshed\n- if running locally with your own dev server, run 'vercel env pull' to fetch the token\n- in production/preview, the token is automatically obtained and refreshed`;\n }\n\n return new GatewayAuthenticationError({\n message: contextualMessage,\n statusCode,\n cause,\n });\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayInvalidRequestError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Invalid request - missing headers, malformed data, etc.\n */\nexport class GatewayInvalidRequestError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'invalid_request_error';\n\n constructor({\n message = 'Invalid request',\n statusCode = 400,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayInvalidRequestError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayRateLimitError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Rate limit exceeded.\n */\nexport class GatewayRateLimitError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'rate_limit_exceeded';\n\n constructor({\n message = 'Rate limit exceeded',\n statusCode = 429,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayRateLimitError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { z } from 'zod/v4';\nimport { GatewayError } from './gateway-error';\n\nconst name = 'GatewayModelNotFoundError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport const modelNotFoundParamSchema = z.object({\n modelId: z.string(),\n});\n\n/**\n * Model not found or not available\n */\nexport class GatewayModelNotFoundError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'model_not_found';\n readonly modelId?: string;\n\n constructor({\n message = 'Model not found',\n statusCode = 404,\n modelId,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n modelId?: string;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n this.modelId = modelId;\n }\n\n static isInstance(error: unknown): error is GatewayModelNotFoundError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayInternalServerError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Internal server error from the Gateway\n */\nexport class GatewayInternalServerError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'internal_server_error';\n\n constructor({\n message = 'Internal server error',\n statusCode = 500,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayInternalServerError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { GatewayError } from './gateway-error';\nimport type { ZodError } from 'zod/v4';\n\nconst name = 'GatewayResponseError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Gateway response parsing error\n */\nexport class GatewayResponseError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'response_error';\n readonly response?: unknown;\n readonly validationError?: ZodError;\n\n constructor({\n message = 'Invalid response from Gateway',\n statusCode = 502,\n response,\n validationError,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n response?: unknown;\n validationError?: ZodError;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n this.response = response;\n this.validationError = validationError;\n }\n\n static isInstance(error: unknown): error is GatewayResponseError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import type { APICallError } from '@ai-sdk/provider';\n\nexport function extractApiCallResponse(error: APICallError): unknown {\n if (error.data !== undefined) {\n return error.data;\n }\n if (error.responseBody != null) {\n try {\n return JSON.parse(error.responseBody);\n } catch {\n return error.responseBody;\n }\n }\n return {};\n}\n","import { z } from 'zod/v4';\n\nexport const GATEWAY_AUTH_METHOD_HEADER = 'ai-gateway-auth-method' as const;\n\nexport function parseAuthMethod(headers: Record<string, string | undefined>) {\n const result = gatewayAuthMethodSchema.safeParse(\n headers[GATEWAY_AUTH_METHOD_HEADER],\n );\n return result.success ? result.data : undefined;\n}\n\nconst gatewayAuthMethodSchema = z.union([\n z.literal('api-key'),\n z.literal('oidc'),\n]);\n","import {\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n getFromApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { asGatewayError } from './errors';\nimport type { GatewayConfig } from './gateway-config';\nimport type { GatewayLanguageModelEntry } from './gateway-model-entry';\nimport { z } from 'zod/v4';\n\ntype GatewayFetchMetadataConfig = GatewayConfig;\n\nexport interface GatewayFetchMetadataResponse {\n models: GatewayLanguageModelEntry[];\n}\n\nexport class GatewayFetchMetadata {\n constructor(private readonly config: GatewayFetchMetadataConfig) {}\n\n async getAvailableModels(): Promise<GatewayFetchMetadataResponse> {\n try {\n const { value } = await getFromApi({\n url: `${this.config.baseURL}/config`,\n headers: await resolve(this.config.headers()),\n successfulResponseHandler: createJsonResponseHandler(\n gatewayFetchMetadataSchema,\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n fetch: this.config.fetch,\n });\n\n return value;\n } catch (error) {\n throw asGatewayError(error);\n }\n }\n}\n\nconst gatewayLanguageModelSpecificationSchema = z.object({\n specificationVersion: z.literal('v2'),\n provider: z.string(),\n modelId: z.string(),\n});\n\nconst gatewayLanguageModelPricingSchema = z.object({\n input: z.string(),\n output: z.string(),\n});\n\nconst gatewayLanguageModelEntrySchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().nullish(),\n pricing: gatewayLanguageModelPricingSchema.nullish(),\n specification: gatewayLanguageModelSpecificationSchema,\n});\n\nconst gatewayFetchMetadataSchema = z.object({\n models: z.array(gatewayLanguageModelEntrySchema),\n});\n","import type {\n LanguageModelV2,\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n LanguageModelV2FilePart,\n LanguageModelV2StreamPart,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n postJsonToApi,\n resolve,\n type ParseResult,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { GatewayConfig } from './gateway-config';\nimport type { GatewayModelId } from './gateway-language-model-settings';\nimport { asGatewayError } from './errors';\nimport { parseAuthMethod } from './errors/parse-auth-method';\n\ntype GatewayChatConfig = GatewayConfig & {\n provider: string;\n o11yHeaders: Resolvable<Record<string, string>>;\n};\n\nexport class GatewayLanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n readonly supportedUrls = { '*/*': [/.*/] };\n\n constructor(\n readonly modelId: GatewayModelId,\n private readonly config: GatewayChatConfig,\n ) {}\n\n get provider(): string {\n return this.config.provider;\n }\n\n private async getArgs(options: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const { abortSignal: _abortSignal, ...optionsWithoutSignal } = options;\n\n return {\n args: this.maybeEncodeFileParts(optionsWithoutSignal),\n warnings: [],\n };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings } = await this.getArgs(options);\n const { abortSignal } = options;\n\n const resolvedHeaders = await resolve(this.config.headers());\n\n try {\n const {\n responseHeaders,\n value: responseBody,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.getUrl(),\n headers: combineHeaders(\n resolvedHeaders,\n options.headers,\n this.getModelConfigHeaders(this.modelId, false),\n await resolve(this.config.o11yHeaders),\n ),\n body: args,\n successfulResponseHandler: createJsonResponseHandler(z.any()),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n ...(abortSignal && { abortSignal }),\n fetch: this.config.fetch,\n });\n\n return {\n ...responseBody,\n request: { body: args },\n response: { headers: responseHeaders, body: rawResponse },\n warnings,\n };\n } catch (error) {\n throw asGatewayError(error, parseAuthMethod(resolvedHeaders));\n }\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings } = await this.getArgs(options);\n const { abortSignal } = options;\n\n const resolvedHeaders = await resolve(this.config.headers());\n\n try {\n const { value: response, responseHeaders } = await postJsonToApi({\n url: this.getUrl(),\n headers: combineHeaders(\n resolvedHeaders,\n options.headers,\n this.getModelConfigHeaders(this.modelId, true),\n await resolve(this.config.o11yHeaders),\n ),\n body: args,\n successfulResponseHandler: createEventSourceResponseHandler(z.any()),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n ...(abortSignal && { abortSignal }),\n fetch: this.config.fetch,\n });\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<LanguageModelV2StreamPart>,\n LanguageModelV2StreamPart\n >({\n start(controller) {\n if (warnings.length > 0) {\n controller.enqueue({ type: 'stream-start', warnings });\n }\n },\n transform(chunk, controller) {\n if (chunk.success) {\n const streamPart = chunk.value;\n\n // Handle raw chunks: if this is a raw chunk from the gateway API,\n // only emit it if includeRawChunks is true\n if (streamPart.type === 'raw' && !options.includeRawChunks) {\n return; // Skip raw chunks if not requested\n }\n\n if (\n streamPart.type === 'response-metadata' &&\n streamPart.timestamp &&\n typeof streamPart.timestamp === 'string'\n ) {\n streamPart.timestamp = new Date(streamPart.timestamp);\n }\n\n controller.enqueue(streamPart);\n } else {\n controller.error(\n (chunk as { success: false; error: unknown }).error,\n );\n }\n },\n }),\n ),\n request: { body: args },\n response: { headers: responseHeaders },\n };\n } catch (error) {\n throw asGatewayError(error, parseAuthMethod(resolvedHeaders));\n }\n }\n\n private isFilePart(part: unknown) {\n return (\n part && typeof part === 'object' && 'type' in part && part.type === 'file'\n );\n }\n\n /**\n * Encodes file parts in the prompt to base64. Mutates the passed options\n * instance directly to avoid copying the file data.\n * @param options - The options to encode.\n * @returns The options with the file parts encoded.\n */\n private maybeEncodeFileParts(options: LanguageModelV2CallOptions) {\n for (const message of options.prompt) {\n for (const part of message.content) {\n if (this.isFilePart(part)) {\n const filePart = part as LanguageModelV2FilePart;\n // If the file part is a URL it will get cleanly converted to a string.\n // If it's a binary file attachment we convert it to a data url.\n // In either case, server-side we should only ever see URLs as strings.\n if (filePart.data instanceof Uint8Array) {\n const buffer = Uint8Array.from(filePart.data);\n const base64Data = Buffer.from(buffer).toString('base64');\n filePart.data = new URL(\n `data:${filePart.mediaType || 'application/octet-stream'};base64,${base64Data}`,\n );\n }\n }\n }\n }\n return options;\n }\n\n private getUrl() {\n return `${this.config.baseURL}/language-model`;\n }\n\n private getModelConfigHeaders(modelId: string, streaming: boolean) {\n return {\n 'ai-language-model-specification-version': '2',\n 'ai-language-model-id': modelId,\n 'ai-language-model-streaming': String(streaming),\n };\n }\n}\n","import type { EmbeddingModelV2 } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n createJsonErrorResponseHandler,\n postJsonToApi,\n resolve,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { GatewayConfig } from './gateway-config';\nimport { asGatewayError } from './errors';\nimport { parseAuthMethod } from './errors/parse-auth-method';\nimport type { SharedV2ProviderMetadata } from '@ai-sdk/provider';\n\nexport class GatewayEmbeddingModel implements EmbeddingModelV2<string> {\n readonly specificationVersion = 'v2';\n readonly maxEmbeddingsPerCall = 2048;\n readonly supportsParallelCalls = true;\n\n constructor(\n readonly modelId: string,\n private readonly config: GatewayConfig & {\n provider: string;\n o11yHeaders: Resolvable<Record<string, string>>;\n },\n ) {}\n\n get provider(): string {\n return this.config.provider;\n }\n\n async doEmbed({\n values,\n headers,\n abortSignal,\n providerOptions,\n }: Parameters<EmbeddingModelV2<string>['doEmbed']>[0]): Promise<\n Awaited<ReturnType<EmbeddingModelV2<string>['doEmbed']>>\n > {\n const resolvedHeaders = await resolve(this.config.headers());\n try {\n const {\n responseHeaders,\n value: responseBody,\n rawValue,\n } = await postJsonToApi({\n url: this.getUrl(),\n headers: combineHeaders(\n resolvedHeaders,\n headers ?? {},\n this.getModelConfigHeaders(),\n await resolve(this.config.o11yHeaders),\n ),\n body: {\n input: values.length === 1 ? values[0] : values,\n ...(providerOptions ?? {}),\n },\n successfulResponseHandler: createJsonResponseHandler(\n gatewayEmbeddingResponseSchema,\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n ...(abortSignal && { abortSignal }),\n fetch: this.config.fetch,\n });\n\n return {\n embeddings: responseBody.embeddings,\n usage: responseBody.usage ?? undefined,\n providerMetadata:\n responseBody.providerMetadata as unknown as SharedV2ProviderMetadata,\n response: { headers: responseHeaders, body: rawValue },\n };\n } catch (error) {\n throw asGatewayError(error, parseAuthMethod(resolvedHeaders));\n }\n }\n\n private getUrl() {\n return `${this.config.baseURL}/embedding-model`;\n }\n\n private getModelConfigHeaders() {\n return {\n 'ai-embedding-model-specification-version': '2',\n 'ai-model-id': this.modelId,\n };\n }\n}\n\nconst gatewayEmbeddingResponseSchema = z.object({\n embeddings: z.array(z.array(z.number())),\n usage: z.object({ tokens: z.number() }).nullish(),\n providerMetadata: z\n .record(z.string(), z.record(z.string(), z.unknown()))\n .optional(),\n});\n","import { GatewayAuthenticationError } from './errors';\n\nexport async function getVercelOidcToken(): Promise<string> {\n const token =\n getContext().headers?.['x-vercel-oidc-token'] ??\n process.env.VERCEL_OIDC_TOKEN;\n\n if (!token) {\n throw new GatewayAuthenticationError({\n message: 'OIDC token not available',\n statusCode: 401,\n });\n }\n\n return token;\n}\n\nexport async function getVercelRequestId(): Promise<string | undefined> {\n return getContext().headers?.['x-vercel-id'];\n}\n\ntype Context = {\n headers?: Record<string, string>;\n};\n\nconst SYMBOL_FOR_REQ_CONTEXT = Symbol.for('@vercel/request-context');\n\nfunction getContext(): Context {\n const fromSymbol: typeof globalThis & {\n [SYMBOL_FOR_REQ_CONTEXT]?: { get?: () => Context };\n } = globalThis;\n return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAAiC;AACjC,IAAAC,yBAIO;;;ACLP,sBAA6B;;;ACA7B,IAAAC,aAAkB;;;ACAlB,IAAM,SAAS;AACf,IAAM,SAAS,OAAO,IAAI,MAAM;AADhC;AAGO,IAAe,eAAf,MAAe,uBAAqB,YACvB,aADuB,IAAM;AAAA,EAQ/C,YAAY;AAAA,IACV;AAAA,IACA,aA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Q;AAAA,IACtB,yBAAyB;AAAA,EAC3B,CAAC;AAED,MAAI,QAAQ;AACV,WAAO;AAAA,MACL,OAAO;AAAA,MACP,YAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI;AACF,UAAM,YAAY,MAAM,mBAAmB;AAC3C,WAAO;AAAA,MACL,OAAO;AAAA,MACP,YAAY;AAAA,IACd;AAAA,EACF,SAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["import_provider","import_provider_utils","import_v4","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","_a","import_v4","import_v4","import_provider_utils","import_v4","import_provider_utils","import_v4","_a","_a","_b","_a","_b"]}
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs ADDED
@@ -0,0 +1,789 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
1
+ // src/gateway-provider.ts
2
+ import { NoSuchModelError } from "@ai-sdk/provider";
3
+ import {
4
+ loadOptionalSetting,
5
+ withoutTrailingSlash
6
+ } from "@ai-sdk/provider-utils";
7
+
8
+ // src/errors/as-gateway-error.ts
9
+ import { APICallError } from "@ai-sdk/provider";
10
+
11
+ // src/errors/create-gateway-error.ts
12
+ import { z as z2 } from "zod/v4";
13
+
14
+ // src/errors/gateway-error.ts
15
+ var marker = "vercel.ai.gateway.error";
16
+ var symbol = Symbol.for(marker);
17
+ var _a, _b;
18
+ var GatewayError = class _GatewayError extends (_b = Error, _a = symbol, _b) {
19
+ constructor({
20
+ message,
21
+ statusCode = 500,
22
+ cause
23
+ }) {
24
+ super(message);
25
+ this[_a] = true;
26
+ this.statusCode = statusCode;
27
+ this.cause = cause;
28
+ }
29
+ /**
30
+ * Checks if the given error is a Gateway Error.
31
+ * @param {unknown} error - The error to check.
32
+ * @returns {boolean} True if the error is a Gateway Error, false otherwise.
33
+ */
34
+ static isInstance(error) {
35
+ return _GatewayError.hasMarker(error);
36
+ }
37
+ static hasMarker(error) {
38
+ return typeof error === "object" && error !== null && symbol in error && error[symbol] === true;
39
+ }
40
+ };
41
+
42
+ // src/errors/gateway-authentication-error.ts
43
+ var name = "GatewayAuthenticationError";
44
+ var marker2 = `vercel.ai.gateway.error.${name}`;
45
+ var symbol2 = Symbol.for(marker2);
46
+ var _a2, _b2;
47
+ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2 = GatewayError, _a2 = symbol2, _b2) {
48
+ constructor({
49
+ message = "Authentication failed",
50
+ statusCode = 401,
51
+ cause
52
+ } = {}) {
53
+ super({ message, statusCode, cause });
54
+ this[_a2] = true;
55
+ // used in isInstance
56
+ this.name = name;
57
+ this.type = "authentication_error";
58
+ }
59
+ static isInstance(error) {
60
+ return GatewayError.hasMarker(error) && symbol2 in error;
61
+ }
62
+ /**
63
+ * Creates a contextual error message when authentication fails
64
+ */
65
+ static createContextualError({
66
+ apiKeyProvided,
67
+ oidcTokenProvided,
68
+ message = "Authentication failed",
69
+ statusCode = 401,
70
+ cause
71
+ }) {
72
+ let contextualMessage;
73
+ if (apiKeyProvided) {
74
+ contextualMessage = `AI Gateway authentication failed: Invalid API key provided.
75
+
76
+ The token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;
77
+ } else if (oidcTokenProvided) {
78
+ contextualMessage = `AI Gateway authentication failed: Invalid OIDC token provided.
79
+
80
+ The token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.
81
+ - make sure your Vercel project settings have OIDC enabled
82
+ - if running locally with 'vercel dev', the token is automatically obtained and refreshed
83
+ - if running locally with your own dev server, run 'vercel env pull' to fetch the token
84
+ - in production/preview, the token is automatically obtained and refreshed
85
+
86
+ Alternative: Provide an API key via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;
87
+ } else {
88
+ contextualMessage = `AI Gateway authentication failed: No authentication provided.
89
+
90
+ Provide either an API key or OIDC token.
91
+
92
+ API key instructions:
93
+
94
+ The token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
95
+
96
+ OIDC token instructions:
97
+
98
+ The token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.
99
+ - make sure your Vercel project settings have OIDC enabled
100
+ - if running locally with 'vercel dev', the token is automatically obtained and refreshed
101
+ - if running locally with your own dev server, run 'vercel env pull' to fetch the token
102
+ - in production/preview, the token is automatically obtained and refreshed`;
103
+ }
104
+ return new _GatewayAuthenticationError({
105
+ message: contextualMessage,
106
+ statusCode,
107
+ cause
108
+ });
109
+ }
110
+ };
111
+
112
+ // src/errors/gateway-invalid-request-error.ts
113
+ var name2 = "GatewayInvalidRequestError";
114
+ var marker3 = `vercel.ai.gateway.error.${name2}`;
115
+ var symbol3 = Symbol.for(marker3);
116
+ var _a3, _b3;
117
+ var GatewayInvalidRequestError = class extends (_b3 = GatewayError, _a3 = symbol3, _b3) {
118
+ constructor({
119
+ message = "Invalid request",
120
+ statusCode = 400,
121
+ cause
122
+ } = {}) {
123
+ super({ message, statusCode, cause });
124
+ this[_a3] = true;
125
+ // used in isInstance
126
+ this.name = name2;
127
+ this.type = "invalid_request_error";
128
+ }
129
+ static isInstance(error) {
130
+ return GatewayError.hasMarker(error) && symbol3 in error;
131
+ }
132
+ };
133
+
134
+ // src/errors/gateway-rate-limit-error.ts
135
+ var name3 = "GatewayRateLimitError";
136
+ var marker4 = `vercel.ai.gateway.error.${name3}`;
137
+ var symbol4 = Symbol.for(marker4);
138
+ var _a4, _b4;
139
+ var GatewayRateLimitError = class extends (_b4 = GatewayError, _a4 = symbol4, _b4) {
140
+ constructor({
141
+ message = "Rate limit exceeded",
142
+ statusCode = 429,
143
+ cause
144
+ } = {}) {
145
+ super({ message, statusCode, cause });
146
+ this[_a4] = true;
147
+ // used in isInstance
148
+ this.name = name3;
149
+ this.type = "rate_limit_exceeded";
150
+ }
151
+ static isInstance(error) {
152
+ return GatewayError.hasMarker(error) && symbol4 in error;
153
+ }
154
+ };
155
+
156
+ // src/errors/gateway-model-not-found-error.ts
157
+ import { z } from "zod/v4";
158
+ var name4 = "GatewayModelNotFoundError";
159
+ var marker5 = `vercel.ai.gateway.error.${name4}`;
160
+ var symbol5 = Symbol.for(marker5);
161
+ var modelNotFoundParamSchema = z.object({
162
+ modelId: z.string()
163
+ });
164
+ var _a5, _b5;
165
+ var GatewayModelNotFoundError = class extends (_b5 = GatewayError, _a5 = symbol5, _b5) {
166
+ constructor({
167
+ message = "Model not found",
168
+ statusCode = 404,
169
+ modelId,
170
+ cause
171
+ } = {}) {
172
+ super({ message, statusCode, cause });
173
+ this[_a5] = true;
174
+ // used in isInstance
175
+ this.name = name4;
176
+ this.type = "model_not_found";
177
+ this.modelId = modelId;
178
+ }
179
+ static isInstance(error) {
180
+ return GatewayError.hasMarker(error) && symbol5 in error;
181
+ }
182
+ };
183
+
184
+ // src/errors/gateway-internal-server-error.ts
185
+ var name5 = "GatewayInternalServerError";
186
+ var marker6 = `vercel.ai.gateway.error.${name5}`;
187
+ var symbol6 = Symbol.for(marker6);
188
+ var _a6, _b6;
189
+ var GatewayInternalServerError = class extends (_b6 = GatewayError, _a6 = symbol6, _b6) {
190
+ constructor({
191
+ message = "Internal server error",
192
+ statusCode = 500,
193
+ cause
194
+ } = {}) {
195
+ super({ message, statusCode, cause });
196
+ this[_a6] = true;
197
+ // used in isInstance
198
+ this.name = name5;
199
+ this.type = "internal_server_error";
200
+ }
201
+ static isInstance(error) {
202
+ return GatewayError.hasMarker(error) && symbol6 in error;
203
+ }
204
+ };
205
+
206
+ // src/errors/gateway-response-error.ts
207
+ var name6 = "GatewayResponseError";
208
+ var marker7 = `vercel.ai.gateway.error.${name6}`;
209
+ var symbol7 = Symbol.for(marker7);
210
+ var _a7, _b7;
211
+ var GatewayResponseError = class extends (_b7 = GatewayError, _a7 = symbol7, _b7) {
212
+ constructor({
213
+ message = "Invalid response from Gateway",
214
+ statusCode = 502,
215
+ response,
216
+ validationError,
217
+ cause
218
+ } = {}) {
219
+ super({ message, statusCode, cause });
220
+ this[_a7] = true;
221
+ // used in isInstance
222
+ this.name = name6;
223
+ this.type = "response_error";
224
+ this.response = response;
225
+ this.validationError = validationError;
226
+ }
227
+ static isInstance(error) {
228
+ return GatewayError.hasMarker(error) && symbol7 in error;
229
+ }
230
+ };
231
+
232
+ // src/errors/create-gateway-error.ts
233
+ function createGatewayErrorFromResponse({
234
+ response,
235
+ statusCode,
236
+ defaultMessage = "Gateway request failed",
237
+ cause,
238
+ authMethod
239
+ }) {
240
+ const parseResult = gatewayErrorResponseSchema.safeParse(response);
241
+ if (!parseResult.success) {
242
+ return new GatewayResponseError({
243
+ message: `Invalid error response format: ${defaultMessage}`,
244
+ statusCode,
245
+ response,
246
+ validationError: parseResult.error,
247
+ cause
248
+ });
249
+ }
250
+ const validatedResponse = parseResult.data;
251
+ const errorType = validatedResponse.error.type;
252
+ const message = validatedResponse.error.message;
253
+ switch (errorType) {
254
+ case "authentication_error":
255
+ return GatewayAuthenticationError.createContextualError({
256
+ apiKeyProvided: authMethod === "api-key",
257
+ oidcTokenProvided: authMethod === "oidc",
258
+ statusCode,
259
+ cause
260
+ });
261
+ case "invalid_request_error":
262
+ return new GatewayInvalidRequestError({ message, statusCode, cause });
263
+ case "rate_limit_exceeded":
264
+ return new GatewayRateLimitError({ message, statusCode, cause });
265
+ case "model_not_found": {
266
+ const modelResult = modelNotFoundParamSchema.safeParse(
267
+ validatedResponse.error.param
268
+ );
269
+ return new GatewayModelNotFoundError({
270
+ message,
271
+ statusCode,
272
+ modelId: modelResult.success ? modelResult.data.modelId : void 0,
273
+ cause
274
+ });
275
+ }
276
+ case "internal_server_error":
277
+ return new GatewayInternalServerError({ message, statusCode, cause });
278
+ default:
279
+ return new GatewayInternalServerError({ message, statusCode, cause });
280
+ }
281
+ }
282
+ var gatewayErrorResponseSchema = z2.object({
283
+ error: z2.object({
284
+ message: z2.string(),
285
+ type: z2.string().nullish(),
286
+ param: z2.unknown().nullish(),
287
+ code: z2.union([z2.string(), z2.number()]).nullish()
288
+ })
289
+ });
290
+
291
+ // src/errors/as-gateway-error.ts
292
+ function asGatewayError(error, authMethod) {
293
+ var _a8;
294
+ if (GatewayError.isInstance(error)) {
295
+ return error;
296
+ }
297
+ if (APICallError.isInstance(error)) {
298
+ return createGatewayErrorFromResponse({
299
+ response: extractApiCallResponse(error),
300
+ statusCode: (_a8 = error.statusCode) != null ? _a8 : 500,
301
+ defaultMessage: "Gateway request failed",
302
+ cause: error,
303
+ authMethod
304
+ });
305
+ }
306
+ return createGatewayErrorFromResponse({
307
+ response: {},
308
+ statusCode: 500,
309
+ defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
310
+ cause: error,
311
+ authMethod
312
+ });
313
+ }
314
+
315
+ // src/errors/extract-api-call-response.ts
316
+ function extractApiCallResponse(error) {
317
+ if (error.data !== void 0) {
318
+ return error.data;
319
+ }
320
+ if (error.responseBody != null) {
321
+ try {
322
+ return JSON.parse(error.responseBody);
323
+ } catch (e) {
324
+ return error.responseBody;
325
+ }
326
+ }
327
+ return {};
328
+ }
329
+
330
+ // src/errors/parse-auth-method.ts
331
+ import { z as z3 } from "zod/v4";
332
+ var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
333
+ function parseAuthMethod(headers) {
334
+ const result = gatewayAuthMethodSchema.safeParse(
335
+ headers[GATEWAY_AUTH_METHOD_HEADER]
336
+ );
337
+ return result.success ? result.data : void 0;
338
+ }
339
+ var gatewayAuthMethodSchema = z3.union([
340
+ z3.literal("api-key"),
341
+ z3.literal("oidc")
342
+ ]);
343
+
344
+ // src/gateway-fetch-metadata.ts
345
+ import {
346
+ createJsonErrorResponseHandler,
347
+ createJsonResponseHandler,
348
+ getFromApi,
349
+ resolve
350
+ } from "@ai-sdk/provider-utils";
351
+ import { z as z4 } from "zod/v4";
352
+ var GatewayFetchMetadata = class {
353
+ constructor(config) {
354
+ this.config = config;
355
+ }
356
+ async getAvailableModels() {
357
+ try {
358
+ const { value } = await getFromApi({
359
+ url: `${this.config.baseURL}/config`,
360
+ headers: await resolve(this.config.headers()),
361
+ successfulResponseHandler: createJsonResponseHandler(
362
+ gatewayFetchMetadataSchema
363
+ ),
364
+ failedResponseHandler: createJsonErrorResponseHandler({
365
+ errorSchema: z4.any(),
366
+ errorToMessage: (data) => data
367
+ }),
368
+ fetch: this.config.fetch
369
+ });
370
+ return value;
371
+ } catch (error) {
372
+ throw asGatewayError(error);
373
+ }
374
+ }
375
+ };
376
+ var gatewayLanguageModelSpecificationSchema = z4.object({
377
+ specificationVersion: z4.literal("v2"),
378
+ provider: z4.string(),
379
+ modelId: z4.string()
380
+ });
381
+ var gatewayLanguageModelPricingSchema = z4.object({
382
+ input: z4.string(),
383
+ output: z4.string()
384
+ });
385
+ var gatewayLanguageModelEntrySchema = z4.object({
386
+ id: z4.string(),
387
+ name: z4.string(),
388
+ description: z4.string().nullish(),
389
+ pricing: gatewayLanguageModelPricingSchema.nullish(),
390
+ specification: gatewayLanguageModelSpecificationSchema
391
+ });
392
+ var gatewayFetchMetadataSchema = z4.object({
393
+ models: z4.array(gatewayLanguageModelEntrySchema)
394
+ });
395
+
396
+ // src/gateway-language-model.ts
397
+ import {
398
+ combineHeaders,
399
+ createEventSourceResponseHandler,
400
+ createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
401
+ createJsonResponseHandler as createJsonResponseHandler2,
402
+ postJsonToApi,
403
+ resolve as resolve2
404
+ } from "@ai-sdk/provider-utils";
405
+ import { z as z5 } from "zod/v4";
406
+ var GatewayLanguageModel = class {
407
+ constructor(modelId, config) {
408
+ this.modelId = modelId;
409
+ this.config = config;
410
+ this.specificationVersion = "v2";
411
+ this.supportedUrls = { "*/*": [/.*/] };
412
+ }
413
+ get provider() {
414
+ return this.config.provider;
415
+ }
416
+ async getArgs(options) {
417
+ const { abortSignal: _abortSignal, ...optionsWithoutSignal } = options;
418
+ return {
419
+ args: this.maybeEncodeFileParts(optionsWithoutSignal),
420
+ warnings: []
421
+ };
422
+ }
423
+ async doGenerate(options) {
424
+ const { args, warnings } = await this.getArgs(options);
425
+ const { abortSignal } = options;
426
+ const resolvedHeaders = await resolve2(this.config.headers());
427
+ try {
428
+ const {
429
+ responseHeaders,
430
+ value: responseBody,
431
+ rawValue: rawResponse
432
+ } = await postJsonToApi({
433
+ url: this.getUrl(),
434
+ headers: combineHeaders(
435
+ resolvedHeaders,
436
+ options.headers,
437
+ this.getModelConfigHeaders(this.modelId, false),
438
+ await resolve2(this.config.o11yHeaders)
439
+ ),
440
+ body: args,
441
+ successfulResponseHandler: createJsonResponseHandler2(z5.any()),
442
+ failedResponseHandler: createJsonErrorResponseHandler2({
443
+ errorSchema: z5.any(),
444
+ errorToMessage: (data) => data
445
+ }),
446
+ ...abortSignal && { abortSignal },
447
+ fetch: this.config.fetch
448
+ });
449
+ return {
450
+ ...responseBody,
451
+ request: { body: args },
452
+ response: { headers: responseHeaders, body: rawResponse },
453
+ warnings
454
+ };
455
+ } catch (error) {
456
+ throw asGatewayError(error, parseAuthMethod(resolvedHeaders));
457
+ }
458
+ }
459
+ async doStream(options) {
460
+ const { args, warnings } = await this.getArgs(options);
461
+ const { abortSignal } = options;
462
+ const resolvedHeaders = await resolve2(this.config.headers());
463
+ try {
464
+ const { value: response, responseHeaders } = await postJsonToApi({
465
+ url: this.getUrl(),
466
+ headers: combineHeaders(
467
+ resolvedHeaders,
468
+ options.headers,
469
+ this.getModelConfigHeaders(this.modelId, true),
470
+ await resolve2(this.config.o11yHeaders)
471
+ ),
472
+ body: args,
473
+ successfulResponseHandler: createEventSourceResponseHandler(z5.any()),
474
+ failedResponseHandler: createJsonErrorResponseHandler2({
475
+ errorSchema: z5.any(),
476
+ errorToMessage: (data) => data
477
+ }),
478
+ ...abortSignal && { abortSignal },
479
+ fetch: this.config.fetch
480
+ });
481
+ return {
482
+ stream: response.pipeThrough(
483
+ new TransformStream({
484
+ start(controller) {
485
+ if (warnings.length > 0) {
486
+ controller.enqueue({ type: "stream-start", warnings });
487
+ }
488
+ },
489
+ transform(chunk, controller) {
490
+ if (chunk.success) {
491
+ const streamPart = chunk.value;
492
+ if (streamPart.type === "raw" && !options.includeRawChunks) {
493
+ return;
494
+ }
495
+ if (streamPart.type === "response-metadata" && streamPart.timestamp && typeof streamPart.timestamp === "string") {
496
+ streamPart.timestamp = new Date(streamPart.timestamp);
497
+ }
498
+ controller.enqueue(streamPart);
499
+ } else {
500
+ controller.error(
501
+ chunk.error
502
+ );
503
+ }
504
+ }
505
+ })
506
+ ),
507
+ request: { body: args },
508
+ response: { headers: responseHeaders }
509
+ };
510
+ } catch (error) {
511
+ throw asGatewayError(error, parseAuthMethod(resolvedHeaders));
512
+ }
513
+ }
514
+ isFilePart(part) {
515
+ return part && typeof part === "object" && "type" in part && part.type === "file";
516
+ }
517
+ /**
518
+ * Encodes file parts in the prompt to base64. Mutates the passed options
519
+ * instance directly to avoid copying the file data.
520
+ * @param options - The options to encode.
521
+ * @returns The options with the file parts encoded.
522
+ */
523
+ maybeEncodeFileParts(options) {
524
+ for (const message of options.prompt) {
525
+ for (const part of message.content) {
526
+ if (this.isFilePart(part)) {
527
+ const filePart = part;
528
+ if (filePart.data instanceof Uint8Array) {
529
+ const buffer = Uint8Array.from(filePart.data);
530
+ const base64Data = Buffer.from(buffer).toString("base64");
531
+ filePart.data = new URL(
532
+ `data:${filePart.mediaType || "application/octet-stream"};base64,${base64Data}`
533
+ );
534
+ }
535
+ }
536
+ }
537
+ }
538
+ return options;
539
+ }
540
+ getUrl() {
541
+ return `${this.config.baseURL}/language-model`;
542
+ }
543
+ getModelConfigHeaders(modelId, streaming) {
544
+ return {
545
+ "ai-language-model-specification-version": "2",
546
+ "ai-language-model-id": modelId,
547
+ "ai-language-model-streaming": String(streaming)
548
+ };
549
+ }
550
+ };
551
+
552
+ // src/gateway-embedding-model.ts
553
+ import {
554
+ combineHeaders as combineHeaders2,
555
+ createJsonResponseHandler as createJsonResponseHandler3,
556
+ createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
557
+ postJsonToApi as postJsonToApi2,
558
+ resolve as resolve3
559
+ } from "@ai-sdk/provider-utils";
560
+ import { z as z6 } from "zod/v4";
561
+ var GatewayEmbeddingModel = class {
562
+ constructor(modelId, config) {
563
+ this.modelId = modelId;
564
+ this.config = config;
565
+ this.specificationVersion = "v2";
566
+ this.maxEmbeddingsPerCall = 2048;
567
+ this.supportsParallelCalls = true;
568
+ }
569
+ get provider() {
570
+ return this.config.provider;
571
+ }
572
+ async doEmbed({
573
+ values,
574
+ headers,
575
+ abortSignal,
576
+ providerOptions
577
+ }) {
578
+ var _a8;
579
+ const resolvedHeaders = await resolve3(this.config.headers());
580
+ try {
581
+ const {
582
+ responseHeaders,
583
+ value: responseBody,
584
+ rawValue
585
+ } = await postJsonToApi2({
586
+ url: this.getUrl(),
587
+ headers: combineHeaders2(
588
+ resolvedHeaders,
589
+ headers != null ? headers : {},
590
+ this.getModelConfigHeaders(),
591
+ await resolve3(this.config.o11yHeaders)
592
+ ),
593
+ body: {
594
+ input: values.length === 1 ? values[0] : values,
595
+ ...providerOptions != null ? providerOptions : {}
596
+ },
597
+ successfulResponseHandler: createJsonResponseHandler3(
598
+ gatewayEmbeddingResponseSchema
599
+ ),
600
+ failedResponseHandler: createJsonErrorResponseHandler3({
601
+ errorSchema: z6.any(),
602
+ errorToMessage: (data) => data
603
+ }),
604
+ ...abortSignal && { abortSignal },
605
+ fetch: this.config.fetch
606
+ });
607
+ return {
608
+ embeddings: responseBody.embeddings,
609
+ usage: (_a8 = responseBody.usage) != null ? _a8 : void 0,
610
+ providerMetadata: responseBody.providerMetadata,
611
+ response: { headers: responseHeaders, body: rawValue }
612
+ };
613
+ } catch (error) {
614
+ throw asGatewayError(error, parseAuthMethod(resolvedHeaders));
615
+ }
616
+ }
617
+ getUrl() {
618
+ return `${this.config.baseURL}/embedding-model`;
619
+ }
620
+ getModelConfigHeaders() {
621
+ return {
622
+ "ai-embedding-model-specification-version": "2",
623
+ "ai-model-id": this.modelId
624
+ };
625
+ }
626
+ };
627
+ var gatewayEmbeddingResponseSchema = z6.object({
628
+ embeddings: z6.array(z6.array(z6.number())),
629
+ usage: z6.object({ tokens: z6.number() }).nullish(),
630
+ providerMetadata: z6.record(z6.string(), z6.record(z6.string(), z6.unknown())).optional()
631
+ });
632
+
633
+ // src/vercel-environment.ts
634
+ async function getVercelOidcToken() {
635
+ var _a8, _b8;
636
+ const token = (_b8 = (_a8 = getContext().headers) == null ? void 0 : _a8["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
637
+ if (!token) {
638
+ throw new GatewayAuthenticationError({
639
+ message: "OIDC token not available",
640
+ statusCode: 401
641
+ });
642
+ }
643
+ return token;
644
+ }
645
+ async function getVercelRequestId() {
646
+ var _a8;
647
+ return (_a8 = getContext().headers) == null ? void 0 : _a8["x-vercel-id"];
648
+ }
649
+ var SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
650
+ function getContext() {
651
+ var _a8, _b8, _c;
652
+ const fromSymbol = globalThis;
653
+ return (_c = (_b8 = (_a8 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a8.get) == null ? void 0 : _b8.call(_a8)) != null ? _c : {};
654
+ }
655
+
656
+ // src/gateway-provider.ts
657
+ var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
658
+ function createGatewayProvider(options = {}) {
659
+ var _a8, _b8;
660
+ let pendingMetadata = null;
661
+ let metadataCache = null;
662
+ const cacheRefreshMillis = (_a8 = options.metadataCacheRefreshMillis) != null ? _a8 : 1e3 * 60 * 5;
663
+ let lastFetchTime = 0;
664
+ const baseURL = (_b8 = withoutTrailingSlash(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
665
+ const getHeaders = async () => {
666
+ const auth = await getGatewayAuthToken(options);
667
+ if (auth) {
668
+ return {
669
+ Authorization: `Bearer ${auth.token}`,
670
+ "ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
671
+ [GATEWAY_AUTH_METHOD_HEADER]: auth.authMethod,
672
+ ...options.headers
673
+ };
674
+ }
675
+ throw GatewayAuthenticationError.createContextualError({
676
+ apiKeyProvided: false,
677
+ oidcTokenProvided: false,
678
+ statusCode: 401
679
+ });
680
+ };
681
+ const createO11yHeaders = () => {
682
+ const deploymentId = loadOptionalSetting({
683
+ settingValue: void 0,
684
+ environmentVariableName: "VERCEL_DEPLOYMENT_ID"
685
+ });
686
+ const environment = loadOptionalSetting({
687
+ settingValue: void 0,
688
+ environmentVariableName: "VERCEL_ENV"
689
+ });
690
+ const region = loadOptionalSetting({
691
+ settingValue: void 0,
692
+ environmentVariableName: "VERCEL_REGION"
693
+ });
694
+ return async () => {
695
+ const requestId = await getVercelRequestId();
696
+ return {
697
+ ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
698
+ ...environment && { "ai-o11y-environment": environment },
699
+ ...region && { "ai-o11y-region": region },
700
+ ...requestId && { "ai-o11y-request-id": requestId }
701
+ };
702
+ };
703
+ };
704
+ const createLanguageModel = (modelId) => {
705
+ return new GatewayLanguageModel(modelId, {
706
+ provider: "gateway",
707
+ baseURL,
708
+ headers: getHeaders,
709
+ fetch: options.fetch,
710
+ o11yHeaders: createO11yHeaders()
711
+ });
712
+ };
713
+ const getAvailableModels = async () => {
714
+ var _a9, _b9, _c;
715
+ const now = (_c = (_b9 = (_a9 = options._internal) == null ? void 0 : _a9.currentDate) == null ? void 0 : _b9.call(_a9).getTime()) != null ? _c : Date.now();
716
+ if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
717
+ lastFetchTime = now;
718
+ pendingMetadata = new GatewayFetchMetadata({
719
+ baseURL,
720
+ headers: getHeaders,
721
+ fetch: options.fetch
722
+ }).getAvailableModels().then((metadata) => {
723
+ metadataCache = metadata;
724
+ return metadata;
725
+ }).catch(async (error) => {
726
+ throw asGatewayError(error, parseAuthMethod(await getHeaders()));
727
+ });
728
+ }
729
+ return metadataCache ? Promise.resolve(metadataCache) : pendingMetadata;
730
+ };
731
+ const provider = function(modelId) {
732
+ if (new.target) {
733
+ throw new Error(
734
+ "The Gateway Provider model function cannot be called with the new keyword."
735
+ );
736
+ }
737
+ return createLanguageModel(modelId);
738
+ };
739
+ provider.getAvailableModels = getAvailableModels;
740
+ provider.imageModel = (modelId) => {
741
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
742
+ };
743
+ provider.languageModel = createLanguageModel;
744
+ provider.textEmbeddingModel = (modelId) => {
745
+ return new GatewayEmbeddingModel(modelId, {
746
+ provider: "gateway",
747
+ baseURL,
748
+ headers: getHeaders,
749
+ fetch: options.fetch,
750
+ o11yHeaders: createO11yHeaders()
751
+ });
752
+ };
753
+ return provider;
754
+ }
755
+ var gateway = createGatewayProvider();
756
+ async function getGatewayAuthToken(options) {
757
+ const apiKey = loadOptionalSetting({
758
+ settingValue: options.apiKey,
759
+ environmentVariableName: "AI_GATEWAY_API_KEY"
760
+ });
761
+ if (apiKey) {
762
+ return {
763
+ token: apiKey,
764
+ authMethod: "api-key"
765
+ };
766
+ }
767
+ try {
768
+ const oidcToken = await getVercelOidcToken();
769
+ return {
770
+ token: oidcToken,
771
+ authMethod: "oidc"
772
+ };
773
+ } catch (e) {
774
+ return null;
775
+ }
776
+ }
777
+ export {
778
+ GatewayAuthenticationError,
779
+ GatewayError,
780
+ GatewayInternalServerError,
781
+ GatewayInvalidRequestError,
782
+ GatewayModelNotFoundError,
783
+ GatewayRateLimitError,
784
+ GatewayResponseError,
785
+ createGatewayProvider as createGateway,
786
+ createGatewayProvider,
787
+ gateway
788
+ };
789
+ //# sourceMappingURL=index.mjs.map
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../src/gateway-provider.ts","../src/errors/as-gateway-error.ts","../src/errors/create-gateway-error.ts","../src/errors/gateway-error.ts","../src/errors/gateway-authentication-error.ts","../src/errors/gateway-invalid-request-error.ts","../src/errors/gateway-rate-limit-error.ts","../src/errors/gateway-model-not-found-error.ts","../src/errors/gateway-internal-server-error.ts","../src/errors/gateway-response-error.ts","../src/errors/extract-api-call-response.ts","../src/errors/parse-auth-method.ts","../src/gateway-fetch-metadata.ts","../src/gateway-language-model.ts","../src/gateway-embedding-model.ts","../src/vercel-environment.ts"],"sourcesContent":["import { NoSuchModelError } from '@ai-sdk/provider';\nimport {\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { asGatewayError, GatewayAuthenticationError } from './errors';\nimport {\n GATEWAY_AUTH_METHOD_HEADER,\n parseAuthMethod,\n} from './errors/parse-auth-method';\nimport {\n GatewayFetchMetadata,\n type GatewayFetchMetadataResponse,\n} from './gateway-fetch-metadata';\nimport { GatewayLanguageModel } from './gateway-language-model';\nimport { GatewayEmbeddingModel } from './gateway-embedding-model';\nimport type { GatewayEmbeddingModelId } from './gateway-embedding-model-settings';\nimport { getVercelOidcToken, getVercelRequestId } from './vercel-environment';\nimport type { GatewayModelId } from './gateway-language-model-settings';\nimport type {\n LanguageModelV2,\n EmbeddingModelV2,\n ProviderV2,\n} from '@ai-sdk/provider';\n\nexport interface GatewayProvider extends ProviderV2 {\n (modelId: GatewayModelId): LanguageModelV2;\n\n /**\nCreates a model for text generation.\n*/\n languageModel(modelId: GatewayModelId): LanguageModelV2;\n\n /**\nReturns available providers and models for use with the remote provider.\n */\n getAvailableModels(): Promise<GatewayFetchMetadataResponse>;\n\n /**\nCreates a model for generating text embeddings.\n*/\n textEmbeddingModel(\n modelId: GatewayEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n}\n\nexport interface GatewayProviderSettings {\n /**\nThe base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.\n */\n baseURL?: string;\n\n /**\nAPI key that is being sent using the `Authorization` header.\n */\n apiKey?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\nHow frequently to refresh the metadata cache in milliseconds.\n */\n metadataCacheRefreshMillis?: number;\n\n /**\n * @internal For testing purposes only\n */\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nconst AI_GATEWAY_PROTOCOL_VERSION = '0.0.1';\n\n/**\nCreate a remote provider instance.\n */\nexport function createGatewayProvider(\n options: GatewayProviderSettings = {},\n): GatewayProvider {\n let pendingMetadata: Promise<GatewayFetchMetadataResponse> | null = null;\n let metadataCache: GatewayFetchMetadataResponse | null = null;\n const cacheRefreshMillis =\n options.metadataCacheRefreshMillis ?? 1000 * 60 * 5;\n let lastFetchTime = 0;\n\n const baseURL =\n withoutTrailingSlash(options.baseURL) ??\n 'https://ai-gateway.vercel.sh/v1/ai';\n\n const getHeaders = async () => {\n const auth = await getGatewayAuthToken(options);\n if (auth) {\n return {\n Authorization: `Bearer ${auth.token}`,\n 'ai-gateway-protocol-version': AI_GATEWAY_PROTOCOL_VERSION,\n [GATEWAY_AUTH_METHOD_HEADER]: auth.authMethod,\n ...options.headers,\n };\n }\n\n throw GatewayAuthenticationError.createContextualError({\n apiKeyProvided: false,\n oidcTokenProvided: false,\n statusCode: 401,\n });\n };\n\n const createO11yHeaders = () => {\n const deploymentId = loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'VERCEL_DEPLOYMENT_ID',\n });\n const environment = loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'VERCEL_ENV',\n });\n const region = loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'VERCEL_REGION',\n });\n\n return async () => {\n const requestId = await getVercelRequestId();\n return {\n ...(deploymentId && { 'ai-o11y-deployment-id': deploymentId }),\n ...(environment && { 'ai-o11y-environment': environment }),\n ...(region && { 'ai-o11y-region': region }),\n ...(requestId && { 'ai-o11y-request-id': requestId }),\n };\n };\n };\n\n const createLanguageModel = (modelId: GatewayModelId) => {\n return new GatewayLanguageModel(modelId, {\n provider: 'gateway',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n o11yHeaders: createO11yHeaders(),\n });\n };\n\n const getAvailableModels = async () => {\n const now = options._internal?.currentDate?.().getTime() ?? Date.now();\n if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {\n lastFetchTime = now;\n\n pendingMetadata = new GatewayFetchMetadata({\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n })\n .getAvailableModels()\n .then(metadata => {\n metadataCache = metadata;\n return metadata;\n })\n .catch(async (error: unknown) => {\n throw asGatewayError(error, parseAuthMethod(await getHeaders()));\n });\n }\n\n return metadataCache ? Promise.resolve(metadataCache) : pendingMetadata;\n };\n\n const provider = function (modelId: GatewayModelId) {\n if (new.target) {\n throw new Error(\n 'The Gateway Provider model function cannot be called with the new keyword.',\n );\n }\n\n return createLanguageModel(modelId);\n };\n\n provider.getAvailableModels = getAvailableModels;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.languageModel = createLanguageModel;\n provider.textEmbeddingModel = (modelId: GatewayEmbeddingModelId) => {\n return new GatewayEmbeddingModel(modelId, {\n provider: 'gateway',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n o11yHeaders: createO11yHeaders(),\n });\n };\n\n return provider;\n}\n\nexport const gateway = createGatewayProvider();\n\nexport async function getGatewayAuthToken(\n options: GatewayProviderSettings,\n): Promise<{\n token: string;\n authMethod: 'api-key' | 'oidc';\n} | null> {\n const apiKey = loadOptionalSetting({\n settingValue: options.apiKey,\n environmentVariableName: 'AI_GATEWAY_API_KEY',\n });\n\n if (apiKey) {\n return {\n token: apiKey,\n authMethod: 'api-key',\n };\n }\n\n try {\n const oidcToken = await getVercelOidcToken();\n return {\n token: oidcToken,\n authMethod: 'oidc',\n };\n } catch {\n return null;\n }\n}\n","import { APICallError } from '@ai-sdk/provider';\nimport { extractApiCallResponse, GatewayError } from '.';\nimport { createGatewayErrorFromResponse } from './create-gateway-error';\n\nexport function asGatewayError(\n error: unknown,\n authMethod?: 'api-key' | 'oidc',\n) {\n if (GatewayError.isInstance(error)) {\n return error;\n }\n\n if (APICallError.isInstance(error)) {\n return createGatewayErrorFromResponse({\n response: extractApiCallResponse(error),\n statusCode: error.statusCode ?? 500,\n defaultMessage: 'Gateway request failed',\n cause: error,\n authMethod,\n });\n }\n\n return createGatewayErrorFromResponse({\n response: {},\n statusCode: 500,\n defaultMessage:\n error instanceof Error\n ? `Gateway request failed: ${error.message}`\n : 'Unknown Gateway error',\n cause: error,\n authMethod,\n });\n}\n","import { z } from 'zod/v4';\nimport type { GatewayError } from './gateway-error';\nimport { GatewayAuthenticationError } from './gateway-authentication-error';\nimport { GatewayInvalidRequestError } from './gateway-invalid-request-error';\nimport { GatewayRateLimitError } from './gateway-rate-limit-error';\nimport {\n GatewayModelNotFoundError,\n modelNotFoundParamSchema,\n} from './gateway-model-not-found-error';\nimport { GatewayInternalServerError } from './gateway-internal-server-error';\nimport { GatewayResponseError } from './gateway-response-error';\n\nexport function createGatewayErrorFromResponse({\n response,\n statusCode,\n defaultMessage = 'Gateway request failed',\n cause,\n authMethod,\n}: {\n response: unknown;\n statusCode: number;\n defaultMessage?: string;\n cause?: unknown;\n authMethod?: 'api-key' | 'oidc';\n}): GatewayError {\n const parseResult = gatewayErrorResponseSchema.safeParse(response);\n if (!parseResult.success) {\n return new GatewayResponseError({\n message: `Invalid error response format: ${defaultMessage}`,\n statusCode,\n response,\n validationError: parseResult.error,\n cause,\n });\n }\n\n const validatedResponse: GatewayErrorResponse = parseResult.data;\n const errorType = validatedResponse.error.type;\n const message = validatedResponse.error.message;\n\n switch (errorType) {\n case 'authentication_error':\n return GatewayAuthenticationError.createContextualError({\n apiKeyProvided: authMethod === 'api-key',\n oidcTokenProvided: authMethod === 'oidc',\n statusCode,\n cause,\n });\n case 'invalid_request_error':\n return new GatewayInvalidRequestError({ message, statusCode, cause });\n case 'rate_limit_exceeded':\n return new GatewayRateLimitError({ message, statusCode, cause });\n case 'model_not_found': {\n const modelResult = modelNotFoundParamSchema.safeParse(\n validatedResponse.error.param,\n );\n return new GatewayModelNotFoundError({\n message,\n statusCode,\n modelId: modelResult.success ? modelResult.data.modelId : undefined,\n cause,\n });\n }\n case 'internal_server_error':\n return new GatewayInternalServerError({ message, statusCode, cause });\n default:\n return new GatewayInternalServerError({ message, statusCode, cause });\n }\n}\n\nconst gatewayErrorResponseSchema = z.object({\n error: z.object({\n message: z.string(),\n type: z.string().nullish(),\n param: z.unknown().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n});\n\nexport type GatewayErrorResponse = z.infer<typeof gatewayErrorResponseSchema>;\n","const marker = 'vercel.ai.gateway.error';\nconst symbol = Symbol.for(marker);\n\nexport abstract class GatewayError extends Error {\n private readonly [symbol] = true; // used in isInstance\n\n abstract readonly name: string;\n abstract readonly type: string;\n readonly statusCode: number;\n readonly cause?: unknown;\n\n constructor({\n message,\n statusCode = 500,\n cause,\n }: {\n message: string;\n statusCode?: number;\n cause?: unknown;\n }) {\n super(message);\n this.statusCode = statusCode;\n this.cause = cause;\n }\n\n /**\n * Checks if the given error is a Gateway Error.\n * @param {unknown} error - The error to check.\n * @returns {boolean} True if the error is a Gateway Error, false otherwise.\n */\n static isInstance(error: unknown): error is GatewayError {\n return GatewayError.hasMarker(error);\n }\n\n static hasMarker(error: unknown): error is GatewayError {\n return (\n typeof error === 'object' &&\n error !== null &&\n symbol in error &&\n (error as any)[symbol] === true\n );\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayAuthenticationError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Authentication failed - invalid API key or OIDC token\n */\nexport class GatewayAuthenticationError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'authentication_error';\n\n constructor({\n message = 'Authentication failed',\n statusCode = 401,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayAuthenticationError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n\n /**\n * Creates a contextual error message when authentication fails\n */\n static createContextualError({\n apiKeyProvided,\n oidcTokenProvided,\n message = 'Authentication failed',\n statusCode = 401,\n cause,\n }: {\n apiKeyProvided: boolean;\n oidcTokenProvided: boolean;\n message?: string;\n statusCode?: number;\n cause?: unknown;\n }): GatewayAuthenticationError {\n let contextualMessage: string;\n\n if (apiKeyProvided) {\n contextualMessage = `AI Gateway authentication failed: Invalid API key provided.\n\nThe token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;\n } else if (oidcTokenProvided) {\n contextualMessage = `AI Gateway authentication failed: Invalid OIDC token provided.\n\nThe token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.\n- make sure your Vercel project settings have OIDC enabled\n- if running locally with 'vercel dev', the token is automatically obtained and refreshed\n- if running locally with your own dev server, run 'vercel env pull' to fetch the token\n- in production/preview, the token is automatically obtained and refreshed\n\nAlternative: Provide an API key via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`;\n } else {\n contextualMessage = `AI Gateway authentication failed: No authentication provided.\n\nProvide either an API key or OIDC token.\n\nAPI key instructions:\n\nThe token is expected to be provided via the 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.\n\nOIDC token instructions:\n\nThe token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.\n- make sure your Vercel project settings have OIDC enabled\n- if running locally with 'vercel dev', the token is automatically obtained and refreshed\n- if running locally with your own dev server, run 'vercel env pull' to fetch the token\n- in production/preview, the token is automatically obtained and refreshed`;\n }\n\n return new GatewayAuthenticationError({\n message: contextualMessage,\n statusCode,\n cause,\n });\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayInvalidRequestError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Invalid request - missing headers, malformed data, etc.\n */\nexport class GatewayInvalidRequestError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'invalid_request_error';\n\n constructor({\n message = 'Invalid request',\n statusCode = 400,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayInvalidRequestError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayRateLimitError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Rate limit exceeded.\n */\nexport class GatewayRateLimitError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'rate_limit_exceeded';\n\n constructor({\n message = 'Rate limit exceeded',\n statusCode = 429,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayRateLimitError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { z } from 'zod/v4';\nimport { GatewayError } from './gateway-error';\n\nconst name = 'GatewayModelNotFoundError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport const modelNotFoundParamSchema = z.object({\n modelId: z.string(),\n});\n\n/**\n * Model not found or not available\n */\nexport class GatewayModelNotFoundError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'model_not_found';\n readonly modelId?: string;\n\n constructor({\n message = 'Model not found',\n statusCode = 404,\n modelId,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n modelId?: string;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n this.modelId = modelId;\n }\n\n static isInstance(error: unknown): error is GatewayModelNotFoundError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { GatewayError } from './gateway-error';\n\nconst name = 'GatewayInternalServerError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Internal server error from the Gateway\n */\nexport class GatewayInternalServerError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'internal_server_error';\n\n constructor({\n message = 'Internal server error',\n statusCode = 500,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n }\n\n static isInstance(error: unknown): error is GatewayInternalServerError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import { GatewayError } from './gateway-error';\nimport type { ZodError } from 'zod/v4';\n\nconst name = 'GatewayResponseError';\nconst marker = `vercel.ai.gateway.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Gateway response parsing error\n */\nexport class GatewayResponseError extends GatewayError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly name = name;\n readonly type = 'response_error';\n readonly response?: unknown;\n readonly validationError?: ZodError;\n\n constructor({\n message = 'Invalid response from Gateway',\n statusCode = 502,\n response,\n validationError,\n cause,\n }: {\n message?: string;\n statusCode?: number;\n response?: unknown;\n validationError?: ZodError;\n cause?: unknown;\n } = {}) {\n super({ message, statusCode, cause });\n this.response = response;\n this.validationError = validationError;\n }\n\n static isInstance(error: unknown): error is GatewayResponseError {\n return GatewayError.hasMarker(error) && symbol in error;\n }\n}\n","import type { APICallError } from '@ai-sdk/provider';\n\nexport function extractApiCallResponse(error: APICallError): unknown {\n if (error.data !== undefined) {\n return error.data;\n }\n if (error.responseBody != null) {\n try {\n return JSON.parse(error.responseBody);\n } catch {\n return error.responseBody;\n }\n }\n return {};\n}\n","import { z } from 'zod/v4';\n\nexport const GATEWAY_AUTH_METHOD_HEADER = 'ai-gateway-auth-method' as const;\n\nexport function parseAuthMethod(headers: Record<string, string | undefined>) {\n const result = gatewayAuthMethodSchema.safeParse(\n headers[GATEWAY_AUTH_METHOD_HEADER],\n );\n return result.success ? result.data : undefined;\n}\n\nconst gatewayAuthMethodSchema = z.union([\n z.literal('api-key'),\n z.literal('oidc'),\n]);\n","import {\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n getFromApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { asGatewayError } from './errors';\nimport type { GatewayConfig } from './gateway-config';\nimport type { GatewayLanguageModelEntry } from './gateway-model-entry';\nimport { z } from 'zod/v4';\n\ntype GatewayFetchMetadataConfig = GatewayConfig;\n\nexport interface GatewayFetchMetadataResponse {\n models: GatewayLanguageModelEntry[];\n}\n\nexport class GatewayFetchMetadata {\n constructor(private readonly config: GatewayFetchMetadataConfig) {}\n\n async getAvailableModels(): Promise<GatewayFetchMetadataResponse> {\n try {\n const { value } = await getFromApi({\n url: `${this.config.baseURL}/config`,\n headers: await resolve(this.config.headers()),\n successfulResponseHandler: createJsonResponseHandler(\n gatewayFetchMetadataSchema,\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n fetch: this.config.fetch,\n });\n\n return value;\n } catch (error) {\n throw asGatewayError(error);\n }\n }\n}\n\nconst gatewayLanguageModelSpecificationSchema = z.object({\n specificationVersion: z.literal('v2'),\n provider: z.string(),\n modelId: z.string(),\n});\n\nconst gatewayLanguageModelPricingSchema = z.object({\n input: z.string(),\n output: z.string(),\n});\n\nconst gatewayLanguageModelEntrySchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().nullish(),\n pricing: gatewayLanguageModelPricingSchema.nullish(),\n specification: gatewayLanguageModelSpecificationSchema,\n});\n\nconst gatewayFetchMetadataSchema = z.object({\n models: z.array(gatewayLanguageModelEntrySchema),\n});\n","import type {\n LanguageModelV2,\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n LanguageModelV2FilePart,\n LanguageModelV2StreamPart,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n postJsonToApi,\n resolve,\n type ParseResult,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { GatewayConfig } from './gateway-config';\nimport type { GatewayModelId } from './gateway-language-model-settings';\nimport { asGatewayError } from './errors';\nimport { parseAuthMethod } from './errors/parse-auth-method';\n\ntype GatewayChatConfig = GatewayConfig & {\n provider: string;\n o11yHeaders: Resolvable<Record<string, string>>;\n};\n\nexport class GatewayLanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n readonly supportedUrls = { '*/*': [/.*/] };\n\n constructor(\n readonly modelId: GatewayModelId,\n private readonly config: GatewayChatConfig,\n ) {}\n\n get provider(): string {\n return this.config.provider;\n }\n\n private async getArgs(options: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const { abortSignal: _abortSignal, ...optionsWithoutSignal } = options;\n\n return {\n args: this.maybeEncodeFileParts(optionsWithoutSignal),\n warnings: [],\n };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings } = await this.getArgs(options);\n const { abortSignal } = options;\n\n const resolvedHeaders = await resolve(this.config.headers());\n\n try {\n const {\n responseHeaders,\n value: responseBody,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.getUrl(),\n headers: combineHeaders(\n resolvedHeaders,\n options.headers,\n this.getModelConfigHeaders(this.modelId, false),\n await resolve(this.config.o11yHeaders),\n ),\n body: args,\n successfulResponseHandler: createJsonResponseHandler(z.any()),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n ...(abortSignal && { abortSignal }),\n fetch: this.config.fetch,\n });\n\n return {\n ...responseBody,\n request: { body: args },\n response: { headers: responseHeaders, body: rawResponse },\n warnings,\n };\n } catch (error) {\n throw asGatewayError(error, parseAuthMethod(resolvedHeaders));\n }\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings } = await this.getArgs(options);\n const { abortSignal } = options;\n\n const resolvedHeaders = await resolve(this.config.headers());\n\n try {\n const { value: response, responseHeaders } = await postJsonToApi({\n url: this.getUrl(),\n headers: combineHeaders(\n resolvedHeaders,\n options.headers,\n this.getModelConfigHeaders(this.modelId, true),\n await resolve(this.config.o11yHeaders),\n ),\n body: args,\n successfulResponseHandler: createEventSourceResponseHandler(z.any()),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n ...(abortSignal && { abortSignal }),\n fetch: this.config.fetch,\n });\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<LanguageModelV2StreamPart>,\n LanguageModelV2StreamPart\n >({\n start(controller) {\n if (warnings.length > 0) {\n controller.enqueue({ type: 'stream-start', warnings });\n }\n },\n transform(chunk, controller) {\n if (chunk.success) {\n const streamPart = chunk.value;\n\n // Handle raw chunks: if this is a raw chunk from the gateway API,\n // only emit it if includeRawChunks is true\n if (streamPart.type === 'raw' && !options.includeRawChunks) {\n return; // Skip raw chunks if not requested\n }\n\n if (\n streamPart.type === 'response-metadata' &&\n streamPart.timestamp &&\n typeof streamPart.timestamp === 'string'\n ) {\n streamPart.timestamp = new Date(streamPart.timestamp);\n }\n\n controller.enqueue(streamPart);\n } else {\n controller.error(\n (chunk as { success: false; error: unknown }).error,\n );\n }\n },\n }),\n ),\n request: { body: args },\n response: { headers: responseHeaders },\n };\n } catch (error) {\n throw asGatewayError(error, parseAuthMethod(resolvedHeaders));\n }\n }\n\n private isFilePart(part: unknown) {\n return (\n part && typeof part === 'object' && 'type' in part && part.type === 'file'\n );\n }\n\n /**\n * Encodes file parts in the prompt to base64. Mutates the passed options\n * instance directly to avoid copying the file data.\n * @param options - The options to encode.\n * @returns The options with the file parts encoded.\n */\n private maybeEncodeFileParts(options: LanguageModelV2CallOptions) {\n for (const message of options.prompt) {\n for (const part of message.content) {\n if (this.isFilePart(part)) {\n const filePart = part as LanguageModelV2FilePart;\n // If the file part is a URL it will get cleanly converted to a string.\n // If it's a binary file attachment we convert it to a data url.\n // In either case, server-side we should only ever see URLs as strings.\n if (filePart.data instanceof Uint8Array) {\n const buffer = Uint8Array.from(filePart.data);\n const base64Data = Buffer.from(buffer).toString('base64');\n filePart.data = new URL(\n `data:${filePart.mediaType || 'application/octet-stream'};base64,${base64Data}`,\n );\n }\n }\n }\n }\n return options;\n }\n\n private getUrl() {\n return `${this.config.baseURL}/language-model`;\n }\n\n private getModelConfigHeaders(modelId: string, streaming: boolean) {\n return {\n 'ai-language-model-specification-version': '2',\n 'ai-language-model-id': modelId,\n 'ai-language-model-streaming': String(streaming),\n };\n }\n}\n","import type { EmbeddingModelV2 } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n createJsonErrorResponseHandler,\n postJsonToApi,\n resolve,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { GatewayConfig } from './gateway-config';\nimport { asGatewayError } from './errors';\nimport { parseAuthMethod } from './errors/parse-auth-method';\nimport type { SharedV2ProviderMetadata } from '@ai-sdk/provider';\n\nexport class GatewayEmbeddingModel implements EmbeddingModelV2<string> {\n readonly specificationVersion = 'v2';\n readonly maxEmbeddingsPerCall = 2048;\n readonly supportsParallelCalls = true;\n\n constructor(\n readonly modelId: string,\n private readonly config: GatewayConfig & {\n provider: string;\n o11yHeaders: Resolvable<Record<string, string>>;\n },\n ) {}\n\n get provider(): string {\n return this.config.provider;\n }\n\n async doEmbed({\n values,\n headers,\n abortSignal,\n providerOptions,\n }: Parameters<EmbeddingModelV2<string>['doEmbed']>[0]): Promise<\n Awaited<ReturnType<EmbeddingModelV2<string>['doEmbed']>>\n > {\n const resolvedHeaders = await resolve(this.config.headers());\n try {\n const {\n responseHeaders,\n value: responseBody,\n rawValue,\n } = await postJsonToApi({\n url: this.getUrl(),\n headers: combineHeaders(\n resolvedHeaders,\n headers ?? {},\n this.getModelConfigHeaders(),\n await resolve(this.config.o11yHeaders),\n ),\n body: {\n input: values.length === 1 ? values[0] : values,\n ...(providerOptions ?? {}),\n },\n successfulResponseHandler: createJsonResponseHandler(\n gatewayEmbeddingResponseSchema,\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.any(),\n errorToMessage: data => data,\n }),\n ...(abortSignal && { abortSignal }),\n fetch: this.config.fetch,\n });\n\n return {\n embeddings: responseBody.embeddings,\n usage: responseBody.usage ?? undefined,\n providerMetadata:\n responseBody.providerMetadata as unknown as SharedV2ProviderMetadata,\n response: { headers: responseHeaders, body: rawValue },\n };\n } catch (error) {\n throw asGatewayError(error, parseAuthMethod(resolvedHeaders));\n }\n }\n\n private getUrl() {\n return `${this.config.baseURL}/embedding-model`;\n }\n\n private getModelConfigHeaders() {\n return {\n 'ai-embedding-model-specification-version': '2',\n 'ai-model-id': this.modelId,\n };\n }\n}\n\nconst gatewayEmbeddingResponseSchema = z.object({\n embeddings: z.array(z.array(z.number())),\n usage: z.object({ tokens: z.number() }).nullish(),\n providerMetadata: z\n .record(z.string(), z.record(z.string(), z.unknown()))\n .optional(),\n});\n","import { GatewayAuthenticationError } from './errors';\n\nexport async function getVercelOidcToken(): Promise<string> {\n const token =\n getContext().headers?.['x-vercel-oidc-token'] ??\n process.env.VERCEL_OIDC_TOKEN;\n\n if (!token) {\n throw new GatewayAuthenticationError({\n message: 'OIDC token not available',\n statusCode: 401,\n });\n }\n\n return token;\n}\n\nexport async function getVercelRequestId(): Promise<string | undefined> {\n return getContext().headers?.['x-vercel-id'];\n}\n\ntype Context = {\n headers?: Record<string, string>;\n};\n\nconst SYMBOL_FOR_REQ_CONTEXT = Symbol.for('@vercel/request-context');\n\nfunction getContext(): Context {\n const fromSymbol: typeof globalThis & {\n [SYMBOL_FOR_REQ_CONTEXT]?: { get?: () => Context };\n } = globalThis;\n return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;;;ACLP,SAAS,oBAAoB;;;ACA7B,SAAS,KAAAA,UAAS;;;ACAlB,IAAM,SAAS;AACf,IAAM,SAAS,OAAO,IAAI,MAAM;AADhC;AAGO,IAAe,eAAf,MAAe,uBAAqB,YACvB,aADuB,IAAM;AAAA,EAQ/C,YAAY;AAAA,IACV;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACF,GAIG;AACD,UAAM,OAAO;AAhBf,SAAkB,MAAU;AAiB1B,SAAK,aAAa;AAClB,SAAK,QAAQ;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,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H;AAEA,SAAO;AACT;AAEO,IAAM,UAAU,sBAAsB;AAE7C,eAAsB,oBACpB,SAIQ;AACR,QAAM,SAAS,oBAAoB;AAAA,IACjC,cAAc,QAAQ;AAAA,IACtB,yBAAyB;AAAA,EAC3B,CAAC;AAED,MAAI,QAAQ;AACV,WAAO;AAAA,MACL,OAAO;AAAA,MACP,YAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI;AACF,UAAM,YAAY,MAAM,mBAAmB;AAC3C,WAAO;AAAA,MACL,OAAO;AAAA,MACP,YAAY;AAAA,IACd;AAAA,EACF,SAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["z","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","z","_a","z","z","createJsonErrorResponseHandler","createJsonResponseHandler","resolve","z","resolve","createJsonResponseHandler","z","createJsonErrorResponseHandler","combineHeaders","createJsonResponseHandler","createJsonErrorResponseHandler","postJsonToApi","resolve","z","_a","resolve","postJsonToApi","combineHeaders","createJsonResponseHandler","createJsonErrorResponseHandler","z","_a","_b","_a","_b"]}
node_modules/.pnpm/@ai-sdk+gateway@1.0.4_zod@3.25.76/node_modules/@ai-sdk/gateway/package.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@ai-sdk/gateway",
3
+ "private": false,
4
+ "version": "1.0.4",
5
+ "license": "Apache-2.0",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.mjs",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "dist/**/*",
12
+ "CHANGELOG.md"
13
+ ],
14
+ "exports": {
15
+ "./package.json": "./package.json",
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.js"
20
+ }
21
+ },
22
+ "dependencies": {
23
+ "@ai-sdk/provider": "2.0.0",
24
+ "@ai-sdk/provider-utils": "3.0.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "18.15.11",
28
+ "tsup": "^8",
29
+ "typescript": "5.8.3",
30
+ "zod": "3.25.76",
31
+ "@vercel/ai-tsconfig": "0.0.0"
32
+ },
33
+ "peerDependencies": {
34
+ "zod": "^3.25.76 || ^4"
35
+ },
36
+ "engines": {
37
+ "node": ">=18"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "homepage": "https://ai-sdk.dev/docs",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/vercel/ai.git"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/vercel/ai/issues"
49
+ },
50
+ "keywords": [
51
+ "ai"
52
+ ],
53
+ "scripts": {
54
+ "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
55
+ "build:watch": "pnpm clean && tsup --watch",
56
+ "clean": "rm -rf dist *.tsbuildinfo",
57
+ "lint": "eslint \"./**/*.ts*\"",
58
+ "type-check": "tsc --build",
59
+ "prettier-check": "prettier --check \"./**/*.ts*\"",
60
+ "test": "pnpm test:node && pnpm test:edge",
61
+ "test:update": "pnpm test:node -u",
62
+ "test:watch": "vitest --config vitest.node.config.js",
63
+ "test:edge": "vitest --config vitest.edge.config.js --run",
64
+ "test:node": "vitest --config vitest.node.config.js --run"
65
+ }
66
+ }
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/CHANGELOG.md ADDED
@@ -0,0 +1,1584 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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+
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 961dda1: add labels field to providerOptions
8
+
9
+ ## 2.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 9fb0252: fix(google): add thought signature support for reasoning
14
+
15
+ ## 2.0.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [90d212f]
20
+ - @ai-sdk/provider-utils@3.0.1
21
+
22
+ ## 2.0.1
23
+
24
+ ### Patch Changes
25
+
26
+ - f5464aa: feat(google): update docs + add YouTube URL support to Google Generative AI provider
27
+
28
+ ## 2.0.0
29
+
30
+ ### Major Changes
31
+
32
+ - d5f588f: AI SDK 5
33
+
34
+ ### Patch Changes
35
+
36
+ - 78e7fa9: Add code execution provider defined tool
37
+ - f916255: feat (provider/google): add new gemini models
38
+ - 19a4336: Expose raw usageMetadata returned from Google Generative AI in providerMetadata
39
+ - 8af9e03: Added Image Models to the Google Provider for Imagen 3 Support
40
+ - 1a635b5: update supportedUrls to only support native URL
41
+ - 888b750: feat(providers/google): Add taskType support for Text Embedding Models
42
+ - 3259565: feat (providers/google): add thinking config to provider options
43
+ - e2aceaf: feat: add raw chunk support
44
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
45
+ - 6a16dcf: embed() now uses the single embeddings endpoint
46
+ No code updates are needed.
47
+
48
+ This is to make sure that users are not ratelimited when using the batch endpoint, since many models have different limits for batch and single embeddings.
49
+
50
+ Eg: Google has a limit of 150 RPM for batch requests, and 1500 RPM for single requests.
51
+
52
+ Before, AI SDK would always use the batch endpoint, even for embed() calls, which led to ratelimits.
53
+
54
+ This does not have any breaking functionality and is fully tested :)
55
+ if (values.length > 1) {
56
+ const batchResult = await this.doEmbedBatch({
57
+ values,
58
+ options,
59
+ });
60
+ return batchResult;
61
+ }
62
+
63
+ - 26735b5: chore(embedding-model): add v2 interface
64
+ - 5cf30ea: fix (provider/google): allow "OFF" for Google HarmBlockThreshold
65
+ - 443d8ec: feat(embedding-model-v2): add response body field
66
+ - c68931f: Support tool schemas that allow additional properties (e.g `z.record(z.string())`)
67
+ - 66962ed: fix(packages): export node10 compatible types
68
+ - a313780: fix: omit system message for gemma models
69
+ - fd98925: chore(providers/google): update embedding model to use providerOptions
70
+ - cb787ac: fix: remove non-functional models
71
+ - 7378473: chore(providers/google): switch to providerOptions
72
+ - f07a6d4: fix(providers/google): accept nullish in safetyRatings
73
+ - 75f03b1: Add Gemini 2.5 Flash Lite GA
74
+ - 779d916: feat: add provider option schemas for vertex imagegen and google genai
75
+ - 581a9be: fix (provider/google): prevent error when thinking signature is used
76
+ - 2e06f14: feat (provider/google): Change to provider defined tools
77
+
78
+ - Change the google search tool to be a provider defined tool
79
+ - Added new URL context tool as a provider defined tool
80
+
81
+ - 8e6b69d: feat(providers/google): Add support for Gemini 2.5 Pro and Gemini 2.5 Flash (now stable)
82
+ - 42fcd32: feat(google): automatically handle system instructions for Gemma models
83
+ - d1a034f: feature: using Zod 4 for internal stuff
84
+ - fd65bc6: chore(embedding-model-v2): rename rawResponse to response
85
+ - 878bf45: removes (unsupported) `additionalProperties` from the Schema sent in the request payloads to Google APIs
86
+ - 0f05690: Add gemini-embedding-001 model, add embedding provider options type export
87
+ - 7badba2: fix(google): grounding streaming sources
88
+ - 205077b: fix: improve Zod compatibility
89
+ - f10304b: feat(tool-calling): don't require the user to have to pass parameters
90
+ - Updated dependencies [a571d6e]
91
+ - Updated dependencies [742b7be]
92
+ - Updated dependencies [e7fcc86]
93
+ - Updated dependencies [7cddb72]
94
+ - Updated dependencies [ccce59b]
95
+ - Updated dependencies [e2b9e4b]
96
+ - Updated dependencies [95857aa]
97
+ - Updated dependencies [45c1ea2]
98
+ - Updated dependencies [6f6bb89]
99
+ - Updated dependencies [060370c]
100
+ - Updated dependencies [dc714f3]
101
+ - Updated dependencies [b5da06a]
102
+ - Updated dependencies [d1a1aa1]
103
+ - Updated dependencies [63f9e9b]
104
+ - Updated dependencies [5d142ab]
105
+ - Updated dependencies [d5f588f]
106
+ - Updated dependencies [e025824]
107
+ - Updated dependencies [0571b98]
108
+ - Updated dependencies [b6b43c7]
109
+ - Updated dependencies [4fef487]
110
+ - Updated dependencies [48d257a]
111
+ - Updated dependencies [0c0c0b3]
112
+ - Updated dependencies [0d2c085]
113
+ - Updated dependencies [40acf9b]
114
+ - Updated dependencies [9222aeb]
115
+ - Updated dependencies [e2aceaf]
116
+ - Updated dependencies [411e483]
117
+ - Updated dependencies [8ba77a7]
118
+ - Updated dependencies [7b3ae3f]
119
+ - Updated dependencies [a166433]
120
+ - Updated dependencies [26735b5]
121
+ - Updated dependencies [443d8ec]
122
+ - Updated dependencies [a8c8bd5]
123
+ - Updated dependencies [abf9a79]
124
+ - Updated dependencies [14c9410]
125
+ - Updated dependencies [e86be6f]
126
+ - Updated dependencies [9bf7291]
127
+ - Updated dependencies [2e13791]
128
+ - Updated dependencies [9f95b35]
129
+ - Updated dependencies [66962ed]
130
+ - Updated dependencies [0d06df6]
131
+ - Updated dependencies [472524a]
132
+ - Updated dependencies [dd3ff01]
133
+ - Updated dependencies [d9c98f4]
134
+ - Updated dependencies [05d2819]
135
+ - Updated dependencies [9301f86]
136
+ - Updated dependencies [0a87932]
137
+ - Updated dependencies [c4a2fec]
138
+ - Updated dependencies [957b739]
139
+ - Updated dependencies [79457bd]
140
+ - Updated dependencies [a3f768e]
141
+ - Updated dependencies [7435eb5]
142
+ - Updated dependencies [8aa9e20]
143
+ - Updated dependencies [4617fab]
144
+ - Updated dependencies [ac34802]
145
+ - Updated dependencies [0054544]
146
+ - Updated dependencies [cb68df0]
147
+ - Updated dependencies [ad80501]
148
+ - Updated dependencies [68ecf2f]
149
+ - Updated dependencies [9e9c809]
150
+ - Updated dependencies [32831c6]
151
+ - Updated dependencies [6dc848c]
152
+ - Updated dependencies [6b98118]
153
+ - Updated dependencies [d0f9495]
154
+ - Updated dependencies [63d791d]
155
+ - Updated dependencies [87b828f]
156
+ - Updated dependencies [3f2f00c]
157
+ - Updated dependencies [bfdca8d]
158
+ - Updated dependencies [0ff02bb]
159
+ - Updated dependencies [7979f7f]
160
+ - Updated dependencies [39a4fab]
161
+ - Updated dependencies [44f4aba]
162
+ - Updated dependencies [9bd5ab5]
163
+ - Updated dependencies [57edfcb]
164
+ - Updated dependencies [faf8446]
165
+ - Updated dependencies [7ea4132]
166
+ - Updated dependencies [d1a034f]
167
+ - Updated dependencies [5c56081]
168
+ - Updated dependencies [fd65bc6]
169
+ - Updated dependencies [023ba40]
170
+ - Updated dependencies [ea7a7c9]
171
+ - Updated dependencies [26535e0]
172
+ - Updated dependencies [e030615]
173
+ - Updated dependencies [5e57fae]
174
+ - Updated dependencies [393138b]
175
+ - Updated dependencies [c57e248]
176
+ - Updated dependencies [88a8ee5]
177
+ - Updated dependencies [41fa418]
178
+ - Updated dependencies [205077b]
179
+ - Updated dependencies [71f938d]
180
+ - Updated dependencies [3795467]
181
+ - Updated dependencies [28a5ed5]
182
+ - Updated dependencies [7182d14]
183
+ - Updated dependencies [c1e6647]
184
+ - Updated dependencies [1766ede]
185
+ - Updated dependencies [811dff3]
186
+ - Updated dependencies [f10304b]
187
+ - Updated dependencies [dd5fd43]
188
+ - Updated dependencies [33f4a6a]
189
+ - Updated dependencies [383cbfa]
190
+ - Updated dependencies [27deb4d]
191
+ - Updated dependencies [c4df419]
192
+ - @ai-sdk/provider-utils@3.0.0
193
+ - @ai-sdk/provider@2.0.0
194
+
195
+ ## 2.0.0-beta.19
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies [88a8ee5]
200
+ - @ai-sdk/provider-utils@3.0.0-beta.10
201
+
202
+ ## 2.0.0-beta.18
203
+
204
+ ### Patch Changes
205
+
206
+ - 78e7fa9: Add code execution provider defined tool
207
+ - 0f05690: Add gemini-embedding-001 model, add embedding provider options type export
208
+ - Updated dependencies [27deb4d]
209
+ - @ai-sdk/provider@2.0.0-beta.2
210
+ - @ai-sdk/provider-utils@3.0.0-beta.9
211
+
212
+ ## 2.0.0-beta.17
213
+
214
+ ### Patch Changes
215
+
216
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
217
+ - Updated dependencies [dd5fd43]
218
+ - @ai-sdk/provider-utils@3.0.0-beta.8
219
+
220
+ ## 2.0.0-beta.16
221
+
222
+ ### Patch Changes
223
+
224
+ - Updated dependencies [e7fcc86]
225
+ - @ai-sdk/provider-utils@3.0.0-beta.7
226
+
227
+ ## 2.0.0-beta.15
228
+
229
+ ### Patch Changes
230
+
231
+ - Updated dependencies [ac34802]
232
+ - @ai-sdk/provider-utils@3.0.0-beta.6
233
+
234
+ ## 2.0.0-beta.14
235
+
236
+ ### Patch Changes
237
+
238
+ - 75f03b1: Add Gemini 2.5 Flash Lite GA
239
+
240
+ ## 2.0.0-beta.13
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies [57edfcb]
245
+ - Updated dependencies [383cbfa]
246
+ - @ai-sdk/provider-utils@3.0.0-beta.5
247
+
248
+ ## 2.0.0-beta.12
249
+
250
+ ### Patch Changes
251
+
252
+ - 205077b: fix: improve Zod compatibility
253
+ - Updated dependencies [205077b]
254
+ - @ai-sdk/provider-utils@3.0.0-beta.4
255
+
256
+ ## 2.0.0-beta.11
257
+
258
+ ### Patch Changes
259
+
260
+ - 6a16dcf: embed() now uses the single embeddings endpoint
261
+ No code updates are needed.
262
+
263
+ This is to make sure that users are not ratelimited when using the batch endpoint, since many models have different limits for batch and single embeddings.
264
+
265
+ Eg: Google has a limit of 150 RPM for batch requests, and 1500 RPM for single requests.
266
+
267
+ Before, AI SDK would always use the batch endpoint, even for embed() calls, which led to ratelimits.
268
+
269
+ This does not have any breaking functionality and is fully tested :)
270
+ if (values.length > 1) {
271
+ const batchResult = await this.doEmbedBatch({
272
+ values,
273
+ options,
274
+ });
275
+ return batchResult;
276
+ }
277
+
278
+ ## 2.0.0-beta.10
279
+
280
+ ### Patch Changes
281
+
282
+ - 7badba2: fix(google): grounding streaming sources
283
+ - Updated dependencies [05d2819]
284
+ - @ai-sdk/provider-utils@3.0.0-beta.3
285
+
286
+ ## 2.0.0-beta.9
287
+
288
+ ### Patch Changes
289
+
290
+ - 8af9e03: Added Image Models to the Google Provider for Imagen 3 Support
291
+
292
+ ## 2.0.0-beta.8
293
+
294
+ ### Patch Changes
295
+
296
+ - 2e06f14: feat (provider/google): Change to provider defined tools
297
+
298
+ - Change the google search tool to be a provider defined tool
299
+ - Added new URL context tool as a provider defined tool
300
+
301
+ ## 2.0.0-beta.7
302
+
303
+ ### Patch Changes
304
+
305
+ - 19a4336: Expose raw usageMetadata returned from Google Generative AI in providerMetadata
306
+
307
+ ## 2.0.0-beta.6
308
+
309
+ ### Patch Changes
310
+
311
+ - 878bf45: removes (unsupported) `additionalProperties` from the Schema sent in the request payloads to Google APIs
312
+
313
+ ## 2.0.0-beta.5
314
+
315
+ ### Patch Changes
316
+
317
+ - 42fcd32: feat(google): automatically handle system instructions for Gemma models
318
+
319
+ ## 2.0.0-beta.4
320
+
321
+ ### Patch Changes
322
+
323
+ - c68931f: Support tool schemas that allow additional properties (e.g `z.record(z.string())`)
324
+ - 8e6b69d: feat(providers/google): Add support for Gemini 2.5 Pro and Gemini 2.5 Flash (now stable)
325
+
326
+ ## 2.0.0-beta.3
327
+
328
+ ### Patch Changes
329
+
330
+ - cb787ac: fix: remove non-functional models
331
+ - d1a034f: feature: using Zod 4 for internal stuff
332
+ - Updated dependencies [0571b98]
333
+ - Updated dependencies [39a4fab]
334
+ - Updated dependencies [d1a034f]
335
+ - @ai-sdk/provider-utils@3.0.0-beta.2
336
+
337
+ ## 2.0.0-beta.2
338
+
339
+ ### Patch Changes
340
+
341
+ - a313780: fix: omit system message for gemma models
342
+
343
+ ## 2.0.0-beta.1
344
+
345
+ ### Patch Changes
346
+
347
+ - Updated dependencies [742b7be]
348
+ - Updated dependencies [7cddb72]
349
+ - Updated dependencies [ccce59b]
350
+ - Updated dependencies [e2b9e4b]
351
+ - Updated dependencies [45c1ea2]
352
+ - Updated dependencies [e025824]
353
+ - Updated dependencies [0d06df6]
354
+ - Updated dependencies [472524a]
355
+ - Updated dependencies [dd3ff01]
356
+ - Updated dependencies [7435eb5]
357
+ - Updated dependencies [cb68df0]
358
+ - Updated dependencies [bfdca8d]
359
+ - Updated dependencies [44f4aba]
360
+ - Updated dependencies [023ba40]
361
+ - Updated dependencies [5e57fae]
362
+ - Updated dependencies [71f938d]
363
+ - Updated dependencies [28a5ed5]
364
+ - @ai-sdk/provider@2.0.0-beta.1
365
+ - @ai-sdk/provider-utils@3.0.0-beta.1
366
+
367
+ ## 2.0.0-alpha.15
368
+
369
+ ### Patch Changes
370
+
371
+ - Updated dependencies [48d257a]
372
+ - Updated dependencies [8ba77a7]
373
+ - @ai-sdk/provider@2.0.0-alpha.15
374
+ - @ai-sdk/provider-utils@3.0.0-alpha.15
375
+
376
+ ## 2.0.0-alpha.14
377
+
378
+ ### Patch Changes
379
+
380
+ - Updated dependencies [b5da06a]
381
+ - Updated dependencies [63f9e9b]
382
+ - Updated dependencies [2e13791]
383
+ - @ai-sdk/provider@2.0.0-alpha.14
384
+ - @ai-sdk/provider-utils@3.0.0-alpha.14
385
+
386
+ ## 2.0.0-alpha.13
387
+
388
+ ### Patch Changes
389
+
390
+ - Updated dependencies [68ecf2f]
391
+ - @ai-sdk/provider@2.0.0-alpha.13
392
+ - @ai-sdk/provider-utils@3.0.0-alpha.13
393
+
394
+ ## 2.0.0-alpha.12
395
+
396
+ ### Patch Changes
397
+
398
+ - e2aceaf: feat: add raw chunk support
399
+ - Updated dependencies [e2aceaf]
400
+ - @ai-sdk/provider@2.0.0-alpha.12
401
+ - @ai-sdk/provider-utils@3.0.0-alpha.12
402
+
403
+ ## 2.0.0-alpha.11
404
+
405
+ ### Patch Changes
406
+
407
+ - Updated dependencies [c1e6647]
408
+ - @ai-sdk/provider@2.0.0-alpha.11
409
+ - @ai-sdk/provider-utils@3.0.0-alpha.11
410
+
411
+ ## 2.0.0-alpha.10
412
+
413
+ ### Patch Changes
414
+
415
+ - 581a9be: fix (provider/google): prevent error when thinking signature is used
416
+ - Updated dependencies [c4df419]
417
+ - @ai-sdk/provider@2.0.0-alpha.10
418
+ - @ai-sdk/provider-utils@3.0.0-alpha.10
419
+
420
+ ## 2.0.0-alpha.9
421
+
422
+ ### Patch Changes
423
+
424
+ - Updated dependencies [811dff3]
425
+ - @ai-sdk/provider@2.0.0-alpha.9
426
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
427
+
428
+ ## 2.0.0-alpha.8
429
+
430
+ ### Patch Changes
431
+
432
+ - 1a635b5: update supportedUrls to only support native URL
433
+ - Updated dependencies [4fef487]
434
+ - Updated dependencies [9222aeb]
435
+ - @ai-sdk/provider-utils@3.0.0-alpha.8
436
+ - @ai-sdk/provider@2.0.0-alpha.8
437
+
438
+ ## 2.0.0-alpha.7
439
+
440
+ ### Patch Changes
441
+
442
+ - Updated dependencies [5c56081]
443
+ - @ai-sdk/provider@2.0.0-alpha.7
444
+ - @ai-sdk/provider-utils@3.0.0-alpha.7
445
+
446
+ ## 2.0.0-alpha.6
447
+
448
+ ### Patch Changes
449
+
450
+ - Updated dependencies [0d2c085]
451
+ - @ai-sdk/provider@2.0.0-alpha.6
452
+ - @ai-sdk/provider-utils@3.0.0-alpha.6
453
+
454
+ ## 2.0.0-alpha.4
455
+
456
+ ### Patch Changes
457
+
458
+ - Updated dependencies [dc714f3]
459
+ - @ai-sdk/provider@2.0.0-alpha.4
460
+ - @ai-sdk/provider-utils@3.0.0-alpha.4
461
+
462
+ ## 2.0.0-alpha.3
463
+
464
+ ### Patch Changes
465
+
466
+ - Updated dependencies [6b98118]
467
+ - @ai-sdk/provider@2.0.0-alpha.3
468
+ - @ai-sdk/provider-utils@3.0.0-alpha.3
469
+
470
+ ## 2.0.0-alpha.2
471
+
472
+ ### Patch Changes
473
+
474
+ - Updated dependencies [26535e0]
475
+ - @ai-sdk/provider@2.0.0-alpha.2
476
+ - @ai-sdk/provider-utils@3.0.0-alpha.2
477
+
478
+ ## 2.0.0-alpha.1
479
+
480
+ ### Patch Changes
481
+
482
+ - Updated dependencies [3f2f00c]
483
+ - @ai-sdk/provider@2.0.0-alpha.1
484
+ - @ai-sdk/provider-utils@3.0.0-alpha.1
485
+
486
+ ## 2.0.0-canary.20
487
+
488
+ ### Patch Changes
489
+
490
+ - Updated dependencies [faf8446]
491
+ - @ai-sdk/provider-utils@3.0.0-canary.19
492
+
493
+ ## 2.0.0-canary.19
494
+
495
+ ### Patch Changes
496
+
497
+ - Updated dependencies [40acf9b]
498
+ - @ai-sdk/provider-utils@3.0.0-canary.18
499
+
500
+ ## 2.0.0-canary.18
501
+
502
+ ### Patch Changes
503
+
504
+ - f07a6d4: fix(providers/google): accept nullish in safetyRatings
505
+ - Updated dependencies [ea7a7c9]
506
+ - @ai-sdk/provider-utils@3.0.0-canary.17
507
+
508
+ ## 2.0.0-canary.17
509
+
510
+ ### Patch Changes
511
+
512
+ - Updated dependencies [87b828f]
513
+ - @ai-sdk/provider-utils@3.0.0-canary.16
514
+
515
+ ## 2.0.0-canary.16
516
+
517
+ ### Patch Changes
518
+
519
+ - Updated dependencies [a571d6e]
520
+ - Updated dependencies [a8c8bd5]
521
+ - Updated dependencies [7979f7f]
522
+ - Updated dependencies [41fa418]
523
+ - @ai-sdk/provider-utils@3.0.0-canary.15
524
+ - @ai-sdk/provider@2.0.0-canary.14
525
+
526
+ ## 2.0.0-canary.15
527
+
528
+ ### Patch Changes
529
+
530
+ - Updated dependencies [957b739]
531
+ - Updated dependencies [9bd5ab5]
532
+ - @ai-sdk/provider-utils@3.0.0-canary.14
533
+ - @ai-sdk/provider@2.0.0-canary.13
534
+
535
+ ## 2.0.0-canary.14
536
+
537
+ ### Patch Changes
538
+
539
+ - f916255: feat (provider/google): add new gemini models
540
+ - Updated dependencies [7b3ae3f]
541
+ - Updated dependencies [0ff02bb]
542
+ - @ai-sdk/provider@2.0.0-canary.12
543
+ - @ai-sdk/provider-utils@3.0.0-canary.13
544
+
545
+ ## 2.0.0-canary.13
546
+
547
+ ### Patch Changes
548
+
549
+ - 7378473: chore(providers/google): switch to providerOptions
550
+ - Updated dependencies [9bf7291]
551
+ - Updated dependencies [4617fab]
552
+ - Updated dependencies [e030615]
553
+ - @ai-sdk/provider@2.0.0-canary.11
554
+ - @ai-sdk/provider-utils@3.0.0-canary.12
555
+
556
+ ## 2.0.0-canary.12
557
+
558
+ ### Patch Changes
559
+
560
+ - 888b750: feat(providers/google): Add taskType support for Text Embedding Models
561
+ - 66962ed: fix(packages): export node10 compatible types
562
+ - Updated dependencies [66962ed]
563
+ - Updated dependencies [9301f86]
564
+ - Updated dependencies [a3f768e]
565
+ - @ai-sdk/provider-utils@3.0.0-canary.11
566
+ - @ai-sdk/provider@2.0.0-canary.10
567
+
568
+ ## 2.0.0-canary.11
569
+
570
+ ### Patch Changes
571
+
572
+ - Updated dependencies [e86be6f]
573
+ - @ai-sdk/provider@2.0.0-canary.9
574
+ - @ai-sdk/provider-utils@3.0.0-canary.10
575
+
576
+ ## 2.0.0-canary.10
577
+
578
+ ### Patch Changes
579
+
580
+ - 3259565: feat (providers/google): add thinking config to provider options
581
+ - fd98925: chore(providers/google): update embedding model to use providerOptions
582
+ - Updated dependencies [95857aa]
583
+ - Updated dependencies [7ea4132]
584
+ - @ai-sdk/provider@2.0.0-canary.8
585
+ - @ai-sdk/provider-utils@3.0.0-canary.9
586
+
587
+ ## 2.0.0-canary.9
588
+
589
+ ### Patch Changes
590
+
591
+ - Updated dependencies [5d142ab]
592
+ - Updated dependencies [b6b43c7]
593
+ - Updated dependencies [8aa9e20]
594
+ - Updated dependencies [3795467]
595
+ - @ai-sdk/provider-utils@3.0.0-canary.8
596
+ - @ai-sdk/provider@2.0.0-canary.7
597
+
598
+ ## 2.0.0-canary.8
599
+
600
+ ### Patch Changes
601
+
602
+ - 26735b5: chore(embedding-model): add v2 interface
603
+ - 443d8ec: feat(embedding-model-v2): add response body field
604
+ - fd65bc6: chore(embedding-model-v2): rename rawResponse to response
605
+ - Updated dependencies [26735b5]
606
+ - Updated dependencies [443d8ec]
607
+ - Updated dependencies [14c9410]
608
+ - Updated dependencies [d9c98f4]
609
+ - Updated dependencies [c4a2fec]
610
+ - Updated dependencies [0054544]
611
+ - Updated dependencies [9e9c809]
612
+ - Updated dependencies [32831c6]
613
+ - Updated dependencies [d0f9495]
614
+ - Updated dependencies [fd65bc6]
615
+ - Updated dependencies [393138b]
616
+ - Updated dependencies [7182d14]
617
+ - @ai-sdk/provider@2.0.0-canary.6
618
+ - @ai-sdk/provider-utils@3.0.0-canary.7
619
+
620
+ ## 2.0.0-canary.7
621
+
622
+ ### Patch Changes
623
+
624
+ - f10304b: feat(tool-calling): don't require the user to have to pass parameters
625
+ - Updated dependencies [411e483]
626
+ - Updated dependencies [79457bd]
627
+ - Updated dependencies [ad80501]
628
+ - Updated dependencies [1766ede]
629
+ - Updated dependencies [f10304b]
630
+ - @ai-sdk/provider@2.0.0-canary.5
631
+ - @ai-sdk/provider-utils@3.0.0-canary.6
632
+
633
+ ## 2.0.0-canary.6
634
+
635
+ ### Patch Changes
636
+
637
+ - Updated dependencies [6f6bb89]
638
+ - @ai-sdk/provider@2.0.0-canary.4
639
+ - @ai-sdk/provider-utils@3.0.0-canary.5
640
+
641
+ ## 2.0.0-canary.5
642
+
643
+ ### Patch Changes
644
+
645
+ - Updated dependencies [d1a1aa1]
646
+ - @ai-sdk/provider@2.0.0-canary.3
647
+ - @ai-sdk/provider-utils@3.0.0-canary.4
648
+
649
+ ## 2.0.0-canary.4
650
+
651
+ ### Patch Changes
652
+
653
+ - Updated dependencies [a166433]
654
+ - Updated dependencies [abf9a79]
655
+ - Updated dependencies [9f95b35]
656
+ - Updated dependencies [0a87932]
657
+ - Updated dependencies [6dc848c]
658
+ - @ai-sdk/provider-utils@3.0.0-canary.3
659
+ - @ai-sdk/provider@2.0.0-canary.2
660
+
661
+ ## 2.0.0-canary.3
662
+
663
+ ### Patch Changes
664
+
665
+ - Updated dependencies [c57e248]
666
+ - Updated dependencies [33f4a6a]
667
+ - @ai-sdk/provider@2.0.0-canary.1
668
+ - @ai-sdk/provider-utils@3.0.0-canary.2
669
+
670
+ ## 2.0.0-canary.2
671
+
672
+ ### Patch Changes
673
+
674
+ - 5cf30ea: fix (provider/google): allow "OFF" for Google HarmBlockThreshold
675
+
676
+ ## 2.0.0-canary.1
677
+
678
+ ### Patch Changes
679
+
680
+ - 779d916: feat: add provider option schemas for vertex imagegen and google genai
681
+ - Updated dependencies [060370c]
682
+ - Updated dependencies [0c0c0b3]
683
+ - Updated dependencies [63d791d]
684
+ - @ai-sdk/provider-utils@3.0.0-canary.1
685
+
686
+ ## 2.0.0-canary.0
687
+
688
+ ### Major Changes
689
+
690
+ - d5f588f: AI SDK 5
691
+
692
+ ### Patch Changes
693
+
694
+ - Updated dependencies [d5f588f]
695
+ - @ai-sdk/provider-utils@3.0.0-canary.0
696
+ - @ai-sdk/provider@2.0.0-canary.0
697
+
698
+ ## 1.2.5
699
+
700
+ ### Patch Changes
701
+
702
+ - Updated dependencies [28be004]
703
+ - @ai-sdk/provider-utils@2.2.3
704
+
705
+ ## 1.2.4
706
+
707
+ ### Patch Changes
708
+
709
+ - Updated dependencies [b01120e]
710
+ - @ai-sdk/provider-utils@2.2.2
711
+
712
+ ## 1.2.3
713
+
714
+ ### Patch Changes
715
+
716
+ - 871df87: feat (provider/google): add gemini-2.5-pro-exp-03-25 to model list
717
+
718
+ ## 1.2.2
719
+
720
+ ### Patch Changes
721
+
722
+ - Updated dependencies [f10f0fa]
723
+ - @ai-sdk/provider-utils@2.2.1
724
+
725
+ ## 1.2.1
726
+
727
+ ### Patch Changes
728
+
729
+ - 994a13b: feat (provider/google): support IMAGE_SAFETY finish reason
730
+
731
+ ## 1.2.0
732
+
733
+ ### Minor Changes
734
+
735
+ - 5bc638d: AI SDK 4.2
736
+
737
+ ### Patch Changes
738
+
739
+ - Updated dependencies [5bc638d]
740
+ - @ai-sdk/provider@1.1.0
741
+ - @ai-sdk/provider-utils@2.2.0
742
+
743
+ ## 1.1.27
744
+
745
+ ### Patch Changes
746
+
747
+ - d0c4659: feat (provider-utils): parseProviderOptions function
748
+ - Updated dependencies [d0c4659]
749
+ - @ai-sdk/provider-utils@2.1.15
750
+
751
+ ## 1.1.26
752
+
753
+ ### Patch Changes
754
+
755
+ - 0bd5bc6: feat (ai): support model-generated files
756
+ - Updated dependencies [0bd5bc6]
757
+ - @ai-sdk/provider@1.0.12
758
+ - @ai-sdk/provider-utils@2.1.14
759
+
760
+ ## 1.1.25
761
+
762
+ ### Patch Changes
763
+
764
+ - Updated dependencies [2e1101a]
765
+ - @ai-sdk/provider@1.0.11
766
+ - @ai-sdk/provider-utils@2.1.13
767
+
768
+ ## 1.1.24
769
+
770
+ ### Patch Changes
771
+
772
+ - 5261762: fix (provider/google): ensure correct finishReason for tool calls in streaming response
773
+
774
+ ## 1.1.23
775
+
776
+ ### Patch Changes
777
+
778
+ - 413f5a7: feat (providers/google): add gemma 3 model id
779
+
780
+ ## 1.1.22
781
+
782
+ ### Patch Changes
783
+
784
+ - 62f46fd: feat (provider/google): add support for dynamic retrieval
785
+
786
+ ## 1.1.21
787
+
788
+ ### Patch Changes
789
+
790
+ - Updated dependencies [1531959]
791
+ - @ai-sdk/provider-utils@2.1.12
792
+
793
+ ## 1.1.20
794
+
795
+ ### Patch Changes
796
+
797
+ - e1d3d42: feat (ai): expose raw response body in generateText and generateObject
798
+ - Updated dependencies [e1d3d42]
799
+ - @ai-sdk/provider@1.0.10
800
+ - @ai-sdk/provider-utils@2.1.11
801
+
802
+ ## 1.1.19
803
+
804
+ ### Patch Changes
805
+
806
+ - 2c27583: fix (provider/google): support empty content in malformed function call responses
807
+
808
+ ## 1.1.18
809
+
810
+ ### Patch Changes
811
+
812
+ - 5c8f512: feat (provider/google): add seed support
813
+
814
+ ## 1.1.17
815
+
816
+ ### Patch Changes
817
+
818
+ - Updated dependencies [ddf9740]
819
+ - @ai-sdk/provider@1.0.9
820
+ - @ai-sdk/provider-utils@2.1.10
821
+
822
+ ## 1.1.16
823
+
824
+ ### Patch Changes
825
+
826
+ - 1b2e2a0: fix (provider/google): add resilience against undefined parts
827
+
828
+ ## 1.1.15
829
+
830
+ ### Patch Changes
831
+
832
+ - Updated dependencies [2761f06]
833
+ - @ai-sdk/provider@1.0.8
834
+ - @ai-sdk/provider-utils@2.1.9
835
+
836
+ ## 1.1.14
837
+
838
+ ### Patch Changes
839
+
840
+ - 08a3641: fix (provider/google): support nullable enums in schema
841
+
842
+ ## 1.1.13
843
+
844
+ ### Patch Changes
845
+
846
+ - Updated dependencies [2e898b4]
847
+ - @ai-sdk/provider-utils@2.1.8
848
+
849
+ ## 1.1.12
850
+
851
+ ### Patch Changes
852
+
853
+ - Updated dependencies [3ff4ef8]
854
+ - @ai-sdk/provider-utils@2.1.7
855
+
856
+ ## 1.1.11
857
+
858
+ ### Patch Changes
859
+
860
+ - 6eb7fc4: feat (ai/core): url source support
861
+
862
+ ## 1.1.10
863
+
864
+ ### Patch Changes
865
+
866
+ - e5567f7: feat (provider/google): update model ids
867
+
868
+ ## 1.1.9
869
+
870
+ ### Patch Changes
871
+
872
+ - b2573de: fix (provider/google): remove reasoning text following removal from Gemini API
873
+
874
+ ## 1.1.8
875
+
876
+ ### Patch Changes
877
+
878
+ - Updated dependencies [d89c3b9]
879
+ - @ai-sdk/provider@1.0.7
880
+ - @ai-sdk/provider-utils@2.1.6
881
+
882
+ ## 1.1.7
883
+
884
+ ### Patch Changes
885
+
886
+ - d399f25: feat (provider/google-vertex): support public file urls in messages
887
+
888
+ ## 1.1.6
889
+
890
+ ### Patch Changes
891
+
892
+ - e012cd8: feat (provider/google): add reasoning support
893
+
894
+ ## 1.1.5
895
+
896
+ ### Patch Changes
897
+
898
+ - Updated dependencies [3a602ca]
899
+ - @ai-sdk/provider-utils@2.1.5
900
+
901
+ ## 1.1.4
902
+
903
+ ### Patch Changes
904
+
905
+ - Updated dependencies [066206e]
906
+ - @ai-sdk/provider-utils@2.1.4
907
+
908
+ ## 1.1.3
909
+
910
+ ### Patch Changes
911
+
912
+ - Updated dependencies [39e5c1f]
913
+ - @ai-sdk/provider-utils@2.1.3
914
+
915
+ ## 1.1.2
916
+
917
+ ### Patch Changes
918
+
919
+ - Updated dependencies [ed012d2]
920
+ - Updated dependencies [3a58a2e]
921
+ - @ai-sdk/provider-utils@2.1.2
922
+ - @ai-sdk/provider@1.0.6
923
+
924
+ ## 1.1.1
925
+
926
+ ### Patch Changes
927
+
928
+ - Updated dependencies [e7a9ec9]
929
+ - Updated dependencies [0a699f1]
930
+ - @ai-sdk/provider-utils@2.1.1
931
+ - @ai-sdk/provider@1.0.5
932
+
933
+ ## 1.1.0
934
+
935
+ ### Minor Changes
936
+
937
+ - 62ba5ad: release: AI SDK 4.1
938
+
939
+ ### Patch Changes
940
+
941
+ - Updated dependencies [62ba5ad]
942
+ - @ai-sdk/provider-utils@2.1.0
943
+
944
+ ## 1.0.17
945
+
946
+ ### Patch Changes
947
+
948
+ - Updated dependencies [00114c5]
949
+ - @ai-sdk/provider-utils@2.0.8
950
+
951
+ ## 1.0.16
952
+
953
+ ### Patch Changes
954
+
955
+ - 4eb9b41: fix (provider/google): support conversion of string enums to openapi spec
956
+
957
+ ## 1.0.15
958
+
959
+ ### Patch Changes
960
+
961
+ - 7611964: feat (provider/xai): Support structured output for latest models.
962
+
963
+ ## 1.0.14
964
+
965
+ ### Patch Changes
966
+
967
+ - Updated dependencies [90fb95a]
968
+ - Updated dependencies [e6dfef4]
969
+ - Updated dependencies [6636db6]
970
+ - @ai-sdk/provider-utils@2.0.7
971
+
972
+ ## 1.0.13
973
+
974
+ ### Patch Changes
975
+
976
+ - Updated dependencies [19a2ce7]
977
+ - Updated dependencies [19a2ce7]
978
+ - Updated dependencies [6337688]
979
+ - @ai-sdk/provider@1.0.4
980
+ - @ai-sdk/provider-utils@2.0.6
981
+
982
+ ## 1.0.12
983
+
984
+ ### Patch Changes
985
+
986
+ - 5ed5e45: chore (config): Use ts-library.json tsconfig for no-UI libs.
987
+ - Updated dependencies [5ed5e45]
988
+ - @ai-sdk/provider-utils@2.0.5
989
+ - @ai-sdk/provider@1.0.3
990
+
991
+ ## 1.0.11
992
+
993
+ ### Patch Changes
994
+
995
+ - db31e74: feat: adding audioTimestamp support to GoogleGenerativeAISettings
996
+
997
+ ## 1.0.10
998
+
999
+ ### Patch Changes
1000
+
1001
+ - e07439a: feat (provider/google): Include safety ratings response detail.
1002
+ - 4017b0f: feat (provider/google-vertex): Enhance grounding metadata response detail.
1003
+ - a9df182: feat (provider/google): Add support for search grounding.
1004
+
1005
+ ## 1.0.9
1006
+
1007
+ ### Patch Changes
1008
+
1009
+ - c0b1c7e: feat (provider/google): Add Gemini 2.0 model.
1010
+
1011
+ ## 1.0.8
1012
+
1013
+ ### Patch Changes
1014
+
1015
+ - b7372dc: feat (provider/google): Include optional response grounding metadata.
1016
+
1017
+ ## 1.0.7
1018
+
1019
+ ### Patch Changes
1020
+
1021
+ - Updated dependencies [09a9cab]
1022
+ - @ai-sdk/provider@1.0.2
1023
+ - @ai-sdk/provider-utils@2.0.4
1024
+
1025
+ ## 1.0.6
1026
+
1027
+ ### Patch Changes
1028
+
1029
+ - 9e54403: fix (provider/google-vertex): support empty object as usage metadata
1030
+
1031
+ ## 1.0.5
1032
+
1033
+ ### Patch Changes
1034
+
1035
+ - 0984f0b: feat (provider/google-vertex): Rewrite for Edge runtime support.
1036
+ - Updated dependencies [0984f0b]
1037
+ - @ai-sdk/provider-utils@2.0.3
1038
+
1039
+ ## 1.0.4
1040
+
1041
+ ### Patch Changes
1042
+
1043
+ - 6373c60: fix (provider/google): send json schema into provider
1044
+
1045
+ ## 1.0.3
1046
+
1047
+ ### Patch Changes
1048
+
1049
+ - Updated dependencies [b446ae5]
1050
+ - @ai-sdk/provider@1.0.1
1051
+ - @ai-sdk/provider-utils@2.0.2
1052
+
1053
+ ## 1.0.2
1054
+
1055
+ ### Patch Changes
1056
+
1057
+ - b748dfb: feat (providers): update model lists
1058
+
1059
+ ## 1.0.1
1060
+
1061
+ ### Patch Changes
1062
+
1063
+ - Updated dependencies [c3ab5de]
1064
+ - @ai-sdk/provider-utils@2.0.1
1065
+
1066
+ ## 1.0.0
1067
+
1068
+ ### Major Changes
1069
+
1070
+ - 66060f7: chore (release): bump major version to 4.0
1071
+ - 0d3d3f5: chore (providers): remove baseUrl option
1072
+ - 36b03b0: chore (provider/google): remove topK model setting
1073
+ - 277fc6b: chore (provider/google): remove facade
1074
+
1075
+ ### Patch Changes
1076
+
1077
+ - c38a0db: fix (provider/google): allow empty candidates array when streaming
1078
+ - 0509c34: fix (provider/google): add name/content details to tool responses
1079
+ - Updated dependencies [b469a7e]
1080
+ - Updated dependencies [dce4158]
1081
+ - Updated dependencies [c0ddc24]
1082
+ - Updated dependencies [b1da952]
1083
+ - Updated dependencies [dce4158]
1084
+ - Updated dependencies [8426f55]
1085
+ - Updated dependencies [db46ce5]
1086
+ - @ai-sdk/provider-utils@2.0.0
1087
+ - @ai-sdk/provider@1.0.0
1088
+
1089
+ ## 1.0.0-canary.6
1090
+
1091
+ ### Patch Changes
1092
+
1093
+ - c38a0db: fix (provider/google): allow empty candidates array when streaming
1094
+
1095
+ ## 1.0.0-canary.5
1096
+
1097
+ ### Patch Changes
1098
+
1099
+ - 0509c34: fix (provider/google): add name/content details to tool responses
1100
+
1101
+ ## 1.0.0-canary.4
1102
+
1103
+ ### Major Changes
1104
+
1105
+ - 36b03b0: chore (provider/google): remove topK model setting
1106
+ - 277fc6b: chore (provider/google): remove facade
1107
+
1108
+ ## 1.0.0-canary.3
1109
+
1110
+ ### Patch Changes
1111
+
1112
+ - Updated dependencies [8426f55]
1113
+ - @ai-sdk/provider-utils@2.0.0-canary.3
1114
+
1115
+ ## 1.0.0-canary.2
1116
+
1117
+ ### Patch Changes
1118
+
1119
+ - Updated dependencies [dce4158]
1120
+ - Updated dependencies [dce4158]
1121
+ - @ai-sdk/provider-utils@2.0.0-canary.2
1122
+
1123
+ ## 1.0.0-canary.1
1124
+
1125
+ ### Major Changes
1126
+
1127
+ - 0d3d3f5: chore (providers): remove baseUrl option
1128
+
1129
+ ### Patch Changes
1130
+
1131
+ - Updated dependencies [b1da952]
1132
+ - @ai-sdk/provider-utils@2.0.0-canary.1
1133
+
1134
+ ## 1.0.0-canary.0
1135
+
1136
+ ### Major Changes
1137
+
1138
+ - 66060f7: chore (release): bump major version to 4.0
1139
+
1140
+ ### Patch Changes
1141
+
1142
+ - Updated dependencies [b469a7e]
1143
+ - Updated dependencies [c0ddc24]
1144
+ - Updated dependencies [db46ce5]
1145
+ - @ai-sdk/provider-utils@2.0.0-canary.0
1146
+ - @ai-sdk/provider@1.0.0-canary.0
1147
+
1148
+ ## 0.0.55
1149
+
1150
+ ### Patch Changes
1151
+
1152
+ - 11beb9d: fix (provider/google): support tool calls without parameters
1153
+
1154
+ ## 0.0.54
1155
+
1156
+ ### Patch Changes
1157
+
1158
+ - 1486128: feat: add supportsUrl to language model specification
1159
+ - 1486128: feat (provider/google): support native file URLs without download
1160
+ - 3b1b69a: feat: provider-defined tools
1161
+ - Updated dependencies [aa98cdb]
1162
+ - Updated dependencies [1486128]
1163
+ - Updated dependencies [7b937c5]
1164
+ - Updated dependencies [3b1b69a]
1165
+ - Updated dependencies [811a317]
1166
+ - @ai-sdk/provider-utils@1.0.22
1167
+ - @ai-sdk/provider@0.0.26
1168
+
1169
+ ## 0.0.53
1170
+
1171
+ ### Patch Changes
1172
+
1173
+ - b9b0d7b: feat (ai): access raw request body
1174
+ - Updated dependencies [b9b0d7b]
1175
+ - @ai-sdk/provider@0.0.25
1176
+ - @ai-sdk/provider-utils@1.0.21
1177
+
1178
+ ## 0.0.52
1179
+
1180
+ ### Patch Changes
1181
+
1182
+ - 7944e61: feat (provider/google): enable frequencyPenalty and presencePenalty settings
1183
+
1184
+ ## 0.0.51
1185
+
1186
+ ### Patch Changes
1187
+
1188
+ - d595d0d: feat (ai/core): file content parts
1189
+ - Updated dependencies [d595d0d]
1190
+ - @ai-sdk/provider@0.0.24
1191
+ - @ai-sdk/provider-utils@1.0.20
1192
+
1193
+ ## 0.0.50
1194
+
1195
+ ### Patch Changes
1196
+
1197
+ - 5d113fb: feat (provider/google): support fine-tuned models
1198
+
1199
+ ## 0.0.49
1200
+
1201
+ ### Patch Changes
1202
+
1203
+ - 2e32bd0: fix (provider/google): deal with empty candidatesTokenCount
1204
+ - 2e32bd0: feat (provider/google): add new models
1205
+
1206
+ ## 0.0.48
1207
+
1208
+ ### Patch Changes
1209
+
1210
+ - Updated dependencies [273f696]
1211
+ - @ai-sdk/provider-utils@1.0.19
1212
+
1213
+ ## 0.0.47
1214
+
1215
+ ### Patch Changes
1216
+
1217
+ - Updated dependencies [03313cd]
1218
+ - Updated dependencies [3be7c1c]
1219
+ - @ai-sdk/provider-utils@1.0.18
1220
+ - @ai-sdk/provider@0.0.23
1221
+
1222
+ ## 0.0.46
1223
+
1224
+ ### Patch Changes
1225
+
1226
+ - 26515cb: feat (ai/provider): introduce ProviderV1 specification
1227
+ - Updated dependencies [26515cb]
1228
+ - @ai-sdk/provider@0.0.22
1229
+ - @ai-sdk/provider-utils@1.0.17
1230
+
1231
+ ## 0.0.45
1232
+
1233
+ ### Patch Changes
1234
+
1235
+ - Updated dependencies [09f895f]
1236
+ - @ai-sdk/provider-utils@1.0.16
1237
+
1238
+ ## 0.0.44
1239
+
1240
+ ### Patch Changes
1241
+
1242
+ - cb94042: fix (provider/google): allow disabling structured generation
1243
+
1244
+ ## 0.0.43
1245
+
1246
+ ### Patch Changes
1247
+
1248
+ - Updated dependencies [d67fa9c]
1249
+ - @ai-sdk/provider-utils@1.0.15
1250
+
1251
+ ## 0.0.42
1252
+
1253
+ ### Patch Changes
1254
+
1255
+ - 9c1f4f2: chore (provider/google): remove "models/" from model name
1256
+
1257
+ ## 0.0.41
1258
+
1259
+ ### Patch Changes
1260
+
1261
+ - 5da9c7f: feat (provider/google): embedding support
1262
+
1263
+ ## 0.0.40
1264
+
1265
+ ### Patch Changes
1266
+
1267
+ - Updated dependencies [f2c025e]
1268
+ - @ai-sdk/provider@0.0.21
1269
+ - @ai-sdk/provider-utils@1.0.14
1270
+
1271
+ ## 0.0.39
1272
+
1273
+ ### Patch Changes
1274
+
1275
+ - Updated dependencies [6ac355e]
1276
+ - @ai-sdk/provider@0.0.20
1277
+ - @ai-sdk/provider-utils@1.0.13
1278
+
1279
+ ## 0.0.38
1280
+
1281
+ ### Patch Changes
1282
+
1283
+ - 123134b: fix (provider/google): change default object generation mode to json
1284
+ - dd712ac: fix: use FetchFunction type to prevent self-reference
1285
+ - Updated dependencies [dd712ac]
1286
+ - @ai-sdk/provider-utils@1.0.12
1287
+
1288
+ ## 0.0.37
1289
+
1290
+ ### Patch Changes
1291
+
1292
+ - 89b18ca: fix (ai/provider): send finish reason 'unknown' by default
1293
+ - Updated dependencies [dd4a0f5]
1294
+ - @ai-sdk/provider@0.0.19
1295
+ - @ai-sdk/provider-utils@1.0.11
1296
+
1297
+ ## 0.0.36
1298
+
1299
+ ### Patch Changes
1300
+
1301
+ - Updated dependencies [4bd27a9]
1302
+ - Updated dependencies [845754b]
1303
+ - @ai-sdk/provider-utils@1.0.10
1304
+ - @ai-sdk/provider@0.0.18
1305
+
1306
+ ## 0.0.35
1307
+
1308
+ ### Patch Changes
1309
+
1310
+ - 1e94ed8: feat (provider/google): send json schema in object-json mode
1311
+
1312
+ ## 0.0.34
1313
+
1314
+ ### Patch Changes
1315
+
1316
+ - Updated dependencies [029af4c]
1317
+ - @ai-sdk/provider@0.0.17
1318
+ - @ai-sdk/provider-utils@1.0.9
1319
+
1320
+ ## 0.0.33
1321
+
1322
+ ### Patch Changes
1323
+
1324
+ - Updated dependencies [d58517b]
1325
+ - @ai-sdk/provider@0.0.16
1326
+ - @ai-sdk/provider-utils@1.0.8
1327
+
1328
+ ## 0.0.32
1329
+
1330
+ ### Patch Changes
1331
+
1332
+ - Updated dependencies [96aed25]
1333
+ - @ai-sdk/provider@0.0.15
1334
+ - @ai-sdk/provider-utils@1.0.7
1335
+
1336
+ ## 0.0.31
1337
+
1338
+ ### Patch Changes
1339
+
1340
+ - Updated dependencies [9614584]
1341
+ - Updated dependencies [0762a22]
1342
+ - @ai-sdk/provider-utils@1.0.6
1343
+
1344
+ ## 0.0.30
1345
+
1346
+ ### Patch Changes
1347
+
1348
+ - a8d1c9e9: feat (ai/core): parallel image download
1349
+ - Updated dependencies [a8d1c9e9]
1350
+ - @ai-sdk/provider-utils@1.0.5
1351
+ - @ai-sdk/provider@0.0.14
1352
+
1353
+ ## 0.0.29
1354
+
1355
+ ### Patch Changes
1356
+
1357
+ - Updated dependencies [4f88248f]
1358
+ - @ai-sdk/provider-utils@1.0.4
1359
+
1360
+ ## 0.0.28
1361
+
1362
+ ### Patch Changes
1363
+
1364
+ - 2b9da0f0: feat (core): support stopSequences setting.
1365
+ - a5b58845: feat (core): support topK setting
1366
+ - 4aa8deb3: feat (provider): support responseFormat setting in provider api
1367
+ - 13b27ec6: chore (ai/core): remove grammar mode
1368
+ - Updated dependencies [2b9da0f0]
1369
+ - Updated dependencies [a5b58845]
1370
+ - Updated dependencies [4aa8deb3]
1371
+ - Updated dependencies [13b27ec6]
1372
+ - @ai-sdk/provider@0.0.13
1373
+ - @ai-sdk/provider-utils@1.0.3
1374
+
1375
+ ## 0.0.27
1376
+
1377
+ ### Patch Changes
1378
+
1379
+ - 2e59d266: feat (provider/google): add cachedContent optional setting
1380
+ - d2b9723d: feat (provider/google): support system instructions
1381
+ - 4dfe0b00: feat (provider/google): add tool support for object generation (new default mode)
1382
+
1383
+ ## 0.0.26
1384
+
1385
+ ### Patch Changes
1386
+
1387
+ - Updated dependencies [b7290943]
1388
+ - @ai-sdk/provider@0.0.12
1389
+ - @ai-sdk/provider-utils@1.0.2
1390
+
1391
+ ## 0.0.25
1392
+
1393
+ ### Patch Changes
1394
+
1395
+ - Updated dependencies [d481729f]
1396
+ - @ai-sdk/provider-utils@1.0.1
1397
+
1398
+ ## 0.0.24
1399
+
1400
+ ### Patch Changes
1401
+
1402
+ - 5edc6110: feat (ai/core): add custom request header support
1403
+ - Updated dependencies [5edc6110]
1404
+ - Updated dependencies [5edc6110]
1405
+ - Updated dependencies [5edc6110]
1406
+ - @ai-sdk/provider@0.0.11
1407
+ - @ai-sdk/provider-utils@1.0.0
1408
+
1409
+ ## 0.0.23
1410
+
1411
+ ### Patch Changes
1412
+
1413
+ - Updated dependencies [02f6a088]
1414
+ - @ai-sdk/provider-utils@0.0.16
1415
+
1416
+ ## 0.0.22
1417
+
1418
+ ### Patch Changes
1419
+
1420
+ - Updated dependencies [85712895]
1421
+ - Updated dependencies [85712895]
1422
+ - @ai-sdk/provider-utils@0.0.15
1423
+
1424
+ ## 0.0.21
1425
+
1426
+ ### Patch Changes
1427
+
1428
+ - 4728c37f: feat (core): add text embedding model support to provider registry
1429
+ - 7910ae84: feat (providers): support custom fetch implementations
1430
+ - Updated dependencies [7910ae84]
1431
+ - @ai-sdk/provider-utils@0.0.14
1432
+
1433
+ ## 0.0.20
1434
+
1435
+ ### Patch Changes
1436
+
1437
+ - Updated dependencies [102ca22f]
1438
+ - @ai-sdk/provider@0.0.10
1439
+ - @ai-sdk/provider-utils@0.0.13
1440
+
1441
+ ## 0.0.19
1442
+
1443
+ ### Patch Changes
1444
+
1445
+ - 09295e2e: feat (@ai-sdk/google): automatically download image URLs
1446
+ - Updated dependencies [09295e2e]
1447
+ - Updated dependencies [09295e2e]
1448
+ - Updated dependencies [043a5de2]
1449
+ - @ai-sdk/provider@0.0.9
1450
+ - @ai-sdk/provider-utils@0.0.12
1451
+
1452
+ ## 0.0.18
1453
+
1454
+ ### Patch Changes
1455
+
1456
+ - 8022d73e: feat (provider/google): add safety setting option on models
1457
+
1458
+ ## 0.0.17
1459
+
1460
+ ### Patch Changes
1461
+
1462
+ - f39c0dd2: feat (provider): implement toolChoice support
1463
+ - Updated dependencies [f39c0dd2]
1464
+ - @ai-sdk/provider@0.0.8
1465
+ - @ai-sdk/provider-utils@0.0.11
1466
+
1467
+ ## 0.0.16
1468
+
1469
+ ### Patch Changes
1470
+
1471
+ - 24683b72: fix (providers): Zod is required dependency
1472
+ - Updated dependencies [8e780288]
1473
+ - @ai-sdk/provider@0.0.7
1474
+ - @ai-sdk/provider-utils@0.0.10
1475
+
1476
+ ## 0.0.15
1477
+
1478
+ ### Patch Changes
1479
+
1480
+ - Updated dependencies [6a50ac4]
1481
+ - Updated dependencies [6a50ac4]
1482
+ - @ai-sdk/provider@0.0.6
1483
+ - @ai-sdk/provider-utils@0.0.9
1484
+
1485
+ ## 0.0.14
1486
+
1487
+ ### Patch Changes
1488
+
1489
+ - df47a34: feat (provider/google): add models/gemini-1.5-flash-latest to list of supported models
1490
+
1491
+ ## 0.0.13
1492
+
1493
+ ### Patch Changes
1494
+
1495
+ - 9a7ec8b: feat (provider/google): add token usage information
1496
+
1497
+ ## 0.0.12
1498
+
1499
+ ### Patch Changes
1500
+
1501
+ - Updated dependencies [0f6bc4e]
1502
+ - @ai-sdk/provider@0.0.5
1503
+ - @ai-sdk/provider-utils@0.0.8
1504
+
1505
+ ## 0.0.11
1506
+
1507
+ ### Patch Changes
1508
+
1509
+ - Updated dependencies [325ca55]
1510
+ - @ai-sdk/provider@0.0.4
1511
+ - @ai-sdk/provider-utils@0.0.7
1512
+
1513
+ ## 0.0.10
1514
+
1515
+ ### Patch Changes
1516
+
1517
+ - 20aa9dd: feat (provider/gemini): Add JSON mode for generateObject
1518
+ - Updated dependencies [276f22b]
1519
+ - @ai-sdk/provider-utils@0.0.6
1520
+
1521
+ ## 0.0.9
1522
+
1523
+ ### Patch Changes
1524
+
1525
+ - Updated dependencies [41d5736]
1526
+ - @ai-sdk/provider@0.0.3
1527
+ - @ai-sdk/provider-utils@0.0.5
1528
+
1529
+ ## 0.0.8
1530
+
1531
+ ### Patch Changes
1532
+
1533
+ - Updated dependencies [56ef84a]
1534
+ - @ai-sdk/provider-utils@0.0.4
1535
+
1536
+ ## 0.0.7
1537
+
1538
+ ### Patch Changes
1539
+
1540
+ - 25f3350: ai/core: add support for getting raw response headers.
1541
+ - Updated dependencies [d6431ae]
1542
+ - Updated dependencies [25f3350]
1543
+ - @ai-sdk/provider@0.0.2
1544
+ - @ai-sdk/provider-utils@0.0.3
1545
+
1546
+ ## 0.0.6
1547
+
1548
+ ### Patch Changes
1549
+
1550
+ - Updated dependencies [eb150a6]
1551
+ - @ai-sdk/provider-utils@0.0.2
1552
+ - @ai-sdk/provider@0.0.1
1553
+
1554
+ ## 0.0.5
1555
+
1556
+ ### Patch Changes
1557
+
1558
+ - c6fc35b: Add custom header support.
1559
+
1560
+ ## 0.0.4
1561
+
1562
+ ### Patch Changes
1563
+
1564
+ - ab60b18: Simplified model construction by directly calling provider functions. Add create... functions to create provider instances.
1565
+
1566
+ ## 0.0.3
1567
+
1568
+ ### Patch Changes
1569
+
1570
+ - 587240b: Standardize providers to offer .chat() method
1571
+
1572
+ ## 0.0.2
1573
+
1574
+ ### Patch Changes
1575
+
1576
+ - 2bff460: Fix build for release.
1577
+
1578
+ ## 0.0.1
1579
+
1580
+ ### Patch Changes
1581
+
1582
+ - 7b8791d: Rename baseUrl to baseURL. Automatically remove trailing slashes.
1583
+ - Updated dependencies [7b8791d]
1584
+ - @ai-sdk/provider-utils@0.0.1
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/LICENSE ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/README.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI SDK - Google Generative AI Provider
2
+
3
+ The **[Google Generative AI provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Google Generative AI](https://ai.google/discover/generativeai/) APIs.
4
+
5
+ ## Setup
6
+
7
+ The Google Generative AI provider is available in the `@ai-sdk/google` module. You can install it with
8
+
9
+ ```bash
10
+ npm i @ai-sdk/google
11
+ ```
12
+
13
+ ## Provider Instance
14
+
15
+ You can import the default provider instance `google` from `@ai-sdk/google`:
16
+
17
+ ```ts
18
+ import { google } from '@ai-sdk/google';
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```ts
24
+ import { google } from '@ai-sdk/google';
25
+ import { generateText } from 'ai';
26
+
27
+ const { text } = await generateText({
28
+ model: google('gemini-1.5-pro-latest'),
29
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
30
+ });
31
+ ```
32
+
33
+ ## Documentation
34
+
35
+ Please check out the **[Google Generative AI provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai)** for more information.
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.d.mts ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { z } from 'zod/v4';
2
+ import { ProviderV2, LanguageModelV2, ImageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
+ import { FetchFunction } from '@ai-sdk/provider-utils';
5
+
6
+ declare const googleErrorDataSchema: z.ZodObject<{
7
+ error: z.ZodObject<{
8
+ code: z.ZodNullable<z.ZodNumber>;
9
+ message: z.ZodString;
10
+ status: z.ZodString;
11
+ }, z.core.$strip>;
12
+ }, z.core.$strip>;
13
+ type GoogleErrorData = z.infer<typeof googleErrorDataSchema>;
14
+
15
+ type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.5-pro-exp-03-25' | 'gemini-2.5-flash-preview-04-17' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
16
+ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
17
+ responseModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
18
+ TEXT: "TEXT";
19
+ IMAGE: "IMAGE";
20
+ }>>>;
21
+ thinkingConfig: z.ZodOptional<z.ZodObject<{
22
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
23
+ includeThoughts: z.ZodOptional<z.ZodBoolean>;
24
+ }, z.core.$strip>>;
25
+ cachedContent: z.ZodOptional<z.ZodString>;
26
+ structuredOutputs: z.ZodOptional<z.ZodBoolean>;
27
+ safetySettings: z.ZodOptional<z.ZodArray<z.ZodObject<{
28
+ category: z.ZodEnum<{
29
+ HARM_CATEGORY_UNSPECIFIED: "HARM_CATEGORY_UNSPECIFIED";
30
+ HARM_CATEGORY_HATE_SPEECH: "HARM_CATEGORY_HATE_SPEECH";
31
+ HARM_CATEGORY_DANGEROUS_CONTENT: "HARM_CATEGORY_DANGEROUS_CONTENT";
32
+ HARM_CATEGORY_HARASSMENT: "HARM_CATEGORY_HARASSMENT";
33
+ HARM_CATEGORY_SEXUALLY_EXPLICIT: "HARM_CATEGORY_SEXUALLY_EXPLICIT";
34
+ HARM_CATEGORY_CIVIC_INTEGRITY: "HARM_CATEGORY_CIVIC_INTEGRITY";
35
+ }>;
36
+ threshold: z.ZodEnum<{
37
+ HARM_BLOCK_THRESHOLD_UNSPECIFIED: "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
38
+ BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
39
+ BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
40
+ BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
41
+ BLOCK_NONE: "BLOCK_NONE";
42
+ OFF: "OFF";
43
+ }>;
44
+ }, z.core.$strip>>>;
45
+ threshold: z.ZodOptional<z.ZodEnum<{
46
+ HARM_BLOCK_THRESHOLD_UNSPECIFIED: "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
47
+ BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
48
+ BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
49
+ BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
50
+ BLOCK_NONE: "BLOCK_NONE";
51
+ OFF: "OFF";
52
+ }>>;
53
+ audioTimestamp: z.ZodOptional<z.ZodBoolean>;
54
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
55
+ }, z.core.$strip>;
56
+ type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
57
+
58
+ declare const groundingMetadataSchema: z.ZodObject<{
59
+ webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
60
+ retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
61
+ searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
62
+ renderedContent: z.ZodString;
63
+ }, z.core.$strip>>>;
64
+ groundingChunks: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
65
+ web: z.ZodOptional<z.ZodNullable<z.ZodObject<{
66
+ uri: z.ZodString;
67
+ title: z.ZodString;
68
+ }, z.core.$strip>>>;
69
+ retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
70
+ uri: z.ZodString;
71
+ title: z.ZodString;
72
+ }, z.core.$strip>>>;
73
+ }, z.core.$strip>>>>;
74
+ groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
75
+ segment: z.ZodObject<{
76
+ startIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
77
+ endIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
78
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ }, z.core.$strip>;
80
+ segment_text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ groundingChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
82
+ supportChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
83
+ confidenceScores: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
84
+ confidenceScore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
85
+ }, z.core.$strip>>>>;
86
+ retrievalMetadata: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
87
+ webDynamicRetrievalScore: z.ZodNumber;
88
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>]>>>;
89
+ }, z.core.$strip>;
90
+
91
+ declare const urlContextMetadataSchema: z.ZodObject<{
92
+ urlMetadata: z.ZodArray<z.ZodObject<{
93
+ retrievedUrl: z.ZodString;
94
+ urlRetrievalStatus: z.ZodString;
95
+ }, z.core.$strip>>;
96
+ }, z.core.$strip>;
97
+
98
+ declare const safetyRatingSchema: z.ZodObject<{
99
+ category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
100
+ probability: z.ZodOptional<z.ZodNullable<z.ZodString>>;
101
+ probabilityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
102
+ severity: z.ZodOptional<z.ZodNullable<z.ZodString>>;
103
+ severityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
104
+ blocked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
105
+ }, z.core.$strip>;
106
+
107
+ type GoogleGenerativeAIGroundingMetadata = z.infer<typeof groundingMetadataSchema>;
108
+ type GoogleGenerativeAIUrlContextMetadata = z.infer<typeof urlContextMetadataSchema>;
109
+ type GoogleGenerativeAISafetyRating = z.infer<typeof safetyRatingSchema>;
110
+ interface GoogleGenerativeAIProviderMetadata {
111
+ groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
112
+ urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
113
+ safetyRatings: GoogleGenerativeAISafetyRating[] | null;
114
+ }
115
+
116
+ type GoogleGenerativeAIImageModelId = 'imagen-3.0-generate-002' | (string & {});
117
+ interface GoogleGenerativeAIImageSettings {
118
+ /**
119
+ Override the maximum number of images per call (default 4)
120
+ */
121
+ maxImagesPerCall?: number;
122
+ }
123
+
124
+ declare const googleImageProviderOptionsSchema: z.ZodObject<{
125
+ personGeneration: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
126
+ dont_allow: "dont_allow";
127
+ allow_adult: "allow_adult";
128
+ allow_all: "allow_all";
129
+ }>>>;
130
+ aspectRatio: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
131
+ "1:1": "1:1";
132
+ "3:4": "3:4";
133
+ "4:3": "4:3";
134
+ "9:16": "9:16";
135
+ "16:9": "16:9";
136
+ }>>>;
137
+ }, z.core.$strip>;
138
+ type GoogleGenerativeAIImageProviderOptions = z.infer<typeof googleImageProviderOptionsSchema>;
139
+
140
+ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'text-embedding-004' | (string & {});
141
+ declare const googleGenerativeAIEmbeddingProviderOptions: z.ZodObject<{
142
+ outputDimensionality: z.ZodOptional<z.ZodNumber>;
143
+ taskType: z.ZodOptional<z.ZodEnum<{
144
+ SEMANTIC_SIMILARITY: "SEMANTIC_SIMILARITY";
145
+ CLASSIFICATION: "CLASSIFICATION";
146
+ CLUSTERING: "CLUSTERING";
147
+ RETRIEVAL_DOCUMENT: "RETRIEVAL_DOCUMENT";
148
+ RETRIEVAL_QUERY: "RETRIEVAL_QUERY";
149
+ QUESTION_ANSWERING: "QUESTION_ANSWERING";
150
+ FACT_VERIFICATION: "FACT_VERIFICATION";
151
+ CODE_RETRIEVAL_QUERY: "CODE_RETRIEVAL_QUERY";
152
+ }>>;
153
+ }, z.core.$strip>;
154
+ type GoogleGenerativeAIEmbeddingProviderOptions = z.infer<typeof googleGenerativeAIEmbeddingProviderOptions>;
155
+
156
+ declare const googleTools: {
157
+ /**
158
+ * Creates a Google search tool that gives Google direct access to real-time web content.
159
+ * Must have name "google_search".
160
+ */
161
+ googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
162
+ mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
163
+ dynamicThreshold?: number;
164
+ }>;
165
+ /**
166
+ * Creates a URL context tool that gives Google direct access to real-time web content.
167
+ * Must have name "url_context".
168
+ */
169
+ urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
170
+ /**
171
+ * A tool that enables the model to generate and run Python code.
172
+ * Must have name "code_execution".
173
+ *
174
+ * @note Ensure the selected model supports Code Execution.
175
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
176
+ *
177
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
178
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
179
+ */
180
+ codeExecution: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
181
+ language: string;
182
+ code: string;
183
+ }, {
184
+ outcome: string;
185
+ output: string;
186
+ }, {}>;
187
+ };
188
+
189
+ interface GoogleGenerativeAIProvider extends ProviderV2 {
190
+ (modelId: GoogleGenerativeAIModelId): LanguageModelV2;
191
+ languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
192
+ chat(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
193
+ /**
194
+ Creates a model for image generation.
195
+ */
196
+ image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV2;
197
+ /**
198
+ * @deprecated Use `chat()` instead.
199
+ */
200
+ generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
201
+ /**
202
+ @deprecated Use `textEmbedding()` instead.
203
+ */
204
+ embedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
205
+ textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
206
+ textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
207
+ tools: typeof googleTools;
208
+ }
209
+ interface GoogleGenerativeAIProviderSettings {
210
+ /**
211
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
212
+ The default prefix is `https://generativelanguage.googleapis.com/v1beta`.
213
+ */
214
+ baseURL?: string;
215
+ /**
216
+ API key that is being send using the `x-goog-api-key` header.
217
+ It defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
218
+ */
219
+ apiKey?: string;
220
+ /**
221
+ Custom headers to include in the requests.
222
+ */
223
+ headers?: Record<string, string | undefined>;
224
+ /**
225
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
226
+ or to provide a custom fetch implementation for e.g. testing.
227
+ */
228
+ fetch?: FetchFunction;
229
+ /**
230
+ Optional function to generate a unique ID for each request.
231
+ */
232
+ generateId?: () => string;
233
+ }
234
+ /**
235
+ Create a Google Generative AI provider instance.
236
+ */
237
+ declare function createGoogleGenerativeAI(options?: GoogleGenerativeAIProviderSettings): GoogleGenerativeAIProvider;
238
+ /**
239
+ Default Google Generative AI provider instance.
240
+ */
241
+ declare const google: GoogleGenerativeAIProvider;
242
+
243
+ export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.d.ts ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { z } from 'zod/v4';
2
+ import { ProviderV2, LanguageModelV2, ImageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
+ import { FetchFunction } from '@ai-sdk/provider-utils';
5
+
6
+ declare const googleErrorDataSchema: z.ZodObject<{
7
+ error: z.ZodObject<{
8
+ code: z.ZodNullable<z.ZodNumber>;
9
+ message: z.ZodString;
10
+ status: z.ZodString;
11
+ }, z.core.$strip>;
12
+ }, z.core.$strip>;
13
+ type GoogleErrorData = z.infer<typeof googleErrorDataSchema>;
14
+
15
+ type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.5-pro-exp-03-25' | 'gemini-2.5-flash-preview-04-17' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
16
+ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
17
+ responseModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
18
+ TEXT: "TEXT";
19
+ IMAGE: "IMAGE";
20
+ }>>>;
21
+ thinkingConfig: z.ZodOptional<z.ZodObject<{
22
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
23
+ includeThoughts: z.ZodOptional<z.ZodBoolean>;
24
+ }, z.core.$strip>>;
25
+ cachedContent: z.ZodOptional<z.ZodString>;
26
+ structuredOutputs: z.ZodOptional<z.ZodBoolean>;
27
+ safetySettings: z.ZodOptional<z.ZodArray<z.ZodObject<{
28
+ category: z.ZodEnum<{
29
+ HARM_CATEGORY_UNSPECIFIED: "HARM_CATEGORY_UNSPECIFIED";
30
+ HARM_CATEGORY_HATE_SPEECH: "HARM_CATEGORY_HATE_SPEECH";
31
+ HARM_CATEGORY_DANGEROUS_CONTENT: "HARM_CATEGORY_DANGEROUS_CONTENT";
32
+ HARM_CATEGORY_HARASSMENT: "HARM_CATEGORY_HARASSMENT";
33
+ HARM_CATEGORY_SEXUALLY_EXPLICIT: "HARM_CATEGORY_SEXUALLY_EXPLICIT";
34
+ HARM_CATEGORY_CIVIC_INTEGRITY: "HARM_CATEGORY_CIVIC_INTEGRITY";
35
+ }>;
36
+ threshold: z.ZodEnum<{
37
+ HARM_BLOCK_THRESHOLD_UNSPECIFIED: "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
38
+ BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
39
+ BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
40
+ BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
41
+ BLOCK_NONE: "BLOCK_NONE";
42
+ OFF: "OFF";
43
+ }>;
44
+ }, z.core.$strip>>>;
45
+ threshold: z.ZodOptional<z.ZodEnum<{
46
+ HARM_BLOCK_THRESHOLD_UNSPECIFIED: "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
47
+ BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
48
+ BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
49
+ BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
50
+ BLOCK_NONE: "BLOCK_NONE";
51
+ OFF: "OFF";
52
+ }>>;
53
+ audioTimestamp: z.ZodOptional<z.ZodBoolean>;
54
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
55
+ }, z.core.$strip>;
56
+ type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
57
+
58
+ declare const groundingMetadataSchema: z.ZodObject<{
59
+ webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
60
+ retrievalQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
61
+ searchEntryPoint: z.ZodOptional<z.ZodNullable<z.ZodObject<{
62
+ renderedContent: z.ZodString;
63
+ }, z.core.$strip>>>;
64
+ groundingChunks: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
65
+ web: z.ZodOptional<z.ZodNullable<z.ZodObject<{
66
+ uri: z.ZodString;
67
+ title: z.ZodString;
68
+ }, z.core.$strip>>>;
69
+ retrievedContext: z.ZodOptional<z.ZodNullable<z.ZodObject<{
70
+ uri: z.ZodString;
71
+ title: z.ZodString;
72
+ }, z.core.$strip>>>;
73
+ }, z.core.$strip>>>>;
74
+ groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
75
+ segment: z.ZodObject<{
76
+ startIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
77
+ endIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
78
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ }, z.core.$strip>;
80
+ segment_text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ groundingChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
82
+ supportChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
83
+ confidenceScores: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
84
+ confidenceScore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
85
+ }, z.core.$strip>>>>;
86
+ retrievalMetadata: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
87
+ webDynamicRetrievalScore: z.ZodNumber;
88
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>]>>>;
89
+ }, z.core.$strip>;
90
+
91
+ declare const urlContextMetadataSchema: z.ZodObject<{
92
+ urlMetadata: z.ZodArray<z.ZodObject<{
93
+ retrievedUrl: z.ZodString;
94
+ urlRetrievalStatus: z.ZodString;
95
+ }, z.core.$strip>>;
96
+ }, z.core.$strip>;
97
+
98
+ declare const safetyRatingSchema: z.ZodObject<{
99
+ category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
100
+ probability: z.ZodOptional<z.ZodNullable<z.ZodString>>;
101
+ probabilityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
102
+ severity: z.ZodOptional<z.ZodNullable<z.ZodString>>;
103
+ severityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
104
+ blocked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
105
+ }, z.core.$strip>;
106
+
107
+ type GoogleGenerativeAIGroundingMetadata = z.infer<typeof groundingMetadataSchema>;
108
+ type GoogleGenerativeAIUrlContextMetadata = z.infer<typeof urlContextMetadataSchema>;
109
+ type GoogleGenerativeAISafetyRating = z.infer<typeof safetyRatingSchema>;
110
+ interface GoogleGenerativeAIProviderMetadata {
111
+ groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
112
+ urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
113
+ safetyRatings: GoogleGenerativeAISafetyRating[] | null;
114
+ }
115
+
116
+ type GoogleGenerativeAIImageModelId = 'imagen-3.0-generate-002' | (string & {});
117
+ interface GoogleGenerativeAIImageSettings {
118
+ /**
119
+ Override the maximum number of images per call (default 4)
120
+ */
121
+ maxImagesPerCall?: number;
122
+ }
123
+
124
+ declare const googleImageProviderOptionsSchema: z.ZodObject<{
125
+ personGeneration: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
126
+ dont_allow: "dont_allow";
127
+ allow_adult: "allow_adult";
128
+ allow_all: "allow_all";
129
+ }>>>;
130
+ aspectRatio: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
131
+ "1:1": "1:1";
132
+ "3:4": "3:4";
133
+ "4:3": "4:3";
134
+ "9:16": "9:16";
135
+ "16:9": "16:9";
136
+ }>>>;
137
+ }, z.core.$strip>;
138
+ type GoogleGenerativeAIImageProviderOptions = z.infer<typeof googleImageProviderOptionsSchema>;
139
+
140
+ type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'text-embedding-004' | (string & {});
141
+ declare const googleGenerativeAIEmbeddingProviderOptions: z.ZodObject<{
142
+ outputDimensionality: z.ZodOptional<z.ZodNumber>;
143
+ taskType: z.ZodOptional<z.ZodEnum<{
144
+ SEMANTIC_SIMILARITY: "SEMANTIC_SIMILARITY";
145
+ CLASSIFICATION: "CLASSIFICATION";
146
+ CLUSTERING: "CLUSTERING";
147
+ RETRIEVAL_DOCUMENT: "RETRIEVAL_DOCUMENT";
148
+ RETRIEVAL_QUERY: "RETRIEVAL_QUERY";
149
+ QUESTION_ANSWERING: "QUESTION_ANSWERING";
150
+ FACT_VERIFICATION: "FACT_VERIFICATION";
151
+ CODE_RETRIEVAL_QUERY: "CODE_RETRIEVAL_QUERY";
152
+ }>>;
153
+ }, z.core.$strip>;
154
+ type GoogleGenerativeAIEmbeddingProviderOptions = z.infer<typeof googleGenerativeAIEmbeddingProviderOptions>;
155
+
156
+ declare const googleTools: {
157
+ /**
158
+ * Creates a Google search tool that gives Google direct access to real-time web content.
159
+ * Must have name "google_search".
160
+ */
161
+ googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
162
+ mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
163
+ dynamicThreshold?: number;
164
+ }>;
165
+ /**
166
+ * Creates a URL context tool that gives Google direct access to real-time web content.
167
+ * Must have name "url_context".
168
+ */
169
+ urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
170
+ /**
171
+ * A tool that enables the model to generate and run Python code.
172
+ * Must have name "code_execution".
173
+ *
174
+ * @note Ensure the selected model supports Code Execution.
175
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
176
+ *
177
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
178
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
179
+ */
180
+ codeExecution: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
181
+ language: string;
182
+ code: string;
183
+ }, {
184
+ outcome: string;
185
+ output: string;
186
+ }, {}>;
187
+ };
188
+
189
+ interface GoogleGenerativeAIProvider extends ProviderV2 {
190
+ (modelId: GoogleGenerativeAIModelId): LanguageModelV2;
191
+ languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
192
+ chat(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
193
+ /**
194
+ Creates a model for image generation.
195
+ */
196
+ image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV2;
197
+ /**
198
+ * @deprecated Use `chat()` instead.
199
+ */
200
+ generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV2;
201
+ /**
202
+ @deprecated Use `textEmbedding()` instead.
203
+ */
204
+ embedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
205
+ textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
206
+ textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV2<string>;
207
+ tools: typeof googleTools;
208
+ }
209
+ interface GoogleGenerativeAIProviderSettings {
210
+ /**
211
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
212
+ The default prefix is `https://generativelanguage.googleapis.com/v1beta`.
213
+ */
214
+ baseURL?: string;
215
+ /**
216
+ API key that is being send using the `x-goog-api-key` header.
217
+ It defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
218
+ */
219
+ apiKey?: string;
220
+ /**
221
+ Custom headers to include in the requests.
222
+ */
223
+ headers?: Record<string, string | undefined>;
224
+ /**
225
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
226
+ or to provide a custom fetch implementation for e.g. testing.
227
+ */
228
+ fetch?: FetchFunction;
229
+ /**
230
+ Optional function to generate a unique ID for each request.
231
+ */
232
+ generateId?: () => string;
233
+ }
234
+ /**
235
+ Create a Google Generative AI provider instance.
236
+ */
237
+ declare function createGoogleGenerativeAI(options?: GoogleGenerativeAIProviderSettings): GoogleGenerativeAIProvider;
238
+ /**
239
+ Default Google Generative AI provider instance.
240
+ */
241
+ declare const google: GoogleGenerativeAIProvider;
242
+
243
+ export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.js ADDED
@@ -0,0 +1,1492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ createGoogleGenerativeAI: () => createGoogleGenerativeAI,
24
+ google: () => google
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/google-provider.ts
29
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
30
+
31
+ // src/google-generative-ai-embedding-model.ts
32
+ var import_provider = require("@ai-sdk/provider");
33
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
34
+ var import_v43 = require("zod/v4");
35
+
36
+ // src/google-error.ts
37
+ var import_provider_utils = require("@ai-sdk/provider-utils");
38
+ var import_v4 = require("zod/v4");
39
+ var googleErrorDataSchema = import_v4.z.object({
40
+ error: import_v4.z.object({
41
+ code: import_v4.z.number().nullable(),
42
+ message: import_v4.z.string(),
43
+ status: import_v4.z.string()
44
+ })
45
+ });
46
+ var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
47
+ errorSchema: googleErrorDataSchema,
48
+ errorToMessage: (data) => data.error.message
49
+ });
50
+
51
+ // src/google-generative-ai-embedding-options.ts
52
+ var import_v42 = require("zod/v4");
53
+ var googleGenerativeAIEmbeddingProviderOptions = import_v42.z.object({
54
+ /**
55
+ * Optional. Optional reduced dimension for the output embedding.
56
+ * If set, excessive values in the output embedding are truncated from the end.
57
+ */
58
+ outputDimensionality: import_v42.z.number().optional(),
59
+ /**
60
+ * Optional. Specifies the task type for generating embeddings.
61
+ * Supported task types:
62
+ * - SEMANTIC_SIMILARITY: Optimized for text similarity.
63
+ * - CLASSIFICATION: Optimized for text classification.
64
+ * - CLUSTERING: Optimized for clustering texts based on similarity.
65
+ * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
66
+ * - RETRIEVAL_QUERY: Optimized for query-based retrieval.
67
+ * - QUESTION_ANSWERING: Optimized for answering questions.
68
+ * - FACT_VERIFICATION: Optimized for verifying factual information.
69
+ * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
70
+ */
71
+ taskType: import_v42.z.enum([
72
+ "SEMANTIC_SIMILARITY",
73
+ "CLASSIFICATION",
74
+ "CLUSTERING",
75
+ "RETRIEVAL_DOCUMENT",
76
+ "RETRIEVAL_QUERY",
77
+ "QUESTION_ANSWERING",
78
+ "FACT_VERIFICATION",
79
+ "CODE_RETRIEVAL_QUERY"
80
+ ]).optional()
81
+ });
82
+
83
+ // src/google-generative-ai-embedding-model.ts
84
+ var GoogleGenerativeAIEmbeddingModel = class {
85
+ constructor(modelId, config) {
86
+ this.specificationVersion = "v2";
87
+ this.maxEmbeddingsPerCall = 2048;
88
+ this.supportsParallelCalls = true;
89
+ this.modelId = modelId;
90
+ this.config = config;
91
+ }
92
+ get provider() {
93
+ return this.config.provider;
94
+ }
95
+ async doEmbed({
96
+ values,
97
+ headers,
98
+ abortSignal,
99
+ providerOptions
100
+ }) {
101
+ const googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
102
+ provider: "google",
103
+ providerOptions,
104
+ schema: googleGenerativeAIEmbeddingProviderOptions
105
+ });
106
+ if (values.length > this.maxEmbeddingsPerCall) {
107
+ throw new import_provider.TooManyEmbeddingValuesForCallError({
108
+ provider: this.provider,
109
+ modelId: this.modelId,
110
+ maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
111
+ values
112
+ });
113
+ }
114
+ const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
115
+ await (0, import_provider_utils2.resolve)(this.config.headers),
116
+ headers
117
+ );
118
+ if (values.length === 1) {
119
+ const {
120
+ responseHeaders: responseHeaders2,
121
+ value: response2,
122
+ rawValue: rawValue2
123
+ } = await (0, import_provider_utils2.postJsonToApi)({
124
+ url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
125
+ headers: mergedHeaders,
126
+ body: {
127
+ model: `models/${this.modelId}`,
128
+ content: {
129
+ parts: [{ text: values[0] }]
130
+ },
131
+ outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
132
+ taskType: googleOptions == null ? void 0 : googleOptions.taskType
133
+ },
134
+ failedResponseHandler: googleFailedResponseHandler,
135
+ successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
136
+ googleGenerativeAISingleEmbeddingResponseSchema
137
+ ),
138
+ abortSignal,
139
+ fetch: this.config.fetch
140
+ });
141
+ return {
142
+ embeddings: [response2.embedding.values],
143
+ usage: void 0,
144
+ response: { headers: responseHeaders2, body: rawValue2 }
145
+ };
146
+ }
147
+ const {
148
+ responseHeaders,
149
+ value: response,
150
+ rawValue
151
+ } = await (0, import_provider_utils2.postJsonToApi)({
152
+ url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
153
+ headers: mergedHeaders,
154
+ body: {
155
+ requests: values.map((value) => ({
156
+ model: `models/${this.modelId}`,
157
+ content: { role: "user", parts: [{ text: value }] },
158
+ outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
159
+ taskType: googleOptions == null ? void 0 : googleOptions.taskType
160
+ }))
161
+ },
162
+ failedResponseHandler: googleFailedResponseHandler,
163
+ successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
164
+ googleGenerativeAITextEmbeddingResponseSchema
165
+ ),
166
+ abortSignal,
167
+ fetch: this.config.fetch
168
+ });
169
+ return {
170
+ embeddings: response.embeddings.map((item) => item.values),
171
+ usage: void 0,
172
+ response: { headers: responseHeaders, body: rawValue }
173
+ };
174
+ }
175
+ };
176
+ var googleGenerativeAITextEmbeddingResponseSchema = import_v43.z.object({
177
+ embeddings: import_v43.z.array(import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) }))
178
+ });
179
+ var googleGenerativeAISingleEmbeddingResponseSchema = import_v43.z.object({
180
+ embedding: import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) })
181
+ });
182
+
183
+ // src/google-generative-ai-language-model.ts
184
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
185
+ var import_v47 = require("zod/v4");
186
+
187
+ // src/convert-json-schema-to-openapi-schema.ts
188
+ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
189
+ if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
190
+ return void 0;
191
+ }
192
+ if (typeof jsonSchema === "boolean") {
193
+ return { type: "boolean", properties: {} };
194
+ }
195
+ const {
196
+ type,
197
+ description,
198
+ required,
199
+ properties,
200
+ items,
201
+ allOf,
202
+ anyOf,
203
+ oneOf,
204
+ format,
205
+ const: constValue,
206
+ minLength,
207
+ enum: enumValues
208
+ } = jsonSchema;
209
+ const result = {};
210
+ if (description)
211
+ result.description = description;
212
+ if (required)
213
+ result.required = required;
214
+ if (format)
215
+ result.format = format;
216
+ if (constValue !== void 0) {
217
+ result.enum = [constValue];
218
+ }
219
+ if (type) {
220
+ if (Array.isArray(type)) {
221
+ if (type.includes("null")) {
222
+ result.type = type.filter((t) => t !== "null")[0];
223
+ result.nullable = true;
224
+ } else {
225
+ result.type = type;
226
+ }
227
+ } else if (type === "null") {
228
+ result.type = "null";
229
+ } else {
230
+ result.type = type;
231
+ }
232
+ }
233
+ if (enumValues !== void 0) {
234
+ result.enum = enumValues;
235
+ }
236
+ if (properties != null) {
237
+ result.properties = Object.entries(properties).reduce(
238
+ (acc, [key, value]) => {
239
+ acc[key] = convertJSONSchemaToOpenAPISchema(value);
240
+ return acc;
241
+ },
242
+ {}
243
+ );
244
+ }
245
+ if (items) {
246
+ result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
247
+ }
248
+ if (allOf) {
249
+ result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
250
+ }
251
+ if (anyOf) {
252
+ if (anyOf.some(
253
+ (schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"
254
+ )) {
255
+ const nonNullSchemas = anyOf.filter(
256
+ (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
257
+ );
258
+ if (nonNullSchemas.length === 1) {
259
+ const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
260
+ if (typeof converted === "object") {
261
+ result.nullable = true;
262
+ Object.assign(result, converted);
263
+ }
264
+ } else {
265
+ result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
266
+ result.nullable = true;
267
+ }
268
+ } else {
269
+ result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
270
+ }
271
+ }
272
+ if (oneOf) {
273
+ result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
274
+ }
275
+ if (minLength !== void 0) {
276
+ result.minLength = minLength;
277
+ }
278
+ return result;
279
+ }
280
+ function isEmptyObjectSchema(jsonSchema) {
281
+ return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
282
+ }
283
+
284
+ // src/convert-to-google-generative-ai-messages.ts
285
+ var import_provider2 = require("@ai-sdk/provider");
286
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
287
+ function convertToGoogleGenerativeAIMessages(prompt, options) {
288
+ var _a;
289
+ const systemInstructionParts = [];
290
+ const contents = [];
291
+ let systemMessagesAllowed = true;
292
+ const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
293
+ for (const { role, content } of prompt) {
294
+ switch (role) {
295
+ case "system": {
296
+ if (!systemMessagesAllowed) {
297
+ throw new import_provider2.UnsupportedFunctionalityError({
298
+ functionality: "system messages are only supported at the beginning of the conversation"
299
+ });
300
+ }
301
+ systemInstructionParts.push({ text: content });
302
+ break;
303
+ }
304
+ case "user": {
305
+ systemMessagesAllowed = false;
306
+ const parts = [];
307
+ for (const part of content) {
308
+ switch (part.type) {
309
+ case "text": {
310
+ parts.push({ text: part.text });
311
+ break;
312
+ }
313
+ case "file": {
314
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
315
+ parts.push(
316
+ part.data instanceof URL ? {
317
+ fileData: {
318
+ mimeType: mediaType,
319
+ fileUri: part.data.toString()
320
+ }
321
+ } : {
322
+ inlineData: {
323
+ mimeType: mediaType,
324
+ data: (0, import_provider_utils3.convertToBase64)(part.data)
325
+ }
326
+ }
327
+ );
328
+ break;
329
+ }
330
+ }
331
+ }
332
+ contents.push({ role: "user", parts });
333
+ break;
334
+ }
335
+ case "assistant": {
336
+ systemMessagesAllowed = false;
337
+ contents.push({
338
+ role: "model",
339
+ parts: content.map((part) => {
340
+ var _a2, _b, _c, _d, _e, _f;
341
+ switch (part.type) {
342
+ case "text": {
343
+ return part.text.length === 0 ? void 0 : {
344
+ text: part.text,
345
+ thoughtSignature: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature
346
+ };
347
+ }
348
+ case "reasoning": {
349
+ return part.text.length === 0 ? void 0 : {
350
+ text: part.text,
351
+ thought: true,
352
+ thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
353
+ };
354
+ }
355
+ case "file": {
356
+ if (part.mediaType !== "image/png") {
357
+ throw new import_provider2.UnsupportedFunctionalityError({
358
+ functionality: "Only PNG images are supported in assistant messages"
359
+ });
360
+ }
361
+ if (part.data instanceof URL) {
362
+ throw new import_provider2.UnsupportedFunctionalityError({
363
+ functionality: "File data URLs in assistant messages are not supported"
364
+ });
365
+ }
366
+ return {
367
+ inlineData: {
368
+ mimeType: part.mediaType,
369
+ data: (0, import_provider_utils3.convertToBase64)(part.data)
370
+ }
371
+ };
372
+ }
373
+ case "tool-call": {
374
+ return {
375
+ functionCall: {
376
+ name: part.toolName,
377
+ args: part.input
378
+ },
379
+ thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
380
+ };
381
+ }
382
+ }
383
+ }).filter((part) => part !== void 0)
384
+ });
385
+ break;
386
+ }
387
+ case "tool": {
388
+ systemMessagesAllowed = false;
389
+ contents.push({
390
+ role: "user",
391
+ parts: content.map((part) => ({
392
+ functionResponse: {
393
+ name: part.toolName,
394
+ response: {
395
+ name: part.toolName,
396
+ content: part.output.value
397
+ }
398
+ }
399
+ }))
400
+ });
401
+ break;
402
+ }
403
+ }
404
+ }
405
+ if (isGemmaModel && systemInstructionParts.length > 0 && contents.length > 0 && contents[0].role === "user") {
406
+ const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
407
+ contents[0].parts.unshift({ text: systemText + "\n\n" });
408
+ }
409
+ return {
410
+ systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
411
+ contents
412
+ };
413
+ }
414
+
415
+ // src/get-model-path.ts
416
+ function getModelPath(modelId) {
417
+ return modelId.includes("/") ? modelId : `models/${modelId}`;
418
+ }
419
+
420
+ // src/google-generative-ai-options.ts
421
+ var import_v44 = require("zod/v4");
422
+ var googleGenerativeAIProviderOptions = import_v44.z.object({
423
+ responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
424
+ thinkingConfig: import_v44.z.object({
425
+ thinkingBudget: import_v44.z.number().optional(),
426
+ includeThoughts: import_v44.z.boolean().optional()
427
+ }).optional(),
428
+ /**
429
+ Optional.
430
+ The name of the cached content used as context to serve the prediction.
431
+ Format: cachedContents/{cachedContent}
432
+ */
433
+ cachedContent: import_v44.z.string().optional(),
434
+ /**
435
+ * Optional. Enable structured output. Default is true.
436
+ *
437
+ * This is useful when the JSON Schema contains elements that are
438
+ * not supported by the OpenAPI schema version that
439
+ * Google Generative AI uses. You can use this to disable
440
+ * structured outputs if you need to.
441
+ */
442
+ structuredOutputs: import_v44.z.boolean().optional(),
443
+ /**
444
+ Optional. A list of unique safety settings for blocking unsafe content.
445
+ */
446
+ safetySettings: import_v44.z.array(
447
+ import_v44.z.object({
448
+ category: import_v44.z.enum([
449
+ "HARM_CATEGORY_UNSPECIFIED",
450
+ "HARM_CATEGORY_HATE_SPEECH",
451
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
452
+ "HARM_CATEGORY_HARASSMENT",
453
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT",
454
+ "HARM_CATEGORY_CIVIC_INTEGRITY"
455
+ ]),
456
+ threshold: import_v44.z.enum([
457
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
458
+ "BLOCK_LOW_AND_ABOVE",
459
+ "BLOCK_MEDIUM_AND_ABOVE",
460
+ "BLOCK_ONLY_HIGH",
461
+ "BLOCK_NONE",
462
+ "OFF"
463
+ ])
464
+ })
465
+ ).optional(),
466
+ threshold: import_v44.z.enum([
467
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
468
+ "BLOCK_LOW_AND_ABOVE",
469
+ "BLOCK_MEDIUM_AND_ABOVE",
470
+ "BLOCK_ONLY_HIGH",
471
+ "BLOCK_NONE",
472
+ "OFF"
473
+ ]).optional(),
474
+ /**
475
+ * Optional. Enables timestamp understanding for audio-only files.
476
+ *
477
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
478
+ */
479
+ audioTimestamp: import_v44.z.boolean().optional(),
480
+ /**
481
+ * Optional. Defines labels used in billing reports. Available on Vertex AI only.
482
+ *
483
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
484
+ */
485
+ labels: import_v44.z.record(import_v44.z.string(), import_v44.z.string()).optional()
486
+ });
487
+
488
+ // src/google-prepare-tools.ts
489
+ var import_provider3 = require("@ai-sdk/provider");
490
+ function prepareTools({
491
+ tools,
492
+ toolChoice,
493
+ modelId
494
+ }) {
495
+ var _a;
496
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
497
+ const toolWarnings = [];
498
+ const isGemini2 = modelId.includes("gemini-2");
499
+ const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
500
+ if (tools == null) {
501
+ return { tools: void 0, toolConfig: void 0, toolWarnings };
502
+ }
503
+ const hasFunctionTools = tools.some((tool) => tool.type === "function");
504
+ const hasProviderDefinedTools = tools.some(
505
+ (tool) => tool.type === "provider-defined"
506
+ );
507
+ if (hasFunctionTools && hasProviderDefinedTools) {
508
+ toolWarnings.push({
509
+ type: "unsupported-tool",
510
+ tool: tools.find((tool) => tool.type === "function"),
511
+ details: "Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both."
512
+ });
513
+ }
514
+ if (hasProviderDefinedTools) {
515
+ const googleTools2 = {};
516
+ const providerDefinedTools = tools.filter(
517
+ (tool) => tool.type === "provider-defined"
518
+ );
519
+ providerDefinedTools.forEach((tool) => {
520
+ switch (tool.id) {
521
+ case "google.google_search":
522
+ if (isGemini2) {
523
+ googleTools2.googleSearch = {};
524
+ } else if (supportsDynamicRetrieval) {
525
+ googleTools2.googleSearchRetrieval = {
526
+ dynamicRetrievalConfig: {
527
+ mode: tool.args.mode,
528
+ dynamicThreshold: tool.args.dynamicThreshold
529
+ }
530
+ };
531
+ } else {
532
+ googleTools2.googleSearchRetrieval = {};
533
+ }
534
+ break;
535
+ case "google.url_context":
536
+ if (isGemini2) {
537
+ googleTools2.urlContext = {};
538
+ } else {
539
+ toolWarnings.push({
540
+ type: "unsupported-tool",
541
+ tool,
542
+ details: "The URL context tool is not supported with other Gemini models than Gemini 2."
543
+ });
544
+ }
545
+ break;
546
+ case "google.code_execution":
547
+ if (isGemini2) {
548
+ googleTools2.codeExecution = {};
549
+ } else {
550
+ toolWarnings.push({
551
+ type: "unsupported-tool",
552
+ tool,
553
+ details: "The code execution tools is not supported with other Gemini models than Gemini 2."
554
+ });
555
+ }
556
+ break;
557
+ default:
558
+ toolWarnings.push({ type: "unsupported-tool", tool });
559
+ break;
560
+ }
561
+ });
562
+ return {
563
+ tools: Object.keys(googleTools2).length > 0 ? googleTools2 : void 0,
564
+ toolConfig: void 0,
565
+ toolWarnings
566
+ };
567
+ }
568
+ const functionDeclarations = [];
569
+ for (const tool of tools) {
570
+ switch (tool.type) {
571
+ case "function":
572
+ functionDeclarations.push({
573
+ name: tool.name,
574
+ description: (_a = tool.description) != null ? _a : "",
575
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
576
+ });
577
+ break;
578
+ default:
579
+ toolWarnings.push({ type: "unsupported-tool", tool });
580
+ break;
581
+ }
582
+ }
583
+ if (toolChoice == null) {
584
+ return {
585
+ tools: { functionDeclarations },
586
+ toolConfig: void 0,
587
+ toolWarnings
588
+ };
589
+ }
590
+ const type = toolChoice.type;
591
+ switch (type) {
592
+ case "auto":
593
+ return {
594
+ tools: { functionDeclarations },
595
+ toolConfig: { functionCallingConfig: { mode: "AUTO" } },
596
+ toolWarnings
597
+ };
598
+ case "none":
599
+ return {
600
+ tools: { functionDeclarations },
601
+ toolConfig: { functionCallingConfig: { mode: "NONE" } },
602
+ toolWarnings
603
+ };
604
+ case "required":
605
+ return {
606
+ tools: { functionDeclarations },
607
+ toolConfig: { functionCallingConfig: { mode: "ANY" } },
608
+ toolWarnings
609
+ };
610
+ case "tool":
611
+ return {
612
+ tools: { functionDeclarations },
613
+ toolConfig: {
614
+ functionCallingConfig: {
615
+ mode: "ANY",
616
+ allowedFunctionNames: [toolChoice.toolName]
617
+ }
618
+ },
619
+ toolWarnings
620
+ };
621
+ default: {
622
+ const _exhaustiveCheck = type;
623
+ throw new import_provider3.UnsupportedFunctionalityError({
624
+ functionality: `tool choice type: ${_exhaustiveCheck}`
625
+ });
626
+ }
627
+ }
628
+ }
629
+
630
+ // src/map-google-generative-ai-finish-reason.ts
631
+ function mapGoogleGenerativeAIFinishReason({
632
+ finishReason,
633
+ hasToolCalls
634
+ }) {
635
+ switch (finishReason) {
636
+ case "STOP":
637
+ return hasToolCalls ? "tool-calls" : "stop";
638
+ case "MAX_TOKENS":
639
+ return "length";
640
+ case "IMAGE_SAFETY":
641
+ case "RECITATION":
642
+ case "SAFETY":
643
+ case "BLOCKLIST":
644
+ case "PROHIBITED_CONTENT":
645
+ case "SPII":
646
+ return "content-filter";
647
+ case "FINISH_REASON_UNSPECIFIED":
648
+ case "OTHER":
649
+ return "other";
650
+ case "MALFORMED_FUNCTION_CALL":
651
+ return "error";
652
+ default:
653
+ return "unknown";
654
+ }
655
+ }
656
+
657
+ // src/tool/google-search.ts
658
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
659
+ var import_v45 = require("zod/v4");
660
+ var groundingChunkSchema = import_v45.z.object({
661
+ web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish(),
662
+ retrievedContext: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string() }).nullish()
663
+ });
664
+ var groundingMetadataSchema = import_v45.z.object({
665
+ webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
666
+ retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
667
+ searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
668
+ groundingChunks: import_v45.z.array(groundingChunkSchema).nullish(),
669
+ groundingSupports: import_v45.z.array(
670
+ import_v45.z.object({
671
+ segment: import_v45.z.object({
672
+ startIndex: import_v45.z.number().nullish(),
673
+ endIndex: import_v45.z.number().nullish(),
674
+ text: import_v45.z.string().nullish()
675
+ }),
676
+ segment_text: import_v45.z.string().nullish(),
677
+ groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
678
+ supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
679
+ confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
680
+ confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
681
+ })
682
+ ).nullish(),
683
+ retrievalMetadata: import_v45.z.union([
684
+ import_v45.z.object({
685
+ webDynamicRetrievalScore: import_v45.z.number()
686
+ }),
687
+ import_v45.z.object({})
688
+ ]).nullish()
689
+ });
690
+ var googleSearch = (0, import_provider_utils4.createProviderDefinedToolFactory)({
691
+ id: "google.google_search",
692
+ name: "google_search",
693
+ inputSchema: import_v45.z.object({
694
+ mode: import_v45.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
695
+ dynamicThreshold: import_v45.z.number().default(1)
696
+ })
697
+ });
698
+
699
+ // src/tool/url-context.ts
700
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
701
+ var import_v46 = require("zod/v4");
702
+ var urlMetadataSchema = import_v46.z.object({
703
+ retrievedUrl: import_v46.z.string(),
704
+ urlRetrievalStatus: import_v46.z.string()
705
+ });
706
+ var urlContextMetadataSchema = import_v46.z.object({
707
+ urlMetadata: import_v46.z.array(urlMetadataSchema)
708
+ });
709
+ var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
710
+ id: "google.url_context",
711
+ name: "url_context",
712
+ inputSchema: import_v46.z.object({})
713
+ });
714
+
715
+ // src/google-generative-ai-language-model.ts
716
+ var GoogleGenerativeAILanguageModel = class {
717
+ constructor(modelId, config) {
718
+ this.specificationVersion = "v2";
719
+ var _a;
720
+ this.modelId = modelId;
721
+ this.config = config;
722
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils6.generateId;
723
+ }
724
+ get provider() {
725
+ return this.config.provider;
726
+ }
727
+ get supportedUrls() {
728
+ var _a, _b, _c;
729
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
730
+ }
731
+ async getArgs({
732
+ prompt,
733
+ maxOutputTokens,
734
+ temperature,
735
+ topP,
736
+ topK,
737
+ frequencyPenalty,
738
+ presencePenalty,
739
+ stopSequences,
740
+ responseFormat,
741
+ seed,
742
+ tools,
743
+ toolChoice,
744
+ providerOptions
745
+ }) {
746
+ var _a, _b;
747
+ const warnings = [];
748
+ const googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
749
+ provider: "google",
750
+ providerOptions,
751
+ schema: googleGenerativeAIProviderOptions
752
+ });
753
+ if (((_a = googleOptions == null ? void 0 : googleOptions.thinkingConfig) == null ? void 0 : _a.includeThoughts) === true && !this.config.provider.startsWith("google.vertex.")) {
754
+ warnings.push({
755
+ type: "other",
756
+ message: `The 'includeThoughts' option is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
757
+ });
758
+ }
759
+ const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
760
+ const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
761
+ prompt,
762
+ { isGemmaModel }
763
+ );
764
+ const {
765
+ tools: googleTools2,
766
+ toolConfig: googleToolConfig,
767
+ toolWarnings
768
+ } = prepareTools({
769
+ tools,
770
+ toolChoice,
771
+ modelId: this.modelId
772
+ });
773
+ return {
774
+ args: {
775
+ generationConfig: {
776
+ // standardized settings:
777
+ maxOutputTokens,
778
+ temperature,
779
+ topK,
780
+ topP,
781
+ frequencyPenalty,
782
+ presencePenalty,
783
+ stopSequences,
784
+ seed,
785
+ // response format:
786
+ responseMimeType: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? "application/json" : void 0,
787
+ responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
788
+ // so this is needed as an escape hatch:
789
+ // TODO convert into provider option
790
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
791
+ ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
792
+ audioTimestamp: googleOptions.audioTimestamp
793
+ },
794
+ // provider options:
795
+ responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
796
+ thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
797
+ },
798
+ contents,
799
+ systemInstruction: isGemmaModel ? void 0 : systemInstruction,
800
+ safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
801
+ tools: googleTools2,
802
+ toolConfig: googleToolConfig,
803
+ cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
804
+ labels: googleOptions == null ? void 0 : googleOptions.labels
805
+ },
806
+ warnings: [...warnings, ...toolWarnings]
807
+ };
808
+ }
809
+ async doGenerate(options) {
810
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
811
+ const { args, warnings } = await this.getArgs(options);
812
+ const body = JSON.stringify(args);
813
+ const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
814
+ await (0, import_provider_utils6.resolve)(this.config.headers),
815
+ options.headers
816
+ );
817
+ const {
818
+ responseHeaders,
819
+ value: response,
820
+ rawValue: rawResponse
821
+ } = await (0, import_provider_utils6.postJsonToApi)({
822
+ url: `${this.config.baseURL}/${getModelPath(
823
+ this.modelId
824
+ )}:generateContent`,
825
+ headers: mergedHeaders,
826
+ body: args,
827
+ failedResponseHandler: googleFailedResponseHandler,
828
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(responseSchema),
829
+ abortSignal: options.abortSignal,
830
+ fetch: this.config.fetch
831
+ });
832
+ const candidate = response.candidates[0];
833
+ const content = [];
834
+ const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
835
+ const usageMetadata = response.usageMetadata;
836
+ let lastCodeExecutionToolCallId;
837
+ for (const part of parts) {
838
+ if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
839
+ const toolCallId = this.config.generateId();
840
+ lastCodeExecutionToolCallId = toolCallId;
841
+ content.push({
842
+ type: "tool-call",
843
+ toolCallId,
844
+ toolName: "code_execution",
845
+ input: JSON.stringify(part.executableCode),
846
+ providerExecuted: true
847
+ });
848
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
849
+ content.push({
850
+ type: "tool-result",
851
+ // Assumes a result directly follows its corresponding call part.
852
+ toolCallId: lastCodeExecutionToolCallId,
853
+ toolName: "code_execution",
854
+ result: {
855
+ outcome: part.codeExecutionResult.outcome,
856
+ output: part.codeExecutionResult.output
857
+ },
858
+ providerExecuted: true
859
+ });
860
+ lastCodeExecutionToolCallId = void 0;
861
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
862
+ content.push({
863
+ type: part.thought === true ? "reasoning" : "text",
864
+ text: part.text,
865
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
866
+ });
867
+ } else if ("functionCall" in part) {
868
+ content.push({
869
+ type: "tool-call",
870
+ toolCallId: this.config.generateId(),
871
+ toolName: part.functionCall.name,
872
+ input: JSON.stringify(part.functionCall.args),
873
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
874
+ });
875
+ } else if ("inlineData" in part) {
876
+ content.push({
877
+ type: "file",
878
+ data: part.inlineData.data,
879
+ mediaType: part.inlineData.mimeType
880
+ });
881
+ }
882
+ }
883
+ const sources = (_d = extractSources({
884
+ groundingMetadata: candidate.groundingMetadata,
885
+ generateId: this.config.generateId
886
+ })) != null ? _d : [];
887
+ for (const source of sources) {
888
+ content.push(source);
889
+ }
890
+ return {
891
+ content,
892
+ finishReason: mapGoogleGenerativeAIFinishReason({
893
+ finishReason: candidate.finishReason,
894
+ hasToolCalls: content.some((part) => part.type === "tool-call")
895
+ }),
896
+ usage: {
897
+ inputTokens: (_e = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _e : void 0,
898
+ outputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _f : void 0,
899
+ totalTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _g : void 0,
900
+ reasoningTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _h : void 0,
901
+ cachedInputTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _i : void 0
902
+ },
903
+ warnings,
904
+ providerMetadata: {
905
+ google: {
906
+ groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
907
+ urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
908
+ safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
909
+ usageMetadata: usageMetadata != null ? usageMetadata : null
910
+ }
911
+ },
912
+ request: { body },
913
+ response: {
914
+ // TODO timestamp, model id, id
915
+ headers: responseHeaders,
916
+ body: rawResponse
917
+ }
918
+ };
919
+ }
920
+ async doStream(options) {
921
+ const { args, warnings } = await this.getArgs(options);
922
+ const body = JSON.stringify(args);
923
+ const headers = (0, import_provider_utils6.combineHeaders)(
924
+ await (0, import_provider_utils6.resolve)(this.config.headers),
925
+ options.headers
926
+ );
927
+ const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
928
+ url: `${this.config.baseURL}/${getModelPath(
929
+ this.modelId
930
+ )}:streamGenerateContent?alt=sse`,
931
+ headers,
932
+ body: args,
933
+ failedResponseHandler: googleFailedResponseHandler,
934
+ successfulResponseHandler: (0, import_provider_utils6.createEventSourceResponseHandler)(chunkSchema),
935
+ abortSignal: options.abortSignal,
936
+ fetch: this.config.fetch
937
+ });
938
+ let finishReason = "unknown";
939
+ const usage = {
940
+ inputTokens: void 0,
941
+ outputTokens: void 0,
942
+ totalTokens: void 0
943
+ };
944
+ let providerMetadata = void 0;
945
+ const generateId3 = this.config.generateId;
946
+ let hasToolCalls = false;
947
+ let currentTextBlockId = null;
948
+ let currentReasoningBlockId = null;
949
+ let blockCounter = 0;
950
+ const emittedSourceUrls = /* @__PURE__ */ new Set();
951
+ let lastCodeExecutionToolCallId;
952
+ return {
953
+ stream: response.pipeThrough(
954
+ new TransformStream({
955
+ start(controller) {
956
+ controller.enqueue({ type: "stream-start", warnings });
957
+ },
958
+ transform(chunk, controller) {
959
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
960
+ if (options.includeRawChunks) {
961
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
962
+ }
963
+ if (!chunk.success) {
964
+ controller.enqueue({ type: "error", error: chunk.error });
965
+ return;
966
+ }
967
+ const value = chunk.value;
968
+ const usageMetadata = value.usageMetadata;
969
+ if (usageMetadata != null) {
970
+ usage.inputTokens = (_a = usageMetadata.promptTokenCount) != null ? _a : void 0;
971
+ usage.outputTokens = (_b = usageMetadata.candidatesTokenCount) != null ? _b : void 0;
972
+ usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
973
+ usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
974
+ usage.cachedInputTokens = (_e = usageMetadata.cachedContentTokenCount) != null ? _e : void 0;
975
+ }
976
+ const candidate = (_f = value.candidates) == null ? void 0 : _f[0];
977
+ if (candidate == null) {
978
+ return;
979
+ }
980
+ const content = candidate.content;
981
+ const sources = extractSources({
982
+ groundingMetadata: candidate.groundingMetadata,
983
+ generateId: generateId3
984
+ });
985
+ if (sources != null) {
986
+ for (const source of sources) {
987
+ if (source.sourceType === "url" && !emittedSourceUrls.has(source.url)) {
988
+ emittedSourceUrls.add(source.url);
989
+ controller.enqueue(source);
990
+ }
991
+ }
992
+ }
993
+ if (content != null) {
994
+ const parts = (_g = content.parts) != null ? _g : [];
995
+ for (const part of parts) {
996
+ if ("executableCode" in part && ((_h = part.executableCode) == null ? void 0 : _h.code)) {
997
+ const toolCallId = generateId3();
998
+ lastCodeExecutionToolCallId = toolCallId;
999
+ controller.enqueue({
1000
+ type: "tool-call",
1001
+ toolCallId,
1002
+ toolName: "code_execution",
1003
+ input: JSON.stringify(part.executableCode),
1004
+ providerExecuted: true
1005
+ });
1006
+ hasToolCalls = true;
1007
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1008
+ const toolCallId = lastCodeExecutionToolCallId;
1009
+ if (toolCallId) {
1010
+ controller.enqueue({
1011
+ type: "tool-result",
1012
+ toolCallId,
1013
+ toolName: "code_execution",
1014
+ result: {
1015
+ outcome: part.codeExecutionResult.outcome,
1016
+ output: part.codeExecutionResult.output
1017
+ },
1018
+ providerExecuted: true
1019
+ });
1020
+ lastCodeExecutionToolCallId = void 0;
1021
+ }
1022
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
1023
+ if (part.thought === true) {
1024
+ if (currentTextBlockId !== null) {
1025
+ controller.enqueue({
1026
+ type: "text-end",
1027
+ id: currentTextBlockId
1028
+ });
1029
+ currentTextBlockId = null;
1030
+ }
1031
+ if (currentReasoningBlockId === null) {
1032
+ currentReasoningBlockId = String(blockCounter++);
1033
+ controller.enqueue({
1034
+ type: "reasoning-start",
1035
+ id: currentReasoningBlockId,
1036
+ providerMetadata: part.thoughtSignature ? {
1037
+ google: {
1038
+ thoughtSignature: part.thoughtSignature
1039
+ }
1040
+ } : void 0
1041
+ });
1042
+ }
1043
+ controller.enqueue({
1044
+ type: "reasoning-delta",
1045
+ id: currentReasoningBlockId,
1046
+ delta: part.text,
1047
+ providerMetadata: part.thoughtSignature ? {
1048
+ google: { thoughtSignature: part.thoughtSignature }
1049
+ } : void 0
1050
+ });
1051
+ } else {
1052
+ if (currentReasoningBlockId !== null) {
1053
+ controller.enqueue({
1054
+ type: "reasoning-end",
1055
+ id: currentReasoningBlockId
1056
+ });
1057
+ currentReasoningBlockId = null;
1058
+ }
1059
+ if (currentTextBlockId === null) {
1060
+ currentTextBlockId = String(blockCounter++);
1061
+ controller.enqueue({
1062
+ type: "text-start",
1063
+ id: currentTextBlockId,
1064
+ providerMetadata: part.thoughtSignature ? {
1065
+ google: {
1066
+ thoughtSignature: part.thoughtSignature
1067
+ }
1068
+ } : void 0
1069
+ });
1070
+ }
1071
+ controller.enqueue({
1072
+ type: "text-delta",
1073
+ id: currentTextBlockId,
1074
+ delta: part.text,
1075
+ providerMetadata: part.thoughtSignature ? {
1076
+ google: { thoughtSignature: part.thoughtSignature }
1077
+ } : void 0
1078
+ });
1079
+ }
1080
+ }
1081
+ }
1082
+ const inlineDataParts = getInlineDataParts(content.parts);
1083
+ if (inlineDataParts != null) {
1084
+ for (const part of inlineDataParts) {
1085
+ controller.enqueue({
1086
+ type: "file",
1087
+ mediaType: part.inlineData.mimeType,
1088
+ data: part.inlineData.data
1089
+ });
1090
+ }
1091
+ }
1092
+ const toolCallDeltas = getToolCallsFromParts({
1093
+ parts: content.parts,
1094
+ generateId: generateId3
1095
+ });
1096
+ if (toolCallDeltas != null) {
1097
+ for (const toolCall of toolCallDeltas) {
1098
+ controller.enqueue({
1099
+ type: "tool-input-start",
1100
+ id: toolCall.toolCallId,
1101
+ toolName: toolCall.toolName,
1102
+ providerMetadata: toolCall.providerMetadata
1103
+ });
1104
+ controller.enqueue({
1105
+ type: "tool-input-delta",
1106
+ id: toolCall.toolCallId,
1107
+ delta: toolCall.args,
1108
+ providerMetadata: toolCall.providerMetadata
1109
+ });
1110
+ controller.enqueue({
1111
+ type: "tool-input-end",
1112
+ id: toolCall.toolCallId,
1113
+ providerMetadata: toolCall.providerMetadata
1114
+ });
1115
+ controller.enqueue({
1116
+ type: "tool-call",
1117
+ toolCallId: toolCall.toolCallId,
1118
+ toolName: toolCall.toolName,
1119
+ input: toolCall.args,
1120
+ providerMetadata: toolCall.providerMetadata
1121
+ });
1122
+ hasToolCalls = true;
1123
+ }
1124
+ }
1125
+ }
1126
+ if (candidate.finishReason != null) {
1127
+ finishReason = mapGoogleGenerativeAIFinishReason({
1128
+ finishReason: candidate.finishReason,
1129
+ hasToolCalls
1130
+ });
1131
+ providerMetadata = {
1132
+ google: {
1133
+ groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
1134
+ urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
1135
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
1136
+ }
1137
+ };
1138
+ if (usageMetadata != null) {
1139
+ providerMetadata.google.usageMetadata = usageMetadata;
1140
+ }
1141
+ }
1142
+ },
1143
+ flush(controller) {
1144
+ if (currentTextBlockId !== null) {
1145
+ controller.enqueue({
1146
+ type: "text-end",
1147
+ id: currentTextBlockId
1148
+ });
1149
+ }
1150
+ if (currentReasoningBlockId !== null) {
1151
+ controller.enqueue({
1152
+ type: "reasoning-end",
1153
+ id: currentReasoningBlockId
1154
+ });
1155
+ }
1156
+ controller.enqueue({
1157
+ type: "finish",
1158
+ finishReason,
1159
+ usage,
1160
+ providerMetadata
1161
+ });
1162
+ }
1163
+ })
1164
+ ),
1165
+ response: { headers: responseHeaders },
1166
+ request: { body }
1167
+ };
1168
+ }
1169
+ };
1170
+ function getToolCallsFromParts({
1171
+ parts,
1172
+ generateId: generateId3
1173
+ }) {
1174
+ const functionCallParts = parts == null ? void 0 : parts.filter(
1175
+ (part) => "functionCall" in part
1176
+ );
1177
+ return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1178
+ type: "tool-call",
1179
+ toolCallId: generateId3(),
1180
+ toolName: part.functionCall.name,
1181
+ args: JSON.stringify(part.functionCall.args),
1182
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1183
+ }));
1184
+ }
1185
+ function getInlineDataParts(parts) {
1186
+ return parts == null ? void 0 : parts.filter(
1187
+ (part) => "inlineData" in part
1188
+ );
1189
+ }
1190
+ function extractSources({
1191
+ groundingMetadata,
1192
+ generateId: generateId3
1193
+ }) {
1194
+ var _a;
1195
+ return (_a = groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks) == null ? void 0 : _a.filter(
1196
+ (chunk) => chunk.web != null
1197
+ ).map((chunk) => ({
1198
+ type: "source",
1199
+ sourceType: "url",
1200
+ id: generateId3(),
1201
+ url: chunk.web.uri,
1202
+ title: chunk.web.title
1203
+ }));
1204
+ }
1205
+ var contentSchema = import_v47.z.object({
1206
+ parts: import_v47.z.array(
1207
+ import_v47.z.union([
1208
+ // note: order matters since text can be fully empty
1209
+ import_v47.z.object({
1210
+ functionCall: import_v47.z.object({
1211
+ name: import_v47.z.string(),
1212
+ args: import_v47.z.unknown()
1213
+ }),
1214
+ thoughtSignature: import_v47.z.string().nullish()
1215
+ }),
1216
+ import_v47.z.object({
1217
+ inlineData: import_v47.z.object({
1218
+ mimeType: import_v47.z.string(),
1219
+ data: import_v47.z.string()
1220
+ })
1221
+ }),
1222
+ import_v47.z.object({
1223
+ executableCode: import_v47.z.object({
1224
+ language: import_v47.z.string(),
1225
+ code: import_v47.z.string()
1226
+ }).nullish(),
1227
+ codeExecutionResult: import_v47.z.object({
1228
+ outcome: import_v47.z.string(),
1229
+ output: import_v47.z.string()
1230
+ }).nullish(),
1231
+ text: import_v47.z.string().nullish(),
1232
+ thought: import_v47.z.boolean().nullish(),
1233
+ thoughtSignature: import_v47.z.string().nullish()
1234
+ })
1235
+ ])
1236
+ ).nullish()
1237
+ });
1238
+ var safetyRatingSchema = import_v47.z.object({
1239
+ category: import_v47.z.string().nullish(),
1240
+ probability: import_v47.z.string().nullish(),
1241
+ probabilityScore: import_v47.z.number().nullish(),
1242
+ severity: import_v47.z.string().nullish(),
1243
+ severityScore: import_v47.z.number().nullish(),
1244
+ blocked: import_v47.z.boolean().nullish()
1245
+ });
1246
+ var usageSchema = import_v47.z.object({
1247
+ cachedContentTokenCount: import_v47.z.number().nullish(),
1248
+ thoughtsTokenCount: import_v47.z.number().nullish(),
1249
+ promptTokenCount: import_v47.z.number().nullish(),
1250
+ candidatesTokenCount: import_v47.z.number().nullish(),
1251
+ totalTokenCount: import_v47.z.number().nullish()
1252
+ });
1253
+ var responseSchema = import_v47.z.object({
1254
+ candidates: import_v47.z.array(
1255
+ import_v47.z.object({
1256
+ content: contentSchema.nullish().or(import_v47.z.object({}).strict()),
1257
+ finishReason: import_v47.z.string().nullish(),
1258
+ safetyRatings: import_v47.z.array(safetyRatingSchema).nullish(),
1259
+ groundingMetadata: groundingMetadataSchema.nullish(),
1260
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1261
+ })
1262
+ ),
1263
+ usageMetadata: usageSchema.nullish()
1264
+ });
1265
+ var chunkSchema = import_v47.z.object({
1266
+ candidates: import_v47.z.array(
1267
+ import_v47.z.object({
1268
+ content: contentSchema.nullish(),
1269
+ finishReason: import_v47.z.string().nullish(),
1270
+ safetyRatings: import_v47.z.array(safetyRatingSchema).nullish(),
1271
+ groundingMetadata: groundingMetadataSchema.nullish(),
1272
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1273
+ })
1274
+ ).nullish(),
1275
+ usageMetadata: usageSchema.nullish()
1276
+ });
1277
+
1278
+ // src/tool/code-execution.ts
1279
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1280
+ var import_v48 = require("zod/v4");
1281
+ var codeExecution = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1282
+ id: "google.code_execution",
1283
+ name: "code_execution",
1284
+ inputSchema: import_v48.z.object({
1285
+ language: import_v48.z.string().describe("The programming language of the code."),
1286
+ code: import_v48.z.string().describe("The code to be executed.")
1287
+ }),
1288
+ outputSchema: import_v48.z.object({
1289
+ outcome: import_v48.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1290
+ output: import_v48.z.string().describe("The output from the code execution.")
1291
+ })
1292
+ });
1293
+
1294
+ // src/google-tools.ts
1295
+ var googleTools = {
1296
+ /**
1297
+ * Creates a Google search tool that gives Google direct access to real-time web content.
1298
+ * Must have name "google_search".
1299
+ */
1300
+ googleSearch,
1301
+ /**
1302
+ * Creates a URL context tool that gives Google direct access to real-time web content.
1303
+ * Must have name "url_context".
1304
+ */
1305
+ urlContext,
1306
+ /**
1307
+ * A tool that enables the model to generate and run Python code.
1308
+ * Must have name "code_execution".
1309
+ *
1310
+ * @note Ensure the selected model supports Code Execution.
1311
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
1312
+ *
1313
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
1314
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
1315
+ */
1316
+ codeExecution
1317
+ };
1318
+
1319
+ // src/google-generative-ai-image-model.ts
1320
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1321
+ var import_v49 = require("zod/v4");
1322
+ var GoogleGenerativeAIImageModel = class {
1323
+ constructor(modelId, settings, config) {
1324
+ this.modelId = modelId;
1325
+ this.settings = settings;
1326
+ this.config = config;
1327
+ this.specificationVersion = "v2";
1328
+ }
1329
+ get maxImagesPerCall() {
1330
+ var _a;
1331
+ return (_a = this.settings.maxImagesPerCall) != null ? _a : 4;
1332
+ }
1333
+ get provider() {
1334
+ return this.config.provider;
1335
+ }
1336
+ async doGenerate(options) {
1337
+ var _a, _b, _c;
1338
+ const {
1339
+ prompt,
1340
+ n = 1,
1341
+ size = "1024x1024",
1342
+ aspectRatio = "1:1",
1343
+ seed,
1344
+ providerOptions,
1345
+ headers,
1346
+ abortSignal
1347
+ } = options;
1348
+ const warnings = [];
1349
+ if (size != null) {
1350
+ warnings.push({
1351
+ type: "unsupported-setting",
1352
+ setting: "size",
1353
+ details: "This model does not support the `size` option. Use `aspectRatio` instead."
1354
+ });
1355
+ }
1356
+ if (seed != null) {
1357
+ warnings.push({
1358
+ type: "unsupported-setting",
1359
+ setting: "seed",
1360
+ details: "This model does not support the `seed` option through this provider."
1361
+ });
1362
+ }
1363
+ const googleOptions = await (0, import_provider_utils8.parseProviderOptions)({
1364
+ provider: "google",
1365
+ providerOptions,
1366
+ schema: googleImageProviderOptionsSchema
1367
+ });
1368
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1369
+ const parameters = {
1370
+ sampleCount: n
1371
+ };
1372
+ if (aspectRatio != null) {
1373
+ parameters.aspectRatio = aspectRatio;
1374
+ }
1375
+ if (googleOptions) {
1376
+ Object.assign(parameters, googleOptions);
1377
+ }
1378
+ const body = {
1379
+ instances: [{ prompt }],
1380
+ parameters
1381
+ };
1382
+ const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
1383
+ url: `${this.config.baseURL}/models/${this.modelId}:predict`,
1384
+ headers: (0, import_provider_utils8.combineHeaders)(await (0, import_provider_utils8.resolve)(this.config.headers), headers),
1385
+ body,
1386
+ failedResponseHandler: googleFailedResponseHandler,
1387
+ successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1388
+ googleImageResponseSchema
1389
+ ),
1390
+ abortSignal,
1391
+ fetch: this.config.fetch
1392
+ });
1393
+ return {
1394
+ images: response.predictions.map(
1395
+ (p) => p.bytesBase64Encoded
1396
+ ),
1397
+ warnings: warnings != null ? warnings : [],
1398
+ providerMetadata: {
1399
+ google: {
1400
+ images: response.predictions.map((prediction) => ({
1401
+ // Add any prediction-specific metadata here
1402
+ }))
1403
+ }
1404
+ },
1405
+ response: {
1406
+ timestamp: currentDate,
1407
+ modelId: this.modelId,
1408
+ headers: responseHeaders
1409
+ }
1410
+ };
1411
+ }
1412
+ };
1413
+ var googleImageResponseSchema = import_v49.z.object({
1414
+ predictions: import_v49.z.array(import_v49.z.object({ bytesBase64Encoded: import_v49.z.string() })).default([])
1415
+ });
1416
+ var googleImageProviderOptionsSchema = import_v49.z.object({
1417
+ personGeneration: import_v49.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1418
+ aspectRatio: import_v49.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1419
+ });
1420
+
1421
+ // src/google-provider.ts
1422
+ function createGoogleGenerativeAI(options = {}) {
1423
+ var _a;
1424
+ const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1425
+ const getHeaders = () => ({
1426
+ "x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
1427
+ apiKey: options.apiKey,
1428
+ environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1429
+ description: "Google Generative AI"
1430
+ }),
1431
+ ...options.headers
1432
+ });
1433
+ const createChatModel = (modelId) => {
1434
+ var _a2;
1435
+ return new GoogleGenerativeAILanguageModel(modelId, {
1436
+ provider: "google.generative-ai",
1437
+ baseURL,
1438
+ headers: getHeaders,
1439
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils9.generateId,
1440
+ supportedUrls: () => ({
1441
+ "*": [
1442
+ // Google Generative Language "files" endpoint
1443
+ // e.g. https://generativelanguage.googleapis.com/v1beta/files/...
1444
+ new RegExp(`^${baseURL}/files/.*$`),
1445
+ // YouTube URLs (public or unlisted videos)
1446
+ new RegExp(
1447
+ `^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
1448
+ ),
1449
+ new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
1450
+ ]
1451
+ }),
1452
+ fetch: options.fetch
1453
+ });
1454
+ };
1455
+ const createEmbeddingModel = (modelId) => new GoogleGenerativeAIEmbeddingModel(modelId, {
1456
+ provider: "google.generative-ai",
1457
+ baseURL,
1458
+ headers: getHeaders,
1459
+ fetch: options.fetch
1460
+ });
1461
+ const createImageModel = (modelId, settings = {}) => new GoogleGenerativeAIImageModel(modelId, settings, {
1462
+ provider: "google.generative-ai",
1463
+ baseURL,
1464
+ headers: getHeaders,
1465
+ fetch: options.fetch
1466
+ });
1467
+ const provider = function(modelId) {
1468
+ if (new.target) {
1469
+ throw new Error(
1470
+ "The Google Generative AI model function cannot be called with the new keyword."
1471
+ );
1472
+ }
1473
+ return createChatModel(modelId);
1474
+ };
1475
+ provider.languageModel = createChatModel;
1476
+ provider.chat = createChatModel;
1477
+ provider.generativeAI = createChatModel;
1478
+ provider.embedding = createEmbeddingModel;
1479
+ provider.textEmbedding = createEmbeddingModel;
1480
+ provider.textEmbeddingModel = createEmbeddingModel;
1481
+ provider.image = createImageModel;
1482
+ provider.imageModel = createImageModel;
1483
+ provider.tools = googleTools;
1484
+ return provider;
1485
+ }
1486
+ var google = createGoogleGenerativeAI();
1487
+ // Annotate the CommonJS export names for ESM import in node:
1488
+ 0 && (module.exports = {
1489
+ createGoogleGenerativeAI,
1490
+ google
1491
+ });
1492
+ //# sourceMappingURL=index.js.map
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../src/index.ts","../src/google-provider.ts","../src/google-generative-ai-embedding-model.ts","../src/google-error.ts","../src/google-generative-ai-embedding-options.ts","../src/google-generative-ai-language-model.ts","../src/convert-json-schema-to-openapi-schema.ts","../src/convert-to-google-generative-ai-messages.ts","../src/get-model-path.ts","../src/google-generative-ai-options.ts","../src/google-prepare-tools.ts","../src/map-google-generative-ai-finish-reason.ts","../src/tool/google-search.ts","../src/tool/url-context.ts","../src/tool/code-execution.ts","../src/google-tools.ts","../src/google-generative-ai-image-model.ts"],"sourcesContent":["export type { GoogleErrorData } from './google-error';\nexport type { GoogleGenerativeAIProviderOptions } from './google-generative-ai-options';\nexport type { GoogleGenerativeAIProviderMetadata } from './google-generative-ai-prompt';\nexport type { GoogleGenerativeAIImageProviderOptions } from './google-generative-ai-image-model';\nexport type { GoogleGenerativeAIEmbeddingProviderOptions } from './google-generative-ai-embedding-options';\nexport { createGoogleGenerativeAI, google } from './google-provider';\nexport type {\n GoogleGenerativeAIProvider,\n GoogleGenerativeAIProviderSettings,\n} from './google-provider';\n","import {\n EmbeddingModelV2,\n LanguageModelV2,\n ProviderV2,\n ImageModelV2,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n generateId,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { GoogleGenerativeAIEmbeddingModel } from './google-generative-ai-embedding-model';\nimport { GoogleGenerativeAIEmbeddingModelId } from './google-generative-ai-embedding-options';\nimport { GoogleGenerativeAILanguageModel } from './google-generative-ai-language-model';\nimport { GoogleGenerativeAIModelId } from './google-generative-ai-options';\nimport { googleTools } from './google-tools';\n\nimport {\n GoogleGenerativeAIImageSettings,\n GoogleGenerativeAIImageModelId,\n} from './google-generative-ai-image-settings';\nimport { GoogleGenerativeAIImageModel } from './google-generative-ai-image-model';\n\nexport interface GoogleGenerativeAIProvider extends ProviderV2 {\n (modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n chat(modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n /**\nCreates a model for image generation.\n */\n image(\n modelId: GoogleGenerativeAIImageModelId,\n settings?: GoogleGenerativeAIImageSettings,\n ): ImageModelV2;\n\n /**\n * @deprecated Use `chat()` instead.\n */\n generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n /**\n@deprecated Use `textEmbedding()` instead.\n */\n embedding(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n\n textEmbedding(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n\n textEmbeddingModel(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n\n tools: typeof googleTools;\n}\n\nexport interface GoogleGenerativeAIProviderSettings {\n /**\nUse a different URL prefix for API calls, e.g. to use proxy servers.\nThe default prefix is `https://generativelanguage.googleapis.com/v1beta`.\n */\n baseURL?: string;\n\n /**\nAPI key that is being send using the `x-goog-api-key` header.\nIt defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.\n */\n apiKey?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Record<string, string | undefined>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\nOptional function to generate a unique ID for each request.\n */\n generateId?: () => string;\n}\n\n/**\nCreate a Google Generative AI provider instance.\n */\nexport function createGoogleGenerativeAI(\n options: GoogleGenerativeAIProviderSettings = {},\n): GoogleGenerativeAIProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL) ??\n 'https://generativelanguage.googleapis.com/v1beta';\n\n const getHeaders = () => ({\n 'x-goog-api-key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'GOOGLE_GENERATIVE_AI_API_KEY',\n description: 'Google Generative AI',\n }),\n ...options.headers,\n });\n\n const createChatModel = (modelId: GoogleGenerativeAIModelId) =>\n new GoogleGenerativeAILanguageModel(modelId, {\n provider: 'google.generative-ai',\n baseURL,\n headers: getHeaders,\n generateId: options.generateId ?? generateId,\n supportedUrls: () => ({\n '*': [\n // Google Generative Language \"files\" endpoint\n // e.g. https://generativelanguage.googleapis.com/v1beta/files/...\n new RegExp(`^${baseURL}/files/.*$`),\n // YouTube URLs (public or unlisted videos)\n new RegExp(\n `^https://(?:www\\\\.)?youtube\\\\.com/watch\\\\?v=[\\\\w-]+(?:&[\\\\w=&.-]*)?$`,\n ),\n new RegExp(`^https://youtu\\\\.be/[\\\\w-]+(?:\\\\?[\\\\w=&.-]*)?$`),\n ],\n }),\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (modelId: GoogleGenerativeAIEmbeddingModelId) =>\n new GoogleGenerativeAIEmbeddingModel(modelId, {\n provider: 'google.generative-ai',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createImageModel = (\n modelId: GoogleGenerativeAIImageModelId,\n settings: GoogleGenerativeAIImageSettings = {},\n ) =>\n new GoogleGenerativeAIImageModel(modelId, settings, {\n provider: 'google.generative-ai',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: GoogleGenerativeAIModelId) {\n if (new.target) {\n throw new Error(\n 'The Google Generative AI model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.generativeAI = createChatModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.tools = googleTools;\n return provider as GoogleGenerativeAIProvider;\n}\n\n/**\nDefault Google Generative AI provider instance.\n */\nexport const google = createGoogleGenerativeAI();\n","import {\n EmbeddingModelV2,\n TooManyEmbeddingValuesForCallError,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n FetchFunction,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { googleFailedResponseHandler } from './google-error';\nimport {\n GoogleGenerativeAIEmbeddingModelId,\n googleGenerativeAIEmbeddingProviderOptions,\n} from './google-generative-ai-embedding-options';\n\ntype GoogleGenerativeAIEmbeddingConfig = {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n};\n\nexport class GoogleGenerativeAIEmbeddingModel\n implements EmbeddingModelV2<string>\n{\n readonly specificationVersion = 'v2';\n readonly modelId: GoogleGenerativeAIEmbeddingModelId;\n readonly maxEmbeddingsPerCall = 2048;\n readonly supportsParallelCalls = true;\n\n private readonly config: GoogleGenerativeAIEmbeddingConfig;\n\n get provider(): string {\n return this.config.provider;\n }\n constructor(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n config: GoogleGenerativeAIEmbeddingConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n }\n\n async doEmbed({\n values,\n headers,\n abortSignal,\n providerOptions,\n }: Parameters<EmbeddingModelV2<string>['doEmbed']>[0]): Promise<\n Awaited<ReturnType<EmbeddingModelV2<string>['doEmbed']>>\n > {\n // Parse provider options\n const googleOptions = await parseProviderOptions({\n provider: 'google',\n providerOptions,\n schema: googleGenerativeAIEmbeddingProviderOptions,\n });\n\n if (values.length > this.maxEmbeddingsPerCall) {\n throw new TooManyEmbeddingValuesForCallError({\n provider: this.provider,\n modelId: this.modelId,\n maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,\n values,\n });\n }\n\n const mergedHeaders = combineHeaders(\n await resolve(this.config.headers),\n headers,\n );\n\n // For single embeddings, use the single endpoint (ratelimits, etc.)\n if (values.length === 1) {\n const {\n responseHeaders,\n value: response,\n rawValue,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,\n headers: mergedHeaders,\n body: {\n model: `models/${this.modelId}`,\n content: {\n parts: [{ text: values[0] }],\n },\n outputDimensionality: googleOptions?.outputDimensionality,\n taskType: googleOptions?.taskType,\n },\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n googleGenerativeAISingleEmbeddingResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n embeddings: [response.embedding.values],\n usage: undefined,\n response: { headers: responseHeaders, body: rawValue },\n };\n }\n\n const {\n responseHeaders,\n value: response,\n rawValue,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,\n headers: mergedHeaders,\n body: {\n requests: values.map(value => ({\n model: `models/${this.modelId}`,\n content: { role: 'user', parts: [{ text: value }] },\n outputDimensionality: googleOptions?.outputDimensionality,\n taskType: googleOptions?.taskType,\n })),\n },\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n googleGenerativeAITextEmbeddingResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n embeddings: response.embeddings.map(item => item.values),\n usage: undefined,\n response: { headers: responseHeaders, body: rawValue },\n };\n }\n}\n\n// minimal version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst googleGenerativeAITextEmbeddingResponseSchema = z.object({\n embeddings: z.array(z.object({ values: z.array(z.number()) })),\n});\n\n// Schema for single embedding response\nconst googleGenerativeAISingleEmbeddingResponseSchema = z.object({\n embedding: z.object({ values: z.array(z.number()) }),\n});\n","import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst googleErrorDataSchema = z.object({\n error: z.object({\n code: z.number().nullable(),\n message: z.string(),\n status: z.string(),\n }),\n});\n\nexport type GoogleErrorData = z.infer<typeof googleErrorDataSchema>;\n\nexport const googleFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: googleErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import { z } from 'zod/v4';\n\nexport type GoogleGenerativeAIEmbeddingModelId =\n | 'gemini-embedding-001'\n | 'text-embedding-004'\n | (string & {});\n\nexport const googleGenerativeAIEmbeddingProviderOptions = z.object({\n /**\n * Optional. Optional reduced dimension for the output embedding.\n * If set, excessive values in the output embedding are truncated from the end.\n */\n outputDimensionality: z.number().optional(),\n\n /**\n * Optional. Specifies the task type for generating embeddings.\n * Supported task types:\n * - SEMANTIC_SIMILARITY: Optimized for text similarity.\n * - CLASSIFICATION: Optimized for text classification.\n * - CLUSTERING: Optimized for clustering texts based on similarity.\n * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.\n * - RETRIEVAL_QUERY: Optimized for query-based retrieval.\n * - QUESTION_ANSWERING: Optimized for answering questions.\n * - FACT_VERIFICATION: Optimized for verifying factual information.\n * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.\n */\n taskType: z\n .enum([\n 'SEMANTIC_SIMILARITY',\n 'CLASSIFICATION',\n 'CLUSTERING',\n 'RETRIEVAL_DOCUMENT',\n 'RETRIEVAL_QUERY',\n 'QUESTION_ANSWERING',\n 'FACT_VERIFICATION',\n 'CODE_RETRIEVAL_QUERY',\n ])\n .optional(),\n});\n\nexport type GoogleGenerativeAIEmbeddingProviderOptions = z.infer<\n typeof googleGenerativeAIEmbeddingProviderOptions\n>;\n","import {\n LanguageModelV2,\n LanguageModelV2CallWarning,\n LanguageModelV2Content,\n LanguageModelV2FinishReason,\n LanguageModelV2Source,\n LanguageModelV2StreamPart,\n LanguageModelV2Usage,\n SharedV2ProviderMetadata,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n ParseResult,\n Resolvable,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n generateId,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';\nimport { convertToGoogleGenerativeAIMessages } from './convert-to-google-generative-ai-messages';\nimport { getModelPath } from './get-model-path';\nimport { googleFailedResponseHandler } from './google-error';\nimport { GoogleGenerativeAIContentPart } from './google-generative-ai-prompt';\nimport {\n GoogleGenerativeAIModelId,\n googleGenerativeAIProviderOptions,\n} from './google-generative-ai-options';\nimport { prepareTools } from './google-prepare-tools';\nimport { mapGoogleGenerativeAIFinishReason } from './map-google-generative-ai-finish-reason';\nimport {\n groundingChunkSchema,\n groundingMetadataSchema,\n} from './tool/google-search';\nimport { urlContextMetadataSchema } from './tool/url-context';\n\ntype GoogleGenerativeAIConfig = {\n provider: string;\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n generateId: () => string;\n\n /**\n * The supported URLs for the model.\n */\n supportedUrls?: () => LanguageModelV2['supportedUrls'];\n};\n\nexport class GoogleGenerativeAILanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n\n readonly modelId: GoogleGenerativeAIModelId;\n\n private readonly config: GoogleGenerativeAIConfig;\n private readonly generateId: () => string;\n\n constructor(\n modelId: GoogleGenerativeAIModelId,\n config: GoogleGenerativeAIConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n this.generateId = config.generateId ?? generateId;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n get supportedUrls() {\n return this.config.supportedUrls?.() ?? {};\n }\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n responseFormat,\n seed,\n tools,\n toolChoice,\n providerOptions,\n }: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const warnings: LanguageModelV2CallWarning[] = [];\n\n const googleOptions = await parseProviderOptions({\n provider: 'google',\n providerOptions,\n schema: googleGenerativeAIProviderOptions,\n });\n\n // Add warning if includeThoughts is used with a non-Vertex Google provider\n if (\n googleOptions?.thinkingConfig?.includeThoughts === true &&\n !this.config.provider.startsWith('google.vertex.')\n ) {\n warnings.push({\n type: 'other',\n message:\n \"The 'includeThoughts' option is only supported with the Google Vertex provider \" +\n 'and might not be supported or could behave unexpectedly with the current Google provider ' +\n `(${this.config.provider}).`,\n });\n }\n\n const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');\n\n const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(\n prompt,\n { isGemmaModel },\n );\n\n const {\n tools: googleTools,\n toolConfig: googleToolConfig,\n toolWarnings,\n } = prepareTools({\n tools,\n toolChoice,\n modelId: this.modelId,\n });\n\n return {\n args: {\n generationConfig: {\n // standardized settings:\n maxOutputTokens,\n temperature,\n topK,\n topP,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n seed,\n\n // response format:\n responseMimeType:\n responseFormat?.type === 'json' ? 'application/json' : undefined,\n responseSchema:\n responseFormat?.type === 'json' &&\n responseFormat.schema != null &&\n // Google GenAI does not support all OpenAPI Schema features,\n // so this is needed as an escape hatch:\n // TODO convert into provider option\n (googleOptions?.structuredOutputs ?? true)\n ? convertJSONSchemaToOpenAPISchema(responseFormat.schema)\n : undefined,\n ...(googleOptions?.audioTimestamp && {\n audioTimestamp: googleOptions.audioTimestamp,\n }),\n\n // provider options:\n responseModalities: googleOptions?.responseModalities,\n thinkingConfig: googleOptions?.thinkingConfig,\n },\n contents,\n systemInstruction: isGemmaModel ? undefined : systemInstruction,\n safetySettings: googleOptions?.safetySettings,\n tools: googleTools,\n toolConfig: googleToolConfig,\n cachedContent: googleOptions?.cachedContent,\n labels: googleOptions?.labels,\n },\n warnings: [...warnings, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings } = await this.getArgs(options);\n const body = JSON.stringify(args);\n\n const mergedHeaders = combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n );\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/${getModelPath(\n this.modelId,\n )}:generateContent`,\n headers: mergedHeaders,\n body: args,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(responseSchema),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const candidate = response.candidates[0];\n const content: Array<LanguageModelV2Content> = [];\n\n // map ordered parts to content:\n const parts = candidate.content?.parts ?? [];\n\n const usageMetadata = response.usageMetadata;\n\n // Associates a code execution result with its preceding call.\n let lastCodeExecutionToolCallId: string | undefined;\n\n // Build content array from all parts\n for (const part of parts) {\n if ('executableCode' in part && part.executableCode?.code) {\n const toolCallId = this.config.generateId();\n lastCodeExecutionToolCallId = toolCallId;\n\n content.push({\n type: 'tool-call',\n toolCallId,\n toolName: 'code_execution',\n input: JSON.stringify(part.executableCode),\n providerExecuted: true,\n });\n } else if ('codeExecutionResult' in part && part.codeExecutionResult) {\n content.push({\n type: 'tool-result',\n // Assumes a result directly follows its corresponding call part.\n toolCallId: lastCodeExecutionToolCallId!,\n toolName: 'code_execution',\n result: {\n outcome: part.codeExecutionResult.outcome,\n output: part.codeExecutionResult.output,\n },\n providerExecuted: true,\n });\n // Clear the ID after use to avoid accidental reuse.\n lastCodeExecutionToolCallId = undefined;\n } else if ('text' in part && part.text != null && part.text.length > 0) {\n content.push({\n type: part.thought === true ? 'reasoning' : 'text',\n text: part.text,\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n });\n } else if ('functionCall' in part) {\n content.push({\n type: 'tool-call' as const,\n toolCallId: this.config.generateId(),\n toolName: part.functionCall.name,\n input: JSON.stringify(part.functionCall.args),\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n });\n } else if ('inlineData' in part) {\n content.push({\n type: 'file' as const,\n data: part.inlineData.data,\n mediaType: part.inlineData.mimeType,\n });\n }\n }\n\n const sources =\n extractSources({\n groundingMetadata: candidate.groundingMetadata,\n generateId: this.config.generateId,\n }) ?? [];\n for (const source of sources) {\n content.push(source);\n }\n\n return {\n content,\n finishReason: mapGoogleGenerativeAIFinishReason({\n finishReason: candidate.finishReason,\n hasToolCalls: content.some(part => part.type === 'tool-call'),\n }),\n usage: {\n inputTokens: usageMetadata?.promptTokenCount ?? undefined,\n outputTokens: usageMetadata?.candidatesTokenCount ?? undefined,\n totalTokens: usageMetadata?.totalTokenCount ?? undefined,\n reasoningTokens: usageMetadata?.thoughtsTokenCount ?? undefined,\n cachedInputTokens: usageMetadata?.cachedContentTokenCount ?? undefined,\n },\n warnings,\n providerMetadata: {\n google: {\n groundingMetadata: candidate.groundingMetadata ?? null,\n urlContextMetadata: candidate.urlContextMetadata ?? null,\n safetyRatings: candidate.safetyRatings ?? null,\n usageMetadata: usageMetadata ?? null,\n },\n },\n request: { body },\n response: {\n // TODO timestamp, model id, id\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings } = await this.getArgs(options);\n\n const body = JSON.stringify(args);\n const headers = combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n );\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: `${this.config.baseURL}/${getModelPath(\n this.modelId,\n )}:streamGenerateContent?alt=sse`,\n headers,\n body: args,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let finishReason: LanguageModelV2FinishReason = 'unknown';\n const usage: LanguageModelV2Usage = {\n inputTokens: undefined,\n outputTokens: undefined,\n totalTokens: undefined,\n };\n let providerMetadata: SharedV2ProviderMetadata | undefined = undefined;\n\n const generateId = this.config.generateId;\n let hasToolCalls = false;\n\n // Track active blocks to group consecutive parts of same type\n let currentTextBlockId: string | null = null;\n let currentReasoningBlockId: string | null = null;\n let blockCounter = 0;\n\n // Track emitted sources to prevent duplicates\n const emittedSourceUrls = new Set<string>();\n // Associates a code execution result with its preceding call.\n let lastCodeExecutionToolCallId: string | undefined;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<z.infer<typeof chunkSchema>>,\n LanguageModelV2StreamPart\n >({\n start(controller) {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value;\n\n const usageMetadata = value.usageMetadata;\n\n if (usageMetadata != null) {\n usage.inputTokens = usageMetadata.promptTokenCount ?? undefined;\n usage.outputTokens =\n usageMetadata.candidatesTokenCount ?? undefined;\n usage.totalTokens = usageMetadata.totalTokenCount ?? undefined;\n usage.reasoningTokens =\n usageMetadata.thoughtsTokenCount ?? undefined;\n usage.cachedInputTokens =\n usageMetadata.cachedContentTokenCount ?? undefined;\n }\n\n const candidate = value.candidates?.[0];\n\n // sometimes the API returns an empty candidates array\n if (candidate == null) {\n return;\n }\n\n const content = candidate.content;\n\n const sources = extractSources({\n groundingMetadata: candidate.groundingMetadata,\n generateId,\n });\n if (sources != null) {\n for (const source of sources) {\n if (\n source.sourceType === 'url' &&\n !emittedSourceUrls.has(source.url)\n ) {\n emittedSourceUrls.add(source.url);\n controller.enqueue(source);\n }\n }\n }\n\n // Process tool call's parts before determining finishReason to ensure hasToolCalls is properly set\n if (content != null) {\n // Process text parts individually to handle reasoning parts\n const parts = content.parts ?? [];\n for (const part of parts) {\n if ('executableCode' in part && part.executableCode?.code) {\n const toolCallId = generateId();\n lastCodeExecutionToolCallId = toolCallId;\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId,\n toolName: 'code_execution',\n input: JSON.stringify(part.executableCode),\n providerExecuted: true,\n });\n\n hasToolCalls = true;\n } else if (\n 'codeExecutionResult' in part &&\n part.codeExecutionResult\n ) {\n // Assumes a result directly follows its corresponding call part.\n const toolCallId = lastCodeExecutionToolCallId;\n\n if (toolCallId) {\n controller.enqueue({\n type: 'tool-result',\n toolCallId,\n toolName: 'code_execution',\n result: {\n outcome: part.codeExecutionResult.outcome,\n output: part.codeExecutionResult.output,\n },\n providerExecuted: true,\n });\n // Clear the ID after use.\n lastCodeExecutionToolCallId = undefined;\n }\n } else if (\n 'text' in part &&\n part.text != null &&\n part.text.length > 0\n ) {\n if (part.thought === true) {\n // End any active text block before starting reasoning\n if (currentTextBlockId !== null) {\n controller.enqueue({\n type: 'text-end',\n id: currentTextBlockId,\n });\n currentTextBlockId = null;\n }\n\n // Start new reasoning block if not already active\n if (currentReasoningBlockId === null) {\n currentReasoningBlockId = String(blockCounter++);\n controller.enqueue({\n type: 'reasoning-start',\n id: currentReasoningBlockId,\n providerMetadata: part.thoughtSignature\n ? {\n google: {\n thoughtSignature: part.thoughtSignature,\n },\n }\n : undefined,\n });\n }\n\n controller.enqueue({\n type: 'reasoning-delta',\n id: currentReasoningBlockId,\n delta: part.text,\n providerMetadata: part.thoughtSignature\n ? {\n google: { thoughtSignature: part.thoughtSignature },\n }\n : undefined,\n });\n } else {\n // End any active reasoning block before starting text\n if (currentReasoningBlockId !== null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: currentReasoningBlockId,\n });\n currentReasoningBlockId = null;\n }\n\n // Start new text block if not already active\n if (currentTextBlockId === null) {\n currentTextBlockId = String(blockCounter++);\n controller.enqueue({\n type: 'text-start',\n id: currentTextBlockId,\n providerMetadata: part.thoughtSignature\n ? {\n google: {\n thoughtSignature: part.thoughtSignature,\n },\n }\n : undefined,\n });\n }\n\n controller.enqueue({\n type: 'text-delta',\n id: currentTextBlockId,\n delta: part.text,\n providerMetadata: part.thoughtSignature\n ? {\n google: { thoughtSignature: part.thoughtSignature },\n }\n : undefined,\n });\n }\n }\n }\n\n const inlineDataParts = getInlineDataParts(content.parts);\n if (inlineDataParts != null) {\n for (const part of inlineDataParts) {\n controller.enqueue({\n type: 'file',\n mediaType: part.inlineData.mimeType,\n data: part.inlineData.data,\n });\n }\n }\n\n const toolCallDeltas = getToolCallsFromParts({\n parts: content.parts,\n generateId,\n });\n\n if (toolCallDeltas != null) {\n for (const toolCall of toolCallDeltas) {\n controller.enqueue({\n type: 'tool-input-start',\n id: toolCall.toolCallId,\n toolName: toolCall.toolName,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-input-delta',\n id: toolCall.toolCallId,\n delta: toolCall.args,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-input-end',\n id: toolCall.toolCallId,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId: toolCall.toolCallId,\n toolName: toolCall.toolName,\n input: toolCall.args,\n providerMetadata: toolCall.providerMetadata,\n });\n\n hasToolCalls = true;\n }\n }\n }\n\n if (candidate.finishReason != null) {\n finishReason = mapGoogleGenerativeAIFinishReason({\n finishReason: candidate.finishReason,\n hasToolCalls,\n });\n\n providerMetadata = {\n google: {\n groundingMetadata: candidate.groundingMetadata ?? null,\n urlContextMetadata: candidate.urlContextMetadata ?? null,\n safetyRatings: candidate.safetyRatings ?? null,\n },\n };\n if (usageMetadata != null) {\n providerMetadata.google.usageMetadata = usageMetadata;\n }\n }\n },\n\n flush(controller) {\n // Close any open blocks before finishing\n if (currentTextBlockId !== null) {\n controller.enqueue({\n type: 'text-end',\n id: currentTextBlockId,\n });\n }\n if (currentReasoningBlockId !== null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: currentReasoningBlockId,\n });\n }\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage,\n providerMetadata,\n });\n },\n }),\n ),\n response: { headers: responseHeaders },\n request: { body },\n };\n }\n}\n\nfunction getToolCallsFromParts({\n parts,\n generateId,\n}: {\n parts: z.infer<typeof contentSchema>['parts'];\n generateId: () => string;\n}) {\n const functionCallParts = parts?.filter(\n part => 'functionCall' in part,\n ) as Array<\n GoogleGenerativeAIContentPart & {\n functionCall: { name: string; args: unknown };\n thoughtSignature?: string | null;\n }\n >;\n\n return functionCallParts == null || functionCallParts.length === 0\n ? undefined\n : functionCallParts.map(part => ({\n type: 'tool-call' as const,\n toolCallId: generateId(),\n toolName: part.functionCall.name,\n args: JSON.stringify(part.functionCall.args),\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n }));\n}\n\nfunction getInlineDataParts(parts: z.infer<typeof contentSchema>['parts']) {\n return parts?.filter(\n (\n part,\n ): part is {\n inlineData: { mimeType: string; data: string };\n } => 'inlineData' in part,\n );\n}\n\nfunction extractSources({\n groundingMetadata,\n generateId,\n}: {\n groundingMetadata: z.infer<typeof groundingMetadataSchema> | undefined | null;\n generateId: () => string;\n}): undefined | LanguageModelV2Source[] {\n return groundingMetadata?.groundingChunks\n ?.filter(\n (\n chunk,\n ): chunk is z.infer<typeof groundingChunkSchema> & {\n web: { uri: string; title?: string };\n } => chunk.web != null,\n )\n .map(chunk => ({\n type: 'source',\n sourceType: 'url',\n id: generateId(),\n url: chunk.web.uri,\n title: chunk.web.title,\n }));\n}\n\nconst contentSchema = z.object({\n parts: z\n .array(\n z.union([\n // note: order matters since text can be fully empty\n z.object({\n functionCall: z.object({\n name: z.string(),\n args: z.unknown(),\n }),\n thoughtSignature: z.string().nullish(),\n }),\n z.object({\n inlineData: z.object({\n mimeType: z.string(),\n data: z.string(),\n }),\n }),\n z.object({\n executableCode: z\n .object({\n language: z.string(),\n code: z.string(),\n })\n .nullish(),\n codeExecutionResult: z\n .object({\n outcome: z.string(),\n output: z.string(),\n })\n .nullish(),\n text: z.string().nullish(),\n thought: z.boolean().nullish(),\n thoughtSignature: z.string().nullish(),\n }),\n ]),\n )\n .nullish(),\n});\n\n// https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters\nexport const safetyRatingSchema = z.object({\n category: z.string().nullish(),\n probability: z.string().nullish(),\n probabilityScore: z.number().nullish(),\n severity: z.string().nullish(),\n severityScore: z.number().nullish(),\n blocked: z.boolean().nullish(),\n});\n\nconst usageSchema = z.object({\n cachedContentTokenCount: z.number().nullish(),\n thoughtsTokenCount: z.number().nullish(),\n promptTokenCount: z.number().nullish(),\n candidatesTokenCount: z.number().nullish(),\n totalTokenCount: z.number().nullish(),\n});\n\nconst responseSchema = z.object({\n candidates: z.array(\n z.object({\n content: contentSchema.nullish().or(z.object({}).strict()),\n finishReason: z.string().nullish(),\n safetyRatings: z.array(safetyRatingSchema).nullish(),\n groundingMetadata: groundingMetadataSchema.nullish(),\n urlContextMetadata: urlContextMetadataSchema.nullish(),\n }),\n ),\n usageMetadata: usageSchema.nullish(),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst chunkSchema = z.object({\n candidates: z\n .array(\n z.object({\n content: contentSchema.nullish(),\n finishReason: z.string().nullish(),\n safetyRatings: z.array(safetyRatingSchema).nullish(),\n groundingMetadata: groundingMetadataSchema.nullish(),\n urlContextMetadata: urlContextMetadataSchema.nullish(),\n }),\n )\n .nullish(),\n usageMetadata: usageSchema.nullish(),\n});\n","import { JSONSchema7Definition } from '@ai-sdk/provider';\n\n/**\n * Converts JSON Schema 7 to OpenAPI Schema 3.0\n */\nexport function convertJSONSchemaToOpenAPISchema(\n jsonSchema: JSONSchema7Definition | undefined,\n): unknown {\n // parameters need to be undefined if they are empty objects:\n if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {\n return undefined;\n }\n\n if (typeof jsonSchema === 'boolean') {\n return { type: 'boolean', properties: {} };\n }\n\n const {\n type,\n description,\n required,\n properties,\n items,\n allOf,\n anyOf,\n oneOf,\n format,\n const: constValue,\n minLength,\n enum: enumValues,\n } = jsonSchema;\n\n const result: Record<string, unknown> = {};\n\n if (description) result.description = description;\n if (required) result.required = required;\n if (format) result.format = format;\n\n if (constValue !== undefined) {\n result.enum = [constValue];\n }\n\n // Handle type\n if (type) {\n if (Array.isArray(type)) {\n if (type.includes('null')) {\n result.type = type.filter(t => t !== 'null')[0];\n result.nullable = true;\n } else {\n result.type = type;\n }\n } else if (type === 'null') {\n result.type = 'null';\n } else {\n result.type = type;\n }\n }\n\n // Handle enum\n if (enumValues !== undefined) {\n result.enum = enumValues;\n }\n\n if (properties != null) {\n result.properties = Object.entries(properties).reduce(\n (acc, [key, value]) => {\n acc[key] = convertJSONSchemaToOpenAPISchema(value);\n return acc;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (items) {\n result.items = Array.isArray(items)\n ? items.map(convertJSONSchemaToOpenAPISchema)\n : convertJSONSchemaToOpenAPISchema(items);\n }\n\n if (allOf) {\n result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);\n }\n if (anyOf) {\n // Handle cases where anyOf includes a null type\n if (\n anyOf.some(\n schema => typeof schema === 'object' && schema?.type === 'null',\n )\n ) {\n const nonNullSchemas = anyOf.filter(\n schema => !(typeof schema === 'object' && schema?.type === 'null'),\n );\n\n if (nonNullSchemas.length === 1) {\n // If there's only one non-null schema, convert it and make it nullable\n const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);\n if (typeof converted === 'object') {\n result.nullable = true;\n Object.assign(result, converted);\n }\n } else {\n // If there are multiple non-null schemas, keep them in anyOf\n result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);\n result.nullable = true;\n }\n } else {\n result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);\n }\n }\n if (oneOf) {\n result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);\n }\n\n if (minLength !== undefined) {\n result.minLength = minLength;\n }\n\n return result;\n}\n\nfunction isEmptyObjectSchema(jsonSchema: JSONSchema7Definition): boolean {\n return (\n jsonSchema != null &&\n typeof jsonSchema === 'object' &&\n jsonSchema.type === 'object' &&\n (jsonSchema.properties == null ||\n Object.keys(jsonSchema.properties).length === 0) &&\n !jsonSchema.additionalProperties\n );\n}\n","import {\n LanguageModelV2Prompt,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport {\n GoogleGenerativeAIContent,\n GoogleGenerativeAIContentPart,\n GoogleGenerativeAIPrompt,\n} from './google-generative-ai-prompt';\nimport { convertToBase64 } from '@ai-sdk/provider-utils';\n\nexport function convertToGoogleGenerativeAIMessages(\n prompt: LanguageModelV2Prompt,\n options?: { isGemmaModel?: boolean },\n): GoogleGenerativeAIPrompt {\n const systemInstructionParts: Array<{ text: string }> = [];\n const contents: Array<GoogleGenerativeAIContent> = [];\n let systemMessagesAllowed = true;\n const isGemmaModel = options?.isGemmaModel ?? false;\n\n for (const { role, content } of prompt) {\n switch (role) {\n case 'system': {\n if (!systemMessagesAllowed) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'system messages are only supported at the beginning of the conversation',\n });\n }\n\n systemInstructionParts.push({ text: content });\n break;\n }\n\n case 'user': {\n systemMessagesAllowed = false;\n\n const parts: GoogleGenerativeAIContentPart[] = [];\n\n for (const part of content) {\n switch (part.type) {\n case 'text': {\n parts.push({ text: part.text });\n break;\n }\n\n case 'file': {\n // default to image/jpeg for unknown image/* types\n const mediaType =\n part.mediaType === 'image/*' ? 'image/jpeg' : part.mediaType;\n\n parts.push(\n part.data instanceof URL\n ? {\n fileData: {\n mimeType: mediaType,\n fileUri: part.data.toString(),\n },\n }\n : {\n inlineData: {\n mimeType: mediaType,\n data: convertToBase64(part.data),\n },\n },\n );\n\n break;\n }\n }\n }\n\n contents.push({ role: 'user', parts });\n break;\n }\n\n case 'assistant': {\n systemMessagesAllowed = false;\n\n contents.push({\n role: 'model',\n parts: content\n .map(part => {\n switch (part.type) {\n case 'text': {\n return part.text.length === 0\n ? undefined\n : {\n text: part.text,\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n\n case 'reasoning': {\n return part.text.length === 0\n ? undefined\n : {\n text: part.text,\n thought: true,\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n\n case 'file': {\n if (part.mediaType !== 'image/png') {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Only PNG images are supported in assistant messages',\n });\n }\n\n if (part.data instanceof URL) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'File data URLs in assistant messages are not supported',\n });\n }\n\n return {\n inlineData: {\n mimeType: part.mediaType,\n data: convertToBase64(part.data),\n },\n };\n }\n\n case 'tool-call': {\n return {\n functionCall: {\n name: part.toolName,\n args: part.input,\n },\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n }\n })\n .filter(part => part !== undefined),\n });\n break;\n }\n\n case 'tool': {\n systemMessagesAllowed = false;\n\n contents.push({\n role: 'user',\n parts: content.map(part => ({\n functionResponse: {\n name: part.toolName,\n response: {\n name: part.toolName,\n content: part.output.value,\n },\n },\n })),\n });\n break;\n }\n }\n }\n\n if (\n isGemmaModel &&\n systemInstructionParts.length > 0 &&\n contents.length > 0 &&\n contents[0].role === 'user'\n ) {\n const systemText = systemInstructionParts\n .map(part => part.text)\n .join('\\n\\n');\n\n contents[0].parts.unshift({ text: systemText + '\\n\\n' });\n }\n\n return {\n systemInstruction:\n systemInstructionParts.length > 0 && !isGemmaModel\n ? { parts: systemInstructionParts }\n : undefined,\n contents,\n };\n}\n","export function getModelPath(modelId: string): string {\n return modelId.includes('/') ? modelId : `models/${modelId}`;\n}\n","import { z } from 'zod/v4';\n\nexport type GoogleGenerativeAIModelId =\n // Stable models\n // https://ai.google.dev/gemini-api/docs/models/gemini\n | 'gemini-1.5-flash'\n | 'gemini-1.5-flash-latest'\n | 'gemini-1.5-flash-001'\n | 'gemini-1.5-flash-002'\n | 'gemini-1.5-flash-8b'\n | 'gemini-1.5-flash-8b-latest'\n | 'gemini-1.5-flash-8b-001'\n | 'gemini-1.5-pro'\n | 'gemini-1.5-pro-latest'\n | 'gemini-1.5-pro-001'\n | 'gemini-1.5-pro-002'\n | 'gemini-2.0-flash'\n | 'gemini-2.0-flash-001'\n | 'gemini-2.0-flash-live-001'\n | 'gemini-2.0-flash-lite'\n | 'gemini-2.0-pro-exp-02-05'\n | 'gemini-2.0-flash-thinking-exp-01-21'\n | 'gemini-2.0-flash-exp'\n | 'gemini-2.5-pro'\n | 'gemini-2.5-flash'\n | 'gemini-2.5-flash-lite'\n // Experimental models\n // https://ai.google.dev/gemini-api/docs/models/experimental-models\n | 'gemini-2.5-pro-exp-03-25'\n | 'gemini-2.5-flash-preview-04-17'\n | 'gemini-exp-1206'\n | 'gemma-3-12b-it'\n | 'gemma-3-27b-it'\n | (string & {});\n\nexport const googleGenerativeAIProviderOptions = z.object({\n responseModalities: z.array(z.enum(['TEXT', 'IMAGE'])).optional(),\n\n thinkingConfig: z\n .object({\n thinkingBudget: z.number().optional(),\n includeThoughts: z.boolean().optional(),\n })\n .optional(),\n\n /**\nOptional.\nThe name of the cached content used as context to serve the prediction.\nFormat: cachedContents/{cachedContent}\n */\n cachedContent: z.string().optional(),\n\n /**\n * Optional. Enable structured output. Default is true.\n *\n * This is useful when the JSON Schema contains elements that are\n * not supported by the OpenAPI schema version that\n * Google Generative AI uses. You can use this to disable\n * structured outputs if you need to.\n */\n structuredOutputs: z.boolean().optional(),\n\n /**\nOptional. A list of unique safety settings for blocking unsafe content.\n */\n safetySettings: z\n .array(\n z.object({\n category: z.enum([\n 'HARM_CATEGORY_UNSPECIFIED',\n 'HARM_CATEGORY_HATE_SPEECH',\n 'HARM_CATEGORY_DANGEROUS_CONTENT',\n 'HARM_CATEGORY_HARASSMENT',\n 'HARM_CATEGORY_SEXUALLY_EXPLICIT',\n 'HARM_CATEGORY_CIVIC_INTEGRITY',\n ]),\n threshold: z.enum([\n 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',\n 'BLOCK_LOW_AND_ABOVE',\n 'BLOCK_MEDIUM_AND_ABOVE',\n 'BLOCK_ONLY_HIGH',\n 'BLOCK_NONE',\n 'OFF',\n ]),\n }),\n )\n .optional(),\n\n threshold: z\n .enum([\n 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',\n 'BLOCK_LOW_AND_ABOVE',\n 'BLOCK_MEDIUM_AND_ABOVE',\n 'BLOCK_ONLY_HIGH',\n 'BLOCK_NONE',\n 'OFF',\n ])\n .optional(),\n\n /**\n * Optional. Enables timestamp understanding for audio-only files.\n *\n * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding\n */\n audioTimestamp: z.boolean().optional(),\n\n /**\n * Optional. Defines labels used in billing reports. Available on Vertex AI only.\n *\n * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls\n */\n labels: z.record(z.string(), z.string()).optional(),\n});\n\nexport type GoogleGenerativeAIProviderOptions = z.infer<\n typeof googleGenerativeAIProviderOptions\n>;\n","import {\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';\nimport { GoogleGenerativeAIModelId } from './google-generative-ai-options';\n\nexport function prepareTools({\n tools,\n toolChoice,\n modelId,\n}: {\n tools: LanguageModelV2CallOptions['tools'];\n toolChoice?: LanguageModelV2CallOptions['toolChoice'];\n modelId: GoogleGenerativeAIModelId;\n}): {\n tools:\n | {\n functionDeclarations: Array<{\n name: string;\n description: string;\n parameters: unknown;\n }>;\n }\n | Record<string, any>\n | undefined;\n toolConfig:\n | undefined\n | {\n functionCallingConfig: {\n mode: 'AUTO' | 'NONE' | 'ANY';\n allowedFunctionNames?: string[];\n };\n };\n toolWarnings: LanguageModelV2CallWarning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n\n const isGemini2 = modelId.includes('gemini-2');\n const supportsDynamicRetrieval =\n modelId.includes('gemini-1.5-flash') && !modelId.includes('-8b');\n\n if (tools == null) {\n return { tools: undefined, toolConfig: undefined, toolWarnings };\n }\n\n // Check for mixed tool types and add warnings\n const hasFunctionTools = tools.some(tool => tool.type === 'function');\n const hasProviderDefinedTools = tools.some(\n tool => tool.type === 'provider-defined',\n );\n\n if (hasFunctionTools && hasProviderDefinedTools) {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool: tools.find(tool => tool.type === 'function')!,\n details:\n 'Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both.',\n });\n }\n\n if (hasProviderDefinedTools) {\n const googleTools: Record<string, any> = {};\n\n const providerDefinedTools = tools.filter(\n tool => tool.type === 'provider-defined',\n );\n providerDefinedTools.forEach(tool => {\n switch (tool.id) {\n case 'google.google_search':\n if (isGemini2) {\n googleTools.googleSearch = {};\n } else if (supportsDynamicRetrieval) {\n // For non-Gemini-2 models that don't support dynamic retrieval, use basic googleSearchRetrieval\n googleTools.googleSearchRetrieval = {\n dynamicRetrievalConfig: {\n mode: tool.args.mode as\n | 'MODE_DYNAMIC'\n | 'MODE_UNSPECIFIED'\n | undefined,\n dynamicThreshold: tool.args.dynamicThreshold as\n | number\n | undefined,\n },\n };\n } else {\n googleTools.googleSearchRetrieval = {};\n }\n break;\n case 'google.url_context':\n if (isGemini2) {\n googleTools.urlContext = {};\n } else {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n details:\n 'The URL context tool is not supported with other Gemini models than Gemini 2.',\n });\n }\n break;\n case 'google.code_execution':\n if (isGemini2) {\n googleTools.codeExecution = {};\n } else {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n details:\n 'The code execution tools is not supported with other Gemini models than Gemini 2.',\n });\n }\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n });\n\n return {\n tools: Object.keys(googleTools).length > 0 ? googleTools : undefined,\n toolConfig: undefined,\n toolWarnings,\n };\n }\n\n const functionDeclarations = [];\n for (const tool of tools) {\n switch (tool.type) {\n case 'function':\n functionDeclarations.push({\n name: tool.name,\n description: tool.description ?? '',\n parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema),\n });\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n }\n\n if (toolChoice == null) {\n return {\n tools: { functionDeclarations },\n toolConfig: undefined,\n toolWarnings,\n };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'AUTO' } },\n toolWarnings,\n };\n case 'none':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'NONE' } },\n toolWarnings,\n };\n case 'required':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'ANY' } },\n toolWarnings,\n };\n case 'tool':\n return {\n tools: { functionDeclarations },\n toolConfig: {\n functionCallingConfig: {\n mode: 'ANY',\n allowedFunctionNames: [toolChoice.toolName],\n },\n },\n toolWarnings,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import { LanguageModelV2FinishReason } from '@ai-sdk/provider';\n\nexport function mapGoogleGenerativeAIFinishReason({\n finishReason,\n hasToolCalls,\n}: {\n finishReason: string | null | undefined;\n hasToolCalls: boolean;\n}): LanguageModelV2FinishReason {\n switch (finishReason) {\n case 'STOP':\n return hasToolCalls ? 'tool-calls' : 'stop';\n case 'MAX_TOKENS':\n return 'length';\n case 'IMAGE_SAFETY':\n case 'RECITATION':\n case 'SAFETY':\n case 'BLOCKLIST':\n case 'PROHIBITED_CONTENT':\n case 'SPII':\n return 'content-filter';\n case 'FINISH_REASON_UNSPECIFIED':\n case 'OTHER':\n return 'other';\n case 'MALFORMED_FUNCTION_CALL':\n return 'error';\n default:\n return 'unknown';\n }\n}\n","import { createProviderDefinedToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://ai.google.dev/gemini-api/docs/google-search\n// https://ai.google.dev/api/generate-content#GroundingSupport\n// https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-search\n\nexport const groundingChunkSchema = z.object({\n web: z.object({ uri: z.string(), title: z.string() }).nullish(),\n retrievedContext: z.object({ uri: z.string(), title: z.string() }).nullish(),\n});\n\nexport const groundingMetadataSchema = z.object({\n webSearchQueries: z.array(z.string()).nullish(),\n retrievalQueries: z.array(z.string()).nullish(),\n searchEntryPoint: z.object({ renderedContent: z.string() }).nullish(),\n groundingChunks: z.array(groundingChunkSchema).nullish(),\n groundingSupports: z\n .array(\n z.object({\n segment: z.object({\n startIndex: z.number().nullish(),\n endIndex: z.number().nullish(),\n text: z.string().nullish(),\n }),\n segment_text: z.string().nullish(),\n groundingChunkIndices: z.array(z.number()).nullish(),\n supportChunkIndices: z.array(z.number()).nullish(),\n confidenceScores: z.array(z.number()).nullish(),\n confidenceScore: z.array(z.number()).nullish(),\n }),\n )\n .nullish(),\n retrievalMetadata: z\n .union([\n z.object({\n webDynamicRetrievalScore: z.number(),\n }),\n z.object({}),\n ])\n .nullish(),\n});\n\nexport const googleSearch = createProviderDefinedToolFactory<\n {},\n {\n /**\n * The mode of the predictor to be used in dynamic retrieval. The following modes are supported:\n * - MODE_DYNAMIC: Run retrieval only when system decides it is necessary\n * - MODE_UNSPECIFIED: Always trigger retrieval\n * @default MODE_UNSPECIFIED\n */\n mode?: 'MODE_DYNAMIC' | 'MODE_UNSPECIFIED';\n\n /**\n * The threshold to be used in dynamic retrieval (if not set, a system default value is used).\n */\n dynamicThreshold?: number;\n }\n>({\n id: 'google.google_search',\n name: 'google_search',\n inputSchema: z.object({\n mode: z\n .enum(['MODE_DYNAMIC', 'MODE_UNSPECIFIED'])\n .default('MODE_UNSPECIFIED'),\n dynamicThreshold: z.number().default(1),\n }),\n});\n","import { createProviderDefinedToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://ai.google.dev/api/generate-content#UrlRetrievalMetadata\nconst urlMetadataSchema = z.object({\n retrievedUrl: z.string(),\n urlRetrievalStatus: z.string(),\n});\n\nexport const urlContextMetadataSchema = z.object({\n urlMetadata: z.array(urlMetadataSchema),\n});\n\nexport const urlContext = createProviderDefinedToolFactory<\n {\n // Url context does not have any input schema, it will directly use the url from the prompt\n },\n {}\n>({\n id: 'google.url_context',\n name: 'url_context',\n inputSchema: z.object({}),\n});\n","import { createProviderDefinedToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * A tool that enables the model to generate and run Python code.\n *\n * @note Ensure the selected model supports Code Execution.\n * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.\n *\n * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)\n */\nexport const codeExecution = createProviderDefinedToolFactoryWithOutputSchema<\n {\n language: string;\n code: string;\n },\n {\n outcome: string;\n output: string;\n },\n {}\n>({\n id: 'google.code_execution',\n name: 'code_execution',\n inputSchema: z.object({\n language: z.string().describe('The programming language of the code.'),\n code: z.string().describe('The code to be executed.'),\n }),\n outputSchema: z.object({\n outcome: z\n .string()\n .describe('The outcome of the execution (e.g., \"OUTCOME_OK\").'),\n output: z.string().describe('The output from the code execution.'),\n }),\n});\n","import { codeExecution } from './tool/code-execution';\nimport { googleSearch } from './tool/google-search';\nimport { urlContext } from './tool/url-context';\n\nexport const googleTools = {\n /**\n * Creates a Google search tool that gives Google direct access to real-time web content.\n * Must have name \"google_search\".\n */\n googleSearch,\n\n /**\n * Creates a URL context tool that gives Google direct access to real-time web content.\n * Must have name \"url_context\".\n */\n urlContext,\n /**\n * A tool that enables the model to generate and run Python code.\n * Must have name \"code_execution\".\n *\n * @note Ensure the selected model supports Code Execution.\n * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.\n *\n * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)\n */\n codeExecution,\n};\n","import { ImageModelV2, ImageModelV2CallWarning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { googleFailedResponseHandler } from './google-error';\nimport {\n GoogleGenerativeAIImageModelId,\n GoogleGenerativeAIImageSettings,\n} from './google-generative-ai-image-settings';\nimport { FetchFunction, Resolvable } from '@ai-sdk/provider-utils';\n\ninterface GoogleGenerativeAIImageModelConfig {\n provider: string;\n baseURL: string;\n headers?: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n generateId?: () => string;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class GoogleGenerativeAIImageModel implements ImageModelV2 {\n readonly specificationVersion = 'v2';\n\n get maxImagesPerCall(): number {\n // https://ai.google.dev/gemini-api/docs/imagen#imagen-model\n return this.settings.maxImagesPerCall ?? 4;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: GoogleGenerativeAIImageModelId,\n private readonly settings: GoogleGenerativeAIImageSettings,\n private readonly config: GoogleGenerativeAIImageModelConfig,\n ) {}\n\n async doGenerate(\n options: Parameters<ImageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<ImageModelV2['doGenerate']>>> {\n const {\n prompt,\n n = 1,\n size = '1024x1024',\n aspectRatio = '1:1',\n seed,\n providerOptions,\n headers,\n abortSignal,\n } = options;\n const warnings: Array<ImageModelV2CallWarning> = [];\n\n if (size != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'seed',\n details:\n 'This model does not support the `seed` option through this provider.',\n });\n }\n\n const googleOptions = await parseProviderOptions({\n provider: 'google',\n providerOptions,\n schema: googleImageProviderOptionsSchema,\n });\n\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n\n const parameters: Record<string, unknown> = {\n sampleCount: n,\n };\n\n if (aspectRatio != null) {\n parameters.aspectRatio = aspectRatio;\n }\n\n if (googleOptions) {\n Object.assign(parameters, googleOptions);\n }\n\n const body = {\n instances: [{ prompt }],\n parameters,\n };\n\n const { responseHeaders, value: response } = await postJsonToApi<{\n predictions: Array<{ bytesBase64Encoded: string }>;\n }>({\n url: `${this.config.baseURL}/models/${this.modelId}:predict`,\n headers: combineHeaders(await resolve(this.config.headers), headers),\n body,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n googleImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n return {\n images: response.predictions.map(\n (p: { bytesBase64Encoded: string }) => p.bytesBase64Encoded,\n ),\n warnings: warnings ?? [],\n providerMetadata: {\n google: {\n images: response.predictions.map(prediction => ({\n // Add any prediction-specific metadata here\n })),\n },\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n\n// minimal version of the schema\nconst googleImageResponseSchema = z.object({\n predictions: z\n .array(z.object({ bytesBase64Encoded: z.string() }))\n .default([]),\n});\n\n// Note: For the initial GA launch of Imagen 3, safety filters are not configurable.\n// https://ai.google.dev/gemini-api/docs/imagen#imagen-model\nconst googleImageProviderOptionsSchema = z.object({\n personGeneration: z\n .enum(['dont_allow', 'allow_adult', 'allow_all'])\n .nullish(),\n aspectRatio: z.enum(['1:1', '3:4', '4:3', '9:16', '16:9']).nullish(),\n});\n\nexport type GoogleGenerativeAIImageProviderOptions = z.infer<\n typeof googleImageProviderOptionsSchema\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAAA,yBAKO;;;ACXP,sBAGO;AACP,IAAAC,yBAOO;AACP,IAAAC,aAAkB;;;ACZlB,4BAA+C;AA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ACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,WAAW,SAAU,SAAoC;AAC7D,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,OAAO;AAAA,EAChC;AAEA,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,eAAe;AACxB,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAC9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,QAAQ;AACjB,SAAO;AACT;AAKO,IAAM,SAAS,yBAAyB;","names":["import_provider_utils","import_provider_utils","import_v4","import_v4","responseHeaders","response","rawValue","import_provider_utils","import_v4","import_provider","import_provider_utils","_a","import_v4","import_provider","googleTools","import_provider_utils","import_v4","import_provider_utils","import_v4","googleTools","generateId","import_provider_utils","import_v4","import_provider_utils","import_v4","_a"]}
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.mjs ADDED
@@ -0,0 +1,1494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/google-provider.ts
2
+ import {
3
+ generateId as generateId2,
4
+ loadApiKey,
5
+ withoutTrailingSlash
6
+ } from "@ai-sdk/provider-utils";
7
+
8
+ // src/google-generative-ai-embedding-model.ts
9
+ import {
10
+ TooManyEmbeddingValuesForCallError
11
+ } from "@ai-sdk/provider";
12
+ import {
13
+ combineHeaders,
14
+ createJsonResponseHandler,
15
+ parseProviderOptions,
16
+ postJsonToApi,
17
+ resolve
18
+ } from "@ai-sdk/provider-utils";
19
+ import { z as z3 } from "zod/v4";
20
+
21
+ // src/google-error.ts
22
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
23
+ import { z } from "zod/v4";
24
+ var googleErrorDataSchema = z.object({
25
+ error: z.object({
26
+ code: z.number().nullable(),
27
+ message: z.string(),
28
+ status: z.string()
29
+ })
30
+ });
31
+ var googleFailedResponseHandler = createJsonErrorResponseHandler({
32
+ errorSchema: googleErrorDataSchema,
33
+ errorToMessage: (data) => data.error.message
34
+ });
35
+
36
+ // src/google-generative-ai-embedding-options.ts
37
+ import { z as z2 } from "zod/v4";
38
+ var googleGenerativeAIEmbeddingProviderOptions = z2.object({
39
+ /**
40
+ * Optional. Optional reduced dimension for the output embedding.
41
+ * If set, excessive values in the output embedding are truncated from the end.
42
+ */
43
+ outputDimensionality: z2.number().optional(),
44
+ /**
45
+ * Optional. Specifies the task type for generating embeddings.
46
+ * Supported task types:
47
+ * - SEMANTIC_SIMILARITY: Optimized for text similarity.
48
+ * - CLASSIFICATION: Optimized for text classification.
49
+ * - CLUSTERING: Optimized for clustering texts based on similarity.
50
+ * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
51
+ * - RETRIEVAL_QUERY: Optimized for query-based retrieval.
52
+ * - QUESTION_ANSWERING: Optimized for answering questions.
53
+ * - FACT_VERIFICATION: Optimized for verifying factual information.
54
+ * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
55
+ */
56
+ taskType: z2.enum([
57
+ "SEMANTIC_SIMILARITY",
58
+ "CLASSIFICATION",
59
+ "CLUSTERING",
60
+ "RETRIEVAL_DOCUMENT",
61
+ "RETRIEVAL_QUERY",
62
+ "QUESTION_ANSWERING",
63
+ "FACT_VERIFICATION",
64
+ "CODE_RETRIEVAL_QUERY"
65
+ ]).optional()
66
+ });
67
+
68
+ // src/google-generative-ai-embedding-model.ts
69
+ var GoogleGenerativeAIEmbeddingModel = class {
70
+ constructor(modelId, config) {
71
+ this.specificationVersion = "v2";
72
+ this.maxEmbeddingsPerCall = 2048;
73
+ this.supportsParallelCalls = true;
74
+ this.modelId = modelId;
75
+ this.config = config;
76
+ }
77
+ get provider() {
78
+ return this.config.provider;
79
+ }
80
+ async doEmbed({
81
+ values,
82
+ headers,
83
+ abortSignal,
84
+ providerOptions
85
+ }) {
86
+ const googleOptions = await parseProviderOptions({
87
+ provider: "google",
88
+ providerOptions,
89
+ schema: googleGenerativeAIEmbeddingProviderOptions
90
+ });
91
+ if (values.length > this.maxEmbeddingsPerCall) {
92
+ throw new TooManyEmbeddingValuesForCallError({
93
+ provider: this.provider,
94
+ modelId: this.modelId,
95
+ maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
96
+ values
97
+ });
98
+ }
99
+ const mergedHeaders = combineHeaders(
100
+ await resolve(this.config.headers),
101
+ headers
102
+ );
103
+ if (values.length === 1) {
104
+ const {
105
+ responseHeaders: responseHeaders2,
106
+ value: response2,
107
+ rawValue: rawValue2
108
+ } = await postJsonToApi({
109
+ url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
110
+ headers: mergedHeaders,
111
+ body: {
112
+ model: `models/${this.modelId}`,
113
+ content: {
114
+ parts: [{ text: values[0] }]
115
+ },
116
+ outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
117
+ taskType: googleOptions == null ? void 0 : googleOptions.taskType
118
+ },
119
+ failedResponseHandler: googleFailedResponseHandler,
120
+ successfulResponseHandler: createJsonResponseHandler(
121
+ googleGenerativeAISingleEmbeddingResponseSchema
122
+ ),
123
+ abortSignal,
124
+ fetch: this.config.fetch
125
+ });
126
+ return {
127
+ embeddings: [response2.embedding.values],
128
+ usage: void 0,
129
+ response: { headers: responseHeaders2, body: rawValue2 }
130
+ };
131
+ }
132
+ const {
133
+ responseHeaders,
134
+ value: response,
135
+ rawValue
136
+ } = await postJsonToApi({
137
+ url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
138
+ headers: mergedHeaders,
139
+ body: {
140
+ requests: values.map((value) => ({
141
+ model: `models/${this.modelId}`,
142
+ content: { role: "user", parts: [{ text: value }] },
143
+ outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
144
+ taskType: googleOptions == null ? void 0 : googleOptions.taskType
145
+ }))
146
+ },
147
+ failedResponseHandler: googleFailedResponseHandler,
148
+ successfulResponseHandler: createJsonResponseHandler(
149
+ googleGenerativeAITextEmbeddingResponseSchema
150
+ ),
151
+ abortSignal,
152
+ fetch: this.config.fetch
153
+ });
154
+ return {
155
+ embeddings: response.embeddings.map((item) => item.values),
156
+ usage: void 0,
157
+ response: { headers: responseHeaders, body: rawValue }
158
+ };
159
+ }
160
+ };
161
+ var googleGenerativeAITextEmbeddingResponseSchema = z3.object({
162
+ embeddings: z3.array(z3.object({ values: z3.array(z3.number()) }))
163
+ });
164
+ var googleGenerativeAISingleEmbeddingResponseSchema = z3.object({
165
+ embedding: z3.object({ values: z3.array(z3.number()) })
166
+ });
167
+
168
+ // src/google-generative-ai-language-model.ts
169
+ import {
170
+ combineHeaders as combineHeaders2,
171
+ createEventSourceResponseHandler,
172
+ createJsonResponseHandler as createJsonResponseHandler2,
173
+ generateId,
174
+ parseProviderOptions as parseProviderOptions2,
175
+ postJsonToApi as postJsonToApi2,
176
+ resolve as resolve2
177
+ } from "@ai-sdk/provider-utils";
178
+ import { z as z7 } from "zod/v4";
179
+
180
+ // src/convert-json-schema-to-openapi-schema.ts
181
+ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
182
+ if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
183
+ return void 0;
184
+ }
185
+ if (typeof jsonSchema === "boolean") {
186
+ return { type: "boolean", properties: {} };
187
+ }
188
+ const {
189
+ type,
190
+ description,
191
+ required,
192
+ properties,
193
+ items,
194
+ allOf,
195
+ anyOf,
196
+ oneOf,
197
+ format,
198
+ const: constValue,
199
+ minLength,
200
+ enum: enumValues
201
+ } = jsonSchema;
202
+ const result = {};
203
+ if (description)
204
+ result.description = description;
205
+ if (required)
206
+ result.required = required;
207
+ if (format)
208
+ result.format = format;
209
+ if (constValue !== void 0) {
210
+ result.enum = [constValue];
211
+ }
212
+ if (type) {
213
+ if (Array.isArray(type)) {
214
+ if (type.includes("null")) {
215
+ result.type = type.filter((t) => t !== "null")[0];
216
+ result.nullable = true;
217
+ } else {
218
+ result.type = type;
219
+ }
220
+ } else if (type === "null") {
221
+ result.type = "null";
222
+ } else {
223
+ result.type = type;
224
+ }
225
+ }
226
+ if (enumValues !== void 0) {
227
+ result.enum = enumValues;
228
+ }
229
+ if (properties != null) {
230
+ result.properties = Object.entries(properties).reduce(
231
+ (acc, [key, value]) => {
232
+ acc[key] = convertJSONSchemaToOpenAPISchema(value);
233
+ return acc;
234
+ },
235
+ {}
236
+ );
237
+ }
238
+ if (items) {
239
+ result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
240
+ }
241
+ if (allOf) {
242
+ result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
243
+ }
244
+ if (anyOf) {
245
+ if (anyOf.some(
246
+ (schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"
247
+ )) {
248
+ const nonNullSchemas = anyOf.filter(
249
+ (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
250
+ );
251
+ if (nonNullSchemas.length === 1) {
252
+ const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
253
+ if (typeof converted === "object") {
254
+ result.nullable = true;
255
+ Object.assign(result, converted);
256
+ }
257
+ } else {
258
+ result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
259
+ result.nullable = true;
260
+ }
261
+ } else {
262
+ result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
263
+ }
264
+ }
265
+ if (oneOf) {
266
+ result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
267
+ }
268
+ if (minLength !== void 0) {
269
+ result.minLength = minLength;
270
+ }
271
+ return result;
272
+ }
273
+ function isEmptyObjectSchema(jsonSchema) {
274
+ return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
275
+ }
276
+
277
+ // src/convert-to-google-generative-ai-messages.ts
278
+ import {
279
+ UnsupportedFunctionalityError
280
+ } from "@ai-sdk/provider";
281
+ import { convertToBase64 } from "@ai-sdk/provider-utils";
282
+ function convertToGoogleGenerativeAIMessages(prompt, options) {
283
+ var _a;
284
+ const systemInstructionParts = [];
285
+ const contents = [];
286
+ let systemMessagesAllowed = true;
287
+ const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
288
+ for (const { role, content } of prompt) {
289
+ switch (role) {
290
+ case "system": {
291
+ if (!systemMessagesAllowed) {
292
+ throw new UnsupportedFunctionalityError({
293
+ functionality: "system messages are only supported at the beginning of the conversation"
294
+ });
295
+ }
296
+ systemInstructionParts.push({ text: content });
297
+ break;
298
+ }
299
+ case "user": {
300
+ systemMessagesAllowed = false;
301
+ const parts = [];
302
+ for (const part of content) {
303
+ switch (part.type) {
304
+ case "text": {
305
+ parts.push({ text: part.text });
306
+ break;
307
+ }
308
+ case "file": {
309
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
310
+ parts.push(
311
+ part.data instanceof URL ? {
312
+ fileData: {
313
+ mimeType: mediaType,
314
+ fileUri: part.data.toString()
315
+ }
316
+ } : {
317
+ inlineData: {
318
+ mimeType: mediaType,
319
+ data: convertToBase64(part.data)
320
+ }
321
+ }
322
+ );
323
+ break;
324
+ }
325
+ }
326
+ }
327
+ contents.push({ role: "user", parts });
328
+ break;
329
+ }
330
+ case "assistant": {
331
+ systemMessagesAllowed = false;
332
+ contents.push({
333
+ role: "model",
334
+ parts: content.map((part) => {
335
+ var _a2, _b, _c, _d, _e, _f;
336
+ switch (part.type) {
337
+ case "text": {
338
+ return part.text.length === 0 ? void 0 : {
339
+ text: part.text,
340
+ thoughtSignature: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature
341
+ };
342
+ }
343
+ case "reasoning": {
344
+ return part.text.length === 0 ? void 0 : {
345
+ text: part.text,
346
+ thought: true,
347
+ thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
348
+ };
349
+ }
350
+ case "file": {
351
+ if (part.mediaType !== "image/png") {
352
+ throw new UnsupportedFunctionalityError({
353
+ functionality: "Only PNG images are supported in assistant messages"
354
+ });
355
+ }
356
+ if (part.data instanceof URL) {
357
+ throw new UnsupportedFunctionalityError({
358
+ functionality: "File data URLs in assistant messages are not supported"
359
+ });
360
+ }
361
+ return {
362
+ inlineData: {
363
+ mimeType: part.mediaType,
364
+ data: convertToBase64(part.data)
365
+ }
366
+ };
367
+ }
368
+ case "tool-call": {
369
+ return {
370
+ functionCall: {
371
+ name: part.toolName,
372
+ args: part.input
373
+ },
374
+ thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
375
+ };
376
+ }
377
+ }
378
+ }).filter((part) => part !== void 0)
379
+ });
380
+ break;
381
+ }
382
+ case "tool": {
383
+ systemMessagesAllowed = false;
384
+ contents.push({
385
+ role: "user",
386
+ parts: content.map((part) => ({
387
+ functionResponse: {
388
+ name: part.toolName,
389
+ response: {
390
+ name: part.toolName,
391
+ content: part.output.value
392
+ }
393
+ }
394
+ }))
395
+ });
396
+ break;
397
+ }
398
+ }
399
+ }
400
+ if (isGemmaModel && systemInstructionParts.length > 0 && contents.length > 0 && contents[0].role === "user") {
401
+ const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
402
+ contents[0].parts.unshift({ text: systemText + "\n\n" });
403
+ }
404
+ return {
405
+ systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
406
+ contents
407
+ };
408
+ }
409
+
410
+ // src/get-model-path.ts
411
+ function getModelPath(modelId) {
412
+ return modelId.includes("/") ? modelId : `models/${modelId}`;
413
+ }
414
+
415
+ // src/google-generative-ai-options.ts
416
+ import { z as z4 } from "zod/v4";
417
+ var googleGenerativeAIProviderOptions = z4.object({
418
+ responseModalities: z4.array(z4.enum(["TEXT", "IMAGE"])).optional(),
419
+ thinkingConfig: z4.object({
420
+ thinkingBudget: z4.number().optional(),
421
+ includeThoughts: z4.boolean().optional()
422
+ }).optional(),
423
+ /**
424
+ Optional.
425
+ The name of the cached content used as context to serve the prediction.
426
+ Format: cachedContents/{cachedContent}
427
+ */
428
+ cachedContent: z4.string().optional(),
429
+ /**
430
+ * Optional. Enable structured output. Default is true.
431
+ *
432
+ * This is useful when the JSON Schema contains elements that are
433
+ * not supported by the OpenAPI schema version that
434
+ * Google Generative AI uses. You can use this to disable
435
+ * structured outputs if you need to.
436
+ */
437
+ structuredOutputs: z4.boolean().optional(),
438
+ /**
439
+ Optional. A list of unique safety settings for blocking unsafe content.
440
+ */
441
+ safetySettings: z4.array(
442
+ z4.object({
443
+ category: z4.enum([
444
+ "HARM_CATEGORY_UNSPECIFIED",
445
+ "HARM_CATEGORY_HATE_SPEECH",
446
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
447
+ "HARM_CATEGORY_HARASSMENT",
448
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT",
449
+ "HARM_CATEGORY_CIVIC_INTEGRITY"
450
+ ]),
451
+ threshold: z4.enum([
452
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
453
+ "BLOCK_LOW_AND_ABOVE",
454
+ "BLOCK_MEDIUM_AND_ABOVE",
455
+ "BLOCK_ONLY_HIGH",
456
+ "BLOCK_NONE",
457
+ "OFF"
458
+ ])
459
+ })
460
+ ).optional(),
461
+ threshold: z4.enum([
462
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
463
+ "BLOCK_LOW_AND_ABOVE",
464
+ "BLOCK_MEDIUM_AND_ABOVE",
465
+ "BLOCK_ONLY_HIGH",
466
+ "BLOCK_NONE",
467
+ "OFF"
468
+ ]).optional(),
469
+ /**
470
+ * Optional. Enables timestamp understanding for audio-only files.
471
+ *
472
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
473
+ */
474
+ audioTimestamp: z4.boolean().optional(),
475
+ /**
476
+ * Optional. Defines labels used in billing reports. Available on Vertex AI only.
477
+ *
478
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
479
+ */
480
+ labels: z4.record(z4.string(), z4.string()).optional()
481
+ });
482
+
483
+ // src/google-prepare-tools.ts
484
+ import {
485
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
486
+ } from "@ai-sdk/provider";
487
+ function prepareTools({
488
+ tools,
489
+ toolChoice,
490
+ modelId
491
+ }) {
492
+ var _a;
493
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
494
+ const toolWarnings = [];
495
+ const isGemini2 = modelId.includes("gemini-2");
496
+ const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
497
+ if (tools == null) {
498
+ return { tools: void 0, toolConfig: void 0, toolWarnings };
499
+ }
500
+ const hasFunctionTools = tools.some((tool) => tool.type === "function");
501
+ const hasProviderDefinedTools = tools.some(
502
+ (tool) => tool.type === "provider-defined"
503
+ );
504
+ if (hasFunctionTools && hasProviderDefinedTools) {
505
+ toolWarnings.push({
506
+ type: "unsupported-tool",
507
+ tool: tools.find((tool) => tool.type === "function"),
508
+ details: "Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both."
509
+ });
510
+ }
511
+ if (hasProviderDefinedTools) {
512
+ const googleTools2 = {};
513
+ const providerDefinedTools = tools.filter(
514
+ (tool) => tool.type === "provider-defined"
515
+ );
516
+ providerDefinedTools.forEach((tool) => {
517
+ switch (tool.id) {
518
+ case "google.google_search":
519
+ if (isGemini2) {
520
+ googleTools2.googleSearch = {};
521
+ } else if (supportsDynamicRetrieval) {
522
+ googleTools2.googleSearchRetrieval = {
523
+ dynamicRetrievalConfig: {
524
+ mode: tool.args.mode,
525
+ dynamicThreshold: tool.args.dynamicThreshold
526
+ }
527
+ };
528
+ } else {
529
+ googleTools2.googleSearchRetrieval = {};
530
+ }
531
+ break;
532
+ case "google.url_context":
533
+ if (isGemini2) {
534
+ googleTools2.urlContext = {};
535
+ } else {
536
+ toolWarnings.push({
537
+ type: "unsupported-tool",
538
+ tool,
539
+ details: "The URL context tool is not supported with other Gemini models than Gemini 2."
540
+ });
541
+ }
542
+ break;
543
+ case "google.code_execution":
544
+ if (isGemini2) {
545
+ googleTools2.codeExecution = {};
546
+ } else {
547
+ toolWarnings.push({
548
+ type: "unsupported-tool",
549
+ tool,
550
+ details: "The code execution tools is not supported with other Gemini models than Gemini 2."
551
+ });
552
+ }
553
+ break;
554
+ default:
555
+ toolWarnings.push({ type: "unsupported-tool", tool });
556
+ break;
557
+ }
558
+ });
559
+ return {
560
+ tools: Object.keys(googleTools2).length > 0 ? googleTools2 : void 0,
561
+ toolConfig: void 0,
562
+ toolWarnings
563
+ };
564
+ }
565
+ const functionDeclarations = [];
566
+ for (const tool of tools) {
567
+ switch (tool.type) {
568
+ case "function":
569
+ functionDeclarations.push({
570
+ name: tool.name,
571
+ description: (_a = tool.description) != null ? _a : "",
572
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
573
+ });
574
+ break;
575
+ default:
576
+ toolWarnings.push({ type: "unsupported-tool", tool });
577
+ break;
578
+ }
579
+ }
580
+ if (toolChoice == null) {
581
+ return {
582
+ tools: { functionDeclarations },
583
+ toolConfig: void 0,
584
+ toolWarnings
585
+ };
586
+ }
587
+ const type = toolChoice.type;
588
+ switch (type) {
589
+ case "auto":
590
+ return {
591
+ tools: { functionDeclarations },
592
+ toolConfig: { functionCallingConfig: { mode: "AUTO" } },
593
+ toolWarnings
594
+ };
595
+ case "none":
596
+ return {
597
+ tools: { functionDeclarations },
598
+ toolConfig: { functionCallingConfig: { mode: "NONE" } },
599
+ toolWarnings
600
+ };
601
+ case "required":
602
+ return {
603
+ tools: { functionDeclarations },
604
+ toolConfig: { functionCallingConfig: { mode: "ANY" } },
605
+ toolWarnings
606
+ };
607
+ case "tool":
608
+ return {
609
+ tools: { functionDeclarations },
610
+ toolConfig: {
611
+ functionCallingConfig: {
612
+ mode: "ANY",
613
+ allowedFunctionNames: [toolChoice.toolName]
614
+ }
615
+ },
616
+ toolWarnings
617
+ };
618
+ default: {
619
+ const _exhaustiveCheck = type;
620
+ throw new UnsupportedFunctionalityError2({
621
+ functionality: `tool choice type: ${_exhaustiveCheck}`
622
+ });
623
+ }
624
+ }
625
+ }
626
+
627
+ // src/map-google-generative-ai-finish-reason.ts
628
+ function mapGoogleGenerativeAIFinishReason({
629
+ finishReason,
630
+ hasToolCalls
631
+ }) {
632
+ switch (finishReason) {
633
+ case "STOP":
634
+ return hasToolCalls ? "tool-calls" : "stop";
635
+ case "MAX_TOKENS":
636
+ return "length";
637
+ case "IMAGE_SAFETY":
638
+ case "RECITATION":
639
+ case "SAFETY":
640
+ case "BLOCKLIST":
641
+ case "PROHIBITED_CONTENT":
642
+ case "SPII":
643
+ return "content-filter";
644
+ case "FINISH_REASON_UNSPECIFIED":
645
+ case "OTHER":
646
+ return "other";
647
+ case "MALFORMED_FUNCTION_CALL":
648
+ return "error";
649
+ default:
650
+ return "unknown";
651
+ }
652
+ }
653
+
654
+ // src/tool/google-search.ts
655
+ import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
656
+ import { z as z5 } from "zod/v4";
657
+ var groundingChunkSchema = z5.object({
658
+ web: z5.object({ uri: z5.string(), title: z5.string() }).nullish(),
659
+ retrievedContext: z5.object({ uri: z5.string(), title: z5.string() }).nullish()
660
+ });
661
+ var groundingMetadataSchema = z5.object({
662
+ webSearchQueries: z5.array(z5.string()).nullish(),
663
+ retrievalQueries: z5.array(z5.string()).nullish(),
664
+ searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
665
+ groundingChunks: z5.array(groundingChunkSchema).nullish(),
666
+ groundingSupports: z5.array(
667
+ z5.object({
668
+ segment: z5.object({
669
+ startIndex: z5.number().nullish(),
670
+ endIndex: z5.number().nullish(),
671
+ text: z5.string().nullish()
672
+ }),
673
+ segment_text: z5.string().nullish(),
674
+ groundingChunkIndices: z5.array(z5.number()).nullish(),
675
+ supportChunkIndices: z5.array(z5.number()).nullish(),
676
+ confidenceScores: z5.array(z5.number()).nullish(),
677
+ confidenceScore: z5.array(z5.number()).nullish()
678
+ })
679
+ ).nullish(),
680
+ retrievalMetadata: z5.union([
681
+ z5.object({
682
+ webDynamicRetrievalScore: z5.number()
683
+ }),
684
+ z5.object({})
685
+ ]).nullish()
686
+ });
687
+ var googleSearch = createProviderDefinedToolFactory({
688
+ id: "google.google_search",
689
+ name: "google_search",
690
+ inputSchema: z5.object({
691
+ mode: z5.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
692
+ dynamicThreshold: z5.number().default(1)
693
+ })
694
+ });
695
+
696
+ // src/tool/url-context.ts
697
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
698
+ import { z as z6 } from "zod/v4";
699
+ var urlMetadataSchema = z6.object({
700
+ retrievedUrl: z6.string(),
701
+ urlRetrievalStatus: z6.string()
702
+ });
703
+ var urlContextMetadataSchema = z6.object({
704
+ urlMetadata: z6.array(urlMetadataSchema)
705
+ });
706
+ var urlContext = createProviderDefinedToolFactory2({
707
+ id: "google.url_context",
708
+ name: "url_context",
709
+ inputSchema: z6.object({})
710
+ });
711
+
712
+ // src/google-generative-ai-language-model.ts
713
+ var GoogleGenerativeAILanguageModel = class {
714
+ constructor(modelId, config) {
715
+ this.specificationVersion = "v2";
716
+ var _a;
717
+ this.modelId = modelId;
718
+ this.config = config;
719
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
720
+ }
721
+ get provider() {
722
+ return this.config.provider;
723
+ }
724
+ get supportedUrls() {
725
+ var _a, _b, _c;
726
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
727
+ }
728
+ async getArgs({
729
+ prompt,
730
+ maxOutputTokens,
731
+ temperature,
732
+ topP,
733
+ topK,
734
+ frequencyPenalty,
735
+ presencePenalty,
736
+ stopSequences,
737
+ responseFormat,
738
+ seed,
739
+ tools,
740
+ toolChoice,
741
+ providerOptions
742
+ }) {
743
+ var _a, _b;
744
+ const warnings = [];
745
+ const googleOptions = await parseProviderOptions2({
746
+ provider: "google",
747
+ providerOptions,
748
+ schema: googleGenerativeAIProviderOptions
749
+ });
750
+ if (((_a = googleOptions == null ? void 0 : googleOptions.thinkingConfig) == null ? void 0 : _a.includeThoughts) === true && !this.config.provider.startsWith("google.vertex.")) {
751
+ warnings.push({
752
+ type: "other",
753
+ message: `The 'includeThoughts' option is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
754
+ });
755
+ }
756
+ const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
757
+ const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
758
+ prompt,
759
+ { isGemmaModel }
760
+ );
761
+ const {
762
+ tools: googleTools2,
763
+ toolConfig: googleToolConfig,
764
+ toolWarnings
765
+ } = prepareTools({
766
+ tools,
767
+ toolChoice,
768
+ modelId: this.modelId
769
+ });
770
+ return {
771
+ args: {
772
+ generationConfig: {
773
+ // standardized settings:
774
+ maxOutputTokens,
775
+ temperature,
776
+ topK,
777
+ topP,
778
+ frequencyPenalty,
779
+ presencePenalty,
780
+ stopSequences,
781
+ seed,
782
+ // response format:
783
+ responseMimeType: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? "application/json" : void 0,
784
+ responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
785
+ // so this is needed as an escape hatch:
786
+ // TODO convert into provider option
787
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
788
+ ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
789
+ audioTimestamp: googleOptions.audioTimestamp
790
+ },
791
+ // provider options:
792
+ responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
793
+ thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
794
+ },
795
+ contents,
796
+ systemInstruction: isGemmaModel ? void 0 : systemInstruction,
797
+ safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
798
+ tools: googleTools2,
799
+ toolConfig: googleToolConfig,
800
+ cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
801
+ labels: googleOptions == null ? void 0 : googleOptions.labels
802
+ },
803
+ warnings: [...warnings, ...toolWarnings]
804
+ };
805
+ }
806
+ async doGenerate(options) {
807
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
808
+ const { args, warnings } = await this.getArgs(options);
809
+ const body = JSON.stringify(args);
810
+ const mergedHeaders = combineHeaders2(
811
+ await resolve2(this.config.headers),
812
+ options.headers
813
+ );
814
+ const {
815
+ responseHeaders,
816
+ value: response,
817
+ rawValue: rawResponse
818
+ } = await postJsonToApi2({
819
+ url: `${this.config.baseURL}/${getModelPath(
820
+ this.modelId
821
+ )}:generateContent`,
822
+ headers: mergedHeaders,
823
+ body: args,
824
+ failedResponseHandler: googleFailedResponseHandler,
825
+ successfulResponseHandler: createJsonResponseHandler2(responseSchema),
826
+ abortSignal: options.abortSignal,
827
+ fetch: this.config.fetch
828
+ });
829
+ const candidate = response.candidates[0];
830
+ const content = [];
831
+ const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
832
+ const usageMetadata = response.usageMetadata;
833
+ let lastCodeExecutionToolCallId;
834
+ for (const part of parts) {
835
+ if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
836
+ const toolCallId = this.config.generateId();
837
+ lastCodeExecutionToolCallId = toolCallId;
838
+ content.push({
839
+ type: "tool-call",
840
+ toolCallId,
841
+ toolName: "code_execution",
842
+ input: JSON.stringify(part.executableCode),
843
+ providerExecuted: true
844
+ });
845
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
846
+ content.push({
847
+ type: "tool-result",
848
+ // Assumes a result directly follows its corresponding call part.
849
+ toolCallId: lastCodeExecutionToolCallId,
850
+ toolName: "code_execution",
851
+ result: {
852
+ outcome: part.codeExecutionResult.outcome,
853
+ output: part.codeExecutionResult.output
854
+ },
855
+ providerExecuted: true
856
+ });
857
+ lastCodeExecutionToolCallId = void 0;
858
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
859
+ content.push({
860
+ type: part.thought === true ? "reasoning" : "text",
861
+ text: part.text,
862
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
863
+ });
864
+ } else if ("functionCall" in part) {
865
+ content.push({
866
+ type: "tool-call",
867
+ toolCallId: this.config.generateId(),
868
+ toolName: part.functionCall.name,
869
+ input: JSON.stringify(part.functionCall.args),
870
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
871
+ });
872
+ } else if ("inlineData" in part) {
873
+ content.push({
874
+ type: "file",
875
+ data: part.inlineData.data,
876
+ mediaType: part.inlineData.mimeType
877
+ });
878
+ }
879
+ }
880
+ const sources = (_d = extractSources({
881
+ groundingMetadata: candidate.groundingMetadata,
882
+ generateId: this.config.generateId
883
+ })) != null ? _d : [];
884
+ for (const source of sources) {
885
+ content.push(source);
886
+ }
887
+ return {
888
+ content,
889
+ finishReason: mapGoogleGenerativeAIFinishReason({
890
+ finishReason: candidate.finishReason,
891
+ hasToolCalls: content.some((part) => part.type === "tool-call")
892
+ }),
893
+ usage: {
894
+ inputTokens: (_e = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _e : void 0,
895
+ outputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _f : void 0,
896
+ totalTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _g : void 0,
897
+ reasoningTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _h : void 0,
898
+ cachedInputTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _i : void 0
899
+ },
900
+ warnings,
901
+ providerMetadata: {
902
+ google: {
903
+ groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
904
+ urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
905
+ safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
906
+ usageMetadata: usageMetadata != null ? usageMetadata : null
907
+ }
908
+ },
909
+ request: { body },
910
+ response: {
911
+ // TODO timestamp, model id, id
912
+ headers: responseHeaders,
913
+ body: rawResponse
914
+ }
915
+ };
916
+ }
917
+ async doStream(options) {
918
+ const { args, warnings } = await this.getArgs(options);
919
+ const body = JSON.stringify(args);
920
+ const headers = combineHeaders2(
921
+ await resolve2(this.config.headers),
922
+ options.headers
923
+ );
924
+ const { responseHeaders, value: response } = await postJsonToApi2({
925
+ url: `${this.config.baseURL}/${getModelPath(
926
+ this.modelId
927
+ )}:streamGenerateContent?alt=sse`,
928
+ headers,
929
+ body: args,
930
+ failedResponseHandler: googleFailedResponseHandler,
931
+ successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
932
+ abortSignal: options.abortSignal,
933
+ fetch: this.config.fetch
934
+ });
935
+ let finishReason = "unknown";
936
+ const usage = {
937
+ inputTokens: void 0,
938
+ outputTokens: void 0,
939
+ totalTokens: void 0
940
+ };
941
+ let providerMetadata = void 0;
942
+ const generateId3 = this.config.generateId;
943
+ let hasToolCalls = false;
944
+ let currentTextBlockId = null;
945
+ let currentReasoningBlockId = null;
946
+ let blockCounter = 0;
947
+ const emittedSourceUrls = /* @__PURE__ */ new Set();
948
+ let lastCodeExecutionToolCallId;
949
+ return {
950
+ stream: response.pipeThrough(
951
+ new TransformStream({
952
+ start(controller) {
953
+ controller.enqueue({ type: "stream-start", warnings });
954
+ },
955
+ transform(chunk, controller) {
956
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
957
+ if (options.includeRawChunks) {
958
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
959
+ }
960
+ if (!chunk.success) {
961
+ controller.enqueue({ type: "error", error: chunk.error });
962
+ return;
963
+ }
964
+ const value = chunk.value;
965
+ const usageMetadata = value.usageMetadata;
966
+ if (usageMetadata != null) {
967
+ usage.inputTokens = (_a = usageMetadata.promptTokenCount) != null ? _a : void 0;
968
+ usage.outputTokens = (_b = usageMetadata.candidatesTokenCount) != null ? _b : void 0;
969
+ usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
970
+ usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
971
+ usage.cachedInputTokens = (_e = usageMetadata.cachedContentTokenCount) != null ? _e : void 0;
972
+ }
973
+ const candidate = (_f = value.candidates) == null ? void 0 : _f[0];
974
+ if (candidate == null) {
975
+ return;
976
+ }
977
+ const content = candidate.content;
978
+ const sources = extractSources({
979
+ groundingMetadata: candidate.groundingMetadata,
980
+ generateId: generateId3
981
+ });
982
+ if (sources != null) {
983
+ for (const source of sources) {
984
+ if (source.sourceType === "url" && !emittedSourceUrls.has(source.url)) {
985
+ emittedSourceUrls.add(source.url);
986
+ controller.enqueue(source);
987
+ }
988
+ }
989
+ }
990
+ if (content != null) {
991
+ const parts = (_g = content.parts) != null ? _g : [];
992
+ for (const part of parts) {
993
+ if ("executableCode" in part && ((_h = part.executableCode) == null ? void 0 : _h.code)) {
994
+ const toolCallId = generateId3();
995
+ lastCodeExecutionToolCallId = toolCallId;
996
+ controller.enqueue({
997
+ type: "tool-call",
998
+ toolCallId,
999
+ toolName: "code_execution",
1000
+ input: JSON.stringify(part.executableCode),
1001
+ providerExecuted: true
1002
+ });
1003
+ hasToolCalls = true;
1004
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1005
+ const toolCallId = lastCodeExecutionToolCallId;
1006
+ if (toolCallId) {
1007
+ controller.enqueue({
1008
+ type: "tool-result",
1009
+ toolCallId,
1010
+ toolName: "code_execution",
1011
+ result: {
1012
+ outcome: part.codeExecutionResult.outcome,
1013
+ output: part.codeExecutionResult.output
1014
+ },
1015
+ providerExecuted: true
1016
+ });
1017
+ lastCodeExecutionToolCallId = void 0;
1018
+ }
1019
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
1020
+ if (part.thought === true) {
1021
+ if (currentTextBlockId !== null) {
1022
+ controller.enqueue({
1023
+ type: "text-end",
1024
+ id: currentTextBlockId
1025
+ });
1026
+ currentTextBlockId = null;
1027
+ }
1028
+ if (currentReasoningBlockId === null) {
1029
+ currentReasoningBlockId = String(blockCounter++);
1030
+ controller.enqueue({
1031
+ type: "reasoning-start",
1032
+ id: currentReasoningBlockId,
1033
+ providerMetadata: part.thoughtSignature ? {
1034
+ google: {
1035
+ thoughtSignature: part.thoughtSignature
1036
+ }
1037
+ } : void 0
1038
+ });
1039
+ }
1040
+ controller.enqueue({
1041
+ type: "reasoning-delta",
1042
+ id: currentReasoningBlockId,
1043
+ delta: part.text,
1044
+ providerMetadata: part.thoughtSignature ? {
1045
+ google: { thoughtSignature: part.thoughtSignature }
1046
+ } : void 0
1047
+ });
1048
+ } else {
1049
+ if (currentReasoningBlockId !== null) {
1050
+ controller.enqueue({
1051
+ type: "reasoning-end",
1052
+ id: currentReasoningBlockId
1053
+ });
1054
+ currentReasoningBlockId = null;
1055
+ }
1056
+ if (currentTextBlockId === null) {
1057
+ currentTextBlockId = String(blockCounter++);
1058
+ controller.enqueue({
1059
+ type: "text-start",
1060
+ id: currentTextBlockId,
1061
+ providerMetadata: part.thoughtSignature ? {
1062
+ google: {
1063
+ thoughtSignature: part.thoughtSignature
1064
+ }
1065
+ } : void 0
1066
+ });
1067
+ }
1068
+ controller.enqueue({
1069
+ type: "text-delta",
1070
+ id: currentTextBlockId,
1071
+ delta: part.text,
1072
+ providerMetadata: part.thoughtSignature ? {
1073
+ google: { thoughtSignature: part.thoughtSignature }
1074
+ } : void 0
1075
+ });
1076
+ }
1077
+ }
1078
+ }
1079
+ const inlineDataParts = getInlineDataParts(content.parts);
1080
+ if (inlineDataParts != null) {
1081
+ for (const part of inlineDataParts) {
1082
+ controller.enqueue({
1083
+ type: "file",
1084
+ mediaType: part.inlineData.mimeType,
1085
+ data: part.inlineData.data
1086
+ });
1087
+ }
1088
+ }
1089
+ const toolCallDeltas = getToolCallsFromParts({
1090
+ parts: content.parts,
1091
+ generateId: generateId3
1092
+ });
1093
+ if (toolCallDeltas != null) {
1094
+ for (const toolCall of toolCallDeltas) {
1095
+ controller.enqueue({
1096
+ type: "tool-input-start",
1097
+ id: toolCall.toolCallId,
1098
+ toolName: toolCall.toolName,
1099
+ providerMetadata: toolCall.providerMetadata
1100
+ });
1101
+ controller.enqueue({
1102
+ type: "tool-input-delta",
1103
+ id: toolCall.toolCallId,
1104
+ delta: toolCall.args,
1105
+ providerMetadata: toolCall.providerMetadata
1106
+ });
1107
+ controller.enqueue({
1108
+ type: "tool-input-end",
1109
+ id: toolCall.toolCallId,
1110
+ providerMetadata: toolCall.providerMetadata
1111
+ });
1112
+ controller.enqueue({
1113
+ type: "tool-call",
1114
+ toolCallId: toolCall.toolCallId,
1115
+ toolName: toolCall.toolName,
1116
+ input: toolCall.args,
1117
+ providerMetadata: toolCall.providerMetadata
1118
+ });
1119
+ hasToolCalls = true;
1120
+ }
1121
+ }
1122
+ }
1123
+ if (candidate.finishReason != null) {
1124
+ finishReason = mapGoogleGenerativeAIFinishReason({
1125
+ finishReason: candidate.finishReason,
1126
+ hasToolCalls
1127
+ });
1128
+ providerMetadata = {
1129
+ google: {
1130
+ groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
1131
+ urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
1132
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
1133
+ }
1134
+ };
1135
+ if (usageMetadata != null) {
1136
+ providerMetadata.google.usageMetadata = usageMetadata;
1137
+ }
1138
+ }
1139
+ },
1140
+ flush(controller) {
1141
+ if (currentTextBlockId !== null) {
1142
+ controller.enqueue({
1143
+ type: "text-end",
1144
+ id: currentTextBlockId
1145
+ });
1146
+ }
1147
+ if (currentReasoningBlockId !== null) {
1148
+ controller.enqueue({
1149
+ type: "reasoning-end",
1150
+ id: currentReasoningBlockId
1151
+ });
1152
+ }
1153
+ controller.enqueue({
1154
+ type: "finish",
1155
+ finishReason,
1156
+ usage,
1157
+ providerMetadata
1158
+ });
1159
+ }
1160
+ })
1161
+ ),
1162
+ response: { headers: responseHeaders },
1163
+ request: { body }
1164
+ };
1165
+ }
1166
+ };
1167
+ function getToolCallsFromParts({
1168
+ parts,
1169
+ generateId: generateId3
1170
+ }) {
1171
+ const functionCallParts = parts == null ? void 0 : parts.filter(
1172
+ (part) => "functionCall" in part
1173
+ );
1174
+ return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1175
+ type: "tool-call",
1176
+ toolCallId: generateId3(),
1177
+ toolName: part.functionCall.name,
1178
+ args: JSON.stringify(part.functionCall.args),
1179
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1180
+ }));
1181
+ }
1182
+ function getInlineDataParts(parts) {
1183
+ return parts == null ? void 0 : parts.filter(
1184
+ (part) => "inlineData" in part
1185
+ );
1186
+ }
1187
+ function extractSources({
1188
+ groundingMetadata,
1189
+ generateId: generateId3
1190
+ }) {
1191
+ var _a;
1192
+ return (_a = groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks) == null ? void 0 : _a.filter(
1193
+ (chunk) => chunk.web != null
1194
+ ).map((chunk) => ({
1195
+ type: "source",
1196
+ sourceType: "url",
1197
+ id: generateId3(),
1198
+ url: chunk.web.uri,
1199
+ title: chunk.web.title
1200
+ }));
1201
+ }
1202
+ var contentSchema = z7.object({
1203
+ parts: z7.array(
1204
+ z7.union([
1205
+ // note: order matters since text can be fully empty
1206
+ z7.object({
1207
+ functionCall: z7.object({
1208
+ name: z7.string(),
1209
+ args: z7.unknown()
1210
+ }),
1211
+ thoughtSignature: z7.string().nullish()
1212
+ }),
1213
+ z7.object({
1214
+ inlineData: z7.object({
1215
+ mimeType: z7.string(),
1216
+ data: z7.string()
1217
+ })
1218
+ }),
1219
+ z7.object({
1220
+ executableCode: z7.object({
1221
+ language: z7.string(),
1222
+ code: z7.string()
1223
+ }).nullish(),
1224
+ codeExecutionResult: z7.object({
1225
+ outcome: z7.string(),
1226
+ output: z7.string()
1227
+ }).nullish(),
1228
+ text: z7.string().nullish(),
1229
+ thought: z7.boolean().nullish(),
1230
+ thoughtSignature: z7.string().nullish()
1231
+ })
1232
+ ])
1233
+ ).nullish()
1234
+ });
1235
+ var safetyRatingSchema = z7.object({
1236
+ category: z7.string().nullish(),
1237
+ probability: z7.string().nullish(),
1238
+ probabilityScore: z7.number().nullish(),
1239
+ severity: z7.string().nullish(),
1240
+ severityScore: z7.number().nullish(),
1241
+ blocked: z7.boolean().nullish()
1242
+ });
1243
+ var usageSchema = z7.object({
1244
+ cachedContentTokenCount: z7.number().nullish(),
1245
+ thoughtsTokenCount: z7.number().nullish(),
1246
+ promptTokenCount: z7.number().nullish(),
1247
+ candidatesTokenCount: z7.number().nullish(),
1248
+ totalTokenCount: z7.number().nullish()
1249
+ });
1250
+ var responseSchema = z7.object({
1251
+ candidates: z7.array(
1252
+ z7.object({
1253
+ content: contentSchema.nullish().or(z7.object({}).strict()),
1254
+ finishReason: z7.string().nullish(),
1255
+ safetyRatings: z7.array(safetyRatingSchema).nullish(),
1256
+ groundingMetadata: groundingMetadataSchema.nullish(),
1257
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1258
+ })
1259
+ ),
1260
+ usageMetadata: usageSchema.nullish()
1261
+ });
1262
+ var chunkSchema = z7.object({
1263
+ candidates: z7.array(
1264
+ z7.object({
1265
+ content: contentSchema.nullish(),
1266
+ finishReason: z7.string().nullish(),
1267
+ safetyRatings: z7.array(safetyRatingSchema).nullish(),
1268
+ groundingMetadata: groundingMetadataSchema.nullish(),
1269
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1270
+ })
1271
+ ).nullish(),
1272
+ usageMetadata: usageSchema.nullish()
1273
+ });
1274
+
1275
+ // src/tool/code-execution.ts
1276
+ import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
1277
+ import { z as z8 } from "zod/v4";
1278
+ var codeExecution = createProviderDefinedToolFactoryWithOutputSchema({
1279
+ id: "google.code_execution",
1280
+ name: "code_execution",
1281
+ inputSchema: z8.object({
1282
+ language: z8.string().describe("The programming language of the code."),
1283
+ code: z8.string().describe("The code to be executed.")
1284
+ }),
1285
+ outputSchema: z8.object({
1286
+ outcome: z8.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1287
+ output: z8.string().describe("The output from the code execution.")
1288
+ })
1289
+ });
1290
+
1291
+ // src/google-tools.ts
1292
+ var googleTools = {
1293
+ /**
1294
+ * Creates a Google search tool that gives Google direct access to real-time web content.
1295
+ * Must have name "google_search".
1296
+ */
1297
+ googleSearch,
1298
+ /**
1299
+ * Creates a URL context tool that gives Google direct access to real-time web content.
1300
+ * Must have name "url_context".
1301
+ */
1302
+ urlContext,
1303
+ /**
1304
+ * A tool that enables the model to generate and run Python code.
1305
+ * Must have name "code_execution".
1306
+ *
1307
+ * @note Ensure the selected model supports Code Execution.
1308
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
1309
+ *
1310
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
1311
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
1312
+ */
1313
+ codeExecution
1314
+ };
1315
+
1316
+ // src/google-generative-ai-image-model.ts
1317
+ import {
1318
+ combineHeaders as combineHeaders3,
1319
+ createJsonResponseHandler as createJsonResponseHandler3,
1320
+ parseProviderOptions as parseProviderOptions3,
1321
+ postJsonToApi as postJsonToApi3,
1322
+ resolve as resolve3
1323
+ } from "@ai-sdk/provider-utils";
1324
+ import { z as z9 } from "zod/v4";
1325
+ var GoogleGenerativeAIImageModel = class {
1326
+ constructor(modelId, settings, config) {
1327
+ this.modelId = modelId;
1328
+ this.settings = settings;
1329
+ this.config = config;
1330
+ this.specificationVersion = "v2";
1331
+ }
1332
+ get maxImagesPerCall() {
1333
+ var _a;
1334
+ return (_a = this.settings.maxImagesPerCall) != null ? _a : 4;
1335
+ }
1336
+ get provider() {
1337
+ return this.config.provider;
1338
+ }
1339
+ async doGenerate(options) {
1340
+ var _a, _b, _c;
1341
+ const {
1342
+ prompt,
1343
+ n = 1,
1344
+ size = "1024x1024",
1345
+ aspectRatio = "1:1",
1346
+ seed,
1347
+ providerOptions,
1348
+ headers,
1349
+ abortSignal
1350
+ } = options;
1351
+ const warnings = [];
1352
+ if (size != null) {
1353
+ warnings.push({
1354
+ type: "unsupported-setting",
1355
+ setting: "size",
1356
+ details: "This model does not support the `size` option. Use `aspectRatio` instead."
1357
+ });
1358
+ }
1359
+ if (seed != null) {
1360
+ warnings.push({
1361
+ type: "unsupported-setting",
1362
+ setting: "seed",
1363
+ details: "This model does not support the `seed` option through this provider."
1364
+ });
1365
+ }
1366
+ const googleOptions = await parseProviderOptions3({
1367
+ provider: "google",
1368
+ providerOptions,
1369
+ schema: googleImageProviderOptionsSchema
1370
+ });
1371
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1372
+ const parameters = {
1373
+ sampleCount: n
1374
+ };
1375
+ if (aspectRatio != null) {
1376
+ parameters.aspectRatio = aspectRatio;
1377
+ }
1378
+ if (googleOptions) {
1379
+ Object.assign(parameters, googleOptions);
1380
+ }
1381
+ const body = {
1382
+ instances: [{ prompt }],
1383
+ parameters
1384
+ };
1385
+ const { responseHeaders, value: response } = await postJsonToApi3({
1386
+ url: `${this.config.baseURL}/models/${this.modelId}:predict`,
1387
+ headers: combineHeaders3(await resolve3(this.config.headers), headers),
1388
+ body,
1389
+ failedResponseHandler: googleFailedResponseHandler,
1390
+ successfulResponseHandler: createJsonResponseHandler3(
1391
+ googleImageResponseSchema
1392
+ ),
1393
+ abortSignal,
1394
+ fetch: this.config.fetch
1395
+ });
1396
+ return {
1397
+ images: response.predictions.map(
1398
+ (p) => p.bytesBase64Encoded
1399
+ ),
1400
+ warnings: warnings != null ? warnings : [],
1401
+ providerMetadata: {
1402
+ google: {
1403
+ images: response.predictions.map((prediction) => ({
1404
+ // Add any prediction-specific metadata here
1405
+ }))
1406
+ }
1407
+ },
1408
+ response: {
1409
+ timestamp: currentDate,
1410
+ modelId: this.modelId,
1411
+ headers: responseHeaders
1412
+ }
1413
+ };
1414
+ }
1415
+ };
1416
+ var googleImageResponseSchema = z9.object({
1417
+ predictions: z9.array(z9.object({ bytesBase64Encoded: z9.string() })).default([])
1418
+ });
1419
+ var googleImageProviderOptionsSchema = z9.object({
1420
+ personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1421
+ aspectRatio: z9.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
1422
+ });
1423
+
1424
+ // src/google-provider.ts
1425
+ function createGoogleGenerativeAI(options = {}) {
1426
+ var _a;
1427
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
1428
+ const getHeaders = () => ({
1429
+ "x-goog-api-key": loadApiKey({
1430
+ apiKey: options.apiKey,
1431
+ environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
1432
+ description: "Google Generative AI"
1433
+ }),
1434
+ ...options.headers
1435
+ });
1436
+ const createChatModel = (modelId) => {
1437
+ var _a2;
1438
+ return new GoogleGenerativeAILanguageModel(modelId, {
1439
+ provider: "google.generative-ai",
1440
+ baseURL,
1441
+ headers: getHeaders,
1442
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
1443
+ supportedUrls: () => ({
1444
+ "*": [
1445
+ // Google Generative Language "files" endpoint
1446
+ // e.g. https://generativelanguage.googleapis.com/v1beta/files/...
1447
+ new RegExp(`^${baseURL}/files/.*$`),
1448
+ // YouTube URLs (public or unlisted videos)
1449
+ new RegExp(
1450
+ `^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
1451
+ ),
1452
+ new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
1453
+ ]
1454
+ }),
1455
+ fetch: options.fetch
1456
+ });
1457
+ };
1458
+ const createEmbeddingModel = (modelId) => new GoogleGenerativeAIEmbeddingModel(modelId, {
1459
+ provider: "google.generative-ai",
1460
+ baseURL,
1461
+ headers: getHeaders,
1462
+ fetch: options.fetch
1463
+ });
1464
+ const createImageModel = (modelId, settings = {}) => new GoogleGenerativeAIImageModel(modelId, settings, {
1465
+ provider: "google.generative-ai",
1466
+ baseURL,
1467
+ headers: getHeaders,
1468
+ fetch: options.fetch
1469
+ });
1470
+ const provider = function(modelId) {
1471
+ if (new.target) {
1472
+ throw new Error(
1473
+ "The Google Generative AI model function cannot be called with the new keyword."
1474
+ );
1475
+ }
1476
+ return createChatModel(modelId);
1477
+ };
1478
+ provider.languageModel = createChatModel;
1479
+ provider.chat = createChatModel;
1480
+ provider.generativeAI = createChatModel;
1481
+ provider.embedding = createEmbeddingModel;
1482
+ provider.textEmbedding = createEmbeddingModel;
1483
+ provider.textEmbeddingModel = createEmbeddingModel;
1484
+ provider.image = createImageModel;
1485
+ provider.imageModel = createImageModel;
1486
+ provider.tools = googleTools;
1487
+ return provider;
1488
+ }
1489
+ var google = createGoogleGenerativeAI();
1490
+ export {
1491
+ createGoogleGenerativeAI,
1492
+ google
1493
+ };
1494
+ //# sourceMappingURL=index.mjs.map
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/index.mjs.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../src/google-provider.ts","../src/google-generative-ai-embedding-model.ts","../src/google-error.ts","../src/google-generative-ai-embedding-options.ts","../src/google-generative-ai-language-model.ts","../src/convert-json-schema-to-openapi-schema.ts","../src/convert-to-google-generative-ai-messages.ts","../src/get-model-path.ts","../src/google-generative-ai-options.ts","../src/google-prepare-tools.ts","../src/map-google-generative-ai-finish-reason.ts","../src/tool/google-search.ts","../src/tool/url-context.ts","../src/tool/code-execution.ts","../src/google-tools.ts","../src/google-generative-ai-image-model.ts"],"sourcesContent":["import {\n EmbeddingModelV2,\n LanguageModelV2,\n ProviderV2,\n ImageModelV2,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n generateId,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { GoogleGenerativeAIEmbeddingModel } from './google-generative-ai-embedding-model';\nimport { GoogleGenerativeAIEmbeddingModelId } from './google-generative-ai-embedding-options';\nimport { GoogleGenerativeAILanguageModel } from './google-generative-ai-language-model';\nimport { GoogleGenerativeAIModelId } from './google-generative-ai-options';\nimport { googleTools } from './google-tools';\n\nimport {\n GoogleGenerativeAIImageSettings,\n GoogleGenerativeAIImageModelId,\n} from './google-generative-ai-image-settings';\nimport { GoogleGenerativeAIImageModel } from './google-generative-ai-image-model';\n\nexport interface GoogleGenerativeAIProvider extends ProviderV2 {\n (modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n chat(modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n /**\nCreates a model for image generation.\n */\n image(\n modelId: GoogleGenerativeAIImageModelId,\n settings?: GoogleGenerativeAIImageSettings,\n ): ImageModelV2;\n\n /**\n * @deprecated Use `chat()` instead.\n */\n generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV2;\n\n /**\n@deprecated Use `textEmbedding()` instead.\n */\n embedding(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n\n textEmbedding(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n\n textEmbeddingModel(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n\n tools: typeof googleTools;\n}\n\nexport interface GoogleGenerativeAIProviderSettings {\n /**\nUse a different URL prefix for API calls, e.g. to use proxy servers.\nThe default prefix is `https://generativelanguage.googleapis.com/v1beta`.\n */\n baseURL?: string;\n\n /**\nAPI key that is being send using the `x-goog-api-key` header.\nIt defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.\n */\n apiKey?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Record<string, string | undefined>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\nOptional function to generate a unique ID for each request.\n */\n generateId?: () => string;\n}\n\n/**\nCreate a Google Generative AI provider instance.\n */\nexport function createGoogleGenerativeAI(\n options: GoogleGenerativeAIProviderSettings = {},\n): GoogleGenerativeAIProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL) ??\n 'https://generativelanguage.googleapis.com/v1beta';\n\n const getHeaders = () => ({\n 'x-goog-api-key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'GOOGLE_GENERATIVE_AI_API_KEY',\n description: 'Google Generative AI',\n }),\n ...options.headers,\n });\n\n const createChatModel = (modelId: GoogleGenerativeAIModelId) =>\n new GoogleGenerativeAILanguageModel(modelId, {\n provider: 'google.generative-ai',\n baseURL,\n headers: getHeaders,\n generateId: options.generateId ?? generateId,\n supportedUrls: () => ({\n '*': [\n // Google Generative Language \"files\" endpoint\n // e.g. https://generativelanguage.googleapis.com/v1beta/files/...\n new RegExp(`^${baseURL}/files/.*$`),\n // YouTube URLs (public or unlisted videos)\n new RegExp(\n `^https://(?:www\\\\.)?youtube\\\\.com/watch\\\\?v=[\\\\w-]+(?:&[\\\\w=&.-]*)?$`,\n ),\n new RegExp(`^https://youtu\\\\.be/[\\\\w-]+(?:\\\\?[\\\\w=&.-]*)?$`),\n ],\n }),\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (modelId: GoogleGenerativeAIEmbeddingModelId) =>\n new GoogleGenerativeAIEmbeddingModel(modelId, {\n provider: 'google.generative-ai',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createImageModel = (\n modelId: GoogleGenerativeAIImageModelId,\n settings: GoogleGenerativeAIImageSettings = {},\n ) =>\n new GoogleGenerativeAIImageModel(modelId, settings, {\n provider: 'google.generative-ai',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: GoogleGenerativeAIModelId) {\n if (new.target) {\n throw new Error(\n 'The Google Generative AI model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.generativeAI = createChatModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.tools = googleTools;\n return provider as GoogleGenerativeAIProvider;\n}\n\n/**\nDefault Google Generative AI provider instance.\n */\nexport const google = createGoogleGenerativeAI();\n","import {\n EmbeddingModelV2,\n TooManyEmbeddingValuesForCallError,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n FetchFunction,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { googleFailedResponseHandler } from './google-error';\nimport {\n GoogleGenerativeAIEmbeddingModelId,\n googleGenerativeAIEmbeddingProviderOptions,\n} from './google-generative-ai-embedding-options';\n\ntype GoogleGenerativeAIEmbeddingConfig = {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n};\n\nexport class GoogleGenerativeAIEmbeddingModel\n implements EmbeddingModelV2<string>\n{\n readonly specificationVersion = 'v2';\n readonly modelId: GoogleGenerativeAIEmbeddingModelId;\n readonly maxEmbeddingsPerCall = 2048;\n readonly supportsParallelCalls = true;\n\n private readonly config: GoogleGenerativeAIEmbeddingConfig;\n\n get provider(): string {\n return this.config.provider;\n }\n constructor(\n modelId: GoogleGenerativeAIEmbeddingModelId,\n config: GoogleGenerativeAIEmbeddingConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n }\n\n async doEmbed({\n values,\n headers,\n abortSignal,\n providerOptions,\n }: Parameters<EmbeddingModelV2<string>['doEmbed']>[0]): Promise<\n Awaited<ReturnType<EmbeddingModelV2<string>['doEmbed']>>\n > {\n // Parse provider options\n const googleOptions = await parseProviderOptions({\n provider: 'google',\n providerOptions,\n schema: googleGenerativeAIEmbeddingProviderOptions,\n });\n\n if (values.length > this.maxEmbeddingsPerCall) {\n throw new TooManyEmbeddingValuesForCallError({\n provider: this.provider,\n modelId: this.modelId,\n maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,\n values,\n });\n }\n\n const mergedHeaders = combineHeaders(\n await resolve(this.config.headers),\n headers,\n );\n\n // For single embeddings, use the single endpoint (ratelimits, etc.)\n if (values.length === 1) {\n const {\n responseHeaders,\n value: response,\n rawValue,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,\n headers: mergedHeaders,\n body: {\n model: `models/${this.modelId}`,\n content: {\n parts: [{ text: values[0] }],\n },\n outputDimensionality: googleOptions?.outputDimensionality,\n taskType: googleOptions?.taskType,\n },\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n googleGenerativeAISingleEmbeddingResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n embeddings: [response.embedding.values],\n usage: undefined,\n response: { headers: responseHeaders, body: rawValue },\n };\n }\n\n const {\n responseHeaders,\n value: response,\n rawValue,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,\n headers: mergedHeaders,\n body: {\n requests: values.map(value => ({\n model: `models/${this.modelId}`,\n content: { role: 'user', parts: [{ text: value }] },\n outputDimensionality: googleOptions?.outputDimensionality,\n taskType: googleOptions?.taskType,\n })),\n },\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n googleGenerativeAITextEmbeddingResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n embeddings: response.embeddings.map(item => item.values),\n usage: undefined,\n response: { headers: responseHeaders, body: rawValue },\n };\n }\n}\n\n// minimal version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst googleGenerativeAITextEmbeddingResponseSchema = z.object({\n embeddings: z.array(z.object({ values: z.array(z.number()) })),\n});\n\n// Schema for single embedding response\nconst googleGenerativeAISingleEmbeddingResponseSchema = z.object({\n embedding: z.object({ values: z.array(z.number()) }),\n});\n","import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst googleErrorDataSchema = z.object({\n error: z.object({\n code: z.number().nullable(),\n message: z.string(),\n status: z.string(),\n }),\n});\n\nexport type GoogleErrorData = z.infer<typeof googleErrorDataSchema>;\n\nexport const googleFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: googleErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import { z } from 'zod/v4';\n\nexport type GoogleGenerativeAIEmbeddingModelId =\n | 'gemini-embedding-001'\n | 'text-embedding-004'\n | (string & {});\n\nexport const googleGenerativeAIEmbeddingProviderOptions = z.object({\n /**\n * Optional. Optional reduced dimension for the output embedding.\n * If set, excessive values in the output embedding are truncated from the end.\n */\n outputDimensionality: z.number().optional(),\n\n /**\n * Optional. Specifies the task type for generating embeddings.\n * Supported task types:\n * - SEMANTIC_SIMILARITY: Optimized for text similarity.\n * - CLASSIFICATION: Optimized for text classification.\n * - CLUSTERING: Optimized for clustering texts based on similarity.\n * - RETRIEVAL_DOCUMENT: Optimized for document retrieval.\n * - RETRIEVAL_QUERY: Optimized for query-based retrieval.\n * - QUESTION_ANSWERING: Optimized for answering questions.\n * - FACT_VERIFICATION: Optimized for verifying factual information.\n * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.\n */\n taskType: z\n .enum([\n 'SEMANTIC_SIMILARITY',\n 'CLASSIFICATION',\n 'CLUSTERING',\n 'RETRIEVAL_DOCUMENT',\n 'RETRIEVAL_QUERY',\n 'QUESTION_ANSWERING',\n 'FACT_VERIFICATION',\n 'CODE_RETRIEVAL_QUERY',\n ])\n .optional(),\n});\n\nexport type GoogleGenerativeAIEmbeddingProviderOptions = z.infer<\n typeof googleGenerativeAIEmbeddingProviderOptions\n>;\n","import {\n LanguageModelV2,\n LanguageModelV2CallWarning,\n LanguageModelV2Content,\n LanguageModelV2FinishReason,\n LanguageModelV2Source,\n LanguageModelV2StreamPart,\n LanguageModelV2Usage,\n SharedV2ProviderMetadata,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n ParseResult,\n Resolvable,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n generateId,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';\nimport { convertToGoogleGenerativeAIMessages } from './convert-to-google-generative-ai-messages';\nimport { getModelPath } from './get-model-path';\nimport { googleFailedResponseHandler } from './google-error';\nimport { GoogleGenerativeAIContentPart } from './google-generative-ai-prompt';\nimport {\n GoogleGenerativeAIModelId,\n googleGenerativeAIProviderOptions,\n} from './google-generative-ai-options';\nimport { prepareTools } from './google-prepare-tools';\nimport { mapGoogleGenerativeAIFinishReason } from './map-google-generative-ai-finish-reason';\nimport {\n groundingChunkSchema,\n groundingMetadataSchema,\n} from './tool/google-search';\nimport { urlContextMetadataSchema } from './tool/url-context';\n\ntype GoogleGenerativeAIConfig = {\n provider: string;\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n generateId: () => string;\n\n /**\n * The supported URLs for the model.\n */\n supportedUrls?: () => LanguageModelV2['supportedUrls'];\n};\n\nexport class GoogleGenerativeAILanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n\n readonly modelId: GoogleGenerativeAIModelId;\n\n private readonly config: GoogleGenerativeAIConfig;\n private readonly generateId: () => string;\n\n constructor(\n modelId: GoogleGenerativeAIModelId,\n config: GoogleGenerativeAIConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n this.generateId = config.generateId ?? generateId;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n get supportedUrls() {\n return this.config.supportedUrls?.() ?? {};\n }\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n responseFormat,\n seed,\n tools,\n toolChoice,\n providerOptions,\n }: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const warnings: LanguageModelV2CallWarning[] = [];\n\n const googleOptions = await parseProviderOptions({\n provider: 'google',\n providerOptions,\n schema: googleGenerativeAIProviderOptions,\n });\n\n // Add warning if includeThoughts is used with a non-Vertex Google provider\n if (\n googleOptions?.thinkingConfig?.includeThoughts === true &&\n !this.config.provider.startsWith('google.vertex.')\n ) {\n warnings.push({\n type: 'other',\n message:\n \"The 'includeThoughts' option is only supported with the Google Vertex provider \" +\n 'and might not be supported or could behave unexpectedly with the current Google provider ' +\n `(${this.config.provider}).`,\n });\n }\n\n const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');\n\n const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(\n prompt,\n { isGemmaModel },\n );\n\n const {\n tools: googleTools,\n toolConfig: googleToolConfig,\n toolWarnings,\n } = prepareTools({\n tools,\n toolChoice,\n modelId: this.modelId,\n });\n\n return {\n args: {\n generationConfig: {\n // standardized settings:\n maxOutputTokens,\n temperature,\n topK,\n topP,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n seed,\n\n // response format:\n responseMimeType:\n responseFormat?.type === 'json' ? 'application/json' : undefined,\n responseSchema:\n responseFormat?.type === 'json' &&\n responseFormat.schema != null &&\n // Google GenAI does not support all OpenAPI Schema features,\n // so this is needed as an escape hatch:\n // TODO convert into provider option\n (googleOptions?.structuredOutputs ?? true)\n ? convertJSONSchemaToOpenAPISchema(responseFormat.schema)\n : undefined,\n ...(googleOptions?.audioTimestamp && {\n audioTimestamp: googleOptions.audioTimestamp,\n }),\n\n // provider options:\n responseModalities: googleOptions?.responseModalities,\n thinkingConfig: googleOptions?.thinkingConfig,\n },\n contents,\n systemInstruction: isGemmaModel ? undefined : systemInstruction,\n safetySettings: googleOptions?.safetySettings,\n tools: googleTools,\n toolConfig: googleToolConfig,\n cachedContent: googleOptions?.cachedContent,\n labels: googleOptions?.labels,\n },\n warnings: [...warnings, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings } = await this.getArgs(options);\n const body = JSON.stringify(args);\n\n const mergedHeaders = combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n );\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/${getModelPath(\n this.modelId,\n )}:generateContent`,\n headers: mergedHeaders,\n body: args,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(responseSchema),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const candidate = response.candidates[0];\n const content: Array<LanguageModelV2Content> = [];\n\n // map ordered parts to content:\n const parts = candidate.content?.parts ?? [];\n\n const usageMetadata = response.usageMetadata;\n\n // Associates a code execution result with its preceding call.\n let lastCodeExecutionToolCallId: string | undefined;\n\n // Build content array from all parts\n for (const part of parts) {\n if ('executableCode' in part && part.executableCode?.code) {\n const toolCallId = this.config.generateId();\n lastCodeExecutionToolCallId = toolCallId;\n\n content.push({\n type: 'tool-call',\n toolCallId,\n toolName: 'code_execution',\n input: JSON.stringify(part.executableCode),\n providerExecuted: true,\n });\n } else if ('codeExecutionResult' in part && part.codeExecutionResult) {\n content.push({\n type: 'tool-result',\n // Assumes a result directly follows its corresponding call part.\n toolCallId: lastCodeExecutionToolCallId!,\n toolName: 'code_execution',\n result: {\n outcome: part.codeExecutionResult.outcome,\n output: part.codeExecutionResult.output,\n },\n providerExecuted: true,\n });\n // Clear the ID after use to avoid accidental reuse.\n lastCodeExecutionToolCallId = undefined;\n } else if ('text' in part && part.text != null && part.text.length > 0) {\n content.push({\n type: part.thought === true ? 'reasoning' : 'text',\n text: part.text,\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n });\n } else if ('functionCall' in part) {\n content.push({\n type: 'tool-call' as const,\n toolCallId: this.config.generateId(),\n toolName: part.functionCall.name,\n input: JSON.stringify(part.functionCall.args),\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n });\n } else if ('inlineData' in part) {\n content.push({\n type: 'file' as const,\n data: part.inlineData.data,\n mediaType: part.inlineData.mimeType,\n });\n }\n }\n\n const sources =\n extractSources({\n groundingMetadata: candidate.groundingMetadata,\n generateId: this.config.generateId,\n }) ?? [];\n for (const source of sources) {\n content.push(source);\n }\n\n return {\n content,\n finishReason: mapGoogleGenerativeAIFinishReason({\n finishReason: candidate.finishReason,\n hasToolCalls: content.some(part => part.type === 'tool-call'),\n }),\n usage: {\n inputTokens: usageMetadata?.promptTokenCount ?? undefined,\n outputTokens: usageMetadata?.candidatesTokenCount ?? undefined,\n totalTokens: usageMetadata?.totalTokenCount ?? undefined,\n reasoningTokens: usageMetadata?.thoughtsTokenCount ?? undefined,\n cachedInputTokens: usageMetadata?.cachedContentTokenCount ?? undefined,\n },\n warnings,\n providerMetadata: {\n google: {\n groundingMetadata: candidate.groundingMetadata ?? null,\n urlContextMetadata: candidate.urlContextMetadata ?? null,\n safetyRatings: candidate.safetyRatings ?? null,\n usageMetadata: usageMetadata ?? null,\n },\n },\n request: { body },\n response: {\n // TODO timestamp, model id, id\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings } = await this.getArgs(options);\n\n const body = JSON.stringify(args);\n const headers = combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n );\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: `${this.config.baseURL}/${getModelPath(\n this.modelId,\n )}:streamGenerateContent?alt=sse`,\n headers,\n body: args,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let finishReason: LanguageModelV2FinishReason = 'unknown';\n const usage: LanguageModelV2Usage = {\n inputTokens: undefined,\n outputTokens: undefined,\n totalTokens: undefined,\n };\n let providerMetadata: SharedV2ProviderMetadata | undefined = undefined;\n\n const generateId = this.config.generateId;\n let hasToolCalls = false;\n\n // Track active blocks to group consecutive parts of same type\n let currentTextBlockId: string | null = null;\n let currentReasoningBlockId: string | null = null;\n let blockCounter = 0;\n\n // Track emitted sources to prevent duplicates\n const emittedSourceUrls = new Set<string>();\n // Associates a code execution result with its preceding call.\n let lastCodeExecutionToolCallId: string | undefined;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<z.infer<typeof chunkSchema>>,\n LanguageModelV2StreamPart\n >({\n start(controller) {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value;\n\n const usageMetadata = value.usageMetadata;\n\n if (usageMetadata != null) {\n usage.inputTokens = usageMetadata.promptTokenCount ?? undefined;\n usage.outputTokens =\n usageMetadata.candidatesTokenCount ?? undefined;\n usage.totalTokens = usageMetadata.totalTokenCount ?? undefined;\n usage.reasoningTokens =\n usageMetadata.thoughtsTokenCount ?? undefined;\n usage.cachedInputTokens =\n usageMetadata.cachedContentTokenCount ?? undefined;\n }\n\n const candidate = value.candidates?.[0];\n\n // sometimes the API returns an empty candidates array\n if (candidate == null) {\n return;\n }\n\n const content = candidate.content;\n\n const sources = extractSources({\n groundingMetadata: candidate.groundingMetadata,\n generateId,\n });\n if (sources != null) {\n for (const source of sources) {\n if (\n source.sourceType === 'url' &&\n !emittedSourceUrls.has(source.url)\n ) {\n emittedSourceUrls.add(source.url);\n controller.enqueue(source);\n }\n }\n }\n\n // Process tool call's parts before determining finishReason to ensure hasToolCalls is properly set\n if (content != null) {\n // Process text parts individually to handle reasoning parts\n const parts = content.parts ?? [];\n for (const part of parts) {\n if ('executableCode' in part && part.executableCode?.code) {\n const toolCallId = generateId();\n lastCodeExecutionToolCallId = toolCallId;\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId,\n toolName: 'code_execution',\n input: JSON.stringify(part.executableCode),\n providerExecuted: true,\n });\n\n hasToolCalls = true;\n } else if (\n 'codeExecutionResult' in part &&\n part.codeExecutionResult\n ) {\n // Assumes a result directly follows its corresponding call part.\n const toolCallId = lastCodeExecutionToolCallId;\n\n if (toolCallId) {\n controller.enqueue({\n type: 'tool-result',\n toolCallId,\n toolName: 'code_execution',\n result: {\n outcome: part.codeExecutionResult.outcome,\n output: part.codeExecutionResult.output,\n },\n providerExecuted: true,\n });\n // Clear the ID after use.\n lastCodeExecutionToolCallId = undefined;\n }\n } else if (\n 'text' in part &&\n part.text != null &&\n part.text.length > 0\n ) {\n if (part.thought === true) {\n // End any active text block before starting reasoning\n if (currentTextBlockId !== null) {\n controller.enqueue({\n type: 'text-end',\n id: currentTextBlockId,\n });\n currentTextBlockId = null;\n }\n\n // Start new reasoning block if not already active\n if (currentReasoningBlockId === null) {\n currentReasoningBlockId = String(blockCounter++);\n controller.enqueue({\n type: 'reasoning-start',\n id: currentReasoningBlockId,\n providerMetadata: part.thoughtSignature\n ? {\n google: {\n thoughtSignature: part.thoughtSignature,\n },\n }\n : undefined,\n });\n }\n\n controller.enqueue({\n type: 'reasoning-delta',\n id: currentReasoningBlockId,\n delta: part.text,\n providerMetadata: part.thoughtSignature\n ? {\n google: { thoughtSignature: part.thoughtSignature },\n }\n : undefined,\n });\n } else {\n // End any active reasoning block before starting text\n if (currentReasoningBlockId !== null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: currentReasoningBlockId,\n });\n currentReasoningBlockId = null;\n }\n\n // Start new text block if not already active\n if (currentTextBlockId === null) {\n currentTextBlockId = String(blockCounter++);\n controller.enqueue({\n type: 'text-start',\n id: currentTextBlockId,\n providerMetadata: part.thoughtSignature\n ? {\n google: {\n thoughtSignature: part.thoughtSignature,\n },\n }\n : undefined,\n });\n }\n\n controller.enqueue({\n type: 'text-delta',\n id: currentTextBlockId,\n delta: part.text,\n providerMetadata: part.thoughtSignature\n ? {\n google: { thoughtSignature: part.thoughtSignature },\n }\n : undefined,\n });\n }\n }\n }\n\n const inlineDataParts = getInlineDataParts(content.parts);\n if (inlineDataParts != null) {\n for (const part of inlineDataParts) {\n controller.enqueue({\n type: 'file',\n mediaType: part.inlineData.mimeType,\n data: part.inlineData.data,\n });\n }\n }\n\n const toolCallDeltas = getToolCallsFromParts({\n parts: content.parts,\n generateId,\n });\n\n if (toolCallDeltas != null) {\n for (const toolCall of toolCallDeltas) {\n controller.enqueue({\n type: 'tool-input-start',\n id: toolCall.toolCallId,\n toolName: toolCall.toolName,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-input-delta',\n id: toolCall.toolCallId,\n delta: toolCall.args,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-input-end',\n id: toolCall.toolCallId,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId: toolCall.toolCallId,\n toolName: toolCall.toolName,\n input: toolCall.args,\n providerMetadata: toolCall.providerMetadata,\n });\n\n hasToolCalls = true;\n }\n }\n }\n\n if (candidate.finishReason != null) {\n finishReason = mapGoogleGenerativeAIFinishReason({\n finishReason: candidate.finishReason,\n hasToolCalls,\n });\n\n providerMetadata = {\n google: {\n groundingMetadata: candidate.groundingMetadata ?? null,\n urlContextMetadata: candidate.urlContextMetadata ?? null,\n safetyRatings: candidate.safetyRatings ?? null,\n },\n };\n if (usageMetadata != null) {\n providerMetadata.google.usageMetadata = usageMetadata;\n }\n }\n },\n\n flush(controller) {\n // Close any open blocks before finishing\n if (currentTextBlockId !== null) {\n controller.enqueue({\n type: 'text-end',\n id: currentTextBlockId,\n });\n }\n if (currentReasoningBlockId !== null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: currentReasoningBlockId,\n });\n }\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage,\n providerMetadata,\n });\n },\n }),\n ),\n response: { headers: responseHeaders },\n request: { body },\n };\n }\n}\n\nfunction getToolCallsFromParts({\n parts,\n generateId,\n}: {\n parts: z.infer<typeof contentSchema>['parts'];\n generateId: () => string;\n}) {\n const functionCallParts = parts?.filter(\n part => 'functionCall' in part,\n ) as Array<\n GoogleGenerativeAIContentPart & {\n functionCall: { name: string; args: unknown };\n thoughtSignature?: string | null;\n }\n >;\n\n return functionCallParts == null || functionCallParts.length === 0\n ? undefined\n : functionCallParts.map(part => ({\n type: 'tool-call' as const,\n toolCallId: generateId(),\n toolName: part.functionCall.name,\n args: JSON.stringify(part.functionCall.args),\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n }));\n}\n\nfunction getInlineDataParts(parts: z.infer<typeof contentSchema>['parts']) {\n return parts?.filter(\n (\n part,\n ): part is {\n inlineData: { mimeType: string; data: string };\n } => 'inlineData' in part,\n );\n}\n\nfunction extractSources({\n groundingMetadata,\n generateId,\n}: {\n groundingMetadata: z.infer<typeof groundingMetadataSchema> | undefined | null;\n generateId: () => string;\n}): undefined | LanguageModelV2Source[] {\n return groundingMetadata?.groundingChunks\n ?.filter(\n (\n chunk,\n ): chunk is z.infer<typeof groundingChunkSchema> & {\n web: { uri: string; title?: string };\n } => chunk.web != null,\n )\n .map(chunk => ({\n type: 'source',\n sourceType: 'url',\n id: generateId(),\n url: chunk.web.uri,\n title: chunk.web.title,\n }));\n}\n\nconst contentSchema = z.object({\n parts: z\n .array(\n z.union([\n // note: order matters since text can be fully empty\n z.object({\n functionCall: z.object({\n name: z.string(),\n args: z.unknown(),\n }),\n thoughtSignature: z.string().nullish(),\n }),\n z.object({\n inlineData: z.object({\n mimeType: z.string(),\n data: z.string(),\n }),\n }),\n z.object({\n executableCode: z\n .object({\n language: z.string(),\n code: z.string(),\n })\n .nullish(),\n codeExecutionResult: z\n .object({\n outcome: z.string(),\n output: z.string(),\n })\n .nullish(),\n text: z.string().nullish(),\n thought: z.boolean().nullish(),\n thoughtSignature: z.string().nullish(),\n }),\n ]),\n )\n .nullish(),\n});\n\n// https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters\nexport const safetyRatingSchema = z.object({\n category: z.string().nullish(),\n probability: z.string().nullish(),\n probabilityScore: z.number().nullish(),\n severity: z.string().nullish(),\n severityScore: z.number().nullish(),\n blocked: z.boolean().nullish(),\n});\n\nconst usageSchema = z.object({\n cachedContentTokenCount: z.number().nullish(),\n thoughtsTokenCount: z.number().nullish(),\n promptTokenCount: z.number().nullish(),\n candidatesTokenCount: z.number().nullish(),\n totalTokenCount: z.number().nullish(),\n});\n\nconst responseSchema = z.object({\n candidates: z.array(\n z.object({\n content: contentSchema.nullish().or(z.object({}).strict()),\n finishReason: z.string().nullish(),\n safetyRatings: z.array(safetyRatingSchema).nullish(),\n groundingMetadata: groundingMetadataSchema.nullish(),\n urlContextMetadata: urlContextMetadataSchema.nullish(),\n }),\n ),\n usageMetadata: usageSchema.nullish(),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst chunkSchema = z.object({\n candidates: z\n .array(\n z.object({\n content: contentSchema.nullish(),\n finishReason: z.string().nullish(),\n safetyRatings: z.array(safetyRatingSchema).nullish(),\n groundingMetadata: groundingMetadataSchema.nullish(),\n urlContextMetadata: urlContextMetadataSchema.nullish(),\n }),\n )\n .nullish(),\n usageMetadata: usageSchema.nullish(),\n});\n","import { JSONSchema7Definition } from '@ai-sdk/provider';\n\n/**\n * Converts JSON Schema 7 to OpenAPI Schema 3.0\n */\nexport function convertJSONSchemaToOpenAPISchema(\n jsonSchema: JSONSchema7Definition | undefined,\n): unknown {\n // parameters need to be undefined if they are empty objects:\n if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {\n return undefined;\n }\n\n if (typeof jsonSchema === 'boolean') {\n return { type: 'boolean', properties: {} };\n }\n\n const {\n type,\n description,\n required,\n properties,\n items,\n allOf,\n anyOf,\n oneOf,\n format,\n const: constValue,\n minLength,\n enum: enumValues,\n } = jsonSchema;\n\n const result: Record<string, unknown> = {};\n\n if (description) result.description = description;\n if (required) result.required = required;\n if (format) result.format = format;\n\n if (constValue !== undefined) {\n result.enum = [constValue];\n }\n\n // Handle type\n if (type) {\n if (Array.isArray(type)) {\n if (type.includes('null')) {\n result.type = type.filter(t => t !== 'null')[0];\n result.nullable = true;\n } else {\n result.type = type;\n }\n } else if (type === 'null') {\n result.type = 'null';\n } else {\n result.type = type;\n }\n }\n\n // Handle enum\n if (enumValues !== undefined) {\n result.enum = enumValues;\n }\n\n if (properties != null) {\n result.properties = Object.entries(properties).reduce(\n (acc, [key, value]) => {\n acc[key] = convertJSONSchemaToOpenAPISchema(value);\n return acc;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (items) {\n result.items = Array.isArray(items)\n ? items.map(convertJSONSchemaToOpenAPISchema)\n : convertJSONSchemaToOpenAPISchema(items);\n }\n\n if (allOf) {\n result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);\n }\n if (anyOf) {\n // Handle cases where anyOf includes a null type\n if (\n anyOf.some(\n schema => typeof schema === 'object' && schema?.type === 'null',\n )\n ) {\n const nonNullSchemas = anyOf.filter(\n schema => !(typeof schema === 'object' && schema?.type === 'null'),\n );\n\n if (nonNullSchemas.length === 1) {\n // If there's only one non-null schema, convert it and make it nullable\n const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);\n if (typeof converted === 'object') {\n result.nullable = true;\n Object.assign(result, converted);\n }\n } else {\n // If there are multiple non-null schemas, keep them in anyOf\n result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);\n result.nullable = true;\n }\n } else {\n result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);\n }\n }\n if (oneOf) {\n result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);\n }\n\n if (minLength !== undefined) {\n result.minLength = minLength;\n }\n\n return result;\n}\n\nfunction isEmptyObjectSchema(jsonSchema: JSONSchema7Definition): boolean {\n return (\n jsonSchema != null &&\n typeof jsonSchema === 'object' &&\n jsonSchema.type === 'object' &&\n (jsonSchema.properties == null ||\n Object.keys(jsonSchema.properties).length === 0) &&\n !jsonSchema.additionalProperties\n );\n}\n","import {\n LanguageModelV2Prompt,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport {\n GoogleGenerativeAIContent,\n GoogleGenerativeAIContentPart,\n GoogleGenerativeAIPrompt,\n} from './google-generative-ai-prompt';\nimport { convertToBase64 } from '@ai-sdk/provider-utils';\n\nexport function convertToGoogleGenerativeAIMessages(\n prompt: LanguageModelV2Prompt,\n options?: { isGemmaModel?: boolean },\n): GoogleGenerativeAIPrompt {\n const systemInstructionParts: Array<{ text: string }> = [];\n const contents: Array<GoogleGenerativeAIContent> = [];\n let systemMessagesAllowed = true;\n const isGemmaModel = options?.isGemmaModel ?? false;\n\n for (const { role, content } of prompt) {\n switch (role) {\n case 'system': {\n if (!systemMessagesAllowed) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'system messages are only supported at the beginning of the conversation',\n });\n }\n\n systemInstructionParts.push({ text: content });\n break;\n }\n\n case 'user': {\n systemMessagesAllowed = false;\n\n const parts: GoogleGenerativeAIContentPart[] = [];\n\n for (const part of content) {\n switch (part.type) {\n case 'text': {\n parts.push({ text: part.text });\n break;\n }\n\n case 'file': {\n // default to image/jpeg for unknown image/* types\n const mediaType =\n part.mediaType === 'image/*' ? 'image/jpeg' : part.mediaType;\n\n parts.push(\n part.data instanceof URL\n ? {\n fileData: {\n mimeType: mediaType,\n fileUri: part.data.toString(),\n },\n }\n : {\n inlineData: {\n mimeType: mediaType,\n data: convertToBase64(part.data),\n },\n },\n );\n\n break;\n }\n }\n }\n\n contents.push({ role: 'user', parts });\n break;\n }\n\n case 'assistant': {\n systemMessagesAllowed = false;\n\n contents.push({\n role: 'model',\n parts: content\n .map(part => {\n switch (part.type) {\n case 'text': {\n return part.text.length === 0\n ? undefined\n : {\n text: part.text,\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n\n case 'reasoning': {\n return part.text.length === 0\n ? undefined\n : {\n text: part.text,\n thought: true,\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n\n case 'file': {\n if (part.mediaType !== 'image/png') {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Only PNG images are supported in assistant messages',\n });\n }\n\n if (part.data instanceof URL) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'File data URLs in assistant messages are not supported',\n });\n }\n\n return {\n inlineData: {\n mimeType: part.mediaType,\n data: convertToBase64(part.data),\n },\n };\n }\n\n case 'tool-call': {\n return {\n functionCall: {\n name: part.toolName,\n args: part.input,\n },\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n }\n })\n .filter(part => part !== undefined),\n });\n break;\n }\n\n case 'tool': {\n systemMessagesAllowed = false;\n\n contents.push({\n role: 'user',\n parts: content.map(part => ({\n functionResponse: {\n name: part.toolName,\n response: {\n name: part.toolName,\n content: part.output.value,\n },\n },\n })),\n });\n break;\n }\n }\n }\n\n if (\n isGemmaModel &&\n systemInstructionParts.length > 0 &&\n contents.length > 0 &&\n contents[0].role === 'user'\n ) {\n const systemText = systemInstructionParts\n .map(part => part.text)\n .join('\\n\\n');\n\n contents[0].parts.unshift({ text: systemText + '\\n\\n' });\n }\n\n return {\n systemInstruction:\n systemInstructionParts.length > 0 && !isGemmaModel\n ? { parts: systemInstructionParts }\n : undefined,\n contents,\n };\n}\n","export function getModelPath(modelId: string): string {\n return modelId.includes('/') ? modelId : `models/${modelId}`;\n}\n","import { z } from 'zod/v4';\n\nexport type GoogleGenerativeAIModelId =\n // Stable models\n // https://ai.google.dev/gemini-api/docs/models/gemini\n | 'gemini-1.5-flash'\n | 'gemini-1.5-flash-latest'\n | 'gemini-1.5-flash-001'\n | 'gemini-1.5-flash-002'\n | 'gemini-1.5-flash-8b'\n | 'gemini-1.5-flash-8b-latest'\n | 'gemini-1.5-flash-8b-001'\n | 'gemini-1.5-pro'\n | 'gemini-1.5-pro-latest'\n | 'gemini-1.5-pro-001'\n | 'gemini-1.5-pro-002'\n | 'gemini-2.0-flash'\n | 'gemini-2.0-flash-001'\n | 'gemini-2.0-flash-live-001'\n | 'gemini-2.0-flash-lite'\n | 'gemini-2.0-pro-exp-02-05'\n | 'gemini-2.0-flash-thinking-exp-01-21'\n | 'gemini-2.0-flash-exp'\n | 'gemini-2.5-pro'\n | 'gemini-2.5-flash'\n | 'gemini-2.5-flash-lite'\n // Experimental models\n // https://ai.google.dev/gemini-api/docs/models/experimental-models\n | 'gemini-2.5-pro-exp-03-25'\n | 'gemini-2.5-flash-preview-04-17'\n | 'gemini-exp-1206'\n | 'gemma-3-12b-it'\n | 'gemma-3-27b-it'\n | (string & {});\n\nexport const googleGenerativeAIProviderOptions = z.object({\n responseModalities: z.array(z.enum(['TEXT', 'IMAGE'])).optional(),\n\n thinkingConfig: z\n .object({\n thinkingBudget: z.number().optional(),\n includeThoughts: z.boolean().optional(),\n })\n .optional(),\n\n /**\nOptional.\nThe name of the cached content used as context to serve the prediction.\nFormat: cachedContents/{cachedContent}\n */\n cachedContent: z.string().optional(),\n\n /**\n * Optional. Enable structured output. Default is true.\n *\n * This is useful when the JSON Schema contains elements that are\n * not supported by the OpenAPI schema version that\n * Google Generative AI uses. You can use this to disable\n * structured outputs if you need to.\n */\n structuredOutputs: z.boolean().optional(),\n\n /**\nOptional. A list of unique safety settings for blocking unsafe content.\n */\n safetySettings: z\n .array(\n z.object({\n category: z.enum([\n 'HARM_CATEGORY_UNSPECIFIED',\n 'HARM_CATEGORY_HATE_SPEECH',\n 'HARM_CATEGORY_DANGEROUS_CONTENT',\n 'HARM_CATEGORY_HARASSMENT',\n 'HARM_CATEGORY_SEXUALLY_EXPLICIT',\n 'HARM_CATEGORY_CIVIC_INTEGRITY',\n ]),\n threshold: z.enum([\n 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',\n 'BLOCK_LOW_AND_ABOVE',\n 'BLOCK_MEDIUM_AND_ABOVE',\n 'BLOCK_ONLY_HIGH',\n 'BLOCK_NONE',\n 'OFF',\n ]),\n }),\n )\n .optional(),\n\n threshold: z\n .enum([\n 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',\n 'BLOCK_LOW_AND_ABOVE',\n 'BLOCK_MEDIUM_AND_ABOVE',\n 'BLOCK_ONLY_HIGH',\n 'BLOCK_NONE',\n 'OFF',\n ])\n .optional(),\n\n /**\n * Optional. Enables timestamp understanding for audio-only files.\n *\n * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding\n */\n audioTimestamp: z.boolean().optional(),\n\n /**\n * Optional. Defines labels used in billing reports. Available on Vertex AI only.\n *\n * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls\n */\n labels: z.record(z.string(), z.string()).optional(),\n});\n\nexport type GoogleGenerativeAIProviderOptions = z.infer<\n typeof googleGenerativeAIProviderOptions\n>;\n","import {\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';\nimport { GoogleGenerativeAIModelId } from './google-generative-ai-options';\n\nexport function prepareTools({\n tools,\n toolChoice,\n modelId,\n}: {\n tools: LanguageModelV2CallOptions['tools'];\n toolChoice?: LanguageModelV2CallOptions['toolChoice'];\n modelId: GoogleGenerativeAIModelId;\n}): {\n tools:\n | {\n functionDeclarations: Array<{\n name: string;\n description: string;\n parameters: unknown;\n }>;\n }\n | Record<string, any>\n | undefined;\n toolConfig:\n | undefined\n | {\n functionCallingConfig: {\n mode: 'AUTO' | 'NONE' | 'ANY';\n allowedFunctionNames?: string[];\n };\n };\n toolWarnings: LanguageModelV2CallWarning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n\n const isGemini2 = modelId.includes('gemini-2');\n const supportsDynamicRetrieval =\n modelId.includes('gemini-1.5-flash') && !modelId.includes('-8b');\n\n if (tools == null) {\n return { tools: undefined, toolConfig: undefined, toolWarnings };\n }\n\n // Check for mixed tool types and add warnings\n const hasFunctionTools = tools.some(tool => tool.type === 'function');\n const hasProviderDefinedTools = tools.some(\n tool => tool.type === 'provider-defined',\n );\n\n if (hasFunctionTools && hasProviderDefinedTools) {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool: tools.find(tool => tool.type === 'function')!,\n details:\n 'Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both.',\n });\n }\n\n if (hasProviderDefinedTools) {\n const googleTools: Record<string, any> = {};\n\n const providerDefinedTools = tools.filter(\n tool => tool.type === 'provider-defined',\n );\n providerDefinedTools.forEach(tool => {\n switch (tool.id) {\n case 'google.google_search':\n if (isGemini2) {\n googleTools.googleSearch = {};\n } else if (supportsDynamicRetrieval) {\n // For non-Gemini-2 models that don't support dynamic retrieval, use basic googleSearchRetrieval\n googleTools.googleSearchRetrieval = {\n dynamicRetrievalConfig: {\n mode: tool.args.mode as\n | 'MODE_DYNAMIC'\n | 'MODE_UNSPECIFIED'\n | undefined,\n dynamicThreshold: tool.args.dynamicThreshold as\n | number\n | undefined,\n },\n };\n } else {\n googleTools.googleSearchRetrieval = {};\n }\n break;\n case 'google.url_context':\n if (isGemini2) {\n googleTools.urlContext = {};\n } else {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n details:\n 'The URL context tool is not supported with other Gemini models than Gemini 2.',\n });\n }\n break;\n case 'google.code_execution':\n if (isGemini2) {\n googleTools.codeExecution = {};\n } else {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n details:\n 'The code execution tools is not supported with other Gemini models than Gemini 2.',\n });\n }\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n });\n\n return {\n tools: Object.keys(googleTools).length > 0 ? googleTools : undefined,\n toolConfig: undefined,\n toolWarnings,\n };\n }\n\n const functionDeclarations = [];\n for (const tool of tools) {\n switch (tool.type) {\n case 'function':\n functionDeclarations.push({\n name: tool.name,\n description: tool.description ?? '',\n parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema),\n });\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n }\n\n if (toolChoice == null) {\n return {\n tools: { functionDeclarations },\n toolConfig: undefined,\n toolWarnings,\n };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'AUTO' } },\n toolWarnings,\n };\n case 'none':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'NONE' } },\n toolWarnings,\n };\n case 'required':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'ANY' } },\n toolWarnings,\n };\n case 'tool':\n return {\n tools: { functionDeclarations },\n toolConfig: {\n functionCallingConfig: {\n mode: 'ANY',\n allowedFunctionNames: [toolChoice.toolName],\n },\n },\n toolWarnings,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import { LanguageModelV2FinishReason } from '@ai-sdk/provider';\n\nexport function mapGoogleGenerativeAIFinishReason({\n finishReason,\n hasToolCalls,\n}: {\n finishReason: string | null | undefined;\n hasToolCalls: boolean;\n}): LanguageModelV2FinishReason {\n switch (finishReason) {\n case 'STOP':\n return hasToolCalls ? 'tool-calls' : 'stop';\n case 'MAX_TOKENS':\n return 'length';\n case 'IMAGE_SAFETY':\n case 'RECITATION':\n case 'SAFETY':\n case 'BLOCKLIST':\n case 'PROHIBITED_CONTENT':\n case 'SPII':\n return 'content-filter';\n case 'FINISH_REASON_UNSPECIFIED':\n case 'OTHER':\n return 'other';\n case 'MALFORMED_FUNCTION_CALL':\n return 'error';\n default:\n return 'unknown';\n }\n}\n","import { createProviderDefinedToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://ai.google.dev/gemini-api/docs/google-search\n// https://ai.google.dev/api/generate-content#GroundingSupport\n// https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-search\n\nexport const groundingChunkSchema = z.object({\n web: z.object({ uri: z.string(), title: z.string() }).nullish(),\n retrievedContext: z.object({ uri: z.string(), title: z.string() }).nullish(),\n});\n\nexport const groundingMetadataSchema = z.object({\n webSearchQueries: z.array(z.string()).nullish(),\n retrievalQueries: z.array(z.string()).nullish(),\n searchEntryPoint: z.object({ renderedContent: z.string() }).nullish(),\n groundingChunks: z.array(groundingChunkSchema).nullish(),\n groundingSupports: z\n .array(\n z.object({\n segment: z.object({\n startIndex: z.number().nullish(),\n endIndex: z.number().nullish(),\n text: z.string().nullish(),\n }),\n segment_text: z.string().nullish(),\n groundingChunkIndices: z.array(z.number()).nullish(),\n supportChunkIndices: z.array(z.number()).nullish(),\n confidenceScores: z.array(z.number()).nullish(),\n confidenceScore: z.array(z.number()).nullish(),\n }),\n )\n .nullish(),\n retrievalMetadata: z\n .union([\n z.object({\n webDynamicRetrievalScore: z.number(),\n }),\n z.object({}),\n ])\n .nullish(),\n});\n\nexport const googleSearch = createProviderDefinedToolFactory<\n {},\n {\n /**\n * The mode of the predictor to be used in dynamic retrieval. The following modes are supported:\n * - MODE_DYNAMIC: Run retrieval only when system decides it is necessary\n * - MODE_UNSPECIFIED: Always trigger retrieval\n * @default MODE_UNSPECIFIED\n */\n mode?: 'MODE_DYNAMIC' | 'MODE_UNSPECIFIED';\n\n /**\n * The threshold to be used in dynamic retrieval (if not set, a system default value is used).\n */\n dynamicThreshold?: number;\n }\n>({\n id: 'google.google_search',\n name: 'google_search',\n inputSchema: z.object({\n mode: z\n .enum(['MODE_DYNAMIC', 'MODE_UNSPECIFIED'])\n .default('MODE_UNSPECIFIED'),\n dynamicThreshold: z.number().default(1),\n }),\n});\n","import { createProviderDefinedToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://ai.google.dev/api/generate-content#UrlRetrievalMetadata\nconst urlMetadataSchema = z.object({\n retrievedUrl: z.string(),\n urlRetrievalStatus: z.string(),\n});\n\nexport const urlContextMetadataSchema = z.object({\n urlMetadata: z.array(urlMetadataSchema),\n});\n\nexport const urlContext = createProviderDefinedToolFactory<\n {\n // Url context does not have any input schema, it will directly use the url from the prompt\n },\n {}\n>({\n id: 'google.url_context',\n name: 'url_context',\n inputSchema: z.object({}),\n});\n","import { createProviderDefinedToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * A tool that enables the model to generate and run Python code.\n *\n * @note Ensure the selected model supports Code Execution.\n * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.\n *\n * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)\n */\nexport const codeExecution = createProviderDefinedToolFactoryWithOutputSchema<\n {\n language: string;\n code: string;\n },\n {\n outcome: string;\n output: string;\n },\n {}\n>({\n id: 'google.code_execution',\n name: 'code_execution',\n inputSchema: z.object({\n language: z.string().describe('The programming language of the code.'),\n code: z.string().describe('The code to be executed.'),\n }),\n outputSchema: z.object({\n outcome: z\n .string()\n .describe('The outcome of the execution (e.g., \"OUTCOME_OK\").'),\n output: z.string().describe('The output from the code execution.'),\n }),\n});\n","import { codeExecution } from './tool/code-execution';\nimport { googleSearch } from './tool/google-search';\nimport { urlContext } from './tool/url-context';\n\nexport const googleTools = {\n /**\n * Creates a Google search tool that gives Google direct access to real-time web content.\n * Must have name \"google_search\".\n */\n googleSearch,\n\n /**\n * Creates a URL context tool that gives Google direct access to real-time web content.\n * Must have name \"url_context\".\n */\n urlContext,\n /**\n * A tool that enables the model to generate and run Python code.\n * Must have name \"code_execution\".\n *\n * @note Ensure the selected model supports Code Execution.\n * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.\n *\n * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)\n */\n codeExecution,\n};\n","import { ImageModelV2, ImageModelV2CallWarning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { googleFailedResponseHandler } from './google-error';\nimport {\n GoogleGenerativeAIImageModelId,\n GoogleGenerativeAIImageSettings,\n} from './google-generative-ai-image-settings';\nimport { FetchFunction, Resolvable } from '@ai-sdk/provider-utils';\n\ninterface GoogleGenerativeAIImageModelConfig {\n provider: string;\n baseURL: string;\n headers?: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n generateId?: () => string;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class GoogleGenerativeAIImageModel implements ImageModelV2 {\n readonly specificationVersion = 'v2';\n\n get maxImagesPerCall(): number {\n // https://ai.google.dev/gemini-api/docs/imagen#imagen-model\n return this.settings.maxImagesPerCall ?? 4;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: GoogleGenerativeAIImageModelId,\n private readonly settings: GoogleGenerativeAIImageSettings,\n private readonly config: GoogleGenerativeAIImageModelConfig,\n ) {}\n\n async doGenerate(\n options: Parameters<ImageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<ImageModelV2['doGenerate']>>> {\n const {\n prompt,\n n = 1,\n size = '1024x1024',\n aspectRatio = '1:1',\n seed,\n providerOptions,\n headers,\n abortSignal,\n } = options;\n const warnings: Array<ImageModelV2CallWarning> = [];\n\n if (size != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'seed',\n details:\n 'This model does not support the `seed` option through this provider.',\n });\n }\n\n const googleOptions = await parseProviderOptions({\n provider: 'google',\n providerOptions,\n schema: googleImageProviderOptionsSchema,\n });\n\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n\n const parameters: Record<string, unknown> = {\n sampleCount: n,\n };\n\n if (aspectRatio != null) {\n parameters.aspectRatio = aspectRatio;\n }\n\n if (googleOptions) {\n Object.assign(parameters, googleOptions);\n }\n\n const body = {\n instances: [{ prompt }],\n parameters,\n };\n\n const { responseHeaders, value: response } = await postJsonToApi<{\n predictions: Array<{ bytesBase64Encoded: string }>;\n }>({\n url: `${this.config.baseURL}/models/${this.modelId}:predict`,\n headers: combineHeaders(await resolve(this.config.headers), headers),\n body,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n googleImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n return {\n images: response.predictions.map(\n (p: { bytesBase64Encoded: string }) => p.bytesBase64Encoded,\n ),\n warnings: warnings ?? [],\n providerMetadata: {\n google: {\n images: response.predictions.map(prediction => ({\n // Add any prediction-specific metadata here\n })),\n },\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n\n// minimal version of the schema\nconst googleImageResponseSchema = z.object({\n predictions: z\n .array(z.object({ bytesBase64Encoded: z.string() }))\n .default([]),\n});\n\n// Note: For the initial GA launch of Imagen 3, safety filters are not configurable.\n// https://ai.google.dev/gemini-api/docs/imagen#imagen-model\nconst googleImageProviderOptionsSchema = z.object({\n personGeneration: z\n .enum(['dont_allow', 'allow_adult', 'allow_all'])\n .nullish(),\n aspectRatio: z.enum(['1:1', '3:4', '4:3', '9:16', '16:9']).nullish(),\n});\n\nexport type GoogleGenerativeAIImageProviderOptions = z.infer<\n typeof googleImageProviderOptionsSchema\n>;\n"],"mappings":";AAMA;AAAA,EAEE,cAAAA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACXP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,KAAAC,UAAS;;;ACZlB,SAAS,sCAAsC;AAC/C,SAAS,SAAS;AAElB,IAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,OAAO,EAAE,OAAO;AAAA,IACd,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,SAAS,EAAE,OAAO;AAAA,IAClB,QAAQ,EAAE,OAAO;AAAA,EACnB,CAAC;AACH,CAAC;AAIM,IAAM,8BAA8B,+BAA+B;AAAA,EACxE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK,MAAM;AACrC,CAAC;;;AChBD,SAAS,KAAAC,UAAS;AAOX,IAAM,6CAA6CA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjE,sBAAsBA,GAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc1C,UAAUA,GACP,KAAK;AAAA,IACJ;AAAA,IACA;AAAA,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,WAAO,gBAAgB,OAAO;AAAA,EAChC;AAEA,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,eAAe;AACxB,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAC9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,QAAQ;AACjB,SAAO;AACT;AAKO,IAAM,SAAS,yBAAyB;","names":["generateId","z","z","responseHeaders","response","rawValue","z","combineHeaders","createJsonResponseHandler","parseProviderOptions","postJsonToApi","resolve","z","_a","z","UnsupportedFunctionalityError","googleTools","UnsupportedFunctionalityError","z","createProviderDefinedToolFactory","z","parseProviderOptions","googleTools","combineHeaders","resolve","postJsonToApi","createJsonResponseHandler","generateId","z","z","combineHeaders","createJsonResponseHandler","parseProviderOptions","postJsonToApi","resolve","z","parseProviderOptions","postJsonToApi","combineHeaders","resolve","createJsonResponseHandler","z","_a","generateId"]}
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.d.mts ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { LanguageModelV2 } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
+ import { z } from 'zod/v4';
5
+
6
+ type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.5-pro-exp-03-25' | 'gemini-2.5-flash-preview-04-17' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
7
+
8
+ type GoogleGenerativeAIConfig = {
9
+ provider: string;
10
+ baseURL: string;
11
+ headers: Resolvable<Record<string, string | undefined>>;
12
+ fetch?: FetchFunction;
13
+ generateId: () => string;
14
+ /**
15
+ * The supported URLs for the model.
16
+ */
17
+ supportedUrls?: () => LanguageModelV2['supportedUrls'];
18
+ };
19
+ declare class GoogleGenerativeAILanguageModel implements LanguageModelV2 {
20
+ readonly specificationVersion = "v2";
21
+ readonly modelId: GoogleGenerativeAIModelId;
22
+ private readonly config;
23
+ private readonly generateId;
24
+ constructor(modelId: GoogleGenerativeAIModelId, config: GoogleGenerativeAIConfig);
25
+ get provider(): string;
26
+ get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
27
+ private getArgs;
28
+ doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
29
+ doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
30
+ }
31
+ declare const safetyRatingSchema: z.ZodObject<{
32
+ category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ probability: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ probabilityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
35
+ severity: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ severityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
37
+ blocked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
38
+ }, z.core.$strip>;
39
+
40
+ declare const googleTools: {
41
+ /**
42
+ * Creates a Google search tool that gives Google direct access to real-time web content.
43
+ * Must have name "google_search".
44
+ */
45
+ googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
46
+ mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
47
+ dynamicThreshold?: number;
48
+ }>;
49
+ /**
50
+ * Creates a URL context tool that gives Google direct access to real-time web content.
51
+ * Must have name "url_context".
52
+ */
53
+ urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
54
+ /**
55
+ * A tool that enables the model to generate and run Python code.
56
+ * Must have name "code_execution".
57
+ *
58
+ * @note Ensure the selected model supports Code Execution.
59
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
60
+ *
61
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
62
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
63
+ */
64
+ codeExecution: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
65
+ language: string;
66
+ code: string;
67
+ }, {
68
+ outcome: string;
69
+ output: string;
70
+ }, {}>;
71
+ };
72
+
73
+ export { GoogleGenerativeAILanguageModel, type GoogleGenerativeAIModelId, googleTools, safetyRatingSchema };
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.d.ts ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { LanguageModelV2 } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
+ import { z } from 'zod/v4';
5
+
6
+ type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.5-pro-exp-03-25' | 'gemini-2.5-flash-preview-04-17' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
7
+
8
+ type GoogleGenerativeAIConfig = {
9
+ provider: string;
10
+ baseURL: string;
11
+ headers: Resolvable<Record<string, string | undefined>>;
12
+ fetch?: FetchFunction;
13
+ generateId: () => string;
14
+ /**
15
+ * The supported URLs for the model.
16
+ */
17
+ supportedUrls?: () => LanguageModelV2['supportedUrls'];
18
+ };
19
+ declare class GoogleGenerativeAILanguageModel implements LanguageModelV2 {
20
+ readonly specificationVersion = "v2";
21
+ readonly modelId: GoogleGenerativeAIModelId;
22
+ private readonly config;
23
+ private readonly generateId;
24
+ constructor(modelId: GoogleGenerativeAIModelId, config: GoogleGenerativeAIConfig);
25
+ get provider(): string;
26
+ get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
27
+ private getArgs;
28
+ doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
29
+ doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
30
+ }
31
+ declare const safetyRatingSchema: z.ZodObject<{
32
+ category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ probability: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ probabilityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
35
+ severity: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ severityScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
37
+ blocked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
38
+ }, z.core.$strip>;
39
+
40
+ declare const googleTools: {
41
+ /**
42
+ * Creates a Google search tool that gives Google direct access to real-time web content.
43
+ * Must have name "google_search".
44
+ */
45
+ googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
46
+ mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
47
+ dynamicThreshold?: number;
48
+ }>;
49
+ /**
50
+ * Creates a URL context tool that gives Google direct access to real-time web content.
51
+ * Must have name "url_context".
52
+ */
53
+ urlContext: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {}>;
54
+ /**
55
+ * A tool that enables the model to generate and run Python code.
56
+ * Must have name "code_execution".
57
+ *
58
+ * @note Ensure the selected model supports Code Execution.
59
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
60
+ *
61
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
62
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
63
+ */
64
+ codeExecution: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
65
+ language: string;
66
+ code: string;
67
+ }, {
68
+ outcome: string;
69
+ output: string;
70
+ }, {}>;
71
+ };
72
+
73
+ export { GoogleGenerativeAILanguageModel, type GoogleGenerativeAIModelId, googleTools, safetyRatingSchema };
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/internal/index.ts
21
+ var internal_exports = {};
22
+ __export(internal_exports, {
23
+ GoogleGenerativeAILanguageModel: () => GoogleGenerativeAILanguageModel,
24
+ googleTools: () => googleTools,
25
+ safetyRatingSchema: () => safetyRatingSchema
26
+ });
27
+ module.exports = __toCommonJS(internal_exports);
28
+
29
+ // src/google-generative-ai-language-model.ts
30
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
31
+ var import_v45 = require("zod/v4");
32
+
33
+ // src/convert-json-schema-to-openapi-schema.ts
34
+ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
35
+ if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
36
+ return void 0;
37
+ }
38
+ if (typeof jsonSchema === "boolean") {
39
+ return { type: "boolean", properties: {} };
40
+ }
41
+ const {
42
+ type,
43
+ description,
44
+ required,
45
+ properties,
46
+ items,
47
+ allOf,
48
+ anyOf,
49
+ oneOf,
50
+ format,
51
+ const: constValue,
52
+ minLength,
53
+ enum: enumValues
54
+ } = jsonSchema;
55
+ const result = {};
56
+ if (description)
57
+ result.description = description;
58
+ if (required)
59
+ result.required = required;
60
+ if (format)
61
+ result.format = format;
62
+ if (constValue !== void 0) {
63
+ result.enum = [constValue];
64
+ }
65
+ if (type) {
66
+ if (Array.isArray(type)) {
67
+ if (type.includes("null")) {
68
+ result.type = type.filter((t) => t !== "null")[0];
69
+ result.nullable = true;
70
+ } else {
71
+ result.type = type;
72
+ }
73
+ } else if (type === "null") {
74
+ result.type = "null";
75
+ } else {
76
+ result.type = type;
77
+ }
78
+ }
79
+ if (enumValues !== void 0) {
80
+ result.enum = enumValues;
81
+ }
82
+ if (properties != null) {
83
+ result.properties = Object.entries(properties).reduce(
84
+ (acc, [key, value]) => {
85
+ acc[key] = convertJSONSchemaToOpenAPISchema(value);
86
+ return acc;
87
+ },
88
+ {}
89
+ );
90
+ }
91
+ if (items) {
92
+ result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
93
+ }
94
+ if (allOf) {
95
+ result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
96
+ }
97
+ if (anyOf) {
98
+ if (anyOf.some(
99
+ (schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"
100
+ )) {
101
+ const nonNullSchemas = anyOf.filter(
102
+ (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
103
+ );
104
+ if (nonNullSchemas.length === 1) {
105
+ const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
106
+ if (typeof converted === "object") {
107
+ result.nullable = true;
108
+ Object.assign(result, converted);
109
+ }
110
+ } else {
111
+ result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
112
+ result.nullable = true;
113
+ }
114
+ } else {
115
+ result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
116
+ }
117
+ }
118
+ if (oneOf) {
119
+ result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
120
+ }
121
+ if (minLength !== void 0) {
122
+ result.minLength = minLength;
123
+ }
124
+ return result;
125
+ }
126
+ function isEmptyObjectSchema(jsonSchema) {
127
+ return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
128
+ }
129
+
130
+ // src/convert-to-google-generative-ai-messages.ts
131
+ var import_provider = require("@ai-sdk/provider");
132
+ var import_provider_utils = require("@ai-sdk/provider-utils");
133
+ function convertToGoogleGenerativeAIMessages(prompt, options) {
134
+ var _a;
135
+ const systemInstructionParts = [];
136
+ const contents = [];
137
+ let systemMessagesAllowed = true;
138
+ const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
139
+ for (const { role, content } of prompt) {
140
+ switch (role) {
141
+ case "system": {
142
+ if (!systemMessagesAllowed) {
143
+ throw new import_provider.UnsupportedFunctionalityError({
144
+ functionality: "system messages are only supported at the beginning of the conversation"
145
+ });
146
+ }
147
+ systemInstructionParts.push({ text: content });
148
+ break;
149
+ }
150
+ case "user": {
151
+ systemMessagesAllowed = false;
152
+ const parts = [];
153
+ for (const part of content) {
154
+ switch (part.type) {
155
+ case "text": {
156
+ parts.push({ text: part.text });
157
+ break;
158
+ }
159
+ case "file": {
160
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
161
+ parts.push(
162
+ part.data instanceof URL ? {
163
+ fileData: {
164
+ mimeType: mediaType,
165
+ fileUri: part.data.toString()
166
+ }
167
+ } : {
168
+ inlineData: {
169
+ mimeType: mediaType,
170
+ data: (0, import_provider_utils.convertToBase64)(part.data)
171
+ }
172
+ }
173
+ );
174
+ break;
175
+ }
176
+ }
177
+ }
178
+ contents.push({ role: "user", parts });
179
+ break;
180
+ }
181
+ case "assistant": {
182
+ systemMessagesAllowed = false;
183
+ contents.push({
184
+ role: "model",
185
+ parts: content.map((part) => {
186
+ var _a2, _b, _c, _d, _e, _f;
187
+ switch (part.type) {
188
+ case "text": {
189
+ return part.text.length === 0 ? void 0 : {
190
+ text: part.text,
191
+ thoughtSignature: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature
192
+ };
193
+ }
194
+ case "reasoning": {
195
+ return part.text.length === 0 ? void 0 : {
196
+ text: part.text,
197
+ thought: true,
198
+ thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
199
+ };
200
+ }
201
+ case "file": {
202
+ if (part.mediaType !== "image/png") {
203
+ throw new import_provider.UnsupportedFunctionalityError({
204
+ functionality: "Only PNG images are supported in assistant messages"
205
+ });
206
+ }
207
+ if (part.data instanceof URL) {
208
+ throw new import_provider.UnsupportedFunctionalityError({
209
+ functionality: "File data URLs in assistant messages are not supported"
210
+ });
211
+ }
212
+ return {
213
+ inlineData: {
214
+ mimeType: part.mediaType,
215
+ data: (0, import_provider_utils.convertToBase64)(part.data)
216
+ }
217
+ };
218
+ }
219
+ case "tool-call": {
220
+ return {
221
+ functionCall: {
222
+ name: part.toolName,
223
+ args: part.input
224
+ },
225
+ thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
226
+ };
227
+ }
228
+ }
229
+ }).filter((part) => part !== void 0)
230
+ });
231
+ break;
232
+ }
233
+ case "tool": {
234
+ systemMessagesAllowed = false;
235
+ contents.push({
236
+ role: "user",
237
+ parts: content.map((part) => ({
238
+ functionResponse: {
239
+ name: part.toolName,
240
+ response: {
241
+ name: part.toolName,
242
+ content: part.output.value
243
+ }
244
+ }
245
+ }))
246
+ });
247
+ break;
248
+ }
249
+ }
250
+ }
251
+ if (isGemmaModel && systemInstructionParts.length > 0 && contents.length > 0 && contents[0].role === "user") {
252
+ const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
253
+ contents[0].parts.unshift({ text: systemText + "\n\n" });
254
+ }
255
+ return {
256
+ systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
257
+ contents
258
+ };
259
+ }
260
+
261
+ // src/get-model-path.ts
262
+ function getModelPath(modelId) {
263
+ return modelId.includes("/") ? modelId : `models/${modelId}`;
264
+ }
265
+
266
+ // src/google-error.ts
267
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
268
+ var import_v4 = require("zod/v4");
269
+ var googleErrorDataSchema = import_v4.z.object({
270
+ error: import_v4.z.object({
271
+ code: import_v4.z.number().nullable(),
272
+ message: import_v4.z.string(),
273
+ status: import_v4.z.string()
274
+ })
275
+ });
276
+ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
277
+ errorSchema: googleErrorDataSchema,
278
+ errorToMessage: (data) => data.error.message
279
+ });
280
+
281
+ // src/google-generative-ai-options.ts
282
+ var import_v42 = require("zod/v4");
283
+ var googleGenerativeAIProviderOptions = import_v42.z.object({
284
+ responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
285
+ thinkingConfig: import_v42.z.object({
286
+ thinkingBudget: import_v42.z.number().optional(),
287
+ includeThoughts: import_v42.z.boolean().optional()
288
+ }).optional(),
289
+ /**
290
+ Optional.
291
+ The name of the cached content used as context to serve the prediction.
292
+ Format: cachedContents/{cachedContent}
293
+ */
294
+ cachedContent: import_v42.z.string().optional(),
295
+ /**
296
+ * Optional. Enable structured output. Default is true.
297
+ *
298
+ * This is useful when the JSON Schema contains elements that are
299
+ * not supported by the OpenAPI schema version that
300
+ * Google Generative AI uses. You can use this to disable
301
+ * structured outputs if you need to.
302
+ */
303
+ structuredOutputs: import_v42.z.boolean().optional(),
304
+ /**
305
+ Optional. A list of unique safety settings for blocking unsafe content.
306
+ */
307
+ safetySettings: import_v42.z.array(
308
+ import_v42.z.object({
309
+ category: import_v42.z.enum([
310
+ "HARM_CATEGORY_UNSPECIFIED",
311
+ "HARM_CATEGORY_HATE_SPEECH",
312
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
313
+ "HARM_CATEGORY_HARASSMENT",
314
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT",
315
+ "HARM_CATEGORY_CIVIC_INTEGRITY"
316
+ ]),
317
+ threshold: import_v42.z.enum([
318
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
319
+ "BLOCK_LOW_AND_ABOVE",
320
+ "BLOCK_MEDIUM_AND_ABOVE",
321
+ "BLOCK_ONLY_HIGH",
322
+ "BLOCK_NONE",
323
+ "OFF"
324
+ ])
325
+ })
326
+ ).optional(),
327
+ threshold: import_v42.z.enum([
328
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
329
+ "BLOCK_LOW_AND_ABOVE",
330
+ "BLOCK_MEDIUM_AND_ABOVE",
331
+ "BLOCK_ONLY_HIGH",
332
+ "BLOCK_NONE",
333
+ "OFF"
334
+ ]).optional(),
335
+ /**
336
+ * Optional. Enables timestamp understanding for audio-only files.
337
+ *
338
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
339
+ */
340
+ audioTimestamp: import_v42.z.boolean().optional(),
341
+ /**
342
+ * Optional. Defines labels used in billing reports. Available on Vertex AI only.
343
+ *
344
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
345
+ */
346
+ labels: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional()
347
+ });
348
+
349
+ // src/google-prepare-tools.ts
350
+ var import_provider2 = require("@ai-sdk/provider");
351
+ function prepareTools({
352
+ tools,
353
+ toolChoice,
354
+ modelId
355
+ }) {
356
+ var _a;
357
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
358
+ const toolWarnings = [];
359
+ const isGemini2 = modelId.includes("gemini-2");
360
+ const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
361
+ if (tools == null) {
362
+ return { tools: void 0, toolConfig: void 0, toolWarnings };
363
+ }
364
+ const hasFunctionTools = tools.some((tool) => tool.type === "function");
365
+ const hasProviderDefinedTools = tools.some(
366
+ (tool) => tool.type === "provider-defined"
367
+ );
368
+ if (hasFunctionTools && hasProviderDefinedTools) {
369
+ toolWarnings.push({
370
+ type: "unsupported-tool",
371
+ tool: tools.find((tool) => tool.type === "function"),
372
+ details: "Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both."
373
+ });
374
+ }
375
+ if (hasProviderDefinedTools) {
376
+ const googleTools2 = {};
377
+ const providerDefinedTools = tools.filter(
378
+ (tool) => tool.type === "provider-defined"
379
+ );
380
+ providerDefinedTools.forEach((tool) => {
381
+ switch (tool.id) {
382
+ case "google.google_search":
383
+ if (isGemini2) {
384
+ googleTools2.googleSearch = {};
385
+ } else if (supportsDynamicRetrieval) {
386
+ googleTools2.googleSearchRetrieval = {
387
+ dynamicRetrievalConfig: {
388
+ mode: tool.args.mode,
389
+ dynamicThreshold: tool.args.dynamicThreshold
390
+ }
391
+ };
392
+ } else {
393
+ googleTools2.googleSearchRetrieval = {};
394
+ }
395
+ break;
396
+ case "google.url_context":
397
+ if (isGemini2) {
398
+ googleTools2.urlContext = {};
399
+ } else {
400
+ toolWarnings.push({
401
+ type: "unsupported-tool",
402
+ tool,
403
+ details: "The URL context tool is not supported with other Gemini models than Gemini 2."
404
+ });
405
+ }
406
+ break;
407
+ case "google.code_execution":
408
+ if (isGemini2) {
409
+ googleTools2.codeExecution = {};
410
+ } else {
411
+ toolWarnings.push({
412
+ type: "unsupported-tool",
413
+ tool,
414
+ details: "The code execution tools is not supported with other Gemini models than Gemini 2."
415
+ });
416
+ }
417
+ break;
418
+ default:
419
+ toolWarnings.push({ type: "unsupported-tool", tool });
420
+ break;
421
+ }
422
+ });
423
+ return {
424
+ tools: Object.keys(googleTools2).length > 0 ? googleTools2 : void 0,
425
+ toolConfig: void 0,
426
+ toolWarnings
427
+ };
428
+ }
429
+ const functionDeclarations = [];
430
+ for (const tool of tools) {
431
+ switch (tool.type) {
432
+ case "function":
433
+ functionDeclarations.push({
434
+ name: tool.name,
435
+ description: (_a = tool.description) != null ? _a : "",
436
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
437
+ });
438
+ break;
439
+ default:
440
+ toolWarnings.push({ type: "unsupported-tool", tool });
441
+ break;
442
+ }
443
+ }
444
+ if (toolChoice == null) {
445
+ return {
446
+ tools: { functionDeclarations },
447
+ toolConfig: void 0,
448
+ toolWarnings
449
+ };
450
+ }
451
+ const type = toolChoice.type;
452
+ switch (type) {
453
+ case "auto":
454
+ return {
455
+ tools: { functionDeclarations },
456
+ toolConfig: { functionCallingConfig: { mode: "AUTO" } },
457
+ toolWarnings
458
+ };
459
+ case "none":
460
+ return {
461
+ tools: { functionDeclarations },
462
+ toolConfig: { functionCallingConfig: { mode: "NONE" } },
463
+ toolWarnings
464
+ };
465
+ case "required":
466
+ return {
467
+ tools: { functionDeclarations },
468
+ toolConfig: { functionCallingConfig: { mode: "ANY" } },
469
+ toolWarnings
470
+ };
471
+ case "tool":
472
+ return {
473
+ tools: { functionDeclarations },
474
+ toolConfig: {
475
+ functionCallingConfig: {
476
+ mode: "ANY",
477
+ allowedFunctionNames: [toolChoice.toolName]
478
+ }
479
+ },
480
+ toolWarnings
481
+ };
482
+ default: {
483
+ const _exhaustiveCheck = type;
484
+ throw new import_provider2.UnsupportedFunctionalityError({
485
+ functionality: `tool choice type: ${_exhaustiveCheck}`
486
+ });
487
+ }
488
+ }
489
+ }
490
+
491
+ // src/map-google-generative-ai-finish-reason.ts
492
+ function mapGoogleGenerativeAIFinishReason({
493
+ finishReason,
494
+ hasToolCalls
495
+ }) {
496
+ switch (finishReason) {
497
+ case "STOP":
498
+ return hasToolCalls ? "tool-calls" : "stop";
499
+ case "MAX_TOKENS":
500
+ return "length";
501
+ case "IMAGE_SAFETY":
502
+ case "RECITATION":
503
+ case "SAFETY":
504
+ case "BLOCKLIST":
505
+ case "PROHIBITED_CONTENT":
506
+ case "SPII":
507
+ return "content-filter";
508
+ case "FINISH_REASON_UNSPECIFIED":
509
+ case "OTHER":
510
+ return "other";
511
+ case "MALFORMED_FUNCTION_CALL":
512
+ return "error";
513
+ default:
514
+ return "unknown";
515
+ }
516
+ }
517
+
518
+ // src/tool/google-search.ts
519
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
520
+ var import_v43 = require("zod/v4");
521
+ var groundingChunkSchema = import_v43.z.object({
522
+ web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish(),
523
+ retrievedContext: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish()
524
+ });
525
+ var groundingMetadataSchema = import_v43.z.object({
526
+ webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
527
+ retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
528
+ searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
529
+ groundingChunks: import_v43.z.array(groundingChunkSchema).nullish(),
530
+ groundingSupports: import_v43.z.array(
531
+ import_v43.z.object({
532
+ segment: import_v43.z.object({
533
+ startIndex: import_v43.z.number().nullish(),
534
+ endIndex: import_v43.z.number().nullish(),
535
+ text: import_v43.z.string().nullish()
536
+ }),
537
+ segment_text: import_v43.z.string().nullish(),
538
+ groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
539
+ supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
540
+ confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
541
+ confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
542
+ })
543
+ ).nullish(),
544
+ retrievalMetadata: import_v43.z.union([
545
+ import_v43.z.object({
546
+ webDynamicRetrievalScore: import_v43.z.number()
547
+ }),
548
+ import_v43.z.object({})
549
+ ]).nullish()
550
+ });
551
+ var googleSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
552
+ id: "google.google_search",
553
+ name: "google_search",
554
+ inputSchema: import_v43.z.object({
555
+ mode: import_v43.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
556
+ dynamicThreshold: import_v43.z.number().default(1)
557
+ })
558
+ });
559
+
560
+ // src/tool/url-context.ts
561
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
562
+ var import_v44 = require("zod/v4");
563
+ var urlMetadataSchema = import_v44.z.object({
564
+ retrievedUrl: import_v44.z.string(),
565
+ urlRetrievalStatus: import_v44.z.string()
566
+ });
567
+ var urlContextMetadataSchema = import_v44.z.object({
568
+ urlMetadata: import_v44.z.array(urlMetadataSchema)
569
+ });
570
+ var urlContext = (0, import_provider_utils4.createProviderDefinedToolFactory)({
571
+ id: "google.url_context",
572
+ name: "url_context",
573
+ inputSchema: import_v44.z.object({})
574
+ });
575
+
576
+ // src/google-generative-ai-language-model.ts
577
+ var GoogleGenerativeAILanguageModel = class {
578
+ constructor(modelId, config) {
579
+ this.specificationVersion = "v2";
580
+ var _a;
581
+ this.modelId = modelId;
582
+ this.config = config;
583
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils5.generateId;
584
+ }
585
+ get provider() {
586
+ return this.config.provider;
587
+ }
588
+ get supportedUrls() {
589
+ var _a, _b, _c;
590
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
591
+ }
592
+ async getArgs({
593
+ prompt,
594
+ maxOutputTokens,
595
+ temperature,
596
+ topP,
597
+ topK,
598
+ frequencyPenalty,
599
+ presencePenalty,
600
+ stopSequences,
601
+ responseFormat,
602
+ seed,
603
+ tools,
604
+ toolChoice,
605
+ providerOptions
606
+ }) {
607
+ var _a, _b;
608
+ const warnings = [];
609
+ const googleOptions = await (0, import_provider_utils5.parseProviderOptions)({
610
+ provider: "google",
611
+ providerOptions,
612
+ schema: googleGenerativeAIProviderOptions
613
+ });
614
+ if (((_a = googleOptions == null ? void 0 : googleOptions.thinkingConfig) == null ? void 0 : _a.includeThoughts) === true && !this.config.provider.startsWith("google.vertex.")) {
615
+ warnings.push({
616
+ type: "other",
617
+ message: `The 'includeThoughts' option is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
618
+ });
619
+ }
620
+ const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
621
+ const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
622
+ prompt,
623
+ { isGemmaModel }
624
+ );
625
+ const {
626
+ tools: googleTools2,
627
+ toolConfig: googleToolConfig,
628
+ toolWarnings
629
+ } = prepareTools({
630
+ tools,
631
+ toolChoice,
632
+ modelId: this.modelId
633
+ });
634
+ return {
635
+ args: {
636
+ generationConfig: {
637
+ // standardized settings:
638
+ maxOutputTokens,
639
+ temperature,
640
+ topK,
641
+ topP,
642
+ frequencyPenalty,
643
+ presencePenalty,
644
+ stopSequences,
645
+ seed,
646
+ // response format:
647
+ responseMimeType: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? "application/json" : void 0,
648
+ responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
649
+ // so this is needed as an escape hatch:
650
+ // TODO convert into provider option
651
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
652
+ ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
653
+ audioTimestamp: googleOptions.audioTimestamp
654
+ },
655
+ // provider options:
656
+ responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
657
+ thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
658
+ },
659
+ contents,
660
+ systemInstruction: isGemmaModel ? void 0 : systemInstruction,
661
+ safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
662
+ tools: googleTools2,
663
+ toolConfig: googleToolConfig,
664
+ cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
665
+ labels: googleOptions == null ? void 0 : googleOptions.labels
666
+ },
667
+ warnings: [...warnings, ...toolWarnings]
668
+ };
669
+ }
670
+ async doGenerate(options) {
671
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
672
+ const { args, warnings } = await this.getArgs(options);
673
+ const body = JSON.stringify(args);
674
+ const mergedHeaders = (0, import_provider_utils5.combineHeaders)(
675
+ await (0, import_provider_utils5.resolve)(this.config.headers),
676
+ options.headers
677
+ );
678
+ const {
679
+ responseHeaders,
680
+ value: response,
681
+ rawValue: rawResponse
682
+ } = await (0, import_provider_utils5.postJsonToApi)({
683
+ url: `${this.config.baseURL}/${getModelPath(
684
+ this.modelId
685
+ )}:generateContent`,
686
+ headers: mergedHeaders,
687
+ body: args,
688
+ failedResponseHandler: googleFailedResponseHandler,
689
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(responseSchema),
690
+ abortSignal: options.abortSignal,
691
+ fetch: this.config.fetch
692
+ });
693
+ const candidate = response.candidates[0];
694
+ const content = [];
695
+ const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
696
+ const usageMetadata = response.usageMetadata;
697
+ let lastCodeExecutionToolCallId;
698
+ for (const part of parts) {
699
+ if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
700
+ const toolCallId = this.config.generateId();
701
+ lastCodeExecutionToolCallId = toolCallId;
702
+ content.push({
703
+ type: "tool-call",
704
+ toolCallId,
705
+ toolName: "code_execution",
706
+ input: JSON.stringify(part.executableCode),
707
+ providerExecuted: true
708
+ });
709
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
710
+ content.push({
711
+ type: "tool-result",
712
+ // Assumes a result directly follows its corresponding call part.
713
+ toolCallId: lastCodeExecutionToolCallId,
714
+ toolName: "code_execution",
715
+ result: {
716
+ outcome: part.codeExecutionResult.outcome,
717
+ output: part.codeExecutionResult.output
718
+ },
719
+ providerExecuted: true
720
+ });
721
+ lastCodeExecutionToolCallId = void 0;
722
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
723
+ content.push({
724
+ type: part.thought === true ? "reasoning" : "text",
725
+ text: part.text,
726
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
727
+ });
728
+ } else if ("functionCall" in part) {
729
+ content.push({
730
+ type: "tool-call",
731
+ toolCallId: this.config.generateId(),
732
+ toolName: part.functionCall.name,
733
+ input: JSON.stringify(part.functionCall.args),
734
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
735
+ });
736
+ } else if ("inlineData" in part) {
737
+ content.push({
738
+ type: "file",
739
+ data: part.inlineData.data,
740
+ mediaType: part.inlineData.mimeType
741
+ });
742
+ }
743
+ }
744
+ const sources = (_d = extractSources({
745
+ groundingMetadata: candidate.groundingMetadata,
746
+ generateId: this.config.generateId
747
+ })) != null ? _d : [];
748
+ for (const source of sources) {
749
+ content.push(source);
750
+ }
751
+ return {
752
+ content,
753
+ finishReason: mapGoogleGenerativeAIFinishReason({
754
+ finishReason: candidate.finishReason,
755
+ hasToolCalls: content.some((part) => part.type === "tool-call")
756
+ }),
757
+ usage: {
758
+ inputTokens: (_e = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _e : void 0,
759
+ outputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _f : void 0,
760
+ totalTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _g : void 0,
761
+ reasoningTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _h : void 0,
762
+ cachedInputTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _i : void 0
763
+ },
764
+ warnings,
765
+ providerMetadata: {
766
+ google: {
767
+ groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
768
+ urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
769
+ safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
770
+ usageMetadata: usageMetadata != null ? usageMetadata : null
771
+ }
772
+ },
773
+ request: { body },
774
+ response: {
775
+ // TODO timestamp, model id, id
776
+ headers: responseHeaders,
777
+ body: rawResponse
778
+ }
779
+ };
780
+ }
781
+ async doStream(options) {
782
+ const { args, warnings } = await this.getArgs(options);
783
+ const body = JSON.stringify(args);
784
+ const headers = (0, import_provider_utils5.combineHeaders)(
785
+ await (0, import_provider_utils5.resolve)(this.config.headers),
786
+ options.headers
787
+ );
788
+ const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
789
+ url: `${this.config.baseURL}/${getModelPath(
790
+ this.modelId
791
+ )}:streamGenerateContent?alt=sse`,
792
+ headers,
793
+ body: args,
794
+ failedResponseHandler: googleFailedResponseHandler,
795
+ successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(chunkSchema),
796
+ abortSignal: options.abortSignal,
797
+ fetch: this.config.fetch
798
+ });
799
+ let finishReason = "unknown";
800
+ const usage = {
801
+ inputTokens: void 0,
802
+ outputTokens: void 0,
803
+ totalTokens: void 0
804
+ };
805
+ let providerMetadata = void 0;
806
+ const generateId2 = this.config.generateId;
807
+ let hasToolCalls = false;
808
+ let currentTextBlockId = null;
809
+ let currentReasoningBlockId = null;
810
+ let blockCounter = 0;
811
+ const emittedSourceUrls = /* @__PURE__ */ new Set();
812
+ let lastCodeExecutionToolCallId;
813
+ return {
814
+ stream: response.pipeThrough(
815
+ new TransformStream({
816
+ start(controller) {
817
+ controller.enqueue({ type: "stream-start", warnings });
818
+ },
819
+ transform(chunk, controller) {
820
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
821
+ if (options.includeRawChunks) {
822
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
823
+ }
824
+ if (!chunk.success) {
825
+ controller.enqueue({ type: "error", error: chunk.error });
826
+ return;
827
+ }
828
+ const value = chunk.value;
829
+ const usageMetadata = value.usageMetadata;
830
+ if (usageMetadata != null) {
831
+ usage.inputTokens = (_a = usageMetadata.promptTokenCount) != null ? _a : void 0;
832
+ usage.outputTokens = (_b = usageMetadata.candidatesTokenCount) != null ? _b : void 0;
833
+ usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
834
+ usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
835
+ usage.cachedInputTokens = (_e = usageMetadata.cachedContentTokenCount) != null ? _e : void 0;
836
+ }
837
+ const candidate = (_f = value.candidates) == null ? void 0 : _f[0];
838
+ if (candidate == null) {
839
+ return;
840
+ }
841
+ const content = candidate.content;
842
+ const sources = extractSources({
843
+ groundingMetadata: candidate.groundingMetadata,
844
+ generateId: generateId2
845
+ });
846
+ if (sources != null) {
847
+ for (const source of sources) {
848
+ if (source.sourceType === "url" && !emittedSourceUrls.has(source.url)) {
849
+ emittedSourceUrls.add(source.url);
850
+ controller.enqueue(source);
851
+ }
852
+ }
853
+ }
854
+ if (content != null) {
855
+ const parts = (_g = content.parts) != null ? _g : [];
856
+ for (const part of parts) {
857
+ if ("executableCode" in part && ((_h = part.executableCode) == null ? void 0 : _h.code)) {
858
+ const toolCallId = generateId2();
859
+ lastCodeExecutionToolCallId = toolCallId;
860
+ controller.enqueue({
861
+ type: "tool-call",
862
+ toolCallId,
863
+ toolName: "code_execution",
864
+ input: JSON.stringify(part.executableCode),
865
+ providerExecuted: true
866
+ });
867
+ hasToolCalls = true;
868
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
869
+ const toolCallId = lastCodeExecutionToolCallId;
870
+ if (toolCallId) {
871
+ controller.enqueue({
872
+ type: "tool-result",
873
+ toolCallId,
874
+ toolName: "code_execution",
875
+ result: {
876
+ outcome: part.codeExecutionResult.outcome,
877
+ output: part.codeExecutionResult.output
878
+ },
879
+ providerExecuted: true
880
+ });
881
+ lastCodeExecutionToolCallId = void 0;
882
+ }
883
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
884
+ if (part.thought === true) {
885
+ if (currentTextBlockId !== null) {
886
+ controller.enqueue({
887
+ type: "text-end",
888
+ id: currentTextBlockId
889
+ });
890
+ currentTextBlockId = null;
891
+ }
892
+ if (currentReasoningBlockId === null) {
893
+ currentReasoningBlockId = String(blockCounter++);
894
+ controller.enqueue({
895
+ type: "reasoning-start",
896
+ id: currentReasoningBlockId,
897
+ providerMetadata: part.thoughtSignature ? {
898
+ google: {
899
+ thoughtSignature: part.thoughtSignature
900
+ }
901
+ } : void 0
902
+ });
903
+ }
904
+ controller.enqueue({
905
+ type: "reasoning-delta",
906
+ id: currentReasoningBlockId,
907
+ delta: part.text,
908
+ providerMetadata: part.thoughtSignature ? {
909
+ google: { thoughtSignature: part.thoughtSignature }
910
+ } : void 0
911
+ });
912
+ } else {
913
+ if (currentReasoningBlockId !== null) {
914
+ controller.enqueue({
915
+ type: "reasoning-end",
916
+ id: currentReasoningBlockId
917
+ });
918
+ currentReasoningBlockId = null;
919
+ }
920
+ if (currentTextBlockId === null) {
921
+ currentTextBlockId = String(blockCounter++);
922
+ controller.enqueue({
923
+ type: "text-start",
924
+ id: currentTextBlockId,
925
+ providerMetadata: part.thoughtSignature ? {
926
+ google: {
927
+ thoughtSignature: part.thoughtSignature
928
+ }
929
+ } : void 0
930
+ });
931
+ }
932
+ controller.enqueue({
933
+ type: "text-delta",
934
+ id: currentTextBlockId,
935
+ delta: part.text,
936
+ providerMetadata: part.thoughtSignature ? {
937
+ google: { thoughtSignature: part.thoughtSignature }
938
+ } : void 0
939
+ });
940
+ }
941
+ }
942
+ }
943
+ const inlineDataParts = getInlineDataParts(content.parts);
944
+ if (inlineDataParts != null) {
945
+ for (const part of inlineDataParts) {
946
+ controller.enqueue({
947
+ type: "file",
948
+ mediaType: part.inlineData.mimeType,
949
+ data: part.inlineData.data
950
+ });
951
+ }
952
+ }
953
+ const toolCallDeltas = getToolCallsFromParts({
954
+ parts: content.parts,
955
+ generateId: generateId2
956
+ });
957
+ if (toolCallDeltas != null) {
958
+ for (const toolCall of toolCallDeltas) {
959
+ controller.enqueue({
960
+ type: "tool-input-start",
961
+ id: toolCall.toolCallId,
962
+ toolName: toolCall.toolName,
963
+ providerMetadata: toolCall.providerMetadata
964
+ });
965
+ controller.enqueue({
966
+ type: "tool-input-delta",
967
+ id: toolCall.toolCallId,
968
+ delta: toolCall.args,
969
+ providerMetadata: toolCall.providerMetadata
970
+ });
971
+ controller.enqueue({
972
+ type: "tool-input-end",
973
+ id: toolCall.toolCallId,
974
+ providerMetadata: toolCall.providerMetadata
975
+ });
976
+ controller.enqueue({
977
+ type: "tool-call",
978
+ toolCallId: toolCall.toolCallId,
979
+ toolName: toolCall.toolName,
980
+ input: toolCall.args,
981
+ providerMetadata: toolCall.providerMetadata
982
+ });
983
+ hasToolCalls = true;
984
+ }
985
+ }
986
+ }
987
+ if (candidate.finishReason != null) {
988
+ finishReason = mapGoogleGenerativeAIFinishReason({
989
+ finishReason: candidate.finishReason,
990
+ hasToolCalls
991
+ });
992
+ providerMetadata = {
993
+ google: {
994
+ groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
995
+ urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
996
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
997
+ }
998
+ };
999
+ if (usageMetadata != null) {
1000
+ providerMetadata.google.usageMetadata = usageMetadata;
1001
+ }
1002
+ }
1003
+ },
1004
+ flush(controller) {
1005
+ if (currentTextBlockId !== null) {
1006
+ controller.enqueue({
1007
+ type: "text-end",
1008
+ id: currentTextBlockId
1009
+ });
1010
+ }
1011
+ if (currentReasoningBlockId !== null) {
1012
+ controller.enqueue({
1013
+ type: "reasoning-end",
1014
+ id: currentReasoningBlockId
1015
+ });
1016
+ }
1017
+ controller.enqueue({
1018
+ type: "finish",
1019
+ finishReason,
1020
+ usage,
1021
+ providerMetadata
1022
+ });
1023
+ }
1024
+ })
1025
+ ),
1026
+ response: { headers: responseHeaders },
1027
+ request: { body }
1028
+ };
1029
+ }
1030
+ };
1031
+ function getToolCallsFromParts({
1032
+ parts,
1033
+ generateId: generateId2
1034
+ }) {
1035
+ const functionCallParts = parts == null ? void 0 : parts.filter(
1036
+ (part) => "functionCall" in part
1037
+ );
1038
+ return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1039
+ type: "tool-call",
1040
+ toolCallId: generateId2(),
1041
+ toolName: part.functionCall.name,
1042
+ args: JSON.stringify(part.functionCall.args),
1043
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1044
+ }));
1045
+ }
1046
+ function getInlineDataParts(parts) {
1047
+ return parts == null ? void 0 : parts.filter(
1048
+ (part) => "inlineData" in part
1049
+ );
1050
+ }
1051
+ function extractSources({
1052
+ groundingMetadata,
1053
+ generateId: generateId2
1054
+ }) {
1055
+ var _a;
1056
+ return (_a = groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks) == null ? void 0 : _a.filter(
1057
+ (chunk) => chunk.web != null
1058
+ ).map((chunk) => ({
1059
+ type: "source",
1060
+ sourceType: "url",
1061
+ id: generateId2(),
1062
+ url: chunk.web.uri,
1063
+ title: chunk.web.title
1064
+ }));
1065
+ }
1066
+ var contentSchema = import_v45.z.object({
1067
+ parts: import_v45.z.array(
1068
+ import_v45.z.union([
1069
+ // note: order matters since text can be fully empty
1070
+ import_v45.z.object({
1071
+ functionCall: import_v45.z.object({
1072
+ name: import_v45.z.string(),
1073
+ args: import_v45.z.unknown()
1074
+ }),
1075
+ thoughtSignature: import_v45.z.string().nullish()
1076
+ }),
1077
+ import_v45.z.object({
1078
+ inlineData: import_v45.z.object({
1079
+ mimeType: import_v45.z.string(),
1080
+ data: import_v45.z.string()
1081
+ })
1082
+ }),
1083
+ import_v45.z.object({
1084
+ executableCode: import_v45.z.object({
1085
+ language: import_v45.z.string(),
1086
+ code: import_v45.z.string()
1087
+ }).nullish(),
1088
+ codeExecutionResult: import_v45.z.object({
1089
+ outcome: import_v45.z.string(),
1090
+ output: import_v45.z.string()
1091
+ }).nullish(),
1092
+ text: import_v45.z.string().nullish(),
1093
+ thought: import_v45.z.boolean().nullish(),
1094
+ thoughtSignature: import_v45.z.string().nullish()
1095
+ })
1096
+ ])
1097
+ ).nullish()
1098
+ });
1099
+ var safetyRatingSchema = import_v45.z.object({
1100
+ category: import_v45.z.string().nullish(),
1101
+ probability: import_v45.z.string().nullish(),
1102
+ probabilityScore: import_v45.z.number().nullish(),
1103
+ severity: import_v45.z.string().nullish(),
1104
+ severityScore: import_v45.z.number().nullish(),
1105
+ blocked: import_v45.z.boolean().nullish()
1106
+ });
1107
+ var usageSchema = import_v45.z.object({
1108
+ cachedContentTokenCount: import_v45.z.number().nullish(),
1109
+ thoughtsTokenCount: import_v45.z.number().nullish(),
1110
+ promptTokenCount: import_v45.z.number().nullish(),
1111
+ candidatesTokenCount: import_v45.z.number().nullish(),
1112
+ totalTokenCount: import_v45.z.number().nullish()
1113
+ });
1114
+ var responseSchema = import_v45.z.object({
1115
+ candidates: import_v45.z.array(
1116
+ import_v45.z.object({
1117
+ content: contentSchema.nullish().or(import_v45.z.object({}).strict()),
1118
+ finishReason: import_v45.z.string().nullish(),
1119
+ safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1120
+ groundingMetadata: groundingMetadataSchema.nullish(),
1121
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1122
+ })
1123
+ ),
1124
+ usageMetadata: usageSchema.nullish()
1125
+ });
1126
+ var chunkSchema = import_v45.z.object({
1127
+ candidates: import_v45.z.array(
1128
+ import_v45.z.object({
1129
+ content: contentSchema.nullish(),
1130
+ finishReason: import_v45.z.string().nullish(),
1131
+ safetyRatings: import_v45.z.array(safetyRatingSchema).nullish(),
1132
+ groundingMetadata: groundingMetadataSchema.nullish(),
1133
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1134
+ })
1135
+ ).nullish(),
1136
+ usageMetadata: usageSchema.nullish()
1137
+ });
1138
+
1139
+ // src/tool/code-execution.ts
1140
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1141
+ var import_v46 = require("zod/v4");
1142
+ var codeExecution = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
1143
+ id: "google.code_execution",
1144
+ name: "code_execution",
1145
+ inputSchema: import_v46.z.object({
1146
+ language: import_v46.z.string().describe("The programming language of the code."),
1147
+ code: import_v46.z.string().describe("The code to be executed.")
1148
+ }),
1149
+ outputSchema: import_v46.z.object({
1150
+ outcome: import_v46.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1151
+ output: import_v46.z.string().describe("The output from the code execution.")
1152
+ })
1153
+ });
1154
+
1155
+ // src/google-tools.ts
1156
+ var googleTools = {
1157
+ /**
1158
+ * Creates a Google search tool that gives Google direct access to real-time web content.
1159
+ * Must have name "google_search".
1160
+ */
1161
+ googleSearch,
1162
+ /**
1163
+ * Creates a URL context tool that gives Google direct access to real-time web content.
1164
+ * Must have name "url_context".
1165
+ */
1166
+ urlContext,
1167
+ /**
1168
+ * A tool that enables the model to generate and run Python code.
1169
+ * Must have name "code_execution".
1170
+ *
1171
+ * @note Ensure the selected model supports Code Execution.
1172
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
1173
+ *
1174
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
1175
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
1176
+ */
1177
+ codeExecution
1178
+ };
1179
+ // Annotate the CommonJS export names for ESM import in node:
1180
+ 0 && (module.exports = {
1181
+ GoogleGenerativeAILanguageModel,
1182
+ googleTools,
1183
+ safetyRatingSchema
1184
+ });
1185
+ //# sourceMappingURL=index.js.map
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../../src/internal/index.ts","../../src/google-generative-ai-language-model.ts","../../src/convert-json-schema-to-openapi-schema.ts","../../src/convert-to-google-generative-ai-messages.ts","../../src/get-model-path.ts","../../src/google-error.ts","../../src/google-generative-ai-options.ts","../../src/google-prepare-tools.ts","../../src/map-google-generative-ai-finish-reason.ts","../../src/tool/google-search.ts","../../src/tool/url-context.ts","../../src/tool/code-execution.ts","../../src/google-tools.ts"],"sourcesContent":["export * from '../google-generative-ai-language-model';\nexport { googleTools } from '../google-tools';\nexport type { GoogleGenerativeAIModelId } from '../google-generative-ai-options';\n","import {\n LanguageModelV2,\n LanguageModelV2CallWarning,\n LanguageModelV2Content,\n LanguageModelV2FinishReason,\n LanguageModelV2Source,\n LanguageModelV2StreamPart,\n LanguageModelV2Usage,\n SharedV2ProviderMetadata,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n ParseResult,\n Resolvable,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n generateId,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';\nimport { convertToGoogleGenerativeAIMessages } from './convert-to-google-generative-ai-messages';\nimport { getModelPath } from './get-model-path';\nimport { googleFailedResponseHandler } from './google-error';\nimport { GoogleGenerativeAIContentPart } from './google-generative-ai-prompt';\nimport {\n GoogleGenerativeAIModelId,\n googleGenerativeAIProviderOptions,\n} from './google-generative-ai-options';\nimport { prepareTools } from './google-prepare-tools';\nimport { mapGoogleGenerativeAIFinishReason } from './map-google-generative-ai-finish-reason';\nimport {\n groundingChunkSchema,\n groundingMetadataSchema,\n} from './tool/google-search';\nimport { urlContextMetadataSchema } from './tool/url-context';\n\ntype GoogleGenerativeAIConfig = {\n provider: string;\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n generateId: () => string;\n\n /**\n * The supported URLs for the model.\n */\n supportedUrls?: () => LanguageModelV2['supportedUrls'];\n};\n\nexport class GoogleGenerativeAILanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n\n readonly modelId: GoogleGenerativeAIModelId;\n\n private readonly config: GoogleGenerativeAIConfig;\n private readonly generateId: () => string;\n\n constructor(\n modelId: GoogleGenerativeAIModelId,\n config: GoogleGenerativeAIConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n this.generateId = config.generateId ?? generateId;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n get supportedUrls() {\n return this.config.supportedUrls?.() ?? {};\n }\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n responseFormat,\n seed,\n tools,\n toolChoice,\n providerOptions,\n }: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const warnings: LanguageModelV2CallWarning[] = [];\n\n const googleOptions = await parseProviderOptions({\n provider: 'google',\n providerOptions,\n schema: googleGenerativeAIProviderOptions,\n });\n\n // Add warning if includeThoughts is used with a non-Vertex Google provider\n if (\n googleOptions?.thinkingConfig?.includeThoughts === true &&\n !this.config.provider.startsWith('google.vertex.')\n ) {\n warnings.push({\n type: 'other',\n message:\n \"The 'includeThoughts' option is only supported with the Google Vertex provider \" +\n 'and might not be supported or could behave unexpectedly with the current Google provider ' +\n `(${this.config.provider}).`,\n });\n }\n\n const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');\n\n const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(\n prompt,\n { isGemmaModel },\n );\n\n const {\n tools: googleTools,\n toolConfig: googleToolConfig,\n toolWarnings,\n } = prepareTools({\n tools,\n toolChoice,\n modelId: this.modelId,\n });\n\n return {\n args: {\n generationConfig: {\n // standardized settings:\n maxOutputTokens,\n temperature,\n topK,\n topP,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n seed,\n\n // response format:\n responseMimeType:\n responseFormat?.type === 'json' ? 'application/json' : undefined,\n responseSchema:\n responseFormat?.type === 'json' &&\n responseFormat.schema != null &&\n // Google GenAI does not support all OpenAPI Schema features,\n // so this is needed as an escape hatch:\n // TODO convert into provider option\n (googleOptions?.structuredOutputs ?? true)\n ? convertJSONSchemaToOpenAPISchema(responseFormat.schema)\n : undefined,\n ...(googleOptions?.audioTimestamp && {\n audioTimestamp: googleOptions.audioTimestamp,\n }),\n\n // provider options:\n responseModalities: googleOptions?.responseModalities,\n thinkingConfig: googleOptions?.thinkingConfig,\n },\n contents,\n systemInstruction: isGemmaModel ? undefined : systemInstruction,\n safetySettings: googleOptions?.safetySettings,\n tools: googleTools,\n toolConfig: googleToolConfig,\n cachedContent: googleOptions?.cachedContent,\n labels: googleOptions?.labels,\n },\n warnings: [...warnings, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings } = await this.getArgs(options);\n const body = JSON.stringify(args);\n\n const mergedHeaders = combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n );\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/${getModelPath(\n this.modelId,\n )}:generateContent`,\n headers: mergedHeaders,\n body: args,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(responseSchema),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const candidate = response.candidates[0];\n const content: Array<LanguageModelV2Content> = [];\n\n // map ordered parts to content:\n const parts = candidate.content?.parts ?? [];\n\n const usageMetadata = response.usageMetadata;\n\n // Associates a code execution result with its preceding call.\n let lastCodeExecutionToolCallId: string | undefined;\n\n // Build content array from all parts\n for (const part of parts) {\n if ('executableCode' in part && part.executableCode?.code) {\n const toolCallId = this.config.generateId();\n lastCodeExecutionToolCallId = toolCallId;\n\n content.push({\n type: 'tool-call',\n toolCallId,\n toolName: 'code_execution',\n input: JSON.stringify(part.executableCode),\n providerExecuted: true,\n });\n } else if ('codeExecutionResult' in part && part.codeExecutionResult) {\n content.push({\n type: 'tool-result',\n // Assumes a result directly follows its corresponding call part.\n toolCallId: lastCodeExecutionToolCallId!,\n toolName: 'code_execution',\n result: {\n outcome: part.codeExecutionResult.outcome,\n output: part.codeExecutionResult.output,\n },\n providerExecuted: true,\n });\n // Clear the ID after use to avoid accidental reuse.\n lastCodeExecutionToolCallId = undefined;\n } else if ('text' in part && part.text != null && part.text.length > 0) {\n content.push({\n type: part.thought === true ? 'reasoning' : 'text',\n text: part.text,\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n });\n } else if ('functionCall' in part) {\n content.push({\n type: 'tool-call' as const,\n toolCallId: this.config.generateId(),\n toolName: part.functionCall.name,\n input: JSON.stringify(part.functionCall.args),\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n });\n } else if ('inlineData' in part) {\n content.push({\n type: 'file' as const,\n data: part.inlineData.data,\n mediaType: part.inlineData.mimeType,\n });\n }\n }\n\n const sources =\n extractSources({\n groundingMetadata: candidate.groundingMetadata,\n generateId: this.config.generateId,\n }) ?? [];\n for (const source of sources) {\n content.push(source);\n }\n\n return {\n content,\n finishReason: mapGoogleGenerativeAIFinishReason({\n finishReason: candidate.finishReason,\n hasToolCalls: content.some(part => part.type === 'tool-call'),\n }),\n usage: {\n inputTokens: usageMetadata?.promptTokenCount ?? undefined,\n outputTokens: usageMetadata?.candidatesTokenCount ?? undefined,\n totalTokens: usageMetadata?.totalTokenCount ?? undefined,\n reasoningTokens: usageMetadata?.thoughtsTokenCount ?? undefined,\n cachedInputTokens: usageMetadata?.cachedContentTokenCount ?? undefined,\n },\n warnings,\n providerMetadata: {\n google: {\n groundingMetadata: candidate.groundingMetadata ?? null,\n urlContextMetadata: candidate.urlContextMetadata ?? null,\n safetyRatings: candidate.safetyRatings ?? null,\n usageMetadata: usageMetadata ?? null,\n },\n },\n request: { body },\n response: {\n // TODO timestamp, model id, id\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings } = await this.getArgs(options);\n\n const body = JSON.stringify(args);\n const headers = combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n );\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: `${this.config.baseURL}/${getModelPath(\n this.modelId,\n )}:streamGenerateContent?alt=sse`,\n headers,\n body: args,\n failedResponseHandler: googleFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let finishReason: LanguageModelV2FinishReason = 'unknown';\n const usage: LanguageModelV2Usage = {\n inputTokens: undefined,\n outputTokens: undefined,\n totalTokens: undefined,\n };\n let providerMetadata: SharedV2ProviderMetadata | undefined = undefined;\n\n const generateId = this.config.generateId;\n let hasToolCalls = false;\n\n // Track active blocks to group consecutive parts of same type\n let currentTextBlockId: string | null = null;\n let currentReasoningBlockId: string | null = null;\n let blockCounter = 0;\n\n // Track emitted sources to prevent duplicates\n const emittedSourceUrls = new Set<string>();\n // Associates a code execution result with its preceding call.\n let lastCodeExecutionToolCallId: string | undefined;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<z.infer<typeof chunkSchema>>,\n LanguageModelV2StreamPart\n >({\n start(controller) {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value;\n\n const usageMetadata = value.usageMetadata;\n\n if (usageMetadata != null) {\n usage.inputTokens = usageMetadata.promptTokenCount ?? undefined;\n usage.outputTokens =\n usageMetadata.candidatesTokenCount ?? undefined;\n usage.totalTokens = usageMetadata.totalTokenCount ?? undefined;\n usage.reasoningTokens =\n usageMetadata.thoughtsTokenCount ?? undefined;\n usage.cachedInputTokens =\n usageMetadata.cachedContentTokenCount ?? undefined;\n }\n\n const candidate = value.candidates?.[0];\n\n // sometimes the API returns an empty candidates array\n if (candidate == null) {\n return;\n }\n\n const content = candidate.content;\n\n const sources = extractSources({\n groundingMetadata: candidate.groundingMetadata,\n generateId,\n });\n if (sources != null) {\n for (const source of sources) {\n if (\n source.sourceType === 'url' &&\n !emittedSourceUrls.has(source.url)\n ) {\n emittedSourceUrls.add(source.url);\n controller.enqueue(source);\n }\n }\n }\n\n // Process tool call's parts before determining finishReason to ensure hasToolCalls is properly set\n if (content != null) {\n // Process text parts individually to handle reasoning parts\n const parts = content.parts ?? [];\n for (const part of parts) {\n if ('executableCode' in part && part.executableCode?.code) {\n const toolCallId = generateId();\n lastCodeExecutionToolCallId = toolCallId;\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId,\n toolName: 'code_execution',\n input: JSON.stringify(part.executableCode),\n providerExecuted: true,\n });\n\n hasToolCalls = true;\n } else if (\n 'codeExecutionResult' in part &&\n part.codeExecutionResult\n ) {\n // Assumes a result directly follows its corresponding call part.\n const toolCallId = lastCodeExecutionToolCallId;\n\n if (toolCallId) {\n controller.enqueue({\n type: 'tool-result',\n toolCallId,\n toolName: 'code_execution',\n result: {\n outcome: part.codeExecutionResult.outcome,\n output: part.codeExecutionResult.output,\n },\n providerExecuted: true,\n });\n // Clear the ID after use.\n lastCodeExecutionToolCallId = undefined;\n }\n } else if (\n 'text' in part &&\n part.text != null &&\n part.text.length > 0\n ) {\n if (part.thought === true) {\n // End any active text block before starting reasoning\n if (currentTextBlockId !== null) {\n controller.enqueue({\n type: 'text-end',\n id: currentTextBlockId,\n });\n currentTextBlockId = null;\n }\n\n // Start new reasoning block if not already active\n if (currentReasoningBlockId === null) {\n currentReasoningBlockId = String(blockCounter++);\n controller.enqueue({\n type: 'reasoning-start',\n id: currentReasoningBlockId,\n providerMetadata: part.thoughtSignature\n ? {\n google: {\n thoughtSignature: part.thoughtSignature,\n },\n }\n : undefined,\n });\n }\n\n controller.enqueue({\n type: 'reasoning-delta',\n id: currentReasoningBlockId,\n delta: part.text,\n providerMetadata: part.thoughtSignature\n ? {\n google: { thoughtSignature: part.thoughtSignature },\n }\n : undefined,\n });\n } else {\n // End any active reasoning block before starting text\n if (currentReasoningBlockId !== null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: currentReasoningBlockId,\n });\n currentReasoningBlockId = null;\n }\n\n // Start new text block if not already active\n if (currentTextBlockId === null) {\n currentTextBlockId = String(blockCounter++);\n controller.enqueue({\n type: 'text-start',\n id: currentTextBlockId,\n providerMetadata: part.thoughtSignature\n ? {\n google: {\n thoughtSignature: part.thoughtSignature,\n },\n }\n : undefined,\n });\n }\n\n controller.enqueue({\n type: 'text-delta',\n id: currentTextBlockId,\n delta: part.text,\n providerMetadata: part.thoughtSignature\n ? {\n google: { thoughtSignature: part.thoughtSignature },\n }\n : undefined,\n });\n }\n }\n }\n\n const inlineDataParts = getInlineDataParts(content.parts);\n if (inlineDataParts != null) {\n for (const part of inlineDataParts) {\n controller.enqueue({\n type: 'file',\n mediaType: part.inlineData.mimeType,\n data: part.inlineData.data,\n });\n }\n }\n\n const toolCallDeltas = getToolCallsFromParts({\n parts: content.parts,\n generateId,\n });\n\n if (toolCallDeltas != null) {\n for (const toolCall of toolCallDeltas) {\n controller.enqueue({\n type: 'tool-input-start',\n id: toolCall.toolCallId,\n toolName: toolCall.toolName,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-input-delta',\n id: toolCall.toolCallId,\n delta: toolCall.args,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-input-end',\n id: toolCall.toolCallId,\n providerMetadata: toolCall.providerMetadata,\n });\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId: toolCall.toolCallId,\n toolName: toolCall.toolName,\n input: toolCall.args,\n providerMetadata: toolCall.providerMetadata,\n });\n\n hasToolCalls = true;\n }\n }\n }\n\n if (candidate.finishReason != null) {\n finishReason = mapGoogleGenerativeAIFinishReason({\n finishReason: candidate.finishReason,\n hasToolCalls,\n });\n\n providerMetadata = {\n google: {\n groundingMetadata: candidate.groundingMetadata ?? null,\n urlContextMetadata: candidate.urlContextMetadata ?? null,\n safetyRatings: candidate.safetyRatings ?? null,\n },\n };\n if (usageMetadata != null) {\n providerMetadata.google.usageMetadata = usageMetadata;\n }\n }\n },\n\n flush(controller) {\n // Close any open blocks before finishing\n if (currentTextBlockId !== null) {\n controller.enqueue({\n type: 'text-end',\n id: currentTextBlockId,\n });\n }\n if (currentReasoningBlockId !== null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: currentReasoningBlockId,\n });\n }\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage,\n providerMetadata,\n });\n },\n }),\n ),\n response: { headers: responseHeaders },\n request: { body },\n };\n }\n}\n\nfunction getToolCallsFromParts({\n parts,\n generateId,\n}: {\n parts: z.infer<typeof contentSchema>['parts'];\n generateId: () => string;\n}) {\n const functionCallParts = parts?.filter(\n part => 'functionCall' in part,\n ) as Array<\n GoogleGenerativeAIContentPart & {\n functionCall: { name: string; args: unknown };\n thoughtSignature?: string | null;\n }\n >;\n\n return functionCallParts == null || functionCallParts.length === 0\n ? undefined\n : functionCallParts.map(part => ({\n type: 'tool-call' as const,\n toolCallId: generateId(),\n toolName: part.functionCall.name,\n args: JSON.stringify(part.functionCall.args),\n providerMetadata: part.thoughtSignature\n ? { google: { thoughtSignature: part.thoughtSignature } }\n : undefined,\n }));\n}\n\nfunction getInlineDataParts(parts: z.infer<typeof contentSchema>['parts']) {\n return parts?.filter(\n (\n part,\n ): part is {\n inlineData: { mimeType: string; data: string };\n } => 'inlineData' in part,\n );\n}\n\nfunction extractSources({\n groundingMetadata,\n generateId,\n}: {\n groundingMetadata: z.infer<typeof groundingMetadataSchema> | undefined | null;\n generateId: () => string;\n}): undefined | LanguageModelV2Source[] {\n return groundingMetadata?.groundingChunks\n ?.filter(\n (\n chunk,\n ): chunk is z.infer<typeof groundingChunkSchema> & {\n web: { uri: string; title?: string };\n } => chunk.web != null,\n )\n .map(chunk => ({\n type: 'source',\n sourceType: 'url',\n id: generateId(),\n url: chunk.web.uri,\n title: chunk.web.title,\n }));\n}\n\nconst contentSchema = z.object({\n parts: z\n .array(\n z.union([\n // note: order matters since text can be fully empty\n z.object({\n functionCall: z.object({\n name: z.string(),\n args: z.unknown(),\n }),\n thoughtSignature: z.string().nullish(),\n }),\n z.object({\n inlineData: z.object({\n mimeType: z.string(),\n data: z.string(),\n }),\n }),\n z.object({\n executableCode: z\n .object({\n language: z.string(),\n code: z.string(),\n })\n .nullish(),\n codeExecutionResult: z\n .object({\n outcome: z.string(),\n output: z.string(),\n })\n .nullish(),\n text: z.string().nullish(),\n thought: z.boolean().nullish(),\n thoughtSignature: z.string().nullish(),\n }),\n ]),\n )\n .nullish(),\n});\n\n// https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters\nexport const safetyRatingSchema = z.object({\n category: z.string().nullish(),\n probability: z.string().nullish(),\n probabilityScore: z.number().nullish(),\n severity: z.string().nullish(),\n severityScore: z.number().nullish(),\n blocked: z.boolean().nullish(),\n});\n\nconst usageSchema = z.object({\n cachedContentTokenCount: z.number().nullish(),\n thoughtsTokenCount: z.number().nullish(),\n promptTokenCount: z.number().nullish(),\n candidatesTokenCount: z.number().nullish(),\n totalTokenCount: z.number().nullish(),\n});\n\nconst responseSchema = z.object({\n candidates: z.array(\n z.object({\n content: contentSchema.nullish().or(z.object({}).strict()),\n finishReason: z.string().nullish(),\n safetyRatings: z.array(safetyRatingSchema).nullish(),\n groundingMetadata: groundingMetadataSchema.nullish(),\n urlContextMetadata: urlContextMetadataSchema.nullish(),\n }),\n ),\n usageMetadata: usageSchema.nullish(),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst chunkSchema = z.object({\n candidates: z\n .array(\n z.object({\n content: contentSchema.nullish(),\n finishReason: z.string().nullish(),\n safetyRatings: z.array(safetyRatingSchema).nullish(),\n groundingMetadata: groundingMetadataSchema.nullish(),\n urlContextMetadata: urlContextMetadataSchema.nullish(),\n }),\n )\n .nullish(),\n usageMetadata: usageSchema.nullish(),\n});\n","import { JSONSchema7Definition } from '@ai-sdk/provider';\n\n/**\n * Converts JSON Schema 7 to OpenAPI Schema 3.0\n */\nexport function convertJSONSchemaToOpenAPISchema(\n jsonSchema: JSONSchema7Definition | undefined,\n): unknown {\n // parameters need to be undefined if they are empty objects:\n if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {\n return undefined;\n }\n\n if (typeof jsonSchema === 'boolean') {\n return { type: 'boolean', properties: {} };\n }\n\n const {\n type,\n description,\n required,\n properties,\n items,\n allOf,\n anyOf,\n oneOf,\n format,\n const: constValue,\n minLength,\n enum: enumValues,\n } = jsonSchema;\n\n const result: Record<string, unknown> = {};\n\n if (description) result.description = description;\n if (required) result.required = required;\n if (format) result.format = format;\n\n if (constValue !== undefined) {\n result.enum = [constValue];\n }\n\n // Handle type\n if (type) {\n if (Array.isArray(type)) {\n if (type.includes('null')) {\n result.type = type.filter(t => t !== 'null')[0];\n result.nullable = true;\n } else {\n result.type = type;\n }\n } else if (type === 'null') {\n result.type = 'null';\n } else {\n result.type = type;\n }\n }\n\n // Handle enum\n if (enumValues !== undefined) {\n result.enum = enumValues;\n }\n\n if (properties != null) {\n result.properties = Object.entries(properties).reduce(\n (acc, [key, value]) => {\n acc[key] = convertJSONSchemaToOpenAPISchema(value);\n return acc;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (items) {\n result.items = Array.isArray(items)\n ? items.map(convertJSONSchemaToOpenAPISchema)\n : convertJSONSchemaToOpenAPISchema(items);\n }\n\n if (allOf) {\n result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);\n }\n if (anyOf) {\n // Handle cases where anyOf includes a null type\n if (\n anyOf.some(\n schema => typeof schema === 'object' && schema?.type === 'null',\n )\n ) {\n const nonNullSchemas = anyOf.filter(\n schema => !(typeof schema === 'object' && schema?.type === 'null'),\n );\n\n if (nonNullSchemas.length === 1) {\n // If there's only one non-null schema, convert it and make it nullable\n const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);\n if (typeof converted === 'object') {\n result.nullable = true;\n Object.assign(result, converted);\n }\n } else {\n // If there are multiple non-null schemas, keep them in anyOf\n result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);\n result.nullable = true;\n }\n } else {\n result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);\n }\n }\n if (oneOf) {\n result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);\n }\n\n if (minLength !== undefined) {\n result.minLength = minLength;\n }\n\n return result;\n}\n\nfunction isEmptyObjectSchema(jsonSchema: JSONSchema7Definition): boolean {\n return (\n jsonSchema != null &&\n typeof jsonSchema === 'object' &&\n jsonSchema.type === 'object' &&\n (jsonSchema.properties == null ||\n Object.keys(jsonSchema.properties).length === 0) &&\n !jsonSchema.additionalProperties\n );\n}\n","import {\n LanguageModelV2Prompt,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport {\n GoogleGenerativeAIContent,\n GoogleGenerativeAIContentPart,\n GoogleGenerativeAIPrompt,\n} from './google-generative-ai-prompt';\nimport { convertToBase64 } from '@ai-sdk/provider-utils';\n\nexport function convertToGoogleGenerativeAIMessages(\n prompt: LanguageModelV2Prompt,\n options?: { isGemmaModel?: boolean },\n): GoogleGenerativeAIPrompt {\n const systemInstructionParts: Array<{ text: string }> = [];\n const contents: Array<GoogleGenerativeAIContent> = [];\n let systemMessagesAllowed = true;\n const isGemmaModel = options?.isGemmaModel ?? false;\n\n for (const { role, content } of prompt) {\n switch (role) {\n case 'system': {\n if (!systemMessagesAllowed) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'system messages are only supported at the beginning of the conversation',\n });\n }\n\n systemInstructionParts.push({ text: content });\n break;\n }\n\n case 'user': {\n systemMessagesAllowed = false;\n\n const parts: GoogleGenerativeAIContentPart[] = [];\n\n for (const part of content) {\n switch (part.type) {\n case 'text': {\n parts.push({ text: part.text });\n break;\n }\n\n case 'file': {\n // default to image/jpeg for unknown image/* types\n const mediaType =\n part.mediaType === 'image/*' ? 'image/jpeg' : part.mediaType;\n\n parts.push(\n part.data instanceof URL\n ? {\n fileData: {\n mimeType: mediaType,\n fileUri: part.data.toString(),\n },\n }\n : {\n inlineData: {\n mimeType: mediaType,\n data: convertToBase64(part.data),\n },\n },\n );\n\n break;\n }\n }\n }\n\n contents.push({ role: 'user', parts });\n break;\n }\n\n case 'assistant': {\n systemMessagesAllowed = false;\n\n contents.push({\n role: 'model',\n parts: content\n .map(part => {\n switch (part.type) {\n case 'text': {\n return part.text.length === 0\n ? undefined\n : {\n text: part.text,\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n\n case 'reasoning': {\n return part.text.length === 0\n ? undefined\n : {\n text: part.text,\n thought: true,\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n\n case 'file': {\n if (part.mediaType !== 'image/png') {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Only PNG images are supported in assistant messages',\n });\n }\n\n if (part.data instanceof URL) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'File data URLs in assistant messages are not supported',\n });\n }\n\n return {\n inlineData: {\n mimeType: part.mediaType,\n data: convertToBase64(part.data),\n },\n };\n }\n\n case 'tool-call': {\n return {\n functionCall: {\n name: part.toolName,\n args: part.input,\n },\n thoughtSignature:\n part.providerOptions?.google?.thoughtSignature,\n };\n }\n }\n })\n .filter(part => part !== undefined),\n });\n break;\n }\n\n case 'tool': {\n systemMessagesAllowed = false;\n\n contents.push({\n role: 'user',\n parts: content.map(part => ({\n functionResponse: {\n name: part.toolName,\n response: {\n name: part.toolName,\n content: part.output.value,\n },\n },\n })),\n });\n break;\n }\n }\n }\n\n if (\n isGemmaModel &&\n systemInstructionParts.length > 0 &&\n contents.length > 0 &&\n contents[0].role === 'user'\n ) {\n const systemText = systemInstructionParts\n .map(part => part.text)\n .join('\\n\\n');\n\n contents[0].parts.unshift({ text: systemText + '\\n\\n' });\n }\n\n return {\n systemInstruction:\n systemInstructionParts.length > 0 && !isGemmaModel\n ? { parts: systemInstructionParts }\n : undefined,\n contents,\n };\n}\n","export function getModelPath(modelId: string): string {\n return modelId.includes('/') ? modelId : `models/${modelId}`;\n}\n","import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst googleErrorDataSchema = z.object({\n error: z.object({\n code: z.number().nullable(),\n message: z.string(),\n status: z.string(),\n }),\n});\n\nexport type GoogleErrorData = z.infer<typeof googleErrorDataSchema>;\n\nexport const googleFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: googleErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import { z } from 'zod/v4';\n\nexport type GoogleGenerativeAIModelId =\n // Stable models\n // https://ai.google.dev/gemini-api/docs/models/gemini\n | 'gemini-1.5-flash'\n | 'gemini-1.5-flash-latest'\n | 'gemini-1.5-flash-001'\n | 'gemini-1.5-flash-002'\n | 'gemini-1.5-flash-8b'\n | 'gemini-1.5-flash-8b-latest'\n | 'gemini-1.5-flash-8b-001'\n | 'gemini-1.5-pro'\n | 'gemini-1.5-pro-latest'\n | 'gemini-1.5-pro-001'\n | 'gemini-1.5-pro-002'\n | 'gemini-2.0-flash'\n | 'gemini-2.0-flash-001'\n | 'gemini-2.0-flash-live-001'\n | 'gemini-2.0-flash-lite'\n | 'gemini-2.0-pro-exp-02-05'\n | 'gemini-2.0-flash-thinking-exp-01-21'\n | 'gemini-2.0-flash-exp'\n | 'gemini-2.5-pro'\n | 'gemini-2.5-flash'\n | 'gemini-2.5-flash-lite'\n // Experimental models\n // https://ai.google.dev/gemini-api/docs/models/experimental-models\n | 'gemini-2.5-pro-exp-03-25'\n | 'gemini-2.5-flash-preview-04-17'\n | 'gemini-exp-1206'\n | 'gemma-3-12b-it'\n | 'gemma-3-27b-it'\n | (string & {});\n\nexport const googleGenerativeAIProviderOptions = z.object({\n responseModalities: z.array(z.enum(['TEXT', 'IMAGE'])).optional(),\n\n thinkingConfig: z\n .object({\n thinkingBudget: z.number().optional(),\n includeThoughts: z.boolean().optional(),\n })\n .optional(),\n\n /**\nOptional.\nThe name of the cached content used as context to serve the prediction.\nFormat: cachedContents/{cachedContent}\n */\n cachedContent: z.string().optional(),\n\n /**\n * Optional. Enable structured output. Default is true.\n *\n * This is useful when the JSON Schema contains elements that are\n * not supported by the OpenAPI schema version that\n * Google Generative AI uses. You can use this to disable\n * structured outputs if you need to.\n */\n structuredOutputs: z.boolean().optional(),\n\n /**\nOptional. A list of unique safety settings for blocking unsafe content.\n */\n safetySettings: z\n .array(\n z.object({\n category: z.enum([\n 'HARM_CATEGORY_UNSPECIFIED',\n 'HARM_CATEGORY_HATE_SPEECH',\n 'HARM_CATEGORY_DANGEROUS_CONTENT',\n 'HARM_CATEGORY_HARASSMENT',\n 'HARM_CATEGORY_SEXUALLY_EXPLICIT',\n 'HARM_CATEGORY_CIVIC_INTEGRITY',\n ]),\n threshold: z.enum([\n 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',\n 'BLOCK_LOW_AND_ABOVE',\n 'BLOCK_MEDIUM_AND_ABOVE',\n 'BLOCK_ONLY_HIGH',\n 'BLOCK_NONE',\n 'OFF',\n ]),\n }),\n )\n .optional(),\n\n threshold: z\n .enum([\n 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',\n 'BLOCK_LOW_AND_ABOVE',\n 'BLOCK_MEDIUM_AND_ABOVE',\n 'BLOCK_ONLY_HIGH',\n 'BLOCK_NONE',\n 'OFF',\n ])\n .optional(),\n\n /**\n * Optional. Enables timestamp understanding for audio-only files.\n *\n * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding\n */\n audioTimestamp: z.boolean().optional(),\n\n /**\n * Optional. Defines labels used in billing reports. Available on Vertex AI only.\n *\n * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls\n */\n labels: z.record(z.string(), z.string()).optional(),\n});\n\nexport type GoogleGenerativeAIProviderOptions = z.infer<\n typeof googleGenerativeAIProviderOptions\n>;\n","import {\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport { convertJSONSchemaToOpenAPISchema } from './convert-json-schema-to-openapi-schema';\nimport { GoogleGenerativeAIModelId } from './google-generative-ai-options';\n\nexport function prepareTools({\n tools,\n toolChoice,\n modelId,\n}: {\n tools: LanguageModelV2CallOptions['tools'];\n toolChoice?: LanguageModelV2CallOptions['toolChoice'];\n modelId: GoogleGenerativeAIModelId;\n}): {\n tools:\n | {\n functionDeclarations: Array<{\n name: string;\n description: string;\n parameters: unknown;\n }>;\n }\n | Record<string, any>\n | undefined;\n toolConfig:\n | undefined\n | {\n functionCallingConfig: {\n mode: 'AUTO' | 'NONE' | 'ANY';\n allowedFunctionNames?: string[];\n };\n };\n toolWarnings: LanguageModelV2CallWarning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n\n const isGemini2 = modelId.includes('gemini-2');\n const supportsDynamicRetrieval =\n modelId.includes('gemini-1.5-flash') && !modelId.includes('-8b');\n\n if (tools == null) {\n return { tools: undefined, toolConfig: undefined, toolWarnings };\n }\n\n // Check for mixed tool types and add warnings\n const hasFunctionTools = tools.some(tool => tool.type === 'function');\n const hasProviderDefinedTools = tools.some(\n tool => tool.type === 'provider-defined',\n );\n\n if (hasFunctionTools && hasProviderDefinedTools) {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool: tools.find(tool => tool.type === 'function')!,\n details:\n 'Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both.',\n });\n }\n\n if (hasProviderDefinedTools) {\n const googleTools: Record<string, any> = {};\n\n const providerDefinedTools = tools.filter(\n tool => tool.type === 'provider-defined',\n );\n providerDefinedTools.forEach(tool => {\n switch (tool.id) {\n case 'google.google_search':\n if (isGemini2) {\n googleTools.googleSearch = {};\n } else if (supportsDynamicRetrieval) {\n // For non-Gemini-2 models that don't support dynamic retrieval, use basic googleSearchRetrieval\n googleTools.googleSearchRetrieval = {\n dynamicRetrievalConfig: {\n mode: tool.args.mode as\n | 'MODE_DYNAMIC'\n | 'MODE_UNSPECIFIED'\n | undefined,\n dynamicThreshold: tool.args.dynamicThreshold as\n | number\n | undefined,\n },\n };\n } else {\n googleTools.googleSearchRetrieval = {};\n }\n break;\n case 'google.url_context':\n if (isGemini2) {\n googleTools.urlContext = {};\n } else {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n details:\n 'The URL context tool is not supported with other Gemini models than Gemini 2.',\n });\n }\n break;\n case 'google.code_execution':\n if (isGemini2) {\n googleTools.codeExecution = {};\n } else {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n details:\n 'The code execution tools is not supported with other Gemini models than Gemini 2.',\n });\n }\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n });\n\n return {\n tools: Object.keys(googleTools).length > 0 ? googleTools : undefined,\n toolConfig: undefined,\n toolWarnings,\n };\n }\n\n const functionDeclarations = [];\n for (const tool of tools) {\n switch (tool.type) {\n case 'function':\n functionDeclarations.push({\n name: tool.name,\n description: tool.description ?? '',\n parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema),\n });\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n }\n\n if (toolChoice == null) {\n return {\n tools: { functionDeclarations },\n toolConfig: undefined,\n toolWarnings,\n };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'AUTO' } },\n toolWarnings,\n };\n case 'none':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'NONE' } },\n toolWarnings,\n };\n case 'required':\n return {\n tools: { functionDeclarations },\n toolConfig: { functionCallingConfig: { mode: 'ANY' } },\n toolWarnings,\n };\n case 'tool':\n return {\n tools: { functionDeclarations },\n toolConfig: {\n functionCallingConfig: {\n mode: 'ANY',\n allowedFunctionNames: [toolChoice.toolName],\n },\n },\n toolWarnings,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import { LanguageModelV2FinishReason } from '@ai-sdk/provider';\n\nexport function mapGoogleGenerativeAIFinishReason({\n finishReason,\n hasToolCalls,\n}: {\n finishReason: string | null | undefined;\n hasToolCalls: boolean;\n}): LanguageModelV2FinishReason {\n switch (finishReason) {\n case 'STOP':\n return hasToolCalls ? 'tool-calls' : 'stop';\n case 'MAX_TOKENS':\n return 'length';\n case 'IMAGE_SAFETY':\n case 'RECITATION':\n case 'SAFETY':\n case 'BLOCKLIST':\n case 'PROHIBITED_CONTENT':\n case 'SPII':\n return 'content-filter';\n case 'FINISH_REASON_UNSPECIFIED':\n case 'OTHER':\n return 'other';\n case 'MALFORMED_FUNCTION_CALL':\n return 'error';\n default:\n return 'unknown';\n }\n}\n","import { createProviderDefinedToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://ai.google.dev/gemini-api/docs/google-search\n// https://ai.google.dev/api/generate-content#GroundingSupport\n// https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-search\n\nexport const groundingChunkSchema = z.object({\n web: z.object({ uri: z.string(), title: z.string() }).nullish(),\n retrievedContext: z.object({ uri: z.string(), title: z.string() }).nullish(),\n});\n\nexport const groundingMetadataSchema = z.object({\n webSearchQueries: z.array(z.string()).nullish(),\n retrievalQueries: z.array(z.string()).nullish(),\n searchEntryPoint: z.object({ renderedContent: z.string() }).nullish(),\n groundingChunks: z.array(groundingChunkSchema).nullish(),\n groundingSupports: z\n .array(\n z.object({\n segment: z.object({\n startIndex: z.number().nullish(),\n endIndex: z.number().nullish(),\n text: z.string().nullish(),\n }),\n segment_text: z.string().nullish(),\n groundingChunkIndices: z.array(z.number()).nullish(),\n supportChunkIndices: z.array(z.number()).nullish(),\n confidenceScores: z.array(z.number()).nullish(),\n confidenceScore: z.array(z.number()).nullish(),\n }),\n )\n .nullish(),\n retrievalMetadata: z\n .union([\n z.object({\n webDynamicRetrievalScore: z.number(),\n }),\n z.object({}),\n ])\n .nullish(),\n});\n\nexport const googleSearch = createProviderDefinedToolFactory<\n {},\n {\n /**\n * The mode of the predictor to be used in dynamic retrieval. The following modes are supported:\n * - MODE_DYNAMIC: Run retrieval only when system decides it is necessary\n * - MODE_UNSPECIFIED: Always trigger retrieval\n * @default MODE_UNSPECIFIED\n */\n mode?: 'MODE_DYNAMIC' | 'MODE_UNSPECIFIED';\n\n /**\n * The threshold to be used in dynamic retrieval (if not set, a system default value is used).\n */\n dynamicThreshold?: number;\n }\n>({\n id: 'google.google_search',\n name: 'google_search',\n inputSchema: z.object({\n mode: z\n .enum(['MODE_DYNAMIC', 'MODE_UNSPECIFIED'])\n .default('MODE_UNSPECIFIED'),\n dynamicThreshold: z.number().default(1),\n }),\n});\n","import { createProviderDefinedToolFactory } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://ai.google.dev/api/generate-content#UrlRetrievalMetadata\nconst urlMetadataSchema = z.object({\n retrievedUrl: z.string(),\n urlRetrievalStatus: z.string(),\n});\n\nexport const urlContextMetadataSchema = z.object({\n urlMetadata: z.array(urlMetadataSchema),\n});\n\nexport const urlContext = createProviderDefinedToolFactory<\n {\n // Url context does not have any input schema, it will directly use the url from the prompt\n },\n {}\n>({\n id: 'google.url_context',\n name: 'url_context',\n inputSchema: z.object({}),\n});\n","import { createProviderDefinedToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * A tool that enables the model to generate and run Python code.\n *\n * @note Ensure the selected model supports Code Execution.\n * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.\n *\n * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)\n */\nexport const codeExecution = createProviderDefinedToolFactoryWithOutputSchema<\n {\n language: string;\n code: string;\n },\n {\n outcome: string;\n output: string;\n },\n {}\n>({\n id: 'google.code_execution',\n name: 'code_execution',\n inputSchema: z.object({\n language: z.string().describe('The programming language of the code.'),\n code: z.string().describe('The code to be executed.'),\n }),\n outputSchema: z.object({\n outcome: z\n .string()\n .describe('The outcome of the execution (e.g., \"OUTCOME_OK\").'),\n output: z.string().describe('The output from the code execution.'),\n }),\n});\n","import { codeExecution } from './tool/code-execution';\nimport { googleSearch } from './tool/google-search';\nimport { urlContext } from './tool/url-context';\n\nexport const googleTools = {\n /**\n * Creates a Google search tool that gives Google direct access to real-time web content.\n * Must have name \"google_search\".\n */\n googleSearch,\n\n /**\n * Creates a URL context tool that gives Google direct access to real-time web content.\n * Must have name \"url_context\".\n */\n urlContext,\n /**\n * A tool that enables the model to generate and run Python code.\n * Must have name \"code_execution\".\n *\n * @note Ensure the selected model supports Code Execution.\n * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.\n *\n * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)\n */\n codeExecution,\n};\n"],"mappings":";;;;;;;;;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OAAO,EAAE,SAAS,0BAA0B;AAAA,EACtD,CAAC;AAAA,EACD,cAAc,aAAE,OAAO;AAAA,IACrB,SAAS,aACN,OAAO,EACP,SAAS,oDAAoD;AAAA,IAChE,QAAQ,aAAE,OAAO,EAAE,SAAS,qCAAqC;AAAA,EACnE,CAAC;AACH,CAAC;;;AC/BM,IAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA;AACF;","names":["import_provider_utils","import_v4","_a","import_provider_utils","import_v4","import_provider","googleTools","import_provider_utils","import_v4","import_provider_utils","import_v4","googleTools","generateId","import_provider_utils","import_v4"]}
node_modules/.pnpm/@ai-sdk+google@2.0.4_zod@3.25.76/node_modules/@ai-sdk/google/dist/internal/index.mjs ADDED
@@ -0,0 +1,1168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/google-generative-ai-language-model.ts
2
+ import {
3
+ combineHeaders,
4
+ createEventSourceResponseHandler,
5
+ createJsonResponseHandler,
6
+ generateId,
7
+ parseProviderOptions,
8
+ postJsonToApi,
9
+ resolve
10
+ } from "@ai-sdk/provider-utils";
11
+ import { z as z5 } from "zod/v4";
12
+
13
+ // src/convert-json-schema-to-openapi-schema.ts
14
+ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
15
+ if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
16
+ return void 0;
17
+ }
18
+ if (typeof jsonSchema === "boolean") {
19
+ return { type: "boolean", properties: {} };
20
+ }
21
+ const {
22
+ type,
23
+ description,
24
+ required,
25
+ properties,
26
+ items,
27
+ allOf,
28
+ anyOf,
29
+ oneOf,
30
+ format,
31
+ const: constValue,
32
+ minLength,
33
+ enum: enumValues
34
+ } = jsonSchema;
35
+ const result = {};
36
+ if (description)
37
+ result.description = description;
38
+ if (required)
39
+ result.required = required;
40
+ if (format)
41
+ result.format = format;
42
+ if (constValue !== void 0) {
43
+ result.enum = [constValue];
44
+ }
45
+ if (type) {
46
+ if (Array.isArray(type)) {
47
+ if (type.includes("null")) {
48
+ result.type = type.filter((t) => t !== "null")[0];
49
+ result.nullable = true;
50
+ } else {
51
+ result.type = type;
52
+ }
53
+ } else if (type === "null") {
54
+ result.type = "null";
55
+ } else {
56
+ result.type = type;
57
+ }
58
+ }
59
+ if (enumValues !== void 0) {
60
+ result.enum = enumValues;
61
+ }
62
+ if (properties != null) {
63
+ result.properties = Object.entries(properties).reduce(
64
+ (acc, [key, value]) => {
65
+ acc[key] = convertJSONSchemaToOpenAPISchema(value);
66
+ return acc;
67
+ },
68
+ {}
69
+ );
70
+ }
71
+ if (items) {
72
+ result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
73
+ }
74
+ if (allOf) {
75
+ result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
76
+ }
77
+ if (anyOf) {
78
+ if (anyOf.some(
79
+ (schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"
80
+ )) {
81
+ const nonNullSchemas = anyOf.filter(
82
+ (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
83
+ );
84
+ if (nonNullSchemas.length === 1) {
85
+ const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
86
+ if (typeof converted === "object") {
87
+ result.nullable = true;
88
+ Object.assign(result, converted);
89
+ }
90
+ } else {
91
+ result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
92
+ result.nullable = true;
93
+ }
94
+ } else {
95
+ result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
96
+ }
97
+ }
98
+ if (oneOf) {
99
+ result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
100
+ }
101
+ if (minLength !== void 0) {
102
+ result.minLength = minLength;
103
+ }
104
+ return result;
105
+ }
106
+ function isEmptyObjectSchema(jsonSchema) {
107
+ return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
108
+ }
109
+
110
+ // src/convert-to-google-generative-ai-messages.ts
111
+ import {
112
+ UnsupportedFunctionalityError
113
+ } from "@ai-sdk/provider";
114
+ import { convertToBase64 } from "@ai-sdk/provider-utils";
115
+ function convertToGoogleGenerativeAIMessages(prompt, options) {
116
+ var _a;
117
+ const systemInstructionParts = [];
118
+ const contents = [];
119
+ let systemMessagesAllowed = true;
120
+ const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
121
+ for (const { role, content } of prompt) {
122
+ switch (role) {
123
+ case "system": {
124
+ if (!systemMessagesAllowed) {
125
+ throw new UnsupportedFunctionalityError({
126
+ functionality: "system messages are only supported at the beginning of the conversation"
127
+ });
128
+ }
129
+ systemInstructionParts.push({ text: content });
130
+ break;
131
+ }
132
+ case "user": {
133
+ systemMessagesAllowed = false;
134
+ const parts = [];
135
+ for (const part of content) {
136
+ switch (part.type) {
137
+ case "text": {
138
+ parts.push({ text: part.text });
139
+ break;
140
+ }
141
+ case "file": {
142
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
143
+ parts.push(
144
+ part.data instanceof URL ? {
145
+ fileData: {
146
+ mimeType: mediaType,
147
+ fileUri: part.data.toString()
148
+ }
149
+ } : {
150
+ inlineData: {
151
+ mimeType: mediaType,
152
+ data: convertToBase64(part.data)
153
+ }
154
+ }
155
+ );
156
+ break;
157
+ }
158
+ }
159
+ }
160
+ contents.push({ role: "user", parts });
161
+ break;
162
+ }
163
+ case "assistant": {
164
+ systemMessagesAllowed = false;
165
+ contents.push({
166
+ role: "model",
167
+ parts: content.map((part) => {
168
+ var _a2, _b, _c, _d, _e, _f;
169
+ switch (part.type) {
170
+ case "text": {
171
+ return part.text.length === 0 ? void 0 : {
172
+ text: part.text,
173
+ thoughtSignature: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature
174
+ };
175
+ }
176
+ case "reasoning": {
177
+ return part.text.length === 0 ? void 0 : {
178
+ text: part.text,
179
+ thought: true,
180
+ thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
181
+ };
182
+ }
183
+ case "file": {
184
+ if (part.mediaType !== "image/png") {
185
+ throw new UnsupportedFunctionalityError({
186
+ functionality: "Only PNG images are supported in assistant messages"
187
+ });
188
+ }
189
+ if (part.data instanceof URL) {
190
+ throw new UnsupportedFunctionalityError({
191
+ functionality: "File data URLs in assistant messages are not supported"
192
+ });
193
+ }
194
+ return {
195
+ inlineData: {
196
+ mimeType: part.mediaType,
197
+ data: convertToBase64(part.data)
198
+ }
199
+ };
200
+ }
201
+ case "tool-call": {
202
+ return {
203
+ functionCall: {
204
+ name: part.toolName,
205
+ args: part.input
206
+ },
207
+ thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
208
+ };
209
+ }
210
+ }
211
+ }).filter((part) => part !== void 0)
212
+ });
213
+ break;
214
+ }
215
+ case "tool": {
216
+ systemMessagesAllowed = false;
217
+ contents.push({
218
+ role: "user",
219
+ parts: content.map((part) => ({
220
+ functionResponse: {
221
+ name: part.toolName,
222
+ response: {
223
+ name: part.toolName,
224
+ content: part.output.value
225
+ }
226
+ }
227
+ }))
228
+ });
229
+ break;
230
+ }
231
+ }
232
+ }
233
+ if (isGemmaModel && systemInstructionParts.length > 0 && contents.length > 0 && contents[0].role === "user") {
234
+ const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
235
+ contents[0].parts.unshift({ text: systemText + "\n\n" });
236
+ }
237
+ return {
238
+ systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
239
+ contents
240
+ };
241
+ }
242
+
243
+ // src/get-model-path.ts
244
+ function getModelPath(modelId) {
245
+ return modelId.includes("/") ? modelId : `models/${modelId}`;
246
+ }
247
+
248
+ // src/google-error.ts
249
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
250
+ import { z } from "zod/v4";
251
+ var googleErrorDataSchema = z.object({
252
+ error: z.object({
253
+ code: z.number().nullable(),
254
+ message: z.string(),
255
+ status: z.string()
256
+ })
257
+ });
258
+ var googleFailedResponseHandler = createJsonErrorResponseHandler({
259
+ errorSchema: googleErrorDataSchema,
260
+ errorToMessage: (data) => data.error.message
261
+ });
262
+
263
+ // src/google-generative-ai-options.ts
264
+ import { z as z2 } from "zod/v4";
265
+ var googleGenerativeAIProviderOptions = z2.object({
266
+ responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
267
+ thinkingConfig: z2.object({
268
+ thinkingBudget: z2.number().optional(),
269
+ includeThoughts: z2.boolean().optional()
270
+ }).optional(),
271
+ /**
272
+ Optional.
273
+ The name of the cached content used as context to serve the prediction.
274
+ Format: cachedContents/{cachedContent}
275
+ */
276
+ cachedContent: z2.string().optional(),
277
+ /**
278
+ * Optional. Enable structured output. Default is true.
279
+ *
280
+ * This is useful when the JSON Schema contains elements that are
281
+ * not supported by the OpenAPI schema version that
282
+ * Google Generative AI uses. You can use this to disable
283
+ * structured outputs if you need to.
284
+ */
285
+ structuredOutputs: z2.boolean().optional(),
286
+ /**
287
+ Optional. A list of unique safety settings for blocking unsafe content.
288
+ */
289
+ safetySettings: z2.array(
290
+ z2.object({
291
+ category: z2.enum([
292
+ "HARM_CATEGORY_UNSPECIFIED",
293
+ "HARM_CATEGORY_HATE_SPEECH",
294
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
295
+ "HARM_CATEGORY_HARASSMENT",
296
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT",
297
+ "HARM_CATEGORY_CIVIC_INTEGRITY"
298
+ ]),
299
+ threshold: z2.enum([
300
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
301
+ "BLOCK_LOW_AND_ABOVE",
302
+ "BLOCK_MEDIUM_AND_ABOVE",
303
+ "BLOCK_ONLY_HIGH",
304
+ "BLOCK_NONE",
305
+ "OFF"
306
+ ])
307
+ })
308
+ ).optional(),
309
+ threshold: z2.enum([
310
+ "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
311
+ "BLOCK_LOW_AND_ABOVE",
312
+ "BLOCK_MEDIUM_AND_ABOVE",
313
+ "BLOCK_ONLY_HIGH",
314
+ "BLOCK_NONE",
315
+ "OFF"
316
+ ]).optional(),
317
+ /**
318
+ * Optional. Enables timestamp understanding for audio-only files.
319
+ *
320
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
321
+ */
322
+ audioTimestamp: z2.boolean().optional(),
323
+ /**
324
+ * Optional. Defines labels used in billing reports. Available on Vertex AI only.
325
+ *
326
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
327
+ */
328
+ labels: z2.record(z2.string(), z2.string()).optional()
329
+ });
330
+
331
+ // src/google-prepare-tools.ts
332
+ import {
333
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
334
+ } from "@ai-sdk/provider";
335
+ function prepareTools({
336
+ tools,
337
+ toolChoice,
338
+ modelId
339
+ }) {
340
+ var _a;
341
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
342
+ const toolWarnings = [];
343
+ const isGemini2 = modelId.includes("gemini-2");
344
+ const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
345
+ if (tools == null) {
346
+ return { tools: void 0, toolConfig: void 0, toolWarnings };
347
+ }
348
+ const hasFunctionTools = tools.some((tool) => tool.type === "function");
349
+ const hasProviderDefinedTools = tools.some(
350
+ (tool) => tool.type === "provider-defined"
351
+ );
352
+ if (hasFunctionTools && hasProviderDefinedTools) {
353
+ toolWarnings.push({
354
+ type: "unsupported-tool",
355
+ tool: tools.find((tool) => tool.type === "function"),
356
+ details: "Cannot mix function tools with provider-defined tools in the same request. Please use either function tools or provider-defined tools, but not both."
357
+ });
358
+ }
359
+ if (hasProviderDefinedTools) {
360
+ const googleTools2 = {};
361
+ const providerDefinedTools = tools.filter(
362
+ (tool) => tool.type === "provider-defined"
363
+ );
364
+ providerDefinedTools.forEach((tool) => {
365
+ switch (tool.id) {
366
+ case "google.google_search":
367
+ if (isGemini2) {
368
+ googleTools2.googleSearch = {};
369
+ } else if (supportsDynamicRetrieval) {
370
+ googleTools2.googleSearchRetrieval = {
371
+ dynamicRetrievalConfig: {
372
+ mode: tool.args.mode,
373
+ dynamicThreshold: tool.args.dynamicThreshold
374
+ }
375
+ };
376
+ } else {
377
+ googleTools2.googleSearchRetrieval = {};
378
+ }
379
+ break;
380
+ case "google.url_context":
381
+ if (isGemini2) {
382
+ googleTools2.urlContext = {};
383
+ } else {
384
+ toolWarnings.push({
385
+ type: "unsupported-tool",
386
+ tool,
387
+ details: "The URL context tool is not supported with other Gemini models than Gemini 2."
388
+ });
389
+ }
390
+ break;
391
+ case "google.code_execution":
392
+ if (isGemini2) {
393
+ googleTools2.codeExecution = {};
394
+ } else {
395
+ toolWarnings.push({
396
+ type: "unsupported-tool",
397
+ tool,
398
+ details: "The code execution tools is not supported with other Gemini models than Gemini 2."
399
+ });
400
+ }
401
+ break;
402
+ default:
403
+ toolWarnings.push({ type: "unsupported-tool", tool });
404
+ break;
405
+ }
406
+ });
407
+ return {
408
+ tools: Object.keys(googleTools2).length > 0 ? googleTools2 : void 0,
409
+ toolConfig: void 0,
410
+ toolWarnings
411
+ };
412
+ }
413
+ const functionDeclarations = [];
414
+ for (const tool of tools) {
415
+ switch (tool.type) {
416
+ case "function":
417
+ functionDeclarations.push({
418
+ name: tool.name,
419
+ description: (_a = tool.description) != null ? _a : "",
420
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
421
+ });
422
+ break;
423
+ default:
424
+ toolWarnings.push({ type: "unsupported-tool", tool });
425
+ break;
426
+ }
427
+ }
428
+ if (toolChoice == null) {
429
+ return {
430
+ tools: { functionDeclarations },
431
+ toolConfig: void 0,
432
+ toolWarnings
433
+ };
434
+ }
435
+ const type = toolChoice.type;
436
+ switch (type) {
437
+ case "auto":
438
+ return {
439
+ tools: { functionDeclarations },
440
+ toolConfig: { functionCallingConfig: { mode: "AUTO" } },
441
+ toolWarnings
442
+ };
443
+ case "none":
444
+ return {
445
+ tools: { functionDeclarations },
446
+ toolConfig: { functionCallingConfig: { mode: "NONE" } },
447
+ toolWarnings
448
+ };
449
+ case "required":
450
+ return {
451
+ tools: { functionDeclarations },
452
+ toolConfig: { functionCallingConfig: { mode: "ANY" } },
453
+ toolWarnings
454
+ };
455
+ case "tool":
456
+ return {
457
+ tools: { functionDeclarations },
458
+ toolConfig: {
459
+ functionCallingConfig: {
460
+ mode: "ANY",
461
+ allowedFunctionNames: [toolChoice.toolName]
462
+ }
463
+ },
464
+ toolWarnings
465
+ };
466
+ default: {
467
+ const _exhaustiveCheck = type;
468
+ throw new UnsupportedFunctionalityError2({
469
+ functionality: `tool choice type: ${_exhaustiveCheck}`
470
+ });
471
+ }
472
+ }
473
+ }
474
+
475
+ // src/map-google-generative-ai-finish-reason.ts
476
+ function mapGoogleGenerativeAIFinishReason({
477
+ finishReason,
478
+ hasToolCalls
479
+ }) {
480
+ switch (finishReason) {
481
+ case "STOP":
482
+ return hasToolCalls ? "tool-calls" : "stop";
483
+ case "MAX_TOKENS":
484
+ return "length";
485
+ case "IMAGE_SAFETY":
486
+ case "RECITATION":
487
+ case "SAFETY":
488
+ case "BLOCKLIST":
489
+ case "PROHIBITED_CONTENT":
490
+ case "SPII":
491
+ return "content-filter";
492
+ case "FINISH_REASON_UNSPECIFIED":
493
+ case "OTHER":
494
+ return "other";
495
+ case "MALFORMED_FUNCTION_CALL":
496
+ return "error";
497
+ default:
498
+ return "unknown";
499
+ }
500
+ }
501
+
502
+ // src/tool/google-search.ts
503
+ import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
504
+ import { z as z3 } from "zod/v4";
505
+ var groundingChunkSchema = z3.object({
506
+ web: z3.object({ uri: z3.string(), title: z3.string() }).nullish(),
507
+ retrievedContext: z3.object({ uri: z3.string(), title: z3.string() }).nullish()
508
+ });
509
+ var groundingMetadataSchema = z3.object({
510
+ webSearchQueries: z3.array(z3.string()).nullish(),
511
+ retrievalQueries: z3.array(z3.string()).nullish(),
512
+ searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
513
+ groundingChunks: z3.array(groundingChunkSchema).nullish(),
514
+ groundingSupports: z3.array(
515
+ z3.object({
516
+ segment: z3.object({
517
+ startIndex: z3.number().nullish(),
518
+ endIndex: z3.number().nullish(),
519
+ text: z3.string().nullish()
520
+ }),
521
+ segment_text: z3.string().nullish(),
522
+ groundingChunkIndices: z3.array(z3.number()).nullish(),
523
+ supportChunkIndices: z3.array(z3.number()).nullish(),
524
+ confidenceScores: z3.array(z3.number()).nullish(),
525
+ confidenceScore: z3.array(z3.number()).nullish()
526
+ })
527
+ ).nullish(),
528
+ retrievalMetadata: z3.union([
529
+ z3.object({
530
+ webDynamicRetrievalScore: z3.number()
531
+ }),
532
+ z3.object({})
533
+ ]).nullish()
534
+ });
535
+ var googleSearch = createProviderDefinedToolFactory({
536
+ id: "google.google_search",
537
+ name: "google_search",
538
+ inputSchema: z3.object({
539
+ mode: z3.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
540
+ dynamicThreshold: z3.number().default(1)
541
+ })
542
+ });
543
+
544
+ // src/tool/url-context.ts
545
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
546
+ import { z as z4 } from "zod/v4";
547
+ var urlMetadataSchema = z4.object({
548
+ retrievedUrl: z4.string(),
549
+ urlRetrievalStatus: z4.string()
550
+ });
551
+ var urlContextMetadataSchema = z4.object({
552
+ urlMetadata: z4.array(urlMetadataSchema)
553
+ });
554
+ var urlContext = createProviderDefinedToolFactory2({
555
+ id: "google.url_context",
556
+ name: "url_context",
557
+ inputSchema: z4.object({})
558
+ });
559
+
560
+ // src/google-generative-ai-language-model.ts
561
+ var GoogleGenerativeAILanguageModel = class {
562
+ constructor(modelId, config) {
563
+ this.specificationVersion = "v2";
564
+ var _a;
565
+ this.modelId = modelId;
566
+ this.config = config;
567
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
568
+ }
569
+ get provider() {
570
+ return this.config.provider;
571
+ }
572
+ get supportedUrls() {
573
+ var _a, _b, _c;
574
+ return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
575
+ }
576
+ async getArgs({
577
+ prompt,
578
+ maxOutputTokens,
579
+ temperature,
580
+ topP,
581
+ topK,
582
+ frequencyPenalty,
583
+ presencePenalty,
584
+ stopSequences,
585
+ responseFormat,
586
+ seed,
587
+ tools,
588
+ toolChoice,
589
+ providerOptions
590
+ }) {
591
+ var _a, _b;
592
+ const warnings = [];
593
+ const googleOptions = await parseProviderOptions({
594
+ provider: "google",
595
+ providerOptions,
596
+ schema: googleGenerativeAIProviderOptions
597
+ });
598
+ if (((_a = googleOptions == null ? void 0 : googleOptions.thinkingConfig) == null ? void 0 : _a.includeThoughts) === true && !this.config.provider.startsWith("google.vertex.")) {
599
+ warnings.push({
600
+ type: "other",
601
+ message: `The 'includeThoughts' option is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
602
+ });
603
+ }
604
+ const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
605
+ const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
606
+ prompt,
607
+ { isGemmaModel }
608
+ );
609
+ const {
610
+ tools: googleTools2,
611
+ toolConfig: googleToolConfig,
612
+ toolWarnings
613
+ } = prepareTools({
614
+ tools,
615
+ toolChoice,
616
+ modelId: this.modelId
617
+ });
618
+ return {
619
+ args: {
620
+ generationConfig: {
621
+ // standardized settings:
622
+ maxOutputTokens,
623
+ temperature,
624
+ topK,
625
+ topP,
626
+ frequencyPenalty,
627
+ presencePenalty,
628
+ stopSequences,
629
+ seed,
630
+ // response format:
631
+ responseMimeType: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? "application/json" : void 0,
632
+ responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
633
+ // so this is needed as an escape hatch:
634
+ // TODO convert into provider option
635
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
636
+ ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
637
+ audioTimestamp: googleOptions.audioTimestamp
638
+ },
639
+ // provider options:
640
+ responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
641
+ thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
642
+ },
643
+ contents,
644
+ systemInstruction: isGemmaModel ? void 0 : systemInstruction,
645
+ safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
646
+ tools: googleTools2,
647
+ toolConfig: googleToolConfig,
648
+ cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
649
+ labels: googleOptions == null ? void 0 : googleOptions.labels
650
+ },
651
+ warnings: [...warnings, ...toolWarnings]
652
+ };
653
+ }
654
+ async doGenerate(options) {
655
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
656
+ const { args, warnings } = await this.getArgs(options);
657
+ const body = JSON.stringify(args);
658
+ const mergedHeaders = combineHeaders(
659
+ await resolve(this.config.headers),
660
+ options.headers
661
+ );
662
+ const {
663
+ responseHeaders,
664
+ value: response,
665
+ rawValue: rawResponse
666
+ } = await postJsonToApi({
667
+ url: `${this.config.baseURL}/${getModelPath(
668
+ this.modelId
669
+ )}:generateContent`,
670
+ headers: mergedHeaders,
671
+ body: args,
672
+ failedResponseHandler: googleFailedResponseHandler,
673
+ successfulResponseHandler: createJsonResponseHandler(responseSchema),
674
+ abortSignal: options.abortSignal,
675
+ fetch: this.config.fetch
676
+ });
677
+ const candidate = response.candidates[0];
678
+ const content = [];
679
+ const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
680
+ const usageMetadata = response.usageMetadata;
681
+ let lastCodeExecutionToolCallId;
682
+ for (const part of parts) {
683
+ if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
684
+ const toolCallId = this.config.generateId();
685
+ lastCodeExecutionToolCallId = toolCallId;
686
+ content.push({
687
+ type: "tool-call",
688
+ toolCallId,
689
+ toolName: "code_execution",
690
+ input: JSON.stringify(part.executableCode),
691
+ providerExecuted: true
692
+ });
693
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
694
+ content.push({
695
+ type: "tool-result",
696
+ // Assumes a result directly follows its corresponding call part.
697
+ toolCallId: lastCodeExecutionToolCallId,
698
+ toolName: "code_execution",
699
+ result: {
700
+ outcome: part.codeExecutionResult.outcome,
701
+ output: part.codeExecutionResult.output
702
+ },
703
+ providerExecuted: true
704
+ });
705
+ lastCodeExecutionToolCallId = void 0;
706
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
707
+ content.push({
708
+ type: part.thought === true ? "reasoning" : "text",
709
+ text: part.text,
710
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
711
+ });
712
+ } else if ("functionCall" in part) {
713
+ content.push({
714
+ type: "tool-call",
715
+ toolCallId: this.config.generateId(),
716
+ toolName: part.functionCall.name,
717
+ input: JSON.stringify(part.functionCall.args),
718
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
719
+ });
720
+ } else if ("inlineData" in part) {
721
+ content.push({
722
+ type: "file",
723
+ data: part.inlineData.data,
724
+ mediaType: part.inlineData.mimeType
725
+ });
726
+ }
727
+ }
728
+ const sources = (_d = extractSources({
729
+ groundingMetadata: candidate.groundingMetadata,
730
+ generateId: this.config.generateId
731
+ })) != null ? _d : [];
732
+ for (const source of sources) {
733
+ content.push(source);
734
+ }
735
+ return {
736
+ content,
737
+ finishReason: mapGoogleGenerativeAIFinishReason({
738
+ finishReason: candidate.finishReason,
739
+ hasToolCalls: content.some((part) => part.type === "tool-call")
740
+ }),
741
+ usage: {
742
+ inputTokens: (_e = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _e : void 0,
743
+ outputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _f : void 0,
744
+ totalTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _g : void 0,
745
+ reasoningTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _h : void 0,
746
+ cachedInputTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _i : void 0
747
+ },
748
+ warnings,
749
+ providerMetadata: {
750
+ google: {
751
+ groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
752
+ urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
753
+ safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
754
+ usageMetadata: usageMetadata != null ? usageMetadata : null
755
+ }
756
+ },
757
+ request: { body },
758
+ response: {
759
+ // TODO timestamp, model id, id
760
+ headers: responseHeaders,
761
+ body: rawResponse
762
+ }
763
+ };
764
+ }
765
+ async doStream(options) {
766
+ const { args, warnings } = await this.getArgs(options);
767
+ const body = JSON.stringify(args);
768
+ const headers = combineHeaders(
769
+ await resolve(this.config.headers),
770
+ options.headers
771
+ );
772
+ const { responseHeaders, value: response } = await postJsonToApi({
773
+ url: `${this.config.baseURL}/${getModelPath(
774
+ this.modelId
775
+ )}:streamGenerateContent?alt=sse`,
776
+ headers,
777
+ body: args,
778
+ failedResponseHandler: googleFailedResponseHandler,
779
+ successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
780
+ abortSignal: options.abortSignal,
781
+ fetch: this.config.fetch
782
+ });
783
+ let finishReason = "unknown";
784
+ const usage = {
785
+ inputTokens: void 0,
786
+ outputTokens: void 0,
787
+ totalTokens: void 0
788
+ };
789
+ let providerMetadata = void 0;
790
+ const generateId2 = this.config.generateId;
791
+ let hasToolCalls = false;
792
+ let currentTextBlockId = null;
793
+ let currentReasoningBlockId = null;
794
+ let blockCounter = 0;
795
+ const emittedSourceUrls = /* @__PURE__ */ new Set();
796
+ let lastCodeExecutionToolCallId;
797
+ return {
798
+ stream: response.pipeThrough(
799
+ new TransformStream({
800
+ start(controller) {
801
+ controller.enqueue({ type: "stream-start", warnings });
802
+ },
803
+ transform(chunk, controller) {
804
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
805
+ if (options.includeRawChunks) {
806
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
807
+ }
808
+ if (!chunk.success) {
809
+ controller.enqueue({ type: "error", error: chunk.error });
810
+ return;
811
+ }
812
+ const value = chunk.value;
813
+ const usageMetadata = value.usageMetadata;
814
+ if (usageMetadata != null) {
815
+ usage.inputTokens = (_a = usageMetadata.promptTokenCount) != null ? _a : void 0;
816
+ usage.outputTokens = (_b = usageMetadata.candidatesTokenCount) != null ? _b : void 0;
817
+ usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
818
+ usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
819
+ usage.cachedInputTokens = (_e = usageMetadata.cachedContentTokenCount) != null ? _e : void 0;
820
+ }
821
+ const candidate = (_f = value.candidates) == null ? void 0 : _f[0];
822
+ if (candidate == null) {
823
+ return;
824
+ }
825
+ const content = candidate.content;
826
+ const sources = extractSources({
827
+ groundingMetadata: candidate.groundingMetadata,
828
+ generateId: generateId2
829
+ });
830
+ if (sources != null) {
831
+ for (const source of sources) {
832
+ if (source.sourceType === "url" && !emittedSourceUrls.has(source.url)) {
833
+ emittedSourceUrls.add(source.url);
834
+ controller.enqueue(source);
835
+ }
836
+ }
837
+ }
838
+ if (content != null) {
839
+ const parts = (_g = content.parts) != null ? _g : [];
840
+ for (const part of parts) {
841
+ if ("executableCode" in part && ((_h = part.executableCode) == null ? void 0 : _h.code)) {
842
+ const toolCallId = generateId2();
843
+ lastCodeExecutionToolCallId = toolCallId;
844
+ controller.enqueue({
845
+ type: "tool-call",
846
+ toolCallId,
847
+ toolName: "code_execution",
848
+ input: JSON.stringify(part.executableCode),
849
+ providerExecuted: true
850
+ });
851
+ hasToolCalls = true;
852
+ } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
853
+ const toolCallId = lastCodeExecutionToolCallId;
854
+ if (toolCallId) {
855
+ controller.enqueue({
856
+ type: "tool-result",
857
+ toolCallId,
858
+ toolName: "code_execution",
859
+ result: {
860
+ outcome: part.codeExecutionResult.outcome,
861
+ output: part.codeExecutionResult.output
862
+ },
863
+ providerExecuted: true
864
+ });
865
+ lastCodeExecutionToolCallId = void 0;
866
+ }
867
+ } else if ("text" in part && part.text != null && part.text.length > 0) {
868
+ if (part.thought === true) {
869
+ if (currentTextBlockId !== null) {
870
+ controller.enqueue({
871
+ type: "text-end",
872
+ id: currentTextBlockId
873
+ });
874
+ currentTextBlockId = null;
875
+ }
876
+ if (currentReasoningBlockId === null) {
877
+ currentReasoningBlockId = String(blockCounter++);
878
+ controller.enqueue({
879
+ type: "reasoning-start",
880
+ id: currentReasoningBlockId,
881
+ providerMetadata: part.thoughtSignature ? {
882
+ google: {
883
+ thoughtSignature: part.thoughtSignature
884
+ }
885
+ } : void 0
886
+ });
887
+ }
888
+ controller.enqueue({
889
+ type: "reasoning-delta",
890
+ id: currentReasoningBlockId,
891
+ delta: part.text,
892
+ providerMetadata: part.thoughtSignature ? {
893
+ google: { thoughtSignature: part.thoughtSignature }
894
+ } : void 0
895
+ });
896
+ } else {
897
+ if (currentReasoningBlockId !== null) {
898
+ controller.enqueue({
899
+ type: "reasoning-end",
900
+ id: currentReasoningBlockId
901
+ });
902
+ currentReasoningBlockId = null;
903
+ }
904
+ if (currentTextBlockId === null) {
905
+ currentTextBlockId = String(blockCounter++);
906
+ controller.enqueue({
907
+ type: "text-start",
908
+ id: currentTextBlockId,
909
+ providerMetadata: part.thoughtSignature ? {
910
+ google: {
911
+ thoughtSignature: part.thoughtSignature
912
+ }
913
+ } : void 0
914
+ });
915
+ }
916
+ controller.enqueue({
917
+ type: "text-delta",
918
+ id: currentTextBlockId,
919
+ delta: part.text,
920
+ providerMetadata: part.thoughtSignature ? {
921
+ google: { thoughtSignature: part.thoughtSignature }
922
+ } : void 0
923
+ });
924
+ }
925
+ }
926
+ }
927
+ const inlineDataParts = getInlineDataParts(content.parts);
928
+ if (inlineDataParts != null) {
929
+ for (const part of inlineDataParts) {
930
+ controller.enqueue({
931
+ type: "file",
932
+ mediaType: part.inlineData.mimeType,
933
+ data: part.inlineData.data
934
+ });
935
+ }
936
+ }
937
+ const toolCallDeltas = getToolCallsFromParts({
938
+ parts: content.parts,
939
+ generateId: generateId2
940
+ });
941
+ if (toolCallDeltas != null) {
942
+ for (const toolCall of toolCallDeltas) {
943
+ controller.enqueue({
944
+ type: "tool-input-start",
945
+ id: toolCall.toolCallId,
946
+ toolName: toolCall.toolName,
947
+ providerMetadata: toolCall.providerMetadata
948
+ });
949
+ controller.enqueue({
950
+ type: "tool-input-delta",
951
+ id: toolCall.toolCallId,
952
+ delta: toolCall.args,
953
+ providerMetadata: toolCall.providerMetadata
954
+ });
955
+ controller.enqueue({
956
+ type: "tool-input-end",
957
+ id: toolCall.toolCallId,
958
+ providerMetadata: toolCall.providerMetadata
959
+ });
960
+ controller.enqueue({
961
+ type: "tool-call",
962
+ toolCallId: toolCall.toolCallId,
963
+ toolName: toolCall.toolName,
964
+ input: toolCall.args,
965
+ providerMetadata: toolCall.providerMetadata
966
+ });
967
+ hasToolCalls = true;
968
+ }
969
+ }
970
+ }
971
+ if (candidate.finishReason != null) {
972
+ finishReason = mapGoogleGenerativeAIFinishReason({
973
+ finishReason: candidate.finishReason,
974
+ hasToolCalls
975
+ });
976
+ providerMetadata = {
977
+ google: {
978
+ groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
979
+ urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
980
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
981
+ }
982
+ };
983
+ if (usageMetadata != null) {
984
+ providerMetadata.google.usageMetadata = usageMetadata;
985
+ }
986
+ }
987
+ },
988
+ flush(controller) {
989
+ if (currentTextBlockId !== null) {
990
+ controller.enqueue({
991
+ type: "text-end",
992
+ id: currentTextBlockId
993
+ });
994
+ }
995
+ if (currentReasoningBlockId !== null) {
996
+ controller.enqueue({
997
+ type: "reasoning-end",
998
+ id: currentReasoningBlockId
999
+ });
1000
+ }
1001
+ controller.enqueue({
1002
+ type: "finish",
1003
+ finishReason,
1004
+ usage,
1005
+ providerMetadata
1006
+ });
1007
+ }
1008
+ })
1009
+ ),
1010
+ response: { headers: responseHeaders },
1011
+ request: { body }
1012
+ };
1013
+ }
1014
+ };
1015
+ function getToolCallsFromParts({
1016
+ parts,
1017
+ generateId: generateId2
1018
+ }) {
1019
+ const functionCallParts = parts == null ? void 0 : parts.filter(
1020
+ (part) => "functionCall" in part
1021
+ );
1022
+ return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1023
+ type: "tool-call",
1024
+ toolCallId: generateId2(),
1025
+ toolName: part.functionCall.name,
1026
+ args: JSON.stringify(part.functionCall.args),
1027
+ providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
1028
+ }));
1029
+ }
1030
+ function getInlineDataParts(parts) {
1031
+ return parts == null ? void 0 : parts.filter(
1032
+ (part) => "inlineData" in part
1033
+ );
1034
+ }
1035
+ function extractSources({
1036
+ groundingMetadata,
1037
+ generateId: generateId2
1038
+ }) {
1039
+ var _a;
1040
+ return (_a = groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks) == null ? void 0 : _a.filter(
1041
+ (chunk) => chunk.web != null
1042
+ ).map((chunk) => ({
1043
+ type: "source",
1044
+ sourceType: "url",
1045
+ id: generateId2(),
1046
+ url: chunk.web.uri,
1047
+ title: chunk.web.title
1048
+ }));
1049
+ }
1050
+ var contentSchema = z5.object({
1051
+ parts: z5.array(
1052
+ z5.union([
1053
+ // note: order matters since text can be fully empty
1054
+ z5.object({
1055
+ functionCall: z5.object({
1056
+ name: z5.string(),
1057
+ args: z5.unknown()
1058
+ }),
1059
+ thoughtSignature: z5.string().nullish()
1060
+ }),
1061
+ z5.object({
1062
+ inlineData: z5.object({
1063
+ mimeType: z5.string(),
1064
+ data: z5.string()
1065
+ })
1066
+ }),
1067
+ z5.object({
1068
+ executableCode: z5.object({
1069
+ language: z5.string(),
1070
+ code: z5.string()
1071
+ }).nullish(),
1072
+ codeExecutionResult: z5.object({
1073
+ outcome: z5.string(),
1074
+ output: z5.string()
1075
+ }).nullish(),
1076
+ text: z5.string().nullish(),
1077
+ thought: z5.boolean().nullish(),
1078
+ thoughtSignature: z5.string().nullish()
1079
+ })
1080
+ ])
1081
+ ).nullish()
1082
+ });
1083
+ var safetyRatingSchema = z5.object({
1084
+ category: z5.string().nullish(),
1085
+ probability: z5.string().nullish(),
1086
+ probabilityScore: z5.number().nullish(),
1087
+ severity: z5.string().nullish(),
1088
+ severityScore: z5.number().nullish(),
1089
+ blocked: z5.boolean().nullish()
1090
+ });
1091
+ var usageSchema = z5.object({
1092
+ cachedContentTokenCount: z5.number().nullish(),
1093
+ thoughtsTokenCount: z5.number().nullish(),
1094
+ promptTokenCount: z5.number().nullish(),
1095
+ candidatesTokenCount: z5.number().nullish(),
1096
+ totalTokenCount: z5.number().nullish()
1097
+ });
1098
+ var responseSchema = z5.object({
1099
+ candidates: z5.array(
1100
+ z5.object({
1101
+ content: contentSchema.nullish().or(z5.object({}).strict()),
1102
+ finishReason: z5.string().nullish(),
1103
+ safetyRatings: z5.array(safetyRatingSchema).nullish(),
1104
+ groundingMetadata: groundingMetadataSchema.nullish(),
1105
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1106
+ })
1107
+ ),
1108
+ usageMetadata: usageSchema.nullish()
1109
+ });
1110
+ var chunkSchema = z5.object({
1111
+ candidates: z5.array(
1112
+ z5.object({
1113
+ content: contentSchema.nullish(),
1114
+ finishReason: z5.string().nullish(),
1115
+ safetyRatings: z5.array(safetyRatingSchema).nullish(),
1116
+ groundingMetadata: groundingMetadataSchema.nullish(),
1117
+ urlContextMetadata: urlContextMetadataSchema.nullish()
1118
+ })
1119
+ ).nullish(),
1120
+ usageMetadata: usageSchema.nullish()
1121
+ });
1122
+
1123
+ // src/tool/code-execution.ts
1124
+ import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
1125
+ import { z as z6 } from "zod/v4";
1126
+ var codeExecution = createProviderDefinedToolFactoryWithOutputSchema({
1127
+ id: "google.code_execution",
1128
+ name: "code_execution",
1129
+ inputSchema: z6.object({
1130
+ language: z6.string().describe("The programming language of the code."),
1131
+ code: z6.string().describe("The code to be executed.")
1132
+ }),
1133
+ outputSchema: z6.object({
1134
+ outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1135
+ output: z6.string().describe("The output from the code execution.")
1136
+ })
1137
+ });
1138
+
1139
+ // src/google-tools.ts
1140
+ var googleTools = {
1141
+ /**
1142
+ * Creates a Google search tool that gives Google direct access to real-time web content.
1143
+ * Must have name "google_search".
1144
+ */
1145
+ googleSearch,
1146
+ /**
1147
+ * Creates a URL context tool that gives Google direct access to real-time web content.
1148
+ * Must have name "url_context".
1149
+ */
1150
+ urlContext,
1151
+ /**
1152
+ * A tool that enables the model to generate and run Python code.
1153
+ * Must have name "code_execution".
1154
+ *
1155
+ * @note Ensure the selected model supports Code Execution.
1156
+ * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
1157
+ *
1158
+ * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
1159
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
1160
+ */
1161
+ codeExecution
1162
+ };
1163
+ export {
1164
+ GoogleGenerativeAILanguageModel,
1165
+ googleTools,
1166
+ safetyRatingSchema
1167
+ };
1168
+ //# sourceMappingURL=index.mjs.map