@askalf/dario 6.0.3 → 6.0.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/claude-model.js +35 -16
- package/package.json +1 -1
package/dist/claude-model.js
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
* `--model-alias` values, pinned aliases (`opus48`) and catalog family
|
|
20
20
|
* shorthands (`opus`, `sonnet1m`) map to a canonical id. The caller
|
|
21
21
|
* supplies that resolver so classification and forwarding cannot
|
|
22
|
-
* disagree.
|
|
22
|
+
* disagree. The prefix rule applies to the alias TARGET too, since an
|
|
23
|
+
* operator alias is written the way a request model is written — see
|
|
24
|
+
* stripClaudePrefix.
|
|
23
25
|
* 2. VALIDATE the resolved id against the catalog base set. A `claude-`
|
|
24
26
|
* prefix on its own proves nothing — `claude-sonnet-6` has the prefix and
|
|
25
27
|
* does not exist — so the id (sans `[1m]`) must be a base the pool can
|
|
@@ -37,6 +39,23 @@
|
|
|
37
39
|
import { BAKED_BASE_MODELS, resolveAliasAgainst } from './model-catalog.js';
|
|
38
40
|
/** Provider prefixes that force the Claude path (mirrors proxy.ts's PROVIDER_PREFIXES). */
|
|
39
41
|
const CLAUDE_PREFIXES = new Set(['claude', 'anthropic']);
|
|
42
|
+
/**
|
|
43
|
+
* Strip a Claude-side provider prefix, or refuse the name outright.
|
|
44
|
+
*
|
|
45
|
+
* Null on any prefix that isn't `claude:`/`anthropic:` — a recognized
|
|
46
|
+
* non-Claude prefix is a definite NO, not a fall-through to the name test
|
|
47
|
+
* (`openai:claude-sonnet-5` is the operator pointing somewhere else on
|
|
48
|
+
* purpose), and an unrecognized one names a model this pool has no claim on.
|
|
49
|
+
* `model` is expected already trimmed + lowercased.
|
|
50
|
+
*/
|
|
51
|
+
function stripClaudePrefix(model) {
|
|
52
|
+
const idx = model.indexOf(':');
|
|
53
|
+
if (idx <= 0)
|
|
54
|
+
return model || null;
|
|
55
|
+
if (!CLAUDE_PREFIXES.has(model.slice(0, idx)))
|
|
56
|
+
return null;
|
|
57
|
+
return model.slice(idx + 1) || null;
|
|
58
|
+
}
|
|
40
59
|
/**
|
|
41
60
|
* The canonical id the Claude pool would serve `model` as, or null when it
|
|
42
61
|
* cannot serve it. `bases` is the catalog base set — `getCachedBases()` at a
|
|
@@ -45,22 +64,22 @@ const CLAUDE_PREFIXES = new Set(['claude', 'anthropic']);
|
|
|
45
64
|
* (operator aliases + pinned aliases) where one exists.
|
|
46
65
|
*/
|
|
47
66
|
export function resolveClaudeServable(model, bases = BAKED_BASE_MODELS, resolve) {
|
|
48
|
-
|
|
49
|
-
if (
|
|
67
|
+
const entry = stripClaudePrefix(model.trim().toLowerCase());
|
|
68
|
+
if (entry === null)
|
|
69
|
+
return null;
|
|
70
|
+
// The alias TARGET may carry a prefix of its own — operator aliases are
|
|
71
|
+
// declared the way a request model is written, and `--model-alias=backup=
|
|
72
|
+
// claude:opus` is the natural way to say it (dario#1151). The request path
|
|
73
|
+
// parses that prefix AFTER alias resolution; without the same pass here the
|
|
74
|
+
// target reached the base check as the literal `claude:opus`, matched
|
|
75
|
+
// nothing, and a perfectly valid fallback was skipped.
|
|
76
|
+
const target = stripClaudePrefix((resolve ? resolve(entry) : (resolveAliasAgainst(entry, bases) ?? entry)).trim().toLowerCase());
|
|
77
|
+
if (target === null)
|
|
50
78
|
return null;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// the name test below — `openai:claude-sonnet-5` is the operator pointing
|
|
56
|
-
// somewhere else on purpose.
|
|
57
|
-
if (!CLAUDE_PREFIXES.has(prefix))
|
|
58
|
-
return null;
|
|
59
|
-
m = m.slice(idx + 1);
|
|
60
|
-
if (!m)
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
const resolved = (resolve ? resolve(m) : (resolveAliasAgainst(m, bases) ?? m)).trim().toLowerCase();
|
|
79
|
+
// A target that arrived prefixed still holds a shorthand (`claude:opus` →
|
|
80
|
+
// `opus`), so the catalog pass runs on it. Idempotent for a target already
|
|
81
|
+
// canonical: resolveAliasAgainst only answers for family shorthands.
|
|
82
|
+
const resolved = resolveAliasAgainst(target, bases) ?? target;
|
|
64
83
|
const base = resolved.endsWith('[1m]') ? resolved.slice(0, -4) : resolved;
|
|
65
84
|
return bases.some((b) => b.toLowerCase() === base) ? resolved : null;
|
|
66
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askalf/dario",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
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": {
|