@ai-sdk/anthropic 4.0.23 → 4.0.25
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 +18 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +43 -7
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -4
- package/dist/internal/index.js +42 -6
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/sanitize-json-schema.ts +2 -5
- package/src/tool/code-execution_20250825.ts +26 -1
- package/src/tool/code-execution_20260120.ts +26 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/anthropic",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ai-sdk/provider": "4.0.4",
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.16"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "22.19.19",
|
|
43
43
|
"tsup": "^8.5.1",
|
|
44
44
|
"typescript": "5.8.3",
|
|
45
45
|
"zod": "3.25.76",
|
|
46
|
-
"@ai-sdk/test-server": "2.0.
|
|
46
|
+
"@ai-sdk/test-server": "2.0.1",
|
|
47
47
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JSONSchema7, JSONSchema7Definition } from '@ai-sdk/provider';
|
|
2
|
+
import { isRecord } from '@ai-sdk/provider-utils';
|
|
2
3
|
|
|
3
4
|
const SUPPORTED_STRING_FORMATS = new Set([
|
|
4
5
|
'date-time',
|
|
@@ -44,7 +45,7 @@ export function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7 {
|
|
|
44
45
|
function sanitizeDefinition(
|
|
45
46
|
definition: JSONSchema7Definition,
|
|
46
47
|
): JSONSchema7Definition {
|
|
47
|
-
if (typeof definition === 'boolean' || !
|
|
48
|
+
if (typeof definition === 'boolean' || !isRecord(definition)) {
|
|
48
49
|
return definition;
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -197,7 +198,3 @@ function formatConstraintValue(value: unknown): string {
|
|
|
197
198
|
|
|
198
199
|
return JSON.stringify(value);
|
|
199
200
|
}
|
|
200
|
-
|
|
201
|
-
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
202
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
203
|
-
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderExecutedToolFactory,
|
|
3
|
+
experimental_toolCaller,
|
|
3
4
|
lazySchema,
|
|
4
5
|
zodSchema,
|
|
5
6
|
} from '@ai-sdk/provider-utils';
|
|
@@ -277,5 +278,29 @@ const factory = createProviderExecutedToolFactory<
|
|
|
277
278
|
export const codeExecution_20250825 = (
|
|
278
279
|
args: Parameters<typeof factory>[0] = {},
|
|
279
280
|
) => {
|
|
280
|
-
return factory(args)
|
|
281
|
+
return experimental_toolCaller(factory(args), {
|
|
282
|
+
type: 'provider',
|
|
283
|
+
prepareProviderOptions: providerOptions => {
|
|
284
|
+
const anthropicOptions = providerOptions?.anthropic as
|
|
285
|
+
| {
|
|
286
|
+
allowedCallers?: Array<
|
|
287
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120'
|
|
288
|
+
>;
|
|
289
|
+
}
|
|
290
|
+
| undefined;
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
...providerOptions,
|
|
294
|
+
anthropic: {
|
|
295
|
+
...anthropicOptions,
|
|
296
|
+
allowedCallers: [
|
|
297
|
+
...new Set([
|
|
298
|
+
...(anthropicOptions?.allowedCallers ?? []),
|
|
299
|
+
'code_execution_20250825' as const,
|
|
300
|
+
]),
|
|
301
|
+
],
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
},
|
|
305
|
+
});
|
|
281
306
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderExecutedToolFactory,
|
|
3
|
+
experimental_toolCaller,
|
|
3
4
|
lazySchema,
|
|
4
5
|
zodSchema,
|
|
5
6
|
} from '@ai-sdk/provider-utils';
|
|
@@ -311,5 +312,29 @@ const factory = createProviderExecutedToolFactory<
|
|
|
311
312
|
export const codeExecution_20260120 = (
|
|
312
313
|
args: Parameters<typeof factory>[0] = {},
|
|
313
314
|
) => {
|
|
314
|
-
return factory(args)
|
|
315
|
+
return experimental_toolCaller(factory(args), {
|
|
316
|
+
type: 'provider',
|
|
317
|
+
prepareProviderOptions: providerOptions => {
|
|
318
|
+
const anthropicOptions = providerOptions?.anthropic as
|
|
319
|
+
| {
|
|
320
|
+
allowedCallers?: Array<
|
|
321
|
+
'direct' | 'code_execution_20250825' | 'code_execution_20260120'
|
|
322
|
+
>;
|
|
323
|
+
}
|
|
324
|
+
| undefined;
|
|
325
|
+
|
|
326
|
+
return {
|
|
327
|
+
...providerOptions,
|
|
328
|
+
anthropic: {
|
|
329
|
+
...anthropicOptions,
|
|
330
|
+
allowedCallers: [
|
|
331
|
+
...new Set([
|
|
332
|
+
...(anthropicOptions?.allowedCallers ?? []),
|
|
333
|
+
'code_execution_20260120' as const,
|
|
334
|
+
]),
|
|
335
|
+
],
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
});
|
|
315
340
|
};
|