@askalf/dario 3.10.2 → 3.10.3
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/proxy.js +25 -2
- package/package.json +1 -1
package/dist/proxy.js
CHANGED
|
@@ -1013,14 +1013,37 @@ export async function startProxy(opts = {}) {
|
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
1015
|
requestCount++;
|
|
1016
|
-
// Log billing classification on first request or in verbose mode
|
|
1016
|
+
// Log billing classification on first request or in verbose mode.
|
|
1017
|
+
//
|
|
1018
|
+
// Anthropic is inconsistent about returning rate-limit headers:
|
|
1019
|
+
// - Non-200 responses (429, 500, early aborts) often omit them entirely.
|
|
1020
|
+
// - The overage-utilization header is omitted when there is no overage
|
|
1021
|
+
// bucket configured or when the subscription claim covers the request
|
|
1022
|
+
// — in that case "overage" is effectively 0%, not unknown.
|
|
1023
|
+
// Pre-fix we logged `overage: ?` on every five_hour request that had no
|
|
1024
|
+
// overage configured, which looked like a broken parser (see #37 log
|
|
1025
|
+
// dump). Fix: treat missing overage header as 0% when the claim is
|
|
1026
|
+
// five_hour / five_hour_fallback (the subscription covered it), and fall
|
|
1027
|
+
// back to `n/a` in the genuinely-unknown case.
|
|
1017
1028
|
const billingClaim = upstream.headers.get('anthropic-ratelimit-unified-representative-claim');
|
|
1018
1029
|
const overageUtil = upstream.headers.get('anthropic-ratelimit-unified-overage-utilization');
|
|
1019
1030
|
if (requestCount === 1 || verbose) {
|
|
1020
1031
|
if (billingClaim) {
|
|
1021
|
-
|
|
1032
|
+
let overagePct;
|
|
1033
|
+
if (overageUtil !== null) {
|
|
1034
|
+
overagePct = `${Math.round(parseFloat(overageUtil) * 100)}%`;
|
|
1035
|
+
}
|
|
1036
|
+
else if (billingClaim === 'five_hour' || billingClaim === 'five_hour_fallback') {
|
|
1037
|
+
overagePct = '0%';
|
|
1038
|
+
}
|
|
1039
|
+
else {
|
|
1040
|
+
overagePct = 'n/a';
|
|
1041
|
+
}
|
|
1022
1042
|
console.log(`[dario] #${requestCount} billing: ${billingClaim} (overage: ${overagePct})`);
|
|
1023
1043
|
}
|
|
1044
|
+
else if (verbose) {
|
|
1045
|
+
console.log(`[dario] #${requestCount} billing: headers absent (status=${upstream.status})`);
|
|
1046
|
+
}
|
|
1024
1047
|
}
|
|
1025
1048
|
res.writeHead(upstream.status, responseHeaders);
|
|
1026
1049
|
if (isStream && upstream.body) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askalf/dario",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.3",
|
|
4
4
|
"description": "A local LLM router. One endpoint, every provider — Claude subscriptions, OpenAI, OpenRouter, Groq, local LiteLLM, any OpenAI-compat endpoint — your tools don't need to change.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|