You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@ai-sdk/provider-utils

Package Overview
Dependencies
Maintainers
3
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/provider-utils - npm Package Compare versions

Comparing version
5.0.0-beta.3
to
5.0.0-beta.4
+75
-0
CHANGELOG.md
# @ai-sdk/provider-utils
## 5.0.0-beta.4
### Major Changes
- 61753c3: ### `@ai-sdk/openai`: remove redundant `name` argument from `openai.tools.customTool()`
`openai.tools.customTool()` no longer accepts a `name` field. the tool name is now derived from the sdk tool key (the object key in the `tools` object).
migration: remove the `name` property from `customTool()` calls. the object key is now used as the tool name sent to the openai api.
before:
```ts
tools: {
write_sql: openai.tools.customTool({
name: 'write_sql',
description: '...',
}),
}
```
after:
```ts
tools: {
write_sql: openai.tools.customTool({
description: '...',
}),
}
```
### `@ai-sdk/provider-utils`: `createToolNameMapping()` no longer accepts the `resolveProviderToolName` parameter
before: tool name can be set dynamically
```ts
const toolNameMapping = createToolNameMapping({
tools,
providerToolNames: {
'openai.code_interpreter': 'code_interpreter',
'openai.file_search': 'file_search',
'openai.image_generation': 'image_generation',
'openai.local_shell': 'local_shell',
'openai.shell': 'shell',
'openai.web_search': 'web_search',
'openai.web_search_preview': 'web_search_preview',
'openai.mcp': 'mcp',
'openai.apply_patch': 'apply_patch',
},
resolveProviderToolName: tool =>
tool.id === 'openai.custom'
? (tool.args as { name?: string }).name
: undefined,
});
```
after: tool name is static based on `tools` keys
```
const toolNameMapping = createToolNameMapping({
tools,
providerToolNames: {
'openai.code_interpreter': 'code_interpreter',
'openai.file_search': 'file_search',
'openai.image_generation': 'image_generation',
'openai.local_shell': 'local_shell',
'openai.shell': 'shell',
'openai.web_search': 'web_search',
'openai.web_search_preview': 'web_search_preview',
'openai.mcp': 'mcp',
'openai.apply_patch': 'apply_patch',
}
});
```
## 5.0.0-beta.3

@@ -4,0 +79,0 @@

+10
-13

@@ -1,2 +0,2 @@

