@ai-sdk/openai 4.0.98 → 4.0.100

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.
@@ -5,66 +5,68 @@ import {
5
5
  } from '@ai-sdk/provider-utils';
6
6
  import { z } from 'zod/v4';
7
7
 
8
- const safetyCheckSchema = z.object({
9
- id: z.string(),
10
- code: z.string().optional(),
11
- message: z.string().optional(),
12
- });
13
-
14
- const computerActionSchema = z.discriminatedUnion('type', [
15
- z.object({
16
- type: z.literal('click'),
17
- button: z.enum(['left', 'right', 'wheel', 'back', 'forward']),
18
- x: z.number(),
19
- y: z.number(),
20
- keys: z.array(z.string()).optional(),
21
- }),
22
- z.object({
23
- type: z.literal('double_click'),
24
- x: z.number(),
25
- y: z.number(),
26
- keys: z.array(z.string()).optional(),
27
- }),
28
- z.object({
29
- type: z.literal('drag'),
30
- path: z.array(z.object({ x: z.number(), y: z.number() })),
31
- keys: z.array(z.string()).optional(),
32
- }),
33
- z.object({
34
- type: z.literal('keypress'),
35
- keys: z.array(z.string()),
36
- }),
37
- z.object({
38
- type: z.literal('move'),
39
- x: z.number(),
40
- y: z.number(),
41
- keys: z.array(z.string()).optional(),
42
- }),
43
- z.object({
44
- type: z.literal('screenshot'),
45
- }),
8
+ const safetyCheckSchema = () =>
46
9
  z.object({
47
- type: z.literal('scroll'),
48
- x: z.number(),
49
- y: z.number(),
50
- scrollX: z.number(),
51
- scrollY: z.number(),
52
- keys: z.array(z.string()).optional(),
53
- }),
54
- z.object({
55
- type: z.literal('type'),
56
- text: z.string(),
57
- }),
58
- z.object({
59
- type: z.literal('wait'),
60
- }),
61
- ]);
10
+ id: z.string(),
11
+ code: z.string().optional(),
12
+ message: z.string().optional(),
13
+ });
14
+
15
+ const computerActionSchema = () =>
16
+ z.discriminatedUnion('type', [
17
+ z.object({
18
+ type: z.literal('click'),
19
+ button: z.enum(['left', 'right', 'wheel', 'back', 'forward']),
20
+ x: z.number(),
21
+ y: z.number(),
22
+ keys: z.array(z.string()).optional(),
23
+ }),
24
+ z.object({
25
+ type: z.literal('double_click'),
26
+ x: z.number(),
27
+ y: z.number(),
28
+ keys: z.array(z.string()).optional(),
29
+ }),
30
+ z.object({
31
+ type: z.literal('drag'),
32
+ path: z.array(z.object({ x: z.number(), y: z.number() })),
33
+ keys: z.array(z.string()).optional(),
34
+ }),
35
+ z.object({
36
+ type: z.literal('keypress'),
37
+ keys: z.array(z.string()),
38
+ }),
39
+ z.object({
40
+ type: z.literal('move'),
41
+ x: z.number(),
42
+ y: z.number(),
43
+ keys: z.array(z.string()).optional(),
44
+ }),
45
+ z.object({
46
+ type: z.literal('screenshot'),
47
+ }),
48
+ z.object({
49
+ type: z.literal('scroll'),
50
+ x: z.number(),
51
+ y: z.number(),
52
+ scrollX: z.number(),
53
+ scrollY: z.number(),
54
+ keys: z.array(z.string()).optional(),
55
+ }),
56
+ z.object({
57
+ type: z.literal('type'),
58
+ text: z.string(),
59
+ }),
60
+ z.object({
61
+ type: z.literal('wait'),
62
+ }),
63
+ ]);
62
64
 
63
65
  export const computerInputSchema = lazySchema(() =>
64
66
  zodSchema(
65
67
  z.object({
66
- actions: z.array(computerActionSchema),
67
- pendingSafetyChecks: z.array(safetyCheckSchema),
68
+ actions: z.array(computerActionSchema()),
69
+ pendingSafetyChecks: z.array(safetyCheckSchema()),
68
70
  status: z.enum(['in_progress', 'completed', 'incomplete']),
69
71
  }),
70
72
  ),
@@ -87,13 +89,17 @@ export const computerOutputSchema = lazySchema(() =>
87
89
  detail: z.enum(['auto', 'low', 'high', 'original']).optional(),
88
90
  }),
89
91
  ]),
90
- acknowledgedSafetyChecks: z.array(safetyCheckSchema).optional(),
92
+ acknowledgedSafetyChecks: z.array(safetyCheckSchema()).optional(),
91
93
  }),
92
94
  ),
93
95
  );
94
96
 
95
- export type OpenAIComputerAction = z.infer<typeof computerActionSchema>;
96
- export type OpenAIComputerSafetyCheck = z.infer<typeof safetyCheckSchema>;
97
+ export type OpenAIComputerAction = z.infer<
98
+ ReturnType<typeof computerActionSchema>
99
+ >;
100
+ export type OpenAIComputerSafetyCheck = z.infer<
101
+ ReturnType<typeof safetyCheckSchema>
102
+ >;
97
103
 
98
104
  const computerToolFactory = createProviderDefinedToolFactoryWithOutputSchema<
