@openrouter/ai-sdk-provider 1.5.1 → 1.5.2

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
@@ -1886,9 +1886,15 @@ var OpenRouterChatLanguageModel = class {
1886
1886
  const fileAnnotations = (_k = choice.message.annotations) == null ? void 0 : _k.filter(
1887
1887
  (a) => a.type === "file"
1888
1888
  );
1889
+ const hasToolCalls = choice.message.tool_calls && choice.message.tool_calls.length > 0;
1890
+ const hasEncryptedReasoning = reasoningDetails.some(
1891
+ (d) => d.type === "reasoning.encrypted" /* Encrypted */ && d.data
1892
+ );
1893
+ const shouldOverrideFinishReason = hasToolCalls && hasEncryptedReasoning && choice.finish_reason === "stop";
1894
+ const effectiveFinishReason = shouldOverrideFinishReason ? "tool-calls" : mapOpenRouterFinishReason(choice.finish_reason);
1889
1895
  return {
1890
1896
  content,
1891
- finishReason: mapOpenRouterFinishReason(choice.finish_reason),
1897
+ finishReason: effectiveFinishReason,
1892
1898
  usage: usageInfo,
1893
1899
  warnings: [],
1894
1900
  providerMetadata: {
@@ -2266,6 +2272,13 @@ var OpenRouterChatLanguageModel = class {
2266
2272
  },
2267
2273
  flush(controller) {
2268
2274
  var _a16;
2275
+ const hasToolCalls = toolCalls.length > 0;
2276
+ const hasEncryptedReasoning = accumulatedReasoningDetails.some(
2277
+ (d) => d.type === "reasoning.encrypted" /* Encrypted */ && d.data
2278
+ );
2279
+ if (hasToolCalls && hasEncryptedReasoning && finishReason === "stop") {
2280
+ finishReason = "tool-calls";
2281
+ }
2269
2282
  if (finishReason === "tool-calls") {
2270
2283
  for (const toolCall of toolCalls) {
2271
2284
  if (toolCall && !toolCall.sent) {
@@ -2857,7 +2870,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
2857
2870
  }
2858
2871
 
2859
2872
  // src/version.ts
2860
- var VERSION = false ? "0.0.0-test" : "1.5.1";
2873
+ var VERSION = false ? "0.0.0-test" : "1.5.2";
2861
2874
 
2862
2875
  // src/provider.ts
2863
2876
  function createOpenRouter(options = {}) {