@askalf/dario 3.9.2 → 3.9.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/cc-template.js +17 -1
- package/dist/proxy.js +23 -4
- package/package.json +2 -2
package/dist/cc-template.js
CHANGED
|
@@ -35,7 +35,23 @@ export function scrubFrameworkIdentifiers(text) {
|
|
|
35
35
|
let result = text;
|
|
36
36
|
for (const pattern of FRAMEWORK_PATTERNS) {
|
|
37
37
|
pattern.lastIndex = 0;
|
|
38
|
-
result = result.replace(pattern,
|
|
38
|
+
result = result.replace(pattern, (match, ...args) => {
|
|
39
|
+
const offset = args[args.length - 2];
|
|
40
|
+
const src = args[args.length - 1];
|
|
41
|
+
const before = offset > 0 ? src[offset - 1] : '';
|
|
42
|
+
const after = offset + match.length < src.length ? src[offset + match.length] : '';
|
|
43
|
+
// Preserve matches embedded in filesystem paths or URLs. `\b` word
|
|
44
|
+
// boundaries fire between `.` / `/` and word chars, which made
|
|
45
|
+
// `/Users/foo/.openclaw/workspace/` collapse to `/Users/foo/./workspace/`
|
|
46
|
+
// (dario#35). A preceding `.`, `/`, `\`, `-`, or `_` or a following
|
|
47
|
+
// `/` or `\` is a strong signal the identifier is part of a path or
|
|
48
|
+
// slug, not prose — leave it alone.
|
|
49
|
+
if (before === '.' || before === '/' || before === '\\' || before === '-' || before === '_')
|
|
50
|
+
return match;
|
|
51
|
+
if (after === '/' || after === '\\')
|
|
52
|
+
return match;
|
|
53
|
+
return '';
|
|
54
|
+
});
|
|
39
55
|
}
|
|
40
56
|
return result;
|
|
41
57
|
}
|
package/dist/proxy.js
CHANGED
|
@@ -420,6 +420,14 @@ export async function startProxy(opts = {}) {
|
|
|
420
420
|
};
|
|
421
421
|
let requestCount = 0;
|
|
422
422
|
const semaphore = new Semaphore(MAX_CONCURRENT);
|
|
423
|
+
// Cache context-1m beta availability. Set false once per account (or process
|
|
424
|
+
// in single-account mode) after the first "long context" rejection, so we
|
|
425
|
+
// skip sending context-1m on every subsequent request instead of paying the
|
|
426
|
+
// round-trip + retry cost each time. Keyed by account alias; `__default__`
|
|
427
|
+
// is the single-account slot. Reported by @boeingchoco in dario#36 — the
|
|
428
|
+
// retry loop was firing on every POST with hybrid-tools + OC.
|
|
429
|
+
const context1mUnavailable = new Set();
|
|
430
|
+
const ACCOUNT_KEY_SINGLE = '__default__';
|
|
423
431
|
// Rate governor — minimum 500ms between requests. Fast enough for agents,
|
|
424
432
|
// slow enough to not look like a scripted flood of identical traffic.
|
|
425
433
|
let lastRequestTime = 0;
|
|
@@ -693,8 +701,14 @@ export async function startProxy(opts = {}) {
|
|
|
693
701
|
}
|
|
694
702
|
else {
|
|
695
703
|
// CC v2.1.104 beta set — 8 flags in the order Claude Code sends them.
|
|
696
|
-
// context-1m requires Extra Usage — if it 400s, we auto-retry without
|
|
697
|
-
|
|
704
|
+
// context-1m requires Extra Usage — if it 400s, we auto-retry without
|
|
705
|
+
// it, and cache the rejection so subsequent requests on this account
|
|
706
|
+
// skip context-1m entirely (dario#36).
|
|
707
|
+
const acctKey = poolAccount?.alias ?? ACCOUNT_KEY_SINGLE;
|
|
708
|
+
const skipContext1m = context1mUnavailable.has(acctKey);
|
|
709
|
+
beta = skipContext1m
|
|
710
|
+
? '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'
|
|
711
|
+
: 'claude-code-20250219,oauth-2025-04-20,context-1m-2025-08-07,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';
|
|
698
712
|
if (clientBeta) {
|
|
699
713
|
const baseSet = new Set(beta.split(','));
|
|
700
714
|
const filtered = filterBillableBetas(clientBeta)
|
|
@@ -792,8 +806,13 @@ export async function startProxy(opts = {}) {
|
|
|
792
806
|
|| peekedBody.includes('Extra usage is required')
|
|
793
807
|
|| peekedBody.includes('long_context');
|
|
794
808
|
if (isLongContextError) {
|
|
795
|
-
|
|
796
|
-
|
|
809
|
+
// Cache the rejection so future requests on this account skip
|
|
810
|
+
// context-1m up front instead of re-paying the 400/429 round-trip.
|
|
811
|
+
const acctKey = poolAccount?.alias ?? ACCOUNT_KEY_SINGLE;
|
|
812
|
+
const firstRejection = !context1mUnavailable.has(acctKey);
|
|
813
|
+
context1mUnavailable.add(acctKey);
|
|
814
|
+
if (verbose && firstRejection)
|
|
815
|
+
console.log(`[dario] #${requestCount} context-1m rejected (${upstream.status}) — retrying without it (cached for session)`);
|
|
797
816
|
const reducedBeta = beta.replace(',context-1m-2025-08-07', '').replace('context-1m-2025-08-07,', '');
|
|
798
817
|
const retryHeaders = { ...headers, 'anthropic-beta': reducedBeta };
|
|
799
818
|
const retry = await fetch(targetBase, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askalf/dario",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.4",
|
|
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": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc && cp src/cc-template-data.json dist/",
|
|
24
|
-
"test": "node test/issue-29-tool-translation.mjs && node test/hybrid-tools.mjs && node test/analytics-recording.mjs && node test/failover-429.mjs",
|
|
24
|
+
"test": "node test/issue-29-tool-translation.mjs && node test/hybrid-tools.mjs && node test/scrub-paths.mjs && node test/analytics-recording.mjs && node test/failover-429.mjs",
|
|
25
25
|
"audit": "npm audit --production --audit-level=high",
|
|
26
26
|
"prepublishOnly": "npm run build",
|
|
27
27
|
"start": "node dist/cli.js",
|