claudish 2.6.0 → 2.6.1
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 +13 -5
- package/package.json +1 -1
- package/recommended-models.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36152,6 +36152,8 @@ class OpenRouterHandler {
|
|
|
36152
36152
|
let ping = null;
|
|
36153
36153
|
const encoder = new TextEncoder;
|
|
36154
36154
|
const decoder = new TextDecoder;
|
|
36155
|
+
const middlewareManager = this.middlewareManager;
|
|
36156
|
+
const streamMetadata = new Map;
|
|
36155
36157
|
return c.body(new ReadableStream({
|
|
36156
36158
|
async start(controller) {
|
|
36157
36159
|
const send = (e, d) => {
|
|
@@ -36173,7 +36175,6 @@ data: ${JSON.stringify(d)}
|
|
|
36173
36175
|
const toolIds = new Set;
|
|
36174
36176
|
let accTxt = 0;
|
|
36175
36177
|
let lastActivity = Date.now();
|
|
36176
|
-
const scale = 128000 / 128000;
|
|
36177
36178
|
send("message_start", {
|
|
36178
36179
|
type: "message_start",
|
|
36179
36180
|
message: {
|
|
@@ -36192,7 +36193,7 @@ data: ${JSON.stringify(d)}
|
|
|
36192
36193
|
if (!isClosed && Date.now() - lastActivity > 1000)
|
|
36193
36194
|
send("ping", { type: "ping" });
|
|
36194
36195
|
}, 1000);
|
|
36195
|
-
const finalize = (reason, err) => {
|
|
36196
|
+
const finalize = async (reason, err) => {
|
|
36196
36197
|
if (finalized)
|
|
36197
36198
|
return;
|
|
36198
36199
|
finalized = true;
|
|
@@ -36209,6 +36210,7 @@ data: ${JSON.stringify(d)}
|
|
|
36209
36210
|
send("content_block_stop", { type: "content_block_stop", index: t.blockIndex });
|
|
36210
36211
|
t.closed = true;
|
|
36211
36212
|
}
|
|
36213
|
+
await middlewareManager.afterStreamComplete(target, streamMetadata);
|
|
36212
36214
|
if (reason === "error") {
|
|
36213
36215
|
send("error", { type: "error", error: { type: "api_error", message: err } });
|
|
36214
36216
|
} else {
|
|
@@ -36244,7 +36246,7 @@ data: ${JSON.stringify(d)}
|
|
|
36244
36246
|
continue;
|
|
36245
36247
|
const dataStr = line.slice(6);
|
|
36246
36248
|
if (dataStr === "[DONE]") {
|
|
36247
|
-
finalize("done");
|
|
36249
|
+
await finalize("done");
|
|
36248
36250
|
return;
|
|
36249
36251
|
}
|
|
36250
36252
|
try {
|
|
@@ -36253,6 +36255,12 @@ data: ${JSON.stringify(d)}
|
|
|
36253
36255
|
usage = chunk.usage;
|
|
36254
36256
|
const delta = chunk.choices?.[0]?.delta;
|
|
36255
36257
|
if (delta) {
|
|
36258
|
+
await middlewareManager.afterStreamChunk({
|
|
36259
|
+
modelId: target,
|
|
36260
|
+
chunk,
|
|
36261
|
+
delta,
|
|
36262
|
+
metadata: streamMetadata
|
|
36263
|
+
});
|
|
36256
36264
|
const txt = delta.content || "";
|
|
36257
36265
|
if (txt) {
|
|
36258
36266
|
lastActivity = Date.now();
|
|
@@ -36299,9 +36307,9 @@ data: ${JSON.stringify(d)}
|
|
|
36299
36307
|
} catch (e) {}
|
|
36300
36308
|
}
|
|
36301
36309
|
}
|
|
36302
|
-
finalize("unexpected");
|
|
36310
|
+
await finalize("unexpected");
|
|
36303
36311
|
} catch (e) {
|
|
36304
|
-
finalize("error", String(e));
|
|
36312
|
+
await finalize("error", String(e));
|
|
36305
36313
|
}
|
|
36306
36314
|
},
|
|
36307
36315
|
cancel() {
|
package/package.json
CHANGED