@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.
package/dist/index.mjs CHANGED
@@ -1764,9 +1764,11 @@ var modelMaxImagesPerCall = {
1764
1764
  "dall-e-2": 10,
1765
1765
  "gpt-image-1": 10,
1766
1766
  "gpt-image-1-mini": 10,
1767
- "gpt-image-1.5": 10
1767
+ "gpt-image-1.5": 10,
1768
+ "chatgpt-image-latest": 10
1768
1769
  };
1769
1770
  var defaultResponseFormatPrefixes = [
1771
+ "chatgpt-image-",
1770
1772
  "gpt-image-1-mini",
1771
1773
  "gpt-image-1.5",
1772
1774
  "gpt-image-1"
@@ -2641,7 +2643,7 @@ async function convertToOpenAIResponsesInput({
2641
2643
  hasShellTool = false,
2642
2644
  hasApplyPatchTool = false
2643
2645
  }) {
2644
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2646
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2645
2647
  const input = [];
2646
2648
  const warnings = [];
2647
2649
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -2722,7 +2724,9 @@ async function convertToOpenAIResponsesInput({
2722
2724
  for (const part of content) {
2723
2725
  switch (part.type) {
2724
2726
  case "text": {
2725
- const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName]) == null ? void 0 : _b.itemId;
2727
+ const providerOpts = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName];
2728
+ const id = providerOpts == null ? void 0 : providerOpts.itemId;
2729
+ const phase = providerOpts == null ? void 0 : providerOpts.phase;
2726
2730
  if (hasConversation && id != null) {
2727
2731
  break;
2728
2732
  }
@@ -2733,12 +2737,13 @@ async function convertToOpenAIResponsesInput({
2733
2737
  input.push({
2734
2738
  role: "assistant",
2735
2739
  content: [{ type: "output_text", text: part.text }],
2736
- id
2740
+ id,
2741
+ ...phase != null && { phase }
2737
2742
  });
2738
2743
  break;
2739
2744
  }
2740
2745
  case "tool-call": {
2741
- 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;
2746
+ 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;
2742
2747
  if (hasConversation && id != null) {
2743
2748
  break;
2744
2749
  }
@@ -2849,7 +2854,7 @@ async function convertToOpenAIResponsesInput({
2849
2854
  break;
2850
2855
  }
2851
2856
  if (store) {
2852
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2857
+ const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
2853
2858
  input.push({ type: "item_reference", id: itemId });
2854
2859
  } else {
2855
2860
  warnings.push({
@@ -2943,7 +2948,7 @@ async function convertToOpenAIResponsesInput({
2943
2948
  }
2944
2949
  const output = part.output;
2945
2950
  if (output.type === "execution-denied") {
2946
- const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
2951
+ const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
2947
2952
  if (approvalId) {
2948
2953
  continue;
2949
2954
  }
@@ -3002,7 +3007,7 @@ async function convertToOpenAIResponsesInput({
3002
3007
  contentValue = output.value;
3003
3008
  break;
3004
3009
  case "execution-denied":
3005
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
3010
+ contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
3006
3011
  break;
3007
3012
  case "json":
3008
3013
  case "error-json":
@@ -3135,7 +3140,8 @@ var openaiResponsesChunkSchema = lazySchema17(
3135
3140
  item: z19.discriminatedUnion("type", [
3136
3141
  z19.object({
3137
3142
  type: z19.literal("message"),
3138
- id: z19.string()
3143
+ id: z19.string(),
3144
+ phase: z19.enum(["commentary", "final_answer"]).nullish()
3139
3145
  }),
3140
3146
  z19.object({
3141
3147
  type: z19.literal("reasoning"),
@@ -3252,7 +3258,8 @@ var openaiResponsesChunkSchema = lazySchema17(
3252
3258
  item: z19.discriminatedUnion("type", [
3253
3259
  z19.object({
3254
3260
  type: z19.literal("message"),
3255
- id: z19.string()
3261
+ id: z19.string(),
3262
+ phase: z19.enum(["commentary", "final_answer"]).nullish()
3256
3263
  }),
3257
3264
  z19.object({
3258
3265
  type: z19.literal("reasoning"),
@@ -3564,6 +3571,7 @@ var openaiResponsesResponseSchema = lazySchema17(
3564
3571
  type: z19.literal("message"),
3565
3572
  role: z19.literal("assistant"),
3566
3573
  id: z19.string(),
3574
+ phase: z19.enum(["commentary", "final_answer"]).nullish(),
3567
3575
  content: z19.array(
3568
3576
  z19.object({
3569
3577
  type: z19.literal("output_text"),
@@ -4698,6 +4706,7 @@ var OpenAIResponsesLanguageModel = class {
4698
4706
  }
4699
4707
  const providerMetadata2 = {
4700
4708
  itemId: part.id,
4709
+ ...part.phase != null && { phase: part.phase },
4701
4710
  ...contentPart.annotations.length > 0 && {
4702
4711
  annotations: contentPart.annotations
4703
4712
  }
@@ -5012,6 +5021,7 @@ var OpenAIResponsesLanguageModel = class {
5012
5021
  let responseId = null;
5013
5022
  const ongoingToolCalls = {};
5014
5023
  const ongoingAnnotations = [];
5024
+ let activeMessagePhase;
5015
5025
  let hasFunctionCall = false;
5016
5026
  const activeReasoning = {};
5017
5027
  let serviceTier;
@@ -5022,7 +5032,7 @@ var OpenAIResponsesLanguageModel = class {
5022
5032
  controller.enqueue({ type: "stream-start", warnings });
5023
5033
  },
5024
5034
  transform(chunk, controller) {
5025
- 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;
5035
+ 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;
5026
5036
  if (options.includeRawChunks) {
5027
5037
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5028
5038
  }
@@ -5163,12 +5173,16 @@ var OpenAIResponsesLanguageModel = class {
5163
5173
  } else if (value.item.type === "shell_call_output") {
5164
5174
  } else if (value.item.type === "message") {
5165
5175
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
5176
+ activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
5166
5177
  controller.enqueue({
5167
5178
  type: "text-start",
5168
5179
  id: value.item.id,
5169
5180
  providerMetadata: {
5170
5181
  [providerOptionsName]: {
5171
- itemId: value.item.id
5182
+ itemId: value.item.id,
5183
+ ...value.item.phase != null && {
5184
+ phase: value.item.phase
5185
+ }
5172
5186
  }
5173
5187
  }
5174
5188
  });
@@ -5183,19 +5197,22 @@ var OpenAIResponsesLanguageModel = class {
5183
5197
  providerMetadata: {
5184
5198
  [providerOptionsName]: {
5185
5199
  itemId: value.item.id,
5186
- reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
5200
+ reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
5187
5201
  }
5188
5202
  }
5189
5203
  });
5190
5204
  }
5191
5205
  } else if (isResponseOutputItemDoneChunk(value)) {
5192
5206
  if (value.item.type === "message") {
5207
+ const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
5208
+ activeMessagePhase = void 0;
5193
5209
  controller.enqueue({
5194
5210
  type: "text-end",
5195
5211
  id: value.item.id,
5196
5212
  providerMetadata: {
5197
5213
  [providerOptionsName]: {
5198
5214
  itemId: value.item.id,
5215
+ ...phase != null && { phase },
5199
5216
  ...ongoingAnnotations.length > 0 && {
5200
5217
  annotations: ongoingAnnotations
5201
5218
  }
@@ -5260,13 +5277,13 @@ var OpenAIResponsesLanguageModel = class {
5260
5277
  toolName: toolNameMapping.toCustomToolName("file_search"),
5261
5278
  result: {
5262
5279
  queries: value.item.queries,
5263
- results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
5280
+ results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
5264
5281
  attributes: result.attributes,
5265
5282
  fileId: result.file_id,
5266
5283
  filename: result.filename,
5267
5284
  score: result.score,
5268
5285
  text: result.text
5269
- }))) != null ? _c : null
5286
+ }))) != null ? _e : null
5270
5287
  }
5271
5288
  });
5272
5289
  } else if (value.item.type === "code_interpreter_call") {
@@ -5290,10 +5307,10 @@ var OpenAIResponsesLanguageModel = class {
5290
5307
  });
5291
5308
  } else if (value.item.type === "mcp_call") {
5292
5309
  ongoingToolCalls[value.output_index] = void 0;
5293
- const approvalRequestId = (_d = value.item.approval_request_id) != null ? _d : void 0;
5294
- const aliasedToolCallId = approvalRequestId != null ? (_f = (_e = approvalRequestIdToDummyToolCallIdFromStream.get(
5310
+ const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
5311
+ const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
5295
5312
  approvalRequestId
5296
- )) != null ? _e : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _f : value.item.id : value.item.id;
5313
+ )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
5297
5314
  const toolName = `mcp.${value.item.name}`;
5298
5315
  controller.enqueue({
5299
5316
  type: "tool-call",
@@ -5363,8 +5380,8 @@ var OpenAIResponsesLanguageModel = class {
5363
5380
  ongoingToolCalls[value.output_index] = void 0;
5364
5381
  } else if (value.item.type === "mcp_approval_request") {
5365
5382
  ongoingToolCalls[value.output_index] = void 0;
5366
- const dummyToolCallId = (_i = (_h = (_g = self.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2();
5367
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : value.item.id;
5383
+ const dummyToolCallId = (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId2();
5384
+ const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
5368
5385
  approvalRequestIdToDummyToolCallIdFromStream.set(
5369
5386
  approvalRequestId,
5370
5387
  dummyToolCallId
@@ -5453,7 +5470,7 @@ var OpenAIResponsesLanguageModel = class {
5453
5470
  providerMetadata: {
5454
5471
  [providerOptionsName]: {
5455
5472
  itemId: value.item.id,
5456
- reasoningEncryptedContent: (_k = value.item.encrypted_content) != null ? _k : null
5473
+ reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
5457
5474
  }
5458
5475
  }
5459
5476
  });
@@ -5557,7 +5574,7 @@ var OpenAIResponsesLanguageModel = class {
5557
5574
  id: value.item_id,
5558
5575
  delta: value.delta
5559
5576
  });
5560
- if (((_m = (_l = options.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.logprobs) && value.logprobs) {
5577
+ if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
5561
5578
  logprobs.push(value.logprobs);
5562
5579
  }
5563
5580
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -5586,7 +5603,7 @@ var OpenAIResponsesLanguageModel = class {
5586
5603
  providerMetadata: {
5587
5604
  [providerOptionsName]: {
5588
5605
  itemId: value.item_id,
5589
- reasoningEncryptedContent: (_o = (_n = activeReasoning[value.item_id]) == null ? void 0 : _n.encryptedContent) != null ? _o : null
5606
+ reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
5590
5607
  }
5591
5608
  }
5592
5609
  });
@@ -5620,10 +5637,10 @@ var OpenAIResponsesLanguageModel = class {
5620
5637
  } else if (isResponseFinishedChunk(value)) {
5621
5638
  finishReason = {
5622
5639
  unified: mapOpenAIResponseFinishReason({
5623
- finishReason: (_p = value.response.incomplete_details) == null ? void 0 : _p.reason,
5640
+ finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
5624
5641
  hasFunctionCall
5625
5642
  }),
5626
- raw: (_r = (_q = value.response.incomplete_details) == null ? void 0 : _q.reason) != null ? _r : void 0
5643
+ raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
5627
5644
  };
5628
5645
  usage = value.response.usage;
5629
5646
  if (typeof value.response.service_tier === "string") {
@@ -5635,7 +5652,7 @@ var OpenAIResponsesLanguageModel = class {
5635
5652
  controller.enqueue({
5636
5653
  type: "source",
5637
5654
  sourceType: "url",
5638
- id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
5655
+ id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2(),
5639
5656
  url: value.annotation.url,
5640
5657
  title: value.annotation.title
5641
5658
  });
@@ -5643,7 +5660,7 @@ var OpenAIResponsesLanguageModel = class {
5643
5660
  controller.enqueue({
5644
5661
  type: "source",
5645
5662
  sourceType: "document",
5646
- id: (_x = (_w = (_v = self.config).generateId) == null ? void 0 : _w.call(_v)) != null ? _x : generateId2(),
5663
+ id: (_z = (_y = (_x = self.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId2(),
5647
5664
  mediaType: "text/plain",
5648
5665
  title: value.annotation.filename,
5649
5666
  filename: value.annotation.filename,
@@ -5659,7 +5676,7 @@ var OpenAIResponsesLanguageModel = class {
5659
5676
  controller.enqueue({
5660
5677
  type: "source",
5661
5678
  sourceType: "document",
5662
- id: (_A = (_z = (_y = self.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : generateId2(),
5679
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
5663
5680
  mediaType: "text/plain",
5664
5681
  title: value.annotation.filename,
5665
5682
  filename: value.annotation.filename,
@@ -5675,7 +5692,7 @@ var OpenAIResponsesLanguageModel = class {
5675
5692
  controller.enqueue({
5676
5693
  type: "source",
5677
5694
  sourceType: "document",
5678
- id: (_D = (_C = (_B = self.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : generateId2(),
5695
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
5679
5696
  mediaType: "application/octet-stream",
5680
5697
  title: value.annotation.file_id,
5681
5698
  filename: value.annotation.file_id,
@@ -6146,7 +6163,7 @@ var OpenAITranscriptionModel = class {
6146
6163
  };
6147
6164
 
6148
6165
  // src/version.ts
6149
- var VERSION = true ? "3.0.32" : "0.0.0-test";
6166
+ var VERSION = true ? "3.0.34" : "0.0.0-test";
6150
6167
 
6151
6168
  // src/openai-provider.ts
6152
6169
  function createOpenAI(options = {}) {