@openrouter/ai-sdk-provider 2.8.0 → 2.8.1

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
@@ -3020,9 +3020,9 @@ function convertToOpenRouterChatMessages(prompt) {
3020
3020
  const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
3021
3021
  const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
3022
3022
  const messageAnnotations = parsedProviderOptions.success ? (_g = (_f = parsedProviderOptions.data) == null ? void 0 : _f.openrouter) == null ? void 0 : _g.annotations : void 0;
3023
- const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : findFirstReasoningDetails(content);
3023
+ const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) ? messageReasoningDetails : findFirstReasoningDetails(content);
3024
3024
  let finalReasoningDetails;
3025
- if (candidateReasoningDetails && candidateReasoningDetails.length > 0) {
3025
+ if (candidateReasoningDetails) {
3026
3026
  const validDetails = candidateReasoningDetails.filter((detail) => {
3027
3027
  var _a17;
3028
3028
  if (detail.type !== "reasoning.text" /* Text */) {
@@ -3048,9 +3048,9 @@ function convertToOpenRouterChatMessages(prompt) {
3048
3048
  uniqueDetails.push(detail);
3049
3049
  }
3050
3050
  }
3051
- finalReasoningDetails = uniqueDetails.length > 0 ? uniqueDetails : void 0;
3051
+ finalReasoningDetails = uniqueDetails;
3052
3052
  }
3053
- const effectiveReasoning = reasoning && finalReasoningDetails ? reasoning : void 0;
3053
+ const effectiveReasoning = reasoning && finalReasoningDetails && finalReasoningDetails.length > 0 ? reasoning : void 0;
3054
3054
  messages.push({
3055
3055
  role: "assistant",
3056
3056
  content: text,
@@ -3977,15 +3977,17 @@ var OpenRouterChatLanguageModel = class {
3977
3977
  controller.enqueue({
3978
3978
  type: "reasoning-end",
3979
3979
  id: reasoningId || generateId(),
3980
- // Include accumulated reasoning_details so the AI SDK can update
3981
- // the reasoning part's providerMetadata with the correct signature.
3982
- // The signature typically arrives in the last reasoning delta,
3980
+ // Always include accumulated reasoning_details so the AI SDK can
3981
+ // update the reasoning part's providerMetadata with the correct
3982
+ // signature. The signature typically arrives in the last delta,
3983
3983
  // but reasoning-start only carries the first delta's metadata.
3984
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
3984
+ // An empty array is intentional — it signals the provider produced
3985
+ // no reasoning tokens this turn (e.g. DeepSeek V4).
3986
+ providerMetadata: {
3985
3987
  openrouter: {
3986
3988
  reasoning_details: accumulatedReasoningDetails
3987
3989
  }
3988
- } : void 0
3990
+ }
3989
3991
  });
3990
3992
  reasoningStarted = false;
3991
3993
  }
@@ -4220,13 +4222,14 @@ var OpenRouterChatLanguageModel = class {
4220
4222
  controller.enqueue({
4221
4223
  type: "reasoning-end",
4222
4224
  id: reasoningId || generateId(),
4223
- // Include accumulated reasoning_details so the AI SDK can update
4224
- // the reasoning part's providerMetadata with the correct signature.
4225
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
4225
+ // Always include accumulated reasoning_details so the AI SDK can
4226
+ // update the reasoning part's providerMetadata. An empty array is
4227
+ // intentional it signals the provider produced no reasoning tokens.
4228
+ providerMetadata: {
4226
4229
  openrouter: {
4227
4230
  reasoning_details: accumulatedReasoningDetails
4228
4231
  }
4229
- } : void 0
4232
+ }
4230
4233
  });
4231
4234
  }
4232
4235
  if (textStarted) {
@@ -4241,9 +4244,7 @@ var OpenRouterChatLanguageModel = class {
4241
4244
  if (provider !== void 0) {
4242
4245
  openrouterMetadata.provider = provider;
4243
4246
  }
4244
- if (accumulatedReasoningDetails.length > 0) {
4245
- openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4246
- }
4247
+ openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4247
4248
  if (accumulatedFileAnnotations.length > 0) {
4248
4249
  openrouterMetadata.annotations = accumulatedFileAnnotations;
4249
4250
  }
@@ -5067,7 +5068,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
5067
5068
  }
5068
5069
 
5069
5070
  // src/version.ts
5070
- var VERSION2 = false ? "0.0.0-test" : "2.8.0";
5071
+ var VERSION2 = false ? "0.0.0-test" : "2.8.1";
5071
5072
 
5072
5073
  // src/video/schemas.ts
5073
5074
  import { z as z12 } from "zod/v4";