@bman654/clodex 2.1.3 → 2.1.4
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/cli.js +13 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -216,7 +216,7 @@ import { join } from "path";
|
|
|
216
216
|
// package.json
|
|
217
217
|
var package_default = {
|
|
218
218
|
name: "@bman654/clodex",
|
|
219
|
-
version: "2.1.
|
|
219
|
+
version: "2.1.4",
|
|
220
220
|
publishConfig: {
|
|
221
221
|
access: "public"
|
|
222
222
|
},
|
|
@@ -9739,7 +9739,7 @@ async function writeAnthropicStream(stream, modelId, write, log12, observer, too
|
|
|
9739
9739
|
let openToolId = null;
|
|
9740
9740
|
let finishReason = "end_turn";
|
|
9741
9741
|
let usage = {
|
|
9742
|
-
input_tokens: 0,
|
|
9742
|
+
input_tokens: observer?.initialInputTokens ?? 0,
|
|
9743
9743
|
output_tokens: 0,
|
|
9744
9744
|
cache_creation_input_tokens: 0,
|
|
9745
9745
|
cache_read_input_tokens: 0
|
|
@@ -9758,7 +9758,7 @@ async function writeAnthropicStream(stream, modelId, write, log12, observer, too
|
|
|
9758
9758
|
stop_reason: null,
|
|
9759
9759
|
stop_sequence: null,
|
|
9760
9760
|
usage: {
|
|
9761
|
-
input_tokens:
|
|
9761
|
+
input_tokens: 0,
|
|
9762
9762
|
output_tokens: 0,
|
|
9763
9763
|
cache_creation_input_tokens: 0,
|
|
9764
9764
|
cache_read_input_tokens: 0
|
|
@@ -9895,7 +9895,9 @@ async function writeAnthropicStream(stream, modelId, write, log12, observer, too
|
|
|
9895
9895
|
}
|
|
9896
9896
|
case "finish":
|
|
9897
9897
|
if (part.totalUsage) {
|
|
9898
|
-
|
|
9898
|
+
const finalUsage = toAnthropicUsage(part.totalUsage);
|
|
9899
|
+
const hasFinalInputUsage = finalUsage.input_tokens + finalUsage.cache_creation_input_tokens + finalUsage.cache_read_input_tokens > 0;
|
|
9900
|
+
usage = hasFinalInputUsage ? finalUsage : { ...usage, output_tokens: finalUsage.output_tokens };
|
|
9899
9901
|
}
|
|
9900
9902
|
if (part.finishReason === "tool-calls") finishReason = "tool_use";
|
|
9901
9903
|
else if (part.finishReason === "length") finishReason = "max_tokens";
|
|
@@ -10125,6 +10127,7 @@ function anthropicPromptTooLongMessage(body, contextWindow) {
|
|
|
10125
10127
|
// src/proxy.ts
|
|
10126
10128
|
var STREAM_KEEPALIVE_INTERVAL_MS = 2e4;
|
|
10127
10129
|
var STREAM_KEEPALIVE_PING = 'event: ping\ndata: {"type":"ping"}\n\n';
|
|
10130
|
+
var INTERNAL_ADAPTER_KEEPALIVE_TIMEOUT_MS = 6e4;
|
|
10128
10131
|
function createTranslationLifecycle(logPath, requestId, claudeSessionId, modelId, provider) {
|
|
10129
10132
|
if (!logPath || !requestId) return void 0;
|
|
10130
10133
|
const startedAt = Date.now();
|
|
@@ -10656,6 +10659,7 @@ data: ${JSON.stringify({
|
|
|
10656
10659
|
}
|
|
10657
10660
|
anthropicError(res, 404, `Unknown endpoint: ${req.method} ${req.url}`);
|
|
10658
10661
|
});
|
|
10662
|
+
server.keepAliveTimeout = INTERNAL_ADAPTER_KEEPALIVE_TIMEOUT_MS;
|
|
10659
10663
|
let address;
|
|
10660
10664
|
try {
|
|
10661
10665
|
address = await listenTcpServer(server, 0, "127.0.0.1");
|
|
@@ -12152,7 +12156,7 @@ function forwardRawAnthropicRequest(req, res, rawBody, origin, rejectUnauthorize
|
|
|
12152
12156
|
upstream.end(rawBody);
|
|
12153
12157
|
});
|
|
12154
12158
|
}
|
|
12155
|
-
function forwardToAdapter(req, res, rawBody, adapter, adapterRequest = http.request, lifecycle, isLocalShutdown = () => false) {
|
|
12159
|
+
function forwardToAdapter(req, res, rawBody, adapter, adapterRequest = http.request, adapterAgent, lifecycle, isLocalShutdown = () => false) {
|
|
12156
12160
|
return new Promise((resolve3) => {
|
|
12157
12161
|
const startedAt = Date.now();
|
|
12158
12162
|
let lastActivityAt = startedAt;
|
|
@@ -12260,6 +12264,7 @@ function forwardToAdapter(req, res, rawBody, adapter, adapterRequest = http.requ
|
|
|
12260
12264
|
port: adapter.port,
|
|
12261
12265
|
method: "POST",
|
|
12262
12266
|
path: req.url,
|
|
12267
|
+
agent: adapterAgent,
|
|
12263
12268
|
headers: {
|
|
12264
12269
|
"Content-Type": "application/json",
|
|
12265
12270
|
"Content-Length": String(rawBody.length),
|
|
@@ -12397,6 +12402,7 @@ async function startHttpProxy(options) {
|
|
|
12397
12402
|
options.modelAliases
|
|
12398
12403
|
);
|
|
12399
12404
|
}
|
|
12405
|
+
const adapterAgent = adapter ? new http.Agent({ keepAlive: true }) : void 0;
|
|
12400
12406
|
let shuttingDown = false;
|
|
12401
12407
|
const mitmServer = https.createServer({
|
|
12402
12408
|
key: certificates.serverKey,
|
|
@@ -12490,6 +12496,7 @@ async function startHttpProxy(options) {
|
|
|
12490
12496
|
adapterBody,
|
|
12491
12497
|
adapter,
|
|
12492
12498
|
options.adapterRequest,
|
|
12499
|
+
adapterAgent,
|
|
12493
12500
|
messagesEndpoint === "messages" && options.inferenceLogPath ? {
|
|
12494
12501
|
logPath: options.inferenceLogPath,
|
|
12495
12502
|
requestId,
|
|
@@ -12597,6 +12604,7 @@ async function startHttpProxy(options) {
|
|
|
12597
12604
|
options.host ?? "127.0.0.1"
|
|
12598
12605
|
);
|
|
12599
12606
|
} catch (err) {
|
|
12607
|
+
adapterAgent?.destroy();
|
|
12600
12608
|
adapter?.close();
|
|
12601
12609
|
throw err;
|
|
12602
12610
|
}
|