@askalf/dario 2.8.5 → 2.8.6
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/README.md +5 -4
- package/dist/proxy.js +28 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ Opus, Sonnet, Haiku — all models, streaming, tool use. Works with Cursor, Cont
|
|
|
68
68
|
<tr>
|
|
69
69
|
<td colspan="3" valign="top">
|
|
70
70
|
|
|
71
|
-
*"The 429s were driving us crazy running a multi-agent stack on Claude Max
|
|
71
|
+
*"The 429s were driving us crazy running a multi-agent stack on Claude Max. You found the billing tag, fixed the checksum, reverse-engineered the per-request hash from the binary — v2.8.5 running clean, zero reclassification."* — [@belangertrading](https://github.com/belangertrading), multi-agent stack on Claude Max
|
|
72
72
|
|
|
73
73
|
</td>
|
|
74
74
|
</tr>
|
|
@@ -80,7 +80,7 @@ Opus, Sonnet, Haiku — all models, streaming, tool use. Works with Cursor, Cont
|
|
|
80
80
|
|
|
81
81
|
Most Claude subscription proxies have a critical billing problem: **Anthropic classifies their requests as third-party and routes all usage to Extra Usage billing** — even when you have Max plan limits available. You're paying for your subscription twice.
|
|
82
82
|
|
|
83
|
-
dario is the only proxy that solves this. It injects native Claude Code device identity, billing
|
|
83
|
+
dario is the only proxy that solves this. It injects native Claude Code device identity, per-request billing checksums (reverse-engineered from the Claude Code binary), and priority routing into every request — so Anthropic's billing system treats your requests exactly like Claude Code itself. Your Max plan limits work correctly, and Opus/Sonnet stay available even at high utilization.
|
|
84
84
|
|
|
85
85
|
| | dario | Other proxies |
|
|
86
86
|
|---|---|---|
|
|
@@ -88,6 +88,7 @@ dario is the only proxy that solves this. It injects native Claude Code device i
|
|
|
88
88
|
| **Max plan limits** | Used correctly | Bypassed — billed separately |
|
|
89
89
|
| **Device identity** | Injected automatically | Missing |
|
|
90
90
|
| **Priority routing** | Billing tag + service_tier auto | Missing |
|
|
91
|
+
| **Billing tag fingerprint** | Per-request SHA-256 matching binary RE | Static or missing |
|
|
91
92
|
| **Beta flags** | Match Claude Code v2.1.100 | Outdated or missing |
|
|
92
93
|
| **Billable beta filtering** | Strips surprise charges | Passes everything through |
|
|
93
94
|
|
|
@@ -415,7 +416,7 @@ Then run `hermes` normally — it routes through dario using your Claude subscri
|
|
|
415
416
|
|
|
416
417
|
### Direct API Mode
|
|
417
418
|
- All Claude models (Opus 4.6, Sonnet 4.6, Haiku 4.5) + 1M extended context aliases (`opus1m`, `sonnet1m`)
|
|
418
|
-
- **Native billing classification** — device identity
|
|
419
|
+
- **Native billing classification** — device identity, per-request billing tag with SHA-256 checksums matching real Claude Code (extracted via binary RE), ensures Max plan limits work correctly
|
|
419
420
|
- **Priority routing** — billing tag injection + `service_tier: 'auto'` activates per-model rate limits, keeping Opus/Sonnet available even at 100% overall utilization
|
|
420
421
|
- **Adaptive thinking** — matches Claude Code's `{ type: 'adaptive' }` mode for optimal reasoning (auto-skipped for Haiku 4.5)
|
|
421
422
|
- **Effort control** — injects `output_config: { effort: 'high' }` by default, or passes through client-specified effort level
|
|
@@ -585,7 +586,7 @@ npm run dev # runs with tsx (no build needed)
|
|
|
585
586
|
| Who | Contributions |
|
|
586
587
|
|-----|---------------|
|
|
587
588
|
| [@GodsBoy](https://github.com/GodsBoy) | Proxy authentication, token redaction, error sanitization ([#2](https://github.com/askalf/dario/pull/2)) |
|
|
588
|
-
| [@belangertrading](https://github.com/belangertrading) | Billing classification investigation ([#4](https://github.com/askalf/dario/issues/4)), Opus/Sonnet 429 diagnosis + CLI fallback workaround ([#6](https://github.com/askalf/dario/issues/6)) |
|
|
589
|
+
| [@belangertrading](https://github.com/belangertrading) | Billing classification investigation ([#4](https://github.com/askalf/dario/issues/4)), Opus/Sonnet 429 diagnosis + CLI fallback workaround ([#6](https://github.com/askalf/dario/issues/6)), billing reclassification root cause ([#7](https://github.com/askalf/dario/issues/7)) |
|
|
589
590
|
|
|
590
591
|
## Also by AskAlf
|
|
591
592
|
|
package/dist/proxy.js
CHANGED
|
@@ -4,7 +4,7 @@ import { execSync, spawn } from 'node:child_process';
|
|
|
4
4
|
import { readFileSync, readdirSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { homedir, tmpdir } from 'node:os';
|
|
7
|
-
import { arch, platform
|
|
7
|
+
import { arch, platform } from 'node:process';
|
|
8
8
|
import { getAccessToken, getStatus } from './oauth.js';
|
|
9
9
|
const ANTHROPIC_API = 'https://api.anthropic.com';
|
|
10
10
|
const DEFAULT_PORT = 3456;
|
|
@@ -512,7 +512,8 @@ export async function startProxy(opts = {}) {
|
|
|
512
512
|
'x-stainless-package-version': '0.81.0',
|
|
513
513
|
'x-stainless-retry-count': '0',
|
|
514
514
|
'x-stainless-runtime': 'node',
|
|
515
|
-
|
|
515
|
+
// Claude Code runs on Bun which reports v24.3.0 as Node compat version
|
|
516
|
+
'x-stainless-runtime-version': 'v24.3.0',
|
|
516
517
|
};
|
|
517
518
|
const useCli = opts.cliBackend ?? false;
|
|
518
519
|
let requestCount = 0;
|
|
@@ -686,18 +687,15 @@ export async function startProxy(opts = {}) {
|
|
|
686
687
|
const supportsThinking = !modelName.includes('haiku');
|
|
687
688
|
if (supportsThinking && !r.thinking) {
|
|
688
689
|
r.thinking = { type: 'adaptive' };
|
|
689
|
-
// Ensure max_tokens is reasonable for thinking models
|
|
690
|
-
const clientMax = r.max_tokens || 8192;
|
|
691
|
-
r.max_tokens = Math.max(clientMax, 16000);
|
|
692
690
|
}
|
|
693
|
-
//
|
|
694
|
-
if (!r.
|
|
695
|
-
r.
|
|
691
|
+
// Match Claude Code's default max_tokens (64000) when client sends low values
|
|
692
|
+
if (!r.max_tokens || r.max_tokens < 16000) {
|
|
693
|
+
r.max_tokens = 64000;
|
|
696
694
|
}
|
|
697
|
-
// Set reasoning effort (pass through client value or default)
|
|
695
|
+
// Set reasoning effort (pass through client value or default to 'medium' matching Claude Code)
|
|
698
696
|
// Haiku does not support the effort parameter
|
|
699
697
|
if (supportsThinking && !r.output_config) {
|
|
700
|
-
r.output_config = { effort: '
|
|
698
|
+
r.output_config = { effort: 'medium' };
|
|
701
699
|
}
|
|
702
700
|
// Enable context management (matches Claude Code default)
|
|
703
701
|
// Requires thinking to be enabled — skip for models without thinking support (e.g. Haiku)
|
|
@@ -714,24 +712,39 @@ export async function startProxy(opts = {}) {
|
|
|
714
712
|
// as the real Claude Code binary (Oz$ function):
|
|
715
713
|
// - build tag = SHA-256(seed + msg_chars[4,7,20] + version).slice(0,3)
|
|
716
714
|
// - cch = SHA-256(seed + version + msg_chars[4,7,20]).slice(0,5)
|
|
715
|
+
// Build per-request billing tag matching Claude Code binary
|
|
717
716
|
const userMsg = extractFirstUserMessage(r);
|
|
718
717
|
const buildTag = computeBuildTag(userMsg, cliVersion);
|
|
719
718
|
const cch = computeCch(userMsg, cliVersion);
|
|
720
719
|
const fullVersion = `${cliVersion}.${buildTag}`;
|
|
721
720
|
const billingTag = `x-anthropic-billing-header: cc_version=${fullVersion}; cc_entrypoint=cli; cch=${cch};`;
|
|
721
|
+
// Structure system prompt as 3 blocks matching real Claude Code:
|
|
722
|
+
// [0] billing tag (no cache_control)
|
|
723
|
+
// [1] agent identity string (cache 1h)
|
|
724
|
+
// [2] actual system prompt (cache 1h)
|
|
725
|
+
const AGENT_IDENTITY = 'You are a Claude agent, built on Anthropic\'s Claude Agent SDK.';
|
|
726
|
+
const CACHE_1H = { type: 'ephemeral', ttl: '1h' };
|
|
722
727
|
if (typeof r.system === 'string') {
|
|
723
728
|
if (!r.system.includes('x-anthropic-billing-header:')) {
|
|
724
|
-
r.system =
|
|
729
|
+
r.system = [
|
|
730
|
+
{ type: 'text', text: billingTag },
|
|
731
|
+
{ type: 'text', text: AGENT_IDENTITY, cache_control: CACHE_1H },
|
|
732
|
+
{ type: 'text', text: r.system, cache_control: CACHE_1H },
|
|
733
|
+
];
|
|
725
734
|
}
|
|
726
735
|
}
|
|
727
736
|
else if (Array.isArray(r.system)) {
|
|
728
737
|
const hasTag = r.system.some(b => typeof b.text === 'string' && b.text.includes('x-anthropic-billing-header:'));
|
|
729
738
|
if (!hasTag) {
|
|
730
|
-
|
|
739
|
+
// Prepend billing tag and agent identity before existing blocks
|
|
740
|
+
r.system.unshift({ type: 'text', text: billingTag }, { type: 'text', text: AGENT_IDENTITY, cache_control: CACHE_1H });
|
|
731
741
|
}
|
|
732
742
|
}
|
|
733
743
|
else {
|
|
734
|
-
r.system =
|
|
744
|
+
r.system = [
|
|
745
|
+
{ type: 'text', text: billingTag },
|
|
746
|
+
{ type: 'text', text: AGENT_IDENTITY, cache_control: CACHE_1H },
|
|
747
|
+
];
|
|
735
748
|
}
|
|
736
749
|
}
|
|
737
750
|
finalBody = Buffer.from(JSON.stringify(r));
|
|
@@ -752,8 +765,8 @@ export async function startProxy(opts = {}) {
|
|
|
752
765
|
beta += ',' + clientBeta;
|
|
753
766
|
}
|
|
754
767
|
else {
|
|
755
|
-
// Claude-optimized: full beta set matching
|
|
756
|
-
beta = 'oauth-2025-04-20,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,
|
|
768
|
+
// Claude-optimized: full beta set matching real Claude Code (exact order from MITM capture)
|
|
769
|
+
beta = 'claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,advisor-tool-2026-03-01,effort-2025-11-24';
|
|
757
770
|
if (clientBeta) {
|
|
758
771
|
const filtered = filterBillableBetas(clientBeta);
|
|
759
772
|
if (filtered)
|