@openrouter/ai-sdk-provider 1.2.4 → 1.2.6
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 +17 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +16 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +16 -9
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1071,8 +1071,9 @@ function getCacheControl(providerMetadata) {
|
|
|
1071
1071
|
return (_c = (_b = (_a15 = openrouter2 == null ? void 0 : openrouter2.cacheControl) != null ? _a15 : openrouter2 == null ? void 0 : openrouter2.cache_control) != null ? _b : anthropic == null ? void 0 : anthropic.cacheControl) != null ? _c : anthropic == null ? void 0 : anthropic.cache_control;
|
|
1072
1072
|
}
|
|
1073
1073
|
function convertToOpenRouterChatMessages(prompt) {
|
|
1074
|
-
var _a15, _b, _c, _d, _e;
|
|
1074
|
+
var _a15, _b, _c, _d, _e, _f;
|
|
1075
1075
|
const messages = [];
|
|
1076
|
+
const accumulatedReasoningDetails = [];
|
|
1076
1077
|
for (const { role, content, providerOptions } of prompt) {
|
|
1077
1078
|
switch (role) {
|
|
1078
1079
|
case "system": {
|
|
@@ -1102,7 +1103,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1102
1103
|
const messageCacheControl = getCacheControl(providerOptions);
|
|
1103
1104
|
const contentParts = content.map(
|
|
1104
1105
|
(part) => {
|
|
1105
|
-
var _a16, _b2, _c2, _d2, _e2,
|
|
1106
|
+
var _a16, _b2, _c2, _d2, _e2, _f2;
|
|
1106
1107
|
const cacheControl = (_a16 = getCacheControl(part.providerOptions)) != null ? _a16 : messageCacheControl;
|
|
1107
1108
|
switch (part.type) {
|
|
1108
1109
|
case "text":
|
|
@@ -1128,7 +1129,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1128
1129
|
};
|
|
1129
1130
|
}
|
|
1130
1131
|
const fileName = String(
|
|
1131
|
-
(
|
|
1132
|
+
(_f2 = (_e2 = (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2.openrouter) == null ? void 0 : _d2.filename) != null ? _e2 : part.filename) != null ? _f2 : ""
|
|
1132
1133
|
);
|
|
1133
1134
|
const fileData = getFileUrl({
|
|
1134
1135
|
part,
|
|
@@ -1182,6 +1183,12 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1182
1183
|
break;
|
|
1183
1184
|
}
|
|
1184
1185
|
case "tool-call": {
|
|
1186
|
+
const partReasoningDetails = (_c = part.providerOptions) == null ? void 0 : _c.openrouter;
|
|
1187
|
+
if ((partReasoningDetails == null ? void 0 : partReasoningDetails.reasoning_details) && Array.isArray(partReasoningDetails.reasoning_details)) {
|
|
1188
|
+
accumulatedReasoningDetails.push(
|
|
1189
|
+
...partReasoningDetails.reasoning_details
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1185
1192
|
toolCalls.push({
|
|
1186
1193
|
id: part.toolCallId,
|
|
1187
1194
|
type: "function",
|
|
@@ -1204,14 +1211,14 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1204
1211
|
}
|
|
1205
1212
|
}
|
|
1206
1213
|
const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
|
|
1207
|
-
const
|
|
1214
|
+
const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
|
|
1215
|
+
const finalReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : accumulatedReasoningDetails.length > 0 ? accumulatedReasoningDetails : void 0;
|
|
1208
1216
|
messages.push({
|
|
1209
1217
|
role: "assistant",
|
|
1210
1218
|
content: text,
|
|
1211
1219
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
1212
1220
|
reasoning: reasoning || void 0,
|
|
1213
|
-
|
|
1214
|
-
reasoning_details: preservedReasoningDetails && Array.isArray(preservedReasoningDetails) && preservedReasoningDetails.length > 0 ? preservedReasoningDetails : void 0,
|
|
1221
|
+
reasoning_details: finalReasoningDetails,
|
|
1215
1222
|
cache_control: getCacheControl(providerOptions)
|
|
1216
1223
|
});
|
|
1217
1224
|
break;
|
|
@@ -1223,7 +1230,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1223
1230
|
role: "tool",
|
|
1224
1231
|
tool_call_id: toolResponse.toolCallId,
|
|
1225
1232
|
content: content2,
|
|
1226
|
-
cache_control: (
|
|
1233
|
+
cache_control: (_f = getCacheControl(providerOptions)) != null ? _f : getCacheControl(toolResponse.providerOptions)
|
|
1227
1234
|
});
|
|
1228
1235
|
}
|
|
1229
1236
|
break;
|
|
@@ -1363,7 +1370,7 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1363
1370
|
content: z7.array(
|
|
1364
1371
|
z7.object({
|
|
1365
1372
|
type: z7.string(),
|
|
1366
|
-
text: z7.string()
|
|
1373
|
+
text: z7.string().optional()
|
|
1367
1374
|
}).passthrough()
|
|
1368
1375
|
).optional()
|
|
1369
1376
|
}).passthrough()
|
|
@@ -1446,7 +1453,7 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1446
1453
|
content: z7.array(
|
|
1447
1454
|
z7.object({
|
|
1448
1455
|
type: z7.string(),
|
|
1449
|
-
text: z7.string()
|
|
1456
|
+
text: z7.string().optional()
|
|
1450
1457
|
}).passthrough()
|
|
1451
1458
|
).optional()
|
|
1452
1459
|
}).passthrough()
|
|
@@ -2586,7 +2593,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
2586
2593
|
}
|
|
2587
2594
|
|
|
2588
2595
|
// src/version.ts
|
|
2589
|
-
var VERSION = false ? "0.0.0-test" : "1.2.
|
|
2596
|
+
var VERSION = false ? "0.0.0-test" : "1.2.6";
|
|
2590
2597
|
|
|
2591
2598
|
// src/provider.ts
|
|
2592
2599
|
function createOpenRouter(options = {}) {
|