@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.
@@ -2945,9 +2945,9 @@ function convertToOpenRouterChatMessages(prompt) {
2945
2945
  const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
2946
2946
  const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
2947
2947
  const messageAnnotations = parsedProviderOptions.success ? (_g = (_f = parsedProviderOptions.data) == null ? void 0 : _f.openrouter) == null ? void 0 : _g.annotations : void 0;
2948
- const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : findFirstReasoningDetails(content);
2948
+ const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) ? messageReasoningDetails : findFirstReasoningDetails(content);
2949
2949
  let finalReasoningDetails;
2950
- if (candidateReasoningDetails && candidateReasoningDetails.length > 0) {
2950
+ if (candidateReasoningDetails) {
2951
2951
  const validDetails = candidateReasoningDetails.filter((detail) => {
2952
2952
  var _a17;
2953
2953
  if (detail.type !== "reasoning.text" /* Text */) {
@@ -2973,9 +2973,9 @@ function convertToOpenRouterChatMessages(prompt) {
2973
2973
  uniqueDetails.push(detail);
2974
2974
  }
2975
2975
  }
2976
- finalReasoningDetails = uniqueDetails.length > 0 ? uniqueDetails : void 0;
2976
+ finalReasoningDetails = uniqueDetails;
2977
2977
  }
2978
- const effectiveReasoning = reasoning && finalReasoningDetails ? reasoning : void 0;
2978
+ const effectiveReasoning = reasoning && finalReasoningDetails && finalReasoningDetails.length > 0 ? reasoning : void 0;
2979
2979
  messages.push({
2980
2980
  role: "assistant",
2981
2981
  content: text,
@@ -3902,15 +3902,17 @@ var OpenRouterChatLanguageModel = class {
3902
3902
  controller.enqueue({
3903
3903
  type: "reasoning-end",
3904
3904
  id: reasoningId || generateId(),
3905
- // Include accumulated reasoning_details so the AI SDK can update
3906
- // the reasoning part's providerMetadata with the correct signature.
3907
- // The signature typically arrives in the last reasoning delta,
3905
+ // Always include accumulated reasoning_details so the AI SDK can
3906
+ // update the reasoning part's providerMetadata with the correct
3907
+ // signature. The signature typically arrives in the last delta,
3908
3908
  // but reasoning-start only carries the first delta's metadata.
3909
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
3909
+ // An empty array is intentional — it signals the provider produced
3910
+ // no reasoning tokens this turn (e.g. DeepSeek V4).
3911
+ providerMetadata: {
3910
3912
  openrouter: {
3911
3913
  reasoning_details: accumulatedReasoningDetails
3912
3914
  }
3913
- } : void 0
3915
+ }
3914
3916
  });
3915
3917
  reasoningStarted = false;
3916
3918
  }
@@ -4145,13 +4147,14 @@ var OpenRouterChatLanguageModel = class {
4145
4147
  controller.enqueue({
4146
4148
  type: "reasoning-end",
4147
4149
  id: reasoningId || generateId(),
4148
- // Include accumulated reasoning_details so the AI SDK can update
4149
- // the reasoning part's providerMetadata with the correct signature.
4150
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
4150
+ // Always include accumulated reasoning_details so the AI SDK can
4151
+ // update the reasoning part's providerMetadata. An empty array is
4152
+ // intentional it signals the provider produced no reasoning tokens.
4153
+ providerMetadata: {
4151
4154
  openrouter: {
4152
4155
  reasoning_details: accumulatedReasoningDetails
4153
4156
  }
4154
- } : void 0
4157
+ }
4155
4158
  });
4156
4159
  }
4157
4160
  if (textStarted) {
@@ -4166,9 +4169,7 @@ var OpenRouterChatLanguageModel = class {
4166
4169
  if (provider !== void 0) {
4167
4170
  openrouterMetadata.provider = provider;
4168
4171
  }
4169
- if (accumulatedReasoningDetails.length > 0) {
4170
- openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4171
- }
4172
+ openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4172
4173
  if (accumulatedFileAnnotations.length > 0) {
4173
4174
  openrouterMetadata.annotations = accumulatedFileAnnotations;
4174
4175
  }