@ai-sdk/openai 4.0.15 → 4.0.16

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.
@@ -6567,7 +6567,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6567
6567
  };
6568
6568
  }
6569
6569
  async doGenerate(options) {
6570
- 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;
6570
+ 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;
6571
6571
  const {
6572
6572
  args: body,
6573
6573
  warnings,
@@ -6607,6 +6607,18 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6607
6607
  isRetryable: false
6608
6608
  });
6609
6609
  }
6610
+ if (response.output == null) {
6611
+ const detail = (_c = response.incomplete_details) == null ? void 0 : _c.reason;
6612
+ throw new APICallError2({
6613
+ message: detail ? `Responses API returned no output (${detail})` : "Responses API returned no output",
6614
+ url,
6615
+ requestBodyValues: body,
6616
+ statusCode: 500,
6617
+ responseHeaders,
6618
+ responseBody: rawResponse,
6619
+ isRetryable: false
6620
+ });
6621
+ }
6610
6622
  const content = [];
6611
6623
  const logprobs = [];
6612
6624
  let hasFunctionCall = false;
@@ -6624,7 +6636,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6624
6636
  providerMetadata: {
6625
6637
  [providerOptionsName]: {
6626
6638
  itemId: part.id,
6627
- reasoningEncryptedContent: (_c = part.encrypted_content) != null ? _c : null
6639
+ reasoningEncryptedContent: (_d = part.encrypted_content) != null ? _d : null
6628
6640
  }
6629
6641
  }
6630
6642
  });
@@ -6650,7 +6662,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6650
6662
  break;
6651
6663
  }
6652
6664
  case "tool_search_call": {
6653
- const toolCallId = (_d = part.call_id) != null ? _d : part.id;
6665
+ const toolCallId = (_e = part.call_id) != null ? _e : part.id;
6654
6666
  const isHosted = part.execution === "server";
6655
6667
  if (isHosted) {
6656
6668
  hostedToolSearchCallIds.push(toolCallId);
@@ -6673,7 +6685,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6673
6685
  break;
6674
6686
  }
6675
6687
  case "tool_search_output": {
6676
- const toolCallId = (_f = (_e = part.call_id) != null ? _e : hostedToolSearchCallIds.shift()) != null ? _f : part.id;
6688
+ const toolCallId = (_g = (_f = part.call_id) != null ? _f : hostedToolSearchCallIds.shift()) != null ? _g : part.id;
6677
6689
  content.push({
6678
6690
  type: "tool-result",
6679
6691
  toolCallId,
@@ -6744,7 +6756,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6744
6756
  }
6745
6757
  case "message": {
6746
6758
  for (const contentPart of part.content) {
6747
- if (((_h = (_g = options.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.logprobs) && contentPart.logprobs) {
6759
+ if (((_i = (_h = options.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.logprobs) && contentPart.logprobs) {
6748
6760
  logprobs.push(contentPart.logprobs);
6749
6761
  }
6750
6762
  const providerMetadata2 = {
@@ -6766,7 +6778,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6766
6778
  content.push({
6767
6779
  type: "source",
6768
6780
  sourceType: "url",
6769
- id: (_k = (_j = (_i = this.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId2(),
6781
+ id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
6770
6782
  url: annotation.url,
6771
6783
  title: annotation.title
6772
6784
  });
@@ -6774,7 +6786,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6774
6786
  content.push({
6775
6787
  type: "source",
6776
6788
  sourceType: "document",
6777
- id: (_n = (_m = (_l = this.config).generateId) == null ? void 0 : _m.call(_l)) != null ? _n : generateId2(),
6789
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
6778
6790
  mediaType: "text/plain",
6779
6791
  title: annotation.filename,
6780
6792
  filename: annotation.filename,
@@ -6790,7 +6802,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6790
6802
  content.push({
6791
6803
  type: "source",
6792
6804
  sourceType: "document",
6793
- id: (_q = (_p = (_o = this.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : generateId2(),
6805
+ id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
6794
6806
  mediaType: "text/plain",
6795
6807
  title: annotation.filename,
6796
6808
  filename: annotation.filename,
@@ -6806,7 +6818,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6806
6818
  content.push({
6807
6819
  type: "source",
6808
6820
  sourceType: "document",
6809
- id: (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : generateId2(),
6821
+ id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
6810
6822
  mediaType: "application/octet-stream",
6811
6823
  title: annotation.file_id,
6812
6824
  filename: annotation.file_id,
@@ -6876,7 +6888,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6876
6888
  break;
6877
6889
  }
6878
6890
  case "mcp_call": {
6879
- const toolCallId = part.approval_request_id != null ? (_u = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _u : part.id : part.id;
6891
+ const toolCallId = part.approval_request_id != null ? (_v = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _v : part.id : part.id;
6880
6892
  const toolName = `mcp.${part.name}`;
6881
6893
  content.push({
6882
6894
  type: "tool-call",
@@ -6910,8 +6922,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6910
6922
  break;
6911
6923
  }
6912
6924
  case "mcp_approval_request": {
6913
- const approvalRequestId = (_v = part.approval_request_id) != null ? _v : part.id;
6914
- const dummyToolCallId = (_y = (_x = (_w = this.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : generateId2();
6925
+ const approvalRequestId = (_w = part.approval_request_id) != null ? _w : part.id;
6926
+ const dummyToolCallId = (_z = (_y = (_x = this.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId2();
6915
6927
  const toolName = `mcp.${part.name}`;
6916
6928
  content.push({
6917
6929
  type: "tool-call",
@@ -6977,13 +6989,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6977
6989
  toolName: toolNameMapping.toCustomToolName("file_search"),
6978
6990
  result: {
6979
6991
  queries: part.queries,
6980
- results: (_A = (_z = part.results) == null ? void 0 : _z.map((result) => ({
6992
+ results: (_B = (_A = part.results) == null ? void 0 : _A.map((result) => ({
6981
6993
  attributes: result.attributes,
6982
6994
  fileId: result.file_id,
6983
6995
  filename: result.filename,
6984
6996
  score: result.score,
6985
6997
  text: result.text
6986
- }))) != null ? _A : null
6998
+ }))) != null ? _B : null
6987
6999
  }
6988
7000
  });
6989
7001
  break;
@@ -7047,7 +7059,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7047
7059
  responseId: response.id,
7048
7060
  ...logprobs.length > 0 ? { logprobs } : {},
7049
7061
  ...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
7050
- ...((_B = response.reasoning) == null ? void 0 : _B.context) != null ? { reasoningContext: response.reasoning.context } : {}
7062
+ ...((_C = response.reasoning) == null ? void 0 : _C.context) != null ? { reasoningContext: response.reasoning.context } : {}
7051
7063
  }
7052
7064
  };
7053
7065
  const usage = response.usage;
@@ -7055,10 +7067,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7055
7067
  content,
7056
7068
  finishReason: {
7057
7069
  unified: mapOpenAIResponseFinishReason({
7058
- finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
7070
+ finishReason: (_D = response.incomplete_details) == null ? void 0 : _D.reason,
7059
7071
  hasFunctionCall
7060
7072
  }),
7061
- raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
7073
+ raw: (_F = (_E = response.incomplete_details) == null ? void 0 : _E.reason) != null ? _F : void 0
7062
7074
  },
7063
7075
  usage: convertOpenAIResponsesUsage(usage),
7064
7076
  request: { body },