@ai-sdk/openai 3.0.28 → 3.0.30

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.
@@ -8,6 +8,7 @@ import { codeInterpreterArgsSchema } from '../tool/code-interpreter';
8
8
  import { fileSearchArgsSchema } from '../tool/file-search';
9
9
  import { imageGenerationArgsSchema } from '../tool/image-generation';
10
10
  import { mcpArgsSchema } from '../tool/mcp';
11
+ import { shellArgsSchema } from '../tool/shell';
11
12
  import { webSearchArgsSchema } from '../tool/web-search';
12
13
  import { webSearchPreviewArgsSchema } from '../tool/web-search-preview';
13
14
  import { OpenAIResponsesTool } from './openai-responses-api';
@@ -86,8 +87,16 @@ export async function prepareResponsesTools({
86
87
  break;
87
88
  }
88
89
  case 'openai.shell': {
90
+ const args = await validateTypes({
91
+ value: tool.args,
92
+ schema: shellArgsSchema,
93
+ });
94
+
89
95
  openaiTools.push({
90
96
  type: 'shell',
97
+ ...(args.environment && {
98
+ environment: mapShellEnvironment(args.environment),
99
+ }),
91
100
  });
92
101
  break;
93
102
  }
@@ -262,3 +271,108 @@ export async function prepareResponsesTools({
262
271
  }
263
272
  }
264
273
  }
274
+
275
+ function mapShellEnvironment(environment: {
276
+ type?: string;
277
+ [key: string]: unknown;
278
+ }): NonNullable<
279
+ Extract<OpenAIResponsesTool, { type: 'shell' }>['environment']
280
+ > {
281
+ if (environment.type === 'containerReference') {
282
+ const env = environment as {
283
+ type: 'containerReference';
284
+ containerId: string;
285
+ };
286
+ return {
287
+ type: 'container_reference',
288
+ container_id: env.containerId,
289
+ };
290
+ }
291
+
292
+ if (environment.type === 'containerAuto') {
293
+ const env = environment as {
294
+ type: 'containerAuto';
295
+ fileIds?: string[];
296
+ memoryLimit?: '1g' | '4g' | '16g' | '64g';
297
+ networkPolicy?: {
298
+ type: string;
299
+ allowedDomains?: string[];
300
+ domainSecrets?: Array<{
301
+ domain: string;
302
+ name: string;
303
+ value: string;
304
+ }>;
305
+ };
306
+ skills?: Array<{
307
+ type: string;
308
+ skillId?: string;
309
+ version?: string;
310
+ name?: string;
311
+ description?: string;
312
+ source?: { type: string; mediaType: string; data: string };
313
+ }>;
314
+ };
315
+
316
+ return {
317
+ type: 'container_auto',
318
+ file_ids: env.fileIds,
319
+ memory_limit: env.memoryLimit,
320
+ network_policy:
321
+ env.networkPolicy == null
322
+ ? undefined
323
+ : env.networkPolicy.type === 'disabled'
324
+ ? { type: 'disabled' as const }
325
+ : {
326
+ type: 'allowlist' as const,
327
+ allowed_domains: env.networkPolicy.allowedDomains!,
328
+ domain_secrets: env.networkPolicy.domainSecrets,
329
+ },
330
+ skills: mapShellSkills(env.skills),
331
+ };
332
+ }
333
+
334
+ const env = environment as {
335
+ type?: 'local';
336
+ skills?: Array<{
337
+ name: string;
338
+ description: string;
339
+ path: string;
340
+ }>;
341
+ };
342
+ return {
343
+ type: 'local',
344
+ skills: env.skills,
345
+ };
346
+ }
347
+
348
+ function mapShellSkills(
349
+ skills:
350
+ | Array<{
351
+ type: string;
352
+ skillId?: string;
353
+ version?: string;
354
+ name?: string;
355
+ description?: string;
356
+ source?: { type: string; mediaType: string; data: string };
357
+ }>
358
+ | undefined,
359
+ ) {
360
+ return skills?.map(skill =>
361
+ skill.type === 'skillReference'
362
+ ? {
363
+ type: 'skill_reference' as const,
364
+ skill_id: skill.skillId!,
365
+ version: skill.version,
366
+ }
367
+ : {
368
+ type: 'inline' as const,
369
+ name: skill.name!,
370
+ description: skill.description!,
371
+ source: {
372
+ type: 'base64' as const,
373
+ media_type: skill.source!.mediaType as 'application/zip',
374
+ data: skill.source!.data,
375
+ },
376
+ },
377
+ );
378
+ }
package/src/tool/shell.ts CHANGED
@@ -34,6 +34,124 @@ export const shellOutputSchema = lazySchema(() =>
34
34
  ),
