@ai-sdk/openai 4.0.0-beta.2 → 4.0.0-beta.21

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 (48) hide show
  1. package/CHANGELOG.md +234 -22
  2. package/README.md +2 -0
  3. package/dist/index.d.mts +134 -35
  4. package/dist/index.d.ts +134 -35
  5. package/dist/index.js +1700 -1139
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1697 -1117
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/internal/index.d.mts +107 -41
  10. package/dist/internal/index.d.ts +107 -41
  11. package/dist/internal/index.js +1380 -939
  12. package/dist/internal/index.js.map +1 -1
  13. package/dist/internal/index.mjs +1371 -917
  14. package/dist/internal/index.mjs.map +1 -1
  15. package/docs/03-openai.mdx +274 -9
  16. package/package.json +3 -5
  17. package/src/chat/convert-openai-chat-usage.ts +2 -2
  18. package/src/chat/convert-to-openai-chat-messages.ts +26 -15
  19. package/src/chat/map-openai-finish-reason.ts +2 -2
  20. package/src/chat/openai-chat-language-model.ts +32 -24
  21. package/src/chat/openai-chat-options.ts +5 -0
  22. package/src/chat/openai-chat-prepare-tools.ts +6 -6
  23. package/src/completion/convert-openai-completion-usage.ts +2 -2
  24. package/src/completion/convert-to-openai-completion-prompt.ts +2 -2
  25. package/src/completion/map-openai-finish-reason.ts +2 -2
  26. package/src/completion/openai-completion-language-model.ts +20 -20
  27. package/src/embedding/openai-embedding-model.ts +5 -5
  28. package/src/files/openai-files-api.ts +17 -0
  29. package/src/files/openai-files-options.ts +18 -0
  30. package/src/files/openai-files.ts +102 -0
  31. package/src/image/openai-image-model.ts +9 -9
  32. package/src/index.ts +2 -0
  33. package/src/openai-config.ts +5 -5
  34. package/src/openai-language-model-capabilities.ts +3 -2
  35. package/src/openai-provider.ts +39 -21
  36. package/src/openai-tools.ts +12 -1
  37. package/src/responses/convert-openai-responses-usage.ts +2 -2
  38. package/src/responses/convert-to-openai-responses-input.ts +188 -14
  39. package/src/responses/map-openai-responses-finish-reason.ts +2 -2
  40. package/src/responses/openai-responses-api.ts +136 -2
  41. package/src/responses/openai-responses-language-model.ts +233 -37
  42. package/src/responses/openai-responses-options.ts +24 -2
  43. package/src/responses/openai-responses-prepare-tools.ts +34 -9
  44. package/src/responses/openai-responses-provider-metadata.ts +10 -0
  45. package/src/speech/openai-speech-model.ts +7 -7
  46. package/src/tool/custom.ts +0 -6
  47. package/src/tool/tool-search.ts +98 -0
  48. package/src/transcription/openai-transcription-model.ts +8 -8
package/dist/index.mjs CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  createEventSourceResponseHandler,
16
16
  createJsonResponseHandler,
17
17
  generateId,
18
+ isCustomReasoning,
18
19
  isParsableJson,
19
20
  parseProviderOptions,
20
21
  postJsonToApi
@@ -42,9 +43,9 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
42
43
  // src/openai-language-model-capabilities.ts
