@ai-sdk/openai 3.0.0-beta.27 → 3.0.0-beta.29

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.0-beta.29
4
+
5
+ ### Patch Changes
6
+
7
+ - 0b9fdd5: fix(provider/openai): end reasoning parts earlier
8
+
9
+ ## 3.0.0-beta.28
10
+
11
+ ### Patch Changes
12
+
13
+ - 401f561: fix(provider/openai): fix web search tool input types
14
+
3
15
  ## 3.0.0-beta.27
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -28,7 +28,44 @@ type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large
28
28
 
29
29
  type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | (string & {});
30
30
 
31
- declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
31
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
32
+ /**
33
+ * An object describing the specific action taken in this web search call.
34
+ * Includes details on how the model used the web (search, open_page, find).
35
+ */
36
+ action: {
37
+ /**
38
+ * Action type "search" - Performs a web search query.
39
+ */
40
+ type: "search";
41
+ /**
42
+ * The search query.
43
+ */
44
+ query?: string;
45
+ } | {
46
+ /**
47
+ * Action type "openPage" - Opens a specific URL from search results.
48
+ */
49
+ type: "openPage";
50
+ /**
51
+ * The URL opened by the model.
52
+ */
53
+ url: string;
54
+ } | {
55
+ /**
56
+ * Action type "find": Searches for a pattern within a loaded page.
57
+ */
58
+ type: "find";
59
+ /**
60
+ * The URL of the page searched for the pattern.
61
+ */
62
+ url: string;
63
+ /**
64
+ * The pattern or text to search for within the page.
65
+ */
66
+ pattern: string;
67
+ };
68
+ }, {
32
69
  /**
33
70
  * Filters for the search.
34
71
  */
@@ -227,7 +264,19 @@ declare const openaiTools: {
227
264
  *
228
265
  * @deprecated Use `webSearch` instead.
229
266
  */
230
- webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
267
+ webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
268
+ action: {
269
+ type: "search";
270
+ query?: string;
271
+ } | {
272
+ type: "openPage";
273
+ url: string;
274
+ } | {
275
+ type: "find";
276
+ url: string;
277
+ pattern: string;
278
+ };
279
+ }, {
231
280
  searchContextSize?: "low" | "medium" | "high";
232
281
  userLocation?: {
233
282
  type: "approximate";
@@ -247,7 +296,19 @@ declare const openaiTools: {
247
296
  * @param searchContextSize - The search context size to use for the web search.
248
297
  * @param userLocation - The user location to use for the web search.
249
298
  */
250
- webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, unknown>;
299
+ webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
300
+ action: {
301
+ type: "search";
302
+ query?: string;
303
+ } | {
304
+ type: "openPage";
305
+ url: string;
306
+ } | {
307
+ type: "find";
308
+ url: string;
309
+ pattern: string;
310
+ };
311
+ }>;
251
312
  };
252
313
 
253
314
  type OpenAIResponsesModelId = 'chatgpt-4o-latest' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4-0613' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | (string & {});
package/dist/index.d.ts CHANGED
@@ -28,7 +28,44 @@ type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large
28
28
 
29
29
  type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | (string & {});
30
30
 
31
- declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
31
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
32
+ /**
33
+ * An object describing the specific action taken in this web search call.
34
+ * Includes details on how the model used the web (search, open_page, find).
35
+ */
36
+ action: {
37
+ /**
38
+ * Action type "search" - Performs a web search query.
39
+ */
40
+ type: "search";
41
+ /**
42
+ * The search query.
43
+ */
44
+ query?: string;
45
+ } | {
46
+ /**
47
+ * Action type "openPage" - Opens a specific URL from search results.
48
+ */
49
+ type: "openPage";
50
+ /**
51
+ * The URL opened by the model.
52
+ */
53
+ url: string;
54
+ } | {
55
+ /**
56
+ * Action type "find": Searches for a pattern within a loaded page.
57
+ */
58
+ type: "find";
59
+ /**
60
+ * The URL of the page searched for the pattern.
61
+ */
62
+ url: string;
63
+ /**
64
+ * The pattern or text to search for within the page.
65
+ */
66
+ pattern: string;
67
+ };
68
+ }, {
32
69
  /**
33
70
  * Filters for the search.
34
71
  */
@@ -227,7 +264,19 @@ declare const openaiTools: {
227
264
  *
228
265
  * @deprecated Use `webSearch` instead.
229
266
  */
230
- webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
267
+ webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
268
+ action: {
269
+ type: "search";
270
+ query?: string;
271
+ } | {
272
+ type: "openPage";
273
+ url: string;
274
+ } | {
275
+ type: "find";
276
+ url: string;
277
+ pattern: string;
278
+ };
279
+ }, {
231
280
  searchContextSize?: "low" | "medium" | "high";
232
281
  userLocation?: {
233
282
  type: "approximate";
@@ -247,7 +296,19 @@ declare const openaiTools: {
247
296
  * @param searchContextSize - The search context size to use for the web search.
248
297
  * @param userLocation - The user location to use for the web search.
249
298
  */
250
- webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, unknown>;
299
+ webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
300
+ action: {
301
+ type: "search";
302
+ query?: string;
303
+ } | {
304
+ type: "openPage";
305
+ url: string;
306
+ } | {
307
+ type: "find";
308
+ url: string;
309
+ pattern: string;
310
+ };
311
+ }>;
251
312
  };
252
313
 
253
314
  type OpenAIResponsesModelId = 'chatgpt-4o-latest' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4-0613' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | (string & {});
package/dist/index.js CHANGED
@@ -1920,9 +1920,7 @@ var import_v413 = require("zod/v4");
1920
1920
  var webSearchArgsSchema = (0, import_provider_utils18.lazySchema)(
1921
1921
  () => (0, import_provider_utils18.zodSchema)(
1922
1922
  import_v413.z.object({
1923
- filters: import_v413.z.object({
1924
- allowedDomains: import_v413.z.array(import_v413.z.string()).optional()
1925
- }).optional(),
1923
+ filters: import_v413.z.object({ allowedDomains: import_v413.z.array(import_v413.z.string()).optional() }).optional(),
1926
1924
  searchContextSize: import_v413.z.enum(["low", "medium", "high"]).optional(),
1927
1925
  userLocation: import_v413.z.object({
1928
1926
  type: import_v413.z.literal("approximate"),
@@ -1934,16 +1932,17 @@ var webSearchArgsSchema = (0, import_provider_utils18.lazySchema)(
1934
1932
  })
1935
1933
  )
1936
1934
  );
1937
- var webSearchInputSchema = (0, import_provider_utils18.lazySchema)(
1935
+ var webSearchInputSchema = (0, import_provider_utils18.lazySchema)(() => (0, import_provider_utils18.zodSchema)(import_v413.z.object({})));
1936
+ var webSearchOutputSchema = (0, import_provider_utils18.lazySchema)(
1938
1937
  () => (0, import_provider_utils18.zodSchema)(
1939
1938
  import_v413.z.object({
1940
1939
  action: import_v413.z.discriminatedUnion("type", [
1941
1940
  import_v413.z.object({
1942
1941
  type: import_v413.z.literal("search"),
1943
- query: import_v413.z.string().nullish()
1942
+ query: import_v413.z.string().optional()
1944
1943
  }),
1945
1944
  import_v413.z.object({
1946
- type: import_v413.z.literal("open_page"),
1945
+ type: import_v413.z.literal("openPage"),
1947
1946
  url: import_v413.z.string()
1948
1947
  }),
1949
1948
  import_v413.z.object({
@@ -1951,18 +1950,17 @@ var webSearchInputSchema = (0, import_provider_utils18.lazySchema)(
1951
1950
  url: import_v413.z.string(),
1952
1951
  pattern: import_v413.z.string()
1953
1952
  })
1954
- ]).nullish()
1953
+ ])
1955
1954
  })
1956
1955
  )
1957
1956
  );
1958
- var webSearchToolFactory = (0, import_provider_utils18.createProviderDefinedToolFactory)({
1957
+ var webSearchToolFactory = (0, import_provider_utils18.createProviderDefinedToolFactoryWithOutputSchema)({
1959
1958
  id: "openai.web_search",
1960
1959
  name: "web_search",
1961
- inputSchema: webSearchInputSchema
1960
+ inputSchema: webSearchInputSchema,
1961
+ outputSchema: webSearchOutputSchema
1962
1962
  });
1963
- var webSearch = (args = {}) => {
1964
- return webSearchToolFactory(args);
1965
- };
1963
+ var webSearch = (args = {}) => webSearchToolFactory(args);
1966
1964
 
1967
1965
  // src/tool/web-search-preview.ts
1968
1966
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
@@ -1970,51 +1968,30 @@ var import_v414 = require("zod/v4");
1970
1968
  var webSearchPreviewArgsSchema = (0, import_provider_utils19.lazySchema)(
1971
1969
  () => (0, import_provider_utils19.zodSchema)(
1972
1970
  import_v414.z.object({
1973
- /**
1974
- * Search context size to use for the web search.
1975
- * - high: Most comprehensive context, highest cost, slower response
1976
- * - medium: Balanced context, cost, and latency (default)
1977
- * - low: Least context, lowest cost, fastest response
1978
- */
1979
1971
  searchContextSize: import_v414.z.enum(["low", "medium", "high"]).optional(),
1980
- /**
1981
- * User location information to provide geographically relevant search results.
1982
- */
1983
1972
  userLocation: import_v414.z.object({
1984
- /**
1985
- * Type of location (always 'approximate')
1986
- */
1987
1973
  type: import_v414.z.literal("approximate"),
1988
- /**
1989
- * Two-letter ISO country code (e.g., 'US', 'GB')
1990
- */
1991
1974
  country: import_v414.z.string().optional(),
1992
- /**
1993
- * City name (free text, e.g., 'Minneapolis')
1994
- */
1995
1975
  city: import_v414.z.string().optional(),
1996
- /**
1997
- * Region name (free text, e.g., 'Minnesota')
1998
- */
1999
1976
  region: import_v414.z.string().optional(),
2000
- /**
2001
- * IANA timezone (e.g., 'America/Chicago')
2002
- */
2003
1977
  timezone: import_v414.z.string().optional()
2004
1978
  }).optional()
2005
1979
  })
2006
1980
  )
2007
1981
  );
2008
1982
  var webSearchPreviewInputSchema = (0, import_provider_utils19.lazySchema)(
1983
+ () => (0, import_provider_utils19.zodSchema)(import_v414.z.object({}))
1984
+ );
1985
+ var webSearchPreviewOutputSchema = (0, import_provider_utils19.lazySchema)(
2009
1986
  () => (0, import_provider_utils19.zodSchema)(
2010
1987
  import_v414.z.object({
2011
1988
  action: import_v414.z.discriminatedUnion("type", [
2012
1989
  import_v414.z.object({
2013
1990
  type: import_v414.z.literal("search"),
2014
- query: import_v414.z.string().nullish()
1991
+ query: import_v414.z.string().optional()
2015
1992
  }),
2016
1993
  import_v414.z.object({
2017
- type: import_v414.z.literal("open_page"),
1994
+ type: import_v414.z.literal("openPage"),
2018
1995
  url: import_v414.z.string()
2019
1996
  }),
2020
1997
  import_v414.z.object({
@@ -2022,14 +1999,15 @@ var webSearchPreviewInputSchema = (0, import_provider_utils19.lazySchema)(
2022
1999
  url: import_v414.z.string(),
2023
2000
  pattern: import_v414.z.string()
2024
2001
  })
2025
- ]).nullish()
2002
+ ])
2026
2003
  })
2027
2004
  )
2028
2005
  );
2029
- var webSearchPreview = (0, import_provider_utils19.createProviderDefinedToolFactory)({
2006
+ var webSearchPreview = (0, import_provider_utils19.createProviderDefinedToolFactoryWithOutputSchema)({
2030
2007
  id: "openai.web_search_preview",
2031
2008
  name: "web_search_preview",
2032
- inputSchema: webSearchPreviewInputSchema
2009
+ inputSchema: webSearchPreviewInputSchema,
2010
+ outputSchema: webSearchPreviewOutputSchema
2033
2011
  });
2034
2012
 
2035
2013
  // src/openai-tools.ts
@@ -2314,6 +2292,9 @@ async function convertToOpenAIResponsesInput({
2314
2292
  input.push(reasoningMessages[reasoningId]);
2315
2293
  } else {
2316
2294
  reasoningMessage.summary.push(...summaryParts);
2295
+ if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
2296
+ reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
2297
+ }
2317
2298
  }
2318
2299
  }
2319
2300
  } else {
@@ -2483,11 +2464,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2483
2464
  import_v416.z.object({
2484
2465
  type: import_v416.z.literal("web_search_call"),
2485
2466
  id: import_v416.z.string(),
2486
- status: import_v416.z.string(),
2487
- action: import_v416.z.object({
2488
- type: import_v416.z.literal("search"),
2489
- query: import_v416.z.string().optional()
2490
- }).nullish()
2467
+ status: import_v416.z.string()
2491
2468
  }),
2492
2469
  import_v416.z.object({
2493
2470
  type: import_v416.z.literal("computer_call"),
@@ -2573,7 +2550,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2573
2550
  url: import_v416.z.string(),
2574
2551
  pattern: import_v416.z.string()
2575
2552
  })
2576
- ]).nullish()
2553
+ ])
2577
2554
  }),
2578
2555
  import_v416.z.object({
2579
2556
  type: import_v416.z.literal("file_search_call"),
@@ -2663,6 +2640,11 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2663
2640
  summary_index: import_v416.z.number(),
2664
2641
  delta: import_v416.z.string()
2665
2642
  }),
2643
+ import_v416.z.object({
2644
+ type: import_v416.z.literal("response.reasoning_summary_part.done"),
2645
+ item_id: import_v416.z.string(),
2646
+ summary_index: import_v416.z.number()
2647
+ }),
2666
2648
  import_v416.z.object({
2667
2649
  type: import_v416.z.literal("error"),
2668
2650
  code: import_v416.z.string(),
@@ -2754,7 +2736,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
2754
2736
  url: import_v416.z.string(),
2755
2737
  pattern: import_v416.z.string()
2756
2738
  })
2757
- ]).nullish()
2739
+ ])
2758
2740
  }),