import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
import { LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, ImageModelV4File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV4Prompt, SharedV4ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';

@@ -44,7 +44,7 @@ export * from '@standard-schema/spec';

*/
declare function createToolNameMapping({ tools, providerToolNames, resolveProviderToolName, }: {
declare function createToolNameMapping({ tools, providerToolNames, }: {
/**
* Tools that were passed to the language model.
*/
tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined;
tools: Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool> | undefined;
/**

@@ -54,7 +54,2 @@ * Maps the provider tool ids to the provider tool names.

providerToolNames: Record<`${string}.${string}`, string>;
/**
* Optional resolver for provider tool names that cannot be represented as
* static id -> name mappings (e.g. dynamic provider names).
*/
resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
}): ToolNameMapping;

@@ -102,3 +97,3 @@

/**
* Convert an ImageModelV3File to a URL or data URI string.
* Convert an ImageModelV4File to a URL or data URI string.
*

@@ -109,3 +104,3 @@ * If the file is a URL, it returns the URL as-is.

*/
declare function convertImageModelFileToDataUri(file: ImageModelV3File): string;
declare function convertImageModelFileToDataUri(file: ImageModelV4File): string;

@@ -397,7 +392,7 @@ /**

declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPrefix, schemaSuffix, }: {
messages: LanguageModelV3Prompt;
messages: LanguageModelV4Prompt;
schema?: JSONSchema7;
schemaPrefix?: string;
schemaSuffix?: string;
}): LanguageModelV3Prompt;
}): LanguageModelV4Prompt;

@@ -557,3 +552,3 @@ declare function isAbortError(error: unknown): error is Error;

*/
type ProviderOptions = SharedV3ProviderOptions;
type ProviderOptions = SharedV4ProviderOptions;

@@ -1154,2 +1149,4 @@ /**

* If not provided, the tool result will be sent as a JSON object.
*
* This function is invoked on the server by `convertToModelMessages`, so ensure that you pass the same "tools" (ToolSet) to both "convertToModelMessages" and "streamText" (or other generation APIs).
*/

@@ -1156,0 +1153,0 @@ toModelOutput?: (options: {

@@ -1,2 +0,2 @@

import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
import { LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, ImageModelV4File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV4Prompt, SharedV4ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';

@@ -44,7 +44,7 @@ export * from '@standard-schema/spec';

*/
declare function createToolNameMapping({ tools, providerToolNames, resolveProviderToolName, }: {
declare function createToolNameMapping({ tools, providerToolNames, }: {
/**
* Tools that were passed to the language model.
*/
tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined;
tools: Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool> | undefined;
/**

@@ -54,7 +54,2 @@ * Maps the provider tool ids to the provider tool names.

providerToolNames: Record<`${string}.${string}`, string>;
/**
* Optional resolver for provider tool names that cannot be represented as
* static id -> name mappings (e.g. dynamic provider names).
*/
resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
}): ToolNameMapping;

@@ -102,3 +97,3 @@

/**
* Convert an ImageModelV3File to a URL or data URI string.
* Convert an ImageModelV4File to a URL or data URI string.
*

@@ -109,3 +104,3 @@ * If the file is a URL, it returns the URL as-is.

*/
declare function convertImageModelFileToDataUri(file: ImageModelV3File): string;
declare function convertImageModelFileToDataUri(file: ImageModelV4File): string;

@@ -397,7 +392,7 @@ /**

declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPrefix, schemaSuffix, }: {
messages: LanguageModelV3Prompt;
messages: LanguageModelV4Prompt;
schema?: JSONSchema7;
schemaPrefix?: string;
schemaSuffix?: string;
}): LanguageModelV3Prompt;
}): LanguageModelV4Prompt;

@@ -557,3 +552,3 @@ declare function isAbortError(error: unknown): error is Error;

*/
type ProviderOptions = SharedV3ProviderOptions;
type ProviderOptions = SharedV4ProviderOptions;

@@ -1154,2 +1149,4 @@ /**

* If not provided, the tool result will be sent as a JSON object.
*
* This function is invoked on the server by `convertToModelMessages`, so ensure that you pass the same "tools" (ToolSet) to both "convertToModelMessages" and "streamText" (or other generation APIs).
*/

@@ -1156,0 +1153,0 @@ toModelOutput?: (options: {

{
"name": "@ai-sdk/provider-utils",
"version": "5.0.0-beta.3",
"version": "5.0.0-beta.4",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -1,6 +0,6 @@

import { ImageModelV3File } from '@ai-sdk/provider';
import { ImageModelV4File } from '@ai-sdk/provider';
import { convertUint8ArrayToBase64 } from './uint8-utils';
/**
* Convert an ImageModelV3File to a URL or data URI string.
* Convert an ImageModelV4File to a URL or data URI string.
*

@@ -11,3 +11,3 @@ * If the file is a URL, it returns the URL as-is.

*/
export function convertImageModelFileToDataUri(file: ImageModelV3File): string {
export function convertImageModelFileToDataUri(file: ImageModelV4File): string {
if (file.type === 'url') return file.url;

@@ -14,0 +14,0 @@

import {
LanguageModelV3FunctionTool,
LanguageModelV3ProviderTool,
LanguageModelV4FunctionTool,
LanguageModelV4ProviderTool,
} from '@ai-sdk/provider';

@@ -36,3 +36,2 @@

providerToolNames,
resolveProviderToolName,
}: {

@@ -43,3 +42,3 @@ /**

tools:
| Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool>
| Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool>
| undefined;

@@ -51,10 +50,2 @@

providerToolNames: Record<`${string}.${string}`, string>;
/**
* Optional resolver for provider tool names that cannot be represented as
* static id -> name mappings (e.g. dynamic provider names).
*/
resolveProviderToolName?: (
tool: LanguageModelV3ProviderTool,
) => string | undefined;
}): ToolNameMapping {

@@ -65,11 +56,4 @@ const customToolNameToProviderToolName: Record<string, string> = {};

for (const tool of tools) {
if (tool.type === 'provider') {
const providerToolName =
resolveProviderToolName?.(tool) ??
(tool.id in providerToolNames ? providerToolNames[tool.id] : undefined);
if (providerToolName == null) {
continue;
}
if (tool.type === 'provider' && tool.id in providerToolNames) {
const providerToolName = providerToolNames[tool.id];
customToolNameToProviderToolName[tool.name] = providerToolName;

@@ -76,0 +60,0 @@ providerToolNameToCustomToolName[providerToolName] = tool.name;

import {
JSONSchema7,
LanguageModelV3Message,
LanguageModelV3Prompt,
LanguageModelV4Message,
LanguageModelV4Prompt,
} from '@ai-sdk/provider';

@@ -42,8 +42,8 @@

}: {
messages: LanguageModelV3Prompt;
messages: LanguageModelV4Prompt;
schema?: JSONSchema7;
schemaPrefix?: string;
schemaSuffix?: string;
}): LanguageModelV3Prompt {
const systemMessage: LanguageModelV3Message =
}): LanguageModelV4Prompt {
const systemMessage: LanguageModelV4Message =
messages[0]?.role === 'system'

@@ -50,0 +50,0 @@ ? { ...messages[0] }

@@ -1,2 +0,2 @@

import { SharedV3ProviderOptions } from '@ai-sdk/provider';
import { SharedV4ProviderOptions } from '@ai-sdk/provider';

@@ -9,2 +9,2 @@ /**

*/
export type ProviderOptions = SharedV3ProviderOptions;
export type ProviderOptions = SharedV4ProviderOptions;

@@ -190,2 +190,4 @@ import { JSONValue } from '@ai-sdk/provider';

* If not provided, the tool result will be sent as a JSON object.
*
* This function is invoked on the server by `convertToModelMessages`, so ensure that you pass the same "tools" (ToolSet) to both "convertToModelMessages" and "streamText" (or other generation APIs).
*/

@@ -192,0 +194,0 @@ toModelOutput?: (options: {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display