43
44
  function getOpenAILanguageModelCapabilities(modelId) {
44
45
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
45
- const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
46
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
46
47
  const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
47
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.4");
48
+ const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
48
49
  const systemMessageMode = isReasoningModel ? "developer" : "system";
49
50
  return {
50
51
  supportsFlexProcessing,
@@ -98,7 +99,11 @@ function convertOpenAIChatUsage(usage) {
98
99
  import {
99
100
  UnsupportedFunctionalityError
100
101
  } from "@ai-sdk/provider";
101
- import { convertToBase64 } from "@ai-sdk/provider-utils";
102
+ import {
103
+ convertToBase64,
104
+ isProviderReference,
105
+ resolveProviderReference
106
+ } from "@ai-sdk/provider-utils";
102
107
  function convertToOpenAIChatMessages({
103
108
  prompt,
104
109
  systemMessageMode = "system"
@@ -148,13 +153,23 @@ function convertToOpenAIChatMessages({
148
153
  return { type: "text", text: part.text };
149
154
  }
150
155
  case "file": {
156
+ if (isProviderReference(part.data)) {
157
+ return {
158
+ type: "file",
159
+ file: {
160
+ file_id: resolveProviderReference({
161
+ reference: part.data,
162
+ provider: "openai"
163
+ })
164
+ }
165
+ };
166
+ }
151
167
  if (part.mediaType.startsWith("image/")) {
152
168
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
153
169
  return {
154
170
  type: "image_url",
155
171
  image_url: {
156
172
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
157
- // OpenAI specific extension: image detail
158
173
  detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
159
174
  }
160
175
  };
@@ -198,7 +213,7 @@ function convertToOpenAIChatMessages({
198
213
  }
199
214
  return {
200
215
  type: "file",
201
- file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
216
+ file: {
202
217
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
203
218
  file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
204
219
  }
@@ -639,7 +654,7 @@ function prepareChatTools({
639
654
  // src/chat/openai-chat-language-model.ts
640
655
  var OpenAIChatLanguageModel = class {
641
656
  constructor(modelId, config) {
642
- this.specificationVersion = "v3";
657
+ this.specificationVersion = "v4";
643
658
  this.supportedUrls = {
644
659
  "image/*": [/^https?:\/\/.*$/]
645
660
  };
@@ -662,9 +677,10 @@ var OpenAIChatLanguageModel = class {
662
677
  seed,
663
678
  tools,
664
679
  toolChoice,
680
+ reasoning,
665
681
  providerOptions
666
682
  }) {
667
- var _a, _b, _c, _d, _e;
683
+ var _a, _b, _c, _d, _e, _f;
668
684
  const warnings = [];
669
685
  const openaiOptions = (_a = await parseProviderOptions({
670
686
  provider: "openai",
@@ -672,18 +688,19 @@ var OpenAIChatLanguageModel = class {
672
688
  schema: openaiLanguageModelChatOptions
673
689
  })) != null ? _a : {};
674
690
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
675
- const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
691
+ const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
692
+ const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
676
693
  if (topK != null) {
677
694
  warnings.push({ type: "unsupported", feature: "topK" });
678
695
  }
679
696
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
680
697
  {
681
698
  prompt,
682
- systemMessageMode: (_c = openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
699
+ systemMessageMode: (_d = openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
683
700
  }
684
701
  );
685
702
  warnings.push(...messageWarnings);
686
- const strictJsonSchema = (_d = openaiOptions.strictJsonSchema) != null ? _d : true;
703
+ const strictJsonSchema = (_e = openaiOptions.strictJsonSchema) != null ? _e : true;
687
704
  const baseArgs = {
688
705
  // model id:
689
706
  model: this.modelId,
@@ -704,7 +721,7 @@ var OpenAIChatLanguageModel = class {
704
721
  json_schema: {
705
722
  schema: responseFormat.schema,
706
723
  strict: strictJsonSchema,
707
- name: (_e = responseFormat.name) != null ? _e : "response",
724
+ name: (_f = responseFormat.name) != null ? _f : "response",
708
725
  description: responseFormat.description
709
726
  }
710
727
  } : { type: "json_object" } : void 0,
@@ -717,7 +734,7 @@ var OpenAIChatLanguageModel = class {
717
734
  store: openaiOptions.store,
718
735
  metadata: openaiOptions.metadata,
719
736
  prediction: openaiOptions.prediction,
720
- reasoning_effort: openaiOptions.reasoningEffort,
737
+ reasoning_effort: resolvedReasoningEffort,
721
738
  service_tier: openaiOptions.serviceTier,
722
739
  prompt_cache_key: openaiOptions.promptCacheKey,
723
740
  prompt_cache_retention: openaiOptions.promptCacheRetention,
@@ -726,7 +743,7 @@ var OpenAIChatLanguageModel = class {
726
743
  messages
727
744
  };
728
745
  if (isReasoningModel) {
729
- if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
746
+ if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
730
747
  if (baseArgs.temperature != null) {
731
748
  baseArgs.temperature = void 0;
732
749
  warnings.push({
@@ -1383,7 +1400,7 @@ var openaiLanguageModelCompletionOptions = lazySchema4(
1383
1400
  // src/completion/openai-completion-language-model.ts
1384
1401
  var OpenAICompletionLanguageModel = class {
1385
1402
  constructor(modelId, config) {
1386
- this.specificationVersion = "v3";
1403
+ this.specificationVersion = "v4";
1387
1404
  this.supportedUrls = {
1388
1405
  // No URLs are supported for completion models.
1389
1406
  };
@@ -1655,7 +1672,7 @@ var openaiTextEmbeddingResponseSchema = lazySchema6(
1655
1672
  // src/embedding/openai-embedding-model.ts
1656
1673
  var OpenAIEmbeddingModel = class {
1657
1674
  constructor(modelId, config) {
1658
- this.specificationVersion = "v3";
1675
+ this.specificationVersion = "v4";
1659
1676
  this.maxEmbeddingsPerCall = 2048;
1660
1677
  this.supportsParallelCalls = true;
1661
1678
  this.modelId = modelId;
@@ -1717,41 +1734,149 @@ var OpenAIEmbeddingModel = class {
1717
1734
  }
1718
1735
  };
1719
1736
 
1720
- // src/image/openai-image-model.ts
1737
+ // src/files/openai-files.ts
1721
1738
  import {
1722
1739
  combineHeaders as combineHeaders4,
1723
1740
  convertBase64ToUint8Array,
1724
- convertToFormData,
1725
1741
  createJsonResponseHandler as createJsonResponseHandler4,
1726
- downloadBlob,
1727
- postFormDataToApi,
1728
- postJsonToApi as postJsonToApi4
1742
+ parseProviderOptions as parseProviderOptions4,
1743
+ postFormDataToApi
1729
1744
  } from "@ai-sdk/provider-utils";
1730
1745
 
1731
- // src/image/openai-image-api.ts
1746
+ // src/files/openai-files-api.ts
1732
1747
  import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
1733
1748
  import { z as z8 } from "zod/v4";
1734
- var openaiImageResponseSchema = lazySchema7(
1749
+ var openaiFilesResponseSchema = lazySchema7(
1735
1750
  () => zodSchema7(
1736
1751
  z8.object({
1737
- created: z8.number().nullish(),
1738
- data: z8.array(
1739
- z8.object({
1740
- b64_json: z8.string(),
1741
- revised_prompt: z8.string().nullish()
1752
+ id: z8.string(),
1753
+ object: z8.string().nullish(),
1754
+ bytes: z8.number().nullish(),
1755
+ created_at: z8.number().nullish(),
1756
+ filename: z8.string().nullish(),
1757
+ purpose: z8.string().nullish(),
1758
+ status: z8.string().nullish(),
1759
+ expires_at: z8.number().nullish()
1760
+ })
1761
+ )
1762
+ );
1763
+
1764
+ // src/files/openai-files-options.ts
1765
+ import { lazySchema as lazySchema8, zodSchema as zodSchema8 } from "@ai-sdk/provider-utils";
1766
+ import { z as z9 } from "zod/v4";
1767
+ var openaiFilesOptionsSchema = lazySchema8(
1768
+ () => zodSchema8(
1769
+ z9.object({
1770
+ /*
1771
+ * Required by the OpenAI API, but optional here because
1772
+ * the SDK defaults to "assistants" — by far the most common
1773
+ * purpose when uploading files in this context.
1774
+ */
1775
+ purpose: z9.string().optional(),
1776
+ expiresAfter: z9.number().optional()
1777
+ })
1778
+ )
1779
+ );
1780
+
1781
+ // src/files/openai-files.ts
1782
+ var OpenAIFiles = class {
1783
+ constructor(config) {
1784
+ this.config = config;
1785
+ this.specificationVersion = "v4";
1786
+ }
1787
+ get provider() {
1788
+ return this.config.provider;
1789
+ }
1790
+ async uploadFile({
1791
+ data,
1792
+ mediaType,
1793
+ filename,
1794
+ providerOptions
1795
+ }) {
1796
+ var _a, _b, _c;
1797
+ const openaiOptions = await parseProviderOptions4({
1798
+ provider: "openai",
1799
+ providerOptions,
1800
+ schema: openaiFilesOptionsSchema
1801
+ });
1802
+ const fileBytes = data instanceof Uint8Array ? data : convertBase64ToUint8Array(data);
1803
+ const blob = new Blob([fileBytes], {
1804
+ type: mediaType
1805
+ });
1806
+ const formData = new FormData();
1807
+ if (filename != null) {
1808
+ formData.append("file", blob, filename);
1809
+ } else {
1810
+ formData.append("file", blob);
1811
+ }
1812
+ formData.append("purpose", (_a = openaiOptions == null ? void 0 : openaiOptions.purpose) != null ? _a : "assistants");
1813
+ if ((openaiOptions == null ? void 0 : openaiOptions.expiresAfter) != null) {
1814
+ formData.append("expires_after", String(openaiOptions.expiresAfter));
1815
+ }
1816
+ const { value: response } = await postFormDataToApi({
1817
+ url: `${this.config.baseURL}/files`,
1818
+ headers: combineHeaders4(this.config.headers()),
1819
+ formData,
1820
+ failedResponseHandler: openaiFailedResponseHandler,
1821
+ successfulResponseHandler: createJsonResponseHandler4(
1822
+ openaiFilesResponseSchema
1823
+ ),
1824
+ fetch: this.config.fetch
1825
+ });
1826
+ return {
1827
+ warnings: [],
1828
+ providerReference: { openai: response.id },
1829
+ ...((_b = response.filename) != null ? _b : filename) ? { filename: (_c = response.filename) != null ? _c : filename } : {},
1830
+ ...mediaType != null ? { mediaType } : {},
1831
+ providerMetadata: {
1832
+ openai: {
1833
+ ...response.filename != null ? { filename: response.filename } : {},
1834
+ ...response.purpose != null ? { purpose: response.purpose } : {},
1835
+ ...response.bytes != null ? { bytes: response.bytes } : {},
1836
+ ...response.created_at != null ? { createdAt: response.created_at } : {},
1837
+ ...response.status != null ? { status: response.status } : {},
1838
+ ...response.expires_at != null ? { expiresAt: response.expires_at } : {}
1839
+ }
1840
+ }
1841
+ };
1842
+ }
1843
+ };
1844
+
1845
+ // src/image/openai-image-model.ts
1846
+ import {
1847
+ combineHeaders as combineHeaders5,
1848
+ convertBase64ToUint8Array as convertBase64ToUint8Array2,
1849
+ convertToFormData,
1850
+ createJsonResponseHandler as createJsonResponseHandler5,
1851
+ downloadBlob,
1852
+ postFormDataToApi as postFormDataToApi2,
1853
+ postJsonToApi as postJsonToApi4
1854
+ } from "@ai-sdk/provider-utils";
1855
+
1856
+ // src/image/openai-image-api.ts
1857
+ import { lazySchema as lazySchema9, zodSchema as zodSchema9 } from "@ai-sdk/provider-utils";
1858
+ import { z as z10 } from "zod/v4";
1859
+ var openaiImageResponseSchema = lazySchema9(
1860
+ () => zodSchema9(
1861
+ z10.object({
1862
+ created: z10.number().nullish(),
1863
+ data: z10.array(
1864
+ z10.object({
1865
+ b64_json: z10.string(),
1866
+ revised_prompt: z10.string().nullish()
1742
1867
  })
1743
1868
  ),
1744
- background: z8.string().nullish(),
1745
- output_format: z8.string().nullish(),
1746
- size: z8.string().nullish(),
1747
- quality: z8.string().nullish(),
1748
- usage: z8.object({
1749
- input_tokens: z8.number().nullish(),
1750
- output_tokens: z8.number().nullish(),
1751
- total_tokens: z8.number().nullish(),
1752
- input_tokens_details: z8.object({
1753
- image_tokens: z8.number().nullish(),
1754
- text_tokens: z8.number().nullish()
1869
+ background: z10.string().nullish(),
1870
+ output_format: z10.string().nullish(),
1871
+ size: z10.string().nullish(),
1872
+ quality: z10.string().nullish(),
1873
+ usage: z10.object({
1874
+ input_tokens: z10.number().nullish(),
1875
+ output_tokens: z10.number().nullish(),
1876
+ total_tokens: z10.number().nullish(),
1877
+ input_tokens_details: z10.object({
1878
+ image_tokens: z10.number().nullish(),
1879
+ text_tokens: z10.number().nullish()
1755
1880
  }).nullish()
1756
1881
  }).nullish()
1757
1882
  })
@@ -1784,7 +1909,7 @@ var OpenAIImageModel = class {
1784
1909
  constructor(modelId, config) {
1785
1910
  this.modelId = modelId;
1786
1911
  this.config = config;
1787
- this.specificationVersion = "v3";
1912
+ this.specificationVersion = "v4";
1788
1913
  }
1789
1914
  get maxImagesPerCall() {
1790
1915
  var _a;
@@ -1819,12 +1944,12 @@ var OpenAIImageModel = class {
1819
1944
  }
1820
1945
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1821
1946
  if (files != null) {
1822
- const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
1947
+ const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi2({
1823
1948
  url: this.config.url({
1824
1949
  path: "/images/edits",
1825
1950
  modelId: this.modelId
1826
1951
  }),
1827
- headers: combineHeaders4(this.config.headers(), headers),
1952
+ headers: combineHeaders5(this.config.headers(), headers),
1828
1953
  formData: convertToFormData({
1829
1954
  model: this.modelId,
1830
1955
  prompt,
@@ -1834,7 +1959,7 @@ var OpenAIImageModel = class {
1834
1959
  [
1835
1960
  file.data instanceof Uint8Array ? new Blob([file.data], {
1836
1961
  type: file.mediaType
1837
- }) : new Blob([convertBase64ToUint8Array(file.data)], {
1962
+ }) : new Blob([convertBase64ToUint8Array2(file.data)], {
1838
1963
  type: file.mediaType
1839
1964
  })
1840
1965
  ],
@@ -1848,7 +1973,7 @@ var OpenAIImageModel = class {
1848
1973
  ...(_d = providerOptions.openai) != null ? _d : {}
1849
1974
  }),
1850
1975
  failedResponseHandler: openaiFailedResponseHandler,
1851
- successfulResponseHandler: createJsonResponseHandler4(
1976
+ successfulResponseHandler: createJsonResponseHandler5(
1852
1977
  openaiImageResponseSchema
1853
1978
  ),
1854
1979
  abortSignal,
@@ -1894,7 +2019,7 @@ var OpenAIImageModel = class {
1894
2019
  path: "/images/generations",
1895
2020
  modelId: this.modelId
1896
2021
  }),
1897
- headers: combineHeaders4(this.config.headers(), headers),
2022
+ headers: combineHeaders5(this.config.headers(), headers),
1898
2023
  body: {
1899
2024
  model: this.modelId,
1900
2025
  prompt,
@@ -1904,7 +2029,7 @@ var OpenAIImageModel = class {
1904
2029
  ...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
1905
2030
  },
1906
2031
  failedResponseHandler: openaiFailedResponseHandler,
1907
- successfulResponseHandler: createJsonResponseHandler4(
2032
+ successfulResponseHandler: createJsonResponseHandler5(
1908
2033
  openaiImageResponseSchema
1909
2034
  ),
1910
2035
  abortSignal,
@@ -1968,49 +2093,49 @@ async function fileToBlob(file) {
1968
2093
  if (file.type === "url") {
1969
2094
  return downloadBlob(file.url);
1970
2095
  }
1971
- const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array(file.data);
2096
+ const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array2(file.data);
1972
2097
  return new Blob([data], { type: file.mediaType });
1973
2098
  }
1974
2099
 
1975
2100
  // src/tool/apply-patch.ts
1976
2101
  import {
1977
2102
  createProviderToolFactoryWithOutputSchema,
1978
- lazySchema as lazySchema8,
1979
- zodSchema as zodSchema8
2103
+ lazySchema as lazySchema10,
2104
+ zodSchema as zodSchema10
1980
2105
  } from "@ai-sdk/provider-utils";
1981
- import { z as z9 } from "zod/v4";
1982
- var applyPatchInputSchema = lazySchema8(
1983
- () => zodSchema8(
1984
- z9.object({
1985
- callId: z9.string(),
1986
- operation: z9.discriminatedUnion("type", [
1987
- z9.object({
1988
- type: z9.literal("create_file"),
1989
- path: z9.string(),
1990
- diff: z9.string()
2106
+ import { z as z11 } from "zod/v4";
2107
+ var applyPatchInputSchema = lazySchema10(
2108
+ () => zodSchema10(
2109
+ z11.object({
2110
+ callId: z11.string(),
2111
+ operation: z11.discriminatedUnion("type", [
2112
+ z11.object({
2113
+ type: z11.literal("create_file"),
2114
+ path: z11.string(),
2115
+ diff: z11.string()
1991
2116
  }),
1992
- z9.object({
1993
- type: z9.literal("delete_file"),
1994
- path: z9.string()
2117
+ z11.object({
2118
+ type: z11.literal("delete_file"),
2119
+ path: z11.string()
1995
2120
  }),
1996
- z9.object({
1997
- type: z9.literal("update_file"),
1998
- path: z9.string(),
1999
- diff: z9.string()
2121
+ z11.object({
2122
+ type: z11.literal("update_file"),
2123
+ path: z11.string(),
2124
+ diff: z11.string()
2000
2125
  })
2001
2126
  ])
2002
2127
  })
2003
2128
  )
2004
2129
  );
2005
- var applyPatchOutputSchema = lazySchema8(
2006
- () => zodSchema8(
2007
- z9.object({
2008
- status: z9.enum(["completed", "failed"]),
2009
- output: z9.string().optional()
2130
+ var applyPatchOutputSchema = lazySchema10(
2131
+ () => zodSchema10(
2132
+ z11.object({
2133
+ status: z11.enum(["completed", "failed"]),
2134
+ output: z11.string().optional()
2010
2135
  })
2011
2136
  )
2012
2137
  );
2013
- var applyPatchArgsSchema = lazySchema8(() => zodSchema8(z9.object({})));
2138
+ var applyPatchArgsSchema = lazySchema10(() => zodSchema10(z11.object({})));
2014
2139
  var applyPatchToolFactory = createProviderToolFactoryWithOutputSchema({
2015
2140
  id: "openai.apply_patch",
2016
2141
  inputSchema: applyPatchInputSchema,
@@ -2021,37 +2146,37 @@ var applyPatch = applyPatchToolFactory;
2021
2146
  // src/tool/code-interpreter.ts
2022
2147
  import {
2023
2148
  createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
2024
- lazySchema as lazySchema9,
2025
- zodSchema as zodSchema9
2149
+ lazySchema as lazySchema11,
2150
+ zodSchema as zodSchema11
2026
2151
  } from "@ai-sdk/provider-utils";
2027
- import { z as z10 } from "zod/v4";
2028
- var codeInterpreterInputSchema = lazySchema9(
2029
- () => zodSchema9(
2030
- z10.object({
2031
- code: z10.string().nullish(),
2032
- containerId: z10.string()
2152
+ import { z as z12 } from "zod/v4";
2153
+ var codeInterpreterInputSchema = lazySchema11(
2154
+ () => zodSchema11(
2155
+ z12.object({
2156
+ code: z12.string().nullish(),
2157
+ containerId: z12.string()
2033
2158
  })
2034
2159
  )
2035
2160
  );
2036
- var codeInterpreterOutputSchema = lazySchema9(
2037
- () => zodSchema9(
2038
- z10.object({
2039
- outputs: z10.array(
2040
- z10.discriminatedUnion("type", [
2041
- z10.object({ type: z10.literal("logs"), logs: z10.string() }),
2042
- z10.object({ type: z10.literal("image"), url: z10.string() })
2161
+ var codeInterpreterOutputSchema = lazySchema11(
2162
+ () => zodSchema11(
2163
+ z12.object({
2164
+ outputs: z12.array(
2165
+ z12.discriminatedUnion("type", [
2166
+ z12.object({ type: z12.literal("logs"), logs: z12.string() }),
2167
+ z12.object({ type: z12.literal("image"), url: z12.string() })
2043
2168
  ])
2044
2169
  ).nullish()
2045
2170
  })
2046
2171
  )
2047
2172
  );
2048
- var codeInterpreterArgsSchema = lazySchema9(
2049
- () => zodSchema9(
2050
- z10.object({
2051
- container: z10.union([
2052
- z10.string(),
2053
- z10.object({
2054
- fileIds: z10.array(z10.string()).optional()
2173
+ var codeInterpreterArgsSchema = lazySchema11(
2174
+ () => zodSchema11(
2175
+ z12.object({
2176
+ container: z12.union([
2177
+ z12.string(),
2178
+ z12.object({
2179
+ fileIds: z12.array(z12.string()).optional()
2055
2180
  })
2056
2181
  ]).optional()
2057
2182
  })
@@ -2069,29 +2194,28 @@ var codeInterpreter = (args = {}) => {
2069
2194
  // src/tool/custom.ts
2070
2195
  import {
2071
2196
  createProviderToolFactory,
2072
- lazySchema as lazySchema10,
2073
- zodSchema as zodSchema10
2197
+ lazySchema as lazySchema12,
2198
+ zodSchema as zodSchema12
2074
2199
  } from "@ai-sdk/provider-utils";
2075
- import { z as z11 } from "zod/v4";
2076
- var customArgsSchema = lazySchema10(
2077
- () => zodSchema10(
2078
- z11.object({
2079
- name: z11.string(),
2080
- description: z11.string().optional(),
2081
- format: z11.union([
2082
- z11.object({
2083
- type: z11.literal("grammar"),
2084
- syntax: z11.enum(["regex", "lark"]),
2085
- definition: z11.string()
2200
+ import { z as z13 } from "zod/v4";
2201
+ var customArgsSchema = lazySchema12(
2202
+ () => zodSchema12(
2203
+ z13.object({
2204
+ description: z13.string().optional(),
2205
+ format: z13.union([
2206
+ z13.object({
2207
+ type: z13.literal("grammar"),
2208
+ syntax: z13.enum(["regex", "lark"]),
2209
+ definition: z13.string()
2086
2210
  }),
2087
- z11.object({
2088
- type: z11.literal("text")
2211
+ z13.object({
2212
+ type: z13.literal("text")
2089
2213
  })
2090
2214
  ]).optional()
2091
2215
  })
2092
2216
  )
2093
2217
  );
2094
- var customInputSchema = lazySchema10(() => zodSchema10(z11.string()));
2218
+ var customInputSchema = lazySchema12(() => zodSchema12(z13.string()));
2095
2219
  var customToolFactory = createProviderToolFactory({
2096
2220
  id: "openai.custom",
2097
2221
  inputSchema: customInputSchema
@@ -2101,45 +2225,45 @@ var customTool = (args) => customToolFactory(args);
2101
2225
  // src/tool/file-search.ts
2102
2226
  import {
2103
2227
  createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
2104
- lazySchema as lazySchema11,
2105
- zodSchema as zodSchema11
2228
+ lazySchema as lazySchema13,
2229
+ zodSchema as zodSchema13
2106
2230
  } from "@ai-sdk/provider-utils";
2107
- import { z as z12 } from "zod/v4";
2108
- var comparisonFilterSchema = z12.object({
2109
- key: z12.string(),
2110
- type: z12.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
2111
- value: z12.union([z12.string(), z12.number(), z12.boolean(), z12.array(z12.string())])
2231
+ import { z as z14 } from "zod/v4";
2232
+ var comparisonFilterSchema = z14.object({
2233
+ key: z14.string(),
2234
+ type: z14.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
2235
+ value: z14.union([z14.string(), z14.number(), z14.boolean(), z14.array(z14.string())])
2112
2236
  });
2113
- var compoundFilterSchema = z12.object({
2114
- type: z12.enum(["and", "or"]),
2115
- filters: z12.array(
2116
- z12.union([comparisonFilterSchema, z12.lazy(() => compoundFilterSchema)])
2237
+ var compoundFilterSchema = z14.object({
2238
+ type: z14.enum(["and", "or"]),
2239
+ filters: z14.array(
2240
+ z14.union([comparisonFilterSchema, z14.lazy(() => compoundFilterSchema)])
2117
2241
  )
2118
2242
  });
2119
- var fileSearchArgsSchema = lazySchema11(
2120
- () => zodSchema11(
2121
- z12.object({
2122
- vectorStoreIds: z12.array(z12.string()),
2123
- maxNumResults: z12.number().optional(),
2124
- ranking: z12.object({
2125
- ranker: z12.string().optional(),
2126
- scoreThreshold: z12.number().optional()
2243
+ var fileSearchArgsSchema = lazySchema13(
2244
+ () => zodSchema13(
2245
+ z14.object({
2246
+ vectorStoreIds: z14.array(z14.string()),
2247
+ maxNumResults: z14.number().optional(),
2248
+ ranking: z14.object({
2249
+ ranker: z14.string().optional(),
2250
+ scoreThreshold: z14.number().optional()
2127
2251
  }).optional(),
2128
- filters: z12.union([comparisonFilterSchema, compoundFilterSchema]).optional()
2252
+ filters: z14.union([comparisonFilterSchema, compoundFilterSchema]).optional()
2129
2253
  })
2130
2254
  )
2131
2255
  );
2132
- var fileSearchOutputSchema = lazySchema11(
2133
- () => zodSchema11(
2134
- z12.object({
2135
- queries: z12.array(z12.string()),
2136
- results: z12.array(
2137
- z12.object({
2138
- attributes: z12.record(z12.string(), z12.unknown()),
2139
- fileId: z12.string(),
2140
- filename: z12.string(),
2141
- score: z12.number(),
2142
- text: z12.string()
2256
+ var fileSearchOutputSchema = lazySchema13(
2257
+ () => zodSchema13(
2258
+ z14.object({
2259
+ queries: z14.array(z14.string()),
2260
+ results: z14.array(
2261
+ z14.object({
2262
+ attributes: z14.record(z14.string(), z14.unknown()),
2263
+ fileId: z14.string(),
2264
+ filename: z14.string(),
2265
+ score: z14.number(),
2266
+ text: z14.string()
2143
2267
  })
2144
2268
  ).nullable()
2145
2269
  })
@@ -2147,39 +2271,39 @@ var fileSearchOutputSchema = lazySchema11(
2147
2271
  );
2148
2272
  var fileSearch = createProviderToolFactoryWithOutputSchema3({
2149
2273
  id: "openai.file_search",
2150
- inputSchema: z12.object({}),
2274
+ inputSchema: z14.object({}),
2151
2275
  outputSchema: fileSearchOutputSchema
2152
2276
  });
2153
2277
 
2154
2278
  // src/tool/image-generation.ts
2155
2279
  import {
2156
2280
  createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
2157
- lazySchema as lazySchema12,
2158
- zodSchema as zodSchema12
2281
+ lazySchema as lazySchema14,
2282
+ zodSchema as zodSchema14
2159
2283
  } from "@ai-sdk/provider-utils";
2160
- import { z as z13 } from "zod/v4";
2161
- var imageGenerationArgsSchema = lazySchema12(
2162
- () => zodSchema12(
2163
- z13.object({
2164
- background: z13.enum(["auto", "opaque", "transparent"]).optional(),
2165
- inputFidelity: z13.enum(["low", "high"]).optional(),
2166
- inputImageMask: z13.object({
2167
- fileId: z13.string().optional(),
2168
- imageUrl: z13.string().optional()
2284
+ import { z as z15 } from "zod/v4";
2285
+ var imageGenerationArgsSchema = lazySchema14(
2286
+ () => zodSchema14(
2287
+ z15.object({
2288
+ background: z15.enum(["auto", "opaque", "transparent"]).optional(),
2289
+ inputFidelity: z15.enum(["low", "high"]).optional(),
2290
+ inputImageMask: z15.object({
2291
+ fileId: z15.string().optional(),
2292
+ imageUrl: z15.string().optional()
2169
2293
  }).optional(),
2170
- model: z13.string().optional(),
2171
- moderation: z13.enum(["auto"]).optional(),
2172
- outputCompression: z13.number().int().min(0).max(100).optional(),
2173
- outputFormat: z13.enum(["png", "jpeg", "webp"]).optional(),
2174
- partialImages: z13.number().int().min(0).max(3).optional(),
2175
- quality: z13.enum(["auto", "low", "medium", "high"]).optional(),
2176
- size: z13.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2294
+ model: z15.string().optional(),
2295
+ moderation: z15.enum(["auto"]).optional(),
2296
+ outputCompression: z15.number().int().min(0).max(100).optional(),
2297
+ outputFormat: z15.enum(["png", "jpeg", "webp"]).optional(),
2298
+ partialImages: z15.number().int().min(0).max(3).optional(),
2299
+ quality: z15.enum(["auto", "low", "medium", "high"]).optional(),
2300
+ size: z15.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2177
2301
  }).strict()
2178
2302
  )
2179
2303
  );
2180
- var imageGenerationInputSchema = lazySchema12(() => zodSchema12(z13.object({})));
2181
- var imageGenerationOutputSchema = lazySchema12(
2182
- () => zodSchema12(z13.object({ result: z13.string() }))
2304
+ var imageGenerationInputSchema = lazySchema14(() => zodSchema14(z15.object({})));
2305
+ var imageGenerationOutputSchema = lazySchema14(
2306
+ () => zodSchema14(z15.object({ result: z15.string() }))
2183
2307
  );
2184
2308
  var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema4({
2185
2309
  id: "openai.image_generation",
@@ -2193,26 +2317,26 @@ var imageGeneration = (args = {}) => {
2193
2317
  // src/tool/local-shell.ts
2194
2318
  import {
2195
2319
  createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
2196
- lazySchema as lazySchema13,
2197
- zodSchema as zodSchema13
2320
+ lazySchema as lazySchema15,
2321
+ zodSchema as zodSchema15
2198
2322
  } from "@ai-sdk/provider-utils";
2199
- import { z as z14 } from "zod/v4";
2200
- var localShellInputSchema = lazySchema13(
2201
- () => zodSchema13(
2202
- z14.object({
2203
- action: z14.object({
2204
- type: z14.literal("exec"),
2205
- command: z14.array(z14.string()),
2206
- timeoutMs: z14.number().optional(),
2207
- user: z14.string().optional(),
2208
- workingDirectory: z14.string().optional(),
2209
- env: z14.record(z14.string(), z14.string()).optional()
2323
+ import { z as z16 } from "zod/v4";
2324
+ var localShellInputSchema = lazySchema15(
2325
+ () => zodSchema15(
2326
+ z16.object({
2327
+ action: z16.object({
2328
+ type: z16.literal("exec"),
2329
+ command: z16.array(z16.string()),
2330
+ timeoutMs: z16.number().optional(),
2331
+ user: z16.string().optional(),
2332
+ workingDirectory: z16.string().optional(),
2333
+ env: z16.record(z16.string(), z16.string()).optional()
2210
2334
  })
2211
2335
  })
2212
2336
  )
2213
2337
  );
2214
- var localShellOutputSchema = lazySchema13(
2215
- () => zodSchema13(z14.object({ output: z14.string() }))
2338
+ var localShellOutputSchema = lazySchema15(
2339
+ () => zodSchema15(z16.object({ output: z16.string() }))
2216
2340
  );
2217
2341
  var localShell = createProviderToolFactoryWithOutputSchema5({
2218
2342
  id: "openai.local_shell",
@@ -2223,91 +2347,91 @@ var localShell = createProviderToolFactoryWithOutputSchema5({
2223
2347
  // src/tool/shell.ts
2224
2348
  import {
2225
2349
  createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
2226
- lazySchema as lazySchema14,
2227
- zodSchema as zodSchema14
2350
+ lazySchema as lazySchema16,
2351
+ zodSchema as zodSchema16
2228
2352
  } from "@ai-sdk/provider-utils";
2229
- import { z as z15 } from "zod/v4";
2230
- var shellInputSchema = lazySchema14(
2231
- () => zodSchema14(
2232
- z15.object({
2233
- action: z15.object({
2234
- commands: z15.array(z15.string()),
2235
- timeoutMs: z15.number().optional(),
2236
- maxOutputLength: z15.number().optional()
2353
+ import { z as z17 } from "zod/v4";
2354
+ var shellInputSchema = lazySchema16(
2355
+ () => zodSchema16(
2356
+ z17.object({
2357
+ action: z17.object({
2358
+ commands: z17.array(z17.string()),
2359
+ timeoutMs: z17.number().optional(),
2360
+ maxOutputLength: z17.number().optional()
2237
2361
  })
2238
2362
  })
2239
2363
  )
2240
2364
  );
2241
- var shellOutputSchema = lazySchema14(
2242
- () => zodSchema14(
2243
- z15.object({
2244
- output: z15.array(
2245
- z15.object({
2246
- stdout: z15.string(),
2247
- stderr: z15.string(),
2248
- outcome: z15.discriminatedUnion("type", [
2249
- z15.object({ type: z15.literal("timeout") }),
2250
- z15.object({ type: z15.literal("exit"), exitCode: z15.number() })
2365
+ var shellOutputSchema = lazySchema16(
2366
+ () => zodSchema16(
2367
+ z17.object({
2368
+ output: z17.array(
2369
+ z17.object({
2370
+ stdout: z17.string(),
2371
+ stderr: z17.string(),
2372
+ outcome: z17.discriminatedUnion("type", [
2373
+ z17.object({ type: z17.literal("timeout") }),
2374
+ z17.object({ type: z17.literal("exit"), exitCode: z17.number() })
2251
2375
  ])
2252
2376
  })
2253
2377
  )
2254
2378
  })
2255
2379
  )
2256
2380
  );
2257
- var shellSkillsSchema = z15.array(
2258
- z15.discriminatedUnion("type", [
2259
- z15.object({
2260
- type: z15.literal("skillReference"),
2261
- skillId: z15.string(),
2262
- version: z15.string().optional()
2381
+ var shellSkillsSchema = z17.array(
2382
+ z17.discriminatedUnion("type", [
2383
+ z17.object({
2384
+ type: z17.literal("skillReference"),
2385
+ skillId: z17.string(),
2386
+ version: z17.string().optional()
2263
2387
  }),
2264
- z15.object({
2265
- type: z15.literal("inline"),
2266
- name: z15.string(),
2267
- description: z15.string(),
2268
- source: z15.object({
2269
- type: z15.literal("base64"),
2270
- mediaType: z15.literal("application/zip"),
2271
- data: z15.string()
2388
+ z17.object({
2389
+ type: z17.literal("inline"),
2390
+ name: z17.string(),
2391
+ description: z17.string(),
2392
+ source: z17.object({
2393
+ type: z17.literal("base64"),
2394
+ mediaType: z17.literal("application/zip"),
2395
+ data: z17.string()
2272
2396
  })
2273
2397
  })
2274
2398
  ])
2275
2399
  ).optional();
2276
- var shellArgsSchema = lazySchema14(
2277
- () => zodSchema14(
2278
- z15.object({
2279
- environment: z15.union([
2280
- z15.object({
2281
- type: z15.literal("containerAuto"),
2282
- fileIds: z15.array(z15.string()).optional(),
2283
- memoryLimit: z15.enum(["1g", "4g", "16g", "64g"]).optional(),
2284
- networkPolicy: z15.discriminatedUnion("type", [
2285
- z15.object({ type: z15.literal("disabled") }),
2286
- z15.object({
2287
- type: z15.literal("allowlist"),
2288
- allowedDomains: z15.array(z15.string()),
2289
- domainSecrets: z15.array(
2290
- z15.object({
2291
- domain: z15.string(),
2292
- name: z15.string(),
2293
- value: z15.string()
2400
+ var shellArgsSchema = lazySchema16(
2401
+ () => zodSchema16(
2402
+ z17.object({
2403
+ environment: z17.union([
2404
+ z17.object({
2405
+ type: z17.literal("containerAuto"),
2406
+ fileIds: z17.array(z17.string()).optional(),
2407
+ memoryLimit: z17.enum(["1g", "4g", "16g", "64g"]).optional(),
2408
+ networkPolicy: z17.discriminatedUnion("type", [
2409
+ z17.object({ type: z17.literal("disabled") }),
2410
+ z17.object({
2411
+ type: z17.literal("allowlist"),
2412
+ allowedDomains: z17.array(z17.string()),
2413
+ domainSecrets: z17.array(
2414
+ z17.object({
2415
+ domain: z17.string(),
2416
+ name: z17.string(),
2417
+ value: z17.string()
2294
2418
  })
2295
2419
  ).optional()
2296
2420
  })
2297
2421
  ]).optional(),
2298
2422
  skills: shellSkillsSchema
2299
2423
  }),
2300
- z15.object({
2301
- type: z15.literal("containerReference"),
2302
- containerId: z15.string()
2424
+ z17.object({
2425
+ type: z17.literal("containerReference"),
2426
+ containerId: z17.string()
2303
2427
  }),
2304
- z15.object({
2305
- type: z15.literal("local").optional(),
2306
- skills: z15.array(
2307
- z15.object({
2308
- name: z15.string(),
2309
- description: z15.string(),
2310
- path: z15.string()
2428
+ z17.object({
2429
+ type: z17.literal("local").optional(),
2430
+ skills: z17.array(
2431
+ z17.object({
2432
+ name: z17.string(),
2433
+ description: z17.string(),
2434
+ path: z17.string()
2311
2435
  })
2312
2436
  ).optional()
2313
2437
  })
@@ -2321,58 +2445,96 @@ var shell = createProviderToolFactoryWithOutputSchema6({
2321
2445
  outputSchema: shellOutputSchema
2322
2446
  });
2323
2447
 
2324
- // src/tool/web-search.ts
2448
+ // src/tool/tool-search.ts
2325
2449
  import {
2326
2450
  createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
2327
- lazySchema as lazySchema15,
2328
- zodSchema as zodSchema15
2451
+ lazySchema as lazySchema17,
2452
+ zodSchema as zodSchema17
2329
2453
  } from "@ai-sdk/provider-utils";
2330
- import { z as z16 } from "zod/v4";
2331
- var webSearchArgsSchema = lazySchema15(
2332
- () => zodSchema15(
2333
- z16.object({
2334
- externalWebAccess: z16.boolean().optional(),
2335
- filters: z16.object({ allowedDomains: z16.array(z16.string()).optional() }).optional(),
2336
- searchContextSize: z16.enum(["low", "medium", "high"]).optional(),
2337
- userLocation: z16.object({
2338
- type: z16.literal("approximate"),
2339
- country: z16.string().optional(),
2340
- city: z16.string().optional(),
2341
- region: z16.string().optional(),
2342
- timezone: z16.string().optional()
2454
+ import { z as z18 } from "zod/v4";
2455
+ var toolSearchArgsSchema = lazySchema17(
2456
+ () => zodSchema17(
2457
+ z18.object({
2458
+ execution: z18.enum(["server", "client"]).optional(),
2459
+ description: z18.string().optional(),
2460
+ parameters: z18.record(z18.string(), z18.unknown()).optional()
2461
+ })
2462
+ )
2463
+ );
2464
+ var toolSearchInputSchema = lazySchema17(
2465
+ () => zodSchema17(
2466
+ z18.object({
2467
+ arguments: z18.unknown().optional(),
2468
+ call_id: z18.string().nullish()
2469
+ })
2470
+ )
2471
+ );
2472
+ var toolSearchOutputSchema = lazySchema17(
2473
+ () => zodSchema17(
2474
+ z18.object({
2475
+ tools: z18.array(z18.record(z18.string(), z18.unknown()))
2476
+ })
2477
+ )
2478
+ );
2479
+ var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema7({
2480
+ id: "openai.tool_search",
2481
+ inputSchema: toolSearchInputSchema,
2482
+ outputSchema: toolSearchOutputSchema
2483
+ });
2484
+ var toolSearch = (args = {}) => toolSearchToolFactory(args);
2485
+
2486
+ // src/tool/web-search.ts
2487
+ import {
2488
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
2489
+ lazySchema as lazySchema18,
2490
+ zodSchema as zodSchema18
2491
+ } from "@ai-sdk/provider-utils";
2492
+ import { z as z19 } from "zod/v4";
2493
+ var webSearchArgsSchema = lazySchema18(
2494
+ () => zodSchema18(
2495
+ z19.object({
2496
+ externalWebAccess: z19.boolean().optional(),
2497
+ filters: z19.object({ allowedDomains: z19.array(z19.string()).optional() }).optional(),
2498
+ searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
2499
+ userLocation: z19.object({
2500
+ type: z19.literal("approximate"),
2501
+ country: z19.string().optional(),
2502
+ city: z19.string().optional(),
2503
+ region: z19.string().optional(),
2504
+ timezone: z19.string().optional()
2343
2505
  }).optional()
2344
2506
  })
2345
2507
  )
2346
2508
  );
2347
- var webSearchInputSchema = lazySchema15(() => zodSchema15(z16.object({})));
2348
- var webSearchOutputSchema = lazySchema15(
2349
- () => zodSchema15(
2350
- z16.object({
2351
- action: z16.discriminatedUnion("type", [
2352
- z16.object({
2353
- type: z16.literal("search"),
2354
- query: z16.string().optional()
2509
+ var webSearchInputSchema = lazySchema18(() => zodSchema18(z19.object({})));
2510
+ var webSearchOutputSchema = lazySchema18(
2511
+ () => zodSchema18(
2512
+ z19.object({
2513
+ action: z19.discriminatedUnion("type", [
2514
+ z19.object({
2515
+ type: z19.literal("search"),
2516
+ query: z19.string().optional()
2355
2517
  }),
2356
- z16.object({
2357
- type: z16.literal("openPage"),
2358
- url: z16.string().nullish()
2518
+ z19.object({
2519
+ type: z19.literal("openPage"),
2520
+ url: z19.string().nullish()
2359
2521
  }),
2360
- z16.object({
2361
- type: z16.literal("findInPage"),
2362
- url: z16.string().nullish(),
2363
- pattern: z16.string().nullish()
2522
+ z19.object({
2523
+ type: z19.literal("findInPage"),
2524
+ url: z19.string().nullish(),
2525
+ pattern: z19.string().nullish()
2364
2526
  })
2365
2527
  ]).optional(),
2366
- sources: z16.array(
2367
- z16.discriminatedUnion("type", [
2368
- z16.object({ type: z16.literal("url"), url: z16.string() }),
2369
- z16.object({ type: z16.literal("api"), name: z16.string() })
2528
+ sources: z19.array(
2529
+ z19.discriminatedUnion("type", [
2530
+ z19.object({ type: z19.literal("url"), url: z19.string() }),
2531
+ z19.object({ type: z19.literal("api"), name: z19.string() })
2370
2532
  ])
2371
2533
  ).optional()
2372
2534
  })
2373
2535
  )
2374
2536
  );
2375
- var webSearchToolFactory = createProviderToolFactoryWithOutputSchema7({
2537
+ var webSearchToolFactory = createProviderToolFactoryWithOutputSchema8({
2376
2538
  id: "openai.web_search",
2377
2539
  inputSchema: webSearchInputSchema,
2378
2540
  outputSchema: webSearchOutputSchema
@@ -2381,50 +2543,50 @@ var webSearch = (args = {}) => webSearchToolFactory(args);
2381
2543
 
2382
2544
  // src/tool/web-search-preview.ts
2383
2545
  import {
2384
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
2385
- lazySchema as lazySchema16,
2386
- zodSchema as zodSchema16
2546
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
2547
+ lazySchema as lazySchema19,
2548
+ zodSchema as zodSchema19
2387
2549
  } from "@ai-sdk/provider-utils";
2388
- import { z as z17 } from "zod/v4";
2389
- var webSearchPreviewArgsSchema = lazySchema16(
2390
- () => zodSchema16(
2391
- z17.object({
2392
- searchContextSize: z17.enum(["low", "medium", "high"]).optional(),
2393
- userLocation: z17.object({
2394
- type: z17.literal("approximate"),
2395
- country: z17.string().optional(),
2396
- city: z17.string().optional(),
2397
- region: z17.string().optional(),
2398
- timezone: z17.string().optional()
2550
+ import { z as z20 } from "zod/v4";
2551
+ var webSearchPreviewArgsSchema = lazySchema19(
2552
+ () => zodSchema19(
2553
+ z20.object({
2554
+ searchContextSize: z20.enum(["low", "medium", "high"]).optional(),
2555
+ userLocation: z20.object({
2556
+ type: z20.literal("approximate"),
2557
+ country: z20.string().optional(),
2558
+ city: z20.string().optional(),
2559
+ region: z20.string().optional(),
2560
+ timezone: z20.string().optional()
2399
2561
  }).optional()
2400
2562
  })
2401
2563
  )
2402
2564
  );
2403
- var webSearchPreviewInputSchema = lazySchema16(
2404
- () => zodSchema16(z17.object({}))
2565
+ var webSearchPreviewInputSchema = lazySchema19(
2566
+ () => zodSchema19(z20.object({}))
2405
2567
  );
2406
- var webSearchPreviewOutputSchema = lazySchema16(
2407
- () => zodSchema16(
2408
- z17.object({
2409
- action: z17.discriminatedUnion("type", [
2410
- z17.object({
2411
- type: z17.literal("search"),
2412
- query: z17.string().optional()
2568
+ var webSearchPreviewOutputSchema = lazySchema19(
2569
+ () => zodSchema19(
2570
+ z20.object({
2571
+ action: z20.discriminatedUnion("type", [
2572
+ z20.object({
2573
+ type: z20.literal("search"),
2574
+ query: z20.string().optional()
2413
2575
  }),
2414
- z17.object({
2415
- type: z17.literal("openPage"),
2416
- url: z17.string().nullish()
2576
+ z20.object({
2577
+ type: z20.literal("openPage"),
2578
+ url: z20.string().nullish()
2417
2579
  }),
2418
- z17.object({
2419
- type: z17.literal("findInPage"),
2420
- url: z17.string().nullish(),
2421
- pattern: z17.string().nullish()
2580
+ z20.object({
2581
+ type: z20.literal("findInPage"),
2582
+ url: z20.string().nullish(),
2583
+ pattern: z20.string().nullish()
2422
2584
  })
2423
2585
  ]).optional()
2424
2586
  })
2425
2587
  )
2426
2588
  );
2427
- var webSearchPreview = createProviderToolFactoryWithOutputSchema8({
2589
+ var webSearchPreview = createProviderToolFactoryWithOutputSchema9({
2428
2590
  id: "openai.web_search_preview",
2429
2591
  inputSchema: webSearchPreviewInputSchema,
2430
2592
  outputSchema: webSearchPreviewOutputSchema
@@ -2432,65 +2594,65 @@ var webSearchPreview = createProviderToolFactoryWithOutputSchema8({
2432
2594
 
2433
2595
  // src/tool/mcp.ts
2434
2596
  import {
2435
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
2436
- lazySchema as lazySchema17,
2437
- zodSchema as zodSchema17
2597
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema10,
2598
+ lazySchema as lazySchema20,
2599
+ zodSchema as zodSchema20
2438
2600
  } from "@ai-sdk/provider-utils";
2439
- import { z as z18 } from "zod/v4";
2440
- var jsonValueSchema = z18.lazy(
2441
- () => z18.union([
2442
- z18.string(),
2443
- z18.number(),
2444
- z18.boolean(),
2445
- z18.null(),
2446
- z18.array(jsonValueSchema),
2447
- z18.record(z18.string(), jsonValueSchema)
2601
+ import { z as z21 } from "zod/v4";
2602
+ var jsonValueSchema = z21.lazy(
2603
+ () => z21.union([
2604
+ z21.string(),
2605
+ z21.number(),
2606
+ z21.boolean(),
2607
+ z21.null(),
2608
+ z21.array(jsonValueSchema),
2609
+ z21.record(z21.string(), jsonValueSchema)
2448
2610
  ])
2449
2611
  );
2450
- var mcpArgsSchema = lazySchema17(
2451
- () => zodSchema17(
2452
- z18.object({
2453
- serverLabel: z18.string(),
2454
- allowedTools: z18.union([
2455
- z18.array(z18.string()),
2456
- z18.object({
2457
- readOnly: z18.boolean().optional(),
2458
- toolNames: z18.array(z18.string()).optional()
2612
+ var mcpArgsSchema = lazySchema20(
2613
+ () => zodSchema20(
2614
+ z21.object({
2615
+ serverLabel: z21.string(),
2616
+ allowedTools: z21.union([
2617
+ z21.array(z21.string()),
2618
+ z21.object({
2619
+ readOnly: z21.boolean().optional(),
2620
+ toolNames: z21.array(z21.string()).optional()
2459
2621
  })
2460
2622
  ]).optional(),
2461
- authorization: z18.string().optional(),
2462
- connectorId: z18.string().optional(),
2463
- headers: z18.record(z18.string(), z18.string()).optional(),
2464
- requireApproval: z18.union([
2465
- z18.enum(["always", "never"]),
2466
- z18.object({
2467
- never: z18.object({
2468
- toolNames: z18.array(z18.string()).optional()
2623
+ authorization: z21.string().optional(),
2624
+ connectorId: z21.string().optional(),
2625
+ headers: z21.record(z21.string(), z21.string()).optional(),
2626
+ requireApproval: z21.union([
2627
+ z21.enum(["always", "never"]),
2628
+ z21.object({
2629
+ never: z21.object({
2630
+ toolNames: z21.array(z21.string()).optional()
2469
2631
  }).optional()
2470
2632
  })
2471
2633
  ]).optional(),
2472
- serverDescription: z18.string().optional(),
2473
- serverUrl: z18.string().optional()
2634
+ serverDescription: z21.string().optional(),
2635
+ serverUrl: z21.string().optional()
2474
2636
  }).refine(
2475
2637
  (v) => v.serverUrl != null || v.connectorId != null,
2476
2638
  "One of serverUrl or connectorId must be provided."
2477
2639
  )
2478
2640
  )
2479
2641
  );
2480
- var mcpInputSchema = lazySchema17(() => zodSchema17(z18.object({})));
2481
- var mcpOutputSchema = lazySchema17(
2482
- () => zodSchema17(
2483
- z18.object({
2484
- type: z18.literal("call"),
2485
- serverLabel: z18.string(),
2486
- name: z18.string(),
2487
- arguments: z18.string(),
2488
- output: z18.string().nullish(),
2489
- error: z18.union([z18.string(), jsonValueSchema]).optional()
2642
+ var mcpInputSchema = lazySchema20(() => zodSchema20(z21.object({})));
2643
+ var mcpOutputSchema = lazySchema20(
2644
+ () => zodSchema20(
2645
+ z21.object({
2646
+ type: z21.literal("call"),
2647
+ serverLabel: z21.string(),
2648
+ name: z21.string(),
2649
+ arguments: z21.string(),
2650
+ output: z21.string().nullish(),
2651
+ error: z21.union([z21.string(), jsonValueSchema]).optional()
2490
2652
  })
2491
2653
  )
2492
2654
  );
2493
- var mcpToolFactory = createProviderToolFactoryWithOutputSchema9({
2655
+ var mcpToolFactory = createProviderToolFactoryWithOutputSchema10({
2494
2656
  id: "openai.mcp",
2495
2657
  inputSchema: mcpInputSchema,
2496
2658
  outputSchema: mcpOutputSchema
@@ -2512,7 +2674,6 @@ var openaiTools = {
2512
2674
  * Lark syntax). The model returns a `custom_tool_call` output item whose
2513
2675
  * `input` field is a string matching the specified grammar.
2514
2676
  *
2515
- * @param name - The name of the custom tool.
2516
2677
  * @param description - An optional description of the tool.
2517
2678
  * @param format - The output format constraint (grammar type, syntax, and definition).
2518
2679
  */
@@ -2602,7 +2763,17 @@ var openaiTools = {
2602
2763
  * @param serverDescription - Optional description of the server.
2603
2764
  * @param serverUrl - URL for the MCP server.
2604
2765
  */
2605
- mcp
2766
+ mcp,
2767
+ /**
2768
+ * Tool search allows the model to dynamically search for and load deferred
2769
+ * tools into the model's context as needed. This helps reduce overall token
2770
+ * usage, cost, and latency by only loading tools when the model needs them.
2771
+ *
2772
+ * To use tool search, mark functions or namespaces with `defer_loading: true`
2773
+ * in the tools array. The model will use tool search to load these tools
2774
+ * when it determines they are needed.
2775
+ */
2776
+ toolSearch
2606
2777
  };
2607
2778
 
2608
2779
  // src/responses/openai-responses-language-model.ts
@@ -2610,12 +2781,13 @@ import {
2610
2781
  APICallError
2611
2782
  } from "@ai-sdk/provider";
2612
2783
  import {
2613
- combineHeaders as combineHeaders5,
2784
+ combineHeaders as combineHeaders6,
2614
2785
  createEventSourceResponseHandler as createEventSourceResponseHandler3,
2615
- createJsonResponseHandler as createJsonResponseHandler5,
2786
+ createJsonResponseHandler as createJsonResponseHandler6,
2616
2787
  createToolNameMapping,
2617
2788
  generateId as generateId2,
2618
- parseProviderOptions as parseProviderOptions5,
2789
+ isCustomReasoning as isCustomReasoning2,
2790
+ parseProviderOptions as parseProviderOptions6,
2619
2791
  postJsonToApi as postJsonToApi5
2620
2792
  } from "@ai-sdk/provider-utils";
2621
2793
 
@@ -2665,10 +2837,13 @@ import {
2665
2837
  import {
2666
2838
  convertToBase64 as convertToBase642,
2667
2839
  isNonNullable,
2668
- parseProviderOptions as parseProviderOptions4,
2840
+ isProviderReference as isProviderReference2,
2841
+ parseJSON,
2842
+ parseProviderOptions as parseProviderOptions5,
2843
+ resolveProviderReference as resolveProviderReference2,
2669
2844
  validateTypes
2670
2845
  } from "@ai-sdk/provider-utils";
2671
- import { z as z19 } from "zod/v4";
2846
+ import { z as z22 } from "zod/v4";
2672
2847
  function isFileId(data, prefixes) {
2673
2848
  if (!prefixes) return false;
2674
2849
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -2686,8 +2861,8 @@ async function convertToOpenAIResponsesInput({
2686
2861
  hasApplyPatchTool = false,
2687
2862
  customProviderToolNames
2688
2863
  }) {
2689
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2690
- const input = [];
2864
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
2865
+ let input = [];
2691
2866
  const warnings = [];
2692
2867
  const processedApprovalIds = /* @__PURE__ */ new Set();
2693
2868
  for (const { role, content } of prompt) {
@@ -2722,12 +2897,29 @@ async function convertToOpenAIResponsesInput({
2722
2897
  input.push({
2723
2898
  role: "user",
2724
2899
  content: content.map((part, index) => {
2725
- var _a2, _b2, _c2;
2900
+ var _a2, _b2, _c2, _d2, _e2;
2726
2901
  switch (part.type) {
2727
2902
  case "text": {
2728
2903
  return { type: "input_text", text: part.text };
2729
2904
  }
2730
2905
  case "file": {
2906
+ if (isProviderReference2(part.data)) {
2907
+ const fileId = resolveProviderReference2({
2908
+ reference: part.data,
2909
+ provider: providerOptionsName
2910
+ });
2911
+ if (part.mediaType.startsWith("image/")) {
2912
+ return {
2913
+ type: "input_image",
2914
+ file_id: fileId,
2915
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
2916
+ };
2917
+ }
2918
+ return {
2919
+ type: "input_file",
2920
+ file_id: fileId
2921
+ };
2922
+ }
2731
2923
  if (part.mediaType.startsWith("image/")) {
2732
2924
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2733
2925
  return {
@@ -2735,7 +2927,7 @@ async function convertToOpenAIResponsesInput({
2735
2927
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2736
2928
  image_url: `data:${mediaType};base64,${convertToBase642(part.data)}`
2737
2929
  },
2738
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
2930
+ detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
2739
2931
  };
2740
2932
  } else if (part.mediaType === "application/pdf") {
2741
2933
  if (part.data instanceof URL) {
@@ -2747,7 +2939,7 @@ async function convertToOpenAIResponsesInput({
2747
2939
  return {
2748
2940
  type: "input_file",
2749
2941
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2750
- filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2942
+ filename: (_e2 = part.filename) != null ? _e2 : `part-${index}.pdf`,
2751
2943
  file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
2752
2944
  }
2753
2945
  };
@@ -2790,6 +2982,32 @@ async function convertToOpenAIResponsesInput({
2790
2982
  if (hasConversation && id != null) {
2791
2983
  break;
2792
2984
  }
2985
+ const resolvedToolName = toolNameMapping.toProviderToolName(
2986
+ part.toolName
2987
+ );
2988
+ if (resolvedToolName === "tool_search") {
2989
+ if (store && id != null) {
2990
+ input.push({ type: "item_reference", id });
2991
+ break;
2992
+ }
2993
+ const parsedInput = typeof part.input === "string" ? await parseJSON({
2994
+ text: part.input,
2995
+ schema: toolSearchInputSchema
2996
+ }) : await validateTypes({
2997
+ value: part.input,
2998
+ schema: toolSearchInputSchema
2999
+ });
3000
+ const execution = parsedInput.call_id != null ? "client" : "server";
3001
+ input.push({
3002
+ type: "tool_search_call",
3003
+ id: id != null ? id : part.toolCallId,
3004
+ execution,
3005
+ call_id: (_g = parsedInput.call_id) != null ? _g : null,
3006
+ status: "completed",
3007
+ arguments: parsedInput.arguments
3008
+ });
3009
+ break;
3010
+ }
2793
3011
  if (part.providerExecuted) {
2794
3012
  if (store && id != null) {
2795
3013
  input.push({ type: "item_reference", id });
@@ -2800,9 +3018,6 @@ async function convertToOpenAIResponsesInput({
2800
3018
  input.push({ type: "item_reference", id });
2801
3019
  break;
2802
3020
  }
2803
- const resolvedToolName = toolNameMapping.toProviderToolName(
2804
- part.toolName
2805
- );
2806
3021
  if (hasLocalShellTool && resolvedToolName === "local_shell") {
2807
3022
  const parsedInput = await validateTypes({
2808
3023
  value: part.input,
@@ -2885,6 +3100,26 @@ async function convertToOpenAIResponsesInput({
2885
3100
  const resolvedResultToolName = toolNameMapping.toProviderToolName(
2886
3101
  part.toolName
2887
3102
  );
3103
+ if (resolvedResultToolName === "tool_search") {
3104
+ const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
3105
+ if (store) {
3106
+ input.push({ type: "item_reference", id: itemId });
3107
+ } else if (part.output.type === "json") {
3108
+ const parsedOutput = await validateTypes({
3109
+ value: part.output.value,
3110
+ schema: toolSearchOutputSchema
3111
+ });
3112
+ input.push({
3113
+ type: "tool_search_output",
3114
+ id: itemId,
3115
+ execution: "server",
3116
+ call_id: null,
3117
+ status: "completed",
3118
+ tools: parsedOutput.tools
3119
+ });
3120
+ }
3121
+ break;
3122
+ }
2888
3123
  if (hasShellTool && resolvedResultToolName === "shell") {
2889
3124
  if (part.output.type === "json") {
2890
3125
  const parsedOutput = await validateTypes({
@@ -2907,7 +3142,7 @@ async function convertToOpenAIResponsesInput({
2907
3142
  break;
2908
3143
  }
2909
3144
  if (store) {
2910
- const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
3145
+ const itemId = (_m = (_l = (_k = part.providerOptions) == null ? void 0 : _k[providerOptionsName]) == null ? void 0 : _l.itemId) != null ? _m : part.toolCallId;
2911
3146
  input.push({ type: "item_reference", id: itemId });
2912
3147
  } else {
2913
3148
  warnings.push({
@@ -2918,7 +3153,7 @@ async function convertToOpenAIResponsesInput({
2918
3153
  break;
2919
3154
  }
2920
3155
  case "reasoning": {
2921
- const providerOptions = await parseProviderOptions4({
3156
+ const providerOptions = await parseProviderOptions5({
2922
3157
  provider: providerOptionsName,
2923
3158
  providerOptions: part.providerOptions,
2924
3159
  schema: openaiResponsesReasoningProviderOptionsSchema
@@ -2990,6 +3225,28 @@ async function convertToOpenAIResponsesInput({
2990
3225
  }
2991
3226
  break;
2992
3227
  }
3228
+ case "custom": {
3229
+ if (part.kind === "openai.compaction") {
3230
+ const providerOpts = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName];
3231
+ const id = providerOpts == null ? void 0 : providerOpts.itemId;
3232
+ if (hasConversation && id != null) {
3233
+ break;
3234
+ }
3235
+ if (store && id != null) {
3236
+ input.push({ type: "item_reference", id });
3237
+ break;
3238
+ }
3239
+ const encryptedContent = providerOpts == null ? void 0 : providerOpts.encryptedContent;
3240
+ if (id != null) {
3241
+ input.push({
3242
+ type: "compaction",
3243
+ id,
3244
+ encrypted_content: encryptedContent
3245
+ });
3246
+ }
3247
+ }
3248
+ break;
3249
+ }
2993
3250
  }
2994
3251
  }
2995
3252
  break;
@@ -3017,7 +3274,7 @@ async function convertToOpenAIResponsesInput({
3017
3274
  }
3018
3275
  const output = part.output;
3019
3276
  if (output.type === "execution-denied") {
3020
- const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
3277
+ const approvalId = (_p = (_o = output.providerOptions) == null ? void 0 : _o.openai) == null ? void 0 : _p.approvalId;
3021
3278
  if (approvalId) {
3022
3279
  continue;
3023
3280
  }
@@ -3025,6 +3282,20 @@ async function convertToOpenAIResponsesInput({
3025
3282
  const resolvedToolName = toolNameMapping.toProviderToolName(
3026
3283
  part.toolName
3027
3284
  );
3285
+ if (resolvedToolName === "tool_search" && output.type === "json") {
3286
+ const parsedOutput = await validateTypes({
3287
+ value: output.value,
3288
+ schema: toolSearchOutputSchema
3289
+ });
3290
+ input.push({
3291
+ type: "tool_search_output",
3292
+ execution: "client",
3293
+ call_id: part.toolCallId,
3294
+ status: "completed",
3295
+ tools: parsedOutput.tools
3296
+ });
3297
+ continue;
3298
+ }
3028
3299
  if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
3029
3300
  const parsedOutput = await validateTypes({
3030
3301
  value: output.value,
@@ -3077,7 +3348,7 @@ async function convertToOpenAIResponsesInput({
3077
3348
  outputValue = output.value;
3078
3349
  break;
3079
3350
  case "execution-denied":
3080
- outputValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
3351
+ outputValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
3081
3352
  break;
3082
3353
  case "json":
3083
3354
  case "error-json":
@@ -3105,6 +3376,11 @@ async function convertToOpenAIResponsesInput({
3105
3376
  filename: (_a2 = item.filename) != null ? _a2 : "data",
3106
3377
  file_data: `data:${item.mediaType};base64,${item.data}`
3107
3378
  };
3379
+ case "file-url":
3380
+ return {
3381
+ type: "input_file",
3382
+ file_url: item.url
3383
+ };
3108
3384
  default:
3109
3385
  warnings.push({
3110
3386
  type: "other",
@@ -3131,7 +3407,7 @@ async function convertToOpenAIResponsesInput({
3131
3407
  contentValue = output.value;
3132
3408
  break;
3133
3409
  case "execution-denied":
3134
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
3410
+ contentValue = (_r = output.reason) != null ? _r : "Tool execution denied.";
3135
3411
  break;
3136
3412
  case "json":
3137
3413
  case "error-json":
@@ -3163,6 +3439,12 @@ async function convertToOpenAIResponsesInput({
3163
3439
  file_data: `data:${item.mediaType};base64,${item.data}`
3164
3440
  };
3165
3441
  }
3442
+ case "file-url": {
3443
+ return {
3444
+ type: "input_file",
3445
+ file_url: item.url
3446
+ };
3447
+ }
3166
3448
  default: {
3167
3449
  warnings.push({
3168
3450
  type: "other",
@@ -3188,11 +3470,22 @@ async function convertToOpenAIResponsesInput({
3188
3470
  }
3189
3471
  }
3190
3472
  }
3473
+ if (!store && input.some(
3474
+ (item) => "type" in item && item.type === "reasoning" && item.encrypted_content == null
3475
+ )) {
3476
+ warnings.push({
3477
+ type: "other",
3478
+ message: "Reasoning parts without encrypted content are not supported when store is false. Skipping reasoning parts."
3479
+ });
3480
+ input = input.filter(
3481
+ (item) => !("type" in item) || item.type !== "reasoning" || item.encrypted_content != null
3482
+ );
3483
+ }
3191
3484
  return { input, warnings };
3192
3485
  }
3193
- var openaiResponsesReasoningProviderOptionsSchema = z19.object({
3194
- itemId: z19.string().nullish(),
3195
- reasoningEncryptedContent: z19.string().nullish()
3486
+ var openaiResponsesReasoningProviderOptionsSchema = z22.object({
3487
+ itemId: z22.string().nullish(),
3488
+ reasoningEncryptedContent: z22.string().nullish()
3196
3489
  });
3197
3490
 
3198
3491
  // src/responses/map-openai-responses-finish-reason.ts
@@ -3214,483 +3507,552 @@ function mapOpenAIResponseFinishReason({
3214
3507
  }
3215
3508
 
3216
3509
  // src/responses/openai-responses-api.ts
3217
- import { lazySchema as lazySchema18, zodSchema as zodSchema18 } from "@ai-sdk/provider-utils";
3218
- import { z as z20 } from "zod/v4";
3219
- var openaiResponsesChunkSchema = lazySchema18(
3220
- () => zodSchema18(
3221
- z20.union([
3222
- z20.object({
3223
- type: z20.literal("response.output_text.delta"),
3224
- item_id: z20.string(),
3225
- delta: z20.string(),
3226
- logprobs: z20.array(
3227
- z20.object({
3228
- token: z20.string(),
3229
- logprob: z20.number(),
3230
- top_logprobs: z20.array(
3231
- z20.object({
3232
- token: z20.string(),
3233
- logprob: z20.number()
3510
+ import { lazySchema as lazySchema21, zodSchema as zodSchema21 } from "@ai-sdk/provider-utils";
3511
+ import { z as z23 } from "zod/v4";
3512
+ var jsonValueSchema2 = z23.lazy(
3513
+ () => z23.union([
3514
+ z23.string(),
3515
+ z23.number(),
3516
+ z23.boolean(),
3517
+ z23.null(),
3518
+ z23.array(jsonValueSchema2),
3519
+ z23.record(z23.string(), jsonValueSchema2.optional())
3520
+ ])
3521
+ );
3522
+ var openaiResponsesChunkSchema = lazySchema21(
3523
+ () => zodSchema21(
3524
+ z23.union([
3525
+ z23.object({
3526
+ type: z23.literal("response.output_text.delta"),
3527
+ item_id: z23.string(),
3528
+ delta: z23.string(),
3529
+ logprobs: z23.array(
3530
+ z23.object({
3531
+ token: z23.string(),
3532
+ logprob: z23.number(),
3533
+ top_logprobs: z23.array(
3534
+ z23.object({
3535
+ token: z23.string(),
3536
+ logprob: z23.number()
3234
3537
  })
3235
3538
  )
3236
3539
  })
3237
3540
  ).nullish()
3238
3541
  }),
3239
- z20.object({
3240
- type: z20.enum(["response.completed", "response.incomplete"]),
3241
- response: z20.object({
3242
- incomplete_details: z20.object({ reason: z20.string() }).nullish(),
3243
- usage: z20.object({
3244
- input_tokens: z20.number(),
3245
- input_tokens_details: z20.object({ cached_tokens: z20.number().nullish() }).nullish(),
3246
- output_tokens: z20.number(),
3247
- output_tokens_details: z20.object({ reasoning_tokens: z20.number().nullish() }).nullish()
3542
+ z23.object({
3543
+ type: z23.enum(["response.completed", "response.incomplete"]),
3544
+ response: z23.object({
3545
+ incomplete_details: z23.object({ reason: z23.string() }).nullish(),
3546
+ usage: z23.object({
3547
+ input_tokens: z23.number(),
3548
+ input_tokens_details: z23.object({ cached_tokens: z23.number().nullish() }).nullish(),
3549
+ output_tokens: z23.number(),
3550
+ output_tokens_details: z23.object({ reasoning_tokens: z23.number().nullish() }).nullish()
3248
3551
  }),
3249
- service_tier: z20.string().nullish()
3552
+ service_tier: z23.string().nullish()
3553
+ })
3554
+ }),
3555
+ z23.object({
3556
+ type: z23.literal("response.failed"),
3557
+ response: z23.object({
3558
+ error: z23.object({
3559
+ code: z23.string().nullish(),
3560
+ message: z23.string()
3561
+ }).nullish(),
3562
+ incomplete_details: z23.object({ reason: z23.string() }).nullish(),
3563
+ usage: z23.object({
3564
+ input_tokens: z23.number(),
3565
+ input_tokens_details: z23.object({ cached_tokens: z23.number().nullish() }).nullish(),
3566
+ output_tokens: z23.number(),
3567
+ output_tokens_details: z23.object({ reasoning_tokens: z23.number().nullish() }).nullish()
3568
+ }).nullish(),
3569
+ service_tier: z23.string().nullish()
3250
3570
  })
3251
3571
  }),
3252
- z20.object({
3253
- type: z20.literal("response.created"),
3254
- response: z20.object({
3255
- id: z20.string(),
3256
- created_at: z20.number(),
3257
- model: z20.string(),
3258
- service_tier: z20.string().nullish()
3572
+ z23.object({
3573
+ type: z23.literal("response.created"),
3574
+ response: z23.object({
3575
+ id: z23.string(),
3576
+ created_at: z23.number(),
3577
+ model: z23.string(),
3578
+ service_tier: z23.string().nullish()
3259
3579
  })
3260
3580
  }),
3261
- z20.object({
3262
- type: z20.literal("response.output_item.added"),
3263
- output_index: z20.number(),
3264
- item: z20.discriminatedUnion("type", [
3265
- z20.object({
3266
- type: z20.literal("message"),
3267
- id: z20.string(),
3268
- phase: z20.enum(["commentary", "final_answer"]).nullish()
3581
+ z23.object({
3582
+ type: z23.literal("response.output_item.added"),
3583
+ output_index: z23.number(),
3584
+ item: z23.discriminatedUnion("type", [
3585
+ z23.object({
3586
+ type: z23.literal("message"),
3587
+ id: z23.string(),
3588
+ phase: z23.enum(["commentary", "final_answer"]).nullish()
3269
3589
  }),
3270
- z20.object({
3271
- type: z20.literal("reasoning"),
3272
- id: z20.string(),
3273
- encrypted_content: z20.string().nullish()
3590
+ z23.object({
3591
+ type: z23.literal("reasoning"),
3592
+ id: z23.string(),
3593
+ encrypted_content: z23.string().nullish()
3274
3594
  }),
3275
- z20.object({
3276
- type: z20.literal("function_call"),
3277
- id: z20.string(),
3278
- call_id: z20.string(),
3279
- name: z20.string(),
3280
- arguments: z20.string()
3595
+ z23.object({
3596
+ type: z23.literal("function_call"),
3597
+ id: z23.string(),
3598
+ call_id: z23.string(),
3599
+ name: z23.string(),
3600
+ arguments: z23.string()
3281
3601
  }),
3282
- z20.object({
3283
- type: z20.literal("web_search_call"),
3284
- id: z20.string(),
3285
- status: z20.string()
3602
+ z23.object({
3603
+ type: z23.literal("web_search_call"),
3604
+ id: z23.string(),
3605
+ status: z23.string()
3286
3606
  }),
3287
- z20.object({
3288
- type: z20.literal("computer_call"),
3289
- id: z20.string(),
3290
- status: z20.string()
3607
+ z23.object({
3608
+ type: z23.literal("computer_call"),
3609
+ id: z23.string(),
3610
+ status: z23.string()
3291
3611
  }),
3292
- z20.object({
3293
- type: z20.literal("file_search_call"),
3294
- id: z20.string()
3612
+ z23.object({
3613
+ type: z23.literal("file_search_call"),
3614
+ id: z23.string()
3295
3615
  }),
3296
- z20.object({
3297
- type: z20.literal("image_generation_call"),
3298
- id: z20.string()
3616
+ z23.object({
3617
+ type: z23.literal("image_generation_call"),
3618
+ id: z23.string()
3299
3619
  }),
3300
- z20.object({
3301
- type: z20.literal("code_interpreter_call"),
3302
- id: z20.string(),
3303
- container_id: z20.string(),
3304
- code: z20.string().nullable(),
3305
- outputs: z20.array(
3306
- z20.discriminatedUnion("type", [
3307
- z20.object({ type: z20.literal("logs"), logs: z20.string() }),
3308
- z20.object({ type: z20.literal("image"), url: z20.string() })
3620
+ z23.object({
3621
+ type: z23.literal("code_interpreter_call"),
3622
+ id: z23.string(),
3623
+ container_id: z23.string(),
3624
+ code: z23.string().nullable(),
3625
+ outputs: z23.array(
3626
+ z23.discriminatedUnion("type", [
3627
+ z23.object({ type: z23.literal("logs"), logs: z23.string() }),
3628
+ z23.object({ type: z23.literal("image"), url: z23.string() })
3309
3629
  ])
3310
3630
  ).nullable(),
3311
- status: z20.string()
3631
+ status: z23.string()
3312
3632
  }),
3313
- z20.object({
3314
- type: z20.literal("mcp_call"),
3315
- id: z20.string(),
3316
- status: z20.string(),
3317
- approval_request_id: z20.string().nullish()
3633
+ z23.object({
3634
+ type: z23.literal("mcp_call"),
3635
+ id: z23.string(),
3636
+ status: z23.string(),
3637
+ approval_request_id: z23.string().nullish()
3318
3638
  }),
3319
- z20.object({
3320
- type: z20.literal("mcp_list_tools"),
3321
- id: z20.string()
3639
+ z23.object({
3640
+ type: z23.literal("mcp_list_tools"),
3641
+ id: z23.string()
3322
3642
  }),
3323
- z20.object({
3324
- type: z20.literal("mcp_approval_request"),
3325
- id: z20.string()
3643
+ z23.object({
3644
+ type: z23.literal("mcp_approval_request"),
3645
+ id: z23.string()
3326
3646
  }),
3327
- z20.object({
3328
- type: z20.literal("apply_patch_call"),
3329
- id: z20.string(),
3330
- call_id: z20.string(),
3331
- status: z20.enum(["in_progress", "completed"]),
3332
- operation: z20.discriminatedUnion("type", [
3333
- z20.object({
3334
- type: z20.literal("create_file"),
3335
- path: z20.string(),
3336
- diff: z20.string()
3647
+ z23.object({
3648
+ type: z23.literal("apply_patch_call"),
3649
+ id: z23.string(),
3650
+ call_id: z23.string(),
3651
+ status: z23.enum(["in_progress", "completed"]),
3652
+ operation: z23.discriminatedUnion("type", [
3653
+ z23.object({
3654
+ type: z23.literal("create_file"),
3655
+ path: z23.string(),
3656
+ diff: z23.string()
3337
3657
  }),
3338
- z20.object({
3339
- type: z20.literal("delete_file"),
3340
- path: z20.string()
3658
+ z23.object({
3659
+ type: z23.literal("delete_file"),
3660
+ path: z23.string()
3341
3661
  }),
3342
- z20.object({
3343
- type: z20.literal("update_file"),
3344
- path: z20.string(),
3345
- diff: z20.string()
3662
+ z23.object({
3663
+ type: z23.literal("update_file"),
3664
+ path: z23.string(),
3665
+ diff: z23.string()
3346
3666
  })
3347
3667
  ])
3348
3668
  }),
3349
- z20.object({
3350
- type: z20.literal("custom_tool_call"),
3351
- id: z20.string(),
3352
- call_id: z20.string(),
3353
- name: z20.string(),
3354
- input: z20.string()
3669
+ z23.object({
3670
+ type: z23.literal("custom_tool_call"),
3671
+ id: z23.string(),
3672
+ call_id: z23.string(),
3673
+ name: z23.string(),
3674
+ input: z23.string()
3355
3675
  }),
3356
- z20.object({
3357
- type: z20.literal("shell_call"),
3358
- id: z20.string(),
3359
- call_id: z20.string(),
3360
- status: z20.enum(["in_progress", "completed", "incomplete"]),
3361
- action: z20.object({
3362
- commands: z20.array(z20.string())
3676
+ z23.object({
3677
+ type: z23.literal("shell_call"),
3678
+ id: z23.string(),
3679
+ call_id: z23.string(),
3680
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3681
+ action: z23.object({
3682
+ commands: z23.array(z23.string())
3363
3683
  })
3364
3684
  }),
3365
- z20.object({
3366
- type: z20.literal("shell_call_output"),
3367
- id: z20.string(),
3368
- call_id: z20.string(),
3369
- status: z20.enum(["in_progress", "completed", "incomplete"]),
3370
- output: z20.array(
3371
- z20.object({
3372
- stdout: z20.string(),
3373
- stderr: z20.string(),
3374
- outcome: z20.discriminatedUnion("type", [
3375
- z20.object({ type: z20.literal("timeout") }),
3376
- z20.object({
3377
- type: z20.literal("exit"),
3378
- exit_code: z20.number()
3685
+ z23.object({
3686
+ type: z23.literal("compaction"),
3687
+ id: z23.string(),
3688
+ encrypted_content: z23.string().nullish()
3689
+ }),
3690
+ z23.object({
3691
+ type: z23.literal("shell_call_output"),
3692
+ id: z23.string(),
3693
+ call_id: z23.string(),
3694
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3695
+ output: z23.array(
3696
+ z23.object({
3697
+ stdout: z23.string(),
3698
+ stderr: z23.string(),
3699
+ outcome: z23.discriminatedUnion("type", [
3700
+ z23.object({ type: z23.literal("timeout") }),
3701
+ z23.object({
3702
+ type: z23.literal("exit"),
3703
+ exit_code: z23.number()
3379
3704
  })
3380
3705
  ])
3381
3706
  })
3382
3707
  )
3708
+ }),
3709
+ z23.object({
3710
+ type: z23.literal("tool_search_call"),
3711
+ id: z23.string(),
3712
+ execution: z23.enum(["server", "client"]),
3713
+ call_id: z23.string().nullable(),
3714
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3715
+ arguments: z23.unknown()
3716
+ }),
3717
+ z23.object({
3718
+ type: z23.literal("tool_search_output"),
3719
+ id: z23.string(),
3720
+ execution: z23.enum(["server", "client"]),
3721
+ call_id: z23.string().nullable(),
3722
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3723
+ tools: z23.array(z23.record(z23.string(), jsonValueSchema2.optional()))
3383
3724
  })
3384
3725
  ])
3385
3726
  }),
3386
- z20.object({
3387
- type: z20.literal("response.output_item.done"),
3388
- output_index: z20.number(),
3389
- item: z20.discriminatedUnion("type", [
3390
- z20.object({
3391
- type: z20.literal("message"),
3392
- id: z20.string(),
3393
- phase: z20.enum(["commentary", "final_answer"]).nullish()
3727
+ z23.object({
3728
+ type: z23.literal("response.output_item.done"),
3729
+ output_index: z23.number(),
3730
+ item: z23.discriminatedUnion("type", [
3731
+ z23.object({
3732
+ type: z23.literal("message"),
3733
+ id: z23.string(),
3734
+ phase: z23.enum(["commentary", "final_answer"]).nullish()
3394
3735
  }),
3395
- z20.object({
3396
- type: z20.literal("reasoning"),
3397
- id: z20.string(),
3398
- encrypted_content: z20.string().nullish()
3736
+ z23.object({
3737
+ type: z23.literal("reasoning"),
3738
+ id: z23.string(),
3739
+ encrypted_content: z23.string().nullish()
3399
3740
  }),
3400
- z20.object({
3401
- type: z20.literal("function_call"),
3402
- id: z20.string(),
3403
- call_id: z20.string(),
3404
- name: z20.string(),
3405
- arguments: z20.string(),
3406
- status: z20.literal("completed")
3741
+ z23.object({
3742
+ type: z23.literal("function_call"),
3743
+ id: z23.string(),
3744
+ call_id: z23.string(),
3745
+ name: z23.string(),
3746
+ arguments: z23.string(),
3747
+ status: z23.literal("completed")
3407
3748
  }),
3408
- z20.object({
3409
- type: z20.literal("custom_tool_call"),
3410
- id: z20.string(),
3411
- call_id: z20.string(),
3412
- name: z20.string(),
3413
- input: z20.string(),
3414
- status: z20.literal("completed")
3749
+ z23.object({
3750
+ type: z23.literal("custom_tool_call"),
3751
+ id: z23.string(),
3752
+ call_id: z23.string(),
3753
+ name: z23.string(),
3754
+ input: z23.string(),
3755
+ status: z23.literal("completed")
3415
3756
  }),
3416
- z20.object({
3417
- type: z20.literal("code_interpreter_call"),
3418
- id: z20.string(),
3419
- code: z20.string().nullable(),
3420
- container_id: z20.string(),
3421
- outputs: z20.array(
3422
- z20.discriminatedUnion("type", [
3423
- z20.object({ type: z20.literal("logs"), logs: z20.string() }),
3424
- z20.object({ type: z20.literal("image"), url: z20.string() })
3757
+ z23.object({
3758
+ type: z23.literal("code_interpreter_call"),
3759
+ id: z23.string(),
3760
+ code: z23.string().nullable(),
3761
+ container_id: z23.string(),
3762
+ outputs: z23.array(
3763
+ z23.discriminatedUnion("type", [
3764
+ z23.object({ type: z23.literal("logs"), logs: z23.string() }),
3765
+ z23.object({ type: z23.literal("image"), url: z23.string() })
3425
3766
  ])
3426
3767
  ).nullable()
3427
3768
  }),
3428
- z20.object({
3429
- type: z20.literal("image_generation_call"),
3430
- id: z20.string(),
3431
- result: z20.string()
3769
+ z23.object({
3770
+ type: z23.literal("image_generation_call"),
3771
+ id: z23.string(),
3772
+ result: z23.string()
3432
3773
  }),
3433
- z20.object({
3434
- type: z20.literal("web_search_call"),
3435
- id: z20.string(),
3436
- status: z20.string(),
3437
- action: z20.discriminatedUnion("type", [
3438
- z20.object({
3439
- type: z20.literal("search"),
3440
- query: z20.string().nullish(),
3441
- sources: z20.array(
3442
- z20.discriminatedUnion("type", [
3443
- z20.object({ type: z20.literal("url"), url: z20.string() }),
3444
- z20.object({ type: z20.literal("api"), name: z20.string() })
3774
+ z23.object({
3775
+ type: z23.literal("web_search_call"),
3776
+ id: z23.string(),
3777
+ status: z23.string(),
3778
+ action: z23.discriminatedUnion("type", [
3779
+ z23.object({
3780
+ type: z23.literal("search"),
3781
+ query: z23.string().nullish(),
3782
+ sources: z23.array(
3783
+ z23.discriminatedUnion("type", [
3784
+ z23.object({ type: z23.literal("url"), url: z23.string() }),
3785
+ z23.object({ type: z23.literal("api"), name: z23.string() })
3445
3786
  ])
3446
3787
  ).nullish()
3447
3788
  }),
3448
- z20.object({
3449
- type: z20.literal("open_page"),
3450
- url: z20.string().nullish()
3789
+ z23.object({
3790
+ type: z23.literal("open_page"),
3791
+ url: z23.string().nullish()
3451
3792
  }),
3452
- z20.object({
3453
- type: z20.literal("find_in_page"),
3454
- url: z20.string().nullish(),
3455
- pattern: z20.string().nullish()
3793
+ z23.object({
3794
+ type: z23.literal("find_in_page"),
3795
+ url: z23.string().nullish(),
3796
+ pattern: z23.string().nullish()
3456
3797
  })
3457
3798
  ]).nullish()
3458
3799
  }),
3459
- z20.object({
3460
- type: z20.literal("file_search_call"),
3461
- id: z20.string(),
3462
- queries: z20.array(z20.string()),
3463
- results: z20.array(
3464
- z20.object({
3465
- attributes: z20.record(
3466
- z20.string(),
3467
- z20.union([z20.string(), z20.number(), z20.boolean()])
3800
+ z23.object({
3801
+ type: z23.literal("file_search_call"),
3802
+ id: z23.string(),
3803
+ queries: z23.array(z23.string()),
3804
+ results: z23.array(
3805
+ z23.object({
3806
+ attributes: z23.record(
3807
+ z23.string(),
3808
+ z23.union([z23.string(), z23.number(), z23.boolean()])
3468
3809
  ),
3469
- file_id: z20.string(),
3470
- filename: z20.string(),
3471
- score: z20.number(),
3472
- text: z20.string()
3810
+ file_id: z23.string(),
3811
+ filename: z23.string(),
3812
+ score: z23.number(),
3813
+ text: z23.string()
3473
3814
  })
3474
3815
  ).nullish()
3475
3816
  }),
3476
- z20.object({
3477
- type: z20.literal("local_shell_call"),
3478
- id: z20.string(),
3479
- call_id: z20.string(),
3480
- action: z20.object({
3481
- type: z20.literal("exec"),
3482
- command: z20.array(z20.string()),
3483
- timeout_ms: z20.number().optional(),
3484
- user: z20.string().optional(),
3485
- working_directory: z20.string().optional(),
3486
- env: z20.record(z20.string(), z20.string()).optional()
3817
+ z23.object({
3818
+ type: z23.literal("local_shell_call"),
3819
+ id: z23.string(),
3820
+ call_id: z23.string(),
3821
+ action: z23.object({
3822
+ type: z23.literal("exec"),
3823
+ command: z23.array(z23.string()),
3824
+ timeout_ms: z23.number().optional(),
3825
+ user: z23.string().optional(),
3826
+ working_directory: z23.string().optional(),
3827
+ env: z23.record(z23.string(), z23.string()).optional()
3487
3828
  })
3488
3829
  }),
3489
- z20.object({
3490
- type: z20.literal("computer_call"),
3491
- id: z20.string(),
3492
- status: z20.literal("completed")
3830
+ z23.object({
3831
+ type: z23.literal("computer_call"),
3832
+ id: z23.string(),
3833
+ status: z23.literal("completed")
3493
3834
  }),
3494
- z20.object({
3495
- type: z20.literal("mcp_call"),
3496
- id: z20.string(),
3497
- status: z20.string(),
3498
- arguments: z20.string(),
3499
- name: z20.string(),
3500
- server_label: z20.string(),
3501
- output: z20.string().nullish(),
3502
- error: z20.union([
3503
- z20.string(),
3504
- z20.object({
3505
- type: z20.string().optional(),
3506
- code: z20.union([z20.number(), z20.string()]).optional(),
3507
- message: z20.string().optional()
3835
+ z23.object({
3836
+ type: z23.literal("mcp_call"),
3837
+ id: z23.string(),
3838
+ status: z23.string(),
3839
+ arguments: z23.string(),
3840
+ name: z23.string(),
3841
+ server_label: z23.string(),
3842
+ output: z23.string().nullish(),
3843
+ error: z23.union([
3844
+ z23.string(),
3845
+ z23.object({
3846
+ type: z23.string().optional(),
3847
+ code: z23.union([z23.number(), z23.string()]).optional(),
3848
+ message: z23.string().optional()
3508
3849
  }).loose()
3509
3850
  ]).nullish(),
3510
- approval_request_id: z20.string().nullish()
3851
+ approval_request_id: z23.string().nullish()
3511
3852
  }),
3512
- z20.object({
3513
- type: z20.literal("mcp_list_tools"),
3514
- id: z20.string(),
3515
- server_label: z20.string(),
3516
- tools: z20.array(
3517
- z20.object({
3518
- name: z20.string(),
3519
- description: z20.string().optional(),
3520
- input_schema: z20.any(),
3521
- annotations: z20.record(z20.string(), z20.unknown()).optional()
3853
+ z23.object({
3854
+ type: z23.literal("mcp_list_tools"),
3855
+ id: z23.string(),
3856
+ server_label: z23.string(),
3857
+ tools: z23.array(
3858
+ z23.object({
3859
+ name: z23.string(),
3860
+ description: z23.string().optional(),
3861
+ input_schema: z23.any(),
3862
+ annotations: z23.record(z23.string(), z23.unknown()).optional()
3522
3863
  })
3523
3864
  ),
3524
- error: z20.union([
3525
- z20.string(),
3526
- z20.object({
3527
- type: z20.string().optional(),
3528
- code: z20.union([z20.number(), z20.string()]).optional(),
3529
- message: z20.string().optional()
3865
+ error: z23.union([
3866
+ z23.string(),
3867
+ z23.object({
3868
+ type: z23.string().optional(),
3869
+ code: z23.union([z23.number(), z23.string()]).optional(),
3870
+ message: z23.string().optional()
3530
3871
  }).loose()
3531
3872
  ]).optional()
3532
3873
  }),
3533
- z20.object({
3534
- type: z20.literal("mcp_approval_request"),
3535
- id: z20.string(),
3536
- server_label: z20.string(),
3537
- name: z20.string(),
3538
- arguments: z20.string(),
3539
- approval_request_id: z20.string().optional()
3874
+ z23.object({
3875
+ type: z23.literal("mcp_approval_request"),
3876
+ id: z23.string(),
3877
+ server_label: z23.string(),
3878
+ name: z23.string(),
3879
+ arguments: z23.string(),
3880
+ approval_request_id: z23.string().optional()
3540
3881
  }),
3541
- z20.object({
3542
- type: z20.literal("apply_patch_call"),
3543
- id: z20.string(),
3544
- call_id: z20.string(),
3545
- status: z20.enum(["in_progress", "completed"]),
3546
- operation: z20.discriminatedUnion("type", [
3547
- z20.object({
3548
- type: z20.literal("create_file"),
3549
- path: z20.string(),
3550
- diff: z20.string()
3882
+ z23.object({
3883
+ type: z23.literal("apply_patch_call"),
3884
+ id: z23.string(),
3885
+ call_id: z23.string(),
3886
+ status: z23.enum(["in_progress", "completed"]),
3887
+ operation: z23.discriminatedUnion("type", [
3888
+ z23.object({
3889
+ type: z23.literal("create_file"),
3890
+ path: z23.string(),
3891
+ diff: z23.string()
3551
3892
  }),
3552
- z20.object({
3553
- type: z20.literal("delete_file"),
3554
- path: z20.string()
3893
+ z23.object({
3894
+ type: z23.literal("delete_file"),
3895
+ path: z23.string()
3555
3896
  }),
3556
- z20.object({
3557
- type: z20.literal("update_file"),
3558
- path: z20.string(),
3559
- diff: z20.string()
3897
+ z23.object({
3898
+ type: z23.literal("update_file"),
3899
+ path: z23.string(),
3900
+ diff: z23.string()
3560
3901
  })
3561
3902
  ])
3562
3903
  }),
3563
- z20.object({
3564
- type: z20.literal("shell_call"),
3565
- id: z20.string(),
3566
- call_id: z20.string(),
3567
- status: z20.enum(["in_progress", "completed", "incomplete"]),
3568
- action: z20.object({
3569
- commands: z20.array(z20.string())
3904
+ z23.object({
3905
+ type: z23.literal("shell_call"),
3906
+ id: z23.string(),
3907
+ call_id: z23.string(),
3908
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3909
+ action: z23.object({
3910
+ commands: z23.array(z23.string())
3570
3911
  })
3571
3912
  }),
3572
- z20.object({
3573
- type: z20.literal("shell_call_output"),
3574
- id: z20.string(),
3575
- call_id: z20.string(),
3576
- status: z20.enum(["in_progress", "completed", "incomplete"]),
3577
- output: z20.array(
3578
- z20.object({
3579
- stdout: z20.string(),
3580
- stderr: z20.string(),
3581
- outcome: z20.discriminatedUnion("type", [
3582
- z20.object({ type: z20.literal("timeout") }),
3583
- z20.object({
3584
- type: z20.literal("exit"),
3585
- exit_code: z20.number()
3913
+ z23.object({
3914
+ type: z23.literal("compaction"),
3915
+ id: z23.string(),
3916
+ encrypted_content: z23.string()
3917
+ }),
3918
+ z23.object({
3919
+ type: z23.literal("shell_call_output"),
3920
+ id: z23.string(),
3921
+ call_id: z23.string(),
3922
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3923
+ output: z23.array(
3924
+ z23.object({
3925
+ stdout: z23.string(),
3926
+ stderr: z23.string(),
3927
+ outcome: z23.discriminatedUnion("type", [
3928
+ z23.object({ type: z23.literal("timeout") }),
3929
+ z23.object({
3930
+ type: z23.literal("exit"),
3931
+ exit_code: z23.number()
3586
3932
  })
3587
3933
  ])
3588
3934
  })
3589
3935
  )
3936
+ }),
3937
+ z23.object({
3938
+ type: z23.literal("tool_search_call"),
3939
+ id: z23.string(),
3940
+ execution: z23.enum(["server", "client"]),
3941
+ call_id: z23.string().nullable(),
3942
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3943
+ arguments: z23.unknown()
3944
+ }),
3945
+ z23.object({
3946
+ type: z23.literal("tool_search_output"),
3947
+ id: z23.string(),
3948
+ execution: z23.enum(["server", "client"]),
3949
+ call_id: z23.string().nullable(),
3950
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
3951
+ tools: z23.array(z23.record(z23.string(), jsonValueSchema2.optional()))
3590
3952
  })
3591
3953
  ])
3592
3954
  }),
3593
- z20.object({
3594
- type: z20.literal("response.function_call_arguments.delta"),
3595
- item_id: z20.string(),
3596
- output_index: z20.number(),
3597
- delta: z20.string()
3955
+ z23.object({
3956
+ type: z23.literal("response.function_call_arguments.delta"),
3957
+ item_id: z23.string(),
3958
+ output_index: z23.number(),
3959
+ delta: z23.string()
3598
3960
  }),
3599
- z20.object({
3600
- type: z20.literal("response.custom_tool_call_input.delta"),
3601
- item_id: z20.string(),
3602
- output_index: z20.number(),
3603
- delta: z20.string()
3961
+ z23.object({
3962
+ type: z23.literal("response.custom_tool_call_input.delta"),
3963
+ item_id: z23.string(),
3964
+ output_index: z23.number(),
3965
+ delta: z23.string()
3604
3966
  }),
3605
- z20.object({
3606
- type: z20.literal("response.image_generation_call.partial_image"),
3607
- item_id: z20.string(),
3608
- output_index: z20.number(),
3609
- partial_image_b64: z20.string()
3967
+ z23.object({
3968
+ type: z23.literal("response.image_generation_call.partial_image"),
3969
+ item_id: z23.string(),
3970
+ output_index: z23.number(),
3971
+ partial_image_b64: z23.string()
3610
3972
  }),
3611
- z20.object({
3612
- type: z20.literal("response.code_interpreter_call_code.delta"),
3613
- item_id: z20.string(),
3614
- output_index: z20.number(),
3615
- delta: z20.string()
3973
+ z23.object({
3974
+ type: z23.literal("response.code_interpreter_call_code.delta"),
3975
+ item_id: z23.string(),
3976
+ output_index: z23.number(),
3977
+ delta: z23.string()
3616
3978
  }),
3617
- z20.object({
3618
- type: z20.literal("response.code_interpreter_call_code.done"),
3619
- item_id: z20.string(),
3620
- output_index: z20.number(),
3621
- code: z20.string()
3979
+ z23.object({
3980
+ type: z23.literal("response.code_interpreter_call_code.done"),
3981
+ item_id: z23.string(),
3982
+ output_index: z23.number(),
3983
+ code: z23.string()
3622
3984
  }),
3623
- z20.object({
3624
- type: z20.literal("response.output_text.annotation.added"),
3625
- annotation: z20.discriminatedUnion("type", [
3626
- z20.object({
3627
- type: z20.literal("url_citation"),
3628
- start_index: z20.number(),
3629
- end_index: z20.number(),
3630
- url: z20.string(),
3631
- title: z20.string()
3985
+ z23.object({
3986
+ type: z23.literal("response.output_text.annotation.added"),
3987
+ annotation: z23.discriminatedUnion("type", [
3988
+ z23.object({
3989
+ type: z23.literal("url_citation"),
3990
+ start_index: z23.number(),
3991
+ end_index: z23.number(),
3992
+ url: z23.string(),
3993
+ title: z23.string()
3632
3994
  }),
3633
- z20.object({
3634
- type: z20.literal("file_citation"),
3635
- file_id: z20.string(),
3636
- filename: z20.string(),
3637
- index: z20.number()
3995
+ z23.object({
3996
+ type: z23.literal("file_citation"),
3997
+ file_id: z23.string(),
3998
+ filename: z23.string(),
3999
+ index: z23.number()
3638
4000
  }),
3639
- z20.object({
3640
- type: z20.literal("container_file_citation"),
3641
- container_id: z20.string(),
3642
- file_id: z20.string(),
3643
- filename: z20.string(),
3644
- start_index: z20.number(),
3645
- end_index: z20.number()
4001
+ z23.object({
4002
+ type: z23.literal("container_file_citation"),
4003
+ container_id: z23.string(),
4004
+ file_id: z23.string(),
4005
+ filename: z23.string(),
4006
+ start_index: z23.number(),
4007
+ end_index: z23.number()
3646
4008
  }),
3647
- z20.object({
3648
- type: z20.literal("file_path"),
3649
- file_id: z20.string(),
3650
- index: z20.number()
4009
+ z23.object({
4010
+ type: z23.literal("file_path"),
4011
+ file_id: z23.string(),
4012
+ index: z23.number()
3651
4013
  })
3652
4014
  ])
3653
4015
  }),
3654
- z20.object({
3655
- type: z20.literal("response.reasoning_summary_part.added"),
3656
- item_id: z20.string(),
3657
- summary_index: z20.number()
4016
+ z23.object({
4017
+ type: z23.literal("response.reasoning_summary_part.added"),
4018
+ item_id: z23.string(),
4019
+ summary_index: z23.number()
3658
4020
  }),
3659
- z20.object({
3660
- type: z20.literal("response.reasoning_summary_text.delta"),
3661
- item_id: z20.string(),
3662
- summary_index: z20.number(),
3663
- delta: z20.string()
4021
+ z23.object({
4022
+ type: z23.literal("response.reasoning_summary_text.delta"),
4023
+ item_id: z23.string(),
4024
+ summary_index: z23.number(),
4025
+ delta: z23.string()
3664
4026
  }),
3665
- z20.object({
3666
- type: z20.literal("response.reasoning_summary_part.done"),
3667
- item_id: z20.string(),
3668
- summary_index: z20.number()
4027
+ z23.object({
4028
+ type: z23.literal("response.reasoning_summary_part.done"),
4029
+ item_id: z23.string(),
4030
+ summary_index: z23.number()
3669
4031
  }),
3670
- z20.object({
3671
- type: z20.literal("response.apply_patch_call_operation_diff.delta"),
3672
- item_id: z20.string(),
3673
- output_index: z20.number(),
3674
- delta: z20.string(),
3675
- obfuscation: z20.string().nullish()
4032
+ z23.object({
4033
+ type: z23.literal("response.apply_patch_call_operation_diff.delta"),
4034
+ item_id: z23.string(),
4035
+ output_index: z23.number(),
4036
+ delta: z23.string(),
4037
+ obfuscation: z23.string().nullish()
3676
4038
  }),
3677
- z20.object({
3678
- type: z20.literal("response.apply_patch_call_operation_diff.done"),
3679
- item_id: z20.string(),
3680
- output_index: z20.number(),
3681
- diff: z20.string()
4039
+ z23.object({
4040
+ type: z23.literal("response.apply_patch_call_operation_diff.done"),
4041
+ item_id: z23.string(),
4042
+ output_index: z23.number(),
4043
+ diff: z23.string()
3682
4044
  }),
3683
- z20.object({
3684
- type: z20.literal("error"),
3685
- sequence_number: z20.number(),
3686
- error: z20.object({
3687
- type: z20.string(),
3688
- code: z20.string(),
3689
- message: z20.string(),
3690
- param: z20.string().nullish()
4045
+ z23.object({
4046
+ type: z23.literal("error"),
4047
+ sequence_number: z23.number(),
4048
+ error: z23.object({
4049
+ type: z23.string(),
4050
+ code: z23.string(),
4051
+ message: z23.string(),
4052
+ param: z23.string().nullish()
3691
4053
  })
3692
4054
  }),
3693
- z20.object({ type: z20.string() }).loose().transform((value) => ({
4055
+ z23.object({ type: z23.string() }).loose().transform((value) => ({
3694
4056
  type: "unknown_chunk",
3695
4057
  message: value.type
3696
4058
  }))
@@ -3698,294 +4060,315 @@ var openaiResponsesChunkSchema = lazySchema18(
3698
4060
  ])
3699
4061
  )
3700
4062
  );
3701
- var openaiResponsesResponseSchema = lazySchema18(
3702
- () => zodSchema18(
3703
- z20.object({
3704
- id: z20.string().optional(),
3705
- created_at: z20.number().optional(),
3706
- error: z20.object({
3707
- message: z20.string(),
3708
- type: z20.string(),
3709
- param: z20.string().nullish(),
3710
- code: z20.string()
4063
+ var openaiResponsesResponseSchema = lazySchema21(
4064
+ () => zodSchema21(
4065
+ z23.object({
4066
+ id: z23.string().optional(),
4067
+ created_at: z23.number().optional(),
4068
+ error: z23.object({
4069
+ message: z23.string(),
4070
+ type: z23.string(),
4071
+ param: z23.string().nullish(),
4072
+ code: z23.string()
3711
4073
  }).nullish(),
3712
- model: z20.string().optional(),
3713
- output: z20.array(
3714
- z20.discriminatedUnion("type", [
3715
- z20.object({
3716
- type: z20.literal("message"),
3717
- role: z20.literal("assistant"),
3718
- id: z20.string(),
3719
- phase: z20.enum(["commentary", "final_answer"]).nullish(),
3720
- content: z20.array(
3721
- z20.object({
3722
- type: z20.literal("output_text"),
3723
- text: z20.string(),
3724
- logprobs: z20.array(
3725
- z20.object({
3726
- token: z20.string(),
3727
- logprob: z20.number(),
3728
- top_logprobs: z20.array(
3729
- z20.object({
3730
- token: z20.string(),
3731
- logprob: z20.number()
4074
+ model: z23.string().optional(),
4075
+ output: z23.array(
4076
+ z23.discriminatedUnion("type", [
4077
+ z23.object({
4078
+ type: z23.literal("message"),
4079
+ role: z23.literal("assistant"),
4080
+ id: z23.string(),
4081
+ phase: z23.enum(["commentary", "final_answer"]).nullish(),
4082
+ content: z23.array(
4083
+ z23.object({
4084
+ type: z23.literal("output_text"),
4085
+ text: z23.string(),
4086
+ logprobs: z23.array(
4087
+ z23.object({
4088
+ token: z23.string(),
4089
+ logprob: z23.number(),
4090
+ top_logprobs: z23.array(
4091
+ z23.object({
4092
+ token: z23.string(),
4093
+ logprob: z23.number()
3732
4094
  })
3733
4095
  )
3734
4096
  })
3735
4097
  ).nullish(),
3736
- annotations: z20.array(
3737
- z20.discriminatedUnion("type", [
3738
- z20.object({
3739
- type: z20.literal("url_citation"),
3740
- start_index: z20.number(),
3741
- end_index: z20.number(),
3742
- url: z20.string(),
3743
- title: z20.string()
4098
+ annotations: z23.array(
4099
+ z23.discriminatedUnion("type", [
4100
+ z23.object({
4101
+ type: z23.literal("url_citation"),
4102
+ start_index: z23.number(),
4103
+ end_index: z23.number(),
4104
+ url: z23.string(),
4105
+ title: z23.string()
3744
4106
  }),
3745
- z20.object({
3746
- type: z20.literal("file_citation"),
3747
- file_id: z20.string(),
3748
- filename: z20.string(),
3749
- index: z20.number()
4107
+ z23.object({
4108
+ type: z23.literal("file_citation"),
4109
+ file_id: z23.string(),
4110
+ filename: z23.string(),
4111
+ index: z23.number()
3750
4112
  }),
3751
- z20.object({
3752
- type: z20.literal("container_file_citation"),
3753
- container_id: z20.string(),
3754
- file_id: z20.string(),
3755
- filename: z20.string(),
3756
- start_index: z20.number(),
3757
- end_index: z20.number()
4113
+ z23.object({
4114
+ type: z23.literal("container_file_citation"),
4115
+ container_id: z23.string(),
4116
+ file_id: z23.string(),
4117
+ filename: z23.string(),
4118
+ start_index: z23.number(),
4119
+ end_index: z23.number()
3758
4120
  }),
3759
- z20.object({
3760
- type: z20.literal("file_path"),
3761
- file_id: z20.string(),
3762
- index: z20.number()
4121
+ z23.object({
4122
+ type: z23.literal("file_path"),
4123
+ file_id: z23.string(),
4124
+ index: z23.number()
3763
4125
  })
3764
4126
  ])
3765
4127
  )
3766
4128
  })
3767
4129
  )
3768
4130
  }),
3769
- z20.object({
3770
- type: z20.literal("web_search_call"),
3771
- id: z20.string(),
3772
- status: z20.string(),
3773
- action: z20.discriminatedUnion("type", [
3774
- z20.object({
3775
- type: z20.literal("search"),
3776
- query: z20.string().nullish(),
3777
- sources: z20.array(
3778
- z20.discriminatedUnion("type", [
3779
- z20.object({ type: z20.literal("url"), url: z20.string() }),
3780
- z20.object({
3781
- type: z20.literal("api"),
3782
- name: z20.string()
4131
+ z23.object({
4132
+ type: z23.literal("web_search_call"),
4133
+ id: z23.string(),
4134
+ status: z23.string(),
4135
+ action: z23.discriminatedUnion("type", [
4136
+ z23.object({
4137
+ type: z23.literal("search"),
4138
+ query: z23.string().nullish(),
4139
+ sources: z23.array(
4140
+ z23.discriminatedUnion("type", [
4141
+ z23.object({ type: z23.literal("url"), url: z23.string() }),
4142
+ z23.object({
4143
+ type: z23.literal("api"),
4144
+ name: z23.string()
3783
4145
  })
3784
4146
  ])
3785
4147
  ).nullish()
3786
4148
  }),
3787
- z20.object({
3788
- type: z20.literal("open_page"),
3789
- url: z20.string().nullish()
4149
+ z23.object({
4150
+ type: z23.literal("open_page"),
4151
+ url: z23.string().nullish()
3790
4152
  }),
3791
- z20.object({
3792
- type: z20.literal("find_in_page"),
3793
- url: z20.string().nullish(),
3794
- pattern: z20.string().nullish()
4153
+ z23.object({
4154
+ type: z23.literal("find_in_page"),
4155
+ url: z23.string().nullish(),
4156
+ pattern: z23.string().nullish()
3795
4157
  })
3796
4158
  ]).nullish()
3797
4159
  }),
3798
- z20.object({
3799
- type: z20.literal("file_search_call"),
3800
- id: z20.string(),
3801
- queries: z20.array(z20.string()),
3802
- results: z20.array(
3803
- z20.object({
3804
- attributes: z20.record(
3805
- z20.string(),
3806
- z20.union([z20.string(), z20.number(), z20.boolean()])
4160
+ z23.object({
4161
+ type: z23.literal("file_search_call"),
4162
+ id: z23.string(),
4163
+ queries: z23.array(z23.string()),
4164
+ results: z23.array(
4165
+ z23.object({
4166
+ attributes: z23.record(
4167
+ z23.string(),
4168
+ z23.union([z23.string(), z23.number(), z23.boolean()])
3807
4169
  ),
3808
- file_id: z20.string(),
3809
- filename: z20.string(),
3810
- score: z20.number(),
3811
- text: z20.string()
4170
+ file_id: z23.string(),
4171
+ filename: z23.string(),
4172
+ score: z23.number(),
4173
+ text: z23.string()
3812
4174
  })
3813
4175
  ).nullish()
3814
4176
  }),
3815
- z20.object({
3816
- type: z20.literal("code_interpreter_call"),
3817
- id: z20.string(),
3818
- code: z20.string().nullable(),
3819
- container_id: z20.string(),
3820
- outputs: z20.array(
3821
- z20.discriminatedUnion("type", [
3822
- z20.object({ type: z20.literal("logs"), logs: z20.string() }),
3823
- z20.object({ type: z20.literal("image"), url: z20.string() })
4177
+ z23.object({
4178
+ type: z23.literal("code_interpreter_call"),
4179
+ id: z23.string(),
4180
+ code: z23.string().nullable(),
4181
+ container_id: z23.string(),
4182
+ outputs: z23.array(
4183
+ z23.discriminatedUnion("type", [
4184
+ z23.object({ type: z23.literal("logs"), logs: z23.string() }),
4185
+ z23.object({ type: z23.literal("image"), url: z23.string() })
3824
4186
  ])
3825
4187
  ).nullable()
3826
4188
  }),
3827
- z20.object({
3828
- type: z20.literal("image_generation_call"),
3829
- id: z20.string(),
3830
- result: z20.string()
4189
+ z23.object({
4190
+ type: z23.literal("image_generation_call"),
4191
+ id: z23.string(),
4192
+ result: z23.string()
3831
4193
  }),
3832
- z20.object({
3833
- type: z20.literal("local_shell_call"),
3834
- id: z20.string(),
3835
- call_id: z20.string(),
3836
- action: z20.object({
3837
- type: z20.literal("exec"),
3838
- command: z20.array(z20.string()),
3839
- timeout_ms: z20.number().optional(),
3840
- user: z20.string().optional(),
3841
- working_directory: z20.string().optional(),
3842
- env: z20.record(z20.string(), z20.string()).optional()
4194
+ z23.object({
4195
+ type: z23.literal("local_shell_call"),
4196
+ id: z23.string(),
4197
+ call_id: z23.string(),
4198
+ action: z23.object({
4199
+ type: z23.literal("exec"),
4200
+ command: z23.array(z23.string()),
4201
+ timeout_ms: z23.number().optional(),
4202
+ user: z23.string().optional(),
4203
+ working_directory: z23.string().optional(),
4204
+ env: z23.record(z23.string(), z23.string()).optional()
3843
4205
  })
3844
4206
  }),
3845
- z20.object({
3846
- type: z20.literal("function_call"),
3847
- call_id: z20.string(),
3848
- name: z20.string(),
3849
- arguments: z20.string(),
3850
- id: z20.string()
4207
+ z23.object({
4208
+ type: z23.literal("function_call"),
4209
+ call_id: z23.string(),
4210
+ name: z23.string(),
4211
+ arguments: z23.string(),
4212
+ id: z23.string()
3851
4213
  }),
3852
- z20.object({
3853
- type: z20.literal("custom_tool_call"),
3854
- call_id: z20.string(),
3855
- name: z20.string(),
3856
- input: z20.string(),
3857
- id: z20.string()
4214
+ z23.object({
4215
+ type: z23.literal("custom_tool_call"),
4216
+ call_id: z23.string(),
4217
+ name: z23.string(),
4218
+ input: z23.string(),
4219
+ id: z23.string()
3858
4220
  }),
3859
- z20.object({
3860
- type: z20.literal("computer_call"),
3861
- id: z20.string(),
3862
- status: z20.string().optional()
4221
+ z23.object({
4222
+ type: z23.literal("computer_call"),
4223
+ id: z23.string(),
4224
+ status: z23.string().optional()
3863
4225
  }),
3864
- z20.object({
3865
- type: z20.literal("reasoning"),
3866
- id: z20.string(),
3867
- encrypted_content: z20.string().nullish(),
3868
- summary: z20.array(
3869
- z20.object({
3870
- type: z20.literal("summary_text"),
3871
- text: z20.string()
4226
+ z23.object({
4227
+ type: z23.literal("reasoning"),
4228
+ id: z23.string(),
4229
+ encrypted_content: z23.string().nullish(),
4230
+ summary: z23.array(
4231
+ z23.object({
4232
+ type: z23.literal("summary_text"),
4233
+ text: z23.string()
3872
4234
  })
3873
4235
  )
3874
4236
  }),
3875
- z20.object({
3876
- type: z20.literal("mcp_call"),
3877
- id: z20.string(),
3878
- status: z20.string(),
3879
- arguments: z20.string(),
3880
- name: z20.string(),
3881
- server_label: z20.string(),
3882
- output: z20.string().nullish(),
3883
- error: z20.union([
3884
- z20.string(),
3885
- z20.object({
3886
- type: z20.string().optional(),
3887
- code: z20.union([z20.number(), z20.string()]).optional(),
3888
- message: z20.string().optional()
4237
+ z23.object({
4238
+ type: z23.literal("mcp_call"),
4239
+ id: z23.string(),
4240
+ status: z23.string(),
4241
+ arguments: z23.string(),
4242
+ name: z23.string(),
4243
+ server_label: z23.string(),
4244
+ output: z23.string().nullish(),
4245
+ error: z23.union([
4246
+ z23.string(),
4247
+ z23.object({
4248
+ type: z23.string().optional(),
4249
+ code: z23.union([z23.number(), z23.string()]).optional(),
4250
+ message: z23.string().optional()
3889
4251
  }).loose()
3890
4252
  ]).nullish(),
3891
- approval_request_id: z20.string().nullish()
4253
+ approval_request_id: z23.string().nullish()
3892
4254
  }),
3893
- z20.object({
3894
- type: z20.literal("mcp_list_tools"),
3895
- id: z20.string(),
3896
- server_label: z20.string(),
3897
- tools: z20.array(
3898
- z20.object({
3899
- name: z20.string(),
3900
- description: z20.string().optional(),
3901
- input_schema: z20.any(),
3902
- annotations: z20.record(z20.string(), z20.unknown()).optional()
4255
+ z23.object({
4256
+ type: z23.literal("mcp_list_tools"),
4257
+ id: z23.string(),
4258
+ server_label: z23.string(),
4259
+ tools: z23.array(
4260
+ z23.object({
4261
+ name: z23.string(),
4262
+ description: z23.string().optional(),
4263
+ input_schema: z23.any(),
4264
+ annotations: z23.record(z23.string(), z23.unknown()).optional()
3903
4265
  })
3904
4266
  ),
3905
- error: z20.union([
3906
- z20.string(),
3907
- z20.object({
3908
- type: z20.string().optional(),
3909
- code: z20.union([z20.number(), z20.string()]).optional(),
3910
- message: z20.string().optional()
4267
+ error: z23.union([
4268
+ z23.string(),
4269
+ z23.object({
4270
+ type: z23.string().optional(),
4271
+ code: z23.union([z23.number(), z23.string()]).optional(),
4272
+ message: z23.string().optional()
3911
4273
  }).loose()
3912
4274
  ]).optional()
3913
4275
  }),
3914
- z20.object({
3915
- type: z20.literal("mcp_approval_request"),
3916
- id: z20.string(),
3917
- server_label: z20.string(),
3918
- name: z20.string(),
3919
- arguments: z20.string(),
3920
- approval_request_id: z20.string().optional()
4276
+ z23.object({
4277
+ type: z23.literal("mcp_approval_request"),
4278
+ id: z23.string(),
4279
+ server_label: z23.string(),
4280
+ name: z23.string(),
4281
+ arguments: z23.string(),
4282
+ approval_request_id: z23.string().optional()
3921
4283
  }),
3922
- z20.object({
3923
- type: z20.literal("apply_patch_call"),
3924
- id: z20.string(),
3925
- call_id: z20.string(),
3926
- status: z20.enum(["in_progress", "completed"]),
3927
- operation: z20.discriminatedUnion("type", [
3928
- z20.object({
3929
- type: z20.literal("create_file"),
3930
- path: z20.string(),
3931
- diff: z20.string()
4284
+ z23.object({
4285
+ type: z23.literal("apply_patch_call"),
4286
+ id: z23.string(),
4287
+ call_id: z23.string(),
4288
+ status: z23.enum(["in_progress", "completed"]),
4289
+ operation: z23.discriminatedUnion("type", [
4290
+ z23.object({
4291
+ type: z23.literal("create_file"),
4292
+ path: z23.string(),
4293
+ diff: z23.string()
3932
4294
  }),
3933
- z20.object({
3934
- type: z20.literal("delete_file"),
3935
- path: z20.string()
4295
+ z23.object({
4296
+ type: z23.literal("delete_file"),
4297
+ path: z23.string()
3936
4298
  }),
3937
- z20.object({
3938
- type: z20.literal("update_file"),
3939
- path: z20.string(),
3940
- diff: z20.string()
4299
+ z23.object({
4300
+ type: z23.literal("update_file"),
4301
+ path: z23.string(),
4302
+ diff: z23.string()
3941
4303
  })
3942
4304
  ])
3943
4305
  }),
3944
- z20.object({
3945
- type: z20.literal("shell_call"),
3946
- id: z20.string(),
3947
- call_id: z20.string(),
3948
- status: z20.enum(["in_progress", "completed", "incomplete"]),
3949
- action: z20.object({
3950
- commands: z20.array(z20.string())
4306
+ z23.object({
4307
+ type: z23.literal("shell_call"),
4308
+ id: z23.string(),
4309
+ call_id: z23.string(),
4310
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
4311
+ action: z23.object({
4312
+ commands: z23.array(z23.string())
3951
4313
  })
3952
4314
  }),
3953
- z20.object({
3954
- type: z20.literal("shell_call_output"),
3955
- id: z20.string(),
3956
- call_id: z20.string(),
3957
- status: z20.enum(["in_progress", "completed", "incomplete"]),
3958
- output: z20.array(
3959
- z20.object({
3960
- stdout: z20.string(),
3961
- stderr: z20.string(),
3962
- outcome: z20.discriminatedUnion("type", [
3963
- z20.object({ type: z20.literal("timeout") }),
3964
- z20.object({
3965
- type: z20.literal("exit"),
3966
- exit_code: z20.number()
4315
+ z23.object({
4316
+ type: z23.literal("compaction"),
4317
+ id: z23.string(),
4318
+ encrypted_content: z23.string()
4319
+ }),
4320
+ z23.object({
4321
+ type: z23.literal("shell_call_output"),
4322
+ id: z23.string(),
4323
+ call_id: z23.string(),
4324
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
4325
+ output: z23.array(
4326
+ z23.object({
4327
+ stdout: z23.string(),
4328
+ stderr: z23.string(),
4329
+ outcome: z23.discriminatedUnion("type", [
4330
+ z23.object({ type: z23.literal("timeout") }),
4331
+ z23.object({
4332
+ type: z23.literal("exit"),
4333
+ exit_code: z23.number()
3967
4334
  })
3968
4335
  ])
3969
4336
  })
3970
4337
  )
4338
+ }),
4339
+ z23.object({
4340
+ type: z23.literal("tool_search_call"),
4341
+ id: z23.string(),
4342
+ execution: z23.enum(["server", "client"]),
4343
+ call_id: z23.string().nullable(),
4344
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
4345
+ arguments: z23.unknown()
4346
+ }),
4347
+ z23.object({
4348
+ type: z23.literal("tool_search_output"),
4349
+ id: z23.string(),
4350
+ execution: z23.enum(["server", "client"]),
4351
+ call_id: z23.string().nullable(),
4352
+ status: z23.enum(["in_progress", "completed", "incomplete"]),
4353
+ tools: z23.array(z23.record(z23.string(), jsonValueSchema2.optional()))
3971
4354
  })
3972
4355
  ])
3973
4356
  ).optional(),
3974
- service_tier: z20.string().nullish(),
3975
- incomplete_details: z20.object({ reason: z20.string() }).nullish(),
3976
- usage: z20.object({
3977
- input_tokens: z20.number(),
3978
- input_tokens_details: z20.object({ cached_tokens: z20.number().nullish() }).nullish(),
3979
- output_tokens: z20.number(),
3980
- output_tokens_details: z20.object({ reasoning_tokens: z20.number().nullish() }).nullish()
4357
+ service_tier: z23.string().nullish(),
4358
+ incomplete_details: z23.object({ reason: z23.string() }).nullish(),
4359
+ usage: z23.object({
4360
+ input_tokens: z23.number(),
4361
+ input_tokens_details: z23.object({ cached_tokens: z23.number().nullish() }).nullish(),
4362
+ output_tokens: z23.number(),
4363
+ output_tokens_details: z23.object({ reasoning_tokens: z23.number().nullish() }).nullish()
3981
4364
  }).optional()
3982
4365
  })
3983
4366
  )
3984
4367
  );
3985
4368
 
3986
4369
  // src/responses/openai-responses-options.ts
3987
- import { lazySchema as lazySchema19, zodSchema as zodSchema19 } from "@ai-sdk/provider-utils";
3988
- import { z as z21 } from "zod/v4";
4370
+ import { lazySchema as lazySchema22, zodSchema as zodSchema22 } from "@ai-sdk/provider-utils";
4371
+ import { z as z24 } from "zod/v4";
3989
4372
  var TOP_LOGPROBS_MAX = 20;
3990
4373
  var openaiResponsesReasoningModelIds = [
3991
4374
  "o1",
@@ -4014,11 +4397,16 @@ var openaiResponsesReasoningModelIds = [
4014
4397
  "gpt-5.2-chat-latest",
4015
4398
  "gpt-5.2-pro",
4016
4399
  "gpt-5.2-codex",
4400
+ "gpt-5.3-chat-latest",
4401
+ "gpt-5.3-codex",
4017
4402
  "gpt-5.4",
4018
4403
  "gpt-5.4-2026-03-05",
4404
+ "gpt-5.4-mini",
4405
+ "gpt-5.4-mini-2026-03-17",
4406
+ "gpt-5.4-nano",
4407
+ "gpt-5.4-nano-2026-03-17",
4019
4408
  "gpt-5.4-pro",
4020
- "gpt-5.4-pro-2026-03-05",
4021
- "gpt-5.3-codex"
4409
+ "gpt-5.4-pro-2026-03-05"
4022
4410
  ];
4023
4411
  var openaiResponsesModelIds = [
4024
4412
  "gpt-4.1",
@@ -4045,9 +4433,9 @@ var openaiResponsesModelIds = [
4045
4433
  "gpt-5-chat-latest",
4046
4434
  ...openaiResponsesReasoningModelIds
4047
4435
  ];
4048
- var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4049
- () => zodSchema19(
4050
- z21.object({
4436
+ var openaiLanguageModelResponsesOptionsSchema = lazySchema22(
4437
+ () => zodSchema22(
4438
+ z24.object({
4051
4439
  /**
4052
4440
  * The ID of the OpenAI Conversation to continue.
4053
4441
  * You must create a conversation first via the OpenAI API.
@@ -4055,13 +4443,13 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4055
4443
  * Defaults to `undefined`.
4056
4444
  * @see https://platform.openai.com/docs/api-reference/conversations/create
4057
4445
  */
4058
- conversation: z21.string().nullish(),
4446
+ conversation: z24.string().nullish(),
4059
4447
  /**
4060
4448
  * The set of extra fields to include in the response (advanced, usually not needed).
4061
4449
  * Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'message.output_text.logprobs'.
4062
4450
  */
4063
- include: z21.array(
4064
- z21.enum([
4451
+ include: z24.array(
4452
+ z24.enum([
4065
4453
  "reasoning.encrypted_content",
4066
4454
  // handled internally by default, only needed for unknown reasoning models
4067
4455
  "file_search_call.results",
@@ -4073,7 +4461,7 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4073
4461
  * They can be used to change the system or developer message when continuing a conversation using the `previousResponseId` option.
4074
4462
  * Defaults to `undefined`.
4075
4463
  */
4076
- instructions: z21.string().nullish(),
4464
+ instructions: z24.string().nullish(),
4077
4465
  /**
4078
4466
  * Return the log probabilities of the tokens. Including logprobs will increase
4079
4467
  * the response size and can slow down response times. However, it can
@@ -4088,30 +4476,30 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4088
4476
  * @see https://platform.openai.com/docs/api-reference/responses/create
4089
4477
  * @see https://cookbook.openai.com/examples/using_logprobs
4090
4478
  */
4091
- logprobs: z21.union([z21.boolean(), z21.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
4479
+ logprobs: z24.union([z24.boolean(), z24.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
4092
4480
  /**
4093
4481
  * The maximum number of total calls to built-in tools that can be processed in a response.
4094
4482
  * This maximum number applies across all built-in tool calls, not per individual tool.
4095
4483
  * Any further attempts to call a tool by the model will be ignored.
4096
4484
  */
4097
- maxToolCalls: z21.number().nullish(),
4485
+ maxToolCalls: z24.number().nullish(),
4098
4486
  /**
4099
4487
  * Additional metadata to store with the generation.
4100
4488
  */
4101
- metadata: z21.any().nullish(),
4489
+ metadata: z24.any().nullish(),
4102
4490
  /**
4103
4491
  * Whether to use parallel tool calls. Defaults to `true`.
4104
4492
  */
4105
- parallelToolCalls: z21.boolean().nullish(),
4493
+ parallelToolCalls: z24.boolean().nullish(),
4106
4494
  /**
4107
4495
  * The ID of the previous response. You can use it to continue a conversation.
4108
4496
  * Defaults to `undefined`.
4109
4497
  */
4110
- previousResponseId: z21.string().nullish(),
4498
+ previousResponseId: z24.string().nullish(),
4111
4499
  /**
4112
4500
  * Sets a cache key to tie this prompt to cached prefixes for better caching performance.
4113
4501
  */
4114
- promptCacheKey: z21.string().nullish(),
4502
+ promptCacheKey: z24.string().nullish(),
4115
4503
  /**
4116
4504
  * The retention policy for the prompt cache.
4117
4505
  * - 'in_memory': Default. Standard prompt caching behavior.
@@ -4120,7 +4508,7 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4120
4508
  *
4121
4509
  * @default 'in_memory'
4122
4510
  */
4123
- promptCacheRetention: z21.enum(["in_memory", "24h"]).nullish(),
4511
+ promptCacheRetention: z24.enum(["in_memory", "24h"]).nullish(),
4124
4512
  /**
4125
4513
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
4126
4514
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
@@ -4131,17 +4519,17 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4131
4519
  * OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
4132
4520
  * an error.
4133
4521
  */
4134
- reasoningEffort: z21.string().nullish(),
4522
+ reasoningEffort: z24.string().nullish(),
4135
4523
  /**
4136
4524
  * Controls reasoning summary output from the model.
4137
4525
  * Set to "auto" to automatically receive the richest level available,
4138
4526
  * or "detailed" for comprehensive summaries.
4139
4527
  */
4140
- reasoningSummary: z21.string().nullish(),
4528
+ reasoningSummary: z24.string().nullish(),
4141
4529
  /**
4142
4530
  * The identifier for safety monitoring and tracking.
4143
4531
  */
4144
- safetyIdentifier: z21.string().nullish(),
4532
+ safetyIdentifier: z24.string().nullish(),
4145
4533
  /**
4146
4534
  * Service tier for the request.
4147
4535
  * Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
@@ -4149,34 +4537,34 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4149
4537
  *
4150
4538
  * Defaults to 'auto'.
4151
4539
  */
4152
- serviceTier: z21.enum(["auto", "flex", "priority", "default"]).nullish(),
4540
+ serviceTier: z24.enum(["auto", "flex", "priority", "default"]).nullish(),
4153
4541
  /**
4154
4542
  * Whether to store the generation. Defaults to `true`.
4155
4543
  */
4156
- store: z21.boolean().nullish(),
4544
+ store: z24.boolean().nullish(),
4157
4545
  /**
4158
4546
  * Whether to use strict JSON schema validation.
4159
4547
  * Defaults to `true`.
4160
4548
  */
4161
- strictJsonSchema: z21.boolean().nullish(),
4549
+ strictJsonSchema: z24.boolean().nullish(),
4162
4550
  /**
4163
4551
  * Controls the verbosity of the model's responses. Lower values ('low') will result
4164
4552
  * in more concise responses, while higher values ('high') will result in more verbose responses.
4165
4553
  * Valid values: 'low', 'medium', 'high'.
4166
4554
  */
4167
- textVerbosity: z21.enum(["low", "medium", "high"]).nullish(),
4555
+ textVerbosity: z24.enum(["low", "medium", "high"]).nullish(),
4168
4556
  /**
4169
4557
  * Controls output truncation. 'auto' (default) performs truncation automatically;
4170
4558
  * 'disabled' turns truncation off.
4171
4559
  */
4172
- truncation: z21.enum(["auto", "disabled"]).nullish(),
4560
+ truncation: z24.enum(["auto", "disabled"]).nullish(),
4173
4561
  /**
4174
4562
  * A unique identifier representing your end-user, which can help OpenAI to
4175
4563
  * monitor and detect abuse.
4176
4564
  * Defaults to `undefined`.
4177
4565
  * @see https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids
4178
4566
  */
4179
- user: z21.string().nullish(),
4567
+ user: z24.string().nullish(),
4180
4568
  /**
4181
4569
  * Override the system message mode for this model.
4182
4570
  * - 'system': Use the 'system' role for system messages (default for most models)
@@ -4185,7 +4573,7 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4185
4573
  *
4186
4574
  * If not specified, the mode is automatically determined based on the model.
4187
4575
  */
4188
- systemMessageMode: z21.enum(["system", "developer", "remove"]).optional(),
4576
+ systemMessageMode: z24.enum(["system", "developer", "remove"]).optional(),
4189
4577
  /**
4190
4578
  * Force treating this model as a reasoning model.
4191
4579
  *
@@ -4195,7 +4583,16 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
4195
4583
  * When enabled, the SDK applies reasoning-model parameter compatibility rules
4196
4584
  * and defaults `systemMessageMode` to `developer` unless overridden.
4197
4585
  */
4198
- forceReasoning: z21.boolean().optional()
4586
+ forceReasoning: z24.boolean().optional(),
4587
+ /**
4588
+ * Enable server-side context management (compaction).
4589
+ */
4590
+ contextManagement: z24.array(
4591
+ z24.object({
4592
+ type: z24.literal("compaction"),
4593
+ compactThreshold: z24.number()
4594
+ })
4595
+ ).nullish()
4199
4596
  })
4200
4597
  )
4201
4598
  );
@@ -4211,7 +4608,7 @@ async function prepareResponsesTools({
4211
4608
  toolNameMapping,
4212
4609
  customProviderToolNames
4213
4610
  }) {
4214
- var _a;
4611
+ var _a, _b;
4215
4612
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
4216
4613
  const toolWarnings = [];
4217
4614
  if (tools == null) {
@@ -4221,15 +4618,19 @@ async function prepareResponsesTools({
4221
4618
  const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
4222
4619
  for (const tool of tools) {
4223
4620
  switch (tool.type) {
4224
- case "function":
4621
+ case "function": {
4622
+ const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
4623
+ const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
4225
4624
  openaiTools2.push({
4226
4625
  type: "function",
4227
4626
  name: tool.name,
4228
4627
  description: tool.description,
4229
4628
  parameters: tool.inputSchema,
4230
- ...tool.strict != null ? { strict: tool.strict } : {}
4629
+ ...tool.strict != null ? { strict: tool.strict } : {},
4630
+ ...deferLoading != null ? { defer_loading: deferLoading } : {}
4231
4631
  });
4232
4632
  break;
4633
+ }
4233
4634
  case "provider": {
4234
4635
  switch (tool.id) {
4235
4636
  case "openai.file_search": {
@@ -4367,11 +4768,24 @@ async function prepareResponsesTools({
4367
4768
  });
4368
4769
  openaiTools2.push({
4369
4770
  type: "custom",
4370
- name: args.name,
4771
+ name: tool.name,
4371
4772
  description: args.description,
4372
4773
  format: args.format
4373
4774
  });
4374
- resolvedCustomProviderToolNames.add(args.name);
4775
+ resolvedCustomProviderToolNames.add(tool.name);
4776
+ break;
4777
+ }
4778
+ case "openai.tool_search": {
4779
+ const args = await validateTypes2({
4780
+ value: tool.args,
4781
+ schema: toolSearchArgsSchema
4782
+ });
4783
+ openaiTools2.push({
4784
+ type: "tool_search",
4785
+ ...args.execution != null ? { execution: args.execution } : {},
4786
+ ...args.description != null ? { description: args.description } : {},
4787
+ ...args.parameters != null ? { parameters: args.parameters } : {}
4788
+ });
4375
4789
  break;
4376
4790
  }
4377
4791
  }
@@ -4395,7 +4809,7 @@ async function prepareResponsesTools({
4395
4809
  case "required":
4396
4810
  return { tools: openaiTools2, toolChoice: type, toolWarnings };
4397
4811
  case "tool": {
4398
- const resolvedToolName = (_a = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _a : toolChoice.toolName;
4812
+ const resolvedToolName = (_b = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _b : toolChoice.toolName;
4399
4813
  return {
4400
4814
  tools: openaiTools2,
4401
4815
  toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
@@ -4475,7 +4889,7 @@ function extractApprovalRequestIdToToolCallIdMapping(prompt) {
4475
4889
  }
4476
4890
  var OpenAIResponsesLanguageModel = class {
4477
4891
  constructor(modelId, config) {
4478
- this.specificationVersion = "v3";
4892
+ this.specificationVersion = "v4";
4479
4893
  this.supportedUrls = {
4480
4894
  "image/*": [/^https?:\/\/.*$/],
4481
4895
  "application/pdf": [/^https?:\/\/.*$/]
@@ -4496,12 +4910,13 @@ var OpenAIResponsesLanguageModel = class {
4496
4910
  frequencyPenalty,
4497
4911
  seed,
4498
4912
  prompt,
4913
+ reasoning,
4499
4914
  providerOptions,
4500
4915
  tools,
4501
4916
  toolChoice,
4502
4917
  responseFormat
4503
4918
  }) {
4504
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4919
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4505
4920
  const warnings = [];
4506
4921
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4507
4922
  if (topK != null) {
@@ -4520,19 +4935,20 @@ var OpenAIResponsesLanguageModel = class {
4520
4935
  warnings.push({ type: "unsupported", feature: "stopSequences" });
4521
4936
  }
4522
4937
  const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
4523
- let openaiOptions = await parseProviderOptions5({
4938
+ let openaiOptions = await parseProviderOptions6({
4524
4939
  provider: providerOptionsName,
4525
4940
  providerOptions,
4526
4941
  schema: openaiLanguageModelResponsesOptionsSchema
4527
4942
  });
4528
4943
  if (openaiOptions == null && providerOptionsName !== "openai") {
4529
- openaiOptions = await parseProviderOptions5({
4944
+ openaiOptions = await parseProviderOptions6({
4530
4945
  provider: "openai",
4531
4946
  providerOptions,
4532
4947
  schema: openaiLanguageModelResponsesOptionsSchema
4533
4948
  });
4534
4949
  }
4535
- const isReasoningModel = (_a = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a : modelCapabilities.isReasoningModel;
4950
+ const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : isCustomReasoning2(reasoning) ? reasoning : void 0;
4951
+ const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
4536
4952
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
4537
4953
  warnings.push({
4538
4954
  type: "unsupported",
@@ -4551,9 +4967,9 @@ var OpenAIResponsesLanguageModel = class {
4551
4967
  "openai.web_search": "web_search",
4552
4968
  "openai.web_search_preview": "web_search_preview",
4553
4969
  "openai.mcp": "mcp",
4554
- "openai.apply_patch": "apply_patch"
4555
- },
4556
- resolveProviderToolName: (tool) => tool.id === "openai.custom" ? tool.args.name : void 0
4970
+ "openai.apply_patch": "apply_patch",
4971
+ "openai.tool_search": "tool_search"
4972
+ }
4557
4973
  });
4558
4974
  const customProviderToolNames = /* @__PURE__ */ new Set();
4559
4975
  const {
@@ -4569,10 +4985,10 @@ var OpenAIResponsesLanguageModel = class {
4569
4985
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
4570
4986
  prompt,
4571
4987
  toolNameMapping,
4572
- systemMessageMode: (_b = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4988
+ systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4573
4989
  providerOptionsName,
4574
4990
  fileIdPrefixes: this.config.fileIdPrefixes,
4575
- store: (_c = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c : true,
4991
+ store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
4576
4992
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
4577
4993
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4578
4994
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -4580,7 +4996,7 @@ var OpenAIResponsesLanguageModel = class {
4580
4996
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
4581
4997
  });
4582
4998
  warnings.push(...inputWarnings);
4583
- const strictJsonSchema = (_d = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _d : true;
4999
+ const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4584
5000
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4585
5001
  function addInclude(key) {
4586
5002
  if (include == null) {
@@ -4596,9 +5012,9 @@ var OpenAIResponsesLanguageModel = class {
4596
5012
  if (topLogprobs) {
4597
5013
  addInclude("message.output_text.logprobs");
4598
5014
  }
4599
- const webSearchToolName = (_e = tools == null ? void 0 : tools.find(
5015
+ const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4600
5016
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4601
- )) == null ? void 0 : _e.name;
5017
+ )) == null ? void 0 : _f.name;
4602
5018
  if (webSearchToolName) {
4603
5019
  addInclude("web_search_call.action.sources");
4604
5020
  }
@@ -4621,7 +5037,7 @@ var OpenAIResponsesLanguageModel = class {
4621
5037
  format: responseFormat.schema != null ? {
4622
5038
  type: "json_schema",
4623
5039
  strict: strictJsonSchema,
4624
- name: (_f = responseFormat.name) != null ? _f : "response",
5040
+ name: (_g = responseFormat.name) != null ? _g : "response",
4625
5041
  description: responseFormat.description,
4626
5042
  schema: responseFormat.schema
4627
5043
  } : { type: "json_object" }
@@ -4647,11 +5063,18 @@ var OpenAIResponsesLanguageModel = class {
4647
5063
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
4648
5064
  top_logprobs: topLogprobs,
4649
5065
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
5066
+ // context management (server-side compaction):
5067
+ ...(openaiOptions == null ? void 0 : openaiOptions.contextManagement) && {
5068
+ context_management: openaiOptions.contextManagement.map((cm) => ({
5069
+ type: cm.type,
5070
+ compact_threshold: cm.compactThreshold
5071
+ }))
5072
+ },
4650
5073
  // model-specific settings:
4651
- ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
5074
+ ...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4652
5075
  reasoning: {
4653
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
4654
- effort: openaiOptions.reasoningEffort
5076
+ ...resolvedReasoningEffort != null && {
5077
+ effort: resolvedReasoningEffort
4655
5078
  },
4656
5079
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
4657
5080
  summary: openaiOptions.reasoningSummary
@@ -4660,7 +5083,7 @@ var OpenAIResponsesLanguageModel = class {
4660
5083
  }
4661
5084
  };
4662
5085
  if (isReasoningModel) {
4663
- if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
5086
+ if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
4664
5087
  if (baseArgs.temperature != null) {
4665
5088
  baseArgs.temperature = void 0;
4666
5089
  warnings.push({
@@ -4710,9 +5133,9 @@ var OpenAIResponsesLanguageModel = class {
4710
5133
  });
4711
5134
  delete baseArgs.service_tier;
4712
5135
  }
4713
- const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
5136
+ const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
4714
5137
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
4715
- )) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
5138
+ )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
4716
5139
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
4717
5140
  return {
4718
5141
  webSearchToolName,
@@ -4729,7 +5152,7 @@ var OpenAIResponsesLanguageModel = class {
4729
5152
  };
4730
5153
  }
4731
5154
  async doGenerate(options) {
4732
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
5155
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
4733
5156
  const {
4734
5157
  args: body,
4735
5158
  warnings,
@@ -4749,10 +5172,10 @@ var OpenAIResponsesLanguageModel = class {
4749
5172
  rawValue: rawResponse
4750
5173
  } = await postJsonToApi5({
4751
5174
  url,
4752
- headers: combineHeaders5(this.config.headers(), options.headers),
5175
+ headers: combineHeaders6(this.config.headers(), options.headers),
4753
5176
  body,
4754
5177
  failedResponseHandler: openaiFailedResponseHandler,
4755
- successfulResponseHandler: createJsonResponseHandler5(
5178
+ successfulResponseHandler: createJsonResponseHandler6(
4756
5179
  openaiResponsesResponseSchema
4757
5180
  ),
4758
5181
  abortSignal: options.abortSignal,
@@ -4772,6 +5195,7 @@ var OpenAIResponsesLanguageModel = class {
4772
5195
  const content = [];
4773
5196
  const logprobs = [];
4774
5197
  let hasFunctionCall = false;
5198
+ const hostedToolSearchCallIds = [];
4775
5199
  for (const part of response.output) {
4776
5200
  switch (part.type) {
4777
5201
  case "reasoning": {
@@ -4810,6 +5234,46 @@ var OpenAIResponsesLanguageModel = class {
4810
5234
  });
4811
5235
  break;
4812
5236
  }
5237
+ case "tool_search_call": {
5238
+ const toolCallId = (_b = part.call_id) != null ? _b : part.id;
5239
+ const isHosted = part.execution === "server";
5240
+ if (isHosted) {
5241
+ hostedToolSearchCallIds.push(toolCallId);
5242
+ }
5243
+ content.push({
5244
+ type: "tool-call",
5245
+ toolCallId,
5246
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
5247
+ input: JSON.stringify({
5248
+ arguments: part.arguments,
5249
+ call_id: part.call_id
5250
+ }),
5251
+ ...isHosted ? { providerExecuted: true } : {},
5252
+ providerMetadata: {
5253
+ [providerOptionsName]: {
5254
+ itemId: part.id
5255
+ }
5256
+ }
5257
+ });
5258
+ break;
5259
+ }
5260
+ case "tool_search_output": {
5261
+ const toolCallId = (_d = (_c = part.call_id) != null ? _c : hostedToolSearchCallIds.shift()) != null ? _d : part.id;
5262
+ content.push({
5263
+ type: "tool-result",
5264
+ toolCallId,
5265
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
5266
+ result: {
5267
+ tools: part.tools
5268
+ },
5269
+ providerMetadata: {
5270
+ [providerOptionsName]: {
5271
+ itemId: part.id
5272
+ }
5273
+ }
5274
+ });
5275
+ break;
5276
+ }
4813
5277
  case "local_shell_call": {
4814
5278
  content.push({
4815
5279
  type: "tool-call",
@@ -4865,7 +5329,7 @@ var OpenAIResponsesLanguageModel = class {
4865
5329
  }
4866
5330
  case "message": {
4867
5331
  for (const contentPart of part.content) {
4868
- if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
5332
+ if (((_f = (_e = options.providerOptions) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.logprobs) && contentPart.logprobs) {
4869
5333
  logprobs.push(contentPart.logprobs);
4870
5334
  }
4871
5335
  const providerMetadata2 = {
@@ -4887,7 +5351,7 @@ var OpenAIResponsesLanguageModel = class {
4887
5351
  content.push({
4888
5352
  type: "source",
4889
5353
  sourceType: "url",
4890
- id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : generateId2(),
5354
+ id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
4891
5355
  url: annotation.url,
4892
5356
  title: annotation.title
4893
5357
  });
@@ -4895,7 +5359,7 @@ var OpenAIResponsesLanguageModel = class {
4895
5359
  content.push({
4896
5360
  type: "source",
4897
5361
  sourceType: "document",
4898
- id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
5362
+ id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
4899
5363
  mediaType: "text/plain",
4900
5364
  title: annotation.filename,
4901
5365
  filename: annotation.filename,
@@ -4911,7 +5375,7 @@ var OpenAIResponsesLanguageModel = class {
4911
5375
  content.push({
4912
5376
  type: "source",
4913
5377
  sourceType: "document",
4914
- id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
5378
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
4915
5379
  mediaType: "text/plain",
4916
5380
  title: annotation.filename,
4917
5381
  filename: annotation.filename,
@@ -4927,7 +5391,7 @@ var OpenAIResponsesLanguageModel = class {
4927
5391
  content.push({
4928
5392
  type: "source",
4929
5393
  sourceType: "document",
4930
- id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
5394
+ id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
4931
5395
  mediaType: "application/octet-stream",
4932
5396
  title: annotation.file_id,
4933
5397
  filename: annotation.file_id,
@@ -4996,7 +5460,7 @@ var OpenAIResponsesLanguageModel = class {
4996
5460
  break;
4997
5461
  }
4998
5462
  case "mcp_call": {
4999
- const toolCallId = part.approval_request_id != null ? (_p = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _p : part.id : part.id;
5463
+ const toolCallId = part.approval_request_id != null ? (_s = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _s : part.id : part.id;
5000
5464
  const toolName = `mcp.${part.name}`;
5001
5465
  content.push({
5002
5466
  type: "tool-call",
@@ -5030,8 +5494,8 @@ var OpenAIResponsesLanguageModel = class {
5030
5494
  break;
5031
5495
  }
5032
5496
  case "mcp_approval_request": {
5033
- const approvalRequestId = (_q = part.approval_request_id) != null ? _q : part.id;
5034
- const dummyToolCallId = (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : generateId2();
5497
+ const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
5498
+ const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2();
5035
5499
  const toolName = `mcp.${part.name}`;
5036
5500
  content.push({
5037
5501
  type: "tool-call",
@@ -5081,13 +5545,13 @@ var OpenAIResponsesLanguageModel = class {
5081
5545
  toolName: toolNameMapping.toCustomToolName("file_search"),
5082
5546
  result: {
5083
5547
  queries: part.queries,
5084
- results: (_v = (_u = part.results) == null ? void 0 : _u.map((result) => ({
5548
+ results: (_y = (_x = part.results) == null ? void 0 : _x.map((result) => ({
5085
5549
  attributes: result.attributes,
5086
5550
  fileId: result.file_id,
5087
5551
  filename: result.filename,
5088
5552
  score: result.score,
5089
5553
  text: result.text
5090
- }))) != null ? _v : null
5554
+ }))) != null ? _y : null
5091
5555
  }
5092
5556
  });
5093
5557
  break;
@@ -5130,6 +5594,20 @@ var OpenAIResponsesLanguageModel = class {
5130
5594
  });
5131
5595
  break;
5132
5596
  }
5597
+ case "compaction": {
5598
+ content.push({
5599
+ type: "custom",
5600
+ kind: "openai.compaction",
5601
+ providerMetadata: {
5602
+ [providerOptionsName]: {
5603
+ type: "compaction",
5604
+ itemId: part.id,
5605
+ encryptedContent: part.encrypted_content
5606
+ }
5607
+ }
5608
+ });
5609
+ break;
5610
+ }
5133
5611
  }
5134
5612
  }
5135
5613
  const providerMetadata = {
@@ -5144,10 +5622,10 @@ var OpenAIResponsesLanguageModel = class {
5144
5622
  content,
5145
5623
  finishReason: {
5146
5624
  unified: mapOpenAIResponseFinishReason({
5147
- finishReason: (_w = response.incomplete_details) == null ? void 0 : _w.reason,
5625
+ finishReason: (_z = response.incomplete_details) == null ? void 0 : _z.reason,
5148
5626
  hasFunctionCall
5149
5627
  }),
5150
- raw: (_y = (_x = response.incomplete_details) == null ? void 0 : _x.reason) != null ? _y : void 0
5628
+ raw: (_B = (_A = response.incomplete_details) == null ? void 0 : _A.reason) != null ? _B : void 0
5151
5629
  },
5152
5630
  usage: convertOpenAIResponsesUsage(usage),
5153
5631
  request: { body },
@@ -5177,7 +5655,7 @@ var OpenAIResponsesLanguageModel = class {
5177
5655
  path: "/responses",
5178
5656
  modelId: this.modelId
5179
5657
  }),
5180
- headers: combineHeaders5(this.config.headers(), options.headers),
5658
+ headers: combineHeaders6(this.config.headers(), options.headers),
5181
5659
  body: {
5182
5660
  ...body,
5183
5661
  stream: true
@@ -5205,6 +5683,7 @@ var OpenAIResponsesLanguageModel = class {
5205
5683
  let hasFunctionCall = false;
5206
5684
  const activeReasoning = {};
5207
5685
  let serviceTier;
5686
+ const hostedToolSearchCallIds = [];
5208
5687
  return {
5209
5688
  stream: response.pipeThrough(
5210
5689
  new TransformStream({
@@ -5212,7 +5691,7 @@ var OpenAIResponsesLanguageModel = class {
5212
5691
  controller.enqueue({ type: "stream-start", warnings });
5213
5692
  },
5214
5693
  transform(chunk, controller) {
5215
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
5694
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
5216
5695
  if (options.includeRawChunks) {
5217
5696
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5218
5697
  }
@@ -5320,6 +5799,24 @@ var OpenAIResponsesLanguageModel = class {
5320
5799
  input: "{}",
5321
5800
  providerExecuted: true
5322
5801
  });
5802
+ } else if (value.item.type === "tool_search_call") {
5803
+ const toolCallId = value.item.id;
5804
+ const toolName = toolNameMapping.toCustomToolName("tool_search");
5805
+ const isHosted = value.item.execution === "server";
5806
+ ongoingToolCalls[value.output_index] = {
5807
+ toolName,
5808
+ toolCallId,
5809
+ toolSearchExecution: (_a = value.item.execution) != null ? _a : "server"
5810
+ };
5811
+ if (isHosted) {
5812
+ controller.enqueue({
5813
+ type: "tool-input-start",
5814
+ id: toolCallId,
5815
+ toolName,
5816
+ providerExecuted: true
5817
+ });
5818
+ }
5819
+ } else if (value.item.type === "tool_search_output") {
5323
5820
  } else if (value.item.type === "mcp_call" || value.item.type === "mcp_list_tools" || value.item.type === "mcp_approval_request") {
5324
5821
  } else if (value.item.type === "apply_patch_call") {
5325
5822
  const { call_id: callId, operation } = value.item;
@@ -5366,7 +5863,7 @@ var OpenAIResponsesLanguageModel = class {
5366
5863
  } else if (value.item.type === "shell_call_output") {
5367
5864
  } else if (value.item.type === "message") {
5368
5865
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
5369
- activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
5866
+ activeMessagePhase = (_b = value.item.phase) != null ? _b : void 0;
5370
5867
  controller.enqueue({
5371
5868
  type: "text-start",
5372
5869
  id: value.item.id,
@@ -5390,14 +5887,14 @@ var OpenAIResponsesLanguageModel = class {
5390
5887
  providerMetadata: {
5391
5888
  [providerOptionsName]: {
5392
5889
  itemId: value.item.id,
5393
- reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
5890
+ reasoningEncryptedContent: (_c = value.item.encrypted_content) != null ? _c : null
5394
5891
  }
5395
5892
  }
5396
5893
  });
5397
5894
  }
5398
5895
  } else if (isResponseOutputItemDoneChunk(value)) {
5399
5896
  if (value.item.type === "message") {
5400
- const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
5897
+ const phase = (_d = value.item.phase) != null ? _d : activeMessagePhase;
5401
5898
  activeMessagePhase = void 0;
5402
5899
  controller.enqueue({
5403
5900
  type: "text-end",
@@ -5491,13 +5988,13 @@ var OpenAIResponsesLanguageModel = class {
5491
5988
  toolName: toolNameMapping.toCustomToolName("file_search"),
5492
5989
  result: {
5493
5990
  queries: value.item.queries,
5494
- results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
5991
+ results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result) => ({
5495
5992
  attributes: result.attributes,
5496
5993
  fileId: result.file_id,
5497
5994
  filename: result.filename,
5498
5995
  score: result.score,
5499
5996
  text: result.text
5500
- }))) != null ? _e : null
5997
+ }))) != null ? _f : null
5501
5998
  }
5502
5999
  });
5503
6000
  } else if (value.item.type === "code_interpreter_call") {
@@ -5519,12 +6016,62 @@ var OpenAIResponsesLanguageModel = class {
5519
6016
  result: value.item.result
5520
6017
  }
5521
6018
  });
6019
+ } else if (value.item.type === "tool_search_call") {
6020
+ const toolCall = ongoingToolCalls[value.output_index];
6021
+ const isHosted = value.item.execution === "server";
6022
+ if (toolCall != null) {
6023
+ const toolCallId = isHosted ? toolCall.toolCallId : (_g = value.item.call_id) != null ? _g : value.item.id;
6024
+ if (isHosted) {
6025
+ hostedToolSearchCallIds.push(toolCallId);
6026
+ } else {
6027
+ controller.enqueue({
6028
+ type: "tool-input-start",
6029
+ id: toolCallId,
6030
+ toolName: toolCall.toolName
6031
+ });
6032
+ }
6033
+ controller.enqueue({
6034
+ type: "tool-input-end",
6035
+ id: toolCallId
6036
+ });
6037
+ controller.enqueue({
6038
+ type: "tool-call",
6039
+ toolCallId,
6040
+ toolName: toolCall.toolName,
6041
+ input: JSON.stringify({
6042
+ arguments: value.item.arguments,
6043
+ call_id: isHosted ? null : toolCallId
6044
+ }),
6045
+ ...isHosted ? { providerExecuted: true } : {},
6046
+ providerMetadata: {
6047
+ [providerOptionsName]: {
6048
+ itemId: value.item.id
6049
+ }
6050
+ }
6051
+ });
6052
+ }
6053
+ ongoingToolCalls[value.output_index] = void 0;
6054
+ } else if (value.item.type === "tool_search_output") {
6055
+ const toolCallId = (_i = (_h = value.item.call_id) != null ? _h : hostedToolSearchCallIds.shift()) != null ? _i : value.item.id;
6056
+ controller.enqueue({
6057
+ type: "tool-result",
6058
+ toolCallId,
6059
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
6060
+ result: {
6061
+ tools: value.item.tools
6062
+ },
6063
+ providerMetadata: {
6064
+ [providerOptionsName]: {
6065
+ itemId: value.item.id
6066
+ }
6067
+ }
6068
+ });
5522
6069
  } else if (value.item.type === "mcp_call") {
5523
6070
  ongoingToolCalls[value.output_index] = void 0;
5524
- const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
5525
- const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
6071
+ const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : void 0;
6072
+ const aliasedToolCallId = approvalRequestId != null ? (_l = (_k = approvalRequestIdToDummyToolCallIdFromStream.get(
5526
6073
  approvalRequestId
5527
- )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
6074
+ )) != null ? _k : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _l : value.item.id : value.item.id;
5528
6075
  const toolName = `mcp.${value.item.name}`;
5529
6076
  controller.enqueue({
5530
6077
  type: "tool-call",
@@ -5594,8 +6141,8 @@ var OpenAIResponsesLanguageModel = class {
5594
6141
  ongoingToolCalls[value.output_index] = void 0;
5595
6142
  } else if (value.item.type === "mcp_approval_request") {
5596
6143
  ongoingToolCalls[value.output_index] = void 0;
5597
- const dummyToolCallId = (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId2();
5598
- const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
6144
+ const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2();
6145
+ const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
5599
6146
  approvalRequestIdToDummyToolCallIdFromStream.set(
5600
6147
  approvalRequestId,
5601
6148
  dummyToolCallId
@@ -5684,12 +6231,24 @@ var OpenAIResponsesLanguageModel = class {
5684
6231
  providerMetadata: {
5685
6232
  [providerOptionsName]: {
5686
6233
  itemId: value.item.id,
5687
- reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
6234
+ reasoningEncryptedContent: (_q = value.item.encrypted_content) != null ? _q : null
5688
6235
  }
5689
6236
  }
5690
6237
  });
5691
6238
  }
5692
6239
  delete activeReasoning[value.item.id];
6240
+ } else if (value.item.type === "compaction") {
6241
+ controller.enqueue({
6242
+ type: "custom",
6243
+ kind: "openai.compaction",
6244
+ providerMetadata: {
6245
+ [providerOptionsName]: {
6246
+ type: "compaction",
6247
+ itemId: value.item.id,
6248
+ encryptedContent: value.item.encrypted_content
6249
+ }
6250
+ }
6251
+ });
5693
6252
  }
5694
6253
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
5695
6254
  const toolCall = ongoingToolCalls[value.output_index];
@@ -5797,7 +6356,7 @@ var OpenAIResponsesLanguageModel = class {
5797
6356
  id: value.item_id,
5798
6357
  delta: value.delta
5799
6358
  });
5800
- if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
6359
+ if (((_s = (_r = options.providerOptions) == null ? void 0 : _r[providerOptionsName]) == null ? void 0 : _s.logprobs) && value.logprobs) {
5801
6360
  logprobs.push(value.logprobs);
5802
6361
  }
5803
6362
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -5826,7 +6385,7 @@ var OpenAIResponsesLanguageModel = class {
5826
6385
  providerMetadata: {
5827
6386
  [providerOptionsName]: {
5828
6387
  itemId: value.item_id,
5829
- reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
6388
+ reasoningEncryptedContent: (_u = (_t = activeReasoning[value.item_id]) == null ? void 0 : _t.encryptedContent) != null ? _u : null
5830
6389
  }
5831
6390
  }
5832
6391
  });
@@ -5860,22 +6419,32 @@ var OpenAIResponsesLanguageModel = class {
5860
6419
  } else if (isResponseFinishedChunk(value)) {
5861
6420
  finishReason = {
5862
6421
  unified: mapOpenAIResponseFinishReason({
5863
- finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
6422
+ finishReason: (_v = value.response.incomplete_details) == null ? void 0 : _v.reason,
5864
6423
  hasFunctionCall
5865
6424
  }),
5866
- raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
6425
+ raw: (_x = (_w = value.response.incomplete_details) == null ? void 0 : _w.reason) != null ? _x : void 0
5867
6426
  };
5868
6427
  usage = value.response.usage;
5869
6428
  if (typeof value.response.service_tier === "string") {
5870
6429
  serviceTier = value.response.service_tier;
5871
6430
  }
6431
+ } else if (isResponseFailedChunk(value)) {
6432
+ const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
6433
+ finishReason = {
6434
+ unified: incompleteReason ? mapOpenAIResponseFinishReason({
6435
+ finishReason: incompleteReason,
6436
+ hasFunctionCall
6437
+ }) : "error",
6438
+ raw: incompleteReason != null ? incompleteReason : "error"
6439
+ };
6440
+ usage = (_z = value.response.usage) != null ? _z : void 0;
5872
6441
  } else if (isResponseAnnotationAddedChunk(value)) {
5873
6442
  ongoingAnnotations.push(value.annotation);
5874
6443
  if (value.annotation.type === "url_citation") {
5875
6444
  controller.enqueue({
5876
6445
  type: "source",
5877
6446
  sourceType: "url",
5878
- id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2(),
6447
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
5879
6448
  url: value.annotation.url,
5880
6449
  title: value.annotation.title
5881
6450
  });
@@ -5883,7 +6452,7 @@ var OpenAIResponsesLanguageModel = class {
5883
6452
  controller.enqueue({
5884
6453
  type: "source",
5885
6454
  sourceType: "document",
5886
- id: (_z = (_y = (_x = self.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId2(),
6455
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
5887
6456
  mediaType: "text/plain",
5888
6457
  title: value.annotation.filename,
5889
6458
  filename: value.annotation.filename,
@@ -5899,7 +6468,7 @@ var OpenAIResponsesLanguageModel = class {
5899
6468
  controller.enqueue({
5900
6469
  type: "source",
5901
6470
  sourceType: "document",
5902
- id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
6471
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
5903
6472
  mediaType: "text/plain",
5904
6473
  title: value.annotation.filename,
5905
6474
  filename: value.annotation.filename,
@@ -5915,7 +6484,7 @@ var OpenAIResponsesLanguageModel = class {
5915
6484
  controller.enqueue({
5916
6485
  type: "source",
5917
6486
  sourceType: "document",
5918
- id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
6487
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
5919
6488
  mediaType: "application/octet-stream",
5920
6489
  title: value.annotation.file_id,
5921
6490
  filename: value.annotation.file_id,
@@ -5963,6 +6532,9 @@ function isResponseOutputItemDoneChunk(chunk) {
5963
6532
  function isResponseFinishedChunk(chunk) {
5964
6533
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
5965
6534
  }
6535
+ function isResponseFailedChunk(chunk) {
6536
+ return chunk.type === "response.failed";
6537
+ }
5966
6538
  function isResponseCreatedChunk(chunk) {
5967
6539
  return chunk.type === "response.created";
5968
6540
  }
@@ -6026,20 +6598,20 @@ function escapeJSONDelta(delta) {
6026
6598
 
6027
6599
  // src/speech/openai-speech-model.ts
6028
6600
  import {
6029
- combineHeaders as combineHeaders6,
6601
+ combineHeaders as combineHeaders7,
6030
6602
  createBinaryResponseHandler,
6031
- parseProviderOptions as parseProviderOptions6,
6603
+ parseProviderOptions as parseProviderOptions7,
6032
6604
  postJsonToApi as postJsonToApi6
6033
6605
  } from "@ai-sdk/provider-utils";
6034
6606
 
6035
6607
  // src/speech/openai-speech-options.ts
6036
- import { lazySchema as lazySchema20, zodSchema as zodSchema20 } from "@ai-sdk/provider-utils";
6037
- import { z as z22 } from "zod/v4";
6038
- var openaiSpeechModelOptionsSchema = lazySchema20(
6039
- () => zodSchema20(
6040
- z22.object({
6041
- instructions: z22.string().nullish(),
6042
- speed: z22.number().min(0.25).max(4).default(1).nullish()
6608
+ import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
6609
+ import { z as z25 } from "zod/v4";
6610
+ var openaiSpeechModelOptionsSchema = lazySchema23(
6611
+ () => zodSchema23(
6612
+ z25.object({
6613
+ instructions: z25.string().nullish(),
6614
+ speed: z25.number().min(0.25).max(4).default(1).nullish()
6043
6615
  })
6044
6616
  )
6045
6617
  );
@@ -6049,7 +6621,7 @@ var OpenAISpeechModel = class {
6049
6621
  constructor(modelId, config) {
6050
6622
  this.modelId = modelId;
6051
6623
  this.config = config;
6052
- this.specificationVersion = "v3";
6624
+ this.specificationVersion = "v4";
6053
6625
  }
6054
6626
  get provider() {
6055
6627
  return this.config.provider;
@@ -6064,7 +6636,7 @@ var OpenAISpeechModel = class {
6064
6636
  providerOptions
6065
6637
  }) {
6066
6638
  const warnings = [];
6067
- const openAIOptions = await parseProviderOptions6({
6639
+ const openAIOptions = await parseProviderOptions7({
6068
6640
  provider: "openai",
6069
6641
  providerOptions,
6070
6642
  schema: openaiSpeechModelOptionsSchema
@@ -6122,7 +6694,7 @@ var OpenAISpeechModel = class {
6122
6694
  path: "/audio/speech",
6123
6695
  modelId: this.modelId
6124
6696
  }),
6125
- headers: combineHeaders6(this.config.headers(), options.headers),
6697
+ headers: combineHeaders7(this.config.headers(), options.headers),
6126
6698
  body: requestBody,
6127
6699
  failedResponseHandler: openaiFailedResponseHandler,
6128
6700
  successfulResponseHandler: createBinaryResponseHandler(),
@@ -6147,42 +6719,42 @@ var OpenAISpeechModel = class {
6147
6719
 
6148
6720
  // src/transcription/openai-transcription-model.ts
6149
6721
  import {
6150
- combineHeaders as combineHeaders7,
6151
- convertBase64ToUint8Array as convertBase64ToUint8Array2,
6152
- createJsonResponseHandler as createJsonResponseHandler6,
6722
+ combineHeaders as combineHeaders8,
6723
+ convertBase64ToUint8Array as convertBase64ToUint8Array3,
6724
+ createJsonResponseHandler as createJsonResponseHandler7,
6153
6725
  mediaTypeToExtension,
6154
- parseProviderOptions as parseProviderOptions7,
6155
- postFormDataToApi as postFormDataToApi2
6726
+ parseProviderOptions as parseProviderOptions8,
6727
+ postFormDataToApi as postFormDataToApi3
6156
6728
  } from "@ai-sdk/provider-utils";
6157
6729
 
6158
6730
  // src/transcription/openai-transcription-api.ts
6159
- import { lazySchema as lazySchema21, zodSchema as zodSchema21 } from "@ai-sdk/provider-utils";
6160
- import { z as z23 } from "zod/v4";
6161
- var openaiTranscriptionResponseSchema = lazySchema21(
6162
- () => zodSchema21(
6163
- z23.object({
6164
- text: z23.string(),
6165
- language: z23.string().nullish(),
6166
- duration: z23.number().nullish(),
6167
- words: z23.array(
6168
- z23.object({
6169
- word: z23.string(),
6170
- start: z23.number(),
6171
- end: z23.number()
6731
+ import { lazySchema as lazySchema24, zodSchema as zodSchema24 } from "@ai-sdk/provider-utils";
6732
+ import { z as z26 } from "zod/v4";
6733
+ var openaiTranscriptionResponseSchema = lazySchema24(
6734
+ () => zodSchema24(
6735
+ z26.object({
6736
+ text: z26.string(),
6737
+ language: z26.string().nullish(),
6738
+ duration: z26.number().nullish(),
6739
+ words: z26.array(
6740
+ z26.object({
6741
+ word: z26.string(),
6742
+ start: z26.number(),
6743
+ end: z26.number()
6172
6744
  })
6173
6745
  ).nullish(),
6174
- segments: z23.array(
6175
- z23.object({
6176
- id: z23.number(),
6177
- seek: z23.number(),
6178
- start: z23.number(),
6179
- end: z23.number(),
6180
- text: z23.string(),
6181
- tokens: z23.array(z23.number()),
6182
- temperature: z23.number(),
6183
- avg_logprob: z23.number(),
6184
- compression_ratio: z23.number(),
6185
- no_speech_prob: z23.number()
6746
+ segments: z26.array(
6747
+ z26.object({
6748
+ id: z26.number(),
6749
+ seek: z26.number(),
6750
+ start: z26.number(),
6751
+ end: z26.number(),
6752
+ text: z26.string(),
6753
+ tokens: z26.array(z26.number()),
6754
+ temperature: z26.number(),
6755
+ avg_logprob: z26.number(),
6756
+ compression_ratio: z26.number(),
6757
+ no_speech_prob: z26.number()
6186
6758
  })
6187
6759
  ).nullish()
6188
6760
  })
@@ -6190,33 +6762,33 @@ var openaiTranscriptionResponseSchema = lazySchema21(
6190
6762
  );
6191
6763
 
6192
6764
  // src/transcription/openai-transcription-options.ts
6193
- import { lazySchema as lazySchema22, zodSchema as zodSchema22 } from "@ai-sdk/provider-utils";
6194
- import { z as z24 } from "zod/v4";
6195
- var openAITranscriptionModelOptions = lazySchema22(
6196
- () => zodSchema22(
6197
- z24.object({
6765
+ import { lazySchema as lazySchema25, zodSchema as zodSchema25 } from "@ai-sdk/provider-utils";
6766
+ import { z as z27 } from "zod/v4";
6767
+ var openAITranscriptionModelOptions = lazySchema25(
6768
+ () => zodSchema25(
6769
+ z27.object({
6198
6770
  /**
6199
6771
  * Additional information to include in the transcription response.
6200
6772
  */
6201
- include: z24.array(z24.string()).optional(),
6773
+ include: z27.array(z27.string()).optional(),
6202
6774
  /**
6203
6775
  * The language of the input audio in ISO-639-1 format.
6204
6776
  */
6205
- language: z24.string().optional(),
6777
+ language: z27.string().optional(),
6206
6778
  /**
6207
6779
  * An optional text to guide the model's style or continue a previous audio segment.
6208
6780
  */
6209
- prompt: z24.string().optional(),
6781
+ prompt: z27.string().optional(),
6210
6782
  /**
6211
6783
  * The sampling temperature, between 0 and 1.
6212
6784
  * @default 0
6213
6785
  */
6214
- temperature: z24.number().min(0).max(1).default(0).optional(),
6786
+ temperature: z27.number().min(0).max(1).default(0).optional(),
6215
6787
  /**
6216
6788
  * The timestamp granularities to populate for this transcription.
6217
6789
  * @default ['segment']
6218
6790
  */
6219
- timestampGranularities: z24.array(z24.enum(["word", "segment"])).default(["segment"]).optional()
6791
+ timestampGranularities: z27.array(z27.enum(["word", "segment"])).default(["segment"]).optional()
6220
6792
  })
6221
6793
  )
6222
6794
  );
@@ -6285,7 +6857,7 @@ var OpenAITranscriptionModel = class {
6285
6857
  constructor(modelId, config) {
6286
6858
  this.modelId = modelId;
6287
6859
  this.config = config;
6288
- this.specificationVersion = "v3";
6860
+ this.specificationVersion = "v4";
6289
6861
  }
6290
6862
  get provider() {
6291
6863
  return this.config.provider;
@@ -6296,13 +6868,13 @@ var OpenAITranscriptionModel = class {
6296
6868
  providerOptions
6297
6869
  }) {
6298
6870
  const warnings = [];
6299
- const openAIOptions = await parseProviderOptions7({
6871
+ const openAIOptions = await parseProviderOptions8({
6300
6872
  provider: "openai",
6301
6873
  providerOptions,
6302
6874
  schema: openAITranscriptionModelOptions
6303
6875
  });
6304
6876
  const formData = new FormData();
6305
- const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array2(audio)]);
6877
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array3(audio)]);
6306
6878
  formData.append("model", this.modelId);
6307
6879
  const fileExtension = mediaTypeToExtension(mediaType);
6308
6880
  formData.append(
@@ -6349,15 +6921,15 @@ var OpenAITranscriptionModel = class {
6349
6921
  value: response,
6350
6922
  responseHeaders,
6351
6923
  rawValue: rawResponse
6352
- } = await postFormDataToApi2({
6924
+ } = await postFormDataToApi3({
6353
6925
  url: this.config.url({
6354
6926
  path: "/audio/transcriptions",
6355
6927
  modelId: this.modelId
6356
6928
  }),
6357
- headers: combineHeaders7(this.config.headers(), options.headers),
6929
+ headers: combineHeaders8(this.config.headers(), options.headers),
6358
6930
  formData,
6359
6931
  failedResponseHandler: openaiFailedResponseHandler,
6360
- successfulResponseHandler: createJsonResponseHandler6(
6932
+ successfulResponseHandler: createJsonResponseHandler7(
6361
6933
  openaiTranscriptionResponseSchema
6362
6934
  ),
6363
6935
  abortSignal: options.abortSignal,
@@ -6389,7 +6961,7 @@ var OpenAITranscriptionModel = class {
6389
6961
  };
6390
6962
 
6391
6963
  // src/version.ts
6392
- var VERSION = true ? "4.0.0-beta.2" : "0.0.0-test";
6964
+ var VERSION = true ? "4.0.0-beta.21" : "0.0.0-test";
6393
6965
 
6394
6966
  // src/openai-provider.ts
6395
6967
  function createOpenAI(options = {}) {
@@ -6450,6 +7022,12 @@ function createOpenAI(options = {}) {
6450
7022
  headers: getHeaders,
6451
7023
  fetch: options.fetch
6452
7024
  });
7025
+ const createFiles = () => new OpenAIFiles({
7026
+ provider: `${providerName}.files`,
7027
+ baseURL,
7028
+ headers: getHeaders,
7029
+ fetch: options.fetch
7030
+ });
6453
7031
  const createLanguageModel = (modelId) => {
6454
7032
  if (new.target) {
6455
7033
  throw new Error(
@@ -6464,13 +7042,14 @@ function createOpenAI(options = {}) {
6464
7042
  url: ({ path }) => `${baseURL}${path}`,
6465
7043
  headers: getHeaders,
6466
7044
  fetch: options.fetch,
7045
+ // Soft-deprecated. TODO: remove in v8
6467
7046
  fileIdPrefixes: ["file-"]
6468
7047
  });
6469
7048
  };
6470
7049
  const provider = function(modelId) {
6471
7050
  return createLanguageModel(modelId);
6472
7051
  };
6473
- provider.specificationVersion = "v3";
7052
+ provider.specificationVersion = "v4";
6474
7053
  provider.languageModel = createLanguageModel;
6475
7054
  provider.chat = createChatModel;
6476
7055
  provider.completion = createCompletionModel;
@@ -6485,6 +7064,7 @@ function createOpenAI(options = {}) {
6485
7064
  provider.transcriptionModel = createTranscriptionModel;
6486
7065
  provider.speech = createSpeechModel;
6487
7066
  provider.speechModel = createSpeechModel;
7067
+ provider.files = createFiles;
6488
7068
  provider.tools = openaiTools;
6489
7069
  return provider;
6490
7070
  }