@askalf/dario 3.35.0 → 3.36.0
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.d.ts +12 -0
- package/dist/proxy.js +30 -2
- package/package.json +1 -1
package/dist/proxy.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { type IncomingMessage } from 'node:http';
|
|
2
2
|
import { type WriteStream } from 'node:fs';
|
|
3
3
|
import { type EffortValue } from './cc-template.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a Claude-side model name through MODEL_ALIASES if it's a short
|
|
6
|
+
* alias (`opus`/`sonnet`/`haiku`/etc.), otherwise pass through unchanged.
|
|
7
|
+
*
|
|
8
|
+
* Used at request time on the provider-prefix path so `claude:opus` arrives
|
|
9
|
+
* upstream as `claude-opus-4-6` rather than the bare `opus` (which Anthropic
|
|
10
|
+
* 400's). Critical for Cursor BYOK setups (dario#190) where users have to
|
|
11
|
+
* pick a colon-prefixed model name to dodge Cursor's built-in `claude-*`
|
|
12
|
+
* name collision — which means the natural shorthand is `claude:opus`, and
|
|
13
|
+
* that needs to Just Work.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveClaudeAlias(model: string): string;
|
|
4
16
|
export declare function parseProviderPrefix(model: string): {
|
|
5
17
|
provider: 'openai' | 'claude';
|
|
6
18
|
model: string;
|
package/dist/proxy.js
CHANGED
|
@@ -131,6 +131,20 @@ const MODEL_ALIASES = {
|
|
|
131
131
|
'sonnet1m': 'claude-sonnet-4-6[1m]',
|
|
132
132
|
'haiku': 'claude-haiku-4-5',
|
|
133
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Resolve a Claude-side model name through MODEL_ALIASES if it's a short
|
|
136
|
+
* alias (`opus`/`sonnet`/`haiku`/etc.), otherwise pass through unchanged.
|
|
137
|
+
*
|
|
138
|
+
* Used at request time on the provider-prefix path so `claude:opus` arrives
|
|
139
|
+
* upstream as `claude-opus-4-6` rather than the bare `opus` (which Anthropic
|
|
140
|
+
* 400's). Critical for Cursor BYOK setups (dario#190) where users have to
|
|
141
|
+
* pick a colon-prefixed model name to dodge Cursor's built-in `claude-*`
|
|
142
|
+
* name collision — which means the natural shorthand is `claude:opus`, and
|
|
143
|
+
* that needs to Just Work.
|
|
144
|
+
*/
|
|
145
|
+
export function resolveClaudeAlias(model) {
|
|
146
|
+
return MODEL_ALIASES[model] ?? model;
|
|
147
|
+
}
|
|
134
148
|
// Provider prefix in the `model` field — `<provider>:<model>`. Forces
|
|
135
149
|
// routing regardless of model-name regex. Only recognized prefixes are
|
|
136
150
|
// parsed, so ollama-style `llama3:8b` (without a recognized prefix)
|
|
@@ -960,6 +974,16 @@ export async function startProxy(opts = {}) {
|
|
|
960
974
|
// regex. CLI-level `--model=<provider>:<name>` applies the same override
|
|
961
975
|
// server-wide. Rewrites the body in place once so both code paths below
|
|
962
976
|
// see the stripped model name.
|
|
977
|
+
//
|
|
978
|
+
// MODEL_ALIASES resolution (v3.36): on the claude/anthropic prefix path,
|
|
979
|
+
// resolve short names (`opus`/`sonnet`/`haiku`) to canonical Anthropic
|
|
980
|
+
// model IDs at request time. Without this, `claude:opus` would forward
|
|
981
|
+
// `model: "opus"` upstream and Anthropic 400's it. The CLI parser
|
|
982
|
+
// (--model=opus) already does this at startup; the request-time path
|
|
983
|
+
// didn't until now. Important for the Cursor BYOK workaround in
|
|
984
|
+
// dario#190 where users have to use a colon-prefix to dodge Cursor's
|
|
985
|
+
// built-in `claude-*` name collision (Cursor reroutes any name it
|
|
986
|
+
// recognizes through its own Anthropic gateway, bypassing localhost).
|
|
963
987
|
let forcedProvider = cliProviderOverride;
|
|
964
988
|
if (body.length > 0) {
|
|
965
989
|
try {
|
|
@@ -968,10 +992,14 @@ export async function startProxy(opts = {}) {
|
|
|
968
992
|
const prefix = parseProviderPrefix(rawModel);
|
|
969
993
|
if (prefix) {
|
|
970
994
|
forcedProvider = prefix.provider;
|
|
971
|
-
|
|
995
|
+
const resolvedModel = prefix.provider === 'claude'
|
|
996
|
+
? resolveClaudeAlias(prefix.model)
|
|
997
|
+
: prefix.model;
|
|
998
|
+
parsed.model = resolvedModel;
|
|
972
999
|
body = Buffer.from(JSON.stringify(parsed));
|
|
973
1000
|
if (verbose) {
|
|
974
|
-
|
|
1001
|
+
const aliasNote = resolvedModel !== prefix.model ? ` (alias: ${prefix.model} → ${resolvedModel})` : '';
|
|
1002
|
+
console.log(`[dario] provider prefix: ${rawModel} → ${prefix.provider} backend with model ${resolvedModel}${aliasNote}`);
|
|
975
1003
|
}
|
|
976
1004
|
}
|
|
977
1005
|
else if (cliProviderOverride === 'openai' && cliModelRaw) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askalf/dario",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.36.0",
|
|
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": {
|