35
35
  );
36
36
 
37
+ const shellSkillsSchema = z
38
+ .array(
39
+ z.discriminatedUnion('type', [
40
+ z.object({
41
+ type: z.literal('skillReference'),
42
+ skillId: z.string(),
43
+ version: z.string().optional(),
44
+ }),
45
+ z.object({
46
+ type: z.literal('inline'),
47
+ name: z.string(),
48
+ description: z.string(),
49
+ source: z.object({
50
+ type: z.literal('base64'),
51
+ mediaType: z.literal('application/zip'),
52
+ data: z.string(),
53
+ }),
54
+ }),
55
+ ]),
56
+ )
57
+ .optional();
58
+
59
+ export const shellArgsSchema = lazySchema(() =>
60
+ zodSchema(
61
+ z.object({
62
+ environment: z
63
+ .union([
64
+ z.object({
65
+ type: z.literal('containerAuto'),
66
+ fileIds: z.array(z.string()).optional(),
67
+ memoryLimit: z.enum(['1g', '4g', '16g', '64g']).optional(),
68
+ networkPolicy: z
69
+ .discriminatedUnion('type', [
70
+ z.object({ type: z.literal('disabled') }),
71
+ z.object({
72
+ type: z.literal('allowlist'),
73
+ allowedDomains: z.array(z.string()),
74
+ domainSecrets: z
75
+ .array(
76
+ z.object({
77
+ domain: z.string(),
78
+ name: z.string(),
79
+ value: z.string(),
80
+ }),
81
+ )
82
+ .optional(),
83
+ }),
84
+ ])
85
+ .optional(),
86
+ skills: shellSkillsSchema,
87
+ }),
88
+ z.object({
89
+ type: z.literal('containerReference'),
90
+ containerId: z.string(),
91
+ }),
92
+ z.object({
93
+ type: z.literal('local').optional(),
94
+ skills: z
95
+ .array(
96
+ z.object({
97
+ name: z.string(),
98
+ description: z.string(),
99
+ path: z.string(),
100
+ }),
101
+ )
102
+ .optional(),
103
+ }),
104
+ ])
105
+ .optional(),
106
+ }),
107
+ ),
108
+ );
109
+
110
+ type ShellArgs = {
111
+ environment?:
112
+ | {
113
+ type: 'containerAuto';
114
+ fileIds?: string[];
115
+ memoryLimit?: '1g' | '4g' | '16g' | '64g';
116
+ networkPolicy?:
117
+ | { type: 'disabled' }
118
+ | {
119
+ type: 'allowlist';
120
+ allowedDomains: string[];
121
+ domainSecrets?: Array<{
122
+ domain: string;
123
+ name: string;
124
+ value: string;
125
+ }>;
126
+ };
127
+ skills?: Array<
128
+ | { type: 'skillReference'; skillId: string; version?: string }
129
+ | {
130
+ type: 'inline';
131
+ name: string;
132
+ description: string;
133
+ source: {
134
+ type: 'base64';
135
+ mediaType: 'application/zip';
136
+ data: string;
137
+ };
138
+ }
139
+ >;
140
+ }
141
+ | {
142
+ type: 'containerReference';
143
+ containerId: string;
144
+ }
145
+ | {
146
+ type?: 'local';
147
+ skills?: Array<{
148
+ name: string;
149
+ description: string;
150
+ path: string;
151
+ }>;
152
+ };
153
+ };
154
+
37
155
  export const shell = createProviderToolFactoryWithOutputSchema<
38
156
  {
39
157
  /**
@@ -77,7 +195,7 @@ export const shell = createProviderToolFactoryWithOutputSchema<
77
195
  outcome: { type: 'timeout' } | { type: 'exit'; exitCode: number };
78
196
  }>;
79
197
  },
80
- {}
198
+ ShellArgs
81
199
  >({
82
200
  id: 'openai.shell',
83
201
  inputSchema: shellInputSchema,