@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,13 +1,16 @@
1
1
  import {
2
- LanguageModelV3Prompt,
3
- LanguageModelV3ToolApprovalResponsePart,
4
- SharedV3Warning,
2
+ LanguageModelV4Prompt,
3
+ LanguageModelV4ToolApprovalResponsePart,
4
+ SharedV4Warning,
5
5
  UnsupportedFunctionalityError,
6
6
  } from '@ai-sdk/provider';
7
7
  import {
8
8
  convertToBase64,
9
9
  isNonNullable,
10
+ isProviderReference,
11
+ parseJSON,
10
12
  parseProviderOptions,
13
+ resolveProviderReference,
11
14
  ToolNameMapping,
12
15
  validateTypes,
13
16
  } from '@ai-sdk/provider-utils';
@@ -22,15 +25,26 @@ import {
22
25
  } from '../tool/local-shell';
23
26
  import { shellInputSchema, shellOutputSchema } from '../tool/shell';
24
27
  import {
28
+ OpenAIResponsesCompactionItem,
25
29
  OpenAIResponsesCustomToolCallOutput,
26
30
  OpenAIResponsesFunctionCallOutput,
27
31
  OpenAIResponsesInput,
28
32
  OpenAIResponsesReasoning,
29
33
  } from './openai-responses-api';
34
+ import {
35
+ toolSearchInputSchema,
36
+ toolSearchOutputSchema,
37
+ } from '../tool/tool-search';
38
+
39
+ function serializeToolCallArguments(input: unknown): string {
40
+ return JSON.stringify(input === undefined ? {} : input);
41
+ }
30
42
 
31
43
  /**
32
- * Check if a string is a file ID based on the given prefixes
33
- * Returns false if prefixes is undefined (disables file ID detection)
44
+ * This is soft-deprecated. Use provider references instead. Kept for backward compatibility
45
+ * with the `fileIdPrefixes` option.
46
+ *
47
+ * TODO: remove in v8
34
48
  */
