@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.mjs
CHANGED
|
@@ -18,32 +18,6 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
|
-
// src/schemas/reasoning-details.ts
|
|
22
|
-
import { z } from "zod/v4";
|
|
23
|
-
var ReasoningDetailSummarySchema = z.object({
|
|
24
|
-
type: z.literal("reasoning.summary" /* Summary */),
|
|
25
|
-
summary: z.string()
|
|
26
|
-
});
|
|
27
|
-
var ReasoningDetailEncryptedSchema = z.object({
|
|
28
|
-
type: z.literal("reasoning.encrypted" /* Encrypted */),
|
|
29
|
-
data: z.string()
|
|
30
|
-
});
|
|
31
|
-
var ReasoningDetailTextSchema = z.object({
|
|
32
|
-
type: z.literal("reasoning.text" /* Text */),
|
|
33
|
-
text: z.string().nullish(),
|
|
34
|
-
signature: z.string().nullish()
|
|
35
|
-
});
|
|
36
|
-
var ReasoningDetailUnionSchema = z.union([
|
|
37
|
-
ReasoningDetailSummarySchema,
|
|
38
|
-
ReasoningDetailEncryptedSchema,
|
|
39
|
-
ReasoningDetailTextSchema
|
|
40
|
-
]);
|
|
41
|
-
var ReasoningDetailsWithUnknownSchema = z.union([
|
|
42
|
-
ReasoningDetailUnionSchema,
|
|
43
|
-
z.unknown().transform(() => null)
|
|
44
|
-
]);
|
|
45
|
-
var ReasoningDetailArraySchema = z.array(ReasoningDetailsWithUnknownSchema).transform((d) => d.filter((d2) => !!d2));
|
|
46
|
-
|
|
47
21
|
// node_modules/.pnpm/@ai-sdk+provider@2.0.0-beta.1/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
48
22
|
var marker = "vercel.ai.error";
|
|
49
23
|
var symbol = Symbol.for(marker);
|
|
@@ -428,28 +402,28 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
428
402
|
}
|
|
429
403
|
};
|
|
430
404
|
|
|
431
|
-
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.0-beta.5_zod@
|
|
405
|
+
// 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
|
|
432
406
|
import * as z4 from "zod/v4";
|
|
433
407
|
|
|
434
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
408
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
435
409
|
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
436
410
|
|
|
437
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
411
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
438
412
|
import { ZodFirstPartyTypeKind as ZodFirstPartyTypeKind3 } from "zod";
|
|
439
413
|
|
|
440
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
414
|
+
// 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
|
|
441
415
|
import { ZodFirstPartyTypeKind } from "zod";
|
|
442
416
|
|
|
443
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
417
|
+
// 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
|
|
444
418
|
import { ZodFirstPartyTypeKind as ZodFirstPartyTypeKind2 } from "zod";
|
|
445
419
|
|
|
446
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
420
|
+
// 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
|
|
447
421
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
448
422
|
|
|
449
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@
|
|
423
|
+
// 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
|
|
450
424
|
import { ZodOptional } from "zod";
|
|
451
425
|
|
|
452
|
-
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.0-beta.5_zod@
|
|
426
|
+
// 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
|
|
453
427
|
function combineHeaders(...headers) {
|
|
454
428
|
return headers.reduce(
|
|
455
429
|
(combinedHeaders, currentHeaders) => __spreadValues(__spreadValues({}, combinedHeaders), currentHeaders != null ? currentHeaders : {}),
|
|
@@ -866,6 +840,32 @@ function convertUint8ArrayToBase64(array) {
|
|
|
866
840
|
return btoa(latin1string);
|
|
867
841
|
}
|
|
868
842
|
|
|
843
|
+
// src/schemas/reasoning-details.ts
|
|
844
|
+
import { z } from "zod/v4";
|
|
845
|
+
var ReasoningDetailSummarySchema = z.object({
|
|
846
|
+
type: z.literal("reasoning.summary" /* Summary */),
|
|
847
|
+
summary: z.string()
|
|
848
|
+
});
|
|
849
|
+
var ReasoningDetailEncryptedSchema = z.object({
|
|
850
|
+
type: z.literal("reasoning.encrypted" /* Encrypted */),
|
|
851
|
+
data: z.string()
|
|
852
|
+
});
|
|
853
|
+
var ReasoningDetailTextSchema = z.object({
|
|
854
|
+
type: z.literal("reasoning.text" /* Text */),
|
|
855
|
+
text: z.string().nullish(),
|
|
856
|
+
signature: z.string().nullish()
|
|
857
|
+
});
|
|
858
|
+
var ReasoningDetailUnionSchema = z.union([
|
|
859
|
+
ReasoningDetailSummarySchema,
|
|
860
|
+
ReasoningDetailEncryptedSchema,
|
|
861
|
+
ReasoningDetailTextSchema
|
|
862
|
+
]);
|
|
863
|
+
var ReasoningDetailsWithUnknownSchema = z.union([
|
|
864
|
+
ReasoningDetailUnionSchema,
|
|
865
|
+
z.unknown().transform(() => null)
|
|
866
|
+
]);
|
|
867
|
+
var ReasoningDetailArraySchema = z.array(ReasoningDetailsWithUnknownSchema).transform((d) => d.filter((d2) => !!d2));
|
|
868
|
+
|
|
869
869
|
// src/schemas/error-response.ts
|
|
870
870
|
import { z as z2 } from "zod/v4";
|
|
871
871
|
var OpenRouterErrorResponseSchema = z2.object({
|
|
@@ -1360,15 +1360,13 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1360
1360
|
cachedInputTokens: 0
|
|
1361
1361
|
};
|
|
1362
1362
|
const reasoningDetails = (_i = choice.message.reasoning_details) != null ? _i : [];
|
|
1363
|
-
reasoningDetails.length > 0 ? reasoningDetails.map((detail) => {
|
|
1364
|
-
var _a16;
|
|
1363
|
+
const reasoning = reasoningDetails.length > 0 ? reasoningDetails.map((detail) => {
|
|
1365
1364
|
switch (detail.type) {
|
|
1366
1365
|
case "reasoning.text" /* Text */: {
|
|
1367
1366
|
if (detail.text) {
|
|
1368
1367
|
return {
|
|
1369
|
-
type: "
|
|
1370
|
-
text: detail.text
|
|
1371
|
-
signature: (_a16 = detail.signature) != null ? _a16 : void 0
|
|
1368
|
+
type: "reasoning",
|
|
1369
|
+
text: detail.text
|
|
1372
1370
|
};
|
|
1373
1371
|
}
|
|
1374
1372
|
break;
|
|
@@ -1376,7 +1374,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1376
1374
|
case "reasoning.summary" /* Summary */: {
|
|
1377
1375
|
if (detail.summary) {
|
|
1378
1376
|
return {
|
|
1379
|
-
type: "
|
|
1377
|
+
type: "reasoning",
|
|
1380
1378
|
text: detail.summary
|
|
1381
1379
|
};
|
|
1382
1380
|
}
|
|
@@ -1385,8 +1383,8 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1385
1383
|
case "reasoning.encrypted" /* Encrypted */: {
|
|
1386
1384
|
if (detail.data) {
|
|
1387
1385
|
return {
|
|
1388
|
-
type: "
|
|
1389
|
-
|
|
1386
|
+
type: "reasoning",
|
|
1387
|
+
text: "[REDACTED]"
|
|
1390
1388
|
};
|
|
1391
1389
|
}
|
|
1392
1390
|
break;
|
|
@@ -1398,11 +1396,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1398
1396
|
return null;
|
|
1399
1397
|
}).filter((p) => p !== null) : choice.message.reasoning ? [
|
|
1400
1398
|
{
|
|
1401
|
-
type: "
|
|
1399
|
+
type: "reasoning",
|
|
1402
1400
|
text: choice.message.reasoning
|
|
1403
1401
|
}
|
|
1404
1402
|
] : [];
|
|
1405
1403
|
const content = [];
|
|
1404
|
+
content.push(...reasoning);
|
|
1406
1405
|
if (choice.message.content) {
|
|
1407
1406
|
content.push({
|
|
1408
1407
|
type: "text",
|
|
@@ -1551,21 +1550,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1551
1550
|
return;
|
|
1552
1551
|
}
|
|
1553
1552
|
const delta = choice.delta;
|
|
1554
|
-
if (delta.content != null) {
|
|
1555
|
-
if (!textStarted) {
|
|
1556
|
-
textId = openrouterResponseId || generateId();
|
|
1557
|
-
controller.enqueue({
|
|
1558
|
-
type: "text-start",
|
|
1559
|
-
id: textId
|
|
1560
|
-
});
|
|
1561
|
-
textStarted = true;
|
|
1562
|
-
}
|
|
1563
|
-
controller.enqueue({
|
|
1564
|
-
type: "text-delta",
|
|
1565
|
-
delta: delta.content,
|
|
1566
|
-
id: textId || generateId()
|
|
1567
|
-
});
|
|
1568
|
-
}
|
|
1569
1553
|
const emitReasoningChunk = (chunkText) => {
|
|
1570
1554
|
if (!reasoningStarted) {
|
|
1571
1555
|
reasoningId = openrouterResponseId || generateId();
|
|
@@ -1581,9 +1565,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1581
1565
|
id: reasoningId || generateId()
|
|
1582
1566
|
});
|
|
1583
1567
|
};
|
|
1584
|
-
if (delta.reasoning != null) {
|
|
1585
|
-
emitReasoningChunk(delta.reasoning);
|
|
1586
|
-
}
|
|
1587
1568
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
1588
1569
|
for (const detail of delta.reasoning_details) {
|
|
1589
1570
|
switch (detail.type) {
|
|
@@ -1611,6 +1592,23 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1611
1592
|
}
|
|
1612
1593
|
}
|
|
1613
1594
|
}
|
|
1595
|
+
} else if (delta.reasoning != null) {
|
|
1596
|
+
emitReasoningChunk(delta.reasoning);
|
|
1597
|
+
}
|
|
1598
|
+
if (delta.content != null) {
|
|
1599
|
+
if (!textStarted) {
|
|
1600
|
+
textId = openrouterResponseId || generateId();
|
|
1601
|
+
controller.enqueue({
|
|
1602
|
+
type: "text-start",
|
|
1603
|
+
id: textId
|
|
1604
|
+
});
|
|
1605
|
+
textStarted = true;
|
|
1606
|
+
}
|
|
1607
|
+
controller.enqueue({
|
|
1608
|
+
type: "text-delta",
|
|
1609
|
+
delta: delta.content,
|
|
1610
|
+
id: textId || generateId()
|
|
1611
|
+
});
|
|
1614
1612
|
}
|
|
1615
1613
|
if (delta.tool_calls != null) {
|
|
1616
1614
|
for (const toolCallDelta of delta.tool_calls) {
|
|
@@ -1710,7 +1708,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1710
1708
|
var _a16;
|
|
1711
1709
|
if (finishReason === "tool-calls") {
|
|
1712
1710
|
for (const toolCall of toolCalls) {
|
|
1713
|
-
if (!toolCall.sent) {
|
|
1711
|
+
if (toolCall && !toolCall.sent) {
|
|
1714
1712
|
controller.enqueue({
|
|
1715
1713
|
type: "tool-call",
|
|
1716
1714
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|