99
105
  {
@@ -9,18 +9,21 @@ import type {
9
9
  OpenAIResponsesFileSearchToolCompoundFilter,
10
10
  } from '../responses/openai-responses-api';
11
11
 
12
- const comparisonFilterSchema = z.object({
13
- key: z.string(),
14
- type: z.enum(['eq', 'ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin']),
15
- value: z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
16
- });
12
+ const comparisonFilterSchema = () =>
13
+ z.object({
14
+ key: z.string(),
15
+ type: z.enum(['eq', 'ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin']),
16
+ value: z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
17
+ });
17
18
 
18
- const compoundFilterSchema: z.ZodType<any> = z.object({
19
- type: z.enum(['and', 'or']),
20
- filters: z.array(
21
- z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)]),
22
- ),
23
- });
19
+ let cachedCompoundFilterSchema: z.ZodType<any> | undefined;
20
+ const compoundFilterSchema = (): z.ZodType<any> =>
21
+ (cachedCompoundFilterSchema ??= z.object({
22
+ type: z.enum(['and', 'or']),
23
+ filters: z.array(
24
+ z.union([comparisonFilterSchema(), z.lazy(() => compoundFilterSchema())]),
25
+ ),
26
+ }));
24
27
 
25
28
  export const fileSearchArgsSchema = lazySchema(() =>
26
29
  zodSchema(
@@ -34,7 +37,7 @@ export const fileSearchArgsSchema = lazySchema(() =>
34
37
  })
35
38
  .optional(),
36
39
  filters: z
37
- .union([comparisonFilterSchema, compoundFilterSchema])
40
+ .union([comparisonFilterSchema(), compoundFilterSchema()])
38
41
  .optional(),
39
42
  }),
40
43
  ),
package/src/tool/mcp.ts CHANGED
@@ -6,16 +6,18 @@ import {
6
6
  import type { JSONValue } from '@ai-sdk/provider';
7
7
  import { z } from 'zod/v4';
8
8
 
9
- const jsonValueSchema: z.ZodType<JSONValue> = z.lazy(() =>
10
- z.union([
11
- z.string(),
12
- z.number(),
13
- z.boolean(),
14
- z.null(),
15
- z.array(jsonValueSchema),
16
- z.record(z.string(), jsonValueSchema),
17
- ]),
18
- );
9
+ let cachedJsonValueSchema: z.ZodType<JSONValue> | undefined;
10
+ const jsonValueSchema = (): z.ZodType<JSONValue> =>
11
+ (cachedJsonValueSchema ??= z.lazy(() =>
12
+ z.union([
13
+ z.string(),
14
+ z.number(),
15
+ z.boolean(),
16
+ z.null(),
17
+ z.array(jsonValueSchema()),
18
+ z.record(z.string(), jsonValueSchema()),
19
+ ]),
20
+ ));
19
21
 
20
22
  export const mcpArgsSchema = lazySchema(() =>
21
23
  zodSchema(
@@ -67,7 +69,7 @@ export const mcpOutputSchema = lazySchema(() =>
67
69
  name: z.string(),
68
70
  arguments: z.string(),
69
71
  output: z.string().nullish(),
70
- error: z.union([z.string(), jsonValueSchema]).optional(),
72
+ error: z.union([z.string(), jsonValueSchema()]).optional(),
71
73
  }),
72
74
  ),
73
75
  );
package/src/tool/shell.ts CHANGED
@@ -36,27 +36,28 @@ export const shellOutputSchema = lazySchema(() =>
36
36
  ),
37
37
  );
38
38
 
39
- const shellSkillsSchema = z
40
- .array(
41
- z.discriminatedUnion('type', [
42
- z.object({
43
- type: z.literal('skillReference'),
44
- providerReference: z.record(z.string(), z.string()),
45
- version: z.string().optional(),
46
- }),
47
- z.object({
48
- type: z.literal('inline'),
49
- name: z.string(),
50
- description: z.string(),
51
- source: z.object({
52
- type: z.literal('base64'),
53
- mediaType: z.literal('application/zip'),
54
- data: z.string(),
39
+ const shellSkillsSchema = () =>
40
+ z
41
+ .array(
42
+ z.discriminatedUnion('type', [
43
+ z.object({
44
+ type: z.literal('skillReference'),
45
+ providerReference: z.record(z.string(), z.string()),
46
+ version: z.string().optional(),
55
47
  }),
56
- }),
57
- ]),
58
- )
59
- .optional();
48
+ z.object({
49
+ type: z.literal('inline'),
50
+ name: z.string(),
51
+ description: z.string(),
52
+ source: z.object({
53
+ type: z.literal('base64'),
54
+ mediaType: z.literal('application/zip'),
55
+ data: z.string(),
56
+ }),
57
+ }),
58
+ ]),
59
+ )
60
+ .optional();
60
61
 
61
62
  export const shellArgsSchema = lazySchema(() =>
62
63
  zodSchema(
@@ -85,7 +86,7 @@ export const shellArgsSchema = lazySchema(() =>
85
86
  }),
86
87
  ])
87
88
  .optional(),
88
- skills: shellSkillsSchema,
89
+ skills: shellSkillsSchema(),
89
90
  }),
90
91
  z.object({
91
92
  type: z.literal('containerReference'),