@ai-sdk/google-vertex 5.0.0-canary.73 → 5.0.0-canary.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/anthropic/edge/index.d.ts +4 -187
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.js.map +1 -1
- package/dist/anthropic/index.d.ts +4 -187
- package/dist/anthropic/index.js.map +1 -1
- package/dist/edge/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/maas/edge/index.js +1 -1
- package/dist/xai/edge/index.js +1 -1
- package/package.json +5 -5
- package/src/anthropic/google-vertex-anthropic-provider.ts +15 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/google-vertex
|
|
2
2
|
|
|
3
|
+
## 5.0.0-canary.74
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [2610e84]
|
|
8
|
+
- Updated dependencies [ebbb0f2]
|
|
9
|
+
- Updated dependencies [69254e0]
|
|
10
|
+
- Updated dependencies [3015fc3]
|
|
11
|
+
- @ai-sdk/anthropic@4.0.0-canary.47
|
|
12
|
+
- @ai-sdk/google@4.0.0-canary.55
|
|
13
|
+
- @ai-sdk/provider-utils@5.0.0-canary.34
|
|
14
|
+
- @ai-sdk/openai-compatible@3.0.0-canary.41
|
|
15
|
+
|
|
3
16
|
## 5.0.0-canary.73
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
|
-
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
1
|
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
4
4
|
|
|
5
5
|
interface GoogleCredentials {
|
|
6
6
|
/**
|
|
@@ -22,195 +22,12 @@ interface GoogleCredentials {
|
|
|
22
22
|
|
|
23
23
|
type GoogleVertexAnthropicModelId = 'claude-opus-4-7' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-opus-4-5@20251101' | 'claude-sonnet-4-5@20250929' | 'claude-opus-4-1@20250805' | 'claude-opus-4@20250514' | 'claude-sonnet-4@20250514' | 'claude-3-7-sonnet@20250219' | 'claude-3-5-sonnet-v2@20241022' | 'claude-3-5-haiku@20241022' | 'claude-3-5-sonnet@20240620' | 'claude-3-haiku@20240307' | 'claude-3-sonnet@20240229' | 'claude-3-opus@20240229' | (string & {});
|
|
24
24
|
|
|
25
|
+
type GoogleVertexAnthropicTools = Pick<typeof anthropicTools, 'bash_20241022' | 'bash_20250124' | 'textEditor_20241022' | 'textEditor_20250124' | 'textEditor_20250429' | 'textEditor_20250728' | 'computer_20241022' | 'webSearch_20250305' | 'toolSearchRegex_20251119' | 'toolSearchBm25_20251119'>;
|
|
25
26
|
/**
|
|
26
27
|
* Tools supported by Google Vertex Anthropic.
|
|
27
28
|
* This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.
|
|
28
29
|
*/
|
|
29
|
-
declare const googleVertexAnthropicTools:
|
|
30
|
-
/**
|
|
31
|
-
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
32
|
-
* allowing system operations, script execution, and command-line automation.
|
|
33
|
-
*
|
|
34
|
-
* Image results are supported.
|
|
35
|
-
*/
|
|
36
|
-
bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
37
|
-
command: string;
|
|
38
|
-
restart?: boolean;
|
|
39
|
-
}, {}, {}>;
|
|
40
|
-
/**
|
|
41
|
-
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
42
|
-
* allowing system operations, script execution, and command-line automation.
|
|
43
|
-
*
|
|
44
|
-
* Image results are supported.
|
|
45
|
-
*/
|
|
46
|
-
bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
47
|
-
command: string;
|
|
48
|
-
restart?: boolean;
|
|
49
|
-
}, {}, {}>;
|
|
50
|
-
/**
|
|
51
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
52
|
-
* helping you debug, fix, and improve your code or other text documents.
|
|
53
|
-
*
|
|
54
|
-
* Supported models: Claude Sonnet 3.5
|
|
55
|
-
*/
|
|
56
|
-
textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
57
|
-
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
58
|
-
path: string;
|
|
59
|
-
file_text?: string;
|
|
60
|
-
insert_line?: number;
|
|
61
|
-
new_str?: string;
|
|
62
|
-
insert_text?: string;
|
|
63
|
-
old_str?: string;
|
|
64
|
-
view_range?: number[];
|
|
65
|
-
}, {}, {}>;
|
|
66
|
-
/**
|
|
67
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
68
|
-
* helping you debug, fix, and improve your code or other text documents.
|
|
69
|
-
*
|
|
70
|
-
* Supported models: Claude Sonnet 3.7
|
|
71
|
-
*/
|
|
72
|
-
textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
73
|
-
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
74
|
-
path: string;
|
|
75
|
-
file_text?: string;
|
|
76
|
-
insert_line?: number;
|
|
77
|
-
new_str?: string;
|
|
78
|
-
insert_text?: string;
|
|
79
|
-
old_str?: string;
|
|
80
|
-
view_range?: number[];
|
|
81
|
-
}, {}, {}>;
|
|
82
|
-
/**
|
|
83
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
84
|
-
* Note: This version does not support the "undo_edit" command.
|
|
85
|
-
* @deprecated Use textEditor_20250728 instead
|
|
86
|
-
*/
|
|
87
|
-
textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
88
|
-
command: "view" | "create" | "str_replace" | "insert";
|
|
89
|
-
path: string;
|
|
90
|
-
file_text?: string;
|
|
91
|
-
insert_line?: number;
|
|
92
|
-
new_str?: string;
|
|
93
|
-
insert_text?: string;
|
|
94
|
-
old_str?: string;
|
|
95
|
-
view_range?: number[];
|
|
96
|
-
}, {}, {}>;
|
|
97
|
-
/**
|
|
98
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
99
|
-
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
100
|
-
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
101
|
-
*/
|
|
102
|
-
textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
103
|
-
command: "view" | "create" | "str_replace" | "insert";
|
|
104
|
-
path: string;
|
|
105
|
-
file_text?: string;
|
|
106
|
-
insert_line?: number;
|
|
107
|
-
new_str?: string;
|
|
108
|
-
insert_text?: string;
|
|
109
|
-
old_str?: string;
|
|
110
|
-
view_range?: number[];
|
|
111
|
-
}, {
|
|
112
|
-
maxCharacters?: number;
|
|
113
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderDefinedTool<{
|
|
114
|
-
command: "view" | "create" | "str_replace" | "insert";
|
|
115
|
-
path: string;
|
|
116
|
-
file_text?: string;
|
|
117
|
-
insert_line?: number;
|
|
118
|
-
new_str?: string;
|
|
119
|
-
insert_text?: string;
|
|
120
|
-
old_str?: string;
|
|
121
|
-
view_range?: number[];
|
|
122
|
-
}, unknown, {}>;
|
|
123
|
-
/**
|
|
124
|
-
* Claude can interact with computer environments through the computer use tool, which
|
|
125
|
-
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
126
|
-
*
|
|
127
|
-
* Image results are supported.
|
|
128
|
-
*/
|
|
129
|
-
computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
130
|
-
action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
|
|
131
|
-
coordinate?: number[];
|
|
132
|
-
text?: string;
|
|
133
|
-
}, {
|
|
134
|
-
displayWidthPx: number;
|
|
135
|
-
displayHeightPx: number;
|
|
136
|
-
displayNumber?: number;
|
|
137
|
-
}, {}>;
|
|
138
|
-
/**
|
|
139
|
-
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
140
|
-
*/
|
|
141
|
-
webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
142
|
-
query: string;
|
|
143
|
-
}, {
|
|
144
|
-
type: "web_search_result";
|
|
145
|
-
url: string;
|
|
146
|
-
title: string | null;
|
|
147
|
-
pageAge: string | null;
|
|
148
|
-
encryptedContent: string;
|
|
149
|
-
}[], {
|
|
150
|
-
maxUses?: number;
|
|
151
|
-
allowedDomains?: string[];
|
|
152
|
-
blockedDomains?: string[];
|
|
153
|
-
userLocation?: {
|
|
154
|
-
type: "approximate";
|
|
155
|
-
city?: string;
|
|
156
|
-
region?: string;
|
|
157
|
-
country?: string;
|
|
158
|
-
timezone?: string;
|
|
159
|
-
};
|
|
160
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{
|
|
161
|
-
query: string;
|
|
162
|
-
}, {
|
|
163
|
-
type: "web_search_result";
|
|
164
|
-
url: string;
|
|
165
|
-
title: string | null;
|
|
166
|
-
pageAge: string | null;
|
|
167
|
-
encryptedContent: string;
|
|
168
|
-
}[], {}>;
|
|
169
|
-
/**
|
|
170
|
-
* Creates a tool search tool that uses regex patterns to find tools.
|
|
171
|
-
*
|
|
172
|
-
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
173
|
-
* by dynamically discovering and loading them on-demand.
|
|
174
|
-
*
|
|
175
|
-
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
176
|
-
* to mark them for deferred loading.
|
|
177
|
-
*/
|
|
178
|
-
toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
179
|
-
pattern: string;
|
|
180
|
-
limit?: number;
|
|
181
|
-
}, {
|
|
182
|
-
type: "tool_reference";
|
|
183
|
-
toolName: string;
|
|
184
|
-
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{
|
|
185
|
-
pattern: string;
|
|
186
|
-
limit?: number;
|
|
187
|
-
}, {
|
|
188
|
-
type: "tool_reference";
|
|
189
|
-
toolName: string;
|
|
190
|
-
}[], {}>;
|
|
191
|
-
/**
|
|
192
|
-
* Creates a tool search tool that uses BM25 (natural language) to find tools.
|
|
193
|
-
*
|
|
194
|
-
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
195
|
-
* by dynamically discovering and loading them on-demand.
|
|
196
|
-
*
|
|
197
|
-
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
198
|
-
* to mark them for deferred loading.
|
|
199
|
-
*/
|
|
200
|
-
toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
201
|
-
query: string;
|
|
202
|
-
limit?: number;
|
|
203
|
-
}, {
|
|
204
|
-
type: "tool_reference";
|
|
205
|
-
toolName: string;
|
|
206
|
-
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{
|
|
207
|
-
query: string;
|
|
208
|
-
limit?: number;
|
|
209
|
-
}, {
|
|
210
|
-
type: "tool_reference";
|
|
211
|
-
toolName: string;
|
|
212
|
-
}[], {}>;
|
|
213
|
-
};
|
|
30
|
+
declare const googleVertexAnthropicTools: GoogleVertexAnthropicTools;
|
|
214
31
|
interface GoogleVertexAnthropicProvider extends ProviderV4 {
|
|
215
32
|
/**
|
|
216
33
|
* Creates a model for text generation.
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ai-sdk/provider-utils";
|
|
11
11
|
|
|
12
12
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "5.0.0-canary.
|
|
13
|
+
var VERSION = true ? "5.0.0-canary.74" : "0.0.0-test";
|
|
14
14
|
|
|
15
15
|
// src/edge/google-vertex-auth-edge.ts
|
|
16
16
|
var loadCredentials = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/anthropic/edge/google-vertex-anthropic-provider-edge.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/version.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["import { resolve } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken as defaultGenerateAuthToken,\n type GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from '../google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n * Optional. The Google credentials for the Google Cloud service account. If\n * not provided, the Google Vertex provider will use environment variables to\n * load the credentials.\n */\n googleCredentials?: GoogleCredentials;\n /**\n * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * with `googleCredentials`.\n */\n generateAuthToken?: () => Promise<string>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n (() => defaultGenerateAuthToken(options.googleCredentials));\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex AI Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\n","import {\n loadOptionalSetting,\n loadSetting,\n withUserAgentSuffix,\n getRuntimeEnvironmentUserAgent,\n} from '@ai-sdk/provider-utils';\nimport { VERSION } from '../version';\n\nexport interface GoogleCredentials {\n /**\n * The client email for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_CLIENT_EMAIL` environment variable.\n */\n clientEmail: string;\n\n /**\n * The private key for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_PRIVATE_KEY` environment variable.\n */\n privateKey: string;\n\n /**\n * Optional. The private key ID for the Google Cloud service account. Defaults\n * to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.\n */\n privateKeyId?: string;\n}\n\nconst loadCredentials = async (): Promise<GoogleCredentials> => {\n try {\n return {\n clientEmail: loadSetting({\n settingValue: undefined,\n settingName: 'clientEmail',\n environmentVariableName: 'GOOGLE_CLIENT_EMAIL',\n description: 'Google client email',\n }),\n privateKey: loadSetting({\n settingValue: undefined,\n settingName: 'privateKey',\n environmentVariableName: 'GOOGLE_PRIVATE_KEY',\n description: 'Google private key',\n }),\n privateKeyId: loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'GOOGLE_PRIVATE_KEY_ID',\n }),\n };\n } catch (error: any) {\n throw new Error(`Failed to load Google credentials: ${error.message}`);\n }\n};\n\n// Convert a string to base64url\nconst base64url = (str: string) => {\n return btoa(str).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n};\nconst importPrivateKey = async (pemKey: string) => {\n const pemHeader = '-----BEGIN PRIVATE KEY-----';\n const pemFooter = '-----END PRIVATE KEY-----';\n\n // Remove header, footer, and any whitespace/newlines\n const pemContents = pemKey\n .replace(pemHeader, '')\n .replace(pemFooter, '')\n .replace(/\\s/g, '');\n\n // Decode base64 to binary\n const binaryString = atob(pemContents);\n\n // Convert binary string to Uint8Array\n const binaryData = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n binaryData[i] = binaryString.charCodeAt(i);\n }\n\n return await crypto.subtle.importKey(\n 'pkcs8',\n binaryData,\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\n true,\n ['sign'],\n );\n};\n\nconst buildJwt = async (credentials: GoogleCredentials) => {\n const now = Math.floor(Date.now() / 1000);\n\n // Only include kid in header if privateKeyId is provided\n const header: { alg: string; typ: string; kid?: string } = {\n alg: 'RS256',\n typ: 'JWT',\n };\n\n if (credentials.privateKeyId) {\n header.kid = credentials.privateKeyId;\n }\n\n const payload = {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/cloud-platform',\n aud: 'https://oauth2.googleapis.com/token',\n exp: now + 3600,\n iat: now,\n };\n\n const privateKey = await importPrivateKey(credentials.privateKey);\n\n const signingInput = `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}`;\n const encoder = new TextEncoder();\n const data = encoder.encode(signingInput);\n\n const signature = await crypto.subtle.sign(\n 'RSASSA-PKCS1-v1_5',\n privateKey,\n data,\n );\n\n const signatureBase64 = base64url(\n String.fromCharCode(...new Uint8Array(signature)),\n );\n\n return `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}.${signatureBase64}`;\n};\n\n/**\n * Generate an authentication token for Google Vertex AI in a manner compatible\n * with the Edge runtime.\n */\nexport async function generateAuthToken(credentials?: GoogleCredentials) {\n try {\n const creds = credentials || (await loadCredentials());\n const jwt = await buildJwt(creds);\n\n const response = await fetch('https://oauth2.googleapis.com/token', {\n method: 'POST',\n headers: withUserAgentSuffix(\n { 'Content-Type': 'application/x-www-form-urlencoded' },\n `ai-sdk/google-vertex/${VERSION}`,\n getRuntimeEnvironmentUserAgent(),\n ),\n body: new URLSearchParams({\n grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n assertion: jwt,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Token request failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.access_token;\n } catch (error) {\n throw error;\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create a Google Vertex Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n return (\n withoutTrailingSlash(options.baseURL) ??\n `https://${location === 'global' ? '' : location + '-'}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`\n );\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\n"],"mappings":";AAAA,SAAS,eAAe;;;ACAxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACHA,IAAM,UACX,OACI,oBACA;;;ADuBN,IAAM,kBAAkB,YAAwC;AAC9D,MAAI;AACF,WAAO;AAAA,MACL,aAAa,YAAY;AAAA,QACvB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,YAAY,YAAY;AAAA,QACtB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,cAAc,oBAAoB;AAAA,QAChC,cAAc;AAAA,QACd,yBAAyB;AAAA,MAC3B,CAAC;AAAA,IACH;AAAA,EACF,SAAS,OAAY;AACnB,UAAM,IAAI,MAAM,sCAAsC,MAAM,OAAO,EAAE;AAAA,EACvE;AACF;AAGA,IAAM,YAAY,CAAC,QAAgB;AACjC,SAAO,KAAK,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,MAAM,EAAE;AAC3E;AACA,IAAM,mBAAmB,OAAO,WAAmB;AACjD,QAAM,YAAY;AAClB,QAAM,YAAY;AAGlB,QAAM,cAAc,OACjB,QAAQ,WAAW,EAAE,EACrB,QAAQ,WAAW,EAAE,EACrB,QAAQ,OAAO,EAAE;AAGpB,QAAM,eAAe,KAAK,WAAW;AAGrC,QAAM,aAAa,IAAI,WAAW,aAAa,MAAM;AACrD,WAAS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AA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;AHhNO,SAASC,6BACd,UAAiD,CAAC,GACnB;AA5BjC;AA6BE,QAAMC,sBACJ,aAAQ,sBAAR,aACC,MAAM,kBAAyB,QAAQ,iBAAiB;AAC3D,SAAO,4BAA8B;AAAA,IACnC,GAAG;AAAA,IACH,SAAS,aAAa;AAAA,MACpB,eAAe,UAAU,MAAMA,mBAAkB,CAAC;AAAA,MAClD,GAAI,MAAM,QAAQ,QAAQ,OAAO;AAAA,IACnC;AAAA,EACF,CAAC;AACH;AAKO,IAAM,wBAAwBD,6BAA4B;","names":["loadOptionalSetting","createGoogleVertexAnthropic","generateAuthToken"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/anthropic/edge/google-vertex-anthropic-provider-edge.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/version.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["import { resolve } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken as defaultGenerateAuthToken,\n type GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from '../google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n * Optional. The Google credentials for the Google Cloud service account. If\n * not provided, the Google Vertex provider will use environment variables to\n * load the credentials.\n */\n googleCredentials?: GoogleCredentials;\n /**\n * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * with `googleCredentials`.\n */\n generateAuthToken?: () => Promise<string>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n (() => defaultGenerateAuthToken(options.googleCredentials));\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex AI Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\n","import {\n loadOptionalSetting,\n loadSetting,\n withUserAgentSuffix,\n getRuntimeEnvironmentUserAgent,\n} from '@ai-sdk/provider-utils';\nimport { VERSION } from '../version';\n\nexport interface GoogleCredentials {\n /**\n * The client email for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_CLIENT_EMAIL` environment variable.\n */\n clientEmail: string;\n\n /**\n * The private key for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_PRIVATE_KEY` environment variable.\n */\n privateKey: string;\n\n /**\n * Optional. The private key ID for the Google Cloud service account. Defaults\n * to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.\n */\n privateKeyId?: string;\n}\n\nconst loadCredentials = async (): Promise<GoogleCredentials> => {\n try {\n return {\n clientEmail: loadSetting({\n settingValue: undefined,\n settingName: 'clientEmail',\n environmentVariableName: 'GOOGLE_CLIENT_EMAIL',\n description: 'Google client email',\n }),\n privateKey: loadSetting({\n settingValue: undefined,\n settingName: 'privateKey',\n environmentVariableName: 'GOOGLE_PRIVATE_KEY',\n description: 'Google private key',\n }),\n privateKeyId: loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'GOOGLE_PRIVATE_KEY_ID',\n }),\n };\n } catch (error: any) {\n throw new Error(`Failed to load Google credentials: ${error.message}`);\n }\n};\n\n// Convert a string to base64url\nconst base64url = (str: string) => {\n return btoa(str).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n};\nconst importPrivateKey = async (pemKey: string) => {\n const pemHeader = '-----BEGIN PRIVATE KEY-----';\n const pemFooter = '-----END PRIVATE KEY-----';\n\n // Remove header, footer, and any whitespace/newlines\n const pemContents = pemKey\n .replace(pemHeader, '')\n .replace(pemFooter, '')\n .replace(/\\s/g, '');\n\n // Decode base64 to binary\n const binaryString = atob(pemContents);\n\n // Convert binary string to Uint8Array\n const binaryData = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n binaryData[i] = binaryString.charCodeAt(i);\n }\n\n return await crypto.subtle.importKey(\n 'pkcs8',\n binaryData,\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\n true,\n ['sign'],\n );\n};\n\nconst buildJwt = async (credentials: GoogleCredentials) => {\n const now = Math.floor(Date.now() / 1000);\n\n // Only include kid in header if privateKeyId is provided\n const header: { alg: string; typ: string; kid?: string } = {\n alg: 'RS256',\n typ: 'JWT',\n };\n\n if (credentials.privateKeyId) {\n header.kid = credentials.privateKeyId;\n }\n\n const payload = {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/cloud-platform',\n aud: 'https://oauth2.googleapis.com/token',\n exp: now + 3600,\n iat: now,\n };\n\n const privateKey = await importPrivateKey(credentials.privateKey);\n\n const signingInput = `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}`;\n const encoder = new TextEncoder();\n const data = encoder.encode(signingInput);\n\n const signature = await crypto.subtle.sign(\n 'RSASSA-PKCS1-v1_5',\n privateKey,\n data,\n );\n\n const signatureBase64 = base64url(\n String.fromCharCode(...new Uint8Array(signature)),\n );\n\n return `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}.${signatureBase64}`;\n};\n\n/**\n * Generate an authentication token for Google Vertex AI in a manner compatible\n * with the Edge runtime.\n */\nexport async function generateAuthToken(credentials?: GoogleCredentials) {\n try {\n const creds = credentials || (await loadCredentials());\n const jwt = await buildJwt(creds);\n\n const response = await fetch('https://oauth2.googleapis.com/token', {\n method: 'POST',\n headers: withUserAgentSuffix(\n { 'Content-Type': 'application/x-www-form-urlencoded' },\n `ai-sdk/google-vertex/${VERSION}`,\n getRuntimeEnvironmentUserAgent(),\n ),\n body: new URLSearchParams({\n grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n assertion: jwt,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Token request failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.access_token;\n } catch (error) {\n throw error;\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';\n\ntype GoogleVertexAnthropicTools = Pick<\n typeof anthropicTools,\n | 'bash_20241022'\n | 'bash_20250124'\n | 'textEditor_20241022'\n | 'textEditor_20250124'\n | 'textEditor_20250429'\n | 'textEditor_20250728'\n | 'computer_20241022'\n | 'webSearch_20250305'\n | 'toolSearchRegex_20251119'\n | 'toolSearchBm25_20251119'\n>;\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools: GoogleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create a Google Vertex Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n return (\n withoutTrailingSlash(options.baseURL) ??\n `https://${location === 'global' ? '' : location + '-'}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`\n );\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\n"],"mappings":";AAAA,SAAS,eAAe;;;ACAxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACHA,IAAM,UACX,OACI,oBACA;;;ADuBN,IAAM,kBAAkB,YAAwC;AAC9D,MAAI;AACF,WAAO;AAAA,MACL,aAAa,YAAY;AAAA,QACvB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,YAAY,YAAY;AAAA,QACtB,cAAc;AAAA,QACd,aAAa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uthOptions } from 'google-auth-library';
|
|
2
|
-
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
2
|
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
3
|
+
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
5
5
|
|
|
6
6
|
type GoogleVertexAnthropicModelId = 'claude-opus-4-7' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-opus-4-5@20251101' | 'claude-sonnet-4-5@20250929' | 'claude-opus-4-1@20250805' | 'claude-opus-4@20250514' | 'claude-sonnet-4@20250514' | 'claude-3-7-sonnet@20250219' | 'claude-3-5-sonnet-v2@20241022' | 'claude-3-5-haiku@20241022' | 'claude-3-5-sonnet@20240620' | 'claude-3-haiku@20240307' | 'claude-3-sonnet@20240229' | 'claude-3-opus@20240229' | (string & {});
|
|
7
7
|
|
|
8
|
+
type GoogleVertexAnthropicTools = Pick<typeof anthropicTools, 'bash_20241022' | 'bash_20250124' | 'textEditor_20241022' | 'textEditor_20250124' | 'textEditor_20250429' | 'textEditor_20250728' | 'computer_20241022' | 'webSearch_20250305' | 'toolSearchRegex_20251119' | 'toolSearchBm25_20251119'>;
|
|
8
9
|
/**
|
|
9
10
|
* Tools supported by Google Vertex Anthropic.
|
|
10
11
|
* This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.
|
|
11
12
|
*/
|
|
12
|
-
declare const googleVertexAnthropicTools:
|
|
13
|
-
/**
|
|
14
|
-
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
15
|
-
* allowing system operations, script execution, and command-line automation.
|
|
16
|
-
*
|
|
17
|
-
* Image results are supported.
|
|
18
|
-
*/
|
|
19
|
-
bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
20
|
-
command: string;
|
|
21
|
-
restart?: boolean;
|
|
22
|
-
}, {}, {}>;
|
|
23
|
-
/**
|
|
24
|
-
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
25
|
-
* allowing system operations, script execution, and command-line automation.
|
|
26
|
-
*
|
|
27
|
-
* Image results are supported.
|
|
28
|
-
*/
|
|
29
|
-
bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
30
|
-
command: string;
|
|
31
|
-
restart?: boolean;
|
|
32
|
-
}, {}, {}>;
|
|
33
|
-
/**
|
|
34
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
35
|
-
* helping you debug, fix, and improve your code or other text documents.
|
|
36
|
-
*
|
|
37
|
-
* Supported models: Claude Sonnet 3.5
|
|
38
|
-
*/
|
|
39
|
-
textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
40
|
-
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
41
|
-
path: string;
|
|
42
|
-
file_text?: string;
|
|
43
|
-
insert_line?: number;
|
|
44
|
-
new_str?: string;
|
|
45
|
-
insert_text?: string;
|
|
46
|
-
old_str?: string;
|
|
47
|
-
view_range?: number[];
|
|
48
|
-
}, {}, {}>;
|
|
49
|
-
/**
|
|
50
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
51
|
-
* helping you debug, fix, and improve your code or other text documents.
|
|
52
|
-
*
|
|
53
|
-
* Supported models: Claude Sonnet 3.7
|
|
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
|
-
insert_text?: string;
|
|
62
|
-
old_str?: string;
|
|
63
|
-
view_range?: number[];
|
|
64
|
-
}, {}, {}>;
|
|
65
|
-
/**
|
|
66
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
67
|
-
* Note: This version does not support the "undo_edit" command.
|
|
68
|
-
* @deprecated Use textEditor_20250728 instead
|
|
69
|
-
*/
|
|
70
|
-
textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
71
|
-
command: "view" | "create" | "str_replace" | "insert";
|
|
72
|
-
path: string;
|
|
73
|
-
file_text?: string;
|
|
74
|
-
insert_line?: number;
|
|
75
|
-
new_str?: string;
|
|
76
|
-
insert_text?: string;
|
|
77
|
-
old_str?: string;
|
|
78
|
-
view_range?: number[];
|
|
79
|
-
}, {}, {}>;
|
|
80
|
-
/**
|
|
81
|
-
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
82
|
-
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
83
|
-
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
84
|
-
*/
|
|
85
|
-
textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
86
|
-
command: "view" | "create" | "str_replace" | "insert";
|
|
87
|
-
path: string;
|
|
88
|
-
file_text?: string;
|
|
89
|
-
insert_line?: number;
|
|
90
|
-
new_str?: string;
|
|
91
|
-
insert_text?: string;
|
|
92
|
-
old_str?: string;
|
|
93
|
-
view_range?: number[];
|
|
94
|
-
}, {
|
|
95
|
-
maxCharacters?: number;
|
|
96
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderDefinedTool<{
|
|
97
|
-
command: "view" | "create" | "str_replace" | "insert";
|
|
98
|
-
path: string;
|
|
99
|
-
file_text?: string;
|
|
100
|
-
insert_line?: number;
|
|
101
|
-
new_str?: string;
|
|
102
|
-
insert_text?: string;
|
|
103
|
-
old_str?: string;
|
|
104
|
-
view_range?: number[];
|
|
105
|
-
}, unknown, {}>;
|
|
106
|
-
/**
|
|
107
|
-
* Claude can interact with computer environments through the computer use tool, which
|
|
108
|
-
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
109
|
-
*
|
|
110
|
-
* Image results are supported.
|
|
111
|
-
*/
|
|
112
|
-
computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
113
|
-
action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
|
|
114
|
-
coordinate?: number[];
|
|
115
|
-
text?: string;
|
|
116
|
-
}, {
|
|
117
|
-
displayWidthPx: number;
|
|
118
|
-
displayHeightPx: number;
|
|
119
|
-
displayNumber?: number;
|
|
120
|
-
}, {}>;
|
|
121
|
-
/**
|
|
122
|
-
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
123
|
-
*/
|
|
124
|
-
webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
125
|
-
query: string;
|
|
126
|
-
}, {
|
|
127
|
-
type: "web_search_result";
|
|
128
|
-
url: string;
|
|
129
|
-
title: string | null;
|
|
130
|
-
pageAge: string | null;
|
|
131
|
-
encryptedContent: string;
|
|
132
|
-
}[], {
|
|
133
|
-
maxUses?: number;
|
|
134
|
-
allowedDomains?: string[];
|
|
135
|
-
blockedDomains?: string[];
|
|
136
|
-
userLocation?: {
|
|
137
|
-
type: "approximate";
|
|
138
|
-
city?: string;
|
|
139
|
-
region?: string;
|
|
140
|
-
country?: string;
|
|
141
|
-
timezone?: string;
|
|
142
|
-
};
|
|
143
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{
|
|
144
|
-
query: string;
|
|
145
|
-
}, {
|
|
146
|
-
type: "web_search_result";
|
|
147
|
-
url: string;
|
|
148
|
-
title: string | null;
|
|
149
|
-
pageAge: string | null;
|
|
150
|
-
encryptedContent: string;
|
|
151
|
-
}[], {}>;
|
|
152
|
-
/**
|
|
153
|
-
* Creates a tool search tool that uses regex patterns to find tools.
|
|
154
|
-
*
|
|
155
|
-
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
156
|
-
* by dynamically discovering and loading them on-demand.
|
|
157
|
-
*
|
|
158
|
-
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
159
|
-
* to mark them for deferred loading.
|
|
160
|
-
*/
|
|
161
|
-
toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
162
|
-
pattern: string;
|
|
163
|
-
limit?: number;
|
|
164
|
-
}, {
|
|
165
|
-
type: "tool_reference";
|
|
166
|
-
toolName: string;
|
|
167
|
-
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{
|
|
168
|
-
pattern: string;
|
|
169
|
-
limit?: number;
|
|
170
|
-
}, {
|
|
171
|
-
type: "tool_reference";
|
|
172
|
-
toolName: string;
|
|
173
|
-
}[], {}>;
|
|
174
|
-
/**
|
|
175
|
-
* Creates a tool search tool that uses BM25 (natural language) to find tools.
|
|
176
|
-
*
|
|
177
|
-
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
178
|
-
* by dynamically discovering and loading them on-demand.
|
|
179
|
-
*
|
|
180
|
-
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
181
|
-
* to mark them for deferred loading.
|
|
182
|
-
*/
|
|
183
|
-
toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
184
|
-
query: string;
|
|
185
|
-
limit?: number;
|
|
186
|
-
}, {
|
|
187
|
-
type: "tool_reference";
|
|
188
|
-
toolName: string;
|
|
189
|
-
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{
|
|
190
|
-
query: string;
|
|
191
|
-
limit?: number;
|
|
192
|
-
}, {
|
|
193
|
-
type: "tool_reference";
|
|
194
|
-
toolName: string;
|
|
195
|
-
}[], {}>;
|
|
196
|
-
};
|
|
13
|
+
declare const googleVertexAnthropicTools: GoogleVertexAnthropicTools;
|
|
197
14
|
interface GoogleVertexAnthropicProvider extends ProviderV4 {
|
|
198
15
|
/**
|
|
199
16
|
* Creates a model for text generation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/anthropic/google-vertex-anthropic-provider-node.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["import { resolve } from '@ai-sdk/provider-utils';\nimport type { GoogleAuthOptions } from 'google-auth-library';\nimport { createAuthTokenGenerator } from '../google-vertex-auth-google-auth-library';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from './google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n * Optional. The Authentication options provided by google-auth-library.\n * Complete list of authentication options is documented in the\n * GoogleAuthOptions interface:\n * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.\n */\n googleAuthOptions?: GoogleAuthOptions;\n /**\n * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * via `google-auth-library` with `googleAuthOptions`.\n */\n generateAuthToken?: () => Promise<string | null>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n createAuthTokenGenerator(options.googleAuthOptions);\n\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\n","import { GoogleAuth, type GoogleAuthOptions } from 'google-auth-library';\n\nexport function createAuthTokenGenerator(options?: GoogleAuthOptions) {\n const auth = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n ...options,\n });\n\n return async function generateAuthToken() {\n const client = await auth.getClient();\n const token = await client.getAccessToken();\n return token?.token ?? null;\n };\n}\n","import {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create a Google Vertex Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n return (\n withoutTrailingSlash(options.baseURL) ??\n `https://${location === 'global' ? '' : location + '-'}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`\n );\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\n"],"mappings":";AAAA,SAAS,eAAe;;;ACAxB,SAAS,kBAA0C;AAE5C,SAAS,yBAAyB,SAA6B;AACpE,QAAM,OAAO,IAAI,WAAW;AAAA,IAC1B,QAAQ,CAAC,gDAAgD;AAAA,IACzD,GAAG;AAAA,EACL,CAAC;AAED,SAAO,eAAe,oBAAoB;AAR5C;AASI,UAAM,SAAS,MAAM,KAAK,UAAU;AACpC,UAAM,QAAQ,MAAM,OAAO,eAAe;AAC1C,YAAO,oCAAO,UAAP,YAAgB;AAAA,EACzB;AACF;;;ACbA;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOA,IAAM,6BAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxC,eAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,eAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,qBAAqB,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpC,qBAAqB,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpC,qBAAqB,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpC,qBAAqB,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpC,mBAAmB,eAAe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AO,gBAAgB,OAAO;AAAA,EAChC;AAEA,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,WAAW;AAEpB,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;AFjNO,SAASA,6BACd,UAAiD,CAAC,GACnB;AA3BjC;AA4BE,QAAM,qBACJ,aAAQ,sBAAR,YACA,yBAAyB,QAAQ,iBAAiB;AAEpD,SAAO,4BAA8B;AAAA,IACnC,GAAG;AAAA,IACH,SAAS,aAAa;AAAA,MACpB,eAAe,UAAU,MAAM,kBAAkB,CAAC;AAAA,MAClD,GAAI,MAAM,QAAQ,QAAQ,OAAO;AAAA,IACnC;AAAA,EACF,CAAC;AACH;AAKO,IAAM,wBAAwBA,6BAA4B;","names":["createGoogleVertexAnthropic"]}
|
|
1
|
+
{"version":3,"sources":["../../src/anthropic/google-vertex-anthropic-provider-node.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["import { resolve } from '@ai-sdk/provider-utils';\nimport type { GoogleAuthOptions } from 'google-auth-library';\nimport { createAuthTokenGenerator } from '../google-vertex-auth-google-auth-library';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from './google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n * Optional. The Authentication options provided by google-auth-library.\n * Complete list of authentication options is documented in the\n * GoogleAuthOptions interface:\n * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.\n */\n googleAuthOptions?: GoogleAuthOptions;\n /**\n * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * via `google-auth-library` with `googleAuthOptions`.\n */\n generateAuthToken?: () => Promise<string | null>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n createAuthTokenGenerator(options.googleAuthOptions);\n\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\n","import { GoogleAuth, type GoogleAuthOptions } from 'google-auth-library';\n\nexport function createAuthTokenGenerator(options?: GoogleAuthOptions) {\n const auth = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n ...options,\n });\n\n return async function generateAuthToken() {\n const client = await auth.getClient();\n const token = await client.getAccessToken();\n return token?.token ?? null;\n };\n}\n","import {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';\n\ntype GoogleVertexAnthropicTools = Pick<\n typeof anthropicTools,\n | 'bash_20241022'\n | 'bash_20250124'\n | 'textEditor_20241022'\n | 'textEditor_20250124'\n | 'textEditor_20250429'\n | 'textEditor_20250728'\n | 'computer_20241022'\n | 'webSearch_20250305'\n | 'toolSearchRegex_20251119'\n | 'toolSearchBm25_20251119'\n>;\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools: GoogleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create a Google Vertex Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n return (\n withoutTrailingSlash(options.baseURL) ??\n `https://${location === 'global' ? '' : location + '-'}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`\n );\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\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EACjE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;AF/NO,SAASA,6BACd,UAAiD,CAAC,GACnB;AA3BjC;AA4BE,QAAM,qBACJ,aAAQ,sBAAR,YACA,yBAAyB,QAAQ,iBAAiB;AAEpD,SAAO,4BAA8B;AAAA,IACnC,GAAG;AAAA,IACH,SAAS,aAAa;AAAA,MACpB,eAAe,UAAU,MAAM,kBAAkB,CAAC;AAAA,MAClD,GAAI,MAAM,QAAQ,QAAQ,OAAO;AAAA,IACnC;AAAA,EACF,CAAC;AACH;AAKO,IAAM,wBAAwBA,6BAA4B;","names":["createGoogleVertexAnthropic"]}
|
package/dist/edge/index.js
CHANGED
package/dist/index.js
CHANGED
package/dist/maas/edge/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ai-sdk/provider-utils";
|
|
11
11
|
|
|
12
12
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "5.0.0-canary.
|
|
13
|
+
var VERSION = true ? "5.0.0-canary.74" : "0.0.0-test";
|
|
14
14
|
|
|
15
15
|
// src/edge/google-vertex-auth-edge.ts
|
|
16
16
|
var loadCredentials = async () => {
|
package/dist/xai/edge/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ai-sdk/provider-utils";
|
|
11
11
|
|
|
12
12
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "5.0.0-canary.
|
|
13
|
+
var VERSION = true ? "5.0.0-canary.74" : "0.0.0-test";
|
|
14
14
|
|
|
15
15
|
// src/edge/google-vertex-auth-edge.ts
|
|
16
16
|
var loadCredentials = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google-vertex",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.74",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"google-auth-library": "^10.5.0",
|
|
75
|
-
"@ai-sdk/anthropic": "4.0.0-canary.
|
|
76
|
-
"@ai-sdk/google": "4.0.0-canary.
|
|
77
|
-
"@ai-sdk/openai-compatible": "3.0.0-canary.
|
|
75
|
+
"@ai-sdk/anthropic": "4.0.0-canary.47",
|
|
76
|
+
"@ai-sdk/google": "4.0.0-canary.55",
|
|
77
|
+
"@ai-sdk/openai-compatible": "3.0.0-canary.41",
|
|
78
78
|
"@ai-sdk/provider": "4.0.0-canary.16",
|
|
79
|
-
"@ai-sdk/provider-utils": "5.0.0-canary.
|
|
79
|
+
"@ai-sdk/provider-utils": "5.0.0-canary.34"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/node": "20.17.24",
|
|
@@ -15,11 +15,25 @@ import {
|
|
|
15
15
|
} from '@ai-sdk/anthropic/internal';
|
|
16
16
|
import type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';
|
|
17
17
|
|
|
18
|
+
type GoogleVertexAnthropicTools = Pick<
|
|
19
|
+
typeof anthropicTools,
|
|
20
|
+
| 'bash_20241022'
|
|
21
|
+
| 'bash_20250124'
|
|
22
|
+
| 'textEditor_20241022'
|
|
23
|
+
| 'textEditor_20250124'
|
|
24
|
+
| 'textEditor_20250429'
|
|
25
|
+
| 'textEditor_20250728'
|
|
26
|
+
| 'computer_20241022'
|
|
27
|
+
| 'webSearch_20250305'
|
|
28
|
+
| 'toolSearchRegex_20251119'
|
|
29
|
+
| 'toolSearchBm25_20251119'
|
|
30
|
+
>;
|
|
31
|
+
|
|
18
32
|
/**
|
|
19
33
|
* Tools supported by Google Vertex Anthropic.
|
|
20
34
|
* This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.
|
|
21
35
|
*/
|
|
22
|
-
export const googleVertexAnthropicTools = {
|
|
36
|
+
export const googleVertexAnthropicTools: GoogleVertexAnthropicTools = {
|
|
23
37
|
/**
|
|
24
38
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
25
39
|
* allowing system operations, script execution, and command-line automation.
|