copilot-relay 0.1.0 → 0.1.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/main.js +0 -14
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2477,7 +2477,6 @@ const getTokenCount = async (payload, model) => {
|
|
|
2477
2477
|
//#endregion
|
|
2478
2478
|
//#region src/routes/claude.ts
|
|
2479
2479
|
const claudeRoutes = new Hono();
|
|
2480
|
-
const streamKeepAliveIntervalMs = 15e3;
|
|
2481
2480
|
const createTokenCountModel = (modelId) => ({
|
|
2482
2481
|
capabilities: { tokenizer: "o200k_base" },
|
|
2483
2482
|
id: modelId
|
|
@@ -2555,17 +2554,6 @@ const createQueuedClaudeStreamWriter = (write) => {
|
|
|
2555
2554
|
return pending;
|
|
2556
2555
|
};
|
|
2557
2556
|
};
|
|
2558
|
-
const startClaudeStreamKeepAlive = (writeEvent) => {
|
|
2559
|
-
const writePing = () => {
|
|
2560
|
-
writeEvent({ type: "ping" }).catch(() => void 0);
|
|
2561
|
-
};
|
|
2562
|
-
writePing();
|
|
2563
|
-
const timer = setInterval(writePing, streamKeepAliveIntervalMs);
|
|
2564
|
-
if (typeof timer.unref === "function") timer.unref();
|
|
2565
|
-
return () => {
|
|
2566
|
-
clearInterval(timer);
|
|
2567
|
-
};
|
|
2568
|
-
};
|
|
2569
2557
|
const writeClaudeStreamEvents = async (events$1, writeEvent) => {
|
|
2570
2558
|
for (const event of events$1) await writeEvent(event);
|
|
2571
2559
|
};
|
|
@@ -2667,14 +2655,12 @@ claudeRoutes.post("/messages", async (c) => {
|
|
|
2667
2655
|
event: event.type,
|
|
2668
2656
|
data: JSON.stringify(event)
|
|
2669
2657
|
}));
|
|
2670
|
-
const stopKeepAlive = startClaudeStreamKeepAlive(writeEvent);
|
|
2671
2658
|
try {
|
|
2672
2659
|
await handleClaudeMessageRequest(config, claudePayload, requestSignal, requestId, writeEvent);
|
|
2673
2660
|
} catch (error) {
|
|
2674
2661
|
log.error("Error during Claude stream request:", error);
|
|
2675
2662
|
await writeEvent(translateErrorToClaudeErrorEvent());
|
|
2676
2663
|
} finally {
|
|
2677
|
-
stopKeepAlive();
|
|
2678
2664
|
log.info(`request_id=${requestId} stream completed ${Math.round(performance.now() - streamStarted)}ms`);
|
|
2679
2665
|
}
|
|
2680
2666
|
});
|