@ai-sdk/openai 4.0.0-beta.4 → 4.0.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +387 -22
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +162 -45
  4. package/dist/index.js +2341 -1572
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +174 -51
  7. package/dist/internal/index.js +2110 -1593
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/03-openai.mdx +274 -9
  10. package/package.json +13 -14
  11. package/src/chat/convert-openai-chat-usage.ts +2 -2
  12. package/src/chat/convert-to-openai-chat-messages.ts +33 -18
  13. package/src/chat/map-openai-finish-reason.ts +2 -2
  14. package/src/chat/openai-chat-language-model.ts +62 -158
  15. package/src/chat/openai-chat-options.ts +5 -0
  16. package/src/chat/openai-chat-prepare-tools.ts +6 -6
  17. package/src/completion/convert-openai-completion-usage.ts +2 -2
  18. package/src/completion/convert-to-openai-completion-prompt.ts +2 -2
  19. package/src/completion/map-openai-finish-reason.ts +2 -2
  20. package/src/completion/openai-completion-language-model.ts +40 -23
  21. package/src/embedding/openai-embedding-model.ts +23 -6
  22. package/src/files/openai-files-api.ts +17 -0
  23. package/src/files/openai-files-options.ts +18 -0
  24. package/src/files/openai-files.ts +102 -0
  25. package/src/image/openai-image-model.ts +28 -11
  26. package/src/image/openai-image-options.ts +3 -0
  27. package/src/index.ts +2 -0
  28. package/src/openai-config.ts +6 -6
  29. package/src/openai-language-model-capabilities.ts +3 -2
  30. package/src/openai-provider.ts +54 -21
  31. package/src/openai-tools.ts +12 -1
  32. package/src/responses/convert-openai-responses-usage.ts +2 -2
  33. package/src/responses/convert-to-openai-responses-input.ts +194 -39
  34. package/src/responses/map-openai-responses-finish-reason.ts +2 -2
  35. package/src/responses/openai-responses-api.ts +136 -2
  36. package/src/responses/openai-responses-language-model.ts +252 -39
  37. package/src/responses/openai-responses-options.ts +24 -2
  38. package/src/responses/openai-responses-prepare-tools.ts +47 -14
  39. package/src/responses/openai-responses-provider-metadata.ts +10 -0
  40. package/src/skills/openai-skills-api.ts +31 -0
  41. package/src/skills/openai-skills.ts +87 -0
  42. package/src/speech/openai-speech-model.ts +25 -8
  43. package/src/tool/apply-patch.ts +33 -32
  44. package/src/tool/code-interpreter.ts +40 -41
  45. package/src/tool/custom.ts +2 -8
  46. package/src/tool/file-search.ts +2 -2
  47. package/src/tool/image-generation.ts +2 -2
  48. package/src/tool/local-shell.ts +2 -2
  49. package/src/tool/mcp.ts +2 -2
  50. package/src/tool/shell.ts +9 -4
  51. package/src/tool/tool-search.ts +98 -0
  52. package/src/tool/web-search-preview.ts +2 -2
  53. package/src/tool/web-search.ts +2 -2
  54. package/src/transcription/openai-transcription-model.ts +26 -9
  55. package/dist/index.d.mts +0 -1107
  56. package/dist/index.mjs +0 -6508
  57. package/dist/index.mjs.map +0 -1
  58. package/dist/internal/index.d.mts +0 -1137
  59. package/dist/internal/index.mjs +0 -6321
  60. package/dist/internal/index.mjs.map +0 -1
@@ -1,15 +1,21 @@
1
1
  import {
2
- LanguageModelV3CallOptions,
3
- SharedV3Warning,
2
+ LanguageModelV4CallOptions,
3
+ SharedV4ProviderReference,
4
+ SharedV4Warning,
4
5
  UnsupportedFunctionalityError,
5
6
  } from '@ai-sdk/provider';