2759
2741
  import_v416.z.object({
2760
2742
  type: import_v416.z.literal("file_search_call"),
@@ -3298,7 +3280,8 @@ var OpenAIResponsesLanguageModel = class {
3298
3280
  tools: openaiTools2,
3299
3281
  tool_choice: openaiToolChoice
3300
3282
  },
3301
- warnings: [...warnings, ...toolWarnings]
3283
+ warnings: [...warnings, ...toolWarnings],
3284
+ store
3302
3285
  };
3303
3286
  }
3304
3287
  async doGenerate(options) {
@@ -3453,14 +3436,14 @@ var OpenAIResponsesLanguageModel = class {
3453
3436
  type: "tool-call",
3454
3437
  toolCallId: part.id,
3455
3438
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3456
- input: JSON.stringify({ action: part.action }),
3439
+ input: JSON.stringify({}),
3457
3440
  providerExecuted: true
3458
3441
  });
3459
3442
  content.push({
3460
3443
  type: "tool-result",
3461
3444
  toolCallId: part.id,
3462
3445
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3463
- result: { status: part.status },
3446
+ result: mapWebSearchOutput(part.action),
3464
3447
  providerExecuted: true
3465
3448
  });
3466
3449
  break;
@@ -3573,7 +3556,8 @@ var OpenAIResponsesLanguageModel = class {
3573
3556
  const {
3574
3557
  args: body,
3575
3558
  warnings,
3576
- webSearchToolName
3559
+ webSearchToolName,
3560
+ store
3577
3561
  } = await this.getArgs(options);
3578
3562
  const { responseHeaders, value: response } = await (0, import_provider_utils24.postJsonToApi)({
3579
3563
  url: this.config.url({
@@ -3612,7 +3596,7 @@ var OpenAIResponsesLanguageModel = class {
3612
3596
  controller.enqueue({ type: "stream-start", warnings });
3613
3597
  },
3614
3598
  transform(chunk, controller) {
3615
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
3599
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
3616
3600
  if (options.includeRawChunks) {
3617
3601
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3618
3602
  }
@@ -3644,6 +3628,17 @@ var OpenAIResponsesLanguageModel = class {
3644
3628
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3645
3629
  providerExecuted: true
3646
3630
  });
3631
+ controller.enqueue({
3632
+ type: "tool-input-end",
3633
+ id: value.item.id
3634
+ });
3635
+ controller.enqueue({
3636
+ type: "tool-call",
3637
+ toolCallId: value.item.id,
3638
+ toolName: "web_search",
3639
+ input: JSON.stringify({}),
3640
+ providerExecuted: true
3641
+ });
3647
3642
  } else if (value.item.type === "computer_call") {
3648
3643
  ongoingToolCalls[value.output_index] = {
3649
3644
  toolName: "computer_use",
@@ -3700,10 +3695,10 @@ var OpenAIResponsesLanguageModel = class {
3700
3695
  }
3701
3696
  }
3702
3697
  });
3703
- } else if (isResponseOutputItemAddedReasoningChunk(value)) {
3698
+ } else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
3704
3699
  activeReasoning[value.item.id] = {
3705
3700
  encryptedContent: value.item.encrypted_content,
3706
- summaryParts: [0]
3701
+ summaryParts: { 0: "active" }
3707
3702
  };
3708
3703
  controller.enqueue({
3709
3704
  type: "reasoning-start",
@@ -3737,22 +3732,11 @@ var OpenAIResponsesLanguageModel = class {
3737
3732
  });
3738
3733
  } else if (value.item.type === "web_search_call") {
3739
3734
  ongoingToolCalls[value.output_index] = void 0;
3740
- controller.enqueue({
3741
- type: "tool-input-end",
3742
- id: value.item.id
3743
- });
3744
- controller.enqueue({
3745
- type: "tool-call",
3746
- toolCallId: value.item.id,
3747
- toolName: "web_search",
3748
- input: JSON.stringify({ action: value.item.action }),
3749
- providerExecuted: true
3750
- });
3751
3735
  controller.enqueue({
3752
3736
  type: "tool-result",
3753
3737
  toolCallId: value.item.id,
3754
3738
  toolName: "web_search",
3755
- result: { status: value.item.status },
3739
+ result: mapWebSearchOutput(value.item.action),
3756
3740
  providerExecuted: true
3757
3741
  });
3758
3742
  } else if (value.item.type === "computer_call") {
@@ -3842,9 +3826,14 @@ var OpenAIResponsesLanguageModel = class {
3842
3826
  type: "text-end",
3843
3827
  id: value.item.id
3844
3828
  });
3845
- } else if (isResponseOutputItemDoneReasoningChunk(value)) {
3829
+ } else if (value.item.type === "reasoning") {
3846
3830
  const activeReasoningPart = activeReasoning[value.item.id];
3847
- for (const summaryIndex of activeReasoningPart.summaryParts) {
3831
+ const summaryPartIndices = Object.entries(
3832
+ activeReasoningPart.summaryParts
3833
+ ).filter(
3834
+ ([_, status]) => status === "active" || status === "can-conclude"
3835
+ ).map(([summaryIndex]) => summaryIndex);
3836
+ for (const summaryIndex of summaryPartIndices) {
3848
3837
  controller.enqueue({
3849
3838
  type: "reasoning-end",
3850
3839
  id: `${value.item.id}:${summaryIndex}`,
@@ -3929,23 +3918,34 @@ var OpenAIResponsesLanguageModel = class {
3929
3918
  if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
3930
3919
  logprobs.push(value.logprobs);
3931
3920
  }
3932
- } else if (isResponseReasoningSummaryPartAddedChunk(value)) {
3921
+ } else if (value.type === "response.reasoning_summary_part.added") {
3933
3922
  if (value.summary_index > 0) {
3934
- (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.summaryParts.push(
3935
- value.summary_index
3936
- );
3923
+ const activeReasoningPart = activeReasoning[value.item_id];
3924
+ activeReasoningPart.summaryParts[value.summary_index] = "active";
3925
+ for (const summaryIndex of Object.keys(
3926
+ activeReasoningPart.summaryParts
3927
+ )) {
3928
+ if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
3929
+ controller.enqueue({
3930
+ type: "reasoning-end",
3931
+ id: `${value.item_id}:${summaryIndex}`,
3932
+ providerMetadata: { openai: { itemId: value.item_id } }
3933
+ });
3934
+ activeReasoningPart.summaryParts[summaryIndex] = "concluded";
3935
+ }
3936
+ }
3937
3937
  controller.enqueue({
3938
3938
  type: "reasoning-start",
3939
3939
  id: `${value.item_id}:${value.summary_index}`,
3940
3940
  providerMetadata: {
3941
3941
  openai: {
3942
3942
  itemId: value.item_id,
3943
- reasoningEncryptedContent: (_i = (_h = activeReasoning[value.item_id]) == null ? void 0 : _h.encryptedContent) != null ? _i : null
3943
+ reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
3944
3944
  }
3945
3945
  }
3946
3946
  });
3947
3947
  }
3948
- } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
3948
+ } else if (value.type === "response.reasoning_summary_text.delta") {
3949
3949
  controller.enqueue({
3950
3950
  type: "reasoning-delta",
3951
3951
  id: `${value.item_id}:${value.summary_index}`,
@@ -3956,16 +3956,29 @@ var OpenAIResponsesLanguageModel = class {
3956
3956
  }
3957
3957
  }
3958
3958
  });
3959
+ } else if (value.type === "response.reasoning_summary_part.done") {
3960
+ if (store) {
3961
+ controller.enqueue({
3962
+ type: "reasoning-end",
3963
+ id: `${value.item_id}:${value.summary_index}`,
3964
+ providerMetadata: {
3965
+ openai: { itemId: value.item_id }
3966
+ }
3967
+ });
3968
+ activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
3969
+ } else {
3970
+ activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
3971
+ }
3959
3972
  } else if (isResponseFinishedChunk(value)) {
3960
3973
  finishReason = mapOpenAIResponseFinishReason({
3961
- finishReason: (_j = value.response.incomplete_details) == null ? void 0 : _j.reason,
3974
+ finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
3962
3975
  hasFunctionCall
3963
3976
  });
3964
3977
  usage.inputTokens = value.response.usage.input_tokens;
3965
3978
  usage.outputTokens = value.response.usage.output_tokens;
3966
3979
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
3967
- usage.reasoningTokens = (_l = (_k = value.response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0;
3968
- usage.cachedInputTokens = (_n = (_m = value.response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0;
3980
+ usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
3981
+ usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
3969
3982
  if (typeof value.response.service_tier === "string") {
3970
3983
  serviceTier = value.response.service_tier;
3971
3984
  }
@@ -3974,7 +3987,7 @@ var OpenAIResponsesLanguageModel = class {
3974
3987
  controller.enqueue({
3975
3988
  type: "source",
3976
3989
  sourceType: "url",
3977
- id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils24.generateId)(),
3990
+ id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils24.generateId)(),
3978
3991
  url: value.annotation.url,
3979
3992
  title: value.annotation.title
3980
3993
  });
@@ -3982,10 +3995,10 @@ var OpenAIResponsesLanguageModel = class {
3982
3995
  controller.enqueue({
3983
3996
  type: "source",
3984
3997
  sourceType: "document",
3985
- id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils24.generateId)(),
3998
+ id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0, import_provider_utils24.generateId)(),
3986
3999
  mediaType: "text/plain",
3987
- title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
3988
- filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id
4000
+ title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
4001
+ filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
3989
4002
  });
3990
4003
  }
3991
4004
  } else if (isErrorChunk(value)) {
@@ -4024,9 +4037,6 @@ function isTextDeltaChunk(chunk) {
4024
4037
  function isResponseOutputItemDoneChunk(chunk) {
4025
4038
  return chunk.type === "response.output_item.done";
4026
4039
  }
4027
- function isResponseOutputItemDoneReasoningChunk(chunk) {
4028
- return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
4029
- }
4030
4040
  function isResponseFinishedChunk(chunk) {
4031
4041
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
4032
4042
  }
@@ -4048,18 +4058,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
4048
4058
  function isResponseOutputItemAddedChunk(chunk) {
4049
4059
  return chunk.type === "response.output_item.added";
4050
4060
  }
4051
- function isResponseOutputItemAddedReasoningChunk(chunk) {
4052
- return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
4053
- }
4054
4061
  function isResponseAnnotationAddedChunk(chunk) {
4055
4062
  return chunk.type === "response.output_text.annotation.added";
4056
4063
  }
4057
- function isResponseReasoningSummaryPartAddedChunk(chunk) {
4058
- return chunk.type === "response.reasoning_summary_part.added";
4059
- }
4060
- function isResponseReasoningSummaryTextDeltaChunk(chunk) {
4061
- return chunk.type === "response.reasoning_summary_text.delta";
4062
- }
4063
4064
  function isErrorChunk(chunk) {
4064
4065
  return chunk.type === "error";
4065
4066
  }
@@ -4097,6 +4098,19 @@ function getResponsesModelConfig(modelId) {
4097
4098
  isReasoningModel: false
4098
4099
  };
4099
4100
  }
4101
+ function mapWebSearchOutput(action) {
4102
+ var _a;
4103
+ switch (action.type) {
4104
+ case "search":
4105
+ return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
4106
+ case "open_page":
4107
+ return { action: { type: "openPage", url: action.url } };
4108
+ case "find":
4109
+ return {
4110
+ action: { type: "find", url: action.url, pattern: action.pattern }
4111
+ };
4112
+ }
4113
+ }
4100
4114
 
4101
4115
  // src/speech/openai-speech-model.ts
4102
4116
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
@@ -4451,7 +4465,7 @@ var OpenAITranscriptionModel = class {
4451
4465
  };
4452
4466
 
4453
4467
  // src/version.ts
4454
- var VERSION = true ? "3.0.0-beta.27" : "0.0.0-test";
4468
+ var VERSION = true ? "3.0.0-beta.29" : "0.0.0-test";
4455
4469
 
4456
4470
  // src/openai-provider.ts
4457
4471
  function createOpenAI(options = {}) {