@openrouter/ai-sdk-provider 1.0.0-beta.4 → 1.0.0-beta.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 +34 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -36
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +60 -62
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +60 -62
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -52,32 +52,6 @@ __export(index_exports, {
|
|
|
52
52
|
});
|
|
53
53
|
module.exports = __toCommonJS(index_exports);
|
|
54
54
|
|
|
55
|
-
// src/schemas/reasoning-details.ts
|
|
56
|
-
var import_v4 = require("zod/v4");
|
|
57
|
-
var ReasoningDetailSummarySchema = import_v4.z.object({
|
|
58
|
-
type: import_v4.z.literal("reasoning.summary" /* Summary */),
|
|
59
|
-
summary: import_v4.z.string()
|
|
60
|
-
});
|
|
61
|
-
var ReasoningDetailEncryptedSchema = import_v4.z.object({
|
|
62
|
-
type: import_v4.z.literal("reasoning.encrypted" /* Encrypted */),
|
|
63
|
-
data: import_v4.z.string()
|
|
64
|
-
});
|
|
65
|
-
var ReasoningDetailTextSchema = import_v4.z.object({
|
|
66
|
-
type: import_v4.z.literal("reasoning.text" /* Text */),
|
|
67
|
-
text: import_v4.z.string().nullish(),
|
|
68
|
-
signature: import_v4.z.string().nullish()
|
|
69
|
-
});
|
|
70
|
-
var ReasoningDetailUnionSchema = import_v4.z.union([
|
|
71
|
-
ReasoningDetailSummarySchema,
|
|
72
|
-
ReasoningDetailEncryptedSchema,
|
|
73
|
-
ReasoningDetailTextSchema
|
|
74
|
-
]);
|
|
75
|
-
var ReasoningDetailsWithUnknownSchema = import_v4.z.union([
|
|
76
|
-
ReasoningDetailUnionSchema,
|
|
77
|
-
import_v4.z.unknown().transform(() => null)
|
|
78
|
-
]);
|
|
79
|
-
var ReasoningDetailArraySchema = import_v4.z.array(ReasoningDetailsWithUnknownSchema).transform((d) => d.filter((d2) => !!d2));
|
|
80
|
-
|
|
81
55
|
// node_modules/.pnpm/@ai-sdk+provider@2.0.0-beta.1/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
82
56
|
var marker = "vercel.ai.error";
|
|
83
57
|
var symbol = Symbol.for(marker);
|
|
@@ -462,28 +436,28 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
462
436
|
}
|
|
463
437
|
};
|
|
464
438
|
|
|
465
|
-
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.0-beta.5_zod@
|
|
439
|
+
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.0-beta.5_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
466
440
|
var z4 = __toESM(require("zod/v4"), 1);
|
|
467
441
|
|
|
468
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
442
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
469
443
|
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
470
444
|
|
|
471
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
445
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
472
446
|
var import_zod4 = require("zod");
|
|
473
447
|
|
|
474
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
448
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
475
449
|
var import_zod = require("zod");
|
|
476
450
|
|
|
477
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
451
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
478
452
|
var import_zod2 = require("zod");
|
|
479
453
|
|
|
480
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
454
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
481
455
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
482
456
|
|
|
483
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
457
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
484
458
|
var import_zod3 = require("zod");
|
|
485
459
|
|
|
486
|
-
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.0-beta.5_zod@
|
|
460
|
+
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.0-beta.5_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
487
461
|
function combineHeaders(...headers) {
|
|
488
462
|
return headers.reduce(
|
|
489
463
|
(combinedHeaders, currentHeaders) => __spreadValues(__spreadValues({}, combinedHeaders), currentHeaders != null ? currentHeaders : {}),
|
|
@@ -900,6 +874,32 @@ function convertUint8ArrayToBase64(array) {
|
|
|
900
874
|
return btoa(latin1string);
|
|
901
875
|
}
|
|
902
876
|
|
|
877
|
+
// src/schemas/reasoning-details.ts
|
|
878
|
+
var import_v4 = require("zod/v4");
|
|
879
|
+
var ReasoningDetailSummarySchema = import_v4.z.object({
|
|
880
|
+
type: import_v4.z.literal("reasoning.summary" /* Summary */),
|
|
881
|
+
summary: import_v4.z.string()
|
|
882
|
+
});
|
|
883
|
+
var ReasoningDetailEncryptedSchema = import_v4.z.object({
|
|
884
|
+
type: import_v4.z.literal("reasoning.encrypted" /* Encrypted */),
|
|
885
|
+
data: import_v4.z.string()
|
|
886
|
+
});
|
|
887
|
+
var ReasoningDetailTextSchema = import_v4.z.object({
|
|
888
|
+
type: import_v4.z.literal("reasoning.text" /* Text */),
|
|
889
|
+
text: import_v4.z.string().nullish(),
|
|
890
|
+
signature: import_v4.z.string().nullish()
|
|
891
|
+
});
|
|
892
|
+
var ReasoningDetailUnionSchema = import_v4.z.union([
|
|
893
|
+
ReasoningDetailSummarySchema,
|
|
894
|
+
ReasoningDetailEncryptedSchema,
|
|
895
|
+
ReasoningDetailTextSchema
|
|
896
|
+
]);
|
|
897
|
+
var ReasoningDetailsWithUnknownSchema = import_v4.z.union([
|
|
898
|
+
ReasoningDetailUnionSchema,
|
|
899
|
+
import_v4.z.unknown().transform(() => null)
|
|
900
|
+
]);
|
|
901
|
+
var ReasoningDetailArraySchema = import_v4.z.array(ReasoningDetailsWithUnknownSchema).transform((d) => d.filter((d2) => !!d2));
|
|
902
|
+
|
|
903
903
|
// src/schemas/error-response.ts
|
|
904
904
|
var import_v42 = require("zod/v4");
|
|
905
905
|
var OpenRouterErrorResponseSchema = import_v42.z.object({
|
|
@@ -1394,15 +1394,13 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1394
1394
|
cachedInputTokens: 0
|
|
1395
1395
|
};
|
|
1396
1396
|
const reasoningDetails = (_i = choice.message.reasoning_details) != null ? _i : [];
|
|
1397
|
-
reasoningDetails.length > 0 ? reasoningDetails.map((detail) => {
|
|
1398
|
-
var _a16;
|
|
1397
|
+
const reasoning = reasoningDetails.length > 0 ? reasoningDetails.map((detail) => {
|
|
1399
1398
|
switch (detail.type) {
|
|
1400
1399
|
case "reasoning.text" /* Text */: {
|
|
1401
1400
|
if (detail.text) {
|
|
1402
1401
|
return {
|
|
1403
|
-
type: "
|
|
1404
|
-
text: detail.text
|
|
1405
|
-
signature: (_a16 = detail.signature) != null ? _a16 : void 0
|
|
1402
|
+
type: "reasoning",
|
|
1403
|
+
text: detail.text
|
|
1406
1404
|
};
|
|
1407
1405
|
}
|
|
1408
1406
|
break;
|
|
@@ -1410,7 +1408,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1410
1408
|
case "reasoning.summary" /* Summary */: {
|
|
1411
1409
|
if (detail.summary) {
|
|
1412
1410
|
return {
|
|
1413
|
-
type: "
|
|
1411
|
+
type: "reasoning",
|
|
1414
1412
|
text: detail.summary
|
|
1415
1413
|
};
|
|
1416
1414
|
}
|
|
@@ -1419,8 +1417,8 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1419
1417
|
case "reasoning.encrypted" /* Encrypted */: {
|
|
1420
1418
|
if (detail.data) {
|
|
1421
1419
|
return {
|
|
1422
|
-
type: "
|
|
1423
|
-
|
|
1420
|
+
type: "reasoning",
|
|
1421
|
+
text: "[REDACTED]"
|
|
1424
1422
|
};
|
|
1425
1423
|
}
|
|
1426
1424
|
break;
|
|
@@ -1432,11 +1430,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1432
1430
|
return null;
|
|
1433
1431
|
}).filter((p) => p !== null) : choice.message.reasoning ? [
|
|
1434
1432
|
{
|
|
1435
|
-
type: "
|
|
1433
|
+
type: "reasoning",
|
|
1436
1434
|
text: choice.message.reasoning
|
|
1437
1435
|
}
|
|
1438
1436
|
] : [];
|
|
1439
1437
|
const content = [];
|
|
1438
|
+
content.push(...reasoning);
|
|
1440
1439
|
if (choice.message.content) {
|
|
1441
1440
|
content.push({
|
|
1442
1441
|
type: "text",
|
|
@@ -1585,21 +1584,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1585
1584
|
return;
|
|
1586
1585
|
}
|
|
1587
1586
|
const delta = choice.delta;
|
|
1588
|
-
if (delta.content != null) {
|
|
1589
|
-
if (!textStarted) {
|
|
1590
|
-
textId = openrouterResponseId || generateId();
|
|
1591
|
-
controller.enqueue({
|
|
1592
|
-
type: "text-start",
|
|
1593
|
-
id: textId
|
|
1594
|
-
});
|
|
1595
|
-
textStarted = true;
|
|
1596
|
-
}
|
|
1597
|
-
controller.enqueue({
|
|
1598
|
-
type: "text-delta",
|
|
1599
|
-
delta: delta.content,
|
|
1600
|
-
id: textId || generateId()
|
|
1601
|
-
});
|
|
1602
|
-
}
|
|
1603
1587
|
const emitReasoningChunk = (chunkText) => {
|
|
1604
1588
|
if (!reasoningStarted) {
|
|
1605
1589
|
reasoningId = openrouterResponseId || generateId();
|
|
@@ -1615,9 +1599,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1615
1599
|
id: reasoningId || generateId()
|
|
1616
1600
|
});
|
|
1617
1601
|
};
|
|
1618
|
-
if (delta.reasoning != null) {
|
|
1619
|
-
emitReasoningChunk(delta.reasoning);
|
|
1620
|
-
}
|
|
1621
1602
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
1622
1603
|
for (const detail of delta.reasoning_details) {
|
|
1623
1604
|
switch (detail.type) {
|
|
@@ -1645,6 +1626,23 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1645
1626
|
}
|
|
1646
1627
|
}
|
|
1647
1628
|
}
|
|
1629
|
+
} else if (delta.reasoning != null) {
|
|
1630
|
+
emitReasoningChunk(delta.reasoning);
|
|
1631
|
+
}
|
|
1632
|
+
if (delta.content != null) {
|
|
1633
|
+
if (!textStarted) {
|
|
1634
|
+
textId = openrouterResponseId || generateId();
|
|
1635
|
+
controller.enqueue({
|
|
1636
|
+
type: "text-start",
|
|
1637
|
+
id: textId
|
|
1638
|
+
});
|
|
1639
|
+
textStarted = true;
|
|
1640
|
+
}
|
|
1641
|
+
controller.enqueue({
|
|
1642
|
+
type: "text-delta",
|
|
1643
|
+
delta: delta.content,
|
|
1644
|
+
id: textId || generateId()
|
|
1645
|
+
});
|
|
1648
1646
|
}
|
|
1649
1647
|
if (delta.tool_calls != null) {
|
|
1650
1648
|
for (const toolCallDelta of delta.tool_calls) {
|
|
@@ -1744,7 +1742,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1744
1742
|
var _a16;
|
|
1745
1743
|
if (finishReason === "tool-calls") {
|
|
1746
1744
|
for (const toolCall of toolCalls) {
|
|
1747
|
-
if (!toolCall.sent) {
|
|
1745
|
+
if (toolCall && !toolCall.sent) {
|
|
1748
1746
|
controller.enqueue({
|
|
1749
1747
|
type: "tool-call",
|
|
1750
1748
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|