35
49
  function isFileId(data: string, prefixes?: readonly string[]): boolean {
36
50
  if (!prefixes) return false;
@@ -50,10 +64,11 @@ export async function convertToOpenAIResponsesInput({
50
64
  hasApplyPatchTool = false,
51
65
  customProviderToolNames,
52
66
  }: {
53
- prompt: LanguageModelV3Prompt;
67
+ prompt: LanguageModelV4Prompt;
54
68
  toolNameMapping: ToolNameMapping;
55
69
  systemMessageMode: 'system' | 'developer' | 'remove';
56
70
  providerOptionsName: string;
71
+ /** @deprecated Use provider references instead. */
57
72
  fileIdPrefixes?: readonly string[];
58
73
  store: boolean;
59
74
  hasConversation?: boolean; // when true, skip assistant messages that already have item IDs
@@ -63,10 +78,10 @@ export async function convertToOpenAIResponsesInput({
63
78
  customProviderToolNames?: Set<string>;
64
79
  }): Promise<{
65
80
  input: OpenAIResponsesInput;
66
- warnings: Array<SharedV3Warning>;
81
+ warnings: Array<SharedV4Warning>;
67
82
  }> {
68
83
  let input: OpenAIResponsesInput = [];
69
- const warnings: Array<SharedV3Warning> = [];
84
+ const warnings: Array<SharedV4Warning> = [];
70
85
  const processedApprovalIds = new Set<string>();
71
86
 
72
87
  for (const { role, content } of prompt) {
@@ -107,6 +122,28 @@ export async function convertToOpenAIResponsesInput({
107
122
  return { type: 'input_text', text: part.text };
108
123
  }
109
124
  case 'file': {
125
+ if (isProviderReference(part.data)) {
126
+ const fileId = resolveProviderReference({
127
+ reference: part.data,
128
+ provider: providerOptionsName,
129
+ });
130
+
131
+ if (part.mediaType.startsWith('image/')) {
132
+ return {
133
+ type: 'input_image',
134
+ file_id: fileId,
135
+ detail:
136
+ part.providerOptions?.[providerOptionsName]
137
+ ?.imageDetail,
138
+ };
139
+ }
140
+
141
+ return {
142
+ type: 'input_file',
143
+ file_id: fileId,
144
+ };
145
+ }
146
+
110
147
  if (part.mediaType.startsWith('image/')) {
111
148
  const mediaType =
112
149
  part.mediaType === 'image/*'
@@ -206,6 +243,41 @@ export async function convertToOpenAIResponsesInput({
206
243
  break;
207
244
  }
208
245
 
246
+ const resolvedToolName = toolNameMapping.toProviderToolName(
247
+ part.toolName,
248
+ );
249
+
250
+ if (resolvedToolName === 'tool_search') {
251
+ if (store && id != null) {
252
+ input.push({ type: 'item_reference', id });
253
+ break;
254
+ }
255
+
256
+ const parsedInput =
257
+ typeof part.input === 'string'
258
+ ? await parseJSON({
259
+ text: part.input,
260
+ schema: toolSearchInputSchema,
261
+ })
262
+ : await validateTypes({
263
+ value: part.input,
264
+ schema: toolSearchInputSchema,
265
+ });
266
+
267
+ const execution =
268
+ parsedInput.call_id != null ? 'client' : 'server';
269
+
270
+ input.push({
271
+ type: 'tool_search_call',
272
+ id: id ?? part.toolCallId,
273
+ execution,
274
+ call_id: parsedInput.call_id ?? null,
275
+ status: 'completed',
276
+ arguments: parsedInput.arguments,
277
+ });
278
+ break;
279
+ }
280
+
209
281
  if (part.providerExecuted) {
210
282
  if (store && id != null) {
211
283
  input.push({ type: 'item_reference', id });
@@ -218,10 +290,6 @@ export async function convertToOpenAIResponsesInput({
218
290
  break;
219
291
  }
220
292
 
221
- const resolvedToolName = toolNameMapping.toProviderToolName(
222
- part.toolName,
223
- );
224
-
225
293
  if (hasLocalShellTool && resolvedToolName === 'local_shell') {
226
294
  const parsedInput = await validateTypes({
227
295
  value: part.input,
@@ -298,7 +366,7 @@ export async function convertToOpenAIResponsesInput({
298
366
  type: 'function_call',
299
367
  call_id: part.toolCallId,
300
368
  name: resolvedToolName,
301
- arguments: JSON.stringify(part.input),
369
+ arguments: serializeToolCallArguments(part.input),
302
370
  id,
303
371
  });
304
372
  break;
@@ -328,6 +396,35 @@ export async function convertToOpenAIResponsesInput({
328
396
  part.toolName,
329
397
  );
330
398
 
399
+ if (resolvedResultToolName === 'tool_search') {
400
+ const itemId =
401
+ (
402
+ part.providerOptions?.[providerOptionsName] as
403
+ | { itemId?: string }
404
+ | undefined
405
+ )?.itemId ?? part.toolCallId;
406
+
407
+ if (store) {
408
+ input.push({ type: 'item_reference', id: itemId });
409
+ } else if (part.output.type === 'json') {
410
+ const parsedOutput = await validateTypes({
411
+ value: part.output.value,
412
+ schema: toolSearchOutputSchema,
413
+ });
414
+
415
+ input.push({
416
+ type: 'tool_search_output',
417
+ id: itemId,
418
+ execution: 'server',
419
+ call_id: null,
420
+ status: 'completed',
421
+ tools: parsedOutput.tools,
422
+ });
423
+ }
424
+
425
+ break;
426
+ }
427
+
331
428
  /*
332
429
  * Shell tool results are separate output items (shell_call_output)
333
430
  * with their own item IDs distinct from the shell_call's item ID.
@@ -478,6 +575,36 @@ export async function convertToOpenAIResponsesInput({
478
575
  }
479
576
  break;
480
577
  }
578
+
579
+ case 'custom': {
580
+ if (part.kind === 'openai.compaction') {
581
+ const providerOpts =
582
+ part.providerOptions?.[providerOptionsName];
583
+ const id = providerOpts?.itemId as string | undefined;
584
+
585
+ if (hasConversation && id != null) {
586
+ break;
587
+ }
588
+
589
+ if (store && id != null) {
590
+ input.push({ type: 'item_reference', id });
591
+ break;
592
+ }
593
+
594
+ const encryptedContent = providerOpts?.encryptedContent as
595
+ | string
596
+ | undefined;
597
+
598
+ if (id != null) {
599
+ input.push({
600
+ type: 'compaction',
601
+ id,
602
+ encrypted_content: encryptedContent!,
603
+ } satisfies OpenAIResponsesCompactionItem);
604
+ }
605
+ }
606
+ break;
607
+ }
481
608
  }
482
609
  }
483
610
 
@@ -488,7 +615,7 @@ export async function convertToOpenAIResponsesInput({
488
615
  for (const part of content) {
489
616
  if (part.type === 'tool-approval-response') {
490
617
  const approvalResponse =
491
- part as LanguageModelV3ToolApprovalResponsePart;
618
+ part as LanguageModelV4ToolApprovalResponsePart;
492
619
 
493
620
  if (processedApprovalIds.has(approvalResponse.approvalId)) {
494
621
  continue;
@@ -527,6 +654,22 @@ export async function convertToOpenAIResponsesInput({
527
654
  part.toolName,
528
655
  );
529
656
 
657
+ if (resolvedToolName === 'tool_search' && output.type === 'json') {
658
+ const parsedOutput = await validateTypes({
659
+ value: output.value,
660
+ schema: toolSearchOutputSchema,
661
+ });
662
+
663
+ input.push({
664
+ type: 'tool_search_output',
665
+ execution: 'client',
666
+ call_id: part.toolCallId,
667
+ status: 'completed',
668
+ tools: parsedOutput.tools,
669
+ });
670
+ continue;
671
+ }
672
+
530
673
  if (
531
674
  hasLocalShellTool &&
532
675
  resolvedToolName === 'local_shell' &&
@@ -600,7 +743,7 @@ export async function convertToOpenAIResponsesInput({
600
743
  outputValue = output.value;
601
744
  break;
602
745
  case 'execution-denied':
603
- outputValue = output.reason ?? 'Tool execution denied.';
746
+ outputValue = output.reason ?? 'Tool call execution denied.';
604
747
  break;
605
748
  case 'json':
606
749
  case 'error-json':
@@ -612,22 +755,29 @@ export async function convertToOpenAIResponsesInput({
612
755
  switch (item.type) {
613
756
  case 'text':
614
757
  return { type: 'input_text' as const, text: item.text };
615
- case 'image-data':
616
- return {
617
- type: 'input_image' as const,
618
- image_url: `data:${item.mediaType};base64,${item.data}`,
619
- };
620
- case 'image-url':
621
- return {
622
- type: 'input_image' as const,
623
- image_url: item.url,
624
- };
625
758
  case 'file-data':
759
+ if (item.mediaType.startsWith('image/')) {
760
+ return {
761
+ type: 'input_image' as const,
762
+ image_url: `data:${item.mediaType};base64,${item.data}`,
763
+ };
764
+ }
626
765
  return {
627
766
  type: 'input_file' as const,
628
767
  filename: item.filename ?? 'data',
629
768
  file_data: `data:${item.mediaType};base64,${item.data}`,
630
769
  };
770
+ case 'file-url':
771
+ if (item.mediaType.startsWith('image/')) {
772
+ return {
773
+ type: 'input_image' as const,
774
+ image_url: item.url,
775
+ };
776
+ }
777
+ return {
778
+ type: 'input_file' as const,
779
+ file_url: item.url,
780
+ };
631
781
  default:
632
782
  warnings.push({
633
783
  type: 'other',
@@ -656,7 +806,7 @@ export async function convertToOpenAIResponsesInput({
656
806
  contentValue = output.value;
657
807
  break;
658
808
  case 'execution-denied':
659
- contentValue = output.reason ?? 'Tool execution denied.';
809
+ contentValue = output.reason ?? 'Tool call execution denied.';
660
810
  break;
661
811
  case 'json':
662
812
  case 'error-json':
@@ -670,25 +820,30 @@ export async function convertToOpenAIResponsesInput({
670
820
  return { type: 'input_text' as const, text: item.text };
671
821
  }
672
822
 
673
- case 'image-data': {
674
- return {
675
- type: 'input_image' as const,
676
- image_url: `data:${item.mediaType};base64,${item.data}`,
677
- };
678
- }
679
-
680
- case 'image-url': {
823
+ case 'file-data': {
824
+ if (item.mediaType.startsWith('image/')) {
825
+ return {
826
+ type: 'input_image' as const,
827
+ image_url: `data:${item.mediaType};base64,${item.data}`,
828
+ };
829
+ }
681
830
  return {
682
- type: 'input_image' as const,
683
- image_url: item.url,
831
+ type: 'input_file' as const,
832
+ filename: item.filename ?? 'data',
833
+ file_data: `data:${item.mediaType};base64,${item.data}`,
684
834
  };
685
835
  }
686
836
 
687
- case 'file-data': {
837
+ case 'file-url': {
838
+ if (item.mediaType.startsWith('image/')) {
839
+ return {
840
+ type: 'input_image' as const,
841
+ image_url: item.url,
842
+ };
843
+ }
688
844
  return {
689
845
  type: 'input_file' as const,
690
- filename: item.filename ?? 'data',
691
- file_data: `data:${item.mediaType};base64,${item.data}`,
846
+ file_url: item.url,
692
847
  };
693
848
  }
694
849
 
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3FinishReason } from '@ai-sdk/provider';
1
+ import { LanguageModelV4FinishReason } from '@ai-sdk/provider';
2
2
 
3
3
  export function mapOpenAIResponseFinishReason({
4
4
  finishReason,
@@ -7,7 +7,7 @@ export function mapOpenAIResponseFinishReason({
7
7
  finishReason: string | null | undefined;
8
8
  // flag that checks if there have been client-side tool calls (not executed by openai)
9
9
  hasFunctionCall: boolean;
10
- }): LanguageModelV3FinishReason['unified'] {
10
+ }): LanguageModelV4FinishReason['unified'] {
11
11
  switch (finishReason) {
12
12
  case undefined:
13
13
  case null:
@@ -1,7 +1,18 @@
1
- import { JSONSchema7 } from '@ai-sdk/provider';
1
+ import { JSONObject, JSONSchema7, JSONValue } from '@ai-sdk/provider';
2
2
  import { InferSchema, lazySchema, zodSchema } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod/v4';
4
4
 
5
+ const jsonValueSchema: z.ZodType<JSONValue> = z.lazy(() =>
6
+ z.union([
7
+ z.string(),
8
+ z.number(),
9
+ z.boolean(),
10
+ z.null(),
11
+ z.array(jsonValueSchema),
12
+ z.record(z.string(), jsonValueSchema.optional()),
13
+ ]),
14
+ );
15
+
5
16
  export type OpenAIResponsesInput = Array<OpenAIResponsesInputItem>;
6
17
 
7
18
  export type OpenAIResponsesInputItem =
@@ -20,8 +31,11 @@ export type OpenAIResponsesInputItem =
20
31
  | OpenAIResponsesShellCallOutput
21
32
  | OpenAIResponsesApplyPatchCall
22
33
  | OpenAIResponsesApplyPatchCallOutput
34
+ | OpenAIResponsesToolSearchCall
35
+ | OpenAIResponsesToolSearchOutput
23
36
  | OpenAIResponsesReasoning
24
- | OpenAIResponsesItemReference;
37
+ | OpenAIResponsesItemReference
38
+ | OpenAIResponsesCompactionItem;
25
39
 
26
40
  export type OpenAIResponsesIncludeValue =
27
41
  | 'web_search_call.action.sources'
@@ -93,6 +107,7 @@ export type OpenAIResponsesFunctionCallOutput = {
93
107
  | { type: 'input_text'; text: string }
94
108
  | { type: 'input_image'; image_url: string }
95
109
  | { type: 'input_file'; filename: string; file_data: string }
110
+ | { type: 'input_file'; file_url: string }
96
111
  >;
97
112
  };
98
113
 
@@ -199,11 +214,35 @@ export type OpenAIResponsesApplyPatchCallOutput = {
199
214
  output?: string;
200
215
  };
201
216
 
217
+ export type OpenAIResponsesToolSearchCall = {
218
+ type: 'tool_search_call';
219
+ id: string;
220
+ execution: 'server' | 'client';
221
+ call_id: string | null;
222
+ status: 'in_progress' | 'completed' | 'incomplete';
223
+ arguments: unknown;
224
+ };
225
+
226
+ export type OpenAIResponsesToolSearchOutput = {
227
+ type: 'tool_search_output';
228
+ id?: string;
229
+ execution: 'server' | 'client';
230
+ call_id: string | null;
231
+ status: 'in_progress' | 'completed' | 'incomplete';
232
+ tools: Array<JSONObject>;
233
+ };
234
+
202
235
  export type OpenAIResponsesItemReference = {
203
236
  type: 'item_reference';
204
237
  id: string;
205
238
  };
206
239
 
240
+ export type OpenAIResponsesCompactionItem = {
241
+ type: 'compaction';
242
+ id: string;
243
+ encrypted_content: string;
244
+ };
245
+
207
246
  /**
208
247
  * A filter used to compare a specified attribute key to a given value using a defined comparison operation.
209
248
  */
@@ -249,6 +288,7 @@ export type OpenAIResponsesTool =
249
288
  description: string | undefined;
250
289
  parameters: JSONSchema7;
251
290
  strict?: boolean;
291
+ defer_loading?: boolean;
252
292
  }
253
293
  | {
254
294
  type: 'apply_patch';
@@ -407,6 +447,12 @@ export type OpenAIResponsesTool =
407
447
  path: string;
408
448
  }>;
409
449
  };
450
+ }
451
+ | {
452
+ type: 'tool_search';
453
+ execution?: 'server' | 'client';
454
+ description?: string;
455
+ parameters?: Record<string, unknown>;
410
456
  };
411
457
 
412
458
  export type OpenAIResponsesReasoning = {
@@ -458,6 +504,31 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
458
504
  service_tier: z.string().nullish(),
459
505
  }),
460
506
  }),
507
+ z.object({
508
+ type: z.literal('response.failed'),
509
+ response: z.object({
510
+ error: z
511
+ .object({
512
+ code: z.string().nullish(),
513
+ message: z.string(),
514
+ })
515
+ .nullish(),
516
+ incomplete_details: z.object({ reason: z.string() }).nullish(),
517
+ usage: z
518
+ .object({
519
+ input_tokens: z.number(),
520
+ input_tokens_details: z
521
+ .object({ cached_tokens: z.number().nullish() })
522
+ .nullish(),
523
+ output_tokens: z.number(),
524
+ output_tokens_details: z
525
+ .object({ reasoning_tokens: z.number().nullish() })
526
+ .nullish(),
527
+ })
528
+ .nullish(),
529
+ service_tier: z.string().nullish(),
530
+ }),
531
+ }),
461
532
  z.object({
462
533
  type: z.literal('response.created'),
463
534
  response: z.object({
@@ -573,6 +644,11 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
573
644
  commands: z.array(z.string()),
574
645
  }),
575
646
  }),
647
+ z.object({
648
+ type: z.literal('compaction'),
649
+ id: z.string(),
650
+ encrypted_content: z.string().nullish(),
651
+ }),
576
652
  z.object({
577
653
  type: z.literal('shell_call_output'),
578
654
  id: z.string(),
@@ -592,6 +668,22 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
592
668
  }),
593
669
  ),
594
670
  }),
671
+ z.object({
672
+ type: z.literal('tool_search_call'),
673
+ id: z.string(),
674
+ execution: z.enum(['server', 'client']),
675
+ call_id: z.string().nullable(),
676
+ status: z.enum(['in_progress', 'completed', 'incomplete']),
677
+ arguments: z.unknown(),
678
+ }),
679
+ z.object({
680
+ type: z.literal('tool_search_output'),
681
+ id: z.string(),
682
+ execution: z.enum(['server', 'client']),
683
+ call_id: z.string().nullable(),
684
+ status: z.enum(['in_progress', 'completed', 'incomplete']),
685
+ tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
686
+ }),
595
687
  ]),
596
688
  }),
597
689
  z.object({
@@ -796,6 +888,11 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
796
888
  commands: z.array(z.string()),
797
889
  }),
798
890
  }),
891
+ z.object({
892
+ type: z.literal('compaction'),
893
+ id: z.string(),
894
+ encrypted_content: z.string(),
895
+ }),
799
896
  z.object({
800
897
  type: z.literal('shell_call_output'),
801
898
  id: z.string(),
@@ -815,6 +912,22 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
815
912
  }),
816
913
  ),
