@ai-sdk/openai 2.0.129 → 2.0.131

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/dist/index.mjs CHANGED
@@ -11,11 +11,11 @@ import {
11
11
  InvalidResponseDataError
12
12
  } from "@ai-sdk/provider";
13
13
  import {
14
+ StreamingToolCallTracker,
14
15
  combineHeaders,
15
16
  createEventSourceResponseHandler,
16
17
  createJsonResponseHandler,
17
18
  generateId,
18
- isParsableJson,
19
19
  parseProviderOptions,
20
20
  postJsonToApi
21
21
  } from "@ai-sdk/provider-utils";
@@ -1034,7 +1034,7 @@ var OpenAIChatLanguageModel = class {
1034
1034
  abortSignal: options.abortSignal,
1035
1035
  fetch: this.config.fetch
1036
1036
  });
1037
- const toolCalls = [];
1037
+ let toolCallTracker;
1038
1038
  let finishReason = "unknown";
1039
1039
  const usage = {
1040
1040
  inputTokens: void 0,
@@ -1048,10 +1048,14 @@ var OpenAIChatLanguageModel = class {
1048
1048
  stream: response.pipeThrough(
1049
1049
  new TransformStream({
1050
1050
  start(controller) {
1051
+ toolCallTracker = new StreamingToolCallTracker(controller, {
1052
+ generateId,
1053
+ typeValidation: "if-present"
1054
+ });
1051
1055
  controller.enqueue({ type: "stream-start", warnings });
1052
1056
  },
1053
1057
  transform(chunk, controller) {
1054
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
1058
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1055
1059
  if (options.includeRawChunks) {
1056
1060
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1057
1061
  }
@@ -1118,90 +1122,7 @@ var OpenAIChatLanguageModel = class {
1118
1122
  }
1119
1123
  if (delta.tool_calls != null) {
1120
1124
  for (const toolCallDelta of delta.tool_calls) {
1121
- const index = toolCallDelta.index;
1122
- if (toolCalls[index] == null) {
1123
- if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
1124
- throw new InvalidResponseDataError({
1125
- data: toolCallDelta,
1126
- message: `Expected 'function' type.`
1127
- });
1128
- }
1129
- if (toolCallDelta.id == null) {
1130
- throw new InvalidResponseDataError({
1131
- data: toolCallDelta,
1132
- message: `Expected 'id' to be a string.`
1133
- });
1134
- }
1135
- if (((_n = toolCallDelta.function) == null ? void 0 : _n.name) == null) {
1136
- throw new InvalidResponseDataError({
1137
- data: toolCallDelta,
1138
- message: `Expected 'function.name' to be a string.`
1139
- });
1140
- }
1141
- controller.enqueue({
1142
- type: "tool-input-start",
1143
- id: toolCallDelta.id,
1144
- toolName: toolCallDelta.function.name
1145
- });
1146
- toolCalls[index] = {
1147
- id: toolCallDelta.id,
1148
- type: "function",
1149
- function: {
1150
- name: toolCallDelta.function.name,
1151
- arguments: (_o = toolCallDelta.function.arguments) != null ? _o : ""
1152
- },
1153
- hasFinished: false
1154
- };
1155
- const toolCall2 = toolCalls[index];
1156
- if (((_p = toolCall2.function) == null ? void 0 : _p.name) != null && ((_q = toolCall2.function) == null ? void 0 : _q.arguments) != null) {
1157
- if (toolCall2.function.arguments.length > 0) {
1158
- controller.enqueue({
1159
- type: "tool-input-delta",
1160
- id: toolCall2.id,
1161
- delta: toolCall2.function.arguments
1162
- });
1163
- }
1164
- if (isParsableJson(toolCall2.function.arguments)) {
1165
- controller.enqueue({
1166
- type: "tool-input-end",
1167
- id: toolCall2.id
1168
- });
1169
- controller.enqueue({
1170
- type: "tool-call",
1171
- toolCallId: (_r = toolCall2.id) != null ? _r : generateId(),
1172
- toolName: toolCall2.function.name,
1173
- input: toolCall2.function.arguments
1174
- });
1175
- toolCall2.hasFinished = true;
1176
- }
1177
- }
1178
- continue;
1179
- }
1180
- const toolCall = toolCalls[index];
1181
- if (toolCall.hasFinished) {
1182
- continue;
1183
- }
1184
- if (((_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null) {
1185
- toolCall.function.arguments += (_u = (_t = toolCallDelta.function) == null ? void 0 : _t.arguments) != null ? _u : "";
1186
- }
1187
- controller.enqueue({
1188
- type: "tool-input-delta",
1189
- id: toolCall.id,
1190
- delta: (_v = toolCallDelta.function.arguments) != null ? _v : ""
1191
- });
1192
- if (((_w = toolCall.function) == null ? void 0 : _w.name) != null && ((_x = toolCall.function) == null ? void 0 : _x.arguments) != null && isParsableJson(toolCall.function.arguments)) {
1193
- controller.enqueue({
1194
- type: "tool-input-end",
1195
- id: toolCall.id
1196
- });
1197
- controller.enqueue({
1198
- type: "tool-call",
1199
- toolCallId: (_y = toolCall.id) != null ? _y : generateId(),
1200
- toolName: toolCall.function.name,
1201
- input: toolCall.function.arguments
1202
- });
1203
- toolCall.hasFinished = true;
1204
- }
1125
+ toolCallTracker.processDelta(toolCallDelta);
1205
1126
  }
1206
1127
  }
1207
1128
  if (delta.annotations != null) {
@@ -1220,6 +1141,7 @@ var OpenAIChatLanguageModel = class {
1220
1141
  if (isActiveText) {
1221
1142
  controller.enqueue({ type: "text-end", id: "0" });
1222
1143
  }
1144
+ toolCallTracker.flush();
1223
1145
  controller.enqueue({
1224
1146
  type: "finish",
1225
1147
  finishReason,
@@ -2408,6 +2330,7 @@ var openaiTools = {
2408
2330
 
2409
2331
  // src/responses/openai-responses-language-model.ts
2410
2332
  import {
2333
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError6,
2411
2334
  APICallError
2412
2335
  } from "@ai-sdk/provider";
2413
2336
  import {
@@ -2428,7 +2351,213 @@ import {
2428
2351
  parseProviderOptions as parseProviderOptions5,
2429
2352
  validateTypes
2430
2353
  } from "@ai-sdk/provider-utils";
2354
+ import { z as z17 } from "zod/v4";
2355
+
2356
+ // src/responses/openai-responses-options.ts
2357
+ import {
2358
+ lazyValidator as lazyValidator9,
2359
+ zodSchema as zodSchema15
2360
+ } from "@ai-sdk/provider-utils";
2431
2361
  import { z as z16 } from "zod/v4";
2362
+ var TOP_LOGPROBS_MAX = 20;
2363
+ var openaiResponsesReasoningModelIds = [
2364
+ "o1",
2365
+ "o1-2024-12-17",
2366
+ "o3",
2367
+ "o3-2025-04-16",
2368
+ "o3-deep-research",
2369
+ "o3-deep-research-2025-06-26",
2370
+ "o3-mini",
2371
+ "o3-mini-2025-01-31",
2372
+ "o4-mini",
2373
+ "o4-mini-2025-04-16",
2374
+ "o4-mini-deep-research",
2375
+ "o4-mini-deep-research-2025-06-26",
2376
+ "codex-mini-latest",
2377
+ "computer-use-preview",
2378
+ "gpt-5",
2379
+ "gpt-5-2025-08-07",
2380
+ "gpt-5-codex",
2381
+ "gpt-5-mini",
2382
+ "gpt-5-mini-2025-08-07",
2383
+ "gpt-5-nano",
2384
+ "gpt-5-nano-2025-08-07",
2385
+ "gpt-5-pro",
2386
+ "gpt-5-pro-2025-10-06",
2387
+ "gpt-5.1",
2388
+ "gpt-5.1-chat-latest",
2389
+ "gpt-5.1-codex-mini",
2390
+ "gpt-5.1-codex",
2391
+ "gpt-5.1-codex-max",
2392
+ "gpt-5.2",
2393
+ "gpt-5.2-chat-latest",
2394
+ "gpt-5.2-pro",
2395
+ "gpt-5.2-codex",
2396
+ "gpt-5.3-chat-latest",
2397
+ "gpt-5.3-codex",
2398
+ "gpt-5.4",
2399
+ "gpt-5.4-2026-03-05",
2400
+ "gpt-5.4-mini",
2401
+ "gpt-5.4-mini-2026-03-17",
2402
+ "gpt-5.4-nano",
2403
+ "gpt-5.4-nano-2026-03-17",
2404
+ "gpt-5.4-pro",
2405
+ "gpt-5.4-pro-2026-03-05",
2406
+ "gpt-5.6",
2407
+ "gpt-5.6-luna",
2408
+ "gpt-5.6-sol",
2409
+ "gpt-5.6-terra",
2410
+ "gpt-6-astra",
2411
+ "gpt-6-luna",
2412
+ "gpt-6-sol"
2413
+ ];
2414
+ var openaiResponsesModelIds = [
2415
+ "gpt-4.1",
2416
+ "gpt-4.1-2025-04-14",
2417
+ "gpt-4.1-mini",
2418
+ "gpt-4.1-mini-2025-04-14",
2419
+ "gpt-4.1-nano",
2420
+ "gpt-4.1-nano-2025-04-14",
2421
+ "gpt-4o",
2422
+ "gpt-4o-2024-05-13",
2423
+ "gpt-4o-2024-08-06",
2424
+ "gpt-4o-2024-11-20",
2425
+ "gpt-4o-audio-preview",
2426
+ "gpt-4o-audio-preview-2024-10-01",
2427
+ "gpt-4o-audio-preview-2024-12-17",
2428
+ "gpt-4o-search-preview",
2429
+ "gpt-4o-search-preview-2025-03-11",
2430
+ "gpt-4o-mini-search-preview",
2431
+ "gpt-4o-mini-search-preview-2025-03-11",
2432
+ "gpt-4o-mini",
2433
+ "gpt-4o-mini-2024-07-18",
2434
+ "gpt-4-turbo",
2435
+ "gpt-4-turbo-2024-04-09",
2436
+ "gpt-4-turbo-preview",
2437
+ "gpt-4-0125-preview",
2438
+ "gpt-4-1106-preview",
2439
+ "gpt-4",
2440
+ "gpt-4-0613",
2441
+ "gpt-4.5-preview",
2442
+ "gpt-4.5-preview-2025-02-27",
2443
+ "gpt-3.5-turbo-0125",
2444
+ "gpt-3.5-turbo",
2445
+ "gpt-3.5-turbo-1106",
2446
+ "chatgpt-4o-latest",
2447
+ "gpt-5-chat-latest",
2448
+ ...openaiResponsesReasoningModelIds
2449
+ ];
2450
+ var openaiResponsesProviderOptionsSchema = lazyValidator9(
2451
+ () => zodSchema15(
2452
+ z16.object({
2453
+ conversation: z16.string().nullish(),
2454
+ include: z16.array(
2455
+ z16.enum([
2456
+ "reasoning.encrypted_content",
2457
+ // handled internally by default, only needed for unknown reasoning models
2458
+ "file_search_call.results",
2459
+ "message.output_text.logprobs"
2460
+ ])
2461
+ ).nullish(),
2462
+ instructions: z16.string().nullish(),
2463
+ /**
2464
+ * Return the log probabilities of the tokens.
2465
+ *
2466
+ * Setting to true will return the log probabilities of the tokens that
2467
+ * were generated.
2468
+ *
2469
+ * Setting to a number will return the log probabilities of the top n
2470
+ * tokens that were generated.
2471
+ *
2472
+ * @see https://platform.openai.com/docs/api-reference/responses/create
2473
+ * @see https://cookbook.openai.com/examples/using_logprobs
2474
+ */
2475
+ logprobs: z16.union([z16.boolean(), z16.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
2476
+ /**
2477
+ * The maximum number of total calls to built-in tools that can be processed in a response.
2478
+ * This maximum number applies across all built-in tool calls, not per individual tool.
2479
+ * Any further attempts to call a tool by the model will be ignored.
2480
+ */
2481
+ maxToolCalls: z16.number().nullish(),
2482
+ metadata: z16.any().nullish(),
2483
+ parallelToolCalls: z16.boolean().nullish(),
2484
+ previousResponseId: z16.string().nullish(),
2485
+ promptCacheKey: z16.string().nullish(),
2486
+ /**
2487
+ * Prompt cache behavior for GPT-5.6 and later models.
2488
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
2489
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
2490
+ */
2491
+ promptCacheOptions: z16.object({
2492
+ mode: z16.enum(["implicit", "explicit"]).optional(),
2493
+ ttl: z16.literal("30m").optional()
2494
+ }).optional(),
2495
+ /**
2496
+ * The retention policy for the prompt cache.
2497
+ * - 'in_memory': Default. Standard prompt caching behavior.
2498
+ * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
2499
+ * Available for models before GPT-5.6 that support extended caching.
2500
+ *
2501
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
2502
+ *
2503
+ * @default 'in_memory'
2504
+ */
2505
+ promptCacheRetention: z16.enum(["in_memory", "24h"]).nullish(),
2506
+ /**
2507
+ * Reasoning effort for reasoning models. Defaults to `medium`. If you use
2508
+ * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
2509
+ * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
2510
+ * Supported values vary by model.
2511
+ */
2512
+ reasoningEffort: z16.string().nullish(),
2513
+ /**
2514
+ * Updates the reasoning effort for GPT-6 and later models starting with this response
2515
+ * without changing the request-level reasoning effort. This preserves the
2516
+ * request prefix for prompt caching.
2517
+ *
2518
+ * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
2519
+ * combined with automatic truncation.
2520
+ */
2521
+ reasoningEffortUpdate: z16.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
2522
+ /**
2523
+ * Controls how much model work GPT-5.6 performs before returning a final answer.
2524
+ * `standard` is the default. `pro` increases quality, latency, and token usage.
2525
+ */
2526
+ reasoningMode: z16.enum(["standard", "pro"]).optional(),
2527
+ /**
2528
+ * Controls which available reasoning items GPT-5.6 can use.
2529
+ * `auto` uses the model default, `current_turn` excludes reasoning from earlier
2530
+ * turns, and `all_turns` makes compatible earlier reasoning available.
2531
+ */
2532
+ reasoningContext: z16.enum(["auto", "current_turn", "all_turns"]).optional(),
2533
+ reasoningSummary: z16.string().nullish(),
2534
+ safetyIdentifier: z16.string().nullish(),
2535
+ serviceTier: z16.enum(["auto", "flex", "priority", "default"]).nullish(),
2536
+ store: z16.boolean().nullish(),
2537
+ strictJsonSchema: z16.boolean().nullish(),
2538
+ textVerbosity: z16.enum(["low", "medium", "high"]).nullish(),
2539
+ truncation: z16.enum(["auto", "disabled"]).nullish(),
2540
+ user: z16.string().nullish()
2541
+ })
2542
+ )
2543
+ );
2544
+ var openaiResponsesSystemMessageOptionsSchema = lazyValidator9(
2545
+ () => zodSchema15(
2546
+ z16.object({
2547
+ /**
2548
+ * Emit a configuration update at this position in Responses history.
2549
+ * Requires empty system message content and the same supported
2550
+ * configuration as the request-level reasoningEffortUpdate option.
2551
+ * Unsupported historical updates throw instead of being omitted.
2552
+ *
2553
+ * @see https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation
2554
+ */
2555
+ reasoningEffortUpdate: z16.enum(["low", "medium", "high", "xhigh", "max"]).optional()
2556
+ })
2557
+ )
2558
+ );
2559
+
2560
+ // src/responses/convert-to-openai-responses-input.ts
2432
2561
  function getPromptCacheBreakpoint2(providerOptions) {
2433
2562
  var _a2;
2434
2563
  return (_a2 = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a2.promptCacheBreakpoint;
@@ -2440,9 +2569,11 @@ function isFileId(data, prefixes) {
2440
2569
  async function convertToOpenAIResponsesInput({
2441
2570
  prompt,
2442
2571
  systemMessageMode,
2572
+ providerOptionsName = "openai",
2443
2573
  explicitMessageItemType = false,
2444
2574
  fileIdPrefixes,
2445
2575
  store,
2576
+ configurationUpdateUnsupportedReason,
2446
2577
  hasLocalShellTool = false
2447
2578
  }) {
2448
2579
  var _a2, _b, _c, _d, _e, _f, _g, _h;
@@ -2451,6 +2582,33 @@ async function convertToOpenAIResponsesInput({
2451
2582
  for (const { role, content, providerOptions } of prompt) {
2452
2583
  switch (role) {
2453
2584
  case "system": {
2585
+ let options = await parseProviderOptions5({
2586
+ provider: providerOptionsName,
2587
+ providerOptions,
2588
+ schema: openaiResponsesSystemMessageOptionsSchema
2589
+ });
2590
+ if (options == null && providerOptionsName !== "openai") {
2591
+ options = await parseProviderOptions5({
2592
+ provider: "openai",
2593
+ providerOptions,
2594
+ schema: openaiResponsesSystemMessageOptionsSchema
2595
+ });
2596
+ }
2597
+ const effort = options == null ? void 0 : options.reasoningEffortUpdate;
2598
+ if (effort != null) {
2599
+ const unsupportedReason = content !== "" ? "Message-level reasoningEffortUpdate requires empty system message content." : configurationUpdateUnsupportedReason;
2600
+ if (unsupportedReason != null) {
2601
+ throw new UnsupportedFunctionalityError4({
2602
+ functionality: "Message-level reasoningEffortUpdate",
2603
+ message: unsupportedReason
2604
+ });
2605
+ }
2606
+ input.push({
2607
+ type: "configuration_update",
2608
+ reasoning: { effort }
2609
+ });
2610
+ break;
2611
+ }
2454
2612
  switch (systemMessageMode) {
2455
2613
  case "system": {
2456
2614
  const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
@@ -2796,9 +2954,9 @@ async function convertToOpenAIResponsesInput({
2796
2954
  }
2797
2955
  return { input, warnings };
2798
2956
  }
2799
- var openaiResponsesReasoningProviderOptionsSchema = z16.object({
2800
- itemId: z16.string().nullish(),
2801
- reasoningEncryptedContent: z16.string().nullish()
2957
+ var openaiResponsesReasoningProviderOptionsSchema = z17.object({
2958
+ itemId: z17.string().nullish(),
2959
+ reasoningEncryptedContent: z17.string().nullish()
2802
2960
  });
2803
2961
 
2804
2962
  // src/responses/map-openai-responses-finish-reason.ts
@@ -2821,290 +2979,290 @@ function mapOpenAIResponseFinishReason({
2821
2979
 
2822
2980
  // src/responses/openai-responses-api.ts
2823
2981
  import {
2824
- lazyValidator as lazyValidator9,
2825
- zodSchema as zodSchema15
2982
+ lazyValidator as lazyValidator10,
2983
+ zodSchema as zodSchema16
2826
2984
  } from "@ai-sdk/provider-utils";
2827
- import { z as z17 } from "zod/v4";
2828
- var openaiResponsesChunkSchema = lazyValidator9(
2829
- () => zodSchema15(
2830
- z17.union([
2831
- z17.object({
2832
- type: z17.literal("response.output_text.delta"),
2833
- item_id: z17.string(),
2834
- delta: z17.string(),
2835
- logprobs: z17.array(
2836
- z17.object({
2837
- token: z17.string(),
2838
- logprob: z17.number(),
2839
- top_logprobs: z17.array(
2840
- z17.object({
2841
- token: z17.string(),
2842
- logprob: z17.number()
2985
+ import { z as z18 } from "zod/v4";
2986
+ var openaiResponsesChunkSchema = lazyValidator10(
2987
+ () => zodSchema16(
2988
+ z18.union([
2989
+ z18.object({
2990
+ type: z18.literal("response.output_text.delta"),
2991
+ item_id: z18.string(),
2992
+ delta: z18.string(),
2993
+ logprobs: z18.array(
2994
+ z18.object({
2995
+ token: z18.string(),
2996
+ logprob: z18.number(),
2997
+ top_logprobs: z18.array(
2998
+ z18.object({
2999
+ token: z18.string(),
3000
+ logprob: z18.number()
2843
3001
  })
2844
3002
  )
2845
3003
  })
2846
3004
  ).nullish()
2847
3005
  }),
2848
- z17.object({
2849
- type: z17.enum(["response.completed", "response.incomplete"]),
2850
- response: z17.object({
2851
- incomplete_details: z17.object({ reason: z17.string() }).nullish(),
2852
- usage: z17.object({
2853
- input_tokens: z17.number(),
2854
- input_tokens_details: z17.object({
2855
- cached_tokens: z17.number().nullish(),
2856
- cache_write_tokens: z17.number().nullish(),
2857
- orchestration_input_tokens: z17.number().nullish(),
2858
- orchestration_input_cached_tokens: z17.number().nullish()
3006
+ z18.object({
3007
+ type: z18.enum(["response.completed", "response.incomplete"]),
3008
+ response: z18.object({
3009
+ incomplete_details: z18.object({ reason: z18.string() }).nullish(),
3010
+ usage: z18.object({
3011
+ input_tokens: z18.number(),
3012
+ input_tokens_details: z18.object({
3013
+ cached_tokens: z18.number().nullish(),
3014
+ cache_write_tokens: z18.number().nullish(),
3015
+ orchestration_input_tokens: z18.number().nullish(),
3016
+ orchestration_input_cached_tokens: z18.number().nullish()
2859
3017
  }).nullish(),
2860
- output_tokens: z17.number(),
2861
- output_tokens_details: z17.object({
2862
- reasoning_tokens: z17.number().nullish(),
2863
- orchestration_output_tokens: z17.number().nullish()
3018
+ output_tokens: z18.number(),
3019
+ output_tokens_details: z18.object({
3020
+ reasoning_tokens: z18.number().nullish(),
3021
+ orchestration_output_tokens: z18.number().nullish()
2864
3022
  }).nullish()
2865
3023
  }),
2866
- reasoning: z17.object({
2867
- context: z17.string().nullish()
3024
+ reasoning: z18.object({
3025
+ context: z18.string().nullish()
2868
3026
  }).nullish(),
2869
- service_tier: z17.string().nullish()
3027
+ service_tier: z18.string().nullish()
2870
3028
  })
2871
3029
  }),
2872
- z17.object({
2873
- type: z17.literal("response.created"),
2874
- response: z17.object({
2875
- id: z17.string(),
2876
- created_at: z17.number(),
2877
- model: z17.string(),
2878
- service_tier: z17.string().nullish()
3030
+ z18.object({
3031
+ type: z18.literal("response.created"),
3032
+ response: z18.object({
3033
+ id: z18.string(),
3034
+ created_at: z18.number(),
3035
+ model: z18.string(),
3036
+ service_tier: z18.string().nullish()
2879
3037
  })
2880
3038
  }),
2881
- z17.object({
2882
- type: z17.literal("response.output_item.added"),
2883
- output_index: z17.number(),
2884
- item: z17.discriminatedUnion("type", [
2885
- z17.object({
2886
- type: z17.literal("message"),
2887
- id: z17.string(),
2888
- phase: z17.enum(["commentary", "final_answer"]).nullish()
3039
+ z18.object({
3040
+ type: z18.literal("response.output_item.added"),
3041
+ output_index: z18.number(),
3042
+ item: z18.discriminatedUnion("type", [
3043
+ z18.object({
3044
+ type: z18.literal("message"),
3045
+ id: z18.string(),
3046
+ phase: z18.enum(["commentary", "final_answer"]).nullish()
2889
3047
  }),
2890
- z17.object({
2891
- type: z17.literal("reasoning"),
2892
- id: z17.string(),
2893
- encrypted_content: z17.string().nullish()
3048
+ z18.object({
3049
+ type: z18.literal("reasoning"),
3050
+ id: z18.string(),
3051
+ encrypted_content: z18.string().nullish()
2894
3052
  }),
2895
- z17.object({
2896
- type: z17.literal("function_call"),
2897
- id: z17.string(),
2898
- call_id: z17.string(),
2899
- name: z17.string(),
2900
- arguments: z17.string(),
2901
- async: z17.boolean().nullish()
3053
+ z18.object({
3054
+ type: z18.literal("function_call"),
3055
+ id: z18.string(),
3056
+ call_id: z18.string(),
3057
+ name: z18.string(),
3058
+ arguments: z18.string(),
3059
+ async: z18.boolean().nullish()
2902
3060
  }),
2903
- z17.object({
2904
- type: z17.literal("web_search_call"),
2905
- id: z17.string(),
2906
- status: z17.string()
3061
+ z18.object({
3062
+ type: z18.literal("web_search_call"),
3063
+ id: z18.string(),
3064
+ status: z18.string()
2907
3065
  }),
2908
- z17.object({
2909
- type: z17.literal("computer_call"),
2910
- id: z17.string(),
2911
- status: z17.string()
3066
+ z18.object({
3067
+ type: z18.literal("computer_call"),
3068
+ id: z18.string(),
3069
+ status: z18.string()
2912
3070
  }),
2913
- z17.object({
2914
- type: z17.literal("file_search_call"),
2915
- id: z17.string()
3071
+ z18.object({
3072
+ type: z18.literal("file_search_call"),
3073
+ id: z18.string()
2916
3074
  }),
2917
- z17.object({
2918
- type: z17.literal("image_generation_call"),
2919
- id: z17.string()
3075
+ z18.object({
3076
+ type: z18.literal("image_generation_call"),
3077
+ id: z18.string()
2920
3078
  }),
2921
- z17.object({
2922
- type: z17.literal("code_interpreter_call"),
2923
- id: z17.string(),
2924
- container_id: z17.string(),
2925
- code: z17.string().nullable(),
2926
- outputs: z17.array(
2927
- z17.discriminatedUnion("type", [
2928
- z17.object({ type: z17.literal("logs"), logs: z17.string() }),
2929
- z17.object({ type: z17.literal("image"), url: z17.string() })
3079
+ z18.object({
3080
+ type: z18.literal("code_interpreter_call"),
3081
+ id: z18.string(),
3082
+ container_id: z18.string(),
3083
+ code: z18.string().nullable(),
3084
+ outputs: z18.array(
3085
+ z18.discriminatedUnion("type", [
3086
+ z18.object({ type: z18.literal("logs"), logs: z18.string() }),
3087
+ z18.object({ type: z18.literal("image"), url: z18.string() })
2930
3088
  ])
2931
3089
  ).nullable(),
2932
- status: z17.string()
3090
+ status: z18.string()
2933
3091
  })
2934
3092
  ])
2935
3093
  }),
2936
- z17.object({
2937
- type: z17.literal("response.output_item.done"),
2938
- output_index: z17.number(),
2939
- item: z17.discriminatedUnion("type", [
2940
- z17.object({
2941
- type: z17.literal("message"),
2942
- id: z17.string(),
2943
- phase: z17.enum(["commentary", "final_answer"]).nullish()
3094
+ z18.object({
3095
+ type: z18.literal("response.output_item.done"),
3096
+ output_index: z18.number(),
3097
+ item: z18.discriminatedUnion("type", [
3098
+ z18.object({
3099
+ type: z18.literal("message"),
3100
+ id: z18.string(),
3101
+ phase: z18.enum(["commentary", "final_answer"]).nullish()
2944
3102
  }),
2945
- z17.object({
2946
- type: z17.literal("reasoning"),
2947
- id: z17.string(),
2948
- encrypted_content: z17.string().nullish()
3103
+ z18.object({
3104
+ type: z18.literal("reasoning"),
3105
+ id: z18.string(),
3106
+ encrypted_content: z18.string().nullish()
2949
3107
  }),
2950
- z17.object({
2951
- type: z17.literal("function_call"),
2952
- id: z17.string(),
2953
- call_id: z17.string(),
2954
- name: z17.string(),
2955
- arguments: z17.string(),
2956
- async: z17.boolean().nullish(),
2957
- status: z17.enum(["in_progress", "completed", "incomplete"])
3108
+ z18.object({
3109
+ type: z18.literal("function_call"),
3110
+ id: z18.string(),
3111
+ call_id: z18.string(),
3112
+ name: z18.string(),
3113
+ arguments: z18.string(),
3114
+ async: z18.boolean().nullish(),
3115
+ status: z18.enum(["in_progress", "completed", "incomplete"])
2958
3116
  }),
2959
- z17.object({
2960
- type: z17.literal("code_interpreter_call"),
2961
- id: z17.string(),
2962
- code: z17.string().nullable(),
2963
- container_id: z17.string(),
2964
- outputs: z17.array(
2965
- z17.discriminatedUnion("type", [
2966
- z17.object({ type: z17.literal("logs"), logs: z17.string() }),
2967
- z17.object({ type: z17.literal("image"), url: z17.string() })
3117
+ z18.object({
3118
+ type: z18.literal("code_interpreter_call"),
3119
+ id: z18.string(),
3120
+ code: z18.string().nullable(),
3121
+ container_id: z18.string(),
3122
+ outputs: z18.array(
3123
+ z18.discriminatedUnion("type", [
3124
+ z18.object({ type: z18.literal("logs"), logs: z18.string() }),
3125
+ z18.object({ type: z18.literal("image"), url: z18.string() })
2968
3126
  ])
2969
3127
  ).nullable()
2970
3128
  }),
2971
- z17.object({
2972
- type: z17.literal("image_generation_call"),
2973
- id: z17.string(),
2974
- result: z17.string()
3129
+ z18.object({
3130
+ type: z18.literal("image_generation_call"),
3131
+ id: z18.string(),
3132
+ result: z18.string()
2975
3133
  }),
2976
- z17.object({
2977
- type: z17.literal("web_search_call"),
2978
- id: z17.string(),
2979
- status: z17.string(),
2980
- action: z17.discriminatedUnion("type", [
2981
- z17.object({
2982
- type: z17.literal("search"),
2983
- query: z17.string().nullish(),
2984
- sources: z17.array(
2985
- z17.discriminatedUnion("type", [
2986
- z17.object({ type: z17.literal("url"), url: z17.string() }),
2987
- z17.object({ type: z17.literal("api"), name: z17.string() })
3134
+ z18.object({
3135
+ type: z18.literal("web_search_call"),
3136
+ id: z18.string(),
3137
+ status: z18.string(),
3138
+ action: z18.discriminatedUnion("type", [
3139
+ z18.object({
3140
+ type: z18.literal("search"),
3141
+ query: z18.string().nullish(),
3142
+ sources: z18.array(
3143
+ z18.discriminatedUnion("type", [
3144
+ z18.object({ type: z18.literal("url"), url: z18.string() }),
3145
+ z18.object({ type: z18.literal("api"), name: z18.string() })
2988
3146
  ])
2989
3147
  ).nullish()
2990
3148
  }),
2991
- z17.object({
2992
- type: z17.literal("open_page"),
2993
- url: z17.string().nullish()
3149
+ z18.object({
3150
+ type: z18.literal("open_page"),
3151
+ url: z18.string().nullish()
2994
3152
  }),
2995
- z17.object({
2996
- type: z17.literal("find_in_page"),
2997
- url: z17.string().nullish(),
2998
- pattern: z17.string().nullish()
3153
+ z18.object({
3154
+ type: z18.literal("find_in_page"),
3155
+ url: z18.string().nullish(),
3156
+ pattern: z18.string().nullish()
2999
3157
  })
3000
3158
  ]).nullish()
3001
3159
  }),
3002
- z17.object({
3003
- type: z17.literal("file_search_call"),
3004
- id: z17.string(),
3005
- queries: z17.array(z17.string()),
3006
- results: z17.array(
3007
- z17.object({
3008
- attributes: z17.record(z17.string(), z17.unknown()),
3009
- file_id: z17.string(),
3010
- filename: z17.string(),
3011
- score: z17.number(),
3012
- text: z17.string()
3160
+ z18.object({
3161
+ type: z18.literal("file_search_call"),
3162
+ id: z18.string(),
3163
+ queries: z18.array(z18.string()),
3164
+ results: z18.array(
3165
+ z18.object({
3166
+ attributes: z18.record(z18.string(), z18.unknown()),
3167
+ file_id: z18.string(),
3168
+ filename: z18.string(),
3169
+ score: z18.number(),
3170
+ text: z18.string()
3013
3171
  })
3014
3172
  ).nullish()
3015
3173
  }),
3016
- z17.object({
3017
- type: z17.literal("local_shell_call"),
3018
- id: z17.string(),
3019
- call_id: z17.string(),
3020
- action: z17.object({
3021
- type: z17.literal("exec"),
3022
- command: z17.array(z17.string()),
3023
- timeout_ms: z17.number().optional(),
3024
- user: z17.string().optional(),
3025
- working_directory: z17.string().optional(),
3026
- env: z17.record(z17.string(), z17.string()).optional()
3174
+ z18.object({
3175
+ type: z18.literal("local_shell_call"),
3176
+ id: z18.string(),
3177
+ call_id: z18.string(),
3178
+ action: z18.object({
3179
+ type: z18.literal("exec"),
3180
+ command: z18.array(z18.string()),
3181
+ timeout_ms: z18.number().optional(),
3182
+ user: z18.string().optional(),
3183
+ working_directory: z18.string().optional(),
3184
+ env: z18.record(z18.string(), z18.string()).optional()
3027
3185
  })
3028
3186
  }),
3029
- z17.object({
3030
- type: z17.literal("computer_call"),
3031
- id: z17.string(),
3032
- status: z17.literal("completed")
3187
+ z18.object({
3188
+ type: z18.literal("computer_call"),
3189
+ id: z18.string(),
3190
+ status: z18.literal("completed")
3033
3191
  })
3034
3192
  ])
3035
3193
  }),
3036
- z17.object({
3037
- type: z17.literal("response.function_call_arguments.delta"),
3038
- item_id: z17.string(),
3039
- output_index: z17.number(),
3040
- delta: z17.string()
3194
+ z18.object({
3195
+ type: z18.literal("response.function_call_arguments.delta"),
3196
+ item_id: z18.string(),
3197
+ output_index: z18.number(),
3198
+ delta: z18.string()
3041
3199
  }),
3042
- z17.object({
3043
- type: z17.literal("response.image_generation_call.partial_image"),
3044
- item_id: z17.string(),
3045
- output_index: z17.number(),
3046
- partial_image_b64: z17.string()
3200
+ z18.object({
3201
+ type: z18.literal("response.image_generation_call.partial_image"),
3202
+ item_id: z18.string(),
3203
+ output_index: z18.number(),
3204
+ partial_image_b64: z18.string()
3047
3205
  }),
3048
- z17.object({
3049
- type: z17.literal("response.code_interpreter_call_code.delta"),
3050
- item_id: z17.string(),
3051
- output_index: z17.number(),
3052
- delta: z17.string()
3206
+ z18.object({
3207
+ type: z18.literal("response.code_interpreter_call_code.delta"),
3208
+ item_id: z18.string(),
3209
+ output_index: z18.number(),
3210
+ delta: z18.string()
3053
3211
  }),
3054
- z17.object({
3055
- type: z17.literal("response.code_interpreter_call_code.done"),
3056
- item_id: z17.string(),
3057
- output_index: z17.number(),
3058
- code: z17.string()
3212
+ z18.object({
3213
+ type: z18.literal("response.code_interpreter_call_code.done"),
3214
+ item_id: z18.string(),
3215
+ output_index: z18.number(),
3216
+ code: z18.string()
3059
3217
  }),
3060
- z17.object({
3061
- type: z17.literal("response.output_text.annotation.added"),
3062
- annotation: z17.discriminatedUnion("type", [
3063
- z17.object({
3064
- type: z17.literal("url_citation"),
3065
- start_index: z17.number(),
3066
- end_index: z17.number(),
3067
- url: z17.string(),
3068
- title: z17.string()
3218
+ z18.object({
3219
+ type: z18.literal("response.output_text.annotation.added"),
3220
+ annotation: z18.discriminatedUnion("type", [
3221
+ z18.object({
3222
+ type: z18.literal("url_citation"),
3223
+ start_index: z18.number(),
3224
+ end_index: z18.number(),
3225
+ url: z18.string(),
3226
+ title: z18.string()
3069
3227
  }),
3070
- z17.object({
3071
- type: z17.literal("file_citation"),
3072
- file_id: z17.string(),
3073
- filename: z17.string().nullish(),
3074
- index: z17.number().nullish(),
3075
- start_index: z17.number().nullish(),
3076
- end_index: z17.number().nullish(),
3077
- quote: z17.string().nullish()
3228
+ z18.object({
3229
+ type: z18.literal("file_citation"),
3230
+ file_id: z18.string(),
3231
+ filename: z18.string().nullish(),
3232
+ index: z18.number().nullish(),
3233
+ start_index: z18.number().nullish(),
3234
+ end_index: z18.number().nullish(),
3235
+ quote: z18.string().nullish()
3078
3236
  })
3079
3237
  ])
3080
3238
  }),
3081
- z17.object({
3082
- type: z17.literal("response.reasoning_summary_part.added"),
3083
- item_id: z17.string(),
3084
- summary_index: z17.number()
3239
+ z18.object({
3240
+ type: z18.literal("response.reasoning_summary_part.added"),
3241
+ item_id: z18.string(),
3242
+ summary_index: z18.number()
3085
3243
  }),
3086
- z17.object({
3087
- type: z17.literal("response.reasoning_summary_text.delta"),
3088
- item_id: z17.string(),
3089
- summary_index: z17.number(),
3090
- delta: z17.string()
3244
+ z18.object({
3245
+ type: z18.literal("response.reasoning_summary_text.delta"),
3246
+ item_id: z18.string(),
3247
+ summary_index: z18.number(),
3248
+ delta: z18.string()
3091
3249
  }),
3092
- z17.object({
3093
- type: z17.literal("response.reasoning_summary_part.done"),
3094
- item_id: z17.string(),
3095
- summary_index: z17.number()
3250
+ z18.object({
3251
+ type: z18.literal("response.reasoning_summary_part.done"),
3252
+ item_id: z18.string(),
3253
+ summary_index: z18.number()
3096
3254
  }),
3097
- z17.object({
3098
- type: z17.literal("error"),
3099
- sequence_number: z17.number(),
3100
- error: z17.object({
3101
- type: z17.string(),
3102
- code: z17.string(),
3103
- message: z17.string(),
3104
- param: z17.string().nullish()
3255
+ z18.object({
3256
+ type: z18.literal("error"),
3257
+ sequence_number: z18.number(),
3258
+ error: z18.object({
3259
+ type: z18.string(),
3260
+ code: z18.string(),
3261
+ message: z18.string(),
3262
+ param: z18.string().nullish()
3105
3263
  })
3106
3264
  }),
3107
- z17.object({ type: z17.string() }).loose().transform((value) => ({
3265
+ z18.object({ type: z18.string() }).loose().transform((value) => ({
3108
3266
  type: "unknown_chunk",
3109
3267
  message: value.type
3110
3268
  }))
@@ -3112,392 +3270,203 @@ var openaiResponsesChunkSchema = lazyValidator9(
3112
3270
  ])
3113
3271
  )
3114
3272
  );
3115
- var openaiResponsesResponseSchema = lazyValidator9(
3116
- () => zodSchema15(
3117
- z17.object({
3118
- id: z17.string().optional(),
3119
- created_at: z17.number().optional(),
3120
- error: z17.object({
3121
- message: z17.string(),
3122
- type: z17.string(),
3123
- param: z17.string().nullish(),
3124
- code: z17.string()
3273
+ var openaiResponsesResponseSchema = lazyValidator10(
3274
+ () => zodSchema16(
3275
+ z18.object({
3276
+ id: z18.string().optional(),
3277
+ created_at: z18.number().optional(),
3278
+ error: z18.object({
3279
+ message: z18.string(),
3280
+ type: z18.string(),
3281
+ param: z18.string().nullish(),
3282
+ code: z18.string()
3125
3283
  }).nullish(),
3126
- model: z17.string().optional(),
3127
- output: z17.array(
3128
- z17.discriminatedUnion("type", [
3129
- z17.object({
3130
- type: z17.literal("message"),
3131
- role: z17.literal("assistant"),
3132
- id: z17.string(),
3133
- phase: z17.enum(["commentary", "final_answer"]).nullish(),
3134
- content: z17.array(
3135
- z17.object({
3136
- type: z17.literal("output_text"),
3137
- text: z17.string(),
3138
- logprobs: z17.array(
3139
- z17.object({
3140
- token: z17.string(),
3141
- logprob: z17.number(),
3142
- top_logprobs: z17.array(
3143
- z17.object({
3144
- token: z17.string(),
3145
- logprob: z17.number()
3284
+ model: z18.string().optional(),
3285
+ output: z18.array(
3286
+ z18.discriminatedUnion("type", [
3287
+ z18.object({
3288
+ type: z18.literal("message"),
3289
+ role: z18.literal("assistant"),
3290
+ id: z18.string(),
3291
+ phase: z18.enum(["commentary", "final_answer"]).nullish(),
3292
+ content: z18.array(
3293
+ z18.object({
3294
+ type: z18.literal("output_text"),
3295
+ text: z18.string(),
3296
+ logprobs: z18.array(
3297
+ z18.object({
3298
+ token: z18.string(),
3299
+ logprob: z18.number(),
3300
+ top_logprobs: z18.array(
3301
+ z18.object({
3302
+ token: z18.string(),
3303
+ logprob: z18.number()
3146
3304
  })
3147
3305
  )
3148
3306
  })
3149
3307
  ).nullish(),
3150
- annotations: z17.array(
3151
- z17.discriminatedUnion("type", [
3152
- z17.object({
3153
- type: z17.literal("url_citation"),
3154
- start_index: z17.number(),
3155
- end_index: z17.number(),
3156
- url: z17.string(),
3157
- title: z17.string()
3308
+ annotations: z18.array(
3309
+ z18.discriminatedUnion("type", [
3310
+ z18.object({
3311
+ type: z18.literal("url_citation"),
3312
+ start_index: z18.number(),
3313
+ end_index: z18.number(),
3314
+ url: z18.string(),
3315
+ title: z18.string()
3158
3316
  }),
3159
- z17.object({
3160
- type: z17.literal("file_citation"),
3161
- file_id: z17.string(),
3162
- filename: z17.string().nullish(),
3163
- index: z17.number().nullish(),
3164
- start_index: z17.number().nullish(),
3165
- end_index: z17.number().nullish(),
3166
- quote: z17.string().nullish()
3317
+ z18.object({
3318
+ type: z18.literal("file_citation"),
3319
+ file_id: z18.string(),
3320
+ filename: z18.string().nullish(),
3321
+ index: z18.number().nullish(),
3322
+ start_index: z18.number().nullish(),
3323
+ end_index: z18.number().nullish(),
3324
+ quote: z18.string().nullish()
3167
3325
  }),
3168
- z17.object({
3169
- type: z17.literal("container_file_citation"),
3170
- container_id: z17.string(),
3171
- file_id: z17.string(),
3172
- filename: z17.string().nullish(),
3173
- start_index: z17.number().nullish(),
3174
- end_index: z17.number().nullish(),
3175
- index: z17.number().nullish()
3326
+ z18.object({
3327
+ type: z18.literal("container_file_citation"),
3328
+ container_id: z18.string(),
3329
+ file_id: z18.string(),
3330
+ filename: z18.string().nullish(),
3331
+ start_index: z18.number().nullish(),
3332
+ end_index: z18.number().nullish(),
3333
+ index: z18.number().nullish()
3176
3334
  }),
3177
- z17.object({
3178
- type: z17.literal("file_path"),
3179
- file_id: z17.string(),
3180
- index: z17.number().nullish()
3335
+ z18.object({
3336
+ type: z18.literal("file_path"),
3337
+ file_id: z18.string(),
3338
+ index: z18.number().nullish()
3181
3339
  })
3182
3340
  ])
3183
3341
  )
3184
3342
  })
3185
3343
  )
3186
3344
  }),
3187
- z17.object({
3188
- type: z17.literal("web_search_call"),
3189
- id: z17.string(),
3190
- status: z17.string(),
3191
- action: z17.discriminatedUnion("type", [
3192
- z17.object({
3193
- type: z17.literal("search"),
3194
- query: z17.string().nullish(),
3195
- sources: z17.array(
3196
- z17.discriminatedUnion("type", [
3197
- z17.object({ type: z17.literal("url"), url: z17.string() }),
3198
- z17.object({
3199
- type: z17.literal("api"),
3200
- name: z17.string()
3345
+ z18.object({
3346
+ type: z18.literal("web_search_call"),
3347
+ id: z18.string(),
3348
+ status: z18.string(),
3349
+ action: z18.discriminatedUnion("type", [
3350
+ z18.object({
3351
+ type: z18.literal("search"),
3352
+ query: z18.string().nullish(),
3353
+ sources: z18.array(
3354
+ z18.discriminatedUnion("type", [
3355
+ z18.object({ type: z18.literal("url"), url: z18.string() }),
3356
+ z18.object({
3357
+ type: z18.literal("api"),
3358
+ name: z18.string()
3201
3359
  })
3202
3360
  ])
3203
3361
  ).nullish()
3204
3362
  }),
3205
- z17.object({
3206
- type: z17.literal("open_page"),
3207
- url: z17.string().nullish()
3363
+ z18.object({
3364
+ type: z18.literal("open_page"),
3365
+ url: z18.string().nullish()
3208
3366
  }),
3209
- z17.object({
3210
- type: z17.literal("find_in_page"),
3211
- url: z17.string().nullish(),
3212
- pattern: z17.string().nullish()
3367
+ z18.object({
3368
+ type: z18.literal("find_in_page"),
3369
+ url: z18.string().nullish(),
3370
+ pattern: z18.string().nullish()
3213
3371
  })
3214
3372
  ]).nullish()
3215
3373
  }),
3216
- z17.object({
3217
- type: z17.literal("file_search_call"),
3218
- id: z17.string(),
3219
- queries: z17.array(z17.string()),
3220
- results: z17.array(
3221
- z17.object({
3222
- attributes: z17.record(
3223
- z17.string(),
3224
- z17.union([z17.string(), z17.number(), z17.boolean()])
3374
+ z18.object({
3375
+ type: z18.literal("file_search_call"),
3376
+ id: z18.string(),
3377
+ queries: z18.array(z18.string()),
3378
+ results: z18.array(
3379
+ z18.object({
3380
+ attributes: z18.record(
3381
+ z18.string(),
3382
+ z18.union([z18.string(), z18.number(), z18.boolean()])
3225
3383
  ),
3226
- file_id: z17.string(),
3227
- filename: z17.string(),
3228
- score: z17.number(),
3229
- text: z17.string()
3384
+ file_id: z18.string(),
3385
+ filename: z18.string(),
3386
+ score: z18.number(),
3387
+ text: z18.string()
3230
3388
  })
3231
3389
  ).nullish()
3232
3390
  }),
3233
- z17.object({
3234
- type: z17.literal("code_interpreter_call"),
3235
- id: z17.string(),
3236
- code: z17.string().nullable(),
3237
- container_id: z17.string(),
3238
- outputs: z17.array(
3239
- z17.discriminatedUnion("type", [
3240
- z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3241
- z17.object({ type: z17.literal("image"), url: z17.string() })
3391
+ z18.object({
3392
+ type: z18.literal("code_interpreter_call"),
3393
+ id: z18.string(),
3394
+ code: z18.string().nullable(),
3395
+ container_id: z18.string(),
3396
+ outputs: z18.array(
3397
+ z18.discriminatedUnion("type", [
3398
+ z18.object({ type: z18.literal("logs"), logs: z18.string() }),
3399
+ z18.object({ type: z18.literal("image"), url: z18.string() })
3242
3400
  ])
3243
3401
  ).nullable()
3244
3402
  }),
3245
- z17.object({
3246
- type: z17.literal("image_generation_call"),
3247
- id: z17.string(),
3248
- result: z17.string()
3403
+ z18.object({
3404
+ type: z18.literal("image_generation_call"),
3405
+ id: z18.string(),
3406
+ result: z18.string()
3249
3407
  }),
3250
- z17.object({
3251
- type: z17.literal("local_shell_call"),
3252
- id: z17.string(),
3253
- call_id: z17.string(),
3254
- action: z17.object({
3255
- type: z17.literal("exec"),
3256
- command: z17.array(z17.string()),
3257
- timeout_ms: z17.number().optional(),
3258
- user: z17.string().optional(),
3259
- working_directory: z17.string().optional(),
3260
- env: z17.record(z17.string(), z17.string()).optional()
3408
+ z18.object({
3409
+ type: z18.literal("local_shell_call"),
3410
+ id: z18.string(),
3411
+ call_id: z18.string(),
3412
+ action: z18.object({
3413
+ type: z18.literal("exec"),
3414
+ command: z18.array(z18.string()),
3415
+ timeout_ms: z18.number().optional(),
3416
+ user: z18.string().optional(),
3417
+ working_directory: z18.string().optional(),
3418
+ env: z18.record(z18.string(), z18.string()).optional()
3261
3419
  })
3262
3420
  }),
3263
- z17.object({
3264
- type: z17.literal("function_call"),
3265
- call_id: z17.string(),
3266
- name: z17.string(),
3267
- arguments: z17.string(),
3268
- id: z17.string(),
3269
- async: z17.boolean().nullish()
3421
+ z18.object({
3422
+ type: z18.literal("function_call"),
3423
+ call_id: z18.string(),
3424
+ name: z18.string(),
3425
+ arguments: z18.string(),
3426
+ id: z18.string(),
3427
+ async: z18.boolean().nullish()
3270
3428
  }),
3271
- z17.object({
3272
- type: z17.literal("computer_call"),
3273
- id: z17.string(),
3274
- status: z17.string().optional()
3429
+ z18.object({
3430
+ type: z18.literal("computer_call"),
3431
+ id: z18.string(),
3432
+ status: z18.string().optional()
3275
3433
  }),
3276
- z17.object({
3277
- type: z17.literal("reasoning"),
3278
- id: z17.string(),
3279
- encrypted_content: z17.string().nullish(),
3280
- summary: z17.array(
3281
- z17.object({
3282
- type: z17.literal("summary_text"),
3283
- text: z17.string()
3434
+ z18.object({
3435
+ type: z18.literal("reasoning"),
3436
+ id: z18.string(),
3437
+ encrypted_content: z18.string().nullish(),
3438
+ summary: z18.array(
3439
+ z18.object({
3440
+ type: z18.literal("summary_text"),
3441
+ text: z18.string()
3284
3442
  })
3285
3443
  )
3286
3444
  })
3287
3445
  ])
3288
3446
  ).optional(),
3289
- service_tier: z17.string().nullish(),
3290
- reasoning: z17.object({
3291
- context: z17.string().nullish()
3447
+ service_tier: z18.string().nullish(),
3448
+ reasoning: z18.object({
3449
+ context: z18.string().nullish()
3292
3450
  }).nullish(),
3293
- incomplete_details: z17.object({ reason: z17.string() }).nullish(),
3294
- usage: z17.object({
3295
- input_tokens: z17.number(),
3296
- input_tokens_details: z17.object({
3297
- cached_tokens: z17.number().nullish(),
3298
- cache_write_tokens: z17.number().nullish(),
3299
- orchestration_input_tokens: z17.number().nullish(),
3300
- orchestration_input_cached_tokens: z17.number().nullish()
3451
+ incomplete_details: z18.object({ reason: z18.string() }).nullish(),
3452
+ usage: z18.object({
3453
+ input_tokens: z18.number(),
3454
+ input_tokens_details: z18.object({
3455
+ cached_tokens: z18.number().nullish(),
3456
+ cache_write_tokens: z18.number().nullish(),
3457
+ orchestration_input_tokens: z18.number().nullish(),
3458
+ orchestration_input_cached_tokens: z18.number().nullish()
3301
3459
  }).nullish(),
3302
- output_tokens: z17.number(),
3303
- output_tokens_details: z17.object({
3304
- reasoning_tokens: z17.number().nullish(),
3305
- orchestration_output_tokens: z17.number().nullish()
3460
+ output_tokens: z18.number(),
3461
+ output_tokens_details: z18.object({
3462
+ reasoning_tokens: z18.number().nullish(),
3463
+ orchestration_output_tokens: z18.number().nullish()
3306
3464
  }).nullish()
3307
3465
  }).optional()
3308
3466
  })
3309
3467
  )
3310
3468
  );
3311
3469
 
3312
- // src/responses/openai-responses-options.ts
3313
- import {
3314
- lazyValidator as lazyValidator10,
3315
- zodSchema as zodSchema16
3316
- } from "@ai-sdk/provider-utils";
3317
- import { z as z18 } from "zod/v4";
3318
- var TOP_LOGPROBS_MAX = 20;
3319
- var openaiResponsesReasoningModelIds = [
3320
- "o1",
3321
- "o1-2024-12-17",
3322
- "o3",
3323
- "o3-2025-04-16",
3324
- "o3-deep-research",
3325
- "o3-deep-research-2025-06-26",
3326
- "o3-mini",
3327
- "o3-mini-2025-01-31",
3328
- "o4-mini",
3329
- "o4-mini-2025-04-16",
3330
- "o4-mini-deep-research",
3331
- "o4-mini-deep-research-2025-06-26",
3332
- "codex-mini-latest",
3333
- "computer-use-preview",
3334
- "gpt-5",
3335
- "gpt-5-2025-08-07",
3336
- "gpt-5-codex",
3337
- "gpt-5-mini",
3338
- "gpt-5-mini-2025-08-07",
3339
- "gpt-5-nano",
3340
- "gpt-5-nano-2025-08-07",
3341
- "gpt-5-pro",
3342
- "gpt-5-pro-2025-10-06",
3343
- "gpt-5.1",
3344
- "gpt-5.1-chat-latest",
3345
- "gpt-5.1-codex-mini",
3346
- "gpt-5.1-codex",
3347
- "gpt-5.1-codex-max",
3348
- "gpt-5.2",
3349
- "gpt-5.2-chat-latest",
3350
- "gpt-5.2-pro",
3351
- "gpt-5.2-codex",
3352
- "gpt-5.3-chat-latest",
3353
- "gpt-5.3-codex",
3354
- "gpt-5.4",
3355
- "gpt-5.4-2026-03-05",
3356
- "gpt-5.4-mini",
3357
- "gpt-5.4-mini-2026-03-17",
3358
- "gpt-5.4-nano",
3359
- "gpt-5.4-nano-2026-03-17",
3360
- "gpt-5.4-pro",
3361
- "gpt-5.4-pro-2026-03-05",
3362
- "gpt-5.6",
3363
- "gpt-5.6-luna",
3364
- "gpt-5.6-sol",
3365
- "gpt-5.6-terra",
3366
- "gpt-6-astra",
3367
- "gpt-6-luna",
3368
- "gpt-6-sol"
3369
- ];
3370
- var openaiResponsesModelIds = [
3371
- "gpt-4.1",
3372
- "gpt-4.1-2025-04-14",
3373
- "gpt-4.1-mini",
3374
- "gpt-4.1-mini-2025-04-14",
3375
- "gpt-4.1-nano",
3376
- "gpt-4.1-nano-2025-04-14",
3377
- "gpt-4o",
3378
- "gpt-4o-2024-05-13",
3379
- "gpt-4o-2024-08-06",
3380
- "gpt-4o-2024-11-20",
3381
- "gpt-4o-audio-preview",
3382
- "gpt-4o-audio-preview-2024-10-01",
3383
- "gpt-4o-audio-preview-2024-12-17",
3384
- "gpt-4o-search-preview",
3385
- "gpt-4o-search-preview-2025-03-11",
3386
- "gpt-4o-mini-search-preview",
3387
- "gpt-4o-mini-search-preview-2025-03-11",
3388
- "gpt-4o-mini",
3389
- "gpt-4o-mini-2024-07-18",
3390
- "gpt-4-turbo",
3391
- "gpt-4-turbo-2024-04-09",
3392
- "gpt-4-turbo-preview",
3393
- "gpt-4-0125-preview",
3394
- "gpt-4-1106-preview",
3395
- "gpt-4",
3396
- "gpt-4-0613",
3397
- "gpt-4.5-preview",
3398
- "gpt-4.5-preview-2025-02-27",
3399
- "gpt-3.5-turbo-0125",
3400
- "gpt-3.5-turbo",
3401
- "gpt-3.5-turbo-1106",
3402
- "chatgpt-4o-latest",
3403
- "gpt-5-chat-latest",
3404
- ...openaiResponsesReasoningModelIds
3405
- ];
3406
- var openaiResponsesProviderOptionsSchema = lazyValidator10(
3407
- () => zodSchema16(
3408
- z18.object({
3409
- conversation: z18.string().nullish(),
3410
- include: z18.array(
3411
- z18.enum([
3412
- "reasoning.encrypted_content",
3413
- // handled internally by default, only needed for unknown reasoning models
3414
- "file_search_call.results",
3415
- "message.output_text.logprobs"
3416
- ])
3417
- ).nullish(),
3418
- instructions: z18.string().nullish(),
3419
- /**
3420
- * Return the log probabilities of the tokens.
3421
- *
3422
- * Setting to true will return the log probabilities of the tokens that
3423
- * were generated.
3424
- *
3425
- * Setting to a number will return the log probabilities of the top n
3426
- * tokens that were generated.
3427
- *
3428
- * @see https://platform.openai.com/docs/api-reference/responses/create
3429
- * @see https://cookbook.openai.com/examples/using_logprobs
3430
- */
3431
- logprobs: z18.union([z18.boolean(), z18.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3432
- /**
3433
- * The maximum number of total calls to built-in tools that can be processed in a response.
3434
- * This maximum number applies across all built-in tool calls, not per individual tool.
3435
- * Any further attempts to call a tool by the model will be ignored.
3436
- */
3437
- maxToolCalls: z18.number().nullish(),
3438
- metadata: z18.any().nullish(),
3439
- parallelToolCalls: z18.boolean().nullish(),
3440
- previousResponseId: z18.string().nullish(),
3441
- promptCacheKey: z18.string().nullish(),
3442
- /**
3443
- * Prompt cache behavior for GPT-5.6 and later models.
3444
- * `mode` controls whether OpenAI also places an implicit breakpoint.
3445
- * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
3446
- */
3447
- promptCacheOptions: z18.object({
3448
- mode: z18.enum(["implicit", "explicit"]).optional(),
3449
- ttl: z18.literal("30m").optional()
3450
- }).optional(),
3451
- /**
3452
- * The retention policy for the prompt cache.
3453
- * - 'in_memory': Default. Standard prompt caching behavior.
3454
- * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
3455
- * Available for models before GPT-5.6 that support extended caching.
3456
- *
3457
- * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
3458
- *
3459
- * @default 'in_memory'
3460
- */
3461
- promptCacheRetention: z18.enum(["in_memory", "24h"]).nullish(),
3462
- /**
3463
- * Reasoning effort for reasoning models. Defaults to `medium`. If you use
3464
- * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
3465
- * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
3466
- * Supported values vary by model.
3467
- */
3468
- reasoningEffort: z18.string().nullish(),
3469
- /**
3470
- * Updates the reasoning effort for GPT-6 and later models starting with this response
3471
- * without changing the request-level reasoning effort. This preserves the
3472
- * request prefix for prompt caching.
3473
- *
3474
- * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
3475
- * combined with automatic truncation.
3476
- */
3477
- reasoningEffortUpdate: z18.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
3478
- /**
3479
- * Controls how much model work GPT-5.6 performs before returning a final answer.
3480
- * `standard` is the default. `pro` increases quality, latency, and token usage.
3481
- */
3482
- reasoningMode: z18.enum(["standard", "pro"]).optional(),
3483
- /**
3484
- * Controls which available reasoning items GPT-5.6 can use.
3485
- * `auto` uses the model default, `current_turn` excludes reasoning from earlier
3486
- * turns, and `all_turns` makes compatible earlier reasoning available.
3487
- */
3488
- reasoningContext: z18.enum(["auto", "current_turn", "all_turns"]).optional(),
3489
- reasoningSummary: z18.string().nullish(),
3490
- safetyIdentifier: z18.string().nullish(),
3491
- serviceTier: z18.enum(["auto", "flex", "priority", "default"]).nullish(),
3492
- store: z18.boolean().nullish(),
3493
- strictJsonSchema: z18.boolean().nullish(),
3494
- textVerbosity: z18.enum(["low", "medium", "high"]).nullish(),
3495
- truncation: z18.enum(["auto", "disabled"]).nullish(),
3496
- user: z18.string().nullish()
3497
- })
3498
- )
3499
- );
3500
-
3501
3470
  // src/responses/openai-responses-prepare-tools.ts
3502
3471
  import {
3503
3472
  UnsupportedFunctionalityError as UnsupportedFunctionalityError5
@@ -3672,6 +3641,18 @@ function resolveAsyncToolOption({
3672
3641
  }
3673
3642
 
3674
3643
  // src/responses/openai-responses-language-model.ts
3644
+ function getConfigurationUpdateUnsupportedReason({
3645
+ modelCapabilities,
3646
+ options
3647
+ }) {
3648
+ if (!modelCapabilities.supportsConfigurationUpdate) {
3649
+ return "reasoningEffortUpdate is only supported by GPT-6 and later models";
3650
+ }
3651
+ if ((options == null ? void 0 : options.reasoningMode) === "pro" || (options == null ? void 0 : options.truncation) === "auto") {
3652
+ return "reasoningEffortUpdate requires standard reasoning mode without automatic truncation";
3653
+ }
3654
+ return void 0;
3655
+ }
3675
3656
  var OpenAIResponsesLanguageModel = class {
3676
3657
  constructor(modelId, config) {
3677
3658
  this.specificationVersion = "v2";
@@ -3736,8 +3717,14 @@ var OpenAIResponsesLanguageModel = class {
3736
3717
  details: "conversation and previousResponseId cannot be used together"
3737
3718
  });
3738
3719
  }
3720
+ const configurationUpdateUnsupportedReason = getConfigurationUpdateUnsupportedReason({
3721
+ modelCapabilities,
3722
+ options: openaiOptions
3723
+ });
3739
3724
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
3740
3725
  prompt,
3726
+ configurationUpdateUnsupportedReason,
3727
+ providerOptionsName: this.config.provider.includes("azure") ? "azure" : "openai",
3741
3728
  systemMessageMode: modelCapabilities.systemMessageMode,
3742
3729
  explicitMessageItemType: this.config.explicitMessageItemType,
3743
3730
  fileIdPrefixes: this.config.fileIdPrefixes,
@@ -3757,18 +3744,27 @@ var OpenAIResponsesLanguageModel = class {
3757
3744
  resolvedReasoningEffort = void 0;
3758
3745
  }
3759
3746
  const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
3760
- const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
3761
- if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
3747
+ if (reasoningEffortUpdate != null && configurationUpdateUnsupportedReason != null) {
3762
3748
  warnings.push({
3763
3749
  type: "unsupported-setting",
3764
3750
  setting: "reasoningEffortUpdate",
3765
- details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
3751
+ details: configurationUpdateUnsupportedReason
3766
3752
  });
3767
3753
  } else if (reasoningEffortUpdate != null) {
3768
- input.unshift({
3769
- type: "configuration_update",
3770
- reasoning: { effort: reasoningEffortUpdate }
3771
- });
3754
+ const firstItem = input[0];
3755
+ if ((firstItem == null ? void 0 : firstItem.type) !== "configuration_update" || firstItem.reasoning.effort !== reasoningEffortUpdate) {
3756
+ input.unshift({
3757
+ type: "configuration_update",
3758
+ reasoning: { effort: reasoningEffortUpdate }
3759
+ });
3760
+ }
3761
+ }
3762
+ for (let i = 1; i < input.length; i++) {
3763
+ if (input[i - 1].type === "configuration_update" && input[i].type === "configuration_update") {
3764
+ throw new UnsupportedFunctionalityError6({
3765
+ functionality: "Adjacent reasoning effort configuration updates"
3766
+ });
3767
+ }
3772
3768
  }
3773
3769
  const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
3774
3770
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
@@ -5239,7 +5235,7 @@ var OpenAITranscriptionModel = class {
5239
5235
  };
5240
5236
 
5241
5237
  // src/version.ts
5242
- var VERSION = true ? "2.0.129" : "0.0.0-test";
5238
+ var VERSION = true ? "2.0.131" : "0.0.0-test";
5243
5239
 
5244
5240
  // src/openai-provider.ts
5245
5241
  function createOpenAI(options = {}) {