@blockrun/clawrouter 0.11.9 → 0.11.11
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 +11 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/reinstall.sh +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -770,6 +770,8 @@ type UsageEntry = {
|
|
|
770
770
|
baselineCost: number;
|
|
771
771
|
savings: number;
|
|
772
772
|
latencyMs: number;
|
|
773
|
+
/** Input (prompt) tokens reported by the provider */
|
|
774
|
+
inputTokens?: number;
|
|
773
775
|
/** Partner service ID (e.g., "x_users_lookup") — only set for partner API calls */
|
|
774
776
|
partnerId?: string;
|
|
775
777
|
/** Partner service name (e.g., "AttentionVC") — only set for partner API calls */
|
package/dist/index.js
CHANGED
|
@@ -5335,6 +5335,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5335
5335
|
let maxTokens = 4096;
|
|
5336
5336
|
let routingProfile = null;
|
|
5337
5337
|
let accumulatedContent = "";
|
|
5338
|
+
let responseInputTokens;
|
|
5338
5339
|
const isChatCompletion = req.url?.includes("/chat/completions");
|
|
5339
5340
|
const sessionId = getSessionId(req.headers);
|
|
5340
5341
|
let effectiveSessionId = sessionId;
|
|
@@ -6189,6 +6190,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
6189
6190
|
const jsonStr = jsonBody.toString();
|
|
6190
6191
|
try {
|
|
6191
6192
|
const rsp = JSON.parse(jsonStr);
|
|
6193
|
+
if (rsp.usage && typeof rsp.usage === "object") {
|
|
6194
|
+
const u = rsp.usage;
|
|
6195
|
+
if (typeof u.prompt_tokens === "number") responseInputTokens = u.prompt_tokens;
|
|
6196
|
+
}
|
|
6192
6197
|
const baseChunk = {
|
|
6193
6198
|
id: rsp.id ?? `chatcmpl-${Date.now()}`,
|
|
6194
6199
|
object: "chat.completion.chunk",
|
|
@@ -6337,6 +6342,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
6337
6342
|
if (rspJson.choices?.[0]?.message?.content) {
|
|
6338
6343
|
accumulatedContent = rspJson.choices[0].message.content;
|
|
6339
6344
|
}
|
|
6345
|
+
if (rspJson.usage && typeof rspJson.usage === "object") {
|
|
6346
|
+
if (typeof rspJson.usage.prompt_tokens === "number")
|
|
6347
|
+
responseInputTokens = rspJson.usage.prompt_tokens;
|
|
6348
|
+
}
|
|
6340
6349
|
} catch {
|
|
6341
6350
|
}
|
|
6342
6351
|
}
|
|
@@ -6385,7 +6394,8 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
6385
6394
|
cost: costWithBuffer,
|
|
6386
6395
|
baselineCost: baselineWithBuffer,
|
|
6387
6396
|
savings: accurateCosts.savings,
|
|
6388
|
-
latencyMs: Date.now() - startTime
|
|
6397
|
+
latencyMs: Date.now() - startTime,
|
|
6398
|
+
...responseInputTokens !== void 0 && { inputTokens: responseInputTokens }
|
|
6389
6399
|
};
|
|
6390
6400
|
logUsage(entry).catch(() => {
|
|
6391
6401
|
});
|
|
@@ -6789,8 +6799,8 @@ function injectModelsConfig(logger) {
|
|
|
6789
6799
|
"openai/gpt-5.2",
|
|
6790
6800
|
"openai/gpt-4o",
|
|
6791
6801
|
"openai/o3",
|
|
6792
|
-
"google/gemini-
|
|
6793
|
-
"google/gemini-
|
|
6802
|
+
"google/gemini-3.1-pro",
|
|
6803
|
+
"google/gemini-3-flash-preview",
|
|
6794
6804
|
"deepseek/deepseek-chat",
|
|
6795
6805
|
"moonshot/kimi-k2.5",
|
|
6796
6806
|
"xai/grok-3",
|