6
- import { ToolNameMapping, validateTypes } from '@ai-sdk/provider-utils';
7
+ import {
8
+ resolveProviderReference,
9
+ ToolNameMapping,
10
+ validateTypes,
11
+ } from '@ai-sdk/provider-utils';
7
12
  import { codeInterpreterArgsSchema } from '../tool/code-interpreter';
8
13
  import { fileSearchArgsSchema } from '../tool/file-search';
9
14
  import { imageGenerationArgsSchema } from '../tool/image-generation';
10
15
  import { customArgsSchema } from '../tool/custom';
11
16
  import { mcpArgsSchema } from '../tool/mcp';
12
17
  import { shellArgsSchema } from '../tool/shell';
18
+ import { toolSearchArgsSchema } from '../tool/tool-search';
13
19
  import { webSearchArgsSchema } from '../tool/web-search';
14
20
  import { webSearchPreviewArgsSchema } from '../tool/web-search-preview';
15
21
  import { OpenAIResponsesTool } from './openai-responses-api';
@@ -20,8 +26,8 @@ export async function prepareResponsesTools({
20
26
  toolNameMapping,
21
27
  customProviderToolNames,
22
28
  }: {
23
- tools: LanguageModelV3CallOptions['tools'];
24
- toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
29
+ tools: LanguageModelV4CallOptions['tools'];
30
+ toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
25
31
  toolNameMapping?: ToolNameMapping;
26
32
  customProviderToolNames?: Set<string>;
27
33
  }): Promise<{
@@ -39,12 +45,12 @@ export async function prepareResponsesTools({
39
45
  | { type: 'mcp' }
40
46
  | { type: 'image_generation' }
41
47
  | { type: 'apply_patch' };
42
- toolWarnings: SharedV3Warning[];
48
+ toolWarnings: SharedV4Warning[];
43
49
  }> {
44
50
  // when the tools array is empty, change it to undefined to prevent errors:
45
51
  tools = tools?.length ? tools : undefined;
46
52
 
47
- const toolWarnings: SharedV3Warning[] = [];
53
+ const toolWarnings: SharedV4Warning[] = [];
48
54
 
49
55
  if (tools == null) {
50
56
  return { tools: undefined, toolChoice: undefined, toolWarnings };
@@ -56,15 +62,22 @@ export async function prepareResponsesTools({
56
62
 
57
63
  for (const tool of tools) {
58
64
  switch (tool.type) {
59
- case 'function':
65
+ case 'function': {
66
+ const openaiOptions = tool.providerOptions?.openai as
67
+ | { deferLoading?: boolean }
68
+ | undefined;
69
+ const deferLoading = openaiOptions?.deferLoading;
70
+
60
71
  openaiTools.push({
61
72
  type: 'function',
62
73
  name: tool.name,
63
74
  description: tool.description,
64
75
  parameters: tool.inputSchema,
65
76
  ...(tool.strict != null ? { strict: tool.strict } : {}),
77
+ ...(deferLoading != null ? { defer_loading: deferLoading } : {}),
66
78
  });
67
79
  break;
80
+ }
68
81
  case 'provider': {
69
82
  switch (tool.id) {
70
83
  case 'openai.file_search': {
@@ -241,11 +254,28 @@ export async function prepareResponsesTools({
241
254
 
242
255
  openaiTools.push({
243
256
  type: 'custom',
244
- name: args.name,
257
+ name: tool.name,
245
258
  description: args.description,
246
259
  format: args.format,
247
260
  });
248
- resolvedCustomProviderToolNames.add(args.name);
261
+ resolvedCustomProviderToolNames.add(tool.name);
262
+ break;
263
+ }
264
+ case 'openai.tool_search': {
265
+ const args = await validateTypes({
266
+ value: tool.args,
267
+ schema: toolSearchArgsSchema,
268
+ });
269
+ openaiTools.push({
270
+ type: 'tool_search',
271
+ ...(args.execution != null ? { execution: args.execution } : {}),
272
+ ...(args.description != null
273
+ ? { description: args.description }
274
+ : {}),
275
+ ...(args.parameters != null
276
+ ? { parameters: args.parameters }
277
+ : {}),
278
+ });
249
279
  break;
250
280
  }
251
281
  }
@@ -335,7 +365,7 @@ function mapShellEnvironment(environment: {
335
365
  };
336
366
  skills?: Array<{
337
367
  type: string;
338
- skillId?: string;
368
+ providerReference?: SharedV4ProviderReference;
339
369
  version?: string;
340
370
  name?: string;
341
371
  description?: string;
@@ -379,7 +409,7 @@ function mapShellSkills(
379
409
  skills:
380
410
  | Array<{
381
411
  type: string;
382
- skillId?: string;
412
+ providerReference?: SharedV4ProviderReference;
383
413
  version?: string;
384
414
  name?: string;
385
415
  description?: string;
@@ -391,8 +421,11 @@ function mapShellSkills(
391
421
  skill.type === 'skillReference'
392
422
  ? {
393
423
  type: 'skill_reference' as const,
394
- skill_id: skill.skillId!,
395
- version: skill.version,
424
+ skill_id: resolveProviderReference({
425
+ reference: skill.providerReference ?? {},
426
+ provider: 'openai',
427
+ }),
428
+ version: skill.version ?? 'latest',
396
429
  }
397
430
  : {
398
431
  type: 'inline' as const,
@@ -30,6 +30,16 @@ export type OpenaiResponsesProviderMetadata = {
30
30
  openai: ResponsesProviderMetadata;
31
31
  };
32
32
 
33
+ export type ResponsesCompactionProviderMetadata = {
34
+ type: 'compaction';
35
+ itemId: string;
36
+ encryptedContent?: string;
37
+ };
38
+
39
+ export type OpenaiResponsesCompactionProviderMetadata = {
40
+ openai: ResponsesCompactionProviderMetadata;
41
+ };
42
+
33
43
  export type ResponsesTextProviderMetadata = {
34
44
  itemId: string;
35
45
  phase?: 'commentary' | 'final_answer' | null;
@@ -0,0 +1,31 @@
1
+ import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
2
+ import { z } from 'zod/v4';
3
+
4
+ export const openaiSkillResponseSchema = lazySchema(() =>
5
+ zodSchema(
6
+ z.object({
7
+ id: z.string(),
8
+ name: z.string().nullish(),
9
+ description: z.string().nullish(),
10
+ default_version: z.string().nullish(),
11
+ latest_version: z.string().nullish(),
12
+ created_at: z.number(),
13
+ updated_at: z.number().nullish(),
14
+ }),
15
+ ),
16
+ );
17
+
18
+ export type OpenAISkillResponse = ReturnType<
19
+ typeof openaiSkillResponseSchema
20
+ >['_type'];
21
+
22
+ export const openaiSkillVersionResponseSchema = lazySchema(() =>
23
+ zodSchema(
24
+ z.object({
25
+ id: z.string(),
26
+ version: z.string().nullish(),
27
+ name: z.string().nullish(),
28
+ description: z.string().nullish(),
29
+ }),
30
+ ),
31
+ );
@@ -0,0 +1,87 @@
1
+ import { SkillsV4, SharedV4Warning } from '@ai-sdk/provider';
2
+ import {
3
+ combineHeaders,
4
+ convertBase64ToUint8Array,
5
+ createJsonResponseHandler,
6
+ FetchFunction,
7
+ postFormDataToApi,
8
+ } from '@ai-sdk/provider-utils';
9
+ import { openaiFailedResponseHandler } from '../openai-error';
10
+ import { openaiSkillResponseSchema } from './openai-skills-api';
11
+
12
+ interface OpenAISkillsConfig {
13
+ provider: string;
14
+ url: (options: { path: string }) => string;
15
+ headers: () => Record<string, string | undefined>;
16
+ fetch?: FetchFunction;
17
+ }
18
+
19
+ export class OpenAISkills implements SkillsV4 {
20
+ readonly specificationVersion = 'v4';
21
+
22
+ get provider(): string {
23
+ return this.config.provider;
24
+ }
25
+
26
+ constructor(private readonly config: OpenAISkillsConfig) {}
27
+
28
+ async uploadSkill(
29
+ params: Parameters<SkillsV4['uploadSkill']>[0],
30
+ ): Promise<Awaited<ReturnType<SkillsV4['uploadSkill']>>> {
31
+ const warnings: SharedV4Warning[] = [];
32
+
33
+ if (params.displayTitle != null) {
34
+ warnings.push({
35
+ type: 'unsupported',
36
+ feature: 'displayTitle',
37
+ });
38
+ }
39
+
40
+ const formData = new FormData();
41
+
42
+ for (const file of params.files) {
43
+ const content =
44
+ typeof file.content === 'string'
45
+ ? convertBase64ToUint8Array(file.content)
46
+ : file.content;
47
+
48
+ formData.append('files[]', new Blob([content]), file.path);
49
+ }
50
+
51
+ const { value: response } = await postFormDataToApi({
52
+ url: this.config.url({ path: '/skills' }),
53
+ headers: combineHeaders(this.config.headers()),
54
+ formData,
55
+ failedResponseHandler: openaiFailedResponseHandler,
56
+ successfulResponseHandler: createJsonResponseHandler(
57
+ openaiSkillResponseSchema,
58
+ ),
59
+ fetch: this.config.fetch,
60
+ });
61
+
62
+ return {
63
+ providerReference: { openai: response.id },
64
+ ...(response.name != null ? { name: response.name } : {}),
65
+ ...(response.description != null
66
+ ? { description: response.description }
67
+ : {}),
68
+ ...(response.latest_version != null
69
+ ? { latestVersion: response.latest_version }
70
+ : {}),
71
+ providerMetadata: {
72
+ openai: {
73
+ ...(response.default_version != null
74
+ ? { defaultVersion: response.default_version }
75
+ : {}),
76
+ ...(response.created_at != null
77
+ ? { createdAt: response.created_at }
78
+ : {}),
79
+ ...(response.updated_at != null
80
+ ? { updatedAt: response.updated_at }
81
+ : {}),
82
+ },
83
+ },
84
+ warnings,
85
+ };
86
+ }
87
+ }
@@ -1,9 +1,12 @@
1
- import { SpeechModelV3, SharedV3Warning } from '@ai-sdk/provider';
1
+ import { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';
2
2
  import {
3
3
  combineHeaders,
4
4
  createBinaryResponseHandler,
5
5
  parseProviderOptions,
6
6
  postJsonToApi,
7
+ serializeModelOptions,
8
+ WORKFLOW_DESERIALIZE,
9
+ WORKFLOW_SERIALIZE,
7
10
  } from '@ai-sdk/provider-utils';
8
11
  import { OpenAIConfig } from '../openai-config';
9
12
  import { openaiFailedResponseHandler } from '../openai-error';
@@ -19,8 +22,22 @@ interface OpenAISpeechModelConfig extends OpenAIConfig {
19
22
  };
20
23
  }
21
24
 
22
- export class OpenAISpeechModel implements SpeechModelV3 {
23
- readonly specificationVersion = 'v3';
25
+ export class OpenAISpeechModel implements SpeechModelV4 {
26
+ readonly specificationVersion = 'v4';
27
+
28
+ static [WORKFLOW_SERIALIZE](model: OpenAISpeechModel) {
29
+ return serializeModelOptions({
30
+ modelId: model.modelId,
31
+ config: model.config,
32
+ });
33
+ }
34
+
35
+ static [WORKFLOW_DESERIALIZE](options: {
36
+ modelId: OpenAISpeechModelId;
37
+ config: OpenAISpeechModelConfig;
38
+ }) {
39
+ return new OpenAISpeechModel(options.modelId, options.config);
40
+ }
24
41
 
25
42
  get provider(): string {
26
43
  return this.config.provider;
@@ -39,8 +56,8 @@ export class OpenAISpeechModel implements SpeechModelV3 {
39
56
  instructions,
40
57
  language,
41
58
  providerOptions,
42
- }: Parameters<SpeechModelV3['doGenerate']>[0]) {
43
- const warnings: SharedV3Warning[] = [];
59
+ }: Parameters<SpeechModelV4['doGenerate']>[0]) {
60
+ const warnings: SharedV4Warning[] = [];
44
61
 
45
62
  // Parse provider options
46
63
  const openAIOptions = await parseProviderOptions({
@@ -98,8 +115,8 @@ export class OpenAISpeechModel implements SpeechModelV3 {
98
115
  }
99
116
 
100
117
  async doGenerate(
101
- options: Parameters<SpeechModelV3['doGenerate']>[0],
102
- ): Promise<Awaited<ReturnType<SpeechModelV3['doGenerate']>>> {
118
+ options: Parameters<SpeechModelV4['doGenerate']>[0],
119
+ ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {
103
120
  const currentDate = this.config._internal?.currentDate?.() ?? new Date();
104
121
  const { requestBody, warnings } = await this.getArgs(options);
105
122
 
@@ -112,7 +129,7 @@ export class OpenAISpeechModel implements SpeechModelV3 {
112
129
  path: '/audio/speech',
113
130
  modelId: this.modelId,
114
131
  }),
115
- headers: combineHeaders(this.config.headers(), options.headers),
132
+ headers: combineHeaders(this.config.headers?.(), options.headers),
116
133
  body: requestBody,
117
134
  failedResponseHandler: openaiFailedResponseHandler,
118
135
  successfulResponseHandler: createBinaryResponseHandler(),
@@ -1,5 +1,5 @@
1
1
  import {
2
- createProviderToolFactoryWithOutputSchema,
2
+ createProviderDefinedToolFactoryWithOutputSchema,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
@@ -98,39 +98,40 @@ export type ApplyPatchOperation =
98
98
  * - Returns the status of applying those patches (completed or failed)
99
99
  *
100
100
  */
101
- export const applyPatchToolFactory = createProviderToolFactoryWithOutputSchema<
102
- {
103
- /**
104
- * The unique ID of the apply patch tool call generated by the model.
105
- */
106
- callId: string;
101
+ export const applyPatchToolFactory =
102
+ createProviderDefinedToolFactoryWithOutputSchema<
103
+ {
104
+ /**
105
+ * The unique ID of the apply patch tool call generated by the model.
106
+ */
107
+ callId: string;
107
108
 
108
- /**
109
- * The specific create, delete, or update instruction for the apply_patch tool call.
110
- */
111
- operation: ApplyPatchOperation;
112
- },
113
- {
114
- /**
115
- * The status of the apply patch tool call output.
116
- * - 'completed': The patch was applied successfully.
117
- * - 'failed': The patch failed to apply.
118
- */
119
- status: 'completed' | 'failed';
109
+ /**
110
+ * The specific create, delete, or update instruction for the apply_patch tool call.
111
+ */
112
+ operation: ApplyPatchOperation;
113
+ },
114
+ {
115
+ /**
116
+ * The status of the apply patch tool call output.
117
+ * - 'completed': The patch was applied successfully.
118
+ * - 'failed': The patch failed to apply.
119
+ */
120
+ status: 'completed' | 'failed';
120
121
 
121
- /**
122
- * Optional human-readable log text from the apply patch tool
123
- * (e.g., patch results or errors).
124
- */
125
- output?: string;
126
- },
127
- // No configuration options for apply_patch
128
- {}
129
- >({
130
- id: 'openai.apply_patch',
131
- inputSchema: applyPatchInputSchema,
132
- outputSchema: applyPatchOutputSchema,
133
- });
122
+ /**
123
+ * Optional human-readable log text from the apply patch tool
124
+ * (e.g., patch results or errors).
125
+ */
126
+ output?: string;
127
+ },
128
+ // No configuration options for apply_patch
129
+ {}
130
+ >({
131
+ id: 'openai.apply_patch',
132
+ inputSchema: applyPatchInputSchema,
133
+ outputSchema: applyPatchOutputSchema,
134
+ });
134
135
 
135
136
  /**
136
137
  * The apply_patch tool lets GPT-5.1 create, update, and delete files in your
@@ -1,5 +1,5 @@
1
1
  import {
2
- createProviderToolFactoryWithOutputSchema,
2
+ createProviderExecutedToolFactory,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
@@ -53,49 +53,48 @@ type CodeInterpreterArgs = {
53
53
  container?: string | { fileIds?: string[] };
54
54
  };
55
55
 
56
- export const codeInterpreterToolFactory =
57
- createProviderToolFactoryWithOutputSchema<
58
- {
59
- /**
60
- * The code to run, or null if not available.
61
- */
62
- code?: string | null;
56
+ export const codeInterpreterToolFactory = createProviderExecutedToolFactory<
57
+ {
58
+ /**
59
+ * The code to run, or null if not available.
60
+ */
61
+ code?: string | null;
63
62
 
64
- /**
65
- * The ID of the container used to run the code.
66
- */
67
- containerId: string;
68
- },
69
- {
70
- /**
71
- * The outputs generated by the code interpreter, such as logs or images.
72
- * Can be null if no outputs are available.
73
- */
74
- outputs?: Array<
75
- | {
76
- type: 'logs';
63
+ /**
64
+ * The ID of the container used to run the code.
65
+ */
66
+ containerId: string;
67
+ },
68
+ {
69
+ /**
70
+ * The outputs generated by the code interpreter, such as logs or images.
71
+ * Can be null if no outputs are available.
72
+ */
73
+ outputs?: Array<
74
+ | {
75
+ type: 'logs';
77
76
 
78
- /**
79
- * The logs output from the code interpreter.
80
- */
81
- logs: string;
82
- }
83
- | {
84
- type: 'image';
77
+ /**
78
+ * The logs output from the code interpreter.
79
+ */
80
+ logs: string;
81
+ }
82
+ | {
83
+ type: 'image';
85
84
 
86
- /**
87
- * The URL of the image output from the code interpreter.
88
- */
89
- url: string;
90
- }
91
- > | null;
92
- },
93
- CodeInterpreterArgs
94
- >({
95
- id: 'openai.code_interpreter',
96
- inputSchema: codeInterpreterInputSchema,
97
- outputSchema: codeInterpreterOutputSchema,
98
- });
85
+ /**
86
+ * The URL of the image output from the code interpreter.
87
+ */
88
+ url: string;
89
+ }
90
+ > | null;
91
+ },
92
+ CodeInterpreterArgs
93
+ >({
94
+ id: 'openai.code_interpreter',
95
+ inputSchema: codeInterpreterInputSchema,
96
+ outputSchema: codeInterpreterOutputSchema,
97
+ });
99
98
 
100
99
  export const codeInterpreter = (
101
100
  args: CodeInterpreterArgs = {}, // default
@@ -1,5 +1,5 @@
1
1
  import {
2
- createProviderToolFactory,
2
+ createProviderDefinedToolFactory,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
@@ -8,7 +8,6 @@ import { z } from 'zod/v4';
8
8
  export const customArgsSchema = lazySchema(() =>
9
9
  zodSchema(
10
10
  z.object({
11
- name: z.string(),
12
11
  description: z.string().optional(),
13
12
  format: z
14
13
  .union([
@@ -28,14 +27,9 @@ export const customArgsSchema = lazySchema(() =>
28
27
 
29
28
  const customInputSchema = lazySchema(() => zodSchema(z.string()));
30
29
 
31
- export const customToolFactory = createProviderToolFactory<
30
+ export const customToolFactory = createProviderDefinedToolFactory<
32
31
  string,
33
32
  {
34
- /**
35
- * The name of the custom tool, used to identify it in the API.
36
- */
37
- name: string;
38
-
39
33
  /**
40
34
  * An optional description of what the tool does.
41
35
  */
@@ -1,5 +1,5 @@
1
1
  import {
2
- createProviderToolFactoryWithOutputSchema,
2
+ createProviderExecutedToolFactory,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
@@ -59,7 +59,7 @@ export const fileSearchOutputSchema = lazySchema(() =>
59
59
  ),
60
60
  );
61
61
 
62
- export const fileSearch = createProviderToolFactoryWithOutputSchema<
62
+ export const fileSearch = createProviderExecutedToolFactory<
63
63
  {},
64
64
  {
65
65
  /**
@@ -1,5 +1,5 @@
1
1
  import {
2
- createProviderToolFactoryWithOutputSchema,
2
+ createProviderExecutedToolFactory,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
@@ -104,7 +104,7 @@ type ImageGenerationArgs = {
104
104
  size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024';
105
105
  };
106
106
 
107
- const imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema<
107
+ const imageGenerationToolFactory = createProviderExecutedToolFactory<
108
108
  {},
109
109
  {
110
110
  /**
@@ -1,5 +1,5 @@
1
1
  import {
2
- createProviderToolFactoryWithOutputSchema,
2
+ createProviderDefinedToolFactoryWithOutputSchema,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
@@ -24,7 +24,7 @@ export const localShellOutputSchema = lazySchema(() =>
24
24
  zodSchema(z.object({ output: z.string() })),
25
25
  );
26
26
 
27
- export const localShell = createProviderToolFactoryWithOutputSchema<
27
+ export const localShell = createProviderDefinedToolFactoryWithOutputSchema<
28
28
  {
29
29
  /**
30
30
  * Execute a shell command on the server.
package/src/tool/mcp.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {
2
- createProviderToolFactoryWithOutputSchema,
2
+ createProviderExecutedToolFactory,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
@@ -105,7 +105,7 @@ type McpArgs = {
105
105
  serverUrl?: string;
106
106
  };
107
107
 
108
- export const mcpToolFactory = createProviderToolFactoryWithOutputSchema<
108
+ export const mcpToolFactory = createProviderExecutedToolFactory<
109
109
  {},
110
110
  {
111
111
  type: 'call';
package/src/tool/shell.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
- createProviderToolFactoryWithOutputSchema,
2
+ createProviderDefinedToolFactoryWithOutputSchema,
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
6
+ import type { SharedV4ProviderReference } from '@ai-sdk/provider';
6
7
  import { z } from 'zod/v4';
7
8
 
8
9
  export const shellInputSchema = lazySchema(() =>
@@ -39,7 +40,7 @@ const shellSkillsSchema = z
39
40
  z.discriminatedUnion('type', [
40
41
  z.object({
41
42
  type: z.literal('skillReference'),
42
- skillId: z.string(),
43
+ providerReference: z.record(z.string(), z.string()),
43
44
  version: z.string().optional(),
44
45
  }),
45
46
  z.object({
@@ -125,7 +126,11 @@ type ShellArgs = {
125
126
  }>;
126
127
  };
127
128
  skills?: Array<
128
- | { type: 'skillReference'; skillId: string; version?: string }
129
+ | {
130
+ type: 'skillReference';
131
+ providerReference: SharedV4ProviderReference;
132
+ version?: string;
133
+ }
129
134
  | {
130
135
  type: 'inline';
131
136
  name: string;
@@ -152,7 +157,7 @@ type ShellArgs = {
152
157
  };
153
158
  };
154
159
 
155
- export const shell = createProviderToolFactoryWithOutputSchema<
160
+ export const shell = createProviderDefinedToolFactoryWithOutputSchema<
156
161
  {
157
162
  /**
158
163
  * Shell tool action containing commands to execute.