@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.
@@ -2980,9 +2980,9 @@ function convertToOpenRouterChatMessages(prompt) {
2980
2980
  const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
2981
2981
  const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
2982
2982
  const messageAnnotations = parsedProviderOptions.success ? (_g = (_f = parsedProviderOptions.data) == null ? void 0 : _f.openrouter) == null ? void 0 : _g.annotations : void 0;
2983
- const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : findFirstReasoningDetails(content);
2983
+ const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) ? messageReasoningDetails : findFirstReasoningDetails(content);
2984
2984
  let finalReasoningDetails;
2985
- if (candidateReasoningDetails && candidateReasoningDetails.length > 0) {
2985
+ if (candidateReasoningDetails) {
2986
2986
  const validDetails = candidateReasoningDetails.filter((detail) => {
2987
2987
  var _a17;
2988
2988
  if (detail.type !== "reasoning.text" /* Text */) {
@@ -3008,9 +3008,9 @@ function convertToOpenRouterChatMessages(prompt) {
3008
3008
  uniqueDetails.push(detail);
3009
3009
  }
3010
3010
  }
3011
- finalReasoningDetails = uniqueDetails.length > 0 ? uniqueDetails : void 0;
3011
+ finalReasoningDetails = uniqueDetails;
3012
3012
  }
3013
- const effectiveReasoning = reasoning && finalReasoningDetails ? reasoning : void 0;
3013
+ const effectiveReasoning = reasoning && finalReasoningDetails && finalReasoningDetails.length > 0 ? reasoning : void 0;
3014
3014
  messages.push({
3015
3015
  role: "assistant",
3016
3016
  content: text,
@@ -3937,15 +3937,17 @@ var OpenRouterChatLanguageModel = class {
3937
3937
  controller.enqueue({
3938
3938
  type: "reasoning-end",
3939
3939
  id: reasoningId || generateId(),
3940
- // Include accumulated reasoning_details so the AI SDK can update
3941
- // the reasoning part's providerMetadata with the correct signature.
3942
- // The signature typically arrives in the last reasoning delta,
3940
+ // Always include accumulated reasoning_details so the AI SDK can
3941
+ // update the reasoning part's providerMetadata with the correct
3942
+ // signature. The signature typically arrives in the last delta,
3943
3943
  // but reasoning-start only carries the first delta's metadata.
3944
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
3944
+ // An empty array is intentional — it signals the provider produced
3945
+ // no reasoning tokens this turn (e.g. DeepSeek V4).
3946
+ providerMetadata: {
3945
3947
  openrouter: {
3946
3948
  reasoning_details: accumulatedReasoningDetails
3947
3949
  }
3948
- } : void 0
3950
+ }
3949
3951
  });
3950
3952
  reasoningStarted = false;
3951
3953
  }
@@ -4180,13 +4182,14 @@ var OpenRouterChatLanguageModel = class {
4180
4182
  controller.enqueue({
4181
4183
  type: "reasoning-end",
4182
4184
  id: reasoningId || generateId(),
4183
- // Include accumulated reasoning_details so the AI SDK can update
4184
- // the reasoning part's providerMetadata with the correct signature.
4185
- providerMetadata: accumulatedReasoningDetails.length > 0 ? {
4185
+ // Always include accumulated reasoning_details so the AI SDK can
4186
+ // update the reasoning part's providerMetadata. An empty array is
4187
+ // intentional it signals the provider produced no reasoning tokens.
4188
+ providerMetadata: {
4186
4189
  openrouter: {
4187
4190
  reasoning_details: accumulatedReasoningDetails
4188
4191
  }
4189
- } : void 0
4192
+ }
4190
4193
  });
4191
4194
  }
4192
4195
  if (textStarted) {
@@ -4201,9 +4204,7 @@ var OpenRouterChatLanguageModel = class {
4201
4204
  if (provider !== void 0) {
4202
4205
  openrouterMetadata.provider = provider;
4203
4206
  }
4204
- if (accumulatedReasoningDetails.length > 0) {
4205
- openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4206
- }
4207
+ openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
4207
4208
  if (accumulatedFileAnnotations.length > 0) {
4208
4209
  openrouterMetadata.annotations = accumulatedFileAnnotations;
4209
4210
  }