@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.js CHANGED
@@ -3053,9 +3053,9 @@ function convertToOpenRouterChatMessages(prompt) {
3053
3053
  const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
3054
3054
  const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
3055
3055
  const messageAnnotations = parsedProviderOptions.success ? (_g = (_f = parsedProviderOptions.data) == null ? void 0 : _f.openrouter) == null ? void 0 : _g.annotations : void 0;
3056
- const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : findFirstReasoningDetails(content);
3056
+ const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) ? messageReasoningDetails : findFirstReasoningDetails(content);
3057
3057
  let finalReasoningDetails;
3058
- if (candidateReasoningDetails && candidateReasoningDetails.length > 0) {
3058
+ if (candidateReasoningDetails) {
3059
3059
  const validDetails = candidateReasoningDetails.filter((detail) => {
3060
3060
  var _a17;
3061
3061
  if (detail.type !== "reasoning.text" /* Text */) {
@@ -3081,9 +3081,9 @@ function convertToOpenRouterChatMessages(prompt) {
3081
3081
  uniqueDetails.push(detail);
3082
3082
  }
3083
3083
  }
3084
- finalReasoningDetails = uniqueDetails.length > 0 ? uniqueDetails : void 0;
3084
+ finalReasoningDetails = uniqueDetails;
3085
3085
  }
3086
- const effectiveReasoning = reasoning && finalReasoningDetails ? reasoning : void 0;
3086
+ const effectiveReasoning = reasoning && finalReasoningDetails && finalReasoningDetails.length > 0 ? reasoning : void 0;
3087
3087
  messages.push({
3088
3088
  role: "assistant",
3089
3089
  content: text,
@@ -4010,15 +4010,17 @@ var OpenRouterChatLanguageModel = class {
4010
4010
  controller.enqueue({
4011
4011
  type: "reasoning-end",
4012
4012
  id: reasoningId || generateId(),
4013
- // Include accumulated reasoning_details so the AI SDK can update
4014
- // the reasoning part's providerMetadata with the correct signature.
4015
- // The signature typically arrives in the last reasoning delta,
4013
+ // Always include accumulated reasoning_details so the AI SDK can
4014
+ // update the reasoning part's providerMetadata with the correct
4015
+ // signature. The signature typically arrives in the last delta,
4016
4016
  // but reasoning-start only carries the first delta's metadata.
4017
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
4017
+ // An empty array is intentional — it signals the provider produced
4018
+ // no reasoning tokens this turn (e.g. DeepSeek V4).
4019
+ providerMetadata: {
4018
4020
  openrouter: {
4019
4021
  reasoning_details: accumulatedReasoningDetails
4020
4022
  }
4021
- } : void 0
4023
+ }
4022
4024
  });
4023
4025
  reasoningStarted = false;
4024
4026
  }
@@ -4253,13 +4255,14 @@ var OpenRouterChatLanguageModel = class {
4253
4255
  controller.enqueue({
4254
4256
  type: "reasoning-end",
4255
4257
  id: reasoningId || generateId(),
4256
- // Include accumulated reasoning_details so the AI SDK can update
4257
- // the reasoning part's providerMetadata with the correct signature.
4258
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
4258
+ // Always include accumulated reasoning_details so the AI SDK can
4259
+ // update the reasoning part's providerMetadata. An empty array is
4260
+ // intentional it signals the provider produced no reasoning tokens.
4261
+ providerMetadata: {
4259
4262
  openrouter: {
4260
4263
  reasoning_details: accumulatedReasoningDetails
4261
4264
  }
4262
- } : void 0
4265
+ }
4263
4266
  });
4264
4267
  }
4265
4268
  if (textStarted) {
@@ -4274,9 +4277,7 @@ var OpenRouterChatLanguageModel = class {
4274
4277
  if (provider !== void 0) {
4275
4278
  openrouterMetadata.provider = provider;
4276
4279
  }
4277
- if (accumulatedReasoningDetails.length > 0) {
4278
- openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4279
- }
4280
+ openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4280
4281
  if (accumulatedFileAnnotations.length > 0) {
4281
4282
  openrouterMetadata.annotations = accumulatedFileAnnotations;
4282
4283
  }
@@ -5100,7 +5101,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
5100
5101
  }
5101
5102
 
5102
5103
  // src/version.ts
5103
- var VERSION2 = false ? "0.0.0-test" : "2.8.0";
5104
+ var VERSION2 = false ? "0.0.0-test" : "2.8.1";
5104
5105
 
5105
5106
  // src/video/schemas.ts
5106
5107
  var import_v411 = require("zod/v4");