@ai-sdk/openai 3.0.32 → 3.0.34

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.
@@ -1756,9 +1756,11 @@ var modelMaxImagesPerCall = {
1756
1756
  "dall-e-2": 10,
1757
1757
  "gpt-image-1": 10,
1758
1758
  "gpt-image-1-mini": 10,
1759
- "gpt-image-1.5": 10
1759
+ "gpt-image-1.5": 10,
1760
+ "chatgpt-image-latest": 10
1760
1761
  };
1761
1762
  var defaultResponseFormatPrefixes = [
1763
+ "chatgpt-image-",
1762
1764
  "gpt-image-1-mini",
1763
1765
  "gpt-image-1.5",
1764
1766
  "gpt-image-1"
@@ -2585,7 +2587,7 @@ async function convertToOpenAIResponsesInput({
2585
2587
  hasShellTool = false,
2586
2588
  hasApplyPatchTool = false
2587
2589
  }) {
2588
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2590
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2589
2591
  const input = [];
2590
2592
  const warnings = [];
2591
2593
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -2666,7 +2668,9 @@ async function convertToOpenAIResponsesInput({
2666
2668
  for (const part of content) {
2667
2669
  switch (part.type) {
2668
2670
  case "text": {
2669
- const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName]) == null ? void 0 : _b.itemId;
2671
+ const providerOpts = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName];
2672
+ const id = providerOpts == null ? void 0 : providerOpts.itemId;
2673
+ const phase = providerOpts == null ? void 0 : providerOpts.phase;
2670
2674
  if (hasConversation && id != null) {
2671
2675
  break;
2672
2676
  }
@@ -2677,12 +2681,13 @@ async function convertToOpenAIResponsesInput({
2677
2681
  input.push({
2678
2682
  role: "assistant",
2679
2683
  content: [{ type: "output_text", text: part.text }],
2680
- id
2684
+ id,
2685
+ ...phase != null && { phase }
2681
2686
  });
2682
2687
  break;
2683
2688
  }
2684
2689
  case "tool-call": {
2685
- const id = (_g = (_d = (_c = part.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.itemId) != null ? _g : (_f = (_e = part.providerMetadata) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.itemId;
2690
+ const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
2686
2691
  if (hasConversation && id != null) {
2687
2692
  break;
2688
2693
  }
@@ -2793,7 +2798,7 @@ async function convertToOpenAIResponsesInput({
2793
2798
  break;
2794
2799
  }
2795
2800
  if (store) {
2796
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2801
+ const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
2797
2802
  input.push({ type: "item_reference", id: itemId });
2798
2803
  } else {
2799
2804
  warnings.push({
@@ -2887,7 +2892,7 @@ async function convertToOpenAIResponsesInput({
2887
2892
  }
2888
2893
  const output = part.output;
2889
2894
  if (output.type === "execution-denied") {
2890
- const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
2895
+ const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
2891
2896
  if (approvalId) {
2892
2897
  continue;
2893
2898
  }
@@ -2946,7 +2951,7 @@ async function convertToOpenAIResponsesInput({
2946
2951
  contentValue = output.value;
2947
2952
  break;
2948
2953
  case "execution-denied":
2949
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
2954
+ contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
2950
2955
  break;
2951
2956
  case "json":
2952
2957
  case "error-json":
@@ -3079,7 +3084,8 @@ var openaiResponsesChunkSchema = lazySchema14(
3079
3084
  item: z16.discriminatedUnion("type", [
3080
3085
  z16.object({
3081
3086
  type: z16.literal("message"),
3082
- id: z16.string()
3087
+ id: z16.string(),
3088
+ phase: z16.enum(["commentary", "final_answer"]).nullish()
3083
3089
  }),
3084
3090
  z16.object({
3085
3091
  type: z16.literal("reasoning"),
@@ -3196,7 +3202,8 @@ var openaiResponsesChunkSchema = lazySchema14(
3196
3202
  item: z16.discriminatedUnion("type", [
3197
3203
  z16.object({
3198
3204
  type: z16.literal("message"),
3199
- id: z16.string()
3205
+ id: z16.string(),
3206
+ phase: z16.enum(["commentary", "final_answer"]).nullish()
3200
3207
  }),
3201
3208
  z16.object({
3202
3209
  type: z16.literal("reasoning"),
@@ -3508,6 +3515,7 @@ var openaiResponsesResponseSchema = lazySchema14(
3508
3515
  type: z16.literal("message"),
3509
3516
  role: z16.literal("assistant"),
3510
3517
  id: z16.string(),
3518
+ phase: z16.enum(["commentary", "final_answer"]).nullish(),
3511
3519
  content: z16.array(
3512
3520
  z16.object({
3513
3521
  type: z16.literal("output_text"),
@@ -4958,6 +4966,7 @@ var OpenAIResponsesLanguageModel = class {
4958
4966
  }
4959
4967
  const providerMetadata2 = {
4960
4968
  itemId: part.id,
4969
+ ...part.phase != null && { phase: part.phase },
4961
4970
  ...contentPart.annotations.length > 0 && {
4962
4971
  annotations: contentPart.annotations
4963
4972
  }
@@ -5272,6 +5281,7 @@ var OpenAIResponsesLanguageModel = class {
5272
5281
  let responseId = null;
5273
5282
  const ongoingToolCalls = {};
5274
5283
  const ongoingAnnotations = [];
5284
+ let activeMessagePhase;
5275
5285
  let hasFunctionCall = false;
5276
5286
  const activeReasoning = {};
5277
5287
  let serviceTier;
@@ -5282,7 +5292,7 @@ var OpenAIResponsesLanguageModel = class {
5282
5292
  controller.enqueue({ type: "stream-start", warnings });
5283
5293
  },
5284
5294
  transform(chunk, controller) {
5285
- 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;
5295
+ 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;
5286
5296
  if (options.includeRawChunks) {
5287
5297
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5288
5298
  }
@@ -5423,12 +5433,16 @@ var OpenAIResponsesLanguageModel = class {
5423
5433
  } else if (value.item.type === "shell_call_output") {
5424
5434
  } else if (value.item.type === "message") {
5425
5435
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
5436
+ activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
5426
5437
  controller.enqueue({
5427
5438
  type: "text-start",
5428
5439
  id: value.item.id,
5429
5440
  providerMetadata: {
5430
5441
  [providerOptionsName]: {
5431
- itemId: value.item.id
5442
+ itemId: value.item.id,
5443
+ ...value.item.phase != null && {
5444
+ phase: value.item.phase
5445
+ }
5432
5446
  }
5433
5447
  }
5434
5448
  });
@@ -5443,19 +5457,22 @@ var OpenAIResponsesLanguageModel = class {
5443
5457
  providerMetadata: {
5444
5458
  [providerOptionsName]: {
5445
5459
  itemId: value.item.id,
5446
- reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
5460
+ reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
5447
5461
  }
5448
5462
  }
5449
5463
  });
5450
5464
  }
5451
5465
  } else if (isResponseOutputItemDoneChunk(value)) {
5452
5466
  if (value.item.type === "message") {
5467
+ const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
5468
+ activeMessagePhase = void 0;
5453
5469
  controller.enqueue({
5454
5470
  type: "text-end",
5455
5471
  id: value.item.id,
5456
5472
  providerMetadata: {
5457
5473
  [providerOptionsName]: {
5458
5474
  itemId: value.item.id,
5475
+ ...phase != null && { phase },
5459
5476
  ...ongoingAnnotations.length > 0 && {
5460
5477
  annotations: ongoingAnnotations
5461
5478
  }
@@ -5520,13 +5537,13 @@ var OpenAIResponsesLanguageModel = class {
5520
5537
  toolName: toolNameMapping.toCustomToolName("file_search"),
5521
5538
  result: {
5522
5539
  queries: value.item.queries,
5523
- results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
5540
+ results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
5524
5541
  attributes: result.attributes,
5525
5542
  fileId: result.file_id,
5526
5543
  filename: result.filename,
5527
5544
  score: result.score,
5528
5545
  text: result.text
5529
- }))) != null ? _c : null
5546
+ }))) != null ? _e : null
5530
5547
  }
5531
5548
  });
5532
5549
  } else if (value.item.type === "code_interpreter_call") {
@@ -5550,10 +5567,10 @@ var OpenAIResponsesLanguageModel = class {
5550
5567
  });
5551
5568
  } else if (value.item.type === "mcp_call") {
5552
5569
  ongoingToolCalls[value.output_index] = void 0;
5553
- const approvalRequestId = (_d = value.item.approval_request_id) != null ? _d : void 0;
5554
- const aliasedToolCallId = approvalRequestId != null ? (_f = (_e = approvalRequestIdToDummyToolCallIdFromStream.get(
5570
+ const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
5571
+ const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
5555
5572
  approvalRequestId
5556
- )) != null ? _e : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _f : value.item.id : value.item.id;
5573
+ )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
5557
5574
  const toolName = `mcp.${value.item.name}`;
5558
5575
  controller.enqueue({
5559
5576
  type: "tool-call",
@@ -5623,8 +5640,8 @@ var OpenAIResponsesLanguageModel = class {
5623
5640
  ongoingToolCalls[value.output_index] = void 0;
5624
5641
  } else if (value.item.type === "mcp_approval_request") {
5625
5642
  ongoingToolCalls[value.output_index] = void 0;
5626
- const dummyToolCallId = (_i = (_h = (_g = self.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2();
5627
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : value.item.id;
5643
+ const dummyToolCallId = (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId2();
5644
+ const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
5628
5645
  approvalRequestIdToDummyToolCallIdFromStream.set(
5629
5646
  approvalRequestId,
5630
5647
  dummyToolCallId
@@ -5713,7 +5730,7 @@ var OpenAIResponsesLanguageModel = class {
5713
5730
  providerMetadata: {
5714
5731
  [providerOptionsName]: {
5715
5732
  itemId: value.item.id,
5716
- reasoningEncryptedContent: (_k = value.item.encrypted_content) != null ? _k : null
5733
+ reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
5717
5734
  }
5718
5735
  }
5719
5736
  });
@@ -5817,7 +5834,7 @@ var OpenAIResponsesLanguageModel = class {
5817
5834
  id: value.item_id,
5818
5835
  delta: value.delta
5819
5836
  });
5820
- if (((_m = (_l = options.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.logprobs) && value.logprobs) {
5837
+ if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
5821
5838
  logprobs.push(value.logprobs);
5822
5839
  }
5823
5840
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -5846,7 +5863,7 @@ var OpenAIResponsesLanguageModel = class {
5846
5863
  providerMetadata: {
5847
5864
  [providerOptionsName]: {
5848
5865
  itemId: value.item_id,
5849
- reasoningEncryptedContent: (_o = (_n = activeReasoning[value.item_id]) == null ? void 0 : _n.encryptedContent) != null ? _o : null
5866
+ reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
5850
5867
  }
5851
5868
  }
5852
5869
  });
@@ -5880,10 +5897,10 @@ var OpenAIResponsesLanguageModel = class {
5880
5897
  } else if (isResponseFinishedChunk(value)) {
5881
5898
  finishReason = {
5882
5899
  unified: mapOpenAIResponseFinishReason({
5883
- finishReason: (_p = value.response.incomplete_details) == null ? void 0 : _p.reason,
5900
+ finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
5884
5901
  hasFunctionCall
5885
5902
  }),
5886
- raw: (_r = (_q = value.response.incomplete_details) == null ? void 0 : _q.reason) != null ? _r : void 0
5903
+ raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
5887
5904
  };
5888
5905
  usage = value.response.usage;
5889
5906
  if (typeof value.response.service_tier === "string") {
@@ -5895,7 +5912,7 @@ var OpenAIResponsesLanguageModel = class {
5895
5912
  controller.enqueue({
5896
5913
  type: "source",
5897
5914
  sourceType: "url",
5898
- id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
5915
+ id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2(),
5899
5916
  url: value.annotation.url,
5900
5917
  title: value.annotation.title
5901
5918
  });
@@ -5903,7 +5920,7 @@ var OpenAIResponsesLanguageModel = class {
5903
5920
  controller.enqueue({
5904
5921
  type: "source",
5905
5922
  sourceType: "document",
5906
- id: (_x = (_w = (_v = self.config).generateId) == null ? void 0 : _w.call(_v)) != null ? _x : generateId2(),
5923
+ id: (_z = (_y = (_x = self.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId2(),
5907
5924
  mediaType: "text/plain",
5908
5925
  title: value.annotation.filename,
5909
5926
  filename: value.annotation.filename,
@@ -5919,7 +5936,7 @@ var OpenAIResponsesLanguageModel = class {
5919
5936
  controller.enqueue({
5920
5937
  type: "source",
5921
5938
  sourceType: "document",
5922
- id: (_A = (_z = (_y = self.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : generateId2(),
5939
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
5923
5940
  mediaType: "text/plain",
5924
5941
  title: value.annotation.filename,
5925
5942
  filename: value.annotation.filename,
@@ -5935,7 +5952,7 @@ var OpenAIResponsesLanguageModel = class {
5935
5952
  controller.enqueue({
5936
5953
  type: "source",
5937
5954
  sourceType: "document",
5938
- id: (_D = (_C = (_B = self.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : generateId2(),
5955
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
5939
5956
  mediaType: "application/octet-stream",
5940
5957
  title: value.annotation.file_id,
5941
5958
  filename: value.annotation.file_id,