817
914
  }),
915
+ z.object({
916
+ type: z.literal('tool_search_call'),
917
+ id: z.string(),
918
+ execution: z.enum(['server', 'client']),
919
+ call_id: z.string().nullable(),
920
+ status: z.enum(['in_progress', 'completed', 'incomplete']),
921
+ arguments: z.unknown(),
922
+ }),
923
+ z.object({
924
+ type: z.literal('tool_search_output'),
925
+ id: z.string(),
926
+ execution: z.enum(['server', 'client']),
927
+ call_id: z.string().nullable(),
928
+ status: z.enum(['in_progress', 'completed', 'incomplete']),
929
+ tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
930
+ }),
818
931
  ]),
819
932
  }),
820
933
  z.object({
@@ -1219,6 +1332,11 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
1219
1332
  commands: z.array(z.string()),
1220
1333
  }),
1221
1334
  }),
1335
+ z.object({
1336
+ type: z.literal('compaction'),
1337
+ id: z.string(),
1338
+ encrypted_content: z.string(),
1339
+ }),
1222
1340
  z.object({
1223
1341
  type: z.literal('shell_call_output'),
1224
1342
  id: z.string(),
@@ -1238,6 +1356,22 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
1238
1356
  }),
1239
1357
  ),
1240
1358
  }),
1359
+ z.object({
1360
+ type: z.literal('tool_search_call'),
1361
+ id: z.string(),
1362
+ execution: z.enum(['server', 'client']),
1363
+ call_id: z.string().nullable(),
1364
+ status: z.enum(['in_progress', 'completed', 'incomplete']),
1365
+ arguments: z.unknown(),
1366
+ }),
1367
+ z.object({
1368
+ type: z.literal('tool_search_output'),
1369
+ id: z.string(),
1370
+ execution: z.enum(['server', 'client']),
1371
+ call_id: z.string().nullable(),
1372
+ status: z.enum(['in_progress', 'completed', 'incomplete']),
1373
+ tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
1374
+ }),
1241
1375
  ]),
1242
1376
  )
1243
1377
  .optional(),