190proof 1.0.117 → 1.0.119
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/README.md +1 -1
- package/dist/index.d.mts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +37 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
// interfaces.ts
|
|
8
|
+
// src/interfaces.ts
|
|
9
9
|
var ClaudeModel = /* @__PURE__ */ ((ClaudeModel2) => {
|
|
10
10
|
ClaudeModel2["HAIKU_3"] = "claude-3-haiku-20240307";
|
|
11
11
|
ClaudeModel2["SONNET_3"] = "claude-3-sonnet-20240229";
|
|
@@ -64,7 +64,7 @@ var GeminiModel = /* @__PURE__ */ ((GeminiModel2) => {
|
|
|
64
64
|
return GeminiModel2;
|
|
65
65
|
})(GeminiModel || {});
|
|
66
66
|
|
|
67
|
-
// logger.ts
|
|
67
|
+
// src/logger.ts
|
|
68
68
|
function formatIdentifier(identifier) {
|
|
69
69
|
if (Array.isArray(identifier)) {
|
|
70
70
|
return identifier.map((id) => `[${id}]`).join(" ");
|
|
@@ -89,14 +89,14 @@ var logger_default = {
|
|
|
89
89
|
error
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
// index.ts
|
|
92
|
+
// src/index.ts
|
|
93
93
|
import {
|
|
94
94
|
BedrockRuntimeClient,
|
|
95
95
|
InvokeModelCommand
|
|
96
96
|
} from "@aws-sdk/client-bedrock-runtime";
|
|
97
97
|
import axios from "axios";
|
|
98
98
|
|
|
99
|
-
// utils.ts
|
|
99
|
+
// src/utils.ts
|
|
100
100
|
function timeout(ms) {
|
|
101
101
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
102
102
|
}
|
|
@@ -106,7 +106,7 @@ function isHeicImage(name, mime) {
|
|
|
106
106
|
return ["heic", "heif", "heics"].includes(extension) || !!(mime && ["image/heic", "image/heif", "image/heic-sequence"].includes(mime));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
// index.ts
|
|
109
|
+
// src/index.ts
|
|
110
110
|
var sharp = __require("sharp");
|
|
111
111
|
var decode = __require("heic-decode");
|
|
112
112
|
function anySignal(signals) {
|
|
@@ -1378,7 +1378,11 @@ function prepareOpenRouterPayload(payload) {
|
|
|
1378
1378
|
tool_choice: payload.function_call ? typeof payload.function_call === "string" ? payload.function_call : { type: "function", function: payload.function_call } : void 0,
|
|
1379
1379
|
temperature: payload.temperature,
|
|
1380
1380
|
provider: payload.provider,
|
|
1381
|
-
|
|
1381
|
+
// Nested form is OpenRouter's canonical param and the only one that
|
|
1382
|
+
// accepts "max" (flat reasoning_effort rejects it — OpenAI enum tops out
|
|
1383
|
+
// at xhigh, and measured on gpt-5.6-luna nested max buys more reasoning
|
|
1384
|
+
// tokens than xhigh despite the docs calling them equivalent).
|
|
1385
|
+
reasoning: payload.reasoningEffort ? { effort: payload.reasoningEffort } : void 0
|
|
1382
1386
|
};
|
|
1383
1387
|
}
|
|
1384
1388
|
var DSML_ENVELOPE_RE = /<|+DSML|+tool_calls>/;
|
|
@@ -1525,6 +1529,14 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
|
|
|
1525
1529
|
let finishReason = null;
|
|
1526
1530
|
let sawDone = false;
|
|
1527
1531
|
let dataChunks = 0;
|
|
1532
|
+
const RAW_HEAD_MAX = 3e3;
|
|
1533
|
+
const RAW_TAIL_MAX = 1500;
|
|
1534
|
+
let rawHead = "";
|
|
1535
|
+
let rawTail = "";
|
|
1536
|
+
let generationId;
|
|
1537
|
+
const unreadKeys = /* @__PURE__ */ new Set();
|
|
1538
|
+
const KNOWN_DELTA_KEYS = /* @__PURE__ */ new Set(["role", "content", "reasoning", "reasoning_details", "tool_calls"]);
|
|
1539
|
+
const KNOWN_CHOICE_KEYS = /* @__PURE__ */ new Set(["index", "delta", "finish_reason", "native_finish_reason", "logprobs"]);
|
|
1528
1540
|
try {
|
|
1529
1541
|
armStallTimer();
|
|
1530
1542
|
const response = await fetch(openRouterEndpoint(), {
|
|
@@ -1576,6 +1588,11 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
|
|
|
1576
1588
|
sawDone = true;
|
|
1577
1589
|
break outer;
|
|
1578
1590
|
}
|
|
1591
|
+
if (rawHead.length < RAW_HEAD_MAX) {
|
|
1592
|
+
rawHead += dataStr.slice(0, RAW_HEAD_MAX - rawHead.length) + "\n";
|
|
1593
|
+
} else {
|
|
1594
|
+
rawTail = (rawTail + dataStr + "\n").slice(-RAW_TAIL_MAX);
|
|
1595
|
+
}
|
|
1579
1596
|
let json;
|
|
1580
1597
|
try {
|
|
1581
1598
|
json = JSON.parse(dataStr);
|
|
@@ -1597,6 +1614,7 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
|
|
|
1597
1614
|
throw error2;
|
|
1598
1615
|
}
|
|
1599
1616
|
if (json.provider) provider = json.provider;
|
|
1617
|
+
if (json.id && !generationId) generationId = json.id;
|
|
1600
1618
|
let useful = false;
|
|
1601
1619
|
if (json.usage) {
|
|
1602
1620
|
usage = json.usage;
|
|
@@ -1605,6 +1623,12 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
|
|
|
1605
1623
|
const choice = (_c = json.choices) == null ? void 0 : _c[0];
|
|
1606
1624
|
if (choice) {
|
|
1607
1625
|
const delta = (_d = choice.delta) != null ? _d : {};
|
|
1626
|
+
for (const k of Object.keys(choice)) {
|
|
1627
|
+
if (!KNOWN_CHOICE_KEYS.has(k) && choice[k] != null) unreadKeys.add(`choice.${k}`);
|
|
1628
|
+
}
|
|
1629
|
+
for (const k of Object.keys(delta)) {
|
|
1630
|
+
if (!KNOWN_DELTA_KEYS.has(k) && delta[k] != null && delta[k] !== "") unreadKeys.add(`delta.${k}`);
|
|
1631
|
+
}
|
|
1608
1632
|
if (delta.content) {
|
|
1609
1633
|
paragraph += delta.content;
|
|
1610
1634
|
useful = true;
|
|
@@ -1661,7 +1685,12 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
|
|
|
1661
1685
|
usage,
|
|
1662
1686
|
paragraph: paragraph.slice(0, 500),
|
|
1663
1687
|
reasoningChars: reasoning.length,
|
|
1664
|
-
toolCalls
|
|
1688
|
+
toolCalls,
|
|
1689
|
+
generationId,
|
|
1690
|
+
dataChunks,
|
|
1691
|
+
unreadKeys: [...unreadKeys],
|
|
1692
|
+
rawHead,
|
|
1693
|
+
rawTail: rawTail || void 0
|
|
1665
1694
|
})
|
|
1666
1695
|
});
|
|
1667
1696
|
} catch (error2) {
|