@openrouter/ai-sdk-provider 1.2.3 → 1.2.4

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.
@@ -7,7 +7,8 @@ declare enum ReasoningFormat {
7
7
  Unknown = "unknown",
8
8
  OpenAIResponsesV1 = "openai-responses-v1",
9
9
  XAIResponsesV1 = "xai-responses-v1",
10
- AnthropicClaudeV1 = "anthropic-claude-v1"
10
+ AnthropicClaudeV1 = "anthropic-claude-v1",
11
+ GoogleGeminiV1 = "google-gemini-v1"
11
12
  }
12
13
 
13
14
  declare enum ReasoningDetailType {
@@ -7,7 +7,8 @@ declare enum ReasoningFormat {
7
7
  Unknown = "unknown",
8
8
  OpenAIResponsesV1 = "openai-responses-v1",
9
9
  XAIResponsesV1 = "xai-responses-v1",
10
- AnthropicClaudeV1 = "anthropic-claude-v1"
10
+ AnthropicClaudeV1 = "anthropic-claude-v1",
11
+ GoogleGeminiV1 = "google-gemini-v1"
11
12
  }
12
13
 
13
14
  declare enum ReasoningDetailType {
@@ -897,6 +897,7 @@ var ReasoningFormat = /* @__PURE__ */ ((ReasoningFormat2) => {
897
897
  ReasoningFormat2["OpenAIResponsesV1"] = "openai-responses-v1";
898
898
  ReasoningFormat2["XAIResponsesV1"] = "xai-responses-v1";
899
899
  ReasoningFormat2["AnthropicClaudeV1"] = "anthropic-claude-v1";
900
+ ReasoningFormat2["GoogleGeminiV1"] = "google-gemini-v1";
900
901
  return ReasoningFormat2;
901
902
  })(ReasoningFormat || {});
902
903
 
@@ -1544,7 +1545,9 @@ var OpenRouterChatLanguageModel = class {
1544
1545
  });
1545
1546
  }
1546
1547
  if (tools && tools.length > 0) {
1547
- const mappedTools = tools.filter((tool) => tool.type === "function").map((tool) => ({
1548
+ const mappedTools = tools.filter(
1549
+ (tool) => tool.type === "function"
1550
+ ).map((tool) => ({
1548
1551
  type: "function",
1549
1552
  function: {
1550
1553
  name: tool.name,
@@ -1619,7 +1622,12 @@ var OpenRouterChatLanguageModel = class {
1619
1622
  if (detail.text) {
1620
1623
  return {
1621
1624
  type: "reasoning",
1622
- text: detail.text
1625
+ text: detail.text,
1626
+ providerMetadata: {
1627
+ openrouter: {
1628
+ reasoning_details: [detail]
1629
+ }
1630
+ }
1623
1631
  };
1624
1632
  }
1625
1633
  break;
@@ -1628,7 +1636,12 @@ var OpenRouterChatLanguageModel = class {
1628
1636
  if (detail.summary) {
1629
1637
  return {
1630
1638
  type: "reasoning",
1631
- text: detail.summary
1639
+ text: detail.summary,
1640
+ providerMetadata: {
1641
+ openrouter: {
1642
+ reasoning_details: [detail]
1643
+ }
1644
+ }
1632
1645
  };
1633
1646
  }
1634
1647
  break;
@@ -1637,7 +1650,12 @@ var OpenRouterChatLanguageModel = class {
1637
1650
  if (detail.data) {
1638
1651
  return {
1639
1652
  type: "reasoning",
1640
- text: "[REDACTED]"
1653
+ text: "[REDACTED]",
1654
+ providerMetadata: {
1655
+ openrouter: {
1656
+ reasoning_details: [detail]
1657
+ }
1658
+ }
1641
1659
  };
1642
1660
  }
1643
1661
  break;
@@ -1667,7 +1685,12 @@ var OpenRouterChatLanguageModel = class {
1667
1685
  type: "tool-call",
1668
1686
  toolCallId: (_j = toolCall.id) != null ? _j : generateId(),
1669
1687
  toolName: toolCall.function.name,
1670
- input: toolCall.function.arguments
1688
+ input: toolCall.function.arguments,
1689
+ providerMetadata: {
1690
+ openrouter: {
1691
+ reasoning_details: reasoningDetails
1692
+ }
1693
+ }
1671
1694
  });
1672
1695
  }
1673
1696
  }
@@ -1853,7 +1876,18 @@ var OpenRouterChatLanguageModel = class {
1853
1876
  });
1854
1877
  };
1855
1878
  if (delta.reasoning_details && delta.reasoning_details.length > 0) {
1856
- accumulatedReasoningDetails.push(...delta.reasoning_details);
1879
+ for (const detail of delta.reasoning_details) {
1880
+ if (detail.type === "reasoning.text" /* Text */) {
1881
+ const lastDetail = accumulatedReasoningDetails[accumulatedReasoningDetails.length - 1];
1882
+ if ((lastDetail == null ? void 0 : lastDetail.type) === "reasoning.text" /* Text */) {
1883
+ lastDetail.text = (lastDetail.text || "") + (detail.text || "");
1884
+ } else {
1885
+ accumulatedReasoningDetails.push(__spreadValues({}, detail));
1886
+ }
1887
+ } else {
1888
+ accumulatedReasoningDetails.push(detail);
1889
+ }
1890
+ }
1857
1891
  for (const detail of delta.reasoning_details) {
1858
1892
  switch (detail.type) {
1859
1893
  case "reasoning.text" /* Text */: {
@@ -1982,7 +2016,12 @@ var OpenRouterChatLanguageModel = class {
1982
2016
  type: "tool-call",
1983
2017
  toolCallId: toolCall2.id,
1984
2018
  toolName: toolCall2.function.name,
1985
- input: toolCall2.function.arguments
2019
+ input: toolCall2.function.arguments,
2020
+ providerMetadata: {
2021
+ openrouter: {
2022
+ reasoning_details: accumulatedReasoningDetails
2023
+ }
2024
+ }
1986
2025
  });
1987
2026
  toolCall2.sent = true;
1988
2027
  }
@@ -2020,7 +2059,12 @@ var OpenRouterChatLanguageModel = class {
2020
2059
  type: "tool-call",
2021
2060
  toolCallId: (_n = toolCall.id) != null ? _n : generateId(),
2022
2061
  toolName: toolCall.function.name,
2023
- input: toolCall.function.arguments
2062
+ input: toolCall.function.arguments,
2063
+ providerMetadata: {
2064
+ openrouter: {
2065
+ reasoning_details: accumulatedReasoningDetails
2066
+ }
2067
+ }
2024
2068
  });
2025
2069
  toolCall.sent = true;
2026
2070
  }
@@ -2046,7 +2090,12 @@ var OpenRouterChatLanguageModel = class {
2046
2090
  toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
2047
2091
  toolName: toolCall.function.name,
2048
2092
  // Coerce invalid arguments to an empty JSON object
2049
- input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}"
2093
+ input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
2094
+ providerMetadata: {
2095
+ openrouter: {
2096
+ reasoning_details: accumulatedReasoningDetails
2097
+ }
2098
+ }
2050
2099
  });
2051
2100
  toolCall.sent = true;
2052
2101
  }