@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/index.mjs
CHANGED
|
@@ -908,6 +908,7 @@ var ReasoningFormat = /* @__PURE__ */ ((ReasoningFormat2) => {
|
|
|
908
908
|
ReasoningFormat2["OpenAIResponsesV1"] = "openai-responses-v1";
|
|
909
909
|
ReasoningFormat2["XAIResponsesV1"] = "xai-responses-v1";
|
|
910
910
|
ReasoningFormat2["AnthropicClaudeV1"] = "anthropic-claude-v1";
|
|
911
|
+
ReasoningFormat2["GoogleGeminiV1"] = "google-gemini-v1";
|
|
911
912
|
return ReasoningFormat2;
|
|
912
913
|
})(ReasoningFormat || {});
|
|
913
914
|
|
|
@@ -1555,7 +1556,9 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1555
1556
|
});
|
|
1556
1557
|
}
|
|
1557
1558
|
if (tools && tools.length > 0) {
|
|
1558
|
-
const mappedTools = tools.filter(
|
|
1559
|
+
const mappedTools = tools.filter(
|
|
1560
|
+
(tool) => tool.type === "function"
|
|
1561
|
+
).map((tool) => ({
|
|
1559
1562
|
type: "function",
|
|
1560
1563
|
function: {
|
|
1561
1564
|
name: tool.name,
|
|
@@ -1630,7 +1633,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1630
1633
|
if (detail.text) {
|
|
1631
1634
|
return {
|
|
1632
1635
|
type: "reasoning",
|
|
1633
|
-
text: detail.text
|
|
1636
|
+
text: detail.text,
|
|
1637
|
+
providerMetadata: {
|
|
1638
|
+
openrouter: {
|
|
1639
|
+
reasoning_details: [detail]
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1634
1642
|
};
|
|
1635
1643
|
}
|
|
1636
1644
|
break;
|
|
@@ -1639,7 +1647,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1639
1647
|
if (detail.summary) {
|
|
1640
1648
|
return {
|
|
1641
1649
|
type: "reasoning",
|
|
1642
|
-
text: detail.summary
|
|
1650
|
+
text: detail.summary,
|
|
1651
|
+
providerMetadata: {
|
|
1652
|
+
openrouter: {
|
|
1653
|
+
reasoning_details: [detail]
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1643
1656
|
};
|
|
1644
1657
|
}
|
|
1645
1658
|
break;
|
|
@@ -1648,7 +1661,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1648
1661
|
if (detail.data) {
|
|
1649
1662
|
return {
|
|
1650
1663
|
type: "reasoning",
|
|
1651
|
-
text: "[REDACTED]"
|
|
1664
|
+
text: "[REDACTED]",
|
|
1665
|
+
providerMetadata: {
|
|
1666
|
+
openrouter: {
|
|
1667
|
+
reasoning_details: [detail]
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1652
1670
|
};
|
|
1653
1671
|
}
|
|
1654
1672
|
break;
|
|
@@ -1678,7 +1696,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1678
1696
|
type: "tool-call",
|
|
1679
1697
|
toolCallId: (_j = toolCall.id) != null ? _j : generateId(),
|
|
1680
1698
|
toolName: toolCall.function.name,
|
|
1681
|
-
input: toolCall.function.arguments
|
|
1699
|
+
input: toolCall.function.arguments,
|
|
1700
|
+
providerMetadata: {
|
|
1701
|
+
openrouter: {
|
|
1702
|
+
reasoning_details: reasoningDetails
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1682
1705
|
});
|
|
1683
1706
|
}
|
|
1684
1707
|
}
|
|
@@ -1864,7 +1887,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1864
1887
|
});
|
|
1865
1888
|
};
|
|
1866
1889
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
1867
|
-
|
|
1890
|
+
for (const detail of delta.reasoning_details) {
|
|
1891
|
+
if (detail.type === "reasoning.text" /* Text */) {
|
|
1892
|
+
const lastDetail = accumulatedReasoningDetails[accumulatedReasoningDetails.length - 1];
|
|
1893
|
+
if ((lastDetail == null ? void 0 : lastDetail.type) === "reasoning.text" /* Text */) {
|
|
1894
|
+
lastDetail.text = (lastDetail.text || "") + (detail.text || "");
|
|
1895
|
+
} else {
|
|
1896
|
+
accumulatedReasoningDetails.push(__spreadValues({}, detail));
|
|
1897
|
+
}
|
|
1898
|
+
} else {
|
|
1899
|
+
accumulatedReasoningDetails.push(detail);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1868
1902
|
for (const detail of delta.reasoning_details) {
|
|
1869
1903
|
switch (detail.type) {
|
|
1870
1904
|
case "reasoning.text" /* Text */: {
|
|
@@ -1993,7 +2027,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1993
2027
|
type: "tool-call",
|
|
1994
2028
|
toolCallId: toolCall2.id,
|
|
1995
2029
|
toolName: toolCall2.function.name,
|
|
1996
|
-
input: toolCall2.function.arguments
|
|
2030
|
+
input: toolCall2.function.arguments,
|
|
2031
|
+
providerMetadata: {
|
|
2032
|
+
openrouter: {
|
|
2033
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
1997
2036
|
});
|
|
1998
2037
|
toolCall2.sent = true;
|
|
1999
2038
|
}
|
|
@@ -2031,7 +2070,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2031
2070
|
type: "tool-call",
|
|
2032
2071
|
toolCallId: (_n = toolCall.id) != null ? _n : generateId(),
|
|
2033
2072
|
toolName: toolCall.function.name,
|
|
2034
|
-
input: toolCall.function.arguments
|
|
2073
|
+
input: toolCall.function.arguments,
|
|
2074
|
+
providerMetadata: {
|
|
2075
|
+
openrouter: {
|
|
2076
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2035
2079
|
});
|
|
2036
2080
|
toolCall.sent = true;
|
|
2037
2081
|
}
|
|
@@ -2057,7 +2101,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2057
2101
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|
|
2058
2102
|
toolName: toolCall.function.name,
|
|
2059
2103
|
// Coerce invalid arguments to an empty JSON object
|
|
2060
|
-
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}"
|
|
2104
|
+
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
|
|
2105
|
+
providerMetadata: {
|
|
2106
|
+
openrouter: {
|
|
2107
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2061
2110
|
});
|
|
2062
2111
|
toolCall.sent = true;
|
|
2063
2112
|
}
|
|
@@ -2537,7 +2586,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
2537
2586
|
}
|
|
2538
2587
|
|
|
2539
2588
|
// src/version.ts
|
|
2540
|
-
var VERSION = false ? "0.0.0-test" : "1.2.
|
|
2589
|
+
var VERSION = false ? "0.0.0-test" : "1.2.4";
|
|
2541
2590
|
|
|
2542
2591
|
// src/provider.ts
|
|
2543
2592
|
function createOpenRouter(options = {}) {
|