@askalf/dario 4.8.128 → 4.8.130
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/cc-template.d.ts +6 -5
- package/dist/cc-template.js +17 -6
- package/dist/cch.d.ts +7 -0
- package/dist/cch.js +20 -3
- package/dist/proxy.d.ts +42 -24
- package/dist/proxy.js +136 -63
- package/package.json +3 -1
package/dist/cc-template.d.ts
CHANGED
|
@@ -362,11 +362,12 @@ export declare function parseEffortSuffix(model: string): {
|
|
|
362
362
|
* defaulted to `high`; dario special-cased it. A fresh live replay on 2026-07-01
|
|
363
363
|
* through the deployed proxy (CC 2.1.198's verbatim fable body, only
|
|
364
364
|
* output_config.effort mutated) shows the redeployed fable now ANSWERS all three
|
|
365
|
-
* — high/xhigh/max → end_turn, zero refusals
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
365
|
+
* — high/xhigh/max → end_turn, zero refusals. So the clamp + the fable-only
|
|
366
|
+
* default are gone: fable now takes the general path (no clamp), matching how
|
|
367
|
+
* dario treats opus. The general default is `high` (see resolveEffort below) —
|
|
368
|
+
* a clean-room 2.1.199 capture shows CC sends `high` on every family; earlier
|
|
369
|
+
* `xhigh` sightings were from configured captures. `model` is retained in the
|
|
370
|
+
* signature in case a future model needs per-family effort handling again.
|
|
370
371
|
*
|
|
371
372
|
* Exported for tests.
|
|
372
373
|
*/
|
package/dist/cc-template.js
CHANGED
|
@@ -1111,17 +1111,28 @@ function normalizeEffortForWire(effort) {
|
|
|
1111
1111
|
* defaulted to `high`; dario special-cased it. A fresh live replay on 2026-07-01
|
|
1112
1112
|
* through the deployed proxy (CC 2.1.198's verbatim fable body, only
|
|
1113
1113
|
* output_config.effort mutated) shows the redeployed fable now ANSWERS all three
|
|
1114
|
-
* — high/xhigh/max → end_turn, zero refusals
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1114
|
+
* — high/xhigh/max → end_turn, zero refusals. So the clamp + the fable-only
|
|
1115
|
+
* default are gone: fable now takes the general path (no clamp), matching how
|
|
1116
|
+
* dario treats opus. The general default is `high` (see resolveEffort below) —
|
|
1117
|
+
* a clean-room 2.1.199 capture shows CC sends `high` on every family; earlier
|
|
1118
|
+
* `xhigh` sightings were from configured captures. `model` is retained in the
|
|
1119
|
+
* signature in case a future model needs per-family effort handling again.
|
|
1119
1120
|
*
|
|
1120
1121
|
* Exported for tests.
|
|
1121
1122
|
*/
|
|
1122
1123
|
export function resolveEffort(flag, clientBody, model) {
|
|
1123
1124
|
void model; // no per-family effort handling at present (see FABLE CLAMP note above)
|
|
1124
|
-
|
|
1125
|
+
// Match real CC's wire value. A clean-room capture (fresh HOME, no config) of
|
|
1126
|
+
// CC 2.1.199 sends `effort: high` on every adaptive-thinking model (opus-4-8,
|
|
1127
|
+
// sonnet-5, fable-5, opus-4-6, sonnet-4-6 — verified 2026-07-03). The prior
|
|
1128
|
+
// default `'max'` was the reasoning ceiling and diverged from CC on two
|
|
1129
|
+
// counts: it's not what CC sends, and `max` effort + unbounded adaptive
|
|
1130
|
+
// thinking makes the model reason until it exhausts `max_tokens` — on prompts
|
|
1131
|
+
// over ~5K input tokens the thinking phase consumes the entire budget, so the
|
|
1132
|
+
// stream ends `stop_reason: max_tokens` with ZERO text blocks (dario#658). CC
|
|
1133
|
+
// at `high` thinks proportionally and leaves room for text. Operators who
|
|
1134
|
+
// want a higher tier still pin it via `--effort` / DARIO_EFFORT.
|
|
1135
|
+
const familyDefault = 'high';
|
|
1125
1136
|
if (flag === undefined)
|
|
1126
1137
|
return familyDefault;
|
|
1127
1138
|
if (flag === 'client') {
|
package/dist/cch.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/** Verified per-release seeds, keyed on `major.minor.patch`. */
|
|
2
2
|
export declare const CCH_SEEDS: Record<string, bigint>;
|
|
3
|
+
/**
|
|
4
|
+
* Whether a calibrated cch seed exists for `version`. The proxy gates cch
|
|
5
|
+
* EMISSION on this: with a seed it stamps the deterministic value, without
|
|
6
|
+
* one it omits the token (matching CC 2.1.199+, which sends no cch). Keyed on
|
|
7
|
+
* `major.minor.patch` — same key space as CCH_SEEDS.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasCchSeed(version: string): boolean;
|
|
3
10
|
/** Canonical xxHash64 of `data` with a 64-bit `seed`. */
|
|
4
11
|
export declare function xxh64(data: Uint8Array, seed: bigint): bigint;
|
|
5
12
|
/**
|
package/dist/cch.js
CHANGED
|
@@ -21,13 +21,30 @@
|
|
|
21
21
|
// The seed rotates per Claude Code release and is keyed on major.minor.patch
|
|
22
22
|
// (the build-tag suffix, e.g. ".e2d" vs ".dd9", does NOT change it — verified
|
|
23
23
|
// against two captures with different suffixes, same 2.1.177 seed). An unknown
|
|
24
|
-
// version returns null
|
|
25
|
-
//
|
|
26
|
-
//
|
|
24
|
+
// version returns null; the caller then OMITS the cch token entirely rather
|
|
25
|
+
// than stamping a random one (see hasCchSeed below).
|
|
26
|
+
//
|
|
27
|
+
// ⚠ Claude Code DROPPED the cch token between 2.1.177 and 2.1.199 (live
|
|
28
|
+
// capture 2026-07-03, sdk-cli entrypoint — the entrypoint dario claims): the
|
|
29
|
+
// billing block is now `cc_version=…; cc_entrypoint=sdk-cli;` with no `cch=`.
|
|
30
|
+
// So "no seed" and "CC emits no cch" currently coincide, and gating cch
|
|
31
|
+
// emission on seed availability keeps dario byte-aligned with real CC: we emit
|
|
32
|
+
// cch only when we can emit the CORRECT deterministic value, and otherwise
|
|
33
|
+
// send nothing — which is exactly what current CC sends. A random cch never
|
|
34
|
+
// validates AND is a field genuine CC no longer carries: a 100%-vs-0% tell.
|
|
27
35
|
/** Verified per-release seeds, keyed on `major.minor.patch`. */
|
|
28
36
|
export const CCH_SEEDS = {
|
|
29
37
|
'2.1.177': 0x4d659218e32a3268n,
|
|
30
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Whether a calibrated cch seed exists for `version`. The proxy gates cch
|
|
41
|
+
* EMISSION on this: with a seed it stamps the deterministic value, without
|
|
42
|
+
* one it omits the token (matching CC 2.1.199+, which sends no cch). Keyed on
|
|
43
|
+
* `major.minor.patch` — same key space as CCH_SEEDS.
|
|
44
|
+
*/
|
|
45
|
+
export function hasCchSeed(version) {
|
|
46
|
+
return CCH_SEEDS[version] !== undefined;
|
|
47
|
+
}
|
|
31
48
|
const MASK = 0xfffffn;
|
|
32
49
|
const U64 = (1n << 64n) - 1n;
|
|
33
50
|
// xxHash64 primes.
|
package/dist/proxy.d.ts
CHANGED
|
@@ -2,6 +2,21 @@ import { type IncomingMessage } from 'node:http';
|
|
|
2
2
|
import { type WriteStream } from 'node:fs';
|
|
3
3
|
import { getAccessToken, getStatus } from './oauth.js';
|
|
4
4
|
import { type EffortValue } from './cc-template.js';
|
|
5
|
+
/**
|
|
6
|
+
* Assemble the `x-anthropic-billing-header` system-block text, tracking real
|
|
7
|
+
* Claude Code's wire shape:
|
|
8
|
+
* with cch: `…; cc_entrypoint=sdk-cli; cch=<5hex>;` (CC ≤ 2.1.177)
|
|
9
|
+
* without cch: `…; cc_entrypoint=sdk-cli;` (CC 2.1.199+)
|
|
10
|
+
*
|
|
11
|
+
* `cch` is passed in rather than generated here so this stays a pure, testable
|
|
12
|
+
* string builder: the caller gates on hasCchSeed(cliVersion) and passes
|
|
13
|
+
* computeCch() (a placeholder stampCch later overwrites with the deterministic
|
|
14
|
+
* value) when a seed exists, or null when it doesn't. Passing null omits the
|
|
15
|
+
* token — never emit a cch we can't stand behind, and never emit one current
|
|
16
|
+
* CC doesn't send. The cc_version build suffix is stable per config
|
|
17
|
+
* (computeVersionSuffix), independent of the request. Exported for tests.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildBillingTag(cliVersion: string, cch: string | null): string;
|
|
5
20
|
/**
|
|
6
21
|
* Resolve a Claude-side model name through the family-alias rules if it's a
|
|
7
22
|
* short alias (`opus`/`sonnet`/`haiku`/etc.), otherwise pass through
|
|
@@ -40,36 +55,39 @@ export declare const FABLE_FALLBACK_CREDIT_BETA = "fallback-credit-2026-06-01";
|
|
|
40
55
|
export declare const CONTEXT_1M_BETA = "context-1m-2025-08-07";
|
|
41
56
|
export declare const MID_CONVERSATION_SYSTEM_BETA = "mid-conversation-system-2026-04-07";
|
|
42
57
|
export declare const EFFORT_BETA = "effort-2025-11-24";
|
|
58
|
+
export declare const AFK_MODE_BETA = "afk-mode-2026-01-31";
|
|
59
|
+
export declare const ADVISOR_TOOL_BETA = "advisor-tool-2026-03-01";
|
|
60
|
+
export declare const CLAUDE_CODE_BETA = "claude-code-20250219";
|
|
43
61
|
/**
|
|
44
|
-
* Model-conditional beta
|
|
45
|
-
* 2026-
|
|
46
|
-
*
|
|
62
|
+
* Model-conditional anthropic-beta set, mirroring real CC 2.1.199 (live
|
|
63
|
+
* captures 2026-07-03, this box, `--print --model <m> -p hi` — same
|
|
64
|
+
* binary/account, deterministic across repeat trials). `base` is the captured
|
|
65
|
+
* opus/sonnet order (TEMPLATE.anthropic_beta); each family is a transform of
|
|
66
|
+
* it, ORDER included:
|
|
47
67
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
68
|
+
* opus-4-8 = base (unchanged)
|
|
69
|
+
* sonnet-5 = base (unchanged — KEEPS
|
|
70
|
+
* mid-conversation-system; the old 2.1.170 sonnet-4-6 drop is
|
|
71
|
+
* gone: 2.1.199 sonnet == opus)
|
|
72
|
+
* haiku-4-5 = base − {mid-conversation-system, effort, afk-mode}, and
|
|
73
|
+
* claude-code-20250219 MOVED to position 5 (before advisor-tool)
|
|
74
|
+
* fable-5 = base + fallback-credit-2026-06-01 inserted BEFORE afk-mode
|
|
53
75
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* NOT send it for plain models). `skipContext1m` (dario#36) suppresses the
|
|
59
|
-
* [1m] append when the account's long-context billing was rejected.
|
|
76
|
+
* `[1m]`-labelled models additionally carry context-1m-2025-08-07 at POSITION 2
|
|
77
|
+
* (immediately after claude-code-20250219), not appended at the tail. CC does
|
|
78
|
+
* NOT send it for plain models. `skipContext1m` (dario#36) suppresses it when
|
|
79
|
+
* the account's long-context billing was rejected.
|
|
60
80
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* the beta just restores consistency).
|
|
81
|
+
* afk-mode-2026-01-31 is REMOTE-CONFIG controlled and flips within a CC version
|
|
82
|
+
* (memory: rolled off 7/2, back on 7/3), so its presence is a property of the
|
|
83
|
+
* captured `base`, not of this function — the live capture heals it. haiku
|
|
84
|
+
* drops it regardless. The per-family shape here is correct whether or not the
|
|
85
|
+
* base carries afk-mode: the anchor-relative inserts/moves degrade gracefully
|
|
86
|
+
* (append / no-op) when an anchor is absent.
|
|
68
87
|
*
|
|
69
88
|
* Removing a beta can never provoke an upstream 400 (the runtime rejection
|
|
70
|
-
* cache only ever needs to ADD strips), so the omissions are
|
|
71
|
-
*
|
|
72
|
-
* unknown models keep the full baked set unchanged.
|
|
89
|
+
* cache only ever needs to ADD strips), so the haiku omissions are safe; the
|
|
90
|
+
* position fixes are pure wire-shape fidelity.
|
|
73
91
|
*/
|
|
74
92
|
export declare function betaForModel(base: string, model: string | null | undefined, skipContext1m?: boolean): string;
|
|
75
93
|
/**
|
package/dist/proxy.js
CHANGED
|
@@ -10,7 +10,7 @@ import { getAccessToken, getStatus } from './oauth.js';
|
|
|
10
10
|
import { buildHealthResponse, derivePoolStatus, shouldDiscloseHealthInternals } from './health-response.js';
|
|
11
11
|
import { darioVersion } from './version.js';
|
|
12
12
|
import { buildCCRequest, applyCcPromptCaching, parseEffortSuffix, reverseMapResponse, createStreamingReverseMapper, orderHeadersForOutbound, CC_TEMPLATE } from './cc-template.js';
|
|
13
|
-
import { stampCch } from './cch.js';
|
|
13
|
+
import { stampCch, hasCchSeed } from './cch.js';
|
|
14
14
|
import { describeTemplate, detectDrift, checkCCCompat } from './live-fingerprint.js';
|
|
15
15
|
import { AccountPool, computeStickyKey, parseRateLimits, modelFamily, isInAuthCooldown, authCooldownMs, reconcilePoolAccounts } from './pool.js';
|
|
16
16
|
import { Analytics, billingBucketFromClaim } from './analytics.js';
|
|
@@ -52,27 +52,69 @@ function isLoopbackAddr(addr) {
|
|
|
52
52
|
}
|
|
53
53
|
// Concurrency control: see src/request-queue.ts for the bounded queue
|
|
54
54
|
// (replaced the v3.30.x-and-earlier simple unbounded semaphore in dario#80).
|
|
55
|
-
//
|
|
55
|
+
// Deterministic seed for the cc_version build suffix. Once reverse-engineered
|
|
56
|
+
// as Claude Code's own value; it is now just dario's stable constant — CC's
|
|
57
|
+
// real suffix algorithm has moved (see computeVersionSuffix).
|
|
56
58
|
const BILLING_SEED = '59cf53e54c78';
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
// The `.<suffix>` on cc_version (e.g. `2.1.199.ef3`). A clean-room capture
|
|
60
|
+
// (2026-07-03, fresh HOME with no CLAUDE.md / memory / project context) proved
|
|
61
|
+
// this is NOT a function of the user message: every prompt — any content, any
|
|
62
|
+
// length, bytes flipped at positions 0/4/7/20/29 — returned the SAME suffix,
|
|
63
|
+
// and it shifted only when the injected SYSTEM CONTEXT changed. So CC derives
|
|
64
|
+
// it from the system payload and it is STABLE for a given config. dario's old
|
|
65
|
+
// `chars[4,7,20]`-of-user-message hash was doubly wrong: wrong input, and
|
|
66
|
+
// per-request-varying where real CC is stable across requests.
|
|
67
|
+
//
|
|
68
|
+
// We can't reproduce CC's exact algorithm (it lives in the compiled binary,
|
|
69
|
+
// same as the cch seed) and the value isn't population-discriminating — every
|
|
70
|
+
// CC machine's suffix differs by its own context — so a STABLE, plausible 3-hex
|
|
71
|
+
// derived from the template we replay is the faithful choice: it matches CC's
|
|
72
|
+
// observable property (one stable suffix per config, like a single real
|
|
73
|
+
// install) and changes only when the system payload changes (a template
|
|
74
|
+
// rebake). Memoized — the inputs don't change within a process.
|
|
75
|
+
let _versionSuffixCache = null;
|
|
76
|
+
function computeVersionSuffix(version) {
|
|
77
|
+
if (_versionSuffixCache && _versionSuffixCache.key === version)
|
|
78
|
+
return _versionSuffixCache.value;
|
|
79
|
+
const sys = CC_TEMPLATE.system_prompt ?? '';
|
|
80
|
+
const value = createHash('sha256').update(`${BILLING_SEED}${version}${sys}`).digest('hex').slice(0, 3);
|
|
81
|
+
_versionSuffixCache = { key: version, value };
|
|
82
|
+
return value;
|
|
62
83
|
}
|
|
63
84
|
// Per-request cch PLACEHOLDER. Claude Code's cch is a deterministic xxHash64
|
|
64
85
|
// over a projection of the request body (see src/cch.ts, dario#528). We can
|
|
65
86
|
// only compute the real value once the final body is assembled, so we seed the
|
|
66
87
|
// billing tag with a random 5-hex token here and overwrite it in place with the
|
|
67
|
-
// deterministic value at serialize time (the `
|
|
68
|
-
// JSON.stringify of the outbound body).
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
88
|
+
// deterministic value at serialize time (the `stampCch` call near the
|
|
89
|
+
// JSON.stringify of the outbound body).
|
|
90
|
+
//
|
|
91
|
+
// This placeholder is only emitted for CC versions we hold a calibrated seed
|
|
92
|
+
// for — see buildBillingTag / hasCchSeed. Versions without a seed omit the cch
|
|
93
|
+
// token entirely: current CC (2.1.199+) sends no cch at all, so a random
|
|
94
|
+
// value would be a fingerprint, not cover. Operators can force the random
|
|
95
|
+
// path on every seeded request with DARIO_CCH=random.
|
|
73
96
|
function computeCch() {
|
|
74
97
|
return randomBytes(3).toString('hex').slice(0, 5);
|
|
75
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Assemble the `x-anthropic-billing-header` system-block text, tracking real
|
|
101
|
+
* Claude Code's wire shape:
|
|
102
|
+
* with cch: `…; cc_entrypoint=sdk-cli; cch=<5hex>;` (CC ≤ 2.1.177)
|
|
103
|
+
* without cch: `…; cc_entrypoint=sdk-cli;` (CC 2.1.199+)
|
|
104
|
+
*
|
|
105
|
+
* `cch` is passed in rather than generated here so this stays a pure, testable
|
|
106
|
+
* string builder: the caller gates on hasCchSeed(cliVersion) and passes
|
|
107
|
+
* computeCch() (a placeholder stampCch later overwrites with the deterministic
|
|
108
|
+
* value) when a seed exists, or null when it doesn't. Passing null omits the
|
|
109
|
+
* token — never emit a cch we can't stand behind, and never emit one current
|
|
110
|
+
* CC doesn't send. The cc_version build suffix is stable per config
|
|
111
|
+
* (computeVersionSuffix), independent of the request. Exported for tests.
|
|
112
|
+
*/
|
|
113
|
+
export function buildBillingTag(cliVersion, cch) {
|
|
114
|
+
const fullVersion = `${cliVersion}.${computeVersionSuffix(cliVersion)}`;
|
|
115
|
+
const base = `x-anthropic-billing-header: cc_version=${fullVersion}; cc_entrypoint=sdk-cli;`;
|
|
116
|
+
return cch === null ? base : `${base} cch=${cch};`;
|
|
117
|
+
}
|
|
76
118
|
// Detect installed Claude Code version for the build-tag computation.
|
|
77
119
|
// Falls back to the bundled template's captured version when claude isn't
|
|
78
120
|
// on PATH (the common container case) — previously this fell back to a
|
|
@@ -250,61 +292,87 @@ export const FABLE_FALLBACK_CREDIT_BETA = 'fallback-credit-2026-06-01';
|
|
|
250
292
|
export const CONTEXT_1M_BETA = 'context-1m-2025-08-07';
|
|
251
293
|
export const MID_CONVERSATION_SYSTEM_BETA = 'mid-conversation-system-2026-04-07';
|
|
252
294
|
export const EFFORT_BETA = 'effort-2025-11-24';
|
|
295
|
+
export const AFK_MODE_BETA = 'afk-mode-2026-01-31';
|
|
296
|
+
export const ADVISOR_TOOL_BETA = 'advisor-tool-2026-03-01';
|
|
297
|
+
export const CLAUDE_CODE_BETA = 'claude-code-20250219';
|
|
253
298
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
299
|
+
* Insert `flag` immediately before the first `anchor`, deduped. If `flag` is
|
|
300
|
+
* already present the list is returned unchanged; if `anchor` is absent `flag`
|
|
301
|
+
* is appended at the tail. Used to place model-conditional betas at the exact
|
|
302
|
+
* position real CC emits them, rather than always appending.
|
|
303
|
+
*/
|
|
304
|
+
function insertBetaBefore(flags, flag, anchor) {
|
|
305
|
+
if (flags.includes(flag))
|
|
306
|
+
return flags;
|
|
307
|
+
const i = flags.indexOf(anchor);
|
|
308
|
+
return i < 0 ? [...flags, flag] : [...flags.slice(0, i), flag, ...flags.slice(i)];
|
|
309
|
+
}
|
|
310
|
+
/** As insertBetaBefore, but places `flag` immediately AFTER the first `anchor`. */
|
|
311
|
+
function insertBetaAfter(flags, flag, anchor) {
|
|
312
|
+
if (flags.includes(flag))
|
|
313
|
+
return flags;
|
|
314
|
+
const i = flags.indexOf(anchor);
|
|
315
|
+
return i < 0 ? [...flags, flag] : [...flags.slice(0, i + 1), flag, ...flags.slice(i + 1)];
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Move an already-present `flag` to immediately before the first `anchor`.
|
|
319
|
+
* No-op when either is absent. Used for haiku, where CC emits
|
|
320
|
+
* claude-code-20250219 mid-list rather than first.
|
|
321
|
+
*/
|
|
322
|
+
function moveBetaBefore(flags, flag, anchor) {
|
|
323
|
+
if (!flags.includes(flag))
|
|
324
|
+
return flags;
|
|
325
|
+
const without = flags.filter((f) => f !== flag);
|
|
326
|
+
const i = without.indexOf(anchor);
|
|
327
|
+
return i < 0 ? flags : [...without.slice(0, i), flag, ...without.slice(i)];
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Model-conditional anthropic-beta set, mirroring real CC 2.1.199 (live
|
|
331
|
+
* captures 2026-07-03, this box, `--print --model <m> -p hi` — same
|
|
332
|
+
* binary/account, deterministic across repeat trials). `base` is the captured
|
|
333
|
+
* opus/sonnet order (TEMPLATE.anthropic_beta); each family is a transform of
|
|
334
|
+
* it, ORDER included:
|
|
257
335
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
336
|
+
* opus-4-8 = base (unchanged)
|
|
337
|
+
* sonnet-5 = base (unchanged — KEEPS
|
|
338
|
+
* mid-conversation-system; the old 2.1.170 sonnet-4-6 drop is
|
|
339
|
+
* gone: 2.1.199 sonnet == opus)
|
|
340
|
+
* haiku-4-5 = base − {mid-conversation-system, effort, afk-mode}, and
|
|
341
|
+
* claude-code-20250219 MOVED to position 5 (before advisor-tool)
|
|
342
|
+
* fable-5 = base + fallback-credit-2026-06-01 inserted BEFORE afk-mode
|
|
263
343
|
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* NOT send it for plain models). `skipContext1m` (dario#36) suppresses the
|
|
269
|
-
* [1m] append when the account's long-context billing was rejected.
|
|
344
|
+
* `[1m]`-labelled models additionally carry context-1m-2025-08-07 at POSITION 2
|
|
345
|
+
* (immediately after claude-code-20250219), not appended at the tail. CC does
|
|
346
|
+
* NOT send it for plain models. `skipContext1m` (dario#36) suppresses it when
|
|
347
|
+
* the account's long-context billing was rejected.
|
|
270
348
|
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* the beta just restores consistency).
|
|
349
|
+
* afk-mode-2026-01-31 is REMOTE-CONFIG controlled and flips within a CC version
|
|
350
|
+
* (memory: rolled off 7/2, back on 7/3), so its presence is a property of the
|
|
351
|
+
* captured `base`, not of this function — the live capture heals it. haiku
|
|
352
|
+
* drops it regardless. The per-family shape here is correct whether or not the
|
|
353
|
+
* base carries afk-mode: the anchor-relative inserts/moves degrade gracefully
|
|
354
|
+
* (append / no-op) when an anchor is absent.
|
|
278
355
|
*
|
|
279
356
|
* Removing a beta can never provoke an upstream 400 (the runtime rejection
|
|
280
|
-
* cache only ever needs to ADD strips), so the omissions are
|
|
281
|
-
*
|
|
282
|
-
* unknown models keep the full baked set unchanged.
|
|
357
|
+
* cache only ever needs to ADD strips), so the haiku omissions are safe; the
|
|
358
|
+
* position fixes are pure wire-shape fidelity.
|
|
283
359
|
*/
|
|
284
360
|
export function betaForModel(base, model, skipContext1m = false) {
|
|
285
|
-
let beta = base;
|
|
286
361
|
const m = (model ?? '').toLowerCase();
|
|
287
|
-
|
|
288
|
-
if (beta.split(',').includes(flag))
|
|
289
|
-
return;
|
|
290
|
-
beta = beta ? `${beta},${flag}` : flag;
|
|
291
|
-
};
|
|
292
|
-
if (m.includes('fable'))
|
|
293
|
-
append(FABLE_FALLBACK_CREDIT_BETA);
|
|
294
|
-
if (/\[1m\]$/.test(m) && !skipContext1m)
|
|
295
|
-
append(CONTEXT_1M_BETA);
|
|
296
|
-
const drop = new Set();
|
|
362
|
+
let flags = base.split(',').map((s) => s.trim()).filter(Boolean);
|
|
297
363
|
if (m.includes('haiku')) {
|
|
298
|
-
drop
|
|
299
|
-
drop.
|
|
364
|
+
const drop = new Set([MID_CONVERSATION_SYSTEM_BETA, EFFORT_BETA, AFK_MODE_BETA]);
|
|
365
|
+
flags = flags.filter((f) => !drop.has(f));
|
|
366
|
+
flags = moveBetaBefore(flags, CLAUDE_CODE_BETA, ADVISOR_TOOL_BETA);
|
|
300
367
|
}
|
|
301
|
-
else if (m.includes('
|
|
302
|
-
|
|
368
|
+
else if (m.includes('fable')) {
|
|
369
|
+
flags = insertBetaBefore(flags, FABLE_FALLBACK_CREDIT_BETA, AFK_MODE_BETA);
|
|
303
370
|
}
|
|
304
|
-
|
|
305
|
-
|
|
371
|
+
// opus + sonnet + unknown families keep the base set unchanged.
|
|
372
|
+
if (/\[1m\]$/.test(m) && !skipContext1m) {
|
|
373
|
+
flags = insertBetaAfter(flags, CONTEXT_1M_BETA, CLAUDE_CODE_BETA);
|
|
306
374
|
}
|
|
307
|
-
return
|
|
375
|
+
return flags.join(',');
|
|
308
376
|
}
|
|
309
377
|
/**
|
|
310
378
|
* Strip a trailing `[1m]` long-context tag from a model id. The tag is a
|
|
@@ -1980,10 +2048,13 @@ export async function startProxy(opts = {}) {
|
|
|
1980
2048
|
// from CC's exact template and inject only the conversation content.
|
|
1981
2049
|
// The upstream sees a genuine CC request structure.
|
|
1982
2050
|
const userMsg = extractFirstUserMessage(r);
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2051
|
+
// Emit a cch token only for CC versions we hold a calibrated seed
|
|
2052
|
+
// for (stampCch overwrites this placeholder with the deterministic
|
|
2053
|
+
// value at serialize time). Uncalibrated versions omit cch: current
|
|
2054
|
+
// CC (2.1.199+) sends none, so a random placeholder would be a
|
|
2055
|
+
// fingerprint rather than cover. dario#528 + 2026-07-03 drift.
|
|
2056
|
+
const cch = hasCchSeed(cliVersion) ? computeCch() : null;
|
|
2057
|
+
const billingTag = buildBillingTag(cliVersion, cch);
|
|
1987
2058
|
const CACHE_EPHEMERAL = { type: 'ephemeral' };
|
|
1988
2059
|
// Session stickiness: rebind the pre-selected pool account to
|
|
1989
2060
|
// whatever the sticky-key resolver picks. If this is a new
|
|
@@ -2142,10 +2213,12 @@ export async function startProxy(opts = {}) {
|
|
|
2142
2213
|
// reverse-engineered. stampCch hashes a projection of THIS final body
|
|
2143
2214
|
// (so it must run after every mutation above) and replaces the cch
|
|
2144
2215
|
// anchored to the billing tag — never a cch quoted in conversation
|
|
2145
|
-
// content. No-op for
|
|
2146
|
-
//
|
|
2147
|
-
//
|
|
2148
|
-
//
|
|
2216
|
+
// content. No-op for uncalibrated versions — but those also carry no
|
|
2217
|
+
// cch token to begin with (buildBillingTag omits it without a seed,
|
|
2218
|
+
// matching CC 2.1.199+), so there is nothing to stamp and nothing
|
|
2219
|
+
// stale is shipped. Only the template-replay path is stamped —
|
|
2220
|
+
// passthrough / count_tokens forward the client's body (and its own
|
|
2221
|
+
// cch) verbatim. Reversible kill-switch: DARIO_CCH=random.
|
|
2149
2222
|
let outboundText = JSON.stringify(r);
|
|
2150
2223
|
if (!passthrough && !isCountTokens && process.env.DARIO_CCH !== 'random') {
|
|
2151
2224
|
outboundText = stampCch(outboundText, cliVersion);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askalf/dario",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.130",
|
|
4
4
|
"description": "Use your Claude Pro/Max subscription in any tool — Cursor, Cline, Aider, the Agent SDK, your scripts — at subscription pricing, not per-token API bills. One local Anthropic + OpenAI-compatible endpoint.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"compat": "node test/compat.mjs",
|
|
33
33
|
"lint:pkg": "node scripts/check-package-json.mjs",
|
|
34
34
|
"drift:sdk": "node scripts/check-sdk-drift.mjs",
|
|
35
|
+
"drift:wire": "node scripts/check-wire-drift.mjs",
|
|
36
|
+
"check:overage": "node scripts/check-overage-live.mjs",
|
|
35
37
|
"cch:calibrate": "node scripts/cch-calibrate.mjs",
|
|
36
38
|
"fix:pkg": "node -e \"const fs=require('fs');fs.writeFileSync('package.json',JSON.stringify(JSON.parse(fs.readFileSync('package.json','utf-8')),null,2)+'\\n')\""
|
|
37
39
|
},
|