@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.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +59 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +58 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +58 -9
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -863,6 +863,7 @@ var ReasoningFormat = /* @__PURE__ */ ((ReasoningFormat2) => {
|
|
|
863
863
|
ReasoningFormat2["OpenAIResponsesV1"] = "openai-responses-v1";
|
|
864
864
|
ReasoningFormat2["XAIResponsesV1"] = "xai-responses-v1";
|
|
865
865
|
ReasoningFormat2["AnthropicClaudeV1"] = "anthropic-claude-v1";
|
|
866
|
+
ReasoningFormat2["GoogleGeminiV1"] = "google-gemini-v1";
|
|
866
867
|
return ReasoningFormat2;
|
|
867
868
|
})(ReasoningFormat || {});
|
|
868
869
|
|
|
@@ -1510,7 +1511,9 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1510
1511
|
});
|
|
1511
1512
|
}
|
|
1512
1513
|
if (tools && tools.length > 0) {
|
|
1513
|
-
const mappedTools = tools.filter(
|
|
1514
|
+
const mappedTools = tools.filter(
|
|
1515
|
+
(tool) => tool.type === "function"
|
|
1516
|
+
).map((tool) => ({
|
|
1514
1517
|
type: "function",
|
|
1515
1518
|
function: {
|
|
1516
1519
|
name: tool.name,
|
|
@@ -1585,7 +1588,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1585
1588
|
if (detail.text) {
|
|
1586
1589
|
return {
|
|
1587
1590
|
type: "reasoning",
|
|
1588
|
-
text: detail.text
|
|
1591
|
+
text: detail.text,
|
|
1592
|
+
providerMetadata: {
|
|
1593
|
+
openrouter: {
|
|
1594
|
+
reasoning_details: [detail]
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1589
1597
|
};
|
|
1590
1598
|
}
|
|
1591
1599
|
break;
|
|
@@ -1594,7 +1602,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1594
1602
|
if (detail.summary) {
|
|
1595
1603
|
return {
|
|
1596
1604
|
type: "reasoning",
|
|
1597
|
-
text: detail.summary
|
|
1605
|
+
text: detail.summary,
|
|
1606
|
+
providerMetadata: {
|
|
1607
|
+
openrouter: {
|
|
1608
|
+
reasoning_details: [detail]
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1598
1611
|
};
|
|
1599
1612
|
}
|
|
1600
1613
|
break;
|
|
@@ -1603,7 +1616,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1603
1616
|
if (detail.data) {
|
|
1604
1617
|
return {
|
|
1605
1618
|
type: "reasoning",
|
|
1606
|
-
text: "[REDACTED]"
|
|
1619
|
+
text: "[REDACTED]",
|
|
1620
|
+
providerMetadata: {
|
|
1621
|
+
openrouter: {
|
|
1622
|
+
reasoning_details: [detail]
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1607
1625
|
};
|
|
1608
1626
|
}
|
|
1609
1627
|
break;
|
|
@@ -1633,7 +1651,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1633
1651
|
type: "tool-call",
|
|
1634
1652
|
toolCallId: (_j = toolCall.id) != null ? _j : generateId(),
|
|
1635
1653
|
toolName: toolCall.function.name,
|
|
1636
|
-
input: toolCall.function.arguments
|
|
1654
|
+
input: toolCall.function.arguments,
|
|
1655
|
+
providerMetadata: {
|
|
1656
|
+
openrouter: {
|
|
1657
|
+
reasoning_details: reasoningDetails
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1637
1660
|
});
|
|
1638
1661
|
}
|
|
1639
1662
|
}
|
|
@@ -1819,7 +1842,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1819
1842
|
});
|
|
1820
1843
|
};
|
|
1821
1844
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
1822
|
-
|
|
1845
|
+
for (const detail of delta.reasoning_details) {
|
|
1846
|
+
if (detail.type === "reasoning.text" /* Text */) {
|
|
1847
|
+
const lastDetail = accumulatedReasoningDetails[accumulatedReasoningDetails.length - 1];
|
|
1848
|
+
if ((lastDetail == null ? void 0 : lastDetail.type) === "reasoning.text" /* Text */) {
|
|
1849
|
+
lastDetail.text = (lastDetail.text || "") + (detail.text || "");
|
|
1850
|
+
} else {
|
|
1851
|
+
accumulatedReasoningDetails.push(__spreadValues({}, detail));
|
|
1852
|
+
}
|
|
1853
|
+
} else {
|
|
1854
|
+
accumulatedReasoningDetails.push(detail);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1823
1857
|
for (const detail of delta.reasoning_details) {
|
|
1824
1858
|
switch (detail.type) {
|
|
1825
1859
|
case "reasoning.text" /* Text */: {
|
|
@@ -1948,7 +1982,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1948
1982
|
type: "tool-call",
|
|
1949
1983
|
toolCallId: toolCall2.id,
|
|
1950
1984
|
toolName: toolCall2.function.name,
|
|
1951
|
-
input: toolCall2.function.arguments
|
|
1985
|
+
input: toolCall2.function.arguments,
|
|
1986
|
+
providerMetadata: {
|
|
1987
|
+
openrouter: {
|
|
1988
|
+
reasoning_details: accumulatedReasoningDetails
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1952
1991
|
});
|
|
1953
1992
|
toolCall2.sent = true;
|
|
1954
1993
|
}
|
|
@@ -1986,7 +2025,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1986
2025
|
type: "tool-call",
|
|
1987
2026
|
toolCallId: (_n = toolCall.id) != null ? _n : generateId(),
|
|
1988
2027
|
toolName: toolCall.function.name,
|
|
1989
|
-
input: toolCall.function.arguments
|
|
2028
|
+
input: toolCall.function.arguments,
|
|
2029
|
+
providerMetadata: {
|
|
2030
|
+
openrouter: {
|
|
2031
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
1990
2034
|
});
|
|
1991
2035
|
toolCall.sent = true;
|
|
1992
2036
|
}
|
|
@@ -2012,7 +2056,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2012
2056
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|
|
2013
2057
|
toolName: toolCall.function.name,
|
|
2014
2058
|
// Coerce invalid arguments to an empty JSON object
|
|
2015
|
-
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}"
|
|
2059
|
+
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
|
|
2060
|
+
providerMetadata: {
|
|
2061
|
+
openrouter: {
|
|
2062
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2016
2065
|
});
|
|
2017
2066
|
toolCall.sent = true;
|
|
2018
2067
|
}
|