190proof 1.0.118 → 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/dist/index.js CHANGED
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // index.ts
30
+ // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  ClaudeModel: () => ClaudeModel,
@@ -44,7 +44,7 @@ __export(index_exports, {
44
44
  });
45
45
  module.exports = __toCommonJS(index_exports);
46
46
 
47
- // interfaces.ts
47
+ // src/interfaces.ts
48
48
  var ClaudeModel = /* @__PURE__ */ ((ClaudeModel2) => {
49
49
  ClaudeModel2["HAIKU_3"] = "claude-3-haiku-20240307";
50
50
  ClaudeModel2["SONNET_3"] = "claude-3-sonnet-20240229";
@@ -103,7 +103,7 @@ var GeminiModel = /* @__PURE__ */ ((GeminiModel2) => {
103
103
  return GeminiModel2;
104
104
  })(GeminiModel || {});
105
105
 
106
- // logger.ts
106
+ // src/logger.ts
107
107
  function formatIdentifier(identifier) {
108
108
  if (Array.isArray(identifier)) {
109
109
  return identifier.map((id) => `[${id}]`).join(" ");
@@ -128,11 +128,11 @@ var logger_default = {
128
128
  error
129
129
  };
130
130
 
131
- // index.ts
131
+ // src/index.ts
132
132
  var import_client_bedrock_runtime = require("@aws-sdk/client-bedrock-runtime");
133
133
  var import_axios = __toESM(require("axios"));
134
134
 
135
- // utils.ts
135
+ // src/utils.ts
136
136
  function timeout(ms) {
137
137
  return new Promise((resolve) => setTimeout(resolve, ms));
138
138
  }
@@ -142,7 +142,7 @@ function isHeicImage(name, mime) {
142
142
  return ["heic", "heif", "heics"].includes(extension) || !!(mime && ["image/heic", "image/heif", "image/heic-sequence"].includes(mime));
143
143
  }
144
144
 
145
- // index.ts
145
+ // src/index.ts
146
146
  var sharp = require("sharp");
147
147
  var decode = require("heic-decode");
148
148
  function anySignal(signals) {
@@ -1565,6 +1565,14 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
1565
1565
  let finishReason = null;
1566
1566
  let sawDone = false;
1567
1567
  let dataChunks = 0;
1568
+ const RAW_HEAD_MAX = 3e3;
1569
+ const RAW_TAIL_MAX = 1500;
1570
+ let rawHead = "";
1571
+ let rawTail = "";
1572
+ let generationId;
1573
+ const unreadKeys = /* @__PURE__ */ new Set();
1574
+ const KNOWN_DELTA_KEYS = /* @__PURE__ */ new Set(["role", "content", "reasoning", "reasoning_details", "tool_calls"]);
1575
+ const KNOWN_CHOICE_KEYS = /* @__PURE__ */ new Set(["index", "delta", "finish_reason", "native_finish_reason", "logprobs"]);
1568
1576
  try {
1569
1577
  armStallTimer();
1570
1578
  const response = await fetch(openRouterEndpoint(), {
@@ -1616,6 +1624,11 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
1616
1624
  sawDone = true;
1617
1625
  break outer;
1618
1626
  }
1627
+ if (rawHead.length < RAW_HEAD_MAX) {
1628
+ rawHead += dataStr.slice(0, RAW_HEAD_MAX - rawHead.length) + "\n";
1629
+ } else {
1630
+ rawTail = (rawTail + dataStr + "\n").slice(-RAW_TAIL_MAX);
1631
+ }
1619
1632
  let json;
1620
1633
  try {
1621
1634
  json = JSON.parse(dataStr);
@@ -1637,6 +1650,7 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
1637
1650
  throw error2;
1638
1651
  }
1639
1652
  if (json.provider) provider = json.provider;
1653
+ if (json.id && !generationId) generationId = json.id;
1640
1654
  let useful = false;
1641
1655
  if (json.usage) {
1642
1656
  usage = json.usage;
@@ -1645,6 +1659,12 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
1645
1659
  const choice = (_c = json.choices) == null ? void 0 : _c[0];
1646
1660
  if (choice) {
1647
1661
  const delta = (_d = choice.delta) != null ? _d : {};
1662
+ for (const k of Object.keys(choice)) {
1663
+ if (!KNOWN_CHOICE_KEYS.has(k) && choice[k] != null) unreadKeys.add(`choice.${k}`);
1664
+ }
1665
+ for (const k of Object.keys(delta)) {
1666
+ if (!KNOWN_DELTA_KEYS.has(k) && delta[k] != null && delta[k] !== "") unreadKeys.add(`delta.${k}`);
1667
+ }
1648
1668
  if (delta.content) {
1649
1669
  paragraph += delta.content;
1650
1670
  useful = true;
@@ -1701,7 +1721,12 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
1701
1721
  usage,
1702
1722
  paragraph: paragraph.slice(0, 500),
1703
1723
  reasoningChars: reasoning.length,
1704
- toolCalls
1724
+ toolCalls,
1725
+ generationId,
1726
+ dataChunks,
1727
+ unreadKeys: [...unreadKeys],
1728
+ rawHead,
1729
+ rawTail: rawTail || void 0
1705
1730
  })
1706
1731
  });
1707
1732
  } catch (error2) {