@openrouter/ai-sdk-provider 1.2.4 → 1.2.5

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
@@ -1071,8 +1071,9 @@ function getCacheControl(providerMetadata) {
1071
1071
  return (_c = (_b = (_a15 = openrouter2 == null ? void 0 : openrouter2.cacheControl) != null ? _a15 : openrouter2 == null ? void 0 : openrouter2.cache_control) != null ? _b : anthropic == null ? void 0 : anthropic.cacheControl) != null ? _c : anthropic == null ? void 0 : anthropic.cache_control;
1072
1072
  }
1073
1073
  function convertToOpenRouterChatMessages(prompt) {
1074
- var _a15, _b, _c, _d, _e;
1074
+ var _a15, _b, _c, _d, _e, _f;
1075
1075
  const messages = [];
1076
+ const accumulatedReasoningDetails = [];
1076
1077
  for (const { role, content, providerOptions } of prompt) {
1077
1078
  switch (role) {
1078
1079
  case "system": {
@@ -1102,7 +1103,7 @@ function convertToOpenRouterChatMessages(prompt) {
1102
1103
  const messageCacheControl = getCacheControl(providerOptions);
1103
1104
  const contentParts = content.map(
1104
1105
  (part) => {
1105
- var _a16, _b2, _c2, _d2, _e2, _f;
1106
+ var _a16, _b2, _c2, _d2, _e2, _f2;
1106
1107
  const cacheControl = (_a16 = getCacheControl(part.providerOptions)) != null ? _a16 : messageCacheControl;
1107
1108
  switch (part.type) {
1108
1109
  case "text":
@@ -1128,7 +1129,7 @@ function convertToOpenRouterChatMessages(prompt) {
1128
1129
  };
1129
1130
  }
1130
1131
  const fileName = String(
1131
- (_f = (_e2 = (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2.openrouter) == null ? void 0 : _d2.filename) != null ? _e2 : part.filename) != null ? _f : ""
1132
+ (_f2 = (_e2 = (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2.openrouter) == null ? void 0 : _d2.filename) != null ? _e2 : part.filename) != null ? _f2 : ""
1132
1133
  );
1133
1134
  const fileData = getFileUrl({
1134
1135
  part,
@@ -1182,6 +1183,12 @@ function convertToOpenRouterChatMessages(prompt) {
1182
1183
  break;
1183
1184
  }
1184
1185
  case "tool-call": {
1186
+ const partReasoningDetails = (_c = part.providerOptions) == null ? void 0 : _c.openrouter;
1187
+ if ((partReasoningDetails == null ? void 0 : partReasoningDetails.reasoning_details) && Array.isArray(partReasoningDetails.reasoning_details)) {
1188
+ accumulatedReasoningDetails.push(
1189
+ ...partReasoningDetails.reasoning_details
1190
+ );
1191
+ }
1185
1192
  toolCalls.push({
1186
1193
  id: part.toolCallId,
1187
1194
  type: "function",
@@ -1204,14 +1211,14 @@ function convertToOpenRouterChatMessages(prompt) {
1204
1211
  }
1205
1212
  }
1206
1213
  const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
1207
- const preservedReasoningDetails = parsedProviderOptions.success ? (_d = (_c = parsedProviderOptions.data) == null ? void 0 : _c.openrouter) == null ? void 0 : _d.reasoning_details : void 0;
1214
+ const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
1215
+ const finalReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : accumulatedReasoningDetails.length > 0 ? accumulatedReasoningDetails : void 0;
1208
1216
  messages.push({
1209
1217
  role: "assistant",
1210
1218
  content: text,
1211
1219
  tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
1212
1220
  reasoning: reasoning || void 0,
1213
- // Only include reasoning_details if we have the preserved original version
1214
- reasoning_details: preservedReasoningDetails && Array.isArray(preservedReasoningDetails) && preservedReasoningDetails.length > 0 ? preservedReasoningDetails : void 0,
1221
+ reasoning_details: finalReasoningDetails,
1215
1222
  cache_control: getCacheControl(providerOptions)
1216
1223
  });
1217
1224
  break;
@@ -1223,7 +1230,7 @@ function convertToOpenRouterChatMessages(prompt) {
1223
1230
  role: "tool",
1224
1231
  tool_call_id: toolResponse.toolCallId,
1225
1232
  content: content2,
1226
- cache_control: (_e = getCacheControl(providerOptions)) != null ? _e : getCacheControl(toolResponse.providerOptions)
1233
+ cache_control: (_f = getCacheControl(providerOptions)) != null ? _f : getCacheControl(toolResponse.providerOptions)
1227
1234
  });
1228
1235
  }
1229
1236
  break;
@@ -2586,7 +2593,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
2586
2593
  }
2587
2594
 
2588
2595
  // src/version.ts
2589
- var VERSION = false ? "0.0.0-test" : "1.2.4";
2596
+ var VERSION = false ? "0.0.0-test" : "1.2.5";
2590
2597
 
2591
2598
  // src/provider.ts
2592
2599
  function createOpenRouter(options = {}) {